[keel] Split out Nostalgia Foundation and Pack lib into Keel

This commit is contained in:
Gary Talent 2023-03-24 21:20:55 -05:00
parent 4a95a79926
commit 7beb3cc6fc
50 changed files with 185 additions and 206 deletions

View File

@ -1,3 +1,4 @@
include_directories(".") include_directories(".")
add_subdirectory(keel)
add_subdirectory(nostalgia) add_subdirectory(nostalgia)

View File

@ -1,18 +1,20 @@
add_library( add_library(
NostalgiaFoundation Keel
asset.cpp asset.cpp
media.cpp media.cpp
module.cpp module.cpp
pack.cpp
typeconv.cpp typeconv.cpp
) )
target_link_libraries( target_link_libraries(
NostalgiaFoundation PUBLIC Keel PUBLIC
OxClaw OxClaw
OxEvent OxEvent
OxFS OxFS
OxModel OxModel
OxPreloader
OxStd OxStd
) )
@ -20,11 +22,12 @@ install(
FILES FILES
assetmanager.hpp assetmanager.hpp
context.hpp context.hpp
foundation.hpp keel.hpp
asset.hpp asset.hpp
media.hpp media.hpp
module.hpp module.hpp
pack.hpp
typeconv.hpp typeconv.hpp
DESTINATION DESTINATION
include/nostalgia/foundation include/keel
) )

View File

@ -4,7 +4,7 @@
#include "asset.hpp" #include "asset.hpp"
namespace nostalgia::foundation { namespace keel {
ox::Result<ox::UUID> readUuidHeader(const ox::Buffer &buff) noexcept { ox::Result<ox::UUID> readUuidHeader(const ox::Buffer &buff) noexcept {
return readUuidHeader(buff.data(), buff.size()); return readUuidHeader(buff.data(), buff.size());

View File

@ -9,7 +9,7 @@
#include <ox/claw/claw.hpp> #include <ox/claw/claw.hpp>
#include <ox/fs/fs.hpp> #include <ox/fs/fs.hpp>
namespace nostalgia::foundation { namespace keel {
constexpr auto N1HdrSz = 40; constexpr auto N1HdrSz = 40;

View File

@ -10,7 +10,7 @@
#include <ox/std/hashmap.hpp> #include <ox/std/hashmap.hpp>
#include <ox/std/utility.hpp> #include <ox/std/utility.hpp>
namespace nostalgia::foundation { namespace keel {
class AssetManager; class AssetManager;

View File

@ -10,7 +10,7 @@
#include "assetmanager.hpp" #include "assetmanager.hpp"
namespace nostalgia::foundation { namespace keel {
class Context; class Context;
using PackTransform = ox::Error(*)(Context*, ox::Buffer *clawData); using PackTransform = ox::Error(*)(Context*, ox::Buffer *clawData);

View File

@ -9,10 +9,11 @@
#include "context.hpp" #include "context.hpp"
#include "media.hpp" #include "media.hpp"
#include "module.hpp" #include "module.hpp"
#include "pack.hpp"
namespace nostalgia::foundation { namespace keel {
template<typename Ctx = foundation::Context> template<typename Ctx = keel::Context>
ox::Result<ox::UPtr<Ctx>> init(ox::UPtr<ox::FileSystem> &&fs, ox::CRStringView appName) noexcept { ox::Result<ox::UPtr<Ctx>> init(ox::UPtr<ox::FileSystem> &&fs, ox::CRStringView appName) noexcept {
auto ctx = ox::make_unique<Ctx>(); auto ctx = ox::make_unique<Ctx>();
ctx->appName = appName; ctx->appName = appName;

View File

@ -10,9 +10,9 @@
#include <ox/std/trace.hpp> #include <ox/std/trace.hpp>
#include <nostalgia/foundation/media.hpp> #include "media.hpp"
namespace nostalgia::foundation { namespace keel {
ox::Result<char*> loadRom(ox::CRStringView path) noexcept { ox::Result<char*> loadRom(ox::CRStringView path) noexcept {
std::ifstream file(std::string(toStdStringView(path)), std::ios::binary | std::ios::ate); 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<char*>(0x0800'0000) #define MEM_ROM reinterpret_cast<char*>(0x0800'0000)
namespace nostalgia::foundation { namespace keel {
static void clearUuidMap(Context*) noexcept { static void clearUuidMap(Context*) noexcept {
} }
@ -114,7 +114,7 @@ ox::Result<char*> loadRom(ox::CRStringView) noexcept {
void unloadRom(char*) noexcept { void unloadRom(char*) noexcept {
} }
ox::Result<std::size_t> getPreloadAddr(foundation::Context *ctx, ox::CRStringView path) noexcept { ox::Result<std::size_t> getPreloadAddr(keel::Context *ctx, ox::CRStringView path) noexcept {
oxRequire(stat, ctx->rom->stat(path)); oxRequire(stat, ctx->rom->stat(path));
oxRequire(buff, static_cast<ox::MemFS*>(ctx->rom.get())->directAccess(path)); oxRequire(buff, static_cast<ox::MemFS*>(ctx->rom.get())->directAccess(path));
PreloadPtr p; PreloadPtr p;
@ -122,7 +122,7 @@ ox::Result<std::size_t> getPreloadAddr(foundation::Context *ctx, ox::CRStringVie
return p.preloadAddr + ctx->preloadSectionOffset; return p.preloadAddr + ctx->preloadSectionOffset;
} }
ox::Result<std::size_t> getPreloadAddr(foundation::Context *ctx, const ox::FileAddress &file) noexcept { ox::Result<std::size_t> getPreloadAddr(keel::Context *ctx, const ox::FileAddress &file) noexcept {
oxRequire(stat, ctx->rom->stat(file)); oxRequire(stat, ctx->rom->stat(file));
oxRequire(buff, static_cast<ox::MemFS*>(ctx->rom.get())->directAccess(file)); oxRequire(buff, static_cast<ox::MemFS*>(ctx->rom.get())->directAccess(file));
PreloadPtr p; PreloadPtr p;
@ -134,7 +134,7 @@ ox::Result<std::size_t> getPreloadAddr(foundation::Context *ctx, const ox::FileA
#endif #endif
namespace nostalgia::foundation { namespace keel {
ox::Error setRomFs(Context *ctx, ox::UPtr<ox::FileSystem> fs) noexcept { ox::Error setRomFs(Context *ctx, ox::UPtr<ox::FileSystem> fs) noexcept {
ctx->rom = std::move(fs); ctx->rom = std::move(fs);

View File

@ -15,7 +15,7 @@
#include "context.hpp" #include "context.hpp"
#include "typeconv.hpp" #include "typeconv.hpp"
namespace nostalgia::foundation { namespace keel {
// Pointer to preloaded data that can be stored in FS in place of the actual // Pointer to preloaded data that can be stored in FS in place of the actual
// data. // data.
@ -29,14 +29,14 @@ oxModelBegin(PreloadPtr)
oxModelField(preloadAddr) oxModelField(preloadAddr)
oxModelEnd() oxModelEnd()
ox::Result<std::size_t> getPreloadAddr(foundation::Context *ctx, const ox::FileAddress &file) noexcept; ox::Result<std::size_t> getPreloadAddr(keel::Context *ctx, const ox::FileAddress &file) noexcept;
ox::Result<std::size_t> getPreloadAddr(foundation::Context *ctx, ox::CRStringView file) noexcept; ox::Result<std::size_t> getPreloadAddr(keel::Context *ctx, ox::CRStringView file) noexcept;
#ifndef OX_BARE_METAL #ifndef OX_BARE_METAL
template<typename T> template<typename T>
ox::Result<foundation::AssetRef<T>> readObjFile( ox::Result<keel::AssetRef<T>> readObjFile(
foundation::Context *ctx, keel::Context *ctx,
ox::StringView assetId, ox::StringView assetId,
bool forceLoad) noexcept { bool forceLoad) noexcept {
constexpr auto readConvert = [](Context *ctx, const ox::Buffer &buff) -> ox::Result<T> { constexpr auto readConvert = [](Context *ctx, const ox::Buffer &buff) -> ox::Result<T> {
@ -78,12 +78,12 @@ ox::Result<foundation::AssetRef<T>> readObjFile(
#else #else
template<typename T> template<typename T>
ox::Result<foundation::AssetRef<T>> readObjNoCache( ox::Result<keel::AssetRef<T>> readObjNoCache(
foundation::Context *ctx, keel::Context *ctx,
ox::CRStringView assetId) noexcept { ox::CRStringView assetId) noexcept {
if constexpr(ox::preloadable<T>::value) { if constexpr(ox::preloadable<T>::value) {
oxRequire(addr, getPreloadAddr(ctx, assetId)); oxRequire(addr, getPreloadAddr(ctx, assetId));
return foundation::AssetRef<T>(reinterpret_cast<const T*>(addr)); return keel::AssetRef<T>(reinterpret_cast<const T*>(addr));
} else { } else {
return OxError(1); return OxError(1);
} }
@ -96,8 +96,8 @@ void createUuidMapping(Context *ctx, const ox::String &filePath, const ox::UUID
ox::Error buildUuidMap(Context *ctx) noexcept; ox::Error buildUuidMap(Context *ctx) noexcept;
template<typename T> template<typename T>
ox::Result<foundation::AssetRef<T>> readObj( ox::Result<keel::AssetRef<T>> readObj(
[[maybe_unused]] foundation::Context *ctx, [[maybe_unused]] keel::Context *ctx,
[[maybe_unused]] ox::CRStringView assetId, [[maybe_unused]] ox::CRStringView assetId,
[[maybe_unused]] bool forceLoad = false) noexcept { [[maybe_unused]] bool forceLoad = false) noexcept {
#ifndef OX_BARE_METAL #ifndef OX_BARE_METAL
@ -108,8 +108,8 @@ ox::Result<foundation::AssetRef<T>> readObj(
} }
template<typename T> template<typename T>
ox::Result<foundation::AssetRef<T>> readObj( ox::Result<keel::AssetRef<T>> readObj(
foundation::Context *ctx, keel::Context *ctx,
const ox::FileAddress &file, const ox::FileAddress &file,
[[maybe_unused]] bool forceLoad = false) noexcept { [[maybe_unused]] bool forceLoad = false) noexcept {
#ifndef OX_BARE_METAL #ifndef OX_BARE_METAL
@ -118,7 +118,7 @@ ox::Result<foundation::AssetRef<T>> readObj(
#else #else
if constexpr(ox::preloadable<T>::value) { if constexpr(ox::preloadable<T>::value) {
oxRequire(addr, getPreloadAddr(ctx, file)); oxRequire(addr, getPreloadAddr(ctx, file));
return foundation::AssetRef<T>(reinterpret_cast<const T*>(addr)); return keel::AssetRef<T>(reinterpret_cast<const T*>(addr));
} else { } else {
return OxError(1); return OxError(1);
} }
@ -127,7 +127,7 @@ ox::Result<foundation::AssetRef<T>> readObj(
template<typename T> template<typename T>
ox::Error writeObj( ox::Error writeObj(
foundation::Context *ctx, keel::Context *ctx,
const ox::FileAddress &file, const ox::FileAddress &file,
const T &obj, const T &obj,
ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept { ox::ClawFormat fmt = ox::ClawFormat::Metal) noexcept {

View File

@ -4,7 +4,7 @@
#include "module.hpp" #include "module.hpp"
namespace nostalgia::foundation { namespace keel {
static ox::Vector<const Module*> mods; static ox::Vector<const Module*> mods;
@ -22,7 +22,7 @@ ox::Vector<TypeDescGenerator> Module::types() const noexcept {
return {}; return {};
} }
ox::Vector<const foundation::BaseConverter*> Module::converters() const noexcept { ox::Vector<const keel::BaseConverter*> Module::converters() const noexcept {
return {}; return {};
} }

View File

@ -9,7 +9,7 @@
#include "typeconv.hpp" #include "typeconv.hpp"
namespace nostalgia::foundation { namespace keel {
using TypeDescGenerator = ox::Error(*)(ox::TypeStore*); using TypeDescGenerator = ox::Error(*)(ox::TypeStore*);
@ -30,7 +30,7 @@ class Module {
[[nodiscard]] [[nodiscard]]
virtual ox::Vector<TypeDescGenerator> types() const noexcept; virtual ox::Vector<TypeDescGenerator> types() const noexcept;
[[nodiscard]] [[nodiscard]]
virtual ox::Vector<const foundation::BaseConverter*> converters() const noexcept; virtual ox::Vector<const keel::BaseConverter*> converters() const noexcept;
[[nodiscard]] [[nodiscard]]
virtual ox::Vector<PackTransform> packTransforms() const noexcept; virtual ox::Vector<PackTransform> packTransforms() const noexcept;
}; };
@ -38,6 +38,6 @@ class Module {
void registerModule(const Module *mod) noexcept; void registerModule(const Module *mod) noexcept;
[[nodiscard]] [[nodiscard]]
const ox::Vector<const foundation::Module*> &modules() noexcept; const ox::Vector<const keel::Module*> &modules() noexcept;
} }

View File

@ -2,18 +2,20 @@
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/ */
#ifndef OX_BARE_METAL
#include <ox/claw/read.hpp> #include <ox/claw/read.hpp>
#include <ox/fs/fs.hpp> #include <ox/fs/fs.hpp>
#include <ox/model/descwrite.hpp> #include <ox/model/descwrite.hpp>
#include <ox/model/modelvalue.hpp> #include <ox/model/modelvalue.hpp>
#include <nostalgia/foundation/media.hpp> #include <keel/media.hpp>
#include "pack.hpp" #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 &o = *obj;
auto type = static_cast<ox::FileAddressType>(o["type"].get<int8_t>()); auto type = static_cast<ox::FileAddressType>(o["type"].get<int8_t>());
auto &data = o["data"].get<ox::ModelUnion>(); auto &data = o["data"].get<ox::ModelUnion>();
@ -38,10 +40,10 @@ static ox::Error pathToInode(foundation::Context *ctx, ox::FileSystem *dest, ox:
return data.set(2, s.inode); return data.set(2, s.inode);
} }
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;
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;
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) { if (v->type() == ox::ModelValue::Type::Object) {
auto &obj = v->get<ox::ModelObject>(); auto &obj = v->get<ox::ModelObject>();
return transformFileAddressesObj(ctx, dest, &obj); return transformFileAddressesObj(ctx, dest, &obj);
@ -52,7 +54,7 @@ static ox::Error transformFileAddresses(foundation::Context *ctx, ox::FileSystem
return {}; 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) { for (auto &f : *v) {
oxReturnError(transformFileAddresses(ctx, dest, &f)); 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 * Convert path references in Claw data to inodes to save space
* @return error * @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) { if (obj->typeName() == "net.drinkingtea.ox.FileAddress" && obj->typeVersion() == 1) {
return pathToInode(ctx, dest, obj); return pathToInode(ctx, dest, obj);
} }
@ -74,7 +76,7 @@ static ox::Error transformFileAddressesObj(foundation::Context *ctx, ox::FileSys
return {}; 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 // load file
oxRequire(s, dest->stat(filePath)); oxRequire(s, dest->stat(filePath));
// do transformations // do transformations
@ -83,7 +85,7 @@ static ox::Error doTransformations(foundation::Context *ctx, ox::TypeStore *ts,
oxReturnError(tr(ctx, &buff)); oxReturnError(tr(ctx, &buff));
} }
// transform FileAddresses // transform FileAddresses
oxRequireM(obj, foundation::readAsset(ts, buff)); oxRequireM(obj, keel::readAsset(ts, buff));
oxReturnError(transformFileAddressesObj(ctx, dest, &obj)); oxReturnError(transformFileAddressesObj(ctx, dest, &obj));
oxReturnError(ox::writeClaw(&obj).moveTo(&buff)); oxReturnError(ox::writeClaw(&obj).moveTo(&buff));
// write file to dest // 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 // 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 // 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 // copy
oxTracef("pack::transformClaw", "path: {}", path); oxTracef("pack::transformClaw", "path: {}", path);
oxRequire(fileList, dest->ls(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)); oxRequire(fileList, src->ls(path));
for (const auto &name : fileList) { for (const auto &name : fileList) {
auto currentFile = ox::sfmt("{}{}", path, name); auto currentFile = ox::sfmt("{}{}", path, name);
if (currentFile == "/.nostalgia") { if (beginsWith(name, ".")) {
continue; continue;
} }
oxOutf("reading {}\n", currentFile); oxOutf("reading {}\n", currentFile);
@ -169,7 +171,7 @@ static ox::Error preloadObj(
GbaPreloader *pl, ox::CRStringView path) noexcept { GbaPreloader *pl, ox::CRStringView path) noexcept {
// load file // load file
oxRequireM(buff, romFs->read(path)); oxRequireM(buff, romFs->read(path));
oxRequireM(obj, foundation::readAsset(ts, buff)); oxRequireM(obj, keel::readAsset(ts, buff));
if (obj.type()->preloadable) { if (obj.type()->preloadable) {
oxOutf("preloading {}\n", path); oxOutf("preloading {}\n", path);
// preload // preload
@ -177,7 +179,7 @@ static ox::Error preloadObj(
const auto err = ox::preload<GbaPlatSpec, decltype(obj)>(pl, &obj); const auto err = ox::preload<GbaPlatSpec, decltype(obj)>(pl, &obj);
oxReturnError(pl->endAlloc()); oxReturnError(pl->endAlloc());
oxReturnError(err); oxReturnError(err);
const foundation::PreloadPtr p{.preloadAddr = static_cast<uint32_t>(a)}; const keel::PreloadPtr p{.preloadAddr = static_cast<uint32_t>(a)};
oxReturnError(ox::writeMC(&p).moveTo(&buff)); oxReturnError(ox::writeMC(&p).moveTo(&buff));
} else { } else {
// strip the Claw header (it is not needed after preloading) and write back out to dest fs // 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 {}; 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)); oxReturnError(copyFS(ctx->rom.get(), dest));
oxOut("Doing transforms\n"); oxOut("Doing transforms\n");
oxReturnError(transformClaw(ctx, ts, dest, "/")); oxReturnError(transformClaw(ctx, ts, dest, "/"));
@ -241,3 +243,5 @@ ox::Error preload(ox::TypeStore *ts, ox::FileSystem *src, GbaPreloader *pl) noex
} }
} }
#endif

View File

@ -2,15 +2,17 @@
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/ */
#pragma once
#include <ox/fs/fs.hpp> #include <ox/fs/fs.hpp>
#include <ox/preloader/preloader.hpp> #include <ox/preloader/preloader.hpp>
namespace nostalgia { namespace keel {
namespace foundation {
class Context; class Context;
} }
namespace keel {
struct GbaPlatSpec { struct GbaPlatSpec {
using PtrType = uint32_t; using PtrType = uint32_t;
using size_t = uint32_t; using size_t = uint32_t;
@ -78,8 +80,8 @@ using GbaPreloader = ox::Preloader<GbaPlatSpec>;
ox::Error appendBinary(ox::Buffer *binBuff, ox::Buffer *fsBuff, GbaPreloader *pl) noexcept; 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;
} }

View File

@ -7,13 +7,13 @@
#include "media.hpp" #include "media.hpp"
#include "typeconv.hpp" #include "typeconv.hpp"
namespace nostalgia::foundation { namespace keel {
#ifndef OX_BARE_METAL #ifndef OX_BARE_METAL
[[nodiscard]] [[nodiscard]]
static ox::Result<const BaseConverter*> findConverter( static ox::Result<const BaseConverter*> findConverter(
foundation::Context *ctx, keel::Context *ctx,
ox::CRStringView srcTypeName, int srcTypeVersion, ox::CRStringView srcTypeName, int srcTypeVersion,
ox::CRStringView dstTypeName, int dstTypeVersion) noexcept { ox::CRStringView dstTypeName, int dstTypeVersion) noexcept {
for (auto &c : ctx->converters) { for (auto &c : ctx->converters) {
@ -25,7 +25,7 @@ static ox::Result<const BaseConverter*> findConverter(
}; };
static ox::Result<ox::UniquePtr<Wrap>> convert( static ox::Result<ox::UniquePtr<Wrap>> convert(
foundation::Context *ctx, const ox::Buffer &srcBuffer, keel::Context *ctx, const ox::Buffer &srcBuffer,
ox::CRStringView srcTypeName, int srcTypeVersion, ox::CRStringView srcTypeName, int srcTypeVersion,
ox::CRStringView dstTypeName, int dstTypeVersion) noexcept { ox::CRStringView dstTypeName, int dstTypeVersion) noexcept {
// look for direct converter // look for direct converter
@ -49,7 +49,7 @@ static ox::Result<ox::UniquePtr<Wrap>> convert(
} }
ox::Result<ox::UniquePtr<Wrap>> convert( ox::Result<ox::UniquePtr<Wrap>> convert(
foundation::Context *ctx, keel::Context *ctx,
const ox::Buffer &srcBuffer, const ox::Buffer &srcBuffer,
ox::CRStringView dstTypeName, ox::CRStringView dstTypeName,
int dstTypeVersion) noexcept { int dstTypeVersion) noexcept {

View File

@ -13,7 +13,7 @@
#include "context.hpp" #include "context.hpp"
#include "media.hpp" #include "media.hpp"
namespace nostalgia::foundation { namespace keel {
class Wrap { class Wrap {
public: public:
@ -87,9 +87,9 @@ class BaseConverter {
[[nodiscard]] [[nodiscard]]
virtual bool dstMatches(ox::CRStringView dstTypeName, int dstTypeVersion) const noexcept = 0; virtual bool dstMatches(ox::CRStringView dstTypeName, int dstTypeVersion) const noexcept = 0;
virtual ox::Result<ox::UniquePtr<Wrap>> convertPtrToPtr(foundation::Context *ctx, Wrap *src) const noexcept = 0; virtual ox::Result<ox::UniquePtr<Wrap>> convertPtrToPtr(keel::Context *ctx, Wrap *src) const noexcept = 0;
virtual ox::Result<ox::UniquePtr<Wrap>> convertBuffToPtr(foundation::Context *ctx, const ox::Buffer &srcBuff) const noexcept = 0; virtual ox::Result<ox::UniquePtr<Wrap>> convertBuffToPtr(keel::Context *ctx, const ox::Buffer &srcBuff) const noexcept = 0;
[[nodiscard]] [[nodiscard]]
inline bool matches(ox::CRStringView srcTypeName, int srcTypeVersion, inline bool matches(ox::CRStringView srcTypeName, int srcTypeVersion,
@ -129,13 +129,13 @@ class Converter: public BaseConverter {
&& dstTypeVersion == DstTypeVersion; && dstTypeVersion == DstTypeVersion;
} }
ox::Result<ox::UniquePtr<Wrap>> convertPtrToPtr(foundation::Context *ctx, Wrap *src) const noexcept final { ox::Result<ox::UniquePtr<Wrap>> convertPtrToPtr(keel::Context *ctx, Wrap *src) const noexcept final {
auto dst = makeWrap<DstType>(); auto dst = makeWrap<DstType>();
oxReturnError(convert(ctx, wrapCast<SrcType>(src), wrapCast<DstType>(dst.get()))); oxReturnError(convert(ctx, wrapCast<SrcType>(src), wrapCast<DstType>(dst.get())));
return ox::Result<ox::UniquePtr<Wrap>>(std::move(dst)); return ox::Result<ox::UniquePtr<Wrap>>(std::move(dst));
} }
ox::Result<ox::UniquePtr<Wrap>> convertBuffToPtr(foundation::Context *ctx, const ox::Buffer &srcBuff) const noexcept final { ox::Result<ox::UniquePtr<Wrap>> convertBuffToPtr(keel::Context *ctx, const ox::Buffer &srcBuff) const noexcept final {
oxRequireM(src, readAsset<SrcType>(srcBuff)); oxRequireM(src, readAsset<SrcType>(srcBuff));
auto dst = makeWrap<DstType>(); auto dst = makeWrap<DstType>();
oxReturnError(convert(ctx, &src, wrapCast<DstType>(dst.get()))); oxReturnError(convert(ctx, &src, wrapCast<DstType>(dst.get())));
@ -143,15 +143,15 @@ class Converter: public BaseConverter {
} }
protected: 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<ox::UniquePtr<Wrap>> convert(foundation::Context *ctx, const ox::Buffer &srcBuffer, ox::Result<ox::UniquePtr<Wrap>> convert(keel::Context *ctx, const ox::Buffer &srcBuffer,
ox::CRStringView dstTypeName, int dstTypeVersion) noexcept; ox::CRStringView dstTypeName, int dstTypeVersion) noexcept;
template<typename DstType> template<typename DstType>
ox::Result<DstType> convert(foundation::Context *ctx, const ox::Buffer &srcBuffer) noexcept { ox::Result<DstType> convert(keel::Context *ctx, const ox::Buffer &srcBuffer) noexcept {
static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>(); static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>();
static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>(); static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion)); oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion));
@ -159,7 +159,7 @@ ox::Result<DstType> convert(foundation::Context *ctx, const ox::Buffer &srcBuffe
} }
template<typename DstType> template<typename DstType>
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<DstType>(); static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>();
static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>(); static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
oxRequire(outPtr, convert(ctx, buff, DstTypeName, DstTypeVersion)); oxRequire(outPtr, convert(ctx, buff, DstTypeName, DstTypeVersion));
@ -168,7 +168,7 @@ ox::Error convert(foundation::Context *ctx, const ox::Buffer &buff, DstType *out
} }
template<typename DstType> template<typename DstType>
ox::Result<ox::Buffer> convertBuffToBuff(foundation::Context *ctx, const ox::Buffer &srcBuffer, ox::ClawFormat fmt) noexcept { ox::Result<ox::Buffer> convertBuffToBuff(keel::Context *ctx, const ox::Buffer &srcBuffer, ox::ClawFormat fmt) noexcept {
static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>(); static constexpr auto DstTypeName = ox::requireModelTypeName<DstType>();
static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>(); static constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion)); oxRequire(out, convert(ctx, srcBuffer, DstTypeName, DstTypeVersion));
@ -176,12 +176,12 @@ ox::Result<ox::Buffer> convertBuffToBuff(foundation::Context *ctx, const ox::Buf
} }
template<typename From, typename To, ox::ClawFormat fmt = ox::ClawFormat::Metal> template<typename From, typename To, ox::ClawFormat fmt = ox::ClawFormat::Metal>
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)); oxRequire(hdr, readAssetHeader(*buff));
const auto typeId = ox::buildTypeId( const auto typeId = ox::buildTypeId(
hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams); hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams);
if (typeId == ox::buildTypeId<From>()) { if (typeId == ox::buildTypeId<From>()) {
oxReturnError(foundation::convertBuffToBuff<To>(ctx, *buff, fmt).moveTo(buff)); oxReturnError(keel::convertBuffToBuff<To>(ctx, *buff, fmt).moveTo(buff));
} }
return {}; return {};
}; };

View File

@ -3,7 +3,6 @@
add_subdirectory(appmodules) add_subdirectory(appmodules)
add_subdirectory(core) add_subdirectory(core)
add_subdirectory(foundation)
add_subdirectory(geo) add_subdirectory(geo)
add_subdirectory(scene) add_subdirectory(scene)

View File

@ -10,7 +10,7 @@ endif()
target_link_libraries( target_link_libraries(
NostalgiaAppModules PUBLIC NostalgiaAppModules PUBLIC
NostalgiaCore NostalgiaCore
NostalgiaFoundation Keel
NostalgiaScene NostalgiaScene
) )

View File

@ -2,7 +2,7 @@
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/ */
#include <nostalgia/foundation/module.hpp> #include <keel/module.hpp>
#include <nostalgia/core/module.hpp> #include <nostalgia/core/module.hpp>
#include <nostalgia/scene/scenemodule.hpp> #include <nostalgia/scene/scenemodule.hpp>
@ -14,8 +14,8 @@ void loadModules() noexcept {
if (modulesLoaded) { if (modulesLoaded) {
return; return;
} }
foundation::registerModule(core::module()); keel::registerModule(core::module());
foundation::registerModule(scene::module()); keel::registerModule(scene::module());
modulesLoaded = true; modulesLoaded = true;
} }

View File

@ -51,7 +51,7 @@ endif()
target_link_libraries( target_link_libraries(
NostalgiaCore-Common PUBLIC NostalgiaCore-Common PUBLIC
NostalgiaFoundation Keel
) )
target_link_libraries( target_link_libraries(

View File

@ -8,7 +8,7 @@
#include <ox/model/desctypes.hpp> #include <ox/model/desctypes.hpp>
#include <ox/std/buffer.hpp> #include <ox/std/buffer.hpp>
#include <nostalgia/foundation/context.hpp> #include <keel/context.hpp>
#include <nostalgia/geo/size.hpp> #include <nostalgia/geo/size.hpp>
#include "event.hpp" #include "event.hpp"
@ -59,7 +59,7 @@ struct BgCbbData {
}; };
// User Input Output // User Input Output
class Context: public foundation::Context { class Context: public keel::Context {
friend constexpr void setApplicationData(Context *ctx, void *applicationData) noexcept; friend constexpr void setApplicationData(Context *ctx, void *applicationData) noexcept;
template<typename T> template<typename T>
friend constexpr T *applicationData(Context *ctx) noexcept; friend constexpr T *applicationData(Context *ctx) noexcept;

View File

@ -6,7 +6,7 @@
#include <ox/mc/mc.hpp> #include <ox/mc/mc.hpp>
#include <ox/std/array.hpp> #include <ox/std/array.hpp>
#include <nostalgia/foundation/media.hpp> #include <keel/media.hpp>
#include <nostalgia/core/context.hpp> #include <nostalgia/core/context.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/core/gfx.hpp>
@ -130,7 +130,7 @@ ox::Error initConsole(Context *ctx) noexcept {
setBgStatus(ctx, 0b0001); setBgStatus(ctx, 0b0001);
if (!ctx) { if (!ctx) {
ctx = new (ox_alloca(sizeof(Context))) Context(); ctx = new (ox_alloca(sizeof(Context))) Context();
oxRequire(rom, foundation::loadRom()); oxRequire(rom, keel::loadRom());
ox::FileStore32 fs(rom, 32 * ox::units::MB); ox::FileStore32 fs(rom, 32 * ox::units::MB);
auto romFs = new (ox_alloca(sizeof(ox::FileSystem32))) ox::FileSystem32(fs); auto romFs = new (ox_alloca(sizeof(ox::FileSystem32))) ox::FileSystem32(fs);
new (&ctx->rom) ox::UniquePtr<ox::FileSystem>(romFs); new (&ctx->rom) ox::UniquePtr<ox::FileSystem>(romFs);

View File

@ -5,7 +5,7 @@
#include <glad/glad.h> #include <glad/glad.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <nostalgia/foundation/foundation.hpp> #include <keel/keel.hpp>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/core/gfx.hpp>
#include <nostalgia/core/input.hpp> #include <nostalgia/core/input.hpp>
#include <nostalgia/core/opengl/gfx.hpp> #include <nostalgia/core/opengl/gfx.hpp>
@ -15,7 +15,7 @@
namespace nostalgia::core { namespace nostalgia::core {
ox::Result<ox::UPtr<Context>> init(ox::UPtr<ox::FileSystem> fs, ox::CRStringView appName) noexcept { ox::Result<ox::UPtr<Context>> init(ox::UPtr<ox::FileSystem> fs, ox::CRStringView appName) noexcept {
oxRequireM(ctx, foundation::init<Context>(std::move(fs), appName)); oxRequireM(ctx, keel::init<Context>(std::move(fs), appName));
const auto id = ox::make<GlfwImplData>(); const auto id = ox::make<GlfwImplData>();
ctx->setWindowerData(id); ctx->setWindowerData(id);
using namespace std::chrono; using namespace std::chrono;

View File

@ -4,8 +4,8 @@
#include <ox/model/model.hpp> #include <ox/model/model.hpp>
#include <nostalgia/foundation/asset.hpp> #include <keel/asset.hpp>
#include <nostalgia/foundation/module.hpp> #include <keel/module.hpp>
#include "gfx.hpp" #include "gfx.hpp"
#include "typeconv.hpp" #include "typeconv.hpp"
@ -14,7 +14,7 @@
namespace nostalgia::core { namespace nostalgia::core {
class CoreModule: public foundation::Module { class CoreModule: public keel::Module {
private: private:
NostalgiaPaletteToPaletteConverter nostalgiaPaletteToPaletteConverter; NostalgiaPaletteToPaletteConverter nostalgiaPaletteToPaletteConverter;
TileSheetV1ToTileSheetConverter nostalgiaGraphicToTileSheetConverter; TileSheetV1ToTileSheetConverter nostalgiaGraphicToTileSheetConverter;
@ -24,31 +24,31 @@ class CoreModule: public foundation::Module {
public: public:
static CoreModule mod; static CoreModule mod;
[[nodiscard]] [[nodiscard]]
ox::Vector<foundation::TypeDescGenerator> types() const noexcept override; ox::Vector<keel::TypeDescGenerator> types() const noexcept override;
[[nodiscard]] [[nodiscard]]
ox::Vector<const foundation::BaseConverter*> converters() const noexcept override; ox::Vector<const keel::BaseConverter*> converters() const noexcept override;
[[nodiscard]] [[nodiscard]]
ox::Vector<foundation::PackTransform> packTransforms() const noexcept override; ox::Vector<keel::PackTransform> packTransforms() const noexcept override;
}; };
CoreModule CoreModule::mod; CoreModule CoreModule::mod;
const foundation::Module *module() noexcept { const keel::Module *module() noexcept {
return &CoreModule::mod; return &CoreModule::mod;
} }
ox::Vector<foundation::TypeDescGenerator> CoreModule::types() const noexcept { ox::Vector<keel::TypeDescGenerator> CoreModule::types() const noexcept {
return { return {
foundation::generateTypeDesc<TileSheetV1>, keel::generateTypeDesc<TileSheetV1>,
foundation::generateTypeDesc<TileSheetV2>, keel::generateTypeDesc<TileSheetV2>,
foundation::generateTypeDesc<TileSheet>, keel::generateTypeDesc<TileSheet>,
foundation::generateTypeDesc<CompactTileSheet>, keel::generateTypeDesc<CompactTileSheet>,
foundation::generateTypeDesc<NostalgiaPalette>, keel::generateTypeDesc<NostalgiaPalette>,
foundation::generateTypeDesc<Palette>, keel::generateTypeDesc<Palette>,
}; };
} }
ox::Vector<const foundation::BaseConverter*> CoreModule::converters() const noexcept { ox::Vector<const keel::BaseConverter*> CoreModule::converters() const noexcept {
return { return {
&nostalgiaPaletteToPaletteConverter, &nostalgiaPaletteToPaletteConverter,
&nostalgiaGraphicToTileSheetConverter, &nostalgiaGraphicToTileSheetConverter,
@ -57,16 +57,16 @@ ox::Vector<const foundation::BaseConverter*> CoreModule::converters() const noex
}; };
} }
ox::Vector<foundation::PackTransform> CoreModule::packTransforms() const noexcept { ox::Vector<keel::PackTransform> CoreModule::packTransforms() const noexcept {
return { return {
// convert tilesheets to CompactTileSheets // convert tilesheets to CompactTileSheets
[](foundation::Context *ctx, ox::Buffer *buff) -> ox::Error { [](keel::Context *ctx, ox::Buffer *buff) -> ox::Error {
oxRequire(hdr, foundation::readAssetHeader(*buff)); oxRequire(hdr, keel::readAssetHeader(*buff));
const auto typeId = ox::buildTypeId(hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams); const auto typeId = ox::buildTypeId(hdr.clawHdr.typeName, hdr.clawHdr.typeVersion, hdr.clawHdr.typeParams);
if (typeId == ox::buildTypeId<TileSheetV1>() || if (typeId == ox::buildTypeId<TileSheetV1>() ||
typeId == ox::buildTypeId<TileSheetV2>() || typeId == ox::buildTypeId<TileSheetV2>() ||
typeId == ox::buildTypeId<TileSheet>()) { typeId == ox::buildTypeId<TileSheet>()) {
oxReturnError(foundation::convertBuffToBuff<core::CompactTileSheet>( oxReturnError(keel::convertBuffToBuff<core::CompactTileSheet>(
ctx, *buff, ox::ClawFormat::Metal).moveTo(buff)); ctx, *buff, ox::ClawFormat::Metal).moveTo(buff));
} }
return {}; return {};

View File

@ -4,10 +4,10 @@
#pragma once #pragma once
#include <nostalgia/foundation/module.hpp> #include <keel/module.hpp>
namespace nostalgia::core { namespace nostalgia::core {
const foundation::Module *module() noexcept; const keel::Module *module() noexcept;
} }

View File

@ -3,7 +3,7 @@
*/ */
#include <nostalgia/core/gfx.hpp> #include <nostalgia/core/gfx.hpp>
#include <nostalgia/foundation/media.hpp> #include <keel/media.hpp>
#include "gfx.hpp" #include "gfx.hpp"

View File

@ -5,7 +5,7 @@
#include <imgui.h> #include <imgui.h>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/core/gfx.hpp>
#include <nostalgia/foundation/media.hpp> #include <keel/media.hpp>
#include <ox/std/memory.hpp> #include <ox/std/memory.hpp>
#include "paletteeditor.hpp" #include "paletteeditor.hpp"
@ -19,7 +19,7 @@ ox::Result<PaletteEditorImGui*> PaletteEditorImGui::make(Context *ctx, ox::CRStr
out->m_itemPath = path; out->m_itemPath = path;
const auto lastSlash = std::find(out->m_itemPath.rbegin(), out->m_itemPath.rend(), '/').offset(); const auto lastSlash = std::find(out->m_itemPath.rbegin(), out->m_itemPath.rend(), '/').offset();
out->m_itemName = out->m_itemPath.substr(lastSlash + 1); out->m_itemName = out->m_itemPath.substr(lastSlash + 1);
oxRequire(pal, foundation::readObj<Palette>(out->m_ctx, ox::FileAddress(out->m_itemPath.c_str()))); oxRequire(pal, keel::readObj<Palette>(out->m_ctx, ox::FileAddress(out->m_itemPath.c_str())));
out->m_pal = *pal; out->m_pal = *pal;
return out.release(); return out.release();
} }

View File

@ -5,7 +5,7 @@
#include <imgui.h> #include <imgui.h>
#include <lodepng.h> #include <lodepng.h>
#include <nostalgia/foundation/media.hpp> #include <keel/media.hpp>
#include <nostalgia/geo/point.hpp> #include <nostalgia/geo/point.hpp>
#include "tilesheeteditor-imgui.hpp" #include "tilesheeteditor-imgui.hpp"

View File

@ -9,7 +9,7 @@
#include <ox/std/memory.hpp> #include <ox/std/memory.hpp>
#include <nostalgia/core/clipboard.hpp> #include <nostalgia/core/clipboard.hpp>
#include <nostalgia/foundation/media.hpp> #include <keel/media.hpp>
#include "tilesheeteditormodel.hpp" #include "tilesheeteditormodel.hpp"

View File

@ -23,7 +23,7 @@ class TileSheetEditorModel: public ox::SignalHandler {
static const Palette s_defaultPalette; static const Palette s_defaultPalette;
TileSheet m_img; TileSheet m_img;
TileSheet::SubSheetIdx m_activeSubsSheetIdx; TileSheet::SubSheetIdx m_activeSubsSheetIdx;
foundation::AssetRef<Palette> m_pal; keel::AssetRef<Palette> m_pal;
studio::UndoStack m_undoStack; studio::UndoStack m_undoStack;
class DrawCommand *m_ongoingDrawCommand = nullptr; class DrawCommand *m_ongoingDrawCommand = nullptr;
bool m_updated = false; bool m_updated = false;

View File

@ -3,7 +3,7 @@
*/ */
#include <nostalgia/core/consts.hpp> #include <nostalgia/core/consts.hpp>
#include <nostalgia/foundation/media.hpp> #include <keel/media.hpp>
#include <nostalgia/geo/point.hpp> #include <nostalgia/geo/point.hpp>
#include "tilesheeteditorview.hpp" #include "tilesheeteditorview.hpp"

View File

@ -7,7 +7,7 @@
namespace nostalgia::core { namespace nostalgia::core {
ox::Error NostalgiaPaletteToPaletteConverter::convert( ox::Error NostalgiaPaletteToPaletteConverter::convert(
foundation::Context*, keel::Context*,
NostalgiaPalette *src, NostalgiaPalette *src,
Palette *dst) const noexcept { Palette *dst) const noexcept {
dst->colors = std::move(src->colors); dst->colors = std::move(src->colors);
@ -15,7 +15,7 @@ ox::Error NostalgiaPaletteToPaletteConverter::convert(
} }
ox::Error TileSheetV1ToTileSheetConverter::convert( ox::Error TileSheetV1ToTileSheetConverter::convert(
foundation::Context*, keel::Context*,
TileSheetV1 *src, TileSheetV1 *src,
TileSheet *dst) const noexcept { TileSheet *dst) const noexcept {
dst->bpp = src->bpp; dst->bpp = src->bpp;
@ -28,7 +28,7 @@ ox::Error TileSheetV1ToTileSheetConverter::convert(
} }
ox::Error TileSheetToCompactTileSheetConverter::convert( ox::Error TileSheetToCompactTileSheetConverter::convert(
foundation::Context*, keel::Context*,
TileSheet *src, TileSheet *src,
CompactTileSheet *dst) const noexcept { CompactTileSheet *dst) const noexcept {
dst->bpp = src->bpp; dst->bpp = src->bpp;
@ -55,7 +55,7 @@ void TileSheetV2ToTileSheetConverter::convertSubsheet(
} }
ox::Error TileSheetV2ToTileSheetConverter::convert( ox::Error TileSheetV2ToTileSheetConverter::convert(
foundation::Context*, keel::Context*,
TileSheetV2 *src, TileSheetV2 *src,
TileSheet *dst) const noexcept { TileSheet *dst) const noexcept {
dst->bpp = src->bpp; dst->bpp = src->bpp;

View File

@ -6,7 +6,7 @@
#include <ox/std/def.hpp> #include <ox/std/def.hpp>
#include <nostalgia/foundation/typeconv.hpp> #include <keel/typeconv.hpp>
#include "context.hpp" #include "context.hpp"
#include "gfx.hpp" #include "gfx.hpp"
@ -15,25 +15,25 @@ namespace nostalgia::core {
// Type converters // Type converters
class NostalgiaPaletteToPaletteConverter: public foundation::Converter<NostalgiaPalette, Palette> { class NostalgiaPaletteToPaletteConverter: public keel::Converter<NostalgiaPalette, Palette> {
ox::Error convert(foundation::Context*, NostalgiaPalette *src, Palette *dst) const noexcept final; ox::Error convert(keel::Context*, NostalgiaPalette *src, Palette *dst) const noexcept final;
}; };
class TileSheetV1ToTileSheetConverter: public foundation::Converter<TileSheetV1, TileSheet> { class TileSheetV1ToTileSheetConverter: public keel::Converter<TileSheetV1, TileSheet> {
ox::Error convert(foundation::Context*, TileSheetV1 *src, TileSheet *dst) const noexcept final; ox::Error convert(keel::Context*, TileSheetV1 *src, TileSheet *dst) const noexcept final;
}; };
class TileSheetToCompactTileSheetConverter: public foundation::Converter<TileSheet, CompactTileSheet> { class TileSheetToCompactTileSheetConverter: public keel::Converter<TileSheet, CompactTileSheet> {
ox::Error convert(foundation::Context*, TileSheet *src, CompactTileSheet *dst) const noexcept final; ox::Error convert(keel::Context*, TileSheet *src, CompactTileSheet *dst) const noexcept final;
}; };
class TileSheetV2ToTileSheetConverter: public foundation::Converter<TileSheetV2, TileSheet> { class TileSheetV2ToTileSheetConverter: public keel::Converter<TileSheetV2, TileSheet> {
static void convertSubsheet( static void convertSubsheet(
TileSheetV2::SubSheet *src, TileSheetV2::SubSheet *src,
TileSheet::SubSheet *dst, TileSheet::SubSheet *dst,
SubSheetId *idIt) noexcept; 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;
}; };

View File

@ -33,7 +33,7 @@ ox::Error run(ox::UniquePtr<ox::FileSystem> fs) noexcept {
oxTraceInitHook(); oxTraceInitHook();
oxRequireM(ctx, core::init(std::move(fs))); oxRequireM(ctx, core::init(std::move(fs)));
constexpr ox::FileAddress SceneAddr("/Scenes/Chester.nscn"); constexpr ox::FileAddress SceneAddr("/Scenes/Chester.nscn");
oxRequire(scn, foundation::readObj<scene::SceneStatic>(ctx.get(), SceneAddr)); oxRequire(scn, keel::readObj<scene::SceneStatic>(ctx.get(), SceneAddr));
core::setUpdateHandler(ctx.get(), updateHandler); core::setUpdateHandler(ctx.get(), updateHandler);
core::setKeyEventHandler(ctx.get(), keyEventHandler); core::setKeyEventHandler(ctx.get(), keyEventHandler);
s_scene.emplace(*scn); s_scene.emplace(*scn);

View File

@ -22,7 +22,7 @@ static ox::Error run(int argc, const char **argv) noexcept {
return OxError(1); return OxError(1);
} }
const auto path = argv[1]; const auto path = argv[1];
oxRequireM(fs, nostalgia::foundation::loadRomFs(path)); oxRequireM(fs, keel::loadRomFs(path));
return run(std::move(fs)); return run(std::move(fs));
} }

View File

@ -11,37 +11,37 @@
namespace nostalgia::scene { namespace nostalgia::scene {
class SceneModule: public foundation::Module { class SceneModule: public keel::Module {
private: private:
SceneDocToSceneStaticConverter sceneDocToSceneStaticConverter; SceneDocToSceneStaticConverter sceneDocToSceneStaticConverter;
public: public:
[[nodiscard]] [[nodiscard]]
ox::Vector<foundation::TypeDescGenerator> types() const noexcept override { ox::Vector<keel::TypeDescGenerator> types() const noexcept override {
return { return {
foundation::generateTypeDesc<SceneDoc>, keel::generateTypeDesc<SceneDoc>,
foundation::generateTypeDesc<SceneStatic>, keel::generateTypeDesc<SceneStatic>,
}; };
} }
[[nodiscard]] [[nodiscard]]
ox::Vector<const foundation::BaseConverter*> converters() const noexcept override { ox::Vector<const keel::BaseConverter*> converters() const noexcept override {
return { return {
&sceneDocToSceneStaticConverter, &sceneDocToSceneStaticConverter,
}; };
} }
[[nodiscard]] [[nodiscard]]
ox::Vector<foundation::PackTransform> packTransforms() const noexcept override { ox::Vector<keel::PackTransform> packTransforms() const noexcept override {
return { return {
foundation::transformRule<SceneDoc, SceneStatic>, keel::transformRule<SceneDoc, SceneStatic>,
}; };
} }
}; };
static SceneModule mod; static SceneModule mod;
const foundation::Module *module() noexcept { const keel::Module *module() noexcept {
return &mod; return &mod;
} }

View File

@ -4,10 +4,10 @@
#pragma once #pragma once
#include <nostalgia/foundation/module.hpp> #include <keel/module.hpp>
namespace nostalgia::scene { namespace nostalgia::scene {
const foundation::Module *module() noexcept; const keel::Module *module() noexcept;
} }

View File

@ -5,7 +5,7 @@
#include <imgui.h> #include <imgui.h>
#include <nostalgia/core/gfx.hpp> #include <nostalgia/core/gfx.hpp>
#include <nostalgia/foundation/media.hpp> #include <keel/media.hpp>
#include <ox/std/memory.hpp> #include <ox/std/memory.hpp>
#include "sceneeditor-imgui.hpp" #include "sceneeditor-imgui.hpp"

View File

@ -8,7 +8,7 @@ namespace nostalgia::scene {
SceneEditor::SceneEditor(core::Context *ctx, ox::CRStringView path) { SceneEditor::SceneEditor(core::Context *ctx, ox::CRStringView path) {
m_ctx = ctx; m_ctx = ctx;
oxRequireT(scn, foundation::readObj<SceneStatic>(m_ctx, path)); oxRequireT(scn, keel::readObj<SceneStatic>(m_ctx, path));
m_scene = *scn; m_scene = *scn;
} }

View File

@ -3,7 +3,7 @@
*/ */
#include <nostalgia/core/gfx.hpp> #include <nostalgia/core/gfx.hpp>
#include <nostalgia/foundation/media.hpp> #include <keel/media.hpp>
#include "typeconv.hpp" #include "typeconv.hpp"
@ -34,10 +34,10 @@ constexpr void setLayerAttachments(unsigned layer, const TileDoc &srcTile, Scene
} }
ox::Error SceneDocToSceneStaticConverter::convert( ox::Error SceneDocToSceneStaticConverter::convert(
foundation::Context *ctx, keel::Context *ctx,
SceneDoc *src, SceneDoc *src,
SceneStatic *dst) const noexcept { SceneStatic *dst) const noexcept {
oxRequire(ts, foundation::readObj<core::TileSheet>(ctx, src->tilesheet)); oxRequire(ts, keel::readObj<core::TileSheet>(ctx, src->tilesheet));
const auto layerCnt = src->tiles.size(); const auto layerCnt = src->tiles.size();
dst->setLayerCnt(layerCnt); dst->setLayerCnt(layerCnt);
dst->tilesheet = ox::FileAddress(src->tilesheet); dst->tilesheet = ox::FileAddress(src->tilesheet);

View File

@ -4,14 +4,14 @@
#pragma once #pragma once
#include <nostalgia/foundation/typeconv.hpp> #include <keel/typeconv.hpp>
#include "scenestatic.hpp" #include "scenestatic.hpp"
namespace nostalgia::scene { namespace nostalgia::scene {
class SceneDocToSceneStaticConverter: public foundation::Converter<SceneDoc, SceneStatic> { class SceneDocToSceneStaticConverter: public keel::Converter<SceneDoc, SceneStatic> {
ox::Error convert(foundation::Context*, SceneDoc *src, SceneStatic *dst) const noexcept final; ox::Error convert(keel::Context*, SceneDoc *src, SceneStatic *dst) const noexcept final;
}; };
} }

View File

@ -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"); const auto homeDir = std::getenv(ox::defines::OS == ox::OS::Windows ? "USERPROFILE" : "HOME");
return ox::sfmt(ConfigDir, homeDir, ctx->appName); return ox::sfmt(ConfigDir, homeDir, ctx->appName);
} }

View File

@ -18,10 +18,10 @@
namespace nostalgia::studio { namespace nostalgia::studio {
[[nodiscard]] [[nodiscard]]
ox::String configPath(const foundation::Context *ctx) noexcept; ox::String configPath(const keel::Context *ctx) noexcept;
template<typename T> template<typename T>
ox::Result<T> readConfig(foundation::Context *ctx, ox::CRStringView name) noexcept { ox::Result<T> readConfig(keel::Context *ctx, ox::CRStringView name) noexcept {
oxAssert(name != "", "Config type has no TypeName"); oxAssert(name != "", "Config type has no TypeName");
const auto path = ox::sfmt("/{}.json", name); const auto path = ox::sfmt("/{}.json", name);
ox::PassThroughFS fs(configPath(ctx)); ox::PassThroughFS fs(configPath(ctx));
@ -34,13 +34,13 @@ ox::Result<T> readConfig(foundation::Context *ctx, ox::CRStringView name) noexce
} }
template<typename T> template<typename T>
ox::Result<T> readConfig(foundation::Context *ctx) noexcept { ox::Result<T> readConfig(keel::Context *ctx) noexcept {
constexpr auto TypeName = ox::requireModelTypeName<T>(); constexpr auto TypeName = ox::requireModelTypeName<T>();
return readConfig<T>(ctx, TypeName); return readConfig<T>(ctx, TypeName);
} }
template<typename T> template<typename T>
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"); oxAssert(name != "", "Config type has no TypeName");
const auto path = ox::sfmt("/{}.json", name); const auto path = ox::sfmt("/{}.json", name);
ox::PassThroughFS fs(configPath(ctx)); ox::PassThroughFS fs(configPath(ctx));
@ -58,13 +58,13 @@ ox::Error writeConfig(foundation::Context *ctx, ox::CRStringView name, T *data)
} }
template<typename T> template<typename T>
ox::Error writeConfig(foundation::Context *ctx, T *data) noexcept { ox::Error writeConfig(keel::Context *ctx, T *data) noexcept {
constexpr auto TypeName = ox::requireModelTypeName<T>(); constexpr auto TypeName = ox::requireModelTypeName<T>();
return writeConfig(ctx, TypeName, data); return writeConfig(ctx, TypeName, data);
} }
template<typename T, typename Func> template<typename T, typename Func>
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"); oxAssert(name != "", "Config type has no TypeName");
const auto [c, err] = readConfig<T>(ctx, name); const auto [c, err] = readConfig<T>(ctx, name);
oxLogError(err); oxLogError(err);
@ -72,13 +72,13 @@ void openConfig(foundation::Context *ctx, const auto &name, Func f) noexcept {
} }
template<typename T, typename Func> template<typename T, typename Func>
void openConfig(foundation::Context *ctx, Func f) noexcept { void openConfig(keel::Context *ctx, Func f) noexcept {
constexpr auto TypeName = ox::requireModelTypeName<T>(); constexpr auto TypeName = ox::requireModelTypeName<T>();
openConfig<T>(ctx, TypeName, f); openConfig<T>(ctx, TypeName, f);
} }
template<typename T, typename Func> template<typename T, typename Func>
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"); oxAssert(ox_strcmp(name, ""), "Config type has no TypeName");
auto [c, err] = readConfig<T>(ctx, name); auto [c, err] = readConfig<T>(ctx, name);
oxLogError(err); oxLogError(err);
@ -87,7 +87,7 @@ void editConfig(foundation::Context *ctx, const auto &name, Func f) noexcept {
} }
template<typename T, typename Func> template<typename T, typename Func>
void editConfig(foundation::Context *ctx, Func f) noexcept { void editConfig(keel::Context *ctx, Func f) noexcept {
constexpr auto TypeName = ox::requireModelTypeName<T>(); constexpr auto TypeName = ox::requireModelTypeName<T>();
editConfig<T>(ctx, TypeName, f); editConfig<T>(ctx, TypeName, f);
} }

View File

@ -6,7 +6,7 @@
#include <ox/claw/claw.hpp> #include <ox/claw/claw.hpp>
#include <nostalgia/foundation/media.hpp> #include <keel/media.hpp>
#include <nostalgia/core/context.hpp> #include <nostalgia/core/context.hpp>
#include "context.hpp" #include "context.hpp"
@ -50,7 +50,7 @@ class ItemMakerT: public ItemMaker {
ox::Error write(core::Context *ctx, ox::CRStringView pName) const noexcept override { ox::Error write(core::Context *ctx, ox::CRStringView pName) const noexcept override {
const auto path = ox::sfmt("/{}/{}.{}", parentDir, pName, fileExt); const auto path = ox::sfmt("/{}/{}.{}", parentDir, pName, fileExt);
auto sctx = core::applicationData<studio::StudioContext>(ctx); auto sctx = core::applicationData<studio::StudioContext>(ctx);
foundation::createUuidMapping(ctx, path, ox::UUID::generate().unwrap()); keel::createUuidMapping(ctx, path, ox::UUID::generate().unwrap());
return sctx->project->writeObj(path, &item, fmt); return sctx->project->writeObj(path, &item, fmt);
} }
}; };

View File

@ -7,21 +7,21 @@
#include <ox/std/std.hpp> #include <ox/std/std.hpp>
#include <nostalgia/foundation/module.hpp> #include <keel/module.hpp>
#include "project.hpp" #include "project.hpp"
namespace nostalgia::studio { namespace nostalgia::studio {
static void generateTypes(ox::TypeStore *ts) noexcept { static void generateTypes(ox::TypeStore *ts) noexcept {
for (const auto mod : foundation::modules()) { for (const auto mod : keel::modules()) {
for (auto gen : mod->types()) { for (auto gen : mod->types()) {
oxLogError(gen(ts)); 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_path(std::move(path)),
m_typeStore(ctx->rom.get()), m_typeStore(ctx->rom.get()),
m_fs(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); ox::BufferWriter writer(&outBuff);
const auto [uuid, err] = m_ctx->pathToUuid.at(path); const auto [uuid, err] = m_ctx->pathToUuid.at(path);
if (!err) { if (!err) {
oxReturnError(foundation::writeUuidHeader(&writer, *uuid)); oxReturnError(keel::writeUuidHeader(&writer, *uuid));
} }
oxReturnError(writer.write(buff.data(), buff.size())); oxReturnError(writer.write(buff.data(), buff.size()));
const auto newFile = m_fs->stat(path).error != 0; const auto newFile = m_fs->stat(path).error != 0;

View File

@ -13,7 +13,7 @@
#include <ox/std/hashmap.hpp> #include <ox/std/hashmap.hpp>
#include <nostalgia/core/typestore.hpp> #include <nostalgia/core/typestore.hpp>
#include <nostalgia/foundation/media.hpp> #include <keel/media.hpp>
#include "nostalgiastudio_export.h" #include "nostalgiastudio_export.h"
@ -43,11 +43,11 @@ class NOSTALGIASTUDIO_EXPORT Project {
ox::String m_path; ox::String m_path;
mutable core::TypeStore m_typeStore; mutable core::TypeStore m_typeStore;
mutable ox::FileSystem *m_fs = nullptr; mutable ox::FileSystem *m_fs = nullptr;
foundation::Context *m_ctx = nullptr; keel::Context *m_ctx = nullptr;
ox::HashMap<ox::String, ox::Vector<ox::String>> m_fileExtFileMap; ox::HashMap<ox::String, ox::Vector<ox::String>> m_fileExtFileMap;
public: public:
explicit Project(foundation::Context *ctx, ox::String path) noexcept; explicit Project(keel::Context *ctx, ox::String path) noexcept;
ox::Error create() noexcept; ox::Error create() noexcept;
@ -131,9 +131,9 @@ template<typename T>
ox::Result<T> Project::loadObj(const ox::String &path) const noexcept { ox::Result<T> Project::loadObj(const ox::String &path) const noexcept {
oxRequire(buff, loadBuff(path)); oxRequire(buff, loadBuff(path));
if constexpr (ox::is_same_v<T, ox::ModelObject>) { if constexpr (ox::is_same_v<T, ox::ModelObject>) {
return foundation::readAsset(&m_typeStore, buff); return keel::readAsset(&m_typeStore, buff);
} else { } else {
return foundation::readAsset<T>(buff); return keel::readAsset<T>(buff);
} }
} }

View File

@ -10,7 +10,7 @@
#include <nostalgia/appmodules/appmodules.hpp> #include <nostalgia/appmodules/appmodules.hpp>
#include <nostalgia/core/core.hpp> #include <nostalgia/core/core.hpp>
#include <nostalgia/foundation/media.hpp> #include <keel/media.hpp>
#include "lib/context.hpp" #include "lib/context.hpp"
#include "studioapp.hpp" #include "studioapp.hpp"

View File

@ -5,7 +5,7 @@
#include <imgui.h> #include <imgui.h>
#include <nostalgia/core/core.hpp> #include <nostalgia/core/core.hpp>
#include <nostalgia/foundation/media.hpp> #include <keel/media.hpp>
#include "lib/configio.hpp" #include "lib/configio.hpp"
#include "builtinmodules.hpp" #include "builtinmodules.hpp"
@ -290,8 +290,8 @@ void StudioUI::save() noexcept {
} }
ox::Error StudioUI::openProject(ox::CRStringView path) noexcept { ox::Error StudioUI::openProject(ox::CRStringView path) noexcept {
oxRequireM(fs, foundation::loadRomFs(path)); oxRequireM(fs, keel::loadRomFs(path));
oxReturnError(foundation::setRomFs(m_ctx, std::move(fs))); oxReturnError(keel::setRomFs(m_ctx, std::move(fs)));
core::setWindowTitle(m_ctx, ox::sfmt("Nostalgia Studio - {}", path)); core::setWindowTitle(m_ctx, ox::sfmt("Nostalgia Studio - {}", path));
m_project = ox::make_unique<studio::Project>(m_ctx, path); m_project = ox::make_unique<studio::Project>(m_ctx, path);
auto sctx = applicationData<studio::StudioContext>(m_ctx); auto sctx = applicationData<studio::StudioContext>(m_ctx);

View File

@ -4,7 +4,7 @@ target_link_libraries(
nost-pack nost-pack
OxClArgs OxClArgs
OxLogConn OxLogConn
NostalgiaPack Keel
NostalgiaAppModules NostalgiaAppModules
) )
@ -19,6 +19,3 @@ install(
RUNTIME DESTINATION RUNTIME DESTINATION
bin bin
) )
add_subdirectory(pack)

View File

@ -8,12 +8,9 @@
#include <ox/fs/fs.hpp> #include <ox/fs/fs.hpp>
#include <ox/logconn/logconn.hpp> #include <ox/logconn/logconn.hpp>
#include <keel/keel.hpp>
#include <nostalgia/appmodules/appmodules.hpp> #include <nostalgia/appmodules/appmodules.hpp>
#include <nostalgia/core/typestore.hpp> #include <nostalgia/core/typestore.hpp>
#include <nostalgia/foundation/foundation.hpp>
#include <nostalgia/foundation/module.hpp>
#include "pack/pack.hpp"
using namespace nostalgia; using namespace nostalgia;
@ -46,7 +43,7 @@ static ox::Result<ox::Buffer> readFileBuff(ox::CRStringView path) noexcept {
} }
static ox::Error generateTypes(ox::TypeStore *ts) 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()) { for (auto gen : mod->types()) {
oxReturnError(gen(ts)); oxReturnError(gen(ts));
} }
@ -69,11 +66,11 @@ static ox::Error run(const ox::ClArgs &args) noexcept {
ox::Buffer dstBuff(32 * ox::units::MB); ox::Buffer dstBuff(32 * ox::units::MB);
oxReturnError(ox::FileSystem32::format(dstBuff.data(), dstBuff.size())); oxReturnError(ox::FileSystem32::format(dstBuff.data(), dstBuff.size()));
ox::FileSystem32 dst(ox::FileStore32(dstBuff.data(), dstBuff.size())); ox::FileSystem32 dst(ox::FileStore32(dstBuff.data(), dstBuff.size()));
oxRequire(ctx, foundation::init(ox::make_unique<ox::PassThroughFS>(argSrc), "nost-pack")); oxRequire(ctx, keel::init(ox::make_unique<ox::PassThroughFS>(argSrc), "nost-pack"));
core::TypeStore ts(ctx->rom.get()); core::TypeStore ts(ctx->rom.get());
oxReturnError(generateTypes(&ts)); oxReturnError(generateTypes(&ts));
oxReturnError(pack(ctx.get(), &ts, &dst)); oxReturnError(keel::pack(ctx.get(), &ts, &dst));
oxRequireM(pl, GbaPreloader::make()); oxRequireM(pl, keel::GbaPreloader::make());
oxReturnError(preload(&ts, &dst, pl.get())); oxReturnError(preload(&ts, &dst, pl.get()));
oxReturnError(dst.resize()); oxReturnError(dst.resize());
// resize buffer // resize buffer

View File

@ -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
)