From ce34e879e348cecd4e21329be5974cc4162fa6c4 Mon Sep 17 00:00:00 2001 From: neonloop Date: Wed, 9 Feb 2022 07:15:14 +0000 Subject: Adds experimental ARM dynarec Supports ARMv5 and higher, enable with USE_DYNAREC Makefile variable --- libretro.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'libretro.c') 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 #include @@ -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) -- cgit v1.2.3