diff options
-rw-r--r-- | src/devices/bus/bbc/userport/pointer.cpp | 63 | ||||
-rw-r--r-- | src/devices/bus/bbc/userport/pointer.h | 8 |
2 files changed, 27 insertions, 44 deletions
diff --git a/src/devices/bus/bbc/userport/pointer.cpp b/src/devices/bus/bbc/userport/pointer.cpp index d8272766d98..18c861265d4 100644 --- a/src/devices/bus/bbc/userport/pointer.cpp +++ b/src/devices/bus/bbc/userport/pointer.cpp @@ -47,10 +47,10 @@ DEFINE_DEVICE_TYPE(BBC_TRACKER, bbc_tracker_device, "bbc_tracker", "Marcon static INPUT_PORTS_START( amxmouse ) PORT_START("POINTER_X") - PORT_BIT(0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(5) PORT_CHANGED_MEMBER(DEVICE_SELF, bbc_pointer_device, pointer_changed, 0) PORT_RESET + PORT_BIT(0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_START("POINTER_Y") - PORT_BIT(0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(5) PORT_CHANGED_MEMBER(DEVICE_SELF, bbc_pointer_device, pointer_changed, 0) PORT_RESET + PORT_BIT(0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_START("BUTTONS") PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Mouse Left Button (Execute)") PORT_CODE(MOUSECODE_BUTTON1) @@ -65,10 +65,10 @@ INPUT_PORTS_END static INPUT_PORTS_START( m512mouse ) PORT_START("POINTER_X") - PORT_BIT(0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(5) PORT_CHANGED_MEMBER(DEVICE_SELF, bbc_pointer_device, pointer_changed, 0) PORT_RESET + PORT_BIT(0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_START("POINTER_Y") - PORT_BIT(0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(5) PORT_CHANGED_MEMBER(DEVICE_SELF, bbc_pointer_device, pointer_changed, 0) PORT_RESET + PORT_BIT(0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_START("BUTTONS") PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Mouse Left Button") PORT_CODE(MOUSECODE_BUTTON1) @@ -82,10 +82,10 @@ INPUT_PORTS_END static INPUT_PORTS_START( tracker ) PORT_START("POINTER_X") - PORT_BIT(0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(5) PORT_CHANGED_MEMBER(DEVICE_SELF, bbc_pointer_device, pointer_changed, 0) PORT_RESET + PORT_BIT(0xff, 0x00, IPT_TRACKBALL_X) PORT_SENSITIVITY(100) PORT_START("POINTER_Y") - PORT_BIT(0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(5) PORT_CHANGED_MEMBER(DEVICE_SELF, bbc_pointer_device, pointer_changed, 0) PORT_RESET + PORT_BIT(0xff, 0x00, IPT_TRACKBALL_Y) PORT_SENSITIVITY(100) PORT_START("BUTTONS") PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Left Button") PORT_CODE(MOUSECODE_BUTTON1) @@ -151,8 +151,7 @@ bbc_tracker_device::bbc_tracker_device(const machine_config &mconfig, const char void bbc_pointer_device::device_start() { - m_pointer_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(bbc_pointer_device::pointer_poll), this)); - m_pointer_timer->adjust(attotime::zero, 0, attotime::from_hz(1400)); + m_pointer_timer = timer_alloc(); } @@ -164,12 +163,12 @@ void bbc_pointer_device::device_reset() { m_xdir = 0; m_ydir = 0; - m_direction_x = 0; - m_direction_y = 0; - m_distance_x = 0; - m_distance_y = 0; + m_x = 0; + m_y = 0; m_phase_x = 0; m_phase_y = 0; + + m_pointer_timer->adjust(attotime::zero, 0, attotime::from_hz(1400)); } @@ -177,25 +176,16 @@ void bbc_pointer_device::device_reset() // IMPLEMENTATION //************************************************************************** -INPUT_CHANGED_MEMBER(bbc_pointer_device::pointer_changed) +void bbc_pointer_device::device_timer(emu_timer &timer, device_timer_id id, int param) { int x = m_pointer_x->read(); int y = m_pointer_y->read(); - x -= (x & 0x80) ? 0x100 : 0; - y -= (y & 0x80) ? 0x100 : 0; - // Set the mouse movement direction and record the movement units - m_direction_x = (x > 0) ? 1 : 0; - m_distance_x = abs(x); - - m_direction_y = (y > 0) ? 1 : 0; - m_distance_y = abs(y); -} + int dx = x - m_x; + int dy = y - m_y; -TIMER_CALLBACK_MEMBER(bbc_pointer_device::pointer_poll) -{ // Process X output - if (m_distance_x) + if (dx) { // Set the output pins according to the current phase switch (m_phase_x) @@ -215,20 +205,17 @@ TIMER_CALLBACK_MEMBER(bbc_pointer_device::pointer_poll) } // Change phase - if (m_direction_x == 0) - m_phase_x--; - else + if (dx > 0) m_phase_x++; - - // Decrement the distance left to move - m_distance_x--; + else + m_phase_x--; // Range check the phase m_phase_x &= 3; } // Process Y output - if (m_distance_y) + if (dy) { // Set the output pins according to the current phase switch (m_phase_y) @@ -248,17 +235,17 @@ TIMER_CALLBACK_MEMBER(bbc_pointer_device::pointer_poll) } // Change phase - if (m_direction_y == 0) - m_phase_y--; - else + if (dy > 0) m_phase_y++; - - // Decrement the distance left to move - m_distance_y--; + else + m_phase_y--; // Range check the phase m_phase_y &= 3; } + + m_x = x; + m_y = y; } uint8_t bbc_amxmouse_device::pb_r() diff --git a/src/devices/bus/bbc/userport/pointer.h b/src/devices/bus/bbc/userport/pointer.h index a6e1bd0a629..c830caf7f00 100644 --- a/src/devices/bus/bbc/userport/pointer.h +++ b/src/devices/bus/bbc/userport/pointer.h @@ -22,9 +22,6 @@ class bbc_pointer_device : public device_t, public device_bbc_userport_interface { -public: - DECLARE_INPUT_CHANGED_MEMBER(pointer_changed); - protected: // construction/destruction bbc_pointer_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); @@ -32,6 +29,7 @@ protected: // device-level overrides virtual void device_start() override; virtual void device_reset() override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param) override; required_ioport m_pointer_x; required_ioport m_pointer_y; @@ -41,11 +39,9 @@ protected: int m_xdir, m_ydir; // internal quadrature state - int m_direction_x, m_direction_y; - int m_distance_x, m_distance_y; + int m_x, m_y; int m_phase_x, m_phase_y; - TIMER_CALLBACK_MEMBER(pointer_poll); emu_timer *m_pointer_timer; }; |