summaryrefslogtreecommitdiff
path: root/mapper_066.c
diff options
context:
space:
mode:
authorPeter Fors <peter.fors@mindkiller.com>2025-04-04 01:03:19 +0200
committerPeter Fors <peter.fors@mindkiller.com>2025-04-04 01:03:19 +0200
commit8c82be43720d9e221a9e2541c9ff6151015838bb (patch)
tree6ed341720934bbf69a386e254c4e9449f9051616 /mapper_066.c
parent6274071e3857c1640cc5aef804cb86509ab312f9 (diff)
move read/write prg/chr/cirom data to mapper
Diffstat (limited to 'mapper_066.c')
-rw-r--r--mapper_066.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/mapper_066.c b/mapper_066.c
index aabf471..7a2b542 100644
--- a/mapper_066.c
+++ b/mapper_066.c
@@ -4,15 +4,15 @@ static void mapper_066_init(struct nes_state *state) {
state->map.m066.chr_offset = 0;
}
-static uint8_t mapper_066_read(struct nes_state *state, uint32_t addr) {
+static uint8_t mapper_066_prg_read(struct nes_state *state, uint32_t addr) {
if(addr >= 0x8000) {
uint32_t base = state->map.m066.prg_offset;
- return state->rom[base + (addr - 0x8000)];
+ return state->prg_rom[base + (addr - 0x8000)];
}
return 0;
}
-static void mapper_066_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+static void mapper_066_prg_write(struct nes_state *state, uint32_t addr, uint8_t value) {
if(addr >= 0x8000) {
uint32_t prg_bank = (value >> 4) & 3;
uint32_t chr_bank = (value >> 0) & 3;
@@ -22,6 +22,37 @@ static void mapper_066_write(struct nes_state *state, uint32_t addr, uint8_t val
}
}
+static uint8_t mapper_066_chr_read(struct nes_state *state, uint32_t addr) {
+ return state->chr_rom[state->map.m066.chr_offset + addr];
+}
+
+static void mapper_066_chr_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+}
+
+static uint8_t mapper_066_ciram_read(struct nes_state *state, uint32_t addr) {
+ uint32_t mirrored = addr & 0x0fff;
+
+ if(state->ines.mirroring == 0) { // Horizontal
+ mirrored = (mirrored & 0x800) | (mirrored & 0x3ff);
+ } else { // Vertical (default fallback)
+ mirrored = mirrored & 0x7ff;
+ }
+
+ return state->ciram[mirrored];
+}
+
+static void mapper_066_ciram_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+ uint32_t mirrored = addr & 0x0fff;
+
+ if(state->ines.mirroring == 0) {
+ mirrored = (mirrored & 0x800) | (mirrored & 0x3ff);
+ } else {
+ mirrored = mirrored & 0x7ff;
+ }
+
+ state->ciram[mirrored] = value;
+}
+
static void mapper_066_tick(struct nes_state *state) {
// No IRQ or timing logic needed
}