SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 1dfcdffa712a9be821d084bd63a96e9d5e2fdd12 parent 5b983bc7adcd0da288a7b2f64bfba1f55c32fef2 Author: Lior Halphon <LIJI32@gmail.com> Date: Sun, 20 Jul 2025 22:42:12 +0300 Properly handled Inbox and Boot ROMs in GBROMManager Diffstat:
| M | iOS/GBROMManager.h | 1 | + |
| M | iOS/GBROMManager.m | 19 | +++++++++++++++++-- |
| M | iOS/GBROMViewController.m | 11 | +++++++++++ |
| M | iOS/GBViewController.m | 15 | ++++----------- |
4 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/iOS/GBROMManager.h b/iOS/GBROMManager.h @@ -10,6 +10,7 @@ @property (readonly) NSString *batterySaveFile; @property (readonly) NSString *autosaveStateFile; @property (readonly) NSString *cheatsFile; +@property (readonly) NSArray <NSString *> *forbiddenNames; @property (readonly) NSString *localRoot; - (NSString *)stateFile:(unsigned)index; diff --git a/iOS/GBROMManager.m b/iOS/GBROMManager.m @@ -34,9 +34,17 @@ return self; } +- (NSArray<NSString *> *)forbiddenNames +{ + return @[@"Inbox", @"Boot ROMs"]; +} + - (void)setCurrentROM:(NSString *)currentROM { _romFile = nil; + if ([self.forbiddenNames containsObject:currentROM]) { + currentROM = nil; + } _currentROM = currentROM; bool foundROM = self.romFile; @@ -64,6 +72,9 @@ - (NSString *)romDirectoryForROM:(NSString *)romFile { + if ([self.forbiddenNames containsObject:romFile]) { + return nil; + } return [self.localRoot stringByAppendingPathComponent:romFile]; } @@ -80,9 +91,10 @@ if (rom == _currentROM) { return self.romFile; } - if ([rom isEqualToString:@"Inbox"]) return nil; - if ([rom isEqualToString:@"Boot ROMs"]) return nil; + if ([self.forbiddenNames containsObject:rom]) { + return nil; + } return [self romFileForDirectory:[self romDirectoryForROM:rom]]; } @@ -149,6 +161,9 @@ - (NSString *)makeNameUnique:(NSString *)name { + if ([self.forbiddenNames containsObject:name]) { + name = @"Imported ROM"; + } NSString *root = self.localRoot; if (![[NSFileManager defaultManager] fileExistsAtPath:[root stringByAppendingPathComponent:name]]) return name; diff --git a/iOS/GBROMViewController.m b/iOS/GBROMViewController.m @@ -256,6 +256,17 @@ [self presentViewController:alert animated:true completion:nil]; return; } + if ([[GBROMManager sharedManager].forbiddenNames containsObject:newName]) { + [self.tableView reloadData]; + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Invalid Name" + message:@"This name is reserved by SameBoy or iOS. Please choose another name." + preferredStyle:UIAlertControllerStyleAlert]; + [alert addAction:[UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleCancel + handler:nil]]; + [self presentViewController:alert animated:true completion:nil]; + return; + } [self renameROM:oldName toName:newName]; _renamingPath = nil; } diff --git a/iOS/GBViewController.m b/iOS/GBViewController.m @@ -902,17 +902,10 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) } NSDate *date = nil; - @try { - [[NSURL fileURLWithPath:[GBROMManager sharedManager].autosaveStateFile] getResourceValue:&date - forKey:NSURLContentModificationDateKey - error:nil]; - } - @catch (NSException *exception) { - /* fileURLWithPath: throws an exception on some crash logs. I don't know why or how to reproduce it, - but let's at least not crash. */ - GB_rewind_reset(&_gb); - } - + [[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]) {
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.