Libretro: Cheat code support
Jeffrey Pfau jeffrey@endrift.com
Sat, 14 Nov 2015 21:08:31 -0800
3 files changed,
15 insertions(+),
4 deletions(-)
M
CHANGES
→
CHANGES
@@ -4,6 +4,7 @@ - Officially supported ports for the Nintendo 3DS, Wii, and PlayStation Vita
- I/O viewer - Booting of multiboot images - Customization of GIF recording + - Libretro: Cheat code support Bugfixes: - Util: Fix PowerPC PNG read/write pixel order - Qt: Use safer isLoaded check in GameController
M
src/gba/cheats.h
→
src/gba/cheats.h
@@ -212,7 +212,6 @@ bool GBACheatAddProActionReplay(struct GBACheatSet*, uint32_t op1, uint32_t op2);
bool GBACheatAddProActionReplayLine(struct GBACheatSet*, const char* line); bool GBACheatAddAutodetect(struct GBACheatSet*, uint32_t op1, uint32_t op2); -bool GBACheatAddAutodetectLine(struct GBACheatSet*, const char* line); bool GBACheatParseFile(struct GBACheatDevice*, struct VFile*); bool GBACheatSaveFile(struct GBACheatDevice*, struct VFile*);
M
src/platform/libretro/libretro.c
→
src/platform/libretro/libretro.c
@@ -7,6 +7,7 @@ #include "libretro.h"
#include "util/common.h" +#include "gba/cheats.h" #include "gba/renderers/video-software.h" #include "gba/serialize.h" #include "gba/context/context.h"@@ -45,6 +46,8 @@ static struct CircleBuffer rumbleHistory;
static struct GBARumble rumble; static struct GBALuminanceSource lux; static int luxLevel; +static struct GBACheatDevice cheats; +static struct GBACheatSet cheatSet; unsigned retro_api_version(void) { return RETRO_API_VERSION;@@ -190,10 +193,18 @@ #if RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF
blip_set_rates(context.gba->audio.left, GBA_ARM7TDMI_FREQUENCY, 32768); blip_set_rates(context.gba->audio.right, GBA_ARM7TDMI_FREQUENCY, 32768); #endif + + GBACheatDeviceCreate(&cheats); + GBACheatSetInit(&cheatSet, "libretro"); + GBACheatAddSet(&cheats, &cheatSet); + GBACheatAttachDevice(context.gba, &cheats); } void retro_deinit(void) { GBAContextDeinit(&context); + GBACheatRemoveSet(&cheats, &cheatSet); + GBACheatDeviceDestroy(&cheats); + GBACheatSetDeinit(&cheatSet); free(renderer.outputBuffer); }@@ -303,14 +314,14 @@ return true;
} void retro_cheat_reset(void) { - // TODO: Cheats + GBACheatSetDeinit(&cheatSet); + GBACheatSetInit(&cheatSet, "libretro"); } void retro_cheat_set(unsigned index, bool enabled, const char* code) { - // TODO: Cheats UNUSED(index); UNUSED(enabled); - UNUSED(code); + GBACheatAddLine(&cheatSet, code); } unsigned retro_get_region(void) {