mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Clean up some timing-related code.
- duke3d.h: comment the timing marcos a bit more - factor out smoothratio calculation - (TICRATE/TICSPERFRAME) --> REALGAMETICSPERSEC git-svn-id: https://svn.eduke32.com/eduke32@3007 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
8fba52a2bb
commit
fba2556f9b
6 changed files with 32 additions and 25 deletions
|
@ -40,11 +40,11 @@ int32_t g_demo_rewind=0;
|
|||
int32_t g_demo_showStats=1;
|
||||
static int32_t g_demo_soundToggle;
|
||||
|
||||
static int32_t demo_hasdiffs, demorec_diffs=1, demorec_difftics = 2*(TICRATE/TICSPERFRAME);
|
||||
static int32_t demo_hasdiffs, demorec_diffs=1, demorec_difftics = 2*REALGAMETICSPERSEC;
|
||||
int32_t demoplay_diffs=1;
|
||||
int32_t demorec_diffs_cvar=1;
|
||||
int32_t demorec_force_cvar=0;
|
||||
int32_t demorec_difftics_cvar = 2*(TICRATE/TICSPERFRAME);
|
||||
int32_t demorec_difftics_cvar = 2*REALGAMETICSPERSEC;
|
||||
int32_t demorec_diffcompress_cvar=1;
|
||||
int32_t demorec_synccompress_cvar=1;
|
||||
int32_t demorec_seeds_cvar=1;
|
||||
|
@ -114,7 +114,7 @@ static int32_t G_OpenDemoRead(int32_t g_whichDemo) // 0 = mine
|
|||
demo_hasseeds = demo_synccompress&2;
|
||||
demo_synccompress &= 1;
|
||||
|
||||
i = g_demo_totalCnt/(TICRATE/TICSPERFRAME);
|
||||
i = g_demo_totalCnt/REALGAMETICSPERSEC;
|
||||
OSD_Printf("demo %d duration: %d min %d sec\n", g_whichDemo, i/60, i%60);
|
||||
|
||||
g_demo_cnt = 1;
|
||||
|
@ -494,7 +494,7 @@ RECHECK:
|
|||
}
|
||||
|
||||
while (totalclock >= (lockclock+TICSPERFRAME)
|
||||
// || (ud.reccnt > (TICRATE/TICSPERFRAME)*2 && ud.pause_on)
|
||||
// || (ud.reccnt > REALGAMETICSPERSEC*2 && ud.pause_on)
|
||||
|| (g_demo_goalCnt>0 && g_demo_cnt<g_demo_goalCnt))
|
||||
{
|
||||
if (ud.reccnt<=0)
|
||||
|
@ -642,8 +642,6 @@ nextdemo_nomenu:
|
|||
|
||||
G_HandleLocalKeys();
|
||||
|
||||
// j = min(max((totalclock-lockclock)*(65536/TICSPERFRAME),0),65536);
|
||||
|
||||
if (framewaiting)
|
||||
{
|
||||
framewaiting--;
|
||||
|
@ -666,7 +664,7 @@ nextdemo_nomenu:
|
|||
|
||||
nextrender += g_frameDelay;
|
||||
|
||||
j = min(max((totalclock - ototalclock) * (65536 / 4),0),65536);
|
||||
j = calc_smoothratio(totalclock, ototalclock);
|
||||
if (g_demo_paused && g_demo_rewind)
|
||||
j = 65536-j;
|
||||
|
||||
|
@ -693,7 +691,7 @@ nextdemo_nomenu:
|
|||
gametext(160,100,buf,0,2+8+16);
|
||||
}
|
||||
#endif
|
||||
j=g_demo_cnt/(TICRATE/TICSPERFRAME);
|
||||
j=g_demo_cnt/REALGAMETICSPERSEC;
|
||||
Bsprintf(buf, "%02d:%02d", j/60, j%60);
|
||||
gametext(18,16,buf,0,2+8+16+1024);
|
||||
|
||||
|
@ -705,7 +703,7 @@ nextdemo_nomenu:
|
|||
j = (182<<16) - ((((120*(g_demo_totalCnt-g_demo_cnt))<<4)/g_demo_totalCnt)<<12);
|
||||
rotatesprite_fs(j,(16<<16)+(1<<15),32768,0,SLIDEBAR+1,0,0,2+8+16+1024);
|
||||
|
||||
j=(g_demo_totalCnt-g_demo_cnt)/(TICRATE/TICSPERFRAME);
|
||||
j=(g_demo_totalCnt-g_demo_cnt)/REALGAMETICSPERSEC;
|
||||
Bsprintf(buf, "-%02d:%02d%s", j/60, j%60, g_demo_paused?" ^15PAUSED":"");
|
||||
gametext(194,16,buf,0,2+8+16+1024);
|
||||
}
|
||||
|
|
|
@ -74,12 +74,20 @@ extern "C" {
|
|||
#define MAXLEVELS 64
|
||||
#define MAXGAMETYPES 16
|
||||
|
||||
// used as a constant to satisfy all of the calculations written with ticrate = 26 in mind
|
||||
#define GAMETICSPERSEC 26
|
||||
#define REALGAMETICSPERSEC 30
|
||||
// this used to be TICRATE/GAMETICSPERSEC, which was 120/26 = 4.615~ truncated to 4 by integer division
|
||||
#define TICSPERFRAME 4
|
||||
////////// TIMING CONSTANTS //////////
|
||||
// The number of 'totalclock' increments per second:
|
||||
#define TICRATE 120
|
||||
// The number of game state updates per second:
|
||||
#define REALGAMETICSPERSEC 30
|
||||
// The number of 'totalclock' increments per game state update:
|
||||
// NOTE: calling a game state update a 'frame' is really weird.
|
||||
// (This used to be TICRATE/GAMETICSPERSEC, which was 120/26 = 4.615~ truncated
|
||||
// to 4 by integer division.)
|
||||
#define TICSPERFRAME (TICRATE/REALGAMETICSPERSEC)
|
||||
// Used as a constant to satisfy all of the calculations written with ticrate =
|
||||
// 26 in mind:
|
||||
#define GAMETICSPERSEC 26
|
||||
|
||||
|
||||
#define PACKBUF_SIZE 16384
|
||||
|
||||
|
|
|
@ -2754,8 +2754,9 @@ void G_DisplayRest(int32_t smoothratio)
|
|||
if (ud.overhead_on > 0)
|
||||
{
|
||||
// smoothratio = min(max(smoothratio,0),65536);
|
||||
smoothratio = min(max((totalclock - ototalclock) * (65536 / 4),0),65536);
|
||||
smoothratio = calc_smoothratio(totalclock, ototalclock);
|
||||
G_DoInterpolations(smoothratio);
|
||||
|
||||
if (ud.scrollmode == 0)
|
||||
{
|
||||
if (pp->newowner == -1 && !ud.pause_on)
|
||||
|
@ -7638,7 +7639,7 @@ void G_HandleLocalKeys(void)
|
|||
{
|
||||
KB_ClearKeyDown(sc_kpad_6);
|
||||
j = (15<<ALT_IS_PRESSED)<<(2*SHIFTS_IS_PRESSED);
|
||||
g_demo_goalCnt = g_demo_paused ? g_demo_cnt+1 : g_demo_cnt+(TICRATE/TICSPERFRAME)*j;
|
||||
g_demo_goalCnt = g_demo_paused ? g_demo_cnt+1 : g_demo_cnt+REALGAMETICSPERSEC*j;
|
||||
g_demo_rewind = 0;
|
||||
|
||||
if (g_demo_goalCnt > g_demo_totalCnt)
|
||||
|
@ -7650,7 +7651,7 @@ void G_HandleLocalKeys(void)
|
|||
{
|
||||
KB_ClearKeyDown(sc_kpad_4);
|
||||
j = (15<<ALT_IS_PRESSED)<<(2*SHIFTS_IS_PRESSED);
|
||||
g_demo_goalCnt = g_demo_paused ? g_demo_cnt-1 : g_demo_cnt-(TICRATE/TICSPERFRAME)*j;
|
||||
g_demo_goalCnt = g_demo_paused ? g_demo_cnt-1 : g_demo_cnt-REALGAMETICSPERSEC*j;
|
||||
g_demo_rewind = 1;
|
||||
|
||||
if (g_demo_goalCnt <= 0)
|
||||
|
@ -10664,7 +10665,7 @@ MAIN_LOOP_RESTART:
|
|||
|
||||
if ((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && !(g_player[myconnectindex].ps->gm&MODE_MENU)) ||
|
||||
(g_netServer || ud.multimode > 1) || ud.recstat == 2)
|
||||
i = min(max((totalclock-ototalclock)*(65536L/TICSPERFRAME),0),65536);
|
||||
i = calc_smoothratio(totalclock, ototalclock);
|
||||
else
|
||||
i = 65536;
|
||||
|
||||
|
|
|
@ -340,6 +340,11 @@ static inline void G_HandleAsync(void)
|
|||
Net_GetPackets();
|
||||
}
|
||||
|
||||
static inline int32_t calc_smoothratio(int32_t totalclk, int32_t ototalclk)
|
||||
{
|
||||
return clamp((totalclk-ototalclk)*(65536/TICSPERFRAME), 0, 65536);
|
||||
}
|
||||
|
||||
// sector effector lotags
|
||||
enum {
|
||||
SE_16_REACTOR = 16,
|
||||
|
|
|
@ -2415,7 +2415,7 @@ nullquote:
|
|||
int32_t y1=Gv_GetVarX(*insptr++);
|
||||
int32_t x2=Gv_GetVarX(*insptr++);
|
||||
int32_t y2=Gv_GetVarX(*insptr++);
|
||||
int32_t smoothratio = min(max((totalclock - ototalclock) * (65536 / 4),0),65536);
|
||||
int32_t smoothratio = calc_smoothratio(totalclock, ototalclock);
|
||||
#ifdef USE_OPENGL
|
||||
int32_t oprojhacks;
|
||||
#endif
|
||||
|
@ -2479,11 +2479,6 @@ nullquote:
|
|||
newaspect_enable = o;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (!ud.pause_on && ((ud.show_help == 0 && (!net_server && ud.multimode < 2) && !(g_player[myconnectindex].ps->gm&MODE_MENU))
|
||||
|| (net_server || ud.multimode > 1) || ud.recstat == 2))
|
||||
smoothratio = min(max((totalclock-ototalclock)*(65536L/TICSPERFRAME),0),65536);
|
||||
#endif
|
||||
G_DoInterpolations(smoothratio);
|
||||
|
||||
G_HandleMirror(x, y, z, a, horiz, smoothratio);
|
||||
|
|
|
@ -1403,7 +1403,7 @@ int32_t registerosdcommands(void)
|
|||
{ "demorec_force","demorec_force: enable/disable forced demo recording",(void *)&demorec_force_cvar, CVAR_BOOL|CVAR_NOSAVE, 0, 1 },
|
||||
{
|
||||
"demorec_difftics","demorec_difftics <number>: sets game tic interval after which a diff is recorded",
|
||||
(void *)&demorec_difftics_cvar, CVAR_INT, 2, 60*(TICRATE/TICSPERFRAME)
|
||||
(void *)&demorec_difftics_cvar, CVAR_INT, 2, 60*REALGAMETICSPERSEC
|
||||
},
|
||||
{ "demorec_diffcompress","demorec_diffcompress <number>: Compression method for diffs. (0: none, 1: KSLZW)",(void *)&demorec_diffcompress_cvar, CVAR_INT, 0, 1 },
|
||||
{ "demorec_synccompress","demorec_synccompress <number>: Compression method for input. (0: none, 1: KSLZW)",(void *)&demorec_synccompress_cvar, CVAR_INT, 0, 1 },
|
||||
|
|
Loading…
Reference in a new issue