Subversion Repositories Kolibri OS

Rev

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