summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/hvyunit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/hvyunit.cpp')
-rw-r--r--src/mame/drivers/hvyunit.cpp65
1 files changed, 17 insertions, 48 deletions
diff --git a/src/mame/drivers/hvyunit.cpp b/src/mame/drivers/hvyunit.cpp
index 3dd8fb8f6c5..ab64e3d769f 100644
--- a/src/mame/drivers/hvyunit.cpp
+++ b/src/mame/drivers/hvyunit.cpp
@@ -89,6 +89,8 @@ public:
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_soundlatch(*this, "soundlatch"),
+ m_mermaidlatch(*this, "mermaidlatch"),
+ m_slavelatch(*this, "slavelatch"),
m_videoram(*this, "videoram"),
m_colorram(*this, "colorram")
{ }
@@ -102,6 +104,8 @@ public:
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
required_device<generic_latch_8_device> m_soundlatch;
+ required_device<generic_latch_8_device> m_mermaidlatch;
+ required_device<generic_latch_8_device> m_slavelatch;
/* Video */
required_shared_ptr<uint8_t> m_videoram;
@@ -112,17 +116,10 @@ public:
uint16_t m_port0_data;
/* Mermaid */
- uint8_t m_data_to_mermaid;
- uint8_t m_data_to_z80;
- uint8_t m_mermaid_to_z80_full;
- uint8_t m_z80_to_mermaid_full;
- uint8_t m_mermaid_int0_l;
uint8_t m_mermaid_p[4];
DECLARE_WRITE8_MEMBER(trigger_nmi_on_slave_cpu);
DECLARE_WRITE8_MEMBER(master_bankswitch_w);
- DECLARE_WRITE8_MEMBER(mermaid_data_w);
- DECLARE_READ8_MEMBER(mermaid_data_r);
DECLARE_READ8_MEMBER(mermaid_status_r);
DECLARE_WRITE8_MEMBER(trigger_nmi_on_sound_cpu2);
DECLARE_WRITE8_MEMBER(hu_videoram_w);
@@ -166,19 +163,11 @@ void hvyunit_state::machine_start()
membank("slave_bank")->configure_entries(0, 4, memregion("slave")->base(), 0x4000);
membank("sound_bank")->configure_entries(0, 4, memregion("soundcpu")->base(), 0x4000);
- save_item(NAME(m_data_to_mermaid));
- save_item(NAME(m_data_to_z80));
- save_item(NAME(m_mermaid_to_z80_full));
- save_item(NAME(m_z80_to_mermaid_full));
- save_item(NAME(m_mermaid_int0_l));
save_item(NAME(m_mermaid_p));
}
void hvyunit_state::machine_reset()
{
- m_mermaid_int0_l = 1;
- m_mermaid_to_z80_full = 0;
- m_z80_to_mermaid_full = 0;
}
@@ -246,23 +235,9 @@ WRITE8_MEMBER(hvyunit_state::master_bankswitch_w)
membank("master_bank")->set_entry(data & 7);
}
-WRITE8_MEMBER(hvyunit_state::mermaid_data_w)
-{
- m_data_to_mermaid = data;
- m_z80_to_mermaid_full = 1;
- m_mermaid_int0_l = 0;
- m_mermaid->set_input_line(INPUT_LINE_IRQ0, ASSERT_LINE);
-}
-
-READ8_MEMBER(hvyunit_state::mermaid_data_r)
-{
- m_mermaid_to_z80_full = 0;
- return m_data_to_z80;
-}
-
READ8_MEMBER(hvyunit_state::mermaid_status_r)
{
- return (!m_mermaid_to_z80_full << 2) | (m_z80_to_mermaid_full << 3);
+ return (!m_slavelatch->pending_r() << 2) | (m_mermaidlatch->pending_r() << 3);
}
@@ -340,33 +315,21 @@ READ8_MEMBER(hvyunit_state::mermaid_p0_r)
WRITE8_MEMBER(hvyunit_state::mermaid_p0_w)
{
if (!BIT(m_mermaid_p[0], 1) && BIT(data, 1))
- {
- m_mermaid_to_z80_full = 1;
- m_data_to_z80 = m_mermaid_p[1];
- }
+ m_slavelatch->write(space, 0, m_mermaid_p[1]);
- if (BIT(data, 0) == 1)
- m_z80_to_mermaid_full = 0;
+ if (BIT(data, 0) == 0)
+ m_mermaid_p[1] = m_mermaidlatch->read(space, 0);
m_mermaid_p[0] = data;
}
READ8_MEMBER(hvyunit_state::mermaid_p1_r)
{
- if (BIT(m_mermaid_p[0], 0) == 0)
- return m_data_to_mermaid;
- else
- return 0; // ?
+ return m_mermaid_p[1];
}
WRITE8_MEMBER(hvyunit_state::mermaid_p1_w)
{
- if (data == 0xff)
- {
- m_mermaid_int0_l = 1;
- m_mermaid->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE);
- }
-
m_mermaid_p[1] = data;
}
@@ -400,7 +363,7 @@ READ8_MEMBER(hvyunit_state::mermaid_p3_r)
case 3: dsw = (BIT(dsw2, 7) << 3) | (BIT(dsw2, 3) << 2) | (BIT(dsw1, 7) << 1) | BIT(dsw1, 3); break;
}
- return (dsw << 4) | (m_mermaid_int0_l << 2) | (m_mermaid_to_z80_full << 3);
+ return (dsw << 4) | (m_slavelatch->pending_r() << 3) | (!m_mermaidlatch->pending_r() << 2);
}
WRITE8_MEMBER(hvyunit_state::mermaid_p3_w)
@@ -447,7 +410,8 @@ static ADDRESS_MAP_START( slave_io, AS_IO, 8, hvyunit_state )
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE(0x00, 0x00) AM_WRITE(slave_bankswitch_w)
AM_RANGE(0x02, 0x02) AM_WRITE(trigger_nmi_on_sound_cpu2)
- AM_RANGE(0x04, 0x04) AM_READWRITE(mermaid_data_r, mermaid_data_w)
+ AM_RANGE(0x04, 0x04) AM_DEVREAD("slavelatch", generic_latch_8_device, read)
+ AM_RANGE(0x04, 0x04) AM_DEVWRITE("mermaidlatch", generic_latch_8_device, write)
AM_RANGE(0x06, 0x06) AM_WRITE(hu_scrolly_w)
AM_RANGE(0x08, 0x08) AM_WRITE(hu_scrollx_w)
AM_RANGE(0x0c, 0x0c) AM_READ(mermaid_status_r)
@@ -664,6 +628,11 @@ static MACHINE_CONFIG_START( hvyunit )
MCFG_CPU_ADD("mermaid", I80C51, 6000000)
MCFG_CPU_IO_MAP(mcu_io)
+ MCFG_GENERIC_LATCH_8_ADD("mermaidlatch")
+ MCFG_GENERIC_LATCH_DATA_PENDING_CB(INPUTLINE("mermaid", INPUT_LINE_IRQ0))
+
+ MCFG_GENERIC_LATCH_8_ADD("slavelatch")
+
MCFG_QUANTUM_TIME(attotime::from_hz(6000))
MCFG_SCREEN_ADD("screen", RASTER)