all repos — mgba @ dd39a0add47226109f9789d4834ab969bda0e38f

mGBA Game Boy Advance Emulator

GB: Fix running beyond the end of the video buffer
Jeffrey Pfau jeffrey@endrift.com
Sun, 21 Feb 2016 02:23:40 -0800
commit

dd39a0add47226109f9789d4834ab969bda0e38f

parent

3ead128a2d1868917c2765c3e71571a54a530327

1 files changed, 4 insertions(+), 1 deletions(-)

jump to
M src/gb/renderers/software.csrc/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]; } }