summaryrefslogtreecommitdiff
path: root/mappers
diff options
context:
space:
mode:
Diffstat (limited to 'mappers')
-rw-r--r--mappers/mapper.c48
-rw-r--r--mappers/mapper.h10
-rw-r--r--mappers/mapper_000_0.c11
-rw-r--r--mappers/mapper_001_0.c24
-rw-r--r--mappers/mapper_002_2.c19
-rw-r--r--mappers/mapper_003_0.c16
-rw-r--r--mappers/mapper_003_1.c16
-rw-r--r--mappers/mapper_003_2.c16
-rw-r--r--mappers/mapper_007_2.c27
-rw-r--r--mappers/mapper_011_0.c18
-rw-r--r--mappers/mapper_066_0.c18
11 files changed, 127 insertions, 96 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);
}
}
diff --git a/mappers/mapper.h b/mappers/mapper.h
index 20ee906..d4384ac 100644
--- a/mappers/mapper.h
+++ b/mappers/mapper.h
@@ -12,8 +12,10 @@
struct nes_state;
struct mapper_functions {
- 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 (*prg_rom_read)(struct nes_state *state, uint32_t addr);
+ void (*prg_rom_write)(struct nes_state *state, uint32_t addr, uint8_t value);
+ uint8_t (*prg_ram_read)(struct nes_state *state, uint32_t addr);
+ void (*prg_ram_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);
@@ -25,8 +27,8 @@ union mapper_data {
struct mapper_000_0 m000_0;
struct mapper_001_0 m001_0;
struct mapper_002_2 m002_2;
- struct mapper_003_2 m003_0;
- struct mapper_003_2 m003_1;
+ struct mapper_003_0 m003_0;
+ struct mapper_003_1 m003_1;
struct mapper_003_2 m003_2;
struct mapper_007_2 m007_2;
struct mapper_011_0 m011_0;
diff --git a/mappers/mapper_000_0.c b/mappers/mapper_000_0.c
index cc7baf8..2faa002 100644
--- a/mappers/mapper_000_0.c
+++ b/mappers/mapper_000_0.c
@@ -1,8 +1,8 @@
__attribute__((section(".mapper_000_0")))
-static uint8_t mapper_000_0_prg_read(struct nes_state *state, uint32_t addr) {
- struct mapper_000_0 *mapper = (struct mapper_000_0 *)&state->map;
+static uint8_t mapper_000_0_prg_rom_read(struct nes_state *state, uint32_t addr) {
+ struct mapper_000_0 *mapper = &state->mapper_data.m000_0;
return state->prg_rom[addr & mapper->mask];
}
@@ -14,9 +14,10 @@ static uint8_t mapper_000_0_chr_read(struct nes_state *state, uint32_t addr) {
__attribute__((section(".mapper_000_0")))
static void mapper_000_0_init(struct nes_state *state) {
- struct mapper_000_0 *mapper = (struct mapper_000_0 *)&state->map;
- state->mapper.prg_read = mapper_000_0_prg_read;
- state->mapper.chr_read = mapper_000_0_chr_read;
+ struct mapper_000_0 *mapper = &state->mapper_data.m000_0;
+
+ state->mapper_function.prg_rom_read = mapper_000_0_prg_rom_read;
+ state->mapper_function.chr_read = mapper_000_0_chr_read;
mapper->mask = (state->ines.prg_size == 16384) ? 0x3fff : 0x7fff;
}
diff --git a/mappers/mapper_001_0.c b/mappers/mapper_001_0.c
index 0a03a27..51d22a2 100644
--- a/mappers/mapper_001_0.c
+++ b/mappers/mapper_001_0.c
@@ -1,7 +1,7 @@
__attribute__((section(".mapper_001_0")))
-static uint8_t mapper_001_0_prg_read(struct nes_state *state, uint32_t addr) {
- struct mapper_001_0 *mapper = (struct mapper_001_0 *)&state->map;
+static uint8_t mapper_001_0_prg_rom_read(struct nes_state *state, uint32_t addr) {
+ struct mapper_001_0 *mapper = &state->mapper_data.m001_0;
if(addr >= 0x8000) {
if(addr < 0xc000) {
return mapper->prg_rom_0[addr & 0x3fff];
@@ -13,8 +13,8 @@ static uint8_t mapper_001_0_prg_read(struct nes_state *state, uint32_t addr) {
}
__attribute__((section(".mapper_001_0")))
-static void mapper_001_0_prg_write(struct nes_state *state, uint32_t addr, uint8_t value) {
- struct mapper_001_0 *mapper = (struct mapper_001_0 *)&state->map;
+static void mapper_001_0_prg_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+ struct mapper_001_0 *mapper = &state->mapper_data.m001_0;
if(addr < 0x8000) return;
if(value & 0x80) {
@@ -71,7 +71,7 @@ static void mapper_001_0_prg_write(struct nes_state *state, uint32_t addr, uint8
__attribute__((section(".mapper_001_0")))
static uint8_t mapper_001_0_chr_read(struct nes_state *state, uint32_t addr) {
- struct mapper_001_0 *mapper = (struct mapper_001_0 *)&state->map;
+ struct mapper_001_0 *mapper = &state->mapper_data.m001_0;
if(mapper->control & 0x10) {
// 4KB mode
if(addr < 0x1000) {
@@ -103,7 +103,7 @@ static void mapper_001_0_ciram_write(struct nes_state *state, uint32_t addr, uin
__attribute__((section(".mapper_001_0")))
static void mapper_001_0_init(struct nes_state *state) {
- struct mapper_001_0 *mapper = (struct mapper_001_0 *)&state->map;
+ struct mapper_001_0 *mapper = &state->mapper_data.m001_0;
mapper->control = 0x0c;
mapper->prg_rom_0 = state->prg_rom;
@@ -112,10 +112,10 @@ static void mapper_001_0_init(struct nes_state *state) {
mapper->chr_bank_0 = state->chr_rom;
mapper->chr_bank_1 = state->chr_rom + 0x1000;
- state->mapper.prg_read = mapper_001_0_prg_read;
- state->mapper.prg_write = mapper_001_0_prg_write;
- state->mapper.chr_read = mapper_001_0_chr_read;
- state->mapper.chr_write = mapper_001_0_chr_write;
- state->mapper.ciram_read = mapper_001_0_ciram_read;
- state->mapper.ciram_write = mapper_001_0_ciram_write;
+ state->mapper_function.prg_rom_read = mapper_001_0_prg_rom_read;
+ state->mapper_function.prg_rom_write = mapper_001_0_prg_rom_write;
+ state->mapper_function.chr_read = mapper_001_0_chr_read;
+ state->mapper_function.chr_write = mapper_001_0_chr_write;
+ state->mapper_function.ciram_read = mapper_001_0_ciram_read;
+ state->mapper_function.ciram_write = mapper_001_0_ciram_write;
}
diff --git a/mappers/mapper_002_2.c b/mappers/mapper_002_2.c
index 4dbea85..e6cddf7 100644
--- a/mappers/mapper_002_2.c
+++ b/mappers/mapper_002_2.c
@@ -1,8 +1,9 @@
__attribute__((section(".mapper_002_2")))
-static uint8_t mapper_002_2_prg_read(struct nes_state *state, uint32_t addr) {
- struct mapper_002_2 *mapper = (struct mapper_002_2 *)&state->map;
+static uint8_t mapper_002_2_prg_rom_read(struct nes_state *state, uint32_t addr) {
+ struct mapper_002_2 *mapper = &state->mapper_data.m002_2;
+
if(addr >= 0x8000 && addr < 0xc000) {
return mapper->prg_bank0[addr & 0x3fff];
@@ -14,8 +15,8 @@ static uint8_t mapper_002_2_prg_read(struct nes_state *state, uint32_t addr) {
}
__attribute__((section(".mapper_002_2")))
-static void mapper_002_2_prg_write(struct nes_state *state, uint32_t addr, uint8_t value) {
- struct mapper_002_2 *mapper = (struct mapper_002_2 *)&state->map;
+static void mapper_002_2_prg_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+ struct mapper_002_2 *mapper = &state->mapper_data.m002_2;
if(addr >= 0x8000) {
mapper->prg_bank0 = state->prg_rom + ((value & 0x0f) * 0x4000);
@@ -34,13 +35,13 @@ static void mapper_002_2_chr_write(struct nes_state *state, uint32_t addr, uint8
__attribute__((section(".mapper_002_2")))
static void mapper_002_2_init(struct nes_state *state) {
- struct mapper_002_2 *mapper = (struct mapper_002_2 *)&state->map;
+ struct mapper_002_2 *mapper = &state->mapper_data.m002_2;
mapper->prg_bank0 = state->prg_rom;
mapper->prg_bank1 = state->prg_rom + state->ines.prg_size - 0x4000;
- state->mapper.prg_read = mapper_002_2_prg_read;
- state->mapper.prg_write = mapper_002_2_prg_write;
- state->mapper.chr_read = mapper_002_2_chr_read;
- state->mapper.chr_write = mapper_002_2_chr_write;
+ state->mapper_function.prg_rom_read = mapper_002_2_prg_rom_read;
+ state->mapper_function.prg_rom_write = mapper_002_2_prg_rom_write;
+ state->mapper_function.chr_read = mapper_002_2_chr_read;
+ state->mapper_function.chr_write = mapper_002_2_chr_write;
}
diff --git a/mappers/mapper_003_0.c b/mappers/mapper_003_0.c
index ec38f35..8c754a3 100644
--- a/mappers/mapper_003_0.c
+++ b/mappers/mapper_003_0.c
@@ -1,12 +1,12 @@
__attribute__((section(".mapper_003_0")))
-static uint8_t mapper_003_0_prg_read(struct nes_state *state, uint32_t addr) {
+static uint8_t mapper_003_0_prg_rom_read(struct nes_state *state, uint32_t addr) {
return state->prg_rom[addr & 0x7fff];
}
__attribute__((section(".mapper_003_0")))
-static void mapper_003_0_prg_write(struct nes_state *state, uint32_t addr, uint8_t value) {
- struct mapper_003_0 *mapper = (struct mapper_003_0 *)&state->map;
+static void mapper_003_0_prg_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+ struct mapper_003_0 *mapper = &state->mapper_data.m003_0;
if(addr >= 0x8000) {
mapper->chr_ptr = state->chr_rom + (value & 3) * 0x2000;
@@ -15,17 +15,17 @@ static void mapper_003_0_prg_write(struct nes_state *state, uint32_t addr, uint8
__attribute__((section(".mapper_003_0")))
static uint8_t mapper_003_0_chr_read(struct nes_state *state, uint32_t addr) {
- struct mapper_003_0 *mapper = (struct mapper_003_0 *)&state->map;
+ struct mapper_003_0 *mapper = &state->mapper_data.m003_0;
return mapper->chr_ptr[addr];
}
__attribute__((section(".mapper_003_0")))
static void mapper_003_0_init(struct nes_state *state) {
- struct mapper_003_0 *mapper = (struct mapper_003_0 *)&state->map;
+ struct mapper_003_0 *mapper = &state->mapper_data.m003_0;
mapper->chr_ptr = state->chr_rom;
- state->mapper.prg_read = mapper_003_0_prg_read;
- state->mapper.prg_write = mapper_003_0_prg_write;
- state->mapper.chr_read = mapper_003_0_chr_read;
+ state->mapper_function.prg_rom_read = mapper_003_0_prg_rom_read;
+ state->mapper_function.prg_rom_write = mapper_003_0_prg_rom_write;
+ state->mapper_function.chr_read = mapper_003_0_chr_read;
}
diff --git a/mappers/mapper_003_1.c b/mappers/mapper_003_1.c
index 0032fbc..68e67c7 100644
--- a/mappers/mapper_003_1.c
+++ b/mappers/mapper_003_1.c
@@ -1,12 +1,12 @@
__attribute__((section(".mapper_003_1")))
-static uint8_t mapper_003_1_prg_read(struct nes_state *state, uint32_t addr) {
+static uint8_t mapper_003_1_prg_rom_read(struct nes_state *state, uint32_t addr) {
return state->prg_rom[addr & 0x7fff];
}
__attribute__((section(".mapper_003_1")))
-static void mapper_003_1_prg_write(struct nes_state *state, uint32_t addr, uint8_t value) {
- struct mapper_003_1 *mapper = (struct mapper_003_1 *)&state->map;
+static void mapper_003_1_prg_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+ struct mapper_003_1 *mapper = &state->mapper_data.m003_1;
if(addr >= 0x8000) {
mapper->chr_ptr = state->chr_rom + (value & 3) * 0x2000;
@@ -15,17 +15,17 @@ static void mapper_003_1_prg_write(struct nes_state *state, uint32_t addr, uint8
__attribute__((section(".mapper_003_1")))
static uint8_t mapper_003_1_chr_read(struct nes_state *state, uint32_t addr) {
- struct mapper_003_1 *mapper = (struct mapper_003_1 *)&state->map;
+ struct mapper_003_1 *mapper = &state->mapper_data.m003_1;
return mapper->chr_ptr[addr];
}
__attribute__((section(".mapper_003_1")))
static void mapper_003_1_init(struct nes_state *state) {
- struct mapper_003_1 *mapper = (struct mapper_003_1 *)&state->map;
+ struct mapper_003_1 *mapper = &state->mapper_data.m003_1;
mapper->chr_ptr = state->chr_rom;
- state->mapper.prg_read = mapper_003_1_prg_read;
- state->mapper.prg_write = mapper_003_1_prg_write;
- state->mapper.chr_read = mapper_003_1_chr_read;
+ state->mapper_function.prg_rom_read = mapper_003_1_prg_rom_read;
+ state->mapper_function.prg_rom_write = mapper_003_1_prg_rom_write;
+ state->mapper_function.chr_read = mapper_003_1_chr_read;
}
diff --git a/mappers/mapper_003_2.c b/mappers/mapper_003_2.c
index 73cfdc6..9c0d40d 100644
--- a/mappers/mapper_003_2.c
+++ b/mappers/mapper_003_2.c
@@ -1,12 +1,12 @@
__attribute__((section(".mapper_003_2")))
-static uint8_t mapper_003_2_prg_read(struct nes_state *state, uint32_t addr) {
+static uint8_t mapper_003_2_prg_rom_read(struct nes_state *state, uint32_t addr) {
return state->prg_rom[addr & 0x7fff];
}
__attribute__((section(".mapper_003_2")))
-static void mapper_003_2_prg_write(struct nes_state *state, uint32_t addr, uint8_t value) {
- struct mapper_003_2 *mapper = (struct mapper_003_2 *)&state->map;
+static void mapper_003_2_prg_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+ struct mapper_003_2 *mapper = &state->mapper_data.m003_2;
if(addr >= 0x8000) {
value &= state->prg_rom[addr & 0x7fff];
@@ -16,17 +16,17 @@ static void mapper_003_2_prg_write(struct nes_state *state, uint32_t addr, uint8
__attribute__((section(".mapper_003_2")))
static uint8_t mapper_003_2_chr_read(struct nes_state *state, uint32_t addr) {
- struct mapper_003_2 *mapper = (struct mapper_003_2 *)&state->map;
+ struct mapper_003_2 *mapper = &state->mapper_data.m003_2;
return mapper->chr_ptr[addr];
}
__attribute__((section(".mapper_003_2")))
static void mapper_003_2_init(struct nes_state *state) {
- struct mapper_003_2 *mapper = (struct mapper_003_2 *)&state->map;
+ struct mapper_003_2 *mapper = &state->mapper_data.m003_2;
mapper->chr_ptr = state->chr_rom;
- state->mapper.prg_read = mapper_003_2_prg_read;
- state->mapper.prg_write = mapper_003_2_prg_write;
- state->mapper.chr_read = mapper_003_2_chr_read;
+ state->mapper_function.prg_rom_read = mapper_003_2_prg_rom_read;
+ state->mapper_function.prg_rom_write = mapper_003_2_prg_rom_write;
+ state->mapper_function.chr_read = mapper_003_2_chr_read;
}
diff --git a/mappers/mapper_007_2.c b/mappers/mapper_007_2.c
index c42bc62..7f5963f 100644
--- a/mappers/mapper_007_2.c
+++ b/mappers/mapper_007_2.c
@@ -1,7 +1,8 @@
__attribute__((section(".mapper_007_2")))
-static uint8_t mapper_007_2_prg_read(struct nes_state *state, uint32_t addr) {
- struct mapper_007_2 *mapper = (struct mapper_007_2 *)&state->map;
+static uint8_t mapper_007_2_prg_rom_read(struct nes_state *state, uint32_t addr) {
+ struct mapper_007_2 *mapper = &state->mapper_data.m007_2;
+
if(addr >= 0x8000) {
return mapper->prg_rom[addr & 0x7fff];
}
@@ -9,8 +10,8 @@ static uint8_t mapper_007_2_prg_read(struct nes_state *state, uint32_t addr) {
}
__attribute__((section(".mapper_007_2")))
-static void mapper_007_2_prg_write(struct nes_state *state, uint32_t addr, uint8_t value) {
- struct mapper_007_2 *mapper = (struct mapper_007_2 *)&state->map;
+static void mapper_007_2_prg_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+ struct mapper_007_2 *mapper = &state->mapper_data.m007_2;
if(addr >= 0x8000) {
uint32_t prg_off = (value & 0x0f) << 15;
uint32_t ciram_off = (value & 0x10) << 11;
@@ -34,26 +35,26 @@ static void mapper_007_2_chr_write(struct nes_state *state, uint32_t addr, uint8
__attribute__((section(".mapper_007_2")))
static uint8_t mapper_007_2_ciram_read(struct nes_state *state, uint32_t addr) {
- struct mapper_007_2 *mapper = (struct mapper_007_2 *)&state->map;
+ struct mapper_007_2 *mapper = &state->mapper_data.m007_2;
return mapper->ciram[addr & 0x3ff];
}
__attribute__((section(".mapper_007_2")))
static void mapper_007_2_ciram_write(struct nes_state *state, uint32_t addr, uint8_t value) {
- struct mapper_007_2 *mapper = (struct mapper_007_2 *)&state->map;
+ struct mapper_007_2 *mapper = &state->mapper_data.m007_2;
mapper->ciram[addr & 0x3ff] = value;
}
__attribute__((section(".mapper_007_2")))
static void mapper_007_2_init(struct nes_state *state) {
- struct mapper_007_2 *mapper = (struct mapper_007_2 *)&state->map;
+ struct mapper_007_2 *mapper = &state->mapper_data.m007_2;
mapper->prg_rom = state->prg_rom;
mapper->ciram = 0;
- state->mapper.prg_read = mapper_007_2_prg_read;
- state->mapper.prg_write = mapper_007_2_prg_write;
- state->mapper.chr_read = mapper_007_2_chr_read;
- state->mapper.chr_write = mapper_007_2_chr_write;
- state->mapper.ciram_read = mapper_007_2_ciram_read;
- state->mapper.ciram_write = mapper_007_2_ciram_write;
+ state->mapper_function.prg_rom_read = mapper_007_2_prg_rom_read;
+ state->mapper_function.prg_rom_write = mapper_007_2_prg_rom_write;
+ state->mapper_function.chr_read = mapper_007_2_chr_read;
+ state->mapper_function.chr_write = mapper_007_2_chr_write;
+ state->mapper_function.ciram_read = mapper_007_2_ciram_read;
+ state->mapper_function.ciram_write = mapper_007_2_ciram_write;
}
diff --git a/mappers/mapper_011_0.c b/mappers/mapper_011_0.c
index e5db02c..d324fcf 100644
--- a/mappers/mapper_011_0.c
+++ b/mappers/mapper_011_0.c
@@ -1,7 +1,7 @@
__attribute__((section(".mapper_011_0")))
-static uint8_t mapper_011_0_prg_read(struct nes_state *state, uint32_t addr) {
- struct mapper_011_0 *mapper = (struct mapper_011_0 *)&state->map;
+static uint8_t mapper_011_0_prg_rom_read(struct nes_state *state, uint32_t addr) {
+ struct mapper_011_0 *mapper = &state->mapper_data.m011_0;
if(addr >= 0x8000) {
return mapper->prg_rom[addr - 0x8000];
@@ -10,8 +10,8 @@ static uint8_t mapper_011_0_prg_read(struct nes_state *state, uint32_t addr) {
}
__attribute__((section(".mapper_011_0")))
-static void mapper_011_0_prg_write(struct nes_state *state, uint32_t addr, uint8_t value) {
- struct mapper_011_0 *mapper = (struct mapper_011_0 *)&state->map;
+static void mapper_011_0_prg_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+ struct mapper_011_0 *mapper = &state->mapper_data.m011_0;
if(addr >= 0x8000) {
mapper->prg_rom = state->prg_rom + ((value >> 4) & 7) * 0x8000;
@@ -21,20 +21,20 @@ static void mapper_011_0_prg_write(struct nes_state *state, uint32_t addr, uint8
__attribute__((section(".mapper_011_0")))
static uint8_t mapper_011_0_chr_read(struct nes_state *state, uint32_t addr) {
- struct mapper_011_0 *mapper = (struct mapper_011_0 *)&state->map;
+ struct mapper_011_0 *mapper = &state->mapper_data.m011_0;
return mapper->chr_ptr[addr];
}
__attribute__((section(".mapper_011_0")))
static void mapper_011_0_init(struct nes_state *state) {
- struct mapper_011_0 *mapper = (struct mapper_011_0 *)&state->map;
+ struct mapper_011_0 *mapper = &state->mapper_data.m011_0;
mapper->prg_rom = state->prg_rom;
mapper->chr_ptr = state->chr_rom;
- state->mapper.prg_read = mapper_011_0_prg_read;
- state->mapper.prg_write = mapper_011_0_prg_write;
- state->mapper.chr_read = mapper_011_0_chr_read;
+ state->mapper_function.prg_rom_read = mapper_011_0_prg_rom_read;
+ state->mapper_function.prg_rom_write = mapper_011_0_prg_rom_write;
+ state->mapper_function.chr_read = mapper_011_0_chr_read;
}
diff --git a/mappers/mapper_066_0.c b/mappers/mapper_066_0.c
index 9629fb2..ccd00fe 100644
--- a/mappers/mapper_066_0.c
+++ b/mappers/mapper_066_0.c
@@ -1,7 +1,7 @@
__attribute__((section(".mapper_066_0")))
-static uint8_t mapper_066_0_prg_read(struct nes_state *state, uint32_t addr) {
- struct mapper_066_0 *mapper = (struct mapper_066_0 *)&state->map;
+static uint8_t mapper_066_0_prg_rom_read(struct nes_state *state, uint32_t addr) {
+ struct mapper_066_0 *mapper = &state->mapper_data.m066_0;
if(addr >= 0x8000) {
return state->prg_rom[addr & 0x7fff];
@@ -10,8 +10,8 @@ static uint8_t mapper_066_0_prg_read(struct nes_state *state, uint32_t addr) {
}
__attribute__((section(".mapper_066_0")))
-static void mapper_066_0_prg_write(struct nes_state *state, uint32_t addr, uint8_t value) {
- struct mapper_066_0 *mapper = (struct mapper_066_0 *)&state->map;
+static void mapper_066_0_prg_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+ struct mapper_066_0 *mapper = &state->mapper_data.m066_0;
if(addr >= 0x8000) {
uint32_t prg_bank = (value >> 4) & 3;
@@ -24,19 +24,19 @@ static void mapper_066_0_prg_write(struct nes_state *state, uint32_t addr, uint8
__attribute__((section(".mapper_066_0")))
static uint8_t mapper_066_0_chr_read(struct nes_state *state, uint32_t addr) {
- struct mapper_066_0 *mapper = (struct mapper_066_0 *)&state->map;
+ struct mapper_066_0 *mapper = &state->mapper_data.m066_0;
return mapper->chr_offset[addr];
}
__attribute__((section(".mapper_066_0")))
static void mapper_066_0_init(struct nes_state *state) {
- struct mapper_066_0 *mapper = (struct mapper_066_0 *)&state->map;
+ struct mapper_066_0 *mapper = &state->mapper_data.m066_0;
mapper->prg_offset = state->prg_rom;
mapper->chr_offset = state->chr_rom;
- state->mapper.prg_read = mapper_066_0_prg_read;
- state->mapper.prg_write = mapper_066_0_prg_write;
- state->mapper.chr_read = mapper_066_0_chr_read;
+ state->mapper_function.prg_rom_read = mapper_066_0_prg_rom_read;
+ state->mapper_function.prg_rom_write = mapper_066_0_prg_rom_write;
+ state->mapper_function.chr_read = mapper_066_0_chr_read;
}