Permalink
Browse files

Clean up load_no_rom grabbing interface.

  • Loading branch information...
1 parent 9999017 commit f3cd25ebb7137e6e75d93d728b606ddb8f51e4ad @Themaister committed May 2, 2013
Showing with 18 additions and 4 deletions.
  1. +9 −4 dynamic.c
  2. +9 −0 dynamic.h
View
13 dynamic.c
@@ -119,6 +119,14 @@ static bool environ_cb_get_system_info(unsigned cmd, void *data)
return true;
}
+void libretro_get_environment_info(void (*func)(retro_environment_t), bool *load_no_rom)
+{
+ load_no_rom_hook = load_no_rom;
+
+ // load_no_rom gets set in this callback.
+ func(environ_cb_get_system_info);
+}
+
static dylib_t libretro_get_system_info_lib(const char *path, struct retro_system_info *info, bool *load_no_rom)
{
dylib_t lib = dylib_load(path);
@@ -145,10 +153,7 @@ static dylib_t libretro_get_system_info_lib(const char *path, struct retro_syste
if (!set_environ)
return lib;
- load_no_rom_hook = load_no_rom;
-
- // load_no_rom gets set in this callback.
- set_environ(environ_cb_get_system_info);
+ libretro_get_environment_info(set_environ, load_no_rom);
}
return lib;
View
9 dynamic.h
@@ -45,6 +45,15 @@ void dylib_close(dylib_t lib);
function_t dylib_proc(dylib_t lib, const char *proc);
#endif
+// Sets environment callback in order to get statically known information from it.
+// Fetched via environment callbacks instead of retro_get_system_info(), as this info
+// is part of extensions.
+// Should only be called once right after core load to avoid overwriting
+// the "real" environ callback.
+//
+// For statically linked cores, pass retro_set_environment as argument.
+void libretro_get_environment_info(void (*)(retro_environment_t), bool *load_no_rom);
+
#ifdef HAVE_DYNAMIC
// Gets system info from an arbitrary lib.
// The struct returned must be freed as strings are allocated dynamically.

0 comments on commit f3cd25e

Please sign in to comment.