Compare commits

..

10 commits

Author SHA1 Message Date
Echo J
8871042371 SilentPatchVC: Add GCC-style inline assembly statements
This also includes a small wrapper to call a C++ function from GCC-style inline ASM

These statements almost work on llvm-mingw too (but there's some stubborn call instructions)
2024-11-15 01:43:43 +02:00
Echo J
af090bc76a SilentPatchIII: Add GCC-style inline assembly statements
These almost work on llvm-mingw too (but there's some stubborn call instructions)
2024-11-15 01:38:59 +02:00
Echo J
723765e441 SilentPatchIII: Add a missing functional header include
MinGW GCC doesn't implicitly include it either
2024-11-15 00:22:53 +02:00
Echo J
84ba52d98d SilentPatch: Add missing cmath header include
It's required for the modf() function (and it isn't implicitly
included on MinGW GCC)
2024-11-15 00:22:53 +02:00
Echo J
500718176c SilentPatch: Move a header include in SVF
This makes sure the fixed-width integer types are included in SVF.h
2024-11-15 00:22:53 +02:00
Echo J
ae7973f068 SilentPatch: Define a replacement for _stricmp() on non-MSVC
MinGW GCC doesn't have this MSVC-specific function
2024-11-15 00:22:53 +02:00
Echo J
60977fd74d SilentPatch: Move RwEngineInstance definition to headers
MinGW GCC can't locate it in some files otherwise
2024-11-15 00:22:53 +02:00
Echo J
135d1b322e SilentPatch: Simplify RwIm2DRenderLine function pointer declaration
MinGW GCC doesn't seem to unwind the layers of the macro define
properly (which causes it to not find the declaration type)
2024-11-15 00:22:53 +02:00
Echo J
a696e2c389 SilentPatch: Don't define certain Rw* functions if not needed
Redefining them can cause strange compile errors with MinGW GCC
2024-11-15 00:22:53 +02:00
Echo J
9dbda6951b DDraw: Cast the memcpy() source argument
This works around the MinGW GCC type strictness
2024-11-15 00:22:53 +02:00
2 changed files with 100 additions and 101 deletions

View file

@ -199,13 +199,13 @@ void __declspec(naked) M16StatsFix()
#ifdef _MSC_VER #ifdef _MSC_VER
_asm _asm
{ {
add eax, 0x34 add eax, 34h
add ebx, 0x34 add ebx, 34h
mov ecx, InstantHitsFiredByPlayer mov ecx, [InstantHitsFiredByPlayer]
inc dword ptr [ecx] inc [ecx]
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"add eax, 0x34\n" "add eax, 0x34\n"
@ -224,22 +224,22 @@ void __declspec(naked) HeadlightsFix()
#ifdef _MSC_VER #ifdef _MSC_VER
_asm _asm
{ {
fld dword ptr [esp+0x708-0x690] fld [esp+708h-690h]
fcomp fMinusOne fcomp fMinusOne
fnstsw ax fnstsw ax
and ah, 5 and ah, 5
cmp ah, 1 cmp ah, 1
jnz HeadlightsFix_DontLimit jnz HeadlightsFix_DontLimit
fld fMinusOne fld fMinusOne
fstp dword ptr [esp+0x708-0x690] fstp [esp+708h-690h]
HeadlightsFix_DontLimit: HeadlightsFix_DontLimit:
fld dword ptr [esp+0x708-0x690] fld [esp+708h-690h]
fabs fabs
fld st fld st
jmp HeadlightsFix_JumpBack jmp [HeadlightsFix_JumpBack]
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"fld dword ptr [esp+0x708-0x690]\n" "fld dword ptr [esp+0x708-0x690]\n"
@ -353,11 +353,11 @@ void __declspec(naked) SubtitlesShadowFix()
{ {
push eax push eax
call Recalculate call Recalculate
fadd dword ptr [esp+0x50+8] fadd [esp+50h+8]
fadd fShadowYSize fadd [fShadowYSize]
jmp SubtitlesShadowFix_JumpBack jmp SubtitlesShadowFix_JumpBack
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"push eax\n" "push eax\n"
@ -377,16 +377,16 @@ void __declspec(naked) III_SensResetFix()
#ifdef _MSC_VER #ifdef _MSC_VER
_asm _asm
{ {
mov ecx, 0x3A76 mov ecx, 3A76h
mov edi, ebp mov edi, ebp
fld dword ptr [ebp+0x194] fld dword ptr [ebp+194h]
fld dword ptr [ebp+0x198] fld dword ptr [ebp+198h]
rep stosd rep stosd
fstp dword ptr [ebp+0x198] fstp dword ptr [ebp+198h]
fstp dword ptr [ebp+0x194] fstp dword ptr [ebp+194h]
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"mov ecx, 0x3A76\n" "mov ecx, 0x3A76\n"
@ -408,7 +408,7 @@ void __declspec(naked) RadarBoundsCheckCoordBlip()
#ifdef _MSC_VER #ifdef _MSC_VER
_asm _asm
{ {
mov edx, RadarBoundsCheckCoordBlip_Count mov edx, dword ptr [RadarBoundsCheckCoordBlip_Count]
cmp cl, byte ptr [edx] cmp cl, byte ptr [edx]
jnb OutOfBounds jnb OutOfBounds
mov edx, ecx mov edx, ecx
@ -418,9 +418,9 @@ void __declspec(naked) RadarBoundsCheckCoordBlip()
OutOfBounds: OutOfBounds:
or eax, -1 or eax, -1
fcompp fcompp
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"mov edx, %[RadarBoundsCheckCoordBlip_Count]\n" "mov edx, %[RadarBoundsCheckCoordBlip_Count]\n"
@ -446,7 +446,7 @@ void __declspec(naked) RadarBoundsCheckEntityBlip()
#ifdef _MSC_VER #ifdef _MSC_VER
_asm _asm
{ {
mov edx, RadarBoundsCheckCoordBlip_Count mov edx, dword ptr [RadarBoundsCheckCoordBlip_Count]
cmp cl, byte ptr [edx] cmp cl, byte ptr [edx]
jnb OutOfBounds jnb OutOfBounds
mov edx, ecx mov edx, ecx
@ -455,9 +455,9 @@ void __declspec(naked) RadarBoundsCheckEntityBlip()
OutOfBounds: OutOfBounds:
or eax, -1 or eax, -1
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"mov edx, %[RadarBoundsCheckCoordBlip_Count]\n" "mov edx, %[RadarBoundsCheckCoordBlip_Count]\n"
@ -514,8 +514,8 @@ void __declspec(naked) AutoPilotTimerFix_III()
{ {
#ifdef _MSC_VER #ifdef _MSC_VER
_asm { _asm {
push dword ptr [esp + 0x4] push dword ptr[esp + 0x4]
push dword ptr [ebx + 0x10] push dword ptr[ebx + 0x10]
push eax push eax
call AutoPilotTimerCalculation_III call AutoPilotTimerCalculation_III
add esp, 0xC add esp, 0xC
@ -524,9 +524,9 @@ void __declspec(naked) AutoPilotTimerFix_III()
pop ebp pop ebp
pop esi pop esi
pop ebx pop ebx
ret 4 retn 4
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"push dword ptr [esp + 0x4]\n" "push dword ptr [esp + 0x4]\n"
@ -700,18 +700,18 @@ namespace RemoveDriverStatusFix
#ifdef _MSC_VER #ifdef _MSC_VER
_asm _asm
{ {
mov ah, [ecx+0x50] mov ah, [ecx+50h]
mov al, ah mov al, ah
and ah, 0xF8 and ah, 0F8h
cmp ah, 0x28 cmp ah, 28h
je DontSetStatus je DontSetStatus
and al, 7 and al, 7
or al, 0x20 or al, 20h
DontSetStatus: DontSetStatus:
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"mov ah, [ecx+0x50]\n" "mov ah, [ecx+0x50]\n"
@ -761,15 +761,15 @@ namespace EvasiveDiveFix
#ifdef _MSC_VER #ifdef _MSC_VER
_asm _asm
{ {
push dword ptr [esi+0x7C] push dword ptr [esi+7Ch]
push dword ptr [esi+0x78] push dword ptr [esi+78h]
call CalculateAngle call CalculateAngle
add esp, 8 add esp, 8
mov ecx, ebp mov ecx, ebp
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"push dword ptr [esi+0x7C]\n" "push dword ptr [esi+0x7C]\n"
@ -799,9 +799,9 @@ 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]
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"mov eax, [esp+4]\n" "mov eax, [esp+4]\n"
@ -820,9 +820,9 @@ namespace NullTerminatedLines
{ {
mov eax, [esp+4] mov eax, [esp+4]
mov byte ptr [eax+ecx], 0 mov byte ptr [eax+ecx], 0
jmp orgSscanf1 jmp [orgSscanf1]
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"mov eax, [esp+4]\n" "mov eax, [esp+4]\n"
@ -838,14 +838,14 @@ namespace NullTerminatedLines
#ifdef _MSC_VER #ifdef _MSC_VER
_asm _asm
{ {
mov ecx, gString mov ecx, [gString]
mov byte ptr [ecx+edx], 0 mov byte ptr [ecx+edx], 0
mov ecx, [esi] mov ecx, [esi]
inc ebp inc ebp
add ecx, [esp+0xAC-0x98] add ecx, [esp+0ACh-98h]
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"mov ecx, %[gString]\n" "mov ecx, %[gString]\n"
@ -886,16 +886,16 @@ namespace DodoKeyboardControls
#ifdef _MSC_VER #ifdef _MSC_VER
_asm _asm
{ {
call orgFindPlayerVehicle call [orgFindPlayerVehicle]
mov ecx, bAllDodosCheat mov ecx, [bAllDodosCheat]
cmp byte ptr [ecx], 0 cmp byte ptr [ecx], 0
je CheatDisabled je CheatDisabled
mov byte ptr [esp+0x1C-0x14], 1 mov byte ptr [esp+1Ch-14h], 1
CheatDisabled: CheatDisabled:
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"call %[orgFindPlayerVehicle]\n" "call %[orgFindPlayerVehicle]\n"
@ -969,7 +969,7 @@ namespace GenerateNewPickup_ReuseObjectFix
#ifdef _MSC_VER #ifdef _MSC_VER
_asm _asm
{ {
mov eax, pPickupObject mov eax, [pPickupObject]
add eax, ebp add eax, ebp
mov eax, [eax] mov eax, [eax]
test eax, eax test eax, eax
@ -978,7 +978,7 @@ namespace GenerateNewPickup_ReuseObjectFix
mov edi, eax mov edi, eax
push edi push edi
call WorldRemove call [WorldRemove]
add esp, 4 add esp, 4
// Call dtor // Call dtor
@ -990,9 +990,9 @@ namespace GenerateNewPickup_ReuseObjectFix
pop edi pop edi
NoPickup: NoPickup:
jmp orgGiveUsAPickUpObject jmp [orgGiveUsAPickUpObject]
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"mov eax, %[pPickupObject]\n" "mov eax, %[pPickupObject]\n"

View file

@ -675,7 +675,7 @@ void __declspec(naked) SubtitlesShadowFix()
_asm _asm
{ {
mov [esp], eax mov [esp], eax
fild dword ptr [esp] fild [esp]
push eax push eax
lea eax, [esp+20h-18h] lea eax, [esp+20h-18h]
push eax push eax
@ -684,7 +684,7 @@ void __declspec(naked) SubtitlesShadowFix()
call Recalculate call Recalculate
jmp SubtitlesShadowFix_JumpBack jmp SubtitlesShadowFix_JumpBack
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"mov [esp], eax\n" "mov [esp], eax\n"
@ -716,9 +716,9 @@ void __declspec(naked) CreateInstance_BikeFix()
push eax push eax
mov ecx, ebp mov ecx, ebp
call CVehicleModelInfo::GetExtrasFrame call CVehicleModelInfo::GetExtrasFrame
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"push eax\n" "push eax\n"
@ -768,10 +768,9 @@ unsigned int __cdecl AutoPilotTimerCalculation_VC(unsigned int nTimer, int nScal
void __declspec(naked) AutoPilotTimerFix_VC() void __declspec(naked) AutoPilotTimerFix_VC()
{ {
#ifdef MSC_VER #ifdef MSC_VER
_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
call AutoPilotTimerCalculation_VC call AutoPilotTimerCalculation_VC
add esp, 0xC add esp, 0xC
@ -779,9 +778,9 @@ void __declspec(naked) AutoPilotTimerFix_VC()
add esp, 0x30 add esp, 0x30
pop ebp pop ebp
pop ebx pop ebx
ret 4 retn 4
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"push dword ptr [esp + 0xC]\n" "push dword ptr [esp + 0xC]\n"
@ -920,21 +919,21 @@ namespace SirenSwitchingFix
#ifdef MSC_VER #ifdef MSC_VER
_asm _asm
{ {
mov dword ptr [esi+0x1C], 0x1C mov dword ptr [esi+1Ch], 1Ch
// al = 0 - high pitched siren // al = 0 - high pitched siren
// al = 1 - normal siren // al = 1 - normal siren
cmp dword ptr [ebp+0x14], 90 // fbiranch cmp dword ptr [ebp+14h], 90 // fbiranch
je IsFBIRanchOrFBICar_HighPitchSiren je IsFBIRanchOrFBICar_HighPitchSiren
cmp dword ptr [ebp+0x14], 17 // fbicar cmp dword ptr [ebp+14h], 17 // fbicar
setne al setne al
ret retn
IsFBIRanchOrFBICar_HighPitchSiren: IsFBIRanchOrFBICar_HighPitchSiren:
xor al, al xor al, al
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"mov dword ptr [esi+0x1C], 0x1C\n" "mov dword ptr [esi+0x1C], 0x1C\n"
@ -1023,18 +1022,18 @@ namespace RemoveDriverStatusFix
#ifdef MSC_VER #ifdef MSC_VER
_asm _asm
{ {
mov cl, [ebx+0x50] mov cl, [ebx+50h]
mov al, cl mov al, cl
and cl, 0xF8 and cl, 0F8h
cmp cl, 0x28 cmp cl, 28h
je DontSetStatus je DontSetStatus
and al, 7 and al, 7
or al, 0x20 or al, 20h
DontSetStatus: DontSetStatus:
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"mov cl, [ebx+0x50]\n" "mov cl, [ebx+0x50]\n"
@ -1126,9 +1125,9 @@ 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]
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"mov eax, [esp+4]\n" "mov eax, [esp+4]\n"
@ -1164,11 +1163,11 @@ namespace PickupEffectsFixes
#ifdef MSC_VER #ifdef MSC_VER
_asm _asm
{ {
mov byte ptr [esp+0x184-0x170], 0 mov byte ptr [esp+184h-170h], 0
mov dword ptr [esp+0x184-0x174], 37 mov dword ptr [esp+184h-174h], 37
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"mov byte ptr [esp+0x184-0x170], 0\n" "mov byte ptr [esp+0x184-0x170], 0\n"
@ -1185,7 +1184,7 @@ namespace PickupEffectsFixes
{ {
cmp ecx, 294 // minigun2 cmp ecx, 294 // minigun2
jnz NotMinigun2 jnz NotMinigun2
mov byte ptr [esp+0x184-0x170], 0 mov byte ptr [esp+184h-170h], 0
xor eax, eax xor eax, eax
jmp Return jmp Return
@ -1194,9 +1193,9 @@ namespace PickupEffectsFixes
Return: Return:
mov ebx, ecx mov ebx, ecx
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"cmp ecx, 294\n" // minigun2 "cmp ecx, 294\n" // minigun2
@ -1234,23 +1233,23 @@ 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+0x11C-0x10C], 0 cmp byte ptr [esp+11Ch-10Ch], 0
ret retn
ReturnToUpdateCompareFlag: ReturnToUpdateCompareFlag:
xor al, al xor al, al
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"test bl, bl\n" "test bl, bl\n"
@ -1365,10 +1364,10 @@ namespace SelectableBackfaceCulling
{ {
push ebx push ebx
mov ebx, ecx mov ebx, ecx
cmp dword ptr [ebx+0x4C], 0 cmp dword ptr [ebx+4Ch], 0
jmp EntityRender_Prologue_JumpBack jmp [EntityRender_Prologue_JumpBack]
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"push ebx\n" "push ebx\n"
@ -1560,9 +1559,9 @@ namespace TommyFistShakeWithWeapons
call WeaponProhibitsFistShake call WeaponProhibitsFistShake
add esp, 4 add esp, 4
test al, al test al, al
ret retn
} }
#elif defined(__GNUC__) || defined(__clang__) #else
__asm__ volatile __asm__ volatile
( (
"push dword ptr [eax]\n" "push dword ptr [eax]\n"