Skip to content

Commit 74cd1c8

Browse files
committed
CrescentSuzukiRacing & TheSting!:
- Fixed minor things
1 parent dce7ec4 commit 74cd1c8

2 files changed

Lines changed: 30 additions & 36 deletions

File tree

source/fixes/CrescentSuzukiRacingWidescreenFix/dllmain.cpp

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,18 @@ enum class Game
6262
Unknown
6363
};
6464

65-
enum ResolutionInstructionsIndex
65+
enum ResolutionInstructionsIndices
6666
{
67-
Resolution1Scan,
68-
Resolution2Scan,
69-
Resolution3Scan,
70-
Resolution4Scan
67+
Res1,
68+
Res2,
69+
Res3,
70+
Res4
7171
};
7272

73-
enum CameraFOVInstructionsIndex
73+
enum CameraFOVInstructionsIndices
7474
{
75-
CameraFOV1Scan,
76-
CameraFOV2Scan
75+
FOV1,
76+
FOV2
7777
};
7878

7979
struct GameInfo
@@ -207,7 +207,6 @@ static SafetyHookMid ResolutionWidthInstruction1Hook{};
207207
static SafetyHookMid ResolutionHeightInstruction1Hook{};
208208
static SafetyHookMid ResolutionWidthInstruction2Hook{};
209209
static SafetyHookMid ResolutionHeightInstruction2Hook{};
210-
static SafetyHookMid AspectRatioInstructionHook{};
211210
static SafetyHookMid CameraFOVInstruction1Hook{};
212211

213212
void WidescreenFix()
@@ -221,60 +220,55 @@ void WidescreenFix()
221220
std::vector<std::uint8_t*> ResolutionInstructionsScansResult = Memory::PatternScan(exeModule, "A3 ?? ?? ?? ?? A1 ?? ?? ?? ?? 57", "A3 ?? ?? ?? ?? 7D ?? D8 05 ?? ?? ?? ?? 85 C0", "8B 86 ?? ?? ?? ?? 85 C0 A3", "C7 05 ?? ?? ?? ?? ?? ?? ?? ?? EB ?? 68 ?? ?? ?? ?? 56 E8 ?? ?? ?? ?? 83 C4 ?? 85 C0 75 ?? C7 05 ?? ?? ?? ?? ?? ?? ?? ?? EB ?? 68 ?? ?? ?? ?? 56 E8 ?? ?? ?? ?? 83 C4 ?? 85 C0 75 ?? C7 05 ?? ?? ?? ?? ?? ?? ?? ?? EB ?? 68 ?? ?? ?? ?? 56 E8 ?? ?? ?? ?? 83 C4 ?? 85 C0 75 ?? C7 05 ?? ?? ?? ?? ?? ?? ?? ?? EB");
222221
if (Memory::AreAllSignaturesValid(ResolutionInstructionsScansResult) == true)
223222
{
224-
spdlog::info("Resolution Width Instruction 1 Scan: Address is {:s}+{:x}", sExeName.c_str(), ResolutionInstructionsScansResult[Resolution1Scan] - (std::uint8_t*)exeModule);
223+
spdlog::info("Resolution Width Instruction 1 Scan: Address is {:s}+{:x}", sExeName.c_str(), ResolutionInstructionsScansResult[Res1] - (std::uint8_t*)exeModule);
225224

226-
spdlog::info("Resolution Height Instruction 1 Scan: Address is {:s}+{:x}", sExeName.c_str(), ResolutionInstructionsScansResult[Resolution2Scan] - (std::uint8_t*)exeModule);
225+
spdlog::info("Resolution Height Instruction 1 Scan: Address is {:s}+{:x}", sExeName.c_str(), ResolutionInstructionsScansResult[Res2] - (std::uint8_t*)exeModule);
227226

228-
spdlog::info("Resolution Instructions 2 Scan: Address is {:s}+{:x}", sExeName.c_str(), ResolutionInstructionsScansResult[Resolution3Scan] - (std::uint8_t*)exeModule);
227+
spdlog::info("Resolution Instructions 2 Scan: Address is {:s}+{:x}", sExeName.c_str(), ResolutionInstructionsScansResult[Res3] - (std::uint8_t*)exeModule);
229228

230-
spdlog::info("Resolution Instructions 3 Scan: Address is {:s}+{:x}", sExeName.c_str(), ResolutionInstructionsScansResult[Resolution4Scan] - (std::uint8_t*)exeModule);
229+
spdlog::info("Resolution Instructions 3 Scan: Address is {:s}+{:x}", sExeName.c_str(), ResolutionInstructionsScansResult[Res4] - (std::uint8_t*)exeModule);
231230

232-
ResolutionWidthInstruction1Hook = safetyhook::create_mid(ResolutionInstructionsScansResult[Resolution1Scan], [](SafetyHookContext& ctx)
231+
ResolutionWidthInstruction1Hook = safetyhook::create_mid(ResolutionInstructionsScansResult[Res1], [](SafetyHookContext& ctx)
233232
{
234233
ctx.eax = std::bit_cast<uintptr_t>(iCurrentResX);
235234
});
236235

237-
ResolutionHeightInstruction1Hook = safetyhook::create_mid(ResolutionInstructionsScansResult[Resolution2Scan], [](SafetyHookContext& ctx)
236+
ResolutionHeightInstruction1Hook = safetyhook::create_mid(ResolutionInstructionsScansResult[Res2], [](SafetyHookContext& ctx)
238237
{
239238
ctx.eax = std::bit_cast<uintptr_t>(iCurrentResY);
240239
});
241240

242-
Memory::WriteNOPs(ResolutionInstructionsScansResult[Resolution3Scan], 6);
241+
Memory::WriteNOPs(ResolutionInstructionsScansResult[Res3], 6);
243242

244-
ResolutionWidthInstruction2Hook = safetyhook::create_mid(ResolutionInstructionsScansResult[Resolution3Scan], [](SafetyHookContext& ctx)
243+
ResolutionWidthInstruction2Hook = safetyhook::create_mid(ResolutionInstructionsScansResult[Res3], [](SafetyHookContext& ctx)
245244
{
246245
ctx.eax = std::bit_cast<uintptr_t>(iCurrentResX);
247246
});
248247

249-
Memory::WriteNOPs(ResolutionInstructionsScansResult[Resolution3Scan] + 13, 6);
248+
Memory::WriteNOPs(ResolutionInstructionsScansResult[Res3] + 13, 6);
250249

251-
ResolutionHeightInstruction2Hook = safetyhook::create_mid(ResolutionInstructionsScansResult[Resolution3Scan] + 13, [](SafetyHookContext& ctx)
250+
ResolutionHeightInstruction2Hook = safetyhook::create_mid(ResolutionInstructionsScansResult[Res3] + 13, [](SafetyHookContext& ctx)
252251
{
253252
ctx.ecx = std::bit_cast<uintptr_t>(iCurrentResY);
254253
});
255254

256-
Memory::Write(ResolutionInstructionsScansResult[Resolution4Scan] + 6, iCurrentResX);
255+
Memory::Write(ResolutionInstructionsScansResult[Res4] + 6, iCurrentResX);
257256

258-
Memory::Write(ResolutionInstructionsScansResult[Resolution4Scan] + 36, iCurrentResX);
257+
Memory::Write(ResolutionInstructionsScansResult[Res4] + 36, iCurrentResX);
259258

260-
Memory::Write(ResolutionInstructionsScansResult[Resolution4Scan] + 66, iCurrentResX);
259+
Memory::Write(ResolutionInstructionsScansResult[Res4] + 66, iCurrentResX);
261260

262-
Memory::Write(ResolutionInstructionsScansResult[Resolution4Scan] + 96, iCurrentResX);
261+
Memory::Write(ResolutionInstructionsScansResult[Res4] + 96, iCurrentResX);
263262

264-
Memory::Write(ResolutionInstructionsScansResult[Resolution4Scan] + 126, iCurrentResX);
263+
Memory::Write(ResolutionInstructionsScansResult[Res4] + 126, iCurrentResX);
265264
}
266265

267266
std::uint8_t* AspectRatioInstructionScanResult = Memory::PatternScan(exeModule, "D9 05 ?? ?? ?? ?? D8 C9 89 51");
268267
if (AspectRatioInstructionScanResult)
269268
{
270269
spdlog::info("Aspect Ratio Instruction: Address is {:s}+{:x}", sExeName.c_str(), AspectRatioInstructionScanResult - (std::uint8_t*)exeModule);
271270

272-
Memory::WriteNOPs(AspectRatioInstructionScanResult, 6);
273-
274-
AspectRatioInstructionHook = safetyhook::create_mid(AspectRatioInstructionScanResult, [](SafetyHookContext& ctx)
275-
{
276-
FPU::FLD(fNewAspectRatio);
277-
});
271+
Memory::Write(AspectRatioInstructionScanResult + 2, &fNewAspectRatio);
278272
}
279273
else
280274
{
@@ -285,13 +279,13 @@ void WidescreenFix()
285279
std::vector<std::uint8_t*> CameraFOVInstructionsScansResult = Memory::PatternScan(exeModule, "8B 56 ?? 50 68 ?? ?? ?? ?? 51 8B 0E 52 E8 ?? ?? ?? ?? D9 46 ?? D8 0D ?? ?? ?? ?? D9 F2 DD D8 DD 05 ?? ?? ?? ?? D9 F2 DD D8 D9 C9 D9 C9 DE F9 D8 15 ?? ?? ?? ?? DF E0 F6 C4 ?? 7A ?? D8 0D ?? ?? ?? ?? D9 05 ?? ?? ?? ?? D8 25 ?? ?? ?? ?? DE C1 8B 06 D9 98 ?? ?? ?? ?? 8B 0E E8 ?? ?? ?? ?? 8B 36 56 B9 ?? ?? ?? ?? E8 ?? ?? ?? ?? 89 35 ?? ?? ?? ?? 5E C2 ?? ?? CC", "C7 43 ?? ?? ?? ?? ?? 89 43");
286280
if (Memory::AreAllSignaturesValid(CameraFOVInstructionsScansResult) == true)
287281
{
288-
spdlog::info("Camera FOV Instruction 1: Address is {:s}+{:x}", sExeName.c_str(), CameraFOVInstructionsScansResult[CameraFOV1Scan] - (std::uint8_t*)exeModule);
282+
spdlog::info("Camera FOV Instruction 1: Address is {:s}+{:x}", sExeName.c_str(), CameraFOVInstructionsScansResult[FOV1] - (std::uint8_t*)exeModule);
289283

290-
spdlog::info("Camera FOV Instruction 2: Address is {:s}+{:x}", sExeName.c_str(), CameraFOVInstructionsScansResult[CameraFOV2Scan] - (std::uint8_t*)exeModule);
284+
spdlog::info("Camera FOV Instruction 2: Address is {:s}+{:x}", sExeName.c_str(), CameraFOVInstructionsScansResult[FOV2] - (std::uint8_t*)exeModule);
291285

292-
Memory::WriteNOPs(CameraFOVInstructionsScansResult[CameraFOV1Scan], 3); // NOP out the original instruction
286+
Memory::WriteNOPs(CameraFOVInstructionsScansResult[FOV1], 3); // NOP out the original instruction
293287

294-
CameraFOVInstruction1Hook = safetyhook::create_mid(CameraFOVInstructionsScansResult[CameraFOV1Scan], [](SafetyHookContext& ctx)
288+
CameraFOVInstruction1Hook = safetyhook::create_mid(CameraFOVInstructionsScansResult[FOV1], [](SafetyHookContext& ctx)
295289
{
296290
float& fCurrentCameraFOV = Memory::ReadMem(ctx.esi + 0x1C);
297291

@@ -302,7 +296,7 @@ void WidescreenFix()
302296

303297
fNewCameraFOV2 = 1.04719758033752f / fFOVFactor;
304298

305-
Memory::Write(CameraFOVInstructionsScansResult[CameraFOV2Scan] + 3, fNewCameraFOV2);
299+
Memory::Write(CameraFOVInstructionsScansResult[FOV2] + 3, fNewCameraFOV2);
306300
}
307301
}
308302
}

source/fixes/TheSting!FOVFix/dllmain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct GameInfo
7070
};
7171

7272
const std::map<Game, GameInfo> kGames = {
73-
{Game::TS_ENG, {"The Sting! (English & Polish)", "Sting.exe"}},
73+
{Game::TS_ENG, {"The Sting! (English/Polish/Spanish)", "Sting.exe"}},
7474
{Game::TS_RU, {"The Sting! / Va-Bank! (Russian)", "VaBank.exe"}},
7575
{Game::TS_GER, {"The Sting! / Der Clou! 2 (German)", "Clou2.exe"}},
7676
};

0 commit comments

Comments
 (0)