[jasper] Upgrade to newer Nostalgia
All checks were successful
Build / build (push) Successful in 3m57s

This commit is contained in:
Gary Talent 2025-01-20 03:18:30 -06:00
parent 2eb87c06f2
commit c33ffa7b36
19 changed files with 84 additions and 84 deletions

View File

@ -4,13 +4,13 @@
#pragma once #pragma once
#include <nostalgia/core/context.hpp> #include <nostalgia/gfx/context.hpp>
#include "worldstatic.hpp" #include "worldstatic.hpp"
namespace jasper::world { namespace jasper::world {
namespace ncore = nostalgia::core; namespace ngfx = nostalgia::gfx;
class World { class World {
private: private:
@ -19,14 +19,14 @@ class World {
uint16_t frame{}; uint16_t frame{};
turbine::TimeMs nextUpdateTime{}; turbine::TimeMs nextUpdateTime{};
}; };
ncore::Context &m_nctx; ngfx::Context &m_nctx;
WorldStatic const&m_worldStatic; WorldStatic const&m_worldStatic;
ox::Vector<keel::AssetRef<ncore::CompactTileSheet>, 32> m_tilesheets; ox::Vector<keel::AssetRef<ngfx::CompactTileSheet>, 32> m_tilesheets;
ox::Vector<ObjState, 128> m_objStates; ox::Vector<ObjState, 128> m_objStates;
turbine::TimeMs m_currentTicks{}; turbine::TimeMs m_currentTicks{};
public: public:
explicit World(ncore::Context &nctx, WorldStatic const&worldStatic) noexcept; explicit World(ngfx::Context &nctx, WorldStatic const&worldStatic) noexcept;
ox::Error setupDisplay() noexcept; ox::Error setupDisplay() noexcept;

View File

@ -10,20 +10,20 @@
#include <ox/std/types.hpp> #include <ox/std/types.hpp>
#include <ox/std/vector.hpp> #include <ox/std/vector.hpp>
#include <nostalgia/core/tilesheet.hpp> #include <nostalgia/gfx/tilesheet.hpp>
#include "worldobject.hpp" #include "worldobject.hpp"
namespace jasper::world { namespace jasper::world {
namespace ncore = nostalgia::core; namespace ngfx = nostalgia::gfx;
struct SpriteDoc { struct SpriteDoc {
constexpr static auto TypeName = "net.drinkingtea.jasper.world.SpriteDoc"; constexpr static auto TypeName = "net.drinkingtea.jasper.world.SpriteDoc";
constexpr static auto TypeVersion = 1; constexpr static auto TypeVersion = 1;
constexpr static auto Preloadable = true; constexpr static auto Preloadable = true;
ox::String tilesheetPath; ox::String tilesheetPath;
ox::Vector<ncore::SubSheetId> subsheetId; ox::Vector<ngfx::SubSheetId> subsheetId;
}; };
struct DocObjRef { struct DocObjRef {

View File

@ -6,12 +6,12 @@
#include <ox/std/array.hpp> #include <ox/std/array.hpp>
#include <nostalgia/core/context.hpp> #include <nostalgia/gfx/context.hpp>
#include <nostalgia/core/tilesheet.hpp> #include <nostalgia/gfx/tilesheet.hpp>
namespace jasper::world { namespace jasper::world {
namespace ncore = nostalgia::core; namespace ngfx = nostalgia::gfx;
using CollisionMap = uint32_t; using CollisionMap = uint32_t;
@ -31,7 +31,7 @@ struct WorldObject {
ox::String name; ox::String name;
uint16_t intervalMs{}; uint16_t intervalMs{};
uint8_t palBank{}; uint8_t palBank{};
ncore::SubSheetId subsheetId{}; ngfx::SubSheetId subsheetId{};
CollisionMap collisionMap{}; CollisionMap collisionMap{};
uint8_t frames{}; uint8_t frames{};
uint8_t objectType{}; uint8_t objectType{};

View File

@ -14,7 +14,7 @@
namespace jasper::world { namespace jasper::world {
namespace ncore = nostalgia::core; namespace ngfx = nostalgia::gfx;
constexpr void setTopEdge(uint8_t &layerAttachments, uint8_t const val) noexcept { constexpr void setTopEdge(uint8_t &layerAttachments, uint8_t const val) noexcept {
layerAttachments = static_cast<uint8_t>((layerAttachments & 0b11111100) | val); layerAttachments = static_cast<uint8_t>((layerAttachments & 0b11111100) | val);

View File

@ -2,7 +2,7 @@
* Copyright 2023 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. * Copyright 2023 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/ */
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include <keel/media.hpp> #include <keel/media.hpp>
#include "typeconv.hpp" #include "typeconv.hpp"

View File

@ -25,14 +25,14 @@ const glutils::ProgramSource MapTileHighlighter::s_programSrc = {
void main() { void main() {
gl_Position = vec4(vPosition, 0.0, 1.0); gl_Position = vec4(vPosition, 0.0, 1.0);
fSelection = vSelection; fSelection = vSelection;
})", ncore::gl::GlslVersion), })", ngfx::gl::GlslVersion),
.fragShader = ox::sfmt(R"( .fragShader = ox::sfmt(R"(
{} {}
in float fSelection; in float fSelection;
out vec4 outColor; out vec4 outColor;
void main() { void main() {
outColor = vec4(0.0, 0.7, 1.0, 0.4) * fSelection; outColor = vec4(0.0, 0.7, 1.0, 0.4) * fSelection;
})", ncore::gl::GlslVersion), })", ngfx::gl::GlslVersion),
}; };
MapTileHighlighter::MapTileHighlighter() { MapTileHighlighter::MapTileHighlighter() {
@ -97,8 +97,8 @@ void MapTileHighlighter::setPixelBufferObject(
bool const selected, bool const selected,
float *vbo, float *vbo,
GLuint *ebo) noexcept { GLuint *ebo) noexcept {
auto constexpr xmod = static_cast<float>(ncore::TileWidth) / 240.f * 4; auto constexpr xmod = static_cast<float>(ngfx::TileWidth) / 240.f * 4;
auto constexpr ymod = static_cast<float>(ncore::TileHeight) / 160.f * 4; auto constexpr ymod = static_cast<float>(ngfx::TileHeight) / 160.f * 4;
x *= xmod; x *= xmod;
y *= -ymod; y *= -ymod;
x -= 1.0f; x -= 1.0f;

View File

@ -7,13 +7,13 @@
#include <glutils/glutils.hpp> #include <glutils/glutils.hpp>
#include <studio/context.hpp> #include <studio/context.hpp>
#include <nostalgia/core/core.hpp> #include <nostalgia/gfx/core.hpp>
#include <jasper/world/worldobject.hpp> #include <jasper/world/worldobject.hpp>
namespace jasper::world { namespace jasper::world {
namespace ncore = nostalgia::core; namespace ngfx = nostalgia::gfx;
class MapTileHighlighter { class MapTileHighlighter {
private: private:

View File

@ -33,10 +33,10 @@ static class: public studio::Module {
ox::Vector<ox::UniquePtr<studio::ItemTemplate>> out; ox::Vector<ox::UniquePtr<studio::ItemTemplate>> out;
// Person TileSheet // Person TileSheet
{ {
ncore::TileSheetV4 ts; ngfx::TileSheetV4 ts;
ts.bpp = 4; ts.bpp = 4;
auto const addSheet = [&ts]( auto const addSheet = [&ts](
ncore::TileSheetV4::SubSheet &ss, ngfx::TileSheetV4::SubSheet &ss,
ox::StringParam name, ox::StringParam name,
int const cols, int const cols,
int const rows) -> auto& { int const rows) -> auto& {
@ -52,7 +52,7 @@ static class: public studio::Module {
addSheetSet("Back"); addSheetSet("Back");
addSheetSet("Left"); addSheetSet("Left");
addSheetSet("Right"); addSheetSet("Right");
out.emplace_back(ox::make<studio::ItemTemplateT<ncore::TileSheetV4>>( out.emplace_back(ox::make<studio::ItemTemplateT<ngfx::TileSheetV4>>(
"Jasper World Person", "Jasper World Person",
std::move(ts))); std::move(ts)));
} }

View File

@ -2,7 +2,7 @@
* Copyright 2023 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved. * Copyright 2023 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/ */
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include "worldeditorview.hpp" #include "worldeditorview.hpp"
@ -10,7 +10,7 @@ namespace jasper::world {
WorldEditorView::WorldEditorView(studio::StudioContext &sctx, WorldStatic const&worldStatic): WorldEditorView::WorldEditorView(studio::StudioContext &sctx, WorldStatic const&worldStatic):
m_sctx{sctx}, m_sctx{sctx},
m_nctx{ncore::init(m_sctx.tctx, {.glInstallDrawer = false}).unwrapThrow()}, m_nctx{ngfx::init(m_sctx.tctx, {.glInstallDrawer = false}).unwrapThrow()},
m_worldStatic{worldStatic}, m_worldStatic{worldStatic},
m_world{*m_nctx, m_worldStatic} {} m_world{*m_nctx, m_worldStatic} {}
@ -27,7 +27,7 @@ void WorldEditorView::setupTiles() noexcept {
} }
ox::Error WorldEditorView::setupWorld() noexcept { ox::Error WorldEditorView::setupWorld() noexcept {
glutils::resizeInitFrameBuffer(m_frameBuffer, ncore::gl::drawSize(m_scale)); glutils::resizeInitFrameBuffer(m_frameBuffer, ngfx::gl::drawSize(m_scale));
if (m_columns != m_worldStatic.columns || m_rows != m_worldStatic.rows) { if (m_columns != m_worldStatic.columns || m_rows != m_worldStatic.rows) {
OX_RETURN_ERROR(m_highlighter.setup({m_worldStatic.columns, m_worldStatic.rows})); OX_RETURN_ERROR(m_highlighter.setup({m_worldStatic.columns, m_worldStatic.rows}));
m_columns = m_worldStatic.columns; m_columns = m_worldStatic.columns;
@ -38,11 +38,11 @@ ox::Error WorldEditorView::setupWorld() noexcept {
} }
void WorldEditorView::draw(ox::Size const&targetSz) noexcept { void WorldEditorView::draw(ox::Size const&targetSz) noexcept {
auto const scaleSz = targetSz / ncore::gl::drawSize(1); auto const scaleSz = targetSz / ngfx::gl::drawSize(1);
if (m_scaleSz != scaleSz) [[unlikely]] { if (m_scaleSz != scaleSz) [[unlikely]] {
m_scale = ox::max(1, ox::max(scaleSz.width, scaleSz.height)); m_scale = ox::max(1, ox::max(scaleSz.width, scaleSz.height));
m_scaleSz = ncore::gl::drawSize(m_scale); m_scaleSz = ngfx::gl::drawSize(m_scale);
glutils::resizeInitFrameBuffer(m_frameBuffer, ncore::gl::drawSize(m_scale)); glutils::resizeInitFrameBuffer(m_frameBuffer, ngfx::gl::drawSize(m_scale));
} }
glutils::FrameBufferBind const frameBufferBind(m_frameBuffer); glutils::FrameBufferBind const frameBufferBind(m_frameBuffer);
if (m_animateWorld) { if (m_animateWorld) {
@ -51,7 +51,7 @@ void WorldEditorView::draw(ox::Size const&targetSz) noexcept {
turbine::setRefreshWithin(m_sctx.tctx, wakeUp.value); turbine::setRefreshWithin(m_sctx.tctx, wakeUp.value);
} }
} }
ncore::gl::draw(*m_nctx, m_scale); ngfx::gl::draw(*m_nctx, m_scale);
m_highlighter.draw(); m_highlighter.draw();
} }
@ -76,7 +76,7 @@ glutils::FrameBuffer const&WorldEditorView::framebuffer() const noexcept {
} }
ox::Size WorldEditorView::drawSize() const noexcept { ox::Size WorldEditorView::drawSize() const noexcept {
return ncore::gl::drawSize(m_scale); return ngfx::gl::drawSize(m_scale);
} }
} }

View File

@ -8,8 +8,8 @@
#include <studio/studio.hpp> #include <studio/studio.hpp>
#include <nostalgia/core/context.hpp> #include <nostalgia/gfx/context.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include <jasper/world/world.hpp> #include <jasper/world/world.hpp>
@ -17,19 +17,19 @@
namespace jasper::world { namespace jasper::world {
namespace ncore = nostalgia::core; namespace ngfx = nostalgia::gfx;
class WorldEditorView: public ox::SignalHandler { class WorldEditorView: public ox::SignalHandler {
private: private:
studio::StudioContext &m_sctx; studio::StudioContext &m_sctx;
ncore::ContextUPtr m_nctx; ngfx::ContextUPtr m_nctx;
WorldStatic const&m_worldStatic; WorldStatic const&m_worldStatic;
int m_columns{}, m_rows{}; int m_columns{}, m_rows{};
World m_world; World m_world;
glutils::FrameBuffer m_frameBuffer; glutils::FrameBuffer m_frameBuffer;
int m_scale = 1; int m_scale = 1;
ox::Size m_scaleSz = ncore::gl::drawSize(m_scale); ox::Size m_scaleSz = ngfx::gl::drawSize(m_scale);
ox::Optional<studio::Selection> m_selection; ox::Optional<studio::Selection> m_selection;
MapTileHighlighter m_highlighter; MapTileHighlighter m_highlighter;
bool m_animateWorld{}; bool m_animateWorld{};

View File

@ -12,7 +12,7 @@ CollisionMap mapIdx(auto x, auto y) noexcept {
} }
CollisionView::CollisionView(studio::StudioContext &sctx): CollisionView::CollisionView(studio::StudioContext &sctx):
m_nctx(ncore::init(sctx.tctx, { m_nctx(ngfx::init(sctx.tctx, {
.glInstallDrawer = false, .glInstallDrawer = false,
.glSpriteCount = 0, .glSpriteCount = 0,
}).unwrapThrow()), }).unwrapThrow()),
@ -29,9 +29,9 @@ ox::Error CollisionView::setup(
m_subsheetTilesWidth = w; m_subsheetTilesWidth = w;
m_subsheetTilesHeight = h; m_subsheetTilesHeight = h;
m_sheetTileStart = tile; m_sheetTileStart = tile;
ncore::setBgStatus(*m_nctx, 0, true); ngfx::setBgStatus(*m_nctx, 0, true);
OX_RETURN_ERROR(ncore::loadBgTileSheet(*m_nctx, 0, tsAddr)); OX_RETURN_ERROR(ngfx::loadBgTileSheet(*m_nctx, 0, tsAddr));
OX_RETURN_ERROR(ncore::loadBgPalette(*m_nctx, 0, palAddr)); OX_RETURN_ERROR(ngfx::loadBgPalette(*m_nctx, 0, palAddr));
OX_RETURN_ERROR(m_highlighter.setup({w / 2, h / 2})); OX_RETURN_ERROR(m_highlighter.setup({w / 2, h / 2}));
buildGlBuffers(colMap); buildGlBuffers(colMap);
return {}; return {};
@ -39,7 +39,7 @@ ox::Error CollisionView::setup(
void CollisionView::draw() noexcept { void CollisionView::draw() noexcept {
glutils::FrameBufferBind const frameBufferBind(m_frameBuffer); glutils::FrameBufferBind const frameBufferBind(m_frameBuffer);
ncore::gl::draw(*m_nctx, s_scale); ngfx::gl::draw(*m_nctx, s_scale);
m_highlighter.draw(); m_highlighter.draw();
} }
@ -67,7 +67,7 @@ void CollisionView::buildGlBuffers(CollisionMap colMap) noexcept {
auto tile = m_sheetTileStart; auto tile = m_sheetTileStart;
for (auto y = 0; y < m_subsheetTilesHeight; ++y) { for (auto y = 0; y < m_subsheetTilesHeight; ++y) {
for (auto x = 0; x < m_subsheetTilesWidth; ++x) { for (auto x = 0; x < m_subsheetTilesWidth; ++x) {
ncore::setBgTile(*m_nctx, 0, x, y, tile); ngfx::setBgTile(*m_nctx, 0, x, y, tile);
auto const collidable = (colMap >> mapIdx(x, y)) & 1; auto const collidable = (colMap >> mapIdx(x, y)) & 1;
std::ignore = m_highlighter.setTileHighlight({x, y}, collidable); std::ignore = m_highlighter.setTileHighlight({x, y}, collidable);
++tile; ++tile;

View File

@ -7,7 +7,7 @@
#include <glutils/glutils.hpp> #include <glutils/glutils.hpp>
#include <studio/context.hpp> #include <studio/context.hpp>
#include <nostalgia/core/core.hpp> #include <nostalgia/gfx/core.hpp>
#include <jasper/world/worldobject.hpp> #include <jasper/world/worldobject.hpp>
@ -15,12 +15,12 @@
namespace jasper::world { namespace jasper::world {
namespace ncore = nostalgia::core; namespace ngfx = nostalgia::gfx;
class CollisionView { class CollisionView {
private: private:
static constexpr int s_scale = 5; static constexpr int s_scale = 5;
ncore::ContextUPtr m_nctx; ngfx::ContextUPtr m_nctx;
glutils::FrameBuffer m_frameBuffer; glutils::FrameBuffer m_frameBuffer;
uint_t m_sheetTileStart{}; uint_t m_sheetTileStart{};
int m_subsheetTilesWidth{}; int m_subsheetTilesWidth{};

View File

@ -9,7 +9,7 @@ namespace jasper::world {
EditObjectSubSheet::EditObjectSubSheet( EditObjectSubSheet::EditObjectSubSheet(
WorldObjectSet &doc, WorldObjectSet &doc,
size_t const objIdx, size_t const objIdx,
ncore::SubSheetId const newSubSheet, ngfx::SubSheetId const newSubSheet,
uint8_t const newFrames) noexcept: uint8_t const newFrames) noexcept:
m_doc{doc}, m_doc{doc},
m_objIdx{objIdx}, m_objIdx{objIdx},

View File

@ -110,15 +110,15 @@ class EditObjectSubSheet: public studio::UndoCommand {
private: private:
WorldObjectSet &m_doc; WorldObjectSet &m_doc;
size_t const m_objIdx{}; size_t const m_objIdx{};
ncore::SubSheetId const m_oldSubSheet{}; ngfx::SubSheetId const m_oldSubSheet{};
ncore::SubSheetId m_newSubSheet{}; ngfx::SubSheetId m_newSubSheet{};
uint8_t const m_oldFrames{}; uint8_t const m_oldFrames{};
uint8_t m_newFrames{}; uint8_t m_newFrames{};
public: public:
EditObjectSubSheet( EditObjectSubSheet(
WorldObjectSet &doc, WorldObjectSet &doc,
size_t objIdx, size_t objIdx,
ncore::SubSheetId newSubSheet, ngfx::SubSheetId newSubSheet,
uint8_t newFrames) noexcept; uint8_t newFrames) noexcept;
ox::Error redo() noexcept override; ox::Error redo() noexcept override;

View File

@ -28,7 +28,7 @@ WorldObjectSetEditorImGui::WorldObjectSetEditorImGui(
m_sctx(ctx), m_sctx(ctx),
m_itemPath(itemPath()), m_itemPath(itemPath()),
m_doc(*readObj<WorldObjectSet>(keelCtx(m_sctx), itemPath()).unwrapThrow()), m_doc(*readObj<WorldObjectSet>(keelCtx(m_sctx), itemPath()).unwrapThrow()),
m_tileSheet(readObj<ncore::TileSheet>(keelCtx(m_sctx), m_doc.tilesheet).unwrapThrow()) { m_tileSheet(readObj<ngfx::TileSheet>(keelCtx(m_sctx), m_doc.tilesheet).unwrapThrow()) {
auto &kctx = keelCtx(m_sctx); auto &kctx = keelCtx(m_sctx);
auto const [tsPath, err] = getPath(kctx, m_doc.tilesheet); auto const [tsPath, err] = getPath(kctx, m_doc.tilesheet);
if (!err) { if (!err) {
@ -95,7 +95,7 @@ void WorldObjectSetEditorImGui::drawTileSheetSelector() noexcept {
ig::InputText("Tile Sheet", m_tilesheetPath, tsFlags); ig::InputText("Tile Sheet", m_tilesheetPath, tsFlags);
if (ig::DragDropTarget const d; d) { if (ig::DragDropTarget const d; d) {
auto const [fr, err] = ig::getDragDropPayload<studio::FileRef>("FileRef"); auto const [fr, err] = ig::getDragDropPayload<studio::FileRef>("FileRef");
if (!err && endsWith(fr.path, ncore::FileExt_ng)) { if (!err && endsWith(fr.path, ngfx::FileExt_ng)) {
std::ignore = setTileSheet(fr.path); std::ignore = setTileSheet(fr.path);
} }
} }
@ -215,8 +215,8 @@ void WorldObjectSetEditorImGui::drawObjEditor() noexcept {
auto const&fb = m_colView.framebuffer(); auto const&fb = m_colView.framebuffer();
uintptr_t const buffId = fb.color.id; uintptr_t const buffId = fb.color.id;
auto const scale = static_cast<float>(m_colView.scale()); auto const scale = static_cast<float>(m_colView.scale());
auto const width = static_cast<float>(m_visibleSubsheet->columns * ncore::TileWidth); auto const width = static_cast<float>(m_visibleSubsheet->columns * ngfx::TileWidth);
auto const height = static_cast<float>(m_visibleSubsheet->rows * ncore::TileHeight); auto const height = static_cast<float>(m_visibleSubsheet->rows * ngfx::TileHeight);
auto const horzPct = width / 240.f; auto const horzPct = width / 240.f;
auto const vertPct = height / 160.f; auto const vertPct = height / 160.f;
auto const imageSz = ImVec2{width * scale, height * scale}; auto const imageSz = ImVec2{width * scale, height * scale};
@ -238,7 +238,7 @@ void WorldObjectSetEditorImGui::drawObjEditor() noexcept {
} }
} }
void WorldObjectSetEditorImGui::drawSubSheetNode(ncore::TileSheet::SubSheet const&ss) noexcept { void WorldObjectSetEditorImGui::drawSubSheetNode(ngfx::TileSheet::SubSheet const&ss) noexcept {
auto constexpr dirFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick; auto constexpr dirFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick;
auto const&obj = activeObj(); auto const&obj = activeObj();
auto const selected = ss.id == obj.subsheetId ? ImGuiTreeNodeFlags_Selected : 0; auto const selected = ss.id == obj.subsheetId ? ImGuiTreeNodeFlags_Selected : 0;
@ -285,7 +285,7 @@ void WorldObjectSetEditorImGui::drawPaletteList() noexcept {
} }
if (ig::DragDropTarget const d; d) { if (ig::DragDropTarget const d; d) {
auto const [fr, err] = ig::getDragDropPayload<studio::FileRef>("FileRef"); auto const [fr, err] = ig::getDragDropPayload<studio::FileRef>("FileRef");
if (!err && endsWith(fr.path, ncore::FileExt_npal)) { if (!err && endsWith(fr.path, ngfx::FileExt_npal)) {
addPalette(fr.path); addPalette(fr.path);
} }
} }
@ -315,7 +315,7 @@ void WorldObjectSetEditorImGui::drawAddPalettePopup() noexcept {
auto constexpr popupSz = ImVec2{285.f, 0}; auto constexpr popupSz = ImVec2{285.f, 0};
ig::IDStackItem const idStackItem{"AddPalette"}; ig::IDStackItem const idStackItem{"AddPalette"};
if (ig::BeginPopup(m_sctx.tctx, popupName, m_addPalPopup.show, popupSz)) { if (ig::BeginPopup(m_sctx.tctx, popupName, m_addPalPopup.show, popupSz)) {
auto const&palettes = m_sctx.project->fileList(ncore::FileExt_npal); auto const&palettes = m_sctx.project->fileList(ngfx::FileExt_npal);
ig::ComboBox("Palette", palettes, m_addPalPopup.selectedIdx); ig::ComboBox("Palette", palettes, m_addPalPopup.selectedIdx);
if (ig::PopupControlsOkCancel(popupSz.x, m_addPalPopup.show) == ig::PopupResponse::OK) { if (ig::PopupControlsOkCancel(popupSz.x, m_addPalPopup.show) == ig::PopupResponse::OK) {
addPalette(palettes[m_addPalPopup.selectedIdx]); addPalette(palettes[m_addPalPopup.selectedIdx]);
@ -359,7 +359,7 @@ ox::Error WorldObjectSetEditorImGui::handleCmd(studio::UndoCommand const*cmd) no
if (dynamic_cast<ChangeTileSheet const*>(cmd)) { if (dynamic_cast<ChangeTileSheet const*>(cmd)) {
auto &kctx = keelCtx(m_sctx.tctx); auto &kctx = keelCtx(m_sctx.tctx);
std::ignore = m_tileSheet.updated.disconnectObject(this); std::ignore = m_tileSheet.updated.disconnectObject(this);
oxLogError(readObj<ncore::TileSheet>(kctx, m_doc.tilesheet).moveTo(m_tileSheet)); oxLogError(readObj<ngfx::TileSheet>(kctx, m_doc.tilesheet).moveTo(m_tileSheet));
m_tileSheet.updated.connect(this, &WorldObjectSetEditorImGui::loadObj); m_tileSheet.updated.connect(this, &WorldObjectSetEditorImGui::loadObj);
} else if ( } else if (
dynamic_cast<AddPalette const*>(cmd) || dynamic_cast<AddPalette const*>(cmd) ||

View File

@ -18,8 +18,8 @@ class WorldObjectSetEditorImGui: public studio::Editor {
studio::StudioContext &m_sctx; studio::StudioContext &m_sctx;
ox::String m_itemPath; ox::String m_itemPath;
WorldObjectSet m_doc; WorldObjectSet m_doc;
keel::AssetRef<ncore::TileSheet> m_tileSheet; keel::AssetRef<ngfx::TileSheet> m_tileSheet;
ncore::TileSheet::SubSheet const*m_visibleSubsheet = nullptr; ngfx::TileSheet::SubSheet const*m_visibleSubsheet = nullptr;
ox::Vector<ox::String> m_paletteDisplayNames; ox::Vector<ox::String> m_paletteDisplayNames;
size_t m_selectedObj{}; size_t m_selectedObj{};
size_t m_selectedPal{}; size_t m_selectedPal{};
@ -58,7 +58,7 @@ class WorldObjectSetEditorImGui: public studio::Editor {
void drawObjEditor() noexcept; void drawObjEditor() noexcept;
void drawSubSheetNode(ncore::TileSheet::SubSheet const&ss) noexcept; void drawSubSheetNode(ngfx::TileSheet::SubSheet const&ss) noexcept;
void drawPaletteList() noexcept; void drawPaletteList() noexcept;

View File

@ -4,7 +4,7 @@
#include <keel/keel.hpp> #include <keel/keel.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include <jasper/world/world.hpp> #include <jasper/world/world.hpp>
@ -15,7 +15,7 @@ static bool isUpdatingObj(ObjTileRefSet const&obj) noexcept {
return obj.frames > 1; return obj.frames > 1;
} }
World::World(ncore::Context &nctx, WorldStatic const&worldStatic) noexcept: World::World(ngfx::Context &nctx, WorldStatic const&worldStatic) noexcept:
m_nctx(nctx), m_nctx(nctx),
m_worldStatic(worldStatic) {} m_worldStatic(worldStatic) {}
@ -38,17 +38,17 @@ ox::Error World::setupDisplay() noexcept {
if (m_tilesheets.empty()) { if (m_tilesheets.empty()) {
auto &kctx = keelCtx(m_nctx); auto &kctx = keelCtx(m_nctx);
for (auto const&tsAddr : m_worldStatic.tilesheets) { for (auto const&tsAddr : m_worldStatic.tilesheets) {
OX_REQUIRE_M(ts, keel::readObj<ncore::CompactTileSheet>(kctx, tsAddr)); OX_REQUIRE_M(ts, keel::readObj<ngfx::CompactTileSheet>(kctx, tsAddr));
m_tilesheets.emplace_back(std::move(ts)); m_tilesheets.emplace_back(std::move(ts));
} }
} }
for (auto i = 0u; auto const&palAddr : m_worldStatic.palettes) { for (auto i = 0u; auto const&palAddr : m_worldStatic.palettes) {
OX_RETURN_ERROR(ncore::loadBgPalette(m_nctx, i, palAddr)); OX_RETURN_ERROR(ngfx::loadBgPalette(m_nctx, i, palAddr));
++i; ++i;
} }
for (size_t i = 1; i < m_worldStatic.objTileRefSets.size(); ++i) { for (size_t i = 1; i < m_worldStatic.objTileRefSets.size(); ++i) {
auto const&rs = m_worldStatic.objTileRefSets[i]; auto const&rs = m_worldStatic.objTileRefSets[i];
OX_RETURN_ERROR(ncore::loadBgTileSheet( OX_RETURN_ERROR(ngfx::loadBgTileSheet(
m_nctx, m_nctx,
rs.cbb, rs.cbb,
*m_tilesheets[rs.tilesheetId], *m_tilesheets[rs.tilesheetId],
@ -72,7 +72,7 @@ ox::Result<int> World::update() noexcept {
void World::setupTiles() noexcept { void World::setupTiles() noexcept {
m_currentTicks = ticksMs(turbineCtx(m_nctx)); m_currentTicks = ticksMs(turbineCtx(m_nctx));
ncore::setBgStatus(m_nctx, 0); // disable all backgrounds ngfx::setBgStatus(m_nctx, 0); // disable all backgrounds
for (auto layerNo = 0u; auto const&layer : m_worldStatic.map) { for (auto layerNo = 0u; auto const&layer : m_worldStatic.map) {
setupLayer(layerNo, layer.cbb); setupLayer(layerNo, layer.cbb);
++layerNo; ++layerNo;
@ -87,19 +87,19 @@ void World::setupTile(
auto const tx = static_cast<int>(x) * 2; auto const tx = static_cast<int>(x) * 2;
auto const ty = static_cast<int>(y) * 2; auto const ty = static_cast<int>(y) * 2;
auto const &obj = m_worldStatic.objTileRefSets[t.objIdxRefSet]; auto const &obj = m_worldStatic.objTileRefSets[t.objIdxRefSet];
ncore::setBgTile(m_nctx, lyr, tx + 0, ty + 0, { ngfx::setBgTile(m_nctx, lyr, tx + 0, ty + 0, {
.tileIdx = static_cast<uint_t>(obj.cbbIdx + 0), .tileIdx = static_cast<uint_t>(obj.cbbIdx + 0),
.palBank = obj.palBank, .palBank = obj.palBank,
}); });
ncore::setBgTile(m_nctx, lyr, tx + 1, ty + 0, { ngfx::setBgTile(m_nctx, lyr, tx + 1, ty + 0, {
.tileIdx = static_cast<uint_t>(obj.cbbIdx + 1), .tileIdx = static_cast<uint_t>(obj.cbbIdx + 1),
.palBank = obj.palBank, .palBank = obj.palBank,
}); });
ncore::setBgTile(m_nctx, lyr, tx + 0, ty + 1, { ngfx::setBgTile(m_nctx, lyr, tx + 0, ty + 1, {
.tileIdx = static_cast<uint_t>(obj.cbbIdx + 2), .tileIdx = static_cast<uint_t>(obj.cbbIdx + 2),
.palBank = obj.palBank, .palBank = obj.palBank,
}); });
ncore::setBgTile(m_nctx, lyr, tx + 1, ty + 1, { ngfx::setBgTile(m_nctx, lyr, tx + 1, ty + 1, {
.tileIdx = static_cast<uint_t>(obj.cbbIdx + 3), .tileIdx = static_cast<uint_t>(obj.cbbIdx + 3),
.palBank = obj.palBank, .palBank = obj.palBank,
}); });
@ -112,7 +112,7 @@ ox::Result<turbine::TimeMs> World::updateObj(ObjState &state) noexcept {
if (state.frame >= obj.frames) { if (state.frame >= obj.frames) {
state.frame = 0; state.frame = 0;
} }
OX_RETURN_ERROR(ncore::loadBgTileSheet( OX_RETURN_ERROR(ngfx::loadBgTileSheet(
m_nctx, m_nctx,
obj.cbb, obj.cbb,
*m_tilesheets[obj.tilesheetId], *m_tilesheets[obj.tilesheetId],
@ -127,11 +127,11 @@ ox::Result<turbine::TimeMs> World::updateObj(ObjState &state) noexcept {
void World::setupLayer( void World::setupLayer(
uint_t const lyr, uint_t const lyr,
uint_t const cbb) noexcept { uint_t const cbb) noexcept {
ncore::clearBg(m_nctx, lyr); ngfx::clearBg(m_nctx, lyr);
ncore::setBgStatus(m_nctx, lyr, true); ngfx::setBgStatus(m_nctx, lyr, true);
ncore::setBgCbb(m_nctx, lyr, cbb); ngfx::setBgCbb(m_nctx, lyr, cbb);
auto const rows = ox::min<int>(m_worldStatic.rows, ncore::tileRows(m_nctx) / 2); auto const rows = ox::min<int>(m_worldStatic.rows, ngfx::tileRows(m_nctx) / 2);
auto const columns = ox::min<int>(m_worldStatic.columns, ncore::tileColumns(m_nctx) / 2); auto const columns = ox::min<int>(m_worldStatic.columns, ngfx::tileColumns(m_nctx) / 2);
for (auto y = 0; y < rows; ++y) { for (auto y = 0; y < rows; ++y) {
for (auto x = 0; x < columns; ++x) { for (auto x = 0; x < columns; ++x) {
setupTile(lyr, static_cast<uint32_t>(x), static_cast<uint32_t>(y)); setupTile(lyr, static_cast<uint32_t>(x), static_cast<uint32_t>(y));

View File

@ -4,7 +4,7 @@
#include <keel/media.hpp> #include <keel/media.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/gfx/gfx.hpp>
#include <jasper/world/worldobject.hpp> #include <jasper/world/worldobject.hpp>
#include <jasper/world/worldstatic.hpp> #include <jasper/world/worldstatic.hpp>
@ -20,7 +20,7 @@ static void ensureInVec(ox::Vector<ox::FileAddress> &vec, ox::FileAddress const&
// If the root subsheet is not a leaf node, it will return the // If the root subsheet is not a leaf node, it will return the
// tile count of the first leaf node that it finds. // tile count of the first leaf node that it finds.
[[nodiscard]] [[nodiscard]]
static uint8_t subsheetTileCnt(ncore::TileSheet::SubSheet const&ss) noexcept { static uint8_t subsheetTileCnt(ngfx::TileSheet::SubSheet const&ss) noexcept {
if (ss.subsheets.empty()) { if (ss.subsheets.empty()) {
return static_cast<uint8_t>(ss.size()); return static_cast<uint8_t>(ss.size());
} }
@ -148,14 +148,14 @@ ox::Result<uint8_t> WorldStaticLoader::setupTileResrc(DocObjRef const&docObjRef)
if (obj == objSet->objects.end()) { if (obj == objSet->objects.end()) {
return ox::Error{obj == objSet->objects.end(), "could not find WorldObject in WorldObjectSet"}; return ox::Error{obj == objSet->objects.end(), "could not find WorldObject in WorldObjectSet"};
} }
OX_REQUIRE(ts, keel::readObj<ncore::TileSheet>(m_kctx, objSet->tilesheet)); OX_REQUIRE(ts, keel::readObj<ngfx::TileSheet>(m_kctx, objSet->tilesheet));
OX_REQUIRE(tsIdx, ox::findIdx( OX_REQUIRE(tsIdx, ox::findIdx(
m_worldStatic.tilesheets.begin(), m_worldStatic.tilesheets.end(), objSet->tilesheet).to<uint8_t>()); m_worldStatic.tilesheets.begin(), m_worldStatic.tilesheets.end(), objSet->tilesheet).to<uint8_t>());
auto const subsheetOffset = ncore::getTileIdx(*ts, obj->subsheetId); auto const subsheetOffset = ngfx::getTileIdx(*ts, obj->subsheetId);
if (!subsheetOffset) { if (!subsheetOffset) {
return ox::Error{1, "invalid subsheet idx"}; return ox::Error{1, "invalid subsheet idx"};
} }
auto const subsheet = ncore::getSubsheet(*ts, obj->subsheetId); auto const subsheet = ngfx::getSubsheet(*ts, obj->subsheetId);
if (!subsheet) { if (!subsheet) {
return ox::Error{1, "could not find subsheet"}; return ox::Error{1, "could not find subsheet"};
} }

View File

@ -8,12 +8,12 @@
#include <keel/keel.hpp> #include <keel/keel.hpp>
#include <turbine/turbine.hpp> #include <turbine/turbine.hpp>
#include <nostalgia/core/core.hpp> #include <nostalgia/gfx/core.hpp>
#include <jasper/core/bootfile.hpp> #include <jasper/core/bootfile.hpp>
#include <jasper/world/world.hpp> #include <jasper/world/world.hpp>
namespace ncore = nostalgia::core; namespace ngfx = nostalgia::gfx;
using namespace jasper; using namespace jasper;
@ -27,7 +27,7 @@ ox::Error run(
auto &kctx = keelCtx(*tctx); auto &kctx = keelCtx(*tctx);
OX_REQUIRE(bootfile, keel::readObj<jasper::core::Bootfile>(kctx, "/Bootfile")); OX_REQUIRE(bootfile, keel::readObj<jasper::core::Bootfile>(kctx, "/Bootfile"));
oxOut("Jasper Player\n"); oxOut("Jasper Player\n");
OX_REQUIRE(nctx, ncore::init(*tctx)); OX_REQUIRE(nctx, ngfx::init(*tctx));
auto const&worldPath = *bootfile->args.at(0).unwrap(); auto const&worldPath = *bootfile->args.at(0).unwrap();
OX_REQUIRE(worldStatic, readObj<world::WorldStatic>(kctx, worldPath)); OX_REQUIRE(worldStatic, readObj<world::WorldStatic>(kctx, worldPath));
world::World world(*nctx, *worldStatic); world::World world(*nctx, *worldStatic);