- for (i = 0; i < 4 && w > 0; i++) {
- if (x < 512) {
- wb = w;
- if (x + w > 512)
- wb = 512 - x;
- src = gpu.vram + xt * i + y * 1024 + x;
- dst = egpu.enhancement_buf_ptr +
- (1024*1024 + xt * 2) * i + (y * 1024 + x) * 2;
- scale2x_tiles8(dst, src, wb / 8, h);
- }
-
- x -= xt;
- if (x < 0) {
- w += x;
- x = 0;
- }
+ while (w > 0) {
+ fb_index = egpu.enhancement_buf_by_x16[x / step_x];
+ for (w1 = 0; w > 0; w1++, w -= step_x)
+ if (fb_index != egpu.enhancement_buf_by_x16[x / step_x + w1])
+ break;
+
+ src = gpu.vram + y * 1024 + x;
+ dst = select_enhancement_buf_ptr(&egpu, x);
+ dst += (y * 1024 + x) * 2;
+ scale2x_tiles8(dst, src, w1 * step_x / 8, h);
+
+ x += w1 * step_x;