forked from arantius/anago-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nintendo_mmc4_fkrom.ae
83 lines (75 loc) · 2.01 KB
/
nintendo_mmc4_fkrom.ae
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
72
73
74
75
76
77
78
79
80
81
82
83
/*
HVC-2I Fire Emblem Gaiden
command line option
./anago d22 mmc4_fkrom.ae hvc_2i.nes b
*/
board <- {
mappernum = 10, vram_mirrorfind = false, ppu_ramfind = false,
cpu_rom = {
size_base = 1 * mega, size_max = 2 * mega,
banksize = 0x4000,
},
cpu_ram = {
size_base = 0x2000, size_max = 0x2000,
banksize = 0x2000,
},
ppu_rom = {
size_base = 0x10000, size_max = 1 * mega,
banksize = 0x1000
}
};
/*
[cpu memmorymap - read]
$6000-$7fff SRAM (battery backuped, optional)
$8000-$bfff program ROM bank #0
$c000-$ffff program ROM bank #1 (fixed)
[cpu memmorymap - write]
$a000-$afff program ROM bank register #0
$b000-$bfff charcter ROM bank register #0
$c000-$cfff charcter ROM bank register #1
$d000-$dfff charcter ROM bank register #2
$d000-$dfff charcter ROM bank register #3
[ppu memorymap - read]
0x0000-0x0fff charcter ROM bank #A (#0 or #1)
0x0fd0-0x0fdf charcter ROM bank register switch to #0
0x0fe0-0x0fef charcter ROM bank register switch to #1
0x1000-0x1fff charcter ROM bank #B (#2 or #3)
0x1fd0-0x1fdf charcter ROM bank register switch to #2
0x1fe0-0x1fef charcter ROM bank register switch to #3
*/
function cpu_dump(d, pagesize, banksize)
{
for(local i = 0; i < pagesize - 1; i += 1){
cpu_write(d, 0xa000, i);
cpu_read(d, 0x8000, banksize);
}
cpu_read(d, 0xc000, banksize);
}
/*
PPU の read 途中にバンクレジスタが切り替わるらしいので下記の処理で
同じデータを得るようにする。
PPU address register
0x0000-0x0fdf -> #0
0x0fe0-0x0fff -> #1
0x1000-0x1fdf -> #2
0x1fe0-0x1fff -> #3
ppu_read 前に #0 + #1 , #2 + #3 の内容は同じにしておく。
*/
function ppu_dump(d, pagesize, banksize)
{
for(local i = 0; i < pagesize; i += 2){
ppu_read(d, 0x0fd0, 0);
cpu_write(d, 0xb000, i);
ppu_read(d, 0x0fe0, 0);
cpu_write(d, 0xc000, i);
ppu_read(d, 0x1fd0, 0);
cpu_write(d, 0xd000, i + 1);
ppu_read(d, 0x1fe0, 0);
cpu_write(d, 0xe000, i + 1);
ppu_read(d, 0, banksize * 2);
}
}
function cpu_ram_access(d, pagesize, banksize)
{
cpu_ramrw(d, 0x6000, banksize);
}