Page 1 of 1

Touchpad dead when allocating 32x32 BMP sprites - SOLVED

Posted: Tue Nov 02, 2010 10:28 am
by kvleonhardt
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.

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++;		
			}
		}
	}
}
Can anyone find the logic?

BR
Kasper

Re: Touchpad dead when allocating more than 4 32x32 BMP spri

Posted: Wed Nov 03, 2010 10:41 am
by kvleonhardt
Hi again

Fogot to write that I am using the last version of libNDS that runs with DeSmuMe 0.9.6. I do not know the version number but I think it was 1.3.8.

kvleonhardt

Re: Touchpad dead when allocating more than 4 32x32 BMP spri

Posted: Wed Nov 03, 2010 11:29 am
by WinterMute
Hopefully there will be a new desmume release soon but in the meantime you'll be better using a recent SVN build from http://www.emucr.com/search/label/NDS/

If you're using old libnds versions there's no guarantee that you're not running into a bug that has been fixed recently and there's no point me wasting time trying to figure out your problem.

Re: Touchpad dead when allocating 32x32 BMP sprites - SOLVED

Posted: Wed Nov 03, 2010 11:41 am
by kvleonhardt
HI

Wintermute: Thank you for the link to the DeSmuMe build. I thourgth that it only was available in source code. I will upgrade soon.

But the problem is solved. It was not the allocation that gave me problems. It was trying to use oamset with invalid parameters for the location of the bitmap.


kvleonhardt