Fix a flaky/random-seed rgbgfx_test test failure

Commit 21eaa2d2cc missed some
intentional unsigned underflow that is needed to set `nbTilesInBank`.
Without it, some of the randomly-seeded RGBGFX tests, such as
`./rgbgfx_test seed8.bin -b 207 -N 54,256`, can fail with "Color
mismatch after round-tripping" errors.
This commit is contained in:
Rangi
2026-07-13 21:31:05 -04:00
parent 59b6b15106
commit 8b951bc047
+5 -3
View File
@@ -320,9 +320,11 @@ void reverse() {
);
}
} else {
if (uint8_t tileID = (*tilemap)[index];
tileID >= nbTilesInBank[bank] + options.baseTileIDs[bank]) {
nbTilesInBank[bank] = tileID - options.baseTileIDs[bank] + 1;
// The unsigned underflow for `tileOfs` is intentional, since a nonzero
// base tile ID may overflow and continue with IDs from 0.
if (uint8_t tileOfs = (*tilemap)[index] - options.baseTileIDs[bank];
tileOfs >= nbTilesInBank[bank]) {
nbTilesInBank[bank] = tileOfs + 1;
}
}
}