From 71d7a8ff686dc4ac45c773eaf18da141d90b88cb Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sat, 23 Feb 2019 01:17:16 +1100 Subject: magic numbers are bad, untested changes are worse (nw) --- src/devices/machine/timekpr.cpp | 12 +++--------- src/devices/machine/timekpr.h | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/devices/machine/timekpr.cpp b/src/devices/machine/timekpr.cpp index 66c83ab2046..614f071ade7 100644 --- a/src/devices/machine/timekpr.cpp +++ b/src/devices/machine/timekpr.cpp @@ -69,21 +69,15 @@ DEFINE_DEVICE_TYPE(MK48T12, mk48t12_device, "mk48t12", "MK48T12 Timekeeper") INLINE FUNCTIONS ***************************************************************************/ -static void counter_to_ram(u8 *data, u32 offset, u8 counter) +inline void counter_to_ram(u8 *data, s32 offset, u8 counter) { if (offset >= 0) - { data[offset] = counter; - } } -static int counter_from_ram(u8 *data, u32 offset) +inline int counter_from_ram(u8 const *data, s32 offset, u8 unmap = 0) { - if (offset >= 0) - { - return data[offset]; - } - return 0; + return (offset >= 0) ? data[offset] : unmap; } //************************************************************************** diff --git a/src/devices/machine/timekpr.h b/src/devices/machine/timekpr.h index e4e1803b5a4..def60c02059 100644 --- a/src/devices/machine/timekpr.h +++ b/src/devices/machine/timekpr.h @@ -79,17 +79,17 @@ private: attotime m_watchdog_delay; protected: u32 const m_size; - u32 m_offset_watchdog; - u32 m_offset_control; - u32 m_offset_seconds; - u32 m_offset_minutes; - u32 m_offset_hours; - u32 m_offset_day; - u32 m_offset_date; - u32 m_offset_month; - u32 m_offset_year; - u32 m_offset_century; - u32 m_offset_flags; + s32 m_offset_watchdog; + s32 m_offset_control; + s32 m_offset_seconds; + s32 m_offset_minutes; + s32 m_offset_hours; + s32 m_offset_day; + s32 m_offset_date; + s32 m_offset_month; + s32 m_offset_year; + s32 m_offset_century; + s32 m_offset_flags; }; class m48t02_device : public timekeeper_device -- cgit v1.2.3