[turbine,nostalgia] Cleanup

This commit is contained in:
2025-01-20 23:19:07 -06:00
parent 87e2fdefcf
commit 3c056276c1
17 changed files with 37 additions and 46 deletions

View File

@ -17,11 +17,7 @@ namespace turbine {
class Context;
struct ContextDeleter {
void operator()(Context *p) noexcept;
};
using ContextUPtr = ox::UPtr<Context, ContextDeleter>;
void safeDelete(Context *p);
void shutdown(Context &ctx) noexcept;

View File

@ -16,9 +16,9 @@ namespace turbine {
using TimeMs = uint64_t;
ox::Result<ContextUPtr> init(ox::UPtr<ox::FileSystem> &&fs, ox::StringViewCR appName) noexcept;
ox::Result<ox::UPtr<Context>> init(ox::UPtr<ox::FileSystem> &&fs, ox::StringViewCR appName) noexcept;
ox::Result<ContextUPtr> init(ox::StringViewCR fsPath, ox::StringViewCR appName) noexcept;
ox::Result<ox::UPtr<Context>> init(ox::StringViewCR fsPath, ox::StringViewCR appName) noexcept;
ox::Error run(Context &ctx) noexcept;

View File

@ -6,8 +6,8 @@
namespace turbine {
void ContextDeleter::operator()(Context *p) noexcept {
ox::safeDelete(p);
void safeDelete(Context *p) {
delete p;
}
keel::Context const&keelCtx(Context const&ctx) noexcept {

View File

@ -58,7 +58,7 @@ OX_ALLOW_UNSAFE_BUFFERS_END
return ox::Error(1);
}
ox::Result<ContextUPtr> init(
ox::Result<ox::UPtr<Context>> init(
ox::UPtr<ox::FileSystem> &&fs, ox::StringViewCR appName) noexcept {
auto ctx = ox::make_unique<Context>();
OX_RETURN_ERROR(keel::init(ctx->keelCtx, std::move(fs), appName));
@ -68,7 +68,7 @@ ox::Result<ContextUPtr> init(
OX_RETURN_ERROR(initGfx(*ctx));
initTimer();
initIrq();
return ox::UPtr<turbine::Context, ContextDeleter>(std::move(ctx));
return ox::UPtr<Context>(std::move(ctx));
}
void shutdown(Context&) noexcept {

View File

@ -8,8 +8,8 @@
namespace turbine {
void ContextDeleter::operator()(Context *p) noexcept {
ox::safeDelete(p);
void safeDelete(Context *p) {
delete p;
}
keel::Context const&keelCtx(Context const&ctx) noexcept {

View File

@ -40,7 +40,7 @@ static void draw(GLFWwindow *window, int, int) noexcept {
draw(ctx);
}
ox::Result<ContextUPtr> init(
ox::Result<ox::UPtr<Context>> init(
ox::UPtr<ox::FileSystem> &&fs, ox::StringViewCR appName) noexcept {
auto ctx = ox::make_unique<Context>();
OX_RETURN_ERROR(keel::init(ctx->keelCtx, std::move(fs), appName));
@ -51,10 +51,10 @@ ox::Result<ContextUPtr> init(
OX_RETURN_ERROR(initGfx(*ctx));
glfwSetWindowSizeCallback(ctx->window, draw);
ctx->mandatoryRefreshPeriodEnd = ticksMs(*ctx) + config::MandatoryRefreshPeriod;
return ox::UPtr<Context, ContextDeleter>(ctx.release());
return ox::UPtr<Context>(ctx.release());
}
static void tickFps(Context &ctx, uint64_t nowMs) noexcept {
static void tickFps(Context &ctx, uint64_t const nowMs) noexcept {
++ctx.draws;
if (ctx.draws >= 500) {
auto const duration = static_cast<double>(nowMs - ctx.prevFpsCheckTime) / 1000.0;
@ -114,7 +114,7 @@ TimeMs ticksMs(Context const&ctx) noexcept {
return static_cast<TimeMs>(now) - ctx.startTime;
}
bool buttonDown(Context const&ctx, Key key) noexcept {
bool buttonDown(Context const&ctx, Key const key) noexcept {
return (ctx.keysDown >> static_cast<int>(key)) & 1;
}

View File

@ -8,7 +8,7 @@
namespace turbine {
ox::Result<ContextUPtr> init(ox::StringViewCR fsPath, ox::StringViewCR appName) noexcept {
ox::Result<ox::UPtr<Context>> init(ox::StringViewCR fsPath, ox::StringViewCR appName) noexcept {
OX_REQUIRE_M(fs, keel::loadRomFs(fsPath));
return init(std::move(fs), appName);
}