Rev 5161 | Rev 5349 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2455 | mario79 | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
4850 | mario79 | 3 | ;; Copyright (C) KolibriOS team 2011-2014. All rights reserved. ;; |
2455 | mario79 | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1894 | serge | 7 | |
4850 | mario79 | 8 | $Revision: 5164 $ |
9 | |||
10 | |||
2384 | hidnplayr | 11 | struct BLITTER_BLOCK |
12 | xmin dd ? |
||
13 | ymin dd ? |
||
14 | xmax dd ? |
||
15 | ymax dd ? |
||
16 | ends |
||
1894 | serge | 17 | |
18 | |||
2384 | hidnplayr | 19 | struct BLITTER |
2988 | Serge | 20 | dc RECT |
21 | sc RECT |
||
2384 | hidnplayr | 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 |
||
1894 | serge | 28 | |
2384 | hidnplayr | 29 | bitmap dd ? ; 56 |
30 | stride dd ? ; 60 |
||
31 | ends |
||
1894 | serge | 32 | |
33 | |||
2988 | Serge | 34 | |
1894 | serge | 35 | align 4 |
2988 | Serge | 36 | block_clip: |
37 | ;esi= clip RECT ptr |
||
38 | ;edi= RECT ptr |
||
39 | ;return code: |
||
40 | ;eax= 0 - draw, 1 - don't draw |
||
1894 | serge | 41 | |
2288 | clevermous | 42 | push ebx |
1894 | serge | 43 | |
2988 | Serge | 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 |
||
1894 | serge | 48 | |
2988 | Serge | 49 | cmp eax, edx ;left >= clip.right |
50 | jge .fail |
||
1894 | serge | 51 | |
2988 | Serge | 52 | cmp ebx, ecx ;right < clip.left |
53 | jl .fail |
||
1894 | serge | 54 | |
2988 | Serge | 55 | cmp eax, ecx ;left >= clip.left |
56 | jae @F |
||
1894 | serge | 57 | |
2988 | Serge | 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 |
||
2288 | clevermous | 91 | pop ebx |
2988 | Serge | 92 | xor eax, eax |
1894 | serge | 93 | ret |
2988 | Serge | 94 | .fail: |
95 | pop ebx |
||
96 | mov eax, 1 |
||
97 | ret |
||
1894 | serge | 98 | |
2988 | Serge | 99 | |
1894 | serge | 100 | align 4 |
101 | blit_clip: |
||
102 | |||
2988 | Serge | 103 | .sx0 equ 8 |
104 | .sy0 equ 12 |
||
105 | .sx1 equ 16 |
||
106 | .sy1 equ 20 |
||
1894 | serge | 107 | |
2988 | Serge | 108 | .dx0 equ 24 |
109 | .dy0 equ 28 |
||
110 | .dx1 equ 32 |
||
111 | .dy1 equ 36 |
||
1894 | serge | 112 | |
113 | |||
2288 | clevermous | 114 | push edi |
115 | push esi |
||
116 | push ebx |
||
117 | sub esp, 40 |
||
1894 | serge | 118 | |
2288 | clevermous | 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] |
||
2988 | Serge | 125 | add eax, [ecx+BLITTER.h] |
2288 | clevermous | 126 | mov [esp+.sx1], edx |
127 | mov [esp+.sy1], eax |
||
1894 | serge | 128 | |
2988 | Serge | 129 | lea edi, [esp+.sx0] |
130 | lea esi, [ebx+BLITTER.sc] |
||
1894 | serge | 131 | |
2288 | clevermous | 132 | call block_clip |
2988 | Serge | 133 | test eax, eax |
2288 | clevermous | 134 | mov esi, 1 |
2988 | Serge | 135 | jnz .done |
1894 | serge | 136 | |
2288 | clevermous | 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 |
||
1894 | serge | 142 | |
2288 | clevermous | 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 |
||
2988 | Serge | 148 | |
2288 | clevermous | 149 | sub edx, edi |
150 | add edx, [esp+.sx1] |
||
151 | mov [esp+.dx1], edx |
||
1894 | serge | 152 | |
2288 | clevermous | 153 | sub eax, ecx |
154 | add eax, [esp+.sy1] |
||
155 | mov [esp+.dy1], eax |
||
1894 | serge | 156 | |
2988 | Serge | 157 | lea edi, [esp+.dx0] |
158 | lea esi, [ebx+BLITTER.dc] |
||
2288 | clevermous | 159 | call block_clip |
160 | test eax, eax |
||
2988 | Serge | 161 | mov esi, 1 |
162 | jnz .done |
||
1894 | serge | 163 | |
2288 | clevermous | 164 | mov edx, [esp+.dx0] |
165 | mov eax, [esp+.dx1] |
||
166 | sub eax, edx |
||
167 | mov [ebx+BLITTER.w], eax |
||
1894 | serge | 168 | |
2288 | clevermous | 169 | mov eax, [esp+.dy0] |
170 | mov ecx, [esp+.dy1] |
||
171 | sub ecx, eax |
||
172 | mov [ebx+BLITTER.h], ecx |
||
1894 | serge | 173 | |
2288 | clevermous | 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 |
||
1894 | serge | 178 | |
2288 | clevermous | 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 |
||
2988 | Serge | 186 | .done: |
2288 | clevermous | 187 | mov eax, esi |
188 | add esp, 40 |
||
189 | pop ebx |
||
190 | pop esi |
||
191 | pop edi |
||
1894 | serge | 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: |
||
2288 | clevermous | 208 | push ebp |
209 | push edi |
||
210 | push esi |
||
211 | push ebx |
||
4444 | clevermous | 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 |
||
1894 | serge | 219 | |
2288 | clevermous | 220 | mov eax, [TASK_BASE] |
221 | mov ebx, [eax-twdw + WDATA.box.width] |
||
222 | mov edx, [eax-twdw + WDATA.box.height] |
||
2988 | Serge | 223 | inc ebx |
224 | inc edx |
||
1894 | serge | 225 | |
2288 | clevermous | 226 | xor eax, eax |
1894 | serge | 227 | |
2988 | Serge | 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 |
||
1894 | serge | 232 | |
2988 | Serge | 233 | mov [esp+BLITTER.sc.left], eax |
234 | mov [esp+BLITTER.sc.top], eax |
||
2288 | clevermous | 235 | mov eax, [ecx+24] |
2988 | Serge | 236 | |
237 | mov [esp+BLITTER.sc.right], eax |
||
2288 | clevermous | 238 | mov eax, [ecx+28] |
1894 | serge | 239 | |
2988 | Serge | 240 | mov [esp+BLITTER.sc.bottom], eax |
241 | |||
2288 | clevermous | 242 | mov eax, [ecx] |
243 | mov [esp+BLITTER.dst_x], eax |
||
244 | mov eax, [ecx+4] |
||
245 | mov [esp+BLITTER.dst_y], eax |
||
1894 | serge | 246 | |
2288 | clevermous | 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 |
||
1894 | serge | 255 | |
256 | |||
2288 | clevermous | 257 | mov eax, [ecx+32] |
4444 | clevermous | 258 | mov [esp+BLITTER.bitmap], eax |
2288 | clevermous | 259 | mov eax, [ecx+36] |
4444 | clevermous | 260 | mov [esp+BLITTER.stride], eax |
1894 | serge | 261 | |
2288 | clevermous | 262 | mov ecx, esp |
263 | call blit_clip |
||
264 | test eax, eax |
||
265 | jne .L57 |
||
1894 | serge | 266 | |
2288 | clevermous | 267 | mov eax, [TASK_BASE] |
1894 | serge | 268 | |
2288 | clevermous | 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] |
||
2430 | mario79 | 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 | |||
4444 | clevermous | 280 | mov eax, ebx |
281 | shl eax, 16 |
||
282 | mov ax, bp |
||
283 | mov [esp+.position], eax |
||
284 | |||
2288 | clevermous | 285 | mov edi, ebp |
1894 | serge | 286 | |
2480 | mario79 | 287 | ; imul edi, [_display.pitch] |
288 | mov edi, [BPSLine_calc_area+edi*4] |
||
2446 | mario79 | 289 | ; imul ebp, [_display.width] |
2480 | mario79 | 290 | mov ebp, [d_width_calc_area+ebp*4] |
2446 | mario79 | 291 | |
2288 | clevermous | 292 | add ebp, ebx |
293 | add ebp, [_WinMapAddress] |
||
1894 | serge | 294 | |
2288 | clevermous | 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] |
||
1894 | serge | 300 | |
2430 | mario79 | 301 | mov eax, ecx |
2288 | clevermous | 302 | mov ecx, [esp+BLITTER.h] |
303 | mov edx, [esp+BLITTER.w] |
||
1894 | serge | 304 | |
2288 | clevermous | 305 | test ecx, ecx ;FIXME check clipping |
306 | jz .L57 |
||
1894 | serge | 307 | |
2288 | clevermous | 308 | test edx, edx |
309 | jz .L57 |
||
1894 | serge | 310 | |
5154 | hidnplayr | 311 | cmp [_display.bits_per_pixel], 32 |
2288 | clevermous | 312 | jne .core_24 |
1894 | serge | 313 | |
2288 | clevermous | 314 | lea edi, [edi+ebx*4] |
1894 | serge | 315 | |
2288 | clevermous | 316 | mov ebx, [CURRENT_TASK] |
4444 | clevermous | 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: |
||
1894 | serge | 324 | align 4 |
325 | .outer32: |
||
326 | |||
327 | align 4 |
||
328 | .inner32: |
||
4444 | clevermous | 329 | cmp [ebp], bl |
2449 | mario79 | 330 | jne .skip |
2430 | mario79 | 331 | ;-------------------------------------- |
4444 | clevermous | 332 | mov eax, [esi] |
1894 | serge | 333 | |
4444 | clevermous | 334 | mov ecx, [esp+.position] |
2430 | mario79 | 335 | |
336 | ; check mouse area for putpixel |
||
337 | call [_display.check_mouse] |
||
2448 | mario79 | 338 | ;-------------------------------------- |
2430 | mario79 | 339 | ; store to real LFB |
4444 | clevermous | 340 | mov [LFB_BASE+edi], eax |
2430 | mario79 | 341 | ;-------------------------------------- |
342 | align 4 |
||
2449 | mario79 | 343 | .skip: |
4444 | clevermous | 344 | add esi, 4 |
345 | add edi, 4 |
||
346 | inc ebp |
||
347 | add [esp+.position], 1 shl 16 |
||
2288 | clevermous | 348 | dec edx |
349 | jnz .inner32 |
||
1894 | serge | 350 | |
2288 | clevermous | 351 | add esi, [esp+BLITTER.stride] |
352 | add edi, [_display.pitch] |
||
353 | add ebp, [_display.width] |
||
1894 | serge | 354 | |
2288 | clevermous | 355 | mov edx, [esp+BLITTER.w] |
4444 | clevermous | 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 |
||
2288 | clevermous | 364 | dec [esp+BLITTER.h] |
365 | jnz .outer32 |
||
4444 | clevermous | 366 | jmp .done |
367 | .core_32.hardware_cursor: |
||
368 | align 4 |
||
369 | .hw.outer32: |
||
370 | xor ecx, ecx |
||
1894 | serge | 371 | |
4444 | clevermous | 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 | |||
1894 | serge | 393 | .done: |
2453 | mario79 | 394 | ; call [draw_pointer] |
2988 | Serge | 395 | ; call __sys_draw_pointer |
1894 | serge | 396 | .L57: |
4444 | clevermous | 397 | add esp, .local_vars_size |
2288 | clevermous | 398 | pop ebx |
399 | pop esi |
||
400 | pop edi |
||
401 | pop ebp |
||
1894 | serge | 402 | ret |
403 | |||
404 | .core_24: |
||
5161 | hidnplayr | 405 | cmp [_display.bits_per_pixel], 24 |
406 | jne .core_16 |
||
407 | |||
2288 | clevermous | 408 | lea ebx, [ebx+ebx*2] |
409 | lea edi, [LFB_BASE+edi+ebx] |
||
410 | mov ebx, [CURRENT_TASK] |
||
1894 | serge | 411 | |
412 | align 4 |
||
413 | .outer24: |
||
4444 | clevermous | 414 | mov [esp+.extra_var1], edi |
2288 | clevermous | 415 | xor ecx, ecx |
1894 | serge | 416 | |
417 | align 4 |
||
418 | .inner24: |
||
5161 | hidnplayr | 419 | cmp [ebp+ecx], bl ; Does the process own this pixel? |
2449 | mario79 | 420 | jne .skip_1 |
2430 | mario79 | 421 | ;-------------------------------------- |
422 | push eax |
||
2288 | clevermous | 423 | mov eax, [esi+ecx*4] |
1894 | serge | 424 | |
2288 | clevermous | 425 | lea edi, [edi+ecx*2] |
2430 | mario79 | 426 | |
2448 | mario79 | 427 | ; check for hardware cursor |
2451 | mario79 | 428 | cmp [_display.select_cursor], select_cursor |
429 | je @f |
||
2448 | mario79 | 430 | cmp [_display.select_cursor], 0 |
431 | jne .no_mouseunder_1 |
||
432 | ;-------------------------------------- |
||
433 | align 4 |
||
434 | @@: |
||
2430 | mario79 | 435 | push ecx |
436 | |||
437 | mov ecx, [esp+4] |
||
438 | ror ecx, 16 |
||
439 | sub ecx, edx |
||
440 | rol ecx, 16 |
||
441 | sub ecx, [esp+BLITTER.h + 8] |
||
442 | |||
443 | ; check mouse area for putpixel |
||
444 | call [_display.check_mouse] |
||
445 | pop ecx |
||
2448 | mario79 | 446 | ;-------------------------------------- |
447 | align 4 |
||
448 | .no_mouseunder_1: |
||
2288 | clevermous | 449 | mov [edi+ecx], ax |
450 | shr eax, 16 |
||
451 | mov [edi+ecx+2], al |
||
2430 | mario79 | 452 | |
453 | pop eax |
||
454 | ;-------------------------------------- |
||
455 | align 4 |
||
2449 | mario79 | 456 | .skip_1: |
2288 | clevermous | 457 | inc ecx |
458 | dec edx |
||
459 | jnz .inner24 |
||
1894 | serge | 460 | |
2288 | clevermous | 461 | add esi, [esp+BLITTER.stride] |
5164 | hidnplayr | 462 | mov edi, [esp+.extra_var1] |
2288 | clevermous | 463 | add edi, [_display.pitch] |
464 | add ebp, [_display.width] |
||
1894 | serge | 465 | |
2288 | clevermous | 466 | mov edx, [esp+BLITTER.w] |
467 | dec [esp+BLITTER.h] |
||
468 | jnz .outer24 |
||
1894 | serge | 469 | |
2288 | clevermous | 470 | jmp .done |
5161 | hidnplayr | 471 | |
472 | |||
473 | .core_16: |
||
474 | lea edi, [LFB_BASE+edi+ebx*2] |
||
475 | mov ebx, [CURRENT_TASK] |
||
476 | |||
5164 | hidnplayr | 477 | .outer16: |
5161 | hidnplayr | 478 | mov [esp+.extra_var1], edi |
479 | xor ecx, ecx |
||
480 | |||
5164 | hidnplayr | 481 | .inner16: |
5161 | hidnplayr | 482 | cmp [ebp+ecx], bl ; Does the process own this pixel? |
483 | jne .skip_2 |
||
484 | ;-------------------------------------- |
||
485 | push eax |
||
486 | mov eax, [esi+ecx*4] |
||
487 | |||
488 | ; check for hardware cursor |
||
489 | cmp [_display.select_cursor], select_cursor |
||
490 | je @f |
||
491 | cmp [_display.select_cursor], 0 |
||
492 | jne .no_mouseunder_2 |
||
493 | ;-------------------------------------- |
||
5164 | hidnplayr | 494 | @@: |
5161 | hidnplayr | 495 | push ecx |
496 | |||
497 | mov ecx, [esp+4] |
||
498 | ror ecx, 16 |
||
499 | sub ecx, edx |
||
500 | rol ecx, 16 |
||
501 | sub ecx, [esp+BLITTER.h + 8] |
||
502 | |||
503 | ; check mouse area for putpixel |
||
504 | call [_display.check_mouse] |
||
505 | pop ecx |
||
506 | ;-------------------------------------- |
||
5164 | hidnplayr | 507 | .no_mouseunder_2: |
5161 | hidnplayr | 508 | ; convert to 16 bpp and store to LFB |
509 | and eax, 00000000111110001111110011111000b |
||
510 | shr ah, 2 |
||
511 | shr ax, 3 |
||
512 | ror eax, 8 |
||
513 | add al, ah |
||
514 | rol eax, 8 |
||
515 | mov [edi+ecx*2], ax |
||
516 | pop eax |
||
517 | ;-------------------------------------- |
||
5164 | hidnplayr | 518 | .skip_2: |
5161 | hidnplayr | 519 | inc ecx |
520 | dec edx |
||
521 | jnz .inner16 |
||
522 | |||
523 | add esi, [esp+BLITTER.stride] |
||
5164 | hidnplayr | 524 | mov edi, [esp+.extra_var1] |
5161 | hidnplayr | 525 | add edi, [_display.pitch] |
526 | add ebp, [_display.width] |
||
527 | |||
528 | mov edx, [esp+BLITTER.w] |
||
529 | dec [esp+BLITTER.h] |
||
530 | jnz .outer16 |
||
531 | |||
532 | jmp .done=>>=>> |
||
533 |