Touchpad dead when allocating 32x32 BMP sprites - SOLVED
Posted: Tue Nov 02, 2010 10:28 am
Hi
I am coding a game where you have to tidy up the room. I have made 5 x 4 pieces of 32x32 px BMP sprites. Total 40960 bytes. I am using VRAM bank A for the sprites so there should be pleanty of space for it. The graphics are stored in four 32x160 px bitmap, to reduce the number of files.
But if I allocate more than 4 sprites, the touch pad goes dead. !!!! But only on a real NDS with DSTT adaptor. When using DeSmuME all works fine.
A different part of the program, I allocate 6 sprites at same size with no problem. I have tried to move the sprites to the sub screen using VRAM bank D, but the problem is still there.
Here are a part of the code.
Can anyone find the logic?
BR
Kasper
I am coding a game where you have to tidy up the room. I have made 5 x 4 pieces of 32x32 px BMP sprites. Total 40960 bytes. I am using VRAM bank A for the sprites so there should be pleanty of space for it. The graphics are stored in four 32x160 px bitmap, to reduce the number of files.
But if I allocate more than 4 sprites, the touch pad goes dead. !!!! But only on a real NDS with DSTT adaptor. When using DeSmuME all works fine.
A different part of the program, I allocate 6 sprites at same size with no problem. I have tried to move the sprites to the sub screen using VRAM bank D, but the problem is still there.
Here are a part of the code.
Code: Select all
#include "T_WildAnimal.h"
#include "T_Doll.h"
#include "T_Car.h"
#include "T_Dino.h"
#define T_TOY_TYPES 4
#define T_TOY_VARIANTS 5
u16* apToySprites[T_TOY_TYPES][T_TOY_VARIANTS];
static u16* apSpriteBitmaps[T_TOY_TYPES] = {(u16*)T_DollBitmap, (u16*)T_WildAnimalBitmap, (u16*)T_CarBitmap, (u16*)T_DinoBitmap};
static void T_InitSprites(void)
{
u16* gfxOutPtr; // Pointer to sprite registers
u16* gfxInPtr; // Pointer to sprite registers
vramSetBankA(VRAM_A_MAIN_SPRITE);
oamInit(&oamMain, SpriteMapping_Bmp_1D_128, false);
// allocate and make pointers to the sprites to make them easy to use.
for(int iTypes = 0 ; iTypes < T_TOY_TYPES ; iTypes++) // Loop all the types
{
gfxInPtr = apSpriteBitmaps[iTypes]; // Copy the pointer of the first address for the next toy type of sprites
for(int iVariants= 0 ; iVariants < T_TOY_VARIANTS ; iVariants++) // Loop all the variants
{
gfxOutPtr = apToySprites[iTypes][iVariants] = oamAllocateGfx(&oamMain, SpriteSize_32x32, SpriteColorFormat_Bmp); // Allocate space for the sprite
for(int i = 0; i < 32*32; i++) // write the sprite
{
if (*gfxInPtr)
*gfxOutPtr = *gfxInPtr | 0x8000;
else
*gfxOutPtr = 0;
gfxInPtr++;
gfxOutPtr++;
}
}
}
}
BR
Kasper