sm64tools icon indicating copy to clipboard operation
sm64tools copied to clipboard

Fix memory allocation issue for ci textures

Open MegaMech opened this issue 2 years ago • 2 comments

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.

MegaMech avatar Jan 29 '23 07:01 MegaMech

CI4 likely needs a bit of testing. However, CI8s should be working properly now.

MegaMech avatar Feb 03 '23 05:02 MegaMech

I think I just need to modify the documentation a bit and then this PR is good to go.

MegaMech avatar Feb 06 '23 04:02 MegaMech