Rev 389 | Rev 431 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
425 | victor | 1 | $Revision: 425 $ |
33 | mario79 | 2 | ; check mouse |
3 | ; |
||
4 | ; |
||
5 | ; FB00 -> FB0F mouse memory 00 chunk count - FB0A-B x - FB0C-D y |
||
6 | ; FB10 -> FB17 mouse color mem |
||
7 | ; FB21 x move |
||
8 | ; FB22 y move |
||
9 | ; FB30 color temp |
||
10 | ; FB28 high bits temp |
||
11 | ; FB4A -> FB4D FB4A-B x-under - FB4C-D y-under |
||
12 | ; FC00 -> FCFE com1/ps2 buffer |
||
13 | ; FCFF com1/ps2 buffer count starting from FC00 |
||
14 | |||
15 | uglobal |
||
16 | mousecount dd 0x0 |
||
17 | mousedata dd 0x0 |
||
18 | endg |
||
19 | |||
120 | mario79 | 20 | mouse_delay dd 10 |
21 | mouse_speed_factor dw 3 |
||
22 | |||
33 | mario79 | 23 | include 'm_ps2.inc' |
24 | include 'm_com1.inc' |
||
25 | include 'm_com2.inc' |
||
26 | |||
27 | |||
28 | ;test_mario79: |
||
29 | ; push esi |
||
30 | ; push eax |
||
31 | ; mov [write_error_to],process_test_m79+43 |
||
32 | ; movzx eax,al ;[DevErrorCode] |
||
33 | ; call writehex |
||
34 | ; mov esi,process_test_m79 |
||
35 | ; call sys_msg_board_str |
||
36 | ; pop eax |
||
37 | ; pop esi |
||
38 | ; ret |
||
39 | ;process_test_m79 db 'K : Process - test Mario79 error 00000000',13,10,0 |
||
40 | |||
41 | draw_mouse_under: |
||
42 | ; return old picture |
||
214 | serge | 43 | |
44 | cmp [set_hw_cursor], 0 |
||
221 | serge | 45 | jz @F |
46 | pushad |
||
381 | serge | 47 | movzx eax,word [X_UNDER] |
48 | movzx ebx,word [Y_UNDER] |
||
221 | serge | 49 | stdcall [hw_restore], eax, ebx |
50 | popad |
||
214 | serge | 51 | ret |
52 | @@: |
||
33 | mario79 | 53 | pushad |
54 | xor ecx,ecx |
||
55 | xor edx,edx |
||
56 | align 4 |
||
119 | mario79 | 57 | mres: |
381 | serge | 58 | movzx eax,word [X_UNDER] |
59 | movzx ebx,word [Y_UNDER] |
||
33 | mario79 | 60 | add eax,ecx |
61 | add ebx,edx |
||
62 | push ecx |
||
63 | push edx |
||
64 | push eax |
||
65 | push ebx |
||
66 | mov eax,edx |
||
67 | shl eax,6 |
||
68 | shl ecx,2 |
||
69 | add eax,ecx |
||
70 | add eax,mouseunder |
||
71 | mov ecx,[eax] |
||
72 | pop ebx |
||
73 | pop eax |
||
74 | mov edi, 1 ;force |
||
75 | call [putpixel] |
||
76 | pop edx |
||
77 | pop ecx |
||
78 | inc ecx |
||
79 | cmp ecx, 16 |
||
80 | jnz mres |
||
81 | xor ecx, ecx |
||
82 | inc edx |
||
83 | cmp edx, 24 |
||
84 | jnz mres |
||
85 | popad |
||
86 | ret |
||
87 | |||
88 | save_draw_mouse: |
||
214 | serge | 89 | |
90 | cmp [set_hw_cursor], 0 |
||
91 | jz @F |
||
221 | serge | 92 | pushad |
93 | |||
381 | serge | 94 | mov [X_UNDER],ax |
95 | mov [Y_UNDER],bx |
||
96 | movzx eax,word [MOUSE_Y] |
||
97 | movzx ebx,word [MOUSE_X] |
||
221 | serge | 98 | push eax |
214 | serge | 99 | push ebx |
221 | serge | 100 | |
381 | serge | 101 | mov ecx, [ScreenWidth] |
221 | serge | 102 | inc ecx |
103 | mul ecx |
||
389 | serge | 104 | |
221 | serge | 105 | movzx edx, byte [display_data+ebx+eax] |
106 | shl edx, 8 |
||
380 | serge | 107 | mov ecx, [edx+SLOT_BASE+APPDATA.cursor] |
230 | serge | 108 | |
109 | cmp [ecx+CURSOR.magic], 'CURS' |
||
110 | jne .fail |
||
281 | serge | 111 | ; cmp [ecx+CURSOR.size], CURSOR_SIZE |
112 | ; jne .fail |
||
230 | serge | 113 | push ecx |
214 | serge | 114 | call [set_hw_cursor] |
221 | serge | 115 | popad |
214 | serge | 116 | ret |
230 | serge | 117 | .fail: |
118 | mov ecx, [def_cursor] |
||
380 | serge | 119 | mov [edx+SLOT_BASE+APPDATA.cursor], ecx |
230 | serge | 120 | push ecx |
121 | call [set_hw_cursor] |
||
122 | popad |
||
123 | ret |
||
124 | |||
214 | serge | 125 | @@: |
33 | mario79 | 126 | pushad |
127 | ; save & draw |
||
381 | serge | 128 | mov [X_UNDER],ax |
129 | mov [Y_UNDER],bx |
||
33 | mario79 | 130 | push eax |
131 | push ebx |
||
132 | mov ecx,0 |
||
133 | mov edx,0 |
||
134 | align 4 |
||
119 | mario79 | 135 | drm: |
33 | mario79 | 136 | push eax |
137 | push ebx |
||
138 | push ecx |
||
139 | push edx |
||
140 | ; helloworld |
||
141 | push ecx |
||
142 | add eax,ecx ; save picture under mouse |
||
143 | add ebx,edx |
||
144 | push ecx |
||
145 | call getpixel |
||
381 | serge | 146 | mov [COLOR_TEMP],ecx |
33 | mario79 | 147 | pop ecx |
148 | mov eax,edx |
||
149 | shl eax,6 |
||
150 | shl ecx,2 |
||
151 | add eax,ecx |
||
152 | add eax,mouseunder |
||
381 | serge | 153 | mov ebx,[COLOR_TEMP] |
33 | mario79 | 154 | mov [eax],ebx |
155 | pop ecx |
||
156 | mov edi,edx ; y cycle |
||
157 | shl edi,4 ; *16 bytes per row |
||
158 | add edi,ecx ; x cycle |
||
159 | mov esi, edi |
||
160 | add edi, esi |
||
161 | add edi, esi ; *3 |
||
381 | serge | 162 | add edi,[MOUSE_PICTURE] ; we have our str address |
33 | mario79 | 163 | mov esi, edi |
164 | add esi, 16*24*3 |
||
165 | push ecx |
||
381 | serge | 166 | mov ecx, [COLOR_TEMP] |
33 | mario79 | 167 | call combine_colors |
381 | serge | 168 | mov [MOUSE_COLOR_MEM], ecx |
33 | mario79 | 169 | pop ecx |
170 | pop edx |
||
171 | pop ecx |
||
172 | pop ebx |
||
173 | pop eax |
||
174 | add eax,ecx ; we have x coord+cycle |
||
175 | add ebx,edx ; and y coord+cycle |
||
176 | push ecx |
||
381 | serge | 177 | mov ecx, [MOUSE_COLOR_MEM] |
33 | mario79 | 178 | mov edi, 1 |
179 | call [putpixel] |
||
180 | pop ecx |
||
181 | mov ebx,[esp+0] ; pure y coord again |
||
182 | mov eax,[esp+4] ; and x |
||
183 | inc ecx ; +1 cycle |
||
184 | cmp ecx,16 ; if more than 16 |
||
185 | jnz drm |
||
186 | xor ecx, ecx |
||
187 | inc edx |
||
188 | cmp edx,24 |
||
189 | jnz drm |
||
119 | mario79 | 190 | add esp,8 |
33 | mario79 | 191 | popad |
192 | ret |
||
193 | |||
194 | |||
195 | combine_colors: |
||
196 | ; in |
||
197 | ; ecx - color ( 00 RR GG BB ) |
||
198 | ; edi - ref to new color byte |
||
199 | ; esi - ref to alpha byte |
||
200 | ; |
||
201 | ; out |
||
202 | ; ecx - new color ( roughly (ecx*[esi]>>8)+([edi]*[esi]>>8) ) |
||
203 | push eax |
||
204 | push ebx |
||
205 | push edx |
||
206 | push ecx |
||
207 | xor ecx, ecx |
||
208 | ; byte 2 |
||
209 | mov eax, 0xff |
||
210 | sub al, [esi+0] |
||
211 | mov ebx, [esp] |
||
212 | shr ebx, 16 |
||
213 | and ebx, 0xff |
||
214 | mul ebx |
||
215 | shr eax, 8 |
||
216 | add ecx, eax |
||
119 | mario79 | 217 | xor eax, eax |
218 | xor ebx, ebx |
||
219 | mov al, [edi+0] |
||
220 | mov bl, [esi+0] |
||
33 | mario79 | 221 | mul ebx |
222 | shr eax, 8 |
||
223 | add ecx, eax |
||
224 | shl ecx, 8 |
||
225 | ; byte 1 |
||
226 | mov eax, 0xff |
||
227 | sub al, [esi+1] |
||
228 | mov ebx, [esp] |
||
229 | shr ebx, 8 |
||
230 | and ebx, 0xff |
||
231 | mul ebx |
||
232 | shr eax, 8 |
||
233 | add ecx, eax |
||
119 | mario79 | 234 | xor eax, eax |
235 | xor ebx, ebx |
||
236 | mov al, [edi+1] |
||
237 | mov bl, [esi+1] |
||
33 | mario79 | 238 | mul ebx |
239 | shr eax, 8 |
||
240 | add ecx, eax |
||
241 | shl ecx, 8 |
||
242 | ; byte 2 |
||
243 | mov eax, 0xff |
||
244 | sub al, [esi+2] |
||
245 | mov ebx, [esp] |
||
246 | and ebx, 0xff |
||
247 | mul ebx |
||
248 | shr eax, 8 |
||
249 | add ecx, eax |
||
119 | mario79 | 250 | xor eax, eax |
251 | xor ebx, ebx |
||
252 | mov al, [edi+2] |
||
253 | mov bl, [esi+2] |
||
33 | mario79 | 254 | mul ebx |
255 | shr eax, 8 |
||
256 | add ecx, eax |
||
257 | pop eax |
||
258 | pop edx |
||
259 | pop ebx |
||
260 | pop eax |
||
261 | ret |
||
262 | |||
263 | |||
264 | __sys_disable_mouse: |
||
381 | serge | 265 | cmp dword [MOUSE_VISIBLE],dword 0 |
36 | mario79 | 266 | je @f |
267 | ret |
||
214 | serge | 268 | @@: |
33 | mario79 | 269 | pushad |
379 | serge | 270 | cmp [CURRENT_TASK],dword 1 |
33 | mario79 | 271 | je disable_m |
379 | serge | 272 | mov edx,[CURRENT_TASK] |
33 | mario79 | 273 | shl edx,5 |
274 | add edx,window_data |
||
381 | serge | 275 | movzx eax, word [MOUSE_X] |
276 | movzx ebx, word [MOUSE_Y] |
||
277 | mov ecx,[ScreenWidth] |
||
33 | mario79 | 278 | inc ecx |
279 | imul ecx,ebx |
||
280 | add ecx,eax |
||
281 | add ecx, display_data |
||
379 | serge | 282 | mov eax, [CURRENT_TASK] |
33 | mario79 | 283 | movzx ebx, byte [ecx] |
284 | cmp eax,ebx |
||
285 | je yes_mouse_disable |
||
286 | movzx ebx, byte [ecx+16] |
||
287 | cmp eax,ebx |
||
288 | je yes_mouse_disable |
||
381 | serge | 289 | mov ebx,[ScreenWidth] |
33 | mario79 | 290 | inc ebx |
291 | imul ebx,10 |
||
292 | add ecx,ebx |
||
293 | movzx ebx, byte [ecx] |
||
294 | cmp eax,ebx |
||
295 | je yes_mouse_disable |
||
296 | movzx ebx, byte [ecx+16] |
||
297 | cmp eax,ebx |
||
298 | je yes_mouse_disable |
||
299 | jmp no_mouse_disable |
||
119 | mario79 | 300 | yes_mouse_disable: |
379 | serge | 301 | mov edx,[CURRENT_TASK] |
33 | mario79 | 302 | shl edx,5 |
303 | add edx,window_data |
||
381 | serge | 304 | movzx eax, word [MOUSE_X] |
305 | movzx ebx, word [MOUSE_Y] |
||
33 | mario79 | 306 | mov ecx,[edx+0] ; mouse inside the area ? |
307 | add eax,14 |
||
308 | cmp eax,ecx |
||
309 | jb no_mouse_disable |
||
310 | sub eax,14 |
||
311 | add ecx,[edx+8] |
||
312 | cmp eax,ecx |
||
313 | jg no_mouse_disable |
||
314 | mov ecx,[edx+4] |
||
315 | add ebx,20 |
||
316 | cmp ebx,ecx |
||
317 | jb no_mouse_disable |
||
318 | sub ebx,20 |
||
319 | add ecx,[edx+12] |
||
320 | cmp ebx,ecx |
||
321 | jg no_mouse_disable |
||
119 | mario79 | 322 | disable_m: |
381 | serge | 323 | cmp dword [MOUSE_VISIBLE],dword 0 |
119 | mario79 | 324 | jne no_mouse_disable |
389 | serge | 325 | pushf |
36 | mario79 | 326 | cli |
119 | mario79 | 327 | call draw_mouse_under |
389 | serge | 328 | popf |
381 | serge | 329 | mov [MOUSE_VISIBLE],dword 1 |
119 | mario79 | 330 | no_mouse_disable: |
33 | mario79 | 331 | popad |
332 | ret |
||
333 | |||
334 | __sys_draw_pointer: |
||
335 | cmp [mouse_pause],0 |
||
336 | je @f |
||
36 | mario79 | 337 | ret |
119 | mario79 | 338 | @@: |
36 | mario79 | 339 | push eax |
340 | mov eax,[timer_ticks] |
||
341 | sub eax,[MouseTickCounter] |
||
342 | cmp eax,1 |
||
343 | ja @f |
||
344 | pop eax |
||
345 | ret |
||
119 | mario79 | 346 | @@: |
36 | mario79 | 347 | mov eax,[timer_ticks] |
348 | mov [MouseTickCounter],eax |
||
349 | pop eax |
||
350 | pushad |
||
381 | serge | 351 | cmp dword [MOUSE_VISIBLE],dword 0 ; mouse visible ? |
33 | mario79 | 352 | je chms00 |
381 | serge | 353 | mov [MOUSE_VISIBLE], dword 0 |
354 | movzx ebx,word [MOUSE_Y] |
||
355 | movzx eax,word [MOUSE_X] |
||
389 | serge | 356 | pushfd |
36 | mario79 | 357 | cli |
33 | mario79 | 358 | call save_draw_mouse |
389 | serge | 359 | popfd |
119 | mario79 | 360 | nodmu2: |
33 | mario79 | 361 | popad |
362 | ret |
||
119 | mario79 | 363 | chms00: |
381 | serge | 364 | movzx ecx,word [X_UNDER] |
365 | movzx edx,word [Y_UNDER] |
||
366 | movzx ebx,word [MOUSE_Y] |
||
367 | movzx eax,word [MOUSE_X] |
||
33 | mario79 | 368 | cmp eax,ecx |
369 | jne redrawmouse |
||
370 | cmp ebx,edx |
||
371 | jne redrawmouse |
||
372 | jmp nodmp |
||
119 | mario79 | 373 | redrawmouse: |
389 | serge | 374 | pushfd |
36 | mario79 | 375 | cli |
33 | mario79 | 376 | call draw_mouse_under |
377 | call save_draw_mouse |
||
389 | serge | 378 | popfd |
119 | mario79 | 379 | nodmp: |
33 | mario79 | 380 | popad |
381 | ret |
||
119 | mario79 | 382 |