Rev 2288 | Rev 2446 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2288 | Rev 2430 | ||
---|---|---|---|
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: 2288 $ |
8 | $Revision: 2430 $ |
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 | ;-------------------------------------- |
|
- | 26 | align 4 |
|
25 | mousecount dd 0x0 |
27 | mousecount dd 0x0 |
26 | mousedata dd 0x0 |
28 | mousedata dd 0x0 |
- | 29 | Y_UNDER_subtraction_CUR_hot_y: |
|
- | 30 | dd 0 |
|
- | 31 | X_UNDER_subtraction_CUR_hot_x: |
|
- | 32 | dd 0 |
|
- | 33 | Y_UNDER_sub_CUR_hot_y_add_curh: |
|
- | 34 | dd 0 |
|
- | 35 | X_UNDER_sub_CUR_hot_x_add_curh: |
|
- | 36 | dd 0 |
|
27 | endg |
37 | endg |
28 | 38 | ||
29 | iglobal |
39 | iglobal |
- | 40 | ;-------------------------------------- |
|
- | 41 | align 4 |
|
30 | mouse_delay dd 10 |
42 | mouse_delay dd 10 |
31 | mouse_speed_factor: |
43 | mouse_speed_factor: |
32 | dd 3 |
44 | dd 3 |
33 | mouse_timer_ticks dd 0 |
45 | mouse_timer_ticks dd 0 |
34 | endg |
46 | endg |
35 | - | ||
36 | ;include 'm_com.inc' |
- | |
37 | - | ||
38 | - | ||
39 | ;test_mario79: |
- | |
40 | ; push esi |
- | |
41 | ; push eax |
- | |
42 | ; mov [write_error_to],process_test_m79+43 |
47 | ;----------------------------------------------------------------------------- |
43 | ; movzx eax,al ;[DevErrorCode] |
- | |
44 | ; call writehex |
- | |
45 | ; mov esi,process_test_m79 |
- | |
46 | ; call sys_msg_board_str |
- | |
47 | ; pop eax |
- | |
48 | ; pop esi |
- | |
49 | ; ret |
48 | align 4 |
50 | ;process_test_m79 db 'K : Process - test Mario79 error 00000000',13,10,0 |
- | |
51 | - | ||
52 | draw_mouse_under: |
49 | draw_mouse_under: |
53 | ; return old picture |
50 | ; return old picture |
54 | - | ||
55 | cmp [_display.restore_cursor], 0 |
51 | cmp [_display.restore_cursor], 0 |
56 | je @F |
52 | je @F |
57 | 53 | ||
58 | pushad |
54 | pushad |
59 | movzx eax, word [X_UNDER] |
55 | movzx eax, word [X_UNDER] |
60 | movzx ebx, word [Y_UNDER] |
56 | movzx ebx, word [Y_UNDER] |
61 | stdcall [_display.restore_cursor], eax, ebx |
57 | stdcall [_display.restore_cursor], eax, ebx |
62 | popad |
58 | popad |
63 | ret |
59 | ret |
- | 60 | ;-------------------------------------- |
|
- | 61 | align 4 |
|
64 | @@: |
62 | @@: |
65 | pushad |
63 | pushad |
66 | xor ecx, ecx |
64 | xor ecx, ecx |
67 | xor edx, edx |
65 | xor edx, edx |
- | 66 | ;-------------------------------------- |
|
68 | align 4 |
67 | align 4 |
69 | mres: |
68 | mres: |
70 | movzx eax, word [X_UNDER] |
69 | movzx eax, word [X_UNDER] |
71 | movzx ebx, word [Y_UNDER] |
70 | movzx ebx, word [Y_UNDER] |
72 | add eax, ecx |
71 | add eax, ecx |
73 | add ebx, edx |
72 | add ebx, edx |
74 | push ecx |
73 | push ecx |
75 | push edx |
74 | push edx |
76 | push eax |
75 | push eax |
77 | push ebx |
76 | push ebx |
78 | mov eax, edx |
77 | mov eax, edx |
79 | shl eax, 6 |
78 | shl eax, 6 |
80 | shl ecx, 2 |
79 | shl ecx, 2 |
81 | add eax, ecx |
80 | add eax, ecx |
82 | add eax, mouseunder |
81 | add eax, mouseunder |
83 | mov ecx, [eax] |
82 | mov ecx, [eax] |
84 | pop ebx |
83 | pop ebx |
85 | pop eax |
84 | pop eax |
86 | mov edi, 1;force |
85 | mov edi, 1 ; force |
- | 86 | or ecx, 0x04000000 ; don't save to mouseunder area |
|
87 | call [putpixel] |
87 | call [putpixel] |
88 | pop edx |
88 | pop edx |
89 | pop ecx |
89 | pop ecx |
90 | inc ecx |
90 | inc ecx |
91 | cmp ecx, 16 |
91 | cmp ecx, 16 |
92 | jnz mres |
92 | jnz mres |
93 | xor ecx, ecx |
93 | xor ecx, ecx |
94 | inc edx |
94 | inc edx |
95 | cmp edx, 24 |
95 | cmp edx, 24 |
96 | jnz mres |
96 | jnz mres |
97 | popad |
97 | popad |
98 | ret |
98 | ret |
- | 99 | ;----------------------------------------------------------------------------- |
|
99 | 100 | align 4 |
|
100 | save_draw_mouse: |
101 | save_draw_mouse: |
101 | - | ||
102 | cmp [_display.move_cursor], 0 |
102 | cmp [_display.move_cursor], 0 |
103 | je .no_hw_cursor |
103 | je .no_hw_cursor |
104 | pushad |
104 | pushad |
105 | 105 | ||
106 | mov [X_UNDER], ax |
106 | mov [X_UNDER], ax |
107 | mov [Y_UNDER], bx |
107 | mov [Y_UNDER], bx |
108 | movzx eax, word [MOUSE_Y] |
108 | movzx eax, word [MOUSE_Y] |
109 | movzx ebx, word [MOUSE_X] |
109 | movzx ebx, word [MOUSE_X] |
110 | push eax |
110 | push eax |
111 | push ebx |
111 | push ebx |
112 | 112 | ||
113 | mov ecx, [Screen_Max_X] |
113 | mov ecx, [Screen_Max_X] |
114 | inc ecx |
114 | inc ecx |
115 | mul ecx |
115 | mul ecx |
116 | add eax, [_WinMapAddress] |
116 | add eax, [_WinMapAddress] |
117 | movzx edx, byte [ebx+eax] |
117 | movzx edx, byte [ebx+eax] |
118 | shl edx, 8 |
118 | shl edx, 8 |
119 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
119 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
120 | 120 | ||
121 | cmp esi, [current_cursor] |
121 | cmp esi, [current_cursor] |
122 | je .draw |
122 | je .draw |
123 | 123 | ||
124 | push esi |
124 | push esi |
125 | call [_display.select_cursor] |
125 | call [_display.select_cursor] |
126 | mov [current_cursor], esi |
126 | mov [current_cursor], esi |
- | 127 | ;-------------------------------------- |
|
- | 128 | align 4 |
|
127 | .draw: |
129 | .draw: |
128 | stdcall [_display.move_cursor], esi |
130 | stdcall [_display.move_cursor], esi |
129 | popad |
131 | popad |
130 | ret |
132 | ret |
- | 133 | ;-------------------------------------- |
|
- | 134 | ;align 4 |
|
131 | .fail: |
135 | ;.fail: |
132 | mov ecx, [def_cursor] |
136 | ; mov ecx, [def_cursor] |
133 | mov [edx+SLOT_BASE+APPDATA.cursor], ecx |
137 | ; mov [edx+SLOT_BASE+APPDATA.cursor], ecx |
134 | stdcall [_display.move_cursor], ecx ; stdcall: [esp]=ebx,eax |
138 | ; stdcall [_display.move_cursor], ecx ; stdcall: [esp]=ebx,eax |
135 | popad |
139 | ; popad |
136 | ret |
140 | ; ret |
- | 141 | ;-------------------------------------- |
|
137 | 142 | align 4 |
|
138 | .no_hw_cursor: |
143 | .no_hw_cursor: |
139 | pushad |
144 | pushad |
140 | ; save & draw |
145 | ; save & draw |
141 | mov [X_UNDER], ax |
146 | mov [X_UNDER], ax |
142 | mov [Y_UNDER], bx |
147 | mov [Y_UNDER], bx |
143 | push eax |
148 | push eax |
144 | push ebx |
149 | push ebx |
145 | mov ecx, 0 |
150 | mov ecx, 0 |
146 | mov edx, 0 |
151 | mov edx, 0 |
- | 152 | ;-------------------------------------- |
|
147 | align 4 |
153 | align 4 |
148 | drm: |
154 | drm: |
149 | push eax |
155 | push eax |
150 | push ebx |
156 | push ebx |
151 | push ecx |
157 | push ecx |
152 | push edx |
158 | push edx |
153 | ; helloworld |
159 | ; helloworld |
154 | push ecx |
160 | push ecx |
155 | add eax, ecx; save picture under mouse |
161 | add eax, ecx; save picture under mouse |
156 | add ebx, edx |
162 | add ebx, edx |
157 | push ecx |
163 | push ecx |
- | 164 | or ecx, 0x04000000 ; don't load to mouseunder area |
|
158 | call getpixel |
165 | call getpixel |
159 | mov [COLOR_TEMP], ecx |
166 | mov [COLOR_TEMP], ecx |
160 | pop ecx |
167 | pop ecx |
161 | mov eax, edx |
168 | mov eax, edx |
162 | shl eax, 6 |
169 | shl eax, 6 |
163 | shl ecx, 2 |
170 | shl ecx, 2 |
164 | add eax, ecx |
171 | add eax, ecx |
165 | add eax, mouseunder |
172 | add eax, mouseunder |
166 | mov ebx, [COLOR_TEMP] |
173 | mov ebx, [COLOR_TEMP] |
- | 174 | and ebx, 0xffffff |
|
167 | mov [eax], ebx |
175 | mov [eax], ebx |
168 | pop ecx |
176 | pop ecx |
169 | mov edi, edx ; y cycle |
177 | mov edi, edx ; y cycle |
170 | shl edi, 4 ; *16 bytes per row |
178 | shl edi, 4 ; *16 bytes per row |
171 | add edi, ecx ; x cycle |
179 | add edi, ecx ; x cycle |
172 | mov esi, edi |
180 | mov esi, edi |
173 | add edi, esi |
181 | add edi, esi |
174 | add edi, esi ; *3 |
182 | add edi, esi ; *3 |
175 | add edi, [MOUSE_PICTURE] ; we have our str address |
183 | add edi, [MOUSE_PICTURE] ; we have our str address |
176 | mov esi, edi |
184 | mov esi, edi |
177 | add esi, 16*24*3 |
185 | add esi, 16*24*3 |
178 | push ecx |
186 | push ecx |
179 | mov ecx, [COLOR_TEMP] |
187 | mov ecx, [COLOR_TEMP] |
180 | call combine_colors |
188 | call combine_colors |
- | 189 | and ecx, 0xffffff |
|
181 | mov [MOUSE_COLOR_MEM], ecx |
190 | mov [MOUSE_COLOR_MEM], ecx |
182 | pop ecx |
191 | pop ecx |
183 | pop edx |
192 | pop edx |
184 | pop ecx |
193 | pop ecx |
185 | pop ebx |
194 | pop ebx |
186 | pop eax |
195 | pop eax |
187 | add eax, ecx ; we have x coord+cycle |
196 | add eax, ecx ; we have x coord+cycle |
188 | add ebx, edx ; and y coord+cycle |
197 | add ebx, edx ; and y coord+cycle |
189 | push ecx |
198 | push ecx |
190 | mov ecx, [MOUSE_COLOR_MEM] |
199 | mov ecx, [MOUSE_COLOR_MEM] |
191 | mov edi, 1 |
200 | mov edi, 1 ; force |
- | 201 | or ecx, 0x04000000 ; don't save to mouseunder area |
|
192 | call [putpixel] |
202 | call [putpixel] |
193 | pop ecx |
203 | pop ecx |
194 | mov ebx, [esp+0] ; pure y coord again |
204 | mov ebx, [esp+0] ; pure y coord again |
195 | mov eax, [esp+4] ; and x |
205 | mov eax, [esp+4] ; and x |
196 | inc ecx ; +1 cycle |
206 | inc ecx ; +1 cycle |
197 | cmp ecx, 16 ; if more than 16 |
207 | cmp ecx, 16 ; if more than 16 |
198 | jnz drm |
208 | jnz drm |
199 | xor ecx, ecx |
209 | xor ecx, ecx |
200 | inc edx |
210 | inc edx |
201 | cmp edx, 24 |
211 | cmp edx, 24 |
202 | jnz drm |
212 | jnz drm |
203 | add esp, 8 |
213 | add esp, 8 |
204 | popad |
214 | popad |
205 | ret |
215 | ret |
206 | - | ||
- | 216 | ;----------------------------------------------------------------------------- |
|
207 | 217 | align 4 |
|
208 | combine_colors: |
218 | combine_colors: |
209 | ; in |
219 | ; in |
210 | ; ecx - color ( 00 RR GG BB ) |
220 | ; ecx - color ( 00 RR GG BB ) |
211 | ; edi - ref to new color byte |
221 | ; edi - ref to new color byte |
212 | ; esi - ref to alpha byte |
222 | ; esi - ref to alpha byte |
213 | ; |
223 | ; |
214 | ; out |
224 | ; out |
215 | ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) ) |
225 | ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) ) |
216 | push eax |
226 | push eax |
217 | push ebx |
227 | push ebx |
218 | push edx |
228 | push edx |
219 | push ecx |
229 | push ecx |
220 | xor ecx, ecx |
230 | xor ecx, ecx |
221 | ; byte 2 |
231 | ; byte 2 |
222 | mov eax, 0xff |
232 | mov eax, 0xff |
223 | sub al, [esi+0] |
233 | sub al, [esi+0] |
224 | mov ebx, [esp] |
234 | mov ebx, [esp] |
225 | shr ebx, 16 |
235 | shr ebx, 16 |
226 | and ebx, 0xff |
236 | and ebx, 0xff |
227 | mul ebx |
237 | mul ebx |
228 | shr eax, 8 |
238 | shr eax, 8 |
229 | add ecx, eax |
239 | add ecx, eax |
230 | xor eax, eax |
240 | xor eax, eax |
231 | xor ebx, ebx |
241 | xor ebx, ebx |
232 | mov al, [edi+0] |
242 | mov al, [edi+0] |
233 | mov bl, [esi+0] |
243 | mov bl, [esi+0] |
234 | mul ebx |
244 | mul ebx |
235 | shr eax, 8 |
245 | shr eax, 8 |
236 | add ecx, eax |
246 | add ecx, eax |
237 | shl ecx, 8 |
247 | shl ecx, 8 |
238 | ; byte 1 |
248 | ; byte 1 |
239 | mov eax, 0xff |
249 | mov eax, 0xff |
240 | sub al, [esi+1] |
250 | sub al, [esi+1] |
241 | mov ebx, [esp] |
251 | mov ebx, [esp] |
242 | shr ebx, 8 |
252 | shr ebx, 8 |
243 | and ebx, 0xff |
253 | and ebx, 0xff |
244 | mul ebx |
254 | mul ebx |
245 | shr eax, 8 |
255 | shr eax, 8 |
246 | add ecx, eax |
256 | add ecx, eax |
247 | xor eax, eax |
257 | xor eax, eax |
248 | xor ebx, ebx |
258 | xor ebx, ebx |
249 | mov al, [edi+1] |
259 | mov al, [edi+1] |
250 | mov bl, [esi+1] |
260 | mov bl, [esi+1] |
251 | mul ebx |
261 | mul ebx |
252 | shr eax, 8 |
262 | shr eax, 8 |
253 | add ecx, eax |
263 | add ecx, eax |
254 | shl ecx, 8 |
264 | shl ecx, 8 |
255 | ; byte 2 |
265 | ; byte 2 |
256 | mov eax, 0xff |
266 | mov eax, 0xff |
257 | sub al, [esi+2] |
267 | sub al, [esi+2] |
258 | mov ebx, [esp] |
268 | mov ebx, [esp] |
259 | and ebx, 0xff |
269 | and ebx, 0xff |
260 | mul ebx |
270 | mul ebx |
261 | shr eax, 8 |
271 | shr eax, 8 |
262 | add ecx, eax |
272 | add ecx, eax |
263 | xor eax, eax |
273 | xor eax, eax |
264 | xor ebx, ebx |
274 | xor ebx, ebx |
265 | mov al, [edi+2] |
275 | mov al, [edi+2] |
266 | mov bl, [esi+2] |
276 | mov bl, [esi+2] |
267 | mul ebx |
277 | mul ebx |
268 | shr eax, 8 |
278 | shr eax, 8 |
269 | add ecx, eax |
279 | add ecx, eax |
270 | pop eax |
280 | pop eax |
271 | pop edx |
281 | pop edx |
272 | pop ebx |
282 | pop ebx |
273 | pop eax |
283 | pop eax |
274 | ret |
284 | ret |
- | 285 | ;----------------------------------------------------------------------------- |
|
- | 286 | align 4 |
|
- | 287 | check_mouse_area_for_getpixel: |
|
- | 288 | ; in: |
|
- | 289 | ; eax = x |
|
- | 290 | ; ebx = y |
|
- | 291 | ; out: |
|
- | 292 | ; ecx = new color |
|
- | 293 | push eax ebx |
|
- | 294 | ; check for Y |
|
- | 295 | xor ecx, ecx |
|
- | 296 | mov cx, [Y_UNDER] ; [MOUSE_Y] |
|
275 | - | ||
276 | - | ||
277 | __sys_disable_mouse: |
- | |
278 | cmp dword [MOUSE_VISIBLE], dword 0 |
- | |
279 | je @f |
- | |
280 | ret |
- | |
281 | @@: |
- | |
282 | pushad |
- | |
283 | cmp [CURRENT_TASK], dword 1 |
- | |
284 | je disable_m |
- | |
285 | mov edx, [CURRENT_TASK] |
- | |
286 | shl edx, 5 |
- | |
287 | add edx, window_data |
- | |
288 | movzx eax, word [MOUSE_X] |
- | |
289 | movzx ebx, word [MOUSE_Y] |
- | |
290 | mov ecx, [Screen_Max_X] |
- | |
291 | inc ecx |
- | |
292 | imul ecx, ebx |
- | |
293 | add ecx, eax |
- | |
294 | add ecx, [_WinMapAddress] |
- | |
295 | mov eax, [CURRENT_TASK] |
- | |
296 | cmp al, [ecx] |
- | |
297 | je yes_mouse_disable |
- | |
298 | cmp al, [ecx+16] |
- | |
299 | je yes_mouse_disable |
- | |
300 | add ebx, 10 |
- | |
301 | cmp ebx, [Screen_Max_Y] |
- | |
302 | jae no_mouse_disable |
- | |
303 | mov ebx, [Screen_Max_X] |
- | |
304 | inc ebx |
- | |
305 | imul ebx, 10 |
- | |
306 | add ecx, ebx |
- | |
307 | cmp al, [ecx] |
- | |
308 | je yes_mouse_disable |
- | |
309 | cmp al, [ecx+16] |
- | |
310 | je yes_mouse_disable |
- | |
311 | jmp no_mouse_disable |
- | |
312 | yes_mouse_disable: |
- | |
313 | mov edx, [CURRENT_TASK] |
- | |
314 | shl edx, 5 |
- | |
315 | add edx, window_data |
- | |
316 | movzx eax, word [MOUSE_X] |
- | |
317 | movzx ebx, word [MOUSE_Y] |
- | |
318 | mov ecx, [edx+0]; mouse inside the area ? |
- | |
319 | add eax, 10 |
- | |
320 | cmp eax, ecx |
- | |
321 | jb no_mouse_disable |
- | |
322 | sub eax, 10 |
- | |
323 | add ecx, [edx+8] |
- | |
324 | cmp eax, ecx |
- | |
325 | jg no_mouse_disable |
- | |
326 | mov ecx, [edx+4] |
- | |
327 | add ebx, 14 |
297 | |
328 | cmp ebx, ecx |
298 | cmp ebx, ecx |
329 | jb no_mouse_disable |
- | |
330 | sub ebx, 14 |
299 | jb .no_mouse_area |
331 | add ecx, [edx+12] |
300 | add ecx, 23 ; mouse cursor Y size |
332 | cmp ebx, ecx |
301 | cmp ebx, ecx |
333 | jg no_mouse_disable |
302 | ja .no_mouse_area |
- | 303 | ; offset Y |
|
- | 304 | sub bx, [Y_UNDER] ;[MOUSE_Y] |
|
- | 305 | ;-------------------------------------- |
|
- | 306 | ; check for X |
|
334 | disable_m: |
307 | xor ecx, ecx |
- | 308 | mov cx, [X_UNDER] ;[MOUSE_X] |
|
335 | cmp dword [MOUSE_VISIBLE], dword 0 |
309 | cmp eax, ecx |
- | 310 | jb .no_mouse_area |
|
336 | jne no_mouse_disable |
311 | add ecx, 15 ; mouse cursor X size |
- | 312 | cmp eax, ecx |
|
337 | pushf |
313 | ja .no_mouse_area |
- | 314 | ; offset X |
|
- | 315 | sub ax, [X_UNDER] ;[MOUSE_X] |
|
- | 316 | ;-------------------------------------- |
|
- | 317 | ; eax = offset x |
|
- | 318 | ; ebx = offset y |
|
- | 319 | shl ebx, 6 ;y |
|
- | 320 | shl eax, 2 ;x |
|
338 | cli |
321 | add eax, ebx |
339 | call draw_mouse_under |
322 | add eax, mouseunder |
340 | popf |
323 | mov ecx, [eax] |
341 | mov [MOUSE_VISIBLE], dword 1 |
324 | and ecx, 0xffffff |
342 | no_mouse_disable: |
325 | or ecx, 0xff000000 |
343 | popad |
326 | pop ebx eax |
- | 327 | ret |
|
344 | ret |
328 | ;-------------------------------------- |
345 | 329 | align 4 |
|
346 | __sys_draw_pointer: |
330 | .no_mouse_area: |
347 | cmp [mouse_pause], 0 |
331 | xor ecx, ecx |
348 | je @f |
332 | pop ebx eax |
- | 333 | ret |
|
- | 334 | ;----------------------------------------------------------------------------- |
|
- | 335 | align 4 |
|
349 | ret |
336 | check_mouse_area_for_putpixel: |
- | 337 | ; in: |
|
- | 338 | ; ecx = x shl 16 + y |
|
- | 339 | ; eax = color |
|
- | 340 | ; out: |
|
350 | @@: |
341 | ; eax = new color |
- | 342 | push eax |
|
- | 343 | ; check for Y |
|
- | 344 | mov ax, [Y_UNDER] ; [MOUSE_Y] |
|
- | 345 | cmp cx, ax |
|
- | 346 | jb .no_mouse_area |
|
- | 347 | add ax, 23 ; mouse cursor Y size |
|
- | 348 | cmp cx, ax |
|
- | 349 | ja .no_mouse_area |
|
- | 350 | ; offset Y |
|
351 | push eax |
351 | sub cx, [Y_UNDER] ;[MOUSE_Y] |
- | 352 | mov ax, cx |
|
- | 353 | shl eax, 16 |
|
- | 354 | ;-------------------------------------- |
|
- | 355 | ; check for X |
|
- | 356 | mov ax, [X_UNDER] ;[MOUSE_X] |
|
- | 357 | shr ecx, 16 |
|
- | 358 | cmp cx, ax |
|
352 | mov eax, [timer_ticks] |
359 | jb .no_mouse_area |
353 | sub eax, [MouseTickCounter] |
360 | add ax, 15 ; mouse cursor X size |
- | 361 | cmp cx, ax |
|
- | 362 | ja .no_mouse_area |
|
- | 363 | ; offset X |
|
354 | cmp eax, 1 |
364 | sub cx, [X_UNDER] ;[MOUSE_X] |
- | 365 | mov ax, cx |
|
- | 366 | ;-------------------------------------- |
|
- | 367 | ; eax = (offset y) shl 16 + (offset x) |
|
355 | ja @f |
368 | |
- | 369 | pop ecx |
|
- | 370 | ||
- | 371 | push eax ebx |
|
- | 372 | ||
- | 373 | mov ebx, eax |
|
- | 374 | shr ebx, 16 ;y |
|
- | 375 | and eax, 0xffff ;x |
|
- | 376 | ||
- | 377 | shl ebx, 6 |
|
- | 378 | shl eax, 2 |
|
- | 379 | add eax, ebx |
|
- | 380 | add eax, mouseunder |
|
- | 381 | and ecx, 0xFFFFFF |
|
- | 382 | mov [eax], ecx |
|
- | 383 | ||
- | 384 | pop ebx eax |
|
- | 385 | ||
- | 386 | push esi edi |
|
- | 387 | rol eax, 16 |
|
- | 388 | movzx edi, ax ; y cycle |
|
- | 389 | shl edi, 4 ; *16 bytes per row |
|
- | 390 | shr eax, 16 |
|
- | 391 | add edi, eax ; x cycle |
|
- | 392 | lea edi, [edi*3] |
|
- | 393 | add edi, [MOUSE_PICTURE] ; we have our str address |
|
- | 394 | mov esi, edi |
|
- | 395 | add esi, 16*24*3 |
|
- | 396 | call combine_colors |
|
- | 397 | pop edi esi |
|
- | 398 | ;-------------------------------------- |
|
- | 399 | align 4 |
|
- | 400 | .end: |
|
356 | pop eax |
401 | mov eax, ecx |
- | 402 | ret |
|
357 | ret |
403 | ;-------------------------------------- |
358 | @@: |
- | |
359 | mov eax, [timer_ticks] |
404 | align 4 |
360 | mov [MouseTickCounter], eax |
405 | .no_mouse_area: |
361 | pop eax |
- | |
362 | pushad |
- | |
363 | cmp dword [MOUSE_VISIBLE], dword 0; mouse visible ? |
- | |
364 | je chms00 |
- | |
365 | mov [MOUSE_VISIBLE], dword 0 |
- | |
366 | movzx ebx, word [MOUSE_Y] |
- | |
367 | movzx eax, word [MOUSE_X] |
- | |
368 | pushfd |
- | |
369 | cli |
- | |
370 | call save_draw_mouse |
- | |
371 | popfd |
- | |
372 | nodmu2: |
- | |
373 | popad |
406 | pop eax |
- | 407 | ret |
|
374 | ret |
408 | ;----------------------------------------------------------------------------- |
- | 409 | align 4 |
|
- | 410 | __sys_draw_pointer: |
|
375 | chms00: |
411 | pushad |
376 | movzx ecx, word [X_UNDER] |
412 | movzx ecx, word [X_UNDER] |
377 | movzx edx, word [Y_UNDER] |
413 | movzx edx, word [Y_UNDER] |
378 | movzx ebx, word [MOUSE_Y] |
414 | movzx ebx, word [MOUSE_Y] |
379 | movzx eax, word [MOUSE_X] |
415 | movzx eax, word [MOUSE_X] |
380 | cmp eax, ecx |
416 | cmp eax, ecx |
381 | jne redrawmouse |
417 | jne redrawmouse |
382 | cmp ebx, edx |
418 | cmp ebx, edx |
383 | jne redrawmouse |
419 | je nodmp |
384 | jmp nodmp |
420 | ;-------------------------------------- |
- | 421 | align 4 |
|
385 | redrawmouse: |
422 | redrawmouse: |
386 | pushfd |
423 | pushfd |
387 | cli |
424 | cli |
388 | call draw_mouse_under |
425 | call draw_mouse_under |
389 | call save_draw_mouse |
426 | call save_draw_mouse |
- | 427 | ||
- | 428 | mov eax, [_display.select_cursor] |
|
- | 429 | test eax, eax |
|
- | 430 | jz @f |
|
- | 431 | ||
- | 432 | xor eax, eax |
|
- | 433 | mov esi, [current_cursor] |
|
- | 434 | ||
- | 435 | mov ax, [Y_UNDER] |
|
- | 436 | sub eax, [esi+CURSOR.hot_y] |
|
- | 437 | mov [Y_UNDER_subtraction_CUR_hot_y], eax |
|
- | 438 | add eax, [cur.h] |
|
- | 439 | mov [Y_UNDER_sub_CUR_hot_y_add_curh], eax |
|
- | 440 | ||
- | 441 | mov ax, [X_UNDER] |
|
- | 442 | sub eax, [esi+CURSOR.hot_x] |
|
- | 443 | mov [X_UNDER_subtraction_CUR_hot_x], eax |
|
- | 444 | add eax, [cur.w] |
|
- | 445 | mov [X_UNDER_sub_CUR_hot_x_add_curh], eax |
|
- | 446 | ;-------------------------------------- |
|
- | 447 | align 4 |
|
- | 448 | @@: |
|
390 | popfd |
449 | popfd |
- | 450 | ;-------------------------------------- |
|
- | 451 | align 4 |
|
391 | nodmp: |
452 | nodmp: |
392 | popad |
453 | popad |
393 | ret |
454 | ret |
- | 455 | ;----------------------------------------------------------------------------- |
|
394 | 456 | align 4 |
|
395 | proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword |
457 | proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword |
396 | 458 | ||
397 | mov eax, [BtnState] |
459 | mov eax, [BtnState] |
398 | mov [BTN_DOWN], eax |
460 | mov [BTN_DOWN], eax |
399 | 461 | ||
400 | mov eax, [XMoving] |
462 | mov eax, [XMoving] |
401 | call mouse_acceleration |
463 | call mouse_acceleration |
402 | add ax, [MOUSE_X];[XCoordinate] |
464 | add ax, [MOUSE_X];[XCoordinate] |
403 | cmp ax, 0 |
465 | cmp ax, 0 |
404 | jge @@M1 |
466 | jge @@M1 |
405 | mov eax, 0 |
467 | mov eax, 0 |
406 | jmp @@M2 |
468 | jmp @@M2 |
- | 469 | ;-------------------------------------- |
|
- | 470 | align 4 |
|
407 | @@M1: |
471 | @@M1: |
408 | cmp ax, [Screen_Max_X];ScreenLength |
472 | cmp ax, [Screen_Max_X];ScreenLength |
409 | jl @@M2 |
473 | jl @@M2 |
410 | mov ax, [Screen_Max_X];ScreenLength-1 |
474 | mov ax, [Screen_Max_X];ScreenLength-1 |
- | 475 | ;-------------------------------------- |
|
411 | 476 | align 4 |
|
412 | @@M2: |
477 | @@M2: |
413 | mov [MOUSE_X], ax;[XCoordinate] |
478 | mov [MOUSE_X], ax;[XCoordinate] |
414 | 479 | ||
415 | mov eax, [YMoving] |
480 | mov eax, [YMoving] |
416 | neg eax |
481 | neg eax |
417 | call mouse_acceleration |
482 | call mouse_acceleration |
418 | 483 | ||
419 | add ax, [MOUSE_Y];[YCoordinate] |
484 | add ax, [MOUSE_Y];[YCoordinate] |
420 | cmp ax, 0 |
485 | cmp ax, 0 |
421 | jge @@M3 |
486 | jge @@M3 |
422 | mov ax, 0 |
487 | mov ax, 0 |
423 | jmp @@M4 |
488 | jmp @@M4 |
- | 489 | ;-------------------------------------- |
|
- | 490 | align 4 |
|
424 | @@M3: |
491 | @@M3: |
425 | cmp ax, [Screen_Max_Y];ScreenHeigth |
492 | cmp ax, [Screen_Max_Y];ScreenHeigth |
426 | jl @@M4 |
493 | jl @@M4 |
427 | mov ax, [Screen_Max_Y];ScreenHeigth-1 |
494 | mov ax, [Screen_Max_Y];ScreenHeigth-1 |
- | 495 | ;-------------------------------------- |
|
428 | 496 | align 4 |
|
429 | @@M4: |
497 | @@M4: |
430 | mov [MOUSE_Y], ax;[YCoordinate] |
498 | mov [MOUSE_Y], ax;[YCoordinate] |
431 | 499 | ||
432 | mov eax, [VScroll] |
500 | mov eax, [VScroll] |
433 | add [MOUSE_SCROLL_V], ax |
501 | add [MOUSE_SCROLL_V], ax |
434 | 502 | ||
435 | mov eax, [HScroll] |
503 | mov eax, [HScroll] |
436 | add [MOUSE_SCROLL_H], ax |
504 | add [MOUSE_SCROLL_H], ax |
437 | 505 | ||
438 | mov [mouse_active], 1 |
506 | mov [mouse_active], 1 |
439 | mov eax, [timer_ticks] |
507 | mov eax, [timer_ticks] |
440 | mov [mouse_timer_ticks], eax |
508 | mov [mouse_timer_ticks], eax |
441 | ret |
509 | ret |
442 | endp |
510 | endp |
- | 511 | ;----------------------------------------------------------------------------- |
|
443 | 512 | align 4 |
|
444 | mouse_acceleration: |
513 | mouse_acceleration: |
445 | push eax |
514 | push eax |
446 | mov eax, [timer_ticks] |
515 | mov eax, [timer_ticks] |
447 | sub eax, [mouse_timer_ticks] |
516 | sub eax, [mouse_timer_ticks] |
448 | cmp eax, [mouse_delay] |
517 | cmp eax, [mouse_delay] |
449 | pop eax |
518 | pop eax |
450 | ja @f |
519 | ja @f |
451 | ;push edx |
520 | ;push edx |
452 | imul eax, [mouse_speed_factor] |
521 | imul eax, [mouse_speed_factor] |
453 | ;pop edx |
522 | ;pop edx |
- | 523 | ;-------------------------------------- |
|
- | 524 | align 4 |
|
454 | @@: |
525 | @@: |
455 | ret |
526 | ret |
456 | - | ||
- | 527 | ;----------------------------------------------------------------------------- |