Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

SDL-3DS: Difference between revisions

From GameBrew
No edit summary
m (Text replacement - "Category:PC utilities for 3DS homebrew" to "")
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Infobox 3DS homebrew
{{Infobox 3DS Homebrews
| title = SDL-3DS
|title=SDL-3DS
| image = https://dlhb.gamebrew.org/3dshomebrew/SDL_logo.png|250px
|image=Sdl3ds2.png
| type = PC Utilities
|description=SDL 1.2 for 3DS.
| version = v0.9
|author=nop90
| licence = Mixed
|lastupdated=2017/07/27
| author = nop90
|type=Developments
| website = https://gbatemp.net/threads/release-sdl-3ds-1-2-15-simple-directmedia-layer-for-3ds.459291/
|version=0.9
| download = https://dlhb.gamebrew.org/3dshomebrew/SDL-3DS.rar
|license=Mixed
| source = https://dlhb.gamebrew.org/3dshomebrew/SDL-3DS.rar
|download=https://dlhb.gamebrew.org/3dshomebrews/sdl3ds.7z
|website=https://gbatemp.net/threads/release-sdl-3ds-1-2-15-simple-directmedia-layer-for-3ds.459291
|source=https://github.com/nop90/SDL-3DS
}}
}}
<youtube> </youtube>
SDL-3DS is a 3DS port of SDL 1.2 - Simple DirectMedia Layer Version 1.2.15.


=SDL-3DS=
==Installation==
 
Extract the zip archive in your devkitPro/portlibs/3ds folder. These libs depend on other libs: refer to the SDL documentation.
SDL 1.2 for 3DS - Simple DirectMedia Layer.
Version 1.2.15 Nintendo 3DS port.
 
==CREDITS==
 
This port of the SDL 1.2 lib to 3ds was made with the help of several coders of the 3ds scene: Xerpi, Rikku2000, Nop90, Wenting,
The autotools scripts where tuned with the help of WinterMute (maintainer of DevkitPro)
 
==INSTALLATION==


Run make all to build and install:
Run make all to build and install:
Line 32: Line 25:
* SDL_sound
* SDL_sound
* SDL_gfx
* SDL_gfx
The installation script for SDL_image and SDL_gfx need to be fixed, so the global makefile uses two prebuilt makefiles.


The installation script for SDL_image and SDL_gfx need to be fixed, so the global makefile uses two prebuilt makefiles.
==User guide==
 
===Video===
==VIDEO==
The video device will be rendered centered on the HW screen (default screen is the TOP one). Five bpp modes supported: 32 (RGBA8), 24 (RGB8), 16 (RGB565), 15 (RGB555_A1), 8 (paletted)  
 
the video device will be rendered centered on the HW screen (default screen is the TOP one)  
 
five bpp modes supported : 32 (RGBA8), 24 (RGB8), 16 (RGB565), 15 (RGB555_A1), 8 (paletted)  


With these video sizes can be used the following options:
With these video sizes can be used the following options:
* SDL_FULLSCREEN - Option stretchs the video device on the HW screen.
* SDL_TOPSCR - Select the top screen for rendering the video device (it's the default option, so you don't really need to set this flag).
* SDL_BOTTOMSCR - Select the bottom screen for rendering the video device.
* SDL_DUALSCR - Draws the upper half of the video device on the top screeen and the lower half on the bottom screen.
* SDL_FITWIDTH - Resizes the video device to fit the selected screen width (if SDL_DUALSCR is set, it's resized to 400 pixel width).
* SDL_FITHEIGHT - Resizes the video device to fit the screen/screens height.
* SDL_CONSOLETOP - Enables console output on the top screen (only if SDL_TOPSCR or SDL_FULLSCREEN are not set).
* SDL_CONSOLEBOTTOM - Enables console output on the bottom screen (only if SDL_BOTTOMSCR or SDL_FULLSCREEN are not set).


* SDL_FULLSCREEN option stretchs the video device on the HW screen.
'''Note:''' using the SDL_FULLSCREEN flag is the same of using (SDL_TOPSCR | SDL_BOTTOMSCR).
* SDL_TOPSCR: select the top screen for rendering the video device (it's the default option, so you don't really need to set this flag)
* SDL_BOTTOMSCR: select the bottom screen for rendering the video device
* SDL_DUALSCR: draws the upper half of the video device on the top screeen and the lower half on the bottom screen
* SDL_FITWIDTH: resizes the video device to fit the selected screen width (if SDL_DUALSCR is set, its' resized to 400 pixel width)
* SDL_FITHEIGHT: resizes the video device to fit the screen/screens height
* SDL_CONSOLETOP: enables console output on the top screen (only if SDL_TOPSCR or SDL_FULLSCREEN are not set)
* SDL_CONSOLEBOTTOM: enables console output on the bottom screen (only if SDL_BOTTOMSCR or SDL_FULLSCREEN are not set)
 
Note: using the SDL_FULLSCREEN flag is the same of using (SDL_TOPSCR | SDL_BOTTOMSCR)  


==EVENTS==
===Events===
 
* SDL events handles the interaction with the 3ds home menu in homebrews released in installable format (CIA).  
SDL events handles the interaction with the 3ds home menu in homebrews released in installable format (CIA). The lib puts the code in the sleep mode when closing the lid and triggers a SDL_QUIT event when closing the app from the 3ds home menu.
* The lib puts the code in the sleep mode when closing the lid and triggers a SDL_QUIT event when closing the app from the 3ds home menu.
 
* Rmember that once the SDL_QUIT event is triggered, the code can't access anymore to the video services or thecode will hung.
Rmember that once the SDL_QUIT event is triggered, the code can't access anymore to the video services or thecode will hung.
 
==KEY INPUT==


===Key Iuput===
Default key bindings are:
Default key bindings are:
KEY_A      -> SDLK_a
KEY_B      -> SDLK_b
KEY_X      -> SDLK_x
KEY_Y      -> SDLK_y
KEY_L      -> SDLK_l
KEY_R      -> SDLK_r
KEY_ZL    -> SDLK_LSHIFT
KEY_ZR    -> SDLK_RSHIFT
KEY_START  -> SDLK_RETURN
KEY_SELECT -> SDLK_ESCAPE
KEY_RIGHT  -> SDLK_RIGHT
KEY_LEFT  -> SDLK_LEFT
SDLK_UP    -> KEY_UP
KEY_DOWN  -> SDLK_DOWN


* KEY_A -> SDLK_a
There is a custom function to bind one or more N3DS keys to a SDL key value:
* KEY_B -> SDLK_b
void SDL_N3DSKeyBind(unsigned int hidkey, SDLKey key)
* KEY_X -> SDLK_x
* KEY_Y -> SDLK_y
* KEY_L -> SDLK_l
* KEY_R -> SDLK_r
* KEY_ZL -> SDLK_LSHIFT
* KEY_ZR -> SDLK_RSHIFT
* KEY_START -> SDLK_RETURN
* KEY_SELECT -> SDLK_ESCAPE
* KEY_RIGHT -> SDLK_RIGHT
* KEY_LEFT -> SDLK_LEFT
* SDLK_UP -> KEY_UP
* KEY_DOWN -> SDLK_DOWN
 
there is a custom function to bind one or more N3DS keys to a SDL key value:
 
* void SDL_N3DSKeyBind(unsigned int hidkey, SDLKey key)
 
NOTE: circle pad and C-Stick are not mapped to the direction key by default( circle pad is mapped to the default Joystick) but if someone wants to make this mapping he can use the following code:


* SDL_N3DSKeyBind(KEY_CPAD_UP|KEY_CSTICK_UP, SDLK_UP);
'''Note:''' circle pad and C-Stick are not mapped to the direction key by default( circle pad is mapped to the default Joystick) but if someone wants to make this mapping he can use the following code:
* SDL_N3DSKeyBind(KEY_CPAD_DOWN|KEY_CSTICK_DOWN, SDLK_DOWN);
SDL_N3DSKeyBind(KEY_CPAD_UP|KEY_CSTICK_UP, SDLK_UP);
* SDL_N3DSKeyBind(KEY_CPAD_LEFT|KEY_CSTICK_LEFT, SDLK_LEFT);
SDL_N3DSKeyBind(KEY_CPAD_DOWN|KEY_CSTICK_DOWN, SDLK_DOWN);
* SDL_N3DSKeyBind(KEY_CPAD_RIGHT|KEY_CSTICK_RIGHT, SDLK_RIGHT);
SDL_N3DSKeyBind(KEY_CPAD_LEFT|KEY_CSTICK_LEFT, SDLK_LEFT);
SDL_N3DSKeyBind(KEY_CPAD_RIGHT|KEY_CSTICK_RIGHT, SDLK_RIGHT);


It's not possible to bind a N3DS key to two or more SDL Key values.
It's not possible to bind a N3DS key to two or more SDL Key values.


==JOYSTICK==
===Joystick===
 
* Joystick support is enabled.
Joystick support is enabled
 
==MOUSEPOINTER==
 
Mouse pointer is controlled with the touchpad. Touching the bottom screen controls the pointer position and trigger a left button click.


==AUDIO==
===Mousepointer===
* Mouse pointer is controlled with the touchpad.
* Touching the bottom screen controls the pointer position and trigger a left button click.


Supported audio format are AUDIO_S8 and AUDIO_S16.
===Audio===
* Supported audio format are AUDIO_S8 and AUDIO_S16.
* Audio uses the DSP, so to use it with a homebrew compiled as a CIA you need to dump the DSp Firm in the 3ds folder.
* Audio thread would have a higher priority than the main thread, but it would give main thread a fixed time to process the audio.
* If you are experiencing problems with the audio, try using a larger sample buffer or change the delay time in SDL_n3dsaudio.c


Audio uses the DSP, so to use it with a homebrew compiled as a CIA you need to dump the DSp Firm in the 3ds folder.  
===Multithread===
Audio thread would have a higher priority than the main thread, but it would give main thread a fixed time to process the audio. If you are experiencing problems with the audio, try using a larger sample buffer or change the delay time in SDL_n3dsaudio.c
* Multithread is supported. But please bear in mind that due to the design of 3DS' OS, thread won't evenly share CPU time.
* You would have to use SDL_Delay to give other threads CPU time to run.  
* All threads would be created with a higher priority than the main thread, and they would start running as soon as you create them.


==MULTITHREAD==
==Changelog==
'''v0.9 2007/07/27'''
* 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.


Multithread is supported. But please bear in mind that due to the design of 3DS' OS, thread won't evenly share CPU time. You would have to use SDL_Delay to give other threads CPU time to run. All threads would be created with a higher priority than the main thread, and they would start running as soon as you create them.
'''v0.8 2017/05/29'''
* 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 2017/04/07'''
* 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.


http://www.libsdl.org/
'''v0.6 2017/03/22'''
* Fixed Video Fickering.
* Minor tunings.


First release
'''v0.5 2017/02/17'''
@nop90 nop90 released this on Nov 30, 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.


Extract the zip archive in your devkitPro/portlibs/3ds folder.
'''v0.4 2017/01/30'''
* 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).


These libs depend on other libs: refer to the SDL documentation.
==Credits==
This port of the [http://www.libsdl.org/ SDL 1.2 lib] to 3ds was made with the help of several coders of the 3ds scene: Xerpi, Rikku2000, Nop90, Wenting,


All the dependencies (and many other useful libs for coding homebrews for the 3ds) can be installed using the makefile that can be found at: http://github.com/devkitPro/3ds_portlibs
The autotools scripts where tuned with the help of WinterMute (maintainer of DevkitPro).


Happy coding :-)
==External links==
* GitHub - https://github.com/nop90/SDL-3DS
* GBAtemp - https://gbatemp.net/threads/release-sdl-3ds-1-2-15-simple-directmedia-layer-for-3ds.459291/

Latest revision as of 04:26, 6 Mayıs 2024

SDL-3DS
Sdl3ds2.png
General
Authornop90
TypeDevelopments
Version0.9
LicenseMixed
Last Updated2017/07/27
Links
Download
Website
Source

SDL-3DS is a 3DS port of SDL 1.2 - Simple DirectMedia Layer Version 1.2.15.

Installation

Extract the zip archive in your devkitPro/portlibs/3ds folder. These libs depend on other libs: refer to the SDL documentation.

Run make all to build and install:

  • SDL
  • SDL_ttf
  • SDL_mixer
  • SDL_image
  • SDL_net
  • SDL_sound
  • SDL_gfx

The installation script for SDL_image and SDL_gfx need to be fixed, so the global makefile uses two prebuilt makefiles.

User guide

Video

The video device will be rendered centered on the HW screen (default screen is the TOP one). Five bpp modes supported: 32 (RGBA8), 24 (RGB8), 16 (RGB565), 15 (RGB555_A1), 8 (paletted)

With these video sizes can be used the following options:

  • SDL_FULLSCREEN - Option stretchs the video device on the HW screen.
  • SDL_TOPSCR - Select the top screen for rendering the video device (it's the default option, so you don't really need to set this flag).
  • SDL_BOTTOMSCR - Select the bottom screen for rendering the video device.
  • SDL_DUALSCR - Draws the upper half of the video device on the top screeen and the lower half on the bottom screen.
  • SDL_FITWIDTH - Resizes the video device to fit the selected screen width (if SDL_DUALSCR is set, it's resized to 400 pixel width).
  • SDL_FITHEIGHT - Resizes the video device to fit the screen/screens height.
  • SDL_CONSOLETOP - Enables console output on the top screen (only if SDL_TOPSCR or SDL_FULLSCREEN are not set).
  • SDL_CONSOLEBOTTOM - Enables console output on the bottom screen (only if SDL_BOTTOMSCR or SDL_FULLSCREEN are not set).

Note: using the SDL_FULLSCREEN flag is the same of using (SDL_TOPSCR | SDL_BOTTOMSCR).

Events

  • SDL events handles the interaction with the 3ds home menu in homebrews released in installable format (CIA).
  • The lib puts the code in the sleep mode when closing the lid and triggers a SDL_QUIT event when closing the app from the 3ds home menu.
  • Rmember that once the SDL_QUIT event is triggered, the code can't access anymore to the video services or thecode will hung.

Key Iuput

Default key bindings are:

KEY_A      -> SDLK_a
KEY_B      -> SDLK_b
KEY_X      -> SDLK_x
KEY_Y      -> SDLK_y
KEY_L      -> SDLK_l
KEY_R      -> SDLK_r
KEY_ZL     -> SDLK_LSHIFT
KEY_ZR     -> SDLK_RSHIFT
KEY_START  -> SDLK_RETURN
KEY_SELECT -> SDLK_ESCAPE
KEY_RIGHT  -> SDLK_RIGHT
KEY_LEFT   -> SDLK_LEFT
SDLK_UP    -> KEY_UP
KEY_DOWN   -> SDLK_DOWN

There is a custom function to bind one or more N3DS keys to a SDL key value:

void SDL_N3DSKeyBind(unsigned int hidkey, SDLKey key)

Note: circle pad and C-Stick are not mapped to the direction key by default( circle pad is mapped to the default Joystick) but if someone wants to make this mapping he can use the following code:

SDL_N3DSKeyBind(KEY_CPAD_UP|KEY_CSTICK_UP, SDLK_UP);
SDL_N3DSKeyBind(KEY_CPAD_DOWN|KEY_CSTICK_DOWN, SDLK_DOWN);
SDL_N3DSKeyBind(KEY_CPAD_LEFT|KEY_CSTICK_LEFT, SDLK_LEFT);
SDL_N3DSKeyBind(KEY_CPAD_RIGHT|KEY_CSTICK_RIGHT, SDLK_RIGHT);

It's not possible to bind a N3DS key to two or more SDL Key values.

Joystick

  • Joystick support is enabled.

Mousepointer

  • Mouse pointer is controlled with the touchpad.
  • Touching the bottom screen controls the pointer position and trigger a left button click.

Audio

  • Supported audio format are AUDIO_S8 and AUDIO_S16.
  • Audio uses the DSP, so to use it with a homebrew compiled as a CIA you need to dump the DSp Firm in the 3ds folder.
  • Audio thread would have a higher priority than the main thread, but it would give main thread a fixed time to process the audio.
  • If you are experiencing problems with the audio, try using a larger sample buffer or change the delay time in SDL_n3dsaudio.c

Multithread

  • Multithread is supported. But please bear in mind that due to the design of 3DS' OS, thread won't evenly share CPU time.
  • You would have to use SDL_Delay to give other threads CPU time to run.
  • All threads would be created with a higher priority than the main thread, and they would start running as soon as you create them.

Changelog

v0.9 2007/07/27

  • 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 2017/05/29

  • 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 2017/04/07

  • 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 2017/03/22

  • Fixed Video Fickering.
  • Minor tunings.

v0.5 2017/02/17

  • 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 2017/01/30

  • 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).

Credits

This port of the SDL 1.2 lib to 3ds was made with the help of several coders of the 3ds scene: Xerpi, Rikku2000, Nop90, Wenting,

The autotools scripts where tuned with the help of WinterMute (maintainer of DevkitPro).

External links

Advertising: