Skip to content

Commit

Permalink
Added release schema with predefined ROMs
Browse files Browse the repository at this point in the history
  • Loading branch information
LiarPrincess committed Nov 9, 2020
1 parent e39e6ad commit 7a773b0
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 0 deletions.
1 change: 1 addition & 0 deletions Sources/GameBoyMac/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {

func applicationDidFinishLaunching(_ aNotification: Notification) {
let argumentsRaw = CommandLine.arguments
// let argumentsRaw = ["GameBoyMac", ROMs.tetris]
let arguments = Arguments(arguments: argumentsRaw)

let keyMap = KeyMap(
Expand Down
85 changes: 85 additions & 0 deletions Sources/GameBoyMac/ROMs.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

import Foundation

// swiftlint:disable line_length

private let bundle = Bundle.main
private let fileManager = FileManager.default

/// Path to the ROMs in ROMs dir.
enum ROMs {

static let tetris = Self.createPath(filename: "Tetris.gb")
static let pokemonRed = Self.createPath(filename: "Pokemon Red.gb")
static let pokemonBlue = Self.createPath(filename: "Pokemon Blue.gb")
static let superMarioLand = Self.createPath(filename: "Super Mario Land.gb")
static let legendOfZelda = Self.createPath(filename: "Legend of Zelda - The Link's Awakening.gb")
static let bomberman = Self.createPath(filename: "Bomberman.gb")
static let f1Race = Self.createPath(filename: "F-1 Race.gb")
static let galagaGalaxian = Self.createPath(filename: "Galaga & Galaxian.gb")
static let kirbysDreamLand = Self.createPath(filename: "Kirby's Dream Land.gb")
static let spaceInvaders = Self.createPath(filename: "Space Invaders.gb")

enum Blargg {
static let cpuInstrs01 = Self.createBlarggPath(filename: "cpu_instrs/individual/01-special.gb")
static let cpuInstrs02 = Self.createBlarggPath(filename: "cpu_instrs/individual/02-interrupts.gb")
static let cpuInstrs03 = Self.createBlarggPath(filename: "cpu_instrs/individual/03-op sp,hl.gb")
static let cpuInstrs04 = Self.createBlarggPath(filename: "cpu_instrs/individual/04-op r,imm.gb")
static let cpuInstrs05 = Self.createBlarggPath(filename: "cpu_instrs/individual/05-op rp.gb")
static let cpuInstrs06 = Self.createBlarggPath(filename: "cpu_instrs/individual/06-ld r,r.gb")
static let cpuInstrs07 = Self.createBlarggPath(filename: "cpu_instrs/individual/07-jr,jp,call,ret,rst.gb")
static let cpuInstrs08 = Self.createBlarggPath(filename: "cpu_instrs/individual/08-misc instrs.gb")
static let cpuInstrs09 = Self.createBlarggPath(filename: "cpu_instrs/individual/09-op r,r.gb")
static let cpuInstrs10 = Self.createBlarggPath(filename: "cpu_instrs/individual/10-bit ops.gb")
static let cpuInstrs11 = Self.createBlarggPath(filename: "cpu_instrs/individual/11-op a,(hl).gb")
static let instrTiming = Self.createBlarggPath(filename: "instr_timing/instr_timing.gb")

private static func createBlarggPath(filename: String) -> String {
let romUrl = ROMs.romsDir
.appendingPathComponent("Tests - Blargg")
.appendingPathComponent("ROMs")
.appendingPathComponent(filename)

return romUrl.path
}
}

private static func createPath(filename: String) -> String {
let romUrl = Self.romsDir.appendingPathComponent(filename)
return romUrl.path
}

private static let executableURL: URL = {
if let url = bundle.executableURL {
return url
}

if let path = bundle.executablePath {
return URL(fileURLWithPath: path)
}

fatalError("Failed to obtain executable path.")
}()

/// `ROMs` directory in repository root.
private static let romsDir: URL = {
var dir = executableURL
dir.deleteLastPathComponent()

for _ in 0..<dir.pathComponents.count {
let romDir = dir.appendingPathComponent("ROMs")
let exists = fileManager.fileExists(atPath: romDir.path)

if exists {
return romDir
}

dir.deleteLastPathComponent()
}

fatalError("Failed to obtain ROM dir")
}()
}
4 changes: 4 additions & 0 deletions Swift plays pokemon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
903C2B642559774B00EB1C6D /* GameBoyWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 903C2B5D2559774B00EB1C6D /* GameBoyWindow.swift */; };
903C2B652559774B00EB1C6D /* Arguments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 903C2B5E2559774B00EB1C6D /* Arguments.swift */; };
903C2B662559774B00EB1C6D /* Metal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 903C2B5F2559774B00EB1C6D /* Metal.swift */; };
903C2B962559A5B000EB1C6D /* ROMs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 903C2B952559A5AF00EB1C6D /* ROMs.swift */; };
90427CF825545FC8007A9E9D /* CpuMemory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90427CF725545FC8007A9E9D /* CpuMemory.swift */; };
90427D5725546F00007A9E9D /* BootromMemory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90427D5625546F00007A9E9D /* BootromMemory.swift */; };
90427D84255480B2007A9E9D /* Interrupts+properties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90427D7C25548092007A9E9D /* Interrupts+properties.swift */; };
Expand Down Expand Up @@ -239,6 +240,7 @@
903C2B5D2559774B00EB1C6D /* GameBoyWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameBoyWindow.swift; sourceTree = "<group>"; };
903C2B5E2559774B00EB1C6D /* Arguments.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Arguments.swift; sourceTree = "<group>"; };
903C2B5F2559774B00EB1C6D /* Metal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Metal.swift; sourceTree = "<group>"; };
903C2B952559A5AF00EB1C6D /* ROMs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ROMs.swift; sourceTree = "<group>"; };
90427CF725545FC8007A9E9D /* CpuMemory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CpuMemory.swift; sourceTree = "<group>"; };
90427D5625546F00007A9E9D /* BootromMemory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BootromMemory.swift; sourceTree = "<group>"; };
90427D7C25548092007A9E9D /* Interrupts+properties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Interrupts+properties.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -491,6 +493,7 @@
903C2B5D2559774B00EB1C6D /* GameBoyWindow.swift */,
903C2B5A2559774B00EB1C6D /* KeyMap.swift */,
903C2B5F2559774B00EB1C6D /* Metal.swift */,
903C2B952559A5AF00EB1C6D /* ROMs.swift */,
903C2B5B2559774B00EB1C6D /* Shader.metal */,
903C2B1B2559758300EB1C6D /* Info.plist */,
);
Expand Down Expand Up @@ -1025,6 +1028,7 @@
903C2B622559774B00EB1C6D /* Shader.metal in Sources */,
903C2B662559774B00EB1C6D /* Metal.swift in Sources */,
903C2B612559774B00EB1C6D /* KeyMap.swift in Sources */,
903C2B962559A5B000EB1C6D /* ROMs.swift in Sources */,
903C2B102559758100EB1C6D /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "903C2B0C2559758100EB1C6D"
BuildableName = "GameBoyMac.app"
BlueprintName = "GameBoyMac"
ReferencedContainer = "container:Swift plays Pokemon.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "903C2B0C2559758100EB1C6D"
BuildableName = "GameBoyMac.app"
BlueprintName = "GameBoyMac"
ReferencedContainer = "container:Swift plays Pokemon.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "903C2B0C2559758100EB1C6D"
BuildableName = "GameBoyMac.app"
BlueprintName = "GameBoyMac"
ReferencedContainer = "container:Swift plays Pokemon.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

0 comments on commit 7a773b0

Please sign in to comment.