Subversion Repositories Kolibri OS

Rev

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

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