Scripting: Commands to read / write palettes#3692
Scripting: Commands to read / write palettes#3692Jengolus wants to merge 5 commits intomgba-emu:masterfrom
Conversation
|
First and foremost: There are several peculiar consistency issues with your code that imply you didn't review it yourself before submitting it. Is this code AI generated? Please review your own code for these issues before asking us to review it. Please also ensure you adhere to the existing coding and style guides used elsewhere in the code. Second, when it comes to opinionated matters:
Please bring this PR to non-draft quality before asking for further review. |
|
|
||
| if (palette == 0) { | ||
| return &mScriptValueNull; | ||
| return 0x8000; |
There was a problem hiding this comment.
What is the logic behind returning 0x8000 here?
There was a problem hiding this comment.
To my knowledge and testing, the highest bit is ignored, so I figured it would make a good error marker since readPalette cannot return a nil anymore.
src/core/scripting.c
Outdated
| } | ||
|
|
||
| return tbl; | ||
| return palette[index]; |
src/core/scripting.c
Outdated
| palette[4*index + i] = values[i]; | ||
| video->renderer->writePalette(video->renderer, 4*index + i, values[i]); | ||
| } | ||
| palette[index] = color; |
There was a problem hiding this comment.
This needs to be a STORE_16, but it also needs to be before the ->writePalette calls.
There was a problem hiding this comment.
Done for both readPalette and writePalette.
src/core/scripting.c
Outdated
| mSCRIPT_DEFINE_DOCSTRING("Read a 16-bit value from the given palette index (0-indexed)") | ||
| mSCRIPT_DEFINE_STRUCT_METHOD(mCore, readPalette) | ||
| mSCRIPT_DEFINE_DOCSTRING("Set the colors of the palette of the given index (0-indexed). Takes four integers encoding the colors in 5 bits each. See util.packColor. Does nothing on GBA.") | ||
| mSCRIPT_DEFINE_DOCSTRING("Write a 16-bit value to the given palette index (0-indexed)") |
There was a problem hiding this comment.
Why did you remove mention of format and util.packColor?
There was a problem hiding this comment.
I felt that mimicked the other docstrings more closely; added it back in now.
This PR adds scripting commands to manipulate color palettes and corresponding tests. They can be used as follows:
Motivation: There isn't currently any way to directly modify palettes, especially for SGB games. In particular, I am working on a socket interface between the pixel art software Aseprite and mGBA to preview images directly in the games they should appear in, but I cannot change the colors on SGB.
Design choices: