Subversion Repositories Kolibri OS

Rev

Rev 4051 | Rev 4215 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;
  2. ; END
  3. ; KolibriOS Team 2005-2013
  4. ;
  5. ; <diamond> note that 'mov al,xx' is shorter than 'mov eax,xx'
  6. ;           and if we know that high 24 bits of eax are zero, we can use 1st form
  7. ;           the same about ebx,ecx,edx
  8.  
  9. use32        ; âêëþ÷èòü 32-áèòíûé ðåæèì àññåìáëåðà
  10. org 0x0      ; àäðåñàöèÿ ñ íóëÿ
  11.  
  12. db 'MENUET01'    ; 8-áàéòíûé èäåíòèôèêàòîð MenuetOS
  13. dd 0x01          ; âåðñèÿ çàãîëîâêà (âñåãäà 1)
  14. dd START         ; àäðåñ ïåðâîé êîìàíäû
  15. dd IM_END        ; ðàçìåð ïðîãðàììû
  16. dd I_END         ; êîëè÷åñòâî ïàìÿòè
  17. dd stacktop      ; àäðåñ âåðøèíû ñòåêà
  18. dd 0x0           ; àäðåñ áóôåðà äëÿ ïàðàìåòðîâ
  19. dd cur_dir_path
  20.  
  21. include 'lang.inc'
  22. include '../../../macros.inc'
  23. include '../../../proc32.inc'
  24. include '../../../dll.inc'
  25. include '../../../develop/libraries/box_lib/load_lib.mac'
  26. include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
  27.  
  28.         @use_library
  29.  
  30. align 4
  31. START:
  32.  
  33. load_libraries l_libs_start,end_l_libs
  34.         inc     eax
  35.         test    eax,eax
  36.         jz      close
  37.  
  38. push    dword check1
  39. call    [init_checkbox2]
  40.  
  41. stdcall dll.Init,[init_lib]
  42.  
  43. invoke  ini_get_int,ini_file,asettings,aautosave,0
  44.         mov   [autosave],eax
  45.         cmp   eax,1
  46.         jne   @f
  47.         bts   dword [check1.flags],1
  48. @@:
  49.         mcall   40,0x00000027
  50. redraw:
  51.     call draw_window
  52. still:
  53.     mov  al,10
  54.     mcall                                    ;wait here for event
  55.     dec  eax
  56.     jz   redraw
  57.     dec  eax
  58.     jz   key
  59.     dec  eax
  60.     jz   button
  61.  
  62.     push dword check1
  63.     call [check_box_mouse2]
  64.     bt   dword [check1.flags],1
  65.     jnc  @f
  66.     mov  [autosave],1
  67.     jmp  still
  68. @@:
  69.     mov  [autosave],0
  70.     jmp  still
  71.    
  72. key:
  73.     mov  al,2
  74.     mcall                                    ;eax=2 - get key code
  75.     mov  al,ah
  76.      cmp  al,13
  77.      jz   restart
  78.      cmp  al,19
  79.      jz   checkbox
  80.      cmp  al,27
  81.      jz   close
  82.      cmp  al,180
  83.      jz   restart_kernel
  84.      cmp  al,181
  85.      jz   power_off
  86.      jmp  still
  87.  
  88. button:
  89.     mcall 17                                 ;eax=17 - get pressed button id
  90.     xchg al,ah
  91.     dec  eax
  92.     jz   close
  93.     dec  eax
  94.     jz   restart_kernel
  95.     dec  eax
  96.     jz   restart
  97.     dec  eax
  98.     jnz  checkbox
  99.  
  100. power_off:
  101.     push 2
  102.     jmp  mcall_and_close
  103.  
  104. restart:
  105.     push 3
  106.     jmp  mcall_and_close
  107.  
  108. restart_kernel:
  109.     push 4
  110.  
  111. mcall_and_close:
  112.     invoke  ini_set_int,ini_file,asettings,aautosave,[autosave]
  113.     cmp  [autosave],1
  114.     jne   no_save
  115.     mcall 70,rdsave
  116.     test  eax,eax
  117.     js    no_save
  118.     mov   ecx,eax
  119.     mcall 18,21
  120.     mov   ecx,eax
  121. @@:
  122.     push ecx
  123.     mcall 23,50
  124.     dec   eax
  125.     jnz   no_red
  126.     call draw_window
  127. no_red:
  128.     pop   ecx
  129.     mcall 9,proc_info
  130.     cmp   [proc_info+50],9
  131.     je    no_save
  132.     jmp   @b
  133. no_save:
  134.     pop  ecx
  135.     mcall 18,9
  136.  
  137. close:
  138.     mcall -1
  139.  
  140. checkbox:
  141.     btc   dword [check1.flags],1
  142.     jc    .1
  143.     mov   [autosave],1
  144.     jmp   .draw
  145. .1:
  146.     mov   [autosave],0
  147. .draw:
  148.     push  dword check1
  149.     call  [check_box_draw2]
  150.     jmp    still
  151.    
  152. draw_window:
  153.     mov   al,12
  154.     mcall ,1
  155.  
  156.     mcall 14                                 ;eax=14 - get screen max x & max y
  157.     movzx ecx,ax
  158.     shr  eax,17
  159.     shl  eax,16
  160.     lea  ebx,[eax-110 shl 16+222]
  161.     shr  ecx,1
  162.     shl  ecx,16
  163.     lea  ecx,[ecx-70 shl 16+117]
  164.  
  165.     xor eax,eax
  166.     mcall  , , ,0x019098b0,0x01000000        ;define and draw window
  167.  
  168.     mov   al,13
  169.     mcall   ,<0,223> ,<0,118>
  170.     mcall   ,<1,221>,<1,116>,0xffffff
  171.     mcall   ,<2,220>,<2,115>,0xe4dfe1
  172.  
  173.     mov    al,8
  174.     mcall   ,<16,90> ,<20,27>,4,0x990022     ;eax=8 - draw buttons
  175.     mcall   ,<113,90>,       ,2,0xaa7700
  176.     mcall   ,        ,<54,27>,1,0x777777
  177.     mcall   ,<16,90> ,       ,3,0x007700
  178.  
  179.     push  dword check1
  180.     call  [check_box_draw2]
  181.    
  182.     mcall 4,<27,24> ,0x90ffffff,label2        ;eax=4 - write text
  183.     mcall  ,<23,58> ,          ,label3
  184.     mcall  ,<47,37> ,0x90ffffff,label5
  185.     mcall  ,<44,71> ,          ,label6
  186.  
  187.     mov   al,12
  188.     mcall   ,2
  189.     ret
  190.  
  191. data
  192. include 'data.inc'
  193.  
  194. ;---------------------------------------------------------------------
  195. IM_END:
  196. ;---------------------------------------------------------------------
  197. align 4
  198.  
  199. proc_info  rb 1024
  200.  
  201. autosave rd 1
  202. ;---------------------------------------------------------------------
  203. cur_dir_path:
  204.         rb 4096
  205. ;---------------------------------------------------------------------
  206. library_path:
  207.         rb 4096
  208. ;---------------------------------------------------------------------
  209. align 32
  210.         rb 4096
  211. stacktop:
  212. I_END:  ; ìåòêà êîíöà ïðîãðàììû