summaryrefslogtreecommitdiff
path: root/mapper.c
diff options
context:
space:
mode:
authorPeter Fors <peter.fors@mindkiller.com>2025-04-06 12:27:12 +0200
committerPeter Fors <peter.fors@mindkiller.com>2025-04-06 12:27:12 +0200
commit39715ca6bf65d2e2dd889cdef4b39d584464d9e7 (patch)
tree39390f6fadd0ddbe913ae66e11847b8b3e7b16bb /mapper.c
parentdabd7a5848e6aa55e91cf4c804f6236b4f7fe30e (diff)
added more mappers (buggy)
Diffstat (limited to 'mapper.c')
-rw-r--r--mapper.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/mapper.c b/mapper.c
index 09d9a62..821224d 100644
--- a/mapper.c
+++ b/mapper.c
@@ -1,7 +1,11 @@
#include "mapper_0000.c"
+#include "mapper_0003.c"
+#include "mapper_0007.c"
+#include "mapper_000b.c"
#include "mapper_0042.c"
+#include "mapper_2002.c"
static uint8_t mapper_default_ciram_read(struct nes_state *state, uint32_t addr) {
@@ -32,23 +36,29 @@ static void mapper_default_tick(struct nes_state *state) { // No IRQ or timing l
* NOTE(peter): Mapper 0 always has to be first!
*/
static struct mapper_entry mapper_table[] = {
-/* Mapper: 0 */ { 0x00, mapper_0000_prg_read, mapper_0000_prg_write, mapper_0000_chr_read, mapper_0000_chr_write, mapper_default_ciram_read, mapper_default_ciram_write, mapper_default_tick, mapper_0000_init },
-/* Mapper: 66 */ { 0x42, mapper_0042_prg_read, mapper_0042_prg_write, mapper_0042_chr_read, mapper_0042_chr_write, mapper_default_ciram_read, mapper_default_ciram_write, mapper_default_tick, mapper_0042_init },
+/* Mapper: 0 */ { 0x00, mapper_0000_prg_read, mapper_0000_prg_write, mapper_0000_chr_read, mapper_0000_chr_write, mapper_default_ciram_read, mapper_default_ciram_write, mapper_default_tick, mapper_0000_init },
+/* Mapper: 3 */ { 0x03, mapper_0003_prg_read, mapper_0003_prg_write, mapper_0003_chr_read, mapper_0003_chr_write, mapper_default_ciram_read, mapper_default_ciram_write, mapper_default_tick, mapper_0003_init },
+/* Mapper: 7 */ { 0x07, mapper_0007_prg_read, mapper_0007_prg_write, mapper_0007_chr_read, mapper_0007_chr_write, mapper_0007_ciram_read, mapper_0007_ciram_write, mapper_default_tick, mapper_0007_init },
+/* Mapper: b */ { 0x0b, mapper_000b_prg_read, mapper_000b_prg_write, mapper_000b_chr_read, mapper_000b_chr_write, mapper_default_ciram_read, mapper_default_ciram_write, mapper_default_tick, mapper_000b_init },
+/* Mapper: 66 */ { 0x42, mapper_0042_prg_read, mapper_0042_prg_write, mapper_0042_chr_read, mapper_0042_chr_write, mapper_default_ciram_read, mapper_default_ciram_write, mapper_default_tick, mapper_0042_init },
+/* Mapper: 2002 */ { 0x2002, mapper_2002_prg_read, mapper_2002_prg_write, mapper_2002_chr_read, mapper_2002_chr_write, mapper_default_ciram_read, mapper_default_ciram_write, mapper_default_tick, mapper_2002_init },
};
-
static void mapper_setup(struct nes_state *state) {
- uint32_t mapper = state->ines.mapper;
+ uint32_t mapper = (state->ines.submapper << 12) | 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 = mapper_table[i];
+ printf("Mapper %4.4x\n", mapper);
+ memcpy(&state->mapper, &mapper_table[i], sizeof(struct mapper_entry)); // NOTE(peter): BECAUSE GCC IS BROKEN
+ // state->mapper = mapper_table[i];
state->mapper.init(state);
return;
}
}
- printf("Unsupported mapper %d, falling back to NROM\n", mapper);
- state->mapper = mapper_table[0];
+ printf("Unsupported mapper %4.4x, falling back to NROM\n", mapper);
+ memcpy(&state->mapper, &mapper_table[0], sizeof(struct mapper_entry)); // NOTE(peter): BECAUSE GCC IS BROKEN
+ // state->mapper = mapper_table[0];
state->mapper.init(state);
}