From 98fb80a8cabd7729ba7adfa339c528dbe0a14275 Mon Sep 17 00:00:00 2001 From: MetalliC <0vetal0@gmail.com> Date: Sat, 20 May 2017 17:06:28 +0300 Subject: [PATCH] add hopper-like mode to ticket dispenser device --- src/mame/drivers/stv.cpp | 12 +++--------- src/mame/machine/ticket.cpp | 20 ++++++++++++++++---- src/mame/machine/ticket.h | 9 +++++++-- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/mame/drivers/stv.cpp b/src/mame/drivers/stv.cpp index 1417869f38d..98c0fa7e481 100644 --- a/src/mame/drivers/stv.cpp +++ b/src/mame/drivers/stv.cpp @@ -256,14 +256,8 @@ WRITE8_MEMBER(stv_state::stvmp_ioga_w) WRITE8_MEMBER(stv_state::hop_ioga_w) { - if (offset == 7) { - if ((data & 0x80) == 0) { - m_hopper->motor_w(0); // - m_hopper->motor_w(0x80); // ugly hack to reset status of ticket dispenser device - m_hopper->motor_w(0); - } else - m_hopper->motor_w(0x80); - } + if (offset == 7) + m_hopper->motor_w(data & 0x80); stv_ioga_w(space, offset, data); } @@ -1141,7 +1135,7 @@ static MACHINE_CONFIG_DERIVED( stv_slot, stv ) MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( hopper, stv ) - MCFG_TICKET_DISPENSER_ADD("hopper", attotime::from_msec(100), TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_HIGH) + MCFG_HOPPER_ADD("hopper", attotime::from_msec(100), TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_HIGH) MACHINE_CONFIG_END MACHINE_RESET_MEMBER(stv_state,stv) diff --git a/src/mame/machine/ticket.cpp b/src/mame/machine/ticket.cpp index 92265c814ae..bb7c4481f98 100644 --- a/src/mame/machine/ticket.cpp +++ b/src/mame/machine/ticket.cpp @@ -43,6 +43,7 @@ ticket_dispenser_device::ticket_dispenser_device(const machine_config &mconfig, m_motor_sense(TICKET_MOTOR_ACTIVE_LOW), m_status_sense(TICKET_STATUS_ACTIVE_LOW), m_period(attotime::from_msec(100)), + m_hopper_type(false), m_active_bit(0x80), m_motoron(0), m_ticketdispensed(0), @@ -83,11 +84,12 @@ void ticket_dispenser_device::static_set_period(device_t &device, const attotime // the motor and status bits //------------------------------------------------- -void ticket_dispenser_device::static_set_senses(device_t &device, uint8_t motor_sense, uint8_t status_sense) +void ticket_dispenser_device::static_set_senses(device_t &device, uint8_t motor_sense, uint8_t status_sense, bool hopper_type) { ticket_dispenser_device &ticket = downcast(device); ticket.m_motor_sense = motor_sense; ticket.m_status_sense = status_sense; + ticket.m_hopper_type = hopper_type; } @@ -140,9 +142,12 @@ WRITE8_MEMBER( ticket_dispenser_device::write ) { if (m_power) { - LOG(("%s: Ticket Power Off\n", machine().describe_context())); - m_timer->adjust(attotime::never); - machine().output().set_led_value(2,0); + if (m_hopper_type == false || m_status == m_ticketnotdispensed) + { + LOG(("%s: Ticket Power Off\n", machine().describe_context())); + m_timer->adjust(attotime::never); + machine().output().set_led_value(2, 0); + } m_power = 0; } } @@ -205,6 +210,13 @@ void ticket_dispenser_device::device_timer(emu_timer &timer, device_timer_id id, LOG(("Ticket Status Changed to %02X\n", m_status)); m_timer->adjust(m_period); } + else if (m_hopper_type) + { + m_status ^= m_active_bit; + LOG(("%s: Ticket Power Off\n", machine().describe_context())); + m_timer->adjust(attotime::never); + machine().output().set_led_value(2, 0); + } // update LED status (fixme: should map to an output) machine().output().set_led_value(2, (m_status == m_ticketdispensed)); diff --git a/src/mame/machine/ticket.h b/src/mame/machine/ticket.h index cb48cba8587..929085fe5b9 100644 --- a/src/mame/machine/ticket.h +++ b/src/mame/machine/ticket.h @@ -30,8 +30,12 @@ DECLARE_DEVICE_TYPE(TICKET_DISPENSER, ticket_dispenser_device) #define MCFG_TICKET_DISPENSER_ADD(_tag, _period_in_msec, _motor_sense, _status_sense) \ MCFG_DEVICE_ADD(_tag, TICKET_DISPENSER, 0) \ ticket_dispenser_device::static_set_period(*device, _period_in_msec); \ - ticket_dispenser_device::static_set_senses(*device, _motor_sense, _status_sense); + ticket_dispenser_device::static_set_senses(*device, _motor_sense, _status_sense, false); +#define MCFG_HOPPER_ADD(_tag, _period_in_msec, _motor_sense, _status_sense) \ + MCFG_DEVICE_ADD(_tag, TICKET_DISPENSER, 0) \ + ticket_dispenser_device::static_set_period(*device, _period_in_msec); \ + ticket_dispenser_device::static_set_senses(*device, _motor_sense, _status_sense, true); //************************************************************************** // CONSTANTS @@ -60,7 +64,7 @@ public: // inline configuration helpers static void static_set_period(device_t &device, const attotime &period); - static void static_set_senses(device_t &device, uint8_t motor_sense, uint8_t status_sense); + static void static_set_senses(device_t &device, uint8_t motor_sense, uint8_t status_sense, bool hopper_type); // read/write handlers DECLARE_READ8_MEMBER( read ); @@ -78,6 +82,7 @@ protected: uint8_t m_motor_sense; uint8_t m_status_sense; attotime m_period; + bool m_hopper_type; // active state uint8_t m_active_bit;