Repository navigation
MgbaLink: re-anchor the controller clock across LOAD and RESET - #508
Merged
Merged
Conversation
A save-state LOAD or a RESET moves mGBA to another frame under the pacer's and the key schedule's anchor: old grants would stall the emulator after a jump ahead or let it run free after a jump back, and queued KEYS would land on the wrong timeline. KeySender::jump() stops the pacer, drops states not sent yet, sends LOAD or RESET, reads the new frame with "GRANT 0", anchors a new clock, schedule and input log there, releases held keys on that frame and starts granting again. A refused command keeps the old clock and pacer. ProController_MgbaLink exposes load_state() and reset_console(). Tests: fake-bridge cases for load ahead, load back, load before any key, reset, a waiting state dropped by a load, and a refused load.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #506 (base
lab/mgba-slice2b; the diff shows only this change).Keeps the mGBA controller's frame clock right when a save-state LOAD or a RESET moves the emulator to another frame, and adds the controller-side commands for them (design:
docs/design/Lab-mGBA-Console.mdonagents).KeySender::jump(JumpCommand)stops the pacer, drops states not sent yet (a waitingpush()returns), sendsLOAD <file>orRESET, reads the new frame withGRANT 0, anchors a new clock, schedule and input log there, releases held keys on that frame, and grants again. A refused command keeps the old clock and pacer.ProController_MgbaLink::load_state()andreset_console()clear the scheduler and call it.Testing: new fake-bridge cases in the key sender suite (load ahead, load back, load before any key, reset, a waiting state dropped by a load, a refused load) check that every KEYS and GRANT after the jump is on the new timeline. Compiled with
-fsyntax-onlylocally; Fork Draft CI builds and runs them. Not yet tried against a live mGBA.