diff options
| author | Peter Fors <peter.fors@mindkiller.com> | 2025-10-09 22:07:52 +0200 |
|---|---|---|
| committer | Peter Fors <peter.fors@mindkiller.com> | 2025-10-09 22:07:52 +0200 |
| commit | 030724a9aea346e4a9843d5842fb28c6d6c4cf1a (patch) | |
| tree | f06fb84aaef64b2f4e2d81b3d2d3eef71bad83ec /mappers | |
| parent | 412b2ef851516c1de8ba5006ddd284192cbcaf9b (diff) | |
Rearrangement and refactoring and optimizations and more accuracy
Diffstat (limited to 'mappers')
| -rw-r--r-- | mappers/mapper.c | 97 | ||||
| -rw-r--r-- | mappers/mapper.h | 37 | ||||
| -rw-r--r-- | mappers/mapper_000_0.c | 3 | ||||
| -rw-r--r-- | mappers/mapper_001_0.c | 135 | ||||
| -rw-r--r-- | mappers/mapper_002_2.c | 5 | ||||
| -rw-r--r-- | mappers/mapper_003_0.c | 4 | ||||
| -rw-r--r-- | mappers/mapper_003_1.c | 4 | ||||
| -rw-r--r-- | mappers/mapper_003_2.c | 4 | ||||
| -rw-r--r-- | mappers/mapper_007_2.c | 7 | ||||
| -rw-r--r-- | mappers/mapper_011_0.c | 4 | ||||
| -rw-r--r-- | mappers/mapper_066_0.c | 4 |
11 files changed, 95 insertions, 209 deletions
diff --git a/mappers/mapper.c b/mappers/mapper.c deleted file mode 100644 index 84586e9..0000000 --- a/mappers/mapper.c +++ /dev/null @@ -1,97 +0,0 @@ - -static uint8_t mapper_default_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_default_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_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)) static void mapper_default_prg_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) { - __asm__ __volatile__("ret"); -} - -__attribute__((naked)) static 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)) static void mapper_default_prg_ram_write(struct nes_state *state, uint32_t addr, uint8_t value) { - __asm__ __volatile__("ret"); -} - -__attribute__((naked)) static void mapper_default_chr_write(struct nes_state *state, uint32_t addr, uint8_t value) { - __asm__ __volatile__("ret"); -} - -__attribute__((naked)) static void mapper_default_tick(struct nes_state *state) { - __asm__ __volatile__("ret"); -} - - -#include "mapper_000_0.c" -#include "mapper_001_0.c" -#include "mapper_002_2.c" -#include "mapper_003_0.c" -#include "mapper_003_1.c" -#include "mapper_003_2.c" -#include "mapper_007_2.c" -#include "mapper_011_0.c" -#include "mapper_066_0.c" - -#define MAPPER_ID(mapper, submapper) (((mapper) << 4) | (submapper)) - -static void (*mapper_table[4096])(struct nes_state *state) = { - [MAPPER_ID( 0, 0)] = mapper_000_0_init, - [MAPPER_ID( 1, 0)] = mapper_001_0_init, - [MAPPER_ID( 2, 2)] = mapper_002_2_init, - [MAPPER_ID( 3, 0)] = mapper_003_0_init, - [MAPPER_ID( 3, 1)] = mapper_003_1_init, - [MAPPER_ID( 3, 2)] = mapper_003_2_init, - [MAPPER_ID( 7, 2)] = mapper_007_2_init, - [MAPPER_ID(11, 0)] = mapper_011_0_init, - [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_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) { - uint32_t mapper = state->ines.mapper << 4 | state->ines.submapper; - printf("Mapper %d_%x requested.\n", state->ines.mapper, state->ines.submapper); - - mapper_reset(state); - if(mapper_table[mapper]) { - mapper_table[mapper](state); - } else { - 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 deleted file mode 100644 index d4384ac..0000000 --- a/mappers/mapper.h +++ /dev/null @@ -1,37 +0,0 @@ - -#include "mapper_000_0.h" -#include "mapper_001_0.h" -#include "mapper_002_2.h" -#include "mapper_003_0.h" -#include "mapper_003_1.h" -#include "mapper_003_2.h" -#include "mapper_007_2.h" -#include "mapper_011_0.h" -#include "mapper_066_0.h" - -struct nes_state; - -struct mapper_functions { - 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); - void (*ciram_write)(struct nes_state *state, uint32_t addr, uint8_t value); - void (*tick)(struct nes_state *state); -} __attribute__((aligned(64))); - -union mapper_data { - struct mapper_000_0 m000_0; - struct mapper_001_0 m001_0; - struct mapper_002_2 m002_2; - 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; - struct mapper_066_0 m066_0; -} __attribute__((aligned(64))); - diff --git a/mappers/mapper_000_0.c b/mappers/mapper_000_0.c index 2faa002..bb89b5d 100644 --- a/mappers/mapper_000_0.c +++ b/mappers/mapper_000_0.c @@ -1,18 +1,15 @@ -__attribute__((section(".mapper_000_0"))) 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]; } -__attribute__((section(".mapper_000_0"))) static uint8_t mapper_000_0_chr_read(struct nes_state *state, uint32_t addr) { return state->chr_rom[addr]; } -__attribute__((section(".mapper_000_0"))) static void mapper_000_0_init(struct nes_state *state) { struct mapper_000_0 *mapper = &state->mapper_data.m000_0; diff --git a/mappers/mapper_001_0.c b/mappers/mapper_001_0.c index 51d22a2..a449fe7 100644 --- a/mappers/mapper_001_0.c +++ b/mappers/mapper_001_0.c @@ -1,7 +1,6 @@ - -__attribute__((section(".mapper_001_0"))) 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]; @@ -12,10 +11,14 @@ static uint8_t mapper_001_0_prg_rom_read(struct nes_state *state, uint32_t addr) return 0; } -__attribute__((section(".mapper_001_0"))) 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; + +printf("MMC1 write: addr=%04x val=%02x\n", addr, value); + + if(addr < 0x8000) { + return; + } if(value & 0x80) { mapper->shift = 0; @@ -28,94 +31,146 @@ static void mapper_001_0_prg_rom_write(struct nes_state *state, uint32_t addr, u mapper->shift_count++; if(mapper->shift_count == 5) { - uint32_t bank; - uint8_t reg = (addr >> 13) & 0x03; + uint8_t reg = (addr >> 13) & 3; + switch(reg) { - case 0: {// Control + case 0: { mapper->control = mapper->shift; + switch(mapper->control & 3) { + case 0: { + state->ines.mirroring = MIRROR_ONESCREEN_LOW; + } break; + + case 1: { + state->ines.mirroring = MIRROR_ONESCREEN_HIGH; + } break; + + case 2: { + state->ines.mirroring = MIRROR_VERTICAL; + } break; + + case 3: { + state->ines.mirroring = MIRROR_HORIZONTAL; + } break; + } } break; - case 1: { // CHR bank 0 + case 1: { mapper->chr_bank0 = mapper->shift; mapper->chr_bank_0 = state->chr_rom + (mapper->chr_bank0 * 0x1000); } break; - case 2: { // CHR bank 1 + case 2: { mapper->chr_bank1 = mapper->shift; mapper->chr_bank_1 = state->chr_rom + (mapper->chr_bank1 * 0x1000); } break; - case 3: { // PRG bank + case 3: { mapper->prg_bank = mapper->shift & 0x0f; + if(mapper->control & 0x08) { - // 16KB bank switching if(mapper->control & 0x04) { - mapper->prg_rom_0 = state->prg_rom + 0x4000 * 0; - mapper->prg_rom_1 = state->prg_rom + 0x4000 * mapper->prg_bank; + mapper->prg_rom_0 = state->prg_rom; + mapper->prg_rom_1 = state->prg_rom + (mapper->prg_bank * 0x4000); } else { - mapper->prg_rom_0 = state->prg_rom + 0x4000 * mapper->prg_bank; - mapper->prg_rom_1 = state->prg_rom + 0x4000 * (state->ines.prg_size / 0x4000 - 1); + mapper->prg_rom_0 = state->prg_rom + (mapper->prg_bank * 0x4000); + mapper->prg_rom_1 = state->prg_rom + (state->ines.prg_size - 0x4000); } } else { - // 32KB mode - bank = (mapper->prg_bank & 0x0e) * 0x4000; - mapper->prg_rom_0 = state->prg_rom + bank; - mapper->prg_rom_1 = state->prg_rom + bank + 0x4000; + uint32_t base = (mapper->prg_bank & 0x0e) * 0x4000; + mapper->prg_rom_0 = state->prg_rom + base; + mapper->prg_rom_1 = state->prg_rom + base + 0x4000; } } break; } + mapper->shift = 0; mapper->shift_count = 0; } } -__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 = &state->mapper_data.m001_0; + if(mapper->control & 0x10) { - // 4KB mode if(addr < 0x1000) { - return mapper->chr_bank_0[addr]; + return mapper->chr_bank_0[addr & 0xfff]; } else { - return mapper->chr_bank_1[addr - 0x1000]; + return mapper->chr_bank_1[addr & 0xfff]; } } else { - // 8KB mode - return mapper->chr_bank_0[addr]; + return mapper->chr_bank_0[addr & 0x1fff]; } } -__attribute__((section(".mapper_001_0"))) static void mapper_001_0_chr_write(struct nes_state *state, uint32_t addr, uint8_t value) { - // CHR RAM write (if present) state->chr_ram[addr] = value; } -__attribute__((section(".mapper_001_0"))) static uint8_t mapper_001_0_ciram_read(struct nes_state *state, uint32_t addr) { - return state->ciram[addr & 0x3ff]; + // MMC1 can set mirroring mode dynamically via control register + switch(state->ines.mirroring) { + case MIRROR_ONESCREEN_LOW: + addr = addr & 0x3ff; + break; + case MIRROR_ONESCREEN_HIGH: + addr = 0x400 | (addr & 0x3ff); + break; + case MIRROR_HORIZONTAL: // Horizontal: NT0↔NT1, NT2↔NT3 + addr = ((addr >> 1) & 0x400) | (addr & 0x3ff); + break; + case MIRROR_VERTICAL: // Vertical: NT0↔NT2, NT1↔NT3 + addr = addr & 0x7ff; + break; + } + return state->ciram[addr]; } -__attribute__((section(".mapper_001_0"))) static void mapper_001_0_ciram_write(struct nes_state *state, uint32_t addr, uint8_t value) { - state->ciram[addr & 0x3ff] = value; + // MMC1 can set mirroring mode dynamically via control register + switch(state->ines.mirroring) { + case MIRROR_ONESCREEN_LOW: + addr = addr & 0x3ff; + break; + case MIRROR_ONESCREEN_HIGH: + addr = 0x400 | (addr & 0x3ff); + break; + case MIRROR_HORIZONTAL: // Horizontal: NT0↔NT1, NT2↔NT3 + addr = ((addr >> 1) & 0x400) | (addr & 0x3ff); + break; + case MIRROR_VERTICAL: // Vertical: NT0↔NT2, NT1↔NT3 + addr = addr & 0x7ff; + break; + } + state->ciram[addr] = value; } -__attribute__((section(".mapper_001_0"))) static void mapper_001_0_init(struct nes_state *state) { struct mapper_001_0 *mapper = &state->mapper_data.m001_0; + mapper->shift = 0; + mapper->shift_count = 0; mapper->control = 0x0c; + + mapper->prg_bank = 0; + mapper->chr_bank0 = 0; + mapper->chr_bank1 = 0; + mapper->prg_rom_0 = state->prg_rom; mapper->prg_rom_1 = state->prg_rom + (state->ines.prg_size - 0x4000); - mapper->chr_bank_0 = state->chr_rom; - mapper->chr_bank_1 = state->chr_rom + 0x1000; + if(state->ines.chr_size) { + mapper->chr_bank_0 = state->chr_rom; + mapper->chr_bank_1 = state->chr_rom + 0x1000; + } else { + mapper->chr_bank_0 = state->chr_ram; + mapper->chr_bank_1 = state->chr_ram + 0x1000; + } - 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; + 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 b65ce33..2145b52 100644 --- a/mappers/mapper_002_2.c +++ b/mappers/mapper_002_2.c @@ -1,6 +1,5 @@ -__attribute__((section(".mapper_002_2"))) 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; @@ -10,24 +9,20 @@ static uint8_t mapper_002_2_prg_rom_read(struct nes_state *state, uint32_t addr) return mapper->prg_bank0[addr & 0x3fff]; } -__attribute__((section(".mapper_002_2"))) 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; mapper->prg_bank0 = state->prg_rom + ((value & 0x0f) * 0x4000); } -__attribute__((section(".mapper_002_2"))) static uint8_t mapper_002_2_chr_read(struct nes_state *state, uint32_t addr) { return state->chr_ram[addr]; } -__attribute__((section(".mapper_002_2"))) static void mapper_002_2_chr_write(struct nes_state *state, uint32_t addr, uint8_t value) { state->chr_ram[addr] = value; } -__attribute__((section(".mapper_002_2"))) static void mapper_002_2_init(struct nes_state *state) { struct mapper_002_2 *mapper = &state->mapper_data.m002_2; diff --git a/mappers/mapper_003_0.c b/mappers/mapper_003_0.c index 8c754a3..cab17a2 100644 --- a/mappers/mapper_003_0.c +++ b/mappers/mapper_003_0.c @@ -1,10 +1,8 @@ -__attribute__((section(".mapper_003_0"))) 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_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) { struct mapper_003_0 *mapper = &state->mapper_data.m003_0; @@ -13,13 +11,11 @@ static void mapper_003_0_prg_rom_write(struct nes_state *state, uint32_t addr, u } } -__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 = &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 = &state->mapper_data.m003_0; diff --git a/mappers/mapper_003_1.c b/mappers/mapper_003_1.c index 68e67c7..2f4b504 100644 --- a/mappers/mapper_003_1.c +++ b/mappers/mapper_003_1.c @@ -1,10 +1,8 @@ -__attribute__((section(".mapper_003_1"))) 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_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) { struct mapper_003_1 *mapper = &state->mapper_data.m003_1; @@ -13,13 +11,11 @@ static void mapper_003_1_prg_rom_write(struct nes_state *state, uint32_t addr, u } } -__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 = &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 = &state->mapper_data.m003_1; diff --git a/mappers/mapper_003_2.c b/mappers/mapper_003_2.c index 9c0d40d..1c67fc8 100644 --- a/mappers/mapper_003_2.c +++ b/mappers/mapper_003_2.c @@ -1,10 +1,8 @@ -__attribute__((section(".mapper_003_2"))) 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_rom_write(struct nes_state *state, uint32_t addr, uint8_t value) { struct mapper_003_2 *mapper = &state->mapper_data.m003_2; @@ -14,13 +12,11 @@ static void mapper_003_2_prg_rom_write(struct nes_state *state, uint32_t addr, u } } -__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 = &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 = &state->mapper_data.m003_2; diff --git a/mappers/mapper_007_2.c b/mappers/mapper_007_2.c index 7f5963f..9f5a3dc 100644 --- a/mappers/mapper_007_2.c +++ b/mappers/mapper_007_2.c @@ -1,5 +1,4 @@ -__attribute__((section(".mapper_007_2"))) 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; @@ -9,7 +8,6 @@ static uint8_t mapper_007_2_prg_rom_read(struct nes_state *state, uint32_t addr) return 0; } -__attribute__((section(".mapper_007_2"))) 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) { @@ -23,29 +21,24 @@ static void mapper_007_2_prg_rom_write(struct nes_state *state, uint32_t addr, u } } -__attribute__((section(".mapper_007_2"))) static uint8_t mapper_007_2_chr_read(struct nes_state *state, uint32_t addr) { return state->chr_ram[addr]; } -__attribute__((section(".mapper_007_2"))) static void mapper_007_2_chr_write(struct nes_state *state, uint32_t addr, uint8_t value) { state->chr_ram[addr] = value; } -__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 = &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 = &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 = &state->mapper_data.m007_2; mapper->prg_rom = state->prg_rom; diff --git a/mappers/mapper_011_0.c b/mappers/mapper_011_0.c index d324fcf..12b68ba 100644 --- a/mappers/mapper_011_0.c +++ b/mappers/mapper_011_0.c @@ -1,5 +1,4 @@ -__attribute__((section(".mapper_011_0"))) 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; @@ -9,7 +8,6 @@ static uint8_t mapper_011_0_prg_rom_read(struct nes_state *state, uint32_t addr) return 0; } -__attribute__((section(".mapper_011_0"))) 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; @@ -19,14 +17,12 @@ static void mapper_011_0_prg_rom_write(struct nes_state *state, uint32_t addr, u } } -__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 = &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 = &state->mapper_data.m011_0; diff --git a/mappers/mapper_066_0.c b/mappers/mapper_066_0.c index bd4c124..23cba94 100644 --- a/mappers/mapper_066_0.c +++ b/mappers/mapper_066_0.c @@ -1,12 +1,10 @@ -__attribute__((section(".mapper_066_0"))) 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; return mapper->prg_offset[addr & 0x7fff]; } -__attribute__((section(".mapper_066_0"))) 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; @@ -17,13 +15,11 @@ static void mapper_066_0_prg_rom_write(struct nes_state *state, uint32_t addr, u mapper->chr_offset = state->chr_rom + (chr_bank * 0x2000); } -__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 = &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 = &state->mapper_data.m066_0; |
