From 0f729c662f9851c03c2d2b283873b91fbb8d43e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20A=2E=20A=CC=81lvarez?= Date: Sat, 28 May 2016 13:01:13 +0200 Subject: [PATCH] put emulator in loadable bundle --- Mini vMac.xcodeproj/project.pbxproj | 279 +++++++++++++++---- Mini vMac/AppDelegate.h | 21 +- Mini vMac/AppDelegate.m | 135 +++------ Mini vMac/Emulator.h | 16 ++ Mini vMac/Emulator.m | 154 ++++++++++ Mini vMac/EmulatorProtocol.h | 42 +++ Mini vMac/InsertDiskViewController.m | 20 +- Mini vMac/MNVMApplication.m | 14 +- Mini vMac/MYOSGLUE.m | 21 +- Mini vMac/{mnvm_cfg => MacPlus4M}/CNFGGLOB.h | 0 Mini vMac/{mnvm_cfg => MacPlus4M}/CNFGRAPI.h | 0 Mini vMac/{mnvm_cfg => MacPlus4M}/EMCONFIG.h | 0 Mini vMac/MacPlus4M/Info.plist | 28 ++ Mini vMac/ScreenView.h | 1 - Mini vMac/ScreenView.m | 11 +- Mini vMac/SettingsViewController.m | 9 +- Mini vMac/TouchScreen.m | 16 +- Mini vMac/TrackPad.m | 10 +- Mini vMac/UIImage+DiskImageIcon.m | 2 +- Mini vMac/ViewController.m | 4 +- Mini vMac/about.plist | 8 +- 21 files changed, 558 insertions(+), 233 deletions(-) create mode 100644 Mini vMac/Emulator.h create mode 100644 Mini vMac/Emulator.m create mode 100644 Mini vMac/EmulatorProtocol.h rename Mini vMac/{mnvm_cfg => MacPlus4M}/CNFGGLOB.h (100%) rename Mini vMac/{mnvm_cfg => MacPlus4M}/CNFGRAPI.h (100%) rename Mini vMac/{mnvm_cfg => MacPlus4M}/EMCONFIG.h (100%) create mode 100644 Mini vMac/MacPlus4M/Info.plist diff --git a/Mini vMac.xcodeproj/project.pbxproj b/Mini vMac.xcodeproj/project.pbxproj index 988fa97..5b21866 100644 --- a/Mini vMac.xcodeproj/project.pbxproj +++ b/Mini vMac.xcodeproj/project.pbxproj @@ -7,6 +7,24 @@ objects = { /* Begin PBXBuildFile section */ + 283422D21CF8EF8C0088B634 /* MacPlus4M.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 283422CA1CF8EF8C0088B634 /* MacPlus4M.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 283422D81CF8F16C0088B634 /* GLOBGLUE.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E931CD4C3B200FE25A8 /* GLOBGLUE.c */; }; + 283422D91CF8F16C0088B634 /* IWMEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E961CD4C3B200FE25A8 /* IWMEMDEV.c */; }; + 283422DA1CF8F16C0088B634 /* KBRDEMDV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E981CD4C3B200FE25A8 /* KBRDEMDV.c */; }; + 283422DB1CF8F16C0088B634 /* M68KITAB.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E9A1CD4C3B200FE25A8 /* M68KITAB.c */; }; + 283422DC1CF8F16C0088B634 /* MINEM68K.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E9C1CD4C3B200FE25A8 /* MINEM68K.c */; }; + 283422DD1CF8F16C0088B634 /* MOUSEMDV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E9E1CD4C3B200FE25A8 /* MOUSEMDV.c */; }; + 283422DE1CF8F16C0088B634 /* PROGMAIN.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EA11CD4C3B200FE25A8 /* PROGMAIN.c */; }; + 283422DF1CF8F16C0088B634 /* ROMEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EA31CD4C3B200FE25A8 /* ROMEMDEV.c */; }; + 283422E01CF8F16C0088B634 /* RTCEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EA51CD4C3B200FE25A8 /* RTCEMDEV.c */; }; + 283422E11CF8F16C0088B634 /* SCCEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EA71CD4C3B200FE25A8 /* SCCEMDEV.c */; }; + 283422E21CF8F16C0088B634 /* SCRNEMDV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EA91CD4C3B200FE25A8 /* SCRNEMDV.c */; }; + 283422E31CF8F16C0088B634 /* SCSIEMDV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EAC1CD4C3B200FE25A8 /* SCSIEMDV.c */; }; + 283422E41CF8F16C0088B634 /* SNDEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EAE1CD4C3B200FE25A8 /* SNDEMDEV.c */; }; + 283422E51CF8F16C0088B634 /* SONYEMDV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EB01CD4C3B200FE25A8 /* SONYEMDV.c */; }; + 283422E61CF8F16C0088B634 /* VIAEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EB31CD4C3B200FE25A8 /* VIAEMDEV.c */; }; + 283422EE1CF8F2210088B634 /* MYOSGLUE.m in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8ECB1CD4CDC500FE25A8 /* MYOSGLUE.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + 283422F41CF8F55E0088B634 /* Emulator.m in Sources */ = {isa = PBXBuildFile; fileRef = 283422F21CF8F5400088B634 /* Emulator.m */; }; 28848B621CDE97D600B86C45 /* InsertDiskViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28848B611CDE97D600B86C45 /* InsertDiskViewController.m */; }; 28848B651CDE97E900B86C45 /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28848B641CDE97E900B86C45 /* SettingsViewController.m */; }; 28BA897E1CE7315400A98104 /* KBKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 28BA89751CE7315400A98104 /* KBKey.m */; }; @@ -15,22 +33,6 @@ 28BA89821CE7336500A98104 /* Keyboard Layouts in Resources */ = {isa = PBXBuildFile; fileRef = 28BA89811CE7336500A98104 /* Keyboard Layouts */; }; 28BA89851CE73E7200A98104 /* TrackPad.m in Sources */ = {isa = PBXBuildFile; fileRef = 28BA89841CE73E7200A98104 /* TrackPad.m */; }; 28BA89881CE73FBC00A98104 /* MNVMApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 28BA89871CE73FBC00A98104 /* MNVMApplication.m */; }; - 28CE8EB51CD4C3B200FE25A8 /* GLOBGLUE.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E931CD4C3B200FE25A8 /* GLOBGLUE.c */; }; - 28CE8EB61CD4C3B200FE25A8 /* IWMEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E961CD4C3B200FE25A8 /* IWMEMDEV.c */; }; - 28CE8EB71CD4C3B200FE25A8 /* KBRDEMDV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E981CD4C3B200FE25A8 /* KBRDEMDV.c */; }; - 28CE8EB81CD4C3B200FE25A8 /* M68KITAB.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E9A1CD4C3B200FE25A8 /* M68KITAB.c */; }; - 28CE8EB91CD4C3B200FE25A8 /* MINEM68K.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E9C1CD4C3B200FE25A8 /* MINEM68K.c */; }; - 28CE8EBA1CD4C3B200FE25A8 /* MOUSEMDV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8E9E1CD4C3B200FE25A8 /* MOUSEMDV.c */; }; - 28CE8EBB1CD4C3B200FE25A8 /* PROGMAIN.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EA11CD4C3B200FE25A8 /* PROGMAIN.c */; }; - 28CE8EBC1CD4C3B200FE25A8 /* ROMEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EA31CD4C3B200FE25A8 /* ROMEMDEV.c */; }; - 28CE8EBD1CD4C3B200FE25A8 /* RTCEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EA51CD4C3B200FE25A8 /* RTCEMDEV.c */; }; - 28CE8EBE1CD4C3B200FE25A8 /* SCCEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EA71CD4C3B200FE25A8 /* SCCEMDEV.c */; }; - 28CE8EBF1CD4C3B200FE25A8 /* SCRNEMDV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EA91CD4C3B200FE25A8 /* SCRNEMDV.c */; }; - 28CE8EC01CD4C3B200FE25A8 /* SCSIEMDV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EAC1CD4C3B200FE25A8 /* SCSIEMDV.c */; }; - 28CE8EC11CD4C3B200FE25A8 /* SNDEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EAE1CD4C3B200FE25A8 /* SNDEMDEV.c */; }; - 28CE8EC21CD4C3B200FE25A8 /* SONYEMDV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EB01CD4C3B200FE25A8 /* SONYEMDV.c */; }; - 28CE8EC31CD4C3B200FE25A8 /* VIAEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8EB31CD4C3B200FE25A8 /* VIAEMDEV.c */; }; - 28CE8ECC1CD4CDC500FE25A8 /* MYOSGLUE.m in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8ECB1CD4CDC500FE25A8 /* MYOSGLUE.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 28CE8ED61CD4F56C00FE25A8 /* ScreenView.m in Sources */ = {isa = PBXBuildFile; fileRef = 28CE8ED51CD4F56C00FE25A8 /* ScreenView.m */; }; 28D5A3FD1CD6868F001A33F6 /* TouchScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D5A3FC1CD6868E001A33F6 /* TouchScreen.m */; }; 28F676C21CD15E0B00FC6FA6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 28F676C11CD15E0B00FC6FA6 /* main.m */; }; @@ -62,7 +64,28 @@ 28F6B4CF1CF77099002D76D0 /* compat.m in Sources */ = {isa = PBXBuildFile; fileRef = 28F6B4CE1CF77099002D76D0 /* compat.m */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 283422CF1CF8EF8C0088B634 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 28F676B51CD15E0B00FC6FA6 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 283422C91CF8EF8C0088B634; + remoteInfo = "minivmac-plus4m"; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXCopyFilesBuildPhase section */ + 283422D61CF8EF8C0088B634 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 283422D21CF8EF8C0088B634 /* MacPlus4M.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; 28F6B48C1CF07DDD002D76D0 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -94,6 +117,14 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 283422CA1CF8EF8C0088B634 /* MacPlus4M.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MacPlus4M.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 283422CE1CF8EF8C0088B634 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 283422D71CF8EFD80088B634 /* EmulatorProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EmulatorProtocol.h; sourceTree = ""; }; + 283422E71CF8F1C80088B634 /* CNFGGLOB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNFGGLOB.h; sourceTree = ""; }; + 283422E81CF8F1C80088B634 /* CNFGRAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNFGRAPI.h; sourceTree = ""; }; + 283422E91CF8F1C80088B634 /* EMCONFIG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EMCONFIG.h; sourceTree = ""; }; + 283422F11CF8F5400088B634 /* Emulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Emulator.h; sourceTree = ""; }; + 283422F21CF8F5400088B634 /* Emulator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Emulator.m; sourceTree = ""; }; 28848B601CDE97D600B86C45 /* InsertDiskViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InsertDiskViewController.h; sourceTree = ""; }; 28848B611CDE97D600B86C45 /* InsertDiskViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InsertDiskViewController.m; sourceTree = ""; }; 28848B631CDE97E900B86C45 /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = ""; }; @@ -109,9 +140,6 @@ 28BA89841CE73E7200A98104 /* TrackPad.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TrackPad.m; sourceTree = ""; }; 28BA89861CE73FBC00A98104 /* MNVMApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MNVMApplication.h; sourceTree = ""; }; 28BA89871CE73FBC00A98104 /* MNVMApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MNVMApplication.m; sourceTree = ""; }; - 28CE8E881CD4C33E00FE25A8 /* CNFGGLOB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNFGGLOB.h; sourceTree = ""; }; - 28CE8E891CD4C33E00FE25A8 /* CNFGRAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNFGRAPI.h; sourceTree = ""; }; - 28CE8E8A1CD4C33E00FE25A8 /* EMCONFIG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EMCONFIG.h; sourceTree = ""; }; 28CE8E8F1CD4C3B200FE25A8 /* COMOSGLU.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = COMOSGLU.h; sourceTree = ""; }; 28CE8E911CD4C3B200FE25A8 /* DATE2SEC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DATE2SEC.h; sourceTree = ""; }; 28CE8E921CD4C3B200FE25A8 /* ENDIANAC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ENDIANAC.h; sourceTree = ""; }; @@ -211,6 +239,13 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 283422C61CF8EF8C0088B634 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 28F676BA1CD15E0B00FC6FA6 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -245,6 +280,38 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 283422CB1CF8EF8C0088B634 /* MacPlus4M */ = { + isa = PBXGroup; + children = ( + 283422E71CF8F1C80088B634 /* CNFGGLOB.h */, + 283422E81CF8F1C80088B634 /* CNFGRAPI.h */, + 283422E91CF8F1C80088B634 /* EMCONFIG.h */, + 283422CE1CF8EF8C0088B634 /* Info.plist */, + ); + path = MacPlus4M; + sourceTree = ""; + }; + 283422EF1CF8F33A0088B634 /* Emulator Bundles */ = { + isa = PBXGroup; + children = ( + 283422F01CF8F3530088B634 /* Shared */, + 283422CB1CF8EF8C0088B634 /* MacPlus4M */, + ); + name = "Emulator Bundles"; + sourceTree = ""; + }; + 283422F01CF8F3530088B634 /* Shared */ = { + isa = PBXGroup; + children = ( + 283422D71CF8EFD80088B634 /* EmulatorProtocol.h */, + 283422F11CF8F5400088B634 /* Emulator.h */, + 283422F21CF8F5400088B634 /* Emulator.m */, + 28CE8ECB1CD4CDC500FE25A8 /* MYOSGLUE.m */, + 28CE8E8E1CD4C3B200FE25A8 /* mnvm_core */, + ); + name = Shared; + sourceTree = ""; + }; 28BA896E1CE7314500A98104 /* Keyboard */ = { isa = PBXGroup; children = ( @@ -259,16 +326,6 @@ name = Keyboard; sourceTree = ""; }; - 28CE8E871CD4C33E00FE25A8 /* mnvm_cfg */ = { - isa = PBXGroup; - children = ( - 28CE8E881CD4C33E00FE25A8 /* CNFGGLOB.h */, - 28CE8E891CD4C33E00FE25A8 /* CNFGRAPI.h */, - 28CE8E8A1CD4C33E00FE25A8 /* EMCONFIG.h */, - ); - path = mnvm_cfg; - sourceTree = ""; - }; 28CE8E8E1CD4C3B200FE25A8 /* mnvm_core */ = { isa = PBXGroup; children = ( @@ -329,6 +386,7 @@ 28F6B48E1CF07DDD002D76D0 /* liblibhfs.a */, 28F6B4A81CF07EC9002D76D0 /* liblibmfs.a */, 28F6B4B61CF07F32002D76D0 /* liblibres.a */, + 283422CA1CF8EF8C0088B634 /* MacPlus4M.framework */, ); name = Products; sourceTree = ""; @@ -340,7 +398,6 @@ 28F676C41CD15E0B00FC6FA6 /* AppDelegate.m */, 28BA89861CE73FBC00A98104 /* MNVMApplication.h */, 28BA89871CE73FBC00A98104 /* MNVMApplication.m */, - 28CE8ECB1CD4CDC500FE25A8 /* MYOSGLUE.m */, 28CE8ED41CD4F56C00FE25A8 /* ScreenView.h */, 28CE8ED51CD4F56C00FE25A8 /* ScreenView.m */, 28D5A3FB1CD6868E001A33F6 /* TouchScreen.h */, @@ -358,13 +415,12 @@ 28BA896E1CE7314500A98104 /* Keyboard */, 28F676CE1CD15E0B00FC6FA6 /* LaunchScreen.storyboard */, 28F676D11CD15E0B00FC6FA6 /* Info.plist */, - 28CE8E8E1CD4C3B200FE25A8 /* mnvm_core */, - 28CE8E871CD4C33E00FE25A8 /* mnvm_cfg */, 28F676C01CD15E0B00FC6FA6 /* Supporting Files */, 28F6B4501CF07C48002D76D0 /* UIImage+DiskImageIcon.h */, 28F6B4511CF07C48002D76D0 /* UIImage+DiskImageIcon.m */, 28F6B4C91CF1FA7A002D76D0 /* about.plist */, 28F6B4CE1CF77099002D76D0 /* compat.m */, + 283422EF1CF8F33A0088B634 /* Emulator Bundles */, ); path = "Mini vMac"; sourceTree = ""; @@ -450,7 +506,35 @@ }; /* End PBXGroup section */ +/* Begin PBXHeadersBuildPhase section */ + 283422C71CF8EF8C0088B634 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + /* Begin PBXNativeTarget section */ + 283422C91CF8EF8C0088B634 /* MacPlus4M */ = { + isa = PBXNativeTarget; + buildConfigurationList = 283422D31CF8EF8C0088B634 /* Build configuration list for PBXNativeTarget "MacPlus4M" */; + buildPhases = ( + 283422C51CF8EF8C0088B634 /* Sources */, + 283422C61CF8EF8C0088B634 /* Frameworks */, + 283422C71CF8EF8C0088B634 /* Headers */, + 283422C81CF8EF8C0088B634 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = MacPlus4M; + productName = "minivmac-plus4m"; + productReference = 283422CA1CF8EF8C0088B634 /* MacPlus4M.framework */; + productType = "com.apple.product-type.framework"; + }; 28F676BC1CD15E0B00FC6FA6 /* Mini vMac */ = { isa = PBXNativeTarget; buildConfigurationList = 28F676D41CD15E0B00FC6FA6 /* Build configuration list for PBXNativeTarget "Mini vMac" */; @@ -459,10 +543,13 @@ 28F676BA1CD15E0B00FC6FA6 /* Frameworks */, 28F676BB1CD15E0B00FC6FA6 /* Resources */, 28F6B4CD1CF76D88002D76D0 /* ShellScript */, + 283422D61CF8EF8C0088B634 /* Embed Frameworks */, + 283422F51CF9ACAD0088B634 /* Change PlugIn extensions to mnvm */, ); buildRules = ( ); dependencies = ( + 283422D01CF8EF8C0088B634 /* PBXTargetDependency */, ); name = "Mini vMac"; productName = "Mini vMac"; @@ -529,6 +616,10 @@ LastUpgradeCheck = 0730; ORGANIZATIONNAME = namedfork; TargetAttributes = { + 283422C91CF8EF8C0088B634 = { + CreatedOnToolsVersion = 7.3.1; + DevelopmentTeam = UJXNDZ5TNU; + }; 28F676BC1CD15E0B00FC6FA6 = { CreatedOnToolsVersion = 7.3; DevelopmentTeam = UJXNDZ5TNU; @@ -561,11 +652,19 @@ 28F6B48D1CF07DDD002D76D0 /* libhfs */, 28F6B4A71CF07EC9002D76D0 /* libmfs */, 28F6B4B51CF07F32002D76D0 /* libres */, + 283422C91CF8EF8C0088B634 /* MacPlus4M */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 283422C81CF8EF8C0088B634 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; 28F676BB1CD15E0B00FC6FA6 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -581,6 +680,20 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 283422F51CF9ACAD0088B634 /* Change PlugIn extensions to mnvm */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Change PlugIn extensions to mnvm"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "cd \"$BUILT_PRODUCTS_DIR/$PLUGINS_FOLDER_PATH\"\nfor name in *.framework\ndo\n mv \"$name\" \"${name%.framework}.mnvm\"\ndone\n"; + }; 28F6B4CD1CF76D88002D76D0 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -597,39 +710,47 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 283422C51CF8EF8C0088B634 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 283422F41CF8F55E0088B634 /* Emulator.m in Sources */, + 283422D81CF8F16C0088B634 /* GLOBGLUE.c in Sources */, + 283422E11CF8F16C0088B634 /* SCCEMDEV.c in Sources */, + 283422E01CF8F16C0088B634 /* RTCEMDEV.c in Sources */, + 283422DB1CF8F16C0088B634 /* M68KITAB.c in Sources */, + 283422DF1CF8F16C0088B634 /* ROMEMDEV.c in Sources */, + 283422DE1CF8F16C0088B634 /* PROGMAIN.c in Sources */, + 283422D91CF8F16C0088B634 /* IWMEMDEV.c in Sources */, + 283422E21CF8F16C0088B634 /* SCRNEMDV.c in Sources */, + 283422E61CF8F16C0088B634 /* VIAEMDEV.c in Sources */, + 283422DD1CF8F16C0088B634 /* MOUSEMDV.c in Sources */, + 283422EE1CF8F2210088B634 /* MYOSGLUE.m in Sources */, + 283422E31CF8F16C0088B634 /* SCSIEMDV.c in Sources */, + 283422E51CF8F16C0088B634 /* SONYEMDV.c in Sources */, + 283422DA1CF8F16C0088B634 /* KBRDEMDV.c in Sources */, + 283422E41CF8F16C0088B634 /* SNDEMDEV.c in Sources */, + 283422DC1CF8F16C0088B634 /* MINEM68K.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 28F676B91CD15E0B00FC6FA6 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 28BA897E1CE7315400A98104 /* KBKey.m in Sources */, - 28CE8EC01CD4C3B200FE25A8 /* SCSIEMDV.c in Sources */, - 28CE8EC11CD4C3B200FE25A8 /* SNDEMDEV.c in Sources */, - 28CE8EB51CD4C3B200FE25A8 /* GLOBGLUE.c in Sources */, - 28CE8EBF1CD4C3B200FE25A8 /* SCRNEMDV.c in Sources */, 28BA89851CE73E7200A98104 /* TrackPad.m in Sources */, - 28CE8EBD1CD4C3B200FE25A8 /* RTCEMDEV.c in Sources */, - 28CE8EB61CD4C3B200FE25A8 /* IWMEMDEV.c in Sources */, 28CE8ED61CD4F56C00FE25A8 /* ScreenView.m in Sources */, - 28CE8EB91CD4C3B200FE25A8 /* MINEM68K.c in Sources */, - 28CE8EBA1CD4C3B200FE25A8 /* MOUSEMDV.c in Sources */, - 28CE8EC31CD4C3B200FE25A8 /* VIAEMDEV.c in Sources */, - 28CE8EB81CD4C3B200FE25A8 /* M68KITAB.c in Sources */, 28848B651CDE97E900B86C45 /* SettingsViewController.m in Sources */, 28BA89881CE73FBC00A98104 /* MNVMApplication.m in Sources */, 28F6B4CF1CF77099002D76D0 /* compat.m in Sources */, 28F6B4521CF07C48002D76D0 /* UIImage+DiskImageIcon.m in Sources */, - 28CE8EB71CD4C3B200FE25A8 /* KBRDEMDV.c in Sources */, - 28CE8EBC1CD4C3B200FE25A8 /* ROMEMDEV.c in Sources */, 28BA897F1CE7315400A98104 /* KBKeyboardLayout.m in Sources */, - 28CE8EBB1CD4C3B200FE25A8 /* PROGMAIN.c in Sources */, 28848B621CDE97D600B86C45 /* InsertDiskViewController.m in Sources */, 28F676C81CD15E0B00FC6FA6 /* ViewController.m in Sources */, 28D5A3FD1CD6868F001A33F6 /* TouchScreen.m in Sources */, - 28CE8EC21CD4C3B200FE25A8 /* SONYEMDV.c in Sources */, 28F676C51CD15E0B00FC6FA6 /* AppDelegate.m in Sources */, 28BA89801CE7315400A98104 /* KBKeyboardView.m in Sources */, - 28CE8EBE1CD4C3B200FE25A8 /* SCCEMDEV.c in Sources */, - 28CE8ECC1CD4CDC500FE25A8 /* MYOSGLUE.m in Sources */, 28F676C21CD15E0B00FC6FA6 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -672,6 +793,14 @@ }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 283422D01CF8EF8C0088B634 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 283422C91CF8EF8C0088B634 /* MacPlus4M */; + targetProxy = 283422CF1CF8EF8C0088B634 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ 28F676C91CD15E0B00FC6FA6 /* Main.storyboard */ = { isa = PBXVariantGroup; @@ -692,6 +821,52 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + 283422D41CF8EF8C0088B634 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = NO; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = "$(SRCROOT)/Mini vMac/MacPlus4M/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = net.namedfork.minivmac.macplus4m; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 283422D51CF8EF8C0088B634 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = NO; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = "$(SRCROOT)/Mini vMac/MacPlus4M/Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; + LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = net.namedfork.minivmac.macplus4m; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; 28F676D21CD15E0B00FC6FA6 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -877,6 +1052,14 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 283422D31CF8EF8C0088B634 /* Build configuration list for PBXNativeTarget "MacPlus4M" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 283422D41CF8EF8C0088B634 /* Debug */, + 283422D51CF8EF8C0088B634 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; 28F676B81CD15E0B00FC6FA6 /* Build configuration list for PBXProject "Mini vMac" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Mini vMac/AppDelegate.h b/Mini vMac/AppDelegate.h index 77b5eb2..2057905 100644 --- a/Mini vMac/AppDelegate.h +++ b/Mini vMac/AppDelegate.h @@ -7,35 +7,22 @@ // #import - -extern NSString * const MNVMDidInsertDiskNotification; -extern NSString * const MNVMDidEjectDiskNotification; +#import "EmulatorProtocol.h" @interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; -@property (assign, nonatomic, getter=isEmulatorRunning) BOOL emulatorRunning; @property (nonatomic, readonly) NSString *documentsPath; @property (nonatomic, readonly) NSArray *diskImageExtensions; +@property (nonatomic, readonly) NSArray *availableEmulators; @property (readonly, nonatomic, getter = isSandboxed) BOOL sandboxed; + (instancetype)sharedInstance; ++ (id)sharedEmulator; + - (void)showAlertWithTitle:(NSString *)title message:(NSString *)message; - (IBAction)showInsertDisk:(id)sender; - (IBAction)showSettings:(id)sender; -- (void)setMouseX:(NSInteger)x Y:(NSInteger)y; -- (void)moveMouseX:(NSInteger)x Y:(NSInteger)y; -- (void)setMouseButton:(BOOL)down; - -- (void)keyDown:(int)scancode; -- (void)keyUp:(int)scancode; - -- (BOOL)insertDisk:(NSString*)path; -- (BOOL)isDiskInserted:(NSString*)path; - -- (void)macInterrupt; -- (void)macReset; - @end diff --git a/Mini vMac/AppDelegate.m b/Mini vMac/AppDelegate.m index 9cddbd3..34a84bf 100644 --- a/Mini vMac/AppDelegate.m +++ b/Mini vMac/AppDelegate.m @@ -9,27 +9,9 @@ #import "AppDelegate.h" #import "SettingsViewController.h" #import "InsertDiskViewController.h" -#include "CNFGRAPI.h" -#include "SYSDEPNS.h" -#include "MYOSGLUE.h" - -IMPORTPROC RunEmulator(void); -IMPORTFUNC blnr GetSpeedStopped(void); -IMPORTPROC SetSpeedStopped(blnr stopped); -IMPORTPROC SetMouseButton(blnr down); -IMPORTPROC SetMouseLoc(ui4r h, ui4r v); -IMPORTPROC SetMouseDelta(ui4r dh, ui4r dv); -IMPORTFUNC blnr Sony_Insert1(NSString *filePath, blnr silentfail); -IMPORTFUNC blnr Sony_IsInserted(NSString *filePath); -IMPORTFUNC blnr AnyDiskInserted(void); -EXPORTVAR(ui3b,SpeedValue); -IMPORTPROC SetKeyState(int key, blnr down); -IMPORTPROC MacInterrupt(); -IMPORTPROC MacReset(); static AppDelegate *sharedAppDelegate = nil; -NSString * const MNVMDidInsertDiskNotification = @"MNVMDidInsertDisk"; -NSString * const MNVMDidEjectDiskNotification = @"MNVMDidEjectDisk"; +static NSObject *sharedEmulator = nil; @interface AppDelegate () @@ -44,10 +26,18 @@ NSString * const MNVMDidEjectDiskNotification = @"MNVMDidEjectDisk"; return sharedAppDelegate; } ++ (id)sharedEmulator { + return sharedEmulator; +} + - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { sharedAppDelegate = self; [self initDefaults]; - [self performSelector:@selector(runEmulator) withObject:nil afterDelay:0.1]; + if (![self loadEmulator:[[NSUserDefaults standardUserDefaults] stringForKey:@"machine"]]) { + [self loadEmulator:@"MacPlus4M"]; + } + [sharedEmulator performSelector:@selector(run) withObject:nil afterDelay:0.1]; + return YES; } @@ -59,32 +49,54 @@ NSString * const MNVMDidEjectDiskNotification = @"MNVMDidEjectDisk"; NSString *firstLanguage = [NSBundle preferredLocalizationsFromArray:layoutForLanguage.allKeys].firstObject; NSDictionary *defaultValues = @{@"trackpad": @([UIDevice currentDevice].userInterfaceIdiom != UIUserInterfaceIdiomPad), @"frameskip": @(0), - @"keyboardLayout": layoutForLanguage[firstLanguage] + @"keyboardLayout": layoutForLanguage[firstLanguage], + @"machine": @"MacPlus4M" }; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults registerDefaults:defaultValues]; - [defaults setValue:@(WantInitSpeedValue) forKey:@"speedValue"]; + [defaults setValue:@(sharedEmulator.initialSpeed) forKey:@"speedValue"]; [defaults addObserver:self forKeyPath:@"speedValue" options:0 context:NULL]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (object == [NSUserDefaults standardUserDefaults]) { if ([keyPath isEqualToString:@"speedValue"]) { - SpeedValue = [[NSUserDefaults standardUserDefaults] integerForKey:@"speedValue"]; + sharedEmulator.speed = [[NSUserDefaults standardUserDefaults] integerForKey:@"speedValue"]; } } } +- (NSArray*)availableEmulators { + NSString *pluginsPath = [NSBundle mainBundle].builtInPlugInsPath; + NSArray *names = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pluginsPath error:NULL]; + NSMutableArray *emulatorBundles = [NSMutableArray arrayWithCapacity:names.count]; + for (NSString *name in [names pathsMatchingExtensions:@[@"mnvm"]]) { + NSBundle *bundle = [NSBundle bundleWithPath:[pluginsPath stringByAppendingPathComponent:name]]; + [emulatorBundles addObject:bundle]; + } + return emulatorBundles; +} + +- (BOOL)loadEmulator:(NSString*)name { + NSString *emulatorBundleName = [name stringByAppendingPathExtension:@"mnvm"]; + NSString *emulatorBundlePath = [[NSBundle mainBundle].builtInPlugInsPath stringByAppendingPathComponent:emulatorBundleName]; + NSBundle *emulatorBundle = [NSBundle bundleWithPath:emulatorBundlePath]; + [emulatorBundle load]; + sharedEmulator = [[emulatorBundle principalClass] new]; + sharedEmulator.dataPath = self.documentsPath; + return sharedEmulator != nil; +} + - (void)applicationDidEnterBackground:(UIApplication *)application { - self.emulatorRunning = NO; - if (AnyDiskInserted() == falseblnr) { + sharedEmulator.running = NO; + if (sharedEmulator.anyDiskInserted == NO) { exit(0); } } - (void)applicationWillEnterForeground:(UIApplication *)application { - self.emulatorRunning = YES; + sharedEmulator.running = YES; } - (void)showAlertWithTitle:(NSString *)title message:(NSString *)message { @@ -259,75 +271,4 @@ NSString * const MNVMDidEjectDiskNotification = @"MNVMDidEjectDisk"; return YES; } -#pragma mark - Emulation - -- (void)runEmulator { - SpeedValue = [[NSUserDefaults standardUserDefaults] integerForKey:@"speedValue"]; - if (SpeedValue > 3) { - SpeedValue = 3; - } - RunEmulator(); -} - -- (BOOL)isEmulatorRunning { - return !GetSpeedStopped(); -} - -- (void)setEmulatorRunning:(BOOL)emulatorRunning { - SetSpeedStopped(emulatorRunning); -} - -#pragma mark - Mouse - -- (void)setMouseX:(NSInteger)x Y:(NSInteger)y { - SetMouseLoc(x, y); -} - -- (void)moveMouseX:(NSInteger)x Y:(NSInteger)y { - SetMouseDelta(x, y); -} - -- (void)setMouseButton:(BOOL)down { - SetMouseButton(down); -} - -- (void)macInterrupt { - MacInterrupt(); -} - --(void)macReset { - MacReset(); -} - -#pragma mark - Keyboard - -- (int)translateScanCode:(int)scancode { - switch (scancode) { - case 54: return 59; // left control - case 59: return 70; // arrow left - case 60: return 66; // arrow right - case 61: return 72; // arrow down - case 62: return 77; // arrow up - default: return scancode; - } -} - -- (void)keyDown:(int)scancode { - SetKeyState([self translateScanCode:scancode], true); -} - -- (void)keyUp:(int)scancode { - SetKeyState([self translateScanCode:scancode], false); -} - -#pragma mark - Disk Drive - -- (BOOL)insertDisk:(NSString *)path { - return Sony_Insert1(path.stringByStandardizingPath, falseblnr); -} - -- (BOOL)isDiskInserted:(NSString *)path { - return Sony_IsInserted(path.stringByStandardizingPath); -} - @end diff --git a/Mini vMac/Emulator.h b/Mini vMac/Emulator.h new file mode 100644 index 0000000..a4805a4 --- /dev/null +++ b/Mini vMac/Emulator.h @@ -0,0 +1,16 @@ +// +// Emulator.h +// Mini vMac +// +// Created by Jesús A. Álvarez on 27/05/2016. +// Copyright © 2016 namedfork. All rights reserved. +// + +#import +#import "EmulatorProtocol.h" + +@interface Emulator : NSObject + +- (void)updateScreen:(CGImageRef)screenImage; + +@end diff --git a/Mini vMac/Emulator.m b/Mini vMac/Emulator.m new file mode 100644 index 0000000..b2f54dc --- /dev/null +++ b/Mini vMac/Emulator.m @@ -0,0 +1,154 @@ +// +// Emulator.m +// Mini vMac +// +// Created by Jesús A. Álvarez on 27/05/2016. +// Copyright © 2016 namedfork. All rights reserved. +// + +#import "Emulator.h" +#include "CNFGRAPI.h" +#include "SYSDEPNS.h" +#include "ENDIANAC.h" +#include "MYOSGLUE.h" + +IMPORTPROC RunEmulator(void); +IMPORTFUNC blnr GetSpeedStopped(void); +IMPORTPROC SetSpeedStopped(blnr stopped); +IMPORTPROC SetMouseButton(blnr down); +IMPORTPROC SetMouseLoc(ui4r h, ui4r v); +IMPORTPROC SetMouseDelta(ui4r dh, ui4r dv); +IMPORTFUNC blnr Sony_Insert1(NSString *filePath, blnr silentfail); +IMPORTFUNC blnr Sony_IsInserted(NSString *filePath); +IMPORTPROC SetKeyState(int key, blnr down); + +static Emulator *sharedEmulator = nil; +static dispatch_once_t onceToken; + +@implementation Emulator + +@synthesize dataPath; + ++ (instancetype)sharedEmulator { + dispatch_once(&onceToken, ^{ + sharedEmulator = [self new]; + }); + return sharedEmulator; +} + +- (instancetype)init { + if ((self = [super init])) { + dispatch_once(&onceToken, ^{ + sharedEmulator = self; + }); + } + return self; +} +- (void)run { + SpeedValue = [[NSUserDefaults standardUserDefaults] integerForKey:@"speedValue"]; + if (SpeedValue > 3) { + SpeedValue = 3; + } + RunEmulator(); +} + +- (NSInteger)initialSpeed { + return WantInitSpeedValue; +} + +- (NSInteger)speed { + return SpeedValue; +} + +- (void)setSpeed:(NSInteger)speed { + SpeedValue = speed; +} + +- (BOOL)isRunning { + return !GetSpeedStopped(); +} + +- (void)setRunning:(BOOL)running { + SetSpeedStopped(running ? falseblnr : trueblnr); +} + +- (void)interrupt { + WantMacInterrupt = trueblnr; +} + +- (void)reset { + WantMacReset = trueblnr; +} + +#pragma mark - Screen + +@synthesize screenLayer; + +- (CGSize)screenSize { + return CGSizeMake(vMacScreenWidth, vMacScreenHeight); +} + +- (void)updateScreen:(CGImageRef)screenImage { + screenLayer.contents = (__bridge id)screenImage; +} + +#pragma mark - Disk + +@synthesize insertDiskNotification, ejectDiskNotification; + +- (BOOL)anyDiskInserted { + return AnyDiskInserted(); +} + +- (BOOL)isDiskInserted:(NSString *)path { + return Sony_IsInserted(path); +} + +- (BOOL)insertDisk:(NSString *)path { + return Sony_Insert1(path, false); +} + +- (NSString *)insertDiskNotification { + return @"didInsertDisk"; +} + +- (NSString *)ejectDiskNotification { + return @"didEjectDisk"; +} + +#pragma mark - Keyboard + +- (int)translateScanCode:(int)scancode { + switch (scancode) { + case 54: return 59; // left control + case 59: return 70; // arrow left + case 60: return 66; // arrow right + case 61: return 72; // arrow down + case 62: return 77; // arrow up + default: return scancode; + } +} + +- (void)keyDown:(int)scancode { + SetKeyState([self translateScanCode:scancode], true); +} + +- (void)keyUp:(int)scancode { + SetKeyState([self translateScanCode:scancode], false); +} + +#pragma mark - Mouse + +- (void)setMouseX:(NSInteger)x Y:(NSInteger)y { + SetMouseLoc(x, y); +} + +- (void)moveMouseX:(NSInteger)x Y:(NSInteger)y { + SetMouseDelta(x, y); +} + +- (void)setMouseButton:(BOOL)down { + SetMouseButton(down); +} + +@end diff --git a/Mini vMac/EmulatorProtocol.h b/Mini vMac/EmulatorProtocol.h new file mode 100644 index 0000000..eb73a8d --- /dev/null +++ b/Mini vMac/EmulatorProtocol.h @@ -0,0 +1,42 @@ +// +// EmulatorProtocol.h +// Mini vMac +// +// Created by Jesús A. Álvarez on 27/05/2016. +// Copyright © 2016 namedfork. All rights reserved. +// + +@import Foundation; +@import CoreGraphics; +@import QuartzCore; + +@protocol Emulator + +@property (nonatomic, strong) NSString *dataPath; +@property (nonatomic, assign, getter=isRunning) BOOL running; +@property (nonatomic, assign) NSInteger speed; +@property (nonatomic, weak) CALayer *screenLayer; + +@property (nonatomic, readonly) CGSize screenSize; +@property (nonatomic, readonly) NSString *insertDiskNotification, *ejectDiskNotification; +@property (nonatomic, readonly) NSInteger initialSpeed; + +@property (nonatomic, readonly) BOOL anyDiskInserted; + ++ (instancetype)sharedEmulator; + +- (void)run; +- (void)reset; +- (void)interrupt; + +- (void)keyDown:(int)scancode; +- (void)keyUp:(int)scancode; + +- (void)setMouseX:(NSInteger)x Y:(NSInteger)y; +- (void)moveMouseX:(NSInteger)x Y:(NSInteger)y; +- (void)setMouseButton:(BOOL)down; + +- (BOOL)insertDisk:(NSString*)path; +- (BOOL)isDiskInserted:(NSString*)path; + +@end diff --git a/Mini vMac/InsertDiskViewController.m b/Mini vMac/InsertDiskViewController.m index 498cdc2..91a6dca 100644 --- a/Mini vMac/InsertDiskViewController.m +++ b/Mini vMac/InsertDiskViewController.m @@ -49,15 +49,15 @@ - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(reloadData:) name:MNVMDidInsertDiskNotification object:nil]; - [nc addObserver:self selector:@selector(reloadData:) name:MNVMDidEjectDiskNotification object:nil]; + [nc addObserver:self selector:@selector(reloadData:) name:[AppDelegate sharedEmulator].insertDiskNotification object:nil]; + [nc addObserver:self selector:@selector(reloadData:) name:[AppDelegate sharedEmulator].ejectDiskNotification object:nil]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - [nc removeObserver:self name:MNVMDidInsertDiskNotification object:nil]; - [nc removeObserver:self name:MNVMDidEjectDiskNotification object:nil]; + [nc removeObserver:self name:[AppDelegate sharedEmulator].insertDiskNotification object:nil]; + [nc removeObserver:self name:[AppDelegate sharedEmulator].ejectDiskNotification object:nil]; } - (void)loadDirectoryContents { @@ -89,11 +89,11 @@ - (void)macInterrupt:(id)sender { [self dismiss:sender]; - [[AppDelegate sharedInstance] macInterrupt]; + [[AppDelegate sharedEmulator] interrupt]; } - (void)macReset:(id)sender { - [[AppDelegate sharedInstance] macReset]; + [[AppDelegate sharedEmulator] reset]; } #pragma mark - Table view data source @@ -158,7 +158,7 @@ NSString *filePath = [self fileAtIndexPath:indexPath]; if (filePath) { cell.filePath = filePath; - if ([[AppDelegate sharedInstance] isDiskInserted:filePath]) { + if ([[AppDelegate sharedEmulator] isDiskInserted:filePath]) { cell.userInteractionEnabled = NO; cell.textLabel.enabled = NO; cell.imageView.alpha = 0.5; @@ -179,7 +179,7 @@ return UITableViewCellEditingStyleInsert; } NSString *filePath = [self fileAtIndexPath:indexPath]; - BOOL isInserted = [[AppDelegate sharedInstance] isDiskInserted:filePath]; + BOOL isInserted = [[AppDelegate sharedEmulator] isDiskInserted:filePath]; return isInserted ? UITableViewCellEditingStyleNone : UITableViewCellEditingStyleDelete; } else { return UITableViewCellEditingStyleDelete; @@ -213,9 +213,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *filePath = [self fileAtIndexPath:indexPath]; - if (filePath && ![[AppDelegate sharedInstance] isDiskInserted:filePath]) { + if (filePath && ![[AppDelegate sharedEmulator] isDiskInserted:filePath]) { [self dismissViewControllerAnimated:YES completion:^{ - [[AppDelegate sharedInstance] insertDisk:filePath]; + [[AppDelegate sharedEmulator] insertDisk:filePath]; }]; } } diff --git a/Mini vMac/MNVMApplication.m b/Mini vMac/MNVMApplication.m index d7954f7..ec58736 100644 --- a/Mini vMac/MNVMApplication.m +++ b/Mini vMac/MNVMApplication.m @@ -65,18 +65,18 @@ static int8_t usb_to_adb_scancode[] = { if (scancode == 57) { // caps lock if (event._isKeyDown && !physicalCapsLocked) { - [[AppDelegate sharedInstance] keyDown:scancode]; + [[AppDelegate sharedEmulator] keyDown:scancode]; physicalCapsLocked = YES; } else if (event._isKeyDown && physicalCapsLocked) { - [[AppDelegate sharedInstance] keyUp:scancode]; + [[AppDelegate sharedEmulator] keyUp:scancode]; physicalCapsLocked = NO; } - } else if (scancode >= 0 && [AppDelegate sharedInstance].emulatorRunning) { + } else if (scancode >= 0 && [AppDelegate sharedEmulator].running) { if (event._isKeyDown) { [self _updateCapsLockStatus:event]; - [[AppDelegate sharedInstance] keyDown:scancode]; + [[AppDelegate sharedEmulator] keyDown:scancode]; } else { - [[AppDelegate sharedInstance] keyUp:scancode]; + [[AppDelegate sharedEmulator] keyUp:scancode]; } } } @@ -90,9 +90,9 @@ static int8_t usb_to_adb_scancode[] = { if (currentCapsLock != physicalCapsLocked) { physicalCapsLocked = currentCapsLock; if (physicalCapsLocked) { - [[AppDelegate sharedInstance] keyDown:57]; + [[AppDelegate sharedEmulator] keyDown:57]; } else { - [[AppDelegate sharedInstance] keyUp:57]; + [[AppDelegate sharedEmulator] keyUp:57]; } } } diff --git a/Mini vMac/MYOSGLUE.m b/Mini vMac/MYOSGLUE.m index 7a319d9..bbe625f 100644 --- a/Mini vMac/MYOSGLUE.m +++ b/Mini vMac/MYOSGLUE.m @@ -32,8 +32,7 @@ #include "ENDIANAC.h" #include "MYOSGLUE.h" #include "STRCONST.h" -#import "ScreenView.h" -#import "AppDelegate.h" +#import "Emulator.h" #pragma mark - some simple utilities @@ -145,7 +144,7 @@ LOCALPROC Screen_UnInit(void) { LOCALVAR NSString *MyDataPath = nil; LOCALFUNC blnr InitCocoaStuff(void) { - MyDataPath = [AppDelegate sharedInstance].documentsPath; + MyDataPath = [Emulator sharedEmulator].dataPath; if (MyDataPath) { [MyDataPath retain]; } @@ -464,7 +463,7 @@ LOCALFUNC tMacErr vSonyEject0(tDrive Drive_No, blnr deleteit) { NSDictionary *userInfo = @{@"path": DriveNames[Drive_No], @"drive": @(Drive_No), @"delete": @(deleteit)}; - [[NSNotificationCenter defaultCenter] postNotificationName:MNVMDidEjectDiskNotification object:[AppDelegate sharedInstance] userInfo:userInfo]; + [[NSNotificationCenter defaultCenter] postNotificationName:[Emulator sharedEmulator].ejectDiskNotification object:[Emulator sharedEmulator] userInfo:userInfo]; DiskEjectedNotify(Drive_No); #if HaveAdvisoryLocks @@ -540,8 +539,8 @@ LOCALFUNC blnr Sony_Insert0(FILE *refnum, blnr locked, NSString *filePath) { } else { NSDictionary *userInfo = @{@"path": filePath, @"drive": @(Drive_No)}; - [[NSNotificationCenter defaultCenter] postNotificationName:MNVMDidInsertDiskNotification object:[AppDelegate sharedInstance] userInfo:userInfo]; - + [[NSNotificationCenter defaultCenter] postNotificationName:[Emulator sharedEmulator].insertDiskNotification object:[Emulator sharedEmulator] userInfo:userInfo]; + /* printf("Sony_Insert0 %d\n", (int)Drive_No); */ #if HaveAdvisoryLocks @@ -859,7 +858,7 @@ LOCALPROC HaveChangedScreenBuff(ui4r top, ui4r left, ui4r bottom, ui4r right) { CGBitmapInfo options = 0; CGImageRef screenImage = CGImageCreate(vMacScreenWidth, vMacScreenHeight, bitsPerComponent, bitsPerPixel, vMacScreenByteWidth, screenColorSpace, options, screenDataProvider, NULL, false, kCGRenderingIntentDefault); - [[ScreenView sharedScreenView] updateScreen:screenImage]; + [[Emulator sharedEmulator] updateScreen:screenImage]; CGImageRelease(screenImage); } @@ -1703,11 +1702,3 @@ GLOBALPROC RunEmulator(void) { } UnInitOSGLU(); } - -GLOBALPROC MacInterrupt(void) { - WantMacInterrupt = trueblnr; -} - -GLOBALPROC MacReset(void) { - WantMacReset = trueblnr; -} \ No newline at end of file diff --git a/Mini vMac/mnvm_cfg/CNFGGLOB.h b/Mini vMac/MacPlus4M/CNFGGLOB.h similarity index 100% rename from Mini vMac/mnvm_cfg/CNFGGLOB.h rename to Mini vMac/MacPlus4M/CNFGGLOB.h diff --git a/Mini vMac/mnvm_cfg/CNFGRAPI.h b/Mini vMac/MacPlus4M/CNFGRAPI.h similarity index 100% rename from Mini vMac/mnvm_cfg/CNFGRAPI.h rename to Mini vMac/MacPlus4M/CNFGRAPI.h diff --git a/Mini vMac/mnvm_cfg/EMCONFIG.h b/Mini vMac/MacPlus4M/EMCONFIG.h similarity index 100% rename from Mini vMac/mnvm_cfg/EMCONFIG.h rename to Mini vMac/MacPlus4M/EMCONFIG.h diff --git a/Mini vMac/MacPlus4M/Info.plist b/Mini vMac/MacPlus4M/Info.plist new file mode 100644 index 0000000..beb84b3 --- /dev/null +++ b/Mini vMac/MacPlus4M/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDisplayName + Mac Plus 4M + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + MnvM + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + Emulator + + diff --git a/Mini vMac/ScreenView.h b/Mini vMac/ScreenView.h index a09d458..33c22ce 100644 --- a/Mini vMac/ScreenView.h +++ b/Mini vMac/ScreenView.h @@ -14,6 +14,5 @@ @property (nonatomic, readonly) CGSize screenSize; + (instancetype)sharedScreenView; -- (void)updateScreen:(CGImageRef)screenImage; @end diff --git a/Mini vMac/ScreenView.m b/Mini vMac/ScreenView.m index 937fd26..2989ec1 100644 --- a/Mini vMac/ScreenView.m +++ b/Mini vMac/ScreenView.m @@ -7,7 +7,7 @@ // #import "ScreenView.h" -#import "CNFGGLOB.h" +#import "AppDelegate.h" static ScreenView *sharedScreenView = nil; @@ -23,7 +23,8 @@ static ScreenView *sharedScreenView = nil; [super awakeFromNib]; sharedScreenView = self; videoLayer = [CALayer layer]; - screenSize = CGSizeMake(vMacScreenWidth, vMacScreenHeight); + [AppDelegate sharedEmulator].screenLayer = videoLayer; + screenSize = [AppDelegate sharedEmulator].screenSize; [self.layer addSublayer:videoLayer]; } @@ -39,12 +40,6 @@ static ScreenView *sharedScreenView = nil; return screenSize; } -- (void)updateScreen:(CGImageRef)newScreenImage { - CGImageRelease(screenImage); - screenImage = CGImageRetain(newScreenImage); - videoLayer.contents = (__bridge id)screenImage; -} - - (void)layoutSubviews { [super layoutSubviews]; CGRect viewBounds = self.bounds; diff --git a/Mini vMac/SettingsViewController.m b/Mini vMac/SettingsViewController.m index cbe7624..f57310f 100644 --- a/Mini vMac/SettingsViewController.m +++ b/Mini vMac/SettingsViewController.m @@ -8,7 +8,6 @@ #import "SettingsViewController.h" #import "AppDelegate.h" -#import "CNFGRAPI.h" @interface SettingsViewController () @@ -49,12 +48,12 @@ - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - [AppDelegate sharedInstance].emulatorRunning = NO; + [AppDelegate sharedEmulator].running = NO; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; - [AppDelegate sharedInstance].emulatorRunning = YES; + [AppDelegate sharedEmulator].running = YES; } - (void)showInsertDisk:(id)sender { @@ -146,10 +145,6 @@ NSString *versionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; NSString *commitString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"GitVersion"]; cell.detailTextLabel.text = commitString.length > 0 ? [NSString stringWithFormat:@"%@ (%@)", versionString, commitString] : versionString; - } else if ([detailText isEqualToString:@"kAppVariationStr"]) { - cell.detailTextLabel.text = @(kAppVariationStr); - } else if ([detailText isEqualToString:@"kMaintainerName"]) { - cell.detailTextLabel.text = @(kMaintainerName); } else { cell.detailTextLabel.text = detailText; } diff --git a/Mini vMac/TouchScreen.m b/Mini vMac/TouchScreen.m index 3eb2382..d5d11fc 100644 --- a/Mini vMac/TouchScreen.m +++ b/Mini vMac/TouchScreen.m @@ -41,11 +41,11 @@ } - (void)mouseDown { - [[AppDelegate sharedInstance] setMouseButton:YES]; + [[AppDelegate sharedEmulator] setMouseButton:YES]; } - (void)mouseUp { - [[AppDelegate sharedInstance] setMouseButton:NO]; + [[AppDelegate sharedEmulator] setMouseButton:NO]; } - (CGPoint)effectiveTouchPointForEvent:(UIEvent *)event { @@ -61,29 +61,29 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [currentTouches unionSet:touches]; - if (![AppDelegate sharedInstance].emulatorRunning) return; + if (![AppDelegate sharedEmulator].running) return; CGPoint touchLoc = [self effectiveTouchPointForEvent:event]; Point mouseLoc = [self mouseLocForCGPoint:touchLoc]; - [[AppDelegate sharedInstance] setMouseX:mouseLoc.h Y:mouseLoc.v]; + [[AppDelegate sharedEmulator] setMouseX:mouseLoc.h Y:mouseLoc.v]; [self performSelector:@selector(mouseDown) withObject:nil afterDelay:mouseButtonDelay]; previousTouchLoc = touchLoc; previousTouchTime = event.timestamp; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - if (![AppDelegate sharedInstance].emulatorRunning) return; + if (![AppDelegate sharedEmulator].running) return; CGPoint touchLoc = [self effectiveTouchPointForEvent:event]; Point mouseLoc = [self mouseLocForCGPoint:touchLoc]; - [[AppDelegate sharedInstance] setMouseX:mouseLoc.h Y:mouseLoc.v]; + [[AppDelegate sharedEmulator] setMouseX:mouseLoc.h Y:mouseLoc.v]; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [currentTouches minusSet:touches]; - if (![AppDelegate sharedInstance].emulatorRunning) return; + if (![AppDelegate sharedEmulator].running) return; if (currentTouches.count > 0) return; CGPoint touchLoc = [self effectiveTouchPointForEvent:event]; Point mouseLoc = [self mouseLocForCGPoint:touchLoc]; - [[AppDelegate sharedInstance] setMouseX:mouseLoc.h Y:mouseLoc.v]; + [[AppDelegate sharedEmulator] setMouseX:mouseLoc.h Y:mouseLoc.v]; [self performSelector:@selector(mouseUp) withObject:nil afterDelay:mouseButtonDelay]; previousTouchLoc = touchLoc; previousTouchTime = event.timestamp; diff --git a/Mini vMac/TrackPad.m b/Mini vMac/TrackPad.m index 3f9013a..f5c373b 100644 --- a/Mini vMac/TrackPad.m +++ b/Mini vMac/TrackPad.m @@ -39,7 +39,7 @@ fabs(previousTouchLoc.x - touchLoc.x) < touchDistanceThreshold && fabs(previousTouchLoc.y - touchLoc.y) < touchDistanceThreshold) { drag = YES; - [[AppDelegate sharedInstance] setMouseButton:YES]; + [[AppDelegate sharedEmulator] setMouseButton:YES]; } previousTouchTime = event.timestamp; previousTouchLoc = touchLoc; @@ -56,7 +56,7 @@ locDiff.x *= accel; locDiff.y *= accel; click = NO; - [[AppDelegate sharedInstance] moveMouseX:locDiff.x Y:locDiff.y]; + [[AppDelegate sharedEmulator] moveMouseX:locDiff.x Y:locDiff.y]; previousTouchTime = event.timestamp; previousTouchLoc = touchLoc; } @@ -70,7 +70,7 @@ } click = NO; if (drag) { - [[AppDelegate sharedInstance] setMouseButton:NO]; + [[AppDelegate sharedEmulator] setMouseButton:NO]; drag = NO; } @@ -82,12 +82,12 @@ if (drag) { return; } - [[AppDelegate sharedInstance] setMouseButton:YES]; + [[AppDelegate sharedEmulator] setMouseButton:YES]; [self performSelector:@selector(mouseUp) withObject:nil afterDelay:2.0/60.0]; } - (void)mouseUp { - [[AppDelegate sharedInstance] setMouseButton:NO]; + [[AppDelegate sharedEmulator] setMouseButton:NO]; } @end diff --git a/Mini vMac/UIImage+DiskImageIcon.m b/Mini vMac/UIImage+DiskImageIcon.m index 2f3795d..26f5d93 100644 --- a/Mini vMac/UIImage+DiskImageIcon.m +++ b/Mini vMac/UIImage+DiskImageIcon.m @@ -32,7 +32,7 @@ static NSCache *diskImageIconCache = nil; dispatch_once(&onceToken, ^{ diskImageIconCache = [NSCache new]; diskImageIconCache.name = @"net.namedfork.minivmac.icon-cache"; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didEjectDisk:) name:MNVMDidEjectDiskNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didEjectDisk:) name:[AppDelegate sharedEmulator].ejectDiskNotification object:nil]; }); return diskImageIconCache; } diff --git a/Mini vMac/ViewController.m b/Mini vMac/ViewController.m index fd4aac7..7ccfb52 100644 --- a/Mini vMac/ViewController.m +++ b/Mini vMac/ViewController.m @@ -192,11 +192,11 @@ } - (void)keyDown:(int)scancode { - [[AppDelegate sharedInstance] keyDown:scancode]; + [[AppDelegate sharedEmulator] keyDown:scancode]; } - (void)keyUp:(int)scancode { - [[AppDelegate sharedInstance] keyUp:scancode]; + [[AppDelegate sharedEmulator] keyUp:scancode]; } @end diff --git a/Mini vMac/about.plist b/Mini vMac/about.plist index 6aeba6a..b9018c2 100644 --- a/Mini vMac/about.plist +++ b/Mini vMac/about.plist @@ -12,17 +12,11 @@ detailText $version - - text - Core - detailText - kAppVariationStr - text Maintainer detailText - kMaintainerName + Jesús A. Álvarez link https://twitter.com/maczydeco