#include "../include/mapper.h" #include "../include/rom.h" #include "../cpu/memory.h" #define PRG_BANK_SIZE 0x4000 // 16Kb byte *nrom_mem_read(address addr) { Rom *rom = rom_get(); if (addr < PRG_BANK_SIZE || rom->prg_rom_size > PRG_BANK_SIZE) { return &rom->prg_rom[addr]; } // The second bank is mirrored return &rom->prg_rom[addr - PRG_BANK_SIZE]; } byte *nrom_ppu_read(address addr) { if (addr < 0x2000) { Rom *rom = rom_get(); return &rom->chr_rom[addr]; } return NULL; } Mapper get_simple_mapper() { Mapper mapper; mapper.mem_read = &nrom_mem_read; mapper.ppu_read = &nrom_ppu_read; return mapper; }