Files
source/Standard Gaming Platform/timer.cpp
T
majcostaandGitHub 24425a82b1 More unused stuff removal (#49)
* More unused stuff removal

delete:
- giant 'metaheaders' (JA2 All.h, Laptop All.h, etc), preferring to add #includes directly where needed
- unused ExceptionHandling and DbMan translation units
- unused WizShare.h, Bitmap.h, trle.h, video_private.h headers

* remove mentions from vc proj files too

* remove preprocessor conditionals for unused definitions

find . -iname '*.h' -o -iname '*.cpp' -exec unifdef.exe -m -UPRECOMPILED_HEADERS -UJA2_PRECOMPILED_HEADERS -UWIZ8_PRECOMPILED_HEADERS -UPRECOMPILEDHEADERS {} ';'

then manually fixed a couple files the tool errored out on

* yes, the comments too

as title
2023-01-03 15:51:48 +02:00

68 lines
1.4 KiB
C++

#include "types.h"
#include <windows.h>
#if defined( JA2 ) || defined( UTIL )
#include "video.h"
#else
#include "video2.h"
#endif
#include "timer.h"
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
UINT32 guiStartupTime;
UINT32 guiCurrentTime;
void CALLBACK Clock( HWND hWindow, UINT uMessage, UINT idEvent, DWORD dwTime )
{
guiCurrentTime = GetTickCount();
if (guiCurrentTime < guiStartupTime)
{ // Adjust guiCurrentTime because of loopback on the timer value
guiCurrentTime = guiCurrentTime + (0xffffffff - guiStartupTime);
}
else
{ // Adjust guiCurrentTime because of loopback on the timer value
guiCurrentTime = guiCurrentTime - guiStartupTime;
}
}
BOOLEAN InitializeClockManager(void)
{
// Register the start time (use WIN95 API call)
guiCurrentTime = guiStartupTime = GetTickCount();
SetTimer(ghWindow, MAIN_TIMER_ID, 10, (TIMERPROC)Clock);
return TRUE;
}
void ShutdownClockManager(void)
{
// Make sure we kill the timer
KillTimer(ghWindow, MAIN_TIMER_ID);
}
TIMER GetClock(void)
{
return guiCurrentTime;
}
TIMER SetCountdownClock(UINT32 uiTimeToElapse)
{
return (guiCurrentTime + uiTimeToElapse);
}
UINT32 ClockIsTicking(TIMER uiTimer)
{
if (uiTimer > guiCurrentTime)
{ // Well timer still hasn't elapsed
return (uiTimer - guiCurrentTime);
}
// Time's up
return 0;
}