1 | #include "ppu.hpp" |
---|---|
2 | #include "mappers/mapper2.hpp" |
3 | |
4 | /* Based off of https://wiki.nesdev.com/w/index.php/UxROM */ |
5 | |
6 | /* Apply the registers state */ |
7 | void Mapper2::apply() |
8 | { |
9 | /* |
10 | * 16 kb PRG ROM Banks |
11 | * 0x8000 - 0xBFFF swappable |
12 | * 0xC000 - 0xFFFF fixed |
13 | */ |
14 | map_prg<16>(0, regs[0] & 0xF); |
15 | map_prg<16>(1, 0xF); |
16 | |
17 | /* 8k of CHR */ |
18 | map_chr<8>(0, 0); |
19 | |
20 | /* mirroring is based on the header (soldered) */ |
21 | set_mirroring(vertical_mirroring?PPU::VERTICAL:PPU::HORIZONTAL); |
22 | } |
23 | |
24 | u8 Mapper2::write(u16 addr, u8 v) |
25 | { |
26 | /* check for bus contingency? (addr & 0x8000 == v?) nah */ |
27 | |
28 | /* bank switching */ |
29 | if (addr & 0x8000) |
30 | { |
31 | regs[0] = v; |
32 | apply(); |
33 | } |
34 | return v; |
35 | } |
36 | |
37 | u8 Mapper2::chr_write(u16 addr, u8 v) |
38 | { |
39 | return chr[addr] = v; |
40 | } |
41 |