Prevent the rewind buffer from being reset unexpectedly on iOS

This commit is contained in:
Lior Halphon 2024-11-23 13:54:50 +02:00
parent a0c5b6f97a
commit 117da602ca
1 changed files with 22 additions and 1 deletions

View File

@ -78,6 +78,9 @@
UIButton *_printerButton;
UIActivityIndicatorView *_printerSpinner;
NSMutableData *_currentPrinterImageData;
NSString *_lastSavedROM;
NSDate *_saveDate;
}
static void loadBootROM(GB_gameboy_t *gb, GB_boot_rom_t type)
@ -697,7 +700,17 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
}
}
}
GB_rewind_reset(&_gb);
NSDate *date = nil;
[[NSURL fileURLWithPath:[GBROMManager sharedManager].autosaveStateFile] getResourceValue:&date
forKey:NSURLContentModificationDateKey
error:nil];
// Reset the rewind buffer only if we switched ROMs or had the save state change externally
if (![_lastSavedROM isEqual:[GBROMManager sharedManager].currentROM] ||
![_saveDate isEqual:date]) {
GB_rewind_reset(&_gb);
}
}
}
else {
@ -1155,6 +1168,14 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
if (!_swappingROM) {
GB_save_battery(&_gb, [GBROMManager sharedManager].batterySaveFile.fileSystemRepresentation);
[self saveStateToFile:[GBROMManager sharedManager].autosaveStateFile];
NSDate *date;
[[NSURL fileURLWithPath:[GBROMManager sharedManager].autosaveStateFile] getResourceValue:&date
forKey:NSURLContentModificationDateKey
error:nil];
_saveDate = date;
_lastSavedROM = [GBROMManager sharedManager].currentROM;
}
[[GBHapticManager sharedManager] setRumbleStrength:0];
if (@available(iOS 14.0, *)) {