GB: Fix running beyond the end of the video buffer
Jeffrey Pfau jeffrey@endrift.com
Sun, 21 Feb 2016 02:23:40 -0800
1 files changed,
4 insertions(+),
1 deletions(-)
jump to
M
src/gb/renderers/software.c
→
src/gb/renderers/software.c
@@ -130,7 +130,7 @@ }
} color_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y]; int x; - for (x = startX; x < endX; x += 8) { + for (x = startX; x < endX & ~7; x += 8) { row[x] = softwareRenderer->palette[softwareRenderer->row[x] & 0x7F]; row[x + 1] = softwareRenderer->palette[softwareRenderer->row[x + 1] & 0x7F]; row[x + 2] = softwareRenderer->palette[softwareRenderer->row[x + 2] & 0x7F];@@ -139,6 +139,9 @@ row[x + 4] = softwareRenderer->palette[softwareRenderer->row[x + 4] & 0x7F];
row[x + 5] = softwareRenderer->palette[softwareRenderer->row[x + 5] & 0x7F]; row[x + 6] = softwareRenderer->palette[softwareRenderer->row[x + 6] & 0x7F]; row[x + 7] = softwareRenderer->palette[softwareRenderer->row[x + 7] & 0x7F]; + } + for (; x < endX; ++x) { + row[x] = softwareRenderer->palette[softwareRenderer->row[x] & 0x7F]; } }