mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-11-22 13:32:36 +01:00
More stable framelimiter - III
This commit is contained in:
parent
4d459e0ad4
commit
3b98e5abaf
@ -234,6 +234,21 @@ char* GetMyDocumentsPath()
|
||||
return cUserFilesPath;
|
||||
}
|
||||
|
||||
static LARGE_INTEGER FrameTime;
|
||||
DWORD GetTimeSinceLastFrame()
|
||||
{
|
||||
LARGE_INTEGER curTime;
|
||||
QueryPerformanceCounter(&curTime);
|
||||
return curTime.QuadPart - FrameTime.QuadPart;
|
||||
}
|
||||
|
||||
static void (*RsEventHandler)(int, void*);
|
||||
void NewFrameRender(int nEvent, void* pParam)
|
||||
{
|
||||
QueryPerformanceCounter(&FrameTime);
|
||||
RsEventHandler(nEvent, pParam);
|
||||
}
|
||||
|
||||
static char aNoDesktopMode[64];
|
||||
|
||||
void Patch_III_10(const RECT& desktop)
|
||||
@ -350,6 +365,12 @@ void Patch_III_10(const RECT& desktop)
|
||||
// BOOOOORING fixed
|
||||
Patch<BYTE>(0x4925D7, 10);
|
||||
|
||||
// (Hopefully) more precise frame limiter
|
||||
int pAddress = 0x582EFD;
|
||||
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5);
|
||||
InjectHook(pAddress, NewFrameRender);
|
||||
InjectHook(0x582EA4, GetTimeSinceLastFrame);
|
||||
|
||||
// Default to desktop res
|
||||
Patch<DWORD>(0x581E5E, desktop.right);
|
||||
Patch<DWORD>(0x581E68, desktop.bottom);
|
||||
@ -475,6 +496,12 @@ void Patch_III_11(const RECT& desktop)
|
||||
OldWndProc = *(LRESULT (CALLBACK***)(HWND, UINT, WPARAM, LPARAM))0x581FB4;
|
||||
Patch(0x581FB4, &pCustomWndProc);
|
||||
|
||||
// (Hopefully) more precise frame limiter
|
||||
int pAddress = 0x58323D;
|
||||
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5);
|
||||
InjectHook(pAddress, NewFrameRender);
|
||||
InjectHook(0x5831E4, GetTimeSinceLastFrame);
|
||||
|
||||
// Default to desktop res
|
||||
Patch<DWORD>(0x58219E, desktop.right);
|
||||
Patch<DWORD>(0x5821A8, desktop.bottom);
|
||||
@ -596,6 +623,12 @@ void Patch_III_Steam(const RECT& desktop)
|
||||
OldWndProc = *(LRESULT (CALLBACK***)(HWND, UINT, WPARAM, LPARAM))0x581EA4;
|
||||
Patch(0x581EA4, &pCustomWndProc);
|
||||
|
||||
// (Hopefully) more precise frame limiter
|
||||
int pAddress = 0x58312D;
|
||||
RsEventHandler = (void(*)(int,void*))(*(int*)(pAddress+1) + pAddress + 5);
|
||||
InjectHook(pAddress, NewFrameRender);
|
||||
InjectHook(0x5830D4, GetTimeSinceLastFrame);
|
||||
|
||||
// Default to desktop res
|
||||
Patch<DWORD>(0x58208E, desktop.right);
|
||||
Patch<DWORD>(0x582098, desktop.bottom);
|
||||
|
Loading…
Reference in New Issue
Block a user