Subversion Repositories Kolibri OS

Rev

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

  1. macro square_width_put
  2. {
  3. local .no_put_to_screen
  4. local .next_color_put
  5. local .vertical_width_put
  6. local .horizontal_width_put
  7.  
  8.         mov ebx,[ReserveArray]
  9.         mov eax,[ebx]
  10.         test eax,eax
  11.         jz .no_put_to_screen
  12.         mov ecx,[ebx]
  13.         add ebx,4
  14.         xor ebp,ebp
  15.  
  16.         .next_color_put:
  17.         ;put saved pixels in ReserveArray
  18.         push ecx
  19.         mov [counter2],5
  20.         mov edi,[ebx]
  21.         push edi
  22.         .vertical_width_put:
  23.                 mov [counter],5
  24.  
  25.                 .horizontal_width_put:
  26.                         mov edx,[ebx+mem_offs_shape+ebp]
  27.                         ;and edx,0xffffff
  28.                         mov [edi],dx
  29.                         shr edx,16
  30.                         mov [edi+2],dl
  31.  
  32.                 add edi,3
  33.                 add ebp,4
  34.                 dec [counter]
  35.                 jnz .horizontal_width_put
  36.  
  37.                 mov ecx,[Picture_SizeX]
  38.                 sub ecx,5
  39.                 lea ecx,[ecx+ecx*2]
  40.                 add edi,ecx
  41.         dec [counter2]
  42.         jnz .vertical_width_put
  43.         pop edi
  44.         pop ecx
  45.  
  46.         add ebx,4
  47.         dec ecx
  48.         jnz .next_color_put
  49.  
  50.         .no_put_to_screen:
  51. }
  52.  
  53. macro square_width_save
  54. {
  55. local .next_color_save
  56. local .vertical_width_save
  57. local .horizontal_width_save
  58.         mov ebx,[ReserveArray]
  59.         mov [ebx],eax
  60.         mov ecx,eax
  61.         add ebx,4
  62.         xor ebp,ebp
  63.  
  64.         .next_color_save:
  65.         ;save color of pixel in ReserveArray
  66.         push ecx
  67.         mov [counter2],5
  68.         mov edi,[ebx]
  69.         .vertical_width_save:
  70.                 mov [counter],5
  71.  
  72.                 .horizontal_width_save:
  73.                         mov eax,edi
  74.                         mov edx,[eax]
  75.                         ;and edx,0xffffff
  76.                         mov [ebx+mem_offs_shape+ebp],dx
  77.                         shr edx,16
  78.                         mov [ebx+mem_offs_shape+2+ebp],dl
  79.  
  80.                 add edi,3
  81.                 add ebp,4
  82.                 dec [counter]
  83.                 jnz .horizontal_width_save
  84.  
  85.                 mov ecx,[Picture_SizeX]
  86.                 sub ecx,5
  87.                 lea ecx,[ecx+ecx*2]
  88.                 add edi,ecx
  89.         dec [counter2]
  90.         jnz .vertical_width_save
  91.         pop ecx
  92.  
  93.         add ebx,4
  94.         dec ecx
  95.         jnz .next_color_save
  96. }
  97.  
  98. macro draw_calc_pixels brush
  99. {
  100. local .next_pixel_put
  101. local .vertical_width
  102. local .horizontal_width
  103. local .no_draw_pixel
  104.  
  105.         mov ebx,[ReserveArray]
  106.         mov ecx,[ebx]
  107.         mov edx,[Color]
  108.         mov esi,[Color]
  109.         shr edx,16
  110.         add ebx,4
  111.         mov edi,[line_width]
  112.         dec edi
  113.         imul edi,25
  114.         add edi,brush
  115.         .next_pixel_put:
  116.  
  117.         mov eax,[ebx]
  118.         push eax
  119.         push ecx
  120.         xor ebp,ebp
  121.         mov [counter2],5
  122.  
  123.         .vertical_width:
  124.                 mov [counter],5
  125.  
  126.                 .horizontal_width:
  127.                 xor ecx,ecx
  128.                 mov cl,byte[edi+ebp]
  129.                 test cl,cl
  130.                 jz .no_draw_pixel
  131.                         mov [eax],si
  132.                         mov [eax+2],dl
  133.                 .no_draw_pixel:
  134.                 add eax,3
  135.                 inc ebp
  136.                 dec [counter]
  137.                 jnz .horizontal_width
  138.  
  139.                 mov ecx,[Picture_SizeX]
  140.                 sub ecx,5
  141.                 lea ecx,[ecx+ecx*2]
  142.                 add eax,ecx
  143.         dec [counter2]
  144.         jnz .vertical_width
  145.  
  146.         pop ecx
  147.         pop eax
  148.         add ebx,4
  149.         dec ecx
  150.         jnz .next_pixel_put
  151. }
  152.  
  153. ;-----------------------------------------------------------
  154. ;-----instruments of panel(icon's instruments)--------------
  155. ;-----------------------------------------------------------
  156. ;input:
  157. ; [Current_instrument] - instrument code
  158. ;
  159. ; *** instrument codes ***
  160. ;10 - pensil
  161. ;11 - draw brush
  162. ;12 - spray
  163. ;13 - lastik
  164. ;14 - flood fill
  165. ;15 - pipetka
  166. ;16 - draw line
  167. ;17 - draw rectangle
  168. ;18 - draw circle
  169. ;19 - draw ellips
  170. ;20 - draw hard contour
  171. ;21 - allocation of a countour
  172. ;23 - reflection from left to right
  173. ;24 - reflection from up to down
  174. ;40 - brush 1
  175. ;41 - brush 2
  176. ;42 - brush 3
  177. ;43 - brush 4
  178. ;44 - brush 5
  179. ;45 - zoom 1
  180. ;46 - zoom 2
  181. ;47 - zoom 3
  182. ;48 - zoom 4
  183. ;49 - zoom 8
  184. ;50 - zoom 16
  185. ;51 - palette
  186.  
  187. align 4
  188. TakeButtonInstruments:
  189.         mov eax,[Current_instrument]
  190.  
  191.         ;*************************brush 1***********************
  192.         cmp eax,40
  193.         jne no_brush1
  194.  
  195.         mov [Brush_SizeX],4
  196.         mov [Brush_SizeY],4
  197.         mov [Number_Brush],0
  198.         mov ebx,[Last_instrument]
  199.         mov [Current_instrument],ebx
  200.  
  201.         mov [line_width],1
  202.         ret
  203.         no_brush1:
  204.  
  205.         ;*************************brush 2***********************
  206.         cmp eax,41
  207.         jne no_brush2
  208.  
  209.         mov [Brush_SizeX],6
  210.         mov [Brush_SizeY],4
  211.         mov [Number_Brush],1
  212.         mov ebx,[Last_instrument]
  213.         mov [Current_instrument],ebx
  214.  
  215.         mov [line_width],2
  216.         ret
  217.         no_brush2:
  218.  
  219.         ;*************************brush 3***********************
  220.         cmp eax,42
  221.         jne no_brush3
  222.  
  223.         mov [Brush_SizeX],8
  224.         mov [Brush_SizeY],7
  225.         mov [Number_Brush],2
  226.         mov ebx,[Last_instrument]
  227.         mov [Current_instrument],ebx
  228.  
  229.         mov [line_width],3
  230.         ret
  231.         no_brush3:
  232.  
  233.         ;*************************brush 4***********************
  234.         cmp eax,43
  235.         jne no_brush4
  236.  
  237.         mov [Brush_SizeX],14
  238.         mov [Brush_SizeY],14
  239.         mov [Number_Brush],3
  240.         mov ebx,[Last_instrument]
  241.         mov [Current_instrument],ebx
  242.  
  243.         mov [line_width],4
  244.         ret
  245.         no_brush4:
  246.  
  247.         ;*************************brush 5***********************
  248.         cmp eax,44
  249.         jne no_brush5
  250.  
  251.         mov [Brush_SizeX],6
  252.         mov [Brush_SizeY],6
  253.         mov [Number_Brush],4
  254.         mov ebx,[Last_instrument]
  255.         mov [Current_instrument],ebx
  256.  
  257.         mov [line_width],5
  258.         ret
  259.         no_brush5:
  260.  
  261.         ;*************************pensil************************
  262.         cmp eax,10
  263.         jne no_pensil
  264.  
  265.         mov al,[exit_from_work_arrea]
  266.  
  267.         test al,al
  268.         jz no_exit_from_work_arrea
  269.  
  270.         and [Activate_instrument],0
  271.         and [exit_from_work_arrea],0
  272.  
  273.         no_exit_from_work_arrea:
  274.  
  275.         mov al,[Activate_instrument]
  276.  
  277.         test al,al
  278.         jnz no_activated_later
  279.  
  280.         call GetScreenCordinats
  281.         mov eax,[ScreenX]
  282.         mov ebx,[ScreenY]
  283.         add eax,[PosX]
  284.         add ebx,[PosY]
  285.         mov [OldX],eax
  286.         mov [OldY],ebx
  287.  
  288.         no_activated_later:
  289.  
  290.         mov eax,[PointerToPicture]
  291.         mov ebx,[ReserveArray]
  292.         mov ecx,[Picture_SizeX]
  293.         mov edx,[OldX]
  294.         shl edx,16
  295.         add edx,[OldY]
  296.         mov esi,[ScreenX]
  297.         mov edi,[ScreenY]
  298.         add esi,[PosX]
  299.         add edi,[PosY]
  300.         call calculate_line
  301.  
  302.         mov ecx,eax
  303.         mov edx,[Color]
  304.         mov esi,[Color]
  305.         shr edx,16
  306.         xor ebx,ebx
  307.         mov eax,[ReserveArray]
  308.  
  309.         pensil_next_pixel_draw:
  310.  
  311.           mov ebx,[eax]
  312.           mov [ebx],si
  313.           mov [ebx+2],dl
  314.           add eax,4
  315.  
  316.         dec ecx
  317.         jnz pensil_next_pixel_draw
  318.  
  319.         mov eax,[ScreenX]
  320.         mov ebx,[ScreenY]
  321.         add eax,[PosX]
  322.         add ebx,[PosY]
  323.         mov [OldX],eax
  324.         mov [OldY],ebx
  325.  
  326.         call MovePictureToWorkScreen
  327.         mov [Activate_instrument],1
  328.         ret
  329.         no_pensil:
  330.  
  331.         ;*************************draw brush********************
  332.         cmp eax,11
  333.         jne no_brush
  334.  
  335.         mov [Last_instrument],eax
  336.  
  337.         jmp no_lastik_
  338.  
  339.         lastik_in:
  340.         mov eax,[Color]
  341.         mov [SColor],eax
  342.         mov [Color],0xffffff
  343.         no_lastik_:
  344.  
  345.         mov eax,[ScreenX]
  346.         mov ebx,[ScreenY]
  347.         mov ecx,[Brush_SizeX]
  348.         mov edx,[Brush_SizeY]
  349.         add eax,[PosX]
  350.         add ebx,[PosY]
  351.         add eax,ecx
  352.         add ebx,edx
  353.  
  354.         cmp eax,[Picture_SizeX]
  355.         jl no_max_pos_x
  356.         mov eax,[Picture_SizeX]
  357.         no_max_pos_x:
  358.  
  359.         cmp ebx,[Picture_SizeY]
  360.         jl no_max_pos_y
  361.         mov ebx,[Picture_SizeY]
  362.         no_max_pos_y:
  363.  
  364.         cmp eax,ecx
  365.         ja no_min_pos_x
  366.         mov eax,[Brush_SizeX]
  367.         no_min_pos_x:
  368.  
  369.         cmp ebx,edx
  370.         ja no_min_pos_y
  371.         mov ebx,[Brush_SizeY]
  372.         no_min_pos_y:
  373.  
  374.         sub eax,[Brush_SizeX]
  375.         sub ebx,[Brush_SizeY]
  376.  
  377.         mov [x],eax
  378.         mov [y],ebx
  379.  
  380.         mov al,[exit_from_work_arrea]
  381.         test al,al
  382.         jz no_exit_from_work_arrea_brush
  383.         and [Activate_instrument],0
  384.         and [exit_from_work_arrea],0
  385.         no_exit_from_work_arrea_brush:
  386.  
  387.         mov al,[Activate_instrument]
  388.         test al,al
  389.         jnz no_new_brush_xy
  390.         mov eax,[x]
  391.         mov ebx,[y]
  392.         mov [OldX],eax
  393.         mov [OldY],ebx
  394.         mov [Activate_instrument],1
  395.         no_new_brush_xy:
  396.  
  397.         mov eax,[PointerToPicture]
  398.         mov ebx,[ReserveArray]
  399.         add ebx,4
  400.         mov ecx,[Picture_SizeX]
  401.         mov edx,[OldX]
  402.         shl edx,16
  403.         add edx,[OldY]
  404.         mov esi,[x]
  405.         mov edi,[y]
  406.  
  407.         call calculate_line
  408.  
  409.         mov ebx,[ReserveArray]
  410.         mov [ebx],eax
  411.  
  412.         ;procedure drawing of brush
  413.         mov ebx,[ReserveArray]
  414.         mov ecx,[ebx]
  415.         mov edx,[Color]
  416.         mov esi,[Color]
  417.         shr edx,16
  418.         add ebx,4
  419.         mov edi,[Number_Brush]
  420.         imul edi,20*20
  421.  
  422.         next_pixel_put_brush:
  423.  
  424.         mov eax,[ebx]
  425.         push eax
  426.         push ecx
  427.         xor ebp,ebp
  428.         and [counter2],0
  429.  
  430.         vertical_width_brush:
  431.            and [counter],0
  432.  
  433.            horizontal_width_brush:
  434.            xor ecx,ecx
  435.            mov cl,byte[Brush_color+edi+ebp]
  436.            test cl,cl
  437.              jz no_draw_pixel_brush
  438.               mov [eax],si
  439.               mov [eax+2],dl
  440.              no_draw_pixel_brush:
  441.            add eax,3
  442.            inc ebp
  443.            inc [counter]
  444.            cmp [counter],20
  445.            jne horizontal_width_brush
  446.  
  447.            mov ecx,[Picture_SizeX]
  448.            sub ecx,20
  449.            lea ecx,[ecx+ecx*2]
  450.            add eax,ecx
  451.         inc [counter2]
  452.         cmp [counter2],20
  453.         jne vertical_width_brush
  454.  
  455.         pop ecx
  456.         pop eax
  457.         add ebx,4
  458.         dec ecx
  459.         jnz next_pixel_put_brush
  460.  
  461.         mov eax,[x]
  462.         mov ebx,[y]
  463.         mov [OldX],eax
  464.         mov [OldY],ebx
  465.  
  466.         mov al,[lastik_is_active]
  467.         test al,al
  468.         jz no_lastik_active
  469.  
  470.         mov eax,[SColor]
  471.         mov [Color],eax
  472.         and [lastik_is_active],0
  473.         no_lastik_active:
  474.  
  475.         call MovePictureToWorkScreen
  476.         mov eax,[Current_instrument]
  477.         mov [Last_instrument],eax
  478.  
  479.         ret
  480.         no_brush:
  481.  
  482.         ;*************************pipetka***********************
  483.         cmp eax,15
  484.         jne no_pipetka
  485.  
  486.         mov eax,[ScreenY]
  487.         mov ebx,[Picture_SizeX]
  488.         add eax,[PosY]
  489.         imul eax,ebx
  490.         add eax,[ScreenX]
  491.         add eax,[PosX]
  492.         lea eax,[eax+eax*2]
  493.         add eax,[PointerToPicture]
  494.         mov ebx,[eax]
  495.         and ebx,0xffffff
  496.         mov [Color],ebx
  497.  
  498.         mcall SF_DRAW_RECT, ((ci_panel_x_pos+130) shl 16)+21,\
  499.                 ((ci_panel_y_pos+28) shl 16)+21, [Color]
  500.  
  501.         ret
  502.         no_pipetka:
  503.  
  504.         ;************************lastik*************************
  505.         cmp eax,13
  506.         jne no_lastik
  507.  
  508.         mov [Last_instrument],eax
  509.         mov [lastik_is_active],1
  510.         jmp lastik_in
  511.         no_lastik:
  512.  
  513.         ;************************Flood Fill*********************
  514.         cmp eax,14
  515.         jne no_FloodFill
  516.  
  517.         mov eax,[PointerToPicture]
  518.         mov ebx,[PointerToEditBufer]
  519.  
  520.         mov ecx,[Picture_SizeX]
  521.         imul ecx,[Picture_SizeY]
  522.         lea ecx,[ecx+ecx*2]
  523.         shl ecx,1
  524.  
  525.         cmp ecx,mem_flood_f
  526.         ja normal_size_of_bufer
  527.  
  528.         mov ebx,[ReserveArray]
  529.  
  530.         normal_size_of_bufer:
  531.  
  532.         add ebx,4
  533.         mov ecx,[Picture_SizeX]
  534.         mov edx,[ScreenX]
  535.         add edx,[PosX]
  536.         shl edx,16
  537.         add edx,[ScreenY]
  538.         add edx,[PosY]
  539.         mov esi,[Picture_SizeX]
  540.         dec esi
  541.         shl esi,16
  542.         add esi,[Picture_SizeY]
  543.         dec esi
  544.         mov edi,[Color]
  545.  
  546.         call flood_fill
  547.         call MovePictureToWorkScreen
  548.         ret
  549.         no_FloodFill:
  550.  
  551.         ;************************spray**************************
  552.         cmp eax,12
  553.         jne no_spray
  554.  
  555.         cmp [Activate_instrument],0
  556.         jne no_null_spray
  557.         mov [Activate_instrument],1
  558.         ret
  559.         no_null_spray:
  560.  
  561.         mov eax,[ScreenX]
  562.         mov ebx,[ScreenY]
  563.         mov ecx,[Brush_SizeX]
  564.         mov edx,[Brush_SizeY]
  565.         add eax,[PosX]
  566.         add ebx,[PosY]
  567.         add eax,ecx
  568.         add ebx,edx
  569.  
  570.         cmp eax,[Picture_SizeX]
  571.         jl no_max_pos_x_spray
  572.         mov eax,[Picture_SizeX]
  573.         no_max_pos_x_spray:
  574.  
  575.         cmp ebx,[Picture_SizeY]
  576.         jl no_max_pos_y_spray
  577.         mov ebx,[Picture_SizeY]
  578.         no_max_pos_y_spray:
  579.  
  580.         cmp eax,ecx
  581.         ja no_min_pos_x_spray
  582.         mov eax,[Brush_SizeX]
  583.         no_min_pos_x_spray:
  584.  
  585.         cmp ebx,edx
  586.         ja no_min_pos_y_spray
  587.         mov ebx,[Brush_SizeY]
  588.         no_min_pos_y_spray:
  589.  
  590.         sub eax,[Brush_SizeX]
  591.         sub ebx,[Brush_SizeY]
  592.         mov edi,0;[Number_Brush]
  593.         imul edi,20*20
  594.  
  595.         mov [x],eax
  596.         mov [y],ebx
  597.         mov ebp,[Picture_SizeX]
  598.         xor edx,edx
  599.         brush_y_spray:
  600.           xor ecx,ecx
  601.           brush_x_spray:
  602.            ;calculate position in array of spray
  603.            mov esi,edx
  604.            lea esi,[esi+esi*4] ;esi=esi*5
  605.            shl esi,2           ;esi=(esi*3)*4
  606.            add esi,ecx
  607.            add esi,edi
  608.            ;read byte from array
  609.            xor eax,eax
  610.            mov al,[Spray_color+esi]
  611.            test eax,eax
  612.            jz no_color_spray
  613.            mov eax,[x]
  614.            mov ebx,[y]
  615.            add eax,ecx
  616.            add ebx,edx
  617.            imul ebx,ebp; ebp=[Picture_SizeX]
  618.            add eax,ebx
  619.            lea eax,[eax+eax*2]
  620.            add eax,[PointerToPicture]
  621.            mov ebx,[Color]
  622.            mov [eax],bx
  623.            shr ebx,16
  624.            mov [eax+2],bl
  625.            no_color_spray:
  626.            inc ecx
  627.            cmp ecx,20
  628.           jl brush_x_spray
  629.         inc edx
  630.         cmp edx,20
  631.         jl brush_y_spray
  632.  
  633.         call MovePictureToWorkScreen
  634.         ret
  635.         no_spray:
  636.  
  637.         ;************************palette************************
  638.         cmp eax,51
  639.         jne no_palette
  640.  
  641.         stdcall [ColorDialog_Start],ColorDialog_data
  642. ; 2 - use another method/not found program
  643.         ;cmp    [ColorDialog_data.status],2
  644.         ;je     no_palette
  645. ; 1 - OK, color selected       
  646.         cmp     [ColorDialog_data.status],1
  647.         jne     @f
  648.                 mov     eax,[ColorDialog_data.color]
  649.                 mov [Color],eax
  650.         @@:
  651.         ;call drawwin
  652.  
  653.         mov eax,[Last_instrument]
  654.         mov [Current_instrument],eax
  655.         ret
  656.         no_palette:
  657.  
  658.         ;************************draw line**********************
  659.         cmp eax,16
  660.         jne no_line
  661.  
  662.         mov [Last_instrument],eax
  663.  
  664.         mov al,[Activate_instrument]
  665.         test al,al
  666.         jnz no_new_line_xy
  667.         mov eax,[ScreenX]
  668.         mov ebx,[ScreenY]
  669.         add eax,[PosX]
  670.         add ebx,[PosY]
  671.         mov [OldX],eax
  672.         mov [OldY],ebx
  673.         mov [Activate_instrument],1
  674.         xor eax,eax
  675.         mov ecx,mem_flood_f/4
  676.         mov edi,[ReserveArray]
  677.         cld
  678.         rep stosd
  679.         ret
  680.         no_new_line_xy:
  681.  
  682.         ;put saved pixels
  683.         square_width_put
  684.  
  685.         ;calculate line
  686.         mov ebx,[ReserveArray]
  687.         add ebx,4
  688.         mov eax,[PointerToPicture]
  689.         mov ecx,[Picture_SizeX]
  690.         mov edx,[OldX]
  691.         shl edx,16
  692.         add edx,[OldY]
  693.         mov esi,[ScreenX]
  694.         mov edi,[ScreenY]
  695.         add esi,[PosX]
  696.         add edi,[PosY]
  697.  
  698.         mov ebp,[Picture_SizeX]
  699.         sub ebp,[line_width]
  700.         cmp esi,ebp
  701.         jl no_minimum_x_line
  702.         mov esi,ebp
  703.         no_minimum_x_line:
  704.  
  705.         mov ebp,[Picture_SizeY]
  706.         sub ebp,[line_width]
  707.         cmp edi,ebp
  708.         jl no_minimum_y_line
  709.         mov edi,ebp
  710.         no_minimum_y_line:
  711.  
  712.         call calculate_line
  713.  
  714.         ;save color pixels in ReserveArray
  715.         square_width_save
  716.  
  717.         ;draw calculated pixels on work arrea
  718.         draw_calc_pixels width_pixels
  719.  
  720.         call MovePictureToWorkScreen
  721.         ret
  722.         no_line:
  723.  
  724.         ;************************draw rectangle*****************
  725.         cmp eax,17
  726.         jne no_rectangle
  727.  
  728.         mov [Last_instrument],eax
  729.  
  730.         mov al,[Activate_instrument]
  731.         test al,al
  732.         jnz no_new_rectangle_xy
  733.         mov eax,[ScreenX]
  734.         mov ebx,[ScreenY]
  735.         add eax,[PosX]
  736.         add ebx,[PosY]
  737.         mov [OldX],eax
  738.         mov [OldY],ebx
  739.         mov [Activate_instrument],1
  740.         xor eax,eax
  741.         mov ecx,mem_flood_f/4
  742.         mov edi,[ReserveArray]
  743.         cld
  744.         rep stosd
  745.         ret
  746.         no_new_rectangle_xy:
  747.  
  748.         ;put saved pixels
  749.         square_width_put
  750.  
  751.         ;calculate line
  752.         mov ebx,[ReserveArray]
  753.         add ebx,4
  754.         mov eax,[PointerToPicture]
  755.         mov ecx,[Picture_SizeX]
  756.         mov edx,[OldX]
  757.         shl edx,16
  758.         add edx,[OldY]
  759.         mov esi,[ScreenX]
  760.         mov edi,[ScreenY]
  761.         add esi,[PosX]
  762.         add edi,[PosY]
  763.  
  764.         mov ebp,[Picture_SizeX]
  765.         sub ebp,[line_width]
  766.         cmp esi,ebp
  767.         jl no_minimum_x_rectangle
  768.         mov esi,ebp
  769.         no_minimum_x_rectangle:
  770.  
  771.         mov ebp,[Picture_SizeY]
  772.         sub ebp,[line_width]
  773.         cmp edi,ebp
  774.         jl no_minimum_y_rectangle
  775.         mov edi,ebp
  776.         no_minimum_y_rectangle:
  777.  
  778.         call calculate_rectangle
  779.  
  780.         ;save color pixels in ReserveArray
  781.         square_width_save
  782.  
  783.         ;draw calculated pixels on work arrea
  784.         draw_calc_pixels width_pixels_rectangle
  785.  
  786.         call MovePictureToWorkScreen
  787.         ret
  788.         no_rectangle:
  789.  
  790.         ;************************draw circle********************
  791.         cmp eax,18
  792.         jne no_circle
  793.  
  794.         mov [Last_instrument],eax
  795.  
  796.         mov al,[Activate_instrument]
  797.         test al,al
  798.         jnz no_new_circle_xy
  799.         mov eax,[ScreenX]
  800.         mov ebx,[ScreenY]
  801.         add eax,[PosX]
  802.         add ebx,[PosY]
  803.         mov [OldX],eax
  804.         mov [OldY],ebx
  805.         mov [Activate_instrument],1
  806.         xor eax,eax
  807.         mov ecx,mem_flood_f/4
  808.         mov edi,[ReserveArray]
  809.         cld
  810.         rep stosd
  811.         ret
  812.         no_new_circle_xy:
  813.  
  814.         ;put saved pixels
  815.         square_width_put
  816.  
  817.         mov esi,[ScreenX]
  818.         mov edi,[ScreenY]
  819.         add esi,[PosX]
  820.         add edi,[PosY]
  821.  
  822.         sub esi,[OldX]
  823.         jns no_sign_x_circle
  824.         neg esi
  825.         shr esi,1
  826.         neg esi
  827.         add esi,[OldX]
  828.         jmp no_plus_sign_x_circle
  829.         no_sign_x_circle:
  830.  
  831.         shr esi,1
  832.         add esi,[OldX]
  833.         no_plus_sign_x_circle:
  834.  
  835.         sub edi,[OldY]
  836.         jns no_sign_y_circle
  837.         neg edi
  838.         shr edi,1
  839.         neg edi
  840.         add edi,[OldY]
  841.         jmp no_plus_sign_y_circle
  842.         no_sign_y_circle:
  843.  
  844.         shr edi,1
  845.         add edi,[OldY]
  846.         no_plus_sign_y_circle:
  847.  
  848.         mov [x],esi
  849.         mov [y],edi
  850.  
  851.         mov esi,[ScreenX]
  852.         mov edi,[ScreenY]
  853.         add esi,[PosX]
  854.         add edi,[PosY]
  855.  
  856.         sub esi,[OldX]
  857.         jns no_sign_x_circle_r
  858.         neg esi
  859.         no_sign_x_circle_r:
  860.  
  861.         sub edi,[OldY]
  862.         jns no_sign_y_circle_r
  863.         neg edi
  864.         no_sign_y_circle_r:
  865.  
  866.         mov [Dx_],esi
  867.         mov [Dy_],edi
  868.  
  869.         ;finit
  870.         fild [Dx_]
  871.         fmul st0,st0
  872.         fild [Dy_]
  873.         fmul st0,st0
  874.         fadd st0,st1
  875.         fsqrt
  876.         fistp [Radius]
  877.         fistp [Icon_X]
  878.         mov esi,[Radius]
  879.         shr esi,1
  880.         cmp esi,0
  881.         jne no_null_radius
  882.         mov [Radius],1
  883.         no_null_radius:
  884.  
  885.         mov [Radius],esi
  886.  
  887.         mov edi,[x]
  888.         mov ebp,[y]
  889.         add edi,esi
  890.         add ebp,esi
  891.  
  892.         mov edx,[Picture_SizeX]
  893.         sub edx,[line_width]
  894.         cmp edi,edx
  895.         jl no_limit_x_circle
  896.         sub edi,edx
  897.         sub [Radius],edi
  898.         no_limit_x_circle:
  899.  
  900.         mov edx,[Picture_SizeY]
  901.         sub edx,[line_width]
  902.         cmp ebp,edx
  903.         jl no_limit_y_circle
  904.         sub ebp,edx
  905.         sub [Radius],ebp
  906.         no_limit_y_circle:
  907.  
  908.  
  909.         mov edi,[x]
  910.         mov ebp,[y]
  911.  
  912.         sub edi,[Radius]
  913.         jns no_minimum_x_circle
  914.         add [Radius],edi
  915.         no_minimum_x_circle:
  916.  
  917.         sub ebp,[Radius]
  918.         jns no_minimum_y_circle
  919.         add [Radius],ebp
  920.         no_minimum_y_circle:
  921.  
  922.         ;calculate circle
  923.         mov ebx,[ReserveArray]
  924.         add ebx,4
  925.         mov eax,[PointerToPicture]
  926.         mov ecx,[Picture_SizeX]
  927.         mov edx,[x]
  928.         shl edx,16
  929.         add edx,[y]
  930.         mov esi,[Radius]
  931.         call calculate_circle
  932.  
  933.         ;save color pixels in ReserveArray
  934.         square_width_save
  935.  
  936.         ;draw calculated pixels on work arrea
  937.         draw_calc_pixels width_pixels
  938.  
  939.         call MovePictureToWorkScreen
  940.         ret
  941.         no_circle:
  942.  
  943.         ;************************zoom 1*************************
  944.         cmp eax,45
  945.         jne no_1_
  946.         mov [k],1
  947.         call scrollbar_move_00
  948.         and [Current_instrument],0 ;???
  949.         call drawwin
  950.         ret
  951.         no_1_:
  952.  
  953.         ;************************zoom 2*************************
  954.         cmp eax,46
  955.         jne no_2_
  956.         mov [k],2
  957.         call drawwin
  958.         call scrollbar_move_00
  959.         and [Current_instrument],0
  960.         ret
  961.         no_2_:
  962.  
  963.         ;************************zoom 3*************************
  964.         cmp eax,47
  965.         jne no_3_
  966.         mov [k],3
  967.         call drawwin
  968.         call scrollbar_move_00
  969.         and [Current_instrument],0
  970.         ret
  971.         no_3_:
  972.  
  973.         ;************************zoom 4*************************
  974.         cmp eax,48
  975.         jne no_4_
  976.         mov [k],4
  977.         call drawwin
  978.         call scrollbar_move_00
  979.         and [Current_instrument],0
  980.         ret
  981.         no_4_:
  982.  
  983.         ;************************zoom 8*************************
  984.         cmp eax,49
  985.         jne no_8_
  986.         mov [k],8
  987.         call drawwin
  988.         call scrollbar_move_00
  989.         and [Current_instrument],0
  990.         ret
  991.         no_8_:
  992.  
  993.         ;************************zoom 16************************
  994.         cmp eax,50
  995.         jne no_16_
  996.         mov [k],16
  997.         call drawwin
  998.         call scrollbar_move_00
  999.         and [Current_instrument],0
  1000.         ret
  1001.         no_16_:
  1002.  
  1003.         ;***************allocation of a countour****************
  1004.         cmp eax,21
  1005.         jne no_allocation
  1006.  
  1007.         mov [Activate_instrument],1
  1008.  
  1009.         call GetScreenCordinats
  1010.  
  1011.         bt [MouseBut],8 ;left button down
  1012.         jnc .left_but_down
  1013.                 cmp [crossing],2
  1014.                 jne @f
  1015.                         ;move old selection
  1016.                         mov eax,[crossing_old_x]
  1017.                         mov ebx,[crossing_old_y]
  1018.                         mov ecx,[ScreenX]
  1019.                         mov edx,[ScreenY]
  1020.                         add ecx,[PosX]
  1021.                         add edx,[PosY]
  1022.                         mov esi,[rectangular_shade_x]
  1023.                         mov edi,[rectangular_shade_y]
  1024.                         sub esi,eax
  1025.                         sub edi,ebx
  1026.                         call columnus
  1027.  
  1028.                         test eax,eax
  1029.                         jz @f
  1030.                                 mov [crossing],3
  1031.                                 mov [OldX],ecx
  1032.                                 mov [OldY],edx
  1033.                                 jmp selection_update
  1034.                 @@:
  1035.                 ;start new selection
  1036.                 mov eax,[ScreenX]
  1037.                 add eax,[PosX]
  1038.                 mov [crossing_old_x],eax
  1039.                 mov [rectangular_shade_x],eax
  1040.                 mov eax,[ScreenY]
  1041.                 add eax,[PosY]
  1042.                 mov [crossing_old_y],eax
  1043.                 mov [rectangular_shade_y],eax
  1044.                 mov [crossing],1
  1045.                 jmp selection_update
  1046.         .left_but_down:
  1047.  
  1048.         bt [MouseBut],0 ;left button press
  1049.         jnc .no_mouse_move
  1050.                 cmp [crossing],3
  1051.                 jne .no_sel_move
  1052.                         ;move selection
  1053.                         mov eax,[ScreenX]
  1054.                         add eax,[PosX]
  1055.                         sub eax,[OldX]
  1056.                         add [OldX],eax
  1057.                         mov ebx,[crossing_old_x]
  1058.                         add ebx,eax
  1059.                         cmp ebx,0
  1060.                         jge @f
  1061.                                 ;exit from left border
  1062.                                 sub eax,ebx
  1063.                         @@:
  1064.                         add [crossing_old_x],eax
  1065.                         add [rectangular_shade_x],eax
  1066.                         mov eax,[ScreenY]
  1067.                         add eax,[PosY]
  1068.                         sub eax,[OldY]
  1069.                         add [OldY],eax
  1070.                         mov ebx,[crossing_old_y]
  1071.                         add ebx,eax
  1072.                         cmp ebx,0
  1073.                         jge @f
  1074.                                 ;exit from top border
  1075.                                 sub eax,ebx
  1076.                         @@:
  1077.                         add [crossing_old_y],eax
  1078.                         add [rectangular_shade_y],eax
  1079.                         jmp selection_update
  1080.                 .no_sel_move:
  1081.                 ;resize selection
  1082.                 mov eax,[ScreenX]
  1083.                 add eax,[PosX]
  1084.                 mov [rectangular_shade_x],eax
  1085.                 mov eax,[ScreenY]
  1086.                 add eax,[PosY]
  1087.                 mov [rectangular_shade_y],eax
  1088.                 jmp selection_update
  1089.         .no_mouse_move:
  1090.  
  1091.         bt [MouseBut],16 ;left button up
  1092.         jnc .left_but_up
  1093.                 ;finish selection
  1094.                 mov eax,[crossing_old_x]
  1095.                 mov ebx,[rectangular_shade_x]
  1096.                 cmp eax,ebx
  1097.                 jle @f
  1098.                         mov [crossing_old_x],ebx
  1099.                         mov [rectangular_shade_x],eax
  1100.                 @@:
  1101.                 mov eax,[crossing_old_y]
  1102.                 mov ebx,[rectangular_shade_y]
  1103.                 cmp eax,ebx
  1104.                 jle @f
  1105.                         mov [crossing_old_y],ebx
  1106.                         mov [rectangular_shade_y],eax
  1107.                 @@:
  1108.                 mov [crossing],2
  1109.                 ret
  1110.         .left_but_up:
  1111.  
  1112.         bt [MouseBut],9 ;right button down
  1113.         jnc .right_but_down
  1114.                 ;delete select
  1115.                 mov [crossing],0
  1116.                 jmp selection_update
  1117.         .right_but_down:
  1118.  
  1119. if 0
  1120.         cmp [Paste_flag],1
  1121.         je @f
  1122.                 call PutFonForSprite
  1123.         @@:
  1124.         cmp [DrawSprite_flag],1
  1125.         jne @f
  1126.                 call SaveFonForSprite
  1127.                 call DrawSprite
  1128.         @@:
  1129. end if
  1130.  
  1131.         selection_update:
  1132.         call MovePictureToWorkScreen
  1133.         ret
  1134.         no_allocation:
  1135.  
  1136.         ;*************reflection from left to right*************
  1137.         cmp eax,23
  1138.         jne no_reflection_from_left_to_right
  1139.  
  1140.         mov ebp,[PointerToPicture]
  1141.         mov edx,[ReserveArray]
  1142.         mov esi,[Picture_SizeX]
  1143.         mov ebx,[Picture_SizeX]
  1144.         lea ebx,[ebx+ebx*2]
  1145.         shr esi,1
  1146.         next_line_reflection_x:
  1147.         ;copy vertical line to array
  1148.         mov ecx,[Picture_SizeX]
  1149.         shr ecx,1
  1150.         sub ecx,esi
  1151.         lea ecx,[ecx+ecx*2]
  1152.         add ecx,[PointerToPicture]
  1153.         mov edx,[ReserveArray]
  1154.         and edi,0
  1155.         copy_to_array_line_reflection_y:
  1156.         mov eax,[ecx]
  1157.         mov ebp,edi
  1158.         lea ebp,[ebp+ebp*2]
  1159.         mov [edx+ebp],ax
  1160.         shr eax,16
  1161.         mov [edx+ebp+2],al
  1162.         add ecx,ebx
  1163.         inc edi
  1164.         cmp edi,[Picture_SizeY]
  1165.         jne copy_to_array_line_reflection_y
  1166.  
  1167.         mov ecx,[Picture_SizeX]
  1168.         shr ecx,1
  1169.         mov ebp,ecx
  1170.         add ecx,esi
  1171.         dec ecx
  1172.         lea ecx,[ecx+ecx*2]
  1173.         add ecx,[PointerToPicture]
  1174.         sub ebp,esi
  1175.         lea ebp,[ebp+ebp*2]
  1176.         add ebp,[PointerToPicture]
  1177.         and edi,0
  1178.         next_line_reflection_y:
  1179.         mov eax,[ecx]
  1180.         and eax,0xffffff
  1181.         mov [ebp],ax
  1182.         shr eax,16
  1183.         mov [ebp+2],al
  1184.         add ebp,ebx
  1185.         add ecx,ebx
  1186.         inc edi
  1187.         cmp edi,[Picture_SizeY]
  1188.         jnz next_line_reflection_y
  1189.  
  1190.         ;copy vertical line  from array to screen
  1191.         mov ecx,[Picture_SizeX]
  1192.         shr ecx,1
  1193.         add ecx,esi
  1194.         dec ecx
  1195.         lea ecx,[ecx+ecx*2]
  1196.         add ecx,[PointerToPicture]
  1197.         mov edx,[ReserveArray]
  1198.         and edi,0
  1199.         copy_from_array_to_screen_reflection_y:
  1200.         mov ebp,edi
  1201.         lea ebp,[ebp+ebp*2]
  1202.         xor eax,eax
  1203.         mov eax,[edx+ebp]
  1204.         mov [ecx],ax
  1205.         shr eax,16
  1206.         mov [ecx+2],al
  1207.         add ecx,ebx
  1208.         inc edi
  1209.         cmp edi,[Picture_SizeY]
  1210.         jne copy_from_array_to_screen_reflection_y
  1211.  
  1212.         dec esi
  1213.         jnz next_line_reflection_x
  1214.  
  1215.         call MovePictureToWorkScreen
  1216.         ret
  1217.         no_reflection_from_left_to_right:
  1218.  
  1219.         ;*************reflection from up to down****************
  1220.         cmp eax,24
  1221.         jne no_reflection_from_up_to_down
  1222.         mov esi,[Picture_SizeX]
  1223.         mov edi,esi
  1224.         lea esi,[esi+esi*2]
  1225.         lea edi,[edi+edi*2]
  1226.         imul edi,[Picture_SizeY]
  1227.         mov edx,[ReserveArray]
  1228.         mov ecx,[Picture_SizeY]
  1229.         shr ecx,1
  1230.         add edi,[PointerToPicture]
  1231.         sub edi,esi
  1232.         mov ebp,[PointerToPicture]
  1233.         next_lines_reflection:
  1234.         ;copy line
  1235.         xor ebx,ebx
  1236.         copy_line_1:
  1237.         xor eax,eax
  1238.         mov al,[edi+ebx]
  1239.         mov [edx+ebx],al
  1240.         inc ebx
  1241.         cmp ebx,esi
  1242.         jne copy_line_1
  1243.  
  1244.         xor ebx,ebx
  1245.         copy_line_2:
  1246.         xor eax,eax
  1247.         mov al,[ebp+ebx]
  1248.         mov [edi+ebx],al
  1249.         inc ebx
  1250.         cmp ebx,esi
  1251.         jne copy_line_2
  1252.  
  1253.         xor ebx,ebx
  1254.         copy_line_3:
  1255.         xor eax,eax
  1256.         mov al,[edx+ebx]
  1257.         mov [ebp+ebx],al
  1258.         inc ebx
  1259.         cmp ebx,esi
  1260.         jne copy_line_3
  1261.  
  1262.         add ebp,esi
  1263.         sub edi,esi
  1264.         dec ecx
  1265.         jnz next_lines_reflection
  1266.  
  1267.         call MovePictureToWorkScreen
  1268.         ret
  1269.         no_reflection_from_up_to_down:
  1270.  
  1271.         ;*********************draw hard contour*****************
  1272.         cmp eax,20
  1273.         jne no_kontur_
  1274.  
  1275.         mov [Last_instrument],eax
  1276.  
  1277.         mov al,[Activate_instrument]
  1278.         test al,al
  1279.         jnz no_new_konture_xy
  1280.  
  1281.         mov al,[instrument_used]
  1282.         test al,al
  1283.         jz instrument_not_used
  1284.         mov eax,[used_OldX]
  1285.         mov ebx,[used_OldY]
  1286.         mov [OldX],eax
  1287.         mov [OldY],ebx
  1288.         jmp exit_used_instrument
  1289.         instrument_not_used:
  1290.  
  1291.         mov eax,[ScreenX]
  1292.         mov ebx,[ScreenY]
  1293.         add eax,[PosX]
  1294.         add ebx,[PosY]
  1295.         mov [OldX],eax
  1296.         mov [OldY],ebx
  1297.         exit_used_instrument:
  1298.  
  1299.         mov al,[instrument_used]
  1300.         test al,al
  1301.         jnz instrument_used_true
  1302.         mov [instrument_used],byte 1
  1303.         instrument_used_true:
  1304.  
  1305.         mov [Activate_instrument],1
  1306.         xor eax,eax
  1307.         mov ecx,mem_flood_f/4
  1308.         mov edi,[ReserveArray]
  1309.         rep stosd
  1310.  
  1311.         no_new_konture_xy:
  1312.  
  1313.         ;put saved pixels
  1314.         square_width_put
  1315.  
  1316.         ;calculate line
  1317.         mov ebx,[ReserveArray]
  1318.         add ebx,4
  1319.         mov eax,[PointerToPicture]
  1320.         mov ecx,[Picture_SizeX]
  1321.         mov edx,[OldX]
  1322.         shl edx,16
  1323.         add edx,[OldY]
  1324.         mov esi,[ScreenX]
  1325.         mov edi,[ScreenY]
  1326.         add esi,[PosX]
  1327.         add edi,[PosY]
  1328.  
  1329.         mov ebp,[Picture_SizeX]
  1330.         sub ebp,[line_width]
  1331.         cmp esi,ebp
  1332.         jl no_minimum_x_konture
  1333.         mov esi,ebp
  1334.         no_minimum_x_konture:
  1335.  
  1336.         mov ebp,[Picture_SizeY]
  1337.         sub ebp,[line_width]
  1338.         cmp edi,ebp
  1339.         jl no_minimum_y_konture
  1340.         mov edi,ebp
  1341.         no_minimum_y_konture:
  1342.  
  1343.         call calculate_line
  1344.  
  1345.         ;save color pixels in ReserveArray
  1346.         square_width_save
  1347.  
  1348.         ;draw calculated pixels on work arrea
  1349.         draw_calc_pixels width_pixels
  1350.  
  1351.         mov eax,[ScreenX]
  1352.         mov ebx,[ScreenY]
  1353.         add eax,[PosX]
  1354.         add ebx,[PosY]
  1355.         mov [used_OldX],eax
  1356.         mov [used_OldY],ebx
  1357.  
  1358.         call MovePictureToWorkScreen
  1359.         ret
  1360.         no_kontur_:
  1361.  
  1362.         ;************************draw ellips********************
  1363.         cmp eax,19
  1364.         jne no_ellips
  1365.  
  1366.         mov [Last_instrument],eax
  1367.  
  1368.         mov al,[Activate_instrument]
  1369.         test al,al
  1370.         jnz no_new_ellips_xy
  1371.         mov eax,[ScreenX]
  1372.         mov ebx,[ScreenY]
  1373.         add eax,[PosX]
  1374.         add ebx,[PosY]
  1375.         mov [OldX],eax
  1376.         mov [OldY],ebx
  1377.         mov [Activate_instrument],1
  1378.         xor eax,eax
  1379.         mov ecx,mem_flood_f/4
  1380.         mov edi,[ReserveArray]
  1381.         cld
  1382.         rep stosd
  1383.         ret
  1384.         no_new_ellips_xy:
  1385.  
  1386.         ;put saved pixels
  1387.         square_width_put
  1388.  
  1389.  
  1390.         mov esi,[ScreenX]
  1391.         mov edi,[ScreenY]
  1392.         add esi,[PosX]
  1393.         add edi,[PosY]
  1394.  
  1395.         sub esi,[OldX]
  1396.         jns no_sign_x_ellips
  1397.         neg esi
  1398.         shr esi,1
  1399.         neg esi
  1400.         add esi,[OldX]
  1401.         jmp no_plus_sign_x_ellips
  1402.         no_sign_x_ellips:
  1403.  
  1404.         shr esi,1
  1405.         add esi,[OldX]
  1406.         no_plus_sign_x_ellips:
  1407.  
  1408.         sub edi,[OldY]
  1409.         jns no_sign_y_ellips
  1410.         neg edi
  1411.         shr edi,1
  1412.         neg edi
  1413.         add edi,[OldY]
  1414.         jmp no_plus_sign_y_ellips
  1415.         no_sign_y_ellips:
  1416.  
  1417.         shr edi,1
  1418.         add edi,[OldY]
  1419.         no_plus_sign_y_ellips:
  1420.  
  1421.         mov [x],esi
  1422.         mov [y],edi
  1423.  
  1424.         mov esi,[ScreenX]
  1425.         mov edi,[ScreenY]
  1426.         add esi,[PosX]
  1427.         add edi,[PosY]
  1428.  
  1429.         sub esi,[OldX]
  1430.         jns no_sign_x_ellips_r
  1431.         neg esi
  1432.         no_sign_x_ellips_r:
  1433.  
  1434.         sub edi,[OldY]
  1435.         jns no_sign_y_ellips_r
  1436.         neg edi
  1437.         no_sign_y_ellips_r:
  1438.  
  1439.         cmp edi,0
  1440.         jnz no_null_a_ellips
  1441.         mov edi,1
  1442.         no_null_a_ellips:
  1443.  
  1444.         shr esi,1
  1445.         shr edi,1
  1446.         mov [a_ellips],esi
  1447.         mov [b_ellips],edi
  1448.  
  1449.         mov edi,[x]
  1450.         mov ebp,[y]
  1451.         add edi,esi
  1452.         add ebp,esi
  1453.  
  1454.         mov edx,[Picture_SizeX]
  1455.         sub edx,[line_width]
  1456.         cmp edi,edx
  1457.         jl no_limit_x_ellips
  1458.         sub edi,edx
  1459.         sub [a_ellips],edi
  1460.         no_limit_x_ellips:
  1461.  
  1462.         mov edx,[Picture_SizeY]
  1463.         sub edx,[line_width]
  1464.         cmp ebp,edx
  1465.         jl no_limit_y_ellips
  1466.         sub ebp,edx
  1467.         sub [b_ellips],ebp
  1468.         no_limit_y_ellips:
  1469.  
  1470.  
  1471.         mov edi,[x]
  1472.         mov ebp,[y]
  1473.  
  1474.         sub edi,[a_ellips]
  1475.         jns no_minimum_x_ellips
  1476.         add [a_ellips],edi
  1477.         no_minimum_x_ellips:
  1478.  
  1479.         sub ebp,[b_ellips]
  1480.         jns no_minimum_y_ellips
  1481.         add [b_ellips],ebp
  1482.         no_minimum_y_ellips:
  1483.  
  1484.         ;calculate circle
  1485.         mov ebx,[ReserveArray]
  1486.         add ebx,4
  1487.         mov eax,[PointerToPicture]
  1488.         mov ecx,[Picture_SizeX]
  1489.         mov edx,[x]
  1490.         shl edx,16
  1491.         add edx,[y]
  1492.         mov esi,[a_ellips]
  1493.         shl esi,16
  1494.         add esi,[b_ellips]
  1495.         call calculate_ellips
  1496.  
  1497.         ;save color pixels in ReserveArray
  1498.         square_width_save
  1499.  
  1500.         ;draw calculated pixels on work arrea
  1501.         draw_calc_pixels width_pixels
  1502.  
  1503.         call MovePictureToWorkScreen
  1504.         ;ret
  1505.         no_ellips:
  1506.  
  1507.         ret