From 98e0f529ed7ffaecd8ad4400d7b53dd12cbe0533 Mon Sep 17 00:00:00 2001 From: hap Date: Thu, 9 Nov 2023 10:54:35 +0100 Subject: ccompan2: add power off nmi --- src/mame/handheld/wildfire.cpp | 2 +- src/mame/saitek/ccompan.cpp | 2 +- src/mame/saitek/ccompan2.cpp | 178 +++++++++++++++++++++++++---------------- src/mame/saitek/simultano.cpp | 10 +-- 4 files changed, 116 insertions(+), 76 deletions(-) diff --git a/src/mame/handheld/wildfire.cpp b/src/mame/handheld/wildfire.cpp index 2b644f8c4fc..2ef97d14fce 100644 --- a/src/mame/handheld/wildfire.cpp +++ b/src/mame/handheld/wildfire.cpp @@ -197,7 +197,7 @@ void wildfire_state::wildfire(machine_config &config) ROM_START( wildfire ) ROM_REGION( 0x0800, "maincpu", ROMREGION_ERASE00 ) // Typed in from patent US4334679, data should be correct(it included checksums). 1st half was also dumped/verified with release version. - ROM_LOAD( "us4341385", 0x0000, 0x0400, CRC(84ac0f1f) SHA1(1e00ddd402acfc2cc267c34eed4b89d863e2144f) ) + ROM_LOAD( "us4334679", 0x0000, 0x0400, CRC(84ac0f1f) SHA1(1e00ddd402acfc2cc267c34eed4b89d863e2144f) ) ROM_CONTINUE( 0x0600, 0x0200 ) ROM_END diff --git a/src/mame/saitek/ccompan.cpp b/src/mame/saitek/ccompan.cpp index 9275ddd40b4..776e0817c2d 100644 --- a/src/mame/saitek/ccompan.cpp +++ b/src/mame/saitek/ccompan.cpp @@ -219,7 +219,7 @@ void ccompan_state::ccompan(machine_config &config) ROM_START( ccompan ) ROM_REGION( 0x10000, "maincpu", 0 ) - ROM_LOAD("2332n_y01a", 0x1000, 0x1000, CRC(a715d51c) SHA1(3e1bd9dc119c914b502f1433ee2d6ce3f477b99a) ) // 2332 + ROM_LOAD("2332n_yo1a", 0x1000, 0x1000, CRC(a715d51c) SHA1(3e1bd9dc119c914b502f1433ee2d6ce3f477b99a) ) // 2332 ROM_END } // anonymous namespace diff --git a/src/mame/saitek/ccompan2.cpp b/src/mame/saitek/ccompan2.cpp index 1fe7312b1d6..7395528654c 100644 --- a/src/mame/saitek/ccompan2.cpp +++ b/src/mame/saitek/ccompan2.cpp @@ -9,14 +9,16 @@ The chess engine is LogiChess (ported from Z80 to 6800), by Kaare Danielsen. CXG Enterprise "S" / Star Chess is probably on similar hardware. TODO: -- standby/battery save mode +- add nvram (belongs in m6801.cpp, and it needs to save port $14 too) +- verify SciSys MCU frequency, the only videos online (for hearing sound pitch) + are from the Tandy 1650 ones ******************************************************************************** Hardware notes: Chess Companion II: -- PCB label: Y01B-01 REV.B +- PCB label: YO1B-01 REV.B - Hitachi HD6301V1 (0609V171) @ ~3MHz (LC oscillator) - chessboard buttons, 16+5 leds, piezo @@ -27,7 +29,7 @@ Explorer Chess: Concord II: - PCB label: SCISYS ST3 REV.E -- MCU clock frequency is twice higher than Concord +- MCU clock frequency is twice higher than Concord, again no XTAL - rest is same as ccompan2, it just has the buttons/status leds at the bottom instead of at the right @@ -70,26 +72,25 @@ public: m_maincpu(*this, "maincpu"), m_board(*this, "board"), m_display(*this, "display"), - m_dac(*this, "dac"), m_inputs(*this, "IN.%u", 0) { } void ccompan2(machine_config &config); void expchess(machine_config &config); + DECLARE_INPUT_CHANGED_MEMBER(power_off); DECLARE_INPUT_CHANGED_MEMBER(change_cpu_freq) { set_cpu_freq(); } protected: virtual void machine_start() override; - virtual void machine_reset() override { set_cpu_freq(); } - DECLARE_MACHINE_RESET(expchess) { ; } + virtual void machine_reset() override; + DECLARE_MACHINE_RESET(ccompan2) { machine_reset(); set_cpu_freq(); } private: // devices/pointers required_device m_maincpu; required_device m_board; required_device m_display; - required_device m_dac; required_ioport_array<8+1> m_inputs; // address maps @@ -98,19 +99,26 @@ private: // I/O handlers u8 input1_r(); u8 input2_r(); - void speaker_w(u8 data); void mux_w(u8 data); - u8 battery_r(); + u8 power_r(); void led_w(u8 data); void set_cpu_freq(); + TIMER_CALLBACK_MEMBER(set_pin); + emu_timer *m_standbytimer; + emu_timer *m_nmitimer; + bool m_power = false; u8 m_inp_mux = 0; }; void ccompan2_state::machine_start() { + m_nmitimer = timer_alloc(FUNC(ccompan2_state::set_pin), this); + m_standbytimer = timer_alloc(FUNC(ccompan2_state::set_pin), this); + // register for savestates + save_item(NAME(m_power)); save_item(NAME(m_inp_mux)); } @@ -122,6 +130,39 @@ void ccompan2_state::set_cpu_freq() +/******************************************************************************* + Power +*******************************************************************************/ + +void ccompan2_state::machine_reset() +{ + m_power = true; + m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); +} + +TIMER_CALLBACK_MEMBER(ccompan2_state::set_pin) +{ + m_maincpu->set_input_line(param, ASSERT_LINE); +} + +INPUT_CHANGED_MEMBER(ccompan2_state::power_off) +{ + if (newval && m_power) + { + m_power = false; + + // when power switch is set to MEMORY, it triggers an NMI after a short delay + attotime delay = attotime::from_msec(100); + m_nmitimer->adjust(delay, INPUT_LINE_NMI); + + // afterwards, MCU STBY pin is asserted after a short delay + delay += attotime::from_msec(10); + m_standbytimer->adjust(delay, INPUT_LINE_RESET); + } +} + + + /******************************************************************************* I/O *******************************************************************************/ @@ -153,12 +194,6 @@ u8 ccompan2_state::input2_r() return ~data; } -void ccompan2_state::speaker_w(u8 data) -{ - // P20: speaker out - m_dac->write(data & 1); -} - void ccompan2_state::mux_w(u8 data) { // P30-P37: input mux, led data @@ -166,10 +201,10 @@ void ccompan2_state::mux_w(u8 data) m_display->write_mx(m_inp_mux); } -u8 ccompan2_state::battery_r() +u8 ccompan2_state::power_r() { - // P40: battery status (only reads it at boot) - return 0; + // P40: power switch state + return m_power ? 0 : 1; } void ccompan2_state::led_w(u8 data) @@ -198,48 +233,6 @@ void ccompan2_state::main_map(address_map &map) Input Ports *******************************************************************************/ -static INPUT_PORTS_START( ccompan2 ) - PORT_START("IN.0") - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_UNUSED) - PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_UNUSED) - - PORT_START("IN.1") - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_S) PORT_NAME("Sound") - PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_L) PORT_NAME("Level") - - PORT_START("IN.2") - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_C) PORT_NAME("Color") - PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_M) PORT_NAME("Multi Move") - - PORT_START("IN.3") - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_1) PORT_CODE(KEYCODE_1_PAD) PORT_NAME("King") - PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_2) PORT_CODE(KEYCODE_2_PAD) PORT_NAME("Queen") - - PORT_START("IN.4") - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_3) PORT_CODE(KEYCODE_3_PAD) PORT_NAME("Rook") - PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_O) PORT_NAME("Play") - - PORT_START("IN.5") - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_4) PORT_CODE(KEYCODE_4_PAD) PORT_NAME("Bishop") - PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_E) PORT_NAME("Enter Position") - - PORT_START("IN.6") - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_5) PORT_CODE(KEYCODE_5_PAD) PORT_NAME("Knight") - PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_T) PORT_NAME("Take Back") - - PORT_START("IN.7") - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_6) PORT_CODE(KEYCODE_6_PAD) PORT_NAME("Pawn") - PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_N) PORT_NAME("New Game") - - PORT_START("IN.8") - PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_CUSTOM) // button config - - PORT_START("FAKE") - PORT_CONFNAME( 0x01, 0x00, "CPU Frequency" ) PORT_CHANGED_MEMBER(DEVICE_SELF, ccompan2_state, change_cpu_freq, 0) // factory set - PORT_CONFSETTING( 0x00, "3MHz (original)" ) - PORT_CONFSETTING( 0x01, "6MHz (Concord II)" ) -INPUT_PORTS_END - static INPUT_PORTS_START( expchess ) PORT_START("IN.0") PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_UNUSED) @@ -275,6 +268,53 @@ static INPUT_PORTS_START( expchess ) PORT_START("IN.8") PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_CUSTOM) // button config + + PORT_START("POWER") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_OTHER) PORT_CODE(KEYCODE_F1) PORT_CHANGED_MEMBER(DEVICE_SELF, ccompan2_state, power_off, 0) PORT_NAME("Power Off") +INPUT_PORTS_END + +static INPUT_PORTS_START( ccompan2 ) + PORT_INCLUDE( expchess ) + + PORT_MODIFY("IN.0") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_UNUSED) + + PORT_MODIFY("IN.1") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_S) PORT_NAME("Sound") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_L) PORT_NAME("Level") + + PORT_MODIFY("IN.2") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_C) PORT_NAME("Color") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_M) PORT_NAME("Multi Move") + + PORT_MODIFY("IN.3") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_1) PORT_CODE(KEYCODE_1_PAD) PORT_NAME("King") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_2) PORT_CODE(KEYCODE_2_PAD) PORT_NAME("Queen") + + PORT_MODIFY("IN.4") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_3) PORT_CODE(KEYCODE_3_PAD) PORT_NAME("Rook") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_O) PORT_NAME("Play") + + PORT_MODIFY("IN.5") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_4) PORT_CODE(KEYCODE_4_PAD) PORT_NAME("Bishop") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_E) PORT_NAME("Enter Position") + + PORT_MODIFY("IN.6") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_5) PORT_CODE(KEYCODE_5_PAD) PORT_NAME("Knight") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_T) PORT_NAME("Take Back") + + PORT_MODIFY("IN.7") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_6) PORT_CODE(KEYCODE_6_PAD) PORT_NAME("Pawn") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_N) PORT_NAME("New Game") + + PORT_MODIFY("IN.8") + PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_CUSTOM) // button config + + PORT_START("FAKE") + PORT_CONFNAME( 0x01, 0x00, "CPU Frequency" ) PORT_CHANGED_MEMBER(DEVICE_SELF, ccompan2_state, change_cpu_freq, 0) // factory set + PORT_CONFSETTING( 0x00, "3MHz (original)" ) + PORT_CONFSETTING( 0x01, "6MHz (Concord II)" ) INPUT_PORTS_END @@ -283,16 +323,16 @@ INPUT_PORTS_END Machine Configs *******************************************************************************/ -void ccompan2_state::ccompan2(machine_config &config) +void ccompan2_state::expchess(machine_config &config) { // basic machine hardware HD6301V1(config, m_maincpu, 3000000); // approximation, no XTAL m_maincpu->set_addrmap(AS_PROGRAM, &ccompan2_state::main_map); m_maincpu->in_p1_cb().set(FUNC(ccompan2_state::input1_r)); m_maincpu->in_p2_cb().set(FUNC(ccompan2_state::input2_r)); - m_maincpu->out_p2_cb().set(FUNC(ccompan2_state::speaker_w)); + m_maincpu->out_p2_cb().set("dac", FUNC(dac_1bit_device::write)).bit(0); m_maincpu->out_p3_cb().set(FUNC(ccompan2_state::mux_w)); - m_maincpu->in_p4_cb().set(FUNC(ccompan2_state::battery_r)); + m_maincpu->in_p4_cb().set(FUNC(ccompan2_state::power_r)); m_maincpu->out_p4_cb().set(FUNC(ccompan2_state::led_w)); SENSORBOARD(config, m_board).set_type(sensorboard_device::BUTTONS); @@ -302,19 +342,19 @@ void ccompan2_state::ccompan2(machine_config &config) // video hardware PWM_DISPLAY(config, m_display).set_size(5+2, 8); m_display->set_interpolation(0.25); - config.set_default_layout(layout_saitek_ccompan2); + config.set_default_layout(layout_saitek_expchess); // sound hardware SPEAKER(config, "speaker").front_center(); - DAC_1BIT(config, m_dac).add_route(ALL_OUTPUTS, "speaker", 0.25); + DAC_1BIT(config, "dac").add_route(ALL_OUTPUTS, "speaker", 0.25); } -void ccompan2_state::expchess(machine_config &config) +void ccompan2_state::ccompan2(machine_config &config) { - ccompan2(config); + expchess(config); - MCFG_MACHINE_RESET_OVERRIDE(ccompan2_state, expchess) - config.set_default_layout(layout_saitek_expchess); + MCFG_MACHINE_RESET_OVERRIDE(ccompan2_state, ccompan2) + config.set_default_layout(layout_saitek_ccompan2); } diff --git a/src/mame/saitek/simultano.cpp b/src/mame/saitek/simultano.cpp index 65286e74bfc..c31fce37a93 100644 --- a/src/mame/saitek/simultano.cpp +++ b/src/mame/saitek/simultano.cpp @@ -371,8 +371,8 @@ void simultano_state::simultano(machine_config &config) ROM_START( simultano ) ROM_REGION( 0x10000, "maincpu", 0 ) - ROM_LOAD("y01h_c12_u3.u3", 0x0000, 0x8000, CRC(e7f8bae4) SHA1(82d8c6879e031b9909dd63bff692055f32236f9c) ) - ROM_LOAD("by01h_c13_u4.u4", 0x8000, 0x8000, CRC(4f5557bc) SHA1(2fd4b1791cec4e6e33b1da644edb603ed8c9cd2e) ) + ROM_LOAD("yo1h_c12_u3.u3", 0x0000, 0x8000, CRC(e7f8bae4) SHA1(82d8c6879e031b9909dd63bff692055f32236f9c) ) + ROM_LOAD("byo1h_c13_u4.u4", 0x8000, 0x8000, CRC(4f5557bc) SHA1(2fd4b1791cec4e6e33b1da644edb603ed8c9cd2e) ) ROM_REGION( 795951, "screen", 0 ) ROM_LOAD("simultano.svg", 0, 795951, CRC(ac9942bb) SHA1(f9252e5bf7b8af698a403c3f8f5ea9e475e0bf0b) ) @@ -380,8 +380,8 @@ ROM_END ROM_START( simultanoa ) ROM_REGION( 0x10000, "maincpu", 0 ) - ROM_LOAD("y01h_c12e_u3.u3", 0x0000, 0x8000, CRC(d583fdb4) SHA1(4be242691215ab1635a5d672441d339596f719c6) ) // AMI 27256 - ROM_LOAD("by01h_c13b_u4.u4", 0x8000, 0x8000, CRC(c607b421) SHA1(b0c784b570dfd1fcbe3da68bcfbae2dae2957a74) ) // " + ROM_LOAD("yo1h_c12e_u3.u3", 0x0000, 0x8000, CRC(d583fdb4) SHA1(4be242691215ab1635a5d672441d339596f719c6) ) // AMI 27256 + ROM_LOAD("byo1h_c13b_u4.u4", 0x8000, 0x8000, CRC(c607b421) SHA1(b0c784b570dfd1fcbe3da68bcfbae2dae2957a74) ) // " ROM_REGION( 795951, "screen", 0 ) ROM_LOAD("simultano.svg", 0, 795951, CRC(ac9942bb) SHA1(f9252e5bf7b8af698a403c3f8f5ea9e475e0bf0b) ) @@ -389,7 +389,7 @@ ROM_END ROM_START( cc2150 ) ROM_REGION( 0x10000, "maincpu", 0 ) - ROM_LOAD("y01g_418_u3.u3", 0x8000, 0x8000, CRC(612dac24) SHA1(ba318f2ba34f9eb3df76a30c455bded76617bb11) ) // AMI 27512 + ROM_LOAD("yo1g_418_u3.u3", 0x8000, 0x8000, CRC(612dac24) SHA1(ba318f2ba34f9eb3df76a30c455bded76617bb11) ) // AMI 27512 ROM_CONTINUE( 0x0000, 0x8000 ) ROM_REGION( 795951, "screen", 0 ) -- cgit v1.2.3