Hello,
I've some Problems displaying sprites.
The sprites are displayed with the libnds API, but there are always inaccuracies (1 or 2 pixel) (the sprites are not symmetric).
Because of I'm using 16x16 sprites, it doesn't look fine. Sometimes there are black pixels in a sprite where it should be blue...
Can I do something against it, or is that a error of the DS hardware ?
Sprite Errors
Re: Sprite Errors
It's highly unlikely that it's an issue with the DS Hardware. I would say most likely it's a palette problem.
How are you loading the sprites? Are you converting with grit?
How are you loading the sprites? Are you converting with grit?
-
- Posts: 19
- Joined: Wed Apr 15, 2009 3:17 pm
Re: Sprite Errors
Yes, but the problem is, if I take a screenshot and zoom in it looks right ... 
Grit code:

Code: Select all
LoadSpritePal(1,1,eTeleporterPal,512);
CreateSpriteFromGrit(1,12,150,160,1,eTeleporterTiles,eTeleporterTilesLen,16,32);
Code: Select all
define VRAM_I_EXT_PALETTE ((_palette *)VRAM_I)
void UpdateSprite(int Screen, int Number)
{
OamState* oam;
if(Screen==MainScreen)
{
oam=&oamMain;
}
else
{
oam=&oamSub;
}
oamSet(oam,
Number,
Sprites[Screen][Number].x, //X-Koordinate
Sprites[Screen][Number].y, //Y-Koordinate
0,
Sprites[Screen][Number].palette, //use different palettes
Sprites[Screen][Number].Size,
SpriteColorFormat_256Color,
Sprites[Screen][Number].gfx,
Sprites[Screen][Number].rotset,
false,
false,
false, false,
false
);
}
void LoadSpritePal(int Screen, int Number, const unsigned short* PAL, int PalSize)
{
if(Screen==MainScreen)
{
// unlock vram (cannot write to vram while it is mapped as a palette)
vramSetBankG(VRAM_G_LCD);
dmaCopy(PAL,&VRAM_G_EXT_PALETTE[Number][0],PalSize);
// set vram to ex palette
vramSetBankG(VRAM_G_SPRITE_EXT_PALETTE);
}
else
{
vramSetBankI(VRAM_I_LCD);
dmaCopy(PAL,&VRAM_I_EXT_PALETTE[Number][0],PalSize);
vramSetBankI(VRAM_I_SUB_SPRITE_EXT_PALETTE);
}
}
void CreateSprite(int Screen, int Number,int x, int y, int palette, void* GFX,int GfxSize, int Width,int Height)
{
OamState* oam;
if(Screen==MainScreen)
{
oam=&oamMain;
}
else
{
oam=&oamSub;
}
Sprites[Screen][Number].x=x;
Sprites[Screen][Number].y=y;
Sprites[Screen][Number].Width=Width;
Sprites[Screen][Number].Height=Height;
Sprites[Screen][Number].Size=getSize(Width,Height);
Sprites[Screen][Number].palette=palette;
Sprites[Screen][Number].gfx=oamAllocateGfx(oam, getSize( Width,Height), SpriteColorFormat_256Color);
Sprites[Screen][Number].rotset=-1;
dmaCopy(GFX, Sprites[Screen][Number].gfx, GfxSize);
UpdateSprite(Screen,Number);
}
void CreateSpriteFromGrit(int Screen, int Number,int x, int y, int palette, const unsigned int* GFX, int GfxSize , int Width,int Height)
{
CreateSprite(Screen,Number,x,y,palette,(void*)GFX,GfxSize, Width, Height);
}
Code: Select all
#-------------------------------------------------------
# graphics in tile format
#-------------------------------------------------------
-gt
#-------------------------------------------------------
# graphics bit depth is 8 (256 color)
#-------------------------------------------------------
-gB8
-gTFF00FF
Who is online
Users browsing this forum: No registered users and 4 guests