Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ha | 1 | max_buttons=4095 |
2 | dececx: |
||
3 | |||
4 | push eax |
||
5 | push edx |
||
6 | push ecx |
||
7 | |||
8 | mov edx,1 |
||
9 | dececl: |
||
10 | |||
11 | movzx eax,byte [esp+edx] |
||
12 | cmp eax,0x20 |
||
13 | jge @f |
||
14 | mov [esp+edx],byte 0x20 |
||
15 | @@: |
||
16 | sub [esp+edx],byte 0x20 |
||
17 | |||
18 | add edx,1 |
||
19 | cmp edx,4 |
||
20 | jbe dececl |
||
21 | |||
22 | pop ecx |
||
23 | pop edx |
||
24 | pop eax |
||
25 | ret |
||
26 | |||
27 | |||
28 | drawbuttonframes: |
||
29 | |||
30 | push esi |
||
31 | push edi |
||
32 | push eax |
||
33 | push ebx |
||
34 | push ecx |
||
35 | push edx |
||
36 | |||
37 | shr eax,16 |
||
38 | shr ebx,16 |
||
39 | mov edx,[0x3010] |
||
40 | |||
41 | add eax,[edx-twdw] |
||
42 | add ebx,[edx-twdw+4] |
||
43 | mov cx,ax |
||
44 | mov dx,bx |
||
45 | shl eax,16 |
||
46 | shl ebx,16 |
||
47 | mov ax,cx |
||
48 | mov bx,dx |
||
49 | add ax,word [esp+12] |
||
50 | mov esi,ebx |
||
51 | mov edi,0 |
||
52 | mov ecx,[esp+0] |
||
53 | add ecx,0x202020 |
||
54 | call [draw_line] |
||
55 | |||
56 | movzx edx,word [esp+8] |
||
57 | add ebx,edx |
||
58 | shl edx,16 |
||
59 | add ebx,edx |
||
60 | mov ecx,[esp+0] |
||
61 | call dececx |
||
62 | call [draw_line] |
||
63 | |||
64 | mov ebx,esi |
||
65 | push edx |
||
66 | mov edx,eax |
||
67 | shr edx,16 |
||
68 | mov ax,dx |
||
69 | mov edx,ebx |
||
70 | shr edx,16 |
||
71 | mov bx,dx |
||
72 | mov dx,[esp+8+4] |
||
73 | add bx,dx |
||
74 | pop edx |
||
75 | mov edi,0 |
||
76 | mov ecx,[esp+0] |
||
77 | add ecx,0x202020 |
||
78 | call [draw_line] |
||
79 | |||
80 | mov esi,edx |
||
81 | mov dx,[esp+12] |
||
82 | add ax,dx |
||
83 | shl edx,16 |
||
84 | add eax,edx |
||
85 | add ebx,1*65536 |
||
86 | mov edx,esi |
||
87 | mov ecx,[esp+0] |
||
88 | call dececx |
||
89 | call [draw_line] |
||
90 | |||
91 | pop edx |
||
92 | pop ecx |
||
93 | pop ebx |
||
94 | pop eax |
||
95 | pop edi |
||
96 | pop esi |
||
97 | |||
98 | ret |
||
99 | |||
100 | button_dececx: |
||
101 | |||
102 | cmp [buttontype],dword 1 |
||
103 | jne .finish |
||
104 | ; je bdece |
||
105 | ; ret |
||
106 | ; bdece: |
||
107 | push eax |
||
108 | mov eax,0x01 |
||
109 | cmp edi,20 |
||
110 | jg @f |
||
111 | mov eax,0x02 |
||
112 | @@: |
||
113 | test ecx,0xff |
||
114 | jz @f |
||
115 | sub ecx,eax |
||
116 | @@: |
||
117 | shl eax,8 |
||
118 | test ecx,0xff00 |
||
119 | jz @f |
||
120 | sub ecx,eax |
||
121 | @@: |
||
122 | shl eax,8 |
||
123 | test ecx,0xff0000 |
||
124 | jz @f |
||
125 | sub ecx,eax |
||
126 | @@: |
||
127 | pop eax |
||
128 | .finish: |
||
129 | ret |
||
130 | |||
131 | |||
132 | sys_button: |
||
133 | |||
134 | test ecx,0x80000000 |
||
135 | jnz remove_button |
||
136 | |||
137 | push esi |
||
138 | push edi |
||
139 | push eax |
||
140 | push ebx |
||
141 | push ecx |
||
142 | push edx |
||
143 | |||
144 | test ecx,0x40000000 |
||
145 | jnz button_no_draw |
||
146 | |||
147 | pushad ; button body |
||
148 | push ebx |
||
149 | shr eax,16 |
||
150 | shr ebx,16 |
||
151 | mov edx,[0x3010] |
||
152 | mov esi,[edx-twdw] |
||
153 | mov edi,[edx-twdw+4] |
||
154 | add eax,esi |
||
155 | add ebx,edi |
||
156 | mov cx,ax |
||
157 | mov dx,bx |
||
158 | shl eax,16 |
||
159 | shl ebx,16 |
||
160 | mov ax,cx |
||
161 | mov bx,dx |
||
162 | movzx ecx,word [4+32+esp+12] |
||
163 | add eax,ecx |
||
164 | mov ecx,[4+32+esp+0] |
||
165 | cmp [buttontype],dword 0 |
||
166 | je @f |
||
167 | add ecx,0x141414 |
||
168 | @@: |
||
169 | movzx edi,word [esp] |
||
170 | |||
171 | ; |
||
172 | pop edx |
||
173 | and edx, 0xFFFF |
||
174 | ;;cli |
||
175 | .newline: |
||
176 | call button_dececx |
||
177 | push edi |
||
178 | xor edi, edi |
||
179 | call [draw_line] |
||
180 | pop edi |
||
181 | add ebx,1*65536+1 ; [ y start | y end ] |
||
182 | dec edx |
||
183 | jnz .newline |
||
184 | ;;sti |
||
185 | ;; pop ebx |
||
186 | ; |
||
187 | popad |
||
188 | |||
189 | call drawbuttonframes |
||
190 | |||
191 | button_no_draw: |
||
192 | |||
193 | and ecx,0xffff |
||
194 | |||
195 | mov edi,[0x3010] |
||
196 | sub edi,twdw |
||
197 | |||
198 | mov edi,[0xfe88] |
||
199 | movzx eax,word [edi] |
||
200 | cmp eax,max_buttons |
||
201 | jge noaddbutt |
||
202 | inc eax |
||
203 | mov [edi],ax |
||
204 | |||
205 | shl eax,4 |
||
206 | add eax,edi |
||
207 | |||
208 | mov bx,[0x3000] |
||
209 | mov [eax],bx |
||
210 | |||
211 | add eax,2 ; save button id number |
||
212 | mov ebx,[esp+4] |
||
213 | mov [eax],bx ; bits 0-15 |
||
214 | shr ebx,16 |
||
215 | mov [eax-2+0xc],bx; bits 16-31 |
||
216 | add eax,2 ; x start |
||
217 | mov bx,[esp+12+2] |
||
218 | mov [eax],bx |
||
219 | add eax,2 ; x size |
||
220 | mov bx,[esp+12+0] |
||
221 | mov [eax],bx |
||
222 | add eax,2 ; y start |
||
223 | mov bx,[esp+8+2] |
||
224 | mov [eax],bx |
||
225 | add eax,2 ; y size |
||
226 | mov bx,[esp+8+0] |
||
227 | mov [eax],bx |
||
228 | |||
229 | noaddbutt: |
||
230 | |||
231 | pop edx |
||
232 | pop ecx |
||
233 | pop ebx |
||
234 | pop eax |
||
235 | pop edi |
||
236 | pop esi |
||
237 | |||
238 | ret |
||
239 | |||
240 | |||
241 | remove_button: |
||
242 | |||
243 | and ecx,0x7fffffff |
||
244 | |||
245 | rnewba2: |
||
246 | |||
247 | mov edi,[0xfe88] |
||
248 | mov eax,edi |
||
249 | movzx ebx,word [edi] |
||
250 | inc bx |
||
251 | |||
252 | rnewba: |
||
253 | |||
254 | dec bx |
||
255 | jz rnmba |
||
256 | |||
257 | add eax,0x10 |
||
258 | |||
259 | mov dx,[0x3000] |
||
260 | cmp dx,[eax] |
||
261 | jnz rnewba |
||
262 | |||
263 | cmp cx,[eax+2] |
||
264 | jnz rnewba |
||
265 | |||
266 | pushad |
||
267 | mov ecx,ebx |
||
268 | inc ecx |
||
269 | shl ecx,4 |
||
270 | mov ebx,eax |
||
271 | add eax,0x10 |
||
272 | call memmove |
||
273 | dec dword [edi] |
||
274 | popad |
||
275 | |||
276 | jmp rnewba2 |
||
277 | |||
278 | rnmba: |
||
279 | |||
280 | ret |
||
281 | |||
282 | find_pressed_button_frames: |
||
283 | |||
284 | pushad |
||
285 | |||
286 | movzx ebx,word [eax+0] |
||
287 | shl ebx,5 |
||
288 | add ebx,window_data |
||
289 | movzx ecx,word [ebx+0] ; window x start |
||
290 | movzx edx,word [eax+4] ; button x start |
||
291 | add ecx,edx |
||
292 | push ecx |
||
293 | |||
294 | mov dx,[eax+6] ; button x size |
||
295 | add cx,dx |
||
296 | mov esi,ecx |
||
297 | inc esi |
||
298 | mov cx,[ebx+4] ; window y start |
||
299 | mov dx,[eax+8] ; button y start |
||
300 | add ecx,edx |
||
301 | mov ebx,ecx |
||
302 | mov dx,[eax+10] ; button y size |
||
303 | add dx,cx |
||
304 | inc dx |
||
305 | |||
306 | pop eax |
||
307 | |||
308 | ; eax x beginning |
||
309 | ; ebx y beginning |
||
310 | ; esi x end |
||
311 | ; edx y end |
||
312 | ; ecx color |
||
313 | |||
314 | mov [pressed_button_eax],eax |
||
315 | mov [pressed_button_ebx],ebx |
||
316 | mov [pressed_button_ecx],ecx |
||
317 | mov [pressed_button_edx],edx |
||
318 | mov [pressed_button_esi],esi |
||
319 | |||
320 | popad |
||
321 | ret |
||
322 | |||
323 | uglobal |
||
324 | pressed_button_eax dd 0 |
||
325 | pressed_button_ebx dd 0 |
||
326 | pressed_button_ecx dd 0 |
||
327 | pressed_button_edx dd 0 |
||
328 | pressed_button_esi dd 0 |
||
329 | endg |
||
330 | |||
331 | ; negative button image |
||
332 | |||
333 | negativebutton: |
||
334 | ; If requested, do not display button |
||
335 | ; boarder on press. |
||
336 | test ebx,0x20000000 |
||
337 | jz draw_negative_button |
||
338 | ret |
||
339 | draw_negative_button: |
||
340 | |||
341 | pushad |
||
342 | |||
343 | mov eax,[pressed_button_eax] |
||
344 | mov ebx,[pressed_button_ebx] |
||
345 | mov ecx,[pressed_button_ecx] |
||
346 | mov edx,[pressed_button_edx] |
||
347 | mov esi,[pressed_button_esi] |
||
348 | mov ecx,0x01000000 |
||
349 | |||
350 | dec edx |
||
351 | push edx |
||
352 | inc edx |
||
353 | dec esi |
||
354 | push esi |
||
355 | inc esi |
||
356 | |||
357 | push eax |
||
358 | push ebx |
||
359 | push ecx |
||
360 | push edx |
||
361 | push edi |
||
362 | |||
363 | call [disable_mouse] |
||
364 | |||
365 | bdbnewline: |
||
366 | mov edi,1 ; force |
||
367 | cmp eax,[esp+16] |
||
368 | jz bneg |
||
369 | cmp eax,[esp+20] |
||
370 | jz bneg |
||
371 | cmp ebx,[esp+12] |
||
372 | jz bneg |
||
373 | cmp ebx,[esp+24] |
||
374 | jnz nbneg |
||
375 | ; jz bneg |
||
376 | ; jmp nbneg |
||
377 | |||
378 | bneg: |
||
379 | |||
380 | ;;;call [disable_mouse] |
||
381 | call [putpixel] |
||
382 | |||
383 | nbneg: |
||
384 | |||
385 | inc eax |
||
386 | cmp eax,esi |
||
387 | jnz bdbnewline |
||
388 | mov eax,[esp+16] |
||
389 | inc ebx |
||
390 | cmp ebx,edx |
||
391 | jnz bdbnewline |
||
392 | |||
393 | add esp,28 |
||
394 | |||
395 | popad |
||
396 | |||
397 | ret |
||
398 | |||
399 | ; check buttons |
||
400 | |||
401 | |||
402 | ; 0000 word process number |
||
403 | ; 0002 word button id number : bits 0-15 |
||
404 | ; 0004 word x start |
||
405 | ; 0006 word x size |
||
406 | ; 0008 word y start |
||
407 | ; 000A word y size |
||
408 | ; 000C word button id number : bits 16-31 |
||
409 | ; |
||
410 | ; button table in 0x10 increments |
||
411 | ; |
||
412 | ; first at 0x10 |
||
413 | |||
414 | |||
415 | checkbuttons: |
||
416 | |||
417 | cmp [0xfb40],byte 0 ; mouse buttons pressed |
||
418 | jnz @f |
||
419 | ret |
||
420 | @@: |
||
421 | |||
422 | pushad |
||
423 | |||
424 | xor esi, esi |
||
425 | mov edi, [0xfe88] |
||
426 | movzx edx, word [edi] |
||
427 | test edx, edx |
||
428 | jne @f |
||
429 | popad |
||
430 | ret |
||
431 | |||
432 | @@: |
||
433 | |||
434 | push esi |
||
435 | inc edx |
||
436 | push edx |
||
437 | |||
438 | buttonnewcheck: |
||
439 | |||
440 | pop edx |
||
441 | pop esi |
||
442 | inc esi |
||
443 | cmp edx,esi |
||
444 | jge bch |
||
445 | |||
446 | popad ; no button pressed |
||
447 | ret |
||
448 | |||
449 | bch: |
||
450 | |||
451 | push esi |
||
452 | push edx |
||
453 | mov eax,esi |
||
454 | shl eax,4 |
||
455 | add eax,edi |
||
456 | |||
457 | ; check that button is at top of windowing stack |
||
458 | |||
459 | movzx ebx,word [eax] |
||
460 | movzx ecx,word [0xC000 + ebx * 2] |
||
461 | cmp ecx,[0x3004] |
||
462 | jne buttonnewcheck |
||
463 | |||
464 | ; check that button start is inside window x/y end |
||
465 | |||
466 | movzx ebx,word [eax+0] |
||
467 | shl ebx,5 |
||
468 | ; add ebx,window_data |
||
469 | ; mov ecx,[window_data+ebx+8] ; window end X |
||
470 | movzx edx,word [eax+4] ; button start X |
||
471 | cmp edx, [window_data+ebx+8] ;ecx |
||
472 | jge buttonnewcheck |
||
473 | |||
474 | ; mov ecx,[window_data+ebx+12] ; window end Y |
||
475 | movzx edx, word [eax+8] ; button start Y |
||
476 | cmp edx, [window_data+ebx+12] ;ecx |
||
477 | jge buttonnewcheck |
||
478 | |||
479 | ; check coordinates |
||
480 | ; mouse x >= button x ? |
||
481 | movzx ebx,word [eax+0] |
||
482 | shl ebx,5 |
||
483 | add ebx,window_data |
||
484 | movzx ecx,word [ebx+0] ; window x start |
||
485 | movzx edx,word [eax+4] ; button x start |
||
486 | add edx,ecx |
||
487 | mov cx,[0xfb0a] |
||
488 | cmp edx,ecx |
||
489 | jg buttonnewcheck |
||
490 | |||
491 | movzx ebx,word [eax+6] ; button x size |
||
492 | add edx,ebx |
||
493 | cmp ecx,edx |
||
494 | jg buttonnewcheck |
||
495 | |||
496 | ; mouse y >= button y ? |
||
497 | movzx ebx,word [eax+0] |
||
498 | shl ebx,5 |
||
499 | add ebx,window_data |
||
500 | movzx ecx,word [ebx+4] ; window y start |
||
501 | movzx edx,word [eax+8] ; button y start |
||
502 | add edx,ecx |
||
503 | mov cx,[0xfb0c] |
||
504 | cmp edx,ecx |
||
505 | jg buttonnewcheck |
||
506 | |||
507 | movzx ebx,word [eax+10] ; button y size |
||
508 | add edx,ebx |
||
509 | cmp ecx,edx |
||
510 | jg buttonnewcheck |
||
511 | |||
512 | ; mouse on button |
||
513 | |||
514 | pop edx |
||
515 | pop esi |
||
516 | |||
517 | mov bx,[eax+0xc] ; button id : bits 16-31 |
||
518 | shl ebx,16 |
||
519 | mov bx,[eax+2] ; button id : bits 00-16 |
||
520 | push ebx |
||
521 | |||
522 | mov [0xfb44],byte 1 ; no mouse down checks |
||
523 | call find_pressed_button_frames |
||
524 | call negativebutton |
||
525 | |||
526 | pushad |
||
527 | cbwaitmouseup: |
||
528 | |||
529 | call checkidle |
||
530 | |||
531 | call check_mouse_data |
||
532 | call [draw_pointer] |
||
533 | |||
534 | pushad |
||
535 | call stack_handler |
||
536 | popad |
||
537 | |||
538 | cmp [0xfb40],byte 0 ; mouse buttons pressed ? |
||
539 | jnz cbwaitmouseup |
||
540 | popad |
||
541 | |||
542 | call negativebutton |
||
543 | mov [0xfff4],byte 0 ; no mouse background |
||
544 | mov [0xfff5],byte 0 ; draw mouse |
||
545 | mov [0xf500],byte 1 |
||
546 | pop ebx |
||
547 | mov [0xf501],ebx |
||
548 | mov [0xfb44],byte 0 ; mouse down checks |
||
549 | popad |
||
550 | ret |
||
551 |