Compare commits

..

7 Commits

Author SHA1 Message Date
d2e30b4cfd [keel] Cleanup pack tool
Some checks failed
Build / build (push) Failing after 47s
2024-12-18 23:43:22 -06:00
7a8680610d [jasper] Change macro names to comply with broader conventions 2024-12-18 23:43:22 -06:00
1986619f65 [glutils] Change macro names to comply with broader conventions 2024-12-18 23:43:22 -06:00
c410c8e897 [ox] Change macro names to comply with broader conventions
Some checks failed
Build / build (push) Failing after 23s
2024-12-18 23:43:22 -06:00
2a286a64ca Merge commit '8c39be2b0682ec31b0c62623a8a921467b09cfe1' into pre-macro 2024-12-18 23:40:19 -06:00
cc4da3a4c4 [buildcore] Map aarch64 to arm64 in util.get_arch
All checks were successful
Build / build (push) Successful in 2m56s
2024-12-14 21:05:56 -06:00
1bc050026f [ox/std] Fix compiler warning 2024-12-14 21:02:33 -06:00
35 changed files with 88 additions and 99 deletions

View File

@@ -35,4 +35,6 @@ def get_arch() -> str:
arch = platform.machine().lower()
if arch == 'amd64':
arch = 'x86_64'
elif arch == 'aarch64':
arch = 'arm64'
return arch

View File

@@ -10,11 +10,7 @@ if(NOT DEFINED BUILD_SHARED_LIBS)
option(BUILD_SHARED_LIBS "Build a shared library instead of static" OFF)
endif()
option(NFD_BUILD_TESTS "Build tests for nfd" ${nfd_ROOT_PROJECT})
# DrinkingTea: begin
if(NOT DEFINED NFD_INSTALL)
option(NFD_INSTALL "Generate install target for nfd" ${nfd_ROOT_PROJECT})
endif()
# DrinkingTea: end
option(NFD_INSTALL "Generate install target for nfd" ${nfd_ROOT_PROJECT})
set(nfd_PLATFORM Undefined)
if(WIN32)
@@ -25,9 +21,7 @@ elseif(UNIX AND NOT APPLE)
set(nfd_PLATFORM PLATFORM_UNIX)
endif()
# DrinkingTea: begin
#message("nfd Platform: ${nfd_PLATFORM}")
# DrinkingTea: end
message("nfd Platform: ${nfd_PLATFORM}")
set(nfd_COMPILER Undefined)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
@@ -39,9 +33,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "C
set(nfd_COMPILER COMPILER_GNU)
endif()
# DrinkingTea: begin
#message("nfd Compiler: ${nfd_COMPILER}")
# DrinkingTea: end
message("nfd Compiler: ${nfd_COMPILER}")
# Use latest C++ by default (should be the best one), but let user override it
if(NOT DEFINED CMAKE_CXX_STANDARD)

View File

@@ -32,7 +32,7 @@ ox::Result<char> StreamReader::peek() const noexcept {
try {
char c{};
m_strm.get(c);
auto const ok = c != EOF;
auto const ok = c != static_cast<char>(EOF);
if (ok && m_strm.unget()) [[unlikely]] {
return ox::Error(1, "Unable to unget character");
}

View File

@@ -2,4 +2,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"length" : 4,
"primitiveType" : 1,
"typeName" : "B.int32"
}
}

View File

@@ -2,4 +2,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"length" : 1,
"primitiveType" : 1,
"typeName" : "B.int8"
}
}

View File

@@ -1,4 +1,4 @@
O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 4,
"typeName" : "B.string"
}
}

View File

@@ -1,4 +1,4 @@
O1;net.drinkingtea.ox.TypeDescriptor;1;{
"length" : 2,
"typeName" : "B.uint16"
}
}

View File

@@ -1,4 +1,4 @@
O1;net.drinkingtea.ox.TypeDescriptor;1;{
"length" : 8,
"typeName" : "B.uint64"
}
}

View File

@@ -1,4 +1,4 @@
O1;net.drinkingtea.ox.TypeDescriptor;1;{
"length" : 1,
"typeName" : "B.uint8"
}
}

View File

@@ -20,4 +20,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.CompactPalette",
"typeVersion" : 1
}
}

View File

@@ -25,4 +25,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.CompactTileSheet",
"typeVersion" : 1
}
}

View File

@@ -36,4 +36,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.NostalgiaGraphic",
"typeVersion" : 1
}
}

View File

@@ -9,4 +9,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.Palette.ColorInfo",
"typeVersion" : 3
}
}

View File

@@ -20,4 +20,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.Palette.PalettePage",
"typeVersion" : 1
}
}

View File

@@ -16,4 +16,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.Palette",
"typeVersion" : 1
}
}

View File

@@ -20,4 +20,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.Palette",
"typeVersion" : 2
}
}

View File

@@ -31,4 +31,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.Palette",
"typeVersion" : 3
}
}

View File

@@ -28,4 +28,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.Palette",
"typeVersion" : 4
}
}

View File

@@ -21,4 +21,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.PaletteColor",
"typeVersion" : 1
}
}

View File

@@ -39,4 +39,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.TileSheet.SubSheet",
"typeVersion" : 1
}
}

View File

@@ -39,4 +39,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.TileSheet.SubSheet",
"typeVersion" : 3
}
}

View File

@@ -43,4 +43,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.TileSheet.SubSheet",
"typeVersion" : 4
}
}

View File

@@ -17,4 +17,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.TileSheet",
"typeVersion" : 2
}
}

View File

@@ -21,4 +21,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.TileSheet",
"typeVersion" : 3
}
}

View File

@@ -21,4 +21,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.core.TileSheet",
"typeVersion" : 4
}
}

View File

@@ -38,4 +38,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.scene.SceneDoc",
"typeVersion" : 1
}
}

View File

@@ -85,4 +85,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.scene.SceneStatic",
"typeVersion" : 1
}
}

View File

@@ -30,4 +30,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.nostalgia.scene.TileDoc",
"typeVersion" : 1
}
}

View File

@@ -6,4 +6,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"8"
],
"typeVersion" : 1
}
}

View File

@@ -17,4 +17,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 6,
"typeName" : "net.drinkingtea.ox.FileAddress.Data",
"typeVersion" : 1
}
}

View File

@@ -13,4 +13,4 @@ O1;net.drinkingtea.ox.TypeDescriptor;1;{
"primitiveType" : 5,
"typeName" : "net.drinkingtea.ox.FileAddress",
"typeVersion" : 1
}
}

View File

@@ -67,12 +67,12 @@ static void testKeyEventHandler(turbine::Context &tctx, turbine::Key key, bool d
static ox::Error runTest(turbine::Context &tctx) {
constexpr ox::StringView TileSheetAddr{"/TileSheets/Charset.ng"};
constexpr ox::StringView PaletteAddr{"/Palettes/Chester.npal"};
OX_REQUIRE_M(cctx, core::init(tctx));
oxRequireM(cctx, core::init(tctx));
turbine::setApplicationData(tctx, cctx.get());
OX_REQUIRE(tsStat, turbine::rom(tctx)->stat(PaletteAddr));
OX_RETURN_ERROR(core::loadSpriteTileSheet(*cctx, TileSheetAddr));
OX_RETURN_ERROR(core::loadSpritePalette(*cctx, PaletteAddr));
OX_RETURN_ERROR(core::initConsole(*cctx));
oxRequire(tsStat, turbine::rom(tctx)->stat(PaletteAddr));
oxReturnError(core::loadSpriteTileSheet(*cctx, TileSheetAddr));
oxReturnError(core::loadSpritePalette(*cctx, PaletteAddr));
oxReturnError(core::initConsole(*cctx));
core::puts(*cctx, 10, 9, "DOPENESS!!!");
turbine::setUpdateHandler(tctx, testUpdateHandler);
turbine::setKeyEventHandler(tctx, testKeyEventHandler);
@@ -85,9 +85,9 @@ static ox::Error runTileSheetSetTest(turbine::Context &tctx) {
// this should make the screen display 'ABCDB', with the A being upside down
// and the first B being backwards
constexpr ox::StringView PaletteAddr{"/Palettes/Charset.npal"};
OX_REQUIRE_M(cctx, core::init(tctx));
oxRequireM(cctx, core::init(tctx));
turbine::setApplicationData(tctx, cctx.get());
OX_REQUIRE(tsStat, turbine::rom(tctx)->stat(PaletteAddr));
oxRequire(tsStat, turbine::rom(tctx)->stat(PaletteAddr));
core::TileSheetSet const set{
.bpp = 4,
.entries = {
@@ -98,11 +98,11 @@ static ox::Error runTileSheetSetTest(turbine::Context &tctx) {
},
};
constexpr auto bgPalBank = 1;
OX_RETURN_ERROR(core::loadBgTileSheet(*cctx, 0, set));
OX_RETURN_ERROR(core::loadSpriteTileSheet(*cctx, set));
OX_RETURN_ERROR(core::loadBgPalette(*cctx, bgPalBank, PaletteAddr));
OX_RETURN_ERROR(core::loadBgPalette(*cctx, 0, PaletteAddr));
OX_RETURN_ERROR(core::loadSpritePalette(*cctx, PaletteAddr));
oxReturnError(core::loadBgTileSheet(*cctx, 0, set));
oxReturnError(core::loadSpriteTileSheet(*cctx, set));
oxReturnError(core::loadBgPalette(*cctx, bgPalBank, PaletteAddr));
oxReturnError(core::loadBgPalette(*cctx, 0, PaletteAddr));
oxReturnError(core::loadSpritePalette(*cctx, PaletteAddr));
core::setBgStatus(*cctx, 0, true);
core::setBgTile(*cctx, 0, 10, 9, { .tileIdx = 1, .palBank = bgPalBank, .flipX = 0, .flipY = 1 });
core::setBgTile(*cctx, 0, 11, 9, { .tileIdx = 2, .palBank = bgPalBank, .flipX = 1, .flipY = 0 });
@@ -148,12 +148,12 @@ static void sceneKeyEventHandler(turbine::Context &tctx, turbine::Key key, bool
[[maybe_unused]]
static ox::Error runScene(turbine::Context &tctx) {
constexpr ox::StringView SceneAddr{"/Scenes/Chester.nscn"};
OX_REQUIRE_M(cctx, core::init(tctx));
OX_REQUIRE(scn, keel::readObj<scene::SceneStatic>(keelCtx(tctx), SceneAddr));
oxRequireM(cctx, core::init(tctx));
oxRequire(scn, keel::readObj<scene::SceneStatic>(keelCtx(tctx), SceneAddr));
turbine::setUpdateHandler(tctx, sceneUpdateHandler);
turbine::setKeyEventHandler(tctx, sceneKeyEventHandler);
scene::Scene const scene(*scn);
OX_RETURN_ERROR(scene.setupDisplay(*cctx));
oxReturnError(scene.setupDisplay(*cctx));
return turbine::run(tctx);
}
@@ -166,7 +166,7 @@ ox::Error run(
return ox::Error(1, "Please provide path to project directory or OxFS file.");
}
auto const path = args[1];
OX_REQUIRE_M(fs, keel::loadRomFs(path));
OX_REQUIRE_M(tctx, turbine::init(std::move(fs), project));
oxRequireM(fs, keel::loadRomFs(path));
oxRequireM(tctx, turbine::init(std::move(fs), project));
return runTileSheetSetTest(*tctx);
}

View File

@@ -11,7 +11,7 @@ target_link_libraries(
target_compile_definitions(
NostalgiaStudio PUBLIC
OLYMPIC_APP_VERSION="d2024.12.0"
OLYMPIC_APP_VERSION="dev build"
)
install(

View File

@@ -33,7 +33,7 @@ ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, ox::FileAddress const
ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, ox::StringViewCR path) noexcept;
void createUuidMapping(Context &ctx, ox::StringViewCR filePath, ox::UUID const&uuid) noexcept;
void createUuidMapping(Context &ctx, ox::StringView filePath, ox::UUID const&uuid) noexcept;
ox::Error buildUuidMap(Context &ctx) noexcept;
@@ -41,17 +41,17 @@ ox::Result<ox::UUID> pathToUuid(Context &ctx, ox::StringViewCR path) noexcept;
ox::Result<ox::UUID> getUuid(Context &ctx, ox::FileAddress const&fileAddr) noexcept;
ox::Result<ox::UUID> getUuid(Context &ctx, ox::StringViewCR path) noexcept;
ox::Result<ox::UUID> getUuid(Context &ctx, ox::StringView path) noexcept;
ox::Result<ox::CStringView> getPath(Context &ctx, ox::FileAddress const&fileAddr) noexcept;
ox::Result<ox::CStringView> getPath(Context &ctx, ox::CStringViewCR fileId) noexcept;
ox::Result<ox::CStringView> getPath(Context &ctx, ox::CStringView fileId) noexcept;
constexpr ox::Result<ox::UUID> uuidUrlToUuid(ox::StringViewCR uuidUrl) noexcept {
constexpr ox::Result<ox::UUID> uuidUrlToUuid(ox::StringView uuidUrl) noexcept {
return ox::UUID::fromString(substr(uuidUrl, 7));
}
ox::Result<ox::CStringView> uuidUrlToPath(Context &ctx, ox::StringViewCR uuid) noexcept;
ox::Result<ox::CStringView> uuidUrlToPath(Context &ctx, ox::StringView uuid) noexcept;
ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::StringViewCR uuid) noexcept;
@@ -62,7 +62,7 @@ ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::UUID const&uuid) noexce
namespace detail {
template<typename T>
constexpr auto makeLoader(Context &ctx) {
return [&ctx](ox::StringViewCR assetId) -> ox::Result<T> {
return [&ctx](ox::StringView assetId) -> ox::Result<T> {
OX_REQUIRE(p, ctx.uuidToPath.at(assetId));
OX_REQUIRE(buff, ctx.rom->read(*p));
auto [obj, err] = readAsset<T>(buff);
@@ -80,34 +80,27 @@ constexpr auto makeLoader(Context &ctx) {
template<typename T>
ox::Result<keel::AssetRef<T>> readObjFile(
keel::Context &ctx,
ox::StringViewCR assetId,
bool const forceLoad) noexcept {
static constexpr auto load = [](
keel::Context &ctx,
ox::StringViewCR assetId,
bool forceLoad) -> ox::Result<keel::AssetRef<T>> {
if (forceLoad) {
ctx.assetManager.initTypeManager<T>(detail::makeLoader<T>, ctx);
return ctx.assetManager.loadAsset<T>(assetId);
} else {
auto [cached, err] = ctx.assetManager.getAsset<T>(assetId);
if (err) {
ctx.assetManager.initTypeManager<T>(detail::makeLoader<T>, ctx);
OX_RETURN_ERROR(ctx.assetManager.loadAsset<T>(assetId).moveTo(cached));
}
return cached;
}
};
ox::StringView assetId,
bool forceLoad) noexcept {
if (beginsWith(assetId, "uuid://")) {
return load(ctx, substr(assetId, 7), forceLoad);
assetId = substr(assetId, 7);
} else {
auto const [uuid, uuidErr] = getUuid(ctx, assetId);
if (!uuidErr) {
return load(ctx, uuid.toString(), forceLoad);
} else {
return load(ctx, assetId, forceLoad);
assetId = uuid.toString();
}
}
if (forceLoad) {
ctx.assetManager.initTypeManager<T>(detail::makeLoader<T>, ctx);
return ctx.assetManager.loadAsset<T>(assetId);
} else {
auto [cached, err] = ctx.assetManager.getAsset<T>(assetId);
if (err) {
ctx.assetManager.initTypeManager<T>(detail::makeLoader<T>, ctx);
OX_RETURN_ERROR(ctx.assetManager.loadAsset<T>(assetId).moveTo(cached));
}
return cached;
}
}
#else
@@ -126,7 +119,7 @@ ox::Result<keel::AssetRef<T>> readObjNoCache(
#endif
ox::Error reloadAsset(keel::Context &ctx, ox::StringViewCR assetId) noexcept;
ox::Error reloadAsset(keel::Context &ctx, ox::StringView assetId) noexcept;
template<typename T>
ox::Result<keel::AssetRef<T>> readObj(
@@ -170,7 +163,7 @@ ox::Error writeObj(
ox::Error setRomFs(Context &ctx, ox::UPtr<ox::FileSystem> &&fs) noexcept;
ox::Result<ox::UPtr<ox::FileSystem>> loadRomFs(ox::StringViewCR path) noexcept;
ox::Result<ox::UniquePtr<ox::FileSystem>> loadRomFs(ox::StringViewCR path) noexcept;
ox::Result<char*> loadRom(ox::StringViewCR path = "") noexcept;

View File

@@ -42,7 +42,7 @@ static void clearUuidMap(Context &ctx) noexcept {
ctx.pathToUuid.clear();
}
void createUuidMapping(Context &ctx, ox::StringViewCR filePath, ox::UUID const&uuid) noexcept {
void createUuidMapping(Context &ctx, ox::StringView filePath, ox::UUID const&uuid) noexcept {
ctx.pathToUuid[filePath] = uuid;
ctx.uuidToPath[uuid.toString()] = filePath;
}
@@ -88,7 +88,7 @@ ox::Result<ox::UUID> getUuid(Context &ctx, ox::FileAddress const&fileAddr) noexc
return getUuid(ctx, path);
}
ox::Result<ox::UUID> getUuid(Context &ctx, ox::StringViewCR path) noexcept {
ox::Result<ox::UUID> getUuid(Context &ctx, ox::StringView path) noexcept {
if (beginsWith(path, "uuid://")) {
auto const uuid = substr(path, 7);
return ox::UUID::fromString(uuid);
@@ -112,7 +112,7 @@ ox::Result<ox::CStringView> getPath(Context &ctx, ox::FileAddress const&fileAddr
}
}
ox::Result<ox::CStringView> getPath(Context &ctx, ox::CStringViewCR fileId) noexcept {
ox::Result<ox::CStringView> getPath(Context &ctx, ox::CStringView fileId) noexcept {
if (beginsWith(fileId, "uuid://")) {
auto const uuid = substr(fileId, 7);
#ifndef OX_BARE_METAL
@@ -126,9 +126,10 @@ ox::Result<ox::CStringView> getPath(Context &ctx, ox::CStringViewCR fileId) noex
}
}
ox::Result<ox::CStringView> uuidUrlToPath(Context &ctx, ox::StringViewCR uuid) noexcept {
ox::Result<ox::CStringView> uuidUrlToPath(Context &ctx, ox::StringView uuid) noexcept {
uuid = substr(uuid, 7);
#ifndef OX_BARE_METAL
OX_REQUIRE_M(out, ctx.uuidToPath.at(substr(uuid, 7)));
OX_REQUIRE_M(out, ctx.uuidToPath.at(uuid));
return ox::CStringView(*out);
#else
return ox::Error(1, "UUID to path conversion not supported on this platform");
@@ -153,18 +154,19 @@ ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::UUID const&uuid) noexce
#endif
}
ox::Error reloadAsset(keel::Context &ctx, ox::StringViewCR assetId) noexcept {
ox::Error reloadAsset(keel::Context &ctx, ox::StringView assetId) noexcept {
ox::UUIDStr uuidStr;
if (beginsWith(assetId, "uuid://")) {
return ctx.assetManager.reloadAsset(substr(assetId, 7));
assetId = substr(assetId, 7);
OX_REQUIRE(p, keel::uuidToPath(ctx, assetId));
} else {
auto const [uuid, uuidErr] = getUuid(ctx, assetId);
if (!uuidErr) {
return ctx.assetManager.reloadAsset(uuidStr);
} else {
return ctx.assetManager.reloadAsset(assetId);
uuidStr = uuid.toString();
assetId = uuidStr;
}
}
return ctx.assetManager.reloadAsset(assetId);
}
}
@@ -236,7 +238,7 @@ ox::Error setRomFs(Context &ctx, ox::UPtr<ox::FileSystem> &&fs) noexcept {
return buildUuidMap(ctx);
}
ox::Result<ox::UPtr<ox::FileSystem>> loadRomFs(ox::StringViewCR path) noexcept {
ox::Result<ox::UniquePtr<ox::FileSystem>> loadRomFs(ox::StringViewCR path) noexcept {
auto const lastDot = ox::lastIndexOf(path, '.');
if (!lastDot.error && substr(path, lastDot.value) == ".oxfs") {
OX_REQUIRE(rom, loadRom(path));