Manic EMU is an all-in-one retro game emulator for iOS. It packs powerful features while keeping a clean, sleek UI and delivering buttery-smooth gameplay.
Swift
Fixed the Citra core destruction exception; fixed the J2ME/JGenesis cross-domain issue.
Daiuno3836ee4efef7
diff --git a/.gitignore b/.gitignoreindex 5a392703..fcf80a64 100644--- a/.gitignore+++ b/.gitignore@@ -96,6 +96,7 @@ Dependencies/*i18n/Scripts/System.core.verManicEmu/ManicEmu/Resources/System.core+AppStoreConnect#claude code.claudediff --git a/Cores/Citra.framework/Citra b/Cores/Citra.framework/Citraindex 86add6ff..544ad651 100755--- a/Cores/Citra.framework/Citra+++ b/Cores/Citra.framework/Citra@@ -1,3 +1,3 @@version https://git-lfs.github.com/spec/v1-oid sha256:0e224f5ce28841178ddd36534652084fec95f57853ef5f33d1a54f0f705e40e8-size 23305584+oid sha256:ca788a729c706155233678572d14b48b0e24462eddba4a1e054d5c4fc3cb47ed+size 24326624diff --git a/ManicEmu/ManicEmu/Resources/Config-Base.xcconfig b/ManicEmu/ManicEmu/Resources/Config-Base.xcconfigindex 72dc61d4..28ced99e 100644--- a/ManicEmu/ManicEmu/Resources/Config-Base.xcconfig+++ b/ManicEmu/ManicEmu/Resources/Config-Base.xcconfig@@ -11,7 +11,7 @@// https://help.apple.com/xcode/#/dev745c5c974APP_BUNDLE_IDENTIFIER = com.aoshuang.manicemu-APP_BUILD_VERSION = 7+APP_BUILD_VERSION = 8APP_VERSION = 2.0.0// Prebuilt cores under ProjectManicEMU/Cores (Citra.framework, *.libretro.framework, …)diff --git a/ManicEmu/ManicEmu/Resources/Info.plist b/ManicEmu/ManicEmu/Resources/Info.plistindex 95c3a0d7..c106365e 100644--- a/ManicEmu/ManicEmu/Resources/Info.plist+++ b/ManicEmu/ManicEmu/Resources/Info.plist@@ -1681,6 +1681,7 @@<dict><key>public.filename-extension</key><array>+ <string>zip</string><string>sav</string><string>dsv</string><string>srm</string>diff --git a/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.stringsindex 9367c8ef..7a6bf190 100644--- a/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.strings+++ b/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.strings@@ -1056,3 +1056,4 @@ Press the controller button to complete mapping...";"AchievementsMultiSetsGuide" = "This only switches which achievement list is shown. Changing the selected set does not affect earning achievements from any set while you play.";"GoToSettings" = "Go to Settings";+"SymbianSaveTips" = "Symbian apps don't share a common save format. Please use the Files app to open: Manic EMU - EKA2L1 to manage your save files on your own.";diff --git a/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.stringsindex aa5f192f..c50f7ee1 100644--- a/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.strings+++ b/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.strings@@ -1050,3 +1050,5 @@"AchievementsNoSubset" = "该游戏暂无额外成就集。你可以在 retroachievements.org 为本游戏启用子集。\n\n已启用 Multiset 的游戏会在集合选择控件旁显示「Subset Configuration」按钮,用于启用或禁用该游戏的任意成就集。";"AchievementsMultiSetsGuide" = "此处仅用于切换成就列表的显示。切换成就集不会影响游戏运行中对所有成就集的收集。";"GoToSettings" = "去设置";++"SymbianSaveTips" = "Symbian 应用没有统一的存档规范。请使用“文件”App 打开:Manic EMU - EKA2L1,自行管理存档文件。";diff --git a/ManicEmu/ManicEmu/Sources/Base/ExternalSceneDelegate.swift b/ManicEmu/ManicEmu/Sources/Base/ExternalSceneDelegate.swiftindex dca2edca..ee8d2b3a 100644--- a/ManicEmu/ManicEmu/Sources/Base/ExternalSceneDelegate.swift+++ b/ManicEmu/ManicEmu/Sources/Base/ExternalSceneDelegate.swift@@ -77,10 +77,9 @@ class ExternalSceneDelegate: UIResponder, UIWindowSceneDelegate {private func updateScene() {if PurchaseManager.isMember, Settings.defalut.airPlay, PlayViewController.isGaming, PlayViewController.enableAirplay {- //开启了airPlay的全屏模式window?.isHidden = false} else {- //没有开启 正常显示手机镜像即可+ // Mirror the phone insteadwindow?.isHidden = true}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Views/J2MEView.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Views/J2MEView.swiftindex e534a67f..377ae972 100644--- a/ManicEmu/ManicEmu/Sources/Business/Common/Views/J2MEView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Common/Views/J2MEView.swift@@ -478,9 +478,9 @@ class J2MEView: BaseView {self.screenSize = screenSizeself.rotation = rotation- // Register file to local server+ // Same host as the page (127.0.0.1). localhost is a different origin and may resolve to ::1.let fileId = localServer.registerFile(filePath: filePath)- let jarURL = "http://localhost:\(localServer.port)/file/\(fileId)"+ let jarURL = localServer.fileURL(for: fileId)let fileName = filePath.lastPathComponent// Build the JavaScript to load the JARdiff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Views/JGenesisView.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Views/JGenesisView.swiftindex 57e117a4..47a87f26 100644--- a/ManicEmu/ManicEmu/Sources/Business/Common/Views/JGenesisView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Common/Views/JGenesisView.swift@@ -177,9 +177,9 @@ extension JGenesisView {romPath = filePathlet fileName = filePath.lastPathComponent.escapeJSString()- // 注册文件到本地服务器+ // Register file to local server (127.0.0.1, same origin as the page)let fileId = localServer.registerFile(filePath: filePath)- let romURL = "http://localhost:8080/file/\(fileId)"+ let romURL = localServer.fileURL(for: fileId)let script = """(async () => {@@ -228,28 +228,28 @@ extension JGenesisView {romPath = filePathlet fileName = filePath.lastPathComponent.escapeJSString()- // 注册 ROM 文件到本地服务器+ // Register ROM to local server (127.0.0.1, same origin as the page)let romFileId = localServer.registerFile(filePath: filePath)- let romURL = "http://localhost:8080/file/\(romFileId)"+ let romURL = localServer.fileURL(for: romFileId)- // 注册 BIOS 文件(如果存在)+ // Register BIOS files if presentvar americasBiosURL: String? = nilvar japanBiosURL: String? = nilvar europeBiosURL: String? = nilif let path = americasBiosPath, FileManager.default.fileExists(atPath: path) {let fileId = localServer.registerFile(filePath: path)- americasBiosURL = "http://localhost:8080/file/\(fileId)"+ americasBiosURL = localServer.fileURL(for: fileId)}if let path = japanBiosPath, FileManager.default.fileExists(atPath: path) {let fileId = localServer.registerFile(filePath: path)- japanBiosURL = "http://localhost:8080/file/\(fileId)"+ japanBiosURL = localServer.fileURL(for: fileId)}if let path = europeBiosPath, FileManager.default.fileExists(atPath: path) {let fileId = localServer.registerFile(filePath: path)- europeBiosURL = "http://localhost:8080/file/\(fileId)"+ europeBiosURL = localServer.fileURL(for: fileId)}// 构建 JavaScript 代码中的 BIOS URL 参数diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SaveStateListView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SaveStateListView.swiftindex a2fa4212..f6b46a4e 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SaveStateListView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SaveStateListView.swift@@ -156,7 +156,7 @@ class SaveStateListView: BaseView {group.enter()let now = Date.nowlet state = GameSaveState()- state.name = "\(now.string(withFormat: R.Strings.FileNameTimeFormat))_" + self.game.fileName+ state.name = self.importedSaveStateName(url: url, timestamp: now)state.type = .manualSaveStatestate.date = nowself.game.getCoverImage(completion: { image in@@ -301,6 +301,24 @@ class SaveStateListView: BaseView {}}+ /// Citra load reads the slot from `name.deletingPathExtension.pathExtension`.+ /// Native files are `{titleId}.{slot:02d}.cst`; keep that stem so in-game load can copy into the slot.+ private func importedSaveStateName(url: URL, timestamp: Date) -> String {+ let timePrefix = timestamp.string(withFormat: R.Strings.FileNameTimeFormat)+ guard game.isCitra3DS else {+ return "\(timePrefix)_" + game.fileName+ }+ let imported = url.lastPathComponent+ let slot: UInt32+ if let parsed = UInt32(imported.deletingPathExtension.pathExtension), (1...50).contains(parsed) {+ slot = parsed+ } else {+ slot = 1+ }+ let titleId = String(format: "%016llX", game.identifierFor3DS)+ return "\(timePrefix)_\(titleId).\(String(format: "%02d", slot)).cst"+ }+private func getSaveStatesSection() -> ASListPage.Section {var cells = [ASListPage.Cell]()for (index, saveState) in currentGameSaveStates.enumerated() {diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionPerform.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionPerform.swiftindex 633e8b1d..71326a3d 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionPerform.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionPerform.swift@@ -62,6 +62,12 @@ extension GameOption {cancelTitle: R.string.localizable.gotIt())return}+ if firstGame.gameType == .symbian {+ UIView.makeAlert(title: R.string.localizable.focusShortcutsTips(),+ detail: R.string.localizable.symbianSaveTips(),+ cancelTitle: R.string.localizable.gotIt())+ return+ }FilesImporter.shared.presentImportController(supportedTypes: UTType.gamesaveTypes, allowsMultipleSelection: false) { urls inif var url = urls.first {if firstGame.gameType == ._3ds || firstGame.gameType == .psp {@@ -100,6 +106,12 @@ extension GameOption {cancelTitle: R.string.localizable.gotIt())return}+ if games.contains(where: { $0.gameType == .symbian }) {+ UIView.makeAlert(title: R.string.localizable.focusShortcutsTips(),+ detail: R.string.localizable.symbianSaveTips(),+ cancelTitle: R.string.localizable.gotIt())+ return+ }ShareManager.shareFiles(games: games, shareFileType: .save)case .delete:@@ -218,6 +230,7 @@ extension GameOption {let realm = Database.realmif realm.object(ofType: Game.self, forPrimaryKey: Game.DOSHomeMenuPrimaryKey) == nil {let game = Game()+ game.gameType = .dosgame.id = Game.DOSHomeMenuPrimaryKeygame.name = Game.DOSHomeMenuPrimaryKeytry? realm.write {@@ -776,7 +789,6 @@ extension GameOption {case .swapScreen:performSwitchAction(with: games, accessoryChange: accessoryChange)- hideSheetInGaming()case .resolution:if performImmediately {@@ -791,7 +803,6 @@ extension GameOption {case .amiibo:PlayViewController.amiibo()- hideSheetInGaming()case .hideControls:performSwitchAction(with: games, accessoryChange: accessoryChange)diff --git a/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swift b/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swiftindex 13afc021..dc2fc96f 100644--- a/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swift@@ -437,7 +437,7 @@ class Game: Object, ObjectUpdatable {} else if defaultCore == 1 {return .VBAM} else if defaultCore == 2 {- return .VBAM+ return .gpSP}} else if gameType == .dc {return .Flycastdiff --git a/ManicEmu/ManicEmu/Sources/Business/Play/Models/Skin.swift b/ManicEmu/ManicEmu/Sources/Business/Play/Models/Skin.swiftindex 42176142..baa793bb 100644--- a/ManicEmu/ManicEmu/Sources/Business/Play/Models/Skin.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Play/Models/Skin.swift@@ -88,9 +88,13 @@ class Skin: Object, ObjectUpdatable {}var isEditable: Bool {- if skinType == .default || identifier.hasSuffix(".keyboard") {+ if skinType == .default || isKeyboardSkin {return false}return true}++ var isKeyboardSkin: Bool {+ identifier.hasSuffix(".keyboard")+ }}diff --git a/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swiftindex e2502ef1..93f543dd 100644--- a/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift@@ -325,6 +325,7 @@ class PlayViewController: GameViewController {\Game.haptic,\Game.accurateShaders,\Game.renderRightEye,+ \Game.swapScreen,]) { [weak self] change inguard let self = self else { return }switch change {@@ -341,6 +342,9 @@ class PlayViewController: GameViewController {citraCore?.updateConfig(["ManicEMU.useShadersAccurateMul": self.manicGame.accurateShaders])} else if property.name == "renderRightEye" {citraCore?.updateConfig(["ManicEMU.disableRightEyeRender": self.manicGame.renderRightEye])+ } else if property.name == "swapScreen" {+ self.skinSwitchBindDatas["reverseScreens"] = self.manicGame.swapScreen+ self.updateSkin()}Log.debug("设置更新 Property '\(property.name)' changed from \(property.oldValue == nil ? "nil" : property.oldValue!) to '\(property.newValue!)'")}@@ -1088,9 +1092,13 @@ extension PlayViewController {if let state = state ?? manicGame.gameSaveStates.last {if manicGame.isCitra3DS {- if let citraCore,- let slot = UInt32(state.name.deletingPathExtension.pathExtension) {- //现将存档移到模拟器工作目录+ if let citraCore {+ let slotFromName = UInt32(state.name.deletingPathExtension.pathExtension)+ let slotFromFile = state.stateData.flatMap {+ UInt32($0.filePath.lastPathComponent.deletingPathExtension.pathExtension)+ }+ let slot = slotFromName ?? slotFromFile ?? 1+ // Copy into Citra's `{titleId}.{slot:02d}.cst` before the core loads that slot.if let fileUrl = state.stateData?.filePath {citraCore.addSaveState(fileUrl: fileUrl, slot: slot)}@@ -2294,8 +2302,11 @@ extension PlayViewController {}controllerView.controllerSkin = controllerSkincurrentSkinID = skin.id- } else {- controllerView.controllerSkin = ControllerSkin.standardControllerSkin(for: manicGame.gameType)+ } else if var controllerSkin = ControllerSkin.standardControllerSkin(for: manicGame.gameType) {+ if manicGame.supportSwapScreen {+ controllerSkin.isSwapScreen = manicGame.swapScreen+ }+ controllerView.controllerSkin = controllerSkin// Same dual-orientation skin may only be stored under the other orientation key.controllerView.updateControllerSkin()}@@ -2437,10 +2448,9 @@ extension PlayViewController {triggerProView?.hapticType = manicGame.haptic}- /// 更新AirPlay+ /// Move the game Metal view onto the AirPlay window, or back onto the phone.private func updateAirPlay() {if PurchaseManager.isMember, Settings.defalut.airPlay, ExternalSceneDelegate.isAirPlaying {- //执行全屏投屏if let airPlayViewController = ExternalSceneDelegate.airPlayViewController, let gameMetalView {gameMetalView.removeFromSuperview()var dimensions = emulatorCore?.deltaCore.videoFormat.dimensions ?? CGSize(width: 480, height: 360)@@ -2455,7 +2465,6 @@ extension PlayViewController {updateNDSCursor()}} else {- //不执行全屏投屏if let _ = ExternalSceneDelegate.airPlayViewController, let gameMetalView {gameMetalView.removeFromSuperview()view.insertSubview(gameMetalView, belowSubview: controllerView)@@ -2473,7 +2482,7 @@ extension PlayViewController {}if let controllerSkin = controllerView.controllerSkin {if let skin = Database.realm.objects(Skin.self).first(where: { $0.identifier == controllerSkin.identifier }) {- if skin.skinType == .default {+ if skin.skinType == .default || skin.isKeyboardSkin {//当前使用的是默认皮肤 则添加功能按钮let shortcuts = Prefference.defalut.getPrefference(kind: .gameShortcut,storeKey: .game(gameId: manicGame.id),diff --git a/ManicEmu/ManicEmu/Sources/Tools/Cores/ThreeDS.swift b/ManicEmu/ManicEmu/Sources/Tools/Cores/ThreeDS.swiftindex 65b80320..cfd2264f 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Cores/ThreeDS.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Cores/ThreeDS.swift@@ -345,8 +345,6 @@ class ThreeDSEmulatorBridge : EmulatorBridgeBase {}}--func destory() {citraCore.deallocateVulkanLibrary()citraCore.deallocateMetalLayers()@@ -603,7 +601,7 @@ class ThreeDSEmulatorBridge : EmulatorBridgeBase {"ManicEMU.audioStretching" : false,"ManicEMU.realtimeAudio": true,"ManicEMU.outputType" : 3,- "ManicEMU.inputType" : 3,+ "ManicEMU.inputType" : 4,"ManicEMU.webAPIURL" : "http://88.198.47.47:5000"] + buildLayoutConfig()}()@@ -638,8 +636,8 @@ class ThreeDSEmulatorBridge : EmulatorBridgeBase {"ManicEMU.audioEmulation" : 0, //"HLE" : 0, "LLE" : 1, "LLE (Multithreaded)" : 2"ManicEMU.audioStretching" : false,"ManicEMU.realtimeAudio": true,- "ManicEMU.outputType" : 3, //Auto = 0, Null = 1, Cubeb = 2, OpenAL = 3, SDL3 = 4,- "ManicEMU.inputType" : 3,//Auto = 0, Null = 1, Static = 2, Cubeb = 3, OpenAL = 4,+ "ManicEMU.outputType" : 3, // Auto = 0, Null = 1, Cubeb = 2, OpenAL = 3, SDL3 = 4+ "ManicEMU.inputType" : 4, // Auto = 0, Null = 1, Static = 2, Cubeb = 3, OpenAL = 4"ManicEMU.webAPIURL" : "http://88.198.47.47:5000"] + buildLayoutConfig()}()@@ -675,7 +673,7 @@ class ThreeDSEmulatorBridge : EmulatorBridgeBase {"ManicEMU.audioStretching" : false,"ManicEMU.realtimeAudio": true,"ManicEMU.outputType" : 3,- "ManicEMU.inputType" : 3,+ "ManicEMU.inputType" : 4,"ManicEMU.webAPIURL" : "http://88.198.47.47:5000"] + buildLayoutConfig()}()diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/FilesImporter.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/FilesImporter.swiftindex d78315dd..ff4a437c 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Others/FilesImporter.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/FilesImporter.swift@@ -1110,6 +1110,7 @@ extension FilesImporter {if isSaveExist {//询问是否覆盖DispatchQueue.main.async {+ UIView.hideLoading()UIView.makeAlert(title: R.string.localizable.gameSaveAlreadyExistTitle(),detail: R.string.localizable.filesImporterErrorSaveAlreadyExist(url.lastPathComponent),confirmTitle: R.string.localizable.confirmTitle(),@@ -1171,6 +1172,7 @@ extension FilesImporter {if isSaveExist {//询问是否覆盖DispatchQueue.main.async {+ UIView.hideLoading()UIView.makeAlert(title: R.string.localizable.gameSaveAlreadyExistTitle(),detail: R.string.localizable.filesImporterErrorSaveAlreadyExist(url.lastPathComponent),confirmTitle: R.string.localizable.confirmTitle(),diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/LocalWebServer.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/LocalWebServer.swiftindex 395833e2..6407fc45 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Others/LocalWebServer.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/LocalWebServer.swift@@ -176,8 +176,13 @@ class LocalWebServer {func getURL() -> URL? {return URL(string: "http://127.0.0.1:\(port)/index.html")}++ /// Same host as `getURL()` so WKWebView fetch stays same-origin (`localhost` ≠ `127.0.0.1`).+ func fileURL(for fileId: String) -> String {+ "http://127.0.0.1:\(port)/file/\(fileId)"+ }- /// 注册 ROM 文件,返回唯一文件 ID+ /// Registers a ROM file and returns a unique file ID.func registerFile(filePath: String) -> String {let fileId = "\(filePath.lastPathComponent.sha256())"files[fileId] = filePath