src/mess/drivers/einstein.c
| r4275 | r4276 | |
| 86 | 86 | #include "cpu/z80/z80.h" |
| 87 | 87 | #include "cpu/z80/z80daisy.h" |
| 88 | 88 | #include "machine/wd17xx.h" |
| 89 | | #include "machine/centroni.h" |
| 89 | #include "machine/ctronics.h" |
| 90 | 90 | #include "machine/msm8251.h" |
| 91 | 91 | #include "devices/dsk.h" |
| 92 | 92 | #include "devices/basicdsk.h" |
| 93 | | #include "devices/printer.h" |
| 94 | 93 | #include "sound/ay8910.h" |
| 95 | 94 | #include "video/mc6845.h" |
| 96 | 95 | |
| r4275 | r4276 | |
| 438 | 437 | z80ctc_trg3_w |
| 439 | 438 | }; |
| 440 | 439 | |
| 440 | |
| 441 | 441 | static void einstein_pio_ardy(const device_config *device, int state) |
| 442 | 442 | { |
| 443 | | int handshake; |
| 444 | | |
| 445 | | handshake = 0; |
| 446 | | |
| 447 | | /* strobe is inverted state of ardy */ |
| 448 | | if (state != 0) |
| 449 | | handshake = CENTRONICS_STROBE; |
| 450 | | |
| 451 | | /* ardy is connected to strobe */ |
| 452 | | centronics_write_handshake(device->machine,0, CENTRONICS_SELECT | CENTRONICS_NO_RESET, CENTRONICS_SELECT| CENTRONICS_NO_RESET); |
| 453 | | centronics_write_handshake(device->machine,0, handshake, CENTRONICS_STROBE); |
| 443 | const device_config *printer = devtag_get_device(device->machine, CENTRONICS, "centronics"); |
| 444 | centronics_strobe_w(printer, state); |
| 454 | 445 | } |
| 455 | 446 | |
| 456 | 447 | static WRITE8_DEVICE_HANDLER( einstein_pio_port_a_w ) |
| 457 | 448 | { |
| 458 | | centronics_write_data(device->machine,0,data); |
| 449 | const device_config *printer = devtag_get_device(device->machine, CENTRONICS, "centronics"); |
| 450 | centronics_data_w(printer, 0, data); |
| 459 | 451 | } |
| 460 | 452 | |
| 461 | 453 | |
| r4275 | r4276 | |
| 860 | 852 | |
| 861 | 853 | static READ8_HANDLER(einstein_key_int_r) |
| 862 | 854 | { |
| 863 | | int centronics_handshake; |
| 855 | const device_config *printer = devtag_get_device(space->machine, CENTRONICS, "centronics"); |
| 864 | 856 | int data; |
| 865 | 857 | |
| 866 | 858 | /* clear key int. a read of this I/O port will do this or a reset */ |
| r4275 | r4276 | |
| 868 | 860 | |
| 869 | 861 | einstein_update_interrupts(space->machine); |
| 870 | 862 | |
| 871 | | centronics_write_handshake(space->machine,0, CENTRONICS_SELECT | CENTRONICS_NO_RESET, CENTRONICS_SELECT| CENTRONICS_NO_RESET); |
| 872 | | centronics_handshake = centronics_read_handshake(space->machine,0); |
| 873 | | |
| 874 | 863 | /* bit 7: 0=shift pressed */ |
| 875 | 864 | /* bit 6: 0=control pressed */ |
| 876 | 865 | /* bit 5: 0=graph pressed */ |
| r4275 | r4276 | |
| 881 | 870 | /* bit 0: fire 0 */ |
| 882 | 871 | data = ((input_port_read(space->machine, "EXTRA") & 0x07)<<5) | (input_port_read(space->machine, "BUTTONS") & 0x03) | 0x01c; |
| 883 | 872 | |
| 884 | | /* error? */ |
| 885 | | if (centronics_handshake & CENTRONICS_NO_ERROR) |
| 886 | | { |
| 887 | | /* if CENTRONICS_NO_ERROR flag set there is no error */ |
| 873 | data |= centronics_fault_r(printer) << 4; |
| 874 | data |= centronics_pe_r(printer) << 3; |
| 875 | data |= centronics_busy_r(printer) << 2; |
| 888 | 876 | |
| 889 | | /* no error */ |
| 890 | | data |= (1<<4); |
| 891 | | } |
| 892 | | |
| 893 | | /* no paper? */ |
| 894 | | if ((centronics_handshake & CENTRONICS_NO_PAPER)==0) |
| 895 | | { |
| 896 | | /* if CENTRONICS_NO_PAPER flag set there is no paper */ |
| 897 | | |
| 898 | | /* has paper */ |
| 899 | | data |= (1<<3); |
| 900 | | } |
| 901 | | |
| 902 | | if ((centronics_handshake & CENTRONICS_NOT_BUSY)==0) |
| 903 | | { |
| 904 | | /* if CENTRONICS_NOT_BUSY flag set then not busy */ |
| 905 | | |
| 906 | | /* busy */ |
| 907 | | data |= (1<<2); |
| 908 | | } |
| 909 | | |
| 910 | 877 | logerror("key int r: %02x\n",data); |
| 911 | 878 | |
| 912 | 879 | return data; |
| r4275 | r4276 | |
| 1360 | 1327 | |
| 1361 | 1328 | |
| 1362 | 1329 | |
| 1363 | | |
| 1364 | | static void einstein_printer_handshake_in(running_machine *machine,int number, int data, int mask) |
| 1365 | | { |
| 1366 | | if (mask & CENTRONICS_ACKNOWLEDGE) |
| 1367 | | { |
| 1368 | | if (data & CENTRONICS_ACKNOWLEDGE) |
| 1369 | | { |
| 1370 | | /* /ack into /astb */ |
| 1371 | | z80pio_astb_w( einstein_z80pio, 0); |
| 1372 | | } |
| 1373 | | else |
| 1374 | | { |
| 1375 | | z80pio_astb_w( einstein_z80pio, 1); |
| 1376 | | } |
| 1377 | | } |
| 1378 | | } |
| 1379 | | |
| 1380 | | static const CENTRONICS_CONFIG einstein_cent_config[1]={ |
| 1381 | | { |
| 1382 | | PRINTER_CENTRONICS, |
| 1383 | | einstein_printer_handshake_in |
| 1384 | | }, |
| 1385 | | }; |
| 1386 | | |
| 1387 | | |
| 1388 | 1330 | /* when Z80 acknowledges int, /IORQ and /M1 will be low */ |
| 1389 | 1331 | /* this allows I057 octal latch to output data onto the bus */ |
| 1390 | 1332 | static IRQ_CALLBACK(einstein_cpu_acknowledge_int) |
| r4275 | r4276 | |
| 1457 | 1399 | /* the input to channel 0 and 1 of the ctc is a 2 MHz clock */ |
| 1458 | 1400 | einstein_ctc_trigger = 0; |
| 1459 | 1401 | timer_pulse(machine, ATTOTIME_IN_HZ(2000000), (void *)devtag_get_device(machine, Z80CTC, "z80ctc"), 0, einstein_ctc_trigger_callback); |
| 1460 | | |
| 1461 | | centronics_config(machine, 0, einstein_cent_config); |
| 1462 | | /* assumption: select is tied low */ |
| 1463 | | centronics_write_handshake(machine, 0, CENTRONICS_SELECT | CENTRONICS_NO_RESET, CENTRONICS_SELECT| CENTRONICS_NO_RESET); |
| 1464 | | |
| 1465 | 1402 | } |
| 1466 | 1403 | |
| 1467 | 1404 | static MACHINE_RESET( einstein2 ) |
| r4275 | r4276 | |
| 1609 | 1546 | NULL |
| 1610 | 1547 | }; |
| 1611 | 1548 | |
| 1549 | static const centronics_interface einstein_centronics_config = |
| 1550 | { |
| 1551 | FALSE, |
| 1552 | DEVCB_DEVICE_LINE(Z80PIO, "z80pio", z80pio_astb_w), |
| 1553 | DEVCB_NULL, |
| 1554 | DEVCB_NULL |
| 1555 | }; |
| 1556 | |
| 1612 | 1557 | /* |
| 1613 | 1558 | 0: 126 (127) horizontal total |
| 1614 | 1559 | 1: 80 horizontal displayed |
| r4275 | r4276 | |
| 1739 | 1684 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) |
| 1740 | 1685 | |
| 1741 | 1686 | /* printer */ |
| 1742 | | MDRV_PRINTER_ADD("printer") |
| 1687 | MDRV_CENTRONICS_ADD("centronics", einstein_centronics_config) |
| 1743 | 1688 | |
| 1744 | 1689 | /* uart */ |
| 1745 | 1690 | MDRV_MSM8251_ADD("uart", default_msm8251_interface) |
| 1746 | | |
| 1691 | |
| 1747 | 1692 | MDRV_WD177X_ADD("wd177x", default_wd17xx_interface ) |
| 1748 | 1693 | MACHINE_DRIVER_END |
| 1749 | 1694 | |