diff options
Diffstat (limited to 'src/devices/machine/er1400.cpp')
-rw-r--r-- | src/devices/machine/er1400.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/devices/machine/er1400.cpp b/src/devices/machine/er1400.cpp index a4eed0dacae..03b1df5036c 100644 --- a/src/devices/machine/er1400.cpp +++ b/src/devices/machine/er1400.cpp @@ -22,7 +22,7 @@ ***************************************************************************/ #include "emu.h" -#include "machine/er1400.h" +#include "er1400.h" #define VERBOSE 0 #include "logmacro.h" @@ -42,7 +42,7 @@ DEFINE_DEVICE_TYPE(ER1400, er1400_device, "er1400", "ER1400 Serial EAROM (100x14 er1400_device::er1400_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, ER1400, tag, owner, clock) , device_nvram_interface(mconfig, *this) - , m_default_data(*this, DEVICE_SELF, 100) + , m_default_data(*this, DEVICE_SELF) , m_clock_input(0) , m_code_input(0) , m_data_input(0) @@ -75,7 +75,7 @@ void er1400_device::device_start() m_data_array = std::make_unique<u16[]>(100); save_pointer(NAME(m_data_array), 100); - m_data_propagation_timer = timer_alloc(PROPAGATION_TIMER); + m_data_propagation_timer = timer_alloc(FUNC(er1400_device::propagate_data), this); } @@ -104,9 +104,12 @@ void er1400_device::nvram_default() // .nv file //------------------------------------------------- -void er1400_device::nvram_read(emu_file &file) +bool er1400_device::nvram_read(util::read_stream &file) { - file.read(&m_data_array[0], 100 * sizeof(m_data_array[0])); + size_t const size = 100 * sizeof(m_data_array[0]); + + auto const [err, actual] = read(file, &m_data_array[0], size); + return !err && (actual == size); } @@ -115,9 +118,12 @@ void er1400_device::nvram_read(emu_file &file) // specified file //------------------------------------------------- -void er1400_device::nvram_write(emu_file &file) +bool er1400_device::nvram_write(util::write_stream &file) { - file.write(&m_data_array[0], 100 * sizeof(m_data_array[0])); + size_t const size = 100 * sizeof(m_data_array[0]); + + auto const [err, actual] = write(file, &m_data_array[0], size); + return !err; } @@ -239,7 +245,7 @@ void er1400_device::erase_data() // data_w - write data input line //------------------------------------------------- -WRITE_LINE_MEMBER(er1400_device::data_w) +void er1400_device::data_w(int state) { m_data_input = bool(state); } @@ -249,7 +255,7 @@ WRITE_LINE_MEMBER(er1400_device::data_w) // c1_w - write to first control line //------------------------------------------------- -WRITE_LINE_MEMBER(er1400_device::c1_w) +void er1400_device::c1_w(int state) { if (bool(state) == BIT(m_code_input, 2)) return; @@ -264,7 +270,7 @@ WRITE_LINE_MEMBER(er1400_device::c1_w) // c2_w - write to second control line //------------------------------------------------- -WRITE_LINE_MEMBER(er1400_device::c2_w) +void er1400_device::c2_w(int state) { if (bool(state) == BIT(m_code_input, 1)) return; @@ -279,7 +285,7 @@ WRITE_LINE_MEMBER(er1400_device::c2_w) // c3_w - write to third control line //------------------------------------------------- -WRITE_LINE_MEMBER(er1400_device::c3_w) +void er1400_device::c3_w(int state) { if (bool(state) == BIT(m_code_input, 0)) return; @@ -291,24 +297,18 @@ WRITE_LINE_MEMBER(er1400_device::c3_w) //------------------------------------------------- -// device_timer - called whenever a device timer -// fires +// propagate_data - clock data out from the chip //------------------------------------------------- -void er1400_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(er1400_device::propagate_data) { - switch (id) + if (m_code_input == 5) { - case PROPAGATION_TIMER: - if (m_code_input == 5) - { - m_data_output = BIT(m_data_register, 13); - LOG("Data output %d bit\n", m_data_output); - } - else - m_data_output = false; - break; + m_data_output = BIT(m_data_register, 13); + LOG("Data output %d bit\n", m_data_output); } + else + m_data_output = false; } @@ -316,14 +316,14 @@ void er1400_device::device_timer(emu_timer &timer, device_timer_id id, int param // clock_w - write to clock line //------------------------------------------------- -WRITE_LINE_MEMBER(er1400_device::clock_w) +void er1400_device::clock_w(int state) { if (m_clock_input == bool(state)) return; m_clock_input = bool(state); // Commands are clocked by a logical 1 -> 0 transition (i.e. rising edge) - if (!state) + if (state) { if (machine().time() >= m_write_time) write_data(); @@ -396,7 +396,7 @@ WRITE_LINE_MEMBER(er1400_device::clock_w) // data_r - read data line //------------------------------------------------- -READ_LINE_MEMBER(er1400_device::data_r) +int er1400_device::data_r() { - return m_data_input | m_data_output; + return m_data_input & m_data_output; } |