OSDN Git Service

cartrdige script を管理開始 (なぜかやってなかった)
[unagi/old-svn-converted.git] / client / trunk / anago / vrc6b.af
1 /*VRC6 type B/351949A/address bus A0=R1, A1=R0
2 CPU memory bank
3 cpu address|rom address    |page|task
4 $8000-$bfff|n * 0x4000     |even|write area + write 0x2aaa
5 $c000-$dfff|0x04000-0x05fff|2   |write 0x5555
6 -------------------------------------
7 $8000-$bfff|n * 0x4000     |odd |write area + write 0x5555
8 $c000-$dfff|0x02000-0x03fff|1   |write 0x2aaa
9 $e000-$efff|末尾           |fix |boot area, 未使用
10
11 PPU memory bank
12 ppu address|rom address    |page|task
13 $0000-$03ff|0x02800-0x02bff|0x0a|write (0x2aaa & 0x03ff) + 0
14 $0400-$07ff|0x05400-0x057ff|0x15|write (0x5555 & 0x03ff) + 0x400
15 $1000-$1fff|n * 0x1000     |n   |write area*/
16 board <- {
17         mappernum = 26, vram_mirrorfind = false,
18         cpu = {banksize = 0x4000, maxsize = 2 * mega},
19         ppu = {banksize = 0x0400, maxsize = 2 * mega},
20 }
21 function cpubank_even_set(d, bank, cpu_banksize)
22 {
23         cpu_command(d, 0x2aaa, 0x8000, cpu_banksize);
24         cpu_command(d, 0x5555, 0xc000, 0x2000);
25         cpu_write(d, 0x8000, bank)
26         cpu_write(d, 0xc000, 2)
27 }
28 function initalize(d, cpu_banksize, ppu_banksize)
29 {
30         cpubank_even_set(d, 0, cpu_banksize);
31         cpu_command(d, 0, 0x8000, cpu_banksize);
32
33         ppu_command(d, 0x2aaa, 0, ppu_banksize);
34         ppu_command(d, 0x5555, 0x0400, ppu_banksize);
35         ppu_command(d, 0, 0x0800, ppu_banksize);
36         
37         cpu_write(d, 0xb003, 0); //work ram disable
38         cpu_write(d, 0xd000, 0x0a);
39         cpu_write(d, 0xd002, 0x15);
40         cpu_write(d, 0xd001, 0x00);
41         cpu_write(d, 0xd003, 0x00);
42 }
43 function cpu_transfer(d, start, end, cpu_banksize)
44 {
45         local i;
46         for(i = start; i < end - 2; i += 2){
47                 cpubank_even_set(d, i, cpu_banksize);
48                 cpu_program(d, 0x8000, cpu_banksize);
49                 
50                 cpu_command(d, 0x5555, 0x8000, cpu_banksize);
51                 cpu_command(d, 0x2aaa, 0xc000, 0x2000);
52                 cpu_write(d, 0x8000, i | 1)
53                 cpu_write(d, 0xc000, 1)
54                 cpu_program(d, 0x8000, cpu_banksize);
55         }
56         cpubank_even_set(d, i, cpu_banksize);
57         cpu_program(d, 0x8000, cpu_banksize);
58
59         cpu_command(d, 0x5555, 0x8000, cpu_banksize);
60         cpu_command(d, 0x2aaa, 0xc000, 0x2000);
61         cpu_write(d, 0x8000, i | 1)
62         cpu_write(d, 0xc000, 1)
63         cpu_program(d, 0x8000, cpu_banksize);
64 }
65
66 function ppu_transfer(d, start, end, ppu_banksize)
67 {
68         for(local i = start; i < end; i += 4){
69                 cpu_write(d, 0xe000, i | 0);
70                 cpu_write(d, 0xe002, i | 1);
71                 cpu_write(d, 0xe001, i | 2);
72                 cpu_write(d, 0xe003, i | 3);
73                 ppu_program(d, 0x1000, ppu_banksize * 4);
74         }
75 }