diff --git a/stepmania/src/arch/ArchHooks/ArchHooks.h b/stepmania/src/arch/ArchHooks/ArchHooks.h index 950b412e57..4e7554bc34 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks.h +++ b/stepmania/src/arch/ArchHooks/ArchHooks.h @@ -1,20 +1,6 @@ #ifndef ARCH_HOOKS_H #define ARCH_HOOKS_H -/* - * I'm undecided about when it's a good idea to use arch; I'm experimenting - * a bit. - * - * This arch driver is simply called at various important points, to let - * architectures do things. Windows can use this to start up the crash - * handler and to output Windows-specific debug information, for example. - * - * This class should have one-way data transfer only: functions are called, - * they may do something, and no data is returned. (We don't want to have - * to deal with error handling and so on when using these functions.) - * - * This class is constructed at the very start of the program. - */ class ArchHooks { public: @@ -36,6 +22,9 @@ public: virtual void ExitTimeCriticalSection() { } virtual void SetTime( tm newtime ) { } + + /* */ + virtual int64_t GetMicrosecondsSinceStart() = 0; }; ArchHooks *MakeArchHooks(); diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp index a12b77863e..adbd4188c4 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp @@ -13,6 +13,9 @@ #include "archutils/win32/VideoDriverInfo.h" #include "archutils/win32/WindowsResources.h" +#include +#pragma comment(lib, "winmm.lib") // for GetMicrosecondsSinceStart + ArchHooks_Win32::ArchHooks_Win32() { SetUnhandledExceptionFilter(CrashHandler); @@ -182,6 +185,20 @@ void ArchHooks_Win32::SetTime( tm newtime ) SetLocalTime( &st ); } +int64_t ArchHooks_Win32::GetMicrosecondsSinceStart() +{ + static bool bInitialized; + static DWORD iStartTime; + if( !bInitialized ) + { + timeBeginPeriod( 1 ); + bInitialized = true; + iStartTime = timeGetTime(); + } + + return (timeGetTime() - iStartTime) * 1000; +} + /* * (c) 2003-2004 Glenn Maynard, Chris Danford * All rights reserved. diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h index c9a6b51f08..3d72256aa7 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h @@ -17,6 +17,7 @@ public: void EnterTimeCriticalSection(); void ExitTimeCriticalSection(); void SetTime( tm newtime ); + int64_t GetMicrosecondsSinceStart(); private: void CheckVideoDriver();