src/emu/machine/scn2661.c
| r0 | r15337 | |
| 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
| r0 | r15337 | |
| 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/im6402.c
| r15336 | r15337 | |
| 23 | 23 | // MACROS / CONSTANTS
|
| 24 | 24 | //**************************************************************************
|
| 25 | 25 | |
| 26 | | #define LOG 0
|
| 26 | #define LOG 1
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | |
| r15336 | r15337 | |
| 73 | 73 | |
| 74 | 74 | inline void im6402_device::receive()
|
| 75 | 75 | {
|
| 76 | int bit = 1;
|
| 77 | |
| 76 | 78 | if (m_in_rri_func.isnull())
|
| 77 | 79 | {
|
| 78 | | receive_register_update_bit(get_in_data_bit());
|
| 80 | bit = get_in_data_bit();
|
| 79 | 81 | }
|
| 80 | 82 | else
|
| 81 | 83 | {
|
| 82 | | receive_register_update_bit(m_in_rri_func());
|
| 84 | bit = m_in_rri_func();
|
| 83 | 85 | }
|
| 84 | 86 | |
| 87 | // if (LOG) logerror("IM6402 '%s' Receive Bit %u\n", tag(), bit);
|
| 88 |
|
| 89 | receive_register_update_bit(bit);
|
| 90 | |
| 85 | 91 | if (is_receive_register_full())
|
| 86 | 92 | {
|
| 87 | 93 | receive_register_extract();
|
| 88 | 94 | m_rbr = get_received_char();
|
| 95 | |
| 96 | if (LOG) logerror("IM6402 '%s' Receive Data %02x\n", tag(), m_rbr);
|
| 89 | 97 | |
| 90 | 98 | if (m_dr)
|
| 91 | 99 | {
|
| r15336 | r15337 | |
| 105 | 113 | {
|
| 106 | 114 | if (is_transmit_register_empty() && !m_tbre)
|
| 107 | 115 | {
|
| 116 | if (LOG) logerror("IM6402 '%s' Transmit Data %02x\n", tag(), m_tbr);
|
| 117 | |
| 108 | 118 | transmit_register_setup(m_tbr);
|
| 109 | 119 | |
| 110 | 120 | set_tbre(ASSERT_LINE);
|
| r15336 | r15337 | |
| 113 | 123 | |
| 114 | 124 | if (!is_transmit_register_empty())
|
| 115 | 125 | {
|
| 116 | | int bit = transmit_register_get_data_bit();
|
| 126 | int bit = transmit_register_send_bit();
|
| 117 | 127 | |
| 128 | if (LOG) logerror("IM6402 '%s' Transmit Bit %u\n", tag(), bit);
|
| 129 | |
| 118 | 130 | m_out_tro_func(bit);
|
| 119 | | serial_connection_out();
|
| 120 | 131 | |
| 121 | 132 | if (is_transmit_register_empty())
|
| 122 | 133 | {
|
| r15336 | r15337 | |
| 219 | 230 | |
| 220 | 231 | void im6402_device::device_reset()
|
| 221 | 232 | {
|
| 233 | transmit_register_reset();
|
| 234 | receive_register_reset();
|
| 235 | |
| 222 | 236 | m_rrc_count = 0;
|
| 223 | 237 | m_trc_count = 0;
|
| 224 | 238 | |
| r15336 | r15337 | |
| 277 | 291 | |
| 278 | 292 | WRITE8_MEMBER( im6402_device::write )
|
| 279 | 293 | {
|
| 294 | if (LOG) logerror("IM6402 '%s' Transmit Buffer Register %02x\n", tag(), data);
|
| 295 | |
| 280 | 296 | m_tbr = data;
|
| 281 | 297 | |
| 282 | 298 | set_tbre(CLEAR_LINE);
|
| r15336 | r15337 | |
| 433 | 449 | {
|
| 434 | 450 | if (state)
|
| 435 | 451 | {
|
| 452 | if (LOG) logerror("IM6402 '%s' Control Register Load\n", tag());
|
| 453 | |
| 436 | 454 | int word_length = 5 + ((m_cls2 << 1) | m_cls1);
|
| 437 | | int stop_bits = 1 + m_sbs ? ((word_length == 5) ? 0.5 : 1) : 0;
|
| 455 | int stop_bits = 1 + (m_sbs ? ((word_length == 5) ? 0.5 : 1) : 0);
|
| 438 | 456 | int parity_code;
|
| 439 | 457 | |
| 440 | 458 | if (m_pi) parity_code = SERIAL_PARITY_NONE;
|
| r15336 | r15337 | |
| 452 | 470 | |
| 453 | 471 | WRITE_LINE_MEMBER( im6402_device::pi_w )
|
| 454 | 472 | {
|
| 473 | if (LOG) logerror("IM6402 '%s' Parity Inhibit %u\n", tag(), state);
|
| 474 | |
| 455 | 475 | m_pi = state;
|
| 456 | 476 | }
|
| 457 | 477 | |
| r15336 | r15337 | |
| 462 | 482 | |
| 463 | 483 | WRITE_LINE_MEMBER( im6402_device::sbs_w )
|
| 464 | 484 | {
|
| 485 | if (LOG) logerror("IM6402 '%s' Stop Bit Select %u\n", tag(), state);
|
| 486 |
|
| 465 | 487 | m_sbs = state;
|
| 466 | 488 | }
|
| 467 | 489 | |
| r15336 | r15337 | |
| 472 | 494 | |
| 473 | 495 | WRITE_LINE_MEMBER( im6402_device::cls1_w )
|
| 474 | 496 | {
|
| 497 | if (LOG) logerror("IM6402 '%s' Character Length Select 1 %u\n", tag(), state);
|
| 498 | |
| 475 | 499 | m_cls1 = state;
|
| 476 | 500 | }
|
| 477 | 501 | |
| r15336 | r15337 | |
| 482 | 506 | |
| 483 | 507 | WRITE_LINE_MEMBER( im6402_device::cls2_w )
|
| 484 | 508 | {
|
| 509 | if (LOG) logerror("IM6402 '%s' Character Length Select 2 %u\n", tag(), state);
|
| 510 |
|
| 485 | 511 | m_cls2 = state;
|
| 486 | 512 | }
|
| 487 | 513 | |
| r15336 | r15337 | |
| 492 | 518 | |
| 493 | 519 | WRITE_LINE_MEMBER( im6402_device::epe_w )
|
| 494 | 520 | {
|
| 521 | if (LOG) logerror("IM6402 '%s' Even Parity Enable %u\n", tag(), state);
|
| 522 | |
| 495 | 523 | m_epe = state;
|
| 496 | 524 | }
|
src/mess/machine/wangpckb.c
| r15336 | r15337 | |
| 95 | 95 | //-------------------------------------------------
|
| 96 | 96 | |
| 97 | 97 | static ADDRESS_MAP_START( wangpc_keyboard_io, AS_IO, 8, wangpc_keyboard_device )
|
| 98 | AM_RANGE(0x4800, 0x4800) AM_DEVWRITE_LEGACY(SN76496_TAG, sn76496_w)
|
| 98 | 99 | AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_READ(kb_p1_r) AM_WRITENOP
|
| 99 | 100 | AM_RANGE(MCS51_PORT_P2, MCS51_PORT_P2) AM_WRITE(kb_p2_w)
|
| 100 | 101 | AM_RANGE(MCS51_PORT_P3, MCS51_PORT_P3) AM_WRITE(kb_p3_w)
|
| 101 | | AM_RANGE(0x0000, 0xfeff) AM_NOP
|
| 102 | //AM_RANGE(0x0000, 0xfeff) AM_READNOP
|
| 102 | 103 | ADDRESS_MAP_END
|
| 103 | 104 | |
| 104 | 105 | |
| r15336 | r15337 | |
| 393 | 394 | |
| 394 | 395 | void wangpc_keyboard_device::device_reset()
|
| 395 | 396 | {
|
| 397 | transmit_register_reset();
|
| 398 | receive_register_reset();
|
| 396 | 399 | }
|
| 397 | 400 | |
| 398 | 401 | |
| r15336 | r15337 | |
| 402 | 405 | |
| 403 | 406 | void wangpc_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
| 404 | 407 | {
|
| 405 | | // receive
|
| 406 | | int bit = get_in_data_bit();
|
| 407 | | receive_register_update_bit(bit);
|
| 408 | | /*
|
| 409 | | if (start bit)
|
| 410 | | {
|
| 411 | | m_maincpu->set_input_line(MCS51_RX_LINE, ASSERT_LINE);
|
| 412 | | }
|
| 413 | | */
|
| 414 | | if (is_receive_register_full())
|
| 415 | | {
|
| 416 | | receive_register_extract();
|
| 417 | | }
|
| 418 | | |
| 419 | | // transmit
|
| 420 | | if (!is_transmit_register_empty())
|
| 421 | | {
|
| 422 | | transmit_register_get_data_bit();
|
| 423 | | serial_connection_out();
|
| 424 | | }
|
| 425 | 408 | }
|
| 426 | 409 | |
| 427 | 410 | |
| r15336 | r15337 | |
| 431 | 414 | |
| 432 | 415 | void wangpc_keyboard_device::input_callback(UINT8 state)
|
| 433 | 416 | {
|
| 417 | //logerror("input %02x\n", state);
|
| 418 | |
| 419 | // receive
|
| 420 | int bit = (state & SERIAL_STATE_RX_DATA) ? 1 : 0;
|
| 421 | |
| 422 | //logerror("inbit %u \n", bit);
|
| 423 | receive_register_update_bit(bit);
|
| 424 | |
| 425 | if (is_receive_register_full())
|
| 426 | {
|
| 427 | m_maincpu->set_input_line(MCS51_RX_LINE, ASSERT_LINE);
|
| 428 | receive_register_extract();
|
| 429 | logerror("Wang PC keyboard receive data %02x\n", get_received_char());
|
| 430 | }
|
| 431 | |
| 432 | // transmit
|
| 433 | if (!is_transmit_register_empty())
|
| 434 | {
|
| 435 | transmit_register_get_data_bit();
|
| 436 | serial_connection_out();
|
| 437 | }
|
| 434 | 438 | }
|
| 435 | 439 | |
| 436 | 440 | |
| r15336 | r15337 | |
| 454 | 458 | {
|
| 455 | 459 | wangpc_keyboard_device *kb = static_cast<wangpc_keyboard_device *>(device->owner());
|
| 456 | 460 | |
| 461 | logerror("Wang PC keyboard transmit data %02x\n", data);
|
| 462 | |
| 457 | 463 | kb->transmit_register_setup(data);
|
| 458 | 464 | }
|
| 459 | 465 | |
| r15336 | r15337 | |
| 510 | 516 | P2.7
|
| 511 | 517 | |
| 512 | 518 | */
|
| 513 | |
|
| 519 | //logerror("P2 %02x\n", data);
|
| 514 | 520 | m_y = data;
|
| 515 | 521 | }
|
| 516 | 522 | |
| r15336 | r15337 | |
| 535 | 541 | P3.7
|
| 536 | 542 | |
| 537 | 543 | */
|
| 544 | //logerror("P3 %02x\n", data);
|
| 538 | 545 | }
|
src/mess/includes/wangpc.h
| r15336 | r15337 | |
| 13 | 13 | #include "machine/pic8259.h"
|
| 14 | 14 | #include "machine/pit8253.h"
|
| 15 | 15 | #include "machine/ram.h"
|
| 16 | #include "machine/scn2661.h"
|
| 16 | 17 | #include "machine/upd765.h"
|
| 17 | 18 | #include "machine/wangpcbus.h"
|
| 18 | 19 | #include "machine/wangpckb.h"
|
| r15336 | r15337 | |
| 43 | 44 | m_ppi(*this, I8255A_TAG),
|
| 44 | 45 | m_pit(*this, I8253_TAG),
|
| 45 | 46 | m_uart(*this, IM6402_TAG),
|
| 47 | m_epci(*this, SCN2661_TAG),
|
| 46 | 48 | m_fdc(*this, UPD765_TAG),
|
| 47 | 49 | m_ram(*this, RAM_TAG),
|
| 48 | 50 | m_floppy0(*this, FLOPPY_0),
|
| r15336 | r15337 | |
| 51 | 53 | m_kb(*this, WANGPC_KEYBOARD_TAG),
|
| 52 | 54 | m_bus(*this, WANGPC_BUS_TAG),
|
| 53 | 55 | m_timer2_irq(1),
|
| 54 | | m_ecpi_irq(1),
|
| 55 | 56 | m_acknlg(1),
|
| 56 | 57 | m_dav(1),
|
| 57 | 58 | m_busy(1),
|
| r15336 | r15337 | |
| 73 | 74 | required_device<i8255_device> m_ppi;
|
| 74 | 75 | required_device<device_t> m_pit;
|
| 75 | 76 | required_device<im6402_device> m_uart;
|
| 77 | required_device<scn2661_device> m_epci;
|
| 76 | 78 | required_device<device_t> m_fdc;
|
| 77 | 79 | required_device<ram_device> m_ram;
|
| 78 | 80 | required_device<device_t> m_floppy0;
|
| r15336 | r15337 | |
| 154 | 156 | DECLARE_WRITE_LINE_MEMBER( pit2_w );
|
| 155 | 157 | DECLARE_WRITE_LINE_MEMBER( uart_dr_w );
|
| 156 | 158 | DECLARE_WRITE_LINE_MEMBER( uart_tbre_w );
|
| 159 | DECLARE_WRITE_LINE_MEMBER( epci_irq_w );
|
| 157 | 160 | DECLARE_WRITE_LINE_MEMBER( fdc_int_w );
|
| 158 | 161 | DECLARE_WRITE_LINE_MEMBER( fdc_drq_w );
|
| 159 | 162 | DECLARE_WRITE_LINE_MEMBER( ack_w );
|
| r15336 | r15337 | |
| 164 | 167 | int m_dma_channel;
|
| 165 | 168 | |
| 166 | 169 | int m_timer2_irq;
|
| 167 | | int m_ecpi_irq;
|
| 168 | 170 | int m_acknlg;
|
| 169 | 171 | int m_dav;
|
| 170 | 172 | int m_busy;
|
src/mess/drivers/wangpc.c
| r15336 | r15337 | |
| 572 | 572 | AM_RANGE(0x1020, 0x1027) AM_DEVREADWRITE8(I8255A_TAG, i8255_device, read, write, 0x00ff)
|
| 573 | 573 | AM_RANGE(0x1040, 0x1047) AM_DEVREADWRITE8_LEGACY(I8253_TAG, pit8253_r, pit8253_w, 0x00ff)
|
| 574 | 574 | 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)
|
| 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)
|
| 577 | 577 | AM_RANGE(0x10a0, 0x10bf) AM_DEVREADWRITE8_LEGACY(AM9517A_TAG, i8237_r, i8237_w, 0x00ff)
|
| 578 | 578 | AM_RANGE(0x10c2, 0x10c7) AM_WRITE8(dma_page_w, 0x00ff)
|
| 579 | 579 | AM_RANGE(0x10e0, 0x10e1) AM_READWRITE8(status_r, timer0_irq_clr_w, 0x00ff)
|
| r15336 | r15337 | |
| 753 | 753 | |
| 754 | 754 | void wangpc_state::check_level1_interrupts()
|
| 755 | 755 | {
|
| 756 | | int state = !m_timer2_irq | !m_ecpi_irq | !m_acknlg | !m_dav | !m_busy;
|
| 756 | int state = !m_timer2_irq | m_epci->rxrdy_r() | m_epci->txemt_r() | !m_acknlg | !m_dav | !m_busy;
|
| 757 | 757 | |
| 758 | 758 | pic8259_ir1_w(m_pic, state);
|
| 759 | 759 | }
|
| r15336 | r15337 | |
| 835 | 835 | data |= m_timer2_irq;
|
| 836 | 836 | |
| 837 | 837 | // serial interrupt
|
| 838 | | data |= m_ecpi_irq << 1;
|
| 838 | data |= (m_epci->rxrdy_r() | m_epci->txemt_r()) << 1;
|
| 839 | 839 | |
| 840 | 840 | // parallel port interrupt
|
| 841 | 841 | data |= m_acknlg << 2;
|
| r15336 | r15337 | |
| 980 | 980 | |
| 981 | 981 | |
| 982 | 982 | //-------------------------------------------------
|
| 983 | // SCN2661_INTERFACE( epci_intf )
|
| 984 | //-------------------------------------------------
|
| 985 | |
| 986 | WRITE_LINE_MEMBER( wangpc_state::epci_irq_w )
|
| 987 | {
|
| 988 | check_level1_interrupts();
|
| 989 | }
|
| 990 | |
| 991 | static SCN2661_INTERFACE( epci_intf )
|
| 992 | {
|
| 993 | 0,
|
| 994 | 0,
|
| 995 | DEVCB_NULL,
|
| 996 | DEVCB_NULL,
|
| 997 | DEVCB_DRIVER_LINE_MEMBER(wangpc_state, epci_irq_w),
|
| 998 | DEVCB_NULL,
|
| 999 | DEVCB_NULL,
|
| 1000 | DEVCB_NULL,
|
| 1001 | DEVCB_DRIVER_LINE_MEMBER(wangpc_state, epci_irq_w),
|
| 1002 | DEVCB_NULL,
|
| 1003 | DEVCB_NULL
|
| 1004 | };
|
| 1005 | |
| 1006 | |
| 1007 | //-------------------------------------------------
|
| 983 | 1008 | // upd765_interface fdc_intf
|
| 984 | 1009 | //-------------------------------------------------
|
| 985 | 1010 | |
| r15336 | r15337 | |
| 1136 | 1161 | save_item(NAME(m_dma_page));
|
| 1137 | 1162 | save_item(NAME(m_dma_channel));
|
| 1138 | 1163 | save_item(NAME(m_timer2_irq));
|
| 1139 | | save_item(NAME(m_ecpi_irq));
|
| 1140 | 1164 | save_item(NAME(m_acknlg));
|
| 1141 | 1165 | save_item(NAME(m_dav));
|
| 1142 | 1166 | save_item(NAME(m_busy));
|
| r15336 | r15337 | |
| 1188 | 1212 | MCFG_I8255A_ADD(I8255A_TAG, ppi_intf)
|
| 1189 | 1213 | MCFG_PIT8253_ADD(I8253_TAG, pit_intf)
|
| 1190 | 1214 | MCFG_IM6402_ADD(IM6402_TAG, uart_intf)
|
| 1191 | | // SCN2661 for RS-232
|
| 1215 | MCFG_SCN2661_ADD(SCN2661_TAG, 0, epci_intf)
|
| 1192 | 1216 | MCFG_UPD765A_ADD(UPD765_TAG, fdc_intf)
|
| 1193 | 1217 | MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(floppy_intf)
|
| 1194 | 1218 | MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, centronics_intf)
|