summaryrefslogtreecommitdiff
path: root/libretro.c
diff options
context:
space:
mode:
authoraliaspider2015-04-08 10:20:32 +0100
committeraliaspider2015-04-08 10:20:32 +0100
commit5b6683bb939d5930e5cd69a5b49aa03523ce3ea3 (patch)
tree3a4ff0fb85db7e5fa5c94ceb19882f92677a7ce3 /libretro.c
parentd4caae665f187e242f3b1d3867ecb71fed27dc04 (diff)
downloadpicogpsp-5b6683bb939d5930e5cd69a5b49aa03523ce3ea3.tar.gz
picogpsp-5b6683bb939d5930e5cd69a5b49aa03523ce3ea3.tar.bz2
picogpsp-5b6683bb939d5930e5cd69a5b49aa03523ce3ea3.zip
(3DS) enable dynarec support, works only with ninjahax.
Diffstat (limited to 'libretro.c')
-rw-r--r--libretro.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libretro.c b/libretro.c
index c7f2cd7..c2820da 100644
--- a/libretro.c
+++ b/libretro.c
@@ -8,6 +8,14 @@
#include "libretro.h"
#include "memmap.h"
+#if defined(_3DS) && defined(HAVE_DYNAREC)
+int32_t hbInit(void);
+void hbExit(void);
+int32_t HB_FlushInvalidateCache(void);
+int32_t HB_ReprotectMemory(void* addr, uint32_t pages, uint32_t mode, uint32_t* reprotectedPages);
+int hb_service_available;
+#endif
+
#ifndef MAX_PATH
#define MAX_PATH (512)
#endif
@@ -104,6 +112,19 @@ void retro_init(void)
{
init_gamepak_buffer();
init_sound(1);
+#if defined(_3DS) && defined(HAVE_DYNAREC)
+ hb_service_available = !hbInit();
+ if (hb_service_available)
+ {
+ HB_ReprotectMemory(rom_translation_cache,
+ ROM_TRANSLATION_CACHE_SIZE / 0x1000, 0b111, NULL);
+ HB_ReprotectMemory(ram_translation_cache,
+ RAM_TRANSLATION_CACHE_SIZE / 0x1000, 0b111, NULL);
+ HB_ReprotectMemory(bios_translation_cache,
+ BIOS_TRANSLATION_CACHE_SIZE / 0x1000, 0b111, NULL);
+ HB_FlushInvalidateCache();
+ }
+#endif
}
@@ -117,6 +138,9 @@ void retro_deinit(void)
munmap(ram_translation_cache, RAM_TRANSLATION_CACHE_SIZE);
munmap(bios_translation_cache, BIOS_TRANSLATION_CACHE_SIZE);
#endif
+#if defined(_3DS) && defined(HAVE_DYNAREC)
+ hbExit();
+#endif
}
static retro_time_t retro_perf_dummy_get_time_usec() { return 0; }
@@ -275,6 +299,9 @@ bool retro_load_game(const struct retro_game_info* info)
rom_translation_ptr = rom_translation_cache;
ram_translation_ptr = ram_translation_cache;
bios_translation_ptr = bios_translation_cache;
+#elif defined(_3DS)
+ if(!hb_service_available)
+ dynarec_enable = 0;
#endif
}
else