;
;             "soft2812.txt" ;    WS2812
;
    .cseg
 test2812:
         ldiw x,point0
        clr tmp0 ;   0
        ser tmp1 ; 255
        ldi tmp2,128 ; 128
;-------------- 0 : R
         st x+,tmp0 ; g
         st x+,tmp1 ; r
         st x+,tmp0 ; b
;-------------- 1 : G
         st x+,tmp1 ; g
         st x+,tmp0 ; r
         st x+,tmp0 ; b
;-------------- 2 : B
         st x+,tmp0 ; g
         st x+,tmp0 ; r
         st x+,tmp1 ; b
;-------------- 3 : R+G = Y
         st x+,tmp2 ; g
         st x+,tmp2 ; r
         st x+,tmp0 ; b
;-------------- 4 : G+B = ?
         st x+,tmp2 ; g
         st x+,tmp0 ; r
         st x+,tmp2 ; b
;-------------- 5 : R+B = CY
         st x+,tmp0 ; g
         st x+,tmp2 ; r
         st x+,tmp2 ; b
;-------------- 6 : W50%
         st x+,tmp2 ; g
         st x+,tmp2 ; r
         st x+,tmp2 ; b
;-------------- 7 : W
         st x+,tmp1 ; g  
         st x+,tmp1 ; r   
         st x+,tmp1 ; b   
      rcall mass_trm ;    
;--------------------------------------------
;      XOR 
        ldiw x,hass_dat_b
        ldi tmp0,has_mask_b
        st x,tmp0
        ldiw x,hass_dat_r
        ldi tmp0,has_mask_r
        st x,tmp0
        ldiw x,hass_dat_g
        ldi tmp0,has_mask_g
        st x,tmp0
;-------------------------------------------------------
       ldi tmp5,dev_spt0
       sts cnt_30s,tmp5
       ldi tmp5,dev_spt1
       sts cnt_5m,tmp5 ;   
			            ;    sleep
;-------------------------------------------------------
 remark:
        start_tc0 ;   0  
 wile_mark:
       sbrs flags,mark_h
       rjmp wile_mark ;   
       clr flags ;  
			     ; (     mark_t0.txt)
;-------------------------------------------------------
 waitt:
    lds tmp5,cnt_30s
    dec tmp5
    brne pot_0
    ldi tmp5,dev_spt0
    sts cnt_30s,tmp5
    lds tmp5,cnt_5m
    dec tmp5
    brne pot_1
    cli
     rjmp prep_dream ;      prep_dream
 pot_0:
    sts cnt_30s,tmp5
    rjmp work
 pot_1:
    sts cnt_5m,tmp5
;-------------------------------------------------------
 work:
      hsaa_msst hass_dat_b ;     XOR/ 
			rcall hass_zt ;   
      hsaa_msst hass_dat_r
      rcall hass_zt ;   
      hsaa_msst hass_dat_g
      rcall hass_zt ;   
 wario:
      ldiw x,point7
      ld tmp0,x+
      push tmp0
      ld tmp0,x+
      push tmp0
      ld tmp0,x+
      push tmp0
      ldi tmp0,3
      and r8,tmp0 ;    
      ldiw x,point6
     rcall stepp7
      ldiw x,point5
     rcall stepp7
      ldiw x,point4
     rcall stepp7
      ldiw x,point3
     rcall stepp7
      ldiw x,point2
     rcall stepp7
      ldiw x,point1
     rcall stepp7
      ldiw x,point0
     rcall stepp7
       pop r4
       pop r3
       pop r2
      ldiw x,point0
     rcall stepp8 step:
     rcall mass_trm ;    
    rjmp remark
;
 stepp7:
      ld r2,x+
      ld r3,x+
      ld r4,x+
 stepp8:
      ld r5,x+
      ld r6,x+
      ld r7,x+
      sbrc r8,Gy_f
      mov r5,r2
      sbrc r8,Ry_f
      mov r6,r3
      sbrc r8,Ry_f
      mov r7,r4
      st -x,r7
      st -x,r6
      st -x,r5
    ret
;