Pass off video registers to renderer
Jeffrey Pfau jeffrey@endrift.com
Sun, 21 Apr 2013 12:39:33 -0700
2 files changed,
90 insertions(+),
82 deletions(-)
M
src/gba/gba-io.c
→
src/gba/gba-io.c
@@ -7,93 +7,97 @@ gba->memory.io[REG_KEYINPUT >> 1] = 0x3FF;
} void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value) { - switch (address) { - // Video - case REG_DISPSTAT: - GBAVideoWriteDISPSTAT(&gba->video, value); - break; + if (address < REG_SOUND1CNT_LO && address != REG_DISPSTAT) { + gba->video.renderer->writeVideoRegister(gba->video.renderer, address, value); + } else { + switch (address) { + // Video + case REG_DISPSTAT: + GBAVideoWriteDISPSTAT(&gba->video, value); + break; - // DMA - case REG_DMA0CNT_LO: - GBAMemoryWriteDMACNT_LO(&gba->memory, 0, value); - break; - case REG_DMA0CNT_HI: - value = GBAMemoryWriteDMACNT_HI(&gba->memory, 0, value); - break; - case REG_DMA1CNT_LO: - GBAMemoryWriteDMACNT_LO(&gba->memory, 1, value); - break; - case REG_DMA1CNT_HI: - value = GBAMemoryWriteDMACNT_HI(&gba->memory, 1, value); - break; - case REG_DMA2CNT_LO: - GBAMemoryWriteDMACNT_LO(&gba->memory, 2, value); - break; - case REG_DMA2CNT_HI: - value = GBAMemoryWriteDMACNT_HI(&gba->memory, 2, value); - break; - case REG_DMA3CNT_LO: - GBAMemoryWriteDMACNT_LO(&gba->memory, 3, value); - break; - case REG_DMA3CNT_HI: - value = GBAMemoryWriteDMACNT_HI(&gba->memory, 3, value); - break; + // DMA + case REG_DMA0CNT_LO: + GBAMemoryWriteDMACNT_LO(&gba->memory, 0, value); + break; + case REG_DMA0CNT_HI: + value = GBAMemoryWriteDMACNT_HI(&gba->memory, 0, value); + break; + case REG_DMA1CNT_LO: + GBAMemoryWriteDMACNT_LO(&gba->memory, 1, value); + break; + case REG_DMA1CNT_HI: + value = GBAMemoryWriteDMACNT_HI(&gba->memory, 1, value); + break; + case REG_DMA2CNT_LO: + GBAMemoryWriteDMACNT_LO(&gba->memory, 2, value); + break; + case REG_DMA2CNT_HI: + value = GBAMemoryWriteDMACNT_HI(&gba->memory, 2, value); + break; + case REG_DMA3CNT_LO: + GBAMemoryWriteDMACNT_LO(&gba->memory, 3, value); + break; + case REG_DMA3CNT_HI: + value = GBAMemoryWriteDMACNT_HI(&gba->memory, 3, value); + break; - // Timers - case REG_TM0CNT_LO: - GBATimerWriteTMCNT_LO(gba, 0, value); - return; - case REG_TM1CNT_LO: - GBATimerWriteTMCNT_LO(gba, 1, value); - return; - case REG_TM2CNT_LO: - GBATimerWriteTMCNT_LO(gba, 2, value); - return; - case REG_TM3CNT_LO: - GBATimerWriteTMCNT_LO(gba, 3, value); - return; + // Timers + case REG_TM0CNT_LO: + GBATimerWriteTMCNT_LO(gba, 0, value); + return; + case REG_TM1CNT_LO: + GBATimerWriteTMCNT_LO(gba, 1, value); + return; + case REG_TM2CNT_LO: + GBATimerWriteTMCNT_LO(gba, 2, value); + return; + case REG_TM3CNT_LO: + GBATimerWriteTMCNT_LO(gba, 3, value); + return; - case REG_TM0CNT_HI: - value &= 0x00C7; - GBATimerWriteTMCNT_HI(gba, 0, value); - break; - case REG_TM1CNT_HI: - value &= 0x00C7; - GBATimerWriteTMCNT_HI(gba, 1, value); - break; - case REG_TM2CNT_HI: - value &= 0x00C7; - GBATimerWriteTMCNT_HI(gba, 2, value); - break; - case REG_TM3CNT_HI: - value &= 0x00C7; - GBATimerWriteTMCNT_HI(gba, 3, value); - break; + case REG_TM0CNT_HI: + value &= 0x00C7; + GBATimerWriteTMCNT_HI(gba, 0, value); + break; + case REG_TM1CNT_HI: + value &= 0x00C7; + GBATimerWriteTMCNT_HI(gba, 1, value); + break; + case REG_TM2CNT_HI: + value &= 0x00C7; + GBATimerWriteTMCNT_HI(gba, 2, value); + break; + case REG_TM3CNT_HI: + value &= 0x00C7; + GBATimerWriteTMCNT_HI(gba, 3, value); + break; - // Interrupts and misc - case REG_WAITCNT: - GBAAdjustWaitstates(&gba->memory, value); - break; - case REG_IE: - GBAWriteIE(gba, value); - break; - case REG_IF: - value = gba->memory.io[REG_IF >> 1] & ~value; - break; - case REG_IME: - GBAWriteIME(gba, value); - break; - case REG_HALTCNT: - value &= 0x80; - if (!value) { - GBAHalt(gba); - } else { - GBALog(GBA_LOG_STUB, "Stop unimplemented"); + // Interrupts and misc + case REG_WAITCNT: + GBAAdjustWaitstates(&gba->memory, value); + break; + case REG_IE: + GBAWriteIE(gba, value); + break; + case REG_IF: + value = gba->memory.io[REG_IF >> 1] & ~value; + break; + case REG_IME: + GBAWriteIME(gba, value); + break; + case REG_HALTCNT: + value &= 0x80; + if (!value) { + GBAHalt(gba); + } else { + GBALog(GBA_LOG_STUB, "Stop unimplemented"); + } + return; + default: + GBALog(GBA_LOG_STUB, "Stub I/O register write: %03x", address); + break; } - return; - default: - GBALog(GBA_LOG_STUB, "Stub I/O register write: %03x", address); - break; } gba->memory.io[address >> 1] = value; }
M
src/gba/renderers/video-software.c
→
src/gba/renderers/video-software.c
@@ -36,6 +36,10 @@ }
static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRenderer* renderer, uint32_t address, uint16_t value) { struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer; + switch (address) { + default: + GBALog(GBA_LOG_STUB, "Stub video register write: %03x", address); + } return value; }