Subversion Repositories Kolibri OS

Rev

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

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