SilentPatchVC: Fixup the MSVC inline assembly statements

Also clean them up in general
This commit is contained in:
Echo J 2024-11-07 10:11:20 +02:00 committed by Silent
parent 7819f30c75
commit 5d90ed55d7

View file

@ -669,12 +669,12 @@ float FixedRefValue()
return 1.0f; return 1.0f;
} }
void __declspec(naked) SubtitlesShadowFix() __declspec(naked) void SubtitlesShadowFix()
{ {
_asm _asm
{ {
mov [esp], eax mov [esp], eax
fild [esp] fild dword ptr [esp]
push eax push eax
lea eax, [esp+20h-18h] lea eax, [esp+20h-18h]
push eax push eax
@ -685,14 +685,14 @@ void __declspec(naked) SubtitlesShadowFix()
} }
} }
void __declspec(naked) CreateInstance_BikeFix() __declspec(naked) void CreateInstance_BikeFix()
{ {
_asm _asm
{ {
push eax push eax
mov ecx, ebp mov ecx, ebp
call CVehicleModelInfo::GetExtrasFrame call CVehicleModelInfo::GetExtrasFrame
retn ret
} }
} }
@ -731,9 +731,10 @@ unsigned int __cdecl AutoPilotTimerCalculation_VC(unsigned int nTimer, int nScal
return nTimer - static_cast<unsigned int>(nScaleFactor * fScaleCoef); return nTimer - static_cast<unsigned int>(nScaleFactor * fScaleCoef);
} }
void __declspec(naked) AutoPilotTimerFix_VC() __declspec(naked) void AutoPilotTimerFix_VC()
{
_asm
{ {
_asm {
push dword ptr [esp + 0xC] push dword ptr [esp + 0xC]
push dword ptr [ebx + 0x10] push dword ptr [ebx + 0x10]
push eax push eax
@ -743,7 +744,7 @@ void __declspec(naked) AutoPilotTimerFix_VC()
add esp, 0x30 add esp, 0x30
pop ebp pop ebp
pop ebx pop ebx
retn 4 ret 4
} }
} }
@ -863,23 +864,23 @@ namespace Localization
// ============= Corrected FBI Washington sirens sound ============= // ============= Corrected FBI Washington sirens sound =============
namespace SirenSwitchingFix namespace SirenSwitchingFix
{ {
void __declspec(naked) IsFBIRanchOrFBICar() __declspec(naked) static void IsFBIRanchOrFBICar()
{ {
_asm _asm
{ {
mov dword ptr [esi+1Ch], 1Ch mov dword ptr [esi+0x1C], 0x1C
// al = 0 - high pitched siren // al = 0 - high pitched siren
// al = 1 - normal siren // al = 1 - normal siren
cmp dword ptr [ebp+14h], 90 // fbiranch cmp dword ptr [ebp+0x14], 90 // fbiranch
je IsFBIRanchOrFBICar_HighPitchSiren je IsFBIRanchOrFBICar_HighPitchSiren
cmp dword ptr [ebp+14h], 17 // fbicar cmp dword ptr [ebp+0x14], 17 // fbicar
setne al setne al
retn ret
IsFBIRanchOrFBICar_HighPitchSiren: IsFBIRanchOrFBICar_HighPitchSiren:
xor al, al xor al, al
retn ret
} }
} }
} }
@ -945,22 +946,22 @@ namespace FBISirenCoronaFix
// ============= Fixed vehicles exploding twice if the driver leaves the car while it's exploding ============= // ============= Fixed vehicles exploding twice if the driver leaves the car while it's exploding =============
namespace RemoveDriverStatusFix namespace RemoveDriverStatusFix
{ {
__declspec(naked) void RemoveDriver_SetStatus() __declspec(naked) static void RemoveDriver_SetStatus()
{ {
// if (m_nStatus != STATUS_WRECKED) // if (m_nStatus != STATUS_WRECKED)
// m_nStatus = STATUS_ABANDONED; // m_nStatus = STATUS_ABANDONED;
_asm _asm
{ {
mov cl, [ebx+50h] mov cl, [ebx+0x50]
mov al, cl mov al, cl
and cl, 0F8h and cl, 0xF8
cmp cl, 28h cmp cl, 0x28
je DontSetStatus je DontSetStatus
and al, 7 and al, 7
or al, 20h or al, 0x20
DontSetStatus: DontSetStatus:
retn ret
} }
} }
} }
@ -1038,7 +1039,7 @@ namespace NullTerminatedLines
{ {
mov eax, [esp+4] mov eax, [esp+4]
mov byte ptr [eax+ecx], 0 mov byte ptr [eax+ecx], 0
jmp [orgSscanf_LoadPath] jmp orgSscanf_LoadPath
} }
} }
} }
@ -1066,9 +1067,9 @@ namespace PickupEffectsFixes
{ {
_asm _asm
{ {
mov byte ptr [esp+184h-170h], 0 mov byte ptr [esp+0x184-0x170], 0
mov dword ptr [esp+184h-174h], 37 mov dword ptr [esp+0x184-0x174], 37
retn ret
} }
} }
@ -1078,7 +1079,7 @@ namespace PickupEffectsFixes
{ {
cmp ecx, 294 // minigun2 cmp ecx, 294 // minigun2
jnz NotMinigun2 jnz NotMinigun2
mov byte ptr [esp+184h-170h], 0 mov byte ptr [esp+0x184-0x170], 0
xor eax, eax xor eax, eax
jmp Return jmp Return
@ -1087,7 +1088,7 @@ namespace PickupEffectsFixes
Return: Return:
mov ebx, ecx mov ebx, ecx
retn ret
} }
} }
} }
@ -1109,21 +1110,21 @@ namespace IsPlayerTargettingCharFix
{ {
test bl, bl test bl, bl
jnz ReturnToUpdateCompareFlag jnz ReturnToUpdateCompareFlag
mov eax, [bUseMouse3rdPerson] mov eax, bUseMouse3rdPerson
cmp byte ptr [eax], 0 cmp byte ptr [eax], 0
jne CmpAndReturn jne CmpAndReturn
mov ecx, [TheCamera] mov ecx, TheCamera
call [Using1stPersonWeaponMode] call Using1stPersonWeaponMode
test al, al test al, al
jz ReturnToUpdateCompareFlag jz ReturnToUpdateCompareFlag
CmpAndReturn: CmpAndReturn:
cmp byte ptr [esp+11Ch-10Ch], 0 cmp byte ptr [esp+0x11C-0x10C], 0
retn ret
ReturnToUpdateCompareFlag: ReturnToUpdateCompareFlag:
xor al, al xor al, al
retn ret
} }
} }
} }
@ -1214,8 +1215,8 @@ namespace SelectableBackfaceCulling
{ {
push ebx push ebx
mov ebx, ecx mov ebx, ecx
cmp dword ptr [ebx+4Ch], 0 cmp dword ptr [ebx+0x4C], 0
jmp [EntityRender_Prologue_JumpBack] jmp EntityRender_Prologue_JumpBack
} }
} }
@ -1390,7 +1391,7 @@ namespace TommyFistShakeWithWeapons
return !bWeaponAllowsFistShake; return !bWeaponAllowsFistShake;
} }
static __declspec(naked) void CheckWeaponGroupHook() __declspec(naked) static void CheckWeaponGroupHook()
{ {
_asm _asm
{ {
@ -1398,7 +1399,7 @@ namespace TommyFistShakeWithWeapons
call WeaponProhibitsFistShake call WeaponProhibitsFistShake
add esp, 4 add esp, 4
test al, al test al, al
retn ret
} }
} }