home *** CD-ROM | disk | FTP | other *** search
- Program DiskTalkCOM; { DISKTALK.PAS September 21, 1989 }
-
- { I have used a dense coding format, enabling complete subroutines fit on one
- computer screen. Using a more typical and readable format prevented this,
- making it harder to understand subroutines while in the modification process.
- Most variable declarations are at the top for editing, and sharing variables.
- }
-
- {$R+}
- TYPE HexByte = STRING[2];
- CONST EF: Byte = 26;
- VAR Buffer: array[0..511] of byte;
- HX: array[0..255] of HexByte;
- AS: array[0..255] of char;
-
- Atr, C, DIRn, Esum,Ebyt, F, First, N, R, S, SStart,
- SUsed, TByte, Tb: INTEGER;
-
- Block, Col, Ehi,Elo, Ml, Mr, Ps, Pe, Pt, Row, Sector, Sr, Start, TheChar,
- Tr,Track, Used: BYTE;
-
- DidRead, OK, SW, WP: BOOLEAN;
-
- X, YorN, Z: CHAR;
-
- FilVar: FILE OF BYTE;
-
- Name, Path, P, Pedit: STRING[14];
-
- {$I Regpack.typ}
- {$I ResetA.lib}
- {$I Getsectr.lib}
- {$I Monitor.lib}
- {$I Screen.lib}
- {$I Getkeys.lib}
-
- procedure Initialize; var N, Temp : byte;
- BEGIN CheckColor; { Check video display type.} for N := 0 to 255 do
- BEGIN case N of
- 7..13 : AS[N] := chr(N + 64); { The array AS consists of }
- 28 : AS[N] := '\'; { a PRINTABLE character for }
- 29 : AS[N] := ']'; { each byte 0 to 255. Some }
- 30 : AS[N] := chr(24); { of the characters are not }
- 31 : AS[N] := chr(25); { normally printable, because }
- else AS[N] := chr(N); { they change the display. }
- END; {case} HX[N] := '00'; Temp := N mod 16;
- If Temp <= 9 then HX[N][2] := chr(Temp + 48) {I use an array here }
- else HX[N][2] := chr(Temp + 55); {rather than making }
- Temp := N div 16; {a function in order }
- If Temp <= 9 then HX[N][1] := chr(Temp + 48) {to save calculation }
- else HX[N][1] := chr(Temp + 55); {time. }
- END; {for N} DidRead := false; { From Getsectr.lib } END;
-
- procedure Beep; BEGIN Sound(660); Delay(30); NoSound; Delay(25); END;
-
- procedure BigCursor; var Regis : RegPack; BEGIN
- If mem[$0000:$0449] < 7 then Regis.cx:= $0007 else Regis.cx:= $010B;
- Regis.ax:= $0100; intr($10,Regis); END;
-
- procedure Increment(var Trak, Sek: byte); BEGIN { 1:1 interleave made 5:1.}
- If Sek = 4 then BEGIN Sek := 1; { Sector 4 is last in Track. }
- Trak := Trak + 1; { So we advance Tracks now. }
- If Trak > 39 then Trak := 0; { The procedures "Increment" }
- END else BEGIN { and "Decrement" codIfy Adam }
- Sek := Sek + 5; { 5:1 Interleave. }
- If Sek > 8 then { This advances Sek 5 Sectors }
- BEGIN Sek := Sek - 8; END; END; END; { in the same Track. }
- procedure Decrement(var Trak, Sek: byte); BEGIN {Opposite direction.}
- If Sek = 1 then BEGIN Sek := 4; If Trak = 0 then Trak := 39
- else Trak := Trak - 1; END else BEGIN
- If Sek < 6 then Sek := Sek + 3 else Sek := Sek - 5; END; END;
-
- { REVEAL AND MODIFY PROCEDURES }
- procedure Choices; BEGIN GotoXY(1,2); { "Reveal disk" intro screen.}
- writeLn('**********************',
- '*********************************************************');
- writeLn('* Welcome to the Reveal',
- ' and Modify Adam Disk Utility. Here you can examine or *');
- writeLn('* change any part of t',
- 'he Adam disk. Unless you use F10 and SAVE any changes, *');
- writeLn('* nothing is changed. ',
- ' So enjoy your exploration! If you want to make a copy *');
- writeLn('* of one or more ADAM ',
- 'Blocks, use this utility to find the Start Block. Then *');
- writeLn('* put a DOS disk in dr',
- 'ive B:, and use Alt-F4 to COPY BLOCK(S) onto that disk. *');
- writeLn('* To copy an actual se',
- 'ctor from one ADAM disk to another, display the sector *');
- writeLn('* and put the target d',
- 'isk in drive A:, then tap F10 to SAVE it onto the same *');
- writeLn('* sector of the target',
- ' disk. ********************* Now, unless you already *');
- writeLn('* know which sector yo',
- 'u want to see, just tap the Enter key to Reveal "DIR1." *');
- writeLn('* Your selection is di',
- 'splayed in Hexadecimal on the left, text on the right. *');
- writeLn('* When you''re done, ju',
- 'st tap the F7 key to EXIT back to the Transfer program. *');
- writeLn('***********************',
- '*********************************************************');
- GotoXY(29,17); write('For Adam DIR, Hit Enter.');
- If DIRn=1 then Sector:=3 else Sector:=8; Track:=0;
- REPEAT GotoXY(29,16); write('Select Track (0-39) ');
- GotoXY(49,16); read(Track); UNTIL Track in [0..39];
-
- GotoXY(29,20); write('For Adam DIR, Hit Enter.');
- REPEAT GotoXY(29,19); write('Select Sector (1-8) ');
- GotoXY(49,19); read(Sector); UNTIL Sector in [1..8]; END;
-
- procedure ByteAtt(WhichByte : integer; Attr : byte); {Lights up the byte}
- BEGIN Row:=(WhichByte div 26)+2; Col:=(WhichByte mod 26); { selected. }
- ScreenAttribute(Col*2+1, Row, Attr); ScreenAttribute(Col*2+2, Row, attr);
- ScreenAttribute(Col +54, Row, Attr); END;
-
- procedure BigShow; BEGIN If DidRead then BEGIN ClrScr; { Editing screen}
- writeLn(' Reading A: ',0,':',Track,':',Sector); { with sector of }
- GotoXY(60,1); write('Byte:',TByte); for N:=0 to 511 do { disk displayed }
- BEGIN Row:= (N div 26)+2; Col:=(N mod 26); GotoXY(2*Col+1,Row);
- write(HX[Buffer[N]]); GotoXY(Col + 54,Row); write(AS[Buffer[N]]); END;
- GotoXY(30,1); Block:=(Track*4); case Sector of
- 3:Block:= Block+1; 8:Block:= Block+1; 5:Block:= Block+2;
- 2:Block:= Block+2; 7:Block:= Block+3; 4:Block:= Block+3; END; {case}
- write('Block:',HX[Block]); If odd(Sector) then write('a')
- else write('b'); TextColor(black); TextBackGround(white);
- If Track = 0 then If Sector = 3 then BEGIN GotoXY(38,24); write('DIR 1');
- GotoXY(25,1); write('A'); GotoXY(27,1); write('SB'); DIRn:=1;
- GotoXY(39,1); write('BU'); END else
- If Sector = 8 then BEGIN GotoXY(38,24); write('DIR 2');
- GotoXY(41,1); write('A'); GotoXY(43,1); write('SB'); DIRn:=2;
- GotoXY(3,1); write('BU'); END;
- GotoXY(1,22); TextBackGround(white); TextColor(blue); { blue=Underline }
- writeLn(' F1=RESET * F2=SB * F3=HELP * F4=$10 ', { in mono. }
- '(User A) * F5=DIR * F6=$00 ');
- writeLn(' F7=EXIT * F8=$03 * F9=$14 (Del A) * ',
- 'F10=SAVE CHANGES * PgDn=NEXT ');
- write('** Alt-F2=SEEK SW FILE **'); GotoXY(57,24);
- write('** Alt-F4=COPY BLOCK **'); TextColor(White); END; END;
-
- procedure SmallShow; BEGIN R:=7; REPEAT GotoXY(1,R); ClrEOL; R:=R+1; UNTIL
- R=17; for N:= 104 to 416 do BEGIN Row:=(N div 26)+2; Col:=(N mod 26);
- GotoXY(2*Col+1,Row); write(HX[Buffer[N]]); GotoXY(Col + 54,Row);
- write(AS[Buffer[N]]); END; { Fixes the DIR after Help } END;
-
- procedure NewChar(ch : char); BEGIN Beep; GotoXY(48,25); { Update video & RAM.}
- write('Last change:',HX[TheChar],' to: at BYTE:',(TByte));
- WriteScreen(62,25,chr(Buffer[TByte]),112); WriteScreen(67,25,ch,112);
- Buffer[TByte] := ord(ch); WriteScreen((TByte mod 26) + 54,
- (TByte div 26)+2,ch,112); TextColor(black);TextBackGround(white);
- GotoXY(2*(TByte mod 26)+1,(TByte div 26) + 2); write(HX[ord(ch)]);
- TextColor(white); TextBackGround(black); END;
-
- procedure ShowChar; { Displays Byte }
- BEGIN GotoXY(65,1); ClrEOL; write(TByte); { and Char }
- TheChar := Buffer[TByte]; GotoXY(70,1); write('$'); { at Upper }
- { run time error ^ 90 in Reveal using PgDn }
- TextColor(black);TextBackGround(white); { Right of }
- write(HX[TheChar],' = ',Buffer[TByte]); GotoXY(37,22); { screen. }
- TextColor(white);TextBackGround(black); END;
-
- procedure SB; BEGIN If (Sector+Row)=29 then BEGIN END else BEGIN
- ByteAtt(TByte,15); TByte:=((Row-2)*26+S+13);Tb:=TByte; ByteAtt(TByte,112);
- ShowChar; S:= (Buffer[TByte]*2); If (S>0) and (S<159) then BEGIN
- Sector:=1; REPEAT Increment(Track,Sector); S:=(S-1) { SB=ADAM Start Block.}
- UNTIL S=0; GetSector('R','A',0,Sector,Track,DidRead);
- If (Buffer[0]=0) and (Buffer[1]=1) then TByte:=259 else TByte:=0;
- BigShow; ShowChar; ByteAtt(TByte,112); END else
- BEGIN GotoXY(45,1); write('*INVALID SB*'); Beep; S:=$00; GetKeys(X,X);
- GotoXY(45,1); write(' '); GotoXY(37,22); END; END; END;
-
- procedure FileAttr; BEGIN If S*2+TByte<510 then BEGIN ByteAtt(TByte,15);
- TByte:= ((Row-2)*26+S+12); ByteAtt(TByte,112); If F=1 then NewChar(#16)
- else NewChar(#20); ShowChar; GotoXY(37,22); END else END;
- { ADAM file attribute.}
- procedure RevealHelp; BEGIN GotoXY(1,6); ClrEOL; GotoXY(1,7); { Help for }
- writeLn('* A 512 byte Sector ', { the Reveal Adam Disk screen. }
- '(a or b of 2 Sector Adam Block) is shown in hex and text. *');
- writeLn('* Top line "Reading"',
- ' displays Drive:Side:Track:Sector, Adam Block being read. *');
- writeLn('* The SB and BU mark',
- 'ers show Start Block and Blocks Used column in both DIRs. *');
- writeLn('* In DIR2 the BU for',
- ' each file is on the line BELOW the line of the filename. *');
- writeLn('* The A marker befor',
- 'e SB in DIRs shows file Attribute (Deleted= 14 User= 10). *');
- writeLn('* F1 lets you ',
- 'quickly RESET to another Track and Sector anywhere on the disk. *');
- writeLn('* Type changes',
- ' in, or hold down "Alt" while using Num keys for Decimal value. *');
- writeLn('* You MUST use',
- ' F6 or F8 to enter Hex 00 or Hex 03 respectively (NOT Alt-Num). *');
- writeLn('* F2, F4, and ',
- 'F9 are for DIRs. F2=Go to file, F4 or F9=User or Deleted file. *');
- writeLn('** Alt-F2 Will',
- ' SEEK Adam SmartWriter files from here to the end of the disk. **');
- ClrEOL; GetKeys(X,X); SmallShow; ShowChar; ByteAtt(TByte,112); END;
-
- procedure Advance; BEGIN If TByte < 511 then BEGIN ByteAtt(TByte,15);
- TByte := TByte + 1; ByteAtt(Tbyte,112); ShowChar; END; END;
- { Advance to next character only if not at end of sector. }
-
- procedure Seek; { Seeks SmartWriter files (Hdr: 0001) to end of disk. }
-
- procedure Find; BEGIN Increment(Track,Sector); { Adam Blocks start on }
- If odd(Sector) = false then BEGIN Seek; END else BEGIN {odd Sectors.}
- GetSector('R','A',0,Sector,Track,DidRead); If Buffer[1]=1 then
- BEGIN If Buffer[0]=0 then BEGIN TByte:=259; BigShow; ShowChar;
- ByteAtt(TByte,112); END else Seek; END else Seek; END; END;
- BEGIN If Track<39 then BEGIN Find; END else BEGIN Sector:=Sr; Track:=Tr; Beep;
- Beep; GotoXY(21,25); write('** No SmartWriter file found - TAP ENTER');Read(Z);
- GotoXY(1,25); ClrEOL; GetSector('R','A',0,Sector,Track,DidRead); ShowChar;
- ByteAtt(TByte,112); END; END;
-
- procedure ResetTrSr;BEGIN ClrScr;writeLn('RESET TRACK AND/OR SECTOR');
- REPEAT ClrEOL; writeLn('Which Track (0-39)? ');
- write('(Current setting: TRACK ',Track,' - Tap Enter to retain it)');
- Beep; GotoXY(21,2); Read(Track); UNTIL Track in [0..39];
- REPEAT GotoXY(1,3); ClrEOL; writeLn('Which Sector (1-8)? ');
- write('(Current setting: SECTOR ',Sector,' - Tap Enter to retain it)');
- Beep; GotoXY(21,3); Read(Sector);
- UNTIL Sector in [1..8]; GetSector('R','A',0,Sector,Track,DidRead);
- TByte := 0; BigShow; ShowChar; ByteAtt(Tbyte,112); END;
-
- procedure SaveChanges; BEGIN GotoXY(1,25); Beep;
- write(' ** CAUTION ** Write changes? '); Beep;
- Getkeys(YorN,X); If UpCase(YorN)='Y' then
- BEGIN write('Y'); GetSector('W','A',0,Sector,Track,DidRead);
- BigShow; ShowChar; ByteAtt(Tbyte,112); END
- else BEGIN GotoXY(1,25); write('** Changes NOT written to disk.');
- GotoXY(37,22); END; END;
-
- procedure SectXfrWrite(var SU: integer); { Set Name of file before calling.}
- { Writes SU count of 512 byte SECTORS from current sector, to B:\Name.}
- BEGIN GotoXY(17,16);
- Assign(FilVar,Path+Name); {$I-} Rewrite(FilVar) {$I+};
- OK:=(IOresult=0); If not OK then
- BEGIN write('** DOS won''t accept ',Path+Name); Beep; END else
- BEGIN Beep; write('Working...');
- GetSector('R','A',0,Sr,Tr,DidRead); If not DidRead then
- BEGIN GotoXY(55,15); write('**READ ERROR - ABORTED**'); Beep; Beep; END else
- BEGIN REPEAT For N:=0 to 511 do BEGIN write(FilVar,buffer[N]); END;
- Increment(Tr,Sr); GetSector('R','A',0,Sr,Tr,DidRead); SU:=(SU-1);
- UNTIL (SU)=0; write(FilVar,EF); { DOS E.O.F marker.} write('** DONE');
- END; END; Sr:=Sector; Tr:=Track; Close(FilVar);
- write(' - Tap Enter'); Beep; Read(X); END;
-
- procedure BlockTransfer; { Copies one or more 1k ADAM blocks to a DOS file.}
-
- procedure BlkXfrInstruct; BEGIN
- For N:=6 to 16 do BEGIN GotoXY(1,N); ClrEOL; END; GotoXY(1,7);
- writeLn('* This utility will ', { Adam BLOCK COPY (Transfer) Instructions.}
- 'COPY BLOCK(S) from an Adam disk to a DOS file starting at *');
- writeLn('* the current Block:',HX[Block],
- ' If the Block displayed now isn''t the right Start Block *');
- writeLn('* on the Adam disk f',
- 'or the DOS file you want to create, just tap Enter alone. *');
- writeLn('* NOTE: The Block s',
- 'elected MUST end in a, indicating the Start of the Block. *');
- REPEAT GotoXY(1,12);
- writeLn(' To continue, type in the number of BLOCKS TO COPY: (160 Max.)');
- writeLn(' (Enter=ABORT)');
- GotoXY(54,12); SUsed:=0; Read(SUsed); { Get Number of Blocks to Copy.}
- UNTIL SUsed in [0..160]; If (SUsed)=0 then
- BEGIN Beep; Beep; write('**ABORTED - Enter again'); Read(X); END else
- BEGIN Path:='B:\'; { NOTE: Path input could be added here.}
- BEGIN GotoXY(1,13); ClrEOL; GotoXY(47,15); write('(Enter=ABORT)');
- GotoXY(36,14); Write('DOS FILE NAME ',Path); Read(Name);
- If Length(Name)=0 then
- BEGIN Beep; Beep; write('**ABORTED - Enter again'); Read(X); END else
- BEGIN GotoXY(17,15); ClrEOL; write('Preparing to COPY ',SUsed,
- ' BLOCK(s) starting at ',HX[Block],' to ',Path+Name);
- SUsed:=(SUsed*2); { 2 Sect/Block }
- SectXfrWrite(SUsed); END;
- END;
- END; END;
-
- { procedure BlockTransfer starts here }
- BEGIN If not odd(Sector) then { Not odd Sector = we're in 2nd half of Block.}
- BEGIN GotoXY(1,25); Beep; Write('**',HX[Block],'b selected - USE PgUp');
- GotoXY(16,25); GetKeys(X,X); { Display message & wait for keystroke. }
- END else BEGIN Sr:=Sector; Tr:=Track; BlkXfrInstruct;
- GetSector('R','A',0,Sector,Track,DidRead); SmallShow;
- END; Beep; GotoXY(37,22); END;
-
- procedure DOSin2adam;
- var LB,BU:integer; Q,SS,TT:byte;
-
- procedure DOSinDONE;
- BEGIN Beep; write(' - Adam BU:',BU,' LB:',LB); GotoXY(16,22);
- write('** DONE - DOS file is copied to X on the Adam disk.'); GotoXY(16,23);
- write(' (Note: only ASCII was copied.) Tap Enter'); Read(X); END;
-
- procedure DOSinCOPY;
- BEGIN SS:=5; TT:=0; BU:=1;
- GetSector('R','A',0,SS,TT,DidRead); { Copy Adam TABs - could eliminate this.}
- Buffer[0]:=0; For N:=1 to 2 do Buffer[N]:=1; { 00 01 01 = SmartWriter Hdr.}
- { Put S.Writer margins on Adam disk - won't match srce. OR dest. file (elim?).}
- Buffer[3]:=12; Buffer[4]:=120; { Top & Bottom margins x2 in SmartWriter.}
- Buffer[5]:=9; Buffer[6]:=69; { Left & Right margins.} Buffer[7]:=2;
- For N:=8 to 11 do Buffer[N]:=0; Buffer[12]:=1; { Buffer[12] is 1st TAB, }
- For N:=13 to 84 do Buffer[N]:=0; { only 1 set - maybe wrong.}
- { Copy the source file, starting AFTER the Adam Header we just made.}
- N:= 259; LB:= 259; { Xfer ASCII }
- While not EOF (FilVar) do BEGIN read(FilVar,Q); If (Q<32) and (Q<>13)
- { Copy CR - strip all other Lo/Hi ASCII (less than 32, more than 126).}
- or (Q>126) then BEGIN END else BEGIN Buffer[N]:=Q; N:=N+1; LB:=LB+1;
- If N=512 then BEGIN N:=0; GetSector('W','A',0,SS,TT,DidRead);
- Increment(TT,SS); If LB > 1023 then BEGIN BU:=BU+1; LB:=1; END;
- END; END; END; { Fill end of }
- Close(FilVar); REPEAT Buffer[N]:=$20; N:=N+1; UNTIL N=512; { Last Sector }
- GetSector('W','A',0,SS,TT,DidRead); { with spaces.}
- GetSector('R','A',0,3,0,DidRead); Buffer[95]:=BU; { Update Adam DIR }
- Buffer[97]:=BU; Buffer[99]:=Lo(LB); Buffer[100]:=Hi(LB);
- GetSector('W','A',0,3,0,DidRead); DOSinDONE;
- END;
-
- procedure NonAdamA; BEGIN GotoXY(9,24);
- write('**ABORTED. SPECIALLY PREPARED ADAM DISK MUST BE IN DRIVE A: ');
- Beep; Beep; For N:=1 to 2 do BEGIN Delay(400); write('*'); END; END;
-
- procedure DOSinNote; { A special note to the user, if DOS-IN won't work.}
- BEGIN GotoXY(1,13); ClrEOL; writeLn('NOTE:');
- writeLn('* You may be able to force the copying ',
- 'of the DOS file to the disk in A:, IF: *');
- writeLn('* 1) The disk in A: is an Adam disk. ',
- '2) You are willing to risk losing data *');
- writeLn('* now on the disk in A:. To do this, ',
- 'use the REVEAL utility to put an upper *');
- writeLn('* case letter X at byte 78 of Track 0, ',
- 'Sector 2. This is the first character *');
- writeLn('* of the 1st file entry on the Adam dis',
- 'k. ** The safer method is to prepare a *');
- writeLn('* new Adam DATA disk, with an empty fil',
- 'e named X as the only directory item. *');
- write('Tap the Enter key to continue'); Read(X); END;
- procedure NotFound; BEGIN GotoXY(25,25); Beep; Beep;
- write('** ',P,'-AX.TXT not found - Tap Enter'); P:='B:\'; Read(X); END;
-
- procedure NoDOSin; BEGIN GotoXY(25,25); Beep; Beep; Close(FilVar);
- write('**ABORTED - Tap Enter'); Read(X); END;
-
- procedure DOSinTEST;
- BEGIN GetSector('R','A',0,2,0,DidRead); { Sect.2, Track 0=DOS Media Descr.}
- If not DidRead then BEGIN NonAdamA; { Disk error.} END else
- If Buffer[0]=$FD then BEGIN NonAdamA; { FD=DOS disk.} END else
- GetSector('R','A',0,3,0,DidRead);
- If Buffer[78]<>$58 then BEGIN NonAdamA; DOSinNote; { 1st not X } END else
- BEGIN GotoXY(18,15); { Get Drive:\path\name. }
- write('DOS drive and path of -AX.TXT source file: '); GotoXY(31,16);
- write('(ie: C:\wp\stuff\ - ENTER = ',P,' )'); GotoXY(54,18);
- write('** A = ABORT **');
- GotoXY(61,15); Read(Path); C:=WhereX; { Get cursor position.}
- GotoXY(31,16); ClrEOL; GotoXY(54,18); ClrEOL;
- If Length(Path)=0 then Path:=P; P:=Path; { P either old or new one now.}
- If UpCase(P[1])='A' then BEGIN
- GotoXY(28,20); Path:='B:\'; P:=Path;
- write('** ABORTED - Tap Enter'); Beep; Beep; Read(X); END else
- BEGIN If (P[Length(P)] <> '\') then BEGIN
- REPEAT GotoXY(31,16); write(' ** PATH MUST END WITH "\" **');
- Beep; Beep; Delay(900); GotoXY(C,15); ClrEOL; Read(Pedit);
- P:=P+Pedit; C:=WhereX;
- UNTIL (P[Length(P)] = '\'); END;
- Assign(FilVar,P+'-AX.TXT'); {$I-} Reset(FilVar) {$I+}; OK:=(IOresult=0);
- If not OK then BEGIN NotFound; END else
- BEGIN C:=FileSize(FilVar);
- GotoXY(16,19); write('FOUND ',P,'-AX.TXT file of ',C,' bytes. Y=Continue');
- GetKeys(X,X); If UpCase(X) <> 'Y' then BEGIN NoDOSin; { ABORTED } END else
- BEGIN { Continue writing file.}
- GotoXY(16,19); write('WRITING ',P,'-AX.TXT to A:X (Adam SmartWriter format)');
- GotoXY(21,20); write('DOS ',C,' bytes ');
- DOSinCOPY; END; END; { Adam 'X' file copied from DOS Drive:\path\-AX.TXT. }
- END; END; { DOSinTEST ends here.} END;
-
- procedure DOSinGREET;
- BEGIN ClrScr; GotoXY(1,1);
- writeLn('* Welcome to the DOS-IN utility. ',
- 'This feature allows you to copy a DOS file *');
- writeLn('* onto an ADAM disk. WARNING: THIS',
- ' IS A LIMITED SAFETY UTILITY. It does not *');
- writeLn('* perform many safety checks, and w',
- 'ill * OVER-WRITE DATA * on the disk in the *');
- writeLn('* A: drive if you proceed. BEFORE',
- ' USING this utility, put a special "blank" *');
- writeLn('* ADAM DATA disk in drive A:, and m',
- 'ake a copy of the DOS target file with the *');
- writeLn('* name "-AX.TXT" (without quotes). ',
- ' That is, the DOS file you wish to copy to *');
- writeLn('* the Adam disk must be named -AX.T',
- 'XT, and the Adam disk in drive A: must be *');
- writeLn('* blank (see documentation). ONLY ',
- 'ONE SUCH FILE CAN BE COPIED PER ADAM DISK. *');
- writeLn('* That is, once the Adam disk has a',
- ' file on it, a different Adam disk will be *');
- writeLn('* needed to copy another DOS file. ',
- ' * NOTE: only ASCII 32-126, TAB, CR, & FF *');
- writeLn('* are copied by this utility. Put a',
- ' prepared Adam disk in A: now to continue. *');
- GotoXY(1,13);
- write('** TAP THE LETTER Y KEY TO CONTINUE',
- ' OR ENTER TO ABORT THE DOS-IN UTILITY. **');
- GotoXY(20,13); Beep; GetKeys(X,X); DidRead:=False; GotoXY(1,13); ClrEOL;
- If UpCase(X)<>'Y' then BEGIN GotoXY(47,13); write('* ABORTED *'); Beep;
- Delay(50); Beep; Delay(750); END else
- DOSinTEST; END;
- { Main body of procedure DOSin2adam.}
- BEGIN DOSinGREET; { Copy only if tests passed.} END;
-
-
- procedure TakeInstructions; var choice, EscChoice : char;
- BEGIN { BEGIN TakeInstructions - Wait 'til a key is pressed. If it's }
- REPEAT { a "special" key, check what action to }
- GetKeys(choice,EscChoice); { take. If it's "ordinary", insert its }
- If choice = chr(27) then { value in the Buffer at the current }
- case EscChoice of { place and display it. }
- #0 : BEGIN NewChar(#27); Advance; END; { Enters Esc Code **Esc }
- 'I': {PgUp} BEGIN Decrement(Track,Sector); { **PgUp }
- GetSector('R','A',0,Sector,Track,DidRead); TByte := 0; Bigshow;
- ShowChar; ByteAtt(TByte,112); END;
- 'Q': {PgDn} BEGIN Increment(Track,Sector); { **PgDn }
- GetSector('R','A',0,Sector,Track,DidRead); TByte := 0; Bigshow;
- ShowChar; ByteAtt(TByte,112); END;
- 'G': {Home} BEGIN ByteAtt(TByte,15); TByte := 0; { **Home }
- ByteAtt(TByte,112); ShowChar; END;
- 'O': {END} BEGIN ByteAtt(TByte,15); If TByte < 494 then { **END }
- TByte := (TByte + (25 - ((TByte + 26) mod 26))) else TByte:= 511;
- ByteAtt(TByte,112); ShowChar; END;
- 'H': If (TByte div 26) > 0 then BEGIN { UP ARROW }
- ByteAtt(TByte,15); TByte := TByte - 26; ByteAtt(Tbyte,112);
- ShowChar; END;
- 'P': If TByte < 486 then BEGIN { DOWN ARROW }
- ByteAtt(TByte,15); TByte := TByte + 26; ByteAtt(Tbyte,112);
- ShowChar; END;
- 'K': If TByte > 0 then BEGIN { LEFT ARROW }
- ByteAtt(TByte,15); TByte := TByte - 1; ByteAtt(Tbyte,112);
- ShowChar; END;
- 'M': BEGIN Advance; END; { calls procedure Advance - RIGHT ARROW }
- ';': BEGIN ResetTrSr; END;{RESET*F1 }
-
- '<': BEGIN If Track = 0 then case Sector of { SEARCH*F2 }
- 3 : BEGIN S:= 0; SB; END;
- 8 : BEGIN S:= 8; SB; END else END; {case} END;
- 'i': BEGIN GotoXY(1,25); ClrEOL; GotoXY(21,25); { SEEK*Alt-F2 }
- write('Seeking SmartWriter file to end of disk');
- Tr:=Track; Sr:=Sector; Seek; END;
- '=': BEGIN RevealHelp; END;{ HELP*F3 }
- '>': BEGIN If (Track=0) and (Sector=3) or (Sector=8) then { USER*F4 }
- BEGIN F:=1; S:=Sector; FileAttr; Beep; END else END;
- 'k': BEGIN BlockTransfer; END; {1k BLOCK XFR - **Alt-F4 }
- 'R': BEGIN If (Track=0) and (Sector=3) or (Sector=8) then { USER*INS }
- BEGIN F:=1; S:=Sector; FileAttr; Beep; END else END;
- '?': BEGIN Track:=0; If DIRn=1 then Sector:=3 else Sector:=8; { DIR*F5 }
- GetSector('R','A',0,Sector,0,DidRead);
- TByte:=Tb; BigShow; ShowChar; ByteAtt(TByte,112); END;
- '@': BEGIN NewChar(#00); Advance; END;{ $00 *F6 }
- 'B': BEGIN { Enters a chr(3), equivalent to <Ctrl><Break>. $03 *F8 }
- NewChar(#3); Advance; END;
- 'C': BEGIN If (Track=0) and (Sector=3) or (Sector=8) then { DELETE*F9 }
- BEGIN F:=0; S:=Sector; FileAttr; Beep; END else END;
- 'S': BEGIN If (Track=0) and (Sector=3) or (Sector=8) then { DELETE*DEL }
- BEGIN F:=0; S:=Sector; FileAttr; Beep; END else END;
- 'D': BEGIN SaveChanges; { SAVE - **F10 }
- END; END { case }
- else BEGIN NewChar(choice); Advance; END; { For regular ASCII }
-
- UNTIL (choice = chr(27)) and (EscChoice = 'A'); { EXIT **F7 }
- { Return to Main Loop } END;
- { MAIN PROGRAM LOOP - TRANSFER PROCEDURES }
- procedure DiskCheck; { Disk-related error checking & identification.}
-
- procedure Data; { Additional test for Adam DATA disk, after CASE below.}
- BEGIN GetSector('R','A',0,3,0,DidRead); If Buffer[0]=$46 then
- BEGIN write(' Probable Adam SmartFiler DATA disk.'); END else
- BEGIN Beep;write('** CAN''T IDENTIFY TYPE OF DISK IN A: **');END; END;
-
- BEGIN { DiskCheck starts here.}
- GotoXY(9,6); Beep; write(' The ADAM DISK must be in Drive A:',
- ' now, in order to continue.'); GotoXY(15,7); write('Tap',
- ' Y when ready to go, or any other key to ABORT.'); GetKeys(YorN,Z);
- If UpCase(YorN)='Y'then BEGIN ResetA; GetSector('R','A',0,2,0,DidRead); END
- else BEGIN writeLn(' ');writeLn(' ');Beep; write('**ABORTED**'); Halt; END;
- If not DidRead then {ResetA resets the drive} BEGIN
- Beep; writeLn(' '); write('**DISK ERROR - TERMINATED**');Beep;Halt; END else
- { Next, use Buffer[0] (DOS disk descriptor byte) to check disk.} BEGIN
- GotoXY(20,16); CASE Buffer[0] of
- $CB:BEGIN write('Probable Adam SmartFiler DISK MANAGER "DOS" disk.'); END;
- $75:If Buffer[4] =$DD then
- BEGIN write(' Probable ADAMLINK system disk.'); END else
- BEGIN Data; END;
- $52:If Buffer[20]=$D0 then { 75,52,20 are common ASCII, so do 2nd test.}
- BEGIN write(' Probable AdamBASIC system disk.'); END else
- BEGIN Data; END;
- $20:If Buffer[1] =$30 then
- BEGIN write(' Probable AdamLOGO system disk.'); END else
- BEGIN Data; END;
- $FF:BEGIN If Buffer[5]=$FF then
- BEGIN write(' Probable Adam CP/M system disk.') END else
- BEGIN write('** A: May be NON-ADAM disk! (DSDD 8) **'); END; END;
- $FC:BEGIN write('** A: May be NON-ADAM disk! (SSDD 9) **'); END;
- $FD:BEGIN write('** A: May be NON-ADAM disk! (DSDD 9) **'); END;
- else Data; END; { Case } END;
- GotoXY(24,17); write('Enter=CONTINUE * Ctrl-C=STOP'); Beep; Read(Z); END;
-
- procedure LiteName; BEGIN TextColor(black); { Lights up chosen filename.}
- TextBackGround(white); N:=Tbyte+First; Row:=N div 26+2; Col:=1;
- Atr:=Buffer[N+12];
- REPEAT GotoXY(2*Col,Row); write(AS[buffer[N]],' '); N:=N+1; Col:=Col+1;
- UNTIL (Buffer[N]=3) or (Col>11); N:=N-1; If UpCase(Buffer[N])='H' then
- SW:=true else SW:=false; { Determine if it's a SmartWriter file } If SW
- then BEGIN GotoXY(55,11); write('** Adam SmartWriter file.'); END;
- If Atr=$14 then BEGIN GotoXY(55,11); write('DELETED') END;
- TextColor(white); TextBackGround(black);
- GotoXY(2*Col-2,Row); write(AS[buffer[N]],' '); GotoXY(1,22); END;
-
- procedure DarkName; BEGIN GotoXY(55,11); ClrEOL; { Turn off lite when leaving.}
- N:=Tbyte+First; Row:=(N div 26)+2; Col:=1;
- REPEAT GotoXY(2*Col,Row); write(AS[buffer[N]],' '); N:=N+1; Col:=Col+1;
- UNTIL Col>11; END;
-
- procedure Err; BEGIN Beep; GotoXY(59,2); ClrEOL; GotoXY(45,1);
- write('** BAD SB, BU or LB **'); ClrEOL; Beep; GotoXY(1,22); END;
- { For invalid selections by user.}
-
- procedure XDIR; { Displays Adam Transfer DIR in 26 byte lines. }
- BEGIN GetSector('R','A',0,Sector,0,DidRead);
- If DidRead then BEGIN ClrScr; for N:= (First) to 511 do BEGIN
- Row:=((N - First) div 26)+2; Col:=((N - First) mod 26)+1;
- GotoXY(2*Col,Row); If Col > 12 then write(HX[buffer[N]])
- else write(AS[buffer[N]]); END;
- TextColor(black); TextBackGround(white); GotoXY(40,1); write('BU');
- GotoXY(1,22); write('** USE ARROWS TO SELECT FILE **'); GotoXY(38,22);
- write('DIR ',DIRn); GotoXY(1,23); TextColor(blue); {blue=Underline}
- write(' ** F10=TRANSFER selected file * F3=HELP * '); {in mono. }
- write(' F7=EXIT * '); If DIRn = 1 then
- BEGIN write('PgDn = Next DIR **'); END else
- BEGIN write('PgUp= First DIR **'); END; GotoXY(1,24);
- write(' ** HOLD DOWN Ctrl or Alt to start either:',
- ' Ctrl-F5=DOS-IN * Alt-F3=REVEAL **');
- GotoXY(1,22); END else err; END;
-
- procedure FixDIR; BEGIN for R:=8 to 17 do { Restores Dir after HELP or BlockX.}
- BEGIN GotoXY(1,R); ClrEOL; END; for N:=(First)+156 to (First)+415 do
- BEGIN Row:=((N - First) div 26)+2; Col:=((N - First) mod 26)+1;
- GotoXY(2*Col,Row); If Col > 12 then write(HX[buffer[N]])
- else write(AS[buffer[N]]);
- END; LiteName; GotoXY(1,22); END;
-
- procedure Settings; BEGIN { Get PageStart, PageEnd & Mgns. from SW Header }
- {$R-} Ps:=Buffer[3]; Pe:=Buffer[4]; Pt:=(Pe-Ps); { and Save w/WP format.}
- Buffer[4]:=Pt; Ml:=Buffer[5]; Ml:=Ml+1; Mr:=Buffer[6]; Mr:=Mr+1; {$R+}
- If Ps+Pe+Ml+Mr > 255 then BEGIN { Range Checking off reading Adam in case.}
- GotoXY(55,5); write(' ** PROBABLE ERROR IN');
- GotoXY(55,6); write(' ** ADAM FILE MARGINS');
- GotoXY(55,7); write(' - continuing -'); Beep; END;
- Buffer[9]:=Ml; Buffer[10]:=Mr; { Margins. } Buffer[0]:=$D0; { them }
- Buffer[1]:=$42; Buffer[2]:=$78; Buffer[3]:=$42; Buffer[5]:=$D0; { to WP }
- Buffer[6]:=$C0; Buffer[7]:=$00; Buffer[8]:=$4E; Buffer[11]:=$C0; { Hdr. }
- for N:=0 to 11 do BEGIN write(FilVar,Buffer[N]); END; END;
-
- procedure Transfer; { Translates and transfers an ADAM file to a DOS file.}
-
- procedure OneSector; BEGIN If Esum>511 then Ebyt:= 511 else Ebyt:= Esum;
- If SUsed>2 then Ebyt:=511; If SUsed=1 then Ebyt:=Esum-512; If Ebyt<0
- then BEGIN END else BEGIN For N:= S to Ebyt do
- BEGIN If SW then { SW is set in procedure LiteName. }
- BEGIN If buffer[N]= $13 then buffer[N]:= $94; { If SmartWriter file, }
- If buffer[N]= $14 then buffer[N]:= $95; { change Adam UL to WP }
- If buffer[N]= $0D then buffer[N]:= $0A; { and CR to LF. }
- END; write(FilVar,buffer[N]); { Write character to DOS file }
- END; Increment(Track,Sector); GetSector('R','A',0,Sector,Track,DidRead);
- END; SUsed:=(SUsed-1); END;
-
-
- { The main TRANSFER procedure starts here }
- BEGIN GetSector('R','A',0,Sector,Track,DidRead); If not DidRead then
- BEGIN Beep; GotoXY(59,2); write('**DISK ERROR**'); Beep; END else BEGIN
- If WP=true then Settings; WP:=false;
- OneSector; S:=0; REPEAT OneSector; UNTIL SUsed<1; END; END;
- procedure SetUp; BEGIN N:=TByte; N:=(N+First+13); { Read File Info. }
- Start:=Buffer[N]; If (TByte=494) AND (DIRn=1) then BEGIN { If the Last }
- GetSector('R','A',0,8,0,DidRead); Used:=Buffer[1]; { file in DIR 1. }
- Elo:=Buffer[3]; Ehi:=Buffer[4]; GetSector('R','A',0,3,0,DidRead); END
- else { For all files but Last file in DIR 1 (If-AND above).} BEGIN
- N:=N+6; Used:=Buffer[N]; N:=N+2; Elo:=Buffer[N];
- N:=N+1; Ehi :=Buffer[N]; END;
- Esum:= (Elo+(Ehi*256)-1); GotoXY(1,1); write('SB:',Start,
- ' BU:',Used,' LB:',Esum,' ');
- If ((Start+Used)>159) or (Start>158) or (Used<1) or (Esum<1) then
- BEGIN Err; END else
-
- BEGIN {Start Xfr} GotoXY(55,3); ClrEOL; GotoXY(55,2); ClrEOL;
- write(' ENTER=',P); GotoXY(45,1); ClrEOL; write('DOS DRIVE:\PATH\ ');
- Read(Path); C:=WhereX; { Get cursor position to edit path if no "\".}
- If UpCase(Path[1])='A' then
- BEGIN Beep; GotoXY(45,1); write('** CAN''T USE DRIVE A: **');
- Path:=P; ClrEOL; END
- else If (Length(Path)=1) or (Length(Path)>1) and (Path[2] <> ':') then
- BEGIN Beep; GotoXY(45,1); write('** USE ":", AS IN C:\WP\ **');
- Path:=P; ClrEOL; END else BEGIN
- If (Length(Path)>0) and (Path[Length(Path)] <> '\') then
- BEGIN REPEAT GotoXY(55,2); write('** MUST END WITH "\" **');
- Beep; Beep; Delay(900); GotoXY(C,1); Read(Pedit);
- Path:=Path+Pedit; C:=WhereX;
- UNTIL (length(Path) < 1) or (Path[Length(Path)] = '\');
- GotoXY(55,2); ClrEOL; { delete error message }
- END;
-
- If length(Path)=0 then Path:=P else P:=Path;
- GotoXY(55,2); write('** Enter DOS filename **');
- ClrEOL; GotoXY(55,3); ClrEOL; write(' (ENTER alone=Cancel)');
- SStart:=(Start*2); SUsed:=(Used*2); Sector:=1; Track:=0;
- REPEAT Increment(Track,Sector); SStart:=(SStart-1); UNTIL (SStart)<1;
- GotoXY(45,1); ClrEOL; write(Path); Read(Name); GotoXY(55,2); ClrEOL;
- GotoXY(55,3); ClrEOL; GotoXY(45,1); ClrEOL; If length(Name)=0 then
- BEGIN write('** NO TRANSFER'); Beep; END else
- BEGIN Assign(FilVar,Path+Name); {$I-} Rewrite(FilVar) {$I+};
- OK:=(IOresult=0); If not OK then
- BEGIN Beep; write(Path+Name); P:='B:\'; GotoXY(55,2);
- write('** DOS PATH\NAME ERROR **'); Beep; END
-
- else BEGIN write('WRITING: ',Path+Name);
- If SW then BEGIN S:=259; GotoXY(55,3); write(' (Enter=TXT format) ');
- Beep; GotoXY(58,2); ClrEOL; write('WP 4.2 Output? '); GetKeys(YorN,Z);
- GotoXY(55,3); ClrEOL; GotoXY(58,2); write('OUTPUT FORMAT: ');
- If UpCase(YorN)='Y' then BEGIN WP:=true; write('WP'); END
- else BEGIN WP:=false; write('TXT'); ClrEOL; END
- END else
- BEGIN S:=0; {Hdr} GotoXY(58,2); write('OUTPUT FORMAT: BIN'); ClrEOL; END;
- Transfer; write(FilVar,EF); { DOS End Of File marker.}
- GotoXY(55,3); write(' ** DONE **'); ClrEOL; END; Close(FilVar); END;
- For N:=5 to 7 do BEGIN GotoXY(55,N); ClrEOL; END; { Erase any error msg.}
- END; GotoXY(1,22); If DIRn=1 then Sector:=3 else Sector:=8;
- GetSector('R','A',0,Sector,0,DidRead);
- END; Beep; END;
-
- procedure Help; BEGIN GotoXY(1,8); ClrEOL; GotoXY(1,9); { For TRANSFER screen.}
- writeLn('** File names vary in length. The end',
- 's are marked with a letter and ',chr(3),' mark. **');
- writeLn('** SmartWriter (H',chr(3),' or h',chr(3),' after',
- ' name) & DELETED files are noted on the right. **');
- writeLn('** The BU column shows the file sizes in',
- ' number of 1k byte Adam Blocks used. **');
- writeLn('** F10 will ask you for a DOS path for ',
- 'the new DOS file (the default = B:\). **');
- writeLn('** Next, you are asked for a DOS file na',
- 'me. Hit Enter (w/o name) to Cancel. **');
- writeLn('** Files can be transferred to BIN (as ',
- 'is) TXT, or WP (with margins) format. **');
- writeLn('** Only Smartwriter files (H',chr(3),') can use ',
- 'the TXT or WP format- others use BIN. **');
- writeLn('** TXT & WP formats change the "CR" ',
- 'code Adam uses to end lines, into a "LF" **'); ClrEOL; END;
-
- procedure RevealAndModify; FORWARD; {Body of procedure follows PickFile}
-
- procedure PickFile; FORWARD; {Called by the next two procedures }
-
-
- { Dir 2 sector has 8 bytes of Dir 1, so needs a different display subroutine
- than Dir 1. TByte=1st useable file, First=sector offset of Dir entry. }
-
- procedure DirOne; BEGIN Sector:=3; Track:=0; DIRn:= 1;
- GetSector('R','A',0,Sector,Track,DidRead); TByte:=78; Tb:=TByte;
- First:=0; XDIR; LiteName; PickFile; END;
-
- procedure DirTwo; BEGIN Sector:=8; Track:=0; DIRn:= 2;
- GetSector('R','A',0,Sector,Track,DidRead); TByte:=0; Tb:=TByte;
- First:= 8; XDIR; LiteName; PickFile; END;
-
- procedure PickFile; var doit, Choice, EscChoice:char;
-
- BEGIN REPEAT REPEAT
- GetKeys(Choice,EscChoice); UNTIL Choice = chr(27); CASE EscChoice of
- 'I': BEGIN If DIRn = 2 then BEGIN DirOne; END else END; { PgUp }
- 'Q': BEGIN If DIRn = 1 then BEGIN DirTwo; END else END; { PgDn }
- 'H': If (TByte div 26) > 0 then BEGIN Beep; DarkName; { UP ARROW }
- TByte:=TByte-26; Tb:=TByte; LiteName; END;
- 'P': If (TByte+First) < 469 then BEGIN Beep; DarkName; { DOWN ARROW }
- TByte:=TByte+26; Tb:=TByte; LiteName; END;
- '=': BEGIN Help; GetKeys(Z,Z); FixDIR; END; { HELP - **F3 }
- 'j': BEGIN RevealAndModify; END; { REVEAL LOOP - **Alt-F3 }
- 'b': BEGIN DOSin2adam; DirOne; END; { DOS > Adam DOS-IN - **Ctrl-F5 }
- 'D': BEGIN Beep; SetUp; END; { TRANSFER - **F10 }
- END; {case} UNTIL (Choice=chr(27)) and (EscChoice='A'); { EXIT - **F7 }
- REPEAT Beep; GotoXY(60,5); write('********************');
- Beep; GotoXY(60,6); write('** REMOVE A: DISK **');
- Beep; GotoXY(60,7); write('** Then hit Y key **');
- GotoXY(60,8); write('********************'); GetKeys(YorN,Z);
- UNTIL UpCase(YorN) = 'Y'; GotoXY(1,24); halt; END;
-
-
- procedure MainScreen; BEGIN If DIRn=1 then DirOne else DirTwo; END;
-
- procedure RevealAndModify; BEGIN ClrScr; Choices;
- GetSector('R','A',0,Sector,Track,DidRead); BigShow;
- ShowChar; ByteAtt(Tbyte,112); TakeInstructions; MainScreen; END;
-
-
- { ** DISKTALK STARTS HERE with MAIN TRANSFER PROGRAM ** }
-
- BEGIN Initialize; BigCursor; ClrScr; GotoXY(12,20); writeLn
- ('DISK TALK, version 2.4 * Copyright 8/89 by John L. Wiley.');
- GotoXY(32,22); writeLn('USE DISKTALK TO:');
- writeLn('* TRANSFER files between an ADAM ',
- 'disk in Drive A:, and DOS in another Drive or,');
- write('* REVEAL ADAM disk inner secrets ',
- 'and contents to change or repair them at will.');
-
- DiskCheck; P:='B:\'; { Default DOS Path } DIRn:=1; MainScreen; END.