mirror of
https://github.com/gbdev/rgbds.git
synced 2026-08-19 21:34:31 +00:00
Fix assertion failure on nonzero base palette ID without an attribute map or palette map
Also fix palette map IDs to wrap at 256, not at 8 like attributes
This commit is contained in:
+4
-2
@@ -427,7 +427,7 @@ void reverse() {
|
||||
|
||||
// The unsigned underflow for `palOfs` is intentional, since a nonzero
|
||||
// base palette ID may overflow and continue with IDs from 0.
|
||||
if (uint8_t palOfs = (palID - options.basePalID) & 0b111; palOfs >= palettes.size()) {
|
||||
if (uint8_t palOfs = (palID - options.basePalID) & 0xff; palOfs >= palettes.size()) {
|
||||
error(
|
||||
"Palette map references palette #%" PRIu8
|
||||
" at (%zu, %zu), but there %s only %zu palette%s",
|
||||
@@ -553,7 +553,9 @@ void reverse() {
|
||||
// This should have been enforced by the earlier checking.
|
||||
assume(tileOfs < nbTiles + options.trim);
|
||||
size_t palOfs =
|
||||
((palmap ? (*palmap)[index] : attribute & 0b111) - options.basePalID) & 0b111;
|
||||
(palmap ? ((*palmap)[index] - options.basePalID) & 0xff
|
||||
: attrmap ? (attribute - options.basePalID) & 0b111
|
||||
: 0);
|
||||
assume(palOfs < palettes.size()); // Should be ensured on data read
|
||||
|
||||
// We do not have data for tiles trimmed with `-x`, so assume they are "blank"
|
||||
|
||||
Reference in New Issue
Block a user