mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-01 03:18:40 +00:00
Comment on how overflow to 0 is explicitly allowed for tile and palette IDs
This commit is contained in:
@@ -699,6 +699,8 @@ static void outputUnoptimizedMaps(
|
|||||||
// processed, since there cannot be more tiles than could fit in both banks.
|
// processed, since there cannot be more tiles than could fit in both banks.
|
||||||
assume(bank < 2);
|
assume(bank < 2);
|
||||||
|
|
||||||
|
// The unsigned overflow for `tileID` and `palID` is intentional, since
|
||||||
|
// nonzero base IDs may overflow beyond 255 and continue with IDs from 0.
|
||||||
if (tilemapOutput.has_value()) {
|
if (tilemapOutput.has_value()) {
|
||||||
uint8_t tileID = (attr.isBackgroundTile() ? 0 : tileIdx) + options.baseTileIDs[bank];
|
uint8_t tileID = (attr.isBackgroundTile() ? 0 : tileIdx) + options.baseTileIDs[bank];
|
||||||
(*tilemapOutput)->sputc(tileID);
|
(*tilemapOutput)->sputc(tileID);
|
||||||
@@ -904,6 +906,8 @@ static void
|
|||||||
for (AttrmapEntry const &entry : attrmap) {
|
for (AttrmapEntry const &entry : attrmap) {
|
||||||
uint8_t attr = entry.xFlip << 5 | entry.yFlip << 6;
|
uint8_t attr = entry.xFlip << 5 | entry.yFlip << 6;
|
||||||
attr |= entry.bank << 3;
|
attr |= entry.bank << 3;
|
||||||
|
// The unsigned underflow for the palette ID is intentional, since a
|
||||||
|
// nonzero base palette ID may overflow and continue with IDs from 0.
|
||||||
attr |= (entry.getPalID(mappings) + options.basePalID) & 0b111;
|
attr |= (entry.getPalID(mappings) + options.basePalID) & 0b111;
|
||||||
output->sputc(attr);
|
output->sputc(attr);
|
||||||
}
|
}
|
||||||
@@ -919,6 +923,8 @@ static void
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (AttrmapEntry const &entry : attrmap) {
|
for (AttrmapEntry const &entry : attrmap) {
|
||||||
|
// The unsigned underflow for the palette ID is intentional, since a
|
||||||
|
// nonzero base palette ID may overflow and continue with IDs from 0.
|
||||||
output->sputc(entry.getPalID(mappings) + options.basePalID);
|
output->sputc(entry.getPalID(mappings) + options.basePalID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user