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 > Am I overloading the OAM?

#19786 - CyberSlag5k - Sun Apr 25, 2004 5:40 pm

I've got a sprite with 19 frames of animation. I use gifs2sprites to convert all the frames into one .h file complete with palette. However, any frame above the 7th or so acts kind of funny.

A download can be found here:

[url]homepages.udayton.edu/~pateramj/main.bin[/url]

Here are the setions of pertinant code:

Code:

   sprites[0].attribute0 = COLOR_256 | SQUARE | soldier.posY;
   sprites[0].attribute1 = SIZE_64 | soldier.posX;
   sprites[0].attribute2 = 0;

   u16 const *myArray[19] = {obj0, obj1, obj2, obj3, obj4, obj5, obj6, obj7, obj8, obj9, obj10, obj11, obj12, obj13, obj14, obj15, obj16, obj17}; //obj0, obj1, obj2,....are arrays containing the frame data stored in soldier.h

   for(int j = 0; j < 18; j++)
   {
      soldier.spriteFrame[j] = j*128;
      for(int i = 0; i < 2048; i++)
      {
         OAMData[i + (j * 2048)] = myArray[j][i];
      }
   }

   soldier.OAMSpriteNum = 0;
   soldier.activeFrame = 0;



When you press A or B, the visor of the little soldier guy should open or close (it just increments activeFrame based on time). All is well for the first 7 frames or so, and then, as you can see, everything goes to hell. I'm thinking maybe I'm overloading (not as in OOP, but as in putting too much into it) the OAM. Is that a reasonable assessment? These sprites are rather huge (64*64). I know there's a fix using the DMA but I'm not at that level just yet (I hope to tackle the DMA within a week or two), but is there something I'm doing wrong here? Or am I just pushing the OAM too far?

Thanks in advance![/url]
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...


Last edited by CyberSlag5k on Sun Apr 25, 2004 6:28 pm; edited 1 time in total

#19788 - sajiimori - Sun Apr 25, 2004 6:09 pm

If you want to make it a little easier on your would-be helpers, use the Preview button to check your posts for correct formatting, and try to use the right terms (OAM is not the same thing as sprite cell RAM).

Sprite cell RAM only has space for 16 16-color 64x64 images, or 8 256-color 64x64 images.

Don't let DMA scare you -- sprites are way harder and you already have those working.

#19790 - CyberSlag5k - Sun Apr 25, 2004 6:31 pm

Quote:

If you want to make it a little easier on your would-be helpers, use the Preview button to check your posts for correct formatting,


Right, sorry about that. Fixed it.

Quote:

and try to use the right terms (OAM is not the same thing as sprite cell RAM).


Duelly noted.

Quote:

Sprite cell RAM only has space for 16 16-color 64x64 images, or 8 256-color 64x64 images.


So I am indeed putting too many frames into memory. I'll get right on learning the DMA then.

Thank you.
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...

#19792 - CyberSlag5k - Sun Apr 25, 2004 6:39 pm

Er...just so I am clear, the OAM is where I put my sprite attributes in, then? attribute0, attribute1, and attribute2? And when I'm loading my sprites into memory, that's into sprite RAM? I guess I got confused becaues in my gba.h what I've been putting my sprite data into is called OAMData.
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...

#19793 - sajiimori - Sun Apr 25, 2004 6:43 pm

That's right -- some GBA headers use that stupid term OAMData, which has caused havoc around here. :)

#19795 - CyberSlag5k - Sun Apr 25, 2004 6:48 pm

changed from OAMData to spriteMem.

I have seen the light!
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...