diff --git a/src/nostalgia/core/gba/gfx.cpp b/src/nostalgia/core/gba/gfx.cpp index 0fe8a270..6c917f1c 100644 --- a/src/nostalgia/core/gba/gfx.cpp +++ b/src/nostalgia/core/gba/gfx.cpp @@ -101,6 +101,18 @@ ox::Error shutdownGfx(Context*) { return OxError(0); } +int getScreenWidth(Context*) { + return 240; +} + +int getScreenHeight(Context*) { + return 160; +} + +common::Point getScreenSize(Context*) { + return {240, 160}; +} + [[nodiscard]] constexpr volatile uint32_t &bgCtl(int bg) noexcept { switch (bg) { case 0: diff --git a/src/nostalgia/core/gfx.hpp b/src/nostalgia/core/gfx.hpp index 94fcb31c..b66f3ab5 100644 --- a/src/nostalgia/core/gfx.hpp +++ b/src/nostalgia/core/gfx.hpp @@ -9,6 +9,7 @@ #pragma once #include +#include #include "context.hpp" @@ -80,7 +81,13 @@ struct Sprite { ox::Error initGfx(Context *ctx); -ox::Error shutdownGfx(Context*); +ox::Error shutdownGfx(Context *ctx); + +int getScreenWidth(Context *ctx); + +int getScreenHeight(Context *ctx); + +common::Point getScreenSize(Context *ctx); ox::Error initConsole(Context *ctx); diff --git a/src/nostalgia/core/sdl/gfx.cpp b/src/nostalgia/core/sdl/gfx.cpp index 986b8c97..c8847781 100644 --- a/src/nostalgia/core/sdl/gfx.cpp +++ b/src/nostalgia/core/sdl/gfx.cpp @@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "nostalgia/common/point.hpp" #include #ifdef NOST_FPS_PRINT #include @@ -57,4 +58,25 @@ ox::Error shutdownGfx(Context *ctx) { return OxError(0); } +int getScreenWidth(Context *ctx) { + auto id = ctx->windowerData(); + int x = 0, y = 0; + SDL_GetWindowSize(id->window, &x, &y); + return x; +} + +int getScreenHeight(Context *ctx) { + auto id = ctx->windowerData(); + int x = 0, y = 0; + SDL_GetWindowSize(id->window, &x, &y); + return y; +} + +common::Point getScreenSize(Context *ctx) { + auto id = ctx->windowerData(); + int x = 0, y = 0; + SDL_GetWindowSize(id->window, &x, &y); + return {x, y}; +} + }