Attempt to add irq function, it crashes (?) for whatever reason if enabled

This commit is contained in:
Angelo Salese 2011-12-19 17:54:02 +00:00
parent c297dab35c
commit 6d8285349a
6 changed files with 181 additions and 27 deletions

View File

@ -54,7 +54,7 @@ msm6242_device::msm6242_device(const machine_config &mconfig, const char *tag, d
}
void msm6242_device::timer_callback()
void msm6242_device::rtc_timer_callback()
{
static const UINT8 dpm[12] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 };
int dpm_count;
@ -79,9 +79,21 @@ void msm6242_device::timer_callback()
if(m_rtc.year >= 100) { m_rtc.year = 0; } //1900-1999 possible timeframe
}
void msm6242_device::std_callback()
{
//if ( !m_irq_changed.isnull() )
// m_irq_changed(TRUE);
}
TIMER_CALLBACK( msm6242_device::rtc_inc_callback )
{
reinterpret_cast<msm6242_device *>(ptr)->timer_callback();
reinterpret_cast<msm6242_device *>(ptr)->rtc_timer_callback();
}
TIMER_CALLBACK( msm6242_device::std_callback )
{
reinterpret_cast<msm6242_device *>(ptr)->std_callback();
}
//-------------------------------------------------
@ -101,8 +113,11 @@ bool msm6242_device::device_validity_check(emu_options &options, const game_driv
void msm6242_device::device_start()
{
m_irq_changed.resolve( m_out_int_line, *this );
/* let's call the timer callback every second */
machine().scheduler().timer_pulse(attotime::from_hz(clock() / XTAL_32_768kHz), FUNC(rtc_inc_callback), 0, (void *)this);
m_std_timer = machine().scheduler().timer_alloc(FUNC(std_callback), 0);
system_time systime;
machine().base_datetime(systime);
@ -127,6 +142,31 @@ void msm6242_device::device_start()
void msm6242_device::device_reset()
{
m_std_timer->adjust(attotime::never, 0, attotime::never);
if ( !m_irq_changed.isnull() )
m_irq_changed( FALSE );
}
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void msm6242_device::device_config_complete()
{
const msm6242_interface *intf = reinterpret_cast<const msm6242_interface *>(static_config());
if ( intf != NULL )
{
*static_cast<msm6242_interface *>(this) = *intf;
}
else
{
memset(&m_out_int_line, 0, sizeof(m_out_int_line));
}
}
//**************************************************************************
@ -211,7 +251,22 @@ WRITE8_MEMBER( msm6242_device::write )
return;
}
case MSM6242_REG_CE: m_reg[1] = data & 0x0f; return;
case MSM6242_REG_CE:
m_reg[1] = data & 0x0f;
if((data & 3) == 0) // MASK & STD = 0
{
static const double timer_param[4] = { 1000 / 64, 1000, 1000 * 60, 1000 * 60 * 60};
m_std_timer->adjust(attotime::from_msec(timer_param[(data & 0xc) >> 2]), 0, attotime::from_msec(timer_param[(data & 0xc) >> 2]));
}
else
{
m_std_timer->adjust(attotime::never, 0, attotime::never);
//if ( !m_irq_changed.isnull() )
// m_irq_changed( FALSE );
}
return;
case MSM6242_REG_CF:
{

View File

@ -13,8 +13,20 @@
#define __MSM6242DEV_H__
#define MCFG_MSM6242_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, msm6242, XTAL_32_768kHz)
#define MCFG_MSM6242_ADD(_tag, _config) \
MCFG_DEVICE_ADD(_tag, msm6242, XTAL_32_768kHz) \
MCFG_DEVICE_CONFIG(_config)
#define MSM6242_INTERFACE(name) \
const msm6242_interface (name) =
// ======================> ramdac_interface
typedef struct _msm6242_interface msm6242_interface;
struct _msm6242_interface
{
devcb_write_line m_out_int_line; /* Callback is called whenever the state of the INT output changes */
};
typedef struct
{
@ -24,7 +36,8 @@ typedef struct
// ======================> msm6242_device
class msm6242_device : public device_t
class msm6242_device : public device_t,
public msm6242_interface
{
public:
// construction/destruction
@ -33,20 +46,26 @@ public:
// I/O operations
DECLARE_WRITE8_MEMBER( write );
DECLARE_READ8_MEMBER( read );
void timer_callback();
void rtc_timer_callback();
void std_callback();
protected:
// device-level overrides
virtual bool device_validity_check(emu_options &options, const game_driver &driver) const;
virtual void device_start();
virtual void device_reset();
virtual void device_config_complete();
static TIMER_CALLBACK( rtc_inc_callback );
static TIMER_CALLBACK( std_callback );
private:
UINT8 m_reg[3];
rtc_regs_t m_rtc;
rtc_regs_t m_hold;
emu_timer *m_std_timer;
devcb_resolved_write_line m_irq_changed;
};

View File

@ -7789,6 +7789,12 @@ static MACHINE_START( sryudens )
Don Den Lover Vol.1
***************************************************************************/
static MSM6242_INTERFACE( ddenlovr_rtc_intf )
{
DEVCB_NULL
};
static MACHINE_CONFIG_START( ddenlovr, dynax_state )
/* basic machine hardware */
@ -7826,7 +7832,7 @@ static MACHINE_CONFIG_START( ddenlovr, dynax_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", ddenlovr_rtc_intf)
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( ddenlovj, ddenlovr )
@ -7913,6 +7919,11 @@ static INTERRUPT_GEN( rtc_irq )
}
#endif
static MSM6242_INTERFACE( quizchq_rtc_intf )
{
DEVCB_NULL
};
static MACHINE_CONFIG_START( quizchq, dynax_state )
/* basic machine hardware */
@ -7948,7 +7959,7 @@ static MACHINE_CONFIG_START( quizchq, dynax_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", quizchq_rtc_intf)
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( rongrong, quizchq )
@ -7990,6 +8001,12 @@ static TIMER_DEVICE_CALLBACK( mmpanic_irq )
device_set_input_line_and_vector(state->m_maincpu, 0, HOLD_LINE, 0xe7); // RST 20, clock
}
static MSM6242_INTERFACE( mmpanic_rtc_intf )
{
DEVCB_NULL
};
static MACHINE_CONFIG_START( mmpanic, dynax_state )
/* basic machine hardware */
@ -8033,7 +8050,7 @@ static MACHINE_CONFIG_START( mmpanic, dynax_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", mmpanic_rtc_intf)
MACHINE_CONFIG_END
@ -8067,6 +8084,10 @@ static TIMER_DEVICE_CALLBACK( hanakanz_irq )
device_set_input_line_and_vector(state->m_maincpu, 0, HOLD_LINE, 0xe2);
}
static MSM6242_INTERFACE( hanakanz_rtc_intf )
{
DEVCB_NULL
};
static MACHINE_CONFIG_START( hanakanz, dynax_state )
@ -8103,7 +8124,7 @@ static MACHINE_CONFIG_START( hanakanz, dynax_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", hanakanz_rtc_intf)
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( hkagerou, hanakanz )
@ -8413,6 +8434,12 @@ static MACHINE_CONFIG_DERIVED( hparadis, quizchq )
MCFG_MACHINE_START(hparadis)
MACHINE_CONFIG_END
static MSM6242_INTERFACE( jongtei_rtc_intf )
{
DEVCB_NULL
};
static MACHINE_CONFIG_START( jongtei, dynax_state )
/* basic machine hardware */
@ -8448,13 +8475,18 @@ static MACHINE_CONFIG_START( jongtei, dynax_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", jongtei_rtc_intf)
MACHINE_CONFIG_END
/***************************************************************************
Mahjong Seiryu Densetsu
***************************************************************************/
static MSM6242_INTERFACE( sryudens_rtc_intf )
{
DEVCB_NULL
};
static MACHINE_CONFIG_START( sryudens, dynax_state )
/* basic machine hardware */
@ -8493,13 +8525,20 @@ static MACHINE_CONFIG_START( sryudens, dynax_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", sryudens_rtc_intf)
MACHINE_CONFIG_END
/***************************************************************************
Mahjong Daimyojin
***************************************************************************/
static MSM6242_INTERFACE( daimyojin_rtc_intf )
{
DEVCB_NULL
};
static MACHINE_CONFIG_START( daimyojn, dynax_state )
/* basic machine hardware */
@ -8535,7 +8574,7 @@ static MACHINE_CONFIG_START( daimyojn, dynax_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", daimyojin_rtc_intf)
MACHINE_CONFIG_END

View File

@ -4620,6 +4620,11 @@ static INTERRUPT_GEN( yarunara_clock_interrupt )
sprtmtch_update_irq(device->machine());
}
static MSM6242_INTERFACE( yarunara_rtc_intf )
{
DEVCB_NULL
};
static MACHINE_CONFIG_DERIVED( yarunara, hnoridur )
/* basic machine hardware */
@ -4635,7 +4640,7 @@ static MACHINE_CONFIG_DERIVED( yarunara, hnoridur )
MCFG_SCREEN_VISIBLE_AREA(0, 336-1, 8, 256-1-8-1)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", yarunara_rtc_intf)
MACHINE_CONFIG_END
@ -4700,6 +4705,12 @@ static MACHINE_START( jantouki )
MACHINE_START_CALL(dynax);
}
static MSM6242_INTERFACE( jantouki_rtc_intf )
{
DEVCB_NULL
};
static MACHINE_CONFIG_START( jantouki, dynax_state )
/* basic machine hardware */
@ -4759,7 +4770,7 @@ static MACHINE_CONFIG_START( jantouki, dynax_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", jantouki_rtc_intf)
MACHINE_CONFIG_END
@ -4872,6 +4883,12 @@ static const ay8910_interface htengoku_ay8910_interface =
DEVCB_NULL, DEVCB_HANDLER(htengoku_dsw_w) // W
};
static MSM6242_INTERFACE( htengoku_rtc_intf )
{
DEVCB_NULL
};
static MACHINE_CONFIG_START( htengoku, dynax_state )
/* basic machine hardware */
@ -4911,7 +4928,7 @@ static MACHINE_CONFIG_START( htengoku, dynax_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", htengoku_rtc_intf)
MACHINE_CONFIG_END
@ -4927,9 +4944,6 @@ static TIMER_DEVICE_CALLBACK( tenkai_interrupt )
if(scanline == 256)
device_set_input_line(state->m_maincpu, INPUT_LINE_IRQ0, HOLD_LINE);
if(scanline == 128)
device_set_input_line(state->m_maincpu, INPUT_LINE_IRQ1, HOLD_LINE);
if(scanline == 0)
device_set_input_line(state->m_maincpu, INPUT_LINE_IRQ2, HOLD_LINE);
}
@ -4950,6 +4964,18 @@ static MACHINE_START( tenkai )
machine.save().register_postload(save_prepost_delegate(FUNC(tenkai_update_rombank), &machine));
}
static WRITE_LINE_DEVICE_HANDLER(tenkai_rtc_irq)
{
dynax_state *drvstate = device->machine().driver_data<dynax_state>();
device_set_input_line(drvstate->m_maincpu, INPUT_LINE_IRQ1, HOLD_LINE);
}
static MSM6242_INTERFACE( tenkai_rtc_intf )
{
DEVCB_LINE(tenkai_rtc_irq)
};
static MACHINE_CONFIG_START( tenkai, dynax_state )
/* basic machine hardware */
@ -4987,7 +5013,7 @@ static MACHINE_CONFIG_START( tenkai, dynax_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", tenkai_rtc_intf)
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( majrjhdx, tenkai )

View File

@ -3282,6 +3282,11 @@ static TIMER_DEVICE_CALLBACK( janptr96_interrupt )
device_set_input_line_and_vector(state->m_maincpu, 0, HOLD_LINE, 0x84); // demo
}
static MSM6242_INTERFACE( janptr96_rtc_intf )
{
DEVCB_NULL
};
static MACHINE_CONFIG_DERIVED( janptr96, mjderngr )
MCFG_DEVICE_REMOVE("maincpu")
@ -3294,7 +3299,7 @@ static MACHINE_CONFIG_DERIVED( janptr96, mjderngr )
MCFG_SCREEN_VISIBLE_AREA(0, 255, 9, 255-8)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", janptr96_rtc_intf)
MACHINE_CONFIG_END
@ -3332,6 +3337,11 @@ static TIMER_DEVICE_CALLBACK( mjtensin_interrupt )
device_set_input_line(state->m_maincpu, 0, INPUT_LINE_IRQ1); // rtc
}
static MSM6242_INTERFACE( mjtensin_rtc_intf )
{
DEVCB_NULL
};
static MACHINE_CONFIG_DERIVED( mjtensin, mjderngr )
MCFG_CPU_REPLACE("maincpu",TMP90841, 12000000) /* ? */
@ -3343,7 +3353,7 @@ static MACHINE_CONFIG_DERIVED( mjtensin, mjderngr )
MCFG_SCREEN_VISIBLE_AREA(0, 255, 8, 255-8)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", mjtensin_rtc_intf)
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( cafetime, mjderngr )
@ -3356,7 +3366,7 @@ static MACHINE_CONFIG_DERIVED( cafetime, mjderngr )
MCFG_SCREEN_VISIBLE_AREA(0, 255, 8, 255-8)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", mjtensin_rtc_intf)
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( mjvegasa, mjderngr )
@ -3369,7 +3379,7 @@ static MACHINE_CONFIG_DERIVED( mjvegasa, mjderngr )
MCFG_SCREEN_VISIBLE_AREA(0, 255, 8, 255-8)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", mjtensin_rtc_intf)
MACHINE_CONFIG_END

View File

@ -8973,7 +8973,7 @@ MACHINE_CONFIG_END
International Toote
***************************************************************************/
// Test mode shows a 16ms and 2ms counters
// Test mode shows a 16ms and 2ms counters, then there's vblank and presumably ACIA irqs ...
static TIMER_DEVICE_CALLBACK( inttoote_interrupt )
{
seta_state *state = timer.machine().driver_data<seta_state>();
@ -9024,6 +9024,11 @@ static const pia6821_interface inttoote_pia1_intf =
DEVCB_NULL /* IRQB */
};
static MSM6242_INTERFACE( rtc_intf )
{
DEVCB_NULL
};
static MACHINE_CONFIG_START( inttoote, seta_state )
/* basic machine hardware */
@ -9060,7 +9065,7 @@ static MACHINE_CONFIG_START( inttoote, seta_state )
MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
/* devices */
MCFG_MSM6242_ADD("rtc")
MCFG_MSM6242_ADD("rtc", rtc_intf)
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( jockeyc, inttoote )