#4281 - fezz1k - Wed Mar 26, 2003 2:10 pm
hey there..
something weird is happening with my code. i've programmed in c/c++ for years, but for my first gba attempt, i figured i'd make a tetris clone. when setting up my sprites (one for each of the types of block types), the attribute0 setting for the fifth sprite always reset itself. this was driving me crazy, and i couldn't get started with any real progress, because i couldn't figure out why it was doing this. lo and behold, if at the end of the function where i set all this stuff up, i manually just set it once again, everything works fine. so i'm continuing my work on this, but i still can't figure out for the life of me what's happening! perhaps someone else could clue me in?
thanks
this is the code that's been ruffling my feathers (you can see at the end where i set the attribute again.. with that line commented, it is like i never set it at all):
something weird is happening with my code. i've programmed in c/c++ for years, but for my first gba attempt, i figured i'd make a tetris clone. when setting up my sprites (one for each of the types of block types), the attribute0 setting for the fifth sprite always reset itself. this was driving me crazy, and i couldn't get started with any real progress, because i couldn't figure out why it was doing this. lo and behold, if at the end of the function where i set all this stuff up, i manually just set it once again, everything works fine. so i'm continuing my work on this, but i still can't figure out for the life of me what's happening! perhaps someone else could clue me in?
thanks
this is the code that's been ruffling my feathers (you can see at the end where i set the attribute again.. with that line commented, it is like i never set it at all):
Code: |
void LoadSprites() { // should probably return a value, but not as concerned the info won't be there w/ roms char snum; // sprite we are dealing with. each represents a block type, 0-6 int lcv; s16 x,y; //u16* charMem = (u16*)0x6010000; //u16* objpalMem = (u16*)0x5000200; for (lcv=0;lcv<23;lcv++) { OBJPaletteMem[lcv]=palette[lcv]; } y=160; // init offscreen, since all 6 will technically always be there x=240; for (lcv=0;lcv<128;lcv++) { OAMdata[lcv]=obj0[lcv]; } for (lcv=0;lcv<256;lcv++) { OAMdata[lcv+128]=obj1[lcv]; } for (lcv=0;lcv<256;lcv++) { OAMdata[lcv+384]=obj2[lcv]; } for (lcv=0;lcv<128;lcv++) { OAMdata[lcv+640]=obj3[lcv]; } for (lcv=0;lcv<256;lcv++) { OAMdata[lcv+768]=obj4[lcv]; } for (lcv=0;lcv<256;lcv++) { OAMdata[lcv+1024]=obj5[lcv]; } for (lcv=0;lcv<256;lcv++) { OAMdata[lcv+1280]=obj6[lcv]; } snum=0; // line block | sprites[snum].attribute0 = COLOR_256 | WIDE | y; sprites[snum].attribute1 = SIZE_16 | x; sprites[snum].attribute2 = 0; snum=1; // backwards L |_ sprites[snum].attribute0 = COLOR_256 | WIDE | y; sprites[snum].attribute1 = SIZE_32 | x; sprites[snum].attribute2 = 8; snum=2; // forwards L _| sprites[snum].attribute0 = COLOR_256 | WIDE | y; sprites[snum].attribute1 = SIZE_32 | x; sprites[snum].attribute2 = 24; snum=3; // square piece [] sprites[snum].attribute0 = COLOR_256 | SQUARE | y; sprites[snum].attribute1 = SIZE_16 | x; sprites[snum].attribute2 = 40; snum=4; // squiggle left \ sprites[snum].attribute0 = COLOR_256 | WIDE | y; sprites[snum].attribute1 = SIZE_32 | x; sprites[snum].attribute2 = 48; snum=5; // squiggle right / sprites[snum].attribute0 = COLOR_256 | WIDE | y; sprites[snum].attribute1 = SIZE_32 | x; sprites[snum].attribute2 = 64; snum=6; // easy fit piece _+_ sprites[snum].attribute0 = COLOR_256 | WIDE | y; sprites[snum].attribute1 = SIZE_32 | x; sprites[snum].attribute2 = 80; sprites[4].attribute0 = COLOR_256 | WIDE | y; // don't ask me why i have to do this (again), but i do. } |