-
Notifications
You must be signed in to change notification settings - Fork 2
/
FORMAT.PAS
3069 lines (2228 loc) · 78.3 KB
/
FORMAT.PAS
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{/////////////////////////////////////////////////////////////////////////
//
// Dos Navigator Version 1.51 Copyright (C) 1991-99 RIT Research Labs
//
// This programs is free for commercial and non-commercial use as long as
// the following conditions are aheared to.
//
// Copyright remains RIT Research Labs, and as such any Copyright notices
// in the code are not to be removed. If this package is used in a
// product, RIT Research Labs should be given attribution as the RIT Research
// Labs of the parts of the library used. This can be in the form of a textual
// message at program startup or in documentation (online or textual)
// provided with the package.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. All advertising materials mentioning features or use of this software
// must display the following acknowledgement:
// "Based on Dos Navigator by RIT Research Labs."
//
// THIS SOFTWARE IS PROVIDED BY RIT RESEARCH LABS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// The licence and distribution terms for any publically available
// version or derivative of this code cannot be changed. i.e. this code
// cannot simply be copied and put under another distribution licence
// (including the GNU Public Licence).
//
//////////////////////////////////////////////////////////////////////////}
{$DEFINE bFMTDBG}
{$DEFINE nFAST}
{$IFnDEF FMTDBG}
Unit Format;
interface
{$ENDIF}
uses Objects,DOS,advance;
Const
cmStatusUpdate = 1990;
stInit = 0;
stAnalyze = 1;
stFormat = 2;
stQuick = 3;
stVerify = 4;
stSystem = 5;
stBoot = 6;
stNone = 255;
fdInsertNewDisk = 0;
fdUserInterrupt = 1;
fdHardwareError = 2;
fdNoDiskInDrive = 3;
fdDiskProtected = 4;
fdNonDosFormat = 5;
fdNQuickFormat = 6;
fdNoSystemFiles = 7;
fdTrack0Bad = 8;
fdBadInterleave = 9;
fdErrorSysAreas =10;
fdDiskFormatted =11;
fdContinue = 0;
fdAbort = 1;
fmFastFormat = 0;
fmDosFormat = 1;
fmSafeFormat = 2;
fmQuickFormat = 3;
fmNonDos = 4;
foSystemDisk = 1;
foUncond = 2;
foMarkTrack = 4;
fooptimize = 8;
iosys : string[10] = 'IBMBIO.COM' ;
mdos : string[10] = 'IBMDOS.COM' ;
iosys1 : string[6] = 'IO.SYS' ;
mdos1 : string[9] = 'MSDOS.SYS' ;
flFormat : String[6] = 'Format' ;
flVerify : String[6] = 'Verify' ;
flWrite : String[6] = 'Write' ;
flRead : String[6] = 'Read' ;
flMode : array [0..4] of String[5] = ('Fast','DOS','Safe','Quick','User');
{360,720,1200,1400,2800 floppy}
const StdTracks : array [1..5] of byte = (40,80,80,80,80);
StdSect : array [1..5] of byte = ( 9,10,15,18,36);
(*
Old8 : Pointer = Nil;
In13 : boolean = False ;
*)
var
Timer : Longint Absolute $40:$6C ;
type
{ erAction = (cmCancel,cmOk);}
Barray = array [0..$F000] of byte;
pBArray = ^BArray;
BootArray = array [28..511] of byte ;
IOpar = record
{_______IOCtl parameter block___ }
ioctlb : byte ; {}
iodev : byte ; {device type = 360K drive}
ioatr : word ; {attributes}
iocil : word ; {cils on drive = 40 tracks}
iomed : byte ; {mdia type}
{_______BPB }
iobps : word ; { bytes per sector }
ioclu : byte ; { cluster size }
iobsz : word ; { BOOT size }
iofcp : byte ; { FAT copyes }
iorsz : word ; { ROOT entries }
iotsc : word ; { total sectors}
iomds : byte ; { media descriptor }
iofat : word ; { sectors per FAT }
iosec : word ; { sectors per track }
iohed : word ; { heads number }
shara : array [0..$FF] of byte ;
end;
{_______BOOT sector record______ }
BootSector = record
bootd : array [1..3] of byte;
blabel : array [1..8] of char;
ssize : word ; { sector size }
csize : byte ; { cluster size }
bsize : word ; { sectors before 1st fat }
fsize : byte ; { FAT copyes }
rsize : word ; { root size }
topsec : word ; { top sector number }
media : byte ; { media descriptor }
fatsz : word ; { total sectors in one FAT }
tsect : word ; { sectors per track }
headc : word ; { heads }
Boot_code : BootArray;
{shara : array [1..374] of byte ;}
end;
DiskBaseTable = record
dbt : byte ; { disk base table. head unload, SRT }
sh001 : byte ; { head load time, DMA transfer method }
sh002 : byte ; { motor wait }
secsiz : byte ; { sector size }
eot : byte ; { max. sector number }
dgap : byte ; { data GAP length }
sh004 : byte ; { DTL }
fgap : byte ; { format GAP length }
fillb : byte ; { fill byte }
sh005 : byte ; { head settle time }
sh006 : byte ; { motor start time }
dnsign : array [1..16] of byte ;
end;
TrackDescriptors = array [1..40,1..4] of byte;
{
c01,h01,n01,s01 : byte;
sh000 : array [0..$1FF] of byte;
end;
}
DirEntrie = record
FileName : array [0..10] of byte;
Attr : byte;
SHARA : array [0..9] of byte;
DateTime : longint;
Cluster : word;
Size : longint;
end;
DirSector = Array [1..16] of DirEntrie ;
SysFile = record
Path : string[80];
Name : string[12];
Size : longint ;
end;
type Pfmt = ^Tfmt;
Tfmt = object(Tobject)
DBT : DiskBaseTable;
OldDbt : Pointer;
{ Old15 : Pointer; }
regs : registers ;
c_Terminate : boolean ;
{_______work data_______________}
bsectd : byte ; { start sector}
btrack : word ; { start track }
tracks : word ; { 0054h ; tracks count}
(* trackb : byte ; { absolute tracks ; } *)
heads : byte ; { heads count }
drvNum : byte ; { drive number }
drvSave : byte ; { saved drive number }
{ sectors : byte ; }
interl : byte ; { interleave num }
shifts : byte ; { sectors shift factor }
shiftt : byte ; { tracks shift factor }
shifth : byte ; { heads shift factor }
t_start : longint ; { timer start }
t_elaps : longint ; { timer elaps }
t_estim : longint ; { estimated timer }
{ Information block - used for output }
{ status information }
i_size : longint ;
i_formatted : longint ;
i_bads : longint ; { bad sectors }
i_operation : String[12] ;
i_track : longint ;
i_head : longint ;
I_SysSpace : longint ;
I_Serial : longint ;
IO_error : word ;
U_ClustSz : byte ; { User - defined }
U_Roots : byte ; { User - defined }
fatkey : byte ; { cluster selection key }
oldclu : byte ; { trapped track descriptor }
fatcvf : byte ; { sectors count buffer }
{ clsize : byte ; clusters size }
medias : byte ; { media descriptor }
set8b : byte ; { low level BIOS info }
set8f : byte ;
set90 : byte ;
set92 : byte ;
fgap1 : byte ;
roots : word ;
dataStart : word ; { 1st sector of data sector }
TotalClusters: word ;
{_______Mode Control_____}
bfkey1 : char ; { direct set bios call }
bfkey2 : char ; { format type }
Verify : char ;
fMode : word ; { format type }
fOptions : word ; { options }
fVlabel : string[11] ;
{_______BOOT SECTOR______}
BootS,Boot1 : BootSector;
Trdsc : TrackDescriptors;
FAT : pBArray;
FATsize : word;
{
FAT : array [0..$11F] of byte;
}
{_______System Files_____}
S_IOSYS , S_MSDOS, S_COMMAND : SysFile;
constructor init;
procedure SetStatus( Status : integer );virtual;
procedure UpdateParams;virtual;
function ScanEvents : boolean ;virtual;
function UserInterrupt : boolean;
function FormatDialog( Code : integer ):integer;virtual;
procedure SetData ;virtual;
procedure SetAdditionalData ;virtual;
(*
procedure set360k;
procedure set720k;
procedure set12m;
procedure set14m;
*)
procedure set28m;
function CheckIOError : byte;
function CheckErrors : boolean;
function GetErrorString( Code : byte ):String;
function GetStatusString( Code : byte ):String;
function GetLimit:longint;
procedure initBoot(var Data); { Fill boot with std params }
procedure initDBT(var Data); { Copy DBT from constants area }
procedure Interleave(trk,head : byte); { make interleave for sectors }
Function Cluster(Sector: Word):Word; { Sector from cluster }
procedure InitFAT; { Init fat by BPB params }
procedure DoneFAT; { Disposes fat }
procedure SetupHardware; { Prepare 4 format }
function SameType : boolean ; { Compare BootS & Boot }
function IsDos : boolean ; { IS Boot1 DOS- disk ? }
procedure CopyQuickBoot ; { Copy BPB form Boot1 2 Boots }
procedure AddFile(Name : string); virtual ;
function CheckFilesOnDisk : boolean ; virtual ;
function formatTrack(trk,head : byte):byte;
function VerifyTrack(trk,head,sec,secnum : byte):byte;
function ReadTrack(trk,head,sec,secnum : byte; var Buf):byte;
function MarkBadSectors(trk,head : byte):word;
function FormatMedia:boolean;
function WriteBootFatRoot : boolean;
procedure CalculateBootFatRoot;
function FindSystemFiles:boolean;
procedure TransferSystem; { Copy system files }
{function getdrv(drv : byte):boolean;} { Actual Drive type 0..5 }
function runFormat:integer; { MAin format proc }
{procedure Int15;}
destructor done;virtual;
end;
function drvtype(drv:byte) : byte;
{$IFnDEF FMTDBG}
implementation uses xTime;
{$ENDIF}
(*
procedure INT8;interrupt;
begin
if In13 then
asm
push es
push ax
sub ax,ax
mov es,ax
push cx
mov cx,2h
@@1:
push cx
pushf
call dword ptr ES:[ 28h * 4 ]
pop cx
loop @@1
pop cx
pop ax
pop es
end;
asm
sub ax,ax
pushf
call dword ptr old8
end;
end;
*)
function MaxAvail: LongInt;
begin
MaxAvail := MemAdjust(System.MaxAvail);
end;
function CopyFile(FFrom,FTo:string):boolean;
var
FromF, ToF: file;
NumRead, NumWritten: Word;
Buf: array[1..4096] of Char;
FATTR : word;
FTIME : longint;
begin
Assign(FromF, FFrom); { Open input file }
GetFattr(FromF,FATTR);
Reset(FromF, 1); { Record size = 1 }
Assign(ToF, Fto ); { Open output file }
Rewrite(ToF, 1); { Record size = 1 }
repeat
BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
BlockWrite(ToF, Buf, NumRead, NumWritten);
until (NumRead = 0) or (NumWritten <> NumRead);
GetFtime(FromF,FTime);
GetFattr(FromF,FATTR);
SetFtime(ToF,FTime);
Close(FromF);
Close(ToF);
Assign(ToF, Fto ); { Open output file }
SetFattr(ToF,FATTR);
end;
function FileExists(FileName: String): Boolean;
{ Boolean function that returns True if the file exists;otherwise,
it returns False. Closes the file if it exists. }
var
F: file;
begin
{$I-}
Assign(F, FileName);
FileMode := 0; { Set file access to read only }
Reset(F);
Close(F);
{$I+}
FileExists := (IOResult = 0) and (FileName <> '');
end; { FileExists }
procedure GetAbsSector(relSector:Word; BootS : BootSector;
Var track,head,phsector:byte);
var RelTrk : word;
begin
With Boots do
begin
PhSector:= Succ(RelSector mod TSect);
RelTrk := RelSector div TSect;
track := RelTrk div headc;
head := RelTrk mod headc;
end;
end;
Function GetLogSector(Head,Track,Sector : Word;
BootS : BootSector ) : Word;
begin
with Boots Do
GetLogSector := Track * headc * tsect +
Head * tsect +
Pred(Sector) ;
end;
function MoreDiv(A,B : word):word;
begin
MoreDiv := A div B + byte((A mod B) > 0);
end;
procedure Tfmt.initDBT;assembler;
asm
push ds
les di,DATA
mov si,offset @@DBT
mov ax,cs
mov ds,ax
mov cx,9
cld
rep movsw
pop ds
jmp @@done
@@DBT: db 0dfh { disk base table. head unload, SRT }
db 002h { head load time, DMA transfer method }
db 025h { motor wait }
db 002h { sector size }
db 009h { max. sector number }
db 01bh { data GAP length }
db 0ffh { DTL }
db 002h { format GAP length }
db 0f6h { fill byte }
db 00fh { head settle time }
db 004h { motor start time }
db 'DN II Par table'
@@done:
{
disk10:paratyp=($df,$02,$25,$02,10,$1b,$ff,$2e,$F6,$0f,$04);
}
end;
procedure Tfmt.initBoot;assembler;
asm
push ds
les di,data
mov si,offset @@Boot
mov ax,cs
mov ds,ax
mov cx,$100
cld
rep movsw
pop ds
jmp @@done
@@BOOT: db 0EBh,042h,090h
db 'Vaccined',000h
db 02h { sector size }
db 02h { cluster size }
dw 00001h { boot size }
db 02h { sectors per FAT }
dw 00070h { root size }
dw 00b40h { top sector number }
db 0f0h { media descriptor }
dw 00009h { fat size }
dw 0012h { sectors per track }
dw 0002h { heads }
db 000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,044h,04Eh,020h,046h,04Fh
db 052h,04Dh,041h,054h,049h,049h,046h,041h
db 054h,031h,032h,020h,020h,020h,02Eh,080h
db 026h,090h,004h,0DFh,0FAh,0FCh,033h,0C0h
db 08Eh,0D0h,0BCh,000h,07Ch,016h,007h,0BBh
db 078h,000h,036h,0C5h,037h,01Eh,056h,0BFh
db 02Bh,07Ch,0B9h,00Bh,000h,0F3h,0A4h,006h
db 01Fh,0C6h,045h,0FEh,00Fh,0C6h,045h,0F9h
db 016h,089h,047h,002h,0C7h,007h,02Bh,07Ch
db 0FBh,0CDh,013h,072h,06Bh,0BAh,000h,0F0h
db 033h,0EDh,0E8h,0CDh,000h,022h,073h,004h
db 0C7h,005h,0A5h,0FEh,0E8h,0C3h,000h,026h
db 073h,004h,0C7h,005h,087h,0E9h,0E8h,0B9h
db 000h,05Eh,073h,004h,0C7h,005h,0D2h,0EFh
db 0E8h,0AFh,000h,072h,073h,004h,0C7h,005h
db 053h,0FFh,0B6h,0C8h,0E8h,0A3h,000h,04Eh
db 073h,002h,0A5h,0A5h,04Dh,073h,021h,0BEh
db 0DCh,07Dh,0E8h,08Fh,000h,098h,0CDh,016h
db 03Ch,06Eh,074h,014h,0B9h,001h,000h,0BAh
db 000h,000h,0B7h,07Ch,0B8h,001h,003h,00Eh
db 007h,0CDh,013h,0EAh,0F0h,0FFh,000h,0F0h
db 0B9h,006h,000h,0BAh,000h,000h,0BBh,000h
db 005h,0B8h,001h,002h,0CDh,013h,073h,013h
db 0BEh,09Fh,07Dh,0E8h,05Eh,000h,098h,0CDh
db 016h,08Fh,006h,078h,000h,08Fh,006h,07Ah
db 000h,0CDh,019h,080h,07Fh,00Bh,004h,074h
db 0E7h,0BEh,02Ch,000h,0B7h,007h,0B9h,004h
db 000h,0B6h,001h,0A1h,018h,07Ch,02Ah,0C1h
db 040h,03Bh,0F0h,077h,002h,08Bh,0C6h,050h
db 0B4h,002h,0CDh,013h,058h,072h,0C9h,098h
db 02Bh,0F0h,076h,014h,002h,0F8h,002h,0F8h
db 0B1h,001h,0FEh,0C6h,03Ah,036h,01Ah,07Ch
db 072h,0D9h,0FEh,0C5h,0B6h,000h,0EBh,0D3h
db 08Ah,02Eh,015h,07Ch,0B2h,000h,0BBh,00Ch
db 000h,0B8h,000h,000h,0EAh,000h,000h,070h
db 000h,0E8h,04Fh,000h,0ACh,00Ah,0C0h,075h
db 0F8h,0C3h,05Eh,0ACh,056h,098h,097h,026h
db 039h,015h,073h,047h,0BEh,0D1h,07Dh,0E8h
db 0EAh,0FFh,08Bh,0C7h,0D0h,0E8h,0D0h,0E8h
db 0E8h,01Fh,000h,0B0h,02Dh,0E8h,02Bh,000h
db 08Bh,005h,0E8h,00Ch,000h,0B0h,03Ah,0E8h
db 021h,000h,089h,015h,083h,0EFh,002h,08Bh
db 005h,08Ah,0E8h,08Ah,0C4h,0E8h,002h,000h
db 08Ah,0C5h,050h,0B1h,004h,0D2h,0E8h,0E8h
db 001h,000h,058h,024h,00Fh,004h,090h,027h
db 014h,040h,027h,033h,0DBh,0B4h,00Eh,0CDh
db 010h,045h,0F9h,0C3h,000h,000h,000h,00Ah
db 00Dh,04Eh,06Fh,020h,073h,079h,073h,074h
db 065h,06Dh,020h,06Fh,072h,020h,064h,069h
db 073h,06Bh,020h,065h,072h,072h,06Fh,072h
db 00Ah,00Dh,050h,072h,065h,073h,073h,020h
db 061h,020h,06Bh,065h,079h,020h,074h,06Fh
db 020h,072h,065h,074h,072h,079h,00Ah,00Dh
db 000h,007h,00Ah,00Dh,049h,06Eh,074h,000h
db 059h,0ECh,000h,0F0h,00Ah,00Dh,056h,069h
db 072h,075h,073h,020h,073h,074h,065h,072h
db 069h,06Ch,069h,07Ah,065h,064h,02Eh,020h
db 043h,075h,072h,065h,020h,042h,04Fh,04Fh
db 054h,03Fh,00Ah,00Dh,007h,000h,055h,0AAh
@@done:
end;
procedure tfmt.SetStatus;
begin
{ Setup Status }
end;
function tfmt.ScanEvents;
begin
scanEvents := False;
end;
procedure tfmt.UpdateParams;
begin
{ Params changed }
{ More Bad Sectors, etc }
end;
function tfmt.FormatDialog;
begin
{ Write(' Error Occured... (A)bort or (C)ontinue'); }
{ Error := acContinue; }
{
case Code of
end;
}
end;
procedure tfmt.SetAdditionalData;
begin
{ Update optimize information }
end;
procedure tfmt.initFat;
begin
with BootS do begin
FATsize := longint(FATSZ)*longint(SSize);
if (FATsize> $8000) or (FatSize>MaxAvail) then exit;
GetMem(FAT,FatSize);
if FAT <> Nil then
begin
FillChar(FAT^,FatSize,0);
FAT^[0] := Media;
FAT^[1] := $FF;
FAT^[2] := $FF;
end;
end { with }
end;
procedure tfmt.DoneFat;
begin
if FAT<>Nil then FreeMem(FAT,FATSize);
end;
(*
procedure Tfmt.set360k;
begin
with BootS do begin
tracks := 40; { tracks amount }
tsect := 9; { sectors / track }
rsize := $70; { root size }
U_ClustSZ := 2; { sectors / claster }
medias := $FD; { media descriptor }
bfkey1 := 'd';
end;
end;
procedure Tfmt.set720k;
begin
with BootS do begin
tracks := 80; { tracks amount }
tsect := 9; { sectors / track }
rsize := $70; { root size }
U_ClustSZ := 2; { sectors / claster }
medias := $F9; { media descriptor }
bfkey1 := 'd';
end;
end;
procedure Tfmt.set12m;
begin
with BootS do begin
tracks := 80; { tracks amount }
tsect := 15; { sectors / track }
rsize := $E0; { root size }
U_ClustSZ := 1; { sectors / claster }
medias := $F9; { media descriptor }
bfkey1 := 'd';
end;
end;
procedure Tfmt.set14m;
begin
with BootS do begin
tracks := 80; { tracks amount }
tsect := 18; { sectors / track }
rsize := $E0; { root size }
U_ClustSZ := 1; { sectors / claster }
medias := $F0; { media descriptor }
bfkey1 := 'd';
end;
end;
*)
procedure Tfmt.set28m;
begin
with BootS do begin
tracks := 80; { tracks amount }
tsect := 36; { sectors / track }
rsize := $E0; { root size }
U_ClustSZ := 1; { sectors / claster }
medias := $F0; { media descriptor }
fgap1 := $74; { set gap length }
bfkey1 := 'd';
end;
end;
Constructor Tfmt.init;
begin
inherited init;
{ initialize internal structures }
initBoot(BootS);
initDBT(DBT);
{ set disk parameter table }
GetIntVec($1E,olddbt);
SetIntVec($1E,@DBT);
(*
GetIntVec($8,old8);
SetIntVec($8,Addr(int8));
*)
bfkey1 := ' ';
bfkey2 := ' ';
FAT := nil;
DrvSave := $FF ;
SetData;
if not DrvSave in [1..5,$FF] then Fail;
if DrvSave = $FF then
DrvSave := DrvType(DrvNum);
end;
Destructor Tfmt.done;
begin
{ restore disk parameter table }
SetIntVec($1E,olddbt);
(*
with regs do
begin
DL := drvnum; { drive }
DH := Pred(Heads);
AH := $18; { set media type }
CH := Lo(Stdtracks[DrvSave]); { tracks }
CL := STdsect[DrvSave]; { sectors per track }
intr($13,regs);
end;
*)
(*
SetIntVec($8,old8) ;
*)
with regs do
begin
{
BL := Succ(drvnum);
AX := $440F ;
intr($21,Regs);
}
DL := drvnum;
AX := 0;
Intr($13,Regs);
BL := Succ(drvnum);
AX := $440F ;
intr($21,Regs);
end;
inherited done;
end;
function drvtype;
var MaxC : word;
MaxS : byte;
Driv : byte;
Ioctl : Iopar ;
label
NotOK ;
function GetDrv(Drv:Byte):boolean;
var
Attr : byte ;
regs : registers;
begin
GetDrv := False ;
with IoCtl , Regs do begin
ax:=$4409;
bl:=Succ(DRV );
bh:=0;
intr($21,regs);
if (FCarry and Flags) <> 0 then exit;
if (dx and $9200)<>0 then exit;
ax:=$440e;
bl:=Succ(Drv);
bh:=0;
intr($21,regs);
if (FCarry and Flags)<>0 then exit;
Attr := al;
ax:=$440f;
bl:=Succ(Drv);
bh:=0;
intr($21,regs);
if (FCarry and Flags)<>0 then Exit;
IoCtlB := 0;
ax:=$440d;
cx:=$860;
bl:=Succ( Drv );
bh:=0;
dx:=ofs(IoCtlB);
ds:=seg(IoCtlB);
intr($21,regs);
if Not IoDev in [0,1,2,7] then Exit;
if Attr <> 0 then
begin
bh:=0;
ax:=$440f;
bl:=Attr;
intr($21,regs);
end;
GetDrv := True ;
end; { with regs }
end; { proc }
begin
if GetDrv( Drv )
then
with IOCtl do
begin
case IODev of
0 : DrvType := 1;
1 : DrvType := 3;
2 : DrvType := 2;
7 : begin
if IoSec >= 23
Then DrvType := 5
else DrvType := 4;
end;
end; { Case }
Exit ;
end; { IOCTL }
asm
mov dl,drv
mov ah,08h {; get disk parameters}
int 13h {; call BIOS service }
jc NotOk
mov Driv,BL { only for AT & PS/2 }
mov ax,cx
xchg ah,al
mov ch,cl
mov cl,6
shr ah,cl
mov maxc ,ax
and ch,$3F
mov maxs ,ch
end;
if maxc <= 48 then
begin { 360 floppy }
drvtype := 1; exit;
end;
if maxs >= 23 then
begin { 288 floppy }
drvtype := 5; exit;
end;
if maxs >= 18 then
begin { 144 floppy }
drvtype := 4; exit;
end;
if maxs >= 13 then
begin { 12 floppy }
drvtype := 3; exit;
end;
{ 720 floppy }
drvtype := 2; exit;
NotOK : drvtype := 0;
end;
(*
procedure tfmt.getdrv;
var ioctlb : IOpar ;
maxc : word;
maxs : byte;
ioctl : byte;