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