Skip to content

Seek backwards/forwards in replays by checkpoint#18238

Merged
LibretroAdmin merged 12 commits intolibretro:masterfrom
JoeOsborn:bsv-seek-forward-back
Sep 9, 2025
Merged

Seek backwards/forwards in replays by checkpoint#18238
LibretroAdmin merged 12 commits intolibretro:masterfrom
JoeOsborn:bsv-seek-forward-back

Conversation

@JoeOsborn
Copy link
Copy Markdown
Contributor

@JoeOsborn JoeOsborn commented Sep 5, 2025

This adds three keybinds/text commands: make a checkpoint, go to previous checkpoint, and go to next checkpoint. It also adds a text (stdin/socket) command to seek a replay to a specific frame, which will also return (via the command replier) the frame which was actually seeked-to (for now, it will only seek to checkpoint frames, since afaik there is no API for running retroarch forward by some number of frames).

This even works for replays being recorded; backwards seeking works as expected but forwards seeking can also work if the replay was seeked-backwards while paused.

I would like particularly close review around:

  • adding the keybinds, since it touches many files
  • the single-frame unpause (with run_frames_and_pause) used to activate the forward/back scanning logic while paused
  • refactoring the movie "reset to beginning of playback" code

I like to bind "make checkpoint" to f2 (same as save-state) and use n/m to go back/forward through checkpoints.

In the future it would be good if seeking backwards could use the backref field in replay frames to more efficiently go backwards, but it would depend on remembering the file position at which a statestream block was written in the replay file so it could be reloaded if it had been garbage-collected (which feels like a separate PR). For now, scanning backwards requires scanning forwards from the beginning of the replay, which is not ideal but it is what it is.

Comment thread retroarch.c
Comment thread input/bsv/uint32s_index.c
Comment thread intl/msg_hash_us.h
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_META_PREV_REPLAY_CHECKPOINT_KEY,
"Rewinds the replay to the previous automatically or manually saved checkpoint."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are checkpoints created automatically?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an interval in seconds that's a setting in the RA config.

@JoeOsborn
Copy link
Copy Markdown
Contributor Author

I want to change the "find the previous checkpoint" code to not be side-effecting on the movie, so please don't merge until my next patch lands. I also am adding the "seek forward or back to (the closest replay checkpoint before) a given frame number" text command.

@JoeOsborn JoeOsborn marked this pull request as draft September 6, 2025 04:10
@JoeOsborn JoeOsborn marked this pull request as ready for review September 6, 2025 21:04
@JoeOsborn JoeOsborn marked this pull request as draft September 7, 2025 03:21
@JoeOsborn JoeOsborn marked this pull request as ready for review September 7, 2025 03:44
@JoeOsborn JoeOsborn marked this pull request as draft September 7, 2025 19:04
@JoeOsborn JoeOsborn marked this pull request as ready for review September 8, 2025 15:41
@LibretroAdmin LibretroAdmin merged commit fa42321 into libretro:master Sep 9, 2025
28 of 31 checks passed
@bslenul bslenul mentioned this pull request Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants