GBA Memory: Fix STM to VRAM (fixes #1430)

This commit is contained in:
Vicki Pfau 2019-05-30 12:26:49 -07:00
parent 0cace151e1
commit ba00cdfc02
2 changed files with 34 additions and 19 deletions

View File

@ -19,6 +19,7 @@ Emulation fixes:
- GB Video: Fix window being enabled mid-scanline (fixes mgba.io/i/1328) - GB Video: Fix window being enabled mid-scanline (fixes mgba.io/i/1328)
- GB I/O: Filter IE top bits properly (fixes mgba.io/i/1329) - GB I/O: Filter IE top bits properly (fixes mgba.io/i/1329)
- GBA Video: Fix wrapped sprite mosaic clamping (fixes mgba.io/i/1432) - GBA Video: Fix wrapped sprite mosaic clamping (fixes mgba.io/i/1432)
- GBA Memory: Fix STM to VRAM (fixes mgba.io/i/1430)
Other fixes: Other fixes:
- Qt: Fix some Qt display driver race conditions - Qt: Fix some Qt display driver race conditions
- Core: Improved lockstep driver reliability (Le Hoang Quyen) - Core: Improved lockstep driver reliability (Le Hoang Quyen)

View File

@ -396,9 +396,10 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
value = 0; \ value = 0; \
break; \ break; \
} \ } \
address &= 0x00017FFC; \ LOAD_32(value, address & 0x00017FFC, gba->video.vram); \
} else { \
LOAD_32(value, address & 0x0001FFFC, gba->video.vram); \
} \ } \
LOAD_32(value, address & 0x0001FFFC, gba->video.vram); \
wait += waitstatesRegion[REGION_VRAM]; wait += waitstatesRegion[REGION_VRAM];
#define LOAD_OAM LOAD_32(value, address & (SIZE_OAM - 4), gba->video.oam.raw); #define LOAD_OAM LOAD_32(value, address & (SIZE_OAM - 4), gba->video.oam.raw);
@ -530,9 +531,10 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
value = 0; value = 0;
break; break;
} }
address &= 0x00017FFE; LOAD_16(value, address & 0x00017FFE, gba->video.vram);
} else {
LOAD_16(value, address & 0x0001FFFE, gba->video.vram);
} }
LOAD_16(value, address & 0x0001FFFE, gba->video.vram);
break; break;
case REGION_OAM: case REGION_OAM:
LOAD_16(value, address & (SIZE_OAM - 2), gba->video.oam.raw); LOAD_16(value, address & (SIZE_OAM - 2), gba->video.oam.raw);
@ -645,9 +647,10 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
value = 0; value = 0;
break; break;
} }
address &= 0x00017FFF; value = ((uint8_t*) gba->video.vram)[address & 0x00017FFF];
} else {
value = ((uint8_t*) gba->video.vram)[address & 0x0001FFFF];
} }
value = ((uint8_t*) gba->video.vram)[address & 0x0001FFFF];
break; break;
case REGION_OAM: case REGION_OAM:
value = ((uint8_t*) gba->video.oam.raw)[address & (SIZE_OAM - 1)]; value = ((uint8_t*) gba->video.oam.raw)[address & (SIZE_OAM - 1)];
@ -734,13 +737,19 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
mLOG(GBA_MEM, GAME_ERROR, "Bad VRAM Store32: 0x%08X", address); \ mLOG(GBA_MEM, GAME_ERROR, "Bad VRAM Store32: 0x%08X", address); \
break; \ break; \
} \ } \
address &= 0x00017FFC; \ LOAD_32(oldValue, address & 0x00017FFC, gba->video.vram); \
} \ if (oldValue != value) { \
LOAD_32(oldValue, address & 0x0001FFFC, gba->video.vram); \ STORE_32(value, address & 0x00017FFC, gba->video.vram); \
if (oldValue != value) { \ gba->video.renderer->writeVRAM(gba->video.renderer, (address & 0x00017FFC) + 2); \
STORE_32(value, address & 0x0001FFFC, gba->video.vram); \ gba->video.renderer->writeVRAM(gba->video.renderer, (address & 0x00017FFC)); \
gba->video.renderer->writeVRAM(gba->video.renderer, (address & 0x0001FFFC) + 2); \ } \
gba->video.renderer->writeVRAM(gba->video.renderer, (address & 0x0001FFFC)); \ } else { \
LOAD_32(oldValue, address & 0x0001FFFC, gba->video.vram); \
if (oldValue != value) { \
STORE_32(value, address & 0x0001FFFC, gba->video.vram); \
gba->video.renderer->writeVRAM(gba->video.renderer, (address & 0x0001FFFC) + 2); \
gba->video.renderer->writeVRAM(gba->video.renderer, (address & 0x0001FFFC)); \
} \
} \ } \
wait += waitstatesRegion[REGION_VRAM]; wait += waitstatesRegion[REGION_VRAM];
@ -855,12 +864,17 @@ void GBAStore16(struct ARMCore* cpu, uint32_t address, int16_t value, int* cycle
mLOG(GBA_MEM, GAME_ERROR, "Bad VRAM Store16: 0x%08X", address); mLOG(GBA_MEM, GAME_ERROR, "Bad VRAM Store16: 0x%08X", address);
break; break;
} }
address &= 0x00017FFE; LOAD_16(oldValue, address & 0x00017FFE, gba->video.vram);
} if (value != oldValue) {
LOAD_16(oldValue, address & 0x0001FFFE, gba->video.vram); STORE_16(value, address & 0x00017FFE, gba->video.vram);
if (value != oldValue) { gba->video.renderer->writeVRAM(gba->video.renderer, address & 0x00017FFE);
STORE_16(value, address & 0x0001FFFE, gba->video.vram); }
gba->video.renderer->writeVRAM(gba->video.renderer, address & 0x0001FFFE); } else {
LOAD_16(oldValue, address & 0x0001FFFE, gba->video.vram);
if (value != oldValue) {
STORE_16(value, address & 0x0001FFFE, gba->video.vram);
gba->video.renderer->writeVRAM(gba->video.renderer, address & 0x0001FFFE);
}
} }
break; break;
case REGION_OAM: case REGION_OAM: