image not showing!

codycox.c
Posts: 49
Joined: Thu Mar 08, 2012 2:26 am

image not showing!

Post by codycox.c » Sat May 05, 2012 2:56 am

I made a ds game and tried to display a sprite on the screen. I used grit and it compiled just fine, but when I ran it the sprite did not show up on the screen. here is my code

Code: Select all

#include <nds.h>

//include sprites
 
#include "sprite.h" 
 
int main() {
// Setup the video modes.
videoSetMode( MODE_0_2D );
vramSetPrimaryBanks(VRAM_A_MAIN_SPRITE,VRAM_B_LCD,VRAM_C_LCD,VRAM_D_LCD);
 
//setup sprites
oamInit(&oamMain, SpriteMapping_Bmp_1D_128, false); //initialize the oam
u16* gfx = oamAllocateGfx(&oamMain, SpriteSize_64x64,SpriteColorFormat_256Color);//make room for the sprite
dmaCopy(spriteTiles,gfx, spriteTilesLen);//copy the sprite
dmaCopy(spritePal, SPRITE_PALETTE, spritePalLen); //copy the sprites palette oamEnable(&oamMain);
 
while (1) //infinite loop
{
oamSet(&oamMain,0,0,0,0,0,SpriteSize_64x64,SpriteColorFormat_256Color,gfx,0,false,false,false,false,false);
swiWaitForVBlank();
}
return 0;
}
Any help would be appreciated.

mtheall
Posts: 210
Joined: Thu Feb 03, 2011 10:47 pm

Re: image not showing!

Post by mtheall » Sat May 05, 2012 5:38 pm

After swiWaitForVBlank, you need oamUpdate(&oamMain)

codycox.c
Posts: 49
Joined: Thu Mar 08, 2012 2:26 am

Re: image not showing!

Post by codycox.c » Sat May 05, 2012 8:33 pm

Thanks! It worked but the bottom part of the image is not below the top part it is on the right side of the top part of the image. How can this be fixed?

mtheall
Posts: 210
Joined: Thu Feb 03, 2011 10:47 pm

Re: image not showing!

Post by mtheall » Sat May 05, 2012 9:10 pm

What were the grit options you used? Can you post the image so I can try it out myself with your code and grit options?

codycox.c
Posts: 49
Joined: Thu Mar 08, 2012 2:26 am

Re: image not showing!

Post by codycox.c » Sat May 05, 2012 10:42 pm

I think this is the grit options -#8 bit bitmap
-gB8

#Tile the image
-gt

#cyan transparent
-gT 00FFFF
Attachments
sprite.png
(969 Bytes) Not downloaded yet

mtheall
Posts: 210
Joined: Thu Feb 03, 2011 10:47 pm

Re: image not showing!

Post by mtheall » Sat May 05, 2012 10:53 pm

-gB8 means 8bpp. You need to add -gb for bitmap

codycox.c
Posts: 49
Joined: Thu Mar 08, 2012 2:26 am

Re: image not showing!

Post by codycox.c » Sat May 05, 2012 10:59 pm

It is not a bitmap image it is a png

mtheall
Posts: 210
Joined: Thu Feb 03, 2011 10:47 pm

Re: image not showing!

Post by mtheall » Sat May 05, 2012 11:02 pm

I mean Bmp sprite. There is bitmap sprite and tiled sprite. You said oamInit(&oamMain, SpriteMapping_Bmp_1D_128, false); so that means bitmap sprites.

Code: Select all

#8 bit
-gB8

# bitmap
-gb

#cyan transparent 
-gT 00FFFF
Or you can leave your settings the same and use oamInit(&oamMain, SpriteMapping_1D_128, false); (notice you remove Bmp)

codycox.c
Posts: 49
Joined: Thu Mar 08, 2012 2:26 am

Re: image not showing!

Post by codycox.c » Sun May 06, 2012 3:15 am

I did what you said but the sprite still appeared weird. :?:

mtheall
Posts: 210
Joined: Thu Feb 03, 2011 10:47 pm

Re: image not showing!

Post by mtheall » Sun May 06, 2012 3:19 am

Did you remove -gt from the grit settings?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest