tms9902_device: converted to devcb2 (nw)

This commit is contained in:
Ivan Vangelista 2014-04-21 08:23:25 +00:00
parent 94db067125
commit 1fb88b94ed
6 changed files with 57 additions and 89 deletions

View File

@ -1014,22 +1014,6 @@ WRITE8_MEMBER( ti_rs232_pio_device::ctrl1_callback )
ctrl_callback(1, offset, data); ctrl_callback(1, offset, data);
} }
static const tms9902_interface tms9902_params0 =
{
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, int0_callback), /* called when interrupt pin state changes */
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, rcv0_callback), /* called when a character is received */
DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, xmit0_callback), /* called when a character is transmitted */
DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, ctrl0_callback)
};
static const tms9902_interface tms9902_params1 =
{
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, int1_callback), /* called when interrupt pin state changes */
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, rcv1_callback), /* called when a character is received */
DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, xmit1_callback), /* called when a character is transmitted */
DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, ti_rs232_pio_device, ctrl1_callback)
};
void ti_rs232_pio_device::device_start() void ti_rs232_pio_device::device_start()
{ {
m_dsrrom = memregion(DSRROM)->base(); m_dsrrom = memregion(DSRROM)->base();
@ -1097,8 +1081,16 @@ void ti_rs232_pio_device::device_reset()
} }
static MACHINE_CONFIG_FRAGMENT( ti_rs232 ) static MACHINE_CONFIG_FRAGMENT( ti_rs232 )
MCFG_TMS9902_ADD("tms9902_0", tms9902_params0, 3000000) MCFG_DEVICE_ADD("tms9902_0", TMS9902, 3000000)
MCFG_TMS9902_ADD("tms9902_1", tms9902_params1, 3000000) MCFG_TMS9902_INT_CB(WRITELINE(ti_rs232_pio_device, int0_callback)) /* called when interrupt pin state changes */
MCFG_TMS9902_RCV_CB(WRITELINE(ti_rs232_pio_device, rcv0_callback)) /* called when a character is received */
MCFG_TMS9902_XMIT_CB(WRITE8(ti_rs232_pio_device, xmit0_callback)) /* called when a character is transmitted */
MCFG_TMS9902_CTRL_CB(WRITE8(ti_rs232_pio_device, ctrl0_callback))
MCFG_DEVICE_ADD("tms9902_0", TMS9902, 3000000)
MCFG_TMS9902_INT_CB(WRITELINE(ti_rs232_pio_device, int1_callback)) /* called when interrupt pin state changes */
MCFG_TMS9902_RCV_CB(WRITELINE(ti_rs232_pio_device, rcv1_callback)) /* called when a character is received */
MCFG_TMS9902_XMIT_CB(WRITE8(ti_rs232_pio_device, xmit1_callback)) /* called when a character is transmitted */
MCFG_TMS9902_CTRL_CB(WRITE8(ti_rs232_pio_device, ctrl1_callback))
MCFG_DEVICE_ADD("serdev0", TI99_RS232_DEV, 0) MCFG_DEVICE_ADD("serdev0", TI99_RS232_DEV, 0)
MCFG_DEVICE_ADD("serdev1", TI99_RS232_DEV, 0) MCFG_DEVICE_ADD("serdev1", TI99_RS232_DEV, 0)
MCFG_DEVICE_ADD("piodev", TI99_PIO_DEV, 0) MCFG_DEVICE_ADD("piodev", TI99_PIO_DEV, 0)

View File

@ -61,7 +61,11 @@ enum
Constructor Constructor
*/ */
tms9902_device::tms9902_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) tms9902_device::tms9902_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, TMS9902, "TMS9902 ACC", tag, owner, clock, "tms9902", __FILE__) : device_t(mconfig, TMS9902, "TMS9902 ACC", tag, owner, clock, "tms9902", __FILE__),
m_int_cb(*this),
m_rcv_cb(*this),
m_xmit_cb(*this),
m_ctrl_cb(*this)
{ {
} }
@ -82,7 +86,7 @@ void tms9902_device::field_interrupts()
// Only consider edges // Only consider edges
m_INT = new_int; m_INT = new_int;
if (VERBOSE>3) LOG("TMS9902: /INT = %s\n", (m_INT)? "asserted" : "cleared"); if (VERBOSE>3) LOG("TMS9902: /INT = %s\n", (m_INT)? "asserted" : "cleared");
int_callback(m_INT? ASSERT_LINE : CLEAR_LINE); m_int_cb(m_INT? ASSERT_LINE : CLEAR_LINE);
} }
} }
@ -248,7 +252,7 @@ void tms9902_device::device_timer(emu_timer &timer, device_timer_id id, int para
// depending on CLK4M. With this timer, reception of characters becomes // depending on CLK4M. With this timer, reception of characters becomes
// possible. // possible.
case RECVTIMER: case RECVTIMER:
rcv_callback(ASSERT_LINE); m_rcv_cb(ASSERT_LINE);
break; break;
case SENDTIMER: case SENDTIMER:
@ -291,7 +295,7 @@ void tms9902_device::send_break(bool state)
if (VERBOSE>2) LOG("TMS9902: Sending BREAK=%d\n", state? 1:0); if (VERBOSE>2) LOG("TMS9902: Sending BREAK=%d\n", state? 1:0);
// Signal BRK (on/off) to the remote site // Signal BRK (on/off) to the remote site
ctrl_callback((EXCEPT | BRK), state? 1:0); m_ctrl_cb((offs_t)(EXCEPT | BRK), state? 1:0);
} }
} }
@ -334,7 +338,7 @@ void tms9902_device::set_receive_data_rate()
if (VERBOSE>3) LOG ("TMS9902: baudpoll = %lf\n", m_baudpoll); if (VERBOSE>3) LOG ("TMS9902: baudpoll = %lf\n", m_baudpoll);
m_last_config_value = value; m_last_config_value = value;
ctrl_callback(CONFIG, RATERECV); m_ctrl_cb((offs_t)CONFIG, RATERECV);
} }
/* /*
@ -346,7 +350,7 @@ void tms9902_device::set_transmit_data_rate()
int value = (m_CLK4M? 0x800 : 0) | (m_XDV8? 0x400 : 0) | m_XDR; int value = (m_CLK4M? 0x800 : 0) | (m_XDV8? 0x400 : 0) | m_XDR;
if (VERBOSE>3) LOG("TMS9902: set transmit rate = %04x\n", value); if (VERBOSE>3) LOG("TMS9902: set transmit rate = %04x\n", value);
m_last_config_value = value; m_last_config_value = value;
ctrl_callback(CONFIG, RATEXMIT); m_ctrl_cb((offs_t)CONFIG, RATEXMIT);
} }
void tms9902_device::set_stop_bits() void tms9902_device::set_stop_bits()
@ -354,7 +358,7 @@ void tms9902_device::set_stop_bits()
int value = m_STOPB; int value = m_STOPB;
if (VERBOSE>3) LOG("TMS9902: set stop bits = %02x\n", value); if (VERBOSE>3) LOG("TMS9902: set stop bits = %02x\n", value);
m_last_config_value = value; m_last_config_value = value;
ctrl_callback(CONFIG, STOPBITS); m_ctrl_cb((offs_t)CONFIG, STOPBITS);
} }
void tms9902_device::set_data_bits() void tms9902_device::set_data_bits()
@ -362,7 +366,7 @@ void tms9902_device::set_data_bits()
int value = m_RCL; int value = m_RCL;
if (VERBOSE>3) LOG("TMS9902: set data bits = %02x\n", value); if (VERBOSE>3) LOG("TMS9902: set data bits = %02x\n", value);
m_last_config_value = value; m_last_config_value = value;
ctrl_callback(CONFIG, DATABITS); m_ctrl_cb((offs_t)CONFIG, DATABITS);
} }
void tms9902_device::set_parity() void tms9902_device::set_parity()
@ -370,7 +374,7 @@ void tms9902_device::set_parity()
int value = (m_PENB? 2:0) | (m_ODDP? 1:0); int value = (m_PENB? 2:0) | (m_ODDP? 1:0);
if (VERBOSE>3) LOG("TMS9902: set parity = %02x\n", value); if (VERBOSE>3) LOG("TMS9902: set parity = %02x\n", value);
m_last_config_value = value; m_last_config_value = value;
ctrl_callback(CONFIG, PARITY); m_ctrl_cb((offs_t)CONFIG, PARITY);
} }
void tms9902_device::transmit_line_state() void tms9902_device::transmit_line_state()
@ -379,7 +383,7 @@ void tms9902_device::transmit_line_state()
// The 9902 only outputs RTS and BRK // The 9902 only outputs RTS and BRK
if (VERBOSE>3) LOG("TMS9902: transmitting line state (only RTS) = %02x\n", (m_RTSout)? 1:0); if (VERBOSE>3) LOG("TMS9902: transmitting line state (only RTS) = %02x\n", (m_RTSout)? 1:0);
m_last_config_value = (m_RTSout)? RTS : 0; m_last_config_value = (m_RTSout)? RTS : 0;
ctrl_callback(LINES, RTS); m_ctrl_cb((offs_t)LINES, RTS);
} }
void tms9902_device::set_rts(line_state state) void tms9902_device::set_rts(line_state state)
@ -423,7 +427,7 @@ void tms9902_device::initiate_transmit()
if (VERBOSE>4) LOG("TMS9902: transmit XSR=%02x, RCL=%02x\n", m_XSR, m_RCL); if (VERBOSE>4) LOG("TMS9902: transmit XSR=%02x, RCL=%02x\n", m_XSR, m_RCL);
xmit_callback(0, m_XSR & (0xff >> (3-m_RCL))); m_xmit_cb((offs_t)0, m_XSR & (0xff >> (3-m_RCL)));
// Should store that somewhere (but the CPU is fast enough, can afford to recalc :-) ) // Should store that somewhere (but the CPU is fast enough, can afford to recalc :-) )
double fint = m_clock_rate / ((m_CLK4M) ? 4.0 : 3.0); double fint = m_clock_rate / ((m_CLK4M) ? 4.0 : 3.0);
@ -828,14 +832,12 @@ void tms9902_device::device_reset()
void tms9902_device::device_start() void tms9902_device::device_start()
{ {
const tms9902_interface *intf = reinterpret_cast<const tms9902_interface *>(static_config());
m_clock_rate = clock(); m_clock_rate = clock();
int_callback.resolve(intf->int_callback, *this); m_int_cb.resolve_safe();
rcv_callback.resolve(intf->rcv_callback, *this); m_rcv_cb.resolve_safe();
xmit_callback.resolve(intf->xmit_callback, *this); m_xmit_cb.resolve_safe();
ctrl_callback.resolve(intf->ctrl_callback, *this); m_ctrl_cb.resolve_safe();
m_dectimer = timer_alloc(DECTIMER); m_dectimer = timer_alloc(DECTIMER);
m_recvtimer = timer_alloc(RECVTIMER); m_recvtimer = timer_alloc(RECVTIMER);

View File

@ -44,18 +44,16 @@
extern const device_type TMS9902; extern const device_type TMS9902;
struct tms9902_interface
{
devcb_write_line int_callback;
devcb_write_line rcv_callback;
devcb_write8 xmit_callback;
devcb_write8 ctrl_callback;
};
class tms9902_device : public device_t class tms9902_device : public device_t
{ {
public: public:
tms9902_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); tms9902_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
template<class _Object> static devcb2_base &set_int_callback(device_t &device, _Object object) { return downcast<tms9902_device &>(device).m_int_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_rcv_callback(device_t &device, _Object object) { return downcast<tms9902_device &>(device).m_rcv_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_xmit_callback(device_t &device, _Object object) { return downcast<tms9902_device &>(device).m_xmit_cb.set_callback(object); }
template<class _Object> static devcb2_base &set_ctrl_callback(device_t &device, _Object object) { return downcast<tms9902_device &>(device).m_ctrl_cb.set_callback(object); }
void set_clock(bool state); void set_clock(bool state);
void rcv_cts(line_state state); void rcv_cts(line_state state);
@ -92,10 +90,10 @@ private:
void initiate_transmit(); void initiate_transmit();
void reset_uart(); void reset_uart();
devcb_resolved_write_line int_callback; devcb2_write_line m_int_cb;
devcb_resolved_write_line rcv_callback; devcb2_write_line m_rcv_cb;
devcb_resolved_write8 xmit_callback; devcb2_write8 m_xmit_cb;
devcb_resolved_write8 ctrl_callback; // needs to be used with get_config_value devcb2_write8 m_ctrl_cb; // needs to be used with get_config_value
// tms9902 clock rate (PHI* pin, normally connected to TMS9900 Phi3*) // tms9902 clock rate (PHI* pin, normally connected to TMS9900 Phi3*)
// Official range is 2MHz-3.3MHz. Some tms9902s were sold as "MP9214", and // Official range is 2MHz-3.3MHz. Some tms9902s were sold as "MP9214", and
@ -190,8 +188,16 @@ private:
DEVICE CONFIGURATION MACROS DEVICE CONFIGURATION MACROS
***************************************************************************/ ***************************************************************************/
#define MCFG_TMS9902_ADD(_tag, _intrf, _clock) \ #define MCFG_TMS9902_INT_CB(_devcb) \
MCFG_DEVICE_ADD(_tag, TMS9902, _clock) \ devcb = &tms9902_device::set_int_callback(*device, DEVCB2_##_devcb);
MCFG_DEVICE_CONFIG(_intrf)
#define MCFG_TMS9902_RCV_CB(_devcb) \
devcb = &tms9902_device::set_rcv_callback(*device, DEVCB2_##_devcb);
#define MCFG_TMS9902_XMIT_CB(_devcb) \
devcb = &tms9902_device::set_xmit_callback(*device, DEVCB2_##_devcb);
#define MCFG_TMS9902_CTRL_CB(_devcb) \
devcb = &tms9902_device::set_ctrl_callback(*device, DEVCB2_##_devcb);
#endif /* __TMS9902_H__ */ #endif /* __TMS9902_H__ */

View File

@ -131,23 +131,6 @@ WRITE8_MEMBER(jpmmps_state::jpmmps_ic22_portc_w)
} }
// Communication with Reel MCU
static const tms9902_interface tms9902_uart4_ic10_params =
{
DEVCB_NULL, /*int_callback,*/ /* called when interrupt pin state changes */
DEVCB_NULL, /*rcv_callback,*/ /* called when a character shall be received */
DEVCB_NULL, /* called when a character is transmitted */
DEVCB_NULL /* called for setting interface parameters and line states */
};
// Communication with Security / Printer
static const tms9902_interface tms9902_uart2_ic5_params =
{
DEVCB_NULL, /*int_callback,*/ /* called when interrupt pin state changes */
DEVCB_NULL, /*rcv_callback,*/ /* called when a character shall be received */
DEVCB_NULL, /* called when a character is transmitted */
DEVCB_NULL /* called for setting interface parameters and line states */
};
// these are wrong // these are wrong
#define MAIN_CLOCK 2000000 #define MAIN_CLOCK 2000000
@ -185,8 +168,8 @@ static MACHINE_CONFIG_START( jpmmps, jpmmps_state )
MCFG_DEVICE_ADD("ppi8255_ic25", I8255, 0) MCFG_DEVICE_ADD("ppi8255_ic25", I8255, 0)
MCFG_TMS9902_ADD("tms9902_ic10", tms9902_uart4_ic10_params, DUART_CLOCK) MCFG_DEVICE_ADD("tms9902_ic10", TMS9902, DUART_CLOCK) // Communication with Reel MCU
MCFG_TMS9902_ADD("tms9902_ic5", tms9902_uart2_ic5_params, DUART_CLOCK) MCFG_DEVICE_ADD("tms9902_ic5", TMS9902, DUART_CLOCK) // Communication with Security / Printer
MCFG_MACHINE_START_OVERRIDE(jpmmps_state,jpmmps) MCFG_MACHINE_START_OVERRIDE(jpmmps_state,jpmmps)

View File

@ -81,14 +81,6 @@ static const ay8910_interface ay8910_interface_jpm =
#define SOUND_CLOCK 2000000 #define SOUND_CLOCK 2000000
#define DUART_CLOCK 2000000 #define DUART_CLOCK 2000000
static const tms9902_interface tms9902_config =
{
DEVCB_NULL, /*int_callback,*/ /* called when interrupt pin state changes */
DEVCB_NULL, /*rcv_callback,*/ /* called when a character shall be received */
DEVCB_NULL, /* called when a character is transmitted */
DEVCB_NULL /* called for setting interface parameters and line states */
};
void jpms80_state::machine_reset() void jpms80_state::machine_reset()
{ {
// Disable auto wait state generation by raising the READY line on reset // Disable auto wait state generation by raising the READY line on reset
@ -100,7 +92,7 @@ static MACHINE_CONFIG_START( jpms80, jpms80_state )
MCFG_TMS99xx_ADD("maincpu", TMS9995, MAIN_CLOCK, jpms80_map, jpms80_io_map) MCFG_TMS99xx_ADD("maincpu", TMS9995, MAIN_CLOCK, jpms80_map, jpms80_io_map)
MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_TMS9902_ADD("tms9902duart", tms9902_config, DUART_CLOCK) MCFG_DEVICE_ADD("tms9902duart", TMS9902, DUART_CLOCK)
MCFG_SOUND_ADD("aysnd", AY8910, 2000000) MCFG_SOUND_ADD("aysnd", AY8910, 2000000)
MCFG_SOUND_CONFIG(ay8910_interface_jpm) MCFG_SOUND_CONFIG(ay8910_interface_jpm)

View File

@ -722,15 +722,6 @@ static const tms9901_interface sys9901reset_param =
0x3000-0x3fff: 4kb onboard ROM 0x3000-0x3fff: 4kb onboard ROM
*/ */
// MZ: needs to be fixed once the RS232 support is complete
static const tms9902_interface tms9902_params =
{
DEVCB_NULL, /*int_callback,*/ /* called when interrupt pin state changes */
DEVCB_NULL, /*rcv_callback,*/ /* called when a character shall be received */
DEVCB_DRIVER_MEMBER(tm990189_state, xmit_callback), /* called when a character is transmitted */
DEVCB_NULL /* called for setting interface parameters and line states */
};
static ADDRESS_MAP_START( tm990_189_memmap, AS_PROGRAM, 8, tm990189_state ) static ADDRESS_MAP_START( tm990_189_memmap, AS_PROGRAM, 8, tm990189_state )
AM_RANGE(0x0000, 0x07ff) AM_RAM /* RAM */ AM_RANGE(0x0000, 0x07ff) AM_RAM /* RAM */
AM_RANGE(0x0800, 0x0fff) AM_ROM /* extra ROM - application programs with unibug, remaining 2kb of program for university basic */ AM_RANGE(0x0800, 0x0fff) AM_ROM /* extra ROM - application programs with unibug, remaining 2kb of program for university basic */
@ -864,7 +855,8 @@ static MACHINE_CONFIG_START( tm990_189, tm990189_state )
MCFG_TMS9901_P15_HANDLER( WRITELINE( tm990189_state, sys9901_tapewdata_w) ) MCFG_TMS9901_P15_HANDLER( WRITELINE( tm990189_state, sys9901_tapewdata_w) )
MCFG_TMS9901_INTLEVEL_HANDLER( WRITE8( tm990189_state, sys9901_interrupt_callback) ) MCFG_TMS9901_INTLEVEL_HANDLER( WRITE8( tm990189_state, sys9901_interrupt_callback) )
MCFG_TMS9902_ADD("tms9902", tms9902_params, 2000000) MCFG_DEVICE_ADD("tms9902", TMS9902, 2000000) // MZ: needs to be fixed once the RS232 support is complete
MCFG_TMS9902_XMIT_CB(WRITE8(tm990189_state, xmit_callback)) /* called when a character is transmitted */
MCFG_TM990_189_RS232_ADD("rs232") MCFG_TM990_189_RS232_ADD("rs232")
MCFG_TIMER_DRIVER_ADD_PERIODIC("display_timer", tm990189_state, display_callback, attotime::from_hz(30)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_timer", tm990189_state, display_callback, attotime::from_hz(30))
// Need to delay the timer, or it will spoil the initial LOAD // Need to delay the timer, or it will spoil the initial LOAD
@ -923,7 +915,8 @@ static MACHINE_CONFIG_START( tm990_189_v, tm990189_state )
MCFG_TMS9901_P15_HANDLER( WRITELINE( tm990189_state, sys9901_tapewdata_w) ) MCFG_TMS9901_P15_HANDLER( WRITELINE( tm990189_state, sys9901_tapewdata_w) )
MCFG_TMS9901_INTLEVEL_HANDLER( WRITE8( tm990189_state, sys9901_interrupt_callback) ) MCFG_TMS9901_INTLEVEL_HANDLER( WRITE8( tm990189_state, sys9901_interrupt_callback) )
MCFG_TMS9902_ADD("tms9902", tms9902_params, 2000000) MCFG_DEVICE_ADD("tms9902", TMS9902, 2000000) // MZ: needs to be fixed once the RS232 support is complete
MCFG_TMS9902_XMIT_CB(WRITE8(tm990189_state, xmit_callback)) /* called when a character is transmitted */
MCFG_TM990_189_RS232_ADD("rs232") MCFG_TM990_189_RS232_ADD("rs232")
MCFG_TIMER_DRIVER_ADD_PERIODIC("display_timer", tm990189_state, display_callback, attotime::from_hz(30)) MCFG_TIMER_DRIVER_ADD_PERIODIC("display_timer", tm990189_state, display_callback, attotime::from_hz(30))
MCFG_TIMER_START_DELAY(attotime::from_msec(150)) MCFG_TIMER_START_DELAY(attotime::from_msec(150))