From df5405de65e38b9ba9d06ea2a306e4b980c29466 Mon Sep 17 00:00:00 2001 From: AJR Date: Sat, 8 Oct 2016 14:27:04 -0400 Subject: [PATCH] witch: Take the "Hopper Active" DSW value into proper account; no longer must it be low Add ticket_dispenser_device::motor_w as a proper WRITE_LINE method, first step towards eliminating the m_active_bit=0x80 nonsense (nw) (#1485 please take note) --- src/mame/drivers/witch.cpp | 12 ++++++++++-- src/mame/machine/ticket.cpp | 12 +++++++++++- src/mame/machine/ticket.h | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/mame/drivers/witch.cpp b/src/mame/drivers/witch.cpp index 1c0ce81a155..c488382a987 100644 --- a/src/mame/drivers/witch.cpp +++ b/src/mame/drivers/witch.cpp @@ -274,6 +274,7 @@ public: int m_scrollx; int m_scrolly; UINT8 m_reg_a002; + UINT8 m_motor_active; DECLARE_WRITE8_MEMBER(gfx0_vram_w); DECLARE_WRITE8_MEMBER(gfx0_cram_w); DECLARE_WRITE8_MEMBER(gfx1_vram_w); @@ -295,6 +296,7 @@ public: virtual void video_start() override; UINT32 screen_update_witch(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); + virtual void machine_reset() override; }; @@ -420,8 +422,7 @@ WRITE8_MEMBER(witch_state::write_a006) if (data == 0) return; - // TODO: this assumes the "Hopper Active" DSW is "Low" - m_hopper->write(space, 0, !BIT(data, 1) ? 0x80 : 0); + m_hopper->motor_w(!BIT(data, 1) ^ m_motor_active); // TODO: Bit 3 = Attendant Pay @@ -695,6 +696,7 @@ void witch_state::video_start() save_item(NAME(m_scrollx)); save_item(NAME(m_scrolly)); save_item(NAME(m_reg_a002)); + save_item(NAME(m_motor_active)); } void witch_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) @@ -756,6 +758,12 @@ UINT32 witch_state::screen_update_witch(screen_device &screen, bitmap_ind16 &bit return 0; } +void witch_state::machine_reset() +{ + // Keep track of the "Hopper Active" DSW value because the program will use it + m_motor_active = (ioport("YM_PortB")->read() & 0x08) ? 0 : 1; +} + static MACHINE_CONFIG_START( witch, witch_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", Z80, CPU_CLOCK) /* 3 MHz */ diff --git a/src/mame/machine/ticket.cpp b/src/mame/machine/ticket.cpp index 3bd90d40e53..551afdfa04d 100644 --- a/src/mame/machine/ticket.cpp +++ b/src/mame/machine/ticket.cpp @@ -98,6 +98,7 @@ void ticket_dispenser_device::static_set_senses(device_t &device, UINT8 motor_se //------------------------------------------------- // read - read the status line via the active bit +// (legacy method) //------------------------------------------------- READ8_MEMBER( ticket_dispenser_device::read ) @@ -119,7 +120,7 @@ READ_LINE_MEMBER( ticket_dispenser_device::line_r ) //------------------------------------------------- // write - write the control line via the active -// bit +// bit (legacy method) //------------------------------------------------- WRITE8_MEMBER( ticket_dispenser_device::write ) @@ -147,6 +148,15 @@ WRITE8_MEMBER( ticket_dispenser_device::write ) } } +//------------------------------------------------- +// motor_w - write the control line as a proper +// line +//------------------------------------------------- + +WRITE_LINE_MEMBER( ticket_dispenser_device::motor_w ) +{ + write(machine().driver_data()->generic_space(), 0, state ? m_active_bit : 0); +} //************************************************************************** diff --git a/src/mame/machine/ticket.h b/src/mame/machine/ticket.h index 1d02202103e..629d215355f 100644 --- a/src/mame/machine/ticket.h +++ b/src/mame/machine/ticket.h @@ -64,6 +64,7 @@ public: DECLARE_READ8_MEMBER( read ); DECLARE_READ_LINE_MEMBER( line_r ); DECLARE_WRITE8_MEMBER( write ); + DECLARE_WRITE_LINE_MEMBER( motor_w ); protected: // device-level overrides