Subversion Repositories Kolibri OS

Rev

Rev 8236 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;      h2d2b v0.5 big fonts by Leency      ;;
  2. ;;      09.11.2016                          ;;
  3.  
  4. ;;      h2d2b v0.4 use editbox by IgorA     ;;
  5. ;;      30.08.2011                          ;;
  6.  
  7. ;;      h2d2b v0.3 system colors by Leency  ;;
  8. ;;      21.08.2011                          ;;
  9.  
  10. ;;      hex2dec2bin 0.2 by Alexei Ershov    ;;
  11. ;;      16.11.2006                          ;;
  12.  
  13. WIN_W = 364
  14.  
  15. use32
  16.     org 0
  17.     db  'MENUET01'
  18.     dd  1,start,i_end,e_end,e_end,0,sys_path
  19.  
  20. include '../../../proc32.inc'
  21. include '../../../macros.inc' ; ¬ ªà®áë ®¡«¥£ç îâ ¦¨§­ì  áᥬ¡«¥à騪®¢!
  22. include '../../../KOSfuncs.inc'
  23. include '../../../load_lib.mac'
  24. include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
  25. include 'lang.inc'
  26.  
  27. @use_library
  28.  
  29. start:
  30.         load_libraries l_libs_start,l_libs_end
  31.         ;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ­ è  ¡¨¡«¨®â¥ª 
  32.         mov     ebp,lib_0
  33.         cmp     dword [ebp+ll_struc_size-4],0
  34.         jz      @f
  35.                 mcall SF_TERMINATE_PROCESS
  36.         @@:
  37.         mcall SF_SET_EVENTS_MASK,0x80000027
  38.         mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sys_colors, 40
  39.         edit_boxes_set_sys_color edit1,editboxes_end,sys_colors
  40.  
  41. red:
  42.     call draw_window
  43.  
  44. align 4
  45. still:
  46.     mcall SF_WAIT_EVENT
  47.  
  48.     cmp  eax,1          ; ¯¥à¥à¨á®¢ âì ®ª­® ?
  49.     je   red            ; ¥á«¨ ¤  - ­  ¬¥âªã red
  50.     cmp  eax,2          ; ­ ¦ â  ª« ¢¨è  ?
  51.     je   key            ; ¥á«¨ ¤  - ­  key
  52.     cmp  eax,3          ; ­ ¦ â  ª­®¯ª  ?
  53.     je   button         ; ¥á«¨ ¤  - ­  button
  54.     cmp  eax,6
  55.     je   mouse
  56.  
  57.     jmp  still          ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ­ ç «® 横« 
  58.  
  59. ;---------------------------------------------------------------------
  60.  
  61. key:                   ; ­ ¦ â  ª« ¢¨è  ­  ª« ¢¨ âãà¥
  62.     mcall SF_GET_KEY
  63.         cmp ah,13 ;®¡à ¡®âª  ª­®¯ª¨ Enter
  64.         je @f
  65.                 stdcall [edit_box_key], dword edit1
  66.                 jmp still
  67.         @@:
  68.         mov edi,string1
  69.         add edi,[edit1.size] ;ãáâ ­ ¢«¨¢ ¥¬ ¢ edi ª®­¥æ áâப¨
  70.         jmp read_str
  71.     jmp still           ; ¢¥à­ãâìáï ª ­ ç «ã 横« 
  72.  
  73. read_str:
  74.     dec   edi
  75.     mov   esi, string1
  76.  
  77.     call  GetBase
  78.  
  79.     xor   ecx, ecx
  80.     inc   ecx           ; ecx = 1
  81.  
  82. make_bin:
  83.     xor   eax, eax
  84.  
  85. next_digit:
  86.     xor   edx, edx
  87.     cmp   edi, esi
  88.     jb    .done
  89.  
  90.     mov   dl, [edi]
  91.     cmp   dl, '-'
  92.     jne   @f
  93.     neg   eax
  94.     jmp   .done
  95. @@:
  96.     cmp   dl, 'F'
  97.     jbe   @f
  98.     and   dl, 11011111b
  99. @@:
  100.     sub   dl, '0'
  101.     cmp   dl, 9
  102.     jbe   @f
  103.     sub   dl, 'A'-'9'-1
  104. @@:
  105.     cmp   dl, bl
  106.     jb    @f
  107.     ; ‡¤¥áì ®¡à ¡®â âì ®è¨¡ªã
  108.  
  109.     jmp   .done
  110. @@:
  111.     push  ecx
  112.     xchg  eax, ecx
  113.     mul   edx ;        edx:eax = eax * edx
  114.     add   ecx, eax
  115.     pop   eax
  116.     mul   ebx
  117.     xchg  eax, ecx
  118.     dec   edi
  119.     jmp   next_digit
  120.  
  121. .done:
  122.    mov    [num], eax    ; á®å࠭塞 ¢¢¥¤¥­­®¥ ç¨á«®
  123.    jmp    red
  124.  
  125. ;---------------------------------------------------------------------
  126.  
  127. button:
  128.         mcall SF_GET_BUTTON
  129.         cmp   ah, 1     ; ¥á«¨ … ­ ¦ â  ª­®¯ª  á ­®¬¥à®¬ 1,
  130.         jne   @f
  131.                 mcall SF_TERMINATE_PROCESS
  132.         @@:
  133.         cmp ah, 2
  134.         jne @f
  135.                 shl [num], 1
  136.                 jmp red
  137.         @@:
  138.         cmp ah, 3
  139.         jne @f
  140.                 shr [num], 1
  141.                 jmp red
  142.         @@:
  143.         cmp ah, 4
  144.         jne @f
  145.                 sar [num], 1
  146.                 jmp red
  147.         @@:
  148.         cmp ah, 5
  149.         jne @f
  150.                 mov edi,string1
  151.                 add edi,[edit1.size] ;ãáâ ­ ¢«¨¢ ¥¬ ¢ edi ª®­¥æ áâப¨
  152.                 jmp read_str
  153.                 ;jmp red
  154.         @@:
  155.         jmp still
  156.  
  157. mouse:
  158.         stdcall [edit_box_mouse], edit1
  159.         jmp still
  160.  
  161. ;------------------------------------------------
  162. draw_window:
  163. ;------------------------------------------------
  164.         mcall   SF_STYLE_SETTINGS, SSF_GET_COLORS, sys_colors, 40
  165.  
  166.     mcall SF_REDRAW, SSF_BEGIN_DRAW
  167.         mov     edx, 0x14000000
  168.         or      edx, [sys_colors.work]
  169.         ;mov    esi, 0x80000000
  170.         ;or     esi, [sys_colors.grab_text]
  171.     mcall SF_CREATE_WINDOW, 200*65536+WIN_W, 200*65536+179, ,,title
  172.  
  173.        
  174.     mcall  SF_DEFINE_BUTTON, 15*65536+42,106*65536+ 21, 2, [sys_colors.work_button] ; ª­®¯ª  shl
  175.     mcall   ,         70*65536+42,             ,  , ; ª­®¯ª  sal
  176.     mcall   , (WIN_W-55)*65536+42,             , 3, ; ª­®¯ª  shr
  177.     mcall   ,(WIN_W-111)*65536+42,             , 4, ; ª­®¯ª  sar
  178.     mcall   , (WIN_W-72)*65536+58,145*65536+ 21, 5, ; ª­®¯ª  Ok
  179.  
  180.         mov     ecx, 0x90000000
  181.         or      ecx, [sys_colors.work_text]
  182.     mcall  SF_DRAW_TEXT, 15*65536+30,   , binstr,
  183.     mcall   , 15*65536+46,   , decstr,
  184.     mcall   , 15*65536+62,   ,sdecstr,
  185.     mcall   , 15*65536+78,   , hexstr,
  186.     mcall   , 15*65536+150,  , numstr,
  187.  
  188.         mov     ecx, 0x90000000
  189.         or      ecx, [sys_colors.work_button_text]
  190.     mcall  , 23*65536+109, , shl_sal_sar_shr_button_caption
  191.         mcall  , (WIN_W-59)*65536+149,  , Okstr,
  192.     mov    ecx, [num]
  193.  
  194.         mov esi, [sys_colors.work_text]
  195.         or  esi, 0x90000000
  196.  
  197.     mcall SF_DRAW_NUMBER, 10*65536,   ,(WIN_W-92)*65536+62,    ; 10-­ ï á® §­ ª®¬
  198.         BIN_LINE_BLOCK_W = 76
  199.     mcall SF_DRAW_NUMBER, 8*65536+512,,(WIN_W-BIN_LINE_BLOCK_W)*65536+30 ; 2-­ ï       
  200.     ror    ecx, 8
  201.         mov    edx, (WIN_W-BIN_LINE_BLOCK_W*2)*65536+30
  202.         mcall
  203.     ror    ecx, 8
  204.     mov    edx, (WIN_W-BIN_LINE_BLOCK_W*3)*65536+30
  205.         mcall
  206.     ror    ecx, 8
  207.     mov    edx, (WIN_W-BIN_LINE_BLOCK_W*4)*65536+30
  208.         mcall
  209.     ror    ecx, 8
  210.     mov    [minus], '+'
  211.     jnc    @f
  212.     mov    [minus], '-'
  213.     neg    ecx
  214. @@:
  215.     mcall   , 10*65536,   ,(WIN_W-92)*65536+46,    ; 10-­ ï
  216.         mcall   , 8*65536+256,,(WIN_W-76)*65536+78,    ; 16-­ ï
  217.         mov   ecx,esi
  218.     mcall SF_DRAW_TEXT, (WIN_W-102)*65536+61, , minus, 1
  219.     mcall SF_DRAW_LINE, 15*65536+WIN_W-15, 137*65536+137, [sys_colors.work_graph]
  220.         stdcall [edit_box_draw], edit1
  221.     mcall SF_REDRAW, SSF_END_DRAW
  222.  
  223. ret
  224.  
  225.  
  226. ;-------------------------------------------------
  227.     GetBase:
  228. ;-------------------------------------------------
  229.     mov   ebx, 10
  230.     cmp   edi, esi
  231.     jb    .done
  232.  
  233.     mov   al, [edi]
  234.     cmp   al, 'H'
  235.     jbe   @f
  236.     and   al, 11011111b
  237. @@:
  238.     cmp   al, 'H'
  239.     jne   @f
  240.     mov   ebx, 16
  241.     dec   edi
  242.     jmp   .done
  243.  
  244. @@:
  245.     cmp   al, 'D'
  246.     jne   @f
  247.     mov   ebx, 10
  248.     dec   edi
  249.     jmp   .done
  250.  
  251. @@:
  252.     cmp   al, 'B'
  253.     jne   .done
  254.     mov   ebx, 2
  255.     dec   edi
  256.  
  257. .done:
  258. ret
  259.  
  260. ;-------------------------------------------------
  261. string1:
  262.   db  34 dup(' ')
  263. string1_end:
  264.   num   dd  0
  265.  
  266.  
  267.  title db 'hex2dec2bin 0.5',0
  268.  minus  db '-',0
  269.  hexstr db 'hex:',0
  270.  binstr db 'bin:',0
  271.  decstr db 'dec:',0
  272.  sdecstr db 'signed dec:',0
  273.  shl_sal_sar_shr_button_caption db 'shl    sal                    sar    shr',0
  274.  
  275. if lang eq ru
  276.         numstr db '—¨á«®:',0
  277.         Okstr db '‚¢®¤',0
  278. else
  279.         numstr db 'Number:',0
  280.         Okstr db 'Enter',0
  281. end if
  282.  
  283. mouse_dd dd 0
  284. edit1 edit_box (WIN_W-67-82), 67, 146, 0xffffff, 0xff, 0x80ff, 0, 0x90000000, (string1_end-string1), string1 , mouse_dd, ed_focus+ed_always_focus
  285.  
  286. editboxes_end:
  287.  
  288. system_dir_0 db '/sys/lib/'
  289. lib_name_0 db 'box_lib.obj',0
  290.  
  291. l_libs_start:
  292.         lib_0 l_libs lib_name_0, library_path, system_dir_0,import_box_lib
  293. l_libs_end:
  294.  
  295. align 4
  296. import_box_lib:
  297.         ;dd sz_init1
  298.         edit_box_draw dd sz_edit_box_draw
  299.         edit_box_key dd sz_edit_box_key
  300.         edit_box_mouse dd sz_edit_box_mouse
  301.         ;edit_box_set_text dd sz_edit_box_set_text
  302. dd 0,0
  303.         ;sz_init1 db 'lib_init',0
  304.         sz_edit_box_draw db 'edit_box_draw',0
  305.         sz_edit_box_key db 'edit_box_key',0
  306.         sz_edit_box_mouse db 'edit_box_mouse',0
  307.         ;sz_edit_box_set_text db 'edit_box_set_text',0
  308.  
  309. i_end:
  310.         sys_colors system_colors
  311.         sys_path rb 4096
  312.         library_path rb 4096
  313.         rb 0x400        ; stack
  314. e_end:                  ; ¬¥âª  ª®­æ  ¯à®£à ¬¬ë
  315.