mirror of
https://github.com/gbdev/rgbds.git
synced 2026-08-19 05:14:31 +00:00
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:
+5
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user