OpenEmu: Update implementation (#1910)

* OpenEmu: Update implementation

* CMake: Add ARC compile option to OpenEmu build
This commit is contained in:
clobber 2020-10-16 20:12:41 -05:00 committed by GitHub
parent 2702dcfb6f
commit bf2cdbacb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 28 deletions

View File

@ -947,6 +947,7 @@ if(BUILD_OPENEMU)
BUNDLE TRUE
BUNDLE_EXTENSION oecoreplugin
OUTPUT_NAME ${PROJECT_NAME}
COMPILE_OPTIONS "-fobjc-arc"
COMPILE_DEFINITIONS "DISABLE_THREADING;MGBA_STANDALONE;${OS_DEFINES};${FUNCTION_DEFINES};MINIMAL_CORE=1")
target_link_libraries(${BINARY_NAME}-openemu ${OS_LIB} ${FOUNDATION} ${OPENEMUBASE})
install(TARGETS ${BINARY_NAME}-openemu LIBRARY DESTINATION ${OE_LIBDIR} COMPONENT ${BINARY_NAME}.oecoreplugin NAMELINK_SKIP)

View File

@ -27,7 +27,7 @@
<key>openemu.system.gba</key>
<dict>
<key>OEGameCoreRewindBufferSeconds</key>
<integer>1200</integer>
<integer>60</integer>
<key>OEGameCoreRewindInterval</key>
<integer>0</integer>
<key>OEGameCoreSupportsRewinding</key>

View File

@ -67,6 +67,10 @@
core->init(core);
outputBuffer = nil;
unsigned width, height;
core->desiredVideoDimensions(core, &width, &height);
outputBuffer = malloc(width * height * BYTES_PER_PIXEL);
core->setVideoBuffer(core, outputBuffer, width);
core->setAudioBufferSize(core, SAMPLES);
cheatSets = [[NSMutableDictionary alloc] init];
}
@ -78,10 +82,7 @@
{
mCoreConfigDeinit(&core->config);
core->deinit(core);
[cheatSets release];
free(outputBuffer);
[super dealloc];
}
#pragma mark - Execution
@ -96,9 +97,9 @@
if (core->dirs.save) {
core->dirs.save->close(core->dirs.save);
}
core->dirs.save = VDirOpen([batterySavesDirectory UTF8String]);
core->dirs.save = VDirOpen([batterySavesDirectory fileSystemRepresentation]);
if (!mCoreLoadFile(core, [path UTF8String])) {
if (!mCoreLoadFile(core, [path fileSystemRepresentation])) {
*error = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadROMError userInfo:nil];
return NO;
}
@ -106,14 +107,6 @@
core->reset(core);
unsigned width, height;
core->desiredVideoDimensions(core, &width, &height);
if (outputBuffer) {
free(outputBuffer);
}
outputBuffer = malloc(width * height * BYTES_PER_PIXEL);
core->setVideoBuffer(core, outputBuffer, width);
return YES;
}
@ -161,9 +154,18 @@
return OEIntSizeMake(width, height);
}
- (const void *)videoBuffer
- (const void *)getVideoBufferWithHint:(void *)hint
{
return outputBuffer;
OEIntSize bufferSize = [self bufferSize];
if (!hint) {
hint = outputBuffer;
}
outputBuffer = hint;
core->setVideoBuffer(core, hint, bufferSize.width);
return hint;
}
- (GLenum)pixelFormat
@ -176,11 +178,6 @@
return GL_UNSIGNED_INT_8_8_8_8_REV;
}
- (GLenum)internalPixelFormat
{
return GL_RGB8;
}
- (NSTimeInterval)frameInterval
{
return core->frequency(core) / (double) core->frameCycles(core);
@ -230,14 +227,14 @@
- (void)saveStateToFileAtPath:(NSString *)fileName completionHandler:(void (^)(BOOL, NSError *))block
{
struct VFile* vf = VFileOpen([fileName UTF8String], O_CREAT | O_TRUNC | O_RDWR);
struct VFile* vf = VFileOpen([fileName fileSystemRepresentation], O_CREAT | O_TRUNC | O_RDWR);
block(mCoreSaveStateNamed(core, vf, 0), nil);
vf->close(vf);
}
- (void)loadStateFromFileAtPath:(NSString *)fileName completionHandler:(void (^)(BOOL, NSError *))block
{
struct VFile* vf = VFileOpen([fileName UTF8String], O_RDONLY);
struct VFile* vf = VFileOpen([fileName fileSystemRepresentation], O_RDONLY);
block(mCoreLoadStateNamed(core, vf, 0), nil);
vf->close(vf);
}
@ -284,12 +281,11 @@ const int GBAMap[] = {
}
struct mCheatDevice* cheats = core->cheatDevice(core);
cheatSet = cheats->createSet(cheats, [codeId UTF8String]);
int codeType = GBA_CHEAT_AUTODETECT;
if ([type isEqual:@"GameShark"]) {
codeType = GBA_CHEAT_GAMESHARK;
} else if ([type isEqual:@"Action Replay"]) {
codeType = GBA_CHEAT_PRO_ACTION_REPLAY;
size_t size = mCheatSetsSize(&cheats->cheats);
if (size) {
cheatSet->copyProperties(cheatSet, *mCheatSetsGetPointer(&cheats->cheats, size - 1));
}
int codeType = GBA_CHEAT_AUTODETECT;
NSArray *codeSet = [code componentsSeparatedByString:@"+"];
for (id c in codeSet) {
mCheatAddLine(cheatSet, [c UTF8String], codeType);