Rev 769 | Rev 983 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
431 | serge | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
||
4 | ;; Distributed under terms of the GNU General Public License ;; |
||
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
593 | mikedld | 8 | $Revision: 802 $ |
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 |
||
25 | mousecount dd 0x0 |
||
26 | mousedata dd 0x0 |
||
27 | endg |
||
28 | |||
473 | diamond | 29 | iglobal |
769 | Rus | 30 | mouse_delay dd 10 |
479 | kastigar | 31 | mouse_speed_factor: dd 3 |
32 | mouse_timer_ticks dd 0 |
||
473 | diamond | 33 | endg |
120 | mario79 | 34 | |
769 | Rus | 35 | ;include 'm_com.inc' |
33 | mario79 | 36 | |
37 | |||
38 | ;test_mario79: |
||
39 | ; push esi |
||
40 | ; push eax |
||
41 | ; mov [write_error_to],process_test_m79+43 |
||
42 | ; movzx eax,al ;[DevErrorCode] |
||
43 | ; call writehex |
||
44 | ; mov esi,process_test_m79 |
||
45 | ; call sys_msg_board_str |
||
46 | ; pop eax |
||
47 | ; pop esi |
||
48 | ; ret |
||
49 | ;process_test_m79 db 'K : Process - test Mario79 error 00000000',13,10,0 |
||
50 | |||
51 | draw_mouse_under: |
||
769 | Rus | 52 | ; return old picture |
214 | serge | 53 | |
769 | Rus | 54 | cmp [set_hw_cursor], 0 |
55 | jz @F |
||
56 | pushad |
||
57 | movzx eax,word [X_UNDER] |
||
58 | movzx ebx,word [Y_UNDER] |
||
59 | stdcall [hw_restore], eax, ebx |
||
60 | popad |
||
61 | ret |
||
214 | serge | 62 | @@: |
769 | Rus | 63 | pushad |
64 | xor ecx,ecx |
||
65 | xor edx,edx |
||
66 | align 4 |
||
119 | mario79 | 67 | mres: |
769 | Rus | 68 | movzx eax,word [X_UNDER] |
69 | movzx ebx,word [Y_UNDER] |
||
70 | add eax,ecx |
||
71 | add ebx,edx |
||
72 | push ecx |
||
73 | push edx |
||
74 | push eax |
||
75 | push ebx |
||
76 | mov eax,edx |
||
77 | shl eax,6 |
||
78 | shl ecx,2 |
||
79 | add eax,ecx |
||
80 | add eax,mouseunder |
||
81 | mov ecx,[eax] |
||
82 | pop ebx |
||
83 | pop eax |
||
84 | mov edi, 1 ;force |
||
85 | call [putpixel] |
||
86 | pop edx |
||
87 | pop ecx |
||
88 | inc ecx |
||
89 | cmp ecx, 16 |
||
90 | jnz mres |
||
91 | xor ecx, ecx |
||
92 | inc edx |
||
93 | cmp edx, 24 |
||
94 | jnz mres |
||
95 | popad |
||
96 | ret |
||
33 | mario79 | 97 | |
98 | save_draw_mouse: |
||
214 | serge | 99 | |
769 | Rus | 100 | cmp [set_hw_cursor], 0 |
101 | je .no_hw_cursor |
||
102 | pushad |
||
221 | serge | 103 | |
769 | Rus | 104 | mov [X_UNDER],ax |
105 | mov [Y_UNDER],bx |
||
106 | movzx eax,word [MOUSE_Y] |
||
107 | movzx ebx,word [MOUSE_X] |
||
108 | push eax |
||
109 | push ebx |
||
221 | serge | 110 | |
769 | Rus | 111 | mov ecx, [Screen_Max_X] |
112 | inc ecx |
||
113 | mul ecx |
||
389 | serge | 114 | |
769 | Rus | 115 | movzx edx, byte [display_data+ebx+eax] |
116 | shl edx, 8 |
||
802 | serge | 117 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
230 | serge | 118 | |
802 | serge | 119 | cmp esi, [current_cursor] |
769 | Rus | 120 | je .draw |
630 | serge | 121 | |
802 | serge | 122 | ; cmp [esi+CURSOR.magic], 'CURS' |
123 | ; jne .fail |
||
630 | serge | 124 | |
802 | serge | 125 | push esi |
769 | Rus | 126 | call [select_hw_cursor] |
802 | serge | 127 | mov [current_cursor], esi |
630 | serge | 128 | .draw: |
802 | serge | 129 | stdcall [set_hw_cursor], esi |
769 | Rus | 130 | popad |
131 | ret |
||
230 | serge | 132 | .fail: |
769 | Rus | 133 | mov ecx, [def_cursor] |
134 | mov [edx+SLOT_BASE+APPDATA.cursor], ecx |
||
802 | serge | 135 | stdcall [set_hw_cursor], ecx ; stdcall: [esp]=ebx,eax |
769 | Rus | 136 | popad |
137 | ret |
||
230 | serge | 138 | |
630 | serge | 139 | .no_hw_cursor: |
769 | Rus | 140 | pushad |
141 | ; save & draw |
||
142 | mov [X_UNDER],ax |
||
143 | mov [Y_UNDER],bx |
||
144 | push eax |
||
145 | push ebx |
||
146 | mov ecx,0 |
||
147 | mov edx,0 |
||
148 | align 4 |
||
119 | mario79 | 149 | drm: |
769 | Rus | 150 | push eax |
151 | push ebx |
||
152 | push ecx |
||
153 | push edx |
||
154 | ; helloworld |
||
155 | push ecx |
||
156 | add eax,ecx ; save picture under mouse |
||
157 | add ebx,edx |
||
158 | push ecx |
||
159 | call getpixel |
||
160 | mov [COLOR_TEMP],ecx |
||
161 | pop ecx |
||
162 | mov eax,edx |
||
163 | shl eax,6 |
||
164 | shl ecx,2 |
||
165 | add eax,ecx |
||
166 | add eax,mouseunder |
||
167 | mov ebx,[COLOR_TEMP] |
||
168 | mov [eax],ebx |
||
169 | pop ecx |
||
170 | mov edi,edx ; y cycle |
||
171 | shl edi,4 ; *16 bytes per row |
||
172 | add edi,ecx ; x cycle |
||
173 | mov esi, edi |
||
174 | add edi, esi |
||
175 | add edi, esi ; *3 |
||
176 | add edi,[MOUSE_PICTURE] ; we have our str address |
||
177 | mov esi, edi |
||
178 | add esi, 16*24*3 |
||
179 | push ecx |
||
180 | mov ecx, [COLOR_TEMP] |
||
181 | call combine_colors |
||
182 | mov [MOUSE_COLOR_MEM], ecx |
||
183 | pop ecx |
||
184 | pop edx |
||
185 | pop ecx |
||
186 | pop ebx |
||
187 | pop eax |
||
188 | add eax,ecx ; we have x coord+cycle |
||
189 | add ebx,edx ; and y coord+cycle |
||
190 | push ecx |
||
191 | mov ecx, [MOUSE_COLOR_MEM] |
||
192 | mov edi, 1 |
||
193 | call [putpixel] |
||
194 | pop ecx |
||
195 | mov ebx,[esp+0] ; pure y coord again |
||
196 | mov eax,[esp+4] ; and x |
||
197 | inc ecx ; +1 cycle |
||
198 | cmp ecx,16 ; if more than 16 |
||
199 | jnz drm |
||
200 | xor ecx, ecx |
||
201 | inc edx |
||
202 | cmp edx,24 |
||
203 | jnz drm |
||
204 | add esp,8 |
||
205 | popad |
||
206 | ret |
||
33 | mario79 | 207 | |
208 | |||
209 | combine_colors: |
||
210 | ; in |
||
211 | ; ecx - color ( 00 RR GG BB ) |
||
212 | ; edi - ref to new color byte |
||
213 | ; esi - ref to alpha byte |
||
214 | ; |
||
215 | ; out |
||
216 | ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) ) |
||
217 | push eax |
||
218 | push ebx |
||
219 | push edx |
||
220 | push ecx |
||
221 | xor ecx, ecx |
||
769 | Rus | 222 | ; byte 2 |
33 | mario79 | 223 | mov eax, 0xff |
224 | sub al, [esi+0] |
||
225 | mov ebx, [esp] |
||
226 | shr ebx, 16 |
||
227 | and ebx, 0xff |
||
228 | mul ebx |
||
229 | shr eax, 8 |
||
230 | add ecx, eax |
||
119 | mario79 | 231 | xor eax, eax |
232 | xor ebx, ebx |
||
233 | mov al, [edi+0] |
||
234 | mov bl, [esi+0] |
||
33 | mario79 | 235 | mul ebx |
236 | shr eax, 8 |
||
237 | add ecx, eax |
||
238 | shl ecx, 8 |
||
769 | Rus | 239 | ; byte 1 |
33 | mario79 | 240 | mov eax, 0xff |
241 | sub al, [esi+1] |
||
242 | mov ebx, [esp] |
||
243 | shr ebx, 8 |
||
244 | and ebx, 0xff |
||
245 | mul ebx |
||
246 | shr eax, 8 |
||
247 | add ecx, eax |
||
119 | mario79 | 248 | xor eax, eax |
249 | xor ebx, ebx |
||
250 | mov al, [edi+1] |
||
251 | mov bl, [esi+1] |
||
33 | mario79 | 252 | mul ebx |
253 | shr eax, 8 |
||
254 | add ecx, eax |
||
255 | shl ecx, 8 |
||
769 | Rus | 256 | ; byte 2 |
33 | mario79 | 257 | mov eax, 0xff |
258 | sub al, [esi+2] |
||
259 | mov ebx, [esp] |
||
260 | and ebx, 0xff |
||
261 | mul ebx |
||
262 | shr eax, 8 |
||
263 | add ecx, eax |
||
119 | mario79 | 264 | xor eax, eax |
265 | xor ebx, ebx |
||
266 | mov al, [edi+2] |
||
267 | mov bl, [esi+2] |
||
33 | mario79 | 268 | mul ebx |
269 | shr eax, 8 |
||
270 | add ecx, eax |
||
271 | pop eax |
||
272 | pop edx |
||
273 | pop ebx |
||
274 | pop eax |
||
275 | ret |
||
276 | |||
277 | |||
278 | __sys_disable_mouse: |
||
381 | serge | 279 | cmp dword [MOUSE_VISIBLE],dword 0 |
36 | mario79 | 280 | je @f |
281 | ret |
||
214 | serge | 282 | @@: |
33 | mario79 | 283 | pushad |
379 | serge | 284 | cmp [CURRENT_TASK],dword 1 |
33 | mario79 | 285 | je disable_m |
379 | serge | 286 | mov edx,[CURRENT_TASK] |
33 | mario79 | 287 | shl edx,5 |
288 | add edx,window_data |
||
381 | serge | 289 | movzx eax, word [MOUSE_X] |
290 | movzx ebx, word [MOUSE_Y] |
||
753 | serge | 291 | mov ecx,[Screen_Max_X] |
33 | mario79 | 292 | inc ecx |
293 | imul ecx,ebx |
||
294 | add ecx,eax |
||
295 | add ecx, display_data |
||
379 | serge | 296 | mov eax, [CURRENT_TASK] |
33 | mario79 | 297 | movzx ebx, byte [ecx] |
298 | cmp eax,ebx |
||
299 | je yes_mouse_disable |
||
300 | movzx ebx, byte [ecx+16] |
||
301 | cmp eax,ebx |
||
302 | je yes_mouse_disable |
||
753 | serge | 303 | mov ebx,[Screen_Max_X] |
33 | mario79 | 304 | inc ebx |
305 | imul ebx,10 |
||
306 | add ecx,ebx |
||
307 | movzx ebx, byte [ecx] |
||
308 | cmp eax,ebx |
||
309 | je yes_mouse_disable |
||
310 | movzx ebx, byte [ecx+16] |
||
311 | cmp eax,ebx |
||
312 | je yes_mouse_disable |
||
313 | jmp no_mouse_disable |
||
119 | mario79 | 314 | yes_mouse_disable: |
379 | serge | 315 | mov edx,[CURRENT_TASK] |
33 | mario79 | 316 | shl edx,5 |
317 | add edx,window_data |
||
381 | serge | 318 | movzx eax, word [MOUSE_X] |
319 | movzx ebx, word [MOUSE_Y] |
||
769 | Rus | 320 | mov ecx,[edx+0] ; mouse inside the area ? |
739 | heavyiron | 321 | add eax,10 |
33 | mario79 | 322 | cmp eax,ecx |
323 | jb no_mouse_disable |
||
739 | heavyiron | 324 | sub eax,10 |
33 | mario79 | 325 | add ecx,[edx+8] |
326 | cmp eax,ecx |
||
327 | jg no_mouse_disable |
||
328 | mov ecx,[edx+4] |
||
739 | heavyiron | 329 | add ebx,14 |
33 | mario79 | 330 | cmp ebx,ecx |
331 | jb no_mouse_disable |
||
739 | heavyiron | 332 | sub ebx,14 |
33 | mario79 | 333 | add ecx,[edx+12] |
334 | cmp ebx,ecx |
||
335 | jg no_mouse_disable |
||
119 | mario79 | 336 | disable_m: |
381 | serge | 337 | cmp dword [MOUSE_VISIBLE],dword 0 |
119 | mario79 | 338 | jne no_mouse_disable |
389 | serge | 339 | pushf |
36 | mario79 | 340 | cli |
119 | mario79 | 341 | call draw_mouse_under |
389 | serge | 342 | popf |
381 | serge | 343 | mov [MOUSE_VISIBLE],dword 1 |
119 | mario79 | 344 | no_mouse_disable: |
33 | mario79 | 345 | popad |
346 | ret |
||
347 | |||
348 | __sys_draw_pointer: |
||
769 | Rus | 349 | cmp [mouse_pause],0 |
350 | je @f |
||
351 | ret |
||
119 | mario79 | 352 | @@: |
769 | Rus | 353 | push eax |
354 | mov eax,[timer_ticks] |
||
355 | sub eax,[MouseTickCounter] |
||
356 | cmp eax,1 |
||
357 | ja @f |
||
358 | pop eax |
||
359 | ret |
||
119 | mario79 | 360 | @@: |
769 | Rus | 361 | mov eax,[timer_ticks] |
362 | mov [MouseTickCounter],eax |
||
363 | pop eax |
||
364 | pushad |
||
365 | cmp dword [MOUSE_VISIBLE],dword 0 ; mouse visible ? |
||
366 | je chms00 |
||
367 | mov [MOUSE_VISIBLE], dword 0 |
||
368 | movzx ebx,word [MOUSE_Y] |
||
369 | movzx eax,word [MOUSE_X] |
||
370 | pushfd |
||
371 | cli |
||
372 | call save_draw_mouse |
||
373 | popfd |
||
119 | mario79 | 374 | nodmu2: |
769 | Rus | 375 | popad |
376 | ret |
||
119 | mario79 | 377 | chms00: |
769 | Rus | 378 | movzx ecx,word [X_UNDER] |
379 | movzx edx,word [Y_UNDER] |
||
380 | movzx ebx,word [MOUSE_Y] |
||
381 | movzx eax,word [MOUSE_X] |
||
382 | cmp eax,ecx |
||
383 | jne redrawmouse |
||
384 | cmp ebx,edx |
||
385 | jne redrawmouse |
||
386 | jmp nodmp |
||
119 | mario79 | 387 | redrawmouse: |
769 | Rus | 388 | pushfd |
389 | cli |
||
390 | call draw_mouse_under |
||
391 | call save_draw_mouse |
||
392 | popfd |
||
119 | mario79 | 393 | nodmp: |
769 | Rus | 394 | popad |
395 | ret |
||
119 | mario79 | 396 | |
479 | kastigar | 397 | proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword |
630 | serge | 398 | |
479 | kastigar | 399 | mov eax,[BtnState] |
400 | mov [BTN_DOWN],eax |
||
401 | |||
402 | mov eax,[XMoving] |
||
403 | call mouse_acceleration |
||
769 | Rus | 404 | add ax,[MOUSE_X] ;[XCoordinate] |
479 | kastigar | 405 | cmp ax,0 |
406 | jge @@M1 |
||
407 | mov eax,0 |
||
408 | jmp @@M2 |
||
409 | @@M1: |
||
753 | serge | 410 | cmp ax,[Screen_Max_X] ;ScreenLength |
769 | Rus | 411 | jl @@M2 |
753 | serge | 412 | mov ax,[Screen_Max_X] ;ScreenLength-1 |
479 | kastigar | 413 | |
414 | @@M2: |
||
769 | Rus | 415 | mov [MOUSE_X],ax ;[XCoordinate] |
479 | kastigar | 416 | |
417 | mov eax,[YMoving] |
||
418 | neg eax |
||
419 | call mouse_acceleration |
||
420 | |||
769 | Rus | 421 | add ax,[MOUSE_Y] ;[YCoordinate] |
479 | kastigar | 422 | cmp ax,0 |
423 | jge @@M3 |
||
424 | mov ax,0 |
||
425 | jmp @@M4 |
||
426 | @@M3: |
||
753 | serge | 427 | cmp ax,[Screen_Max_Y] ;ScreenHeigth |
769 | Rus | 428 | jl @@M4 |
753 | serge | 429 | mov ax,[Screen_Max_Y] ;ScreenHeigth-1 |
479 | kastigar | 430 | |
431 | @@M4: |
||
769 | Rus | 432 | mov [MOUSE_Y],ax ;[YCoordinate] |
479 | kastigar | 433 | |
434 | mov eax,[VScroll] |
||
435 | add [MOUSE_SCROLL_V],ax |
||
630 | serge | 436 | |
479 | kastigar | 437 | mov eax,[HScroll] |
438 | add [MOUSE_SCROLL_H],ax |
||
439 | |||
440 | mov [mouse_active],1 |
||
441 | mov eax,[timer_ticks] |
||
442 | mov [mouse_timer_ticks],eax |
||
443 | ret |
||
444 | endp |
||
445 | |||
446 | mouse_acceleration: |
||
769 | Rus | 447 | push eax |
448 | mov eax,[timer_ticks] |
||
449 | sub eax,[mouse_timer_ticks] |
||
450 | cmp eax,[mouse_delay] |
||
451 | pop eax |
||
452 | ja @f |
||
453 | ;push edx |
||
454 | imul eax,[mouse_speed_factor] |
||
455 | ;pop edx |
||
479 | kastigar | 456 | @@: |
769 | Rus | 457 | ret |
479 | kastigar | 458 |