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 > Sprites not showing up..

#35380 - Mitch GBA - Thu Feb 03, 2005 9:11 pm

Hey. I have a problem.. I've started a new project, and I'm doing everything I did at other projects, and now it doesnt work.. The sprite wont show up, the background does show up. You know what I'm doing wrong here???

Code:
//***********************\\
//   COLOR TAP ADVANCE   \\
//***********************\\
//by: Mitch Monhemius

#include "gba.h"
#include "levelbg.h"
#include "pressor.h"


void InitializeSprites(void);
void CopyOAM(void);

OAMEntry sprites[128];

u16 xship = 32;
u16 yship = 80;

int main() {

   u16 loop;

   SetMode(MODE_4 | BG2_ENABLE | OBJ_ENABLE | OBJ_MAP_1D);

      for (loop = 0; loop < 256; loop++) {
         BG_PaletteMem[loop]=levelbgPalette[loop];
      }

      for (loop = 0; loop < (120*160); loop++) {
         FrontBuffer[loop] = levelbgData[loop] ;
      }



   for(loop = 0; loop < 256; loop++) {
   OBJ_PaletteMem[loop] = pressorPalette[loop];
   }


   memcpy( (u16 *)0x06014000, &pressorData, sizeof(pressorData) );


   //bullets\\
   sprites[0].attribute0 = COLOR_256 | WIDE | yship;
   sprites[0].attribute1 = SIZE_16 | xship;
   sprites[0].attribute2 = 512;



   while(1)
   {

      WaitForVsync();
      CopyOAM();
   }


   return 0;

}






// FUNCTIONS HERE:


void InitializeSprites(void)
{
   u16 loop;
   for(loop = 0; loop < 128; loop++) {
      sprites[loop].attribute0 = 160;
      sprites[loop].attribute1 = 240;
   }
}

void CopyOAM(void)
{
   u16 loop;
   u16* temp;
   temp = (u16*)sprites;
   for(loop = 0; loop < 128*4; loop++)   {
      OAM_Mem[loop] = temp[loop];
   }
}



It's not the files.. I tested them in another project and they're fine.. I dunno why it doesnt work..

#35382 - Mucca - Thu Feb 03, 2005 9:35 pm

Code:
memcpy( (u16 *)0x06014000, &pressorData, sizeof(pressorData) );

This looks a little funny to me - if pressorData is an array, the reference operator is unnecessary, if its not an array, sizeof won't work. Which is it?

#35383 - sajiimori - Thu Feb 03, 2005 9:45 pm

If it worked in your previous programs, start reverting things that are different until it works again, then you'll know what broke it.

#35388 - Mucca - Thu Feb 03, 2005 10:55 pm

Oops, to correct myself, I guess pressorData could be a struct containing all the sprite tiles, although I doubt thats the case.

#35389 - Mitch GBA - Thu Feb 03, 2005 11:13 pm

Quote:
If it worked in your previous programs, start reverting things that are different until it works again, then you'll know what broke it.


That's the weird part.. It is the same. I dunno why it wont show up

#35390 - DekuTree64 - Thu Feb 03, 2005 11:20 pm

Have you tried checking it out in VBA's OAM/tile viewers? That should tell you right away wether it's not being loaded correctly, or if the OAM isn't set up right.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#35391 - sajiimori - Thu Feb 03, 2005 11:26 pm

If you insist that it's the same, you won't find the difference that is obviously there.

If you're running Windows, you can use the command line "fc" program to compare your source and data files.

#35402 - gauauu - Fri Feb 04, 2005 4:44 am

amazing! I never knew windows came with a diff program....

#35430 - Cearn - Fri Feb 04, 2005 4:10 pm

Mitch GBA wrote:
Code:
void CopyOAM(void)
{
   u16 loop;
   u16* temp;
   temp = (u16*)sprites;
   for(loop = 0; loop < 128*4; loop++)   {
      OAM_Mem[loop] = temp[loop];
   }
}


(I'm having this strange sense of deja vu). It couldn't be related to this problem, could it? What's the definition of OAM_Mem?