@@ -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
8587void 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
264309void 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
0 commit comments