Allow loading .RAM files

This commit is contained in:
Lior Halphon 2020-04-25 23:09:08 +03:00
parent ca567bee79
commit 9e99ce434e
2 changed files with 7 additions and 0 deletions

View File

@ -650,6 +650,8 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample)
GB_debugger_clear_symbols(&gb);
if ([[self.fileType pathExtension] isEqualToString:@"isx"]) {
GB_load_isx(&gb, [self.fileName UTF8String]);
GB_load_battery(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"ram"] UTF8String]);
}
else {
GB_load_rom(&gb, [self.fileName UTF8String]);

View File

@ -540,6 +540,11 @@ restart:
}
if (strcmp(extension, "isx") == 0) {
error = GB_load_isx(&gb, filename);
/* Try loading .ram file if available */
char battery_save_path[path_length + 5]; /* At the worst case, size is strlen(path) + 4 bytes for .sav + NULL */
replace_extension(filename, path_length, battery_save_path, ".ram");
battery_save_path_ptr = battery_save_path;
GB_load_battery(&gb, battery_save_path);
}
else {
GB_load_rom(&gb, filename);