diff --git a/CMakeLists.txt b/CMakeLists.txt index 9517e225d..af0426b8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/platform/openemu/Info.plist.in b/src/platform/openemu/Info.plist.in index 0642d81f1..b4ecfa95e 100644 --- a/src/platform/openemu/Info.plist.in +++ b/src/platform/openemu/Info.plist.in @@ -27,7 +27,7 @@ openemu.system.gba OEGameCoreRewindBufferSeconds - 1200 + 60 OEGameCoreRewindInterval 0 OEGameCoreSupportsRewinding diff --git a/src/platform/openemu/mGBAGameCore.m b/src/platform/openemu/mGBAGameCore.m index 2612ddef4..36bb3464a 100644 --- a/src/platform/openemu/mGBAGameCore.m +++ b/src/platform/openemu/mGBAGameCore.m @@ -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);