Thursday, July 18, 2013

MAME Tempest mouse input patch

I love the classic arcade game Tempest, as well as its later incarnations and derivations from Llamasoft (Tempest 2000, Space Giraffe). I noticed that the mouse input in the current version of mame (0.149) had a bug in it, where moving too quickly to the right or left resulted in motion in the opposite direction. This is apparently due to the fact that Tempest uses only 4 signed bits of resolution for spinner deltas, and MAME was supplying higher values causing overflow. I made a quick and dirty patch to fix this, by hardcoding the max incoming adjust mouse delta values. Worth a shot if this is bothering you too.

--- src\emu\ioport.c.orig       2013-02-11 14:23:02.000000000 -0500
+++ src\emu\ioport.c    2013-07-18 16:16:08.000000000 -0400
@@ -4376,6 +4376,12 @@
                m_accum = 0;

        // apply the delta to the accumulated value
+
+#define MYMAXDELTA 32000
+        if( delta > MYMAXDELTA )
+                delta = MYMAXDELTA;
+        if( delta < -MYMAXDELTA )
+                delta = -MYMAXDELTA;
        m_accum += delta;

        // if our last movement was due to a digital input, and if this control
@@ -4435,6 +4441,9 @@
        // apply standard analog settings
        value = apply_settings(value);

+       if ( value == 0 )
+               return; // do nothing
+
        // remap the value if needed
        if (m_field.remap_table() != NULL)
                value = m_field.remap_table()[value];

No comments:

Post a Comment