Rev 425 | Rev 473 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
425 | victor | 1 | $Revision: 431 $ |
431 | serge | 2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
3 | ;; ;; |
||
4 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
||
5 | ;; Distributed under terms of the GNU General Public License ;; |
||
6 | ;; ;; |
||
7 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
8 | |||
33 | mario79 | 9 | ; check mouse |
10 | ; |
||
11 | ; |
||
12 | ; FB00 -> FB0F mouse memory 00 chunk count - FB0A-B x - FB0C-D y |
||
13 | ; FB10 -> FB17 mouse color mem |
||
14 | ; FB21 x move |
||
15 | ; FB22 y move |
||
16 | ; FB30 color temp |
||
17 | ; FB28 high bits temp |
||
18 | ; FB4A -> FB4D FB4A-B x-under - FB4C-D y-under |
||
19 | ; FC00 -> FCFE com1/ps2 buffer |
||
20 | ; FCFF com1/ps2 buffer count starting from FC00 |
||
21 | |||
22 | uglobal |
||
23 | mousecount dd 0x0 |
||
24 | mousedata dd 0x0 |
||
25 | endg |
||
26 | |||
120 | mario79 | 27 | mouse_delay dd 10 |
28 | mouse_speed_factor dw 3 |
||
29 | |||
33 | mario79 | 30 | include 'm_ps2.inc' |
31 | include 'm_com1.inc' |
||
32 | include 'm_com2.inc' |
||
33 | |||
34 | |||
35 | ;test_mario79: |
||
36 | ; push esi |
||
37 | ; push eax |
||
38 | ; mov [write_error_to],process_test_m79+43 |
||
39 | ; movzx eax,al ;[DevErrorCode] |
||
40 | ; call writehex |
||
41 | ; mov esi,process_test_m79 |
||
42 | ; call sys_msg_board_str |
||
43 | ; pop eax |
||
44 | ; pop esi |
||
45 | ; ret |
||
46 | ;process_test_m79 db 'K : Process - test Mario79 error 00000000',13,10,0 |
||
47 | |||
48 | draw_mouse_under: |
||
49 | ; return old picture |
||
214 | serge | 50 | |
51 | cmp [set_hw_cursor], 0 |
||
221 | serge | 52 | jz @F |
53 | pushad |
||
381 | serge | 54 | movzx eax,word [X_UNDER] |
55 | movzx ebx,word [Y_UNDER] |
||
221 | serge | 56 | stdcall [hw_restore], eax, ebx |
57 | popad |
||
214 | serge | 58 | ret |
59 | @@: |
||
33 | mario79 | 60 | pushad |
61 | xor ecx,ecx |
||
62 | xor edx,edx |
||
63 | align 4 |
||
119 | mario79 | 64 | mres: |
381 | serge | 65 | movzx eax,word [X_UNDER] |
66 | movzx ebx,word [Y_UNDER] |
||
33 | mario79 | 67 | add eax,ecx |
68 | add ebx,edx |
||
69 | push ecx |
||
70 | push edx |
||
71 | push eax |
||
72 | push ebx |
||
73 | mov eax,edx |
||
74 | shl eax,6 |
||
75 | shl ecx,2 |
||
76 | add eax,ecx |
||
77 | add eax,mouseunder |
||
78 | mov ecx,[eax] |
||
79 | pop ebx |
||
80 | pop eax |
||
81 | mov edi, 1 ;force |
||
82 | call [putpixel] |
||
83 | pop edx |
||
84 | pop ecx |
||
85 | inc ecx |
||
86 | cmp ecx, 16 |
||
87 | jnz mres |
||
88 | xor ecx, ecx |
||
89 | inc edx |
||
90 | cmp edx, 24 |
||
91 | jnz mres |
||
92 | popad |
||
93 | ret |
||
94 | |||
95 | save_draw_mouse: |
||
214 | serge | 96 | |
97 | cmp [set_hw_cursor], 0 |
||
98 | jz @F |
||
221 | serge | 99 | pushad |
100 | |||
381 | serge | 101 | mov [X_UNDER],ax |
102 | mov [Y_UNDER],bx |
||
103 | movzx eax,word [MOUSE_Y] |
||
104 | movzx ebx,word [MOUSE_X] |
||
221 | serge | 105 | push eax |
214 | serge | 106 | push ebx |
221 | serge | 107 | |
381 | serge | 108 | mov ecx, [ScreenWidth] |
221 | serge | 109 | inc ecx |
110 | mul ecx |
||
389 | serge | 111 | |
221 | serge | 112 | movzx edx, byte [display_data+ebx+eax] |
113 | shl edx, 8 |
||
380 | serge | 114 | mov ecx, [edx+SLOT_BASE+APPDATA.cursor] |
230 | serge | 115 | |
116 | cmp [ecx+CURSOR.magic], 'CURS' |
||
117 | jne .fail |
||
281 | serge | 118 | ; cmp [ecx+CURSOR.size], CURSOR_SIZE |
119 | ; jne .fail |
||
230 | serge | 120 | push ecx |
214 | serge | 121 | call [set_hw_cursor] |
221 | serge | 122 | popad |
214 | serge | 123 | ret |
230 | serge | 124 | .fail: |
125 | mov ecx, [def_cursor] |
||
380 | serge | 126 | mov [edx+SLOT_BASE+APPDATA.cursor], ecx |
230 | serge | 127 | push ecx |
128 | call [set_hw_cursor] |
||
129 | popad |
||
130 | ret |
||
131 | |||
214 | serge | 132 | @@: |
33 | mario79 | 133 | pushad |
134 | ; save & draw |
||
381 | serge | 135 | mov [X_UNDER],ax |
136 | mov [Y_UNDER],bx |
||
33 | mario79 | 137 | push eax |
138 | push ebx |
||
139 | mov ecx,0 |
||
140 | mov edx,0 |
||
141 | align 4 |
||
119 | mario79 | 142 | drm: |
33 | mario79 | 143 | push eax |
144 | push ebx |
||
145 | push ecx |
||
146 | push edx |
||
147 | ; helloworld |
||
148 | push ecx |
||
149 | add eax,ecx ; save picture under mouse |
||
150 | add ebx,edx |
||
151 | push ecx |
||
152 | call getpixel |
||
381 | serge | 153 | mov [COLOR_TEMP],ecx |
33 | mario79 | 154 | pop ecx |
155 | mov eax,edx |
||
156 | shl eax,6 |
||
157 | shl ecx,2 |
||
158 | add eax,ecx |
||
159 | add eax,mouseunder |
||
381 | serge | 160 | mov ebx,[COLOR_TEMP] |
33 | mario79 | 161 | mov [eax],ebx |
162 | pop ecx |
||
163 | mov edi,edx ; y cycle |
||
164 | shl edi,4 ; *16 bytes per row |
||
165 | add edi,ecx ; x cycle |
||
166 | mov esi, edi |
||
167 | add edi, esi |
||
168 | add edi, esi ; *3 |
||
381 | serge | 169 | add edi,[MOUSE_PICTURE] ; we have our str address |
33 | mario79 | 170 | mov esi, edi |
171 | add esi, 16*24*3 |
||
172 | push ecx |
||
381 | serge | 173 | mov ecx, [COLOR_TEMP] |
33 | mario79 | 174 | call combine_colors |
381 | serge | 175 | mov [MOUSE_COLOR_MEM], ecx |
33 | mario79 | 176 | pop ecx |
177 | pop edx |
||
178 | pop ecx |
||
179 | pop ebx |
||
180 | pop eax |
||
181 | add eax,ecx ; we have x coord+cycle |
||
182 | add ebx,edx ; and y coord+cycle |
||
183 | push ecx |
||
381 | serge | 184 | mov ecx, [MOUSE_COLOR_MEM] |
33 | mario79 | 185 | mov edi, 1 |
186 | call [putpixel] |
||
187 | pop ecx |
||
188 | mov ebx,[esp+0] ; pure y coord again |
||
189 | mov eax,[esp+4] ; and x |
||
190 | inc ecx ; +1 cycle |
||
191 | cmp ecx,16 ; if more than 16 |
||
192 | jnz drm |
||
193 | xor ecx, ecx |
||
194 | inc edx |
||
195 | cmp edx,24 |
||
196 | jnz drm |
||
119 | mario79 | 197 | add esp,8 |
33 | mario79 | 198 | popad |
199 | ret |
||
200 | |||
201 | |||
202 | combine_colors: |
||
203 | ; in |
||
204 | ; ecx - color ( 00 RR GG BB ) |
||
205 | ; edi - ref to new color byte |
||
206 | ; esi - ref to alpha byte |
||
207 | ; |
||
208 | ; out |
||
209 | ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) ) |
||
210 | push eax |
||
211 | push ebx |
||
212 | push edx |
||
213 | push ecx |
||
214 | xor ecx, ecx |
||
215 | ; byte 2 |
||
216 | mov eax, 0xff |
||
217 | sub al, [esi+0] |
||
218 | mov ebx, [esp] |
||
219 | shr ebx, 16 |
||
220 | and ebx, 0xff |
||
221 | mul ebx |
||
222 | shr eax, 8 |
||
223 | add ecx, eax |
||
119 | mario79 | 224 | xor eax, eax |
225 | xor ebx, ebx |
||
226 | mov al, [edi+0] |
||
227 | mov bl, [esi+0] |
||
33 | mario79 | 228 | mul ebx |
229 | shr eax, 8 |
||
230 | add ecx, eax |
||
231 | shl ecx, 8 |
||
232 | ; byte 1 |
||
233 | mov eax, 0xff |
||
234 | sub al, [esi+1] |
||
235 | mov ebx, [esp] |
||
236 | shr ebx, 8 |
||
237 | and ebx, 0xff |
||
238 | mul ebx |
||
239 | shr eax, 8 |
||
240 | add ecx, eax |
||
119 | mario79 | 241 | xor eax, eax |
242 | xor ebx, ebx |
||
243 | mov al, [edi+1] |
||
244 | mov bl, [esi+1] |
||
33 | mario79 | 245 | mul ebx |
246 | shr eax, 8 |
||
247 | add ecx, eax |
||
248 | shl ecx, 8 |
||
249 | ; byte 2 |
||
250 | mov eax, 0xff |
||
251 | sub al, [esi+2] |
||
252 | mov ebx, [esp] |
||
253 | and ebx, 0xff |
||
254 | mul ebx |
||
255 | shr eax, 8 |
||
256 | add ecx, eax |
||
119 | mario79 | 257 | xor eax, eax |
258 | xor ebx, ebx |
||
259 | mov al, [edi+2] |
||
260 | mov bl, [esi+2] |
||
33 | mario79 | 261 | mul ebx |
262 | shr eax, 8 |
||
263 | add ecx, eax |
||
264 | pop eax |
||
265 | pop edx |
||
266 | pop ebx |
||
267 | pop eax |
||
268 | ret |
||
269 | |||
270 | |||
271 | __sys_disable_mouse: |
||
381 | serge | 272 | cmp dword [MOUSE_VISIBLE],dword 0 |
36 | mario79 | 273 | je @f |
274 | ret |
||
214 | serge | 275 | @@: |
33 | mario79 | 276 | pushad |
379 | serge | 277 | cmp [CURRENT_TASK],dword 1 |
33 | mario79 | 278 | je disable_m |
379 | serge | 279 | mov edx,[CURRENT_TASK] |
33 | mario79 | 280 | shl edx,5 |
281 | add edx,window_data |
||
381 | serge | 282 | movzx eax, word [MOUSE_X] |
283 | movzx ebx, word [MOUSE_Y] |
||
284 | mov ecx,[ScreenWidth] |
||
33 | mario79 | 285 | inc ecx |
286 | imul ecx,ebx |
||
287 | add ecx,eax |
||
288 | add ecx, display_data |
||
379 | serge | 289 | mov eax, [CURRENT_TASK] |
33 | mario79 | 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 |
||
381 | serge | 296 | mov ebx,[ScreenWidth] |
33 | mario79 | 297 | inc ebx |
298 | imul ebx,10 |
||
299 | add ecx,ebx |
||
300 | movzx ebx, byte [ecx] |
||
301 | cmp eax,ebx |
||
302 | je yes_mouse_disable |
||
303 | movzx ebx, byte [ecx+16] |
||
304 | cmp eax,ebx |
||
305 | je yes_mouse_disable |
||
306 | jmp no_mouse_disable |
||
119 | mario79 | 307 | yes_mouse_disable: |
379 | serge | 308 | mov edx,[CURRENT_TASK] |
33 | mario79 | 309 | shl edx,5 |
310 | add edx,window_data |
||
381 | serge | 311 | movzx eax, word [MOUSE_X] |
312 | movzx ebx, word [MOUSE_Y] |
||
33 | mario79 | 313 | mov ecx,[edx+0] ; mouse inside the area ? |
314 | add eax,14 |
||
315 | cmp eax,ecx |
||
316 | jb no_mouse_disable |
||
317 | sub eax,14 |
||
318 | add ecx,[edx+8] |
||
319 | cmp eax,ecx |
||
320 | jg no_mouse_disable |
||
321 | mov ecx,[edx+4] |
||
322 | add ebx,20 |
||
323 | cmp ebx,ecx |
||
324 | jb no_mouse_disable |
||
325 | sub ebx,20 |
||
326 | add ecx,[edx+12] |
||
327 | cmp ebx,ecx |
||
328 | jg no_mouse_disable |
||
119 | mario79 | 329 | disable_m: |
381 | serge | 330 | cmp dword [MOUSE_VISIBLE],dword 0 |
119 | mario79 | 331 | jne no_mouse_disable |
389 | serge | 332 | pushf |
36 | mario79 | 333 | cli |
119 | mario79 | 334 | call draw_mouse_under |
389 | serge | 335 | popf |
381 | serge | 336 | mov [MOUSE_VISIBLE],dword 1 |
119 | mario79 | 337 | no_mouse_disable: |
33 | mario79 | 338 | popad |
339 | ret |
||
340 | |||
341 | __sys_draw_pointer: |
||
342 | cmp [mouse_pause],0 |
||
343 | je @f |
||
36 | mario79 | 344 | ret |
119 | mario79 | 345 | @@: |
36 | mario79 | 346 | push eax |
347 | mov eax,[timer_ticks] |
||
348 | sub eax,[MouseTickCounter] |
||
349 | cmp eax,1 |
||
350 | ja @f |
||
351 | pop eax |
||
352 | ret |
||
119 | mario79 | 353 | @@: |
36 | mario79 | 354 | mov eax,[timer_ticks] |
355 | mov [MouseTickCounter],eax |
||
356 | pop eax |
||
357 | pushad |
||
381 | serge | 358 | cmp dword [MOUSE_VISIBLE],dword 0 ; mouse visible ? |
33 | mario79 | 359 | je chms00 |
381 | serge | 360 | mov [MOUSE_VISIBLE], dword 0 |
361 | movzx ebx,word [MOUSE_Y] |
||
362 | movzx eax,word [MOUSE_X] |
||
389 | serge | 363 | pushfd |
36 | mario79 | 364 | cli |
33 | mario79 | 365 | call save_draw_mouse |
389 | serge | 366 | popfd |
119 | mario79 | 367 | nodmu2: |
33 | mario79 | 368 | popad |
369 | ret |
||
119 | mario79 | 370 | chms00: |
381 | serge | 371 | movzx ecx,word [X_UNDER] |
372 | movzx edx,word [Y_UNDER] |
||
373 | movzx ebx,word [MOUSE_Y] |
||
374 | movzx eax,word [MOUSE_X] |
||
33 | mario79 | 375 | cmp eax,ecx |
376 | jne redrawmouse |
||
377 | cmp ebx,edx |
||
378 | jne redrawmouse |
||
379 | jmp nodmp |
||
119 | mario79 | 380 | redrawmouse: |
389 | serge | 381 | pushfd |
36 | mario79 | 382 | cli |
33 | mario79 | 383 | call draw_mouse_under |
384 | call save_draw_mouse |
||
389 | serge | 385 | popfd |
119 | mario79 | 386 | nodmp: |
33 | mario79 | 387 | popad |
388 | ret |
||
119 | mario79 | 389 |