Subversion Repositories Kolibri OS

Rev

Rev 6352 | Rev 6355 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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