doug@odin.UUCP (11/02/83)
PROCEDURE Terminal REM ************************************************************ REM *** *** REM *** *** REM *** TERMINAL enables communication between two CPUs. *** REM *** co-operating program not required on 2ed machine *** REM *** *** REM *** Copyright (C) 1983 The JBM Group Inc. *** REM *** *** REM *** This software is made freely available to the OS9 *** REM *** community, for private noncommercial use only, with *** REM *** inclusion of the above copyright notice. Distribu- *** REM *** tion in this mode does not transfer copyright or *** REM *** title to any other person or group. The JBM Group *** REM *** does not undertake to support this software, nor *** REM *** does it warrant this software, as distributed or in *** REM *** modified form, for any purpose whatsoever. Use of *** REM *** this software is understood to release The JBM Group *** REM *** Inc. from all claims for liability resulting from or *** REM *** associated with its use. *** REM *** *** REM *** *** REM ************************************************************ REM ************************************************************ REM *** *** REM *** INSTALLING TERMINAL: *** REM *** - X1 is a sample device descriptor for a com. port *** REM *** - Do not run a "tsmon" on the com. port *** REM *** - Options J & K require dma capability disks *** REM *** *** REM *** USING TERMINAL: *** REM *** - Most of the commands "toggle" beteen states *** REM *** - Option A controls special character processing *** REM *** - The pause interval is useful for systems not *** REM *** using x-on/x-off protocals. *** REM *** - Option B sets full-duplex/half-duplex. *** REM *** - The name of the printer path is /p1 (see line 1300)*** REM *** - Option D receives data from systems which only *** REM *** append <CR> to lines instead of <CR><LF> *** REM *** - Terminal does not send <EOF> to the receiving *** REM *** system. You must enter it yourself. *** REM *** *** REM *** BUGS: *** REM *** - During extended file transfers, terminal "pops out *** REM *** of gear" and the menu re-appears. *** REM *** Just enter the P option to continue with no *** REM *** loss of data! *** REM *** - The <DEL> character is not passed to the target *** REM *** *** REM *** REFERENCES: *** REM *** OCT 1983 issue of FORUM68 *** REM *** *** 100 REM *** dim program varibles *** DIM cntrl:STRING[2] DIM comi,como,char,opt,La120,file,sfile,lfile,zero:BYTE TYPE commun_def=record:BYTE DIM commun:commun_def DIM COMMANDS(32),device,sendfile:STRING[32] DIM Cntrl_byte(16):BYTE DIM maxsize,sleepytime,sleepyctr,sleepsignal,E:INTEGER DIM array(32767):BYTE DIM filename:STRING[29] DIM address(3):INTEGER DIM i1:INTEGER REM *** initialize program varibles *** FOR i1=1 TO 16 Cntrl_byte(i1)=$00 NEXT i1 address(1)=$00 address(2)=$00 address(3)=$7FFF \REM *** size of buffer array *** Cntrl_byte(4)=$FF zero=0 sleepytime=0 sleepyctr=0 (* sleepsignal = characters to process before sleep sleepsignal=32 200 REM *** set up program default values *** COMMANDS(1)="Control Enabled" \COMMANDS($11)="Control Disabled" COMMANDS(2)="Host Echo" \COMMANDS($12)="Local Echo" COMMANDS(3)="Printer Off" \COMMANDS($13)="Printer On" COMMANDS(4)="Auto LF On" \COMMANDS($14)="Auto LF Off" COMMANDS(5)="Print Buffer" \COMMANDS($15)="" COMMANDS(6)="Reset Buffer" \COMMANDS($16)="" COMMANDS(7)="Save Buffer" \COMMANDS($17)="" COMMANDS(8)="Load File" \COMMANDS($18)="" COMMANDS(9)="Transmit Buffer" \COMMANDS($19)="" COMMANDS($0A)="Rx File" \COMMANDS($1A)="" COMMANDS($0B)="Tx File" \COMMANDS($1B)="" COMMANDS($0C)="Open Buffer" \COMMANDS($1C)="Close Buffer" COMMANDS($0D)="Buffer Status" \COMMANDS($1D)="" COMMANDS($0E)="System Command" \COMMANDS($1E)="" COMMANDS($0F)="Return to OS9" \COMMANDS($1F)="" COMMANDS($10)="Terminal Mode" \COMMANDS($20)="" PRINT "Terminal - Copyright (C) 1983 The JBM Group Inc." 300 ON ERROR REM open *** program paths *** INPUT "device to communicate to ",device ON ERROR GOTO 4400 OPEN #comi,device:READ OPEN #como,device:WRITE ON ERROR opt=1 400 REM *** SET UP menu *** PRINT PRINT FOR x=1 TO 16 IF Cntrl_byte(x)=0 THEN PRINT CHR$(64+x),COMMANDS(x) ELSE PRINT CHR$(64+x),COMMANDS($10+x) ENDIF NEXT x PRINT PRINT PRINT "Input Option "; GET #0,opt PRINT PRINT IF opt>=65 AND opt<=80 THEN opt=opt-64 GOTO 500 ENDIF IF opt>=97 AND opt<=112 THEN opt=opt-96 GOTO 500 ENDIF GOTO 400 500 REM *** flip byte status *** IF Cntrl_byte(opt)=$00 THEN Cntrl_byte(opt)=$FF ELSE Cntrl_byte(opt)=$00 ENDIF REM *** operate on instructions *** ON INT(opt) GOSUB 1200,510,1300,510,1400,1500,1600,2000,2200,2300 ,2700,3400,3500,3600,3700,3800 GOTO 400 510 RETURN 600 REM *** get a char from keyboard *** RUN inbyt(zero,char) char=LAND(char,$7F) IF char<>$7F AND char<>18 THEN PUT #como,char IF sleepytime<>0 THEN GOSUB 4260 ENDIF ENDIF RETURN 700 REM *** get a char from comdevice *** RUN inbyt(comi,char) char=LAND(char,$7F) IF char<>$7F THEN IF char=$0A THEN IF Cntrl_byte(4)=$00 THEN PRINT CHR$($0A); ENDIF ELSE PRINT CHR$(char); ENDIF IF sleepytime<>0 THEN GOSUB 4260 ENDIF ENDIF RETURN 800 REM *** turn local echo off *** cntrl=CHR$(4)+CHR$(0) RUN tcx(cntrl) RETURN 900 REM *** turn local echo echo on cntrl=CHR$(4)+CHR$(1) RUN tcx(cntrl) RETURN 1000 REM *** communicate with device until control 'r' from kb *** GOSUB 800 1100 GOSUB 600 IF char=18 THEN GOSUB 900 END ENDIF GOSUB 700 GOTO 1100 1200 REM *** local terminal control status *** IF Cntrl_byte(1)=$00 THEN REM *** restore controls cntrl=CHR$($0C)+CHR$($1A) RUN tcx(cntrl) cntrl=CHR$($0D)+CHR$($04) RUN tcx(cntrl) cntrl=CH$($0E)+CHR$($01) RUN tcx(cntrl) cntrl=CHR$($10)+CHR$($03) RUN tcx(cntrl) cntrl=CHR$($11)+CHR$($0B) RUN tcx(cntrl) ELSE REM *** disable controls *** cntrl=CHR$($0C)+CHR$(0) RUN tcx(cntrl) cntrl=CHR$($0D)+CHR$(0) RUN tcx(cntrl) cntrl=CHR$($0E)+CHR$($00) RUN tcx(cntrl) cntrl=CHR$($10)+CHR$(0) RUN tcx(cntrl) cntrl=CHR$($11)+CHR$(0) RUN tcx(cntrl) ENDIF RETURN 1300 REM *** print channel control *** IF Cntrl_byte(3)=0 THEN REM *** close path *** PRINT PRINT "Closing Printer Port" PRINT CLOSE #La120 ELSE REM *** open path *** PRINT PRINT "Opening Printer Port" PRINT OPEN #La120,"/P1" ENDIF RETURN 1400 REM *** print buffer routine *** REM *** if print port open to print as well else just to terminal *** FOR x=address(1) TO address(2) PUT #0,array(x+1) IF array(x+1)=$0D THEN PRINT #0,CHR$($0A); ENDIF IF Cntrl_byte(3)<>0 THEN PUT #La120,array(x+1) IF array(x+1)=$0D THEN PRINT #La120,CHR$($0A); ENDIF ENDIF NEXT x Cntrl_byte(5)=$00 RETURN 1500 REM *** reset buffer pointers *** Cntrl_byte(opt)=0 address(1)=$00 address(2)=$00 RETURN 1600 REM *** save buffer to file *** PRINT PRINT "input/path/filename - "; INPUT filename ON ERROR GOTO 1800 CREATE #file,filename 1700 ON ERROR FOR x=address(1) TO address(2) PUT #file,array(x+1) NEXT x CLOSE #file Cntrl_byte(7)=0 RETURN 1800 PRINT E:=ERR GOSUB 4500 PRINT "a) input another filename" PRINT PRINT "b) overwrite filename" PRINT PRINT "return to menu" ON ERROR PRINT PRINT PRINT "option - "; GET #0,opt PRINT PRINT IF opt>=65 AND opt<=67 THEN opt=opt-64 GOTO 1900 ENDIF IF opt>=97 AND opt<=99 THEN opt=opt-96 GOTO 1900 ENDIF GOTO 1800 1900 IF option=1 THEN GOTO 1600 ENDIF IF option=2 THEN OPEN #file,filename GOTO 1700 ENDIF IF opt=3 THEN Cntrl_byte(7)=0 GOTO 400 ENDIF PRINT 2000 REM *** load file into buffer *** INPUT "Input /path/filename ",COMMANDS($18) ON ERROR GOTO 4300 PRINT PRINT "loading "; COMMANDS($18) OPEN #lfile,COMMANDS($18):READ REM *** SET UP ADDRESSES *** address(1)=0 address(2)=0 REM *** REM UNTIL EOF *** 2100 GET #lfile,array(address(2)+1) address(2)=address(2)+1 IF address(2)=address(3) THEN CLOSE #lfile PRINT "file to big for buffer"+CHR$(7) PRINT GOTO 400 ENDIF GOTO 2100 Cntrl_byte(8)=0 RETURN 2200 REM *** transmit contents of buffer *** GOSUB 4250 ON ERROR GOTO 2210 FOR x=address(1) TO address(2) PUT #como,array(x+1) GOSUB 600 IF char=18 THEN GOTO 2205 ENDIF GOSUB 700 GOSUB 4200 GOSUB 700 GOSUB 4200 IF sleepytime<>0 THEN GOSUB 4260 ENDIF NEXT x 2205 GOSUB 700 IF char<>$7F THEN GOTO 2205 ENDIF Cntrl_byte(opt)=$00 sleepytime=0 RETURN 2210 E:=ERR ON ERROR GOSUB 4500 RETURN 2300 REM *** recieve data direct to a file *** IF Cntrl_byte($0A)<>0 THEN REM *** create a file for input *** 2400 PRINT "Input /path/filename - "; INPUT filename COMMANDS($1A)="Rx "+filename ON ERROR GOTO 2500 CREATE #file,filename ON ERROR RETURN 2500 PRINT E:=ERR GOSUB 4500 PRINT PRINT "a) input another filename" PRINT PRINT "b) overwrite filename" PRINT PRINT "c) return to menu" ON ERROR PRINT PRINT PRINT "option - "; GET #0,opt PRINT PRINT IF opt>=65 AND opt<=67 THEN opt=opt-64 GOTO 2600 ENDIF IF opt>=97 AND opt<=99 THEN opt=opt-96 GOTO 2600 ENDIF 2600 IF opt=1 THEN filename="" GOTO 2400 ENDIF IF opt=2 THEN OPEN #file,filename RETURN ENDIF IF opt=3 THEN Cntrl_byte($0A)=0 GOTO 400 ENDIF GOTO 2500 ELSE PRINT PRINT "Closing "+filename PRINT CLOSE #file ENDIF RETURN 2700 REM *** transmit a file directly *** PRINT "input/path/filename - "; INPUT sendfile ON ERROR GOTO 3000 OPEN #sfile,sendfile:READ ON ERROR GOSUB 4250 REM *** send file *** PRINT PRINT "transmitting "; sendfile PRINT PRINT "to abort type CNTRL 'r' " PRINT ON ERROR GOTO 3200 2800 GET #sfile,char PUT #como,char GOSUB 600 IF char=18 THEN GOTO 2900 ENDIF GOSUB 700 GOSUB 4200 GOSUB 700 GOSUB 4200 IF sleepytime<>0 THEN GOSUB 4260 ENDIF GOTO 2800 2900 Cntrl_byte($0B)=0 CLOSE #sfile 2910 GOSUB 700 IF char<>$7F THEN GOTO 2910 ENDIF sleepytime=0 RETURN 3000 E:=ERR PRINT GOSUB 4500 PRINT PRINT "a) input another filename" PRINT PRINT "b) return to menu" 3100 PRINT PRINT "option - "; GET #0,opt PRINT IF opt>=65 AND opt<=66 THEN opt=opt-64 GOTO 3300 ENDIF IF opt>=97 AND opt<=98 THEN opt=opt-96 GOTO 3300 ENDIF GOTO 3100 3200 REM *** error encountered *** E:=ERR ON ERROR IF E<>211 THEN GOSUB 4500 GOTO 2900 ELSE GOTO 2900 ENDIF 3300 IF opt=1 THEN filename="" GOTO 2700 ENDIF IF opt=2 THEN Cntrl_byte($0B)=0 GOTO 400 ENDIF GOTO 3100 3400 REM *** open buffer *** REM *** no operation except to toggle status bit *** REM return 3500 REM *** print buffer status *** PRINT "No of Characters stored = "; address(2) PRINT "Amount of storage left = "; address(3)-address(2) Cntrl_byte($0D)=0 RETURN 3600 REM *** pass a command to the host operating system *** Cntrl_byte(opt)=0 IF Cntrl_byte(1)<>0 THEN cntrl=CHR$($0C)+CHR$($1A) RUN tcx(cntrl) ENDIF PRINT "Type EOF chr to exit" SHELL "" IF Cntrl_byte(1)<>0 THEN cntrl=CHR$($0C)+CHR$($00) RUN tcx(cntrl) ENDIF RETURN 3700 REM *** return to OS9 *** Cntrl_byte(opt)=0 REM *** check control status if disabled enable it *** IF Cntrl_byte(1)<>0 THEN Cntrl_byte(1)=$00 GOSUB 1200 ENDIF REM *** check print port status if open close it *** IF Cntrl_byte(3)<>0 THEN Cntrl_byte(3)=0 GOSUB 1300 ENDIF REM *** check status of file if open close it *** IF Cntrl_byte($0A)<>0 THEN Cntrl_byte($0A)=0 GOSUB 2300 ENDIF CLOSE #comi CLOSE #como END RETURN 3800 REM *** enter terminal mode *** Cntrl_byte(opt)=0 REM *** Get pause *** GOSUB 4250 REM *** check to see if local echo *** REM *** if not disable echo *** IF Cntrl_byte(2)=$00 THEN GOSUB 800 ENDIF REM *** start communication *** 3900 (* see if character from keyboard GOSUB 600 (* see if character is terminantion character IF char=18 THEN (* terminate communitations sleepytime=0 GOTO 4000 ENDIF IF Cntrl_byte(2)<>$00 THEN (* local echo GOSUB 4100 ENDIF (* get char from communication device GOSUB 700 (* do with character what one will GOSUB 4100 IF sleepytime<>0 THEN GOSUB 4260 ENDIF GOTO 3900 4000 REM *** if local echo disbled enable it *** IF Cntrl_byte(2)=$00 THEN GOSUB 900 ENDIF RETURN 4100 REM *** check to see if char should goto array *** IF Cntrl_byte($0C)<>0 THEN IF char>20 AND char<$7F THEN array(address(2)+1)=char address(2)=address(2)+1 ELSE IF char=$0D THEN array(address(2)+1)=char address(2)=address(2)+1 ENDIF ENDIF ENDIF REM *** CHECK TO SEE IF CHARACTER SOULD GOT TO DISK *** IF Cntrl_byte($0A)=$FF THEN IF char<$7F THEN IF char<>$0A THEN PUT #file,char ENDIF ENDIF ENDIF 4200 REM *** check for valid print *** IF Cntrl_byte(3)<>$00 AND char<$7F THEN IF char=$0A THEN IF Cntrl_byte(4)=$00 THEN PRINT #La120,CHR$($0A); ENDIF ELSE PRINT #La120,CHR$(char); ENDIF ENDIF RETURN 4250 REM *** get time to sleep between transmissions to target *** INPUT "pause - ",sleepytime sleepyctr=0 RETURN 4260 REM *** increment character counter; if counter equals 16, *** REM *** sleep sleepytime ticks and zero counter before continuing *** sleepyctr=sleepyctr+1 IF sleepyctr=sleepsignal THEN SHELL "SLEEP "+STR$(sleepytime) sleepyctr=0 ENDIF RETURN 4300 REM *** error routine *** REM *** ERROR CATCHING FOR NON OS9 READ *** E:=ERR IF E=211 THEN REM *** end of file on valid file *** address(2)=address(2)-1 CLOSE #lfile GOTO 400 ENDIF PRINT GOSUB 4500 PRINT Cntrl_byte(8)=$00 GOTO 400 4400 REM *** open channel error *** E=ERR PRINT GOSUB 4500 PRINT GOTO 300 4500 REM *** ERROR HANDLER PRINTER *** PRINT CHR$(7); ON E-213 GOTO 4700,4800,4900,4600,5000,4600,4600,5100 4600 PRINT "* * Error no. "; E; " * *" RETURN 4700 PRINT "* * File not accessible * *" RETURN 4800 PRINT "* * Bad pathlist * *" RETURN 4900 PRINT "* * File not found * *" RETURN 5000 PRINT " * * File already exists * * " RETURN 5100 PRINT "* * Module or path not found * * " RETURN ********************************************************************** ********************************************************************** * ASSEMBLY SUBROUTINES * * * * * Tcx * * Subroutine to reset an option in the SCF options table * * This routine is intended for use with Terminal. It does * no error checking and can be extremely dangerous for * casual use. * TcxTyp set SBRTN+OBJCT TcxRev set REENT+1 mod TcxEnd,TcxNam,TcxTyp,TcxRev,TcxEnt,TcxMem nam Tcx ttl Copyright (C) 83/08/19 The JBM Group Inc. ifp1 use /H0/Defs/DefsFile endc TcxNam fcs /Tcx/ fcb $01 Edition number fcs /(C)1983 JBM Inc/ org $00 TcxMem equ . TcxEnt tfr s,u Save stack pointer position leas -$20,s Reserve 32. bytes for SCF options clra Path 0 clrb Get options tfr s,x Buffer address OS9 I$GetStt Get current options ldy 4,u Address of passed argument lda ,y+ Index to option ldb ,y New value of option stb a,x Write new value in option table clra Path 0 clrb Set options OS9 I$SetStt Set new options tfr u,s Restore stack pointer rts Back to Basic09 emod TcxEnd equ * end ******************************************************************** ******************************************************************** * * * * X1 * * Device descriptor for use with TERMINAL - based on the * JBM Group's hardware configuration * * Copyright (C) 1983 The JBM Group Inc. This software * is made freely available to the OS9 users community * for private, noncommercial use only with inclusion * of the above copyright notice. Distribution * in this mode does not transfer copyright or title * to the software to any other person or group. The * JBM Group does not undertake to support this software, * nor does it warrant this software, as distributed or * in modified form, for any purpose whatsoever. Use * of this software is understood to release The JBM * Group Inc. from all claims for liability resulting * from or associated with its use. * * In other words, you're on your own. nam X1 ttl Copyright (C) 1983 The JBM Group Inc. ifp1 use /H0/Defs/DefsFile endc IOPTyp set DEVIC+OBJCT IOPRev set REENT+1 mod IOPEnd,IOPNam,IOPTyp,IOPRev,IOPMgr,IOPDrv IOMode fcb Updat. Enable read/write IOPor1 fcb $0F High byte of port address IOPor2 fdb $E070 Low bytes of port address IOOpts fcb IOPNam-*-1 Option byte count * Option section, as defined on p. 7-4 * of the OS9 System Programmer's Manual * copyright (C) 1980, 1982 Microware * Systems Corporation, Revision F-1 * (January 1983) * IODTyp fcb DT.SCF Device type: SCF IO.Upc fcb $00 Upper/lower case IO.Bso fcb $00 Backspace IO.Dlo fcb $00 Delete: Backspace over line IO.Eko fcb $00 Auto echo on IO.Alf fcb $00 Auto line feed on IO.Nul fcb $00 End-of-line null count IO.Pau fcb $00 End-of-page pause off IO.Pag fcb $00 Lines per page IO.Bsp fcb $00 Backspace character (none) IO.Del fcb $00 Delete line character (none) IO.Eor fcb $0D End-of-record character IO.Eof fcb $00 End-of-file character (none) IO.Rpr fcb $00 Reprint line character (none) IO.Dup fcb $00 Duplicate last line character (none) IO.Psc fcb $00 Pause character (none) IO.Int fcb $00 Keyboard interrupt character (none) IO.Qut fcb $00 Keyboard quit character (none) IO.Bse fcb $00 Backspace echo character IO.Ovf fcb $00 Line overflow signal (none) * Value here is for the MC6551 chip * IO.Par fcb $0B No parity, no interrupts * MC6551 control register values: * * $1E 1 stop, 8 data, int clk 9600 Baud * $1C 1 stop, 8 data, int clk 4800 Baud * $1A 1 stop, 8 data, int clk 2400 Baud * $08 1 stop, 8 data, int clk 1200 Baud * $06 1 stop, 8 data, int clk 300 Baud * IO.Bau fcb $08 IO.D2p fcb $00 Offset to echo device (none) IO.Xon fcb $11 Value of XON character IO.Xof fcb $13 Value of XOFF character * Each GIMIX I/O processor board has three "ports", * numbered 0, 1, and 2. Value here points to the * "port" this descriptor is for. * IO.Who fcb $01 Use "port" 1 IOPNam fcs /Com1/ Device name IOPMgr fcs /IOPMan/ File manager name IOPDrv fcs /IOP/ Device driver name emod IOPEnd equ * end ******************************************************************* ******************************************************************* * Inbyt * * Read a single character, ignoring "read error" - typically * line noise * * If no character is ready on the specified device, $FF - the * Basic09 terminator - is returned * * This routine is intended for use with Terminal. It does no * error checking and can be extremely dangerous for casual * use. * InbTyp set SBRTN+OBJCT InbRev set REENT+1 mod InbEnd,InbNam,InbTyp,InbRev,InbEnt,InbMem nam Inbyt ttl Copyright (C) 83/08/19 The JBM Group Inc. ifp1 use /H0/Defs/DefsFile endc InbNam fcs /Inbyt/ fcb $01 Edition number fcs /(C)1983 JBM Inc/ org $00 InbMem equ . InbEnt tfr s,u Save stack pointer position ldx 8,u Address of one-byte buffer lda [4,u] Path number ldb #1 Option code for device-ready check InbChk pshs a,b Save path, option code OS9 I$GetStt Do the device-ready check bcc InbGch Ready - get the character cmpb #E$NotRdy Not-ready or error? beq Inb$FF Not ready - return InbCh1 cmpb #E$Read Read error? bne InbAbo If anything else, abort puls a,b Restore registers bra InbChk Try again Inb$FF clra Clear the A register coma Complement it (now contains $FF) sta ,x Stuff it into the buffer bra InbRtn InbGch ldy #1 Read one byte OS9 I$Read Do it bcs InbCh1 Check out any errors InbRtn tfr u,s Restore stack pointer clrb No error rts InbAbo orcc #$01 Set the C bit OS9 F$Exit Abort emod InbEnd equ * end