Rev 983 | Rev 1420 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
431 | serge | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
983 | diamond | 3 | ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
431 | serge | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;; VESA20.INC ;; |
||
7 | ;; ;; |
||
8 | ;; Vesa 2.0 functions for MenuetOS ;; |
||
9 | ;; ;; |
||
10 | ;; Copyright 2002 Ville Turjanmaa ;; |
||
11 | ;; Alexey, kgaz@crosswindws.net ;; |
||
12 | ;; - Voodoo compatible graphics ;; |
||
13 | ;; Juan M. Caravaca ;; |
||
14 | ;; - Graphics optimimizations eg. drawline ;; |
||
15 | ;; ;; |
||
16 | ;; See file COPYING for details ;; |
||
17 | ;; ;; |
||
18 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1 | ha | 19 | |
593 | mikedld | 20 | $Revision: 1300 $ |
21 | |||
22 | |||
1 | ha | 23 | ; If you're planning to write your own video driver I suggest |
24 | ; you replace the VESA12.INC file and see those instructions. |
||
25 | |||
753 | serge | 26 | ;Screen_Max_X equ 0xfe00 |
27 | ;Screen_Max_Y equ 0xfe04 |
||
381 | serge | 28 | ;BytesPerScanLine equ 0xfe08 |
29 | ;LFBAddress equ 0xfe80 |
||
30 | ;ScreenBPP equ 0xfbf1 |
||
1 | ha | 31 | |
32 | |||
33 | |||
34 | ;************************************************* |
||
35 | ; getpixel |
||
36 | ; |
||
37 | ; in: |
||
38 | ; eax = x coordinate |
||
39 | ; ebx = y coordinate |
||
40 | ; |
||
41 | ; ret: |
||
42 | ; ecx = 00 RR GG BB |
||
43 | |||
44 | getpixel: |
||
469 | serge | 45 | push eax ebx edx edi |
46 | call dword [GETPIXEL] |
||
47 | pop edi edx ebx eax |
||
48 | ret |
||
1 | ha | 49 | |
50 | Vesa20_getpixel24: |
||
469 | serge | 51 | ; eax = x |
52 | ; ebx = y |
||
53 | imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier |
||
54 | lea edi, [eax+eax*2] ; edi = x*3 |
||
55 | add edi, ebx ; edi = x*3+(y*y multiplier) |
||
1300 | serge | 56 | mov ecx, [LFB_BASE+edi] |
469 | serge | 57 | and ecx, 0xffffff |
58 | ret |
||
1 | ha | 59 | |
60 | Vesa20_getpixel32: |
||
469 | serge | 61 | imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier |
62 | lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier) |
||
1300 | serge | 63 | mov ecx, [LFB_BASE+edi] |
469 | serge | 64 | and ecx, 0xffffff |
65 | ret |
||
1 | ha | 66 | |
67 | ;************************************************* |
||
68 | |||
69 | virtual at esp |
||
70 | putimg: |
||
71 | .real_sx dd ? |
||
72 | .real_sy dd ? |
||
73 | .image_sx dd ? |
||
74 | .image_sy dd ? |
||
75 | .image_cx dd ? |
||
76 | .image_cy dd ? |
||
77 | .pti dd ? |
||
78 | .abs_cx dd ? |
||
79 | .abs_cy dd ? |
||
80 | .line_increment dd ? |
||
81 | .winmap_newline dd ? |
||
82 | .screen_newline dd ? |
||
283 | diamond | 83 | .stack_data = 4*12 |
84 | .edi dd ? |
||
85 | .esi dd ? |
||
86 | .ebp dd ? |
||
314 | diamond | 87 | .esp dd ? |
88 | .ebx dd ? |
||
89 | .edx dd ? |
||
90 | .ecx dd ? |
||
91 | .eax dd ? |
||
92 | .ret_addr dd ? |
||
93 | .arg_0 dd ? |
||
1 | ha | 94 | end virtual |
95 | |||
283 | diamond | 96 | align 16 |
1 | ha | 97 | ; ebx = pointer |
98 | ; ecx = size [x|y] |
||
99 | ; edx = coordinates [x|y] |
||
283 | diamond | 100 | ; ebp = pointer to 'get' function |
101 | ; esi = pointer to 'init' function |
||
102 | ; edi = parameter for 'get' function |
||
469 | serge | 103 | |
1 | ha | 104 | vesa20_putimage: |
469 | serge | 105 | pushad |
1300 | serge | 106 | call [_display.disable_mouse] |
469 | serge | 107 | sub esp, putimg.stack_data |
108 | ; save pointer to image |
||
109 | mov [putimg.pti], ebx |
||
110 | ; unpack the size |
||
111 | mov eax, ecx |
||
112 | and ecx, 0xFFFF |
||
113 | shr eax, 16 |
||
114 | mov [putimg.image_sx], eax |
||
115 | mov [putimg.image_sy], ecx |
||
116 | ; unpack the coordinates |
||
117 | mov eax, edx |
||
118 | and edx, 0xFFFF |
||
119 | shr eax, 16 |
||
120 | mov [putimg.image_cx], eax |
||
121 | mov [putimg.image_cy], edx |
||
122 | ; calculate absolute (i.e. screen) coordinates |
||
123 | mov eax, [TASK_BASE] |
||
124 | mov ebx, [eax-twdw + WDATA.box.left] |
||
125 | add ebx, [putimg.image_cx] |
||
126 | mov [putimg.abs_cx], ebx |
||
127 | mov ebx, [eax-twdw + WDATA.box.top] |
||
128 | add ebx, [putimg.image_cy] |
||
129 | mov [putimg.abs_cy], ebx |
||
130 | ; real_sx = MIN(wnd_sx-image_cx, image_sx); |
||
131 | mov ebx, [eax-twdw + WDATA.box.width] ; ebx = wnd_sx |
||
133 | diamond | 132 | ; \begin{diamond}[20.08.2006] |
133 | ; note that WDATA.box.width is one pixel less than real window x-size |
||
469 | serge | 134 | inc ebx |
133 | diamond | 135 | ; \end{diamond}[20.08.2006] |
469 | serge | 136 | sub ebx, [putimg.image_cx] |
137 | ja @f |
||
138 | add esp, putimg.stack_data |
||
139 | popad |
||
140 | ret |
||
141 | @@: |
||
142 | cmp ebx, [putimg.image_sx] |
||
143 | jbe .end_x |
||
144 | mov ebx, [putimg.image_sx] |
||
145 | .end_x: |
||
146 | mov [putimg.real_sx], ebx |
||
147 | ; init real_sy |
||
148 | mov ebx, [eax-twdw + WDATA.box.height] ; ebx = wnd_sy |
||
133 | diamond | 149 | ; \begin{diamond}[20.08.2006] |
469 | serge | 150 | inc ebx |
133 | diamond | 151 | ; \end{diamond}[20.08.2006] |
469 | serge | 152 | sub ebx, [putimg.image_cy] |
153 | ja @f |
||
154 | add esp, putimg.stack_data |
||
155 | popad |
||
156 | ret |
||
157 | @@: |
||
158 | cmp ebx, [putimg.image_sy] |
||
159 | jbe .end_y |
||
160 | mov ebx, [putimg.image_sy] |
||
161 | .end_y: |
||
162 | mov [putimg.real_sy], ebx |
||
163 | ; line increment |
||
164 | mov eax, [putimg.image_sx] |
||
911 | diamond | 165 | mov ecx, [putimg.real_sx] |
166 | sub eax, ecx |
||
469 | serge | 167 | ;; imul eax, [putimg.source_bpp] |
168 | ; lea eax, [eax + eax * 2] |
||
169 | call esi |
||
170 | add eax, [putimg.arg_0] |
||
171 | mov [putimg.line_increment], eax |
||
172 | ; winmap new line increment |
||
753 | serge | 173 | mov eax, [Screen_Max_X] |
469 | serge | 174 | inc eax |
175 | sub eax, [putimg.real_sx] |
||
176 | mov [putimg.winmap_newline], eax |
||
177 | ; screen new line increment |
||
178 | mov eax, [BytesPerScanLine] |
||
179 | movzx ebx, byte [ScreenBPP] |
||
180 | shr ebx, 3 |
||
181 | imul ecx, ebx |
||
182 | sub eax, ecx |
||
183 | mov [putimg.screen_newline], eax |
||
184 | ; pointer to image |
||
185 | mov esi, [putimg.pti] |
||
186 | ; pointer to screen |
||
187 | mov edx, [putimg.abs_cy] |
||
188 | imul edx, [BytesPerScanLine] |
||
189 | mov eax, [putimg.abs_cx] |
||
190 | movzx ebx, byte [ScreenBPP] |
||
191 | shr ebx, 3 |
||
192 | imul eax, ebx |
||
193 | add edx, eax |
||
194 | ; pointer to pixel map |
||
195 | mov eax, [putimg.abs_cy] |
||
753 | serge | 196 | imul eax, [Screen_Max_X] |
469 | serge | 197 | add eax, [putimg.abs_cy] |
198 | add eax, [putimg.abs_cx] |
||
1300 | serge | 199 | add eax, [_WinMapAddress] |
469 | serge | 200 | xchg eax, ebp |
201 | ; get process number |
||
202 | mov ebx, [CURRENT_TASK] |
||
203 | cmp byte [ScreenBPP], 32 |
||
204 | je put_image_end_32 |
||
1 | ha | 205 | ;put_image_end_24: |
469 | serge | 206 | mov edi, [putimg.real_sy] |
207 | align 4 |
||
208 | .new_line: |
||
209 | mov ecx, [putimg.real_sx] |
||
210 | ; push ebp edx |
||
211 | align 4 |
||
212 | .new_x: |
||
213 | push [putimg.edi] |
||
214 | mov eax, [putimg.ebp+4] |
||
215 | call eax |
||
216 | cmp [ebp], bl |
||
217 | jne .skip |
||
218 | ; mov eax, [esi] ; eax = RRBBGGRR |
||
1300 | serge | 219 | mov [LFB_BASE+edx], ax |
469 | serge | 220 | shr eax, 16 |
1300 | serge | 221 | mov [LFB_BASE+edx+2], al |
469 | serge | 222 | .skip: |
223 | ; add esi, 3 ;[putimg.source_bpp] |
||
224 | add edx, 3 |
||
225 | inc ebp |
||
226 | dec ecx |
||
227 | jnz .new_x |
||
228 | ; pop edx ebp |
||
229 | add esi, [putimg.line_increment] |
||
230 | add edx, [putimg.screen_newline] ;[BytesPerScanLine] |
||
753 | serge | 231 | add ebp, [putimg.winmap_newline] ;[Screen_Max_X] |
469 | serge | 232 | ; inc ebp |
911 | diamond | 233 | cmp [putimg.ebp], putimage_get1bpp |
234 | jz .correct |
||
918 | diamond | 235 | cmp [putimg.ebp], putimage_get2bpp |
236 | jz .correct |
||
911 | diamond | 237 | cmp [putimg.ebp], putimage_get4bpp |
238 | jnz @f |
||
239 | .correct: |
||
240 | mov eax, [putimg.edi] |
||
241 | mov byte [eax], 80h |
||
242 | @@: |
||
469 | serge | 243 | dec edi |
244 | jnz .new_line |
||
245 | .finish: |
||
246 | add esp, putimg.stack_data |
||
247 | popad |
||
248 | ret |
||
1 | ha | 249 | |
250 | put_image_end_32: |
||
469 | serge | 251 | mov edi, [putimg.real_sy] |
252 | align 4 |
||
253 | .new_line: |
||
254 | mov ecx, [putimg.real_sx] |
||
255 | ; push ebp edx |
||
256 | align 4 |
||
257 | .new_x: |
||
258 | push [putimg.edi] |
||
259 | mov eax, [putimg.ebp+4] |
||
260 | call eax |
||
261 | cmp [ebp], bl |
||
262 | jne .skip |
||
263 | ; mov eax, [esi] ; ecx = RRBBGGRR |
||
1300 | serge | 264 | mov [LFB_BASE+edx], eax |
469 | serge | 265 | .skip: |
266 | ; add esi, [putimg.source_bpp] |
||
267 | add edx, 4 |
||
268 | inc ebp |
||
269 | dec ecx |
||
270 | jnz .new_x |
||
271 | ; pop edx ebp |
||
272 | add esi, [putimg.line_increment] |
||
273 | add edx, [putimg.screen_newline] ;[BytesPerScanLine] |
||
753 | serge | 274 | add ebp, [putimg.winmap_newline] ;[Screen_Max_X] |
469 | serge | 275 | ; inc ebp |
911 | diamond | 276 | cmp [putimg.ebp], putimage_get1bpp |
277 | jz .correct |
||
918 | diamond | 278 | cmp [putimg.ebp], putimage_get2bpp |
279 | jz .correct |
||
911 | diamond | 280 | cmp [putimg.ebp], putimage_get4bpp |
281 | jnz @f |
||
282 | .correct: |
||
283 | mov eax, [putimg.edi] |
||
284 | mov byte [eax], 80h |
||
285 | @@: |
||
469 | serge | 286 | dec edi |
287 | jnz .new_line |
||
288 | .finish: |
||
289 | add esp, putimg.stack_data |
||
290 | popad |
||
291 | call VGA__putimage |
||
292 | mov [EGA_counter],1 |
||
293 | ret |
||
1 | ha | 294 | |
295 | |||
296 | ;************************************************* |
||
297 | align 4 |
||
298 | __sys_putpixel: |
||
299 | |||
300 | ; eax = x coordinate |
||
301 | ; ebx = y coordinate |
||
302 | ; ecx = ?? RR GG BB ; 0x01000000 negation |
||
303 | ; edi = 0x00000001 force |
||
304 | |||
305 | ;;; mov [novesachecksum], dword 0 |
||
469 | serge | 306 | pushad |
1300 | serge | 307 | cmp [Screen_Max_X], eax |
308 | jb .exit |
||
309 | cmp [Screen_Max_Y], ebx |
||
310 | jb .exit |
||
469 | serge | 311 | test edi,1 ; force ? |
312 | jnz .forced |
||
1300 | serge | 313 | |
469 | serge | 314 | ; not forced: |
1300 | serge | 315 | |
316 | push eax |
||
317 | mov edx,[_display.width] ; screen x size |
||
318 | imul edx, ebx |
||
319 | add eax, [_WinMapAddress] |
||
320 | movzx edx, byte [eax+edx] |
||
321 | cmp edx, [CURRENT_TASK] |
||
322 | pop eax |
||
323 | jne .exit |
||
324 | |||
469 | serge | 325 | .forced: |
326 | ; check if negation |
||
327 | test ecx,0x01000000 |
||
328 | jz .noneg |
||
329 | call getpixel |
||
330 | not ecx |
||
331 | mov [esp+32-8],ecx |
||
332 | .noneg: |
||
333 | ; OK to set pixel |
||
334 | call dword [PUTPIXEL] ; call the real put_pixel function |
||
335 | .exit: |
||
336 | popad |
||
337 | ret |
||
1 | ha | 338 | |
339 | align 4 |
||
340 | Vesa20_putpixel24: |
||
469 | serge | 341 | ; eax = x |
342 | ; ebx = y |
||
343 | imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier |
||
344 | lea edi, [eax+eax*2] ; edi = x*3 |
||
345 | mov eax, [esp+32-8+4] |
||
1300 | serge | 346 | mov [LFB_BASE+ebx+edi], ax |
469 | serge | 347 | shr eax, 16 |
1300 | serge | 348 | mov [LFB_BASE+ebx+edi+2], al |
469 | serge | 349 | ret |
1 | ha | 350 | |
351 | |||
352 | align 4 |
||
353 | Vesa20_putpixel32: |
||
469 | serge | 354 | ; eax = x |
355 | ; ebx = y |
||
356 | imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier |
||
357 | lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier) |
||
358 | mov eax, [esp+32-8+4] ; eax = color |
||
1300 | serge | 359 | mov [LFB_BASE+edi], eax |
469 | serge | 360 | ret |
1 | ha | 361 | |
362 | ;************************************************* |
||
363 | |||
364 | ;align 4 |
||
365 | calculate_edi: |
||
469 | serge | 366 | mov edi, ebx |
753 | serge | 367 | imul edi, [Screen_Max_X] |
469 | serge | 368 | add edi, ebx |
369 | add edi, eax |
||
370 | ret |
||
1 | ha | 371 | |
372 | ;************************************************* |
||
373 | |||
374 | ; DRAWLINE |
||
375 | |||
376 | align 4 |
||
377 | __sys_draw_line: |
||
36 | mario79 | 378 | ; inc [mouse_pause] |
1300 | serge | 379 | call [_display.disable_mouse] |
1 | ha | 380 | |
381 | ; draw a line |
||
382 | ; eax = HIWORD = x1 |
||
383 | ; LOWORD = x2 |
||
384 | ; ebx = HIWORD = y1 |
||
385 | ; LOWORD = y2 |
||
386 | ; ecx = color |
||
387 | ; edi = force ? |
||
388 | pusha |
||
389 | |||
390 | dl_x1 equ esp+20 |
||
391 | dl_y1 equ esp+16 |
||
392 | dl_x2 equ esp+12 |
||
393 | dl_y2 equ esp+8 |
||
394 | dl_dx equ esp+4 |
||
395 | dl_dy equ esp+0 |
||
396 | |||
469 | serge | 397 | xor edx, edx ; clear edx |
398 | xor esi, esi ; unpack arguments |
||
399 | xor ebp, ebp |
||
400 | mov si, ax ; esi = x2 |
||
401 | mov bp, bx ; ebp = y2 |
||
402 | shr eax, 16 ; eax = x1 |
||
403 | shr ebx, 16 ; ebx = y1 |
||
404 | push eax ; save x1 |
||
405 | push ebx ; save y1 |
||
406 | push esi ; save x2 |
||
407 | push ebp ; save y2 |
||
408 | ; checking x-axis... |
||
409 | sub esi, eax ; esi = x2-x1 |
||
410 | push esi ; save y2-y1 |
||
411 | jl .x2lx1 ; is x2 less than x1 ? |
||
412 | jg .no_vline ; x1 > x2 ? |
||
413 | mov edx, ebp ; else (if x1=x2) |
||
414 | call vline |
||
415 | push edx ; necessary to rightly restore stack frame at .exit |
||
416 | jmp .exit |
||
1 | ha | 417 | .x2lx1: |
469 | serge | 418 | neg esi ; get esi absolute value |
1 | ha | 419 | .no_vline: |
469 | serge | 420 | ; checking y-axis... |
421 | sub ebp, ebx ; ebp = y2-y1 |
||
422 | push ebp ; save y2-y1 |
||
423 | jl .y2ly1 ; is y2 less than y1 ? |
||
424 | jg .no_hline ; y1 > y2 ? |
||
425 | mov edx, [dl_x2] ; else (if y1=y2) |
||
426 | call hline |
||
427 | jmp .exit |
||
1 | ha | 428 | |
429 | .y2ly1: |
||
469 | serge | 430 | neg ebp ; get ebp absolute value |
1 | ha | 431 | .no_hline: |
469 | serge | 432 | cmp ebp, esi |
433 | jle .x_rules ; |y2-y1| < |x2-x1| ? |
||
434 | cmp [dl_y2], ebx ; make sure y1 is at the begining |
||
435 | jge .no_reverse1 |
||
436 | neg dword [dl_dx] |
||
437 | mov edx, [dl_x2] |
||
438 | mov [dl_x2], eax |
||
439 | mov [dl_x1], edx |
||
440 | mov edx, [dl_y2] |
||
441 | mov [dl_y2], ebx |
||
442 | mov [dl_y1], edx |
||
1 | ha | 443 | .no_reverse1: |
469 | serge | 444 | mov eax, [dl_dx] |
445 | cdq ; extend eax sing to edx |
||
446 | shl eax, 16 ; using 16bit fix-point maths |
||
447 | idiv ebp ; eax = ((x2-x1)*65536)/(y2-y1) |
||
448 | mov edx, ebp ; edx = counter (number of pixels to draw) |
||
449 | mov ebp, 1 *65536 ; <<16 ; ebp = dy = 1.0 |
||
450 | mov esi, eax ; esi = dx |
||
451 | jmp .y_rules |
||
1 | ha | 452 | |
453 | .x_rules: |
||
469 | serge | 454 | cmp [dl_x2], eax ; make sure x1 is at the begining |
455 | jge .no_reverse2 |
||
456 | neg dword [dl_dy] |
||
457 | mov edx, [dl_x2] |
||
458 | mov [dl_x2], eax |
||
459 | mov [dl_x1], edx |
||
460 | mov edx, [dl_y2] |
||
461 | mov [dl_y2], ebx |
||
462 | mov [dl_y1], edx |
||
1 | ha | 463 | .no_reverse2: |
469 | serge | 464 | xor edx, edx |
465 | mov eax, [dl_dy] |
||
466 | cdq ; extend eax sing to edx |
||
467 | shl eax, 16 ; using 16bit fix-point maths |
||
468 | idiv esi ; eax = ((y2-y1)*65536)/(x2-x1) |
||
469 | mov edx, esi ; edx = counter (number of pixels to draw) |
||
470 | mov esi, 1 *65536 ;<< 16 ; esi = dx = 1.0 |
||
471 | mov ebp, eax ; ebp = dy |
||
1 | ha | 472 | .y_rules: |
469 | serge | 473 | mov eax, [dl_x1] |
474 | mov ebx, [dl_y1] |
||
475 | shl eax, 16 |
||
476 | shl ebx, 16 |
||
1 | ha | 477 | align 4 |
478 | .draw: |
||
469 | serge | 479 | push eax ebx |
480 | shr eax, 16 |
||
481 | shr ebx, 16 |
||
482 | call [putpixel] |
||
483 | pop ebx eax |
||
484 | add ebx, ebp ; y = y+dy |
||
485 | add eax, esi ; x = x+dx |
||
486 | dec edx |
||
487 | jnz .draw |
||
488 | ; force last drawn pixel to be at (x2,y2) |
||
489 | mov eax, [dl_x2] |
||
490 | mov ebx, [dl_y2] |
||
491 | call [putpixel] |
||
1 | ha | 492 | .exit: |
469 | serge | 493 | add esp, 6*4 |
494 | popa |
||
36 | mario79 | 495 | ; dec [mouse_pause] |
496 | call [draw_pointer] |
||
469 | serge | 497 | ret |
1 | ha | 498 | |
499 | |||
500 | hline: |
||
501 | ; draw an horizontal line |
||
502 | ; eax = x1 |
||
503 | ; edx = x2 |
||
504 | ; ebx = y |
||
505 | ; ecx = color |
||
506 | ; edi = force ? |
||
469 | serge | 507 | push eax edx |
508 | cmp edx, eax ; make sure x2 is above x1 |
||
509 | jge @f |
||
510 | xchg eax, edx |
||
511 | align 4 |
||
512 | @@: |
||
513 | call [putpixel] |
||
514 | inc eax |
||
515 | cmp eax, edx |
||
516 | jle @b |
||
517 | pop edx eax |
||
518 | ret |
||
1 | ha | 519 | |
520 | |||
521 | vline: |
||
522 | ; draw a vertical line |
||
523 | ; eax = x |
||
524 | ; ebx = y1 |
||
525 | ; edx = y2 |
||
526 | ; ecx = color |
||
527 | ; edi = force ? |
||
469 | serge | 528 | push ebx edx |
529 | cmp edx, ebx ; make sure y2 is above y1 |
||
530 | jge @f |
||
531 | xchg ebx, edx |
||
532 | align 4 |
||
533 | @@: |
||
534 | call [putpixel] |
||
535 | inc ebx |
||
536 | cmp ebx, edx |
||
537 | jle @b |
||
538 | pop edx ebx |
||
539 | ret |
||
1 | ha | 540 | |
541 | |||
542 | ;************************************************* |
||
543 | |||
544 | |||
545 | virtual at esp |
||
469 | serge | 546 | drbar: |
547 | .bar_sx dd ? |
||
548 | .bar_sy dd ? |
||
549 | .bar_cx dd ? |
||
550 | .bar_cy dd ? |
||
551 | .abs_cx dd ? |
||
552 | .abs_cy dd ? |
||
553 | .real_sx dd ? |
||
554 | .real_sy dd ? |
||
555 | .color dd ? |
||
556 | .line_inc_scr dd ? |
||
557 | .line_inc_map dd ? |
||
558 | .stack_data = 4*11 |
||
1 | ha | 559 | end virtual |
560 | |||
561 | align 4 |
||
562 | ; eax cx |
||
563 | ; ebx cy |
||
564 | ; ecx xe |
||
565 | ; edx ye |
||
566 | ; edi color |
||
567 | vesa20_drawbar: |
||
469 | serge | 568 | pushad |
1300 | serge | 569 | call [_display.disable_mouse] |
469 | serge | 570 | sub esp, drbar.stack_data |
571 | mov [drbar.color], edi |
||
572 | sub edx, ebx |
||
573 | jle .exit ;// mike.dld, 2005-01-29 |
||
574 | sub ecx, eax |
||
575 | jle .exit ;// mike.dld, 2005-01-29 |
||
576 | mov [drbar.bar_sy], edx |
||
577 | mov [drbar.bar_sx], ecx |
||
578 | mov [drbar.bar_cx], eax |
||
579 | mov [drbar.bar_cy], ebx |
||
580 | mov edi, [TASK_BASE] |
||
581 | add eax, [edi-twdw + WDATA.box.left] ; win_cx |
||
582 | add ebx, [edi-twdw + WDATA.box.top] ; win_cy |
||
583 | mov [drbar.abs_cx], eax |
||
584 | mov [drbar.abs_cy], ebx |
||
585 | ; real_sx = MIN(wnd_sx-bar_cx, bar_sx); |
||
586 | mov ebx, [edi-twdw + WDATA.box.width] ; ebx = wnd_sx |
||
133 | diamond | 587 | ; \begin{diamond}[20.08.2006] |
588 | ; note that WDATA.box.width is one pixel less than real window x-size |
||
469 | serge | 589 | inc ebx |
133 | diamond | 590 | ; \end{diamond}[20.08.2006] |
469 | serge | 591 | sub ebx, [drbar.bar_cx] |
592 | ja @f |
||
593 | .exit: ;// mike.dld, 2005-01-29 |
||
594 | add esp, drbar.stack_data |
||
595 | popad |
||
596 | xor eax, eax |
||
597 | inc eax |
||
598 | ret |
||
599 | @@: |
||
600 | cmp ebx, [drbar.bar_sx] |
||
601 | jbe .end_x |
||
602 | mov ebx, [drbar.bar_sx] |
||
603 | .end_x: |
||
604 | mov [drbar.real_sx], ebx |
||
605 | ; real_sy = MIN(wnd_sy-bar_cy, bar_sy); |
||
606 | mov ebx, [edi-twdw + WDATA.box.height] ; ebx = wnd_sy |
||
133 | diamond | 607 | ; \begin{diamond}[20.08.2006] |
469 | serge | 608 | inc ebx |
133 | diamond | 609 | ; \end{diamond} |
469 | serge | 610 | sub ebx, [drbar.bar_cy] |
611 | ja @f |
||
612 | add esp, drbar.stack_data |
||
613 | popad |
||
614 | xor eax, eax |
||
615 | inc eax |
||
616 | ret |
||
617 | @@: |
||
618 | cmp ebx, [drbar.bar_sy] |
||
619 | jbe .end_y |
||
620 | mov ebx, [drbar.bar_sy] |
||
621 | .end_y: |
||
622 | mov [drbar.real_sy], ebx |
||
623 | ; line_inc_map |
||
753 | serge | 624 | mov eax, [Screen_Max_X] |
469 | serge | 625 | sub eax, [drbar.real_sx] |
626 | inc eax |
||
627 | mov [drbar.line_inc_map], eax |
||
628 | ; line_inc_scr |
||
629 | mov eax, [drbar.real_sx] |
||
630 | movzx ebx, byte [ScreenBPP] |
||
631 | shr ebx, 3 |
||
632 | imul eax, ebx |
||
633 | neg eax |
||
634 | add eax, [BytesPerScanLine] |
||
635 | mov [drbar.line_inc_scr], eax |
||
636 | ; pointer to screen |
||
637 | mov edx, [drbar.abs_cy] |
||
638 | imul edx, [BytesPerScanLine] |
||
639 | mov eax, [drbar.abs_cx] |
||
640 | ; movzx ebx, byte [ScreenBPP] |
||
641 | ; shr ebx, 3 |
||
642 | imul eax, ebx |
||
643 | add edx, eax |
||
644 | ; pointer to pixel map |
||
645 | mov eax, [drbar.abs_cy] |
||
753 | serge | 646 | imul eax, [Screen_Max_X] |
469 | serge | 647 | add eax, [drbar.abs_cy] |
648 | add eax, [drbar.abs_cx] |
||
1300 | serge | 649 | add eax, [_WinMapAddress] |
469 | serge | 650 | xchg eax, ebp |
651 | ; get process number |
||
652 | mov ebx, [CURRENT_TASK] |
||
653 | cmp byte [ScreenBPP], 24 |
||
654 | jne draw_bar_end_32 |
||
1 | ha | 655 | draw_bar_end_24: |
469 | serge | 656 | mov eax, [drbar.color] ;; BBGGRR00 |
657 | mov bh, al ;; bh = BB |
||
658 | shr eax, 8 ;; eax = RRGG |
||
1 | ha | 659 | ; eax - color high RRGG |
660 | ; bl - process num |
||
661 | ; bh - color low BB |
||
662 | ; ecx - temp |
||
663 | ; edx - pointer to screen |
||
664 | ; esi - counter |
||
665 | ; edi - counter |
||
469 | serge | 666 | mov esi, [drbar.real_sy] |
667 | align 4 |
||
668 | .new_y: |
||
669 | mov edi, [drbar.real_sx] |
||
670 | align 4 |
||
671 | .new_x: |
||
672 | cmp byte [ebp], bl |
||
673 | jne .skip |
||
1300 | serge | 674 | |
675 | mov [LFB_BASE+edx], bh |
||
676 | mov [LFB_BASE+edx + 1], ax |
||
469 | serge | 677 | .skip: |
678 | ; add pixel |
||
679 | add edx, 3 |
||
680 | inc ebp |
||
681 | dec edi |
||
682 | jnz .new_x |
||
683 | ; add line |
||
684 | add edx, [drbar.line_inc_scr] |
||
685 | add ebp, [drbar.line_inc_map] |
||
686 | ; |
||
687 | test eax, 0x00800000 |
||
688 | jz @f |
||
689 | test bh, bh |
||
690 | jz @f |
||
691 | dec bh |
||
692 | @@: |
||
693 | ; |
||
694 | dec esi |
||
695 | jnz .new_y |
||
696 | add esp, drbar.stack_data |
||
697 | popad |
||
698 | xor eax, eax |
||
699 | ret |
||
1 | ha | 700 | |
701 | draw_bar_end_32: |
||
469 | serge | 702 | mov eax, [drbar.color] ;; BBGGRR00 |
703 | mov esi, [drbar.real_sy] |
||
704 | align 4 |
||
705 | .new_y: |
||
706 | mov edi, [drbar.real_sx] |
||
707 | align 4 |
||
708 | .new_x: |
||
709 | cmp byte [ebp], bl |
||
710 | jne .skip |
||
1300 | serge | 711 | |
712 | mov [LFB_BASE+edx], eax |
||
469 | serge | 713 | .skip: |
714 | ; add pixel |
||
715 | add edx, 4 |
||
716 | inc ebp |
||
717 | dec edi |
||
718 | jnz .new_x |
||
719 | ; add line |
||
720 | add edx, [drbar.line_inc_scr] |
||
721 | add ebp, [drbar.line_inc_map] |
||
722 | ; |
||
723 | test eax, 0x80000000 |
||
724 | jz @f |
||
725 | test al, al |
||
726 | jz @f |
||
727 | dec al |
||
728 | @@: |
||
729 | ; |
||
730 | dec esi |
||
731 | jnz .new_y |
||
732 | add esp, drbar.stack_data |
||
733 | popad |
||
734 | call VGA_draw_bar |
||
735 | xor eax, eax |
||
736 | mov [EGA_counter],1 |
||
737 | ret |
||
1 | ha | 738 | |
1300 | serge | 739 | align 4 |
1 | ha | 740 | vesa20_drawbackground_tiled: |
1300 | serge | 741 | call [_display.disable_mouse] |
527 | diamond | 742 | pushad |
743 | ; External loop for all y from start to end |
||
744 | mov ebx, [draw_data+32+RECT.top] ; y start |
||
745 | dp2: |
||
746 | mov ebp, [draw_data+32+RECT.left] ; x start |
||
747 | ; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp] |
||
748 | ; and LFB data (output for our function) [edi] |
||
749 | mov eax, [BytesPerScanLine] |
||
750 | mul ebx |
||
751 | xchg ebp, eax |
||
752 | add ebp, eax |
||
753 | add ebp, eax |
||
754 | add ebp, eax |
||
755 | cmp [ScreenBPP], byte 24 ; 24 or 32 bpp ? - x size |
||
756 | jz @f |
||
757 | add ebp, eax |
||
469 | serge | 758 | @@: |
1300 | serge | 759 | add ebp, LFB_BASE |
469 | serge | 760 | ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB |
527 | diamond | 761 | call calculate_edi |
762 | xchg edi, ebp |
||
1300 | serge | 763 | add ebp, [_WinMapAddress] |
527 | diamond | 764 | ; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress |
765 | ; 2) Calculate offset in background memory block |
||
766 | push eax |
||
767 | xor edx, edx |
||
768 | mov eax, ebx |
||
784 | diamond | 769 | div dword [BgrDataHeight] ; edx := y mod BgrDataHeight |
527 | diamond | 770 | pop eax |
771 | push eax |
||
784 | diamond | 772 | mov ecx, [BgrDataWidth] |
527 | diamond | 773 | mov esi, edx |
784 | diamond | 774 | imul esi, ecx ; esi := (y mod BgrDataHeight) * BgrDataWidth |
527 | diamond | 775 | xor edx, edx |
784 | diamond | 776 | div ecx ; edx := x mod BgrDataWidth |
777 | sub ecx, edx |
||
527 | diamond | 778 | add esi, edx ; esi := (y mod BgrDataHeight)*BgrDataWidth + (x mod BgrDataWidth) |
779 | pop eax |
||
780 | lea esi, [esi*3] |
||
781 | add esi, [img_background] |
||
782 | xor edx, edx |
||
783 | inc edx |
||
784 | ; 3) Loop through redraw rectangle and copy background data |
||
785 | ; Registers meaning: |
||
786 | ; eax = x, ebx = y (screen coordinates) |
||
787 | ; ecx = deltax - number of pixels left in current tile block |
||
788 | ; edx = 1 |
||
789 | ; esi -> bgr memory, edi -> output |
||
790 | ; ebp = offset in WinMapAddress |
||
791 | dp3: |
||
1300 | serge | 792 | cmp [ebp], dl |
527 | diamond | 793 | jnz nbgp |
794 | movsb |
||
795 | movsb |
||
796 | movsb |
||
797 | jmp @f |
||
469 | serge | 798 | nbgp: |
527 | diamond | 799 | add esi, 3 |
800 | add edi, 3 |
||
469 | serge | 801 | @@: |
527 | diamond | 802 | cmp [ScreenBPP], byte 25 ; 24 or 32 bpp? |
803 | sbb edi, -1 ; +1 for 32 bpp |
||
804 | ; I do not use 'inc eax' because this is slightly slower then 'add eax,1' |
||
805 | add ebp, edx |
||
806 | add eax, edx |
||
807 | cmp eax, [draw_data+32+RECT.right] |
||
808 | ja dp4 |
||
809 | sub ecx, edx |
||
810 | jnz dp3 |
||
811 | ; next tile block on x-axis |
||
812 | mov ecx, [BgrDataWidth] |
||
813 | sub esi, ecx |
||
814 | sub esi, ecx |
||
815 | sub esi, ecx |
||
816 | jmp dp3 |
||
817 | dp4: |
||
818 | ; next scan line |
||
819 | inc ebx |
||
820 | cmp ebx, [draw_data+32+RECT.bottom] |
||
821 | jbe dp2 |
||
822 | popad |
||
823 | mov [EGA_counter], 1 |
||
824 | call VGA_drawbackground |
||
825 | ret |
||
1 | ha | 826 | |
827 | ; ---------- |
||
828 | |||
829 | |||
830 | vesa20_drawbackground_stretch: |
||
1300 | serge | 831 | call [_display.disable_mouse] |
527 | diamond | 832 | pushad |
833 | ; Helper variables |
||
755 | diamond | 834 | ; calculate 2^32*(BgrDataWidth-1) mod (ScreenWidth-1) |
527 | diamond | 835 | mov eax, [BgrDataWidth] |
546 | diamond | 836 | dec eax |
527 | diamond | 837 | xor edx, edx |
753 | serge | 838 | div dword [Screen_Max_X] |
546 | diamond | 839 | push eax ; high |
840 | xor eax, eax |
||
753 | serge | 841 | div dword [Screen_Max_X] |
546 | diamond | 842 | push eax ; low |
843 | ; the same for height |
||
527 | diamond | 844 | mov eax, [BgrDataHeight] |
546 | diamond | 845 | dec eax |
527 | diamond | 846 | xor edx, edx |
753 | serge | 847 | div dword [Screen_Max_Y] |
546 | diamond | 848 | push eax ; high |
849 | xor eax, eax |
||
753 | serge | 850 | div dword [Screen_Max_Y] |
546 | diamond | 851 | push eax ; low |
527 | diamond | 852 | ; External loop for all y from start to end |
853 | mov ebx, [draw_data+32+RECT.top] ; y start |
||
854 | mov ebp, [draw_data+32+RECT.left] ; x start |
||
855 | ; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp] |
||
856 | ; and LFB data (output for our function) [edi] |
||
857 | mov eax, [BytesPerScanLine] |
||
858 | mul ebx |
||
859 | xchg ebp, eax |
||
860 | add ebp, eax |
||
861 | add ebp, eax |
||
862 | add ebp, eax |
||
863 | cmp [ScreenBPP], byte 24 ; 24 or 32 bpp ? - x size |
||
864 | jz @f |
||
865 | add ebp, eax |
||
469 | serge | 866 | @@: |
867 | ; ebp:=Y*BytesPerScanLine+X*BytesPerPixel+AddrLFB |
||
527 | diamond | 868 | call calculate_edi |
869 | xchg edi, ebp |
||
870 | ; Now eax=x, ebx=y, edi->output, ebp=offset in WinMapAddress |
||
871 | push ebx |
||
546 | diamond | 872 | push eax |
527 | diamond | 873 | ; 2) Calculate offset in background memory block |
874 | mov eax, ebx |
||
546 | diamond | 875 | imul ebx, dword [esp+12] |
876 | mul dword [esp+8] |
||
755 | diamond | 877 | add edx, ebx ; edx:eax = y * 2^32*(BgrDataHeight-1)/(ScreenHeight-1) |
546 | diamond | 878 | mov esi, edx |
879 | imul esi, [BgrDataWidth] |
||
880 | push edx |
||
527 | diamond | 881 | push eax |
546 | diamond | 882 | mov eax, [esp+8] |
883 | mul dword [esp+28] |
||
884 | push eax |
||
885 | mov eax, [esp+12] |
||
886 | mul dword [esp+28] |
||
887 | add [esp], edx |
||
755 | diamond | 888 | pop edx ; edx:eax = x * 2^32*(BgrDataWidth-1)/(ScreenWidth-1) |
546 | diamond | 889 | add esi, edx |
527 | diamond | 890 | lea esi, [esi*3] |
891 | add esi, [img_background] |
||
555 | diamond | 892 | push eax |
893 | push edx |
||
894 | push esi |
||
895 | ; 3) Smooth horizontal |
||
896 | bgr_resmooth0: |
||
897 | mov ecx, [esp+8] |
||
898 | mov edx, [esp+4] |
||
899 | mov esi, [esp] |
||
900 | push edi |
||
901 | mov edi, bgr_cur_line |
||
902 | call smooth_line |
||
903 | bgr_resmooth1: |
||
559 | diamond | 904 | mov eax, [esp+16+4] |
905 | inc eax |
||
906 | cmp eax, [BgrDataHeight] |
||
907 | jae bgr.no2nd |
||
555 | diamond | 908 | mov ecx, [esp+8+4] |
909 | mov edx, [esp+4+4] |
||
910 | mov esi, [esp+4] |
||
911 | add esi, [BgrDataWidth] |
||
912 | add esi, [BgrDataWidth] |
||
913 | add esi, [BgrDataWidth] |
||
914 | mov edi, bgr_next_line |
||
915 | call smooth_line |
||
916 | bgr.no2nd: |
||
917 | pop edi |
||
918 | sdp3: |
||
919 | xor esi, esi |
||
920 | mov ecx, [esp+12] |
||
921 | ; 4) Loop through redraw rectangle and copy background data |
||
527 | diamond | 922 | ; Registers meaning: |
555 | diamond | 923 | ; esi = offset in current line, edi -> output |
527 | diamond | 924 | ; ebp = offset in WinMapAddress |
555 | diamond | 925 | ; dword [esp] = offset in bgr data |
755 | diamond | 926 | ; qword [esp+4] = x * 2^32 * (BgrDataWidth-1) / (ScreenWidth-1) |
927 | ; qword [esp+12] = y * 2^32 * (BgrDataHeight-1) / (ScreenHeight-1) |
||
536 | diamond | 928 | ; dword [esp+20] = x |
546 | diamond | 929 | ; dword [esp+24] = y |
527 | diamond | 930 | ; precalculated constants: |
755 | diamond | 931 | ; qword [esp+28] = 2^32*(BgrDataHeight-1)/(ScreenHeight-1) |
932 | ; qword [esp+36] = 2^32*(BgrDataWidth-1)/(ScreenWidth-1) |
||
555 | diamond | 933 | sdp3a: |
1300 | serge | 934 | mov eax, [_WinMapAddress] |
935 | cmp [ebp+eax], byte 1 |
||
527 | diamond | 936 | jnz snbgp |
555 | diamond | 937 | mov eax, [bgr_cur_line+esi] |
546 | diamond | 938 | test ecx, ecx |
939 | jz .novert |
||
555 | diamond | 940 | mov ebx, [bgr_next_line+esi] |
941 | call [overlapping_of_points_ptr] |
||
546 | diamond | 942 | .novert: |
1300 | serge | 943 | |
944 | mov [LFB_BASE+edi], ax |
||
527 | diamond | 945 | shr eax, 16 |
1300 | serge | 946 | |
947 | mov [LFB_BASE+edi+2], al |
||
527 | diamond | 948 | snbgp: |
949 | cmp [ScreenBPP], byte 25 |
||
950 | sbb edi, -4 |
||
951 | add ebp, 1 |
||
536 | diamond | 952 | mov eax, [esp+20] |
527 | diamond | 953 | add eax, 1 |
536 | diamond | 954 | mov [esp+20], eax |
555 | diamond | 955 | add esi, 4 |
527 | diamond | 956 | cmp eax, [draw_data+32+RECT.right] |
555 | diamond | 957 | jbe sdp3a |
527 | diamond | 958 | sdp4: |
959 | ; next y |
||
546 | diamond | 960 | mov ebx, [esp+24] |
527 | diamond | 961 | add ebx, 1 |
546 | diamond | 962 | mov [esp+24], ebx |
527 | diamond | 963 | cmp ebx, [draw_data+32+RECT.bottom] |
964 | ja sdpdone |
||
965 | ; advance edi, ebp to next scan line |
||
966 | sub eax, [draw_data+32+RECT.left] |
||
967 | sub ebp, eax |
||
753 | serge | 968 | add ebp, [Screen_Max_X] |
527 | diamond | 969 | add ebp, 1 |
970 | sub edi, eax |
||
971 | sub edi, eax |
||
972 | sub edi, eax |
||
973 | cmp [ScreenBPP], byte 24 |
||
974 | jz @f |
||
975 | sub edi, eax |
||
379 | serge | 976 | @@: |
527 | diamond | 977 | add edi, [BytesPerScanLine] |
978 | ; restore ecx,edx; advance esi to next background line |
||
546 | diamond | 979 | mov eax, [esp+28] |
980 | mov ebx, [esp+32] |
||
981 | add [esp+12], eax |
||
982 | mov eax, [esp+16] |
||
983 | adc [esp+16], ebx |
||
555 | diamond | 984 | sub eax, [esp+16] |
985 | mov ebx, eax |
||
546 | diamond | 986 | lea eax, [eax*3] |
987 | imul eax, [BgrDataWidth] |
||
555 | diamond | 988 | sub [esp], eax |
527 | diamond | 989 | mov eax, [draw_data+32+RECT.left] |
536 | diamond | 990 | mov [esp+20], eax |
555 | diamond | 991 | test ebx, ebx |
992 | jz sdp3 |
||
993 | cmp ebx, -1 |
||
994 | jnz bgr_resmooth0 |
||
995 | push edi |
||
996 | mov esi, bgr_next_line |
||
997 | mov edi, bgr_cur_line |
||
753 | serge | 998 | mov ecx, [Screen_Max_X] |
555 | diamond | 999 | inc ecx |
1000 | rep movsd |
||
1001 | jmp bgr_resmooth1 |
||
527 | diamond | 1002 | sdpdone: |
546 | diamond | 1003 | add esp, 44 |
527 | diamond | 1004 | popad |
1005 | mov [EGA_counter],1 |
||
1006 | call VGA_drawbackground |
||
1007 | ret |
||
1 | ha | 1008 | |
555 | diamond | 1009 | uglobal |
1010 | align 4 |
||
1011 | bgr_cur_line rd 1280 ; maximum width of screen |
||
1012 | bgr_next_line rd 1280 |
||
1013 | endg |
||
1014 | |||
1015 | smooth_line: |
||
1016 | mov al, [esi+2] |
||
1017 | shl eax, 16 |
||
1018 | mov ax, [esi] |
||
1019 | test ecx, ecx |
||
1020 | jz @f |
||
1021 | mov ebx, [esi+2] |
||
1022 | shr ebx, 8 |
||
1023 | call [overlapping_of_points_ptr] |
||
1024 | @@: |
||
1025 | stosd |
||
1026 | mov eax, [esp+20+8] |
||
1027 | add eax, 1 |
||
1028 | mov [esp+20+8], eax |
||
1029 | cmp eax, [draw_data+32+RECT.right] |
||
1030 | ja @f |
||
1031 | add ecx, [esp+36+8] |
||
1032 | mov eax, edx |
||
1033 | adc edx, [esp+40+8] |
||
1034 | sub eax, edx |
||
1035 | lea eax, [eax*3] |
||
1036 | sub esi, eax |
||
1037 | jmp smooth_line |
||
1038 | @@: |
||
1039 | mov eax, [draw_data+32+RECT.left] |
||
1040 | mov [esp+20+8], eax |
||
1041 | ret |
||
1042 | |||
1043 | align 16 |
||
379 | serge | 1044 | overlapping_of_points: |
555 | diamond | 1045 | if 0 |
1046 | ; this version of procedure works, but is slower than next version |
||
546 | diamond | 1047 | push ecx edx |
1048 | mov edx, eax |
||
1049 | push esi |
||
1050 | shr ecx, 24 |
||
1051 | mov esi, ecx |
||
1052 | mov ecx, ebx |
||
1053 | movzx ebx, dl |
||
527 | diamond | 1054 | movzx eax, cl |
546 | diamond | 1055 | sub eax, ebx |
527 | diamond | 1056 | movzx ebx, dh |
546 | diamond | 1057 | imul eax, esi |
1058 | add dl, ah |
||
527 | diamond | 1059 | movzx eax, ch |
546 | diamond | 1060 | sub eax, ebx |
1061 | imul eax, esi |
||
1062 | add dh, ah |
||
1063 | ror ecx, 16 |
||
1064 | ror edx, 16 |
||
1065 | movzx eax, cl |
||
1066 | movzx ebx, dl |
||
1067 | sub eax, ebx |
||
1068 | imul eax, esi |
||
1069 | pop esi |
||
1070 | add dl, ah |
||
1071 | mov eax, edx |
||
1072 | pop edx |
||
527 | diamond | 1073 | ror eax, 16 |
546 | diamond | 1074 | pop ecx |
527 | diamond | 1075 | ret |
555 | diamond | 1076 | else |
1077 | push ecx edx |
||
1078 | mov edx, eax |
||
1079 | push esi |
||
1080 | shr ecx, 26 |
||
1081 | mov esi, ecx |
||
1082 | mov ecx, ebx |
||
1083 | shl esi, 9 |
||
1084 | movzx ebx, dl |
||
1085 | movzx eax, cl |
||
1086 | sub eax, ebx |
||
1087 | movzx ebx, dh |
||
1088 | add dl, [BgrAuxTable+(eax+0x100)+esi] |
||
1089 | movzx eax, ch |
||
1090 | sub eax, ebx |
||
1091 | add dh, [BgrAuxTable+(eax+0x100)+esi] |
||
1092 | ror ecx, 16 |
||
1093 | ror edx, 16 |
||
1094 | movzx eax, cl |
||
1095 | movzx ebx, dl |
||
1096 | sub eax, ebx |
||
1097 | add dl, [BgrAuxTable+(eax+0x100)+esi] |
||
1098 | pop esi |
||
1099 | mov eax, edx |
||
1100 | pop edx |
||
1101 | ror eax, 16 |
||
1102 | pop ecx |
||
1103 | ret |
||
1104 | end if |
||
1105 | |||
1106 | iglobal |
||
1107 | align 4 |
||
1108 | overlapping_of_points_ptr dd overlapping_of_points |
||
1109 | endg |
||
1110 | |||
1111 | init_background: |
||
1112 | mov edi, BgrAuxTable |
||
1113 | xor edx, edx |
||
1114 | .loop2: |
||
1115 | mov eax, edx |
||
1116 | shl eax, 8 |
||
1117 | neg eax |
||
1118 | mov ecx, 0x200 |
||
1119 | .loop1: |
||
1120 | mov byte [edi], ah |
||
1121 | inc edi |
||
1122 | add eax, edx |
||
1123 | loop .loop1 |
||
1124 | add dl, 4 |
||
1125 | jnz .loop2 |
||
564 | diamond | 1126 | test byte [cpu_caps+(CAPS_MMX/8)], 1 shl (CAPS_MMX mod 8) |
555 | diamond | 1127 | jz @f |
1128 | mov [overlapping_of_points_ptr], overlapping_of_points_mmx |
||
1129 | @@: |
||
1130 | ret |
||
1131 | |||
1132 | align 16 |
||
1133 | overlapping_of_points_mmx: |
||
1134 | movd mm0, eax |
||
1135 | movd mm4, eax |
||
1136 | movd mm1, ebx |
||
1137 | pxor mm2, mm2 |
||
1138 | punpcklbw mm0, mm2 |
||
1139 | punpcklbw mm1, mm2 |
||
1140 | psubw mm1, mm0 |
||
1141 | movd mm3, ecx |
||
1142 | psrld mm3, 24 |
||
1143 | packuswb mm3, mm3 |
||
1144 | packuswb mm3, mm3 |
||
1145 | pmullw mm1, mm3 |
||
1146 | psrlw mm1, 8 |
||
1147 | packuswb mm1, mm2 |
||
1148 | paddb mm4, mm1 |
||
1149 | movd eax, mm4 |
||
1150 | ret><>16><16>> |