diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2680a930..1ef4f24b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,4 @@ include_directories(".") +add_subdirectory(keel) add_subdirectory(nostalgia) diff --git a/src/nostalgia/foundation/CMakeLists.txt b/src/keel/CMakeLists.txt similarity index 72% rename from src/nostalgia/foundation/CMakeLists.txt rename to src/keel/CMakeLists.txt index ac741983..e7ef53e9 100644 --- a/src/nostalgia/foundation/CMakeLists.txt +++ b/src/keel/CMakeLists.txt @@ -1,18 +1,20 @@ add_library( - NostalgiaFoundation + Keel asset.cpp media.cpp module.cpp + pack.cpp typeconv.cpp ) target_link_libraries( - NostalgiaFoundation PUBLIC + Keel PUBLIC OxClaw OxEvent OxFS OxModel + OxPreloader OxStd ) @@ -20,11 +22,12 @@ install( FILES assetmanager.hpp context.hpp - foundation.hpp + keel.hpp asset.hpp media.hpp module.hpp + pack.hpp typeconv.hpp DESTINATION - include/nostalgia/foundation + include/keel ) diff --git a/src/nostalgia/foundation/asset.cpp b/src/keel/asset.cpp similarity index 97% rename from src/nostalgia/foundation/asset.cpp rename to src/keel/asset.cpp index 1d743891..87ba8ab9 100644 --- a/src/nostalgia/foundation/asset.cpp +++ b/src/keel/asset.cpp @@ -4,7 +4,7 @@ #include "asset.hpp" -namespace nostalgia::foundation { +namespace keel { ox::Result readUuidHeader(const ox::Buffer &buff) noexcept { return readUuidHeader(buff.data(), buff.size()); diff --git a/src/nostalgia/foundation/asset.hpp b/src/keel/asset.hpp similarity index 97% rename from src/nostalgia/foundation/asset.hpp rename to src/keel/asset.hpp index df1be686..331f6640 100644 --- a/src/nostalgia/foundation/asset.hpp +++ b/src/keel/asset.hpp @@ -9,7 +9,7 @@ #include #include -namespace nostalgia::foundation { +namespace keel { constexpr auto N1HdrSz = 40; diff --git a/src/nostalgia/foundation/assetmanager.hpp b/src/keel/assetmanager.hpp similarity index 99% rename from src/nostalgia/foundation/assetmanager.hpp rename to src/keel/assetmanager.hpp index c27979a8..9683861c 100644 --- a/src/nostalgia/foundation/assetmanager.hpp +++ b/src/keel/assetmanager.hpp @@ -10,7 +10,7 @@ #include #include -namespace nostalgia::foundation { +namespace keel { class AssetManager; diff --git a/src/nostalgia/foundation/context.hpp b/src/keel/context.hpp similarity index 96% rename from src/nostalgia/foundation/context.hpp rename to src/keel/context.hpp index 40484491..3f4ce3b9 100644 --- a/src/nostalgia/foundation/context.hpp +++ b/src/keel/context.hpp @@ -10,7 +10,7 @@ #include "assetmanager.hpp" -namespace nostalgia::foundation { +namespace keel { class Context; using PackTransform = ox::Error(*)(Context*, ox::Buffer *clawData); diff --git a/src/nostalgia/foundation/foundation.hpp b/src/keel/keel.hpp similarity index 90% rename from src/nostalgia/foundation/foundation.hpp rename to src/keel/keel.hpp index ce0ebde9..2cb36c5b 100644 --- a/src/nostalgia/foundation/foundation.hpp +++ b/src/keel/keel.hpp @@ -9,10 +9,11 @@ #include "context.hpp" #include "media.hpp" #include "module.hpp" +#include "pack.hpp" -namespace nostalgia::foundation { +namespace keel { -template +template ox::Result> init(ox::UPtr &&fs, ox::CRStringView appName) noexcept { auto ctx = ox::make_unique(); ctx->appName = appName; diff --git a/src/nostalgia/foundation/media.cpp b/src/keel/media.cpp similarity index 92% rename from src/nostalgia/foundation/media.cpp rename to src/keel/media.cpp index c277a581..a2654a7d 100644 --- a/src/nostalgia/foundation/media.cpp +++ b/src/keel/media.cpp @@ -10,9 +10,9 @@ #include -#include +#include "media.hpp" -namespace nostalgia::foundation { +namespace keel { ox::Result loadRom(ox::CRStringView path) noexcept { std::ifstream file(std::string(toStdStringView(path)), std::ios::binary | std::ios::ate); @@ -85,7 +85,7 @@ ox::Error buildUuidMap(Context *ctx) noexcept { #define MEM_ROM reinterpret_cast(0x0800'0000) -namespace nostalgia::foundation { +namespace keel { static void clearUuidMap(Context*) noexcept { } @@ -114,7 +114,7 @@ ox::Result loadRom(ox::CRStringView) noexcept { void unloadRom(char*) noexcept { } -ox::Result getPreloadAddr(foundation::Context *ctx, ox::CRStringView path) noexcept { +ox::Result getPreloadAddr(keel::Context *ctx, ox::CRStringView path) noexcept { oxRequire(stat, ctx->rom->stat(path)); oxRequire(buff, static_cast(ctx->rom.get())->directAccess(path)); PreloadPtr p; @@ -122,7 +122,7 @@ ox::Result getPreloadAddr(foundation::Context *ctx, ox::CRStringVie return p.preloadAddr + ctx->preloadSectionOffset; } -ox::Result getPreloadAddr(foundation::Context *ctx, const ox::FileAddress &file) noexcept { +ox::Result getPreloadAddr(keel::Context *ctx, const ox::FileAddress &file) noexcept { oxRequire(stat, ctx->rom->stat(file)); oxRequire(buff, static_cast(ctx->rom.get())->directAccess(file)); PreloadPtr p; @@ -134,7 +134,7 @@ ox::Result getPreloadAddr(foundation::Context *ctx, const ox::FileA #endif -namespace nostalgia::foundation { +namespace keel { ox::Error setRomFs(Context *ctx, ox::UPtr fs) noexcept { ctx->rom = std::move(fs); diff --git a/src/nostalgia/foundation/media.hpp b/src/keel/media.hpp similarity index 81% rename from src/nostalgia/foundation/media.hpp rename to src/keel/media.hpp index 1f0506ce..07e638df 100644 --- a/src/nostalgia/foundation/media.hpp +++ b/src/keel/media.hpp @@ -15,7 +15,7 @@ #include "context.hpp" #include "typeconv.hpp" -namespace nostalgia::foundation { +namespace keel { // Pointer to preloaded data that can be stored in FS in place of the actual // data. @@ -29,14 +29,14 @@ oxModelBegin(PreloadPtr) oxModelField(preloadAddr) oxModelEnd() -ox::Result getPreloadAddr(foundation::Context *ctx, const ox::FileAddress &file) noexcept; -ox::Result getPreloadAddr(foundation::Context *ctx, ox::CRStringView file) noexcept; +ox::Result getPreloadAddr(keel::Context *ctx, const ox::FileAddress &file) noexcept; +ox::Result getPreloadAddr(keel::Context *ctx, ox::CRStringView file) noexcept; #ifndef OX_BARE_METAL template -ox::Result> readObjFile( - foundation::Context *ctx, +ox::Result> readObjFile( + keel::Context *ctx, ox::StringView assetId, bool forceLoad) noexcept { constexpr auto readConvert = [](Context *ctx, const ox::Buffer &buff) -> ox::Result { @@ -78,12 +78,12 @@ ox::Result> readObjFile( #else template -ox::Result> readObjNoCache( - foundation::Context *ctx, +ox::Result> readObjNoCache( + keel::Context *ctx, ox::CRStringView assetId) noexcept { if constexpr(ox::preloadable::value) { oxRequire(addr, getPreloadAddr(ctx, assetId)); - return foundation::AssetRef(reinterpret_cast(addr)); + return keel::AssetRef(reinterpret_cast(addr)); } else { return OxError(1); } @@ -96,8 +96,8 @@ void createUuidMapping(Context *ctx, const ox::String &filePath, const ox::UUID ox::Error buildUuidMap(Context *ctx) noexcept; template -ox::Result> readObj( - [[maybe_unused]] foundation::Context *ctx, +ox::Result> readObj( + [[maybe_unused]] keel::Context *ctx, [[maybe_unused]] ox::CRStringView assetId, [[maybe_unused]] bool forceLoad = false) noexcept { #ifndef OX_BARE_METAL @@ -108,8 +108,8 @@ ox::Result> readObj( } template -ox::Result> readObj( - foundation::Context *ctx, +ox::Result> readObj( + keel::Context *ctx, const ox::FileAddress &file, [[maybe_unused]] bool forceLoad = false) noexcept { #ifndef OX_BARE_METAL @@ -118,7 +118,7 @@ ox::Result> readObj( #else if constexpr(ox::preloadable::value) { oxRequire(addr, getPreloadAddr(ctx, file)); - return foundation::AssetRef(reinterpret_cast(addr)); + return keel::AssetRef(reinterpret_cast(addr)); } else { return OxError(1); } @@ -127,7 +127,7 @@ ox::Result> readObj( template ox::Error writeObj( - foundation::Context *ctx, + keel::Context *ctx, const ox::FileAddress &file, const T &obj, ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept { diff --git a/src/nostalgia/foundation/module.cpp b/src/keel/module.cpp similarity index 80% rename from src/nostalgia/foundation/module.cpp rename to src/keel/module.cpp index 51157ee5..75aecb1f 100644 --- a/src/nostalgia/foundation/module.cpp +++ b/src/keel/module.cpp @@ -4,7 +4,7 @@ #include "module.hpp" -namespace nostalgia::foundation { +namespace keel { static ox::Vector mods; @@ -22,7 +22,7 @@ ox::Vector Module::types() const noexcept { return {}; } -ox::Vector Module::converters() const noexcept { +ox::Vector Module::converters() const noexcept { return {}; } diff --git a/src/nostalgia/foundation/module.hpp b/src/keel/module.hpp similarity index 83% rename from src/nostalgia/foundation/module.hpp rename to src/keel/module.hpp index ff8f559a..c8c2cb2f 100644 --- a/src/nostalgia/foundation/module.hpp +++ b/src/keel/module.hpp @@ -9,7 +9,7 @@ #include "typeconv.hpp" -namespace nostalgia::foundation { +namespace keel { using TypeDescGenerator = ox::Error(*)(ox::TypeStore*); @@ -30,7 +30,7 @@ class Module { [[nodiscard]] virtual ox::Vector types() const noexcept; [[nodiscard]] - virtual ox::Vector converters() const noexcept; + virtual ox::Vector converters() const noexcept; [[nodiscard]] virtual ox::Vector packTransforms() const noexcept; }; @@ -38,6 +38,6 @@ class Module { void registerModule(const Module *mod) noexcept; [[nodiscard]] -const ox::Vector &modules() noexcept; +const ox::Vector &modules() noexcept; } diff --git a/src/nostalgia/tools/pack/pack.cpp b/src/keel/pack.cpp similarity index 84% rename from src/nostalgia/tools/pack/pack.cpp rename to src/keel/pack.cpp index 7bf0c649..8b370070 100644 --- a/src/nostalgia/tools/pack/pack.cpp +++ b/src/keel/pack.cpp @@ -2,18 +2,20 @@ * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ +#ifndef OX_BARE_METAL + #include #include #include #include -#include +#include #include "pack.hpp" -namespace nostalgia { +namespace keel { -static ox::Error pathToInode(foundation::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept { +static ox::Error pathToInode(keel::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept { auto &o = *obj; auto type = static_cast(o["type"].get()); auto &data = o["data"].get(); @@ -38,10 +40,10 @@ static ox::Error pathToInode(foundation::Context *ctx, ox::FileSystem *dest, ox: return data.set(2, s.inode); } -static ox::Error transformFileAddressesObj(foundation::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept; -static ox::Error transformFileAddressesVec(foundation::Context *ctx, ox::FileSystem *dest, ox::ModelValueVector *v) noexcept; +static ox::Error transformFileAddressesObj(keel::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept; +static ox::Error transformFileAddressesVec(keel::Context *ctx, ox::FileSystem *dest, ox::ModelValueVector *v) noexcept; -static ox::Error transformFileAddresses(foundation::Context *ctx, ox::FileSystem *dest, ox::ModelValue *v) noexcept { +static ox::Error transformFileAddresses(keel::Context *ctx, ox::FileSystem *dest, ox::ModelValue *v) noexcept { if (v->type() == ox::ModelValue::Type::Object) { auto &obj = v->get(); return transformFileAddressesObj(ctx, dest, &obj); @@ -52,7 +54,7 @@ static ox::Error transformFileAddresses(foundation::Context *ctx, ox::FileSystem return {}; } -static ox::Error transformFileAddressesVec(foundation::Context *ctx, ox::FileSystem *dest, ox::ModelValueVector *v) noexcept { +static ox::Error transformFileAddressesVec(keel::Context *ctx, ox::FileSystem *dest, ox::ModelValueVector *v) noexcept { for (auto &f : *v) { oxReturnError(transformFileAddresses(ctx, dest, &f)); } @@ -63,7 +65,7 @@ static ox::Error transformFileAddressesVec(foundation::Context *ctx, ox::FileSys * Convert path references in Claw data to inodes to save space * @return error */ -static ox::Error transformFileAddressesObj(foundation::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept { +static ox::Error transformFileAddressesObj(keel::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept { if (obj->typeName() == "net.drinkingtea.ox.FileAddress" && obj->typeVersion() == 1) { return pathToInode(ctx, dest, obj); } @@ -74,7 +76,7 @@ static ox::Error transformFileAddressesObj(foundation::Context *ctx, ox::FileSys return {}; } -static ox::Error doTransformations(foundation::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView filePath) noexcept { +static ox::Error doTransformations(keel::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView filePath) noexcept { // load file oxRequire(s, dest->stat(filePath)); // do transformations @@ -83,7 +85,7 @@ static ox::Error doTransformations(foundation::Context *ctx, ox::TypeStore *ts, oxReturnError(tr(ctx, &buff)); } // transform FileAddresses - oxRequireM(obj, foundation::readAsset(ts, buff)); + oxRequireM(obj, keel::readAsset(ts, buff)); oxReturnError(transformFileAddressesObj(ctx, dest, &obj)); oxReturnError(ox::writeClaw(&obj).moveTo(&buff)); // write file to dest @@ -93,7 +95,7 @@ static ox::Error doTransformations(foundation::Context *ctx, ox::TypeStore *ts, // claw file transformations are broken out from copy because path to inode // transformations need to be done after the copy to the new FS is complete -static ox::Error transformClaw(foundation::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView path) noexcept { +static ox::Error transformClaw(keel::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView path) noexcept { // copy oxTracef("pack::transformClaw", "path: {}", path); oxRequire(fileList, dest->ls(path)); @@ -131,7 +133,7 @@ static ox::Error copy(ox::FileSystem *src, ox::FileSystem *dest, ox::CRStringVie oxRequire(fileList, src->ls(path)); for (const auto &name : fileList) { auto currentFile = ox::sfmt("{}{}", path, name); - if (currentFile == "/.nostalgia") { + if (beginsWith(name, ".")) { continue; } oxOutf("reading {}\n", currentFile); @@ -169,7 +171,7 @@ static ox::Error preloadObj( GbaPreloader *pl, ox::CRStringView path) noexcept { // load file oxRequireM(buff, romFs->read(path)); - oxRequireM(obj, foundation::readAsset(ts, buff)); + oxRequireM(obj, keel::readAsset(ts, buff)); if (obj.type()->preloadable) { oxOutf("preloading {}\n", path); // preload @@ -177,7 +179,7 @@ static ox::Error preloadObj( const auto err = ox::preload(pl, &obj); oxReturnError(pl->endAlloc()); oxReturnError(err); - const foundation::PreloadPtr p{.preloadAddr = static_cast(a)}; + const keel::PreloadPtr p{.preloadAddr = static_cast(a)}; oxReturnError(ox::writeMC(&p).moveTo(&buff)); } else { // strip the Claw header (it is not needed after preloading) and write back out to dest fs @@ -228,7 +230,7 @@ ox::Error appendBinary(ox::Buffer *binBuff, ox::Buffer *fsBuff, GbaPreloader *pl return {}; } -ox::Error pack(foundation::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest) noexcept { +ox::Error pack(keel::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest) noexcept { oxReturnError(copyFS(ctx->rom.get(), dest)); oxOut("Doing transforms\n"); oxReturnError(transformClaw(ctx, ts, dest, "/")); @@ -241,3 +243,5 @@ ox::Error preload(ox::TypeStore *ts, ox::FileSystem *src, GbaPreloader *pl) noex } } + +#endif diff --git a/src/nostalgia/tools/pack/pack.hpp b/src/keel/pack.hpp similarity index 86% rename from src/nostalgia/tools/pack/pack.hpp rename to src/keel/pack.hpp index dd0031d7..2369622f 100644 --- a/src/nostalgia/tools/pack/pack.hpp +++ b/src/keel/pack.hpp @@ -2,15 +2,17 @@ * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ +#pragma once + #include #include -namespace nostalgia { - -namespace foundation { +namespace keel { class Context; } +namespace keel { + struct GbaPlatSpec { using PtrType = uint32_t; using size_t = uint32_t; @@ -78,8 +80,8 @@ using GbaPreloader = ox::Preloader; ox::Error appendBinary(ox::Buffer *binBuff, ox::Buffer *fsBuff, GbaPreloader *pl) noexcept; -auto pack(foundation::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest) noexcept -> ox::Error; +ox::Error pack(keel::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest) noexcept; -auto preload(ox::TypeStore *ts, ox::FileSystem *src, GbaPreloader *ph) noexcept -> ox::Error; +ox::Error preload(ox::TypeStore *ts, ox::FileSystem *src, GbaPreloader *ph) noexcept; } diff --git a/src/nostalgia/foundation/typeconv.cpp b/src/keel/typeconv.cpp similarity index 92% rename from src/nostalgia/foundation/typeconv.cpp rename to src/keel/typeconv.cpp index f3abdb65..a4e2b44e 100644 --- a/src/nostalgia/foundation/typeconv.cpp +++ b/src/keel/typeconv.cpp @@ -7,13 +7,13 @@ #include "media.hpp" #include "typeconv.hpp" -namespace nostalgia::foundation { +namespace keel { #ifndef OX_BARE_METAL [[nodiscard]] static ox::Result findConverter( - foundation::Context *ctx, + keel::Context *ctx, ox::CRStringView srcTypeName, int srcTypeVersion, ox::CRStringView dstTypeName, int dstTypeVersion) noexcept { for (auto &c : ctx->converters) { @@ -25,7 +25,7 @@ static ox::Result findConverter( }; static ox::Result> convert( - foundation::Context *ctx, const ox::Buffer &srcBuffer, + keel::Context *ctx, const ox::Buffer &srcBuffer, ox::CRStringView srcTypeName, int srcTypeVersion, ox::CRStringView dstTypeName, int dstTypeVersion) noexcept { // look for direct converter @@ -49,7 +49,7 @@ static ox::Result> convert( } ox::Result> convert( - foundation::Context *ctx, + keel::Context *ctx, const ox::Buffer &srcBuffer, ox::CRStringView dstTypeName, int dstTypeVersion) noexcept { diff --git a/src/nostalgia/foundation/typeconv.hpp b/src/keel/typeconv.hpp similarity index 80% rename from src/nostalgia/foundation/typeconv.hpp rename to src/keel/typeconv.hpp index 2ed38139..6cc70d0a 100644 --- a/src/nostalgia/foundation/typeconv.hpp +++ b/src/keel/typeconv.hpp @@ -13,7 +13,7 @@ #include "context.hpp" #include "media.hpp" -namespace nostalgia::foundation { +namespace keel { class Wrap { public: @@ -87,9 +87,9 @@ class BaseConverter { [[nodiscard]] virtual bool dstMatches(ox::CRStringView dstTypeName, int dstTypeVersion) const noexcept = 0; - virtual ox::Result> convertPtrToPtr(foundation::Context *ctx, Wrap *src) const noexcept = 0; + virtual ox::Result> convertPtrToPtr(keel::Context *ctx, Wrap *src) const noexcept = 0; - virtual ox::Result> convertBuffToPtr(foundation::Context *ctx, const ox::Buffer &srcBuff) const noexcept = 0; + virtual ox::Result> convertBuffToPtr(keel::Context *ctx, const ox::Buffer &srcBuff) const noexcept = 0; [[nodiscard]] inline bool matches(ox::CRStringView srcTypeName, int srcTypeVersion, @@ -129,13 +129,13 @@ class Converter: public BaseConverter { && dstTypeVersion == DstTypeVersion; } - ox::Result> convertPtrToPtr(foundation::Context *ctx, Wrap *src) const noexcept final { + ox::Result> convertPtrToPtr(keel::Context *ctx, Wrap *src) const noexcept final { auto dst = makeWrap(); oxReturnError(convert(ctx, wrapCast(src), wrapCast(dst.get()))); return ox::Result>(std::move(dst)); } - ox::Result> convertBuffToPtr(foundation::Context *ctx, const ox::Buffer &srcBuff) const noexcept final { + ox::Result> convertBuffToPtr(keel::Context *ctx, const ox::Buffer &srcBuff) const noexcept final { oxRequireM(src, readAsset(srcBuff)); auto dst = makeWrap(); oxReturnError(convert(ctx, &src, wrapCast(dst.get()))); @@ -143,15 +143,15 @@ class Converter: public BaseConverter { } protected: - virtual ox::Error convert(foundation::Context *ctx, SrcType*, DstType*) const noexcept = 0; + virtual ox::Error convert(keel::Context *ctx, SrcType*, DstType*) const noexcept = 0; }; -ox::Result> convert(foundation::Context *ctx, const ox::Buffer &srcBuffer, +ox::Result> convert(keel::Context *ctx, const ox::Buffer &srcBuffer, ox::CRStringView dstTypeName, int dstTypeVersion) noexcept; template -ox::Result convert(foundation::Context *ctx, const ox::Buffer &srcBuffer) noexcept { +ox::Result convert(keel::Context *ctx, const ox::Buffer &srcBuffer) noexcept { static constexpr auto DstTypeName = ox::requireModelTypeName(); static constexpr auto DstTypeVersion = ox::requireModelTypeVersion(); oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion)); @@ -159,7 +159,7 @@ ox::Result convert(foundation::Context *ctx, const ox::Buffer &srcBuffe } template -ox::Error convert(foundation::Context *ctx, const ox::Buffer &buff, DstType *outObj) noexcept { +ox::Error convert(keel::Context *ctx, const ox::Buffer &buff, DstType *outObj) noexcept { static constexpr auto DstTypeName = ox::requireModelTypeName(); static constexpr auto DstTypeVersion = ox::requireModelTypeVersion(); oxRequire(outPtr, convert(ctx, buff, DstTypeName, DstTypeVersion)); @@ -168,7 +168,7 @@ ox::Error convert(foundation::Context *ctx, const ox::Buffer &buff, DstType *out } template -ox::Result convertBuffToBuff(foundation::Context *ctx, const ox::Buffer &srcBuffer, ox::ClawFormat fmt) noexcept { +ox::Result convertBuffToBuff(keel::Context *ctx, const ox::Buffer &srcBuffer, ox::ClawFormat fmt) noexcept { static constexpr auto DstTypeName = ox::requireModelTypeName(); static constexpr auto DstTypeVersion = ox::requireModelTypeVersion(); oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion)); @@ -176,12 +176,12 @@ ox::Result convertBuffToBuff(foundation::Context *ctx, const ox::Buf } template -auto transformRule(foundation::Context *ctx, ox::Buffer *buff) noexcept -> ox::Error { +auto transformRule(keel::Context *ctx, ox::Buffer *buff) noexcept -> ox::Error { oxRequire(hdr, readAssetHeader(*buff)); const auto typeId = ox::buildTypeId( hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams); if (typeId == ox::buildTypeId()) { - oxReturnError(foundation::convertBuffToBuff(ctx, *buff, fmt).moveTo(buff)); + oxReturnError(keel::convertBuffToBuff(ctx, *buff, fmt).moveTo(buff)); } return {}; }; diff --git a/src/nostalgia/CMakeLists.txt b/src/nostalgia/CMakeLists.txt index 7683b90b..f57f5442 100644 --- a/src/nostalgia/CMakeLists.txt +++ b/src/nostalgia/CMakeLists.txt @@ -3,7 +3,6 @@ add_subdirectory(appmodules) add_subdirectory(core) -add_subdirectory(foundation) add_subdirectory(geo) add_subdirectory(scene) diff --git a/src/nostalgia/appmodules/CMakeLists.txt b/src/nostalgia/appmodules/CMakeLists.txt index 7201886a..9e75f1e4 100644 --- a/src/nostalgia/appmodules/CMakeLists.txt +++ b/src/nostalgia/appmodules/CMakeLists.txt @@ -10,7 +10,7 @@ endif() target_link_libraries( NostalgiaAppModules PUBLIC NostalgiaCore - NostalgiaFoundation + Keel NostalgiaScene ) diff --git a/src/nostalgia/appmodules/appmodules.cpp b/src/nostalgia/appmodules/appmodules.cpp index b5efeabd..cac111f5 100644 --- a/src/nostalgia/appmodules/appmodules.cpp +++ b/src/nostalgia/appmodules/appmodules.cpp @@ -2,7 +2,7 @@ * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ -#include +#include #include #include @@ -14,8 +14,8 @@ void loadModules() noexcept { if (modulesLoaded) { return; } - foundation::registerModule(core::module()); - foundation::registerModule(scene::module()); + keel::registerModule(core::module()); + keel::registerModule(scene::module()); modulesLoaded = true; } diff --git a/src/nostalgia/core/CMakeLists.txt b/src/nostalgia/core/CMakeLists.txt index 24f685c3..180be104 100644 --- a/src/nostalgia/core/CMakeLists.txt +++ b/src/nostalgia/core/CMakeLists.txt @@ -51,7 +51,7 @@ endif() target_link_libraries( NostalgiaCore-Common PUBLIC - NostalgiaFoundation + Keel ) target_link_libraries( diff --git a/src/nostalgia/core/context.hpp b/src/nostalgia/core/context.hpp index acd32253..8ca59e81 100644 --- a/src/nostalgia/core/context.hpp +++ b/src/nostalgia/core/context.hpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include "event.hpp" @@ -59,7 +59,7 @@ struct BgCbbData { }; // User Input Output -class Context: public foundation::Context { +class Context: public keel::Context { friend constexpr void setApplicationData(Context *ctx, void *applicationData) noexcept; template friend constexpr T *applicationData(Context *ctx) noexcept; diff --git a/src/nostalgia/core/gba/gfx.cpp b/src/nostalgia/core/gba/gfx.cpp index 767e6ae2..abc56ea4 100644 --- a/src/nostalgia/core/gba/gfx.cpp +++ b/src/nostalgia/core/gba/gfx.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include @@ -130,7 +130,7 @@ ox::Error initConsole(Context *ctx) noexcept { setBgStatus(ctx, 0b0001); if (!ctx) { ctx = new (ox_alloca(sizeof(Context))) Context(); - oxRequire(rom, foundation::loadRom()); + oxRequire(rom, keel::loadRom()); ox::FileStore32 fs(rom, 32 * ox::units::MB); auto romFs = new (ox_alloca(sizeof(ox::FileSystem32))) ox::FileSystem32(fs); new (&ctx->rom) ox::UniquePtr(romFs); diff --git a/src/nostalgia/core/glfw/core.cpp b/src/nostalgia/core/glfw/core.cpp index c05de4c9..86c6b80c 100644 --- a/src/nostalgia/core/glfw/core.cpp +++ b/src/nostalgia/core/glfw/core.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include @@ -15,7 +15,7 @@ namespace nostalgia::core { ox::Result> init(ox::UPtr fs, ox::CRStringView appName) noexcept { - oxRequireM(ctx, foundation::init(std::move(fs), appName)); + oxRequireM(ctx, keel::init(std::move(fs), appName)); const auto id = ox::make(); ctx->setWindowerData(id); using namespace std::chrono; diff --git a/src/nostalgia/core/module.cpp b/src/nostalgia/core/module.cpp index 8b3e1a9b..a6bb768d 100644 --- a/src/nostalgia/core/module.cpp +++ b/src/nostalgia/core/module.cpp @@ -4,8 +4,8 @@ #include -#include -#include +#include +#include #include "gfx.hpp" #include "typeconv.hpp" @@ -14,7 +14,7 @@ namespace nostalgia::core { -class CoreModule: public foundation::Module { +class CoreModule: public keel::Module { private: NostalgiaPaletteToPaletteConverter nostalgiaPaletteToPaletteConverter; TileSheetV1ToTileSheetConverter nostalgiaGraphicToTileSheetConverter; @@ -24,31 +24,31 @@ class CoreModule: public foundation::Module { public: static CoreModule mod; [[nodiscard]] - ox::Vector types() const noexcept override; + ox::Vector types() const noexcept override; [[nodiscard]] - ox::Vector converters() const noexcept override; + ox::Vector converters() const noexcept override; [[nodiscard]] - ox::Vector packTransforms() const noexcept override; + ox::Vector packTransforms() const noexcept override; }; CoreModule CoreModule::mod; -const foundation::Module *module() noexcept { +const keel::Module *module() noexcept { return &CoreModule::mod; } -ox::Vector CoreModule::types() const noexcept { +ox::Vector CoreModule::types() const noexcept { return { - foundation::generateTypeDesc, - foundation::generateTypeDesc, - foundation::generateTypeDesc, - foundation::generateTypeDesc, - foundation::generateTypeDesc, - foundation::generateTypeDesc, + keel::generateTypeDesc, + keel::generateTypeDesc, + keel::generateTypeDesc, + keel::generateTypeDesc, + keel::generateTypeDesc, + keel::generateTypeDesc, }; } -ox::Vector CoreModule::converters() const noexcept { +ox::Vector CoreModule::converters() const noexcept { return { &nostalgiaPaletteToPaletteConverter, &nostalgiaGraphicToTileSheetConverter, @@ -57,16 +57,16 @@ ox::Vector CoreModule::converters() const noex }; } -ox::Vector CoreModule::packTransforms() const noexcept { +ox::Vector CoreModule::packTransforms() const noexcept { return { // convert tilesheets to CompactTileSheets - [](foundation::Context *ctx, ox::Buffer *buff) -> ox::Error { - oxRequire(hdr, foundation::readAssetHeader(*buff)); + [](keel::Context *ctx, ox::Buffer *buff) -> ox::Error { + oxRequire(hdr, keel::readAssetHeader(*buff)); const auto typeId = ox::buildTypeId(hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams); if (typeId == ox::buildTypeId() || typeId == ox::buildTypeId() || typeId == ox::buildTypeId()) { - oxReturnError(foundation::convertBuffToBuff( + oxReturnError(keel::convertBuffToBuff( ctx, *buff, ox::ClawFormat::Metal).moveTo(buff)); } return {}; diff --git a/src/nostalgia/core/module.hpp b/src/nostalgia/core/module.hpp index bd741bc3..447fefb4 100644 --- a/src/nostalgia/core/module.hpp +++ b/src/nostalgia/core/module.hpp @@ -4,10 +4,10 @@ #pragma once -#include +#include namespace nostalgia::core { -const foundation::Module *module() noexcept; +const keel::Module *module() noexcept; } diff --git a/src/nostalgia/core/opengl/gfx.cpp b/src/nostalgia/core/opengl/gfx.cpp index 759f4c7c..7e0c6555 100644 --- a/src/nostalgia/core/opengl/gfx.cpp +++ b/src/nostalgia/core/opengl/gfx.cpp @@ -3,7 +3,7 @@ */ #include -#include +#include #include "gfx.hpp" diff --git a/src/nostalgia/core/studio/paletteeditor-imgui.cpp b/src/nostalgia/core/studio/paletteeditor-imgui.cpp index f19026d4..d3430c7f 100644 --- a/src/nostalgia/core/studio/paletteeditor-imgui.cpp +++ b/src/nostalgia/core/studio/paletteeditor-imgui.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include "paletteeditor.hpp" @@ -19,7 +19,7 @@ ox::Result PaletteEditorImGui::make(Context *ctx, ox::CRStr out->m_itemPath = path; const auto lastSlash = std::find(out->m_itemPath.rbegin(), out->m_itemPath.rend(), '/').offset(); out->m_itemName = out->m_itemPath.substr(lastSlash + 1); - oxRequire(pal, foundation::readObj(out->m_ctx, ox::FileAddress(out->m_itemPath.c_str()))); + oxRequire(pal, keel::readObj(out->m_ctx, ox::FileAddress(out->m_itemPath.c_str()))); out->m_pal = *pal; return out.release(); } diff --git a/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp b/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp index 191b12f7..e477a79e 100644 --- a/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp +++ b/src/nostalgia/core/studio/tilesheeteditor-imgui.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include "tilesheeteditor-imgui.hpp" diff --git a/src/nostalgia/core/studio/tilesheeteditormodel.cpp b/src/nostalgia/core/studio/tilesheeteditormodel.cpp index 739d7c13..3192e3a7 100644 --- a/src/nostalgia/core/studio/tilesheeteditormodel.cpp +++ b/src/nostalgia/core/studio/tilesheeteditormodel.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include "tilesheeteditormodel.hpp" diff --git a/src/nostalgia/core/studio/tilesheeteditormodel.hpp b/src/nostalgia/core/studio/tilesheeteditormodel.hpp index 04f2db6f..1472cc71 100644 --- a/src/nostalgia/core/studio/tilesheeteditormodel.hpp +++ b/src/nostalgia/core/studio/tilesheeteditormodel.hpp @@ -23,7 +23,7 @@ class TileSheetEditorModel: public ox::SignalHandler { static const Palette s_defaultPalette; TileSheet m_img; TileSheet::SubSheetIdx m_activeSubsSheetIdx; - foundation::AssetRef m_pal; + keel::AssetRef m_pal; studio::UndoStack m_undoStack; class DrawCommand *m_ongoingDrawCommand = nullptr; bool m_updated = false; diff --git a/src/nostalgia/core/studio/tilesheeteditorview.cpp b/src/nostalgia/core/studio/tilesheeteditorview.cpp index e22ad785..b0134ed0 100644 --- a/src/nostalgia/core/studio/tilesheeteditorview.cpp +++ b/src/nostalgia/core/studio/tilesheeteditorview.cpp @@ -3,7 +3,7 @@ */ #include -#include +#include #include #include "tilesheeteditorview.hpp" diff --git a/src/nostalgia/core/typeconv.cpp b/src/nostalgia/core/typeconv.cpp index 461b0275..00aeb853 100644 --- a/src/nostalgia/core/typeconv.cpp +++ b/src/nostalgia/core/typeconv.cpp @@ -7,7 +7,7 @@ namespace nostalgia::core { ox::Error NostalgiaPaletteToPaletteConverter::convert( - foundation::Context*, + keel::Context*, NostalgiaPalette *src, Palette *dst) const noexcept { dst->colors = std::move(src->colors); @@ -15,7 +15,7 @@ ox::Error NostalgiaPaletteToPaletteConverter::convert( } ox::Error TileSheetV1ToTileSheetConverter::convert( - foundation::Context*, + keel::Context*, TileSheetV1 *src, TileSheet *dst) const noexcept { dst->bpp = src->bpp; @@ -28,7 +28,7 @@ ox::Error TileSheetV1ToTileSheetConverter::convert( } ox::Error TileSheetToCompactTileSheetConverter::convert( - foundation::Context*, + keel::Context*, TileSheet *src, CompactTileSheet *dst) const noexcept { dst->bpp = src->bpp; @@ -55,7 +55,7 @@ void TileSheetV2ToTileSheetConverter::convertSubsheet( } ox::Error TileSheetV2ToTileSheetConverter::convert( - foundation::Context*, + keel::Context*, TileSheetV2 *src, TileSheet *dst) const noexcept { dst->bpp = src->bpp; diff --git a/src/nostalgia/core/typeconv.hpp b/src/nostalgia/core/typeconv.hpp index 3c65f399..287e08fc 100644 --- a/src/nostalgia/core/typeconv.hpp +++ b/src/nostalgia/core/typeconv.hpp @@ -6,7 +6,7 @@ #include -#include +#include #include "context.hpp" #include "gfx.hpp" @@ -15,25 +15,25 @@ namespace nostalgia::core { // Type converters -class NostalgiaPaletteToPaletteConverter: public foundation::Converter { - ox::Error convert(foundation::Context*, NostalgiaPalette *src, Palette *dst) const noexcept final; +class NostalgiaPaletteToPaletteConverter: public keel::Converter { + ox::Error convert(keel::Context*, NostalgiaPalette *src, Palette *dst) const noexcept final; }; -class TileSheetV1ToTileSheetConverter: public foundation::Converter { - ox::Error convert(foundation::Context*, TileSheetV1 *src, TileSheet *dst) const noexcept final; +class TileSheetV1ToTileSheetConverter: public keel::Converter { + ox::Error convert(keel::Context*, TileSheetV1 *src, TileSheet *dst) const noexcept final; }; -class TileSheetToCompactTileSheetConverter: public foundation::Converter { - ox::Error convert(foundation::Context*, TileSheet *src, CompactTileSheet *dst) const noexcept final; +class TileSheetToCompactTileSheetConverter: public keel::Converter { + ox::Error convert(keel::Context*, TileSheet *src, CompactTileSheet *dst) const noexcept final; }; -class TileSheetV2ToTileSheetConverter: public foundation::Converter { +class TileSheetV2ToTileSheetConverter: public keel::Converter { static void convertSubsheet( TileSheetV2::SubSheet *src, TileSheet::SubSheet *dst, SubSheetId *idIt) noexcept; - ox::Error convert(foundation::Context*, TileSheetV2 *src, TileSheet *dst) const noexcept final; + ox::Error convert(keel::Context*, TileSheetV2 *src, TileSheet *dst) const noexcept final; }; diff --git a/src/nostalgia/player/app.cpp b/src/nostalgia/player/app.cpp index fa6a885f..e06a26c7 100644 --- a/src/nostalgia/player/app.cpp +++ b/src/nostalgia/player/app.cpp @@ -33,7 +33,7 @@ ox::Error run(ox::UniquePtr fs) noexcept { oxTraceInitHook(); oxRequireM(ctx, core::init(std::move(fs))); constexpr ox::FileAddress SceneAddr("/Scenes/Chester.nscn"); - oxRequire(scn, foundation::readObj(ctx.get(), SceneAddr)); + oxRequire(scn, keel::readObj(ctx.get(), SceneAddr)); core::setUpdateHandler(ctx.get(), updateHandler); core::setKeyEventHandler(ctx.get(), keyEventHandler); s_scene.emplace(*scn); diff --git a/src/nostalgia/player/main.cpp b/src/nostalgia/player/main.cpp index 2b47ed20..552c7bec 100644 --- a/src/nostalgia/player/main.cpp +++ b/src/nostalgia/player/main.cpp @@ -22,7 +22,7 @@ static ox::Error run(int argc, const char **argv) noexcept { return OxError(1); } const auto path = argv[1]; - oxRequireM(fs, nostalgia::foundation::loadRomFs(path)); + oxRequireM(fs, keel::loadRomFs(path)); return run(std::move(fs)); } diff --git a/src/nostalgia/scene/scenemodule.cpp b/src/nostalgia/scene/scenemodule.cpp index 62c41522..478b5f49 100644 --- a/src/nostalgia/scene/scenemodule.cpp +++ b/src/nostalgia/scene/scenemodule.cpp @@ -11,37 +11,37 @@ namespace nostalgia::scene { -class SceneModule: public foundation::Module { +class SceneModule: public keel::Module { private: SceneDocToSceneStaticConverter sceneDocToSceneStaticConverter; public: [[nodiscard]] - ox::Vector types() const noexcept override { + ox::Vector types() const noexcept override { return { - foundation::generateTypeDesc, - foundation::generateTypeDesc, + keel::generateTypeDesc, + keel::generateTypeDesc, }; } [[nodiscard]] - ox::Vector converters() const noexcept override { + ox::Vector converters() const noexcept override { return { &sceneDocToSceneStaticConverter, }; } [[nodiscard]] - ox::Vector packTransforms() const noexcept override { + ox::Vector packTransforms() const noexcept override { return { - foundation::transformRule, + keel::transformRule, }; } }; static SceneModule mod; -const foundation::Module *module() noexcept { +const keel::Module *module() noexcept { return &mod; } diff --git a/src/nostalgia/scene/scenemodule.hpp b/src/nostalgia/scene/scenemodule.hpp index 109b087b..397591cc 100644 --- a/src/nostalgia/scene/scenemodule.hpp +++ b/src/nostalgia/scene/scenemodule.hpp @@ -4,10 +4,10 @@ #pragma once -#include +#include namespace nostalgia::scene { -const foundation::Module *module() noexcept; +const keel::Module *module() noexcept; } diff --git a/src/nostalgia/scene/studio/sceneeditor-imgui.cpp b/src/nostalgia/scene/studio/sceneeditor-imgui.cpp index fb4e205f..2926d3be 100644 --- a/src/nostalgia/scene/studio/sceneeditor-imgui.cpp +++ b/src/nostalgia/scene/studio/sceneeditor-imgui.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include "sceneeditor-imgui.hpp" diff --git a/src/nostalgia/scene/studio/sceneeditor.cpp b/src/nostalgia/scene/studio/sceneeditor.cpp index b5a28bf4..e21f11bd 100644 --- a/src/nostalgia/scene/studio/sceneeditor.cpp +++ b/src/nostalgia/scene/studio/sceneeditor.cpp @@ -8,7 +8,7 @@ namespace nostalgia::scene { SceneEditor::SceneEditor(core::Context *ctx, ox::CRStringView path) { m_ctx = ctx; - oxRequireT(scn, foundation::readObj(m_ctx, path)); + oxRequireT(scn, keel::readObj(m_ctx, path)); m_scene = *scn; } diff --git a/src/nostalgia/scene/typeconv.cpp b/src/nostalgia/scene/typeconv.cpp index 15a059cd..d600d4ff 100644 --- a/src/nostalgia/scene/typeconv.cpp +++ b/src/nostalgia/scene/typeconv.cpp @@ -3,7 +3,7 @@ */ #include -#include +#include #include "typeconv.hpp" @@ -34,10 +34,10 @@ constexpr void setLayerAttachments(unsigned layer, const TileDoc &srcTile, Scene } ox::Error SceneDocToSceneStaticConverter::convert( - foundation::Context *ctx, + keel::Context *ctx, SceneDoc *src, SceneStatic *dst) const noexcept { - oxRequire(ts, foundation::readObj(ctx, src->tilesheet)); + oxRequire(ts, keel::readObj(ctx, src->tilesheet)); const auto layerCnt = src->tiles.size(); dst->setLayerCnt(layerCnt); dst->tilesheet = ox::FileAddress(src->tilesheet); diff --git a/src/nostalgia/scene/typeconv.hpp b/src/nostalgia/scene/typeconv.hpp index 5a8c60e2..5b0fb8ad 100644 --- a/src/nostalgia/scene/typeconv.hpp +++ b/src/nostalgia/scene/typeconv.hpp @@ -4,14 +4,14 @@ #pragma once -#include +#include #include "scenestatic.hpp" namespace nostalgia::scene { -class SceneDocToSceneStaticConverter: public foundation::Converter { - ox::Error convert(foundation::Context*, SceneDoc *src, SceneStatic *dst) const noexcept final; +class SceneDocToSceneStaticConverter: public keel::Converter { + ox::Error convert(keel::Context*, SceneDoc *src, SceneStatic *dst) const noexcept final; }; } diff --git a/src/nostalgia/studio/lib/configio.cpp b/src/nostalgia/studio/lib/configio.cpp index 1fa71f10..50554ee9 100644 --- a/src/nostalgia/studio/lib/configio.cpp +++ b/src/nostalgia/studio/lib/configio.cpp @@ -23,7 +23,7 @@ constexpr auto ConfigDir = [] { } }(); -ox::String configPath(const foundation::Context *ctx) noexcept { +ox::String configPath(const keel::Context *ctx) noexcept { const auto homeDir = std::getenv(ox::defines::OS == ox::OS::Windows ? "USERPROFILE" : "HOME"); return ox::sfmt(ConfigDir, homeDir, ctx->appName); } diff --git a/src/nostalgia/studio/lib/configio.hpp b/src/nostalgia/studio/lib/configio.hpp index 172643e4..9954dfb2 100644 --- a/src/nostalgia/studio/lib/configio.hpp +++ b/src/nostalgia/studio/lib/configio.hpp @@ -18,10 +18,10 @@ namespace nostalgia::studio { [[nodiscard]] -ox::String configPath(const foundation::Context *ctx) noexcept; +ox::String configPath(const keel::Context *ctx) noexcept; template -ox::Result readConfig(foundation::Context *ctx, ox::CRStringView name) noexcept { +ox::Result readConfig(keel::Context *ctx, ox::CRStringView name) noexcept { oxAssert(name != "", "Config type has no TypeName"); const auto path = ox::sfmt("/{}.json", name); ox::PassThroughFS fs(configPath(ctx)); @@ -34,13 +34,13 @@ ox::Result readConfig(foundation::Context *ctx, ox::CRStringView name) noexce } template -ox::Result readConfig(foundation::Context *ctx) noexcept { +ox::Result readConfig(keel::Context *ctx) noexcept { constexpr auto TypeName = ox::requireModelTypeName(); return readConfig(ctx, TypeName); } template -ox::Error writeConfig(foundation::Context *ctx, ox::CRStringView name, T *data) noexcept { +ox::Error writeConfig(keel::Context *ctx, ox::CRStringView name, T *data) noexcept { oxAssert(name != "", "Config type has no TypeName"); const auto path = ox::sfmt("/{}.json", name); ox::PassThroughFS fs(configPath(ctx)); @@ -58,13 +58,13 @@ ox::Error writeConfig(foundation::Context *ctx, ox::CRStringView name, T *data) } template -ox::Error writeConfig(foundation::Context *ctx, T *data) noexcept { +ox::Error writeConfig(keel::Context *ctx, T *data) noexcept { constexpr auto TypeName = ox::requireModelTypeName(); return writeConfig(ctx, TypeName, data); } template -void openConfig(foundation::Context *ctx, const auto &name, Func f) noexcept { +void openConfig(keel::Context *ctx, const auto &name, Func f) noexcept { oxAssert(name != "", "Config type has no TypeName"); const auto [c, err] = readConfig(ctx, name); oxLogError(err); @@ -72,13 +72,13 @@ void openConfig(foundation::Context *ctx, const auto &name, Func f) noexcept { } template -void openConfig(foundation::Context *ctx, Func f) noexcept { +void openConfig(keel::Context *ctx, Func f) noexcept { constexpr auto TypeName = ox::requireModelTypeName(); openConfig(ctx, TypeName, f); } template -void editConfig(foundation::Context *ctx, const auto &name, Func f) noexcept { +void editConfig(keel::Context *ctx, const auto &name, Func f) noexcept { oxAssert(ox_strcmp(name, ""), "Config type has no TypeName"); auto [c, err] = readConfig(ctx, name); oxLogError(err); @@ -87,7 +87,7 @@ void editConfig(foundation::Context *ctx, const auto &name, Func f) noexcept { } template -void editConfig(foundation::Context *ctx, Func f) noexcept { +void editConfig(keel::Context *ctx, Func f) noexcept { constexpr auto TypeName = ox::requireModelTypeName(); editConfig(ctx, TypeName, f); } diff --git a/src/nostalgia/studio/lib/itemmaker.hpp b/src/nostalgia/studio/lib/itemmaker.hpp index 0c56e9ff..6a7d74c9 100644 --- a/src/nostalgia/studio/lib/itemmaker.hpp +++ b/src/nostalgia/studio/lib/itemmaker.hpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include "context.hpp" @@ -50,7 +50,7 @@ class ItemMakerT: public ItemMaker { ox::Error write(core::Context *ctx, ox::CRStringView pName) const noexcept override { const auto path = ox::sfmt("/{}/{}.{}", parentDir, pName, fileExt); auto sctx = core::applicationData(ctx); - foundation::createUuidMapping(ctx, path, ox::UUID::generate().unwrap()); + keel::createUuidMapping(ctx, path, ox::UUID::generate().unwrap()); return sctx->project->writeObj(path, &item, fmt); } }; diff --git a/src/nostalgia/studio/lib/project.cpp b/src/nostalgia/studio/lib/project.cpp index cc67714a..d99919c3 100644 --- a/src/nostalgia/studio/lib/project.cpp +++ b/src/nostalgia/studio/lib/project.cpp @@ -7,21 +7,21 @@ #include -#include +#include #include "project.hpp" namespace nostalgia::studio { static void generateTypes(ox::TypeStore *ts) noexcept { - for (const auto mod : foundation::modules()) { + for (const auto mod : keel::modules()) { for (auto gen : mod->types()) { oxLogError(gen(ts)); } } } -Project::Project(foundation::Context *ctx, ox::String path) noexcept: +Project::Project(keel::Context *ctx, ox::String path) noexcept: m_path(std::move(path)), m_typeStore(ctx->rom.get()), m_fs(ctx->rom.get()), @@ -89,7 +89,7 @@ ox::Error Project::writeBuff(const ox::StringView &path, const ox::Buffer &buff) ox::BufferWriter writer(&outBuff); const auto [uuid, err] = m_ctx->pathToUuid.at(path); if (!err) { - oxReturnError(foundation::writeUuidHeader(&writer, *uuid)); + oxReturnError(keel::writeUuidHeader(&writer, *uuid)); } oxReturnError(writer.write(buff.data(), buff.size())); const auto newFile = m_fs->stat(path).error != 0; diff --git a/src/nostalgia/studio/lib/project.hpp b/src/nostalgia/studio/lib/project.hpp index c064c0b4..7fb157d3 100644 --- a/src/nostalgia/studio/lib/project.hpp +++ b/src/nostalgia/studio/lib/project.hpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include "nostalgiastudio_export.h" @@ -43,11 +43,11 @@ class NOSTALGIASTUDIO_EXPORT Project { ox::String m_path; mutable core::TypeStore m_typeStore; mutable ox::FileSystem *m_fs = nullptr; - foundation::Context *m_ctx = nullptr; + keel::Context *m_ctx = nullptr; ox::HashMap> m_fileExtFileMap; public: - explicit Project(foundation::Context *ctx, ox::String path) noexcept; + explicit Project(keel::Context *ctx, ox::String path) noexcept; ox::Error create() noexcept; @@ -131,9 +131,9 @@ template ox::Result Project::loadObj(const ox::String &path) const noexcept { oxRequire(buff, loadBuff(path)); if constexpr (ox::is_same_v) { - return foundation::readAsset(&m_typeStore, buff); + return keel::readAsset(&m_typeStore, buff); } else { - return foundation::readAsset(buff); + return keel::readAsset(buff); } } diff --git a/src/nostalgia/studio/main.cpp b/src/nostalgia/studio/main.cpp index e0f56b19..19b194dc 100644 --- a/src/nostalgia/studio/main.cpp +++ b/src/nostalgia/studio/main.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include "lib/context.hpp" #include "studioapp.hpp" diff --git a/src/nostalgia/studio/studioapp.cpp b/src/nostalgia/studio/studioapp.cpp index 476abaf4..2824a71e 100644 --- a/src/nostalgia/studio/studioapp.cpp +++ b/src/nostalgia/studio/studioapp.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include "lib/configio.hpp" #include "builtinmodules.hpp" @@ -290,8 +290,8 @@ void StudioUI::save() noexcept { } ox::Error StudioUI::openProject(ox::CRStringView path) noexcept { - oxRequireM(fs, foundation::loadRomFs(path)); - oxReturnError(foundation::setRomFs(m_ctx, std::move(fs))); + oxRequireM(fs, keel::loadRomFs(path)); + oxReturnError(keel::setRomFs(m_ctx, std::move(fs))); core::setWindowTitle(m_ctx, ox::sfmt("Nostalgia Studio - {}", path)); m_project = ox::make_unique(m_ctx, path); auto sctx = applicationData(m_ctx); diff --git a/src/nostalgia/tools/CMakeLists.txt b/src/nostalgia/tools/CMakeLists.txt index 0c30cf9d..7bca9bd6 100644 --- a/src/nostalgia/tools/CMakeLists.txt +++ b/src/nostalgia/tools/CMakeLists.txt @@ -4,7 +4,7 @@ target_link_libraries( nost-pack OxClArgs OxLogConn - NostalgiaPack + Keel NostalgiaAppModules ) @@ -19,6 +19,3 @@ install( RUNTIME DESTINATION bin ) - - -add_subdirectory(pack) diff --git a/src/nostalgia/tools/pack.cpp b/src/nostalgia/tools/pack.cpp index 417bd10b..41ea2b81 100644 --- a/src/nostalgia/tools/pack.cpp +++ b/src/nostalgia/tools/pack.cpp @@ -8,12 +8,9 @@ #include #include +#include #include #include -#include -#include - -#include "pack/pack.hpp" using namespace nostalgia; @@ -46,7 +43,7 @@ static ox::Result readFileBuff(ox::CRStringView path) noexcept { } static ox::Error generateTypes(ox::TypeStore *ts) noexcept { - for (const auto mod : foundation::modules()) { + for (const auto mod : keel::modules()) { for (auto gen : mod->types()) { oxReturnError(gen(ts)); } @@ -69,11 +66,11 @@ static ox::Error run(const ox::ClArgs &args) noexcept { ox::Buffer dstBuff(32 * ox::units::MB); oxReturnError(ox::FileSystem32::format(dstBuff.data(), dstBuff.size())); ox::FileSystem32 dst(ox::FileStore32(dstBuff.data(), dstBuff.size())); - oxRequire(ctx, foundation::init(ox::make_unique(argSrc), "nost-pack")); + oxRequire(ctx, keel::init(ox::make_unique(argSrc), "nost-pack")); core::TypeStore ts(ctx->rom.get()); oxReturnError(generateTypes(&ts)); - oxReturnError(pack(ctx.get(), &ts, &dst)); - oxRequireM(pl, GbaPreloader::make()); + oxReturnError(keel::pack(ctx.get(), &ts, &dst)); + oxRequireM(pl, keel::GbaPreloader::make()); oxReturnError(preload(&ts, &dst, pl.get())); oxReturnError(dst.resize()); // resize buffer diff --git a/src/nostalgia/tools/pack/CMakeLists.txt b/src/nostalgia/tools/pack/CMakeLists.txt deleted file mode 100644 index 9f36ec65..00000000 --- a/src/nostalgia/tools/pack/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ - -add_library( - NostalgiaPack - pack.cpp -) - -target_link_libraries( - NostalgiaPack PUBLIC - NostalgiaFoundation - OxPreloader -) - -install( - TARGETS - NostalgiaPack - ARCHIVE DESTINATION - lib/nostalgia -) - -install( - FILES - pack.hpp - DESTINATION - include/nostalgia/tools/pack -)