From a80c62e12eef859af22a0faea2306759ab4ecd3b Mon Sep 17 00:00:00 2001 From: Robbbert Date: Thu, 17 Feb 2022 06:29:33 +1100 Subject: decopincpu: added outputs, removed unused switch. --- src/mame/drivers/de_2.cpp | 24 ++++++++++++++- src/mame/drivers/de_3.cpp | 24 ++++++++++++++- src/mame/drivers/de_3b.cpp | 27 +++++++++++++++-- src/mame/machine/decopincpu.cpp | 67 +++++++++++++++++++++++------------------ src/mame/machine/decopincpu.h | 11 ++++--- 5 files changed, 113 insertions(+), 40 deletions(-) diff --git a/src/mame/drivers/de_2.cpp b/src/mame/drivers/de_2.cpp index 7331c5cecaa..2bc5dcbc230 100644 --- a/src/mame/drivers/de_2.cpp +++ b/src/mame/drivers/de_2.cpp @@ -43,7 +43,6 @@ Status: - All machines are playable ToDo: -- Outputs - Mechanical sounds - robo_a29,robo_a34: can't coin up, buggy rom? @@ -118,6 +117,7 @@ private: void type2alpha3_display_w(offs_t offset, uint8_t data); void type3_display_w(offs_t offset, uint8_t data); void lamps_w(offs_t offset, uint8_t data); + void sol_w(offs_t, uint8_t); // devices required_device m_ym2151; @@ -138,6 +138,7 @@ private: uint8_t m_row = 0U; uint8_t m_diag = 0U; uint8_t m_sound_data = 0U; + u16 m_sol = 0U; }; @@ -253,6 +254,7 @@ void de_2_state::machine_start() save_item(NAME(m_more_data)); save_item(NAME(m_strobe)); save_item(NAME(m_row)); + save_item(NAME(m_sol)); uint8_t *const ROM = memregion("sound1")->base(); m_sample_bank->configure_entries(0, 16, &ROM[0x0000], 0x4000); @@ -391,6 +393,25 @@ void de_2_state::switch_w(uint8_t data) m_row = data; } +void de_2_state::sol_w(offs_t offset, u8 data) +{ + if (!offset) + m_sol = (m_sol & 0xff00) | data; + else + m_sol = (m_sol & 0xff) | (BIT(data, 1) ? 0x100 : 0); + + // these vary per game, this is an example + switch (m_sol) + { + case 0x0002: + m_samples->start(5, 5); // outhole + break; + case 0x0080: + m_samples->start(0, 6); // knocker + break; + } +} + // 6821 PIA at 0x3400 void de_2_state::type2alpha3_pia34_pa_w(uint8_t data) { @@ -603,6 +624,7 @@ void de_2_state::de_type3(machine_config &config) decocpu.switch_read_callback().set(FUNC(de_2_state::switch_r)); decocpu.switch_write_callback().set(FUNC(de_2_state::switch_w)); decocpu.lamp_write_callback().set(FUNC(de_2_state::lamps_w)); + decocpu.solenoid_write_callback().set(FUNC(de_2_state::sol_w)); /* Video */ config.set_default_layout(layout_de2a3); diff --git a/src/mame/drivers/de_3.cpp b/src/mame/drivers/de_3.cpp index f42fa2b3036..a119e3ae7ac 100644 --- a/src/mame/drivers/de_3.cpp +++ b/src/mame/drivers/de_3.cpp @@ -43,7 +43,6 @@ ToDo: - Checkpoint: no sound - TMNT: no sound - Batman: music missing -- Outputs - Mechanical sounds *********************************************************************************************************************/ @@ -92,6 +91,7 @@ private: uint8_t display_r(offs_t offset); void display_w(offs_t offset, uint8_t data); void lamps_w(offs_t offset, uint8_t data); + void sol_w(offs_t, uint8_t); void de_3(machine_config &config); @@ -102,6 +102,7 @@ private: required_ioport_array<8> m_io_keyboard; uint8_t m_row = 0U; + u16 m_sol = 0U; }; @@ -262,6 +263,25 @@ void de_3_state::switch_w(uint8_t data) m_row = data; } +void de_3_state::sol_w(offs_t offset, u8 data) +{ + if (!offset) + m_sol = (m_sol & 0xff00) | data; + else + m_sol = (m_sol & 0xff) | (BIT(data, 1) ? 0x100 : 0); + + // these vary per game, this is an example + switch (m_sol) + { + case 0x0002: + m_samples->start(5, 5); // outhole + break; + case 0x0080: + m_samples->start(0, 6); // knocker + break; + } +} + // 6821 PIA at 0x3400 uint8_t de_3_state::dmd_status_r() { @@ -332,6 +352,7 @@ void de_3_state::machine_start() genpin_class::machine_start(); save_item(NAME(m_row)); + save_item(NAME(m_sol)); } void de_3_state::machine_reset() @@ -349,6 +370,7 @@ void de_3_state::de_3(machine_config &config) decocpu.switch_read_callback().set(FUNC(de_3_state::switch_r)); decocpu.switch_write_callback().set(FUNC(de_3_state::switch_w)); decocpu.lamp_write_callback().set(FUNC(de_3_state::lamps_w)); + decocpu.solenoid_write_callback().set(FUNC(de_3_state::sol_w)); decocpu.dmdstatus_read_callback().set(FUNC(de_3_state::dmd_status_r)); genpin_audio(config); diff --git a/src/mame/drivers/de_3b.cpp b/src/mame/drivers/de_3b.cpp index 63a9a62808a..53a33d40bc1 100644 --- a/src/mame/drivers/de_3b.cpp +++ b/src/mame/drivers/de_3b.cpp @@ -22,8 +22,6 @@ Status: ToDo: - Cut the Cheese: screen goes blank after a short while - Test fixture: nothing to see -- Outputs -- Mechanical sounds *********************************************************************************************************************/ #include "emu.h" @@ -67,12 +65,14 @@ private: uint8_t display_r(offs_t offset); void display_w(offs_t offset, uint8_t data); void lamps_w(offs_t offset, uint8_t data); + void sol_w(offs_t, uint8_t); // driver_device overrides virtual void machine_start() override; virtual void machine_reset() override; uint8_t m_row = 0U; + u16 m_sol = 0U; }; @@ -180,6 +180,25 @@ void de_3b_state::sound_w(uint8_t data) m_decobsmt->bsmt_comms_w(data); } +void de_3b_state::sol_w(offs_t offset, u8 data) +{ + if (!offset) + m_sol = (m_sol & 0xff00) | data; + else + m_sol = (m_sol & 0xff) | (BIT(data, 1) ? 0x100 : 0); + + // these vary per game, this is an example + switch (m_sol) + { + case 0x0002: + m_samples->start(5, 5); // outhole + break; + case 0x0080: + m_samples->start(0, 6); // knocker + break; + } +} + uint8_t de_3b_state::dmd_status_r() { return m_dmdtype3->status_r(); @@ -256,6 +275,7 @@ void de_3b_state::machine_start() genpin_class::machine_start(); save_item(NAME(m_row)); + save_item(NAME(m_sol)); } void de_3b_state::machine_reset() @@ -274,6 +294,7 @@ void de_3b_state::de_3b(machine_config &config) decocpu.switch_read_callback().set(FUNC(de_3b_state::switch_r)); decocpu.switch_write_callback().set(FUNC(de_3b_state::switch_w)); decocpu.lamp_write_callback().set(FUNC(de_3b_state::lamps_w)); + decocpu.solenoid_write_callback().set(FUNC(de_3b_state::sol_w)); decocpu.dmdstatus_read_callback().set(FUNC(de_3b_state::dmd_status_r)); genpin_audio(config); @@ -748,6 +769,6 @@ GAME(1995, frankstg, frankst, de_3b, de_3b, de_3b_state, empty_init, ROT0, "Se GAME(1994, mav_402, 0, de_3b, de_3b, de_3b_state, empty_init, ROT0, "Sega", "Maverick (Display Rev. 4.02)", MACHINE_IS_SKELETON_MECHANICAL) GAME(1994, mav_401, mav_402, de_3b, de_3b, de_3b_state, empty_init, ROT0, "Sega", "Maverick (Display Rev. 4.01)", MACHINE_IS_SKELETON_MECHANICAL) GAME(1994, mav_400, mav_402, de_3b, de_3b, de_3b_state, empty_init, ROT0, "Sega", "Maverick (Display Rev. 4.00)", MACHINE_IS_SKELETON_MECHANICAL) -GAME(1994, mav_100, mav_402, de_3b, de_3b, de_3b_state, empty_init, ROT0, "Sega", "Maverick (1.00)", MACHINE_IS_SKELETON_MECHANICAL) +GAME(1994, mav_100, mav_402, de_3b, de_3b, de_3b_state, empty_init, ROT0, "Data East", "Maverick (1.00)", MACHINE_IS_SKELETON_MECHANICAL) GAME(1998, detest, 0, detest, de_3b, de_3b_state, empty_init, ROT0, "Data East", "Data East Test Chip", MACHINE_IS_SKELETON_MECHANICAL) GAME(1996, ctcheese, 0, de_3b, de_3b, de_3b_state, empty_init, ROT0, "Sega", "Cut The Cheese (Redemption)", MACHINE_IS_SKELETON_MECHANICAL) diff --git a/src/mame/machine/decopincpu.cpp b/src/mame/machine/decopincpu.cpp index c07a807b2b1..f7aa98d0b94 100644 --- a/src/mame/machine/decopincpu.cpp +++ b/src/mame/machine/decopincpu.cpp @@ -9,7 +9,7 @@ * Type 3b: Adds printer option * * TODO: - * - make use of solenoid callbacks + * - support for solenoids 17-22 (m_io_outputs 16-21) * - printer option (type 3b) */ @@ -25,7 +25,7 @@ void decocpu_type1_device::decocpu1_map(address_map &map) { map(0x0000, 0x07ff).ram().share("nvram"); map(0x2100, 0x2103).rw("pia21", FUNC(pia6821_device::read), FUNC(pia6821_device::write)); // sound+solenoids - map(0x2200, 0x2200).w(FUNC(decocpu_type1_device::solenoid2_w)); // solenoids + map(0x2200, 0x2200).w(FUNC(decocpu_type1_device::solenoid0_w)); // solenoids map(0x2400, 0x2403).rw("pia24", FUNC(pia6821_device::read), FUNC(pia6821_device::write)); // lamps map(0x2800, 0x2803).rw("pia28", FUNC(pia6821_device::read), FUNC(pia6821_device::write)); // display map(0x2c00, 0x2c03).rw("pia2c", FUNC(pia6821_device::read), FUNC(pia6821_device::write)); // alphanumeric display @@ -38,7 +38,7 @@ void decocpu_type2_device::decocpu2_map(address_map &map) { map(0x0000, 0x1fff).ram().share("nvram"); map(0x2100, 0x2103).rw("pia21", FUNC(pia6821_device::read), FUNC(pia6821_device::write)); // sound+solenoids - map(0x2200, 0x2200).w(FUNC(decocpu_type2_device::solenoid2_w)); // solenoids + map(0x2200, 0x2200).w(FUNC(decocpu_type2_device::solenoid0_w)); // solenoids map(0x2400, 0x2403).rw("pia24", FUNC(pia6821_device::read), FUNC(pia6821_device::write)); // lamps map(0x2800, 0x2803).rw("pia28", FUNC(pia6821_device::read), FUNC(pia6821_device::write)); // display map(0x2c00, 0x2c03).rw("pia2c", FUNC(pia6821_device::read), FUNC(pia6821_device::write)); // alphanumeric display @@ -49,7 +49,6 @@ void decocpu_type2_device::decocpu2_map(address_map &map) static INPUT_PORTS_START( decocpu1 ) PORT_START("DIAGS") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("Audio Diag") PORT_CODE(KEYCODE_9_PAD) PORT_CHANGED_MEMBER(DEVICE_SELF, decocpu_type1_device, audio_nmi, 1) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("Main Diag") PORT_CODE(KEYCODE_0_PAD) PORT_CHANGED_MEMBER(DEVICE_SELF, decocpu_type1_device, main_nmi, 1) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("Advance") PORT_CODE(KEYCODE_1_PAD) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("Up/Down") PORT_CODE(KEYCODE_2_PAD) PORT_TOGGLE @@ -90,11 +89,6 @@ INPUT_CHANGED_MEMBER( decocpu_type1_device::main_nmi ) m_cpu->pulse_input_line(INPUT_LINE_NMI, attotime::zero); } -INPUT_CHANGED_MEMBER( decocpu_type1_device::audio_nmi ) -{ - // Not on DECO board? -} - WRITE_LINE_MEMBER(decocpu_type1_device::cpu_pia_irq) { if(state == CLEAR_LINE) @@ -121,11 +115,17 @@ WRITE_LINE_MEMBER( decocpu_type1_device::pia21_ca2_w ) void decocpu_type1_device::lamp0_w(uint8_t data) { m_cpu->set_input_line(M6808_IRQ_LINE, CLEAR_LINE); + m_lamp_data = data ^ 0xff; m_write_lamp(0,data,0xff); } void decocpu_type1_device::lamp1_w(uint8_t data) { + for (u8 i = 0; i < 8; i++) + if (BIT(data, i)) + for (u8 j = 0; j < 8; j++) + m_io_outputs[22U+i*8U+j] = BIT(m_lamp_data, j); + m_write_lamp(1,data,0xff); } @@ -191,12 +191,16 @@ void decocpu_type1_device::sound_w(uint8_t data) void decocpu_type1_device::solenoid1_w(uint8_t data) { - // todo + m_write_solenoid(1,data,0xff); + for (u8 i = 0; i < 8; i++) + m_io_outputs[i+8] = BIT(data, i); } -void decocpu_type1_device::solenoid2_w(uint8_t data) +void decocpu_type1_device::solenoid0_w(uint8_t data) { - // todo + m_write_solenoid(0,data,0xff); + for (u8 i = 0; i < 8; i++) + m_io_outputs[i] = BIT(data, i); } void decocpu_type1_device::device_add_mconfig(machine_config &config) @@ -207,7 +211,7 @@ void decocpu_type1_device::device_add_mconfig(machine_config &config) /* Devices */ PIA6821(config, m_pia21, 0); // 5F - PIA at 0x2100 - m_pia21->writepa_handler().set(FUNC(decocpu_type1_device::solenoid1_w)); + m_pia21->writepb_handler().set(FUNC(decocpu_type1_device::solenoid1_w)); m_pia21->ca2_handler().set(FUNC(decocpu_type1_device::pia21_ca2_w)); m_pia21->irqa_handler().set(FUNC(decocpu_type1_device::cpu_pia_irq)); m_pia21->irqb_handler().set(FUNC(decocpu_type1_device::cpu_pia_irq)); @@ -258,23 +262,24 @@ decocpu_type1_device::decocpu_type1_device(const machine_config &mconfig, const {} decocpu_type1_device::decocpu_type1_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock), - m_cpu(*this,"maincpu"), - m_pia21(*this, "pia21"), - m_pia24(*this, "pia24"), - m_pia28(*this, "pia28"), - m_pia2c(*this, "pia2c"), - m_pia30(*this, "pia30"), - m_pia34(*this, "pia34"), - m_rom(*this, finder_base::DUMMY_TAG), - m_read_display(*this), - m_write_display(*this), - m_read_dmdstatus(*this), - m_write_soundlatch(*this), - m_read_switch(*this), - m_write_switch(*this), - m_write_lamp(*this), - m_write_solenoid(*this) + : device_t(mconfig, type, tag, owner, clock) + , m_cpu(*this,"maincpu") + , m_pia21(*this, "pia21") + , m_pia24(*this, "pia24") + , m_pia28(*this, "pia28") + , m_pia2c(*this, "pia2c") + , m_pia30(*this, "pia30") + , m_pia34(*this, "pia34") + , m_rom(*this, finder_base::DUMMY_TAG) + , m_read_display(*this) + , m_write_display(*this) + , m_read_dmdstatus(*this) + , m_write_soundlatch(*this) + , m_read_switch(*this) + , m_write_switch(*this) + , m_write_lamp(*this) + , m_write_solenoid(*this) + , m_io_outputs(*this, "out%d", 0U) {} void decocpu_type1_device::device_start() @@ -294,6 +299,8 @@ void decocpu_type1_device::device_start() m_irq_active = false; m_cpu->space(AS_PROGRAM).install_rom(0x4000,0xffff,&m_rom[0x4000]); + + m_io_outputs.resolve(); } decocpu_type2_device::decocpu_type2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) diff --git a/src/mame/machine/decopincpu.h b/src/mame/machine/decopincpu.h index 5455d2fb37a..ade722721d8 100644 --- a/src/mame/machine/decopincpu.h +++ b/src/mame/machine/decopincpu.h @@ -47,14 +47,13 @@ public: auto lamp_write_callback() { return m_write_lamp.bind(); } auto solenoid_write_callback() { return m_write_solenoid.bind(); } - void solenoid2_w(uint8_t data); INPUT_CHANGED_MEMBER(main_nmi); - INPUT_CHANGED_MEMBER(audio_nmi); template void set_cpuregion(T &&tag) { m_rom.set_tag(std::forward(tag)); } // region for cpu board code and data protected: static constexpr device_timer_id TIMER_IRQ = 0; + void solenoid0_w(uint8_t data); decocpu_type1_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); @@ -76,9 +75,10 @@ protected: required_region_ptr m_rom; private: - emu_timer* m_irq_timer; - bool m_irq_active; - bool m_ca2; + emu_timer* m_irq_timer = 0; + bool m_irq_active = 0; + bool m_ca2 = 0; + u8 m_lamp_data = 0U; // callbacks devcb_read8 m_read_display; @@ -89,6 +89,7 @@ private: devcb_write8 m_write_switch; devcb_write8 m_write_lamp; devcb_write8 m_write_solenoid; + output_finder<86> m_io_outputs; // 22 solenoids + 64 lamps DECLARE_WRITE_LINE_MEMBER(cpu_pia_irq); DECLARE_WRITE_LINE_MEMBER(pia21_ca2_w); -- cgit v1.2.3