src/mame/machine/snes.c
| r7773 | r7774 | |
| 6 | 6 | |
| 7 | 7 | R. Belmont |
| 8 | 8 | Anthony Kruize |
| 9 | Angelo Salese |
| 10 | Fabio Priuli |
| 9 | 11 | Harmony |
| 10 | 12 | Based on the original code by Lee Hammerton (aka Savoury Snax) |
| 11 | 13 | Thanks to Anomie for invaluable technical information. |
| r7773 | r7774 | |
| 955 | 957 | else |
| 956 | 958 | value = snes_ram[offset]; |
| 957 | 959 | |
| 958 | | cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset)); |
| 960 | if(!space->debugger_access) |
| 961 | cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset)); |
| 962 | |
| 959 | 963 | return value; |
| 960 | 964 | } |
| 961 | 965 | |
| r7773 | r7774 | |
| 1012 | 1016 | else |
| 1013 | 1017 | value = snes_ram[0x300000 + offset]; |
| 1014 | 1018 | |
| 1015 | | cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset)); |
| 1019 | if(!space->debugger_access) |
| 1020 | cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset)); |
| 1016 | 1021 | |
| 1017 | 1022 | return value; |
| 1018 | 1023 | } |
| r7773 | r7774 | |
| 1052 | 1057 | else /* Mode 21 & 25 + SuperFX games */ |
| 1053 | 1058 | value = snes_ram[0x400000 + offset]; |
| 1054 | 1059 | |
| 1055 | | cpu_adjust_icount(space->cpu, -8); |
| 1060 | if(!space->debugger_access) |
| 1061 | cpu_adjust_icount(space->cpu, -8); |
| 1062 | |
| 1056 | 1063 | return value; |
| 1057 | 1064 | } |
| 1058 | 1065 | |
| r7773 | r7774 | |
| 1088 | 1095 | else if (snes_cart.mode & 0x0a) /* Mode 21 & 25 */ |
| 1089 | 1096 | value = snes_ram[0x600000 + offset]; |
| 1090 | 1097 | |
| 1091 | | cpu_adjust_icount(space->cpu, -8); |
| 1098 | if(!space->debugger_access) |
| 1099 | cpu_adjust_icount(space->cpu, -8); |
| 1100 | |
| 1092 | 1101 | return value; |
| 1093 | 1102 | } |
| 1094 | 1103 | |
| r7773 | r7774 | |
| 1122 | 1131 | else |
| 1123 | 1132 | value = snes_ram[0x700000 + offset]; |
| 1124 | 1133 | |
| 1125 | | cpu_adjust_icount(space->cpu, -8); |
| 1134 | if(!space->debugger_access) |
| 1135 | cpu_adjust_icount(space->cpu, -8); |
| 1136 | |
| 1126 | 1137 | return value; |
| 1127 | 1138 | } |
| 1128 | 1139 | |
| r7773 | r7774 | |
| 1168 | 1179 | else |
| 1169 | 1180 | value = snes_ram[0x800000 + offset]; |
| 1170 | 1181 | |
| 1171 | | cpu_adjust_icount(space->cpu, -snes_bank_0x80_0xbf_cycles(space->machine, offset)); |
| 1182 | if(!space->debugger_access) |
| 1183 | cpu_adjust_icount(space->cpu, -snes_bank_0x80_0xbf_cycles(space->machine, offset)); |
| 1184 | |
| 1172 | 1185 | return value; |
| 1173 | 1186 | } |
| 1174 | 1187 | |
| r7773 | r7774 | |
| 1219 | 1232 | else /* Mode 21 & 25 + SuperFX Games */ |
| 1220 | 1233 | value = snes_ram[0xc00000 + offset]; |
| 1221 | 1234 | |
| 1222 | | cpu_adjust_icount(space->cpu, -((snes_ram[MEMSEL] & 1) ? 6 : 8)); |
| 1235 | if(!space->debugger_access) |
| 1236 | cpu_adjust_icount(space->cpu, -((snes_ram[MEMSEL] & 1) ? 6 : 8)); |
| 1223 | 1237 | |
| 1224 | 1238 | return value; |
| 1225 | 1239 | } |
| r7773 | r7774 | |
| 1266 | 1280 | else |
| 1267 | 1281 | logerror( "(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset ); |
| 1268 | 1282 | |
| 1269 | | cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset)); |
| 1283 | if(!space->debugger_access) |
| 1284 | cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset)); |
| 1270 | 1285 | } |
| 1271 | 1286 | |
| 1272 | 1287 | /* 0x300000 - 0x3fffff */ |
| r7773 | r7774 | |
| 1317 | 1332 | else |
| 1318 | 1333 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x300000); |
| 1319 | 1334 | |
| 1320 | | cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset)); |
| 1335 | if(!space->debugger_access) |
| 1336 | cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset)); |
| 1321 | 1337 | } |
| 1322 | 1338 | |
| 1323 | 1339 | /* 0x600000 - 0x6fffff */ |
| r7773 | r7774 | |
| 1341 | 1357 | else if (snes_cart.mode & 0x0a) |
| 1342 | 1358 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x600000); |
| 1343 | 1359 | |
| 1344 | | cpu_adjust_icount(space->cpu, -8); |
| 1360 | if(!space->debugger_access) |
| 1361 | cpu_adjust_icount(space->cpu, -8); |
| 1345 | 1362 | } |
| 1346 | 1363 | |
| 1347 | 1364 | /* 0x700000 - 0x7dffff */ |
| r7773 | r7774 | |
| 1364 | 1381 | else if (snes_cart.mode & 0x0a) |
| 1365 | 1382 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x700000); |
| 1366 | 1383 | |
| 1367 | | cpu_adjust_icount(space->cpu, -8); |
| 1384 | if(!space->debugger_access) |
| 1385 | cpu_adjust_icount(space->cpu, -8); |
| 1368 | 1386 | } |
| 1369 | 1387 | |
| 1370 | 1388 | |
| r7773 | r7774 | |
| 1411 | 1429 | else |
| 1412 | 1430 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x800000); |
| 1413 | 1431 | |
| 1414 | | cpu_adjust_icount(space->cpu, -snes_bank_0x80_0xbf_cycles(space->machine, offset)); |
| 1432 | if(!space->debugger_access) |
| 1433 | cpu_adjust_icount(space->cpu, -snes_bank_0x80_0xbf_cycles(space->machine, offset)); |
| 1415 | 1434 | } |
| 1416 | 1435 | |
| 1417 | 1436 | |
| r7773 | r7774 | |
| 1449 | 1468 | else if (snes_cart.mode & 0x0a) |
| 1450 | 1469 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0xc00000); |
| 1451 | 1470 | |
| 1452 | | cpu_adjust_icount(space->cpu, -((snes_ram[MEMSEL] & 1) ? 6 : 8)); |
| 1471 | if(!space->debugger_access) |
| 1472 | cpu_adjust_icount(space->cpu, -((snes_ram[MEMSEL] & 1) ? 6 : 8)); |
| 1453 | 1473 | } |
| 1454 | 1474 | |
| 1455 | 1475 | |
| r7773 | r7774 | |
| 1703 | 1723 | snes_ram[WRDIVL] = 0xff; |
| 1704 | 1724 | snes_ram[WRDIVH] = 0xff; |
| 1705 | 1725 | |
| 1726 | /* init DMA regs to be 0xff */ |
| 1727 | { |
| 1728 | int i; |
| 1729 | |
| 1730 | for(i=0;i<8;i++) |
| 1731 | { |
| 1732 | state->dma_channel[i].dmap = 0xff; |
| 1733 | state->dma_channel[i].dest_addr = 0xff; |
| 1734 | state->dma_channel[i].src_addr = 0xffff; |
| 1735 | state->dma_channel[i].bank = 0xff; |
| 1736 | state->dma_channel[i].trans_size = 0xffff; |
| 1737 | state->dma_channel[i].ibank = 0xff; |
| 1738 | state->dma_channel[i].hdma_addr = 0xffff; |
| 1739 | state->dma_channel[i].hdma_line_counter = 0xff; |
| 1740 | state->dma_channel[i].unk = 0xff; |
| 1741 | } |
| 1742 | } |
| 1743 | |
| 1706 | 1744 | switch (snes_has_addon_chip) |
| 1707 | 1745 | { |
| 1708 | 1746 | case HAS_SDD1: |
| r7773 | r7774 | |
| 2035 | 2073 | |
| 2036 | 2074 | bbus = state->dma_channel[i].dest_addr + 0x2100; |
| 2037 | 2075 | |
| 2076 | |
| 2077 | |
| 2038 | 2078 | switch (state->dma_channel[i].dmap & 0x07) |
| 2039 | 2079 | { |
| 2040 | 2080 | case 0: /* 1 register write once (1 byte: p ) */ |
| r7773 | r7774 | |
| 2140 | 2180 | /* Number of bytes to transfer */ |
| 2141 | 2181 | length = state->dma_channel[i].trans_size; |
| 2142 | 2182 | |
| 2143 | | // printf( "DMA-Ch %d: len: %X, abus: %X, bbus: %X, incr: %d, dir: %s, type: %d\n", i, length, abus | abus_bank, bbus, increment, state->dma_channel[i].dmap & 0x80 ? "PPU->CPU" : "CPU->PPU", state->dma_channel[i].dmap & 0x07); |
| 2183 | // printf( "DMA-Ch %d: len: %X, abus: %X, bbus: %X, incr: %d, dir: %s, type: %d\n", i, length, abus | abus_bank, bbus, increment, state->dma_channel[i].dmap & 0x80 ? "PPU->CPU" : "CPU->PPU", state->dma_channel[i].dmap & 0x07); |
| 2144 | 2184 | |
| 2145 | 2185 | #ifdef SNES_DBG_DMA |
| 2146 | 2186 | mame_printf_debug( "DMA-Ch %d: len: %X, abus: %X, bbus: %X, incr: %d, dir: %s, type: %d\n", i, length, abus | abus_bank, bbus, increment, state->dma_channel[i].dmap & 0x80 ? "PPU->CPU" : "CPU->PPU", state->dma_channel[i].dmap & 0x07); |