[turbine,nostalgia] Cleanup
This commit is contained in:
parent
87e2fdefcf
commit
3c056276c1
@ -12,7 +12,7 @@ namespace nostalgia::gfx {
|
||||
using Color16 = uint16_t;
|
||||
|
||||
/**
|
||||
* Nostalgia Core logically uses 16 bit colors, but must translate that to 32
|
||||
* Nostalgia logically uses 16 bit colors, but must translate that to 32
|
||||
* bit colors in some implementations.
|
||||
*/
|
||||
using Color32 = uint32_t;
|
||||
|
@ -4,10 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/model/desctypes.hpp>
|
||||
#include <ox/std/buffer.hpp>
|
||||
#include <ox/std/size.hpp>
|
||||
#include <ox/std/memory.hpp>
|
||||
|
||||
#include <turbine/context.hpp>
|
||||
|
||||
@ -19,9 +16,7 @@ class Context;
|
||||
|
||||
void safeDelete(Context *ctx) noexcept;
|
||||
|
||||
using ContextUPtr = ox::UPtr<Context>;
|
||||
|
||||
ox::Result<ContextUPtr> init(turbine::Context &tctx, InitParams const¶ms = {}) noexcept;
|
||||
ox::Result<ox::UPtr<Context>> init(turbine::Context &tctx, InitParams const¶ms = {}) noexcept;
|
||||
|
||||
keel::Context &keelCtx(Context &ctx) noexcept;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
namespace nostalgia::gfx {
|
||||
|
||||
struct Sprite {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Sprite";
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.Sprite";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
bool enabled = false;
|
||||
int x = 0;
|
||||
@ -46,7 +46,7 @@ OX_MODEL_BEGIN(Sprite)
|
||||
OX_MODEL_END()
|
||||
|
||||
struct BgTile {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.BgTile";
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.BgTile";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
unsigned tileIdx = 0;
|
||||
unsigned palBank = 0;
|
||||
@ -62,7 +62,7 @@ OX_MODEL_BEGIN(BgTile)
|
||||
OX_MODEL_END()
|
||||
|
||||
struct TileSheetSetEntrySection {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSetEntrySection";
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.TileSheetSetEntrySection";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
int32_t begin = 0;
|
||||
int32_t tiles = 0;
|
||||
@ -78,7 +78,7 @@ OX_MODEL_BEGIN(TileSheetSetEntrySection)
|
||||
OX_MODEL_END()
|
||||
|
||||
struct TileSheetSetEntry {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSetEntry";
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.TileSheetSetEntry";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
ox::FileAddress tilesheet;
|
||||
ox::Vector<TileSheetSetEntrySection> sections;
|
||||
@ -90,7 +90,7 @@ OX_MODEL_BEGIN(TileSheetSetEntry)
|
||||
OX_MODEL_END()
|
||||
|
||||
struct TileSheetSet {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheetSet";
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.TileSheetSet";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
static constexpr auto Preloadable = true;
|
||||
int32_t bpp = 0;
|
||||
|
@ -19,10 +19,10 @@ Context::Context(turbine::Context &tctx) noexcept: turbineCtx(tctx) {
|
||||
|
||||
ox::Error initGfx(Context &ctx, InitParams const&) noexcept;
|
||||
|
||||
ox::Result<ContextUPtr> init(turbine::Context &tctx, InitParams const¶ms) noexcept {
|
||||
ox::Result<ox::UPtr<Context>> init(turbine::Context &tctx, InitParams const¶ms) noexcept {
|
||||
auto ctx = ox::make_unique<Context>(tctx);
|
||||
OX_RETURN_ERROR(initGfx(*ctx, params));
|
||||
return ContextUPtr(std::move(ctx));
|
||||
return ox::UPtr<Context>(std::move(ctx));
|
||||
}
|
||||
|
||||
keel::Context &keelCtx(Context &ctx) noexcept {
|
||||
@ -33,4 +33,4 @@ turbine::Context &turbineCtx(Context &ctx) noexcept {
|
||||
return ctx.turbineCtx;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include <ox/model/model.hpp>
|
||||
|
||||
#include <keel/asset.hpp>
|
||||
#include <keel/module.hpp>
|
||||
|
||||
#include <nostalgia/gfx/palette.hpp>
|
||||
@ -29,7 +28,7 @@ static class: public keel::Module {
|
||||
public:
|
||||
[[nodiscard]]
|
||||
ox::String id() const noexcept override {
|
||||
return ox::String("net.drinkingtea.nostalgia.core");
|
||||
return ox::String{"net.drinkingtea.nostalgia.gfx"};
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
@ -92,6 +91,7 @@ static class: public keel::Module {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
} const mod;
|
||||
|
||||
keel::Module const*keelModule() noexcept {
|
||||
|
@ -23,10 +23,10 @@ Context::~Context() noexcept {
|
||||
shutdownGfx(*this);
|
||||
}
|
||||
|
||||
ox::Result<ContextUPtr> init(turbine::Context &tctx, InitParams const¶ms) noexcept {
|
||||
ox::Result<ox::UPtr<Context>> init(turbine::Context &tctx, InitParams const¶ms) noexcept {
|
||||
auto ctx = ox::make_unique<Context>(tctx, params);
|
||||
OX_RETURN_ERROR(initGfx(*ctx, params));
|
||||
return ContextUPtr(ctx.release());
|
||||
return ox::UPtr<Context>(ctx.release());
|
||||
}
|
||||
|
||||
keel::Context &keelCtx(Context &ctx) noexcept {
|
||||
|
@ -650,7 +650,7 @@ ox::Error loadSpriteTileSheet(
|
||||
CompactTileSheet const&ts,
|
||||
bool loadDefaultPalette) noexcept {
|
||||
OX_REQUIRE(tsd, normalizeTileSheet(ts));
|
||||
oxTracef("nostalgia.core.gfx.gl", "loadSpriteTexture: { w: {}, h: {} }", tsd.width, tsd.height);
|
||||
oxTracef("nostalgia.gfx.gl", "loadSpriteTexture: { w: {}, h: {} }", tsd.width, tsd.height);
|
||||
ctx.spriteBlocks.tex = renderer::createTexture(tsd.width, tsd.height, tsd.pixels.data());
|
||||
if (loadDefaultPalette) {
|
||||
OX_RETURN_ERROR(loadSpritePalette(ctx, ts.defaultPalette));
|
||||
@ -673,7 +673,7 @@ void setBgTile(
|
||||
int row,
|
||||
BgTile const&tile) noexcept {
|
||||
oxTracef(
|
||||
"nostalgia.core.gfx.setBgTile",
|
||||
"nostalgia.gfx.setBgTile",
|
||||
"bgIdx: {}, column: {}, row: {}, tile: {}, palBank: {}",
|
||||
bgIdx, column, row, tile.tileIdx, tile.palBank);
|
||||
const auto z = static_cast<uint_t>(bgIdx);
|
||||
|
@ -14,13 +14,13 @@ OX_MODEL_FWD_DECL(class TileSheetClipboard);
|
||||
|
||||
class TileSheetClipboard: public turbine::ClipboardObject<TileSheetClipboard> {
|
||||
public:
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.TileSheetClipboard";
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.studio.TileSheetClipboard";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
|
||||
OX_MODEL_FRIEND(TileSheetClipboard);
|
||||
|
||||
struct Pixel {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.TileSheetClipboard.Pixel";
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.studio.TileSheetClipboard.Pixel";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
uint16_t colorIdx = 0;
|
||||
ox::Point pt;
|
||||
|
@ -16,7 +16,7 @@ namespace nostalgia::gfx {
|
||||
namespace ig = studio::ig;
|
||||
|
||||
struct TileSheetEditorConfig {
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.TileSheetEditorConfig";
|
||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.gfx.studio.TileSheetEditorConfig";
|
||||
static constexpr auto TypeVersion = 1;
|
||||
TileSheet::SubSheetIdx activeSubsheet{};
|
||||
};
|
||||
@ -47,8 +47,8 @@ static ox::Vector<uint32_t> normalizePixelSizes(
|
||||
|
||||
static ox::Vector<uint32_t> normalizePixelArrangement(
|
||||
ox::Vector<uint32_t> const&inPixels,
|
||||
int cols,
|
||||
int scale) {
|
||||
int const cols,
|
||||
int const scale) {
|
||||
auto const scalePt = ox::Point{scale, scale};
|
||||
auto const width = cols * TileWidth;
|
||||
auto const height = static_cast<int>(inPixels.size()) / width;
|
||||
|
@ -15,7 +15,7 @@ namespace nostalgia::scene {
|
||||
class SceneEditorView {
|
||||
|
||||
private:
|
||||
gfx::ContextUPtr m_cctx;
|
||||
ox::UPtr<gfx::Context> m_cctx;
|
||||
SceneStatic const&m_sceneStatic;
|
||||
Scene m_scene;
|
||||
glutils::FrameBuffer m_frameBuffer;
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user