; B3AC-2 - Apple-Cat insert for BYE5                    - 07/30/85
;
;               Novation Apple-Cat routines for BYE3
;
; This version is for the Apple ][ running with an Apple-Cat modem card.
; Note:  This is an insert, not an overlay.
;
;       This routine will not function due to changes made in Bye335.
;       However, it is being kept with the library, because a version
;       of BYE will soon appear that will allow this overlay to work.
;
; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
;
; 07/30/85 - Restored to original format                - pst
; 06/22/82 - Created                                    - Dave Roznar
;
; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
;
; Apple-Cat modem address equates
;
SLOT    EQU     2               ; Apple-Cat residing in Slot #2
SLOTVAL EQU     SLOT*16         ; Number to add for proper slot
;
MCSTATP EQU     0E080H+SLOTVAL  ; Carrier status
LNCTL   EQU     0E081H+SLOTVAL  ; Line control
PHCTL   EQU     0E082H+SLOTVAL  ; Phone control
BSRINT  EQU     0E083H+SLOTVAL  ; BSR and interrupts
RCVCTL  EQU     0E089H+SLOTVAL  ; Receiver control
MDPORT  EQU     0E08AH+SLOTVAL  ; Mode (parity/stop bits) port
BAUDPT  EQU     0E08BH+SLOTVAL  ; Baud rate port
XRINT   EQU     0E08CH+SLOTVAL  ; Transmit/receive interrupts
TRXCTL  EQU     0E08DH+SLOTVAL  ; Transmitter control
MODSEL  EQU     0E08FH+SLOTVAL  ; Modem select port
;
RSPORT  EQU     0E08FH+SLOTVAL  ; Receive status port
RDPORT  EQU     0E08BH+SLOTVAL  ; Receive data port
TSPORT  EQU     0E08FH+SLOTVAL  ; Transmit status port
TDPORT  EQU     0E08EH+SLOTVAL  ; Transmit data port
;
DAV     EQU     00001000B       ; Data available
TBMT    EQU     00010000B       ; Transmit buffer empty
DCD     EQU     00100000B       ; Data carrier detect
;
;-----------------------------------------------------------------------
;
; See if we still have a carrier - if not, return with the zero flag set
;
MDCARCK:LDA     MCSTATP         ; Get carrier status
       ANI     DCD             ; Got carrier?
       RZ
       ORI     255
       RET
;
; Disconnect and wait for an incoming call
;
MDINIT: MVI     A,1FH           ; Turn off transmitter
       STA     TRXCTL
       MVI     A,0             ; Hang up phone
       STA     PHCTL
       RET
;
; Input a character from the modem port
;
MDINP:  MVI     A,10H           ; Clear receiver
       STA     TRXCTL
       LDA     RDPORT          ; Read character
       RET
;
; Check the status to see if a character is available.  If not, return
; with the zero flag set.  If yes, use 0FFH to clear the flag.
;
MDINST: LDA     RSPORT          ; Get modem status
       ANI     DAV             ; Data available?
       RZ                      ; Nope
       ORI     255             ; Return true
       RET
;
; Send a character to the modem
;
MDOUTP: STA     TDPORT          ; Send character
       RET
;
; See if the output is ready for another character
;
MDOUTST:LDA     TSPORT          ; Get modem status
       ANI     TBMT            ; Check transmit buffer empty bit
       RZ
       ORI     255
       RET
;
; Reinitialize the modem and hang up the phone by dropping DTR and
; leaving it inactive.
;
MDQUIT:  IF     IMODEM          ; If using a smartmodem
       CALL    IMQUIT
        ENDIF                  ; IMODEM
;
MDSTOP: MVI     A,1FH           ; Turn off transmitter
       STA     TRXCTL
       MVI     A,0             ; Hang up phone
       STA     PHCTL
       RET
;
; The following routine sets the baudrate.  BYE5 asks for the maximim
; speed you have available.
;
SET1200 EQU     $               ; 1200 bps not supported
SET2400 EQU     $               ; 2400 bps not supported
       ORI     255             ; Make sure the Zero flag isn't set
       RET
;
SET300: CALL    MDINP           ; Set for 300 baud
       CALL    MDINP
       MVI     A,22H           ; Set 300 baud
       STA     BAUDPT
       MVI     A,03H           ; Set 8 data bits, no parity, 1 stop bit
       STA     MDPORT          ; 03H = 1 stop, 0DH = 2 stop bits
       XRA     A
       RET
;                              end
;-----------------------------------------------------------------------