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