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.

Hardware > GBA Sprites not showing properly

#88632 - Azenris - Tue Jun 20, 2006 6:30 pm

Sorry Wrong Forum, can someone move this thread

I'm using MODE_4.

What happens is weird, and im unsure why its happening, prolly sommet simple too :(

But when I display a sprite to screen only the first colour is used and written to both pixels (you have to write two pixels at a time in mode 4.

so, if i was to make two pixels [R][Y] on the screen it would do [R][R] and you would see not yellow, only the red shows :/


Code:

SetGBAMode(MODE_4 | BG2_ENABLE | OBJ_ENABLE | OBJ_MAP_1D);

for(loop = 0; loop < 256; loop++)
{
   OBJ_PaletteMem[loop] = object_Palette[loop];
}
for (loop = 0; loop < 256; loop++)
{
   BG_PaletteMem[loop] = background_Palette[loop];
}

memcpy( (u16 *)0x06014000, &ballData, sizeof(ballData) );
sprites[0].attribute0 = COLOR_256 | SQUARE | 100;
sprites[0].attribute1 = SIZE_8 | 100;
sprites[0].attribute2 = 512;
WaitForVsync();
DrawOAM();


What stupid mistake am i making :p


Last edited by Azenris on Tue Jun 20, 2006 6:33 pm; edited 2 times in total

#88633 - tepples - Tue Jun 20, 2006 6:33 pm

I think the version of memcpy() that you're using may not be optimized. Have you tried CpuFastSet()?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#88634 - Azenris - Tue Jun 20, 2006 6:38 pm

Never heard of CpuFastSet(), ill do some digging into that, atleast i have something different than looking at my own code now

#88670 - Cearn - Tue Jun 20, 2006 9:15 pm

memcpy won't work properly if either source or destination data isn't word aligned. This is a common problem when you are #including data.

#88681 - tepples - Tue Jun 20, 2006 10:17 pm

Some memcpy() implementations copy bytes anyway in at least some cases, regardless of whether the source, destination, and length are aligned.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#88983 - Azenris - Thu Jun 22, 2006 5:57 pm

Sorry guys, forgot to say thnx, its all working now from the info you gave me. ty ty