Fix timing on palette RAM and VRAM 32-bit load/stores
Jeffrey Pfau jeffrey@endrift.com
Tue, 21 Oct 2014 23:42:24 -0700
1 files changed,
12 insertions(+),
3 deletions(-)
jump to
M
src/gba/gba-memory.c
→
src/gba/gba-memory.c
@@ -180,8 +180,15 @@ wait += waitstatesRegion[REGION_WORKING_RAM];
#define LOAD_WORKING_IRAM LOAD_32(value, address & (SIZE_WORKING_IRAM - 1), memory->iwram); #define LOAD_IO value = GBAIORead(gba, (address & (SIZE_IO - 1)) & ~2) | (GBAIORead(gba, (address & (SIZE_IO - 1)) | 2) << 16); -#define LOAD_PALETTE_RAM LOAD_32(value, address & (SIZE_PALETTE_RAM - 1), gba->video.palette); -#define LOAD_VRAM LOAD_32(value, address & 0x0001FFFF, gba->video.renderer->vram); + +#define LOAD_PALETTE_RAM \ + LOAD_32(value, address & (SIZE_PALETTE_RAM - 1), gba->video.palette); \ + ++wait; + +#define LOAD_VRAM \ + LOAD_32(value, address & 0x0001FFFF, gba->video.renderer->vram); \ + ++wait; + #define LOAD_OAM LOAD_32(value, address & (SIZE_OAM - 1), gba->video.oam.raw); #define LOAD_CART \@@ -424,6 +431,7 @@
#define STORE_PALETTE_RAM \ STORE_32(value, address & (SIZE_PALETTE_RAM - 1), gba->video.palette); \ gba->video.renderer->writePalette(gba->video.renderer, (address & (SIZE_PALETTE_RAM - 1)) + 2, value >> 16); \ + ++wait; \ gba->video.renderer->writePalette(gba->video.renderer, address & (SIZE_PALETTE_RAM - 1), value); #define STORE_VRAM \@@ -431,7 +439,8 @@ if ((address & OFFSET_MASK) < SIZE_VRAM) { \
STORE_32(value, address & 0x0001FFFF, gba->video.renderer->vram); \ } else if ((address & OFFSET_MASK) < 0x00020000) { \ STORE_32(value, address & 0x00017FFF, gba->video.renderer->vram); \ - } + } \ + ++wait; #define STORE_OAM \ STORE_32(value, address & (SIZE_OAM - 1), gba->video.oam.raw); \