From e8c7efdc32a5f7cc91768dc40cb94b09f6afb422 Mon Sep 17 00:00:00 2001 From: cam900 Date: Mon, 6 May 2019 19:06:12 +0900 Subject: [PATCH] taitoio_yoke.cpp : Updates Simplify handlers, Reduce runtime tag lookups --- src/mame/drivers/mlanding.cpp | 12 ++++++------ src/mame/drivers/taitoair.cpp | 12 ++++++------ src/mame/machine/taitoio_yoke.cpp | 27 +++++++++++++++------------ src/mame/machine/taitoio_yoke.h | 11 ++++++++--- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/mame/drivers/mlanding.cpp b/src/mame/drivers/mlanding.cpp index 0326639fbfd..b6c3fa81384 100644 --- a/src/mame/drivers/mlanding.cpp +++ b/src/mame/drivers/mlanding.cpp @@ -483,19 +483,19 @@ WRITE16_MEMBER(mlanding_state::output_w) READ16_MEMBER(mlanding_state::analog1_msb_r) { - return (m_yoke->throttle_r(space,0) >> 4) & 0xff; + return (m_yoke->throttle_r() >> 4) & 0xff; } READ16_MEMBER(mlanding_state::analog2_msb_r) { - return (m_yoke->stickx_r(space,0) >> 4) & 0xff; + return (m_yoke->stickx_r() >> 4) & 0xff; } READ16_MEMBER(mlanding_state::analog3_msb_r) { - return (m_yoke->sticky_r(space,0) >> 4) & 0xff; + return (m_yoke->sticky_r() >> 4) & 0xff; } @@ -509,7 +509,7 @@ READ16_MEMBER(mlanding_state::analog1_lsb_r) .x...... Slot down */ - uint8_t res = (ioport("LIMIT0")->read() & 0x70) | (m_yoke->throttle_r(space,0) & 0xf); + uint8_t res = (ioport("LIMIT0")->read() & 0x70) | (m_yoke->throttle_r() & 0xf); return res; } @@ -521,7 +521,7 @@ READ16_MEMBER(mlanding_state::analog2_lsb_r) 76543210 ....xxxx Counter 2 bits 3-0 */ - return m_yoke->stickx_r(space,0) & 0x0f; + return m_yoke->stickx_r() & 0x0f; } @@ -534,7 +534,7 @@ READ16_MEMBER(mlanding_state::analog3_lsb_r) ..x..... Handle left .x...... Handle up */ - uint8_t res = (ioport("LIMIT1")->read() & 0x70) | (m_yoke->sticky_r(space,0) & 0xf); + uint8_t res = (ioport("LIMIT1")->read() & 0x70) | (m_yoke->sticky_r() & 0xf); return res; } diff --git a/src/mame/drivers/taitoair.cpp b/src/mame/drivers/taitoair.cpp index 0ec2eb8e635..9505e980db2 100644 --- a/src/mame/drivers/taitoair.cpp +++ b/src/mame/drivers/taitoair.cpp @@ -304,16 +304,16 @@ READ16_MEMBER(taitoair_state::stick_input_r) switch( offset ) { case 0x00: /* "counter 1" lo */ - return m_yoke->throttle_r(space,0) & 0xff; + return m_yoke->throttle_r() & 0xff; case 0x01: /* "counter 2" lo */ - return m_yoke->stickx_r(space,0) & 0xff; + return m_yoke->stickx_r() & 0xff; case 0x02: /* "counter 1" hi */ - return (m_yoke->throttle_r(space,0) & 0xff00) >> 8; + return (m_yoke->throttle_r() & 0xff00) >> 8; case 0x03: /* "counter 2" hi */ - return (m_yoke->stickx_r(space,0) & 0xff00) >> 8; + return (m_yoke->stickx_r() & 0xff00) >> 8; } return 0; @@ -324,10 +324,10 @@ READ16_MEMBER(taitoair_state::stick2_input_r) switch( offset ) { case 0x00: /* "counter 3" lo */ - return m_yoke->sticky_r(space,0); + return m_yoke->sticky_r(); case 0x02: /* "counter 3" hi */ - return (m_yoke->sticky_r(space,0) & 0xff00) >> 8; + return (m_yoke->sticky_r() & 0xff00) >> 8; } return 0; diff --git a/src/mame/machine/taitoio_yoke.cpp b/src/mame/machine/taitoio_yoke.cpp index 576c925edc4..9d7fa7fec24 100644 --- a/src/mame/machine/taitoio_yoke.cpp +++ b/src/mame/machine/taitoio_yoke.cpp @@ -37,6 +37,9 @@ DEFINE_DEVICE_TYPE(TAITOIO_YOKE, taitoio_yoke_device, "taitoio_yoke", "Taito I/O taitoio_yoke_device::taitoio_yoke_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, TAITOIO_YOKE, tag, owner, clock) + , m_stick_x(*this, "STICK_X") + , m_stick_y(*this, "STICK_Y") + , m_throttle(*this, "THROTTLE") { } @@ -82,59 +85,59 @@ ioport_constructor taitoio_yoke_device::device_input_ports() const // READ/WRITE HANDLERS //************************************************************************** -READ16_MEMBER( taitoio_yoke_device::stickx_r ) +u16 taitoio_yoke_device::stickx_r() { - return ioport("STICK_X")->read(); + return m_stick_x->read(); } -READ16_MEMBER( taitoio_yoke_device::sticky_r ) +u16 taitoio_yoke_device::sticky_r() { - return ioport("STICK_Y")->read(); + return m_stick_y->read(); } -READ16_MEMBER( taitoio_yoke_device::throttle_r ) +u16 taitoio_yoke_device::throttle_r() { - return ioport("THROTTLE")->read(); + return m_throttle->read(); } READ_LINE_MEMBER( taitoio_yoke_device::slot_down_r ) { - uint16_t throttle = ioport("THROTTLE")->read(); + uint16_t throttle = m_throttle->read(); return (throttle & 0xe00) == 0x600; } READ_LINE_MEMBER( taitoio_yoke_device::slot_up_r ) { - uint16_t throttle = ioport("THROTTLE")->read(); + uint16_t throttle = m_throttle->read(); return (throttle & 0xe00) == 0x800; } READ_LINE_MEMBER( taitoio_yoke_device::handle_left_r ) { - uint16_t x = ioport("STICK_X")->read(); + uint16_t x = m_stick_x->read(); return (x & 0xe00) == 0x800; } READ_LINE_MEMBER( taitoio_yoke_device::handle_right_r ) { - uint16_t x = ioport("STICK_X")->read(); + uint16_t x = m_stick_x->read(); return (x & 0xe00) == 0x600; } READ_LINE_MEMBER( taitoio_yoke_device::handle_up_r ) { - uint16_t y = ioport("STICK_Y")->read(); + uint16_t y = m_stick_y->read(); return (y & 0xe00) == 0x800; } READ_LINE_MEMBER( taitoio_yoke_device::handle_down_r ) { - uint16_t y = ioport("STICK_Y")->read(); + uint16_t y = m_stick_y->read(); return (y & 0xe00) == 0x600; } diff --git a/src/mame/machine/taitoio_yoke.h b/src/mame/machine/taitoio_yoke.h index b80a0af910e..d531ade856a 100644 --- a/src/mame/machine/taitoio_yoke.h +++ b/src/mame/machine/taitoio_yoke.h @@ -22,9 +22,9 @@ public: taitoio_yoke_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); // I/O operations - DECLARE_READ16_MEMBER( throttle_r ); - DECLARE_READ16_MEMBER( stickx_r ); - DECLARE_READ16_MEMBER( sticky_r ); + u16 throttle_r(); + u16 stickx_r(); + u16 sticky_r(); DECLARE_READ_LINE_MEMBER( slot_up_r ); DECLARE_READ_LINE_MEMBER( slot_down_r ); @@ -40,6 +40,11 @@ protected: // virtual void device_validity_check(validity_checker &valid) const; virtual void device_start() override; virtual void device_reset() override; + +private: + required_ioport m_stick_x; + required_ioport m_stick_y; + required_ioport m_throttle; };