#19317 - CyberSlag5k - Sat Apr 17, 2004 4:55 am
I'm just starting to develop for the GBA but am having a bit of a problem. I cannot seem to get my sprite to show up on the screen. Relavent code is as follows:
The background image shows, but no sprite. Interestingly enough, if I move the mode 4 stuff (the background image) to the beginning of main, the background image appears for 1 second and then the screen goes white. Is it possible that my sprite is being displayed but is for some reason taking up the whole screen (and is white)?
Any help would be appreacited.
Code: |
u16* videoBuffeer = ((u16*)0x6000000); u16* paletteMem = ((u16*)0x5000000); u16* OAM = ((u16*)0x7000000); OAMEntry sprites[128]; pRotData rotData = (pRotData)sprites; void copyOAM() { u16* temp; temp = (u16*)sprites; for(u16 i = 0; i < 128*4; i++) OAM[i] = temp[i]; } void initializeSprites() { for(u16 i = 0; i < 128; i++) { sprites[i].attribute0 = 160; sprites[i].attribute1 = 240; } } void VSync() { while((volatile u16)REG_VCOUNT != 160) { } } void plotPixel(int x, int y, unsigned short int c) { videoBuffeer[(y) * 120 + (x)] = (c); } void setMode(u16 mode) { REG_DISPCNT = mode; } int main() { s16 x = 100, y = 60; setMode(MODE_1 | OBJ_ENABLE | OBJ_MAP_1D); for(int i = 0; i < 256; i++) OBJPaletteMem[i] = mySpritePalette[i]; initializeSprites(); sprites[0].attribute0 = COLOR_256 | SQUARE | x; sprites[0].attribute1 = SIZE_64 | y; sprites[0].attribute2 = 0; setMode(MODE_4 | BG2_ENABLE); for(int i = 0; i < 128; i++) OAMdata[i] = mySpriteData[i]; for(int i = 0; i < 256; i++) paletteMem[i] = FFPalette[i]; for(int i = 0; i < 120; i++) for(int j = 0; j < 160; j++) plotPixel(i, j, FFData[j * 120 + i]); while(1) { VSync(); copyOAM(); } return 0; } |
The background image shows, but no sprite. Interestingly enough, if I move the mode 4 stuff (the background image) to the beginning of main, the background image appears for 1 second and then the screen goes white. Is it possible that my sprite is being displayed but is for some reason taking up the whole screen (and is white)?
Any help would be appreacited.