#51254 - triton - Wed Aug 17, 2005 5:45 pm
Been trying to display a sprite. Here's my gba.h code.
And my main file:
But the sprite doesn't move can someone help?
Code: |
.... typedef struct { u16 att0, att1, att2, att3; }OAM; OAM oamc[128]; typedef struct { int x, y; OAM* oam; }SPRITE; void initspr() { int i; for (i=0; i<128; i++) { oamc[i].att0=160; oamc[i].att1=240; } } void oamup() { int i; for(i=0; i<128*sizeof(OAM)/4; i++) ((u32*)charmem)[i]=((u32*)oamc)[i]; } void DMA(int dma, u32* source, u32* dest,unsigned int count) {// 0,1,2,3 # words/halfwords 2, 4 { (*(unsigned int*)(0x40000b0 + dma * 12))= (unsigned int)source; (*(unsigned int*)(0x40000b4 + dma * 12)) = (unsigned int)dest; (*(unsigned int*)(0x40000b8 + dma * 12)) = 0x84000000| count; } return; } void keys(SPRITE* ex) { if(!(KEY & 0x0010))//right { ex->x += 1; } if(!(KEY & 0x0020)) { ex->x -= 1; } } .... |
And my main file:
Code: |
int main() { DISP_CNT=0x1000; initspr(); DMA(3, (u32*)spr_palette, (u32*)0x5000200, 128); DMA(3, (u32*)spr, (u32*)0x6010000, 1024); SPRITE sprite; sprite.x = 120; sprite.y = 80; sprite.oam=&oamc[0]; sprite.oam->att0=sprite.y|COLOR_256; sprite.oam->att1=sprite.x|SIZE_64; while(1) { keys(&sprite); vblank(); oamup(); } } |
But the sprite doesn't move can someone help?