lra@aluxe.UUCP (Lonnie R. Abelbeck, AT&T Bell Labs) (04/21/84)
<> Below is a simple Tektronix 4010 terminal emulator for the Macintosh. The program DOES use the cross-hairs , a simple approach was taken suchthat utility was stressed rather than completeness. A scrolling ALPHA mode exists as well, as that mode is faster for text work, and you don't have to clear the screen all the time. Notice that the basic character I/O routines are from the MacTEP program posted earlier. Don't expect this to work any faster than 300 baud, though you can use your 1200 baud modem, and the program handshakes XON/XOFF. I can hardly wait to rewrite this in 'C', WHEN??? <enjoy> ----- cut here ------ 10 REM MacTek- Macintosh Tektronix 4010 Emulator - Version 1.10a 20 REM Lonnie R. Abelbeck - added Tektronix Terminal Emulation 25 REM based on MacTEP by 30 REM Dennis F. Brothers - Compuserve ID [70065,172] - 16 Mar 84 40 REM copyright 1984 - brothers associates, wayland ma 50 REM PERMISSION IS HEREBY GRANTED FOR PERSONAL, NON-COMMERCIAL 60 REM reproduction and use of this program, provided that this notice is 70 REM included in any copy 80 REM 90 REM Modem connection ( Mac -> modem) 3->7 5->2 8->1 9->3 100 REM 110 REM 120 DEFINT A-Z : REM default to integers for speed 130 DIM PT(4) : REM a single point used for the cross-hairs 140 REM 150 REM define constants 160 REM 170 BUFLIM=32 180 REM 190 FALSE=0 : TRUE=-1 200 REM 210 LF=10: LF$=CHR$(LF) 220 CR=13: CR$=CHR$(CR) 230 BS=8: BS$=CHR$(BS) 240 DEL=127: DEL$=CHR$(DEL) 250 XON=17: XON$=CHR$(XON) 260 XOFF=19: XOFF$=CHR$(XOFF) 270 REM 280 CMDR=168: CMDR$=CHR$(CMDR) 290 CMDT=160: CMDT$=CHR$(CMDT) 300 CMDH=250: CMDH$=CHR$(CMDH) 310 CMDA=140: CMDA$=CHR$(CMDA) 320 CMDG=169: CMDG$=CHR$(CMDG) 330 REM 340 REM 350 REM initialize and display startup information 360 REM 370 CALL TEXTSIZE(9): CALL TEXTFONT(4):CALL TEXTMODE(1): WIDTH(80) 380 HX=0: HY=0: LX=0: LY=0: OLD=0: CH=0 390 OXHAIR=200: OYHAIR=150 400 LINE (0,0)-(0,0) : GET (0,0)-(0,0),PT 410 FLAG$="T": X=0: Y= 200: TEXTSTEP=7 420 CLS: PRINT: PRINT: PRINT 430 PRINT "MacTek - V1.10a - Copyright 1984, Lonnie R. Abelbeck" 440 PRINT: PRINT: PRINT 450 PRINT " Option-h HOME cursor in GRAPHICS mode" 460 PRINT " Option-a enter ALPHA mode" 470 PRINT " Option-g enter GRAPHICS mode" 480 PRINT " Option-t starts and stops ASCII transmit (upload)" 490 PRINT " Option-r starts and stops ASCII receive (download)" 500 PRINT " ENTER sends a CONTROL-C" 510 PRINT: PRINT 520 REM 530 REM Open the COM1 port, set the baud rate 540 REM 550 OPEN "COM1:" AS #1 560 GOSUB 2070 570 PRINT: PRINT: PRINT 580 REM 590 REM 600 REM Main terminal emulator routines 610 REM 620 REM 630 REM all speeds - use x-on/x-off throttling 640 REM 650 XFLAG=FALSE: AMODE=TRUE 660 WHILE LOC(1) <> 0 670 IF (LOC(1) > BUFLIM) AND (NOT XFLAG) THEN PRINT #1,XOFF$;: XFLAG=TRUE 680 OLD=CH 690 CH=ASC(INPUT$(1,1)) AND &H7F 700 IF CH = 29 THEN FLAG$="B": AMODE=FALSE: WIDTH(255): GOTO 860 710 IF CH=59 AND OLD = 27 THEN TEXTSTEP=4: GOTO 860 720 IF CH = 58 AND OLD = 27 THEN TEXTSTEP=5: GOTO 860 730 IF (CH = 56 OR CH=57) AND OLD = 27 THEN TEXTSTEP=7: GOTO 860 740 IF AMODE AND CH <> CR AND CH <> XON AND CH <> XOFF THEN PRINT CHR$(CH);: GOTO 860 750 IF AMODE THEN GOTO 860 760 IF CH=LF THEN Y=Y+11: X=0: GOTO 860 770 IF CH = 7 THEN BEEP: GOTO 860 780 IF CH = 8 THEN X=X-TEXTSTEP: GOTO 860 790 IF CH = 12 AND OLD = 27 THEN CLS: X=0: Y=8: FLAG$="T": GOTO 860 800 IF CH=26 AND OLD=27 THEN GOSUB 1040: GOTO 860 810 IF CH = 31 THEN FLAG$="T": GOTO 860 820 IF CH < 32 THEN 860 830 IF FLAG$ = "T" THEN GOSUB 1000: GOTO 860 840 GOSUB 880 850 REM 860 WEND 870 GOTO 1300 880 IF CH > 31 AND CH < 64 AND OLD > 95 AND OLD < 128 THEN HX=CH:OLD=CH:RETURN 890 IF CH > 31 AND CH < 64 THEN HY = CH: OLD = CH: RETURN 900 IF CH > 95 AND CH < 128 THEN LY = CH: OLD = CH: RETURN 910 IF CH > 63 AND CH < 96 THEN LX = CH: OLD = CH: GOSUB 920: RETURN 920 X=(500!/1024!)*((HX-32)*32+LX-64) 930 IF X < 0 THEN X =0 940 Y= 290-.37*((HY-32)*32+LY-96) 950 IF Y < 0 THEN Y = 0 960 IF FLAG$ = "B" THEN XX = X: YY = Y 970 IF FLAG$ = "A" THEN LINE (XX,YY)-(X,Y) : XX = X: YY = Y 980 FLAG$ = "A" 990 RETURN 1000 IF Y> 290 THEN PRINT #1,XOFF$;: BEEP:FOO$=INPUT$(1):CLS:Y=8: PRINT #1,XON$; 1010 CALL MOVETO(X,Y+2): PRINT CHR$(CH); 1020 X = X + TEXTSTEP 1030 RETURN 1040 REM *** here's the cross-hair routine 1050 PUT (OXHAIR,0)-(OXHAIR,342),PT 1060 PUT (0,OYHAIR)-(512,OYHAIR),PT 1070 IF MOUSE(0) = 0 THEN 1170 1080 XHAIR=MOUSE(1): YHAIR=MOUSE(2) 1090 IF OXHAIR=XHAIR AND OYHAIR=YHAIR GOTO 1070 1100 IF OXHAIR=XHAIR GOTO 1130 1110 PUT (OXHAIR,0)-(OXHAIR,342),PT 1120 PUT (XHAIR,0)-(XHAIR,342),PT 1130 IF OYHAIR=YHAIR GOTO 1160 1140 PUT (0,OYHAIR)-(512,OYHAIR),PT 1150 PUT (0,YHAIR)-(512,YHAIR),PT 1160 OXHAIR=XHAIR: OYHAIR=YHAIR 1170 D$=INKEY$ : IF D$="" GOTO 1070 1180 PRINT #1,D$; 1190 INTX= (1024!/500!)*XHAIR 1200 INTY=(290!-YHAIR)/.37 1210 ALX = (INTX MOD 32) +32 1220 AHX = (INTX -(ALX-32))/32 + 32 1230 ALY = (INTY MOD 32) +32 1240 AHY = (INTY -(ALY-32))/32 + 32 1250 PRINT #1, CHR$(AHX);CHR$(ALX);CHR$(AHY);CHR$(ALY);CHR$(CR); 1260 PUT (XHAIR,0)-(XHAIR,342),PT 1270 PUT (0,YHAIR)-(512,YHAIR),PT 1280 OXHAIR=XHAIR: OYHAIR=YHAIR 1290 RETURN 1300 REM *** input buffer empty 1310 IF XFLAG THEN XFLAG=FALSE: PRINT #1,XON$; 1320 C$=INKEY$ 1330 IF C$="" GOTO 660 1340 IF C$=CMDH$ THEN FLAG$="T": Y=8: X=0: CLS: TEXTSTEP=7: GOTO 660 1350 IF C$=CMDA$ THEN AMODE=TRUE:WIDTH(80):CLS:TEXTSTEP=7: GOTO 660 1360 IF C$=CMDG$ THEN FLAG$="T":Y=8:X=0:CLS:TEXTSTEP=7: AMODE=FALSE: WIDTH(255): GOTO 660 1370 IF C$=CMDR$ GOTO 1440 1380 IF C$=CMDT$ GOTO 1720 1390 IF C$=BS$ THEN C$=BSCH$ 1400 PRINT #1,C$; 1410 GOTO 660 1420 REM 1430 REM 1440 REM receive (download) ASCII file 1450 REM 1460 PRINT: LINE INPUT "Receive filename: ",F$ 1470 IF F$="" THEN GOTO 600 1480 OPEN F$ FOR OUTPUT AS #2 1490 XFLAG=FALSE: L$="" 1500 WHILE F$<>"" 1510 WHILE LOC(1) <> 0 1520 IF ( LOC(1) > BUFLIM) AND (NOT XFLAG) THEN PRINT #1,XOFF$;:XFLAG=TRUE 1530 C=ASC(INPUT$(1,1)) AND &H7F 1540 IF C=LF OR C =XOFF OR C=XON THEN GOTO 1600 1550 PRINT CHR$(C); 1560 IF C<> CR THEN L$=L$+CHR$(C): GOTO 1600 1570 IF NOT XFLAG THEN PRINT #1, XOFF$;: XFLAG=TRUE 1580 PRINT #2,L$ 1590 L$="" 1600 WEND 1610 IF XFLAG THEN XFLAG=FALSE: PRINT #1,XON$; 1620 C$=INKEY$ 1630 IF C$="" THEN GOTO 1680 1640 IF (C$<>CMDR$) THEN PRINT #1,C$;: GOTO 1680 1650 CLOSE #2 1660 PRINT: PRINT "Receive Ended..": PRINT 1670 F$="" 1680 WEND 1690 GOTO 600 1700 REM 1710 REM 1720 REM transmit (upload) ASCII file 1730 REM 1740 PRINT: LINE INPUT "Transmit filename: ",F$ 1750 IF F$="" THEN GOTO 600 1760 OPEN F$ FOR INPUT AS #2 1770 XFLAG=FALSE: DLY=FALSE: QUIT=FALSE 1780 I=1: LL=0 1790 WHILE NOT ((EOF(2) AND (I>LL)) OR QUIT ) 1800 WHILE LOC(1) <> 0 1810 IF (LOC(1) > BUFLIM) AND (NOT XFLAG) THEN PRINT #1,XOFF$;: XFAG=TRUE 1820 C=ASC(INPUT$(1,1)) AND &H7F 1830 IF C=LF THEN GOTO 1870 1840 IF C=XOFF THEN DLY=TRUE: GOTO 1870 1850 IF C=XON THEN DLY=FALSE: GOTO 1870 1860 PRINT CHR$(C); 1870 WEND 1880 IF XFLAG THEN XFLAG=FALSE: PRINT #1,XON$; 1890 IF DLY THEN GOTO 1970 1900 IF I<=LL THEN GOTO 1950 1910 PRINT #1,XOFF$; 1920 LINE INPUT #2,L$ 1930 I=0: LL=LEN(L$) 1940 PRINT #1,XON$; 1950 IF I=LL THEN PRINT #1,CR$;: I=I+1: GOTO 1970 1960 I=I+1: PRINT #1,MID$(L$,I,1); 1970 C$=INKEY$ 1980 IF C$="" THEN GOTO 2010 1990 IF C$=CMDT$ THEN QUIT=TRUE: GOTO 2010 2000 PRINT #1,C$; 2010 WEND 2020 CLOSE #2 2030 PRINT: PRINT "Transfer Ended": PRINT 2040 GOTO 600 2050 REM 2060 REM 2070 REM Subroutine to ask for and set COM1 baud rate 2080 REM 2090 REM fill array with Write SCC B machine-language subroutine 2100 REM 2110 DIM ML(50) 2120 I=0 2130 READ A: ML(I)=A 2140 I=I+1 2150 IF A<>-1 THEN GOTO 2130 2160 REM 2170 REM get baud rate, calculate time constant, and bash SCC 2180 REM 2190 INPUT "Baud Rate: ",BR 2200 REM BR=1200 : REM I usually hardwire it. 2210 TC=(115200!/BR)-2 2220 TCH=INT(TC/256) 2230 TCL=TC MOD 256 2240 R=12: X=TCL: WSCCB!=VARPTR(ML(0)): CALL WSCCB!(R,X) 2250 R=13: X=TCH: WSCCB!=VARPTR(ML(0)): CALL WSCCB!(R,X) 2260 INPUT "Delete instead of backspace (y/n) ", BSC$ 2270 IF BSC$="Y" OR BSC$="y" THEN BSCH$=DEL$ ELSE BSCH$=BS$ 2280 RETURN 2290 REM 2300 REM 68000 machine language code for subroutine to write 2310 REM control regs of Z8530 Serial Communication Controller (SCC) 2320 REM - this subroutine addresses the B port of the Mac's SCC 2330 REM 2340 REM link a6,0 2350 DATA &H4E56,&H0000 2360 REM MOVE.B 11(A6), 10(A6) 2370 DATA &H1D6E,&H000B,&H000A 2380 REM CLR.B 11(A6) 2390 DATA &H422E,&H000B 2400 REM MOVE.B 9(A6), 8(A6) 2410 DATA &H1D6E,&H0009,&H0008 2420 REM CLR.B 9(A6) 2430 DATA &H422E,&H0009 2440 REM OR.W 0700H,SR 2450 DATA &H007C,&H0700 2460 REM MOVE.W 10(A6),00B00002H 2470 DATA &H33EE,&H000A,&H00B0,&H0002 2480 REM MOVE.W 8(A6),00B00002H 2490 DATA &H33EE,&H0008,&H00B0,&H0002 2500 REM AND.W 0F8FFH,SR 2510 DATA &H027C,&HF8FF 2520 REM UNLK A6 2530 DATA &H4E5E 2540 REM RTS 2550 DATA &H4E75 2560 REM 2570 DATA -1 2580 REM 2590 END ----------- cut here -------- Lonnie R. Abelbeck AT&T Bell Laboratories aluxe!lra