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