sprites help.

Post Reply
opearn
Posts: 23
Joined: Tue Feb 17, 2009 11:29 am

sprites help.

Post by opearn » Fri Mar 27, 2009 4:20 pm

hi everyone
i'm trying to load a sprite using this code

Code: Select all

#include <nds.h>
#include "drunkenlogo.h"

int main(void) {
	videoSetMode(MODE_0_2D);
	vramSetBankA(VRAM_A_MAIN_SPRITE);
	u16* gfx = oamAllocateGfx(&oamMain, SpriteSize_64x64, SpriteColorFormat_256Color);
	dmaCopy(drunkenlogoBitmap, gfx, 32*32);
	dmaCopy(drunkenlogoPal, SPRITE_PALETTE, 512);
	while(1) {
		oamSet(&oamMain,0,32,32,0,0,SpriteSize_64x64,SpriteColorFormat_256Color,gfx,-1,false,false,false,false,false);
		swiWaitForVBlank();
		oamUpdate(&oamMain);
	}
	return 0;
}
what do i need to change to make it work?
note: i'm new to libnds's sprites

Sylus101
Posts: 179
Joined: Wed Dec 24, 2008 5:08 am

Re: sprites help.

Post by Sylus101 » Fri Mar 27, 2009 6:08 pm

Off the top of my head, you're missing a call to oamInit() before you allocate memory for the gfx. Are you working from the examples?
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

opearn
Posts: 23
Joined: Tue Feb 17, 2009 11:29 am

Re: sprites help.

Post by opearn » Sat Mar 28, 2009 1:10 am

yeah soz about that, this is a extract from my app and i accidently left that out
but thanks for your help

EDIT* after examining pataters tutorial i have made my simple sprite code.

Here it is

Code: Select all

 /*-------------------------------------------------------------\
|	opearns sprite code										|
| 		based off the devkitpro examples and pataters tut.		|
 \-------------------------------------------------------------*/
#include <nds.h>
#include "drunkenlogo.h"

int main(void) {
	videoSetMode(MODE_0_2D | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D);//set the video mode to 2d
	vramSetBankA(VRAM_A_MAIN_SPRITE); //set up some VRam for sprites
	oamInit(&oamMain, SpriteMapping_Bmp_1D_128, false); //initialize the oam
	u16* gfx = oamAllocateGfx(&oamMain, SpriteSize_64x64, SpriteColorFormat_256Color);//setup the sprite
	dmaCopy(drunkenlogoTiles, gfx, drunkenlogoTilesLen);//load the sprite to gfx (last line)
	dmaCopy(drunkenlogoPal, SPRITE_PALETTE, drunkenlogoPalLen); //copy the sprites palette
	while(1) {//infinite loop
		oamSet(&oamMain,0,32,32,0,0,SpriteSize_64x64,SpriteColorFormat_256Color,gfx,-1,false,false,false,false,false);
		swiWaitForVBlank();
		oamUpdate(&oamMain);
	}
	return 0;
}
the grit has to use tiles so the code for that is here

Code: Select all

# 8 bit bitmap

-gB8

# Tile the image
-gt

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests