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