[nostalgia/core] Add valid and repair functions for PaletteV3

This commit is contained in:
Gary Talent 2024-06-01 13:56:15 -05:00
parent a2cec10cb6
commit 3cb3bc122b

View File

@ -74,6 +74,18 @@ constexpr bool valid(Palette const&p) noexcept {
});
}
[[nodiscard]]
constexpr bool repair(Palette &p) noexcept {
auto const colors = p.colorInfo.size();
if (p.pages.size() == 0) {
p.pages.emplace_back();
}
for (auto &page : p.pages) {
page.resize(colors);
}
return true;
}
[[nodiscard]]
constexpr Color16 color(Palette const&pal, size_t page, size_t idx) noexcept {
if (page < pal.pages.size() && idx < pal.pages[page].size()) [[likely]] {