gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > How to load an NDS icon?

#75584 - jandujar - Tue Mar 14, 2006 11:42 am

Hello people,

I hope somebody can help me with this.

I have created a function that opens a nds file and then shows it's icon.

But I have a problem, the function works con Desmume, but does not work on others emus or hardware.

I think, it's a palette error.

Can somebody help me? (I use PAlib)

Code:

void nds_icon_create_sprite(u8 screen,u8 sprite,u8 palette,u8* nds_file,u8 x, u8 y){
   u8 puntero[4];
   puntero[0]=nds_file[104];
   puntero[1]=nds_file[105];
   puntero[2]=nds_file[106];
   puntero[3]=nds_file[107];

   u32 mipuntero;
   mipuntero=puntero[3]<<24 | puntero[2]<<16 | puntero[1]<<8 | puntero[0];

   u8 tile[512];
   u8 paleta[32];
   mipuntero+=32;   
   int i;
   
   for(i=0;i<512;i++){
      tile[i]=nds_file[mipuntero+i];
   }
   mipuntero+=512;
   
   for(i=0;i<32;i++){
      paleta[i]=nds_file[mipuntero+i];   
   }
   if(screen==0){
      PA_LoadPal16(PAL_SPRITE0, palette,(void*)paleta);
      PA_CreateSprite (0, sprite, (void*)tile, OBJ_SIZE_32X32,0,0,x,y);      
   }else{ //screen==1
      PA_LoadPal16(PAL_SPRITE1, palette,(void*)paleta);
      PA_CreateSprite (1, sprite, (void*)tile, OBJ_SIZE_32X32,0,0,x,y);      
   }
   
}



I call the function with:


Code:

#include "ejemplo_nds.h"   // ->bin2o

int main(){
        PA_Init();    // Initializes PA_Lib
   PA_InitVBL(); // Initializes a standard VBL

        nds_icon_create_sprite(1,0,0,(u8*)ejemplo_nds,0,0);

        while(1){
           PA_WaitForVBL();
        }
}

_________________
http://jandujar.homelinux.com
http://www.dsrobot.com

#76681 - Payk - Thu Mar 23, 2006 2:42 pm

sorry i have no idea but nice work anyway. eres de espana? hehe
Quote:
,(u8*)ejemplo_nds,0,0);

#76682 - Payk - Thu Mar 23, 2006 2:44 pm

hmhmh but u need to inluclude nds file before compiling?!?! mhmhm what du u think would that be possible when reading the header of the game using chishms fat lib? sure must be possible but its ur aim?

#76683 - Payk - Thu Mar 23, 2006 2:48 pm

dont know if that info is a help for u but i read something like that the icon has fixed size(sure 32x32 but i mean data size) i had problems when i wanted to insert a foto to the icon..it had to much colors but it was less then 256.... so perhaps there is a special way they compressed that icon?!?!

#76692 - tepples - Thu Mar 23, 2006 4:38 pm

You need a 16-color icon.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#76694 - jandujar - Thu Mar 23, 2006 5:16 pm

thx.
I haved resolved the problem one week ago.
_________________
http://jandujar.homelinux.com
http://www.dsrobot.com

#76701 - Payk - Thu Mar 23, 2006 7:20 pm

haha ok.