use devcb instead of a fake memmap for tms7000 i/o ports

This commit is contained in:
Michaël Banaan Ananas 2014-07-03 00:52:15 +00:00
parent 5fb35cc10e
commit ac107d1742
3 changed files with 103 additions and 81 deletions

View File

@ -25,7 +25,6 @@
* This source implements the MC pin at Vss and mode bits in single chip mode.
*****************************************************************************/
#include "emu.h"
#include "debugger.h"
#include "tms7000.h"
@ -73,18 +72,28 @@ 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_io_config("io", ENDIANNESS_BIG, 8, 8, 0)
, m_opcode(s_opfn)
: 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)
{
}
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_io_config("io", ENDIANNESS_BIG, 8, 8, 0)
, m_opcode(opcode)
: 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)
{
}
@ -186,7 +195,15 @@ void tms7000_device::device_start()
{
m_program = &space(AS_PROGRAM);
m_direct = &m_program->direct();
m_io = &space(AS_IO);
// 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();
memset(m_pf, 0, 0x100);
m_cycles_per_INT2 = 0;
@ -475,19 +492,19 @@ WRITE8_MEMBER( tms7000_device::tms70x0_pf_w ) /* Perpherial file write */
break;
case 0x06: /* Port B write */
m_io->write_byte( TMS7000_PORTB, data );
m_outportsb(data);
m_pf[ 0x06 ] = data;
break;
case 0x08: /* Port C write */
temp1 = data & m_pf[ 0x09 ]; /* Mask off input bits */
m_io->write_byte( TMS7000_PORTC, temp1 );
m_outportsc(temp1);
m_pf[ 0x08 ] = temp1;
break;
case 0x0a: /* Port D write */
temp1 = data & m_pf[ 0x0b ]; /* Mask off input bits */
m_io->write_byte( TMS7000_PORTD, temp1 );
m_outportsd(temp1);
m_pf[ 0x0a ] = temp1;
break;
@ -522,7 +539,7 @@ READ8_MEMBER( tms7000_device::tms70x0_pf_r ) /* Perpherial file read */
break;
case 0x04: /* Port A read */
result = m_io->read_byte( TMS7000_PORTA );
result = m_inportsa();
break;
@ -533,14 +550,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_io->read_byte( TMS7000_PORTC ); /* Read port */
temp2 = m_inportsc(); /* 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_io->read_byte( TMS7000_PORTD ); /* Read port */
temp2 = m_inportsd(); /* Read port */
temp3 = temp2 & (~m_pf[ 0x0b ]); /* Mask off output bits */
result = temp1 | temp3; /* OR together */
break;

View File

@ -22,6 +22,7 @@
#ifndef __TMS7000_H__
#define __TMS7000_H__
#include "emu.h"
enum { TMS7000_PC=1, TMS7000_SP, TMS7000_ST, TMS7000_IDLE, TMS7000_T1_CL, TMS7000_T1_PS, TMS7000_T1_DEC };
@ -33,14 +34,37 @@ enum
TMS7000_IRQNONE = 255
};
enum
{
TMS7000_PORTA = 0,
TMS7000_PORTB,
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
{
@ -53,6 +77,15 @@ 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<class _Object> static devcb_base & set_inportsa_cb(device_t &device, _Object object) { return downcast<tms7000_device &>(device).m_inportsa.set_callback(object); }
template<class _Object> static devcb_base & set_inportsc_cb(device_t &device, _Object object) { return downcast<tms7000_device &>(device).m_inportsc.set_callback(object); }
template<class _Object> static devcb_base & set_inportsd_cb(device_t &device, _Object object) { return downcast<tms7000_device &>(device).m_inportsd.set_callback(object); }
template<class _Object> static devcb_base & set_outportsb_cb(device_t &device, _Object object) { return downcast<tms7000_device &>(device).m_outportsb.set_callback(object); }
template<class _Object> static devcb_base & set_outportsc_cb(device_t &device, _Object object) { return downcast<tms7000_device &>(device).m_outportsc.set_callback(object); }
template<class _Object> static devcb_base & set_outportsd_cb(device_t &device, _Object object) { return downcast<tms7000_device &>(device).m_outportsd.set_callback(object); }
DECLARE_WRITE8_MEMBER( tms70x0_pf_w );
DECLARE_READ8_MEMBER( tms70x0_pf_r );
@ -69,7 +102,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 : ( (spacenum == AS_IO) ? &m_io_config : NULL ); }
virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == AS_PROGRAM) ? &m_program_config : NULL; }
// device_state_interface overrides
void state_string_export(const device_state_entry &entry, astring &string);
@ -81,7 +114,6 @@ protected:
private:
address_space_config m_program_config;
address_space_config m_io_config;
const opcode_func *m_opcode;
@ -104,7 +136,17 @@ private:
address_space *m_program;
direct_read_data *m_direct;
address_space *m_io;
// 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;
/////////////////////////////////////////////////////////
inline UINT16 RM16( UINT32 mAddr );
inline UINT16 RRF16( UINT32 mAddr );

View File

@ -78,12 +78,8 @@ public:
DECLARE_READ8_MEMBER( mailbox_wx319_r );
DECLARE_WRITE8_MEMBER( mailbox_wx318_w );
DECLARE_READ8_MEMBER( tms7020_porta_r );
DECLARE_WRITE8_MEMBER( tms7020_porta_w );
DECLARE_READ8_MEMBER( tms7020_portb_r );
DECLARE_WRITE8_MEMBER( tms7020_portb_w );
DECLARE_READ8_MEMBER( tms7041_porta_r );
DECLARE_WRITE8_MEMBER( tms7041_porta_w );
DECLARE_READ8_MEMBER( tms7041_portb_r );
DECLARE_WRITE8_MEMBER( tms7041_portb_w );
DECLARE_READ8_MEMBER( tms7041_portc_r );
DECLARE_WRITE8_MEMBER( tms7041_portc_w );
@ -91,11 +87,9 @@ public:
DECLARE_WRITE8_MEMBER( tms7041_portd_w );
/* tms7020 i/o ports */
UINT8 m_tms7020_porta;
UINT8 m_tms7020_portb;
/* tms7041 i/o ports */
UINT8 m_tms7041_porta;
UINT8 m_tms7041_portb;
UINT8 m_tms7041_portc;
UINT8 m_tms7041_portd;
@ -259,13 +253,6 @@ READ8_MEMBER(exelv_state::tms7020_porta_r)
}
WRITE8_MEMBER(exelv_state::tms7020_porta_w)
{
logerror("tms7020_porta_w: data = 0x%02x\n", data);
m_tms7020_porta = data;
}
/*
TMS7020 PORT B
B0 - W - TMS7041 port A bit 2 (REV2)
@ -277,13 +264,6 @@ WRITE8_MEMBER(exelv_state::tms7020_porta_w)
B6 -
B7 -
*/
READ8_MEMBER(exelv_state::tms7020_portb_r)
{
logerror("tms7020_portb_r\n");
return 0x00;
}
WRITE8_MEMBER(exelv_state::tms7020_portb_w)
{
logerror("tms7020_portb_w: data = 0x%02x\n", data);
@ -326,13 +306,6 @@ READ8_MEMBER(exelv_state::tms7041_porta_r)
}
WRITE8_MEMBER(exelv_state::tms7041_porta_w)
{
logerror("tms7041_porta_w: data = 0x%02x\n", data);
m_tms7041_porta = data;
}
/*
TMS7041 PORT B
B0 - W - TMS5220 W
@ -344,14 +317,6 @@ WRITE8_MEMBER(exelv_state::tms7041_porta_w)
B6 - W - REV6 WX319-11
B7 - W - TMS7020 port A bit 0 (REV3)
*/
READ8_MEMBER(exelv_state::tms7041_portb_r)
{
UINT8 data = 0xff;
logerror("tms7041_portb_r\n");
return data;
}
WRITE8_MEMBER(exelv_state::tms7041_portb_w)
{
logerror("tms7041_portb_w: data = 0x%02x\n", data);
@ -465,25 +430,11 @@ static ADDRESS_MAP_START(tms7020_mem, AS_PROGRAM, 8, exelv_state)
ADDRESS_MAP_END
static ADDRESS_MAP_START(tms7020_port, AS_IO, 8, exelv_state)
AM_RANGE(TMS7000_PORTA, TMS7000_PORTA) AM_READWRITE(tms7020_porta_r, tms7020_porta_w)
AM_RANGE(TMS7000_PORTB, TMS7000_PORTB) AM_READWRITE(tms7020_portb_r, 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_READWRITE(tms7041_porta_r, tms7041_porta_w)
AM_RANGE(TMS7000_PORTB, TMS7000_PORTB) AM_READWRITE(tms7041_portb_r, 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
AM_RANGE(0x0124, 0x0124) AM_DEVREAD("tms3556", tms3556_device, vram_r)
@ -536,9 +487,7 @@ void exelv_state::machine_start()
membank("bank1")->set_entry(0);
/* register for state saving */
save_item(NAME(m_tms7020_porta));
save_item(NAME(m_tms7020_portb));
save_item(NAME(m_tms7041_porta));
save_item(NAME(m_tms7041_portb));
save_item(NAME(m_tms7041_portc));
save_item(NAME(m_tms7041_portd));
@ -547,15 +496,22 @@ void exelv_state::machine_start()
}
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_CPU_IO_MAP(tms7020_port)
MCFG_TMS7000_PORTA_READ_CB(READ8(exelv_state, tms7020_porta_r))
MCFG_TMS7000_PORTB_WRITE_CB(WRITE8(exelv_state, tms7020_portb_w))
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_CPU_IO_MAP(tms7041_port)
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_QUANTUM_PERFECT_CPU("maincpu")
@ -598,15 +554,22 @@ MACHINE_CONFIG_END
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_CPU_IO_MAP(tms7020_port)
MCFG_TMS7000_PORTA_READ_CB(READ8(exelv_state, tms7020_porta_r))
MCFG_TMS7000_PORTB_WRITE_CB(WRITE8(exelv_state, tms7020_portb_w))
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_CPU_IO_MAP(tms7041_port)
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_QUANTUM_PERFECT_CPU("maincpu")