-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapper000.js
34 lines (29 loc) · 861 Bytes
/
mapper000.js
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
function Mapper000 (nPRGBanks, nCHRBanks) {
this.nPRGBanks = nPRGBanks
this.nCHRBanks = nCHRBanks
this.reset = () => {}
this.cpuMapRead = (addr) => {
if (addr >= 0x8000 && addr <= 0xFFFF) {
return { mappedAddr: addr & (this.nPRGBanks > 1 ? 0x7FFF : 0x3FFF), output: true }
}
else return { output: false }
}
this.cpuMapWrite = (addr) => {
if (addr >= 0x8000 && addr <= 0xFFFF) {
return { mappedAddr: addr & (this.nPRGBanks > 1 ? 0x7FFF : 0x3FFF), output: true }
}
else return { output: false }
}
this.ppuMapRead = (addr) => {
if (addr >= 0x0000 && addr <= 0x1FFF) {
return { mappedAddr: addr, output: true }
}
else return { output: false }
}
this.ppuMapWrite = (addr) => {
if (addr >= 0x0000 && addr <= 0x1FFF) {
if (this.nCHRBanks == 0) return { mappedAddr: addr, output: true }
}
return { output: false }
}
}