Page 2 of 2
Posted: Thu Sep 06, 2012 5:00 pm
by KanedaFr
.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 !
Posted: Thu Sep 06, 2012 5:10 pm
by Stef
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

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.
Posted: Thu Sep 06, 2012 5:23 pm
by KanedaFr
hmmm... you're perhaps right...
I misunderstood my own sentence

...but I don't remember why I use size in pixels, not tiles....
Posted: Thu Sep 06, 2012 5:32 pm
by Manveru
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.
Posted: Fri Sep 07, 2012 3:32 am
by lingh
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.
Posted: Fri Sep 07, 2012 11:08 am
by Manveru
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.