Rev 5351 | Rev 7136 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2455 | mario79 | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
5363 | yogev_ezra | 3 | ;; Copyright (C) KolibriOS team 2011-2015. All rights reserved. ;; |
2455 | mario79 | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1894 | serge | 7 | |
4850 | mario79 | 8 | $Revision: 5363 $ |
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: |
||
5349 | serge | 40 | ;CF= 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 |
5349 | serge | 56 | jge @F |
1894 | serge | 57 | |
5349 | serge | 58 | mov [edi+RECT.left], ecx |
2988 | Serge | 59 | @@: |
60 | cmp ebx, edx ;right <= clip.right |
||
61 | jle @f |
||
5349 | serge | 62 | |
63 | mov [edi+RECT.right], edx |
||
2988 | Serge | 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 |
||
5349 | serge | 77 | jge @F |
2988 | Serge | 78 | |
5349 | serge | 79 | mov [edi+RECT.top], ecx |
2988 | Serge | 80 | @@: |
81 | cmp ebx, edx ;bottom <= clip.bottom |
||
82 | jle @f |
||
5349 | serge | 83 | |
84 | mov [edi+RECT.bottom], edx |
||
2988 | Serge | 85 | @@: |
2288 | clevermous | 86 | pop ebx |
5349 | serge | 87 | clc |
1894 | serge | 88 | ret |
2988 | Serge | 89 | .fail: |
90 | pop ebx |
||
5349 | serge | 91 | stc |
2988 | Serge | 92 | ret |
1894 | serge | 93 | |
2988 | Serge | 94 | |
1894 | serge | 95 | align 4 |
96 | blit_clip: |
||
97 | |||
5349 | serge | 98 | ;return code: |
99 | ;CF= 0 - draw, 1 - don't draw |
||
100 | |||
2988 | Serge | 101 | .sx0 equ 8 |
102 | .sy0 equ 12 |
||
103 | .sx1 equ 16 |
||
104 | .sy1 equ 20 |
||
1894 | serge | 105 | |
2988 | Serge | 106 | .dx0 equ 24 |
107 | .dy0 equ 28 |
||
108 | .dx1 equ 32 |
||
109 | .dy1 equ 36 |
||
1894 | serge | 110 | |
111 | |||
2288 | clevermous | 112 | push edi |
113 | push esi |
||
114 | push ebx |
||
115 | sub esp, 40 |
||
1894 | serge | 116 | |
2288 | clevermous | 117 | mov ebx, ecx |
118 | mov edx, [ecx+BLITTER.src_x] |
||
119 | mov [esp+.sx0], edx |
||
120 | mov eax, [ecx+BLITTER.src_y] |
||
121 | mov [esp+.sy0], eax |
||
122 | add edx, [ecx+BLITTER.w] |
||
2988 | Serge | 123 | add eax, [ecx+BLITTER.h] |
2288 | clevermous | 124 | mov [esp+.sx1], edx |
125 | mov [esp+.sy1], eax |
||
1894 | serge | 126 | |
2988 | Serge | 127 | lea edi, [esp+.sx0] |
128 | lea esi, [ebx+BLITTER.sc] |
||
1894 | serge | 129 | |
2288 | clevermous | 130 | call block_clip |
5349 | serge | 131 | jc .done |
1894 | serge | 132 | |
2288 | clevermous | 133 | mov edi, [esp+.sx0] |
134 | mov edx, [ebx+BLITTER.dst_x] |
||
135 | add edx, edi |
||
136 | sub edx, [ebx+BLITTER.src_x] |
||
137 | mov [esp+.dx0], edx |
||
1894 | serge | 138 | |
2288 | clevermous | 139 | mov ecx, [esp+.sy0] |
140 | mov eax, [ebx+BLITTER.dst_y] |
||
141 | add eax, ecx |
||
142 | sub eax, [ebx+BLITTER.src_y] |
||
143 | mov [esp+.dy0], eax |
||
2988 | Serge | 144 | |
2288 | clevermous | 145 | sub edx, edi |
146 | add edx, [esp+.sx1] |
||
147 | mov [esp+.dx1], edx |
||
1894 | serge | 148 | |
2288 | clevermous | 149 | sub eax, ecx |
150 | add eax, [esp+.sy1] |
||
151 | mov [esp+.dy1], eax |
||
1894 | serge | 152 | |
2988 | Serge | 153 | lea edi, [esp+.dx0] |
154 | lea esi, [ebx+BLITTER.dc] |
||
2288 | clevermous | 155 | call block_clip |
5349 | serge | 156 | jc .done |
1894 | serge | 157 | |
2288 | clevermous | 158 | mov edx, [esp+.dx0] |
159 | mov eax, [esp+.dx1] |
||
160 | sub eax, edx |
||
161 | mov [ebx+BLITTER.w], eax |
||
1894 | serge | 162 | |
2288 | clevermous | 163 | mov eax, [esp+.dy0] |
164 | mov ecx, [esp+.dy1] |
||
165 | sub ecx, eax |
||
166 | mov [ebx+BLITTER.h], ecx |
||
1894 | serge | 167 | |
2288 | clevermous | 168 | mov ecx, [ebx+BLITTER.src_x] |
169 | add ecx, edx |
||
170 | sub ecx, [ebx+BLITTER.dst_x] |
||
171 | mov [ebx+BLITTER.src_x], ecx |
||
1894 | serge | 172 | |
2288 | clevermous | 173 | mov ecx, [ebx+BLITTER.src_y] |
174 | add ecx, eax |
||
175 | sub ecx, [ebx+BLITTER.dst_y] |
||
176 | mov [ebx+BLITTER.src_y], ecx |
||
177 | mov [ebx+BLITTER.dst_x], edx |
||
178 | mov [ebx+BLITTER.dst_y], eax |
||
5349 | serge | 179 | clc |
2988 | Serge | 180 | .done: |
2288 | clevermous | 181 | add esp, 40 |
182 | pop ebx |
||
183 | pop esi |
||
184 | pop edi |
||
1894 | serge | 185 | |
186 | |||
187 | purge .sx0 |
||
188 | purge .sy0 |
||
189 | purge .sx1 |
||
190 | purge .sy1 |
||
191 | |||
192 | purge .dx0 |
||
193 | purge .dy0 |
||
194 | purge .dx1 |
||
195 | purge .dy1 |
||
196 | |||
197 | ret |
||
198 | |||
199 | align 4 |
||
200 | blit_32: |
||
2288 | clevermous | 201 | push ebp |
202 | push edi |
||
203 | push esi |
||
204 | push ebx |
||
4444 | clevermous | 205 | virtual at sizeof.BLITTER |
206 | .position dd ? ; (x shl 16) + y |
||
207 | ; ??? |
||
208 | .extra_var1 dd ? |
||
209 | .local_vars_size = $ |
||
210 | end virtual |
||
211 | sub esp, .local_vars_size |
||
1894 | serge | 212 | |
2288 | clevermous | 213 | mov eax, [TASK_BASE] |
214 | mov ebx, [eax-twdw + WDATA.box.width] |
||
215 | mov edx, [eax-twdw + WDATA.box.height] |
||
2988 | Serge | 216 | inc ebx |
217 | inc edx |
||
1894 | serge | 218 | |
2288 | clevermous | 219 | xor eax, eax |
1894 | serge | 220 | |
2988 | Serge | 221 | mov [esp+BLITTER.dc.left], eax |
222 | mov [esp+BLITTER.dc.top], eax |
||
223 | mov [esp+BLITTER.dc.right], ebx |
||
224 | mov [esp+BLITTER.dc.bottom], edx |
||
1894 | serge | 225 | |
2988 | Serge | 226 | mov [esp+BLITTER.sc.left], eax |
227 | mov [esp+BLITTER.sc.top], eax |
||
2288 | clevermous | 228 | mov eax, [ecx+24] |
2988 | Serge | 229 | |
230 | mov [esp+BLITTER.sc.right], eax |
||
2288 | clevermous | 231 | mov eax, [ecx+28] |
1894 | serge | 232 | |
2988 | Serge | 233 | mov [esp+BLITTER.sc.bottom], eax |
234 | |||
2288 | clevermous | 235 | mov eax, [ecx] |
236 | mov [esp+BLITTER.dst_x], eax |
||
237 | mov eax, [ecx+4] |
||
238 | mov [esp+BLITTER.dst_y], eax |
||
1894 | serge | 239 | |
2288 | clevermous | 240 | mov eax, [ecx+16] |
241 | mov [esp+BLITTER.src_x], eax |
||
242 | mov eax, [ecx+20] |
||
243 | mov [esp+BLITTER.src_y], eax |
||
244 | mov eax, [ecx+8] |
||
245 | mov [esp+BLITTER.w], eax |
||
246 | mov eax, [ecx+12] |
||
247 | mov [esp+BLITTER.h], eax |
||
1894 | serge | 248 | |
249 | |||
2288 | clevermous | 250 | mov eax, [ecx+32] |
4444 | clevermous | 251 | mov [esp+BLITTER.bitmap], eax |
2288 | clevermous | 252 | mov eax, [ecx+36] |
4444 | clevermous | 253 | mov [esp+BLITTER.stride], eax |
1894 | serge | 254 | |
2288 | clevermous | 255 | mov ecx, esp |
256 | call blit_clip |
||
5349 | serge | 257 | jc .L57 |
1894 | serge | 258 | |
2288 | clevermous | 259 | mov eax, [TASK_BASE] |
1894 | serge | 260 | |
2288 | clevermous | 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] |
||
2430 | mario79 | 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 | |||
4444 | clevermous | 272 | mov eax, ebx |
273 | shl eax, 16 |
||
274 | mov ax, bp |
||
275 | mov [esp+.position], eax |
||
276 | |||
2288 | clevermous | 277 | mov edi, ebp |
1894 | serge | 278 | |
2480 | mario79 | 279 | ; imul edi, [_display.pitch] |
280 | mov edi, [BPSLine_calc_area+edi*4] |
||
2446 | mario79 | 281 | ; imul ebp, [_display.width] |
2480 | mario79 | 282 | mov ebp, [d_width_calc_area+ebp*4] |
2446 | mario79 | 283 | |
2288 | clevermous | 284 | add ebp, ebx |
5351 | serge | 285 | add ebp, [_display.win_map] |
1894 | serge | 286 | |
2288 | clevermous | 287 | mov eax, [esp+BLITTER.src_y] |
288 | imul eax, [esp+BLITTER.stride] |
||
289 | mov esi, [esp+BLITTER.src_x] |
||
290 | lea esi, [eax+esi*4] |
||
291 | add esi, [esp+BLITTER.bitmap] |
||
1894 | serge | 292 | |
2430 | mario79 | 293 | mov eax, ecx |
2288 | clevermous | 294 | mov ecx, [esp+BLITTER.h] |
295 | mov edx, [esp+BLITTER.w] |
||
1894 | serge | 296 | |
2288 | clevermous | 297 | test ecx, ecx ;FIXME check clipping |
298 | jz .L57 |
||
1894 | serge | 299 | |
2288 | clevermous | 300 | test edx, edx |
301 | jz .L57 |
||
1894 | serge | 302 | |
5154 | hidnplayr | 303 | cmp [_display.bits_per_pixel], 32 |
2288 | clevermous | 304 | jne .core_24 |
1894 | serge | 305 | |
2288 | clevermous | 306 | lea edi, [edi+ebx*4] |
1894 | serge | 307 | |
2288 | clevermous | 308 | mov ebx, [CURRENT_TASK] |
4444 | clevermous | 309 | ; check for hardware cursor |
310 | cmp [_display.select_cursor], select_cursor |
||
311 | je .core_32.software_cursor |
||
312 | cmp [_display.select_cursor], 0 |
||
313 | jne .core_32.hardware_cursor |
||
314 | ;-------------------------------------- |
||
315 | .core_32.software_cursor: |
||
1894 | serge | 316 | align 4 |
317 | .outer32: |
||
318 | |||
319 | align 4 |
||
320 | .inner32: |
||
4444 | clevermous | 321 | cmp [ebp], bl |
2449 | mario79 | 322 | jne .skip |
2430 | mario79 | 323 | ;-------------------------------------- |
4444 | clevermous | 324 | mov eax, [esi] |
1894 | serge | 325 | |
4444 | clevermous | 326 | mov ecx, [esp+.position] |
2430 | mario79 | 327 | |
328 | ; check mouse area for putpixel |
||
329 | call [_display.check_mouse] |
||
2448 | mario79 | 330 | ;-------------------------------------- |
2430 | mario79 | 331 | ; store to real LFB |
4444 | clevermous | 332 | mov [LFB_BASE+edi], eax |
2430 | mario79 | 333 | ;-------------------------------------- |
334 | align 4 |
||
2449 | mario79 | 335 | .skip: |
4444 | clevermous | 336 | add esi, 4 |
337 | add edi, 4 |
||
338 | inc ebp |
||
339 | add [esp+.position], 1 shl 16 |
||
2288 | clevermous | 340 | dec edx |
341 | jnz .inner32 |
||
1894 | serge | 342 | |
2288 | clevermous | 343 | add esi, [esp+BLITTER.stride] |
5351 | serge | 344 | add edi, [_display.lfb_pitch] |
2288 | clevermous | 345 | add ebp, [_display.width] |
1894 | serge | 346 | |
2288 | clevermous | 347 | mov edx, [esp+BLITTER.w] |
4444 | clevermous | 348 | mov eax, edx |
349 | inc [esp+.position] |
||
350 | sub ebp, edx |
||
351 | shl eax, 2 |
||
352 | sub esi, eax |
||
353 | sub edi, eax |
||
354 | shl eax, 16-2 |
||
355 | sub [esp+.position], eax |
||
2288 | clevermous | 356 | dec [esp+BLITTER.h] |
357 | jnz .outer32 |
||
4444 | clevermous | 358 | jmp .done |
359 | .core_32.hardware_cursor: |
||
360 | align 4 |
||
361 | .hw.outer32: |
||
362 | xor ecx, ecx |
||
1894 | serge | 363 | |
4444 | clevermous | 364 | align 4 |
365 | .hw.inner32: |
||
366 | cmp [ebp+ecx], bl |
||
367 | jne .hw.skip |
||
368 | mov eax, [esi+ecx*4] |
||
369 | mov [LFB_BASE+edi+ecx*4], eax |
||
370 | |||
371 | align 4 |
||
372 | .hw.skip: |
||
373 | inc ecx |
||
374 | dec edx |
||
375 | jnz .hw.inner32 |
||
376 | |||
377 | add esi, [esp+BLITTER.stride] |
||
5351 | serge | 378 | add edi, [_display.lfb_pitch] |
4444 | clevermous | 379 | add ebp, [_display.width] |
380 | |||
381 | mov edx, [esp+BLITTER.w] |
||
382 | dec [esp+BLITTER.h] |
||
383 | jnz .hw.outer32 |
||
384 | |||
1894 | serge | 385 | .done: |
2453 | mario79 | 386 | ; call [draw_pointer] |
2988 | Serge | 387 | ; call __sys_draw_pointer |
1894 | serge | 388 | .L57: |
4444 | clevermous | 389 | add esp, .local_vars_size |
2288 | clevermous | 390 | pop ebx |
391 | pop esi |
||
392 | pop edi |
||
393 | pop ebp |
||
1894 | serge | 394 | ret |
395 | |||
396 | .core_24: |
||
5161 | hidnplayr | 397 | cmp [_display.bits_per_pixel], 24 |
398 | jne .core_16 |
||
399 | |||
2288 | clevermous | 400 | lea ebx, [ebx+ebx*2] |
401 | lea edi, [LFB_BASE+edi+ebx] |
||
402 | mov ebx, [CURRENT_TASK] |
||
1894 | serge | 403 | |
404 | align 4 |
||
405 | .outer24: |
||
4444 | clevermous | 406 | mov [esp+.extra_var1], edi |
2288 | clevermous | 407 | xor ecx, ecx |
1894 | serge | 408 | |
409 | align 4 |
||
410 | .inner24: |
||
5161 | hidnplayr | 411 | cmp [ebp+ecx], bl ; Does the process own this pixel? |
2449 | mario79 | 412 | jne .skip_1 |
2430 | mario79 | 413 | ;-------------------------------------- |
414 | push eax |
||
2288 | clevermous | 415 | mov eax, [esi+ecx*4] |
1894 | serge | 416 | |
2288 | clevermous | 417 | lea edi, [edi+ecx*2] |
2430 | mario79 | 418 | |
2448 | mario79 | 419 | ; check for hardware cursor |
2451 | mario79 | 420 | cmp [_display.select_cursor], select_cursor |
421 | je @f |
||
2448 | mario79 | 422 | cmp [_display.select_cursor], 0 |
423 | jne .no_mouseunder_1 |
||
424 | ;-------------------------------------- |
||
425 | align 4 |
||
426 | @@: |
||
2430 | mario79 | 427 | push ecx |
428 | |||
429 | mov ecx, [esp+4] |
||
430 | ror ecx, 16 |
||
431 | sub ecx, edx |
||
432 | rol ecx, 16 |
||
433 | sub ecx, [esp+BLITTER.h + 8] |
||
434 | |||
435 | ; check mouse area for putpixel |
||
436 | call [_display.check_mouse] |
||
437 | pop ecx |
||
2448 | mario79 | 438 | ;-------------------------------------- |
439 | align 4 |
||
440 | .no_mouseunder_1: |
||
2288 | clevermous | 441 | mov [edi+ecx], ax |
442 | shr eax, 16 |
||
443 | mov [edi+ecx+2], al |
||
2430 | mario79 | 444 | |
445 | pop eax |
||
446 | ;-------------------------------------- |
||
447 | align 4 |
||
2449 | mario79 | 448 | .skip_1: |
2288 | clevermous | 449 | inc ecx |
450 | dec edx |
||
451 | jnz .inner24 |
||
1894 | serge | 452 | |
2288 | clevermous | 453 | add esi, [esp+BLITTER.stride] |
5164 | hidnplayr | 454 | mov edi, [esp+.extra_var1] |
5351 | serge | 455 | add edi, [_display.lfb_pitch] |
2288 | clevermous | 456 | add ebp, [_display.width] |
1894 | serge | 457 | |
2288 | clevermous | 458 | mov edx, [esp+BLITTER.w] |
459 | dec [esp+BLITTER.h] |
||
460 | jnz .outer24 |
||
1894 | serge | 461 | |
2288 | clevermous | 462 | jmp .done |
5161 | hidnplayr | 463 | |
464 | |||
465 | .core_16: |
||
466 | lea edi, [LFB_BASE+edi+ebx*2] |
||
467 | mov ebx, [CURRENT_TASK] |
||
468 | |||
5164 | hidnplayr | 469 | .outer16: |
5161 | hidnplayr | 470 | mov [esp+.extra_var1], edi |
471 | xor ecx, ecx |
||
472 | |||
5164 | hidnplayr | 473 | .inner16: |
5161 | hidnplayr | 474 | cmp [ebp+ecx], bl ; Does the process own this pixel? |
475 | jne .skip_2 |
||
476 | ;-------------------------------------- |
||
477 | push eax |
||
478 | mov eax, [esi+ecx*4] |
||
479 | |||
480 | ; check for hardware cursor |
||
481 | cmp [_display.select_cursor], select_cursor |
||
482 | je @f |
||
483 | cmp [_display.select_cursor], 0 |
||
484 | jne .no_mouseunder_2 |
||
485 | ;-------------------------------------- |
||
5164 | hidnplayr | 486 | @@: |
5161 | hidnplayr | 487 | push ecx |
488 | |||
489 | mov ecx, [esp+4] |
||
490 | ror ecx, 16 |
||
491 | sub ecx, edx |
||
492 | rol ecx, 16 |
||
493 | sub ecx, [esp+BLITTER.h + 8] |
||
494 | |||
495 | ; check mouse area for putpixel |
||
496 | call [_display.check_mouse] |
||
497 | pop ecx |
||
498 | ;-------------------------------------- |
||
5164 | hidnplayr | 499 | .no_mouseunder_2: |
5161 | hidnplayr | 500 | ; convert to 16 bpp and store to LFB |
501 | and eax, 00000000111110001111110011111000b |
||
502 | shr ah, 2 |
||
503 | shr ax, 3 |
||
504 | ror eax, 8 |
||
505 | add al, ah |
||
506 | rol eax, 8 |
||
507 | mov [edi+ecx*2], ax |
||
508 | pop eax |
||
509 | ;-------------------------------------- |
||
5164 | hidnplayr | 510 | .skip_2: |
5161 | hidnplayr | 511 | inc ecx |
512 | dec edx |
||
513 | jnz .inner16 |
||
514 | |||
515 | add esi, [esp+BLITTER.stride] |
||
5164 | hidnplayr | 516 | mov edi, [esp+.extra_var1] |
5351 | serge | 517 | add edi, [_display.lfb_pitch] |
5161 | hidnplayr | 518 | add ebp, [_display.width] |
519 | |||
520 | mov edx, [esp+BLITTER.w] |
||
521 | dec [esp+BLITTER.h] |
||
522 | jnz .outer16 |
||
523 | |||
524 | jmp .done=>>=>> |
||
525 |