[nostalgia] Break part of core out into Turbine and TeaGBA libraries

This commit is contained in:
2023-06-01 23:22:31 -05:00
parent 07284ac595
commit 8c43baedea
119 changed files with 1918 additions and 1873 deletions
+13 -11
View File
@@ -3,6 +3,7 @@
*/
#include <keel/media.hpp>
#include <turbine/turbine.hpp>
#include <nostalgia/core/core.hpp>
#include <nostalgia/scene/scene.hpp>
@@ -12,7 +13,7 @@ using namespace nostalgia;
static bool s_paused = false;
static ox::Optional<scene::Scene> s_scene;
static int updateHandler(core::Context*) noexcept {
static int updateHandler(turbine::Context&) noexcept {
constexpr auto sleepTime = 16;
if (s_paused) {
return sleepTime;
@@ -21,11 +22,11 @@ static int updateHandler(core::Context*) noexcept {
return sleepTime;
}
static void keyEventHandler(core::Context *ctx, core::Key key, bool down) noexcept {
static void keyEventHandler(turbine::Context &tctx, turbine::Key key, bool down) noexcept {
if (down) {
if (key == core::Key::Alpha_Q) {
core::shutdown(ctx);
} else if (key == core::Key::Alpha_P) {
if (key == turbine::Key::Alpha_Q) {
turbine::requestShutdown(tctx);
} else if (key == turbine::Key::Alpha_P) {
s_paused = !s_paused;
}
}
@@ -33,12 +34,13 @@ static void keyEventHandler(core::Context *ctx, core::Key key, bool down) noexce
ox::Error run(ox::UniquePtr<ox::FileSystem> fs) noexcept {
oxTraceInitHook();
oxRequireM(ctx, core::init(std::move(fs)));
oxRequireM(tctx, turbine::init(std::move(fs)));
oxRequireM(cctx, core::init(tctx.get()));
constexpr ox::FileAddress SceneAddr("/Scenes/Chester.nscn");
oxRequire(scn, keel::readObj<scene::SceneStatic>(ctx.get(), SceneAddr));
core::setUpdateHandler(ctx.get(), updateHandler);
core::setKeyEventHandler(ctx.get(), keyEventHandler);
oxRequire(scn, keel::readObj<scene::SceneStatic>(tctx.get(), SceneAddr));
turbine::setUpdateHandler(*tctx, updateHandler);
turbine::setKeyEventHandler(*tctx, keyEventHandler);
s_scene.emplace(*scn);
oxReturnError(s_scene->setupDisplay(ctx.get()));
return core::run(ctx.get());
oxReturnError(s_scene->setupDisplay(cctx.get()));
return turbine::run(*tctx);
}