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

Palette order is rotated when specifying palettes with the hex format #1519

Open
nitro2k01 opened this issue Sep 26, 2024 · 2 comments
Open
Labels
bug Unexpected behavior / crashes; to be fixed ASAP! rgbgfx This affects RGBGFX
Milestone

Comments

@nitro2k01
Copy link
Member

When specifying an explicit palette using -c hex it seems the palette entries are rotated within the palette. In particular it seems if the input order is 0123 the output order is 3012.

For example, I would expect the input data: (This is test1.hex)

ffffff
b2b2b2
4c4c4c
000000

to output the following GBC format data, with white first and black last:

FF7F D65A 2925 0000

However, the actual output is this:

0000 FF7F D65A 2925

Included are two test images and three test palettes, for a total of 6 test commands. The reason for all of these tests is to test whether the order was affected by either the first color seen in the image, or the brightness of the palettes. However, it seems to consistently rotate the order as described above, so really only 3 of the test cases are relevant, as the output from the black and white tests is identical.

Command invocation:

rgbgfx -o white-test1.2bpp -p white-test1.pal -b128 -m -u -c hex:test1.hex white-bg.png
rgbgfx -o white-test2.2bpp -p white-test2.pal -b128 -m -u -c hex:test2.hex white-bg.png
rgbgfx -o white-test3.2bpp -p white-test3.pal -b128 -m -u -c hex:test3.hex white-bg.png
rgbgfx -o black-test1.2bpp -p black-test1.pal -b128 -m -u -c hex:test1.hex black-bg.png
rgbgfx -o black-test2.2bpp -p black-test2.pal -b128 -m -u -c hex:test2.hex black-bg.png
rgbgfx -o black-test3.2bpp -p black-test3.pal -b128 -m -u -c hex:test3.hex black-bg.png

Here's the input and output I observed during for the other test cases:

test2.hex

ffffff
4c4c4c
b2b2b2
000000

black-test2.pal/white-test2.pal

0000 FF7F 2925 D65A

test3.hex

000000
ffffff
4c4c4c
b2b2b2

black-test3.pal/white-test3.pal

D65A 0000 FF7F 2925

Notes:

  • In all tested cases, the input order 0123 is transformed to the output order is 3012. The brightness or order the colors are seen in the image don't seem to matter.
  • Specifying a palette with -c gbc preserves the order in the input file in all my tests. I have not tested other palette formats than those.
  • The generated tile data has been internally consistent with the palette data in all my tests, so used as is the data would create the correct image on the screen. (But in my use case it caused other problems with code that assumed that the order was as specified.)

Test cases:

gfxtest.zip

@Rangi42 Rangi42 added bug Unexpected behavior / crashes; to be fixed ASAP! rgbgfx This affects RGBGFX labels Sep 26, 2024
@Rangi42 Rangi42 added this to the v0.9.0 milestone Sep 26, 2024
@Rangi42
Copy link
Contributor

Rangi42 commented Sep 26, 2024

Very thorough report and testing, thank you!

@Rangi42
Copy link
Contributor

Rangi42 commented Sep 26, 2024

Note to self: the HEX palette parsing function is very similar to the GPL one, so double-check both of those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behavior / crashes; to be fixed ASAP! rgbgfx This affects RGBGFX
Projects
None yet
Development

No branches or pull requests

2 participants