1 'Run this program on the PC in conjunction with a Fortran program 2 '(MSBOOT.FOR) on the mainframe to download Kermit to the PC. This 3 'program will run for about thirty minutes, depending on line speed. 4 ' Bill Catchings, June 1984 (Revised Sept 1984) 5 ' Columbia University Center for Computing Activities 10 t\$ = time\$ ' Save the time. 20 defint a-z ' All integer to gain some speed. 30 n\$ = chr\$(0) 40 z = asc("0") 50 t = asc("~")-z 60 def fnuchr%(a\$)=asc(a\$)-z 70 open "com1:9600,s,7,1,cs,ds,cd" as #1 100 print#1,"O ,2" ' Char constants "O", " " and "," 110 input#1,f\$ 120 if len(f\$) < 5 then goto 110 ' In case the host echos the ACK. 130 input#1,n 135 print f\$+" "+str\$(n) 140 if n > 20 then goto 900 150 open f\$ for output as #2 160 print "Outputting to "+f\$ 170 goto 300 ' Correct version of the file. 200 gosub 1000 ' Do turnaround char processing 210 print#1,"NO" ' Tell host data was incorrect. 220 goto 320 300 gosub 1000 ' Do turnaround char processing 310 print#1,"OK" ' Say the line was all right. 320 input#1,x\$ 330 if len(x\$) < 5 then goto 320 ' In case the host echos ACK/NAK 340 input#1,n 345 print x\$+" "+str\$(n) 350 if len(x\$) <> n then goto 200 ' Length doesn't match, NAK it. 360 if x\$ = "&&&&&&&&&&" then goto 800 ' End of file? 370 y\$ = "" ' Set output string to null. 380 goto 500 400 print#2,y\$; ' Print the output string. 410 goto 300 ' Go get another line. 500 if len(x\$) = 0 goto 400 ' Done with input string? 510 a = fnuchr%(x\$) 520 if a = t then goto 700 ' Null repeat character? 530 q\$=mid\$(x\$,2,3) ' Get the quadruplet to decode. 540 x\$=mid\$(x\$,5) 550 b = fnuchr%(q\$) 560 q\$ = mid\$(q\$,2) 570 c = fnuchr%(q\$) 580 q\$ = mid\$(q\$,2) 590 d = fnuchr%(q\$) 600 y\$ = y\$ + chr\$(((a * 4) + (b \ 16)) and 255) ' Decode the quad. 610 y\$ = y\$ + chr\$(((b * 16) + (c \ 4)) and 255) 620 y\$ = y\$ + chr\$(((c * 64) + d) and 255) 630 goto 500 ' Get another quad. 700 x\$ = mid\$(x\$,2) ' Expand nulls. 710 r = fnuchr%(x\$) ' Get the number of nulls. 715 print " Null: ",r 720 x\$ = mid\$(x\$,2) 730 for i=1 to r ' Loop, adding nulls to string. 740 y\$ = y\$ + n\$ 750 next 760 print#2,y\$; ' Print the nulls. 770 y\$ = "" ' Clear the output buffer. 780 goto 500 800 print "Processing complete, elapsed time: "+t\$+" to "+time\$ 810 print "Output in "+f\$ 820 close #1,#2 830 goto 9999 900 print "?The format of the BOO file is incorrect" 910 goto 820 1000 x\$ = input\$(1,#1) ' Make this line RETURN for full-duplex 1010 if x\$ <> chr\$(17) then goto 1000 ' Loop for a turn around char. 1020 return 9999 end