Libretro: Cheat code support

This commit is contained in:
Jeffrey Pfau 2015-11-14 21:08:31 -08:00
parent d5284f0f31
commit 51e9042f62
3 changed files with 15 additions and 4 deletions

View File

@ -4,6 +4,7 @@ Features:
- 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

View File

@ -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*);

View File

@ -7,6 +7,7 @@
#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 @@ void retro_init(void) {
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 @@ bool retro_unserialize(const void* data, size_t size) {
}
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) {