diff --git a/CMakeLists.txt b/CMakeLists.txt index d573b0c6c..2d69b000b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,9 +68,6 @@ if(NOT LIBMGBA_ONLY) set(BUILD_QT ON CACHE BOOL "Build Qt frontend") set(BUILD_SDL ON CACHE BOOL "Build SDL frontend") set(BUILD_LIBRETRO OFF CACHE BOOL "Build libretro core") - if(APPLE) - set(BUILD_OPENEMU OFF CACHE BOOL "Build OpenEmu core") - endif() set(BUILD_PERF OFF CACHE BOOL "Build performance profiling tool") set(BUILD_TEST OFF CACHE BOOL "Build testing harness") set(BUILD_SUITE OFF CACHE BOOL "Build test suite") @@ -80,7 +77,7 @@ if(NOT LIBMGBA_ONLY) set(BUILD_PYTHON OFF CACHE BOOL "Build Python bindings") set(BUILD_STATIC OFF CACHE BOOL "Build a static library") set(BUILD_SHARED ON CACHE BOOL "Build a shared library") - set(SKIP_LIBRARY OFF CACHE BOOL "Skip building the library (useful for only building libretro or OpenEmu cores)") + set(SKIP_LIBRARY OFF CACHE BOOL "Skip building the library (useful for only building libretro core)") set(BUILD_GL ON CACHE BOOL "Build with OpenGL") set(BUILD_GLES2 ON CACHE BOOL "Build with OpenGL|ES 2") set(BUILD_GLES3 ON CACHE BOOL "Build with OpenGL|ES 3") @@ -144,11 +141,6 @@ if (BUILD_LIBRETRO) mark_as_advanced(LIBRETRO_LIBDIR) endif() -if (BUILD_OPENEMU) - set(OE_LIBDIR "${LIBDIR}" CACHE PATH "Installed library directory (OpenEmu)") - mark_as_advanced(OE_LIBDIR) -endif() - if (DISTBUILD) set(EXTRA_LICENSES "" CACHE FILEPATH "Extra licenses to include in distribution packaages") mark_as_advanced(EXTRA_LICENSES) @@ -1001,22 +993,6 @@ if(BUILD_LIBRETRO) endif() endif() -if(BUILD_OPENEMU) - find_library(FOUNDATION Foundation) - find_library(OPENEMUBASE OpenEmuBase) - file(GLOB OE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/openemu/*.m) - add_library(${BINARY_NAME}-openemu MODULE ${CORE_SRC} ${OS_SRC}) - set_target_properties(${BINARY_NAME}-openemu PROPERTIES - 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) -endif() - if(BUILD_QT AND (WIN32 OR APPLE OR CMAKE_SYSTEM_NAME STREQUAL "Linux")) set(BUILD_UPDATER ON) endif() @@ -1345,9 +1321,6 @@ if(NOT QUIET AND NOT LIBMGBA_ONLY) message(STATUS " ROM tester: ${BUILD_ROM_TEST}") message(STATUS "Cores:") message(STATUS " Libretro core: ${BUILD_LIBRETRO}") - if(APPLE) - message(STATUS " OpenEmu core: ${BUILD_OPENEMU}") - endif() message(STATUS "Libraries:") message(STATUS " Static: ${BUILD_STATIC}") message(STATUS " Shared: ${BUILD_SHARED}") diff --git a/src/platform/openemu/Info.plist.in b/src/platform/openemu/Info.plist.in deleted file mode 100644 index b4ecfa95e..000000000 --- a/src/platform/openemu/Info.plist.in +++ /dev/null @@ -1,52 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ${PROJECT_NAME} - CFBundleIconFile - mGBA - CFBundleIdentifier - com.endrift.mgba - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - BNDL - CFBundleSignature - ???? - CFBundleVersion - ${VERSION_STRING} - NSPrincipalClass - OEGameCoreController - OEGameCoreClass - mGBAGameCore - OEGameCoreOptions - - openemu.system.gba - - OEGameCoreRewindBufferSeconds - 60 - OEGameCoreRewindInterval - 0 - OEGameCoreSupportsRewinding - - OEGameCoreSupportsCheatCode - - - - OEGameCorePlayerCount - 1 - OEProjectURL - https://mgba.io/ - OESystemIdentifiers - - openemu.system.gba - - SUEnableAutomaticChecks - 1 - SUFeedURL - https://raw.github.com/OpenEmu/OpenEmu-Update/master/mgba_appcast.xml - - diff --git a/src/platform/openemu/OEGBASystemResponderClient.h b/src/platform/openemu/OEGBASystemResponderClient.h deleted file mode 100644 index 4fc0179d1..000000000 --- a/src/platform/openemu/OEGBASystemResponderClient.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (c) 2011, OpenEmu Team - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the OpenEmu Team nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY OpenEmu Team ''AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL OpenEmu Team BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import - -@protocol OESystemResponderClient; - -typedef enum _OEGBAButton -{ - OEGBAButtonUp, - OEGBAButtonDown, - OEGBAButtonLeft, - OEGBAButtonRight, - OEGBAButtonA, - OEGBAButtonB, - OEGBAButtonL, - OEGBAButtonR, - OEGBAButtonStart, - OEGBAButtonSelect, - OEGBAButtonCount -} OEGBAButton; - -@protocol OEGBASystemResponderClient - -- (oneway void)didPushGBAButton:(OEGBAButton)button forPlayer:(NSUInteger)player; -- (oneway void)didReleaseGBAButton:(OEGBAButton)button forPlayer:(NSUInteger)player; - -@end diff --git a/src/platform/openemu/mGBAGameCore.h b/src/platform/openemu/mGBAGameCore.h deleted file mode 100644 index 744fdecfe..000000000 --- a/src/platform/openemu/mGBAGameCore.h +++ /dev/null @@ -1,6 +0,0 @@ -#import -#import - -OE_EXPORTED_CLASS -@interface mGBAGameCore : OEGameCore -@end diff --git a/src/platform/openemu/mGBAGameCore.m b/src/platform/openemu/mGBAGameCore.m deleted file mode 100644 index 7656a8945..000000000 --- a/src/platform/openemu/mGBAGameCore.m +++ /dev/null @@ -1,298 +0,0 @@ -/* - Copyright (c) 2016, Jeffrey Pfau - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS'' - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#import "mGBAGameCore.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#import -#import "OEGBASystemResponderClient.h" -#import - -#define SAMPLES 1024 - -@interface mGBAGameCore () -{ - struct mCore* core; - void* outputBuffer; - NSMutableDictionary *cheatSets; -} -@end - -@implementation mGBAGameCore - -- (id)init -{ - if ((self = [super init])) - { - core = GBACoreCreate(); - mCoreInitConfig(core, nil); - - struct mCoreOptions opts = { - .useBios = true, - }; - mCoreConfigLoadDefaults(&core->config, &opts); - core->init(core); - outputBuffer = nil; - - unsigned width, height; - core->baseVideoSize(core, &width, &height); - outputBuffer = malloc(width * height * BYTES_PER_PIXEL); - core->setVideoBuffer(core, outputBuffer, width); - core->setAudioBufferSize(core, SAMPLES); - cheatSets = [[NSMutableDictionary alloc] init]; - } - - return self; -} - -- (void)dealloc -{ - mCoreConfigDeinit(&core->config); - core->deinit(core); - free(outputBuffer); -} - -#pragma mark - Execution - -- (BOOL)loadFileAtPath:(NSString *)path error:(NSError **)error -{ - NSString *batterySavesDirectory = [self batterySavesDirectoryPath]; - [[NSFileManager defaultManager] createDirectoryAtURL:[NSURL fileURLWithPath:batterySavesDirectory] - withIntermediateDirectories:YES - attributes:nil - error:nil]; - if (core->dirs.save) { - core->dirs.save->close(core->dirs.save); - } - core->dirs.save = VDirOpen([batterySavesDirectory fileSystemRepresentation]); - - if (!mCoreLoadFile(core, [path fileSystemRepresentation])) { - *error = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadROMError userInfo:nil]; - return NO; - } - mCoreAutoloadSave(core); - - core->reset(core); - - return YES; -} - -- (void)executeFrame -{ - core->runFrame(core); - - int16_t samples[SAMPLES * 2]; - size_t available = 0; - available = blip_samples_avail(core->getAudioChannel(core, 0)); - blip_read_samples(core->getAudioChannel(core, 0), samples, available, true); - blip_read_samples(core->getAudioChannel(core, 1), samples + 1, available, true); - [[self ringBufferAtIndex:0] write:samples maxLength:available * 4]; -} - -- (void)resetEmulation -{ - core->reset(core); -} - -- (void)setupEmulation -{ - blip_set_rates(core->getAudioChannel(core, 0), core->frequency(core), 32768); - blip_set_rates(core->getAudioChannel(core, 1), core->frequency(core), 32768); -} - -#pragma mark - Video - -- (OEIntSize)aspectSize -{ - return OEIntSizeMake(3, 2); -} - -- (OEIntRect)screenRect -{ - unsigned width, height; - core->currentVideoSize(core, &width, &height); - return OEIntRectMake(0, 0, width, height); -} - -- (OEIntSize)bufferSize -{ - unsigned width, height; - core->baseVideoSize(core, &width, &height); - return OEIntSizeMake(width, height); -} - -- (const void *)getVideoBufferWithHint:(void *)hint -{ - OEIntSize bufferSize = [self bufferSize]; - - if (!hint) { - hint = outputBuffer; - } - - outputBuffer = hint; - core->setVideoBuffer(core, hint, bufferSize.width); - - return hint; -} - -- (GLenum)pixelFormat -{ - return GL_RGBA; -} - -- (GLenum)pixelType -{ - return GL_UNSIGNED_INT_8_8_8_8_REV; -} - -- (NSTimeInterval)frameInterval -{ - return core->frequency(core) / (double) core->frameCycles(core); -} - -#pragma mark - Audio - -- (NSUInteger)channelCount -{ - return 2; -} - -- (double)audioSampleRate -{ - return 32768; -} - -#pragma mark - Save State - -- (NSData *)serializeStateWithError:(NSError **)outError -{ - struct VFile* vf = VFileMemChunk(nil, 0); - if (!mCoreSaveStateNamed(core, vf, SAVESTATE_SAVEDATA)) { - *outError = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadStateError userInfo:nil]; - vf->close(vf); - return nil; - } - size_t size = vf->size(vf); - void* data = vf->map(vf, size, MAP_READ); - NSData *nsdata = [NSData dataWithBytes:data length:size]; - vf->unmap(vf, data, size); - vf->close(vf); - return nsdata; -} - -- (BOOL)deserializeState:(NSData *)state withError:(NSError **)outError -{ - struct VFile* vf = VFileFromConstMemory(state.bytes, state.length); - if (!mCoreLoadStateNamed(core, vf, SAVESTATE_SAVEDATA)) { - *outError = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadStateError userInfo:nil]; - vf->close(vf); - return NO; - } - vf->close(vf); - return YES; -} - -- (void)saveStateToFileAtPath:(NSString *)fileName completionHandler:(void (^)(BOOL, NSError *))block -{ - 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 fileSystemRepresentation], O_RDONLY); - block(mCoreLoadStateNamed(core, vf, 0), nil); - vf->close(vf); -} - -#pragma mark - Input - -const int GBAMap[] = { - GBA_KEY_UP, - GBA_KEY_DOWN, - GBA_KEY_LEFT, - GBA_KEY_RIGHT, - GBA_KEY_A, - GBA_KEY_B, - GBA_KEY_L, - GBA_KEY_R, - GBA_KEY_START, - GBA_KEY_SELECT -}; - -- (oneway void)didPushGBAButton:(OEGBAButton)button forPlayer:(NSUInteger)player -{ - UNUSED(player); - core->addKeys(core, 1 << GBAMap[button]); -} - -- (oneway void)didReleaseGBAButton:(OEGBAButton)button forPlayer:(NSUInteger)player -{ - UNUSED(player); - core->clearKeys(core, 1 << GBAMap[button]); -} - -#pragma mark - Cheats - -- (void)setCheat:(NSString *)code setType:(NSString *)type setEnabled:(BOOL)enabled -{ - code = [code stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - code = [code stringByReplacingOccurrencesOfString:@" " withString:@""]; - - NSString *codeId = [code stringByAppendingFormat:@"/%@", type]; - struct mCheatSet* cheatSet = [[cheatSets objectForKey:codeId] pointerValue]; - if (cheatSet) { - cheatSet->enabled = enabled; - 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; - NSArray *codeSet = [code componentsSeparatedByString:@"+"]; - for (id c in codeSet) { - mCheatAddLine(cheatSet, [c UTF8String], codeType); - } - cheatSet->enabled = enabled; - [cheatSets setObject:[NSValue valueWithPointer:cheatSet] forKey:codeId]; - mCheatAddSet(cheats, cheatSet); -} -@end -