[Release] SDL-3DS 1.2.15 - Simple DirectMedia Layer for 3DS

Discussion in '3DS - Homebrew Development and Emulators' started by nop90, Jan 30, 2017.

  1. nop90
    OP

    nop90 GBAtemp Maniac

    Member
    1,385
    2,073
    Jan 11, 2014
    Italy
    Rome
    SDL_logo.png 1.2.15​

    This summer I decided to complete the SDL 1.2 port to 3ds started by @Rikku2000 in this thread: https://gbatemp.net/threads/sdl-for-3ds.374519/
    After some months studying the SDL 1.2 internals and experimenting with the Citro3D lib, here is my version of the SDL lib for 3DS. The release number starts from 0.4 because the last Rikku version was v0.3.

    In my version I tried to make a clean port, so when the port is completed, will be possible to easily merge it in the official SDL release (don't know if old v1.2.15 is maintained anymore, but I hope yes).

    In my version I introduced a set of custom flags and functions to handle the 3ds hw peculiarity. Refer to the following post or to the github readme for details.

    I'm porting only the base SDL lib, other libs (SDL_Image, SDL_TTF, SDL_Mixer) don't need any change to be compiled for 3DS, as long as SDLlib is correctly compiled and installed in your DevkitArm toolchain. To help people to compile and install the whole set of libraries, I'll provide later a set of makefiles.

    I' hope that with this well known library available for the 3ds, we will see more and more developers coding for this console.

    PS: After completing the SDL 1.2 port, I'm planning to reuse the code to finish the @xerpi port of SDL 2.0. I know a lot of people prefer SDL2, but I know SDL1.2 better.

    Source code: https://github.com/nop90/SDL-3DS

    Changelog


    v0.9 - (27/07/2017)
    - reduced video thread priority to avoid conflicts with ctulib threads, mainly the NDSP handler one
    - fixed a crash callingSDL_SetVideoMode a secont time, caused by not releasing the scene (shader ans Rendertargets) before loading it again with the new video mode

    v0.8 - (29/05/2017)
    - Fixed bottom screen zoom/positioning in dual screen mode
    - Changed code to maintain screen aspect ratio using SDL_FITWIDTH or SDL_FITHEIGHT custom video flags
    - Aligned mouse movement area to bottom screen visible part in dual screen mode

    v0.7 - (07/04/2017)
    - Video code reworked - GPU freezing highly reduced (played severals SDL games for long time on old and new 3ds without freezes)
    - Fixed SDL_QUIT event triggering on closing the application from Home menu
    - Fixed Audio and Video Therads to not acces DSP ang GPU on app pause and app exiting (SDL_QUIT)
    - Udated to use tatest DevKitPro and ctrulib
    - Using latest fix on Citro3d lib ("Next" branch on github) to reduce GPU freezes
    - added SDL_net. Compiling but untested

    v0.6 - (22/03/2017)

    - Fixed Video Fickering
    - Minor tunings

    v0.5 - (17/02/2017)

    - Fixed Audio, Threads and Timer (by @Wenting )
    - Fixed Joystick
    - Added 8bpp video mode (from @Wenting)
    - Minor tuning
    - Moved lib installation path from portilibs/armv6k to portilibs/3ds (reinslalling please delete the old lib and the include forlder by hand)
    - Fixed the makefile for compiling the pica shader file

    v0.4 - (30/01/2017)
    Respect to Rikku's v0.3 the video device code was completly rewritten using C3D for the final rendering. This means that there is no need to rotate the screen anymore, both top and bottom screens are supported, there are no limits to video sizes (with possibility to HW stretching the video to the 3ds screen size) and there are four available video modes (RGBA8, RGB8, RGB565, RGB5A1).

    Note that the internal drawing routines aren't HW acelerated, C3DS is used only for the final blitting from the videobuffer to the HW framebuffer, allowing for HW screen scaling. So do not expect high farmerate using this lib. Maybe I'll add some optimizations to one of the next releases, but this lib is for simplify the developement on the 3ds, if you need performance there are other low level tools available.

    At the moment the video part is almost completed, the input part is at 50% and the sound device is under developement (so no sound support yet)

    Installation

    Run make install on the provided Makefile.n3ds. This will compile the lib and instal it in the portlibs directory of your devkitarm toolchain.

    To use the lib remember to declare all the libraries dependencies in you makefile ( at least -lSDL -lcitro3d -lctru , for other dependencies refer to the standard SDL 1.2 documentation).

    Known Bugs

    -

    To Do List

    -

    Retroguru games using SDL 1.2 for 3DS (closed source)

    icon.png Hermes - Ported by @Nop90 Released at REVISION 2017, SAARBRÜCKEN (GBATemp Link)

    icon.png Sqrxz3 - Ported by @Nop90 (GBATemp Link)

    Game Engines and Emulators using SDL 1.2 for 3DS

    icon.png NeoPop - Ported by @Nop90 (GBATemp Link)

    ons-en.png Onscripter-EN - Ported by @Nop90 (GBATemp Link)

    List of Homebrews using SDL 1.2 for 3DS

    SDLPal.png SDLPal - Ported by @Wenting (GBATemp Link)
    Meritous.png Meritous - Ported by @nop90 (GBATemp link)
    Opentyrian.png Opentyrian - Ported by @nop90 (GBATemp link)
    icon.png Xrich - Ported by @nop90 (GBATemp link)
    hexahop.png Hex a Hop - Ported by @nop90 (GBATemp link)
    supertux.png Supertux Milestone 1 - Ported by @nop90 (GBATemp link)
    KETM.png KETM - Ported by @nop90 (GBATemp link)
    Zelda3T.png Zelda 3T - Ported by @nop90 (wip)
    icon.png Maze of Galious - Ported by @nop90 (GBATemp link)
    icon.png Amphetamine - Ported by @nop90 (GBATemp link)
    FyWod.png Fy.Wod! - Ported by @nop90 (GBATemp link)
    C-Dogs.png C-Dogs - Ported by @MrHuu (GBATemp link)
     
    Last edited by nop90, Aug 24, 2017


  2. nop90
    OP

    nop90 GBAtemp Maniac

    Member
    1,385
    2,073
    Jan 11, 2014
    Italy
    Rome
    SDL
    Version 1.2.15 Nintendo 3DS port​
    TOC
    - Video
    - Events
    - Key input
    - Joystick
    - Mousepointer
    - Multithread
    - Audio

    VIDEO - 100% completed
    Warning: Spoilers inside!

    EVENTS - 100% completed

    Warning: Spoilers inside!

    KEY INPUT
    - 100% completed
    Warning: Spoilers inside!

    JOYSTICK - 100% completed

    Warning: Spoilers inside!

    MOUSEPOINTER
    - 90% completed

    Warning: Spoilers inside!

    MULTITHREAD - 100% completed

    Warning: Spoilers inside!

    AUDIO
    - 100% completed

    Warning: Spoilers inside!
     
    Last edited by nop90, Feb 28, 2017
  3. thunderjackl

    thunderjackl Advanced Member

    Newcomer
    73
    12
    Oct 5, 2016
    United States
    Cool but I have no idea how to use this lol
     
  4. Joom

    Joom  ❤❤❤

    Member
    3,890
    2,617
    Jan 8, 2016
    United States
    If you're not a developer you have no use for this.
     
  5. DogParty

    DogParty Advanced Member

    Newcomer
    75
    99
    Sep 15, 2015
    United States
    For those who don't know, this is huge. SDL is akin to a 2D version of OpenGL which means a lot of 2D homebrew is based on it. With a proper port of the lib, we can presumably cross compile a lot of games meant for Linux or other systems with homebrew.
     
  6. MajinCubyan

    MajinCubyan The Funky Super Saiyan

    Member
    GBAtemp Patron
    MajinCubyan is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    587
    928
    Nov 24, 2014
    United States
    Orre
    Wow, awesome job! Maybe now my dream of Super Mario War on the 3ds can come true, which is coded in SDL. Can't wait to see what happens now. :D
     
  7. nop90
    OP

    nop90 GBAtemp Maniac

    Member
    1,385
    2,073
    Jan 11, 2014
    Italy
    Rome
    My goal with this lib is to port SMW with a standard SDL lib, instead of changing a lot of code to make it work with a fake SDL layer calling ctruib lowlevel functions.

    I'll try to compile it after completing the audio device code.
     
    SlimPortable, CeeDee and MajinCubyan like this.
  8. MajinCubyan

    MajinCubyan The Funky Super Saiyan

    Member
    GBAtemp Patron
    MajinCubyan is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    587
    928
    Nov 24, 2014
    United States
    Orre
    You, sir, are my hero. I've made custom graphics, maps, and sprites for that game. Thank you.

    I was just looking for the source code to share it with people too, Haha.
     
    Last edited by MajinCubyan, Jan 30, 2017
  9. realWinterMute

    realWinterMute Member

    Newcomer
    32
    28
    Feb 24, 2011
    You'll get a cleaner port if you start with the git mirror instead of just starting your own git repo.

    I did make a start eons ago but never really found the time to actually learn enough SDL to figure out the rest of the port.

    https://github.com/SDL-mirror is the official mirror.

    Please don't do this. The msys setup provided with devkitARM will allow configure && make which will perform various tests against the toolchains & set things up properly.

    This port should also go in $DEVKITPRO/portlibs/3ds since it is a 3ds specific port rather than generic armv6k

    The way you've set up your repository makes it very difficult to see what changes you've actually made to the upstream sources unfortunately.

    I've dug out the intitial changes I did to get the autotools setup working & put them up at https://github.com/WinterMute/SDL.

    git checkout SDL-1.2-3DS, run ./autogen to get configure then
    Code:
    PATH=$DEVKITARM/bin:$PATH
    mkdir 3ds-build
    cd 3ds-build
    ../configure --host=arm-none-eabi \
    --prefix=$DEVKITPRO/portlibs/3ds \
    --with-platform=3ds
    
    to get your code in & building you can add the video files to src/video/3ds then add something like this to the arm-none-eabi section
    Code:
    # Set up files for the video library
    if test x$enable_video = xyes; then
    AC_DEFINE(SDL_VIDEO_DRIVER_3DS)
    SOURCES="$SOURCES $srcdir/src/video/3ds/*.c"
    have_video=yes
    fi
    
    or I guess n3ds folder if you prefer.Rerun autogen when you do this.

    Hit me up on irc or devkitpro forums if you need some help with the build system.
     
  10. nop90
    OP

    nop90 GBAtemp Maniac

    Member
    1,385
    2,073
    Jan 11, 2014
    Italy
    Rome
    Thank you for your hints but for the moment I prefer to work with a private repositoy so I can try all the tricks and workaraunds I need to figure out how the sdl internals work.

    I did this way with the video code, than cleaned the most part of it and put it in a std sdl version.

    I'm going to do the same with the audio part.

    I'm worried about the non standard flags and functions I introduced too.

    Probably people will suggest a lot of smart changes. So it's to early to think about merging with the standard repository.

    About the config script I know how to make it work on windows, but it's tricky and some people could find it difficoult, so I used a premade config header file. Other platforms do the same. I could change this later.

    Let me finish the audio code then I'll ask your help to clean everything
     
    Last edited by nop90, Jan 30, 2017
  11. WhySayingMyName

    WhySayingMyName Member

    Newcomer
    29
    6
    Jan 25, 2017
    France
    Good job, is there any chance that SDL2 will get ported as well ?
     
  12. gnmmarechal

    gnmmarechal Kirigiri > Naoto

    Member
    GBAtemp Patron
    gnmmarechal is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    4,533
    2,714
    Jul 13, 2014
    Portugal
    https://gs2012.xyz
    You'd know if you read the thread :3
     
  13. WhySayingMyName

    WhySayingMyName Member

    Newcomer
    29
    6
    Jan 25, 2017
    France
    My bad, I am too much excited about this
     
    gnmmarechal likes this.
  14. gnmmarechal

    gnmmarechal Kirigiri > Naoto

    Member
    GBAtemp Patron
    gnmmarechal is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    4,533
    2,714
    Jul 13, 2014
    Portugal
    https://gs2012.xyz
    Lul

    Sent from my cave of despair where I collect souls
     
  15. Manurocker95

    Manurocker95 Game Dev & Pokémon Master

    Member
    653
    175
    May 29, 2016
    Spain
    Madrid
    Pretty nice! I'll take a look and try something with this ^^
     
    MajinCubyan likes this.
  16. nop90
    OP

    nop90 GBAtemp Maniac

    Member
    1,385
    2,073
    Jan 11, 2014
    Italy
    Rome
    @Wenting forked my project and fixed the sound part (http://gbatemp.net/threads/wip-libsdl-1-2-15-for-3ds.461023/).

    This is a big step ahed; now I'm going to check his code to merge it with my local copy of the project, that has some part not released yet.

    I hope to release a new version for this week end.

    Next things planned are:
    - Implementing the changes proposed by @realWinterMute to have a clean and standard SDL port
    - working on HW acceleration (at the moment the video part is very slow)
     
  17. nop90
    OP

    nop90 GBAtemp Maniac

    Member
    1,385
    2,073
    Jan 11, 2014
    Italy
    Rome
    Updated on github the new code merged with the fixes and the addons made by @Wenting

    Now the lib is complete (added sound, thread and Joystic), but a lot of things can be improved.

    Warning: I moved the installation path from portilibs/armv6k to portilibs/3ds, so before installing the new version remember to delete the old lib and the include folder.
     
  18. WhySayingMyName

    WhySayingMyName Member

    Newcomer
    29
    6
    Jan 25, 2017
    France
    Man that's amazing, though I'm not using SDL 1.2, SDL2 is much better in all points (personnal though and preference)
     
    Last edited by WhySayingMyName, Feb 19, 2017
    Minnow likes this.
  19. nop90
    OP

    nop90 GBAtemp Maniac

    Member
    1,385
    2,073
    Jan 11, 2014
    Italy
    Rome
    The code used for SDL 1.2 will be used to complete the SDL 2 porr started by @xerpi .

    But my time is very limited, if someone want s to contribute to the SDl 2 project he is welcome. Knowing a little of the internals of SDL, completing a first working version of SDL 2 ia s matter of few hours of work.

    I dont want to start a new project before finishing to tune up of this lib, there are a lot of small thing to fix to make it work smooth and flawless
     
  20. nop90
    OP

    nop90 GBAtemp Maniac

    Member
    1,385
    2,073
    Jan 11, 2014
    Italy
    Rome
    Just released Meritous compiled with this lib.

    Porting the game was very easy, and I used it totest and fix le code of the lib.

    There is only a graphic glitch diagonally on the sceen to solve, but thw lib seems to works very fine.

    I'm working on OpenTyrian too (working but no sound yet)
     
    MajinCubyan likes this.