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