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
|
#ifdef GB_DISABLE_REWIND
|
||||||
#define GB_rewind_free(...)
|
#define GB_rewind_reset(...)
|
||||||
#define GB_rewind_push(...)
|
#define GB_rewind_push(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ void GB_free(GB_gameboy_t *gb)
|
||||||
#ifndef GB_DISABLE_DEBUGGER
|
#ifndef GB_DISABLE_DEBUGGER
|
||||||
GB_debugger_clear_symbols(gb);
|
GB_debugger_clear_symbols(gb);
|
||||||
#endif
|
#endif
|
||||||
GB_rewind_free(gb);
|
GB_rewind_reset(gb);
|
||||||
#ifndef GB_DISABLE_CHEATS
|
#ifndef GB_DISABLE_CHEATS
|
||||||
while (gb->cheats) {
|
while (gb->cheats) {
|
||||||
GB_remove_cheat(gb, gb->cheats[0]);
|
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);
|
free(gb->undo_state);
|
||||||
gb->undo_state = NULL;
|
gb->undo_state = NULL;
|
||||||
}
|
}
|
||||||
GB_rewind_free(gb);
|
GB_rewind_reset(gb);
|
||||||
GB_reset(gb);
|
GB_reset(gb);
|
||||||
load_default_border(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);
|
const size_t save_size = GB_get_save_state_size_no_bess(gb);
|
||||||
if (gb->rewind_state_size != save_size) {
|
if (gb->rewind_state_size != save_size) {
|
||||||
GB_rewind_free(gb);
|
GB_rewind_reset(gb);
|
||||||
gb->rewind_state_size = save_size;
|
gb->rewind_state_size = save_size;
|
||||||
}
|
}
|
||||||
if (!gb->rewind_sequences) {
|
if (!gb->rewind_sequences) {
|
||||||
|
@ -185,7 +185,7 @@ bool GB_rewind_pop(GB_gameboy_t *gb)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GB_rewind_free(GB_gameboy_t *gb)
|
void GB_rewind_reset(GB_gameboy_t *gb)
|
||||||
{
|
{
|
||||||
if (!gb->rewind_sequences) return;
|
if (!gb->rewind_sequences) return;
|
||||||
for (unsigned i = 0; i < gb->rewind_buffer_length; i++) {
|
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)
|
void GB_set_rewind_length(GB_gameboy_t *gb, double seconds)
|
||||||
{
|
{
|
||||||
GB_rewind_free(gb);
|
GB_rewind_reset(gb);
|
||||||
if (seconds == 0) {
|
if (seconds == 0) {
|
||||||
gb->rewind_buffer_length = 0;
|
gb->rewind_buffer_length = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
#ifdef GB_INTERNAL
|
#ifdef GB_INTERNAL
|
||||||
internal void GB_rewind_push(GB_gameboy_t *gb);
|
internal void GB_rewind_push(GB_gameboy_t *gb);
|
||||||
internal void GB_rewind_free(GB_gameboy_t *gb);
|
|
||||||
#endif
|
#endif
|
||||||
bool GB_rewind_pop(GB_gameboy_t *gb);
|
bool GB_rewind_pop(GB_gameboy_t *gb);
|
||||||
void GB_set_rewind_length(GB_gameboy_t *gb, double seconds);
|
void GB_set_rewind_length(GB_gameboy_t *gb, double seconds);
|
||||||
|
void GB_rewind_reset(GB_gameboy_t *gb);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,6 +45,7 @@ void set_filename(const char *new_filename, typeof(free) *new_free_function)
|
||||||
}
|
}
|
||||||
filename = (char *) new_filename;
|
filename = (char *) new_filename;
|
||||||
free_function = new_free_function;
|
free_function = new_free_function;
|
||||||
|
GB_rewind_reset(&gb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *completer(const char *substring, uintptr_t *context)
|
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) {
|
if (romManager.romFile) {
|
||||||
// Todo: display errors and warnings
|
// Todo: display errors and warnings
|
||||||
_romLoaded = GB_load_rom(&_gb, romManager.romFile.fileSystemRepresentation) == 0;
|
_romLoaded = GB_load_rom(&_gb, romManager.romFile.fileSystemRepresentation) == 0;
|
||||||
|
GB_rewind_reset(&_gb);
|
||||||
if (_romLoaded) {
|
if (_romLoaded) {
|
||||||
GB_reset(&_gb);
|
GB_reset(&_gb);
|
||||||
GB_load_battery(&_gb, [GBROMManager sharedManager].batterySaveFile.fileSystemRepresentation);
|
GB_load_battery(&_gb, [GBROMManager sharedManager].batterySaveFile.fileSystemRepresentation);
|
||||||
|
|
Loading…
Reference in New Issue