This program allows file transfer to take place from the PC to the Apple. It's
purpose is to transfer the larger packet protocol communications program from
the PC to the Apple. Entering this short program beats entering 4K+ of machine
code!

Currently my parallel port adapter link is the only supported method to connect
the two systems. I will be working on serial support, but since my real Apple
doesn't have a serial card it will be difficult.

It's a little slow (~16cps), but how fast can you type? The main communications
program is a little faster, ~2000cps.

Enter the following Applesoft BASIC program:

*** Listing for FTP:

10 S = 1
20 F$ = "":DA = 911:SL = 912:CS = 913:RB = 768:CK = 14802
30 FOR A = RB TO RB + 142: READ I: CK = CK - I: POKE A,I: NEXT A
40 IF CK <  > 0 THEN  PRINT "MACHINE CODE ERROR": END
50 POKE SL,S * 16
60 PRINT "WAITING...";: HTAB 1
70 CALL RB: IF PEEK (DA) <  > 0 THEN F$ = F$ +  CHR$ ( PEEK (DA)): GOTO 70
80 PRINT "FILENAME="F$
90 CALL RB:A =  PEEK (DA): CALL RB:A = A +  PEEK (DA) * 256: PRINT "ADDRESS ="A
100 CALL RB:L =  PEEK (DA): CALL RB:L = L +  PEEK (DA) * 256: PRINT "LENGTH  ="L
110 POKE CS,255: POKE CS + 1,255
120 FOR I = 1 TO L: CALL RB: POKE A + I - 1, PEEK (DA): HTAB 1: PRINT I;: NEXT I
130 CALL RB: CALL RB
140 IF  PEEK (CS) <> 184 OR  PEEK (CS + 1) <> 240 THEN  PRINT "CRC ERROR": END
150 C$ = "BSAVE " + F$ + ",A" +  STR$ (A) + ",L" +  STR$ (L)
160 HTAB 1: PRINT "CRC OK": PRINT C$: PRINT  CHR$ (4)C$: END
170 DATA 174,144,  3, 94,132,192,176,251
180 DATA  94,132,192,144,251,189,131,192
190 DATA  41,232, 74, 74, 74, 74,144,  2
200 DATA   9,  1,141,143,  3, 94,132,192
210 DATA 176,251,189,131,192, 41,232,170
220 DATA  41,  8,240,  6,138,  9, 16, 41
230 DATA 240,170,138, 13,143,  3,141,143
240 DATA   3,184, 77,145,  3, 41, 15, 10
250 DATA 170,160,  4, 78,146,  3,110,145
260 DATA   3,136,208,247,173,146,  3, 41
270 DATA  15, 93,112,  3,141,146,  3,173
280 DATA 145,  3, 93,111,  3,141,145,  3
290 DATA 112, 12, 44,110,  3,173,143,  3
300 DATA  74, 74, 74, 74,112,204, 96,  0
310 DATA   0,129, 16,  2, 33,131, 49,  4
320 DATA  66,133, 82,  6, 99,135,115,  8
330 DATA 132,137,148, 10,165,139,181, 12
340 DATA 198,141,214, 14,231,143,247

Save with:

   SAVE FTP

How FTP works:

Line  10 sets the communications slot (i.e. the slot I use is 1).
Line  20 initialises the various constants required.
Line  30 sets up the machine language part of this program.
Line  40 sets the slot for the machine language program.
Line  50 prints a status message.
Line  60 gets the filename.
Line  70 displays the filename.
Line  80 gets the starting address to store the data.
Line  90 gets the length of the data (in bytes).
Line 100 initialises the CRC-CCITT checksum.
Line 110 gets the data and shows a running count of the number of bytes
         received.
Line 120 gets the CRC-CCITT checksum.
Line 130 validates the CRC-CCITT and exits the program if it's invalid.
Line 140 sets up the save string.
Line 150 shows some status messages, saves the data and exits the program.
Lines 170 to 340 are the machine language part of the program.

How the machine code works:

  See comments from listing A2ISMALL.ASM.

