Subversion Repositories Kolibri OS

Rev

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