-
-
Notifications
You must be signed in to change notification settings - Fork 463
Fix HUD size when playing on widescreen #3444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
botder
merged 26 commits into
multitheftauto:master
from
henrymarques:bugfix/widescreen
May 26, 2025
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f1d7a6f
Fix HUD size when playing on widescreen
henrymarques eee2a8e
Remove junk code from hud header file
henrymarques 41f7701
Merge branch 'master' of https://github.com/multitheftauto/mtasa-blue…
henrymarques 7992392
Upload widescreen fix
henrymarques d618a60
Removed frontend fixes due it's not necessary
henrymarques b0cf8f5
Removed unnecessary null pointers and null checks
henrymarques 6a4ee2f
Change type references
henrymarques 88d0820
Remove unused variables, change altimeter size and const to constexpr
henrymarques aa2c42c
Change variable names and remove unused functions
henrymarques b299e1b
Remove AdjustFOV due it's not used
henrymarques 099e827
Remove unused structs, align zones and vehicle names
henrymarques d68a3d6
Merge branch 'master' of https://github.com/multitheftauto/mtasa-blue…
henrymarques 0fa951a
Remove unecessary patches
henrymarques 41ef5a5
Align weapon ammo, add fov fix
henrymarques 4254ce2
Add ability to choose hud match aspect ratio
henrymarques 6911919
Remove testing junk
henrymarques a0b4dd1
Merge branch 'master' of github.com:multitheftauto/mtasa-blue into fe…
henrymarques 07effc3
Fix merge conflicts
henrymarques 3d0998a
Rework hud changes
henrymarques 4e396f7
Merge branch 'master' of github.com:multitheftauto/mtasa-blue into fe…
henrymarques f1a16a6
Move hud changes to CHudSA.cpp
henrymarques d9554ae
Adjust altimeter size
henrymarques 1d12abc
Add comments
henrymarques 26b64e5
Make functions static
henrymarques 91c5dc6
Merge branch 'master' of github.com:multitheftauto/mtasa-blue into bu…
henrymarques 52e2731
Change cast on CHudSA
henrymarques File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: multiplayer_sa/CMultiplayerSA_WidescreenFix.cpp | ||
* | ||
* Multi Theft Auto is available from https://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
// NOTE: This code is based on ThirteenAG's fix, which is licensed under the MIT license. | ||
#include "StdInc.h" | ||
|
||
#ifndef M_PI | ||
#define M_PI 3.14159265358979323846 | ||
#endif | ||
|
||
static constexpr float CameraWidth = 0.01403292f; | ||
static constexpr float SkyMultiFix = 10.0f; | ||
|
||
static float* ScreenAspectRatio = reinterpret_cast<float*>(0xC3EFA4); | ||
static float* ScreenFieldOfView = reinterpret_cast<float*>(0x8D5038); | ||
|
||
static float AdjustFOV(float factor, float aspectRatio) noexcept | ||
{ | ||
return std::round((2.0f * std::atan(((aspectRatio) / (4.0f / 3.0f)) * | ||
std::tan(factor / 2.0f * ((float)M_PI / 180.0f)))) * | ||
(180.0f / (float)M_PI) * 100.0f) / 100.0f; | ||
} | ||
|
||
static void SetFOV(float factor) | ||
{ | ||
*ScreenFieldOfView = AdjustFOV(factor, *ScreenAspectRatio); | ||
} | ||
|
||
static constexpr std::uintptr_t RETURN_CCamera_Find3rdPersonCamTargetVector = 0x5149A6; | ||
static void __declspec(naked) CalculateAimingPoint() | ||
{ | ||
_asm | ||
{ | ||
fstp st | ||
mov edx, [ScreenAspectRatio] | ||
fmul [edx] | ||
mov edi, [esp + 1Ch + 14h] | ||
mov edx, edi | ||
jmp RETURN_CCamera_Find3rdPersonCamTargetVector | ||
} | ||
} | ||
|
||
static void InstallAspectRatioFixes() | ||
{ | ||
// Disables jump instructions in GetVideoModeList | ||
MemSet((void*)0x745BD1, 0x90, 2); | ||
MemSet((void*)0x745BD9, 0x90, 2); | ||
|
||
// Proportional coronas, skips multiplication by ScreenY in CCoronas::Render | ||
MemSet((void*)0x6FB2C9, 0x90, 4); | ||
|
||
// Load ScreenY value from the stack | ||
MemPut<BYTE>(0x6FB2BD, 0x6C); // CCoronas::Render | ||
MemPut<BYTE>(0x6FB2DC, 0x78); // CCoronas::Render | ||
MemPut<BYTE>(0x713BE5, 0x20); // CClouds::Render | ||
MemPut<BYTE>(0x713B6D, 0x38); // CClouds::Render | ||
MemPut<BYTE>(0x713CFB, 0x38); // CClouds::Render | ||
MemPut<BYTE>(0x713EFC, 0x30); // CClouds::Render | ||
MemPut<BYTE>(0x714004, 0x38); // CClouds::Render | ||
} | ||
|
||
static void InstallFieldOfViewFixes() | ||
{ | ||
// Fix sky blurring white in ultrawide screens | ||
MemPut<const float*>(0x714843, &SkyMultiFix); | ||
MemPut<const float*>(0x714860, &SkyMultiFix); | ||
henrymarques marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
HookInstall(0x6FF410, reinterpret_cast<DWORD>(SetFOV), 9); | ||
HookInstall(0x51499E, reinterpret_cast<DWORD>(CalculateAimingPoint), 6); | ||
|
||
// Skips division by CDraw::ms_fAspectRatio | ||
MemSet((void*)0x50AD79, 0x90, 6); | ||
henrymarques marked this conversation as resolved.
Show resolved
Hide resolved
|
||
MemPut<const float*>(0x50AD5B, &CameraWidth); // CCamera::Find3rdPersonQuickAimPitch | ||
MemPut<const float*>(0x51498F, &CameraWidth); // CCamera::Find3rdPersonCamTargetVector | ||
} | ||
|
||
void CMultiplayerSA::InitHooks_WidescreenFix() | ||
henrymarques marked this conversation as resolved.
Show resolved
Hide resolved
henrymarques marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
InstallAspectRatioFixes(); | ||
InstallFieldOfViewFixes(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.