+#ifdef USE_SDL_LIBRARY
+
+static unsigned long mainCounter(int mode)
+{
+ static unsigned long base_ms = 0;
+ unsigned long current_ms;
+ unsigned long counter_ms;
+
+ current_ms = SDL_GetTicks();
+
+ /* reset base time in case of counter initializing or wrap-around */
+ if (mode == INIT_COUNTER || current_ms < base_ms)
+ base_ms = current_ms;
+
+ counter_ms = current_ms - base_ms;
+
+ return counter_ms; /* return milliseconds since last init */
+}
+
+#else /* !USE_SDL_LIBRARY */