SGDK Rescomp

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
@FedericoTech
Newbie
Posts: 2
Joined: Thu Dec 03, 2015 2:41 am

SGDK Rescomp

Post by @FedericoTech » Thu Dec 03, 2015 2:58 am

Hi friends.

I'm new in genesis developing.
I'm doing some experiments with SGDK.

I want to implement a way to load tilemaps. given the MAP rescomp plugin is not implemented yet, I'm trying through BIN rescomp plugin.

The rescomp.text document says like below:

BIN name file align salign fill

name BIN data variable name
file path of the data file to convert to binary data array
align memory address alignment for generated data array (default is 2)
salign size alignment for the generated data array (default is 2)
fill fill value for the size alignment (default is 0)

In my project I'm using a line like this: BIN stage1_map "stage1.map" 2 2 0

stage1.map is a binary file which contains int values which are the indexes of the tiles as you know.

What I obtain when I run my program is an u8 array which has a zero value in between eachother values.

for example if my file contains the values 1, 2, 3, 4, 5, 5, 6, 7, the array I get contains 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7.

what I'd like to get would be a u16 array with no that zeroes.

I think the problem is that I don't understand how the params align, saling and fill work.

Can somebody help me with this?

Thanks in advance.
@FedericoTech.

@FedericoTech
Newbie
Posts: 2
Joined: Thu Dec 03, 2015 2:41 am

Re: SGDK Rescomp

Post by @FedericoTech » Thu Dec 03, 2015 9:46 am

Ok, although I don't know how to use BIN, I see it's working properly. there are zeroes in between because data is 16 bits.

Here my solution to read bytes:

int i;
for(i = 0; i < FILE_SIZE; i+=2)
{
u16 iData = (stage1_map<<8)|stage1_map[i+1];

//do something with this
}
Last edited by @FedericoTech on Thu Dec 03, 2015 10:45 am, edited 1 time in total.

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

Re: SGDK Rescomp

Post by Stef » Thu Dec 03, 2015 10:40 am

Yep, that should make any difference. Just cast the obtained data as u16 (BIN always generated u8 data) and that is =)

Post Reply