Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reverse_1bit RGBGFX test #1555

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/gfx/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -755,9 +758,7 @@ class TileData {
hashBitplanes(bitplanes, _hash);

_data[writeIndex++] = bitplanes & 0xFF;
if (options.bitDepth == 2) {
_data[writeIndex++] = bitplanes >> 8;
}
_data[writeIndex++] = bitplanes >> 8;
}
}

Expand Down Expand Up @@ -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]);
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions test/gfx/reverse_1bit.1bpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
 @L������F@ 
Binary file added test/gfx/reverse_1bit.attrmap
Binary file not shown.
3 changes: 3 additions & 0 deletions test/gfx/reverse_1bit.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-m
-t reverse_1bit.tilemap
-a reverse_1bit.attrmap
Binary file added test/gfx/reverse_1bit.tilemap
Binary file not shown.