forked from christoh/fdformat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
XFORMAT.PAS
1347 lines (1302 loc) · 52.7 KB
/
XFORMAT.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
{$A+,B-,D+,E+,F-,L+,N-,O-,R-,S-,V-}
{$M 8192,0,0}
PROGRAM XFORMAT;
USES dos,auxdos,baseconv,desqview;
{Copyright (c) 1988-91, Christoph H. Hochst„tter & 2024 Alex313031}
{Donated to the Public-Domain for non-commercial usage}
{Compiled in Turbo-Pascal 6.0}
{$IFDEF L49}
CONST text01 = 'Fehler ';
CONST text02 = '(A)bbrechen (W)iederholen (I)gnorieren ? ';
CONST t3 = 'W';
CONST text04 = 'Kein gltiges Laufwerk.';
CONST text05 = 'SUBST/ASSIGN/Netzwerk-Laufwerk.';
CONST text06 = 'Nicht Floppy-Laufwerk! INT18h';
CONST text07 = 'V”llig unbekannte Laufwerksart';
CONST text08 = 'Ich formatiere Laufwerk ';
CONST text09 = ' Seite(n), ';
CONST text10 = ' Spuren, ';
CONST text11 = ' Sektoren/Spur, ';
CONST text12 = ' Basisverzeichniseintr„ge, ';
CONST text13 = ' Sektor(en)/Cluster, Sektoren-Versatz: ';
CONST text14 = 'Kopf: ';
CONST text15 = ', Zylinder: ';
CONST text17 = 'Formatierfehler im Systembereich: Programm abgebrochen.';
CONST text18 = 'Mehr als ';
CONST text19 = ' Sektoren nicht lesbar. Programm abgebrochen.';
CONST text20 = ' als schlecht markiert';
CONST text21 = 'Format-Identifizierung: ';
CONST text22 = 'Gesamtsektoren auf der Diskette: ';
CONST text23 = 'Sektoren pro Spur: ';
CONST text24 = 'Schreib-/Lesek”pfe: ';
CONST text25 = 'Bytes pro Sektor: ';
CONST text26 = 'Versteckte Sektoren: ';
CONST text27 = 'Boot-Sektoren: ';
CONST text28 = 'Anzahl der FAT''s: ';
CONST text29 = 'Sektoren pro FAT: ';
CONST text30 = 'Cluster auf Diskette: ';
CONST text79 = 'Disketten-Seriennummer: ';
CONST text34 = 'Dieses Laufwerk kann nicht formatiert werden.';
CONST text35 = 'Laufwerk ist physisch ';
CONST text36 = 'BIOS Umschaltung 40/80 Spuren: ';
CONST text37 = 'nach XT-Standard';
CONST text38 = 'nach EPSON QX-16 Standard';
CONST text39 = 'nach AT-Standard';
CONST text40 = 'wird nicht untersttzt';
CONST text41 = 'Syntax Error beim Aufruf.';
CONST text42 = 'Format ist: xformat drive: [Optionen]';
CONST text43 = ' Beispiel: xformat a: /u /f:1.48 > Führt ein bedingungsloses 1.48Mb format aus';
CONST text44 = 'Parameter Bedeutung Voreinstellung';
CONST text45 = 'drive: Laufwerk, das formatiert werden soll ----';
CONST text46 = 'Tnn Anzahl der Spuren je Seite 40/80 je nach Laufwerk';
CONST text47 = 'Hnn Anzahl der Seiten 2';
CONST text48 = 'Nnn Anzahl der Sektoren je Spur 9/15/18 je nach Laufwerk';
CONST text49 = 'Cn Anzahl der Sektoren je Cluster 1 bei HD, 2 bei DD';
CONST text50 = 'Dnnn Anzahl der Basisverzeichniseintr„ge 224 bei HD, 112 bei DD';
CONST text51 = 'Inn Interleave-Faktor 1';
CONST text52 = 'Fnnn Format festlegen';
CONST text53 = 'R Formatierung nicht verifizieren';
CONST text69 = 'Bnnn Diskettentypbyte festlegen je nach Format';
CONST text70 = 'Gnnn GAP-L„nge festlegen je nach Format';
CONST text71 = 'Lesen Sie die FDFORMAT.DOC Datei fr weitere Optionen';
CONST text54 = 'Dieses Programm ben”tigt mindestens DOS 3.20.';
{$IFOPT G+}
CONST text55 = 'XFORMAT/286 - Formatieren von Disketten mit erh”hter Kapazit„t';
{$ELSE}
CONST text55 = 'XFORMAT/88 - Formatieren von Disketten mit erh”hter Kapazit„t';
{$ENDIF}
CONST text56 = 'Urheberrechte (c) 2024 Alex313031. Ver. 1.9';
CONST text57 = 'Sie k”nnen nur 1 oder 2 Seiten nehmen.';
CONST text58 = 'Sie sollten schon mindestens eine Spur formatieren.';
CONST text59 = 'Interleave muá von 1-';
CONST text60 = ' sein.';
CONST text61 = 'WARNUNG! DOS verwaltet bei Disketten nur 1 oder 2 Sektoren/Cluster';
CONST text62 = 'WARNUNG! Zu viele Spuren. Das kann Ihr Laufwerk besch„digen';
CONST text63 = 'WARNUNG! DOS verwaltet bei Disketten maximal 240 Basisverzeichniseintr„ge';
CONST text64 = 'Neue Diskette in Laufwerk ';
CONST text65 = ': einlegen';
CONST text66 = 'Anschlieáend ENTER drcken (ESC=Abbruch)';
CONST text67 = 'šbertragungsrate: ';
CONST text68 = ', GAP-L„nge: ';
CONST text72 = 'EIN';
CONST text73 = 'AUS';
CONST text74 = 'Bitte Diskettennamen eingeben (max. 11 Zeichen): ';
CONST text75 = 'Fehler beim Erstellen des Namens.';
CONST text76 = 'Syntax-Fehler in der Datei XFORMAT.CFG.';
CONST text77 = 'Lesefehler in der Datei XFORMAT.CFG.';
CONST text78 = ', Sektoren: ';
CONST text80 = 'Fehler beim Aufbau eines neuen Disk-Parameter-Blocks. DOS-Fehler: ';
CONST text81 = 'Altes Format kann nicht gelesen werden. Formatieren ohne l”schen nicht m”glich.';
CONST text31 = ' formatierte Bytes gesamt';
CONST text32 = ' Bytes im Boot-Sektor';
CONST text33 = ' Bytes im Basis-Verzeichnis';
CONST text82 = ' Bytes in der FAT';
CONST text83 = ' Bytes in schlechten Sektoren';
CONST text84 = ' Bytes frei fuer Dateien';
CONST text85 = ' Bytes tats„chlich frei';
CONST text86 = 'Setze Laufwerksparameter ber Spur/Sektor-Kombination...';
CONST text87 = 'Setze Laufwerksparameter ber Diskettentyp...';
CONST text88 = 'erfolgreich';
CONST text89 = 'Fehler';
CONST text90 = 'WARNUNG! BIOS-Media-Byte konnte nicht korrekt gesetzt werden.';
CONST text91 = 'BIOS-Media-Byte ist: ';
CONST text92 = 'x, Soll: ';
CONST text93 = 'Laufwerksparameter durch direktes Schreiben des BIOS-Media-Bytes gesetzt.';
CONST text94 = 'Programmabbruch durch den Benutzer.';
CONST error01 = 'Falsches Disketten-Steuer-Kommando';
CONST error02 = 'Formatierung nicht gefunden';
CONST error03 = 'Diskette ist schreibgeschtzt';
CONST error04 = 'Sektor nicht gefunden';
CONST error06 = 'Unerlaubter Diskettenwechsel';
CONST error08 = 'DMA-Baustein bergelaufen';
CONST error09 = 'Mehr als 64 kByte im DMA Baustein';
CONST error0c = 'Format nicht kompatibel mit Datenbertragungsrate';
CONST error10 = 'Zyklische Redundanzprfung fehlerhaft';
CONST error20 = 'Diskettenadapter fehlerhaft';
CONST error40 = 'Laufwerkskopf konnte nicht positioniert werden';
CONST error80 = 'Keine Diskette im Laufwerk oder falsch eingelegt';
CONST errorxx = 'Fehlerursache unbekannt';
{$ENDIF}
{$IFDEF L1}
CONST text01 = 'Error ';
CONST text02 = '(A)bort (R)etry (I)gnore ? ';
CONST t3 = 'R';
CONST text04 = 'No valid drive.';
CONST text05 = 'SUBST/ASSIGN/Network-Drive.';
CONST text06 = 'Not a floppy drive! INT18h';
CONST text07 = 'Unknown drive type.';
CONST text08 = 'Formatting drive ';
CONST text09 = ' Head(s), ';
CONST text10 = ' Tracks, ';
CONST text11 = ' Sectors/track, ';
CONST text12 = ' Root Directory Entries, ';
CONST text13 = ' Sector(s)/Cluster, Sector-Shift: ';
CONST text14 = 'Head: ';
CONST text15 = ', Cylinder: ';
CONST text17 = 'Format error in system area: Program aborted.';
CONST text18 = 'More than ';
CONST text19 = ' sectors unreadable. Program aborted.';
CONST text20 = ' marked as bad';
CONST text21 = 'OEM-Entry: ';
CONST text22 = 'Total sectors on disk: ';
CONST text23 = 'Sectors per track: ';
CONST text24 = 'Heads: ';
CONST text25 = 'Bytes per sector: ';
CONST text26 = 'Hidden sectors: ';
CONST text27 = 'Boot-sectors: ';
CONST text28 = 'Number of FATs: ';
CONST text29 = 'Sectors per FAT: ';
CONST text30 = 'Total clusters on disk: ';
CONST text79 = 'Volume serial number: ';
CONST text34 = 'This drive cannot be formatted.';
CONST text35 = 'Drive is physical ';
CONST text36 = 'BIOS double-step support: ';
CONST text37 = 'XT-like';
CONST text38 = 'EPSON QX-16 like';
CONST text39 = 'AT-like';
CONST text40 = 'Not available or unknown';
CONST text41 = 'Syntax Error.';
CONST text42 = 'Usage is: xformat drive: [options]';
CONST text43 = ' Example: xformat a: /u /f:1.48 > Performs an unconditional 1.48Mb format';
CONST text44 = 'Option Meaning Default';
CONST text45 = 'drive: drive to be formatted none';
CONST text46 = 'Tnn Number of tracks 40/80 depends on drive';
CONST text47 = 'Hnn Number of heads 2';
CONST text48 = 'Nnn Number of sectors per track 9/15/18 depends on drive';
CONST text49 = 'Cn Number of sectors per cluster 1 for HD, 2 for DD';
CONST text50 = 'Dnnn Number of root directory entries 224 for HD, 112 for DDD';
CONST text51 = 'Inn Interleave 1';
CONST text52 = 'F specify Diskette format';
CONST text53 = 'R Skip verifying';
CONST text69 = 'Bnnn Force a specified Format-Descriptor depends on format';
CONST text70 = 'Gnnn Use specified GAP-Length depends on format';
CONST text71 = 'See the FDFORMAT.DOC file for other options';
CONST text54 = 'This program requires DOS 3.2 or higher.';
{$IFOPT G+}
CONST text55 = 'XFORMAT/286 - Disk Formatter for High Capacity Disks - Ver 1.9';
{$ELSE}
CONST text55 = 'XFORMAT/88 - Disk Formatter for High Capacity Disks - Ver 1.9';
{$ENDIF}
CONST text56 = 'Copyright (c) 2024 Alex313031. Ver. 1.9';
CONST text57 = 'Heads must be 1 or 2.';
CONST text58 = 'At least one track should be formatted.';
CONST text59 = 'Interleave must be from 1 to ';
CONST text60 = '.';
CONST text61 = 'WARNING! DOS supports only 1 or 2 sectors per cluster.';
CONST text62 = 'WARNING! That many tracks could cause damage to your drive.';
CONST text63 = 'WARNING! DOS supports a maximum of 240 root directory entries.';
CONST text64 = 'Insert new Diskette in drive ';
CONST text65 = ':';
CONST text66 = 'Press ENTER when ready (ESC=QUIT)';
CONST text67 = 'Data Transfer Rate: ';
CONST text68 = ', GAP-Length: ';
CONST text72 = 'ON';
CONST text73 = 'OFF';
CONST text74 = 'Enter Volume Name (max. 11 characters): ';
CONST text75 = 'Error creating volume label.';
CONST text76 = 'Syntax Error in XFORMAT.CFG.';
CONST text77 = 'Error reading XFORMAT.CFG.';
CONST text78 = ', Sectors: ';
CONST text80 = 'Error building new disk-parameter-block. DOS-Error: ';
CONST text81 = 'Cannot read old diskette parameters. Format without erase impossible.';
CONST text31 = ' Bytes total';
CONST text32 = ' Bytes in boot-sector';
CONST text33 = ' Bytes in Root-Directory';
CONST text82 = ' Bytes in the FAT';
CONST text83 = ' Bytes in bad sectors';
CONST text84 = ' Bytes available for files';
CONST text85 = ' Bytes actually free';
CONST text86 = 'Setting drive parameters via track/sector-combination...';
CONST text87 = 'Setting drive parameters via media typ...';
CONST text88 = 'successful';
CONST text89 = 'Error';
CONST text90 = 'WARNING! BIOS-Media-Byte could not set correctly.';
CONST text91 = 'BIOS-media-byte is: ';
CONST text92 = 'x, should be: ';
CONST text93 = 'drive parameters set via direct write to BIOS-media-byte.';
CONST text94 = 'Program aborted by user.';
CONST error01 = 'Illegal Command. Bug in XFORMAT';
CONST error02 = 'Address mark not found';
CONST error03 = 'Disk is write protected';
CONST error04 = 'Sector not found';
CONST error06 = 'Illegal disk change';
CONST error08 = 'DMA overrun';
CONST error09 = 'DMA accross 64 kB boundary';
CONST error0c = 'Format not compatible with data transfer rate';
CONST error10 = 'CRC error';
CONST error20 = 'controller/adapter error';
CONST error40 = 'seek error';
CONST error80 = 'No disk in drive';
CONST errorxx = 'Unknown error';
{$ENDIF}
CONST maxform = 20;
TYPE tabletyp = ARRAY[1..25] OF RECORD
t,h,s,f:Byte;
END;
paratyp = ARRAY[0..10] OF Byte;
boottyp = ARRAY[62..511] OF Byte;
btttyp = ARRAY[1..20] OF RECORD
head: Byte;
track: Byte;
END;
ftabtyp = ARRAY[1..maxform] OF RECORD
fmt: Word;
trk: Byte;
sec: Byte;
hds: Byte;
END;
bpbtyp = RECORD
jmp: ARRAY[1..3] OF Byte; {Die ersten drei Bytes fr JUMP}
oem: ARRAY[1..8] OF Char; {OEM-Eintrag}
bps: Word; {Bytes pro Sektor}
spc: Byte; {Sektoren pro Cluster}
res: Word; {BOOT-Sektoren}
fat: Byte; {Anzahl der FAT's}
rde: Word; {Basisverzeichniseintr„ge}
sec: Word; {Gesamtsektoren der Diskette}
mds: Byte; {Media-Deskriptor}
spf: Word; {Sektoren pro FAT}
spt: Word; {Sektoren pro Spur}
hds: Word; {Seiten}
shh: LongInt; {Versteckte Sektoren}
lse: LongInt; {Lange Anzahl der Sektoren}
pdn: Word; {Physical Drive Number}
ebs: Byte; {Extended Boot Signature}
vsn: LongInt; {Volume Serial-Number}
vlb: ARRAY[1..11] OF Char; {Volume Label}
fsi: ARRAY[1..8] OF Char; {File System Id}
boot_code: boottyp; {Puffer fr BOOT-Code}
END;
bdib = RECORD
flag : Byte; {Bitmapped flags}
dtyp : Byte; {Drive Type: 0,1,2 or 7 supported by XFORMAT}
dflag : Word; {Bitmapped flags}
noc : Word; {Number of cylinders}
mt : Byte; {Media Type}
bpb : ARRAY[0..30] OF Byte; {BPB}
nos : Word; {Number of sectors per track}
sly : ARRAY[0..4598] OF RECORD {sector layout}
num: Word; {Sector Number}
siz: Word; {Size of sector}
END;
END;
VAR regs: registers; {Prozessor-Register}
track: Byte; {Aktuelle Spur}
head: Byte; {Aktuelle Seite}
table: tabletyp; {Formatierungs-Tabelle}
table2: ARRAY[1..25] OF Byte; {Interleave-Tabelle}
x: Word; {Hilfsvariable}
buffer: ARRAY[0..18435] OF Byte; {Puffer fr eingelesene Sektoren}
old1E: Pointer; {Alter Zeiger auf die Parameterliste}
new1E: ^paratyp; {Neuer Zeiger auf die Parameterliste}
old13: Pointer; {Alter Zeiger auf Interrupt 13}
chx: Char; {Hilfsvariable}
lw: Byte; {Ausgew„hltes Laufwerk}
hds,sec: Word; {Anzahl der Seiten, Sektoren}
trk: Word; {Anzahl der Spuren}
hd,lwhd: Boolean; {High-Density Flags}
lwtrk: Byte; {maximale Spuren des Laufwerks}
lwsec: Byte; {maximale Sektoren des Laufwerks}
para: ARRAY[1..50] OF String[20]; {Parameter von der Kommandozeile}
rde: Byte; {Basisverzeichniseintr„ge}
spc: Byte; {Sektoren pro Cluster}
i: Byte; {Hilfsvariablen}
j,n: Integer; {Hilfsvariable}
again: Boolean; {Flag, ob INT 13 nochmal kommen muá}
bttCount: Word; {Anzahl der schlechten Spuren}
btt: btttyp; {Tabelle der schlechten Spuren}
Offset: Word; {Relative Position im FAT}
Mask: Word; {Maske fr schlechten Cluster}
bytes: LongInt; {Bytes Gesamtkapazit„t}
bytesub: LongInt; {Bytes, die von der Gesamtkapazit„t subtrahiert werden}
at80: Boolean; {TRUE, wenn 80/40 Spur nach AT-BIOS}
DiskId: Byte; {Disketten-Format-Beschreibung fr AT-BIOS}
il: Byte; {Interleave-Faktor}
gpl: Byte; {GAP-L„nge}
shiftt: Byte; {Sektor-Shifting fr Spuren}
shifth: Byte; {Sektor-Shifting fr K”pfe}
ModelByte: Byte ABSOLUTE $F000:$FFFE; {XT/AT/386}
ForceType: Byte; {Gezwungener Diskid}
ForceMedia: Byte; {Erzwungener Media-Deskriptor}
dosdrive: Byte; {DOS-Laufwerks-Identifizierer}
PCount: Byte; {Anzahl der Parameter}
found: Boolean; {Format gefunden}
sys: Boolean; {System initialisieren}
lwtab: ARRAY[0..3] OF Byte ABSOLUTE $40:$90; {Tabelle der Laufwerke}
dlabel: String[15]; {Disketten-Label}
setlabel: Boolean; {Label setzen}
batch: Boolean; {Ohne Tastatur-Abfrage}
cfgat80: Boolean; {TRUE, wenn Laufwerk fr AT konfiguriert}
cfgpc80: Boolean; {TRUE, wenn Laufwerk fr XT konfiguriert}
cfgdrive: Byte; {Laufwerksart aus Konfiguration}
bios: Boolean; {TRUE, wenn nur BIOS-Aufrufe}
pc80: Byte; {Maske, fr 80 Spur nach XT-BIOS}
pc40: Byte; {Maske, fr 80 Spur nach XT-BIOS}
v720: Byte; {Media-Typ fr 720 kByte}
v360: Byte; {Media-Typ fr 360 kByte}
v12: Byte; {Media-Typ fr 1.2 MByte}
v144: Byte; {Media-Typ fr 1.44 MByte}
lwphys: Byte; {Physikalisches Laufwerk}
NormExit: Pointer; {Normale Exit-Procedure}
CONST para17: paratyp =($df,$02,$25,$02,17,$02,$ff,$23,$f6,$0f,$08);
para18a: paratyp =($df,$02,$25,$02,18,$02,$ff,$02,$f6,$0f,$08);
para18: paratyp =($df,$02,$25,$02,18,$02,$ff,$6c,$f6,$0f,$08);
para10: paratyp =($df,$02,$25,$02,10,$02,$ff,$2e,$f6,$0f,$08); {GPL 26-36}
para11: paratyp =($df,$02,$25,$02,11,$02,$ff,$02,$f6,$0f,$08);
para15: paratyp =($df,$02,$25,$02,15,$02,$ff,$54,$f6,$0f,$08);
para09: paratyp =($df,$02,$25,$02,09,$02,$ff,$50,$f6,$0f,$08);
para08: paratyp =($df,$02,$25,$02,08,$02,$ff,$58,$f6,$0f,$08);
para20: paratyp =($df,$02,$25,$02,20,$02,$ff,$2a,$f6,$0f,$08); {GPL 17-33}
para21: paratyp =($df,$02,$25,$02,21,$02,$ff,$0c,$f6,$0f,$08);
para22: paratyp =($df,$02,$25,$02,22,$02,$ff,$01,$f6,$0f,$08);
ftab: ftabtyp = ((fmt:160;trk:40;sec:8;hds:1), {Requires 180 kByte Drive}
(fmt:180;trk:40;sec:9;hds:1), {Requires 180 kByte Drive}
(fmt:200;trk:40;sec:10;hds:1), {Requires 180 kByte Drive}
(fmt:205;trk:41;sec:10;hds:1), {Requires 180 kByte Drive}
(fmt:320;trk:40;sec:8;hds:2), {Requires 360 kByte Drive}
(fmt:360;trk:40;sec:9;hds:2), {Requires 360 kByte Drive}
(fmt:400;trk:40;sec:10;hds:2), {Requires 360 kByte Drive}
(fmt:410;trk:41;sec:10;hds:2), {Requires 360 kByte Drive}
(fmt:720;trk:80;sec:9;hds:2), {Requires 720 kByte Drive}
(fmt:800;trk:80;sec:10;hds:2), {Requires 720 kByte Drive}
(fmt:820;trk:82;sec:10;hds:2), {Requires 720 kByte Drive}
(fmt:120;trk:80;sec:15;hds:2), {Requires 1.2 MByte Drive}
(fmt:12;trk:80;sec:15;hds:2), {Requires 1.2 MByte Drive}
(fmt:144;trk:80;sec:18;hds:2), {Requires 1.2 MByte Drive}
(fmt:14;trk:80;sec:18;hds:2), {Requires 1.2 MByte Drive}
(fmt:148;trk:82;sec:18;hds:2), {Requires 1.2 MByte Drive}
(fmt:16;trk:80;sec:20;hds:2), {Requires 1.4 MByte Drive}
(fmt:164;trk:82;sec:20;hds:2), {Requires 1.4 MByte Drive}
(fmt:168;trk:80;sec:21;hds:2), {Requires 1.4 MByte Drive}
(fmt:172;trk:82;sec:21;hds:2)); {Requires 1.4 MByte Drive}
swchar: Char ='/'; {Default-Switch-Char}
Quick: Boolean =False; {Quick-Format}
noformat: Boolean =True; {Don't really format}
noverify: Boolean =False; {Don't verify}
fwe: Boolean =False; {Format without erase}
bad: LongInt =0; {Bytes in schlechten Sektoren}
ExitRequest: Boolean =False; {Abbruchsanforderung}
PROCEDURE GetPhys; Far; Assembler;
ASM
push ds
{$IFOPT G-}
mov ax,Seg @data
mov ds,ax
{$ENDIF}
{$IFOPT G+}
push Seg @data
pop ds
{$ENDIF}
mov ds:lwphys,dl
pop ds
mov ax,101h
iret
END;
CONST bpb: bpbtyp = (
jmp : ($EB,$40,$90);
oem : 'CH-FOR18';
bps : 512;
spc : 0;
res : 1;
fat : 2;
rde : 0;
sec : 0;
mds : 0;
spf : 0;
spt : 0;
hds : 2;
shh : 0;
lse : 0;
pdn : 0;
ebs : $29;
vsn : 0;
vlb : ' ';
fsi : 'FAT12 ';
boot_code: (
{$IFDEF L49}
{$I FDBOOT.049}
{$ENDIF}
{$IFDEF L1}
{$I FDBOOT.001}
{$ENDIF}
));
FUNCTION ReadKey:Char;
VAR r:registers;
BEGIN
GiveUpIdle;
WITH r DO BEGIN
ah:=7;
intr($21,r);
IF al IN [3,27] THEN BEGIN
WriteLn;
Halt(4);
END;
ReadKey:=Chr(al);
END;
END;
PROCEDURE RequestAbort; Far;
BEGIN
SetIntVec($1E,old1E);
SetIntVec($13,old13);
DefExitProc;
END;
PROCEDURE ConfigError;
BEGIN
WriteLn(stderr,#10#13,text76);
Halt(16);
END;
PROCEDURE GetValue(x,y:String;VAR Value:Byte);
VAR i,k: Byte;
j: Integer;
BEGIN
y:=' '+y+'=';
i:=pos(y,x);
IF i<>0 THEN BEGIN
i:=i+Length(y);
WHILE x[i]=' ' DO Inc(i);
IF i>Length(x) THEN ConfigError;
k:=i;
WHILE x[k]<>' ' DO Inc(k);
IF x[i]<>'$' THEN BEGIN
Val(Copy(x,i,k-i),Value,j);
IF j<>0 THEN ConfigError;
END ELSE BEGIN
Value:=dezh(Copy(x,i+1,k-i-1));
IF BaseError<>0 THEN ConfigError;
END;
END;
END;
PROCEDURE CfgRead;
VAR f: Text;
x: String;
i: Byte;
BEGIN
cfgat80:=False;
cfgpc80:=False;
cfgdrive:=255;
bios:=False;
pc80:=0;
pc40:=0;
v720:=0;
v360:=0;
v12:=0;
v144:=0;
x:=FSearch('XFORMAT.CFG',GetEnv('PATH'));
IF x<>'' THEN BEGIN
Assign(f,x);
{$I-} Reset(f); {$I+}
IF IoResult=0 THEN BEGIN
WHILE NOT eof(f) DO BEGIN
ReadLn(f,x);
x:=x+' ';
FOR i:=1 TO Length(x) DO x[i]:=Upcase(x[i]);
IF Copy(x,1,2)=para[1] THEN BEGIN
IF pos(' BIOS ',x)<>0 THEN bios:=True;
IF pos(' AT ',x)<>0 THEN cfgat80:=True;
GetValue(x,'F',cfgdrive);
IF NOT(cfgdrive IN [0,1,2,7,255]) THEN ConfigError;
IF pos(' XT ',x)<>0 THEN cfgpc80:=True;
GetValue(x,'40',pc40);
GetValue(x,'80',pc80);
GetValue(x,'360',v360);
GetValue(x,'720',v720);
GetValue(x,'1.2',v12);
GetValue(x,'1.44',v144);
GetValue(x,'X',shifth);
GetValue(x,'Y',shiftt);
END;
IF cfgat80 AND cfgpc80 THEN ConfigError;
END;
{$I-} Close(f); {$I+}
END ELSE BEGIN
WriteLn(stderr,#10#13,text77);
Halt(8);
END;
END;
END;
PROCEDURE int13error;
BEGIN
WriteLn;
CASE regs.ah OF
$01: Write(stderr,error01);
$02: Write(stderr,error02);
$03: Write(stderr,error03);
$04: Write(stderr,error04);
$06: Write(stderr,error06);
$08: Write(stderr,error08);
$09: Write(stderr,error09);
$0c: Write(stderr,error0c);
$10: Write(stderr,error10);
$20: Write(stderr,error20);
$40: Write(stderr,error40);
$80: Write(stderr,error80);
ELSE Write(stderr,errorxx);
END;
WriteLn(stderr,'.');
END;
PROCEDURE int13;
VAR axs: Word;
chx: Char;
er: Boolean;
BEGIN
again:=False;
WITH regs DO BEGIN
axs:=ax;
REPEAT
GiveUpCPU;
ax:=axs;
IF ah IN [2,3,5] THEN SetIntVec($1E,new1E);
IF trk>43 THEN dl:=dl OR pc80 ELSE dl:=dl OR pc40;
IF NOT(bios) THEN lwtab[dl]:=DiskId;
intr($13,regs);
SetIntVec($1E,old1E);
GiveUpCPU;
er:=ah>1;
UNTIL ah<>6;
IF er THEN BEGIN
noformat:=False;
WriteLn(stderr,#10#13,text01,regs.ah,' ',text14,dh,text15,ch,text78,cl,'-',cl+Lo(axs)-1);
int13error;
WriteLn(stderr,text02);
REPEAT
chx:=Upcase(ReadKey);
CASE chx OF
'A': Halt(4);
'I': er:=False;
t3 : BEGIN er:=False; again:=True; END;
END;
UNTIL chx IN ['A','I',t3];
END;
ax:=axs;
END;
END;
PROCEDURE parse;
VAR j: Byte;
argstr: String[80];
BEGIN
argstr:='';
FOR j:=1 TO 50 DO para[j]:='';
FOR j:=1 TO ParamCount DO argstr:=argstr+' '+ParamStr(j);
FOR j:=1 TO Length(argstr) DO argstr[j]:=Upcase(argstr[j]);
PCount:=0;
FOR j:=1 TO Length(argstr) DO BEGIN
IF argstr[j] IN [swchar,' ','-','/']
THEN
Inc(PCount)
ELSE IF (NOT(argstr[j] IN [':','.'])) OR (PCount=1)
THEN
para[PCount]:=para[PCount]+argstr[j];
END;
END;
FUNCTION GetPhysical(lw:Byte):Byte;
BEGIN
WITH regs DO BEGIN
SetIntVec($13,@GetPhys);
ASM
cli
mov al,lw
mov cx,1
xor dx,dx
mov bx,offset buffer
push bp {DOS 3 alters BP, DOS 4 & 5 don't}
int 25h
pop cx
pop bp
END;
SetIntVec($13,old13);
ASM
sti
END;
GetPhysical:=lwphys;
END;
END;
PROCEDURE DriveTyp(VAR lw:Byte;VAR hd:Boolean;VAR trk,sec:Byte);
BEGIN
WITH regs DO BEGIN
ax:=$4409; bx:=lw+1;
intr($21,regs);
IF (FCarry AND Flags) <> 0 THEN BEGIN
WriteLn(stderr,text04);
trk:=0;
Exit;
END;
IF (dx AND $9200)<>0 THEN BEGIN
WriteLn(stderr,text05);
trk:=0;
Exit;
END;
ax:=$440f; bx:=lw+1;
intr($21,regs);
IF (FCarry AND Flags)<>0 THEN BEGIN
WriteLn(stderr,text04);
trk:=0;
Exit;
END;
ax:=$440d; cx:=$860; bx:=lw+1;
dx:=Ofs(buffer); ds:=Seg(buffer);
buffer[0]:=0;
intr($21,regs);
dosdrive:=bdib(buffer).dtyp;
IF cfgdrive<>255 THEN
dosdrive:=cfgdrive;
CASE dosdrive OF
0: BEGIN trk:=39; sec:= 9; hd:=False; END;
1: BEGIN trk:=79; sec:=15; hd:=True ; END;
2: BEGIN trk:=79; sec:= 9; hd:=False; END;
7: BEGIN trk:=79; sec:=18; hd:=True ; END;
ELSE
BEGIN
WriteLn(stderr,text06);
trk:=0;
Exit;
END
END;
IF Swap(DosVersion)<$1000 THEN lw:=GetPhysical(lw);
lw:=lw AND $9f;
IF NOT(lw IN [0..3]) THEN BEGIN
WriteLn(stderr,text07);
trk:=0;
Exit;
END;
IF cfgat80 THEN
at80:=cfgat80
ELSE
at80:=(ModelByte=$f8) OR (ModelByte=$fc);
END;
END;
PROCEDURE ATSetDrive(lw:Byte; trk,sec,Disk2,Disk,SetUp:Byte);
BEGIN
WITH regs DO BEGIN
IF lw>1 THEN bios:=True;
dh:=lw; ah:=$18; ch:=trk; cl:=sec;
IF bios THEN Write(text86);
intr($13,regs);
IF ah>1 THEN BEGIN
IF bios THEN Write(text89,#10#13,text87);
ah:=$17; al:=SetUp; dl:=lw;
intr($13,regs);
IF ah<>0 THEN BEGIN
IF bios THEN WriteLn(text89);
END ELSE BEGIN
IF bios THEN WriteLn(text88);
END;
END ELSE
IF bios THEN WriteLn(text88);
IF ForceType<>0 THEN BEGIN
lwtab[lw]:=ForceType;
bios:=False;
END ELSE IF Disk2<>0 THEN BEGIN
bios:=False;
lwtab[lw]:=Disk2;
END ELSE IF NOT(bios) THEN BEGIN
lwtab[lw]:=Disk;
END;
DiskId:=lwtab[lw];
IF not(bios) THEN
WriteLn(text93)
ELSE BEGIN
IF (lw<2) AND ((lwtab[lw] AND $F0) <> (Disk AND $F0)) THEN BEGIN
Writeln(stderr,text90);
Writeln(stderr,text91,hexf(lwtab[lw] shr 4,1),
text92,hexf(Disk shr 4,1),'x.');
END;
END;
END;
END;
PROCEDURE SectorAbsolute(sector:Word;VAR hds,trk,sec:Byte);
VAR h:Word;
BEGIN
sec:=(sector MOD bpb.spt)+1;
h:=sector DIV bpb.spt;
trk:=h DIV bpb.hds;
hds:=h MOD bpb.hds;
END;
FUNCTION SectorLogical(hds,trk,sec:Byte):Word;
BEGIN
SectorLogical:=trk*bpb.hds*bpb.spt+hds*bpb.spt+sec-1;
END;
FUNCTION Cluster(sector: Word):Word;
BEGIN
Cluster:=((sector-(bpb.rde SHR 4)
-(bpb.spf SHL 1)-1)
DIV Word(bpb.spc))+2;
END;
PROCEDURE ClusterOffset(Cluster:Word; VAR Offset,Mask:Word);
BEGIN
Offset:=Cluster*3 SHR 1;
IF Cluster AND 1 = 0 THEN
Mask:=$ff7
ELSE
Mask:=$ff70;
END;
PROCEDURE GetOldParms;
VAR bpb2: bpbtyp;
BEGIN
WITH regs DO BEGIN
ax:=$201;
dx:=lw;
cx:=$101;
es:=Seg(bpb2);
bx:=Ofs(bpb2);
intr($13,regs);
ax:=$201;
dx:=lw;
cx:=$1;
es:=Seg(bpb2);
bx:=Ofs(bpb2);
intr($13,regs);
IF ((FCarry AND Flags) = 0) AND (bpb2.hds<>0) AND (bpb2.spt<>0)
AND (bpb2.sec MOD (bpb2.hds*bpb2.spt)=0) THEN BEGIN
IF NOT(Quick) AND ((sec<>bpb2.spt) OR (hds<>bpb2.hds) OR
(trk<>bpb2.sec DIV bpb2.hds DIV bpb2.spt)) THEN BEGIN
noformat:=False;
END ELSE BEGIN
sec:=bpb2.spt;
hds:=bpb2.hds;
trk:=bpb2.sec DIV bpb2.hds DIV bpb2.spt;
END;
END ELSE BEGIN
IF fwe THEN BEGIN
WriteLn(stderr,text81);
Halt(3);
END ELSE
noformat:=False;
END;
IF fwe THEN bpb:=bpb2;
END;
END;
PROCEDURE format;
VAR i:Byte;
BEGIN
IF NOT(fwe) THEN BEGIN
IF rde AND 15 <> 0 THEN Inc(rde,16);
rde:=rde SHR 4;
IF (spc=2) AND (rde AND 1 = 0) THEN Inc(rde);
bpb.rde:=rde SHL 4;
END;
CASE sec OF
0..8: new1E:=@para08;
9: new1E:=@para09;
10: new1E:=@para10;
11: new1E:=@para11;
12..15: new1E:=@para15;
17: new1E:=@para17;
18: IF lwsec>17 THEN
new1E:=@para18
ELSE
new1E:=@para18a;
19..20: new1E:=@para20;
21: new1E:=@para21;
22..255:new1E:=@para22;
END;
IF gpl<>0 THEN
new1E^[7]:=gpl
ELSE
gpl:=new1E^[7];
WriteLn;
Write(text08,Chr(lw+$41),', ');
IF hd THEN WriteLn('High-Density') ELSE WriteLn('Double-Density');
WriteLn(hds,text09,trk,text10,sec,text11,'Interleave: ',il,text68,gpl);
WriteLn(bpb.rde,text12,spc,text13,shiftt,':',shifth);
bttCount:=0;
WITH regs DO BEGIN
FOR i:=1 TO 25 DO BEGIN
table[i].f:=2;
table2[i]:=0;
END;
i:=1;
n:=1;
REPEAT
REPEAT
WHILE table2[n]<>0 DO Inc(n);
IF n>sec THEN n:=1;
UNTIL table2[n]=0;
table2[n]:=i;
n:=n+il;
Inc(i);
UNTIL i>sec;
ax:=0;
bx:=0;
dl:=lw;
IF at80 AND NOT(fwe) THEN BEGIN
CASE dosdrive OF
0: ATSetDrive(lw,39,9,v360,$53,1);
1: IF (trk>43) AND (sec>11) THEN
ATSetDrive(lw,79,15,v12,$14,3)
ELSE IF (trk>43) AND (sec<12) THEN
ATSetDrive(lw,79,9,v720,$53,5)
ELSE IF sec<12 THEN
ATSetDrive(lw,39,9,v360,$73,2)
ELSE
ATSetDrive(lw,39,15,0,$34,2);
2: IF (trk>43) THEN
ATSetDrive(lw,79,9,v720,$97,4)
ELSE
ATSetDrive(lw,39,9,v360,$B7,2);
7: IF (trk>43) AND (sec>11) THEN
ATSetDrive(lw,79,18,v144,$14,3)
ELSE IF (trk>43) AND (sec<12) THEN
ATSetDrive(lw,79,9,v720,$97,5)
ELSE IF sec<12 THEN
ATSetDrive(lw,39,9,v360,$B7,2)
ELSE
ATSetDrive(lw,39,18,0,$34,3);
END;
END;
IF at80 AND NOT(bios) THEN BEGIN
Write(text67);
CASE (DiskId AND $C0) OF
$00: Write('500');
$40: Write('300');
$80: Write('250');
$C0: Write('???');
END;
Write(' kBaud, Double-Stepping: ');
IF (DiskId AND 32)=0 THEN
Write(text73,', ')
ELSE
Write(text72,', ');
END;
IF NOT(fwe) THEN BEGIN
bpb.spt:=sec;
bpb.hds:=hds;
bpb.spc:=spc;
bpb.sec:=sec*bpb.hds*trk;
IF ForceMedia=0 THEN BEGIN
CASE bpb.spc OF
1: IF (trk>44) AND (bpb.spt IN [12..17]) THEN
bpb.mds:=$f9
ELSE
bpb.mds:=$f0;
2: IF trk IN [1..43] THEN bpb.mds:=$fd ELSE bpb.mds:=$f9;
ELSE bpb.mds:=$f8;
END;
END
ELSE bpb.mds:=ForceMedia;
bpb.spf:=Trunc(bpb.sec*1.5/512/bpb.spc)+1;
WHILE Trunc((1.5*(((bpb.sec-bpb.res-(bpb.rde DIV 16)
-bpb.fat*(bpb.spf-1)) DIV bpb.spc)+2)-1)/bpb.bps)+1<bpb.spf DO
Dec(bpb.spf);
END;
WriteLn('Media-Byte: ',hexf(bpb.mds,2));
WriteLn;
dl:=lw;
ax:=0;
REPEAT int13 UNTIL NOT again;
n:=0;
FillChar(buffer,SizeOf(buffer),#0);
FOR track:=trk-1 DOWNTO 0 DO BEGIN
IF track<>trk-1 THEN n:=n+shiftt;
FOR head:=hds-1 DOWNTO 0 DO BEGIN
IF head<>hds-1 THEN n:=n+shifth;
n:=n MOD sec;
FOR i:=1 TO sec DO
table[i].s:=table2[(i+n-1) MOD sec+1];
Write(text14,head,text15,track,', ',100-(track*100 DIV Pred(trk)),'%');
x:=SectorLogical(head,track,1);
x:=Cluster(x);
FOR i:=1 TO sec DO BEGIN
table[i].t:=track;
table[i].h:=head;
END;
EndProgram(4,text94);
REPEAT
IF NOT(fwe) THEN BEGIN
again:=False;
Write(' ');
END ELSE BEGIN
ah:=2;
al:=sec;
dl:=lw;
dh:=head;
ch:=track;
cl:=1;
es:=Seg(buffer);
bx:=Ofs(buffer);
Write(' R '#8#8#8);
int13;
END;
UNTIL NOT(again);
REPEAT
IF NOT(noformat) THEN BEGIN
ah:=5;
al:=sec;
dl:=lw;
dh:=head;
ch:=track;
cl:=1;
es:=Seg(table);
bx:=Ofs(table);
Write(#8'F '#8#8#8);
int13;
END;
Write(#8,'V '#13);
IF fwe OR NOT(again OR noverify) OR (track<3) THEN BEGIN
ah:=3;
al:=sec;
dl:=lw;
dh:=head;
ch:=track;
cl:=1;
es:=Seg(buffer);
bx:=Ofs(buffer);
int13;
END;
UNTIL NOT again;
IF (FCarry AND Flags) <> 0 THEN BEGIN
IF (x<2) OR (x>10000) THEN BEGIN
WriteLn(stderr,text17);
Halt(2);
END;
Inc(bttCount);
IF bttCount>20 THEN BEGIN
WriteLn(stderr,text18,20*sec,text19);
Halt(2);
END;
btt[bttCount].track:=track;
btt[bttCount].head:=head;
WriteLn(text14,head,text15,track,text20,#10#13);
END;
END;
END;
END;
END;