diff --git a/src/emu/machine/ds2404.c b/src/emu/machine/ds2404.c index a02dd2d5a0a..70bea84c0ce 100644 --- a/src/emu/machine/ds2404.c +++ b/src/emu/machine/ds2404.c @@ -24,8 +24,15 @@ const device_type DS2404 = &device_creator; 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(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; } } diff --git a/src/emu/machine/ds2404.h b/src/emu/machine/ds2404.h index 154d818a005..0e1b8999aea 100644 --- a/src/emu/machine/ds2404.h +++ b/src/emu/machine/ds2404.h @@ -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;