Subversion Repositories Kolibri OS

Rev

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

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