-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapper002.cpp
More file actions
34 lines (25 loc) · 1.12 KB
/
mapper002.cpp
File metadata and controls
34 lines (25 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "mapper002.hpp"
/**** iNES mapper 002 ****/
uint32_t Mapper002::MapReadPRG(uint16_t address, bool &fromRAM)
{
uint32_t mappedAddress = 0x00000000;
if (address >= 0x8000 && address <= 0xBFFF) // low 16 KiB of address space mapped to selected PRG ROM bank
mappedAddress = mappedPRGBank * 0x4000 + (address & 0x3FFF); // mapped address == mapped bank number * 16 KiB + offset
if (address >= 0xC000 && address <= 0xFFFF) // last 16 KiB of address space always mapped to last PRG ROM bank
mappedAddress = (numBanksPRG - 1) * 0x4000 + (address & 0x3FFF); // mapped address == index of last bank * 16 KiB + offset
return mappedAddress;
}
uint32_t Mapper002::MapWritePRG(uint16_t address, uint8_t data, bool &toRAM)
{
if (address >= 0x8000 && address <= 0xFFFF) // writing to 0x8000 - 0xFFFF selects PRG bank
mappedPRGBank = data & 0x0F;
return 0x00000000;
}
uint32_t Mapper002::MapReadCHR(uint16_t address)
{
return address;
}
uint32_t Mapper002::MapWriteCHR(uint16_t address)
{
return address;
}