Subversion Repositories Kolibri OS

Rev

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

  1. dialog_line:
  2.             mov [string_x],eax
  3.             mov [string_y],ebx
  4.             mov [MaxSizeString],ecx
  5.  
  6.             and [position],0
  7.             mov eax,string_
  8.             mov ebx,64/4
  9.             next_byte_cleare:
  10.             mov [eax],dword 0
  11.             add eax,4
  12.             dec ebx
  13.             jnz next_byte_cleare
  14.             call print_line
  15.             call print_cursor
  16.  
  17. opros:
  18.         mcall SF_SLEEP, 5 ;fix cpu use 100%
  19.         mcall SF_WAIT_EVENT
  20.  
  21.         cmp eax,1 ;redraw window
  22.         jne @f
  23.                 call dialog2_draw
  24.  
  25.                 mov ebx,[string_x]
  26.                 shl ebx,16
  27.                 add ebx,[string_y]
  28.                 mov edx,string_
  29.                 mov esi,[MaxSizeString]
  30.                 mcall SF_DRAW_TEXT,,0
  31.                 jmp opros
  32.         @@:
  33.         cmp eax,3 ;press button
  34.         je exit_cycle
  35.  
  36.         cmp eax,2 ;press key
  37.         jne opros
  38.  
  39.             mcall SF_GET_KEY
  40.             shr eax,8
  41.  
  42.             cmp al,13
  43.             je exit_cycle
  44.             cmp al,8
  45.             je backspace
  46.             cmp al,176
  47.             je left
  48.             cmp al,179
  49.             je right
  50.             cmp al,32
  51.             je probel
  52.  
  53.             inc [position]
  54.             inc [MaxSizeString]
  55.             call MinMaxCorrect
  56.             dec [MaxSizeString]
  57.             test ecx,ecx
  58.             jz no_maximum_position
  59.             jmp opros
  60.             no_maximum_position:
  61.  
  62.  
  63.             mov ebx,[position]
  64.             dec ebx
  65.             mov [string_+ebx],al
  66.  
  67.             call print_line
  68.             call print_cursor
  69.             jmp  opros
  70.   backspace:
  71.             dec [position]
  72.             call MinMaxCorrect
  73.             mov ebx,[position]
  74.             mov [string_+ebx],byte ' '
  75.  
  76.             call print_line
  77.             call print_cursor
  78.             jmp opros
  79.  
  80.        left:
  81.             dec [position]
  82.             call MinMaxCorrect
  83.             call print_line
  84.             call print_cursor
  85.             jmp opros
  86.  
  87.       right:
  88.             inc [position]
  89.             call MinMaxCorrect
  90.             call print_line
  91.             call print_cursor
  92.             jmp opros
  93.  
  94.      probel:
  95.             mov ebx,[position]
  96.             mov [string_+ebx],byte ' '
  97.             inc [position]
  98.             call MinMaxCorrect
  99.             call print_line
  100.             call print_cursor
  101.             jmp opros
  102.  
  103.  exit_cycle:
  104.              inc [position]
  105.              mov ebx,[position]
  106.              mov [string_+ebx],byte 13
  107.              exit_opros:
  108.  
  109.              call print_line
  110.             ret
  111. ;---------------------------------------------------------------
  112. print_line:
  113.         mov ebx,[string_x]
  114.         mov ecx,[string_y]
  115.         mov edx,[MaxSizeString]
  116.         shl ebx,16
  117.         shl ecx,16
  118.         imul edx,6
  119.         add ebx,edx
  120.         add ebx,2
  121.         add ecx,10
  122.         mov edx,0xffffff
  123.         mcall SF_DRAW_RECT
  124.         mov ebx,[string_x]
  125.         shl ebx,16
  126.         add ebx,[string_y]
  127.         mov edx,string_
  128.         mov esi,[MaxSizeString]
  129.         mcall SF_DRAW_TEXT,,0
  130.         ret
  131.  
  132. print_cursor:
  133.         mov ebx,[position]
  134.         mov ecx,[string_y]
  135.         imul ebx,6
  136.         add ebx,[string_x]
  137.         shl ebx,16
  138.         shl ecx,16
  139.         add ebx,2
  140.         add ecx,8
  141.         mcall SF_DRAW_RECT,,,0xff6c58
  142.         ret
  143. ;----------------------------------------------------------
  144. MinMaxCorrect:
  145.             mov ebx,[MaxSizeString]
  146.             xor ecx,ecx
  147.  
  148.             cmp [position],ebx
  149.             jl no_maximum_length_string
  150.             mov [position],ebx
  151.             mov ecx,1    ;maximul position
  152.             no_maximum_length_string:
  153.  
  154.             cmp [position],0
  155.             jns no_minimum_length_string
  156.             and [position],0
  157.             no_minimum_length_string:
  158.  
  159.             ret
  160. ;----------------------------------------------------------
  161. string_       rb 65
  162. position      dd 0
  163. MaxSizeString dd 0
  164. string_x      dd 0
  165. string_y      dd 0
  166.  
  167. ;----------------------------------------------------------
  168. ;input:
  169. ; eax - pointer to string
  170. ;output:
  171. ; eax - value
  172. str_to_int:
  173.         xor edx,edx
  174.   cycle_value_:
  175.         xor ebx,ebx
  176.         mov bl,byte[eax]
  177.  
  178.         cmp bl,'0'
  179.         jne no_0
  180.         mov ebx,0
  181.         jmp exit_v
  182.         no_0:
  183.         cmp bl,'1'
  184.         jne no_1
  185.         mov ebx,1
  186.         jmp exit_v
  187.         no_1:
  188.         cmp bl,'2'
  189.         jne no_2
  190.         mov ebx,2
  191.         jmp exit_v
  192.         no_2:
  193.         cmp bl,'3'
  194.         jne no_3
  195.         mov ebx,3
  196.         jmp exit_v
  197.         no_3:
  198.         cmp bl,'4'
  199.         jne no_4
  200.         mov ebx,4
  201.         jmp exit_v
  202.         no_4:
  203.         cmp bl,'5'
  204.         jne no_5
  205.         mov ebx,5
  206.         jmp exit_v
  207.         no_5:
  208.         cmp bl,'6'
  209.         jne no_6
  210.         mov ebx,6
  211.         jmp exit_v
  212.         no_6:
  213.         cmp bl,'7'
  214.         jne no_7
  215.         mov ebx,7
  216.         jmp exit_v
  217.         no_7:
  218.         cmp bl,'8'
  219.         jne no_8
  220.         mov ebx,8
  221.         jmp exit_v
  222.         no_8:
  223.         cmp bl,'9'
  224.         jne no_9
  225.         mov ebx,9
  226.         jmp exit_v
  227.         no_9:
  228.         xor edx,edx
  229.         jmp error
  230.         exit_v:
  231.         mov ecx,[length_number]
  232.         dec ecx
  233.         test ecx,ecx
  234.         jz no_stepen
  235.  
  236.     next_mul:
  237.         imul ebx,10
  238.         dec ecx
  239.         jne next_mul
  240.  
  241.         no_stepen:
  242.         add edx,ebx
  243.  
  244.         inc eax
  245.         dec [length_number]
  246.         jnz cycle_value_
  247.         error:
  248.         mov eax,edx
  249.         ret
  250.  
  251. ;----------------------------------------------------------
  252. align 4
  253. dialog2_draw:
  254.         mov     eax,80
  255.         mov     ebx,100
  256.         mov     ecx,150
  257.         mov     edx,90
  258.         mov esi,1
  259.         call draw_volume_rectangle ; dialog 'file new'
  260.  
  261.         mov     eax,177
  262.         mov     ebx,115
  263.         mov     ecx,40
  264.         mov     edx,14
  265.         mov esi,4
  266.         call draw_volume_rectangle
  267.  
  268.         mov     eax,177
  269.         mov     ebx,115+24
  270.         mov     ecx,40
  271.         mov     edx,14
  272.         mov esi,4
  273.         call draw_volume_rectangle
  274.  
  275.         mov     eax,177
  276.         mov     ebx,170
  277.         mov     ecx,40
  278.         mov     edx,15
  279.         mov     esi,1
  280.         call draw_volume_rectangle ; button [Ok]
  281.  
  282.         mov     eax,90
  283.         mov     ebx,118
  284.         mov     ecx,0xffffff
  285.         mov     edx,new_text1
  286.         mov     esi,14
  287.         call print_text
  288.  
  289.         mov     eax,90
  290.         mov     ebx,118+24
  291.         mov     ecx,0xffffff
  292.         mov     edx,new_text2
  293.         mov     esi,14
  294.         call print_text
  295.  
  296.         mov     eax,185
  297.         mov     ebx,175
  298.         mov     ecx,0xffffff
  299.         mov     edx,ok_text
  300.         mov     esi,2
  301.         call print_text
  302.         ret
  303.  
  304. length_number   dd 0