shithub: zelda3

Download patch

ref: b60754746106adab515226b763b4135e5461edbe
parent: 25c5b4226a514cec1ffb2ce6b46f81adf26fc1cf
author: Snesrev <[email protected]>
date: Thu Sep 22 10:12:43 EDT 2022

Avoid up/down and left/right from being pressed at the same time (Fixes #105)

--- a/main.c
+++ b/main.c
@@ -358,14 +358,19 @@
       continue;
     }
 
+    uint64 t0 = SDL_GetPerformanceCounter();
+
     // Clear gamepad inputs when joypad directional inputs to avoid wonkiness
     int inputs = g_input1_state;
     if (g_input1_state & 0xf0)
       g_gamepad_buttons = 0;
+    inputs |= g_gamepad_buttons;
 
-    uint64 t0 = SDL_GetPerformanceCounter();
+    // Avoid up/down and left/right from being pressed at the same time
+    if ((inputs & 0x30) == 0x30) inputs ^= 0x30;
+    if ((inputs & 0xc0) == 0xc0) inputs ^= 0xc0;
 
-    bool is_turbo = RunOneFrame(snes_run, g_input1_state | g_gamepad_buttons, (frameCtr++ & 0x7f) != 0 && g_turbo);
+    bool is_turbo = RunOneFrame(snes_run, inputs, (frameCtr++ & 0x7f) != 0 && g_turbo);
 
     if (is_turbo)
       continue;