Subversion Repositories Kolibri OS

Rev

Rev 3539 | Rev 3565 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2288 clevermous 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2455 mario79 3
;; Copyright (C) KolibriOS team 2004-2012. 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: 3545 $
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
3539 clevermous 24
FreeEvents = event_start-EVENT.fd    ; "виртуальный" event, используются только поля:
25
                                     ;  FreeEvents.fd=event_start и 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
32
      ; eax - current event, ebx - previos event below
33
        mov     ecx, EV_SPACE        ; current - in allocated space
3539 clevermous 34
        mov     ebx, FreeEvents      ; previos - начало списка
35
        push    ebx                  ; оно же и конец потом будет
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
3539 clevermous 44
        pop     eax                  ; вот оно концом и стало
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
;-----------------------------------------------------------------------------
3539 clevermous 52
EVENT_WATCHED    equ 0x10000000 ;бит 28
53
EVENT_SIGNALED   equ 0x20000000 ;бит 29
54
MANUAL_RESET     equ 0x40000000 ;бит 30
55
MANUAL_DESTROY   equ 0x80000000 ;бит 31
2513 mario79 56
;-----------------------------------------------------------------------------
2288 clevermous 57
align 4
58
create_event:                                      ;; EXPORT use
59
;info:
3539 clevermous 60
;   Переносим EVENT из списка FreeEvents в список ObjList текущего слота
61
;   EVENT.state устанавливаем из ecx, EVENT.code косвенно из esi (если 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
71
        mov     edx, [TASK_BASE]
72
        mov     edx, [edx+TASKDATA.pid]
73
        pushfd
74
        cli
2513 mario79 75
;--------------------------------------
76
align 4
2288 clevermous 77
set_event:                                         ;; INTERNAL use !!! don't use for Call
78
;info:
3539 clevermous 79
;   Берем новый event из FreeEvents, заполняем его поля, как указано в ecx,edx,esi
80
;   и устанавливаем в список, указанный в ebx.
81
;   Возвращаем сам event (в eax), и его uid (в 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]
107
        Mov     [eax+EVENT.id],edx,[event_uid]
108
        or      esi, esi
109
        jz      RemoveEventTo
110
        lea     edi, [eax+EVENT.code]
2384 hidnplayr 111
        mov     ecx, (sizeof.EVENT -EVENT.code)/4
2288 clevermous 112
        cld
113
        rep movsd
2513 mario79 114
;--------------------------------------
115
align 4
2288 clevermous 116
RemoveEventTo:                                     ;; INTERNAL use !!! don't use for Call
117
;param:
3539 clevermous 118
;   eax - указатель на event, КОТОРЫЙ вставляем
119
;   ebx - указатель на event, ПОСЛЕ которого вставляем
2288 clevermous 120
;scratched: ebx,ecx
121
        mov     ecx, eax             ; ecx=eax=Self,      ebx=NewLeft
122
        xchg    ecx, [ebx+EVENT.fd]  ; NewLeft.fd=Self,   ecx=NewRight
3539 clevermous 123
        cmp     eax, ecx             ; стоп, себе думаю...
124
        je      .break               ; - а не дурак ли я?
2288 clevermous 125
        mov     [ecx+EVENT.bk], eax  ; NewRight.bk=Self
126
        xchg    ebx, [eax+EVENT.bk]  ; Self.bk=NewLeft,   ebx=OldLeft
127
        xchg    ecx, [eax+EVENT.fd]  ; Self.fd=NewRight,  ecx=OldRight
128
        mov     [ebx+EVENT.fd], ecx  ; OldLeft.fd=OldRight
129
        mov     [ecx+EVENT.bk], ebx  ; OldRight.bk=OldLeft
2513 mario79 130
;--------------------------------------
131
align 4
2288 clevermous 132
.break:
133
        popfd
134
        ret
2513 mario79 135
;-----------------------------------------------------------------------------
2288 clevermous 136
align 4
137
NotDummyTest:                                      ;; INTERNAL use (not returned for fail !!!)
138
        pop     edi
139
        call    DummyTest ; not returned for fail !!!
140
        mov     ebx, eax
141
        mov     eax, [ebx+EVENT.pid]
142
        push    edi
2513 mario79 143
;--------------------------------------
144
align 4
3539 clevermous 145
.small: ; криво как-то...
2288 clevermous 146
        pop     edi
147
        pushfd
148
        cli
149
        call    pid_to_slot ; saved all registers (eax - retval)
150
        shl     eax, 8
151
        jz      RemoveEventTo.break ; POPF+RET
3539 clevermous 152
        jmp     edi ; штатный возврат
2513 mario79 153
;-----------------------------------------------------------------------------
2288 clevermous 154
align 4
155
raise_event:                                       ;; EXPORT use
156
;info:
3539 clevermous 157
;   Устанавливаем данные EVENT.code
158
;   Если там флаг EVENT_SIGNALED уже активен - больше ничего
159
;   Иначе: этот флаг взводится, за исключением случая наличия флага EVENT_WATCHED в edx
160
;   В этом случае EVENT_SIGNALED взводится лишь при наличие EVENT_WATCHED в самом событии
2288 clevermous 161
;param:
162
;   eax - event
163
;   ebx - uid (for Dummy testing)
164
;   edx - flags
165
;   esi - event data (=0 => skip)
166
;scratched: ebx,ecx,esi,edi
167
        call    NotDummyTest ; not returned for fail !!!
168
        or      esi, esi
169
        jz      @f
170
        lea     edi, [ebx+EVENT.code]
2384 hidnplayr 171
        mov     ecx, (sizeof.EVENT -EVENT.code)/4
2288 clevermous 172
        cld
173
        rep movsd
2513 mario79 174
;--------------------------------------
175
align 4
176
@@:
2288 clevermous 177
        test    byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24
178
        jnz     RemoveEventTo.break  ; POPF+RET
179
        bt      edx, 28 ;EVENT_WATCHED
180
        jnc     @f
181
        test    byte[ebx+EVENT.state+3], EVENT_WATCHED shr 24
182
        jz      RemoveEventTo.break  ; POPF+RET
2513 mario79 183
;--------------------------------------
184
align 4
185
@@:
2288 clevermous 186
        or      byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24
187
        add     eax, SLOT_BASE+APP_EV_OFFSET
188
        xchg    eax, ebx
189
        jmp     RemoveEventTo
2513 mario79 190
;-----------------------------------------------------------------------------
2288 clevermous 191
align 4
192
clear_event:                                       ;; EXPORT use
193
;info:
194
;
195
;param:
196
;   eax - event
197
;   ebx - uid (for Dummy testing)
198
;scratched: ebx,ecx
199
        call    NotDummyTest ; not returned for fail !!!
200
        add     eax, SLOT_BASE+APP_OBJ_OFFSET
201
        and     byte[ebx+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24)
202
        xchg    eax, ebx
203
        jmp     RemoveEventTo
2513 mario79 204
;-----------------------------------------------------------------------------
2288 clevermous 205
align 4
206
send_event:                                        ;; EXPORT use
207
;info:
3539 clevermous 208
;   Создает новый EVENT (вытаскивает из списка FreeEvents) в списке EventList
209
;   целевого слота (eax=pid), с данными из esi косвенно, и state=EVENT_SIGNALED
2288 clevermous 210
;param:
211
;   eax - slots pid, to sending new event
212
;   esi - pointer to sending data (in code field of new event)
213
;retval:
214
;   eax - event (=0 => fail)
215
;   edx - uid
216
;warning:
217
;   may be used as CDECL with such prefix...
218
;       mov     esi,[esp+8]
219
;       mov     eax,[esp+4]
220
;   but not as STDCALL :(
221
;scratched: ebx,ecx,esi,edi
222
        mov     edx, eax
223
        call    NotDummyTest.small ; not returned for fail !!!
224
        lea     ebx, [eax+SLOT_BASE+APP_EV_OFFSET]
225
        mov     ecx, EVENT_SIGNALED
226
        jmp     set_event
2513 mario79 227
;-----------------------------------------------------------------------------
2288 clevermous 228
align 4
229
DummyTest:                                         ;; INTERNAL use (not returned for fail !!!)
230
;param:
231
;   eax - event
232
;   ebx - uid (for Dummy testing)
233
        cmp     [eax+EVENT.magic], 'EVNT'
234
        jne     @f
235
        cmp     [eax+EVENT.id], ebx
236
        je      .ret
2513 mario79 237
;--------------------------------------
238
align 4
239
@@:
2288 clevermous 240
        pop     eax
241
        xor     eax, eax
2513 mario79 242
;--------------------------------------
243
align 4
2288 clevermous 244
.ret:
245
        ret
2513 mario79 246
;-----------------------------------------------------------------------------
2288 clevermous 247
align 4
248
Wait_events:
249
        or      ebx, -1; infinite timeout
2513 mario79 250
;--------------------------------------
251
align 4
2288 clevermous 252
Wait_events_ex:
253
;info:
3539 clevermous 254
;   Ожидание "абстрактного" события через перевод слота в 5-ю позицию.
255
;   Абстрактность заключена в том, что факт события определяется функцией APPDATA.wait_test,
256
;   которая задается клиентом и может быть фактически любой.
257
;   Это позволяет shed-у надежно определить факт события, и не совершать "холостых" переключений,
258
;   предназначенных для разборок типа "свой/чужой" внутри задачи.
2288 clevermous 259
;param:
3539 clevermous 260
;   edx - wait_test, клиентская ф-я тестирования (адрес кода)
261
;   ecx - wait_param, дополнительный параметр, возможно необходимый для [wait_test]
2288 clevermous 262
;   ebx - wait_timeout
263
;retval:
3539 clevermous 264
;   eax - результат вызова [wait_test] (=0 => timeout)
2288 clevermous 265
;scratched: esi
266
        mov     esi, [current_slot]
267
        mov     [esi+APPDATA.wait_param], ecx
268
        pushad
3539 clevermous 269
        mov     ebx, esi;пока это вопрос, чего куды сувать..........
270
        pushfd  ; это следствие общей концепции: пусть ф-я тестирования имеет
271
        cli     ; право рассчитывать на закрытые прерывания, как при вызове из shed
2288 clevermous 272
        call    edx
273
        popfd
274
        mov     [esp+28], eax
275
        popad
276
        or      eax, eax
277
        jnz     @f   ;RET
278
        mov     [esi+APPDATA.wait_test], edx
279
        mov     [esi+APPDATA.wait_timeout], ebx
280
        Mov     [esi+APPDATA.wait_begin],eax,[timer_ticks]
281
        mov     eax, [TASK_BASE]
282
        mov     [eax+TASKDATA.state], 5
283
        call    change_task
284
        mov     eax, [esi+APPDATA.wait_param]
2513 mario79 285
;--------------------------------------
286
align 4
287
@@:
2288 clevermous 288
        ret
2513 mario79 289
;-----------------------------------------------------------------------------
2288 clevermous 290
align 4
291
wait_event:                                        ;; EXPORT use
292
;info:
3539 clevermous 293
;   Ожидание флага EVENT_SIGNALED в совершенно конкретном Event
294
;   (устанавливаемого, надо полагать, через raise_event)
295
;   При активном флаге MANUAL_RESET - больше ничего
296
;   Иначе: флаги EVENT_SIGNALED и EVENT_WATCHED у полученного события сбрасываются,
297
;   и, при активном MANUAL_DESTROY - перемещается в список ObjList текущего слота,
298
;   а при не активном - уничтожается штатно (destroy_event.internal)
2288 clevermous 299
;param:
300
;   eax - event
301
;   ebx - uid (for Dummy testing)
302
;scratched: ecx,edx,esi
303
        call    DummyTest
304
        mov     ecx, eax             ; wait_param
305
        mov     edx, get_event_alone ; wait_test
306
        call    Wait_events          ; timeout ignored
307
        jmp     wait_finish
2513 mario79 308
;-----------------------------------------------------------------------------
2288 clevermous 309
align 4
3390 Serge 310
wait_event_timeout:
311
;param:
312
;   eax - event
313
;   ebx - uid (for Dummy testing)
314
;   ecx - timeout in timer ticks
315
;retval:
316
;   eax - EVENT handle or 0 if timeout
317
        call    DummyTest
318
        mov     ebx, ecx
319
        mov     ecx, eax             ; wait_param
320
        mov     edx, get_event_alone ; wait_test
321
        call    Wait_events_ex
3396 clevermous 322
        test    eax, eax
323
        jnz     wait_finish
324
        ret
3390 Serge 325
;-----------------------------------------------------------------------------
326
align 4
2288 clevermous 327
get_event_ex:                                      ;; f68:14
328
;info:
3539 clevermous 329
;   Ожидание любого события в очереди EventList текущего слота
330
;   Данные события code - копируются в память приложения (косвенно по edi)
331
;   При активном флаге MANUAL_RESET - больше ничего
332
;   Иначе: флаги EVENT_SIGNALED и EVENT_WATCHED у полученного события сбрасываются,
333
;   и, при активном MANUAL_DESTROY - перемещается в список ObjList текущего слота,
334
;   а при не активном - уничтожается штатно (destroy_event.internal)
2288 clevermous 335
;param:
3539 clevermous 336
;   edi - адрес в коде приложения для копирования данных из EVENT.code
2288 clevermous 337
;retval:
3539 clevermous 338
;   eax - собственно EVENT (будем называть это его хэндлом)
2288 clevermous 339
;scratched: ebx,ecx,edx,esi,edi
340
        mov     edx, get_event_queue ; wait_test
341
        call    Wait_events          ; timeout ignored
342
        lea     esi, [eax+EVENT.code]
2384 hidnplayr 343
        mov     ecx, (sizeof.EVENT-EVENT.code)/4
2288 clevermous 344
        cld
345
        rep movsd
2384 hidnplayr 346
        mov     byte[edi-(sizeof.EVENT-EVENT.code)+2], cl;clear priority field
2513 mario79 347
;--------------------------------------
348
align 4
2288 clevermous 349
wait_finish:
350
        test    byte[eax+EVENT.state+3], MANUAL_RESET shr 24
351
        jnz     get_event_queue.ret  ; RET
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
354
        jz      destroy_event.internal
355
        mov     ebx, [current_slot]
356
        add     ebx, APP_OBJ_OFFSET
357
        pushfd
358
        cli
359
        jmp     RemoveEventTo
2513 mario79 360
;-----------------------------------------------------------------------------
2288 clevermous 361
align 4
362
destroy_event:                                     ;; EXPORT use
363
;info:
3539 clevermous 364
;   Переносим EVENT в список FreeEvents, чистим поля magic,destroy,pid,id
2288 clevermous 365
;param:
366
;   eax - event
367
;   ebx - uid (for Dummy testing)
368
;retval:
3539 clevermous 369
;   eax - адрес объекта EVENT (=0 => fail)
2288 clevermous 370
;scratched: ebx,ecx
371
        call    DummyTest ; not returned for fail !!!
2513 mario79 372
;--------------------------------------
373
align 4
2288 clevermous 374
.internal:
375
        xor     ecx, ecx  ; clear common header
376
        pushfd
377
        cli
378
        mov     [eax+EVENT.magic], ecx
379
        mov     [eax+EVENT.destroy], ecx
380
        mov     [eax+EVENT.pid], ecx
381
        mov     [eax+EVENT.id], ecx
382
        mov     ebx, FreeEvents
383
        jmp     RemoveEventTo
2513 mario79 384
;-----------------------------------------------------------------------------
2288 clevermous 385
align 4
386
get_event_queue:
387
;info:
3539 clevermous 388
;   клиентская ф-я тестирования для get_event_ex
2288 clevermous 389
;warning:
390
;  -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot
391
;  -may be assumed, that interrupt are disabled
392
;  -it is not restriction for scratched registers
393
;param:
3539 clevermous 394
;   ebx - адрес APPDATA слота тестирования
2288 clevermous 395
;retval:
3539 clevermous 396
;   eax - адрес объекта EVENT (=0 => fail)
2288 clevermous 397
        add     ebx, APP_EV_OFFSET
3539 clevermous 398
        mov     eax, [ebx+APPOBJ.bk] ; выбираем с конца, по принципу FIFO
2288 clevermous 399
        cmp     eax, ebx ; empty ???
400
        je      get_event_alone.ret0
2513 mario79 401
;--------------------------------------
402
align 4
2288 clevermous 403
.ret:
404
        ret
2513 mario79 405
;-----------------------------------------------------------------------------
2288 clevermous 406
align 4
407
get_event_alone:
408
;info:
3539 clevermous 409
;   клиентская ф-я тестирования для wait_event
2288 clevermous 410
;warning:
411
;  -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot
412
;  -may be assumed, that interrupt are disabled
413
;  -it is not restriction for scratched registers
414
;param:
3539 clevermous 415
;   ebx - адрес APPDATA слота тестирования
2288 clevermous 416
;retval:
3539 clevermous 417
;   eax - адрес объекта EVENT (=0 => fail)
2288 clevermous 418
        mov     eax, [ebx+APPDATA.wait_param]
419
        test    byte[eax+EVENT.state+3], EVENT_SIGNALED shr 24
420
        jnz     .ret
421
        or      byte[eax+EVENT.state+3], EVENT_WATCHED shr 24
2513 mario79 422
;--------------------------------------
423
align 4
2288 clevermous 424
.ret0:
425
        xor     eax, eax; NO event!!!
2513 mario79 426
;--------------------------------------
427
align 4
2288 clevermous 428
.ret:
429
        ret
2513 mario79 430
;-----------------------------------------------------------------------------
2288 clevermous 431
align 4
432
sys_sendwindowmsg:                                 ;; f72
433
        dec     ebx
434
        jnz     .ret ;subfunction==1 ?
2508 mario79 435
        pushfd
2288 clevermous 436
        cli
437
        sub     ecx, 2
438
        je      .sendkey
439
        dec     ecx
440
        jnz     .retf
2513 mario79 441
;--------------------------------------
442
align 4
2288 clevermous 443
.sendbtn:
444
        cmp     byte[BTN_COUNT], 1
445
        jae     .result ;overflow
446
        inc     byte[BTN_COUNT]
447
        shl     edx, 8
448
        mov     [BTN_BUFF], edx
449
        jmp     .result
2513 mario79 450
;--------------------------------------
451
align 4
2288 clevermous 452
.sendkey:
453
        movzx   eax, byte[KEY_COUNT]
454
        cmp     al, 120
455
        jae     .result ;overflow
456
        inc     byte[KEY_COUNT]
457
        mov     [KEY_COUNT+1+eax], dl
2513 mario79 458
;--------------------------------------
459
align 4
2288 clevermous 460
.result:
3539 clevermous 461
        setae   byte[esp+32+4] ;считаем, что исходно: dword[esp+32+4]==72
2513 mario79 462
;--------------------------------------
463
align 4
2508 mario79 464
.retf:
465
        popfd
2513 mario79 466
;--------------------------------------
467
align 4
2288 clevermous 468
.ret:
469
        ret
2513 mario79 470
;-----------------------------------------------------------------------------
2288 clevermous 471
align 4
472
sys_getevent:                                      ;; f11
3539 clevermous 473
        mov     ebx, [current_slot];пока это вопрос, чего куды сувать..........
474
        pushfd  ; это следствие общей концепции: пусть ф-я тестирования имеет
475
        cli     ; право рассчитывать на закрытые прерывания, как при вызове из shed
2288 clevermous 476
        call    get_event_for_app
477
        popfd
478
        mov     [esp+32], eax
479
        ret
2513 mario79 480
;-----------------------------------------------------------------------------
2288 clevermous 481
align 4
482
sys_waitforevent:                                  ;; f10
483
        or      ebx, -1; infinite timeout
2513 mario79 484
;--------------------------------------
485
align 4
2288 clevermous 486
sys_wait_event_timeout:                            ;; f23
3303 clevermous 487
        call    unprotect_from_terminate
2288 clevermous 488
        mov     edx, get_event_for_app; wait_test
489
        call    Wait_events_ex        ; ebx - timeout
490
        mov     [esp+32], eax
3303 clevermous 491
        call    protect_from_terminate
2288 clevermous 492
        ret
2513 mario79 493
;-----------------------------------------------------------------------------
2288 clevermous 494
align 4
495
get_event_for_app:                                 ;; used from f10,f11,f23
496
;info:
3539 clevermous 497
;   клиентская ф-я тестирования для приложений (f10,f23)
2288 clevermous 498
;warning:
499
;  -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot
500
;  -may be assumed, that interrupt are disabled
501
;  -it is not restriction for scratched registers
502
;param:
3539 clevermous 503
;   ebx - адрес APPDATA слота тестирования
2288 clevermous 504
;retval:
3539 clevermous 505
;   eax - номер события (=0 => no events)
2288 clevermous 506
        movzx   edi, bh               ; bh  is assumed as [CURRENT_TASK]
507
        shl     edi, 5
508
        add     edi, CURRENT_TASK     ; edi is assumed as [TASK_BASE]
509
        mov     ecx, [edi+TASKDATA.event_mask]
2411 Serge 510
        and     ecx, 0x7FFFFFFF
2513 mario79 511
;--------------------------------------
512
align 4
3539 clevermous 513
.loop: ; пока не исчерпаем все биты маски
514
        bsr     eax, ecx       ; находим ненулевой бит маски (31 -> 0)
515
        jz      .no_events     ; исчерпали все биты маски, но ничего не нашли ???
516
        btr     ecx, eax       ; сбрасываем проверяемый бит маски
517
       ; переходим на обработчик этого (eax) бита
3545 hidnplayr 518
        cmp     eax, 10
519
        jae     .loop          ; eax=[10..31], ignored (event 10...32)
2534 mario79 520
 
2288 clevermous 521
        cmp     eax, 3
2534 mario79 522
        je      .loop          ; eax=3, ignored (event 4)
523
 
524
        cmp     eax, 4
525
        je      .FlagAutoReset  ; eax=4, retvals=eax+1 (event 5)
526
 
527
        cmp     eax, 5
528
        je      .mouse_check  ; eax=5, retvals=eax+1 (event 6)
529
 
3545 hidnplayr 530
        ja      .FlagAutoReset ; eax=[6..9], retvals=eax+1 (event 7...10)
2534 mario79 531
 
2288 clevermous 532
        cmp     eax, 1
2534 mario79 533
        jae     .BtKy          ; eax=[1,2],  retvals=eax+1 (event 2,3)
2513 mario79 534
;--------------------------------------
535
align 4
2288 clevermous 536
.WndRedraw:                    ; eax=0, retval WndRedraw=1
537
        cmp     [edi-twdw+WDATA.fl_redraw], al;al==0
538
        jne     .result
539
        jmp     .loop
2513 mario79 540
;--------------------------------------
541
align 4
542
.no_events:
2288 clevermous 543
        xor     eax, eax
544
        ret
2513 mario79 545
;--------------------------------------
546
align 4
2534 mario79 547
.mouse_check:    ; Mouse 5+1=6
2424 mario79 548
        push    eax
2426 mario79 549
        mov     eax, [TASK_BASE]
550
        mov     eax, [eax + TASKDATA.event_mask]
551
        test    eax, 0x80000000 ; bit 31: active/inactive filter f.40
552
        jz      @f
553
        pop     eax
2534 mario79 554
        jmp     .FlagAutoReset
2513 mario79 555
;--------------------------------------
556
align 4
2426 mario79 557
@@:
2288 clevermous 558
; If the window is captured and moved by the user, then no mouse events!!!
2424 mario79 559
        mov     al, [mouse.active_sys_window.action]
560
        and     al, WINDOW_MOVE_AND_RESIZE_FLAGS
561
        test    al, al
562
        pop     eax
563
        jnz     .loop
2513 mario79 564
;--------------------------------------
565
align 4
2534 mario79 566
.FlagAutoReset: ; retvals: BgrRedraw=5, IPC=7, Stack=8, Debug=9
2288 clevermous 567
        btr     [ebx+APPDATA.event_mask], eax
568
        jnc     .loop
2513 mario79 569
;--------------------------------------
570
align 4
571
.result:      ; retval = eax+1
2288 clevermous 572
        inc     eax
573
        ret
2513 mario79 574
;--------------------------------------
575
align 4
576
.BtKy:
2288 clevermous 577
        movzx   edx, bh
578
        movzx   edx, word[WIN_STACK+edx*2]
579
        je      .Keys          ; eax=1, retval Keys=2
2513 mario79 580
;--------------------------------------
581
align 4
2288 clevermous 582
.Buttons:                      ; eax=2, retval Buttons=3
583
        cmp     byte[BTN_COUNT], 0
584
        je      .loop          ; empty ???
585
        cmp     edx, [TASK_COUNT]
586
        jne     .loop          ; not Top ???
587
        mov     edx, [BTN_BUFF]
588
        shr     edx, 8
589
        cmp     edx, 0xFFFF    ;-ID for Minimize-Button of Form
590
        jne     .result
591
        mov     [window_minimize], 1
3534 clevermous 592
        call    wakeup_osloop
2288 clevermous 593
        dec     byte[BTN_COUNT]
594
        jmp     .loop
2513 mario79 595
;--------------------------------------
596
align 4
2288 clevermous 597
.Keys:    ; eax==1
598
        cmp     edx, [TASK_COUNT]
599
        jne     @f             ; not Top ???
600
        cmp     [KEY_COUNT], al; al==1
601
        jae     .result        ; not empty ???
2513 mario79 602
;--------------------------------------
603
align 4
604
@@:
2288 clevermous 605
        mov     edx, hotkey_buffer
2513 mario79 606
;--------------------------------------
607
align 4
608
@@:
2288 clevermous 609
        cmp     [edx], bh      ; bh - slot for testing
610
        je      .result
611
        add     edx, 8
612
        cmp     edx, hotkey_buffer+120*8
613
        jb      @b
614
        jmp     .loop
615
;end.
3390 Serge 616
;-----------------------------------------------------------------------------