Ok, so let me explain my problem before I show the code. I've run into a couple of problems where I am getting corrupted tiles when using u16* arrays for sprites with more than one gfx frame. The corruption never exceeds a 32x32 pixel area and is contiguous, usually occupying either an entire 32x32 sprite, or the top 1024 pixels of a 64x64 sprite. Up to this point I have been able to solve this by rearranging the order in which the various graphics are allocated and copied into memory. Today, however, i ran into an issue that i can't handle this way. I added a 64x64 graphic with 6 frames. After I allocate its memory, the program freezes when I swiCopy() the graphics to memory, and when I dmaCopy(), the program doesn't freeze, but the last member of the array is always addressing to 0x64000, and displaying all the tiles that are actually in that area of memory. I have tried increasing and decreasing the size of the graphics and arrays, and it always has the same result. Here is the code I am working with:
Code: Select all
void SpriteList::loadTiles(){
u16 i;
/* Create pointers & allocate memory for sprite tiles used in this level. (main engine) */
/* Copy tiles data into main OAM. */
afterburnTiles_ptr = oamAllocateGfx(oam, SpriteSize_8x8, SpriteColorFormat_16Color);
swiCopy(afterburn_gfxTiles, afterburnTiles_ptr, afterburn_gfxTilesLen);
asteroidTiles_ptr = oamAllocateGfx(oam, SpriteSize_32x32, SpriteColorFormat_16Color);
swiCopy(asteroid_gfxTiles, asteroidTiles_ptr, asteroid_gfxTilesLen);
laserTiles_ptr = oamAllocateGfx(oam, SpriteSize_32x32, SpriteColorFormat_16Color);
swiCopy(lazer_gfxTiles, laserTiles_ptr, lazer_gfxTilesLen);
membraneTiles_ptr = oamAllocateGfx(oam, SpriteSize_32x32, SpriteColorFormat_16Color);
swiCopy(membrane_gfxTiles, membraneTiles_ptr, membrane_gfxTilesLen);
roamerTiles_ptr = oamAllocateGfx(oam, SpriteSize_32x32, SpriteColorFormat_16Color);
swiCopy(roamer_gfxTiles, roamerTiles_ptr, roamer_gfxTilesLen);
sporeTiles_ptr = oamAllocateGfx(oam, SpriteSize_32x32, SpriteColorFormat_16Color);
swiCopy(spore_gfxTiles, sporeTiles_ptr, spore_gfxTilesLen);
for(i=0; i<3; i++) astxplodTiles_ptr[i] = oamAllocateGfx(oam, SpriteSize_32x32, SpriteColorFormat_16Color);
for(i=0; i<3; i++) swiCopy(&astxplod_gfxTiles[i*128], astxplodTiles_ptr[i], astxplod_gfxTilesLen/3);
for(i=0; i<3; i++) mbrndslvTiles_ptr[i] = oamAllocateGfx(oam, SpriteSize_32x32, SpriteColorFormat_16Color);
for(i=0; i<3; i++) swiCopy(&mbrndslv_gfxTiles[i*128], mbrndslvTiles_ptr[i], mbrndslv_gfxTilesLen/3);
for(i=0; i<5; i++) outlawTiles_ptr[i] = oamAllocateGfx(oam, SpriteSize_32x32, SpriteColorFormat_16Color);
for(i=0; i<5; i++) swiCopy(&outlaw_gfxTiles[i*128], outlawTiles_ptr[i], outlaw_gfxTilesLen/5);
for(i=0; i<3; i++) explode32x32Tiles_ptr[i] = oamAllocateGfx(oam, SpriteSize_32x32, SpriteColorFormat_16Color);
for(i=0; i<3; i++) swiCopy(&explode32x32_gfxTiles[i*128], explode32x32Tiles_ptr[i], explode32x32_gfxTilesLen/3);
for(i=0; i<4; i++) shooterTiles_ptr[i] = oamAllocateGfx(oam, SpriteSize_32x32, SpriteColorFormat_16Color);
for(i=0; i<4; i++) swiCopy(&shooter_gfxTiles[i*128], shooterTiles_ptr[i], shooter_gfxTilesLen/4);
for(i=0; i<4; i++) skirmerTiles_ptr[i] = oamAllocateGfx(oam, SpriteSize_32x32, SpriteColorFormat_16Color);
for(i=0; i<4; i++) swiCopy(&skirmer_gfxTiles[i*128], skirmerTiles_ptr[i], skirmer_gfxTilesLen/4);
for(i=0; i<4; i++) skirmLordTiles_ptr[i] = oamAllocateGfx(oam, SpriteSize_64x64, SpriteColorFormat_16Color);
for(i=0; i<4; i++) swiCopy(&skirmLord_gfxTiles[i*512], skirmLordTiles_ptr[i], skirmLord_gfxTilesLen/4);
for(i=0; i<6; i++) explode64x64Tiles_ptr[i] = oamAllocateGfx(oam, SpriteSize_64x64, SpriteColorFormat_16Color);
for(i=0; i<6; i++) swiCopy(&explode64x64_gfxTiles[i*512], explode64x64Tiles_ptr[i], explode64x64_gfxTilesLen/6);