-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapper.c
66 lines (53 loc) · 1.02 KB
/
mapper.c
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
/* SPDX-License-Identifier: MIT */
#include <stdlib.h>
#include "util.h"
#include "mapper.h"
#define MODE(_a) if (mode == _a)
void
mappers_init(struct nes *nes)
{
MAP_DECL(00);
MAP_DECL(01);
}
void
mapper_init(struct nes *nes)
{
switch (nes->cartridge.mapper)
{
case 1:
break;
}
}
MAP_FUNC(00)
{
MODE(MAP_MODE_CPU)
{
IFINRANGE(addr, 0x8000, 0xFFFF)
{
return nes->cartridge.prg +
(addr & (nes->cartridge.s_prg_rom_16 > 1 ? 0x7FFF : 0x3FFF));
}
}
MODE(MAP_MODE_PPU)
{
IFINRANGE(addr, 0x0000, 0x1FFF) //
{
// printf("\n%04X\n", addr);
return nes->cartridge.chr + addr;
}
}
return (mem + addr);
}
MAP_FUNC(01)
{
MODE(MAP_MODE_CPU)
{
IFINRANGE(addr, 0x6000, 0x7FFF)
{
return nes->cartridge.prg_ram + (addr - 0x6000);
}
IFINRANGE(addr, 0x8000, 0xBFFF) {}
}
MODE(MAP_MODE_PPU) {}
return (mem + addr);
}