sm64tools
sm64tools copied to clipboard
Fix memory allocation issue for ci textures
When using
./n64graphics -i tex.rgba.ci4.inc16.c -g tex.rgba16.ci4.png -f ci4 -s u8 -c rgba16 -p tex_gen.rgba16.ci4.inc.c -v
This results in a memory next error. Due to this line:
raw16_size = config.width * config.height * config.pal_format.depth / 8;
It's still using the default of 32x32 to allocate memory. However, this texture is 128x32. Therefore, we need to read the .png's dimension metadata earlier to allocate memory based on that.
Adds -m argument (stands for magic number or magic filler) to specify what value to fill palettes with. This way the tail end of the palette will match.
CI4 likely needs a bit of testing. However, CI8s should be working properly now.
I think I just need to modify the documentation a bit and then this PR is good to go.