diff options
Diffstat (limited to 'mappers/mapper.c')
| -rw-r--r-- | mappers/mapper.c | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/mappers/mapper.c b/mappers/mapper.c index 5636705..0b5612b 100644 --- a/mappers/mapper.c +++ b/mappers/mapper.c @@ -18,9 +18,32 @@ static void mapper_default_ciram_write(struct nes_state *state, uint32_t addr, u state->ciram[addr] = value; } -static void mapper_default_prg_write(struct nes_state *state, uint32_t addr, uint8_t value) { } -static void mapper_default_chr_write(struct nes_state *state, uint32_t addr, uint8_t value) { } -static void mapper_default_tick(struct nes_state *state) { } +// static void mapper_default_prg_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) { } +// static uint8_t mapper_default_prg_ram_read(struct nes_state *state, uint32_t addr) { return 0; } +// static void mapper_default_prg_ram_write(struct nes_state *state, uint32_t addr, uint8_t value) { } +// static void mapper_default_chr_write(struct nes_state *state, uint32_t addr, uint8_t value) { } +// static void mapper_default_tick(struct nes_state *state) { } + +__attribute__((naked)) void mapper_default_prg_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) { + __asm__ __volatile__("ret"); +} + +__attribute__((naked)) uint8_t mapper_default_prg_ram_read(struct nes_state *state, uint32_t addr) { + __asm__ __volatile__("xor %%al, %%al\n\t" "ret" : : : "al"); +} + +__attribute__((naked)) void mapper_default_prg_ram_write(struct nes_state *state, uint32_t addr, uint8_t value) { + __asm__ __volatile__("ret"); +} + +__attribute__((naked)) void mapper_default_chr_write(struct nes_state *state, uint32_t addr, uint8_t value) { + __asm__ __volatile__("ret"); +} + +__attribute__((naked)) void mapper_default_tick(struct nes_state *state) { + __asm__ __volatile__("ret"); +} + #include "mapper_000_0.c" #include "mapper_001_0.c" @@ -46,14 +69,17 @@ static void (*mapper_table[4096])(struct nes_state *state) = { [MAPPER_ID(66, 0)] = mapper_066_0_init, }; +// NOTE(peter): The entries with 0x0 will always have to be supplied/set by the mapper! static void mapper_reset(struct nes_state *state) { - state->mapper.prg_read = 0; - state->mapper.prg_write = mapper_default_prg_write; - state->mapper.chr_read = 0; - state->mapper.chr_write = mapper_default_chr_write; - state->mapper.ciram_read = mapper_default_ciram_read; - state->mapper.ciram_write = mapper_default_ciram_write; - state->mapper.tick = mapper_default_tick; + state->mapper_function.prg_rom_read = 0x0; + state->mapper_function.prg_rom_write = mapper_default_prg_rom_write; + state->mapper_function.prg_ram_read = mapper_default_prg_ram_read; + state->mapper_function.prg_ram_write = mapper_default_prg_ram_write; + state->mapper_function.chr_read = 0x0; + state->mapper_function.chr_write = mapper_default_chr_write; + state->mapper_function.ciram_read = mapper_default_ciram_read; + state->mapper_function.ciram_write = mapper_default_ciram_write; + state->mapper_function.tick = 0; } static void mapper_setup(struct nes_state *state) { @@ -64,7 +90,7 @@ static void mapper_setup(struct nes_state *state) { if(mapper_table[mapper]) { mapper_table[mapper](state); } else { - printf("Unsupported mapper %d_%x, falling back to NROM\n", state->ines.mapper, state->ines.submapper); + printf("Unsupported mapper %d_%x, falling back to NROM (mapper 0)\n", state->ines.mapper, state->ines.submapper); mapper_table[0](state); } } |
