Remove byte order logic from half-transparency lookups #6872
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I think I see two issues. First, here is where we draw the half-transparent rectangle.
devilutionX/Source/engine.cpp
Lines 54 to 59 in 6648f08
When we make use of this lookup table on big-endian systems, we swap the 16-bit values we pass into the lookup, but the 16-bit values themselves are in the system's native endian order. However, since we are interpreting the original pixel as a native-endian 32-bit value and also assigning
*pix
as a native-endian 32-bit value, I think it would be easiest to use native-endian order throughout. The little-endian logic doesn't swap any bytes so we can just remove the special case for big-endian systems.And that just leaves us with making sure that we build the lookup table using native-endian order...
devilutionX/Source/engine/palette.cpp
Lines 110 to 115 in 6648f08
On big-endian systems,
i
is placed beforej
when computingindex
, butpaletteTransparencyLookup[0][j]
is placed beforepaletteTransparencyLookup[0][i]
regardless of the endian order. This swaps the bytes on big-endian systems when you use this lookup table. Since we want to use native-endian order, we don't need to swap any bytes on any systems. Therefore, once again, we should be able to remove the special case for big-endian systems since we currently don't swap the bytes on little-endian systems.This resolves #6871 (I assume)