From b347d0a5314c6e74ed527f818e4bfb026e08d67f Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 23 Sep 2014 17:43:19 +0200 Subject: [PATCH] Game caps on 1000 FPS now --- SAFix/SilentPatchSA.cpp | 141 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/SAFix/SilentPatchSA.cpp b/SAFix/SilentPatchSA.cpp index bcce3e8..8c253cd 100644 --- a/SAFix/SilentPatchSA.cpp +++ b/SAFix/SilentPatchSA.cpp @@ -1450,6 +1450,129 @@ DarkVehiclesFix4_MakeItDark: } // 1.0 ONLY ENDS HERE +static void* const FPSLimit_ReturnTrue = AddressByVersion(0x748D98, 0x74969D, 0x782D22); +static void* const FPSLimit_ReturnFalse = AddressByVersion(0x748DA3, 0x7496A8, 0x782D2D); +static int& FPSLimitVal = **AddressByVersion(0x619622, 0x619E42, 0x63B112); +void __declspec(naked) YesFPSLimit() +{ + static const double f1000 = 1000.0; + _asm + { + mov eax, [FPSLimitVal] + fild [eax] + fdivr [f1000] + fcomp [esp+94h-80h] + fnstsw ax + test ah, 5 + jp YesFPSLimit_Skip + + jmp FPSLimit_ReturnTrue + +YesFPSLimit_Skip: + jmp FPSLimit_ReturnFalse + } +} + +void __declspec(naked) NoFPSLimit() +{ + _asm + { + test al, al + jnz YesFPSLimit + + fld1 + fcomp [esp+94h-80h] + fnstsw ax + test ah, 5 + jp NoFPSLimit_Skip + + jmp FPSLimit_ReturnTrue + +NoFPSLimit_Skip: + jmp FPSLimit_ReturnFalse + } +} + +void __declspec(naked) YesFPSLimit_11() +{ + static const double f1000 = 1000.0; + _asm + { + mov eax, [FPSLimitVal] + fild [eax] + fdivr [f1000] + fcomp [esp+1Ch] + fnstsw ax + test ah, 5 + jp YesFPSLimit_Skip + + jmp FPSLimit_ReturnTrue + +YesFPSLimit_Skip: + jmp FPSLimit_ReturnFalse + } +} + +void __declspec(naked) NoFPSLimit_11() +{ + _asm + { + test al, al + jnz YesFPSLimit_11 + + fld1 + fcomp [esp+1Ch] + fnstsw ax + test ah, 5 + jp NoFPSLimit_Skip + + jmp FPSLimit_ReturnTrue + +NoFPSLimit_Skip: + jmp FPSLimit_ReturnFalse + } +} + +void __declspec(naked) YesFPSLimit_Steam() +{ + static const double f1000 = 1000.0; + _asm + { + mov eax, [FPSLimitVal] + fild [eax] + fdivr [f1000] + fcomp [esp+90h-78h] + fnstsw ax + test ah, 5 + jp YesFPSLimit_Skip + + jmp FPSLimit_ReturnTrue + +YesFPSLimit_Skip: + jmp FPSLimit_ReturnFalse + } +} + +void __declspec(naked) NoFPSLimit_Steam() +{ + _asm + { + test al, al + jnz YesFPSLimit_Steam + + fld1 + fcomp [esp+90h-78h] + fnstsw ax + test ah, 5 + jp NoFPSLimit_Skip + + jmp FPSLimit_ReturnTrue + +NoFPSLimit_Skip: + jmp FPSLimit_ReturnFalse + } +} + static const float fSteamSubtitleSizeX = 0.45f; static const float fSteamSubtitleSizeY = 0.9f; static const float fSteamRadioNamePosY = 33.0f; @@ -2253,6 +2376,12 @@ void Patch_SA_10() Patch(0x746368, desktop.bottom); Patch(0x7463C8, aNoDesktopMode); + // 1000 FPS cap + Patch(0x748D69, 0x18); + Patch(0x748D72, 0x0F); + InjectHook(0x748D7D, NoFPSLimit, PATCH_JUMP); + InjectHook(0x748D82, YesFPSLimit, PATCH_JUMP); + // Fixed police scanner names char* pScannerNames = *(char**)0x4E72D4; strncpy(pScannerNames + (8*113), "WESTP", 8); @@ -2455,6 +2584,12 @@ void Patch_SA_11() Patch(0x746BE8, desktop.bottom); Patch(0x746C48, aNoDesktopMode); + // 1000 FPS cap + Patch(0x74966E, 0x18); + Patch(0x749677, 0x0F); + InjectHook(0x749682, NoFPSLimit_11, PATCH_JUMP); + InjectHook(0x749687, YesFPSLimit_11, PATCH_JUMP); + // Fixed police scanner names char* pScannerNames = *(char**)0x4E7714; strncpy(pScannerNames + (8*113), "WESTP", 8); @@ -2631,6 +2766,12 @@ void Patch_SA_Steam() Patch(0x78021E, desktop.bottom); Patch(0x78027E, aNoDesktopMode); + // 1000 FPS cap + Patch(0x782CF1, 0x18); + Patch(0x782CFA, 0x0F); + InjectHook(0x782D05, NoFPSLimit_Steam, PATCH_JUMP); + InjectHook(0x782D0A, YesFPSLimit_Steam, PATCH_JUMP); + // Fixed police scanner names char* pScannerNames = *(char**)0x4F2B83; strncpy(pScannerNames + (8*113), "WESTP", 8);