ref: 25c5b4226a514cec1ffb2ce6b46f81adf26fc1cf
parent: 109c2a10c1a1a78a740de4127c132027cb28ba17
author: Snesrev <snesrev@protonmail.com>
date: Thu Sep 22 10:02:26 EDT 2022
The old renderer isn't playing nice with widescreen (Fixes #98)
--- a/snes/ppu.c
+++ b/snes/ppu.c
@@ -206,8 +206,14 @@
ppu_calculateMode7Starts(ppu, line);
for (int x = 0; x < 256; x++)
ppu_handlePixel(ppu, x, line);
+
uint8 *dst = ppu->renderBuffer + ((line - 1) * 2 * ppu->renderPitch);
- memcpy(dst + ppu->renderPitch, dst, 512 * 4);
+
+ if (ppu->extraLeftRight != 0) {
+ memset(dst, 0, 2 * sizeof(uint32) * ppu->extraLeftRight);
+ memset(dst + 2 * sizeof(uint32) * (256 + ppu->extraLeftRight), 0, 2 * sizeof(uint32) * ppu->extraLeftRight);
+ }
+ memcpy(dst + ppu->renderPitch, dst, 2 * sizeof(uint32) * (256 + ppu->extraLeftRight * 2));
}
}
}
@@ -1031,7 +1037,7 @@
}
}
int row = y - 1;
- uint8 *pixelBuffer = (uint8*) &ppu->renderBuffer[row * 2 * ppu->renderPitch + x * 8];
+ uint8 *pixelBuffer = (uint8*) &ppu->renderBuffer[row * 2 * ppu->renderPitch + (x + ppu->extraLeftRight) * 8];
pixelBuffer[0] = ((b2 << 3) | (b2 >> 2)) * ppu->brightness / 15;
pixelBuffer[1] = ((g2 << 3) | (g2 >> 2)) * ppu->brightness / 15;
pixelBuffer[2] = ((r2 << 3) | (r2 >> 2)) * ppu->brightness / 15;