summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/hd64610.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/hd64610.cpp')
-rw-r--r--src/devices/machine/hd64610.cpp66
1 files changed, 30 insertions, 36 deletions
diff --git a/src/devices/machine/hd64610.cpp b/src/devices/machine/hd64610.cpp
index 0da686e7bf0..41482acacfe 100644
--- a/src/devices/machine/hd64610.cpp
+++ b/src/devices/machine/hd64610.cpp
@@ -16,9 +16,10 @@
#include "emu.h"
#include "hd64610.h"
+
#include "coreutil.h"
-#define VERBOSE 1
+#define VERBOSE 0
#include "logmacro.h"
@@ -169,12 +170,8 @@ hd64610_device::hd64610_device(const machine_config &mconfig, const char *tag, d
void hd64610_device::device_start()
{
- // resolve callbacks
- m_out_irq_cb.resolve_safe();
- m_out_1hz_cb.resolve_safe();
-
// allocate timers
- m_counter_timer = timer_alloc(TIMER_UPDATE_COUNTER);
+ m_counter_timer = timer_alloc(FUNC(hd64610_device::update_counter), this);
m_counter_timer->adjust(attotime::from_hz(clock() / 256), 0, attotime::from_hz(clock() / 256));
// state saving
@@ -185,37 +182,32 @@ void hd64610_device::device_start()
//-------------------------------------------------
-// device_timer - handler timer events
+// update_counter - update our count registers
//-------------------------------------------------
-void hd64610_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+TIMER_CALLBACK_MEMBER(hd64610_device::update_counter)
{
- switch (id)
+ if(m_hline_state || (m_regs[REG_CRB] & CRB_S))
{
- case TIMER_UPDATE_COUNTER:
- if(m_hline_state || (m_regs[REG_CRB] & CRB_S))
- {
- m_regs[REG_64HZ]++;
+ m_regs[REG_64HZ]++;
- if (m_regs[REG_64HZ] & 0x80)
- {
- // update seconds
- advance_seconds();
+ if (m_regs[REG_64HZ] & 0x80)
+ {
+ // update seconds
+ advance_seconds();
- // set carry flag
- m_regs[REG_CRA] |= CRA_CF;
+ // set carry flag
+ m_regs[REG_CRA] |= CRA_CF;
- m_regs[REG_64HZ] &= 0x7f;
- }
+ m_regs[REG_64HZ] &= 0x7f;
+ }
- // update 1Hz out
- m_out_1hz_cb(BIT(m_regs[REG_64HZ], 6));
+ // update 1Hz out
+ m_out_1hz_cb(BIT(m_regs[REG_64HZ], 6));
- // update IRQ
- check_alarm();
- set_irq_line();
- }
- break;
+ // update IRQ
+ check_alarm();
+ set_irq_line();
}
}
@@ -232,7 +224,7 @@ void hd64610_device::rtc_clock_updated(int year, int month, int day, int day_of_
write_counter(REG_DAY, day);
write_counter(REG_MONTH, month);
write_counter(REG_YEAR, year);
- m_regs[REG_DAY_OF_THE_WEEK] = day_of_week;
+ m_regs[REG_DAY_OF_THE_WEEK] = day_of_week - 1;
check_alarm();
set_irq_line();
@@ -255,9 +247,10 @@ void hd64610_device::nvram_default()
// .nv file
//-------------------------------------------------
-void hd64610_device::nvram_read(emu_file &file)
+bool hd64610_device::nvram_read(util::read_stream &file)
{
- file.read(m_regs, 0x10);
+ auto const [err, actual] = util::read(file, m_regs, 0x10);
+ return !err && (actual == 0x10);
}
@@ -266,9 +259,10 @@ void hd64610_device::nvram_read(emu_file &file)
// .nv file
//-------------------------------------------------
-void hd64610_device::nvram_write(emu_file &file)
+bool hd64610_device::nvram_write(util::write_stream &file)
{
- file.write(m_regs, 0x10);
+ auto const [err, actual] = util::write(file, m_regs, 0x10);
+ return !err;
}
@@ -276,7 +270,7 @@ void hd64610_device::nvram_write(emu_file &file)
// hardware start/stop
//-------------------------------------------------
-WRITE_LINE_MEMBER( hd64610_device::h_w )
+void hd64610_device::h_w(int state)
{
m_hline_state = state;
}
@@ -286,7 +280,7 @@ WRITE_LINE_MEMBER( hd64610_device::h_w )
// read -
//-------------------------------------------------
-READ8_MEMBER( hd64610_device::read )
+uint8_t hd64610_device::read(offs_t offset)
{
uint8_t data = m_regs[offset & 0x0f];
@@ -300,7 +294,7 @@ READ8_MEMBER( hd64610_device::read )
// write -
//-------------------------------------------------
-WRITE8_MEMBER( hd64610_device::write )
+void hd64610_device::write(offs_t offset, uint8_t data)
{
switch (offset & 0x0f)
{