How graphic assets exactly work?

SGDK only sub forum

Moderator: Stef

Post Reply
Arrovs
Interested
Posts: 18
Joined: Wed Sep 11, 2013 3:44 pm

How graphic assets exactly work?

Post by Arrovs » Sun Mar 22, 2015 9:27 pm

Hello. Im new one here and with sega genesis development at all.
Im managed to go through some examples and got some outputs, but some things bothers me.

How exactly that rescomp stuff works?
For example if i want make map for game like this one should i create one big png which looks like map and rescomp will somehow know how to make it in map?
For first try i made every tile in its own png file and drawed map from array information. Is this right way to do it?
Also if i want to make tile sheet like this how im supposed to cut every piece in its own image or which structure is more suitable for this case?

By the way i want to draw map in background(like PLAN_A) and units as sprites. In this way array info is helpful as i can easely know on what terrain unit is standing and i can additionaly give advantages or disadvantages to it.
As 40*30 tiles is needed to fill whole screen and i dont need huge maps i possibly can get through background without updating it. But how im supposed to give animation for background tile like water?
Also how im going to make sprite animation sheets? I of course seen them in sprite demo, but how im going to map them from png file? Or all this stuff is done before rescomp in some usefull programms?

Also VDP_drawImage - does it automatically sets pallettes, knows to not load same images on VRAM or should i better do this stuff on my own?

Also can i use 16*4 colors from RGB palette or i need to use some specific ones as i heard sega have 512(or so) colors only.

Thanks for reading and answering all this easy questions which arent covered in mystical way.

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

Re: How graphic assets exactly work?

Post by Stef » Mon Mar 23, 2015 10:57 am

Hello,

Many questions actually !
First, you can try to read the rescomp.txt file :
https://github.com/Stephane-D/SGDK/blob ... escomp.txt
But i agree it does not say much about how thing are worked internally.
So basically you guessed right, when you define an "IMAGE" resource, rescomp will automatically break the image in 8x8 tiles and build the map by taking care of duplicated and filled tiles. So you just need to feed it with a big iamge and that is. Of course you need to build your image image by taking the hardware limitation in consideration, so use 8x8 pixels tile as base (the number of different tiles is limited, think you can host about 1400 tiles in VRAM aside the others data). Each tile should only use a palette of 16 colors (4bpp, where color 0 is transparent) and that you have only 4 palettes to deal with the 2 background and the sprites. Also the color range of megadrive is indeed 512 (RGB333), you can extend it with highlight / shadow but forget that for now ;)
To edit your map you may try this tool :
http://www.mapeditor.org/

The background map size is configurable :
32x64, 32x128
62x32, 64x64
128x32

so even if you don't have big map i guess you will need to update the internal map at somepoint, hopefully SGDK provide nice methods, this have been already discussed here :
viewtopic.php?t=1949
viewtopic.php?t=1753

For background tiles animation, you have severals choices:
you can replace tile indexes in the map or you can directly modify the "water" tiles in VRAM.

About the sprites, yeah the "sprite" sample included in SGDK is a nice example about how define and use it, basically yeah you draw your sprite sheet where each row define a sprite animation and column a frame of that animation, each cell should have a fixed size (in step of 8 pixels).
Then all this is declared in your .res file :
https://github.com/Stephane-D/SGDK/blob ... es/gfx.res

For example in the sprite sample, you can see the sonic sprite is declared as :

Code: Select all

SPRITE sonic_sprite "sonic.png" 6 6 -1 5
"6 6" is used to define the size of the sprite
-1 for the compression
5 for the animation time

All these is described in the rescomp.txt file.

Last point, VDP_drawImage(..) will always use palette 0, it's better to use VDP_drawImageEx(..) to have more control.

Hope that help =)
Last edited by Stef on Mon Mar 23, 2015 3:50 pm, edited 1 time in total.

Arrovs
Interested
Posts: 18
Joined: Wed Sep 11, 2013 3:44 pm

Post by Arrovs » Mon Mar 23, 2015 11:57 am

Thanks for all this info.
I exactly wondered how im supposed to feed animation speed for sprites.

But still - how im supposed to break spritesheet into small images? In your case you assume use of predefined map which i pump into VRAM.
So i could use one spritesheet for all map tiles (4x4size) and manually load needed ones to VRAM. I can only imagine map property to get right x and y to get tiles from it, but that sounds bit painfull to map all tiles.
Also each tile(8x8pixels) will define its own palette or all IMAGE together? With this i mean, can i make png with 1k+ colors and use like desert, grass, snow terrains and each terrain will have its palette or should i better make its own png for each palette. So in this case it could be 2 pngs for every terrain type(30 colors).
Also as i see i can use my own palettes in resource file - so i still assume i can make much color png to define tiles and give right palettes to them.

Also what exactly is difference between TileSet and Map and how they are related?

Much brainstorming. Please give me some insight in this.
If i will master all this stuff i will sure make tutorial for newbies.

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

P

Post by Stef » Tue Mar 24, 2015 9:36 am

Arrovs wrote:Thanks for all this info.
I exactly wondered how im supposed to feed animation speed for sprites.

But still - how im supposed to break spritesheet into small images? In your case you assume use of predefined map which i pump into VRAM.
So i could use one spritesheet for all map tiles (4x4size) and manually load needed ones to VRAM. I can only imagine map property to get right x and y to get tiles from it, but that sounds bit painfull to map all tiles.
Also each tile(8x8pixels) will define its own palette or all IMAGE together? With this i mean, can i make png with 1k+ colors and use like desert, grass, snow terrains and each terrain will have its palette or should i better make its own png for each palette. So in this case it could be 2 pngs for every terrain type(30 colors).
Also as i see i can use my own palettes in resource file - so i still assume i can make much color png to define tiles and give right palettes to them.

Also what exactly is difference between TileSet and Map and how they are related?

Much brainstorming. Please give me some insight in this.
If i will master all this stuff i will sure make tutorial for newbies.
Actually you can use different methods to draw your MAP but currently SGDK does not support direct "MAP" resources so you can't really separate the TILESET from the MAP.
You have to use IMAGE resource which internally contains a TILESET + a MAP + a PALETTE but you don't have to care about them. You just give an image representing your background plan and automatically rescomp with build the TILESET, MAP and PALETTE structure for you.
Again to build your image you need to pass by a map builder tool as tiled but free to you to use whatever you prefer. The only restriction is that you need to use 4BPP tiles and tile should have a size of 8x8 pixels (multiple of 8x8 will work of course). Also in your complete image you should not have more than 4 different palettes, that's all !
There is many topics discussing about Tiles and Map :

viewtopic.php?t=1908
viewtopic.php?t=1373
viewtopic.php?t=898
viewtopic.php?t=1457
viewtopic.php?t=1478

Arrovs
Interested
Posts: 18
Joined: Wed Sep 11, 2013 3:44 pm

Post by Arrovs » Fri Apr 03, 2015 4:32 pm

Now i atleast know how to get things out of spritesheets:
VDP_setMapEx
Very usefull function.

Also does VDP_setMap will be faster than standart VDP_drawImageEx?

Also can i change plane size for A and B differently(f.e. A: 32x32 B: 64x32)?

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

Post by Stef » Fri Apr 03, 2015 8:22 pm

Indeed setMapEx is the method you need... and you need to understand how hardware works to understand how use this method correctly ;)
setMap is a lot faster than drawImage as you only change the map and do no upload any new tiles to the VRAM.
About the map size, no unfortunately they are linked, same size for both.

Arrovs
Interested
Posts: 18
Joined: Wed Sep 11, 2013 3:44 pm

Post by Arrovs » Fri Apr 03, 2015 9:04 pm

strange part about VDP_drawImageEx is TILE_ATTR_FULL where i use index from already uploaded tiles. So it means im uploading in that index tiles again? If so i can whole map generation move to setMap as i uploaded every tile once.

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

Post by Stef » Fri Apr 03, 2015 10:04 pm

Of course ;) drawImage actually does upload tiles, it should be used to display an image on its own but not for plan/background scrolling. For that you need first to upload the tileset then use setMap or setMapEx methods.

Post Reply