Subversion Repositories Kolibri OS

Rev

Rev 6379 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
255 heavyiron 1
;----------------------------------------------------------
2
;--------Move picture from array to work screeen-----------
3
;----------------------------------------------------------
4
MovePictureToWorkScreen:
1643 mario79 5
	call	cleare_screen
6
	mov	eax,[Picture_SizeX]
7
	mov	ebx,[Picture_SizeY]
8
	mov	ecx,[MaxWorkScreen_SizeX]
9
	mov	edx,[MaxWorkScreen_SizeY]
10
	mov	esi,[k]
11
	imul	eax,esi
12
	imul	ebx,esi
13
	cmp	eax,ecx
14
	jle	lab1
255 heavyiron 15
 
1643 mario79 16
	mov	eax,[MaxWorkScreen_SizeX]
17
	mov	[WorkScreen_SizeX],eax
18
	jmp	lab2
255 heavyiron 19
 
1643 mario79 20
lab1:
21
	mov	[WorkScreen_SizeX],eax
255 heavyiron 22
 
1643 mario79 23
lab2:
24
	cmp	ebx,edx
25
	jle	lab3
26
	mov	ebx,[MaxWorkScreen_SizeY]
27
	mov	[WorkScreen_SizeY],ebx
28
	jmp	lab4
255 heavyiron 29
 
1643 mario79 30
lab3:
31
	mov	[WorkScreen_SizeY],ebx
255 heavyiron 32
 
1643 mario79 33
lab4:
34
	mov	eax,[WorkScreen_SizeX]
35
	mov	ebx,[k]
255 heavyiron 36
	cdq
1643 mario79 37
	idiv	ebx
38
	mov	[CounterX],eax
39
	mov	eax,[WorkScreen_SizeY]
255 heavyiron 40
	cdq
1643 mario79 41
	idiv	ebx
42
	mov	[CounterY],eax
255 heavyiron 43
 
1643 mario79 44
	mov	eax,[WorkScreen_SizeX]
45
	mov	ecx,eax
46
	mov	ebx,[k]
255 heavyiron 47
	cdq
1643 mario79 48
	idiv	ebx
49
	imul	eax,ebx
50
	sub	ecx,eax
51
	lea	ecx,[ecx+ecx*2]
255 heavyiron 52
 
1643 mario79 53
	mov	eax,[WorkScreen_SizeX]
54
	mov	ebx,[k]
55
	dec	ebx
56
	imul	eax,ebx
57
	lea	eax,[eax+eax*2]
58
	add	eax,ecx
59
	mov	[OffsetYWorkScreen],eax
255 heavyiron 60
 
1643 mario79 61
	mov	ebx,[Picture_SizeX]
62
	mov	eax,[CounterX]
63
	sub	ebx,eax
64
	lea	ebx,[ebx+ebx*2]
65
	mov	[OffsetYPicture],ebx
255 heavyiron 66
 
1643 mario79 67
	mov	eax,[WorkScreen_SizeX]
68
	mov	ebx,[k]
69
	sub	eax,ebx
70
	lea	eax,[eax+eax*2]
71
	mov	[OffsetYBigPixel],eax
255 heavyiron 72
 
1643 mario79 73
	mov	eax,[PosX]
74
	mov	ebx,[PosY]
75
	mov	ecx,[Picture_SizeX]
76
	imul	ecx,ebx
77
	add	eax,ecx
78
	lea	eax,[eax+eax*2]
79
	add	eax,[PointerToPicture]
255 heavyiron 80
 
1643 mario79 81
	mov	ebx,[ScreenPointer]
82
	mov	edi,[CounterY]
255 heavyiron 83
 
1643 mario79 84
;if size of picture natural(mastab is 1) than move picture to work screen
85
	cmp	[k],1
86
	jne	no_zoom_1_
255 heavyiron 87
 
1643 mario79 88
screen_y_1:
89
	mov	esi,[CounterX]
255 heavyiron 90
 
1643 mario79 91
screen_x_1:
92
	mov	ecx,[eax]
93
	mov	ebp,ecx
94
	shr	ecx,16
95
	mov	[ebx],bp
96
	mov	[ebx+2],cl
6379 IgorA 97
	add	ebx,3
1643 mario79 98
	add	eax,3
99
	dec	esi
100
	jnz	screen_x_1
101
	add	eax,[OffsetYPicture]
102
	add	ebx,[OffsetYWorkScreen]
103
	dec	edi
104
	jnz	screen_y_1
105
	jmp	fps
255 heavyiron 106
 
1643 mario79 107
no_zoom_1_:
108
	cmp	[k],2
109
	jne	no_zoom_2
255 heavyiron 110
 
1643 mario79 111
screen_y_2:
112
	mov	esi,[CounterX]
255 heavyiron 113
 
1643 mario79 114
screen_x_2:
115
	mov	ecx,[eax]
116
	mov	ebp,ecx
117
	shr	ecx,16
118
	mov	edx,ebx
119
	mov	[edx],bp
120
	mov	[edx+2],cl
121
	mov	[edx+3],bp
122
	mov	[edx+3+2],cl
123
	add	edx,3*2
124
	add	edx,[OffsetYBigPixel]
125
	mov	[edx],bp
126
	mov	[edx+2],cl
127
	mov	[edx+3],bp
128
	mov	[edx+3+2],cl
129
	add	ebx,3*2
130
	add	eax,3
131
	dec	esi
132
	jnz	screen_x_2
133
	add	eax,[OffsetYPicture]
134
	add	ebx,[OffsetYWorkScreen]
135
	dec	edi
136
	jnz	screen_y_2
137
	jmp	fps
255 heavyiron 138
 
1643 mario79 139
no_zoom_2:
140
	cmp	[k],4
141
	jne	no_zoom_4
255 heavyiron 142
 
1643 mario79 143
screen_y_4:
144
	mov	esi,[CounterX]
255 heavyiron 145
 
1643 mario79 146
screen_x_4:
147
	mov	ecx,[eax]
148
	mov	ebp,ecx
149
	shr	ecx,16
150
	mov	edx,ebx
151
	mov	[edx],bp
152
	mov	[edx+2],cl
153
	mov	[edx+3],bp
154
	mov	[edx+3+2],cl
155
	mov	[edx+6],bp
156
	mov	[edx+6+2],cl
157
	mov	[edx+9],bp
158
	mov	[edx+9+2],cl
159
	add	edx,3*4
160
	add	edx,[OffsetYBigPixel]
161
	mov	[edx],bp
162
	mov	[edx+2],cl
163
	mov	[edx+3],bp
164
	mov	[edx+3+2],cl
165
	mov	[edx+6],bp
166
	mov	[edx+6+2],cl
167
	mov	[edx+9],bp
168
	mov	[edx+9+2],cl
169
	add	edx,3*4
170
	add	edx,[OffsetYBigPixel]
171
	mov	[edx],bp
172
	mov	[edx+2],cl
173
	mov	[edx+3],bp
174
	mov	[edx+3+2],cl
175
	mov	[edx+6],bp
176
	mov	[edx+6+2],cl
177
	mov	[edx+9],bp
178
	mov	[edx+9+2],cl
179
	add	edx,3*4
180
	add	edx,[OffsetYBigPixel]
181
	mov	[edx],bp
182
	mov	[edx+2],cl
183
	mov	[edx+3],bp
184
	mov	[edx+3+2],cl
185
	mov	[edx+6],bp
186
	mov	[edx+6+2],cl
187
	mov	[edx+9],bp
188
	mov	[edx+9+2],cl
189
	add	ebx,4*3
190
	add	eax,3
191
	dec	esi
192
	jnz	screen_x_4
193
	add	eax,[OffsetYPicture]
194
	add	ebx,[OffsetYWorkScreen]
195
	dec	edi
196
	jnz	screen_y_4
197
	jmp	fps
198
 
199
no_zoom_4:
200
;if zoom more than 4
201
screen_y:
202
	mov	esi,[CounterX]
203
 
204
screen_x:
205
	mov	ecx,[eax]
206
	mov	ebp,ecx
207
	shr	ecx,16
208
;---------------------------------------------------------
209
	push	ebx eax
210
	mov	edx,[k]
211
 
212
big_pixel_y:
213
	mov	eax,[k]
214
 
215
big_pixel_x:
216
	mov	[ebx],bp
217
	mov	[ebx+2],cl
218
	add	ebx,3
219
	dec	eax
220
	jnz	big_pixel_x
221
	add	ebx,[OffsetYBigPixel]
222
	dec	edx
223
	jnz	big_pixel_y
224
	pop	eax ebx
225
;---------------------------------------------------------
226
	mov	edx,[k]
227
	lea	edx,[edx+edx*2]
228
	add	ebx,edx
229
	add	eax,3
230
	dec	esi
231
	jnz	screen_x
232
	add	eax,[OffsetYPicture]
233
	add	ebx,[OffsetYWorkScreen]
234
	dec	edi
235
	jnz	screen_y
236
 
237
fps:
6379 IgorA 238
	;calculate selection rect
6385 IgorA 239
	cmp [crossing],0
240
	je .no_selection_rect
6379 IgorA 241
	mov edx,[rectangular_shade_y]
242
	sub edx,[PosY]
243
	mov ecx,[rectangular_shade_x]
244
	sub ecx,[PosX]
6385 IgorA 245
	mov ebx,[crossing_old_y]
6379 IgorA 246
	sub ebx,[PosY]
6385 IgorA 247
	mov eax,[crossing_old_x]
6379 IgorA 248
	sub eax,[PosX]
249
	cmp [k],1
250
	je .zo_1
251
		cmp eax,ecx
252
		jle @f
253
			xchg eax,ecx
254
		@@:
255
		cmp ebx,edx
256
		jle @f
257
			xchg ebx,edx
258
		@@:
259
		inc eax
260
		inc ebx
261
		imul eax,[k]
262
		imul ebx,[k]
263
		imul ecx,[k]
264
		imul edx,[k]
265
		dec eax
266
		dec ebx
267
	.zo_1:
268
	stdcall draw_selection_rect, eax,ebx,ecx,edx
269
	.no_selection_rect:
270
 
1643 mario79 271
	mov	ecx,[WorkScreen_SizeX]
272
	shl	ecx,16
6359 IgorA 273
	add	ecx,[WorkScreen_SizeY]
6357 IgorA 274
	mov	edx,((ci_edit_wnd_x_pos+ci_edit_wnd_border) shl 16)\
275
		+ (ci_edit_wnd_y_pos+ci_edit_wnd_border)
6379 IgorA 276
	mcall SF_PUT_IMAGE, [ScreenPointer]
1643 mario79 277
	ret
255 heavyiron 278
;----------------------------------------------------------
6379 IgorA 279
align 4
280
proc draw_selection_rect, x0:dword, y0:dword, x1:dword, y1:dword
281
	mov eax,0xffff3fff ;2:2
282
	mov edx,0xff1f ;1:1
283
 
284
	mov edi,[x0]
285
	mov ebx,[y0]
286
	mov ecx,[x1]
287
	cmp edi,ecx
288
	jle @f
289
		xchg edi,ecx
290
	@@:
291
	call draw_line_h
292
	mov ebx,[y1]
293
	call draw_line_h
294
 
295
	mov edi,[x0]
296
	mov ecx,[y0]
297
	cmp ebx,ecx
298
	jle @f
299
		xchg ebx,ecx
300
	@@:
301
	call draw_line_w
302
	mov edi,[x1]
303
	call draw_line_w
304
	ret
305
endp
306
 
307
;input:
308
; eax - color1(g,r):color2(g,r)
309
;  dx - color1(b):color2(b)
310
; edi - x0
311
; ebx - y0
312
; ecx - x1 (x1 >= x0)
313
align 4
314
draw_line_h:
315
	cmp edi,ecx
316
	je .end_f
317
	cmp ecx,1
318
	jl .end_f
319
	cmp edi,[WorkScreen_SizeX]
320
	jge .end_f
321
	cmp ebx,0
322
	jl .end_f
323
	cmp ebx,[WorkScreen_SizeY]
324
	jge .end_f
325
push ebx ecx edi
326
	cmp ecx,[WorkScreen_SizeX]
327
	jl @f
328
		mov ecx,[WorkScreen_SizeX]
329
	@@:
330
	cmp edi,0
331
	jge @f
332
		xor edi,edi
333
	@@:
334
	sub ecx,edi
335
	imul ebx,[WorkScreen_SizeX]
336
	add edi,ebx
337
	lea	edi,[edi+edi*2]
338
	add edi,[ScreenPointer]
339
	cld
340
	.line_t:
341
		stosw
342
		mov byte[edi],dl
343
		inc edi
344
		bt ecx,1
345
		jc @f
346
		bt ecx,0
347
		jc @f
348
			ror eax,16
349
			ror dx,8
350
		@@:
351
		dec ecx
352
		jnz .line_t
353
pop edi ecx ebx
354
	.end_f:
355
	ret
356
 
357
;input:
358
; eax - color1(g,r):color2(g,r)
359
;  dx - color1(b):color2(b)
360
; edi - x0
361
; ebx - y0
362
; ecx - y1 (y1 >= y0)
363
align 4
364
draw_line_w:
365
	cmp edi,0
366
	jl .end_f
367
	cmp edi,[WorkScreen_SizeX]
368
	jge .end_f
369
	cmp ebx,ecx
370
	je .end_f
371
	cmp ebx,[WorkScreen_SizeY]
372
	jge .end_f
373
	cmp ecx,1
374
	jl .end_f
375
push ebx ecx edi
376
	cmp ecx,[WorkScreen_SizeY]
377
	jl @f
378
		mov ecx,[WorkScreen_SizeY]
379
	@@:
380
	cmp ebx,0
381
	jge @f
382
		xor ebx,ebx
383
	@@:
384
	sub ecx,ebx
385
	cmp ecx,1
386
	jl .end_f
387
	imul ebx,[WorkScreen_SizeX]
388
	add edi,ebx
389
	lea	edi,[edi+edi*2]
390
	add edi,[ScreenPointer]
391
	mov	ebx,[WorkScreen_SizeX]
392
	lea	ebx,[ebx+ebx*2]
393
	sub ebx,2
394
	cld
395
	.line_r:
396
		stosw
397
		mov byte[edi],dl
398
		add edi,ebx
399
		bt ecx,1
400
		jc @f
401
		bt ecx,0
402
		jc @f
403
			ror eax,16
404
			ror dx,8
405
		@@:
406
		dec ecx
407
		jnz .line_r
408
pop edi ecx ebx
409
	.end_f:
410
	ret
411
;----------------------------------------------------------
255 heavyiron 412
;--------------------clear screen--------------------------
413
;----------------------------------------------------------
6379 IgorA 414
align 4
255 heavyiron 415
cleare_screen:
6341 IgorA 416
	mov edi,[ScreenPointer]
417
	mov ebx,[WorkScreen_SizeX]
418
	imul ebx,[WorkScreen_SizeY]
419
	lea ebx,[ebx+ebx*2]
420
	mov eax,0xffffffff
421
	mov ecx,ebx
422
	shr ecx,2
6359 IgorA 423
	cld
6341 IgorA 424
	rep stosd
425
	mov ecx,ebx
426
	and ecx,3
427
	rep stosb
255 heavyiron 428
	ret
429
;----------------------------------------------------------
430
;-------------cleare work arrea(work screen)---------------
431
;----------------------------------------------------------
432
cleare_work_arrea:
6341 IgorA 433
	mov edi,[PointerToPicture]
434
	mov ebx,[Picture_SizeX]
435
	imul ebx,[Picture_SizeY]
436
	lea ebx,[ebx+ebx*2]
437
	mov eax,0xffffffff
438
	mov ecx,ebx
439
	shr ecx,2
6359 IgorA 440
	cld
6341 IgorA 441
	rep stosd
442
	mov ecx,ebx
443
	and ecx,3
444
	rep stosb
255 heavyiron 445
	ret
446
;-----------------------------------------------------------
447
;calculate position work screen on a picture
448
;-----------------------------------------------------------
449
CalculatePositionScreen:
6357 IgorA 450
	mov eax,[Picture_SizeX]
451
	sub eax,[CounterX]
452
	cmp [PosX],eax
453
	jle @f
454
		mov [PosX],eax
455
	@@:
456
	cmp [PosX],0
457
	jns @f
458
		mov [PosX],0
459
	@@:
460
	mov ebx,[Picture_SizeY]
461
	sub ebx,[CounterY]
462
	cmp [PosY],ebx
463
	jle @f
464
		mov [PosY],ebx
465
	@@:
466
	cmp [PosY],0
467
	jns @f
468
		mov [PosY],0
469
	@@:
1643 mario79 470
	ret
255 heavyiron 471
;-----------------------------------------------------------
472
;-----------calculate cordinats on work picture--------------
473
;-----------------------------------------------------------
474
GetScreenCordinats:
6357 IgorA 475
	mov eax,[MouseX]
476
	mov ebx,[MouseY]
477
	sub eax,ci_edit_wnd_x_pos+ci_edit_wnd_border
478
	cmp eax,0
479
	jge @f
480
		xor eax,eax
481
	@@:
482
	sub ebx,ci_edit_wnd_y_pos+ci_edit_wnd_border
483
	cmp ebx,0
484
	jge @f
485
		xor ebx,ebx
486
	@@:
487
	mov ecx,[k]
255 heavyiron 488
	cdq
6357 IgorA 489
	idiv ecx
490
	mov [ScreenX],eax
491
	mov eax,ebx
255 heavyiron 492
	cdq
6357 IgorA 493
	idiv ecx
494
	mov [ScreenY],eax
255 heavyiron 495
	ret