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