-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMapper_000.hpp
71 lines (57 loc) · 1.43 KB
/
Mapper_000.hpp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include <iostream>
#include "Mapper.hpp"
using namespace std;
class Mapper_000 : public Mapper
{
public:
Mapper_000(uint8_t prgBanks, uint8_t chrBanks);
~Mapper_000();
public:
bool cpuMapRead(uint16_t addr, uint32_t &mapped_addr) override;
bool cpuMapWrite(uint16_t addr, uint32_t &mapped_addr, uint8_t data=0) override;
bool ppuMapRead(uint16_t addr, uint32_t &mapped_addr) override;
bool ppuMapWrite(uint16_t addr, uint32_t &mapped_addr) override;
};
Mapper_000::Mapper_000(uint8_t prgBanks, uint8_t chrBanks) : Mapper(prgBanks, chrBanks)
{
}
Mapper_000::~Mapper_000()
{
}
bool Mapper_000::cpuMapRead(uint16_t addr, uint32_t &mapped_addr)
{
if(addr >= 0x8000 && addr <= 0xFFFF)
{
mapped_addr=addr&(nPRGBanks>1 ? 0x7FFF: 0x3FFF);
return true;
}
return false;
}
bool Mapper_000::cpuMapWrite(uint16_t addr, uint32_t &mapped_addr, uint8_t data){
if(addr >= 0x8000 && addr <= 0xFFFF)
{
mapped_addr = addr & (nPRGBanks > 1 ? 0x7FFF : 0x3FFF);
return true;
}
return false;
}
bool Mapper_000::ppuMapRead(uint16_t addr, uint32_t &mapped_addr){
if(addr >= 0x0000 && addr <= 0x1FFF)
{
mapped_addr =addr;
return true;
}
return false;
}
bool Mapper_000::ppuMapWrite(uint16_t addr, uint32_t &mapped_addr){
if (addr <= 0x1FFF)
{
if (!nCHRBanks)
{
mapped_addr = addr;
return true;
}
}
return false;
}