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