Refactor expression for clarity

`tileData[realY + 1 % options.bitDepth]` relied on order of
operations and the fact that `1 % 1 == 0` but `1 % 2 == 1` for
correct indexing. However, it was not obvious at first glance,
and confusable with the more common `(base + offset) % size`
pattern. (And would need changing anyway if we ever support 4bpp.)
This commit is contained in:
Rangi
2026-07-10 14:30:25 -04:00
parent 255cd7f7f6
commit 7b39bcd412
+1 -1
View File
@@ -531,7 +531,7 @@ void reverse() {
// If vertically mirrored, fetch the bytes from the other end
uint8_t realY = (attribute & 0x40 ? 7 - y : y) * options.bitDepth;
uint8_t bitplane0 = tileData[realY];
uint8_t bitplane1 = tileData[realY + 1 % options.bitDepth];
uint8_t bitplane1 = options.bitDepth == 2 ? tileData[realY + 1] : bitplane0;
if (attribute & 0x20) { // Handle horizontal flip
bitplane0 = flipTable[bitplane0];
bitplane1 = flipTable[bitplane1];