; B3KPRO-5.ASM Kaypro Z80-SIO insert for BYE3 - 04/04/84 ; ; Zilog Z80-SIO routines ; by Steve Fox ; ; This version adapts any Kaypro computer to BYE3. It may be used with ; any autor-answer modem such as the Hayes Smartmodem 300 or 1200, the ; Cermetek Infomate 212a, etc. ; ;======================================================================= ; ; 04/04/84 Improved for use with BYE3-20 - Paul Traina ; 02/25/84 Corrected NORING to MDRING - Irv Hoff ; 12/15/83 Renamed B3KPRO-3 to simplify updating. - Irv Hoff ; 12/07/83 Adapted for use with BYE3. - Steve Sanders ; ;======================================================================= ; ; Set base port for SIO & CTC chips ; BASEP: EQU 04H ;base port for SIO BASEC: EQU 00H ;base port for CTC baud rate generator ALTCTC: EQU NO ;true if using alternate baud rate set ;(see note below) ; ; The following define the port addresses to use. ; DATPORT:EQU BASEP ;data port STPORT: EQU BASEP+2 ;status/Control port BPORT: EQU BASEC ;baud rate port ; ; ; The following are STPORT commands (output these to STPORT) ; RESCHN: EQU 00011000B ;reset channel RESSTA: EQU 00010000B ;reset ext/status WRREG1: EQU 00000000B ;value to write to register 1 WRREG3: EQU 11000001B ;8 bits/char, Rx enable WRREG4: EQU 01000100B ;16x, 1 stop bit, no parity DTROFF: EQU 00000000B ;DTR off, RTS off DTRON: EQU 11101010B ;DTR on, 8 bits/char, Tx enable, RTS on ONINS: EQU 00110000B ;error reset ; ; The following are STPORT status masks ; DAV: EQU 00000001B ;data available TRDY: EQU 00000100B ;transmit buffer empty DCD: EQU 00001000B ;data carrier detect PE: EQU 00010000B ;parity error OE: EQU 00100000B ;overrun error FE: EQU 01000000B ;framing error ERR: EQU PE+OE+FE ;parity, overrun and framing error ; ; ; Now comes the time to decide how we set the baud rate. Set it for ; your particular CTC configuration. ; ; ; First Byte of CTC Command: ; IF ALTCTC BDCMD1: EQU 05H ;110 & 300 bps BDCMD2: EQU 45H ;600 & 1200 bps ; ; Second Byte of CTC Command: ; ;BD110 EQU 8EH ;110 bps BD300: EQU 34H ;300 bps ;BD600 EQU D0H ;600 bps, not supported with Smartmodem BD1200: EQU 68H ;1200 bps ENDIF ;ALTCTC ; ; First Byte of CTC Command: ; IF NOT ALTCTC BDCMD1: EQU 47H ;300 bps BDCMD2: EQU BDCMD1 ;600 & 1200 bps ; ; ; The following are baud rates for BPORT. ; BD300: EQU 5H ;300 bps ;BD600 EQU 64 ;600 bps, not supported with Smartmodem BD1200: EQU 7H ;1200 bps ENDIF ;NOT ALTCTC ; ; The following routine will reset the CTC to 300 baud and allow the ; modem to answer the phone when DTR is set True. ; MDANSW: CALL SET300 ;set 300 baud ; IF IMODEM CALL IMANSW ENDIF ;IMODEM ; IN DATPORT ;clear out garbage IN DATPORT ;make sure we're clear RET ; ; The following routine checks to make sure we still have carrier. If ; there is no carrier, it will return with the Zero flag set. ; MDCARCK:MVI A,RESSTA ;reset status OUT STPORT IN STPORT ;get status ANI DCD ;check for data carrier RET ; ; Hang up modem by turning off DTR ; MDHANG: MVI A,5 ;setup to write register 5 OUT STPORT MVI A,DTROFF ;clear DTR OUT STPORT ;..causing phone to hang up JMP MDANSW ;now set up to answer the phone ; ; MDINIT: MVI A,RESCHN ;reset channel OUT STPORT MVI A,4 ;setup to write register 4 OUT STPORT MVI A,WRREG4 OUT STPORT MVI A,1 ;setup to write register 1 OUT STPORT MVI A,WRREG1 OUT STPORT CALL MDHANG ;turn off DTR, hang up, set 300 bps PUSH B ;save in case it is being used elsewhere MVI B,20 ;2 second delay ; OFFTI: CALL DELAY ;0.1 second delay DCR B JNZ OFFTI ;keep looping until finished POP B ;restore BC MVI A,3 ;setup to write register 3 OUT STPORT MVI A,WRREG3 ;initialize receive register OUT STPORT MVI A,5 ;setup to write register 5 OUT STPORT MVI A,DTRON ;turn on DTR - modem can answer phone OUT STPORT ; IF IMODEM ;if using Hayes 300/1200 Smartmodem CALL IMINIT ;..go initialize it now ENDIF ;SMODEM ; RET ;Return ; ; The following is a routine that will input one character from the mo- ; dem port. If there is nothing there, it will return garbage... so use ; the MDINST routine first. ; MDINP: IN DATPORT ;get character ANI 7FH ;strip parity RET ; ; The following routine determines if there is a character waiting to be ; received. If no character is waiting, the Zero flag will be set, ; otherwise, 0FFH (255 decimal) will be returned in register A. ; MDINST: IN STPORT ;get status ANI DAV ;got a character? RZ ;teturn if none ORI 0FFH ;..otherwise, set the proper flag RET ; ; The following is a routine to determine if the transmit buffer is ; empty. If empty, it will return with the Zero flag clear. If the ; transmitter is busy, it will return with the Zero flag set. ; MDOUTST:IN STPORT ANI TRDY ;mask it RET ; ; The following is a routine that will output one character in register ; A to the modem. REMEMBER, that is register A, not register C. ; ; ** Use MDOUTST first to see if buffer is empty ** ; MDOUTP: OUT DATPORT ;send it RET ; MDQUIT: IF IMODEM CALL IMQUIT ENDIF ;IMODEM ; RET ; MDRING: RET ; ; These next routines set the proper baud rates for the modem. If you ; do not support the particular rate, then simply put the labele in front ; of the SETINV routine. If the baud rate change was successful, make ; SURE the Zero flag is set. ; ; Set up for 300 baud ; SET300: MVI A,BD300 ;load rate ; PUSH PSW ;..store it ; MVI A,BDCMD1 ;get first byte of command JMP SETBAUD ; ; ; Set up for 1200 baud ; SET1200:MVI A,BD1200 ;load rate ; PUSH PSW ;..save it ; MVI A,BDCMD2 ;get first byte of command ; SETBAUD:OUT BPORT ;send first byte of command ; POP PSW ;restore the rate OUT BPORT ;send rate XRA A ;say rate is OK RET ; ;The following routine returns a 255 because we were not able to set to ;the proper baud rate because either the serial port or the modem can't ;handle it. ; SET110: DS 0 ;110 bps not supported SET450: DS 0 ;450 bps not supported SET600: DS 0 ;600 bps not supported SET710: DS 0 ;710 bps not supported SETINV: ORI 0FFH ;make sure zero flag is not set RET ; ; Ok, that's all of the modem dependant routines that BYE3 uses, so if ; you patch this file into your copy of BYE3, then it should work fine. ;