aboutsummaryrefslogtreecommitdiff
path: root/libretro.c
diff options
context:
space:
mode:
Diffstat (limited to 'libretro.c')
-rw-r--r--libretro.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/libretro.c b/libretro.c
index 5e4dc31..2370f4c 100644
--- a/libretro.c
+++ b/libretro.c
@@ -12,6 +12,10 @@
#include "srtc.h"
#include "sa1.h"
+#ifdef USE_DYNAREC
+#include "arm_dynarec/dynaexec.h"
+#endif
+
#ifdef PSP
#include <pspkernel.h>
#include <pspgu.h>
@@ -456,6 +460,12 @@ void retro_init(void)
#endif
CPU.SaveStateVersion = 0;
+#ifdef USE_DYNAREC
+ /* Init before loading ROM to have a better chance of mmaping close to code */
+ if (DynaInit())
+ Settings.EnableDynarec = false;
+#endif
+
if (environ_cb(RETRO_ENVIRONMENT_GET_INPUT_BITMASKS, NULL))
libretro_supports_bitmasks = true;
}
@@ -535,6 +545,7 @@ static void check_variables(bool first_run)
{
struct retro_variable var;
bool prev_frameskip_type;
+ bool prev_dynarec;
if (first_run)
{
@@ -632,6 +643,27 @@ static void check_variables(bool first_run)
if (strcmp(var.value, "enabled") == 0)
reduce_sprite_flicker = true;
+#ifdef USE_DYNAREC
+ prev_dynarec = Settings.EnableDynarec;
+
+ var.key = "snes9x_2005_dynarec";
+ var.value = NULL;
+
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
+ {
+ if (strcmp(var.value, "enabled") == 0)
+ Settings.EnableDynarec = true;
+ else
+ Settings.EnableDynarec = false;
+ }
+
+ if (Settings.EnableDynarec && Settings.EnableDynarec != prev_dynarec) {
+ if (DynaReset())
+ Settings.EnableDynarec = false;
+ }
+
+#endif /* USE_DYNAREC */
+
/* Reinitialise frameskipping, if required */
if (!first_run &&
(frameskip_type != prev_frameskip_type))
@@ -827,6 +859,13 @@ void retro_reset(void)
{
CPU.Flags = 0;
S9xSoftReset();
+#ifdef USE_DYNAREC
+ if (Settings.EnableDynarec)
+ {
+ if (DynaReset())
+ Settings.EnableDynarec = false;
+ }
+#endif /* USE_DYNAREC */
}
size_t retro_serialize_size(void)