all repos — mgba @ 2cd339d3f6075e8e68a5ea5dd81d06ea3e10aac8

mGBA Game Boy Advance Emulator

GB Video: Implement ATTR_DIV
Vicki Pfau vi@endrift.com
Sat, 21 Apr 2018 17:36:42 -0700
commit

2cd339d3f6075e8e68a5ea5dd81d06ea3e10aac8

parent

f29cff2e2f36b8af71d88052cf8d3e26056d6c11

2 files changed, 53 insertions(+), 0 deletions(-)

jump to
M src/gb/renderers/software.csrc/gb/renderers/software.c

@@ -264,6 +264,9 @@ int sets;

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];

@@ -282,6 +285,55 @@ sets = softwareRenderer->sgbPacket[1];

i = 2; for (; i < (softwareRenderer->sgbCommandHeader & 7) << 4 && sets; i += 6, --sets) { _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:
M src/gb/video.csrc/gb/video.c

@@ -692,6 +692,7 @@ video->renderer->writePalette(video->renderer, i * 4 + 3, video->palette[i * 4 + 3]);

} break; case SGB_ATTR_BLK: + case SGB_ATTR_DIV: case SGB_ATTR_CHR: case SGB_PAL_TRN: case SGB_ATRC_EN: