Skip to content

Commit

Permalink
Clean up deprecated methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
clobber committed Dec 13, 2015
1 parent 9596973 commit 4269e63
Showing 1 changed file with 20 additions and 44 deletions.
64 changes: 20 additions & 44 deletions GBGameCore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,14 @@ @interface GBGameCore () <OEGBSystemResponderClient>
double sampleRate;
int displayMode;
}
- (void)outputAudio:(unsigned)frames;

- (void)applyCheat:(NSString *)code;
- (void)loadPalette;

@end

@implementation GBGameCore

static __weak GBGameCore *_current;

- (id)init
{
if((self = [super init]))
Expand All @@ -75,8 +74,6 @@ - (id)init
displayMode = 0;
}

_current = self;

return self;
}

Expand Down Expand Up @@ -125,18 +122,11 @@ - (BOOL)loadFileAtPath:(NSString *)path error:(NSError **)error
}

- (void)executeFrame
{
[self executeFrameSkippingFrame:NO];
}

- (void)executeFrameSkippingFrame:(BOOL)skip
{
size_t samples = 2064;

while (gb.runFor(videoBuffer, 160, inSoundBuffer, samples) == -1)
{
[self outputAudio:samples];
}

[self outputAudio:samples];
}
Expand Down Expand Up @@ -223,12 +213,11 @@ - (void)loadStateFromFileAtPath:(NSString *)fileName completionHandler:(void (^)
if(block) block(success==1, nil);
}

- (NSData*)serializeStateWithError:(NSError **)outError
- (NSData *)serializeStateWithError:(NSError **)outError
{
std::stringstream stream(std::ios::in|std::ios::out|std::ios::binary);

if(gb.serializeState(stream))
{
if(gb.serializeState(stream)) {
stream.seekg(0, std::ios::end);
NSUInteger length = stream.tellg();
stream.seekg(0, std::ios::beg);
Expand All @@ -238,20 +227,15 @@ - (NSData*)serializeStateWithError:(NSError **)outError

return [NSData dataWithBytesNoCopy:bytes length:length];
}
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
Expand All @@ -263,23 +247,15 @@ - (BOOL)deserializeState:(NSData *)state withError:(NSError **)outError
stream.write(bytes, size);

if(gb.deserializeState(stream))
{
return YES;

if(outError) {
*outError = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadStateError userInfo:@{
NSLocalizedDescriptionKey : @"The save state data could not be read",
NSLocalizedRecoverySuggestionErrorKey : @"Could not load data from the save state"
}];
}
else
{
if(outError)
{
*outError = [NSError errorWithDomain:OEGameCoreErrorDomain
code:OEGameCoreCouldNotLoadStateError
userInfo:@{
NSLocalizedDescriptionKey : @"The save state data could not be read",
NSLocalizedRecoverySuggestionErrorKey : @"Could not load data from the save state"
}];
}

return NO;
}
return NO;
}

# pragma mark - Input
Expand Down Expand Up @@ -484,7 +460,7 @@ - (void)changeDisplayMode

# pragma mark - Misc Helper Methods

- (void)outputAudio:(unsigned)frames
- (void)outputAudio:(size_t)frames
{
if (!frames)
return;
Expand Down

0 comments on commit 4269e63

Please sign in to comment.