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