Skip to content

Commit 7da2722

Browse files
committed
- Fixed a bug in changing render speed where the sound and countdown timer would not slow down
- Bumped to 0.3
1 parent 1ff957c commit 7da2722

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

Swift8/AppDelegate.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,23 @@ class AppDelegate: NSObject, NSApplicationDelegate
1414
// Loading the window controller manually
1515
lazy var windowController = NSStoryboard(name: "Main", bundle: nil).instantiateControllerWithIdentifier("MainWindowController") as! Chip8WindowController
1616

17+
// Don't show the initial open file screen if we opened through double clicking a file
18+
var didOpenWithFile = false
19+
1720
func applicationDidFinishLaunching(aNotification: NSNotification)
1821
{
1922
// Setup theme menu
2023
self.setupThemes()
2124

22-
// Show the initial open screen
23-
self.onOpenButton(self)
24-
2525
// Update the menu reflecting the sound state
2626
self.setSoundState(Settings.sharedSettings.playSound)
27+
28+
// Show the initial open screen
29+
30+
if !self.didOpenWithFile
31+
{
32+
self.onOpenButton(self)
33+
}
2734
}
2835

2936
@IBOutlet weak var themeMenu: NSMenu!
@@ -109,6 +116,7 @@ class AppDelegate: NSObject, NSApplicationDelegate
109116

110117
if url.pathExtension == "ch8"
111118
{
119+
self.didOpenWithFile = true
112120
self.windowController.loadPath(url)
113121
return true
114122
}

Swift8/Chip8.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ class Chip8
626626
self.makeNoise()
627627

628628
// And call self recursively after that delay
629-
delay(1.0/60.0, closure: self.timerLoop)
629+
delay(1.0 / (60.0 * Settings.sharedSettings.renderSpeed), closure: self.timerLoop)
630630
}
631631

632632
}
@@ -643,7 +643,7 @@ class Chip8
643643
self.tickInstruction()
644644

645645
// And call self recursively after that delay
646-
delay(1.0 / self.speed, closure: self.CPUCycleLoop)
646+
delay(1.0 / (1000 * Settings.sharedSettings.renderSpeed), closure: self.CPUCycleLoop)
647647
}
648648
}
649649

Swift8/Chip8ViewController.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ class Chip8ViewController: NSViewController
1414
// Holds the chip 8 emulator system
1515
var chip : Chip8?
1616

17-
// Limiting how fast the emulator can run
18-
let minSpeed = 50.0
19-
let maxSpeed = 1000.0
20-
21-
let speedStep = 50.0
22-
2317
// Current speed at which the emulator runs
2418
var currentSpeed : Double {
2519
get {
@@ -68,12 +62,12 @@ class Chip8ViewController: NSViewController
6862

6963
func increaseSpeed()
7064
{
71-
self.setSpeed(min(self.currentSpeed + self.speedStep, self.maxSpeed))
65+
self.setSpeed(min(self.currentSpeed + 0.1, 1))
7266
}
7367

7468
func decreaseSpeed()
7569
{
76-
self.setSpeed(max(self.currentSpeed - 100, self.minSpeed))
70+
self.setSpeed(max(self.currentSpeed - 0.1, 0.1))
7771
}
7872

7973
func changeTheme(theme: Theme)

Swift8/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<key>CFBundlePackageType</key>
3535
<string>APPL</string>
3636
<key>CFBundleShortVersionString</key>
37-
<string>0.2</string>
37+
<string>0.3</string>
3838
<key>CFBundleSignature</key>
3939
<string>????</string>
4040
<key>CFBundleVersion</key>

Swift8/Settings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Settings
8585
private func setDefaultValues()
8686
{
8787
self.theme = Themes.defaultTheme
88-
self.renderSpeed = 500.0
88+
self.renderSpeed = 0.5
8989
self.playSound = true
9090
}
9191

0 commit comments

Comments
 (0)