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 Misc > SDL for the Nintendo DS

#59726 - GPFerror - Thu Nov 03, 2005 7:53 pm

Iv released all the libs and sources and some examples on my site.

The SDL port is based off of SDL 1.2.3 so some work is need to upgrade it to the latest version, still needs sound support and filesystem support.

included is SDL_image , libpng-1.2.8 , jpeg-6b , zlib-1.2.2 , SDL_mixer , SDL_ttf , libfreetype , SDL_flic , SDL_gfx , SFont

http://gpf.dcemu.co.uk

Enjoy, fix the source and share :)
Troy Davis(GPF)

#59739 - birslip - Thu Nov 03, 2005 9:40 pm

Thanks!
Support of the ttf is amazing! It works well!
You use hardware's sprites/bg? or bitmap mode?

#59740 - GPFerror - Thu Nov 03, 2005 9:46 pm

its all done on a mode6 1024X512 background bitmap

#59777 - deltro - Fri Nov 04, 2005 1:39 am

Holy crap! Awesome GPF- this is just what the scene needed

<3

#59808 - Humanoid - Fri Nov 04, 2005 5:12 am

Yes! Thanks alot, I've been waiting for a port of this so I can start porting my stuff!

#59916 - Extreme Coder - Sat Nov 05, 2005 2:14 pm

Nice work GPFerror. Until I figure out why the heck libnds doesn't support textures other than 128x128, I'll be using this:)
But the question is: How fast are the gfx routines?

#59953 - GPFerror - Sat Nov 05, 2005 10:20 pm

check out the examples and my SuperMarioWarsDS port to see the lib in action.
http://gpf.dcemu.co.uk

Troy(GPF)

#59955 - Extreme Coder - Sat Nov 05, 2005 10:42 pm

You wouldn't mind posting some docs about the functions,right?:)

#59963 - GPFerror - Sun Nov 06, 2005 12:04 am

http://www.libsdl.org

has all the docs for SDL and links to most of the other libs I believe.

Use the makefile to bin2o your graphics etc, and then use SDL_RWops and SDL_RWFromMem to load them.

or ask me and Ill do my best to help :)

Troy(GPF)

#60035 - Extreme Coder - Sun Nov 06, 2005 3:26 pm

Won't putting them as png's or jpeg's work? I see you've putted libpng and libjpeg there.

#60038 - GPFerror - Sun Nov 06, 2005 4:36 pm

yes, if you use one of examples as a template, put the graphics in the data folder and then either change or add a new section to the makefile that bin2o the file.

Code:
%.gif.o   :   %.gif
#---------------------------------------------------------------------------------
   @echo $(notdir $<)
   @$(bin2o)

then in your code you add an include to bring the file in



Code:
#include <nds.h>


#include <SDL.h>
#include <SDL_image.h>
#include <stdio.h>   
 
#include "troydesktop_gif.h" 
   
int main(void) {   

  SDL_Surface *screen;      
  SDL_Surface *one; 
  SDL_Rect rect; 
 
  /* This is the RWops structure we'll be using */
  SDL_RWops *rw;   

  SDL_Init(SDL_INIT_VIDEO); 
       
  screen = SDL_SetVideoMode(1024,512,8 , SDL_SWSURFACE);
   
  /* This is where we actually create our RWops structure.  Here we're
     instructing SDL to get it from the file pointer we just opened */
 
   rw = SDL_RWFromMem((void*)troydesktop_gif, troydesktop_gif_size);
  /* IMG_LoadPGIF_RW is the RWops version of ,
     IMG_LoadGIF.  This will get the image from the RWops you passed
     in; */

  one = IMG_LoadGIF_RW(rw);
 
  /* Clean up after ourselves */
  SDL_FreeRW(rw);

  /* Haphazard way of getting stuff to the screen */
  rect.x = rect.y = 0; 
  rect.w = 1024;  //width of graphic
  rect.h = 512;   //height of graphic


while(1){
     SDL_BlitSurface(one, NULL, screen, &rect);
 
   SDL_Flip(screen);
  SDL_Delay(5);
}

  return 0;
}

#60051 - Lazy1 - Sun Nov 06, 2005 6:54 pm

I keep getting an undefined reference to SDL_main when trying to compile SDL sopwith.
None of the solutions I found on google seem to work.

Quote:

arm-elf-gcc -g -mno-fpu -mthumb-interwork -specs=ds_arm9.specs -L/c/devkitpro/li
bnds/lib -L/c/devkitpro/libsdl/lib -lnds9 -lSDL arm9.o -o arm9.elf
c:/devkitpro/libsdl/lib\libSDL.a(SDLMain.o): In function `main':
c:/devkitPro/msys/home/Troy.Davis/prj/SDL/source/main/SDLMain.c:15: undefined re
ference to `SDL_main'
make: *** [arm9.elf] Error 1

#60228 - GPFerror - Tue Nov 08, 2005 6:59 am

can you post some of your code or send me a link to the code and ill take a look at it?

Or go over all my examples source and check the Makefiles etc

Troy

#60233 - Lazy1 - Tue Nov 08, 2005 7:55 am

http://sdl-sopwith.sourceforge.net/

I did look at your example makefiles, mine is very different in some ways but linking the objects to libraries is exactly the same.
It's not a compilation issue since both the SDL specific files and the game specific files compile just fine.

I'll take another look again tomorrow, it might be something incredibly small that I overlooked.

#60289 - GPFerror - Tue Nov 08, 2005 6:12 pm

ok let me know , I did a quick 10 minute port of it to see if I could figure out what was wrong, got the 1st screen displaying , just needs to implement controls and be tested on real hardware :)

#60290 - Lazy1 - Tue Nov 08, 2005 6:18 pm

Cool, I'm going to re-write my makefile after lunch and see if I can get it to link with sdl properly.

#60292 - josath - Tue Nov 08, 2005 6:34 pm

I also got it to compile, but it crashes after the diffuculty select screen. I didn't spend much time trying to debug it, but the crash is very strange: it actually restarts back to the beginning of the program.

#62778 - GPFerror - Mon Dec 05, 2005 6:28 pm

finally made a page with all the files for download, since the link were only on the my news page that has since scrolled away.

http://gpf.dcemu.co.uk/ndsSDL.shtml

Troy(GPF)

#63035 - Durandle - Thu Dec 08, 2005 12:28 am

Does it only support 8bit mode? I tried one of the examples you gave in 16 bit and it works right up to the screen init.

Oh and I tried it with PNG files (made the needed changes) and it throws a ton of errors in IMG_png.c

"c:/devkitPro/msys/home/<your-name>/prj/SDL_image/source/IMG_png.c:123: undefined reference to `png_create_read_struct'" ... etc ...

seems to have your DIR structure built into it :P

#74050 - GPFerror - Thu Mar 02, 2006 12:05 am

with the help of parrot on #dsdev, He's has merged the existing code into the SDL 1.2.9 branch and I wrote a new Makefile and fixed a couple things.

I will release soon, its has the same functionallity still, but lib seems smaller.

Was looking through some other OS ports of SDL's existing code and there may be a way of using interupts to play audio instead of needing a threading library on the ds , just is going to take some time to figure that out.

Also have updated SDL_image-1.2.4 and SDL_mixer-1.2.6 and I will update the whole package when I release the code.

Troy(GPF)

#74095 - Durandle - Thu Mar 02, 2006 10:25 am

I know you can't test it your self, but could you replace the fopen, file, fread, etc.... to the DS FAT lib ones? It does work... I know, I could do it some weekend but then we'd end up with two versions of SDLDS floating around.

As for sound... I thought there was a threading lib being added to the DS lib at the moment? Or would using interrupt be less CPU intensive?

#74114 - GPFerror - Thu Mar 02, 2006 4:01 pm

Durandle wrote:
I know you can't test it your self, but could you replace the fopen, file, fread, etc.... to the DS FAT lib ones? It does work... I know, I could do it some weekend but then we'd end up with two versions of SDLDS floating around.

As for sound... I thought there was a threading lib being added to the DS lib at the moment? Or would using interrupt be less CPU intensive?


Yeah I look into adding that, I just realized I have the code you sent me with FAT implemented for that :)

16bit mode is working now , just need to add a few more modes and need to implement doublebuffering (hardware and software).

The working threading lib that I ported(RTAdvanced) doesnt do preemptive threading so it doesnt meet the requirements of the existing SDL code. I still havent been able to get Mighty Max's multithreading code working so I have starting looking into some other possible methods of getting the audio thread working. Looking through the Mint code(atari port?) doesn't use threading but uses interrupts, so it might be possible to mimic the same type of code for the DS.

Still need some way of knowing when the previous audio buffer is done playing and how to tell what its current buffer position is or threading/irq's won't make any difference.

Troy(GPF)
http://gpf.dcemu.co.uk

#74649 - GPFerror - Mon Mar 06, 2006 8:20 pm

OK finally uploaded the newer version of SDL 1.2.9, SDL_image1.2.6 and SDL_mixer-1.2.6 , the precompiled libs and examples have not been updated with the new version yet though.

Troy(GPF)
http://gpf.dcemu.co.uk/ndsSDL.shtml

#74654 - Raziel Fireeye - Mon Mar 06, 2006 8:30 pm

Cool ;)

A question. Its posible to see a DS port of FENIX language (Game developing language also ported to gp32,gp2x,dreamcast) whit this DS SDL ?? (http://fenix.divsite.net/)
Im not asking for someone to port it, only asking if it will be posible.

#74690 - GPFerror - Tue Mar 07, 2006 12:08 am

does the original version use SDL? I know that the gp32 and dreamcast version do, but I cant find Chuis sourcecode anywhere. So im not sure of its portability.

Troy(GPF)

#75037 - Raziel Fireeye - Thu Mar 09, 2006 7:02 pm

I found the GP2X fenix source ;)

http://gp32wip.com/projects/fenixb3_src.zip

#131719 - jandujar - Tue Jun 19, 2007 12:23 pm

hello GPF,

I'm trying to include the SDL in the NDS-DEV-OS.

I successfully build libSDL (applying some changes in Makefile)

But I have problems building libpng. Maybe you have solved them and you can help me.

libpng build successfully, but the test pngtest.c does not.

This is the error.
Code:

arm-eabi-gcc -o pngtest pngtest.o -mthumb -mthumb-interwork -L. -L/home/nds/NDS/LIBS/zlib-1.22/lib -lpng -lz -lm -s
/home/nds/devkitpro/devkitARM_r20/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/lib/thumb/libc.a(lib_a-abort.o): In function `abort':
(.text+0xc): undefined reference to `_exit'
/home/nds/devkitpro/devkitARM_r20/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/lib/thumb/libc.a(lib_a-exit.o): In function `exit':
(.text+0x1a): undefined reference to `_exit'
/home/nds/devkitpro/devkitARM_r20/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/lib/thumb/libc.a(lib_a-fstatr.o): In function `_fstat_r':
(.text+0x10): undefined reference to `_fstat'
/home/nds/devkitpro/devkitARM_r20/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/lib/thumb/libc.a(lib_a-makebuf.o): In function `__smakebuf':
(.text+0x6e): undefined reference to `isatty'
/home/nds/devkitpro/devkitARM_r20/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/lib/thumb/libc.a(lib_a-openr.o): In function `_open_r':
(.text+0x12): undefined reference to `_open'
/home/nds/devkitpro/devkitARM_r20/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/lib/thumb/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
(.text+0xe): undefined reference to `_sbrk'
/home/nds/devkitpro/devkitARM_r20/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/lib/thumb/libc.a(lib_a-signalr.o): In function `_getpid_r':
(.text+0x4): undefined reference to `_getpid'
/home/nds/devkitpro/devkitARM_r20/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/lib/thumb/libc.a(lib_a-signalr.o): In function `_kill_r':
(.text+0x20): undefined reference to `_kill'
/home/nds/devkitpro/devkitARM_r20/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/lib/thumb/libc.a(lib_a-writer.o): In function `_write_r':
(.text+0x12): undefined reference to `_write'
/home/nds/devkitpro/devkitARM_r20/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/lib/thumb/libc.a(lib_a-closer.o): In function `_close_r':
(.text+0xe): undefined reference to `_close'
/home/nds/devkitpro/devkitARM_r20/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/lib/thumb/libc.a(lib_a-lseekr.o): In function `_lseek_r':
(.text+0x12): undefined reference to `_lseek'
/home/nds/devkitpro/devkitARM_r20/bin/../lib/gcc/arm-eabi/4.1.1/../../../../arm-eabi/lib/thumb/libc.a(lib_a-readr.o): In function `_read_r':
(.text+0x12): undefined reference to `_read'
collect2: ld returned 1 exit status
make[1]: *** [pngtest] Error 1
make[1]: Leaving directory `/home/nds/tmp/libpng/libpng-1.2.8/source'
make: *** [all] Error 2


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