From 9e99ce434e9903d7c1db0747a344059768505814 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 25 Apr 2020 23:09:08 +0300 Subject: [PATCH] Allow loading .RAM files --- Cocoa/Document.m | 2 ++ SDL/main.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/Cocoa/Document.m b/Cocoa/Document.m index ed52efb..6eb9c2f 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -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]); diff --git a/SDL/main.c b/SDL/main.c index e09630b..9a358d0 100644 --- a/SDL/main.c +++ b/SDL/main.c @@ -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);