diff --git a/src/nostalgia/modules/core/src/gba/gfx.cpp b/src/nostalgia/modules/core/src/gba/gfx.cpp index 59e25287..3d58ce57 100644 --- a/src/nostalgia/modules/core/src/gba/gfx.cpp +++ b/src/nostalgia/modules/core/src/gba/gfx.cpp @@ -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(ts.pixels[srcIdx]); auto const p2 = static_cast(ts.pixels[srcIdx + 1]);