summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2021-11-06 12:07:22 -0400
committer AJR <ajrhacker@users.noreply.github.com>2021-11-06 12:07:22 -0400
commit79738b4cb44a039bd6bf04632585ffeb9bb4648d (patch)
tree6f9bca527bd4d39dcaec81c03400a723493fee3e /src/devices/machine
parentc8148093e39370cec2734e776d1a0db46b1f8a5a (diff)
upd4701: Change input update method to not use PORT_RESET
Diffstat (limited to 'src/devices/machine')
-rw-r--r--src/devices/machine/upd4701.cpp37
-rw-r--r--src/devices/machine/upd4701.h9
2 files changed, 37 insertions, 9 deletions
diff --git a/src/devices/machine/upd4701.cpp b/src/devices/machine/upd4701.cpp
index 6a053a41063..d840492073b 100644
--- a/src/devices/machine/upd4701.cpp
+++ b/src/devices/machine/upd4701.cpp
@@ -28,6 +28,8 @@ upd4701_device::upd4701_device(const machine_config &mconfig, const char *tag, d
, m_starty(0)
, m_x(0)
, m_y(0)
+ , m_last_x_read(0)
+ , m_last_y_read(0)
, m_switches(0)
, m_latchswitches(0)
, m_cf(true)
@@ -60,13 +62,15 @@ void upd4701_device::device_start()
save_item(NAME(m_starty));
save_item(NAME(m_x));
save_item(NAME(m_y));
+ save_item(NAME(m_last_x_read));
+ save_item(NAME(m_last_y_read));
save_item(NAME(m_switches));
save_item(NAME(m_latchswitches));
save_item(NAME(m_cf));
- // register special callback for analog inputs
+ // register special callback for inputs
if (m_portx.found() || m_porty.found())
- machine().add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(&upd4701_device::analog_update, this));
+ machine().add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(&upd4701_device::update, this));
}
//-------------------------------------------------
@@ -211,15 +215,36 @@ void upd4701_device::reset_xy_w(u8 data)
}
//-------------------------------------------------
-// analog_update - per-frame input update
+// update - per-frame input update
//-------------------------------------------------
-void upd4701_device::analog_update()
+void upd4701_device::update()
{
if (m_portx.found())
- x_add(m_portx->read() & MASK_COUNTER);
+ {
+ u16 x = m_portx->read() & MASK_COUNTER;
+ x_add(x - m_last_x_read);
+ m_last_x_read = x;
+ }
+ if (m_porty.found())
+ {
+ u16 y = m_porty->read() & MASK_COUNTER;
+ y_add(y - m_last_y_read);
+ m_last_y_read = y;
+ }
+}
+
+//-------------------------------------------------
+// recalibrate - refresh saved X & Y inputs
+// (to be used if the input source changes)
+//-------------------------------------------------
+
+void upd4701_device::recalibrate()
+{
+ if (m_portx.found())
+ m_last_x_read = m_portx->read() & MASK_COUNTER;
if (m_porty.found())
- y_add(m_porty->read() & MASK_COUNTER);
+ m_last_y_read = m_porty->read() & MASK_COUNTER;
}
//-------------------------------------------------
diff --git a/src/devices/machine/upd4701.h b/src/devices/machine/upd4701.h
index bfc77a00fc3..245ef7bf82c 100644
--- a/src/devices/machine/upd4701.h
+++ b/src/devices/machine/upd4701.h
@@ -39,8 +39,8 @@ public:
auto sf_cb() { return m_sf_cb.bind(); }
auto open_bus_cb() { return m_open_bus_cb.bind(); }
- void x_add(s16 data);
- void y_add(s16 data);
+ void update();
+ void recalibrate();
DECLARE_WRITE_LINE_MEMBER(cs_w);
DECLARE_WRITE_LINE_MEMBER(xy_w);
@@ -72,7 +72,8 @@ protected:
private:
// internal helpers
- void analog_update();
+ void x_add(s16 data);
+ void y_add(s16 data);
void switch_update(u8 mask, bool state);
// control lines
@@ -91,6 +92,8 @@ private:
s16 m_starty;
s16 m_x;
s16 m_y;
+ u16 m_last_x_read;
+ u16 m_last_y_read;
// switch state
u8 m_switches;