summaryrefslogtreecommitdiff
path: root/mapper_001.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_001.c
parent6274071e3857c1640cc5aef804cb86509ab312f9 (diff)
move read/write prg/chr/cirom data to mapper
Diffstat (limited to 'mapper_001.c')
-rw-r--r--mapper_001.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/mapper_001.c b/mapper_001.c
index 8c65367..4704444 100644
--- a/mapper_001.c
+++ b/mapper_001.c
@@ -4,20 +4,43 @@ static void mapper_001_init(struct nes_state *state) {
// Nothing to initialize for 001
}
-static uint8_t mapper_001_read(struct nes_state *state, uint32_t addr) {
+static uint8_t mapper_001_prg_read(struct nes_state *state, uint32_t addr) {
uint32_t prg_size = state->ines.prg_size;
uint32_t mask = (state->ines.prg_size == 16384) ? 0x3fff : 0x7fff;
- return state->rom[addr & mask];
+ return state->prg_rom[addr & mask];
}
-static void mapper_001_write(struct nes_state *state, uint32_t addr, uint8_t value) {
- (void)state;
- (void)addr;
- (void)value;
+static void mapper_001_prg_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+}
+
+static uint8_t mapper_001_chr_read(struct nes_state *state, uint32_t addr) {
+ return state->chr_rom[addr];
+}
+
+static void mapper_001_chr_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+}
+
+static uint8_t mapper_001_ciram_read(struct nes_state *state, uint32_t addr) {
+ if(state->ines.mirroring == 0) { // Horizontal
+ addr = (addr & 0x800) | (addr & 0x3ff);
+ } else { // Vertical (default fallback)
+ addr = addr & 0x7ff;
+ }
+
+ return state->ciram[addr];
+}
+
+static void mapper_001_ciram_write(struct nes_state *state, uint32_t addr, uint8_t value) {
+ if(state->ines.mirroring == 0) {
+ addr = (addr & 0x800) | (addr & 0x3ff);
+ } else {
+ addr = addr & 0x7ff;
+ }
+
+ state->ciram[addr] = value;
}
static void mapper_001_tick(struct nes_state *state) {
- (void)state;
}