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