;
;
;          "kitchen.txt" 
;     
;      
;     :   
;
;
;   " .  " (prefekt,#(8<<4)
;  " :  " (prefekt,#(9<<4)
;   ,   
;    bufust2:bufust0,
;    setibu2:setibu0
;  tionn "  '' " ("  ")
;  talarm "   "
;   = 0xD6
;  "" = 0xED
;---------------------------------------------------------------
;   "  " - " .  "
; ( ""   "?"   '?         ')
;   8
;
 kitchen1:
    mov left_bp+1,#high(tmgluks)
    mov left_bp,#low(tmgluks)
    mov right_bp+1,#high(glokinp)
    mov right_bp,#low(glokinp)
    mov main_bp+1,#high(kitchen1)
    mov main_bp,#low(kitchen1)
    mov stabl+1,#high(subrus) ;      
    mov stabl,#low(subrus) ;       
    mov target+1,#high(kitchen2)
    mov target,#low(kitchen2)
    mov retter+1,#high(kit1_cls)
    mov retter,#low(kit1_cls)
    mov prefekt,#(8<<4) ;    0x00-0x0F (  masktbl)
                 ;       
                 ;        masktbl8
    ptints str9,frame0 ;   frame1+refram   str9
                  ; " .  "
    setb fmnk ; "" 
   lo_sbuf sp_buf2 
    mov setibu0,bufust0
    mov setibu1,bufust1
    mov setibu2,bufust2 ;     
    mov bufos_f,#0x4D ; 'M'   16 (F)
 reust:
    lcall viev_sb ; in file "sektim.txt"
    ljmp open_cor ; in file "datclock.txt"
;---------------------------------------------------------------
;   "  "( ""   
;      0(?) frame1   )
;     bufust2:bufust0  
;
 kit1_cls:
       ljmp re_baksp ; in file "datclock.txt"    
;---------------------------------------------------------------
;   "  " - " :  "
; ( ""   "?"   ' .  ')
;   9
;
 kitchen2:
    mov left_bp+1,#high(kitchen1)
    mov left_bp,#low(kitchen1)
    mov right_bp+1,#high(glokinp)
    mov right_bp,#low(glokinp)
    mov main_bp+1,#high(kitchen2)
    mov main_bp,#low(kitchen2)
    mov stabl+1,#high(subrus) ;      
    mov stabl,#low(subrus) ;       
    mov target+1,#high(u_kits1)
    mov target,#low(u_kits1)
    mov retter+1,#high(u_kits2)
    mov retter,#low(u_kits2)
    mov prefekt,#(9<<4) ;    0x00-0x0F (  masktbl)
                 ;       
                 ;        masktbl9
    ptints str10,frame0 ;   frame1+refram   str10
                  ; " :  "
    clr fmnk ; ""   
    lcall confint2 ; (in file "semetr.txt")
		              ;    /2
    lcall re_kodes ;      
 hast8:
    mov bufust0,setibu0
    mov bufust1,setibu1
    mov bufust2,setibu2 ;    
    mov bufos_1,#0xD6 ;   ""   1 frame1
    mov bufos_f,#0x20 ;   ""   16 (F)
   ljmp open_cor ; in file "datclock.txt"
;---------------------------------------------------------------
;   "  "
;  ""   
;      0(?) frame1   
;  tionn=1 
;  talarm=1 
;
 u_kits2:
       jnb tionn,ekit_cls ;     
       ljmp step4 ;      
  ekit_cls:
       jnb talarm,ekit_cls1 ;    talarm=0
       ljmp step4
  ekit_cls1:
        ptints str9,frame0 ;   frame1+refram   str9
                  ; ' .  '
         ljmp re_baksp2 ; in file "datclock.txt"
;---------------------------------------------------------------
;   / (  TR2)
;  ""   
;      0(?) frame1   
;  tionn=0   
;  tionn=1   
;  talarm=1 
;
 u_kits1:
    jnb talarm,kit_trig ;    talarm=0
    ljmp step4 ;     ...?
  kit_trig:
       jbc tionn,kit_off
   kit_on:
        setb TR0
        setb tionn
        ljmp step4
  kit_off:
        clr TR0
        ljmp step4
;---------------------------------------------------------------
;
 funkit2:
     mov a,P1
		 orl a,mason1
		 setb ACC.2
		 mov P1,a ;    
     clr talarm ;   talarm
  funkit3:
     mov setibu0,bufust0 ;   
     mov setibu1,bufust1
     mov setibu2,bufust2
     mov bufos_1,#0xD6 ;   ""   1 frame1
     lcall viev_sb ; in file "sektim.txt"    
    ljmp open_cor ; in file "datclock.txt"    
                 ;    0('?')
;---------------------------------------------------------------
;    1 (/)
;
;  ""     
;    =-,  tionn=1 
;  bufust2:bufust0  setibu2:setibu0   
;
;  ""  +   bufust2:bufust0
;  tionn=1 
; 
;         0,    1
;   bufos_1    
 fnukit:
   jnb tionn,funkit1
   ljmp step4
  funkit1:
     jbc downf,funkit2 ;   ""
     jb talarm,funkit2 ; /  ""  talarm=1
  ;---------------------------------------------------
  ;           
	;       
  ;    
  ;
     mov a,setibu2 ;    
     jnz hast0 ;     0
     mov a,bufust2 ;  setibu2=0    bufust2
     sjmp hast1 ;    hast1
  hast0:
     mov a,bufust2 ;    bufust2
     jz hast1 ;   bufust2=0   hast1
     clr c ;  CY
     subb a,setibu2 ;    bufust2  setibu2
  hast1:
     mov setibu2,a ;    setibu2
       ;--------------------------------
     mov a,setibu1 ;    
     jnz hast2 ;     0
     mov a,bufust1 ;  setibu1=0    bufust1
     sjmp hast4 ;    hast4
		       ; (=0,    )
  hast2:
     mov a,bufust1 ;    bufust1
     jnz hast3 ;   bufust1=0   hast3
     dec setibu2 ;     setibu2
     mov a,#60 ;      60
  hast3:
     clr c ;  CY
     subb a,setibu1 ;    bufust1  setibu1
     jnc hast4 ;        hast4
     mov a,bufust1 ;     bufust1
     add a,#60 ;  60  ( CY=0)
     dec setibu2 ;    setibu2
     subb a,setibu1 ;    bufust1+60  setibu1
  hast4:
     mov setibu1,a ;    setibu1
       ;--------------------------------
     mov a,setibu0 ;    
     jnz hast5 ;     0
     mov a,bufust0 ;  setibu0=0    bufust0
     sjmp hast7 ;    hast7
           ; (=0,    )
  hast5:
     mov a,bufust0 ;    bufust0
     jnz hast6 ;   bufust0=0   hast6
     dec setibu1 ;     setibu1
     mov a,#60 ;      60
  hast6:
     clr c ;  CY
     subb a,setibu0 ;    bufust0  setibu0
     jnc hast7 ;        hast7
     mov a,bufust0 ;     bufust0
     add a,#60 ;  60  ( CY=0)
     dec setibu1 ;    setibu1
     subb a,setibu0 ;    bufust0+60  setibu0
  hast7:
     mov setibu0,a ;    setibu1
       ;--------------------------------
     lcall viev_sb ; in file "sektim.txt"    
     ljmp hast8
;---------------------------------------------------------------
;
;       
;
  re_kodes:
      mov a,bufos_b
      anl a,#0x0F
      mov r7,a
      mov a,bufos_a
      anl a,#0x0F
      swap a
      orl a,r7
      lcall decobin
      mov setibu0,a
       mov a,bufos_8
       anl a,#0x0F
       mov r7,a
       mov a,bufos_7
       anl a,#0x0F
       swap a
       orl a,r7
       lcall decobin
       mov setibu1,a
      mov a,bufos_5
      anl a,#0x0F
      mov r7,a
      mov a,bufos_4
      anl a,#0x0F
      swap a
      orl a,r7
      lcall decobin
      mov setibu2,a
    ret
;---------------------------------------------------------------
;     RTC ("" downf=0)/  RTC   ("" downf=1)
rem_rtc:
     jbc downf,rider
     lcall re_kodes ;      
     lcall tm_wrt ; in "lan_i2c.txt"
     sjmp riderr
 rider:
     lcall tm_rd ; in "lan_i2c.txt"
 riderr:
     ljmp reust ;      /
              ;      "?"
;---------------------------------------------------------------