Need help planting this MD project on a solid foundation

SGDK only sub forum

Moderator: Stef

camous
Interested
Posts: 23
Joined: Sun Jan 05, 2014 12:28 pm
Location: Denmark

Post by camous »

Kaneda, could you tell me what the idx property in the struct below is supposed to be used for?

Is it an index into a "(animation name)_sprite" property in the data.o?

struct animSpriteInfo{
u16 idx;
u8 x,y; // upon frame upper left
};
KanedaFr
Administrateur
Posts: 1154
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr »

it's for info only if I remember...

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...
camous
Interested
Posts: 23
Joined: Sun Jan 05, 2014 12:28 pm
Location: Denmark

Post by camous »

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?
KanedaFr
Administrateur
Posts: 1154
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr »

I load them this way

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 );
so to answer : in "sprite_data" ;)
camous
Interested
Posts: 23
Joined: Sun Jan 05, 2014 12:28 pm
Location: Denmark

Post by camous »

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?
KanedaFr
Administrateur
Posts: 1154
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr »

hmm...it's mean it was able to export the tiles ?
strange...!i don't remember what you should be done on GGales' side :(
camous
Interested
Posts: 23
Joined: Sun Jan 05, 2014 12:28 pm
Location: Denmark

Post by camous »

The tile data for the animation certainly seems to be in the ROM but sprite_data is not pointing to them.
KanedaFr
Administrateur
Posts: 1154
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr »

Perhaps stupid question but are you sure '0' is the ADDRESS of the data and the the first byte of the data
I often fight myself with pointer and reference...

Do you try to load it ?
camous
Interested
Posts: 23
Joined: Sun Jan 05, 2014 12:28 pm
Location: Denmark

Post by camous »

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);
}
KanedaFr
Administrateur
Posts: 1154
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr »

a good way to debug these values is to use KDebug.h
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 ?)
Look at kmod's Messages window
camous
Interested
Posts: 23
Joined: Sun Jan 05, 2014 12:28 pm
Location: Denmark

Post by camous »

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.
KanedaFr
Administrateur
Posts: 1154
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr »

Did you include "KDebug.h" ?
Did you activate the dev feature of KMod ?

For the ani, just send me you your ani file so I could test it.
If it comes for the format (and so from Genres), I should test it first...
camous
Interested
Posts: 23
Joined: Sun Jan 05, 2014 12:28 pm
Location: Denmark

Post by camous »

Ah, didnt know I had to enable debug in kmod.

As for the .ani files, I can certainly send them to you. Do you have an email address that I can forward them to?
camous
Interested
Posts: 23
Joined: Sun Jan 05, 2014 12:28 pm
Location: Denmark

Post by camous »

Kaneda, did you get a chance to take a look at the .ani files that I sent you?
camous
Interested
Posts: 23
Joined: Sun Jan 05, 2014 12:28 pm
Location: Denmark

Post by camous »

Did you get my second email with the files?
Post Reply