GBA Video: Allow windows that end at 256

This commit is contained in:
Vicki Pfau 2017-03-19 14:30:40 -07:00
parent 2a5aac5868
commit 25a8b125ed
2 changed files with 14 additions and 8 deletions

View File

@ -80,8 +80,8 @@ enum {
#define IS_WRITABLE(PIXEL) ((PIXEL) & 0xFE000000) #define IS_WRITABLE(PIXEL) ((PIXEL) & 0xFE000000)
struct WindowRegion { struct WindowRegion {
uint8_t end; int end;
uint8_t start; int start;
}; };
DECL_BITFIELD(GBAWindowControl, uint8_t); DECL_BITFIELD(GBAWindowControl, uint8_t);
@ -168,7 +168,7 @@ struct GBAVideoSoftwareRenderer {
int start; int start;
int end; int end;
int masterEnd; int masterEnd;
unsigned masterHeight; int masterHeight;
int masterScanlines; int masterScanlines;
int masterBright; int masterBright;

View File

@ -282,7 +282,7 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender
} }
break; break;
case REG_WIN0H: case REG_WIN0H:
softwareRenderer->winN[0].h.end = value; softwareRenderer->winN[0].h.end = value & 0xFF;
softwareRenderer->winN[0].h.start = value >> 8; softwareRenderer->winN[0].h.start = value >> 8;
if (softwareRenderer->winN[0].h.start > softwareRenderer->masterEnd && softwareRenderer->winN[0].h.start > softwareRenderer->winN[0].h.end) { if (softwareRenderer->winN[0].h.start > softwareRenderer->masterEnd && softwareRenderer->winN[0].h.start > softwareRenderer->winN[0].h.end) {
softwareRenderer->winN[0].h.start = 0; softwareRenderer->winN[0].h.start = 0;
@ -293,9 +293,12 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender
softwareRenderer->winN[0].h.start = softwareRenderer->masterEnd; softwareRenderer->winN[0].h.start = softwareRenderer->masterEnd;
} }
} }
if (softwareRenderer->masterEnd > 0xFF && softwareRenderer->winN[0].h.end == (softwareRenderer->masterEnd & 0xFF) && softwareRenderer->winN[0].h.start != softwareRenderer->winN[0].h.end) {
softwareRenderer->winN[0].h.end = softwareRenderer->masterEnd;
}
break; break;
case REG_WIN1H: case REG_WIN1H:
softwareRenderer->winN[1].h.end = value; softwareRenderer->winN[1].h.end = value & 0xFF;
softwareRenderer->winN[1].h.start = value >> 8; softwareRenderer->winN[1].h.start = value >> 8;
if (softwareRenderer->winN[1].h.start > softwareRenderer->masterEnd && softwareRenderer->winN[1].h.start > softwareRenderer->winN[1].h.end) { if (softwareRenderer->winN[1].h.start > softwareRenderer->masterEnd && softwareRenderer->winN[1].h.start > softwareRenderer->winN[1].h.end) {
softwareRenderer->winN[1].h.start = 0; softwareRenderer->winN[1].h.start = 0;
@ -306,9 +309,12 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender
softwareRenderer->winN[1].h.start = softwareRenderer->masterEnd; softwareRenderer->winN[1].h.start = softwareRenderer->masterEnd;
} }
} }
if (softwareRenderer->masterEnd > 0xFF && softwareRenderer->winN[1].h.end == (softwareRenderer->masterEnd & 0xFF) && softwareRenderer->winN[1].h.start != softwareRenderer->winN[1].h.end) {
softwareRenderer->winN[1].h.end = softwareRenderer->masterEnd;
}
break; break;
case REG_WIN0V: case REG_WIN0V:
softwareRenderer->winN[0].v.end = value; softwareRenderer->winN[0].v.end = value & 0xFF;
softwareRenderer->winN[0].v.start = value >> 8; softwareRenderer->winN[0].v.start = value >> 8;
if (softwareRenderer->winN[0].v.start > softwareRenderer->masterHeight && softwareRenderer->winN[0].v.start > softwareRenderer->winN[0].v.end) { if (softwareRenderer->winN[0].v.start > softwareRenderer->masterHeight && softwareRenderer->winN[0].v.start > softwareRenderer->winN[0].v.end) {
softwareRenderer->winN[0].v.start = 0; softwareRenderer->winN[0].v.start = 0;
@ -321,7 +327,7 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender
} }
break; break;
case REG_WIN1V: case REG_WIN1V:
softwareRenderer->winN[1].v.end = value; softwareRenderer->winN[1].v.end = value & 0xFF;
softwareRenderer->winN[1].v.start = value >> 8; softwareRenderer->winN[1].v.start = value >> 8;
if (softwareRenderer->winN[1].v.start > softwareRenderer->masterHeight && softwareRenderer->winN[1].v.start > softwareRenderer->winN[1].v.end) { if (softwareRenderer->winN[1].v.start > softwareRenderer->masterHeight && softwareRenderer->winN[1].v.start > softwareRenderer->winN[1].v.end) {
softwareRenderer->winN[1].v.start = 0; softwareRenderer->winN[1].v.start = 0;
@ -607,7 +613,7 @@ static void GBAVideoSoftwareRendererPutPixels(struct GBAVideoRenderer* renderer,
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer; struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
const color_t* colorPixels = pixels; const color_t* colorPixels = pixels;
unsigned i; int i;
for (i = 0; i < softwareRenderer->masterHeight; ++i) { for (i = 0; i < softwareRenderer->masterHeight; ++i) {
memmove(&softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * i], &colorPixels[stride * i], softwareRenderer->masterEnd * BYTES_PER_PIXEL); memmove(&softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * i], &colorPixels[stride * i], softwareRenderer->masterEnd * BYTES_PER_PIXEL);
} }