#33585 - ymalik - Wed Jan 05, 2005 8:29 pm
The following program displays a messed up sprite (that's the best way I can describe it). The messed up sprite scrolls fine, though.
The sprite is a 4 bit 64x64. I created the sprites by using gba2gfx as follows:
gfx2gba -t8 -pmario.pal -fsrc mario.bmp
I can't use pcx2sprite because I don't know how to make PCX files.
Thanks,
Yasir
Code: |
#include "stuff.h"
#include "mario.raw.c" #include "mario.pal.c" void wait_vblank(); void process_buttons(s16 *, s16 *); int main(void) { s16 x = 10, y = 10; int i; u16 char_number = 0; Sprite sprite[128]; SetMode(2 | OBJ_ENABLE | OBJ_MAP_1D); // initialize sprites // for(i = 0; i < 128; i++) // { // sprite[0].attribute0 = 160; // sprite[0].attribute1 = 240; // } // copy sprite palette for(i = 0; i < 256; i++) SpritePal[i] = mario_Palette[i]; // copy sprite data for(i = 0; i < 4096; i++) SpriteData[i] = mario_Bitmap[i]; sprite[0].attribute0 = COLOR_16 | y; sprite[0].attribute1 = SIZE_64 | x; sprite[0].attribute2 = char_number; while(1) { process_buttons(&x, &y); sprite[0].attribute0 &= 0; sprite[0].attribute0 = COLOR_16 | y; sprite[0].attribute1 &= 0; sprite[0].attribute1 = SIZE_64 | x; wait_vblank(); SpriteMem[0] = sprite[0].attribute0; SpriteMem[1] = sprite[0].attribute1; SpriteMem[2] = sprite[0].attribute2; SpriteMem[3] = sprite[0].attribute3; } return 0; } void process_buttons(s16 *x, s16 *y) { if(!(*BUTTONS & BUTTON_LEFT)) (*x)--; if(!(*BUTTONS & BUTTON_RIGHT)) (*x)++; if(!(*BUTTONS & BUTTON_UP)) (*y)--; if(!(*BUTTONS & BUTTON_DOWN)) (*y)++; } void wait_vblank(void) { while(!(REG_DISPSTAT & 1)); while(REG_DISPSTAT & 1); } |
The sprite is a 4 bit 64x64. I created the sprites by using gba2gfx as follows:
gfx2gba -t8 -pmario.pal -fsrc mario.bmp
I can't use pcx2sprite because I don't know how to make PCX files.
Thanks,
Yasir