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