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