diff options
Diffstat (limited to 'src/devices/machine/ds2430a.cpp')
-rw-r--r-- | src/devices/machine/ds2430a.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/devices/machine/ds2430a.cpp b/src/devices/machine/ds2430a.cpp index ba7926432e7..fca443e76a1 100644 --- a/src/devices/machine/ds2430a.cpp +++ b/src/devices/machine/ds2430a.cpp @@ -39,16 +39,18 @@ #include "ds2430a.h" #include <numeric> // std::accumulate +#include <tuple> // std::tie #define LOG_PULSE (1U << 1) #define LOG_BITS (1U << 2) #define LOG_STATE (1U << 3) #define LOG_DATA (1U << 4) #define LOG_COMMAND (1U << 5) -#define VERBOSE (0) +#define VERBOSE (0) #include "logmacro.h" + //************************************************************************** // GLOBAL VARIABLES //************************************************************************** @@ -457,15 +459,18 @@ void ds2430a_device::device_start() bool ds2430a_device::nvram_read(util::read_stream &file) { + std::error_condition err; size_t actual; - if (file.read(&m_eeprom[0], 0x20, actual) || actual != 0x20) + std::tie(err, actual) = read(file, &m_eeprom[0], 0x20); + if (err || (0x20 != actual)) return false; - if (file.read(&m_rom[0], 8, actual) || actual != 8) + std::tie(err, actual) = read(file, &m_rom[0], 8); + if (err || (8 != actual)) return false; if (m_rom[0] != 0x14) osd_printf_error("Incorrect ROM family code (expected 14h, found %02Xh in saved data)\n", m_rom[0]); - u8 crc = std::accumulate(std::begin(m_rom), std::end(m_rom) - 1, u8(0), &ds1wire_crc); + u8 const crc = std::accumulate(std::begin(m_rom), std::end(m_rom) - 1, u8(0), &ds1wire_crc); if (m_rom[7] != crc) osd_printf_error("Incorrect ROM CRC (expected %02Xh, found %02Xh in saved data)\n", crc, m_rom[7]); @@ -480,10 +485,13 @@ bool ds2430a_device::nvram_read(util::read_stream &file) bool ds2430a_device::nvram_write(util::write_stream &file) { + std::error_condition err; size_t actual; - if (file.write(&m_eeprom[0], 0x20, actual) || actual != 0x20) + std::tie(err, actual) = write(file, &m_eeprom[0], 0x20); + if (err) return false; - if (file.write(&m_rom[0], 8, actual) || actual != 8) + std::tie(err, actual) = write(file, &m_rom[0], 8); + if (err) return false; return true; |