-
Notifications
You must be signed in to change notification settings - Fork 0
/
DDE.BAK
executable file
·3025 lines (2932 loc) · 90.8 KB
/
DDE.BAK
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
Program DDE;
(*****************************************************************************
* DOS DiskEditOR v2.01 beta 1 *
*****************************************************************************
* *
* — á⨠ª®¤ ¢§ïâë ¨§: *
* þ DOS Navigator OSP by RIT Research Labs & OSP Team *
* þ HDDSpeed 2.1 by Michael Radchenko, 2:5025/25 *
* *
* Since: 01/04/Y2k *
* (C) NiKe'Soft UnLtd. Last UpDate: 01/07/2001 *
*****************************************************************************)
{$DEFINE DEBUG}
{$DEFINE RussianLang}
{.$DEFINE Beta}
{.$DEFINE EnableWrite}
{$DEFINE TestDrive}
{$A- Word aligned data}
{$E- 80x87 Emulation}
{$N+ Numeric co-processor}
{$F- Far calls}
{$X+ Extended syntax}
{$B- Boolean evaluation}
{$G- Group unit segments}
{$O- Overlays}
{$IFDEF DEBUG}
{$D+ Debug information}
{$I+ I/O checking}
{$L+ Local symbols information}
{$Y+ Symbol information}
{$T+ Type-checked pointers}
{$R+ Range checking}
{$P+ Open strings parameters}
{$Q- Overflow checking}
{$S+ Stack-overflow checking}
{$V+ Var-string checking}
{$ELSE}
{$D- Debug information}
{$I- I/O checking}
{$L- Local symbols information}
{$Y- Symbol information}
{$T- Type-checked pointers}
{$R- Range checking}
{$P- Open strings parameters}
{$Q- Overflow checking}
{$S- Stack-overflow checking}
{$V- Var-string checking}
{$ENDIF}
{$M 65521,0,655360}
Uses DiskTool,vFAT,Service,TextModeUtil,Keyboard,Hex,HelpZ;
const CopyRight = '(c) NiKe''Soft UnLtd';
appName = 'DOS DiskEditOR (DDE)';
STappName = 'DOS DiskEditOR ('+'~'+char(16*cBlack+cLCyan)+'~'+'DDE'+'~'+char(16*cBlack+cGray)+'~'+')';
appBuild = '01/07/2001';
{$IFDEF DEBUG}
{$IFDEF BETA}
appVer = 'v2.01d beta 1';
{$ELSE}
appVer = 'v2.01d';
{$ENDIF}
{$ELSE}
{$IFDEF BETA}
appVer = 'v2.01 beta 1';
{$ELSE}
appVer = 'v2.01';
{$ENDIF}
{$ENDIF}
const
Max_Items = 4096;
Max_Drives = 4{FDD}+6{HDD}+2{Reserved};
nRetries = 2;
vtHex = 0;
vtHex64 = 1;
ViewType : byte = vtHex64;
ViewChLimit : byte = 0;
CharLimits : array[0..2] of string[6] =
(('00..FF'),
('20..7F'),
('20..FF')
);
Wrap : byte = 0;
TabSize : byte = 8;
pt_None = 0;
pt_Drives = 1;
pt_LDrives = 2;
pt_Dirs = 3;
SavingPath: string = 'c:\rec\';
{$IFDEF RussianLang}
stDrive = '„¨áª';
stHdr01 = ' ‚ë¡¥à¨â¥ „¨áª ';
stHdr02 = ' ‚ë¡¥à¨â¥ §¤¥« ';
stInit_Drives = 'ˆ¨æ¨¨à㥬 â ¡«¨æë „¨áª®¢ ... ';
stFound = ' ©¤¥(®)';
stErroR = 'Žè¨¡ª ';
stNum = 'No.';
stSize = ' §¬¥à';
stHeads = '‘â®à®';
stHead = '‘â®à.';
stTracks = '„®à®¦.';
stTrack = '„®à®¦.';
stSector = '‘¥ªâ.';
stActive = '€ªâ.';
stSystem = 'ID ‘¨á⥬ë';
stYes = '„ ';
stNo = '¥â';
stCluster = 'Š« áâ¥à';
stDirectory = 'Š â «®£';
st_NORMAL_st = '~'+char(16*cGray+cRed)+'~'+#25#24#27#26'/End/Home/PgDn/PgUp'+'~'+char(16*cGray+cBlack)+'~'+
' - ¯¥à¥¬¥é. '+'~'+char(16*cGray+cRed)+'~'+'Enter'+'~'+char(16*cGray+cBlack)+'~'+' - ¢ ª â «®£. '+
'~'+char(16*cGray+cRed)+'~'+'F12'+'~'+char(16*cGray+cBlack)+'~'+' - §ªà . '+
'~'+char(16*cGray+cRed)+'~'+'ESC'+'~'+char(16*cGray+cBlack)+'~'+' - ¢ë室';
st_Shift_st = '~'+char(16*cGray+cRed)+'~'+#25#24#27#26'/End/Home/PgDn/PgUp'+'~'+char(16*cGray+cBlack)+'~'+
' - ¯¥à¥¬¥é. '+'~'+char(16*cGray+cRed)+'~'+'Enter'+'~'+char(16*cGray+cBlack)+'~'+' - ¢ ª â «®£. '+
'~'+char(16*cGray+cRed)+'~'+'ESC'+'~'+char(16*cGray+cBlack)+'~'+' - ¢ë室';
st_Alt_st = '~'+char(16*cGray+cRed)+'~'+'F1/F2'+'~'+char(16*cGray+cBlack)+'~'+' - ¢ë¡®à ¤¨áª . '+
'~'+char(16*cGray+cRed)+'~'+'R'+'~'+char(16*cGray+cBlack)+'~'+' - ¯¥à¥ç¨â âì. '+
'~'+char(16*cGray+cRed)+'~'+#27#26'/Home/End'+'~'+char(16*cGray+cBlack)+'~'+' - LFNofs'+
'~'+char(16*cGray+cRed)+'~'+' I'+'~'+char(16*cGray+cBlack)+'~'+' ¨ä®';
st_Ctrl_st = '~'+char(16*cGray+cRed)+'~'+'F1-F5'+'~'+char(16*cGray+cBlack)+'~'+' - á®àâ¨à®¢ª¨. '+
'~'+char(16*cGray+cRed)+'~'+'R'+'~'+char(16*cGray+cBlack)+'~'+' - ¯¥à¥ç¨â âì. '+
'~'+char(16*cGray+cRed)+'~'+'End/Home'+'~'+char(16*cGray+cBlack)+'~'+' - ¯¥à¥¬¥é¥¨¥. '+
'~'+char(16*cGray+cRed)+'~'+'T'+'~'+char(16*cGray+cBlack)+'~'+' - ’¥áâ '+'~'+char(16*cGray+cRed)+'~'+
'+/-'+'~'+char(16*cGray+cBlack)+'~'+' H ¯p.';
stTesting = ' ’¥áâ஢ ¨¥/¯à®¢¥àª ¤¨áª ';
stFrom = '¨§';
stEstimated = ' áç¥â®¥';
stElapsed = 'à®è«®';
stTimeLeft = 'Žáâ «®áì';
stDriveInfo = 'ˆä®à¬ æ¨ï ® ¤¨áª¥';
stViewingFile = ' p®á¬®âp ä ©« ';
stBytes = '¡ ©â';
stNew = '®¢ëå';
stBad = '«®å¨å:';
stBiosDrv = 'BIOS-„¨áª ';
stRootElements = ' í«¥¬¥â®¢ ª®àï';
stRootCluster = 'Š« áâ¥à ª®àï ';
stPartFrom = ' §¤¥« ®â ';
stFileSys = '” ©«®¢ ï á¨á⥬ - ';
stFreeClusters = ' c¢®¡®¤ëå ª« áâ¥à®¢';
stClusterLength = ' ᥪâ®à®¢ ¢ ª« áâ¥à¥';
stClusters = ' ª« áâ¥à®¢';
stFatLength = ' ᥪâ®à®¢ ¢ FAT';
stCopies = 'ª®¯¨¨';
stPartLength = ' ᥪâ®à®¢ ¢ à §¤¥«¥';
stSectora = ' ᥪâ®à ';
stOtnSec = ' ®.á.';
stFaultCluster = 'B - á¡®©ë©';
stErrorCluster = 'E - ®è¨¡®çë©';
stResCluster = 'R - १¥à¢ë©';
stGoodBye = '‘¯ ᨡ®. „® ¢áâà¥ç "¡®àâã" ¬®¥£® á®äâ :-)';
{$ELSE}
stDrive = 'Drive';
stHdr01 = ' Choose Drive ';
stHdr02 = ' Choose Partition ';
stInit_Drives = 'Initializing DRiVE Tables ... ';
stFound = 'found';
stErroR = 'ErroR';
stNum = 'No.';
stTracks = 'Tracks';
stTrack = 'Track';
stHeads = 'Heads';
stHead = 'Head';
stSector = 'Sect.';
stSize = ' Size';
stActive = 'Act.';
stSystem = 'System ID';
stYes = 'Yes';
stNo = 'No';
stCluster = 'Cluster';
stDirectory = ' DIR ';
st_NORMAL_st = '~'+char(16*cGray+cRed)+'~'+#25#24#27#26'/End/Home/PgDn/PgUp'+'~'+char(16*cGray+cBlack)+'~'+
' - moving '+'~'+char(16*cGray+cRed)+'~'+'Enter'+'~'+char(16*cGray+cBlack)+'~'+' - Goto DIR '+
'~'+char(16*cGray+cRed)+'~'+'F12'+'~'+char(16*cGray+cBlack)+'~'+' - Scr.Off '+
'~'+char(16*cGray+cRed)+'~'+'ESC'+'~'+char(16*cGray+cBlack)+'~'+' - Exit';
st_Shift_st = '~'+char(16*cGray+cRed)+'~'+#25#24#27#26'/End/Home/PgDn/PgUp'+'~'+char(16*cGray+cBlack)+'~'+
' - moving '+'~'+char(16*cGray+cRed)+'~'+'Enter'+'~'+char(16*cGray+cBlack)+'~'+' - Goto DIR '+
'~'+char(16*cGray+cRed)+'~'+'ESC'+'~'+char(16*cGray+cBlack)+'~'+' - exit';
st_Alt_st = '~'+char(16*cGray+cRed)+'~'+'F1/F2'+'~'+char(16*cGray+cBlack)+'~'+' - Select Drive '+
'~'+char(16*cGray+cRed)+'~'+'R'+'~'+char(16*cGray+cBlack)+'~'+' - ReRead '+
'~'+char(16*cGray+cRed)+'~'+#27#26'/Home/End'+'~'+char(16*cGray+cBlack)+'~'+' - LFNofs'+
'~'+char(16*cGray+cRed)+'~'+' I'+'~'+char(16*cGray+cBlack)+'~'+' Info';
st_Ctrl_st = '~'+char(16*cGray+cRed)+'~'+'F1-F5'+'~'+char(16*cGray+cBlack)+'~'+' - sortings '+
'~'+char(16*cGray+cRed)+'~'+'R'+'~'+char(16*cGray+cBlack)+'~'+' - ReRead '+
'~'+char(16*cGray+cRed)+'~'+'End/Home'+'~'+char(16*cGray+cBlack)+'~'+' - moving '+
'~'+char(16*cGray+cRed)+'~'+'T'+'~'+char(16*cGray+cBlack)+'~'+' - Test '+'~'+char(16*cGray+cRed)+'~'+
'+/-'+'~'+char(16*cGray+cBlack)+'~'+' Sort direction';
stTesting = ' Testing/recovering drive ';
stFrom = 'from';
stEstimated = 'Estimated';
stElapsed = 'Elapsed';
stTimeLeft = 'Time left';
stDriveInfo = 'Drive info';
stViewingFile = ' Viewing file';
stBytes = 'bytes';
stNew = 'new';
stBad = 'Bad:';
stBiosDrv = 'BIOS-Drv ';
stRootElements = ' root elements';
stRootCluster = 'Root cluster ';
stPartFrom = 'Partition from ';
stFileSys = 'File System - ';
stFreeClusters = ' free clusters';
stClusterLength = ' sectors per cluster';
stClusters = ' clusters';
stFatLength = ' sectors per FAT';
stCopies = 'copies';
stPartLength = ' sectors in partition';
stSectora = ' sector';
stOtnSec = ' r.s.';
stFaultCluster = 'B - BAD cluster';
stErrorCluster = 'E - Errored';
stResCluster = 'R - Reserved';
stGoodBye = 'T|-|a|\|x 4 |_|$i|\|G /\/\y $*Ft, $ee y/-\ |_/-\teR :-)';
{$ENDIF}
DriveDlgW = 49;
LDriveDlgW = 63;
Max_Partitions = 20;
smUnsorted = 0;
smName = 1;
smExtension = 2;
smSize = 3;
smDateTime = 4;
const max_buf = 32767;
type tBuf = array[0..max_buf] of char;
type pString = ^String;
type pFile_Item = ^tFile_Item;
tFile_Item = record
case byte of
0:( Name : array[0..7] of char;
Ext : array[0..2] of char;
Attr : byte;
lCase : byte; {Char case of name & ext}
cTime_ms : byte; {Creation time, milliseconds}
cTime : word; {Creation time}
cDate : word; {Creation date}
aDate : word; {Last access date}
Year : word;
Month,Day: byte;
Hour,Minute,Sec: byte;
Cluster : longint;
Size : longint;
LFName : pString;
Sel : boolean;
ShowSize : boolean);
1:( NameExt : array[0..10] of char);
end;
type pLDrive = ^tLDrive;
tLDrive = record
BiosDrv : byte;
Part : tPartition;
end;
type pItem = ^tItem;
tItem = record
case byte of
1: ( F : tFile_Item);
2: ( D : tBios_Drive);
3: ( L : tLDrive);
end;
type tPanel = record
FD : pFat_Device;
Items : array[0..Max_Items] of pItem;
nItems,_dp,
_ds,_x,_y : word;
x1,y1,x2,y2 : word;
PathName : string;
PathType : byte;
Cluster : longint;
Visible : boolean;
LFNOfs : byte;
MaxLfnOfs : byte;
LastClus : longint;
OldClus : longint;
SortMode : byte;
SortAsc : boolean;
UseLFN : boolean;
ShowDeleted : boolean;
ShowDot : boolean; {Show '.' dir el.}
end;
Var Panel : array[0..1] of tPanel;
CurPnl : byte;
Drives : array[1..Max_Drives] of tBios_Drive;
Pts : array[1..Max_Partitions] of tPartition;
oldx,oldy,nDrives : byte;
buf : array512;
procedure DDEFont; external; {$L DDEFont.Obj}
function ShowError(err : string) : integer;
var tt : byte;
x1,y1,ww,hh : byte;
act : byte;
key : word;
begin
ShowError := -1;
SaveScr(5);
err := ' Error: '+err+' ';
tt := length(err) + 1;
ww := 10;
if tt > ww then
begin
if tt > 78 then tt := 78;
ww := tt;
end;
x1 := (80 - ww) div 2 - 1;
y1 := 09; hh := 4;
tt := cLRed;
Set_Window(x1,y1,x1+ww,y1+hh,Borders[brd_double],pa(15,tt),15,tt,pa(14,tt),' ',err,true);
writest('ESC/N - Break',x1+2,y1+1);
writest('Y/R - ReRead',x1+2,y1+2);
writest('S - Skip [sector]',x1+2,y1+3);
while keypressed do getkey;
act := 0;
while true do
begin
key := getkey;
if key<>kbnokey then
begin
if key = kbESC then act := 1 else
if (upcase(chr(lo(key))) = 'Y')or(upcase(chr(lo(key))) = 'R')or(key = kbEnter) then act := 2 else
if (upcase(chr(lo(key))) = 'N') then act := 3 else
if (upcase(chr(lo(key))) = 'S') then act := 4 else
end;
if act <> 0 then break;
end;
PutScr(5);
ShowError := act;
end;
function AddSlash(s : string) : string;
begin
if length(s) >= 1 then if s[length(s)] <> '\' then s := s + '\' else else s := '\';
AddSlash := s;
end;
function IsExe(it : pItem) : boolean;
var e : string;
begin
e:=UpCaseStr(RTrim(it^.f.ext));
IsExe:=true;
if (e<>'EXE') then
if (e<>'COM') then
if (e<>'BAT') then
IsExe:=false;
end;
function IsArchive(it : pItem) : boolean;
var e : string;
begin
e:=upcasestr(RTrim(it^.f.ext));
IsArchive:=true;
if length(e)<2 then IsArchive:=false else
if length(e)=2 then
begin
if (e<>'HA') then
if (e<>'GZ') then IsArchive:=false else
end else
if (e[1]='A') then
begin
if not((e[2]='C')and(e[3]='E')) then
if not((e[2]='R')and(e[3]='J')) then
if not((e[2]='R')and(e[3]='C')) then
if not((e[2]='I')and(e[3]='N')) then IsArchive:=false;
end else
if (e[1]='B') then
begin
if not((e[2]='S')and(e[3]='A')) then
if not((e[2]='S')and(e[3]='2')) then IsArchive:=false;
end else
if (e[1]='C') then
begin
if not((e[2]='M')and(e[3]='Z')) then
if not((e[2]='A')and(e[3]='B')) then IsArchive:=false;
end else
if (e[1]='H') then
begin
if not((e[2]='A')and(e[3]='P')) then
if not((e[2]='P')and(e[3]='K')) then
if not((e[2]='Y')and(e[3]='P')) then IsArchive:=false;
end else
if (e<>'RAR') then
if (e<>'SQZ') then
if (e<>'TAR') then
if (e<>'UC2') then
if (e[1]='Z') then
begin
if not((e[2]='H')and(e[3]='A')) then
if not((e[2]='I')and(e[3]='M')) then
if not((e[2]='I')and(e[3]='P')) then
if not((e[2]='O')and(e[3]='O')) then
if not((e[2]='X')and(e[3]='Z')) then IsArchive:=false;
end else
if (e<>'PAK') then
IsArchive:=false;
end;
function GetItemColor(it : pItem) : byte;
var c : byte;
ex : string[3];
begin
ex := UpCaseStr(RTrim(it^.f.ext));
if isEXE(it) then c:=11
else if isArchive(it) then c:=10
else if (ex='PAS') then c:=03
else if (ex='DPR') then c:=03
else if (ex='BAS') then c:=03
else if (ex='C' ) then c:=03
else if (ex='CPP') then c:=03
else if (ex='H' ) then c:=03
else if (ex='ASM') then c:=03
else if (ex='A86') then c:=03
else if (ex='INC') then c:=03
else if (ex='' ) then c:=02
else if (ex='INI') then c:=02
else if (ex='CTL') then c:=02
else if (ex='CFG') then c:=02
else if (ex='TXT') then c:=02
else if (ex='RTF') then c:=02
else if (ex='DOC') then c:=02
else if (ex='DIZ') then c:=02
else if (ex='ME' ) then c:=02
{
else if (ex='DBF') then c:=13
else if (ex='WKZ') then c:=13
else if (ex='123') then c:=13
else if (ex='WK' ) then c:=13
else if (ex='XLS') then c:=13
}
else if (ex='TMP') then c:=12
else if (ex='$$$') then c:=12
else if (ex='BAK') then c:=12
else if (ex='BMP') then c:=09
else if (ex='PCX') then c:=09
else if (ex='PIC') then c:=09
else if (ex='GIF') then c:=09
else if (ex='JPG') then c:=09
else if (ex='JPE') then c:=09
else if (ex='RLE') then c:=09
else if (ex='ICO') then c:=09
else if (ex='PNG') then c:=09
else if (ex='TIF') then c:=09
else if (ex='TGA') then c:=09
else if (ex='KDC') then c:=09
else if (ex='WAV') then c:=13
else if (ex='MP3') then c:=13
else if (ex='MP2') then c:=13
else if (ex='MP1') then c:=13
else if (ex='MID') then c:=13
else if (ex='VQF') then c:=13
else if (ex='669') then c:=13
else if (ex='S3M') then c:=13
else if (ex='IT' ) then c:=13
else if (ex='MOD') then c:=13
else if (ex='VOC') then c:=13
else if (ex='M3U') then c:=13
else if (ex='PLS') then c:=13
else if (ex='NKS') then c:=13
else c:=07;
GetItemColor := c;
end;
{$DEFINE UseBuffering}
function ViewFile(Pnl : byte; It : word) : integer;
{$IFDEF UseBuffering}
const MaxClusBuf = 255;
MaxSectBuf = 10;
var clusbufpos,sectbufpos : word;
SectBuf : array[0..MaxSectBuf] of record
SectN : longint;
Data : array[0..511] of char;
end;
ClusBuf : array[0..MaxClusBuf] of record
Clus : longint;
ClusN : longint;
end;
{$ENDIF}
var hh,h,hexpos : word;
key,mkey : word;
hexing,done : boolean;
clus,clse,DsP,Size : longint;
bufdsp : longint;
bf : array[0..6666] of char;
s : string;
fnd : boolean;
LastClust : record
Clus : longint;
ClusN : longint;
end;
function AllowedChar(ch : char) : boolean;
begin
case ViewChLimit of
1: AllowedChar := (ch >= ' ')and(ch <= '');
2: AllowedChar := (ch >= ' ')and(ch <= #$FF);
else AllowedChar := true;
end;
end;
procedure AdjustBuffer(ReRead : boolean);
var StClus,tmp,clu,sz,c,sec,cl : longint;
t,j : word;
oofs : word;
bf2 : array[0..511] of char;
begin
with Panel[Pnl] do
begin
if (dsp < 0)or(dsp > size) then exit;
if not ReRead then if (dsp = bufdsp) then exit;
sec := dsp div fd^.sector_length;
oofs := dsp mod fd^.sector_length;
cl := sec div fd^.cluster_length;
j := sec mod fd^.cluster_length;
sz := 0;
clus := Items[it]^.f.cluster;
if (cl > 0) then
begin
if (LastClust.ClusN > 1)and(LastClust.ClusN < cl)and(not ReRead) then
begin
StClus := LastClust.ClusN;
clus := LastClust.Clus;
end else StClus := 1;
for c := StClus to cl do
begin
{$IFDEF UseBuffering}
fnd := false;
if not ReRead then
begin
for t := 1 to MaxClusBuf do
begin
if ClusBuf[t].ClusN = c then begin fnd := true; break; end;
end;
end;
if fnd then clu := ClusBuf[t].Clus else
{$ENDIF}
begin
while (true) do
begin
clu := Get_FAT_Item(fd^,clus);
if (clu < 2)or((clu > fd^.clusters) and (clu < fd^.EOF_Mark)) then
begin
case ShowError('Illegal FAT Item! ('+hexl(clu)+')') of
1,3: {ESC} begin break; end;
2: {ReRead} begin clu := Get_FAT_Item(Panel[Pnl].fd^,clus); end;
4: {Skip} begin {size := sz;} break; end;
end;
end else break;
end;
{$IFDEF UseBuffering}
ClusBuf[ClusBufPos].ClusN := c;
ClusBuf[ClusBufPos].Clus := clu;
if ClusBufPos >= MaxClusBuf then ClusBufPos := 0 else inc(ClusBufPos);
{$ENDIF}
end;
if (clu < 2)or(clu >= fd^.BAD_Mark) then
begin
break;
end else
begin
clus := clu;
sz := sz + longint(fd^.cluster_length)*fd^.sector_length;
if (sz >= size) then break;
end;
end;
if not((clu < 2)or(clu >= fd^.BAD_Mark)) then
if LastClust.ClusN < c then begin LastClust.ClusN := c; LastClust.Clus := clu end;
end;
bufdsp := dsp;
c := 0;
sec := get_cluster_sector(fd^,clus);
if sec < 0 then exit;
if sz < 0 then sz := 0;
for c := 0 to 5 do {—¨â ¥¬ ᥪâ®à ä ©« }
begin
if (sz >= size) then break;
tmp := c*fd^.sector_length - oofs; if tmp < 0 then tmp := 0;
{$IFDEF UseBuffering}
fnd := false;
if not ReRead then
begin
for t := 1 to MaxSectBuf do
begin
if SectBuf[t].SectN = sec+j then begin fnd := true; break; end;
end;
end;
if fnd then
begin
move(SectBuf[t].Data[(oofs)*byte(c=0)],bf[tmp],sizeof(SectBuf[t].Data));
end else
{$ENDIF}
begin
Read_Sectors(fd^,sec+j,1,bf2);
move(bf2[(oofs)*byte(c=0)],bf[tmp],sizeof(bf2));
{$IFDEF UseBuffering}
move(bf2,SectBuf[SectBufPos].Data,sizeof(SectBuf[SectBufPos].Data));
SectBuf[SectBufPos].SectN := sec+j;
if SectBufPos >= MaxSectBuf then SectBufPos := 0 else inc(SectBufPos);
{$ENDIF}
end;
sz := sz + fd^.sector_length;
if sz > size then break;
inc(j);
if (j mod fd^.cluster_length = 0) then
begin
while (true) do
begin
clu := Get_FAT_Item(fd^,clus);
if (clu < 2)or((clu > fd^.clusters) and (clu < fd^.EOF_Mark)) then
begin
case ShowError('Illegal FAT Item! ('+hexl(clu)+')') of
1,3: {ESC} begin break; end;
2: {ReRead} begin clu := Get_FAT_Item(Panel[Pnl].fd^,clus); end;
4: {Skip} begin {size := sz;} break; end;
end;
end else break;
end;
clus := clu;
j := 0;
sec := get_cluster_sector(fd^,clus);
if sec < 0 then break;
end;
end;
end;
end;
procedure DrawScr(DsP : longint);
var cl,a,i,w,ww : longint;
c : char;
begin
with Panel[Pnl] do
begin
if (Scr_buf<>nil) then
begin
move(ptr(Text_Seg,0)^,Scr_buf^,80*25*2);
oText_Seg:=Text_Seg;
Text_Seg:=seg(Scr_Buf^);
end;
case ViewType of
vtHex,vtHex64:
begin
s := rtrim(Items[it]^.f.name);
if rtrim(Items[it]^.f.ext)<>'' then s:=s+'.'+rtrim(Items[it]^.f.ext);
fillscr(1,1,80,25,' ');
Set_Window(1,1,80,24,borders[brd_double],15,07,08,PA(10,08),' ',
stViewingFile+' "'+s+'" (C:'+hexl(Items[it]^.f.cluster)+'h) ',false);
if (ViewType = vtHex) then
begin
hh := 16;
writestf('['+hexl(DsP+hexpos div 2)+' '+hexb(DsP mod 16),2,24,15);
for i := 1 to 15 do writestf('-'+hexb(i + DsP mod 16),14+(i-1)*3,24,15);
writestf('['+hexl(size){fstr(size,1,',',' ',RightAlign)}{+' '+stBytes}+'] - ['+CharLimits[ViewChLimit]+']',62,24,15);
end else
begin
hh := 64;
writestf('['+hexl(DsP+hexpos div 2)+' - '+strf(round((1.0*100/size)*(DsP+hexpos div 2)),1)+'% '+
stFrom+' '+fstr(size,1,',',' ',RightAlign)+' '+stBytes+'] - ['+CharLimits[ViewChLimit]+']',2,24,15);
end;
if (Size - DsP) > hh*22 then w := hh*22 else w := Size-DsP;
ww := w div hh;
if (w mod hh <> 0) then inc(ww);{}
for i := 1 to ww do
begin
writestf(hexl(DsP+(i-1)*hh),02,01+i,07);
putchf(10,01+i,':',07);
for a := 0 to hh-1 do
begin
if longint(DsP+(i-1)*hh+a) >= Size then begin dec(a); break; end;
if ((i-1)*hh+a) < sizeof(bf) then
begin
if (ViewType = vtHex) then
begin
c := bf[(i-1)*hh+a];
writestf(hexb(byte(c)),15+(a-1)*3,01+i,07);
if (a+1) mod 4<>0 then putchf(17+(a-1)*3,01+i,' ',07);
if AllowedChar(c) then putchf(62+a,01+i,c,07);
end else
begin
c := bf[(i-1)*hh+a];
if AllowedChar(c) then putchf(12+a,01+i,c,07) else putchf(12+a,01+i,' ',07);
end;
end;
end;
for a := a+1 to hh-1 do
begin
if (ViewType = vtHex) then
begin
writestf(' ',15+(a-1)*3,01+i,07);
putchf(62+a,01+i,' ',07);
end else putchf(12+a,01+i,' ',07);
end;
if (ViewType = vtHex64) then fil(76,01+i,79,' ');
if (ViewType = vtHex) then
begin
putchf(23,01+i,'³',15);
putchf(35,01+i,'³',15);
putchf(47,01+i,'³',15);
putchf(60,01+i,'º'{³},15);
end;
end;
for i := ww+1 to 22 do fil(2,01+i,78,' ');
end;
end;
if (Scr_buf<>nil) then
begin
Text_Seg:=oText_Seg;
wretr;
move(Scr_buf^,ptr(Text_Seg,0)^,80*25*2);
end;
end;
end;
procedure AdjustCursor;
var x : byte;
begin
if longint(size - dsp) > hh*22 then h := hh*22*2 else h := (size - dsp)*2;
if (hexpos >= h) then hexpos := h-1;
if (not hexing)or(ViewType = vtHex64) then
begin
x := (hexpos div 2) mod (hh) + 12;
if (ViewType = vtHex) then inc(x,50);
end else
begin
h := (hexpos mod (hh*2));
x := h + h div 2 + 12;
end;
Set_Cursor_Pos(x,hexpos div (hh*2) + 2)
end;
begin
ViewFile := 1;
with LastClust do begin ClusN := 0; Clus := 0; end;
SaveScr(4);
{$IFDEF UseBuffering}
FillChar(ClusBuf,sizeof(clusbuf),#0); clusbufpos := 0;
fillchar(SectBuf,sizeof(sectbuf),#0); sectbufpos := 0;
{$ENDIF}
with Panel[Pnl] do if (nItems > 0)and(it < nItems) then if (Items[it] <> nil) then
begin
dsp := 0; bufdsp := 0;
hexpos := 0; hexing := true; {¯¥p¥¬¥é¥¨¥ ¯® HEX-ç¨á« ¬ ¥ ¯® ASCII}
case ViewType of
vtHex: hh := 16;
vtHex64: hh := 64;
end;
Size := Items[it]^.f.Size;
fillchar(bf,sizeof(bf),#0);
done := false; mkey := kbnokey;
AdjustBuffer(true);
AdjustCursor;
DrawScr(DsP);
set_cursor(true);
while (not done) do
begin
if (mkey <> kbnokey) then begin key := mkey; mkey := kbnokey; end else key := getkey;
if (key <> kbNoKey) then
begin
if dsp > size then dsp := size-1;
if dsp < 0 then dsp := 0;
case key of
kbDown: {Down}
begin
if longint(size - dsp) > hh*22 then h := hh*22*2 else h := (size - dsp)*2;
if (hexpos+hh*2 < h) then
begin
inc(hexpos,hh*2);
end else
if (longint(Size - DsP) > hh*22) then inc(DsP,hh);
end;
kbUp: {Up}
begin
if (hexpos >= hh*2) then
begin
dec(hexpos,hh*2);
end else
if (DsP-hh >= 0) then
begin
dec(DsP,hh);
end else DsP := 0;
end;
kbRight: {Right}
begin
if longint(size - dsp) > hh*22 then h := hh*22*2 else h := (size-dsp)*2;
if (not hexing)or(ViewType = vtHex64) then
begin
if (hexpos+2 < h) then inc(hexpos,2) else begin hexpos := h-1; if (DsP+h div 2< Size) then mkey := kbCtrlRight end;
end else
if (Hexpos+1 < h) then inc(hexpos) else begin Hexpos := h-1; if (DsP+h div 2 < Size) then mkey := kbCtrlRight end;
end;
kbLeft: {Left}
begin
if (not hexing)or(ViewType = vtHex64) then
begin
if (Hexpos > 1) then dec(hexpos,2)
else if (DsP > 0) then begin mkey := kbCtrlLeft; hexpos := 0; end else Hexpos := hh*2-1;
end else
begin
if (Hexpos > 0) then dec(hexpos)
else if (DsP > 0) then begin mkey := kbCtrlLeft; hexpos := 0; end else Hexpos := hh*2-1;
end;
if longint(size - dsp) > hh*22 then h := hh*22*2 else h := (size - dsp)*2;
if (hexpos >= h) then hexpos := h-1;
end;
kbTab: {Tab}
begin
if ViewType = vtHex then hexing := not hexing{ else hexing:=true};
end;
kbF4: {F4}
begin
if ViewType = vtHex then
begin
ViewType := vtHex64;
hh := 64;
end else
begin
ViewType := vtHex;
hh := 16;
end;
if longint(size-dsp) > hh*22 then h := hh*22*2 else h := (size-dsp)*2;
if (hexpos >= h) then hexpos := h-1;
end;
kbF6: {F6}
begin
if ViewChLimit >= 2 then ViewChLimit := 0 else inc(ViewChLimit);
end;
kbHome: {Home}
begin
hexpos := (hexpos div (hh*2))*hh*2
end;
kbEnd: {End}
begin
if longint(size-dsp) > hh*22 then h := hh*22*2 else h := (size-dsp)*2;
hexpos := (hexpos div (hh*2)+1)*hh*2-1;
if hexpos > h then hexpos := h-1;
end;
kbCtrlHome: {CtrlHome}
begin
hexpos := hexpos mod (hh*2);
end;
kbCtrlEnd: {CtrlEnd}
begin
if longint(size-dsp) > hh*22 then h := hh*22*2 else h := (size-dsp)*2;
hexpos := hexpos+(h div (hh*2) - hexpos div (hh*2)-1*byte((h div 2) mod hh=0))*hh*2;
if (hexpos >= h) then
begin
dec(hexpos,hh*2);
if (hexpos >= h) then hexpos := h-1;
end;
end;
kbCtrlPgUp: {CtrlPageUp}
begin
dsp := 0; hexpos := 0;
end;
kbCtrlPgDn: {CtrlPageDown}
begin
if (size >= hh*22) then DsP := ((Size - hh*22) div hh+1)*hh else dsp := 0;
if longint(size-dsp) > hh*22 then hexpos := hh*22*2 else hexpos := (size-dsp)*2;
dec(hexpos);
end;
kbPgDn: {PageDown}
begin
if longint(Size-hh*22) > 0 then
if (DsP+hh*21 <= Size-hh*22) then inc(DsP,hh*21) else
DsP := ((Size-hh*22) div hh+1)*hh;
end;
kbPgUp: {PageUp}
begin
if longint(Size-hh*22) > 0 then
if (DsP-hh*21 >= 0) then dec(DsP,hh*21) else
DsP := 0;
end;
kbCtrlLeft: {CtrlLeft}
begin
if (DsP > 0) then dec(DsP);
end;
kbCtrlRight: {CtrlRight}
begin
if (DsP < Size-1) then inc(DsP);
if longint(size-dsp) > hh*22 then h := hh*22*2 else h := (size-dsp)*2;
if (hexpos > h) then hexpos := h-1;
end;
kbCtrlR:
begin
AdjustBuffer(true);
end;
kbESC: {ESCAPE} done := true;
end;
if dsp <> bufDSP then AdjustBuffer(false);
AdjustCursor;
DrawScr(DsP);
end; {if key<>kbNoKey then}
end;
ViewFile := 0;
set_cursor(false);
end;
PutScr(4);
end;
function Init_Drives : boolean;
var i : byte;
procedure chk(d : byte);
begin
if GetDriveInfo(d,Drives[nDrives+1]) = 0 then
begin
inc(nDrives);
end;
end;
begin
nDrives := 0; fillchar(Drives,SizeOf(Drives),#0);
for i := $00 to $03 do if nDrives >= Max_Drives then break else
begin
chk(i);
end;
for i := $80 to $85 do if nDrives >= Max_Drives then break else
begin
chk(i);
end;
for i := $02 to $80-1 do if nDrives >= Max_Drives then break else
begin
chk(i);
end;
for i := $85 to $FF-1 do if nDrives >= Max_Drives then break else
begin
chk(i);
end;
Init_Drives := nDrives > 0;
end;
function GetDrvSt(Drv : byte) : string;
begin
if (Drv>=$00)and(Drv<=$01) then GetDrvSt := 'FDD'+chr(Drv+ord('0')) else
if (Drv>=$80)and(Drv<=$84) then GetDrvSt := 'HDD'+chr(Drv-$80+ord('0'))
else GetDrvSt := hexb(Drv)+'h';
end;
function Choose_Drive(x1,y1 : byte) : byte;
var od,d : byte; c : char; Done : boolean;
sz : double;
procedure DrawItem(I,x,y : byte; Selected : boolean);
var c : byte;
s : string;
begin
if Selected then c := 03 else c:=01;
VidB(x,y,x+DriveDlgW,c);
if Selected then c := 00 else c:=15;
writestf(strf(i,2),x+1,y,c);
if Selected then c := 00 else c:=10;
writestf(GetDrvSt(Drives[i].Drive),x+6,y,c);
if Selected then c:=00 else c:=07;
with Drives[i] do
begin
writestf(strf(MaxTrack+1,6),x+14,y,c);
writestf(strf(MaxHead+1,6),x+23,y,c);
writestf(strf(MaxSector,5),x+32,y,c);
sz := (1.0*(SEHD)*(MaxTrack+1)*SecSiz/1024);
writestf(lz(size_str_kb(sz),09,' '),x+40,y,c)
end;
end;
begin
Choose_Drive := 0;
if (nDrives < 1) then if not Init_Drives then exit;
SaveScr(2);
if (x1=0) then x1 := text_maxx div 2 - DriveDlgW div 2;
if (y1=0) then y1 := text_maxy div 2 - nDrives div 2 - 2;
set_window(x1,y1,x1+DriveDlgW+2,y1+3+nDrives,Borders[brd_mix3],15,07,01,PA(10,01),' ',stHdr01,true);
inc(x1);
inc(y1);
writestf(stNum,x1+1,y1,14);
writestf(stDrive,x1+6,y1,14);
writestf(stTracks,x1+14,y1,14);