Subversion Repositories Kolibri OS

Rev

Rev 2 | Rev 33 | 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
 
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
 
28 mario79 457
;......................start 1/2 : modified by vhanla .............................
458
    mov   [buttonid],eax
459
;......................end   1/2 : modified by vhanla .............................
460
 
1 ha 461
    ; check that button is at top of windowing stack
462
 
463
    movzx ebx,word [eax]
464
    movzx ecx,word [0xC000 + ebx * 2]
465
    cmp   ecx,[0x3004]
466
    jne   buttonnewcheck
467
 
468
    ; check that button start is inside window x/y end
469
 
470
    movzx ebx,word [eax+0]
471
    shl   ebx,5
472
;    add   ebx,window_data
473
;    mov   ecx,[window_data+ebx+8]          ; window end X
474
    movzx edx,word [eax+4]     ; button start X
475
    cmp   edx, [window_data+ebx+8] ;ecx
476
    jge   buttonnewcheck
477
 
478
;    mov   ecx,[window_data+ebx+12]         ; window end Y
479
    movzx edx, word [eax+8]    ; button start Y
480
    cmp   edx, [window_data+ebx+12] ;ecx
481
    jge   buttonnewcheck
482
 
483
    ; check coordinates
484
                               ; mouse x >= button x ?
485
    movzx ebx,word [eax+0]
486
    shl   ebx,5
487
    add   ebx,window_data
488
    movzx ecx,word [ebx+0]     ; window x start
489
    movzx edx,word [eax+4]     ; button x start
490
    add   edx,ecx
491
    mov   cx,[0xfb0a]
492
    cmp   edx,ecx
493
    jg    buttonnewcheck
494
 
495
    movzx ebx,word [eax+6]     ; button x size
496
    add   edx,ebx
497
    cmp   ecx,edx
498
    jg    buttonnewcheck
499
 
500
                               ; mouse y >= button y ?
501
    movzx ebx,word [eax+0]
502
    shl   ebx,5
503
    add   ebx,window_data
504
    movzx ecx,word [ebx+4]     ; window y start
505
    movzx edx,word [eax+8]     ; button y start
506
    add   edx,ecx
507
    mov   cx,[0xfb0c]
508
    cmp   edx,ecx
509
    jg    buttonnewcheck
510
 
511
    movzx ebx,word [eax+10]    ; button y size
512
    add   edx,ebx
513
    cmp   ecx,edx
514
    jg    buttonnewcheck
515
 
516
    ; mouse on button
517
 
518
    pop   edx
519
    pop   esi
520
 
521
    mov   bx,[eax+0xc]     ; button id : bits 16-31
522
    shl   ebx,16
523
    mov   bx,[eax+2]       ; button id : bits 00-16
524
    push  ebx
525
 
526
    mov   [0xfb44],byte 1  ; no mouse down checks
527
    call find_pressed_button_frames
528
    call negativebutton
529
 
530
    pushad
531
  cbwaitmouseup:
532
 
533
    call  checkidle
534
 
535
    call  check_mouse_data
536
    call  [draw_pointer]
537
 
538
    pushad
539
    call  stack_handler
540
    popad
541
 
542
    cmp   [0xfb40],byte 0  ; mouse buttons pressed ?
543
    jnz   cbwaitmouseup
544
    popad
545
 
546
    call  negativebutton
547
    mov   [0xfff4],byte 0  ; no mouse background
548
    mov   [0xfff5],byte 0  ; draw mouse
28 mario79 549
;..................................... start 2/2 : modified by vhanla .............................
550
    ; check coordinates
551
    jmp afterbuttonid
552
    buttonid dd 0x0 ;here a will backup the eax value
553
    afterbuttonid:
554
 
555
    pusha
556
    mov   eax,[buttonid]
557
                ; mouse x >= button x ?
558
    movzx ebx,word [eax+0]
559
    shl   ebx,5
560
    add   ebx,window_data
561
    movzx ecx,word [ebx+0]     ; window x start
562
    movzx edx,word [eax+4]     ; button x start
563
    add   edx,ecx
564
    mov   cx,[0xfb0a]
565
    cmp   edx,ecx
566
    jg      no_on_button        ;if we release the pointer out of the button area
567
 
568
    movzx ebx,word [eax+6]     ; button x size
569
    add   edx,ebx
570
    cmp   ecx,edx
571
    jg      no_on_button
572
 
573
                   ; mouse y >= button y ?
574
    movzx ebx,word [eax+0]
575
    shl   ebx,5
576
    add   ebx,window_data
577
    movzx ecx,word [ebx+4]     ; window y start
578
    movzx edx,word [eax+8]     ; button y start
579
    add   edx,ecx
580
    mov   cx,[0xfb0c]
581
    cmp   edx,ecx
582
    jg      no_on_button
583
 
584
    movzx ebx,word [eax+10]    ; button y size
585
    add   edx,ebx
586
    cmp   ecx,edx
587
    jg      no_on_button
588
    popa
589
    mov   [0xf500],byte 1  ; no of buttons in buffer
1 ha 590
    pop   ebx
28 mario79 591
    mov   [0xf501],ebx       ; lets put the button id in buffer
592
    push  ebx
593
    pusha
594
    jmp yes_on_button
595
no_on_button:
596
    mov   [0xf500],byte 0  ; no of buttons in buffer
597
yes_on_button:
598
    mov   [0xfb44],byte 0  ; mouse down -> do not draw
599
    popa
600
    pop ebx
601
    popa
1 ha 602
    ret
28 mario79 603
;..................................... end 2/2 : modified by vhanla ................................
1 ha 604