Tutorial sample file problem

SGDK only sub forum

Moderator: Stef

Post Reply
billybob884
Interested
Posts: 18
Joined: Tue Aug 21, 2018 1:03 pm

Tutorial sample file problem

Post by billybob884 » Sat Sep 08, 2018 7:42 pm

Hello, new user here,
I'm going through the tutorials for the first time and wanted to report a small problem with the sample project provided on tutorial #3 (Tile and tilemap).

The project fails to compile due to errors:

Code: Select all

main.c|27|error: 'APLAN' undeclared (first use in this function)|
main.c|35|error: 'BPLAN' undeclared (first use in this function)|
...ect
This is caused by functions VDP_setTileMapXY and VDP_fillTileMapRect using APLAN and BPLAN, where they should be using PLAN_A and PLAN_B

It took me a minute to figure out, correcting the download file should make things easier for other first timers.

Thank you!

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

Re: Tutorial sample file problem

Post by Stef » Mon Sep 10, 2018 2:09 pm

Tutorials are terribly outdated unfortunately :-/
You may try to dig into the given sample (in sample folder), you will have more up to date example to work from :)

billybob884
Interested
Posts: 18
Joined: Tue Aug 21, 2018 1:03 pm

Re: Tutorial sample file problem

Post by billybob884 » Wed Sep 12, 2018 2:18 am

Yes, I've seen people say they are outdated (which is fine! I'm grateful for what is provided), I mostly wanted to post the answer here for any other new people that might search for it.

Side question: I'm looking at the "sprite" sample program, I'm trying to understand the syntax for the "sprite.res" resource file, can you point me to where it is in the documentation? I can't seem to find it.

Code: Select all

SPRITE enemies_sprite "sprite/enemies.png" 6 4 FAST 5
I'm guessing 6 and 4 are the width/height per frame (in tiles), but I'm not sure what the "fast" and "5" define.

Thank you for your help

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

Re: Tutorial sample file problem

Post by Stef » Wed Sep 12, 2018 7:48 am

Ok i understand, thanks for providing the fix to these outdated tutorials, i really need to update them (i repeat that everytime ^^).
Oh yeah, the document you're looking for is rescomp.txt, you can find in the 'bin' folder (rescomp is the resource compiler of SGDK) :)

billybob884
Interested
Posts: 18
Joined: Tue Aug 21, 2018 1:03 pm

Re: Tutorial sample file problem

Post by billybob884 » Wed Sep 19, 2018 6:17 pm

Hello, I have another question about rescomp. The list of structures says that maps are not yet supported:

Code: Select all

https://github.com/Stephane-D/SGDK/blob/master/bin/rescomp.txt

MAP
---
NOT YET SUPPORTED !
Take an map file as input and transform it in SGDK Map structure.
Map is used to define background plan tilemap data.
I've been reviewing the example provided here: https://gendev.spritesmind.net/forum/vi ... =19&t=2771
How was this map created? By hand?

Thank you for your help

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

Re: Tutorial sample file problem

Post by Stef » Thu Sep 20, 2018 12:12 pm

Probably using others tools !

But you know that an IMAGE resource internally contains a tilemap, so if you feed rescomp with a big PNG image (2048x2048 for instance) respecting the tile limit (no more than 2048 different tiles) then it will build the 256x256 map out of it :)

billybob884
Interested
Posts: 18
Joined: Tue Aug 21, 2018 1:03 pm

Re: Tutorial sample file problem

Post by billybob884 » Sun Sep 23, 2018 4:15 pm

I understand IMAGE contains a tilemap, so what I'm trying to do is modify kcowolf's scrolling demo to use images instead of the hard-coded map/tiles. Looking at this example project, kcowolf passes an array (containing the tilemap) directly to a MAP structure, and then the rest of the code handles drawing rows & columns:

Code: Select all

fgMap.tilemap = (u16*) TILEMAP_TEST_FG_MAP;
So I'm guessing the "tilemap" attribute is stored as an array. What I tried to do was instead pass it the "map" attribute from an image resource (FGimage):

Code: Select all

fgMap.tilemap = (u16*) FGimage.map;
But this just renders as garbage. How are the MAP structure's "tilemap" and the IMAGE structure's "map" attribute data stored? Are they interchangeable?

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

Re: Tutorial sample file problem

Post by Stef » Mon Sep 24, 2018 7:55 am

You need to browse a bit the SGDK source to understand that ;)

Here's how are defined Image and Map structures :

Code: Select all

typedef struct
{
    Palette *palette;
    TileSet *tileset;
    Map *map;
} Image;

typedef struct
{
    u16 compression;
    u16 w;
    u16 h;
    u16 *tilemap;
} Map;
You can see that Map isn't just the tilemap array data.

billybob884
Interested
Posts: 18
Joined: Tue Aug 21, 2018 1:03 pm

Re: Tutorial sample file problem

Post by billybob884 » Mon Sep 24, 2018 11:43 pm

Previous post deleted, I found the unpackMap command and have it working now. Thank you!

Post Reply