From 1d0f8adaf8c1fd3d2dcf33daec19268da588e85e Mon Sep 17 00:00:00 2001 From: hap Date: Tue, 12 Dec 2023 20:31:16 +0100 Subject: hh*: same cpuclock refactor as prev commit --- src/mame/handheld/hh_hmcs40.cpp | 20 ++---- src/mame/handheld/hh_pic16.cpp | 20 ++---- src/mame/handheld/hh_tms1k.cpp | 138 ++++++++++------------------------------ src/mame/handheld/hh_ucom4.cpp | 22 ++----- 4 files changed, 52 insertions(+), 148 deletions(-) diff --git a/src/mame/handheld/hh_hmcs40.cpp b/src/mame/handheld/hh_hmcs40.cpp index 21aa56066bf..98995a25d11 100644 --- a/src/mame/handheld/hh_hmcs40.cpp +++ b/src/mame/handheld/hh_hmcs40.cpp @@ -3348,17 +3348,15 @@ public: void eturtles(machine_config &config); DECLARE_INPUT_CHANGED_MEMBER(input_changed) { update_int(); } - DECLARE_INPUT_CHANGED_MEMBER(game_speed) { set_clock(); } + DECLARE_INPUT_CHANGED_MEMBER(game_speed); protected: virtual void machine_start() override; - virtual void machine_reset() override; required_device m_audiocpu; u8 m_cop_irq = 0; - void set_clock(); void update_int(); virtual void update_display(); void plate_w(offs_t offset, u8 data); @@ -3376,18 +3374,12 @@ void eturtles_state::machine_start() save_item(NAME(m_cop_irq)); } -void eturtles_state::machine_reset() -{ - hh_hmcs40_state::machine_reset(); - set_clock(); -} - // handlers: maincpu side -void eturtles_state::set_clock() +INPUT_CHANGED_MEMBER(eturtles_state::game_speed) { // maincpu clock is controlled by game speed knob, range is around 150kHz - m_maincpu->set_unscaled_clock(m_inputs[6]->read() * 1500 + 325000); + m_maincpu->set_unscaled_clock(newval * 1500 + 325000); } void eturtles_state::update_display() @@ -3490,7 +3482,7 @@ static INPUT_PORTS_START( eturtles ) PORT_CONFSETTING( 0x00, "1" ) PORT_CONFSETTING( 0x01, "2" ) - PORT_START("IN.6") + PORT_START("CPU") PORT_ADJUSTER(50, "Game Speed") PORT_CHANGED_MEMBER(DEVICE_SELF, eturtles_state, game_speed, 0) INPUT_PORTS_END @@ -3499,7 +3491,7 @@ INPUT_PORTS_END void eturtles_state::eturtles(machine_config &config) { // basic machine hardware - HD38820(config, m_maincpu, 400000); // see set_clock + HD38820(config, m_maincpu, 400000); // see game_speed m_maincpu->write_r<0>().set(FUNC(eturtles_state::plate_w)); m_maincpu->write_r<1>().set(FUNC(eturtles_state::plate_w)); m_maincpu->write_r<2>().set(FUNC(eturtles_state::plate_w)); @@ -3640,7 +3632,7 @@ INPUT_PORTS_END void estargte_state::estargte(machine_config &config) { // basic machine hardware - HD38820(config, m_maincpu, 400000); // see set_clock + HD38820(config, m_maincpu, 400000); // see game_speed m_maincpu->write_r<0>().set(FUNC(estargte_state::plate_w)); m_maincpu->write_r<1>().set(FUNC(estargte_state::plate_w)); m_maincpu->write_r<2>().set(FUNC(estargte_state::plate_w)); diff --git a/src/mame/handheld/hh_pic16.cpp b/src/mame/handheld/hh_pic16.cpp index c06d6b74d97..31f1fe4e4eb 100644 --- a/src/mame/handheld/hh_pic16.cpp +++ b/src/mame/handheld/hh_pic16.cpp @@ -1024,31 +1024,21 @@ public: void matchme(machine_config &config); - DECLARE_INPUT_CHANGED_MEMBER(speed_switch) { set_clock(); } - -protected: - virtual void machine_reset() override; + DECLARE_INPUT_CHANGED_MEMBER(speed_switch); private: - void set_clock(); void write_b(u8 data); void write_c(u8 data); u8 read_c(); }; -void matchme_state::machine_reset() -{ - hh_pic16_state::machine_reset(); - set_clock(); -} - // handlers -void matchme_state::set_clock() +INPUT_CHANGED_MEMBER(matchme_state::speed_switch) { // MCU clock is ~1.2MHz by default (R=18K, C=15pF), high speed setting adds a // 10pF cap to speed it up by about 7.5%. - m_maincpu->set_unscaled_clock((m_inputs[4]->read() & 1) ? 1300000 : 1200000); + m_maincpu->set_unscaled_clock((newval & 1) ? 1300000 : 1200000); } void matchme_state::write_b(u8 data) @@ -1111,7 +1101,7 @@ static INPUT_PORTS_START( matchme ) PORT_CONFSETTING( 0x08, "Amateur" ) // AM PORT_CONFSETTING( 0x00, "Professional" ) // PRO - PORT_START("IN.4") // another fake + PORT_START("CPU") // another fake PORT_CONFNAME( 0x01, 0x00, "Speed" ) PORT_CHANGED_MEMBER(DEVICE_SELF, matchme_state, speed_switch, 0) PORT_CONFSETTING( 0x00, DEF_STR( Low ) ) PORT_CONFSETTING( 0x01, DEF_STR( High ) ) @@ -1128,7 +1118,7 @@ INPUT_PORTS_END void matchme_state::matchme(machine_config &config) { // basic machine hardware - PIC1655(config, m_maincpu, 1200000); // see set_clock + PIC1655(config, m_maincpu, 1200000); // see speed_switch m_maincpu->read_a().set_ioport("IN.3"); m_maincpu->write_b().set(FUNC(matchme_state::write_b)); m_maincpu->read_c().set(FUNC(matchme_state::read_c)); diff --git a/src/mame/handheld/hh_tms1k.cpp b/src/mame/handheld/hh_tms1k.cpp index 0906d3975e5..49d3a90625a 100644 --- a/src/mame/handheld/hh_tms1k.cpp +++ b/src/mame/handheld/hh_tms1k.cpp @@ -2802,32 +2802,22 @@ public: void h2hbaseb(machine_config &config); - DECLARE_INPUT_CHANGED_MEMBER(skill_switch) { set_clock(); } - -protected: - virtual void machine_reset() override; + DECLARE_INPUT_CHANGED_MEMBER(skill_switch); private: - void set_clock(); void update_display(); void write_r(u32 data); void write_o(u16 data); u8 read_k(); }; -void h2hbaseb_state::machine_reset() -{ - hh_tms1k_state::machine_reset(); - set_clock(); -} - // handlers -void h2hbaseb_state::set_clock() +INPUT_CHANGED_MEMBER(h2hbaseb_state::skill_switch) { // MCU clock is from an RC circuit with C=47pF, and R value is depending on // skill switch: R=51K(1) or 43K(2) - m_maincpu->set_unscaled_clock((m_inputs[5]->read() & 1) ? 400000 : 350000); + m_maincpu->set_unscaled_clock((newval & 1) ? 400000 : 350000); } void h2hbaseb_state::update_display() @@ -2888,7 +2878,7 @@ static INPUT_PORTS_START( h2hbaseb ) PORT_BIT( 0x07, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Swing") - PORT_START("IN.5") // fake + PORT_START("CPU") // fake PORT_CONFNAME( 0x01, 0x00, DEF_STR( Difficulty ) ) PORT_CHANGED_MEMBER(DEVICE_SELF, h2hbaseb_state, skill_switch, 0) PORT_CONFSETTING( 0x00, "1" ) PORT_CONFSETTING( 0x01, "2" ) @@ -2899,7 +2889,7 @@ INPUT_PORTS_END void h2hbaseb_state::h2hbaseb(machine_config &config) { // basic machine hardware - TMS1170(config, m_maincpu, 350000); // see set_clock + TMS1170(config, m_maincpu, 350000); // see skill_switch m_maincpu->read_k().set(FUNC(h2hbaseb_state::read_k)); m_maincpu->write_r().set(FUNC(h2hbaseb_state::write_r)); m_maincpu->write_o().set(FUNC(h2hbaseb_state::write_o)); @@ -5002,33 +4992,23 @@ public: void ebball3(machine_config &config); - DECLARE_INPUT_CHANGED_MEMBER(skill_switch) { set_clock(); } - -protected: - virtual void machine_reset() override; + DECLARE_INPUT_CHANGED_MEMBER(skill_switch); private: - void set_clock(); void update_display(); void write_r(u32 data); void write_o(u16 data); u8 read_k(); }; -void ebball3_state::machine_reset() -{ - hh_tms1k_state::machine_reset(); - set_clock(); -} - // handlers -void ebball3_state::set_clock() +INPUT_CHANGED_MEMBER(ebball3_state::skill_switch) { // MCU clock is from an RC circuit(R=47K, C=33pF) oscillating by default at ~340kHz, // but on PRO, the difficulty switch adds an extra 150K resistor to Vdd to speed // it up to around ~440kHz. - m_maincpu->set_unscaled_clock((m_inputs[3]->read() & 1) ? 440000 : 340000); + m_maincpu->set_unscaled_clock((newval & 1) ? 440000 : 340000); } void ebball3_state::update_display() @@ -5104,7 +5084,7 @@ static INPUT_PORTS_START( ebball3 ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Bunt") PORT_BIT( 0x0c, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_START("IN.3") // fake + PORT_START("CPU") // fake PORT_CONFNAME( 0x01, 0x00, DEF_STR( Difficulty ) ) PORT_CHANGED_MEMBER(DEVICE_SELF, ebball3_state, skill_switch, 0) PORT_CONFSETTING( 0x00, "1" ) // AM PORT_CONFSETTING( 0x01, "2" ) // PRO @@ -5115,7 +5095,7 @@ INPUT_PORTS_END void ebball3_state::ebball3(machine_config &config) { // basic machine hardware - TMS1100(config, m_maincpu, 340000); // see set_clock + TMS1100(config, m_maincpu, 340000); // see skill_switch m_maincpu->read_k().set(FUNC(ebball3_state::read_k)); m_maincpu->write_r().set(FUNC(ebball3_state::write_r)); m_maincpu->write_o().set(FUNC(ebball3_state::write_o)); @@ -5403,33 +5383,23 @@ public: hh_tms1k_state(mconfig, type, tag) { } - DECLARE_INPUT_CHANGED_MEMBER(skill_switch) { set_clock(); } + DECLARE_INPUT_CHANGED_MEMBER(skill_switch); void einvader(machine_config &config); -protected: - virtual void machine_reset() override; - private: - void set_clock(); void update_display(); void write_r(u32 data); void write_o(u16 data); }; -void einvader_state::machine_reset() -{ - hh_tms1k_state::machine_reset(); - set_clock(); -} - // handlers -void einvader_state::set_clock() +INPUT_CHANGED_MEMBER(einvader_state::skill_switch) { // MCU clock is from an RC circuit(R=47K, C=56pF) oscillating by default at ~320kHz, // but on PRO, the difficulty switch adds an extra 180K resistor to Vdd to speed // it up to around ~400kHz. - m_maincpu->set_unscaled_clock((m_inputs[0]->read() & 8) ? 400000 : 320000); + m_maincpu->set_unscaled_clock((newval & 1) ? 400000 : 320000); } void einvader_state::update_display() @@ -5472,7 +5442,7 @@ INPUT_PORTS_END void einvader_state::einvader(machine_config &config) { // basic machine hardware - TMS1100(config, m_maincpu, 320000); // see set_clock + TMS1100(config, m_maincpu, 320000); // see skill_switch m_maincpu->read_k().set_ioport("IN.0"); m_maincpu->write_r().set(FUNC(einvader_state::write_r)); m_maincpu->write_o().set(FUNC(einvader_state::write_o)); @@ -5832,36 +5802,26 @@ public: void raisedvl(machine_config &config); void ebknight(machine_config &config); - DECLARE_INPUT_CHANGED_MEMBER(skill_switch) { set_clock(); } - -protected: - virtual void machine_reset() override; + DECLARE_INPUT_CHANGED_MEMBER(skill_switch); private: - void set_clock(); void update_display(); void write_r(u32 data); void write_o(u16 data); u8 read_k(); }; -void raisedvl_state::machine_reset() -{ - hh_tms1k_state::machine_reset(); - set_clock(); -} - // handlers -void raisedvl_state::set_clock() +INPUT_CHANGED_MEMBER(raisedvl_state::skill_switch) { // MCU clock is from an RC circuit with C=47pF, R=47K by default. Skills // 2 and 3 add a 150K resistor in parallel, and skill 4 adds a 100K one. // 0: R=47K -> ~350kHz // 2,3: R=35K8 -> ~425kHz (combined) // 4: R=32K -> ~465kHz (combined) - u8 inp = m_inputs[1]->read(); - m_maincpu->set_unscaled_clock((inp & 0x20) ? 465000 : ((inp & 0x10) ? 425000 : 350000)); + static const u32 freq[3] = { 350000, 425000, 465000 }; + m_maincpu->set_unscaled_clock(freq[(newval >> 4) % 3]); } void raisedvl_state::update_display() @@ -5919,7 +5879,7 @@ INPUT_PORTS_END void raisedvl_state::raisedvl(machine_config &config) { // basic machine hardware - TMS1100(config, m_maincpu, 350000); // see set_clock + TMS1100(config, m_maincpu, 350000); // see skill_switch m_maincpu->read_k().set(FUNC(raisedvl_state::read_k)); m_maincpu->write_r().set(FUNC(raisedvl_state::write_r)); m_maincpu->write_o().set(FUNC(raisedvl_state::write_o)); @@ -6313,31 +6273,21 @@ public: void f3in1(machine_config &config); - DECLARE_INPUT_CHANGED_MEMBER(skill_switch) { set_clock(); } - -protected: - virtual void machine_reset() override; + DECLARE_INPUT_CHANGED_MEMBER(skill_switch); private: - void set_clock(); void update_display(); void write_r(u32 data); void write_o(u16 data); u8 read_k(); }; -void f3in1_state::machine_reset() -{ - hh_tms1k_state::machine_reset(); - set_clock(); -} - // handlers -void f3in1_state::set_clock() +INPUT_CHANGED_MEMBER(f3in1_state::skill_switch) { // MCU clock is from an RC circuit where C=47pF, R=39K(PROF) or 56K(REG) - m_maincpu->set_unscaled_clock((m_inputs[4]->read() & 1) ? 400000 : 300000); + m_maincpu->set_unscaled_clock((newval & 1) ? 400000 : 300000); } void f3in1_state::update_display() @@ -6398,7 +6348,7 @@ static INPUT_PORTS_START( f3in1 ) PORT_CONFSETTING( 0x04, "Basketball" ) PORT_CONFSETTING( 0x08, "Soccer" ) - PORT_START("IN.4") // fake + PORT_START("CPU") // fake PORT_CONFNAME( 0x01, 0x00, DEF_STR( Difficulty ) ) PORT_CHANGED_MEMBER(DEVICE_SELF, f3in1_state, skill_switch, 0) PORT_CONFSETTING( 0x00, "1" ) // REG PORT_CONFSETTING( 0x01, "2" ) // PROF @@ -6409,7 +6359,7 @@ INPUT_PORTS_END void f3in1_state::f3in1(machine_config &config) { // basic machine hardware - TMS1100(config, m_maincpu, 300000); // see set_clock + TMS1100(config, m_maincpu, 300000); // see skill_switch m_maincpu->read_k().set(FUNC(f3in1_state::read_k)); m_maincpu->write_r().set(FUNC(f3in1_state::write_r)); m_maincpu->write_o().set(FUNC(f3in1_state::write_o)); @@ -9504,33 +9454,23 @@ public: void ssimon(machine_config &config); - DECLARE_INPUT_CHANGED_MEMBER(speed_switch) { set_clock(); } - -protected: - virtual void machine_reset() override; + DECLARE_INPUT_CHANGED_MEMBER(speed_switch); private: - void set_clock(); void write_r(u32 data); u8 read_k(); }; -void ssimon_state::machine_reset() -{ - hh_tms1k_state::machine_reset(); - set_clock(); -} - // handlers -void ssimon_state::set_clock() +INPUT_CHANGED_MEMBER(ssimon_state::speed_switch) { // MCU clock is from an RC circuit with C=100pF, R=x depending on speed switch: // 0 Simple: R=51K -> ~200kHz // 1 Normal: R=37K -> ~275kHz // 2 Super: R=22K -> ~400kHz - u8 inp = m_inputs[6]->read(); - m_maincpu->set_unscaled_clock((inp & 2) ? 400000 : ((inp & 1) ? 275000 : 200000)); + static const u32 freq[3] = { 200000, 275000, 400000 }; + m_maincpu->set_unscaled_clock(freq[newval % 3]); } void ssimon_state::write_r(u32 data) @@ -9595,7 +9535,7 @@ static INPUT_PORTS_START( ssimon ) PORT_BIT( 0x02, 0x02, IPT_CUSTOM ) PORT_CONDITION("IN.4", 0x0f, EQUALS, 0x00) PORT_BIT( 0x0d, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_START("IN.6") // fake + PORT_START("CPU") // fake PORT_CONFNAME( 0x03, 0x01, "Speed" ) PORT_CHANGED_MEMBER(DEVICE_SELF, ssimon_state, speed_switch, 0) PORT_CONFSETTING( 0x00, "Simple" ) PORT_CONFSETTING( 0x01, "Normal" ) @@ -9615,7 +9555,7 @@ INPUT_PORTS_END void ssimon_state::ssimon(machine_config &config) { // basic machine hardware - TMS1100(config, m_maincpu, 275000); // see set_clock + TMS1100(config, m_maincpu, 275000); // see speed_switch m_maincpu->read_k().set(FUNC(ssimon_state::read_k)); m_maincpu->write_r().set(FUNC(ssimon_state::write_r)); @@ -16251,10 +16191,9 @@ public: void tbreakup(machine_config &config); - DECLARE_INPUT_CHANGED_MEMBER(skill_switch) { set_clock(); } + DECLARE_INPUT_CHANGED_MEMBER(skill_switch); protected: - virtual void machine_reset() override; virtual void machine_start() override; private: @@ -16263,7 +16202,6 @@ private: void expander_w(offs_t offset, u8 data); - void set_clock(); void update_display(); void write_r(u32 data); void write_o(u16 data); @@ -16276,18 +16214,12 @@ void tbreakup_state::machine_start() save_item(NAME(m_exp_port)); } -void tbreakup_state::machine_reset() -{ - hh_tms1k_state::machine_reset(); - set_clock(); -} - // handlers -void tbreakup_state::set_clock() +INPUT_CHANGED_MEMBER(tbreakup_state::skill_switch) { // MCU clock is from an analog circuit with resistor of 73K, PRO2 adds 100K - m_maincpu->set_unscaled_clock((m_inputs[3]->read() & 1) ? 500000 : 325000); + m_maincpu->set_unscaled_clock((newval & 1) ? 500000 : 325000); } void tbreakup_state::update_display() @@ -16358,7 +16290,7 @@ static INPUT_PORTS_START( tbreakup ) PORT_CONFSETTING( 0x00, "3" ) PORT_CONFSETTING( 0x04, "5" ) - PORT_START("IN.3") // fake + PORT_START("CPU") // fake PORT_CONFNAME( 0x01, 0x00, DEF_STR( Difficulty ) ) PORT_CHANGED_MEMBER(DEVICE_SELF, tbreakup_state, skill_switch, 0) PORT_CONFSETTING( 0x00, "1" ) // PRO 1 PORT_CONFSETTING( 0x01, "2" ) // PRO 2 @@ -16369,7 +16301,7 @@ INPUT_PORTS_END void tbreakup_state::tbreakup(machine_config &config) { // basic machine hardware - TMS1040(config, m_maincpu, 325000); // see set_clock + TMS1040(config, m_maincpu, 325000); // see skill_switch m_maincpu->read_k().set(FUNC(tbreakup_state::read_k)); m_maincpu->write_r().set(FUNC(tbreakup_state::write_r)); m_maincpu->write_o().set(FUNC(tbreakup_state::write_o)); diff --git a/src/mame/handheld/hh_ucom4.cpp b/src/mame/handheld/hh_ucom4.cpp index b78f6fdc97f..1f7f5ae407f 100644 --- a/src/mame/handheld/hh_ucom4.cpp +++ b/src/mame/handheld/hh_ucom4.cpp @@ -2686,13 +2686,9 @@ public: void tmtennis(machine_config &config); - DECLARE_INPUT_CHANGED_MEMBER(difficulty_switch) { set_clock(); } - -protected: - virtual void machine_reset() override; + DECLARE_INPUT_CHANGED_MEMBER(skill_switch); private: - void set_clock(); void update_display(); void grid_w(offs_t offset, u8 data); void plate_w(offs_t offset, u8 data); @@ -2700,20 +2696,14 @@ private: u8 input_r(offs_t offset); }; -void tmtennis_state::machine_reset() -{ - hh_ucom4_state::machine_reset(); - set_clock(); -} - // handlers -void tmtennis_state::set_clock() +INPUT_CHANGED_MEMBER(tmtennis_state::skill_switch) { // MCU clock is from an LC circuit oscillating by default at ~360kHz, // but on PRO1, the difficulty switch puts a capacitor across the LC circuit // to slow it down to ~260kHz. - m_maincpu->set_unscaled_clock((m_inputs[1]->read() & 0x100) ? 260000 : 360000); + m_maincpu->set_unscaled_clock((newval & 0x100) ? 260000 : 360000); } void tmtennis_state::update_display() @@ -2776,9 +2766,9 @@ static INPUT_PORTS_START( tmtennis ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_J) PORT_NAME("P1 Button 6") PORT_START("IN.1") // E1 port A/B - PORT_CONFNAME( 0x101, 0x100, DEF_STR( Difficulty ) ) PORT_CHANGED_MEMBER(DEVICE_SELF, tmtennis_state, difficulty_switch, 0) + PORT_CONFNAME( 0x101, 0x100, DEF_STR( Difficulty ) ) PORT_CHANGED_MEMBER(DEVICE_SELF, tmtennis_state, skill_switch, 0) PORT_CONFSETTING( 0x001, "Practice" ) - PORT_CONFSETTING( 0x100, "Pro 1" ) // -> difficulty_switch + PORT_CONFSETTING( 0x100, "Pro 1" ) // -> skill_switch PORT_CONFSETTING( 0x000, "Pro 2" ) PORT_CONFNAME( 0x02, 0x00, DEF_STR( Players ) ) PORT_CONFSETTING( 0x00, "1" ) @@ -2796,7 +2786,7 @@ INPUT_PORTS_END void tmtennis_state::tmtennis(machine_config &config) { // basic machine hardware - NEC_D552(config, m_maincpu, 360000); // see set_clock + NEC_D552(config, m_maincpu, 260000); // see skill_switch m_maincpu->read_a().set(FUNC(tmtennis_state::input_r)); m_maincpu->read_b().set(FUNC(tmtennis_state::input_r)); m_maincpu->write_c().set(FUNC(tmtennis_state::plate_w)); -- cgit v1.2.3