@@ -20,8 +20,71 @@ import Virtualization
2020#endif
2121
2222struct VMWizardHardwareView : View {
23+ private enum ClassicMacSystem : CaseIterable , Identifiable {
24+ case quadra800
25+ //case powerMacG3Beige
26+ case powerMacG4
27+ case powerMacG5
28+
29+ var id : Self { self }
30+
31+ var title : LocalizedStringKey {
32+ switch self {
33+ case . quadra800: " Macintosh Quadra 800 (M68K) "
34+ //case .powerMacG3Beige: "Power Macintosh G3 (Beige)"
35+ case . powerMacG4: " Power Macintosh G4 (PPC) "
36+ case . powerMacG4: " Power Macintosh G5 (PPC64) "
37+ }
38+ }
39+
40+ var architecture : QEMUArchitecture {
41+ switch self {
42+ case . quadra800: return . m68k
43+ //case .powerMacG3Beige: return .ppc
44+ case . powerMacG4: return . ppc
45+ case . powerMacG5: return . ppc64
46+ }
47+ }
48+
49+ var target : any QEMUTarget {
50+ switch self {
51+ case . quadra800: return QEMUTarget_m68k . q800
52+ //case .powerMacG3Beige: return QEMUTarget_ppc.g3beige
53+ case . powerMacG4: return QEMUTarget_ppc . mac99
54+ case . powerMacG5: return QEMUTarget_ppc . mac99
55+ }
56+ }
57+
58+ var minRam : Int {
59+ switch self {
60+ case . quadra800: return 8
61+ //case .powerMacG3Beige: return 32
62+ case . powerMacG4: return 64
63+ case . powerMacG5: return 64
64+ }
65+ }
66+
67+ var maxRam : Int {
68+ switch self {
69+ case . quadra800: return 1024
70+ //case .powerMacG3Beige: return 2047
71+ case . powerMacG4: return 2048
72+ case . powerMacG5: return 2048
73+ }
74+ }
75+
76+ var defaultRam : Int {
77+ switch self {
78+ case . quadra800: return 128
79+ //case .powerMacG3Beige: return 512
80+ case . powerMacG4: return 512
81+ case . powerMacG5: return 512
82+ }
83+ }
84+ }
2385 @ObservedObject var wizardState : VMWizardState
24-
86+ @State private var classicMacSystem : ClassicMacSystem = . powerMacG4
87+
2588 var minCores : Int {
2689 #if canImport(Virtualization)
2790 VZVirtualMachineConfiguration . minimumAllowedCPUCount
@@ -56,7 +119,7 @@ struct VMWizardHardwareView: View {
56119
57120 var body : some View {
58121 VMWizardContent ( " Hardware " ) {
59- if !wizardState. useVirtualization {
122+ if !wizardState. useVirtualization && wizardState . operatingSystem != . ClassicMacOS {
60123 Section {
61124 VMConfigConstantPicker ( selection: $wizardState. systemArchitecture)
62125 . onChange ( of: wizardState. systemArchitecture) { newValue in
@@ -72,39 +135,60 @@ struct VMWizardHardwareView: View {
72135 Text ( " System " )
73136 }
74137
138+ } else if wizardState. operatingSystem == . ClassicMacOS {
139+ Section {
140+ Picker ( " Machine " , selection: $classicMacSystem) {
141+ ForEach ( ClassicMacSystem . allCases) { system in
142+ Text ( system. title) . tag ( system)
143+ }
144+ } . pickerStyle ( . inline)
145+ . onChange ( of: classicMacSystem) { newValue in
146+ wizardState. systemArchitecture = newValue. architecture
147+ wizardState. systemTarget = newValue. target
148+ wizardState. systemMemoryMib = newValue. defaultRam
149+ wizardState. systemCpuCount = 1
150+ }
151+ }
75152 }
76153 Section {
77154 RAMSlider ( systemMemory: $wizardState. systemMemoryMib) { _ in
78- if wizardState. systemMemoryMib > maxMemoryMib {
79- wizardState. systemMemoryMib = maxMemoryMib
155+ let validMax = wizardState. operatingSystem == . ClassicMacOS ? classicMacSystem. maxRam : maxMemoryMib
156+ if wizardState. systemMemoryMib > validMax {
157+ wizardState. systemMemoryMib = validMax
158+ }
159+ let validMin = wizardState. operatingSystem == . ClassicMacOS ? classicMacSystem. minRam : 0
160+ if wizardState. systemMemoryMib < validMin {
161+ wizardState. systemMemoryMib = validMin
80162 }
81163 }
82164 } header: {
83165 Text ( " Memory " )
84166 }
85-
86- Section {
87- HStack {
88- Stepper ( value: $wizardState. systemCpuCount, in: minCores... maxCores) {
89- Text ( " CPU Cores " )
90- }
91- NumberTextField ( " " , number: $wizardState. systemCpuCount, prompt: " Default " , onEditingChanged: { _ in
92- guard wizardState. systemCpuCount != 0 else {
93- return
94- }
95- if wizardState. systemCpuCount < minCores {
96- wizardState. systemCpuCount = minCores
97- } else if wizardState. systemCpuCount > maxCores {
98- wizardState. systemCpuCount = maxCores
167+
168+ if wizardState. operatingSystem != . ClassicMacOS {
169+ Section {
170+ HStack {
171+ Stepper ( value: $wizardState. systemCpuCount, in: minCores... maxCores) {
172+ Text ( " CPU Cores " )
99173 }
100- } )
174+ NumberTextField ( " " , number: $wizardState. systemCpuCount, prompt: " Default " , onEditingChanged: { _ in
175+ guard wizardState. systemCpuCount != 0 else {
176+ return
177+ }
178+ if wizardState. systemCpuCount < minCores {
179+ wizardState. systemCpuCount = minCores
180+ } else if wizardState. systemCpuCount > maxCores {
181+ wizardState. systemCpuCount = maxCores
182+ }
183+ } )
101184 . frame ( width: 80 )
102185 . multilineTextAlignment ( . trailing)
186+ }
187+ } header: {
188+ Text ( " CPU " )
103189 }
104- } header: {
105- Text ( " CPU " )
106190 }
107-
191+
108192
109193
110194 if !wizardState. useAppleVirtualization && wizardState. operatingSystem == . Linux {
@@ -135,6 +219,12 @@ struct VMWizardHardwareView: View {
135219 if wizardState. legacyHardware && wizardState. systemArchitecture == . x86_64 {
136220 wizardState. systemTarget = QEMUTarget_x86_64 . pc
137221 }
222+ if wizardState. operatingSystem == . ClassicMacOS {
223+ wizardState. systemArchitecture = classicMacSystem. architecture
224+ wizardState. systemTarget = classicMacSystem. target
225+ wizardState. systemMemoryMib = classicMacSystem. defaultRam
226+ wizardState. systemCpuCount = 1
227+ }
138228 }
139229 }
140230
0 commit comments