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