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.

Beginners > Problem with VHam and gfx2gba...

#71444 - Nave Adair - Sun Feb 12, 2006 11:17 pm

I've been into GBA development lately (been doing othe languages for about a year, but I just started HAM). I'm working on a pong game to get used to it, and I'm not having any problems with the programming. However, I'm having trouble with the graphics I'm converting with gfx2gba. Somewhere along the way, something messes them up, expecially the ball's sprite.

Ball sprite.
Conversion code
ball.pal.c
ball.raw.c
int main()
GBA file to see how ball shows up.

Anyone who can tell me where it was messed up and how to fix it?

#71451 - Cearn - Sun Feb 12, 2006 11:54 pm

Note, I am not a HAM expert

The reason the ball is off is because you're converting it as a bitmap, rather than as tiles. I believe you should use '-t8' rather that '-t1' for that.

Also, you only have one object palette of 256 colors that is shared by all sprites. By using ham_LoadObjPal twice, you're overwriting the what you did with the first call.

Ham's text services work only for tiles text, i.e., not modes 3,4,5.

Why most of object VRAM is filled with 0x01's is still a bit of a mystery to me, though.

#71453 - Nave Adair - Mon Feb 13, 2006 12:02 am

It looks more like a ball, but it is still off.

Almost there... any other ideas?

#71459 - Cearn - Mon Feb 13, 2006 12:39 am

I'm guessing data alignment.

From what I can tell, the sprite data is put at 0201:913E, which is a valid halfword address, but not a valid word address. HAM uses a 32bit DMA to copy in the data, which screws up because of the mis-alignment.

I'll take a wild stab and assume you're #including the data arrays, rather than linking them separately? That, combined with using non-word arrays is a recipe for disaster. So don't do that then.

Alternatively, use the '-align' flag. I think that may fix it as well.

Do a search for alignment here. This problem crops up from time to time.

#71466 - Nave Adair - Mon Feb 13, 2006 1:24 am

Cearn wrote:
Alternatively, use the '-align' flag. I think that may fix it as well.


That worked perfectly, thank you for all the help!