Added a frameskip mode, mainly to debug replays

This commit is contained in:
Andrei "Akari" Alexeyev 2017-02-05 20:25:18 +02:00
parent cb2cf24233
commit 3d639aae52
4 changed files with 24 additions and 1 deletions

View file

@ -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);

View file

@ -103,6 +103,7 @@ typedef struct {
int frames;
int lasttime; // frame limiter
int timer;
int frameskip;
Boss *boss;
Dialog *dialog;

View file

@ -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;

View file

@ -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);