diff options
| author | MegaMech <7255464+MegaMech@users.noreply.github.com> | 2025-01-04 17:31:32 -0700 |
|---|---|---|
| committer | MegaMech <7255464+MegaMech@users.noreply.github.com> | 2025-01-04 17:31:32 -0700 |
| commit | 8746a4337e17f32a38920a45c2e8a0676fbf08bf (patch) | |
| tree | bc8b68dfacaab227891e5397f58fc3e421086cfc /src/port/Engine.cpp | |
| parent | 4dfc8a9fef29af9319d7c145ba7190540ccd9d02 (diff) | |
Wide screen progress
Diffstat (limited to 'src/port/Engine.cpp')
| -rw-r--r-- | src/port/Engine.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 59d76cfb9..4b6b9b2c9 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -449,6 +449,28 @@ extern "C" int16_t OTRGetRectDimensionFromRightEdge(float v) { return ((int) ceilf(OTRGetDimensionFromRightEdge(v))); } +/** + * Centers an item in a given area. + * + * Adds the number of extended screen pixels to the location to center. + * This allows stretching the game window really wide, and the item will stay in-place. + * + * This is not for centering in the direct center of the screen. + * + * How to use: + * + * s32 center = OTRCalculateCenterOfAreaFromRightEdge((SCREEN_WIDTH / 4) + (SCREEN_WIDTH / 2)); + * x = center - (texWidth / 2) + * x2 = center + (texWidth / 2) + */ +extern "C" uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center) { + return ((OTRGetDimensionFromRightEdge(SCREEN_WIDTH) - SCREEN_WIDTH) / 2) + center; +} + +extern "C" uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center) { + return ((OTRGetDimensionFromLeftEdge(0) - SCREEN_WIDTH) / 2) + center; +} + // Gets the width of the current render target area extern "C" uint32_t OTRGetGameRenderWidth() { return gfx_current_dimensions.width; |
