RobLoach / RobLoach/SDL_libretro
Load RetroArch-format cheat files (.cht)
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 2
- Forks
- 0
- Avg merge
- 16h 55m
- Merged PRs (30d)
- 12
Description
The cheat API is currently raw-only: SDL_Libretro_SetCheat() / SDL_Libretro_ResetCheats() (include/SDL_libretro.h:266-267) forward directly to retro_cheat_set / retro_cheat_reset, so every application must parse cheat databases itself. The de-facto ecosystem format is RetroArch's .cht INI-style file (cheat0_desc, cheat0_code, cheat0_enable, cheats = N), and the repo already vendors an INI parser (include/SDL_ini.h) used by the config system.
Suggested Implementation
bool SDL_Libretro_LoadCheats(SDL_Libretro* lr, const char* path);
bool SDL_Libretro_LoadCheats_IO(SDL_Libretro* lr, SDL_IOStream* src, bool closeio);
unsigned SDL_Libretro_GetCheatCount(const SDL_Libretro* lr);
bool SDL_Libretro_GetCheat(const SDL_Libretro* lr, unsigned index, const char** desc, const char** code, bool* enabled);
bool SDL_Libretro_SetCheatEnabled(SDL_Libretro* lr, unsigned index, bool enabled);
- Parse with
SDL_ini.h(cheats = N, thencheatN_desc/cheatN_code/cheatN_enablekeys); store a deep-copied cheat list on the context so cheats can be listed and toggled after load (the menu system #129 would surface this list). - On load and on toggle, replay the enabled set to the core via the existing
SetCheatpath; clear the list inResetCheatsand on game unload. - Optionally auto-load
<content>.chtfrom the save directory viaSDL_Libretro_GetSavePath()when a game loads, mirroring how SRAM auto-restore works.
QA
- Unit tests: parse a sample
.cht(including quoted values and a disabled entry), assert count/desc/code/enabled round-trip, assert the test core (test/test_core.c) receivedretro_cheat_setcalls for enabled cheats only, and toggling replays correctly. - Malformed file returns false with an SDL error and leaves prior cheats untouched.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with include/SDL_libretro.h and the existing SDL_Libretro_SetCheat(), ResetCheats(), and game-unload paths, then read include/SDL_ini.h for the parser API. Inspect test/test_core.c and run the existing tests before adding coverage for quoted values, disabled entries, malformed files, and replayed toggles. Done means the listed APIs preserve cheats, apply enabled entries to the core, and leave prior state intact on load failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 62/100