Subversion Repositories Kolibri OS

Rev

Rev 4213 | Rev 4250 | 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.         dec   eax
  46.         jnz   @f
  47.         bts   dword [check1.flags],1
  48. @@:
  49.         mcall   40,0x80000027
  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.      je   restart
  78.      cmp  al,19
  79.      je   checkbox
  80.      cmp  al,180
  81.      je   restart_kernel
  82.      cmp  al,181
  83.      je   power_off
  84.      cmp  al,27
  85.      jne   still
  86.  
  87. close:
  88.     mcall -1
  89.  
  90. button:
  91.     mcall 17                                 ;eax=17 - get pressed button id
  92.     xchg al,ah
  93.     dec  eax
  94.     jz   close
  95.     dec  eax
  96.     jz   restart_kernel
  97.     dec  eax
  98.     jz   restart
  99.     dec  eax
  100.     jnz  checkbox
  101.  
  102. power_off:
  103.     push 2
  104.     jmp  mcall_and_close
  105.  
  106. restart:
  107.     push 3
  108.     jmp  mcall_and_close
  109.  
  110. restart_kernel:
  111.     push 4
  112.  
  113. mcall_and_close:
  114.     invoke  ini_set_int,ini_file,asettings,aautosave,[autosave]
  115.     cmp  [autosave],1
  116.     jne   no_save
  117.     mcall 70,rdsave
  118.     test  eax,eax
  119.     js    no_save
  120.     mov   ecx,eax
  121.     mcall 18,21
  122.     mov   ecx,eax
  123. @@:
  124.     push ecx
  125.     mcall 23,100
  126.     dec   eax
  127.     jnz   no_red
  128.     call draw_window
  129. no_red:
  130.     pop   ecx
  131.     mcall 9,proc_info
  132.     cmp   [proc_info+50],9
  133.     je    no_save
  134.     jmp   @b
  135. no_save:
  136.     pop  ecx
  137.     mcall 18,9
  138.  
  139. checkbox:
  140.     btc   dword [check1.flags],1
  141.     jc    .1
  142.     mov   [autosave],1
  143.     jmp   .draw
  144. .1:
  145.     mov   [autosave],0
  146. .draw:
  147.     push  dword check1
  148.     call  [check_box_draw2]
  149.     jmp    still
  150.    
  151. draw_window:
  152.     mov   al,12
  153.     mcall   ,1
  154.  
  155.     mov   al,14
  156.     mcall                                    ;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.     mov   al,4
  180.     mcall   ,<27,24> ,0x90ffffff,label2        ;eax=4 - write text
  181.     mcall   ,<23,58> ,          ,label3
  182.     mcall   ,<47,37> ,          ,label5
  183.     mcall   ,<41,71> ,          ,label6
  184.  
  185.     push  dword check1
  186.     call  [check_box_draw2]
  187.  
  188.     mov   al,12
  189.     mcall   ,2
  190.     ret
  191. ;---------------------------------------------------------------------
  192. ;data
  193. include 'data.inc'
  194.  
  195. ;---------------------------------------------------------------------
  196. IM_END:
  197. ;---------------------------------------------------------------------
  198. align 4
  199.  
  200. proc_info  rb 1024
  201.  
  202. autosave rd 1
  203. ;---------------------------------------------------------------------
  204. cur_dir_path:
  205.         rb 4096
  206. ;---------------------------------------------------------------------
  207. library_path:
  208.         rb 4096
  209. ;---------------------------------------------------------------------
  210. align 32
  211.         rb 4096
  212. stacktop:
  213. I_END:  ; ìåòêà êîíöà ïðîãðàììû