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 > Unable to load more than 8 16x16 sprites at a time

#59366 - blacksun - Mon Oct 31, 2005 10:10 pm

I am trying to load up a bunch of sprites into my SpriteData 0x6010000. For some reason I can only load up 8 16x16 sprites at a time. If I load up any more, it will repeat the data with the first sprites in the strip. If I load 8 at a time it works perfectly. Is there a size or speed limitation to copy over the sprite data?

Here is what I am currently using:
Code:
void InitGameSprites(int mode)
{
   int i;
   int currSize = 0;

   int primesDim = 16*16*8/2;
   int prodDim = 16*16*8/2;
   int cursorDim = 16*16*6/2;
   //int blankDim = 32*32/2;
   numOfSelects = 0;
   
   for(i = 0; i < 10; i++)
   {
      select[i].xPos = 0;
      select[i].yPos = 0;
      select[i].index = 118;
      select[i].active = false;
   }

   for(i = 0; i < numOfSprites; i++)
   {
      spriteArray[i].xPos = 160;
      spriteArray[i].yPos = 240;
      spriteArray[i].spriteIndex = 0;
   }

   for(i = 0; i < 128; i++)
      SpriteData[i] = 0x0000;

   for(i = 0; i < 128; i++)
   {
      sprites[i].attribute0 = 160 | COLOR_256;
      sprites[i].attribute1 = 240;
      sprites[i].attribute2 = 0;
      sprites[i].attribute3 = 0;
   }

   numOfSprites = 0;

   for(i = 0; i < cursorDim; i++)
      SpriteData[i] = cursorData[i];
   currSize += cursorDim;

   for(i = currSize; i < primesDim + currSize; i++)
      SpriteData[i] = primesData[i - currSize];
   currSize += primesDim;

   for(i = currSize; i < prodDim + currSize; i++)
      SpriteData[i] = prods415Data[i - currSize];
   currSize += prodDim;

   for(i = currSize; i < prodDim + currSize; i++)
      SpriteData[i] = prods1626Data[i - currSize];
   currSize += prodDim;

}


I am not running out of memory because I can see it allocating the memory, just not copying over the right ones.

#59571 - SittingDuck - Wed Nov 02, 2005 7:06 pm

I don't know.

#59624 - strager - Wed Nov 02, 2005 10:35 pm

SittingDuck wrote:
I don't know.

That was the most meaningless and pointless (and most all-around stupid) post I have ever seen.

I assume the following:
sprites points to 0x07000000 and defines the OAM attributes.
SpriteData points to 0x06010000.

I do not know what the first two loops do. Can you briefly explain their purpose?

I've notice that your code defines cursorDim to be 768, but I'm thinking you mean 1024. Am I right?
Your Code wrote:
int cursorDim = 16*16*6/2;

This seems to be the problem; try correcting it and see if it works the way you want it to then.

#60210 - blacksun - Tue Nov 08, 2005 2:25 am

Ok ignore the first set of loops, I was just messing around with clearing sprite data.

you are correct in the address labels.

Now for the small code snipit
Code:

int cursorDim = 16*16*6/2;


What I am doing there is specifying how much data I will need to put in. The cursor sprite has 6 different 16x16 sprites. My blocksDim has more. That is what the number is for.

I am also using bmp2spr to convert these sprite strips. Is there some weird limitation on the size of the sprites? Because no matter what number i use for the blocksDim, it will only load up 8 unique sprites. It will still allocate enough memory for all the sprites, it just repeats the same 8 sprites.

Sorry this is a little long winded. Again, if I split up the blocks into 8 16x16 strips it loads fine, but that would take a while to do.

Thanks[/code]