mmt@dciem.UUCP (Martin Taylor) (04/04/84)
The following program was taken from INFO-MAC on the ARPANET. I am using it at this moment to talk to my UNIX host, and it has been tested for simple ASCII terminal operation and for transmission of files to and from the host. The copyright notice is self-explanatory. ============================== 1000 REM MacTEP - Macintosh Terminal Emulator - Version 1.60a 1010 REM Dennis F. Brothers - Compuserve ID [70065,172] - 16 Mar 84 1020 REM COPYRIGHT 1984 - BROTHERS ASSOCIATES, WAYLAND MA 1030 REM PERMISSION IS HEREBY GRANTED FOR PERSONAL, NON-COMMERCIAL 1040 REM REPRODUCTION AND USE OF THIS PROGRAM, PROVIDED THAT THIS NOTICE IS 1050 REM INCLUDED IN ANY COPY 1060 REM 1070 REM Modem connection (MAC -> modem) 3->7 5->2 8->1 9->3 1080 REM 1090 REM 1100 DEFINT A-Z :REM default to integers for speed 1110 REM 1120 REM 1130 REM Define constants 1140 REM 1150 BUFLIM=32 1160 REM 1170 FALSE=0: TRUE=-1 1180 REM 1190 LF=10: LF$=CHR$(LF) 1200 CR=13: CR$=CHR$(CR) 1202 BS=8: BS$=CHR$(BS) 1204 DEL=127: DEL$=CHR$(DEL) 1210 XON=17:XON$=CHR$(XON) 1220 XOFF=19: XOFF$=CHR$(XOFF) 1230 REM 1240 CMDB=186: CMDB$=CHR$(CMDB) 1250 CMDE=171: CMDE$=CHR$(CMDE) 1260 CMDR=168: CMDR$=CHR$(CMDR) 1270 CMDT=160: CMDT$=CHR$(CMDT) 1280 REM 1290 REM 2000 REM initialize and display startup information 2010 REM 2020 CALL TEXTSIZE(9): CALL TEXTFONT(4): WIDTH 80 2030 CLS: PRINT: PRINT: PRINT 2040 PRINT "MacTEP - V1.60a - copyright ) 1984, Brothers Associates 2050 PRINT: PRINT: PRINT 2051 PRINT " Enter sends a CONTROL-C" 2052 PRINT " Command-C interrupts this program" 2060 PRINT " Option-E option-E exits to the Macintosh desktop" 2070 PRINT " Option-T starts and stops ASCII transmit (upload)" 2080 PRINT " Option-R starts and stops ASCII receive (download)" 2090 PRINT " Option-B starts and stops ASCII Basic receive" 2100 PRINT " (lines not beginning with a digit are ignored" 2110 PRINT: PRINT 2120 REM 2130 REM Open the COM1 port, set the baud rate 2140 REM 2150 OPEN "com1: " AS #1 2160 GOSUB 9000 2170 PRINT: PRINT: PRINT 2180 REM 2190 REM 3000 REM Main terminal emulator routines 3010 REM 3020 IF BR > 300 THEN GOTO 4000 3030 REM 3040 REM Low speed - no throttling required 3050 REM 3060 WHILE LOC(1)<>0 3070 C=ASC(INPUT$(1,1)) AND &H7F 3080 IF C<>LF AND C<>XOFF AND C<>XON THEN PRINT CHR$(C); 3090 WEND 3100 C$=INKEY$ 3110 IF C$="" THEN GOTO 3060 3120 IF C$=CMDE$ THEN PRINT: PRINT "Exiting...": SYSTEM 3130 IF C$=CMDB$ THEN BMODE=TRUE: GOTO 5000 3140 IF C$=CMDR$ THEN BMODE=FALSE: GOTO 5000 3150 IF C$=CMDT$ THEN GOTO 6000 3152 IF C$=BS$ THEN C$=BSCH$ 3160 PRINT #1,C$; 3170 GOTO 3060 3180 REM 3190 REM 4000 REM high speed - use X-on/X-off throttling 4010 REM 4020 XFLAG=FALSE 4030 WHILE LOC(1)<>0 4040 IF (LOC(1)>BUFLIM) AND (NOT XFLAG) THEN PRINT #1,XOFF;: XFLAG=TRUE 4050 C=ASC(INPUT$(1,1)) AND &H7F 4060 IF C<>LF AND C<>XOFF AND C<>XON THEN PRINT CHR$(C); 4070 WEND 4080 IF XFLAG THEN XFLAG=FALSE: PRINT #1,XON$; 4090 C$=INKEY$ 4100 IF C$="" THEN GOTO 4030 4110 IF C$=CMDE$ THEN PRINT: PRINT "Exiting...": SYSTEM 4120 IF C$=CMDB$ THEN BMODE=TRUE: GOTO 5000 4130 IF C$=CMDR$ THEN BMODE=FALSE: GOTO 5000 4140 IF C$=CMDT$ THEN GOTO 6000 4142 IF C$=BS$ THEN C$=BSCH$ 4150 PRINT #1,C$ 4160 GOTO 4030 4170 REM 4180 REM 5000 REM receive (download) ASCII file 5010 REM 5020 PRINT: LINE INPUT "receive file name: ",F$ 5025 IF F$="" THEN GOTO 3000 5030 OPEN F$ FOR OUTPUT AS #2 5040 XFLAG=FALSE: L$="" 5050 WHILE F$<>"" 5060 WHILE LOC(1)<>0 5070 IF (LOC(1)>BUFLIM) AND (NOT XFLAG) THEN PRINT #1,XOFF$;: XFLAG=TRUE 5080 C=ASC(INPUT$(1,1)) AND &H7F 5090 IF C=LF OR C=XOFF OR C=XON THEN GOTO 5170 5100 PRINT CHR$(C); 5110 IF C<>CR THEN L$=L$+CHR$(C): GOTO 5170 5120 IF NOT XFLAG THEN PRINT #1,XOFF$;: XFLAG=TRUE 5130 IF BMODE AND (L$="") THEN GOTO 5170 5140 IF BMODE THEN C$=LEFT$(L$,1): IF (C$<"0") OR (C$>"9") THEN GOTO 5160 5150 PRINT #2,L$ 5160 L$="" 5170 WEND 5180 IF XFLAG THEN XFLAG=FALSE: PRINT #1,XON$; 5190 C$=INKEY$ 5200 IF C$="" THEN GOTO 5250 5210 IF ((C$<>CMDB$) AND (C$<>CMDR$)) THEN PRINT #1,C$;: GOTO 5250 5220 CLOSE #2 5230 PRINT: PRINT "Receive Ended": PRINT 5240 F$="" 5250 WEND 5260 GOTO 3000 5270 REM 5280 REM 6000 REM transmit (upload) ASCII file 6010 REM 6020 PRINT: LINE INPUT "transmit file name: ",F$ 6030 IF F$="" THEN GOTO 3000 6040 OPEN F$ FOR INPUT AS #2 6050 XFLAG=FALSE: DLY=FALSE: QUIT=FALSE 6060 I=1: LL=0 6070 WHILE NOT ((EOF(2) AND (I>LL)) OR QUIT) 6080 WHILE LOC(1)<>0 6090 IF (LOC(1)>BUFLIM) AND (NOT XFLAG) THEN PRINT #1,XOFF$;: XFLAG=TRUE 6100 C=ASC(INPUT$(1,1)) AND &H7F 6110 IF C=LF THEN GOTO 6150 6120 IF C=XOFF THEN DLY=TRUE: GOTO 6150 6130 IF C=XON THEN DLY=FALSE: GOTO 6150 6140 PRINT CHR$(C); 6150 WEND 6160 IF XFLAG THEN XFLAG=FALSE: PRINT #1,XON$; 6170 IF DLY THEN GOTO 6250 6180 IF I<=LL THEN GOTO 6230 6190 PRINT #1,XOFF$; 6200 LINE INPUT #2,L$ 6210 I=0: LL=LEN(L$) 6220 PRINT #1,XON$; 6230 IF I=LL THEN PRINT #1,CR$;: I=I+1: GOTO 6250 6240 I=I+1: PRINT #1,MID$(L$,I,1); 6250 C$=INKEY$ 6260 IF C$="" THEN GOTO 6290 6270 IF C$=CMDT$ THEN QUIT=TRUE: GOTO 6290 6280 PRINT #1,C$; 6290 WEND 6300 CLOSE #2 6310 PRINT: PRINT "Transmit Ended": PRINT 6320 GOTO 3000 6330 REM 6340 REM 9000 REM Subroutine to ask for and set COM1 baud rate 9010 REM 9020 REM Fill array with Write SCC B machine-language subroutine 9030 REM 9040 DIM ML(50) 9050 I=0 9060 READ A: ML(I)=A 9070 I=I+1 9080 IF A<>-1 THEN GOTO 9060 9090 REM 9100 REM Get baud rate, calculate time constant, and bash SCC 9110 REM 9120 INPUT "Baud Rate: ",BR 9130 TC=(115200!/BR)-2 9140 TCH=INT(TC/256) 9150 TCL=TC MOD 256 9160 R=12: X=TCL: WSCCB!=VARPTR(ML(0)): CALL WSCCB!(R,X) 9170 R=13: X=TCH: WSCCB!=VARPTR(ML(0)): CALL WSCCB!(R,X) 9172 INPUT "delete instead of backspace (y/n)", BSC$ 9174 IF BSC$="Y" OR BSC$="y" THEN BSCH$=DEL$ ELSE BSCH$=BS$ 9180 RETURN 9190 REM 9200 REM 68000 machine language code for subroutine to write 9210 REM control regs of Z8530 Serial Communication Controller (SCC) 9220 REM - this subroutine addresses the B port of the Mac's SCC 9230 REM 9240 REM link A6,0 9250 DATA &H4E56,&H0000 9260 REM move.B 11(A6),10(A6) 9270 DATA &H1D6E,&H000B,&H000A 9280 REM clr.B 11(A6) 9290 DATA &H422E,&H000B 9300 REM move.B 9(A6),8(A6) 9310 DATA &H1D6E,&H0009,&H0008 9320 REM clr.B 9(A6) 9330 DATA &H422E,&H0009 9340 REM or.W 0700H,SR 9350 DATA &H007C,&H0700 9360 REM move.W 10(A6),00B00002H 9370 DATA &H33EE,&H000A,&H00B0,&H0002 9380 REM move.W 8(A6),00B00002H 9390 DATA &H33EE,&H0008,&H00B0,&H0002 9400 REM and.W 0F8FFH,SR 9410 DATA &H027C,&HF8FF 9420 REM unlk A6 9430 DATA &H4E5E 9440 REM rts 9450 DATA &H4E75 9460 REM 9470 DATA -1 9480 REM 9490 END -- Martin Taylor {allegra,linus,ihnp4,uw-beaver,floyd,ubc-vision}!utzoo!dciem!mmt