mirror of https://github.com/mgba-emu/mgba.git
GBA Memory: Fix several unused I/O register read values
This commit is contained in:
parent
11486fea77
commit
e6b4144ba2
1
CHANGES
1
CHANGES
|
@ -24,6 +24,7 @@ Bugfixes:
|
|||
- 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
|
||||
|
|
21
src/gba/io.c
21
src/gba/io.c
|
@ -742,26 +742,30 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) {
|
|||
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:
|
||||
case REG_POSTFLG:
|
||||
|
@ -832,6 +836,15 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) {
|
|||
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);
|
||||
|
|
|
@ -367,7 +367,7 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
|
|||
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 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
|||
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 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
|
|||
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 @@ void GBAStore16(struct ARMCore* cpu, uint32_t address, int16_t value, int* cycle
|
|||
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 @@ void GBAStore8(struct ARMCore* cpu, uint32_t address, int8_t value, int* cycleCo
|
|||
((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);
|
||||
|
|
Loading…
Reference in New Issue