Simple start NDS File and open image file

Post Reply
ilendemli
Posts: 7
Joined: Tue Aug 25, 2009 3:21 pm

Simple start NDS File and open image file

Post by ilendemli » Fri Sep 10, 2010 3:49 pm

Hello!

I am new and currently programming something.
Currently i have to problems:
First i want to start a nds file but i dont know the code for that. Can somebody give me a simple nds starting code?

And the second one is to open an image file from the filesystem and set it as Background.


Currently code to open an image file:

Code: Select all


consoleInit ( 0, 1, BgType_Text4bpp, BgSize_T_256x256, 0, 6, false, true); //für das untere Bildschirm

    FILE *pFile=fopen ("TTMenu/Starter/Down.bmp","rb");
      
    if (pFile!=NULL)   {
      //file size
      fseek (pFile, 0 , SEEK_END);
      long lSize = ftell (pFile);
      u8 *buffer= (u8*) malloc (sizeof(u8)*lSize);
      rewind (pFile);
      
      if (fread (buffer,1,lSize,pFile) != lSize)
         printf("\n Datei kann nicht gelesen werden\n"); //File could not be read
      
      //copy from buffer
        //dmaCopy(buffer, BG_GFX_SUB, lSize);
        decompress(buffer, BG_GFX_SUB, LZ77Vram); 
    
      //close file and clean buffer
      fclose (pFile);
      free (buffer);
    }
    else printf("\n Datei wurde nicht gefunden!\n"); //File not found


please help

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: Simple start NDS File and open image file

Post by zeromus » Fri Sep 10, 2010 5:44 pm

1. loading an nds file is probably hard. maybe you should master some more basic skills first.
2. you seem not to understand the bmp file format. you seem not to understand ds graphics modes. the two arent the same. You need to use pcx instead, reference examples that load pcx from files in the data directory, and modify them to load from your fopen'd and fread'd buffer instead. then you need to reference the 256_color_bmp example to see how set up the layer correctly and how to load it with the data that you got from the pcx-opening functions.

ilendemli
Posts: 7
Joined: Tue Aug 25, 2009 3:21 pm

Re: Simple start NDS File and open image file

Post by ilendemli » Fri Sep 10, 2010 6:02 pm

hmmm, difficult :S

ilendemli
Posts: 7
Joined: Tue Aug 25, 2009 3:21 pm

Re: Simple start NDS File and open image file

Post by ilendemli » Fri Sep 10, 2010 8:23 pm

Can i display a picture with this code?

Code: Select all

void displayPicture(){
    consoleInit ( 0, 1, BgType_Text4bpp, BgSize_T_256x256, 0, 6, false, true);
    
    FILE *pFile=fopen("Down.png","rb");
      
    if (pFile!=NULL)   {
      decompress("Down.png", BG_GFX_SUB,  LZ77Vram);
    }
    else printf("\n FileNotFound!\n");
}
i have tried it but it wont display.

can somebody give me the source pls

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: Simple start NDS File and open image file

Post by zeromus » Fri Sep 10, 2010 9:09 pm

you seem not to understand the png file format. you seem not to understand ds graphics modes. the two arent the same. applying lz77 decompression to a png binary blob does not result in ds graphics, especially not text4bpp, and indeed not even graphics at all. it results in garbage and maybe even a crash, because a png binary blob is not an lz77 compressed binary blob. the two arent the same.

of course, you arent even decompressing a png binary blob. youre decompressing a string "down.png" which makes even less sense.

it is a waste of time for someone to give you code to load a png from the filesystem because you won't be able to do whatever next step you want to do and youll just ask for that as well.

i suggest tweaking examples while you learn the first thing, instead of trying to make your own code from scratch. the examples don't do things your way, and for good reason.

give up on your first goal and come back to it later. pick a more modest goal.

even if you want to stick to your first goal, which is a mistake, i told you how to do it. you seem to have ignored me by trying a png instead of a pcx and using something other than 256_color_bmp as a basis.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests