Rev 2453 | Rev 2480 | 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 |
17 | dc BLITTER_BLOCK |
||
18 | sc BLITTER_BLOCK |
||
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 | |||
31 | align 4 |
||
32 | |||
33 | __L1OutCode: |
||
2288 | clevermous | 34 | push ebx |
35 | mov ebx, 8 |
||
36 | cmp edx, [eax] |
||
37 | jl .L2 |
||
38 | xor ebx, ebx |
||
39 | cmp edx, [eax+8] |
||
40 | setg bl |
||
41 | sal ebx, 2 |
||
1894 | serge | 42 | .L2: |
2288 | clevermous | 43 | cmp ecx, [eax+4] |
44 | jge .L3 |
||
45 | or ebx, 1 |
||
46 | jmp .L4 |
||
1894 | serge | 47 | |
48 | .L3: |
||
2288 | clevermous | 49 | cmp ecx, [eax+12] |
50 | jle .L4 |
||
51 | or ebx, 2 |
||
1894 | serge | 52 | .L4: |
2288 | clevermous | 53 | mov eax, ebx |
54 | pop ebx |
||
1894 | serge | 55 | ret |
56 | |||
57 | align 4 |
||
58 | block_clip: |
||
2288 | clevermous | 59 | push ebp |
60 | push edi |
||
61 | push esi |
||
62 | push ebx |
||
63 | sub esp, 4 |
||
1894 | serge | 64 | |
2288 | clevermous | 65 | mov ebx, eax |
66 | mov [esp], edx |
||
67 | mov ebp, ecx |
||
68 | mov ecx, [ecx] |
||
69 | mov edx, [edx] |
||
70 | call __L1OutCode |
||
1894 | serge | 71 | |
2288 | clevermous | 72 | mov esi, eax |
73 | mov edx, [esp+28] |
||
74 | mov ecx, [edx] |
||
1894 | serge | 75 | .L21: |
2288 | clevermous | 76 | mov eax, [esp+24] |
77 | mov edx, [eax] |
||
78 | mov eax, ebx |
||
79 | call __L1OutCode |
||
1894 | serge | 80 | |
2288 | clevermous | 81 | mov edi, eax |
1894 | serge | 82 | .L20: |
2288 | clevermous | 83 | mov eax, edi |
84 | and eax, esi |
||
85 | jne .L9 |
||
86 | cmp esi, edi |
||
87 | je .L9 |
||
88 | test esi, esi |
||
89 | jne .L10 |
||
90 | test edi, 1 |
||
91 | je .L11 |
||
92 | mov eax, [ebx+4] |
||
93 | jmp .L25 |
||
1894 | serge | 94 | .L11: |
2288 | clevermous | 95 | test edi, 2 |
96 | je .L13 |
||
97 | mov eax, [ebx+12] |
||
1894 | serge | 98 | .L25: |
2288 | clevermous | 99 | mov edx, [esp+28] |
100 | jmp .L22 |
||
1894 | serge | 101 | .L13: |
2288 | clevermous | 102 | test edi, 4 |
103 | je .L14 |
||
104 | mov eax, [ebx+8] |
||
105 | jmp .L26 |
||
1894 | serge | 106 | .L14: |
2288 | clevermous | 107 | and edi, 8 |
108 | je .L12 |
||
109 | mov eax, [ebx] |
||
1894 | serge | 110 | .L26: |
2288 | clevermous | 111 | mov edx, [esp+24] |
1894 | serge | 112 | .L22: |
2288 | clevermous | 113 | mov [edx], eax |
1894 | serge | 114 | .L12: |
2288 | clevermous | 115 | mov eax, [esp+28] |
116 | mov ecx, [eax] |
||
117 | jmp .L21 |
||
1894 | serge | 118 | .L10: |
2288 | clevermous | 119 | test esi, 1 |
120 | je .L16 |
||
121 | mov eax, [ebx+4] |
||
122 | jmp .L23 |
||
1894 | serge | 123 | .L16: |
2288 | clevermous | 124 | test esi, 2 |
125 | je .L18 |
||
126 | mov eax, [ebx+12] |
||
1894 | serge | 127 | .L23: |
2288 | clevermous | 128 | mov [ebp+0], eax |
129 | jmp .L17 |
||
1894 | serge | 130 | .L18: |
2288 | clevermous | 131 | test esi, 4 |
132 | je .L19 |
||
133 | mov eax, [ebx+8] |
||
134 | jmp .L24 |
||
1894 | serge | 135 | .L19: |
2288 | clevermous | 136 | and esi, 8 |
137 | je .L17 |
||
138 | mov eax, [ebx] |
||
1894 | serge | 139 | .L24: |
2288 | clevermous | 140 | mov edx, [esp] |
141 | mov [edx], eax |
||
1894 | serge | 142 | .L17: |
2288 | clevermous | 143 | mov ecx, [ebp+0] |
144 | mov eax, [esp] |
||
145 | mov edx, [eax] |
||
146 | mov eax, ebx |
||
147 | call __L1OutCode |
||
148 | mov esi, eax |
||
149 | jmp .L20 |
||
1894 | serge | 150 | .L9: |
2288 | clevermous | 151 | add esp, 4 |
152 | pop ebx |
||
153 | pop esi |
||
154 | pop edi |
||
155 | pop ebp |
||
1894 | serge | 156 | ret |
157 | |||
158 | align 4 |
||
159 | blit_clip: |
||
160 | |||
161 | .sx0 equ 36 |
||
162 | .sy0 equ 32 |
||
163 | .sx1 equ 28 |
||
164 | .sy1 equ 24 |
||
165 | |||
166 | .dx0 equ 20 |
||
167 | .dy0 equ 16 |
||
168 | .dx1 equ 12 |
||
169 | .dy1 equ 8 |
||
170 | |||
171 | |||
2288 | clevermous | 172 | push edi |
173 | push esi |
||
174 | push ebx |
||
175 | sub esp, 40 |
||
1894 | serge | 176 | |
2288 | clevermous | 177 | mov ebx, ecx |
178 | mov edx, [ecx+BLITTER.src_x] |
||
179 | mov [esp+.sx0], edx |
||
180 | mov eax, [ecx+BLITTER.src_y] |
||
181 | mov [esp+.sy0], eax |
||
182 | add edx, [ecx+BLITTER.w] |
||
183 | dec edx |
||
184 | mov [esp+.sx1], edx |
||
185 | add eax, [ecx+BLITTER.h] |
||
186 | dec eax |
||
187 | mov [esp+.sy1], eax |
||
1894 | serge | 188 | |
2288 | clevermous | 189 | lea ecx, [esp+.sy0] |
190 | lea edx, [esp+.sx0] |
||
191 | lea eax, [ebx+BLITTER.sc] |
||
192 | lea esi, [esp+.sy1] |
||
1894 | serge | 193 | |
2288 | clevermous | 194 | mov [esp+4], esi |
195 | lea esi, [esp+.sx1] |
||
196 | mov [esp], esi |
||
197 | call block_clip |
||
1894 | serge | 198 | |
2288 | clevermous | 199 | mov esi, 1 |
200 | test eax, eax |
||
201 | jne .L28 |
||
1894 | serge | 202 | |
2288 | clevermous | 203 | mov edi, [esp+.sx0] |
204 | mov edx, [ebx+BLITTER.dst_x] |
||
205 | add edx, edi |
||
206 | sub edx, [ebx+BLITTER.src_x] |
||
207 | mov [esp+.dx0], edx |
||
1894 | serge | 208 | |
2288 | clevermous | 209 | mov ecx, [esp+.sy0] |
210 | mov eax, [ebx+BLITTER.dst_y] |
||
211 | add eax, ecx |
||
212 | sub eax, [ebx+BLITTER.src_y] |
||
213 | mov [esp+.dy0], eax |
||
214 | sub edx, edi |
||
215 | add edx, [esp+.sx1] |
||
216 | mov [esp+.dx1], edx |
||
1894 | serge | 217 | |
2288 | clevermous | 218 | sub eax, ecx |
219 | add eax, [esp+.sy1] |
||
220 | mov [esp+.dy1], eax |
||
1894 | serge | 221 | |
2288 | clevermous | 222 | lea ecx, [esp+.dy0] |
223 | lea edx, [esp+.dx0] |
||
224 | lea eax, [esp+.dy1] |
||
225 | mov [esp+4], eax |
||
226 | lea eax, [esp+.dx1] |
||
227 | mov [esp], eax |
||
228 | mov eax, ebx |
||
229 | call block_clip |
||
230 | test eax, eax |
||
231 | jne .L28 |
||
1894 | serge | 232 | |
2288 | clevermous | 233 | mov edx, [esp+.dx0] |
234 | mov eax, [esp+.dx1] |
||
235 | inc eax |
||
236 | sub eax, edx |
||
237 | mov [ebx+BLITTER.w], eax |
||
1894 | serge | 238 | |
2288 | clevermous | 239 | mov eax, [esp+.dy0] |
240 | mov ecx, [esp+.dy1] |
||
241 | inc ecx |
||
242 | sub ecx, eax |
||
243 | mov [ebx+BLITTER.h], ecx |
||
1894 | serge | 244 | |
2288 | clevermous | 245 | mov ecx, [ebx+BLITTER.src_x] |
246 | add ecx, edx |
||
247 | sub ecx, [ebx+BLITTER.dst_x] |
||
248 | mov [ebx+BLITTER.src_x], ecx |
||
1894 | serge | 249 | |
2288 | clevermous | 250 | mov ecx, [ebx+BLITTER.src_y] |
251 | add ecx, eax |
||
252 | sub ecx, [ebx+BLITTER.dst_y] |
||
253 | mov [ebx+BLITTER.src_y], ecx |
||
254 | mov [ebx+BLITTER.dst_x], edx |
||
255 | mov [ebx+BLITTER.dst_y], eax |
||
256 | xor esi, esi |
||
1894 | serge | 257 | .L28: |
2288 | clevermous | 258 | mov eax, esi |
259 | add esp, 40 |
||
260 | pop ebx |
||
261 | pop esi |
||
262 | pop edi |
||
1894 | serge | 263 | |
264 | |||
265 | purge .sx0 |
||
266 | purge .sy0 |
||
267 | purge .sx1 |
||
268 | purge .sy1 |
||
269 | |||
270 | purge .dx0 |
||
271 | purge .dy0 |
||
272 | purge .dx1 |
||
273 | purge .dy1 |
||
274 | |||
275 | ret |
||
276 | |||
277 | |||
278 | |||
279 | align 4 |
||
280 | |||
281 | blit_32: |
||
2288 | clevermous | 282 | push ebp |
283 | push edi |
||
284 | push esi |
||
285 | push ebx |
||
286 | sub esp, 72 |
||
1894 | serge | 287 | |
2288 | clevermous | 288 | mov eax, [TASK_BASE] |
289 | mov ebx, [eax-twdw + WDATA.box.width] |
||
290 | mov edx, [eax-twdw + WDATA.box.height] |
||
1894 | serge | 291 | |
2288 | clevermous | 292 | xor eax, eax |
1894 | serge | 293 | |
2288 | clevermous | 294 | mov [esp+BLITTER.dc.xmin], eax |
295 | mov [esp+BLITTER.dc.ymin], eax |
||
296 | mov [esp+BLITTER.dc.xmax], ebx |
||
297 | mov [esp+BLITTER.dc.ymax], edx |
||
1894 | serge | 298 | |
2288 | clevermous | 299 | mov [esp+BLITTER.sc.xmin], eax |
300 | mov [esp+BLITTER.sc.ymin], eax |
||
301 | mov eax, [ecx+24] |
||
302 | dec eax |
||
303 | mov [esp+BLITTER.sc.xmax], eax |
||
304 | mov eax, [ecx+28] |
||
305 | dec eax |
||
306 | mov [esp+BLITTER.sc.ymax], eax |
||
1894 | serge | 307 | |
2288 | clevermous | 308 | mov eax, [ecx] |
309 | mov [esp+BLITTER.dst_x], eax |
||
310 | mov eax, [ecx+4] |
||
311 | mov [esp+BLITTER.dst_y], eax |
||
1894 | serge | 312 | |
2288 | clevermous | 313 | mov eax, [ecx+16] |
314 | mov [esp+BLITTER.src_x], eax |
||
315 | mov eax, [ecx+20] |
||
316 | mov [esp+BLITTER.src_y], eax |
||
317 | mov eax, [ecx+8] |
||
318 | mov [esp+BLITTER.w], eax |
||
319 | mov eax, [ecx+12] |
||
320 | mov [esp+BLITTER.h], eax |
||
1894 | serge | 321 | |
322 | |||
2288 | clevermous | 323 | mov eax, [ecx+32] |
324 | mov [esp+56], eax |
||
325 | mov eax, [ecx+36] |
||
326 | mov [esp+60], eax |
||
1894 | serge | 327 | |
2288 | clevermous | 328 | mov ecx, esp |
329 | call blit_clip |
||
330 | test eax, eax |
||
331 | jne .L57 |
||
1894 | serge | 332 | |
2288 | clevermous | 333 | mov eax, [TASK_BASE] |
1894 | serge | 334 | |
2288 | clevermous | 335 | mov ebx, [esp+BLITTER.dst_x] |
336 | mov ebp, [esp+BLITTER.dst_y] |
||
337 | add ebx, [eax-twdw + WDATA.box.left] |
||
338 | add ebp, [eax-twdw + WDATA.box.top] |
||
2430 | mario79 | 339 | |
340 | mov ecx, ebx |
||
341 | add ecx, [esp+BLITTER.w] |
||
342 | shl ecx, 16 |
||
343 | mov cx, bp |
||
344 | add ecx, [esp+BLITTER.h] |
||
345 | |||
2288 | clevermous | 346 | mov edi, ebp |
1894 | serge | 347 | |
2288 | clevermous | 348 | imul edi, [_display.pitch] |
2446 | mario79 | 349 | ; imul ebp, [_display.width] |
350 | mov ebp, [d_width_calc_area + ebp*4] |
||
351 | |||
2288 | clevermous | 352 | add ebp, ebx |
353 | add ebp, [_WinMapAddress] |
||
1894 | serge | 354 | |
2288 | clevermous | 355 | mov eax, [esp+BLITTER.src_y] |
356 | imul eax, [esp+BLITTER.stride] |
||
357 | mov esi, [esp+BLITTER.src_x] |
||
358 | lea esi, [eax+esi*4] |
||
359 | add esi, [esp+BLITTER.bitmap] |
||
1894 | serge | 360 | |
2430 | mario79 | 361 | mov eax, ecx |
2288 | clevermous | 362 | mov ecx, [esp+BLITTER.h] |
363 | mov edx, [esp+BLITTER.w] |
||
1894 | serge | 364 | |
2288 | clevermous | 365 | test ecx, ecx ;FIXME check clipping |
366 | jz .L57 |
||
1894 | serge | 367 | |
2288 | clevermous | 368 | test edx, edx |
369 | jz .L57 |
||
1894 | serge | 370 | |
2288 | clevermous | 371 | cmp [_display.bpp], 32 |
372 | jne .core_24 |
||
1894 | serge | 373 | |
2288 | clevermous | 374 | lea edi, [edi+ebx*4] |
1894 | serge | 375 | |
2288 | clevermous | 376 | mov ebx, [CURRENT_TASK] |
1894 | serge | 377 | align 4 |
378 | .outer32: |
||
2288 | clevermous | 379 | xor ecx, ecx |
1894 | serge | 380 | |
381 | align 4 |
||
382 | .inner32: |
||
2288 | clevermous | 383 | cmp [ebp+ecx], bl |
2449 | mario79 | 384 | jne .skip |
2430 | mario79 | 385 | ;-------------------------------------- |
386 | push eax |
||
387 | mov eax, [esi+ecx*4] |
||
1894 | serge | 388 | |
2448 | mario79 | 389 | ; check for hardware cursor |
2451 | mario79 | 390 | cmp [_display.select_cursor], select_cursor |
391 | je @f |
||
2448 | mario79 | 392 | cmp [_display.select_cursor], 0 |
393 | jne .no_mouseunder |
||
394 | ;-------------------------------------- |
||
395 | align 4 |
||
396 | @@: |
||
2430 | mario79 | 397 | push ecx |
398 | |||
399 | mov ecx, [esp+4] |
||
400 | ror ecx, 16 |
||
401 | sub ecx, edx |
||
402 | rol ecx, 16 |
||
403 | sub ecx, [esp+BLITTER.h + 8] |
||
404 | |||
405 | ; check mouse area for putpixel |
||
406 | call [_display.check_mouse] |
||
407 | pop ecx |
||
2448 | mario79 | 408 | ;-------------------------------------- |
409 | align 4 |
||
410 | .no_mouseunder: |
||
2430 | mario79 | 411 | ; store to real LFB |
2288 | clevermous | 412 | mov [LFB_BASE+edi+ecx*4], eax |
2430 | mario79 | 413 | pop eax |
414 | ;-------------------------------------- |
||
415 | align 4 |
||
2449 | mario79 | 416 | .skip: |
2288 | clevermous | 417 | inc ecx |
418 | dec edx |
||
419 | jnz .inner32 |
||
1894 | serge | 420 | |
2288 | clevermous | 421 | add esi, [esp+BLITTER.stride] |
422 | add edi, [_display.pitch] |
||
423 | add ebp, [_display.width] |
||
1894 | serge | 424 | |
2288 | clevermous | 425 | mov edx, [esp+BLITTER.w] |
426 | dec [esp+BLITTER.h] |
||
427 | jnz .outer32 |
||
1894 | serge | 428 | |
429 | .done: |
||
2453 | mario79 | 430 | ; call [draw_pointer] |
431 | call __sys_draw_pointer |
||
1894 | serge | 432 | .L57: |
2288 | clevermous | 433 | add esp, 72 |
434 | pop ebx |
||
435 | pop esi |
||
436 | pop edi |
||
437 | pop ebp |
||
1894 | serge | 438 | ret |
439 | |||
440 | .core_24: |
||
2288 | clevermous | 441 | lea ebx, [ebx+ebx*2] |
442 | lea edi, [LFB_BASE+edi+ebx] |
||
443 | mov ebx, [CURRENT_TASK] |
||
1894 | serge | 444 | |
445 | align 4 |
||
446 | .outer24: |
||
2288 | clevermous | 447 | mov [esp+64], edi |
448 | xor ecx, ecx |
||
1894 | serge | 449 | |
450 | align 4 |
||
451 | .inner24: |
||
2288 | clevermous | 452 | cmp [ebp+ecx], bl |
2449 | mario79 | 453 | jne .skip_1 |
2430 | mario79 | 454 | ;-------------------------------------- |
455 | push eax |
||
2288 | clevermous | 456 | mov eax, [esi+ecx*4] |
1894 | serge | 457 | |
2288 | clevermous | 458 | lea edi, [edi+ecx*2] |
2430 | mario79 | 459 | |
2448 | mario79 | 460 | ; check for hardware cursor |
2451 | mario79 | 461 | cmp [_display.select_cursor], select_cursor |
462 | je @f |
||
2448 | mario79 | 463 | cmp [_display.select_cursor], 0 |
464 | jne .no_mouseunder_1 |
||
465 | ;-------------------------------------- |
||
466 | align 4 |
||
467 | @@: |
||
2430 | mario79 | 468 | push ecx |
469 | |||
470 | mov ecx, [esp+4] |
||
471 | ror ecx, 16 |
||
472 | sub ecx, edx |
||
473 | rol ecx, 16 |
||
474 | sub ecx, [esp+BLITTER.h + 8] |
||
475 | |||
476 | ; check mouse area for putpixel |
||
477 | call [_display.check_mouse] |
||
478 | pop ecx |
||
2448 | mario79 | 479 | ;-------------------------------------- |
480 | align 4 |
||
481 | .no_mouseunder_1: |
||
2288 | clevermous | 482 | mov [edi+ecx], ax |
483 | shr eax, 16 |
||
484 | mov [edi+ecx+2], al |
||
2430 | mario79 | 485 | |
486 | pop eax |
||
487 | ;-------------------------------------- |
||
488 | align 4 |
||
2449 | mario79 | 489 | .skip_1: |
2288 | clevermous | 490 | mov edi, [esp+64] |
491 | inc ecx |
||
492 | dec edx |
||
493 | jnz .inner24 |
||
1894 | serge | 494 | |
2288 | clevermous | 495 | add esi, [esp+BLITTER.stride] |
496 | add edi, [_display.pitch] |
||
497 | add ebp, [_display.width] |
||
1894 | serge | 498 | |
2288 | clevermous | 499 | mov edx, [esp+BLITTER.w] |
500 | dec [esp+BLITTER.h] |
||
501 | jnz .outer24 |
||
1894 | serge | 502 | |
2288 | clevermous | 503 | jmp .done |