|
SDL_Libretro
SDL3-power libretro frontend.
|
SDL_libretro - save states, core memory (SRAM/RTC/...), and rewind. More...
Go to the source code of this file.
Macros | |
| #define | SDL_LIBRETRO_ENABLE_REWIND_DELTA |
| Compile-time switch that enables the delta compression for the rewind buffer. | |
| #define | SDL_LIBRETRO_REWIND_DEFAULT_MAX_BYTES ((size_t)256 * 1024 * 1024) |
| Default ceiling on the encoded rewind history (delta data only), in bytes. | |
Functions | |
| void * | SDL_Libretro_GetMapAddress (const SDL_Libretro *lr, size_t address, size_t *regionRemaining) |
| Translate an emulated (guest) address to a live host pointer via the memory map. | |
| void * | SDL_Libretro_GetMemoryData (const SDL_Libretro *lr, unsigned memoryType, size_t *size) |
| Get a pointer to a core memory region and its size. | |
| unsigned | SDL_Libretro_GetMemoryMapCount (const SDL_Libretro *lr) |
| Get the number of memory-map descriptors the core has published. | |
| bool | SDL_Libretro_GetMemoryMapDescriptor (const SDL_Libretro *lr, unsigned index, Uint64 *flags, void **ptr, size_t *offset, size_t *start, size_t *select, size_t *disconnect, size_t *len, const char **addrspace) |
| Retrieve one memory-map descriptor by index. | |
| bool | SDL_Libretro_GetRewindEnabled (const SDL_Libretro *lr) |
| Check whether the rewind system is enabled (independent of current direction). | |
| size_t | SDL_Libretro_GetRewindMemoryLimit (const SDL_Libretro *lr) |
| Get the current rewind memory budget in bytes (0 if unbounded). | |
| size_t | SDL_Libretro_GetRewindMemoryUsage (const SDL_Libretro *lr) |
| Get the approximate memory currently held by the rewind buffer, in bytes. | |
| double | SDL_Libretro_GetRewindRemaining (const SDL_Libretro *lr) |
| Calculates the amount of rewind time remaining in the buffer. | |
| size_t | SDL_Libretro_GetStateSize (const SDL_Libretro *lr) |
| Retrieves the size of serialized states. | |
| bool | SDL_Libretro_LoadMemory (SDL_Libretro *lr, unsigned memoryType, const char *file) |
| Load a core memory region from a file. | |
| bool | SDL_Libretro_LoadMemory_IO (SDL_Libretro *lr, unsigned memoryType, SDL_IOStream *src, bool closeio) |
| Load a core memory region from a stream. | |
| bool | SDL_Libretro_LoadSRAM (SDL_Libretro *lr, const char *file) |
| Loads the current SRAM to the given file. | |
| bool | SDL_Libretro_LoadState (SDL_Libretro *lr, const char *file) |
| Loads the libretro state from the given file. | |
| bool | SDL_Libretro_SaveMemory (SDL_Libretro *lr, unsigned memoryType, const char *file) |
| Write a core memory region to a file. | |
| bool | SDL_Libretro_SaveMemory_IO (SDL_Libretro *lr, unsigned memoryType, SDL_IOStream *dst, bool closeio) |
| Write a core memory region to a stream. | |
| bool | SDL_Libretro_SaveSRAM (SDL_Libretro *lr, const char *file) |
| Saves the current SRAM to the given file. | |
| bool | SDL_Libretro_SaveState (SDL_Libretro *lr, const char *file) |
| Saves the current libretro state to a file. | |
| bool | SDL_Libretro_SaveState_IO (SDL_Libretro *lr, SDL_IOStream *dst, bool closeio) |
| Save the current libretro state to the given SDL_IOStream. | |
| bool | SDL_Libretro_SetMemoryData (SDL_Libretro *lr, unsigned memoryType, const void *data, size_t size) |
| Overwrite a core memory region with caller-provided bytes. | |
| bool | SDL_Libretro_SetRewindEnabled (SDL_Libretro *lr, bool enabled, unsigned bufferFrames, unsigned captureInterval) |
| Enable or disable the rewind system. | |
| bool | SDL_Libretro_SetRewindMemoryDuration (SDL_Libretro *lr, double seconds) |
| Set the rewind memory budget by target duration instead of raw bytes. | |
| void | SDL_Libretro_SetRewindMemoryLimit (SDL_Libretro *lr, size_t maxBytes) |
| Set the maximum number of bytes of encoded delta history to retain. | |
SDL_libretro - save states, core memory (SRAM/RTC/...), and rewind.
Definition in file SDL_libretro_serialize.h.
| #define SDL_LIBRETRO_ENABLE_REWIND_DELTA |
Compile-time switch that enables the delta compression for the rewind buffer.
Undefined by default, rewind stores each snapshot as a full serialized state, so capture is a single fixed-size copy and a step back is a single copy back. Define this before including the implementation to instead store an RLE-compressed XOR delta between consecutive states: a single full reference state is kept, each entry holds only the bytes that changed, and a step back XORs the delta into the reference to reconstruct the previous state.
This trades CPU for memory. Deltas dramatically shrink the per-frame footprint when little changes frame to frame (so the frame-count and byte-budget limits buy a far longer rewind window), at the cost of an encode pass on every capture and a decode pass on every step. For multi-megabyte states (e.g. PSX) that extra scan is the dominant capture cost, so leave it off when memory is ample and capture latency matters.
Definition at line 21 of file SDL_libretro_serialize.h.
| #define SDL_LIBRETRO_REWIND_DEFAULT_MAX_BYTES ((size_t)256 * 1024 * 1024) |
Default ceiling on the encoded rewind history (delta data only), in bytes.
Caps worst-case memory for cores with a large or incompressible serialize size, where the frame-count limit alone could otherwise grow the buffer to gigabytes. Override per build, or at runtime via SDL_Libretro_SetRewindMemoryLimit().
Definition at line 31 of file SDL_libretro_serialize.h.