Skip to content

Commit 3247a97

Browse files
committed
disable near focus in d12t3 during angle 2
1 parent 548c959 commit 3247a97

4 files changed

Lines changed: 57 additions & 5 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ This is a fix that adds custom resolutions, ultrawide support and much more to t
5454
- Option to force Real Time Clock based hostage Easter Egg.
5555
- Option to restore grenade cooking (having detonation timer start while the grenade is still held.)
5656
- Option to swap X/O (OK / CANCEL inputs) in Menus.
57-
- Option to swap thermal goggle color palettes in realtime (Substance/vanilla, red hot / Sons of Liberty, Splinter Cell Blacklist, black hot, white hot.)
57+
- Option to swap thermal goggle color palettes in realtime (Substance/vanilla, red hot / Sons of Liberty, Splinter Cell Blacklist, black hot, white hot.) [Examples](https://imgur.com/a/ThRpIbj)
5858
- Option to enable cut Metal Gear 2: Solid Snake Colonel sprites during some late-game Codec calls. [PR #234](https://github.com/ShizCalev/MGSHDFix/pull/234)
59-
- Option to restore original 2001 Sons of Liberty radar rotation.
60-
59+
- Option to restore original 2001 Sons of Liberty radar rotation. [Example](https://imgur.com/a/QNDTgrO)
6160
- BP_Asset / Manifest file modloader support. [PR #251](https://github.com/ShizCalev/MGSHDFix/pull/251)
6261

6362

@@ -80,15 +79,16 @@ This is a fix that adds custom resolutions, ultrawide support and much more to t
8079

8180

8281
#### MGS2 Specific Bug Fixes:
83-
- Restores contrast / color filter post processing effects in numerous cutscenes, which have been broken/missing since the 2011 HD Collection.
82+
- Restores contrast / color filter post processing effects in numerous cutscenes, which have been broken/missing since the 2011 HD Collection. [Examples (SPOILER WARNING)](https://imgur.com/a/pJAc8H1)
8483
- Restore broken heat haze post processing effect on roof of Strut A.
8584
- Restore underwater UI swimming post processing effect. [PR #245](https://github.com/ShizCalev/MGSHDFix/pull/245)
8685
- Restores numerous particle and visual effects to proper PS2 timing, fixing effects that ran at double speed and ended too early in the HD Collection and Master Collection versions.
8786
- Restores dogtag viewer information.
8887
- Restores color swapping Red / Blue "2" on the title screen after game completions. (Requires MGS2 Community Bugfix Compilation)
88+
- Fixes in-game timer not pausing during loading times. (This was a HD Collection regression. IGT behavior now matches with Substance.)
8989
- Fixes Depth of Field / blur post processing effects not scaling with resolution. [PR #248](https://github.com/ShizCalev/MGSHDFix/pull/248)
9090
- Fixes shadow resolution not scaling with game resolution. (It was hard-coded to 256x256 / PS2 resolution.)
91-
- Fixes incorrectly positioning "Metal Gear Solid 2" title card during the start of Tanker when playing in Letterbox mode.
91+
- Fixes incorrectly positioning "Metal Gear Solid 2" title card during the start of Tanker when playing in Letterbox mode. [Example](https://imgur.com/a/bGkGwJ9)
9292
- Fixes crashes, audio desync, timer delays, and broken loading zones bugs caused by alt-tabbing the game. (For speedrunners who utilize this bug to skip forced codec calls, this bugfix can be forced off in the ini.)
9393
- Fixes the Steam Cloud related ["DAMAGED SAVE" / "CORRUPT SAVE"](https://www.pcgamingwiki.com/wiki/Metal_Gear_Solid_2:_Sons_of_Liberty_-_Master_Collection_Version#Save_File_Appears_as_DAMAGED_FILE) issue.
9494
- Fixes bug where your character would stop aiming their gun while holding L1 when you fully tilt your joystick.

src/fixes/depth_of_field.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33

44
#include "common.hpp"
55
#include "custom_resolution_and_borderless.hpp"
6+
#include "gamevars.hpp"
67
#include "helper.hpp"
8+
#ifndef RELEASE_BUILD
9+
#include "input_handler.hpp"
10+
#endif
711
#include "logging.hpp"
812

913
namespace
@@ -40,6 +44,11 @@ namespace
4044
using DmapackRenderCallbackFn = void(__fastcall*)(void*);
4145
using SetDepthFuncFn = void(__fastcall*)(void*, uint64_t);
4246

47+
bool bCutsceneNeedsSpecialHandling = false; //for per-cutscene effect skip handling.
48+
bool bIsD12T3 = false;
49+
int iNearEffectCount = 0;
50+
51+
4352
struct FocusSourcePacket
4453
{
4554
int maxPlane;
@@ -611,6 +620,18 @@ namespace
611620
{
612621
return false;
613622
}
623+
// if (bCutsceneNeedsSpecialHandling)
624+
{
625+
if (bIsD12T3)
626+
{
627+
iNearEffectCount++;
628+
if (iNearEffectCount >= 80 && iNearEffectCount < 440)
629+
{
630+
spdlog::info("MGS 2: Depth of Field: skipping near focus packet {:d} for cutscene special handling.", iNearEffectCount);
631+
return false;
632+
}
633+
}
634+
}
614635

615636
if (!PrepareFocusSource(source))
616637
{
@@ -956,6 +977,16 @@ namespace
956977
}
957978
}
958979

980+
void DepthOfFieldFixes::HandleLevelTransition()
981+
{
982+
if (!bEnabled)
983+
{
984+
return;
985+
}
986+
iNearEffectCount = 0;
987+
bIsD12T3 = g_GameVars.IsStage(MGS2Stages::D12T3);
988+
}
989+
959990
void DepthOfFieldFixes::Initialize()
960991
{
961992
if (!(eGameType & MGS2))
@@ -971,6 +1002,7 @@ void DepthOfFieldFixes::Initialize()
9711002

9721003
if (IsUltrawide())
9731004
{
1005+
bEnabled = false;
9741006
spdlog::info("MGS 2: Depth of Field: disabled for ultrawide aspect ratio.");
9751007
return;
9761008
}
@@ -991,4 +1023,20 @@ void DepthOfFieldFixes::Initialize()
9911023
spdlog::warn("MGS 2: Depth of Field: failed to resolve necessary functions for near focus fixes; near focus adjustments disabled.");
9921024
}
9931025
InstallBlurUvScaleHook();
1026+
1027+
#ifndef RELEASE_BUILD
1028+
g_InputHandler.RegisterHotkey(VK_ADD, "print", []
1029+
{
1030+
spdlog::info("iNearEffectCount = {}, bIsD12T3 = {}", iNearEffectCount, bIsD12T3);
1031+
});
1032+
1033+
/*
1034+
MAKE_HOOK_MID(baseModule, "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 48 89 7C 24 ?? 41 56 48 83 EC ?? 41 8B F9 41 8B F0 45 33 C9 8B EA 44 8B F1 BA ?? ?? ?? ?? 41 B8 ?? ?? ?? ?? 41 8D 49 ?? E8 A4 1C B2 FF", "NewNearFocusEffect -> Focal Points", {
1035+
spdlog::info("ctx.r8 = {}, ctx.r9 = {}", ctx.r8, ctx.r9);
1036+
ctx.r9 = 0;
1037+
ctx.r8 = 4000;
1038+
//r8 = var_near
1039+
//r9 = var_far
1040+
})*/
1041+
#endif
9941042
}

src/fixes/depth_of_field.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class DepthOfFieldFixes final
77
float fBlurUvMultiplier = 3.0f;
88

99
void Initialize();
10+
void HandleLevelTransition();
1011
};
1112

1213
inline DepthOfFieldFixes g_DepthOfFieldFixes;

src/resources/gamevars.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "stdafx.h"
22
#include "common.hpp"
33
#include "gamevars.hpp"
4+
5+
#include "depth_of_field.hpp"
46
#include "effect_speeds.hpp"
57
#include "game_funcs.hpp"
68
#include "keep_aiming_after_firing.hpp"
@@ -188,6 +190,7 @@ void GameVars::OnLevelTransition()
188190
MGS2_First_Person_View::HandleLevelTransition();
189191
MGS2_ThirdPersonFreecam::HandleLevelTransition();
190192
MGS2Sunglasses::CheckOnTransition();
193+
g_DepthOfFieldFixes.HandleLevelTransition();
191194
}
192195
}
193196

0 commit comments

Comments
 (0)