src/emu/machine/scn2661.c
| r15348 | r15349 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | Philips SCN2661 Enhanced Programmable Communications Interface emulation |
| 4 | | |
| 5 | | Copyright the MESS Team. |
| 6 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | | |
| 8 | | ***************************************************************************/ |
| 9 | | |
| 10 | | #include "scn2661.h" |
| 11 | | |
| 12 | | |
| 13 | | |
| 14 | | //************************************************************************** |
| 15 | | // DEVICE DEFINITIONS |
| 16 | | //************************************************************************** |
| 17 | | |
| 18 | | const device_type SCN2661 = &device_creator<scn2661_device>; |
| 19 | | |
| 20 | | |
| 21 | | |
| 22 | | //************************************************************************** |
| 23 | | // MACROS / CONSTANTS |
| 24 | | //************************************************************************** |
| 25 | | |
| 26 | | #define LOG 1 |
| 27 | | |
| 28 | | enum |
| 29 | | { |
| 30 | | REGISTER_HOLDING = 0, |
| 31 | | REGISTER_STATUS, |
| 32 | | REGISTER_SYNC = REGISTER_STATUS, |
| 33 | | REGISTER_MODE, |
| 34 | | REGISTER_COMMAND |
| 35 | | }; |
| 36 | | |
| 37 | | |
| 38 | | //************************************************************************** |
| 39 | | // INLINE HELPERS |
| 40 | | //************************************************************************** |
| 41 | | |
| 42 | | //------------------------------------------------- |
| 43 | | // receive - |
| 44 | | //------------------------------------------------- |
| 45 | | |
| 46 | | inline void scn2661_device::receive() |
| 47 | | { |
| 48 | | } |
| 49 | | |
| 50 | | |
| 51 | | //------------------------------------------------- |
| 52 | | // transmit - |
| 53 | | //------------------------------------------------- |
| 54 | | |
| 55 | | inline void scn2661_device::transmit() |
| 56 | | { |
| 57 | | } |
| 58 | | |
| 59 | | |
| 60 | | |
| 61 | | //************************************************************************** |
| 62 | | // LIVE DEVICE |
| 63 | | //************************************************************************** |
| 64 | | |
| 65 | | //------------------------------------------------- |
| 66 | | // scn2661_device - constructor |
| 67 | | //------------------------------------------------- |
| 68 | | |
| 69 | | scn2661_device::scn2661_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 70 | | : device_t(mconfig, SCN2661, "SCN2661", tag, owner, clock), |
| 71 | | device_serial_interface(mconfig, *this) |
| 72 | | { |
| 73 | | } |
| 74 | | |
| 75 | | |
| 76 | | //------------------------------------------------- |
| 77 | | // device_config_complete - perform any |
| 78 | | // operations now that the configuration is |
| 79 | | // complete |
| 80 | | //------------------------------------------------- |
| 81 | | |
| 82 | | void scn2661_device::device_config_complete() |
| 83 | | { |
| 84 | | // inherit a copy of the static data |
| 85 | | const scn2661_interface *intf = reinterpret_cast<const scn2661_interface *>(static_config()); |
| 86 | | if (intf != NULL) |
| 87 | | *static_cast<scn2661_interface *>(this) = *intf; |
| 88 | | |
| 89 | | // or initialize to defaults if none provided |
| 90 | | else |
| 91 | | { |
| 92 | | memset(&m_in_rxd_cb, 0, sizeof(m_in_rxd_cb)); |
| 93 | | memset(&m_out_txd_cb, 0, sizeof(m_out_txd_cb)); |
| 94 | | memset(&m_out_rxrdy_cb, 0, sizeof(m_out_rxrdy_cb)); |
| 95 | | memset(&m_out_txrdy_cb, 0, sizeof(m_out_txrdy_cb)); |
| 96 | | memset(&m_out_rts_cb, 0, sizeof(m_out_rts_cb)); |
| 97 | | memset(&m_out_dtr_cb, 0, sizeof(m_out_dtr_cb)); |
| 98 | | memset(&m_out_txemt_dschg_cb, 0, sizeof(m_out_txemt_dschg_cb)); |
| 99 | | memset(&m_out_bkdet_cb, 0, sizeof(m_out_bkdet_cb)); |
| 100 | | memset(&m_out_xsync_cb, 0, sizeof(m_out_xsync_cb)); |
| 101 | | } |
| 102 | | } |
| 103 | | |
| 104 | | |
| 105 | | //------------------------------------------------- |
| 106 | | // device_start - device-specific startup |
| 107 | | //------------------------------------------------- |
| 108 | | |
| 109 | | void scn2661_device::device_start() |
| 110 | | { |
| 111 | | // resolve callbacks |
| 112 | | m_in_rxd_func.resolve(m_in_rxd_cb, *this); |
| 113 | | m_out_txd_func.resolve(m_out_txd_cb, *this); |
| 114 | | m_out_rxrdy_func.resolve(m_out_rxrdy_cb, *this); |
| 115 | | m_out_txrdy_func.resolve(m_out_txrdy_cb, *this); |
| 116 | | m_out_rts_func.resolve(m_out_rts_cb, *this); |
| 117 | | m_out_dtr_func.resolve(m_out_dtr_cb, *this); |
| 118 | | m_out_txemt_dschg_func.resolve(m_out_txemt_dschg_cb, *this); |
| 119 | | m_out_bkdet_func.resolve(m_out_bkdet_cb, *this); |
| 120 | | m_out_xsync_func.resolve(m_out_xsync_cb, *this); |
| 121 | | |
| 122 | | // create the timers |
| 123 | | if (m_rxc > 0) |
| 124 | | { |
| 125 | | m_rx_timer = timer_alloc(TIMER_RX); |
| 126 | | m_rx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_rxc)); |
| 127 | | } |
| 128 | | |
| 129 | | if (m_txc > 0) |
| 130 | | { |
| 131 | | m_tx_timer = timer_alloc(TIMER_TX); |
| 132 | | m_tx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_txc)); |
| 133 | | } |
| 134 | | } |
| 135 | | |
| 136 | | |
| 137 | | //------------------------------------------------- |
| 138 | | // device_reset - device-specific reset |
| 139 | | //------------------------------------------------- |
| 140 | | |
| 141 | | void scn2661_device::device_reset() |
| 142 | | { |
| 143 | | transmit_register_reset(); |
| 144 | | receive_register_reset(); |
| 145 | | } |
| 146 | | |
| 147 | | |
| 148 | | //------------------------------------------------- |
| 149 | | // device_timer - handler timer events |
| 150 | | //------------------------------------------------- |
| 151 | | |
| 152 | | void scn2661_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 153 | | { |
| 154 | | switch (id) |
| 155 | | { |
| 156 | | case TIMER_RX: |
| 157 | | rxc_w(1); |
| 158 | | break; |
| 159 | | |
| 160 | | case TIMER_TX: |
| 161 | | txc_w(1); |
| 162 | | break; |
| 163 | | } |
| 164 | | } |
| 165 | | |
| 166 | | |
| 167 | | //------------------------------------------------- |
| 168 | | // input_callback - |
| 169 | | //------------------------------------------------- |
| 170 | | |
| 171 | | void scn2661_device::input_callback(UINT8 state) |
| 172 | | { |
| 173 | | } |
| 174 | | |
| 175 | | |
| 176 | | //------------------------------------------------- |
| 177 | | // read - |
| 178 | | //------------------------------------------------- |
| 179 | | |
| 180 | | READ8_MEMBER( scn2661_device::read ) |
| 181 | | { |
| 182 | | UINT8 data = 0; |
| 183 | | |
| 184 | | switch (offset & 0x03) |
| 185 | | { |
| 186 | | case REGISTER_HOLDING: |
| 187 | | data = m_rhr; |
| 188 | | break; |
| 189 | | |
| 190 | | case REGISTER_STATUS: |
| 191 | | data = m_sr; |
| 192 | | break; |
| 193 | | |
| 194 | | case REGISTER_MODE: |
| 195 | | break; |
| 196 | | |
| 197 | | case REGISTER_COMMAND: |
| 198 | | data = m_cr; |
| 199 | | break; |
| 200 | | } |
| 201 | | |
| 202 | | return data; |
| 203 | | } |
| 204 | | |
| 205 | | |
| 206 | | //------------------------------------------------- |
| 207 | | // write - transmitter buffer register write |
| 208 | | //------------------------------------------------- |
| 209 | | |
| 210 | | WRITE8_MEMBER( scn2661_device::write ) |
| 211 | | { |
| 212 | | switch (offset & 0x03) |
| 213 | | { |
| 214 | | case REGISTER_HOLDING: |
| 215 | | m_thr = data; |
| 216 | | break; |
| 217 | | |
| 218 | | case REGISTER_SYNC: |
| 219 | | break; |
| 220 | | |
| 221 | | case REGISTER_MODE: |
| 222 | | break; |
| 223 | | |
| 224 | | case REGISTER_COMMAND: |
| 225 | | m_cr = data; |
| 226 | | break; |
| 227 | | } |
| 228 | | } |
| 229 | | |
| 230 | | |
| 231 | | //------------------------------------------------- |
| 232 | | // rxc_w - receiver clock |
| 233 | | //------------------------------------------------- |
| 234 | | |
| 235 | | WRITE_LINE_MEMBER( scn2661_device::rxc_w ) |
| 236 | | { |
| 237 | | } |
| 238 | | |
| 239 | | |
| 240 | | //------------------------------------------------- |
| 241 | | // txc_w - transmitter clock |
| 242 | | //------------------------------------------------- |
| 243 | | |
| 244 | | WRITE_LINE_MEMBER( scn2661_device::txc_w ) |
| 245 | | { |
| 246 | | } |
| 247 | | |
| 248 | | |
| 249 | | //------------------------------------------------- |
| 250 | | // dsr_w - data set ready |
| 251 | | //------------------------------------------------- |
| 252 | | |
| 253 | | WRITE_LINE_MEMBER( scn2661_device::dsr_w ) |
| 254 | | { |
| 255 | | } |
| 256 | | |
| 257 | | |
| 258 | | //------------------------------------------------- |
| 259 | | // dcd_w - data carrier detect |
| 260 | | //------------------------------------------------- |
| 261 | | |
| 262 | | WRITE_LINE_MEMBER( scn2661_device::dcd_w ) |
| 263 | | { |
| 264 | | } |
| 265 | | |
| 266 | | |
| 267 | | //------------------------------------------------- |
| 268 | | // cts_w - clear to send |
| 269 | | //------------------------------------------------- |
| 270 | | |
| 271 | | WRITE_LINE_MEMBER( scn2661_device::cts_w ) |
| 272 | | { |
| 273 | | } |
| 274 | | |
| 275 | | |
| 276 | | //------------------------------------------------- |
| 277 | | // rxrdy_r - receiver ready |
| 278 | | //------------------------------------------------- |
| 279 | | |
| 280 | | READ_LINE_MEMBER( scn2661_device::rxrdy_r ) |
| 281 | | { |
| 282 | | return CLEAR_LINE; |
| 283 | | } |
| 284 | | |
| 285 | | |
| 286 | | //------------------------------------------------- |
| 287 | | // txemt_r - transmitter empty |
| 288 | | //------------------------------------------------- |
| 289 | | |
| 290 | | READ_LINE_MEMBER( scn2661_device::txemt_r ) |
| 291 | | { |
| 292 | | return CLEAR_LINE; |
| 293 | | } |
src/emu/machine/scn2661.h
| r15348 | r15349 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | Philips SCN2661 Enhanced Programmable Communications Interface emulation |
| 4 | | |
| 5 | | Copyright the MESS Team. |
| 6 | | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | | |
| 8 | | **************************************************************************** |
| 9 | | _____ _____ |
| 10 | | D2 1 |* \_/ | 28 D1 |
| 11 | | D3 2 | | 27 D0 |
| 12 | | RxD 3 | | 26 Vcc |
| 13 | | GND 4 | | 25 _RxC/BKDET |
| 14 | | D4 5 | | 24 _DTR |
| 15 | | D5 6 | | 23 _RTS |
| 16 | | D6 7 | SCN2661 | 22 _DSR |
| 17 | | D7 8 | | 21 RESET |
| 18 | | _TxC/XSYNC 9 | | 20 BRCLK |
| 19 | | A1 10 | | 19 TxD |
| 20 | | _CE 11 | | 18 _TxEMT/DSCHG |
| 21 | | A0 12 | | 17 _CTS |
| 22 | | _R/W 13 | | 16 _DCD |
| 23 | | _RxRDY 14 |_____________| 15 _TxRDY |
| 24 | | |
| 25 | | ***************************************************************************/ |
| 26 | | |
| 27 | | #pragma once |
| 28 | | |
| 29 | | #ifndef __SCN2661__ |
| 30 | | #define __SCN2661__ |
| 31 | | |
| 32 | | #include "emu.h" |
| 33 | | |
| 34 | | |
| 35 | | |
| 36 | | /*************************************************************************** |
| 37 | | DEVICE CONFIGURATION MACROS |
| 38 | | ***************************************************************************/ |
| 39 | | |
| 40 | | #define MCFG_SCN2661_ADD(_tag, _clock, _config) \ |
| 41 | | MCFG_DEVICE_ADD(_tag, SCN2661, _clock) \ |
| 42 | | MCFG_DEVICE_CONFIG(_config) |
| 43 | | |
| 44 | | |
| 45 | | #define SCN2661_INTERFACE(_name) \ |
| 46 | | const scn2661_interface (_name) = |
| 47 | | |
| 48 | | |
| 49 | | |
| 50 | | /*************************************************************************** |
| 51 | | TYPE DEFINITIONS |
| 52 | | ***************************************************************************/ |
| 53 | | |
| 54 | | // ======================> scn2661_interface |
| 55 | | |
| 56 | | struct scn2661_interface |
| 57 | | { |
| 58 | | int m_rxc; |
| 59 | | int m_txc; |
| 60 | | |
| 61 | | devcb_read_line m_in_rxd_cb; |
| 62 | | devcb_write_line m_out_txd_cb; |
| 63 | | |
| 64 | | devcb_write_line m_out_rxrdy_cb; |
| 65 | | devcb_write_line m_out_txrdy_cb; |
| 66 | | devcb_write_line m_out_rts_cb; |
| 67 | | devcb_write_line m_out_dtr_cb; |
| 68 | | devcb_write_line m_out_txemt_dschg_cb; |
| 69 | | devcb_write_line m_out_bkdet_cb; |
| 70 | | devcb_write_line m_out_xsync_cb; |
| 71 | | }; |
| 72 | | |
| 73 | | |
| 74 | | // ======================> scn2661_device |
| 75 | | |
| 76 | | class scn2661_device : public device_t, |
| 77 | | public device_serial_interface, |
| 78 | | public scn2661_interface |
| 79 | | { |
| 80 | | public: |
| 81 | | // construction/destruction |
| 82 | | scn2661_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 83 | | |
| 84 | | DECLARE_READ8_MEMBER( read ); |
| 85 | | DECLARE_WRITE8_MEMBER( write ); |
| 86 | | |
| 87 | | DECLARE_WRITE_LINE_MEMBER( rxc_w ); |
| 88 | | DECLARE_WRITE_LINE_MEMBER( txc_w ); |
| 89 | | |
| 90 | | DECLARE_WRITE_LINE_MEMBER( dsr_w ); |
| 91 | | DECLARE_WRITE_LINE_MEMBER( dcd_w ); |
| 92 | | DECLARE_WRITE_LINE_MEMBER( cts_w ); |
| 93 | | |
| 94 | | DECLARE_READ_LINE_MEMBER( rxrdy_r ); |
| 95 | | DECLARE_READ_LINE_MEMBER( txemt_r ); |
| 96 | | |
| 97 | | protected: |
| 98 | | // device-level overrides |
| 99 | | virtual void device_config_complete(); |
| 100 | | virtual void device_start(); |
| 101 | | virtual void device_reset(); |
| 102 | | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 103 | | |
| 104 | | // device_serial_interface overrides |
| 105 | | virtual void input_callback(UINT8 state); |
| 106 | | |
| 107 | | private: |
| 108 | | inline void receive(); |
| 109 | | inline void transmit(); |
| 110 | | |
| 111 | | enum |
| 112 | | { |
| 113 | | TIMER_RX, |
| 114 | | TIMER_TX |
| 115 | | }; |
| 116 | | |
| 117 | | devcb_resolved_read_line m_in_rxd_func; |
| 118 | | devcb_resolved_write_line m_out_txd_func; |
| 119 | | |
| 120 | | devcb_resolved_write_line m_out_rxrdy_func; |
| 121 | | devcb_resolved_write_line m_out_txrdy_func; |
| 122 | | devcb_resolved_write_line m_out_rts_func; |
| 123 | | devcb_resolved_write_line m_out_dtr_func; |
| 124 | | devcb_resolved_write_line m_out_txemt_dschg_func; |
| 125 | | devcb_resolved_write_line m_out_bkdet_func; |
| 126 | | devcb_resolved_write_line m_out_xsync_func; |
| 127 | | |
| 128 | | UINT8 m_rhr; |
| 129 | | UINT8 m_thr; |
| 130 | | UINT8 m_cr; |
| 131 | | UINT8 m_sr; |
| 132 | | UINT8 m_mr1; |
| 133 | | UINT8 m_mr2; |
| 134 | | UINT8 m_syn1; |
| 135 | | UINT8 m_syn2; |
| 136 | | UINT8 m_dle; |
| 137 | | |
| 138 | | int m_mr_index; |
| 139 | | int m_sync_index; |
| 140 | | |
| 141 | | // timers |
| 142 | | emu_timer *m_rx_timer; |
| 143 | | emu_timer *m_tx_timer; |
| 144 | | }; |
| 145 | | |
| 146 | | |
| 147 | | // device type definition |
| 148 | | extern const device_type SCN2661; |
| 149 | | |
| 150 | | |
| 151 | | |
| 152 | | #endif |
src/emu/machine/mc2661.c
| r0 | r15349 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | Motorola MC2661/MC68661 Enhanced Programmable Communications Interface |
| 4 | |
| 5 | Copyright the MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | ***************************************************************************/ |
| 9 | |
| 10 | #include "mc2661.h" |
| 11 | |
| 12 | |
| 13 | |
| 14 | //************************************************************************** |
| 15 | // DEVICE DEFINITIONS |
| 16 | //************************************************************************** |
| 17 | |
| 18 | const device_type MC2661 = &device_creator<mc2661_device>; |
| 19 | |
| 20 | |
| 21 | |
| 22 | //************************************************************************** |
| 23 | // MACROS / CONSTANTS |
| 24 | //************************************************************************** |
| 25 | |
| 26 | #define LOG 0 |
| 27 | |
| 28 | |
| 29 | enum |
| 30 | { |
| 31 | REGISTER_HOLDING = 0, |
| 32 | REGISTER_STATUS, |
| 33 | REGISTER_SYNC = REGISTER_STATUS, |
| 34 | REGISTER_MODE, |
| 35 | REGISTER_COMMAND |
| 36 | }; |
| 37 | |
| 38 | |
| 39 | #define MODE_BAUD_RATE (m_mr[0] & 0x03) |
| 40 | #define MODE_CHARACTER ((m_mr[0] >> 2) & 0x03) |
| 41 | #define MODE_PARITY BIT(m_mr[0], 4) |
| 42 | #define MODE_PARITY_EVEN BIT(m_mr[0], 5) |
| 43 | #define MODE_TRANSPARENT BIT(m_mr[0], 6) |
| 44 | #define MODE_SINGLE_SYN BIT(m_mr[0], 7) |
| 45 | #define MODE_STOP_BITS ((m_mr[0] >> 6) & 0x03) |
| 46 | |
| 47 | |
| 48 | enum |
| 49 | { |
| 50 | STOP_BITS_INVALID = 0, |
| 51 | STOP_BITS_1, |
| 52 | STOP_BITS_1_5, |
| 53 | STOP_BITS_2 |
| 54 | }; |
| 55 | |
| 56 | |
| 57 | #define SYN1 m_sync[0] |
| 58 | #define SYN2 m_sync[1] |
| 59 | #define DLE m_sync[2] |
| 60 | |
| 61 | |
| 62 | #define COMMAND_TXEN BIT(m_cr, 0) |
| 63 | #define COMMAND_DTR BIT(m_cr, 1) |
| 64 | #define COMMAND_RXEN BIT(m_cr, 2) |
| 65 | #define COMMAND_BREAK BIT(m_cr, 3) |
| 66 | #define COMMAND_DLE BIT(m_cr, 3) |
| 67 | #define COMMAND_RESET BIT(m_cr, 4) |
| 68 | #define COMMAND_RTS BIT(m_cr, 5) |
| 69 | #define COMMAND_MODE (m_cr >> 6) |
| 70 | |
| 71 | |
| 72 | enum |
| 73 | { |
| 74 | MODE_NORMAL = 0, |
| 75 | MODE_ASYNC, |
| 76 | MODE_LOCAL_LOOP_BACK, |
| 77 | MODE_REMOTE_LOOP_BACK |
| 78 | }; |
| 79 | |
| 80 | |
| 81 | #define STATUS_TXRDY 0x01 |
| 82 | #define STATUS_RXRDY 0x02 |
| 83 | #define STATUS_TXEMT 0x04 |
| 84 | #define STATUS_PE 0x08 |
| 85 | #define STATUS_DLE 0x08 |
| 86 | #define STATUS_OVERRUN 0x10 |
| 87 | #define STATUS_FE 0x20 |
| 88 | #define STATUS_SYN 0x20 |
| 89 | #define STATUS_DCD 0x40 |
| 90 | #define STATUS_DSR 0x80 |
| 91 | |
| 92 | |
| 93 | |
| 94 | //************************************************************************** |
| 95 | // INLINE HELPERS |
| 96 | //************************************************************************** |
| 97 | |
| 98 | //------------------------------------------------- |
| 99 | // receive - |
| 100 | //------------------------------------------------- |
| 101 | |
| 102 | inline void mc2661_device::receive() |
| 103 | { |
| 104 | } |
| 105 | |
| 106 | |
| 107 | //------------------------------------------------- |
| 108 | // transmit - |
| 109 | //------------------------------------------------- |
| 110 | |
| 111 | inline void mc2661_device::transmit() |
| 112 | { |
| 113 | } |
| 114 | |
| 115 | |
| 116 | |
| 117 | //************************************************************************** |
| 118 | // LIVE DEVICE |
| 119 | //************************************************************************** |
| 120 | |
| 121 | //------------------------------------------------- |
| 122 | // mc2661_device - constructor |
| 123 | //------------------------------------------------- |
| 124 | |
| 125 | mc2661_device::mc2661_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 126 | : device_t(mconfig, MC2661, "MC2661", tag, owner, clock), |
| 127 | device_serial_interface(mconfig, *this) |
| 128 | { |
| 129 | } |
| 130 | |
| 131 | |
| 132 | //------------------------------------------------- |
| 133 | // device_config_complete - perform any |
| 134 | // operations now that the configuration is |
| 135 | // complete |
| 136 | //------------------------------------------------- |
| 137 | |
| 138 | void mc2661_device::device_config_complete() |
| 139 | { |
| 140 | // inherit a copy of the static data |
| 141 | const mc2661_interface *intf = reinterpret_cast<const mc2661_interface *>(static_config()); |
| 142 | if (intf != NULL) |
| 143 | *static_cast<mc2661_interface *>(this) = *intf; |
| 144 | |
| 145 | // or initialize to defaults if none provided |
| 146 | else |
| 147 | { |
| 148 | memset(&m_in_rxd_cb, 0, sizeof(m_in_rxd_cb)); |
| 149 | memset(&m_out_txd_cb, 0, sizeof(m_out_txd_cb)); |
| 150 | memset(&m_out_rxrdy_cb, 0, sizeof(m_out_rxrdy_cb)); |
| 151 | memset(&m_out_txrdy_cb, 0, sizeof(m_out_txrdy_cb)); |
| 152 | memset(&m_out_rts_cb, 0, sizeof(m_out_rts_cb)); |
| 153 | memset(&m_out_dtr_cb, 0, sizeof(m_out_dtr_cb)); |
| 154 | memset(&m_out_txemt_dschg_cb, 0, sizeof(m_out_txemt_dschg_cb)); |
| 155 | memset(&m_out_bkdet_cb, 0, sizeof(m_out_bkdet_cb)); |
| 156 | memset(&m_out_xsync_cb, 0, sizeof(m_out_xsync_cb)); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | |
| 161 | //------------------------------------------------- |
| 162 | // device_start - device-specific startup |
| 163 | //------------------------------------------------- |
| 164 | |
| 165 | void mc2661_device::device_start() |
| 166 | { |
| 167 | // resolve callbacks |
| 168 | m_in_rxd_func.resolve(m_in_rxd_cb, *this); |
| 169 | m_out_txd_func.resolve(m_out_txd_cb, *this); |
| 170 | m_out_rxrdy_func.resolve(m_out_rxrdy_cb, *this); |
| 171 | m_out_txrdy_func.resolve(m_out_txrdy_cb, *this); |
| 172 | m_out_rts_func.resolve(m_out_rts_cb, *this); |
| 173 | m_out_dtr_func.resolve(m_out_dtr_cb, *this); |
| 174 | m_out_txemt_dschg_func.resolve(m_out_txemt_dschg_cb, *this); |
| 175 | m_out_bkdet_func.resolve(m_out_bkdet_cb, *this); |
| 176 | m_out_xsync_func.resolve(m_out_xsync_cb, *this); |
| 177 | |
| 178 | // create the timers |
| 179 | if (m_rxc > 0) |
| 180 | { |
| 181 | m_rx_timer = timer_alloc(TIMER_RX); |
| 182 | m_rx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_rxc)); |
| 183 | } |
| 184 | |
| 185 | if (m_txc > 0) |
| 186 | { |
| 187 | m_tx_timer = timer_alloc(TIMER_TX); |
| 188 | m_tx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_txc)); |
| 189 | } |
| 190 | |
| 191 | // save state |
| 192 | save_item(NAME(m_rhr)); |
| 193 | save_item(NAME(m_thr)); |
| 194 | save_item(NAME(m_cr)); |
| 195 | save_item(NAME(m_sr)); |
| 196 | save_item(NAME(m_mr)); |
| 197 | save_item(NAME(m_sync)); |
| 198 | save_item(NAME(m_mode_index)); |
| 199 | save_item(NAME(m_sync_index)); |
| 200 | } |
| 201 | |
| 202 | |
| 203 | //------------------------------------------------- |
| 204 | // device_reset - device-specific reset |
| 205 | //------------------------------------------------- |
| 206 | |
| 207 | void mc2661_device::device_reset() |
| 208 | { |
| 209 | transmit_register_reset(); |
| 210 | receive_register_reset(); |
| 211 | |
| 212 | m_mr[0] = m_mr[1] = 0; |
| 213 | m_sync[0] = m_sync[1] = m_sync[2] = 0; |
| 214 | m_cr = 0; |
| 215 | m_sr = 0; |
| 216 | |
| 217 | m_mode_index = 0; |
| 218 | m_sync_index = 0; |
| 219 | |
| 220 | m_out_txd_func(1); |
| 221 | m_out_rxrdy_func(CLEAR_LINE); |
| 222 | m_out_txrdy_func(CLEAR_LINE); |
| 223 | m_out_rts_func(1); |
| 224 | m_out_dtr_func(1); |
| 225 | m_out_txemt_dschg_func(ASSERT_LINE); |
| 226 | m_out_bkdet_func(0); |
| 227 | m_out_xsync_func(0); |
| 228 | } |
| 229 | |
| 230 | |
| 231 | //------------------------------------------------- |
| 232 | // device_timer - handle timer events |
| 233 | //------------------------------------------------- |
| 234 | |
| 235 | void mc2661_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 236 | { |
| 237 | switch (id) |
| 238 | { |
| 239 | case TIMER_RX: |
| 240 | rxc_w(1); |
| 241 | break; |
| 242 | |
| 243 | case TIMER_TX: |
| 244 | txc_w(1); |
| 245 | break; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | |
| 250 | //------------------------------------------------- |
| 251 | // input_callback - |
| 252 | //------------------------------------------------- |
| 253 | |
| 254 | void mc2661_device::input_callback(UINT8 state) |
| 255 | { |
| 256 | } |
| 257 | |
| 258 | |
| 259 | //------------------------------------------------- |
| 260 | // read - register read |
| 261 | //------------------------------------------------- |
| 262 | |
| 263 | READ8_MEMBER( mc2661_device::read ) |
| 264 | { |
| 265 | UINT8 data = 0; |
| 266 | |
| 267 | switch (offset & 0x03) |
| 268 | { |
| 269 | case REGISTER_HOLDING: |
| 270 | data = m_rhr; |
| 271 | break; |
| 272 | |
| 273 | case REGISTER_STATUS: |
| 274 | data = m_sr; |
| 275 | break; |
| 276 | |
| 277 | case REGISTER_MODE: |
| 278 | data = m_mr[m_mode_index]; |
| 279 | |
| 280 | m_mode_index++; |
| 281 | m_mode_index &= 0x01; |
| 282 | break; |
| 283 | |
| 284 | case REGISTER_COMMAND: |
| 285 | m_mode_index = 0; |
| 286 | m_sync_index = 0; |
| 287 | |
| 288 | data = m_cr; |
| 289 | break; |
| 290 | } |
| 291 | |
| 292 | return data; |
| 293 | } |
| 294 | |
| 295 | |
| 296 | //------------------------------------------------- |
| 297 | // write - register write |
| 298 | //------------------------------------------------- |
| 299 | |
| 300 | WRITE8_MEMBER( mc2661_device::write ) |
| 301 | { |
| 302 | switch (offset & 0x03) |
| 303 | { |
| 304 | case REGISTER_HOLDING: |
| 305 | if (LOG) logerror("MC2661 '%s' Transmit Holding Register: %02x\n", tag(), data); |
| 306 | |
| 307 | m_thr = data; |
| 308 | break; |
| 309 | |
| 310 | case REGISTER_SYNC: |
| 311 | if (LOG) logerror("MC2661 '%s' Sync Register %u: %02x\n", tag(), m_sync_index + 1, data); |
| 312 | |
| 313 | m_sync[m_sync_index] = data; |
| 314 | |
| 315 | m_sync_index++; |
| 316 | if (m_sync_index == 3) m_sync_index = 0; |
| 317 | break; |
| 318 | |
| 319 | case REGISTER_MODE: |
| 320 | if (LOG) logerror("MC2661 '%s' Mode Register %u: %02x\n", tag(), m_mode_index + 1, data); |
| 321 | |
| 322 | m_mr[m_mode_index] = data; |
| 323 | |
| 324 | if (m_mode_index == 0) |
| 325 | { |
| 326 | int word_length = 5 + MODE_CHARACTER; |
| 327 | float stop_bits = 0; |
| 328 | int parity_code; |
| 329 | |
| 330 | switch (MODE_STOP_BITS) |
| 331 | { |
| 332 | case STOP_BITS_1: stop_bits = 1; break; |
| 333 | case STOP_BITS_1_5: stop_bits = 1.5; break; |
| 334 | case STOP_BITS_2: stop_bits = 2; break; |
| 335 | } |
| 336 | |
| 337 | if (!MODE_PARITY) parity_code = SERIAL_PARITY_NONE; |
| 338 | else if (MODE_PARITY_EVEN) parity_code = SERIAL_PARITY_EVEN; |
| 339 | else parity_code = SERIAL_PARITY_ODD; |
| 340 | |
| 341 | set_data_frame(word_length, stop_bits, parity_code); |
| 342 | } |
| 343 | |
| 344 | m_mode_index++; |
| 345 | m_mode_index &= 0x01; |
| 346 | break; |
| 347 | |
| 348 | case REGISTER_COMMAND: |
| 349 | if (LOG) logerror("MC2661 '%s' Command Register: %02x\n", tag(), data); |
| 350 | |
| 351 | m_cr = data & 0xef; |
| 352 | |
| 353 | if (COMMAND_RESET) |
| 354 | { |
| 355 | m_sr &= ~(STATUS_FE | STATUS_OVERRUN | STATUS_PE); |
| 356 | } |
| 357 | |
| 358 | m_out_dtr_func(!COMMAND_DTR); |
| 359 | m_out_rts_func(!COMMAND_RTS); |
| 360 | break; |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | |
| 365 | //------------------------------------------------- |
| 366 | // rxc_w - receiver clock |
| 367 | //------------------------------------------------- |
| 368 | |
| 369 | WRITE_LINE_MEMBER( mc2661_device::rxc_w ) |
| 370 | { |
| 371 | } |
| 372 | |
| 373 | |
| 374 | //------------------------------------------------- |
| 375 | // txc_w - transmitter clock |
| 376 | //------------------------------------------------- |
| 377 | |
| 378 | WRITE_LINE_MEMBER( mc2661_device::txc_w ) |
| 379 | { |
| 380 | } |
| 381 | |
| 382 | |
| 383 | //------------------------------------------------- |
| 384 | // dsr_w - data set ready |
| 385 | //------------------------------------------------- |
| 386 | |
| 387 | WRITE_LINE_MEMBER( mc2661_device::dsr_w ) |
| 388 | { |
| 389 | if (LOG) logerror("MC2661 '%s' Data Set Ready: %u\n", tag(), state); |
| 390 | |
| 391 | if (state) |
| 392 | { |
| 393 | m_sr &= ~STATUS_DSR; |
| 394 | } |
| 395 | else |
| 396 | { |
| 397 | m_sr |= STATUS_DSR; |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | |
| 402 | //------------------------------------------------- |
| 403 | // dcd_w - data carrier detect |
| 404 | //------------------------------------------------- |
| 405 | |
| 406 | WRITE_LINE_MEMBER( mc2661_device::dcd_w ) |
| 407 | { |
| 408 | if (LOG) logerror("MC2661 '%s' Data Carrier Detect: %u\n", tag(), state); |
| 409 | |
| 410 | if (state) |
| 411 | { |
| 412 | m_sr &= ~STATUS_DCD; |
| 413 | } |
| 414 | else |
| 415 | { |
| 416 | m_sr |= STATUS_DCD; |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | |
| 421 | //------------------------------------------------- |
| 422 | // cts_w - clear to send |
| 423 | //------------------------------------------------- |
| 424 | |
| 425 | WRITE_LINE_MEMBER( mc2661_device::cts_w ) |
| 426 | { |
| 427 | if (LOG) logerror("MC2661 '%s' Clear to Send: %u\n", tag(), state); |
| 428 | } |
| 429 | |
| 430 | |
| 431 | //------------------------------------------------- |
| 432 | // rxrdy_r - receiver ready |
| 433 | //------------------------------------------------- |
| 434 | |
| 435 | READ_LINE_MEMBER( mc2661_device::rxrdy_r ) |
| 436 | { |
| 437 | return STATUS_RXRDY; |
| 438 | } |
| 439 | |
| 440 | |
| 441 | //------------------------------------------------- |
| 442 | // txemt_r - transmitter empty |
| 443 | //------------------------------------------------- |
| 444 | |
| 445 | READ_LINE_MEMBER( mc2661_device::txemt_r ) |
| 446 | { |
| 447 | return STATUS_TXEMT; |
| 448 | } |
src/emu/machine/mc2661.h
| r0 | r15349 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | Motorola MC2661/MC68661 Enhanced Programmable Communications Interface |
| 4 | |
| 5 | Copyright the MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **************************************************************************** |
| 9 | _____ _____ |
| 10 | D2 1 |* \_/ | 28 D1 |
| 11 | D3 2 | | 27 D0 |
| 12 | RxD 3 | | 26 Vcc |
| 13 | GND 4 | | 25 _RxC/BKDET |
| 14 | D4 5 | | 24 _DTR |
| 15 | D5 6 | | 23 _RTS |
| 16 | D6 7 | MC2661 | 22 _DSR |
| 17 | D7 8 | MC68661 | 21 RESET |
| 18 | _TxC/XSYNC 9 | | 20 BRCLK |
| 19 | A1 10 | | 19 TxD |
| 20 | _CE 11 | | 18 _TxEMT/DSCHG |
| 21 | A0 12 | | 17 _CTS |
| 22 | _R/W 13 | | 16 _DCD |
| 23 | _RxRDY 14 |_____________| 15 _TxRDY |
| 24 | |
| 25 | ***************************************************************************/ |
| 26 | |
| 27 | #pragma once |
| 28 | |
| 29 | #ifndef __MC2661__ |
| 30 | #define __MC2661__ |
| 31 | |
| 32 | #include "emu.h" |
| 33 | |
| 34 | |
| 35 | |
| 36 | /*************************************************************************** |
| 37 | DEVICE CONFIGURATION MACROS |
| 38 | ***************************************************************************/ |
| 39 | |
| 40 | #define MCFG_MC2661_ADD(_tag, _clock, _config) \ |
| 41 | MCFG_DEVICE_ADD(_tag, MC2661, _clock) \ |
| 42 | MCFG_DEVICE_CONFIG(_config) |
| 43 | |
| 44 | |
| 45 | #define MC2661_INTERFACE(_name) \ |
| 46 | const mc2661_interface (_name) = |
| 47 | |
| 48 | |
| 49 | |
| 50 | /*************************************************************************** |
| 51 | TYPE DEFINITIONS |
| 52 | ***************************************************************************/ |
| 53 | |
| 54 | // ======================> mc2661_interface |
| 55 | |
| 56 | struct mc2661_interface |
| 57 | { |
| 58 | int m_rxc; |
| 59 | int m_txc; |
| 60 | |
| 61 | devcb_read_line m_in_rxd_cb; |
| 62 | devcb_write_line m_out_txd_cb; |
| 63 | |
| 64 | devcb_write_line m_out_rxrdy_cb; |
| 65 | devcb_write_line m_out_txrdy_cb; |
| 66 | devcb_write_line m_out_rts_cb; |
| 67 | devcb_write_line m_out_dtr_cb; |
| 68 | devcb_write_line m_out_txemt_dschg_cb; |
| 69 | devcb_write_line m_out_bkdet_cb; |
| 70 | devcb_write_line m_out_xsync_cb; |
| 71 | }; |
| 72 | |
| 73 | |
| 74 | // ======================> mc2661_device |
| 75 | |
| 76 | class mc2661_device : public device_t, |
| 77 | public device_serial_interface, |
| 78 | public mc2661_interface |
| 79 | { |
| 80 | public: |
| 81 | // construction/destruction |
| 82 | mc2661_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 83 | |
| 84 | DECLARE_READ8_MEMBER( read ); |
| 85 | DECLARE_WRITE8_MEMBER( write ); |
| 86 | |
| 87 | DECLARE_WRITE_LINE_MEMBER( rxc_w ); |
| 88 | DECLARE_WRITE_LINE_MEMBER( txc_w ); |
| 89 | |
| 90 | DECLARE_WRITE_LINE_MEMBER( dsr_w ); |
| 91 | DECLARE_WRITE_LINE_MEMBER( dcd_w ); |
| 92 | DECLARE_WRITE_LINE_MEMBER( cts_w ); |
| 93 | |
| 94 | DECLARE_READ_LINE_MEMBER( rxrdy_r ); |
| 95 | DECLARE_READ_LINE_MEMBER( txemt_r ); |
| 96 | |
| 97 | protected: |
| 98 | // device-level overrides |
| 99 | virtual void device_config_complete(); |
| 100 | virtual void device_start(); |
| 101 | virtual void device_reset(); |
| 102 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 103 | |
| 104 | // device_serial_interface overrides |
| 105 | virtual void input_callback(UINT8 state); |
| 106 | |
| 107 | private: |
| 108 | inline void receive(); |
| 109 | inline void transmit(); |
| 110 | |
| 111 | enum |
| 112 | { |
| 113 | TIMER_RX, |
| 114 | TIMER_TX |
| 115 | }; |
| 116 | |
| 117 | devcb_resolved_read_line m_in_rxd_func; |
| 118 | devcb_resolved_write_line m_out_txd_func; |
| 119 | |
| 120 | devcb_resolved_write_line m_out_rxrdy_func; |
| 121 | devcb_resolved_write_line m_out_txrdy_func; |
| 122 | devcb_resolved_write_line m_out_rts_func; |
| 123 | devcb_resolved_write_line m_out_dtr_func; |
| 124 | devcb_resolved_write_line m_out_txemt_dschg_func; |
| 125 | devcb_resolved_write_line m_out_bkdet_func; |
| 126 | devcb_resolved_write_line m_out_xsync_func; |
| 127 | |
| 128 | UINT8 m_rhr; |
| 129 | UINT8 m_thr; |
| 130 | UINT8 m_cr; |
| 131 | UINT8 m_sr; |
| 132 | UINT8 m_mr[2]; |
| 133 | UINT8 m_sync[3]; |
| 134 | |
| 135 | int m_mode_index; |
| 136 | int m_sync_index; |
| 137 | |
| 138 | // timers |
| 139 | emu_timer *m_rx_timer; |
| 140 | emu_timer *m_tx_timer; |
| 141 | }; |
| 142 | |
| 143 | |
| 144 | // device type definition |
| 145 | extern const device_type MC2661; |
| 146 | |
| 147 | |
| 148 | |
| 149 | #endif |
src/mess/machine/wangpckb.c
| r15348 | r15349 | |
| 45 | 45 | |
| 46 | 46 | TODO:
|
| 47 | 47 | |
| 48 | | - mcs51.c does not support 9-bit serial I/O
|
| 48 | - rewrite the mcs51.c serial I/O to replace this horrible, horrible hack
|
| 49 | - locate keys
|
| 49 | 50 | |
| 50 | 51 | */
|
| 51 | 52 | |
| r15348 | r15349 | |
| 57 | 58 | // MACROS / CONSTANTS
|
| 58 | 59 | //**************************************************************************
|
| 59 | 60 | |
| 61 | #define LOG 1
|
| 62 | |
| 60 | 63 | #define I8051_TAG "z5"
|
| 61 | 64 | #define SN76496_TAG "z4"
|
| 62 | 65 | |
| r15348 | r15349 | |
| 99 | 102 | AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_READ(kb_p1_r) AM_WRITENOP
|
| 100 | 103 | AM_RANGE(MCS51_PORT_P2, MCS51_PORT_P2) AM_WRITE(kb_p2_w)
|
| 101 | 104 | AM_RANGE(MCS51_PORT_P3, MCS51_PORT_P3) AM_WRITE(kb_p3_w)
|
| 102 | | //AM_RANGE(0x0000, 0xfeff) AM_READNOP
|
| 105 | AM_RANGE(0x0000, 0xfeff) AM_NOP
|
| 103 | 106 | ADDRESS_MAP_END
|
| 104 | 107 | |
| 105 | 108 | |
| r15348 | r15349 | |
| 396 | 399 | {
|
| 397 | 400 | transmit_register_reset();
|
| 398 | 401 | receive_register_reset();
|
| 402 | |
| 403 | set_out_data_bit(1);
|
| 404 | serial_connection_out();
|
| 399 | 405 | }
|
| 400 | 406 | |
| 401 | 407 | |
| 402 | 408 | //-------------------------------------------------
|
| 403 | | // device_timer - handler timer events
|
| 404 | | //-------------------------------------------------
|
| 405 | | |
| 406 | | void wangpc_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
| 407 | | {
|
| 408 | | }
|
| 409 | | |
| 410 | | |
| 411 | | //-------------------------------------------------
|
| 412 | 409 | // input_callback -
|
| 413 | 410 | //-------------------------------------------------
|
| 414 | 411 | |
| 415 | 412 | void wangpc_keyboard_device::input_callback(UINT8 state)
|
| 416 | 413 | {
|
| 417 | | //logerror("input %02x\n", state);
|
| 418 | | |
| 419 | | // receive
|
| 420 | 414 | int bit = (state & SERIAL_STATE_RX_DATA) ? 1 : 0;
|
| 421 | 415 | |
| 422 | | //logerror("inbit %u \n", bit);
|
| 423 | 416 | receive_register_update_bit(bit);
|
| 424 | 417 | |
| 425 | 418 | if (is_receive_register_full())
|
| 426 | 419 | {
|
| 427 | 420 | m_maincpu->set_input_line(MCS51_RX_LINE, ASSERT_LINE);
|
| 428 | 421 | receive_register_extract();
|
| 429 | | logerror("Wang PC keyboard receive data %02x\n", get_received_char());
|
| 422 | |
| 423 | if (LOG) logerror("Wang PC keyboard receive data %02x\n", get_received_char());
|
| 430 | 424 | }
|
| 431 | | |
| 432 | | // transmit
|
| 433 | | if (!is_transmit_register_empty())
|
| 434 | | {
|
| 435 | | transmit_register_get_data_bit();
|
| 436 | | serial_connection_out();
|
| 437 | | }
|
| 438 | 425 | }
|
| 439 | 426 | |
| 440 | 427 | |
| r15348 | r15349 | |
| 458 | 445 | {
|
| 459 | 446 | wangpc_keyboard_device *kb = static_cast<wangpc_keyboard_device *>(device->owner());
|
| 460 | 447 | |
| 461 | | logerror("Wang PC keyboard transmit data %02x\n", data);
|
| 448 | if (LOG) logerror("Wang PC keyboard transmit data %02x\n", data);
|
| 462 | 449 | |
| 463 | 450 | kb->transmit_register_setup(data);
|
| 451 | |
| 452 | // HACK bang the bits out immediately
|
| 453 | while (!kb->is_transmit_register_empty())
|
| 454 | {
|
| 455 | kb->transmit_register_send_bit();
|
| 456 | }
|
| 464 | 457 | }
|
| 465 | 458 | |
| 466 | 459 | |
src/mess/drivers/wangpc.c
| r15348 | r15349 | |
| 12 | 12 | |
| 13 | 13 | TODO:
|
| 14 | 14 | |
| 15 | | - boot
|
| 16 | 15 | - keyboard
|
| 17 | | - floppy
|
| 18 | | - serial
|
| 16 | - upd765.c drive polling (POST expects 4 consecutive Sense Interrupt Status commands to return xx,xx,xx,C3 = ready state changed on drive 3)
|
| 17 | - floppy door disturbed interrupt
|
| 18 | - floppy door open status
|
| 19 | 19 | - hard disk
|
| 20 | 20 | |
| 21 | 21 | */
|
| r15348 | r15349 | |
| 43 | 43 | |
| 44 | 44 | void wangpc_state::select_drive(int drive, bool select)
|
| 45 | 45 | {
|
| 46 | | if (LOG) logerror("%sselect drive %u\n", select ? "" : "De", drive + 1);
|
| 46 | if (LOG) logerror("%s: %sselect drive %u\n", machine().describe_context(), select ? "" : "De", drive + 1);
|
| 47 | 47 | |
| 48 | 48 | int state = select ? 0 : 1;
|
| 49 | 49 | |
| r15348 | r15349 | |
| 59 | 59 | |
| 60 | 60 | void wangpc_state::set_motor(int drive, bool motor)
|
| 61 | 61 | {
|
| 62 | | if (LOG) logerror("Motor %u %s\n", drive + 1, motor ? "on" : "off");
|
| 62 | if (LOG) logerror("%s: Motor %u %s\n", machine().describe_context(), drive + 1, motor ? "on" : "off");
|
| 63 | 63 | |
| 64 | 64 | int state = motor ? 0 : 1;
|
| 65 | 65 | |
| r15348 | r15349 | |
| 75 | 75 | |
| 76 | 76 | void wangpc_state::fdc_reset()
|
| 77 | 77 | {
|
| 78 | | if (LOG) logerror("FDC reset\n");
|
| 78 | if (LOG) logerror("%s: FDC reset\n", machine().describe_context());
|
| 79 | 79 | |
| 80 | 80 | upd765_reset_w(m_fdc, 1);
|
| 81 | 81 | upd765_reset_w(m_fdc, 0);
|
| r15348 | r15349 | |
| 83 | 83 | |
| 84 | 84 | void wangpc_state::fdc_tc()
|
| 85 | 85 | {
|
| 86 | | if (LOG) logerror("FDC TC\n");
|
| 86 | if (LOG) logerror("%s: FDC TC\n", machine().describe_context());
|
| 87 | 87 | |
| 88 | 88 | upd765_tc_w(m_fdc, 1);
|
| 89 | 89 | upd765_tc_w(m_fdc, 0);
|
| r15348 | r15349 | |
| 109 | 109 | m_fdc_tc_enable = BIT(data, 0);
|
| 110 | 110 | m_fdc_dma_enable = BIT(data, 1);
|
| 111 | 111 | |
| 112 | | if (LOG) logerror("Enable /EOP %u\n", m_fdc_tc_enable);
|
| 113 | | if (LOG) logerror("Disable /DREQ2 %u\n", m_fdc_dma_enable);
|
| 112 | if (LOG) logerror("%s: Enable /EOP %u\n", machine().describe_context(), m_fdc_tc_enable);
|
| 113 | if (LOG) logerror("%s: Disable /DREQ2 %u\n", machine().describe_context(), m_fdc_dma_enable);
|
| 114 | 114 | |
| 115 | 115 | update_fdc_tc();
|
| 116 | 116 | update_fdc_drq();
|
| r15348 | r15349 | |
| 264 | 264 | |
| 265 | 265 | WRITE8_MEMBER( wangpc_state::dma_page_w )
|
| 266 | 266 | {
|
| 267 | | if (LOG) logerror("DMA page %u: %01x\n", offset, data & 0x0f);
|
| 267 | if (LOG) logerror("%s: DMA page %u: %01x\n", machine().describe_context(), offset, data & 0x0f);
|
| 268 | 268 | |
| 269 | 269 | m_dma_page[offset] = data & 0x0f;
|
| 270 | 270 | }
|
| r15348 | r15349 | |
| 306 | 306 | |
| 307 | 307 | WRITE8_MEMBER( wangpc_state::timer0_irq_clr_w )
|
| 308 | 308 | {
|
| 309 | | //if (LOG) logerror("Timer 0 IRQ clear\n");
|
| 309 | //if (LOG) logerror("%s: Timer 0 IRQ clear\n", machine().describe_context());
|
| 310 | 310 | |
| 311 | 311 | pic8259_ir0_w(m_pic, CLEAR_LINE);
|
| 312 | 312 | }
|
| r15348 | r15349 | |
| 318 | 318 | |
| 319 | 319 | READ8_MEMBER( wangpc_state::timer2_irq_clr_r )
|
| 320 | 320 | {
|
| 321 | | //if (LOG) logerror("Timer 2 IRQ clear\n");
|
| 321 | //if (LOG) logerror("%s: Timer 2 IRQ clear\n", machine().describe_context());
|
| 322 | 322 | |
| 323 | 323 | m_timer2_irq = 1;
|
| 324 | 324 | check_level1_interrupts();
|
| r15348 | r15349 | |
| 333 | 333 | |
| 334 | 334 | WRITE8_MEMBER( wangpc_state::nmi_mask_w )
|
| 335 | 335 | {
|
| 336 | | if (LOG) logerror("NMI mask %02x\n", data);
|
| 336 | if (LOG) logerror("%s: NMI mask %02x\n", machine().describe_context(), data);
|
| 337 | 337 | }
|
| 338 | 338 | |
| 339 | 339 | |
| r15348 | r15349 | |
| 343 | 343 | |
| 344 | 344 | READ8_MEMBER( wangpc_state::led_on_r )
|
| 345 | 345 | {
|
| 346 | | if (LOG) logerror("LED on\n");
|
| 346 | if (LOG) logerror("%s: Diagnostic LED on\n", machine().describe_context());
|
| 347 | 347 | |
| 348 | 348 | output_set_led_value(LED_DIAGNOSTIC, 1);
|
| 349 | 349 | |
| r15348 | r15349 | |
| 357 | 357 | |
| 358 | 358 | WRITE8_MEMBER( wangpc_state::fpu_mask_w )
|
| 359 | 359 | {
|
| 360 | | if (LOG) logerror("FPU mask %02x\n", data);
|
| 360 | if (LOG) logerror("%s: FPU mask %02x\n", machine().describe_context(), data);
|
| 361 | 361 | }
|
| 362 | 362 | |
| 363 | 363 | |
| r15348 | r15349 | |
| 367 | 367 | |
| 368 | 368 | WRITE8_MEMBER( wangpc_state::uart_tbre_clr_w )
|
| 369 | 369 | {
|
| 370 | | if (LOG) logerror("TBRE clear\n");
|
| 370 | if (LOG) logerror("%s: TBRE clear\n", machine().describe_context());
|
| 371 | 371 | |
| 372 | 372 | m_uart_tbre = 0;
|
| 373 | 373 | check_level2_interrupts();
|
| r15348 | r15349 | |
| 382 | 382 | {
|
| 383 | 383 | m_uart_dr = 0;
|
| 384 | 384 | check_level2_interrupts();
|
| 385 |
|
| 386 | UINT8 data = m_uart->read(space, 0);
|
| 385 | 387 | |
| 386 | | return m_uart->read(space, 0);
|
| 388 | if (LOG) logerror("%s: UART read %02x\n", machine().describe_context(), data);
|
| 389 | |
| 390 | return data;
|
| 387 | 391 | }
|
| 388 | 392 | |
| 389 | 393 | |
| r15348 | r15349 | |
| 393 | 397 | |
| 394 | 398 | WRITE8_MEMBER( wangpc_state::uart_w )
|
| 395 | 399 | {
|
| 396 | | if (LOG) logerror("UART write %02x\n", data);
|
| 400 | if (LOG) logerror("%s: UART write %02x\n", machine().describe_context(), data);
|
| 397 | 401 | |
| 398 | 402 | switch (data)
|
| 399 | 403 | {
|
| r15348 | r15349 | |
| 457 | 461 | |
| 458 | 462 | READ8_MEMBER( wangpc_state::busy_clr_r )
|
| 459 | 463 | {
|
| 460 | | if (LOG) logerror("BUSY clear\n");
|
| 464 | if (LOG) logerror("%s: BUSY clear\n", machine().describe_context());
|
| 461 | 465 | |
| 462 | 466 | m_busy = 1;
|
| 463 | 467 | check_level1_interrupts();
|
| r15348 | r15349 | |
| 472 | 476 | |
| 473 | 477 | WRITE8_MEMBER( wangpc_state::acknlg_clr_w )
|
| 474 | 478 | {
|
| 475 | | if (LOG) logerror("ACKNLG clear\n");
|
| 479 | if (LOG) logerror("%s: ACKNLG clear\n", machine().describe_context());
|
| 476 | 480 | |
| 477 | 481 | m_acknlg = 1;
|
| 478 | 482 | check_level1_interrupts();
|
| r15348 | r15349 | |
| 485 | 489 | |
| 486 | 490 | READ8_MEMBER( wangpc_state::led_off_r )
|
| 487 | 491 | {
|
| 488 | | if (LOG) logerror("LED off\n");
|
| 492 | if (LOG) logerror("%s: Diagnostic LED off\n", machine().describe_context());
|
| 489 | 493 | |
| 490 | 494 | output_set_led_value(LED_DIAGNOSTIC, 0);
|
| 491 | 495 | |
| r15348 | r15349 | |
| 499 | 503 | |
| 500 | 504 | WRITE8_MEMBER( wangpc_state::parity_nmi_clr_w )
|
| 501 | 505 | {
|
| 502 | | if (LOG) logerror("Parity NMI clear\n");
|
| 506 | if (LOG) logerror("%s: Parity NMI clear\n", machine().describe_context());
|
| 503 | 507 | }
|
| 504 | 508 | |
| 505 | 509 | |
| r15348 | r15349 | |
| 572 | 576 | AM_RANGE(0x1020, 0x1027) AM_DEVREADWRITE8(I8255A_TAG, i8255_device, read, write, 0x00ff)
|
| 573 | 577 | AM_RANGE(0x1040, 0x1047) AM_DEVREADWRITE8_LEGACY(I8253_TAG, pit8253_r, pit8253_w, 0x00ff)
|
| 574 | 578 | AM_RANGE(0x1060, 0x1063) AM_DEVREADWRITE8_LEGACY(I8259A_TAG, pic8259_r, pic8259_w, 0x00ff)
|
| 575 | | AM_RANGE(0x1080, 0x1087) AM_DEVREAD8(SCN2661_TAG, scn2661_device, read, 0x00ff)
|
| 576 | | AM_RANGE(0x1088, 0x108f) AM_DEVWRITE8(SCN2661_TAG, scn2661_device, write, 0x00ff)
|
| 579 | AM_RANGE(0x1080, 0x1087) AM_DEVREAD8(SCN2661_TAG, mc2661_device, read, 0x00ff)
|
| 580 | AM_RANGE(0x1088, 0x108f) AM_DEVWRITE8(SCN2661_TAG, mc2661_device, write, 0x00ff)
|
| 577 | 581 | AM_RANGE(0x10a0, 0x10bf) AM_DEVREADWRITE8_LEGACY(AM9517A_TAG, i8237_r, i8237_w, 0x00ff)
|
| 578 | 582 | AM_RANGE(0x10c2, 0x10c7) AM_WRITE8(dma_page_w, 0x00ff)
|
| 579 | 583 | AM_RANGE(0x10e0, 0x10e1) AM_READWRITE8(status_r, timer0_irq_clr_w, 0x00ff)
|
| r15348 | r15349 | |
| 969 | 973 | |
| 970 | 974 | static IM6402_INTERFACE( uart_intf )
|
| 971 | 975 | {
|
| 976 | 0, // HACK should be 62500
|
| 972 | 977 | 62500,
|
| 973 | | 62500,
|
| 974 | 978 | DEVCB_NULL,
|
| 975 | 979 | DEVCB_NULL,
|
| 976 | 980 | DEVCB_DRIVER_LINE_MEMBER(wangpc_state, uart_dr_w),
|
| r15348 | r15349 | |
| 988 | 992 | check_level1_interrupts();
|
| 989 | 993 | }
|
| 990 | 994 | |
| 991 | | static SCN2661_INTERFACE( epci_intf )
|
| 995 | static MC2661_INTERFACE( epci_intf )
|
| 992 | 996 | {
|
| 993 | 997 | 0,
|
| 994 | 998 | 0,
|
| r15348 | r15349 | |
| 1212 | 1216 | MCFG_I8255A_ADD(I8255A_TAG, ppi_intf)
|
| 1213 | 1217 | MCFG_PIT8253_ADD(I8253_TAG, pit_intf)
|
| 1214 | 1218 | MCFG_IM6402_ADD(IM6402_TAG, uart_intf)
|
| 1215 | | MCFG_SCN2661_ADD(SCN2661_TAG, 0, epci_intf)
|
| 1219 | MCFG_MC2661_ADD(SCN2661_TAG, 0, epci_intf)
|
| 1216 | 1220 | MCFG_UPD765A_ADD(UPD765_TAG, fdc_intf)
|
| 1217 | 1221 | MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(floppy_intf)
|
| 1218 | 1222 | MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, centronics_intf)
|