OSDN Git Service

flash programming is supported
[unagi/old-svn-converted.git] / client / trunk / anago / konami_vrc7.ag
1 /*VRC7 FLASH MEMORY WRITE
2 generic CPU memory bank
3 cpu address|rom address    |page|task
4 $8000-$9fff|0x02000-0x03fff|1   |write (0x2aaa & 0x1fff) + 0x8000
5 $a000-$bfff|0x04000-0x05fff|2   |write (0x5555 & 0x1fff) + 0xa000
6 $c000-$dfff|n * 0x2000     |n   |write area
7 $e000-$efff|末尾           |fix |boot area, 未使用*/
8 board <- {
9         mappernum = 85, vram_mirrorfind = false, ppu_ramfind = true,
10         cpu_rom = {banksize = 0x2000, size_max = 4 * mega, size_base = 1 * mega},
11         cpu_ram = {banksize = 0x2000, size_max = 0x2000, size_base = 0x2000},
12         ppu_rom = {banksize = 0x2000 / 8, size_max = 2 * mega, size_base = 1* mega}
13 };
14 function cpu_dump(d, pagesize, banksize)
15 {
16         for(local i = 0; i < pagesize - 2; i += 2){
17                 cpu_write(d, 0x8000, i);
18                 cpu_write(d, 0x8018, i | 1);
19                 cpu_read(d, 0x8000, banksize * 2);
20         }
21         cpu_write(d, 0x9000, 0x3e);
22         cpu_read(d, 0xc000, banksize * 2);
23 }
24
25 function ppu_dump(d, pagesize, banksize)
26 {
27         cpu_write(d, 0xa000, 0);
28         for(local i = 0; i < pagesize; i += 8){
29                 local t = i;
30                 for(local j = 0xa000; j < 0xe000; j += 0x1000){
31                         cpu_write(d, j, t++);
32                         cpu_write(d, j+0x18, t++);
33                 }
34                 ppu_read(d, 0, banksize * 8);
35         }
36 }
37
38 function cpu_ram_access(d, pagesize, banksize)
39 {
40         cpu_write(d, 0xe000, 0x80);
41         cpu_ramrw(d, 0x6000, banksize);
42         cpu_write(d, 0xe000, 0x00);
43 }
44
45 /*
46 this is RC851/352402 style. RV051/353429 style is not supported.
47 352402: Program ROM/ Charcter RAM/ Backup RAM/ R1 = A5, R0 = A4/ Extra Sound
48 353429: Program ROM/ Charcter ROM/ R1 = A3, R0 = ?
49 */
50 function initalize(d, cpu_banksize, ppu_banksize)
51 {
52         cpu_command(d, 0, 0xc000, cpu_banksize);
53         cpu_command(d, 0x2aaa, 0x8000, cpu_banksize);
54         cpu_command(d, 0x5555, 0xa000, cpu_banksize);
55         cpu_write(d, 0x8000, 1);
56         cpu_write(d, 0x8010, 2);
57         cpu_write(d, 0x9000, 0);
58 }
59 function cpu_transfer(d, start, end, banksize)
60 {
61         for(local i = start; i < end - 1; i += 1){
62                 cpu_write(d, 0x9000, i);
63                 cpu_program(d, 0xc000, banksize);
64         }
65         cpu_program(d, 0xe000, banksize);
66 }
67 function ppu_transfer(d, start, end, size)
68 {
69 }