It's this a viable options of reading encoder AND the others buttons ?
Code:
Main:
;==============
;reading buttons on line 0 (pseudo-encoder)
    PortB.5 = 0
    newState = PortA & %00000111
    PortB.5 = 1
    If newState <> 7 THEN
        If newState <> oldState THEN
              
            Select Case oldState
                Case 3
                If NewState = 6 THEN 
                dir=up         
                portb.0 = 1
                endif
                If NewState = 5 THEN 
                dir=dn
                portb.1 = 1
                endif
                
                Case 5
                If NewState = 3 THEN 
                dir=up         
                portb.0 = 1
                endif      
                If NewState = 6 THEN 
                dir=dn
                portb.1 = 1
                endif
                
                Case 6
                If NewState = 5 THEN 
                dir=up
                portb.0 = 1
                endif        
                If NewState = 3 THEN 
                dir=dn
                portb.1 = 1
                endif
            END SELECT      
            oldState = newState
          Pause 100
        ENDIF
    ENDIF
;==============
;reading buttons on line 1
    Porta.4 = 0
    status_2 = PortA & %00000111
    Porta.4 = 1
    select case status_2
                case 3
                gosub trackDn
                case 5
                gosub mute
                case 6
                gosub trackUp
    end select
;==============
;reading buttons on line 2    
    Porta.3 = 0
    status_3 = PortA & %00000111
    Porta.3 = 1
    select case status_3
                case 3
                gosub volDn
                case 5
                gosub volUp
                case 6
                gosub Sursa
    end select                           
Goto Main