-
Notifications
You must be signed in to change notification settings - Fork 159
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 does not work as expected #19
Comments
Hmm, it turns out the 3rd param to store<u32>(w4.PALETTE, 0xff0000, 0); // light
store<u32>(w4.PALETTE, 0xe30000, 4); // red
store<u32>(w4.PALETTE, 0x306850, 8); // green
store<u32>(w4.PALETTE, 0x000000, 12); // black I'll update the docs accordingly. |
Yeah, it is not very use-friendly... What about making it explicit that only four colors are supported?: store<u32>(w4.PALETTE_1, 0xff0000); // light
store<u32>(w4.PALETTE_2, 0xe30000); // red
store<u32>(w4.PALETTE_3, 0x306850); // green
store<u32>(w4.PALETTE_4, 0x000000); // black Some more high-level API wouldn't be quite bad, too: w4.setPallete(0xff0000, 1);
w4.setPallete(0xe30000, 2);
w4.setPallete(0x306850, 3);
w4.setPallete(0x000000, 4); Or even?: w4.setPallete1(0xff0000);
w4.setPallete2(0xe30000);
w4.setPallete3(0x306850);
w4.setPallete4(0x000000);
// or...
w4.setPallete(0xff0000, 0xe30000, 0x306850, 0x000000); |
I think we should also ask the AssemblyScript folks if there's a bug with the 3rd param to |
Could you collaborate more? The AS community is very active on Discord, that would be the best plate where to ask. |
In the |
Cool! |
So unfortunately the AS behavior is intended and the documentation was just wrong. I changed the WASM-4 documentation to use |
In Snake, I have already used
But I find it plain ugly. Especially in JS-related languages such as AS, things like Another benefit of using PALETTE1-4 would be preventing developers from writing:
It is really not a big deal, but IMHO it would increase the Developer Experience. What speaks against that? |
There are a lot of another ways to damage WASM memory. https://github.com/AssemblyScript/assemblyscript/blob/main/tests/compiler/std/pointer.ts |
It should be store<u32>(w4.PALETTE, 0xe0f8cf, 0 * sizeof<u32>()); // light
store<u32>(w4.PALETTE, 0xe30000, 1 * sizeof<u32>()); // red
store<u32>(w4.PALETTE, 0x306850, 2 * sizeof<u32>()); // green
store<u32>(w4.PALETTE, 0x000000, 3 * sizeof<u32>()); // black |
Consider this AS code:
I would expect the background colored in light green, but some kind of violet appears:
Works fine when the other three colors are not set.
The text was updated successfully, but these errors were encountered: