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

Macro to convert palette array entry to u16 #57

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pvmm
Copy link
Contributor

@pvmm pvmm commented Jan 31, 2025

Suppose you can't use VDP_SetPalette because your palette is incomplete. You can use this macro to solve this problem:

    // Set color index i from 1 to 13
    for (int i = 0; i < 13; ++i) {
        VDP_SetPaletteEntry(i + 1, RGB16_FromPal(palette, i));

@aoineko-fr
Copy link
Owner

aoineko-fr commented Jan 31, 2025

What is the problem exactly?

Why don't just use casting?

    // Set color index i from 1 to 13
    for (int i = 0; i < 13; ++i) {
        VDP_SetPaletteEntry(i + 1, ((u16*)palette)[i]);

@pvmm
Copy link
Contributor Author

pvmm commented Jan 31, 2025

I was confused by this formatting string Format: [0:5|green:3|0|red:3|0|blue:3] so I thought it was ordered differently. But I suppose an explicit conversion makes it more clear to the user?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants