GBA: Implement bad I/O register loading

This commit is contained in:
Jeffrey Pfau 2015-11-09 22:44:46 -08:00
parent b3d08eceb1
commit eee291e00e
3 changed files with 41 additions and 4 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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;