GB Video: Implement ATTR_DIV

This commit is contained in:
Vicki Pfau 2018-04-21 17:36:42 -07:00
parent f29cff2e2f
commit 2cd339d3f6
2 changed files with 53 additions and 0 deletions

View File

@ -264,6 +264,9 @@ static void GBVideoSoftwareRendererWriteSGBPacket(struct GBVideoRenderer* render
int attrX;
int attrY;
int attrDirection;
int pBefore;
int pAfter;
int pDiv;
switch (softwareRenderer->sgbCommandHeader >> 3) {
case SGB_PAL_SET:
softwareRenderer->sgbPacket[1] = data[9];
@ -284,6 +287,55 @@ static void GBVideoSoftwareRendererWriteSGBPacket(struct GBVideoRenderer* render
_parseAttrBlock(softwareRenderer, i);
}
break;
case SGB_ATTR_DIV:
pAfter = softwareRenderer->sgbPacket[1] & 3;
pBefore = (softwareRenderer->sgbPacket[1] >> 2) & 3;
pDiv = (softwareRenderer->sgbPacket[1] >> 4) & 3;
attrX = softwareRenderer->sgbPacket[2];
if (softwareRenderer->sgbPacket[1] & 0x40) {
if (attrX > GB_VIDEO_VERTICAL_PIXELS / 8) {
attrX = GB_VIDEO_VERTICAL_PIXELS / 8;
}
int j;
for (j = 0; j < attrX; ++j) {
for (i = 0; i < GB_VIDEO_HORIZONTAL_PIXELS / 8; ++i) {
_setAttribute(renderer->sgbAttributes, i, j, pBefore);
}
}
if (attrX < GB_VIDEO_VERTICAL_PIXELS / 8) {
for (i = 0; i < GB_VIDEO_HORIZONTAL_PIXELS / 8; ++i) {
_setAttribute(renderer->sgbAttributes, i, attrX, pDiv);
}
}
for (; j < GB_VIDEO_VERTICAL_PIXELS / 8; ++j) {
for (i = 0; i < GB_VIDEO_HORIZONTAL_PIXELS / 8; ++i) {
_setAttribute(renderer->sgbAttributes, i, j, pAfter);
}
}
} else {
if (attrX > GB_VIDEO_HORIZONTAL_PIXELS / 8) {
attrX = GB_VIDEO_HORIZONTAL_PIXELS / 8;
}
int j;
for (j = 0; j < attrX; ++j) {
for (i = 0; i < GB_VIDEO_HORIZONTAL_PIXELS / 8; ++i) {
_setAttribute(renderer->sgbAttributes, j, i, pBefore);
}
}
if (attrX < GB_VIDEO_HORIZONTAL_PIXELS / 8) {
for (i = 0; i < GB_VIDEO_VERTICAL_PIXELS / 8; ++i) {
_setAttribute(renderer->sgbAttributes, attrX, i, pDiv);
}
}
for (; j < GB_VIDEO_HORIZONTAL_PIXELS / 8; ++j) {
for (i = 0; i < GB_VIDEO_VERTICAL_PIXELS / 8; ++i) {
_setAttribute(renderer->sgbAttributes, j, i, pAfter);
}
}
}
break;
case SGB_ATTR_CHR:
attrX = softwareRenderer->sgbPacket[1];
attrY = softwareRenderer->sgbPacket[2];

View File

@ -692,6 +692,7 @@ void GBVideoWriteSGBPacket(struct GBVideo* video, uint8_t* data) {
}
break;
case SGB_ATTR_BLK:
case SGB_ATTR_DIV:
case SGB_ATTR_CHR:
case SGB_PAL_TRN:
case SGB_ATRC_EN: