[nostaliga] Cleanup

This commit is contained in:
Gary Talent 2023-06-03 22:06:08 -05:00
parent 8c7f6ffafc
commit 2887fa7819
15 changed files with 31 additions and 49 deletions

View File

@ -1,6 +1,5 @@
add_library(
NostalgiaCore
context.cpp
gfx.cpp
keelmodule.cpp
typeconv.cpp

View File

@ -1,3 +0,0 @@
/*
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/

View File

@ -9,7 +9,6 @@
#include <ox/std/buffer.hpp>
#include <ox/std/size.hpp>
#include <keel/context.hpp>
#include <turbine/context.hpp>
#include "initparams.hpp"
@ -27,11 +26,13 @@ class Context {
Context(const Context &other) noexcept = delete;
Context(const Context &&other) noexcept = delete;
auto &rom() noexcept {
const auto &rom() const noexcept {
return *turbineCtx->rom;
}
};
ox::Result<ox::UniquePtr<Context>> init(turbine::Context *tctx, const InitParams& = {}) noexcept;
}

View File

@ -4,10 +4,12 @@
#pragma once
#include "color.hpp"
#include "context.hpp"
namespace nostalgia::core {
ox::Result<ox::UniquePtr<Context>> init(turbine::Context *tctx, const InitParams& = {}) noexcept;
}
#include "gfx.hpp"
#include "initparams.hpp"
#include "keelmodule.hpp"
#include "palette.hpp"
#include "ptidxconv.hpp"
#include "tilesheet.hpp"
#include "typeconv.hpp"

View File

@ -130,7 +130,7 @@ ox::Error loadBgTileSheet(Context *ctx,
const ox::FileAddress &tilesheetAddr,
const ox::FileAddress &paletteAddr) noexcept {
oxRequire(tsStat, ctx->rom().stat(tilesheetAddr));
oxRequire(ts, static_cast<ox::MemFS*>(&ctx->rom())->directAccess(tilesheetAddr));
oxRequire(ts, static_cast<const ox::MemFS&>(ctx->rom()).directAccess(tilesheetAddr));
GbaTileMapTarget target;
target.pal.palette = MEM_BG_PALETTE;
target.cbbData = &g_cbbData[cbb];
@ -139,7 +139,7 @@ ox::Error loadBgTileSheet(Context *ctx,
// load external palette if available
if (paletteAddr) {
oxRequire(palStat, ctx->rom().stat(paletteAddr));
oxRequire(pal, static_cast<ox::MemFS*>(&ctx->rom())->directAccess(paletteAddr));
oxRequire(pal, static_cast<const ox::MemFS&>(ctx->rom()).directAccess(paletteAddr));
oxReturnError(ox::readMC(pal, palStat.size, &target.pal));
}
// update bpp of all bgs with the updated cbb
@ -156,7 +156,7 @@ ox::Error loadSpriteTileSheet(Context *ctx,
const ox::FileAddress &tilesheetAddr,
const ox::FileAddress &paletteAddr) noexcept {
oxRequire(tsStat, ctx->rom().stat(tilesheetAddr));
oxRequire(ts, static_cast<ox::MemFS*>(&ctx->rom())->directAccess(tilesheetAddr));
oxRequire(ts, static_cast<const ox::MemFS&>(ctx->rom()).directAccess(tilesheetAddr));
GbaTileMapTarget target;
target.pal.palette = MEM_SPRITE_PALETTE;
target.tileMap = MEM_SPRITE_TILES;
@ -164,7 +164,7 @@ ox::Error loadSpriteTileSheet(Context *ctx,
// load external palette if available
if (paletteAddr) {
oxRequire(palStat, ctx->rom().stat(paletteAddr));
oxRequire(pal, static_cast<ox::MemFS*>(&ctx->rom())->directAccess(paletteAddr));
oxRequire(pal, static_cast<const ox::MemFS&>(ctx->rom()).directAccess(paletteAddr));
oxReturnError(ox::readMC(pal, palStat.size, &target.pal));
}
return {};
@ -174,7 +174,7 @@ ox::Error loadBgPalette(Context *ctx, unsigned, const ox::FileAddress &paletteAd
GbaPaletteTarget target;
target.palette = MEM_BG_PALETTE;
oxRequire(palStat, ctx->rom().stat(paletteAddr));
oxRequire(pal, static_cast<ox::MemFS*>(&ctx->rom())->directAccess(paletteAddr));
oxRequire(pal, static_cast<const ox::MemFS&>(ctx->rom()).directAccess(paletteAddr));
oxReturnError(ox::readMC(pal, palStat.size, &target));
return {};
}
@ -183,7 +183,7 @@ ox::Error loadSpritePalette(Context *ctx, unsigned cbb, const ox::FileAddress &p
GbaPaletteTarget target;
target.palette = &MEM_SPRITE_PALETTE[cbb];
oxRequire(palStat, ctx->rom().stat(paletteAddr));
oxRequire(pal, static_cast<ox::MemFS*>(&ctx->rom())->directAccess(paletteAddr));
oxRequire(pal, static_cast<const ox::MemFS&>(ctx->rom()).directAccess(paletteAddr));
oxReturnError(ox::readMC(pal, palStat.size, &target));
return {};
}

View File

@ -1,7 +1,6 @@
target_sources(
NostalgiaCore PRIVATE
context.cpp
core.cpp
gfx.cpp
)
target_link_libraries(

View File

@ -11,4 +11,11 @@ GlContext::~GlContext() noexcept {
shutdownGfx(this);
}
ox::Result<ox::UniquePtr<Context>> init(turbine::Context *tctx, const InitParams &params) noexcept {
ox::UPtr<Context> ctx = ox::make_unique<GlContext>();
ctx->turbineCtx = tctx;
oxReturnError(initGfx(ctx.get(), params));
return ctx;
}
}

View File

@ -1,21 +0,0 @@
/*
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <nostalgia/core/context.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/core/core.hpp>
#include "context.hpp"
namespace nostalgia::core {
ox::Result<ox::UniquePtr<Context>> init(turbine::Context *tctx, const InitParams &params) noexcept {
ox::UPtr<Context> ctx = ox::make_unique<GlContext>();
ctx->turbineCtx = tctx;
oxReturnError(initGfx(ctx.get(), params));
return ctx;
}
}

View File

@ -6,8 +6,6 @@
#include <keel/media.hpp>
#include <nostalgia/core/gfx.hpp>
#include "sceneeditor-imgui.hpp"
namespace nostalgia::scene {

View File

@ -6,7 +6,7 @@
#include <studio/studio.hpp>
#include <nostalgia/core/gfx.hpp>
#include <turbine/context.hpp>
#include "sceneeditor.hpp"
#include "sceneeditorview.hpp"

View File

@ -2,6 +2,8 @@
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <keel/keel.hpp>
#include "sceneeditor.hpp"
namespace nostalgia::scene {

View File

@ -4,9 +4,8 @@
#pragma once
#include <studio/studio.hpp>
#include <turbine/context.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/scene/scene.hpp>
namespace nostalgia::scene {

View File

@ -2,7 +2,7 @@
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <nostalgia/core/core.hpp>
#include <nostalgia/core/gfx.hpp>
#include "sceneeditorview.hpp"
@ -22,7 +22,7 @@ void SceneEditorView::draw(int width, int height) noexcept {
if (width != m_frameBuffer.width || height != m_frameBuffer.height) {
glutils::resizeInitFrameBuffer(&m_frameBuffer, width, height);
}
glutils::FrameBufferBind frameBufferBind(m_frameBuffer);
const glutils::FrameBufferBind frameBufferBind(m_frameBuffer);
core::gl::drawMainView(m_cctx.get(), {width, height});
}

View File

@ -6,7 +6,7 @@
#include <glutils/glutils.hpp>
#include <nostalgia/core/gfx.hpp>
#include <nostalgia/core/context.hpp>
#include <nostalgia/scene/scene.hpp>
namespace nostalgia::scene {

View File

@ -4,7 +4,6 @@
#pragma once
#include <turbine/turbine.hpp>
#include <studio/studio.hpp>
namespace nostalgia::scene {