diff --git a/src/emu/cpu/tms7000/tms7000.c b/src/emu/cpu/tms7000/tms7000.c index 8f5d1f53673..9554411d34f 100644 --- a/src/emu/cpu/tms7000/tms7000.c +++ b/src/emu/cpu/tms7000/tms7000.c @@ -55,6 +55,12 @@ const device_type TMS70C00 = &device_creator; const device_type TMS70C20 = &device_creator; const device_type TMS70C40 = &device_creator; +static ADDRESS_MAP_START(tms7000_io, AS_IO, 8, tms7000_device) + ADDRESS_MAP_UNMAP_HIGH + AM_RANGE(TMS7000_PORTA, TMS7000_PORTA) AM_WRITENOP + 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(0x0100, 0x010f) AM_READWRITE(tms70x0_pf_r, tms70x0_pf_w) /* tms7000 internal I/O ports */ @@ -72,28 +78,18 @@ ADDRESS_MAP_END tms7000_device::tms7000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : cpu_device(mconfig, TMS7000, "TMS7000", tag, owner, clock, "tms7000", __FILE__), - m_program_config("program", ENDIANNESS_BIG, 8, 16, 0, ADDRESS_MAP_NAME(tms7000_mem)), - m_opcode(s_opfn), - m_inportsa(*this), - m_inportsc(*this), - m_inportsd(*this), - m_outportsb(*this), - m_outportsc(*this), - m_outportsd(*this) + : cpu_device(mconfig, TMS7000, "TMS7000", tag, owner, clock, "tms7000", __FILE__) + , m_program_config("program", ENDIANNESS_BIG, 8, 16, 0, ADDRESS_MAP_NAME(tms7000_mem)) + , m_io_config("io", ENDIANNESS_BIG, 8, 8, 0, ADDRESS_MAP_NAME(tms7000_io)) + , m_opcode(s_opfn) { } tms7000_device::tms7000_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, address_map_constructor internal, const opcode_func *opcode, const char *shortname, const char *source) - : cpu_device(mconfig, type, name, tag, owner, clock, shortname, source), - m_program_config("program", ENDIANNESS_BIG, 8, 16, 0, internal), - m_opcode(opcode), - m_inportsa(*this), - m_inportsc(*this), - m_inportsd(*this), - m_outportsb(*this), - m_outportsc(*this), - m_outportsd(*this) + : cpu_device(mconfig, type, name, tag, owner, clock, shortname, source) + , 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_opcode(opcode) { } @@ -195,15 +191,7 @@ void tms7000_device::device_start() { m_program = &space(AS_PROGRAM); m_direct = &m_program->direct(); - - // resolve callbacks - m_inportsa.resolve_safe(0xff); - m_inportsc.resolve_safe(0xff); - m_inportsd.resolve_safe(0xff); - - m_outportsb.resolve_safe(); - m_outportsc.resolve_safe(); - m_outportsd.resolve_safe(); + m_io = &space(AS_IO); memset(m_pf, 0, 0x100); m_cycles_per_INT2 = 0; @@ -492,19 +480,19 @@ WRITE8_MEMBER( tms7000_device::tms70x0_pf_w ) /* Perpherial file write */ break; case 0x06: /* Port B write */ - m_outportsb(data); + m_io->write_byte( TMS7000_PORTB, data ); m_pf[ 0x06 ] = data; break; case 0x08: /* Port C write */ temp1 = data & m_pf[ 0x09 ]; /* Mask off input bits */ - m_outportsc(temp1); + m_io->write_byte( TMS7000_PORTC, temp1 ); m_pf[ 0x08 ] = temp1; break; case 0x0a: /* Port D write */ temp1 = data & m_pf[ 0x0b ]; /* Mask off input bits */ - m_outportsd(temp1); + m_io->write_byte( TMS7000_PORTD, temp1 ); m_pf[ 0x0a ] = temp1; break; @@ -539,7 +527,7 @@ READ8_MEMBER( tms7000_device::tms70x0_pf_r ) /* Perpherial file read */ break; case 0x04: /* Port A read */ - result = m_inportsa(); + result = m_io->read_byte( TMS7000_PORTA ); break; @@ -550,14 +538,14 @@ READ8_MEMBER( tms7000_device::tms70x0_pf_r ) /* Perpherial file read */ case 0x08: /* Port C read */ temp1 = m_pf[ 0x08 ] & m_pf[ 0x09 ]; /* Get previous output bits */ - temp2 = m_inportsc(); /* Read port */ + temp2 = m_io->read_byte( TMS7000_PORTC ); /* Read port */ temp3 = temp2 & (~m_pf[ 0x09 ]); /* Mask off output bits */ result = temp1 | temp3; /* OR together */ break; case 0x0a: /* Port D read */ temp1 = m_pf[ 0x0a ] & m_pf[ 0x0b ]; /* Get previous output bits */ - temp2 = m_inportsd(); /* Read port */ + temp2 = m_io->read_byte( TMS7000_PORTD ); /* Read port */ temp3 = temp2 & (~m_pf[ 0x0b ]); /* Mask off output bits */ result = temp1 | temp3; /* OR together */ break; diff --git a/src/emu/cpu/tms7000/tms7000.h b/src/emu/cpu/tms7000/tms7000.h index ecaf08a47ee..8f7ce382b1d 100644 --- a/src/emu/cpu/tms7000/tms7000.h +++ b/src/emu/cpu/tms7000/tms7000.h @@ -24,6 +24,7 @@ #include "emu.h" + enum { TMS7000_PC=1, TMS7000_SP, TMS7000_ST, TMS7000_IDLE, TMS7000_T1_CL, TMS7000_T1_PS, TMS7000_T1_DEC }; enum @@ -34,37 +35,14 @@ enum TMS7000_IRQNONE = 255 }; +enum +{ + TMS7000_PORTA = 0, /* read-only */ + TMS7000_PORTB, /* write-only */ + TMS7000_PORTC, + TMS7000_PORTD +}; -/*************************************************************************** - DEVICE CONFIGURATION MACROS -***************************************************************************/ - -// I/O callbacks - -// (port A is read-only) -#define MCFG_TMS7000_PORTA_READ_CB(_devcb) \ - devcb = &tms7000_device::set_inportsa_cb(*device, DEVCB_##_devcb); - -#define MCFG_TMS7000_PORTC_READ_CB(_devcb) \ - devcb = &tms7000_device::set_inportsc_cb(*device, DEVCB_##_devcb); - -#define MCFG_TMS7000_PORTD_READ_CB(_devcb) \ - devcb = &tms7000_device::set_inportsd_cb(*device, DEVCB_##_devcb); - -// (port B is write-only) -#define MCFG_TMS7000_PORTB_WRITE_CB(_devcb) \ - devcb = &tms7000_device::set_outportsb_cb(*device, DEVCB_##_devcb); - -#define MCFG_TMS7000_PORTC_WRITE_CB(_devcb) \ - devcb = &tms7000_device::set_outportsc_cb(*device, DEVCB_##_devcb); - -#define MCFG_TMS7000_PORTD_WRITE_CB(_devcb) \ - devcb = &tms7000_device::set_outportsd_cb(*device, DEVCB_##_devcb); - - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ class tms7000_device : public cpu_device { @@ -77,15 +55,6 @@ public: tms7000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); tms7000_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, address_map_constructor internal, const opcode_func *opcode, const char *shortname, const char *source); - // static configuration helpers - template static devcb_base & set_inportsa_cb(device_t &device, _Object object) { return downcast(device).m_inportsa.set_callback(object); } - template static devcb_base & set_inportsc_cb(device_t &device, _Object object) { return downcast(device).m_inportsc.set_callback(object); } - template static devcb_base & set_inportsd_cb(device_t &device, _Object object) { return downcast(device).m_inportsd.set_callback(object); } - - template static devcb_base & set_outportsb_cb(device_t &device, _Object object) { return downcast(device).m_outportsb.set_callback(object); } - template static devcb_base & set_outportsc_cb(device_t &device, _Object object) { return downcast(device).m_outportsc.set_callback(object); } - template static devcb_base & set_outportsd_cb(device_t &device, _Object object) { return downcast(device).m_outportsd.set_callback(object); } - DECLARE_WRITE8_MEMBER( tms70x0_pf_w ); DECLARE_READ8_MEMBER( tms70x0_pf_r ); @@ -102,7 +71,7 @@ protected: virtual void execute_set_input(int inputnum, int state); // device_memory_interface overrides - virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == AS_PROGRAM) ? &m_program_config : NULL; } + virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == AS_PROGRAM) ? &m_program_config : ( (spacenum == AS_IO) ? &m_io_config : NULL ); } // device_state_interface overrides void state_string_export(const device_state_entry &entry, astring &string); @@ -114,6 +83,7 @@ protected: private: address_space_config m_program_config; + address_space_config m_io_config; const opcode_func *m_opcode; @@ -136,17 +106,7 @@ private: address_space *m_program; direct_read_data *m_direct; - - // callbacks - devcb_read8 m_inportsa; - devcb_read8 m_inportsc; - devcb_read8 m_inportsd; - - devcb_write8 m_outportsb; - devcb_write8 m_outportsc; - devcb_write8 m_outportsd; - - ///////////////////////////////////////////////////////// + address_space *m_io; inline UINT16 RM16( UINT32 mAddr ); inline UINT16 RRF16( UINT32 mAddr ); diff --git a/src/mess/drivers/exelv.c b/src/mess/drivers/exelv.c index c8441068b8d..b1b3b43318b 100644 --- a/src/mess/drivers/exelv.c +++ b/src/mess/drivers/exelv.c @@ -429,11 +429,23 @@ 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_map, AS_PROGRAM, 8, exelv_state) AM_RANGE(0x0080, 0x00ff) AM_RAM 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 @@ -500,18 +512,12 @@ static MACHINE_CONFIG_START( exl100, exelv_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", TMS7020_EXL, XTAL_4_9152MHz) MCFG_CPU_PROGRAM_MAP(tms7020_mem) - MCFG_TMS7000_PORTA_READ_CB(READ8(exelv_state, tms7020_porta_r)) - MCFG_TMS7000_PORTB_WRITE_CB(WRITE8(exelv_state, tms7020_portb_w)) + MCFG_CPU_IO_MAP(tms7020_port) MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", exelv_state, exelv_hblank_interrupt, "screen", 0, 1) MCFG_CPU_ADD("tms7041", TMS7040, XTAL_4_9152MHz) // should be TMS7041 MCFG_CPU_PROGRAM_MAP(tms7041_map) - MCFG_TMS7000_PORTA_READ_CB(READ8(exelv_state, tms7041_porta_r)) - MCFG_TMS7000_PORTB_WRITE_CB(WRITE8(exelv_state, tms7041_portb_w)) - MCFG_TMS7000_PORTC_READ_CB(READ8(exelv_state, tms7041_portc_r)) - MCFG_TMS7000_PORTC_WRITE_CB(WRITE8(exelv_state, tms7041_portc_w)) - MCFG_TMS7000_PORTD_READ_CB(READ8(exelv_state, tms7041_portd_r)) - MCFG_TMS7000_PORTD_WRITE_CB(WRITE8(exelv_state, tms7041_portd_w)) + MCFG_CPU_IO_MAP(tms7041_port) MCFG_QUANTUM_PERFECT_CPU("maincpu") @@ -558,18 +564,12 @@ static MACHINE_CONFIG_START( exeltel, exelv_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", TMS7040, XTAL_4_9152MHz) MCFG_CPU_PROGRAM_MAP(tms7040_mem) - MCFG_TMS7000_PORTA_READ_CB(READ8(exelv_state, tms7020_porta_r)) - MCFG_TMS7000_PORTB_WRITE_CB(WRITE8(exelv_state, tms7020_portb_w)) + MCFG_CPU_IO_MAP(tms7020_port) MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", exelv_state, exelv_hblank_interrupt, "screen", 0, 1) MCFG_CPU_ADD("tms7042", TMS7040, XTAL_4_9152MHz) // should be TMS7042 MCFG_CPU_PROGRAM_MAP(tms7042_map) - MCFG_TMS7000_PORTA_READ_CB(READ8(exelv_state, tms7041_porta_r)) - MCFG_TMS7000_PORTB_WRITE_CB(WRITE8(exelv_state, tms7041_portb_w)) - MCFG_TMS7000_PORTC_READ_CB(READ8(exelv_state, tms7041_portc_r)) - MCFG_TMS7000_PORTC_WRITE_CB(WRITE8(exelv_state, tms7041_portc_w)) - MCFG_TMS7000_PORTD_READ_CB(READ8(exelv_state, tms7041_portd_r)) - MCFG_TMS7000_PORTD_WRITE_CB(WRITE8(exelv_state, tms7041_portd_w)) + MCFG_CPU_IO_MAP(tms7041_port) MCFG_QUANTUM_PERFECT_CPU("maincpu")