;
;         "ss_ext_disp.txt"     
;
;         
;  
dp_coldstart:
  ldwi x,dp_shaps ;  
  ldi tmp0,4
  st x+,tmp0 ;     dp_cntk=4
  mov dp_cntk,tmp0
  ldi tmp0,dp_mask
  st x+,tmp0 ;     dp_masbu=0b11110111
  mov dp_masbu,tmp0
  clr dp_idx
  st x,dp_idx ;     dp_idx=0
;
;     
    ldwi y,dp_rdbf ;      
    ldi tmp0,low (dp_maxj)
    ldi tmp1,high (dp_maxj)
    ser r18 ;  0xFF = "  "
    st y+,r18 ; A0
    st y+,r18 ; A1
    st y+,r18 ; A2
    st y+,r18 ; A3
    st y+,tmp0
    st y+,tmp1 ;  a0
    st y+,tmp0
    st y+,tmp1 ;  a1
    st y+,tmp0
    st y+,tmp1 ;  a2
    st y+,tmp0
    st y+,tmp1 ;  a3
    in how_sreg_d,SREG ;   dp_rwrbu
   rcall dp_rwrbu ;      
;---------------------------
;    
   ldwi y,net_buf
   sts net_fsr,yl
   sts (net_fsr+1),yh
   ldi tmp0,8
   sts net_cnt,tmp0
;
;---------------------------
;   (  )    USART
;
dp_works:
  in tmp0,TCCR1B
  sbr tmp0,(1<<CS11)
  out TCCR1B,tmp0
  lds dp_xbuf,dp_datbuf ;   dp_xbuf
  sei ;  
;-------------------------------------------------------
sinhro2:
   sbis t_mk_port,t_mk_RxD
   rjmp sinhro2
   ldi tmp0,0xFF
 l_sinhro2:
    sbis t_mk_port,t_mk_RxD
     rjmp sinhro2
      dec tmp0
     brne l_sinhro2
;-------------------------------------------------------
   cli
  sbi UCSRB,RXEN ;  
  sbi UCSRB,TXEN ;  
   sei
;-------------------------------------------------------
;
;
;---------------------------
;     -   
;  -    
;       
;
scanss:
  nop
  sbrs dp_flags,netdbu
  rjmp scanss
  sbrc dp_flags,dp_exch
  rjmp scanss
  rcall crck ;  CRC
  sbrc dp_flags,er_crc;      CRC
  rcall ptr_ecrc ;     E-CRC 25% 
  ldwi y,dp_rdbf
  ldwi x,net_buf
  ld tmp0,x+
  ld tmp1,x+
  st y+,tmp0
  st y+,tmp1 ; A0&A1
  ld tmp0,x+
  ld tmp1,x+
  st y+,tmp0
  st y+,tmp1 ; A2&A3
  ld tmp0,x+
  ld tmp1,x+
  st y+,tmp0
  st y+,tmp1 ; uri A0
  st y+,tmp0
  st y+,tmp1 ; uri A1
  st y+,tmp0
  st y+,tmp1 ; uri A2
  st y+,tmp0
  st y+,tmp1 ; uri A3
reprint:
  cli
  ldi tmp0,(0xFF - (1<<netdbu))
  and dp_flags,tmp0 ; netdbu=0
  ldi tmp0,(1<<dp_exch)
  or dp_flags,tmp0 ; dp_exch=1
  sei
  rjmp scanss
;
;---------------------------
;
;    
;
ptr_ecrc:
   ldwi x,net_buf
   ldi tmp0,0x39
   st x+,tmp0 ; C
   ldi tmp0,0x50
   st x+,tmp0 ; r
   ldi tmp0,0x39
   st x+,tmp0 ; C
   ldi tmp0,0x79
   st x+,tmp0 ; E
   ldi tmp0,0xDC
   st x+,tmp0
   ldi tmp0,0x05 ; 1500
   st x+,tmp0
   clr tmp0
   st x+,tmp0
   st x,tmp0 ;   
   ret
;
;---------------------------
;