Rev 4288 | Rev 5565 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4288 | Rev 5201 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 4288 $ |
8 | $Revision: 5201 $ |
9 | 9 | ||
10 | 10 | ||
Line 22... | Line 22... | ||
22 | ; FCFF com1/ps2 buffer count starting from FC00 |
22 | ; FCFF com1/ps2 buffer count starting from FC00 |
Line 23... | Line 23... | ||
23 | 23 | ||
24 | uglobal |
24 | uglobal |
25 | ;-------------------------------------- |
25 | ;-------------------------------------- |
26 | align 4 |
26 | align 4 |
27 | mousecount dd 0x0 |
27 | mousecount dd ? |
28 | mousedata dd 0x0 |
28 | mousedata dd ? |
29 | Y_UNDER_sub_CUR_hot_y_add_curh: |
- | |
30 | dw 0 |
29 | Y_UNDER_sub_CUR_hot_y_add_curh dw ? |
31 | Y_UNDER_subtraction_CUR_hot_y: |
- | |
32 | dw 0 |
30 | Y_UNDER_subtraction_CUR_hot_y dw ? |
33 | X_UNDER_sub_CUR_hot_x_add_curh: |
- | |
34 | dw 0 |
31 | X_UNDER_sub_CUR_hot_x_add_curh dw ? |
35 | X_UNDER_subtraction_CUR_hot_x: |
- | |
36 | dw 0 |
32 | X_UNDER_subtraction_CUR_hot_x dw ? |
Line 37... | Line 33... | ||
37 | endg |
33 | endg |
38 | 34 | ||
39 | iglobal |
35 | iglobal |
40 | ;-------------------------------------- |
36 | ;-------------------------------------- |
41 | align 4 |
37 | align 4 |
42 | mouse_delay dd 10 |
38 | mouse_delay dd 10 |
43 | mouse_speed_factor: |
39 | mouse_speed_factor: |
44 | dd 3 |
40 | dd 3 |
- | 41 | mouse_timer_ticks dd 0 |
|
45 | mouse_timer_ticks dd 0 |
42 | endg |
- | 43 | ||
46 | endg |
44 | ;----------------------------------------------------------------------------- |
47 | ;----------------------------------------------------------------------------- |
45 | |
- | 46 | align 4 |
|
48 | align 4 |
47 | draw_mouse_under: |
49 | draw_mouse_under: |
48 | |
50 | ; return old picture |
49 | ; return old picture |
Line 51... | Line 50... | ||
51 | cmp [_display.restore_cursor], 0 |
50 | cmp [_display.restore_cursor], 0 |
52 | je @F |
51 | je @F |
53 | 52 | ||
54 | pushad |
53 | pushad |
55 | movzx eax, word [X_UNDER] |
54 | movzx eax, word [X_UNDER] |
56 | movzx ebx, word [Y_UNDER] |
55 | movzx ebx, word [Y_UNDER] |
57 | stdcall [_display.restore_cursor], eax, ebx |
- | |
58 | popad |
56 | stdcall [_display.restore_cursor], eax, ebx |
59 | ret |
57 | popad |
60 | ;-------------------------------------- |
58 | ret |
61 | align 4 |
59 | |
62 | @@: |
60 | @@: |
63 | pushad |
- | |
64 | xor ecx, ecx |
61 | pushad |
65 | xor edx, edx |
62 | xor ecx, ecx |
66 | ;-------------------------------------- |
63 | xor edx, edx |
67 | align 4 |
64 | |
68 | mres: |
65 | mres: |
69 | movzx eax, word [X_UNDER] |
66 | movzx eax, word [X_UNDER] |
Line 95... | Line 92... | ||
95 | inc edx |
92 | inc edx |
96 | cmp edx, 24 |
93 | cmp edx, 24 |
97 | jnz mres |
94 | jnz mres |
98 | popad |
95 | popad |
99 | ret |
96 | ret |
- | 97 | ||
100 | ;----------------------------------------------------------------------------- |
98 | ;----------------------------------------------------------------------------- |
- | 99 | ||
101 | align 4 |
100 | align 4 |
102 | save_draw_mouse: |
101 | save_draw_mouse: |
103 | cmp [_display.move_cursor], 0 |
102 | cmp [_display.move_cursor], 0 |
104 | je .no_hw_cursor |
103 | je .no_hw_cursor |
105 | pushad |
104 | pushad |
Line 109... | Line 108... | ||
109 | movzx eax, word [MOUSE_Y] |
108 | movzx eax, word [MOUSE_Y] |
110 | movzx ebx, word [MOUSE_X] |
109 | movzx ebx, word [MOUSE_X] |
111 | push eax |
110 | push eax |
112 | push ebx |
111 | push ebx |
Line -... | Line 112... | ||
- | 112 | ||
- | 113 | ; mov ecx, [Screen_Max_X] |
|
- | 114 | ; inc ecx |
|
113 | 115 | ; mul ecx |
|
Line 114... | Line 116... | ||
114 | mov eax, [d_width_calc_area + eax*4] |
116 | mov eax, [d_width_calc_area + eax*4] |
115 | 117 | ||
116 | add eax, [_WinMapAddress] |
118 | add eax, [_WinMapAddress] |
Line 172... | Line 174... | ||
172 | push ecx |
174 | push ecx |
173 | add eax, ecx; save picture under mouse |
175 | add eax, ecx ; save picture under mouse |
174 | add ebx, edx |
176 | add ebx, edx |
175 | push ecx |
177 | push ecx |
176 | or ecx, 0x04000000 ; don't load to mouseunder area |
178 | or ecx, 0x04000000 ; don't load to mouseunder area |
- | 179 | push eax ebx edx edi |
|
177 | call getpixel |
180 | call [GETPIXEL] |
- | 181 | pop edi edx ebx eax |
|
178 | mov [COLOR_TEMP], ecx |
182 | mov [COLOR_TEMP], ecx |
179 | pop ecx |
183 | pop ecx |
180 | mov eax, edx |
184 | mov eax, edx |
181 | shl eax, 6 |
185 | shl eax, 6 |
182 | shl ecx, 2 |
186 | shl ecx, 2 |
Line 224... | Line 228... | ||
224 | cmp edx, 24 |
228 | cmp edx, 24 |
225 | jnz drm |
229 | jnz drm |
226 | add esp, 8 |
230 | add esp, 8 |
227 | popad |
231 | popad |
228 | ret |
232 | ret |
- | 233 | ||
229 | ;----------------------------------------------------------------------------- |
234 | ;----------------------------------------------------------------------------- |
- | 235 | ||
230 | align 4 |
236 | align 4 |
231 | combine_colors: |
237 | combine_colors: |
232 | ; in |
238 | ; in |
233 | ; ecx - color ( 00 RR GG BB ) |
239 | ; ecx - color ( 00 RR GG BB ) |
234 | ; edi - ref to new color byte |
240 | ; edi - ref to new color byte |
Line 239... | Line 245... | ||
239 | push eax |
245 | push eax |
240 | push ebx |
246 | push ebx |
241 | push edx |
247 | push edx |
242 | push ecx |
248 | push ecx |
243 | xor ecx, ecx |
249 | xor ecx, ecx |
244 | ; byte 2 |
250 | ; byte 0 |
245 | mov eax, 0xff |
251 | mov eax, 0xff |
246 | sub al, [esi+0] |
252 | sub al, [esi+0] |
247 | mov ebx, [esp] |
253 | mov ebx, [esp] |
248 | shr ebx, 16 |
254 | shr ebx, 16 |
249 | and ebx, 0xff |
255 | and ebx, 0xff |
Line 293... | Line 299... | ||
293 | pop eax |
299 | pop eax |
294 | pop edx |
300 | pop edx |
295 | pop ebx |
301 | pop ebx |
296 | pop eax |
302 | pop eax |
297 | ret |
303 | ret |
- | 304 | ||
298 | ;----------------------------------------------------------------------------- |
305 | ;----------------------------------------------------------------------------- |
- | 306 | ||
299 | align 4 |
307 | align 4 |
300 | check_mouse_area_for_getpixel: |
308 | check_mouse_area_for_getpixel: |
301 | ; in: |
309 | ; in: |
302 | ; eax = x |
310 | ; eax = x |
303 | ; ebx = y |
311 | ; ebx = y |
Line 336... | Line 344... | ||
336 | mov ecx, [eax] |
344 | mov ecx, [eax] |
337 | and ecx, 0xffffff |
345 | and ecx, 0xffffff |
338 | or ecx, 0xff000000 |
346 | or ecx, 0xff000000 |
339 | pop ebx eax |
347 | pop ebx eax |
340 | ret |
348 | ret |
341 | ;-------------------------------------- |
- | |
342 | align 4 |
349 | |
343 | .no_mouse_area: |
350 | .no_mouse_area: |
344 | xor ecx, ecx |
351 | xor ecx, ecx |
345 | pop ebx eax |
352 | pop ebx eax |
346 | ret |
353 | ret |
- | 354 | ||
347 | ;----------------------------------------------------------------------------- |
355 | ;----------------------------------------------------------------------------- |
- | 356 | ||
348 | align 4 |
357 | align 4 |
349 | check_mouse_area_for_putpixel: |
358 | check_mouse_area_for_putpixel: |
350 | ; in: |
359 | ; in: |
351 | ; ecx = x shl 16 + y |
360 | ; ecx = x shl 16 + y |
352 | ; eax = color |
361 | ; eax = color |
Line 362... | Line 371... | ||
362 | ja .no_mouse_area |
371 | ja .no_mouse_area |
363 | ; offset Y |
372 | ; offset Y |
364 | sub cx, [Y_UNDER] ;[MOUSE_Y] |
373 | sub cx, [Y_UNDER] ; [MOUSE_Y] |
365 | mov ax, cx |
374 | mov ax, cx |
366 | shl eax, 16 |
375 | shl eax, 16 |
367 | ;-------------------------------------- |
- | |
- | 376 | ||
368 | ; check for X |
377 | ; check for X |
369 | mov ax, [X_UNDER] ;[MOUSE_X] |
378 | mov ax, [X_UNDER] ; [MOUSE_X] |
370 | shr ecx, 16 |
379 | shr ecx, 16 |
371 | cmp cx, ax |
380 | cmp cx, ax |
372 | jb .no_mouse_area |
381 | jb .no_mouse_area |
Line 374... | Line 383... | ||
374 | cmp cx, ax |
383 | cmp cx, ax |
375 | ja .no_mouse_area |
384 | ja .no_mouse_area |
376 | ; offset X |
385 | ; offset X |
377 | sub cx, [X_UNDER] ;[MOUSE_X] |
386 | sub cx, [X_UNDER] ; [MOUSE_X] |
378 | mov ax, cx |
387 | mov ax, cx |
379 | ;-------------------------------------- |
- | |
- | 388 | ||
380 | ; eax = (offset y) shl 16 + (offset x) |
389 | ; eax = (offset y) shl 16 + (offset x) |
Line 381... | Line 390... | ||
381 | 390 | ||
Line 382... | Line 391... | ||
382 | pop ecx |
391 | pop ecx |
Line 406... | Line 415... | ||
406 | add edi, [MOUSE_PICTURE] ; we have our str address |
415 | add edi, [MOUSE_PICTURE] ; we have our str address |
407 | mov esi, edi |
416 | mov esi, edi |
408 | add esi, 16*24*3 |
417 | add esi, 16*24*3 |
409 | call combine_colors |
418 | call combine_colors |
410 | pop edi esi |
419 | pop edi esi |
411 | ;-------------------------------------- |
- | |
412 | align 4 |
- | |
413 | .end: |
- | |
414 | mov eax, ecx |
420 | mov eax, ecx |
415 | ret |
421 | ret |
416 | ;-------------------------------------- |
- | |
417 | align 4 |
422 | |
418 | .no_mouse_area: |
423 | .no_mouse_area: |
419 | pop eax |
424 | pop eax |
420 | ret |
425 | ret |
- | 426 | ||
421 | ;----------------------------------------------------------------------------- |
427 | ;----------------------------------------------------------------------------- |
- | 428 | ||
422 | align 4 |
429 | align 4 |
423 | __sys_draw_pointer: |
430 | __sys_draw_pointer: |
424 | pushad |
431 | pushad |
425 | movzx ecx, word [X_UNDER] |
432 | movzx ecx, word [X_UNDER] |
426 | movzx edx, word [Y_UNDER] |
433 | movzx edx, word [Y_UNDER] |
Line 428... | Line 435... | ||
428 | movzx eax, word [MOUSE_X] |
435 | movzx eax, word [MOUSE_X] |
429 | cmp [redrawmouse_unconditional], 0 |
436 | cmp [redrawmouse_unconditional], 0 |
430 | je @f |
437 | je @f |
431 | mov [redrawmouse_unconditional], 0 |
438 | mov [redrawmouse_unconditional], 0 |
432 | jmp redrawmouse |
439 | jmp redrawmouse |
433 | ;-------------------------------------- |
- | |
434 | align 4 |
- | |
435 | @@: |
440 | @@: |
436 | cmp eax, ecx |
441 | cmp eax, ecx |
437 | jne redrawmouse |
442 | jne redrawmouse |
438 | cmp ebx, edx |
443 | cmp ebx, edx |
439 | je nodmp |
444 | je nodmp |
- | 445 | ||
440 | ;-------------------------------------- |
446 | ;-------------------------------------- |
- | 447 | ||
441 | align 4 |
448 | align 4 |
442 | redrawmouse: |
449 | redrawmouse: |
443 | pushfd |
450 | pushfd |
444 | cli |
451 | cli |
445 | call draw_mouse_under |
452 | call draw_mouse_under |
Line 463... | Line 470... | ||
463 | mov ax, [X_UNDER] |
470 | mov ax, [X_UNDER] |
464 | sub eax, [esi+CURSOR.hot_x] |
471 | sub eax, [esi+CURSOR.hot_x] |
465 | mov [X_UNDER_subtraction_CUR_hot_x], ax |
472 | mov [X_UNDER_subtraction_CUR_hot_x], ax |
466 | add eax, [cur.w] |
473 | add eax, [cur.w] |
467 | mov [X_UNDER_sub_CUR_hot_x_add_curh], ax |
474 | mov [X_UNDER_sub_CUR_hot_x_add_curh], ax |
468 | ;-------------------------------------- |
- | |
469 | align 4 |
- | |
470 | @@: |
475 | @@: |
471 | popfd |
476 | popfd |
472 | ;-------------------------------------- |
- | |
473 | align 4 |
- | |
474 | nodmp: |
477 | nodmp: |
475 | popad |
478 | popad |
476 | ret |
479 | ret |
- | 480 | ||
477 | ;----------------------------------------------------------------------------- |
481 | ;----------------------------------------------------------------------------- |
- | 482 | ||
478 | align 4 |
483 | align 4 |
479 | proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword |
484 | proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword |
Line 480... | Line 485... | ||
480 | 485 | ||
- | 486 | mov eax, [BtnState] |
|
481 | mov eax, [BtnState] |
487 | and eax, 0x3FFFFFFF ; Top 2 bits are used to flag absolute movements |
482 | mov [BTN_DOWN], eax |
- | |
- | 488 | mov [BTN_DOWN], eax |
|
483 | 489 | ;-------------------------------------- |
|
- | 490 | mov eax, [XMoving] |
|
- | 491 | test [BtnState], 0x80000000 |
|
484 | mov eax, [XMoving] |
492 | jnz .absolute_x |
485 | call mouse_acceleration |
493 | call mouse_acceleration |
486 | add ax, [MOUSE_X];[XCoordinate] |
494 | add ax, [MOUSE_X] |
487 | cmp ax, 0 |
495 | cmp ax, 0 |
488 | jge @@M1 |
496 | jge .check_x |
489 | mov eax, 0 |
497 | mov eax, 0 |
- | 498 | jmp .set_x |
|
- | 499 | .absolute_x: |
|
- | 500 | mov edx, [_display.width] |
|
- | 501 | mul edx |
|
- | 502 | shr eax, 15 |
|
- | 503 | .check_x: |
|
- | 504 | cmp ax, word[Screen_Max_X] |
|
- | 505 | jl .set_x |
|
- | 506 | mov ax, word[Screen_Max_X] |
|
- | 507 | .set_x: |
|
490 | jmp @@M2 |
508 | mov [MOUSE_X], ax |
491 | ;-------------------------------------- |
- | |
492 | align 4 |
- | |
493 | @@M1: |
- | |
494 | cmp ax, word [_display.width] |
- | |
495 | jl @@M2 |
- | |
496 | mov ax, word [_display.width] |
- | |
497 | dec ax |
- | |
498 | ;-------------------------------------- |
- | |
499 | align 4 |
- | |
500 | @@M2: |
- | |
501 | mov [MOUSE_X], ax;[XCoordinate] |
- | |
502 | 509 | ;-------------------------------------- |
|
- | 510 | mov eax, [YMoving] |
|
- | 511 | test [BtnState], 0x40000000 |
|
503 | mov eax, [YMoving] |
512 | jnz .absolute_y |
504 | neg eax |
513 | neg eax |
505 | call mouse_acceleration |
- | |
506 | 514 | call mouse_acceleration |
|
507 | add ax, [MOUSE_Y];[YCoordinate] |
515 | add ax, [MOUSE_Y] |
508 | cmp ax, 0 |
516 | cmp ax, 0 |
509 | jge @@M3 |
517 | jge .check_y |
510 | mov ax, 0 |
518 | mov ax, 0 |
- | 519 | jmp .set_y |
|
511 | jmp @@M4 |
520 | .absolute_y: |
512 | ;-------------------------------------- |
521 | mov edx, [_display.height] |
- | 522 | mul edx |
|
513 | align 4 |
523 | shr eax, 15 |
514 | @@M3: |
524 | .check_y: |
515 | cmp ax, word [_display.height] |
525 | cmp ax, word[Screen_Max_Y] |
516 | jl @@M4 |
526 | jl .set_y |
- | 527 | mov ax, word[Screen_Max_Y] |
|
517 | mov ax, word [_display.height] |
528 | .set_y: |
518 | dec ax |
529 | mov [MOUSE_Y], ax |
519 | ;-------------------------------------- |
- | |
520 | align 4 |
- | |
521 | @@M4: |
- | |
522 | mov [MOUSE_Y], ax;[YCoordinate] |
- | |
523 | 530 | ;-------------------------------------- |
|
524 | mov eax, [VScroll] |
531 | mov eax, [VScroll] |
Line 525... | Line 532... | ||
525 | add [MOUSE_SCROLL_V], ax |
532 | add [MOUSE_SCROLL_V], ax |
526 | 533 | ||
Line 531... | Line 538... | ||
531 | mov eax, [timer_ticks] |
538 | mov eax, [timer_ticks] |
532 | mov [mouse_timer_ticks], eax |
539 | mov [mouse_timer_ticks], eax |
533 | call wakeup_osloop |
540 | call wakeup_osloop |
534 | ret |
541 | ret |
535 | endp |
542 | endp |
- | 543 | ||
536 | ;----------------------------------------------------------------------------- |
544 | ;----------------------------------------------------------------------------- |
- | 545 | ||
537 | align 4 |
546 | align 4 |
538 | mouse_acceleration: |
547 | mouse_acceleration: |
539 | push eax |
548 | push eax |
540 | mov eax, [timer_ticks] |
549 | mov eax, [timer_ticks] |
541 | sub eax, [mouse_timer_ticks] |
550 | sub eax, [mouse_timer_ticks] |
Line 543... | Line 552... | ||
543 | pop eax |
552 | pop eax |
544 | ja @f |
553 | ja @f |
545 | ;push edx |
554 | ;push edx |
546 | imul eax, [mouse_speed_factor] |
555 | imul eax, [mouse_speed_factor] |
547 | ;pop edx |
556 | ;pop edx |
548 | ;-------------------------------------- |
- | |
549 | align 4 |
- | |
550 | @@: |
557 | @@: |
551 | ret |
558 | ret |
552 | ;----------------------------------------------------------------------------- |
- |