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