diff --git a/arch/3ds/CONFIG.3DS b/arch/3ds/CONFIG.3DS index d158f4365..9231b3aee 100755 --- a/arch/3ds/CONFIG.3DS +++ b/arch/3ds/CONFIG.3DS @@ -1,4 +1,6 @@ #!/bin/sh ./config.sh --platform 3ds --enable-release --enable-meter --disable-utils \ - --enable-tremor --disable-screenshots --enable-stdio-redirect "$@" + --disable-sdl --enable-tremor --disable-screenshots \ + --enable-stdio-redirect "$@" + diff --git a/arch/3ds/Makefile.in b/arch/3ds/Makefile.in index fa3319bbc..3d2c623cb 100644 --- a/arch/3ds/Makefile.in +++ b/arch/3ds/Makefile.in @@ -61,6 +61,12 @@ endif MACHDEP = -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -mword-relocations +ifneq (${BUILD_SDL},) +# devkitPro's SDL 1.2 port accidentally defines key_press and key_release as +# global symbols. +ARCH_CFLAGS += -Dkey_press=mzx_key_press -Dkey_release=mzx_key_release +endif + ARCH_CFLAGS += ${EXTRA_INCLUDES} ${MACHDEP} -DARM11 -D__3DS__ -Iarch/3ds ARCH_CXXFLAGS += ${ARCH_CFLAGS} ARCH_LDFLAGS += ${EXTRA_LIBS} ${MACHDEP} -specs=3dsx.specs @@ -120,7 +126,15 @@ clean: build := ${build_root}/3ds/megazeux build: package ${build} +ifeq ($(BUILD_SDL),) ${CP} arch/3ds/pad.config ${build} +else +ifeq ($(BUILD_LIBSDL2),) + ${CP} arch/3ds/pad.config.sdl12 ${build}/pad.config +else + ${CP} arch/3ds/pad.config.sdl2 ${build}/pad.config +endif +endif ${CP} ${mzxrun}.3dsx ${build} ifneq (${BUILD_EDITOR},) ${CP} ${mzx}.3dsx ${build} diff --git a/arch/3ds/pad.config.sdl12 b/arch/3ds/pad.config.sdl12 new file mode 100644 index 000000000..fc0a187ed --- /dev/null +++ b/arch/3ds/pad.config.sdl12 @@ -0,0 +1,28 @@ +# Axis 1/2: Circle pad x/y +# Hat: Directional pad +# Button1: Start +# Button2: A +# Button3: B +# Button4: X +# Button5: Y +# Button6: Left shoulder +# Button7: Right shoulder +# Button8: Select +# Button9: ZL (NOTE: New 3DS only) +# Button10: ZR (NOTE: New 3DS only) + +joy1hat = act_up, act_down, act_left, act_right +joy1axis1 = act_l_left, act_l_right +joy1axis2 = act_l_up, act_l_down +joy1button1 = act_start +joy1button2 = act_a +joy1button3 = act_b +joy1button4 = act_x +joy1button5 = act_y +joy1button6 = act_lshoulder +joy1button7 = act_rshoulder +joy1button8 = act_select +joy1button9 = act_ltrigger +joy1button10 = act_rtrigger +joy1.axis_lx = 1 +joy1.axis_ly = 2 diff --git a/arch/3ds/pad.config.sdl2 b/arch/3ds/pad.config.sdl2 new file mode 100644 index 000000000..e0e3ffbac --- /dev/null +++ b/arch/3ds/pad.config.sdl2 @@ -0,0 +1,34 @@ +# Axis 1/2: Circle pad x/y +# Button1: A +# Button2: B +# Button3: Select +# Button4: Start +# Button5: Right +# Button6: Left +# Button7: Up +# Button8: Down +# Button9: Right shoulder +# Button10: Left shoulder +# Button11: X +# Button12: Y +# Button15: ZL (NOTE: New 3DS only) +# Button16: ZR (NOTE: New 3DS only) + +joy1axis1 = act_l_left, act_l_right +joy1axis2 = act_l_up, act_l_down +joy1button1 = act_a +joy1button2 = act_b +joy1button3 = act_select +joy1button4 = act_start +joy1button5 = act_right +joy1button6 = act_left +joy1button7 = act_up +joy1button8 = act_down +joy1button9 = act_rshoulder +joy1button10 = act_lshoulder +joy1button11 = act_x +joy1button12 = act_y +joy1button15 = act_ltrigger +joy1button16 = act_rtrigger +joy1.axis_lx = 1 +joy1.axis_ly = 2 diff --git a/config.sh b/config.sh index a13639f60..9e84e3d9e 100755 --- a/config.sh +++ b/config.sh @@ -737,8 +737,7 @@ echo "LICENSEDIR=$LICENSEDIR" >> platform.inc # # Platform-specific libraries, or SDL? # -if [ "$PLATFORM" = "3ds" ] || - [ "$PLATFORM" = "nds" ] || +if [ "$PLATFORM" = "nds" ] || [ "$PLATFORM" = "nds-blocksds" ] || [ "$PLATFORM" = "djgpp" ] || [ "$PLATFORM" = "dreamcast" ] || @@ -877,6 +876,18 @@ if [ "$PLATFORM" = "3ds" ]; then IPV6="false" fi +# +# If the 3DS arch is enabled and SDL 1.2 is used, softscale is not +# available. On SDL 2.0, due to the rendering pipeline not supporting +# hardware acceleration as of writing, it is available, but with +# unsatisfactory performance. As a workaround, use the GP2X +# 320x240 renderer. +# +if [ "$PLATFORM" = "3ds" ] && [ "$SDL" = "true" ]; then + echo "Force-enabling GP2X 320x240 renderer (SDL on 3DS)." + GP2X="true" +fi + # # If the Wii arch is enabled, some code has to be compile time # enabled too. @@ -1501,6 +1512,15 @@ if [ "$PLATFORM" = "wii" ] && [ "$SDL" = "false" ]; then echo "BUILD_RENDER_GX=1" >> platform.inc fi +# +# CTR renderer (3DS) +# +if [ "$PLATFORM" = "3ds" ] && [ "$SDL" = "false" ]; then + echo "Building custom CTR renderer." + echo "#define CONFIG_RENDER_CTR" >> src/config.h + echo "BUILD_RENDER_CTR=1" >> platform.inc +fi + # # GP2X renderer # diff --git a/docs/platform_matrix.html b/docs/platform_matrix.html index 1069c779d..634090942 100644 --- a/docs/platform_matrix.html +++ b/docs/platform_matrix.html @@ -53,7 +53,7 @@ var no_low_memory = subopt("NO", 5); var no_updater = subopt("NO", 6); var no_updater_unix = subopt("NO", 7); -var no_sdl_3ds = std("NO", 8); +var optional_sdl_3ds = std("NO / SDL 1.2 / SDL 2", 8); var optional_sdl_wii = std("NO / SDL 1.2", 9); var yes_but_8bpp = subopt("YES (8bpp)", 10); var no_gl_switch = subopt("NO", 11); @@ -168,7 +168,7 @@ adlib_engine: rad, ogg_vorbis: tremor, optimization: speed, - sdl: no_sdl_3ds, + sdl: optional_sdl_3ds, editor: yes, helpsys: yes, audio: yes, diff --git a/src/Makefile.in b/src/Makefile.in index 864b929bf..eeb832ad8 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -154,11 +154,14 @@ endif endif ifeq (${BUILD_3DS},1) +# SDL and platform_sdl.c takes care of all of this when enabled. +ifeq (${BUILD_SDL},) core_cobjs += arch/3ds/shader_2d.shbin.o arch/3ds/shader_playfield.shbin.o core_cobjs += arch/3ds/platform.o arch/3ds/render.o core_cobjs += arch/3ds/event.o arch/3ds/audio.o core_cobjs += arch/3ds/keyboard.o endif +endif ifeq (${BUILD_WII},1) # SDL and platform_sdl.c takes care of all of this when enabled. diff --git a/src/configure.c b/src/configure.c index 2956c29f3..de5cbaaf6 100644 --- a/src/configure.c +++ b/src/configure.c @@ -99,6 +99,12 @@ #endif #ifdef CONFIG_3DS +#ifdef CONFIG_SDL +#define VIDEO_OUTPUT_DEFAULT "gp2x" +#define FULLSCREEN_WIDTH_DEFAULT 400 +#define FULLSCREEN_HEIGHT_DEFAULT 240 +#define FORCE_BPP_DEFAULT 16 +#endif #define VIDEO_RATIO_DEFAULT RATIO_CLASSIC_4_3 #define VFS_ENABLE_DEFAULT true #define VFS_MAX_CACHE_SIZE_DEFAULT (1 << 25) /* 32 MiB */ diff --git a/src/event_sdl.c b/src/event_sdl.c index 16608cb5e..9d3e8f4b4 100644 --- a/src/event_sdl.c +++ b/src/event_sdl.c @@ -1650,10 +1650,11 @@ void __warp_mouse(int x, int y) void initialize_joysticks(void) { -#if !SDL_VERSION_ATLEAST(2,0,0) || defined(CONFIG_SWITCH) || defined(CONFIG_PSVITA) +#if !SDL_VERSION_ATLEAST(2,0,0) || defined(CONFIG_SWITCH) || defined(CONFIG_PSVITA) \ + || defined(CONFIG_3DS) // SDL 1.2 doesn't have joystick added/removed events. - // Switch SDL doesn't seem to generate these events at all on startup. The vita - // appears to have the same issue. + // Switch SDL doesn't seem to generate these events at all on startup. The Vita + // and 3DS appear to have the same issue. int i, count; count = SDL_NumJoysticks(); diff --git a/src/graphics.c b/src/graphics.c index fd77f562f..70002742b 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -90,8 +90,10 @@ static const struct renderer_data renderers[] = { "nds", render_nds_register }, #endif #if defined(CONFIG_3DS) +#if defined(CONFIG_RENDER_CTR) { "3ds", render_ctr_register }, #endif +#endif #if defined(CONFIG_WII) #if defined(CONFIG_RENDER_GX) { "gx", render_gx_register },