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