#11430 - HolyHoppsan - Mon Oct 06, 2003 7:43 pm
HI!
I have a problem. I?m using the pern tutorials, to learn how to display sprites. Althou I almost copied the sourcecode it does not work, whats wrong, heres my code:
I have a problem. I?m using the pern tutorials, to learn how to display sprites. Althou I almost copied the sourcecode it does not work, whats wrong, heres my code:
Code: |
#include <stdio.h>
#include <stdlib.h> #include "gba.h" #include "dispcnt.h" #include "mode.h" #include "pacsprite.h" #include "palette.h" #include "sprites.h" u16* SpritePaletteMem = (u16*)0x5000200; u16* ScreenBuffer = (u16*)0x6000000; u16* OAM = (u16*)0x7000000; u16* SpriteData = (u16*)0x6100000; OAMEntry sprites[128]; pRotData rotData = (pRotData)sprites; //Kopiera sprites till sk?rmen void CopyOAM() { u16 loop;//looping variable for loops u16* temp;//pointer to sprites temp = (u16*)sprites; //loop trough sprites for(loop = 0; loop < 128*4; loop++) { OAM[loop] = temp[loop]; } }//end copyOam //initialize Sprites(set them offscreen) void InitializeSprites() { u16 loop; //loop variable for(loop = 0; loop < 128; loop++) { sprites[loop].attribute0 = 160;//set y offscreen sprites[loop].attribute1 = 240;//set x to offscreen } } //sync screen drawing void WaitForVsync() { while((volatile u16)REG_VCOUNT != 160){} } void PlotPixel(int x, int y, unsigned short int c); int main() { int loop; s16 x = 40; s16 y = 40; SetMode(MODE_1 | OBJ_ENABLE | OBJ_MAP_1D); for(loop = 0; loop < 256; loop++) { OBJPaletteMem[loop] = palette[loop]; } InitializeSprites(); sprites[0].attribute0 = COLOR_256 | SQUARE | y; sprites[0].attribute1 = SIZE_16 | x; sprites[0].attribute2 = 0; for(loop = 0; loop < 128; loop++) { SpriteData[loop] = pacspriteData[loop]; } while(1) { WaitForVsync(); CopyOAM(); } return(0); } void PlotPixel(int x, int y, unsigned short int c) { ScreenBuffer[y * 120 + x] = c; } |