Skip to content

Commit e95df6c

Browse files
committed
Work on onboarding
1 parent a9eaf35 commit e95df6c

File tree

5 files changed

+118
-29
lines changed

5 files changed

+118
-29
lines changed

GUI/Dialogs/Settings/Configuration.swift

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class Configuration {
2222
var renderer: Renderer { return parent.renderer }
2323
var gamePadManager: GamePadManager { return parent.gamePadManager }
2424
var ressourceManager: RessourceManager { return renderer.ressourceManager }
25-
25+
2626
//
2727
// Roms
2828
//
29-
29+
3030
var extStart: Int {
3131
get { return emu.get(.MEM_EXT_START) }
3232
set { emu.set(.MEM_EXT_START, value: newValue) }
@@ -253,30 +253,30 @@ class Configuration {
253253

254254
var gameDevice1 = -1 {
255255
didSet {
256-
256+
257257
// Try to connect the device (may disconnect the other device)
258258
gamePadManager.connect(slot: gameDevice1, port: 1)
259259

260260
// Avoid double mappings
261261
if gameDevice1 != -1 && gameDevice1 == gameDevice2 {
262262
gameDevice2 = -1
263263
}
264-
264+
265265
parent.toolbar.validateVisibleItems()
266266
}
267267
}
268268

269269
var gameDevice2 = -1 {
270270
didSet {
271-
271+
272272
// Try to connect the device (may disconnect the other device)
273273
gamePadManager.connect(slot: gameDevice2, port: 2)
274274

275275
// Avoid double mappings
276276
if gameDevice2 != -1 && gameDevice2 == gameDevice1 {
277277
gameDevice1 = -1
278278
}
279-
279+
280280
parent.toolbar.validateVisibleItems()
281281
}
282282
}
@@ -645,6 +645,49 @@ class Configuration {
645645
get { return emu.get(.MON_DISALIGNMENT_V) }
646646
set { emu.set(.MON_DISALIGNMENT_V, value: newValue) }
647647
}
648-
648+
649649
init(with controller: MyController) { parent = controller }
650+
651+
func revertTo(model: Int) {
652+
653+
print("revertTo \(model)")
654+
655+
switch model {
656+
657+
case 0:
658+
659+
// Amiga 500
660+
agnusRev = AgnusRevision.ECS_1MB.rawValue
661+
deniseRev = DeniseRevision.OCS.rawValue
662+
rtClock = RTCRevision.NONE.rawValue
663+
bankMap = BankMap.A500.rawValue
664+
665+
case 1:
666+
667+
// Amiga 1000
668+
agnusRev = AgnusRevision.OCS_OLD.rawValue
669+
deniseRev = DeniseRevision.OCS.rawValue
670+
rtClock = RTCRevision.NONE.rawValue
671+
bankMap = BankMap.A1000.rawValue
672+
673+
case 2:
674+
675+
// Amiga 2000
676+
agnusRev = AgnusRevision.ECS_2MB.rawValue
677+
deniseRev = DeniseRevision.OCS.rawValue
678+
rtClock = RTCRevision.OKI.rawValue
679+
bankMap = BankMap.A2000B.rawValue
680+
681+
case 3:
682+
683+
// Amiga 500+
684+
agnusRev = AgnusRevision.ECS_2MB.rawValue
685+
deniseRev = DeniseRevision.ECS.rawValue
686+
rtClock = RTCRevision.OKI.rawValue
687+
bankMap = BankMap.A500.rawValue
688+
689+
default:
690+
fatalError()
691+
}
692+
}
650693
}

GUI/Metal/Layers/Onboarding.swift

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class OnboardingLayerViewController: NSViewController {
6464
@IBOutlet weak var skipButton: NSButton!
6565

6666
var layer: Onboarding!
67+
var emu: EmulatorProxy! { layer.emu }
6768

6869
private var pages: [NSViewController] = []
6970
private var currentPageIndex: Int = 0 {
@@ -77,10 +78,12 @@ class OnboardingLayerViewController: NSViewController {
7778

7879
override func viewDidAppear() {
7980

80-
func instantiate(_ id: String) -> NSViewController {
81+
func instantiate(_ id: String) -> OnboardingViewController {
8182

8283
let storyboard = NSStoryboard(name: "Onboarding", bundle: nil)
83-
return storyboard.instantiateController(withIdentifier: id) as! NSViewController
84+
let result = storyboard.instantiateController(withIdentifier: id) as! OnboardingViewController
85+
result.layer = layer
86+
return result
8487
}
8588

8689
// Start over by removing all child view controllers and their views
@@ -142,17 +145,26 @@ class OnboardingLayerViewController: NSViewController {
142145

143146
currentPageIndex = index
144147
prevButton.isEnabled = currentPageIndex > 0
145-
nextButton.title = currentPageIndex == pages.count - 1 ? "Finish" : "Continue"
148+
nextButton.title = currentPageIndex == pages.count - 1 ? "Launch" : "Continue"
146149
}
147150

148151
@IBAction func nextPage(_ sender: Any?) {
149152

150153
let nextIndex = currentPageIndex + 1
154+
151155
if pages.indices.contains(nextIndex) {
152156
showPage(at: nextIndex)
157+
} else {
158+
finish()
153159
}
154160
}
155161

162+
func finish() {
163+
164+
layer.close(delay: 1.0)
165+
try? emu.run()
166+
}
167+
156168
@IBAction func previousPage(_ sender: Any?) {
157169

158170
let prevIndex = currentPageIndex - 1
@@ -164,7 +176,7 @@ class OnboardingLayerViewController: NSViewController {
164176
@IBAction func skipAction(_ sender: Any?) {
165177

166178
print("skip")
167-
layer!.close(delay: 1.0)
179+
finish()
168180
}
169181
}
170182

@@ -226,10 +238,24 @@ class Onboarding: Layer {
226238
}
227239

228240
@MainActor
229-
class OnboardingViewController1: NSViewController {
241+
class OnboardingViewController: NSViewController {
242+
243+
var layer: Onboarding!
244+
var config: Configuration { layer.controller.config }
245+
246+
override func viewDidLoad() {
247+
248+
print("View did load")
249+
apply()
250+
}
230251

231-
var model = 0 { didSet { refresh() } }
252+
func apply() { }
253+
}
232254

255+
@MainActor
256+
class OnboardingViewController1: OnboardingViewController {
257+
258+
var model = 0 { didSet { apply() } }
233259
var a500: Bool { model == 0 }
234260
var a1000: Bool { model == 1 }
235261
var a2000: Bool { model == 2 }
@@ -240,12 +266,13 @@ class OnboardingViewController1: NSViewController {
240266

241267
@IBAction func modelAction(_ sender: NSControl) {
242268

243-
print("modelAction \(sender.tag)")
244269
model = sender.tag
270+
245271
}
246272

247-
override func viewDidLoad() {
273+
override func apply() {
248274

275+
config.revertTo(model: model)
249276
refresh()
250277
}
251278

@@ -260,9 +287,9 @@ class OnboardingViewController1: NSViewController {
260287
}
261288

262289
@MainActor
263-
class OnboardingViewController2: NSViewController {
290+
class OnboardingViewController2: OnboardingViewController {
264291

265-
var rom = 0 { didSet { refresh() } }
292+
var rom = 0 { didSet { apply() } }
266293

267294
var aros: Bool { rom == 0 }
268295
var diag: Bool { rom == 1 }
@@ -274,9 +301,16 @@ class OnboardingViewController2: NSViewController {
274301

275302
print("romAction \(sender.tag)")
276303
rom = sender.tag
304+
277305
}
278306

279-
override func viewDidLoad() {
307+
override func apply() {
308+
309+
switch rom {
310+
case 0: layer.controller.installAros()
311+
case 1: layer.controller.installDiagRom()
312+
default: fatalError()
313+
}
280314

281315
refresh()
282316
}

GUI/MyController.swift

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,6 @@ extension MyController {
208208

209209
do {
210210

211-
// Experimental
212-
renderer.splashScreen.shouldRender = false
213-
renderer.canvas.shouldRender = false
214-
renderer.onboarding.open(delay: 1.0)
215-
216-
// Install Aros if no Kickstart is present
217-
if !emu.mem.info.hasRom { installAros() }
218-
219211
// Switch the Amiga on
220212
emu.powerOn()
221213

@@ -226,6 +218,11 @@ extension MyController {
226218

227219
// Switch the Amiga off
228220
emu.powerOff()
221+
222+
// Open the onboarding agent
223+
renderer.splashScreen.shouldRender = false
224+
renderer.canvas.shouldRender = false
225+
renderer.onboarding.open(delay: 1.0)
229226
}
230227

231228
// Add media file (if provided on startup)

GUI/MyControllerMedia.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension MyController {
1515
installAros(crc32: vamiga.CRC32_AROS_20250219)
1616
}
1717

18-
func installAros(crc32: UInt32) {
18+
func installAros(crc32: UInt32 = vamiga.CRC32_AROS_20250219) {
1919

2020
switch crc32 {
2121

@@ -33,6 +33,21 @@ extension MyController {
3333
}
3434
}
3535

36+
func installDiagRom(crc32: UInt32 = vamiga.CRC32_DIAG13) {
37+
38+
switch crc32 {
39+
40+
case vamiga.CRC32_DIAG121:
41+
install(rom: "diagrom-121")
42+
43+
case vamiga.CRC32_DIAG13:
44+
install(rom: "diagrom-13")
45+
46+
default:
47+
fatalError()
48+
}
49+
}
50+
3651
func installAros(rom: String, ext: String) {
3752

3853
guard let config = config, let emu = emu else { return }

GUI/XIB files/Configuration.xib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24127" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24128" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24127"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24128"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<objects>

0 commit comments

Comments
 (0)