2011-10-14 23:38:50 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2021-06-16 12:04:10 +02:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;;
|
2011-10-14 23:38:50 +02:00
|
|
|
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
|
|
|
WINDOW_MOVE_AND_RESIZE_FLAGS = \
|
|
|
|
mouse.WINDOW_RESIZE_N_FLAG + \
|
|
|
|
mouse.WINDOW_RESIZE_W_FLAG + \
|
|
|
|
mouse.WINDOW_RESIZE_S_FLAG + \
|
|
|
|
mouse.WINDOW_RESIZE_E_FLAG + \
|
|
|
|
mouse.WINDOW_MOVE_FLAG
|
|
|
|
|
|
|
|
uglobal
|
|
|
|
align 4
|
|
|
|
event_start dd ?
|
|
|
|
event_end dd ?
|
|
|
|
event_uid dd 0
|
|
|
|
endg
|
|
|
|
EV_SPACE = 512
|
2020-07-16 21:31:16 +02:00
|
|
|
FreeEvents = event_start-EVENT.fd ; "virtual" event, only following field used:
|
|
|
|
; FreeEvents.fd=event_start and FreeEvents.bk=event_end
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
init_events: ;; used from kernel.asm
|
2012-02-23 19:52:13 +01:00
|
|
|
stdcall kernel_alloc, EV_SPACE*sizeof.EVENT
|
2011-10-14 23:38:50 +02:00
|
|
|
or eax, eax
|
|
|
|
jz .fail
|
2020-07-16 21:31:16 +02:00
|
|
|
; eax - current event, ebx - previous event below
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ecx, EV_SPACE ; current - in allocated space
|
2020-07-16 21:31:16 +02:00
|
|
|
mov ebx, FreeEvents ; previous - list beginning
|
|
|
|
push ebx ; it will be the end later
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [ebx+EVENT.fd], eax
|
|
|
|
mov [eax+EVENT.bk], ebx
|
|
|
|
mov ebx, eax ; previos <- current
|
2012-02-23 19:52:13 +01:00
|
|
|
add eax, sizeof.EVENT ; new current
|
2011-10-14 23:38:50 +02:00
|
|
|
loop @b
|
2020-07-16 21:31:16 +02:00
|
|
|
pop eax ; here it became the end
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [ebx+EVENT.fd], eax
|
|
|
|
mov [eax+EVENT.bk], ebx
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.fail:
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2017-12-20 02:07:10 +01:00
|
|
|
EVENT_WATCHED = 0x10000000 ; bit 28
|
|
|
|
EVENT_SIGNALED = 0x20000000 ; bit 29
|
|
|
|
MANUAL_RESET = 0x40000000 ; bit 30
|
|
|
|
MANUAL_DESTROY = 0x80000000 ; bit 31
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
create_event: ;; EXPORT use
|
|
|
|
;info:
|
2020-07-16 21:31:16 +02:00
|
|
|
; Move EVENT from the FreeEvents list to the ObjList list of the current slot;
|
|
|
|
; EVENT.state is set from ecx, EVENT.code indirectly from esi (if esi <> 0)
|
2011-10-14 23:38:50 +02:00
|
|
|
;param:
|
|
|
|
; esi - event data
|
|
|
|
; ecx - flags
|
|
|
|
;retval:
|
|
|
|
; eax - event (=0 => fail)
|
|
|
|
; edx - uid
|
|
|
|
;scratched: ebx,ecx,esi,edi
|
|
|
|
mov ebx, [current_slot]
|
|
|
|
add ebx, APP_OBJ_OFFSET
|
|
|
|
mov edx, [TASK_BASE]
|
|
|
|
mov edx, [edx+TASKDATA.pid]
|
|
|
|
pushfd
|
|
|
|
cli
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
set_event: ;; INTERNAL use !!! don't use for Call
|
|
|
|
;info:
|
2020-07-16 21:31:16 +02:00
|
|
|
; We take a new event from FreeEvents, fill its fields from ecx, edx, esi
|
|
|
|
; and add it to the list, which specified in ebx.
|
|
|
|
; Return event (to eax), and it's uid (to edx)
|
2011-10-14 23:38:50 +02:00
|
|
|
;param:
|
|
|
|
; ebx - start-chain "virtual" event for entry new event Right of him
|
|
|
|
; ecx - flags (copied to EVENT.state)
|
|
|
|
; edx - pid (copied to EVENT.pid)
|
|
|
|
; esi - event data (copied to EVENT.code indirect, =0 => skip)
|
|
|
|
;retval:
|
|
|
|
; eax - event (=0 => fail)
|
|
|
|
; edx - uid
|
|
|
|
;scratched: ebx,ecx,esi,edi
|
|
|
|
mov eax, FreeEvents
|
|
|
|
cmp eax, [eax+EVENT.fd]
|
|
|
|
jne @f ; not empty ???
|
|
|
|
pushad
|
|
|
|
call init_events
|
|
|
|
popad
|
|
|
|
jz RemoveEventTo.break ; POPF+RET
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, [eax+EVENT.fd]
|
|
|
|
mov [eax+EVENT.magic], 'EVNT'
|
|
|
|
mov [eax+EVENT.destroy], destroy_event.internal
|
|
|
|
mov [eax+EVENT.state], ecx
|
|
|
|
mov [eax+EVENT.pid], edx
|
|
|
|
inc [event_uid]
|
2015-09-03 16:52:02 +02:00
|
|
|
mov edx, [event_uid]
|
|
|
|
mov [eax+EVENT.id], edx
|
2011-10-14 23:38:50 +02:00
|
|
|
or esi, esi
|
|
|
|
jz RemoveEventTo
|
|
|
|
lea edi, [eax+EVENT.code]
|
2012-02-23 19:52:13 +01:00
|
|
|
mov ecx, (sizeof.EVENT -EVENT.code)/4
|
2011-10-14 23:38:50 +02:00
|
|
|
cld
|
|
|
|
rep movsd
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
RemoveEventTo: ;; INTERNAL use !!! don't use for Call
|
|
|
|
;param:
|
2020-07-16 21:31:16 +02:00
|
|
|
; eax - pointer to event, WHICH we will insert
|
|
|
|
; ebx - pointer to event, AFTER which we will insert
|
2011-10-14 23:38:50 +02:00
|
|
|
;scratched: ebx,ecx
|
|
|
|
mov ecx, eax ; ecx=eax=Self, ebx=NewLeft
|
|
|
|
xchg ecx, [ebx+EVENT.fd] ; NewLeft.fd=Self, ecx=NewRight
|
2020-07-16 21:31:16 +02:00
|
|
|
cmp eax, ecx ; stop, I think...
|
|
|
|
je .break ; - am I not a fool?
|
2011-10-14 23:38:50 +02:00
|
|
|
mov [ecx+EVENT.bk], eax ; NewRight.bk=Self
|
|
|
|
xchg ebx, [eax+EVENT.bk] ; Self.bk=NewLeft, ebx=OldLeft
|
|
|
|
xchg ecx, [eax+EVENT.fd] ; Self.fd=NewRight, ecx=OldRight
|
|
|
|
mov [ebx+EVENT.fd], ecx ; OldLeft.fd=OldRight
|
|
|
|
mov [ecx+EVENT.bk], ebx ; OldRight.bk=OldLeft
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.break:
|
|
|
|
popfd
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
NotDummyTest: ;; INTERNAL use (not returned for fail !!!)
|
|
|
|
pop edi
|
|
|
|
call DummyTest ; not returned for fail !!!
|
|
|
|
mov ebx, eax
|
|
|
|
mov eax, [ebx+EVENT.pid]
|
|
|
|
push edi
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2020-07-16 21:31:16 +02:00
|
|
|
.small: ; somehow ugly...
|
2011-10-14 23:38:50 +02:00
|
|
|
pop edi
|
|
|
|
pushfd
|
|
|
|
cli
|
|
|
|
call pid_to_slot ; saved all registers (eax - retval)
|
|
|
|
shl eax, 8
|
|
|
|
jz RemoveEventTo.break ; POPF+RET
|
2020-07-16 21:31:16 +02:00
|
|
|
jmp edi ; normal return
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
raise_event: ;; EXPORT use
|
|
|
|
;info:
|
2020-07-16 21:31:16 +02:00
|
|
|
; Setting up EVENT.code data
|
|
|
|
; If is has flag EVENT_SIGNALED activated - nothing else
|
|
|
|
; Otherwise: activate this flag, except when the EVENT_WATCHED flag is present in edx
|
|
|
|
; In this case EVENT_SIGNALED will activated only if EVENT_WATCHED presents in the event itself
|
2011-10-14 23:38:50 +02:00
|
|
|
;param:
|
|
|
|
; eax - event
|
|
|
|
; ebx - uid (for Dummy testing)
|
|
|
|
; edx - flags
|
|
|
|
; esi - event data (=0 => skip)
|
|
|
|
;scratched: ebx,ecx,esi,edi
|
|
|
|
call NotDummyTest ; not returned for fail !!!
|
|
|
|
or esi, esi
|
|
|
|
jz @f
|
|
|
|
lea edi, [ebx+EVENT.code]
|
2012-02-23 19:52:13 +01:00
|
|
|
mov ecx, (sizeof.EVENT -EVENT.code)/4
|
2011-10-14 23:38:50 +02:00
|
|
|
cld
|
|
|
|
rep movsd
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
test byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24
|
|
|
|
jnz RemoveEventTo.break ; POPF+RET
|
|
|
|
bt edx, 28 ;EVENT_WATCHED
|
|
|
|
jnc @f
|
|
|
|
test byte[ebx+EVENT.state+3], EVENT_WATCHED shr 24
|
|
|
|
jz RemoveEventTo.break ; POPF+RET
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
or byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24
|
|
|
|
add eax, SLOT_BASE+APP_EV_OFFSET
|
|
|
|
xchg eax, ebx
|
|
|
|
jmp RemoveEventTo
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
clear_event: ;; EXPORT use
|
|
|
|
;info:
|
|
|
|
;
|
|
|
|
;param:
|
|
|
|
; eax - event
|
|
|
|
; ebx - uid (for Dummy testing)
|
|
|
|
;scratched: ebx,ecx
|
|
|
|
call NotDummyTest ; not returned for fail !!!
|
|
|
|
add eax, SLOT_BASE+APP_OBJ_OFFSET
|
|
|
|
and byte[ebx+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24)
|
|
|
|
xchg eax, ebx
|
|
|
|
jmp RemoveEventTo
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
send_event: ;; EXPORT use
|
|
|
|
;info:
|
2020-07-16 21:31:16 +02:00
|
|
|
; Creates a new EVENT (pulls from the FreeEvents list) in the EventList list
|
|
|
|
; of target slot (eax=pid), with data from esi indirectly, and state=EVENT_SIGNALED
|
2011-10-14 23:38:50 +02:00
|
|
|
;param:
|
|
|
|
; eax - slots pid, to sending new event
|
|
|
|
; esi - pointer to sending data (in code field of new event)
|
|
|
|
;retval:
|
|
|
|
; eax - event (=0 => fail)
|
|
|
|
; edx - uid
|
|
|
|
;warning:
|
|
|
|
; may be used as CDECL with such prefix...
|
|
|
|
; mov esi,[esp+8]
|
|
|
|
; mov eax,[esp+4]
|
|
|
|
; but not as STDCALL :(
|
|
|
|
;scratched: ebx,ecx,esi,edi
|
|
|
|
mov edx, eax
|
|
|
|
call NotDummyTest.small ; not returned for fail !!!
|
|
|
|
lea ebx, [eax+SLOT_BASE+APP_EV_OFFSET]
|
|
|
|
mov ecx, EVENT_SIGNALED
|
|
|
|
jmp set_event
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
DummyTest: ;; INTERNAL use (not returned for fail !!!)
|
|
|
|
;param:
|
|
|
|
; eax - event
|
|
|
|
; ebx - uid (for Dummy testing)
|
|
|
|
cmp [eax+EVENT.magic], 'EVNT'
|
|
|
|
jne @f
|
|
|
|
cmp [eax+EVENT.id], ebx
|
|
|
|
je .ret
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
pop eax
|
|
|
|
xor eax, eax
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.ret:
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
Wait_events:
|
|
|
|
or ebx, -1; infinite timeout
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
Wait_events_ex:
|
|
|
|
;info:
|
2020-07-16 21:31:16 +02:00
|
|
|
; Waiting for an "abstract" event by moving the slot to the 5th position.
|
|
|
|
; Abstractness lies in the fact, that the fact of an event is determined by the APPDATA.wait_test function,
|
|
|
|
; which is set by the client and can be actually anything.
|
|
|
|
; This allows the shed to reliably determine the fact of the event, and not make "idle" switches,
|
|
|
|
; intended for showdowns like "friend / foe" within the problem.
|
2011-10-14 23:38:50 +02:00
|
|
|
;param:
|
2020-07-16 21:31:16 +02:00
|
|
|
; edx - wait_test, client testing function (code address)
|
|
|
|
; ecx - wait_param, additional parameter, possibly needed for [wait_test]
|
2011-10-14 23:38:50 +02:00
|
|
|
; ebx - wait_timeout
|
|
|
|
;retval:
|
2020-07-16 21:31:16 +02:00
|
|
|
; eax - call result [wait_test] (=0 => timeout)
|
2011-10-14 23:38:50 +02:00
|
|
|
;scratched: esi
|
|
|
|
mov esi, [current_slot]
|
|
|
|
mov [esi+APPDATA.wait_param], ecx
|
|
|
|
pushad
|
2020-07-16 21:31:16 +02:00
|
|
|
mov ebx, esi ;now this is a question, what where to put..........
|
|
|
|
pushfd ; this is a consequence of the general concept: let the test function have
|
|
|
|
cli ; the right to hope to disable interrupts, as when called from shed
|
2011-10-14 23:38:50 +02:00
|
|
|
call edx
|
|
|
|
popfd
|
|
|
|
mov [esp+28], eax
|
|
|
|
popad
|
|
|
|
or eax, eax
|
|
|
|
jnz @f ;RET
|
|
|
|
mov [esi+APPDATA.wait_test], edx
|
|
|
|
mov [esi+APPDATA.wait_timeout], ebx
|
2015-09-03 16:52:02 +02:00
|
|
|
mov eax, [timer_ticks]
|
|
|
|
mov [esi+APPDATA.wait_begin], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, [TASK_BASE]
|
2021-06-19 10:41:09 +02:00
|
|
|
mov [eax+TASKDATA.state], TSTATE_WAITING
|
2011-10-14 23:38:50 +02:00
|
|
|
call change_task
|
|
|
|
mov eax, [esi+APPDATA.wait_param]
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
wait_event: ;; EXPORT use
|
|
|
|
;info:
|
2020-07-16 21:31:16 +02:00
|
|
|
; Waiting for the EVENT_SIGNALED flag in a very specific Event
|
|
|
|
; (set, presumably, via raise_event)
|
|
|
|
; When the MANUAL_RESET flag is active, nothing else
|
|
|
|
; Otherwise: the flags EVENT_SIGNALED and EVENT_WATCHED for the received event are cleared,
|
|
|
|
; and, if MANUAL_DESTROY is active, it moves to the ObjList list of the current slot,
|
|
|
|
; and if not active, it is destroyed normally (destroy_event.internal)
|
2011-10-14 23:38:50 +02:00
|
|
|
;param:
|
|
|
|
; eax - event
|
|
|
|
; ebx - uid (for Dummy testing)
|
|
|
|
;scratched: ecx,edx,esi
|
|
|
|
call DummyTest
|
|
|
|
mov ecx, eax ; wait_param
|
|
|
|
mov edx, get_event_alone ; wait_test
|
|
|
|
call Wait_events ; timeout ignored
|
|
|
|
jmp wait_finish
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
2013-03-19 04:38:52 +01:00
|
|
|
wait_event_timeout:
|
|
|
|
;param:
|
|
|
|
; eax - event
|
|
|
|
; ebx - uid (for Dummy testing)
|
|
|
|
; ecx - timeout in timer ticks
|
|
|
|
;retval:
|
|
|
|
; eax - EVENT handle or 0 if timeout
|
|
|
|
call DummyTest
|
|
|
|
mov ebx, ecx
|
|
|
|
mov ecx, eax ; wait_param
|
|
|
|
mov edx, get_event_alone ; wait_test
|
|
|
|
call Wait_events_ex
|
2013-03-19 23:52:40 +01:00
|
|
|
test eax, eax
|
|
|
|
jnz wait_finish
|
|
|
|
ret
|
2013-03-19 04:38:52 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
get_event_ex: ;; f68:14
|
|
|
|
;info:
|
2020-07-16 21:31:16 +02:00
|
|
|
; Waiting for any event in the EventList of the current slot
|
|
|
|
; Code event data - copied to application memory (indirectly by edi)
|
|
|
|
; When the MANUAL_RESET flag is active, nothing else
|
|
|
|
; Otherwise: the flags EVENT_SIGNALED and EVENT_WATCHED for the received event are cleared,
|
|
|
|
; and, if MANUAL_DESTROY is active, it moves to the ObjList list of the current slot,
|
|
|
|
; and if not active, it is destroyed normally (destroy_event.internal)
|
2011-10-14 23:38:50 +02:00
|
|
|
;param:
|
2020-07-16 21:31:16 +02:00
|
|
|
; edi - address in the application code to copy data from EVENT.code
|
2011-10-14 23:38:50 +02:00
|
|
|
;retval:
|
2020-07-16 21:31:16 +02:00
|
|
|
; eax - EVENT itself (we will call it a handle)
|
2011-10-14 23:38:50 +02:00
|
|
|
;scratched: ebx,ecx,edx,esi,edi
|
|
|
|
mov edx, get_event_queue ; wait_test
|
|
|
|
call Wait_events ; timeout ignored
|
|
|
|
lea esi, [eax+EVENT.code]
|
2012-02-23 19:52:13 +01:00
|
|
|
mov ecx, (sizeof.EVENT-EVENT.code)/4
|
2011-10-14 23:38:50 +02:00
|
|
|
cld
|
|
|
|
rep movsd
|
2012-02-23 19:52:13 +01:00
|
|
|
mov byte[edi-(sizeof.EVENT-EVENT.code)+2], cl;clear priority field
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
wait_finish:
|
|
|
|
test byte[eax+EVENT.state+3], MANUAL_RESET shr 24
|
|
|
|
jnz get_event_queue.ret ; RET
|
|
|
|
and byte[eax+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24)
|
|
|
|
test byte[eax+EVENT.state+3], MANUAL_DESTROY shr 24
|
|
|
|
jz destroy_event.internal
|
|
|
|
mov ebx, [current_slot]
|
|
|
|
add ebx, APP_OBJ_OFFSET
|
|
|
|
pushfd
|
|
|
|
cli
|
|
|
|
jmp RemoveEventTo
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
destroy_event: ;; EXPORT use
|
|
|
|
;info:
|
2020-07-16 21:31:16 +02:00
|
|
|
; Move EVENT to the FreeEvents list, clear the magic, destroy, pid, id fields
|
2011-10-14 23:38:50 +02:00
|
|
|
;param:
|
|
|
|
; eax - event
|
|
|
|
; ebx - uid (for Dummy testing)
|
|
|
|
;retval:
|
2020-07-16 21:31:16 +02:00
|
|
|
; eax - address of EVENT object (=0 => fail)
|
2011-10-14 23:38:50 +02:00
|
|
|
;scratched: ebx,ecx
|
|
|
|
call DummyTest ; not returned for fail !!!
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.internal:
|
|
|
|
xor ecx, ecx ; clear common header
|
|
|
|
pushfd
|
|
|
|
cli
|
|
|
|
mov [eax+EVENT.magic], ecx
|
|
|
|
mov [eax+EVENT.destroy], ecx
|
|
|
|
mov [eax+EVENT.pid], ecx
|
|
|
|
mov [eax+EVENT.id], ecx
|
|
|
|
mov ebx, FreeEvents
|
|
|
|
jmp RemoveEventTo
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
get_event_queue:
|
|
|
|
;info:
|
2020-07-16 21:31:16 +02:00
|
|
|
; client testing function for get_event_ex
|
2011-10-14 23:38:50 +02:00
|
|
|
;warning:
|
2021-06-17 11:41:16 +02:00
|
|
|
; -don't use [TASK_BASE],[current_slot],[current_slot_idx] - it is not for your slot
|
2011-10-14 23:38:50 +02:00
|
|
|
; -may be assumed, that interrupt are disabled
|
|
|
|
; -it is not restriction for scratched registers
|
|
|
|
;param:
|
2020-07-16 21:31:16 +02:00
|
|
|
; ebx - APPDATA address of testing slot
|
2011-10-14 23:38:50 +02:00
|
|
|
;retval:
|
2020-07-16 21:31:16 +02:00
|
|
|
; eax - address of EVENT object (=0 => fail)
|
2011-10-14 23:38:50 +02:00
|
|
|
add ebx, APP_EV_OFFSET
|
2020-07-16 21:31:16 +02:00
|
|
|
mov eax, [ebx+APPOBJ.bk] ; we choose from the end, according to the FIFO principle
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp eax, ebx ; empty ???
|
|
|
|
je get_event_alone.ret0
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.ret:
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
get_event_alone:
|
|
|
|
;info:
|
2020-07-16 21:31:16 +02:00
|
|
|
; client testing function for wait_event
|
2011-10-14 23:38:50 +02:00
|
|
|
;warning:
|
2021-06-17 11:41:16 +02:00
|
|
|
; -don't use [TASK_BASE],[current_slot],[current_slot_idx] - it is not for your slot
|
2011-10-14 23:38:50 +02:00
|
|
|
; -may be assumed, that interrupt are disabled
|
|
|
|
; -it is not restriction for scratched registers
|
|
|
|
;param:
|
2020-07-16 21:31:16 +02:00
|
|
|
; ebx - APPDATA address of testing slot
|
2011-10-14 23:38:50 +02:00
|
|
|
;retval:
|
2020-07-16 21:31:16 +02:00
|
|
|
; eax - address of EVENT object (=0 => fail)
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, [ebx+APPDATA.wait_param]
|
|
|
|
test byte[eax+EVENT.state+3], EVENT_SIGNALED shr 24
|
|
|
|
jnz .ret
|
|
|
|
or byte[eax+EVENT.state+3], EVENT_WATCHED shr 24
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.ret0:
|
|
|
|
xor eax, eax; NO event!!!
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.ret:
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
sys_sendwindowmsg: ;; f72
|
|
|
|
dec ebx
|
|
|
|
jnz .ret ;subfunction==1 ?
|
2012-03-26 22:11:06 +02:00
|
|
|
pushfd
|
2011-10-14 23:38:50 +02:00
|
|
|
cli
|
|
|
|
sub ecx, 2
|
|
|
|
je .sendkey
|
|
|
|
dec ecx
|
|
|
|
jnz .retf
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.sendbtn:
|
|
|
|
cmp byte[BTN_COUNT], 1
|
|
|
|
jae .result ;overflow
|
|
|
|
inc byte[BTN_COUNT]
|
|
|
|
shl edx, 8
|
|
|
|
mov [BTN_BUFF], edx
|
|
|
|
jmp .result
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.sendkey:
|
|
|
|
movzx eax, byte[KEY_COUNT]
|
|
|
|
cmp al, 120
|
|
|
|
jae .result ;overflow
|
|
|
|
inc byte[KEY_COUNT]
|
2014-02-25 02:03:37 +01:00
|
|
|
mov [KEY_BUFF+eax], dl
|
|
|
|
; store empty scancode
|
|
|
|
add eax, 120+2
|
|
|
|
mov [KEY_BUFF+eax], byte 0
|
|
|
|
sub eax, 120+2
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.result:
|
2020-07-16 21:31:16 +02:00
|
|
|
setae byte[esp+32+4] ;we consider that initially was: dword[esp+32+4]==72
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2012-03-26 22:11:06 +02:00
|
|
|
.retf:
|
|
|
|
popfd
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.ret:
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
sys_getevent: ;; f11
|
2020-07-16 21:31:16 +02:00
|
|
|
mov ebx, [current_slot] ;now this is a question, what where to put......
|
|
|
|
pushfd ; this is a consequence of the general concept: let the test function have
|
|
|
|
cli ; the right to hope to disable interrupts, as when called from shed
|
2011-10-14 23:38:50 +02:00
|
|
|
call get_event_for_app
|
|
|
|
popfd
|
|
|
|
mov [esp+32], eax
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
sys_waitforevent: ;; f10
|
|
|
|
or ebx, -1; infinite timeout
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
sys_wait_event_timeout: ;; f23
|
2013-03-01 11:27:19 +01:00
|
|
|
call unprotect_from_terminate
|
2011-10-14 23:38:50 +02:00
|
|
|
mov edx, get_event_for_app; wait_test
|
|
|
|
call Wait_events_ex ; ebx - timeout
|
|
|
|
mov [esp+32], eax
|
2013-03-01 11:27:19 +01:00
|
|
|
call protect_from_terminate
|
2011-10-14 23:38:50 +02:00
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
align 4
|
|
|
|
get_event_for_app: ;; used from f10,f11,f23
|
|
|
|
;info:
|
2020-07-16 21:31:16 +02:00
|
|
|
; client testing function for applications (f10,f23)
|
2011-10-14 23:38:50 +02:00
|
|
|
;warning:
|
2021-06-17 11:41:16 +02:00
|
|
|
; -don't use [TASK_BASE],[current_slot],[current_slot_idx] - it is not for your slot
|
2011-10-14 23:38:50 +02:00
|
|
|
; -may be assumed, that interrupt are disabled
|
|
|
|
; -it is not restriction for scratched registers
|
|
|
|
;param:
|
2020-07-16 21:31:16 +02:00
|
|
|
; ebx - APPDATA address of testing slot
|
2011-10-14 23:38:50 +02:00
|
|
|
;retval:
|
2020-07-16 21:31:16 +02:00
|
|
|
; eax - event number (=0 => no events)
|
2021-06-17 11:41:16 +02:00
|
|
|
movzx edi, bh ; bh is assumed as [current_slot_idx]
|
2011-10-14 23:38:50 +02:00
|
|
|
shl edi, 5
|
2021-06-17 11:41:16 +02:00
|
|
|
add edi, TASK_TABLE ; edi is assumed as [TASK_BASE]
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ecx, [edi+TASKDATA.event_mask]
|
2012-02-27 08:04:31 +01:00
|
|
|
and ecx, 0x7FFFFFFF
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2020-07-16 21:31:16 +02:00
|
|
|
.loop: ; until we run out all the bits of the mask
|
|
|
|
bsr eax, ecx ; find a non-zero bit of the mask (31 -> 0)
|
|
|
|
jz .no_events ; ran out all the bits of the mask but found nothing ???
|
|
|
|
btr ecx, eax ; clear the current checking bit of the mask
|
|
|
|
; go to the handler of this (eax) bit
|
2013-05-28 19:34:26 +02:00
|
|
|
cmp eax, 10
|
2013-05-29 13:46:06 +02:00
|
|
|
jae .loop ; eax=[10..31], ignored (event 11...32)
|
2012-03-31 22:21:39 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp eax, 3
|
2012-03-31 22:21:39 +02:00
|
|
|
je .loop ; eax=3, ignored (event 4)
|
|
|
|
|
|
|
|
cmp eax, 4
|
|
|
|
je .FlagAutoReset ; eax=4, retvals=eax+1 (event 5)
|
|
|
|
|
|
|
|
cmp eax, 5
|
|
|
|
je .mouse_check ; eax=5, retvals=eax+1 (event 6)
|
|
|
|
|
2013-05-28 19:34:26 +02:00
|
|
|
ja .FlagAutoReset ; eax=[6..9], retvals=eax+1 (event 7...10)
|
2012-03-31 22:21:39 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp eax, 1
|
2012-03-31 22:21:39 +02:00
|
|
|
jae .BtKy ; eax=[1,2], retvals=eax+1 (event 2,3)
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.WndRedraw: ; eax=0, retval WndRedraw=1
|
|
|
|
cmp [edi-twdw+WDATA.fl_redraw], al;al==0
|
|
|
|
jne .result
|
|
|
|
jmp .loop
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
.no_events:
|
2011-10-14 23:38:50 +02:00
|
|
|
xor eax, eax
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2012-03-31 22:21:39 +02:00
|
|
|
.mouse_check: ; Mouse 5+1=6
|
2012-03-01 00:27:35 +01:00
|
|
|
push eax
|
2012-03-01 07:28:52 +01:00
|
|
|
mov eax, [TASK_BASE]
|
|
|
|
mov eax, [eax + TASKDATA.event_mask]
|
|
|
|
test eax, 0x80000000 ; bit 31: active/inactive filter f.40
|
|
|
|
jz @f
|
|
|
|
pop eax
|
2012-03-31 22:21:39 +02:00
|
|
|
jmp .FlagAutoReset
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2012-03-01 07:28:52 +01:00
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
; If the window is captured and moved by the user, then no mouse events!!!
|
2012-03-01 00:27:35 +01:00
|
|
|
mov al, [mouse.active_sys_window.action]
|
|
|
|
and al, WINDOW_MOVE_AND_RESIZE_FLAGS
|
|
|
|
test al, al
|
|
|
|
pop eax
|
|
|
|
jnz .loop
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2012-03-31 22:21:39 +02:00
|
|
|
.FlagAutoReset: ; retvals: BgrRedraw=5, IPC=7, Stack=8, Debug=9
|
2021-06-16 15:57:17 +02:00
|
|
|
btr [ebx+APPDATA.occurred_events], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
jnc .loop
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
.result: ; retval = eax+1
|
2011-10-14 23:38:50 +02:00
|
|
|
inc eax
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
.BtKy:
|
2011-10-14 23:38:50 +02:00
|
|
|
movzx edx, bh
|
|
|
|
movzx edx, word[WIN_STACK+edx*2]
|
|
|
|
je .Keys ; eax=1, retval Keys=2
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.Buttons: ; eax=2, retval Buttons=3
|
|
|
|
cmp byte[BTN_COUNT], 0
|
|
|
|
je .loop ; empty ???
|
2021-06-16 12:04:10 +02:00
|
|
|
cmp edx, [thread_count]
|
2011-10-14 23:38:50 +02:00
|
|
|
jne .loop ; not Top ???
|
|
|
|
mov edx, [BTN_BUFF]
|
|
|
|
shr edx, 8
|
|
|
|
cmp edx, 0xFFFF ;-ID for Minimize-Button of Form
|
|
|
|
jne .result
|
|
|
|
mov [window_minimize], 1
|
2013-05-27 11:02:35 +02:00
|
|
|
call wakeup_osloop
|
2011-10-14 23:38:50 +02:00
|
|
|
dec byte[BTN_COUNT]
|
|
|
|
jmp .loop
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
.Keys: ; eax==1
|
2021-06-16 12:04:10 +02:00
|
|
|
cmp edx, [thread_count]
|
2011-10-14 23:38:50 +02:00
|
|
|
jne @f ; not Top ???
|
|
|
|
cmp [KEY_COUNT], al; al==1
|
|
|
|
jae .result ; not empty ???
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
mov edx, hotkey_buffer
|
2012-03-27 22:02:50 +02:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
cmp [edx], bh ; bh - slot for testing
|
|
|
|
je .result
|
|
|
|
add edx, 8
|
|
|
|
cmp edx, hotkey_buffer+120*8
|
|
|
|
jb @b
|
|
|
|
jmp .loop
|
|
|
|
;end.
|
2013-03-19 04:38:52 +01:00
|
|
|
;-----------------------------------------------------------------------------
|