From eeddbd3b9703ce527f8805d33578721cb5ea6b53 Mon Sep 17 00:00:00 2001 From: hap Date: Mon, 16 Feb 2015 23:52:44 +0100 Subject: added interrupt timer --- src/mess/drivers/tb303.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/mess/drivers/tb303.c b/src/mess/drivers/tb303.c index 6d0d32363cb..e82b3dfdc08 100644 --- a/src/mess/drivers/tb303.c +++ b/src/mess/drivers/tb303.c @@ -13,7 +13,6 @@ #include "emu.h" #include "cpu/ucom4/ucom4.h" -#include "sound/speaker.h" #include "tb303.lh" @@ -23,15 +22,41 @@ class tb303_state : public driver_device public: tb303_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu") + m_maincpu(*this, "maincpu"), + m_t3_off_timer(*this, "t3_off") { } required_device m_maincpu; + required_device m_t3_off_timer; + + TIMER_DEVICE_CALLBACK_MEMBER(t3_clock); + TIMER_DEVICE_CALLBACK_MEMBER(t3_off); virtual void machine_start(); }; +// T2 to MCU CLK: LC circuit, stable sine wave, 2.2us interval +#define TB303_T2_CLOCK_HZ 454545 /* in hz */ + +// T3 to MCU _INT: square wave, 1.8ms interval, short duty cycle +#define TB303_T3_CLOCK attotime::from_usec(1800) +#define TB303_T3_OFF (TB303_T3_CLOCK / 8) + +TIMER_DEVICE_CALLBACK_MEMBER(tb303_state::t3_off) +{ + m_maincpu->set_input_line(0, CLEAR_LINE); +} + +TIMER_DEVICE_CALLBACK_MEMBER(tb303_state::t3_clock) +{ + m_maincpu->set_input_line(0, ASSERT_LINE); + m_t3_off_timer->adjust(TB303_T3_OFF); +} + + + + static INPUT_PORTS_START( tb303 ) INPUT_PORTS_END @@ -51,7 +76,10 @@ void tb303_state::machine_start() static MACHINE_CONFIG_START( tb303, tb303_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", NEC_D650, 454545) // LC circuit, 2.2us pulse interval + MCFG_CPU_ADD("maincpu", NEC_D650, TB303_T2_CLOCK_HZ) + + MCFG_TIMER_DRIVER_ADD_PERIODIC("t3_clock", tb303_state, t3_clock, TB303_T3_CLOCK) + MCFG_TIMER_DRIVER_ADD("t3_off", tb303_state, t3_off) MCFG_DEFAULT_LAYOUT(layout_tb303) -- cgit v1.2.3