Add reverse_1bit RGBGFX test (#1555)

Fixes a bug to always use 2bpp `_data` in `TileData`
This commit is contained in:
Sylvie
2024-11-24 19:30:49 -05:00
committed by GitHub
parent cb546f0cd8
commit e0ee9dc3ad
5 changed files with 16 additions and 4 deletions

View File

@@ -712,6 +712,9 @@ static void hashBitplanes(uint16_t bitplanes, uint16_t &hash) {
}
class TileData {
// Importantly, `TileData` is **always** 2bpp.
// If the active bit depth is 1bpp, all tiles are processed as 2bpp nonetheless, but emitted as 1bpp.
// This massively simplifies internal processing, since bit depth is always identical outside of I/O / serialization boundaries.
std::array<uint8_t, 16> _data;
// The hash is a bit lax: it's the XOR of all lines, and every other nibble is identical
// if horizontal mirroring is in effect. It should still be a reasonable tie-breaker in
@@ -755,11 +758,9 @@ public:
hashBitplanes(bitplanes, _hash);
_data[writeIndex++] = bitplanes & 0xFF;
if (options.bitDepth == 2) {
_data[writeIndex++] = bitplanes >> 8;
}
}
}
auto const &data() const { return _data; }
uint16_t hash() const { return _hash; }
@@ -1032,7 +1033,14 @@ static void outputTileData(UniqueTiles const &tiles) {
TileData const *tile = *iter;
assume(tile->tileID == tileID);
++tileID;
output->sputn(reinterpret_cast<char const *>(tile->data().data()), options.bitDepth * 8);
if (options.bitDepth == 2) {
output->sputn(reinterpret_cast<char const *>(tile->data().data()), 16);
} else {
assume(options.bitDepth == 1);
for (size_t y = 0; y < 8; ++y) {
output->sputc(tile->data()[y * 2]);
}
}
}
}

View File

@@ -0,0 +1 @@
 @L血€€€宇@ 

Binary file not shown.

View File

@@ -0,0 +1,3 @@
-m
-t reverse_1bit.tilemap
-a reverse_1bit.attrmap

Binary file not shown.