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

Fix Skybox star colors #608

Merged
merged 2 commits into from
May 31, 2024
Merged

Conversation

Archez
Copy link
Contributor

@Archez Archez commented May 30, 2024

The Skybox star colors were appearing generally pinkish due to endianness ordering with Color_RGBA8_u32

typedef union {
    struct {
#ifdef IS_BIGENDIAN
        uint8_t r, g, b, a;
#else
        uint8_t a, b, g, r;
#endif
    };
    uint32_t rgba;
} Color_RGBA8_u32;

To fix this I've added designator field names so that the values are explicitly tied to the correct field regardless of the machines native endianness.

I would've preferred a macro solution as a wrapper around all these variables, but I couldn't come up with something elegant due to the initializer brackets. Anything to get around that was equally as invasive as adding these designators, but less readable.

Edit: Using a solution that switches Color_RGBA8_u32 -> Color_RGBA8 and gDPSetColor -> gDPSetPrimColor

Screen Shot 2024-05-29 at 9 49 29 PM

Fixes #570

Build Artifacts

Copy link
Contributor

@garrettjoecox garrettjoecox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would another solution just be to use Color_RGBA8 instead?

@Archez
Copy link
Contributor Author

Archez commented May 30, 2024

Would another solution just be to use Color_RGBA8 instead?

Color_RGBA8_u32 is a union with u32. That u32 value is what gets passed to gDPSetColor

Color_RGBA8 does not have that union type, so we would then have to bitpack all the individual values back together for gDPSetColor, or switch to using gDPSetPrimColor which handles the packing inside.

Not sure which is more desirable amongst all this.

@Archez
Copy link
Contributor Author

Archez commented May 30, 2024

@garrettjoecox heres what RGBA8 with bitpacking could look like Archez@2010595
Or gDPSetPrimColor Archez@e8f1ff4

Thoughts? (and of course adding 2S2H style comments)

@garrettjoecox
Copy link
Contributor

garrettjoecox commented May 30, 2024

@garrettjoecox heres what RGBA8 with bitpacking could look like Archez@2010595 Or gDPSetPrimColor Archez@e8f1ff4

Thoughts? (and of course adding 2S2H style comments)

I think I prefer either of these over the designators. Are we going to run into this issue anywhere else? Or is this a fairly isolated issue?

@Archez
Copy link
Contributor Author

Archez commented May 30, 2024

I think I prefer either of these over the designators. Are we going to run into this issue anywhere else? Or is this a fairly isolated issue?

This issue only occurs when an initializer list is used with Color_RGBA8_u32 which these two instances are the only ones in the code base.

@Archez
Copy link
Contributor Author

Archez commented May 30, 2024

Updated for the alternate solution

@Archez Archez added the rika label May 30, 2024
@louist103 louist103 merged commit 73c468d into HarbourMasters:develop-rika May 31, 2024
5 checks passed
@Archez Archez deleted the fix-star-colors branch June 26, 2024 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants