gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > Sprites in tiles

#8326 - RaBBi - Tue Jul 08, 2003 1:33 pm

Hello everybody ^^

Firstable I'd like to say sorry for my poor English.
I'm a french newbie on GBA dev, but I'll try to explain my problems by the clearest way ^^

So, that's the number one lol

My aim is to animate sprite.
So I found a tuto on it in the samples directory of vham (yes I use this IDE with Ham, I forget to precise ;-)).
But the bmp used is buggy...but it's a 16x192 (16x16x12) tiles bmp I suppose.

So I do my own bmp with 32x384 (32x32x12), with the same disposition as the bmp use in tuto, aka 3 Up, 3 Right, 3 Down, 3 Left.

Then I used gfx2gba (both version to try -_-) to generate my .c files.

Then, in the code, I load the palette, then create object sprite with ham command.
Something like that :

Code:

ham_CreateObj((void*) &eikishi[32*32],0,2,etc....)


The 32*32 is to target the up-center position of the sprite.

But finally, after building....my sprite looks very weird...
One line blank, one line with some pixel, one line blank...

I don't know if this came from a bad switches in gfx2gba...

Can you help me ?
Perhaps I don't understand the array structure or the concept of number of bits for a image...
I'm desappointed, but no hopeless ! ^^

(I'm in mode 1, but I think the mode is not a problem with sprite?)
_________________
Sorry for my poor english, but it would be worst for you to understand me if I speak in my native language, French ^^

#8332 - Cyberman - Tue Jul 08, 2003 3:41 pm

Lots of things could be wrong here. I am no expert with gfx2gba, as I use my own utilities to convert things now. I would first inspect the sprite data yiou are loading.

    Check the C code that was generated for your sprite to see if the pixel pattern looks right.
    Check to see if you are loading the right data to begin with.
    Be SURE your data is TILED, and not linear the GBA can store sprite data 2 ways one is 8x8 tiles the other is 8x8 adjacent tiles. All of them though are 8x8 tiles.
    BE sure you are using the right palette and that you are using the right number of colors. IE 16 or 256 colors and select the proper palette to be sure.

For animating the sprite you will need to reload the graphics at strategic intervals as well. However seeing it first might be a better place to start ;)

Cyb

#8333 - RaBBi - Tue Jul 08, 2003 3:47 pm

Thank U Cyb ^^

I think the problem comes from this :

Cyberman wrote:

Be SURE your data is TILED, and not linear the GBA can store sprite data 2 ways one is 8x8 tiles the other is 8x8 adjacent tiles. All of them though are 8x8 tiles.


How can I verify this difference ? (in my C code)
_________________
Sorry for my poor english, but it would be worst for you to understand me if I speak in my native language, French ^^

#8336 - niltsair - Tue Jul 08, 2003 5:04 pm

A quick and painless way would be to create a 8x16 bitmaps. Put every even(pair) lines in one color, and odd(impair) line in another color. Generate your .c file.

If the resulting array is :
Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1 .... (16color 0 then 16 color 1)

Then it's not converting right.

Else, if it's :
Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 0, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, Color 1, .... (8 color 0 then 8 color 1)

Then the conversion is right.

Basicly, you need the data to be divided in 8x8 chunks and not just one big picture.

#8337 - RaBBi - Tue Jul 08, 2003 5:09 pm

ok thanks, I'll try to test it ^^

Can someone look at the sample "vham_obj_anim" to see what's wrong with the bitmap et how the guy did, cause it's bitmap is not composed by 8x8 tiles ?

EDIT: It's ok ^^
Like I was thinking to, it's a bad gfx2gba switch, I must use -t8 for tile size.
_________________
Sorry for my poor english, but it would be worst for you to understand me if I speak in my native language, French ^^