Do not reject 1.5 format SOLs
[neverball] / share / state.c
index f7a8f65..0088874 100644 (file)
 #include "glext.h"
 #include "state.h"
 #include "config.h"
+#include "video.h"
 
 /*---------------------------------------------------------------------------*/
 
-static float  state_time;
+static float         state_time;
+static int           state_drawn;
 static struct state *state;
 
 struct state *curr_state(void)
@@ -41,8 +43,9 @@ int goto_state(struct state *st)
     if (state && state->leave)
         state->leave(state->gui_id);
 
-    state      = st;
-    state_time =  0;
+    state       = st;
+    state_time  = 0;
+    state_drawn = 0;
 
     if (state && state->enter)
         state->gui_id = state->enter();
@@ -52,32 +55,37 @@ int goto_state(struct state *st)
 
 /*---------------------------------------------------------------------------*/
 
-void st_paint(void)
+void st_paint(float t)
 {
-    int stereo  = config_get_d(CONFIG_STEREO);
+    int stereo = config_get_d(CONFIG_STEREO);
+
+    state_drawn = 1;
 
     if (state && state->paint)
     {
         if (stereo)
         {
             glDrawBuffer(GL_BACK_LEFT);
-            config_clear();
-            state->paint(state->gui_id, (float) (+stereo));
+            video_clear();
+            state->paint(state->gui_id, t);
 
             glDrawBuffer(GL_BACK_RIGHT);
-            config_clear();
-            state->paint(state->gui_id, (float) (-stereo));
+            video_clear();
+            state->paint(state->gui_id, t);
         }
         else
         {
-            config_clear();
-            state->paint(state->gui_id, 0.0f);
+            video_clear();
+            state->paint(state->gui_id, t);
         }
     }
 }
 
 void st_timer(float dt)
 {
+    if (!state_drawn)
+        return;
+
     state_time += dt;
 
     if (state && state->timer)
@@ -92,6 +100,14 @@ void st_point(int x, int y, int dx, int dy)
 
 void st_stick(int a, int k)
 {
+    if ((config_tst_d(CONFIG_JOYSTICK_AXIS_X, a) &&
+         config_get_d(CONFIG_JOYSTICK_AXIS_X_INVERT)) ||
+        (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a) &&
+         config_get_d(CONFIG_JOYSTICK_AXIS_Y_INVERT)) ||
+        (config_tst_d(CONFIG_JOYSTICK_AXIS_U, a) &&
+         config_get_d(CONFIG_JOYSTICK_AXIS_U_INVERT)))
+        k = -k;
+
     if (state && state->stick)
         state->stick(state->gui_id, a, k);
 }