summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2017-10-30 10:32:23 -0400
committer AJR <ajrhacker@users.noreply.github.com>2017-10-30 10:32:23 -0400
commitb26df88d8354932518b39e0ad4e21634bb1888eb (patch)
treecf3ae471670d482acd78476d8f3c66e4c7493a9a
parent0ddfd95a5a050648f1662ef2ef5d4eead2a0d564 (diff)
tms7000: Convert I/O ports to callbacks (nw)
-rw-r--r--src/devices/bus/coco/coco_ssc.cpp14
-rw-r--r--src/devices/cpu/tms7000/tms7000.cpp26
-rw-r--r--src/devices/cpu/tms7000/tms7000.h51
-rw-r--r--src/mame/drivers/cc40.cpp8
-rw-r--r--src/mame/drivers/exelv.cpp34
-rw-r--r--src/mame/drivers/m24.cpp8
-rw-r--r--src/mame/drivers/ti74.cpp14
7 files changed, 86 insertions, 69 deletions
diff --git a/src/devices/bus/coco/coco_ssc.cpp b/src/devices/bus/coco/coco_ssc.cpp
index 61ae0470540..1eccdd45c03 100644
--- a/src/devices/bus/coco/coco_ssc.cpp
+++ b/src/devices/bus/coco/coco_ssc.cpp
@@ -150,16 +150,14 @@ DEFINE_DEVICE_TYPE(COCOSSC_SAC, cocossc_sac_device, "cocossc_sac", "CoCo SSC Sou
// MACHINE FRAGMENTS AND ADDRESS MAPS
//**************************************************************************
-static ADDRESS_MAP_START(ssc_io_map, AS_IO, 8, coco_ssc_device)
- AM_RANGE(TMS7000_PORTA, TMS7000_PORTA) AM_READ(ssc_port_a_r)
- AM_RANGE(TMS7000_PORTB, TMS7000_PORTB) AM_WRITE(ssc_port_b_w)
- AM_RANGE(TMS7000_PORTC, TMS7000_PORTC) AM_READWRITE(ssc_port_c_r, ssc_port_c_w)
- AM_RANGE(TMS7000_PORTD, TMS7000_PORTD) AM_READWRITE(ssc_port_d_r, ssc_port_d_w)
-ADDRESS_MAP_END
-
MACHINE_CONFIG_MEMBER(coco_ssc_device::device_add_mconfig)
MCFG_CPU_ADD(PIC_TAG, TMS7040, DERIVED_CLOCK(1, 2))
- MCFG_CPU_IO_MAP(ssc_io_map)
+ MCFG_TMS7000_IN_PORTA_CB(READ8(coco_ssc_device, ssc_port_a_r))
+ MCFG_TMS7000_OUT_PORTB_CB(WRITE8(coco_ssc_device, ssc_port_b_w))
+ MCFG_TMS7000_IN_PORTC_CB(READ8(coco_ssc_device, ssc_port_c_r))
+ MCFG_TMS7000_OUT_PORTC_CB(WRITE8(coco_ssc_device, ssc_port_c_w))
+ MCFG_TMS7000_IN_PORTD_CB(READ8(coco_ssc_device, ssc_port_d_r))
+ MCFG_TMS7000_OUT_PORTD_CB(WRITE8(coco_ssc_device, ssc_port_d_w))
MCFG_RAM_ADD("staticram")
MCFG_RAM_DEFAULT_SIZE("2K")
diff --git a/src/devices/cpu/tms7000/tms7000.cpp b/src/devices/cpu/tms7000/tms7000.cpp
index a54bac9e20f..ff3ba23bcf1 100644
--- a/src/devices/cpu/tms7000/tms7000.cpp
+++ b/src/devices/cpu/tms7000/tms7000.cpp
@@ -51,10 +51,6 @@ DEFINE_DEVICE_TYPE(TMS70C46, tms70c46_device, "tms70c46", "TMC70C46")
// internal memory maps
-static ADDRESS_MAP_START(tms7000_io, AS_IO, 8, tms7000_device)
- AM_RANGE(TMS7000_PORTB, TMS7000_PORTB) AM_READNOP
-ADDRESS_MAP_END
-
static ADDRESS_MAP_START(tms7000_mem, AS_PROGRAM, 8, tms7000_device )
AM_RANGE(0x0000, 0x007f) AM_RAM // 128 bytes internal RAM
AM_RANGE(0x0080, 0x00ff) AM_READWRITE(tms7000_unmapped_rf_r, tms7000_unmapped_rf_w)
@@ -114,7 +110,8 @@ tms7000_device::tms7000_device(const machine_config &mconfig, const char *tag, d
tms7000_device::tms7000_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal, uint32_t info_flags)
: cpu_device(mconfig, type, tag, owner, clock),
m_program_config("program", ENDIANNESS_BIG, 8, 16, 0, internal),
- m_io_config("io", ENDIANNESS_BIG, 8, 8, 0, ADDRESS_MAP_NAME(tms7000_io)),
+ m_port_in_cb{{*this}, {*this}, {*this}, {*this}, {*this}},
+ m_port_out_cb{{*this}, {*this}, {*this}, {*this}, {*this}},
m_info_flags(info_flags)
{
}
@@ -177,8 +174,7 @@ tms70c46_device::tms70c46_device(const machine_config &mconfig, const char *tag,
device_memory_interface::space_config_vector tms7000_device::memory_space_config() const
{
return space_config_vector {
- std::make_pair(AS_PROGRAM, &m_program_config),
- std::make_pair(AS_IO, &m_io_config)
+ std::make_pair(AS_PROGRAM, &m_program_config)
};
}
@@ -192,13 +188,17 @@ void tms7000_device::device_start()
// init/zerofill
m_program = &space(AS_PROGRAM);
m_direct = &m_program->direct();
- m_io = &space(AS_IO);
m_icountptr = &m_icount;
m_irq_state[TMS7000_INT1_LINE] = false;
m_irq_state[TMS7000_INT3_LINE] = false;
+ for (auto &cb : m_port_in_cb)
+ cb.resolve_safe(0xff);
+ for (auto &cb : m_port_out_cb)
+ cb.resolve_safe();
+
m_idle_state = false;
m_idle_halt = false;
m_pc = 0;
@@ -512,7 +512,7 @@ READ8_MEMBER(tms7000_device::tms7000_pf_r)
// note: port B is write-only, reading it returns the output value as if ddr is 0xff
int port = offset / 2 - 2;
if (!machine().side_effect_disabled())
- return (m_io->read_byte(port) & ~m_port_ddr[port]) | (m_port_latch[port] & m_port_ddr[port]);
+ return (m_port_in_cb[port]() & ~m_port_ddr[port]) | (m_port_latch[port] & m_port_ddr[port]);
break;
}
@@ -594,7 +594,7 @@ WRITE8_MEMBER(tms7000_device::tms7000_pf_w)
// note: in memory expansion modes, some port output pins are used for memory strobes.
// this is currently ignored, since port writes will always be visible externally on peripheral expansion anyway.
int port = offset / 2 - 2;
- m_io->write_byte(port, data & m_port_ddr[port]);
+ m_port_out_cb[port](data & m_port_ddr[port]);
m_port_latch[port] = data;
break;
}
@@ -888,7 +888,9 @@ void tms70c46_device::device_start()
void tms70c46_device::device_reset()
{
m_control = 0;
- m_io->write_byte(TMS7000_PORTE, 0xff);
+
+ // reset port E
+ m_port_out_cb[4](0xff);
tms7000_device::device_reset();
}
@@ -902,7 +904,7 @@ WRITE8_MEMBER(tms70c46_device::control_w)
{
// d5: enable external databus
if (~m_control & data & 0x20)
- m_io->write_byte(TMS7000_PORTE, 0xff); // go into high impedance
+ m_port_out_cb[4](0xff); // put port E into high impedance
// d4: enable clock divider when accessing slow memory (not emulated)
// known fast memory areas: internal ROM/RAM, system RAM
diff --git a/src/devices/cpu/tms7000/tms7000.h b/src/devices/cpu/tms7000/tms7000.h
index ef69bdb881e..d15bc779518 100644
--- a/src/devices/cpu/tms7000/tms7000.h
+++ b/src/devices/cpu/tms7000/tms7000.h
@@ -14,6 +14,33 @@
#include "debugger.h"
+// read-only on 70x0
+#define MCFG_TMS7000_IN_PORTA_CB(_devcb) \
+ devcb = &tms7000_device::set_port_read_cb(*device, 0, DEVCB_##_devcb);
+#define MCFG_TMS7000_OUT_PORTA_CB(_devcb) \
+ devcb = &tms7000_device::set_port_write_cb(*device, 0, DEVCB_##_devcb);
+
+// write-only
+#define MCFG_TMS7000_OUT_PORTB_CB(_devcb) \
+ devcb = &tms7000_device::set_port_write_cb(*device, 1, DEVCB_##_devcb);
+
+#define MCFG_TMS7000_IN_PORTC_CB(_devcb) \
+ devcb = &tms7000_device::set_port_read_cb(*device, 2, DEVCB_##_devcb);
+#define MCFG_TMS7000_OUT_PORTC_CB(_devcb) \
+ devcb = &tms7000_device::set_port_write_cb(*device, 2, DEVCB_##_devcb);
+
+#define MCFG_TMS7000_IN_PORTD_CB(_devcb) \
+ devcb = &tms7000_device::set_port_read_cb(*device, 3, DEVCB_##_devcb);
+#define MCFG_TMS7000_OUT_PORTD_CB(_devcb) \
+ devcb = &tms7000_device::set_port_write_cb(*device, 3, DEVCB_##_devcb);
+
+// TMS70C46 only
+#define MCFG_TMS7000_IN_PORTE_CB(_devcb) \
+ devcb = &tms7000_device::set_port_read_cb(*device, 4, DEVCB_##_devcb);
+#define MCFG_TMS7000_OUT_PORTE_CB(_devcb) \
+ devcb = &tms7000_device::set_port_write_cb(*device, 4, DEVCB_##_devcb);
+
+
enum { TMS7000_PC=1, TMS7000_SP, TMS7000_ST };
enum
@@ -23,15 +50,6 @@ enum
TMS7000_INT3_LINE
};
-enum
-{
- TMS7000_PORTA = 0, /* read-only on 70x0 */
- TMS7000_PORTB, /* write-only */
- TMS7000_PORTC,
- TMS7000_PORTD,
- TMS7000_PORTE /* TMS70C46 only */
-};
-
class tms7000_device : public cpu_device
{
@@ -39,6 +57,12 @@ public:
// construction/destruction
tms7000_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ // static configuration
+ template<class Object>
+ static devcb_base &set_port_read_cb(device_t &device, int p, Object &&object) { return downcast<tms7000_device &>(device).m_port_in_cb[p].set_callback(std::move(object)); }
+ template<class Object>
+ static devcb_base &set_port_write_cb(device_t &device, int p, Object &&object) { return downcast<tms7000_device &>(device).m_port_out_cb[p].set_callback(std::move(object)); }
+
DECLARE_READ8_MEMBER(tms7000_unmapped_rf_r) { if (!machine().side_effect_disabled()) logerror("'%s' (%04X): unmapped_rf_r @ $%04x\n", tag(), m_pc, offset + 0x80); return 0; };
DECLARE_WRITE8_MEMBER(tms7000_unmapped_rf_w) { logerror("'%s' (%04X): unmapped_rf_w @ $%04x = $%02x\n", tag(), m_pc, offset + 0x80, data); };
@@ -91,13 +115,14 @@ protected:
virtual void execute_one(uint8_t op);
address_space_config m_program_config;
- address_space_config m_io_config;
+
+ devcb_read8 m_port_in_cb[5];
+ devcb_write8 m_port_out_cb[5];
uint32_t m_info_flags;
address_space *m_program;
direct_read_data *m_direct;
- address_space *m_io;
int m_icount;
bool m_irq_state[2];
@@ -319,8 +344,8 @@ public:
DECLARE_WRITE8_MEMBER(dockbus_data_w);
// access I/O port E if databus is disabled
- DECLARE_READ8_MEMBER(e_bus_data_r) { return machine().side_effect_disabled() ? 0xff : ((m_control & 0x20) ? 0xff : m_io->read_byte(TMS7000_PORTE)); }
- DECLARE_WRITE8_MEMBER(e_bus_data_w) { if (~m_control & 0x20) m_io->write_byte(TMS7000_PORTE, data); }
+ DECLARE_READ8_MEMBER(e_bus_data_r) { return machine().side_effect_disabled() ? 0xff : ((m_control & 0x20) ? 0xff : m_port_in_cb[4]()); }
+ DECLARE_WRITE8_MEMBER(e_bus_data_w) { if (~m_control & 0x20) m_port_out_cb[4](data); }
protected:
// device-level overrides
diff --git a/src/mame/drivers/cc40.cpp b/src/mame/drivers/cc40.cpp
index bd4aa8d35cc..562f7f0cb9d 100644
--- a/src/mame/drivers/cc40.cpp
+++ b/src/mame/drivers/cc40.cpp
@@ -381,11 +381,6 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, cc40_state )
AM_RANGE(0xd000, 0xefff) AM_ROMBANK("sysbank")
ADDRESS_MAP_END
-static ADDRESS_MAP_START( main_io_map, AS_IO, 8, cc40_state )
- AM_RANGE(TMS7000_PORTA, TMS7000_PORTA) AM_READ(keyboard_r)
- AM_RANGE(TMS7000_PORTB, TMS7000_PORTB) AM_WRITE(keyboard_w)
-ADDRESS_MAP_END
-
/***************************************************************************
@@ -584,7 +579,8 @@ static MACHINE_CONFIG_START( cc40 )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", TMS70C20, XTAL_5MHz / 2)
MCFG_CPU_PROGRAM_MAP(main_map)
- MCFG_CPU_IO_MAP(main_io_map)
+ MCFG_TMS7000_IN_PORTA_CB(READ8(cc40_state, keyboard_r))
+ MCFG_TMS7000_OUT_PORTB_CB(WRITE8(cc40_state, keyboard_w))
MCFG_NVRAM_ADD_0FILL("sysram.0")
MCFG_NVRAM_ADD_0FILL("sysram.1")
diff --git a/src/mame/drivers/exelv.cpp b/src/mame/drivers/exelv.cpp
index c93e804d625..46ea2c588aa 100644
--- a/src/mame/drivers/exelv.cpp
+++ b/src/mame/drivers/exelv.cpp
@@ -420,18 +420,6 @@ static ADDRESS_MAP_START(tms7020_mem, AS_PROGRAM, 8, exelv_state)
AM_RANGE(0xc800, 0xf7ff) AM_NOP
ADDRESS_MAP_END
-static ADDRESS_MAP_START(tms7020_port, AS_IO, 8, exelv_state)
- AM_RANGE(TMS7000_PORTA, TMS7000_PORTA) AM_READ(tms7020_porta_r)
- AM_RANGE(TMS7000_PORTB, TMS7000_PORTB) AM_WRITE(tms7020_portb_w)
-ADDRESS_MAP_END
-
-static ADDRESS_MAP_START(tms7041_port, AS_IO, 8, exelv_state)
- AM_RANGE(TMS7000_PORTA, TMS7000_PORTA) AM_READ(tms7041_porta_r)
- AM_RANGE(TMS7000_PORTB, TMS7000_PORTB) AM_WRITE(tms7041_portb_w)
- AM_RANGE(TMS7000_PORTC, TMS7000_PORTC) AM_READWRITE(tms7041_portc_r, tms7041_portc_w)
- AM_RANGE(TMS7000_PORTD, TMS7000_PORTD) AM_READWRITE(tms7041_portd_r, tms7041_portd_w)
-ADDRESS_MAP_END
-
static ADDRESS_MAP_START(tms7040_mem, AS_PROGRAM, 8, exelv_state)
AM_RANGE(0x0080, 0x00ff) AM_NOP
@@ -490,12 +478,19 @@ static MACHINE_CONFIG_START( exl100 )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", TMS7020_EXL, XTAL_4_9152MHz)
MCFG_CPU_PROGRAM_MAP(tms7020_mem)
- MCFG_CPU_IO_MAP(tms7020_port)
+ MCFG_TMS7000_IN_PORTA_CB(READ8(exelv_state, tms7020_porta_r))
+ MCFG_TMS7000_OUT_PORTB_CB(WRITE8(exelv_state, tms7020_portb_w))
+
MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", exelv_state, exelv_hblank_interrupt, "screen", 0, 1)
MCFG_MACHINE_START_OVERRIDE(exelv_state, exl100)
MCFG_CPU_ADD("tms7041", TMS7041, XTAL_4_9152MHz)
- MCFG_CPU_IO_MAP(tms7041_port)
+ MCFG_TMS7000_IN_PORTA_CB(READ8(exelv_state, tms7041_porta_r))
+ MCFG_TMS7000_OUT_PORTB_CB(WRITE8(exelv_state, tms7041_portb_w))
+ MCFG_TMS7000_IN_PORTC_CB(READ8(exelv_state, tms7041_portc_r))
+ MCFG_TMS7000_OUT_PORTC_CB(WRITE8(exelv_state, tms7041_portc_w))
+ MCFG_TMS7000_IN_PORTD_CB(READ8(exelv_state, tms7041_portd_r))
+ MCFG_TMS7000_OUT_PORTD_CB(WRITE8(exelv_state, tms7041_portd_w))
MCFG_QUANTUM_PERFECT_CPU("maincpu")
@@ -539,12 +534,19 @@ static MACHINE_CONFIG_START( exeltel )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", TMS7040, XTAL_4_9152MHz)
MCFG_CPU_PROGRAM_MAP(tms7040_mem)
- MCFG_CPU_IO_MAP(tms7020_port)
+ MCFG_TMS7000_IN_PORTA_CB(READ8(exelv_state, tms7020_porta_r))
+ MCFG_TMS7000_OUT_PORTB_CB(WRITE8(exelv_state, tms7020_portb_w))
+
MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", exelv_state, exelv_hblank_interrupt, "screen", 0, 1)
MCFG_MACHINE_START_OVERRIDE(exelv_state, exeltel)
MCFG_CPU_ADD("tms7042", TMS7042, XTAL_4_9152MHz)
- MCFG_CPU_IO_MAP(tms7041_port)
+ MCFG_TMS7000_IN_PORTA_CB(READ8(exelv_state, tms7041_porta_r))
+ MCFG_TMS7000_OUT_PORTB_CB(WRITE8(exelv_state, tms7041_portb_w))
+ MCFG_TMS7000_IN_PORTC_CB(READ8(exelv_state, tms7041_portc_r))
+ MCFG_TMS7000_OUT_PORTC_CB(WRITE8(exelv_state, tms7041_portc_w))
+ MCFG_TMS7000_IN_PORTD_CB(READ8(exelv_state, tms7041_portd_r))
+ MCFG_TMS7000_OUT_PORTD_CB(WRITE8(exelv_state, tms7041_portd_w))
MCFG_QUANTUM_PERFECT_CPU("maincpu")
diff --git a/src/mame/drivers/m24.cpp b/src/mame/drivers/m24.cpp
index 52191dcd293..dd534c3d852 100644
--- a/src/mame/drivers/m24.cpp
+++ b/src/mame/drivers/m24.cpp
@@ -190,11 +190,6 @@ static ADDRESS_MAP_START(kbc_map, AS_PROGRAM, 8, m24_state)
AM_RANGE(0xf800, 0xffff) AM_ROM AM_REGION("kbc", 0)
ADDRESS_MAP_END
-static ADDRESS_MAP_START(kbc_io, AS_IO, 8, m24_state)
- AM_RANGE(TMS7000_PORTA, TMS7000_PORTA) AM_READ(pa_r)
- AM_RANGE(TMS7000_PORTB, TMS7000_PORTB) AM_WRITE(pb_w)
-ADDRESS_MAP_END
-
static INPUT_PORTS_START( m24 )
PORT_START("DSW0")
PORT_DIPNAME( 0x8f, 0x89, "RAM banks")
@@ -277,7 +272,8 @@ static MACHINE_CONFIG_START( olivetti )
MCFG_CPU_ADD("kbc", TMS7000, XTAL_4MHz)
MCFG_CPU_PROGRAM_MAP(kbc_map)
- MCFG_CPU_IO_MAP(kbc_io)
+ MCFG_TMS7000_IN_PORTA_CB(READ8(m24_state, pa_r))
+ MCFG_TMS7000_OUT_PORTB_CB(WRITE8(m24_state, pb_w))
MCFG_DEVICE_ADD("keyboard", M24_KEYBOARD, 0)
MCFG_M24_KEYBOARD_OUT_DATA_HANDLER(WRITELINE(m24_state, kbcin_w))
diff --git a/src/mame/drivers/ti74.cpp b/src/mame/drivers/ti74.cpp
index 0d8e3be42f3..180ef4d8f0a 100644
--- a/src/mame/drivers/ti74.cpp
+++ b/src/mame/drivers/ti74.cpp
@@ -271,12 +271,6 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8, ti74_state )
AM_RANGE(0xc000, 0xdfff) AM_ROMBANK("sysbank")
ADDRESS_MAP_END
-static ADDRESS_MAP_START( main_io_map, AS_IO, 8, ti74_state )
- AM_RANGE(TMS7000_PORTA, TMS7000_PORTA) AM_READ(keyboard_r)
- AM_RANGE(TMS7000_PORTB, TMS7000_PORTB) AM_WRITE(bankswitch_w)
- AM_RANGE(TMS7000_PORTE, TMS7000_PORTE) AM_WRITE(keyboard_w) AM_READNOP
-ADDRESS_MAP_END
-
/***************************************************************************
@@ -514,7 +508,9 @@ static MACHINE_CONFIG_START( ti74 )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", TMS70C46, XTAL_4MHz)
MCFG_CPU_PROGRAM_MAP(main_map)
- MCFG_CPU_IO_MAP(main_io_map)
+ MCFG_TMS7000_IN_PORTA_CB(READ8(ti74_state, keyboard_r))
+ MCFG_TMS7000_OUT_PORTB_CB(WRITE8(ti74_state, bankswitch_w))
+ MCFG_TMS7000_OUT_PORTE_CB(WRITE8(ti74_state, keyboard_w))
MCFG_NVRAM_ADD_0FILL("sysram.ic3")
@@ -548,7 +544,9 @@ static MACHINE_CONFIG_START( ti95 )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", TMS70C46, XTAL_4MHz)
MCFG_CPU_PROGRAM_MAP(main_map)
- MCFG_CPU_IO_MAP(main_io_map)
+ MCFG_TMS7000_IN_PORTA_CB(READ8(ti74_state, keyboard_r))
+ MCFG_TMS7000_OUT_PORTB_CB(WRITE8(ti74_state, bankswitch_w))
+ MCFG_TMS7000_OUT_PORTE_CB(WRITE8(ti74_state, keyboard_w))
MCFG_NVRAM_ADD_0FILL("sysram.ic3")