Skip to content

Commit 030aa54

Browse files
committed
stuff
1 parent 47835af commit 030aa54

5 files changed

Lines changed: 81 additions & 22 deletions

File tree

.github/workflows/create_release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: create-release
1+
name: Create Release
22

33
on:
44
workflow_dispatch:

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Metal Gear Solid Master Collection Fix
22
[![Patreon-Button](https://github.com/Lyall/FISTFix/assets/695941/19c468ac-52af-4790-b4eb-5187c06af949)](https://www.patreon.com/Wintermance) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/W7W01UAI9)<br />
3-
[![Github All Releases](https://img.shields.io/github/downloads/Lyall/MGSHDFix/total.svg)](https://github.com/Lyall/MGSHDFix/releases)<br />
3+
4+
[![Releases](https://img.shields.io/github/v/release/Lyall/MGSHDFix)](https://github.com/Lyall/MGSHDFix/releases) [![Downloads](https://img.shields.io/github/downloads/Lyall/MGSHDFix/total)](https://github.com/Lyall/MGSHDFix/releases) ![Commits](https://img.shields.io/github/commit-activity/t/Lyall/MGSHDFix) ![License](https://img.shields.io/github/license/Lyall/MGSHDFix)
5+
46

57
[MG1 / MG2 Nexus Page](https://www.nexusmods.com/metalgearandmetalgear2mc/mods/9) | [MGS2 Nexus Page](https://www.nexusmods.com/metalgearsolid2mc/mods/49) | [MGS3 Nexus Page](https://www.nexusmods.com/metalgearsolid3mc/mods/139) | **GitHub Repo (You're already here!)**<br />
68

@@ -34,7 +36,7 @@ This is a fix that adds custom resolutions, ultrawide support and much more to t
3436

3537
## Installation
3638
- Grab the latest release of MGSHDFix from [here.](https://github.com/Lyall/MGSHDFix/releases)
37-
- Extract the contents of the release zip in to the the game folder.<br />(e.g. "**steamapps\common\MGS2**" or "**steamapps\common\MGS3**" for Steam).
39+
- Extract the contents of the release zip into the game folder.<br />(e.g. "**steamapps\common\MGS2**" or "**steamapps\common\MGS3**" for Steam).
3840

3941
### Steam Deck/Linux Additional Instructions
4042
🚩**You do not need to do this if you are using Windows!**
@@ -71,6 +73,15 @@ This list will contain bugs which may or may not be fixed.
7173
![vlcsnap-2025-04-30-01h48m54s182](https://github.com/user-attachments/assets/725a0b36-1862-4e91-b524-82aff39616ef)
7274
| Metal Gear Solid 3 |
7375

76+
## Building
77+
```bash
78+
git clone --recursive https://github.com/Lyall/MGSHDFix.git
79+
cd MGSHDFix
80+
```
81+
82+
### Windows
83+
Open MGSFPSUnlock.sln in Visual Studio (2022) and build.
84+
7485
## Credits
7586
[@Lyall](https://codeberg.org/Lyall) for their amazing work making widescreen fix mods, and most importantly, the original creation of this mod!<br />
7687
[@ShizCalev/Afevis](https://github.com/shizcalev) for long-term maintenance and contributing fixes.<br />

src/fixes/effect_speeds.cpp

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ int64_t __fastcall MGS2_solidusFireDashAct(int64_t work)
3939
g_EffectSpeedFix.solidusDashAct_NextUpdate = current_time;
4040
}
4141

42-
double duration = (PS2_IOP_CLOCKSPEED-1); // Slightly slower than PS2_IOP_CLOCKSPEED to account for particle related performance slowdown on PS2 hardware had during closeup shots.
43-
// !!!!! PCSX2 doesn't properly emulate the PS2's slowdown during these scenes either, so do any comparisons against real PS2 hardware if you change this value. !!!!!
44-
if (strcmp(g_GameVars.GetCurrentStage(), "d045p01") != 0)
42+
constexpr double duration = (PS2_IOP_CLOCKSPEED - 1);
43+
/*if (strcmp(g_GameVars.GetCurrentStage(), "d045p01") != 0) //P045_01P01 enter the Harrier 1 polygon demo 1 (MC) - Connecting bridge between Shells 1 and 2
4544
{
46-
duration = 30.0;
47-
}
45+
duration -= 1; // Slightly slower than PS2_IOP_CLOCKSPEED to account for particle related performance slowdown on PS2 hardware had during closeup shots.
46+
}*/
4847
g_EffectSpeedFix.solidusDashAct_NextUpdate += std::chrono::microseconds(static_cast<int64_t>(std::chrono::microseconds::period::den / duration));
4948
return solidusFireDashAct_hook.fastcall<int64_t>(work);
5049
}
@@ -81,6 +80,9 @@ int64_t __fastcall MGS2_splashPartsSlow(DWORD* a1, __int16* a2, float duration)
8180
}
8281
*/
8382
#endif
83+
safetyhook::MidHook debrisVelocityHook;
84+
85+
float g_VelocityScale = (1.0f * FRAME_IOP_DIVIDER);
8486

8587
void EffectSpeedFix::Initialize() const
8688
{
@@ -189,7 +191,9 @@ void EffectSpeedFix::Initialize() const
189191
flyingSmokeSlow_MidHook = safetyhook::create_mid(MGS2_flyingSmokeSlowScanResult,
190192
[](SafetyHookContext& ctx)
191193
{
192-
ctx.r8 = (unsigned int)(ctx.r8 * g_GameVars.ActorWaitMultiplier() * (g_GameVars.InCutscene() ? 2 : 1)); // double the duration in cutscenes
194+
//spdlog::info("flying_smoke_slow before {}", reghelpers::Getr8d(ctx));
195+
reghelpers::Setr8d(ctx, static_cast<unsigned int>((g_GameVars.ActorWaitMultiplier() * (g_GameVars.InCutscene() ? 2.0 : 1.0)) * reghelpers::Getr8d(ctx)));
196+
spdlog::info("flying_smoke_slow after {}", reghelpers::Getr8d(ctx));
193197
});
194198
LOG_HOOK(flyingSmokeSlow_MidHook, "MGS 2: Effect Speed Fix: effect3\\flying_smoke_slow.c", NULL, NULL)
195199
}
@@ -199,6 +203,48 @@ void EffectSpeedFix::Initialize() const
199203
spdlog::info("MGS 2: Effect Speed Fix: Outdated version of MGSFPSUnlock detected, Large explosion & Solidus's Firedash fixes are disabled.");
200204
return;
201205
}
206+
207+
if (uint8_t* MGS2_DEMO_CreateDebrisTex_SetupResult = Memory::PatternScan(baseModule,"F3 0F 58 43 ?? 48 83 C6","MGS2_DEMO_CreateDebrisTex_Setup velocity",nullptr,nullptr))
208+
{
209+
debrisVelocityHook = safetyhook::create_mid(MGS2_DEMO_CreateDebrisTex_SetupResult,
210+
[](SafetyHookContext& ctx)
211+
{
212+
if (strcmp(g_GameVars.GetCurrentStage(), "d12t3") == 0) // T12a1D The Seizure of Metal gear Demo (liquid ocelot first encounter)
213+
{
214+
switch (g_EffectSpeedFix.iDebrisIteration) //28 total, last 3 are at the end.
215+
{
216+
case 1:
217+
case 2:
218+
case 3:
219+
ctx.xmm0.f32[0] /= 4.0f;
220+
break;
221+
case 15:
222+
case 16:
223+
case 17:
224+
case 18:
225+
case 26:
226+
case 27:
227+
case 28:
228+
ctx.xmm0.f32[0] /= 2.0f;
229+
break;
230+
default:
231+
break;
232+
}
233+
234+
}
235+
else if (strcmp(g_GameVars.GetCurrentStage(), "d012p01") == 0) // P012_01_P01 Fortune encounter 1 polygon demo 1 (BC connecting bridge - Fortune vs Seals encounter)
236+
{
237+
ctx.xmm0.f32[0] /= 4.0f;
238+
}
239+
else
240+
{
241+
ctx.xmm0.f32[0] /= 2.0f;
242+
}
243+
}
244+
);
245+
LOG_HOOK(debrisVelocityHook, "MGS 2: Effect Speed Fix: demo\\debris_tex.c\\CreateDebrisTexture velocity", NULL, NULL);
246+
}
247+
202248

203249
if (uint8_t* MGS2_createDebrisTexOffset = Memory::PatternScan(baseModule, "45 89 46 ?? E8", "MGS 2: Effect Speed Fix : demo\\debris_tex.c\\CreateDebrisTexture()", NULL, NULL))
204250
{
@@ -207,10 +253,9 @@ void EffectSpeedFix::Initialize() const
207253
[](SafetyHookContext& ctx)
208254
{
209255
g_EffectSpeedFix.iDebrisIteration++;
210-
g_EffectSpeedFix.iExplosionDuration = 150; //default to double
211-
// Adjust duration based on cutscene
212-
213-
if (strcmp(g_GameVars.GetCurrentStage(), "d12t3") == 0) // T12a1D The Seizure of Metal gear Demo (liquid ocelot first encounter)
256+
g_EffectSpeedFix.iExplosionDuration = 75.0 * FRAME_IOP_MULTIPLIER; //default to double
257+
258+
/*if (strcmp(g_GameVars.GetCurrentStage(), "d12t3") == 0) // T12a1D The Seizure of Metal gear Demo (liquid ocelot first encounter)
214259
{
215260
switch (g_EffectSpeedFix.iDebrisIteration) //28 total, last 3 are at the end.
216261
{
@@ -236,7 +281,7 @@ void EffectSpeedFix::Initialize() const
236281
}
237282
238283
}
239-
else if (strcmp(g_GameVars.GetCurrentStage(), "d012p01") == 0)
284+
else */if (strcmp(g_GameVars.GetCurrentStage(), "d012p01") == 0)
240285
{
241286
// P012_01_P01 Fortune encounter 1 polygon demo 1 (BC connecting bridge - Fortune vs Seals encounter)
242287
g_EffectSpeedFix.iExplosionDuration *= (int)FRAME_IOP_MULTIPLIER * 10;
@@ -258,11 +303,12 @@ void EffectSpeedFix::Initialize() const
258303
solidusFireDashAct_hook = safetyhook::create_inline(reinterpret_cast<void*>(MGS2_solidusFireDashActScanResult), reinterpret_cast<void*>(MGS2_solidusFireDashAct));
259304
LOG_HOOK(solidusFireDashAct_hook, "MGS 2: Effect Speed Fix: effect\\solidas_dash_fire.c", NULL, NULL)
260305
}
261-
306+
262307
}
263308

264309
void EffectSpeedFix::Reset()
265310
{
311+
spdlog::info("MGS 2: Effect Speed Fix: Resetting effect speed fix variables. Level: {}", g_GameVars.GetCurrentStage());
266312
iDebrisIteration = 0;
267313
}
268314

src/resources/RegStateHelpers.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ inline uint8_t Get##reg##l(const safetyhook::Context& regs) { return regs.reg &
126126

127127
// R8 - R15 low 8 bits
128128
#define DEFINE_R8_15_8BIT_HELPERS(num) \
129-
inline void SetR##num##b(safetyhook::Context& regs, uint8_t val) { regs.r##num = (regs.r##num & ~0xFFULL) | val; } \
130-
inline uint8_t GetR##num##b(const safetyhook::Context& regs) { return regs.r##num & 0xFF; }
129+
inline void Setr##num##b(safetyhook::Context& regs, uint8_t val) { regs.r##num = (regs.r##num & ~0xFFULL) | val; } \
130+
inline uint8_t Getr##num##b(const safetyhook::Context& regs) { return regs.r##num & 0xFF; }
131131

132132
DEFINE_R8_15_8BIT_HELPERS(8)
133133
DEFINE_R8_15_8BIT_HELPERS(9)

src/resources/helper.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ namespace Util
264264
{
265265
std::array<std::string, 4> paths = { "", "plugins", "scripts", "update" };
266266
std::filesystem::path foundPath;
267+
bool bFoundOnce = false;
267268
for (const auto& path : paths)
268269
{
269270
auto filePath = sExePath / path / (fileName + ".asi");
@@ -279,18 +280,18 @@ namespace Util
279280
ss >> std::get_time(&checkDate, "%Y-%m-%d");
280281
if (ss.fail() || std::mktime(&fileCreationTime) >= std::mktime(&checkDate))
281282
{
282-
continue; // Skip this file if it doesn't meet the creation date requirement
283+
continue;
283284
}
284285
}
285-
if (!foundPath.empty()) // multiple versions found
286+
if (bFoundOnce)
286287
{
287288
AllocConsole();
288289
FILE* dummy;
289290
freopen_s(&dummy, "CONOUT$", "w", stdout);
290291
std::string errorMessage = "DUPLICATE FILE ERROR: Duplicate " + fileName + ".asi installations found! Please make sure to delete any old versions!\n";
291-
errorMessage.append("DUPLICATE FILE ERROR - Installation 1: ").append((sExePath / foundPath / (fileName + ".asi\n")).string());
292-
errorMessage.append("DUPLICATE FILE ERROR - Installation 2: ").append((sExePath / path / (fileName + ".asi\n")).string());
293-
std::cout << errorMessage;
292+
errorMessage.append("DUPLICATE FILE ERROR - Installation 1: ").append((sExePath / foundPath / (fileName + ".asi")).string().append("\n"));
293+
errorMessage.append("DUPLICATE FILE ERROR - Installation 2: ").append(filePath.string());
294+
std::cout << errorMessage << std::endl;
294295
spdlog::error("{}", errorMessage);
295296
FreeLibraryAndExitThread(baseModule, 1);
296297
}
@@ -303,6 +304,7 @@ namespace Util
303304
{
304305
return TRUE;
305306
}
307+
bFoundOnce = true;
306308
}
307309
}
308310
return FALSE;

0 commit comments

Comments
 (0)