diff options
Diffstat (limited to 'mapper.c')
| -rw-r--r-- | mapper.c | 36 |
1 files changed, 24 insertions, 12 deletions
@@ -7,15 +7,19 @@ struct mapper_entry { int id; - uint8_t (*read)(struct nes_state *state, uint32_t addr); - void (*write)(struct nes_state *state, uint32_t addr, uint8_t value); + uint8_t (*prg_read)(struct nes_state *state, uint32_t addr); + void (*prg_write)(struct nes_state *state, uint32_t addr, uint8_t value); + uint8_t (*chr_read)(struct nes_state *state, uint32_t addr); + void (*chr_write)(struct nes_state *state, uint32_t addr, uint8_t value); + uint8_t (*ciram_read)(struct nes_state *state, uint32_t addr); + void (*ciram_write)(struct nes_state *state, uint32_t addr, uint8_t value); void (*tick)(struct nes_state *state); void (*init)(struct nes_state *state); }; static struct mapper_entry mapper_table[] = { - { 0, mapper_001_read, mapper_001_write, mapper_001_tick, mapper_001_init }, - { 66, mapper_066_read, mapper_066_write, mapper_066_tick, mapper_066_init }, + { 0, mapper_001_prg_read, mapper_001_prg_write, mapper_001_chr_read, mapper_001_chr_write, mapper_001_ciram_read, mapper_001_ciram_write, mapper_001_tick, mapper_001_init }, + { 66, mapper_066_prg_read, mapper_066_prg_write, mapper_066_chr_read, mapper_066_chr_write, mapper_066_ciram_read, mapper_066_ciram_write, mapper_066_tick, mapper_066_init }, // { 1, mapper_mmc1_read, ... }, etc }; @@ -23,10 +27,14 @@ static void mapper_setup(struct nes_state *state) { uint32_t mapper = state->ines.mapper; for(uint32_t i = 0; i < sizeof(mapper_table)/sizeof(mapper_table[0]); i++) { if(mapper_table[i].id == mapper) { - state->mapper.read = mapper_table[i].read; - state->mapper.write = mapper_table[i].write; - state->mapper.tick = mapper_table[i].tick; - state->mapper.init = mapper_table[i].init; + state->mapper.prg_read = mapper_table[i].prg_read; + state->mapper.prg_write = mapper_table[i].prg_write; + state->mapper.chr_read = mapper_table[i].chr_read; + state->mapper.chr_write = mapper_table[i].chr_write; + state->mapper.ciram_read = mapper_table[i].ciram_read; + state->mapper.ciram_write = mapper_table[i].ciram_write; + state->mapper.tick = mapper_table[i].tick; + state->mapper.init = mapper_table[i].init; state->mapper.init(state); return; } @@ -34,9 +42,13 @@ static void mapper_setup(struct nes_state *state) { // NOTE(peter): Not sure how safe this is, but it sure is funny... printf("Unsupported mapper %d, falling back to NROM\n", mapper); - state->mapper.read = mapper_001_read; - state->mapper.write = mapper_001_write; - state->mapper.tick = mapper_001_tick; - state->mapper.init = mapper_001_init; + state->mapper.prg_read = mapper_001_prg_read; + state->mapper.prg_write = mapper_001_prg_write; + state->mapper.chr_read = mapper_001_chr_read; + state->mapper.chr_write = mapper_001_chr_write; + state->mapper.ciram_read = mapper_001_ciram_read; + state->mapper.ciram_write = mapper_001_ciram_write; + state->mapper.tick = mapper_001_tick; + state->mapper.init = mapper_001_init; state->mapper.init(state); } |
