******************************************************************************
*  THIS CODE IS FOR THE WB6JHQ SELECTIVE CALL UNIT.                          *
*                                                                            *
*11/10/94. CHANGED PMTO TO 30 SECONDS.                                       *
*11/10/94. ADDED REMINDER RTN. RCNTRI=180 SECONDS.                             *
******************************************************************************
        ORG     $FB00
FILL1   FDB     $FFFF,$FFFF,$FFFF,$FFFF
*
        ORG     $E000
*
R_DATE  FCC     " DE WB6JHQ, DATE 04/10/02, VERSION 16 "
        FCB     EOT
*
RSPND   FCC     "R"    ;RESPONSE CHARACTER.
        FCB     EOT
*
SOS     FCC     "SOS"    ;UPPER CASE ASCII ONLY.
        FCB     EOT                ;A-F,0-9AND / ,?
*
GROUP   FCC     "GROUP"
        FCB     EOT
*
SELECT  FCC     "HI HI"
        FCB     EOT
*
*PUT POWER ON RESET DEFAULTS HERE.
*
*FUNCTION BYTE ONE.
*
FCT1    EQU    $00      ;POR DEFAULTS FOR FUNCTION BYTE 1.
*
CTRLK   EQU    $80      ;0 . . . . . . . ;CONTROLLER LOCKED.
BLK_GRP EQU    $40      ;. * . . . . . . ;BLOCK GROUP DECODE.
*       EQU    $20      ;. . * . . . . . ;
SPKSET  EQU    $10      ;. . . * . . . . ;SPEAKER IS ON.
*       EQU    $08      ;. . . . * . . . ;
*       EQU    $04      ;. . . . . * . . ;
S_GRP   EQU    $02      ;. . . . . . * . ;SET GROUP BIT.
S_SLC   EQU    $01      ;. . . . . . . * ;SET SELECTIVE BIT.
*
*FUNCTION BYTE TWO.
*
FCT2    EQU    $00      ;POR DEFAULTS FOR FUNCTION BYTE 2.
*
*       EQU    $80      ;* . . . . . . . ;
*       EQU    $40      ;. * . . . . . . ;
TIMEADJ EQU    $20      ;. . * . . . . . ;1 HERTZ TIMER ADJUSTMENT.
P_AUX1  EQU    $10      ;. . . * . . . . ;PULSE AUX1 OUTPUT.
P_AUX2  EQU    $08      ;. . . . * . . . ;PULSE AUX2 OUTPUT.
S_AUX1  EQU    $04      ;. . . . . * . . ;LATCH AUX1 OUTPUT.
S_AUX2  EQU    $02      ;. . . . . . * . ;LATCH AUX2 OUTPUT.
*       EQU    $01      ;. . . . . . . * ;
*
*FUNCTION BYTE THREE.
*
FCT3    EQU    $00      ;POR DEFAULTS FOR FUNCTION BYTE 3.
*
*       EQU    $80      ;* . . . . . . . ;
*       EQU    $40      ;. * . . . . . . ;
*       EQU    $20      ;. . * . . . . . ;
*       EQU    $10      ;. . . * . . . . ;
SNDROM  EQU    $08      ;. . . . * . . . ;SEND ROM DATE BIT.
S_SLCT  EQU    $04      ;. . . . . * . . ;SEND SELECTIVE CALL MSG.
S_GROUP EQU    $02      ;. . . . . . * . ;SEND GROUP CALL MSG.
S_ALARM EQU    $01      ;. . . . . . . * ;SEND EMERGENCY CALL MSG.
*
*       FUNCTION TOUCHTONE CODES GO HERE.
*
* TOUCH-TONE: 1  2  3  4  5  6  7  8  9  0  *  #  A  B  C  D
*             |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
* DECODE HEX: 1  2  3  4  5  6  7  8  9  A  B  C  D  E  F  0
*
*                                      X=USER FUNCT._
*                                                    |
*               HEX                                  V TOUCH-TONE
F1      EQU   $2990  ;LOCK CODE                      ( 2 9 9 )  *
F2      EQU   $2820  ;UNLOCK CODE                    ( 2 8 2 )  *
F3      EQU   $2830  ;RESET NORMAL.                  ( 2 8 3 )
F4      EQU   $2A10  ;FORCE RESET (POR)              ( 2 0 1 )  *
F5      EQU   $2A20  ;PULSE T1.                      ( 2 0 2 )
F6      EQU   $2A30  ;PULSE T2.                      ( 2 0 3 )
F7      EQU   $2A40  ;SET T1.                        ( 2 0 4 )
F8      EQU   $2A50  ;RESET T1.                      ( 2 0 5 )
F9      EQU   $2A60  ;SET T2.                        ( 2 0 6 )
F10     EQU   $2A70  ;RESET T2.                      ( 2 0 7 )
F11     EQU   $2A80  ;SEND EPROM DATE                ( 2 0 8 )  *
F12     EQU   $2A90  ;ADJUST 1 HERTZ TIMER.          ( 2 0 9 )
F13     EQU   $2220  ;TURN ON SELECTIVE CALL.        ( 2 2 2 )  *
F14     EQU   $21A0  ;TURN OFF SELECTIVE CALL LED.   ( 2 1 0 )
F15     EQU   $4AA0  ;TURN ON GROUP CALL.            ( 4 0 0 )  *
F16     EQU   $2110  ;TURN OFF GROUP LED.            ( 2 1 1 )
F17     EQU   $2120  ;TURN ON  EMERG LED.            ( 2 1 2 )
F18     EQU   $2130  ;TURN OFF EMERG LED.            ( 2 1 3 )

*
F_TABLE FDB     F3,RNM
        FDB     F5,S24
        FDB     F6,S23
        FDB     F7,SF6
        FDB     F8,RF6
        FDB     F9,SF5
        FDB     F10,RF5
        FDB     F12,ADJ_ON
        FDB     F14,RF1
        FDB     F16,RF2
        FDB     F17,SF3
        FDB     F18,RF3
SECOND  FDB     F13,S10
        FDB     F15,S11
        FDB     F11,SROM
        FDB     F1,S17
        FDB     F2,R17
        FDB     F4,FRCRST
ENDTAB  RMB     1
*
* LOW MEMORY ASSIGNMENTS
*
MIN3    EQU    $0000    ;3 MINUTE CHOP TIMER SAVE AREA.(1)
FLASH   EQU    $0001    ;INIT VALUE FOR IDTEN.(2)
MEMCHK  EQU    $0003    ;VALUE CHECKED IN THE TIMERTN.(1)
OUT     EQU    $0004    ;COPY OF DATAOUT FOR BLINK RTN.(1)
XTEMP   EQU    $0005    ;TEMP STORAGE FOR SCODE RTN.(2)
TONECT  EQU    $0007    ;TONE DURATION SAVE AREA.(2)
CORRST  EQU    $0009    ;COUNTER FOR RESTORING PL MODE.(1)
UTIME   EQU    $000A    ;MORSE TONE GENERATOR SAVE AREA.(1)
FCCTR   EQU    $000B    ;FUNCTION CONPLETE COUNTER.(1)
X_INC   EQU    $000C    ;INDEX REG. INCREMENT AREA.(2)
DITCNT  EQU    $000E    ;DIT COUNTER FOR SCODE RTN.(2)
SPACNT  EQU    $0010    ;SPACE COUNTER FOR SCODE RTN.(2)
DAHCNT  EQU    $0012    ;DAH COUNTER FOR SCODE RTN.(2)
M3INT   EQU    $0014    ;INIT VALUE FOR MIN3.(1)
ZTIME   EQU    $0015    ;ZERO DETECT TIMER. 3 SECS.(2)
ARPLMS  EQU    $0019    ;AUTO-RESTORE PLMODE TIMER SAVE AREA.(2)
FLAGS   EQU    $001B    ;FLAGS REG.(1)
IN1     EQU    $001D    ;INPUT AREA BYTE ONE, 2 DIGITS.(1)
IN2     EQU    $001E    ;INPUT AREA BYTE TWO, 2 DIGITS.(1)
DCTR    EQU    $001F    ;DIGIT COUNTER SAVE AREA.(1)
FCTB1   EQU    $0020    ;FUNCTION BYTE ONE.(1)
FCTB2   EQU    $0021    ;FUNCTION BYTE TWO.(1)
FCTB3   EQU    $0022    ;FUNCTION BYTE THREE.(1)
MUTECNT EQU    $0027    ;MUTE COUNTER SAVE AREA.(1)
PMTO16  EQU    $0028    ;PMTO COUNTER SAVE AREA.(1)
MSAVE0  EQU    $0029    ;TEMP DATA SAVE AREA FOR MORSE CONV.(1)
MSAVE1  EQU    $002A    ;TERMINATE CHARACTER FOR MORSE CONV.(1)
SAVEXM  EQU    $002B    ;TEMP INDEX SAVE AREA FOR MORSE CONV.(2)
FREQ    EQU    $002D    ;SETS TONE FREQUENCY.(1)
RCNTR   EQU    $002E    ;REMINDER COUNTER.(1)
MODFX   EQU    $002F    ;MODIFY FUNCTION TABLE POINTER.(2)
STACK   EQU    $007F    ;STACK POINTER INITIAL VALUE.
*
* FLAG BYTE0 EQUATES.
*
TXFLG   EQU    $80      ;POWER INDICATOR FLAG.
MODFCT  EQU    $40      ;MODIFY FUNCTION TABLE FLAG.
MODID1  EQU    $20      ;MODIFY IDENTIFICATION ONE FLAG.
MODID2  EQU    $20      ;MODIFY IDENTIFICATION TWO FLAG.
BFLG    EQU    $08      ;BLINK FLAG.
MUTEFLG EQU    $04      ;POWER LED OFF TIME (MUTE FLAG).
RMDFLG  EQU    $02      ;REMINDER FLAG.
ZFLG    EQU    $01      ;ZERO DETECT FLAG.
*
* PIA AND OTHER EQUATES
*
IDAUDIO EQU    $80      ;I.D. AUDIO BIT IN DATA OUT 0 REG.
PTIME   EQU     60      ;60 SECONDS.
ONESEC  EQU    $07D0    ;ADJUST FOR 1 SECOND.
TDLY    EQU    $8000    ;1 SEC. COUNT DOWN VALUE.
ZTIMEI  EQU    $2D00    ;ZERO DETECT TIME INIT.
SLCTBIT EQU    $10      ;PIA COR LINE.
TXBIT   EQU    $10      ;TX BIT IN PIA OUTPUT REG.(T5)
PL_BIT  EQU    $20      ;USER PL BIT.
RNG_BIT EQU    $40      ;RING IN BIT.
DATAIN  EQU    $A000    ;CONTROL LINES AND TOUCHTONES READ HERE.
PIA0CR  EQU    $A001    ;CONTROL REG ADDRESS FOR PIA0.
DATAOUT EQU    $A002    ;OUTPUT TRANSISTORS AND AUDIO SENT HERE.
PIAINP  EQU    $0017    ;CONFIG BYTES FOR PIA'S.(INPUT=00,ENABLE IRQ.)
PIAOUT  EQU    $FF16    ;CONFIG BYTES FOR PIA'S.(OUTPUT=FF,NO IRQ.)
ARPLMI  EQU    $0030    ;AUTO LOCKUP,RESTORE PL,LCD,RPTR OFF VALUE.
LOW1    EQU    $A0      ;LOW TONE FREQ. VALUE.
HIGH1   EQU    $50      ;HIGH TONE FREQ. VALUE.
RMTONE  EQU    $0050    ;REMOTE RESPONSE TONE DURATION.(WAS 45H)
RNGTONE EQU    $0090    ;RING TONE DURATION.
RING1T  EQU    $00F0    ;RING TONE FREQ1.
RING2T  EQU    $00D0    ;RING TONE FREQ2.
HANGT   EQU     90      ;AUTO HANGUP TIMER INIT.
DTCTI   EQU    $0030    ;DIT COUNTER INIT VALUE.
SPCNTI  EQU    $0060    ;SPACE COUNTER INIT VALUE.(2*DIT COUNT)
DHCNTI  EQU    $0090    ;DAH COUNTER INIT VALUE.(3* DIT COUNT)
UTIMI   EQU    $80      ;500 USEC.  (83*6)
FREQI   EQU    $70      ;1 KHZ. APPROX.
EOT     EQU    $FF      ;END OF TRANSMISSION.
EOC     EQU    $80      ;END OF CHARACTER.
SPCE    EQU    $21      ;SPACE CODE.
FLSHI   EQU     1000    ;FLASH RATE COUNTER.
M3I     EQU     0180    ;3 MINUTE INIT VALUE.(CHANGE AS REQUIRED)  ****
DLYI    EQU    $6000    ;DROP DELAY INIT VALUE.(CHANGE AS REQUIRED)
FLGS0I  EQU    $00      ;FLAG BYTE 0 INIT VALUE.
MUTM    EQU    $02      ;MUTE DELAY TIME.
FL1     EQU    $20      ;FUNCTION 1 LATCH (T6).SELECTIVE LED.
FL2     EQU    $40      ;FUNCTION 2 LATCH (T7).GROUP LED.
FL3     EQU    $08      ;FUNCTION 3 LATCH (T4).EMERGENCY LED.
FL4     EQU    $04      ;FUNCTION 4 LATCH (T3).SPEAKER RELAY.
FL5     EQU    $02      ;FUNCTION 5 LATCH (T2).AUX OUT2
FL6     EQU    $01      ;FUNCTION 6 LATCH (T1).AUX OUT1
AUX2    EQU    $02      ;FUNCTION 5 LATCH (T2).AUX OUT2
AUX1    EQU    $01      ;FUNCTION 6 LATCH (T1).AUX OUT1
MASK    EQU    $68      ;MASK FOR BLINK RTN.
RCNTRI  EQU    180      ;REMINDER INIT VALUE.
RMTDLYI EQU    $1000    ;REMOTE TX DROP DELAY INIT VALUE.
HS_DLY  EQU    $F424    ;HALF SECOND LOOP VALUE FOR 1 HERTZ TIMING RTN.
DEL1    EQU    $007D    ;APPROX. .1 SEC. DELAY VALUE USED IN DEL_1.
DEL5    EQU    $0368    ;APPROX. .5 SEC. DELAY VALUE USED IN DEL_5.
*
*
*       TITLE   'REPEATER SOFTWARE BY WB6JHQ'
*
RESTART SEI                    ;DISABLE INTERRUPTS.
        LDS           #STACK   ;LOAD STACK POINTER.
        LDX           #PIAINP  ;INPUTS AND IRQ ENABLED.
        STX            DATAIN  ;INIT 1ST PIA PORT AS INPUTS WITH IRQ.
        LDX           #PIAOUT  ;OUTPUTS AND STROBE.
        STX            DATAOUT ;INIT 2ND PIA PORT AS OUTPUTS & STRB.
        LDAA          #$00     ;CLEAR ALL OUTPUTS.
        STAA           DATAOUT ;
        STAA           OUT
        JSR            CLRMEM  ;CLEAR LOW MEMORY.
        JSR            INITIT  ;INITS LOW MENORY CONSTANTS.
        LDS           #STACK   ;LOAD STACK POINTER.
        CLI                    ;ENABLE INTERRUPTS FROM TOUCHTONE DECODER
*
*       THIS IS THE CONTROL LOOP. CHECKING FUNCTION AND STATUS BITS.
*       PUT SCANNED FUNCTIONS IN HERE.
*
C_LOOP  LDAA           MUTECNT
        BNE            PMTO
        JSR            CLRMUTE
PMTO    LDAA          #PTIME   ;PUT # IN COUNT DOWN TIMER.
        STAA           PMTO16  ;FOR PROCESS MONITOR TIMEOUT.
        LDAA           FCCTR   ;GET RESPONSE VALUE.
        BEQ            SPKER
        JSR            RESPOND ;GO SEND RESPONCE BEEPS.
*
SPKER   LDAA           FCTB1   ;TURNS OFF SPEAKER IF SPKSET BIT OFF.
        ANDA          #SPKSET
        BNE            REMIND
        LDAA          #FL4
        COMA
        JSR            RSTRG1
*
REMIND  LDAA           FLAGS
        ANDA          #RMDFLG
        BEQ            ZERO
        JSR            ATTEN    ;SEND ATTEN EVERY XX MINUTES.
        LDAA          #RMDFLG   ;CLEAR FLAG.
        COMA
        ANDA           FLAGS
        STAA           FLAGS
        LDAA          #RCNTRI  ;INIT REMINDER COUNTER.
        STAA           RCNTR   ;
*
ZERO    LDAA           DATAIN
        ANDA          #SLCTBIT
        BEQ            BLINK
        LDAA           DATAIN
        ANDA          #$0F
        CMPA          #$0A
        BNE            RSTZF
        LDAA           FLAGS
        ANDA          #ZFLG
        BEQ            SETZF
        LDAA           DATAIN
        ANDA          #$0F
        CMPA          #$0A
        BNE            RSTZF
        LDX            ZTIME
        DEX
        STX            ZTIME
        CPX           #$0000
        BNE            BLINK
        LDAA          #FL3
        ORAA           OUT
        STAA           OUT
        LDAA          #FL4
        JSR            SETR1
        LDAA          #M3I
        STAA           MIN3
        LDAA          #SPKSET
        ORAA           FCTB1
        STAA           FCTB1
        JSR            RINGER
        JSR            RINGER
        JSR            RINGER
        JSR            RINGER
        JSR            RINGER
        JSR            RINGER
        JSR            DEL_5
        LDAA          #S_ALARM
        ORAA           FCTB3
        STAA           FCTB3
        BRA            RSTZF
SETZF   SEI
        LDAA          #ZFLG
        ORAA           FLAGS
        STAA           FLAGS
        CLI
        LDX           #ZTIMEI
        STX            ZTIME
        BRA            BLINK
RSTZF   SEI
        LDAA          #ZFLG
        COMA
        ANDA           FLAGS
        STAA           FLAGS
        CLI
        LDX           #ZTIMEI
        STX            ZTIME
*
BLINK   LDAA           OUT     ;ANYTHING TO BLINK?
        BEQ            SENDROM
        LDX            FLASH   ;BLINK RATE VALUE.
        DEX
        STX            FLASH
        CPX           #$0000
        BNE            SENDROM
        LDAA           FLAGS
        ANDA          #BFLG
        BEQ            RBLINK
SBLINK  LDAA           OUT     ;  0000 1000
        ANDA          #MASK    ;  0110 1000
        ORAA           DATAOUT ;  XXXX 1XXX
        STAA           DATAOUT ;  XXXX 1XXX
        SEI
        LDAA          #BFLG    ;RST BFLG
        COMA
        ANDA           FLAGS
        STAA           FLAGS
        CLI
        LDX           #FLSHI
        STX            FLASH
        BRA            SENDROM
RBLINK  LDAA           OUT     ;  0000 1000
        ANDA          #MASK    ;  0110 1000
        COMA                   ;  1111 0111
        SEI
        ANDA           DATAOUT ;  XXXX 1XXX
        STAA           DATAOUT ;  XXXX 0XXX
        LDAA          #BFLG    ;SET BFLG
        ORAA           FLAGS
        STAA           FLAGS
        CLI
        LDX           #FLSHI
        STX            FLASH
*
SENDROM LDAA           FCTB3   ;CHECK IF SEND EPROM IS ON.
        ANDA          #SNDROM
        BEQ            PAUX1
        LDAA           FLAGS   ;CHECK FOR MUTE ON.
        ANDA          #MUTEFLG ;
        BNE            PAUX1
        JSR            TXON
        JSR            EPROM
        LDAA          #SNDROM  ;CLEAR SEND EPROM DATE BIT.
        COMA
        ANDA           FCTB3
        STAA           FCTB3
*
PAUX1   LDAA           FCTB2
        ANDA          #P_AUX1
        BEQ            PAUX2
        LDAA          #AUX1
        JSR            SETR1
        JSR            DEL_5
        LDAA          #P_AUX1
        COMA
        ANDA           FCTB2
        STAA           FCTB2
        LDAA          #AUX1
        COMA
        JSR            RSTRG1
*
PAUX2   LDAA           FCTB2
        ANDA          #P_AUX2
        BEQ            SSLCT
        LDAA          #AUX2
        JSR            SETR1
        JSR            DEL_5
        LDAA          #P_AUX2
        COMA
        ANDA           FCTB2
        STAA           FCTB2
        LDAA          #AUX2
        COMA
        JSR            RSTRG1
*
SSLCT   LDAA           FCTB1
        ANDA          #S_SLC
        BEQ            SGRP
        LDAA          #FL1
        ORAA           OUT
        STAA           OUT
        LDAA          #SPKSET
        ORAA           FCTB1
        ANDA          #$FE
        STAA           FCTB1
        LDAA          #FL4
        JSR            SETR1
        CLR            FCCTR
        JSR            ATTEN
        LDX           #SELECT
        JSR            EPROM1
        LDAA          #M3I
        STAA           MIN3
*
SGRP    LDAA           FCTB1
        ANDA          #S_GRP
        BEQ            ID_IT
        LDAA          #FL2
        ORAA           OUT
        STAA           OUT
        LDAA          #SPKSET
        ORAA           FCTB1
        ANDA          #$FD
        STAA           FCTB1
        LDAA          #FL4
        JSR            SETR1
        CLR            FCCTR
        JSR            ATTEN
        LDX           #GROUP
        JSR            EPROM1
        LDAA          #M3I
        STAA           MIN3
*
ID_IT   LDAA           FCTB3   ;CHK IF FORCE ID BIT IS ON.
        ANDA          #S_ALARM
        BEQ            KDONE
        JSR            IDENT   ;
        LDAA          #S_ALARM   ;RESET FORCE IDENT BIT.
        COMA                   ;
        ANDA           FCTB3   ;
        STAA           FCTB3   ;
*
KDONE   JSR            TXON    ;TURN ON TRANSMITTER.
NOPL    JMP            C_LOOP  ;
*
NO_P    LDAA           DATAOUT ;TURN OFF XMIT.
        ANDA          #$EFH
        STAA           DATAOUT
        RTS
*
TXON    LDAA           FLAGS   ;CHECK FOR MUTE ON.
        ANDA          #MUTEFLG
        BNE            NO_P
NO_APL1 LDAA           FLAGS
        ANDA          #TXFLG
        BNE            FLGON
        SEI
        LDAA           DATAOUT ;GET OUTPUT REG.
        ORAA          #TXBIT   ;SET TX BIT.
        STAA           DATAOUT
        LDAA           FLAGS
        ORAA          #TXFLG   ;SET TX FLAG BIT.
        STAA           FLAGS
        CLI
FLGON   RTS
*
M_WAIT  LDAA           FLAGS   ;CHECK FOR MUTE ON.
        ANDA          #MUTEFLG ;
        BNE            M_WAIT  ;
        RTS
*
WARBLE  JSR             HINOTE
        JSR             LONOTE
        JSR             HINOTE
        JSR             LONOTE
        JSR             HINOTE
        JSR             LONOTE
        JSR             HINOTE
        JSR             LONOTE
        JSR             HINOTE
        JSR             LONOTE
        JSR             HINOTE
        JSR             LONOTE
        JSR             HINOTE
        JSR             LONOTE
        JSR             HINOTE
        JSR             LONOTE
        JSR             HINOTE
        JSR             LONOTE
        JSR             HINOTE
        JSR             LONOTE
        RTS
*
SENDP   LDX           #PCODE    ;
        JSR            SCODE    ;
        RTS                     ;
*
RINGER  LDAA           FREQ    ;SAVE TONE FREQ.
        PSHA                   ;
        LDAA          #RING1T  ;SET FOR LOW TONE. (FREQ.)
        STAA           FREQ    ;
        LDX           #RNGTONE ;SET FOR DURATION. (LENGTH)
        STX            TONECT  ;
        JSR            SAVER   ;DO IT.
        LDAA          #RING2T  ;SET FOR LOW TONE. (FREQ.)
        STAA           FREQ    ;
        LDX           #RNGTONE ;SET FOR DURATION. (LENGTH)
        STX            TONECT  ;
        JSR            SAVER   ;DO IT.
        PULA                   ;RESTORE UTIME.
        STAA           FREQ    ;
        RTS                    ;
*
ATTEN   JSR            LONOTE
        JSR            HINOTE
        JSR            LONOTE
        JSR            HINOTE
        JSR            LONOTE
        JSR            HINOTE
        JSR            LONOTE
        JSR            HINOTE
        JSR            LONOTE
        JSR            HINOTE
        JSR            LONOTE
        JSR            HINOTE
        JSR            LONOTE
        JSR            HINOTE
        JSR            LONOTE
        JSR            HINOTE
        JSR            LONOTE
        JSR            DEL_5
        RTS
*                               ;
LONOTE  LDAA           FREQ    ;SAVE TONE FREQ.
        PSHA                   ;
        LDAA          #LOW1    ;SET FOR LOW TONE. (FREQ.)
        STAA           FREQ    ;
        LDX           #RMTONE  ;SET FOR DURATION. (LENGTH)
        STX            TONECT  ;
        JSR            SAVER   ;DO IT.
        PULA                   ;RESTORE UTIME.
        STAA           FREQ    ;
        RTS                    ;
*
HINOTE  LDAA           FREQ    ;SAVE TONE FREQ.
        PSHA                   ;
        LDAA          #HIGH1   ;SET FOR HI TONE. (FREQ.)
        STAA           FREQ    ;
        LDX           #RMTONE  ;SET FOR DURATION.(LENGTH)
        STX            TONECT  ;
        JSR            SAVER   ;DO IT.
        PULA                   ;RESTORE UTIME.
        STAA           FREQ    ;
        RTS
*
*       INTERUPT ROUTINE FOR TOUCH TONE SERVICE BEGINS HERE. (MI)
*

*
IRQ     LDX           #ARPLMI  ;SET AUTO RESTORE PL MODE VALUE.
        STX            ARPLMS  ;
        LDAA           FLAGS    ;SET MUTE FLAG.
        ORAA          #MUTEFLG  ;
        STAA           FLAGS   ;
        LDAA          #MUTM    ;INIT MUTE COUNTER.
        STAA           MUTECNT ;
        LDAA           DATAIN  ;GET T.T. DATA.
        ANDA          #$0F     ;
        LDAB           DCTR    ;GET BYTE POINTER.
        BNE            CK1     ;IF = ZERO THEN FALL THROUGH.
IRQ1    ASLA                   ;SHIFT DATA LEFT 4 TIMES. ENTER HERE
        ASLA                   ;ALSO IF 4TH DIGIT OF SEQ. AND NOT "PREFIX".
        ASLA                   ;"FUNCTION CHAINING"
        ASLA                   ;
        STAA           IN1     ;PUT AWAY IN INPUT AREA ONE.
        INC            DCTR    ;INCREMENT DIGIT COUNTER.
        RTI                    ;
CK1     CMPB          #$01     ;IS THIS 2ND DIGIT?
        BNE            CK2     ;
        ORAA           IN1     ;OR 1ST DIGIT WITH 2ND.
        STAA           IN1     ;PUT IT BACK.
        INC            DCTR    ;
        RTI                    ;
CK2     CMPB          #$02     ;IS IT 3RD DIGIT?
        BNE            INTRUDE ;
        ASLA                   ;
        ASLA                   ;
        ASLA                   ;
        ASLA                   ;
        ANDA          #$F0
        STAA           IN2     ;
        INC            DCTR    ;INCREMENT DIGIT COUNTER.
        BRA            SEARCH  ;
*                              ;
RSTR    JMP            RESTORE ;
RSTR1   JMP            RSTORE1 ;
*                              ;
SEARCH  LDAA           FCTB1   ;
        ANDA          #CTRLK   ;
        BEQ            ALL_ON  ;
        LDX           #SECOND  ;
        BRA            SRCH1   ;
ALL_ON  LDX           #F_TABLE ;LOAD INDEX REG WITH FUNCTIONS.
SRCH1   LDAA           IN1     ;GET 1ST DIGIT IN A-REG.
        LDAB           IN2     ;GET 2ND DIGIT IN B-REG.
LP1     CMPA             0,X   ;COMPARE A-REG PER INDEX.
        BNE            SRCHM   ;IF NO COMPARE THEN TRY AGAIN.
        INX                    ;IF MATCH THEN INCREMENT INDEX.
        CMPB             0,X   ;COMPARE B-REG PER INDEX.
        BNE            SRCHM1  ;IF NOT THEN TRY AGAIN.
        INC            FCCTR   ;INCREMENT FUNCTION COUNTER.
        LDX              1,X   ;IF MATCHED A & B. THEN GO DO IT
        JMP              0,X   ;PER INDEX REG.MUST END WITH RTI.
SRCHM   INX                    ;GO HERE IF A-REG DONT COMPARE.
SRCHM1  INX                    ;HERE IF A-REG DOES BUT NOT B-REG.
        INX                    ;
        INX                    ;
        CPX           #ENDTAB  ;IF END OF TABLE STOP SEARCHING.
        BNE            LP1     ;IF NOT THEN TRY AGAIN.
INTRUDE CLR            DCTR    ;
        RTI                    ;
*
IDENT   JSR            TXON    ;TURN ON TX.
        BRA            DEFAULT ;MUST BE ID 0.
IDENT1  LDAA           FCTB3   ;GET ID BITS.
        ANDA          #$FC     ;CLEAR ID BITS.
        STAA           FCTB3   ;PUT IT BACK.
CW_ONLY LDX           #S_GROUP   ;
        DEX
        BRA            GO_ID0  ;
ALTID1  LDAA           FCTB3   ;GET ID BITS.
        ANDA          #$FC     ;CLEAR ID BITS.
        STAA           FCTB3   ;PUT IT BACK.
DEFAULT LDX           #SOS     ;POINT TO MORSE CODE.
        DEX
GO_ID0  INX                    ;
        STX            SAVEXM  ;SAVE IT.
        LDAA             0,X   ;GET FIRST CHAR.
        CMPA          #EOT     ;LAST CHAR. SENT?
        BEQ            IDONE1  ;
        JSR            CONVASC ;CONVERT ASCII TO HEX.
        LDX            SAVEXM  ;GET X BACK.
        BRA            GO_ID0  ;
IDONE1  LDAA           FCTB3   ;GET ID BITS.
        INCA                   ;INCREMENT PLUS ONE.
        STAA           FCTB3   ;PUT IT BACK.(MAKES IT LONG ID EVERY 4TH)
IDONE   SEI
        LDAA           FLAGS   ;RESET ID FLAG.
        ANDA          #$F7
        STAA           FLAGS
        CLI
        RTS                    ;
*
RESTORE LDAA           DATAOUT ;TURN OFF XMIT FOR MUTE.
        ANDA          #$EF     ;REMOVE TXBIT.
        STAA           DATAOUT ;
        LDAA          #MUTM    ;
        STAA           MUTECNT ;INIT MUTE COUNTER.
        LDAA           FLAGS   ;SET MUTE FLAG BIT.
        ORAA          #MUTEFLG ;
        STAA           FLAGS   ;
RSTORE1 CLR            DCTR    ;
        RTI                    ;
CLRMEM  LDX           #$0070   ;GET READY TO CLEAR LOW MEMORY.
        LDAA          #$00     ;PUT ZEROS IN A-REG.
CLRLOOP STAA             0,X   ;PUT AWAY PER X-REG.
        DEX                    ;-1 FROM X-REG.
        BNE            CLRLOOP ;IF NOT DONE DO AGAIN.
        STAA             0,X   ;CLEAR ADDRESS ZERO BEFORE RETURN.
        RTS                    ;RETURN.
*
CLRMUTE LDAA          #MUTEFLG ;CLEAR MUTE FLAG.
        ORAA          #TXFLG   ;AND TXFLG.
        COMA                   ;
        ANDA           FLAGS   ;
        STAA           FLAGS   ;
        JSR            TXON    ;
        RTS                    ;
*
EPROM   JSR            TXON    ;SEND EPROM DATE.
        JSR            DELONE  ;
        LDX           #R_DATE  ;
EPROM1  LDAA             0,X   ;GET FIRST CHAR.
        INX                    ;INCREMENT INDEX.
        STX            SAVEXM  ;SAVE IT.
        CMPA          #EOT     ;LAST CHAR. SENT?
        BEQ            IDONE2  ;
        JSR            CONVASC ;CONVERT ASCII TO HEX.
        LDX            SAVEXM  ;GET X BACK.
        BRA            EPROM1  ;
IDONE2  RTS
*
RESPOND LDAA           FLAGS   ;CHECK FOR MUTE ON.
        ANDA          #MUTEFLG ;
        BNE            QUIET   ;
        BRA            CODE    ;
QUIET1  CLR            FCCTR   ;CLEAR FUNCTION COMPLETE COUNTER.
QUIET   RTS                    ;
*
CODE    JSR            TXON    ;TURN ON TRANSMITTER.
        LDAA           RSPND   ;POINT TO RESPONSE CODE.
        JSR            CONVASC ;SEND RESPONSE.
        DEC            FCCTR   ;DECREMENT FUNCTION COUNTER.
        BRA            QUIET   ;
*
* ENTER WITH CHAR. TO CONVERT TO MORSE IN THE A-REG.
*
CONVASC LDX           #ASCII   ;POINT TO CONVERSION TABLE.
LOOP10  CMPA             0,X   ;ASCII TO MORSE.
        BEQ            GOTIT   ;IF MATCH THEN SEND IT.
        INX                    ;POINT TO NEXT IN TABLE.
        BRA            LOOP10  ;LOOK SOMEMORE.
DONE    RTS                    ;
*
GOTIT   CMPA          #EOT     ;IS IT END OF TRANSMISSION?
        BEQ            DONE    ;
        LDAB           $30,X   ;GET MORSW EQUIV. TO ASCII.
        STAB           MSAVE0  ;PUT IT IN MORSE SAVE AREA. AND
        LDAB          #$FF     ;PUT A FF AFTER IT TO END SCODE RTN..
        STAB           MSAVE1  ;
        LDX           #MSAVE0  ;POINT TO CODE FOR SCODE.
        BSR            SCODE   ;
        RTS                     ;
*
ASCII   FCC     "1234567890"    ;UPPER CASE ASCII ONLY.
        FCC     "ABCDEFGHIJ"
        FCC     "KLMNOPQRST"
        FCC     "UVWXYZ/?,. "
        FCB     $0FF
*
        ORG     ASCII+$30
*
HEX     FDB    $7C3C      ;MORSE CODE EQUIV.
        FDB    $1C0C
        FDB    $0484
        FDB    $C4E4
        FDB    $F4FC
        FDB    $6088
        FDB    $A890
        FDB    $4028
        FDB    $D008
        FDB    $2078
        FDB    $B048
        FDB    $E0A0
        FDB    $F068
        FDB    $D850
        FDB    $10C0
        FDB    $3018
        FDB    $7098
        FDB    $B8C8
        FDB    $9432
        FDB    $CE56
        FDB    $21FF
*
SCODE   LDAA             0,X   ;GET CODE PER INDEX REG.
        INX                    ;
        STX            XTEMP   ;SAVE POINTER.
        CMPA          #EOT     ;IS IT END OF TRANSMISSION?
        BEQ            ENDIT   ;
        CMPA          #SPCE    ;IS IT A SPACE?
        BEQ            WRDSPC  ;
SHIFT   ASLA                   ;
        PSHA                   ;
        BCC            DITOUT  ;CARRY CLEAR?
        BSR            DAH     ;NO, SEND DAH.
ENDCHAR PULA                   ;
        CMPA          #EOC     ;IS IT END OF CHARACTER.
        BNE            SHIFT   ;
        BSR            UNISP2  ;
        LDX            XTEMP   ;RESTORE POINTER.
        BRA            SCODE   ;
*
DITOUT  BSR            DIT     ;
        BRA            ENDCHAR ;
*
UNITIM  LDAA           UTIME   ;SETS SPEED OF CODE.
UNITI   DECA                   ;
        BNE            UNITI   ;
        RTS                    ;
*
TONE    LDAA           FREQ    ;SETS FREQ. OF TONE.
FRQ1    DECA                   ;
        BNE            FRQ1    ;
        RTS                    ;
*
DIT     LDX            DITCNT  ;SETS LENGTH OF DITS.
        BRA            SAVER   ;
*
DAH     LDX            DAHCNT  ;SETS DURATION OF DAHS.
SAVER   STX            TONECT  ;ENTER HERE WITH X=LENGTH OF NOTE &
TONOUT  LDAA           DATAOUT ;UTIME SETS FREQUENCY.
        ORAA          #IDAUDIO ;
        STAA           DATAOUT ;TURN BIT ON.
        BSR            TONE    ;SET TIME BETWEEN TURN ON/OFF OF LATCH.(FREQ.)
        LDAA           DATAOUT ;
        ANDA          #$7F      ;TURN BIT OFF.
        STAA           DATAOUT ;
        BSR            TONE    ;SET TIME BETWEEN TURN ON/OFF OF LATCH.(FREQ.)
        LDX            TONECT  ;THIS CHAR. LENGTH DONE YET?
        DEX                    ;
        STX            TONECT  ;
        BNE            TONOUT  ;
UNISPC  LDX            SPACNT  ;SETS SPACE BETWEEN DITS AND DAHS.
UNSP    BSR            UNITIM  ;
        DEX                    ;
        BNE            UNSP    ;
        RTS                    ;
*
UNISP2  BSR            UNISPC  ;
        BSR            UNISPC  ;
ENDIT   RTS                    ;RETURN TO CALLER.
*
WRDSPC  BSR            UNISP2  ;WORD SPACE
        BSR            UNISP2  ;
        BSR            UNISP2  ;
        LDX            XTEMP   ;
        BRA            SCODE   ;
*                              ;
DEL2    BSR            DELONE  ;
        BSR            DELONE  ;
        RTS                    ;
*
DELONE  LDX           #ONESEC  ;SET FOR 1 SECOND.
        BRA            DELX    ;
DEL_1   LDX           #DEL1    ;SET FOR .1 SECOND.
        BRA            DELX    ;
DEL_5   LDX           #DEL5    ;
DELX    BSR            UNITIM  ;
        DEX                    ;
        BNE            DELX    ;
        RTS                    ;
*
BEEP1   LDX           #BEEPR1  ;
        JSR            SCODE   ;
        RTS                    ;
*
BEEP3   LDX           #BEEPR3  ;
        JSR            SCODE   ;
        RTS                    ;
*
INITIT  LDAA          #UTIMI   ;INIT. CODE SPEED AT UTIME.
        STAA           UTIME   ;ABOUT 20 WPM.
        LDAA          #FREQI   ;INIT. CODE TONE AT UTIME.
        STAA           FREQ    ;ABOUT 1000 HERTZ.
        LDX           #DTCTI   ;DIT COUNTER INIT VALUE.
        STX            DITCNT  ;
        LDX           #SPCNTI  ;SPACE COUNTER INIT VALUE.
        STX            SPACNT  ;
        LDX           #DHCNTI  ;DAH COUNTER INIT VALUE.
        STX            DAHCNT  ;
        LDX           #FLSHI   ;INIT ID FIRST TIME.
        STX            FLASH   ;
        LDX           #ARPLMI  ;INIT AUTO RESTORE VALUE.
        STX            ARPLMS  ;
        LDAA          #M3I     ;MIN3 INIT VALUE.
        STAA           M3INT   ;
        STAA           MIN3    ;
        LDAA          #$A5
        STAA           MEMCHK  ;
        LDAA          #FLGS0I  ;FLAGS INIT VALUE.
        STAA           FLAGS   ;
        LDAA          #$00     ;INIT DIGIT COUNTER.
        STAA           DCTR    ;
        LDAA          #FCT1    ;INIT FCTB1.
        STAA           FCTB1   ;
        LDAA          #FCT2    ;INIT FCTB2.
        STAA           FCTB2   ;
        LDAA          #FCT3    ;INIT FCTB3.
        STAA           FCTB3   ;
        LDAA          #RCNTRI  ;INIT REMINDER COUNTER.
        STAA           RCNTR   ;
        RTS                    ;
*
*
LP10    WAI                    ;
        LDX           #$F424   ;INIT INDEX WITH 1/2 SECOND.
LP20    DEX                    ;
        BNE            LP20    ;
        LDX           #$F424
LP30    DEX                    ;
        BNE            LP30    ;
        BRA            LP10    ;
*
TIMERTN LDAA           FCTB2   ;GO SEE IF TIMER ADJUST ON.
        ANDA          #TIMEADJ ;
        BEQ            TIME0   ;
TIMESET STX            $0000   ;ADD ONE TO ADDRESS 0000H
        LDAA           $01
        STAA           DATAOUT ;PUT IN LIGHTS.
TTT     RTI
*
TIME0   LDAA           FCTB1   ;CHK IF SPKR IS ON.
        ANDA          #SPKSET
        BEQ            PMTOX
        DEC            MIN3
        LDAA           MIN3
        BEQ            CHPIT
        BRA            PMTOX
CHPIT   LDAA          #SPKSET  ;TURN OFF SPEAKER.
        COMA
        ANDA           FCTB1
        STAA           FCTB1
PMTOX   DEC            PMTO16  ;DECREMENT AND TEST PMTO. VALUE
        BNE            RMIND   ;IS SET IN C_LOOP.
PMTOX1  JMP            RESTART ;RESTART MACHINE.
*
RMIND   LDAA           FLAGS   ;CHK IF ANY BLINK IS ON.
        ANDA          #BFLG
        BEQ            PLMRST
        DEC            RCNTR
        LDAA           RCNTR
        BNE            PLMRST
        LDAA           FLAGS
        ORAA          #RMDFLG
        STAA           FLAGS
*
PLMRST  LDX            ARPLMS  ;VALUE IS SET AT KDONE ROUTINE.
        DEX                    ;IF ZERO THEN SET PL MODE, CONTROLLER-
        STX            ARPLMS  ;LOCKED AND AUTO REPEATER OFF IF WANTED.
        BNE            CHKMEM
CKALK   LDAA           FCTB1   ;SET CONTROLLER LOCKED BIT.
        ORAA          #CTRLK
        STAA           FCTB1
        LDX           #ARPLMI
        STX            ARPLMS  ;
CHKMEM  LDAA           MEMCHK  ;CHK FOR CLOBBERED MEMORY.
        CMPA          #$A5
        BNE            PMTOX1
RSTMUTE LDAA           MUTECNT
        BEQ            NMIRETN
        DEC            MUTECNT ;VALUE IS SET IN IRQ RTN.
        BNE            NMIRETN
        CLR            DCTR
NMIRETN RTI
*
*
PCODE   FCB    $68
        FCB    $FF
*
BEEP    FCB    $21
        FCB    $40
        FCB    $40
        FCB    $FF
BEEPR1  FCB    $21
        FCB    $40
        FCB    $FF
BEEPR3  FCB    $21
        FCB    $40
        FCB    $21
        FCB    $40
        FCB    $21
        FCB    $40
        FCB    $FF
*
RTN4    JMP            RESTORE ;
*
ID_DN10 LDAB          #$0A     ;INCREMENT THE FREQ COUNTER +10.
        BRA            ID_DNB  ;
ID_DN5  LDAB          #$05     ;INCREMENT THE FREQ COUNTER +5.
ID_DNB  BSR            ID_DWN  ;
        DECB                   ;
        BNE            ID_DNB  ;
        BRA            ID_DNA  ;
ID_DN1  BSR            ID_DWN  ;INCREMENT THE FREQ COUNTER +1.
        BRA            ID_DNA  ;
ID_DWN  LDAA           FREQ    ;INCREMENT THE FREQ COUNTER.
        INCA                   ;
        STAA           FREQ    ;
        RTS                    ;
ID_DNA  BRA            RTN4    ;
*
ID_UP10 LDAB          #$0A     ;DECREMENT THE FREQ COUNTER -10.
        BRA            ID_UPB  ;
ID_UP5  LDAB          #$05     ;DECREMENT THE FREQ COUNTER -5.
ID_UPB  BSR            ID_UP   ;
        DECB                   ;
        BNE            ID_UPB  ;
        BRA            ID_UPA  ;
ID_UP1  BSR            ID_UP   ;DECREMENT THE FREQ COUNTER -1.
        BRA            ID_UPA  ;
ID_UP   LDAA           FREQ    ;DECREMENT THE FREQ COUNTER.
        DECA                   ;
        STAA           FREQ    ;
        RTS                    ;
ID_UPA  BRA            RTN4    ;
*
SP_DN10 LDAB          #$0A     ;INCREMENT THE UTIME COUNTER +10.
        BRA            SP_DNB  ;
SP_DN5  LDAB          #$05     ;INCREMENT THE UTIME COUNTER +5.
SP_DNB  BSR            SP_DWN  ;
        DECB                   ;
        BNE            SP_DNB  ;
        BRA            SP_DNA  ;
SP_DN1  BSR            SP_DWN  ;INCREMENT THE UTIME COUNTER +1.
        BRA            SP_DNA  ;
SP_DWN  LDAA           UTIME   ;INCREMENT THE UTIME COUNTER.
        INCA                   ;
        STAA           UTIME   ;
        RTS                    ;
SP_DNA  BRA            RTN4    ;
*
SP_UP10 LDAB          #$0A     ;DECREMENT THE UTIME COUNTER -10.
        BRA            SP_UPB  ;
SP_UP5  LDAB          #$05     ;DECREMENT THE UTIME COUNTER -5.
SP_UPB  BSR            SP_UP   ;
        DECB                   ;
        BNE            SP_UPB  ;
        BRA            SP_UPA  ;
SP_UP1  BSR            SP_UP   ;DECREMENT THE UTIME COUNTER -1.
        BRA            SP_UPA  ;
SP_UP   LDAA           UTIME   ;DECREMENT THE UTIME COUNTER.
        DECA                   ;
        STAA           UTIME   ;
        RTS                    ;
SP_UPA  BRA            RTN4    ;
*
ICT     LDAA           M3INT   ;INCR CHOPPER BY 30 SECONDS.
        BSR            PLUSA   ;
        STAA           M3INT   ;
        BRA            RTN3    ;
*
PLUSX   LDAB          #$00
PXAGN   INX                    ;INCR INDEX REG.
        DECB                   ;DECR B-REG.
        BNE            PXAGN   ;
        RTS                    ;
*
PLUSA   LDAB          #$1E     ;DECIMAL 30.
APLUS   INCA                   ;
        DECB                   ;
        BNE            APLUS   ;
        RTS                    ;
*
DCT     LDAA           M3INT   ;DECR CHOPPER BY 30 SECONDS.
        BSR            SUB_A   ;
        STAA           M3INT   ;
        BRA            RTN3    ;
*
SUBX    LDAB          #$00
MXAGN   DEX                    ;
        DECB                   ;
        BNE            MXAGN   ;
        RTS                    ;
SUB_A   LDAB          #$1E     ;30 DECIMAL.
MINUSA  DECA                   ;
        DECB                   ;
        BNE            MINUSA  ;
        RTS                    ;
RTN3    JMP            RESTORE ;
*
IDIT10  LDAB          #$0A     ;INCREMENT THE DIT COUNTER +10.
        BRA            IDITB   ;
IDIT5   LDAB          #$05     ;INCREMENT THE DIT COUNTER +5.
IDITB   BSR            IDIT    ;
        DECB                   ;
        BNE            IDITB   ;
        BRA            IDITA   ;
IDIT1   BSR            IDIT    ;INCREMENT THE DIT COUNTER +1.
        BRA            IDITA   ;
IDIT    LDX            DITCNT  ;INCREMENT THE DIT COUNTER.
        INX                    ;
        STX            DITCNT  ;
        RTS                    ;
IDITA   BRA            RTN3    ;
*
ISPC10  LDAB          #$0A     ;INCREMENT THE SPACE COUNTER +10.
        BRA            ISPCB   ;
ISPC5   LDAB          #$05     ;INCREMENT THE SPACE COUNTER +5.
ISPCB   BSR            ISPC    ;
        DECB                   ;
        BNE            ISPCB   ;
        BRA            ISPCA   ;
ISPC1   BSR            ISPC    ;INCREMENT THE SPACE COUNTER +1.
        BRA            ISPCA   ;
ISPC    LDX            SPACNT  ;INCREMENT THE SPACE COUNTER.
        INX                    ;
        STX            SPACNT  ;
        RTS                    ;
ISPCA   BRA            RTN3    ;
*
IDAH10  LDAB          #$0A     ;INCREMENT THE DAH COUNTER +10.
        BRA            IDAHB   ;
IDAH5   LDAB          #$05     ;INCREMENT THE DAH COUNTER +5.
IDAHB   BSR            IDAH    ;
        DECB                   ;
        BNE            IDAHB   ;
        BRA            IDAHA   ;
IDAH1   BSR            IDAH    ;INCREMENT THE DAH COUNTER +1.
        BRA            IDAHA   ;
IDAH    LDX            DAHCNT  ;INCREMENT THE DAH COUNTER.
        INX                    ;
        STX            DAHCNT  ;
        RTS                    ;
IDAHA   BRA            RTN3    ;
*
DDIT10  LDAB          #$0A     ;DECREMENT THE DIT COUNTER -10.
        BRA            DDITB   ;
DDIT5   LDAB          #$05     ;DECREMENT THE DIT COUNTER -5.
DDITB   BSR            DDIT    ;
        DECB                   ;
        BNE            DDITB   ;
        BRA            DDITA   ;
DDIT1   BSR            DDIT    ;DECREMENT THE DIT COUNTER -1.
        BRA            DDITA   ;
DDIT    LDX            DITCNT  ;DECREMENT THE DIT COUNTER.
        DEX                    ;
        STX            DITCNT  ;
        RTS                    ;
DDITA   BRA            RTN2    ;
*
DSPC10  LDAB          #$0A     ;DECREMENT THE SPACE COUNTER -10.
        BRA            DSPCB   ;
DSPC5   LDAB          #$05     ;DECREMENT THE SPACE COUNTER -5.
DSPCB   BSR            DSPC    ;
        DECB                   ;
        BNE            DSPCB   ;
        BRA            DSPCA   ;
DSPC1   BSR            DSPC    ;DECREMENT THE SPACE COUNTER -1.
        BRA            DSPCA   ;
DSPC    LDX            SPACNT  ;DECREMENT THE SPACE COUNTER.
        DEX                    ;
        STX            SPACNT  ;
        RTS                    ;
DSPCA   BRA            RTN2    ;
*
DDAH10  LDAB          #$0A     ;DECREMENT THE DAH COUNTER -10.
        BRA            DDAHB   ;
DDAH5   LDAB          #$05     ;DECREMENT THE DAH COUNTER -5.
DDAHB   BSR            DDAH    ;
        DECB                   ;
        BNE            DDAHB   ;
        BRA            DDAHA   ;
DDAH1   BSR            DDAH    ;DECREMENT THE DAH COUNTER -1.
        BRA            DDAHA   ;
DDAH    LDX            DAHCNT  ;DECREMENT THE DAH COUNTER.
        DEX
        STX            DAHCNT
        RTS
DDAHA   NOP
*
RTN2    JMP            RESTORE
*
S10     LDAA          #S_SLC
        ORAA           FCTB1
        STAA           FCTB1
        BRA            RTN2
S11     LDAA          #S_GRP
        ORAA           FCTB1
        STAA           FCTB1
        BRA            RTN2
SF3     CLR            FCCTR
        LDAA          #FL3
        ORAA           OUT
        STAA           OUT     ;FOR BLINK
        LDAA          #FL4
        BRA            SETREG
SF4     LDAA          #FL4
        BRA            SETREG
SF5     LDAA          #FL5
        BRA            SETREG
SF6     LDAA          #FL6
SETREG  BSR            SETR1
        JMP            RTN2
SETR1   ORAA           DATAOUT
        STAA           DATAOUT
        RTS
*
RF1     LDAA          #FL1
        COMA
        BRA            RSTREG
RF2     LDAA          #FL2
        COMA
        BRA            RSTREG
RF3     LDAA          #FL3
        COMA
        BRA            RSTREG
RF4     LDAA          #FL4
        COMA
        BRA            RSTREG
RF5     LDAA          #FL5
        COMA
        BRA            RSTREG
RF6     LDAA          #FL6
        COMA
RSTREG  BSR            RSTRG1
        JMP            RTN2
RSTRG1  ANDA           DATAOUT
        STAA           DATAOUT
        RTS
*
RTN5    JMP            RESTORE
*THIS GROUP SETS BITS IN FCTB3.
RSPON   LDAA          #$80
        BRA            SFCTB3  ;
SROM    LDAA          #SNDROM  ;
SFCTB3  ORAA           FCTB3   ;
        STAA           FCTB3   ;
        BRA            RTN5    ;
*THIS GROUP RESETS BITS IN FCTB3.
RALOCK  LDAA           FCTB3   ;RESET AUTO-LOCKUP.
        ANDA          #$F7
        BRA            RFCTB3  ;
RSPOFF  LDAA           FCTB3   ;RESPONSE OFF.
        ANDA          #$7F
RFCTB3  STAA           FCTB3   ;
        JMP            RESTORE ;
*THIS GROUP SETS BITS IN FCTB1.
S17     LDAA          #CTRLK   ;
        BRA            SFCTB1  ;
SFCTB1  ORAA           FCTB1   ;
        STAA           FCTB1   ;
        JMP            RETURN1 ;
RETURN2 CLR            FCCTR   ;
        JMP            RESTORE ;
*THIS GROUP RESETS BITS IN FCTB1.
R11     LDAA           FCTB1   ;
        ANDA          #$FD
        BRA            RFCTB1  ;
R10     JSR            M_WAIT
        LDAA           FCTB1   ;
        ANDA          #$FE
        BRA            RFCTB1  ;
R14     LDAA           FCTB1   ;
        ANDA          #$EF
        BRA            RFCTB1  ;
R16     LDAA           FCTB1   ;TURN OFF REPEATER.
        ANDA          #$BF
        STAA           FCTB1   ;
        JMP            RESTORE
KOFF    LDAA           FCTB1
        ANDA          #$FB
        BRA            RFCTB1
R17     LDAA           FCTB1
        ANDA          #$7F
RFCTB1  STAA           FCTB1
RETURN1 JMP            RESTORE
*
FRCRST  JMP            RESTART
*
*SET BITS IN FCTB2.
*
S24     LDAA          #P_AUX1
        ORAA           FCTB2
        STAA           FCTB2
        BRA            RETURN1
S23     LDAA          #P_AUX2
        ORAA           FCTB2
        STAA           FCTB2
        BRA            RETURN1
ADJ_ON  LDAA          #TIMEADJ ;SET TIME ADJUST FUNCTION
        ORAA           FCTB2
        STAA           FCTB2
        JMP            LP10
*RESET BITS IN FCTB2.
PORRST  LDAA           FCTB2
        ANDA          #$7F
        STAA           FCTB2
        BRA            RETURN1
MOFF    LDAA           FCTB2
        ANDA          #$BF
        STAA           FCTB2
        BRA            RETURN1
TROCD   LDAA           FCTB2
        ORAA          #$02
SFCTB2  STAA           FCTB2
        BRA            RETURN1
TROTD   LDAA           FCTB2
        ANDA          #$FD
RFCTB2  STAA           FCTB2
        BRA            RETURN1
RNM     JSR            INITIT  ;GO INIT EVERYTHING BUT DO NOT
        LDAA           FCTB2   ;
        ANDA          #$7F     ;TURN OFF 'P' FOR POR.
        STAA           FCTB2   ;PUT IT BACK.
        JMP            RESTORE ;
*
*
        ORG     $FFF8
*
MI      FDB     IRQ
SWI     FDB     RESTART
NMI     FDB     TIMERTN
RESET   FDB     RESTART
*
        ORG     $FB00
*
FILL2   FDB     $FFFF,$FFFF,$FFFF,$FFFF
        END
