diff options
| author | Peter Fors <peter.fors@mindkiller.com> | 2025-04-16 12:37:40 +0200 |
|---|---|---|
| committer | Peter Fors <peter.fors@mindkiller.com> | 2025-04-16 12:37:40 +0200 |
| commit | 6321f071ed2ab36242e857a9414b7f4c53092d72 (patch) | |
| tree | 80eb868cc206c932d32943d101e7f337324fa7f4 /mapper_0007.c | |
| parent | 18a2c1406f1fa585f4574cd687b0791e52ab5d7a (diff) | |
Battletoads working
Diffstat (limited to 'mapper_0007.c')
| -rw-r--r-- | mapper_0007.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/mapper_0007.c b/mapper_0007.c index fdb6dbb..235f5bb 100644 --- a/mapper_0007.c +++ b/mapper_0007.c @@ -3,20 +3,20 @@ static void mapper_0007_init(struct nes_state *state) { state->map.m0007.prg_ptr = state->prg_rom; - state->map.m0007.mirroring = 0; + state->map.m0007.ciram_base = 0x000; } static uint8_t mapper_0007_prg_read(struct nes_state *state, uint32_t addr) { if(addr >= 0x8000) { - return state->map.m0007.prg_ptr[addr - 0x8000]; + return state->map.m0007.prg_ptr[addr & 0x7fff]; } - return 0; + return 0; // openbus } static void mapper_0007_prg_write(struct nes_state *state, uint32_t addr, uint8_t value) { if(addr >= 0x8000) { - state->map.m0007.prg_ptr = state->prg_rom + ((value & 0x07) * 0x8000); - state->map.m0007.mirroring = (value & 0x10) ? 1 : 0; + state->map.m0007.prg_ptr = state->prg_rom + ((value & 0x0f) * 0x8000); + state->map.m0007.ciram_base = (value & 0x10) ? 0x400 : 0x000; } } @@ -29,19 +29,11 @@ static void mapper_0007_chr_write(struct nes_state *state, uint32_t addr, uint8_ } static uint8_t mapper_0007_ciram_read(struct nes_state *state, uint32_t addr) { - if(state->map.m0007.mirroring == 0) { - addr = (addr & 0x800) | (addr & 0x3ff); - } else { - addr = addr & 0x7ff; - } + addr = state->map.m0007.ciram_base | (addr & 0x3ff); return state->ciram[addr]; } static void mapper_0007_ciram_write(struct nes_state *state, uint32_t addr, uint8_t value) { - if(state->map.m0007.mirroring == 0) { - addr = (addr & 0x800) | (addr & 0x3ff); - } else { - addr = addr & 0x7ff; - } + addr = state->map.m0007.ciram_base | (addr & 0x3ff); state->ciram[addr] = value; } |
