Rev 3555 | Rev 5201 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
431 | serge | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
2465 | Serge | 3 | ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; |
431 | serge | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
593 | mikedld | 8 | $Revision: 4288 $ |
9 | |||
10 | |||
33 | mario79 | 11 | ; check mouse |
12 | ; |
||
13 | ; |
||
14 | ; FB00 -> FB0F mouse memory 00 chunk count - FB0A-B x - FB0C-D y |
||
15 | ; FB10 -> FB17 mouse color mem |
||
16 | ; FB21 x move |
||
17 | ; FB22 y move |
||
18 | ; FB30 color temp |
||
19 | ; FB28 high bits temp |
||
20 | ; FB4A -> FB4D FB4A-B x-under - FB4C-D y-under |
||
21 | ; FC00 -> FCFE com1/ps2 buffer |
||
22 | ; FCFF com1/ps2 buffer count starting from FC00 |
||
23 | |||
24 | uglobal |
||
2434 | Serge | 25 | ;-------------------------------------- |
26 | align 4 |
||
33 | mario79 | 27 | mousecount dd 0x0 |
28 | mousedata dd 0x0 |
||
2987 | Serge | 29 | Y_UNDER_sub_CUR_hot_y_add_curh: |
30 | dw 0 |
||
2434 | Serge | 31 | Y_UNDER_subtraction_CUR_hot_y: |
2987 | Serge | 32 | dw 0 |
33 | X_UNDER_sub_CUR_hot_x_add_curh: |
||
34 | dw 0 |
||
2434 | Serge | 35 | X_UNDER_subtraction_CUR_hot_x: |
2987 | Serge | 36 | dw 0 |
33 | mario79 | 37 | endg |
38 | |||
473 | diamond | 39 | iglobal |
2434 | Serge | 40 | ;-------------------------------------- |
41 | align 4 |
||
42 | mouse_delay dd 10 |
||
43 | mouse_speed_factor: |
||
44 | dd 3 |
||
479 | kastigar | 45 | mouse_timer_ticks dd 0 |
473 | diamond | 46 | endg |
2434 | Serge | 47 | ;----------------------------------------------------------------------------- |
48 | align 4 |
||
33 | mario79 | 49 | draw_mouse_under: |
2434 | Serge | 50 | ; return old picture |
51 | cmp [_display.restore_cursor], 0 |
||
52 | je @F |
||
214 | serge | 53 | |
2434 | Serge | 54 | pushad |
55 | movzx eax, word [X_UNDER] |
||
56 | movzx ebx, word [Y_UNDER] |
||
57 | stdcall [_display.restore_cursor], eax, ebx |
||
58 | popad |
||
59 | ret |
||
60 | ;-------------------------------------- |
||
61 | align 4 |
||
214 | serge | 62 | @@: |
2434 | Serge | 63 | pushad |
64 | xor ecx, ecx |
||
65 | xor edx, edx |
||
66 | ;-------------------------------------- |
||
67 | align 4 |
||
119 | mario79 | 68 | mres: |
2434 | Serge | 69 | movzx eax, word [X_UNDER] |
70 | movzx ebx, word [Y_UNDER] |
||
71 | add eax, ecx |
||
72 | add ebx, edx |
||
73 | push ecx |
||
74 | push edx |
||
75 | push eax |
||
76 | push ebx |
||
77 | mov eax, edx |
||
78 | shl eax, 6 |
||
79 | shl ecx, 2 |
||
80 | add eax, ecx |
||
81 | add eax, mouseunder |
||
82 | mov ecx, [eax] |
||
83 | pop ebx |
||
84 | pop eax |
||
85 | mov edi, 1 ; force |
||
86 | or ecx, 0x04000000 ; don't save to mouseunder area |
||
2465 | Serge | 87 | ; call [putpixel] |
88 | call __sys_putpixel |
||
2434 | Serge | 89 | pop edx |
90 | pop ecx |
||
91 | inc ecx |
||
92 | cmp ecx, 16 |
||
93 | jnz mres |
||
94 | xor ecx, ecx |
||
95 | inc edx |
||
96 | cmp edx, 24 |
||
97 | jnz mres |
||
98 | popad |
||
99 | ret |
||
100 | ;----------------------------------------------------------------------------- |
||
101 | align 4 |
||
33 | mario79 | 102 | save_draw_mouse: |
2434 | Serge | 103 | cmp [_display.move_cursor], 0 |
104 | je .no_hw_cursor |
||
105 | pushad |
||
214 | serge | 106 | |
2434 | Serge | 107 | mov [X_UNDER], ax |
108 | mov [Y_UNDER], bx |
||
109 | movzx eax, word [MOUSE_Y] |
||
110 | movzx ebx, word [MOUSE_X] |
||
111 | push eax |
||
112 | push ebx |
||
221 | serge | 113 | |
2465 | Serge | 114 | mov eax, [d_width_calc_area + eax*4] |
115 | |||
2434 | Serge | 116 | add eax, [_WinMapAddress] |
117 | movzx edx, byte [ebx+eax] |
||
118 | shl edx, 8 |
||
119 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
||
221 | serge | 120 | |
2434 | Serge | 121 | cmp esi, [current_cursor] |
122 | je .draw |
||
230 | serge | 123 | |
3232 | Serge | 124 | mov eax, [TASK_COUNT] |
125 | movzx eax, word [WIN_POS+eax*2] |
||
126 | shl eax, 8 |
||
127 | |||
128 | cmp eax, edx |
||
129 | je @F |
||
130 | |||
131 | mov esi, [def_cursor] |
||
132 | cmp esi, [current_cursor] |
||
133 | je .draw |
||
134 | |||
135 | @@: |
||
2434 | Serge | 136 | push esi |
137 | call [_display.select_cursor] |
||
138 | mov [current_cursor], esi |
||
139 | ;-------------------------------------- |
||
140 | align 4 |
||
630 | serge | 141 | .draw: |
2434 | Serge | 142 | stdcall [_display.move_cursor], esi |
143 | popad |
||
144 | ret |
||
145 | ;-------------------------------------- |
||
146 | ;align 4 |
||
147 | ;.fail: |
||
148 | ; mov ecx, [def_cursor] |
||
149 | ; mov [edx+SLOT_BASE+APPDATA.cursor], ecx |
||
150 | ; stdcall [_display.move_cursor], ecx ; stdcall: [esp]=ebx,eax |
||
151 | ; popad |
||
152 | ; ret |
||
153 | ;-------------------------------------- |
||
154 | align 4 |
||
630 | serge | 155 | .no_hw_cursor: |
2434 | Serge | 156 | pushad |
157 | ; save & draw |
||
158 | mov [X_UNDER], ax |
||
159 | mov [Y_UNDER], bx |
||
160 | push eax |
||
161 | push ebx |
||
162 | mov ecx, 0 |
||
163 | mov edx, 0 |
||
164 | ;-------------------------------------- |
||
165 | align 4 |
||
119 | mario79 | 166 | drm: |
2434 | Serge | 167 | push eax |
168 | push ebx |
||
169 | push ecx |
||
170 | push edx |
||
171 | ; helloworld |
||
172 | push ecx |
||
173 | add eax, ecx; save picture under mouse |
||
174 | add ebx, edx |
||
175 | push ecx |
||
176 | or ecx, 0x04000000 ; don't load to mouseunder area |
||
177 | call getpixel |
||
178 | mov [COLOR_TEMP], ecx |
||
179 | pop ecx |
||
180 | mov eax, edx |
||
181 | shl eax, 6 |
||
182 | shl ecx, 2 |
||
183 | add eax, ecx |
||
184 | add eax, mouseunder |
||
185 | mov ebx, [COLOR_TEMP] |
||
186 | and ebx, 0xffffff |
||
187 | mov [eax], ebx |
||
188 | pop ecx |
||
189 | mov edi, edx ; y cycle |
||
190 | shl edi, 4 ; *16 bytes per row |
||
191 | add edi, ecx ; x cycle |
||
192 | mov esi, edi |
||
193 | add edi, esi |
||
194 | add edi, esi ; *3 |
||
195 | add edi, [MOUSE_PICTURE] ; we have our str address |
||
196 | mov esi, edi |
||
197 | add esi, 16*24*3 |
||
198 | push ecx |
||
199 | mov ecx, [COLOR_TEMP] |
||
200 | call combine_colors |
||
201 | and ecx, 0xffffff |
||
202 | mov [MOUSE_COLOR_MEM], ecx |
||
203 | pop ecx |
||
204 | pop edx |
||
205 | pop ecx |
||
206 | pop ebx |
||
207 | pop eax |
||
208 | add eax, ecx ; we have x coord+cycle |
||
209 | add ebx, edx ; and y coord+cycle |
||
210 | push ecx |
||
211 | mov ecx, [MOUSE_COLOR_MEM] |
||
212 | mov edi, 1 ; force |
||
213 | or ecx, 0x04000000 ; don't save to mouseunder area |
||
2465 | Serge | 214 | ; call [putpixel] |
215 | call __sys_putpixel |
||
2434 | Serge | 216 | pop ecx |
217 | mov ebx, [esp+0] ; pure y coord again |
||
218 | mov eax, [esp+4] ; and x |
||
219 | inc ecx ; +1 cycle |
||
220 | cmp ecx, 16 ; if more than 16 |
||
221 | jnz drm |
||
222 | xor ecx, ecx |
||
223 | inc edx |
||
224 | cmp edx, 24 |
||
225 | jnz drm |
||
226 | add esp, 8 |
||
227 | popad |
||
228 | ret |
||
229 | ;----------------------------------------------------------------------------- |
||
230 | align 4 |
||
33 | mario79 | 231 | combine_colors: |
232 | ; in |
||
233 | ; ecx - color ( 00 RR GG BB ) |
||
234 | ; edi - ref to new color byte |
||
235 | ; esi - ref to alpha byte |
||
236 | ; |
||
237 | ; out |
||
238 | ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) ) |
||
2434 | Serge | 239 | push eax |
240 | push ebx |
||
241 | push edx |
||
242 | push ecx |
||
243 | xor ecx, ecx |
||
244 | ; byte 2 |
||
245 | mov eax, 0xff |
||
246 | sub al, [esi+0] |
||
247 | mov ebx, [esp] |
||
248 | shr ebx, 16 |
||
249 | and ebx, 0xff |
||
250 | mul ebx |
||
251 | shr eax, 8 |
||
252 | add ecx, eax |
||
253 | xor eax, eax |
||
254 | xor ebx, ebx |
||
255 | mov al, [edi+0] |
||
256 | mov bl, [esi+0] |
||
257 | mul ebx |
||
258 | shr eax, 8 |
||
259 | add ecx, eax |
||
260 | shl ecx, 8 |
||
261 | ; byte 1 |
||
262 | mov eax, 0xff |
||
263 | sub al, [esi+1] |
||
264 | mov ebx, [esp] |
||
265 | shr ebx, 8 |
||
266 | and ebx, 0xff |
||
267 | mul ebx |
||
268 | shr eax, 8 |
||
269 | add ecx, eax |
||
270 | xor eax, eax |
||
271 | xor ebx, ebx |
||
272 | mov al, [edi+1] |
||
273 | mov bl, [esi+1] |
||
274 | mul ebx |
||
275 | shr eax, 8 |
||
276 | add ecx, eax |
||
277 | shl ecx, 8 |
||
278 | ; byte 2 |
||
279 | mov eax, 0xff |
||
280 | sub al, [esi+2] |
||
281 | mov ebx, [esp] |
||
282 | and ebx, 0xff |
||
283 | mul ebx |
||
284 | shr eax, 8 |
||
285 | add ecx, eax |
||
286 | xor eax, eax |
||
287 | xor ebx, ebx |
||
288 | mov al, [edi+2] |
||
289 | mov bl, [esi+2] |
||
290 | mul ebx |
||
291 | shr eax, 8 |
||
292 | add ecx, eax |
||
293 | pop eax |
||
294 | pop edx |
||
295 | pop ebx |
||
296 | pop eax |
||
297 | ret |
||
298 | ;----------------------------------------------------------------------------- |
||
299 | align 4 |
||
300 | check_mouse_area_for_getpixel: |
||
301 | ; in: |
||
302 | ; eax = x |
||
303 | ; ebx = y |
||
304 | ; out: |
||
305 | ; ecx = new color |
||
306 | push eax ebx |
||
307 | ; check for Y |
||
308 | xor ecx, ecx |
||
309 | mov cx, [Y_UNDER] ; [MOUSE_Y] |
||
33 | mario79 | 310 | |
2434 | Serge | 311 | cmp ebx, ecx |
312 | jb .no_mouse_area |
||
313 | add ecx, 23 ; mouse cursor Y size |
||
314 | cmp ebx, ecx |
||
315 | ja .no_mouse_area |
||
316 | ; offset Y |
||
317 | sub bx, [Y_UNDER] ;[MOUSE_Y] |
||
318 | ;-------------------------------------- |
||
319 | ; check for X |
||
320 | xor ecx, ecx |
||
321 | mov cx, [X_UNDER] ;[MOUSE_X] |
||
322 | cmp eax, ecx |
||
323 | jb .no_mouse_area |
||
324 | add ecx, 15 ; mouse cursor X size |
||
325 | cmp eax, ecx |
||
326 | ja .no_mouse_area |
||
327 | ; offset X |
||
328 | sub ax, [X_UNDER] ;[MOUSE_X] |
||
329 | ;-------------------------------------- |
||
330 | ; eax = offset x |
||
331 | ; ebx = offset y |
||
332 | shl ebx, 6 ;y |
||
333 | shl eax, 2 ;x |
||
334 | add eax, ebx |
||
335 | add eax, mouseunder |
||
336 | mov ecx, [eax] |
||
337 | and ecx, 0xffffff |
||
338 | or ecx, 0xff000000 |
||
339 | pop ebx eax |
||
340 | ret |
||
341 | ;-------------------------------------- |
||
342 | align 4 |
||
343 | .no_mouse_area: |
||
344 | xor ecx, ecx |
||
345 | pop ebx eax |
||
346 | ret |
||
347 | ;----------------------------------------------------------------------------- |
||
348 | align 4 |
||
349 | check_mouse_area_for_putpixel: |
||
350 | ; in: |
||
351 | ; ecx = x shl 16 + y |
||
352 | ; eax = color |
||
353 | ; out: |
||
354 | ; eax = new color |
||
355 | push eax |
||
356 | ; check for Y |
||
357 | mov ax, [Y_UNDER] ; [MOUSE_Y] |
||
358 | cmp cx, ax |
||
359 | jb .no_mouse_area |
||
360 | add ax, 23 ; mouse cursor Y size |
||
361 | cmp cx, ax |
||
362 | ja .no_mouse_area |
||
363 | ; offset Y |
||
364 | sub cx, [Y_UNDER] ;[MOUSE_Y] |
||
365 | mov ax, cx |
||
366 | shl eax, 16 |
||
367 | ;-------------------------------------- |
||
368 | ; check for X |
||
369 | mov ax, [X_UNDER] ;[MOUSE_X] |
||
370 | shr ecx, 16 |
||
371 | cmp cx, ax |
||
372 | jb .no_mouse_area |
||
373 | add ax, 15 ; mouse cursor X size |
||
374 | cmp cx, ax |
||
375 | ja .no_mouse_area |
||
376 | ; offset X |
||
377 | sub cx, [X_UNDER] ;[MOUSE_X] |
||
378 | mov ax, cx |
||
379 | ;-------------------------------------- |
||
380 | ; eax = (offset y) shl 16 + (offset x) |
||
33 | mario79 | 381 | |
2434 | Serge | 382 | pop ecx |
33 | mario79 | 383 | |
2434 | Serge | 384 | push eax ebx |
385 | |||
386 | mov ebx, eax |
||
387 | shr ebx, 16 ;y |
||
388 | and eax, 0xffff ;x |
||
389 | |||
390 | shl ebx, 6 |
||
391 | shl eax, 2 |
||
392 | add eax, ebx |
||
393 | add eax, mouseunder |
||
394 | and ecx, 0xFFFFFF |
||
395 | mov [eax], ecx |
||
396 | |||
397 | pop ebx eax |
||
398 | |||
399 | push esi edi |
||
400 | rol eax, 16 |
||
401 | movzx edi, ax ; y cycle |
||
402 | shl edi, 4 ; *16 bytes per row |
||
403 | shr eax, 16 |
||
404 | add edi, eax ; x cycle |
||
405 | lea edi, [edi*3] |
||
406 | add edi, [MOUSE_PICTURE] ; we have our str address |
||
407 | mov esi, edi |
||
408 | add esi, 16*24*3 |
||
409 | call combine_colors |
||
410 | pop edi esi |
||
411 | ;-------------------------------------- |
||
412 | align 4 |
||
413 | .end: |
||
414 | mov eax, ecx |
||
415 | ret |
||
416 | ;-------------------------------------- |
||
417 | align 4 |
||
418 | .no_mouse_area: |
||
419 | pop eax |
||
420 | ret |
||
421 | ;----------------------------------------------------------------------------- |
||
422 | align 4 |
||
33 | mario79 | 423 | __sys_draw_pointer: |
2434 | Serge | 424 | pushad |
425 | movzx ecx, word [X_UNDER] |
||
426 | movzx edx, word [Y_UNDER] |
||
427 | movzx ebx, word [MOUSE_Y] |
||
428 | movzx eax, word [MOUSE_X] |
||
2465 | Serge | 429 | cmp [redrawmouse_unconditional], 0 |
430 | je @f |
||
431 | mov [redrawmouse_unconditional], 0 |
||
432 | jmp redrawmouse |
||
433 | ;-------------------------------------- |
||
434 | align 4 |
||
435 | @@: |
||
2434 | Serge | 436 | cmp eax, ecx |
437 | jne redrawmouse |
||
438 | cmp ebx, edx |
||
439 | je nodmp |
||
440 | ;-------------------------------------- |
||
441 | align 4 |
||
442 | redrawmouse: |
||
443 | pushfd |
||
444 | cli |
||
445 | call draw_mouse_under |
||
446 | call save_draw_mouse |
||
447 | |||
2465 | Serge | 448 | ; mov eax, [_display.select_cursor] |
449 | ; test eax, eax |
||
450 | ; jz @f |
||
451 | cmp [_display.select_cursor], select_cursor |
||
452 | jne @f |
||
2434 | Serge | 453 | |
454 | xor eax, eax |
||
455 | mov esi, [current_cursor] |
||
456 | |||
457 | mov ax, [Y_UNDER] |
||
458 | sub eax, [esi+CURSOR.hot_y] |
||
2987 | Serge | 459 | mov [Y_UNDER_subtraction_CUR_hot_y], ax |
2434 | Serge | 460 | add eax, [cur.h] |
2987 | Serge | 461 | mov [Y_UNDER_sub_CUR_hot_y_add_curh], ax |
2434 | Serge | 462 | |
463 | mov ax, [X_UNDER] |
||
464 | sub eax, [esi+CURSOR.hot_x] |
||
2987 | Serge | 465 | mov [X_UNDER_subtraction_CUR_hot_x], ax |
2434 | Serge | 466 | add eax, [cur.w] |
2987 | Serge | 467 | mov [X_UNDER_sub_CUR_hot_x_add_curh], ax |
2434 | Serge | 468 | ;-------------------------------------- |
469 | align 4 |
||
119 | mario79 | 470 | @@: |
2434 | Serge | 471 | popfd |
472 | ;-------------------------------------- |
||
473 | align 4 |
||
119 | mario79 | 474 | nodmp: |
2434 | Serge | 475 | popad |
476 | ret |
||
477 | ;----------------------------------------------------------------------------- |
||
478 | align 4 |
||
479 | kastigar | 479 | proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword |
630 | serge | 480 | |
2434 | Serge | 481 | mov eax, [BtnState] |
482 | mov [BTN_DOWN], eax |
||
479 | kastigar | 483 | |
2434 | Serge | 484 | mov eax, [XMoving] |
485 | call mouse_acceleration |
||
486 | add ax, [MOUSE_X];[XCoordinate] |
||
487 | cmp ax, 0 |
||
488 | jge @@M1 |
||
489 | mov eax, 0 |
||
490 | jmp @@M2 |
||
491 | ;-------------------------------------- |
||
492 | align 4 |
||
479 | kastigar | 493 | @@M1: |
4288 | Serge | 494 | cmp ax, word [_display.width] |
2434 | Serge | 495 | jl @@M2 |
4288 | Serge | 496 | mov ax, word [_display.width] |
497 | dec ax |
||
2434 | Serge | 498 | ;-------------------------------------- |
499 | align 4 |
||
479 | kastigar | 500 | @@M2: |
2434 | Serge | 501 | mov [MOUSE_X], ax;[XCoordinate] |
479 | kastigar | 502 | |
2434 | Serge | 503 | mov eax, [YMoving] |
504 | neg eax |
||
505 | call mouse_acceleration |
||
479 | kastigar | 506 | |
2434 | Serge | 507 | add ax, [MOUSE_Y];[YCoordinate] |
508 | cmp ax, 0 |
||
509 | jge @@M3 |
||
510 | mov ax, 0 |
||
511 | jmp @@M4 |
||
512 | ;-------------------------------------- |
||
513 | align 4 |
||
479 | kastigar | 514 | @@M3: |
4288 | Serge | 515 | cmp ax, word [_display.height] |
2434 | Serge | 516 | jl @@M4 |
4288 | Serge | 517 | mov ax, word [_display.height] |
518 | dec ax |
||
2434 | Serge | 519 | ;-------------------------------------- |
520 | align 4 |
||
479 | kastigar | 521 | @@M4: |
2434 | Serge | 522 | mov [MOUSE_Y], ax;[YCoordinate] |
479 | kastigar | 523 | |
2434 | Serge | 524 | mov eax, [VScroll] |
525 | add [MOUSE_SCROLL_V], ax |
||
630 | serge | 526 | |
2434 | Serge | 527 | mov eax, [HScroll] |
528 | add [MOUSE_SCROLL_H], ax |
||
479 | kastigar | 529 | |
2434 | Serge | 530 | mov [mouse_active], 1 |
531 | mov eax, [timer_ticks] |
||
532 | mov [mouse_timer_ticks], eax |
||
3555 | Serge | 533 | call wakeup_osloop |
2434 | Serge | 534 | ret |
479 | kastigar | 535 | endp |
2434 | Serge | 536 | ;----------------------------------------------------------------------------- |
537 | align 4 |
||
479 | kastigar | 538 | mouse_acceleration: |
2434 | Serge | 539 | push eax |
540 | mov eax, [timer_ticks] |
||
541 | sub eax, [mouse_timer_ticks] |
||
542 | cmp eax, [mouse_delay] |
||
543 | pop eax |
||
544 | ja @f |
||
545 | ;push edx |
||
546 | imul eax, [mouse_speed_factor] |
||
547 | ;pop edx |
||
548 | ;-------------------------------------- |
||
549 | align 4 |
||
479 | kastigar | 550 | @@: |
2434 | Serge | 551 | ret |
552 | ;----------------------------------------------------------------------------- |