From 1296414948623ffcffe01d2409fca6b927707131 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sun, 29 Jan 2017 21:14:23 +1100 Subject: [PATCH] dec0.cpp latch cleanup: 'LS374 sensed positive edge others are educted guesses --- src/mame/includes/dec0.h | 4 +-- src/mame/machine/dec0.cpp | 62 ++++++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/mame/includes/dec0.h b/src/mame/includes/dec0.h index b75982e295f..415ccb58174 100644 --- a/src/mame/includes/dec0.h +++ b/src/mame/includes/dec0.h @@ -54,8 +54,8 @@ public: optional_shared_ptr m_hippodrm_shared_ram; mcu_type m_game; - int m_i8751_return; - int m_i8751_command; + uint16_t m_i8751_return; + uint16_t m_i8751_command; int m_slyspy_state; int m_hippodrm_msb; int m_hippodrm_lsb; diff --git a/src/mame/machine/dec0.cpp b/src/mame/machine/dec0.cpp index 3e10ff56c18..4aef1d1dcff 100644 --- a/src/mame/machine/dec0.cpp +++ b/src/mame/machine/dec0.cpp @@ -10,7 +10,9 @@ Data East machine functions - Bryan McPhail, mish@tendril.co.uk #include "emu.h" #include "includes/dec0.h" + #include "cpu/h6280/h6280.h" +#include "cpu/m68000/m68000.h" #include "cpu/mcs51/mcs51.h" @@ -165,39 +167,35 @@ WRITE16_MEMBER(dec0_state::hippodrm_68000_share_w) READ8_MEMBER(dec0_state::dec0_mcu_port_r) { - int latchEnable=m_i8751_ports[2]>>4; + uint8_t result = 0xff; - // P0 connected to 4 latches - if (offset==0) + // P0 connected to latches + if (offset == 0) { - if ((latchEnable&1)==0) - return m_i8751_command>>8; - else if ((latchEnable&2)==0) - return m_i8751_command&0xff; - else if ((latchEnable&4)==0) - return m_i8751_return>>8; - else if ((latchEnable&8)==0) - return m_i8751_return&0xff; + if (!BIT(m_i8751_ports[2], 4)) + result &= m_i8751_command >> 8; + if (!BIT(m_i8751_ports[2], 5)) + result &= m_i8751_command & 0x00ff; } - return 0xff; + return result; } WRITE8_MEMBER(dec0_state::dec0_mcu_port_w) { - m_i8751_ports[offset]=data; - - if (offset==2) + if (offset == 2) { - if ((data&0x4)==0) - m_maincpu->set_input_line(5, HOLD_LINE); - if ((data&0x8)==0) + if (!BIT(data, 2) && BIT(m_i8751_ports[2], 2)) + m_maincpu->set_input_line(M68K_IRQ_5, HOLD_LINE); + if (!BIT(data, 3)) m_mcu->set_input_line(MCS51_INT1_LINE, CLEAR_LINE); - if ((data&0x40)==0) - m_i8751_return=(m_i8751_return&0xff00)|(m_i8751_ports[0]); - if ((data&0x80)==0) - m_i8751_return=(m_i8751_return&0xff)|(m_i8751_ports[0]<<8); + if (BIT(data, 6) && !BIT(m_i8751_ports[2], 6)) + m_i8751_return = (m_i8751_return & 0xff00) | m_i8751_ports[0]; + if (BIT(data, 7) && !BIT(m_i8751_ports[2], 7)) + m_i8751_return = (m_i8751_return & 0x00ff) | (m_i8751_ports[0] << 8); } + + m_i8751_ports[offset] = data; } void dec0_state::baddudes_i8751_write(int data) @@ -300,12 +298,22 @@ void dec0_state::birdtry_i8751_write(int data) void dec0_state::dec0_i8751_write(int data) { - m_i8751_command=data; + m_i8751_command = data; - /* Writes to this address cause an IRQ to the i8751 microcontroller */ - if (m_game == mcu_type::EMULATED) m_mcu->set_input_line(MCS51_INT1_LINE, ASSERT_LINE); - if (m_game == mcu_type::BADDUDES_SIM) baddudes_i8751_write(data); - if (m_game == mcu_type::BIRDTRY_SIM) birdtry_i8751_write(data); + /* Writes to this address raise an IRQ on the i8751 microcontroller */ + switch (m_game) + { + case mcu_type::EMULATED: + if (BIT(m_i8751_ports[2], 3)) + m_mcu->set_input_line(MCS51_INT1_LINE, ASSERT_LINE); + break; + case mcu_type::BADDUDES_SIM: + baddudes_i8751_write(data); + break; + case mcu_type::BIRDTRY_SIM: + birdtry_i8751_write(data); + break; + } //logerror("%s: warning - write %02x to i8751\n",machine().describe_context(),data); }