Skip to content

Commit

Permalink
Clean up load_no_rom grabbing interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
Themaister committed May 2, 2013
1 parent 9999017 commit f3cd25e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
13 changes: 9 additions & 4 deletions dynamic.c
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions dynamic.h
Expand Up @@ -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.
Expand Down

0 comments on commit f3cd25e

Please sign in to comment.