[net.micro.cbm] C64BOOT.SIM

GMW@psuvm.BITNET (06/05/85)

Here is a version of the C64BOOT program written in SIMULA for
DEC-10/20 computers. I have commented this version a little more
than previous versions of C64BOOT in other languages, to make
it simpler for someone who needs to re-write it into yet another
language.
     
Note two important points: ALL echoing of characters from the
CBM by the HOST must be suppressed. Also the echoing of a line
feed when the CBM sends a carriage return.
     
The delimiter between lines sent to the CBM-64 should be only
carriage return, not carriage return-line feed.
     
 OPTIONS(/l);
 ! This comment copied from the CLU version of C64BOO:
 ! Program to download files to my Commodore 64
 ! Sends lines, one at a time.  Each line is followed by a
 ! checksum.  Commodore validates checksum, and either sends
 ! "OK" or "NG".  If no good, retransmit.  Last line's checksum
 ! is sent with a leading minus sign to show end-of-file;
     
 BEGIN
 EXTERNAL TEXT PROCEDURE frontstrip;
 EXTERNAL PROCEDURE echo;
 REF (infile) file;
 TEXT received, line, outword, outwordbuffer;
 INTEGER checksum;
 CHARACTER c, carriagereturn;
     
 ! suppress all echoing of terminal input;
 echo(sysin,2);
     
 ! Initialization of data;
 carriagereturn:= char(13);
 received:- sysin.image.strip;
 line:- blanks(80); outwordbuffer:- blanks(10);
     
 ! Opening of the input file;
 file:- NEW infile("INFIL *");
 file.open(line);
     
 ! Wait for OK from CBM to start transmission;
 WHILE received <> "OK" DO BEGIN
   sysin.inimage; received:- sysin.image.strip;
 END;
     
 file.inimage;
 WHILE NOT file.endfile OR received = "NG" DO BEGIN
     
   ! If last line was correctly received by the CBM,
   ! get the next line from the file;
   IF received = "OK" AND NOT file.endfile THEN BEGIN
     line:- copy(file.image.strip); file.inimage;
   END;
     
   ! Compute checksum;
   checksum:= 0;
   line.setpos(1);
   WHILE line.more DO BEGIN
     c:= line.getchar; checksum:= checksum+rank(c);
   END;
     
   ! Output one line from the file to the CBM-64;
   sysout.outtext(line); sysout.outchar(carriagereturn);
   sysout.breakoutimage;
     
   ! Output the checksum in decimal format,
   ! without leading blanks, to the CBM-64;
   IF file.endfile THEN sysout.outtext("-");
   outwordbuffer.setpos(1); outwordbuffer.putint(checksum);
   outword:- frontstrip(outwordbuffer); ! Strips leading blanks);
   sysout.outtext(outword);
   sysout.outchar(carriagereturn); sysout.breakoutimage;
     
   ! Read the acknowledgement of the line from the CBM-64;
   sysin.inimage; received:- sysin.image.strip;
 END;
 file.close;
     
 ! Resume normal echoing;
 echo(sysin,0);
     
 END;