Libretro, OpenEmu: Fix build, functionality untested
Jeffrey Pfau jeffrey@endrift.com
Sun, 08 May 2016 00:00:07 -0700
2 files changed,
18 insertions(+),
39 deletions(-)
M
src/platform/libretro/libretro.c
→
src/platform/libretro/libretro.c
@@ -51,8 +51,6 @@ static struct CircleBuffer rumbleHistory;
static struct mRumble rumble; static struct GBALuminanceSource lux; static int luxLevel; -static struct GBACheatDevice cheats; -static struct GBACheatSet cheatSet; static struct mLogger logger; static void _reloadSettings(void) {@@ -213,9 +211,6 @@ stream.postVideoFrame = 0;
} void retro_deinit(void) { - GBACheatRemoveSet(&cheats, &cheatSet); - GBACheatDeviceDestroy(&cheats); - GBACheatSetDeinit(&cheatSet); free(outputBuffer); }@@ -341,11 +336,6 @@ if (bios) {
core->loadBIOS(core, bios, 0); } } - - GBACheatDeviceCreate(&cheats); - GBACheatAttachDevice(gba, &cheats); - GBACheatSetInit(&cheatSet, "libretro"); - GBACheatAddSet(&cheats, &cheatSet); } #endif@@ -389,13 +379,20 @@ return true;
} void retro_cheat_reset(void) { - GBACheatSetDeinit(&cheatSet); - GBACheatSetInit(&cheatSet, "libretro"); + mCheatDeviceClear(core->cheatDevice(core)); } void retro_cheat_set(unsigned index, bool enabled, const char* code) { UNUSED(index); UNUSED(enabled); + struct mCheatDevice* device = core->cheatDevice(core); + struct mCheatSet* cheatSet = NULL; + if (mCheatSetsSize(&device->cheats)) { + cheatSet = *mCheatSetsGetPointer(&device->cheats, 0); + } else { + cheatSet = device->createSet(device, NULL); + mCheatAddSet(device, cheatSet); + } // Convert the super wonky unportable libretro format to something normal char realCode[] = "XXXXXXXX XXXXXXXX"; size_t len = strlen(code) + 1; // Include null terminator@@ -408,7 +405,7 @@ realCode[pos] = code[i];
} if ((pos == 13 && (realCode[pos] == ' ' || !realCode[pos])) || pos == 17) { realCode[pos] = '\0'; - GBACheatAddLine(&cheatSet, realCode); + mCheatAddLine(cheatSet, realCode, 0); pos = 0; continue; }
M
src/platform/openemu/mGBAGameCore.m
→
src/platform/openemu/mGBAGameCore.m
@@ -27,11 +27,8 @@
#include "util/common.h" #include "core/core.h" -#include "gba/audio.h" #include "gba/cheats.h" #include "gba/core.h" -#include "gba/cheats/gameshark.h" -#include "gba/gba.h" #include "gba/input.h" #include "gba/serialize.h" #include "util/circle-buffer.h"@@ -47,8 +44,6 @@
@interface mGBAGameCore () <OEGBASystemResponderClient> { struct mCore* core; - struct GBA* gba; - struct GBACheatDevice cheats; void* outputBuffer; NSMutableDictionary *cheatSets; }@@ -75,9 +70,6 @@ outputBuffer = malloc(width * height * BYTES_PER_PIXEL);
core->setVideoBuffer(core, outputBuffer, width); core->setAudioBufferSize(core, SAMPLES); - gba = core->board; - GBACheatDeviceCreate(&cheats); - GBACheatAttachDevice(gba, &cheats); cheatSets = [[NSMutableDictionary alloc] init]; }@@ -87,17 +79,6 @@
- (void)dealloc { core->deinit(core); - [cheatSets enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - UNUSED(key); - UNUSED(stop); - GBACheatRemoveSet(&cheats, [obj pointerValue]); - }]; - GBACheatDeviceDestroy(&cheats); - [cheatSets enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - UNUSED(key); - UNUSED(stop); - GBACheatSetDeinit([obj pointerValue]); - }]; [cheatSets release]; free(outputBuffer);@@ -288,25 +269,26 @@ code = [code stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
code = [code stringByReplacingOccurrencesOfString:@" " withString:@""]; NSString *codeId = [code stringByAppendingFormat:@"/%@", type]; - struct GBACheatSet* cheatSet = [[cheatSets objectForKey:codeId] pointerValue]; + struct mCheatSet* cheatSet = [[cheatSets objectForKey:codeId] pointerValue]; if (cheatSet) { cheatSet->enabled = enabled; return; } - cheatSet = malloc(sizeof(*cheatSet)); - GBACheatSetInit(cheatSet, [codeId UTF8String]); + struct mCheatDevice* cheats = core->cheatDevice(core); + cheatSet = cheats->createSet(cheats, [codeId UTF8String]); + int codeType = GBA_CHEAT_AUTODETECT; if ([type isEqual:@"GameShark"]) { - GBACheatSetGameSharkVersion(cheatSet, 1); + codeType = GBA_CHEAT_GAMESHARK; } else if ([type isEqual:@"Action Replay"]) { - GBACheatSetGameSharkVersion(cheatSet, 3); + codeType = GBA_CHEAT_PRO_ACTION_REPLAY; } NSArray *codeSet = [code componentsSeparatedByString:@"+"]; for (id c in codeSet) { - GBACheatAddLine(cheatSet, [c UTF8String]); + mCheatAddLine(cheatSet, [c UTF8String], codeType); } cheatSet->enabled = enabled; [cheatSets setObject:[NSValue valueWithPointer:cheatSet] forKey:codeId]; - GBACheatAddSet(&cheats, cheatSet); + mCheatAddSet(cheats, cheatSet); } @end