-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathConfigFileHandler.vb
More file actions
266 lines (249 loc) · 15.9 KB
/
ConfigFileHandler.vb
File metadata and controls
266 lines (249 loc) · 15.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
Module ConfigFileHandler
Public Sub Create(ByVal MacName As String, ByVal Path As String, ByVal Emulator As String, ByVal RAMInMB As Integer, _
ByVal UseDisk As String, Optional ByVal DiskSize As Integer = 0, Optional ByVal DiskPath As String = "")
Dim ConfigFile As String = ""
If UseDisk = "New" Then
DiskImageCreator.CreateRawDisk(DiskSize, DiskPath, False)
End If
EmulatorSection:
Select Case Emulator
Case "vMac"
If UseDisk = "New" Or UseDisk = "Exist" Then
ConfigFile = FormatLine("disk", DiskPath)
End If
ConfigFile = ConfigFile & My.Settings.vMacROM & vbCrLf
Case "SheepShaver"
If UseDisk = "New" Or UseDisk = "Exist" Then
ConfigFile = FormatLine("disk", DiskPath)
End If
ConfigFile = ConfigFile & FormatLine("extfs", "")
ConfigFile = ConfigFile & FormatLine("screen", "win/800/600")
ConfigFile = ConfigFile & FormatLine("windowmodes", "2")
ConfigFile = ConfigFile & FormatLine("screenmodes", "62")
ConfigFile = ConfigFile & FormatLine("seriala", "COM1")
ConfigFile = ConfigFile & FormatLine("serialb", "COM2")
ConfigFile = ConfigFile & FormatLine("rom", My.Settings.SheepShaverROM)
ConfigFile = ConfigFile & FormatLine("bootdrive", "0")
ConfigFile = ConfigFile & FormatLine("bootdriver", "0")
ConfigFile = ConfigFile & FormatLine("ramsize", (RAMInMB * 1024) * 1024)
ConfigFile = ConfigFile & FormatLine("frameskip", "0")
ConfigFile = ConfigFile & FormatLine("gfxaccel", "true")
ConfigFile = ConfigFile & FormatLine("nocdrom", "false")
ConfigFile = ConfigFile & FormatLine("nonet", "false")
ConfigFile = ConfigFile & FormatLine("nosound", "false")
ConfigFile = ConfigFile & FormatLine("nogui", "false")
ConfigFile = ConfigFile & FormatLine("noclipconversion", "false")
ConfigFile = ConfigFile & FormatLine("ignoresegv", "true")
ConfigFile = ConfigFile & FormatLine("ignoreillegal", "true")
ConfigFile = ConfigFile & FormatLine("jit", "true")
ConfigFile = ConfigFile & FormatLine("jit68k", "false")
ConfigFile = ConfigFile & FormatLine("keyboardtype", "5")
ConfigFile = ConfigFile & FormatLine("ether", "slirp")
ConfigFile = ConfigFile & FormatLine("keycodes", "false")
ConfigFile = ConfigFile & FormatLine("keycodefile", "BasiliskII_keycodes")
ConfigFile = ConfigFile & FormatLine("mousewheelmode", "1")
ConfigFile = ConfigFile & FormatLine("mousewheellines", "3")
ConfigFile = ConfigFile & FormatLine("idlewait", "true")
ConfigFile = ConfigFile & FormatLine("mousewheelmode", "1")
ConfigFile = ConfigFile & FormatLine("mousewheellines", "3")
ConfigFile = ConfigFile & FormatLine("enableextfs", "false")
ConfigFile = ConfigFile & FormatLine("debugextfs", "false")
ConfigFile = ConfigFile & FormatLine("extdrives", "CDEFGHIJKLMNOPQRSTUVWXYZ")
ConfigFile = ConfigFile & FormatLine("pollmedia", "true")
ConfigFile = ConfigFile & FormatLine("etherpermanentaddress", "true")
ConfigFile = ConfigFile & FormatLine("routerenabled", "false")
ConfigFile = ConfigFile & FormatLine("portfile0", My.Application.Info.DirectoryPath & "\Emulators\SheepShaver\Com1.txt")
ConfigFile = ConfigFile & FormatLine("portfile1", My.Application.Info.DirectoryPath & "\Emulators\SheepShaver\Com2.txt")
Case "BII"
If UseDisk = "New" Or UseDisk = "Exist" Then
ConfigFile = FormatLine("disk", DiskPath)
End If
ConfigFile = ConfigFile & FormatLine("extfs", "")
ConfigFile = ConfigFile & FormatLine("screen", "win/800/600")
ConfigFile = ConfigFile & FormatLine("seriala", "COM1")
ConfigFile = ConfigFile & FormatLine("serialb", "COM2")
ConfigFile = ConfigFile & FormatLine("ether", "slirp")
ConfigFile = ConfigFile & FormatLine("udptunnel", "false")
ConfigFile = ConfigFile & FormatLine("udpport", "6066")
ConfigFile = ConfigFile & FormatLine("rom", My.Settings.BasiliskROM)
ConfigFile = ConfigFile & FormatLine("bootdrive", 0)
ConfigFile = ConfigFile & FormatLine("bootdriver", 0)
ConfigFile = ConfigFile & FormatLine("ramsize", (RAMInMB * 1024) * 1024)
ConfigFile = ConfigFile & FormatLine("frameskip", 0)
ConfigFile = ConfigFile & FormatLine("modelid", 5)
ConfigFile = ConfigFile & FormatLine("cpu", 4)
ConfigFile = ConfigFile & FormatLine("fpu", "true")
ConfigFile = ConfigFile & FormatLine("nocdrom", "false")
ConfigFile = ConfigFile & FormatLine("nosound", "false")
ConfigFile = ConfigFile & FormatLine("noclipconversion", "false")
ConfigFile = ConfigFile & FormatLine("nogui", "false")
ConfigFile = ConfigFile & FormatLine("jit", "true")
ConfigFile = ConfigFile & FormatLine("jitfpu", "true")
ConfigFile = ConfigFile & FormatLine("jitdebug", "true")
ConfigFile = ConfigFile & FormatLine("jitcachesize", 4096)
ConfigFile = ConfigFile & FormatLine("jitlazyflush", "true")
ConfigFile = ConfigFile & FormatLine("jitinline", "true")
ConfigFile = ConfigFile & FormatLine("keyboardtype", "5")
ConfigFile = ConfigFile & FormatLine("keycodes", "false")
ConfigFile = ConfigFile & FormatLine("keycodefile", "BasiliskII_keycodes")
ConfigFile = ConfigFile & FormatLine("mousewheelmode", "1")
ConfigFile = ConfigFile & FormatLine("mousewheellines", "3")
ConfigFile = ConfigFile & FormatLine("ignoresegv", "true")
ConfigFile = ConfigFile & FormatLine("idlewait", "true")
ConfigFile = ConfigFile & FormatLine("enableextfs", "false")
ConfigFile = ConfigFile & FormatLine("debugextfs", "false")
ConfigFile = ConfigFile & FormatLine("extdrives", "CDEFGHIJKLMNOPQRSTUVWXYZ")
ConfigFile = ConfigFile & FormatLine("pollmedia", "true")
ConfigFile = ConfigFile & FormatLine("etherpermanentaddress", "true")
ConfigFile = ConfigFile & FormatLine("routerenabled", "false")
ConfigFile = ConfigFile & FormatLine("portfile0", My.Application.Info.DirectoryPath & "COM1.log")
ConfigFile = ConfigFile & FormatLine("portfile1", My.Application.Info.DirectoryPath & "COM2.log")
Case "PearPC"
ConfigFile = FormatLine("ppc_start_resolution =", "800x600x15", True)
ConfigFile = ConfigFile & FormatLine("ppc_start_full_screen =", 0)
ConfigFile = ConfigFile & FormatLine("redraw_interval_msec =", 40)
ConfigFile = ConfigFile & FormatLine("key_compose_dialog =", "F11", True)
ConfigFile = ConfigFile & FormatLine("key_change_cd_0 =", "none", True)
ConfigFile = ConfigFile & FormatLine("key_toggle_mouse_grab =", "F12", True)
ConfigFile = ConfigFile & FormatLine("key_toggle_full_screen =", "Alt+Return", True)
ConfigFile = ConfigFile & FormatLine("prom_bootmethod =", "select", True)
ConfigFile = ConfigFile & FormatLine("prom_env_machargs =", "", True)
ConfigFile = ConfigFile & FormatLine("prom_driver_graphic =", "video.x", True)
ConfigFile = ConfigFile & FormatLine("page_table_pa =", "104857600")
ConfigFile = ConfigFile & FormatLine("cpu_pvr =", "0x00088302")
ConfigFile = ConfigFile & FormatLine("memory_size =", "0x" & RAMInMB / 0.0000256)
If UseDisk = "New" Or UseDisk = "Exist" Then
ConfigFile = ConfigFile & FormatLine("pci_ide0_master_installed =", "1")
ConfigFile = ConfigFile & FormatLine("pci_ide0_master_image =", DiskPath, True)
ConfigFile = ConfigFile & FormatLine("pci_ide0_master_type =", "hd", True)
Else
ConfigFile = ConfigFile & FormatLine("pci_ide0_master_installed =", "0")
End If
ConfigFile = ConfigFile & FormatLine("pci_ide0_slave_installed =", "0")
ConfigFile = ConfigFile & FormatLine("pci_3c90x_installed =", "0")
ConfigFile = ConfigFile & FormatLine("pci_3c90x_mac =", "de:ad:ca:fe:12:34", True)
ConfigFile = ConfigFile & FormatLine("pci_rtl8139_installed =", "0", True)
ConfigFile = ConfigFile & FormatLine("pci_rtl8139_mac =", "de:ad:ca:fe:12:34", True)
ConfigFile = ConfigFile & FormatLine("pci_usb_installed =", "1")
ConfigFile = ConfigFile & FormatLine("pci_serial_installed =", "0")
ConfigFile = ConfigFile & FormatLine("nvram_file =", "nvram", True)
Case "QEMU"
'//Will be used for reference to load and save batches for QEMU
'ConfigFile = "qemu-system-ppc.exe -L pc-bios -boot d -m " & RAMInMB & " -M mac99 -prom-env " & Chr(34) & _
' "auto-boot?=true" & Chr(34) & " -prom-env " & Chr(34) & "boot-args=-v" & Chr(34) & " -prom-env " & Chr(34) & _
' "vga-ndrv?=true" & Chr(34) & " -drive file=MacOS9.2.iso,format=raw,media=cdrom " & _
' "-drive file=" & Chr(34) & DiskPath & Chr(34) & _
' ",format=raw,media=disk -sdl -netdev user,id=network01 -device sungem,netdev=network01 "
ConfigFile = "qemu-system-ppc.exe -L pc-bios -boot d -m " & RAMInMB & " -M mac99 -prom-env " & Chr(34) & _
"auto-boot?=true" & Chr(34) & " -prom-env " & Chr(34) & "boot-args=-v" & Chr(34) & " -prom-env " & Chr(34) & _
"vga-ndrv?=true" & Chr(34) & "-drive file=" & Chr(34) & DiskPath & Chr(34) & _
",format=raw,media=disk -sdl -netdev user,id=network01 -device sungem,netdev=network01 "
End Select
CreateFiles:
If My.Computer.FileSystem.DirectoryExists(System.IO.Path.GetDirectoryName(MacName)) = False Then 'Verify that the path doesn't exists
My.Computer.FileSystem.CreateDirectory(System.IO.Path.GetDirectoryName(Path))
Write(ConfigFile, Path)
Else 'If the path does already exist...
MsgBox("This folder already exists. Creating a duplicate.", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
My.Computer.FileSystem.CreateDirectory(System.IO.Path.GetDirectoryName(Path & "(1)"))
Write(ConfigFile, Path)
End If
With frmMain.VMList.Items.Add(MacName) 'Add the fresh new Mac to the console
.SubItems.Add(Path) 'Several SubItems are used to load. This one sets the path tp the config file
.SubItems.Add(Emulator) 'This one sets the emulator to load properly a file
.StateImageIndex = 0 'Will be reimplemented. Used for icons
End With
frmMain.SaveSettings()
End Sub
Public Function FormatLine(ByVal Line1 As String, ByVal Line2 As String, Optional InQuotes As Boolean = False) As String
Dim Formatted As String = ""
If InQuotes = False Then
Formatted = Line1 & " " & Line2 & vbCrLf
Else
Formatted = Line1 & " " & Chr(34) & Line2 & Chr(34) & vbCrLf
End If
Return Formatted
End Function
Public Sub Edit(ByVal ConfigFile As String, ByVal Emulator As String, ByVal Parameters As String)
End Sub
Public Sub Convert(ByVal FileToConvert As String, ByVal OldEmulator As String, ByVal NewEmulator As String)
End Sub
Public Sub Write(ByVal Text As String, ByVal Route As String)
Dim Writer As IO.StreamWriter = IO.File.CreateText(Route)
Writer.Write(Text)
Writer.Flush()
Writer.Close()
End Sub
Public Sub CreateFromFile(ByVal File As String, ByVal Emulator As String, ByVal VMName As String)
Dim VMPath As String = My.Settings.DefaultMacFolder + "\" + VMName
Dim VMFile As String = VMPath + "\" + VMName + ".mcf"
Select Case Emulator
Case "vMacBatch"
If My.Computer.FileSystem.DirectoryExists(VMPath) = False Then
My.Computer.FileSystem.CreateDirectory(VMPath)
My.Computer.FileSystem.CopyFile(File, VMPath + "\" + VMName + ".mcf")
End If
With frmMain.VMList.Items.Add(VMName)
.SubItems.Add(VMFile)
.SubItems.Add("vMac")
.StateImageIndex = 0
End With
frmMain.SaveSettings()
Case "vMac"
If My.Computer.FileSystem.DirectoryExists(VMPath) = False Then
My.Computer.FileSystem.CreateDirectory(VMPath)
My.Computer.FileSystem.CopyFile(File, VMPath + "\" + VMName + ".mcf")
End If
With frmMain.VMList.Items.Add(VMName)
.SubItems.Add(VMFile)
.SubItems.Add("vMac")
.StateImageIndex = 0
End With
frmMain.SaveSettings()
Case "BII"
If My.Computer.FileSystem.DirectoryExists(VMPath) = False Then
My.Computer.FileSystem.CreateDirectory(VMPath)
My.Computer.FileSystem.CopyFile(File, VMPath + "\" + VMName + ".mcf")
End If
With frmMain.VMList.Items.Add(VMName)
.SubItems.Add(VMFile)
.SubItems.Add("BII")
.StateImageIndex = 0
End With
frmMain.SaveSettings()
Case "SheepShaver"
If My.Computer.FileSystem.DirectoryExists(VMPath) = False Then
My.Computer.FileSystem.CreateDirectory(VMPath)
My.Computer.FileSystem.CopyFile(File, VMPath + "\" + VMName + ".mcf")
End If
With frmMain.VMList.Items.Add(VMName)
.SubItems.Add(VMFile)
.SubItems.Add("SheepShaver")
.StateImageIndex = 0
End With
frmMain.SaveSettings()
Case "PearPC"
If My.Computer.FileSystem.DirectoryExists(VMPath) = False Then
My.Computer.FileSystem.CreateDirectory(VMPath)
My.Computer.FileSystem.CopyFile(File, VMPath + "\" + VMName + ".mcf")
End If
With frmMain.VMList.Items.Add(VMName)
.SubItems.Add(VMFile)
.SubItems.Add("PearPC")
.StateImageIndex = 0
End With
frmMain.SaveSettings()
Case "QEMUBatch"
If My.Computer.FileSystem.DirectoryExists(VMPath) = False Then
My.Computer.FileSystem.CreateDirectory(VMPath)
My.Computer.FileSystem.CopyFile(File, VMPath + "\" + VMName + ".mcf")
End If
With frmMain.VMList.Items.Add(VMName)
.SubItems.Add(VMFile)
.SubItems.Add("QEMU")
.StateImageIndex = 0
End With
frmMain.SaveSettings()
End Select
End Sub
End Module