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.

Graphics > clearing sprites per frames issue

#177116 - blessingta@hotmail.co.uk - Tue Dec 13, 2011 3:01 am

The two functions I have below are giving me a real headache as neither won't clear my frame. (this corrupts my states, left over drawings ruining my game)
//ghost effect error func
Code:
void clear_sprites()
{
//Max x = 230,MAx y = 150;
int i_x_sp = 0, i_y_sp = 0;
for (i_y_sp = 0;i_y_sp < 150 ;i_y_sp++ )
{
for (i_x_sp = 0;i_x_sp < 230 ;i_x_sp++ )
{
psMy_OAM_Sprites16[0 * 4 + 0] = ((0<<14)|(0<<7)|(i_y_sp<<0));
psMy_OAM_Sprites16[0 * 4 + 1] = ((0<<14)|(0<<13)|(0<<12)|(0<<8)|(i_x_sp<<0));
psMy_OAM_Sprites16[0 * 4 + 2] = ((0<<12)|(0<<10)|(0<<8)|(0<<0));
psMy_OAM_Sprites16[0 * 4 + 3] = 0;

}
}
}

//the freeze my screen func
Code:
void clear_sprites()
{
int ixasm = 0;

while (ixasm < 512)
{
//do stuff here
psMy_OAM_Sprites16[ixasm] = 0;
ixasm++;
}
}