From 6b71d9c58c3bc6e4e71ef1771883a2880edef280 Mon Sep 17 00:00:00 2001 From: clobber Date: Sat, 12 Dec 2015 17:06:54 -0800 Subject: [PATCH] Clean up deprecated methods. --- ProSystemGameCore.mm | 70 +++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 46 deletions(-) diff --git a/ProSystemGameCore.mm b/ProSystemGameCore.mm index 8bb4d57..ae13db2 100644 --- a/ProSystemGameCore.mm +++ b/ProSystemGameCore.mm @@ -131,11 +131,6 @@ } - (void)executeFrame -{ - [self executeFrameSkippingFrame:NO]; -} - -- (void)executeFrameSkippingFrame:(BOOL)skip { prosystem_ExecuteFrame(_inputState); @@ -229,14 +224,14 @@ #pragma mark - Save States -- (BOOL)saveStateToFileAtPath:(NSString *)fileName +- (void)saveStateToFileAtPath:(NSString *)fileName completionHandler:(void (^)(BOOL, NSError *))block { - return prosystem_Save([fileName UTF8String], false) ? YES : NO; + block(prosystem_Save(fileName.fileSystemRepresentation, false) ? YES : NO, nil); } -- (BOOL)loadStateFromFileAtPath:(NSString *)fileName +- (void)loadStateFromFileAtPath:(NSString *)fileName completionHandler:(void (^)(BOOL, NSError *))block { - return prosystem_Load([fileName UTF8String]) ? YES : NO; + block(prosystem_Load(fileName.fileSystemRepresentation) ? YES : NO, nil); } - (NSData *)serializeStateWithError:(NSError **)outError @@ -245,59 +240,42 @@ void *bytes = malloc(length); if(prosystem_Save_buffer((uint8_t *)bytes)) - { return [NSData dataWithBytesNoCopy:bytes length:length freeWhenDone:YES]; - } - else - { - if(outError) - { - *outError = [NSError errorWithDomain:OEGameCoreErrorDomain - code:OEGameCoreCouldNotSaveStateError - userInfo:@{ - NSLocalizedDescriptionKey : @"Save state data could not be written", - NSLocalizedRecoverySuggestionErrorKey : @"The emulator could not write the state data." - }]; - } - return nil; + if(outError) { + *outError = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotSaveStateError userInfo:@{ + NSLocalizedDescriptionKey : @"Save state data could not be written", + NSLocalizedRecoverySuggestionErrorKey : @"The emulator could not write the state data." + }]; } + + return nil; } - (BOOL)deserializeState:(NSData *)state withError:(NSError **)outError { size_t serial_size = cartridge_type == CARTRIDGE_TYPE_SUPERCART_RAM ? 32837 : 16453; - if(serial_size != [state length]) - { - if(outError) - { - *outError = [NSError errorWithDomain:OEGameCoreErrorDomain - code:OEGameCoreStateHasWrongSizeError - userInfo:@{ - NSLocalizedDescriptionKey : @"Save state has wrong file size.", - NSLocalizedRecoverySuggestionErrorKey : [NSString stringWithFormat:@"The save state does not have the right size, %ld expected, got: %ld.", serial_size, [state length]] - }]; + if(serial_size != [state length]) { + if(outError) { + *outError = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreStateHasWrongSizeError userInfo:@{ + NSLocalizedDescriptionKey : @"Save state has wrong file size.", + NSLocalizedRecoverySuggestionErrorKey : [NSString stringWithFormat:@"The save state does not have the right size, %ld expected, got: %ld.", serial_size, [state length]] + }]; } + return NO; } if(prosystem_Load_buffer((uint8_t *)[state bytes])) - { return YES; - } - else - { - if(outError) - { - *outError = [NSError errorWithDomain:OEGameCoreErrorDomain - code:OEGameCoreCouldNotLoadStateError - userInfo:@{ - NSLocalizedDescriptionKey : @"The save state data could not be read" - }]; - } - return NO; + if(outError) { + *outError = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadStateError userInfo:@{ + NSLocalizedDescriptionKey : @"The save state data could not be read" + }]; } + + return NO; } #pragma mark - Input