Need help planting this MD project on a solid foundation
Moderator: Stef
it's for info only if I remember...
Usually I track the firstTile I loaded my sprite data into then use something like
Note you'll perhaps got problem when using sgdk sprites func because it doesn't give you control on the link attribute...
Usually I track the firstTile I loaded my sprite data into then use something like
Code: Select all
frame = (struct str_Frame *) anim->Frames[ currentFrame ];
size = (anim->sprite_width-1);
size <<= 2;
size |= (anim->sprite_height-1);
from |= palIdx;
from <<=2;
from |= flip;
from <<=11;
u8 nbTiles = anim->sprite_width*anim->sprite_height;
for( curSpr=0; curSpr < frame->nbSprites; curSpr++)
{
idxTile = firstTile + curSpr*nbTiles; /
idxTile &= 0x07FF;//needed ?
posx = x + frame->Sprites[curSpr].X;
posy = y + frame->Sprites[curSpr].Y;
Sprite_Define(sprNum++, posx, posy, size, from | idxTile);
}
Note you'll perhaps got problem when using sgdk sprites func because it doesn't give you control on the link attribute...
I see. But what I really want to know is how I can figure out where genres loads the tiles for an ani.
Lets say I have a file called test.ani and I put this line in data.rc:
ANI test "data/test.ani"
Then in the code I do this:
extern struct genresAnimation test;
However looking at the genresAnimation, animFrame and animSpriteInfo I cannot find a pointer to the tile data for the animation.
At first I thought that test.sprite_data was pointing to the tile data but that seems to be set to 0.
So where is the tile data?
Lets say I have a file called test.ani and I put this line in data.rc:
ANI test "data/test.ani"
Then in the code I do this:
extern struct genresAnimation test;
However looking at the genresAnimation, animFrame and animSpriteInfo I cannot find a pointer to the tile data for the animation.
At first I thought that test.sprite_data was pointing to the tile data but that seems to be set to 0.
So where is the tile data?
I load them this way
so to answer : in "sprite_data" 
Code: Select all
u16 frameTiles = anim->width* anim->sprite_width* anim->height* anim->sprite_height;
VDP_loadTileData( (u32 *) ( anim->sprite_data + 16*frameTiles*curFrame), firstTile, frameTiles, 1 );

Ah, yes, that is also what I guessed before I wrote the question.
Problem is though the value of sprite_data is 0, which is to say it points to the start of the rom. However when I dump the rom and look for the tile data using a hex editor I see that it is in fact stored somewhere else.
All other information in the genresAnimation seem to be valid though. Could it be that the genres I am using is an older version that has a bug or is not complete?
Problem is though the value of sprite_data is 0, which is to say it points to the start of the rom. However when I dump the rom and look for the tile data using a hex editor I see that it is in fact stored somewhere else.
All other information in the genresAnimation seem to be valid though. Could it be that the genres I am using is an older version that has a bug or is not complete?
Not a stupid question at all. C pointers are always hard to wrap ones mind around. I think I am using the address and not the value, here look at the code below and tell me whether I am doing it right?
test.ani is a simple 32x32 one frame animation with colour index 1 filling the whole screen. So when executing the code below I should get a 32x32 solid block painted on the screen, but I get nothing.
When I look at the vdp using kmod I see that the correct palette is loaded but the tile is not loaded in vram.
If I look for the tile data in the rom I see that it is located at address 0x508. If I change the code to pass that address to VDP_loadTileData then the solid block shows up. There is one problem though. The tile data seems to be missing the last line of the last 8x8 segment so that shows up as random garbage.
--------
extern struct genresAnimation test;
int main()
{
u16 nbTiles = (test.sprite_width) * (test.sprite_height);
VDP_loadTileData( (u32 *) test.sprite_data, 1, nbTiles, 0);
VDP_setPalette(PAL1, test.pal);
VDP_resetSprites();
VDP_setSprite(0, 40, 40, SPRITE_SIZE(4,4), TILE_ATTR_FULL(PAL1,1,0,0,1), 0);
VDP_updateSprites();
while(1)
{
VDP_waitVSync();
}
return(0);
}
test.ani is a simple 32x32 one frame animation with colour index 1 filling the whole screen. So when executing the code below I should get a 32x32 solid block painted on the screen, but I get nothing.
When I look at the vdp using kmod I see that the correct palette is loaded but the tile is not loaded in vram.
If I look for the tile data in the rom I see that it is located at address 0x508. If I change the code to pass that address to VDP_loadTileData then the solid block shows up. There is one problem though. The tile data seems to be missing the last line of the last 8x8 segment so that shows up as random garbage.
--------
extern struct genresAnimation test;
int main()
{
u16 nbTiles = (test.sprite_width) * (test.sprite_height);
VDP_loadTileData( (u32 *) test.sprite_data, 1, nbTiles, 0);
VDP_setPalette(PAL1, test.pal);
VDP_resetSprites();
VDP_setSprite(0, 40, 40, SPRITE_SIZE(4,4), TILE_ATTR_FULL(PAL1,1,0,0,1), 0);
VDP_updateSprites();
while(1)
{
VDP_waitVSync();
}
return(0);
}
a good way to debug these values is to use KDebug.h
KDebug_AlertNumber() will help you to check value of
Look at kmod's Messages window
KDebug_AlertNumber() will help you to check value of
Code: Select all
nbTiles
test.sprite_width
test.sprite_height
test.sprite_data (or is it test->sprite_data ?)
Is KDebug_AlertNumber() supposed to cause numbers to appear in Gens Kmod debug messages window?
If so it is not working because nothing is printed there no matter how many KDebug_AlertNumber calls I put in the code.
In any regard I wrote my own print function capable of printing a text string and a number which I use to debug for now.
test.sprite_data is definitely pointing to 0 (null). And test->sprite_data does not work because it causes compiler errors.
Anyway, I am at the end of my tether here, has anyone had luck with using genres to import .ani files into their C project, if so I would appreciate their input, or sample C code.
If so it is not working because nothing is printed there no matter how many KDebug_AlertNumber calls I put in the code.
In any regard I wrote my own print function capable of printing a text string and a number which I use to debug for now.
test.sprite_data is definitely pointing to 0 (null). And test->sprite_data does not work because it causes compiler errors.
Anyway, I am at the end of my tether here, has anyone had luck with using genres to import .ani files into their C project, if so I would appreciate their input, or sample C code.