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