diff --git a/Makefile.ngc b/Makefile.ngc index 4b8c0c7c63..fd8b6ff696 100644 --- a/Makefile.ngc +++ b/Makefile.ngc @@ -4,6 +4,8 @@ DEBUG = 0 HAVE_LOGGER = 1 HAVE_FILE_LOGGER = 0 PERF_TEST = 0 +WHOLE_ARCHIVE_LINK = 0 +BIG_STACK = 0 PC_DEVELOPMENT_IP_ADDRESS = "192.168.1.7" PC_DEVELOPMENT_UDP_PORT = 3490 @@ -32,8 +34,15 @@ LIBDIRS := -L$(DEVKITPRO)/libogc/lib/cube -L. MACHDEP := -DGEKKO -DHW_DOL -mogc -mcpu=750 -meabi -mhard-float CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(INCLUDE) -LDFLAGS := $(MACHDEP) -Wl,-Map,$(notdir $(ELF_TARGET)).map -T gx/ld/ogc.ld -LIBS := -lfat -lretro_ngc -logc +ifeq ($(WHOLE_ARCHIVE_LINK), 1) + WHOLE_START := -Wl,--whole-archive + WHOLE_END := -Wl,--no-whole-archive +endif +LDFLAGS := $(MACHDEP) -Wl,-Map,$(notdir $(ELF_TARGET)).map +ifeq ($(BIG_STACK), 1) + LDFLAGS += -T gx/ld/ogc.ld +endif +LIBS := -lfat $(WHOLE_START) -lretro_ngc $(WHOLE_END) -logc OBJ = console/griffin/griffin.o diff --git a/Makefile.wii b/Makefile.wii index d90446e342..ba0a331efb 100644 --- a/Makefile.wii +++ b/Makefile.wii @@ -4,7 +4,8 @@ DEBUG = 0 HAVE_LOGGER = 0 HAVE_FILE_LOGGER = 0 PERF_TEST = 0 -WHOLE_ARCHIVE_LINK = 0 +WHOLE_ARCHIVE_LINK = 0 +BIG_STACK = 0 PC_DEVELOPMENT_IP_ADDRESS = "192.168.1.100" PC_DEVELOPMENT_UDP_PORT = 3490 @@ -36,10 +37,13 @@ LIBDIRS := -L$(DEVKITPRO)/libogc/lib/wii -L. MACHDEP := -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(INCLUDE) ifeq ($(WHOLE_ARCHIVE_LINK), 1) -WHOLE_START := -Wl,--whole-archive -WHOLE_END := -Wl,--no-whole-archive + WHOLE_START := -Wl,--whole-archive + WHOLE_END := -Wl,--no-whole-archive +endif +LDFLAGS := $(MACHDEP) -Wl,-Map,$(notdir $(ELF_TARGET)).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,strdup,-wrap,strndup,-wrap,malloc_usable_size +ifeq ($(BIG_STACK), 1) + LDFLAGS += -T gx/ld/rvl.ld endif -LDFLAGS := $(MACHDEP) -Wl,-Map,$(notdir $(ELF_TARGET)).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,strdup,-wrap,strndup,-wrap,malloc_usable_size -T gx/ld/rvl.ld LIBS := -lfat $(WHOLE_START) -lretro_wii $(WHOLE_END) -logc $(LDFLAGS_WIIUSE) -lbte APP_BOOTER_DIR = wii/app_booter diff --git a/android/phoenix/src/org/retroarch/browser/RetroArch.java b/android/phoenix/src/org/retroarch/browser/RetroArch.java index ad360f0da7..f7cc6373f9 100644 --- a/android/phoenix/src/org/retroarch/browser/RetroArch.java +++ b/android/phoenix/src/org/retroarch/browser/RetroArch.java @@ -59,11 +59,13 @@ public class RetroArch extends Activity implements AdapterView.OnItemClickListener { private IconAdapter adapter; static private final int ACTIVITY_LOAD_ROM = 0; + static private final int ACTIVITY_NATIVE_ACTIVITY = 1; static private String libretro_path; static private Double report_refreshrate; static private final String TAG = "RetroArch-Phoenix"; private ConfigFile config; private ConfigFile core_config; + private String return_file; private final double getDisplayRefreshRate() { // Android is *very* likely to screw this up. @@ -282,6 +284,12 @@ public class RetroArch extends Activity implements } } + if (getCacheDir() != null && getCacheDir().getAbsolutePath() != null) { + return_file = getCacheDir().getAbsolutePath() + File.pathSeparator + ".return"; + } else { + return_file = getDefaultConfigPath() + ".ret"; + } + this.setVolumeControlStream(AudioManager.STREAM_MUSIC); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { @@ -307,11 +315,7 @@ public class RetroArch extends Activity implements startActivity(i); } }) - .setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - } - }); + .setNegativeButton("No", null); alert.show(); } } @@ -349,8 +353,10 @@ public class RetroArch extends Activity implements return internal + File.separator + "retroarch.cfg"; else if (external != null && new File(internal + File.separator + "retroarch.cfg").canWrite()) return external + File.separator + "retroarch.cfg"; - else + else if (getCacheDir() != null && getCacheDir().getAbsolutePath() != null) return getCacheDir().getAbsolutePath() + File.separator + "retroarch.cfg"; + else // emergency fallback, all else failed + return "/mnt/sdcard/retroarch.cfg"; } private void updateConfigFile() { @@ -365,10 +371,10 @@ public class RetroArch extends Activity implements config.setBoolean("video_vsync", prefs.getBoolean("video_vsync", true)); config.setBoolean("input_autodetect_enable", prefs.getBoolean("input_autodetect_enable", true)); config.setBoolean("input_debug_enable", prefs.getBoolean("input_debug_enable", false)); - config.setInt("input_autodetect_icade_profile_pad1", prefs.getInt("input_autodetect_icade_profile_pad1", 0)); - config.setInt("input_autodetect_icade_profile_pad2", prefs.getInt("input_autodetect_icade_profile_pad2", 0)); - config.setInt("input_autodetect_icade_profile_pad3", prefs.getInt("input_autodetect_icade_profile_pad3", 0)); - config.setInt("input_autodetect_icade_profile_pad4", prefs.getInt("input_autodetect_icade_profile_pad4", 0)); + config.setInt("input_autodetect_icade_profile_pad1", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad1", "0"))); + config.setInt("input_autodetect_icade_profile_pad2", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad2", "0"))); + config.setInt("input_autodetect_icade_profile_pad3", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad3", "0"))); + config.setInt("input_autodetect_icade_profile_pad4", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad4", "0"))); config.setDouble("video_refresh_rate", getRefreshRate()); config.setBoolean("video_threaded", prefs.getBoolean("video_threaded", false)); @@ -454,6 +460,7 @@ public class RetroArch extends Activity implements switch (requestCode) { case ACTIVITY_LOAD_ROM: if (data.getStringExtra("PATH") != null) { + new File(return_file).delete(); Toast.makeText(this, "Loading: [" + data.getStringExtra("PATH") + "]...", Toast.LENGTH_SHORT).show(); @@ -461,10 +468,27 @@ public class RetroArch extends Activity implements myIntent.putExtra("ROM", data.getStringExtra("PATH")); myIntent.putExtra("LIBRETRO", libretro_path); myIntent.putExtra("CONFIGFILE", getDefaultConfigPath()); + myIntent.putExtra("RETURN", return_file); myIntent.putExtra("IME", current_ime); - startActivity(myIntent); + startActivityForResult(myIntent, ACTIVITY_NATIVE_ACTIVITY); } break; + case ACTIVITY_NATIVE_ACTIVITY: + AlertDialog.Builder builder = new AlertDialog.Builder(this).setNeutralButton("OK", null); + try { + DataInputStream cacheStream = new DataInputStream(new FileInputStream(return_file)); + int value = cacheStream.readInt(); + cacheStream.close(); + if (value != 0) { + throw new IOException(); + } + } catch (FileNotFoundException e) { + builder.setTitle("Crash").setMessage("RetroArch Crashed").show(); + } catch (IOException e) { + builder.setTitle("Error").setMessage("RetroArch Could not load the chosen ROM.\n\nCheck the Cores Guide for details on valid ROMs for this emulator.").show(); + } + new File(return_file).delete(); + break; } } diff --git a/dist-scripts/ngc-cores.sh b/dist-scripts/ngc-cores.sh index e9eb06f5da..62b3139774 100755 --- a/dist-scripts/ngc-cores.sh +++ b/dist-scripts/ngc-cores.sh @@ -5,12 +5,15 @@ make -C ../ -f Makefile.ngc clean || exit 1 for f in *_ngc.a ; do name=`echo "$f" | sed 's/\(_libretro\|\)_ngc.a$//'` whole_archive= + big_stack= if [ $name = "nxengine" ] ; then whole_archive="WHOLE_ARCHIVE_LINK=1" - echo $name yes + fi + if [ $name = "tyrquake" ] ; then + big_stack="BIG_STACK=1" fi cp -f "$f" ../libretro_ngc.a - make -C ../ -f Makefile.ngc $whole_archive -j3 || exit 1 + make -C ../ -f Makefile.ngc $whole_archive $big_stack -j3 || exit 1 mv -f ../retroarch_ngc.dol ../ngc/pkg/$name.dol rm -f ../retroarch_ngc.dol ../retroarch_ngc.elf ../retroarch_ngc.elf.map done diff --git a/dist-scripts/wii-cores.sh b/dist-scripts/wii-cores.sh index cc0ed766cf..0d90919069 100755 --- a/dist-scripts/wii-cores.sh +++ b/dist-scripts/wii-cores.sh @@ -9,12 +9,15 @@ make -C ../ -f Makefile.wii.salamander pkg || exit 1 for f in *_wii.a ; do name=`echo "$f" | sed 's/\(_libretro\|\)_wii.a$//'` whole_archive= + big_stack= if [ $name = "nxengine" ] ; then whole_archive="WHOLE_ARCHIVE_LINK=1" - echo $name yes + fi + if [ $name = "tyrquake" ] ; then + big_stack="BIG_STACK=1" fi cp -f "$f" ../libretro_wii.a - make -C ../ -f Makefile.wii $whole_archive -j3 || exit 1 + make -C ../ -f Makefile.wii $whole_archive $big_stack -j3 || exit 1 mv -f ../retroarch_wii.dol ../wii/pkg/$name.dol rm -f ../retroarch_wii.dol ../retroarch_wii.elf ../retroarch_wii.elf.map done diff --git a/frontend/frontend_android.c b/frontend/frontend_android.c index cee92d11dc..cf3ae7b336 100644 --- a/frontend/frontend_android.c +++ b/frontend/frontend_android.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "frontend_android.h" #include "../android/native/jni/jni_macros.h" @@ -280,6 +281,12 @@ static bool android_app_start_main(struct android_app *android_app, int *init_re strlcpy(out_args.in, "IME", sizeof(out_args.in)); jni_get(&in_params, &out_args); + // Return value file + out_args.out = android_app->return_file; + out_args.out_sizeof = sizeof(android_app->return_file); + strlcpy(out_args.in, "RETURN", sizeof(out_args.in)); + jni_get(&in_params, &out_args); + (*in_params.java_vm)->DetachCurrentThread(in_params.java_vm); RARCH_LOG("Checking arguments passed ...\n"); @@ -287,6 +294,9 @@ static bool android_app_start_main(struct android_app *android_app, int *init_re RARCH_LOG("Libretro path: [%s].\n", libretro_path); RARCH_LOG("Config file: [%s].\n", config_file); RARCH_LOG("Current IME: [%s].\n", android_app->current_ime); + RARCH_LOG("Return file: [%s].\n", android_app->return_file); + + unlink(android_app->return_file); struct rarch_main_wrap args = {0}; @@ -371,6 +381,19 @@ exit: #endif rarch_main_clear_state(); + int bs_return = bswap_32(init_ret); + FILE *return_file = fopen(android_app->return_file, "w"); + if (return_file) + { + fwrite(&bs_return, 4, 1, return_file); + fclose(return_file); + } + + // returning from the native activity too fast can make the Java frontend not reappear + // work around it only if we fail to load the ROM + if (init_ret != 0) + usleep(1000000); + RARCH_LOG("android_app_destroy!"); if (android_app->inputQueue != NULL) AInputQueue_detachLooper(android_app->inputQueue); diff --git a/frontend/frontend_android.h b/frontend/frontend_android.h index 16e6f21f9f..591493705a 100644 --- a/frontend/frontend_android.h +++ b/frontend/frontend_android.h @@ -49,6 +49,7 @@ struct android_app AInputQueue* pendingInputQueue; ANativeWindow* pendingWindow; char current_ime[PATH_MAX]; + char return_file[PATH_MAX]; }; enum { diff --git a/general.h b/general.h index 6d22a52847..3c88e84d2b 100644 --- a/general.h +++ b/general.h @@ -155,6 +155,7 @@ struct settings struct { char driver[32]; + char gl_context[32]; float xscale; float yscale; bool fullscreen; diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index 6172dcb10b..0fd295240f 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -630,6 +630,6 @@ const gfx_ctx_driver_t gfx_ctx_drm_egl = { gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, NULL, - "drm-egl", + "kms-egl", }; diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index 85b8b7d591..e4bd6f76d1 100644 --- a/gfx/context/xegl_ctx.c +++ b/gfx/context/xegl_ctx.c @@ -369,7 +369,7 @@ static bool gfx_ctx_set_video_mode( if (true_full) { - RARCH_LOG("[GLX]: Using true fullscreen.\n"); + RARCH_LOG("[X/EGL]: Using true fullscreen.\n"); XMapRaised(g_dpy, g_win); } else if (fullscreen) // We attempted true fullscreen, but failed. Attempt using windowed fullscreen. @@ -455,7 +455,7 @@ static void gfx_ctx_destroy(void) g_screen = x11_get_xinerama_monitor(g_dpy, x, y, target.width, target.height); - RARCH_LOG("[GLX]: Saved monitor #%u.\n", g_screen); + RARCH_LOG("[X/EGL]: Saved monitor #%u.\n", g_screen); #endif XUnmapWindow(g_dpy, g_win); diff --git a/gfx/gl.c b/gfx/gl.c index 019c383d02..4748f12c53 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1569,6 +1569,45 @@ static void gl_init_pbo_readback(void *data) #endif } +static const gfx_ctx_driver_t *gl_get_context(void) +{ +#ifdef HAVE_OPENGLES + enum gfx_ctx_api api = GFX_CTX_OPENGL_ES_API; + const char *api_name = "OpenGL ES"; +#else + enum gfx_ctx_api api = GFX_CTX_OPENGL_API; + const char *api_name = "OpenGL"; +#endif + + if (*g_settings.video.gl_context) + { + const gfx_ctx_driver_t *ctx = gfx_ctx_find_driver(g_settings.video.gl_context); + if (ctx) + { + if (!ctx->bind_api(api)) + { + RARCH_ERR("Failed to bind API %s to context %s.\n", api_name, g_settings.video.gl_context); + return NULL; + } + + if (!ctx->init()) + { + RARCH_ERR("Failed to init GL context: %s.\n", ctx->ident); + return NULL; + } + } + else + { + RARCH_ERR("Didn't find GL context: %s.\n", g_settings.video.gl_context); + return NULL; + } + + return ctx; + } + else + return gfx_ctx_init_first(api); +} + static void *gl_init(const video_info_t *video, const input_driver_t **input, void **input_data) { #ifdef _WIN32 @@ -1589,11 +1628,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo if (!gl) return NULL; -#ifdef HAVE_OPENGLES - gl->ctx_driver = gfx_ctx_init_first(GFX_CTX_OPENGL_ES_API); -#else - gl->ctx_driver = gfx_ctx_init_first(GFX_CTX_OPENGL_API); -#endif + gl->ctx_driver = gl_get_context(); if (!gl->ctx_driver) { free(gl); diff --git a/gx/ld/ogc.ld b/gx/ld/ogc.ld index 0086209667..d6d06bc2ce 100644 --- a/gx/ld/ogc.ld +++ b/gx/ld/ogc.ld @@ -257,7 +257,7 @@ SECTIONS } __isIPL = 0; -__stack_addr = (__bss_start + SIZEOF(.bss) + 0x40000 + 7) & (-8); +__stack_addr = (__bss_start + SIZEOF(.bss) + 0x80000 + 7) & (-8); __stack_end = (__bss_start + SIZEOF(.bss)); __intrstack_addr = (__stack_addr + 0x4000); __intrstack_end = (__stack_addr); diff --git a/gx/ld/rvl.ld b/gx/ld/rvl.ld index 7a9867c2f4..e790eec2db 100644 --- a/gx/ld/rvl.ld +++ b/gx/ld/rvl.ld @@ -268,7 +268,7 @@ SECTIONS } __isIPL = 0; -__stack_addr = (__bss_start + SIZEOF(.bss) + 0x40000 + 7) & (-8); +__stack_addr = (__bss_start + SIZEOF(.bss) + 0x80000 + 7) & (-8); __stack_end = (__bss_start + SIZEOF(.bss)); __intrstack_addr = (__stack_addr + 0x4000); __intrstack_end = (__stack_addr); diff --git a/retroarch.cfg b/retroarch.cfg index e7d853d73b..f0189719bf 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -40,6 +40,11 @@ # Video driver to use. "gl", "xvideo", "sdl" # video_driver = "gl" +# Which OpenGL context implementation to use. +# Possible ones for desktop are: glx, x-egl, kms-egl, sdl-gl, wgl. +# By default, tries to use first suitable driver. +# video_gl_context = + # Windowed xscale and yscale # (Real x res: base_size * xscale * aspect_ratio, real y res: base_size * yscale) # video_xscale = 3.0 diff --git a/settings.c b/settings.c index fd08c27ea1..fe66ac5054 100644 --- a/settings.c +++ b/settings.c @@ -648,6 +648,7 @@ bool config_load_file(const char *path) CONFIG_GET_STRING(audio.resampler, "audio_resampler"); CONFIG_GET_STRING(video.driver, "video_driver"); + CONFIG_GET_STRING(video.gl_context, "video_gl_context"); CONFIG_GET_STRING(audio.driver, "audio_driver"); CONFIG_GET_PATH(audio.dsp_plugin, "audio_dsp_plugin"); CONFIG_GET_STRING(input.driver, "input_driver");