Subversion Repositories Kolibri OS

Rev

Rev 6357 | Rev 6362 | Go to most recent revision | 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+4807*4+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+4807*4+ebp],dx
  77.                         shr edx,16
  78.                         mov [ebx+4807*4+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. TakeButtonInstruments:
  157.  
  158.         mov eax,[Current_instrument]
  159.  
  160.         ;*************************brush 1***********************
  161.         cmp eax,40
  162.         jne no_brush1
  163.  
  164.         mov [Brush_SizeX],4
  165.         mov [Brush_SizeY],4
  166.         mov [Number_Brush],0
  167.         mov ebx,[Last_instrument]
  168.         mov [Current_instrument],ebx
  169.  
  170.         mov [line_width],1
  171.  
  172.         jmp still
  173.         no_brush1:
  174.  
  175.         ;*************************brush 2***********************
  176.         cmp eax,41
  177.         jne no_brush2
  178.  
  179.         mov [Brush_SizeX],6
  180.         mov [Brush_SizeY],4
  181.         mov [Number_Brush],1
  182.         mov ebx,[Last_instrument]
  183.         mov [Current_instrument],ebx
  184.  
  185.         mov [line_width],2
  186.  
  187.         jmp still
  188.         no_brush2:
  189.  
  190.         ;*************************brush 3***********************
  191.         cmp eax,42
  192.         jne no_brush3
  193.  
  194.         mov [Brush_SizeX],8
  195.         mov [Brush_SizeY],7
  196.         mov [Number_Brush],2
  197.         mov ebx,[Last_instrument]
  198.         mov [Current_instrument],ebx
  199.  
  200.         mov [line_width],3
  201.  
  202.         jmp still
  203.         no_brush3:
  204.  
  205.         ;*************************brush 4***********************
  206.         cmp eax,43
  207.         jne no_brush4
  208.  
  209.         mov [Brush_SizeX],14
  210.         mov [Brush_SizeY],14
  211.         mov [Number_Brush],3
  212.         mov ebx,[Last_instrument]
  213.         mov [Current_instrument],ebx
  214.  
  215.         mov [line_width],4
  216.  
  217.         jmp still
  218.         no_brush4:
  219.  
  220.         ;*************************brush 5***********************
  221.         cmp eax,44
  222.         jne no_brush5
  223.  
  224.         mov [Brush_SizeX],6
  225.         mov [Brush_SizeY],6
  226.         mov [Number_Brush],4
  227.         mov ebx,[Last_instrument]
  228.         mov [Current_instrument],ebx
  229.  
  230.         mov [line_width],5
  231.  
  232.         jmp still
  233.         no_brush5:
  234.  
  235.         ;*************************pensil************************
  236.         cmp eax,10
  237.         jne no_pensil
  238.  
  239.         mov al,[exit_from_work_arrea]
  240.  
  241.         test al,al
  242.         jz no_exit_from_work_arrea
  243.  
  244.         and [Activate_instrument],0
  245.         and [exit_from_work_arrea],0
  246.  
  247.         no_exit_from_work_arrea:
  248.  
  249.         mov al,[Activate_instrument]
  250.  
  251.         test al,al
  252.         jnz no_activated_later
  253.  
  254.         call GetScreenCordinats
  255.         mov eax,[ScreenX]
  256.         mov ebx,[ScreenY]
  257.         add eax,[PosX]
  258.         add ebx,[PosY]
  259.         mov [OldX],eax
  260.         mov [OldY],ebx
  261.  
  262.         no_activated_later:
  263.  
  264. ;       mov eax,[MaxWorkScreen_SizeX] ???
  265. ;       mov ebx,[MaxWorkScreen_SizeY] ???
  266.  
  267.         mov eax,[PointerToPicture]
  268.         mov ebx,[ReserveArray]
  269.         mov ecx,[Picture_SizeX]
  270.         mov edx,[OldX]
  271.         shl edx,16
  272.         add edx,[OldY]
  273.         mov esi,[ScreenX]
  274.         mov edi,[ScreenY]
  275.         add esi,[PosX]
  276.         add edi,[PosY]
  277.         call calculate_line
  278.  
  279.         mov ecx,eax
  280.         mov edx,[Color]
  281.         mov esi,[Color]
  282.         shr edx,16
  283.         xor ebx,ebx
  284.         mov eax,[ReserveArray]
  285.  
  286.         pensil_next_pixel_draw:
  287.  
  288.           mov ebx,[eax]
  289.           mov [ebx],si
  290.           mov [ebx+2],dl
  291.           add eax,4
  292.  
  293.         dec ecx
  294.         jnz pensil_next_pixel_draw
  295.  
  296.         mov eax,[ScreenX]
  297.         mov ebx,[ScreenY]
  298.         add eax,[PosX]
  299.         add ebx,[PosY]
  300.         mov [OldX],eax
  301.         mov [OldY],ebx
  302.  
  303.         call MovePictureToWorkScreen
  304.         mov [Activate_instrument],1
  305.         jmp still
  306.         no_pensil:
  307.  
  308.         ;*************************pipetka***********************
  309.         cmp eax,15
  310.         jne no_pipetka
  311.  
  312.         mov eax,[ScreenY]
  313.         mov ebx,[Picture_SizeX]
  314.         add eax,[PosY]
  315.         imul eax,ebx
  316.         add eax,[ScreenX]
  317.         add eax,[PosX]
  318.         lea eax,[eax+eax*2]
  319.         add eax,[PointerToPicture]
  320.         mov ebx,[eax]
  321.         and ebx,0xffffff
  322.         mov [Color],ebx
  323.  
  324.         mcall SF_DRAW_RECT, ((ci_panel_x_pos+130) shl 16)+21,\
  325.                 ((ci_panel_y_pos+28) shl 16)+21, [Color]
  326.  
  327.         jmp still
  328.         no_pipetka:
  329.  
  330.         ;*************************draw brush********************
  331.         cmp eax,11
  332.         jne no_brush
  333.  
  334.         mov [Last_instrument],eax
  335.  
  336.         jmp no_lastik_
  337.  
  338.         lastik_in:
  339.         mov eax,[Color]
  340.         mov [SColor],eax
  341.         mov [Color],0xffffff
  342.         no_lastik_:
  343.  
  344.         mov eax,[ScreenX]
  345.         mov ebx,[ScreenY]
  346.         mov ecx,[Brush_SizeX]
  347.         mov edx,[Brush_SizeY]
  348.         add eax,[PosX]
  349.         add ebx,[PosY]
  350.         add eax,ecx
  351.         add ebx,edx
  352.  
  353.         cmp eax,[Picture_SizeX]
  354.         jl no_max_pos_x
  355.         mov eax,[Picture_SizeX]
  356.         no_max_pos_x:
  357.  
  358.         cmp ebx,[Picture_SizeY]
  359.         jl no_max_pos_y
  360.         mov ebx,[Picture_SizeY]
  361.         no_max_pos_y:
  362.  
  363.         cmp eax,ecx
  364.         ja no_min_pos_x
  365.         mov eax,[Brush_SizeX]
  366.         no_min_pos_x:
  367.  
  368.         cmp ebx,edx
  369.         ja no_min_pos_y
  370.         mov ebx,[Brush_SizeY]
  371.         no_min_pos_y:
  372.  
  373.         sub eax,[Brush_SizeX]
  374.         sub ebx,[Brush_SizeY]
  375.  
  376.         mov [x],eax
  377.         mov [y],ebx
  378.  
  379.         mov al,[exit_from_work_arrea]
  380.         test al,al
  381.         jz no_exit_from_work_arrea_brush
  382.         and [Activate_instrument],0
  383.         and [exit_from_work_arrea],0
  384.         no_exit_from_work_arrea_brush:
  385.  
  386.         mov al,[Activate_instrument]
  387.         test al,al
  388.         jnz no_new_brush_xy
  389.         mov eax,[x]
  390.         mov ebx,[y]
  391.         mov [OldX],eax
  392.         mov [OldY],ebx
  393.         mov [Activate_instrument],1
  394.         no_new_brush_xy:
  395.  
  396.         mov eax,[PointerToPicture]
  397.         mov ebx,[ReserveArray]
  398.         add ebx,4
  399.         mov ecx,[Picture_SizeX]
  400.         mov edx,[OldX]
  401.         shl edx,16
  402.         add edx,[OldY]
  403.         mov esi,[x]
  404.         mov edi,[y]
  405.  
  406.         call calculate_line
  407.  
  408.         mov ebx,[ReserveArray]
  409.         mov [ebx],eax
  410.  
  411.         ;procedure drawing of brush
  412.         mov ebx,[ReserveArray]
  413.         mov ecx,[ebx]
  414.         mov edx,[Color]
  415.         mov esi,[Color]
  416.         shr edx,16
  417.         add ebx,4
  418.         mov edi,[Number_Brush]
  419.         imul edi,20*20
  420.  
  421.         next_pixel_put_brush:
  422.  
  423.         mov eax,[ebx]
  424.         push eax
  425.         push ecx
  426.         xor ebp,ebp
  427.         and [counter2],0
  428.  
  429.         vertical_width_brush:
  430.            and [counter],0
  431.  
  432.            horizontal_width_brush:
  433.            xor ecx,ecx
  434.            mov cl,byte[Brush_color+edi+ebp]
  435.            test cl,cl
  436.              jz no_draw_pixel_brush
  437.               mov [eax],si
  438.               mov [eax+2],dl
  439.              no_draw_pixel_brush:
  440.            add eax,3
  441.            inc ebp
  442.            inc [counter]
  443.            cmp [counter],20
  444.            jne horizontal_width_brush
  445.  
  446.            mov ecx,[Picture_SizeX]
  447.            sub ecx,20
  448.            lea ecx,[ecx+ecx*2]
  449.            add eax,ecx
  450.         inc [counter2]
  451.         cmp [counter2],20
  452.         jne vertical_width_brush
  453.  
  454.         pop ecx
  455.         pop eax
  456.         add ebx,4
  457.         dec ecx
  458.         jnz next_pixel_put_brush
  459.  
  460.         mov eax,[x]
  461.         mov ebx,[y]
  462.         mov [OldX],eax
  463.         mov [OldY],ebx
  464.  
  465.         mov al,[lastik_is_active]
  466.         test al,al
  467.         jz no_lastik_active
  468.  
  469.         mov eax,[SColor]
  470.         mov [Color],eax
  471.         and [lastik_is_active],0
  472.         no_lastik_active:
  473.  
  474.         call MovePictureToWorkScreen
  475.         mov eax,[Current_instrument]
  476.         mov [Last_instrument],eax
  477.  
  478.         jmp still
  479.         no_brush:
  480.  
  481.         ;************************Flood Fill*********************
  482.         cmp eax,14
  483.         jne no_FloodFill
  484.  
  485.         mov eax,[PointerToPicture]
  486.         mov ebx,[PointerToEditBufer]
  487.  
  488.         mov ecx,[Picture_SizeX]
  489.         imul ecx,[Picture_SizeY]
  490.         lea ecx,[ecx+ecx*2]
  491.         shl ecx,1
  492.  
  493.         cmp ecx,mem_flood_f
  494.         ja normal_size_of_bufer
  495.  
  496.         mov ebx,[ReserveArray]
  497.  
  498.         normal_size_of_bufer:
  499.  
  500.         add ebx,4
  501.         mov ecx,[Picture_SizeX]
  502.         mov edx,[ScreenX]
  503.         add edx,[PosX]
  504.         shl edx,16
  505.         add edx,[ScreenY]
  506.         add edx,[PosY]
  507.         mov esi,[Picture_SizeX]
  508.         dec esi
  509.         shl esi,16
  510.         add esi,[Picture_SizeY]
  511.         dec esi
  512.         mov edi,[Color]
  513.  
  514.         call flood_fill
  515.         call MovePictureToWorkScreen
  516.  
  517.         jmp still
  518.         no_FloodFill:
  519.  
  520.         ;************************lastik*************************
  521.         cmp eax,13
  522.         jne no_lastik
  523.  
  524.          mov [Last_instrument],eax
  525.          mov [lastik_is_active],1
  526.         jmp lastik_in
  527.  
  528.         no_lastik:
  529.  
  530.         ;*******************************************************
  531.         cmp eax,12
  532.         jne  no_spray
  533.  
  534.         cmp [Activate_instrument],0
  535.         jne no_null_spray
  536.         mov [Activate_instrument],1
  537.         jmp still
  538.         no_null_spray:
  539.  
  540.         mov eax,[ScreenX]
  541.         mov ebx,[ScreenY]
  542.         mov ecx,[Brush_SizeX]
  543.         mov edx,[Brush_SizeY]
  544.         add eax,[PosX]
  545.         add ebx,[PosY]
  546.         add eax,ecx
  547.         add ebx,edx
  548.  
  549.         cmp eax,[Picture_SizeX]
  550.         jl no_max_pos_x_spray
  551.         mov eax,[Picture_SizeX]
  552.         no_max_pos_x_spray:
  553.  
  554.         cmp ebx,[Picture_SizeY]
  555.         jl no_max_pos_y_spray
  556.         mov ebx,[Picture_SizeY]
  557.         no_max_pos_y_spray:
  558.  
  559.         cmp eax,ecx
  560.         ja no_min_pos_x_spray
  561.         mov eax,[Brush_SizeX]
  562.         no_min_pos_x_spray:
  563.  
  564.         cmp ebx,edx
  565.         ja no_min_pos_y_spray
  566.         mov ebx,[Brush_SizeY]
  567.         no_min_pos_y_spray:
  568.  
  569.         sub eax,[Brush_SizeX]
  570.         sub ebx,[Brush_SizeY]
  571.         mov edi,0;[Number_Brush]
  572.         imul edi,20*20
  573.  
  574.         mov [x],eax
  575.         mov [y],ebx
  576.         mov ebp,[Picture_SizeX]
  577.         xor edx,edx
  578.         brush_y_spray:
  579.           xor ecx,ecx
  580.           brush_x_spray:
  581.            ;calculate position in array of spray
  582.            mov esi,edx
  583.            lea esi,[esi+esi*4] ;esi=esi*5
  584.            shl esi,2           ;esi=(esi*3)*4
  585.            add esi,ecx
  586.            add esi,edi
  587.            ;read byte from array
  588.            xor eax,eax
  589.            mov al,[Spray_color+esi]
  590.            test eax,eax
  591.            jz no_color_spray
  592.            mov eax,[x]
  593.            mov ebx,[y]
  594.            add eax,ecx
  595.            add ebx,edx
  596.            imul ebx,ebp; ebp=[Picture_SizeX]
  597.            add eax,ebx
  598.            lea eax,[eax+eax*2]
  599.            add eax,[PointerToPicture]
  600.            mov ebx,[Color]
  601.            mov [eax],bx
  602.            shr ebx,16
  603.            mov [eax+2],bl
  604.            no_color_spray:
  605.            inc ecx
  606.            cmp ecx,20
  607.           jl brush_x_spray
  608.         inc edx
  609.         cmp edx,20
  610.         jl brush_y_spray
  611.  
  612.         call MovePictureToWorkScreen
  613.         jmp still
  614.  
  615.         no_spray:
  616.  
  617.         ;************************palette************************
  618.         cmp eax,51
  619.         jne no_palette
  620.  
  621.         mov eax,20
  622.         mov ebx,ci_palete_y_pos
  623.         mov ecx,32*10+32*5+7
  624.         mov edx,140
  625.         mov  esi,1
  626.         call draw_volume_rectangle
  627.         mov [x],20+5
  628.         mov [y],ci_palete_y_pos+10
  629.         mov edi,256
  630.         xor esi,esi
  631.         next_rectangle:
  632.         mov ebx,[x]
  633.         mov ecx,[y]
  634.         mov edx,[palitra+esi]
  635.         and edx,0xffffff
  636.         shl ebx,16
  637.         shl ecx,16
  638.         add ebx,13
  639.         add ecx,13
  640.         mcall SF_DRAW_RECT
  641.         add [x],15
  642.         cmp [x],20+15*32
  643.         jl no_new_line
  644.         mov [x],20+5
  645.         add [y],15
  646.         no_new_line:
  647.         add esi,4
  648.         dec edi
  649.         jnz next_rectangle
  650.  
  651.         wait_events:
  652.         call event
  653.  
  654.         cmp eax,1
  655.         je still
  656.  
  657.         cmp eax,2
  658.         jne no_keys
  659.  
  660.         mcall SF_GET_KEY
  661.  
  662.         no_keys:
  663.  
  664.         cmp eax,3
  665.         jne no_buttons
  666.         mcall SF_GET_BUTTON
  667.  
  668.         no_buttons:
  669.  
  670.         cmp eax,6
  671.         jne wait_events
  672.  
  673.         call GetMouseClick
  674.  
  675.         test eax,eax
  676.         jz wait_events
  677.         call GetMouseCoordinats
  678.         mov [x],20+5
  679.         mov [y],ci_palete_y_pos+10
  680.         mov [counter],0
  681.         next_rectangle_column:
  682.         mov eax,[x]
  683.         mov ebx,[y]
  684.         mov ecx,[MouseX]
  685.         mov edx,[MouseY]
  686.         mov esi,13
  687.         mov edi,13
  688.         call columnus
  689.         test eax,eax
  690.         jz no_columnus_color
  691.  
  692.         mov eax,[counter]
  693.         shl eax,2
  694.         mov ebx,[palitra+eax]
  695.         and ebx,0xffffff
  696.         mov [Color],ebx
  697.         no_columnus_color:
  698.  
  699.         add [x],15
  700.  
  701.         cmp [x],20+15*32
  702.         jl no_new_line_column
  703.  
  704.         mov [x],20+5
  705.         add [y],15
  706.         no_new_line_column:
  707.  
  708.         inc [counter]
  709.  
  710.         cmp [counter],257
  711.         jne next_rectangle_column
  712.  
  713.         mcall SF_SLEEP,10
  714.  
  715.         call drawwin
  716.  
  717.         mov eax,[Last_instrument]
  718.         mov [Current_instrument],eax
  719.  
  720.         jmp still
  721.         no_palette:
  722.  
  723.         ;************************draw line**********************
  724.         cmp eax,16
  725.         jne no_line
  726.  
  727.         mov [Last_instrument],eax
  728.  
  729.         mov al,[Activate_instrument]
  730.         test al,al
  731.         jnz no_new_line_xy
  732.         mov eax,[ScreenX]
  733.         mov ebx,[ScreenY]
  734.         add eax,[PosX]
  735.         add ebx,[PosY]
  736.         mov [OldX],eax
  737.         mov [OldY],ebx
  738.         mov [Activate_instrument],1
  739.         xor eax,eax
  740.         mov ecx,mem_flood_f/4
  741.         mov edi,[ReserveArray]
  742.         rep stosd
  743.         jmp still
  744.         no_new_line_xy:
  745.  
  746.         ;put saved pixels
  747.         square_width_put
  748.  
  749.         ;calculate line
  750.         mov ebx,[ReserveArray]
  751.         add ebx,4
  752.         mov eax,[PointerToPicture]
  753.         mov ecx,[Picture_SizeX]
  754.         mov edx,[OldX]
  755.         shl edx,16
  756.         add edx,[OldY]
  757.         mov esi,[ScreenX]
  758.         mov edi,[ScreenY]
  759.         add esi,[PosX]
  760.         add edi,[PosY]
  761.  
  762.         mov ebp,[Picture_SizeX]
  763.         sub ebp,[line_width]
  764.         cmp esi,ebp
  765.         jl no_minimum_x_line
  766.         mov esi,ebp
  767.         no_minimum_x_line:
  768.  
  769.         mov ebp,[Picture_SizeY]
  770.         sub ebp,[line_width]
  771.         cmp edi,ebp
  772.         jl no_minimum_y_line
  773.         mov edi,ebp
  774.         no_minimum_y_line:
  775.  
  776.         call calculate_line
  777.  
  778.         ;save color pixels in ReserveArray
  779.         square_width_save
  780.  
  781.         ;draw calculated pixels on work arrea
  782.         draw_calc_pixels width_pixels
  783.  
  784.         call MovePictureToWorkScreen
  785.         jmp still
  786.         no_line:
  787.  
  788.         ;************************draw rectangle*****************
  789.         cmp eax,17
  790.         jne no_rectangle
  791.  
  792.         mov [Last_instrument],eax
  793.  
  794.         mov al,[Activate_instrument]
  795.         test al,al
  796.         jnz no_new_rectangle_xy
  797.         mov eax,[ScreenX]
  798.         mov ebx,[ScreenY]
  799.         add eax,[PosX]
  800.         add ebx,[PosY]
  801.         mov [OldX],eax
  802.         mov [OldY],ebx
  803.         mov [Activate_instrument],1
  804.         xor eax,eax
  805.         mov ecx,mem_flood_f/4
  806.         mov edi,[ReserveArray]
  807.         rep stosd
  808.         jmp still
  809.         no_new_rectangle_xy:
  810.  
  811.         ;put saved pixels
  812.         square_width_put
  813.  
  814.         ;calculate line
  815.         mov ebx,[ReserveArray]
  816.         add ebx,4
  817.         mov eax,[PointerToPicture]
  818.         mov ecx,[Picture_SizeX]
  819.         mov edx,[OldX]
  820.         shl edx,16
  821.         add edx,[OldY]
  822.         mov esi,[ScreenX]
  823.         mov edi,[ScreenY]
  824.         add esi,[PosX]
  825.         add edi,[PosY]
  826.  
  827.         mov ebp,[Picture_SizeX]
  828.         sub ebp,[line_width]
  829.         cmp esi,ebp
  830.         jl no_minimum_x_rectangle
  831.         mov esi,ebp
  832.         no_minimum_x_rectangle:
  833.  
  834.         mov ebp,[Picture_SizeY]
  835.         sub ebp,[line_width]
  836.         cmp edi,ebp
  837.         jl no_minimum_y_rectangle
  838.         mov edi,ebp
  839.         no_minimum_y_rectangle:
  840.  
  841.         call calculate_rectangle
  842.  
  843.         ;save color pixels in ReserveArray
  844.         square_width_save
  845.  
  846.         ;draw calculated pixels on work arrea
  847.         draw_calc_pixels width_pixels_rectangle
  848.  
  849.         call MovePictureToWorkScreen
  850.         jmp still
  851.         no_rectangle:
  852.  
  853.         ;************************draw circle********************
  854.         cmp eax,18
  855.         jne no_circle
  856.  
  857.         mov [Last_instrument],eax
  858.  
  859.         mov al,[Activate_instrument]
  860.         test al,al
  861.         jnz no_new_circle_xy
  862.         mov eax,[ScreenX]
  863.         mov ebx,[ScreenY]
  864.         add eax,[PosX]
  865.         add ebx,[PosY]
  866.         mov [OldX],eax
  867.         mov [OldY],ebx
  868.         mov [Activate_instrument],1
  869.         xor eax,eax
  870.         mov ecx,mem_flood_f/4
  871.         mov edi,[ReserveArray]
  872.         rep stosd
  873.         jmp still
  874.         no_new_circle_xy:
  875.  
  876.         ;put saved pixels
  877.         square_width_put
  878.  
  879.         mov esi,[ScreenX]
  880.         mov edi,[ScreenY]
  881.         add esi,[PosX]
  882.         add edi,[PosY]
  883.  
  884.         sub esi,[OldX]
  885.         jns no_sign_x_circle
  886.         neg esi
  887.         shr esi,1
  888.         neg esi
  889.         add esi,[OldX]
  890.         jmp no_plus_sign_x_circle
  891.         no_sign_x_circle:
  892.  
  893.         shr esi,1
  894.         add esi,[OldX]
  895.         no_plus_sign_x_circle:
  896.  
  897.         sub edi,[OldY]
  898.         jns no_sign_y_circle
  899.         neg edi
  900.         shr edi,1
  901.         neg edi
  902.         add edi,[OldY]
  903.         jmp no_plus_sign_y_circle
  904.         no_sign_y_circle:
  905.  
  906.         shr edi,1
  907.         add edi,[OldY]
  908.         no_plus_sign_y_circle:
  909.  
  910.         mov [x],esi
  911.         mov [y],edi
  912.  
  913.         mov esi,[ScreenX]
  914.         mov edi,[ScreenY]
  915.         add esi,[PosX]
  916.         add edi,[PosY]
  917.  
  918.         sub esi,[OldX]
  919.         jns no_sign_x_circle_r
  920.         neg esi
  921.         no_sign_x_circle_r:
  922.  
  923.         sub edi,[OldY]
  924.         jns no_sign_y_circle_r
  925.         neg edi
  926.         no_sign_y_circle_r:
  927.  
  928.         mov [Dx_],esi
  929.         mov [Dy_],edi
  930.  
  931.         ;finit
  932.         fild [Dx_]
  933.         fmul st0,st0
  934.         fild [Dy_]
  935.         fmul st0,st0
  936.         fadd st0,st1
  937.         fsqrt
  938.         fistp [Radius]
  939.         fistp [Icon_X]
  940.         mov esi,[Radius]
  941.         shr esi,1
  942.         cmp esi,0
  943.         jne no_null_radius
  944.         mov [Radius],1
  945.         no_null_radius:
  946.  
  947.         mov [Radius],esi
  948.  
  949.         mov edi,[x]
  950.         mov ebp,[y]
  951.         add edi,esi
  952.         add ebp,esi
  953.  
  954.         mov edx,[Picture_SizeX]
  955.         sub edx,[line_width]
  956.         cmp edi,edx
  957.         jl no_limit_x_circle
  958.         sub edi,edx
  959.         sub [Radius],edi
  960.         no_limit_x_circle:
  961.  
  962.         mov edx,[Picture_SizeY]
  963.         sub edx,[line_width]
  964.         cmp ebp,edx
  965.         jl no_limit_y_circle
  966.         sub ebp,edx
  967.         sub [Radius],ebp
  968.         no_limit_y_circle:
  969.  
  970.  
  971.         mov edi,[x]
  972.         mov ebp,[y]
  973.  
  974.         sub edi,[Radius]
  975.         jns no_minimum_x_circle
  976.         add [Radius],edi
  977.         no_minimum_x_circle:
  978.  
  979.         sub ebp,[Radius]
  980.         jns no_minimum_y_circle
  981.         add [Radius],ebp
  982.         no_minimum_y_circle:
  983.  
  984.         ;calculate circle
  985.         mov ebx,[ReserveArray]
  986.         add ebx,4
  987.         mov eax,[PointerToPicture]
  988.         mov ecx,[Picture_SizeX]
  989.         mov edx,[x]
  990.         shl edx,16
  991.         add edx,[y]
  992.         mov esi,[Radius]
  993.         call calculate_circle
  994.  
  995.         ;save color pixels in ReserveArray
  996.         square_width_save
  997.  
  998.         ;draw calculated pixels on work arrea
  999.         draw_calc_pixels width_pixels
  1000.  
  1001.         call MovePictureToWorkScreen
  1002.         jmp still
  1003.         no_circle:
  1004.  
  1005.         ;************************zoom 1*************************
  1006.         cmp eax,45
  1007.         jne no_1_
  1008.         mov [k],1
  1009.         call scrollbar_move_00
  1010.         and [Current_instrument],0
  1011.         call drawwin
  1012.         jmp still
  1013.         no_1_:
  1014.  
  1015.         ;************************zoom 2*************************
  1016.         cmp eax,46
  1017.         jne no_2_
  1018.         mov [k],2
  1019.         call drawwin
  1020.         call scrollbar_move_00
  1021.         and [Current_instrument],0
  1022.         jmp still
  1023.         no_2_:
  1024.  
  1025.  
  1026.         ;************************zoom 3*************************
  1027.         cmp eax,47
  1028.         jne no_3_
  1029.         mov [k],3
  1030.         call drawwin
  1031.         call scrollbar_move_00
  1032.         and [Current_instrument],0
  1033.         jmp still
  1034.         no_3_:
  1035.  
  1036.         ;************************zoom 4*************************
  1037.         cmp eax,48
  1038.         jne no_4_
  1039.         mov [k],4
  1040.         call drawwin
  1041.         call scrollbar_move_00
  1042.         and [Current_instrument],0
  1043.         jmp still
  1044.         no_4_:
  1045.  
  1046.         ;************************zoom 8*************************
  1047.         cmp eax,49
  1048.         jne no_8_
  1049.         mov [k],8
  1050.         call drawwin
  1051.         call scrollbar_move_00
  1052.         and [Current_instrument],0
  1053.         jmp still
  1054.         no_8_:
  1055.  
  1056.         ;************************zoom 16************************
  1057.         cmp eax,50
  1058.         jne no_16_
  1059.         mov [k],16
  1060.         call drawwin
  1061.         call scrollbar_move_00
  1062.         and [Current_instrument],0
  1063.         jmp still
  1064.         no_16_:
  1065.  
  1066.         ;***************allocation of a countour****************
  1067.         cmp eax,21
  1068.         jne no_allocation
  1069.  
  1070.         cmp [instrument_used],0
  1071.         jnz instrument_not_finished_work
  1072.  
  1073.         mov al,[Activate_instrument]
  1074.         test al,al
  1075.         jnz no_new_allocation_xy
  1076.         mov eax,[ScreenX]
  1077.         mov ebx,[ScreenY]
  1078.         add eax,[PosX]
  1079.         add ebx,[PosY]
  1080.         mov [OldX],eax
  1081.         mov [OldY],ebx
  1082.         inc eax
  1083.         inc ebx
  1084.         mov [rectangular_shade_x],eax
  1085.         mov [rectangular_shade_y],ebx
  1086.         mov [Activate_instrument],1
  1087.         mov [instrument_used],1
  1088.         and [crossing],0
  1089.         and [finishing_crossing],0
  1090.         xor eax,eax
  1091.         mov ecx,mem_flood_f/4
  1092.         mov edi,[ReserveArray]
  1093.         rep stosd
  1094.         jmp still
  1095.         no_new_allocation_xy:
  1096.         instrument_not_finished_work:
  1097.  
  1098.         mov al,[instrument_used]
  1099.         test al,al
  1100.         jz no_change_coordinats
  1101.  
  1102.         cmp [Activate_instrument],0
  1103.         jnz no_change_coordinats
  1104.  
  1105.         ;save coordinates as old if crossing=0
  1106.         cmp [crossing],0
  1107.         jnz no_save_coordinate_of_crossing
  1108.  
  1109.         mov eax,[OldX]
  1110.         mov ebx,[OldY]
  1111.  
  1112.         cmp eax,[rectangular_shade_x]
  1113.         jl no_remove_x
  1114.         mov ecx,[rectangular_shade_x]
  1115.         mov [OldX],ecx                    ; OldX <-----> rectangulare_shade_x
  1116.         mov [rectangular_shade_x],eax
  1117.         no_remove_x:
  1118.  
  1119.         cmp ebx,[rectangular_shade_y]
  1120.         jl no_remove_y
  1121.         mov ecx,[rectangular_shade_y]
  1122.         mov [OldY],ecx                    ; OldY <-----> rectangulare_shade_y
  1123.         mov [rectangular_shade_y],ebx
  1124.         no_remove_y:
  1125.  
  1126.         mov eax,[ScreenX]
  1127.         mov ebx,[ScreenY]
  1128.         add eax,[PosX]
  1129.         add ebx,[PosY]
  1130.         mov [crossing_old_x],eax
  1131.         mov [crossing_old_y],ebx
  1132.         mov [crossing],1
  1133.  
  1134.  
  1135.         mov eax,[OldX]
  1136.         mov ebx,[OldY]
  1137.         inc eax
  1138.         inc ebx
  1139.         mov [SpriteCoordinatX],eax
  1140.         mov [SpriteCoordinatY],ebx
  1141.         mov [SpriteOldCoordinatX],eax
  1142.         mov [SpriteOldCoordinatY],ebx
  1143.         mov esi,[rectangular_shade_x]
  1144.         mov edi,[rectangular_shade_y]
  1145.  
  1146.         sub esi,eax
  1147.         jns no_sign_sprite_size_x
  1148.         neg esi
  1149.         no_sign_sprite_size_x:
  1150.  
  1151.         sub edi,ebx
  1152.         jns no_sign_sprite_size_y
  1153.         neg edi
  1154.         no_sign_sprite_size_y:
  1155.  
  1156.         test esi,esi
  1157.         jnz no_null_sprite_x
  1158.         mov esi,1
  1159.         no_null_sprite_x:
  1160.  
  1161.         test edi,edi
  1162.         jnz no_null_sprite_y
  1163.         mov edi,1
  1164.         no_null_sprite_y:
  1165.  
  1166.         mov [SpriteSizeX],esi
  1167.         mov [SpriteSizeY],edi
  1168.  
  1169.         call SaveFonForSprite
  1170.  
  1171.         no_save_coordinate_of_crossing:
  1172.  
  1173.         cmp [crossing],0
  1174.         je no_test_crossing_with_work_arrea
  1175.         ;if mouse situatad after allocation than exit
  1176.         push [ScreenX]
  1177.         push [ScreenY]
  1178.  
  1179.         call GetScreenCordinats
  1180.  
  1181.         mov eax,[OldX]
  1182.         mov ebx,[OldY]
  1183.         mov ecx,[ScreenX]
  1184.         mov edx,[ScreenY]
  1185.         mov esi,[SpriteSizeX]
  1186.         mov edi,[SpriteSizeY]
  1187.         add ecx,[PosX]
  1188.         add edx,[PosY]
  1189.         inc esi;eax
  1190.         inc edi;ebx
  1191.         call columnus
  1192.  
  1193.         test eax,eax
  1194.         jnz crossing_with_work_area
  1195.         mov [finishing_crossing],1
  1196.         mov [register],1
  1197.         crossing_with_work_area:
  1198.  
  1199.         pop [ScreenY]
  1200.         pop [ScreenX]
  1201.  
  1202.         no_test_crossing_with_work_arrea:
  1203.  
  1204.         mov eax,[ScreenX]
  1205.         mov ebx,[ScreenY]
  1206.         add eax,[PosX]
  1207.         add ebx,[PosY]
  1208.         mov ecx,eax
  1209.         mov edx,ebx
  1210.         sub eax,[crossing_old_x]  ;dx=(x-oldx)
  1211.         sub ebx,[crossing_old_y]  ;dy=(y-oldy)
  1212.         mov [crossing_old_x],ecx
  1213.         mov [crossing_old_y],edx
  1214.  
  1215.         add [OldX],eax                 ;x1=x1+dx
  1216.         add [OldY],ebx                 ;y1=y1+dy
  1217.         add [rectangular_shade_x],eax  ;x2=x2+dx
  1218.         add [rectangular_shade_y],ebx  ;y2+y2+dy
  1219.  
  1220.         mov eax,[OldX]
  1221.         mov ebx,[OldY]
  1222.         inc eax
  1223.         inc ebx
  1224.         mov [SpriteCoordinatX],eax
  1225.         mov [SpriteCoordinatY],ebx
  1226.  
  1227.         cmp [SpriteCoordinatX],0
  1228.         jns no_null_sprite_coordinat_x
  1229.         mov [SpriteCoordinatX],1
  1230.         no_null_sprite_coordinat_x:
  1231.  
  1232.         cmp [SpriteCoordinatY],0
  1233.         jns no_null_sprite_coordinat_y
  1234.         mov [SpriteCoordinatY],1
  1235.         no_null_sprite_coordinat_y:
  1236.  
  1237.         mov esi,[rectangular_shade_x]
  1238.         mov edi,[rectangular_shade_y]
  1239.  
  1240.         sub esi,[OldX]
  1241.         jns no_znak_size_of_rectangulare_crossing_x
  1242.         neg esi
  1243.         no_znak_size_of_rectangulare_crossing_x:
  1244.  
  1245.         sub edi,[OldY]
  1246.         jns no_znak_size_of_rectangulare_crossing_y
  1247.         neg edi
  1248.         no_znak_size_of_rectangulare_crossing_y:
  1249.  
  1250.         mov ecx,[OldX]
  1251.         mov edx,[OldY]
  1252.  
  1253.         sub ecx,[PosX]
  1254.         jns no_minimum_x_crossing
  1255.         mov ecx,0
  1256.         add ecx,[PosX]
  1257.         mov [OldX],ecx
  1258.         add ecx,esi
  1259.         mov [rectangular_shade_x],ecx
  1260.         no_minimum_x_crossing:
  1261.  
  1262.         sub edx,[PosY]
  1263.         jns no_minimum_y_crossing
  1264.         mov edx,0
  1265.         add edx,[PosY]
  1266.         mov [OldY],edx
  1267.         add edx,edi
  1268.         mov [rectangular_shade_y],edx
  1269.         no_minimum_y_crossing:
  1270.  
  1271.         mov ecx,[Picture_SizeX]
  1272.         sub ecx,esi
  1273.         cmp [OldX],ecx
  1274.         jl no_maximum_x_crossing
  1275.         dec ecx
  1276.         mov [OldX],ecx
  1277.         add ecx,esi
  1278.         mov [rectangular_shade_x],ecx
  1279.         no_maximum_x_crossing:
  1280.  
  1281.         mov edx,[Picture_SizeY]
  1282.         sub edx,edi
  1283.         cmp [OldY],edx
  1284.         jl no_maximum_y_crossing
  1285.         dec edx
  1286.         mov [OldY],edx
  1287.         add edx,edi
  1288.         mov [rectangular_shade_y],edx
  1289.         no_maximum_y_crossing:
  1290.  
  1291.         mov eax,[rectangular_shade_x]
  1292.         mov ebx,[rectangular_shade_y]
  1293.         sub eax,[PosX]
  1294.         sub ebx,[PosY]
  1295.         mov [ScreenX],eax
  1296.         mov [ScreenY],ebx
  1297.         no_change_coordinats:
  1298.  
  1299.         ;put saved pixels
  1300.         square_width_put
  1301.  
  1302.         cmp [DrawSprite_flag],1
  1303.         jne no_activate_put_fon_
  1304.  
  1305.         cmp [Paste_flag],1
  1306.         je no_put_fon___
  1307.         call PutFonForSprite
  1308.         no_put_fon___:
  1309.         and [Paste_flag],0
  1310.         no_activate_put_fon_:
  1311.  
  1312.         cmp [finishing_crossing],0
  1313.         jz not_finish_from_instrument_crossing
  1314.         and [Activate_instrument],0
  1315.         and [crossing],0
  1316.         and [instrument_used],0
  1317.         and [DrawSprite_flag],0
  1318.         call MovePictureToWorkScreen
  1319.         jmp still
  1320.         not_finish_from_instrument_crossing:
  1321.  
  1322.         ;calculate line
  1323.         mov ebx,[ReserveArray]
  1324.         add ebx,4
  1325.         mov eax,[PointerToPicture]
  1326.         mov ecx,[Picture_SizeX]
  1327.         mov edx,[OldX]
  1328.         shl edx,16
  1329.         add edx,[OldY]
  1330.         mov esi,[ScreenX]
  1331.         mov edi,[ScreenY]
  1332.         add esi,[PosX]
  1333.         add edi,[PosY]
  1334.  
  1335.         mov ebp,[Picture_SizeX]
  1336.         dec ebp
  1337.         cmp esi,ebp
  1338.         jl no_minimum_x_allocation
  1339.         mov esi,ebp
  1340.         no_minimum_x_allocation:
  1341.  
  1342.         mov ebp,[Picture_SizeY]
  1343.         dec ebp
  1344.         cmp edi,ebp
  1345.         jl no_minimum_y_allocation
  1346.         mov edi,ebp
  1347.         no_minimum_y_allocation:
  1348.  
  1349.         call calculate_rectangle
  1350.  
  1351.         ;save color pixels in ReserveArray
  1352.         square_width_save
  1353.  
  1354.         cmp [DrawSprite_flag],1
  1355.         jne no_save_fon_for_sprite_
  1356.         ;save current coordinats as old
  1357.         mov eax,[SpriteCoordinatX]
  1358.         mov ebx,[SpriteCoordinatY]
  1359.         mov [SpriteOldCoordinatX],eax
  1360.         mov [SpriteOldCoordinatY],ebx
  1361.  
  1362.         call SaveFonForSprite
  1363.  
  1364.         no_save_fon_for_sprite_:
  1365.  
  1366.         ;draw calculated pixels on work arrea
  1367.         mov ebx,[ReserveArray]
  1368.         mov ecx,[ebx]
  1369.         add ebx,4
  1370.         next_pixel_put_allocation:
  1371.  
  1372.         mov edx,0x1f3fff
  1373.         mov esi,edx
  1374.         shr edx,16
  1375.  
  1376.         mov ebp,ecx
  1377.         and ebp,8
  1378.         cmp ebp,8
  1379.         jne black_color
  1380.         mov si,0xffff
  1381.         mov dl,0xff
  1382.         black_color:
  1383.  
  1384.         mov eax,[ebx]
  1385.         mov [eax],si
  1386.         mov [eax+2],dl
  1387.  
  1388.         add ebx,4
  1389.         dec ecx
  1390.         jnz next_pixel_put_allocation
  1391.  
  1392.         cmp [DrawSprite_flag],1
  1393.         jne no_activate_draw_sprite_
  1394.  
  1395.         call DrawSprite
  1396.  
  1397.         no_activate_draw_sprite_:
  1398.  
  1399.         mov al,[instrument_used]
  1400.         test al,al
  1401.         jz no_change_coordinats
  1402.         cmp [Activate_instrument],0
  1403.         jz no_save_shades
  1404.         mov eax,[ScreenX]
  1405.         mov ebx,[ScreenY]
  1406.         add eax,[PosX]
  1407.         add ebx,[PosY]
  1408.         mov [rectangular_shade_x],eax
  1409.         mov [rectangular_shade_y],ebx
  1410.         no_save_shades:
  1411.  
  1412.         call MovePictureToWorkScreen
  1413.         jmp still
  1414.         no_allocation:
  1415.  
  1416.         ;*************reflection from left to right*************
  1417.         cmp eax,23
  1418.         jne no_reflection_from_left_to_right
  1419.  
  1420.         mov ebp,[PointerToPicture]
  1421.         mov edx,[ReserveArray]
  1422.         mov esi,[Picture_SizeX]
  1423.         mov ebx,[Picture_SizeX]
  1424.         lea ebx,[ebx+ebx*2]
  1425.         shr esi,1
  1426.         next_line_reflection_x:
  1427.         ;copy vertical line to array
  1428.         mov ecx,[Picture_SizeX]
  1429.         shr ecx,1
  1430.         sub ecx,esi
  1431.         lea ecx,[ecx+ecx*2]
  1432.         add ecx,[PointerToPicture]
  1433.         mov edx,[ReserveArray]
  1434.         and edi,0
  1435.         copy_to_array_line_reflection_y:
  1436.         mov eax,[ecx]
  1437.         mov ebp,edi
  1438.         lea ebp,[ebp+ebp*2]
  1439.         mov [edx+ebp],ax
  1440.         shr eax,16
  1441.         mov [edx+ebp+2],al
  1442.         add ecx,ebx
  1443.         inc edi
  1444.         cmp edi,[Picture_SizeY]
  1445.         jne copy_to_array_line_reflection_y
  1446.  
  1447.         mov ecx,[Picture_SizeX]
  1448.         shr ecx,1
  1449.         mov ebp,ecx
  1450.         add ecx,esi
  1451.         dec ecx
  1452.         lea ecx,[ecx+ecx*2]
  1453.         add ecx,[PointerToPicture]
  1454.         sub ebp,esi
  1455.         lea ebp,[ebp+ebp*2]
  1456.         add ebp,[PointerToPicture]
  1457.         and edi,0
  1458.         next_line_reflection_y:
  1459.         mov eax,[ecx]
  1460.         and eax,0xffffff
  1461.         mov [ebp],ax
  1462.         shr eax,16
  1463.         mov [ebp+2],al
  1464.         add ebp,ebx
  1465.         add ecx,ebx
  1466.         inc edi
  1467.         cmp edi,[Picture_SizeY]
  1468.         jnz next_line_reflection_y
  1469.  
  1470.         ;copy vertical line  from array to screen
  1471.         mov ecx,[Picture_SizeX]
  1472.         shr ecx,1
  1473.         add ecx,esi
  1474.         dec ecx
  1475.         lea ecx,[ecx+ecx*2]
  1476.         add ecx,[PointerToPicture]
  1477.         mov edx,[ReserveArray]
  1478.         and edi,0
  1479.         copy_from_array_to_screen_reflection_y:
  1480.         mov ebp,edi
  1481.         lea ebp,[ebp+ebp*2]
  1482.         xor eax,eax
  1483.         mov eax,[edx+ebp]
  1484.         mov [ecx],ax
  1485.         shr eax,16
  1486.         mov [ecx+2],al
  1487.         add ecx,ebx
  1488.         inc edi
  1489.         cmp edi,[Picture_SizeY]
  1490.         jne copy_from_array_to_screen_reflection_y
  1491.  
  1492.         dec esi
  1493.         jnz next_line_reflection_x
  1494.  
  1495.         call MovePictureToWorkScreen
  1496.         jmp still
  1497.         no_reflection_from_left_to_right:
  1498.  
  1499.         ;*************reflection from up to down****************
  1500.         cmp eax,24
  1501.         jne no_reflection_from_up_to_down
  1502.         mov esi,[Picture_SizeX]
  1503.         mov edi,esi
  1504.         lea esi,[esi+esi*2]
  1505.         lea edi,[edi+edi*2]
  1506.         imul edi,[Picture_SizeY]
  1507.         mov edx,[ReserveArray]
  1508.         mov ecx,[Picture_SizeY]
  1509.         shr ecx,1
  1510.         add edi,[PointerToPicture]
  1511.         sub edi,esi
  1512.         mov ebp,[PointerToPicture]
  1513.         next_lines_reflection:
  1514.         ;copy line
  1515.         xor ebx,ebx
  1516.         copy_line_1:
  1517.         xor eax,eax
  1518.         mov al,[edi+ebx]
  1519.         mov [edx+ebx],al
  1520.         inc ebx
  1521.         cmp ebx,esi
  1522.         jne copy_line_1
  1523.  
  1524.         xor ebx,ebx
  1525.         copy_line_2:
  1526.         xor eax,eax
  1527.         mov al,[ebp+ebx]
  1528.         mov [edi+ebx],al
  1529.         inc ebx
  1530.         cmp ebx,esi
  1531.         jne copy_line_2
  1532.  
  1533.         xor ebx,ebx
  1534.         copy_line_3:
  1535.         xor eax,eax
  1536.         mov al,[edx+ebx]
  1537.         mov [ebp+ebx],al
  1538.         inc ebx
  1539.         cmp ebx,esi
  1540.         jne copy_line_3
  1541.  
  1542.         add ebp,esi
  1543.         sub edi,esi
  1544.         dec ecx
  1545.         jnz next_lines_reflection
  1546.  
  1547.         call MovePictureToWorkScreen
  1548.         jmp still
  1549.         no_reflection_from_up_to_down:
  1550.  
  1551.         ;*********************draw hard contour*****************
  1552.         cmp eax,20
  1553.         jne no_kontur_
  1554.  
  1555.         mov [Last_instrument],eax
  1556.  
  1557.         mov al,[Activate_instrument]
  1558.         test al,al
  1559.         jnz no_new_konture_xy
  1560.  
  1561.         mov al,[instrument_used]
  1562.         test al,al
  1563.         jz instrument_not_used
  1564.         mov eax,[used_OldX]
  1565.         mov ebx,[used_OldY]
  1566.         mov [OldX],eax
  1567.         mov [OldY],ebx
  1568.         jmp exit_used_instrument
  1569.         instrument_not_used:
  1570.  
  1571.         mov eax,[ScreenX]
  1572.         mov ebx,[ScreenY]
  1573.         add eax,[PosX]
  1574.         add ebx,[PosY]
  1575.         mov [OldX],eax
  1576.         mov [OldY],ebx
  1577.         exit_used_instrument:
  1578.  
  1579.         mov al,[instrument_used]
  1580.         test al,al
  1581.         jnz instrument_used_true
  1582.         mov [instrument_used],byte 1
  1583.         instrument_used_true:
  1584.  
  1585.         mov [Activate_instrument],1
  1586.         xor eax,eax
  1587.         mov ecx,mem_flood_f/4
  1588.         mov edi,[ReserveArray]
  1589.         rep stosd
  1590.  
  1591.         no_new_konture_xy:
  1592.  
  1593.         ;put saved pixels
  1594.         square_width_put
  1595.  
  1596.         ;calculate line
  1597.         mov ebx,[ReserveArray]
  1598.         add ebx,4
  1599.         mov eax,[PointerToPicture]
  1600.         mov ecx,[Picture_SizeX]
  1601.         mov edx,[OldX]
  1602.         shl edx,16
  1603.         add edx,[OldY]
  1604.         mov esi,[ScreenX]
  1605.         mov edi,[ScreenY]
  1606.         add esi,[PosX]
  1607.         add edi,[PosY]
  1608.  
  1609.         mov ebp,[Picture_SizeX]
  1610.         sub ebp,[line_width]
  1611.         cmp esi,ebp
  1612.         jl no_minimum_x_konture
  1613.         mov esi,ebp
  1614.         no_minimum_x_konture:
  1615.  
  1616.         mov ebp,[Picture_SizeY]
  1617.         sub ebp,[line_width]
  1618.         cmp edi,ebp
  1619.         jl no_minimum_y_konture
  1620.         mov edi,ebp
  1621.         no_minimum_y_konture:
  1622.  
  1623.         call calculate_line
  1624.  
  1625.         ;save color pixels in ReserveArray
  1626.         square_width_save
  1627.  
  1628.         ;draw calculated pixels on work arrea
  1629.         draw_calc_pixels width_pixels
  1630.  
  1631.         mov eax,[ScreenX]
  1632.         mov ebx,[ScreenY]
  1633.         add eax,[PosX]
  1634.         add ebx,[PosY]
  1635.         mov [used_OldX],eax
  1636.         mov [used_OldY],ebx
  1637.  
  1638.         call MovePictureToWorkScreen
  1639.  
  1640.         jmp still
  1641.  
  1642.         no_kontur_:
  1643.         ;************************draw ellips********************
  1644.         cmp eax,19
  1645.         jne no_ellips
  1646.  
  1647.         mov [Last_instrument],eax
  1648.  
  1649.         mov al,[Activate_instrument]
  1650.         test al,al
  1651.         jnz no_new_ellips_xy
  1652.         mov eax,[ScreenX]
  1653.         mov ebx,[ScreenY]
  1654.         add eax,[PosX]
  1655.         add ebx,[PosY]
  1656.         mov [OldX],eax
  1657.         mov [OldY],ebx
  1658.         mov [Activate_instrument],1
  1659.         xor eax,eax
  1660.         mov ecx,mem_flood_f/4
  1661.         mov edi,[ReserveArray]
  1662.         rep stosd
  1663.         jmp still
  1664.         no_new_ellips_xy:
  1665.  
  1666.         ;put saved pixels
  1667.         square_width_put
  1668.  
  1669.  
  1670.         mov esi,[ScreenX]
  1671.         mov edi,[ScreenY]
  1672.         add esi,[PosX]
  1673.         add edi,[PosY]
  1674.  
  1675.         sub esi,[OldX]
  1676.         jns no_sign_x_ellips
  1677.         neg esi
  1678.         shr esi,1
  1679.         neg esi
  1680.         add esi,[OldX]
  1681.         jmp no_plus_sign_x_ellips
  1682.         no_sign_x_ellips:
  1683.  
  1684.         shr esi,1
  1685.         add esi,[OldX]
  1686.         no_plus_sign_x_ellips:
  1687.  
  1688.         sub edi,[OldY]
  1689.         jns no_sign_y_ellips
  1690.         neg edi
  1691.         shr edi,1
  1692.         neg edi
  1693.         add edi,[OldY]
  1694.         jmp no_plus_sign_y_ellips
  1695.         no_sign_y_ellips:
  1696.  
  1697.         shr edi,1
  1698.         add edi,[OldY]
  1699.         no_plus_sign_y_ellips:
  1700.  
  1701.         mov [x],esi
  1702.         mov [y],edi
  1703.  
  1704.         mov esi,[ScreenX]
  1705.         mov edi,[ScreenY]
  1706.         add esi,[PosX]
  1707.         add edi,[PosY]
  1708.  
  1709.         sub esi,[OldX]
  1710.         jns no_sign_x_ellips_r
  1711.         neg esi
  1712.         no_sign_x_ellips_r:
  1713.  
  1714.         sub edi,[OldY]
  1715.         jns no_sign_y_ellips_r
  1716.         neg edi
  1717.         no_sign_y_ellips_r:
  1718.  
  1719.         cmp edi,0
  1720.         jnz no_null_a_ellips
  1721.         mov edi,1
  1722.         no_null_a_ellips:
  1723.  
  1724.         shr esi,1
  1725.         shr edi,1
  1726.         mov [a_ellips],esi
  1727.         mov [b_ellips],edi
  1728.  
  1729.         mov edi,[x]
  1730.         mov ebp,[y]
  1731.         add edi,esi
  1732.         add ebp,esi
  1733.  
  1734.         mov edx,[Picture_SizeX]
  1735.         sub edx,[line_width]
  1736.         cmp edi,edx
  1737.         jl no_limit_x_ellips
  1738.         sub edi,edx
  1739.         sub [a_ellips],edi
  1740.         no_limit_x_ellips:
  1741.  
  1742.         mov edx,[Picture_SizeY]
  1743.         sub edx,[line_width]
  1744.         cmp ebp,edx
  1745.         jl no_limit_y_ellips
  1746.         sub ebp,edx
  1747.         sub [b_ellips],ebp
  1748.         no_limit_y_ellips:
  1749.  
  1750.  
  1751.         mov edi,[x]
  1752.         mov ebp,[y]
  1753.  
  1754.         sub edi,[a_ellips]
  1755.         jns no_minimum_x_ellips
  1756.         add [a_ellips],edi
  1757.         no_minimum_x_ellips:
  1758.  
  1759.         sub ebp,[b_ellips]
  1760.         jns no_minimum_y_ellips
  1761.         add [b_ellips],ebp
  1762.         no_minimum_y_ellips:
  1763.  
  1764.         ;calculate circle
  1765.         mov ebx,[ReserveArray]
  1766.         add ebx,4
  1767.         mov eax,[PointerToPicture]
  1768.         mov ecx,[Picture_SizeX]
  1769.         mov edx,[x]
  1770.         shl edx,16
  1771.         add edx,[y]
  1772.         mov esi,[a_ellips]
  1773.         shl esi,16
  1774.         add esi,[b_ellips]
  1775.         call calculate_ellips
  1776.  
  1777.         ;save color pixels in ReserveArray
  1778.         square_width_save
  1779.  
  1780.         ;draw calculated pixels on work arrea
  1781.         draw_calc_pixels width_pixels
  1782.  
  1783.         call MovePictureToWorkScreen
  1784.         jmp still
  1785.         no_ellips:
  1786.  
  1787.  
  1788.         jmp still
  1789.         ret