Rev 221 | Rev 281 | 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 |
||
46 | movzx eax,word [0xfb4a] |
||
47 | movzx ebx,word [0xfb4c] |
||
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: |
33 | mario79 | 57 | movzx eax,word [0xfb4a] |
58 | movzx ebx,word [0xfb4c] |
||
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 | |||
214 | serge | 93 | mov [0xfb4a],ax |
94 | mov [0xfb4c],bx |
||
221 | serge | 95 | movzx eax,word [0xfb0c] |
96 | movzx ebx,word [0xfb0a] |
||
97 | push eax |
||
214 | serge | 98 | push ebx |
221 | serge | 99 | |
100 | mov ecx, [0xfe00] |
||
101 | inc ecx |
||
102 | mul ecx |
||
103 | movzx edx, byte [display_data+ebx+eax] |
||
104 | shl edx, 8 |
||
230 | serge | 105 | mov ecx, [edx+PROC_BASE+APPDATA.cursor] |
106 | |||
107 | cmp [ecx+CURSOR.magic], 'CURS' |
||
108 | jne .fail |
||
109 | cmp [ecx+CURSOR.size], CURSOR_SIZE |
||
110 | jne .fail |
||
111 | push ecx |
||
214 | serge | 112 | call [set_hw_cursor] |
221 | serge | 113 | popad |
214 | serge | 114 | ret |
230 | serge | 115 | .fail: |
116 | mov ecx, [def_cursor] |
||
117 | mov [edx+PROC_BASE+APPDATA.cursor], ecx |
||
118 | push ecx |
||
119 | call [set_hw_cursor] |
||
120 | popad |
||
121 | ret |
||
122 | |||
214 | serge | 123 | @@: |
33 | mario79 | 124 | pushad |
125 | ; save & draw |
||
126 | mov [0xfb4a],ax |
||
127 | mov [0xfb4c],bx |
||
128 | push eax |
||
129 | push ebx |
||
130 | mov ecx,0 |
||
131 | mov edx,0 |
||
132 | align 4 |
||
119 | mario79 | 133 | drm: |
33 | mario79 | 134 | push eax |
135 | push ebx |
||
136 | push ecx |
||
137 | push edx |
||
138 | ; helloworld |
||
139 | push ecx |
||
140 | add eax,ecx ; save picture under mouse |
||
141 | add ebx,edx |
||
142 | push ecx |
||
143 | call getpixel |
||
144 | mov [0xfb30],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,[0xfb30] |
||
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,[0xf200] ; we have our str address |
||
161 | mov esi, edi |
||
162 | add esi, 16*24*3 |
||
163 | push ecx |
||
164 | mov ecx, [0xfb30] |
||
165 | call combine_colors |
||
166 | mov [0xfb10], ecx |
||
167 | pop ecx |
||
168 | pop edx |
||
169 | pop ecx |
||
170 | pop ebx |
||
171 | pop eax |
||
172 | add eax,ecx ; we have x coord+cycle |
||
173 | add ebx,edx ; and y coord+cycle |
||
174 | push ecx |
||
175 | mov ecx, [0xfb10] |
||
176 | mov edi, 1 |
||
177 | call [putpixel] |
||
178 | pop ecx |
||
179 | mov ebx,[esp+0] ; pure y coord again |
||
180 | mov eax,[esp+4] ; and x |
||
181 | inc ecx ; +1 cycle |
||
182 | cmp ecx,16 ; if more than 16 |
||
183 | jnz drm |
||
184 | xor ecx, ecx |
||
185 | inc edx |
||
186 | cmp edx,24 |
||
187 | jnz drm |
||
119 | mario79 | 188 | add esp,8 |
33 | mario79 | 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) ) |
||
201 | push eax |
||
202 | push ebx |
||
203 | push edx |
||
204 | push ecx |
||
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 |
||
119 | mario79 | 215 | xor eax, eax |
216 | xor ebx, ebx |
||
217 | mov al, [edi+0] |
||
218 | mov bl, [esi+0] |
||
33 | mario79 | 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 |
||
119 | mario79 | 232 | xor eax, eax |
233 | xor ebx, ebx |
||
234 | mov al, [edi+1] |
||
235 | mov bl, [esi+1] |
||
33 | mario79 | 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 |
||
119 | mario79 | 248 | xor eax, eax |
249 | xor ebx, ebx |
||
250 | mov al, [edi+2] |
||
251 | mov bl, [esi+2] |
||
33 | mario79 | 252 | mul ebx |
253 | shr eax, 8 |
||
254 | add ecx, eax |
||
255 | pop eax |
||
256 | pop edx |
||
257 | pop ebx |
||
258 | pop eax |
||
259 | ret |
||
260 | |||
261 | |||
262 | __sys_disable_mouse: |
||
36 | mario79 | 263 | cmp dword [0xf204],dword 0 |
264 | je @f |
||
265 | ret |
||
214 | serge | 266 | @@: |
33 | mario79 | 267 | pushad |
268 | cmp [0x3000],dword 1 |
||
269 | je disable_m |
||
270 | mov edx,[0x3000] |
||
271 | shl edx,5 |
||
272 | add edx,window_data |
||
273 | movzx eax, word [0xfb0a] |
||
274 | movzx ebx, word [0xfb0c] |
||
275 | mov ecx,[0xfe00] |
||
276 | inc ecx |
||
277 | imul ecx,ebx |
||
278 | add ecx,eax |
||
279 | add ecx, display_data |
||
102 | poddubny | 280 | mov eax, [0x3000] |
33 | mario79 | 281 | movzx ebx, byte [ecx] |
282 | cmp eax,ebx |
||
283 | je yes_mouse_disable |
||
284 | movzx ebx, byte [ecx+16] |
||
285 | cmp eax,ebx |
||
286 | je yes_mouse_disable |
||
287 | mov ebx,[0xfe00] |
||
288 | inc ebx |
||
289 | imul ebx,10 |
||
290 | add ecx,ebx |
||
291 | movzx ebx, byte [ecx] |
||
292 | cmp eax,ebx |
||
293 | je yes_mouse_disable |
||
294 | movzx ebx, byte [ecx+16] |
||
295 | cmp eax,ebx |
||
296 | je yes_mouse_disable |
||
297 | jmp no_mouse_disable |
||
119 | mario79 | 298 | yes_mouse_disable: |
33 | mario79 | 299 | mov edx,[0x3000] |
300 | shl edx,5 |
||
301 | add edx,window_data |
||
302 | movzx eax, word [0xfb0a] |
||
303 | movzx ebx, word [0xfb0c] |
||
304 | mov ecx,[edx+0] ; mouse inside the area ? |
||
305 | add eax,14 |
||
306 | cmp eax,ecx |
||
307 | jb no_mouse_disable |
||
308 | sub eax,14 |
||
309 | add ecx,[edx+8] |
||
310 | cmp eax,ecx |
||
311 | jg no_mouse_disable |
||
312 | mov ecx,[edx+4] |
||
313 | add ebx,20 |
||
314 | cmp ebx,ecx |
||
315 | jb no_mouse_disable |
||
316 | sub ebx,20 |
||
317 | add ecx,[edx+12] |
||
318 | cmp ebx,ecx |
||
319 | jg no_mouse_disable |
||
119 | mario79 | 320 | disable_m: |
33 | mario79 | 321 | cmp dword [0xf204],dword 0 |
119 | mario79 | 322 | jne no_mouse_disable |
36 | mario79 | 323 | cli |
119 | mario79 | 324 | call draw_mouse_under |
36 | mario79 | 325 | sti |
33 | mario79 | 326 | mov [0xf204],dword 1 |
119 | mario79 | 327 | no_mouse_disable: |
33 | mario79 | 328 | popad |
329 | ret |
||
330 | |||
331 | __sys_draw_pointer: |
||
332 | cmp [mouse_pause],0 |
||
333 | je @f |
||
36 | mario79 | 334 | ret |
119 | mario79 | 335 | @@: |
36 | mario79 | 336 | push eax |
337 | mov eax,[timer_ticks] |
||
338 | sub eax,[MouseTickCounter] |
||
339 | cmp eax,1 |
||
340 | ja @f |
||
341 | pop eax |
||
342 | ret |
||
119 | mario79 | 343 | @@: |
36 | mario79 | 344 | mov eax,[timer_ticks] |
345 | mov [MouseTickCounter],eax |
||
346 | pop eax |
||
347 | pushad |
||
33 | mario79 | 348 | cmp dword [0xf204],dword 0 ; mouse visible ? |
349 | je chms00 |
||
350 | mov [0xf204], dword 0 |
||
351 | movzx ebx,word [0xfb0c] |
||
352 | movzx eax,word [0xfb0a] |
||
36 | mario79 | 353 | cli |
33 | mario79 | 354 | call save_draw_mouse |
36 | mario79 | 355 | sti |
119 | mario79 | 356 | nodmu2: |
33 | mario79 | 357 | popad |
358 | ret |
||
119 | mario79 | 359 | chms00: |
33 | mario79 | 360 | movzx ecx,word [0xfb4a] |
361 | movzx edx,word [0xfb4c] |
||
362 | movzx ebx,word [0xfb0c] |
||
363 | movzx eax,word [0xfb0a] |
||
364 | cmp eax,ecx |
||
365 | jne redrawmouse |
||
366 | cmp ebx,edx |
||
367 | jne redrawmouse |
||
368 | jmp nodmp |
||
119 | mario79 | 369 | redrawmouse: |
36 | mario79 | 370 | cli |
33 | mario79 | 371 | call draw_mouse_under |
372 | call save_draw_mouse |
||
36 | mario79 | 373 | sti |
119 | mario79 | 374 | nodmp: |
33 | mario79 | 375 | popad |
376 | ret |
||
119 | mario79 | 377 |