; ;TTY terminal for testing serial port drivers ; ;Version 1.0 ; ;by Scott Alfter ; ;Copyright (C) 1990 by Skunk Works Software Co. ; 43 Megan Dr. ; Henderson, NV 89014 ; ;Source code for MindCraft (TM) Assembler ; ;------------------------------------------------------------------------- ; ;This is a quick hack to check proper functioning of any serial port ;driver developed for the Term One (TM) telecommunications system. It ;implements many (but not all) features of version 1.0 (version byte $10) ;of the serial port driver protocol. When you use this program, you will ;be "speaking" directly to the modem. For a Hayes (R) compatible modem, ;for instance, you will need to use AT commands to tell the modem to dial, ;adjust volume, drop carrier, etc. ; ;This driver uses the standard output (the computer's firmware) for the ;display. Make sure you enter PR#3 before running this program if you ;want an 80-column terminal. This is doubly important because the help ;list and some other stuff uses MouseText. (Don't worry if you don't have ;an enhanced IIe or later machine, though; the program will work, but ;you'll see funny-looking characters.) ; ;NOTE: This program is for test purposes only. It replaces the BIOS and ;console driver that Term One will use. Also, this program does not ;include any file-transfer capability; file-transfer modules will provide ;this functionality in Term One. ; ;------------------------------------------------------------------------- ; ;My legal stuff: ; "Term One" is a trademark of Skunk Works Software Co. ; ;Other people's legal stuff: ; "MindCraft" is a trademark of MindCraft Publishing Corp. ; "Hayes" is a registered trademark of Hayes Microcomputer Products, Inc. ; ;------------------------------------------------------------------------- ; ;EQUates relating to the version 1.0 serial port protocol ; ;Note: It's not mentioned below, but the carry returns set when an error ;occurs in one of the routines. The carry is also returned set by GETCHAR ;if no character has been received. ; INIT EQU $800 ;Init port (A=setup code (see below), X=slot #) ;If card in slot X won't work with the driver ;that's loaded, the routine exits with the carry ;set and the high bit of the Y-register set. SETPARMS EQU $803 ;Set baud rate and data format (A=setup code in ;this format: ; Bit 3=data format ; 0=8/N/1 ; 1=7/E/1 ;Bits 2-0=baud rate ; 0=300 ; 1=1200 ; 2=2400 ; 3=4800 ; 4=9600 ; 5=14400 ; 6=19200 HNDSHK EQU $806 ;Control automatic XON/XOFF handshaking ;(bit 8 of accumulator set to enable) GETCHAR EQU $809 ;Get an incoming character in accumulator SENDCHAR EQU $80C ;Send the character in the accumulator SENDBRK EQU $80F ;Send a 233 ms hardware BREAK SHUTDOWN EQU $812 ;Shut down driver (must do this before quitting) VERSION EQU $815 ;Protocol version number here NAME EQU $816 ;Text name of driver (ends with $00) ; ;Other EQUates ; A1L EQU $3C ;General-purpose address KBD EQU $C000 ;Read the keyboard here KBDSTRB EQU $C010 ;Clear the keyboard strobe BUTN0 EQU $C061 ;High bit set if Open-Apple pressed COUT EQU $FDED ;Send a character to the standard output ORG $2000 ; ;Start things up ; LDA VERSION ;Make sure the driver version # is right CMP #$10 BEQ VERSIONOK LDA #CANTRUN ;If a version 1.0 driver is not loaded, refuse to LDY #CANTRUN/ ;run JMP PRINT VERSIONOK LDA #WELCOME ;Put welcome banner on screen LDY #WELCOME/ JSR PRINT LDA #2 ;Save some stats: STA CURSLOT ;slot number (2) STA CURBAUD ;baud rate (2400) LDA #0 STA CURFMT ;data format (8/N/1) STA OKINIT ;successful initialization (not yet) TRYINIT LDA #INITMSG1 ;Put initialization message on screen LDY #INITMSG1/ JSR PRINT LDA #NAME LDY #NAME/ JSR PRINT LDA #INITMSG2 LDY #INITMSG2/ JSR PRINT LDA CURSLOT ORA #$B0 JSR COUT LDA #INITMSG3 LDY #INITMSG3/ JSR PRINT LDX CURBAUD JSR PRINTBAUD LDA #INITMSG4 LDY #INITMSG4/ JSR PRINT LDX CURFMT JSR PRINTFMT LDA #". JSR COUT LDA #$8D JSR COUT LDA CURFMT ;Try to initialize port now ASL ASL ASL ORA CURBAUD LDX CURSLOT JSR INIT BCC INITOK LDA #0 STA OKINIT CPY #$80 ;An error occurred; let's see what kind BCS BADCARD JMP BADBAUD ;Baud rate not supported by port BADCARD LDA #NAME ;No card/wrong card in slot LDY #NAME/ JSR PRINT LDA #TBADCARD LDY #TBADCARD/ JSR PRINT LDA CURSLOT ORA #$B0 JSR COUT LDA #". JSR COUT LDA #$8D JSR COUT LDA #$87 JSR COUT JMP MAINLOOP INITOK LDA #NAME ;Card initialized OK. LDY #NAME/ JSR PRINT LDA #TINITOK LDY #TINITOK/ JSR PRINT LDA #1 STA OKINIT ; ;Main event loop ; MAINLOOP LDA #CURSOR LDY #CURSOR/ JSR PRINT JSR GETCHAR ;Try grabbing a character first BCS NOCHAR ORA #$80 ;We got one, so make it printable and strip LFs CMP #$A0 BCS ]1 CMP #$87 BEQ ]1 CMP #$88 BEQ ]1 CMP #$8D BNE NOCHAR ]1 JSR COUT NOCHAR LDA KBD ;Try getting a key now BPL MAINLOOP ;Keep looping if no key was pressed STA KBDSTRB ;Clear the key AND #$7F ;Prep it for possible transmission BIT BUTN0 ;Was Open-Apple pressed? BMI COMMAND LDY OKINIT ;No, so is the port initialized? BEQ MAINLOOP ;If not, don't send the character JSR SENDCHAR JMP MAINLOOP COMMAND CMP #$60 ;Change lowercase to uppercase for commands BCC ]1 AND #$5F ]1 CMP #'? ;Request for help BEQ HELP CMP #'/ ;Also take OA-/ as help request BEQ HELP CMP #'S ;Change slot number BEQ CHGSLOT CMP #'R ;Change baud rate BEQ CHGBAUD CMP #'F ;Change data format BEQ CHGFMT CMP #'B ;Send BREAK BEQ BREAK CMP #'Q ;Quit BNE MAINLOOP JMP CONDSHUT ; ;Display help ; HELP LDA #HELPMSG LDY #HELPMSG/ JSR PRINT JMP MAINLOOP ; ;Move up a slot, or switch to slot 1 if already in slot 7 ; CHGSLOT JSR CONDSHUT ;Shut down current slot INC CURSLOT ;Add 1 LDA CURSLOT AND #7 BNE ]1 LDA #1 ;If 0, make it 1 ]1 STA CURSLOT JMP TRYINIT ;Initialize new slot ; ;Change baud rate ; CHGBAUD INC CURBAUD ;Add 1 to baud rate code LDA CURBAUD CMP #7 ;Range is 0 to 6 BCC ]1 LDA #0 ]1 STA CURBAUD PHA ;Print short message LDA #$8D JSR COUT PLA TAX JSR PRINTBAUD LDA #BAUDSEL LDY #BAUDSEL/ JSR PRINT UPDATE LDY OKINIT ;Only set port if it's active BEQ ]2 LDA CURFMT ASL ASL ASL ORA CURBAUD JSR SETPARMS BCS BADBAUD ]2 JMP MAINLOOP ; ;Change data format ; CHGFMT LDA CURFMT EOR #1 STA CURFMT LDA #$8D ;Confirm with message JSR COUT LDX CURFMT JSR PRINTFMT LDA #TCHGFMT LDY #TCHGFMT/ JSR PRINT JMP UPDATE ; ;Send BREAK ; BREAK LDA OKINIT ;Only if the port is active BEQ ]1 JSR SENDBRK ]1 JMP MAINLOOP ; ;Quit (shut down port only if it's active) ; CONDSHUT LDA OKINIT BEQ ]1 JSR SHUTDOWN RTS ; ;Print invalid baud rate message ; BADBAUD LDA #NAME LDY #NAME/ JSR PRINT LDA #TBADBAUD1 LDY #TBADBAUD1/ JSR PRINT LDX CURBAUD JSR PRINTBAUD LDA #TBADBAUD2 LDY #TBADBAUD2/ JSR PRINT JMP MAINLOOP ; ;Print a baud rate ; PRINTBAUD LDA LBAUDNUM,X LDY HBAUDNUM,X JMP PRINT ; ;Print data format ; PRINTFMT LDA LFMT,X LDY HFMT,X JMP PRINT ; ;Routine for sending long, involved messages to the screen ; PRINT STA A1L STY A1L+1 LDY #0 ]1 LDA (A1L),Y BEQ ]END JSR COUT INC A1L BNE [1 INC A1L+1 BNE [1 ]END RTS ; ;Miscellanea ; CURSLOT DFS 1 ;Slot number of serial port in use CURBAUD DFS 1 ;Baud rate code CURFMT DFS 1 ;Data format code OKINIT DFS 1 ;Put something here when a port is initialized LBAUDNUM DFC T300 ;Low bytes of baud-rate text addresses DFC T1200 DFC T2400 DFC T4800 DFC T9600 DFC T14.4K DFC T19.2K HBAUDNUM DFC T300/ ;High bytes of baud-rate text addresses DFC T1200/ DFC T2400/ DFC T4800/ DFC T9600/ DFC T14.4K/ DFC T19.2K/ LFMT DFC T8N1 ;Low bytes of data format text addresses DFC T7E1 HFMT DFC T8N1/ ;High bytes of data format text addresses DFC T7E1/ ; ;Various text messages ; CANTRUN DFC $8C ASC "A version 1.0 serial port driver must be loaded at $800 to use this" DFC $8D ASC "terminal program." DFC $87,$87,$87,$8D,0 WELCOME DFC $8C ASC "Term One Serial Port Driver Evaluation Terminal Program" DFC $8D ASC "(what a long-winded name! :-) )" DFC $8D,$8D ASC "Copyright (C) 1990 by Skunk Works Software Co." DFC $8D ASC "All Rights Reserved" DFC $8D,$8D ASC "If you get stuck, press " DFC $8F,$9B ASC "A" DFC $8E,$98 ASC "-? for some advice." DFC $8D,$8D,$8D,0 INITMSG1 ASC "Initializing " DFC 0 INITMSG2 ASC " in slot " DFC 0 INITMSG3 ASC " at " DFC 0 INITMSG4 ASC " baud, " DFC 0 TBADCARD ASC " not in slot " DFC 0 TINITOK ASC " initialized." DFC $8D,0 TBADBAUD1 ASC " does not accept " DFC 0 TBADBAUD2 ASC " baud." DFC $8D,$87,0 TCHGFMT ASC " selected." DFC $8D,0 CURSOR ASC "_" DFC $88 ASC " " DFC $88,0 HELPMSG DFC $8D,$8D ASC "HELP!!!" DFC $8D,$8D,$8F,$9B ASC "A" DFC $8E,$98 ASC "-S: change slot number" DFC $8D,$8F,$9B ASC "A" DFC $8E,$98 ASC "-R: change baud rate" DFC $8D,$8F,$9B ASC "A" DFC $8E,$98 ASC "-F: change data format" DFC $8D,$8F,$9B ASC "A" DFC $8E,$98 ASC "-B: send 233 ms BREAK" DFC $8D,$8F,$9B ASC "A" DFC $8E,$98 ASC "-Q: quit" DFC $8D,$8D,0 BAUDSEL ASC " baud selected." DFC $8D,0 T300 ASC "300" DFC 0 T1200 ASC "1200" DFC 0 T2400 ASC "2400" DFC 0 T4800 ASC "4800" DFC 0 T9600 ASC "9600" DFC 0 T14.4K ASC "14400" DFC 0 T19.2K ASC "19200" DFC 0 T8N1 ASC "8/N/1" DFC 0 T7E1 ASC "7/E/1" DFC 0