mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Fix bank increment never happening due to unsigned overflow
This commit is contained in:
@@ -695,12 +695,6 @@ static void outputUnoptimizedMaps(
|
|||||||
uint8_t tileID = 0;
|
uint8_t tileID = 0;
|
||||||
uint8_t bank = 0;
|
uint8_t bank = 0;
|
||||||
for (AttrmapEntry const &attr : attrmap) {
|
for (AttrmapEntry const &attr : attrmap) {
|
||||||
if (tileID == options.maxNbTiles[bank]) {
|
|
||||||
assume(bank == 0);
|
|
||||||
bank = 1;
|
|
||||||
tileID = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tilemapOutput.has_value()) {
|
if (tilemapOutput.has_value()) {
|
||||||
(*tilemapOutput)
|
(*tilemapOutput)
|
||||||
->sputc((attr.isBackgroundTile() ? 0 : tileID) + options.baseTileIDs[bank]);
|
->sputc((attr.isBackgroundTile() ? 0 : tileID) + options.baseTileIDs[bank]);
|
||||||
@@ -714,8 +708,17 @@ static void outputUnoptimizedMaps(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Background tiles are skipped in the tile data, so they should be skipped in the maps too.
|
// Background tiles are skipped in the tile data, so they should be skipped in the maps too.
|
||||||
if (!attr.isBackgroundTile()) {
|
if (attr.isBackgroundTile()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare with `maxNbTiles` *before* incrementing, due to unsigned overflow!
|
||||||
|
if (tileID + 1 < options.maxNbTiles[bank]) {
|
||||||
++tileID;
|
++tileID;
|
||||||
|
} else {
|
||||||
|
assume(bank == 0);
|
||||||
|
bank = 1;
|
||||||
|
tileID = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
test/gfx/unoptimized-full.2bpp
Normal file
BIN
test/gfx/unoptimized-full.2bpp
Normal file
Binary file not shown.
BIN
test/gfx/unoptimized-full.attrmap
Normal file
BIN
test/gfx/unoptimized-full.attrmap
Normal file
Binary file not shown.
1
test/gfx/unoptimized-full.flags
Normal file
1
test/gfx/unoptimized-full.flags
Normal file
@@ -0,0 +1 @@
|
|||||||
|
-N 256,256
|
||||||
BIN
test/gfx/unoptimized-full.pal
Normal file
BIN
test/gfx/unoptimized-full.pal
Normal file
Binary file not shown.
BIN
test/gfx/unoptimized-full.png
Normal file
BIN
test/gfx/unoptimized-full.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
BIN
test/gfx/unoptimized-full.tilemap
Normal file
BIN
test/gfx/unoptimized-full.tilemap
Normal file
Binary file not shown.
Reference in New Issue
Block a user