From 4e34735d0fd42a0b0f8d749d91bfa10663914715 Mon Sep 17 00:00:00 2001 From: AJR Date: Sat, 23 Oct 2021 20:19:42 -0400 Subject: rgum.cpp: Improve peripheral hookups; add uPD7759 controls --- src/mame/drivers/rgum.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 8 deletions(-) diff --git a/src/mame/drivers/rgum.cpp b/src/mame/drivers/rgum.cpp index 7a1adea5261..4d27e145dc0 100644 --- a/src/mame/drivers/rgum.cpp +++ b/src/mame/drivers/rgum.cpp @@ -43,6 +43,8 @@ public: m_vram(*this, "vram"), m_cram(*this, "cram"), m_maincpu(*this, "maincpu"), + m_aysnd(*this, "aysnd"), + m_upd(*this, "upd"), m_gfxdecode(*this, "gfxdecode"), m_palette(*this, "palette") { } @@ -52,14 +54,26 @@ public: protected: virtual void video_start() override; + virtual void machine_reset() override; private: required_shared_ptr m_vram; required_shared_ptr m_cram; required_device m_maincpu; + required_device m_aysnd; + required_device m_upd; required_device m_gfxdecode; required_device m_palette; uint8_t m_hbeat; + bool m_aysnd_data_next; + bool m_aysnd_toggle_enabled; + + void aysnd_2000_w(uint8_t data); + void aysnd_2002_w(uint8_t data); + void upd_data_w(uint8_t data); + uint8_t upd_ready_r(); + uint8_t upd_busy_r(); + uint8_t upd_reset_r(); uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); void main_map(address_map &map); @@ -71,6 +85,14 @@ void rgum_state::video_start() m_hbeat = 0; save_item(NAME(m_hbeat)); + save_item(NAME(m_aysnd_data_next)); + save_item(NAME(m_aysnd_toggle_enabled)); +} + +void rgum_state::machine_reset() +{ + m_aysnd_data_next = false; + m_aysnd_toggle_enabled = false; } uint32_t rgum_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) @@ -94,6 +116,51 @@ uint32_t rgum_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, return 0; } +void rgum_state::aysnd_2000_w(uint8_t data) +{ + m_aysnd_toggle_enabled = true; +} + +void rgum_state::aysnd_2002_w(uint8_t data) +{ + // AY-3-8910 interface is bizarre. Address is written to $2000 and then $2002 with successive instructions, then data is written to both $2000 and $2002. + // Sound data contains many pairs where the address byte is $50. Do these control some other device? + m_aysnd->address_data_w(m_aysnd_data_next, data); + if (m_aysnd_toggle_enabled) + { + m_aysnd_data_next = !m_aysnd_data_next; + m_aysnd_toggle_enabled = false; + } +} + +void rgum_state::upd_data_w(u8 data) +{ + m_upd->port_w(data); + m_upd->start_w(1); +} + +uint8_t rgum_state::upd_ready_r() +{ + if (!machine().side_effects_disabled()) + { + m_upd->reset_w(1); + m_upd->start_w(0); + } + return 0; +} + +uint8_t rgum_state::upd_busy_r() +{ + return m_upd->busy_r() ? 0x80 : 0; +} + +uint8_t rgum_state::upd_reset_r() +{ + if (!machine().side_effects_disabled()) + m_upd->reset_w(0); + return 0; +} + void rgum_state::main_map(address_map &map) // TODO: map MK48Z08B-10, second 8255, UPD7759 { map(0x0000, 0x07ff).ram(); // not all of it? @@ -101,14 +168,15 @@ void rgum_state::main_map(address_map &map) // TODO: map MK48Z08B-10, second 825 map(0x0800, 0x0800).w("crtc", FUNC(mc6845_device::address_w)); map(0x0801, 0x0801).rw("crtc", FUNC(mc6845_device::register_r), FUNC(mc6845_device::register_w)); - map(0x2000, 0x2000).w("aysnd", FUNC(ay8910_device::data_w)); - map(0x2002, 0x2002).rw("aysnd", FUNC(ay8910_device::data_r), FUNC(ay8910_device::address_w)); + map(0x2000, 0x2000).w(FUNC(rgum_state::aysnd_2000_w)); + map(0x2002, 0x2002).r("aysnd", FUNC(ay8910_device::data_r)).w(FUNC(rgum_state::aysnd_2002_w)); - map(0x2801, 0x2801).nopr(); // read but value discarded? - map(0x2802, 0x2802).nopr(); - map(0x2803, 0x2803).nopr(); + map(0x2800, 0x2800).w(FUNC(rgum_state::upd_data_w)); + map(0x2801, 0x2801).r(FUNC(rgum_state::upd_ready_r)); + map(0x2802, 0x2802).r(FUNC(rgum_state::upd_busy_r)); + map(0x2803, 0x2803).r(FUNC(rgum_state::upd_reset_r)); - // map(0x2c00, 0x2c03).w(); // ? + map(0x2c00, 0x2c03).w("ppi8255_1", FUNC(i8255_device::write)); map(0x3000, 0x3003).rw("ppi8255_0", FUNC(i8255_device::read), FUNC(i8255_device::write)); @@ -121,8 +189,6 @@ void rgum_state::main_map(address_map &map) // TODO: map MK48Z08B-10, second 825 READ_LINE_MEMBER(rgum_state::heartbeat_r) { - m_hbeat ^= 1; - return m_hbeat; } @@ -289,6 +355,7 @@ void rgum_state::rgum(machine_config &config) ppi.in_pa_callback().set_ioport("IN0"); ppi.in_pb_callback().set_ioport("DSW1"); ppi.in_pc_callback().set_ioport("DSW2"); + ppi.out_pc_callback().set([this](uint8_t data) { m_hbeat = BIT(data, 0); }); I8255A(config, "ppi8255_1"); -- cgit v1.2.3