src/mame/machine/snes.c
| r8081 | r8082 | |
| 26 | 26 | /* -- Globals -- */ |
| 27 | 27 | UINT8 *snes_ram = NULL; /* 65816 ram */ |
| 28 | 28 | |
| 29 | | UINT8 snes_has_addon_chip; |
| 30 | | UINT32 snes_rom_size; |
| 31 | | |
| 32 | 29 | static void snes_dma(const address_space *space, UINT8 channels); |
| 33 | 30 | static void snes_hdma_init(const address_space *space); |
| 34 | 31 | static void snes_hdma(const address_space *space); |
| r8081 | r8082 | |
| 49 | 46 | #include "machine/snessdd1.c" |
| 50 | 47 | #include "machine/snes7110.c" |
| 51 | 48 | #include "machine/snesst10.c" |
| 49 | #include "machine/snesbsx.c" |
| 52 | 50 | |
| 53 | 51 | /************************************* |
| 54 | 52 | |
| r8081 | r8082 | |
| 435 | 433 | return spc_port_out(state->spc700, offset & 0x3); |
| 436 | 434 | } |
| 437 | 435 | |
| 438 | | if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 436 | if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 439 | 437 | { |
| 440 | 438 | if (offset >= 0x3000 && offset < 0x3300) |
| 441 | 439 | { |
| 442 | 440 | return superfx_mmio_read(state->superfx, offset); |
| 443 | 441 | } |
| 444 | 442 | } |
| 445 | | else if (snes_has_addon_chip == HAS_RTC) |
| 443 | else if (state->has_addon_chip == HAS_RTC) |
| 446 | 444 | { |
| 447 | 445 | if (offset == 0x2800 || offset == 0x2801) |
| 448 | 446 | { |
| 449 | 447 | return srtc_read(space, offset); |
| 450 | 448 | } |
| 451 | 449 | } |
| 452 | | else if (snes_has_addon_chip == HAS_SDD1) |
| 450 | else if (state->has_addon_chip == HAS_SDD1) |
| 453 | 451 | { |
| 454 | 452 | if (offset >= 0x4800 && offset < 0x4808) |
| 455 | 453 | { |
| r8081 | r8082 | |
| 460 | 458 | offset += 0x4300; |
| 461 | 459 | } |
| 462 | 460 | } |
| 463 | | else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC) |
| 461 | else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC) |
| 464 | 462 | { |
| 465 | | UINT16 limit = (snes_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 463 | UINT16 limit = (state->has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 466 | 464 | if (offset >= 0x4800 && offset <= limit) |
| 467 | 465 | { |
| 468 | 466 | return spc7110_mmio_read(space, offset); |
| r8081 | r8082 | |
| 578 | 576 | return; |
| 579 | 577 | } |
| 580 | 578 | |
| 581 | | if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 579 | if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 582 | 580 | { |
| 583 | 581 | if (offset >= 0x3000 && offset < 0x3300) |
| 584 | 582 | { |
| r8081 | r8082 | |
| 586 | 584 | return; |
| 587 | 585 | } |
| 588 | 586 | } |
| 589 | | else if (snes_has_addon_chip == HAS_RTC) |
| 587 | else if (state->has_addon_chip == HAS_RTC) |
| 590 | 588 | { |
| 591 | 589 | if (offset == 0x2800 || offset == 0x2801) |
| 592 | 590 | { |
| r8081 | r8082 | |
| 594 | 592 | return; |
| 595 | 593 | } |
| 596 | 594 | } |
| 597 | | else if (snes_has_addon_chip == HAS_SDD1) |
| 595 | else if (state->has_addon_chip == HAS_SDD1) |
| 598 | 596 | { |
| 599 | 597 | if ((offset >= 0x4300 && offset < 0x4380) || |
| 600 | 598 | (offset >= 0x4800 && offset < 0x4808)) |
| r8081 | r8082 | |
| 607 | 605 | offset += 0x4300; |
| 608 | 606 | } |
| 609 | 607 | } |
| 610 | | else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC) |
| 608 | else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC) |
| 611 | 609 | { |
| 612 | | UINT16 limit = (snes_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 610 | UINT16 limit = (state->has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f; |
| 613 | 611 | if (offset >= 0x4800 && offset <= limit) |
| 614 | 612 | { |
| 615 | 613 | spc7110_mmio_write(space->machine, (UINT32)offset, data); |
| r8081 | r8082 | |
| 918 | 916 | if (address < 0x2000) /* Mirror of Low RAM */ |
| 919 | 917 | value = memory_read_byte(space, 0x7e0000 + address); |
| 920 | 918 | else if (address < 0x6000) /* I/O */ |
| 921 | | value = snes_r_io(space, address); |
| 919 | { |
| 920 | if (state->cart[0].mode == SNES_MODE_BSX && address >= 0x5000) |
| 921 | value = bsx_read(space, offset); |
| 922 | else |
| 923 | value = snes_r_io(space, address); |
| 924 | } |
| 922 | 925 | else if (address < 0x8000) |
| 923 | 926 | { |
| 924 | | if (snes_has_addon_chip == HAS_SUPERFX && state->superfx !=NULL) |
| 927 | if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 925 | 928 | { |
| 926 | 929 | if (superfx_access_ram(state->superfx)) |
| 927 | 930 | value = snes_ram[0xf00000 + (offset & 0x1fff)]; // here it should be 0xe00000 but there are mirroring issues |
| 928 | 931 | else |
| 929 | 932 | value = snes_open_bus_r(space, 0); |
| 930 | 933 | } |
| 931 | | else if (snes_has_addon_chip == HAS_OBC1) |
| 934 | else if (state->has_addon_chip == HAS_OBC1) |
| 932 | 935 | value = obc1_read(space, offset); |
| 933 | | else if ((snes_cart.mode == SNES_MODE_21) && (snes_has_addon_chip == HAS_DSP1) && (offset < 0x100000)) |
| 936 | else if ((state->cart[0].mode == SNES_MODE_21) && (state->has_addon_chip == HAS_DSP1) && (offset < 0x100000)) |
| 934 | 937 | value = (address < 0x7000) ? dsp1_get_dr() : dsp1_get_sr(); |
| 935 | | else if (snes_has_addon_chip == HAS_CX4) |
| 938 | else if (state->has_addon_chip == HAS_CX4) |
| 936 | 939 | value = CX4_read(address - 0x6000); |
| 937 | | else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC) |
| 940 | else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC) |
| 938 | 941 | { |
| 939 | 942 | if (offset < 0x10000) |
| 940 | 943 | value = snes_ram[0x306000 + (offset & 0x1fff)]; |
| r8081 | r8082 | |
| 945 | 948 | value = snes_open_bus_r(space, 0); /* Reserved */ |
| 946 | 949 | } |
| 947 | 950 | } |
| 948 | | else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000)) |
| 951 | else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000)) |
| 949 | 952 | value = (address < 0xc000) ? dsp1_get_dr() : dsp1_get_sr(); |
| 950 | | else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000)) |
| 953 | else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000)) |
| 951 | 954 | value = (address < 0xc000) ? dsp2_dr_read() : dsp2_sr_read(); |
| 952 | | else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000)) |
| 955 | else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000)) |
| 953 | 956 | value = dsp3_read(address); |
| 954 | 957 | else |
| 955 | 958 | value = snes_ram[offset]; |
| r8081 | r8082 | |
| 970 | 973 | if (address < 0x2000) /* Mirror of Low RAM */ |
| 971 | 974 | value = memory_read_byte(space, 0x7e0000 + address); |
| 972 | 975 | else if (address < 0x6000) /* I/O */ |
| 973 | | value = snes_r_io(space, address); |
| 976 | { |
| 977 | if (state->cart[0].mode == SNES_MODE_BSX && address >= 0x5000) |
| 978 | value = bsx_read(space, 0x300000 + offset); |
| 979 | else |
| 980 | value = snes_r_io(space, address); |
| 981 | } |
| 974 | 982 | else if (address < 0x8000) /* SRAM for mode_21, Reserved othewise */ |
| 975 | 983 | { |
| 976 | | if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 984 | if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 977 | 985 | { |
| 978 | 986 | if (superfx_access_ram(state->superfx)) |
| 979 | 987 | value = snes_ram[0xf00000 + (offset & 0x1fff)]; // here it should be 0xe00000 but there are mirroring issues |
| 980 | 988 | else |
| 981 | 989 | value = snes_open_bus_r(space, 0); |
| 982 | 990 | } |
| 983 | | else if (snes_has_addon_chip == HAS_OBC1) |
| 991 | else if (state->has_addon_chip == HAS_OBC1) |
| 984 | 992 | value = obc1_read (space, offset); |
| 985 | | else if (snes_has_addon_chip == HAS_CX4) |
| 993 | else if (state->has_addon_chip == HAS_CX4) |
| 986 | 994 | value = CX4_read(address - 0x6000); |
| 987 | | else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC) |
| 995 | else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC) |
| 988 | 996 | { |
| 989 | 997 | if (offset < 0x10000) |
| 990 | 998 | value = snes_ram[0x306000 + (offset & 0x1fff)]; |
| 991 | 999 | } |
| 992 | | else if ((snes_cart.mode == SNES_MODE_21) && (snes_cart.sram > 0)) |
| 1000 | else if ((state->cart[0].mode == SNES_MODE_21) && (state->cart[0].sram > 0)) |
| 993 | 1001 | { |
| 994 | | int mask = (snes_cart.sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */ |
| 1002 | int mask = (state->cart[0].sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */ |
| 995 | 1003 | value = snes_ram[0x300000 + (offset & mask)]; |
| 996 | 1004 | } |
| 997 | 1005 | else |
| r8081 | r8082 | |
| 1001 | 1009 | } |
| 1002 | 1010 | } |
| 1003 | 1011 | /* some dsp1 games use these banks 0x30 to 0x3f at address 0x8000 */ |
| 1004 | | else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1)) |
| 1012 | else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1)) |
| 1005 | 1013 | value = (address < 0xc000) ? dsp1_get_dr() : dsp1_get_sr(); |
| 1006 | | else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2)) |
| 1014 | else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2)) |
| 1007 | 1015 | value = (address < 0xc000) ? dsp2_dr_read() : dsp2_sr_read(); |
| 1008 | | else if (snes_has_addon_chip == HAS_DSP3) |
| 1016 | else if (state->has_addon_chip == HAS_DSP3) |
| 1009 | 1017 | value = dsp3_read(address); |
| 1010 | | else if (snes_has_addon_chip == HAS_DSP4) |
| 1018 | else if (state->has_addon_chip == HAS_DSP4) |
| 1011 | 1019 | value = (address < 0xc000) ? dsp4_read() : 0x80; |
| 1012 | 1020 | else |
| 1013 | 1021 | value = snes_ram[0x300000 + offset]; |
| r8081 | r8082 | |
| 1025 | 1033 | UINT8 value = 0xff; |
| 1026 | 1034 | UINT16 address = offset & 0xffff; |
| 1027 | 1035 | |
| 1028 | | if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 1036 | if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 1029 | 1037 | { |
| 1030 | 1038 | if (superfx_access_rom(state->superfx)) |
| 1031 | 1039 | value = snes_ram[0x400000 + offset]; |
| r8081 | r8082 | |
| 1038 | 1046 | return sfx_data[offset & 0x0f]; |
| 1039 | 1047 | } |
| 1040 | 1048 | } |
| 1041 | | else if ((snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)) |
| 1049 | else if ((state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)) |
| 1042 | 1050 | { |
| 1043 | 1051 | if (offset >= 0x100000 && offset < 0x110000) |
| 1044 | 1052 | value = spc7110_mmio_read(space, 0x4800); |
| 1045 | 1053 | } |
| 1046 | | else if ((snes_cart.mode & 5) && !(snes_has_addon_chip == HAS_SUPERFX)) /* Mode 20 & 22 */ |
| 1054 | else if ((state->cart[0].mode & 5) && !(state->has_addon_chip == HAS_SUPERFX)) /* Mode 20 & 22 */ |
| 1047 | 1055 | { |
| 1048 | | if ((address < 0x8000) && (snes_cart.mode == SNES_MODE_20)) |
| 1056 | if ((address < 0x8000) && (state->cart[0].mode == SNES_MODE_20)) |
| 1049 | 1057 | value = snes_open_bus_r(space, 0); /* Reserved */ |
| 1050 | 1058 | else |
| 1051 | 1059 | value = snes_ram[0x400000 + offset]; |
| r8081 | r8082 | |
| 1066 | 1074 | UINT8 value = 0xff; |
| 1067 | 1075 | UINT16 address = offset & 0xffff; |
| 1068 | 1076 | |
| 1069 | | if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 1077 | if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 1070 | 1078 | { |
| 1071 | 1079 | if (superfx_access_ram(state->superfx)) |
| 1072 | 1080 | value = snes_ram[0xe00000 + offset]; |
| 1073 | 1081 | else |
| 1074 | 1082 | value = snes_open_bus_r(space, 0); |
| 1075 | 1083 | } |
| 1076 | | else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x80000 && address < 0x1000) |
| 1084 | else if (state->has_addon_chip == HAS_ST010 && offset >= 0x80000 && address < 0x1000) |
| 1077 | 1085 | value = st010_read(address); |
| 1078 | | else if (snes_cart.mode & 5) /* Mode 20 & 22 */ |
| 1086 | else if (state->cart[0].mode & 5) /* Mode 20 & 22 */ |
| 1079 | 1087 | { |
| 1080 | 1088 | if (address >= 0x8000) |
| 1081 | 1089 | value = snes_ram[0x600000 + offset]; |
| 1082 | 1090 | /* some other dsp1 games use these banks 0x60 to 0x6f at address 0x0000 */ |
| 1083 | | else if (snes_has_addon_chip == HAS_DSP1) |
| 1091 | else if (state->has_addon_chip == HAS_DSP1) |
| 1084 | 1092 | value = (address >= 0x4000) ? dsp1_get_sr() : dsp1_get_dr(); |
| 1085 | 1093 | else |
| 1086 | 1094 | { |
| r8081 | r8082 | |
| 1088 | 1096 | value = snes_open_bus_r(space, 0); /* Reserved */ |
| 1089 | 1097 | } |
| 1090 | 1098 | } |
| 1091 | | else if (snes_cart.mode & 0x0a) /* Mode 21 & 25 */ |
| 1099 | else if (state->cart[0].mode & 0x0a) /* Mode 21 & 25 */ |
| 1092 | 1100 | value = snes_ram[0x600000 + offset]; |
| 1093 | 1101 | |
| 1094 | 1102 | if(!space->debugger_access) |
| r8081 | r8082 | |
| 1104 | 1112 | UINT8 value; |
| 1105 | 1113 | UINT16 address = offset & 0xffff; |
| 1106 | 1114 | |
| 1107 | | if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 1115 | if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 1108 | 1116 | { |
| 1109 | 1117 | if (superfx_access_ram(state->superfx)) |
| 1110 | 1118 | value = snes_ram[0xf00000 + offset]; |
| 1111 | 1119 | else |
| 1112 | 1120 | value = snes_open_bus_r(space, 0); |
| 1113 | 1121 | } |
| 1114 | | else if ((snes_cart.mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */ |
| 1122 | else if ((state->cart[0].mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */ |
| 1115 | 1123 | { |
| 1116 | | if (snes_cart.sram > 0) |
| 1124 | if (state->cart[0].sram > 0) |
| 1117 | 1125 | { |
| 1118 | | int mask = (snes_cart.sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */ |
| 1126 | int mask = (state->cart[0].sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */ |
| 1119 | 1127 | value = snes_ram[0x700000 + (offset & mask)]; |
| 1120 | 1128 | } |
| 1121 | 1129 | else |
| r8081 | r8082 | |
| 1136 | 1144 | /* 0x800000 - 0xbfffff */ |
| 1137 | 1145 | READ8_HANDLER( snes_r_bank6 ) |
| 1138 | 1146 | { |
| 1147 | snes_state *state = (snes_state *)space->machine->driver_data; |
| 1139 | 1148 | UINT8 value = 0; |
| 1140 | 1149 | UINT16 address = offset & 0xffff; |
| 1141 | 1150 | |
| 1142 | | if (snes_has_addon_chip == HAS_SUPERFX) |
| 1151 | if (state->has_addon_chip == HAS_SUPERFX) |
| 1143 | 1152 | value = memory_read_byte(space, offset); |
| 1144 | 1153 | else if (address < 0x8000) |
| 1145 | 1154 | { |
| 1146 | | if (snes_cart.mode != SNES_MODE_25) |
| 1155 | if (state->cart[0].mode != SNES_MODE_25) |
| 1147 | 1156 | value = memory_read_byte(space, offset); |
| 1148 | | else if ((snes_has_addon_chip == HAS_CX4) && (address >= 0x6000)) |
| 1157 | else if ((state->has_addon_chip == HAS_CX4) && (address >= 0x6000)) |
| 1149 | 1158 | value = CX4_read(address - 0x6000); |
| 1150 | 1159 | else /* Mode 25 has SRAM not mirrored from lower banks */ |
| 1151 | 1160 | { |
| 1152 | 1161 | if (address < 0x6000) |
| 1153 | 1162 | value = memory_read_byte(space, offset); |
| 1154 | | else if ((offset >= 0x300000) && (snes_cart.sram > 0)) |
| 1163 | else if ((offset >= 0x300000) && (state->cart[0].sram > 0)) |
| 1155 | 1164 | { |
| 1156 | | int mask = (snes_cart.sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */ |
| 1165 | int mask = (state->cart[0].sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */ |
| 1157 | 1166 | value = snes_ram[0x800000 + (offset & mask)]; |
| 1158 | 1167 | } |
| 1159 | 1168 | else /* Area 0x6000-0x8000 with offset < 0x300000 is reserved */ |
| r8081 | r8082 | |
| 1163 | 1172 | } |
| 1164 | 1173 | } |
| 1165 | 1174 | } |
| 1166 | | else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000)) |
| 1175 | else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000)) |
| 1167 | 1176 | value = (address < 0xc000) ? dsp1_get_dr() : dsp1_get_sr(); |
| 1168 | | else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000)) |
| 1177 | else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000)) |
| 1169 | 1178 | value = (address < 0xc000) ? dsp2_dr_read() : dsp2_sr_read(); |
| 1170 | | else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000)) |
| 1179 | else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000)) |
| 1171 | 1180 | value = dsp3_read(address); |
| 1172 | | else if ((snes_has_addon_chip == HAS_DSP4) && (offset >= 0x300000)) |
| 1181 | else if ((state->has_addon_chip == HAS_DSP4) && (offset >= 0x300000)) |
| 1173 | 1182 | value = (address < 0xc000) ? dsp4_read() : 0x80; |
| 1174 | 1183 | else |
| 1175 | 1184 | value = snes_ram[0x800000 + offset]; |
| r8081 | r8082 | |
| 1187 | 1196 | UINT8 value = 0; |
| 1188 | 1197 | UINT16 address = offset & 0xffff; |
| 1189 | 1198 | |
| 1190 | | if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 1199 | if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL) |
| 1191 | 1200 | { |
| 1192 | 1201 | if (offset < 0x200000) // ROM |
| 1193 | 1202 | { |
| r8081 | r8082 | |
| 1211 | 1220 | value = snes_open_bus_r(space, 0); |
| 1212 | 1221 | } |
| 1213 | 1222 | } |
| 1214 | | else if ((snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC) && offset >= 0x100000) |
| 1223 | else if ((state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC) && offset >= 0x100000) |
| 1215 | 1224 | value = spc7110_bank7_read(space, offset); |
| 1216 | | else if (snes_has_addon_chip == HAS_SDD1) |
| 1225 | else if (state->has_addon_chip == HAS_SDD1) |
| 1217 | 1226 | value = sdd1_read(space->machine, offset); |
| 1218 | | else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000) |
| 1227 | else if (state->has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000) |
| 1219 | 1228 | value = st010_read(address); |
| 1220 | | else if ((snes_cart.mode & 5) && !(snes_has_addon_chip == HAS_SUPERFX)) /* Mode 20 & 22 */ |
| 1229 | else if ((state->cart[0].mode & 5) && !(state->has_addon_chip == HAS_SUPERFX)) /* Mode 20 & 22 */ |
| 1221 | 1230 | { |
| 1222 | 1231 | if (address < 0x8000) |
| 1223 | 1232 | value = memory_read_byte(space, 0x400000 + offset); |
| r8081 | r8082 | |
| 1237 | 1246 | /* 0x000000 - 0x2fffff */ |
| 1238 | 1247 | WRITE8_HANDLER( snes_w_bank1 ) |
| 1239 | 1248 | { |
| 1249 | snes_state *state = (snes_state *)space->machine->driver_data; |
| 1240 | 1250 | UINT16 address = offset & 0xffff; |
| 1241 | 1251 | |
| 1242 | 1252 | if (address < 0x2000) /* Mirror of Low RAM */ |
| 1243 | 1253 | memory_write_byte(space, 0x7e0000 + address, data); |
| 1244 | 1254 | else if (address < 0x6000) /* I/O */ |
| 1245 | | snes_w_io(space, address, data); |
| 1255 | { |
| 1256 | if (state->cart[0].mode == SNES_MODE_BSX && address >= 0x5000) |
| 1257 | bsx_write(space, offset, data); |
| 1258 | else |
| 1259 | snes_w_io(space, address, data); |
| 1260 | } |
| 1246 | 1261 | else if (address < 0x8000) |
| 1247 | 1262 | { |
| 1248 | | if (snes_has_addon_chip == HAS_SUPERFX) |
| 1263 | if (state->has_addon_chip == HAS_SUPERFX) |
| 1249 | 1264 | snes_ram[0xf00000 + (offset & 0x1fff)] = data; // here it should be 0xe00000 but there are mirroring issues |
| 1250 | | else if (snes_has_addon_chip == HAS_OBC1) |
| 1265 | else if (state->has_addon_chip == HAS_OBC1) |
| 1251 | 1266 | obc1_write(space, offset, data); |
| 1252 | | else if ((snes_cart.mode == SNES_MODE_21) && (snes_has_addon_chip == HAS_DSP1) && (offset < 0x100000)) |
| 1267 | else if ((state->cart[0].mode == SNES_MODE_21) && (state->has_addon_chip == HAS_DSP1) && (offset < 0x100000)) |
| 1253 | 1268 | dsp1_set_dr(data); |
| 1254 | | else if (snes_has_addon_chip == HAS_CX4) |
| 1269 | else if (state->has_addon_chip == HAS_CX4) |
| 1255 | 1270 | CX4_write(space->machine, address - 0x6000, data); |
| 1256 | | else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC) |
| 1271 | else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC) |
| 1257 | 1272 | { |
| 1258 | 1273 | if (offset < 0x10000) |
| 1259 | 1274 | snes_ram[0x306000 + (offset & 0x1fff)] = data; |
| r8081 | r8082 | |
| 1261 | 1276 | else |
| 1262 | 1277 | logerror("snes_w_bank1: Attempt to write to reserved address: %x = %02x\n", offset, data); |
| 1263 | 1278 | } |
| 1264 | | else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000)) |
| 1279 | else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000)) |
| 1265 | 1280 | dsp1_set_dr(data); |
| 1266 | | else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000)) |
| 1281 | else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000)) |
| 1267 | 1282 | { |
| 1268 | 1283 | if (address < 0xc000) |
| 1269 | 1284 | dsp2_dr_write(data); |
| 1270 | 1285 | else |
| 1271 | 1286 | dsp2_sr_write(data); |
| 1272 | 1287 | } |
| 1273 | | else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000)) |
| 1288 | else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000)) |
| 1274 | 1289 | dsp3_write(address, data); |
| 1275 | 1290 | else |
| 1276 | 1291 | logerror( "(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset ); |
| r8081 | r8082 | |
| 1282 | 1297 | /* 0x300000 - 0x3fffff */ |
| 1283 | 1298 | WRITE8_HANDLER( snes_w_bank2 ) |
| 1284 | 1299 | { |
| 1300 | snes_state *state = (snes_state *)space->machine->driver_data; |
| 1285 | 1301 | UINT16 address = offset & 0xffff; |
| 1286 | 1302 | |
| 1287 | 1303 | if (address < 0x2000) /* Mirror of Low RAM */ |
| 1288 | 1304 | memory_write_byte(space, 0x7e0000 + address, data); |
| 1289 | 1305 | else if (address < 0x6000) /* I/O */ |
| 1290 | | snes_w_io(space, address, data); |
| 1306 | { |
| 1307 | if (state->cart[0].mode == SNES_MODE_BSX && address >= 0x5000) |
| 1308 | bsx_write(space, 0x300000 + offset, data); |
| 1309 | else |
| 1310 | snes_w_io(space, address, data); |
| 1311 | } |
| 1291 | 1312 | else if (address < 0x8000) /* SRAM for mode_21, Reserved othewise */ |
| 1292 | 1313 | { |
| 1293 | | if (snes_has_addon_chip == HAS_SUPERFX) |
| 1314 | if (state->has_addon_chip == HAS_SUPERFX) |
| 1294 | 1315 | snes_ram[0xf00000 + (offset & 0x1fff)] = data; // here it should be 0xe00000 but there are mirroring issues |
| 1295 | | else if (snes_has_addon_chip == HAS_OBC1) |
| 1316 | else if (state->has_addon_chip == HAS_OBC1) |
| 1296 | 1317 | obc1_write(space, offset, data); |
| 1297 | | else if (snes_has_addon_chip == HAS_CX4) |
| 1318 | else if (state->has_addon_chip == HAS_CX4) |
| 1298 | 1319 | CX4_write(space->machine, address - 0x6000, data); |
| 1299 | | else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC) |
| 1320 | else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC) |
| 1300 | 1321 | { |
| 1301 | 1322 | if (offset < 0x10000) |
| 1302 | 1323 | snes_ram[0x306000 + (offset & 0x1fff)] = data; |
| 1303 | 1324 | } |
| 1304 | | else if ((snes_cart.mode == SNES_MODE_21) && (snes_cart.sram > 0)) |
| 1325 | else if ((state->cart[0].mode == SNES_MODE_21) && (state->cart[0].sram > 0)) |
| 1305 | 1326 | { |
| 1306 | | int mask = (snes_cart.sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */ |
| 1327 | int mask = (state->cart[0].sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */ |
| 1307 | 1328 | snes_ram[0x300000 + (offset & mask)] = data; |
| 1308 | 1329 | } |
| 1309 | 1330 | else |
| 1310 | 1331 | logerror("snes_w_bank2: Attempt to write to reserved address: %X = %02x\n", offset + 0x300000, data); |
| 1311 | 1332 | } |
| 1312 | 1333 | /* some dsp1 games use these banks 0x30 to 0x3f at address 0x8000 */ |
| 1313 | | else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1)) |
| 1334 | else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1)) |
| 1314 | 1335 | dsp1_set_dr(data); |
| 1315 | | else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2)) |
| 1336 | else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2)) |
| 1316 | 1337 | { |
| 1317 | 1338 | if (address < 0xc000) |
| 1318 | 1339 | dsp2_dr_write(data); |
| 1319 | 1340 | else |
| 1320 | 1341 | dsp2_sr_write(data); |
| 1321 | 1342 | } |
| 1322 | | else if (snes_has_addon_chip == HAS_DSP3) |
| 1343 | else if (state->has_addon_chip == HAS_DSP3) |
| 1323 | 1344 | dsp3_write(address, data); |
| 1324 | | else if ((snes_has_addon_chip == HAS_DSP4) && (address < 0xc000)) |
| 1345 | else if ((state->has_addon_chip == HAS_DSP4) && (address < 0xc000)) |
| 1325 | 1346 | dsp4_write(data); |
| 1326 | 1347 | else |
| 1327 | 1348 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x300000); |
| r8081 | r8082 | |
| 1333 | 1354 | /* 0x600000 - 0x6fffff */ |
| 1334 | 1355 | WRITE8_HANDLER( snes_w_bank4 ) |
| 1335 | 1356 | { |
| 1357 | snes_state *state = (snes_state *)space->machine->driver_data; |
| 1336 | 1358 | UINT16 address = offset & 0xffff; |
| 1337 | 1359 | |
| 1338 | | if (snes_has_addon_chip == HAS_SUPERFX) |
| 1360 | if (state->has_addon_chip == HAS_SUPERFX) |
| 1339 | 1361 | snes_ram[0xe00000 + offset] = data; |
| 1340 | | else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x80000 && address < 0x1000) |
| 1362 | else if (state->has_addon_chip == HAS_ST010 && offset >= 0x80000 && address < 0x1000) |
| 1341 | 1363 | st010_write(address, data); |
| 1342 | | else if (snes_cart.mode & 5) /* Mode 20 & 22 */ |
| 1364 | else if (state->cart[0].mode & 5) /* Mode 20 & 22 */ |
| 1343 | 1365 | { |
| 1344 | 1366 | if (address >= 0x8000) |
| 1345 | 1367 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x600000); |
| 1346 | | else if (snes_has_addon_chip == HAS_DSP1) |
| 1368 | else if (state->has_addon_chip == HAS_DSP1) |
| 1347 | 1369 | dsp1_set_dr(data); |
| 1348 | 1370 | else |
| 1349 | 1371 | logerror("snes_w_bank4: Attempt to write to reserved address: %X = %02x\n", offset + 0x600000, data); |
| 1350 | 1372 | } |
| 1351 | | else if (snes_cart.mode & 0x0a) |
| 1373 | else if (state->cart[0].mode & 0x0a) |
| 1352 | 1374 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x600000); |
| 1353 | 1375 | |
| 1354 | 1376 | if(!space->debugger_access) |
| r8081 | r8082 | |
| 1358 | 1380 | /* 0x700000 - 0x7dffff */ |
| 1359 | 1381 | WRITE8_HANDLER( snes_w_bank5 ) |
| 1360 | 1382 | { |
| 1383 | snes_state *state = (snes_state *)space->machine->driver_data; |
| 1361 | 1384 | UINT16 address = offset & 0xffff; |
| 1362 | 1385 | |
| 1363 | | if (snes_has_addon_chip == HAS_SUPERFX) |
| 1386 | if (state->has_addon_chip == HAS_SUPERFX) |
| 1364 | 1387 | snes_ram[0xf00000 + offset] = data; |
| 1365 | | else if ((snes_cart.mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */ |
| 1388 | else if ((state->cart[0].mode & 5) && (address < 0x8000)) /* Mode 20 & 22 */ |
| 1366 | 1389 | { |
| 1367 | | if (snes_cart.sram > 0) |
| 1390 | if (state->cart[0].sram > 0) |
| 1368 | 1391 | { |
| 1369 | | int mask = (snes_cart.sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */ |
| 1392 | int mask = (state->cart[0].sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */ |
| 1370 | 1393 | snes_ram[0x700000 + (offset & mask)] = data; |
| 1371 | 1394 | } |
| 1372 | 1395 | else |
| 1373 | 1396 | logerror("snes_w_bank5: Attempt to write to reserved address: %X = %02x\n", offset + 0x700000, data); |
| 1374 | 1397 | } |
| 1375 | | else if (snes_cart.mode & 0x0a) |
| 1398 | else if (state->cart[0].mode & 0x0a) |
| 1376 | 1399 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x700000); |
| 1377 | 1400 | |
| 1378 | 1401 | if(!space->debugger_access) |
| r8081 | r8082 | |
| 1383 | 1406 | /* 0x800000 - 0xbfffff */ |
| 1384 | 1407 | WRITE8_HANDLER( snes_w_bank6 ) |
| 1385 | 1408 | { |
| 1409 | snes_state *state = (snes_state *)space->machine->driver_data; |
| 1386 | 1410 | UINT16 address = offset & 0xffff; |
| 1387 | 1411 | |
| 1388 | | if (snes_has_addon_chip == HAS_SUPERFX) |
| 1412 | if (state->has_addon_chip == HAS_SUPERFX) |
| 1389 | 1413 | memory_write_byte(space, offset, data); |
| 1390 | 1414 | else if (address < 0x8000) |
| 1391 | 1415 | { |
| 1392 | | if ((snes_has_addon_chip == HAS_CX4) && (address >= 0x6000)) |
| 1416 | if ((state->has_addon_chip == HAS_CX4) && (address >= 0x6000)) |
| 1393 | 1417 | CX4_write(space->machine, address - 0x6000, data); |
| 1394 | | else if (snes_cart.mode != SNES_MODE_25) |
| 1418 | else if (state->cart[0].mode != SNES_MODE_25) |
| 1395 | 1419 | memory_write_byte(space, offset, data); |
| 1396 | 1420 | else /* Mode 25 has SRAM not mirrored from lower banks */ |
| 1397 | 1421 | { |
| 1398 | 1422 | if (address < 0x6000) |
| 1399 | 1423 | memory_write_byte(space, offset, data); |
| 1400 | | else if ((offset >= 0x300000) && (snes_cart.sram > 0)) |
| 1424 | else if ((offset >= 0x300000) && (state->cart[0].sram > 0)) |
| 1401 | 1425 | { |
| 1402 | | int mask = (snes_cart.sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */ |
| 1426 | int mask = (state->cart[0].sram - 1) | 0xff0000; /* Limit SRAM size to what's actually present */ |
| 1403 | 1427 | snes_ram[0x800000 + (offset & mask)] = data; |
| 1404 | 1428 | } |
| 1405 | 1429 | else /* Area in 0x6000-0x8000 && offset < 0x300000 is Reserved! */ |
| 1406 | 1430 | logerror("snes_w_bank6: Attempt to write to reserved address: %X = %02x\n", offset + 0x800000, data); |
| 1407 | 1431 | } |
| 1408 | 1432 | } |
| 1409 | | else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000)) |
| 1433 | else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000)) |
| 1410 | 1434 | dsp1_set_dr(data); |
| 1411 | | else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000)) |
| 1435 | else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000)) |
| 1412 | 1436 | { |
| 1413 | 1437 | if (address < 0xc000) |
| 1414 | 1438 | dsp2_dr_write(data); |
| 1415 | 1439 | else |
| 1416 | 1440 | dsp2_sr_write(data); |
| 1417 | 1441 | } |
| 1418 | | else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000)) |
| 1442 | else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000)) |
| 1419 | 1443 | dsp3_write(address, data); |
| 1420 | | else if ((snes_has_addon_chip == HAS_DSP4) && (offset >= 0x300000) && (address < 0xc000)) |
| 1444 | else if ((state->has_addon_chip == HAS_DSP4) && (offset >= 0x300000) && (address < 0xc000)) |
| 1421 | 1445 | dsp4_write(data); |
| 1422 | 1446 | else |
| 1423 | 1447 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x800000); |
| r8081 | r8082 | |
| 1430 | 1454 | /* 0xc00000 - 0xffffff */ |
| 1431 | 1455 | WRITE8_HANDLER( snes_w_bank7 ) |
| 1432 | 1456 | { |
| 1457 | snes_state *state = (snes_state *)space->machine->driver_data; |
| 1433 | 1458 | UINT16 address = offset & 0xffff; |
| 1434 | 1459 | |
| 1435 | | if (snes_has_addon_chip == HAS_SUPERFX) |
| 1460 | if (state->has_addon_chip == HAS_SUPERFX) |
| 1436 | 1461 | { |
| 1437 | 1462 | if (offset >= 0x200000) |
| 1438 | 1463 | { |
| r8081 | r8082 | |
| 1442 | 1467 | else |
| 1443 | 1468 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0xc00000); |
| 1444 | 1469 | } |
| 1445 | | else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000) |
| 1470 | else if (state->has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000) |
| 1446 | 1471 | st010_write(address, data); |
| 1447 | | else if (snes_cart.mode & 5) /* Mode 20 & 22 */ |
| 1472 | else if (state->cart[0].mode & 5) /* Mode 20 & 22 */ |
| 1448 | 1473 | { |
| 1449 | 1474 | if (address < 0x8000) |
| 1450 | 1475 | { |
| r8081 | r8082 | |
| 1458 | 1483 | else |
| 1459 | 1484 | logerror("(PC=%06x) snes_w_bank7: Attempt to write to ROM address: %X = %02x\n",cpu_get_pc(space->cpu),offset + 0xc00000, data); |
| 1460 | 1485 | } |
| 1461 | | else if (snes_cart.mode & 0x0a) |
| 1486 | else if (state->cart[0].mode & 0x0a) |
| 1462 | 1487 | logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0xc00000); |
| 1463 | 1488 | |
| 1464 | 1489 | if(!space->debugger_access) |
| r8081 | r8082 | |
| 1606 | 1631 | snes_ram[WRIO] = 0xff; |
| 1607 | 1632 | snes_ram[VMAIN] = 0x80; |
| 1608 | 1633 | |
| 1609 | | switch (snes_has_addon_chip) |
| 1634 | switch (state->has_addon_chip) |
| 1610 | 1635 | { |
| 1611 | 1636 | case HAS_DSP1: |
| 1612 | 1637 | dsp1_init(machine); |
| r8081 | r8082 | |
| 1683 | 1708 | snes_ram[WRDIVL] = 0xff; |
| 1684 | 1709 | snes_ram[WRDIVH] = 0xff; |
| 1685 | 1710 | |
| 1686 | | switch (snes_has_addon_chip) |
| 1711 | switch (state->has_addon_chip) |
| 1687 | 1712 | { |
| 1688 | 1713 | case HAS_SDD1: |
| 1689 | 1714 | sdd1_init(machine); |
| r8081 | r8082 | |
| 1699 | 1724 | break; |
| 1700 | 1725 | } |
| 1701 | 1726 | |
| 1727 | if (state->cart[0].mode == SNES_MODE_BSX) |
| 1728 | bsx_init(machine); |
| 1729 | |
| 1702 | 1730 | snes_init_timers(machine); |
| 1703 | 1731 | |
| 1704 | 1732 | for (i = 0; i < 6; i++) |
| r8081 | r8082 | |
| 1807 | 1835 | /* for mame we use an init, maybe we will need more for the different games */ |
| 1808 | 1836 | DRIVER_INIT( snes ) |
| 1809 | 1837 | { |
| 1838 | snes_state *state = (snes_state *)machine->driver_data; |
| 1810 | 1839 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1811 | 1840 | UINT16 total_blocks, read_blocks; |
| 1812 | 1841 | UINT8 *rom; |
| r8081 | r8082 | |
| 1815 | 1844 | snes_ram = auto_alloc_array_clear(machine, UINT8, 0x1400000); |
| 1816 | 1845 | |
| 1817 | 1846 | /* all NSS games seem to use MODE 20 */ |
| 1818 | | snes_cart.mode = SNES_MODE_20; |
| 1819 | | snes_cart.sram_max = 0x40000; |
| 1820 | | snes_has_addon_chip = HAS_NONE; |
| 1847 | state->cart[0].mode = SNES_MODE_20; |
| 1848 | state->cart[0].sram_max = 0x40000; |
| 1849 | state->has_addon_chip = HAS_NONE; |
| 1821 | 1850 | |
| 1822 | 1851 | /* Find the number of blocks in this ROM */ |
| 1823 | 1852 | total_blocks = (memory_region_length(machine, "user3") / 0x8000); |
| r8081 | r8082 | |
| 1861 | 1890 | } |
| 1862 | 1891 | |
| 1863 | 1892 | /* Find the amount of sram */ |
| 1864 | | snes_cart.sram = snes_r_bank1(space, 0x00ffd8); |
| 1865 | | if (snes_cart.sram > 0) |
| 1893 | state->cart[0].sram = snes_r_bank1(space, 0x00ffd8); |
| 1894 | if (state->cart[0].sram > 0) |
| 1866 | 1895 | { |
| 1867 | | snes_cart.sram = (1024 << snes_cart.sram); |
| 1868 | | if (snes_cart.sram > snes_cart.sram_max) |
| 1869 | | snes_cart.sram = snes_cart.sram_max; |
| 1896 | state->cart[0].sram = (1024 << state->cart[0].sram); |
| 1897 | if (state->cart[0].sram > state->cart[0].sram_max) |
| 1898 | state->cart[0].sram = state->cart[0].sram_max; |
| 1870 | 1899 | } |
| 1871 | 1900 | } |
| 1872 | 1901 | |
| 1873 | 1902 | DRIVER_INIT( snes_hirom ) |
| 1874 | 1903 | { |
| 1904 | snes_state *state = (snes_state *)machine->driver_data; |
| 1875 | 1905 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1876 | 1906 | UINT16 total_blocks, read_blocks; |
| 1877 | 1907 | UINT8 *rom; |
| r8081 | r8082 | |
| 1880 | 1910 | snes_ram = auto_alloc_array(machine, UINT8, 0x1400000); |
| 1881 | 1911 | memset(snes_ram, 0, 0x1400000); |
| 1882 | 1912 | |
| 1883 | | snes_cart.mode = SNES_MODE_21; |
| 1884 | | snes_cart.sram_max = 0x40000; |
| 1885 | | snes_has_addon_chip = HAS_NONE; |
| 1913 | state->cart[0].mode = SNES_MODE_21; |
| 1914 | state->cart[0].sram_max = 0x40000; |
| 1915 | state->has_addon_chip = HAS_NONE; |
| 1886 | 1916 | |
| 1887 | 1917 | /* Find the number of blocks in this ROM */ |
| 1888 | 1918 | total_blocks = (memory_region_length(machine, "user3") / 0x10000); |
| r8081 | r8082 | |
| 1920 | 1950 | } |
| 1921 | 1951 | |
| 1922 | 1952 | /* Find the amount of sram */ |
| 1923 | | snes_cart.sram = snes_r_bank1(space, 0x00ffd8); |
| 1924 | | if (snes_cart.sram > 0) |
| 1953 | state->cart[0].sram = snes_r_bank1(space, 0x00ffd8); |
| 1954 | if (state->cart[0].sram > 0) |
| 1925 | 1955 | { |
| 1926 | | snes_cart.sram = (1024 << snes_cart.sram); |
| 1927 | | if (snes_cart.sram > snes_cart.sram_max) |
| 1928 | | snes_cart.sram = snes_cart.sram_max; |
| 1956 | state->cart[0].sram = (1024 << state->cart[0].sram); |
| 1957 | if (state->cart[0].sram > state->cart[0].sram_max) |
| 1958 | state->cart[0].sram = state->cart[0].sram_max; |
| 1929 | 1959 | } |
| 1930 | 1960 | } |
| 1931 | 1961 | |
src/mess/machine/snescart.c
| r8081 | r8082 | |
| 11 | 11 | #include "devices/cartslot.h" |
| 12 | 12 | #include "snescart.h" |
| 13 | 13 | |
| 14 | | |
| 15 | 14 | #define SNES_CART_DEBUG 0 |
| 16 | 15 | |
| 17 | 16 | /****** Strings for Cart Header Logging ******/ |
| r8081 | r8082 | |
| 123 | 122 | /* Loads the battery backed RAM into the appropriate memory area */ |
| 124 | 123 | static void snes_load_sram(running_machine *machine) |
| 125 | 124 | { |
| 125 | snes_state *state = (snes_state *)machine->driver_data; |
| 126 | 126 | UINT8 ii; |
| 127 | 127 | UINT8 *battery_ram, *ptr; |
| 128 | 128 | |
| 129 | | battery_ram = (UINT8*)malloc(snes_cart.sram_max); |
| 129 | battery_ram = (UINT8*)malloc(state->cart[0].sram_max); |
| 130 | 130 | ptr = battery_ram; |
| 131 | | image_battery_load(devtag_get_device(machine, "cart"), battery_ram, snes_cart.sram_max, 0xff); |
| 131 | image_battery_load(devtag_get_device(machine, "cart"), battery_ram, state->cart[0].sram_max, 0xff); |
| 132 | 132 | |
| 133 | | if (snes_cart.mode == SNES_MODE_20) |
| 133 | if (state->cart[0].mode == SNES_MODE_20) |
| 134 | 134 | { |
| 135 | | UINT32 size = snes_cart.small_sram ? 0x8000 : 0x10000; |
| 135 | UINT32 size = state->cart[0].small_sram ? 0x8000 : 0x10000; |
| 136 | 136 | |
| 137 | 137 | /* There could be some larger image needing banks 0x70 to 0x7f at address 0x8000 for ROM |
| 138 | 138 | * mirroring. These should be treated separately or data would be overwritten by SRAM */ |
| r8081 | r8082 | |
| 145 | 145 | ptr += size; |
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | | else if (snes_cart.mode == SNES_MODE_21) |
| 148 | else if (state->cart[0].mode == SNES_MODE_21) |
| 149 | 149 | { |
| 150 | 150 | for (ii = 0; ii < 16; ii++) |
| 151 | 151 | { |
| r8081 | r8082 | |
| 156 | 156 | ptr += 0x2000; |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | | else if (snes_cart.mode == SNES_MODE_25) |
| 159 | else if (state->cart[0].mode == SNES_MODE_25) |
| 160 | 160 | { |
| 161 | 161 | for (ii = 0; ii < 16; ii++) |
| 162 | 162 | { |
| r8081 | r8082 | |
| 171 | 171 | /* Saves the battery backed RAM from the appropriate memory area */ |
| 172 | 172 | static void snes_save_sram(running_machine *machine) |
| 173 | 173 | { |
| 174 | snes_state *state = (snes_state *)machine->driver_data; |
| 174 | 175 | UINT8 ii; |
| 175 | 176 | UINT8 *battery_ram, *ptr; |
| 176 | 177 | |
| 177 | | battery_ram = (UINT8*)malloc(snes_cart.sram_max); |
| 178 | battery_ram = (UINT8*)malloc(state->cart[0].sram_max); |
| 178 | 179 | ptr = battery_ram; |
| 179 | 180 | |
| 180 | | if (snes_cart.mode == SNES_MODE_20) |
| 181 | if (state->cart[0].mode == SNES_MODE_20) |
| 181 | 182 | { |
| 182 | | UINT32 size = snes_cart.small_sram ? 0x8000 : 0x10000; |
| 183 | UINT32 size = state->cart[0].small_sram ? 0x8000 : 0x10000; |
| 183 | 184 | |
| 184 | 185 | for (ii = 0; ii < 16; ii++) |
| 185 | 186 | { |
| r8081 | r8082 | |
| 187 | 188 | ptr += size; |
| 188 | 189 | } |
| 189 | 190 | } |
| 190 | | else if (snes_cart.mode == SNES_MODE_21) |
| 191 | else if (state->cart[0].mode == SNES_MODE_21) |
| 191 | 192 | { |
| 192 | 193 | for (ii = 0; ii < 16; ii++) |
| 193 | 194 | { |
| r8081 | r8082 | |
| 195 | 196 | ptr += 0x2000; |
| 196 | 197 | } |
| 197 | 198 | } |
| 198 | | else if (snes_cart.mode == SNES_MODE_25) |
| 199 | else if (state->cart[0].mode == SNES_MODE_25) |
| 199 | 200 | { |
| 200 | 201 | for (ii = 0; ii < 16; ii++) |
| 201 | 202 | { |
| r8081 | r8082 | |
| 204 | 205 | } |
| 205 | 206 | } |
| 206 | 207 | |
| 207 | | image_battery_save(devtag_get_device(machine, "cart"), battery_ram, snes_cart.sram_max); |
| 208 | image_battery_save(devtag_get_device(machine, "cart"), battery_ram, state->cart[0].sram_max); |
| 208 | 209 | |
| 209 | 210 | free(battery_ram); |
| 210 | 211 | } |
| 211 | 212 | |
| 212 | 213 | static void snes_machine_stop(running_machine *machine) |
| 213 | 214 | { |
| 215 | snes_state *state = (snes_state *)machine->driver_data; |
| 216 | |
| 214 | 217 | /* Save SRAM */ |
| 215 | | if (snes_cart.sram > 0) |
| 218 | if (state->cart[0].sram > 0) |
| 216 | 219 | snes_save_sram(machine); |
| 217 | 220 | } |
| 218 | 221 | |
| 219 | 222 | MACHINE_START( snes_mess ) |
| 220 | 223 | { |
| 221 | | snes_ram = memory_region(machine, "maincpu"); |
| 222 | 224 | add_exit_callback(machine, snes_machine_stop); |
| 223 | 225 | MACHINE_START_CALL(snes); |
| 224 | 226 | } |
| 225 | 227 | |
| 226 | 228 | |
| 229 | static void sufami_load_sram(running_machine *machine, const char *cart_tag) |
| 230 | { |
| 231 | UINT8 ii; |
| 232 | UINT8 *battery_ram, *ptr; |
| 233 | int st_sram_offset = 0; |
| 234 | |
| 235 | battery_ram = (UINT8*)malloc(0x20000); |
| 236 | ptr = battery_ram; |
| 237 | image_battery_load(devtag_get_device(machine, cart_tag), battery_ram, 0x20000, 0); |
| 238 | |
| 239 | if (strcmp(cart_tag, "slot_a") == 0) |
| 240 | st_sram_offset = 0x608000; |
| 241 | |
| 242 | if (strcmp(cart_tag, "slot_b") == 0) |
| 243 | st_sram_offset = 0x708000; |
| 244 | |
| 245 | /* Cart RAM is at 0x60-0x63:0x8000-0xffff (+0x10 for slot2) */ |
| 246 | for (ii = 0; ii < 4; ii++) |
| 247 | { |
| 248 | /* loading */ |
| 249 | memcpy(&snes_ram[st_sram_offset + (ii * 0x010000)], ptr + (ii * 0x8000), 0x8000); |
| 250 | /* mirroring */ |
| 251 | memcpy(&snes_ram[0x800000 + st_sram_offset + (ii * 0x010000)], &snes_ram[st_sram_offset + (ii * 0x010000)], 0x8000); |
| 252 | } |
| 253 | |
| 254 | free(battery_ram); |
| 255 | } |
| 256 | |
| 257 | static void sufami_machine_stop(running_machine *machine) |
| 258 | { |
| 259 | snes_state *state = (snes_state *)machine->driver_data; |
| 260 | UINT8 ii; |
| 261 | UINT8 *battery_ram, *ptr; |
| 262 | |
| 263 | battery_ram = (UINT8*)malloc(0x20000); |
| 264 | ptr = battery_ram; |
| 265 | |
| 266 | if (state->cart[0].slot_in_use) |
| 267 | { |
| 268 | for (ii = 0; ii < 4; ii++) |
| 269 | { |
| 270 | memmove(ptr + ii * 0x8000, &snes_ram[0x608000 + (ii * 0x010000)], 0x8000); |
| 271 | } |
| 272 | image_battery_save(devtag_get_device(machine, "slot_a"), battery_ram, 0x20000); |
| 273 | } |
| 274 | |
| 275 | if (state->cart[1].slot_in_use) |
| 276 | { |
| 277 | for (ii = 0; ii < 4; ii++) |
| 278 | { |
| 279 | memmove(ptr + ii * 0x8000, &snes_ram[0x708000 + (ii * 0x010000)], 0x8000); |
| 280 | } |
| 281 | image_battery_save(devtag_get_device(machine, "slot_b"), battery_ram, 0x20000); |
| 282 | } |
| 283 | |
| 284 | free(battery_ram); |
| 285 | } |
| 286 | |
| 287 | MACHINE_START( snesst ) |
| 288 | { |
| 289 | add_exit_callback(machine, sufami_machine_stop); |
| 290 | MACHINE_START_CALL(snes); |
| 291 | } |
| 292 | |
| 293 | |
| 227 | 294 | /*************************************************************************** |
| 228 | 295 | |
| 229 | 296 | Cart handling |
| r8081 | r8082 | |
| 339 | 406 | return score; |
| 340 | 407 | } |
| 341 | 408 | |
| 342 | | |
| 343 | | static DEVICE_IMAGE_LOAD( snes_cart ) |
| 409 | /* Here we add a couple of cart utilities, to avoid duplicating the code in each DEVICE_IMAGE_LOAD */ |
| 410 | static UINT32 snes_skip_header( running_device *image, UINT32 snes_rom_size ) |
| 344 | 411 | { |
| 345 | | int i, supported_type = 1; |
| 346 | | running_machine *machine = image->machine; |
| 347 | | const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM ); |
| 348 | | int total_blocks, read_blocks; |
| 349 | | UINT32 offset; |
| 350 | 412 | UINT8 header[512]; |
| 351 | | UINT8 *temp_buffer = auto_alloc_array(machine, UINT8, 0x410000); |
| 352 | | UINT8 valid_mode20, valid_mode21, valid_mode25; |
| 353 | | unsigned char *ROM; |
| 354 | | |
| 355 | | snes_ram = memory_region(machine, "maincpu"); |
| 356 | | memset(snes_ram, 0, 0x1000000); |
| 357 | | |
| 358 | | if (image_software_entry(image) == NULL) |
| 359 | | snes_rom_size = image_length(image); |
| 360 | | else |
| 361 | | snes_rom_size = image_get_software_region_length(image, "rom"); |
| 362 | | |
| 413 | UINT32 offset = 512; |
| 414 | |
| 363 | 415 | /* Check for a header (512 bytes) */ |
| 364 | | offset = 512; |
| 365 | 416 | if (image_software_entry(image) == NULL) |
| 366 | 417 | image_fread(image, header, 512); |
| 367 | 418 | else |
| 368 | 419 | memcpy(header, image_get_software_region(image, "rom"), 512); |
| 369 | | |
| 420 | |
| 370 | 421 | if ((header[8] == 0xaa) && (header[9] == 0xbb) && (header[10] == 0x04)) |
| 371 | 422 | { |
| 372 | 423 | /* Found an SWC identifier */ |
| 373 | | logerror("Found header(SWC) - Skipped\n"); |
| 424 | logerror("Found header (SWC) - Skipped\n"); |
| 374 | 425 | } |
| 375 | 426 | else if ((header[0] | (header[1] << 8)) == (((snes_rom_size - 512) / 1024) / 8)) |
| 376 | 427 | { |
| 377 | 428 | /* Some headers have the rom size at the start, if this matches with the actual rom size, we probably have a header */ |
| 378 | | logerror("Found header(size) - Skipped\n"); |
| 429 | logerror("Found header (size) - Skipped\n"); |
| 379 | 430 | } |
| 380 | 431 | else if ((snes_rom_size % 0x8000) == 512) |
| 381 | 432 | { |
| 382 | 433 | /* As a last check we'll see if there's exactly 512 bytes extra to this image. */ |
| 383 | | logerror("Found header(extra) - Skipped\n"); |
| 434 | logerror("Found header (extra) - Skipped\n"); |
| 384 | 435 | } |
| 385 | 436 | else |
| 386 | 437 | { |
| 387 | 438 | /* No header found so go back to the start of the file */ |
| 388 | 439 | logerror("No header found.\n"); |
| 389 | 440 | offset = 0; |
| 441 | } |
| 442 | |
| 443 | return offset; |
| 444 | } |
| 390 | 445 | |
| 391 | | if (image_software_entry(image) == NULL) |
| 392 | | image_fseek(image, offset, SEEK_SET); |
| 446 | |
| 447 | /* This determines if a cart is in Mode 20, 21, 22 or 25; sets state->cart[0].mode and |
| 448 | state->cart[0].sram accordingly; and returns the offset of the internal header (needed to |
| 449 | detect BSX and ST carts) */ |
| 450 | static UINT32 snes_find_hilo_mode( running_device *image, UINT8 *buffer, UINT32 offset, int cartid ) |
| 451 | { |
| 452 | snes_state *state = (snes_state *)image->machine->driver_data; |
| 453 | UINT8 valid_mode20, valid_mode21, valid_mode25; |
| 454 | UINT32 retvalue; |
| 455 | |
| 456 | /* Now to determine if this is a lo-ROM, a hi-ROM or an extended lo/hi-ROM */ |
| 457 | valid_mode20 = snes_validate_infoblock(buffer, 0x007fc0); |
| 458 | valid_mode21 = snes_validate_infoblock(buffer, 0x00ffc0); |
| 459 | valid_mode25 = snes_validate_infoblock(buffer, 0x40ffc0); |
| 460 | |
| 461 | /* Images larger than 32mbits are likely ExHiRom */ |
| 462 | if (valid_mode25) |
| 463 | valid_mode25 += 4; |
| 464 | |
| 465 | if ((valid_mode20 >= valid_mode21) && (valid_mode20 >= valid_mode25)) |
| 466 | { |
| 467 | if ((buffer[0x007fd5] == 0x32) || ((state->cart_size - offset) > 0x401000)) |
| 468 | state->cart[cartid].mode = SNES_MODE_22; // ExLoRom |
| 469 | else |
| 470 | state->cart[cartid].mode = SNES_MODE_20; // LoRom |
| 471 | |
| 472 | retvalue = 0x007fc0; |
| 473 | |
| 474 | /* a few games require 512k, however we store twice as much to be sure to cover the various mirrors */ |
| 475 | state->cart[cartid].sram_max = 0x100000; |
| 393 | 476 | } |
| 477 | else if (valid_mode21 >= valid_mode25) |
| 478 | { |
| 479 | state->cart[cartid].mode = SNES_MODE_21; // HiRom |
| 480 | retvalue = 0x00ffc0; |
| 481 | state->cart[cartid].sram_max = 0x20000; |
| 482 | } |
| 483 | else |
| 484 | { |
| 485 | state->cart[cartid].mode = SNES_MODE_25; // ExHiRom |
| 486 | retvalue = 0x40ffc0; |
| 487 | state->cart[cartid].sram_max = 0x20000; |
| 488 | } |
| 394 | 489 | |
| 490 | logerror( "\t HiROM/LoROM id: %s (LoROM: %d , HiROM: %d, ExHiROM: %d)\n", |
| 491 | (state->cart[cartid].mode == SNES_MODE_20) ? "LoROM" : |
| 492 | (state->cart[cartid].mode == SNES_MODE_21) ? "HiROM" : |
| 493 | (state->cart[cartid].mode == SNES_MODE_22) ? "ExLoROM" : |
| 494 | (state->cart[cartid].mode == SNES_MODE_25) ? "ExHiROM" : "Other (BSX or ST)", |
| 495 | valid_mode20, valid_mode21, valid_mode25); |
| 496 | |
| 497 | return retvalue; |
| 498 | } |
| 499 | |
| 500 | static int snes_find_addon_chip( running_machine *machine ) |
| 501 | { |
| 502 | snes_state *state = (snes_state *)machine->driver_data; |
| 503 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 504 | int supported_type = 1; |
| 505 | |
| 506 | /* Info mostly taken from http://snesemu.black-ship.net/misc/-from%20nsrt.edgeemu.com-chipinfo.htm */ |
| 507 | switch (snes_r_bank1(space, 0x00ffd6)) |
| 508 | { |
| 509 | case 0x00: |
| 510 | case 0x01: |
| 511 | case 0x02: |
| 512 | state->has_addon_chip = HAS_NONE; |
| 513 | break; |
| 514 | |
| 515 | case 0x03: |
| 516 | if (snes_r_bank1(space, 0x00ffd5) == 0x30) |
| 517 | state->has_addon_chip = HAS_DSP4; |
| 518 | else |
| 519 | state->has_addon_chip = HAS_DSP1; |
| 520 | break; |
| 521 | |
| 522 | case 0x04: |
| 523 | state->has_addon_chip = HAS_DSP1; |
| 524 | break; |
| 525 | |
| 526 | case 0x05: |
| 527 | if (snes_r_bank1(space, 0x00ffd5) == 0x20) |
| 528 | state->has_addon_chip = HAS_DSP2; |
| 529 | /* DSP-3 is hard to detect. We exploit the fact that the only game has been manufactured by Bandai */ |
| 530 | else if ((snes_r_bank1(space, 0x00ffd5) == 0x30) && (snes_r_bank1(space, 0x00ffda) == 0xb2)) |
| 531 | state->has_addon_chip = HAS_DSP3; |
| 532 | else |
| 533 | state->has_addon_chip = HAS_DSP1; |
| 534 | break; |
| 535 | |
| 536 | case 0x13: // Mario Chip 1 |
| 537 | case 0x14: // GSU-x |
| 538 | case 0x15: // GSU-x |
| 539 | case 0x1a: // GSU-1 (21 MHz at start) |
| 540 | if (snes_r_bank1(space, 0x00ffd5) == 0x20) |
| 541 | state->has_addon_chip = HAS_SUPERFX; |
| 542 | break; |
| 543 | |
| 544 | case 0x25: |
| 545 | state->has_addon_chip = HAS_OBC1; |
| 546 | break; |
| 547 | |
| 548 | case 0x32: // needed by a Sample game (according to ZSNES) |
| 549 | case 0x34: |
| 550 | case 0x35: |
| 551 | if (snes_r_bank1(space, 0x00ffd5) == 0x23) |
| 552 | { |
| 553 | state->has_addon_chip = HAS_SA1; |
| 554 | supported_type = 0; |
| 555 | printf("This is a SA-1 type game, currently unsupported by the driver"); |
| 556 | } |
| 557 | break; |
| 558 | |
| 559 | case 0x43: |
| 560 | case 0x45: |
| 561 | if (snes_r_bank1(space, 0x00ffd5) == 0x32) |
| 562 | { |
| 563 | state->has_addon_chip = HAS_SDD1; |
| 564 | } |
| 565 | break; |
| 566 | |
| 567 | case 0x55: |
| 568 | if (snes_r_bank1(space, 0x00ffd5) == 0x35) |
| 569 | { |
| 570 | state->has_addon_chip = HAS_RTC; |
| 571 | } |
| 572 | break; |
| 573 | |
| 574 | case 0xe3: |
| 575 | state->has_addon_chip = HAS_Z80GB; |
| 576 | supported_type = 0; |
| 577 | break; |
| 578 | |
| 579 | case 0xf3: |
| 580 | state->has_addon_chip = HAS_CX4; |
| 581 | break; |
| 582 | |
| 583 | case 0xf5: |
| 584 | if (snes_r_bank1(space, 0x00ffd5) == 0x30) |
| 585 | { |
| 586 | state->has_addon_chip = HAS_ST018; |
| 587 | supported_type = 0; |
| 588 | } |
| 589 | else if (snes_r_bank1(space, 0x00ffd5) == 0x3a) |
| 590 | { |
| 591 | state->has_addon_chip = HAS_SPC7110; |
| 592 | } |
| 593 | break; |
| 594 | |
| 595 | case 0xf6: |
| 596 | /* These Seta ST-01X chips have both 0x30 at 0x00ffd5, |
| 597 | they only differ for the 'size' at 0x00ffd7 */ |
| 598 | if (snes_r_bank1(space, 0x00ffd7) < 0x0a) |
| 599 | { |
| 600 | state->has_addon_chip = HAS_ST011; |
| 601 | supported_type = 0; |
| 602 | } |
| 603 | else |
| 604 | { |
| 605 | state->has_addon_chip = HAS_ST010; |
| 606 | } |
| 607 | break; |
| 608 | |
| 609 | case 0xf9: |
| 610 | if (snes_r_bank1(space, 0x00ffd5) == 0x3a) |
| 611 | { |
| 612 | state->has_addon_chip = HAS_SPC7110_RTC; |
| 613 | supported_type = 0; |
| 614 | } |
| 615 | break; |
| 616 | |
| 617 | default: |
| 618 | state->has_addon_chip = HAS_UNK; |
| 619 | supported_type = 0; |
| 620 | break; |
| 621 | } |
| 622 | |
| 623 | return supported_type; |
| 624 | } |
| 625 | |
| 626 | static void snes_cart_log_info( running_machine *machine, int total_blocks, int supported ) |
| 627 | { |
| 628 | snes_state *state = (snes_state *)machine->driver_data; |
| 629 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 630 | char title[21], rom_id[4], company_id[2]; |
| 631 | int i, company, has_ram = 0, has_sram = 0; |
| 632 | |
| 633 | /* Company */ |
| 634 | for (i = 0; i < 2; i++) |
| 635 | company_id[i] = snes_r_bank1(space, 0x00ffb0 + i); |
| 636 | company = (char_to_int_conv(company_id[0]) << 4) + char_to_int_conv(company_id[1]); |
| 637 | if (company == 0) |
| 638 | company = snes_r_bank1(space, 0x00ffda); |
| 639 | |
| 640 | /* ROM ID */ |
| 641 | for( i = 0; i < 4; i++ ) |
| 642 | rom_id[i] = snes_r_bank1(space, 0x00ffb2 + i); |
| 643 | |
| 644 | /* Title */ |
| 645 | for( i = 0; i < 21; i++ ) |
| 646 | title[i] = snes_r_bank1(space, 0x00ffc0 + i); |
| 647 | |
| 648 | /* RAM */ |
| 649 | if (((snes_r_bank1(space, 0x00ffd6) & 0xf) == 1) || |
| 650 | ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 2) || |
| 651 | ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 4) || |
| 652 | ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 5)) |
| 653 | has_ram = 1; |
| 654 | |
| 655 | /* SRAM */ |
| 656 | if (((snes_r_bank1(space, 0x00ffd6) & 0xf) == 2) || |
| 657 | ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 5) || |
| 658 | ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 6)) |
| 659 | has_sram = 1; |
| 660 | |
| 661 | logerror( "ROM DETAILS\n" ); |
| 662 | logerror( "===========\n\n" ); |
| 663 | logerror( "\tTotal blocks: %d (%dmb)\n", total_blocks, total_blocks / (state->cart[0].mode & 5 ? 32 : 16) ); |
| 664 | logerror( "\tROM bank size: %s \n", |
| 665 | (state->cart[0].mode == SNES_MODE_20) ? "LoROM" : |
| 666 | (state->cart[0].mode == SNES_MODE_21) ? "HiROM" : |
| 667 | (state->cart[0].mode == SNES_MODE_22) ? "ExLoROM" : |
| 668 | (state->cart[0].mode == SNES_MODE_25) ? "ExHiROM" : "Other (BSX or ST)" ); |
| 669 | logerror( "\tCompany: %s [%.2s]\n", companies[company], company_id ); |
| 670 | logerror( "\tROM ID: %.4s\n\n", rom_id ); |
| 671 | |
| 672 | logerror( "HEADER DETAILS\n" ); |
| 673 | logerror( "==============\n\n" ); |
| 674 | logerror( "\tName: %.21s\n", title ); |
| 675 | logerror( "\tSpeed: %s [%d]\n", ((snes_r_bank1(space, 0x00ffd5) & 0xf0)) ? "FastROM" : "SlowROM", (snes_r_bank1(space, 0x00ffd5) & 0xf0) >> 4 ); |
| 676 | logerror( "\tBank size: %s [%d]\n", (snes_r_bank1(space, 0x00ffd5) & 0xf) ? "HiROM" : "LoROM", snes_r_bank1(space, 0x00ffd5) & 0xf ); |
| 677 | |
| 678 | logerror( "\tType: %s", types[state->has_addon_chip]); |
| 679 | if (has_ram) |
| 680 | logerror( ", RAM"); |
| 681 | if (has_sram) |
| 682 | logerror( ", SRAM"); |
| 683 | logerror( " [%d]\n", snes_r_bank1(space, 0x00ffd6) ); |
| 684 | |
| 685 | logerror( "\tSize: %d megabits [%d]\n", 1 << (snes_r_bank1(space, 0x00ffd7) - 7), snes_r_bank1(space, 0x00ffd7) ); |
| 686 | logerror( "\tSRAM: %d kilobits [%d]\n", state->cart[0].sram * 8, snes_ram[0xffd8] ); |
| 687 | logerror( "\tCountry: %s [%d]\n", countries[snes_r_bank1(space, 0x00ffd9)], snes_r_bank1(space, 0x00ffd9) ); |
| 688 | logerror( "\tLicense: %s [%X]\n", companies[snes_r_bank1(space, 0x00ffda)], snes_r_bank1(space, 0x00ffda) ); |
| 689 | logerror( "\tVersion: 1.%d\n", snes_r_bank1(space, 0x00ffdb) ); |
| 690 | logerror( "\tInv Checksum: %X %X\n", snes_r_bank1(space, 0x00ffdd), snes_r_bank1(space, 0x00ffdc) ); |
| 691 | logerror( "\tChecksum: %X %X\n", snes_r_bank1(space, 0x00ffdf), snes_r_bank1(space, 0x00ffde) ); |
| 692 | logerror( "\tNMI Address: %2X%2Xh\n", snes_r_bank1(space, 0x00fffb), snes_r_bank1(space, 0x00fffa) ); |
| 693 | logerror( "\tStart Address: %2X%2Xh\n\n", snes_r_bank1(space, 0x00fffd), snes_r_bank1(space, 0x00fffc) ); |
| 694 | |
| 695 | logerror( "\tMode: %d\n", state->cart[0].mode); |
| 696 | |
| 697 | if (!supported) |
| 698 | logerror("WARNING: This cart type \"%s\" is not supported yet!\n", types[state->has_addon_chip]); |
| 699 | } |
| 700 | |
| 701 | static DEVICE_IMAGE_LOAD( snes_cart ) |
| 702 | { |
| 703 | int supported_type = 1, i, j; |
| 704 | running_machine *machine = image->machine; |
| 705 | snes_state *state = (snes_state *)machine->driver_data; |
| 706 | const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM ); |
| 707 | int total_blocks, read_blocks, has_bsx_slot = 0, st_bios = 0; |
| 708 | UINT32 offset, int_header_offs; |
| 709 | UINT8 *temp_buffer = auto_alloc_array(machine, UINT8, 0x410000); |
| 710 | UINT8 *ROM; |
| 711 | |
| 712 | if (image_software_entry(image) == NULL) |
| 713 | state->cart_size = image_length(image); |
| 714 | else |
| 715 | state->cart_size = image_get_software_region_length(image, "rom"); |
| 716 | |
| 717 | /* Check for a header (512 bytes), and skip it if found */ |
| 718 | offset = snes_skip_header(image, state->cart_size); |
| 719 | |
| 720 | if (image_software_entry(image) == NULL) |
| 721 | image_fseek(image, offset, SEEK_SET); |
| 722 | |
| 395 | 723 | /* We need to take a sample to test what mode we need to be in (the sample has to be quite large to cope with large carts in ExHiRom) */ |
| 396 | 724 | if (image_software_entry(image) == NULL) |
| 397 | 725 | { |
| r8081 | r8082 | |
| 403 | 731 | memcpy(temp_buffer, image_get_software_region(image, "rom") + offset, 0x40ffff); |
| 404 | 732 | } |
| 405 | 733 | |
| 406 | | /* Now to determine if this is a lo-ROM, a hi-ROM or an extended lo/hi-ROM */ |
| 407 | | valid_mode20 = snes_validate_infoblock(temp_buffer, 0x007fc0); |
| 408 | | valid_mode21 = snes_validate_infoblock(temp_buffer, 0x00ffc0); |
| 409 | | valid_mode25 = snes_validate_infoblock(temp_buffer, 0x40ffc0); |
| 734 | /* First, look if the cart is HiROM or LoROM (and set snes_cart accordingly) */ |
| 735 | int_header_offs = snes_find_hilo_mode(image, temp_buffer, offset, 0); |
| 410 | 736 | |
| 411 | | /* Images larger than 32mbits are likely ExHiRom */ |
| 412 | | if (valid_mode25) |
| 413 | | valid_mode25 += 4; |
| 414 | | |
| 415 | | if ((valid_mode20 >= valid_mode21) && (valid_mode20 >= valid_mode25)) |
| 737 | /* Then, detect BS-X carts */ |
| 738 | // Detect presence of BS-X Flash Cart |
| 739 | if ((temp_buffer[int_header_offs + 0x13] == 0x00 || temp_buffer[int_header_offs + 0x13] == 0xff) && |
| 740 | temp_buffer[int_header_offs + 0x14] == 0x00) |
| 416 | 741 | { |
| 417 | | if ((temp_buffer[0x007fd5] == 0x32) || ((snes_rom_size - offset) > 0x401000)) |
| 418 | | snes_cart.mode = SNES_MODE_22; // ExLoRom |
| 419 | | else |
| 420 | | snes_cart.mode = SNES_MODE_20; // LoRom |
| 421 | | |
| 422 | | /* a few games require 512k, however we store twice as much to be sure to cover the various mirrors */ |
| 423 | | snes_cart.sram_max = 0x100000; |
| 742 | UINT8 n15 = temp_buffer[int_header_offs + 0x15]; |
| 743 | if (n15 == 0x00 || n15 == 0x80 || n15 == 0x84 || n15 == 0x9c || n15 == 0xbc || n15 == 0xfc) |
| 744 | { |
| 745 | if (temp_buffer[int_header_offs + 0x1a] == 0x33 || temp_buffer[int_header_offs + 0x1a] == 0xff) |
| 746 | { |
| 747 | // BS-X Flash Cart |
| 748 | state->cart[0].mode = SNES_MODE_BSX; |
| 749 | } |
| 750 | } |
| 424 | 751 | } |
| 425 | | else if (valid_mode21 >= valid_mode25) |
| 752 | |
| 753 | // Detect presence of BS-X flash cartridge connector |
| 754 | if ((temp_buffer[int_header_offs - 14] == 'Z') && (temp_buffer[int_header_offs - 11] == 'J')) |
| 426 | 755 | { |
| 427 | | snes_cart.mode = SNES_MODE_21; // HiRom |
| 428 | | snes_cart.sram_max = 0x20000; |
| 756 | UINT8 n13 = temp_buffer[int_header_offs - 13]; |
| 757 | if ((n13 >= 'A' && n13 <= 'Z') || (n13 >= '0' && n13 <= '9')) |
| 758 | { |
| 759 | if (temp_buffer[int_header_offs + 0x1a] == 0x33 || |
| 760 | (temp_buffer[int_header_offs - 10] == 0x00 && temp_buffer[int_header_offs - 4] == 0x00)) |
| 761 | { |
| 762 | has_bsx_slot = 1; |
| 763 | } |
| 764 | } |
| 429 | 765 | } |
| 430 | | else |
| 766 | |
| 767 | // If there is a BS-X connector, detect if it is the Base Cart or a compatible slotted cart |
| 768 | if (has_bsx_slot) |
| 431 | 769 | { |
| 432 | | snes_cart.mode = SNES_MODE_25; // ExHiRom |
| 433 | | snes_cart.sram_max = 0x20000; |
| 770 | if (!memcmp(temp_buffer + int_header_offs, "Satellaview BS-X ", 21)) |
| 771 | { |
| 772 | //BS-X Base Cart |
| 773 | state->cart[0].mode = SNES_MODE_BSX; |
| 774 | // handle RAM |
| 775 | } |
| 776 | else |
| 777 | { |
| 778 | state->cart[0].mode = (int_header_offs ==0x007fc0) ? SNES_MODE_BSLO : SNES_MODE_BSHI; |
| 779 | // handle RAM? |
| 780 | } |
| 434 | 781 | } |
| 435 | 782 | |
| 436 | | if (SNES_CART_DEBUG) printf("mode %d\n", snes_cart.mode); |
| 437 | | |
| 438 | | /* Loading data */ |
| 783 | /* Then, detect Sufami Turbo carts */ |
| 784 | if (!memcmp(temp_buffer, "BANDAI SFC-ADX", 14)) |
| 785 | { |
| 786 | state->cart[0].mode = SNES_MODE_ST; |
| 787 | if (!memcmp(temp_buffer + 16, "SFC-ADX BACKUP", 14)) |
| 788 | st_bios = 1; |
| 789 | } |
| 790 | |
| 791 | if (SNES_CART_DEBUG) printf("mode %d\n", state->cart[0].mode); |
| 792 | |
| 793 | /* Finally, load data */ |
| 439 | 794 | ROM = memory_region(image->machine, "cart"); |
| 440 | 795 | |
| 441 | 796 | if (image_software_entry(image) == NULL) |
| 442 | | image_fread(image, ROM, snes_rom_size - offset); |
| 797 | image_fread(image, ROM, state->cart_size - offset); |
| 443 | 798 | else |
| 444 | | memcpy(ROM, image_get_software_region(image, "rom") + offset, snes_rom_size - offset); |
| 799 | memcpy(ROM, image_get_software_region(image, "rom") + offset, state->cart_size - offset); |
| 445 | 800 | |
| 446 | | if (SNES_CART_DEBUG) printf("size %08X\n", snes_rom_size - offset); |
| 801 | if (SNES_CART_DEBUG) printf("size %08X\n", state->cart_size - offset); |
| 447 | 802 | |
| 448 | | /* FIXME: Insert crc check here */ |
| 803 | /* FIXME: Insert crc check here? */ |
| 449 | 804 | |
| 450 | 805 | /* How many blocks of data are available to be loaded? */ |
| 451 | | total_blocks = ((snes_rom_size - offset) / (snes_cart.mode & 0x05 ? 0x8000 : 0x10000)); |
| 806 | total_blocks = ((state->cart_size - offset) / (state->cart[0].mode & 0xa5 ? 0x8000 : 0x10000)); |
| 452 | 807 | read_blocks = 0; |
| 453 | 808 | |
| 454 | 809 | if (SNES_CART_DEBUG) printf("blocks %d\n", total_blocks); |
| r8081 | r8082 | |
| 464 | 819 | * This is likely what happens in the real SNES as well, because the unit cannot be aware of the exact |
| 465 | 820 | * size of data in the cart (procedure confirmed by byuu) |
| 466 | 821 | */ |
| 467 | | switch (snes_cart.mode) |
| 822 | switch (state->cart[0].mode) |
| 468 | 823 | { |
| 469 | 824 | case SNES_MODE_21: |
| 470 | 825 | /* HiROM carts load data in banks 0xc0 to 0xff. Each bank is fully mirrored in banks 0x40 to 0x7f |
| r8081 | r8082 | |
| 594 | 949 | } |
| 595 | 950 | break; |
| 596 | 951 | |
| 952 | case SNES_MODE_ST: |
| 953 | if (!st_bios) |
| 954 | { |
| 955 | printf("This is a Sufami Turbo data cart and cannot be loaded for snes/snespal in MESS.\n"); |
| 956 | printf("Please use snesst driver to load it, instead.\n"); |
| 957 | return INIT_FAIL; |
| 958 | } |
| 959 | else |
| 960 | { |
| 961 | // The Base ST cart consists of 8 * 0x8000 block which have to be loaded (and mirrored) |
| 962 | // at 0x00-0x1f:0x8000-0xffff and 0x80-0x9f:0x8000-0xffff |
| 963 | for (i = 0; i < 8; i++) |
| 964 | { |
| 965 | /* Loading data */ |
| 966 | memcpy(&snes_ram[0x008000 + i * 0x10000], &ROM[0x000000 + i * 0x8000], 0x8000); |
| 967 | /* Mirroring */ |
| 968 | memcpy(&snes_ram[0x808000 + i * 0x10000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000); |
| 969 | |
| 970 | /* Additional mirrors (to fill snes_ram up to 0x1fffff) */ |
| 971 | for (j = 1; j < 4; j++) |
| 972 | { |
| 973 | memcpy(&snes_ram[0x008000 + i * 0x10000 + j * 0x80000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000); |
| 974 | memcpy(&snes_ram[0x808000 + i * 0x10000 + j * 0x80000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000); |
| 975 | } |
| 976 | } |
| 977 | } |
| 978 | break; |
| 979 | |
| 980 | case SNES_MODE_BSX: |
| 981 | case SNES_MODE_BSLO: |
| 982 | case SNES_MODE_BSHI: |
| 983 | /* not handled yet */ |
| 984 | printf("This is a BS-X Satellaview image: MESS does not support these yet, sorry.\n"); |
| 985 | #if 0 |
| 986 | // shall we force incompatibility of flash carts without a base unit? |
| 987 | if (!has_bsx_slot) |
| 988 | { |
| 989 | printf("This is a BS-X flash cart and cannot be loaded in snes/snespal.\n"); |
| 990 | // printf("Please use snesbsx driver to load it, instead.\n"); |
| 991 | return INIT_FAIL; |
| 992 | } |
| 993 | #endif |
| 994 | break; |
| 995 | |
| 597 | 996 | default: |
| 598 | 997 | case SNES_MODE_20: |
| 599 | 998 | /* LoROM carts load data in banks 0x00 to 0x7f at address 0x8000 (actually up to 0x7d, because 0x7e and |
| r8081 | r8082 | |
| 648 | 1047 | break; |
| 649 | 1048 | } |
| 650 | 1049 | |
| 651 | | /* Find the type of cart and detect special chips */ |
| 652 | | /* Info mostly taken from http://snesemu.black-ship.net/misc/-from%20nsrt.edgeemu.com-chipinfo.htm */ |
| 653 | | switch (snes_r_bank1(space, 0x00ffd6)) |
| 654 | | { |
| 655 | | case 0x00: |
| 656 | | case 0x01: |
| 657 | | case 0x02: |
| 658 | | snes_has_addon_chip = HAS_NONE; |
| 659 | | break; |
| 1050 | /* Detect special chips */ |
| 1051 | supported_type = snes_find_addon_chip(machine); |
| 660 | 1052 | |
| 661 | | case 0x03: |
| 662 | | if (snes_r_bank1(space, 0x00ffd5) == 0x30) |
| 663 | | snes_has_addon_chip = HAS_DSP4; |
| 664 | | else |
| 665 | | snes_has_addon_chip = HAS_DSP1; |
| 666 | | break; |
| 1053 | /* Find the amount of cart ram (even if we call it sram...) */ |
| 1054 | if ((state->has_addon_chip != HAS_SUPERFX)) |
| 1055 | state->cart[0].sram = snes_r_bank1(space, 0x00ffd8); |
| 1056 | else |
| 1057 | state->cart[0].sram = (snes_r_bank1(space, 0x00ffbd) & 0x07); |
| 667 | 1058 | |
| 668 | | case 0x04: |
| 669 | | snes_has_addon_chip = HAS_DSP1; |
| 670 | | break; |
| 1059 | if (state->cart[0].sram > 0) |
| 1060 | { |
| 1061 | state->cart[0].sram = (1024 << state->cart[0].sram); |
| 1062 | if (state->cart[0].sram > state->cart[0].sram_max) |
| 1063 | state->cart[0].sram = state->cart[0].sram_max; |
| 1064 | } |
| 671 | 1065 | |
| 672 | | case 0x05: |
| 673 | | if (snes_r_bank1(space, 0x00ffd5) == 0x20) |
| 674 | | snes_has_addon_chip = HAS_DSP2; |
| 675 | | /* DSP-3 is hard to detect. We exploit the fact that the only game has been manufactured by Bandai */ |
| 676 | | else if ((snes_r_bank1(space, 0x00ffd5) == 0x30) && (snes_r_bank1(space, 0x00ffda) == 0xb2)) |
| 677 | | snes_has_addon_chip = HAS_DSP3; |
| 678 | | else |
| 679 | | snes_has_addon_chip = HAS_DSP1; |
| 680 | | break; |
| 1066 | /* adjust size for very large carts */ |
| 1067 | if (state->cart[0].mode == SNES_MODE_20 && ((state->cart_size - offset) > 0x200000 || state->cart[0].sram > (32 * 1024))) |
| 1068 | state->cart[0].small_sram = 1; |
| 1069 | else |
| 1070 | state->cart[0].small_sram = 0; |
| 681 | 1071 | |
| 682 | | case 0x13: // Mario Chip 1 |
| 683 | | case 0x14: // GSU-x |
| 684 | | case 0x15: // GSU-x |
| 685 | | case 0x1a: // GSU-1 (21 MHz at start) |
| 686 | | if (snes_r_bank1(space, 0x00ffd5) == 0x20) |
| 687 | | snes_has_addon_chip = HAS_SUPERFX; |
| 688 | | break; |
| 1072 | /* Log snes_cart information */ |
| 1073 | snes_cart_log_info(machine, total_blocks, supported_type); |
| 689 | 1074 | |
| 690 | | case 0x25: |
| 691 | | snes_has_addon_chip = HAS_OBC1; |
| 692 | | break; |
| 1075 | /* Load SRAM */ |
| 1076 | snes_load_sram(machine); |
| 693 | 1077 | |
| 694 | | case 0x32: // needed by a Sample game (according to ZSNES) |
| 695 | | case 0x34: |
| 696 | | case 0x35: |
| 697 | | if (snes_r_bank1(space, 0x00ffd5) == 0x23) |
| 698 | | { |
| 699 | | snes_has_addon_chip = HAS_SA1; |
| 700 | | supported_type = 0; |
| 701 | | fatalerror("This is a SA-1 type game, currently unsupported by the driver"); |
| 702 | | } |
| 703 | | break; |
| 1078 | /* All done */ |
| 1079 | return INIT_PASS; |
| 1080 | } |
| 704 | 1081 | |
| 705 | | case 0x43: |
| 706 | | case 0x45: |
| 707 | | if (snes_r_bank1(space, 0x00ffd5) == 0x32) |
| 708 | | { |
| 709 | | snes_has_addon_chip = HAS_SDD1; |
| 710 | | } |
| 711 | | break; |
| 1082 | static DEVICE_IMAGE_LOAD( sufami_cart ) |
| 1083 | { |
| 1084 | running_machine *machine = image->machine; |
| 1085 | snes_state *state = (snes_state *)machine->driver_data; |
| 1086 | int total_blocks, read_blocks; |
| 1087 | int st_bios = 0, slot_id; |
| 1088 | UINT32 offset, st_data_offset = 0; |
| 1089 | UINT8 *temp_buffer = auto_alloc_array(machine, UINT8, 0x410000); |
| 1090 | UINT8 *ROM; |
| 712 | 1091 | |
| 713 | | case 0x55: |
| 714 | | if (snes_r_bank1(space, 0x00ffd5) == 0x35) |
| 715 | | { |
| 716 | | snes_has_addon_chip = HAS_RTC; |
| 717 | | supported_type = 0; |
| 718 | | } |
| 719 | | break; |
| 1092 | snes_ram = memory_region(machine, "maincpu"); |
| 720 | 1093 | |
| 721 | | case 0xe3: |
| 722 | | snes_has_addon_chip = HAS_Z80GB; |
| 723 | | supported_type = 0; |
| 724 | | break; |
| 1094 | if (strcmp(image->tag(), "slot_a") == 0) |
| 1095 | { |
| 1096 | st_data_offset = 0x200000; |
| 1097 | slot_id = 0; |
| 1098 | } |
| 725 | 1099 | |
| 726 | | case 0xf3: |
| 727 | | snes_has_addon_chip = HAS_CX4; |
| 728 | | break; |
| 729 | | |
| 730 | | case 0xf5: |
| 731 | | if (snes_r_bank1(space, 0x00ffd5) == 0x30) |
| 732 | | { |
| 733 | | snes_has_addon_chip = HAS_ST018; |
| 734 | | supported_type = 0; |
| 735 | | } |
| 736 | | else if (snes_r_bank1(space, 0x00ffd5) == 0x3a) |
| 737 | | { |
| 738 | | snes_has_addon_chip = HAS_SPC7110; |
| 739 | | } |
| 740 | | break; |
| 741 | | |
| 742 | | case 0xf6: |
| 743 | | /* These Seta ST-01X chips have both 0x30 at 0x00ffd5, |
| 744 | | they only differ for the 'size' at 0x00ffd7 */ |
| 745 | | if (snes_r_bank1(space, 0x00ffd7) < 0x0a) |
| 746 | | { |
| 747 | | snes_has_addon_chip = HAS_ST011; |
| 748 | | supported_type = 0; |
| 749 | | } |
| 750 | | else |
| 751 | | { |
| 752 | | snes_has_addon_chip = HAS_ST010; |
| 753 | | } |
| 754 | | break; |
| 755 | | |
| 756 | | case 0xf9: |
| 757 | | if (snes_r_bank1(space, 0x00ffd5) == 0x3a) |
| 758 | | { |
| 759 | | snes_has_addon_chip = HAS_SPC7110_RTC; |
| 760 | | supported_type = 0; |
| 761 | | } |
| 762 | | break; |
| 763 | | |
| 764 | | default: |
| 765 | | snes_has_addon_chip = HAS_UNK; |
| 766 | | supported_type = 0; |
| 767 | | break; |
| 1100 | if (strcmp(image->tag(), "slot_b") == 0) |
| 1101 | { |
| 1102 | st_data_offset = 0x400000; |
| 1103 | slot_id = 1; |
| 768 | 1104 | } |
| 769 | 1105 | |
| 770 | | /* Find the amount of cart ram (even if we call it sram...) */ |
| 771 | | if ((snes_has_addon_chip != HAS_SUPERFX)) |
| 772 | | snes_cart.sram = snes_r_bank1(space, 0x00ffd8); |
| 1106 | if (image_software_entry(image) == NULL) |
| 1107 | state->cart_size = image_length(image); |
| 773 | 1108 | else |
| 774 | | snes_cart.sram = (snes_r_bank1(space, 0x00ffbd) & 0x07); |
| 775 | | |
| 776 | | if (snes_cart.sram > 0) |
| 1109 | state->cart_size = image_get_software_region_length(image, "rom"); |
| 1110 | |
| 1111 | /* Check for a header (512 bytes), and skip it if found */ |
| 1112 | offset = snes_skip_header(image, state->cart_size); |
| 1113 | |
| 1114 | if (image_software_entry(image) == NULL) |
| 1115 | image_fseek(image, offset, SEEK_SET); |
| 1116 | |
| 1117 | /* We need to take a sample to test what mode we need to be in (the sample has to be quite large to cope with large carts in ExHiRom) */ |
| 1118 | if (image_software_entry(image) == NULL) |
| 777 | 1119 | { |
| 778 | | snes_cart.sram = (1024 << snes_cart.sram); |
| 779 | | if (snes_cart.sram > snes_cart.sram_max) |
| 780 | | snes_cart.sram = snes_cart.sram_max; |
| 1120 | image_fread(image, temp_buffer, 0x40ffff); |
| 1121 | image_fseek(image, offset, SEEK_SET); /* Rewind */ |
| 781 | 1122 | } |
| 1123 | else |
| 1124 | { |
| 1125 | memcpy(temp_buffer, image_get_software_region(image, "rom") + offset, 0x40ffff); |
| 1126 | } |
| 1127 | |
| 1128 | /* Detect Sufami Turbo carts */ |
| 1129 | if (!memcmp(temp_buffer, "BANDAI SFC-ADX", 14)) |
| 1130 | { |
| 1131 | state->cart[slot_id].mode = SNES_MODE_ST; |
| 1132 | if (!memcmp(temp_buffer + 16, "SFC-ADX BACKUP", 14)) |
| 1133 | st_bios = 1; |
| 1134 | } |
| 1135 | else |
| 1136 | { |
| 1137 | printf("This is not a Sufami Turbo data pack.\n"); |
| 1138 | printf("This image cannot be loaded in snesst (Use snes or snespal drivers, instead).\n"); |
| 1139 | return INIT_FAIL; |
| 1140 | } |
| 1141 | |
| 1142 | if (st_bios == 1) |
| 1143 | { |
| 1144 | printf("This is the Sufami Turbo BIOS and not a Sufami Turbo data pack.\n"); |
| 1145 | printf("This image cannot be loaded in snesst.\n"); |
| 1146 | return INIT_FAIL; |
| 1147 | } |
| 782 | 1148 | |
| 783 | | /* adjust size for very large carts */ |
| 784 | | if (snes_cart.mode == SNES_MODE_20 && ((snes_rom_size - offset) > 0x200000 || snes_cart.sram > (32 * 1024))) |
| 785 | | snes_cart.small_sram = 1; |
| 1149 | /* Loading data */ |
| 1150 | ROM = memory_region(image->machine, image->tag()); |
| 1151 | |
| 1152 | if (image_software_entry(image) == NULL) |
| 1153 | image_fread(image, ROM, state->cart_size - offset); |
| 786 | 1154 | else |
| 787 | | snes_cart.small_sram = 0; |
| 1155 | memcpy(ROM, image_get_software_region(image, "rom") + offset, state->cart_size - offset); |
| 788 | 1156 | |
| 1157 | if (SNES_CART_DEBUG) |
| 1158 | printf("size %08X\n", state->cart_size - offset); |
| 1159 | |
| 1160 | /* FIXME: Insert crc check here? */ |
| 1161 | |
| 1162 | /* How many blocks of data are available to be loaded? */ |
| 1163 | total_blocks = (state->cart_size - offset) / 0x8000; |
| 1164 | read_blocks = 0; |
| 1165 | |
| 1166 | if (SNES_CART_DEBUG) |
| 1167 | printf("blocks %d\n", total_blocks); |
| 1168 | |
| 1169 | // actually load the cart |
| 1170 | while (read_blocks < 32 && read_blocks < total_blocks) |
| 1171 | { |
| 1172 | /* Loading data */ |
| 1173 | // CART (either A or B) |
| 1174 | memcpy(&snes_ram[0x008000 + st_data_offset + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x8000], 0x8000); |
| 1175 | /* Mirroring */ |
| 1176 | memcpy(&snes_ram[0x808000 + st_data_offset + read_blocks * 0x10000], &snes_ram[0x8000 + st_data_offset + (read_blocks * 0x10000)], 0x8000); |
| 1177 | |
| 1178 | read_blocks++; |
| 1179 | } |
| 789 | 1180 | |
| 790 | | /* Log snes_cart information */ |
| 1181 | /* Filling banks up to 0x1f and their mirrors */ |
| 1182 | while (read_blocks % 32) |
| 791 | 1183 | { |
| 792 | | char title[21], rom_id[4], company_id[2]; |
| 793 | | int company, has_ram = 0, has_sram = 0; |
| 1184 | int j = 0, repeat_blocks; |
| 1185 | while ((read_blocks % (32 >> j)) && j < 5) |
| 1186 | j++; |
| 1187 | repeat_blocks = read_blocks % (32 >> (j - 1)); |
| 1188 | |
| 1189 | memcpy(&snes_ram[st_data_offset + read_blocks * 0x10000], &snes_ram[st_data_offset + (read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000); |
| 1190 | memcpy(&snes_ram[0x800000 + st_data_offset + read_blocks * 0x10000], &snes_ram[st_data_offset + (read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000); |
| 1191 | read_blocks += repeat_blocks; |
| 1192 | } |
| 794 | 1193 | |
| 795 | | /* Company */ |
| 796 | | for( i = 0; i < 2; i++ ) |
| 797 | | company_id[i] = snes_r_bank1(space, 0x00ffb0 + i); |
| 798 | | company = (char_to_int_conv(company_id[0]) << 4) + char_to_int_conv(company_id[1]); |
| 799 | | if (company == 0) |
| 800 | | company = snes_r_bank1(space, 0x00ffda); |
| 1194 | sufami_load_sram(machine, image->tag()); |
| 801 | 1195 | |
| 802 | | /* ROM ID */ |
| 803 | | for( i = 0; i < 4; i++ ) |
| 804 | | rom_id[i] = snes_r_bank1(space, 0x00ffb2 + i); |
| 1196 | state->cart[slot_id].slot_in_use = 1; // aknowledge the cart in this slot, for saving sram at exit |
| 805 | 1197 | |
| 806 | | /* Title */ |
| 807 | | for( i = 0; i < 21; i++ ) |
| 808 | | title[i] = snes_r_bank1(space, 0x00ffc0 + i); |
| 1198 | auto_free(image->machine, temp_buffer); |
| 1199 | |
| 1200 | return INIT_PASS; |
| 1201 | } |
| 809 | 1202 | |
| 810 | | /* RAM */ |
| 811 | | if (((snes_r_bank1(space, 0x00ffd6) & 0xf) == 1) || |
| 812 | | ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 2) || |
| 813 | | ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 4) || |
| 814 | | ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 5)) |
| 815 | | has_ram = 1; |
| 1203 | static DEVICE_IMAGE_LOAD( bsx_cart ) |
| 1204 | { |
| 1205 | running_machine *machine = image->machine; |
| 1206 | snes_state *state = (snes_state *)machine->driver_data; |
| 1207 | int total_blocks, read_blocks; |
| 1208 | int has_bsx_slot = 0; |
| 1209 | UINT32 offset, int_header_offs; |
| 1210 | UINT8 *temp_buffer = auto_alloc_array(machine, UINT8, 0x410000); |
| 1211 | UINT8 *ROM; |
| 1212 | |
| 1213 | if (image_software_entry(image) == NULL) |
| 1214 | state->cart_size = image_length(image); |
| 1215 | else |
| 1216 | state->cart_size = image_get_software_region_length(image, "rom"); |
| 1217 | |
| 1218 | /* Check for a header (512 bytes), and skip it if found */ |
| 1219 | offset = snes_skip_header(image, state->cart_size); |
| 1220 | |
| 1221 | if (image_software_entry(image) == NULL) |
| 1222 | image_fseek(image, offset, SEEK_SET); |
| 1223 | |
| 1224 | /* We need to take a sample to test what mode we need to be in (the sample has to be quite large to cope with large carts in ExHiRom) */ |
| 1225 | if (image_software_entry(image) == NULL) |
| 1226 | { |
| 1227 | image_fread(image, temp_buffer, 0x40ffff); |
| 1228 | image_fseek(image, offset, SEEK_SET); /* Rewind */ |
| 1229 | } |
| 1230 | else |
| 1231 | { |
| 1232 | memcpy(temp_buffer, image_get_software_region(image, "rom") + offset, 0x40ffff); |
| 1233 | } |
| 1234 | |
| 1235 | /* First, look if the cart is HiROM or LoROM (and set snes_cart accordingly) */ |
| 1236 | int_header_offs = snes_find_hilo_mode(image, temp_buffer, offset, 0); |
| 1237 | |
| 1238 | // Detect presence of BS-X flash cartridge connector |
| 1239 | if ((temp_buffer[int_header_offs - 14] == 'Z') && (temp_buffer[int_header_offs - 11] == 'J')) |
| 1240 | { |
| 1241 | UINT8 n13 = temp_buffer[int_header_offs - 13]; |
| 1242 | if ((n13 >= 'A' && n13 <= 'Z') || (n13 >= '0' && n13 <= '9')) |
| 1243 | { |
| 1244 | if (temp_buffer[int_header_offs + 0x1a] == 0x33 || |
| 1245 | (temp_buffer[int_header_offs - 10] == 0x00 && temp_buffer[int_header_offs - 4] == 0x00)) |
| 1246 | { |
| 1247 | has_bsx_slot = 1; |
| 1248 | } |
| 1249 | } |
| 1250 | } |
| 1251 | |
| 1252 | // If there is a BS-X connector, detect if it is the Base Cart or a compatible slotted cart |
| 1253 | if (has_bsx_slot) |
| 1254 | { |
| 1255 | if (!memcmp(temp_buffer + int_header_offs, "Satellaview BS-X ", 21)) |
| 1256 | { |
| 1257 | //BS-X Base Cart |
| 1258 | state->cart[0].mode = SNES_MODE_BSX; |
| 1259 | // handle RAM |
| 1260 | } |
| 1261 | else |
| 1262 | { |
| 1263 | state->cart[0].mode = (int_header_offs ==0x007fc0) ? SNES_MODE_BSLO : SNES_MODE_BSHI; |
| 1264 | // handle RAM? |
| 1265 | } |
| 1266 | } |
| 1267 | else |
| 1268 | { |
| 1269 | printf("This is not a BS-X compatible cart.\n"); |
| 1270 | printf("This image cannot be loaded in the first cartslot of snesbsx.\n"); |
| 1271 | return INIT_FAIL; |
| 1272 | } |
| 1273 | |
| 1274 | /* Loading data */ |
| 1275 | ROM = memory_region(image->machine, "cart"); |
| 1276 | |
| 1277 | if (image_software_entry(image) == NULL) |
| 1278 | image_fread(image, ROM, state->cart_size - offset); |
| 1279 | else |
| 1280 | memcpy(ROM, image_get_software_region(image, "rom") + offset, state->cart_size - offset); |
| 1281 | |
| 1282 | // if (SNES_CART_DEBUG) |
| 1283 | printf("size %08X\n", state->cart_size - offset); |
| 1284 | |
| 1285 | /* FIXME: Insert crc check here? */ |
| 1286 | |
| 1287 | /* How many blocks of data are available to be loaded? */ |
| 1288 | total_blocks = (state->cart_size - offset) / 0x8000; |
| 1289 | read_blocks = 0; |
| 1290 | |
| 1291 | // if (SNES_CART_DEBUG) |
| 1292 | printf("blocks %d\n", total_blocks); |
| 1293 | |
| 1294 | // actually load the cart |
| 1295 | while (read_blocks < 64 && read_blocks < total_blocks) |
| 1296 | { |
| 1297 | /* Loading data */ |
| 1298 | memcpy(&snes_ram[0x008000 + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x8000], 0x8000); |
| 1299 | /* Mirroring */ |
| 1300 | memcpy(&snes_ram[0x808000 + read_blocks * 0x10000], &snes_ram[0x8000 + (read_blocks * 0x10000)], 0x8000); |
| 1301 | |
| 1302 | read_blocks++; |
| 1303 | } |
| 1304 | |
| 1305 | /* Filling banks up to 0x3f and their mirrors */ |
| 1306 | while (read_blocks % 64) |
| 1307 | { |
| 1308 | int j = 0, repeat_blocks; |
| 1309 | while ((read_blocks % (64 >> j)) && j < 6) |
| 1310 | j++; |
| 1311 | repeat_blocks = read_blocks % (64 >> (j - 1)); |
| 1312 | |
| 1313 | memcpy(&snes_ram[read_blocks * 0x10000], &snes_ram[(read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000); |
| 1314 | memcpy(&snes_ram[0x800000 + read_blocks * 0x10000], &snes_ram[(read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000); |
| 1315 | read_blocks += repeat_blocks; |
| 1316 | } |
| 816 | 1317 | |
| 817 | | /* SRAM */ |
| 818 | | if (((snes_r_bank1(space, 0x00ffd6) & 0xf) == 2) || |
| 819 | | ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 5) || |
| 820 | | ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 6)) |
| 821 | | has_sram = 1; |
| 1318 | return INIT_PASS; |
| 1319 | } |
| 822 | 1320 | |
| 823 | | logerror( "ROM DETAILS\n" ); |
| 824 | | logerror( "===========\n\n" ); |
| 825 | | logerror( "\tTotal blocks: %d (%dmb)\n", total_blocks, total_blocks / (snes_cart.mode & 5 ? 32 : 16) ); |
| 826 | | logerror( "\tROM bank size: %s (LoROM: %d , HiROM: %d, ExHiROM: %d)\n", |
| 827 | | (snes_cart.mode == SNES_MODE_20) ? "LoROM" : |
| 828 | | (snes_cart.mode == SNES_MODE_21) ? "HiROM" : |
| 829 | | (snes_cart.mode == SNES_MODE_22) ? "ExLoROM" : "ExHiROM", |
| 830 | | valid_mode20, valid_mode21, valid_mode25); |
| 831 | | logerror( "\tCompany: %s [%.2s]\n", companies[company], company_id ); |
| 832 | | logerror( "\tROM ID: %.4s\n\n", rom_id ); |
| 1321 | static DEVICE_IMAGE_LOAD( bsx2slot_cart ) |
| 1322 | { |
| 1323 | running_machine *machine = image->machine; |
| 1324 | snes_state *state = (snes_state *)machine->driver_data; |
| 1325 | UINT32 offset, int_header_offs; |
| 1326 | UINT8 *temp_buffer = auto_alloc_array(machine, UINT8, 0x410000); |
| 1327 | UINT8 *ROM; |
| 1328 | |
| 1329 | if (image_software_entry(image) == NULL) |
| 1330 | state->cart_size = image_length(image); |
| 1331 | else |
| 1332 | state->cart_size = image_get_software_region_length(image, "rom"); |
| 1333 | |
| 1334 | /* Check for a header (512 bytes), and skip it if found */ |
| 1335 | offset = snes_skip_header(image, state->cart_size); |
| 1336 | |
| 1337 | if (image_software_entry(image) == NULL) |
| 1338 | image_fseek(image, offset, SEEK_SET); |
| 1339 | |
| 1340 | /* We need to take a sample to test what mode we need to be in (the sample has to be quite large to cope with large carts in ExHiRom) */ |
| 1341 | if (image_software_entry(image) == NULL) |
| 1342 | { |
| 1343 | image_fread(image, temp_buffer, 0x40ffff); |
| 1344 | image_fseek(image, offset, SEEK_SET); /* Rewind */ |
| 1345 | } |
| 1346 | else |
| 1347 | { |
| 1348 | memcpy(temp_buffer, image_get_software_region(image, "rom") + offset, 0x40ffff); |
| 1349 | } |
| 1350 | |
| 1351 | /* First, look if the cart is HiROM or LoROM (and set snes_cart accordingly) */ |
| 1352 | int_header_offs = snes_find_hilo_mode(image, temp_buffer, offset, 1); |
| 1353 | |
| 1354 | // Detect presence of BS-X Flash Cart |
| 1355 | if ((temp_buffer[int_header_offs + 0x13] == 0x00 || temp_buffer[int_header_offs + 0x13] == 0xff) && |
| 1356 | temp_buffer[int_header_offs + 0x14] == 0x00) |
| 1357 | { |
| 1358 | UINT8 n15 = temp_buffer[int_header_offs + 0x15]; |
| 1359 | if (n15 == 0x00 || n15 == 0x80 || n15 == 0x84 || n15 == 0x9c || n15 == 0xbc || n15 == 0xfc) |
| 1360 | { |
| 1361 | if (temp_buffer[int_header_offs + 0x1a] == 0x33 || temp_buffer[int_header_offs + 0x1a] == 0xff) |
| 1362 | { |
| 1363 | // BS-X Flash Cart |
| 1364 | state->cart[1].mode = SNES_MODE_BSX; |
| 1365 | } |
| 1366 | } |
| 1367 | } |
| 833 | 1368 | |
| 834 | | logerror( "HEADER DETAILS\n" ); |
| 835 | | logerror( "==============\n\n" ); |
| 836 | | logerror( "\tName: %.21s\n", title ); |
| 837 | | logerror( "\tSpeed: %s [%d]\n", ((snes_r_bank1(space, 0x00ffd5) & 0xf0)) ? "FastROM" : "SlowROM", (snes_r_bank1(space, 0x00ffd5) & 0xf0) >> 4 ); |
| 838 | | logerror( "\tBank size: %s [%d]\n", (snes_r_bank1(space, 0x00ffd5) & 0xf) ? "HiROM" : "LoROM", snes_r_bank1(space, 0x00ffd5) & 0xf ); |
| 839 | | |
| 840 | | logerror( "\tType: %s", types[snes_has_addon_chip]); |
| 841 | | if (has_ram) |
| 842 | | logerror( ", RAM"); |
| 843 | | if (has_sram) |
| 844 | | logerror( ", SRAM"); |
| 845 | | logerror( " [%d]\n", snes_r_bank1(space, 0x00ffd6) ); |
| 846 | | |
| 847 | | logerror( "\tSize: %d megabits [%d]\n", 1 << (snes_r_bank1(space, 0x00ffd7) - 7), snes_r_bank1(space, 0x00ffd7) ); |
| 848 | | logerror( "\tSRAM: %d kilobits [%d]\n", snes_cart.sram * 8, snes_ram[0xffd8] ); |
| 849 | | logerror( "\tCountry: %s [%d]\n", countries[snes_r_bank1(space, 0x00ffd9)], snes_r_bank1(space, 0x00ffd9) ); |
| 850 | | logerror( "\tLicense: %s [%X]\n", companies[snes_r_bank1(space, 0x00ffda)], snes_r_bank1(space, 0x00ffda) ); |
| 851 | | logerror( "\tVersion: 1.%d\n", snes_r_bank1(space, 0x00ffdb) ); |
| 852 | | logerror( "\tInv Checksum: %X %X\n", snes_r_bank1(space, 0x00ffdd), snes_r_bank1(space, 0x00ffdc) ); |
| 853 | | logerror( "\tChecksum: %X %X\n", snes_r_bank1(space, 0x00ffdf), snes_r_bank1(space, 0x00ffde) ); |
| 854 | | logerror( "\tNMI Address: %2X%2Xh\n", snes_r_bank1(space, 0x00fffb), snes_r_bank1(space, 0x00fffa) ); |
| 855 | | logerror( "\tStart Address: %2X%2Xh\n\n", snes_r_bank1(space, 0x00fffd), snes_r_bank1(space, 0x00fffc) ); |
| 856 | | |
| 857 | | logerror( "\tMode: %d\n", snes_cart.mode); |
| 858 | | |
| 859 | | if (!supported_type) |
| 860 | | logerror("WARNING: This cart type \"%s\" is not supported yet!\n", types[snes_has_addon_chip]); |
| 1369 | if (state->cart[1].mode != SNES_MODE_BSX) |
| 1370 | { |
| 1371 | printf("This is not a BS-X flash cart.\n"); |
| 1372 | printf("This image cannot be loaded in the second cartslot of snesbsx.\n"); |
| 1373 | return INIT_FAIL; |
| 861 | 1374 | } |
| 862 | | |
| 863 | | /* Load SRAM */ |
| 864 | | snes_load_sram(space->machine); |
| 865 | | |
| 866 | | /* All done */ |
| 1375 | |
| 1376 | /* Loading data */ |
| 1377 | ROM = memory_region(image->machine, "flash"); |
| 1378 | |
| 1379 | if (image_software_entry(image) == NULL) |
| 1380 | image_fread(image, ROM, state->cart_size - offset); |
| 1381 | else |
| 1382 | memcpy(ROM, image_get_software_region(image, "rom") + offset, state->cart_size - offset); |
| 1383 | |
| 1384 | // actually load the cart |
| 867 | 1385 | return INIT_PASS; |
| 868 | 1386 | } |
| 869 | 1387 | |
| 870 | 1388 | MACHINE_DRIVER_START( snes_cartslot ) |
| 871 | 1389 | MDRV_CARTSLOT_ADD("cart") |
| 872 | | MDRV_CARTSLOT_EXTENSION_LIST("smc,sfc,fig,swc") |
| 1390 | MDRV_CARTSLOT_EXTENSION_LIST("sfc,smc,fig,swc,bin") |
| 873 | 1391 | MDRV_CARTSLOT_NOT_MANDATORY |
| 874 | 1392 | MDRV_CARTSLOT_INTERFACE("snes_cart") |
| 875 | 1393 | MDRV_CARTSLOT_LOAD(snes_cart) |
| 876 | 1394 | MDRV_SOFTWARE_LIST_ADD("snes") |
| 877 | 1395 | MACHINE_DRIVER_END |
| 1396 | |
| 1397 | // This (hackily) emulates a SNES unit with a Sufami Turbo Unit cart inserted: |
| 1398 | // hence, the user can mount two data cart in the two slots available on the ST Unit |
| 1399 | MACHINE_DRIVER_START( sufami_cartslot ) |
| 1400 | MDRV_CARTSLOT_ADD("slot_a") |
| 1401 | MDRV_CARTSLOT_EXTENSION_LIST("st,sfc") |
| 1402 | MDRV_CARTSLOT_NOT_MANDATORY |
| 1403 | MDRV_CARTSLOT_INTERFACE("sufami_cart") |
| 1404 | MDRV_CARTSLOT_LOAD(sufami_cart) |
| 1405 | |
| 1406 | MDRV_CARTSLOT_ADD("slot_b") |
| 1407 | MDRV_CARTSLOT_EXTENSION_LIST("st,sfc") |
| 1408 | MDRV_CARTSLOT_NOT_MANDATORY |
| 1409 | MDRV_CARTSLOT_INTERFACE("sufami_cart") |
| 1410 | MDRV_CARTSLOT_LOAD(sufami_cart) |
| 1411 | |
| 1412 | // MDRV_SOFTWARE_LIST_ADD("snes") |
| 1413 | MACHINE_DRIVER_END |
| 1414 | |
| 1415 | // This (hackily) emulates a SNES unit where you want to load a BS-X compatible cart: |
| 1416 | // hence, the user can mount a SNES cart in the first slot (either a BS-X BIOS cart, or a |
| 1417 | // BS-X compatible one, e.g. Same Game), and there is a second slot for the 8M data pack |
| 1418 | // (in a real SNES this would have been inserted in the smaller slot on the cart itself) |
| 1419 | MACHINE_DRIVER_START( bsx_cartslot ) |
| 1420 | MDRV_CARTSLOT_ADD("cart") |
| 1421 | MDRV_CARTSLOT_EXTENSION_LIST("sfc,smc,fig,swc,bin") |
| 1422 | MDRV_CARTSLOT_NOT_MANDATORY |
| 1423 | MDRV_CARTSLOT_INTERFACE("snes_cart") |
| 1424 | MDRV_CARTSLOT_LOAD(bsx_cart) |
| 1425 | |
| 1426 | MDRV_CARTSLOT_ADD("slot2") |
| 1427 | MDRV_CARTSLOT_EXTENSION_LIST("bs,sfc") |
| 1428 | MDRV_CARTSLOT_NOT_MANDATORY |
| 1429 | MDRV_CARTSLOT_INTERFACE("bsx_cart") |
| 1430 | MDRV_CARTSLOT_LOAD(bsx2slot_cart) |
| 1431 | |
| 1432 | // MDRV_SOFTWARE_LIST_ADD("snes") |
| 1433 | MACHINE_DRIVER_END |
| 1434 | |
| 1435 | DRIVER_INIT( snes_mess ) |
| 1436 | { |
| 1437 | snes_ram = memory_region(machine, "maincpu"); |
| 1438 | memset(snes_ram, 0, 0x1000000); |
| 1439 | } |
| 1440 | |
| 1441 | DRIVER_INIT( snesst ) |
| 1442 | { |
| 1443 | snes_state *state = (snes_state *)machine->driver_data; |
| 1444 | UINT8 *STBIOS = memory_region(machine, "sufami"); |
| 1445 | int i, j; |
| 1446 | |
| 1447 | state->cart[0].slot_in_use = 0; |
| 1448 | state->cart[1].slot_in_use = 0; |
| 1449 | |
| 1450 | DRIVER_INIT_CALL(snes_mess); |
| 1451 | |
| 1452 | // the Base ST cart consists of 8 * 0x8000 block which have to be loaded (and mirrored) |
| 1453 | // at 0x00-0x1f:0x8000-0xffff and 0x80-0x9f:0x8000-0xffff |
| 1454 | for (i = 0; i < 8; i++) |
| 1455 | { |
| 1456 | /* Loading data */ |
| 1457 | memcpy(&snes_ram[0x008000 + i * 0x10000], &STBIOS[0x000000 + i * 0x8000], 0x8000); |
| 1458 | /* Mirroring */ |
| 1459 | memcpy(&snes_ram[0x808000 + i * 0x10000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000); |
| 1460 | |
| 1461 | /* Additional mirrors (to fill snes_ram up to 0x1fffff) */ |
| 1462 | for (j = 1; j < 4; j++) |
| 1463 | { |
| 1464 | memcpy(&snes_ram[0x008000 + i * 0x10000 + j * 0x80000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000); |
| 1465 | memcpy(&snes_ram[0x808000 + i * 0x10000 + j * 0x80000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000); |
| 1466 | } |
| 1467 | } |
| 1468 | |
| 1469 | } |
src/mess/drivers/ti89.c
| r8081 | r8082 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | | TI-89 |
| 3 | TI-89, TI-92 and TI-92 plus driver by Sandro Ronco |
| 4 | 4 | |
| 5 | | 12/05/2009 Skeleton driver. |
| 5 | NVRAM works only if the calculator is turned off (2nd + ON) before closing of MESS |
| 6 | 6 | |
| 7 | TODO: |
| 8 | -Link |
| 9 | -HW 3 I/O port |
| 10 | -RTC |
| 11 | -LCD contrast |
| 7 | 12 | ****************************************************************************/ |
| 8 | 13 | |
| 9 | 14 | #include "emu.h" |
| 10 | 15 | #include "cpu/m68000/m68000.h" |
| 16 | #include "includes/ti89.h" |
| 11 | 17 | |
| 18 | static UINT8 ti_68k_keypad_r (running_machine *machine); |
| 19 | |
| 20 | class t68k_state |
| 21 | { |
| 22 | public: |
| 23 | static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, t68k_state(machine)); } |
| 24 | |
| 25 | t68k_state(running_machine &machine) { } |
| 26 | |
| 27 | /* HW specifications */ |
| 28 | UINT8 hw_version; |
| 29 | UINT8 mem_type; |
| 30 | UINT32 initial_pc; |
| 31 | UINT16 *ram; |
| 32 | UINT32 ram_size; |
| 33 | |
| 34 | /* keyboard */ |
| 35 | UINT16 kb_mask; |
| 36 | UINT8 on_key; |
| 37 | |
| 38 | /* LCD */ |
| 39 | UINT8 lcd_on; |
| 40 | UINT32 lcd_base; |
| 41 | UINT8 lcd_width; |
| 42 | UINT8 lcd_height; |
| 43 | UINT8 lcd_contrast; |
| 44 | |
| 45 | /* Flash */ |
| 46 | UINT8 flash_protect; |
| 47 | UINT8 flash_state; |
| 48 | UINT8 flash_wait; |
| 49 | UINT8 flash_ready; |
| 50 | |
| 51 | /* I/O */ |
| 52 | UINT16 io_hw1[0x10]; |
| 53 | UINT16 io_hw2[0x80]; |
| 54 | |
| 55 | /* Timer */ |
| 56 | UINT8 timer_on; |
| 57 | UINT8 timer_val; |
| 58 | UINT16 timer_mask; |
| 59 | }; |
| 60 | |
| 61 | |
| 62 | static UINT8 ti_68k_keypad_r (running_machine *machine) |
| 63 | { |
| 64 | t68k_state *state = (t68k_state *)machine->driver_data; |
| 65 | UINT8 port, bit, data = 0xff; |
| 66 | static const char *const bitnames[] = {"BIT0", "BIT1", "BIT2", "BIT3", "BIT4", "BIT5", "BIT6", "BIT7"}; |
| 67 | |
| 68 | for (bit = 0; bit < 10; bit++) |
| 69 | if (~state->kb_mask & (0x01 << bit)) |
| 70 | for (port = 0; port < 8; port++) |
| 71 | data ^= input_port_read(machine, bitnames[port]) & (0x01 << bit) ? 0x01 << port : 0x00; |
| 72 | return data; |
| 73 | } |
| 74 | |
| 75 | |
| 76 | WRITE16_HANDLER ( ti68k_io_w ) |
| 77 | { |
| 78 | t68k_state *state = (t68k_state *)space->machine->driver_data; |
| 79 | |
| 80 | switch(offset & 0x0f) |
| 81 | { |
| 82 | case 0x00: |
| 83 | state->lcd_contrast=(state->lcd_contrast & 0xfe) | BIT(data, 5); |
| 84 | break; |
| 85 | case 0x02: |
| 86 | if (!(data & 0x10) && data != state->io_hw1[offset]) |
| 87 | cputag_suspend(space->machine, "maincpu", SUSPEND_REASON_DISABLE, 1); |
| 88 | break; |
| 89 | case 0x08: |
| 90 | state->lcd_base = data << 3; |
| 91 | break; |
| 92 | case 0x09: |
| 93 | state->lcd_width = (0x40 - ((data >> 8) & 0xff)) * 0x10; |
| 94 | state->lcd_height = 0x100 - (data & 0xff); |
| 95 | break; |
| 96 | case 0x0a: |
| 97 | state->timer_on = BIT(data ,1); |
| 98 | switch((data >> 4) & 0x03) |
| 99 | { |
| 100 | case 0: state->timer_mask = 0x0000; break; |
| 101 | case 1: state->timer_mask = 0x000f; break; |
| 102 | case 2: state->timer_mask = 0x007f; break; |
| 103 | case 3: state->timer_mask = 0x1fff; break; |
| 104 | } |
| 105 | break; |
| 106 | case 0x0b: |
| 107 | state->timer_val = data & 0xff; |
| 108 | case 0x0c: |
| 109 | state->kb_mask = data & 0x03ff; |
| 110 | break; |
| 111 | case 0x0e: |
| 112 | state->lcd_on = (((data >> 8) & 0x3c) == 0x3c) ? 0 : 1; |
| 113 | state->lcd_contrast = (state->lcd_contrast & 0x01) | ((data & 0x0f) << 1); |
| 114 | break; |
| 115 | default: break; |
| 116 | } |
| 117 | state->io_hw1[offset & 0x0f] = data; |
| 118 | } |
| 119 | |
| 120 | |
| 121 | READ16_HANDLER ( ti68k_io_r ) |
| 122 | { |
| 123 | t68k_state *state = (t68k_state *)space->machine->driver_data; |
| 124 | UINT16 data; |
| 125 | |
| 126 | switch (offset & 0x0f) |
| 127 | { |
| 128 | case 0x00: |
| 129 | data = 0x0400 | ((state->lcd_contrast & 1) << 13); |
| 130 | break; |
| 131 | case 0x0b: |
| 132 | data = state->timer_val; |
| 133 | break; |
| 134 | case 0x0d: |
| 135 | data = ((!state->on_key) << 9) | ti_68k_keypad_r(space->machine); |
| 136 | break; |
| 137 | default: |
| 138 | data= state->io_hw1[offset & 0x0f]; |
| 139 | } |
| 140 | return data; |
| 141 | } |
| 142 | |
| 143 | |
| 144 | WRITE16_HANDLER ( ti68k_io2_w ) |
| 145 | { |
| 146 | t68k_state *state = (t68k_state *)space->machine->driver_data; |
| 147 | switch(offset & 0x7f) |
| 148 | { |
| 149 | case 0x0b: |
| 150 | state->lcd_base = 0x4c00 + 0x1000 * (data & 0x03); |
| 151 | break; |
| 152 | case 0x0e: |
| 153 | state->lcd_on = (data & 0x02) ? 1 : 0; |
| 154 | break; |
| 155 | default: break; |
| 156 | } |
| 157 | state->io_hw2[offset & 0x7f] = data; |
| 158 | } |
| 159 | |
| 160 | |
| 161 | READ16_HANDLER ( ti68k_io2_r ) |
| 162 | { |
| 163 | t68k_state *state = (t68k_state *)space->machine->driver_data; |
| 164 | UINT16 data; |
| 165 | |
| 166 | switch (offset & 0x7f) |
| 167 | { |
| 168 | default: |
| 169 | data= state->io_hw2[offset & 0x7f]; |
| 170 | } |
| 171 | return data; |
| 172 | } |
| 173 | |
| 174 | |
| 175 | WRITE16_HANDLER ( flash_w ) |
| 176 | { |
| 177 | t68k_state *state = (t68k_state *)space->machine->driver_data; |
| 178 | UINT16 *flash_base = (UINT16 *)memory_region(space->machine, "maincpu"); |
| 179 | |
| 180 | /* verification if it is flash memory */ |
| 181 | if (state->mem_type != FLASH) |
| 182 | return; |
| 183 | |
| 184 | if (state->flash_ready) |
| 185 | { |
| 186 | flash_base[offset] &= data; |
| 187 | state->flash_ready = 0; |
| 188 | state->flash_wait = 1; |
| 189 | } |
| 190 | else if (data == 0x5050) |
| 191 | state->flash_state = 0x50; |
| 192 | else if (data == 0x1010) |
| 193 | { |
| 194 | state->flash_ready = 1; |
| 195 | state->flash_state = 0x50; |
| 196 | } |
| 197 | else if (data == 0x2020 && state->flash_state == 0x50) |
| 198 | state->flash_state = 0x20; |
| 199 | else if (data == 0xd0d0 && state->flash_state == 0x20) |
| 200 | { |
| 201 | state->flash_state = 0xd0; |
| 202 | state->flash_wait = 1; |
| 203 | memset(&flash_base[offset & 0xff0000], 0xff, 64 * 1024); |
| 204 | } |
| 205 | else if (data == 0xffff && state->flash_state == 0x50) |
| 206 | { |
| 207 | state->flash_ready = 0; |
| 208 | state->flash_wait = 0; |
| 209 | } |
| 210 | else if (data == 0x9090) |
| 211 | state->flash_state = 0x90; |
| 212 | } |
| 213 | |
| 214 | |
| 215 | READ16_HANDLER ( rom_r ) |
| 216 | { |
| 217 | t68k_state *state = (t68k_state *)space->machine->driver_data; |
| 218 | UINT16 *rom_base = (UINT16 *)memory_region(space->machine, "maincpu"); |
| 219 | |
| 220 | if (state->mem_type == FLASH) |
| 221 | { |
| 222 | if (state->flash_state == 0x90 ) |
| 223 | switch(offset & 0xffff) |
| 224 | { |
| 225 | case 0: |
| 226 | return 0x8900; |
| 227 | case 2: |
| 228 | return 0xb500; |
| 229 | default: |
| 230 | return 0xffff; |
| 231 | } |
| 232 | else if (state->flash_wait) |
| 233 | return 0xffff; |
| 234 | else |
| 235 | return rom_base[offset]; |
| 236 | } |
| 237 | else |
| 238 | return rom_base[offset]; |
| 239 | } |
| 240 | |
| 241 | |
| 242 | static TIMER_CALLBACK( ti68k_timer_callback ) |
| 243 | { |
| 244 | t68k_state *state = (t68k_state *)machine->driver_data; |
| 245 | static UINT64 timer; |
| 246 | |
| 247 | timer++; |
| 248 | |
| 249 | if (state->timer_on) |
| 250 | { |
| 251 | if (!(timer & state->timer_mask) && BIT(state->io_hw1[0x0a], 3)) |
| 252 | { |
| 253 | if (state->timer_val) |
| 254 | state->timer_val++; |
| 255 | else |
| 256 | state->timer_val = (state->io_hw1[0x0b]) & 0xff; |
| 257 | } |
| 258 | |
| 259 | if (!BIT(state->io_hw1[0x0a], 7) && ((state->hw_version == HW1) || (!BIT(state->io_hw1[0x0f], 2) && !BIT(state->io_hw1[0x0f], 1)))) |
| 260 | { |
| 261 | if (!(timer & 0x003f)) |
| 262 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_1, HOLD_LINE); |
| 263 | |
| 264 | if (!(timer & 0x3fff) && !BIT(state->io_hw1[0x0a], 3)) |
| 265 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_3, HOLD_LINE); |
| 266 | |
| 267 | if (!(timer & state->timer_mask) && BIT(state->io_hw1[0x0a], 3) && state->timer_val == 0) |
| 268 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_5, HOLD_LINE); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | if (ti_68k_keypad_r(machine) != 0xff) |
| 273 | cputag_set_input_line(machine, "maincpu", M68K_IRQ_2, HOLD_LINE); |
| 274 | } |
| 275 | |
| 276 | |
| 277 | static ADDRESS_MAP_START(ti92_mem, ADDRESS_SPACE_PROGRAM, 16 ) |
| 278 | ADDRESS_MAP_UNMAP_HIGH |
| 279 | AM_RANGE(0x000000, 0x0fffff) AM_RAM AM_BASE_SIZE_MEMBER(t68k_state, ram, ram_size) |
| 280 | AM_RANGE(0x200000, 0x5fffff) AM_UNMAP // ROM |
| 281 | AM_RANGE(0x600000, 0x6fffff) AM_READWRITE(ti68k_io_r, ti68k_io_w) |
| 282 | ADDRESS_MAP_END |
| 283 | |
| 284 | |
| 12 | 285 | static ADDRESS_MAP_START(ti89_mem, ADDRESS_SPACE_PROGRAM, 16 ) |
| 13 | 286 | ADDRESS_MAP_UNMAP_HIGH |
| 14 | | AM_RANGE(0x000000, 0x1fffff) AM_ROM |
| 15 | | AM_RANGE(0x200000, 0x2fffff) AM_RAM |
| 287 | AM_RANGE(0x000000, 0x0fffff) AM_RAM AM_BASE_SIZE_MEMBER(t68k_state, ram, ram_size) |
| 288 | AM_RANGE(0x200000, 0x3fffff) AM_READWRITE(rom_r, flash_w) |
| 289 | AM_RANGE(0x400000, 0x5fffff) AM_NOP |
| 290 | AM_RANGE(0x600000, 0x6fffff) AM_READWRITE(ti68k_io_r, ti68k_io_w) |
| 291 | AM_RANGE(0x700000, 0x7fffff) AM_READWRITE(ti68k_io2_r, ti68k_io2_w) |
| 16 | 292 | ADDRESS_MAP_END |
| 17 | 293 | |
| 18 | | /* Input ports */ |
| 19 | | static INPUT_PORTS_START( ti89 ) |
| 294 | |
| 295 | static ADDRESS_MAP_START(ti92p_mem, ADDRESS_SPACE_PROGRAM, 16 ) |
| 296 | ADDRESS_MAP_UNMAP_HIGH |
| 297 | AM_RANGE(0x000000, 0x0fffff) AM_RAM AM_BASE_SIZE_MEMBER(t68k_state, ram, ram_size) |
| 298 | AM_RANGE(0x200000, 0x3fffff) AM_NOP |
| 299 | AM_RANGE(0x400000, 0x5fffff) AM_READWRITE(rom_r, flash_w) |
| 300 | AM_RANGE(0x600000, 0x6fffff) AM_READWRITE(ti68k_io_r, ti68k_io_w) |
| 301 | AM_RANGE(0x700000, 0x7fffff) AM_READWRITE(ti68k_io2_r, ti68k_io2_w) |
| 302 | ADDRESS_MAP_END |
| 303 | |
| 304 | |
| 305 | static INPUT_CHANGED( ti68k_on_key ) |
| 306 | { |
| 307 | t68k_state *state = (t68k_state *)field->port->machine->driver_data; |
| 308 | |
| 309 | state->on_key = newval; |
| 310 | |
| 311 | if (state->on_key) |
| 312 | { |
| 313 | if (cputag_is_suspended(field->port->machine, "maincpu", SUSPEND_REASON_DISABLE)) |
| 314 | cputag_resume(field->port->machine, "maincpu", SUSPEND_REASON_DISABLE); |
| 315 | |
| 316 | cputag_set_input_line(field->port->machine, "maincpu", M68K_IRQ_6, HOLD_LINE); |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | |
| 321 | /* Input ports for TI-89 and TI-89 Titanium*/ |
| 322 | static INPUT_PORTS_START (ti8x) |
| 323 | PORT_START("BIT0") /* bit 0 */ |
| 324 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Up") PORT_CODE(KEYCODE_UP) |
| 325 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ENTER (ENTRY)") PORT_CODE(KEYCODE_ENTER) |
| 326 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(-)") PORT_CODE(KEYCODE_M) |
| 327 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_STOP) |
| 328 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) |
| 329 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("APPS") PORT_CODE(KEYCODE_F11) |
| 330 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC) |
| 331 | PORT_START("BIT1") /* bit 1 */ |
| 332 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Left") PORT_CODE(KEYCODE_LEFT) |
| 333 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("+") PORT_CODE(KEYCODE_BACKSLASH) |
| 334 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) |
| 335 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) |
| 336 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) |
| 337 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("STORE") PORT_CODE(KEYCODE_TAB) |
| 338 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ON") PORT_CODE(KEYCODE_F10) PORT_CHANGED(ti68k_on_key, 0) |
| 339 | PORT_START("BIT2") /* bit 2 */ |
| 340 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Down") PORT_CODE(KEYCODE_DOWN) |
| 341 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS) |
| 342 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) |
| 343 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) |
| 344 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) |
| 345 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("EE") PORT_CODE(KEYCODE_E) |
| 346 | PORT_START("BIT3") /* bit 3 */ |
| 347 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Right") PORT_CODE(KEYCODE_RIGHT) |
| 348 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("*") PORT_CODE(KEYCODE_L) |
| 349 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) |
| 350 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) |
| 351 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7) |
| 352 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("|") PORT_CODE(KEYCODE_COLON) |
| 353 | PORT_START("BIT4") /* bit 4 */ |
| 354 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2nd") PORT_CODE(KEYCODE_LALT) |
| 355 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("/") PORT_CODE(KEYCODE_SLASH) |
| 356 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA) |
| 357 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(")") PORT_CODE(KEYCODE_CLOSEBRACE) |
| 358 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(") PORT_CODE(KEYCODE_OPENBRACE) |
| 359 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("=") PORT_CODE(KEYCODE_EQUALS) |
| 360 | PORT_START("BIT5") /* bit 5 */ |
| 361 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT) |
| 362 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("^") PORT_CODE(KEYCODE_P) |
| 363 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) |
| 364 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) |
| 365 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) |
| 366 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) |
| 367 | PORT_START("BIT6") /* bit 6 */ |
| 368 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3nd") PORT_CODE(KEYCODE_LCONTROL) |
| 369 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CLEAR") PORT_CODE(KEYCODE_DEL) |
| 370 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("<--") PORT_CODE(KEYCODE_BACKSPACE) |
| 371 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CATALOG") PORT_CODE(KEYCODE_F8) |
| 372 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Mode") PORT_CODE(KEYCODE_F12) |
| 373 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("HOME") PORT_CODE(KEYCODE_HOME) |
| 374 | PORT_START("BIT7") /* bit 7 */ |
| 375 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ALPHA") PORT_CODE(KEYCODE_CAPSLOCK) |
| 376 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) |
| 377 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) |
| 378 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) |
| 379 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) |
| 380 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) |
| 20 | 381 | INPUT_PORTS_END |
| 21 | 382 | |
| 383 | /* Input ports for TI-92 and TI92 Plus*/ |
| 384 | static INPUT_PORTS_START (ti9x) |
| 385 | PORT_START("BIT0") /* bit 0 */ |
| 386 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2nd") PORT_CODE(KEYCODE_LALT) |
| 387 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_UNUSED |
| 388 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_UNUSED |
| 389 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("STORE") PORT_CODE(KEYCODE_TAB) |
| 390 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) |
| 391 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("/") PORT_CODE(KEYCODE_SLASH) |
| 392 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("^") PORT_CODE(KEYCODE_COLON) |
| 393 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("=") PORT_CODE(KEYCODE_EQUALS) |
| 394 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("<--") PORT_CODE(KEYCODE_BACKSPACE) |
| 395 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS) |
| 396 | PORT_START("BIT1") /* bit 1 */ |
| 397 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3nd") PORT_CODE(KEYCODE_LCONTROL) |
| 398 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) |
| 399 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) |
| 400 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) |
| 401 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) |
| 402 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) |
| 403 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) |
| 404 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) |
| 405 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("o") PORT_CODE(KEYCODE_BACKSLASH) |
| 406 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER_PAD) |
| 407 | PORT_START("BIT2") /* bit 2 */ |
| 408 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT) |
| 409 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) |
| 410 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) |
| 411 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) |
| 412 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) |
| 413 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H) |
| 414 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J) |
| 415 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) |
| 416 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) |
| 417 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) |
| 418 | PORT_START("BIT3") /* bit 3 */ |
| 419 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Clock") PORT_CODE(KEYCODE_F11) |
| 420 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W) |
| 421 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) |
| 422 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R) |
| 423 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) |
| 424 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) |
| 425 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) |
| 426 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) |
| 427 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) |
| 428 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) |
| 429 | PORT_START("BIT4") /* bit 4 */ |
| 430 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Left") PORT_CODE(KEYCODE_LEFT) |
| 431 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) |
| 432 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) |
| 433 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) |
| 434 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) |
| 435 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) |
| 436 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) |
| 437 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) |
| 438 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("+") PORT_CODE(KEYCODE_PLUS_PAD) |
| 439 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) |
| 440 | PORT_START("BIT5") /* bit 5 */ |
| 441 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Up") PORT_CODE(KEYCODE_UP) |
| 442 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) |
| 443 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) |
| 444 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7) |
| 445 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(") PORT_CODE(KEYCODE_OPENBRACE) |
| 446 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("SIN") PORT_CODE(KEYCODE_PGUP) |
| 447 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("LN") PORT_CODE(KEYCODE_PGDN) |
| 448 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CLEAR") PORT_CODE(KEYCODE_DEL) |
| 449 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("MODE") PORT_CODE(KEYCODE_F12) |
| 450 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) |
| 451 | PORT_START("BIT6") /* bit 6 */ |
| 452 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Right") PORT_CODE(KEYCODE_RIGHT) |
| 453 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) |
| 454 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) |
| 455 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) |
| 456 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(")") PORT_CODE(KEYCODE_CLOSEBRACE) |
| 457 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("COS") PORT_CODE(KEYCODE_END) |
| 458 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER) |
| 459 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("APPS") PORT_CODE(KEYCODE_HOME) |
| 460 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC) |
| 461 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_STOP) |
| 462 | PORT_START("BIT7") /* bit 7 */ |
| 463 | PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Down") PORT_CODE(KEYCODE_DOWN) |
| 464 | PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) |
| 465 | PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) |
| 466 | PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) |
| 467 | PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA) |
| 468 | PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("TAN") PORT_CODE(KEYCODE_INSERT) |
| 469 | PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) |
| 470 | PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("*") PORT_CODE(KEYCODE_ASTERISK) |
| 471 | PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ON") PORT_CODE(KEYCODE_F10) PORT_CHANGED(ti68k_on_key, 0) |
| 472 | PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(-)") PORT_CODE(KEYCODE_MINUS_PAD) |
| 473 | INPUT_PORTS_END |
| 22 | 474 | |
| 23 | | static MACHINE_RESET(ti89) |
| 475 | |
| 476 | NVRAM_HANDLER( ti68k ) |
| 24 | 477 | { |
| 478 | t68k_state *state = (t68k_state *)machine->driver_data; |
| 479 | UINT16 *rom = (UINT16 *)memory_region(machine, "maincpu"); |
| 480 | |
| 481 | if (read_or_write) |
| 482 | { |
| 483 | mame_fwrite(file, state->ram, state->ram_size); |
| 484 | |
| 485 | /* if the memory is flash saves the content */ |
| 486 | if (state->mem_type == FLASH) |
| 487 | mame_fwrite(file, rom, 0x200000); |
| 488 | } |
| 489 | else |
| 490 | { |
| 491 | if (file) |
| 492 | { |
| 493 | mame_fread(file, state->ram, state->ram_size); |
| 494 | if (state->mem_type == FLASH) |
| 495 | mame_fread(file, rom, 0x200000); |
| 496 | } |
| 497 | else |
| 498 | memset(state->ram, 0, sizeof(state->ram)); |
| 499 | } |
| 25 | 500 | } |
| 26 | 501 | |
| 27 | | static VIDEO_START( ti89 ) |
| 502 | |
| 503 | static MACHINE_RESET(ti68k) |
| 28 | 504 | { |
| 505 | t68k_state *state = (t68k_state *)machine->driver_data; |
| 506 | cpu_set_reg(devtag_get_device(machine, "maincpu"), M68K_PC, state->initial_pc); |
| 507 | |
| 508 | state->kb_mask = 0xff; |
| 509 | state->on_key = 0; |
| 510 | state->lcd_base = 0; |
| 511 | state->lcd_width = 0; |
| 512 | state->lcd_height = 0; |
| 513 | state->lcd_on = 0; |
| 514 | state->lcd_contrast = 0; |
| 515 | state->flash_protect = 0; |
| 516 | state->flash_state = 0; |
| 517 | state->flash_wait = 0; |
| 518 | state->flash_ready = 0; |
| 519 | memset(state->io_hw1, 0, sizeof(state->io_hw1)); |
| 520 | memset(state->io_hw2, 0, sizeof(state->io_hw2)); |
| 521 | state->timer_on = 0; |
| 522 | state->timer_mask = 0xf; |
| 523 | state->timer_val = 0; |
| 29 | 524 | } |
| 30 | 525 | |
| 31 | | static VIDEO_UPDATE( ti89 ) |
| 526 | /* video */ |
| 527 | |
| 528 | static VIDEO_START( ti68k ) |
| 32 | 529 | { |
| 33 | | return 0; |
| 530 | |
| 34 | 531 | } |
| 35 | 532 | |
| 533 | static VIDEO_UPDATE( ti68k ) |
| 534 | { |
| 535 | /* preliminary implementation, doesn't use the contrast value */ |
| 536 | t68k_state *state = (t68k_state *)screen->machine->driver_data; |
| 537 | const address_space *space = cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 538 | UINT8 width = video_screen_get_width(screen); |
| 539 | UINT8 height = video_screen_get_height(screen); |
| 540 | UINT8 x, y, b; |
| 541 | |
| 542 | if (!state->lcd_on || !state->lcd_base) |
| 543 | bitmap_fill(bitmap, NULL, 1); |
| 544 | else |
| 545 | for (y = 0; y < height; y++) |
| 546 | for (x = 0; x < width / 8; x++) |
| 547 | { |
| 548 | UINT8 s_byte= memory_read_byte(space, state->lcd_base + y * (width/8) + x); |
| 549 | for (b = 0; b<8; b++) |
| 550 | *BITMAP_ADDR16(bitmap, y, x * 8 + (7 - b)) = (BIT(s_byte, b) > 0) ? 0 : 1; |
| 551 | } |
| 552 | |
| 553 | return 0; |
| 554 | } |
| 555 | |
| 556 | |
| 557 | MACHINE_START( ti68k ) |
| 558 | { |
| 559 | t68k_state *state = (t68k_state *)machine->driver_data; |
| 560 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 561 | UINT16 *rom = (UINT16 *)memory_region(space->machine, "maincpu"); |
| 562 | int i; |
| 563 | |
| 564 | state->mem_type= (rom[0x32] & 0x0f) ? EPROM : FLASH; |
| 565 | |
| 566 | if (state->mem_type == FLASH) |
| 567 | { |
| 568 | UINT32 base = ((((rom[0x82]) << 16) | rom[0x83]) & 0xffff)>>1; |
| 569 | |
| 570 | if (rom[base] >= 8) |
| 571 | state->hw_version = ((rom[base + 0x0b]) << 16) | rom[base + 0x0c]; |
| 572 | |
| 573 | if (!state->hw_version) |
| 574 | state->hw_version = HW1; |
| 575 | |
| 576 | for (i = 0x9000; i < 0x100000; i++) |
| 577 | if (rom[i] == 0xcccc && rom[i + 1] == 0xcccc) |
| 578 | break; |
| 579 | |
| 580 | state->initial_pc = ((rom[i + 4]) << 16) | rom[i + 5]; |
| 581 | } |
| 582 | else |
| 583 | { |
| 584 | state->hw_version = HW1; |
| 585 | state->initial_pc = ((rom[2]) << 16) | rom[3]; |
| 586 | |
| 587 | memory_unmap_read(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x200000, 0x5fffff, 0, 0); |
| 588 | |
| 589 | if (state->initial_pc > 0x400000) |
| 590 | memory_install_read16_handler( cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x400000, 0x5fffff, 0, 0, rom_r ); |
| 591 | else |
| 592 | memory_install_read16_handler( cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x200000, 0x3fffff, 0, 0, rom_r ); |
| 593 | |
| 594 | } |
| 595 | |
| 596 | timer_pulse(machine, ATTOTIME_IN_HZ(1<<14), NULL, 0, ti68k_timer_callback); |
| 597 | } |
| 598 | |
| 599 | |
| 36 | 600 | static MACHINE_DRIVER_START( ti89 ) |
| 601 | |
| 602 | MDRV_DRIVER_DATA(t68k_state) |
| 603 | |
| 37 | 604 | /* basic machine hardware */ |
| 38 | 605 | MDRV_CPU_ADD("maincpu",M68000, XTAL_10MHz) |
| 39 | 606 | MDRV_CPU_PROGRAM_MAP(ti89_mem) |
| 40 | 607 | |
| 41 | | MDRV_MACHINE_RESET(ti89) |
| 608 | MDRV_MACHINE_RESET(ti68k) |
| 42 | 609 | |
| 43 | 610 | /* video hardware */ |
| 44 | 611 | MDRV_SCREEN_ADD("screen", RASTER) |
| 45 | 612 | MDRV_SCREEN_REFRESH_RATE(50) |
| 46 | 613 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 47 | 614 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 48 | | MDRV_SCREEN_SIZE(640, 480) |
| 49 | | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) |
| 615 | MDRV_SCREEN_SIZE(240, 128) |
| 616 | MDRV_SCREEN_VISIBLE_AREA(0, 160-1, 0, 100-1) |
| 50 | 617 | MDRV_PALETTE_LENGTH(2) |
| 618 | MDRV_DEFAULT_LAYOUT(layout_lcd) |
| 51 | 619 | MDRV_PALETTE_INIT(black_and_white) |
| 52 | 620 | |
| 53 | | MDRV_VIDEO_START(ti89) |
| 54 | | MDRV_VIDEO_UPDATE(ti89) |
| 621 | MDRV_VIDEO_START(ti68k) |
| 622 | MDRV_VIDEO_UPDATE(ti68k) |
| 623 | |
| 624 | MDRV_MACHINE_START( ti68k ) |
| 625 | |
| 626 | MDRV_NVRAM_HANDLER(ti68k) |
| 627 | |
| 55 | 628 | MACHINE_DRIVER_END |
| 56 | 629 | |
| 630 | |
| 631 | static MACHINE_DRIVER_START( ti92 ) |
| 632 | |
| 633 | MDRV_IMPORT_FROM( ti89 ) |
| 634 | |
| 635 | MDRV_CPU_MODIFY("maincpu") |
| 636 | MDRV_CPU_PROGRAM_MAP(ti92_mem) |
| 637 | |
| 638 | /* video hardware */ |
| 639 | MDRV_SCREEN_MODIFY("screen") |
| 640 | MDRV_SCREEN_VISIBLE_AREA(0, 240-1, 0, 128-1) |
| 641 | |
| 642 | |
| 643 | MACHINE_DRIVER_END |
| 644 | |
| 645 | |
| 646 | static MACHINE_DRIVER_START( ti92p ) |
| 647 | |
| 648 | MDRV_IMPORT_FROM( ti89 ) |
| 649 | |
| 650 | MDRV_CPU_REPLACE("maincpu",M68000, XTAL_12MHz) |
| 651 | MDRV_CPU_PROGRAM_MAP(ti92p_mem) |
| 652 | |
| 653 | /* video hardware */ |
| 654 | MDRV_SCREEN_MODIFY("screen") |
| 655 | MDRV_SCREEN_VISIBLE_AREA(0, 240-1, 0, 128-1) |
| 656 | |
| 657 | MACHINE_DRIVER_END |
| 658 | |
| 659 | |
| 57 | 660 | /* ROM definition */ |
| 58 | 661 | ROM_START( ti89 ) |
| 59 | 662 | ROM_REGION( 0x200000, "maincpu", ROMREGION_ERASEFF ) |
| 60 | 663 | ROM_SYSTEM_BIOS( 0, "v100", "V 1.00 - HW1" ) |
| 61 | 664 | ROMX_LOAD( "ti89v100.rom", 0x000000, 0x200000, CRC(264b34ad) SHA1(c87586a7e9b6d49fbe908fbb6f3c0038f3498573), ROM_BIOS(1)) |
| 62 | | ROM_SYSTEM_BIOS( 1, "v100", "V 1.00 [a] - HW1" ) |
| 665 | ROM_SYSTEM_BIOS( 1, "v100a", "V 1.00 [a] - HW1" ) |
| 63 | 666 | ROMX_LOAD( "ti89v100a.rom", 0x000000, 0x200000, CRC(95199934) SHA1(b8e3cdeb4705b0c7e0a15ab6c6f62bcde14a3a55), ROM_BIOS(2)) |
| 64 | | ROM_SYSTEM_BIOS( 2, "v100", "V 1.00 [m] - HW1" ) |
| 667 | ROM_SYSTEM_BIOS( 2, "v100m", "V 1.00 [m] - HW1" ) |
| 65 | 668 | ROMX_LOAD( "ti89v100m.rom", 0x000000, 0x200000, CRC(b9059e06) SHA1(b33a7c2935eb9f73b210bcf6e7c7f32d1548a9d5), ROM_BIOS(3)) |
| 66 | | ROM_SYSTEM_BIOS( 3, "v100", "V 1.00 [m2] - HW1" ) |
| 669 | ROM_SYSTEM_BIOS( 3, "v100m2", "V 1.00 [m2] - HW1" ) |
| 67 | 670 | ROMX_LOAD( "ti89v100m2.rom", 0x000000, 0x200000, CRC(cdd69d34) SHA1(1686362b0997bb9597f39b443490d4d8d85b56cc), ROM_BIOS(4)) |
| 68 | 671 | ROM_SYSTEM_BIOS( 4, "v105", "V 1.05 - HW1" ) |
| 69 | 672 | ROMX_LOAD( "ti89v105.rom", 0x000000, 0x200000, CRC(3bc0b474) SHA1(46fe0cd511eb81d53dc12cc4bdacec8a5bba5171), ROM_BIOS(5)) |
| r8081 | r8082 | |
| 92 | 695 | ROM_END |
| 93 | 696 | |
| 94 | 697 | ROM_START( ti92 ) |
| 95 | | ROM_REGION( 0x300000, "maincpu", ROMREGION_ERASEFF ) |
| 96 | | // Internal ROM |
| 97 | | ROM_LOAD( "ti92v111.rom", 0x000000, 0x100000, CRC(67878d52) SHA1(c0fdf162961922a76f286c93fd9b861ce20f23a3)) |
| 98 | | // External ROM |
| 99 | | ROM_SYSTEM_BIOS( 0, "v13", "V 1.3" ) |
| 100 | | ROMX_LOAD( "ti92v13e.rom", 0x100000, 0x100000, CRC(316c8196) SHA1(82c8cd484c6aebe36f814a2023d2afad6d87f840), ROM_BIOS(1)) |
| 101 | | ROM_SYSTEM_BIOS( 1, "v14", "V 1.4" ) |
| 102 | | ROMX_LOAD( "ti92v14e.rom", 0x100000, 0x100000, CRC(239e9405) SHA1(df2f1ab17d490fda43a02f5851b5a15052361b28), ROM_BIOS(2)) |
| 103 | | ROM_SYSTEM_BIOS( 2, "v17", "V 1.7" ) |
| 104 | | ROMX_LOAD( "ti92v17e.rom", 0x100000, 0x100000, CRC(83e27cc5) SHA1(aec5a6a6157ff94a4e665fa3fe747bacb6688cd4), ROM_BIOS(3)) |
| 105 | | ROM_SYSTEM_BIOS( 3, "v111", "V 1.11" ) |
| 106 | | ROMX_LOAD( "ti92v111e.rom", 0x100000, 0x100000, CRC(4a343833) SHA1(ab4eaacc8c83a861c8d37df5c10e532d0d580460), ROM_BIOS(4)) |
| 107 | | ROM_SYSTEM_BIOS( 4, "v112", "V 1.12" ) |
| 108 | | ROMX_LOAD( "ti92v112e.rom", 0x100000, 0x100000, CRC(9a6947a0) SHA1(8bb0538ca98711e9ad46c56e4dfd609d4699be30), ROM_BIOS(5)) |
| 109 | | ROM_SYSTEM_BIOS( 5, "v21", "V 2.1" ) |
| 110 | | ROMX_LOAD( "ti92v21e.rom", 0x100000, 0x200000, CRC(5afb5863) SHA1(bf7b260d37d1502cc4b08dea5e1d55b523f27925), ROM_BIOS(6)) |
| 698 | ROM_REGION( 0x200000, "maincpu", ROMREGION_ERASEFF ) |
| 699 | ROM_SYSTEM_BIOS( 0, "v111", "V 1.11" ) |
| 700 | ROMX_LOAD( "ti92v111.rom", 0x000000, 0x100000, CRC(67878d52) SHA1(c0fdf162961922a76f286c93fd9b861ce20f23a3), ROM_BIOS(1)) |
| 701 | ROM_SYSTEM_BIOS( 1, "v13", "V 1.3" ) |
| 702 | ROMX_LOAD( "ti92v13e.rom", 0x000000, 0x100000, CRC(316c8196) SHA1(82c8cd484c6aebe36f814a2023d2afad6d87f840), ROM_BIOS(2)) |
| 703 | ROM_SYSTEM_BIOS( 2, "v14", "V 1.4" ) |
| 704 | ROMX_LOAD( "ti92v14e.rom", 0x000000, 0x100000, CRC(239e9405) SHA1(df2f1ab17d490fda43a02f5851b5a15052361b28), ROM_BIOS(3)) |
| 705 | ROM_SYSTEM_BIOS( 3, "v17", "V 1.7" ) |
| 706 | ROMX_LOAD( "ti92v17e.rom", 0x000000, 0x100000, CRC(83e27cc5) SHA1(aec5a6a6157ff94a4e665fa3fe747bacb6688cd4), ROM_BIOS(4)) |
| 707 | ROM_SYSTEM_BIOS( 4, "v111", "V 1.11" ) |
| 708 | ROMX_LOAD( "ti92v111e.rom", 0x000000, 0x100000, CRC(4a343833) SHA1(ab4eaacc8c83a861c8d37df5c10e532d0d580460), ROM_BIOS(5)) |
| 709 | ROM_SYSTEM_BIOS( 5, "v112", "V 1.12" ) |
| 710 | ROMX_LOAD( "ti92v112e.rom", 0x000000, 0x100000, CRC(9a6947a0) SHA1(8bb0538ca98711e9ad46c56e4dfd609d4699be30), ROM_BIOS(6)) |
| 711 | ROM_SYSTEM_BIOS( 6, "v21", "V 2.1" ) |
| 712 | ROMX_LOAD( "ti92v21e.rom", 0x000000, 0x200000, CRC(5afb5863) SHA1(bf7b260d37d1502cc4b08dea5e1d55b523f27925), ROM_BIOS(7)) |
| 111 | 713 | |
| 112 | 714 | ROM_END |
| 113 | 715 | |
| r8081 | r8082 | |
| 140 | 742 | /* Driver */ |
| 141 | 743 | |
| 142 | 744 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 143 | | COMP( 1998, ti89, 0, 0, ti89, ti89, 0, "Texas Instruments", "TI-89", GAME_NOT_WORKING | GAME_NO_SOUND) |
| 144 | | COMP( 1995, ti92, 0, 0, ti89, ti89, 0, "Texas Instruments", "TI-92", GAME_NOT_WORKING | GAME_NO_SOUND) |
| 145 | | COMP( 1999, ti92p, 0, 0, ti89, ti89, 0, "Texas Instruments", "TI-92 Plus", GAME_NOT_WORKING | GAME_NO_SOUND) |
| 146 | | |
| 745 | COMP( 1998, ti89, 0, 0, ti89, ti8x, 0, "Texas Instruments", "TI-89", GAME_NO_SOUND) |
| 746 | COMP( 1995, ti92, 0, 0, ti92, ti9x, 0, "Texas Instruments", "TI-92", GAME_NO_SOUND) |
| 747 | COMP( 1999, ti92p, 0, 0, ti92p, ti9x, 0, "Texas Instruments", "TI-92 Plus", GAME_NO_SOUND) |
src/mess/drivers/ti99_4x.c
| r8081 | r8082 | |
| 8 | 8 | /* |
| 9 | 9 | TI99/4 info: |
| 10 | 10 | |
| 11 | | Similar to TI99/4a, except for the following: |
| 11 | Similar to TI99/4a, except for the following: |
| 12 | 12 | * tms9918/9928 has no bitmap mode |
| 13 | 13 | * smaller, 40-key keyboard |
| 14 | 14 | * many small differences in the contents of system ROMs |
| 15 | 15 | |
| 16 | | Historical notes: TI made several last minute design changes. |
| 16 | Historical notes: TI made several last minute design changes. |
| 17 | 17 | * TI99/4 prototypes had an extra port for an I/R joystick and keypad interface. |
| 18 | 18 | * early TI99/4 prototypes were designed for a tms9985, not a tms9900. |
| 19 | 19 | */ |
| r8081 | r8082 | |
| 47 | 47 | #include "devices/ti99_hd.h" |
| 48 | 48 | |
| 49 | 49 | /* |
| 50 | | memory map |
| 50 | Memory map |
| 51 | 51 | */ |
| 52 | 52 | |
| 53 | 53 | static ADDRESS_MAP_START(memmap, ADDRESS_SPACE_PROGRAM, 16) |
| r8081 | r8082 | |
| 90 | 90 | */ |
| 91 | 91 | |
| 92 | 92 | static ADDRESS_MAP_START(cru_map, ADDRESS_SPACE_IO, 8) |
| 93 | | AM_RANGE(0x0000, 0x007f) AM_DEVREAD("tms9901", tms9901_cru_r) |
| 94 | | AM_RANGE(0x0080, 0x00ff) AM_DEVREAD("ti99_multicart", ti99_multicart_cru_r) /* SuperSpace */ |
| 95 | | AM_RANGE(0x0100, 0x01ff) AM_READ(ti99_4x_peb_cru_r) |
| 93 | AM_RANGE(0x0000, 0x007f) AM_DEVREAD("tms9901", tms9901_cru_r) |
| 94 | AM_RANGE(0x0080, 0x00ff) AM_DEVREAD("ti99_multicart", ti99_multicart_cru_r) /* SuperSpace */ |
| 95 | AM_RANGE(0x0100, 0x01ff) AM_READ(ti99_4x_peb_cru_r) |
| 96 | 96 | |
| 97 | 97 | AM_RANGE(0x0000, 0x03ff) AM_DEVWRITE("tms9901", tms9901_cru_w) |
| 98 | | AM_RANGE(0x0400, 0x07ff) AM_DEVWRITE("ti99_multicart", ti99_multicart_cru_w) /* SuperSpace */ |
| 99 | | AM_RANGE(0x0800, 0x0fff) AM_WRITE(ti99_4x_peb_cru_w) |
| 98 | AM_RANGE(0x0400, 0x07ff) AM_DEVWRITE("ti99_multicart", ti99_multicart_cru_w) /* SuperSpace */ |
| 99 | AM_RANGE(0x0800, 0x0fff) AM_WRITE(ti99_4x_peb_cru_w) |
| 100 | 100 | ADDRESS_MAP_END |
| 101 | 101 | |
| 102 | 102 | /* |
| r8081 | r8082 | |
| 157 | 157 | PORT_CONFSETTING( 0x01, "Mechatronics Mouse" ) |
| 158 | 158 | |
| 159 | 159 | PORT_START( "CARTSLOT" ) |
| 160 | | PORT_CONFNAME( 0x07, 0x00, "Cartridge slot" ) |
| 161 | | PORT_CONFSETTING( 0x00, "Auto" ) |
| 162 | | PORT_CONFSETTING( 0x01, "Slot 1" ) |
| 163 | | PORT_CONFSETTING( 0x02, "Slot 2" ) |
| 164 | | PORT_CONFSETTING( 0x03, "Slot 3" ) |
| 165 | | PORT_CONFSETTING( 0x04, "Slot 4" ) |
| 166 | | // PORT_CONFSETTING( 0x05, "GRAM Kracker" ) |
| 160 | PORT_DIPNAME( 0x07, 0x00, "Cartridge slot" ) |
| 161 | PORT_DIPSETTING( 0x00, "Auto" ) |
| 162 | PORT_DIPSETTING( 0x01, "Slot 1" ) |
| 163 | PORT_DIPSETTING( 0x02, "Slot 2" ) |
| 164 | PORT_DIPSETTING( 0x03, "Slot 3" ) |
| 165 | PORT_DIPSETTING( 0x04, "Slot 4" ) |
| 166 | // PORT_DIPSETTING( 0x05, "GRAM Kracker" ) |
| 167 | 167 | |
| 168 | 168 | PORT_START( "HFDCDIP" ) |
| 169 | 169 | PORT_DIPNAME( 0xff, 0x55, "HFDC drive config" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 ) |
| r8081 | r8082 | |
| 192 | 192 | /* 4 ports for keyboard and joystick */ |
| 193 | 193 | PORT_START("KEY0") /* col 0 */ |
| 194 | 194 | PORT_BIT(0x0088, IP_ACTIVE_LOW, IPT_UNUSED) |
| 195 | | /* The original control key is located on the left, but we accept the |
| 196 | | right control key as well */ |
| 195 | /* The original control key is located on the left, but we accept the right control key as well */ |
| 197 | 196 | PORT_BIT(0x0040, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) |
| 198 | 197 | /* TI99/4a has a second shift key which maps the same */ |
| 199 | 198 | PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 200 | | /* The original function key is located on the right, but we accept the |
| 201 | | left alt key as well */ |
| 199 | /* The original function key is located on the right, but we accept the left alt key as well */ |
| 202 | 200 | PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("FCTN") PORT_CODE(KEYCODE_RALT) PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_SHIFT_2) |
| 203 | 201 | PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) |
| 204 | 202 | PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| r8081 | r8082 | |
| 333 | 331 | PORT_CONFSETTING( 0x04, DEF_STR( On ) ) |
| 334 | 332 | |
| 335 | 333 | PORT_START( "CARTSLOT" ) |
| 336 | | PORT_CONFNAME( 0x07, 0x00, "Cartridge slot" ) |
| 337 | | PORT_CONFSETTING( 0x00, "Auto" ) |
| 338 | | PORT_CONFSETTING( 0x01, "Slot 1" ) |
| 339 | | PORT_CONFSETTING( 0x02, "Slot 2" ) |
| 340 | | PORT_CONFSETTING( 0x03, "Slot 3" ) |
| 341 | | PORT_CONFSETTING( 0x04, "Slot 4" ) |
| 342 | | // PORT_CONFSETTING( 0x05, "GRAM Kracker" ) |
| 334 | PORT_DIPNAME( 0x07, 0x00, "Cartridge slot" ) |
| 335 | PORT_DIPSETTING( 0x00, "Auto" ) |
| 336 | PORT_DIPSETTING( 0x01, "Slot 1" ) |
| 337 | PORT_DIPSETTING( 0x02, "Slot 2" ) |
| 338 | PORT_DIPSETTING( 0x03, "Slot 3" ) |
| 339 | PORT_DIPSETTING( 0x04, "Slot 4" ) |
| 340 | // PORT_DIPSETTING( 0x05, "GRAM Kracker" ) |
| 343 | 341 | |
| 344 | 342 | PORT_START( "HFDCDIP" ) |
| 345 | 343 | PORT_DIPNAME( 0xff, 0x55, "HFDC drive config" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 ) |
| r8081 | r8082 | |
| 642 | 640 | |
| 643 | 641 | |
| 644 | 642 | /* |
| 645 | | TMS0285 speech synthesizer |
| 643 | TMS5220 speech synthesizer |
| 644 | Note that in the real hardware, the predecessor TMC0285 was used. |
| 646 | 645 | */ |
| 647 | 646 | static const tms5220_interface ti99_4x_tms5220interface = |
| 648 | 647 | { |
| r8081 | r8082 | |
| 697 | 696 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) |
| 698 | 697 | MDRV_SOUND_ADD("sn76496", SN94624, 3579545/8) /* 3.579545 MHz */ |
| 699 | 698 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 700 | | MDRV_SOUND_ADD("tms5220", TMS5220, 680000L) |
| 699 | MDRV_SOUND_ADD("tmc0285", TMC0285, 680000L) |
| 701 | 700 | MDRV_SOUND_CONFIG(ti99_4x_tms5220interface) |
| 702 | 701 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 703 | 702 | |
| r8081 | r8082 | |
| 749 | 748 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 750 | 749 | MDRV_SOUND_ADD("sn76496", SN94624, 3579545/8) /* 3.579545 MHz */ |
| 751 | 750 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 752 | | MDRV_SOUND_ADD("tms5220", TMS5220, 680000L) |
| 751 | MDRV_SOUND_ADD("tmc0285", TMC0285, 680000L) |
| 753 | 752 | MDRV_SOUND_CONFIG(ti99_4x_tms5220interface) |
| 754 | 753 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 755 | 754 | MDRV_SOUND_WAVE_ADD("wave.1", "cassette1") |
| r8081 | r8082 | |
| 803 | 802 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 804 | 803 | MDRV_SOUND_ADD("sn76496", SN94624, 3579545/8) /* 3.579545 MHz SN94624N */ |
| 805 | 804 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 806 | | MDRV_SOUND_ADD("tms5220", TMS5220, 680000L) |
| 805 | MDRV_SOUND_ADD("tmc0285", TMC0285, 680000L) |
| 807 | 806 | MDRV_SOUND_CONFIG(ti99_4x_tms5220interface) |
| 808 | 807 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 809 | 808 | MDRV_SOUND_WAVE_ADD("wave.1", "cassette1") |
| r8081 | r8082 | |
| 859 | 858 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 860 | 859 | MDRV_SOUND_ADD("sn76496", SN94624, 3579545/8) /* 3.579545 MHz */ |
| 861 | 860 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 862 | | MDRV_SOUND_ADD("tms5220", TMS5220, 680000L) |
| 861 | MDRV_SOUND_ADD("tmc0285", TMC0285, 680000L) |
| 863 | 862 | MDRV_SOUND_CONFIG(ti99_4x_tms5220interface) |
| 864 | 863 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 865 | 864 | MDRV_SOUND_WAVE_ADD("wave.1", "cassette1") |
| r8081 | r8082 | |
| 922 | 921 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 923 | 922 | MDRV_SOUND_ADD("sn76496", SN94624, 3579545/8) /* 3.579545 MHz */ |
| 924 | 923 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) |
| 925 | | MDRV_SOUND_ADD("tms5220", TMS5220, 680000L) |
| 924 | MDRV_SOUND_ADD("tmc0285", TMC0285, 680000L) |
| 926 | 925 | MDRV_SOUND_CONFIG(ti99_4x_tms5220interface) |
| 927 | 926 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 928 | 927 | MDRV_SOUND_WAVE_ADD("wave.1", "cassette1") |
| r8081 | r8082 | |
| 956 | 955 | |
| 957 | 956 | /* |
| 958 | 957 | ROM loading |
| 959 | | |
| 960 | 958 | Note that we use the same ROMset for 50Hz and 60Hz versions. |
| 961 | 959 | */ |
| 962 | 960 | |