mirror of https://github.com/LIJI32/SameBoy.git
Expose an API to reset the rewind buffer, explicitly reset on ROM changes
This commit is contained in:
parent
4c8f364ad7
commit
65a646f050
|
@ -14,7 +14,7 @@
|
|||
|
||||
|
||||
#ifdef GB_DISABLE_REWIND
|
||||
#define GB_rewind_free(...)
|
||||
#define GB_rewind_reset(...)
|
||||
#define GB_rewind_push(...)
|
||||
#endif
|
||||
|
||||
|
@ -225,7 +225,7 @@ void GB_free(GB_gameboy_t *gb)
|
|||
#ifndef GB_DISABLE_DEBUGGER
|
||||
GB_debugger_clear_symbols(gb);
|
||||
#endif
|
||||
GB_rewind_free(gb);
|
||||
GB_rewind_reset(gb);
|
||||
#ifndef GB_DISABLE_CHEATS
|
||||
while (gb->cheats) {
|
||||
GB_remove_cheat(gb, gb->cheats[0]);
|
||||
|
@ -1775,7 +1775,7 @@ void GB_switch_model_and_reset(GB_gameboy_t *gb, GB_model_t model)
|
|||
free(gb->undo_state);
|
||||
gb->undo_state = NULL;
|
||||
}
|
||||
GB_rewind_free(gb);
|
||||
GB_rewind_reset(gb);
|
||||
GB_reset(gb);
|
||||
load_default_border(gb);
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ void GB_rewind_push(GB_gameboy_t *gb)
|
|||
{
|
||||
const size_t save_size = GB_get_save_state_size_no_bess(gb);
|
||||
if (gb->rewind_state_size != save_size) {
|
||||
GB_rewind_free(gb);
|
||||
GB_rewind_reset(gb);
|
||||
gb->rewind_state_size = save_size;
|
||||
}
|
||||
if (!gb->rewind_sequences) {
|
||||
|
@ -185,7 +185,7 @@ bool GB_rewind_pop(GB_gameboy_t *gb)
|
|||
return true;
|
||||
}
|
||||
|
||||
void GB_rewind_free(GB_gameboy_t *gb)
|
||||
void GB_rewind_reset(GB_gameboy_t *gb)
|
||||
{
|
||||
if (!gb->rewind_sequences) return;
|
||||
for (unsigned i = 0; i < gb->rewind_buffer_length; i++) {
|
||||
|
@ -204,7 +204,7 @@ void GB_rewind_free(GB_gameboy_t *gb)
|
|||
|
||||
void GB_set_rewind_length(GB_gameboy_t *gb, double seconds)
|
||||
{
|
||||
GB_rewind_free(gb);
|
||||
GB_rewind_reset(gb);
|
||||
if (seconds == 0) {
|
||||
gb->rewind_buffer_length = 0;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#ifdef GB_INTERNAL
|
||||
internal void GB_rewind_push(GB_gameboy_t *gb);
|
||||
internal void GB_rewind_free(GB_gameboy_t *gb);
|
||||
#endif
|
||||
bool GB_rewind_pop(GB_gameboy_t *gb);
|
||||
void GB_set_rewind_length(GB_gameboy_t *gb, double seconds);
|
||||
void GB_rewind_reset(GB_gameboy_t *gb);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -45,6 +45,7 @@ void set_filename(const char *new_filename, typeof(free) *new_free_function)
|
|||
}
|
||||
filename = (char *) new_filename;
|
||||
free_function = new_free_function;
|
||||
GB_rewind_reset(&gb);
|
||||
}
|
||||
|
||||
static char *completer(const char *substring, uintptr_t *context)
|
||||
|
|
|
@ -276,6 +276,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
|
|||
if (romManager.romFile) {
|
||||
// Todo: display errors and warnings
|
||||
_romLoaded = GB_load_rom(&_gb, romManager.romFile.fileSystemRepresentation) == 0;
|
||||
GB_rewind_reset(&_gb);
|
||||
if (_romLoaded) {
|
||||
GB_reset(&_gb);
|
||||
GB_load_battery(&_gb, [GBROMManager sharedManager].batterySaveFile.fileSystemRepresentation);
|
||||
|
|
Loading…
Reference in New Issue