Skip to content

Commit

Permalink
Merge branch 'master' into add-frame-interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
viti95 authored Aug 29, 2024
2 parents 1c49c66 + a1baaed commit 3e22d3a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 51 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Added player sprite rendering display option (player weapon)
* Fix issue #203. Now savegames are different for each IWAD
* Fix issue on command line parameter "-iwad"
* Faster update rate for the onscreen FPS counter (thanks for the idea @tigrouind)
* Faster update rate for the onscreen FPS counter (@tigrouind)
* Reduced memory usage
* Fixed map names for FreeDoom (now map names are stored in the folder "LEVELS")

Expand Down
5 changes: 1 addition & 4 deletions FASTDOOM/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,6 @@ void D_DoomLoop(void)

while (1)
{
frame_ticcount = ticcount;

// process one or more tics
if (singletics)
{
Expand Down Expand Up @@ -610,8 +608,7 @@ void D_DoomLoopBenchmark(void)
// TODO rdtsc for later CPUs?
while (1)
{
frame_ticcount = ticcount;
start_time = ticcount;
start_time = mscount;

if (uncappedFPS)
{
Expand Down
19 changes: 10 additions & 9 deletions FASTDOOM/hu_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void HU_Start(void)

// [JN] Create the FPS widget
HUlib_initTextLine(&w_fps,
SCREENWIDTH - 48, HU_MSGY,
SCREENWIDTH - 24, HU_MSGY,
hu_font,
HU_FONTSTART);

Expand All @@ -118,15 +118,15 @@ void HU_Start(void)

void HU_DrawScreenFPS(void)
{
static char str[16];
static char str[4];
char *f;
int fpswhole, fpsfrac, tmp;
fpswhole = Div10(fps);
fpsfrac = fps - Mul10(fpswhole);
int fpswhole, tmp;
fpswhole = fps;

f = str + sizeof(str) - 1;

*f-- = '\0'; // NULL terminate
*f-- = '0' + fpsfrac; // Decimal digit
*f = '.'; // dot

// Manual simple unsigned itoa for the whole part
while (1)
{
Expand All @@ -136,6 +136,7 @@ void HU_DrawScreenFPS(void)
break;
fpswhole = tmp;
}

HUlib_clearTextLine(&w_fps);
while (*f)
{
Expand All @@ -149,7 +150,7 @@ void HU_DrawScreenFPS(void)

void HU_DrawDebugCard2DigitsFPS(void)
{
unsigned int outfps = fps / 10;
unsigned int outfps = fps;
unsigned int outval = 0;
unsigned int counter = 0;

Expand All @@ -168,7 +169,7 @@ void HU_DrawDebugCard2DigitsFPS(void)

void HU_DrawDebugCard4DigitsFPS(void)
{
unsigned int outfps = fps / 10;
unsigned int outfps = fps;
unsigned int outval = 0;
unsigned int counter = 0;
int port = debugCardPort;
Expand Down
70 changes: 35 additions & 35 deletions FASTDOOM/i_ibm.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,47 +567,47 @@ void I_UpdateNoBlit(void)

extern int screenblocks;

#define fps_storage_size 16
unsigned int stored_fps[fps_storage_size];
unsigned int fps_array_pos = 0;
unsigned int frame_ticcount;
//#define HIGH_PRECISION_FPS
#define TIMER_RATE 35
#define MAX_FPS 256 //must be power of 2

void I_CalculateFPS(void)
{
static unsigned int fps_counter, fps_starttime, fps_nextcalculation, average_fps, smoothness;
unsigned int opt1, opt2;
unsigned int current_fps;
unsigned int total;
unsigned int i;
unsigned int fps_time[MAX_FPS];
unsigned int fps_head = 0;
unsigned int fps_tail = 0;
unsigned int fps_size = 0;

if (fps_counter == 0)
fps_starttime = frame_ticcount;

fps_counter++;
#ifdef HIGH_PRECISION_FPS
unsigned int fps_sum = 0;
#endif

opt2 = frame_ticcount - fps_starttime;
void I_CalculateFPS(void)
{
unsigned time = ticcount;

if (opt2 != 0)
//dequeue old items (older than 1 sec)
while ((fps_size > 0 && ((time - fps_time[fps_head]) >= TIMER_RATE))
|| (fps_size >= MAX_FPS))
{
opt1 = 35 * 10 * (fps_counter - 1);
current_fps = opt1 / opt2;

fps_counter = 0;

stored_fps[fps_array_pos] = current_fps;

total = 0;
for (i = 0; i < fps_storage_size; i++)
{
total += stored_fps[i];
}

fps = total / fps_storage_size;

fps_array_pos++;
if (fps_array_pos == fps_storage_size)
fps_array_pos = 0;
#ifdef HIGH_PRECISION_FPS
fps_sum -= fps_time[fps_head] - fps_time[(fps_head + MAX_FPS - 1) % MAX_FPS];
#endif
fps_head = (fps_head + 1) % MAX_FPS;
fps_size--;
}

//enqueue new item
#ifdef HIGH_PRECISION_FPS
fps_sum += time - fps_time[(fps_tail + MAX_FPS - 1) % MAX_FPS];
#endif
fps_time[fps_tail] = time;
fps_tail = (fps_tail + 1) % MAX_FPS;
fps_size++;

#ifdef HIGH_PRECISION_FPS
fps = fps_sum == 0 ? 0 : (TIMER_RATE * fps_size) / fps_sum;
#else
fps = fps_size;
#endif
}

//
Expand Down
2 changes: 0 additions & 2 deletions FASTDOOM/i_ibm.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "options.h"

extern unsigned int ticcount_hr;
extern unsigned int frame_ticcount;
extern unsigned int ticcount;
extern unsigned int fps;

Expand All @@ -27,4 +26,3 @@ extern void *I_DosMemAlloc(unsigned long size);
void I_StartupTimer(void);
void I_ShutdownTimer(void);
void I_SetHrTimerEnabled(boolean enabled);

0 comments on commit 3e22d3a

Please sign in to comment.