case XK_8:
case XK_9:
if (key == XK_0)
- GameSpeed = 500;
+ GameFrameDelay = 500;
else
- GameSpeed = (key - XK_0) * 10;
- printf("GameSpeed == %d\n", GameSpeed);
+ GameFrameDelay = (key - XK_0) * 10;
+ printf("Game speed == %d%% (%d ms delay between two frames)\n",
+ GAME_FRAME_DELAY * 100 / GameFrameDelay, GameFrameDelay);
break;
case XK_a:
#ifdef DEBUG
action_delay_value =
- (tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : GameSpeed);
+ (tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : GameFrameDelay);
#else
action_delay_value =
(tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : GAME_FRAME_DELAY);
}
}
- if (TimeLeft>0 && TimeFrames>=(1000/GameSpeed) && !tape.pausing)
+ if (TimeLeft>0 && TimeFrames>=(1000/GameFrameDelay) && !tape.pausing)
{
TimeFrames = 0;
TimeLeft--;
/* fundamental game speed */
#define GAME_FRAME_DELAY 20 /* frame delay in milliseconds */
-#define FFWD_FRAME_DELAY 1
+#define FFWD_FRAME_DELAY 10 /* 200% speed for fast forward */
#define FRAMES_PER_SECOND (1000 / GAME_FRAME_DELAY)
void GetPlayerConfig(void);
int autorecord_on = FALSE;
int joystick_nr = 0;
int quick_doors = FALSE;
-int cpu_friendly = TRUE;
BOOL redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
int redraw_x1 = 0, redraw_y1 = 0;
int lev_fieldx,lev_fieldy, scroll_x,scroll_y;
int FX = SX, FY = SY, ScreenMovPos = 0, ScrollStepSize = TILEX/8;
-int GameSpeed = GAME_FRAME_DELAY, MoveSpeed = 8;
+int GameFrameDelay = GAME_FRAME_DELAY, MoveSpeed = 8;
int BX1 = 0, BY1 = 0, BX2 = SCR_FIELDX-1, BY2 = SCR_FIELDY-1;
int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY;
int PlayerMovDir, PlayerMovPos, PlayerPushing;
extern int autorecord_on;
extern int joystick_nr;
extern int quick_doors;
-extern int cpu_friendly;
extern BOOL redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE];
extern int redraw_x1, redraw_y1;
extern int lev_fieldx,lev_fieldy, scroll_x,scroll_y;
extern int FX,FY, ScreenMovPos, ScrollStepSize;
-extern int GameSpeed, MoveSpeed;
+extern int GameFrameDelay, MoveSpeed;
extern int BX1,BY1, BX2,BY2;
extern int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY;
extern int PlayerMovDir, PlayerMovPos, PlayerPushing;
static void sleep_milliseconds(unsigned long milliseconds_delay)
{
- if (milliseconds_delay < 5 || !cpu_friendly)
+ if (milliseconds_delay < 5)
{
- /* we want to wait less than 5 ms -- if we assume that we have a
+ /* we want to wait only a few ms -- if we assume that we have a
kernel timer resolution of 10 ms, we would wait far to long;
therefore it's better to do a short interval of busy waiting
to get our sleeping time more accurate */
void WaitUntilDelayReached(unsigned long *counter_var, unsigned long delay)
{
- unsigned long actual_counter = Counter();
+ unsigned long actual_counter;
+
+ while(1)
+ {
+ actual_counter = Counter();
- if (actual_counter < *counter_var + delay && actual_counter >= *counter_var)
- sleep_milliseconds(*counter_var + delay - actual_counter);
+ if (actual_counter < *counter_var + delay &&
+ actual_counter >= *counter_var)
+ sleep_milliseconds((*counter_var + delay - actual_counter) / 2);
+ else
+ break;
+ }
*counter_var = actual_counter;
}