MULTIPLEXER

;*****************************************************************************
;* MODULE-MUX-V00.ASM
;*****************************************************************************
;* NAME ...................: MUX
;* VERSION ................: V00
;* PURPOSE ................: CONTROL ANALOG MULTIPLEXOR SELECT LINES
;* PROCEDURE ..............: SET/RESET 2 BITS IN PIA0
;* NOTES ..................: 
;* COLOR COMPUTER 3 SERVICE MANUAL PP 9, 
;* FF01:3 SEL 1 LSB OF THE TWO ANALOG MUX SELECT LINES
;* FF03:3 SEL 2 MSB OF THE TWO ANALOG MUX SELECT LINES
;* SNDEN SEL2 SEL1 SELECTS
;* 0     X    X    1-BIT AUDIO
;* 1     0    0    6-BIT DAC   JOYSTICK 0
;* 1     0    1    CASSETTE    JOYSTICK 1
;* 1     1    0    CARTRIDGE   JOYSTICK 2
;* 1     1    1    NO SOUND    JOYSTICK 3
;*****************************************************************************
PIA0AD:     equ    $FF00      ; PIA 0 PORT A DATA
PIA0AC:     equ    $FF01      ; PIA 0 PORT A CONTROL
PIA0BD:     equ    $FF02      ; PIA 0 PORT B DATA
PIA0BC:     equ    $FF03      ; PIA 0 PORT B CONTROL

MUXSEL:     rmb   1           ; MUX SELECT INPUT

MUX:        pshs  A,B,X,CC    ; SAVE REGISTERS BEFORE WE MESS WITH THEM
            lda   PIA0AC      ; GET CURRENT STATE OF PIA0 PORT A CONTROL
            ldb   PIA0BC      ; GET CURRENT STATE OF PIA0 PORT B CONTROL

            ldx   MUXSEL      ; ENTER WITH X FOR MUX CHOICE
            cmpx  #0          ; MUXSEL equal 0?
            beq   SELDAC      ; 6-BIT DAC SOUND / JOYSTICK AXIS 0
            cmpx  #1          ; MUXSEL equal 1?
            beq   SELCASS     ; CASSETTE SOUND / JOYSTICK AXIS 1
            cmpx  #2          ; MUXSEL equal 2?
            beq   SELCART     ; CART SOUND / JOYSTICK AXIS 2
            cmpx  #3          ; MUXSEL equal 3?
            beq   SELNONE     ; NO SOUND / JOYSTICK AXIS 3
            puls  A,B,X,CC    ; MUXSEL EQUAL SOMETHING ELSE? JUST RETURN

SELDAC:     anda  #%11111011  ; SEL LSB = 0
            andb  #%11111011  ; SEL MSB = 0
            bra   ENDMUX      ; GO SET THEM

SELCASS:    ora   #%00000100  ; SEL LSB = 1
            andb  #%11111011  ; SEL MSB = 0
            bra   ENDMUX      ; GO SET THEM

SELCART:    anda  #%11111011  ; SEL LSB = 0
            orb   #%00000100  ; SEL MSB = 1
            bra   ENDMUX      ; GO SET THEM

SELNONE:    ora   #%00000100  ; SEL LSB = 1
            orb   #%00000100  ; SEL MSB = 1
                              ; FALL THROUGH TO
ENDMUX:     sta   PIA0AC      ; SAVE OUT MODIFIED SEL LSB
            stb   PIA0BC      ; SAVE OUT MODIFIED SEL MSB
            puls  A,B,X,CC,PC ; AND DONE

;*****************************************************************************
;* END OF MODULE-MUX-V00.ASM
;*****************************************************************************

RTS

Return to Tandy Color Computer