Subversion Repositories Kolibri OS

Rev

Rev 415 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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