diff options
author | 2017-01-03 01:09:26 +0100 | |
---|---|---|
committer | 2017-01-03 01:10:55 +0100 | |
commit | d25721b3f33ed83274a9a98b82605eeff0724e07 (patch) | |
tree | c00d37bc3aa60a3b59cdca2f82687e10b73e9cff /src/devices/machine/gen_latch.cpp | |
parent | 3d59f6fc1b11917f4b5aa4164aae2014e2c0fa22 (diff) |
gen_latch: Invert logic (latch_read -> latch_written).
Also fixes initial callback after start.
Diffstat (limited to 'src/devices/machine/gen_latch.cpp')
-rw-r--r-- | src/devices/machine/gen_latch.cpp | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/src/devices/machine/gen_latch.cpp b/src/devices/machine/gen_latch.cpp index 7be65c67943..f41f6df5fca 100644 --- a/src/devices/machine/gen_latch.cpp +++ b/src/devices/machine/gen_latch.cpp @@ -26,7 +26,7 @@ const device_type GENERIC_LATCH_16 = &device_creator<generic_latch_16_device>; generic_latch_base_device::generic_latch_base_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source) : device_t(mconfig, type, name, tag, owner, clock, shortname, source), - m_latch_read(false), + m_latch_written(false), m_data_pending_cb(*this) { } @@ -38,7 +38,16 @@ generic_latch_base_device::generic_latch_base_device(const machine_config &mconf void generic_latch_base_device::device_start() { m_data_pending_cb.resolve_safe(); - save_item(NAME(m_latch_read)); + save_item(NAME(m_latch_written)); +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void generic_latch_base_device::device_reset() +{ + m_latch_written = false; } //------------------------------------------------- @@ -48,20 +57,20 @@ void generic_latch_base_device::device_start() READ_LINE_MEMBER(generic_latch_base_device::pending_r) { - return !m_latch_read; + return m_latch_written ? 1 : 0; } //------------------------------------------------- -// set_latch_read - helper to signal that latch -// has been read or is waiting to be read +// set_latch_written - helper to signal that latch +// has been written or has been read //------------------------------------------------- -void generic_latch_base_device::set_latch_read(bool latch_read) +void generic_latch_base_device::set_latch_written(bool latch_written) { - if (m_latch_read != latch_read) + if (m_latch_written != latch_written) { - m_latch_read = latch_read; - m_data_pending_cb(!latch_read); + m_latch_written = latch_written; + m_data_pending_cb(latch_written ? 1 : 0); } } @@ -77,7 +86,7 @@ generic_latch_8_device::generic_latch_8_device(const machine_config &mconfig, co READ8_MEMBER( generic_latch_8_device::read ) { - set_latch_read(true); + set_latch_written(false); return m_latched_value; } @@ -115,13 +124,13 @@ void generic_latch_8_device::sync_callback(void *ptr, s32 param) { u8 value = param; - // if the latch hasn't been read and the value is changed, log a warning - if (!is_latch_read() && m_latched_value != value) + // if the latch has been written and the value is changed, log a warning + if (is_latch_written() && m_latched_value != value) logerror("Warning: latch written before being read. Previous: %02x, new: %02x\n", m_latched_value, value); // store the new value and mark it not read m_latched_value = value; - set_latch_read(false); + set_latch_written(true); } //------------------------------------------------- @@ -147,7 +156,7 @@ generic_latch_16_device::generic_latch_16_device(const machine_config &mconfig, READ16_MEMBER( generic_latch_16_device::read ) { - set_latch_read(true); + set_latch_written(false); return m_latched_value; } @@ -185,13 +194,13 @@ void generic_latch_16_device::sync_callback(void *ptr, s32 param) { u16 value = param; - // if the latch hasn't been read and the value is changed, log a warning - if (!is_latch_read() && m_latched_value != value) + // if the latch has been written and the value is changed, log a warning + if (is_latch_written() && m_latched_value != value) logerror("Warning: latch written before being read. Previous: %02x, new: %02x\n", m_latched_value, value); // store the new value and mark it not read m_latched_value = value; - set_latch_read(false); + set_latch_written(true); } //------------------------------------------------- |