Touchpad dead when allocating 32x32 BMP sprites - SOLVED

Post Reply
kvleonhardt
Posts: 10
Joined: Mon Jun 14, 2010 7:31 am

Touchpad dead when allocating 32x32 BMP sprites - SOLVED

Post by kvleonhardt » 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.

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
Last edited by kvleonhardt on Wed Nov 03, 2010 11:32 am, edited 1 time in total.

kvleonhardt
Posts: 10
Joined: Mon Jun 14, 2010 7:31 am

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

Post by kvleonhardt » Wed Nov 03, 2010 10:41 am

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

WinterMute
Site Admin
Posts: 2003
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

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

Post by WinterMute » Wed Nov 03, 2010 11:29 am

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.
Help keep devkitPro toolchains free, Donate today

Personal Blog

kvleonhardt
Posts: 10
Joined: Mon Jun 14, 2010 7:31 am

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

Post by kvleonhardt » Wed Nov 03, 2010 11:41 am

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

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests