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 > SDL_LoadBMP crahes SDL on NDS

#164699 - RatherBeerBrew - Fri Nov 14, 2008 3:00 pm

Hi,

I just installed SDL-port for NDS in DevkitPro. But I've got some problems...

if I use "SDL_LoadBMP" to load my .bmp-Images, SDL/NDS crashes. Is there any howto/tutorial f?r using bitmaps on NDS-port of SDL?

Here's what I do:

8< 8< 8< 8< 8< 8< 8< 8<
Code:
pac = SDL_LoadBMP("gfx\pac.bmp");
   if ( pac == NULL) {
      printf("Can't load image of tux: %s", SDL_GetError());
      exit(1);
   };

>8 >8 >8 >8 >8 >8 >8 >8

BTW: on SDL-ports for PC/LINUX/Wii >>this<< source works fine! Any Ideas?

#164704 - Ludo6431 - Fri Nov 14, 2008 7:50 pm

I never used SDL nor on DS neither on PC, but have you correctly initialized the fat system ?

#164758 - RatherBeerBrew - Tue Nov 18, 2008 10:31 am

Ludo6431 wrote:
I never used SDL nor on DS neither on PC, but have you correctly initialized the fat system ?


No, but dark voices told me that NDS is a rom image and fat can't be used. So I have to convert .bmp into .c and bind into my source, right?

#164761 - thedopefish - Tue Nov 18, 2008 3:52 pm

The dark voices lied to you.

You can link binary data like your .bmp directly into your application, which means you get at your data by just referencing a variable rather than loading an actual file. For images in particular, you can use grit to convert them into a DS-friendly format, which makes them more efficient to deal with in your code.

However, you also have the option of using libfat, which allows you to read and write files just like you would in an ordinary PC application.

Also, note that SDL is not really ideal to use on the DS, because it does not take full advantage of the hardware. You should consider looking into the DS' native graphics functionality instead.
_________________
#include <sig.h>

#164808 - HyperHacker - Sat Nov 22, 2008 6:07 am

RatherBeerBrew wrote:
Code:
pac = SDL_LoadBMP("gfx\pac.bmp");
   if ( pac == NULL) {
      printf("Can't load image of tux: %s", SDL_GetError());
      exit(1);
   };
"gfx/pac.bmp"
_________________
I'm a PSP hacker now, but I still <3 DS.

#164810 - Ludo6431 - Sat Nov 22, 2008 9:21 am

I'm sure that you can't load your ".c" bmp like this :
Code:
pac = SDL_LoadBMP("gfx\pac.bmp");
   if ( pac == NULL) {
      printf("Can't load image of tux: %s", SDL_GetError());
      exit(1);
   };


I think SDL_LoadBMP load a bmp from the fat fs.
try to add :
Code:

#include <fat.h>
if(!fatInitDefault()) {
printf("Can't initialise fat fs\n");
exit(1);
}

on top of your code.

put this instead of your code :
Code:
pac = SDL_LoadBMP("/pac.bmp");
   if ( pac == NULL) {
      printf("Can't load image of tux: %s", SDL_GetError());
      exit(1);
   };

and put the file pac.bmp on the root of your memory card.