src/mame/machine/snes.c
| r7745 | r7746 | |
| 809 | 809 | |
| 810 | 810 | */ |
| 811 | 811 | |
| 812 | /*FIXME: missing work RAM access steal */ |
| 813 | static int snes_bank_0x00_0x3f_cycles(running_machine *machine,UINT32 offset) |
| 814 | { |
| 815 | /* |
| 816 | $00-$3F | $0000-$1FFF | Slow | Address Bus A + /WRAM (mirror $7E:0000-$1FFF) |
| 817 | | $2000-$20FF | Fast | Address Bus A |
| 818 | | $2100-$21FF | Fast | Address Bus B |
| 819 | | $2200-$3FFF | Fast | Address Bus A |
| 820 | | $4000-$41FF | XSlow | Internal CPU registers (see Note 1 below) |
| 821 | | $4200-$43FF | Fast | Internal CPU registers (see Note 1 below) |
| 822 | | $4400-$5FFF | Fast | Address Bus A |
| 823 | | $6000-$7FFF | Slow | Address Bus A |
| 824 | | $8000-$FFFF | Slow | Address Bus A + /CART |
| 825 | */ |
| 826 | |
| 827 | if(((offset & 0xff00) == 0x4000) || ((offset & 0xff00) == 0x4100)) |
| 828 | return 12; |
| 829 | |
| 830 | if(((offset & 0xff00) >= 0x0000) && ((offset & 0xff00) <= 0x1f00)) |
| 831 | return 8; |
| 832 | |
| 833 | if((offset & 0xff00) >= 0x6000) |
| 834 | return 8; |
| 835 | |
| 836 | return 6; |
| 837 | } |
| 838 | |
| 839 | static int snes_bank_0x80_0xbf_cycles(running_machine *machine,UINT32 offset) |
| 840 | { |
| 841 | /* |
| 842 | $80-$BF | $0000-$1FFF | Slow | Address Bus A + /WRAM (mirror $7E:0000-$1FFF) |
| 843 | | $2000-$20FF | Fast | Address Bus A |
| 844 | | $2100-$21FF | Fast | Address Bus B |
| 845 | | $2200-$3FFF | Fast | Address Bus A |
| 846 | | $4000-$41FF | XSlow | Internal CPU registers (see Note 1 below) |
| 847 | | $4200-$43FF | Fast | Internal CPU registers (see Note 1 below) |
| 848 | | $4400-$5FFF | Fast | Address Bus A |
| 849 | | $6000-$7FFF | Slow | Address Bus A |
| 850 | | $8000-$FFFF | Note2 | Address Bus A + /CART |
| 851 | */ |
| 852 | |
| 853 | if(((offset & 0xff00) == 0x4000) || ((offset & 0xff00) == 0x4100)) |
| 854 | return 12; |
| 855 | |
| 856 | if(((offset & 0xff00) >= 0x0000) && ((offset & 0xff00) <= 0x1f00)) |
| 857 | return 8; |
| 858 | |
| 859 | if(((offset & 0xff00) >= 0x6000) && ((offset & 0xff00) <= 0x7f00)) |
| 860 | return 8; |
| 861 | |
| 862 | if(((offset & 0xff00) >= 0x8000) && ((offset & 0xff00) <= 0xff00)) |
| 863 | return (snes_ram[MEMSEL] & 1) ? 6 : 8; |
| 864 | |
| 865 | return 6; |
| 866 | } |
| 867 | |
| 812 | 868 | /* 0x000000 - 0x2fffff */ |
| 813 | 869 | READ8_HANDLER( snes_r_bank1 ) |
| 814 | 870 | { |
| r7745 | r7746 | |
| 855 | 911 | else |
| 856 | 912 | value = snes_ram[offset]; |
| 857 | 913 | |
| 914 | cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset)); |
| 858 | 915 | return value; |
| 859 | 916 | } |
| 860 | 917 | |
| r7745 | r7746 | |
| 911 | 968 | else |
| 912 | 969 | value = snes_ram[0x300000 + offset]; |
| 913 | 970 | |
| 971 | cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset)); |
| 972 | |
| 914 | 973 | return value; |
| 915 | 974 | } |
| 916 | 975 | |
| r7745 | r7746 | |
| 949 | 1008 | else /* Mode 21 & 25 + SuperFX games */ |
| 950 | 1009 | value = snes_ram[0x400000 + offset]; |
| 951 | 1010 | |
| 1011 | cpu_adjust_icount(space->cpu, -8); |
| 952 | 1012 | return value; |
| 953 | 1013 | } |
| 954 | 1014 | |
| r7745 | r7746 | |
| 984 | 1044 | else if (snes_cart.mode & 0x0a) /* Mode 21 & 25 */ |
| 985 | 1045 | value = snes_ram[0x600000 + offset]; |
| 986 | 1046 | |
| 1047 | cpu_adjust_icount(space->cpu, -8); |
| 987 | 1048 | return value; |
| 988 | 1049 | } |
| 989 | 1050 | |
| r7745 | r7746 | |
| 1017 | 1078 | else |
| 1018 | 1079 | value = snes_ram[0x700000 + offset]; |
| 1019 | 1080 | |
| 1081 | cpu_adjust_icount(space->cpu, -8); |
| 1020 | 1082 | return value; |
| 1021 | 1083 | } |
| 1022 | 1084 | |
| r7745 | r7746 | |
| 1062 | 1124 | else |
| 1063 | 1125 | value = snes_ram[0x800000 + offset]; |
| 1064 | 1126 | |
| 1127 | cpu_adjust_icount(space->cpu, -snes_bank_0x80_0xbf_cycles(space->machine, offset)); |
| 1065 | 1128 | return value; |
| 1066 | 1129 | } |
| 1067 | 1130 | |
| r7745 | r7746 | |
| 1112 | 1175 | else /* Mode 21 & 25 + SuperFX Games */ |
| 1113 | 1176 | value = snes_ram[0xc00000 + offset]; |
| 1114 | 1177 | |
| 1178 | cpu_adjust_icount(space->cpu, -(snes_ram[MEMSEL] & 1) ? 6 : 8); |
| 1179 | |
| 1115 | 1180 | return value; |
| 1116 | 1181 | } |
| 1117 | 1182 | |
| r7745 | r7746 | |
| 1156 | 1221 | dsp3_write(address, data); |
| 1157 | 1222 | else |
| 1158 | 1223 | logerror( "(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset ); |
| 1224 | |
| 1225 | cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset)); |
| 1159 | 1226 | } |
| 1160 | 1227 | |
| 1161 | 1228 | /* 0x300000 - 0x3fffff */ |
| r7745 | r7746 | |
| 1205 | 1272 | dsp4_write(data); |
| 1206 | 1273 | else |
| 1207 | 1274 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x300000); |
| 1275 | |
| 1276 | cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset)); |
| 1208 | 1277 | } |
| 1209 | 1278 | |
| 1210 | 1279 | /* 0x600000 - 0x6fffff */ |
| r7745 | r7746 | |
| 1227 | 1296 | } |
| 1228 | 1297 | else if (snes_cart.mode & 0x0a) |
| 1229 | 1298 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x600000); |
| 1299 | |
| 1300 | cpu_adjust_icount(space->cpu, -8); |
| 1230 | 1301 | } |
| 1231 | 1302 | |
| 1232 | 1303 | /* 0x700000 - 0x7dffff */ |
| r7745 | r7746 | |
| 1248 | 1319 | } |
| 1249 | 1320 | else if (snes_cart.mode & 0x0a) |
| 1250 | 1321 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x700000); |
| 1322 | |
| 1323 | cpu_adjust_icount(space->cpu, -8); |
| 1251 | 1324 | } |
| 1252 | 1325 | |
| 1253 | 1326 | |
| r7745 | r7746 | |
| 1293 | 1366 | dsp4_write(data); |
| 1294 | 1367 | else |
| 1295 | 1368 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x800000); |
| 1369 | |
| 1370 | cpu_adjust_icount(space->cpu, -snes_bank_0x80_0xbf_cycles(space->machine, offset)); |
| 1296 | 1371 | } |
| 1297 | 1372 | |
| 1298 | 1373 | |
| r7745 | r7746 | |
| 1329 | 1404 | } |
| 1330 | 1405 | else if (snes_cart.mode & 0x0a) |
| 1331 | 1406 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0xc00000); |
| 1407 | |
| 1408 | cpu_adjust_icount(space->cpu, -(snes_ram[MEMSEL] & 1) ? 6 : 8); |
| 1332 | 1409 | } |
| 1333 | 1410 | |
| 1334 | 1411 | |