Archived

This topic is now archived and is closed to further replies.

Tokiko

GBA Sprite Size

Recommended Posts

I recently started programming the gba and I am currently learning how to draw sprites. I had no trouble getting one that is 8x8, but when I change the size to 64x64 and I change the data loop, it draws a distored sprite. Heres the code I use to set the size: sprites[0].attribute1 = SIZE_64 | x; I use this to load the sprite image: for(loop = 0; loop < 2048; loop++) { OAMData[loop] = faceData[loop]; } Im not sure if Im doing it right so could someone help me out with this noobish problem. Thanks

Share this post


Link to post
Share on other sites
To give you a reliable answer I''d need to have a bit more information about what you''re doing. First, are you working in 1D or 2D sprite mode? (This is set in REG_DISPCNT) Secondly, how are you getting your image data? All sprites are stored in a bit of an unusual format, which might be interfering with things. That is, all of it is stored in 8x8 chunks, meaning the first 64 values correspond to the upper left 8x8 chunk, then the next 64 refer to the 8x8 chunk immediately to the left of that. Depending on where your image data is coming from, it may or may not be compensating for that. Also, some of the size data is stored in attribute0 as well, so you should make sure that''s set right. Can I assume then, that it''s creating the right size sprite, but just arranging the image data on the sprite wrong?

A very boring read, but probably the single best resource I''ve seen for programming on the GBA: CowBite Virtual Hardware Spec You might want to check out some of it''s info on sprites.

-Arek the Absolute

Share this post


Link to post
Share on other sites
You''re probably not loading the bitmap data correctly to obj char memory. Depending on which mode you''re using (1D or 2D) you have to write the data differently, make sure you''re doing it correctly for the mode you''re using.

------------
- outRider -

Share this post


Link to post
Share on other sites
Ok I have seemed to figure it out. I was using the 2D sprite mode, and I switched it to 1D and the sprite drew correctly. I must have accidently set it to 2D. Anyways, everything is normal except whatever is coloured white is not appearing. Should this happen? I used the pcx2sprite program and I used a 256 BMP transfered to a PCX format.

Thanks for your help.

Share this post


Link to post
Share on other sites
Most likely this white color is palette index 0, which is used for masking. Whatever color is first in the palette is invisible. Adjust the image''s palette (in the bitmap form, not the code only) and make sure the right stuff is masked.

-Arek the Absolute

Share this post


Link to post
Share on other sites