Subversion Repositories Kolibri OS

Rev

Rev 41 | Rev 102 | 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
 
73
        add   eax,[edx-twdw]
74
        add   ebx,[edx-twdw+4]
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
 
166
        test  ecx,0x80000000
167
        jnz   remove_button
168
 
169
        push  esi
170
        push  edi
171
        push  eax
172
        push  ebx
173
        push  ecx
174
        push  edx
175
 
54 mikedld 176
        or    ax,ax
177
        jle   noaddbutt
178
        or    bx,bx
179
        jle   noaddbutt
180
 
1 ha 181
        test  ecx,0x40000000
182
        jnz   button_no_draw
183
 
184
        pushad                       ; button body
185
        push  ebx
186
        shr   eax,16
187
        shr   ebx,16
188
        mov   edx,[0x3010]
189
        mov   esi,[edx-twdw]
190
        mov   edi,[edx-twdw+4]
191
        add   eax,esi
192
        add   ebx,edi
193
        mov   cx,ax
194
        mov   dx,bx
195
        shl   eax,16
196
        shl   ebx,16
197
        mov   ax,cx
198
        mov   bx,dx
199
        movzx ecx,word [4+32+esp+12]
200
        add   eax,ecx
201
        mov   ecx,[4+32+esp+0]
202
        cmp   [buttontype],dword 0
203
        je    @f
38 halyavin 204
        call  incecx2
1 ha 205
       @@:
206
        movzx edi,word [esp]
207
 
208
; 
209
        pop   edx
210
        and   edx, 0xFFFF
211
   ;;cli
212
     .newline:
213
        call  button_dececx
214
        push  edi
215
        xor   edi, edi
216
        call  [draw_line]
217
        pop   edi
218
        add   ebx,1*65536+1   ; [ y start | y end ]
219
        dec   edx
220
        jnz   .newline
221
   ;;sti
222
;;        pop   ebx
223
; 
224
        popad
225
 
226
        call  drawbuttonframes
227
 
228
      button_no_draw:
229
 
230
        and   ecx,0xffff
231
 
232
        mov   edi,[0x3010]
233
        sub   edi,twdw
234
 
235
        mov   edi,[0xfe88]
236
        movzx eax,word [edi]
237
        cmp   eax,max_buttons
238
        jge   noaddbutt
239
        inc   eax
240
        mov   [edi],ax
241
 
242
        shl   eax,4
243
        add   eax,edi
244
 
245
        mov   bx,[0x3000]
246
        mov   [eax],bx
247
 
248
        add   eax,2         ; save button id number
249
        mov   ebx,[esp+4]
250
        mov   [eax],bx      ; bits 0-15
251
        shr   ebx,16
252
        mov   [eax-2+0xc],bx; bits 16-31
253
        add   eax,2         ; x start
254
        mov   bx,[esp+12+2]
255
        mov   [eax],bx
256
        add   eax,2         ; x size
257
        mov   bx,[esp+12+0]
258
        mov   [eax],bx
259
        add   eax,2         ; y start
260
        mov   bx,[esp+8+2]
261
        mov   [eax],bx
262
        add   eax,2         ; y size
263
        mov   bx,[esp+8+0]
264
        mov   [eax],bx
265
 
266
     noaddbutt:
267
 
268
        pop   edx
269
        pop   ecx
270
        pop   ebx
271
        pop   eax
272
        pop   edi
273
        pop   esi
274
 
275
        ret
276
 
277
 
278
remove_button:
279
 
280
    and  ecx,0x7fffffff
281
 
282
  rnewba2:
283
 
284
    mov   edi,[0xfe88]
285
    mov   eax,edi
286
    movzx ebx,word [edi]
287
    inc   bx
288
 
289
  rnewba:
290
 
291
    dec   bx
292
    jz    rnmba
293
 
294
    add   eax,0x10
295
 
296
    mov   dx,[0x3000]
297
    cmp   dx,[eax]
298
    jnz   rnewba
299
 
300
    cmp   cx,[eax+2]
301
    jnz   rnewba
302
 
303
    pushad
304
    mov   ecx,ebx
305
    inc   ecx
306
    shl   ecx,4
307
    mov   ebx,eax
308
    add   eax,0x10
309
    call  memmove
310
    dec   dword [edi]
311
    popad
312
 
313
    jmp   rnewba2
314
 
315
  rnmba:
316
 
317
    ret
318
 
319
find_pressed_button_frames:
320
 
321
        pushad
322
 
323
        movzx ebx,word [eax+0]
324
        shl   ebx,5
325
        add   ebx,window_data
326
        movzx ecx,word [ebx+0]     ; window x start
327
        movzx edx,word [eax+4]     ; button x start
328
        add   ecx,edx
329
        push  ecx
330
 
331
        mov   dx,[eax+6]     ; button x size
332
        add   cx,dx
333
        mov   esi,ecx
334
        inc   esi
335
        mov   cx,[ebx+4]     ; window y start
336
        mov   dx,[eax+8]     ; button y start
337
        add   ecx,edx
338
        mov   ebx,ecx
339
        mov   dx,[eax+10]    ; button y size
340
        add   dx,cx
341
        inc   dx
342
 
343
        pop   eax
344
 
345
        ; eax x beginning
346
        ; ebx y beginning
347
        ; esi x end
348
        ; edx y end
349
        ; ecx color
350
 
351
        mov   [pressed_button_eax],eax
352
        mov   [pressed_button_ebx],ebx
353
        mov   [pressed_button_ecx],ecx
354
        mov   [pressed_button_edx],edx
355
        mov   [pressed_button_esi],esi
356
 
357
        popad
358
        ret
359
 
360
uglobal
361
  pressed_button_eax  dd  0
362
  pressed_button_ebx  dd  0
363
  pressed_button_ecx  dd  0
364
  pressed_button_edx  dd  0
365
  pressed_button_esi  dd  0
366
endg
367
 
368
; negative button image
369
 
370
negativebutton:
371
        ; If requested, do not display button
372
        ; boarder on press.
373
        test  ebx,0x20000000
374
        jz    draw_negative_button
375
        ret
376
      draw_negative_button:
377
 
378
        pushad
379
 
380
        mov   eax,[pressed_button_eax]
381
        mov   ebx,[pressed_button_ebx]
382
        mov   ecx,[pressed_button_ecx]
383
        mov   edx,[pressed_button_edx]
384
        mov   esi,[pressed_button_esi]
385
        mov   ecx,0x01000000
386
 
387
        dec   edx
388
        push  edx
389
        inc   edx
390
        dec   esi
391
        push  esi
392
        inc   esi
393
 
394
        push  eax
395
        push  ebx
396
        push  ecx
397
        push  edx
398
        push  edi
399
 
400
        call  [disable_mouse]
401
 
402
      bdbnewline:
403
        mov   edi,1    ; force
404
        cmp   eax,[esp+16]
405
        jz    bneg
406
        cmp   eax,[esp+20]
407
        jz    bneg
408
        cmp   ebx,[esp+12]
409
        jz    bneg
410
        cmp   ebx,[esp+24]
411
        jnz   nbneg
412
;        jz    bneg
413
;        jmp   nbneg
414
 
415
      bneg:
416
 
417
        ;;;call  [disable_mouse]
418
        call  [putpixel]
419
 
420
      nbneg:
421
 
422
        inc   eax
423
        cmp   eax,esi
424
        jnz   bdbnewline
425
        mov   eax,[esp+16]
426
        inc   ebx
427
        cmp   ebx,edx
428
        jnz   bdbnewline
429
 
430
        add   esp,28
431
 
432
        popad
433
 
434
        ret
435
 
436
; check buttons
437
 
438
 
439
; 0000 word process number
440
; 0002 word button id number : bits 0-15
441
; 0004 word x start
442
; 0006 word x size
443
; 0008 word y start
444
; 000A word y size
445
; 000C word button id number : bits 16-31
446
;
447
; button table in 0x10 increments
448
;
449
; first at 0x10
450
 
451
 
452
checkbuttons:
453
 
454
    cmp   [0xfb40],byte 0    ; mouse buttons pressed
455
    jnz   @f
456
    ret
457
  @@:
458
 
459
    pushad
460
 
461
    xor    esi, esi
462
    mov    edi, [0xfe88]
463
    movzx  edx, word [edi]
464
    test   edx, edx
465
    jne    @f
466
    popad
467
    ret
468
 
469
  @@:
470
 
471
    push  esi
472
    inc   edx
473
    push  edx
474
 
475
  buttonnewcheck:
476
 
477
    pop   edx
478
    pop   esi
479
    inc   esi
480
    cmp   edx,esi
481
    jge   bch
482
 
483
    popad                 ; no button pressed
484
    ret
485
 
486
  bch:
487
 
488
    push  esi
489
    push  edx
490
    mov   eax,esi
491
    shl   eax,4
492
    add   eax,edi
493
 
28 mario79 494
;......................start 1/2 : modified by vhanla .............................
495
    mov   [buttonid],eax
496
;......................end   1/2 : modified by vhanla .............................
497
 
1 ha 498
    ; check that button is at top of windowing stack
499
 
500
    movzx ebx,word [eax]
501
    movzx ecx,word [0xC000 + ebx * 2]
502
    cmp   ecx,[0x3004]
503
    jne   buttonnewcheck
504
 
505
    ; check that button start is inside window x/y end
506
 
507
    movzx ebx,word [eax+0]
508
    shl   ebx,5
41 mikedld 509
 
510
        test    [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED
511
        jnz     buttonnewcheck
512
 
1 ha 513
;    add   ebx,window_data
514
;    mov   ecx,[window_data+ebx+8]          ; window end X
515
    movzx edx,word [eax+4]     ; button start X
516
    cmp   edx, [window_data+ebx+8] ;ecx
517
    jge   buttonnewcheck
518
 
519
;    mov   ecx,[window_data+ebx+12]         ; window end Y
520
    movzx edx, word [eax+8]    ; button start Y
521
    cmp   edx, [window_data+ebx+12] ;ecx
522
    jge   buttonnewcheck
523
 
524
    ; check coordinates
525
                               ; mouse x >= button x ?
526
    movzx ebx,word [eax+0]
527
    shl   ebx,5
528
    add   ebx,window_data
529
    movzx ecx,word [ebx+0]     ; window x start
530
    movzx edx,word [eax+4]     ; button x start
531
    add   edx,ecx
532
    mov   cx,[0xfb0a]
533
    cmp   edx,ecx
534
    jg    buttonnewcheck
535
 
536
    movzx ebx,word [eax+6]     ; button x size
537
    add   edx,ebx
538
    cmp   ecx,edx
539
    jg    buttonnewcheck
540
 
541
                               ; mouse y >= button y ?
542
    movzx ebx,word [eax+0]
543
    shl   ebx,5
544
    add   ebx,window_data
545
    movzx ecx,word [ebx+4]     ; window y start
546
    movzx edx,word [eax+8]     ; button y start
547
    add   edx,ecx
548
    mov   cx,[0xfb0c]
549
    cmp   edx,ecx
550
    jg    buttonnewcheck
551
 
552
    movzx ebx,word [eax+10]    ; button y size
553
    add   edx,ebx
554
    cmp   ecx,edx
555
    jg    buttonnewcheck
556
 
557
    ; mouse on button
558
 
559
    pop   edx
560
    pop   esi
561
 
562
    mov   bx,[eax+0xc]     ; button id : bits 16-31
563
    shl   ebx,16
564
    mov   bx,[eax+2]       ; button id : bits 00-16
565
    push  ebx
566
 
567
    mov   [0xfb44],byte 1  ; no mouse down checks
568
    call find_pressed_button_frames
569
    call negativebutton
570
 
571
    pushad
572
  cbwaitmouseup:
573
 
574
    call  checkidle
575
 
576
    call  [draw_pointer]
577
 
578
    pushad
579
    call  stack_handler
580
    popad
581
 
582
    cmp   [0xfb40],byte 0  ; mouse buttons pressed ?
583
    jnz   cbwaitmouseup
584
    popad
585
 
586
    call  negativebutton
587
    mov   [0xfff4],byte 0  ; no mouse background
588
    mov   [0xfff5],byte 0  ; draw mouse
28 mario79 589
;..................................... start 2/2 : modified by vhanla .............................
590
    ; check coordinates
591
    jmp afterbuttonid
592
    buttonid dd 0x0 ;here a will backup the eax value
593
    afterbuttonid:
594
 
33 mario79 595
   pusha
596
  ; mouse x >= button x ?
597
   movzx ebx,word [eax+0]
598
   shl   ebx,5
599
   add   ebx,window_data
600
   movzx ecx,word [ebx+0]    ; window x start
601
   movzx edx,word [eax+4]    ; button x start
602
   add   edx,ecx
603
   mov   cx,[0xfb0a]
604
   cmp   edx,ecx
605
   jg   no_on_button ;if we release the pointer out of the button area
28 mario79 606
 
33 mario79 607
   movzx ebx,word [eax+6]    ; button x size
608
   add   edx,ebx
609
   cmp   ecx,edx
610
   jg   no_on_button
28 mario79 611
 
33 mario79 612
        ; mouse y >= button y ?
613
   movzx ebx,word [eax+0]
614
   shl   ebx,5
615
   add   ebx,window_data
616
   movzx ecx,word [ebx+4]    ; window y start
617
   movzx edx,word [eax+8]    ; button y start
618
   add   edx,ecx
619
   mov   cx,[0xfb0c]
620
   cmp   edx,ecx
621
   jg   no_on_button
28 mario79 622
 
33 mario79 623
   movzx ebx,word [eax+10]   ; button y size
624
   add   edx,ebx
625
   cmp   ecx,edx
626
   jg   no_on_button
627
   popa
628
   mov   [0xf500],byte 1 ; no of buttons in buffer
629
   pop   ebx
630
   mov   [0xf501],ebx   ; lets put the button id in buffer
631
   push  ebx
632
   pusha
633
   jmp yes_on_button
28 mario79 634
no_on_button:
33 mario79 635
   mov   [0xf500],byte 0 ; no of buttons in buffer
28 mario79 636
yes_on_button:
33 mario79 637
   mov   [0xfb44],byte 0 ; mouse down -> do not draw
638
   popa
639
   pop ebx
640
   popa
641
   ret
642
 
28 mario79 643
;..................................... end 2/2 : modified by vhanla ................................