Help converting sprites to MD

SGDK only sub forum

Moderator: Stef

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Thu Sep 06, 2012 5:00 pm

.count is the number of sprites found by GenRes, so yes it's the number of frames
.nbTiles is the number of unique 8x8 tile you need to draw a sprite/frame

I don't know if Stef fixed this issue but, if you read the wiki, you also see the size property

Code: Select all

u16 size;               //since we use width/height in pixel, useful info on sprite size
                             //TODO : size is not SGDK compliant, you need to use size>>8


ex:
VDP_setSprite(0, 0, 0, sonic.size>>8, TILE_ATTR_FULL(PAL1,1,0,0,1), 0);
so, to win some ticks, give it a test (with and w/o the >>8)


and for palette, i never found a better tool that the dead debabelizer...
got a VM with XP + debabelizer only for this !

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

Post by Stef » Thu Sep 06, 2012 5:10 pm

KanedaFr wrote: I don't know if Stef fixed this issue but, if you read the wiki, you also see the size property

Code: Select all

u16 size;               //since we use width/height in pixel, useful info on sprite size
                             //TODO : size is not SGDK compliant, you need to use size>>8
Hehe i always though it was an issue with Genres :D
Imo it is not very suited to have size in pixels as the VDP base unit for sprite is the tile (and all methods in SGDK have to be tile based).

Why just don't use tiles unit instead of pixel units ? Or you can keep size in pixels but at least, the "size" field should be in tiles as i guess its only use is to load the sprite in VRAM right ? In this case you may change field name to tileSize / tilenumber / tileCount or whatever you prefer :)

Edit : maybe you want to use size in pixel for accurate collision detection (sprite should be centered then), in this case only the size filed has to be in tile unit.

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Thu Sep 06, 2012 5:23 pm

hmmm... you're perhaps right...
I misunderstood my own sentence ;)
...but I don't remember why I use size in pixels, not tiles....

Manveru
Very interested
Posts: 85
Joined: Wed Sep 05, 2012 3:30 pm

Post by Manveru » Thu Sep 06, 2012 5:32 pm

I had read that and i tried with and without >>8 because i wanted to test if the issue has been fixed since wiki was written. For me both work well.

I am re-reading all wiki and now i see i really do not understand how the data in the bmp file go to the SpriteDef var. I am trying to use 2 bmp files with 2 SpriteDef vars and GenRes but i can´t load each bmp in each variables.
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC

lingh
Interested
Posts: 20
Joined: Thu Sep 06, 2012 4:57 am

Post by lingh » Fri Sep 07, 2012 3:32 am

Manveru

Its all pretty simple. Look to my pseudocode.

Code: Select all

   VDP_loadTileData (void, NUMBER_OF_INDEX_TO_LOAD_DATA, void, void); 
   sonic.sp_sonic1.tile_attr = TILE_ATTR_FULL (void, void, void, void, NUMBER_OF_INDEX_TO_READ_DATA_FROM); 
   sonic.sp_sonic1.link  = LINK_NUMBER_TO_NEXT_SPRITE_TO_DRAW; 
	VDP_setSpriteP (LINK_NUMBER_OF_CURRENT_SPRITE_TO_DRAW, void); 
	
	VDP_loadTileData (void, NUMBER_OF_INDEX_TO_LOAD_DATA + SIZE_OF_LOADED_SPRITES_IN_TILE, void, void); 
   sonic.sp_sonic2.tile_attr = TILE_ATTR_FULL (void, void, void, void, NUMBER_OF_INDEX_TO_READ_DATA_FROM); 
   sonic.sp_sonic2.link  = LINK_NUMBER_TO_NEXT_SPRITE_TO_DRAW; 
	VDP_setSpriteP (sonic.sp_sonic1.link, void);

LINK_NUMBER_OF_CURRENT_SPRITE_TO_DRAW == 0 if it first sprite to draw.
LINK_NUMBER_TO_NEXT_SPRITE_TO_DRAW == 0 if it last sprite to draw. 

Manveru
Very interested
Posts: 85
Joined: Wed Sep 05, 2012 3:30 pm

Post by Manveru » Fri Sep 07, 2012 11:08 am

lingh wrote:Manveru

Its all pretty simple. Look to my pseudocode.

Code: Select all

   VDP_loadTileData (void, NUMBER_OF_INDEX_TO_LOAD_DATA, void, void); 
   sonic.sp_sonic1.tile_attr = TILE_ATTR_FULL (void, void, void, void, NUMBER_OF_INDEX_TO_READ_DATA_FROM); 
   sonic.sp_sonic1.link  = LINK_NUMBER_TO_NEXT_SPRITE_TO_DRAW; 
	VDP_setSpriteP (LINK_NUMBER_OF_CURRENT_SPRITE_TO_DRAW, void); 
	
	VDP_loadTileData (void, NUMBER_OF_INDEX_TO_LOAD_DATA + SIZE_OF_LOADED_SPRITES_IN_TILE, void, void); 
   sonic.sp_sonic2.tile_attr = TILE_ATTR_FULL (void, void, void, void, NUMBER_OF_INDEX_TO_READ_DATA_FROM); 
   sonic.sp_sonic2.link  = LINK_NUMBER_TO_NEXT_SPRITE_TO_DRAW; 
	VDP_setSpriteP (sonic.sp_sonic1.link, void);

LINK_NUMBER_OF_CURRENT_SPRITE_TO_DRAW == 0 if it first sprite to draw.
LINK_NUMBER_TO_NEXT_SPRITE_TO_DRAW == 0 if it last sprite to draw. 
Thanks again lingh. I suposed i have to load VDP_loadTileData twice but i got some strange out, i think i did something wrong, i will test again later.

EDIT: I have discovered my mistake and now it works perfectly. Thanks to all the people who have spent their time helping a begginer.
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC

Post Reply