GB Video: Implement SGB ATTR_LINE

This commit is contained in:
Vicki Pfau 2018-04-25 21:19:04 -07:00
parent 88ef2e2169
commit b89b3b6d13
2 changed files with 32 additions and 0 deletions

View File

@ -135,6 +135,30 @@ static void _parseAttrBlock(struct GBVideoSoftwareRenderer* renderer, int start)
}
}
static void _parseAttrLine(struct GBVideoSoftwareRenderer* renderer, int start) {
uint8_t byte = renderer->sgbPacket[start];
unsigned line = byte & 0x1F;
int pal = (byte >> 5) & 3;
if (byte & 0x80) {
if (line > GB_VIDEO_VERTICAL_PIXELS / 8) {
return;
}
int x;
for (x = 0; x < GB_VIDEO_HORIZONTAL_PIXELS / 8; ++x) {
_setAttribute(renderer->d.sgbAttributes, x, line, pal);
}
} else {
if (line > GB_VIDEO_HORIZONTAL_PIXELS / 8) {
return;
}
int y;
for (y = 0; y < GB_VIDEO_VERTICAL_PIXELS / 8; ++y) {
_setAttribute(renderer->d.sgbAttributes, line, y, pal);
}
}
}
static bool _inWindow(struct GBVideoSoftwareRenderer* renderer) {
return GBRegisterLCDCIsWindow(renderer->lcdc) && GB_VIDEO_HORIZONTAL_PIXELS + 7 > renderer->wx;
}
@ -287,6 +311,13 @@ static void GBVideoSoftwareRendererWriteSGBPacket(struct GBVideoRenderer* render
_parseAttrBlock(softwareRenderer, i);
}
break;
case SGB_ATTR_LIN:
sets = softwareRenderer->sgbPacket[1];
i = 2;
for (; i < (softwareRenderer->sgbCommandHeader & 7) << 4 && sets; ++i, --sets) {
_parseAttrLine(softwareRenderer, i);
}
break;
case SGB_ATTR_DIV:
pAfter = softwareRenderer->sgbPacket[1] & 3;
pBefore = (softwareRenderer->sgbPacket[1] >> 2) & 3;

View File

@ -694,6 +694,7 @@ void GBVideoWriteSGBPacket(struct GBVideo* video, uint8_t* data) {
case SGB_ATTR_BLK:
case SGB_ATTR_DIV:
case SGB_ATTR_CHR:
case SGB_ATTR_LIN:
case SGB_PAL_TRN:
case SGB_ATRC_EN:
case SGB_CHR_TRN: