#149546 - jonezer4 - Mon Jan 21, 2008 10:06 pm
I'm updating some code and come across a weird issue I can't figure out. The old way I used to set up attribute 1 for sprites was like this:
I'm updating it to the easier to read:
In both of those "n" is just a number incremented in a for loop, 0 to 31.
The old way works perfectly, but the new way, all my sprites seem to share the exact same rotation matrix (matrix 0 it appears). Any ideas? Here's the full code for the relevant area:
Code: |
oamMainP->spriteBuffer[n].attribute[1] = ATTR1_ROTDATA(n) |ATTR1_SIZE_64 | 0;
|
I'm updating it to the easier to read:
Code: |
oamMainP->spriteBuffer[n].posX = 0; oamMainP->spriteBuffer[n].rsMatrixIdx = ATTR1_ROTDATA(n); oamMainP->spriteBuffer[n].objSize = OBJSIZE_64; |
In both of those "n" is just a number incremented in a for loop, 0 to 31.
The old way works perfectly, but the new way, all my sprites seem to share the exact same rotation matrix (matrix 0 it appears). Any ideas? Here's the full code for the relevant area:
Code: |
void initSpritesMain(tOAM* oamMainP, SpriteInfo* spriteInfoMainP) { //init OAM initOAM(oamMainP->spriteBuffer, oamMainP->matrixBuffer, MAIN_SCREEN); for (int n = 0; n < 32; n++) { //Attribute 0 stuff oamMainP->spriteBuffer[n].posY = 0; oamMainP->spriteBuffer[n].isRotoscale = true; oamMainP->spriteBuffer[n].rsDouble = false; oamMainP->spriteBuffer[n].objMode = OBJMODE_NORMAL; oamMainP->spriteBuffer[n].isMosaic = false; oamMainP->spriteBuffer[n].colMode = OBJCOLOR_256; oamMainP->spriteBuffer[n].objShape = OBJSHAPE_SQUARE; //ATTRIBUTE 1 STUFF THAT DOESN'T WORK //oamMainP->spriteBuffer[n].posX = 0; //if (n < 32) // oamMainP->spriteBuffer[n].rsMatrixIdx = ATTR1_ROTDATA(n); //else // oamMainP->spriteBuffer[n].rsMatrixIdx = ATTR1_ROTDATA(31); // oamMainP->spriteBuffer[n].objSize = OBJSIZE_64; //Attribute 1 oamMainP->spriteBuffer[n].attribute[1] = ATTR1_ROTDATA(n) |ATTR1_SIZE_64 | 0; //posX //Attribute 2 oamMainP->spriteBuffer[n].tileIdx = spriteGfxID * n; oamMainP->spriteBuffer[n].objPal = spriteGfxID * n; oamMainP->spriteBuffer[n].objPriority = OBJPRIORITY_3; //lowest hideSprite(&oamMainP->spriteBuffer[n], true); //hide all sprites upon initialization spriteInfoMainP[n].entry = &oamMainP->spriteBuffer[n]; rotateSprite(&oamMainP->matrixBuffer[n], 0); spriteInfoMainP[n].rot = &oamMainP->matrixBuffer[n]; } //Copying all sprite images and palette into dma at once dmaCopyHalfWords(SPRITE_DMA_CHANNEL,cardsTiles,&SPRITE_GFX[0], cardsTilesLen); dmaCopyHalfWords(SPRITE_DMA_CHANNEL, cardsPal,(uint16 *)SPRITE_PALETTE,cardsPalLen); updateOAM(oamMainP->spriteBuffer,MAIN_SCREEN); } |