Homebrew I can't show sprites on ds

  • Thread starter Thread starter Triforce333
  • Start date Start date
  • Views Views 1,617
  • Replies Replies 2

Triforce333

New Member
Newbie
Joined
Feb 1, 2011
Messages
2
Reaction score
0
Trophies
0
Age
31
Location
Mersin
XP
87
Country
(My English isn't very well. so i could make mistakes.Sorry)

I'm using this code and i'm using grit 0.8.6 to convert images.
CODE#include
#include
#include "nsmbpng_img_bin.h"
#include "ball_img_bin.h"
#include "nsmbpng_pal_bin.h"
#include "ball_pal_bin.h"
typedef struct {
ÂÂÂÂint x,y; //koordinatlar
ÂÂÂÂSpriteSize size; //boyut
ÂÂÂÂSpriteColorFormat color; //renk
ÂÂÂÂint rot; //döndürme
ÂÂÂÂint palette; //palet
}Sprites;
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
ÂÂÂÂÂÂÂÂint frame=0;
ÂÂÂÂÂÂÂÂu16 sx=0;
ÂÂÂÂÂÂÂÂu16 sy=0;
ÂÂÂÂvideoSetMode(MODE_5_2D);
ÂÂÂÂvideoSetModeSub(MODE_5_2D);
ÂÂÂÂSprites sprite[] = {
ÂÂÂÂ{10,30,SpriteSize_16x16,SpriteColorFormat_256Color,0,0}
ÂÂÂÂ};
ÂÂÂÂvramSetBankA(VRAM_A_MAIN_BG);
ÂÂÂÂvramSetBankB(VRAM_B_MAIN_SPRITE);
ÂÂÂÂvramSetBankC(VRAM_C_SUB_BG);
ÂÂÂÂ
ÂÂÂÂoamInit(&oamMain,SpriteMapping_Bmp_1D_128,false);
ÂÂÂÂint bg3=bgInit(3,BgType_Bmp8,BgSize_B8_256x256,0,0);
ÂÂÂÂu16* spr=oamAllocateGfx(&oamMain,sprite[0].size,sprite[0].color);
ÂÂÂÂ
ÂÂÂÂdmaCopy(nsmbpng_img_bin,bgGetGfxPtr(bg3),49152);
ÂÂÂÂdmaCopy(nsmbpng_pal_bin,BG_PALETTE,512);

ÂÂÂÂdmaCopy(ball_img_bin,spr,256);
ÂÂÂÂdmaCopy(ball_pal_bin,SPRITE_PALETTE,512);
ÂÂÂÂ
ÂÂÂÂiprintf("deneme no=(bilmem kac) :D.\n");
ÂÂÂÂtouchPosition touch;
ÂÂÂÂint snumber=oamCountFragments(&oamMain);
ÂÂÂÂwhile(1) {
ÂÂÂÂÂÂÂÂframe++;
ÂÂÂÂÂÂÂÂswiWaitForVBlank();
ÂÂÂÂÂÂÂÂtouchRead(&touch);
ÂÂÂÂÂÂÂÂsx=touch.px;
ÂÂÂÂÂÂÂÂsy=touch.py;
ÂÂÂÂÂÂÂÂ oamSet(&oamMain,
ÂÂÂÂÂÂÂÂÂÂÂÂ0,
ÂÂÂÂÂÂÂÂÂÂÂÂsprite[0].x,
ÂÂÂÂÂÂÂÂÂÂÂÂsprite[0].y,
ÂÂÂÂÂÂÂÂÂÂÂÂ0,
ÂÂÂÂÂÂÂÂÂÂÂÂsprite[0].palette,
ÂÂÂÂÂÂÂÂÂÂÂÂsprite[0].size,
ÂÂÂÂÂÂÂÂÂÂÂÂsprite[0].color,
ÂÂÂÂÂÂÂÂÂÂÂÂspr,
ÂÂÂÂÂÂÂÂÂÂÂÂsprite[0].rot,
ÂÂÂÂÂÂÂÂÂÂÂÂtrue,false,false,false,false);
ÂÂÂÂÂÂÂÂif (touch.px==0)
ÂÂÂÂÂÂÂÂbgSetCenter(bg3,sx,sy);
ÂÂÂÂÂÂÂÂelse
ÂÂÂÂÂÂÂÂbgSetCenter(bg3,sx-128,sy-96);
ÂÂÂÂÂÂÂÂbgUpdate();
ÂÂÂÂÂÂÂÂoamUpdate(&oamMain);
ÂÂÂÂÂÂÂÂ
ÂÂÂÂÂÂÂÂiprintf("\x1b[10;0H%d",frame);
ÂÂÂÂÂÂÂÂiprintf("\x1b[15;1HX:%4d Y:%4d",touch.px,touch.py);
ÂÂÂÂÂÂÂÂiprintf("\x1b[16;1HNumber of Sprites:%d",snumber);
ÂÂÂÂ}
ÂÂÂÂreturn 0;
}
i'm making nds file without any problem. when i run the code on NO$GBA and DS, bg's are well but the sprite is showing like this:
29fayiv.jpg

original sprite is like this:
1256waw.jpg

I think i can't convert sprite
I've tried many options for converting image but it didn't work.
What must i do for show sprite normally?
Which program i must use for converting images?
 
I think the problem lies within the sprites frame.

I would recommend using the libarry PAlib, put all sprites in the gfx folder and edit the .ini to include oyur sprites whne it compiles all the sprites. All you have to do is use PA_LoadPallete and PA_CreateSprite and it will di the rest! It even comes with loads of examples and special effects on your sprites.
 
I've found the problem I was using wingrit.exe to convert images.
Now i'm making a .grit file in gfx folder

I've used PAlib before. But I want to learn libnds so i'm making practises with libnds

Thanks
smile.gif
 

Site & Scene News

Popular threads in this forum