[WiP] Adding Cheat Support to more cores

It’s hard to tell what’s more frustrating: older games with needlessly-frustrating mechanics, or libretro cores that don’t support cheats when their base emulator does. So, I’m setting out to fix both of those problems by adding cheat support to libretro cores that are missing them, at least until I get bored. Turns out almost all of the work is already done by leftovers in the cores, and I only needed to put the pieces together in retro_cheat_set and retro_cheat_reset.

Current Status:

  • Mupen64Plus and ParaLLEl N64: Full GameShark support
  • Beetle PSX: Full GameShark support
  • Genesis Plus GX, Picodrive: Full GGG and PAR support for all consoles.
  • VBA-M: Supports GSv3 (Encrypted) and CBA (Decrypted).
  • bsnes and bsnes-mercury: Full GG, PAR, and GoldFinger support
  • Snes9x (no-year): Full GG, PAR, and GoldFinger support.
  • Nestopia: Full GG, PAR, and RAW support.

Planned/Potential Updates:

  • Yabause and Beetle Saturn - Investigate current status and add support for all possible cheats. Waiting on me acquiring some Saturn games.
  • mGBA - Investigate current status and add support for all possible cheats.
  • Retroarch - Make entering cheats less of a hassle
  • Retroarch - Replace .cht file format with one that’s less of a hassle
  • Libretro/Retroarch - Add support for explicit cheat types and specifying to underlying cores

How to help me help you help us all:

  • Do not rely on RetroArch’s provided cheat files. These files were auto-generated, are completely untested, and may be in an unsupported format or for a different game version.
  • Verify your code works on a real console cheat device or another emulator before posting any issues here, if possible.
  • Verify you are on the latest version the core.
  • Verify you did not make a typo on code entry.
  • Make a post here identifying your core, test rom including region and version if applicable, and a test code. It helps if it’s something easy to test like infinite ammo. If it requires me to be in a specific location of the game that can’t be reached in only a couple of minutes, attach the game’s save file.
  • Feel free to post cheat issues you have with cores not in my progress list.

Enjoy ruining all of the fun.

6 Likes

I tried gameshark codes with Majora’s Mask in mupen64plus core. When I load the codes the game crashes. I just googled the codes and used the (Must be active code). along with a few other codes. I eventually just tried the (must be active) code, but it crashes every time.

Enable/M/Must be Active codes are only for use by actual gamesharks. Emulators don’t need them, so you should not be using them. Still, this shouldn’t have crashed the emulator. Try the codes without the enable, and if it still crashes I’ll take a closer look at it.

Can you take a look at this issue when you get a chance:

https://github.com/GLupeN64/GLupeN64/issues/148

Turns out I did a dumb on mupen and glupen’s implementations. Pull requests have been submitted, so the fixes should arrive in the next couple of days. Special thanks to LoganMC10 for cross-compiling windows builds for me.

I recently laid the groundwork for integrating cheats into the MAME cores by locating compatible cheat.dat files to the repositories for each of the ‘frozen’ MAME repositories. For example: https://github.com/libretro/mame2003-libretro/blob/master/metadata/cheat.dat

This metadata is required to activate MAME’s internal cheat engine via the ‘tab menu’. Perhaps with your knowledge of RA cheats plus these cheat.dat files you will see an easy path for integration so that cheats can be used in the native RetroArch fashion.

I started an issue in libretro-database last week on this topic, although at this point there is not much more information in the issue than I’ve included in this post :slight_smile: https://github.com/libretro/libretro-database/issues/412

1 Like

I finally got around to investigating the GBA cores for improving cheat support. Currently I’m only seriously working on VBA-M.

VBA-M: Upstream VBA-M allegedly supports nine unique code formats: GSA V1 (+ Encrypted), GSA V3 (+ Encrypted), CBA (+ Encrypted), and native 8/16/32 bit. Here’s the problem I’m facing: All four GSA variants have the exact same string format and length, but are incompatible with each other. XXXXXXXX YYYYYYYY. Both CBA code formats have the same string format and length. XXXXXXXX YYYY Native cheats can have an ending part two, four, or eight characters long, and thus incompatibly overlaps with CBA and GSA codes. However, these native cheats are designed to have their parts delimited with a “:”. XXXXXXXX:YY|YYYY|YYYYYYYY

My previous approaches are based on the assumption that codes would be of one format, or the formats would be sufficiently different to be easily distinguishable in code. RetroArch’s cheat support seems to be designed around this as well, as there is no way to pass a parameter distinguishing what code type the supplied code is.

This leaves me to decide which code formats should be supported. Of the code types, GSv3/v4 and CBA are the most adaptable and can be simultaneously recognized. However, further testing has shown that only encrypted GSA codes and only decrypted CBA codes will properly apply. These two formats should support every code type available, and if a code isn’t in either of these formats, there are many tools that can convert codes from one format to the next, including this online one at gamehacking.org.

Relevant to this decision is the format of RetroArch’s included GBA cheats. This format is exclusively CBA, except depending on the game can be encrypted or decrypted. Given that only decrypted cheats work at the moment, there’s now a decision of whether to decrypt the CBA codes in the cht files or alter the VBA-M code to automatically decrypt CBA codes.

VBA-M has CBA decryption code work and code that’s supposed to automatically decrypt encrypted codes on being added. Problem is, that decryption code just doesn’t want to fire, at least in my test case. When forced to fire, it crashes the emulator. Naturally I don’t want to screw with it any longer.

VBA Next: From a quick search on github, cheat support code exists in headers only. I’ll have to backport the VBA-M code.

Beetle/Mednafen VBA: Cheats are in Mednafen’s internal format. At first glance, none of my VBA-M work will apply.

Meteor: No Cheat support in upstream core.

gpSP: Limited cheat support in upstream core, will likely have to make the same assumptions as in VBA-M.

TempGBA: Core is for PSP only. RetroArch for PSP is so buggy that I’m not sure cheats even work within RA. gpSP Mod supports cheats on the PSP, so just use that if you’re stuck on one of those.

2 Likes

Want to cheat in Genesis games? Worry no longer! PicoDrive will shortly support Game Genie, Genecyst Patch, and, brand new to the emulator, Action Replay cheats. Pull request submitted; expect it to land shortly.

Update on GBA cheats: I submitted a pull request with my preliminary code for VBA-M and a copy of my wall of text. I don’t expect it to get merged in its current state, but hopefully I’ll get a developer’s response on it.

Update on MAME cheats: I don’t do MAME, so I haven’t even looked into it yet, and probably won’t for some time.

3 Likes

Will cheat support be added to the Genesis Plus GX core? I avoid Picodrive like the plague.

I took a quick look and it looks like GX should support cheats already based on what I’m seeing in libretro.c. Time to put it to the test.

Genesis

  • GG - Working
  • Patch - Working
  • AR - Working
  • Multiline - Non-working

Master System / Game Gear

  • GG - Working
  • AR - Non-Working
  • Fusion - Non-Working
  • Multiline - Not Tested

Well, I have to say that’s pretty good already. Some work needs to be done on Master System still.

In only a few minutes, I got multiline to work, so now all Genesis and presumably Sega CD games should be able to be cheated flawlessly. Going to take a look at Master System at a later date.

2 Likes

It seems BSNES doesn’t support cheats either from what i’ve tested. Any plans for that core?

That’s great, so the Megadrive cheats from the online updater should work now? I’ll check it out, thanks!

There are four bsnes cores. I’m not in a position to properly test at the moment, but I can take a peek at libretro.cpp for these cores.

bsnes-libretro - some code is present. Needs testing.

bsnes-mercury - Same code as libretro, but commented out.

beetle-bsnes-libretro - No code present, but upstream likely supports cheats in Mednafen’s special overcomplicated format.

bsnes-libretro-cplusplus98 - Same code as bsnes-libretro, and not commented out.

2 Likes

I haven’t tested the actual cheat files yet but hopefully they will. Still, it may take a day or two for the new builds to make it to the core updater.

Oh right, yeah they are not working currently on Megadrive games, I just tested it there.

I can confirm that Picodrive and Genesis Plus GX both support retroarch’s included cheat files for Genesis games, or at least will once the updates land.

I tested the bsnes core with cheats. Result: CRASH terminate called after throwing an instance of ‘nall::vector::exception_out_of_bounds’

After working around that, none of the code types are working. Looks like the core has incomplete work added to it. Decoding and Applying functions need to be added in. I’ll add it to the list of things to do.

Retroarch Cheats To-Do list:

  • Mednafen PSX - Figure out the internal cheat format. Add multiline support.
  • MAME - Write conversion functions from RA’s cheats to MAME’s internal format.
  • VBA-M - Cleanup code, port to other GBA cores
  • Picodrive - Add cheat support for Master System
  • Genesis Plus GX - Support AR and Fusion format Master System cheats.
  • BSNES - Write functions for decoding SNES and SGB cheats
3 Likes

Thanks a lot for working on this, it’s much appreciated.

When you say Bsnes, does that mean that cheats should work on each of the Bsnes cores once your planned changes are made? There are quite a few Bsnes cores, I use the Accuracy one but I know a lot of people use Balanced aswell.

Thanks again :grinning:

With this pull request, Genesis Plus GX now supports the following cheats:

Global:

  • Multiline: {cheat}+{cheat}

Genesis [and CD?]:

  • Game Genie AAAA-AAAA
  • Patch 012345:6787
  • Action Replay FF1234:5678

Master System [and GG?]:

  • Game Genie ABC-DEF-GHJ
  • Action Replay 0012-3456
  • Fusion 0123:45 and 670123:45

Barring any bugs I missed or requests for other code formats, this can be considered complete.

Up next, Picodrive will be made to have the same cheat support, so that I can finally make Sega do what Nintendon’t. But not to worry, soon you’ll be playing with power.

When I finally get to the BSNES work, it’ll work in Performance Balanced and Accuracy alike.

2 Likes

Picodrive is now finished, and now it and Genesis Plus GX support a “new” code type.

Master System

  • Game Genie [short]: ABC-DEF

It’s a valid code type, so here you go, enjoy.

I’m done with SEGA consoles for now.

3 Likes

Thank you for doing this!