;
;    sfi_ktp.txt      
;
;--------------------------------------------------------------------
; -------------------------------------
;   
;
;
;
;
;
; -------------------------------------
;    
;
cliner
      movlw (0x6F-0x20)
      movwf zntmp
      movlw 0x20
      movwf FSR
      clrw
clins
      movwf INDF
      incf FSR,f
      decfsz zntmp,f
      goto clins
; -------------------------------------
;
    clrf tmm_h_adj
    clrf tmm_m_adj
    movlw kd_pos1
    movwf FSR
    movlw .10
    movwf cnt_zum
    movlw 0xFF
tlp0
    movwf INDF
    incf FSR,f
    decfsz cnt_zum,f
    goto tlp0 ; - "  "
    call prepare
    call w_ksda
    bsf port_ksd,L_INH ;  
    movlw .255
    movwf cnt_zum+2 ;   
    bsf tmm_flags,tmm_zud ;   
    call zuumm ;  
base_timsek
  movlw sni_mask
  movwf FSR
  movlw 1<<L_Sn1
  movwf INDF
  incf FSR,f
  movlw 1<<L_Sn2
  movwf INDF
  incf FSR,f
  movlw 1<<L_Sn3
  movwf INDF ;     
;    /   
tik_taks
  bcf tmm_flags,tmm_apdnf ;   
  movlw 2
  movwf mt_tmp
  clrw
  xorwf tmm_h_adj,w
  btfsc STATUS,Z
  decf mt_tmp,f
  clrw
  xorwf tmm_m_adj,w
  btfsc STATUS,Z
  decf mt_tmp,f
  movf tmm_h_adj,w
  movwf tmm_hors
  movf tmm_m_adj,w
  movwf tmm_min
  clrf tmm_sek ;     
  tstf mt_tmp
  btfsc STATUS,Z ; tmm_apdnf = 0,   
	       ;   0
	goto tik_tak ;    
	       ;  
   bsf tmm_flags,tmm_apdnf ;  ,
	       ;     (tmm_apdnf = 1)
tik_tak
     clrf TMR1L
     clrf TMR1H
     bsf TMR1H,7
     bcf PIR1,TMR1IF ;   -
     bsf INTCON,GIE ;  
     call dabuf_tmmw
     call prepare
     call w_ksda ;    
             ;  "  ,,  "
;----------------------------------------------------------
;
;      
;
sentest0
     btfsc tmm_flags,tmm_tmoff
      call zuumm ;
     movlw sni_mask
     movwf FSR ;     
     movf PORTB,w
     movwf sni_buf ;     sni_buf
     andwf INDF,w
    btfsc STATUS,Z
      goto sn1_0_work ;    sn1_0_work
     incf FSR,f
     movf sni_buf,w
     andwf INDF,w
    btfsc STATUS,Z
      goto sn2_0_work ;    sn2_0_work
     incf FSR,f
     movf sni_buf,w
     andwf INDF,w
    btfsc STATUS,Z
     goto sn3_0_work ;    sn3_0_work
      goto sentest0 ;    
;
;----------------------------------------------------------
;
; L_Sn1 - /
;    tmm_flags.tmm_dissn=1
;
;
sn1_0_work
        call wit_h00
       btfss STATUS,Z
      goto sentest0 ; =1 >> 
    btfsc tmm_flags,tmm_tmoff ;    tmm_flags.tmm_tmoff=1
   goto sentest0
      btfsc tmm_flags,tmm_dissn
     goto count_off ;  tmm_flags.tmm_dissn=1  
count_on
       bsf tmm_flags,tmm_dissn ;   tmm_flags.tmm_dissn=1
       bsf T1CON,TMR1ON ;   - 
      goto scasend ;      
count_off
       bcf tmm_flags,tmm_dissn ;   tmm_flags.tmm_dissn=0
       bcf T1CON,TMR1ON ;   - 
scasend
    call wit_h01 ;   
   goto sentest0
;
;----------------------------------------------------------
;
;
; L_Sn2    tmm_flags.tmm_dissn=1
; tmm_flags,tmm_apdnf=1  tmm_flags.tmm_tmoff=1
;       
;tmm_flags,tmm_dfsf=1
; tmm_flags,tmm_apdnf=1  tmm_flags.tmm_tmoff=0 
; "    "
; tmm_flags,tmm_apdnf=0    
;( )   ( )
;
sn2_0_work
        call wit_h00
        btfss STATUS,Z
      goto sentest0 ; =1 >> 
     btfsc tmm_flags,tmm_dissn
    goto sentest0 ;    tmm_flags.tmm_dissn=1
      call wit_h01 ;   
    bcf tmm_flags,tmm_tmoff
   goto tik_taks ;       
;
;----------------------------------------------------------
; L_Sn3    tmm_flags.tmm_dissn=1
;      
;
sn3_0_work
        call wit_h00
        btfss STATUS,Z
      goto sentest0 ; =1 >> 
       btfsc tmm_flags,tmm_dissn
    goto sentest0 ;    tmm_flags.tmm_dissn=1
       btfsc tmm_flags,tmm_tmoff ;
    goto sentest0 ;   tmm_flags.tmm_tmoff=1
     call wit_h01 ;   
;
;----------------------------------------------------------
;
;     
;
nabor
     call dabuf_tmmu
     call prepare
     call w_ksda ;    
             ;  " -,--- "
;
;
;----------------------------------------------------------
;
;    
;   
;
sentest1
     movlw sni_mask
     movwf FSR ;     
     movf PORTB,w
     movwf sni_buf ;     sni_buf
     andwf INDF,w
    btfsc STATUS,Z
      goto sn1_1_work ;    sn1_1_work
     incf FSR,f
     movf sni_buf,w
     andwf INDF,w
    btfsc STATUS,Z
      goto sn2_1_work ;    sn2_1_work
     incf FSR,f
     movf sni_buf,w
     andwf INDF,w
    btfsc STATUS,Z
     goto sn3_1_work ;    sn3_1_work
      goto sentest1 ;    
;
;----------------------------------------------------------
;
;
;  L_Sn1 +1    0,2 
;    0,2    
; 0,1   
;
sn1_1_work
        call wit_h00
        btfss STATUS,Z
       goto sentest1 ; 
        call adj_inc
         call dabuf_tmmu
          call prepare
           call w_ksda ;    
             ;  " -,--- "
        movlw .6
        movwf cnt_zum+3
wait_sniw
        call tm_azvp
        movf PORTB,w
       andwf INDF,w
       btfss STATUS,Z
      goto w_ofinc
       decfsz cnt_zum+3,f
        goto wait_sniw ;      
waitinc
      call adj_inc
       call dabuf_tmmu
        call prepare
         call w_ksda ;    
             ;  " -,--- "
      movlw 1
      movwf cnt_zum+3
witc
      movlw .100
      movwf cnt_zum+1
      clrf cnt_zum
      call l_tazp
      decfsz cnt_zum+3,f
     goto witc ; 0,128S/inc
       movf PORTB,w
       andwf INDF,w
       btfss STATUS,Z
      goto w_ofinc
     goto waitinc ; ,   
w_ofinc
     call tm_azvp
     movf PORTB,w
      andwf INDF,w
       btfsc STATUS,Z
      goto w_ofinc
     goto sentest1

;
;----------------------------------------------------------
;
;
;  L_Sn2 -1    0,2 
;    0,2    
; 0,1   
;
sn2_1_work
        call wit_h00
        btfss STATUS,Z
        goto sentest1 ; 
        call adj_dec
        call dabuf_tmmu
          call prepare
           call w_ksda ;    
             ;  " -,--- "
        movlw .6
        movwf cnt_zum+3
wait_sndw
        call tm_azvp
        movf PORTB,w
       andwf INDF,w
       btfss STATUS,Z
      goto w_ofdec
       decfsz cnt_zum+3,f
        goto wait_sndw ;      
waitdec
      call adj_dec ;********************
       call dabuf_tmmu
        call prepare
         call w_ksda ;    
             ;  " -,--- "
      movlw 1
      movwf cnt_zum+3
witdc
      movlw .100
      movwf cnt_zum+1
      clrf cnt_zum
      call l_tazp
      decfsz cnt_zum+3,f
     goto witdc ; 0,128S/dec
       movf PORTB,w
       andwf INDF,w
       btfss STATUS,Z
      goto w_ofdec
     goto waitdec ; ,   
w_ofdec
     call tm_azvp
     movf PORTB,w
      andwf INDF,w
       btfsc STATUS,Z
      goto w_ofdec
     goto sentest1
;
;----------------------------------------------------------
;
;
;  L_Sn3    
;        
;   
;   base_timsek
;
sn3_1_work
       call wit_h00
       btfss STATUS,Z
      goto sentest1 ; 
      call wit_h01 ;   
      goto tik_taks ;   
;
;----------------------------------------------------------
;