[jasper/player] Cleanup
Some checks failed
Build / build (push) Has been cancelled

This commit is contained in:
Gary Talent 2024-12-06 23:19:30 -06:00
parent 80e06a5a57
commit 0727b9a1a8

View File

@ -15,17 +15,24 @@
namespace ncore = nostalgia::core;
namespace jasper {
using namespace jasper;
ox::Error run(turbine::Context &tctx, ox::StringView, ox::SpanView<ox::String> args) noexcept {
ox::Error run(
ox::StringView project,
[[maybe_unused]] ox::StringView appName,
[[maybe_unused]] ox::StringView projectDataDir,
ox::SpanView<ox::CString> args) noexcept {
auto const fsPath = args.size() > 1 ? args[1] : ".";
oxRequireM(tctx, turbine::init(fsPath, project));
oxRequire(bootfile, keel::readObj<jasper::core::Bootfile>(keelCtx(*tctx), "/Bootfile"));
oxOut("Jasper Player\n");
oxRequire(nctx, ncore::init(tctx));
auto const&worldPath = args[0];
oxRequire(worldStatic, readObj<world::WorldStatic>(keelCtx(tctx), worldPath));
oxRequire(nctx, ncore::init(*tctx));
auto const&worldPath = *bootfile->args.at(0).unwrap();
oxRequire(worldStatic, readObj<world::WorldStatic>(keelCtx(*tctx), worldPath));
world::World world(*nctx, *worldStatic);
oxReturnError(world.setupDisplay());
turbine::setApplicationData(tctx, &world);
setUpdateHandler(tctx, [](turbine::Context &tctx) -> int {
turbine::setApplicationData(*tctx, &world);
setUpdateHandler(*tctx, [](turbine::Context &tctx) -> int {
auto &world = *applicationData<world::World>(tctx);
auto [sleepTime, err] = world.update();
if (err) {
@ -33,25 +40,7 @@ ox::Error run(turbine::Context &tctx, ox::StringView, ox::SpanView<ox::String> a
}
return 0;
});
oxReturnError(turbine::run(tctx));
oxReturnError(turbine::run(*tctx));
oxOut("Exiting...\n");
return {};
}
}
ox::Error run(
ox::StringView project,
[[maybe_unused]] ox::StringView appName,
[[maybe_unused]] ox::StringView projectDataDir,
ox::SpanView<ox::CString> args) noexcept {
auto path = ".";
if (args.size() > 1) {
path = args[1];
}
oxRequireM(fs, keel::loadRomFs(path));
oxRequireM(tctx, turbine::init(std::move(fs), project));
constexpr ox::FileAddress BootfileAddr = ox::StringLiteral{"/Bootfile"};
oxRequire(bootfile, keel::readObj<jasper::core::Bootfile>(keelCtx(*tctx), BootfileAddr));
return jasper::run(*tctx, bootfile->app, bootfile->args);
}