I can't show sprites on ds

Discussion in 'NDS - Emulation and Homebrew' started by Triforce333, Feb 1, 2011.

  1. Triforce333
    OP

    Triforce333 Newbie

    Newcomer
    2
    0
    Feb 1, 2011
    Mersin
    (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:
    [​IMG]
    original sprite is like this:
    [​IMG]
    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?
     
  2. YoshiInAVoid

    YoshiInAVoid GBAtemp Advanced Fan

    Banned
    560
    337
    Jan 10, 2011
    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.
     
  3. Triforce333
    OP

    Triforce333 Newbie

    Newcomer
    2
    0
    Feb 1, 2011
    Mersin
    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 [​IMG]