Page 1 of 1

Workflow to import extra data into the project

Posted: Mon Apr 27, 2020 1:42 am
by diegzumillo
Hi all
A while ago I made a python script that takes as input Tiled json files and outputs a sequence of C lines of code I can paste in a header of my project, for example:

Code: Select all

const ROMEntity ALLENTITIES [2] ={
    {3, 0, 0, 0, 0, TRUE, 2, 1, 4, 1},
    {5, 2, 1, 0, 0, TRUE, 2, 1, 15, 1}
};
const Room ALLROOMS[8]={
... etc
Today, while snooping around other projects' codes I noticed rescomp has a BIN option, apparently so I can import other stuff that aren't images or sounds.

What do I gain by using this system? I can see it has compression options, which is already very attractive, but anything else? also, how exactly do I make use of this? are there any caveats to keep in mind?

Re: Workflow to import extra data into the project

Posted: Mon Apr 27, 2020 4:53 pm
by Stef
Using BIN resource will just make your binary data (whatever it is internally) accessible through an u8 array in SGDK.
You can specify alignment, padding or stuff like that if you require and as you mentioned you can also pack it.
You can then unpack it using methods from tools.h unit :

Code: Select all

u32 unpack(u16 compression, u8 *src, u8 *dest);
or directly :

Code: Select all

u32 aplib_unpack(u8 *src, u8 *dest);
u32 lz4w_unpack(const u8 *src, u8 *dest);
Obviously you need to know the unpacked size and allocate the buffer to receive unpacked data first ;)

Re: Workflow to import extra data into the project

Posted: Mon Apr 27, 2020 8:16 pm
by diegzumillo
Thanks for clarifying!