Subversion Repositories Kolibri OS

Rev

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

Rev 8867 Rev 8869
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2021. 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
$Revision: 8867 $
8
$Revision: 8869 $
9
 
9
 
10
WINDOW_MOVE_AND_RESIZE_FLAGS = \
10
WINDOW_MOVE_AND_RESIZE_FLAGS = \
11
  mouse.WINDOW_RESIZE_N_FLAG + \
11
  mouse.WINDOW_RESIZE_N_FLAG + \
12
  mouse.WINDOW_RESIZE_W_FLAG + \
12
  mouse.WINDOW_RESIZE_W_FLAG + \
13
  mouse.WINDOW_RESIZE_S_FLAG + \
13
  mouse.WINDOW_RESIZE_S_FLAG + \
14
  mouse.WINDOW_RESIZE_E_FLAG + \
14
  mouse.WINDOW_RESIZE_E_FLAG + \
15
  mouse.WINDOW_MOVE_FLAG
15
  mouse.WINDOW_MOVE_FLAG
16
 
16
 
17
uglobal
17
uglobal
18
align 4
18
align 4
19
  event_start   dd ?
19
  event_start   dd ?
20
  event_end     dd ?
20
  event_end     dd ?
21
  event_uid     dd 0
21
  event_uid     dd 0
22
endg
22
endg
23
EV_SPACE   = 512
23
EV_SPACE   = 512
24
FreeEvents = event_start-EVENT.fd    ; "virtual" event, only following field used:
24
FreeEvents = event_start-EVENT.fd    ; "virtual" event, only following field used:
25
                                     ;  FreeEvents.fd=event_start and FreeEvents.bk=event_end
25
                                     ;  FreeEvents.fd=event_start and FreeEvents.bk=event_end
26
;-----------------------------------------------------------------------------
26
;-----------------------------------------------------------------------------
27
align 4
27
align 4
28
init_events:                                       ;; used from kernel.asm
28
init_events:                                       ;; used from kernel.asm
29
        stdcall kernel_alloc, EV_SPACE*sizeof.EVENT
29
        stdcall kernel_alloc, EV_SPACE*sizeof.EVENT
30
        or      eax, eax
30
        or      eax, eax
31
        jz      .fail
31
        jz      .fail
32
      ; eax - current event, ebx - previous event below
32
      ; eax - current event, ebx - previous event below
33
        mov     ecx, EV_SPACE        ; current - in allocated space
33
        mov     ecx, EV_SPACE        ; current - in allocated space
34
        mov     ebx, FreeEvents      ; previous - list beginning
34
        mov     ebx, FreeEvents      ; previous - list beginning
35
        push    ebx                  ; it will be the end later
35
        push    ebx                  ; it will be the end later
36
;--------------------------------------
36
;--------------------------------------
37
align 4
37
align 4
38
@@:
38
@@:
39
        mov     [ebx+EVENT.fd], eax
39
        mov     [ebx+EVENT.fd], eax
40
        mov     [eax+EVENT.bk], ebx
40
        mov     [eax+EVENT.bk], ebx
41
        mov     ebx, eax             ; previos <- current
41
        mov     ebx, eax             ; previos <- current
42
        add     eax, sizeof.EVENT    ; new current
42
        add     eax, sizeof.EVENT    ; new current
43
        loop    @b
43
        loop    @b
44
        pop     eax                  ; here it became the end
44
        pop     eax                  ; here it became the end
45
        mov     [ebx+EVENT.fd], eax
45
        mov     [ebx+EVENT.fd], eax
46
        mov     [eax+EVENT.bk], ebx
46
        mov     [eax+EVENT.bk], ebx
47
;--------------------------------------
47
;--------------------------------------
48
align 4
48
align 4
49
.fail:
49
.fail:
50
        ret
50
        ret
51
;-----------------------------------------------------------------------------
51
;-----------------------------------------------------------------------------
52
EVENT_WATCHED    = 0x10000000 ; bit 28
52
EVENT_WATCHED    = 0x10000000 ; bit 28
53
EVENT_SIGNALED   = 0x20000000 ; bit 29
53
EVENT_SIGNALED   = 0x20000000 ; bit 29
54
MANUAL_RESET     = 0x40000000 ; bit 30
54
MANUAL_RESET     = 0x40000000 ; bit 30
55
MANUAL_DESTROY   = 0x80000000 ; bit 31
55
MANUAL_DESTROY   = 0x80000000 ; bit 31
56
;-----------------------------------------------------------------------------
56
;-----------------------------------------------------------------------------
57
align 4
57
align 4
58
create_event:                                      ;; EXPORT use
58
create_event:                                      ;; EXPORT use
59
;info:
59
;info:
60
;   Move EVENT from the FreeEvents list to the ObjList list of the current slot;
60
;   Move EVENT from the FreeEvents list to the ObjList list of the current slot;
61
;   EVENT.state is set from ecx, EVENT.code indirectly from esi (if esi <> 0)
61
;   EVENT.state is set from ecx, EVENT.code indirectly from esi (if esi <> 0)
62
;param:
62
;param:
63
;   esi - event data
63
;   esi - event data
64
;   ecx - flags
64
;   ecx - flags
65
;retval:
65
;retval:
66
;   eax - event (=0 => fail)
66
;   eax - event (=0 => fail)
67
;   edx - uid
67
;   edx - uid
68
;scratched: ebx,ecx,esi,edi
68
;scratched: ebx,ecx,esi,edi
69
        mov     ebx, [current_slot]
69
        mov     ebx, [current_slot]
70
        add     ebx, APP_OBJ_OFFSET
70
        add     ebx, APP_OBJ_OFFSET
71
        mov     edx, [TASK_BASE]
71
        mov     edx, [TASK_BASE]
72
        mov     edx, [edx+TASKDATA.pid]
72
        mov     edx, [edx+TASKDATA.pid]
73
        pushfd
73
        pushfd
74
        cli
74
        cli
75
;--------------------------------------
75
;--------------------------------------
76
align 4
76
align 4
77
set_event:                                         ;; INTERNAL use !!! don't use for Call
77
set_event:                                         ;; INTERNAL use !!! don't use for Call
78
;info:
78
;info:
79
;   We take a new event from FreeEvents, fill its fields from ecx, edx, esi
79
;   We take a new event from FreeEvents, fill its fields from ecx, edx, esi
80
;   and add it to the list, which specified in ebx.
80
;   and add it to the list, which specified in ebx.
81
;   Return event (to eax), and it's uid (to edx)
81
;   Return event (to eax), and it's uid (to edx)
82
;param:
82
;param:
83
;   ebx - start-chain "virtual" event for entry new event Right of him
83
;   ebx - start-chain "virtual" event for entry new event Right of him
84
;   ecx - flags      (copied to EVENT.state)
84
;   ecx - flags      (copied to EVENT.state)
85
;   edx - pid        (copied to EVENT.pid)
85
;   edx - pid        (copied to EVENT.pid)
86
;   esi - event data (copied to EVENT.code indirect, =0 => skip)
86
;   esi - event data (copied to EVENT.code indirect, =0 => skip)
87
;retval:
87
;retval:
88
;   eax - event (=0 => fail)
88
;   eax - event (=0 => fail)
89
;   edx - uid
89
;   edx - uid
90
;scratched: ebx,ecx,esi,edi
90
;scratched: ebx,ecx,esi,edi
91
        mov     eax, FreeEvents
91
        mov     eax, FreeEvents
92
        cmp     eax, [eax+EVENT.fd]
92
        cmp     eax, [eax+EVENT.fd]
93
        jne     @f  ; not empty ???
93
        jne     @f  ; not empty ???
94
        pushad
94
        pushad
95
        call    init_events
95
        call    init_events
96
        popad
96
        popad
97
        jz      RemoveEventTo.break ; POPF+RET
97
        jz      RemoveEventTo.break ; POPF+RET
98
;--------------------------------------
98
;--------------------------------------
99
align 4
99
align 4
100
@@:
100
@@:
101
        mov     eax, [eax+EVENT.fd]
101
        mov     eax, [eax+EVENT.fd]
102
        mov     [eax+EVENT.magic], 'EVNT'
102
        mov     [eax+EVENT.magic], 'EVNT'
103
        mov     [eax+EVENT.destroy], destroy_event.internal
103
        mov     [eax+EVENT.destroy], destroy_event.internal
104
        mov     [eax+EVENT.state], ecx
104
        mov     [eax+EVENT.state], ecx
105
        mov     [eax+EVENT.pid], edx
105
        mov     [eax+EVENT.pid], edx
106
        inc     [event_uid]
106
        inc     [event_uid]
107
        mov     edx, [event_uid]
107
        mov     edx, [event_uid]
108
        mov     [eax+EVENT.id], edx
108
        mov     [eax+EVENT.id], edx
109
        or      esi, esi
109
        or      esi, esi
110
        jz      RemoveEventTo
110
        jz      RemoveEventTo
111
        lea     edi, [eax+EVENT.code]
111
        lea     edi, [eax+EVENT.code]
112
        mov     ecx, (sizeof.EVENT -EVENT.code)/4
112
        mov     ecx, (sizeof.EVENT -EVENT.code)/4
113
        cld
113
        cld
114
        rep movsd
114
        rep movsd
115
;--------------------------------------
115
;--------------------------------------
116
align 4
116
align 4
117
RemoveEventTo:                                     ;; INTERNAL use !!! don't use for Call
117
RemoveEventTo:                                     ;; INTERNAL use !!! don't use for Call
118
;param:
118
;param:
119
;   eax - pointer to event, WHICH we will insert
119
;   eax - pointer to event, WHICH we will insert
120
;   ebx - pointer to event, AFTER which we will insert
120
;   ebx - pointer to event, AFTER which we will insert
121
;scratched: ebx,ecx
121
;scratched: ebx,ecx
122
        mov     ecx, eax             ; ecx=eax=Self,      ebx=NewLeft
122
        mov     ecx, eax             ; ecx=eax=Self,      ebx=NewLeft
123
        xchg    ecx, [ebx+EVENT.fd]  ; NewLeft.fd=Self,   ecx=NewRight
123
        xchg    ecx, [ebx+EVENT.fd]  ; NewLeft.fd=Self,   ecx=NewRight
124
        cmp     eax, ecx             ; stop, I think...
124
        cmp     eax, ecx             ; stop, I think...
125
        je      .break               ; - am I not a fool?
125
        je      .break               ; - am I not a fool?
126
        mov     [ecx+EVENT.bk], eax  ; NewRight.bk=Self
126
        mov     [ecx+EVENT.bk], eax  ; NewRight.bk=Self
127
        xchg    ebx, [eax+EVENT.bk]  ; Self.bk=NewLeft,   ebx=OldLeft
127
        xchg    ebx, [eax+EVENT.bk]  ; Self.bk=NewLeft,   ebx=OldLeft
128
        xchg    ecx, [eax+EVENT.fd]  ; Self.fd=NewRight,  ecx=OldRight
128
        xchg    ecx, [eax+EVENT.fd]  ; Self.fd=NewRight,  ecx=OldRight
129
        mov     [ebx+EVENT.fd], ecx  ; OldLeft.fd=OldRight
129
        mov     [ebx+EVENT.fd], ecx  ; OldLeft.fd=OldRight
130
        mov     [ecx+EVENT.bk], ebx  ; OldRight.bk=OldLeft
130
        mov     [ecx+EVENT.bk], ebx  ; OldRight.bk=OldLeft
131
;--------------------------------------
131
;--------------------------------------
132
align 4
132
align 4
133
.break:
133
.break:
134
        popfd
134
        popfd
135
        ret
135
        ret
136
;-----------------------------------------------------------------------------
136
;-----------------------------------------------------------------------------
137
align 4
137
align 4
138
NotDummyTest:                                      ;; INTERNAL use (not returned for fail !!!)
138
NotDummyTest:                                      ;; INTERNAL use (not returned for fail !!!)
139
        pop     edi
139
        pop     edi
140
        call    DummyTest ; not returned for fail !!!
140
        call    DummyTest ; not returned for fail !!!
141
        mov     ebx, eax
141
        mov     ebx, eax
142
        mov     eax, [ebx+EVENT.pid]
142
        mov     eax, [ebx+EVENT.pid]
143
        push    edi
143
        push    edi
144
;--------------------------------------
144
;--------------------------------------
145
align 4
145
align 4
146
.small: ; somehow ugly...
146
.small: ; somehow ugly...
147
        pop     edi
147
        pop     edi
148
        pushfd
148
        pushfd
149
        cli
149
        cli
150
        call    pid_to_slot ; saved all registers (eax - retval)
150
        call    pid_to_slot ; saved all registers (eax - retval)
151
        shl     eax, 8
151
        shl     eax, 8
152
        jz      RemoveEventTo.break ; POPF+RET
152
        jz      RemoveEventTo.break ; POPF+RET
153
        jmp     edi ; normal return
153
        jmp     edi ; normal return
154
;-----------------------------------------------------------------------------
154
;-----------------------------------------------------------------------------
155
align 4
155
align 4
156
raise_event:                                       ;; EXPORT use
156
raise_event:                                       ;; EXPORT use
157
;info:
157
;info:
158
;   Setting up EVENT.code data
158
;   Setting up EVENT.code data
159
;   If is has flag EVENT_SIGNALED activated - nothing else
159
;   If is has flag EVENT_SIGNALED activated - nothing else
160
;   Otherwise: activate this flag, except when the EVENT_WATCHED flag is present in edx
160
;   Otherwise: activate this flag, except when the EVENT_WATCHED flag is present in edx
161
;   In this case EVENT_SIGNALED will activated only if EVENT_WATCHED presents in the event itself
161
;   In this case EVENT_SIGNALED will activated only if EVENT_WATCHED presents in the event itself
162
;param:
162
;param:
163
;   eax - event
163
;   eax - event
164
;   ebx - uid (for Dummy testing)
164
;   ebx - uid (for Dummy testing)
165
;   edx - flags
165
;   edx - flags
166
;   esi - event data (=0 => skip)
166
;   esi - event data (=0 => skip)
167
;scratched: ebx,ecx,esi,edi
167
;scratched: ebx,ecx,esi,edi
168
        call    NotDummyTest ; not returned for fail !!!
168
        call    NotDummyTest ; not returned for fail !!!
169
        or      esi, esi
169
        or      esi, esi
170
        jz      @f
170
        jz      @f
171
        lea     edi, [ebx+EVENT.code]
171
        lea     edi, [ebx+EVENT.code]
172
        mov     ecx, (sizeof.EVENT -EVENT.code)/4
172
        mov     ecx, (sizeof.EVENT -EVENT.code)/4
173
        cld
173
        cld
174
        rep movsd
174
        rep movsd
175
;--------------------------------------
175
;--------------------------------------
176
align 4
176
align 4
177
@@:
177
@@:
178
        test    byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24
178
        test    byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24
179
        jnz     RemoveEventTo.break  ; POPF+RET
179
        jnz     RemoveEventTo.break  ; POPF+RET
180
        bt      edx, 28 ;EVENT_WATCHED
180
        bt      edx, 28 ;EVENT_WATCHED
181
        jnc     @f
181
        jnc     @f
182
        test    byte[ebx+EVENT.state+3], EVENT_WATCHED shr 24
182
        test    byte[ebx+EVENT.state+3], EVENT_WATCHED shr 24
183
        jz      RemoveEventTo.break  ; POPF+RET
183
        jz      RemoveEventTo.break  ; POPF+RET
184
;--------------------------------------
184
;--------------------------------------
185
align 4
185
align 4
186
@@:
186
@@:
187
        or      byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24
187
        or      byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24
188
        add     eax, SLOT_BASE+APP_EV_OFFSET
188
        add     eax, SLOT_BASE+APP_EV_OFFSET
189
        xchg    eax, ebx
189
        xchg    eax, ebx
190
        jmp     RemoveEventTo
190
        jmp     RemoveEventTo
191
;-----------------------------------------------------------------------------
191
;-----------------------------------------------------------------------------
192
align 4
192
align 4
193
clear_event:                                       ;; EXPORT use
193
clear_event:                                       ;; EXPORT use
194
;info:
194
;info:
195
;
195
;
196
;param:
196
;param:
197
;   eax - event
197
;   eax - event
198
;   ebx - uid (for Dummy testing)
198
;   ebx - uid (for Dummy testing)
199
;scratched: ebx,ecx
199
;scratched: ebx,ecx
200
        call    NotDummyTest ; not returned for fail !!!
200
        call    NotDummyTest ; not returned for fail !!!
201
        add     eax, SLOT_BASE+APP_OBJ_OFFSET
201
        add     eax, SLOT_BASE+APP_OBJ_OFFSET
202
        and     byte[ebx+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24)
202
        and     byte[ebx+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24)
203
        xchg    eax, ebx
203
        xchg    eax, ebx
204
        jmp     RemoveEventTo
204
        jmp     RemoveEventTo
205
;-----------------------------------------------------------------------------
205
;-----------------------------------------------------------------------------
206
align 4
206
align 4
207
send_event:                                        ;; EXPORT use
207
send_event:                                        ;; EXPORT use
208
;info:
208
;info:
209
;   Creates a new EVENT (pulls from the FreeEvents list) in the EventList list
209
;   Creates a new EVENT (pulls from the FreeEvents list) in the EventList list
210
;   of target slot (eax=pid), with data from esi indirectly, and state=EVENT_SIGNALED
210
;   of target slot (eax=pid), with data from esi indirectly, and state=EVENT_SIGNALED
211
;param:
211
;param:
212
;   eax - slots pid, to sending new event
212
;   eax - slots pid, to sending new event
213
;   esi - pointer to sending data (in code field of new event)
213
;   esi - pointer to sending data (in code field of new event)
214
;retval:
214
;retval:
215
;   eax - event (=0 => fail)
215
;   eax - event (=0 => fail)
216
;   edx - uid
216
;   edx - uid
217
;warning:
217
;warning:
218
;   may be used as CDECL with such prefix...
218
;   may be used as CDECL with such prefix...
219
;       mov     esi,[esp+8]
219
;       mov     esi,[esp+8]
220
;       mov     eax,[esp+4]
220
;       mov     eax,[esp+4]
221
;   but not as STDCALL :(
221
;   but not as STDCALL :(
222
;scratched: ebx,ecx,esi,edi
222
;scratched: ebx,ecx,esi,edi
223
        mov     edx, eax
223
        mov     edx, eax
224
        call    NotDummyTest.small ; not returned for fail !!!
224
        call    NotDummyTest.small ; not returned for fail !!!
225
        lea     ebx, [eax+SLOT_BASE+APP_EV_OFFSET]
225
        lea     ebx, [eax+SLOT_BASE+APP_EV_OFFSET]
226
        mov     ecx, EVENT_SIGNALED
226
        mov     ecx, EVENT_SIGNALED
227
        jmp     set_event
227
        jmp     set_event
228
;-----------------------------------------------------------------------------
228
;-----------------------------------------------------------------------------
229
align 4
229
align 4
230
DummyTest:                                         ;; INTERNAL use (not returned for fail !!!)
230
DummyTest:                                         ;; INTERNAL use (not returned for fail !!!)
231
;param:
231
;param:
232
;   eax - event
232
;   eax - event
233
;   ebx - uid (for Dummy testing)
233
;   ebx - uid (for Dummy testing)
234
        cmp     [eax+EVENT.magic], 'EVNT'
234
        cmp     [eax+EVENT.magic], 'EVNT'
235
        jne     @f
235
        jne     @f
236
        cmp     [eax+EVENT.id], ebx
236
        cmp     [eax+EVENT.id], ebx
237
        je      .ret
237
        je      .ret
238
;--------------------------------------
238
;--------------------------------------
239
align 4
239
align 4
240
@@:
240
@@:
241
        pop     eax
241
        pop     eax
242
        xor     eax, eax
242
        xor     eax, eax
243
;--------------------------------------
243
;--------------------------------------
244
align 4
244
align 4
245
.ret:
245
.ret:
246
        ret
246
        ret
247
;-----------------------------------------------------------------------------
247
;-----------------------------------------------------------------------------
248
align 4
248
align 4
249
Wait_events:
249
Wait_events:
250
        or      ebx, -1; infinite timeout
250
        or      ebx, -1; infinite timeout
251
;--------------------------------------
251
;--------------------------------------
252
align 4
252
align 4
253
Wait_events_ex:
253
Wait_events_ex:
254
;info:
254
;info:
255
;   Waiting for an "abstract" event by moving the slot to the 5th position.
255
;   Waiting for an "abstract" event by moving the slot to the 5th position.
256
;   Abstractness lies in the fact, that the fact of an event is determined by the APPDATA.wait_test function,
256
;   Abstractness lies in the fact, that the fact of an event is determined by the APPDATA.wait_test function,
257
;   which is set by the client and can be actually anything.
257
;   which is set by the client and can be actually anything.
258
;   This allows the shed to reliably determine the fact of the event, and not make "idle" switches,
258
;   This allows the shed to reliably determine the fact of the event, and not make "idle" switches,
259
;   intended for showdowns like "friend / foe" within the problem.
259
;   intended for showdowns like "friend / foe" within the problem.
260
;param:
260
;param:
261
;   edx - wait_test, client testing function (code address)
261
;   edx - wait_test, client testing function (code address)
262
;   ecx - wait_param, additional parameter, possibly needed for [wait_test]
262
;   ecx - wait_param, additional parameter, possibly needed for [wait_test]
263
;   ebx - wait_timeout
263
;   ebx - wait_timeout
264
;retval:
264
;retval:
265
;   eax - call result [wait_test] (=0 => timeout)
265
;   eax - call result [wait_test] (=0 => timeout)
266
;scratched: esi
266
;scratched: esi
267
        mov     esi, [current_slot]
267
        mov     esi, [current_slot]
268
        mov     [esi+APPDATA.wait_param], ecx
268
        mov     [esi+APPDATA.wait_param], ecx
269
        pushad
269
        pushad
270
        mov     ebx, esi  ;now this is a question, what where to put..........
270
        mov     ebx, esi  ;now this is a question, what where to put..........
271
        pushfd  ; this is a consequence of the general concept: let the test function have
271
        pushfd  ; this is a consequence of the general concept: let the test function have
272
        cli     ; the right to hope to disable interrupts, as when called from shed
272
        cli     ; the right to hope to disable interrupts, as when called from shed
273
        call    edx
273
        call    edx
274
        popfd
274
        popfd
275
        mov     [esp+28], eax
275
        mov     [esp+28], eax
276
        popad
276
        popad
277
        or      eax, eax
277
        or      eax, eax
278
        jnz     @f   ;RET
278
        jnz     @f   ;RET
279
        mov     [esi+APPDATA.wait_test], edx
279
        mov     [esi+APPDATA.wait_test], edx
280
        mov     [esi+APPDATA.wait_timeout], ebx
280
        mov     [esi+APPDATA.wait_timeout], ebx
281
        mov     eax, [timer_ticks]
281
        mov     eax, [timer_ticks]
282
        mov     [esi+APPDATA.wait_begin], eax
282
        mov     [esi+APPDATA.wait_begin], eax
283
        mov     eax, [TASK_BASE]
283
        mov     eax, [TASK_BASE]
284
        mov     [eax+TASKDATA.state], 5
284
        mov     [eax+TASKDATA.state], 5
285
        call    change_task
285
        call    change_task
286
        mov     eax, [esi+APPDATA.wait_param]
286
        mov     eax, [esi+APPDATA.wait_param]
287
;--------------------------------------
287
;--------------------------------------
288
align 4
288
align 4
289
@@:
289
@@:
290
        ret
290
        ret
291
;-----------------------------------------------------------------------------
291
;-----------------------------------------------------------------------------
292
align 4
292
align 4
293
wait_event:                                        ;; EXPORT use
293
wait_event:                                        ;; EXPORT use
294
;info:
294
;info:
295
;   Waiting for the EVENT_SIGNALED flag in a very specific Event
295
;   Waiting for the EVENT_SIGNALED flag in a very specific Event
296
;   (set, presumably, via raise_event)
296
;   (set, presumably, via raise_event)
297
;   When the MANUAL_RESET flag is active, nothing else
297
;   When the MANUAL_RESET flag is active, nothing else
298
;   Otherwise: the flags EVENT_SIGNALED and EVENT_WATCHED for the received event are cleared,
298
;   Otherwise: the flags EVENT_SIGNALED and EVENT_WATCHED for the received event are cleared,
299
;   and, if MANUAL_DESTROY is active, it moves to the ObjList list of the current slot,
299
;   and, if MANUAL_DESTROY is active, it moves to the ObjList list of the current slot,
300
;   and if not active, it is destroyed normally (destroy_event.internal)
300
;   and if not active, it is destroyed normally (destroy_event.internal)
301
;param:
301
;param:
302
;   eax - event
302
;   eax - event
303
;   ebx - uid (for Dummy testing)
303
;   ebx - uid (for Dummy testing)
304
;scratched: ecx,edx,esi
304
;scratched: ecx,edx,esi
305
        call    DummyTest
305
        call    DummyTest
306
        mov     ecx, eax             ; wait_param
306
        mov     ecx, eax             ; wait_param
307
        mov     edx, get_event_alone ; wait_test
307
        mov     edx, get_event_alone ; wait_test
308
        call    Wait_events          ; timeout ignored
308
        call    Wait_events          ; timeout ignored
309
        jmp     wait_finish
309
        jmp     wait_finish
310
;-----------------------------------------------------------------------------
310
;-----------------------------------------------------------------------------
311
align 4
311
align 4
312
wait_event_timeout:
312
wait_event_timeout:
313
;param:
313
;param:
314
;   eax - event
314
;   eax - event
315
;   ebx - uid (for Dummy testing)
315
;   ebx - uid (for Dummy testing)
316
;   ecx - timeout in timer ticks
316
;   ecx - timeout in timer ticks
317
;retval:
317
;retval:
318
;   eax - EVENT handle or 0 if timeout
318
;   eax - EVENT handle or 0 if timeout
319
        call    DummyTest
319
        call    DummyTest
320
        mov     ebx, ecx
320
        mov     ebx, ecx
321
        mov     ecx, eax             ; wait_param
321
        mov     ecx, eax             ; wait_param
322
        mov     edx, get_event_alone ; wait_test
322
        mov     edx, get_event_alone ; wait_test
323
        call    Wait_events_ex
323
        call    Wait_events_ex
324
        test    eax, eax
324
        test    eax, eax
325
        jnz     wait_finish
325
        jnz     wait_finish
326
        ret
326
        ret
327
;-----------------------------------------------------------------------------
327
;-----------------------------------------------------------------------------
328
align 4
328
align 4
329
get_event_ex:                                      ;; f68:14
329
get_event_ex:                                      ;; f68:14
330
;info:
330
;info:
331
;   Waiting for any event in the EventList of the current slot
331
;   Waiting for any event in the EventList of the current slot
332
;   Code event data - copied to application memory (indirectly by edi)
332
;   Code event data - copied to application memory (indirectly by edi)
333
;   When the MANUAL_RESET flag is active, nothing else
333
;   When the MANUAL_RESET flag is active, nothing else
334
;   Otherwise: the flags EVENT_SIGNALED and EVENT_WATCHED for the received event are cleared,
334
;   Otherwise: the flags EVENT_SIGNALED and EVENT_WATCHED for the received event are cleared,
335
;   and, if MANUAL_DESTROY is active, it moves to the ObjList list of the current slot,
335
;   and, if MANUAL_DESTROY is active, it moves to the ObjList list of the current slot,
336
;   and if not active, it is destroyed normally (destroy_event.internal)
336
;   and if not active, it is destroyed normally (destroy_event.internal)
337
;param:
337
;param:
338
;   edi - address in the application code to copy data from EVENT.code
338
;   edi - address in the application code to copy data from EVENT.code
339
;retval:
339
;retval:
340
;   eax - EVENT itself (we will call it a handle)
340
;   eax - EVENT itself (we will call it a handle)
341
;scratched: ebx,ecx,edx,esi,edi
341
;scratched: ebx,ecx,edx,esi,edi
342
        mov     edx, get_event_queue ; wait_test
342
        mov     edx, get_event_queue ; wait_test
343
        call    Wait_events          ; timeout ignored
343
        call    Wait_events          ; timeout ignored
344
        lea     esi, [eax+EVENT.code]
344
        lea     esi, [eax+EVENT.code]
345
        mov     ecx, (sizeof.EVENT-EVENT.code)/4
345
        mov     ecx, (sizeof.EVENT-EVENT.code)/4
346
        cld
346
        cld
347
        rep movsd
347
        rep movsd
348
        mov     byte[edi-(sizeof.EVENT-EVENT.code)+2], cl;clear priority field
348
        mov     byte[edi-(sizeof.EVENT-EVENT.code)+2], cl;clear priority field
349
;--------------------------------------
349
;--------------------------------------
350
align 4
350
align 4
351
wait_finish:
351
wait_finish:
352
        test    byte[eax+EVENT.state+3], MANUAL_RESET shr 24
352
        test    byte[eax+EVENT.state+3], MANUAL_RESET shr 24
353
        jnz     get_event_queue.ret  ; RET
353
        jnz     get_event_queue.ret  ; RET
354
        and     byte[eax+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24)
354
        and     byte[eax+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24)
355
        test    byte[eax+EVENT.state+3], MANUAL_DESTROY shr 24
355
        test    byte[eax+EVENT.state+3], MANUAL_DESTROY shr 24
356
        jz      destroy_event.internal
356
        jz      destroy_event.internal
357
        mov     ebx, [current_slot]
357
        mov     ebx, [current_slot]
358
        add     ebx, APP_OBJ_OFFSET
358
        add     ebx, APP_OBJ_OFFSET
359
        pushfd
359
        pushfd
360
        cli
360
        cli
361
        jmp     RemoveEventTo
361
        jmp     RemoveEventTo
362
;-----------------------------------------------------------------------------
362
;-----------------------------------------------------------------------------
363
align 4
363
align 4
364
destroy_event:                                     ;; EXPORT use
364
destroy_event:                                     ;; EXPORT use
365
;info:
365
;info:
366
;   Move EVENT to the FreeEvents list, clear the magic, destroy, pid, id fields
366
;   Move EVENT to the FreeEvents list, clear the magic, destroy, pid, id fields
367
;param:
367
;param:
368
;   eax - event
368
;   eax - event
369
;   ebx - uid (for Dummy testing)
369
;   ebx - uid (for Dummy testing)
370
;retval:
370
;retval:
371
;   eax - address of EVENT object (=0 => fail)
371
;   eax - address of EVENT object (=0 => fail)
372
;scratched: ebx,ecx
372
;scratched: ebx,ecx
373
        call    DummyTest ; not returned for fail !!!
373
        call    DummyTest ; not returned for fail !!!
374
;--------------------------------------
374
;--------------------------------------
375
align 4
375
align 4
376
.internal:
376
.internal:
377
        xor     ecx, ecx  ; clear common header
377
        xor     ecx, ecx  ; clear common header
378
        pushfd
378
        pushfd
379
        cli
379
        cli
380
        mov     [eax+EVENT.magic], ecx
380
        mov     [eax+EVENT.magic], ecx
381
        mov     [eax+EVENT.destroy], ecx
381
        mov     [eax+EVENT.destroy], ecx
382
        mov     [eax+EVENT.pid], ecx
382
        mov     [eax+EVENT.pid], ecx
383
        mov     [eax+EVENT.id], ecx
383
        mov     [eax+EVENT.id], ecx
384
        mov     ebx, FreeEvents
384
        mov     ebx, FreeEvents
385
        jmp     RemoveEventTo
385
        jmp     RemoveEventTo
386
;-----------------------------------------------------------------------------
386
;-----------------------------------------------------------------------------
387
align 4
387
align 4
388
get_event_queue:
388
get_event_queue:
389
;info:
389
;info:
390
;   client testing function for get_event_ex
390
;   client testing function for get_event_ex
391
;warning:
391
;warning:
392
;  -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot
392
;  -don't use [TASK_BASE],[current_slot],[current_slot_idx] - it is not for your slot
393
;  -may be assumed, that interrupt are disabled
393
;  -may be assumed, that interrupt are disabled
394
;  -it is not restriction for scratched registers
394
;  -it is not restriction for scratched registers
395
;param:
395
;param:
396
;   ebx - APPDATA address of testing slot
396
;   ebx - APPDATA address of testing slot
397
;retval:
397
;retval:
398
;   eax - address of EVENT object (=0 => fail)
398
;   eax - address of EVENT object (=0 => fail)
399
        add     ebx, APP_EV_OFFSET
399
        add     ebx, APP_EV_OFFSET
400
        mov     eax, [ebx+APPOBJ.bk] ; we choose from the end, according to the FIFO principle
400
        mov     eax, [ebx+APPOBJ.bk] ; we choose from the end, according to the FIFO principle
401
        cmp     eax, ebx ; empty ???
401
        cmp     eax, ebx ; empty ???
402
        je      get_event_alone.ret0
402
        je      get_event_alone.ret0
403
;--------------------------------------
403
;--------------------------------------
404
align 4
404
align 4
405
.ret:
405
.ret:
406
        ret
406
        ret
407
;-----------------------------------------------------------------------------
407
;-----------------------------------------------------------------------------
408
align 4
408
align 4
409
get_event_alone:
409
get_event_alone:
410
;info:
410
;info:
411
;   client testing function for wait_event
411
;   client testing function for wait_event
412
;warning:
412
;warning:
413
;  -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot
413
;  -don't use [TASK_BASE],[current_slot],[current_slot_idx] - it is not for your slot
414
;  -may be assumed, that interrupt are disabled
414
;  -may be assumed, that interrupt are disabled
415
;  -it is not restriction for scratched registers
415
;  -it is not restriction for scratched registers
416
;param:
416
;param:
417
;   ebx - APPDATA address of testing slot
417
;   ebx - APPDATA address of testing slot
418
;retval:
418
;retval:
419
;   eax - address of EVENT object (=0 => fail)
419
;   eax - address of EVENT object (=0 => fail)
420
        mov     eax, [ebx+APPDATA.wait_param]
420
        mov     eax, [ebx+APPDATA.wait_param]
421
        test    byte[eax+EVENT.state+3], EVENT_SIGNALED shr 24
421
        test    byte[eax+EVENT.state+3], EVENT_SIGNALED shr 24
422
        jnz     .ret
422
        jnz     .ret
423
        or      byte[eax+EVENT.state+3], EVENT_WATCHED shr 24
423
        or      byte[eax+EVENT.state+3], EVENT_WATCHED shr 24
424
;--------------------------------------
424
;--------------------------------------
425
align 4
425
align 4
426
.ret0:
426
.ret0:
427
        xor     eax, eax; NO event!!!
427
        xor     eax, eax; NO event!!!
428
;--------------------------------------
428
;--------------------------------------
429
align 4
429
align 4
430
.ret:
430
.ret:
431
        ret
431
        ret
432
;-----------------------------------------------------------------------------
432
;-----------------------------------------------------------------------------
433
align 4
433
align 4
434
sys_sendwindowmsg:                                 ;; f72
434
sys_sendwindowmsg:                                 ;; f72
435
        dec     ebx
435
        dec     ebx
436
        jnz     .ret ;subfunction==1 ?
436
        jnz     .ret ;subfunction==1 ?
437
        pushfd
437
        pushfd
438
        cli
438
        cli
439
        sub     ecx, 2
439
        sub     ecx, 2
440
        je      .sendkey
440
        je      .sendkey
441
        dec     ecx
441
        dec     ecx
442
        jnz     .retf
442
        jnz     .retf
443
;--------------------------------------
443
;--------------------------------------
444
align 4
444
align 4
445
.sendbtn:
445
.sendbtn:
446
        cmp     byte[BTN_COUNT], 1
446
        cmp     byte[BTN_COUNT], 1
447
        jae     .result ;overflow
447
        jae     .result ;overflow
448
        inc     byte[BTN_COUNT]
448
        inc     byte[BTN_COUNT]
449
        shl     edx, 8
449
        shl     edx, 8
450
        mov     [BTN_BUFF], edx
450
        mov     [BTN_BUFF], edx
451
        jmp     .result
451
        jmp     .result
452
;--------------------------------------
452
;--------------------------------------
453
align 4
453
align 4
454
.sendkey:
454
.sendkey:
455
        movzx   eax, byte[KEY_COUNT]
455
        movzx   eax, byte[KEY_COUNT]
456
        cmp     al, 120
456
        cmp     al, 120
457
        jae     .result ;overflow
457
        jae     .result ;overflow
458
        inc     byte[KEY_COUNT]
458
        inc     byte[KEY_COUNT]
459
        mov     [KEY_BUFF+eax], dl
459
        mov     [KEY_BUFF+eax], dl
460
; store empty scancode
460
; store empty scancode
461
        add     eax, 120+2
461
        add     eax, 120+2
462
        mov     [KEY_BUFF+eax], byte 0
462
        mov     [KEY_BUFF+eax], byte 0
463
        sub     eax, 120+2
463
        sub     eax, 120+2
464
;--------------------------------------
464
;--------------------------------------
465
align 4
465
align 4
466
.result:
466
.result:
467
        setae   byte[esp+32+4] ;we consider that initially was: dword[esp+32+4]==72
467
        setae   byte[esp+32+4] ;we consider that initially was: dword[esp+32+4]==72
468
;--------------------------------------
468
;--------------------------------------
469
align 4
469
align 4
470
.retf:
470
.retf:
471
        popfd
471
        popfd
472
;--------------------------------------
472
;--------------------------------------
473
align 4
473
align 4
474
.ret:
474
.ret:
475
        ret
475
        ret
476
;-----------------------------------------------------------------------------
476
;-----------------------------------------------------------------------------
477
align 4
477
align 4
478
sys_getevent:                                      ;; f11
478
sys_getevent:                                      ;; f11
479
        mov     ebx, [current_slot]  ;now this is a question, what where to put......
479
        mov     ebx, [current_slot]  ;now this is a question, what where to put......
480
        pushfd  ; this is a consequence of the general concept: let the test function have
480
        pushfd  ; this is a consequence of the general concept: let the test function have
481
        cli     ; the right to hope to disable interrupts, as when called from shed
481
        cli     ; the right to hope to disable interrupts, as when called from shed
482
        call    get_event_for_app
482
        call    get_event_for_app
483
        popfd
483
        popfd
484
        mov     [esp+32], eax
484
        mov     [esp+32], eax
485
        ret
485
        ret
486
;-----------------------------------------------------------------------------
486
;-----------------------------------------------------------------------------
487
align 4
487
align 4
488
sys_waitforevent:                                  ;; f10
488
sys_waitforevent:                                  ;; f10
489
        or      ebx, -1; infinite timeout
489
        or      ebx, -1; infinite timeout
490
;--------------------------------------
490
;--------------------------------------
491
align 4
491
align 4
492
sys_wait_event_timeout:                            ;; f23
492
sys_wait_event_timeout:                            ;; f23
493
        call    unprotect_from_terminate
493
        call    unprotect_from_terminate
494
        mov     edx, get_event_for_app; wait_test
494
        mov     edx, get_event_for_app; wait_test
495
        call    Wait_events_ex        ; ebx - timeout
495
        call    Wait_events_ex        ; ebx - timeout
496
        mov     [esp+32], eax
496
        mov     [esp+32], eax
497
        call    protect_from_terminate
497
        call    protect_from_terminate
498
        ret
498
        ret
499
;-----------------------------------------------------------------------------
499
;-----------------------------------------------------------------------------
500
align 4
500
align 4
501
get_event_for_app:                                 ;; used from f10,f11,f23
501
get_event_for_app:                                 ;; used from f10,f11,f23
502
;info:
502
;info:
503
;   client testing function for applications (f10,f23)
503
;   client testing function for applications (f10,f23)
504
;warning:
504
;warning:
505
;  -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot
505
;  -don't use [TASK_BASE],[current_slot],[current_slot_idx] - it is not for your slot
506
;  -may be assumed, that interrupt are disabled
506
;  -may be assumed, that interrupt are disabled
507
;  -it is not restriction for scratched registers
507
;  -it is not restriction for scratched registers
508
;param:
508
;param:
509
;   ebx - APPDATA address of testing slot
509
;   ebx - APPDATA address of testing slot
510
;retval:
510
;retval:
511
;   eax - event number (=0 => no events)
511
;   eax - event number (=0 => no events)
512
        movzx   edi, bh               ; bh  is assumed as [CURRENT_TASK]
512
        movzx   edi, bh               ; bh  is assumed as [current_slot_idx]
513
        shl     edi, 5
513
        shl     edi, 5
514
        add     edi, CURRENT_TASK     ; edi is assumed as [TASK_BASE]
514
        add     edi, TASK_TABLE     ; edi is assumed as [TASK_BASE]
515
        mov     ecx, [edi+TASKDATA.event_mask]
515
        mov     ecx, [edi+TASKDATA.event_mask]
516
        and     ecx, 0x7FFFFFFF
516
        and     ecx, 0x7FFFFFFF
517
;--------------------------------------
517
;--------------------------------------
518
align 4
518
align 4
519
.loop: ; until we run out all the bits of the mask
519
.loop: ; until we run out all the bits of the mask
520
        bsr     eax, ecx       ; find a non-zero bit of the mask (31 -> 0)
520
        bsr     eax, ecx       ; find a non-zero bit of the mask (31 -> 0)
521
        jz      .no_events     ; ran out all the bits of the mask but found nothing ???
521
        jz      .no_events     ; ran out all the bits of the mask but found nothing ???
522
        btr     ecx, eax       ; clear the current checking bit of the mask
522
        btr     ecx, eax       ; clear the current checking bit of the mask
523
       ; go to the handler of this (eax) bit
523
       ; go to the handler of this (eax) bit
524
        cmp     eax, 10
524
        cmp     eax, 10
525
        jae     .loop          ; eax=[10..31], ignored (event 11...32)
525
        jae     .loop          ; eax=[10..31], ignored (event 11...32)
526
 
526
 
527
        cmp     eax, 3
527
        cmp     eax, 3
528
        je      .loop          ; eax=3, ignored (event 4)
528
        je      .loop          ; eax=3, ignored (event 4)
529
 
529
 
530
        cmp     eax, 4
530
        cmp     eax, 4
531
        je      .FlagAutoReset  ; eax=4, retvals=eax+1 (event 5)
531
        je      .FlagAutoReset  ; eax=4, retvals=eax+1 (event 5)
532
 
532
 
533
        cmp     eax, 5
533
        cmp     eax, 5
534
        je      .mouse_check  ; eax=5, retvals=eax+1 (event 6)
534
        je      .mouse_check  ; eax=5, retvals=eax+1 (event 6)
535
 
535
 
536
        ja      .FlagAutoReset ; eax=[6..9], retvals=eax+1 (event 7...10)
536
        ja      .FlagAutoReset ; eax=[6..9], retvals=eax+1 (event 7...10)
537
 
537
 
538
        cmp     eax, 1
538
        cmp     eax, 1
539
        jae     .BtKy          ; eax=[1,2],  retvals=eax+1 (event 2,3)
539
        jae     .BtKy          ; eax=[1,2],  retvals=eax+1 (event 2,3)
540
;--------------------------------------
540
;--------------------------------------
541
align 4
541
align 4
542
.WndRedraw:                    ; eax=0, retval WndRedraw=1
542
.WndRedraw:                    ; eax=0, retval WndRedraw=1
543
        cmp     [edi-twdw+WDATA.fl_redraw], al;al==0
543
        cmp     [edi-twdw+WDATA.fl_redraw], al;al==0
544
        jne     .result
544
        jne     .result
545
        jmp     .loop
545
        jmp     .loop
546
;--------------------------------------
546
;--------------------------------------
547
align 4
547
align 4
548
.no_events:
548
.no_events:
549
        xor     eax, eax
549
        xor     eax, eax
550
        ret
550
        ret
551
;--------------------------------------
551
;--------------------------------------
552
align 4
552
align 4
553
.mouse_check:    ; Mouse 5+1=6
553
.mouse_check:    ; Mouse 5+1=6
554
        push    eax
554
        push    eax
555
        mov     eax, [TASK_BASE]
555
        mov     eax, [TASK_BASE]
556
        mov     eax, [eax + TASKDATA.event_mask]
556
        mov     eax, [eax + TASKDATA.event_mask]
557
        test    eax, 0x80000000 ; bit 31: active/inactive filter f.40
557
        test    eax, 0x80000000 ; bit 31: active/inactive filter f.40
558
        jz      @f
558
        jz      @f
559
        pop     eax
559
        pop     eax
560
        jmp     .FlagAutoReset
560
        jmp     .FlagAutoReset
561
;--------------------------------------
561
;--------------------------------------
562
align 4
562
align 4
563
@@:
563
@@:
564
; If the window is captured and moved by the user, then no mouse events!!!
564
; If the window is captured and moved by the user, then no mouse events!!!
565
        mov     al, [mouse.active_sys_window.action]
565
        mov     al, [mouse.active_sys_window.action]
566
        and     al, WINDOW_MOVE_AND_RESIZE_FLAGS
566
        and     al, WINDOW_MOVE_AND_RESIZE_FLAGS
567
        test    al, al
567
        test    al, al
568
        pop     eax
568
        pop     eax
569
        jnz     .loop
569
        jnz     .loop
570
;--------------------------------------
570
;--------------------------------------
571
align 4
571
align 4
572
.FlagAutoReset: ; retvals: BgrRedraw=5, IPC=7, Stack=8, Debug=9
572
.FlagAutoReset: ; retvals: BgrRedraw=5, IPC=7, Stack=8, Debug=9
573
        btr     [ebx+APPDATA.occurred_events], eax
573
        btr     [ebx+APPDATA.occurred_events], eax
574
        jnc     .loop
574
        jnc     .loop
575
;--------------------------------------
575
;--------------------------------------
576
align 4
576
align 4
577
.result:      ; retval = eax+1
577
.result:      ; retval = eax+1
578
        inc     eax
578
        inc     eax
579
        ret
579
        ret
580
;--------------------------------------
580
;--------------------------------------
581
align 4
581
align 4
582
.BtKy:
582
.BtKy:
583
        movzx   edx, bh
583
        movzx   edx, bh
584
        movzx   edx, word[WIN_STACK+edx*2]
584
        movzx   edx, word[WIN_STACK+edx*2]
585
        je      .Keys          ; eax=1, retval Keys=2
585
        je      .Keys          ; eax=1, retval Keys=2
586
;--------------------------------------
586
;--------------------------------------
587
align 4
587
align 4
588
.Buttons:                      ; eax=2, retval Buttons=3
588
.Buttons:                      ; eax=2, retval Buttons=3
589
        cmp     byte[BTN_COUNT], 0
589
        cmp     byte[BTN_COUNT], 0
590
        je      .loop          ; empty ???
590
        je      .loop          ; empty ???
591
        cmp     edx, [thread_count]
591
        cmp     edx, [thread_count]
592
        jne     .loop          ; not Top ???
592
        jne     .loop          ; not Top ???
593
        mov     edx, [BTN_BUFF]
593
        mov     edx, [BTN_BUFF]
594
        shr     edx, 8
594
        shr     edx, 8
595
        cmp     edx, 0xFFFF    ;-ID for Minimize-Button of Form
595
        cmp     edx, 0xFFFF    ;-ID for Minimize-Button of Form
596
        jne     .result
596
        jne     .result
597
        mov     [window_minimize], 1
597
        mov     [window_minimize], 1
598
        call    wakeup_osloop
598
        call    wakeup_osloop
599
        dec     byte[BTN_COUNT]
599
        dec     byte[BTN_COUNT]
600
        jmp     .loop
600
        jmp     .loop
601
;--------------------------------------
601
;--------------------------------------
602
align 4
602
align 4
603
.Keys:    ; eax==1
603
.Keys:    ; eax==1
604
        cmp     edx, [thread_count]
604
        cmp     edx, [thread_count]
605
        jne     @f             ; not Top ???
605
        jne     @f             ; not Top ???
606
        cmp     [KEY_COUNT], al; al==1
606
        cmp     [KEY_COUNT], al; al==1
607
        jae     .result        ; not empty ???
607
        jae     .result        ; not empty ???
608
;--------------------------------------
608
;--------------------------------------
609
align 4
609
align 4
610
@@:
610
@@:
611
        mov     edx, hotkey_buffer
611
        mov     edx, hotkey_buffer
612
;--------------------------------------
612
;--------------------------------------
613
align 4
613
align 4
614
@@:
614
@@:
615
        cmp     [edx], bh      ; bh - slot for testing
615
        cmp     [edx], bh      ; bh - slot for testing
616
        je      .result
616
        je      .result
617
        add     edx, 8
617
        add     edx, 8
618
        cmp     edx, hotkey_buffer+120*8
618
        cmp     edx, hotkey_buffer+120*8
619
        jb      @b
619
        jb      @b
620
        jmp     .loop
620
        jmp     .loop
621
;end.
621
;end.
622
;-----------------------------------------------------------------------------
622
;-----------------------------------------------------------------------------