GBA Memory: Fix several unused I/O register read values
Jeffrey Pfau jeffrey@endrift.com
Wed, 28 Sep 2016 12:37:39 -0700
3 files changed,
23 insertions(+),
9 deletions(-)
M
CHANGES
→
CHANGES
@@ -24,6 +24,7 @@ - GB MBC: Fix RTC access when no save file is loaded
- GB: Properly clear KEY1 bit 0 when switching speeds - LR35902: Fix core never exiting with certain event patterns - GBA Cheats: Fix uninitialized memory getting freed when saving + - GBA Memory: Fix several unused I/O register read values Misc: - All: Only update version info if needed - FFmpeg: Encoding cleanup
M
src/gba/io.c
→
src/gba/io.c
@@ -742,25 +742,29 @@ case REG_DMA0SAD_LO:
case REG_DMA0SAD_HI: case REG_DMA0DAD_LO: case REG_DMA0DAD_HI: - case REG_DMA0CNT_LO: case REG_DMA1SAD_LO: case REG_DMA1SAD_HI: case REG_DMA1DAD_LO: case REG_DMA1DAD_HI: - case REG_DMA1CNT_LO: case REG_DMA2SAD_LO: case REG_DMA2SAD_HI: case REG_DMA2DAD_LO: case REG_DMA2DAD_HI: - case REG_DMA2CNT_LO: case REG_DMA3SAD_LO: case REG_DMA3SAD_HI: case REG_DMA3DAD_LO: case REG_DMA3DAD_HI: - case REG_DMA3CNT_LO: // Write-only register mLOG(GBA_IO, GAME_ERROR, "Read from write-only I/O register: %03X", address); return GBALoadBad(gba->cpu); + + case REG_DMA0CNT_LO: + case REG_DMA1CNT_LO: + case REG_DMA2CNT_LO: + case REG_DMA3CNT_LO: + // Write-only register + mLOG(GBA_IO, GAME_ERROR, "Read from write-only I/O register: %03X", address); + return 0; case REG_SOUNDBIAS: case REG_KEYCNT:@@ -832,6 +836,15 @@ break;
case REG_MAX: // Some bad interrupt libraries will read from this break; + case 0x66: + case 0x6E: + case 0x76: + case 0x7A: + case 0x7E: + case 0x86: + case 0x8A: + mLOG(GBA_IO, GAME_ERROR, "Read from unused I/O register: %03X", address); + return 0; default: mLOG(GBA_IO, GAME_ERROR, "Read from unused I/O register: %03X", address); return GBALoadBad(gba->cpu);
M
src/gba/memory.c
→
src/gba/memory.c
@@ -367,7 +367,7 @@ LOAD_32(value, address & (SIZE_WORKING_RAM - 4), memory->wram); \
wait += waitstatesRegion[REGION_WORKING_RAM]; #define LOAD_WORKING_IRAM LOAD_32(value, address & (SIZE_WORKING_IRAM - 4), memory->iwram); -#define LOAD_IO value = GBAIORead(gba, (address & (SIZE_IO - 1)) & ~2) | (GBAIORead(gba, (address & (SIZE_IO - 1)) | 2) << 16); +#define LOAD_IO value = GBAIORead(gba, address & OFFSET_MASK & ~2) | (GBAIORead(gba, (address & OFFSET_MASK) | 2) << 16); #define LOAD_PALETTE_RAM \ LOAD_32(value, address & (SIZE_PALETTE_RAM - 4), gba->video.palette); \@@ -498,7 +498,7 @@ case REGION_WORKING_IRAM:
LOAD_16(value, address & (SIZE_WORKING_IRAM - 2), memory->iwram); break; case REGION_IO: - value = GBAIORead(gba, address & (SIZE_IO - 2)); + value = GBAIORead(gba, address & (OFFSET_MASK - 1)); break; case REGION_PALETTE_RAM: LOAD_16(value, address & (SIZE_PALETTE_RAM - 2), gba->video.palette);@@ -679,7 +679,7 @@ #define STORE_WORKING_IRAM \
STORE_32(value, address & (SIZE_WORKING_IRAM - 4), memory->iwram); #define STORE_IO \ - GBAIOWrite32(gba, address & (SIZE_IO - 4), value); + GBAIOWrite32(gba, address & (OFFSET_MASK - 3), value); #define STORE_PALETTE_RAM \ STORE_32(value, address & (SIZE_PALETTE_RAM - 4), gba->video.palette); \@@ -786,7 +786,7 @@ case REGION_WORKING_IRAM:
STORE_16(value, address & (SIZE_WORKING_IRAM - 2), memory->iwram); break; case REGION_IO: - GBAIOWrite(gba, address & (SIZE_IO - 2), value); + GBAIOWrite(gba, address & (OFFSET_MASK - 1), value); break; case REGION_PALETTE_RAM: STORE_16(value, address & (SIZE_PALETTE_RAM - 2), gba->video.palette);@@ -853,7 +853,7 @@ case REGION_WORKING_IRAM:
((int8_t*) memory->iwram)[address & (SIZE_WORKING_IRAM - 1)] = value; break; case REGION_IO: - GBAIOWrite8(gba, address & (SIZE_IO - 1), value); + GBAIOWrite8(gba, address & OFFSET_MASK, value); break; case REGION_PALETTE_RAM: GBAStore16(cpu, address & ~1, ((uint8_t) value) | ((uint8_t) value << 8), cycleCounter);