From 978f2f9c4fd1bf8e2bf1c7d6526a8e26f8140c42 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 23 Dec 2023 01:50:26 -0600 Subject: [PATCH] [nostalgia/core/gba] Cleanup --- src/nostalgia/modules/core/src/gba/gfx.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/nostalgia/modules/core/src/gba/gfx.cpp b/src/nostalgia/modules/core/src/gba/gfx.cpp index 764c6bb1..aade7c37 100644 --- a/src/nostalgia/modules/core/src/gba/gfx.cpp +++ b/src/nostalgia/modules/core/src/gba/gfx.cpp @@ -96,31 +96,28 @@ constexpr ox::Error model(auto *io, ox::CommonPtrWith auto *t) // cannot be seriously optimized without preloading TileSheets. size_t sectionIdx = 0; if (t->targetBpp == t->bpp) { - TileSheetSetEntrySection const*section = &t->setEntry->sections[0]; - size_t writeIt = 0; uint16_t intermediate = 0; size_t const fourBpp = t->bpp == 4; - const auto handleTileMap = [t, &intermediate, §ion, §ionIdx, &writeIt, fourBpp] + const auto handleTileMap = [t, &intermediate, §ionIdx, fourBpp] (std::size_t i, uint8_t const*tile) { auto const tileIdx = static_cast((i * (2 * fourBpp)) / PixelsPerTile); if (!loadPixel(*t->setEntry, sectionIdx, tileIdx)) { return ox::Error{}; } - if (writeIt & 1) { // i is odd + if (i & 1) { // i is odd intermediate |= static_cast(*tile) << 8; - t->tileMap[writeIt / 2] = intermediate; + t->tileMap[t->tileWriteIdx] = intermediate; ++t->tileWriteIdx; } else { // i is even intermediate = *tile & 0x00ff; } - ++writeIt; return ox::Error{}; }; out = io->template field("tileMap", handleTileMap); } else if (t->targetBpp > t->bpp) { // 4 -> 8 bits - const auto handleTileMap = [t, §ionIdx](std::size_t writeIt, uint8_t const*tile) { + const auto handleTileMap = [t, §ionIdx](std::size_t i, uint8_t const*tile) { auto constexpr BytesPerTile4Bpp = 32; - auto const tileIdx = static_cast(writeIt / BytesPerTile4Bpp); + auto const tileIdx = static_cast(i / BytesPerTile4Bpp); if (!loadPixel(*t->setEntry, sectionIdx, tileIdx)) { return ox::Error{}; }