OSDN Git Service

07b5c693af7389d830d532351b16f4e51af7613c
[unagi/old-svn-converted.git] / client / trunk / anago / namcot_19.ai
1 /*
2 iNES mapper #19
3
4 Many cartridges uses epoxies for ROM, RAM and mapper. Few cartridges 
5 uses discrete parts. Other functions are various though the memory 
6 mapping is common. 
7
8 The mistake of an old document is an etymology of 'namcot 106'. I have
9 seen mapper IC with 163 (well known chip), 129, 175 and 340 for #19. 
10 I have never seen labeled IC with '106'. 
11 '106' is informal virtual name, and the relic of old emulators. 
12 */
13 function cpu_dump(d, pagesize, banksize)
14 {
15         for(local i = 0; i < pagesize - 2; i += 2){
16                 cpu_write(d, 0xe000, i);
17                 cpu_write(d, 0xe800, i | 1);
18                 cpu_read(d, 0x8000, banksize * 2);
19         }
20         cpu_write(d, 0xf000, 0x3e);
21         cpu_read(d, 0xc000, banksize * 2);
22 }
23
24 function ppu_dump(d, pagesize, banksize)
25 {
26         cpu_write(d, 0xe800, 0xe0);
27         for(local i = 0; i < pagesize; i += 8){
28                 local address = 0x8000;
29                 for(local j = 0; j < 8; j++){
30                         cpu_write(d, address, i | j);
31                         address += 0x0800;
32                 }
33                 ppu_read(d, 0, banksize * 8);
34         }
35 }
36
37 function program_initalize(d, cpu_banksize, ppu_banksize)
38 {
39         cpu_command(d, 0x0000, 0xa000, cpu_banksize);
40         cpu_command(d, 0x2aaa, 0x8000, cpu_banksize);
41         cpu_command(d, 0x5555, 0xa000, cpu_banksize);
42         cpu_write(d, 0xe000, 0x41);
43         cpu_write(d, 0xe800, 0xe2);
44
45         ppu_command(d, 0x0000, 0x0000, ppu_banksize);
46         ppu_command(d, 0x2aaa, 0x0400, ppu_banksize);
47         ppu_command(d, 0x5555, 0x0800, ppu_banksize);
48         cpu_write(d, 0x8000, 0x00);
49         cpu_write(d, 0x8800, 0x0a);
50         cpu_write(d, 0x9000, 0x15);
51         //map 0x2000-0x2fff is RAM
52         cpu_write(d, 0xc000, 0xe0);
53         cpu_write(d, 0xc800, 0xe0);
54         cpu_write(d, 0xd000, 0xe1);
55         cpu_write(d, 0xd800, 0xe1);
56 }
57
58 function cpu_transfer(d, start, end, cpu_banksize)
59 {
60         for(local i = start; i < end - 1; i += 1){
61                 cpu_write(d, 0xf000, i | 0xe0);
62                 cpu_program(d, 0xc000, cpu_banksize);
63         }
64         cpu_program(d, 0xe000, cpu_banksize)
65 }
66
67 function ppu_transfer(d, start, end, ppu_banksize)
68 {
69         for(local i = start; i < end; i += 4){
70                 cpu_write(d, 0xa000, i);
71                 cpu_write(d, 0xa800, i | 1);
72                 cpu_write(d, 0xb000, i | 2);
73                 cpu_write(d, 0xb800, i | 3);
74                 ppu_program(d, 0x1000, ppu_banksize * 4);
75         }
76 }