mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 02:11:36 -04:00
61 lines
2.2 KiB
C
61 lines
2.2 KiB
C
#ifndef PSX_NETPLAY_SNAP_RING_H
|
|
#define PSX_NETPLAY_SNAP_RING_H
|
|
|
|
/*
|
|
* Tick-addressable in-memory .pst ring for rollback netplay.
|
|
*
|
|
* Depth defaults to 64 (enough for early soaks; raise toward
|
|
* RNET_RB_SEAL_MAX_SPAN=128 when episodes deepen). Each slot owns a
|
|
* boot_state_save_buffer_raw blob (uncompressed — FPS). save/load call the
|
|
* full-machine serializer; store/peek are for tests / pre-serialized blobs.
|
|
*/
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include "cpu_state.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define NETPLAY_SNAP_RING_DEFAULT_DEPTH 64u
|
|
|
|
typedef struct NetplaySnapRing NetplaySnapRing;
|
|
|
|
NetplaySnapRing* netplay_snap_ring_create(uint32_t depth);
|
|
void netplay_snap_ring_destroy(NetplaySnapRing* r);
|
|
void netplay_snap_ring_clear(NetplaySnapRing* r);
|
|
|
|
uint32_t netplay_snap_ring_depth(const NetplaySnapRing* r);
|
|
uint32_t netplay_snap_ring_count(const NetplaySnapRing* r);
|
|
int netplay_snap_ring_has(const NetplaySnapRing* r, uint32_t tick);
|
|
|
|
/* Serialize live machine into the ring at tick (overwrites same tick). */
|
|
int netplay_snap_ring_save(NetplaySnapRing* r, uint32_t tick,
|
|
const CPUState* cpu, uint32_t bios_checksum,
|
|
uint32_t entry_pc);
|
|
|
|
/* Restore machine from the snap at tick. Returns 0 if missing/reject. */
|
|
int netplay_snap_ring_load(NetplaySnapRing* r, uint32_t tick, CPUState* cpu,
|
|
uint32_t bios_checksum, uint32_t entry_pc);
|
|
|
|
/* Take ownership of data on success (caller must not free). For tests /
|
|
* pre-serialized blobs. Overwrites an existing entry for the same tick. */
|
|
int netplay_snap_ring_store(NetplaySnapRing* r, uint32_t tick,
|
|
uint8_t* data, size_t size);
|
|
|
|
/* Non-owning peek; NULL if missing. */
|
|
const uint8_t* netplay_snap_ring_peek(const NetplaySnapRing* r, uint32_t tick,
|
|
size_t* size_out);
|
|
|
|
/* Oldest/newest occupied tick, or 0 if empty (ambiguous with tick 0 — use
|
|
* count() first). */
|
|
uint32_t netplay_snap_ring_oldest_tick(const NetplaySnapRing* r);
|
|
uint32_t netplay_snap_ring_newest_tick(const NetplaySnapRing* r);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* PSX_NETPLAY_SNAP_RING_H */
|