-/*\r
-iNES mapper #19\r
-\r
-Many cartridges uses epoxies for ROM, RAM and mapper. Few cartridges \r
-uses discrete parts. Other functions are various though the memory \r
-mapping is common. \r
-\r
-The mistake of an old document is an etymology of 'namcot 106'. I have\r
-seen mapper IC with 163 (well known chip), 129, 175 and 340 for #19. \r
-I have never seen labeled IC with '106'. \r
-'106' is informal virtual name, and the relic of old emulators. \r
-*/\r
-function cpu_dump(d, pagesize, banksize)\r
-{\r
- for(local i = 0; i < pagesize - 2; i += 2){\r
- cpu_write(d, 0xe000, i);\r
- cpu_write(d, 0xe800, i | 1);\r
- cpu_read(d, 0x8000, banksize * 2);\r
- }\r
- cpu_write(d, 0xf000, 0x3e);\r
- cpu_read(d, 0xc000, banksize * 2);\r
-}\r
-\r
-function ppu_dump(d, pagesize, banksize)\r
-{\r
- cpu_write(d, 0xe800, 0xe0);\r
- for(local i = 0; i < pagesize; i += 8){\r
- local address = 0x8000;\r
- for(local j = 0; j < 8; j++){\r
- cpu_write(d, address, i | j);\r
- address += 0x0800;\r
- }\r
- ppu_read(d, 0, banksize * 8);\r
- }\r
-}\r
-\r
-function program_initalize(d, cpu_banksize, ppu_banksize)\r
-{\r
- cpu_command(d, 0x0000, 0xa000, cpu_banksize);\r
- cpu_command(d, 0x2aaa, 0x8000, cpu_banksize);\r
- cpu_command(d, 0x5555, 0xa000, cpu_banksize);\r
- cpu_write(d, 0xe000, 0x41);\r
- cpu_write(d, 0xe800, 0xe2);\r
-\r
- ppu_command(d, 0x0000, 0x0000, ppu_banksize);\r
- ppu_command(d, 0x2aaa, 0x0400, ppu_banksize);\r
- ppu_command(d, 0x5555, 0x0800, ppu_banksize);\r
- cpu_write(d, 0x8000, 0x00);\r
- cpu_write(d, 0x8800, 0x0a);\r
- cpu_write(d, 0x9000, 0x15);\r
- //map 0x2000-0x2fff is RAM\r
- cpu_write(d, 0xc000, 0xe0);\r
- cpu_write(d, 0xc800, 0xe0);\r
- cpu_write(d, 0xd000, 0xe1);\r
- cpu_write(d, 0xd800, 0xe1);\r
-}\r
-\r
-function cpu_transfer(d, start, end, cpu_banksize)\r
-{\r
- for(local i = start; i < end - 1; i += 1){\r
- cpu_write(d, 0xf000, i | 0xe0);\r
- cpu_program(d, 0xc000, cpu_banksize);\r
- }\r
- cpu_program(d, 0xe000, cpu_banksize)\r
-}\r
-\r
-function ppu_transfer(d, start, end, ppu_banksize)\r
-{\r
- for(local i = start; i < end; i += 4){\r
- cpu_write(d, 0xa000, i);\r
- cpu_write(d, 0xa800, i | 1);\r
- cpu_write(d, 0xb000, i | 2);\r
- cpu_write(d, 0xb800, i | 3);\r
- ppu_program(d, 0x1000, ppu_banksize * 4);\r
- }\r
-}\r
+/*
+iNES mapper #19
+
+Many cartridges uses epoxies for ROM, RAM and mapper. Few cartridges
+uses discrete parts. Other functions are various though the memory
+mapping is common.
+
+The mistake of an old document is an etymology of 'namcot 106'. I have
+seen mapper IC with 163 (well known chip), 129, 175 and 340 for #19.
+I have never seen labeled IC with '106'.
+'106' is informal virtual name, and the relic of old emulators.
+*/
+function cpu_dump(d, pagesize, banksize)
+{
+ for(local i = 0; i < pagesize - 2; i += 2){
+ cpu_write(d, 0xe000, i);
+ cpu_write(d, 0xe800, i | 1);
+ cpu_read(d, 0x8000, banksize * 2);
+ }
+ cpu_write(d, 0xf000, 0x3e);
+ cpu_read(d, 0xc000, banksize * 2);
+}
+
+function ppu_dump(d, pagesize, banksize)
+{
+ cpu_write(d, 0xe800, 0xe0);
+ for(local i = 0; i < pagesize; i += 8){
+ local address = 0x8000;
+ for(local j = 0; j < 8; j++){
+ cpu_write(d, address, i | j);
+ address += 0x0800;
+ }
+ ppu_read(d, 0, banksize * 8);
+ }
+}
+
+function program_initalize(d, cpu_banksize, ppu_banksize)
+{
+ cpu_command(d, 0x0000, 0xa000, cpu_banksize);
+ cpu_command(d, 0x2aaa, 0x8000, cpu_banksize);
+ cpu_command(d, 0x5555, 0xa000, cpu_banksize);
+ cpu_write(d, 0xe000, 0x41);
+ cpu_write(d, 0xe800, 0xe2);
+
+ ppu_command(d, 0x0000, 0x0000, ppu_banksize);
+ ppu_command(d, 0x2aaa, 0x0400, ppu_banksize);
+ ppu_command(d, 0x5555, 0x0800, ppu_banksize);
+ cpu_write(d, 0x8000, 0x00);
+ cpu_write(d, 0x8800, 0x0a);
+ cpu_write(d, 0x9000, 0x15);
+ //map 0x2000-0x2fff is RAM
+ cpu_write(d, 0xc000, 0xe0);
+ cpu_write(d, 0xc800, 0xe0);
+ cpu_write(d, 0xd000, 0xe1);
+ cpu_write(d, 0xd800, 0xe1);
+}
+
+function cpu_transfer(d, start, end, cpu_banksize)
+{
+ for(local i = start; i < end - 1; i += 1){
+ cpu_write(d, 0xf000, i | 0xe0);
+ cpu_program(d, 0xc000, cpu_banksize);
+ }
+ cpu_program(d, 0xe000, cpu_banksize)
+}
+
+function ppu_transfer(d, start, end, ppu_banksize)
+{
+ for(local i = start; i < end; i += 4){
+ cpu_write(d, 0xa000, i);
+ cpu_write(d, 0xa800, i | 1);
+ cpu_write(d, 0xb000, i | 2);
+ cpu_write(d, 0xb800, i | 3);
+ ppu_program(d, 0x1000, ppu_banksize * 4);
+ }
+}