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.

DS development > Sprite problems

#93388 - iainprice - Tue Jul 18, 2006 10:33 pm

I have tried looking for the answers on the forum but I can't find them but please be kind if these questions are kinda obvious....

I have been using code from other demos for sprite handling but I canot seem to get the y coorinates to work....

[code]
sprites[0].x = 111<<8;
sprites[0].y = 98<<8;
[/code]

then later:
[code]
void updatespritepos(Sprite* sp)
{
int x = sp->x >> 8;
int y = sp->y >> 8;

sp->oam->attribute[1] &= 0xFE00;
sp->oam->attribute[1] |= (x & 0x01FF);

sp->oam->attribute[0] &= 0xFF00;
sp->oam->attribute[0] |= (y & 0x00FF);
}
[/code]

Another problem I have is that I am using kaleid to convert a 32*32 256 bmp to a mode 4 c file. But when I load it, it seems corrupt:

[code] for(i = 0; i < 256; i++)
{
SPRITE_PALETTE[i] = ball_pal[i];
SPRITE_PALETTE_SUB[i] = ball_pal[i];
}
for(i = 0; i< 32*16; i++)
{
SPRITE_GFX[i] = ball_gfx[i];
SPRITE_GFX_SUB[i] = ball_gfx[i];
}
[/code]


Any ideas?

#93514 - iainprice - Wed Jul 19, 2006 5:04 pm

I am now using usenti and the sprites are in 8*8 blocks and now working fine but the y coordinate is still not working....

any ideas?

#93516 - TheRain - Wed Jul 19, 2006 5:12 pm

<edit> nevermind... you got that straight from the complex2d demo. ummm i am not sure why it's not working.

Last edited by TheRain on Wed Jul 19, 2006 5:39 pm; edited 1 time in total

#93520 - iainprice - Wed Jul 19, 2006 5:37 pm

I think I've got it sorted... nearly.

When I enable and disable the sprites it copies data to attribute 0 which stamps all over the y position stored there already.

Just trying to juggle sprites on the main and sub screen and I'll be there....