From 5aa7067876fa28aef663dba4c074bc19b589bc2f Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 15 Jul 2026 22:28:08 -0400 Subject: [PATCH] Comment on how overflow to 0 is explicitly allowed for tile and palette IDs --- src/gfx/process.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gfx/process.cpp b/src/gfx/process.cpp index 7b13c92e..25c0c24f 100644 --- a/src/gfx/process.cpp +++ b/src/gfx/process.cpp @@ -699,6 +699,8 @@ static void outputUnoptimizedMaps( // processed, since there cannot be more tiles than could fit in both banks. 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()) { uint8_t tileID = (attr.isBackgroundTile() ? 0 : tileIdx) + options.baseTileIDs[bank]; (*tilemapOutput)->sputc(tileID); @@ -904,6 +906,8 @@ static void for (AttrmapEntry const &entry : attrmap) { uint8_t attr = entry.xFlip << 5 | entry.yFlip << 6; 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; output->sputc(attr); } @@ -919,6 +923,8 @@ static void } 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); } }