diff options
Diffstat (limited to 'src/devices/machine/er2055.cpp')
-rw-r--r-- | src/devices/machine/er2055.cpp | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/src/devices/machine/er2055.cpp b/src/devices/machine/er2055.cpp index 1c338fbaa3d..c25fbb498fc 100644 --- a/src/devices/machine/er2055.cpp +++ b/src/devices/machine/er2055.cpp @@ -11,6 +11,8 @@ #include "emu.h" #include "machine/er2055.h" +#include "logmacro.h" + //************************************************************************** // GLOBAL VARIABLES @@ -138,11 +140,11 @@ void er2055_device::nvram_write(emu_file &file) // reacts to various combinations //------------------------------------------------- -void er2055_device::set_control(uint8_t cs1, uint8_t cs2, uint8_t c1, uint8_t c2, uint8_t ck) +void er2055_device::set_control(uint8_t cs1, uint8_t cs2, uint8_t c1, uint8_t c2) { // create a new composite control state uint8_t oldstate = m_control_state; - m_control_state = (ck != 0) ? CK : 0; + m_control_state = oldstate & CK; m_control_state |= (c1 != 0) ? C1 : 0; m_control_state |= (c2 != 0) ? C2 : 0; m_control_state |= (cs1 != 0) ? CS1 : 0; @@ -152,29 +154,60 @@ void er2055_device::set_control(uint8_t cs1, uint8_t cs2, uint8_t c1, uint8_t c2 if ((m_control_state & (CS1 | CS2)) != (CS1 | CS2) || m_control_state == oldstate) return; - // something changed, see what it is based on what mode we're in + update_state(); +} + + +//------------------------------------------------- +// update_state - update internal state following +// a transition on clock, control or chip select +// lines based on what mode we're in +//------------------------------------------------- + +void er2055_device::update_state() +{ switch (m_control_state & (C1 | C2)) { // write mode; erasing is required, so we perform an AND against previous // data to simulate incorrect behavior if erasing was not done case 0: space(AS_PROGRAM).write_byte(m_address, space(AS_PROGRAM).read_byte(m_address) & m_data); -//printf("Write %02X = %02X\n", m_address, m_data); + LOG("Write %02X = %02X\n", m_address, m_data); break; // erase mode case C2: space(AS_PROGRAM).write_byte(m_address, 0xff); -//printf("Erase %02X\n", m_address); + LOG("Erase %02X\n", m_address); break; + } +} - // read mode - case C1: - if ((oldstate & CK) != 0 && (m_control_state & CK) == 0) - { - m_data = space(AS_PROGRAM).read_byte(m_address); -//printf("Read %02X = %02X\n", m_address, m_data); - } - break; + +//------------------------------------------------- +// set_clk - set the CLK line, pulses on which +// are required for every read operation and for +// successive write or erase operations +//------------------------------------------------- + +WRITE_LINE_MEMBER(er2055_device::set_clk) +{ + uint8_t oldstate = m_control_state; + if (state) + m_control_state |= CK; + else + m_control_state &= ~CK; + + // updates occur on falling edge when chip is selected + if ((m_control_state & (CS1 | CS2)) == (CS1 | CS2) && (m_control_state != oldstate) && !state) + { + // read mode (C2 is "Don't Care") + if ((m_control_state & C1) == C1) + { + m_data = space(AS_PROGRAM).read_byte(m_address); + LOG("Read %02X = %02X\n", m_address, m_data); + } + + update_state(); } } |