diff options
Diffstat (limited to 'src/devices/machine/icm7170.cpp')
-rw-r--r-- | src/devices/machine/icm7170.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/devices/machine/icm7170.cpp b/src/devices/machine/icm7170.cpp index 005626b6348..97be23ee0d2 100644 --- a/src/devices/machine/icm7170.cpp +++ b/src/devices/machine/icm7170.cpp @@ -8,6 +8,7 @@ #include "emu.h" #include "icm7170.h" + #include "coreutil.h" #define VERBOSE (0) @@ -59,8 +60,6 @@ enum IRQ_BIT_ALARM = 0x01 }; -static constexpr int ICM7170_TIMER_ID = 0; - //************************************************************************** // LIVE DEVICE //************************************************************************** @@ -84,10 +83,7 @@ icm7170_device::icm7170_device(const machine_config &mconfig, const char *tag, d void icm7170_device::device_start() { - // resolve callbacks - m_out_irq_cb.resolve_safe(); - - m_timer = timer_alloc(ICM7170_TIMER_ID); + m_timer = timer_alloc(FUNC(icm7170_device::clock_tick), this); // TODO: frequency should be based on input clock and divisor m_timer->adjust(attotime::from_hz(100), 0, attotime::from_hz(100)); @@ -109,10 +105,10 @@ void icm7170_device::device_reset() } //------------------------------------------------- -// device_timer - handles timer events +// clock_tick - advance the RTC's counters //------------------------------------------------- -void icm7170_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(icm7170_device::clock_tick) { // advance hundredths m_irq_status |= IRQ_BIT_100TH_SECOND; @@ -121,11 +117,11 @@ void icm7170_device::device_timer(emu_timer &timer, device_timer_id id, int para m_regs[REG_CNT_100TH_SEC] = 0; if (m_regs[REG_COMMAND] & CMD_REG_24_HOUR) - LOG("device_timer %02d-%02d-%02d %02d:%02d:%02d\n", + LOG("clock_tick %02d-%02d-%02d %02d:%02d:%02d\n", m_regs[REG_CNT_YEAR], m_regs[REG_CNT_MONTH], m_regs[REG_CNT_DAY], m_regs[REG_CNT_HOURS], m_regs[REG_CNT_MINUTES], m_regs[REG_CNT_SECONDS]); else - LOG("device_timer %02d-%02d-%02d %02d:%02d:%02d %s\n", + LOG("clock_tick %02d-%02d-%02d %02d:%02d:%02d %s\n", m_regs[REG_CNT_YEAR], m_regs[REG_CNT_MONTH], m_regs[REG_CNT_DAY], m_regs[REG_CNT_HOURS] & 0xf, m_regs[REG_CNT_MINUTES], m_regs[REG_CNT_SECONDS], (m_regs[REG_CNT_HOURS] & 0x80) ? "pm" : "am"); @@ -259,9 +255,10 @@ void icm7170_device::nvram_default() // .nv file //------------------------------------------------- -void icm7170_device::nvram_read(emu_file &file) +bool icm7170_device::nvram_read(util::read_stream &file) { - file.read(m_regs, 0x20); + auto const [err, actual] = util::read(file, m_regs, 0x20); + return !err && (actual == 0x20); } @@ -270,9 +267,10 @@ void icm7170_device::nvram_read(emu_file &file) // .nv file //------------------------------------------------- -void icm7170_device::nvram_write(emu_file &file) +bool icm7170_device::nvram_write(util::write_stream &file) { - file.write(m_regs, 0x20); + auto const [err, actual] = util::write(file, m_regs, 0x20); + return !err; } // non-inherited device functions @@ -305,7 +303,7 @@ void icm7170_device::write(offs_t offset, uint8_t data) case REG_COMMAND: m_timer->enable(data & CMD_REG_RUN); - // fall through + [[fallthrough]]; default: m_regs[offset & 0x1f] = data; |