Noticed a few issues with cheats. I tested with Sonic The Hedgehog - Triple Trouble (USA, Europe).gg, running a Debug build in Xcode 6.4, OS X 10.10.4
**Issue 1 - Having two or more cheats enabled and then hitting Reset will freeze the game.
Steps to reproduce:
1. Load game, Sonic The Hedgehog - Triple Trouble (USA, Europe).gg
2. Open "Edit Cheats" menu
3. Add the following two cheats:
- 00D1-4009 (Infinite Lives)
- 00D3-C280 (Invincibility)
4. Select "Enable Cheats"
5. Select Reset
Result:
Game will try to reset and freeze with a black screen. sms_reset() calls sms_cheat_reset() which calls cc_dlist_remove() and I think you may be getting EXEC_BAD_ACCESS somewhere around here: https://sourceforge.net/p/crabemu/code/HEAD/tree/trunk/CrabEmu/src/utils/list.c#l68
**Issue 2 - Having two or more cheats enabled and then deleting one will crash the application.
Steps to reproduce:
1. Load game, Sonic The Hedgehog - Triple Trouble (USA, Europe).gg
2. Open "Edit Cheats" menu
3. Add the following two cheats:
- 00D1-4009 (Infinite Lives)
- 00D3-C280 (Invincibility)
4. Select "Enable Cheats"
5. Reopen "Edit Cheats" menu and delete the second cheat code
Result:
Application will crash with EXEC_BAD_ACCESS at https://sourceforge.net/p/crabemu/code/HEAD/tree/trunk/CrabEmu/src/consoles/sms/cheats.c#l97
**Issue 3 - Multiple cheats not saving correctly in .cht files.
Steps to reproduce:
1. Load game, Sonic The Hedgehog - Triple Trouble (USA, Europe).gg
2. Open "Edit Cheats" menu
3. Add the following two cheats:
- 00D1-4009 (Infinite Lives)
- 00D3-C280 (Invincibility)
4. Quit the application
Result:
Sonic The Hedgehog - Triple Trouble (USA, Europe).gg.cht file will be generated but all cheats will be written on one line instead of new lines for each, which will break restoring these cheats when you reopen the app and play this game again (http://i.imgur.com/Hn4dERz.png).
Example:
"# Cheats file generated by CrabEmu
00D1-4009 CODE100D3-C280 CODE2"
The second and third issues in this report are fixed as of r252.
The first issue isn't actually a bug. The cheat handler is working exactly as it should -- you just can't start the game with your infinite lives cheat enabled. Address 0xD140 (where the code patches) is used for something else while the game starts up, thus forcing it to 0x09 (once again, as the code there is doing) breaks the game startup.
Similar problems happen if you use an infinite rings code (00D1-5997) and have it active when you finish a level. It will never finish the score calculation!
Since all the actual code issues are fixed here, I'm closing this report.