SDL_Libretro 0.1.0
SDL3-power libretro frontend.
Loading...
Searching...
No Matches
Macros | Functions
SDL_libretro_core.h File Reference

SDL_libretro - core lifecycle implementation. More...

Go to the source code of this file.

Macros

#define LOAD_SYM(sym)
 Load a required core symbol in lr->core.
 
#define SDL_LIBRETRO_GET_TICKS_NS()   SDL_GetTicksNS()
 The clock that paces SDL_Libretro_Update() and the frame-time callback, in nanoseconds.
 

Functions

SDL_Libretro * SDL_Libretro_Create (void)
 Creates a new libretro context.
 
void SDL_Libretro_Destroy (SDL_Libretro *lr)
 Destroys the given libretro context.
 
bool SDL_Libretro_GetBlockExtract (const SDL_Libretro *lr)
 Retrieves whether the core expects archives to be loaded directly.
 
const char * SDL_Libretro_GetContentExtension (const SDL_Libretro *lr)
 Get the extension of the loaded content, as it appears in the path.
 
const char * SDL_Libretro_GetCoreAssetsDirectory (SDL_Libretro *lr)
 Get the core assets directory.
 
const char * SDL_Libretro_GetCoreDirectory (SDL_Libretro *lr)
 Get the core directory.
 
const char * SDL_Libretro_GetCoreName (const SDL_Libretro *lr)
 Retrieve the name of the libretro core that's actively loaded.
 
const char * SDL_Libretro_GetCoreVersion (const SDL_Libretro *lr)
 Retrieves the version of the libretro core that's actively loaded.
 
size_t SDL_Libretro_GetFileName (char *dst, size_t dstSize, const char *path, bool withExtension)
 Copy the file name portion of a path into a caller-provided buffer.
 
const char * SDL_Libretro_GetGameName (const SDL_Libretro *lr)
 Retrieve the human-readable name of the loaded game.
 
SDL_LogPriority SDL_Libretro_GetLogLevel (const SDL_Libretro *lr)
 Retrieve the threshold for logs that will be posted.
 
unsigned SDL_Libretro_GetPerformanceLevel (const SDL_Libretro *lr)
 Get the performance level the core requested via SET_PERFORMANCE_LEVEL.
 
const char * SDL_Libretro_GetSaveDirectory (SDL_Libretro *lr)
 Get the save directory.
 
size_t SDL_Libretro_GetSavePath (const SDL_Libretro *lr, const char *extension, char *dst, size_t dstSize)
 Build a path in the save directory for the currently loaded content.
 
enum retro_savestate_context SDL_Libretro_GetSavestateContext (const SDL_Libretro *lr)
 Get the savestate context reported to cores through RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT.
 
float SDL_Libretro_GetSpeed (const SDL_Libretro *lr)
 Get how fast the game runs, as a multiple of its normal speed.
 
const char * SDL_Libretro_GetSystemDirectory (SDL_Libretro *lr)
 Get the system directory.
 
const char * SDL_Libretro_GetUsername (SDL_Libretro *lr)
 Get the username reported to cores.
 
const char * SDL_Libretro_GetValidExtensions (const SDL_Libretro *lr)
 Gets the default set of valid extensions associated with the core, seperated by a "|".
 
int SDL_Libretro_GetVersion (void)
 Get the version of SDL_libretro the implementation was compiled with.
 
float SDL_Libretro_GetVolume (const SDL_Libretro *lr)
 Get the audio volume.
 
bool SDL_Libretro_IsCoreReady (const SDL_Libretro *lr)
 Indicates whether a core is loaded.
 
bool SDL_Libretro_IsFastforwardOverrideActive (const SDL_Libretro *lr)
 Indicates whether the core is forcing fast-forward through RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE.
 
bool SDL_Libretro_IsGameReady (const SDL_Libretro *lr)
 Indicates whether a game is loaded and running.
 
bool SDL_Libretro_IsGameRequired (const SDL_Libretro *lr)
 Indicates whether the loaded core needs content to run.
 
bool SDL_Libretro_LoadCore (SDL_Libretro *lr, const char *core)
 Loads a libretro core.
 
bool SDL_Libretro_LoadGame (SDL_Libretro *lr, const char *gamePath)
 Loads a game at the given path.
 
bool SDL_Libretro_LoadGame_IO (SDL_Libretro *lr, SDL_IOStream *src, const char *path, bool closeio)
 Loads a game from an SDL_IOStream.
 
bool SDL_Libretro_LoadGameSpecial (SDL_Libretro *lr, const char *subsystem, const char **paths, unsigned numPaths)
 Loads multi-ROM subsystem content (e.g.
 
bool SDL_Libretro_LoadGameSpecialById (SDL_Libretro *lr, unsigned subsystemId, const char **paths, unsigned numPaths)
 Load multi-ROM subsystem content by its numeric subsystem id.
 
bool SDL_Libretro_Reset (SDL_Libretro *lr)
 Resets the loaded game, like pressing the console's reset button.
 
bool SDL_Libretro_SetCoreAssetsDirectory (SDL_Libretro *lr, const char *path)
 Sets where cores look for their assets, reported through RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY.
 
bool SDL_Libretro_SetCoreDirectory (SDL_Libretro *lr, const char *path)
 Sets the associated libretro core directory, where the default set of cores will be loaded from.
 
void SDL_Libretro_SetLogLevel (SDL_Libretro *lr, SDL_LogPriority level)
 Sets the threshold for logs to be posted.
 
bool SDL_Libretro_SetSaveDirectory (SDL_Libretro *lr, const char *path)
 Sets where content will be saved.
 
void SDL_Libretro_SetSavestateContext (SDL_Libretro *lr, enum retro_savestate_context context)
 Sets the savestate context reported to cores through RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT.
 
void SDL_Libretro_SetSpeed (SDL_Libretro *lr, float speed)
 Sets how fast the game runs, as a multiple of its normal speed.
 
bool SDL_Libretro_SetSystemDirectory (SDL_Libretro *lr, const char *path)
 Sets where cores look for system files (BIOS, firmware, etc).
 
bool SDL_Libretro_SetUsername (SDL_Libretro *lr, const char *username)
 Sets the username reported to cores through RETRO_ENVIRONMENT_GET_USERNAME.
 
void SDL_Libretro_SetVolume (SDL_Libretro *lr, float volume)
 Set the audio volume when playing sounds.
 
bool SDL_Libretro_ShouldQuit (const SDL_Libretro *lr)
 Indicates whether or not the core has requested to shutdown.
 
void SDL_Libretro_UnloadCore (SDL_Libretro *lr)
 Unloads the actively loaded core.
 
void SDL_Libretro_UnloadGame (SDL_Libretro *lr)
 Unloads the actively loaded game.
 
void SDL_Libretro_Update (SDL_Libretro *lr)
 Runs the loaded game; call it once per frame of the application's loop.
 

Detailed Description

SDL_libretro - core lifecycle implementation.

Definition in file SDL_libretro_core.h.

Macro Definition Documentation

◆ LOAD_SYM

#define LOAD_SYM (   sym)
Value:
do { \
SDL_FunctionPointer fp = SDL_LoadFunction(lr->core.symbols.handle, #sym); \
SDL_memcpy(&lr->core.symbols.sym, &fp, sizeof(fp)); \
if (!fp) { \
SDL_SetError("[SDL_Libretro] Failed to load symbol '%s'", #sym); \
SDL_UnloadObject(lr->core.symbols.handle); \
SDL_memset(&lr->core, 0, sizeof(lr->core)); \
SDL_Libretro_ResetPortDevices(lr); \
return false; \
} \
} while (0)

Load a required core symbol in lr->core.

On failure, unload the shared object and reset lr->core so no handle leaks and no half-initialized state is left behind.

Definition at line 36 of file SDL_libretro_core.h.

◆ SDL_LIBRETRO_GET_TICKS_NS

#define SDL_LIBRETRO_GET_TICKS_NS ( )    SDL_GetTicksNS()

The clock that paces SDL_Libretro_Update() and the frame-time callback, in nanoseconds.

Define before including the implementation to substitute a custom clock, e.g. a fake one in tests.

Definition at line 16 of file SDL_libretro_core.h.