Subversion Repositories Kolibri OS

Rev

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

Rev 5185 Rev 5363
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
5
;; Distributed under terms of the GNU General Public License    ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;                                                              ;;
6
;;                                                              ;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
 
8
 
9
$Revision: 5185 $
9
$Revision: 5363 $
10
 
10
 
11
;==============================================================================
11
;==============================================================================
12
;///// public functions ///////////////////////////////////////////////////////
12
;///// public functions ///////////////////////////////////////////////////////
13
;==============================================================================
13
;==============================================================================
14
 
14
 
15
button.MAX_BUTTONS = 4095
15
button.MAX_BUTTONS = 4095
16
 
16
 
17
struct  SYS_BUTTON
17
struct  SYS_BUTTON
18
        pslot           dw ?
18
        pslot           dw ?
19
        id_lo           dw ?
19
        id_lo           dw ?
20
        left            dw ?
20
        left            dw ?
21
        width           dw ?
21
        width           dw ?
22
        top             dw ?
22
        top             dw ?
23
        height          dw ?
23
        height          dw ?
24
        id_hi           dw ?
24
        id_hi           dw ?
25
                        dw ?
25
                        dw ?
26
ends
26
ends
27
 
27
 
28
align 4
28
align 4
29
;------------------------------------------------------------------------------
29
;------------------------------------------------------------------------------
30
syscall_button: ;///// system function 8 //////////////////////////////////////
30
syscall_button: ;///// system function 8 //////////////////////////////////////
31
;------------------------------------------------------------------------------
31
;------------------------------------------------------------------------------
32
;? Define/undefine GUI button object
32
;? Define/undefine GUI button object
33
;------------------------------------------------------------------------------
33
;------------------------------------------------------------------------------
34
;; Define button:
34
;; Define button:
35
;> ebx = pack[16(x), 16(width)]
35
;> ebx = pack[16(x), 16(width)]
36
;> ecx = pack[16(y), 16(height)]
36
;> ecx = pack[16(y), 16(height)]
37
;> edx = pack[8(flags), 24(button identifier)]
37
;> edx = pack[8(flags), 24(button identifier)]
38
;>       flags bits:
38
;>       flags bits:
39
;>          7 (31) = 0
39
;>          7 (31) = 0
40
;>          6 (30) = don't draw button
40
;>          6 (30) = don't draw button
41
;>          5 (29) = don't draw button frame when pressed
41
;>          5 (29) = don't draw button frame when pressed
42
;> esi = button color
42
;> esi = button color
43
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
43
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
44
;; Undefine button:
44
;; Undefine button:
45
;> edx = pack[8(flags), 24(button identifier)]
45
;> edx = pack[8(flags), 24(button identifier)]
46
;>       flags bits:
46
;>       flags bits:
47
;>          7 (31) = 1
47
;>          7 (31) = 1
48
;------------------------------------------------------------------------------
48
;------------------------------------------------------------------------------
49
        ; do we actually need to undefine the button?
49
        ; do we actually need to undefine the button?
50
        test    edx, 0x80000000
50
        test    edx, 0x80000000
51
        jnz     .remove_button
51
        jnz     .remove_button
52
 
52
 
53
        ; do we have free button slots available?
53
        ; do we have free button slots available?
54
        mov     edi, [BTN_ADDR]
54
        mov     edi, [BTN_ADDR]
55
        mov     eax, [edi]
55
        mov     eax, [edi]
56
        cmp     eax, button.MAX_BUTTONS
56
        cmp     eax, button.MAX_BUTTONS
57
        jge     .exit
57
        jge     .exit
58
 
58
 
59
        ; does it have positive size? (otherwise it doesn't have sense)
59
        ; does it have positive size? (otherwise it doesn't have sense)
60
        or      bx, bx
60
        or      bx, bx
61
        jle     .exit
61
        jle     .exit
62
        or      cx, cx
62
        or      cx, cx
63
        jle     .exit
63
        jle     .exit
64
 
64
 
65
        ; make coordinates clientbox-relative
65
        ; make coordinates clientbox-relative
66
        push    eax
66
        push    eax
67
        mov     eax, [current_slot]
67
        mov     eax, [current_slot]
68
        rol     ebx, 16
68
        rol     ebx, 16
69
        add     bx, word[eax + APPDATA.wnd_clientbox.left]
69
        add     bx, word[eax + APPDATA.wnd_clientbox.left]
70
        rol     ebx, 16
70
        rol     ebx, 16
71
        rol     ecx, 16
71
        rol     ecx, 16
72
        add     cx, word[eax + APPDATA.wnd_clientbox.top]
72
        add     cx, word[eax + APPDATA.wnd_clientbox.top]
73
        rol     ecx, 16
73
        rol     ecx, 16
74
        pop     eax
74
        pop     eax
75
 
75
 
76
        ; basic checks passed, define the button
76
        ; basic checks passed, define the button
77
        push    ebx ecx edx
77
        push    ebx ecx edx
78
        inc     eax
78
        inc     eax
79
        mov     [edi], ax
79
        mov     [edi], ax
80
        shl     eax, 4
80
        shl     eax, 4
81
        add     edi, eax
81
        add     edi, eax
82
        ; NOTE: this code doesn't rely on SYS_BUTTON struct, please revise it
82
        ; NOTE: this code doesn't rely on SYS_BUTTON struct, please revise it
83
        ;       if you change something
83
        ;       if you change something
84
        mov     ax, [CURRENT_TASK]
84
        mov     ax, [CURRENT_TASK]
85
        stosw
85
        stosw
86
        mov     ax, dx
86
        mov     ax, dx
87
        stosw               ; button id number: bits 0-15
87
        stosw               ; button id number: bits 0-15
88
        mov     eax, ebx
88
        mov     eax, ebx
89
        rol     eax, 16
89
        rol     eax, 16
90
        stosd               ; x start | x size
90
        stosd               ; x start | x size
91
        mov     eax, ecx
91
        mov     eax, ecx
92
        rol     eax, 16
92
        rol     eax, 16
93
        stosd               ; y start | y size
93
        stosd               ; y start | y size
94
        mov     eax, edx
94
        mov     eax, edx
95
        shr     eax, 16
95
        shr     eax, 16
96
        stosw               ; button id number: bits 16-31
96
        stosw               ; button id number: bits 16-31
97
        pop     edx ecx ebx
97
        pop     edx ecx ebx
98
 
98
 
99
        ; do we also need to draw the button?
99
        ; do we also need to draw the button?
100
        test    edx, 0x40000000
100
        test    edx, 0x40000000
101
        jnz     .exit
101
        jnz     .exit
102
 
102
 
103
        ; draw button body
103
        ; draw button body
104
 
104
 
105
        pushad
105
        pushad
106
 
106
 
107
        ; calculate window-relative coordinates
107
        ; calculate window-relative coordinates
108
        movzx   edi, cx
108
        movzx   edi, cx
109
        shr     ebx, 16
109
        shr     ebx, 16
110
        shr     ecx, 16
110
        shr     ecx, 16
111
        mov     eax, [TASK_BASE]
111
        mov     eax, [TASK_BASE]
112
        add     ebx, [eax - twdw + WDATA.box.left]
112
        add     ebx, [eax - twdw + WDATA.box.left]
113
        add     ecx, [eax - twdw + WDATA.box.top]
113
        add     ecx, [eax - twdw + WDATA.box.top]
114
        mov     eax, ebx
114
        mov     eax, ebx
115
        shl     eax, 16
115
        shl     eax, 16
116
        mov     ax, bx
116
        mov     ax, bx
117
        add     ax, word[esp + 16]
117
        add     ax, word[esp + 16]
118
        mov     ebx, ecx
118
        mov     ebx, ecx
119
        shl     ebx, 16
119
        shl     ebx, 16
120
        mov     bx, cx
120
        mov     bx, cx
121
 
121
 
122
        ; calculate initial color
122
        ; calculate initial color
123
        mov     ecx, esi
123
        mov     ecx, esi
124
        cmp     [buttontype], 0
124
        cmp     [buttontype], 0
125
        je      @f
125
        je      @f
126
        call    button._.incecx2
126
        call    button._.incecx2
127
 
127
 
128
        ; set button height counter
128
        ; set button height counter
129
    @@:
129
    @@:
130
        mov     edx, edi
130
        mov     edx, edi
131
 
131
 
132
  .next_line:
132
  .next_line:
133
        call    button._.button_dececx
133
        call    button._.button_dececx
134
        push    edi
134
        push    edi
135
        xor     edi, edi
135
        xor     edi, edi
136
;        call    [draw_line]
136
;        call    [draw_line]
137
        call    __sys_draw_line
137
        call    __sys_draw_line
138
        pop     edi
138
        pop     edi
139
        add     ebx, 0x00010001
139
        add     ebx, 0x00010001
140
        dec     edx
140
        dec     edx
141
        jnz     .next_line
141
        jnz     .next_line
142
 
142
 
143
        popad
143
        popad
144
 
144
 
145
        ; draw button frame
145
        ; draw button frame
146
 
146
 
147
        push    ebx ecx
147
        push    ebx ecx
148
 
148
 
149
        ; calculate window-relative coordinates
149
        ; calculate window-relative coordinates
150
        shr     ebx, 16
150
        shr     ebx, 16
151
        shr     ecx, 16
151
        shr     ecx, 16
152
        mov     eax, [TASK_BASE]
152
        mov     eax, [TASK_BASE]
153
        add     ebx, [eax - twdw + WDATA.box.left]
153
        add     ebx, [eax - twdw + WDATA.box.left]
154
        add     ecx, [eax - twdw + WDATA.box.top]
154
        add     ecx, [eax - twdw + WDATA.box.top]
155
 
155
 
156
        ; top border
156
        ; top border
157
        mov     eax, ebx
157
        mov     eax, ebx
158
        shl     eax, 16
158
        shl     eax, 16
159
        mov     ax, bx
159
        mov     ax, bx
160
        add     ax, [esp + 4]
160
        add     ax, [esp + 4]
161
        mov     ebx, ecx
161
        mov     ebx, ecx
162
        shl     ebx, 16
162
        shl     ebx, 16
163
        mov     bx, cx
163
        mov     bx, cx
164
        push    ebx
164
        push    ebx
165
        xor     edi, edi
165
        xor     edi, edi
166
        mov     ecx, esi
166
        mov     ecx, esi
167
        call    button._.incecx
167
        call    button._.incecx
168
;        call    [draw_line]
168
;        call    [draw_line]
169
        call    __sys_draw_line
169
        call    __sys_draw_line
170
 
170
 
171
        ; bottom border
171
        ; bottom border
172
        movzx   edx, word[esp + 4 + 0]
172
        movzx   edx, word[esp + 4 + 0]
173
        add     ebx, edx
173
        add     ebx, edx
174
        shl     edx, 16
174
        shl     edx, 16
175
        add     ebx, edx
175
        add     ebx, edx
176
        mov     ecx, esi
176
        mov     ecx, esi
177
        call    button._.dececx
177
        call    button._.dececx
178
;        call    [draw_line]
178
;        call    [draw_line]
179
        call    __sys_draw_line
179
        call    __sys_draw_line
180
 
180
 
181
        ; left border
181
        ; left border
182
        pop     ebx
182
        pop     ebx
183
        push    edx
183
        push    edx
184
        mov     edx, eax
184
        mov     edx, eax
185
        shr     edx, 16
185
        shr     edx, 16
186
        mov     ax, dx
186
        mov     ax, dx
187
        mov     edx, ebx
187
        mov     edx, ebx
188
        shr     edx, 16
188
        shr     edx, 16
189
        mov     bx, dx
189
        mov     bx, dx
190
        add     bx, [esp + 4 + 0]
190
        add     bx, [esp + 4 + 0]
191
        pop     edx
191
        pop     edx
192
        mov     ecx, esi
192
        mov     ecx, esi
193
        call    button._.incecx
193
        call    button._.incecx
194
;        call    [draw_line]
194
;        call    [draw_line]
195
        call    __sys_draw_line
195
        call    __sys_draw_line
196
 
196
 
197
        ; right border
197
        ; right border
198
        mov     dx, [esp + 4]
198
        mov     dx, [esp + 4]
199
        add     ax, dx
199
        add     ax, dx
200
        shl     edx, 16
200
        shl     edx, 16
201
        add     eax, edx
201
        add     eax, edx
202
        add     ebx, 0x00010000
202
        add     ebx, 0x00010000
203
        mov     ecx, esi
203
        mov     ecx, esi
204
        call    button._.dececx
204
        call    button._.dececx
205
;        call    [draw_line]
205
;        call    [draw_line]
206
        call    __sys_draw_line
206
        call    __sys_draw_line
207
 
207
 
208
        pop     ecx ebx
208
        pop     ecx ebx
209
 
209
 
210
  .exit:
210
  .exit:
211
        ret
211
        ret
212
 
212
 
213
; FIXME: mutex needed
213
; FIXME: mutex needed
214
syscall_button.remove_button:
214
syscall_button.remove_button:
215
        and     edx, 0x00ffffff
215
        and     edx, 0x00ffffff
216
        mov     edi, [BTN_ADDR]
216
        mov     edi, [BTN_ADDR]
217
        mov     ebx, [edi]
217
        mov     ebx, [edi]
218
        inc     ebx
218
        inc     ebx
219
        imul    esi, ebx, sizeof.SYS_BUTTON
219
        imul    esi, ebx, sizeof.SYS_BUTTON
220
        add     esi, edi
220
        add     esi, edi
221
        xor     ecx, ecx
221
        xor     ecx, ecx
222
        add     ecx, -sizeof.SYS_BUTTON
222
        add     ecx, -sizeof.SYS_BUTTON
223
        add     esi, sizeof.SYS_BUTTON
223
        add     esi, sizeof.SYS_BUTTON
224
 
224
 
225
  .next_button:
225
  .next_button:
226
        dec     ebx
226
        dec     ebx
227
        jz      .exit
227
        jz      .exit
228
 
228
 
229
        add     ecx, sizeof.SYS_BUTTON
229
        add     ecx, sizeof.SYS_BUTTON
230
        add     esi, -sizeof.SYS_BUTTON
230
        add     esi, -sizeof.SYS_BUTTON
231
 
231
 
232
        ; does it belong to our process?
232
        ; does it belong to our process?
233
        mov     ax, [CURRENT_TASK]
233
        mov     ax, [CURRENT_TASK]
234
        cmp     ax, [esi + SYS_BUTTON.pslot]
234
        cmp     ax, [esi + SYS_BUTTON.pslot]
235
        jne     .next_button
235
        jne     .next_button
236
 
236
 
237
        ; does the identifier match?
237
        ; does the identifier match?
238
        mov     eax, dword[esi + SYS_BUTTON.id_hi - 2]
238
        mov     eax, dword[esi + SYS_BUTTON.id_hi - 2]
239
        mov     ax, [esi + SYS_BUTTON.id_lo]
239
        mov     ax, [esi + SYS_BUTTON.id_lo]
240
        and     eax, 0x00ffffff
240
        and     eax, 0x00ffffff
241
        cmp     edx, eax
241
        cmp     edx, eax
242
        jne     .next_button
242
        jne     .next_button
243
 
243
 
244
        ; okay, undefine it
244
        ; okay, undefine it
245
        push    ebx
245
        push    ebx
246
        mov     ebx, esi
246
        mov     ebx, esi
247
        lea     eax, [esi + sizeof.SYS_BUTTON]
247
        lea     eax, [esi + sizeof.SYS_BUTTON]
248
        call    memmove
248
        call    memmove
249
        dec     dword[edi]
249
        dec     dword[edi]
250
        add     ecx, -sizeof.SYS_BUTTON
250
        add     ecx, -sizeof.SYS_BUTTON
251
        pop     ebx
251
        pop     ebx
252
        jmp     .next_button
252
        jmp     .next_button
253
 
253
 
254
  .exit:
254
  .exit:
255
        ret
255
        ret
256
 
256
 
257
align 4
257
align 4
258
;------------------------------------------------------------------------------
258
;------------------------------------------------------------------------------
259
sys_button_activate_handler: ;/////////////////////////////////////////////////
259
sys_button_activate_handler: ;/////////////////////////////////////////////////
260
;------------------------------------------------------------------------------
260
;------------------------------------------------------------------------------
261
;? 
261
;? 
262
;------------------------------------------------------------------------------
262
;------------------------------------------------------------------------------
263
;> eax = pack[8(process slot), 24(button id)]
263
;> eax = pack[8(process slot), 24(button id)]
264
;> ebx = pack[16(button x coord), 16(button y coord)]
264
;> ebx = pack[16(button x coord), 16(button y coord)]
265
;> cl = mouse button mask this system button was pressed with
265
;> cl = mouse button mask this system button was pressed with
266
;------------------------------------------------------------------------------
266
;------------------------------------------------------------------------------
267
        call    button._.find_button
267
        call    button._.find_button
268
        or      eax, eax
268
        or      eax, eax
269
        jz      .exit
269
        jz      .exit
270
 
270
 
271
        mov     ebx, dword[eax + SYS_BUTTON.id_hi - 2]
271
        mov     ebx, dword[eax + SYS_BUTTON.id_hi - 2]
272
        call    button._.negative_button
272
        call    button._.negative_button
273
 
273
 
274
  .exit:
274
  .exit:
275
        ret
275
        ret
276
 
276
 
277
align 4
277
align 4
278
;------------------------------------------------------------------------------
278
;------------------------------------------------------------------------------
279
sys_button_deactivate_handler: ;///////////////////////////////////////////////
279
sys_button_deactivate_handler: ;///////////////////////////////////////////////
280
;------------------------------------------------------------------------------
280
;------------------------------------------------------------------------------
281
;? 
281
;? 
282
;------------------------------------------------------------------------------
282
;------------------------------------------------------------------------------
283
;> eax = pack[8(process slot), 24(button id)]
283
;> eax = pack[8(process slot), 24(button id)]
284
;> ebx = pack[16(button x coord), 16(button y coord)]
284
;> ebx = pack[16(button x coord), 16(button y coord)]
285
;> cl = mouse button mask this system button was pressed with
285
;> cl = mouse button mask this system button was pressed with
286
;------------------------------------------------------------------------------
286
;------------------------------------------------------------------------------
287
        call    button._.find_button
287
        call    button._.find_button
288
        or      eax, eax
288
        or      eax, eax
289
        jz      .exit
289
        jz      .exit
290
 
290
 
291
        mov     ebx, dword[eax + SYS_BUTTON.id_hi - 2]
291
        mov     ebx, dword[eax + SYS_BUTTON.id_hi - 2]
292
        call    button._.negative_button
292
        call    button._.negative_button
293
 
293
 
294
  .exit:
294
  .exit:
295
        ret
295
        ret
296
 
296
 
297
align 4
297
align 4
298
;------------------------------------------------------------------------------
298
;------------------------------------------------------------------------------
299
sys_button_perform_handler: ;//////////////////////////////////////////////////
299
sys_button_perform_handler: ;//////////////////////////////////////////////////
300
;------------------------------------------------------------------------------
300
;------------------------------------------------------------------------------
301
;? 
301
;? 
302
;------------------------------------------------------------------------------
302
;------------------------------------------------------------------------------
303
;> eax = pack[8(process slot), 24(button id)]
303
;> eax = pack[8(process slot), 24(button id)]
304
;> ebx = pack[16(button x coord), 16(button y coord)]
304
;> ebx = pack[16(button x coord), 16(button y coord)]
305
;> cl = mouse button mask this system button was pressed with
305
;> cl = mouse button mask this system button was pressed with
306
;------------------------------------------------------------------------------
306
;------------------------------------------------------------------------------
307
        shl     eax, 8
307
        shl     eax, 8
308
        mov     al, cl
308
        mov     al, cl
309
        movzx   ebx, byte[BTN_COUNT]
309
        movzx   ebx, byte[BTN_COUNT]
310
        mov     [BTN_BUFF + ebx * 4], eax
310
        mov     [BTN_BUFF + ebx * 4], eax
311
        inc     bl
311
        inc     bl
312
        mov     [BTN_COUNT], bl
312
        mov     [BTN_COUNT], bl
313
        ret
313
        ret
314
 
314
 
315
;==============================================================================
315
;==============================================================================
316
;///// private functions //////////////////////////////////////////////////////
316
;///// private functions //////////////////////////////////////////////////////
317
;==============================================================================
317
;==============================================================================
318
 
318
 
319
;------------------------------------------------------------------------------
319
;------------------------------------------------------------------------------
320
button._.find_button: ;////////////////////////////////////////////////////////
320
button._.find_button: ;////////////////////////////////////////////////////////
321
;------------------------------------------------------------------------------
321
;------------------------------------------------------------------------------
322
;? Find system button by specified process slot, id and coordinates
322
;? Find system button by specified process slot, id and coordinates
323
;------------------------------------------------------------------------------
323
;------------------------------------------------------------------------------
324
;> eax = pack[8(process slot), 24(button id)] or 0
324
;> eax = pack[8(process slot), 24(button id)] or 0
325
;> ebx = pack[16(button x coord), 16(button y coord)]
325
;> ebx = pack[16(button x coord), 16(button y coord)]
326
;------------------------------------------------------------------------------
326
;------------------------------------------------------------------------------
327
;< eax = pointer to SYS_BUTTON struct or 0
327
;< eax = pointer to SYS_BUTTON struct or 0
328
;------------------------------------------------------------------------------
328
;------------------------------------------------------------------------------
329
        push    ecx edx esi edi
329
        push    ecx edx esi edi
330
 
330
 
331
        mov     edx, eax
331
        mov     edx, eax
332
        shr     edx, 24
332
        shr     edx, 24
333
        and     eax, 0x0ffffff
333
        and     eax, 0x0ffffff
334
 
334
 
335
        mov     edi, [BTN_ADDR]
335
        mov     edi, [BTN_ADDR]
336
        mov     ecx, [edi]
336
        mov     ecx, [edi]
337
        imul    esi, ecx, sizeof.SYS_BUTTON
337
        imul    esi, ecx, sizeof.SYS_BUTTON
338
        add     esi, edi
338
        add     esi, edi
339
        inc     ecx
339
        inc     ecx
340
        add     esi, sizeof.SYS_BUTTON
340
        add     esi, sizeof.SYS_BUTTON
341
 
341
 
342
  .next_button:
342
  .next_button:
343
        dec     ecx
343
        dec     ecx
344
        jz      .not_found
344
        jz      .not_found
345
 
345
 
346
        add     esi, -sizeof.SYS_BUTTON
346
        add     esi, -sizeof.SYS_BUTTON
347
 
347
 
348
        ; does it belong to our process?
348
        ; does it belong to our process?
349
        cmp     dx, [esi + SYS_BUTTON.pslot]
349
        cmp     dx, [esi + SYS_BUTTON.pslot]
350
        jne     .next_button
350
        jne     .next_button
351
 
351
 
352
        ; does id match?
352
        ; does id match?
353
        mov     edi, dword[esi + SYS_BUTTON.id_hi - 2]
353
        mov     edi, dword[esi + SYS_BUTTON.id_hi - 2]
354
        mov     di, [esi + SYS_BUTTON.id_lo]
354
        mov     di, [esi + SYS_BUTTON.id_lo]
355
        and     edi, 0x0ffffff
355
        and     edi, 0x0ffffff
356
        cmp     eax, edi
356
        cmp     eax, edi
357
        jne     .next_button
357
        jne     .next_button
358
 
358
 
359
        ; does coordinates match?
359
        ; does coordinates match?
360
        mov     edi, dword[esi + SYS_BUTTON.left - 2]
360
        mov     edi, dword[esi + SYS_BUTTON.left - 2]
361
        mov     di, [esi + SYS_BUTTON.top]
361
        mov     di, [esi + SYS_BUTTON.top]
362
        cmp     ebx, edi
362
        cmp     ebx, edi
363
        jne     .next_button
363
        jne     .next_button
364
 
364
 
365
        ; okay, return it
365
        ; okay, return it
366
        mov     eax, esi
366
        mov     eax, esi
367
        jmp     .exit
367
        jmp     .exit
368
 
368
 
369
  .not_found:
369
  .not_found:
370
        xor     eax, eax
370
        xor     eax, eax
371
 
371
 
372
  .exit:
372
  .exit:
373
        pop     edi esi edx ecx
373
        pop     edi esi edx ecx
374
        ret
374
        ret
375
 
375
 
376
;------------------------------------------------------------------------------
376
;------------------------------------------------------------------------------
377
button._.dececx: ;/////////////////////////////////////////////////////////////
377
button._.dececx: ;/////////////////////////////////////////////////////////////
378
;------------------------------------------------------------------------------
378
;------------------------------------------------------------------------------
379
;? 
379
;? 
380
;------------------------------------------------------------------------------
380
;------------------------------------------------------------------------------
381
        sub     cl, 0x20
381
        sub     cl, 0x20
382
        jnc     @f
382
        jnc     @f
383
        xor     cl, cl
383
        xor     cl, cl
384
    @@:
384
    @@:
385
        sub     ch, 0x20
385
        sub     ch, 0x20
386
        jnc     @f
386
        jnc     @f
387
        xor     ch, ch
387
        xor     ch, ch
388
    @@:
388
    @@:
389
        rol     ecx, 16
389
        rol     ecx, 16
390
        sub     cl, 0x20
390
        sub     cl, 0x20
391
        jnc     @f
391
        jnc     @f
392
        xor     cl, cl
392
        xor     cl, cl
393
    @@:
393
    @@:
394
        rol     ecx, 16
394
        rol     ecx, 16
395
        ret
395
        ret
396
 
396
 
397
;------------------------------------------------------------------------------
397
;------------------------------------------------------------------------------
398
button._.incecx: ;/////////////////////////////////////////////////////////////
398
button._.incecx: ;/////////////////////////////////////////////////////////////
399
;------------------------------------------------------------------------------
399
;------------------------------------------------------------------------------
400
;? 
400
;? 
401
;------------------------------------------------------------------------------
401
;------------------------------------------------------------------------------
402
        add     cl, 0x20
402
        add     cl, 0x20
403
        jnc     @f
403
        jnc     @f
404
        or      cl, -1
404
        or      cl, -1
405
    @@:
405
    @@:
406
        add     ch, 0x20
406
        add     ch, 0x20
407
        jnc     @f
407
        jnc     @f
408
        or      ch, -1
408
        or      ch, -1
409
    @@:
409
    @@:
410
        rol     ecx, 16
410
        rol     ecx, 16
411
        add     cl, 0x20
411
        add     cl, 0x20
412
        jnc     @f
412
        jnc     @f
413
        or      cl, -1
413
        or      cl, -1
414
    @@:
414
    @@:
415
        rol     ecx, 16
415
        rol     ecx, 16
416
        ret
416
        ret
417
 
417
 
418
;------------------------------------------------------------------------------
418
;------------------------------------------------------------------------------
419
button._.incecx2: ;////////////////////////////////////////////////////////////
419
button._.incecx2: ;////////////////////////////////////////////////////////////
420
;------------------------------------------------------------------------------
420
;------------------------------------------------------------------------------
421
;? 
421
;? 
422
;------------------------------------------------------------------------------
422
;------------------------------------------------------------------------------
423
        add     cl, 0x14
423
        add     cl, 0x14
424
        jnc     @f
424
        jnc     @f
425
        or      cl, -1
425
        or      cl, -1
426
    @@:
426
    @@:
427
        add     ch, 0x14
427
        add     ch, 0x14
428
        jnc     @f
428
        jnc     @f
429
        or      ch, -1
429
        or      ch, -1
430
    @@:
430
    @@:
431
        rol     ecx, 16
431
        rol     ecx, 16
432
        add     cl, 0x14
432
        add     cl, 0x14
433
        jnc     @f
433
        jnc     @f
434
        or      cl, -1
434
        or      cl, -1
435
    @@:
435
    @@:
436
        rol     ecx, 16
436
        rol     ecx, 16
437
        ret
437
        ret
438
 
438
 
439
;------------------------------------------------------------------------------
439
;------------------------------------------------------------------------------
440
button._.button_dececx: ;//////////////////////////////////////////////////////
440
button._.button_dececx: ;//////////////////////////////////////////////////////
441
;------------------------------------------------------------------------------
441
;------------------------------------------------------------------------------
442
;? 
442
;? 
443
;------------------------------------------------------------------------------
443
;------------------------------------------------------------------------------
444
        cmp     [buttontype], 1
444
        cmp     [buttontype], 1
445
        jne     .finish
445
        jne     .finish
446
 
446
 
447
        push    eax
447
        push    eax
448
        mov     al, 1
448
        mov     al, 1
449
        cmp     edi, 20
449
        cmp     edi, 20
450
        jg      @f
450
        jg      @f
451
        mov     al, 2
451
        mov     al, 2
452
 
452
 
453
    @@:
453
    @@:
454
        sub     cl, al
454
        sub     cl, al
455
        jnc     @f
455
        jnc     @f
456
        xor     cl, cl
456
        xor     cl, cl
457
    @@:
457
    @@:
458
        sub     ch, al
458
        sub     ch, al
459
        jnc     @f
459
        jnc     @f
460
        xor     ch, ch
460
        xor     ch, ch
461
    @@:
461
    @@:
462
        rol     ecx, 16
462
        rol     ecx, 16
463
        sub     cl, al
463
        sub     cl, al
464
        jnc     @f
464
        jnc     @f
465
        xor     cl, cl
465
        xor     cl, cl
466
    @@:
466
    @@:
467
        rol     ecx, 16
467
        rol     ecx, 16
468
 
468
 
469
        pop     eax
469
        pop     eax
470
 
470
 
471
  .finish:
471
  .finish:
472
        ret
472
        ret
473
 
473
 
474
;------------------------------------------------------------------------------
474
;------------------------------------------------------------------------------
475
button._.negative_button: ;////////////////////////////////////////////////////
475
button._.negative_button: ;////////////////////////////////////////////////////
476
;------------------------------------------------------------------------------
476
;------------------------------------------------------------------------------
477
;? Invert system button border
477
;? Invert system button border
478
;------------------------------------------------------------------------------
478
;------------------------------------------------------------------------------
479
        ; if requested, do not display button border on press.
479
        ; if requested, do not display button border on press.
480
        test    ebx, 0x20000000
480
        test    ebx, 0x20000000
481
        jnz     .exit
481
        jnz     .exit
482
 
482
 
483
        pushad
483
        pushad
484
 
484
 
485
        xchg    esi, eax
485
        xchg    esi, eax
486
 
486
 
487
        movzx   ecx, [esi + SYS_BUTTON.pslot]
487
        movzx   ecx, [esi + SYS_BUTTON.pslot]
488
        shl     ecx, 5
488
        shl     ecx, 5
489
        add     ecx, window_data
489
        add     ecx, window_data
490
 
490
 
491
        mov     eax, dword[esi + SYS_BUTTON.left]
491
        mov     eax, dword[esi + SYS_BUTTON.left]
492
        mov     ebx, dword[esi + SYS_BUTTON.top]
492
        mov     ebx, dword[esi + SYS_BUTTON.top]
493
        add     eax, [ecx + WDATA.box.left]
493
        add     eax, [ecx + WDATA.box.left]
494
        add     ebx, [ecx + WDATA.box.top]
494
        add     ebx, [ecx + WDATA.box.top]
495
        push    eax ebx
495
        push    eax ebx
496
        pop     edx ecx
496
        pop     edx ecx
497
        rol     eax, 16
497
        rol     eax, 16
498
        rol     ebx, 16
498
        rol     ebx, 16
499
        add     ax, cx
499
        add     ax, cx
500
        add     bx, dx
500
        add     bx, dx
501
 
501
 
502
        mov     esi, 0x01000000
502
        mov     esi, 0x01000000
503
        call    draw_rectangle.forced
503
        call    draw_rectangle.forced
504
 
504
 
505
        popad
505
        popad
506
 
506
 
507
  .exit:
507
  .exit:
508
        ret
508
        ret