Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] fMSX fix build [WIP] #2372

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 92 additions & 21 deletions Cores/fmsx/PVfMSX.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cores/fmsx/PVfMSX/Core.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>PVCoreIdentifier</key>
<string>com.provenance.core.fMSX</string>
<key>PVPrincipleClass</key>
<string>PVfMSXCore</string>
<string>PVfMSX.PVfMSXEmuCore</string>
<key>PVSupportedSystems</key>
<array>
<string>com.provenance.msx</string>
Expand Down
2 changes: 1 addition & 1 deletion Cores/fmsx/PVfMSX/PVfMSX.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ FOUNDATION_EXPORT double PVfMSXVersionNumber;
FOUNDATION_EXPORT const unsigned char PVfMSXVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <PVfMSX/PublicHeader.h>
#import <PVfMSX/PVfMSXCore.h>
#import <PVfMSX/PVfMSXCoreBridge.h>
39 changes: 39 additions & 0 deletions Cores/fmsx/PVfMSXCore/CorePlist-Generated.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// swiftlint:disable all
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen

import Foundation

#if canImport(PVCoreBridge)
@_exported import PVCoreBridge
@_exported import PVPlists
#endif

// swiftlint:disable superfluous_disable_command
// swiftlint:disable file_length

// MARK: - Plist Files

// swiftlint:disable identifier_name line_length number_separator type_body_length
public enum CorePlist {
public static let pvCoreIdentifier: String = "com.provenance.core.fMSX"
public static let pvPrincipleClass: String = "PVfMSX.PVfMSXEmuCore"
public static let pvProjectName: String = "fMSX"
public static let pvProjectURL: String = "http://fms.komkon.org/fMSX/"
public static let pvProjectVersion: String = "0"
public static let pvSupportedSystems: [String] = ["com.provenance.msx", "com.provenance.msx2"]

#if canImport(PVCoreBridge)
public static var corePlist: EmulatorCoreInfoPlist {
.init(
identifier: CorePlist.pvCoreIdentifier,
principleClass: CorePlist.pvPrincipleClass,
supportedSystems: CorePlist.pvSupportedSystems,
projectName: CorePlist.pvProjectName,
projectURL: CorePlist.pvProjectURL,
projectVersion: CorePlist.pvProjectVersion)
}

public var corePlist: EmulatorCoreInfoPlist { Self.corePlist }
#endif
}
// swiftlint:enable identifier_name line_length number_separator type_body_length
71 changes: 71 additions & 0 deletions Cores/fmsx/PVfMSXCore/CorePlist.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// CorePlist.swift
//
//
// Created by Joseph Mattiello on 6/21/24.
//

import Foundation
import PVLogging
import PVCoreBridge
import PVEmulatorCore
import PVPlists

#if SWIFT_PACKAGE
public extension PVBundleFinder {
static var fMSXModule: Bundle { Bundle.module }
static var fMSXBundle: Bundle { Bundle(for: PVfMSXEmuCore.self) }
}
#else
public extension PVBundleFinder {
static var PVfMSXCoreBundle: Bundle { Bundle(for: PVfMSXEmuCore.self) }
}
#endif

@objc
extension PVfMSXEmuCore: EmulatorCoreInfoPlistProvider {

#if SWIFT_PACKAGE
@objc
public static var resourceBundle: Bundle { Bundle.module }

@objc
public override var resourceBundle: Bundle { Bundle.module }
#else
@objc
public static var resourceBundle: Bundle { PVBundleFinder.PVfMSXCoreBundle }

@objc
public override var resourceBundle: Bundle { PVBundleFinder.PVfMSXCoreBundle }

#endif
@objc(corePlistFromBundle)
public static var corePlistFromBundle: EmulatorCoreInfoPlist {

guard let plistPath = resourceBundle.url(forResource: "Core", withExtension: "plist") else {
fatalError("Could not locate Core.plist")
}

guard let data = try? Data(contentsOf: plistPath) else {
fatalError("Could not read Core.plist")
}

guard let plistObject = try? PropertyListSerialization.propertyList(from: data, options: [], format: nil) as? [String: Any] else {
fatalError("Could not generate parse Core.plist")
}

guard let corePlist = EmulatorCoreInfoPlist.init(fromInfoDictionary: plistObject) else {
fatalError("Could not generate EmulatorCoreInfoPlist from Core.plist")
}

return corePlist
}

/// Note: CorePlist is an enum generated by SwiftGen with a custom stencil
/// Change the swiftgen config to the local path to see the outputs and tweak
@objc(corePlist)
public static var corePlist: EmulatorCoreInfoPlist { CorePlist.corePlist }

@objc
public var corePlist: EmulatorCoreInfoPlist { Self.corePlist }
}
79 changes: 79 additions & 0 deletions Cores/fmsx/PVfMSXCore/PVfMSXCore.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// PVfMSXEmuCore.swift
// PVfMSXEmuCore
//
// Created by Joseph Mattiello on 12/31/24.
// Copyright © 2024 Provenance Emu. All rights reserved.
//

import Foundation
import PVEmulatorCore
import PVCoreBridge
import PVCoreObjCBridge
import PVCoreBridgeRetro

@objc
@objcMembers
open class PVfMSXEmuCore: PVEmulatorCore {

let _bridge: PVfMSXCoreBridge = .init()

public required init() {
super.init()
self.bridge = (_bridge as! any ObjCBridgedCoreBridge)
}
}

extension PVfMSXEmuCore: PVMSXSystemResponderClient {
public func didPush(_ button: PVCoreBridge.PVMSXButton, forPlayer player: Int) {
(_bridge as! PVMSXSystemResponderClient).didPush(button, forPlayer: player)
}
public func didRelease(_ button: PVCoreBridge.PVMSXButton, forPlayer player: Int) {
(_bridge as! PVMSXSystemResponderClient).didRelease(button, forPlayer: player)
}

public var gameSupportsKeyboard: Bool { true }
public var requiresKeyboard: Bool { false }
#if canImport(GameController)
// @objc optional var keyChangedHandler: GCKeyboardValueChangedHandler? { _bridge.keyChangedHandler }
public func keyDown(_ key: GCKeyCode) {
(_bridge as! PVMSXSystemResponderClient).keyDown(key)
}
public func keyUp(_ key: GCKeyCode) {
(_bridge as! PVMSXSystemResponderClient).keyUp(key)
}
#endif
}

extension PVfMSXEmuCore: MouseResponder {
public var gameSupportsMouse: Bool { true }
public var requiresMouse: Bool { false }

#if canImport(GameController)
public func didScroll(_ cursor: GCDeviceCursor) {
(_bridge as! MouseResponder).didScroll(cursor)
}
public var mouseMovedHandler: GCMouseMoved? { nil }
#endif
public func mouseMoved(atPoint point: CGPoint) {
(_bridge as! MouseResponder).mouseMoved(atPoint: point)
}
public func mouseMoved(at point: CGPoint) {
(_bridge as! MouseResponder).mouseMoved(atPoint: point)
}
public func leftMouseDown(at point: CGPoint) {
(_bridge as! MouseResponder).leftMouseDown(atPoint: point)
}
public func leftMouseDown(atPoint point: CGPoint) {
(_bridge as! MouseResponder).leftMouseDown(atPoint: point)
}
public func leftMouseUp() {
(_bridge as! MouseResponder).leftMouseUp()
}
public func rightMouseDown(atPoint point: CGPoint) {
(_bridge as! MouseResponder).rightMouseDown(atPoint: point)
}
public func rightMouseUp() {
(_bridge as! MouseResponder).rightMouseUp()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define GET_CURRENT_OR_RETURN(...) __strong __typeof__(_current) current = _current; if(current == nil) return __VA_ARGS__;

__attribute__((visibility("default")))
@interface PVfMSXCore : PVLibRetroCoreBridge <PVMSXSystemResponderClient> {
@interface PVfMSXCoreBridge : PVLibRetroCoreBridge <PVMSXSystemResponderClient> {
// uint8_t padData[4][PVDOSButtonCount];
// int8_t xAxis[4];
// int8_t yAxis[4];
Expand Down
Loading
Loading