Libretro, OpenEmu: Fix build, functionality untested

This commit is contained in:
Jeffrey Pfau 2016-05-08 00:00:07 -07:00
parent 3908b43d93
commit 72b826dd20
2 changed files with 18 additions and 39 deletions

View File

@ -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 @@ void retro_init(void) {
}
void retro_deinit(void) {
GBACheatRemoveSet(&cheats, &cheatSet);
GBACheatDeviceDestroy(&cheats);
GBACheatSetDeinit(&cheatSet);
free(outputBuffer);
}
@ -341,11 +336,6 @@ bool retro_load_game(const struct retro_game_info* game) {
core->loadBIOS(core, bios, 0);
}
}
GBACheatDeviceCreate(&cheats);
GBACheatAttachDevice(gba, &cheats);
GBACheatSetInit(&cheatSet, "libretro");
GBACheatAddSet(&cheats, &cheatSet);
}
#endif
@ -389,13 +379,20 @@ bool retro_unserialize(const void* data, size_t size) {
}
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 @@ void retro_cheat_set(unsigned index, bool enabled, const char* code) {
}
if ((pos == 13 && (realCode[pos] == ' ' || !realCode[pos])) || pos == 17) {
realCode[pos] = '\0';
GBACheatAddLine(&cheatSet, realCode);
mCheatAddLine(cheatSet, realCode, 0);
pos = 0;
continue;
}

View File

@ -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 @@
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 @@ const int GBAMap[] = {
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