From 880f2b7ae1582db69443e922880ecd1ab1096eb0 Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 6 Oct 2019 21:09:40 -0400 Subject: [PATCH] stadhero: Make stage music selection and various other things more random --- src/mame/drivers/stadhero.cpp | 18 +++++++++++------- src/mame/includes/stadhero.h | 4 ++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/mame/drivers/stadhero.cpp b/src/mame/drivers/stadhero.cpp index 1015a6c44a6..c5b66a9551a 100644 --- a/src/mame/drivers/stadhero.cpp +++ b/src/mame/drivers/stadhero.cpp @@ -32,7 +32,6 @@ TODO : RNG issue? Some behavior isn't correct (ex: BGM randomizer). #include "sound/3812intf.h" #include "sound/okim6295.h" #include "emupal.h" -#include "screen.h" #include "speaker.h" @@ -43,6 +42,13 @@ WRITE16_MEMBER(stadhero_state::int_ack_w) m_maincpu->set_input_line(M68K_IRQ_5, CLEAR_LINE); } +uint8_t stadhero_state::mystery_r() +{ + // Polled, very frequently at times, to randomly determine stage music + // selection, attract mode teams, base-stealing attempts, etc. etc. + return m_screen->hpos() / 2; +} + /******************************************************************************/ @@ -54,7 +60,8 @@ void stadhero_state::main_map(address_map &map) map(0x240010, 0x240017).w(m_tilegen, FUNC(deco_bac06_device::pf_control_1_w)); map(0x260000, 0x261fff).rw(m_tilegen, FUNC(deco_bac06_device::pf_data_r), FUNC(deco_bac06_device::pf_data_w)); map(0x30c000, 0x30c001).portr("INPUTS"); - map(0x30c002, 0x30c003).lr8("30c002", [this]() { return uint8_t(m_coin->read()); }); + map(0x30c002, 0x30c002).lr8("30c002", [this]() { return uint8_t(m_coin->read()); }); + map(0x30c003, 0x30c003).r(FUNC(stadhero_state::mystery_r)); map(0x30c004, 0x30c005).portr("DSW").w(FUNC(stadhero_state::int_ack_w)); map(0x30c007, 0x30c007).w(m_soundlatch, FUNC(generic_latch_8_device::write)); map(0x310000, 0x3107ff).ram().w("palette", FUNC(palette_device::write16)).share("palette"); @@ -132,11 +139,8 @@ static INPUT_PORTS_START( stadhero ) PORT_DIPUNUSED( 0x4000, IP_ACTIVE_LOW ) PORT_DIPUNUSED( 0x8000, IP_ACTIVE_LOW ) - PORT_START("COIN") /* 0x30c002 & 0x30c003 */ - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* related to music/sound */ - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* related to music/sound */ - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* related to music/sound */ - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* related to music/sound */ + PORT_START("COIN") /* 0x30c002 */ + PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) diff --git a/src/mame/includes/stadhero.h b/src/mame/includes/stadhero.h index e741c6444c9..3531fd165a1 100644 --- a/src/mame/includes/stadhero.h +++ b/src/mame/includes/stadhero.h @@ -4,6 +4,7 @@ #include "machine/gen_latch.h" #include "video/decbac06.h" #include "video/decmxc06.h" +#include "screen.h" #include "tilemap.h" class stadhero_state : public driver_device @@ -17,6 +18,7 @@ public: m_spritegen(*this, "spritegen"), m_gfxdecode(*this, "gfxdecode"), m_soundlatch(*this, "soundlatch"), + m_screen(*this, "screen"), m_spriteram(*this, "spriteram"), m_pf1_data(*this, "pf1_data"), m_coin(*this, "COIN") @@ -32,6 +34,7 @@ private: required_device m_spritegen; required_device m_gfxdecode; required_device m_soundlatch; + required_device m_screen; required_shared_ptr m_spriteram; required_shared_ptr m_pf1_data; @@ -42,6 +45,7 @@ private: DECLARE_WRITE16_MEMBER(int_ack_w); DECLARE_WRITE16_MEMBER(pf1_data_w); + uint8_t mystery_r(); virtual void video_start() override;