fix DEBUG crash?

This commit is contained in:
Michaël Banaan Ananas 2013-07-07 00:22:30 +00:00
parent cdbf560238
commit b3c1eb9d6f
2 changed files with 33 additions and 15 deletions

View File

@ -24,8 +24,15 @@ const device_type DS2404 = &device_creator<ds2404_device>;
ds2404_device::ds2404_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, DS2404, "DS2404", tag, owner, clock, "ds2404", __FILE__),
device_nvram_interface(mconfig, *this)
device_nvram_interface(mconfig, *this),
m_address(0),
m_offset(0),
m_end_offset(0),
m_a1(0),
m_a2(0),
m_state_ptr(0)
{
memset(m_ram, 0, sizeof(m_ram));
}
@ -89,9 +96,12 @@ void ds2404_device::device_start()
m_rtc[2] = (current_time >> 8) & 0xff;
m_rtc[3] = (current_time >> 16) & 0xff;
m_rtc[4] = (current_time >> 24) & 0xff;
for (int i = 0; i < 8; i++)
m_state[i] = DS2404_STATE_IDLE;
emu_timer *timer = machine().scheduler().timer_alloc(FUNC(ds2404_tick_callback), (void *)this);
timer->adjust(attotime::from_hz(256), 0, attotime::from_hz(256));
m_tick_timer = timer_alloc(0);
m_tick_timer->adjust(attotime::from_hz(256), 0, attotime::from_hz(256));
}
@ -336,20 +346,28 @@ WRITE8_MEMBER( ds2404_device::ds2404_clk_w )
}
}
TIMER_CALLBACK( ds2404_device::ds2404_tick_callback )
void ds2404_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
reinterpret_cast<ds2404_device*>(ptr)->ds2404_tick();
}
void ds2404_device::ds2404_tick()
{
for(int i = 0; i < 5; i++)
switch(id)
{
m_rtc[ i ]++;
if(m_rtc[ i ] != 0)
case 0:
{
// tick
for(int i = 0; i < 5; i++)
{
m_rtc[ i ]++;
if(m_rtc[ i ] != 0)
{
break;
}
}
break;
}
default:
assert_always(FALSE, "Unknown id in ds2404_device::device_timer");
break;
}
}

View File

@ -64,8 +64,6 @@ public:
DECLARE_WRITE8_MEMBER(ds2404_data_w);
DECLARE_WRITE8_MEMBER(ds2404_clk_w);
void ds2404_tick();
protected:
// device-level overrides
virtual void device_start();
@ -78,7 +76,7 @@ protected:
virtual void nvram_read(emu_file &file);
virtual void nvram_write(emu_file &file);
static TIMER_CALLBACK( ds2404_tick_callback );
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
private:
@ -102,6 +100,8 @@ private:
DS2404_STATE_COPY_SCRATCHPAD /* Copy Scratchpad command active */
};
emu_timer *m_tick_timer;
// configuration state
UINT32 m_ref_year;
UINT8 m_ref_month;