From 438b943a1abbf26fa739360551e738c25926127e Mon Sep 17 00:00:00 2001 From: Rangi Date: Fri, 11 Sep 2026 20:44:57 -0400 Subject: [PATCH] Make background tile IDs consistent whether or not deduplication is enabled Fixes #2072 --- src/gfx/process.cpp | 8 ++++---- test/gfx/reverse_bg.2bpp | Bin 0 -> 16 bytes test/gfx/reverse_bg.attrmap | Bin 0 -> 2 bytes test/gfx/reverse_bg.flags | 5 +++++ test/gfx/reverse_bg.pal | Bin 0 -> 8 bytes test/gfx/reverse_bg.tilemap | 1 + 6 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 test/gfx/reverse_bg.2bpp create mode 100644 test/gfx/reverse_bg.attrmap create mode 100644 test/gfx/reverse_bg.flags create mode 100644 test/gfx/reverse_bg.pal create mode 100644 test/gfx/reverse_bg.tilemap diff --git a/src/gfx/process.cpp b/src/gfx/process.cpp index 8fb4bd18..cfab0a5b 100644 --- a/src/gfx/process.cpp +++ b/src/gfx/process.cpp @@ -862,9 +862,9 @@ static UniqueTiles dedupTiles( attr.xFlip = false; attr.yFlip = false; attr.bank = 0; - attr.tileID = 0; + attr.tileID = options.baseTileIDs[attr.bank]; } else { - auto [tileID, matchType] = tiles.addTile({tile, palettes[attr.getPalID(mappings)]}); + auto [tileIdx, matchType] = tiles.addTile({tile, palettes[attr.getPalID(mappings)]}); if (inputWithoutOutput && matchType == TileData::NOPE) { error( @@ -877,8 +877,8 @@ static UniqueTiles dedupTiles( attr.xFlip = matchType == TileData::HFLIP || matchType == TileData::VHFLIP; attr.yFlip = matchType == TileData::VFLIP || matchType == TileData::VHFLIP; - attr.bank = tileID >= options.maxNbTiles[0]; - attr.tileID = (attr.bank ? tileID - options.maxNbTiles[0] : tileID) + attr.bank = tileIdx >= options.maxNbTiles[0]; + attr.tileID = (attr.bank ? tileIdx - options.maxNbTiles[0] : tileIdx) + options.baseTileIDs[attr.bank]; } } diff --git a/test/gfx/reverse_bg.2bpp b/test/gfx/reverse_bg.2bpp new file mode 100644 index 0000000000000000000000000000000000000000..b402019e2da6409ee3fbc76fa8ac4afaa1d21bbd GIT binary patch literal 16 OcmZQzfPnuD5C{Mh`~&>} literal 0 HcmV?d00001 diff --git a/test/gfx/reverse_bg.attrmap b/test/gfx/reverse_bg.attrmap new file mode 100644 index 0000000000000000000000000000000000000000..09f370e38f498a462e1ca0faa724559b6630c04f GIT binary patch literal 2 JcmZQz0000200961 literal 0 HcmV?d00001 diff --git a/test/gfx/reverse_bg.flags b/test/gfx/reverse_bg.flags new file mode 100644 index 00000000..d0afdf57 --- /dev/null +++ b/test/gfx/reverse_bg.flags @@ -0,0 +1,5 @@ +-b 16 +-u +-t reverse_bg.tilemap +-a reverse_bg.attrmap +-p reverse_bg.pal diff --git a/test/gfx/reverse_bg.pal b/test/gfx/reverse_bg.pal new file mode 100644 index 0000000000000000000000000000000000000000..4bb5d33d9a4ed2e9d6ecd0499528d0295f8b434b GIT binary patch literal 8 Ncmb1V_+S4Y2mljn1)2Z= literal 0 HcmV?d00001 diff --git a/test/gfx/reverse_bg.tilemap b/test/gfx/reverse_bg.tilemap new file mode 100644 index 00000000..46581f1a --- /dev/null +++ b/test/gfx/reverse_bg.tilemap @@ -0,0 +1 @@ + \ No newline at end of file