[nostalgia] Make core::shutdown return void and add GBA implementation

This commit is contained in:
2022-03-25 01:28:26 -05:00
parent 6eb4070d97
commit 053d35b31c
7 changed files with 21 additions and 9 deletions
+3 -1
View File
@@ -56,7 +56,7 @@ class Context {
const ox::FileAddress &tilesheetPath,
const ox::FileAddress &palettePath) noexcept;
friend ox::Error run(Context *ctx) noexcept;
friend ox::Error shutdown(Context *ctx) noexcept;
friend void shutdown(Context *ctx) noexcept;
friend ox::Result<ox::UniquePtr<Context>> init(ox::UniquePtr<ox::FileSystem> fs, const char *appName) noexcept;
friend ox::String getClipboardText(Context *ctx) noexcept;
friend uint64_t ticksMs(Context *ctx) noexcept;
@@ -82,6 +82,8 @@ class Context {
AssetManager assetManager;
int uninterruptedRefreshes = 3;
ox::UniquePtr<BaseClipboardObject> clipboard;
#else
bool running = true;
#endif
protected:
#ifndef OX_BARE_METAL
+1 -1
View File
@@ -26,6 +26,6 @@ ox::Error run(Context *ctx) noexcept;
[[nodiscard]]
uint64_t ticksMs(Context *ctx) noexcept;
ox::Error shutdown(Context *ctx) noexcept;
void shutdown(Context *ctx) noexcept;
}
+1 -1
View File
@@ -20,7 +20,7 @@ UpdateHandler g_updateHandler = nullptr;
ox::Error run(Context *ctx) noexcept {
g_wakeupTime = 0;
while (1) {
while (ctx->running) {
if (g_wakeupTime <= g_timerMs && g_updateHandler) {
auto sleepTime = g_updateHandler(ctx);
if (sleepTime >= 0) {
+4
View File
@@ -59,4 +59,8 @@ bool buttonDown(Context*, Key k) noexcept {
return !(REG_GAMEPAD & (1 << static_cast<int>(k)));
}
void shutdown(Context *ctx) noexcept {
ctx->running = false;
}
}
+1 -2
View File
@@ -79,10 +79,9 @@ bool buttonDown(Context *ctx, Key key) noexcept {
return (id->keysDown >> static_cast<int>(key)) & 1;
}
ox::Error shutdown(Context *ctx) noexcept {
void shutdown(Context *ctx) noexcept {
const auto id = ctx->windowerData<GlfwImplData>();
glfwSetWindowShouldClose(id->window, true);
return OxError(0);
}
}