Support writing to palette, display palette on screen
Jeffrey Pfau jeffrey@endrift.com
Sat, 20 Apr 2013 22:08:58 -0700
2 files changed,
22 insertions(+),
0 deletions(-)
M
src/gba/gba-memory.c
→
src/gba/gba-memory.c
@@ -288,6 +288,8 @@ case BASE_IO:
GBAIOWrite32(gbaMemory->p, address & (SIZE_IO - 1), value); break; case BASE_PALETTE_RAM: + gbaMemory->p->video.palette[(address & (SIZE_PALETTE_RAM - 1)) >> 1] = value; + gbaMemory->p->video.palette[((address & (SIZE_PALETTE_RAM - 1)) >> 1) + 1] = value >> 16; break; case BASE_VRAM: break;@@ -318,6 +320,7 @@ case BASE_IO:
GBAIOWrite(gbaMemory->p, address & (SIZE_IO - 1), value); break; case BASE_PALETTE_RAM: + gbaMemory->p->video.palette[(address & (SIZE_PALETTE_RAM - 1)) >> 1] = value; break; case BASE_VRAM: break;
M
src/gba/renderers/video-software.c
→
src/gba/renderers/video-software.c
@@ -41,6 +41,25 @@ }
static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* renderer, int y) { struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer; + int x; + uint16_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y]; + for (x = 0; x < 16; ++x) { + row[(x * 15) + 0] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 1] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 2] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 3] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 4] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 5] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 6] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 7] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 8] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 9] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 10] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 11] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 12] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 13] = renderer->palette[x + (y / 5) * 16]; + row[(x * 15) + 14] = renderer->palette[x + (y / 5) * 16]; + } } static void GBAVideoSoftwareRendererFinishFrame(struct GBAVideoRenderer* renderer) {