Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
4429 Serge 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
4923 Serge 3
;; Copyright (C) KolibriOS team 2011-2014. All rights reserved. ;;
4429 Serge 4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
4923 Serge 8
$Revision: 4850 $
9
 
10
 
4429 Serge 11
struct  BLITTER_BLOCK
12
        xmin            dd ?
13
        ymin            dd ?
14
        xmax            dd ?
15
        ymax            dd ?
16
ends
17
 
18
 
19
struct  BLITTER
20
        dc              RECT
21
        sc              RECT
22
        dst_x           dd ?            ;  32
23
        dst_y           dd ?            ;  36
24
        src_x           dd ?            ;  40
25
        src_y           dd ?            ;  44
26
        w               dd ?            ;  48
27
        h               dd ?            ;  52
28
 
29
        bitmap          dd ?            ;  56
30
        stride          dd ?            ;  60
31
ends
32
 
33
 
34
 
35
align 4
36
block_clip:
37
;esi= clip RECT ptr
38
;edi= RECT ptr
39
;return code:
40
;eax= 0 - draw, 1 - don't draw
41
 
42
        push    ebx
43
 
44
        mov     eax, [edi+RECT.left]
45
        mov     ebx, [edi+RECT.right]
46
        mov     ecx, [esi+RECT.left]    ;clip.left
47
        mov     edx, [esi+RECT.right]   ;clip.right
48
 
49
        cmp     eax, edx                ;left >= clip.right
50
        jge     .fail
51
 
52
        cmp     ebx, ecx                ;right < clip.left
53
        jl      .fail
54
 
55
        cmp     eax, ecx                ;left >= clip.left
56
        jae     @F
57
 
58
        mov     eax, ecx
59
@@:
60
        mov     [edi+RECT.left], eax
61
 
62
        cmp     ebx, edx                ;right <= clip.right
63
        jle     @f
64
        mov     ebx, edx
65
@@:
66
        mov     [edi+RECT.right], ebx
67
 
68
        mov     eax, [edi+RECT.top]
69
        mov     ebx, [edi+RECT.bottom]
70
        mov     ecx, [esi+RECT.top]     ;clip.top
71
        mov     edx, [esi+RECT.bottom]  ;clip.bottom
72
 
73
        cmp     eax, edx                ;top >= clip.bottom
74
        jge     .fail
75
 
76
        cmp     ebx, ecx                ;bottom < clip.top
77
        jl      .fail
78
 
79
        cmp     eax, ecx                ;top >= clip.top
80
        jae     @F
81
 
82
        mov     eax, ecx
83
@@:
84
        mov     [edi+RECT.top], eax
85
 
86
        cmp     ebx, edx                ;bottom <= clip.bottom
87
        jle     @f
88
        mov     ebx, edx
89
@@:
90
        mov     [edi+RECT.bottom], ebx
91
        pop     ebx
92
        xor     eax, eax
93
        ret
94
.fail:
95
        pop     ebx
96
        mov     eax, 1
97
        ret
98
 
99
 
100
align 4
101
blit_clip:
102
 
103
.sx0   equ 8
104
.sy0   equ 12
105
.sx1   equ 16
106
.sy1   equ 20
107
 
108
.dx0   equ 24
109
.dy0   equ 28
110
.dx1   equ 32
111
.dy1   equ 36
112
 
113
 
114
        push    edi
115
        push    esi
116
        push    ebx
117
        sub     esp, 40
118
 
119
        mov     ebx, ecx
120
        mov     edx, [ecx+BLITTER.src_x]
121
        mov     [esp+.sx0], edx
122
        mov     eax, [ecx+BLITTER.src_y]
123
        mov     [esp+.sy0], eax
124
        add     edx, [ecx+BLITTER.w]
125
        add     eax, [ecx+BLITTER.h]
126
        mov     [esp+.sx1], edx
127
        mov     [esp+.sy1], eax
128
 
129
        lea     edi, [esp+.sx0]
130
        lea     esi, [ebx+BLITTER.sc]
131
 
132
        call    block_clip
133
        test    eax, eax
134
        mov     esi, 1
135
        jnz     .done
136
 
137
        mov     edi, [esp+.sx0]
138
        mov     edx, [ebx+BLITTER.dst_x]
139
        add     edx, edi
140
        sub     edx, [ebx+BLITTER.src_x]
141
        mov     [esp+.dx0], edx
142
 
143
        mov     ecx, [esp+.sy0]
144
        mov     eax, [ebx+BLITTER.dst_y]
145
        add     eax, ecx
146
        sub     eax, [ebx+BLITTER.src_y]
147
        mov     [esp+.dy0], eax
148
 
149
        sub     edx, edi
150
        add     edx, [esp+.sx1]
151
        mov     [esp+.dx1], edx
152
 
153
        sub     eax, ecx
154
        add     eax, [esp+.sy1]
155
        mov     [esp+.dy1], eax
156
 
157
        lea     edi, [esp+.dx0]
158
        lea     esi, [ebx+BLITTER.dc]
159
        call    block_clip
160
        test    eax, eax
161
        mov     esi, 1
162
        jnz     .done
163
 
164
        mov     edx, [esp+.dx0]
165
        mov     eax, [esp+.dx1]
166
        sub     eax, edx
167
        mov     [ebx+BLITTER.w], eax
168
 
169
        mov     eax, [esp+.dy0]
170
        mov     ecx, [esp+.dy1]
171
        sub     ecx, eax
172
        mov     [ebx+BLITTER.h], ecx
173
 
174
        mov     ecx, [ebx+BLITTER.src_x]
175
        add     ecx, edx
176
        sub     ecx, [ebx+BLITTER.dst_x]
177
        mov     [ebx+BLITTER.src_x], ecx
178
 
179
        mov     ecx, [ebx+BLITTER.src_y]
180
        add     ecx, eax
181
        sub     ecx, [ebx+BLITTER.dst_y]
182
        mov     [ebx+BLITTER.src_y], ecx
183
        mov     [ebx+BLITTER.dst_x], edx
184
        mov     [ebx+BLITTER.dst_y], eax
185
        xor     esi, esi
186
.done:
187
        mov     eax, esi
188
        add     esp, 40
189
        pop     ebx
190
        pop     esi
191
        pop     edi
192
 
193
 
194
purge .sx0
195
purge .sy0
196
purge .sx1
197
purge .sy1
198
 
199
purge .dx0
200
purge .dy0
201
purge .dx1
202
purge .dy1
203
 
204
        ret
205
 
206
align 4
207
blit_32:
208
        push    ebp
209
        push    edi
210
        push    esi
211
        push    ebx
4457 Serge 212
virtual at sizeof.BLITTER
213
.position       dd      ? ; (x shl 16) + y
214
; ???
215
.extra_var1     dd      ?
216
.local_vars_size = $
217
end virtual
218
        sub     esp, .local_vars_size
4429 Serge 219
 
220
        mov     eax, [TASK_BASE]
221
        mov     ebx, [eax-twdw + WDATA.box.width]
222
        mov     edx, [eax-twdw + WDATA.box.height]
223
        inc     ebx
224
        inc     edx
225
 
226
        xor     eax, eax
227
 
228
        mov     [esp+BLITTER.dc.left], eax
229
        mov     [esp+BLITTER.dc.top], eax
230
        mov     [esp+BLITTER.dc.right], ebx
231
        mov     [esp+BLITTER.dc.bottom], edx
232
 
233
        mov     [esp+BLITTER.sc.left], eax
234
        mov     [esp+BLITTER.sc.top], eax
235
        mov     eax, [ecx+24]
236
 
237
        mov     [esp+BLITTER.sc.right], eax
238
        mov     eax, [ecx+28]
239
 
240
        mov     [esp+BLITTER.sc.bottom], eax
241
 
242
        mov     eax, [ecx]
243
        mov     [esp+BLITTER.dst_x], eax
244
        mov     eax, [ecx+4]
245
        mov     [esp+BLITTER.dst_y], eax
246
 
247
        mov     eax, [ecx+16]
248
        mov     [esp+BLITTER.src_x], eax
249
        mov     eax, [ecx+20]
250
        mov     [esp+BLITTER.src_y], eax
251
        mov     eax, [ecx+8]
252
        mov     [esp+BLITTER.w], eax
253
        mov     eax, [ecx+12]
254
        mov     [esp+BLITTER.h], eax
255
 
256
 
257
        mov     eax, [ecx+32]
4457 Serge 258
        mov     [esp+BLITTER.bitmap], eax
4429 Serge 259
        mov     eax, [ecx+36]
4457 Serge 260
        mov     [esp+BLITTER.stride], eax
4429 Serge 261
 
262
        mov     ecx, esp
263
        call    blit_clip
264
        test    eax, eax
265
        jne     .L57
266
 
267
        mov     eax, [TASK_BASE]
268
 
269
        mov     ebx, [esp+BLITTER.dst_x]
270
        mov     ebp, [esp+BLITTER.dst_y]
271
        add     ebx, [eax-twdw + WDATA.box.left]
272
        add     ebp, [eax-twdw + WDATA.box.top]
273
 
274
        mov     ecx, ebx
275
        add     ecx, [esp+BLITTER.w]
276
        shl     ecx, 16
277
        mov     cx, bp
278
        add     ecx, [esp+BLITTER.h]
279
 
4457 Serge 280
        mov     eax, ebx
281
        shl     eax, 16
282
        mov     ax, bp
283
        mov     [esp+.position], eax
284
 
4429 Serge 285
        mov     edi, ebp
286
 
287
;        imul    edi, [_display.pitch]
288
        mov     edi, [BPSLine_calc_area+edi*4]
289
;        imul    ebp, [_display.width]
290
        mov     ebp, [d_width_calc_area+ebp*4]
291
 
292
        add     ebp, ebx
293
        add     ebp, [_WinMapAddress]
294
 
295
        mov     eax, [esp+BLITTER.src_y]
296
        imul    eax, [esp+BLITTER.stride]
297
        mov     esi, [esp+BLITTER.src_x]
298
        lea     esi, [eax+esi*4]
299
        add     esi, [esp+BLITTER.bitmap]
300
 
301
        mov     eax, ecx
302
        mov     ecx, [esp+BLITTER.h]
303
        mov     edx, [esp+BLITTER.w]
304
 
305
        test    ecx, ecx    ;FIXME check clipping
306
        jz      .L57
307
 
308
        test    edx, edx
309
        jz      .L57
310
 
311
        cmp     [_display.bpp], 32
312
        jne     .core_24
313
 
314
        lea     edi, [edi+ebx*4]
315
 
316
        mov     ebx, [CURRENT_TASK]
4457 Serge 317
; check for hardware cursor
318
        cmp     [_display.select_cursor], select_cursor
319
        je      .core_32.software_cursor
320
        cmp     [_display.select_cursor], 0
321
        jne     .core_32.hardware_cursor
322
;--------------------------------------
323
.core_32.software_cursor:
4429 Serge 324
align 4
325
.outer32:
326
 
327
align 4
328
.inner32:
4457 Serge 329
        cmp     [ebp], bl
4429 Serge 330
        jne     .skip
331
;--------------------------------------
4457 Serge 332
        mov     eax, [esi]
4429 Serge 333
 
4457 Serge 334
        mov     ecx, [esp+.position]
4429 Serge 335
 
336
; check mouse area for putpixel
337
        call    [_display.check_mouse]
338
;--------------------------------------
339
; store to real LFB
4457 Serge 340
        mov     [LFB_BASE+edi], eax
4429 Serge 341
;--------------------------------------
342
align 4
343
.skip:
4457 Serge 344
        add     esi, 4
345
        add     edi, 4
346
        inc     ebp
347
        add     [esp+.position], 1 shl 16
4429 Serge 348
        dec     edx
349
        jnz     .inner32
350
 
351
        add     esi, [esp+BLITTER.stride]
352
        add     edi, [_display.pitch]
353
        add     ebp, [_display.width]
354
 
355
        mov     edx, [esp+BLITTER.w]
4457 Serge 356
        mov     eax, edx
357
        inc     [esp+.position]
358
        sub     ebp, edx
359
        shl     eax, 2
360
        sub     esi, eax
361
        sub     edi, eax
362
        shl     eax, 16-2
363
        sub     [esp+.position], eax
4429 Serge 364
        dec     [esp+BLITTER.h]
365
        jnz     .outer32
4457 Serge 366
        jmp     .done
367
.core_32.hardware_cursor:
368
align 4
369
.hw.outer32:
370
        xor     ecx, ecx
4429 Serge 371
 
4457 Serge 372
align 4
373
.hw.inner32:
374
        cmp     [ebp+ecx], bl
375
        jne     .hw.skip
376
        mov     eax, [esi+ecx*4]
377
        mov     [LFB_BASE+edi+ecx*4], eax
378
 
379
align 4
380
.hw.skip:
381
        inc     ecx
382
        dec     edx
383
        jnz     .hw.inner32
384
 
385
        add     esi, [esp+BLITTER.stride]
386
        add     edi, [_display.pitch]
387
        add     ebp, [_display.width]
388
 
389
        mov     edx, [esp+BLITTER.w]
390
        dec     [esp+BLITTER.h]
391
        jnz     .hw.outer32
392
 
4429 Serge 393
.done:
394
;        call    [draw_pointer]
395
;        call    __sys_draw_pointer
396
.L57:
4457 Serge 397
        add     esp, .local_vars_size
4429 Serge 398
        pop     ebx
399
        pop     esi
400
        pop     edi
401
        pop     ebp
402
        ret
403
 
404
.core_24:
405
        lea     ebx, [ebx+ebx*2]
406
        lea     edi, [LFB_BASE+edi+ebx]
407
        mov     ebx, [CURRENT_TASK]
408
 
409
align 4
410
.outer24:
4457 Serge 411
        mov     [esp+.extra_var1], edi
4429 Serge 412
        xor     ecx, ecx
413
 
414
align 4
415
.inner24:
416
        cmp     [ebp+ecx], bl
417
        jne     .skip_1
418
;--------------------------------------
419
        push    eax
420
        mov     eax, [esi+ecx*4]
421
 
422
        lea     edi, [edi+ecx*2]
423
 
424
; check for hardware cursor
425
        cmp     [_display.select_cursor], select_cursor
426
        je      @f
427
        cmp     [_display.select_cursor], 0
428
        jne     .no_mouseunder_1
429
;--------------------------------------
430
align 4
431
@@:
432
        push    ecx
433
 
434
        mov     ecx, [esp+4]
435
        ror     ecx, 16
436
        sub     ecx, edx
437
        rol     ecx, 16
438
        sub     ecx, [esp+BLITTER.h + 8]
439
 
440
; check mouse area for putpixel
441
        call    [_display.check_mouse]
442
        pop     ecx
443
;--------------------------------------
444
align 4
445
.no_mouseunder_1:
446
        mov     [edi+ecx], ax
447
        shr     eax, 16
448
        mov     [edi+ecx+2], al
449
 
450
        pop     eax
451
;--------------------------------------
452
align 4
453
.skip_1:
4457 Serge 454
        mov     edi, [esp+.extra_var1]
4429 Serge 455
        inc     ecx
456
        dec     edx
457
        jnz     .inner24
458
 
459
        add     esi, [esp+BLITTER.stride]
460
        add     edi, [_display.pitch]
461
        add     ebp, [_display.width]
462
 
463
        mov     edx, [esp+BLITTER.w]
464
        dec     [esp+BLITTER.h]
465
        jnz     .outer24
466
 
467
        jmp     .done