[nostalgia/core/gba] Fix partial tilesheet loading overrun
All checks were successful
Build / build (push) Successful in 3m11s
All checks were successful
Build / build (push) Successful in 3m11s
This commit is contained in:
parent
4e4d8d2c3f
commit
151d7c5736
@ -99,10 +99,10 @@ ox::Error loadBgTileSheet(
|
|||||||
size_t const tileCnt) noexcept {
|
size_t const tileCnt) noexcept {
|
||||||
size_t const bppMod = ts.bpp == 4;
|
size_t const bppMod = ts.bpp == 4;
|
||||||
size_t const bytesPerTile = PixelsPerTile >> bppMod;
|
size_t const bytesPerTile = PixelsPerTile >> bppMod;
|
||||||
auto const pixCnt = tileCnt * bytesPerTile;
|
auto const cnt = (tileCnt * bytesPerTile) / 2;
|
||||||
auto const srcPxIdx = srcTileIdx * bytesPerTile;
|
auto const srcPxIdx = srcTileIdx * bytesPerTile;
|
||||||
auto const dstPxIdx = (dstTileIdx * bytesPerTile) / 2;
|
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 srcIdx = srcPxIdx + i * 2;
|
||||||
auto const p1 = static_cast<uint16_t>(ts.pixels[srcIdx]);
|
auto const p1 = static_cast<uint16_t>(ts.pixels[srcIdx]);
|
||||||
auto const p2 = static_cast<uint16_t>(ts.pixels[srcIdx + 1]);
|
auto const p2 = static_cast<uint16_t>(ts.pixels[srcIdx + 1]);
|
||||||
|
Loading…
Reference in New Issue
Block a user