From eee291e00eab0fd6d75af8c003a292fff045b866 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 9 Nov 2015 22:44:46 -0800 Subject: [PATCH] GBA: Implement bad I/O register loading --- CHANGES | 1 + src/gba/io.c | 32 ++++++++++++++++++++++++++++++ src/gba/renderers/video-software.c | 12 +++++++---- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index f8da4b526..277cc18fb 100644 --- a/CHANGES +++ b/CHANGES @@ -38,6 +38,7 @@ Misc: - GBA Audio: Implement missing flags on SOUNDCNT_X register - Util: Use VFile for configuration - GBA Memory: Implement several unimplemented memory access types + - GBA: Implement bad I/O register loading 0.3.1: (2015-10-24) Bugfixes: diff --git a/src/gba/io.c b/src/gba/io.c index d62ceeb42..7c935ddc2 100644 --- a/src/gba/io.c +++ b/src/gba/io.c @@ -636,6 +636,38 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) { case REG_DMA3CNT_LO: // Write-only register return 0; + case REG_BG0HOFS: + case REG_BG0VOFS: + case REG_BG1HOFS: + case REG_BG1VOFS: + case REG_BG2HOFS: + case REG_BG2VOFS: + case REG_BG3HOFS: + case REG_BG3VOFS: + case REG_BG2PA: + case REG_BG2PB: + case REG_BG2PC: + case REG_BG2PD: + case REG_BG2X_LO: + case REG_BG2X_HI: + case REG_BG2Y_LO: + case REG_BG2Y_HI: + case REG_BG3PA: + case REG_BG3PB: + case REG_BG3PC: + case REG_BG3PD: + case REG_BG3X_LO: + case REG_BG3X_HI: + case REG_BG3Y_LO: + case REG_BG3Y_HI: + case REG_WIN0H: + case REG_WIN1H: + case REG_WIN0V: + case REG_WIN1V: + case REG_MOSAIC: + case REG_BLDY: + // Write-only register + return GBALoad16(gba->cpu, 0x01000000, 0); // Simulate a bad load case REG_DISPCNT: case REG_DISPSTAT: case REG_VCOUNT: diff --git a/src/gba/renderers/video-software.c b/src/gba/renderers/video-software.c index ab9e98b0f..cafd7d7f5 100644 --- a/src/gba/renderers/video-software.c +++ b/src/gba/renderers/video-software.c @@ -145,19 +145,19 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender GBAVideoSoftwareRendererUpdateDISPCNT(softwareRenderer); break; case REG_BG0CNT: - value &= 0xFFCF; + value &= 0xDFFF; GBAVideoSoftwareRendererWriteBGCNT(softwareRenderer, &softwareRenderer->bg[0], value); break; case REG_BG1CNT: - value &= 0xFFCF; + value &= 0xDFFF; GBAVideoSoftwareRendererWriteBGCNT(softwareRenderer, &softwareRenderer->bg[1], value); break; case REG_BG2CNT: - value &= 0xFFCF; + value &= 0xFFFF; GBAVideoSoftwareRendererWriteBGCNT(softwareRenderer, &softwareRenderer->bg[2], value); break; case REG_BG3CNT: - value &= 0xFFCF; + value &= 0xFFFF; GBAVideoSoftwareRendererWriteBGCNT(softwareRenderer, &softwareRenderer->bg[3], value); break; case REG_BG0HOFS: @@ -242,6 +242,7 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender break; case REG_BLDCNT: GBAVideoSoftwareRendererWriteBLDCNT(softwareRenderer, value); + value &= 0x3FFF; break; case REG_BLDALPHA: softwareRenderer->blda = value & 0x1F; @@ -252,6 +253,7 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender if (softwareRenderer->bldb > 0x10) { softwareRenderer->bldb = 0x10; } + value &= 0x1F1F; break; case REG_BLDY: softwareRenderer->bldy = value & 0x1F; @@ -313,10 +315,12 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender } break; case REG_WININ: + value &= 0x3F3F; softwareRenderer->winN[0].control.packed = value; softwareRenderer->winN[1].control.packed = value >> 8; break; case REG_WINOUT: + value &= 0x3F3F; softwareRenderer->winout.packed = value; softwareRenderer->objwin.packed = value >> 8; break;