Repository navigation
FFI: switch games with load_with_save - #8
Merged
Merged
Conversation
load_with_save used to refuse a second game (the global instance was set once). Calling it again now replaces the running game: - the previous game is dropped, which writes its .gbsave - if sound is on, a fresh output stream is opened and attached to the new game, so hosts don't need to call enable_audio again - if the new cartridge is rejected, the running game keeps going The "already loaded" status code (1) is gone.
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.
Summary
load_with_savecan now be called again to switch games without restarting the host process. Before, it returned1once a game was loaded, because the globalGAMEBOYwas only ever set once..gbsave, as before.enable_audiowas called, the core opens a fresh output stream and attaches it to the new game. Hosts don't need to callenable_audioagain; calling it is harmless and returns the sample rate. A fresh stream also picks up the current default output device.-2pluslast_errorare returned.1("already loaded") no longer exists.gameboy.his updated.Testing
make lint,cargo test --release, the wasm build and the FFI build all pass locally (Rust 1.99.1)libgameboy.aswitched Pokémon Silver → Blarggcpu_instrs→ Silver:silver.gbsave(32,776 bytes) is written on switchenable_audioagain-2/ "Unsupported MBC type", and Silver's intro keeps animatingcpu_instrsshows "Passed all tests"