GB: Fix running beyond the end of the video buffer

This commit is contained in:
Jeffrey Pfau 2016-02-21 02:23:40 -08:00
parent 3ead128a2d
commit dd39a0add4
1 changed files with 4 additions and 1 deletions

View File

@ -130,7 +130,7 @@ static void GBVideoSoftwareRendererDrawRange(struct GBVideoRenderer* renderer, i
} }
color_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y]; color_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y];
int x; 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] = softwareRenderer->palette[softwareRenderer->row[x] & 0x7F];
row[x + 1] = softwareRenderer->palette[softwareRenderer->row[x + 1] & 0x7F]; row[x + 1] = softwareRenderer->palette[softwareRenderer->row[x + 1] & 0x7F];
row[x + 2] = softwareRenderer->palette[softwareRenderer->row[x + 2] & 0x7F]; row[x + 2] = softwareRenderer->palette[softwareRenderer->row[x + 2] & 0x7F];
@ -140,6 +140,9 @@ static void GBVideoSoftwareRendererDrawRange(struct GBVideoRenderer* renderer, i
row[x + 6] = softwareRenderer->palette[softwareRenderer->row[x + 6] & 0x7F]; row[x + 6] = softwareRenderer->palette[softwareRenderer->row[x + 6] & 0x7F];
row[x + 7] = softwareRenderer->palette[softwareRenderer->row[x + 7] & 0x7F]; row[x + 7] = softwareRenderer->palette[softwareRenderer->row[x + 7] & 0x7F];
} }
for (; x < endX; ++x) {
row[x] = softwareRenderer->palette[softwareRenderer->row[x] & 0x7F];
}
} }
static void GBVideoSoftwareRendererFinishScanline(struct GBVideoRenderer* renderer, int y) { static void GBVideoSoftwareRendererFinishScanline(struct GBVideoRenderer* renderer, int y) {