1#pragma once
2#include <cstring>
3#include "common.hpp"
4
5
6class Mapper
7{
8 u8* rom;
9 bool chrRam = false;
10
11 protected:
12 u32 prgMap[4];
13 u32 chrMap[8];
14
15 u8 *prg, *chr, *prgRam;
16 u32 prgSize, chrSize, prgRamSize;
17
18 template <int pageKBs> void map_prg(int slot, int bank);
19 template <int pageKBs> void map_chr(int slot, int bank);
20
21 public:
22 Mapper(u8* rom);
23 ~Mapper();
24
25 u8 read(u16 addr);
26 virtual u8 write(u16 addr, u8 v) { return v; }
27
28 u8 chr_read(u16 addr);
29 virtual u8 chr_write(u16 addr, u8 v) { return v; }
30
31 virtual void signal_scanline() {}
32};
33