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