Rev 2465 | Rev 2987 | 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: |
||
205 | push ebp |
||
206 | push edi |
||
207 | push esi |
||
208 | push ebx |
||
209 | sub esp, 72 |
||
210 | |||
211 | mov eax, [TASK_BASE] |
||
212 | mov ebx, [eax-twdw + WDATA.box.width] |
||
213 | mov edx, [eax-twdw + WDATA.box.height] |
||
2467 | Serge | 214 | inc ebx |
215 | inc edx |
||
2434 | Serge | 216 | |
217 | xor eax, eax |
||
218 | |||
2467 | Serge | 219 | mov [esp+BLITTER.dc.left], eax |
220 | mov [esp+BLITTER.dc.top], eax |
||
221 | mov [esp+BLITTER.dc.right], ebx |
||
222 | mov [esp+BLITTER.dc.bottom], edx |
||
2434 | Serge | 223 | |
2467 | Serge | 224 | mov [esp+BLITTER.sc.left], eax |
225 | mov [esp+BLITTER.sc.top], eax |
||
2434 | Serge | 226 | mov eax, [ecx+24] |
2467 | Serge | 227 | |
228 | mov [esp+BLITTER.sc.right], eax |
||
2434 | Serge | 229 | mov eax, [ecx+28] |
230 | |||
2467 | Serge | 231 | mov [esp+BLITTER.sc.bottom], eax |
232 | |||
2434 | Serge | 233 | mov eax, [ecx] |
234 | mov [esp+BLITTER.dst_x], eax |
||
235 | mov eax, [ecx+4] |
||
236 | mov [esp+BLITTER.dst_y], eax |
||
237 | |||
238 | mov eax, [ecx+16] |
||
239 | mov [esp+BLITTER.src_x], eax |
||
240 | mov eax, [ecx+20] |
||
241 | mov [esp+BLITTER.src_y], eax |
||
242 | mov eax, [ecx+8] |
||
243 | mov [esp+BLITTER.w], eax |
||
244 | mov eax, [ecx+12] |
||
245 | mov [esp+BLITTER.h], eax |
||
246 | |||
247 | |||
248 | mov eax, [ecx+32] |
||
249 | mov [esp+56], eax |
||
250 | mov eax, [ecx+36] |
||
251 | mov [esp+60], eax |
||
252 | |||
253 | mov ecx, esp |
||
254 | call blit_clip |
||
255 | test eax, eax |
||
256 | jne .L57 |
||
257 | |||
258 | mov eax, [TASK_BASE] |
||
259 | |||
260 | mov ebx, [esp+BLITTER.dst_x] |
||
261 | mov ebp, [esp+BLITTER.dst_y] |
||
262 | add ebx, [eax-twdw + WDATA.box.left] |
||
263 | add ebp, [eax-twdw + WDATA.box.top] |
||
264 | |||
265 | mov ecx, ebx |
||
266 | add ecx, [esp+BLITTER.w] |
||
267 | shl ecx, 16 |
||
268 | mov cx, bp |
||
269 | add ecx, [esp+BLITTER.h] |
||
270 | |||
271 | mov edi, ebp |
||
272 | |||
273 | imul edi, [_display.pitch] |
||
2465 | Serge | 274 | ; imul ebp, [_display.width] |
275 | mov ebp, [d_width_calc_area + ebp*4] |
||
276 | |||
2434 | Serge | 277 | add ebp, ebx |
278 | add ebp, [_WinMapAddress] |
||
279 | |||
280 | mov eax, [esp+BLITTER.src_y] |
||
281 | imul eax, [esp+BLITTER.stride] |
||
282 | mov esi, [esp+BLITTER.src_x] |
||
283 | lea esi, [eax+esi*4] |
||
284 | add esi, [esp+BLITTER.bitmap] |
||
285 | |||
286 | mov eax, ecx |
||
287 | mov ecx, [esp+BLITTER.h] |
||
288 | mov edx, [esp+BLITTER.w] |
||
289 | |||
290 | test ecx, ecx ;FIXME check clipping |
||
291 | jz .L57 |
||
292 | |||
293 | test edx, edx |
||
294 | jz .L57 |
||
295 | |||
296 | cmp [_display.bpp], 32 |
||
297 | jne .core_24 |
||
298 | |||
299 | lea edi, [edi+ebx*4] |
||
300 | |||
301 | mov ebx, [CURRENT_TASK] |
||
302 | align 4 |
||
303 | .outer32: |
||
304 | xor ecx, ecx |
||
305 | |||
306 | align 4 |
||
307 | .inner32: |
||
308 | cmp [ebp+ecx], bl |
||
2465 | Serge | 309 | jne .skip |
2434 | Serge | 310 | ;-------------------------------------- |
311 | push eax |
||
312 | mov eax, [esi+ecx*4] |
||
313 | |||
2465 | Serge | 314 | ; check for hardware cursor |
315 | cmp [_display.select_cursor], select_cursor |
||
316 | je @f |
||
317 | cmp [_display.select_cursor], 0 |
||
318 | jne .no_mouseunder |
||
319 | ;-------------------------------------- |
||
320 | align 4 |
||
321 | @@: |
||
2434 | Serge | 322 | push ecx |
323 | |||
324 | mov ecx, [esp+4] |
||
325 | ror ecx, 16 |
||
326 | sub ecx, edx |
||
327 | rol ecx, 16 |
||
328 | sub ecx, [esp+BLITTER.h + 8] |
||
329 | |||
330 | ; check mouse area for putpixel |
||
331 | call [_display.check_mouse] |
||
332 | pop ecx |
||
2465 | Serge | 333 | ;-------------------------------------- |
334 | align 4 |
||
335 | .no_mouseunder: |
||
2434 | Serge | 336 | ; store to real LFB |
337 | mov [LFB_BASE+edi+ecx*4], eax |
||
338 | pop eax |
||
339 | ;-------------------------------------- |
||
340 | align 4 |
||
2465 | Serge | 341 | .skip: |
2434 | Serge | 342 | inc ecx |
343 | dec edx |
||
344 | jnz .inner32 |
||
345 | |||
346 | add esi, [esp+BLITTER.stride] |
||
347 | add edi, [_display.pitch] |
||
348 | add ebp, [_display.width] |
||
349 | |||
350 | mov edx, [esp+BLITTER.w] |
||
351 | dec [esp+BLITTER.h] |
||
352 | jnz .outer32 |
||
353 | |||
354 | .done: |
||
2465 | Serge | 355 | ; call [draw_pointer] |
2467 | Serge | 356 | ; call __sys_draw_pointer |
2434 | Serge | 357 | .L57: |
358 | add esp, 72 |
||
359 | pop ebx |
||
360 | pop esi |
||
361 | pop edi |
||
362 | pop ebp |
||
363 | ret |
||
364 | |||
365 | .core_24: |
||
366 | lea ebx, [ebx+ebx*2] |
||
367 | lea edi, [LFB_BASE+edi+ebx] |
||
368 | mov ebx, [CURRENT_TASK] |
||
369 | |||
370 | align 4 |
||
371 | .outer24: |
||
372 | mov [esp+64], edi |
||
373 | xor ecx, ecx |
||
374 | |||
375 | align 4 |
||
376 | .inner24: |
||
377 | cmp [ebp+ecx], bl |
||
2465 | Serge | 378 | jne .skip_1 |
2434 | Serge | 379 | ;-------------------------------------- |
380 | push eax |
||
381 | mov eax, [esi+ecx*4] |
||
382 | |||
383 | lea edi, [edi+ecx*2] |
||
384 | |||
2465 | Serge | 385 | ; check for hardware cursor |
386 | cmp [_display.select_cursor], select_cursor |
||
387 | je @f |
||
388 | cmp [_display.select_cursor], 0 |
||
389 | jne .no_mouseunder_1 |
||
390 | ;-------------------------------------- |
||
391 | align 4 |
||
392 | @@: |
||
2434 | Serge | 393 | push ecx |
394 | |||
395 | mov ecx, [esp+4] |
||
396 | ror ecx, 16 |
||
397 | sub ecx, edx |
||
398 | rol ecx, 16 |
||
399 | sub ecx, [esp+BLITTER.h + 8] |
||
400 | |||
401 | ; check mouse area for putpixel |
||
402 | call [_display.check_mouse] |
||
403 | pop ecx |
||
2465 | Serge | 404 | ;-------------------------------------- |
405 | align 4 |
||
406 | .no_mouseunder_1: |
||
2434 | Serge | 407 | mov [edi+ecx], ax |
408 | shr eax, 16 |
||
409 | mov [edi+ecx+2], al |
||
410 | |||
411 | pop eax |
||
412 | ;-------------------------------------- |
||
413 | align 4 |
||
2465 | Serge | 414 | .skip_1: |
2434 | Serge | 415 | mov edi, [esp+64] |
416 | inc ecx |
||
417 | dec edx |
||
418 | jnz .inner24 |
||
419 | |||
420 | add esi, [esp+BLITTER.stride] |
||
421 | add edi, [_display.pitch] |
||
422 | add ebp, [_display.width] |
||
423 | |||
424 | mov edx, [esp+BLITTER.w] |
||
425 | dec [esp+BLITTER.h] |
||
426 | jnz .outer24 |
||
427 | |||
428 | jmp .done=>>=>> |