all repos — mgba @ bf2cdbacb6037f3bd07f41db62fcb17eda77de10

mGBA Game Boy Advance Emulator

OpenEmu: Update implementation (#1910)

* OpenEmu: Update implementation

* CMake: Add ARC compile option to OpenEmu build
clobber brymaster@gmail.com
Fri, 16 Oct 2020 20:12:41 -0500
commit

bf2cdbacb6037f3bd07f41db62fcb17eda77de10

parent

2702dcfb6f83ebb2aae72207b75959f4a639b6ce

3 files changed, 25 insertions(+), 28 deletions(-)

jump to
M CMakeLists.txtCMakeLists.txt

@@ -947,6 +947,7 @@ MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/openemu/Info.plist.in

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)
M src/platform/openemu/Info.plist.insrc/platform/openemu/Info.plist.in

@@ -27,7 +27,7 @@ <dict>

<key>openemu.system.gba</key> <dict> <key>OEGameCoreRewindBufferSeconds</key> - <integer>1200</integer> + <integer>60</integer> <key>OEGameCoreRewindInterval</key> <integer>0</integer> <key>OEGameCoreSupportsRewinding</key>
M src/platform/openemu/mGBAGameCore.msrc/platform/openemu/mGBAGameCore.m

@@ -67,6 +67,10 @@ mCoreConfigLoadDefaults(&core->config, &opts);

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 @@ - (void)dealloc

{ mCoreConfigDeinit(&core->config); core->deinit(core); - [cheatSets release]; free(outputBuffer); - - [super dealloc]; } #pragma mark - Execution

@@ -96,9 +97,9 @@ error:nil];

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 @@ mCoreAutoloadSave(core);

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 @@ core->desiredVideoDimensions(core, &width, &height);

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

@@ -174,11 +176,6 @@

- (GLenum)pixelType { return GL_UNSIGNED_INT_8_8_8_8_REV; -} - -- (GLenum)internalPixelFormat -{ - return GL_RGB8; } - (NSTimeInterval)frameInterval

@@ -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 @@ return;

} struct mCheatDevice* cheats = core->cheatDevice(core); cheatSet = cheats->createSet(cheats, [codeId UTF8String]); + size_t size = mCheatSetsSize(&cheats->cheats); + if (size) { + cheatSet->copyProperties(cheatSet, *mCheatSetsGetPointer(&cheats->cheats, size - 1)); + } 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; - } NSArray *codeSet = [code componentsSeparatedByString:@"+"]; for (id c in codeSet) { mCheatAddLine(cheatSet, [c UTF8String], codeType);