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