-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapper000.cpp
51 lines (43 loc) · 1.13 KB
/
Mapper000.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "Mapper000.hpp"
#include <stdint.h>
uint8_t Mapper000::ppu_map_read(uint16_t addr, uint32_t *mapped_addr)
{
if (addr >= 0x0000 && addr <= 0x1FFF)
{
*mapped_addr = addr;
return true;
}
*mapped_addr = 0x0000;
return false;
}
uint8_t Mapper000::ppu_map_write(uint16_t addr, uint32_t *mapped_addr)
{
// The system cannot write to the cartridge so
// this is always rejected.
*mapped_addr = 0x0000;
return false;
}
uint8_t Mapper000::cpu_map_read(uint16_t addr, uint32_t *mapped_addr, uint8_t *data)
{
if (addr >= 0x8000 && addr <= 0xFFFF)
{
*mapped_addr = addr & (prog_banks > 1 ? 0x7FFF : 0x3FFF);
return true;
}
*mapped_addr = 0x0000;
return false;
}
uint8_t Mapper000::cpu_map_write(uint16_t addr, uint32_t *mapped_addr, uint8_t data)
{
if (addr >= 0x8000 && addr <= 0xFFFF)
{
// If address within mapper range, then return mapped address which
// is indexed from zero to match ines file.
// If 32kB then just remove address 0x8000 offset.
// If 16kB then mirror address (0x3FFF = 16kB).
*mapped_addr = addr & (prog_banks > 1 ? 0x7FFF : 0x3FFF);
return true;
}
*mapped_addr = 0x0000;
return false;
}