cdp1852: Replace callback macros with devcb3 bindings; use line write handler to clock output from TPB (nw)

comx35: Add SC and TPB handlers for the expansion bus (nw)
This commit is contained in:
AJR 2018-07-19 10:16:08 -04:00
parent 37918a690c
commit 375427dcee
7 changed files with 198 additions and 153 deletions

View File

@ -73,9 +73,7 @@ uint8_t comx_expansion_slot_device::mrd_r(address_space &space, offs_t offset, i
uint8_t data = 0;
if (m_card != nullptr)
{
data = m_card->comx_mrd_r(space, offset, extrom);
}
return data;
}
@ -88,9 +86,7 @@ uint8_t comx_expansion_slot_device::mrd_r(address_space &space, offs_t offset, i
void comx_expansion_slot_device::mwr_w(address_space &space, offs_t offset, uint8_t data)
{
if (m_card != nullptr)
{
m_card->comx_mwr_w(space, offset, data);
}
}
@ -103,9 +99,7 @@ uint8_t comx_expansion_slot_device::io_r(address_space &space, offs_t offset)
uint8_t data = 0;
if (m_card != nullptr)
{
data = m_card->comx_io_r(space, offset);
}
return data;
}
@ -118,9 +112,7 @@ uint8_t comx_expansion_slot_device::io_r(address_space &space, offs_t offset)
void comx_expansion_slot_device::io_w(address_space &space, offs_t offset, uint8_t data)
{
if (m_card != nullptr)
{
m_card->comx_io_w(space, offset, data);
}
}
@ -128,12 +120,10 @@ void comx_expansion_slot_device::io_w(address_space &space, offs_t offset, uint8
// ds_w - device select write
//-------------------------------------------------
WRITE_LINE_MEMBER( comx_expansion_slot_device::ds_w )
WRITE_LINE_MEMBER(comx_expansion_slot_device::ds_w)
{
if (m_card != nullptr)
{
m_card->comx_ds_w(state);
}
}
@ -141,27 +131,50 @@ WRITE_LINE_MEMBER( comx_expansion_slot_device::ds_w )
// q_w - Q write
//-------------------------------------------------
WRITE_LINE_MEMBER( comx_expansion_slot_device::q_w )
WRITE_LINE_MEMBER(comx_expansion_slot_device::q_w)
{
if (m_card != nullptr)
{
m_card->comx_q_w(state);
}
}
READ_LINE_MEMBER( comx_expansion_slot_device::ef4_r )
//-------------------------------------------------
// ef4_r - EF4 poll
//-------------------------------------------------
READ_LINE_MEMBER(comx_expansion_slot_device::ef4_r)
{
int state = CLEAR_LINE;
if (m_card != nullptr)
{
state = m_card->comx_ef4_r();
}
return state;
}
//-------------------------------------------------
// sc_w - state code/N0-N2 write
//-------------------------------------------------
WRITE8_MEMBER(comx_expansion_slot_device::sc_w)
{
if (m_card != nullptr)
m_card->comx_sc_w(offset, data);
}
//-------------------------------------------------
// tpb_w - TPB write
//-------------------------------------------------
WRITE_LINE_MEMBER(comx_expansion_slot_device::tpb_w)
{
if (m_card != nullptr)
m_card->comx_tpb_w(state);
}
//-------------------------------------------------
// SLOT_INTERFACE( comx_expansion_cards )
//-------------------------------------------------

View File

@ -84,12 +84,15 @@ public:
uint8_t io_r(address_space &space, offs_t offset);
void io_w(address_space &space, offs_t offset, uint8_t data);
DECLARE_READ_LINE_MEMBER( ef4_r );
DECLARE_READ_LINE_MEMBER(ef4_r);
DECLARE_WRITE_LINE_MEMBER( ds_w );
DECLARE_WRITE_LINE_MEMBER( q_w );
DECLARE_WRITE_LINE_MEMBER(ds_w);
DECLARE_WRITE_LINE_MEMBER(q_w);
DECLARE_WRITE_LINE_MEMBER( irq_w ) { m_write_irq(state); }
DECLARE_WRITE_LINE_MEMBER(irq_w) { m_write_irq(state); }
DECLARE_WRITE8_MEMBER(sc_w);
DECLARE_WRITE_LINE_MEMBER(tpb_w);
protected:
// device-level overrides
@ -116,6 +119,8 @@ protected:
virtual int comx_ef4_r() { return CLEAR_LINE; }
virtual void comx_ds_w(int state) { m_ds = state; }
virtual void comx_q_w(int state) { }
virtual void comx_sc_w(int n, int sc) { }
virtual void comx_tpb_w(int state) { }
// memory access
virtual uint8_t comx_mrd_r(address_space &space, offs_t offset, int *extrom) { return 0; }

View File

@ -39,13 +39,16 @@ enum
// cdp1852_device - constructor
//-------------------------------------------------
cdp1852_device::cdp1852_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
cdp1852_device::cdp1852_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
device_t(mconfig, CDP1852, tag, owner, clock),
m_read_mode(*this),
m_write_sr(*this),
m_read_data(*this),
m_write_data(*this),
m_new_data(0), m_data(0), m_next_data(0), m_sr(0), m_next_sr(0), m_scan_timer(nullptr)
m_new_data(false), m_data(0),
m_clock_active(true), m_sr(false), m_next_sr(false),
m_update_do_timer(nullptr),
m_update_sr_timer(nullptr)
{
}
@ -63,16 +66,13 @@ void cdp1852_device::device_start()
m_write_data.resolve_safe();
// allocate timers
if (clock() > 0)
{
m_scan_timer = timer_alloc();
m_scan_timer->adjust(attotime::zero, 0, attotime::from_hz(clock()));
}
m_update_do_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cdp1852_device::update_do), this));
m_update_sr_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(cdp1852_device::update_sr), this));
// register for state saving
save_item(NAME(m_new_data));
save_item(NAME(m_data));
save_item(NAME(m_next_data));
save_item(NAME(m_clock_active));
save_item(NAME(m_sr));
save_item(NAME(m_next_sr));
}
@ -90,7 +90,7 @@ void cdp1852_device::device_reset()
if (!m_read_mode())
{
// reset service request flip-flop
set_sr_line(1);
set_sr_line(true);
}
else
{
@ -98,45 +98,47 @@ void cdp1852_device::device_reset()
m_write_data((offs_t)0, m_data);
// reset service request flip-flop
set_sr_line(0);
set_sr_line(false);
}
}
//-------------------------------------------------
// device_timer - handler timer events
// clock_w - clock write
//-------------------------------------------------
void cdp1852_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
WRITE_LINE_MEMBER(cdp1852_device::clock_w)
{
if (!m_read_mode())
{
// input data into register
m_data = m_read_data(0);
if (m_clock_active != bool(state))
return;
// signal processor
set_sr_line(0);
}
else
m_clock_active = bool(state);
if (!state)
{
if (m_new_data)
if (!m_read_mode())
{
m_new_data = 0;
// input data into register
m_data = m_read_data(0);
// latch data into register
m_data = m_next_data;
// output data
m_write_data((offs_t)0, m_data);
// signal peripheral device
set_sr_line(1);
m_next_sr = 0;
// signal processor
set_sr_line(0);
}
else
{
set_sr_line(m_next_sr);
if (m_new_data)
{
m_new_data = false;
// signal peripheral device
set_sr_line(true);
m_next_sr = false;
}
else
{
set_sr_line(m_next_sr);
}
}
}
}
@ -146,30 +148,50 @@ void cdp1852_device::device_timer(emu_timer &timer, device_timer_id id, int para
// set_sr_line -
//-------------------------------------------------
void cdp1852_device::set_sr_line(int state)
void cdp1852_device::set_sr_line(bool state)
{
if (m_sr != state)
{
m_sr = state;
m_write_sr(m_sr);
m_update_sr_timer->adjust(attotime::zero);
}
}
//-------------------------------------------------
// update_do - update data output
//-------------------------------------------------
TIMER_CALLBACK_MEMBER(cdp1852_device::update_do)
{
m_write_data(param);
}
//-------------------------------------------------
// update_sr - update status request output
//-------------------------------------------------
TIMER_CALLBACK_MEMBER(cdp1852_device::update_sr)
{
m_write_sr(m_sr ? 1 : 0);
}
//-------------------------------------------------
// read - data read
//-------------------------------------------------
READ8_MEMBER( cdp1852_device::read )
READ8_MEMBER(cdp1852_device::read)
{
if (!m_read_mode() && !clock())
if (!m_read_mode() && m_clock_active)
{
// input data into register
m_data = m_read_data(0);
}
set_sr_line(1);
set_sr_line(true);
return m_data;
}
@ -179,11 +201,13 @@ READ8_MEMBER( cdp1852_device::read )
// write - data write
//-------------------------------------------------
WRITE8_MEMBER( cdp1852_device::write )
WRITE8_MEMBER(cdp1852_device::write)
{
if (m_read_mode())
if (m_read_mode() && m_clock_active)
{
m_next_data = data;
m_new_data = 1;
// output data
m_update_do_timer->adjust(attotime::zero, data);
m_new_data = true;
}
}

View File

@ -29,24 +29,6 @@
//**************************************************************************
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_CDP1852_MODE_CALLBACK(_read) \
downcast<cdp1852_device &>(*device).set_mode_rd_callback(DEVCB_##_read);
#define MCFG_CDP1852_SR_CALLBACK(_write) \
downcast<cdp1852_device &>(*device).set_sr_wr_callback(DEVCB_##_write);
#define MCFG_CDP1852_DI_CALLBACK(_read) \
downcast<cdp1852_device &>(*device).set_data_rd_callback(DEVCB_##_read);
#define MCFG_CDP1852_DO_CALLBACK(_write) \
downcast<cdp1852_device &>(*device).set_data_wr_callback(DEVCB_##_write);
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
@ -57,15 +39,17 @@ class cdp1852_device : public device_t
{
public:
// construction/destruction
cdp1852_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
cdp1852_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0);
template <class Object> devcb_base &set_mode_rd_callback(Object &&cb) { return m_read_mode.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_sr_wr_callback(Object &&cb) { return m_write_sr.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_data_rd_callback(Object &&cb) { return m_read_data.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_data_wr_callback(Object &&cb) { return m_write_data.set_callback(std::forward<Object>(cb)); }
auto mode_cb() { return m_read_mode.bind(); }
auto sr_cb() { return m_write_sr.bind(); }
auto di_cb() { return m_read_data.bind(); }
auto do_cb() { return m_write_data.bind(); }
DECLARE_READ8_MEMBER( read );
DECLARE_WRITE8_MEMBER( write );
DECLARE_READ8_MEMBER(read);
DECLARE_WRITE8_MEMBER(write);
DECLARE_WRITE_LINE_MEMBER(clock_w);
uint8_t do_r() { return m_data; }
@ -73,25 +57,28 @@ protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
private:
void set_sr_line(int state);
void set_sr_line(bool state);
TIMER_CALLBACK_MEMBER(update_do);
TIMER_CALLBACK_MEMBER(update_sr);
devcb_read_line m_read_mode;
devcb_write_line m_write_sr;
devcb_read8 m_read_data;
devcb_write8 m_write_data;
int m_new_data; // new data written
uint8_t m_data; // data latch
uint8_t m_next_data; // next data
bool m_new_data; // new data written
u8 m_data; // data latch
int m_sr; // service request flag
int m_next_sr; // next value of service request flag
bool m_clock_active; // input clock
bool m_sr; // service request flag
bool m_next_sr; // next value of service request flag
// timers
emu_timer *m_scan_timer;
emu_timer *m_update_do_timer;
emu_timer *m_update_sr_timer;
};

View File

@ -438,22 +438,26 @@ MACHINE_CONFIG_START(cidelsa_state::altair)
cpu.wait_cb().set_constant(1);
cpu.clear_cb().set(FUNC(cidelsa_state::clear_r));
cpu.q_cb().set(FUNC(cidelsa_state::q_w));
cpu.tpb_cb().set("ic26", FUNC(cdp1852_device::clock_w));
MCFG_NVRAM_ADD_0FILL("nvram")
/* input/output hardware */
MCFG_DEVICE_ADD("ic23", CDP1852, 0) // clock is really tied to CDP1869 CMSEL (pin 37)
MCFG_CDP1852_MODE_CALLBACK(CONSTANT(0))
MCFG_CDP1852_DI_CALLBACK(IOPORT("IN0"))
MCFG_DEVICE_ADD("ic24", CDP1852, 0)
MCFG_CDP1852_MODE_CALLBACK(CONSTANT(0))
MCFG_CDP1852_DI_CALLBACK(IOPORT("IN1"))
MCFG_DEVICE_ADD("ic25", CDP1852, 0)
MCFG_CDP1852_MODE_CALLBACK(CONSTANT(0))
MCFG_CDP1852_DI_CALLBACK(IOPORT("IN2"))
MCFG_DEVICE_ADD("ic26", CDP1852, ALTAIR_CHR1 / 8) // clock is CDP1802 TPB
MCFG_CDP1852_MODE_CALLBACK(CONSTANT(1))
MCFG_CDP1852_DO_CALLBACK(WRITE8(*this, cidelsa_state, altair_out1_w))
cdp1852_device &ic23(CDP1852(config, "ic23")); // clock is really tied to CDP1869 CMSEL (pin 37)
ic23.mode_cb().set_constant(0);
ic23.di_cb().set_ioport("IN0");
cdp1852_device &ic24(CDP1852(config, "ic24"));
ic24.mode_cb().set_constant(0);
ic24.di_cb().set_ioport("IN1");
cdp1852_device &ic25(CDP1852(config, "ic25"));
ic25.mode_cb().set_constant(0);
ic25.di_cb().set_ioport("IN2");
cdp1852_device &ic26(CDP1852(config, "ic26")); // clock is CDP1802 TPB
ic26.mode_cb().set_constant(1);
ic26.do_cb().set(FUNC(cidelsa_state::altair_out1_w));
/* sound and video hardware */
altair_video(config);
@ -467,6 +471,7 @@ MACHINE_CONFIG_START(draco_state::draco)
cpu.wait_cb().set_constant(1);
cpu.clear_cb().set(FUNC(draco_state::clear_r));
cpu.q_cb().set(FUNC(draco_state::q_w));
cpu.tpb_cb().set("ic32", FUNC(cdp1852_device::clock_w));
MCFG_NVRAM_ADD_0FILL("nvram")
@ -480,18 +485,21 @@ MACHINE_CONFIG_START(draco_state::draco)
MCFG_COP400_READ_IN_CB(READ8(*this, draco_state, sound_in_r))
/* input/output hardware */
MCFG_DEVICE_ADD("ic29", CDP1852, 0) // clock is really tied to CDP1869 CMSEL (pin 37)
MCFG_CDP1852_MODE_CALLBACK(CONSTANT(0))
MCFG_CDP1852_DI_CALLBACK(IOPORT("IN0"))
MCFG_DEVICE_ADD("ic30", CDP1852, 0)
MCFG_CDP1852_MODE_CALLBACK(CONSTANT(0))
MCFG_CDP1852_DI_CALLBACK(IOPORT("IN1"))
MCFG_DEVICE_ADD("ic31", CDP1852, 0)
MCFG_CDP1852_MODE_CALLBACK(CONSTANT(0))
MCFG_CDP1852_DI_CALLBACK(IOPORT("IN2"))
MCFG_DEVICE_ADD("ic32", CDP1852, ALTAIR_CHR1 / 8) // clock is CDP1802 TPB
MCFG_CDP1852_MODE_CALLBACK(CONSTANT(1))
MCFG_CDP1852_DO_CALLBACK(WRITE8(*this, draco_state, out1_w))
cdp1852_device &ic29(CDP1852(config, "ic29")); // clock is really tied to CDP1869 CMSEL (pin 37)
ic29.mode_cb().set_constant(0);
ic29.di_cb().set_ioport("IN0");
cdp1852_device &ic30(CDP1852(config, "ic30"));
ic30.mode_cb().set_constant(0);
ic30.di_cb().set_ioport("IN1");
cdp1852_device &ic31(CDP1852(config, "ic31"));
ic31.mode_cb().set_constant(0);
ic31.di_cb().set_ioport("IN2");
cdp1852_device &ic32(CDP1852(config, "ic32")); // clock is CDP1802 TPB
ic32.mode_cb().set_constant(1);
ic32.do_cb().set(FUNC(draco_state::out1_w));
/* sound and video hardware */
draco_video(config);

View File

@ -597,15 +597,17 @@ void comx35_state::machine_reset()
MACHINE_CONFIG_START(comx35_state::pal)
// basic system hardware
MCFG_DEVICE_ADD(CDP1802_TAG, CDP1802, cdp1869_device::CPU_CLK_PAL)
MCFG_DEVICE_PROGRAM_MAP(comx35_mem)
MCFG_DEVICE_IO_MAP(comx35_io)
MCFG_COSMAC_WAIT_CALLBACK(CONSTANT(1))
MCFG_COSMAC_CLEAR_CALLBACK(READLINE(*this, comx35_state, clear_r))
MCFG_COSMAC_EF2_CALLBACK(READLINE(*this, comx35_state, ef2_r))
MCFG_COSMAC_EF4_CALLBACK(READLINE(*this, comx35_state, ef4_r))
MCFG_COSMAC_Q_CALLBACK(WRITELINE(*this, comx35_state, q_w))
MCFG_COSMAC_SC_CALLBACK(WRITE8(*this, comx35_state, sc_w))
cdp1802_device &cpu(CDP1802(config, CDP1802_TAG, cdp1869_device::CPU_CLK_PAL));
cpu.set_addrmap(AS_PROGRAM, &comx35_state::comx35_mem);
cpu.set_addrmap(AS_IO, &comx35_state::comx35_io);
cpu.wait_cb().set_constant(1);
cpu.clear_cb().set(FUNC(comx35_state::clear_r));
cpu.ef2_cb().set(FUNC(comx35_state::ef2_r));
cpu.ef4_cb().set(FUNC(comx35_state::ef4_r));
cpu.q_cb().set(FUNC(comx35_state::q_w));
cpu.sc_cb().set(FUNC(comx35_state::sc_w));
cpu.sc_cb().append(EXPANSION_TAG, FUNC(comx_expansion_slot_device::sc_w));
cpu.tpb_cb().set(EXPANSION_TAG, FUNC(comx_expansion_slot_device::tpb_w));
// sound and video hardware
comx35_pal_video(config);
@ -647,15 +649,17 @@ MACHINE_CONFIG_END
MACHINE_CONFIG_START(comx35_state::ntsc)
// basic system hardware
MCFG_DEVICE_ADD(CDP1802_TAG, CDP1802, cdp1869_device::CPU_CLK_NTSC)
MCFG_DEVICE_PROGRAM_MAP(comx35_mem)
MCFG_DEVICE_IO_MAP(comx35_io)
MCFG_COSMAC_WAIT_CALLBACK(CONSTANT(1))
MCFG_COSMAC_CLEAR_CALLBACK(READLINE(*this, comx35_state, clear_r))
MCFG_COSMAC_EF2_CALLBACK(READLINE(*this, comx35_state, ef2_r))
MCFG_COSMAC_EF4_CALLBACK(READLINE(*this, comx35_state, ef4_r))
MCFG_COSMAC_Q_CALLBACK(WRITELINE(*this, comx35_state, q_w))
MCFG_COSMAC_SC_CALLBACK(WRITE8(*this, comx35_state, sc_w))
cdp1802_device &cpu(CDP1802(config, CDP1802_TAG, cdp1869_device::CPU_CLK_NTSC));
cpu.set_addrmap(AS_PROGRAM, &comx35_state::comx35_mem);
cpu.set_addrmap(AS_IO, &comx35_state::comx35_io);
cpu.wait_cb().set_constant(1);
cpu.clear_cb().set(FUNC(comx35_state::clear_r));
cpu.ef2_cb().set(FUNC(comx35_state::ef2_r));
cpu.ef4_cb().set(FUNC(comx35_state::ef4_r));
cpu.q_cb().set(FUNC(comx35_state::q_w));
cpu.sc_cb().set(FUNC(comx35_state::sc_w));
cpu.sc_cb().append(EXPANSION_TAG, FUNC(comx_expansion_slot_device::sc_w));
cpu.tpb_cb().set(EXPANSION_TAG, FUNC(comx_expansion_slot_device::tpb_w));
// sound and video hardware
comx35_ntsc_video(config);

View File

@ -255,30 +255,34 @@ WRITE8_MEMBER( tmc600_state::sc_w )
MACHINE_CONFIG_START(tmc600_state::tmc600)
// CPU
MCFG_DEVICE_ADD(CDP1802_TAG, CDP1802, XTAL(3'570'000))
MCFG_DEVICE_PROGRAM_MAP(tmc600_map)
MCFG_DEVICE_IO_MAP(tmc600_io_map)
MCFG_COSMAC_WAIT_CALLBACK(CONSTANT(1))
MCFG_COSMAC_EF2_CALLBACK(READLINE(*this, tmc600_state, ef2_r))
MCFG_COSMAC_EF3_CALLBACK(READLINE(*this, tmc600_state, ef3_r))
MCFG_COSMAC_Q_CALLBACK(WRITELINE(*this, tmc600_state, q_w))
MCFG_COSMAC_SC_CALLBACK(WRITE8(*this, tmc600_state, sc_w))
cdp1802_device &cpu(CDP1802(config, CDP1802_TAG, 3.57_MHz_XTAL));
cpu.set_addrmap(AS_PROGRAM, &tmc600_state::tmc600_map);
cpu.set_addrmap(AS_IO, &tmc600_state::tmc600_io_map);
cpu.wait_cb().set_constant(1);
cpu.ef2_cb().set(FUNC(tmc600_state::ef2_r));
cpu.ef3_cb().set(FUNC(tmc600_state::ef3_r));
cpu.q_cb().set(FUNC(tmc600_state::q_w));
cpu.sc_cb().set(FUNC(tmc600_state::sc_w));
cpu.tpb_cb().set(CDP1852_KB_TAG, FUNC(cdp1852_device::clock_w));
cpu.tpb_cb().append(CDP1852_TMC700_TAG, FUNC(cdp1852_device::clock_w));
// sound and video hardware
tmc600_video(config);
// keyboard output latch
MCFG_DEVICE_ADD(CDP1852_KB_TAG, CDP1852, XTAL(3'570'000)/8) // clock is CDP1802 TPB
MCFG_CDP1852_MODE_CALLBACK(CONSTANT(1))
CDP1852(config, m_bwio); // clock is CDP1802 TPB
m_bwio->mode_cb().set_constant(1);
#if 0
// address bus demux for expansion bus
MCFG_DEVICE_ADD(CDP1852_BUS_TAG, CDP1852, 0) // clock is expansion bus TPA
MCFG_CDP1852_MODE_CALLBACK(CONSTANT(0))
cdp1852_device &demux(CDP1852(config, CDP1852_BUS_TAG)); // clock is expansion bus TPA
demux.mode_cb().set_constant(0);
#endif
// printer output latch
MCFG_DEVICE_ADD(CDP1852_TMC700_TAG, CDP1852, XTAL(3'570'000)/8) // clock is CDP1802 TPB
MCFG_CDP1852_MODE_CALLBACK(CONSTANT(1))
MCFG_CDP1852_DO_CALLBACK(WRITE8(*this, tmc600_state, printer_w))
cdp1852_device &prtout(CDP1852(config, CDP1852_KB_TAG)); // clock is CDP1802 TPB
prtout.mode_cb().set_constant(1);
prtout.do_cb().set(FUNC(tmc600_state::printer_w));
// printer connector
CENTRONICS(config, m_centronics, centronics_devices, "printer");