Support writing to palette, display palette on screen

This commit is contained in:
Jeffrey Pfau 2013-04-20 22:08:58 -07:00
parent 2860714714
commit 71986b0477
2 changed files with 22 additions and 0 deletions

View File

@ -288,6 +288,8 @@ void GBAStore32(struct ARMMemory* memory, uint32_t address, int32_t value) {
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 @@ void GBAStore16(struct ARMMemory* memory, uint32_t address, int16_t value) {
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;

View File

@ -41,6 +41,25 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender
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) {