summaryrefslogtreecommitdiff
path: root/libretro.c
diff options
context:
space:
mode:
authorAutechre2021-03-18 03:15:03 +0100
committerGitHub2021-03-18 03:15:03 +0100
commit5ef784ab8af08b9629b573b3cfd25f21384771af (patch)
tree250fbceb4e4c0cd061dd524f08459b775fb6e2cf /libretro.c
parent11632ad5e3ac626d9687ae6f25f545cf852f1b55 (diff)
parenteab44b9e0b9dcb5cf7fa7b6851fa5454041da930 (diff)
downloadpicogpsp-5ef784ab8af08b9629b573b3cfd25f21384771af.tar.gz
picogpsp-5ef784ab8af08b9629b573b3cfd25f21384771af.tar.bz2
picogpsp-5ef784ab8af08b9629b573b3cfd25f21384771af.zip
Merge pull request #112 from davidgfnet/master
Enable runtime dynarec enable/disable
Diffstat (limited to 'libretro.c')
-rw-r--r--libretro.c63
1 files changed, 21 insertions, 42 deletions
diff --git a/libretro.c b/libretro.c
index 178b466..bc61977 100644
--- a/libretro.c
+++ b/libretro.c
@@ -408,7 +408,13 @@ void retro_get_system_av_info(struct retro_system_av_info* info)
void retro_init(void)
{
-#if defined(_3DS) && defined(HAVE_DYNAREC)
+#if defined(HAVE_DYNAREC)
+ #if defined(HAVE_MMAP)
+ rom_translation_cache = mmap(NULL, ROM_TRANSLATION_CACHE_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
+ ram_translation_cache = mmap(NULL, RAM_TRANSLATION_CACHE_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
+ #elif defined(_3DS)
if (__ctr_svchax && !translation_caches_inited)
{
uint32_t currentHandle;
@@ -430,10 +436,8 @@ void retro_init(void)
ctr_flush_invalidate_cache();
translation_caches_inited = 1;
}
-#endif
-
-#if defined(VITA) && defined(HAVE_DYNAREC)
- if(!translation_caches_inited){
+ #elif defined(VITA)
+ if(!translation_caches_inited){
void* currentHandle;
sceBlock = getVMBlock();
@@ -456,8 +460,8 @@ void retro_init(void)
ram_translation_ptr = ram_translation_cache;
sceKernelOpenVMDomain();
translation_caches_inited = 1;
-}
-
+ }
+ #endif
#endif
if (!gamepak_rom)
@@ -641,16 +645,19 @@ static void check_variables(int started_from_load)
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
- if (started_from_load)
- {
- if (strcmp(var.value, "disabled") == 0)
- dynarec_enable = 0;
- else if (strcmp(var.value, "enabled") == 0)
- dynarec_enable = 1;
- }
+ int prevvalue = dynarec_enable;
+ if (strcmp(var.value, "disabled") == 0)
+ dynarec_enable = 0;
+ else if (strcmp(var.value, "enabled") == 0)
+ dynarec_enable = 1;
+
+ if (dynarec_enable != prevvalue)
+ wipe_caches();
}
else
dynarec_enable = 1;
+#else
+ dynarec_enable = 0;
#endif
var.key = "gpsp_frameskip";
@@ -779,34 +786,6 @@ bool retro_load_game(const struct retro_game_info* info)
check_variables(1);
set_input_descriptors();
-#if defined(HAVE_DYNAREC)
- if (dynarec_enable)
- {
-#if defined(HAVE_MMAP)
-
- rom_translation_cache = mmap(NULL, ROM_TRANSLATION_CACHE_SIZE,
- PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
- ram_translation_cache = mmap(NULL, RAM_TRANSLATION_CACHE_SIZE,
- PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
-
- rom_translation_ptr = rom_translation_cache;
- ram_translation_ptr = ram_translation_cache;
-#elif defined(_3DS)
- dynarec_enable = __ctr_svchax;
- rom_translation_ptr = rom_translation_cache;
- ram_translation_ptr = ram_translation_cache;
-#elif defined(PSP) || defined(VITA)
- dynarec_enable = 1;
- rom_translation_ptr = rom_translation_cache;
- ram_translation_ptr = ram_translation_cache;
-#endif
- }
- else
- dynarec_enable = 0;
-#else
- dynarec_enable = 0;
-#endif
-
char filename_bios[MAX_PATH];
const char* dir = NULL;