From 3abcd0af8f34b5cf3d1b1af1fbf95d1133d44403 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 30 Nov 2022 20:47:02 -0600 Subject: [PATCH] [nostalgia/tools/pack] Add GbaPlatSpec --- src/nostalgia/tools/pack/pack.hpp | 77 ++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/src/nostalgia/tools/pack/pack.hpp b/src/nostalgia/tools/pack/pack.hpp index 490a9fc2..56885538 100644 --- a/src/nostalgia/tools/pack/pack.hpp +++ b/src/nostalgia/tools/pack/pack.hpp @@ -10,7 +10,82 @@ namespace core { class TypeStore; } -using GbaPreloader = ox::Preloader; +struct GbaPlatSpec { + using PtrType = uint32_t; + using size_t = uint32_t; + + static constexpr auto PtrAlign = 4; + static constexpr PtrType RomStart = 0x08000000; + + [[nodiscard]] + static constexpr std::size_t alignOf(const bool) noexcept { + return 1; + } + + [[nodiscard]] + static constexpr std::size_t alignOf(const uint8_t) noexcept { + return 1; + } + + [[nodiscard]] + static constexpr std::size_t alignOf(const uint16_t) noexcept { + return 2; + } + + [[nodiscard]] + static constexpr std::size_t alignOf(const uint32_t) noexcept { + return 4; + } + + [[nodiscard]] + static constexpr std::size_t alignOf(const uint64_t) noexcept { + return 8; + } + + [[nodiscard]] + static constexpr std::size_t alignOf(const int8_t) noexcept { + return 1; + } + + [[nodiscard]] + static constexpr std::size_t alignOf(const int16_t) noexcept { + return 2; + } + + [[nodiscard]] + static constexpr std::size_t alignOf(const int32_t) noexcept { + return 4; + } + + [[nodiscard]] + static constexpr std::size_t alignOf(const int64_t) noexcept { + return 8; + } + + [[nodiscard]] + static constexpr std::size_t alignOf(auto*) noexcept { + return 4; + } + + [[nodiscard]] + static constexpr std::size_t alignOf(const auto*) noexcept { + return 4; + } + + [[nodiscard]] + static constexpr std::size_t alignOf(const auto &v) noexcept { + ox::AlignmentCatcher c; + oxAssert(model(c.interface(), &v), "Could not get alignment for type"); + return c.biggestAlignment; + } + + [[nodiscard]] + static constexpr auto correctEndianness(auto v) noexcept { + return ox::toLittleEndian(v); + } +}; + +using GbaPreloader = ox::Preloader; ox::Error appendBinary(ox::Buffer *binBuff, ox::Buffer *fsBuff, GbaPreloader *pl) noexcept;