Workflow to import extra data into the project

SGDK only sub forum

Moderator: Stef

Post Reply
diegzumillo
Interested
Posts: 15
Joined: Sun Sep 08, 2019 6:35 pm

Workflow to import extra data into the project

Post by diegzumillo » Mon Apr 27, 2020 1:42 am

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?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Workflow to import extra data into the project

Post by Stef » Mon Apr 27, 2020 4:53 pm

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 ;)

diegzumillo
Interested
Posts: 15
Joined: Sun Sep 08, 2019 6:35 pm

Re: Workflow to import extra data into the project

Post by diegzumillo » Mon Apr 27, 2020 8:16 pm

Thanks for clarifying!

Post Reply