Skip to content

Commit

Permalink
windowed compatibility fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Oct 27, 2024
1 parent b106931 commit 4cf3a06
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 25 deletions.
27 changes: 16 additions & 11 deletions source/GTA3.WidescreenFix/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,21 @@ void Fix2DSprites()
pRwRenderStateSet = (void*)injector::GetBranchDestination(pattern.get_first()).as_int(); //0x649BA0
}

CEXP void UpdateVars()
{
fCrosshairPosFactor = ((0.52999997f - 0.5f) / ((*CDraw::pfScreenAspectRatio) / (16.0f / 9.0f))) + 0.5f;
fCrosshairHeightScaleDown = fWideScreenWidthScaleDown * *CDraw::pfScreenAspectRatio;

fWideScreenHeightScaleDown = 1.0f / 480.0f;
fCustomWideScreenWidthScaleDown = fWideScreenWidthScaleDown * fHudWidthScale;
fCustomWideScreenHeightScaleDown = fWideScreenHeightScaleDown * fHudHeightScale;

fCustomRadarWidthScale = fWideScreenWidthScaleDown * fRadarWidthScale;
fPlayerMarkerPos = 94.0f * fRadarWidthScale;
if (bIVRadarScaling)
fPlayerMarkerPos = (94.0f - 5.5f) * fRadarWidthScale;
}

void Init()
{
//Immediate changes
Expand Down Expand Up @@ -735,17 +750,7 @@ void Init()
wcscpy(ptr, L"BORDERS");
}

fCrosshairPosFactor = ((0.52999997f - 0.5f) / ((*CDraw::pfScreenAspectRatio) / (16.0f / 9.0f))) + 0.5f;
fCrosshairHeightScaleDown = fWideScreenWidthScaleDown * *CDraw::pfScreenAspectRatio;

fWideScreenHeightScaleDown = 1.0f / 480.0f;
fCustomWideScreenWidthScaleDown = fWideScreenWidthScaleDown * fHudWidthScale;
fCustomWideScreenHeightScaleDown = fWideScreenHeightScaleDown * fHudHeightScale;

fCustomRadarWidthScale = fWideScreenWidthScaleDown * fRadarWidthScale;
fPlayerMarkerPos = 94.0f * fRadarWidthScale;
if (bIVRadarScaling)
fPlayerMarkerPos = (94.0f - 5.5f) * fRadarWidthScale;
UpdateVars();

*dwGameLoadState = 9;
}
Expand Down
36 changes: 22 additions & 14 deletions source/GTAVC.WidescreenFix/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,27 @@ void Fix2DSprites()
pRwRenderStateSet = hook::get_pattern("A1 ? ? ? ? 83 EC 08 83 38 00"); //0x649BA0
}

static float* pMenuPattern6;
CEXP void UpdateVars()
{
if (pMenuPattern6)
{
*pMenuPattern6 = fWideScreenWidthScaleDown;

fCrosshairPosFactor = ((0.52999997f - 0.5f) / ((*CDraw::pfScreenAspectRatio) / (16.0f / 9.0f))) + 0.5f;
fCrosshairHeightScaleDown = fWideScreenWidthScaleDown * *CDraw::pfScreenAspectRatio;

fWideScreenHeightScaleDown = 1.0f / 480.0f;
fCustomWideScreenWidthScaleDown = fWideScreenWidthScaleDown * fHudWidthScale;
fCustomWideScreenHeightScaleDown = fWideScreenHeightScaleDown * fHudHeightScale;

fCustomRadarWidthScale = fWideScreenWidthScaleDown * fRadarWidthScale;
fPlayerMarkerPos = 94.0f * fRadarWidthScale;
if (bIVRadarScaling)
fPlayerMarkerPos = (94.0f - 5.5f) * fRadarWidthScale;
}
}

void Init()
{
//Immediate changes
Expand All @@ -802,7 +823,6 @@ void Init()
{
void operator()(injector::reg_pack& regs)
{
static float* pMenuPattern6;
if (*dwGameLoadState < 9)
{
SilentPatchCompatibility();
Expand All @@ -829,19 +849,7 @@ void Init()
wcscpy(ptr, L"BORDERS");
}

*pMenuPattern6 = fWideScreenWidthScaleDown;

fCrosshairPosFactor = ((0.52999997f - 0.5f) / ((*CDraw::pfScreenAspectRatio) / (16.0f / 9.0f))) + 0.5f;
fCrosshairHeightScaleDown = fWideScreenWidthScaleDown * *CDraw::pfScreenAspectRatio;

fWideScreenHeightScaleDown = 1.0f / 480.0f;
fCustomWideScreenWidthScaleDown = fWideScreenWidthScaleDown * fHudWidthScale;
fCustomWideScreenHeightScaleDown = fWideScreenHeightScaleDown * fHudHeightScale;

fCustomRadarWidthScale = fWideScreenWidthScaleDown * fRadarWidthScale;
fPlayerMarkerPos = 94.0f * fRadarWidthScale;
if (bIVRadarScaling)
fPlayerMarkerPos = (94.0f - 5.5f) * fRadarWidthScale;
UpdateVars();

*dwGameLoadState = 9;
}
Expand Down

0 comments on commit 4cf3a06

Please sign in to comment.