mirror of
https://github.com/holub/mame
synced 2025-06-06 12:53:46 +03:00
z80dart: Cleanup. (nw)
This commit is contained in:
parent
f646335964
commit
0884496d2b
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
|
|
||||||
|
- devcb2
|
||||||
- i8274 DMA scheme
|
- i8274 DMA scheme
|
||||||
- break detection
|
- break detection
|
||||||
- wr0 reset tx interrupt pending
|
- wr0 reset tx interrupt pending
|
||||||
@ -30,20 +31,7 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "emu.h"
|
|
||||||
#include "z80dart.h"
|
#include "z80dart.h"
|
||||||
#include "cpu/z80/z80.h"
|
|
||||||
#include "cpu/z80/z80daisy.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
|
||||||
// DEBUGGING
|
|
||||||
//**************************************************************************
|
|
||||||
|
|
||||||
#define VERBOSE 0
|
|
||||||
|
|
||||||
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -51,13 +39,17 @@
|
|||||||
// MACROS / CONSTANTS
|
// MACROS / CONSTANTS
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
|
|
||||||
|
#define VERBOSE 0
|
||||||
|
|
||||||
|
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
|
||||||
|
|
||||||
#define CHANA_TAG "cha"
|
#define CHANA_TAG "cha"
|
||||||
#define CHANB_TAG "chb"
|
#define CHANB_TAG "chb"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
// LIVE DEVICE
|
// DEVICE DEFINITIONS
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
|
|
||||||
// device type definition
|
// device type definition
|
||||||
@ -72,6 +64,10 @@ const device_type I8274 = &device_creator<i8274_device>;
|
|||||||
const device_type UPD7201 = &device_creator<upd7201_device>;
|
const device_type UPD7201 = &device_creator<upd7201_device>;
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// device_mconfig_additions -
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
MACHINE_CONFIG_FRAGMENT( z80dart )
|
MACHINE_CONFIG_FRAGMENT( z80dart )
|
||||||
MCFG_DEVICE_ADD(CHANA_TAG, Z80DART_CHANNEL, 0)
|
MCFG_DEVICE_ADD(CHANA_TAG, Z80DART_CHANNEL, 0)
|
||||||
MCFG_DEVICE_ADD(CHANB_TAG, Z80DART_CHANNEL, 0)
|
MCFG_DEVICE_ADD(CHANB_TAG, Z80DART_CHANNEL, 0)
|
||||||
@ -83,6 +79,11 @@ machine_config_constructor z80dart_device::device_mconfig_additions() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//**************************************************************************
|
||||||
|
// LIVE DEVICE
|
||||||
|
//**************************************************************************
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// z80dart_device - constructor
|
// z80dart_device - constructor
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
@ -238,11 +239,6 @@ void z80dart_device::device_reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
|
||||||
// DAISY CHAIN INTERFACE
|
|
||||||
//**************************************************************************
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// z80daisy_irq_state - get interrupt status
|
// z80daisy_irq_state - get interrupt status
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
@ -334,11 +330,6 @@ void z80dart_device::z80daisy_irq_reti()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
|
||||||
// IMPLEMENTATION
|
|
||||||
//**************************************************************************
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// check_interrupts -
|
// check_interrupts -
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
@ -404,6 +395,68 @@ int z80dart_device::m1_r()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// cd_ba_r -
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
READ8_MEMBER( z80dart_device::cd_ba_r )
|
||||||
|
{
|
||||||
|
int ba = BIT(offset, 0);
|
||||||
|
int cd = BIT(offset, 1);
|
||||||
|
z80dart_channel *channel = ba ? m_chanB : m_chanA;
|
||||||
|
|
||||||
|
return cd ? channel->control_read() : channel->data_read();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// cd_ba_w -
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
WRITE8_MEMBER( z80dart_device::cd_ba_w )
|
||||||
|
{
|
||||||
|
int ba = BIT(offset, 0);
|
||||||
|
int cd = BIT(offset, 1);
|
||||||
|
z80dart_channel *channel = ba ? m_chanB : m_chanA;
|
||||||
|
|
||||||
|
if (cd)
|
||||||
|
channel->control_write(data);
|
||||||
|
else
|
||||||
|
channel->data_write(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// ba_cd_r -
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
READ8_MEMBER( z80dart_device::ba_cd_r )
|
||||||
|
{
|
||||||
|
int ba = BIT(offset, 1);
|
||||||
|
int cd = BIT(offset, 0);
|
||||||
|
z80dart_channel *channel = ba ? m_chanB : m_chanA;
|
||||||
|
|
||||||
|
return cd ? channel->control_read() : channel->data_read();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// ba_cd_w -
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
WRITE8_MEMBER( z80dart_device::ba_cd_w )
|
||||||
|
{
|
||||||
|
int ba = BIT(offset, 1);
|
||||||
|
int cd = BIT(offset, 0);
|
||||||
|
z80dart_channel *channel = ba ? m_chanB : m_chanA;
|
||||||
|
|
||||||
|
if (cd)
|
||||||
|
channel->control_write(data);
|
||||||
|
else
|
||||||
|
channel->data_write(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
// DART CHANNEL
|
// DART CHANNEL
|
||||||
@ -1020,7 +1073,7 @@ void z80dart_channel::receive_data(UINT8 data)
|
|||||||
// cts_w - clear to send handler
|
// cts_w - clear to send handler
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void z80dart_channel::cts_w(int state)
|
WRITE_LINE_MEMBER( z80dart_channel::cts_w )
|
||||||
{
|
{
|
||||||
LOG(("Z80DART \"%s\" Channel %c : CTS %u\n", m_owner->tag(), 'A' + m_index, state));
|
LOG(("Z80DART \"%s\" Channel %c : CTS %u\n", m_owner->tag(), 'A' + m_index, state));
|
||||||
|
|
||||||
@ -1059,7 +1112,7 @@ void z80dart_channel::cts_w(int state)
|
|||||||
// dcd_w - data carrier detected handler
|
// dcd_w - data carrier detected handler
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void z80dart_channel::dcd_w(int state)
|
WRITE_LINE_MEMBER( z80dart_channel::dcd_w )
|
||||||
{
|
{
|
||||||
LOG(("Z80DART \"%s\" Channel %c : DCD %u\n", m_owner->tag(), 'A' + m_index, state));
|
LOG(("Z80DART \"%s\" Channel %c : DCD %u\n", m_owner->tag(), 'A' + m_index, state));
|
||||||
|
|
||||||
@ -1097,7 +1150,7 @@ void z80dart_channel::dcd_w(int state)
|
|||||||
// ri_w - ring indicator handler
|
// ri_w - ring indicator handler
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void z80dart_channel::ri_w(int state)
|
WRITE_LINE_MEMBER( z80dart_channel::ri_w )
|
||||||
{
|
{
|
||||||
LOG(("Z80DART \"%s\" Channel %c : RI %u\n", m_owner->tag(), 'A' + m_index, state));
|
LOG(("Z80DART \"%s\" Channel %c : RI %u\n", m_owner->tag(), 'A' + m_index, state));
|
||||||
|
|
||||||
@ -1130,7 +1183,7 @@ void z80dart_channel::ri_w(int state)
|
|||||||
// sync_w - sync handler
|
// sync_w - sync handler
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void z80dart_channel::sync_w(int state)
|
WRITE_LINE_MEMBER( z80dart_channel::sync_w )
|
||||||
{
|
{
|
||||||
LOG(("Z80DART \"%s\" Channel %c : SYNC %u\n", m_owner->tag(), 'A' + m_index, state));
|
LOG(("Z80DART \"%s\" Channel %c : SYNC %u\n", m_owner->tag(), 'A' + m_index, state));
|
||||||
}
|
}
|
||||||
@ -1140,7 +1193,7 @@ void z80dart_channel::sync_w(int state)
|
|||||||
// rxc_w - receive clock
|
// rxc_w - receive clock
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void z80dart_channel::rxc_w(int state)
|
WRITE_LINE_MEMBER( z80dart_channel::rxc_w )
|
||||||
{
|
{
|
||||||
int clocks = get_clock_mode();
|
int clocks = get_clock_mode();
|
||||||
|
|
||||||
@ -1160,7 +1213,7 @@ void z80dart_channel::rxc_w(int state)
|
|||||||
// txc_w - transmit clock
|
// txc_w - transmit clock
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void z80dart_channel::txc_w(int state)
|
WRITE_LINE_MEMBER( z80dart_channel::txc_w )
|
||||||
{
|
{
|
||||||
int clocks = get_clock_mode();
|
int clocks = get_clock_mode();
|
||||||
|
|
||||||
@ -1244,39 +1297,3 @@ void z80dart_channel::set_rts(int state)
|
|||||||
|
|
||||||
serial_connection_out();
|
serial_connection_out();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************
|
|
||||||
// GLOBAL STUBS
|
|
||||||
//**************************************************************************
|
|
||||||
|
|
||||||
READ8_MEMBER( z80dart_device::cd_ba_r )
|
|
||||||
{
|
|
||||||
return (offset & 2) ? control_read(offset & 1) : data_read(offset & 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
WRITE8_MEMBER( z80dart_device::cd_ba_w )
|
|
||||||
{
|
|
||||||
if (offset & 2)
|
|
||||||
control_write(offset & 1, data);
|
|
||||||
else
|
|
||||||
data_write(offset & 1, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
READ8_MEMBER( z80dart_device::ba_cd_r )
|
|
||||||
{
|
|
||||||
int channel = BIT(offset, 1);
|
|
||||||
|
|
||||||
return (offset & 1) ? control_read(channel) : data_read(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
WRITE8_MEMBER( z80dart_device::ba_cd_w )
|
|
||||||
{
|
|
||||||
int channel = BIT(offset, 1);
|
|
||||||
|
|
||||||
if (offset & 1)
|
|
||||||
control_write(channel, data);
|
|
||||||
else
|
|
||||||
data_write(channel, data);
|
|
||||||
}
|
|
||||||
|
@ -146,6 +146,7 @@
|
|||||||
#ifndef __Z80DART_H__
|
#ifndef __Z80DART_H__
|
||||||
#define __Z80DART_H__
|
#define __Z80DART_H__
|
||||||
|
|
||||||
|
#include "emu.h"
|
||||||
#include "cpu/z80/z80daisy.h"
|
#include "cpu/z80/z80daisy.h"
|
||||||
|
|
||||||
|
|
||||||
@ -268,12 +269,12 @@ public:
|
|||||||
|
|
||||||
void receive_data(UINT8 data);
|
void receive_data(UINT8 data);
|
||||||
|
|
||||||
void cts_w(int state);
|
DECLARE_WRITE_LINE_MEMBER( cts_w );
|
||||||
void dcd_w(int state);
|
DECLARE_WRITE_LINE_MEMBER( dcd_w );
|
||||||
void ri_w(int state);
|
DECLARE_WRITE_LINE_MEMBER( ri_w );
|
||||||
void rxc_w(int state);
|
DECLARE_WRITE_LINE_MEMBER( rxc_w );
|
||||||
void txc_w(int state);
|
DECLARE_WRITE_LINE_MEMBER( txc_w );
|
||||||
void sync_w(int state);
|
DECLARE_WRITE_LINE_MEMBER( sync_w );
|
||||||
|
|
||||||
devcb_read_line m_in_rxd_cb;
|
devcb_read_line m_in_rxd_cb;
|
||||||
devcb_write_line m_out_txd_cb;
|
devcb_write_line m_out_txd_cb;
|
||||||
@ -493,19 +494,19 @@ public:
|
|||||||
// interrupt acknowledge
|
// interrupt acknowledge
|
||||||
int m1_r();
|
int m1_r();
|
||||||
|
|
||||||
DECLARE_WRITE_LINE_MEMBER( ctsa_w ) { cts_w(0, state); }
|
DECLARE_WRITE_LINE_MEMBER( ctsa_w ) { m_chanA->cts_w(state); }
|
||||||
DECLARE_WRITE_LINE_MEMBER( ctsb_w ) { cts_w(1, state); }
|
DECLARE_WRITE_LINE_MEMBER( ctsb_w ) { m_chanB->cts_w(state); }
|
||||||
DECLARE_WRITE_LINE_MEMBER( dcda_w ) { dcd_w(0, state); }
|
DECLARE_WRITE_LINE_MEMBER( dcda_w ) { m_chanA->dcd_w(state); }
|
||||||
DECLARE_WRITE_LINE_MEMBER( dcdb_w ) { dcd_w(1, state); }
|
DECLARE_WRITE_LINE_MEMBER( dcdb_w ) { m_chanB->dcd_w(state); }
|
||||||
DECLARE_WRITE_LINE_MEMBER( ria_w ) { ri_w(0, state); }
|
DECLARE_WRITE_LINE_MEMBER( ria_w ) { m_chanA->ri_w(state); }
|
||||||
DECLARE_WRITE_LINE_MEMBER( rib_w ) { ri_w(1, state); }
|
DECLARE_WRITE_LINE_MEMBER( rib_w ) { m_chanB->ri_w(state); }
|
||||||
DECLARE_WRITE_LINE_MEMBER( rxca_w ) { rxc_w(0, state); }
|
DECLARE_WRITE_LINE_MEMBER( rxca_w ) { m_chanA->rxc_w(state); }
|
||||||
DECLARE_WRITE_LINE_MEMBER( rxcb_w ) { rxc_w(1, state); }
|
DECLARE_WRITE_LINE_MEMBER( rxcb_w ) { m_chanB->rxc_w(state); }
|
||||||
DECLARE_WRITE_LINE_MEMBER( txca_w ) { txc_w(0, state); }
|
DECLARE_WRITE_LINE_MEMBER( txca_w ) { m_chanA->txc_w(state); }
|
||||||
DECLARE_WRITE_LINE_MEMBER( txcb_w ) { txc_w(1, state); }
|
DECLARE_WRITE_LINE_MEMBER( txcb_w ) { m_chanB->txc_w(state); }
|
||||||
DECLARE_WRITE_LINE_MEMBER( rxtxcb_w ) { rxc_w(1, state); txc_w(1, state); }
|
DECLARE_WRITE_LINE_MEMBER( rxtxcb_w ) { m_chanB->rxc_w(state); m_chanB->txc_w(state); }
|
||||||
DECLARE_WRITE_LINE_MEMBER( synca_w ) { sync_w(0, state); }
|
DECLARE_WRITE_LINE_MEMBER( synca_w ) { m_chanA->sync_w(state); }
|
||||||
DECLARE_WRITE_LINE_MEMBER( syncb_w ) { sync_w(1, state); }
|
DECLARE_WRITE_LINE_MEMBER( syncb_w ) { m_chanB->sync_w(state); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// device-level overrides
|
// device-level overrides
|
||||||
@ -523,7 +524,6 @@ protected:
|
|||||||
void check_interrupts();
|
void check_interrupts();
|
||||||
void reset_interrupts();
|
void reset_interrupts();
|
||||||
void trigger_interrupt(int index, int state);
|
void trigger_interrupt(int index, int state);
|
||||||
z80dart_channel *get_channel(int chan) { return chan == 0 ? m_chanA : m_chanB; }
|
|
||||||
int get_channel_index(z80dart_channel *ch) { return (ch == m_chanA) ? 0 : 1; }
|
int get_channel_index(z80dart_channel *ch) { return (ch == m_chanA) ? 0 : 1; }
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -544,22 +544,6 @@ protected:
|
|||||||
CHANNEL_B
|
CHANNEL_B
|
||||||
};
|
};
|
||||||
|
|
||||||
// control register access
|
|
||||||
UINT8 control_read(int which) { return get_channel(which)->control_read(); }
|
|
||||||
void control_write(int which, UINT8 data) { return get_channel(which)->control_write(data); }
|
|
||||||
|
|
||||||
// data register access
|
|
||||||
UINT8 data_read(int which) { return get_channel(which)->data_read(); }
|
|
||||||
void data_write(int which, UINT8 data) { return get_channel(which)->data_write(data); }
|
|
||||||
|
|
||||||
// control line access
|
|
||||||
void cts_w(int which, int state) { get_channel(which)->cts_w(state); }
|
|
||||||
void dcd_w(int which, int state) { get_channel(which)->dcd_w(state); }
|
|
||||||
void ri_w(int which, int state) { get_channel(which)->ri_w(state); }
|
|
||||||
void rxc_w(int which, int state) { get_channel(which)->rxc_w(state); }
|
|
||||||
void txc_w(int which, int state) { get_channel(which)->txc_w(state); }
|
|
||||||
void sync_w(int which, int state) { get_channel(which)->sync_w(state); }
|
|
||||||
|
|
||||||
required_device<z80dart_channel> m_chanA;
|
required_device<z80dart_channel> m_chanA;
|
||||||
required_device<z80dart_channel> m_chanB;
|
required_device<z80dart_channel> m_chanB;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user