src/mess/machine/atom.c
| r4247 | r4248 | |
| 18 | 18 | #include "driver.h" |
| 19 | 19 | #include "machine/8255ppi.h" |
| 20 | 20 | #include "video/m6847.h" |
| 21 | #include "machine/ctronics.h" |
| 21 | 22 | #include "machine/i8271.h" |
| 22 | 23 | #include "machine/6522via.h" |
| 23 | 24 | #include "devices/basicdsk.h" |
| 24 | 25 | #include "devices/flopdrv.h" |
| 25 | 26 | #include "devices/cassette.h" |
| 26 | | #include "devices/printer.h" |
| 27 | 27 | #include "devices/snapquik.h" |
| 28 | 28 | #include "includes/atom.h" |
| 29 | 29 | #include "sound/speaker.h" |
| r4247 | r4248 | |
| 33 | 33 | static UINT8 atom_8255_portb; |
| 34 | 34 | UINT8 atom_8255_portc; |
| 35 | 35 | |
| 36 | | /* printer data written */ |
| 37 | | static char atom_printer_data = 0x07f; |
| 38 | 36 | |
| 39 | 37 | /* I am not sure if this is correct, the atom appears to have a 2.4 kHz timer used for reading tapes?? */ |
| 40 | 38 | static int timer_state = 0; |
| 41 | 39 | |
| 42 | | static void atom_via_irq_func(const device_config *device, int state) |
| 43 | | { |
| 44 | | if (state) |
| 45 | | { |
| 46 | | cpu_set_input_line(device->machine->cpu[0], 0, HOLD_LINE); |
| 47 | | } |
| 48 | | else |
| 49 | | { |
| 50 | | cpu_set_input_line(device->machine->cpu[0], 0, CLEAR_LINE); |
| 51 | | } |
| 52 | | } |
| 53 | | |
| 54 | 40 | static const device_config *cassette_device_image(running_machine *machine) |
| 55 | 41 | { |
| 56 | 42 | return devtag_get_device(machine, CASSETTE, "cassette"); |
| 57 | 43 | } |
| 58 | 44 | |
| 59 | | static const device_config *printer_image(running_machine *machine) |
| 60 | | { |
| 61 | | return devtag_get_device(machine, PRINTER, "printer"); |
| 62 | | } |
| 63 | 45 | |
| 64 | | /* printer status */ |
| 65 | | static READ8_DEVICE_HANDLER(atom_via_in_a_func) |
| 66 | | { |
| 67 | | unsigned char data; |
| 68 | 46 | |
| 69 | | data = atom_printer_data; |
| 47 | /*************************************************************************** |
| 48 | PRINTER INTERFACE |
| 49 | ***************************************************************************/ |
| 70 | 50 | |
| 71 | | if (!printer_is_ready(printer_image(device->machine))) |
| 72 | | { |
| 73 | | /* offline */ |
| 74 | | data |=0x080; |
| 75 | | } |
| 76 | | |
| 77 | | return data; |
| 51 | static void atom_via_irq_func(const device_config *device, int state) |
| 52 | { |
| 53 | cpu_set_input_line(device->machine->cpu[0], 0, state); |
| 78 | 54 | } |
| 79 | 55 | |
| 80 | | /* printer data */ |
| 81 | | static WRITE8_DEVICE_HANDLER(atom_via_out_a_func) |
| 56 | /* BUSY from the centronics interface is connected to PA7 of the via */ |
| 57 | static READ8_DEVICE_HANDLER( atom_printer_busy ) |
| 82 | 58 | { |
| 83 | | /* data is written to port, this causes a pulse on ca2 (printer /strobe input), |
| 84 | | and data is written */ |
| 85 | | /* atom has a 7-bit printer port */ |
| 86 | | atom_printer_data = data & 0x07f; |
| 59 | const device_config *printer = devtag_get_device(device->machine, CENTRONICS, "centronics"); |
| 60 | return centronics_busy_r(printer) << 7; |
| 87 | 61 | } |
| 88 | 62 | |
| 89 | | static unsigned char previous_ca2_data = 0; |
| 90 | | |
| 91 | | /* one of these is pulsed! */ |
| 92 | | static WRITE8_DEVICE_HANDLER(atom_via_out_ca2_func) |
| 63 | /* DATA lines 0 to 6 are connected to PA0 to PA6 of the via */ |
| 64 | static WRITE8_DEVICE_HANDLER( atom_printer_data ) |
| 93 | 65 | { |
| 94 | | /* change in state of ca2 output? */ |
| 95 | | if (((previous_ca2_data^data)&0x01)!=0) |
| 96 | | { |
| 97 | | /* only look for one transition state */ |
| 98 | | if (data & 0x01) |
| 99 | | { |
| 100 | | /* output data to printer */ |
| 101 | | printer_output(printer_image(device->machine), atom_printer_data); |
| 102 | | } |
| 103 | | } |
| 66 | const device_config *printer = devtag_get_device(device->machine, CENTRONICS, "centronics"); |
| 67 | centronics_data_w(printer, 0, data & 0x7f); |
| 68 | } |
| 104 | 69 | |
| 105 | | previous_ca2_data = data; |
| 70 | /* the CA2 output is connected to the STROBE signal on the centronics */ |
| 71 | static WRITE8_DEVICE_HANDLER( atom_printer_strobe ) |
| 72 | { |
| 73 | const device_config *printer = devtag_get_device(device->machine, CENTRONICS, "centronics"); |
| 74 | centronics_strobe_w(printer, data); |
| 106 | 75 | } |
| 107 | 76 | |
| 108 | 77 | const via6522_interface atom_6522_interface = |
| 109 | 78 | { |
| 110 | | atom_via_in_a_func, /* printer status */ |
| 79 | atom_printer_busy, |
| 111 | 80 | NULL, |
| 112 | 81 | NULL, |
| 113 | 82 | NULL, |
| 114 | 83 | NULL, |
| 115 | 84 | NULL, |
| 116 | | atom_via_out_a_func, /* printer data */ |
| 85 | atom_printer_data, |
| 117 | 86 | NULL, |
| 118 | 87 | NULL, |
| 119 | 88 | NULL, |
| 120 | | atom_via_out_ca2_func, /* printer strobe */ |
| 89 | atom_printer_strobe, |
| 121 | 90 | NULL, |
| 122 | 91 | atom_via_irq_func, |
| 123 | 92 | }; |
| r4247 | r4248 | |
| 349 | 318 | READ8_DEVICE_HANDLER ( atom_8255_portb_r ) |
| 350 | 319 | { |
| 351 | 320 | int row; |
| 352 | | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", |
| 321 | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", |
| 353 | 322 | "KEY6", "KEY7", "KEY8", "KEY9", "KEY10", "KEY11" }; |
| 354 | | |
| 323 | |
| 355 | 324 | row = atom_8255_porta & 0x0f; |
| 356 | | /* logerror("8255: Read port b: %02X %02X\n", input_port_read(machine, port), |
| 325 | /* logerror("8255: Read port b: %02X %02X\n", input_port_read(machine, port), |
| 357 | 326 | input_port_read(machine, "KEY10") & 0xc0); */ |
| 358 | 327 | return ((input_port_read(device->machine, keynames[row]) & 0x3f) | (input_port_read(device->machine, "KEY10") & 0xc0)); |
| 359 | 328 | } |
src/mess/drivers/atom.c
| r4247 | r4248 | |
| 62 | 62 | #include "cpu/m6502/m6502.h" |
| 63 | 63 | |
| 64 | 64 | /* Components */ |
| 65 | | #include "machine/centroni.h" |
| 65 | #include "machine/ctronics.h" |
| 66 | 66 | #include "machine/i8271.h" |
| 67 | 67 | #include "machine/8255ppi.h" |
| 68 | 68 | #include "machine/6522via.h" |
| r4247 | r4248 | |
| 71 | 71 | /* Devices */ |
| 72 | 72 | #include "devices/basicdsk.h" |
| 73 | 73 | #include "devices/flopdrv.h" |
| 74 | | #include "devices/printer.h" |
| 75 | 74 | #include "devices/cassette.h" |
| 76 | 75 | #include "devices/snapquik.h" |
| 77 | 76 | #include "sound/speaker.h" |
| r4247 | r4248 | |
| 248 | 247 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED) |
| 249 | 248 | INPUT_PORTS_END |
| 250 | 249 | |
| 251 | | /* sound output */ |
| 252 | 250 | |
| 251 | /* centronics interface */ |
| 252 | static const centronics_interface atom_centronics_config = |
| 253 | { |
| 254 | FALSE, |
| 255 | DEVCB_DEVICE_HANDLER(VIA6522, "via6522_0", via_ca1_w), |
| 256 | DEVCB_NULL, |
| 257 | DEVCB_NULL |
| 258 | }; |
| 259 | |
| 260 | |
| 253 | 261 | /* machine definition */ |
| 254 | 262 | static MACHINE_DRIVER_START( atom ) |
| 255 | 263 | /* basic machine hardware */ |
| r4247 | r4248 | |
| 276 | 284 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 277 | 285 | |
| 278 | 286 | /* printer */ |
| 279 | | MDRV_PRINTER_ADD("printer") |
| 287 | MDRV_CENTRONICS_ADD("centronics", atom_centronics_config) |
| 280 | 288 | |
| 281 | 289 | /* quickload */ |
| 282 | 290 | MDRV_QUICKLOAD_ADD(atom, "atm", 0) |