[nostalgia/core/gba] Fix partial tilesheet loading overrun
All checks were successful
Build / build (push) Successful in 3m11s

This commit is contained in:
Gary Talent 2025-01-13 22:03:36 -06:00
parent 4e4d8d2c3f
commit 151d7c5736

View File

@ -99,10 +99,10 @@ ox::Error loadBgTileSheet(
size_t const tileCnt) noexcept {
size_t const bppMod = ts.bpp == 4;
size_t const bytesPerTile = PixelsPerTile >> bppMod;
auto const pixCnt = tileCnt * bytesPerTile;
auto const cnt = (tileCnt * bytesPerTile) / 2;
auto const srcPxIdx = srcTileIdx * bytesPerTile;
auto const dstPxIdx = (dstTileIdx * bytesPerTile) / 2;
for (size_t i = 0; i < pixCnt; ++i) {
for (size_t i = 0; i < cnt; ++i) {
auto const srcIdx = srcPxIdx + i * 2;
auto const p1 = static_cast<uint16_t>(ts.pixels[srcIdx]);
auto const p2 = static_cast<uint16_t>(ts.pixels[srcIdx + 1]);