Added a frameskip mode, mainly to debug replays
This commit is contained in:
parent
cb2cf24233
commit
3d639aae52
4 changed files with 24 additions and 1 deletions
18
src/global.c
18
src/global.c
|
@ -31,6 +31,20 @@ void init_global(void) {
|
|||
|
||||
memset(&global.replay, 0, sizeof(Replay));
|
||||
global.replaymode = REPLAY_RECORD;
|
||||
|
||||
char *e = getenv("TAISEI_SANIC");
|
||||
|
||||
if(e) {
|
||||
global.frameskip = atoi(e);
|
||||
|
||||
if(global.frameskip < 0) {
|
||||
global.frameskip = INT_MAX;
|
||||
}
|
||||
|
||||
if(global.frameskip) {
|
||||
warnx("FPS limiter disabled by environment. Gotta go fast! (frameskip = %i)", global.frameskip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void print_state_checksum(void) {
|
||||
|
@ -54,6 +68,10 @@ void print_state_checksum(void) {
|
|||
}
|
||||
|
||||
void frame_rate(int *lasttime) {
|
||||
if(global.frameskip) {
|
||||
return;
|
||||
}
|
||||
|
||||
int t = *lasttime + 1000.0/FPS - SDL_GetTicks();
|
||||
if(t > 0)
|
||||
SDL_Delay(t);
|
||||
|
|
|
@ -103,6 +103,7 @@ typedef struct {
|
|||
int frames;
|
||||
int lasttime; // frame limiter
|
||||
int timer;
|
||||
int frameskip;
|
||||
|
||||
Boss *boss;
|
||||
Dialog *dialog;
|
||||
|
|
|
@ -159,7 +159,7 @@ Sound *get_snd(Sound *source, char *name) {
|
|||
|
||||
void play_sound_p(char *name, int unconditional)
|
||||
{
|
||||
if(tconfig.intval[NO_AUDIO]) return;
|
||||
if(tconfig.intval[NO_AUDIO] || global.frameskip) return;
|
||||
|
||||
Sound *snd = get_snd(resources.sounds, name);
|
||||
if (snd == NULL) return;
|
||||
|
|
|
@ -518,6 +518,10 @@ void stage_loop(StageInfo* info, StageRule start, StageRule end, StageRule draw,
|
|||
|
||||
stage_logic(endtime);
|
||||
|
||||
if(global.frameskip && global.frames % global.frameskip) {
|
||||
continue;
|
||||
}
|
||||
|
||||
calc_fps(&global.fps);
|
||||
|
||||
tsrand_switch(&global.rand_visual);
|
||||
|
|
Loading…
Reference in a new issue