src/mess/machine/z80dart.c
| r3481 | r3482 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | | Z80 DART (Z8470) implementation |
| 3 | Z80 DART Dual Asynchronous Receiver/Transmitter emulation |
| 4 | 4 | |
| 5 | | Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team. |
| 5 | Copyright (c) 2008, The MESS Team. |
| 6 | 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | 7 | |
| 8 | 8 | ***************************************************************************/ |
| 9 | 9 | |
| 10 | /* |
| 11 | |
| 12 | TODO: |
| 13 | |
| 14 | - save state support |
| 15 | - break detection |
| 16 | - wr0 reset tx interrupt pending |
| 17 | - wait/ready |
| 18 | - 1.5 stop bits |
| 19 | |
| 20 | */ |
| 21 | |
| 10 | 22 | #include "driver.h" |
| 11 | 23 | #include "z80dart.h" |
| 12 | 24 | #include "cpu/z80/z80.h" |
| 13 | 25 | #include "cpu/z80/z80daisy.h" |
| 14 | 26 | |
| 15 | | |
| 16 | | |
| 17 | 27 | /*************************************************************************** |
| 18 | 28 | DEBUGGING |
| 19 | 29 | ***************************************************************************/ |
| 20 | 30 | |
| 21 | | #define VERBOSE 1 |
| 31 | #define VERBOSE 1 |
| 22 | 32 | |
| 23 | | #define VPRINTF(x) do { if (VERBOSE) logerror x; } while (0) |
| 33 | #define LOGERROR if (VERBOSE) logerror |
| 24 | 34 | |
| 25 | | |
| 26 | | |
| 27 | 35 | /*************************************************************************** |
| 28 | 36 | CONSTANTS |
| 29 | 37 | ***************************************************************************/ |
| 30 | 38 | |
| 31 | | /* interrupt states */ |
| 32 | | #define INT_CHB_TRANSMIT 0x00 /* not confirmed */ |
| 33 | | #define INT_CHB_STATUS 0x01 |
| 34 | | #define INT_CHB_RECEIVE 0x02 |
| 35 | | #define INT_CHB_ERROR 0x03 |
| 39 | enum |
| 40 | { |
| 41 | STATE_START = 0, |
| 42 | STATE_DATA, |
| 43 | STATE_PARITY, |
| 44 | STATE_STOP, |
| 45 | STATE_STOP2 |
| 46 | }; |
| 36 | 47 | |
| 37 | | #define INT_CHA_TRANSMIT 0x04 /* not confirmed */ |
| 38 | | #define INT_CHA_STATUS 0x05 |
| 39 | | #define INT_CHA_RECEIVE 0x06 |
| 40 | | #define INT_CHA_ERROR 0x07 |
| 48 | enum |
| 49 | { |
| 50 | INT_TRANSMIT = 0, |
| 51 | INT_EXTERNAL, |
| 52 | INT_RECEIVE, |
| 53 | INT_SPECIAL |
| 54 | }; |
| 41 | 55 | |
| 42 | | /* DART write register 0 */ |
| 43 | | #define DART_WR0_RESET_MASK 0xc0 /* D7-D6: Reset control */ |
| 44 | | #define DART_WR0_RESET_NULL 0x00 /* 00 = NULL code */ |
| 45 | | #define DART_WR0_RESET_RX_CRC 0x40 /* 01 = Reset Rx CRC checker */ |
| 46 | | #define DART_WR0_RESET_TX_CRC 0x80 /* 10 = Reset Tx CRC generator */ |
| 47 | | #define DART_WR0_RESET_TX_LATCH 0xc0 /* 11 = Reset Tx Underrun/EOM latch */ |
| 48 | | #define DART_WR0_COMMAND_MASK 0x38 /* D5-D3: Command */ |
| 49 | | #define DART_WR0_COMMAND_NULL 0x00 /* 000 = NULL code */ |
| 50 | | /* 001 = not used */ |
| 51 | | #define DART_WR0_COMMAND_RES_STATUS_INT 0x10 /* 010 = reset ext/status interrupts */ |
| 52 | | #define DART_WR0_COMMAND_CH_RESET 0x18 /* 011 = Channel reset */ |
| 53 | | #define DART_WR0_COMMAND_ENA_RX_INT 0x20 /* 100 = Enable int on next Rx character */ |
| 54 | | #define DART_WR0_COMMAND_RES_TX_INT 0x28 /* 101 = Reset Tx int pending */ |
| 55 | | #define DART_WR0_COMMAND_RES_ERROR 0x30 /* 110 = Error reset */ |
| 56 | | #define DART_WR0_COMMAND_RETI 0x38 /* 111 = Return from int (CH-A only) */ |
| 57 | | #define DART_WR0_REGISTER_MASK 0x07 /* D2-D0: Register select (0-7) */ |
| 56 | #define Z80DART_RR0_RX_CHAR_AVAILABLE 0x01 |
| 57 | #define Z80DART_RR0_INTERRUPT_PENDING 0x02 |
| 58 | #define Z80DART_RR0_TX_BUFFER_EMPTY 0x04 |
| 59 | #define Z80DART_RR0_DCD 0x08 |
| 60 | #define Z80DART_RR0_RI 0x10 |
| 61 | #define Z80DART_RR0_CTS 0x20 |
| 62 | #define Z80DART_RR0_BREAK 0x80 /* not supported */ |
| 58 | 63 | |
| 59 | | /* DART write register 1 */ |
| 60 | | #define DART_WR1_READY_WAIT_ENA 0x80 /* D7 = READY/WAIT enable */ |
| 61 | | #define DART_WR1_READY_WAIT_FUNCTION 0x40 /* D6 = READY/WAIT function */ |
| 62 | | #define DART_WR1_READY_WAIT_ON_RT 0x20 /* D5 = READY/WAIT on R/T */ |
| 63 | | #define DART_WR1_RXINT_MASK 0x18 /* D4-D3 = Rx int control */ |
| 64 | | #define DART_WR1_RXINT_DISABLE 0x00 /* 00 = Rx int disable */ |
| 65 | | #define DART_WR1_RXINT_FIRST 0x08 /* 01 = Rx int on first character */ |
| 66 | | #define DART_WR1_RXINT_ALL_PARITY 0x10 /* 10 = int on all Rx characters (parity affects vector) */ |
| 67 | | #define DART_WR1_RXINT_ALL_NOPARITY 0x18 /* 11 = int on all Rx characters (parity ignored) */ |
| 68 | | #define DART_WR1_STATUS_AFFECTS_VECTOR 0x04 /* D2 = Status affects vector (CH-B only) */ |
| 69 | | #define DART_WR1_TXINT_ENABLE 0x02 /* D1 = Tx int enable */ |
| 70 | | #define DART_WR1_STATUSINT_ENABLE 0x01 /* D0 = Ext int enable */ |
| 64 | #define Z80DART_RR1_ALL_SENT 0x01 |
| 65 | #define Z80DART_RR1_PARITY_ERROR 0x10 |
| 66 | #define Z80DART_RR1_RX_OVERRUN_ERROR 0x20 |
| 67 | #define Z80DART_RR1_FRAMING_ERROR 0x40 |
| 71 | 68 | |
| 72 | | /* DART write register 2 (CH-B only) */ |
| 73 | | #define DART_WR2_INT_VECTOR_MASK 0xff /* D7-D0 = interrupt vector */ |
| 69 | #define Z80DART_WR0_REGISTER_MASK 0x07 |
| 70 | #define Z80DART_WR0_COMMAND_MASK 0x38 |
| 71 | #define Z80DART_WR0_NULL_CODE 0x00 |
| 72 | #define Z80DART_WR0_RESET_EXT_STATUS 0x10 |
| 73 | #define Z80DART_WR0_CHANNEL_RESET 0x18 |
| 74 | #define Z80DART_WR0_ENABLE_INT_NEXT_RX 0x20 |
| 75 | #define Z80DART_WR0_RESET_TX_INT 0x28 /* not supported */ |
| 76 | #define Z80DART_WR0_ERROR_RESET 0x30 |
| 77 | #define Z80DART_WR0_RETURN_FROM_INT 0x38 /* not supported */ |
| 74 | 78 | |
| 75 | | /* DART write register 3 */ |
| 76 | | #define DART_WR3_RX_DATABITS_MASK 0xc0 /* D7-D6 = Rx Data bits */ |
| 77 | | #define DART_WR3_RX_DATABITS_5 0x00 /* 00 = Rx 5 bits/character */ |
| 78 | | #define DART_WR3_RX_DATABITS_7 0x40 /* 01 = Rx 7 bits/character */ |
| 79 | | #define DART_WR3_RX_DATABITS_6 0x80 /* 10 = Rx 6 bits/character */ |
| 80 | | #define DART_WR3_RX_DATABITS_8 0xc0 /* 11 = Rx 8 bits/character */ |
| 81 | | #define DART_WR3_AUTO_ENABLES 0x20 /* D5 = Auto enables */ |
| 82 | | /* D1-D4 = not used */ |
| 83 | | #define DART_WR3_RX_ENABLE 0x01 /* D0 = Rx enable */ |
| 79 | #define Z80DART_WR1_EXT_INT_ENABLE 0x01 |
| 80 | #define Z80DART_WR1_TX_INT_ENABLE 0x02 |
| 81 | #define Z80DART_WR1_STATUS_VECTOR 0x04 |
| 82 | #define Z80DART_WR1_RX_INT_ENABLE_MASK 0x18 |
| 83 | #define Z80DART_WR1_RX_INT_DISABLE 0x00 |
| 84 | #define Z80DART_WR1_RX_INT_FIRST 0x08 |
| 85 | #define Z80DART_WR1_RX_INT_ALL_PARITY 0x10 /* not supported */ |
| 86 | #define Z80DART_WR1_RX_INT_ALL 0x18 |
| 87 | #define Z80DART_WR1_WRDY_ON_RX_TX 0x20 /* not supported */ |
| 88 | #define Z80DART_WR1_WRDY_FUNCTION 0x40 /* not supported */ |
| 89 | #define Z80DART_WR1_WRDY_ENABLE 0x80 /* not supported */ |
| 84 | 90 | |
| 85 | | /* DART write register 4 */ |
| 86 | | #define DART_WR4_CLOCK_MODE_MASK 0xc0 /* D7-D6 = Clock mode */ |
| 87 | | #define DART_WR4_CLOCK_MODE_x1 0x00 /* 00 = x1 clock mode */ |
| 88 | | #define DART_WR4_CLOCK_MODE_x16 0x40 /* 01 = x16 clock mode */ |
| 89 | | #define DART_WR4_CLOCK_MODE_x32 0x80 /* 10 = x32 clock mode */ |
| 90 | | #define DART_WR4_CLOCK_MODE_x64 0xc0 /* 11 = x64 clock mode */ |
| 91 | | /* D5-D4 = not used */ |
| 92 | | #define DART_WR4_STOPBITS_MASK 0x0c /* D3-D2 = Stop bits */ |
| 93 | | /* 00 = not used */ |
| 94 | | #define DART_WR4_STOPBITS_1 0x04 /* 01 = 1 stop bit/character */ |
| 95 | | #define DART_WR4_STOPBITS_15 0x08 /* 10 = 1.5 stop bits/character */ |
| 96 | | #define DART_WR4_STOPBITS_2 0x0c /* 11 = 2 stop bits/character */ |
| 97 | | #define DART_WR4_PARITY_EVEN 0x02 /* D1 = Parity even/odd */ |
| 98 | | #define DART_WR4_PARITY_ENABLE 0x01 /* D0 = Parity enable */ |
| 91 | #define Z80DART_WR3_RX_ENABLE 0x01 |
| 92 | #define Z80DART_WR3_AUTO_ENABLES 0x20 |
| 93 | #define Z80DART_WR3_RX_WORD_LENGTH_MASK 0xc0 |
| 94 | #define Z80DART_WR3_RX_WORD_LENGTH_5 0x00 |
| 95 | #define Z80DART_WR3_RX_WORD_LENGTH_7 0x40 |
| 96 | #define Z80DART_WR3_RX_WORD_LENGTH_6 0x80 |
| 97 | #define Z80DART_WR3_RX_WORD_LENGTH_8 0xc0 |
| 99 | 98 | |
| 100 | | /* DART write register 5 */ |
| 101 | | #define DART_WR5_DTR 0x80 /* D7 = DTR */ |
| 102 | | #define DART_WR5_TX_DATABITS_MASK 0x60 /* D6-D5 = Tx Data bits */ |
| 103 | | #define DART_WR5_TX_DATABITS_5 0x00 /* 00 = Tx 5 bits/character */ |
| 104 | | #define DART_WR5_TX_DATABITS_7 0x20 /* 01 = Tx 7 bits/character */ |
| 105 | | #define DART_WR5_TX_DATABITS_6 0x40 /* 10 = Tx 6 bits/character */ |
| 106 | | #define DART_WR5_TX_DATABITS_8 0x60 /* 11 = Tx 8 bits/character */ |
| 107 | | #define DART_WR5_SEND_BREAK 0x10 /* D4 = Send break */ |
| 108 | | #define DART_WR5_TX_ENABLE 0x08 /* D3 = Tx Enable */ |
| 109 | | /* D2 = not used */ |
| 110 | | #define DART_WR5_RTS 0x02 /* D1 = RTS */ |
| 111 | | /* D0 = not used */ |
| 99 | #define Z80DART_WR4_PARITY_ENABLE 0x01 /* not supported */ |
| 100 | #define Z80DART_WR4_PARITY_EVEN 0x02 /* not supported */ |
| 101 | #define Z80DART_WR4_STOP_BITS_MASK 0x0c |
| 102 | #define Z80DART_WR4_STOP_BITS_1 0x04 |
| 103 | #define Z80DART_WR4_STOP_BITS_1_5 0x08 /* not supported */ |
| 104 | #define Z80DART_WR4_STOP_BITS_2 0x0c |
| 105 | #define Z80DART_WR4_CLOCK_MODE_MASK 0xc0 |
| 106 | #define Z80DART_WR4_CLOCK_MODE_X1 0x00 |
| 107 | #define Z80DART_WR4_CLOCK_MODE_X16 0x40 |
| 108 | #define Z80DART_WR4_CLOCK_MODE_X32 0x80 |
| 109 | #define Z80DART_WR4_CLOCK_MODE_X64 0xc0 |
| 112 | 110 | |
| 113 | | /* DART read register 0 */ |
| 114 | | #define DART_RR0_BREAK_ABORT 0x80 /* D7 = Break/abort */ |
| 115 | | /* D6 = not used */ |
| 116 | | #define DART_RR0_CTS 0x20 /* D5 = CTS */ |
| 117 | | #define DART_RR0_RI 0x10 /* D4 = RI */ |
| 118 | | #define DART_RR0_DCD 0x08 /* D3 = DCD */ |
| 119 | | #define DART_RR0_TX_BUFFER_EMPTY 0x04 /* D2 = Tx buffer empty */ |
| 120 | | #define DART_RR0_INT_PENDING 0x02 /* D1 = int pending (CH-A only) */ |
| 121 | | #define DART_RR0_RX_CHAR_AVAILABLE 0x01 /* D0 = Rx character available */ |
| 111 | #define Z80DART_WR5_RTS 0x02 |
| 112 | #define Z80DART_WR5_TX_ENABLE 0x08 |
| 113 | #define Z80DART_WR5_SEND_BREAK 0x10 |
| 114 | #define Z80DART_WR5_TX_WORD_LENGTH_MASK 0x60 |
| 115 | #define Z80DART_WR5_TX_WORD_LENGTH_5 0x00 |
| 116 | #define Z80DART_WR5_TX_WORD_LENGTH_7 0x40 |
| 117 | #define Z80DART_WR5_TX_WORD_LENGTH_6 0x80 |
| 118 | #define Z80DART_WR5_TX_WORD_LENGTH_8 0xc0 |
| 119 | #define Z80DART_WR5_DTR 0x80 |
| 122 | 120 | |
| 123 | | /* DART read register 1 */ |
| 124 | | /* D7 = not used */ |
| 125 | | #define DART_RR1_CRC_FRAMING_ERROR 0x40 /* D6 = Framing error */ |
| 126 | | #define DART_RR1_RX_OVERRUN_ERROR 0x20 /* D5 = Rx overrun error */ |
| 127 | | #define DART_RR1_PARITY_ERROR 0x10 /* D4 = Parity error */ |
| 128 | | /* D3-D1 = not used */ |
| 129 | | #define DART_RR1_ALL_SENT 0x01 /* D0 = All sent */ |
| 130 | | |
| 131 | | /* DART read register 2 (CH-B only) */ |
| 132 | | #define DART_RR2_VECTOR_MASK 0xff /* D7-D0 = Interrupt vector */ |
| 133 | | |
| 134 | | |
| 135 | | |
| 136 | 121 | /*************************************************************************** |
| 137 | 122 | TYPE DEFINITIONS |
| 138 | 123 | ***************************************************************************/ |
| r3481 | r3482 | |
| 140 | 125 | typedef struct _dart_channel dart_channel; |
| 141 | 126 | struct _dart_channel |
| 142 | 127 | { |
| 143 | | UINT8 regs[6]; /* 6 writeable registers */ |
| 144 | | UINT8 status[4]; /* 3 readable registers */ |
| 145 | | int inbuf; /* input buffer */ |
| 146 | | int outbuf; /* output buffer */ |
| 147 | | UINT8 int_on_next_rx; /* interrupt on next rx? */ |
| 148 | | emu_timer *receive_timer; /* timer to clock data in */ |
| 149 | | UINT8 receive_buffer[16]; /* buffer for incoming data */ |
| 150 | | UINT8 receive_inptr; /* index of data coming in */ |
| 151 | | UINT8 receive_outptr; /* index of data going out */ |
| 152 | | }; |
| 128 | /* register state */ |
| 129 | UINT8 rr[3]; /* read register */ |
| 130 | UINT8 wr[6]; /* write register */ |
| 153 | 131 | |
| 132 | /* receiver state */ |
| 133 | UINT8 rx_data_fifo[3]; /* receive data FIFO */ |
| 134 | UINT8 rx_error_fifo[3]; /* receive error FIFO */ |
| 135 | UINT8 rx_shift; /* 8-bit receive shift register */ |
| 136 | UINT8 rx_error; /* current receive error */ |
| 137 | int rx_fifo; /* receive FIFO pointer */ |
| 154 | 138 | |
| 155 | | typedef struct _z80dart z80dart; |
| 156 | | struct _z80dart |
| 157 | | { |
| 158 | | dart_channel chan[2]; /* 2 channels */ |
| 159 | | UINT8 int_state[8]; /* interrupt states */ |
| 139 | int rx_clock; /* receive clock pulse count */ |
| 140 | int rx_state; /* receive state */ |
| 141 | int rx_bits; /* bits received */ |
| 142 | int rx_first; /* first character received */ |
| 143 | int rx_parity; /* received data parity */ |
| 144 | int rx_break; /* receive break condition */ |
| 160 | 145 | |
| 161 | | void (*irq_cb)(const device_config *device, int state); |
| 162 | | write8_device_func dtr_changed_cb; |
| 163 | | write8_device_func rts_changed_cb; |
| 164 | | write8_device_func break_changed_cb; |
| 165 | | write8_device_func transmit_cb; |
| 166 | | int (*receive_poll_cb)(const device_config *device, int ch); |
| 146 | int ri; /* ring indicator latch */ |
| 147 | int cts; /* clear to send latch */ |
| 148 | int dcd; /* data carrier detect latch */ |
| 149 | |
| 150 | /* transmitter state */ |
| 151 | UINT8 tx_data; /* transmit data register */ |
| 152 | UINT8 tx_shift; /* transmit shift register */ |
| 153 | |
| 154 | int tx_clock; /* transmit clock pulse count */ |
| 155 | int tx_state; /* transmit state */ |
| 156 | int tx_bits; /* bits transmitted */ |
| 157 | int tx_parity; /* transmitted data parity */ |
| 158 | |
| 159 | int dtr; /* data terminal ready */ |
| 160 | int rts; /* request to send */ |
| 167 | 161 | }; |
| 168 | 162 | |
| 163 | typedef struct _z80dart_t z80dart_t; |
| 164 | struct _z80dart_t |
| 165 | { |
| 166 | const z80dart_interface *intf; /* interface */ |
| 169 | 167 | |
| 168 | dart_channel channel[2]; /* channels */ |
| 170 | 169 | |
| 170 | int clock; /* base clock */ |
| 171 | int int_state[8]; /* interrupt state */ |
| 172 | |
| 173 | /* timers */ |
| 174 | emu_timer *rxca_timer; |
| 175 | emu_timer *txca_timer; |
| 176 | emu_timer *rxtxcb_timer; |
| 177 | }; |
| 178 | |
| 171 | 179 | /*************************************************************************** |
| 172 | 180 | FUNCTION PROTOTYPES |
| 173 | 181 | ***************************************************************************/ |
| 174 | 182 | |
| 175 | | static TIMER_CALLBACK(serial_callback); |
| 176 | 183 | static int z80dart_irq_state(const device_config *device); |
| 184 | static void z80dart_irq_reti(const device_config *device); |
| 177 | 185 | |
| 186 | /*************************************************************************** |
| 187 | INLINE FUNCTIONS |
| 188 | ***************************************************************************/ |
| 178 | 189 | |
| 190 | INLINE z80dart_t *get_safe_token(const device_config *device) |
| 191 | { |
| 192 | assert(device != NULL); |
| 193 | assert(device->token != NULL); |
| 194 | assert(device->type == Z80DART); |
| 195 | |
| 196 | return (z80dart_t *)device->token; |
| 197 | } |
| 179 | 198 | |
| 180 | | /* |
| 199 | /*************************************************************************** |
| 200 | CALLBACK INTERFACE MANAGEMENT |
| 201 | ***************************************************************************/ |
| 181 | 202 | |
| 182 | | Interrupt priorities: |
| 183 | | Ch A receive |
| 184 | | Ch A transmit |
| 185 | | Ch A external/status |
| 186 | | Ch B receive |
| 187 | | Ch B transmit |
| 188 | | Ch B external/status |
| 203 | static int z80dart_rxd_r(const device_config *device, int channel) |
| 204 | { |
| 205 | z80dart_t *z80dart = get_safe_token(device); |
| 189 | 206 | |
| 207 | int data = 1; |
| 190 | 208 | |
| 191 | | Initial configuration (both channels): |
| 192 | | 005D:dart_reg_w(0,4) = 44 |
| 193 | | 01 = x16 clock mode |
| 194 | | 00 = 8 bit sync character |
| 195 | | 01 = 1 stop bit/character |
| 196 | | Parity odd |
| 197 | | Parity disabled |
| 209 | if (z80dart->intf->rxd_r) |
| 210 | { |
| 211 | data = z80dart->intf->rxd_r(device, channel); |
| 212 | } |
| 198 | 213 | |
| 199 | | 005D:dart_reg_w(0,3) = C1 |
| 200 | | 11 = Rx 8 bits/character |
| 201 | | No auto enables |
| 202 | | No enter hunt phase |
| 203 | | No Rx CRC enable |
| 204 | | No address search mode |
| 205 | | No sync character load inhibit |
| 206 | | Rx enable |
| 214 | return data; |
| 215 | } |
| 207 | 216 | |
| 208 | | 005D:dart_reg_w(0,5) = 68 |
| 209 | | DTR = 0 |
| 210 | | 11 = Tx 8 bits/character |
| 211 | | No send break |
| 212 | | Tx enable |
| 213 | | SDLC |
| 214 | | No RTS |
| 215 | | No CRC enable |
| 217 | static void z80dart_txd_w(const device_config *device, int channel, int state) |
| 218 | { |
| 219 | z80dart_t *z80dart = get_safe_token(device); |
| 216 | 220 | |
| 217 | | 005D:dart_reg_w(0,2) = 40 |
| 218 | | Vector = 0x40 |
| 221 | if (z80dart->intf->on_txd_changed) |
| 222 | { |
| 223 | z80dart->intf->on_txd_changed(device, channel, state); |
| 224 | } |
| 225 | } |
| 219 | 226 | |
| 220 | | 005D:dart_reg_w(0,1) = 1D |
| 221 | | No READY/WAIT |
| 222 | | No READY/WAIT function |
| 223 | | No READY/WAIT on R/T |
| 224 | | 11 = int on all Rx characters (parity ignored) |
| 225 | | Status affects vector |
| 226 | | No Tx int enable |
| 227 | | Ext int enable |
| 227 | static void z80dart_rts_w(const device_config *device, int channel, int state) |
| 228 | { |
| 229 | z80dart_t *z80dart = get_safe_token(device); |
| 228 | 230 | |
| 229 | | */ |
| 231 | if (z80dart->intf->on_rts_changed) |
| 232 | { |
| 233 | z80dart->intf->on_rts_changed(device, channel, state); |
| 234 | } |
| 230 | 235 | |
| 236 | LOGERROR("Z80DART \"%s\" Channel %c : RTS %u\n", device->tag, 'A' + channel, state); |
| 237 | } |
| 231 | 238 | |
| 239 | static void z80dart_dtr_w(const device_config *device, int channel, int state) |
| 240 | { |
| 241 | z80dart_t *z80dart = get_safe_token(device); |
| 242 | |
| 243 | if (z80dart->intf->on_dtr_changed) |
| 244 | { |
| 245 | z80dart->intf->on_dtr_changed(device, channel, state); |
| 246 | } |
| 247 | |
| 248 | LOGERROR("Z80DART \"%s\" Channel %c : DTR %u\n", device->tag, 'A' + channel, state); |
| 249 | } |
| 250 | |
| 232 | 251 | /*************************************************************************** |
| 233 | | INLINE FUNCTIONS |
| 252 | INTERNAL STATE MANAGEMENT |
| 234 | 253 | ***************************************************************************/ |
| 235 | 254 | |
| 236 | | INLINE z80dart *get_safe_token(const device_config *device) |
| 255 | static void z80dart_check_interrupt(const device_config *device) |
| 237 | 256 | { |
| 238 | | assert(device != NULL); |
| 239 | | assert(device->token != NULL); |
| 240 | | assert(device->type == Z80DART); |
| 241 | | return (z80dart *)device->token; |
| 257 | z80dart_t *z80dart = get_safe_token(device); |
| 258 | int state = (z80dart_irq_state(device) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE; |
| 259 | |
| 260 | if (z80dart->intf->on_int_changed) |
| 261 | { |
| 262 | z80dart->intf->on_int_changed(device, state); |
| 263 | } |
| 242 | 264 | } |
| 243 | 265 | |
| 266 | static void z80dart_trigger_interrupt(const device_config *device, int channel, int level) |
| 267 | { |
| 268 | z80dart_t *z80dart = get_safe_token(device); |
| 269 | dart_channel *ch = &z80dart->channel[channel]; |
| 270 | UINT8 vector = ch->wr[2]; |
| 271 | int priority = (channel << 2) | level; |
| 244 | 272 | |
| 245 | | INLINE void interrupt_check(const device_config *device) |
| 273 | LOGERROR("Z80DART \"%s\" Channel %c : Interrupt Request %u\n", device->tag, 'A' + channel, level); |
| 274 | |
| 275 | if ((channel == Z80DART_CH_B) && (ch->wr[1] & Z80DART_WR1_STATUS_VECTOR)) |
| 276 | { |
| 277 | /* status affects vector */ |
| 278 | vector = (ch->wr[2] & 0xf1) | (!channel << 3) | (level << 1); |
| 279 | } |
| 280 | |
| 281 | /* update vector register */ |
| 282 | ch->rr[2] = vector; |
| 283 | |
| 284 | /* trigger interrupt */ |
| 285 | z80dart->int_state[priority] |= Z80_DAISY_INT; |
| 286 | z80dart->channel[Z80DART_CH_A].rr[0] |= Z80DART_RR0_INTERRUPT_PENDING; |
| 287 | |
| 288 | /* check for interrupt */ |
| 289 | z80dart_check_interrupt(device); |
| 290 | } |
| 291 | |
| 292 | static int z80dart_get_clock_mode(const device_config *device, int channel) |
| 246 | 293 | { |
| 247 | | z80dart *dart = get_safe_token( device ); |
| 294 | z80dart_t *z80dart = get_safe_token(device); |
| 295 | dart_channel *ch = &z80dart->channel[channel]; |
| 248 | 296 | |
| 249 | | /* if we have a callback, update it with the current state */ |
| 250 | | if (dart->irq_cb != NULL) |
| 251 | | dart->irq_cb(device, (z80dart_irq_state(device) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE); |
| 297 | int clocks = 1; |
| 298 | |
| 299 | switch (ch->wr[4] & Z80DART_WR4_CLOCK_MODE_MASK) |
| 300 | { |
| 301 | case Z80DART_WR4_CLOCK_MODE_X1: |
| 302 | clocks = 1; |
| 303 | |
| 304 | case Z80DART_WR4_CLOCK_MODE_X16: |
| 305 | clocks = 16; |
| 306 | |
| 307 | case Z80DART_WR4_CLOCK_MODE_X32: |
| 308 | clocks = 32; |
| 309 | |
| 310 | case Z80DART_WR4_CLOCK_MODE_X64: |
| 311 | clocks = 64; |
| 312 | } |
| 313 | |
| 314 | return clocks; |
| 252 | 315 | } |
| 253 | 316 | |
| 317 | static float z80dart_get_stop_bits(const device_config *device, int channel) |
| 318 | { |
| 319 | z80dart_t *z80dart = get_safe_token(device); |
| 320 | dart_channel *ch = &z80dart->channel[channel]; |
| 254 | 321 | |
| 255 | | INLINE attotime compute_time_per_character(const device_config *device, int ch) |
| 256 | | { |
| 257 | | /* fix me -- should compute properly and include data, stop, parity bits */ |
| 258 | | return ATTOTIME_IN_HZ(9600 / 10); |
| 322 | float bits = 1; |
| 323 | |
| 324 | switch (ch->wr[4] & Z80DART_WR4_STOP_BITS_MASK) |
| 325 | { |
| 326 | case Z80DART_WR4_STOP_BITS_1: |
| 327 | bits = 1; |
| 328 | |
| 329 | case Z80DART_WR4_STOP_BITS_1_5: |
| 330 | bits = 1.5; |
| 331 | |
| 332 | case Z80DART_WR4_STOP_BITS_2: |
| 333 | bits = 2; |
| 334 | } |
| 335 | |
| 336 | return bits; |
| 259 | 337 | } |
| 260 | 338 | |
| 261 | | |
| 262 | | INLINE void reset_channel(const device_config *device, int ch) |
| 339 | static int z80dart_get_rx_word_length(const device_config *device, int channel) |
| 263 | 340 | { |
| 264 | | z80dart *dart = get_safe_token( device ); |
| 265 | | attotime tpc = compute_time_per_character(device, ch); |
| 266 | | dart_channel *chan = &dart->chan[ch]; |
| 341 | z80dart_t *z80dart = get_safe_token(device); |
| 342 | dart_channel *ch = &z80dart->channel[channel]; |
| 267 | 343 | |
| 268 | | chan->status[0] = DART_RR0_TX_BUFFER_EMPTY; |
| 269 | | chan->status[1] = 0x00; |
| 270 | | chan->status[2] = 0x00; |
| 271 | | chan->int_on_next_rx = 0; |
| 272 | | chan->outbuf = -1; |
| 344 | int bits = 5; |
| 273 | 345 | |
| 274 | | dart->int_state[0 + 4*ch] = 0; |
| 275 | | dart->int_state[1 + 4*ch] = 0; |
| 276 | | dart->int_state[2 + 4*ch] = 0; |
| 277 | | dart->int_state[3 + 4*ch] = 0; |
| 346 | switch (ch->wr[3] & Z80DART_WR3_RX_WORD_LENGTH_MASK) |
| 347 | { |
| 348 | case Z80DART_WR3_RX_WORD_LENGTH_5: |
| 349 | bits = 5; |
| 278 | 350 | |
| 279 | | /* start the receive timer running */ |
| 280 | | timer_adjust_periodic(chan->receive_timer, tpc, ch, tpc); |
| 351 | case Z80DART_WR3_RX_WORD_LENGTH_6: |
| 352 | bits = 6; |
| 353 | |
| 354 | case Z80DART_WR3_RX_WORD_LENGTH_7: |
| 355 | bits = 7; |
| 356 | |
| 357 | case Z80DART_WR3_RX_WORD_LENGTH_8: |
| 358 | bits = 8; |
| 359 | } |
| 360 | |
| 361 | return bits; |
| 281 | 362 | } |
| 282 | 363 | |
| 364 | static int z80dart_get_tx_word_length(const device_config *device, int channel) |
| 365 | { |
| 366 | z80dart_t *z80dart = get_safe_token(device); |
| 367 | dart_channel *ch = &z80dart->channel[channel]; |
| 283 | 368 | |
| 369 | int bits = 5; |
| 284 | 370 | |
| 285 | | /*************************************************************************** |
| 286 | | CONTROL REGISTER READ/WRITE |
| 287 | | ***************************************************************************/ |
| 371 | switch (ch->wr[5] & Z80DART_WR5_TX_WORD_LENGTH_MASK) |
| 372 | { |
| 373 | case Z80DART_WR5_TX_WORD_LENGTH_5: |
| 374 | bits = 5; |
| 288 | 375 | |
| 289 | | /*------------------------------------------------- |
| 290 | | z80dart_c_w - write to a control register |
| 291 | | -------------------------------------------------*/ |
| 376 | case Z80DART_WR5_TX_WORD_LENGTH_6: |
| 377 | bits = 6; |
| 292 | 378 | |
| 293 | | WRITE8_DEVICE_HANDLER( z80dart_c_w ) |
| 379 | case Z80DART_WR5_TX_WORD_LENGTH_7: |
| 380 | bits = 7; |
| 381 | |
| 382 | case Z80DART_WR5_TX_WORD_LENGTH_8: |
| 383 | bits = 8; |
| 384 | } |
| 385 | |
| 386 | return bits; |
| 387 | } |
| 388 | |
| 389 | static void z80dart_reset_channel(const device_config *device, int channel) |
| 294 | 390 | { |
| 295 | | z80dart *dart = get_safe_token( device ); |
| 296 | | dart_channel *chan = &dart->chan[offset]; |
| 297 | | int reg = chan->regs[0] & 7; |
| 298 | | UINT8 old = chan->regs[reg]; |
| 391 | z80dart_t *z80dart = get_safe_token(device); |
| 392 | dart_channel *ch = &z80dart->channel[channel]; |
| 299 | 393 | |
| 300 | | if (reg != 0 || (reg & 0xf8)) |
| 301 | | VPRINTF(("%04X:dart_reg_w(%c,%d) = %02X\n", activecpu_get_pc(), 'A' + offset, reg, data)); |
| 394 | /* reset read registers */ |
| 395 | ch->rr[0] = Z80DART_RR0_TX_BUFFER_EMPTY; |
| 396 | ch->rr[1] = ch->rr[2] = 0; |
| 302 | 397 | |
| 303 | | /* write a new value to the selected register */ |
| 304 | | chan->regs[reg] = data; |
| 398 | /* reset write registers */ |
| 399 | ch->wr[0] = ch->wr[1] = ch->wr[2] = ch->wr[3] = ch->wr[4] = ch->wr[5] = 0; |
| 305 | 400 | |
| 306 | | /* clear the register number for the next write */ |
| 307 | | if (reg != 0) |
| 308 | | chan->regs[0] &= ~7; |
| 401 | /* reset receiver */ |
| 402 | ch->rx_shift = 0; |
| 403 | ch->rx_error = 0; |
| 404 | ch->rx_data_fifo[0] = ch->rx_data_fifo[1] = ch->rx_data_fifo[2] = 0; |
| 405 | ch->rx_error_fifo[0] = ch->rx_error_fifo[1] = ch->rx_error_fifo[2] = 0; |
| 406 | ch->rx_fifo = 0; |
| 407 | ch->rx_state = STATE_START; |
| 408 | ch->rx_bits = 0; |
| 409 | ch->rx_first = 1; |
| 410 | ch->rx_parity = 0; |
| 309 | 411 | |
| 310 | | /* switch off the register for live state changes */ |
| 311 | | switch (reg) |
| 412 | /* reset transmitter */ |
| 413 | ch->tx_data = 0; |
| 414 | ch->tx_shift = 0; |
| 415 | ch->tx_state = STATE_START; |
| 416 | ch->tx_bits = 0; |
| 417 | ch->tx_parity = 0; |
| 418 | |
| 419 | /* reset external lines */ |
| 420 | z80dart_rts_w(device, channel, 1); |
| 421 | z80dart_dtr_w(device, channel, 1); |
| 422 | |
| 423 | if (channel == Z80DART_CH_A) |
| 312 | 424 | { |
| 313 | | /* DART write register 0 */ |
| 314 | | case 0: |
| 315 | | switch (data & DART_WR0_COMMAND_MASK) |
| 316 | | { |
| 317 | | case DART_WR0_COMMAND_CH_RESET: |
| 318 | | VPRINTF(("%04X:DART reset channel %c\n", activecpu_get_pc(), 'A' + offset)); |
| 319 | | reset_channel(device, offset); |
| 320 | | interrupt_check(device); |
| 321 | | break; |
| 425 | /* reset interrupt logic */ |
| 426 | int i; |
| 322 | 427 | |
| 323 | | case DART_WR0_COMMAND_RES_STATUS_INT: |
| 324 | | dart->int_state[INT_CHA_STATUS - 4*offset] &= ~Z80_DAISY_INT; |
| 325 | | interrupt_check(device); |
| 326 | | break; |
| 428 | for (i = 0; i < 8; i++) |
| 429 | { |
| 430 | z80dart->int_state[i] = 0; |
| 431 | } |
| 327 | 432 | |
| 328 | | case DART_WR0_COMMAND_ENA_RX_INT: |
| 329 | | chan->int_on_next_rx = TRUE; |
| 330 | | interrupt_check(device); |
| 331 | | break; |
| 433 | z80dart_check_interrupt(device); |
| 434 | } |
| 435 | } |
| 332 | 436 | |
| 333 | | case DART_WR0_COMMAND_RES_TX_INT: |
| 334 | | dart->int_state[INT_CHA_TRANSMIT - 4*offset] &= ~Z80_DAISY_INT; |
| 335 | | interrupt_check(device); |
| 336 | | break; |
| 437 | /*************************************************************************** |
| 438 | SERIAL RECEIVE |
| 439 | ***************************************************************************/ |
| 337 | 440 | |
| 338 | | case DART_WR0_COMMAND_RES_ERROR: |
| 339 | | dart->int_state[INT_CHA_ERROR - 4*offset] &= ~Z80_DAISY_INT; |
| 340 | | interrupt_check(device); |
| 341 | | break; |
| 342 | | } |
| 343 | | break; |
| 441 | static int detect_start_bit(const device_config *device, int channel) |
| 442 | { |
| 443 | z80dart_t *z80dart = get_safe_token(device); |
| 444 | dart_channel *ch = &z80dart->channel[channel]; |
| 445 | |
| 446 | if (!(ch->wr[3] & Z80DART_WR3_RX_ENABLE)) |
| 447 | return 0; |
| 344 | 448 | |
| 345 | | /* DART write register 1 */ |
| 346 | | case 1: |
| 347 | | interrupt_check(device); |
| 348 | | break; |
| 449 | return !z80dart_rxd_r(device, channel); |
| 450 | } |
| 349 | 451 | |
| 350 | | /* DART write register 5 */ |
| 351 | | case 5: |
| 352 | | if (((old ^ data) & DART_WR5_DTR) && dart->dtr_changed_cb) |
| 353 | | (*dart->dtr_changed_cb)(device, offset, (data & DART_WR5_DTR) != 0); |
| 354 | | if (((old ^ data) & DART_WR5_SEND_BREAK) && dart->break_changed_cb) |
| 355 | | (*dart->break_changed_cb)(device, offset, (data & DART_WR5_SEND_BREAK) != 0); |
| 356 | | if (((old ^ data) & DART_WR5_RTS) && dart->rts_changed_cb) |
| 357 | | (*dart->rts_changed_cb)(device, offset, (data & DART_WR5_RTS) != 0); |
| 358 | | break; |
| 452 | static void shift_data_in(const device_config *device, int channel) |
| 453 | { |
| 454 | z80dart_t *z80dart = get_safe_token(device); |
| 455 | dart_channel *ch = &z80dart->channel[channel]; |
| 456 | |
| 457 | if (ch->rx_bits < 8) |
| 458 | { |
| 459 | int rxd = z80dart_rxd_r(device, channel); |
| 460 | |
| 461 | ch->rx_shift >>= 1; |
| 462 | ch->rx_shift = (rxd << 7) | (ch->rx_shift & 0x7f); |
| 463 | ch->rx_parity ^= rxd; |
| 464 | ch->rx_bits++; |
| 359 | 465 | } |
| 360 | 466 | } |
| 361 | 467 | |
| 468 | static int character_completed(const device_config *device, int channel) |
| 469 | { |
| 470 | z80dart_t *z80dart = get_safe_token(device); |
| 471 | dart_channel *ch = &z80dart->channel[channel]; |
| 362 | 472 | |
| 363 | | /*------------------------------------------------- |
| 364 | | z80dart_c_r - read from a control register |
| 365 | | -------------------------------------------------*/ |
| 473 | return ch->rx_bits == z80dart_get_rx_word_length(device, channel); |
| 474 | } |
| 366 | 475 | |
| 367 | | READ8_DEVICE_HANDLER( z80dart_c_r ) |
| 476 | static void detect_parity_error(const device_config *device, int channel) |
| 368 | 477 | { |
| 369 | | z80dart *dart = get_safe_token( device ); |
| 370 | | dart_channel *chan = &dart->chan[offset]; |
| 371 | | int reg = chan->regs[0] & 7; |
| 372 | | UINT8 result = chan->status[reg]; |
| 478 | z80dart_t *z80dart = get_safe_token(device); |
| 479 | dart_channel *ch = &z80dart->channel[channel]; |
| 480 | |
| 481 | int rxd = z80dart_rxd_r(device, channel); |
| 482 | int parity = (ch->wr[1] & Z80DART_WR4_PARITY_EVEN) ? 1 : 0; |
| 373 | 483 | |
| 374 | | /* switch off the register for live state changes */ |
| 375 | | switch (reg) |
| 484 | if (rxd != (ch->rx_parity ^ parity)) |
| 376 | 485 | { |
| 377 | | /* DART read register 0 */ |
| 378 | | case 0: |
| 379 | | result &= ~DART_RR0_INT_PENDING; |
| 380 | | if (z80dart_irq_state(device) & Z80_DAISY_INT) |
| 381 | | result |= DART_RR0_INT_PENDING; |
| 486 | /* parity error detected */ |
| 487 | ch->rx_error |= Z80DART_RR1_PARITY_ERROR; |
| 488 | |
| 489 | switch (ch->wr[1] & Z80DART_WR1_RX_INT_ENABLE_MASK) |
| 490 | { |
| 491 | case Z80DART_WR1_RX_INT_FIRST: |
| 492 | if (!ch->rx_first) |
| 493 | { |
| 494 | z80dart_trigger_interrupt(device, channel, INT_SPECIAL); |
| 495 | } |
| 382 | 496 | break; |
| 497 | |
| 498 | case Z80DART_WR1_RX_INT_ALL_PARITY: |
| 499 | z80dart_trigger_interrupt(device, channel, INT_SPECIAL); |
| 500 | break; |
| 501 | |
| 502 | case Z80DART_WR1_RX_INT_ALL: |
| 503 | z80dart_trigger_interrupt(device, channel, INT_RECEIVE); |
| 504 | break; |
| 505 | } |
| 383 | 506 | } |
| 507 | } |
| 384 | 508 | |
| 385 | | VPRINTF(("%04X:dart_reg_r(%c,%d) = %02x\n", activecpu_get_pc(), 'A' + offset, reg, chan->status[reg])); |
| 509 | static void detect_framing_error(const device_config *device, int channel) |
| 510 | { |
| 511 | z80dart_t *z80dart = get_safe_token(device); |
| 512 | dart_channel *ch = &z80dart->channel[channel]; |
| 513 | |
| 514 | int rxd = z80dart_rxd_r(device, channel); |
| 386 | 515 | |
| 387 | | return chan->status[reg]; |
| 516 | if (!rxd) |
| 517 | { |
| 518 | /* framing error detected */ |
| 519 | ch->rx_error |= Z80DART_RR1_FRAMING_ERROR; |
| 520 | |
| 521 | switch (ch->wr[1] & Z80DART_WR1_RX_INT_ENABLE_MASK) |
| 522 | { |
| 523 | case Z80DART_WR1_RX_INT_FIRST: |
| 524 | if (!ch->rx_first) |
| 525 | { |
| 526 | z80dart_trigger_interrupt(device, channel, INT_SPECIAL); |
| 527 | } |
| 528 | break; |
| 529 | |
| 530 | case Z80DART_WR1_RX_INT_ALL_PARITY: |
| 531 | case Z80DART_WR1_RX_INT_ALL: |
| 532 | z80dart_trigger_interrupt(device, channel, INT_SPECIAL); |
| 533 | break; |
| 534 | } |
| 535 | } |
| 388 | 536 | } |
| 389 | 537 | |
| 538 | static void receive(const device_config *device, int channel) |
| 539 | { |
| 540 | z80dart_t *z80dart = get_safe_token(device); |
| 541 | dart_channel *ch = &z80dart->channel[channel]; |
| 542 | |
| 543 | float stop_bits = z80dart_get_stop_bits(device, channel); |
| 390 | 544 | |
| 545 | switch (ch->rx_state) |
| 546 | { |
| 547 | case STATE_START: |
| 548 | /* check for start bit */ |
| 549 | if (detect_start_bit(device, channel)) |
| 550 | { |
| 551 | /* start bit detected */ |
| 552 | ch->rx_shift = 0; |
| 553 | ch->rx_error = 0; |
| 554 | ch->rx_bits = 0; |
| 555 | ch->rx_parity = 0; |
| 391 | 556 | |
| 557 | /* next bit is a data bit */ |
| 558 | ch->rx_state = STATE_DATA; |
| 559 | } |
| 560 | break; |
| 392 | 561 | |
| 562 | case STATE_DATA: |
| 563 | /* shift bit into shift register */ |
| 564 | shift_data_in(device, channel); |
| 565 | |
| 566 | if (character_completed(device, channel)) |
| 567 | { |
| 568 | /* all data bits received */ |
| 569 | if (ch->wr[4] & Z80DART_WR4_PARITY_ENABLE) |
| 570 | { |
| 571 | /* next bit is the parity bit */ |
| 572 | ch->rx_state = STATE_PARITY; |
| 573 | } |
| 574 | else |
| 575 | { |
| 576 | /* next bit is a STOP bit */ |
| 577 | if (stop_bits == 1) |
| 578 | ch->rx_state = STATE_STOP2; |
| 579 | else |
| 580 | ch->rx_state = STATE_STOP; |
| 581 | } |
| 582 | } |
| 583 | break; |
| 584 | |
| 585 | case STATE_PARITY: |
| 586 | /* shift bit into shift register */ |
| 587 | shift_data_in(device, channel); |
| 588 | |
| 589 | /* check for parity error */ |
| 590 | detect_parity_error(device, channel); |
| 591 | |
| 592 | /* next bit is a STOP bit */ |
| 593 | if (stop_bits == 1) |
| 594 | ch->rx_state = STATE_STOP2; |
| 595 | else |
| 596 | ch->rx_state = STATE_STOP; |
| 597 | break; |
| 598 | |
| 599 | case STATE_STOP: |
| 600 | /* shift bit into shift register */ |
| 601 | shift_data_in(device, channel); |
| 602 | |
| 603 | /* check for framing error */ |
| 604 | detect_framing_error(device, channel); |
| 605 | |
| 606 | /* next bit is the second STOP bit */ |
| 607 | ch->rx_state = STATE_STOP2; |
| 608 | break; |
| 609 | |
| 610 | case STATE_STOP2: |
| 611 | /* shift bit into shift register */ |
| 612 | shift_data_in(device, channel); |
| 613 | |
| 614 | /* check for framing error */ |
| 615 | detect_framing_error(device, channel); |
| 616 | |
| 617 | /* store data into FIFO */ |
| 618 | z80dart_receive_data(device, channel, ch->rx_shift); |
| 619 | |
| 620 | /* next bit is the START bit */ |
| 621 | ch->rx_state = STATE_START; |
| 622 | break; |
| 623 | } |
| 624 | } |
| 625 | |
| 393 | 626 | /*************************************************************************** |
| 394 | | DATA REGISTER READ/WRITE |
| 627 | SERIAL TRANSMIT |
| 395 | 628 | ***************************************************************************/ |
| 396 | 629 | |
| 397 | | /*------------------------------------------------- |
| 398 | | z80dart_d_w - write to a data register |
| 399 | | -------------------------------------------------*/ |
| 630 | #define TXD(state) z80dart_txd_w(device, channel, 1); |
| 400 | 631 | |
| 401 | | WRITE8_DEVICE_HANDLER( z80dart_d_w ) |
| 632 | static void transmit(const device_config *device, int channel) |
| 402 | 633 | { |
| 403 | | z80dart *dart = get_safe_token( device ); |
| 404 | | dart_channel *chan = &dart->chan[offset]; |
| 634 | z80dart_t *z80dart = get_safe_token(device); |
| 635 | dart_channel *ch = &z80dart->channel[channel]; |
| 636 | |
| 637 | int word_length = z80dart_get_tx_word_length(device, channel); |
| 638 | float stop_bits = z80dart_get_stop_bits(device, channel); |
| 405 | 639 | |
| 406 | | VPRINTF(("%04X:dart_data_w(%c) = %02X\n", activecpu_get_pc(), 'A' + offset, data)); |
| 640 | switch (ch->tx_state) |
| 641 | { |
| 642 | case STATE_START: |
| 643 | if ((ch->wr[5] & Z80DART_WR5_TX_ENABLE) && !(ch->rr[0] & Z80DART_RR0_TX_BUFFER_EMPTY)) |
| 644 | { |
| 645 | /* transmit start bit */ |
| 646 | TXD(0); |
| 407 | 647 | |
| 408 | | /* if tx not enabled, just ignore it */ |
| 409 | | if (!(chan->regs[5] & DART_WR5_TX_ENABLE)) |
| 410 | | return; |
| 648 | ch->tx_bits = 0; |
| 649 | ch->tx_shift = ch->tx_data; |
| 411 | 650 | |
| 412 | | /* update the status register */ |
| 413 | | chan->status[0] &= ~DART_RR0_TX_BUFFER_EMPTY; |
| 651 | /* empty transmit buffer */ |
| 652 | ch->rr[0] |= Z80DART_RR0_TX_BUFFER_EMPTY; |
| 414 | 653 | |
| 415 | | /* reset the transmit interrupt */ |
| 416 | | dart->int_state[INT_CHA_TRANSMIT - 4*offset] &= ~Z80_DAISY_INT; |
| 417 | | interrupt_check(device); |
| 654 | if (ch->wr[1] & Z80DART_WR1_TX_INT_ENABLE) |
| 655 | z80dart_trigger_interrupt(device, channel, INT_TRANSMIT); |
| 418 | 656 | |
| 419 | | /* stash the character */ |
| 420 | | chan->outbuf = data; |
| 421 | | } |
| 657 | ch->tx_state = STATE_DATA; |
| 658 | } |
| 659 | else if (ch->wr[5] & Z80DART_WR5_SEND_BREAK) |
| 660 | { |
| 661 | /* transmit break */ |
| 662 | TXD(0); |
| 663 | } |
| 664 | else |
| 665 | { |
| 666 | /* transmit marking line */ |
| 667 | TXD(1); |
| 668 | } |
| 422 | 669 | |
| 670 | break; |
| 423 | 671 | |
| 424 | | /*------------------------------------------------- |
| 425 | | z80dart_d_r - read from a data register |
| 426 | | -------------------------------------------------*/ |
| 672 | case STATE_DATA: |
| 673 | /* transmit data bit */ |
| 674 | TXD(BIT(ch->tx_shift, 0)); |
| 427 | 675 | |
| 428 | | READ8_DEVICE_HANDLER( z80dart_d_r ) |
| 429 | | { |
| 430 | | z80dart *dart = get_safe_token( device ); |
| 431 | | dart_channel *chan = &dart->chan[offset]; |
| 676 | /* shift data */ |
| 677 | ch->tx_shift >>= 1; |
| 678 | ch->tx_bits++; |
| 432 | 679 | |
| 433 | | /* update the status register */ |
| 434 | | chan->status[0] &= ~DART_RR0_RX_CHAR_AVAILABLE; |
| 680 | if (ch->rx_bits == word_length) |
| 681 | { |
| 682 | if (ch->wr[4] & Z80DART_WR4_PARITY_ENABLE) |
| 683 | ch->tx_state = STATE_PARITY; |
| 684 | else |
| 685 | { |
| 686 | if (stop_bits == 1) |
| 687 | ch->tx_state = STATE_STOP2; |
| 688 | else |
| 689 | ch->tx_state = STATE_STOP; |
| 690 | } |
| 691 | } |
| 692 | break; |
| 435 | 693 | |
| 436 | | /* reset the receive interrupt */ |
| 437 | | dart->int_state[INT_CHA_RECEIVE - 4*offset] &= ~Z80_DAISY_INT; |
| 438 | | interrupt_check(device); |
| 694 | case STATE_PARITY: |
| 695 | // TODO: calculate parity |
| 696 | if (stop_bits == 1) |
| 697 | ch->tx_state = STATE_STOP2; |
| 698 | else |
| 699 | ch->tx_state = STATE_STOP; |
| 700 | break; |
| 439 | 701 | |
| 440 | | VPRINTF(("%04X:dart_data_r(%c) = %02X\n", activecpu_get_pc(), 'A' + offset, chan->inbuf)); |
| 702 | case STATE_STOP: |
| 703 | /* transmit stop bit */ |
| 704 | TXD(1); |
| 441 | 705 | |
| 442 | | return chan->inbuf; |
| 443 | | } |
| 706 | ch->tx_state = STATE_STOP2; |
| 707 | break; |
| 444 | 708 | |
| 709 | case STATE_STOP2: |
| 710 | /* transmit stop bit */ |
| 711 | TXD(1); |
| 445 | 712 | |
| 713 | /* if transmit buffer is empty */ |
| 714 | if (ch->rr[0] & Z80DART_RR0_TX_BUFFER_EMPTY) |
| 715 | { |
| 716 | /* then all characters have been sent */ |
| 717 | ch->rr[1] |= Z80DART_RR1_ALL_SENT; |
| 446 | 718 | |
| 719 | /* when the RTS bit is reset, the _RTS output goes high after the transmitter empties */ |
| 720 | if (!ch->rts) |
| 721 | z80dart_rts_w(device, channel, 1); |
| 722 | } |
| 723 | |
| 724 | ch->tx_state = STATE_START; |
| 725 | break; |
| 726 | } |
| 727 | } |
| 728 | |
| 447 | 729 | /*************************************************************************** |
| 448 | | CONTROL LINE READ/WRITE |
| 730 | CONTROL REGISTER READ/WRITE |
| 449 | 731 | ***************************************************************************/ |
| 450 | 732 | |
| 451 | | /*------------------------------------------------- |
| 452 | | z80dart_get_dtr - return the state of the DTR |
| 453 | | line |
| 454 | | -------------------------------------------------*/ |
| 455 | | |
| 456 | | int z80dart_get_dtr(const device_config *device, int ch) |
| 733 | READ8_DEVICE_HANDLER( z80dart_c_r ) |
| 457 | 734 | { |
| 458 | | z80dart *dart = get_safe_token( device ); |
| 459 | | dart_channel *chan = &dart->chan[ch]; |
| 460 | | return ((chan->regs[5] & DART_WR5_DTR) != 0); |
| 461 | | } |
| 735 | z80dart_t *z80dart = get_safe_token(device); |
| 736 | int channel = offset & 0x01; |
| 737 | dart_channel *ch = &z80dart->channel[channel]; |
| 738 | UINT8 data = 0; |
| 462 | 739 | |
| 740 | int reg = ch->wr[0] & Z80DART_WR0_REGISTER_MASK; |
| 463 | 741 | |
| 464 | | /*------------------------------------------------- |
| 465 | | z80dart_get_rts - return the state of the RTS |
| 466 | | line |
| 467 | | -------------------------------------------------*/ |
| 742 | switch (reg) |
| 743 | { |
| 744 | case 0: |
| 745 | case 1: |
| 746 | data = ch->rr[reg]; |
| 747 | break; |
| 468 | 748 | |
| 469 | | int z80dart_get_rts(const device_config *device, int ch) |
| 470 | | { |
| 471 | | z80dart *dart = get_safe_token( device ); |
| 472 | | dart_channel *chan = &dart->chan[ch]; |
| 473 | | return ((chan->regs[5] & DART_WR5_RTS) != 0); |
| 474 | | } |
| 749 | case 2: |
| 750 | /* channel B only */ |
| 751 | data = z80dart->channel[Z80DART_CH_B].rr[reg]; |
| 752 | break; |
| 753 | } |
| 475 | 754 | |
| 755 | LOGERROR("Z80DART \"%s\" Channel %c : Control Register Read '%02x'\n", device->tag, 'A' + channel, data); |
| 476 | 756 | |
| 477 | | /*------------------------------------------------- |
| 478 | | z80dart_set_cts - set the state of the CTS |
| 479 | | line |
| 480 | | -------------------------------------------------*/ |
| 757 | return data; |
| 758 | } |
| 481 | 759 | |
| 482 | | static TIMER_CALLBACK(change_input_line) |
| 760 | WRITE8_DEVICE_HANDLER( z80dart_c_w ) |
| 483 | 761 | { |
| 484 | | const device_config *device = ptr; |
| 485 | | z80dart *dart = get_safe_token( device ); |
| 486 | | dart_channel *chan = &dart->chan[param & 1]; |
| 487 | | UINT8 line = (param >> 8) & 0xff; |
| 488 | | int state = (param >> 7) & 1; |
| 489 | | int ch = param & 1; |
| 490 | | UINT8 old; |
| 491 | | char linename[4]; |
| 762 | z80dart_t *z80dart = get_safe_token(device); |
| 763 | int channel = offset & 0x01; |
| 764 | dart_channel *ch = &z80dart->channel[channel]; |
| 492 | 765 | |
| 493 | | switch (line) |
| 766 | int reg = ch->wr[0] & Z80DART_WR0_REGISTER_MASK; |
| 767 | |
| 768 | LOGERROR("Z80DART \"%s\" Channel %c : Control Register Write '%02x'\n", device->tag, 'A' + channel, data); |
| 769 | |
| 770 | /* write data to selected register */ |
| 771 | ch->wr[reg] = data; |
| 772 | |
| 773 | if (reg != 0) |
| 494 | 774 | { |
| 495 | | case DART_RR0_CTS: |
| 496 | | sprintf(linename, "%s", "CTS"); |
| 775 | /* mask out register index */ |
| 776 | ch->wr[0] &= ~Z80DART_WR0_REGISTER_MASK; |
| 777 | } |
| 778 | |
| 779 | switch (reg) |
| 780 | { |
| 781 | case 0: |
| 782 | switch (data & Z80DART_WR0_COMMAND_MASK) |
| 783 | { |
| 784 | case Z80DART_WR0_RESET_EXT_STATUS: |
| 785 | /* reset external/status interrupt */ |
| 786 | ch->rr[0] &= ~(Z80DART_RR0_DCD | Z80DART_RR0_RI | Z80DART_RR0_CTS | Z80DART_RR0_BREAK); |
| 787 | LOGERROR("Z80DART \"%s\" Channel %c : Reset External/Status Interrupt\n", device->tag, 'A' + channel); |
| 788 | break; |
| 789 | |
| 790 | case Z80DART_WR0_CHANNEL_RESET: |
| 791 | /* channel reset */ |
| 792 | LOGERROR("Z80DART \"%s\" Channel %c : Channel Reset\n", device->tag, 'A' + channel); |
| 793 | z80dart_reset_channel(device, channel); |
| 794 | break; |
| 795 | |
| 796 | case Z80DART_WR0_ENABLE_INT_NEXT_RX: |
| 797 | /* enable interrupt on next receive character */ |
| 798 | LOGERROR("Z80DART \"%s\" Channel %c : Enable Interrupt on Next Received Character\n", device->tag, 'A' + channel); |
| 799 | ch->rx_first = 1; |
| 800 | break; |
| 801 | |
| 802 | case Z80DART_WR0_RESET_TX_INT: |
| 803 | /* reset transmitter interrupt pending */ |
| 804 | LOGERROR("Z80DART \"%s\" Channel %c : Reset Transmitter Interrupt Pending\n", device->tag, 'A' + channel); |
| 805 | break; |
| 806 | |
| 807 | case Z80DART_WR0_ERROR_RESET: |
| 808 | /* error reset */ |
| 809 | LOGERROR("Z80DART \"%s\" Channel %c : Error Reset\n", device->tag, 'A' + channel); |
| 810 | ch->rr[1] &= ~(Z80DART_RR1_FRAMING_ERROR | Z80DART_RR1_RX_OVERRUN_ERROR | Z80DART_RR1_PARITY_ERROR); |
| 811 | break; |
| 812 | |
| 813 | case Z80DART_WR0_RETURN_FROM_INT: |
| 814 | /* return from interrupt */ |
| 815 | LOGERROR("Z80DART \"%s\" Channel %c : Return from Interrupt\n", device->tag, 'A' + channel); |
| 816 | z80dart_irq_reti(device); |
| 817 | break; |
| 818 | } |
| 497 | 819 | break; |
| 498 | | case DART_RR0_DCD: |
| 499 | | sprintf(linename, "%s", "DCD"); |
| 820 | |
| 821 | case 1: |
| 822 | LOGERROR("Z80DART \"%s\" Channel %c : External Interrupt Enable %u\n", device->tag, 'A' + channel, (data & Z80DART_WR1_EXT_INT_ENABLE) ? 1 : 0); |
| 823 | LOGERROR("Z80DART \"%s\" Channel %c : Transmit Interrupt Enable %u\n", device->tag, 'A' + channel, (data & Z80DART_WR1_TX_INT_ENABLE) ? 1 : 0); |
| 824 | LOGERROR("Z80DART \"%s\" Channel %c : Status Affects Vector %u\n", device->tag, 'A' + channel, (data & Z80DART_WR1_STATUS_VECTOR) ? 1 : 0); |
| 825 | LOGERROR("Z80DART \"%s\" Channel %c : Wait/Ready Enable %u\n", device->tag, 'A' + channel, (data & Z80DART_WR1_WRDY_ENABLE) ? 1 : 0); |
| 826 | |
| 827 | switch (data & Z80DART_WR1_RX_INT_ENABLE_MASK) |
| 828 | { |
| 829 | case Z80DART_WR1_RX_INT_DISABLE: |
| 830 | LOGERROR("Z80DART \"%s\" Channel %c : Receiver Interrupt Disabled\n", device->tag, 'A' + channel); |
| 831 | break; |
| 832 | |
| 833 | case Z80DART_WR1_RX_INT_FIRST: |
| 834 | LOGERROR("Z80DART \"%s\" Channel %c : Receiver Interrupt on First Character\n", device->tag, 'A' + channel); |
| 835 | break; |
| 836 | |
| 837 | case Z80DART_WR1_RX_INT_ALL_PARITY: |
| 838 | LOGERROR("Z80DART \"%s\" Channel %c : Receiver Interrupt on All Characters, Parity Affects Vector\n", device->tag, 'A' + channel); |
| 839 | break; |
| 840 | |
| 841 | case Z80DART_WR1_RX_INT_ALL: |
| 842 | LOGERROR("Z80DART \"%s\" Channel %c : Receiver Interrupt on All Characters\n", device->tag, 'A' + channel); |
| 843 | break; |
| 844 | } |
| 845 | |
| 846 | z80dart_check_interrupt(device); |
| 500 | 847 | break; |
| 501 | | case DART_RR0_RI: |
| 502 | | sprintf(linename, "%s", "RI"); |
| 848 | |
| 849 | case 2: |
| 850 | /* interrupt vector */ |
| 851 | z80dart_check_interrupt(device); |
| 852 | LOGERROR("Z80DART \"%s\" Channel %c : Interrupt Vector %02x\n", device->tag, 'A' + channel, data); |
| 503 | 853 | break; |
| 504 | | } |
| 505 | | VPRINTF(("dart_change_input_line(%c, %s) = %d\n", 'A' + ch, linename, state)); |
| 506 | 854 | |
| 507 | | /* remember the old value */ |
| 508 | | old = chan->status[0]; |
| 855 | case 3: |
| 856 | LOGERROR("Z80DART \"%s\" Channel %c : Receiver Enable %u\n", device->tag, 'A' + channel, (data & Z80DART_WR3_RX_ENABLE) ? 1 : 0); |
| 857 | LOGERROR("Z80DART \"%s\" Channel %c : Auto Enables %u\n", device->tag, 'A' + channel, (data & Z80DART_WR3_AUTO_ENABLES) ? 1 : 0); |
| 858 | LOGERROR("Z80DART \"%s\" Channel %c : Receiver Bits/Character %u\n", device->tag, 'A' + channel, z80dart_get_rx_word_length(device, channel)); |
| 859 | break; |
| 509 | 860 | |
| 510 | | /* set the bit in the status register */ |
| 511 | | chan->status[0] &= ~line; |
| 512 | | if (state) |
| 513 | | chan->status[0] |= line; |
| 861 | case 4: |
| 862 | LOGERROR("Z80DART \"%s\" Channel %c : Parity Enable %u\n", device->tag, 'A' + channel, (data & Z80DART_WR4_PARITY_ENABLE) ? 1 : 0); |
| 863 | LOGERROR("Z80DART \"%s\" Channel %c : Parity %s\n", device->tag, 'A' + channel, (data & Z80DART_WR4_PARITY_EVEN) ? "Even" : "Odd"); |
| 864 | LOGERROR("Z80DART \"%s\" Channel %c : Stop Bits %f\n", device->tag, 'A' + channel, z80dart_get_stop_bits(device, channel)); |
| 865 | LOGERROR("Z80DART \"%s\" Channel %c : Clock Mode %uX\n", device->tag, 'A' + channel, z80dart_get_clock_mode(device, channel)); |
| 866 | break; |
| 514 | 867 | |
| 515 | | /* if state change interrupts are enabled, signal */ |
| 516 | | if (((old ^ chan->status[0]) & line) && (chan->regs[1] & DART_WR1_STATUSINT_ENABLE)) |
| 517 | | { |
| 518 | | dart->int_state[INT_CHA_STATUS - 4*ch] |= Z80_DAISY_INT; |
| 519 | | interrupt_check(device); |
| 868 | case 5: |
| 869 | LOGERROR("Z80DART \"%s\" Channel %c : Transmitter Enable %u\n", device->tag, 'A' + channel, (data & Z80DART_WR5_TX_ENABLE) ? 1 : 0); |
| 870 | LOGERROR("Z80DART \"%s\" Channel %c : Transmitter Bits/Character %u\n", device->tag, 'A' + channel, z80dart_get_tx_word_length(device, channel)); |
| 871 | LOGERROR("Z80DART \"%s\" Channel %c : Send Break %u\n", device->tag, 'A' + channel, (data & Z80DART_WR5_SEND_BREAK) ? 1 : 0); |
| 872 | LOGERROR("Z80DART \"%s\" Channel %c : Request to Send %u\n", device->tag, 'A' + channel, (data & Z80DART_WR5_RTS) ? 1 : 0); |
| 873 | LOGERROR("Z80DART \"%s\" Channel %c : Data Terminal Ready %u\n", device->tag, 'A' + channel, (data & Z80DART_WR5_DTR) ? 1 : 0); |
| 874 | |
| 875 | if (data & Z80DART_WR5_RTS) |
| 876 | { |
| 877 | /* when the RTS bit is set, the _RTS output goes low */ |
| 878 | z80dart_rts_w(device, channel, 0); |
| 879 | |
| 880 | ch->rts = 1; |
| 881 | } |
| 882 | else |
| 883 | { |
| 884 | /* when the RTS bit is reset, the _RTS output goes high after the transmitter empties */ |
| 885 | ch->rts = 0; |
| 886 | } |
| 887 | |
| 888 | /* data terminal ready output follows the state programmed into the DTR bit*/ |
| 889 | ch->dtr = (data & Z80DART_WR5_DTR) ? 0 : 1; |
| 890 | z80dart_dtr_w(device, channel, ch->dtr); |
| 891 | break; |
| 520 | 892 | } |
| 521 | 893 | } |
| 522 | 894 | |
| 895 | /*************************************************************************** |
| 896 | DATA REGISTER READ/WRITE |
| 897 | ***************************************************************************/ |
| 523 | 898 | |
| 524 | | /*------------------------------------------------- |
| 525 | | z80dart_set_cts - set the state of the CTS |
| 526 | | line |
| 527 | | -------------------------------------------------*/ |
| 528 | | |
| 529 | | void z80dart_set_cts(const device_config *device, int ch, int state) |
| 899 | READ8_DEVICE_HANDLER( z80dart_d_r ) |
| 530 | 900 | { |
| 531 | | /* operate deferred */ |
| 532 | | timer_set(attotime_zero, (void *)device, (DART_RR0_CTS << 8) + (state != 0) * 0x80 + ch, change_input_line); |
| 533 | | } |
| 901 | z80dart_t *z80dart = get_safe_token(device); |
| 902 | int channel = offset & 0x01; |
| 903 | dart_channel *ch = &z80dart->channel[channel]; |
| 904 | UINT8 data = 0; |
| 534 | 905 | |
| 906 | if (ch->rx_fifo >= 0) |
| 907 | { |
| 908 | /* load data from the FIFO */ |
| 909 | data = ch->rx_data_fifo[ch->rx_fifo]; |
| 535 | 910 | |
| 536 | | /*------------------------------------------------- |
| 537 | | z80dart_set_dcd - set the state of the DCD |
| 538 | | line |
| 539 | | -------------------------------------------------*/ |
| 911 | /* load error status from the FIFO, retain overrun and parity errors */ |
| 912 | ch->rr[1] = (ch->rr[1] & (Z80DART_RR1_RX_OVERRUN_ERROR | Z80DART_RR1_PARITY_ERROR)) | ch->rx_error_fifo[ch->rx_fifo]; |
| 540 | 913 | |
| 541 | | void z80dart_set_dcd(const device_config *device, int ch, int state) |
| 542 | | { |
| 543 | | /* operate deferred */ |
| 544 | | timer_set(attotime_zero, (void *)device, (DART_RR0_DCD << 8) + (state != 0) * 0x80 + ch, change_input_line); |
| 914 | /* decrease FIFO pointer */ |
| 915 | ch->rx_fifo--; |
| 916 | |
| 917 | if (ch->rx_fifo < 0) |
| 918 | { |
| 919 | /* no more characters available in the FIFO */ |
| 920 | ch->rr[0] &= ~ Z80DART_RR0_RX_CHAR_AVAILABLE; |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | LOGERROR("Z80DART \"%s\" Channel %c : Data Register Read '%02x'\n", device->tag, 'A' + channel, data); |
| 925 | |
| 926 | return data; |
| 545 | 927 | } |
| 546 | 928 | |
| 929 | WRITE8_DEVICE_HANDLER( z80dart_d_w ) |
| 930 | { |
| 931 | z80dart_t *z80dart = get_safe_token(device); |
| 932 | int channel = offset & 0x01; |
| 933 | dart_channel *ch = &z80dart->channel[channel]; |
| 547 | 934 | |
| 548 | | /*------------------------------------------------- |
| 549 | | z80dart_set_ri - set the state of the RIA |
| 550 | | line |
| 551 | | -------------------------------------------------*/ |
| 935 | ch->tx_data = data; |
| 936 | |
| 937 | ch->rr[0] &= ~Z80DART_RR0_TX_BUFFER_EMPTY; |
| 938 | ch->rr[1] &= ~Z80DART_RR1_ALL_SENT; |
| 552 | 939 | |
| 553 | | void z80dart_set_ri(const device_config *device, int ch, int state) |
| 554 | | { |
| 555 | | /* operate deferred */ |
| 556 | | timer_set(attotime_zero, (void *)device, (DART_RR0_RI << 8) + (state != 0) * 0x80 + ch, change_input_line); |
| 940 | LOGERROR("Z80DART \"%s\" Channel %c : Data Register Write '%02x'\n", device->tag, 'A' + channel, data); |
| 557 | 941 | } |
| 558 | 942 | |
| 943 | /*************************************************************************** |
| 944 | CONTROL LINE READ/WRITE |
| 945 | ***************************************************************************/ |
| 559 | 946 | |
| 560 | | /*------------------------------------------------- |
| 561 | | z80dart_receive_data - receive data on the |
| 562 | | input lines |
| 563 | | -------------------------------------------------*/ |
| 564 | | |
| 565 | | void z80dart_receive_data(const device_config *device, int ch, UINT8 data) |
| 947 | void z80dart_receive_data(const device_config *device, int channel, UINT8 data) |
| 566 | 948 | { |
| 567 | | z80dart *dart = get_safe_token( device ); |
| 568 | | dart_channel *chan = &dart->chan[ch]; |
| 569 | | int newinptr; |
| 949 | z80dart_t *z80dart = get_safe_token(device); |
| 950 | dart_channel *ch = &z80dart->channel[channel]; |
| 570 | 951 | |
| 571 | | /* put it on the queue */ |
| 572 | | newinptr = (chan->receive_inptr + 1) % ARRAY_LENGTH(chan->receive_buffer); |
| 573 | | if (newinptr != chan->receive_outptr) |
| 952 | LOGERROR("Z80DART \"%s\" Channel %c : Receive Data Byte '%02x'\n", device->tag, 'A' + channel, data); |
| 953 | |
| 954 | if (ch->rx_fifo == 2) |
| 574 | 955 | { |
| 575 | | chan->receive_buffer[chan->receive_inptr] = data; |
| 576 | | chan->receive_inptr = newinptr; |
| 956 | /* receive overrun error detected */ |
| 957 | ch->rx_error |= Z80DART_RR1_RX_OVERRUN_ERROR; |
| 958 | |
| 959 | switch (ch->wr[1] & Z80DART_WR1_RX_INT_ENABLE_MASK) |
| 960 | { |
| 961 | case Z80DART_WR1_RX_INT_FIRST: |
| 962 | if (!ch->rx_first) |
| 963 | { |
| 964 | z80dart_trigger_interrupt(device, channel, INT_SPECIAL); |
| 965 | } |
| 966 | break; |
| 967 | |
| 968 | case Z80DART_WR1_RX_INT_ALL_PARITY: |
| 969 | case Z80DART_WR1_RX_INT_ALL: |
| 970 | z80dart_trigger_interrupt(device, channel, INT_SPECIAL); |
| 971 | break; |
| 972 | } |
| 577 | 973 | } |
| 578 | 974 | else |
| 579 | | logerror("z80dart_receive_data: buffer overrun\n"); |
| 975 | { |
| 976 | ch->rx_fifo++; |
| 977 | } |
| 978 | |
| 979 | /* store received character and error status into FIFO */ |
| 980 | ch->rx_data_fifo[ch->rx_fifo] = data; |
| 981 | ch->rx_error_fifo[ch->rx_fifo] = ch->rx_error; |
| 982 | |
| 983 | ch->rr[0] |= Z80DART_RR0_RX_CHAR_AVAILABLE; |
| 984 | |
| 985 | /* receive interrupt */ |
| 986 | switch (ch->wr[1] & Z80DART_WR1_RX_INT_ENABLE_MASK) |
| 987 | { |
| 988 | case Z80DART_WR1_RX_INT_FIRST: |
| 989 | if (ch->rx_first) |
| 990 | { |
| 991 | z80dart_trigger_interrupt(device, channel, INT_RECEIVE); |
| 992 | |
| 993 | ch->rx_first = 0; |
| 994 | } |
| 995 | break; |
| 996 | |
| 997 | case Z80DART_WR1_RX_INT_ALL_PARITY: |
| 998 | case Z80DART_WR1_RX_INT_ALL: |
| 999 | z80dart_trigger_interrupt(device, channel, INT_RECEIVE); |
| 1000 | break; |
| 1001 | } |
| 580 | 1002 | } |
| 581 | 1003 | |
| 1004 | void z80dart_cts_w(const device_config *device, int channel, int state) |
| 1005 | { |
| 1006 | z80dart_t *z80dart = get_safe_token(device); |
| 1007 | dart_channel *ch = &z80dart->channel[channel]; |
| 582 | 1008 | |
| 583 | | /*------------------------------------------------- |
| 584 | | serial_callback - callback to pump |
| 585 | | data through |
| 586 | | -------------------------------------------------*/ |
| 1009 | LOGERROR("Z80DART \"%s\" Channel %c : CTS %u\n", device->tag, 'A' + channel, state); |
| 587 | 1010 | |
| 588 | | static TIMER_CALLBACK(serial_callback) |
| 1011 | if (ch->cts != state) |
| 1012 | { |
| 1013 | /* enable transmitter if in auto enables mode */ |
| 1014 | if (!state) |
| 1015 | if (ch->wr[3] & Z80DART_WR3_AUTO_ENABLES) |
| 1016 | ch->wr[5] |= Z80DART_WR5_TX_ENABLE; |
| 1017 | |
| 1018 | /* set clear to send */ |
| 1019 | ch->cts = state; |
| 1020 | |
| 1021 | if (ch->cts) |
| 1022 | ch->rr[0] |= Z80DART_RR0_CTS; |
| 1023 | |
| 1024 | /* trigger interrupt */ |
| 1025 | z80dart_trigger_interrupt(device, channel, INT_EXTERNAL); |
| 1026 | } |
| 1027 | } |
| 1028 | |
| 1029 | void z80dart_dcd_w(const device_config *device, int channel, int state) |
| 589 | 1030 | { |
| 590 | | const device_config *device = ptr; |
| 591 | | z80dart *dart = get_safe_token( device ); |
| 592 | | dart_channel *chan = &dart->chan[param & 1]; |
| 593 | | int ch = param & 1; |
| 594 | | int data = -1; |
| 1031 | z80dart_t *z80dart = get_safe_token(device); |
| 1032 | dart_channel *ch = &z80dart->channel[channel]; |
| 595 | 1033 | |
| 596 | | /* first perform any outstanding transmits */ |
| 597 | | if (chan->outbuf != -1) |
| 1034 | LOGERROR("Z80DART \"%s\" Channel %c : DCD %u\n", device->tag, 'A' + channel, state); |
| 1035 | |
| 1036 | if (ch->dcd != state) |
| 598 | 1037 | { |
| 599 | | VPRINTF(("serial_callback(%c): Transmitting %02x\n", 'A' + ch, chan->outbuf)); |
| 1038 | /* enable receiver if in auto enables mode */ |
| 1039 | if (!state) |
| 1040 | if (ch->wr[3] & Z80DART_WR3_AUTO_ENABLES) |
| 1041 | ch->wr[3] |= Z80DART_WR3_RX_ENABLE; |
| 600 | 1042 | |
| 601 | | /* actually transmit the character */ |
| 602 | | if (dart->transmit_cb != NULL) |
| 603 | | (*dart->transmit_cb)(device, ch, chan->outbuf); |
| 1043 | /* set data carrier detect */ |
| 1044 | ch->dcd = state; |
| 604 | 1045 | |
| 605 | | /* update the status register */ |
| 606 | | chan->status[0] |= DART_RR0_TX_BUFFER_EMPTY; |
| 1046 | if (ch->dcd) |
| 1047 | ch->rr[0] |= Z80DART_RR0_DCD; |
| 607 | 1048 | |
| 608 | | /* set the transmit buffer empty interrupt if enabled */ |
| 609 | | if (chan->regs[1] & DART_WR1_TXINT_ENABLE) |
| 610 | | { |
| 611 | | dart->int_state[INT_CHA_TRANSMIT - 4*ch] |= Z80_DAISY_INT; |
| 612 | | interrupt_check(device); |
| 613 | | } |
| 1049 | /* trigger interrupt */ |
| 1050 | if (ch->wr[1] & Z80DART_WR1_EXT_INT_ENABLE) |
| 1051 | z80dart_trigger_interrupt(device, channel, INT_EXTERNAL); |
| 1052 | } |
| 1053 | } |
| 614 | 1054 | |
| 615 | | /* reset the output buffer */ |
| 616 | | chan->outbuf = -1; |
| 1055 | void z80dart_ri_w(const device_config *device, int channel, int state) |
| 1056 | { |
| 1057 | z80dart_t *z80dart = get_safe_token(device); |
| 1058 | dart_channel *ch = &z80dart->channel[channel]; |
| 1059 | |
| 1060 | LOGERROR("Z80DART \"%s\" Channel %c : RI %u\n", device->tag, 'A' + channel, state); |
| 1061 | |
| 1062 | if (ch->ri != state) |
| 1063 | { |
| 1064 | /* set ring indicator state */ |
| 1065 | ch->ri = state; |
| 1066 | |
| 1067 | if (ch->ri) |
| 1068 | ch->rr[0] |= Z80DART_RR0_RI; |
| 1069 | |
| 1070 | /* trigger interrupt */ |
| 1071 | if (ch->wr[1] & Z80DART_WR1_EXT_INT_ENABLE) |
| 1072 | z80dart_trigger_interrupt(device, channel, INT_EXTERNAL); |
| 617 | 1073 | } |
| 1074 | } |
| 618 | 1075 | |
| 619 | | /* ask the polling callback if there is data to receive */ |
| 620 | | if (dart->receive_poll_cb != NULL) |
| 621 | | data = (*dart->receive_poll_cb)(device, ch); |
| 1076 | /*************************************************************************** |
| 1077 | CLOCK MANAGEMENT |
| 1078 | ***************************************************************************/ |
| 622 | 1079 | |
| 623 | | /* if we have buffered data, pull it */ |
| 624 | | if (chan->receive_inptr != chan->receive_outptr) |
| 1080 | void z80dart_rxca_w(const device_config *device) |
| 1081 | { |
| 1082 | z80dart_t *z80dart = get_safe_token(device); |
| 1083 | dart_channel *ch = &z80dart->channel[Z80DART_CH_A]; |
| 1084 | |
| 1085 | int clocks = z80dart_get_clock_mode(device, Z80DART_CH_A); |
| 1086 | |
| 1087 | LOGERROR("Z80DART \"%s\" Channel A : Receiver Clock Pulse\n", device->tag); |
| 1088 | |
| 1089 | ch->rx_clock++; |
| 1090 | |
| 1091 | if (ch->rx_clock == clocks) |
| 625 | 1092 | { |
| 626 | | data = chan->receive_buffer[chan->receive_outptr]; |
| 627 | | chan->receive_outptr = (chan->receive_outptr + 1) % ARRAY_LENGTH(chan->receive_buffer); |
| 1093 | ch->rx_clock = 0; |
| 1094 | |
| 1095 | /* receive data */ |
| 1096 | receive(device, Z80DART_CH_A); |
| 628 | 1097 | } |
| 1098 | } |
| 629 | 1099 | |
| 630 | | /* if we have data, receive it */ |
| 631 | | if (data != -1) |
| 1100 | void z80dart_txca_w(const device_config *device) |
| 1101 | { |
| 1102 | z80dart_t *z80dart = get_safe_token(device); |
| 1103 | dart_channel *ch = &z80dart->channel[Z80DART_CH_A]; |
| 1104 | |
| 1105 | int clocks = z80dart_get_clock_mode(device, Z80DART_CH_A); |
| 1106 | |
| 1107 | LOGERROR("Z80DART \"%s\" Channel A : Transmitter Clock Pulse\n", device->tag); |
| 1108 | |
| 1109 | ch->tx_clock++; |
| 1110 | |
| 1111 | if (ch->tx_clock == clocks) |
| 632 | 1112 | { |
| 633 | | VPRINTF(("serial_callback(%c): Receiving %02x\n", 'A' + ch, data)); |
| 1113 | ch->tx_clock = 0; |
| 634 | 1114 | |
| 635 | | /* if rx not enabled, just ignore it */ |
| 636 | | if (!(chan->regs[3] & DART_WR3_RX_ENABLE)) |
| 637 | | { |
| 638 | | VPRINTF((" (ignored because receive is disabled)\n")); |
| 639 | | return; |
| 640 | | } |
| 1115 | /* transmit data */ |
| 1116 | transmit(device, Z80DART_CH_A); |
| 1117 | } |
| 1118 | } |
| 641 | 1119 | |
| 642 | | /* stash the data and update the status */ |
| 643 | | chan->inbuf = data; |
| 644 | | chan->status[0] |= DART_RR0_RX_CHAR_AVAILABLE; |
| 1120 | void z80dart_rxtxcb_w(const device_config *device) |
| 1121 | { |
| 1122 | z80dart_t *z80dart = get_safe_token(device); |
| 1123 | dart_channel *ch = &z80dart->channel[Z80DART_CH_B]; |
| 645 | 1124 | |
| 646 | | /* update our interrupt state */ |
| 647 | | switch (chan->regs[1] & DART_WR1_RXINT_MASK) |
| 648 | | { |
| 649 | | case DART_WR1_RXINT_FIRST: |
| 650 | | if (!chan->int_on_next_rx) |
| 651 | | break; |
| 1125 | int clocks = z80dart_get_clock_mode(device, Z80DART_CH_B); |
| 652 | 1126 | |
| 653 | | case DART_WR1_RXINT_ALL_NOPARITY: |
| 654 | | case DART_WR1_RXINT_ALL_PARITY: |
| 655 | | dart->int_state[INT_CHA_RECEIVE - 4*ch] |= Z80_DAISY_INT; |
| 656 | | interrupt_check(device); |
| 657 | | break; |
| 658 | | } |
| 659 | | chan->int_on_next_rx = FALSE; |
| 1127 | LOGERROR("Z80DART \"%s\" Channel A : Receiver/Transmitter Clock Pulse\n", device->tag); |
| 1128 | |
| 1129 | ch->rx_clock++; |
| 1130 | ch->tx_clock++; |
| 1131 | |
| 1132 | if (ch->rx_clock == clocks) |
| 1133 | { |
| 1134 | ch->rx_clock = 0; |
| 1135 | ch->tx_clock = 0; |
| 1136 | |
| 1137 | /* receive and transmit data */ |
| 1138 | receive(device, Z80DART_CH_B); |
| 1139 | transmit(device, Z80DART_CH_B); |
| 660 | 1140 | } |
| 661 | 1141 | } |
| 662 | 1142 | |
| 1143 | static TIMER_CALLBACK( rxca_tick ) |
| 1144 | { |
| 1145 | z80dart_rxca_w(ptr); |
| 1146 | } |
| 663 | 1147 | |
| 1148 | static TIMER_CALLBACK( txca_tick ) |
| 1149 | { |
| 1150 | z80dart_txca_w(ptr); |
| 1151 | } |
| 664 | 1152 | |
| 1153 | static TIMER_CALLBACK( rxtxcb_tick ) |
| 1154 | { |
| 1155 | z80dart_rxtxcb_w(ptr); |
| 1156 | } |
| 1157 | |
| 665 | 1158 | /*************************************************************************** |
| 666 | 1159 | DAISY CHAIN INTERFACE |
| 667 | 1160 | ***************************************************************************/ |
| 668 | 1161 | |
| 669 | | static const UINT8 int_priority[] = |
| 670 | | { |
| 671 | | INT_CHA_RECEIVE, |
| 672 | | INT_CHA_TRANSMIT, |
| 673 | | INT_CHA_STATUS, |
| 674 | | INT_CHA_ERROR, |
| 675 | | INT_CHB_RECEIVE, |
| 676 | | INT_CHB_TRANSMIT, |
| 677 | | INT_CHB_STATUS, |
| 678 | | INT_CHB_ERROR |
| 679 | | }; |
| 680 | | |
| 681 | | |
| 682 | 1162 | static int z80dart_irq_state(const device_config *device) |
| 683 | 1163 | { |
| 684 | | z80dart *dart = get_safe_token( device ); |
| 1164 | z80dart_t *z80dart = get_safe_token( device ); |
| 685 | 1165 | int state = 0; |
| 686 | 1166 | int i; |
| 687 | 1167 | |
| 688 | | VPRINTF(("dart IRQ state = B:%d%d%d%d A:%d%d%d%d\n", |
| 689 | | dart->int_state[0], dart->int_state[1], dart->int_state[2], dart->int_state[3], |
| 690 | | dart->int_state[4], dart->int_state[5], dart->int_state[6], dart->int_state[7])); |
| 1168 | LOGERROR("dart IRQ state = B:%d%d%d%d A:%d%d%d%d\n", |
| 1169 | z80dart->int_state[0], z80dart->int_state[1], z80dart->int_state[2], z80dart->int_state[3], |
| 1170 | z80dart->int_state[4], z80dart->int_state[5], z80dart->int_state[6], z80dart->int_state[7]); |
| 691 | 1171 | |
| 692 | 1172 | /* loop over all interrupt sources */ |
| 693 | 1173 | for (i = 0; i < 8; i++) |
| 694 | 1174 | { |
| 695 | | int inum = int_priority[i]; |
| 696 | | |
| 697 | 1175 | /* if we're servicing a request, don't indicate more interrupts */ |
| 698 | | if (dart->int_state[inum] & Z80_DAISY_IEO) |
| 1176 | if (z80dart->int_state[i] & Z80_DAISY_IEO) |
| 699 | 1177 | { |
| 700 | 1178 | state |= Z80_DAISY_IEO; |
| 701 | 1179 | break; |
| 702 | 1180 | } |
| 703 | | state |= dart->int_state[inum]; |
| 1181 | state |= z80dart->int_state[i]; |
| 704 | 1182 | } |
| 705 | 1183 | |
| 1184 | LOGERROR("Z80DART \"%s\" : Interrupt State %u\n", device->tag, state); |
| 1185 | |
| 706 | 1186 | return state; |
| 707 | 1187 | } |
| 708 | 1188 | |
| 709 | | |
| 710 | 1189 | static int z80dart_irq_ack(const device_config *device) |
| 711 | 1190 | { |
| 712 | | z80dart *dart = get_safe_token( device ); |
| 1191 | z80dart_t *z80dart = get_safe_token( device ); |
| 713 | 1192 | int i; |
| 714 | 1193 | |
| 1194 | LOGERROR("Z80DART \"%s\" Interrupt Acknowledge\n", device->tag); |
| 1195 | |
| 715 | 1196 | /* loop over all interrupt sources */ |
| 716 | 1197 | for (i = 0; i < 8; i++) |
| 717 | 1198 | { |
| 718 | | int inum = int_priority[i]; |
| 719 | | |
| 720 | 1199 | /* find the first channel with an interrupt requested */ |
| 721 | | if (dart->int_state[inum] & Z80_DAISY_INT) |
| 1200 | if (z80dart->int_state[i] & Z80_DAISY_INT) |
| 722 | 1201 | { |
| 723 | | VPRINTF(("dart IRQAck %d\n", inum)); |
| 1202 | /* clear interrupt, switch to the IEO state, and update the IRQs */ |
| 1203 | z80dart->int_state[i] = Z80_DAISY_IEO; |
| 1204 | z80dart->channel[Z80DART_CH_A].rr[0] &= ~Z80DART_RR0_INTERRUPT_PENDING; |
| 1205 | z80dart_check_interrupt(device); |
| 724 | 1206 | |
| 725 | | /* clear interrupt, switch to the IEO state, and update the IRQs */ |
| 726 | | dart->int_state[inum] = Z80_DAISY_IEO; |
| 727 | | interrupt_check(device); |
| 728 | | return dart->chan[1].regs[2] + inum * 2; |
| 1207 | LOGERROR("Z80DART \"%s\" : Interrupt Acknowledge Vector %02x\n", device->tag, z80dart->channel[Z80DART_CH_B].rr[2]); |
| 1208 | |
| 1209 | return z80dart->channel[Z80DART_CH_B].rr[2]; |
| 729 | 1210 | } |
| 730 | 1211 | } |
| 731 | 1212 | |
| 732 | 1213 | logerror("z80dart_irq_ack: failed to find an interrupt to ack!\n"); |
| 733 | | return dart->chan[1].regs[2]; |
| 1214 | |
| 1215 | return z80dart->channel[Z80DART_CH_B].rr[2]; |
| 734 | 1216 | } |
| 735 | 1217 | |
| 736 | | |
| 737 | 1218 | static void z80dart_irq_reti(const device_config *device) |
| 738 | 1219 | { |
| 739 | | z80dart *dart = get_safe_token( device ); |
| 1220 | z80dart_t *z80dart = get_safe_token( device ); |
| 740 | 1221 | int i; |
| 741 | 1222 | |
| 1223 | LOGERROR("Z80DART \"%s\" Return from Interrupt\n", device->tag); |
| 1224 | |
| 742 | 1225 | /* loop over all interrupt sources */ |
| 743 | 1226 | for (i = 0; i < 8; i++) |
| 744 | 1227 | { |
| 745 | | int inum = int_priority[i]; |
| 746 | | |
| 747 | 1228 | /* find the first channel with an IEO pending */ |
| 748 | | if (dart->int_state[inum] & Z80_DAISY_IEO) |
| 1229 | if (z80dart->int_state[i] & Z80_DAISY_IEO) |
| 749 | 1230 | { |
| 750 | | VPRINTF(("dart IRQReti %d\n", inum)); |
| 751 | | |
| 752 | 1231 | /* clear the IEO state and update the IRQs */ |
| 753 | | dart->int_state[inum] &= ~Z80_DAISY_IEO; |
| 754 | | interrupt_check(device); |
| 1232 | z80dart->int_state[i] &= ~Z80_DAISY_IEO; |
| 1233 | z80dart_check_interrupt(device); |
| 755 | 1234 | return; |
| 756 | 1235 | } |
| 757 | 1236 | } |
| r3481 | r3482 | |
| 759 | 1238 | logerror("z80dart_irq_reti: failed to find an interrupt to clear IEO on!\n"); |
| 760 | 1239 | } |
| 761 | 1240 | |
| 1241 | /*************************************************************************** |
| 1242 | READ/WRITE HANDLERS |
| 1243 | ***************************************************************************/ |
| 762 | 1244 | |
| 1245 | READ8_DEVICE_HANDLER( z80dart_r ) |
| 1246 | { |
| 1247 | return (offset & 2) ? z80dart_c_r(device, offset & 1) : z80dart_d_r(device, offset & 1); |
| 1248 | } |
| 1249 | |
| 1250 | WRITE8_DEVICE_HANDLER( z80dart_w ) |
| 1251 | { |
| 1252 | if (offset & 2) |
| 1253 | z80dart_c_w(device, offset & 1, data); |
| 1254 | else |
| 1255 | z80dart_d_w(device, offset & 1, data); |
| 1256 | } |
| 1257 | |
| 1258 | READ8_DEVICE_HANDLER( z80dart_alt_r ) |
| 1259 | { |
| 1260 | int channel = BIT(offset, 1); |
| 1261 | |
| 1262 | return (offset & 1) ? z80dart_c_r(device, channel) : z80dart_d_r(device, channel); |
| 1263 | } |
| 1264 | |
| 1265 | WRITE8_DEVICE_HANDLER( z80dart_alt_w ) |
| 1266 | { |
| 1267 | int channel = BIT(offset, 1); |
| 1268 | |
| 1269 | if (offset & 1) |
| 1270 | z80dart_c_w(device, channel, data); |
| 1271 | else |
| 1272 | z80dart_d_w(device, channel, data); |
| 1273 | } |
| 1274 | |
| 1275 | /*************************************************************************** |
| 1276 | DEVICE INTERFACE |
| 1277 | ***************************************************************************/ |
| 1278 | |
| 763 | 1279 | static DEVICE_START( z80dart ) |
| 764 | 1280 | { |
| 765 | 1281 | const z80dart_interface *intf = device->static_config; |
| 766 | | z80dart *dart = get_safe_token(device); |
| 1282 | z80dart_t *z80dart = get_safe_token(device); |
| 1283 | char unique_tag[30]; |
| 1284 | int cpunum = -1; |
| 767 | 1285 | |
| 768 | | dart->chan[0].receive_timer = timer_alloc(serial_callback, (void *)device); |
| 769 | | dart->chan[1].receive_timer = timer_alloc(serial_callback, (void *)device); |
| 1286 | assert(intf != NULL); |
| 1287 | z80dart->intf = intf; |
| 770 | 1288 | |
| 771 | | dart->irq_cb = intf->irq_cb; |
| 772 | | dart->dtr_changed_cb = intf->dtr_changed_cb; |
| 773 | | dart->rts_changed_cb = intf->rts_changed_cb; |
| 774 | | dart->break_changed_cb = intf->break_changed_cb; |
| 775 | | dart->transmit_cb = intf->transmit_cb; |
| 776 | | dart->receive_poll_cb = intf->receive_poll_cb; |
| 1289 | /* get clock */ |
| 777 | 1290 | |
| 1291 | if (intf->cpu != NULL) |
| 1292 | { |
| 1293 | cpunum = mame_find_cpu_index(device->machine, intf->cpu); |
| 1294 | } |
| 1295 | |
| 1296 | if (cpunum != -1) |
| 1297 | { |
| 1298 | z80dart->clock = device->machine->config->cpu[cpunum].clock; |
| 1299 | } |
| 1300 | else |
| 1301 | { |
| 1302 | assert(intf->clock > 0); |
| 1303 | z80dart->clock = intf->clock; |
| 1304 | } |
| 1305 | |
| 1306 | /* allocate channel A receive timer */ |
| 1307 | |
| 1308 | z80dart->rxca_timer = timer_alloc(rxca_tick, (void *)device); |
| 1309 | |
| 1310 | if (z80dart->intf->rx_clock_a) |
| 1311 | timer_adjust_periodic(z80dart->rxca_timer, attotime_zero, 0, ATTOTIME_IN_HZ(z80dart->intf->rx_clock_a)); |
| 1312 | |
| 1313 | /* allocate channel A transmit timer */ |
| 1314 | |
| 1315 | z80dart->txca_timer = timer_alloc(txca_tick, (void *)device); |
| 1316 | |
| 1317 | if (z80dart->intf->tx_clock_a) |
| 1318 | timer_adjust_periodic(z80dart->txca_timer, attotime_zero, 0, ATTOTIME_IN_HZ(z80dart->intf->tx_clock_a)); |
| 1319 | |
| 1320 | /* allocate channel B receive/transmit timer */ |
| 1321 | |
| 1322 | z80dart->rxtxcb_timer = timer_alloc(rxtxcb_tick, (void *)device); |
| 1323 | |
| 1324 | if (z80dart->intf->rx_tx_clock_b) |
| 1325 | timer_adjust_periodic(z80dart->rxtxcb_timer, attotime_zero, 0, ATTOTIME_IN_HZ(z80dart->intf->rx_tx_clock_b)); |
| 1326 | |
| 1327 | /* register for state saving */ |
| 1328 | |
| 1329 | state_save_combine_module_and_tag(unique_tag, "z80dart", device->tag); |
| 1330 | |
| 1331 | //state_save_register_item_array(unique_tag, 0, z80dart->); |
| 1332 | |
| 778 | 1333 | return DEVICE_START_OK; |
| 779 | 1334 | } |
| 780 | 1335 | |
| 781 | | |
| 782 | 1336 | static DEVICE_RESET( z80dart ) |
| 783 | 1337 | { |
| 784 | | int ch; |
| 1338 | int channel; |
| 785 | 1339 | |
| 786 | | /* set up defaults */ |
| 787 | | for (ch = 0; ch < 2; ch++) |
| 1340 | for (channel = Z80DART_CH_A; channel <= Z80DART_CH_B; channel++) |
| 788 | 1341 | { |
| 789 | | reset_channel( device, ch ); |
| 1342 | z80dart_reset_channel(device, channel); |
| 790 | 1343 | } |
| 791 | | interrupt_check(device); |
| 1344 | |
| 1345 | z80dart_check_interrupt(device); |
| 792 | 1346 | } |
| 793 | 1347 | |
| 794 | | |
| 795 | 1348 | static DEVICE_SET_INFO( z80dart ) |
| 796 | 1349 | { |
| 797 | 1350 | switch (state) |
| r3481 | r3482 | |
| 800 | 1353 | } |
| 801 | 1354 | } |
| 802 | 1355 | |
| 803 | | |
| 804 | 1356 | DEVICE_GET_INFO( z80dart ) |
| 805 | 1357 | { |
| 806 | 1358 | switch (state) |
| 807 | 1359 | { |
| 808 | 1360 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 809 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(z80dart); break; |
| 1361 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(z80dart_t); break; |
| 810 | 1362 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 811 | 1363 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 812 | 1364 | |
| r3481 | r3482 | |
| 827 | 1379 | case DEVINFO_STR_CREDITS: info->s = "Copyright the MESS Team"; break; |
| 828 | 1380 | } |
| 829 | 1381 | } |
| 830 | | |
src/mess/drivers/abc80x.c
| r3481 | r3482 | |
| 171 | 171 | |
| 172 | 172 | if (keycode) |
| 173 | 173 | { |
| 174 | | if (!keylatch) |
| 174 | if (keycode != keylatch) |
| 175 | 175 | { |
| 176 | 176 | const device_config *z80dart = devtag_get_device(machine, Z80DART, Z80DART_TAG); |
| 177 | 177 | |
| 178 | | z80dart_set_dcd(z80dart, 1, 1); |
| 179 | | z80dart_receive_data(z80dart, 1, keycode); |
| 178 | z80dart_dcd_w(z80dart, Z80DART_CH_B, 0); |
| 179 | z80dart_receive_data(z80dart, Z80DART_CH_B, keycode); |
| 180 | 180 | |
| 181 | 181 | keylatch = keycode; |
| 182 | 182 | } |
| r3481 | r3482 | |
| 187 | 187 | { |
| 188 | 188 | const device_config *z80dart = devtag_get_device(machine, Z80DART, Z80DART_TAG); |
| 189 | 189 | |
| 190 | | z80dart_set_dcd(z80dart, 1, 0); |
| 191 | | z80dart_receive_data(z80dart, 1, 0); |
| 190 | z80dart_dcd_w(z80dart, Z80DART_CH_B, 1); |
| 191 | z80dart_receive_data(z80dart, Z80DART_CH_B, 0); |
| 192 | 192 | |
| 193 | 193 | keylatch = 0; |
| 194 | 194 | } |
| r3481 | r3482 | |
| 208 | 208 | { |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | // ABC 802 |
| 212 | |
| 213 | static void abc802_bankswitch(running_machine *machine) |
| 214 | { |
| 215 | abc802_state *state = machine->driver_data; |
| 216 | |
| 217 | if (state->lrs) |
| 218 | { |
| 219 | /* ROM and video RAM selected */ |
| 220 | memory_install_readwrite8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x77ff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 221 | memory_install_readwrite8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x7800, 0x7fff, 0, 0, abc802_charram_r, abc802_charram_w); |
| 222 | } |
| 223 | else |
| 224 | { |
| 225 | /* low RAM selected */ |
| 226 | memory_install_readwrite8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x7fff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 227 | } |
| 228 | |
| 229 | memory_set_bank(1, state->lrs); |
| 230 | } |
| 231 | |
| 211 | 232 | // ABC 806 |
| 212 | 233 | |
| 213 | 234 | static void abc806_bankswitch(running_machine *machine) |
| r3481 | r3482 | |
| 507 | 528 | |
| 508 | 529 | static ADDRESS_MAP_START( abc802_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 509 | 530 | ADDRESS_MAP_UNMAP_HIGH |
| 510 | | AM_RANGE(0x0000, 0x77ff) AM_RAMBANK(1) |
| 511 | | AM_RANGE(0x7800, 0x7fff) AM_RAM AM_BASE(&videoram) |
| 531 | AM_RANGE(0x0000, 0x7fff) AM_RAMBANK(1) |
| 512 | 532 | AM_RANGE(0x8000, 0xffff) AM_RAM |
| 513 | 533 | ADDRESS_MAP_END |
| 514 | 534 | |
| r3481 | r3482 | |
| 723 | 743 | |
| 724 | 744 | static ABC77_ON_CLOCK_CHANGED( abc77_clock_changed ) |
| 725 | 745 | { |
| 726 | | // const device_config *z80dart = devtag_get_device(device->machine, Z80DART, Z80DART_TAG); |
| 746 | const device_config *z80dart = devtag_get_device(device->machine, Z80DART, Z80DART_TAG); |
| 727 | 747 | |
| 728 | | /* connected to DART channel B RxTxCB (pin ) */ |
| 729 | | //z80dart_rxtxc_w(z80dart, 1, level); |
| 748 | /* connected to DART channel B clock */ |
| 749 | z80dart_rxtxcb_w(z80dart); |
| 730 | 750 | } |
| 731 | 751 | |
| 732 | 752 | static ABC77_ON_KEYDOWN_CHANGED( abc77_keydown_changed ) |
| r3481 | r3482 | |
| 734 | 754 | const device_config *z80dart = devtag_get_device(device->machine, Z80DART, Z80DART_TAG); |
| 735 | 755 | |
| 736 | 756 | /* connected to DART channel B DCD (pin ) */ |
| 737 | | z80dart_set_dcd(z80dart, 1, level); |
| 757 | z80dart_dcd_w(z80dart, 1, level); |
| 738 | 758 | } |
| 739 | 759 | |
| 740 | 760 | static ABC77_INTERFACE( abc800_abc77_intf ) |
| r3481 | r3482 | |
| 795 | 815 | |
| 796 | 816 | static WRITE8_DEVICE_HANDLER( ctc_z0_w ) |
| 797 | 817 | { |
| 798 | | //const device_config *z80sio = devtag_get_device(machine, Z80SIO, Z80SIO_TAG); |
| 818 | //const device_config *z80sio = devtag_get_device(device->machine, Z80SIO, Z80SIO_TAG); |
| 799 | 819 | |
| 800 | 820 | UINT8 sb = input_port_read(device->machine, "SB"); |
| 801 | 821 | |
| 802 | 822 | if (BIT(sb, 2)) |
| 803 | 823 | { |
| 804 | 824 | /* connected to SIO/2 TxCA, CTC CLK/TRG3 */ |
| 805 | | //z80sio_txc_w(z80sio, 0, data); |
| 825 | //z80sio_txca_w(z80sio, data); |
| 806 | 826 | z80ctc_trg_w(device, 3, data); |
| 807 | 827 | } |
| 808 | 828 | |
| 809 | 829 | /* connected to SIO/2 RxCB through a thingy */ |
| 810 | 830 | //z80sio_rxcb = ? |
| 811 | | //z80sio_rxc_w(z80sio, 1, z80sio_rxcb); |
| 831 | //z80sio_rxcb_w(z80sio, z80sio_rxcb); |
| 812 | 832 | |
| 813 | 833 | /* connected to SIO/2 TxCB through a JK divide by 2 */ |
| 814 | 834 | //z80sio_txcb = !z80sio_txcb; |
| 815 | | //z80sio_txc_w(z80sio, 1, z80sio_txcb); |
| 835 | //z80sio_txcb_w(z80sio, z80sio_txcb); |
| 816 | 836 | } |
| 817 | 837 | |
| 818 | 838 | static WRITE8_DEVICE_HANDLER( ctc_z1_w ) |
| 819 | 839 | { |
| 820 | | //const device_config *z80sio = devtag_get_device(machine, Z80SIO, Z80SIO_TAG); |
| 840 | //const device_config *z80sio = devtag_get_device(device->machine, Z80SIO, Z80SIO_TAG); |
| 821 | 841 | |
| 822 | 842 | UINT8 sb = input_port_read(device->machine, "SB"); |
| 823 | 843 | |
| 824 | 844 | if (BIT(sb, 3)) |
| 825 | 845 | { |
| 826 | 846 | /* connected to SIO/2 RxCA */ |
| 827 | | //z80sio_rxc_w(z80sio, 0, data); |
| 847 | //z80sio_rxca_w(z80sio, data); |
| 828 | 848 | } |
| 829 | 849 | |
| 830 | 850 | if (BIT(sb, 8)) |
| 831 | 851 | { |
| 832 | 852 | /* connected to SIO/2 TxCA, CTC CLK/TRG3 */ |
| 833 | | //z80sio_txc_w(z80sio, 0, data); |
| 853 | //z80sio_txca_w(z80sio, data); |
| 834 | 854 | z80ctc_trg_w(device, 3, data); |
| 835 | 855 | } |
| 836 | 856 | } |
| 837 | 857 | |
| 838 | 858 | static WRITE8_DEVICE_HANDLER( ctc_z2_w ) |
| 839 | 859 | { |
| 840 | | // const device_config *z80dart = devtag_get_device(machine, Z80DART, Z80DART_TAG); |
| 860 | const device_config *z80dart = devtag_get_device(device->machine, Z80DART, Z80DART_TAG); |
| 841 | 861 | |
| 842 | | /* connected to DART RxCA/TxCA (pin ) */ |
| 843 | | //z80dart_rxtxc_w(z80dart, 0, data); |
| 862 | /* connected to DART channel A clock inputs */ |
| 863 | z80dart_rxca_w(z80dart); |
| 864 | z80dart_txca_w(z80dart); |
| 844 | 865 | } |
| 845 | 866 | |
| 846 | 867 | static const z80ctc_interface ctc_intf = |
| r3481 | r3482 | |
| 902 | 923 | |
| 903 | 924 | /* Z80 DART */ |
| 904 | 925 | |
| 905 | | static WRITE8_DEVICE_HANDLER( dart_serial_transmit ) |
| 926 | static Z80DART_ON_INT_CHANGED( dart_interrupt ) |
| 906 | 927 | { |
| 928 | cpunum_set_input_line(device->machine, 0, INPUT_LINE_IRQ0, state); |
| 907 | 929 | } |
| 908 | 930 | |
| 909 | | static int dart_serial_receive(const device_config *device, int ch) |
| 931 | static Z80DART_RXD_READ( abc800_dart_rxd_r ) |
| 910 | 932 | { |
| 911 | | return -1; |
| 933 | abc800_state *state = device->machine->driver_data; |
| 934 | |
| 935 | if (channel == Z80DART_CH_B) |
| 936 | { |
| 937 | /* receive bit from keyboard */ |
| 938 | return state->abc77_txd; |
| 939 | } |
| 940 | |
| 941 | return 1; |
| 912 | 942 | } |
| 913 | 943 | |
| 914 | | static void dart_interrupt(const device_config *device, int state) |
| 944 | static Z80DART_ON_TXD_CHANGED( abc800_dart_txd_w ) |
| 915 | 945 | { |
| 916 | | cpunum_set_input_line(device->machine, 0, INPUT_LINE_IRQ0, state); |
| 946 | abc800_state *state = device->machine->driver_data; |
| 947 | |
| 948 | if (channel == Z80DART_CH_B) |
| 949 | { |
| 950 | /* transmit bit to keyboard */ |
| 951 | abc77_rxd_w(state->abc77, level); |
| 952 | } |
| 917 | 953 | } |
| 918 | 954 | |
| 919 | | static const z80dart_interface abc800_dart_intf = |
| 955 | static Z80DART_INTERFACE( abc800_dart_intf ) |
| 920 | 956 | { |
| 921 | 957 | Z80_TAG, /* cpu */ |
| 922 | 958 | ABC800_X01/2/2, /* clock */ |
| 959 | 0, /* channel A receive clock */ |
| 960 | 0, /* channel A transmit clock */ |
| 961 | 0, /* channel B clock */ |
| 923 | 962 | dart_interrupt, /* interrupt handler */ |
| 963 | abc800_dart_rxd_r, /* receive handler */ |
| 964 | abc800_dart_txd_w, /* transmit handler */ |
| 924 | 965 | 0, /* DTR changed handler */ |
| 925 | 966 | 0, /* RTS changed handler */ |
| 926 | | 0, /* BREAK changed handler */ |
| 927 | | dart_serial_transmit, /* transmit handler */ |
| 928 | | dart_serial_receive /* receive handler */ |
| 967 | 0 /* W/RDY changed handler */ |
| 929 | 968 | }; |
| 930 | 969 | |
| 931 | | static WRITE8_DEVICE_HANDLER( abc802_dart_dtr_w ) |
| 970 | static Z80DART_RXD_READ( abc802_dart_rxd_r ) |
| 932 | 971 | { |
| 933 | | if (offset == 1) |
| 972 | abc802_state *state = device->machine->driver_data; |
| 973 | |
| 974 | if (channel == Z80DART_CH_B) |
| 934 | 975 | { |
| 935 | | /* _LRS */ |
| 936 | | memory_set_bank(1, data); |
| 976 | /* receive bit from keyboard */ |
| 977 | return state->abc77_txd; |
| 937 | 978 | } |
| 979 | |
| 980 | return 1; |
| 938 | 981 | } |
| 939 | 982 | |
| 940 | | static WRITE8_DEVICE_HANDLER( abc802_dart_rts_w ) |
| 983 | static Z80DART_ON_TXD_CHANGED( abc802_dart_txd_w ) |
| 941 | 984 | { |
| 942 | 985 | abc802_state *state = device->machine->driver_data; |
| 943 | 986 | |
| 944 | | if (offset == 1) |
| 987 | if (channel == Z80DART_CH_B) |
| 945 | 988 | { |
| 989 | /* transmit bit to keyboard */ |
| 990 | abc77_rxd_w(state->abc77, level); |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | static Z80DART_ON_DTR_CHANGED( abc802_dart_dtr_w ) |
| 995 | { |
| 996 | abc802_state *state = device->machine->driver_data; |
| 997 | |
| 998 | if (channel == Z80DART_CH_B) |
| 999 | { |
| 1000 | /* low RAM select */ |
| 1001 | state->lrs = level; |
| 1002 | |
| 1003 | abc802_bankswitch(device->machine); |
| 1004 | } |
| 1005 | } |
| 1006 | |
| 1007 | static Z80DART_ON_RTS_CHANGED( abc802_dart_rts_w ) |
| 1008 | { |
| 1009 | abc802_state *state = device->machine->driver_data; |
| 1010 | |
| 1011 | if (channel == Z80DART_CH_B) |
| 1012 | { |
| 946 | 1013 | /* _MUX 80/40 */ |
| 947 | | state->mux80_40 = !BIT(data, 0); |
| 1014 | state->mux80_40 = level; |
| 948 | 1015 | } |
| 949 | 1016 | } |
| 950 | 1017 | |
| 951 | | static const z80dart_interface abc802_dart_intf = |
| 1018 | static Z80DART_INTERFACE( abc802_dart_intf ) |
| 952 | 1019 | { |
| 953 | 1020 | Z80_TAG, /* cpu */ |
| 954 | 1021 | ABC800_X01/2/2, /* clock */ |
| 955 | | 0, /* interrupt handler */ |
| 1022 | 0, /* channel A receive clock */ |
| 1023 | 0, /* channel A transmit clock */ |
| 1024 | 0, /* channel B clock */ |
| 1025 | dart_interrupt, /* interrupt handler */ |
| 1026 | abc802_dart_rxd_r, /* receive handler */ |
| 1027 | abc802_dart_txd_w, /* transmit handler */ |
| 956 | 1028 | abc802_dart_dtr_w, /* DTR changed handler */ |
| 957 | 1029 | abc802_dart_rts_w, /* RTS changed handler */ |
| 958 | | 0, /* BREAK changed handler */ |
| 959 | | dart_serial_transmit, /* transmit handler */ |
| 960 | | dart_serial_receive /* receive handler */ |
| 1030 | 0 /* W/RDY changed handler */ |
| 961 | 1031 | }; |
| 962 | 1032 | |
| 963 | | static WRITE8_DEVICE_HANDLER( abc806_dart_dtr_w ) |
| 1033 | static Z80DART_RXD_READ( abc806_dart_rxd_r ) |
| 964 | 1034 | { |
| 965 | 1035 | abc806_state *state = device->machine->driver_data; |
| 1036 | |
| 1037 | if (channel == Z80DART_CH_B) |
| 1038 | { |
| 1039 | /* receive bit from keyboard */ |
| 1040 | return state->abc77_txd; |
| 1041 | } |
| 1042 | |
| 1043 | return 1; |
| 1044 | } |
| 1045 | |
| 1046 | static Z80DART_ON_TXD_CHANGED( abc806_dart_txd_w ) |
| 1047 | { |
| 1048 | abc806_state *state = device->machine->driver_data; |
| 1049 | |
| 1050 | if (channel == Z80DART_CH_B) |
| 1051 | { |
| 1052 | /* transmit bit to keyboard */ |
| 1053 | abc77_rxd_w(state->abc77, level); |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | static Z80DART_ON_DTR_CHANGED( abc806_dart_dtr_w ) |
| 1058 | { |
| 1059 | abc806_state *state = device->machine->driver_data; |
| 966 | 1060 | |
| 967 | | if (offset == 1) |
| 1061 | if (channel == Z80DART_CH_B) |
| 968 | 1062 | { |
| 969 | | state->keydtr = BIT(data, 0); |
| 1063 | state->keydtr = level; |
| 970 | 1064 | } |
| 971 | 1065 | } |
| 972 | 1066 | |
| 973 | | static const z80dart_interface abc806_dart_intf = |
| 1067 | static Z80DART_INTERFACE( abc806_dart_intf ) |
| 974 | 1068 | { |
| 975 | 1069 | Z80_TAG, /* cpu */ |
| 976 | 1070 | ABC800_X01/2/2, /* clock */ |
| 977 | | 0, /* interrupt handler */ |
| 1071 | 0, /* channel A receive clock */ |
| 1072 | 0, /* channel A transmit clock */ |
| 1073 | 0, /* channel B clock */ |
| 1074 | dart_interrupt, /* interrupt handler */ |
| 1075 | abc806_dart_rxd_r, /* receive handler */ |
| 1076 | abc806_dart_txd_w, /* transmit handler */ |
| 978 | 1077 | abc806_dart_dtr_w, /* DTR changed handler */ |
| 979 | 1078 | 0, /* RTS changed handler */ |
| 980 | | 0, /* BREAK changed handler */ |
| 981 | | dart_serial_transmit, /* transmit handler */ |
| 982 | | dart_serial_receive /* receive handler */ |
| 1079 | 0 /* W/RDY changed handler */ |
| 983 | 1080 | }; |
| 984 | 1081 | |
| 985 | 1082 | /* E05-16 */ |
| r3481 | r3482 | |
| 1026 | 1123 | |
| 1027 | 1124 | /* configure memory */ |
| 1028 | 1125 | |
| 1029 | | memory_configure_bank(1, 0, 1, memory_region(machine, Z80_TAG), 0); |
| 1030 | | memory_configure_bank(1, 1, 1, mess_ram, 0); |
| 1126 | memory_configure_bank(1, 0, 1, mess_ram, 0); |
| 1127 | memory_configure_bank(1, 1, 1, memory_region(machine, Z80_TAG), 0); |
| 1031 | 1128 | } |
| 1032 | 1129 | |
| 1033 | 1130 | static MACHINE_RESET( abc802 ) |
| r3481 | r3482 | |
| 1035 | 1132 | abc802_state *state = machine->driver_data; |
| 1036 | 1133 | |
| 1037 | 1134 | /* memory banking */ |
| 1038 | | memory_set_bank(1, 0); |
| 1135 | memory_set_bank(1, 1); |
| 1039 | 1136 | |
| 1040 | 1137 | /* clear screen time out (S1) */ |
| 1041 | 1138 | z80sio_set_dcd(state->z80sio, 1, 0); |
| r3481 | r3482 | |
| 1044 | 1141 | z80sio_set_cts(state->z80sio, 1, 0); |
| 1045 | 1142 | |
| 1046 | 1143 | /* 40/80 char (S3) */ |
| 1047 | | z80dart_set_ri(state->z80dart, 0, 0); // 0 = 40, 1 = 80 |
| 1144 | z80dart_ri_w(state->z80dart, Z80DART_CH_A, 1); // 0 = 40, 1 = 80 |
| 1048 | 1145 | |
| 1049 | 1146 | /* 50/60 Hz */ |
| 1050 | | z80dart_set_cts(state->z80dart, 1, 0); // 0 = 50Hz, 1 = 60Hz ??? |
| 1147 | z80dart_cts_w(state->z80dart, Z80DART_CH_B, 0); // 0 = 50Hz, 1 = 60Hz ??? |
| 1051 | 1148 | } |
| 1052 | 1149 | |
| 1053 | 1150 | static MACHINE_START( abc806 ) |
| r3481 | r3482 | |
| 1489 | 1586 | return address; |
| 1490 | 1587 | } |
| 1491 | 1588 | |
| 1589 | static OPBASE_HANDLER( abc802_opbase_handler ) |
| 1590 | { |
| 1591 | abc802_state *state = machine->driver_data; |
| 1592 | |
| 1593 | if (state->lrs) |
| 1594 | { |
| 1595 | if (address >= 0x7800 && address < 0x8000) |
| 1596 | { |
| 1597 | opbase->rom = opbase->ram = memory_region(machine, Z80_TAG); |
| 1598 | return ~0; |
| 1599 | } |
| 1600 | } |
| 1601 | else |
| 1602 | { |
| 1603 | opbase->rom = opbase->ram = mess_ram; |
| 1604 | return ~0; |
| 1605 | } |
| 1606 | |
| 1607 | return address; |
| 1608 | } |
| 1609 | |
| 1492 | 1610 | static OPBASE_HANDLER( abc806_opbase_handler ) |
| 1493 | 1611 | { |
| 1494 | 1612 | abc806_state *state = machine->driver_data; |
| r3481 | r3482 | |
| 1520 | 1638 | memory_set_opbase_handler(0, abc800_opbase_handler); |
| 1521 | 1639 | } |
| 1522 | 1640 | |
| 1641 | static DRIVER_INIT( abc802 ) |
| 1642 | { |
| 1643 | memory_set_opbase_handler(0, abc802_opbase_handler); |
| 1644 | } |
| 1645 | |
| 1523 | 1646 | static DRIVER_INIT( abc806 ) |
| 1524 | 1647 | { |
| 1525 | 1648 | memory_set_opbase_handler(0, abc806_opbase_handler); |
| r3481 | r3482 | |
| 1530 | 1653 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 1531 | 1654 | COMP( 1981, abc800m, 0, 0, abc800m, abc800, abc800, abc800, "Luxor Datorer AB", "ABC 800 M", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 1532 | 1655 | COMP( 1981, abc800c, abc800m, 0, abc800c, abc800, abc800, abc800, "Luxor Datorer AB", "ABC 800 C", GAME_NOT_WORKING ) |
| 1533 | | COMP( 1983, abc802, 0, 0, abc802, abc802, abc800, abc802, "Luxor Datorer AB", "ABC 802", GAME_NOT_WORKING ) |
| 1534 | | COMP( 1983, abc806, 0, 0, abc806, abc806, abc806, abc806, "Luxor Datorer AB", "ABC 806", GAME_NOT_WORKING ) |
| 1656 | COMP( 1983, abc802, 0, 0, abc802, abc802, abc802, abc802, "Luxor Datorer AB", "ABC 802", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 1657 | COMP( 1983, abc806, 0, 0, abc806, abc806, abc806, abc806, "Luxor Datorer AB", "ABC 806", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |