Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
178 heavyiron 1
;-----------------------------------------------------------------------------
2
func check_cur_vis_inv ;//////////////////////////////////////////////////////
3
;-----------------------------------------------------------------------------
4
	push	eax ebx
5
	xor	bl,bl
6
  .chk_y:
7
	mov	eax,[pos.y]
8
	or	eax,eax
9
	jge	@f
10
	mov	[pos.y],0
11
	jmp	.chk_dy
12
    @@: cmp	eax,[lines]
13
	jl	.chk_dy
14
	mov	eax,[lines]
15
	dec	eax
16
	mov	[pos.y],eax
17
  .chk_dy:
18
	mov	eax,[top_line]
19
	cmp	eax,[pos.y]
20
	jle	@f
21
	push	[pos.y]
22
	pop	[top_line]
23
	inc	bl
24
    @@: add	eax,[lines.scr]
25
	cmp	eax,[pos.y]
26
	jg	.chk_x
27
	mov	eax,[pos.y]
28
	sub	eax,[lines.scr]
29
	inc	eax
30
	mov	[top_line],eax
31
	inc	bl
32
  .chk_x:
33
	mov	eax,[pos.x]
34
	or	eax,eax
35
	jge	@f
36
	mov	[pos.x],0
37
	jmp	.chk_dx
38
    @@: cmp	eax,[columns]
39
	jl	.chk_dx
40
	mov	eax,[columns]
41
	mov	[pos.x],eax
42
  .chk_dx:
43
	mov	eax,[left_col]
44
	cmp	eax,[pos.x]
45
	jle	@f
46
	push	[pos.x]
47
	pop	[left_col]
48
	inc	bl
49
    @@: add	eax,[columns.scr]
50
	cmp	eax,[pos.x]
51
	jg	@f
52
	mov	eax,[pos.x]
53
	sub	eax,[columns.scr]
54
	inc	eax
55
	mov	[left_col],eax
56
	inc	bl
57
    @@: cmp	[mev],MEV_LDOWN
58
	jne	.exit
59
	push	[pos.x] [pos.y]
60
	pop	[sel.y] [sel.x]
61
  .exit:
62
	or	bl,bl
63
	clc
64
	jz	@f
65
	call	draw_file
66
	stc
67
    @@: pop	ebx eax
68
	ret
69
endf
70
 
71
;-----------------------------------------------------------------------------
72
func clear_selection ;////////////////////////////////////////////////////////
73
;-----------------------------------------------------------------------------
74
	push	eax ebx
75
	mov	eax,[sel.y]
76
	mov	ebx,[pos.y]
77
	cmp	eax,ebx
78
	jle	@f
79
	xchg	eax,ebx
80
    @@: push	[pos.x] [pos.y]
81
	pop	[sel.y] [sel.x]
82
	call	draw_file.ex
83
	pop	ebx eax
84
	ret
85
endf
86
 
87
;-----------------------------------------------------------------------------
88
func pt_in_rect ;/////////////////////////////////////////////////////////////
89
;-----------------------------------------------------------------------------
90
	cmp	eax,[ecx+0x0]
91
	jl	@f
92
	cmp	ebx,[ecx+0x4]
93
	jl	@f
94
	cmp	eax,[ecx+0x8]
95
	jg	@f
96
	cmp	ebx,[ecx+0xC]
97
	jg	@f
98
	stc
99
	ret
100
    @@: clc
101
	ret
102
endf
103
 
104
;-----------------------------------------------------------------------------
105
func check_bottom_right ;/////////////////////////////////////////////////////
106
;-----------------------------------------------------------------------------
107
	push	eax
108
	mov	eax,[top_line]
109
	add	eax,[lines.scr]
110
	cmp	eax,[lines]
111
	jbe	.lp1
112
	mov	eax,[lines]
113
	sub	eax,[lines.scr]
114
	jns	@f
115
	xor	eax,eax
116
    @@: mov	[top_line],eax
117
  .lp1: mov	eax,[left_col]
118
	add	eax,[columns.scr]
119
	cmp	eax,[columns]
120
	jbe	.exit
121
	mov	eax,[columns]
122
	sub	eax,[columns.scr]
123
	jns	@f
124
	xor	eax,eax
125
    @@: mov	[left_col],eax
126
  .exit:
127
	pop	eax
128
	ret
129
endf
130
 
131
;-----------------------------------------------------------------------------
132
func check_inv_str ;//////////////////////////////////////////////////////////
133
;-----------------------------------------------------------------------------
134
@^
135
	mov	eax,[pos.y]
136
	mov	ecx,[top_line]
137
  .skip_init:
138
	call	check_cur_vis
139
	mov	[pos.y],eax
140
	mov	[top_line],ecx
141
  .skip_check:
142
;       call    invalidate_string
143
	call	drawfile
144
	ret
145
^@
146
endf
147
 
148
;-----------------------------------------------------------------------------
149
func check_inv_all ;//////////////////////////////////////////////////////////
150
;-----------------------------------------------------------------------------
151
	mov	eax,[pos.y]
152
	mov	ecx,[top_line]
153
  .skip_init:
154
	call	check_cur_vis
155
	mov	[pos.y],eax
156
	mov	[top_line],ecx
157
  .skip_check:
158
;       call    clear_screen
159
	call	draw_file
160
	ret
161
endf
162
 
163
;-----------------------------------------------------------------------------
164
func check_cur_vis ;//////////////////////////////////////////////////////////
165
;-----------------------------------------------------------------------------
166
	cmp	eax,ecx
167
	jb	.low
168
	mov	edx,ecx
169
	add	edx,[lines.scr]
170
	cmp	edx,[lines]
171
	jbe	@f
172
	mov	edx,[lines]
173
    @@: cmp	eax,edx
174
	jb	@f
175
	lea	ecx,[eax+1]
176
	sub	ecx,[lines.scr]
177
	jns	@f
178
	xor	ecx,ecx
179
	jmp	@f
180
  .low: mov	ecx,eax
181
    @@: mov	edx,ecx
182
	add	edx,[lines.scr]
183
	cmp	edx,[lines]
184
	jbe	@f
185
	mov	ecx,[lines]
186
	sub	ecx,[lines.scr]
187
	jns	@f
188
	xor	ecx,ecx
189
    @@:;mov     [top_line],ecx
190
 
191
	pushad
192
	mov	eax,[pos.x]
193
	mov	ebx,[left_col]
194
	mov	ecx,ebx
195
	add	ecx,[columns.scr]
196
	cmp	eax,ebx
197
	jb	.lp1
198
	cmp	eax,ecx
199
	jb	.exit
200
	lea	ebx,[eax]
201
	sub	ebx,[columns.scr]
202
	jmp	@f
203
  .lp1: mov	ebx,eax
204
    @@: mov	[left_col],ebx
205
 
206
  .exit:
207
	mov	[pos.x],eax
208
	popad
209
 
210
	ret
211
endf
212
 
213
;-----------------------------------------------------------------------------
214
func get_real_length ;////////////////////////////////////////////////////////
215
;-----------------------------------------------------------------------------
216
	movzx	eax,word[esi]
217
    @@: cmp	byte[esi+eax+4-1],' '
218
	jne	@f
219
	dec	eax
220
	jnz	@b
221
    @@: ret
222
endf
223
 
224
;-----------------------------------------------------------------------------
225
func get_line_offset ;////////////////////////////////////////////////////////
226
;-----------------------------------------------------------------------------
227
; Input:
228
;  ECX = line number
229
; Output:
230
;  ESI = line data offset
231
;-----------------------------------------------------------------------------
232
	push	eax ecx
233
	mov	esi,AREA_EDIT
234
	jecxz	.exit
235
    @@: movzx	eax,word[esi]
236
	dec	ecx
237
	lea	esi,[esi+eax+4]
238
	jnz	@b
239
  .exit:
240
	pop	ecx eax
241
	ret
242
endf
243
 
244
;-----------------------------------------------------------------------------
245
func init_sel_vars ;//////////////////////////////////////////////////////////
246
;-----------------------------------------------------------------------------
247
	pushad
248
	mov	[sel.selected],1
249
	mov	eax,[sel.x]
250
	mov	ebx,[sel.y]
251
	mov	ecx,[pos.x]
252
	mov	edx,[pos.y]
253
	cmp	ebx,edx
254
	jl	.lp2
255
	jne	@f
256
	cmp	eax,ecx
257
	jl	.lp2
258
	jne	.lp1
259
	dec	[sel.selected]
260
	jmp	.lp2
261
    @@: xchg	ebx,edx
262
  .lp1: xchg	eax,ecx
263
  .lp2: mov	[sel.begin.x],eax
264
	mov	[sel.begin.y],ebx
265
	mov	[sel.end.x],ecx
266
	mov	[sel.end.y],edx
267
	popad
268
	ret
269
endf
270
 
271
;-----------------------------------------------------------------------------
272
func get_scroll_vars ;////////////////////////////////////////////////////////
273
;-----------------------------------------------------------------------------
274
; Input:
275
;  EAX = maximum data size      (units)
276
;  EBX = visible data size      (units)
277
;  ECX = current data position  (units)
278
;  EDX = scrolling area size    (pixels)
279
; Output:
280
;  EAX = srcoller offset        (pixels)
281
;  EBX = scroller size          (pixels)
282
;-----------------------------------------------------------------------------
283
	push	eax ebx edx
284
;       sub     eax,ebx
285
	mov	esi,eax
286
	mov	eax,edx
287
	imul	ebx
288
	idiv	esi
289
	cmp	eax,[esp]
290
	jge	.null
291
	cmp	eax,AMINS
292
	jge	@f
293
	neg	eax
294
	add	eax,AMINS
295
	sub	[esp],eax
296
	mov	eax,AMINS
297
    @@: mov	[esp+4],eax	; scroller size
298
	mov	eax,[esp]
299
	imul	ecx
300
	idiv	esi
301
	or	eax,eax
302
	jns	@f
303
	xor	eax,eax
304
   @@:	mov	[esp+8],eax    ; scroller offset
305
	add	eax,[esp+4]
306
	cmp	eax,[esp]
307
	jle	@f
308
;        mov     eax,[esp]
309
;        sub     eax,[esp+4]
310
;        js      @f
311
;        mov     [esp+8],eax
312
    @@:
313
	pop	edx ebx eax
314
	ret
315
  .null:
316
	mov	dword[esp+4],0
317
	mov	dword[esp+8],0
318
	jmp	@b
319
endf
320
 
321
;-----------------------------------------------------------------------------
322
func uint2strz ;//////////////////////////////////////////////////////////////
323
;-----------------------------------------------------------------------------
324
	dec	ebx
325
	jz	@f
326
	xor	edx,edx
327
	div	ecx
328
	push	edx
329
	call	uint2strz
330
	pop	eax
331
    @@: cmp	al,10
332
	sbb	al,$69
333
	das
334
	stosb
335
	ret
336
endf
337
 
338
;-----------------------------------------------------------------------------
339
func uint2str ;///////////////////////////////////////////////////////////////
340
;-----------------------------------------------------------------------------
341
	cmp	eax,ecx
342
	jb	@f
343
	xor	edx,edx
344
	div	ecx
345
	push	edx
346
	call	uint2str
347
	pop	eax
348
    @@: cmp	al,10
349
	sbb	al,$69
350
	das
351
	stosb
352
	ret
353
endf
354
 
355
;-----------------------------------------------------------------------------
356
func rgb_to_gray ;////////////////////////////////////////////////////////////
357
;-----------------------------------------------------------------------------
358
	push	0 eax
359
	and	dword[esp],0x000000FF
360
	fild	dword[esp]
361
	fmul	[float_gray_b]
362
	shr	eax,8
363
	mov	[esp],eax
364
	and	dword[esp],0x000000FF
365
	fild	dword[esp]
366
	fmul	[float_gray_g]
367
	faddp
368
	shr	eax,8
369
	and	eax,0x000000FF
370
	mov	[esp],eax
371
	fild	dword[esp]
372
	fmul	[float_gray_r]
373
	faddp
374
	frndint
375
	fist	dword[esp]
376
	fist	dword[esp+1]
377
	fistp	dword[esp+2]
378
	pop	eax
379
	add	esp,4
380
	ret
381
endf
382
 
383
;float_gray_r dd 0.30f
384
;float_gray_g dd 0.59f
385
;float_gray_b dd 0.11f
386
 
387
;-----------------------------------------------------------------------------
388
func get_active_menu_item ;///////////////////////////////////////////////////
389
;-----------------------------------------------------------------------------
390
	pushad
391
	mov	[mi_cur],0
392
	mcall	37,1
393
	movsx	ebx,ax
394
	sar	eax,16
395
	mov	ecx,__rc
396
	pushd	2 0 (main_menu.width+7) (ATOPH-2)
397
	popd	[__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
398
;       add     [__rc+0xC],ATOPH-2
399
	call	pt_in_rect
400
	jnc	.outside_menu
401
	m2m	dword[ecx+0x8],dword[ecx+0x0]
402
	mov	edx,main_menu
403
    @@: inc	[mi_cur]
404
	movzx	esi,word[edx+0]
405
	add	[ecx+0x8],esi
406
	call	pt_in_rect
407
	jc	.exit
408
	m2m	dword[ecx+0x0],dword[ecx+0x8]
409
	add	edx,8+1
410
	movzx	esi,byte[edx-1]
411
	add	edx,esi
412
	cmp	byte[edx+8],0
413
	jne	@b
414
	mov	[mi_cur],0
415
  .exit:
416
	popad
417
	ret
418
  .outside_menu:
419
	or	[mi_cur],-1
420
    @@: popad
421
	ret
422
endf
423
 
424
;-----------------------------------------------------------------------------
425
func get_active_popup_item ;//////////////////////////////////////////////////
426
;-----------------------------------------------------------------------------
427
	pushad
428
	mov	[pi_cur],0
429
	mcall	37,1
430
	movsx	ebx,ax
431
	sar	eax,16
432
	mov	ecx,__rc
433
	mov	dword[ecx+0x0],0
434
	mov	dword[ecx+0x4],0
435
	movzx	edx,[ebp+POPUP.width]
436
	mov	dword[ecx+0x8],edx;POP_WIDTH
437
	movzx	edx,[ebp+POPUP.height]
438
	mov	dword[ecx+0xC],edx;POP_HEIGHT
439
	call	pt_in_rect
440
	jnc	.outside_window
441
	inc	dword[ecx+0x0]
442
	mov	dword[ecx+0x4],3
443
	dec	dword[ecx+0x8]
444
	mov	dword[ecx+0xC],3+POP_IHEIGHT-1
445
	mov	edx,[ebp+POPUP.data];popup_text.data
446
    @@: inc	[pi_cur]
447
	inc	edx
448
	movzx	esi,byte[edx-1]
449
	cmp	byte[edx],'-'
450
	jne	.lp1
451
	pushd	[ecx+0xC]
452
	sub	dword[ecx+0xC],POP_IHEIGHT-4
453
	call	pt_in_rect
454
	popd	[ecx+0xC]
455
	jc	.separator
456
	add	dword[ecx+0x4],4
457
	add	dword[ecx+0xC],4
458
	jmp	.lp3
459
  .lp1: call	pt_in_rect
460
	jnc	.lp2
461
	mov	eax,[pi_cur]
462
	test	byte[ebp+eax-1],1;byte[popup_text+eax-1],1
463
	jnz	.exit
464
	jmp	.separator
465
  .lp2: add	dword[ecx+0x4],POP_IHEIGHT
466
	add	dword[ecx+0xC],POP_IHEIGHT
467
	add	edx,esi
468
	inc	edx
469
	movzx	esi,byte[edx-1]
470
  .lp3: add	edx,esi
471
	cmp	byte[edx],0
472
	jne	@b
473
  .separator:
474
	mov	[pi_cur],0
475
  .exit:
476
	popad
477
	ret
478
  .outside_window:
479
	or	[pi_cur],-1
480
	jmp	.exit
481
endf
482
 
483
;-----------------------------------------------------------------------------
484
func line_add_spaces ;////////////////////////////////////////////////////////
485
;-----------------------------------------------------------------------------
486
; esi = line offset
487
; ecx = needed line length
488
;-----------------------------------------------------------------------------
489
	pushad
490
	movzx	edx,word[esi]
491
	cmp	ecx,edx
492
	jbe	.exit
493
	sub	ecx,edx
494
	push	ecx
495
	mov	edi,AREA_TEMP2
496
	mov	eax,esi
497
	mov	esi,edi
498
	sub	esi,ecx
499
	lea	ecx,[eax+4]
500
	add	ecx,edx;[eax]
501
	push	ecx
502
	neg	ecx
503
	lea	ecx,[esi+ecx+1]
504
	std
505
	rep	movsb
506
	pop	edi ecx
507
	add	[eax],cx
508
	mov	al,' '
509
	cld
510
	rep	stosb
511
  .exit:
512
	popad
513
	ret
514
endf
515
 
516
;-----------------------------------------------------------------------------
517
func delete_selection ;///////////////////////////////////////////////////////
518
;-----------------------------------------------------------------------------
519
	cmp	[sel.selected],0
520
	je	.exit.2
521
 
522
	pushad
523
	mov	ecx,[sel.begin.y]
524
	cmp	ecx,[sel.end.y]
525
	je	.single_line
526
	call	get_line_offset
527
	and	dword[esi],not 0x00020000
528
	or	dword[esi],0x00010000
529
	mov	ecx,[sel.begin.x]
530
	call	line_add_spaces
531
	lea	edi,[esi+4]
532
	mov	ecx,[sel.end.y]
533
	call	get_line_offset
534
	call	get_real_length
535
	cmp	eax,[sel.end.x]
536
	jbe	@f
537
	mov	eax,[sel.end.x]
538
    @@: movzx	ecx,word[esi]
539
	sub	ecx,eax
540
	mov	ebx,[sel.begin.x]
541
	add	ebx,ecx
542
	mov	[edi-4],bx
543
	add	edi,[sel.begin.x]
544
	lea	esi,[esi+eax+4]
545
	mov	ecx,AREA_TEMP2
546
	sub	ecx,esi
547
	cld
548
	rep	movsb
549
	mov	eax,[sel.end.y]
550
	sub	eax,[sel.begin.y]
551
	sub	[lines],eax
552
	jmp	.exit
553
 
554
  .single_line:
555
	call	get_line_offset
556
	and	dword[esi],not 0x00020000
557
	or	dword[esi],0x00010000
558
	call	get_real_length
559
	cmp	eax,[sel.begin.x]
560
	jbe	.exit
561
	mov	ecx,[sel.end.x]
562
	cmp	ecx,eax
563
	jbe	@f
564
	mov	ecx,eax
565
    @@: sub	ecx,[sel.begin.x]
566
	sub	[esi],cx
567
	lea	edi,[esi+4]
568
	add	edi,[sel.begin.x]
569
	lea	esi,[edi+ecx]
570
	mov	ecx,AREA_TEMP2
571
	sub	ecx,esi
572
	cld
573
	rep	movsb
574
 
575
  .exit:
576
	mov	eax,[sel.begin.x]
577
	mov	[pos.x],eax
578
	mov	[sel.x],eax
579
	mov	eax,[sel.begin.y]
580
	mov	[pos.y],eax
581
	mov	[sel.y],eax
582
	popad
583
	mov	[modified],1
584
	clc
585
	ret
586
 
587
  .exit.2:
588
	stc
589
	ret
590
endf