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.

Coding > Quick Sprite Question

#4009 - Ninja - Sat Mar 15, 2003 7:58 pm

Hi all. I am trying to get a 32x64 sprite (4 bit color) to display properly, but am having a great deal of trouble doing it. (Probably because I haven't slept in a good 28 hours). I was wondering if one of you would help me out a little?

I am using a 1D array, in Mode 4. I have my array set up like this:

Code:


InitializeSprites();

sprites[0].attribute0 = COLOR_16 | TALL | y;
sprites[0].attribute1 = SIZE_64 | x;
sprites[0].attribute2 = 512;

int size = 512;

for(loop = 512*16; loop < size; loop++)
{
   OAMdata[loop] = obj0[loop];
)

while(1)
{
   CopyOAM();
   WaitForVblank();
}


I am right positive I am writing to the wrong array section, but my tired mind is a little too overworked to figure out the correct formula, an dmy inexperience with graphics isn't helping much.

EDIT: Sorry, I should probably mention that I am seeing the sprite, and in proper dimensions, but the data is corrupted, as I am seeing large blocks of garbage data colored roughly like my sprite.

#4014 - darkcloud - Sat Mar 15, 2003 9:29 pm

Your 'for' loop seems to be the problem. You are setting the initial value of loop greater than what you are checking it against, thus no data would get loaded in. 512*16 is greater than 512 so the loop won't work. You should set loop to 0 at first, then during the loop do something like

Code:
OAMdata[loop+512*16] = obj0[loop];

_________________
Maybe in order to understand mankind, we have to look at the word itself: "Mankind". Basically, it's made up of two separate words - "mank" and "ind". What do these words mean ? It's a mystery, and that's why so is mankind.

#4016 - Ninja - Sat Mar 15, 2003 9:46 pm

Let this be a lesson to the rest of you: When coding, try to stay awake.

Thanks so much man. I finally got it working correctly, after a good 12 hours of beating my head against the wall trying to make it work. :) Man do I ever feel like the world's biggest tool.