static int joystick_up = 0;
static int joystick_down = 0;
static int joystick_fire = 0;
+static int joystick_left_reset = 0;
+static int joystick_right_reset = 0;
+static int joystick_up_reset = 0;
+static int joystick_down_reset = 0;
+static int joystick_fire_reset = 0;
#define CIAAPRA 0xbfe000
#define JOYDAT1 0xdff00c
}
/* use -1 to keep state unchanged */
+/* NOTE: a pressed and then released button/stick will sustain until reset_joystick() is called after rendering was done.
+ * this ensures that a short press (during rendering one frame) will not get lost.
+ */
void set_joystick(int left, int right, int up, int down, int fire)
{
+ if (left == 1)
+ joystick_left = 1;
if (left >= 0)
- joystick_left = left;
+ joystick_left_reset = left;
+ if (right == 1)
+ joystick_right = 1;
if (right >= 0)
- joystick_right = right;
+ joystick_right_reset = right;
+ if (up == 1)
+ joystick_up = 1;
if (up >= 0)
- joystick_up = up;
+ joystick_up_reset = up;
+ if (down == 1)
+ joystick_down = 1;
if (down >= 0)
- joystick_down = down;
+ joystick_down_reset = down;
+ if (fire == 1)
+ joystick_fire = 1;
if (fire >= 0)
- joystick_fire = fire;
+ joystick_fire_reset = fire;
}
+void reset_joystick(void)
+{
+ joystick_left = joystick_left_reset;
+ joystick_right = joystick_right_reset;
+ joystick_up = joystick_up_reset;
+ joystick_down = joystick_down_reset;
+ joystick_fire = joystick_fire_reset;
+}
/* for amiga speed: set delay by the number of cycles */
if (config_amiga_speed)
render_delay += (double)cycle_count / CPU_SPEED;
+ /* reset joystick after rendering */
+ reset_joystick();
}
/* STEP 2: transfer legacy image (or just benson) in memory to OpenGL texture */