Skip to content

Commit

Permalink
Correctly handles multi-line cheats
Browse files Browse the repository at this point in the history
  • Loading branch information
rileytestut committed Apr 20, 2020
1 parent b90b603 commit e16b8aa
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions SNESDeltaCore/Bridge/SNESEmulatorBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -238,30 +238,36 @@ - (void)loadSaveStateFromURL:(NSURL *)URL

- (BOOL)addCheatCode:(NSString *)cheatCode type:(NSString *)type
{
BOOL success = YES;

uint32 address = 0;
uint8 byte = 0;

if ([type isEqualToString:CheatTypeGameGenie])
{
success = (S9xGameGenieToRaw([cheatCode UTF8String], address, byte) == NULL);
}
else if ([type isEqualToString:CheatTypeActionReplay])
{
success = (S9xProActionReplayToRaw([cheatCode UTF8String], address, byte) == NULL);
}
else
{
success = NO;
}

if (success)
NSArray<NSString *> *codes = [cheatCode componentsSeparatedByString:@"\n"];
for (NSString *code in codes)
{
BOOL success = YES;

uint32 address = 0;
uint8 byte = 0;

if ([type isEqualToString:CheatTypeGameGenie])
{
success = (S9xGameGenieToRaw([code UTF8String], address, byte) == NULL);
}
else if ([type isEqualToString:CheatTypeActionReplay])
{
success = (S9xProActionReplayToRaw([code UTF8String], address, byte) == NULL);
}
else
{
success = NO;
}

if (!success)
{
return NO;
}

S9xAddCheat(true, true, address, byte);
}

return success;
return YES;
}

- (void)resetCheats
Expand Down

0 comments on commit e16b8aa

Please sign in to comment.