GBA: Implement bad I/O register loading
Jeffrey Pfau jeffrey@endrift.com
Mon, 09 Nov 2015 22:44:46 -0800
3 files changed,
41 insertions(+),
4 deletions(-)
M
CHANGES
→
CHANGES
@@ -38,6 +38,7 @@ - All: Fix some undefined behavior warnings
- 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:
M
src/gba/io.c
→
src/gba/io.c
@@ -636,6 +636,38 @@ case REG_DMA2CNT_LO:
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:
M
src/gba/renderers/video-software.c
→
src/gba/renderers/video-software.c
@@ -145,19 +145,19 @@ softwareRenderer->dispcnt = value;
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 @@ GBAVideoSoftwareRendererWriteBGY_HI(&softwareRenderer->bg[3], value);
break; case REG_BLDCNT: GBAVideoSoftwareRendererWriteBLDCNT(softwareRenderer, value); + value &= 0x3FFF; break; case REG_BLDALPHA: softwareRenderer->blda = value & 0x1F;@@ -252,6 +253,7 @@ softwareRenderer->bldb = (value >> 8) & 0x1F;
if (softwareRenderer->bldb > 0x10) { softwareRenderer->bldb = 0x10; } + value &= 0x1F1F; break; case REG_BLDY: softwareRenderer->bldy = value & 0x1F;@@ -313,10 +315,12 @@ }
} 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;