[turbine,nostalgia] Cleanup
This commit is contained in:
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user