-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrmConfig.pas
More file actions
377 lines (307 loc) · 9.48 KB
/
frmConfig.pas
File metadata and controls
377 lines (307 loc) · 9.48 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
unit frmConfig;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls;
type
TConfigForm = class (TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Panel1: TPanel;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
lbBoot: TComboBox;
Label2: TLabel;
Label1: TLabel;
lbMemory: TEdit;
lbSectors: TEdit;
Label7: TLabel;
Label6: TLabel;
lbHeads: TEdit;
lbCylinder: TEdit;
Label5: TLabel;
lbHDDFile: TEdit;
Label4: TLabel;
lbHDDPresent: TCheckBox;
lbDiskSize: TEdit;
Label10: TLabel;
TabSheet4: TTabSheet;
Button6: TButton;
Label8: TLabel;
lbCDROMFile: TEdit;
lbCDRomPresent: TCheckBox;
Button4: TButton;
Button7: TButton;
Button8: TButton;
lbFPU: TCheckBox;
lbCDROMDrive: TComboBox;
Label11: TLabel;
lblBios: TLabel;
lblVgaBios: TLabel;
edtBios: TEdit;
edtVgaBios: TEdit;
btnBrowsBios: TButton;
btnBrowsVgaBios: TButton;
lblFont: TLabel;
edtFont: TEdit;
btnBrows3: TButton;
grpFloppyA: TGroupBox;
Label3: TLabel;
lbFloppyAType: TComboBox;
Label12: TLabel;
lbFloppyADrive: TComboBox;
Button9: TButton;
Label9: TLabel;
lbFloppyAFile: TEdit;
Button5: TButton;
grpFloppyB: TGroupBox;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
lbFloppyBType: TComboBox;
lbFloppyBDrive: TComboBox;
Button10: TButton;
lbFloppyBFile: TEdit;
Button11: TButton;
chkFloppyAReadOnly: TCheckBox;
chkFloppyBReadOnly: TCheckBox;
procedure Button3Click (Sender: TObject);
procedure FormActivate (Sender: TObject);
procedure Button2Click (Sender: TObject);
procedure lbCylinderChange (Sender: TObject);
procedure Button4Click (Sender: TObject);
procedure Button5Click (Sender: TObject);
procedure Button6Click (Sender: TObject);
procedure Button7Click (Sender: TObject);
procedure Button8Click (Sender: TObject);
procedure lbCDROMDriveSelect (Sender: TObject);
procedure lbFloppyADriveSelect (Sender: TObject);
procedure Button9Click (Sender: TObject);
procedure btnBrowsBiosClick(Sender: TObject);
procedure btnBrowsVgaBiosClick(Sender: TObject);
procedure btnBrows3Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
private
{ Private declarations }
public
procedure createEmptyFile (fileName: string; sizeFile: int64);
end;
var
ConfigForm: TConfigForm;
implementation
uses CONFIG, m2fMain, CreateIsoForm;
{$R *.dfm}
procedure TConfigForm.btnBrows3Click(Sender: TObject);
var
OD: TOpenDialog;
begin
OD := TOpenDialog.Create(nil);
OD.Title := 'Select VGA BIOS file';
od.Filter := '*.dat|*.dat';
if OD.Execute then
edtFont.Text := OD.FileName;
OD.Free;
end;
procedure TConfigForm.btnBrowsBiosClick(Sender: TObject);
var
OD: TOpenDialog;
begin
OD := TOpenDialog.Create(nil);
OD.Title := 'Select BIOS file';
od.Filter := '*.dat|*.dat';
if OD.Execute then
edtBios.Text := OD.FileName;
OD.Free;
end;
procedure TConfigForm.btnBrowsVgaBiosClick(Sender: TObject);
var
OD: TOpenDialog;
begin
OD := TOpenDialog.Create(nil);
OD.Title := 'Select VGA BIOS file';
od.Filter := '*.dat|*.dat';
if OD.Execute then
edtVgaBios.Text := OD.FileName;
OD.Free;
end;
procedure TConfigForm.Button11Click(Sender: TObject);
var
OD: TOpenDialog;
begin
OD := TOpenDialog.Create(nil);
OD.Title := 'Select image file';
od.Filter := '*.img|*.img|*.iso|*.iso|*.ima|*.ima';
if OD.Execute then
begin
lbFloppyBFile.Text := OD.FileName;
end;
OD.Free;
end;
procedure TConfigForm.Button2Click (Sender: TObject);
begin
VMConfig.Memory := StrToIntDef(lbMemory.Text, 32);
VMConfig.BootDevice := lbBoot.ItemIndex;
VMConfig.FloppyAType := lbFloppyAType.ItemIndex + 10;
VMConfig.FloppyAFile := lbFloppyAFile.Text;
VMConfig.FloppyAReadOnly := chkFloppyAReadOnly.Checked;
VMConfig.FloppyBType := lbFloppyBType.ItemIndex + 10;
VMConfig.FloppyBFile := lbFloppyBFile.Text;
VMConfig.FloppyBReadOnly := chkFloppyBReadOnly.Checked;
VMConfig.HddPresent := lbHDDPresent.Checked;
VMConfig.HddCylinder := StrToIntDef(lbCylinder.Text, 306);
VMConfig.HddHeads := StrToIntDef(lbHeads.Text, 4);
VMConfig.HddSectors := StrToIntDef(lbSectors.Text, 17);
VMConfig.HddFile := lbHDDFile.Text;
VMConfig.CdPresent := lbCDRomPresent.Checked;
VMConfig.CdFile := lbCDROMFile.Text;
VMConfig.usefpu := lbFPU.Checked;
VMConfig.BIOS := edtBios.Text;
VMConfig.VGA_BIOS := edtVgaBios.Text;
VMConfig.Font := edtFont.Text;
fMain1.SaveVMConfig;
fMain1.LoadVMConfig;
Button3.Click;
end;
procedure TConfigForm.Button3Click (Sender: TObject);
begin
lbMemory.Text := Format('%d', [VMConfig.Memory]);
lbBoot.ItemIndex := VMConfig.BootDevice;
lbFloppyAType.ItemIndex := VMConfig.FloppyAType - 10;
lbFloppyAFile.Text := VMConfig.FloppyAFile;
chkFloppyAReadOnly.Checked := VMConfig.FloppyAReadOnly;
lbFloppyBType.ItemIndex := VMConfig.FloppyBType - 10;
lbFloppyBFile.Text := VMConfig.FloppyBFile;
chkFloppyBReadOnly.Checked := VMConfig.FloppyBReadOnly;
lbHDDPresent.Checked := VMConfig.HddPresent;
lbCylinder.Text := Format('%d', [VMConfig.HddCylinder]);
lbHeads.Text := Format('%d', [VMConfig.HddHeads]);
lbSectors.Text := Format('%d', [VMConfig.HddSectors]);
lbHDDFile.Text := VMConfig.HddFile;
lbCDRomPresent.Checked := VMConfig.CdPresent;
lbCDROMFile.Text := VMConfig.CdFile;
lbFPU.Checked := VMConfig.usefpu;
edtBios.Text := VMConfig.BIOS;
edtVgaBios.Text := VMConfig.VGA_BIOS;
edtFont.Text := VMConfig.Font;
lbCylinderChange(nil);
end;
procedure TConfigForm.Button4Click (Sender: TObject);
var
OD: TOpenDialog;
begin
OD := TOpenDialog.Create(nil);
OD.Title := 'Select image file';
od.Filter := '*.img|*.img|*.iso|*.iso|*.ima|*.ima';
if OD.Execute then
begin
lbHDDFile.Text := OD.FileName;
end;
OD.Free;
end;
procedure TConfigForm.Button5Click (Sender: TObject);
var
OD: TOpenDialog;
begin
OD := TOpenDialog.Create(nil);
OD.Title := 'Select image file';
od.Filter := '*.img|*.img|*.iso|*.iso|*.ima|*.ima';
if OD.Execute then
begin
lbFloppyAFile.Text := OD.FileName;
end;
OD.Free;
end;
procedure TConfigForm.Button6Click (Sender: TObject);
var
OD: TOpenDialog;
begin
OD := TOpenDialog.Create(nil);
OD.Title := 'Select image file';
od.Filter := '*.img|*.img|*.iso|*.iso|*.ima|*.ima';
if OD.Execute then
begin
lbCDROMFile.Text := OD.FileName;
end;
OD.Free;
end;
procedure TConfigForm.Button7Click (Sender: TObject);
var
bytes: integer;
begin
bytes := StrToIntDef(lbCylinder.Text, 306) * StrToIntDef(lbHeads.Text, 4) *
StrToIntDef(lbSectors.Text, 17) * BYTES_PER_SECTOR;
if MessageDlg(Format('Ñîçäàòü ïóñòîé îáðàç äèñêà %s?',
[ExtractFileName(lbHDDFile.Text)]), mtConfirmation, [mbYes, mbNo], 0) = idYes then
CreateEmptyFile(lbHDDFile.Text, bytes);
end;
procedure TConfigForm.Button8Click (Sender: TObject);
begin
FormCreateIso := TFormCreateIso.Create(Self);
FormCreateIso.ShowModal;
FormCreateIso.Free;
end;
procedure TConfigForm.Button9Click (Sender: TObject);
begin
if MessageDlg(Format('Ñîçäàòü ïóñòîé îáðàç äèñêà %s?',
[ExtractFileName(lbFloppyAFile.Text)]), mtConfirmation, [mbYes, mbNo], 0) =
idYes then
CreateEmptyFile(lbFloppyAFile.Text, 1474560);
end;
procedure TConfigForm.createEmptyFile (fileName: string; sizeFile: int64);
var
countWrite, i: integer;
zeroBuffer: array [0..511] of byte;
f, modval: integer;
begin
for i := 0 to 511 do
zeroBuffer[i] := 0;
f := FileCreate(filename);
countWrite := sizeFile div 512;
ModVal := sizeFile mod 512;
for I := 1 to countWrite do
FileWrite(f, zeroBuffer[0], 512);
if modval <> 0 then
FileWrite(f, zeroBuffer[0], modval);
FileClose(f);
ShowMessage(Format('Ôàéë %s áûë ñîçäàí', [filename]));
end;
procedure TConfigForm.FormActivate (Sender: TObject);
var
dr, i, dt: integer;
begin
onactivate := nil;
dr := getlogicaldrives;
for i := 0 to 31 do
if (dr shr i) and 1 = 1 then
begin
dt := getdrivetype(PChar(char(byte('A') + i) + ':\'));
if (dt = DRIVE_CDROM) then
lbCDROMDrive.Items.Append(char(byte('A') + i))
else
if (dt = DRIVE_REMOVABLE) then
lbFloppyADrive.Items.Append(char(byte('A') + i));
end;
PageControl1.ActivePageIndex := 0;
Button3.Click;
end;
procedure TConfigForm.lbCDROMDriveSelect (Sender: TObject);
begin
lbCDROMFile.Text := Format('\\.\CDRom%d', [(Sender as TComboBox).ItemIndex]);
end;
procedure TConfigForm.lbCylinderChange (Sender: TObject);
var
bytes: integer;
begin
bytes := StrToIntDef(lbCylinder.Text, 306) * StrToIntDef(lbHeads.Text, 4) *
StrToIntDef(lbSectors.Text, 17) * BYTES_PER_SECTOR;
LbDiskSize.Text := Format('%.f Mb', [bytes / 1024 / 1024]);
end;
procedure TConfigForm.lbFloppyADriveSelect (Sender: TObject);
begin
lbFloppyAFile.Text := Format('\\.\%s:',
[(Sender as TComboBox).Items[(Sender as TComboBox).ItemIndex]]);
end;
end.