Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
129 mikedld 1
;-----------------------------------------------------------------------------
2
func vm_mike_draw_rect.24 ;///////////////////////////////////////////////////
3
;-----------------------------------------------------------------------------
4
; eax - x start
5
; ebx - y start
6
; ecx - x end
7
; edx - y end
8
; edi - color
9
;-----------------------------------------------------------------------------
10
;- eax(ebx) [x start]*65536 + [x size]
11
;- ebx(ecx) [y start]*65536 + [y size]
12
;- ecx(edx) color 0x00RRGGBB
13
;-----------------------------------------------------------------------------
14
begin
15
	pushad
16
	cli
17
	jif	eax,e,ecx,.exit
18
	jif	ebx,e,edx,.exit
19
 
20
	call	get_cursor_rect
21
 
384 mikedld 22
	mov	ebp,[TASK_BASE]
23
	movsx	esi,word[ebp-CURRENT_TASK+0]
129 mikedld 24
	add	eax,esi
25
	add	ecx,esi
384 mikedld 26
	movsx	esi,word[ebp-CURRENT_TASK+4]
129 mikedld 27
	add	ebx,esi
28
	add	edx,esi
384 mikedld 29
;       add     eax,[ebp-CURRENT_TASK+0]
30
;       add     ebx,[ebp-CURRENT_TASK+4]
31
;       add     ecx,[ebp-CURRENT_TASK+0]
32
;       add     edx,[ebp-CURRENT_TASK+4]
129 mikedld 33
 
384 mikedld 34
	mov	esi,[CURRENT_TASK]
129 mikedld 35
	mov	esi,[CLIP_RECTS+esi*4]
36
	mov	ebp,[esi]
37
	or	ebp,ebp
38
	jz	.exit
39
	add	esi,4
40
  .nx:	jif	ecx,l,[rr.left],.skip
41
	jif	eax,ge,[rr.right],.skip
42
	jif	edx,l,[rr.top],.skip
43
	jif	ebx,ge,[rr.bottom],.skip
44
	pushad
45
	jif	eax,ge,[rr.left],@f
46
	mov	eax,[rr.left]
47
    @@: jif	ebx,ge,[rr.top],@f
48
	mov	ebx,[rr.top]
49
    @@: jif	ecx,l,[rr.right],@f
50
	mov	ecx,[rr.right]
51
    @@: jif	edx,l,[rr.bottom],@f
52
	mov	edx,[rr.bottom]
53
    @@: call	is_intersect_rc
54
	jc	.put
384 mikedld 55
	cmp	byte[MOUSE_VISIBLE],0
56
	je	.put
129 mikedld 57
	call	[SF.draw_mouse_under]
384 mikedld 58
	mov	byte[MOUSE_VISIBLE],0
59
  .put: mov	ebp,[BytesPerScanLine]
129 mikedld 60
	imul	ebp,ebx
61
	push	eax
62
	lea	eax,[eax*3]
63
	add	ebp,eax
64
	pop	eax
384 mikedld 65
	add	ebp,[LFBAddress]
129 mikedld 66
  .xxx: push	eax ebp
67
    @@: push	eax
68
	mov	eax,edi
69
	mov	[ebp],ax
70
	shr	eax,16
71
	mov	[ebp+2],al
72
	pop	eax
73
	add	ebp,3
74
	inc	eax
75
	cmp	eax,ecx
76
	jl	@b
77
	pop	ebp eax
384 mikedld 78
	add	ebp,[BytesPerScanLine]
129 mikedld 79
	inc	ebx
80
	cmp	ebx,edx
81
	jl	.xxx
82
	popad
83
  .skip:
84
	add	esi,SR
85
	dec	ebp
86
	jnz	.nx
87
 
88
  .exit:
89
	sti
90
	popad
91
	retn
92
endf
93
 
94
;-----------------------------------------------------------------------------
95
func vm_mike_draw_line.24 ;///////////////////////////////////////////////////
96
;-----------------------------------------------------------------------------
97
; eax(ebx)  [x start] shl 16 + [x end]
98
; ebx(ecx)  [y start] shl 16 + [y end]
99
; ecx(edx)  colour 0x00RRGGBB
100
; edi = 0x00000001 force
101
;-----------------------------------------------------------------------------
102
begin
103
	pushad
104
	cli
105
 
106
	call	get_cursor_rect
107
 
108
	movsx	eax,word[esp+4*7]  ; x end
109
	cmp	ax,[esp+4*7+2]	   ; x start
110
	je	dl.24.vert_line
111
	movsx	eax,word[esp+4*4]  ; y end
112
	cmp	ax,[esp+4*4+2]	   ; y start
113
	je	dl.24.horz_line
114
 
115
	sti
116
	popad
117
	retn
118
 
119
  dl.24.vert_line:
120
	test	edi,1
121
	jnz	.forced
384 mikedld 122
	mov	esi,[CURRENT_TASK]
129 mikedld 123
	mov	esi,[CLIP_RECTS+esi*4]
124
	mov	edi,[esi]
125
	or	edi,edi
126
	jz	.exit
127
	add	esi,4
128
  .nx:	movsx	ebx,word[esp+4*4+2]  ; y start
129
	movsx	edx,word[esp+4*4]    ; y end
130
	cmp	ebx,edx
131
	je	.exit
132
	jl	@f
133
	xchg	ebx,edx
134
    @@: jif	eax,l,[rr.left],.skip
135
	jif	eax,ge,[rr.right],.skip
136
	jif	edx,l,[rr.top],.skip
137
	jif	ebx,ge,[rr.bottom],.skip
138
	jif	ebx,ge,[rr.top],@f
139
	mov	ebx,[rr.top]
140
    @@: jif	edx,l,[rr.bottom],@f
141
	mov	edx,[rr.bottom]
142
	dec	edx
143
  .draw:
144
    @@: call	is_intersect_vln
145
	jc	.put
384 mikedld 146
	cmp	byte[MOUSE_VISIBLE],0
147
	je	.put
129 mikedld 148
	call	[SF.draw_mouse_under]
384 mikedld 149
	mov	byte[MOUSE_VISIBLE],0
150
  .put: mov	ebp,[BytesPerScanLine]
129 mikedld 151
	imul	ebp,ebx
152
	push	eax
153
	lea	eax,[eax*3]
154
	add	ebp,eax
155
	pop	eax
384 mikedld 156
	add	ebp,[LFBAddress]
129 mikedld 157
    @@: test	ecx,0x01000000
158
	jz	.dr
159
	mov	ecx,[ebp]
160
	not	ecx
161
	or	ecx,0x01000000
384 mikedld 162
  .dr:	mov	[ebp],cx
129 mikedld 163
	ror	ecx,8
164
	mov	[ebp+2],ch
165
	rol	ecx,8
384 mikedld 166
	add	ebp,[BytesPerScanLine]
129 mikedld 167
	inc	ebx
168
	cmp	ebx,edx
169
	jle	@b
170
  .skip:
171
	add	esi,SR
172
	dec	edi
173
	jnz	.nx
174
  .exit:
175
	sti
176
	popad
177
	retn
178
  .forced:
179
	jif	eax,l,[viewport.left],.exit
180
	jif	eax,ge,[viewport.right],.exit
181
	movsx	ebx,word[esp+4*4+2]  ; y start
182
	movsx	edx,word[esp+4*4]    ; y end
183
	jif	ebx,e,edx,.exit
184
	jl	@f
185
	xchg	ebx,edx
186
    @@: jif	edx,l,[viewport.top],.exit
187
	jif	ebx,ge,[viewport.bottom],.exit
188
	jif	ebx,ge,[viewport.top],@f
189
	mov	ebx,[viewport.top]
190
    @@: jif	edx,l,[viewport.bottom],@f
191
	mov	edx,[viewport.bottom]
192
	dec	edx
193
    @@: mov	edi,1
194
	jmp	.draw
195
 
196
  dl.24.horz_line:
197
	test	edi,1
198
	jnz	.forced
384 mikedld 199
	mov	esi,[CURRENT_TASK]
129 mikedld 200
	mov	esi,[CLIP_RECTS+esi*4]
201
	mov	edi,[esi]
202
	or	edi,edi
203
	jz	.exit
204
	add	esi,4
205
  .nx:	movsx	ebx,word[esp+4*7+2]  ; x start
206
	movsx	edx,word[esp+4*7]    ; x end
207
	cmp	ebx,edx
208
	je	.exit
209
	jl	@f
210
	xchg	ebx,edx
211
    @@: jif	eax,l,[rr.top],.skip
212
	jif	eax,ge,[rr.bottom],.skip
213
	jif	edx,l,[rr.left],.skip
214
	jif	ebx,ge,[rr.right],.skip
215
	jif	ebx,ge,[rr.left],@f
216
	mov	ebx,[rr.left]
217
    @@: jif	edx,l,[rr.right],@f
218
	mov	edx,[rr.right]
219
	dec	edx
220
  .draw:
221
    @@: call	is_intersect_hln
222
	jc	.put
384 mikedld 223
	cmp	byte[MOUSE_VISIBLE],0
224
	je	.put
129 mikedld 225
	call	[SF.draw_mouse_under]
384 mikedld 226
	mov	byte[MOUSE_VISIBLE],0
227
  .put: mov	ebp,[BytesPerScanLine]
129 mikedld 228
	imul	ebp,eax
229
	push	eax
230
	lea	eax,[ebx*3]
231
	add	ebp,eax
232
	pop	eax
384 mikedld 233
	add	ebp,[LFBAddress]
129 mikedld 234
    @@: test	ecx,0x01000000
235
	jz	.dr
236
	mov	ecx,[ebp]
237
	not	ecx
238
	or	ecx,0x01000000
384 mikedld 239
  .dr:	mov	[ebp],cx
129 mikedld 240
	ror	ecx,8
241
	mov	[ebp+2],ch
242
	rol	ecx,8
243
	add	ebp,3
244
	inc	ebx
245
	cmp	ebx,edx
246
	jle	@b
247
  .skip:
248
	add	esi,SR
249
	dec	edi
250
	jnz	.nx
251
  .exit:
252
	sti
253
	popad
254
	retn
255
  .forced:
256
	jif	eax,l,[viewport.top],.exit
257
	jif	eax,ge,[viewport.bottom],.exit
258
	movsx	ebx,word[esp+4*7+2]  ; x start
259
	movsx	edx,word[esp+4*7]    ; x end
260
	cmp	ebx,edx
261
	je	.exit
262
	jl	@f
263
	xchg	ebx,edx
264
    @@: jif	edx,l,[viewport.left],.exit
265
	jif	ebx,ge,[viewport.right],.exit
266
	jif	ebx,ge,[viewport.left],@f
267
	mov	ebx,[viewport.left]
268
    @@: jif	edx,l,[viewport.right],@f
269
	mov	edx,[viewport.right]
270
	dec	edx
271
    @@: mov	edi,1
272
	jmp	.draw
273
endf
274
 
275
;-----------------------------------------------------------------------------
276
func vm_mike_put_pixel.24 ;///////////////////////////////////////////////////
277
;-----------------------------------------------------------------------------
278
; eax = x coordinate
279
; ebx = y coordinate
280
; ecx = ?? RR GG BB    ; 0x01000000 negation
281
; edi = 0x00000001 force
282
;-----------------------------------------------------------------------------
283
begin
284
	pushad
285
	cli
384 mikedld 286
	mov	edx,[BytesPerScanLine]
129 mikedld 287
	imul	edx,ebx
384 mikedld 288
	add	edx,eax 		; lea esi,[eax*3]
289
	lea	edx,[edx+eax*2] 	; add edx,esi
290
	add	edx,[LFBAddress]
129 mikedld 291
	test	ecx,0x01000000
292
	jz	@f
293
	mov	ecx,[edx]
294
	not	ecx
295
    @@: test	edi,1
296
	jnz	.forced
384 mikedld 297
	mov	esi,[CURRENT_TASK]
129 mikedld 298
	mov	esi,[CLIP_RECTS+esi*4]
299
	mov	edi,[esi]
300
	or	edi,edi
301
	jz	.exit
302
	add	esi,4
303
    @@: jif	eax,l,[rr.left],.skip
304
	jif	eax,ge,[rr.right],.skip
305
	jif	ebx,l,[rr.top],.skip
306
	jif	ebx,ge,[rr.bottom],.skip
307
	call	get_cursor_rect
308
	call	is_intersect_pt
309
	jc	.put
384 mikedld 310
	cmp	byte[MOUSE_VISIBLE],0
311
	je	.put
129 mikedld 312
	call	[SF.draw_mouse_under]
384 mikedld 313
	mov	byte[MOUSE_VISIBLE],0
129 mikedld 314
  .put: mov	[edx],cx
315
	shr	ecx,16
316
	mov	[edx+2],cl
317
  .exit:
318
	sti
319
	popad
320
	retn
321
  .skip:
322
	add	esi,SR
323
	dec	edi
324
	jnz	@b
325
	jmp	.exit
326
  .forced:
327
	jif	eax,l,[viewport.left],.exit
328
	jif	ebx,l,[viewport.top],.exit
329
	jif	eax,ge,[viewport.right],.exit
330
	jif	ebx,ge,[viewport.bottom],.exit
331
	mov	[edx],cx
332
	shr	ecx,16
333
	mov	[edx+2],cl
334
	sti
335
	popad
336
	retn
337
endf
338
 
339
;-----------------------------------------------------------------------------
340
func vm_mike_get_pixel.24 ;///////////////////////////////////////////////////
341
;-----------------------------------------------------------------------------
342
; eax = x coordinate
343
; ebx = y coordinate
344
;-----------------------------------------------------------------------------
345
begin
346
	pushad
347
	cli
384 mikedld 348
	imul	ebx,[BytesPerScanLine]
129 mikedld 349
	lea	eax,[eax*3]
350
	add	eax,ebx
384 mikedld 351
	add	eax,[LFBAddress]
129 mikedld 352
	mov	eax,[eax]
353
	and	eax,0x00FFFFFF
354
	mov	[esp+4*6],eax
355
	sti
356
	popad
357
	retn
358
endf
359
 
360
;-----------------------------------------------------------------------------
361
func vm_mike_put_image.24 ;///////////////////////////////////////////////////
362
;-----------------------------------------------------------------------------
363
; eax(ebx) pointer to image in memory - RRGGBBRRGGBB..
364
; ebx(ecx) image size [x]*65536+[y]
365
; ecx(edx) image position in window [x]*65536+[y]
366
; ret: eax 0 succesful, 1 overlapped
367
;-----------------------------------------------------------------------------
368
begin
369
	mov	eax,ebx
370
	mov	ebx,ecx
371
	mov	ecx,edx
372
 
373
  .direct:
374
	pushad
375
	cli
376
	jif	ebx,z,0x0000FFFF,.exit,test
377
	jif	ebx,z,0xFFFF0000,.exit,test
378
 
379
	call	get_cursor_rect
380
 
381
	mov	ebp,eax
382
	movsx	eax,word[esp+4*6+2]
383
	movsx	ebx,word[esp+4*6]
384
	movsx	ecx,word[esp+4*4+2]
385
	movsx	edx,word[esp+4*4]
386
 
387
	lea	edi,[ecx*3]
388
	push	edi
389
	add	ecx,eax
390
	add	edx,ebx
384 mikedld 391
	mov	edi,[TASK_BASE]
392
	movsx	esi,word[edi-CURRENT_TASK+0]
129 mikedld 393
	add	eax,esi
394
	add	ecx,esi
384 mikedld 395
	movsx	esi,word[edi-CURRENT_TASK+4]
129 mikedld 396
	add	ebx,esi
397
	add	edx,esi
384 mikedld 398
;       add     eax,[edi-CURRENT_TASK+0]
399
;       add     ebx,[edi-CURRENT_TASK+4]
400
;       add     ecx,[edi-CURRENT_TASK+0]
401
;       add     edx,[edi-CURRENT_TASK+4]
129 mikedld 402
 
384 mikedld 403
	mov	esi,[CURRENT_TASK]
129 mikedld 404
	mov	esi,[CLIP_RECTS+esi*4]
405
	mov	edi,[esi]
406
	or	edi,edi
407
	jz	.exit
408
	add	esi,4
409
	cld
410
  .nx:	jif	ecx,l,[rr.left],.skip
411
	jif	eax,ge,[rr.right],.skip
412
	jif	edx,l,[rr.top],.skip
413
	jif	ebx,ge,[rr.bottom],.skip
414
	pushad
415
	jif	eax,ge,[rr.left],@f
416
	mov	eax,[rr.left]
417
    @@: jif	ebx,ge,[rr.top],@f
418
	mov	ebx,[rr.top]
419
    @@: jif	ecx,l,[rr.right],@f
420
	mov	ecx,[rr.right]
421
    @@: jif	edx,l,[rr.bottom],@f
422
	mov	edx,[rr.bottom]
423
    @@: call	is_intersect_rc
424
	jc	.put
384 mikedld 425
	cmp	byte[MOUSE_VISIBLE],0
426
	je	.put
129 mikedld 427
	call	[SF.draw_mouse_under]
384 mikedld 428
	mov	byte[MOUSE_VISIBLE],0
129 mikedld 429
  .put: mov	esi,ebx
430
	sub	esi,[esp+4*4]
431
	imul	esi,[esp+4*8]
432
	mov	edi,eax
433
	sub	edi,[esp+4*7]
434
	lea	edi,[edi*3]
435
	add	esi,edi
436
	add	esi,ebp
384 mikedld 437
	mov	edi,[BytesPerScanLine]
129 mikedld 438
	imul	edi,ebx
439
	push	eax
440
	lea	eax,[eax*3]
441
	add	edi,eax
442
	pop	eax
384 mikedld 443
	add	edi,[LFBAddress]
129 mikedld 444
  .xxx: push	eax esi edi eax
445
    @@: ;movsd
384 mikedld 446
	;dec    esi
447
	;dec    edi
129 mikedld 448
	movsw
449
	movsb
450
	inc	dword[esp]
451
	cmp	[esp],ecx
452
	jl	@b
453
	pop	eax edi esi eax
454
	add	esi,[esp+4*8]
384 mikedld 455
	add	edi,[BytesPerScanLine]
129 mikedld 456
	inc	ebx
457
	cmp	ebx,edx
458
	jl	.xxx
459
	popad
460
  .skip:
461
	add	esi,SR
462
	dec	edi
463
	jnz	.nx
464
 
465
  .exit:
384 mikedld 466
	add	esp,4
129 mikedld 467
	sti
468
	popad
469
	xor	eax,eax
470
	retn
471
endf
472
 
473
;-----------------------------------------------------------------------------
474
func vm_mike_draw_bg.24 ;/////////////////////////////////////////////////////
475
;-----------------------------------------------------------------------------
476
begin
477
	pushad
478
 
479
	cmp	byte[bg_type],BGT_TILE
480
	je	.tiled
481
 
482
	mov	eax,[bg_width]
384 mikedld 483
	cmp	eax,[ScreenWidth]
129 mikedld 484
	jne	@f
485
	mov	eax,[bg_height]
384 mikedld 486
	cmp	eax,[ScreenHeight]
129 mikedld 487
	je	.tiled
488
    @@:
489
	imul	eax,[bg_width],3
384 mikedld 490
	mov	[bg_BytesPerScanLine],eax
129 mikedld 491
 
492
	mov	eax,[viewport.left]
493
	mov	ebx,[viewport.top]
494
	mov	ecx,[viewport.right]
495
	mov	edx,[viewport.bottom]
496
 
497
	cmp	[bg_width],1
498
	jne	@f
499
	cmp	[bg_height],1
500
	je	.color
501
    @@:
502
	cli
503
 
504
	call	[SF.draw_mouse_under]
384 mikedld 505
	mov	byte[MOUSE_VISIBLE],0
129 mikedld 506
 
507
	mov	esi,[CLIP_RECTS+4]
508
	mov	ebp,[esi]
509
	or	ebp,ebp
510
	jz	.exit
511
	add	esi,4
512
  .nx:	jif	ecx,l,[rr.left],.skip
513
	jif	eax,ge,[rr.right],.skip
514
	jif	edx,l,[rr.top],.skip
515
	jif	ebx,ge,[rr.bottom],.skip
516
	pushad
517
	jif	eax,ge,[rr.left],@f
518
	mov	eax,[rr.left]
519
    @@: jif	ebx,ge,[rr.top],@f
520
	mov	ebx,[rr.top]
521
    @@: jif	ecx,l,[rr.right],@f
522
	mov	ecx,[rr.right]
523
    @@: jif	edx,l,[rr.bottom],@f
524
	mov	edx,[rr.bottom]
384 mikedld 525
    @@: ;call   is_intersect_rc
526
	;jc     .put
527
	;cmp    [mouse_invisible],0
528
	;jne    .put
529
	;call   [SF.draw_mouse_under]
530
	;mov    [mouse_invisible],1
531
  .put: mov	ebp,[BytesPerScanLine]
129 mikedld 532
	imul	ebp,ebx
533
	push	eax
534
	lea	eax,[eax*3]
535
	add	ebp,eax
536
	pop	eax
384 mikedld 537
	add	ebp,[LFBAddress]
129 mikedld 538
  .xxx: push	eax ebp
539
    @@: push	ebp
540
	call	[set_bank]
541
	push	eax edx
542
	mul	[bg_width]
384 mikedld 543
	div	dword[ScreenWidth]
129 mikedld 544
	lea	edi,[eax*3]
545
	mov	eax,ebx
546
	mul	[bg_height]
384 mikedld 547
	div	dword[ScreenHeight]
548
	mul	[bg_BytesPerScanLine]
129 mikedld 549
	add	edi,eax
384 mikedld 550
	add	edi,IMG_BACKGROUND
129 mikedld 551
	mov	eax,[edi]
552
	mov	[ebp],eax
384 mikedld 553
	pop	edx eax
129 mikedld 554
	pop	ebp
555
	add	ebp,3
556
	inc	eax
557
	cmp	eax,ecx
558
	jl	@b
559
	pop	ebp eax
384 mikedld 560
	add	ebp,[BytesPerScanLine]
129 mikedld 561
	inc	ebx
562
	cmp	ebx,edx
563
	jl	.xxx
564
	popad
565
  .skip:
566
	add	esi,SR
567
	dec	ebp
568
	jnz	.nx
569
 
570
  .exit:
571
	sti
572
	popad
573
	retn
574
 
575
  .tiled:
384 mikedld 576
	mov	eax,IMG_BACKGROUND
129 mikedld 577
	mov	ebx,[bg_width-2]
578
	mov	bx,word[bg_height]
579
	xor	ecx,ecx
580
  .lp1: push	eax
581
	call	vm_mike_put_image.24.direct
582
	pop	eax
583
	rol	ecx,16
584
	add	cx,word[bg_width]
384 mikedld 585
	cmp	cx,word[ScreenWidth]
129 mikedld 586
	jae	@f
587
	rol	ecx,16
588
	jmp	.lp1
589
    @@: shr	ecx,16
590
	add	ecx,[bg_height]
384 mikedld 591
	cmp	ecx,[ScreenHeight]
129 mikedld 592
	jb	.lp1
593
	popad
594
	retn
595
 
596
  .color:
384 mikedld 597
	mov	edi,[IMG_BACKGROUND]
129 mikedld 598
	and	edi,0x00FFFFFF
599
	call	vm_mike_draw_rect.24
600
	popad
601
	retn
602
endf