From 1260f9b9cf7703a440c435f7b5984a774418aacf Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 21 May 2023 11:35:03 -0400 Subject: mazerbla.cpp: Add ADCs and remove runtime port tag lookups --- src/mame/stern/mazerbla.cpp | 57 ++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/src/mame/stern/mazerbla.cpp b/src/mame/stern/mazerbla.cpp index cec66ec842e..f0e8e8c4c60 100644 --- a/src/mame/stern/mazerbla.cpp +++ b/src/mame/stern/mazerbla.cpp @@ -51,6 +51,8 @@ VSB-2000 - sound/speech/subcpu board (Voice and Sound Board) CRF-1001 - RF Filter board for video/audio output - this same board is shared with cliff hanger (cliffhgr.c) +UIB-1000 - coin inputs, start/fire buttons and gun ADCs (Vin(-) and Vref/2 are calibrated by potentiometers) + Versions: ====== Mazer blazer's zpu-2000 roms are known to exist in at least the following versions: @@ -106,8 +108,10 @@ video z80 #include "emu.h" #include "cpu/z80/z80.h" +#include "machine/adc0804.h" #include "machine/gen_latch.h" #include "machine/nvram.h" +#include "machine/rescap.h" #include "sound/ay8910.h" #include "video/resnet.h" #include "video/mb_vcu.h" @@ -133,6 +137,8 @@ public: , m_vcu(*this,"vcu") , m_screen(*this, "screen") , m_soundlatch(*this, "soundlatch") + , m_uib_adc(*this, "adc%u", 0U) + , m_digital_inputs(*this, { "ZPU", "DSW0", "DSW1", "DSW2", "DSW3", "BUTTONS" }) , m_leds(*this, "led%u", 0U) , m_lamps(*this, "lamp%u", 0U) { } @@ -187,6 +193,8 @@ private: required_device m_vcu; required_device m_screen; optional_device m_soundlatch; + optional_device_array m_uib_adc; + required_ioport_array<6> m_digital_inputs; output_finder<3> m_leds; output_finder<2> m_lamps; @@ -389,17 +397,24 @@ Vertical movement of gun is Strobe 9, Bits 0-7. void mazerbla_state::zpu_bcd_decoder_w(uint8_t data) { /* bcd decoder used a input select (a mux) for reads from port 0x62 */ - m_bcd_7445 = data & 0xf; + if (m_bcd_7445 != (data & 0xf)) + { + if (m_bcd_7445 >= 6 && m_bcd_7445 < 10 && m_uib_adc[m_bcd_7445 - 6].found()) + m_uib_adc[m_bcd_7445 - 6]->wr_w(1); + m_bcd_7445 = data & 0xf; + if (m_bcd_7445 >= 6 && m_bcd_7445 < 10 && m_uib_adc[m_bcd_7445 - 6].found()) + m_uib_adc[m_bcd_7445 - 6]->wr_w(0); + } } uint8_t mazerbla_state::zpu_inputs_r() { - static const char *const strobenames[] = { "ZPU", "DSW0", "DSW1", "DSW2", "DSW3", "BUTTONS", "STICK0_X", "STICK0_Y", - "STICK1_X", "STICK1_Y", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED" }; - - uint8_t ret = 0; + uint8_t ret = 0xff; - ret = ioport(strobenames[m_bcd_7445])->read(); + if (m_bcd_7445 < 6) + ret = m_digital_inputs[m_bcd_7445]->read(); + else if (m_bcd_7445 < 10 && m_uib_adc[m_bcd_7445 - 6].found()) + ret = m_uib_adc[m_bcd_7445 - 6]->read(); return ret; } @@ -703,15 +718,6 @@ static INPUT_PORTS_START( mazerbla ) PORT_START("STICK0_Y") /* Strobe 7: vertical movement of gun */ PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_SENSITIVITY(25) PORT_KEYDELTA(7) PORT_PLAYER(1) - - PORT_START("STICK1_X") /* Strobe 8: horizontal movement of gun */ - PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) - - PORT_START("STICK1_Y") /* Strobe 9: vertical movement of gun */ - PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) - - PORT_START("UNUSED") - PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) INPUT_PORTS_END static INPUT_PORTS_START( mazerblaa ) @@ -889,9 +895,6 @@ static INPUT_PORTS_START( greatgun ) PORT_START("STICK1_Y") /* Strobe 9: vertical movement of gun */ // for whatever reason this should be inverted? PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_MINMAX(0x00, 0xff) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(25) PORT_INVERT PORT_KEYDELTA(7) PORT_PLAYER(2) - - PORT_START("UNUSED") - PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) INPUT_PORTS_END /************************************* @@ -953,8 +956,6 @@ void mazerbla_state::machine_start() void mazerbla_state::machine_reset() { - int i; - m_zpu_int_vector = 0xff; m_gfx_rom_bank = 0xff; @@ -969,11 +970,13 @@ void mazerbla_state::machine_reset() m_soundlatch->acknowledge_w(); } - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { m_ls670_0[i] = 0; m_ls670_1[i] = 0; } + + zpu_bcd_decoder_w(0); } void mazerbla_state::mazerbla(machine_config &config) @@ -998,6 +1001,11 @@ void mazerbla_state::mazerbla(machine_config &config) */ sub2.set_vblank_int("screen", FUNC(mazerbla_state::irq0_line_hold)); + for (int i = 0; i < 2; i++) + ADC0804(config, m_uib_adc[i], RES_R(10), CAP_P(150)).set_rd_mode(adc0804_device::RD_GROUNDED); + m_uib_adc[0]->vin_callback().set_ioport("STICK0_X"); + m_uib_adc[1]->vin_callback().set_ioport("STICK0_Y"); + /* synchronization forced on the fly */ MB_VCU(config, m_vcu, SOUND_CLOCK/4); m_vcu->set_cpu_tag("sub2"); @@ -1041,6 +1049,13 @@ void mazerbla_state::greatgun(machine_config &config) */ sub2.set_vblank_int("screen", FUNC(mazerbla_state::irq0_line_hold)); + for (int i = 0; i < 4; i++) + ADC0804(config, m_uib_adc[i], RES_R(10), CAP_P(150)).set_rd_mode(adc0804_device::RD_GROUNDED); + m_uib_adc[0]->vin_callback().set_ioport("STICK0_X"); + m_uib_adc[1]->vin_callback().set_ioport("STICK0_Y"); + m_uib_adc[2]->vin_callback().set_ioport("STICK1_X"); + m_uib_adc[3]->vin_callback().set_ioport("STICK1_Y"); + MB_VCU(config, m_vcu, SOUND_CLOCK/4); m_vcu->set_cpu_tag("sub2"); m_vcu->set_palette_tag("palette"); -- cgit v1.2.3