From 0ab088f2876ec42864d8d4c8feb67f0625b024d0 Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Tue, 4 Jun 2013 14:13:35 +0000 Subject: [PATCH] (MESS) modernized AY-3-1015 device. [Fabio Priuli] --- src/emu/machine/ay31015.c | 1221 +++++++++++++++++------------------ src/emu/machine/ay31015.h | 220 ++++--- src/mess/drivers/nascom1.c | 2 - src/mess/drivers/ptcsol.c | 87 ++- src/mess/drivers/sorcerer.c | 1 - src/mess/drivers/trs80.c | 1 - src/mess/drivers/z80ne.c | 2 - src/mess/includes/nascom1.h | 17 +- src/mess/includes/z80ne.h | 3 +- src/mess/machine/nascom1.c | 36 +- src/mess/machine/sorcerer.c | 48 +- src/mess/machine/trs80.c | 56 +- src/mess/machine/z80ne.c | 58 +- 13 files changed, 874 insertions(+), 878 deletions(-) diff --git a/src/emu/machine/ay31015.c b/src/emu/machine/ay31015.c index 3b46014de19..752a68e1914 100644 --- a/src/emu/machine/ay31015.c +++ b/src/emu/machine/ay31015.c @@ -72,51 +72,6 @@ Start bit (low), Bit 0, Bit 1... highest bit, Parity bit (if enabled), 1-2 stop #include "emu.h" #include "ay31015.h" -enum state_t -{ - IDLE, - START_BIT, - PROCESSING, - PARITY_BIT, - FIRST_STOP_BIT, - SECOND_STOP_BIT, - PREP_TIME -}; - - -struct ay31015_t -{ - const ay31015_config *config; - - int pins[41]; - - UINT8 control_reg; - UINT8 status_reg; - UINT16 second_stop_bit; // 0, 8, 16 - UINT16 total_pulses; // bits * 16 - UINT8 internal_sample; - - state_t rx_state; - UINT8 rx_data; // byte being received - UINT8 rx_buffer; // received byte waiting to be accepted by computer - UINT8 rx_bit_count; - UINT8 rx_parity; - UINT16 rx_pulses; // total pulses left - double rx_clock; - emu_timer *rx_timer; - - state_t tx_state; - UINT8 tx_data; // byte being sent - UINT8 tx_buffer; // next byte to send - UINT8 tx_parity; - UINT16 tx_pulses; // total pulses left - double tx_clock; - emu_timer *tx_timer; - - devcb_resolved_read8 read_si; /* SI - pin 20 - This will be called whenever the SI pin is sampled. Optional */ - devcb_resolved_write8 write_so; /* SO - pin 25 - This will be called whenever data is put on the SO pin. Optional */ - devcb_resolved_write8 status_changed; /* This will be called whenever one of the status pins may have changed. Optional */ -}; /* control reg */ @@ -136,599 +91,23 @@ struct ay31015_t #define STATUS_EOC 0x20 -/*------------------------------------------------- - get_safe_token - safely gets the data --------------------------------------------------*/ - -INLINE ay31015_t *get_safe_token(device_t *device) -{ - assert(device != NULL); - assert(device->type() == AY31015); - return (ay31015_t *) downcast(device)->token(); -} - - -INLINE UINT8 ay31015_get_si( device_t *device ) -{ - ay31015_t *ay31015 = get_safe_token( device ); - - if ( !ay31015->read_si.isnull() ) - ay31015->pins[AY31015_SI] = ay31015->read_si( 0 ) ? 1 : 0; - - return ay31015->pins[AY31015_SI]; -} - - -INLINE void ay31015_set_so( device_t *device, int data ) -{ - ay31015_t *ay31015 = get_safe_token( device ); - - ay31015->pins[AY31015_SO] = data ? 1 : 0; - - if ( !ay31015->write_so.isnull() ) - ay31015->write_so( 0, ay31015->pins[AY31015_SO] ); -} - - -INLINE int ay31015_update_status_pin( ay31015_t *ay31015, UINT8 reg_bit, ay31015_output_pin_t pin ) -{ - int new_value = ( ay31015->status_reg & reg_bit ) ? 1 : 0; - - if ( new_value == ay31015->pins[pin] ) - return 0; - - ay31015->pins[pin] = new_value; - return 1; -} - - -/*------------------------------------------------- - ay31015_update_status_pins - Update the status pins --------------------------------------------------*/ -static void ay31015_update_status_pins( device_t *device ) -{ - ay31015_t *ay31015 = get_safe_token( device ); - int status_pins_changed = 0; - - /* Should status pins be updated? */ - if ( ! ay31015->pins[AY31015_SWE] ) - { - status_pins_changed += ay31015_update_status_pin( ay31015, STATUS_PE, AY31015_PE ); - status_pins_changed += ay31015_update_status_pin( ay31015, STATUS_FE, AY31015_FE ); - status_pins_changed += ay31015_update_status_pin( ay31015, STATUS_OR, AY31015_OR ); - status_pins_changed += ay31015_update_status_pin( ay31015, STATUS_DAV, AY31015_DAV ); - status_pins_changed += ay31015_update_status_pin( ay31015, STATUS_TBMT, AY31015_TBMT ); - } - status_pins_changed += ay31015_update_status_pin( ay31015, STATUS_EOC, AY31015_EOC ); - - if ( status_pins_changed && !ay31015->status_changed.isnull() ) - { - ay31015->status_changed( 0, status_pins_changed ); - } -} - - -/*************************************************** RECEIVE CONTROLS *************************************************/ - - -/*------------------------------------------------- - ay31015_rx_process - convert serial to parallel --------------------------------------------------*/ -static TIMER_CALLBACK( ay31015_rx_process ) -{ - device_t *device = (device_t *)ptr; - ay31015_t *ay31015 = get_safe_token( device ); - - switch (ay31015->rx_state) - { - case PREP_TIME: // assist sync by ensuring high bit occurs - ay31015->rx_pulses--; - if (ay31015_get_si( device )) - ay31015->rx_state = IDLE; - return; - - case IDLE: - ay31015->rx_pulses--; - if (!ay31015_get_si( device )) - { - ay31015->rx_state = START_BIT; - ay31015->rx_pulses = 16; - } - return; - - case START_BIT: - ay31015->rx_pulses--; - if (ay31015->rx_pulses == 8) // start bit must be low at sample time - { - if ( ay31015_get_si( device ) ) - ay31015->rx_state = IDLE; - } - else - if (!ay31015->rx_pulses) // end of start bit - { - ay31015->rx_state = PROCESSING; - ay31015->rx_pulses = ay31015->total_pulses; - ay31015->rx_bit_count = 0; - ay31015->rx_parity = 0; - ay31015->rx_data = 0; - } - return; - - case PROCESSING: - ay31015->rx_pulses--; - if (!ay31015->rx_pulses) // end of a byte - { - ay31015->rx_pulses = 16; - if (ay31015->control_reg & CONTROL_NP) // see if we need to get a parity bit - ay31015->rx_state = FIRST_STOP_BIT; - else - ay31015->rx_state = PARITY_BIT; - } - else - if (!(ay31015->rx_pulses & 15)) // end of a bit - ay31015->rx_bit_count++; - else - if ((ay31015->rx_pulses & 15) == 8) // sample input stream - { - ay31015->internal_sample = ay31015_get_si( device ); - ay31015->rx_parity ^= ay31015->internal_sample; // calculate cumulative parity - ay31015->rx_data |= ay31015->internal_sample << ay31015->rx_bit_count; - } - return; - - case PARITY_BIT: - ay31015->rx_pulses--; - - if (ay31015->rx_pulses == 8) // sample input stream - { - ay31015->rx_parity ^= ay31015_get_si( device ); // calculate cumulative parity - } - else - if (!ay31015->rx_pulses) // end of a byte - { - ay31015->rx_pulses = 16; - ay31015->rx_state = FIRST_STOP_BIT; - - if ((!(ay31015->control_reg & CONTROL_EPS)) && (ay31015->rx_parity)) - ay31015->rx_parity = 0; // odd parity, ok - else - if ((ay31015->control_reg & CONTROL_EPS) && (!ay31015->rx_parity)) - ay31015->rx_parity = 0; // even parity, ok - else - ay31015->rx_parity = 1; // parity error - } - return; - - case FIRST_STOP_BIT: - ay31015->rx_pulses--; - if (ay31015->rx_pulses == 8) // sample input stream - ay31015->internal_sample = ay31015_get_si( device ); - else - if (ay31015->rx_pulses == 7) // set error flags - { - if (!ay31015->internal_sample) - { - ay31015->status_reg |= STATUS_FE; // framing error - the stop bit not high - ay31015->rx_state = PREP_TIME; // lost sync - start over - // return; - } - else - ay31015->status_reg &= ~STATUS_FE; - - if ((ay31015->rx_parity) && (!(ay31015->control_reg & CONTROL_NP))) - ay31015->status_reg |= STATUS_PE; // parity error - else - ay31015->status_reg &= ~STATUS_PE; - - if (ay31015->status_reg & STATUS_DAV) - ay31015->status_reg |= STATUS_OR; // overrun error - previous byte still in buffer - else - ay31015->status_reg &= ~STATUS_OR; - - ay31015->rx_buffer = ay31015->rx_data; // bring received byte out for computer to read - - ay31015_update_status_pins( device ); - } - else - if (ay31015->rx_pulses == 6) - { - ay31015->status_reg |= STATUS_DAV; // tell computer that new byte is ready - ay31015_update_status_pins( device ); - } - else - if (ay31015->rx_pulses == 4) - { - if (ay31015->second_stop_bit) - { - /* We should wait for the full first stop bit and - the beginning of the second stop bit */ - ay31015->rx_state = SECOND_STOP_BIT; - ay31015->rx_pulses += ay31015->second_stop_bit - 7; - } - else - { - /* We have seen a STOP bit, go back to PREP_TIME */ - ay31015->rx_state = PREP_TIME; - } - } - return; - - case SECOND_STOP_BIT: - ay31015->rx_pulses--; - if (!ay31015->rx_pulses) - ay31015->rx_state = PREP_TIME; - return; - - } -} - - -/*************************************************** TRANSMIT CONTROLS *************************************************/ - - -/*------------------------------------------------- - ay31015_tx_process - convert parallel to serial --------------------------------------------------*/ -static TIMER_CALLBACK( ay31015_tx_process ) -{ - device_t *device = (device_t *)ptr; - ay31015_t *ay31015 = get_safe_token( device ); - - UINT8 t1; - switch (ay31015->tx_state) - { - case IDLE: - if (!(ay31015->status_reg & STATUS_TBMT)) - { - ay31015->tx_state = PREP_TIME; // When idle, see if a byte has been sent to us - ay31015->tx_pulses = 1; - } - return; - - case PREP_TIME: // This phase lets the transmitter regain sync after an idle period - ay31015->tx_pulses--; - if (!ay31015->tx_pulses) - { - ay31015->tx_state = START_BIT; - ay31015->tx_pulses = 16; - } - return; - - case START_BIT: - if (ay31015->tx_pulses == 16) // beginning of start bit - { - ay31015->tx_data = ay31015->tx_buffer; // load the shift register - ay31015->status_reg |= STATUS_TBMT; // tell computer that another byte can be sent to uart - ay31015_set_so( device, 0 ); /* start bit begins now (we are "spacing") */ - ay31015->status_reg &= ~STATUS_EOC; // we are no longer idle - ay31015->tx_parity = 0; - ay31015_update_status_pins( device ); - } - - ay31015->tx_pulses--; - if (!ay31015->tx_pulses) // end of start bit - { - ay31015->tx_state = PROCESSING; - ay31015->tx_pulses = ay31015->total_pulses; - } - return; - - case PROCESSING: - if (!(ay31015->tx_pulses & 15)) // beginning of a data bit - { - if (ay31015->tx_data & 1) - { - ay31015_set_so( device, 1 ); - ay31015->tx_parity++; // calculate cumulative parity - } - else - ay31015_set_so( device, 0 ); - - ay31015->tx_data >>= 1; // adjust the shift register - } - - ay31015->tx_pulses--; - if (!ay31015->tx_pulses) // all data bits sent - { - ay31015->tx_pulses = 16; - if (ay31015->control_reg & CONTROL_NP) // see if we need to make a parity bit - ay31015->tx_state = FIRST_STOP_BIT; - else - ay31015->tx_state = PARITY_BIT; - } - - return; - - case PARITY_BIT: - if (ay31015->tx_pulses == 16) - { - t1 = (ay31015->control_reg & CONTROL_EPS) ? 0 : 1; - t1 ^= (ay31015->tx_parity & 1); - if (t1) - ay31015_set_so( device, 1 ); /* extra bit to set the correct parity */ - else - ay31015_set_so( device, 0 ); /* it was already correct */ - } - - ay31015->tx_pulses--; - if (!ay31015->tx_pulses) - { - ay31015->tx_state = FIRST_STOP_BIT; - ay31015->tx_pulses = 16; - } - return; - - case FIRST_STOP_BIT: - if (ay31015->tx_pulses == 16) - ay31015_set_so( device, 1 ); /* create a stop bit (marking and soon idle) */ - ay31015->tx_pulses--; - if (!ay31015->tx_pulses) - { - ay31015->status_reg |= STATUS_EOC; // character is completely sent - if (ay31015->second_stop_bit) - { - ay31015->tx_state = SECOND_STOP_BIT; - ay31015->tx_pulses = ay31015->second_stop_bit; - } - else - if (ay31015->status_reg & STATUS_TBMT) - ay31015->tx_state = IDLE; // if nothing to send, go idle - else - { - ay31015->tx_pulses = 16; - ay31015->tx_state = START_BIT; // otherwise immediately start next byte - } - ay31015_update_status_pins( device ); - } - return; - - case SECOND_STOP_BIT: - ay31015->tx_pulses--; - if (!ay31015->tx_pulses) - { - if (ay31015->status_reg & STATUS_TBMT) - ay31015->tx_state = IDLE; // if nothing to send, go idle - else - { - ay31015->tx_pulses = 16; - ay31015->tx_state = START_BIT; // otherwise immediately start next byte - } - } - return; - - } -} - - -/*------------------------------------------------- - ay31015_reset - reset internal state --------------------------------------------------*/ -static void ay31015_reset( device_t *device ) -{ - ay31015_t *ay31015 = get_safe_token( device ); - - /* total pulses = 16 * data-bits */ - UINT8 t1; - - if ( ay31015->control_reg & CONTROL_NB2 ) - t1 = ( ay31015->control_reg & CONTROL_NB1 ) ? 8 : 7; - else - t1 = ( ay31015->control_reg & CONTROL_NB1 ) ? 6 : 5; - - ay31015->total_pulses = t1 << 4; /* total clock pulses to load a byte */ - ay31015->second_stop_bit = ((ay31015->control_reg & CONTROL_TSB) ? 16 : 0); /* 2nd stop bit */ - if ((t1 == 5) && (ay31015->second_stop_bit == 16)) - ay31015->second_stop_bit = 8; /* 5 data bits and 2 stop bits = 1.5 stop bits */ - ay31015->status_reg = STATUS_EOC | STATUS_TBMT; - ay31015->tx_data = 0; - ay31015->rx_state = PREP_TIME; - ay31015->tx_state = IDLE; - ay31015->pins[AY31015_SI] = 1; - ay31015_set_so( device, 1 ); - - if ( ay31015->config->type == AY_3_1015 ) - ay31015->rx_data = 0; - -} - - -/*------------------------------------------------- - ay31015_transfer_control_pins - transfers contents of controls pins to the control register --------------------------------------------------*/ -static void ay31015_transfer_control_pins( device_t *device ) -{ - ay31015_t *ay31015 = get_safe_token( device ); - UINT8 control = 0; - - control |= ay31015->pins[AY31015_NP ] ? CONTROL_NP : 0; - control |= ay31015->pins[AY31015_TSB] ? CONTROL_TSB : 0; - control |= ay31015->pins[AY31015_NB1] ? CONTROL_NB1 : 0; - control |= ay31015->pins[AY31015_NB2] ? CONTROL_NB2 : 0; - control |= ay31015->pins[AY31015_EPS] ? CONTROL_EPS : 0; - - if ( ay31015->control_reg != control ) - { - ay31015->control_reg = control; - ay31015_reset( device ); - } -} - - -/*------------------------------------------------- - ay31015_set_input_pin - set an input pin --------------------------------------------------*/ -void ay31015_set_input_pin( device_t *device, ay31015_input_pin_t pin, int data ) -{ - ay31015_t *ay31015 = get_safe_token(device); - - data = data ? 1 : 0; - - switch ( pin ) - { - case AY31015_SWE: - ay31015->pins[pin] = data; - ay31015_update_status_pins( device ); - break; - case AY31015_RDAV: - ay31015->pins[pin] = data; - if ( ! data ) - { - ay31015->status_reg &= ~STATUS_DAV; - ay31015->pins[AY31015_DAV] = 0; - } - break; - case AY31015_SI: - ay31015->pins[pin] = data; - break; - case AY31015_XR: - ay31015->pins[pin] = data; - if ( data ) - ay31015_reset( device ); - break; - case AY31015_CS: - case AY31015_NP: - case AY31015_TSB: - case AY31015_NB1: - case AY31015_NB2: - case AY31015_EPS: - ay31015->pins[pin] = data; - if ( ay31015->pins[AY31015_CS] ) - ay31015_transfer_control_pins( device ); - break; - } -} - - -/*------------------------------------------------- - ay31015_get_output_pin - get the status of an output pin --------------------------------------------------*/ -int ay31015_get_output_pin( device_t *device, ay31015_output_pin_t pin ) -{ - ay31015_t *ay31015 = get_safe_token(device); - - return ay31015->pins[pin]; -} - - -INLINE void ay31015_update_rx_timer( device_t *device ) -{ - ay31015_t *ay31015 = get_safe_token( device ); - - if ( ay31015->rx_clock > 0.0 ) - { - ay31015->rx_timer->adjust( attotime::from_hz( ay31015->rx_clock ), 0, attotime::from_hz( ay31015->rx_clock ) ); - } - else - { - ay31015->rx_timer->enable( 0 ); - } -} - - -INLINE void ay31015_update_tx_timer( device_t *device ) -{ - ay31015_t *ay31015 = get_safe_token( device ); - - if ( ay31015->tx_clock > 0.0 ) - { - ay31015->tx_timer->adjust( attotime::from_hz( ay31015->tx_clock ), 0, attotime::from_hz( ay31015->tx_clock ) ); - } - else - { - ay31015->tx_timer->enable( 0 ); - } -} - - -/*------------------------------------------------- - ay31015_set_receiver_clock - set receive clock --------------------------------------------------*/ -void ay31015_set_receiver_clock( device_t *device, double new_clock ) -{ - ay31015_t *ay31015 = get_safe_token(device); - - ay31015->rx_clock = new_clock; - ay31015_update_rx_timer( device ); -} - - -/*------------------------------------------------- - ay31015_set_transmitter_clock - set transmit clock --------------------------------------------------*/ -void ay31015_set_transmitter_clock( device_t *device, double new_clock ) -{ - ay31015_t *ay31015 = get_safe_token(device); - - ay31015->tx_clock = new_clock; - ay31015_update_tx_timer( device ); -} - - -/*------------------------------------------------- - ay31015_get_received_data - return a byte to the computer --------------------------------------------------*/ -UINT8 ay31015_get_received_data( device_t *device ) -{ - ay31015_t *ay31015 = get_safe_token(device); - - return ay31015->rx_buffer; -} - - -/*------------------------------------------------- - ay31015_set_transmit_data - accept a byte to transmit, if able --------------------------------------------------*/ -void ay31015_set_transmit_data( device_t *device, UINT8 data ) -{ - ay31015_t *ay31015 = get_safe_token(device); - - if (ay31015->status_reg & STATUS_TBMT) - { - ay31015->tx_buffer = data; - ay31015->status_reg &= ~STATUS_TBMT; - ay31015_update_status_pins( device ); - } -} - - -static DEVICE_START(ay31015) -{ - ay31015_t *ay31015 = get_safe_token(device); - - ay31015->config = (const ay31015_config*)device->static_config(); - - ay31015->read_si.resolve(ay31015->config->read_si_cb, *device); - ay31015->write_so.resolve(ay31015->config->write_so_cb, *device); - ay31015->status_changed.resolve(ay31015->config->status_changed_cb, *device); - - ay31015->tx_clock = ay31015->config->transmitter_clock; - ay31015->rx_clock = ay31015->config->receiver_clock; - - ay31015->rx_timer = device->machine().scheduler().timer_alloc(FUNC(ay31015_rx_process), (void *)device ); - ay31015->tx_timer = device->machine().scheduler().timer_alloc(FUNC(ay31015_tx_process), (void *)device ); - - ay31015_update_rx_timer( device ); - ay31015_update_tx_timer( device ); -} - - -static DEVICE_RESET( ay31015 ) -{ - ay31015_t *ay31015 = get_safe_token(device); - - ay31015->control_reg = 0; - ay31015->rx_data = 0; - - ay31015_reset( device ); -} - const device_type AY31015 = &device_creator; +const device_type AY51013 = &device_creator; + +ay31015_device::ay31015_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, type, name, tag, owner, clock) +{ +} ay31015_device::ay31015_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, AY31015, "AY-3-1015", tag, owner, clock) + : device_t(mconfig, AY31015, "AY-3-1015", tag, owner, clock) +{ +} + +ay51013_device::ay51013_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : ay31015_device(mconfig, AY31015, "AY-5-1013", tag, owner, clock) { - m_token = global_alloc_clear(ay31015_t); } //------------------------------------------------- @@ -739,6 +118,20 @@ ay31015_device::ay31015_device(const machine_config &mconfig, const char *tag, d void ay31015_device::device_config_complete() { + // inherit a copy of the static data + const ay31015_config *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + memset(&read_si_cb, 0, sizeof(read_si_cb)); + memset(&write_so_cb, 0, sizeof(write_so_cb)); + memset(&status_changed_cb, 0, sizeof(status_changed_cb)); + transmitter_clock = 0; + receiver_clock = 0; + } } //------------------------------------------------- @@ -747,7 +140,18 @@ void ay31015_device::device_config_complete() void ay31015_device::device_start() { - DEVICE_START_NAME( ay31015 )(this); + m_read_si.resolve(read_si_cb, *this); + m_write_so.resolve(write_so_cb, *this); + m_status_changed.resolve(status_changed_cb, *this); + + m_tx_clock = transmitter_clock; + m_rx_clock = receiver_clock; + + m_rx_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ay31015_device::rx_process),this)); + m_tx_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ay31015_device::tx_process),this)); + + update_rx_timer(); + update_tx_timer(); } //------------------------------------------------- @@ -756,5 +160,552 @@ void ay31015_device::device_start() void ay31015_device::device_reset() { - DEVICE_RESET_NAME( ay31015 )(this); + m_control_reg = 0; + m_rx_data = 0; + + internal_reset(); } + + +inline UINT8 ay31015_device::get_si() +{ + if (!m_read_si.isnull()) + m_pins[AY31015_SI] = m_read_si(0) ? 1 : 0; + + return m_pins[AY31015_SI]; +} + + +inline void ay31015_device::set_so( int data ) +{ + m_pins[AY31015_SO] = data ? 1 : 0; + + if (!m_write_so.isnull()) + m_write_so(0, m_pins[AY31015_SO]); +} + + +inline int ay31015_device::update_status_pin( UINT8 reg_bit, ay31015_output_pin_t pin ) +{ + int new_value = (m_status_reg & reg_bit) ? 1 : 0; + + if (new_value == m_pins[pin]) + return 0; + + m_pins[pin] = new_value; + return 1; +} + + +/*------------------------------------------------- + ay31015_update_status_pins - Update the status pins +-------------------------------------------------*/ + +void ay31015_device::update_status_pins() +{ + int status_pins_changed = 0; + + /* Should status pins be updated? */ + if (!m_pins[AY31015_SWE]) + { + status_pins_changed += update_status_pin(STATUS_PE, AY31015_PE); + status_pins_changed += update_status_pin(STATUS_FE, AY31015_FE); + status_pins_changed += update_status_pin(STATUS_OR, AY31015_OR); + status_pins_changed += update_status_pin(STATUS_DAV, AY31015_DAV); + status_pins_changed += update_status_pin(STATUS_TBMT, AY31015_TBMT); + } + status_pins_changed += update_status_pin(STATUS_EOC, AY31015_EOC); + + if (status_pins_changed && !m_status_changed.isnull()) + { + m_status_changed(0, status_pins_changed); + } +} + + +/*************************************************** RECEIVE CONTROLS *************************************************/ + + +/*------------------------------------------------- + ay31015_rx_process - convert serial to parallel +-------------------------------------------------*/ + +TIMER_CALLBACK_MEMBER( ay31015_device::rx_process ) +{ + switch (m_rx_state) + { + case PREP_TIME: // assist sync by ensuring high bit occurs + m_rx_pulses--; + if (get_si()) + m_rx_state = IDLE; + return; + + case IDLE: + m_rx_pulses--; + if (!get_si()) + { + m_rx_state = START_BIT; + m_rx_pulses = 16; + } + return; + + case START_BIT: + m_rx_pulses--; + if (m_rx_pulses == 8) // start bit must be low at sample time + { + if (get_si()) + m_rx_state = IDLE; + } + else + if (!m_rx_pulses) // end of start bit + { + m_rx_state = PROCESSING; + m_rx_pulses = m_total_pulses; + m_rx_bit_count = 0; + m_rx_parity = 0; + m_rx_data = 0; + } + return; + + case PROCESSING: + m_rx_pulses--; + if (!m_rx_pulses) // end of a byte + { + m_rx_pulses = 16; + if (m_control_reg & CONTROL_NP) // see if we need to get a parity bit + m_rx_state = FIRST_STOP_BIT; + else + m_rx_state = PARITY_BIT; + } + else + if (!(m_rx_pulses & 15)) // end of a bit + m_rx_bit_count++; + else + if ((m_rx_pulses & 15) == 8) // sample input stream + { + m_internal_sample = get_si(); + m_rx_parity ^= m_internal_sample; // calculate cumulative parity + m_rx_data |= m_internal_sample << m_rx_bit_count; + } + return; + + case PARITY_BIT: + m_rx_pulses--; + + if (m_rx_pulses == 8) // sample input stream + { + m_rx_parity ^= get_si(); // calculate cumulative parity + } + else + if (!m_rx_pulses) // end of a byte + { + m_rx_pulses = 16; + m_rx_state = FIRST_STOP_BIT; + + if ((!(m_control_reg & CONTROL_EPS)) && (m_rx_parity)) + m_rx_parity = 0; // odd parity, ok + else + if ((m_control_reg & CONTROL_EPS) && (!m_rx_parity)) + m_rx_parity = 0; // even parity, ok + else + m_rx_parity = 1; // parity error + } + return; + + case FIRST_STOP_BIT: + m_rx_pulses--; + if (m_rx_pulses == 8) // sample input stream + m_internal_sample = get_si(); + else + if (m_rx_pulses == 7) // set error flags + { + if (!m_internal_sample) + { + m_status_reg |= STATUS_FE; // framing error - the stop bit not high + m_rx_state = PREP_TIME; // lost sync - start over + // return; + } + else + m_status_reg &= ~STATUS_FE; + + if ((m_rx_parity) && (!(m_control_reg & CONTROL_NP))) + m_status_reg |= STATUS_PE; // parity error + else + m_status_reg &= ~STATUS_PE; + + if (m_status_reg & STATUS_DAV) + m_status_reg |= STATUS_OR; // overrun error - previous byte still in buffer + else + m_status_reg &= ~STATUS_OR; + + m_rx_buffer = m_rx_data; // bring received byte out for computer to read + + update_status_pins(); + } + else + if (m_rx_pulses == 6) + { + m_status_reg |= STATUS_DAV; // tell computer that new byte is ready + update_status_pins(); + } + else + if (m_rx_pulses == 4) + { + if (m_second_stop_bit) + { + /* We should wait for the full first stop bit and + the beginning of the second stop bit */ + m_rx_state = SECOND_STOP_BIT; + m_rx_pulses += m_second_stop_bit - 7; + } + else + { + /* We have seen a STOP bit, go back to PREP_TIME */ + m_rx_state = PREP_TIME; + } + } + return; + + case SECOND_STOP_BIT: + m_rx_pulses--; + if (!m_rx_pulses) + m_rx_state = PREP_TIME; + return; + + } +} + + +/*************************************************** TRANSMIT CONTROLS *************************************************/ + + +/*------------------------------------------------- + ay31015_tx_process - convert parallel to serial +-------------------------------------------------*/ + +TIMER_CALLBACK_MEMBER( ay31015_device::tx_process ) +{ + UINT8 t1; + switch (m_tx_state) + { + case IDLE: + if (!(m_status_reg & STATUS_TBMT)) + { + m_tx_state = PREP_TIME; // When idle, see if a byte has been sent to us + m_tx_pulses = 1; + } + return; + + case PREP_TIME: // This phase lets the transmitter regain sync after an idle period + m_tx_pulses--; + if (!m_tx_pulses) + { + m_tx_state = START_BIT; + m_tx_pulses = 16; + } + return; + + case START_BIT: + if (m_tx_pulses == 16) // beginning of start bit + { + m_tx_data = m_tx_buffer; // load the shift register + m_status_reg |= STATUS_TBMT; // tell computer that another byte can be sent to uart + set_so(0); /* start bit begins now (we are "spacing") */ + m_status_reg &= ~STATUS_EOC; // we are no longer idle + m_tx_parity = 0; + update_status_pins(); + } + + m_tx_pulses--; + if (!m_tx_pulses) // end of start bit + { + m_tx_state = PROCESSING; + m_tx_pulses = m_total_pulses; + } + return; + + case PROCESSING: + if (!(m_tx_pulses & 15)) // beginning of a data bit + { + if (m_tx_data & 1) + { + set_so(1); + m_tx_parity++; // calculate cumulative parity + } + else + set_so(0); + + m_tx_data >>= 1; // adjust the shift register + } + + m_tx_pulses--; + if (!m_tx_pulses) // all data bits sent + { + m_tx_pulses = 16; + if (m_control_reg & CONTROL_NP) // see if we need to make a parity bit + m_tx_state = FIRST_STOP_BIT; + else + m_tx_state = PARITY_BIT; + } + + return; + + case PARITY_BIT: + if (m_tx_pulses == 16) + { + t1 = (m_control_reg & CONTROL_EPS) ? 0 : 1; + t1 ^= (m_tx_parity & 1); + if (t1) + set_so(1); /* extra bit to set the correct parity */ + else + set_so(0); /* it was already correct */ + } + + m_tx_pulses--; + if (!m_tx_pulses) + { + m_tx_state = FIRST_STOP_BIT; + m_tx_pulses = 16; + } + return; + + case FIRST_STOP_BIT: + if (m_tx_pulses == 16) + set_so(1); /* create a stop bit (marking and soon idle) */ + m_tx_pulses--; + if (!m_tx_pulses) + { + m_status_reg |= STATUS_EOC; // character is completely sent + if (m_second_stop_bit) + { + m_tx_state = SECOND_STOP_BIT; + m_tx_pulses = m_second_stop_bit; + } + else + if (m_status_reg & STATUS_TBMT) + m_tx_state = IDLE; // if nothing to send, go idle + else + { + m_tx_pulses = 16; + m_tx_state = START_BIT; // otherwise immediately start next byte + } + update_status_pins(); + } + return; + + case SECOND_STOP_BIT: + m_tx_pulses--; + if (!m_tx_pulses) + { + if (m_status_reg & STATUS_TBMT) + m_tx_state = IDLE; // if nothing to send, go idle + else + { + m_tx_pulses = 16; + m_tx_state = START_BIT; // otherwise immediately start next byte + } + } + return; + + } +} + + +/*------------------------------------------------- + ay31015_reset - reset internal state +-------------------------------------------------*/ + +void ay31015_device::internal_reset() +{ + /* total pulses = 16 * data-bits */ + UINT8 t1; + + if (m_control_reg & CONTROL_NB2) + t1 = (m_control_reg & CONTROL_NB1) ? 8 : 7; + else + t1 = (m_control_reg & CONTROL_NB1) ? 6 : 5; + + m_total_pulses = t1 << 4; /* total clock pulses to load a byte */ + m_second_stop_bit = ((m_control_reg & CONTROL_TSB) ? 16 : 0); /* 2nd stop bit */ + if ((t1 == 5) && (m_second_stop_bit == 16)) + m_second_stop_bit = 8; /* 5 data bits and 2 stop bits = 1.5 stop bits */ + m_status_reg = STATUS_EOC | STATUS_TBMT; + m_tx_data = 0; + m_rx_state = PREP_TIME; + m_tx_state = IDLE; + m_pins[AY31015_SI] = 1; + set_so(1); + + m_rx_data = 0; +} + + +void ay51013_device::internal_reset() +{ + /* total pulses = 16 * data-bits */ + UINT8 t1; + + if (m_control_reg & CONTROL_NB2) + t1 = (m_control_reg & CONTROL_NB1) ? 8 : 7; + else + t1 = (m_control_reg & CONTROL_NB1) ? 6 : 5; + + m_total_pulses = t1 << 4; /* total clock pulses to load a byte */ + m_second_stop_bit = ((m_control_reg & CONTROL_TSB) ? 16 : 0); /* 2nd stop bit */ + if ((t1 == 5) && (m_second_stop_bit == 16)) + m_second_stop_bit = 8; /* 5 data bits and 2 stop bits = 1.5 stop bits */ + m_status_reg = STATUS_EOC | STATUS_TBMT; + m_tx_data = 0; + m_rx_state = PREP_TIME; + m_tx_state = IDLE; + m_pins[AY31015_SI] = 1; + set_so(1); + // no m_rx_data = 0 in this case +} + +/*------------------------------------------------- + ay31015_transfer_control_pins - transfers contents of controls pins to the control register +-------------------------------------------------*/ + +void ay31015_device::transfer_control_pins() +{ + UINT8 control = 0; + + control |= m_pins[AY31015_NP ] ? CONTROL_NP : 0; + control |= m_pins[AY31015_TSB] ? CONTROL_TSB : 0; + control |= m_pins[AY31015_NB1] ? CONTROL_NB1 : 0; + control |= m_pins[AY31015_NB2] ? CONTROL_NB2 : 0; + control |= m_pins[AY31015_EPS] ? CONTROL_EPS : 0; + + if (m_control_reg != control) + { + m_control_reg = control; + internal_reset(); + } +} + + +/*------------------------------------------------- + ay31015_set_input_pin - set an input pin +-------------------------------------------------*/ +void ay31015_device::set_input_pin( ay31015_input_pin_t pin, int data ) +{ + data = data ? 1 : 0; + + switch (pin) + { + case AY31015_SWE: + m_pins[pin] = data; + update_status_pins(); + break; + case AY31015_RDAV: + m_pins[pin] = data; + if (!data) + { + m_status_reg &= ~STATUS_DAV; + m_pins[AY31015_DAV] = 0; + } + break; + case AY31015_SI: + m_pins[pin] = data; + break; + case AY31015_XR: + m_pins[pin] = data; + if (data) + internal_reset(); + break; + case AY31015_CS: + case AY31015_NP: + case AY31015_TSB: + case AY31015_NB1: + case AY31015_NB2: + case AY31015_EPS: + m_pins[pin] = data; + if (m_pins[AY31015_CS]) + transfer_control_pins(); + break; + } +} + + +/*------------------------------------------------- + ay31015_get_output_pin - get the status of an output pin +-------------------------------------------------*/ + +int ay31015_device::get_output_pin( ay31015_output_pin_t pin ) +{ + return m_pins[pin]; +} + + +inline void ay31015_device::update_rx_timer() +{ + if (m_rx_clock > 0.0) + { + m_rx_timer->adjust(attotime::from_hz(m_rx_clock), 0, attotime::from_hz(m_rx_clock)); + } + else + { + m_rx_timer->enable(0); + } +} + + +inline void ay31015_device::update_tx_timer() +{ + if (m_tx_clock > 0.0) + { + m_tx_timer->adjust(attotime::from_hz(m_tx_clock), 0, attotime::from_hz(m_tx_clock)); + } + else + { + m_tx_timer->enable(0); + } +} + + +/*------------------------------------------------- + ay31015_set_receiver_clock - set receive clock +-------------------------------------------------*/ + +void ay31015_device::set_receiver_clock( double new_clock ) +{ + m_rx_clock = new_clock; + update_rx_timer(); +} + + +/*------------------------------------------------- + ay31015_set_transmitter_clock - set transmit clock +-------------------------------------------------*/ + +void ay31015_device::set_transmitter_clock( double new_clock ) +{ + m_tx_clock = new_clock; + update_tx_timer(); +} + + +/*------------------------------------------------- + ay31015_get_received_data - return a byte to the computer +-------------------------------------------------*/ + +UINT8 ay31015_device::get_received_data() +{ + return m_rx_buffer; +} + + +/*------------------------------------------------- + ay31015_set_transmit_data - accept a byte to transmit, if able +-------------------------------------------------*/ +void ay31015_device::set_transmit_data( UINT8 data ) +{ + if (m_status_reg & STATUS_TBMT) + { + m_tx_buffer = data; + m_status_reg &= ~STATUS_TBMT; + update_status_pins(); + } +} + diff --git a/src/emu/machine/ay31015.h b/src/emu/machine/ay31015.h index 44d5e2b57a0..90bef6e024a 100644 --- a/src/emu/machine/ay31015.h +++ b/src/emu/machine/ay31015.h @@ -12,115 +12,165 @@ ***************************************************************************/ -enum ay31015_type_t -{ - /* For AY-3-1014A, AY-3-1015(D) and HD6402 variants */ - AY_3_1015, - - /* For AY-3-1014, AY-5-1013 and AY-6-1013 variants */ - AY_5_1013 -}; - - enum ay31015_input_pin_t { - AY31015_SWE=16, /* -SWE - Pin 16 - Status word enable */ - AY31015_RDAV=18, /* -RDAV - Pin 18 - Reset data available */ - AY31015_SI=20, /* SI - Pin 20 - Serial input */ - AY31015_XR=21, /* XR - Pin 21 - External reset */ - AY31015_CS=34, /* CS - Pin 34 - Control strobe */ - AY31015_NP=35, /* NP - Pin 35 - No parity */ - AY31015_TSB=36, /* TSB - Pin 36 - Number of stop bits */ - AY31015_NB1=37, /* NB1 - Pin 37 - Number of bits #1 */ - AY31015_NB2=38, /* NB2 - Pin 38 - Number of bits #2 */ - AY31015_EPS=39 /* EPS - Pin 39 - Odd/Even parity select */ + AY31015_SWE = 16, /* -SWE - Pin 16 - Status word enable */ + AY31015_RDAV = 18, /* -RDAV - Pin 18 - Reset data available */ + AY31015_SI = 20, /* SI - Pin 20 - Serial input */ + AY31015_XR = 21, /* XR - Pin 21 - External reset */ + AY31015_CS = 34, /* CS - Pin 34 - Control strobe */ + AY31015_NP = 35, /* NP - Pin 35 - No parity */ + AY31015_TSB = 36, /* TSB - Pin 36 - Number of stop bits */ + AY31015_NB1 = 37, /* NB1 - Pin 37 - Number of bits #1 */ + AY31015_NB2 = 38, /* NB2 - Pin 38 - Number of bits #2 */ + AY31015_EPS = 39 /* EPS - Pin 39 - Odd/Even parity select */ }; enum ay31015_output_pin_t { - AY31015_PE=13, /* PE - Pin 13 - Parity error */ - AY31015_FE=14, /* FE - Pin 14 - Framing error */ - AY31015_OR=15, /* OR - Pin 15 - Over-run */ - AY31015_DAV=19, /* DAV - Pin 19 - Data available */ - AY31015_TBMT=22, /* TBMT - Pin 22 - Transmit buffer empty */ - AY31015_EOC=24, /* EOC - Pin 24 - End of character */ - AY31015_SO=25 /* SO - Pin 25 - Serial output */ + AY31015_PE = 13, /* PE - Pin 13 - Parity error */ + AY31015_FE = 14, /* FE - Pin 14 - Framing error */ + AY31015_OR = 15, /* OR - Pin 15 - Over-run */ + AY31015_DAV = 19, /* DAV - Pin 19 - Data available */ + AY31015_TBMT = 22, /* TBMT - Pin 22 - Transmit buffer empty */ + AY31015_EOC = 24, /* EOC - Pin 24 - End of character */ + AY31015_SO = 25 /* SO - Pin 25 - Serial output */ }; struct ay31015_config { - ay31015_type_t type; /* Type of chip */ - double transmitter_clock; /* TCP - pin 40 */ - double receiver_clock; /* RCP - pin 17 */ - devcb_read8 read_si_cb; /* SI - pin 20 - This will be called whenever the SI pin is sampled. Optional */ + double transmitter_clock; /* TCP - pin 40 */ + double receiver_clock; /* RCP - pin 17 */ + devcb_read8 read_si_cb; /* SI - pin 20 - This will be called whenever the SI pin is sampled. Optional */ devcb_write8 write_so_cb; /* SO - pin 25 - This will be called whenever data is put on the SO pin. Optional */ devcb_write8 status_changed_cb; /* This will be called whenever one of the status pins may have changed. Optional */ }; /*************************************************************************** - DEVICE CONFIGURATION MACROS + DEVICE INTERFACE ***************************************************************************/ +enum state_t +{ + IDLE, + START_BIT, + PROCESSING, + PARITY_BIT, + FIRST_STOP_BIT, + SECOND_STOP_BIT, + PREP_TIME +}; + + +class ay31015_device : public device_t, + public ay31015_config +{ +public: + ay31015_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + ay31015_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock); + ~ay31015_device() {} + + + /* Set an input pin */ + void set_input_pin( ay31015_input_pin_t pin, int data ); + + + /* Get an output pin */ + int get_output_pin( ay31015_output_pin_t pin ); + + + /* Set a new transmitter clock (new_clock is in Hz) */ + void set_transmitter_clock( double new_clock ); + + + /* Set a new receiver clock (new_clock is in Hz) */ + void set_receiver_clock( double new_clock ); + + + /* Reead the received data */ + /* The received data is available on RD8-RD1 (pins 5-12) */ + UINT8 get_received_data(); + + + /* Set the transmitter buffer */ + /* The data to transmit is set on DB1-DB8 (pins 26-33) */ + void set_transmit_data( UINT8 data ); + +protected: + // device-level overrides + virtual void device_config_complete(); + virtual void device_start(); + virtual void device_reset(); + + virtual void internal_reset(); + + // internal state + inline UINT8 get_si(); + inline void set_so(int data); + inline int update_status_pin(UINT8 reg_bit, ay31015_output_pin_t pin); + void update_status_pins(); + void transfer_control_pins(); + inline void update_rx_timer(); + inline void update_tx_timer(); + TIMER_CALLBACK_MEMBER(rx_process); + TIMER_CALLBACK_MEMBER(tx_process); + + int m_pins[41]; + + UINT8 m_control_reg; + UINT8 m_status_reg; + UINT16 m_second_stop_bit; // 0, 8, 16 + UINT16 m_total_pulses; // bits * 16 + UINT8 m_internal_sample; + + state_t m_rx_state; + UINT8 m_rx_data; // byte being received + UINT8 m_rx_buffer; // received byte waiting to be accepted by computer + UINT8 m_rx_bit_count; + UINT8 m_rx_parity; + UINT16 m_rx_pulses; // total pulses left + double m_rx_clock; + emu_timer *m_rx_timer; + + state_t m_tx_state; + UINT8 m_tx_data; // byte being sent + UINT8 m_tx_buffer; // next byte to send + UINT8 m_tx_parity; + UINT16 m_tx_pulses; // total pulses left + double m_tx_clock; + emu_timer *m_tx_timer; + + devcb_resolved_read8 m_read_si; /* SI - pin 20 - This will be called whenever the SI pin is sampled. Optional */ + devcb_resolved_write8 m_write_so; /* SO - pin 25 - This will be called whenever data is put on the SO pin. Optional */ + devcb_resolved_write8 m_status_changed; /* This will be called whenever one of the status pins may have changed. Optional */ +}; + +class ay51013_device : public ay31015_device +{ +public: + ay51013_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + +protected: + virtual void internal_reset(); + +}; + +extern const device_type AY31015; // For AY-3-1014A, AY-3-1015(D) and HD6402 variants +extern const device_type AY51013; // For AY-3-1014, AY-5-1013 and AY-6-1013 variants + + + +/*************************************************************************** + DEVICE CONFIGURATION MACROS + ***************************************************************************/ + #define MCFG_AY31015_ADD(_tag, _config) \ MCFG_DEVICE_ADD(_tag, AY31015, 0) \ MCFG_DEVICE_CONFIG(_config) -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -/* Set an input pin */ -void ay31015_set_input_pin( device_t *device, ay31015_input_pin_t pin, int data ); - - -/* Get an output pin */ -int ay31015_get_output_pin( device_t *device, ay31015_output_pin_t pin ); - - -/* Set a new transmitter clock (new_clock is in Hz) */ -void ay31015_set_transmitter_clock( device_t *device, double new_clock ); - - -/* Set a new receiver clock (new_clock is in Hz) */ -void ay31015_set_receiver_clock( device_t *device, double new_clock ); - - -/* Reead the received data */ -/* The received data is available on RD8-RD1 (pins 5-12) */ -UINT8 ay31015_get_received_data( device_t *device ); - - -/* Set the transmitter buffer */ -/* The data to transmit is set on DB1-DB8 (pins 26-33) */ -void ay31015_set_transmit_data( device_t *device, UINT8 data ); - - -/*************************************************************************** - DEVICE INTERFACE -***************************************************************************/ - -class ay31015_device : public device_t -{ -public: - ay31015_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~ay31015_device() { global_free(m_token); } - - // access to legacy token - void *token() const { assert(m_token != NULL); return m_token; } -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - virtual void device_reset(); -private: - // internal state - void *m_token; -}; - -extern const device_type AY31015; #endif diff --git a/src/mess/drivers/nascom1.c b/src/mess/drivers/nascom1.c index ea2032bf129..d6ad7248abe 100644 --- a/src/mess/drivers/nascom1.c +++ b/src/mess/drivers/nascom1.c @@ -55,7 +55,6 @@ Nascom Memory map /* Components */ #include "cpu/z80/z80.h" #include "machine/wd17xx.h" -#include "machine/ay31015.h" #include "machine/z80pio.h" /* Devices */ @@ -254,7 +253,6 @@ INPUT_PORTS_END static const ay31015_config nascom1_ay31015_config = { - AY_3_1015, ( XTAL_16MHz / 16 ) / 256, ( XTAL_16MHz / 16 ) / 256, DEVCB_DRIVER_MEMBER(nascom1_state, nascom1_hd6402_si), diff --git a/src/mess/drivers/ptcsol.c b/src/mess/drivers/ptcsol.c index e2b69f00d25..5e45b8bf413 100644 --- a/src/mess/drivers/ptcsol.c +++ b/src/mess/drivers/ptcsol.c @@ -247,7 +247,7 @@ TIMER_CALLBACK_MEMBER(sol20_state::sol20_cassette_tc) m_cass_data.input.level = cass_ws; m_cass_data.input.bit = ((m_cass_data.input.length < 0x6) || (m_cass_data.input.length > 0x20)) ? 1 : 0; m_cass_data.input.length = 0; - ay31015_set_input_pin( m_uart, AY31015_SI, m_cass_data.input.bit ); + m_uart->set_input_pin(AY31015_SI, m_cass_data.input.bit); } /* saving a tape - convert the serial stream from the uart, into 1200 and 2400 Hz frequencies. @@ -256,7 +256,7 @@ TIMER_CALLBACK_MEMBER(sol20_state::sol20_cassette_tc) m_cass_data.output.length++; if (!(m_cass_data.output.length & 0x1f)) { - cass_ws = ay31015_get_output_pin( m_uart, AY31015_SO ); + cass_ws = m_uart->get_output_pin(AY31015_SO); if (cass_ws != m_cass_data.output.bit) { m_cass_data.output.bit = cass_ws; @@ -288,7 +288,7 @@ TIMER_CALLBACK_MEMBER(sol20_state::sol20_cassette_tc) m_cass_data.input.length = 0; m_cass_data.input.level = cass_ws; } - ay31015_set_input_pin( m_uart, AY31015_SI, m_cass_data.input.bit ); + m_uart->set_input_pin(AY31015_SI, m_cass_data.input.bit); } /* saving a tape - convert the serial stream from the uart, into 600 and 1200 Hz frequencies. */ @@ -296,7 +296,7 @@ TIMER_CALLBACK_MEMBER(sol20_state::sol20_cassette_tc) m_cass_data.output.length++; if (!(m_cass_data.output.length & 7)) { - cass_ws = ay31015_get_output_pin( m_uart, AY31015_SO ); + cass_ws = m_uart->get_output_pin(AY31015_SO); if (cass_ws != m_cass_data.output.bit) { m_cass_data.output.bit = cass_ws; @@ -322,22 +322,22 @@ READ8_MEMBER( sol20_state::sol20_f8_r ) /* set unemulated bits (CTS/DSR/CD) high */ UINT8 data = 0x23; - ay31015_set_input_pin( m_uart_s, AY31015_SWE, 0 ); - data |= ay31015_get_output_pin( m_uart_s, AY31015_TBMT ) ? 0x80 : 0; - data |= ay31015_get_output_pin( m_uart_s, AY31015_DAV ) ? 0x40 : 0; - data |= ay31015_get_output_pin( m_uart_s, AY31015_OR ) ? 0x10 : 0; - data |= ay31015_get_output_pin( m_uart_s, AY31015_PE ) ? 0x08 : 0; - data |= ay31015_get_output_pin( m_uart_s, AY31015_FE ) ? 0x04 : 0; - ay31015_set_input_pin( m_uart_s, AY31015_SWE, 1 ); + m_uart_s->set_input_pin(AY31015_SWE, 0); + data |= m_uart_s->get_output_pin(AY31015_TBMT) ? 0x80 : 0; + data |= m_uart_s->get_output_pin(AY31015_DAV ) ? 0x40 : 0; + data |= m_uart_s->get_output_pin(AY31015_OR ) ? 0x10 : 0; + data |= m_uart_s->get_output_pin(AY31015_PE ) ? 0x08 : 0; + data |= m_uart_s->get_output_pin(AY31015_FE ) ? 0x04 : 0; + m_uart_s->set_input_pin(AY31015_SWE, 1); return data; } READ8_MEMBER( sol20_state::sol20_f9_r) { - UINT8 data = ay31015_get_received_data( m_uart_s ); - ay31015_set_input_pin( m_uart_s, AY31015_RDAV, 0 ); - ay31015_set_input_pin( m_uart_s, AY31015_RDAV, 1 ); + UINT8 data = m_uart_s->get_received_data(); + m_uart_s->set_input_pin(AY31015_RDAV, 0); + m_uart_s->set_input_pin(AY31015_RDAV, 1); return data; } @@ -346,12 +346,12 @@ READ8_MEMBER( sol20_state::sol20_fa_r ) /* set unused bits high */ UINT8 data = 0x26; - ay31015_set_input_pin( m_uart, AY31015_SWE, 0 ); - data |= ay31015_get_output_pin( m_uart, AY31015_TBMT ) ? 0x80 : 0; - data |= ay31015_get_output_pin( m_uart, AY31015_DAV ) ? 0x40 : 0; - data |= ay31015_get_output_pin( m_uart, AY31015_OR ) ? 0x10 : 0; - data |= ay31015_get_output_pin( m_uart, AY31015_FE ) ? 0x08 : 0; - ay31015_set_input_pin( m_uart, AY31015_SWE, 1 ); + m_uart->set_input_pin(AY31015_SWE, 0); + data |= m_uart->get_output_pin(AY31015_TBMT) ? 0x80 : 0; + data |= m_uart->get_output_pin(AY31015_DAV ) ? 0x40 : 0; + data |= m_uart->get_output_pin(AY31015_OR ) ? 0x10 : 0; + data |= m_uart->get_output_pin(AY31015_FE ) ? 0x08 : 0; + m_uart->set_input_pin(AY31015_SWE, 1); bool arrowkey = m_iop_arrows->read() ? 0 : 1; bool keydown = m_sol20_fa & 1; @@ -361,9 +361,9 @@ READ8_MEMBER( sol20_state::sol20_fa_r ) READ8_MEMBER( sol20_state::sol20_fb_r) { - UINT8 data = ay31015_get_received_data( m_uart ); - ay31015_set_input_pin( m_uart, AY31015_RDAV, 0 ); - ay31015_set_input_pin( m_uart, AY31015_RDAV, 1 ); + UINT8 data = m_uart->get_received_data(); + m_uart->set_input_pin(AY31015_RDAV, 0); + m_uart->set_input_pin(AY31015_RDAV, 1); return data; } @@ -392,7 +392,7 @@ WRITE8_MEMBER( sol20_state::sol20_f8_w ) WRITE8_MEMBER( sol20_state::sol20_f9_w ) { - ay31015_set_transmit_data( m_uart_s, data ); + m_uart_s->set_transmit_data(data); } WRITE8_MEMBER( sol20_state::sol20_fa_w ) @@ -414,13 +414,13 @@ WRITE8_MEMBER( sol20_state::sol20_fa_w ) m_cassette_timer->adjust(attotime::zero); // bit 5 baud rate */ - ay31015_set_receiver_clock( m_uart, (BIT(data, 5)) ? 4800.0 : 19200.0); - ay31015_set_transmitter_clock( m_uart, (BIT(data, 5)) ? 4800.0 : 19200.0); + m_uart->set_receiver_clock((BIT(data, 5)) ? 4800.0 : 19200.0); + m_uart->set_transmitter_clock((BIT(data, 5)) ? 4800.0 : 19200.0); } WRITE8_MEMBER( sol20_state::sol20_fb_w ) { - ay31015_set_transmit_data( m_uart, data ); + m_uart->set_transmit_data(data); } WRITE8_MEMBER( sol20_state::sol20_fd_w ) @@ -549,7 +549,6 @@ INPUT_PORTS_END static const ay31015_config sol20_ay31015_config = { - AY_3_1015, 4800.0, 4800.0, DEVCB_NULL, @@ -587,23 +586,23 @@ void sol20_state::machine_reset() m_sol20_fa=1; // set hard-wired uart pins - ay31015_set_input_pin( m_uart, AY31015_CS, 0 ); - ay31015_set_input_pin( m_uart, AY31015_NB1, 1); - ay31015_set_input_pin( m_uart, AY31015_NB2, 1); - ay31015_set_input_pin( m_uart, AY31015_TSB, 1); - ay31015_set_input_pin( m_uart, AY31015_EPS, 1); - ay31015_set_input_pin( m_uart, AY31015_NP, 1); - ay31015_set_input_pin( m_uart, AY31015_CS, 1 ); + m_uart->set_input_pin(AY31015_CS, 0); + m_uart->set_input_pin(AY31015_NB1, 1); + m_uart->set_input_pin(AY31015_NB2, 1); + m_uart->set_input_pin(AY31015_TSB, 1); + m_uart->set_input_pin(AY31015_EPS, 1); + m_uart->set_input_pin(AY31015_NP, 1); + m_uart->set_input_pin(AY31015_CS, 1); // set switched uart pins data = m_iop_s4->read(); - ay31015_set_input_pin( m_uart_s, AY31015_CS, 0 ); - ay31015_set_input_pin( m_uart_s, AY31015_NB1, BIT(data, 1) ? 1 : 0); - ay31015_set_input_pin( m_uart_s, AY31015_NB2, BIT(data, 2) ? 1 : 0); - ay31015_set_input_pin( m_uart_s, AY31015_TSB, BIT(data, 3) ? 1 : 0); - ay31015_set_input_pin( m_uart_s, AY31015_EPS, BIT(data, 0) ? 1 : 0); - ay31015_set_input_pin( m_uart_s, AY31015_NP, BIT(data, 4) ? 1 : 0); - ay31015_set_input_pin( m_uart_s, AY31015_CS, 1 ); + m_uart_s->set_input_pin(AY31015_CS, 0); + m_uart_s->set_input_pin(AY31015_NB1, BIT(data, 1)); + m_uart_s->set_input_pin(AY31015_NB2, BIT(data, 2)); + m_uart_s->set_input_pin(AY31015_TSB, BIT(data, 3)); + m_uart_s->set_input_pin(AY31015_EPS, BIT(data, 0)); + m_uart_s->set_input_pin(AY31015_NP, BIT(data, 4)); + m_uart_s->set_input_pin(AY31015_CS, 1); // set rs232 baud rate data = m_iop_s3->read(); @@ -622,8 +621,8 @@ void sol20_state::machine_reset() s_clock = s_bauds[s_count] << 4; // these lines could be commented out for now if you want better performance - ay31015_set_receiver_clock( m_uart_s, s_clock); - ay31015_set_transmitter_clock( m_uart_s, s_clock); + m_uart_s->set_receiver_clock(s_clock); + m_uart_s->set_transmitter_clock(s_clock); // boot-bank membank("boot")->set_entry(1); diff --git a/src/mess/drivers/sorcerer.c b/src/mess/drivers/sorcerer.c index f6e517e76b3..1e7af626170 100644 --- a/src/mess/drivers/sorcerer.c +++ b/src/mess/drivers/sorcerer.c @@ -386,7 +386,6 @@ UINT32 sorcerer_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap static const ay31015_config sorcerer_ay31015_config = { - AY_3_1015, 4800.0, 4800.0, DEVCB_NULL, diff --git a/src/mess/drivers/trs80.c b/src/mess/drivers/trs80.c index 4859d4db050..ba2e211a558 100644 --- a/src/mess/drivers/trs80.c +++ b/src/mess/drivers/trs80.c @@ -554,7 +554,6 @@ static const cassette_interface trs80l2_cassette_interface = static const ay31015_config trs80_ay31015_config = { - AY_3_1015, 0.0, 0.0, DEVCB_NULL, diff --git a/src/mess/drivers/z80ne.c b/src/mess/drivers/z80ne.c index 35eb717ee01..3d89876f49a 100644 --- a/src/mess/drivers/z80ne.c +++ b/src/mess/drivers/z80ne.c @@ -97,7 +97,6 @@ #include "machine/ram.h" /* peripheral chips */ -#include "machine/ay31015.h" #include "machine/kr2376.h" #include "machine/wd17xx.h" @@ -405,7 +404,6 @@ static const UINT32 lx388palette[] = static const ay31015_config z80ne_ay31015_config = { - AY_3_1015, 4800.0, 4800.0, DEVCB_NULL, diff --git a/src/mess/includes/nascom1.h b/src/mess/includes/nascom1.h index 4f35b2cb3e1..0a05e776f66 100644 --- a/src/mess/includes/nascom1.h +++ b/src/mess/includes/nascom1.h @@ -8,9 +8,10 @@ #define NASCOM1_H_ #include "imagedev/snapquik.h" -#include "machine/wd17xx.h" #include "imagedev/cassette.h" +#include "machine/wd17xx.h" #include "machine/ram.h" +#include "machine/ay31015.h" struct nascom1_portstat_t { @@ -31,13 +32,18 @@ class nascom1_state : public driver_device public: nascom1_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), - m_videoram(*this, "videoram"), m_maincpu(*this, "maincpu"), + m_hd6402(*this, "hd6402"), m_cassette(*this, "cassette"), - m_ram(*this, RAM_TAG) { } + m_ram(*this, RAM_TAG), + m_videoram(*this, "videoram") + { } + required_device m_maincpu; + required_device m_hd6402; + required_device m_cassette; + required_device m_ram; required_shared_ptr m_videoram; - device_t *m_hd6402; int m_tape_size; UINT8 *m_tape_image; int m_tape_index; @@ -61,9 +67,6 @@ public: DECLARE_WRITE8_MEMBER(nascom1_hd6402_so); DECLARE_DEVICE_IMAGE_LOAD_MEMBER( nascom1_cassette ); DECLARE_DEVICE_IMAGE_UNLOAD_MEMBER( nascom1_cassette ); - required_device m_maincpu; - required_device m_cassette; - required_device m_ram; DECLARE_SNAPSHOT_LOAD_MEMBER( nascom1 ); }; diff --git a/src/mess/includes/z80ne.h b/src/mess/includes/z80ne.h index 46801820e05..3d51d89452d 100644 --- a/src/mess/includes/z80ne.h +++ b/src/mess/includes/z80ne.h @@ -13,6 +13,7 @@ #include "video/mc6847.h" #include "imagedev/cassette.h" +#include "machine/ay31015.h" /*************************************************************************** @@ -97,7 +98,7 @@ public: optional_device m_vdg; optional_shared_ptr m_videoram; - required_device m_ay31015; + required_device m_ay31015; optional_device m_lx388_kr2376; UINT8 m_lx383_scan_counter; UINT8 m_lx383_key[LX383_KEYS]; diff --git a/src/mess/machine/nascom1.c b/src/mess/machine/nascom1.c index 57e94661528..c3848a77235 100644 --- a/src/mess/machine/nascom1.c +++ b/src/mess/machine/nascom1.c @@ -142,26 +142,26 @@ WRITE8_MEMBER(nascom1_state::nascom1_port_00_w) READ8_MEMBER(nascom1_state::nascom1_port_01_r) { - return ay31015_get_received_data( m_hd6402 ); + return m_hd6402->get_received_data(); } WRITE8_MEMBER(nascom1_state::nascom1_port_01_w) { - ay31015_set_transmit_data( m_hd6402, data ); + m_hd6402->set_transmit_data(data); } READ8_MEMBER(nascom1_state::nascom1_port_02_r) { UINT8 data = 0x31; - ay31015_set_input_pin( m_hd6402, AY31015_SWE, 0 ); - data |= ay31015_get_output_pin( m_hd6402, AY31015_OR ) ? 0x02 : 0; - data |= ay31015_get_output_pin( m_hd6402, AY31015_PE ) ? 0x04 : 0; - data |= ay31015_get_output_pin( m_hd6402, AY31015_FE ) ? 0x08 : 0; - data |= ay31015_get_output_pin( m_hd6402, AY31015_TBMT ) ? 0x40 : 0; - data |= ay31015_get_output_pin( m_hd6402, AY31015_DAV ) ? 0x80 : 0; - ay31015_set_input_pin( m_hd6402, AY31015_SWE, 1 ); + m_hd6402->set_input_pin(AY31015_SWE, 0); + data |= m_hd6402->get_output_pin(AY31015_OR ) ? 0x02 : 0; + data |= m_hd6402->get_output_pin(AY31015_PE ) ? 0x04 : 0; + data |= m_hd6402->get_output_pin(AY31015_FE ) ? 0x08 : 0; + data |= m_hd6402->get_output_pin(AY31015_TBMT) ? 0x40 : 0; + data |= m_hd6402->get_output_pin(AY31015_DAV ) ? 0x80 : 0; + m_hd6402->set_input_pin(AY31015_SWE, 1); return data; } @@ -241,18 +241,16 @@ SNAPSHOT_LOAD_MEMBER( nascom1_state, nascom1 ) void nascom1_state::machine_reset() { - m_hd6402 = machine().device("hd6402"); - /* Set up hd6402 pins */ - ay31015_set_input_pin( m_hd6402, AY31015_SWE, 1 ); + m_hd6402->set_input_pin(AY31015_SWE, 1); - ay31015_set_input_pin( m_hd6402, AY31015_CS, 0 ); - ay31015_set_input_pin( m_hd6402, AY31015_NP, 1 ); - ay31015_set_input_pin( m_hd6402, AY31015_NB1, 1 ); - ay31015_set_input_pin( m_hd6402, AY31015_NB2, 1 ); - ay31015_set_input_pin( m_hd6402, AY31015_EPS, 1 ); - ay31015_set_input_pin( m_hd6402, AY31015_TSB, 1 ); - ay31015_set_input_pin( m_hd6402, AY31015_CS, 1 ); + m_hd6402->set_input_pin(AY31015_CS, 0); + m_hd6402->set_input_pin(AY31015_NP, 1); + m_hd6402->set_input_pin(AY31015_NB1, 1); + m_hd6402->set_input_pin(AY31015_NB2, 1); + m_hd6402->set_input_pin(AY31015_EPS, 1); + m_hd6402->set_input_pin(AY31015_TSB, 1); + m_hd6402->set_input_pin(AY31015_CS, 1); } DRIVER_INIT_MEMBER(nascom1_state,nascom1) diff --git a/src/mess/machine/sorcerer.c b/src/mess/machine/sorcerer.c index ade42483699..e6d1c5c0a4d 100644 --- a/src/mess/machine/sorcerer.c +++ b/src/mess/machine/sorcerer.c @@ -69,7 +69,7 @@ TIMER_CALLBACK_MEMBER(sorcerer_state::sorcerer_cassette_tc) m_cass_data.input.level = cass_ws; m_cass_data.input.bit = ((m_cass_data.input.length < 0x6) || (m_cass_data.input.length > 0x20)) ? 1 : 0; m_cass_data.input.length = 0; - ay31015_set_input_pin( m_uart, AY31015_SI, m_cass_data.input.bit ); + m_uart->set_input_pin(AY31015_SI, m_cass_data.input.bit); } /* saving a tape - convert the serial stream from the uart, into 1200 and 2400 Hz frequencies. @@ -78,7 +78,7 @@ TIMER_CALLBACK_MEMBER(sorcerer_state::sorcerer_cassette_tc) m_cass_data.output.length++; if (!(m_cass_data.output.length & 0x1f)) { - cass_ws = ay31015_get_output_pin( m_uart, AY31015_SO ); + cass_ws = m_uart->get_output_pin(AY31015_SO); if (cass_ws != m_cass_data.output.bit) { m_cass_data.output.bit = cass_ws; @@ -110,7 +110,7 @@ TIMER_CALLBACK_MEMBER(sorcerer_state::sorcerer_cassette_tc) m_cass_data.input.length = 0; m_cass_data.input.level = cass_ws; } - ay31015_set_input_pin( m_uart, AY31015_SI, m_cass_data.input.bit ); + m_uart->set_input_pin(AY31015_SI, m_cass_data.input.bit); } /* saving a tape - convert the serial stream from the uart, into 600 and 1200 Hz frequencies. */ @@ -118,7 +118,7 @@ TIMER_CALLBACK_MEMBER(sorcerer_state::sorcerer_cassette_tc) m_cass_data.output.length++; if (!(m_cass_data.output.length & 7)) { - cass_ws = ay31015_get_output_pin( m_uart, AY31015_SO ); + cass_ws = m_uart->get_output_pin(AY31015_SO); if (cass_ws != m_cass_data.output.bit) { m_cass_data.output.bit = cass_ws; @@ -147,7 +147,7 @@ TIMER_CALLBACK_MEMBER(sorcerer_state::sorcerer_reset) WRITE8_MEMBER(sorcerer_state::sorcerer_fc_w) { - ay31015_set_transmit_data( m_uart, data ); + m_uart->set_transmit_data(data); } @@ -155,13 +155,13 @@ WRITE8_MEMBER(sorcerer_state::sorcerer_fd_w) { /* Translate data to control signals */ - ay31015_set_input_pin( m_uart, AY31015_CS, 0 ); - ay31015_set_input_pin( m_uart, AY31015_NB1, data & 1); - ay31015_set_input_pin( m_uart, AY31015_NB2, (BIT(data, 1)) ? 1 : 0 ); - ay31015_set_input_pin( m_uart, AY31015_TSB, (BIT(data, 2)) ? 1 : 0 ); - ay31015_set_input_pin( m_uart, AY31015_EPS, (BIT(data, 3)) ? 1 : 0 ); - ay31015_set_input_pin( m_uart, AY31015_NP, (BIT(data, 4)) ? 1 : 0 ); - ay31015_set_input_pin( m_uart, AY31015_CS, 1 ); + m_uart->set_input_pin(AY31015_CS, 0); + m_uart->set_input_pin(AY31015_NB1, BIT(data, 0)); + m_uart->set_input_pin(AY31015_NB2, BIT(data, 1)); + m_uart->set_input_pin(AY31015_TSB, BIT(data, 2)); + m_uart->set_input_pin(AY31015_EPS, BIT(data, 3)); + m_uart->set_input_pin(AY31015_NP, BIT(data, 4)); + m_uart->set_input_pin(AY31015_CS, 1); } WRITE8_MEMBER(sorcerer_state::sorcerer_fe_w) @@ -215,8 +215,8 @@ WRITE8_MEMBER(sorcerer_state::sorcerer_fe_w) // bit 6 baud rate */ if (BIT(changed_bits, 6)) { - ay31015_set_receiver_clock( m_uart, (BIT(data, 6)) ? 19200.0 : 4800.0); - ay31015_set_transmitter_clock( m_uart, (BIT(data, 6)) ? 19200.0 : 4800.0); + m_uart->set_receiver_clock(BIT(data, 6) ? 19200.0 : 4800.0); + m_uart->set_transmitter_clock(BIT(data, 6) ? 19200.0 : 4800.0); } } @@ -246,9 +246,9 @@ WRITE8_MEMBER(sorcerer_state::sorcerer_ff_w) READ8_MEMBER(sorcerer_state::sorcerer_fc_r) { - UINT8 data = ay31015_get_received_data( m_uart ); - ay31015_set_input_pin( m_uart, AY31015_RDAV, 0 ); - ay31015_set_input_pin( m_uart, AY31015_RDAV, 1 ); + UINT8 data = m_uart->get_received_data(); + m_uart->set_input_pin(AY31015_RDAV, 0); + m_uart->set_input_pin(AY31015_RDAV, 1); return data; } @@ -257,13 +257,13 @@ READ8_MEMBER(sorcerer_state::sorcerer_fd_r) /* set unused bits high */ UINT8 data = 0xe0; - ay31015_set_input_pin( m_uart, AY31015_SWE, 0 ); - data |= ay31015_get_output_pin( m_uart, AY31015_TBMT ) ? 0x01 : 0; - data |= ay31015_get_output_pin( m_uart, AY31015_DAV ) ? 0x02 : 0; - data |= ay31015_get_output_pin( m_uart, AY31015_OR ) ? 0x04 : 0; - data |= ay31015_get_output_pin( m_uart, AY31015_FE ) ? 0x08 : 0; - data |= ay31015_get_output_pin( m_uart, AY31015_PE ) ? 0x10 : 0; - ay31015_set_input_pin( m_uart, AY31015_SWE, 1 ); + m_uart->set_input_pin(AY31015_SWE, 0); + data |= m_uart->get_output_pin(AY31015_TBMT) ? 0x01 : 0; + data |= m_uart->get_output_pin(AY31015_DAV ) ? 0x02 : 0; + data |= m_uart->get_output_pin(AY31015_OR ) ? 0x04 : 0; + data |= m_uart->get_output_pin(AY31015_FE ) ? 0x08 : 0; + data |= m_uart->get_output_pin(AY31015_PE ) ? 0x10 : 0; + m_uart->set_input_pin(AY31015_SWE, 1); return data; } diff --git a/src/mess/machine/trs80.c b/src/mess/machine/trs80.c index bd52ea8611d..71019726aab 100644 --- a/src/mess/machine/trs80.c +++ b/src/mess/machine/trs80.c @@ -123,13 +123,13 @@ READ8_MEMBER( trs80_state::trs80m4_ea_r ) d2..d0 Not used */ UINT8 data=7; - ay31015_set_input_pin( m_ay31015, AY31015_SWE, 0 ); - data |= ay31015_get_output_pin( m_ay31015, AY31015_TBMT ) ? 0x40 : 0; - data |= ay31015_get_output_pin( m_ay31015, AY31015_DAV ) ? 0x80 : 0; - data |= ay31015_get_output_pin( m_ay31015, AY31015_OR ) ? 0x20 : 0; - data |= ay31015_get_output_pin( m_ay31015, AY31015_FE ) ? 0x10 : 0; - data |= ay31015_get_output_pin( m_ay31015, AY31015_PE ) ? 0x08 : 0; - ay31015_set_input_pin( m_ay31015, AY31015_SWE, 1 ); + m_ay31015->set_input_pin(AY31015_SWE, 0); + data |= m_ay31015->get_output_pin(AY31015_TBMT) ? 0x40 : 0; + data |= m_ay31015->get_output_pin(AY31015_DAV ) ? 0x80 : 0; + data |= m_ay31015->get_output_pin(AY31015_OR ) ? 0x20 : 0; + data |= m_ay31015->get_output_pin(AY31015_FE ) ? 0x10 : 0; + data |= m_ay31015->get_output_pin(AY31015_PE ) ? 0x08 : 0; + m_ay31015->set_input_pin(AY31015_SWE, 1); return data; } @@ -137,9 +137,9 @@ READ8_MEMBER( trs80_state::trs80m4_ea_r ) READ8_MEMBER( trs80_state::trs80m4_eb_r ) { /* UART received data */ - UINT8 data = ay31015_get_received_data( m_ay31015 ); - ay31015_set_input_pin( m_ay31015, AY31015_RDAV, 0 ); - ay31015_set_input_pin( m_ay31015, AY31015_RDAV, 1 ); + UINT8 data = m_ay31015->get_received_data(); + m_ay31015->set_input_pin(AY31015_RDAV, 0); + m_ay31015->set_input_pin(AY31015_RDAV, 1); return data; } @@ -162,14 +162,14 @@ READ8_MEMBER( trs80_state::sys80_f9_r ) d1 Overrun d0 Data Available */ - UINT8 data=70; - ay31015_set_input_pin( m_ay31015, AY31015_SWE, 0 ); - data |= ay31015_get_output_pin( m_ay31015, AY31015_TBMT ) ? 0 : 0x80; - data |= ay31015_get_output_pin( m_ay31015, AY31015_DAV ) ? 0x01 : 0; - data |= ay31015_get_output_pin( m_ay31015, AY31015_OR ) ? 0x02 : 0; - data |= ay31015_get_output_pin( m_ay31015, AY31015_FE ) ? 0x04 : 0; - data |= ay31015_get_output_pin( m_ay31015, AY31015_PE ) ? 0x08 : 0; - ay31015_set_input_pin( m_ay31015, AY31015_SWE, 1 ); + UINT8 data = 70; + m_ay31015->set_input_pin(AY31015_SWE, 0); + data |= m_ay31015->get_output_pin(AY31015_TBMT) ? 0 : 0x80; + data |= m_ay31015->get_output_pin(AY31015_DAV ) ? 0x01 : 0; + data |= m_ay31015->get_output_pin(AY31015_OR ) ? 0x02 : 0; + data |= m_ay31015->get_output_pin(AY31015_FE ) ? 0x04 : 0; + data |= m_ay31015->get_output_pin(AY31015_PE ) ? 0x08 : 0; + m_ay31015->set_input_pin(AY31015_SWE, 1); return data; } @@ -421,8 +421,8 @@ WRITE8_MEMBER( trs80_state::trs80m4_e9_w ) FFh 19200 */ static const int baud_clock[]={ 800, 1200, 1760, 2152, 2400, 4800, 9600, 19200, 28800, 32000, 38400, 57600, 76800, 115200, 153600, 307200 }; - ay31015_set_receiver_clock( m_ay31015, baud_clock[data & 0x0f]); - ay31015_set_transmitter_clock( m_ay31015, baud_clock[data>>4]); + m_ay31015->set_receiver_clock(baud_clock[data & 0x0f]); + m_ay31015->set_transmitter_clock(baud_clock[data >> 4]); } WRITE8_MEMBER( trs80_state::trs80m4_ea_w ) @@ -442,13 +442,13 @@ WRITE8_MEMBER( trs80_state::trs80m4_ea_w ) d0 Data-Terminal-Ready (DTR), pin 20 */ { - ay31015_set_input_pin( m_ay31015, AY31015_CS, 0 ); - ay31015_set_input_pin( m_ay31015, AY31015_NB1, ( data & 0x40 ) ? 1 : 0 ); - ay31015_set_input_pin( m_ay31015, AY31015_NB2, ( data & 0x20 ) ? 1 : 0 ); - ay31015_set_input_pin( m_ay31015, AY31015_TSB, ( data & 0x10 ) ? 1 : 0 ); - ay31015_set_input_pin( m_ay31015, AY31015_EPS, ( data & 0x80 ) ? 1 : 0 ); - ay31015_set_input_pin( m_ay31015, AY31015_NP, ( data & 0x08 ) ? 1 : 0 ); - ay31015_set_input_pin( m_ay31015, AY31015_CS, 1 ); + m_ay31015->set_input_pin(AY31015_CS, 0); + m_ay31015->set_input_pin(AY31015_NB1, BIT(data, 6)); + m_ay31015->set_input_pin(AY31015_NB2, BIT(data, 5)); + m_ay31015->set_input_pin(AY31015_TSB, BIT(data, 4)); + m_ay31015->set_input_pin(AY31015_EPS, BIT(data, 7)); + m_ay31015->set_input_pin(AY31015_NP, BIT(data, 3)); + m_ay31015->set_input_pin(AY31015_CS, 1); } else { @@ -466,7 +466,7 @@ WRITE8_MEMBER( trs80_state::trs80m4_ea_w ) WRITE8_MEMBER( trs80_state::trs80m4_eb_w ) { - ay31015_set_transmit_data( m_ay31015, data ); + m_ay31015->set_transmit_data(data); } WRITE8_MEMBER( trs80_state::trs80m4_ec_w ) diff --git a/src/mess/machine/z80ne.c b/src/mess/machine/z80ne.c index 746054b2c45..ee86488044a 100644 --- a/src/mess/machine/z80ne.c +++ b/src/mess/machine/z80ne.c @@ -49,7 +49,7 @@ TIMER_CALLBACK_MEMBER(z80ne_state::z80ne_cassette_tc) m_cass_data.input.level = cass_ws; m_cass_data.input.bit = ((m_cass_data.input.length < m_cass_data.wave_filter) || (m_cass_data.input.length > 0x20)) ? 1 : 0; m_cass_data.input.length = 0; - ay31015_set_input_pin( m_ay31015, AY31015_SI, m_cass_data.input.bit ); + m_ay31015->set_input_pin(AY31015_SI, m_cass_data.input.bit); } m_cass_data.input.level = cass_ws; @@ -64,7 +64,7 @@ TIMER_CALLBACK_MEMBER(z80ne_state::z80ne_cassette_tc) else { m_cass_data.output.level=1; - cass_ws = ay31015_get_output_pin( m_ay31015, AY31015_SO ); + cass_ws = m_ay31015->get_output_pin(AY31015_SO); m_cass_data.wave_length = cass_ws ? m_cass_data.wave_short : m_cass_data.wave_long; } cassette_device_image()->output(m_cass_data.output.level ? -1.0 : +1.0); @@ -312,15 +312,15 @@ MACHINE_RESET_MEMBER(z80ne_state,z80ne_base) m_cass_data.input.length = 0; m_cass_data.input.bit = 1; - ay31015_set_input_pin( m_ay31015, AY31015_CS, 0 ); - ay31015_set_input_pin( m_ay31015, AY31015_NB1, 1 ); - ay31015_set_input_pin( m_ay31015, AY31015_NB2, 1 ); - ay31015_set_input_pin( m_ay31015, AY31015_TSB, 1 ); - ay31015_set_input_pin( m_ay31015, AY31015_EPS, 1 ); - ay31015_set_input_pin( m_ay31015, AY31015_NP, m_io_lx_385->read() & 0x80 ? 1 : 0 ); - ay31015_set_input_pin( m_ay31015, AY31015_CS, 1 ); - ay31015_set_receiver_clock( m_ay31015, m_cass_data.speed * 16.0); - ay31015_set_transmitter_clock( m_ay31015, m_cass_data.speed * 16.0); + m_ay31015->set_input_pin(AY31015_CS, 0); + m_ay31015->set_input_pin(AY31015_NB1, 1); + m_ay31015->set_input_pin(AY31015_NB2, 1); + m_ay31015->set_input_pin(AY31015_TSB, 1); + m_ay31015->set_input_pin(AY31015_EPS, 1); + m_ay31015->set_input_pin(AY31015_NP, m_io_lx_385->read() & 0x80 ? 1 : 0); + m_ay31015->set_input_pin(AY31015_CS, 1); + m_ay31015->set_receiver_clock(m_cass_data.speed * 16.0); + m_ay31015->set_transmitter_clock(m_cass_data.speed * 16.0); m_nmi_delay_counter = 0; lx385_ctrl_w(m_maincpu->space(AS_PROGRAM), 0, 0); @@ -518,7 +518,7 @@ WRITE8_MEMBER(z80ne_state::lx383_w) */ READ8_MEMBER(z80ne_state::lx385_data_r) { - return ay31015_get_received_data( m_ay31015 ); + return m_ay31015->get_received_data(); } READ8_MEMBER(z80ne_state::lx385_ctrl_r) @@ -526,21 +526,21 @@ READ8_MEMBER(z80ne_state::lx385_ctrl_r) /* set unused bits high */ UINT8 data = 0xc0; - ay31015_set_input_pin( m_ay31015, AY31015_SWE, 0 ); - data |= (ay31015_get_output_pin( m_ay31015, AY31015_OR ) ? 0x01 : 0); - data |= (ay31015_get_output_pin( m_ay31015, AY31015_FE ) ? 0x02 : 0); - data |= (ay31015_get_output_pin( m_ay31015, AY31015_PE ) ? 0x04 : 0); - data |= (ay31015_get_output_pin( m_ay31015, AY31015_TBMT ) ? 0x08 : 0); - data |= (ay31015_get_output_pin( m_ay31015, AY31015_DAV ) ? 0x10 : 0); - data |= (ay31015_get_output_pin( m_ay31015, AY31015_EOC ) ? 0x20 : 0); - ay31015_set_input_pin( m_ay31015, AY31015_SWE, 1 ); + m_ay31015->set_input_pin(AY31015_SWE, 0); + data |= (m_ay31015->get_output_pin(AY31015_OR ) ? 0x01 : 0); + data |= (m_ay31015->get_output_pin(AY31015_FE ) ? 0x02 : 0); + data |= (m_ay31015->get_output_pin(AY31015_PE ) ? 0x04 : 0); + data |= (m_ay31015->get_output_pin(AY31015_TBMT) ? 0x08 : 0); + data |= (m_ay31015->get_output_pin(AY31015_DAV ) ? 0x10 : 0); + data |= (m_ay31015->get_output_pin(AY31015_EOC ) ? 0x20 : 0); + m_ay31015->set_input_pin(AY31015_SWE, 1); return data; } WRITE8_MEMBER(z80ne_state::lx385_data_w) { - ay31015_set_transmit_data( m_ay31015, data ); + m_ay31015->set_transmit_data(data); } #define LX385_CASSETTE_MOTOR_MASK ((1<<3)|(1<<4)) @@ -566,23 +566,23 @@ WRITE8_MEMBER(z80ne_state::lx385_ctrl_w) motor_b = ((data & 0x10) == 0x00); /* UART Reset and RDAV */ - if(uart_reset) + if (uart_reset) { - ay31015_set_input_pin( m_ay31015, AY31015_XR, 1 ); - ay31015_set_input_pin( m_ay31015, AY31015_XR, 0 ); + m_ay31015->set_input_pin(AY31015_XR, 1); + m_ay31015->set_input_pin(AY31015_XR, 0); } - if(uart_rdav) + if (uart_rdav) { - ay31015_set_input_pin( m_ay31015, AY31015_RDAV, 1 ); - ay31015_set_input_pin( m_ay31015, AY31015_RDAV, 0 ); + m_ay31015->set_input_pin(AY31015_RDAV, 1); + m_ay31015->set_input_pin(AY31015_RDAV, 0); } if (!changed_bits) return; /* UART Tx Clock enable/disable */ - if(changed_bits & 0x04) - ay31015_set_transmitter_clock( m_ay31015, uart_tx_clock ? m_cass_data.speed * 16.0 : 0.0); + if (changed_bits & 0x04) + m_ay31015->set_transmitter_clock(uart_tx_clock ? m_cass_data.speed * 16.0 : 0.0); /* motors */ if(changed_bits & 0x18)