diff options
| author | Peter Fors <peter.fors@mindkiller.com> | 2025-04-06 12:27:12 +0200 |
|---|---|---|
| committer | Peter Fors <peter.fors@mindkiller.com> | 2025-04-06 12:27:12 +0200 |
| commit | 39715ca6bf65d2e2dd889cdef4b39d584464d9e7 (patch) | |
| tree | 39390f6fadd0ddbe913ae66e11847b8b3e7b16bb /mapper_0007.c | |
| parent | dabd7a5848e6aa55e91cf4c804f6236b4f7fe30e (diff) | |
added more mappers (buggy)
Diffstat (limited to 'mapper_0007.c')
| -rw-r--r-- | mapper_0007.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/mapper_0007.c b/mapper_0007.c new file mode 100644 index 0000000..c1ad7fa --- /dev/null +++ b/mapper_0007.c @@ -0,0 +1,44 @@ +static void mapper_0007_init(struct nes_state *state) { + state->map.m0007.prg_ptr = state->prg_rom; + state->map.m0007.mirroring = 0; +} + +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 0; +} + +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; + } +} + +static uint8_t mapper_0007_chr_read(struct nes_state *state, uint32_t addr) { + return state->chr_ram[addr]; +} + +static void mapper_0007_chr_write(struct nes_state *state, uint32_t addr, uint8_t value) { + state->chr_ram[addr] = value; +} + +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; + } + 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; + } + state->ciram[addr] = value; +} |
