src/mess/machine/amstrad.c
| r12469 | r12470 | |
| 42 | 42 | #include "machine/upd765.h" |
| 43 | 43 | #include "machine/ctronics.h" |
| 44 | 44 | #include "machine/cpc_rom.h" |
| 45 | #include "machine/mface2.h" |
| 45 | 46 | #include "imagedev/cassette.h" |
| 46 | 47 | #include "imagedev/snapquik.h" |
| 47 | 48 | #include "includes/amstrad.h" |
| r12469 | r12470 | |
| 1100 | 1101 | NULL |
| 1101 | 1102 | }; |
| 1102 | 1103 | |
| 1103 | | |
| 1104 | | /****************************************************************************************** |
| 1105 | | Multiface emulation |
| 1106 | | ****************************************************************************************/ |
| 1107 | | |
| 1108 | | |
| 1109 | | /* stop button has been pressed */ |
| 1110 | | #define MULTIFACE_STOP_BUTTON_PRESSED 0x0001 |
| 1111 | | /* ram/rom is paged into memory space */ |
| 1112 | | #define MULTIFACE_RAM_ROM_ENABLED 0x0002 |
| 1113 | | /* when visible OUT commands are performed! */ |
| 1114 | | #define MULTIFACE_VISIBLE 0x0004 |
| 1115 | | |
| 1116 | | /* multiface traps calls to 0x0065 when it is active. |
| 1117 | | This address has a RET and so executes no code. |
| 1118 | | |
| 1119 | | It is believed that it is used to make multiface invisible to programs */ |
| 1120 | | |
| 1121 | | /*#define MULTIFACE_0065_TOGGLE 0x0008*/ |
| 1122 | | |
| 1123 | | DIRECT_UPDATE_HANDLER( amstrad_default ) |
| 1104 | WRITE_LINE_DEVICE_HANDLER(cpc_romdis) |
| 1124 | 1105 | { |
| 1125 | | return address; |
| 1126 | | } |
| 1106 | amstrad_state *tstate = device->machine().driver_data<amstrad_state>(); |
| 1127 | 1107 | |
| 1128 | | /* used to setup computer if a snapshot was specified */ |
| 1129 | | DIRECT_UPDATE_HANDLER( amstrad_multiface_directoverride ) |
| 1130 | | { |
| 1131 | | amstrad_state *state = machine.driver_data<amstrad_state>(); |
| 1132 | | int pc; |
| 1133 | | |
| 1134 | | pc = cpu_get_pc(machine.device("maincpu")); |
| 1135 | | |
| 1136 | | /* there are two places where CALL &0065 can be found |
| 1137 | | in the multiface rom. At this address there is a RET. |
| 1138 | | |
| 1139 | | To disable the multiface from being detected, the multiface |
| 1140 | | stop button must be pressed, then the program that was stopped |
| 1141 | | must be returned to. When this is done, the multiface cannot |
| 1142 | | be detected and the out operations to page the multiface |
| 1143 | | ram/rom into the address space will not work! */ |
| 1144 | | |
| 1145 | | /* I assume that the hardware in the multiface detects |
| 1146 | | the PC set to 0x065 and uses this to enable/disable the multiface |
| 1147 | | */ |
| 1148 | | |
| 1149 | | /* I also use this to allow the stop button to be pressed again */ |
| 1150 | | if (pc==0x0164) |
| 1151 | | { |
| 1152 | | /* first call? */ |
| 1153 | | state->m_multiface_flags |= MULTIFACE_VISIBLE; |
| 1154 | | } |
| 1155 | | else if (pc==0x0c98) |
| 1156 | | { |
| 1157 | | /* second call */ |
| 1158 | | |
| 1159 | | /* no longer visible */ |
| 1160 | | state->m_multiface_flags &= ~(MULTIFACE_VISIBLE|MULTIFACE_STOP_BUTTON_PRESSED); |
| 1161 | | |
| 1162 | | /* clear op base override */ |
| 1163 | | machine.device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(direct_update_delegate(FUNC(amstrad_default), &machine)); |
| 1164 | | } |
| 1165 | | |
| 1166 | | return pc; |
| 1108 | tstate->m_gate_array.romdis = state; |
| 1109 | amstrad_rethinkMemory(device->machine()); |
| 1167 | 1110 | } |
| 1168 | 1111 | |
| 1169 | | static void multiface_init(running_machine &machine) |
| 1112 | WRITE_LINE_DEVICE_HANDLER(cpc_romen) |
| 1170 | 1113 | { |
| 1171 | | amstrad_state *state = machine.driver_data<amstrad_state>(); |
| 1172 | | /* after a reset the multiface is visible */ |
| 1173 | | state->m_multiface_flags = MULTIFACE_VISIBLE; |
| 1114 | amstrad_state *tstate = device->machine().driver_data<amstrad_state>(); |
| 1174 | 1115 | |
| 1175 | | /* allocate ram */ |
| 1176 | | state->m_multiface_ram = auto_alloc_array(machine, UINT8, 8192); |
| 1116 | if(state != 0) |
| 1117 | tstate->m_gate_array.mrer &= ~0x04; |
| 1118 | else |
| 1119 | tstate->m_gate_array.mrer |= 0x04; |
| 1120 | amstrad_rethinkMemory(device->machine()); |
| 1177 | 1121 | } |
| 1178 | 1122 | |
| 1179 | | /* call when a system reset is done */ |
| 1180 | | static void multiface_reset(amstrad_state *state) |
| 1181 | | { |
| 1182 | | /* stop button not pressed and ram/rom disabled */ |
| 1183 | | state->m_multiface_flags &= ~(MULTIFACE_STOP_BUTTON_PRESSED | |
| 1184 | | MULTIFACE_RAM_ROM_ENABLED); |
| 1185 | | /* as on the real hardware the multiface is visible after a reset! */ |
| 1186 | | state->m_multiface_flags |= MULTIFACE_VISIBLE; |
| 1187 | | } |
| 1188 | 1123 | |
| 1189 | | static int multiface_hardware_enabled(running_machine &machine) |
| 1190 | | { |
| 1191 | | amstrad_state *state = machine.driver_data<amstrad_state>(); |
| 1192 | | if (state->m_multiface_ram!=NULL) |
| 1193 | | { |
| 1194 | | if ((input_port_read(machine, "multiface") & 0x01)!=0) |
| 1195 | | { |
| 1196 | | return 1; |
| 1197 | | } |
| 1198 | | } |
| 1199 | | |
| 1200 | | return 0; |
| 1201 | | } |
| 1202 | | |
| 1203 | | |
| 1204 | | static void multiface_rethink_memory(running_machine &machine) |
| 1205 | | { |
| 1206 | | amstrad_state *state = machine.driver_data<amstrad_state>(); |
| 1207 | | unsigned char *multiface_rom; |
| 1208 | | |
| 1209 | | /* multiface hardware enabled? */ |
| 1210 | | if (!multiface_hardware_enabled(machine)) |
| 1211 | | return; |
| 1212 | | |
| 1213 | | multiface_rom = &machine.region("maincpu")->base()[0x01C000]; |
| 1214 | | |
| 1215 | | if ( |
| 1216 | | ((state->m_multiface_flags & MULTIFACE_RAM_ROM_ENABLED)!=0) && |
| 1217 | | ((state->m_gate_array.mrer & 0x04) == 0) |
| 1218 | | ) |
| 1219 | | { |
| 1220 | | |
| 1221 | | /* set bank addressess */ |
| 1222 | | memory_set_bankptr(machine,"bank1", multiface_rom); |
| 1223 | | memory_set_bankptr(machine,"bank2", state->m_multiface_ram); |
| 1224 | | memory_set_bankptr(machine,"bank9", multiface_rom); |
| 1225 | | memory_set_bankptr(machine,"bank10", state->m_multiface_ram); |
| 1226 | | } |
| 1227 | | } |
| 1228 | | |
| 1229 | | |
| 1230 | | /* simulate the stop button has been pressed */ |
| 1231 | | static void multiface_stop(running_machine &machine) |
| 1232 | | { |
| 1233 | | amstrad_state *state = machine.driver_data<amstrad_state>(); |
| 1234 | | /* multiface hardware enabled? */ |
| 1235 | | if (!multiface_hardware_enabled(machine)) |
| 1236 | | return; |
| 1237 | | |
| 1238 | | /* if stop button not already pressed, do press action */ |
| 1239 | | /* pressing stop button while multiface is running has no effect */ |
| 1240 | | if ((state->m_multiface_flags & MULTIFACE_STOP_BUTTON_PRESSED)==0) |
| 1241 | | { |
| 1242 | | /* initialise 0065 toggle */ |
| 1243 | | /*state->m_multiface_flags &= ~MULTIFACE_0065_TOGGLE;*/ |
| 1244 | | |
| 1245 | | state->m_multiface_flags |= MULTIFACE_RAM_ROM_ENABLED; |
| 1246 | | |
| 1247 | | /* stop button has been pressed, furthur pressess will not issue a NMI */ |
| 1248 | | state->m_multiface_flags |= MULTIFACE_STOP_BUTTON_PRESSED; |
| 1249 | | |
| 1250 | | state->m_gate_array.mrer &=~0x04; |
| 1251 | | |
| 1252 | | /* page rom into memory */ |
| 1253 | | multiface_rethink_memory(machine); |
| 1254 | | |
| 1255 | | /* pulse the nmi line */ |
| 1256 | | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); |
| 1257 | | |
| 1258 | | /* initialise 0065 override to monitor calls to 0065 */ |
| 1259 | | machine.device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(direct_update_delegate(FUNC(amstrad_multiface_directoverride), &machine)); |
| 1260 | | } |
| 1261 | | |
| 1262 | | } |
| 1263 | | |
| 1264 | | |
| 1265 | | /* any io writes are passed through here */ |
| 1266 | | static WRITE8_HANDLER(multiface_io_write) |
| 1267 | | { |
| 1268 | | amstrad_state *state = space->machine().driver_data<amstrad_state>(); |
| 1269 | | /* multiface hardware enabled? */ |
| 1270 | | if (!multiface_hardware_enabled(space->machine())) |
| 1271 | | return; |
| 1272 | | |
| 1273 | | /* visible? */ |
| 1274 | | if (state->m_multiface_flags & MULTIFACE_VISIBLE) |
| 1275 | | { |
| 1276 | | if (offset==0x0fee8) |
| 1277 | | { |
| 1278 | | state->m_multiface_flags |= MULTIFACE_RAM_ROM_ENABLED; |
| 1279 | | amstrad_rethinkMemory(space->machine()); |
| 1280 | | } |
| 1281 | | |
| 1282 | | if (offset==0x0feea) |
| 1283 | | { |
| 1284 | | state->m_multiface_flags &= ~MULTIFACE_RAM_ROM_ENABLED; |
| 1285 | | amstrad_rethinkMemory(space->machine()); |
| 1286 | | } |
| 1287 | | } |
| 1288 | | |
| 1289 | | /* update multiface ram with data */ |
| 1290 | | /* these are decoded fully! */ |
| 1291 | | switch ((offset>>8) & 0x0ff) |
| 1292 | | { |
| 1293 | | /* gate array */ |
| 1294 | | case 0x07f: |
| 1295 | | { |
| 1296 | | switch (data & 0x0c0) |
| 1297 | | { |
| 1298 | | /* pen index */ |
| 1299 | | case 0x00: |
| 1300 | | { |
| 1301 | | state->m_multiface_ram[0x01fcf] = data; |
| 1302 | | |
| 1303 | | } |
| 1304 | | break; |
| 1305 | | |
| 1306 | | /* pen colour */ |
| 1307 | | case 0x040: |
| 1308 | | { |
| 1309 | | int pen_index; |
| 1310 | | |
| 1311 | | pen_index = state->m_multiface_ram[0x01fcf] & 0x0f; |
| 1312 | | |
| 1313 | | if (state->m_multiface_ram[0x01fcf] & 0x010) |
| 1314 | | { |
| 1315 | | |
| 1316 | | state->m_multiface_ram[0x01fdf + pen_index] = data; |
| 1317 | | } |
| 1318 | | else |
| 1319 | | { |
| 1320 | | state->m_multiface_ram[0x01f90 + pen_index] = data & 0x01f; |
| 1321 | | } |
| 1322 | | |
| 1323 | | } |
| 1324 | | break; |
| 1325 | | |
| 1326 | | /* rom/mode selection */ |
| 1327 | | case 0x080: |
| 1328 | | { |
| 1329 | | |
| 1330 | | state->m_multiface_ram[0x01fef] = data; |
| 1331 | | |
| 1332 | | } |
| 1333 | | break; |
| 1334 | | |
| 1335 | | /* ram configuration */ |
| 1336 | | case 0x0c0: |
| 1337 | | { |
| 1338 | | |
| 1339 | | state->m_multiface_ram[0x01fff] = data; |
| 1340 | | |
| 1341 | | } |
| 1342 | | break; |
| 1343 | | |
| 1344 | | default: |
| 1345 | | break; |
| 1346 | | |
| 1347 | | } |
| 1348 | | |
| 1349 | | } |
| 1350 | | break; |
| 1351 | | |
| 1352 | | |
| 1353 | | /* crtc register index */ |
| 1354 | | case 0x0bc: |
| 1355 | | { |
| 1356 | | state->m_multiface_ram[0x01cff] = data; |
| 1357 | | } |
| 1358 | | break; |
| 1359 | | |
| 1360 | | /* crtc register write */ |
| 1361 | | case 0x0bd: |
| 1362 | | { |
| 1363 | | int reg_index; |
| 1364 | | |
| 1365 | | reg_index = state->m_multiface_ram[0x01cff] & 0x0f; |
| 1366 | | |
| 1367 | | state->m_multiface_ram[0x01db0 + reg_index] = data; |
| 1368 | | } |
| 1369 | | break; |
| 1370 | | |
| 1371 | | |
| 1372 | | /* 8255 ppi control */ |
| 1373 | | case 0x0f7: |
| 1374 | | { |
| 1375 | | state->m_multiface_ram[0x017ff] = data; |
| 1376 | | |
| 1377 | | } |
| 1378 | | break; |
| 1379 | | |
| 1380 | | /* rom select */ |
| 1381 | | case 0x0df: |
| 1382 | | { |
| 1383 | | state->m_multiface_ram[0x01aac] = data; |
| 1384 | | } |
| 1385 | | break; |
| 1386 | | |
| 1387 | | default: |
| 1388 | | break; |
| 1389 | | |
| 1390 | | } |
| 1391 | | |
| 1392 | | } |
| 1393 | | |
| 1394 | | |
| 1395 | 1124 | /*-------------------------- |
| 1396 | 1125 | - Ram and Rom management - |
| 1397 | 1126 | --------------------------*/ |
| r12469 | r12470 | |
| 1406 | 1135 | /* b2 : "1" Lower rom area disable or "0" Lower rom area enable */ |
| 1407 | 1136 | if ( state->m_system_type == SYSTEM_CPC || state->m_system_type == SYSTEM_ALESTE ) |
| 1408 | 1137 | { |
| 1409 | | if ((state->m_gate_array.mrer & (1<<2)) == 0) |
| 1138 | if ((state->m_gate_array.mrer & (1<<2)) == 0 && state->m_gate_array.romdis == 0) |
| 1410 | 1139 | { |
| 1411 | 1140 | bank_base = &machine.region("maincpu")->base()[0x010000]; |
| 1412 | 1141 | } |
| r12469 | r12470 | |
| 1449 | 1178 | memory_set_bankptr(machine,"bank6", state->m_AmstradCPC_RamBanks[2]+0x2000); |
| 1450 | 1179 | } |
| 1451 | 1180 | |
| 1452 | | if ( (state->m_gate_array.mrer & (1<<2)) == 0) |
| 1181 | if ( (state->m_gate_array.mrer & (1<<2)) == 0 && state->m_gate_array.romdis == 0) |
| 1453 | 1182 | { // ASIC secondary lower ROM selection (bit 5: 1 = enabled) |
| 1454 | 1183 | if ( state->m_asic.enabled ) |
| 1455 | 1184 | { |
| r12469 | r12470 | |
| 1498 | 1227 | UINT8 *bank_base = NULL; |
| 1499 | 1228 | |
| 1500 | 1229 | /* b3 : "1" Upper rom area disable or "0" Upper rom area enable */ |
| 1501 | | if ( ! ( state->m_gate_array.mrer & 0x08 ) ) |
| 1230 | if ( ! ( state->m_gate_array.mrer & 0x08 ) && state->m_gate_array.romdis == 0) |
| 1502 | 1231 | { |
| 1503 | 1232 | bank_base = state->m_Amstrad_ROM_Table[ state->m_gate_array.upper_bank ]; |
| 1504 | 1233 | } |
| r12469 | r12470 | |
| 2210 | 1939 | amstrad_state *state = space->machine().driver_data<amstrad_state>(); |
| 2211 | 1940 | device_t *fdc = space->machine().device("upd765"); |
| 2212 | 1941 | mc6845_device *mc6845 = space->machine().device<mc6845_device>("mc6845"); |
| 1942 | cpc_multiface2_device* mface2; |
| 2213 | 1943 | |
| 2214 | 1944 | if ((offset & (1<<15)) == 0) |
| 2215 | 1945 | { |
| r12469 | r12470 | |
| 2367 | 2097 | mc6845->set_clock( ( state->m_aleste_mode & 0x02 ) ? ( XTAL_16MHz / 8 ) : ( XTAL_16MHz / 16 ) ); |
| 2368 | 2098 | } |
| 2369 | 2099 | |
| 2370 | | multiface_io_write(space, offset, data); |
| 2100 | mface2 = space->machine().device<cpc_multiface2_device>("exp:multiface2"); |
| 2101 | if(mface2 != NULL) |
| 2102 | { |
| 2103 | if(mface2->multiface_io_write(offset, data) != 0) |
| 2104 | amstrad_rethinkMemory(space->machine()); |
| 2105 | } |
| 2371 | 2106 | } |
| 2372 | 2107 | |
| 2373 | 2108 | |
| r12469 | r12470 | |
| 2529 | 2264 | |
| 2530 | 2265 | if ( state->m_system_type == SYSTEM_PLUS || state->m_system_type == SYSTEM_GX4000 ) |
| 2531 | 2266 | memset(state->m_asic.ram,0,16384); // clear ASIC RAM |
| 2532 | | |
| 2533 | | multiface_reset(state); |
| 2534 | 2267 | } |
| 2535 | 2268 | |
| 2536 | 2269 | |
| r12469 | r12470 | |
| 2540 | 2273 | static void amstrad_rethinkMemory(running_machine &machine) |
| 2541 | 2274 | { |
| 2542 | 2275 | amstrad_state *state = machine.driver_data<amstrad_state>(); |
| 2276 | cpc_multiface2_device* mface2; |
| 2543 | 2277 | /* the following is used for banked memory read/writes and for setting up |
| 2544 | 2278 | * opcode and opcode argument reads */ |
| 2545 | 2279 | |
| r12469 | r12470 | |
| 2597 | 2331 | } |
| 2598 | 2332 | |
| 2599 | 2333 | /* multiface hardware enabled? */ |
| 2600 | | if (multiface_hardware_enabled(machine)) |
| 2334 | mface2 = machine.device<cpc_multiface2_device>("exp:multiface2"); |
| 2335 | if(mface2 != NULL) |
| 2601 | 2336 | { |
| 2602 | | multiface_rethink_memory(machine); |
| 2337 | if (mface2->multiface_hardware_enabled()) |
| 2338 | { |
| 2339 | if((state->m_gate_array.mrer & 0x04) == 0) |
| 2340 | mface2->multiface_rethink_memory(); |
| 2341 | } |
| 2603 | 2342 | } |
| 2604 | 2343 | } |
| 2605 | 2344 | |
| r12469 | r12470 | |
| 2616 | 2355 | |
| 2617 | 2356 | SCREEN_EOF( amstrad ) |
| 2618 | 2357 | { |
| 2619 | | if (input_port_read_safe(machine, "multiface", 0) & 0x02) |
| 2358 | cpc_multiface2_device* mface2 = machine.device<cpc_multiface2_device>("exp:multiface2"); |
| 2359 | if(mface2 != NULL) |
| 2620 | 2360 | { |
| 2621 | | multiface_stop(machine); |
| 2361 | mface2->check_button_state(); |
| 2622 | 2362 | } |
| 2623 | 2363 | } |
| 2624 | 2364 | |
| r12469 | r12470 | |
| 3138 | 2878 | MACHINE_START( amstrad ) |
| 3139 | 2879 | { |
| 3140 | 2880 | amstrad_state *state = machine.driver_data<amstrad_state>(); |
| 3141 | | multiface_init(machine); |
| 3142 | 2881 | state->m_system_type = SYSTEM_CPC; |
| 3143 | 2882 | } |
| 3144 | 2883 | |
| r12469 | r12470 | |
| 3264 | 3003 | MACHINE_START( kccomp ) |
| 3265 | 3004 | { |
| 3266 | 3005 | amstrad_state *state = machine.driver_data<amstrad_state>(); |
| 3267 | | multiface_init(machine); |
| 3268 | 3006 | state->m_system_type = SYSTEM_CPC; |
| 3269 | 3007 | } |
| 3270 | 3008 | |
| r12469 | r12470 | |
| 3296 | 3034 | MACHINE_START( aleste ) |
| 3297 | 3035 | { |
| 3298 | 3036 | amstrad_state *state = machine.driver_data<amstrad_state>(); |
| 3299 | | multiface_init(machine); |
| 3300 | 3037 | state->m_system_type = SYSTEM_ALESTE; |
| 3301 | 3038 | } |
| 3302 | 3039 | |
src/mess/machine/mface2.c
| r0 | r12470 | |
| 1 | /* |
| 2 | * mface2.c -- Romantic Robot Multiface II expansion device for the Amstrad CPC/CPC+ |
| 3 | * |
| 4 | * Created on: 31/07/2011 |
| 5 | */ |
| 6 | |
| 7 | #include "emu.h" |
| 8 | #include "machine/mface2.h" |
| 9 | |
| 10 | //************************************************************************** |
| 11 | // DEVICE DEFINITIONS |
| 12 | //************************************************************************** |
| 13 | |
| 14 | const device_type CPC_MFACE2 = &device_creator<cpc_multiface2_device>; |
| 15 | |
| 16 | |
| 17 | DIRECT_UPDATE_MEMBER( cpc_multiface2_device::amstrad_default ) |
| 18 | { |
| 19 | return address; |
| 20 | } |
| 21 | |
| 22 | /* used to setup computer if a snapshot was specified */ |
| 23 | DIRECT_UPDATE_MEMBER( cpc_multiface2_device::amstrad_multiface_directoverride ) |
| 24 | { |
| 25 | int pc; |
| 26 | |
| 27 | pc = cpu_get_pc(machine().device("maincpu")); |
| 28 | /* there are two places where CALL &0065 can be found |
| 29 | in the multiface rom. At this address there is a RET. |
| 30 | |
| 31 | To disable the multiface from being detected, the multiface |
| 32 | stop button must be pressed, then the program that was stopped |
| 33 | must be returned to. When this is done, the multiface cannot |
| 34 | be detected and the out operations to page the multiface |
| 35 | ram/rom into the address space will not work! */ |
| 36 | |
| 37 | /* I assume that the hardware in the multiface detects |
| 38 | the PC set to 0x065 and uses this to enable/disable the multiface |
| 39 | */ |
| 40 | |
| 41 | /* I also use this to allow the stop button to be pressed again */ |
| 42 | if (pc==0x0164) |
| 43 | { |
| 44 | /* first call? */ |
| 45 | m_multiface_flags |= MULTIFACE_VISIBLE; |
| 46 | } |
| 47 | else if (pc==0x0c98) |
| 48 | { |
| 49 | /* second call */ |
| 50 | |
| 51 | /* no longer visible */ |
| 52 | m_multiface_flags &= ~(MULTIFACE_VISIBLE|MULTIFACE_STOP_BUTTON_PRESSED); |
| 53 | |
| 54 | m_romdis=0; |
| 55 | m_slot->romen_w(0); |
| 56 | |
| 57 | /* clear op base override */ |
| 58 | machine().device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(direct_update_delegate(FUNC(cpc_multiface2_device::amstrad_default),this)); |
| 59 | popmessage("DIRECT_UPDATE set to default"); |
| 60 | } |
| 61 | |
| 62 | return pc; |
| 63 | } |
| 64 | |
| 65 | int cpc_multiface2_device::multiface_hardware_enabled() |
| 66 | { |
| 67 | if (m_multiface_ram!=NULL) |
| 68 | { |
| 69 | if ((input_port_read(machine(), "exp:multiface2:multiface") & 0x01)!=0) |
| 70 | { |
| 71 | return 1; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | /* multiface traps calls to 0x0065 when it is active. |
| 79 | This address has a RET and so executes no code. |
| 80 | |
| 81 | It is believed that it is used to make multiface invisible to programs */ |
| 82 | |
| 83 | /*#define MULTIFACE_0065_TOGGLE 0x0008*/ |
| 84 | |
| 85 | |
| 86 | void cpc_multiface2_device::multiface_rethink_memory() |
| 87 | { |
| 88 | unsigned char *multiface_rom; |
| 89 | |
| 90 | /* multiface hardware enabled? */ |
| 91 | if (!multiface_hardware_enabled()) |
| 92 | return; |
| 93 | |
| 94 | multiface_rom = machine().region("exp:multiface2:multiface")->base(); |
| 95 | |
| 96 | if ((m_multiface_flags & MULTIFACE_RAM_ROM_ENABLED)!=0 && m_romdis != 0) |
| 97 | { |
| 98 | /* set bank addressess */ |
| 99 | memory_set_bankptr(machine(),"bank1", multiface_rom); |
| 100 | memory_set_bankptr(machine(),"bank2", m_multiface_ram); |
| 101 | memory_set_bankptr(machine(),"bank9", multiface_rom); |
| 102 | memory_set_bankptr(machine(),"bank10", m_multiface_ram); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | void cpc_multiface2_device::check_button_state() |
| 107 | { |
| 108 | if(!multiface_hardware_enabled()) |
| 109 | return; |
| 110 | // TODO: reset button |
| 111 | if (input_port_read(machine(), "exp:multiface2:multiface") & 0x02) |
| 112 | { |
| 113 | multiface_stop(); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | /* simulate the stop button has been pressed */ |
| 118 | void cpc_multiface2_device::multiface_stop() |
| 119 | { |
| 120 | /* multiface hardware enabled? */ |
| 121 | if (!multiface_hardware_enabled()) |
| 122 | return; |
| 123 | |
| 124 | /* if stop button not already pressed, do press action */ |
| 125 | /* pressing stop button while multiface is running has no effect */ |
| 126 | if ((m_multiface_flags & MULTIFACE_STOP_BUTTON_PRESSED)==0) |
| 127 | { |
| 128 | /* initialise 0065 toggle */ |
| 129 | /*state->m_multiface_flags &= ~MULTIFACE_0065_TOGGLE;*/ |
| 130 | |
| 131 | m_multiface_flags |= MULTIFACE_RAM_ROM_ENABLED; |
| 132 | |
| 133 | /* stop button has been pressed, furthur pressess will not issue a NMI */ |
| 134 | m_multiface_flags |= MULTIFACE_STOP_BUTTON_PRESSED; |
| 135 | |
| 136 | m_romdis = 1; |
| 137 | m_slot->romen_w(1); |
| 138 | |
| 139 | /* page rom into memory */ |
| 140 | multiface_rethink_memory(); |
| 141 | |
| 142 | /* pulse the nmi line */ |
| 143 | m_slot->nmi_w(PULSE_LINE); |
| 144 | |
| 145 | /* initialise 0065 override to monitor calls to 0065 */ |
| 146 | machine().device("maincpu")->memory().space(AS_PROGRAM)->set_direct_update_handler(direct_update_delegate(FUNC(cpc_multiface2_device::amstrad_multiface_directoverride),this)); |
| 147 | popmessage("DIRECT_UPDATE set to Multiface"); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | /* any io writes are passed through here */ |
| 152 | int cpc_multiface2_device::multiface_io_write(UINT16 offset, UINT8 data) |
| 153 | { |
| 154 | int ret = 0; |
| 155 | |
| 156 | /* multiface hardware enabled? */ |
| 157 | if (!multiface_hardware_enabled()) |
| 158 | return 0; |
| 159 | |
| 160 | /* visible? */ |
| 161 | if (m_multiface_flags & MULTIFACE_VISIBLE) |
| 162 | { |
| 163 | if (offset==0x0fee8) |
| 164 | { |
| 165 | m_multiface_flags |= MULTIFACE_RAM_ROM_ENABLED; |
| 166 | ret = 1; |
| 167 | } |
| 168 | |
| 169 | if (offset==0x0feea) |
| 170 | { |
| 171 | m_multiface_flags &= ~MULTIFACE_RAM_ROM_ENABLED; |
| 172 | ret = 1; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | /* update multiface ram with data */ |
| 177 | /* these are decoded fully! */ |
| 178 | switch ((offset>>8) & 0x0ff) |
| 179 | { |
| 180 | /* gate array */ |
| 181 | case 0x07f: |
| 182 | { |
| 183 | switch (data & 0x0c0) |
| 184 | { |
| 185 | /* pen index */ |
| 186 | case 0x00: |
| 187 | { |
| 188 | m_multiface_ram[0x01fcf] = data; |
| 189 | } |
| 190 | break; |
| 191 | /* pen colour */ |
| 192 | case 0x040: |
| 193 | { |
| 194 | int pen_index; |
| 195 | pen_index = m_multiface_ram[0x01fcf] & 0x0f; |
| 196 | if (m_multiface_ram[0x01fcf] & 0x010) |
| 197 | { |
| 198 | m_multiface_ram[0x01fdf + pen_index] = data; |
| 199 | } |
| 200 | else |
| 201 | { |
| 202 | m_multiface_ram[0x01f90 + pen_index] = data & 0x01f; |
| 203 | } |
| 204 | } |
| 205 | break; |
| 206 | /* rom/mode selection */ |
| 207 | case 0x080: |
| 208 | { |
| 209 | m_multiface_ram[0x01fef] = data; |
| 210 | } |
| 211 | break; |
| 212 | /* ram configuration */ |
| 213 | case 0x0c0: |
| 214 | { |
| 215 | m_multiface_ram[0x01fff] = data; |
| 216 | } |
| 217 | break; |
| 218 | default: |
| 219 | break; |
| 220 | } |
| 221 | } |
| 222 | break; |
| 223 | |
| 224 | /* crtc register index */ |
| 225 | case 0x0bc: |
| 226 | { |
| 227 | m_multiface_ram[0x01cff] = data; |
| 228 | } |
| 229 | break; |
| 230 | /* crtc register write */ |
| 231 | case 0x0bd: |
| 232 | { |
| 233 | int reg_index; |
| 234 | reg_index = m_multiface_ram[0x01cff] & 0x0f; |
| 235 | m_multiface_ram[0x01db0 + reg_index] = data; |
| 236 | } |
| 237 | break; |
| 238 | |
| 239 | |
| 240 | /* 8255 ppi control */ |
| 241 | case 0x0f7: |
| 242 | { |
| 243 | m_multiface_ram[0x017ff] = data; |
| 244 | } |
| 245 | break; |
| 246 | /* rom select */ |
| 247 | case 0x0df: |
| 248 | { |
| 249 | m_multiface_ram[0x01aac] = data; |
| 250 | } |
| 251 | break; |
| 252 | default: |
| 253 | break; |
| 254 | } |
| 255 | return ret; |
| 256 | } |
| 257 | |
| 258 | static INPUT_PORTS_START(cpc_mface2) |
| 259 | PORT_START("multiface") |
| 260 | PORT_CONFNAME(0x01, 0x00, "Multiface Two" ) |
| 261 | PORT_CONFSETTING(0x00, DEF_STR( Off) ) |
| 262 | PORT_CONFSETTING(0x01, DEF_STR( On) ) |
| 263 | PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Multiface Two's Stop Button") PORT_CODE(KEYCODE_F6) |
| 264 | // PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Multiface Two's Reset Button") PORT_CODE(KEYCODE_F3) Not implemented |
| 265 | INPUT_PORTS_END |
| 266 | |
| 267 | |
| 268 | |
| 269 | //------------------------------------------------- |
| 270 | // Device ROM definition |
| 271 | //------------------------------------------------- |
| 272 | |
| 273 | // Second known revision (1988) |
| 274 | ROM_START( cpc_mface2 ) |
| 275 | ROM_REGION( 0x2000, "multiface", 0 ) |
| 276 | ROM_LOAD("multface.rom", 0x0000, 0x2000, CRC(f36086de) SHA1(1431ec628d38f000715545dd2186b684c5fe5a6f)) |
| 277 | ROM_END |
| 278 | |
| 279 | //------------------------------------------------- |
| 280 | // rom_region - device-specific ROM region |
| 281 | //------------------------------------------------- |
| 282 | |
| 283 | const rom_entry *cpc_multiface2_device::device_rom_region() const |
| 284 | { |
| 285 | return ROM_NAME( cpc_mface2 ); |
| 286 | } |
| 287 | |
| 288 | ioport_constructor cpc_multiface2_device::device_input_ports() const |
| 289 | { |
| 290 | return INPUT_PORTS_NAME( cpc_mface2 ); |
| 291 | } |
| 292 | |
| 293 | //************************************************************************** |
| 294 | // LIVE DEVICE |
| 295 | //************************************************************************** |
| 296 | |
| 297 | cpc_multiface2_device::cpc_multiface2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 298 | device_t(mconfig, CPC_MFACE2, "Multiface II", tag, owner, clock), |
| 299 | device_cpc_expansion_card_interface(mconfig, *this), |
| 300 | device_slot_card_interface(mconfig, *this) |
| 301 | { |
| 302 | } |
| 303 | |
| 304 | //------------------------------------------------- |
| 305 | // device_start - device-specific startup |
| 306 | //------------------------------------------------- |
| 307 | |
| 308 | void cpc_multiface2_device::device_start() |
| 309 | { |
| 310 | m_slot = dynamic_cast<cpc_expansion_slot_device *>(owner()); |
| 311 | |
| 312 | /* after a reset the multiface is visible */ |
| 313 | m_multiface_flags = MULTIFACE_VISIBLE; |
| 314 | |
| 315 | /* allocate ram */ |
| 316 | m_multiface_ram = auto_alloc_array(machine(), UINT8, 8192); |
| 317 | } |
| 318 | |
| 319 | //------------------------------------------------- |
| 320 | // device_reset - device-specific reset |
| 321 | //------------------------------------------------- |
| 322 | |
| 323 | void cpc_multiface2_device::device_reset() |
| 324 | { |
| 325 | /* stop button not pressed and ram/rom disabled */ |
| 326 | m_multiface_flags &= ~(MULTIFACE_STOP_BUTTON_PRESSED | |
| 327 | MULTIFACE_RAM_ROM_ENABLED); |
| 328 | /* as on the real hardware the multiface is visible after a reset! */ |
| 329 | m_multiface_flags |= MULTIFACE_VISIBLE; |
| 330 | } |
src/mess/machine/mface2.h
| r0 | r12470 | |
| 1 | /* |
| 2 | * mface2.h -- Romantic Robot Multiface II expansion device for the Amstrad CPC/CPC+ |
| 3 | * |
| 4 | * Created on: 31/07/2011 |
| 5 | * |
| 6 | * I/O Ports: |
| 7 | * - FEE8: Enables Multiface ROM and RAM |
| 8 | * - FEEA: Disables Multiface ROM and RAM |
| 9 | * |
| 10 | * When enabled, Multiface ROM is mapped to &0000, and RAM to &2000 |
| 11 | * |
| 12 | * When the Stop button is pressed, the Multiface II will generate an NMI |
| 13 | * (I guess the ROM/RAM is enabled when you do this also?) |
| 14 | * |
| 15 | * It also monitors all I/O port writes, so that it can restore them when resuming the current application. |
| 16 | */ |
| 17 | |
| 18 | #ifndef MFACE2_H_ |
| 19 | #define MFACE2_H_ |
| 20 | |
| 21 | #include "emu.h" |
| 22 | #include "machine/cpcexp.h" |
| 23 | |
| 24 | /* stop button has been pressed */ |
| 25 | #define MULTIFACE_STOP_BUTTON_PRESSED 0x0001 |
| 26 | /* ram/rom is paged into memory space */ |
| 27 | #define MULTIFACE_RAM_ROM_ENABLED 0x0002 |
| 28 | /* when visible OUT commands are performed! */ |
| 29 | #define MULTIFACE_VISIBLE 0x0004 |
| 30 | |
| 31 | |
| 32 | class cpc_multiface2_device : public device_t, |
| 33 | public device_cpc_expansion_card_interface, |
| 34 | public device_slot_card_interface |
| 35 | { |
| 36 | public: |
| 37 | // construction/destruction |
| 38 | cpc_multiface2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 39 | |
| 40 | // optional information overrides |
| 41 | virtual const rom_entry *device_rom_region() const; |
| 42 | virtual ioport_constructor device_input_ports() const; |
| 43 | |
| 44 | int multiface_hardware_enabled(); |
| 45 | void multiface_rethink_memory(); |
| 46 | void multiface_stop(); |
| 47 | int multiface_io_write(UINT16 offset, UINT8 data); |
| 48 | void check_button_state(); |
| 49 | protected: |
| 50 | // device-level overrides |
| 51 | virtual void device_start(); |
| 52 | virtual void device_reset(); |
| 53 | virtual void device_config_complete() { m_shortname = "cpc_mf2"; } |
| 54 | |
| 55 | private: |
| 56 | cpc_expansion_slot_device *m_slot; |
| 57 | |
| 58 | DIRECT_UPDATE_MEMBER( amstrad_default ); |
| 59 | DIRECT_UPDATE_MEMBER( amstrad_multiface_directoverride ); |
| 60 | |
| 61 | unsigned char *m_multiface_ram; |
| 62 | unsigned long m_multiface_flags; |
| 63 | |
| 64 | UINT8 m_romdis; |
| 65 | }; |
| 66 | |
| 67 | // device type definition |
| 68 | extern const device_type CPC_MFACE2; |
| 69 | |
| 70 | #endif /* MFACE2_H_ */ |
src/mess/drivers/amstrad.c
| r12469 | r12470 | |
| 111 | 111 | #include "machine/cpcexp.h" |
| 112 | 112 | #include "machine/cpc_ssa1.h" |
| 113 | 113 | #include "machine/cpc_rom.h" |
| 114 | #include "machine/mface2.h" |
| 114 | 115 | |
| 115 | 116 | #include "machine/ram.h" |
| 116 | 117 | |
| r12469 | r12470 | |
| 124 | 125 | #define SYSTEM_GX4000 2 |
| 125 | 126 | |
| 126 | 127 | |
| 127 | | |
| 128 | 128 | /* ----------------------------- |
| 129 | 129 | - amstrad_ppi8255_interface - |
| 130 | 130 | -----------------------------*/ |
| r12469 | r12470 | |
| 390 | 390 | // PORT_CONFSETTING(M6845_PERSONALITY_AMS40489, "Type 3 - AMS40489") |
| 391 | 391 | // PORT_CONFSETTING(M6845_PERSONALITY_PREASIC, "Type 4 - Pre-ASIC") |
| 392 | 392 | |
| 393 | | PORT_START("multiface") |
| 394 | | PORT_CONFNAME(0x01, 0x00, "Multiface Two" ) |
| 395 | | PORT_CONFSETTING(0x00, DEF_STR( Off) ) |
| 396 | | PORT_CONFSETTING(0x01, DEF_STR( On) ) |
| 397 | | PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Multiface Two's Stop Button") PORT_CODE(KEYCODE_F1) |
| 398 | | // PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Multiface Two's Reset Button") PORT_CODE(KEYCODE_F3) Not implemented |
| 399 | | |
| 400 | 393 | PORT_START("green_display") |
| 401 | 394 | PORT_CONFNAME( 0x01, 0x00, "Monitor" ) PORT_CHANGED( cpc_monitor_changed, 0 ) |
| 402 | 395 | PORT_CONFSETTING(0x00, "CTM640 Colour Monitor" ) |
| r12469 | r12470 | |
| 775 | 768 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Funny looking Russian symbol") PORT_CODE(KEYCODE_END) |
| 776 | 769 | |
| 777 | 770 | PORT_INCLUDE(crtc_links) |
| 778 | | PORT_MODIFY("multiface") // move Multiface II stop to F6, as the Aleste has it's own F1-F5 keys. |
| 779 | | PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("Multiface Two's Stop Button") PORT_CODE(KEYCODE_F6) |
| 780 | 771 | INPUT_PORTS_END |
| 781 | 772 | |
| 782 | 773 | |
| r12469 | r12470 | |
| 875 | 866 | { |
| 876 | 867 | DEVCB_CPU_INPUT_LINE("maincpu", 0), |
| 877 | 868 | DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_NMI), |
| 878 | | DEVCB_NULL // RESET |
| 869 | DEVCB_NULL, // RESET |
| 870 | DEVCB_LINE(cpc_romdis), // ROMDIS |
| 871 | DEVCB_LINE(cpc_romen) // /ROMEN |
| 879 | 872 | }; |
| 880 | 873 | |
| 881 | 874 | static SLOT_INTERFACE_START(cpc_exp_cards) |
| 882 | 875 | SLOT_INTERFACE("ssa1", CPC_SSA1) |
| 883 | 876 | SLOT_INTERFACE("dkspeech", CPC_DKSPEECH) |
| 884 | 877 | SLOT_INTERFACE("rom", CPC_ROM) |
| 878 | SLOT_INTERFACE("multiface2", CPC_MFACE2) |
| 885 | 879 | SLOT_INTERFACE_END |
| 886 | 880 | |
| 881 | static SLOT_INTERFACE_START(cpcplus_exp_cards) |
| 882 | SLOT_INTERFACE("ssa1", CPC_SSA1) |
| 883 | SLOT_INTERFACE("dkspeech", CPC_DKSPEECH) |
| 884 | SLOT_INTERFACE("rom", CPC_ROM) |
| 885 | SLOT_INTERFACE_END |
| 886 | |
| 887 | 887 | static MACHINE_CONFIG_FRAGMENT( cpcplus_cartslot ) |
| 888 | 888 | MCFG_CARTSLOT_ADD("cart") |
| 889 | 889 | MCFG_CARTSLOT_EXTENSION_LIST("cpr,bin") |
| r12469 | r12470 | |
| 1009 | 1009 | |
| 1010 | 1010 | MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(cpc6128_floppy_interface) |
| 1011 | 1011 | |
| 1012 | | MCFG_CPC_EXPANSION_SLOT_ADD("exp",cpc_exp_intf,cpc_exp_cards,NULL,NULL) |
| 1012 | MCFG_CPC_EXPANSION_SLOT_ADD("exp",cpc_exp_intf,cpcplus_exp_cards,NULL,NULL) |
| 1013 | 1013 | |
| 1014 | 1014 | /* internal ram */ |
| 1015 | 1015 | MCFG_RAM_ADD(RAM_TAG) |