diff options
| author | Sonic Dreamcaster <alejandro.asenjo88@gmail.com> | 2024-10-23 11:21:03 -0300 |
|---|---|---|
| committer | Sonic Dreamcaster <alejandro.asenjo88@gmail.com> | 2024-10-23 11:21:03 -0300 |
| commit | 520d49705e15894f73d6e765587005a3766cc024 (patch) | |
| tree | 9aa344895fbba45170382fb21b87b40239e91cd5 /src/port/Engine.cpp | |
| parent | 0900ba71ef60622a7838ef708fb3466bff2ca8d6 (diff) | |
OTRConvertHUDXToScreenX
Diffstat (limited to 'src/port/Engine.cpp')
| -rw-r--r-- | src/port/Engine.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 665dc23b..28a24845 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -349,4 +349,21 @@ extern "C" int16_t OTRGetRectDimensionFromLeftEdge(float v) { extern "C" int16_t OTRGetRectDimensionFromRightEdge(float v) { return ((int)ceilf(OTRGetDimensionFromRightEdge(v))); +} + +extern "C" int32_t OTRConvertHUDXToScreenX(int32_t v) { + float gameAspectRatio = gfx_current_dimensions.aspect_ratio; + int32_t gameHeight = gfx_current_dimensions.height; + int32_t gameWidth = gfx_current_dimensions.width; + float hudAspectRatio = 4.0f / 3.0f; + int32_t hudHeight = gameHeight; + int32_t hudWidth = hudHeight * hudAspectRatio; + float hudScreenRatio = (hudWidth / 320.0f); + float hudCoord = v * hudScreenRatio; + float gameOffset = (gameWidth - hudWidth) / 2; + float gameCoord = hudCoord + gameOffset; + float gameScreenRatio = (320.0f / gameWidth); + float screenScaledCoord = gameCoord * gameScreenRatio; + int32_t screenScaledCoordInt = screenScaledCoord; + return screenScaledCoordInt; }
\ No newline at end of file |
