; MyMouse, Hardware Event Queue, Copr. 1993,94 Matthias K”ppe

		INCLUDE	mymodef.asm

		PUBLIC	BeginCritical, StoreEvent, EndCritical

DATA		SEGMENT WORD PUBLIC

Queue           DW	4 DUP (4 DUP (?))
QPtr		DW	?

DATA		ENDS

CODE		SEGMENT BYTE PUBLIC

BeginCritical	PROC NEAR
		mov	InMouse, 1
		mov	QPtr, OFFSET Queue
		retn
BeginCritical	ENDP

StoreEvent	PROC NEAR
		MOV	DI, QPtr
		CMP	DI, OFFSET QPtr
		JAE	@@1
		MOV	[DI], AX
		MOV	[DI+2], BX
		MOV	[DI+4], CX
		MOV	[DI+6], DX
		ADD	QPtr, 8
@@1:		retn
StoreEvent	ENDP

EndCritical	PROC NEAR
		MOV	SI, OFFSET Queue
@@1:    	CMP	SI, QPtr
		JAE	@@2
		CLD
		LODSW
		XCHG	AX, DI
		LODSW
		XCHG	AX, BX
		LODSW
		XCHG	AX, CX
		LODSW
		XCHG	AX, DX
		XCHG	AX, DI
		PUSH	SI
		CALL	MouseInt
		CALL	UpdateMouse
		POP	SI
		JMP	@@1
@@2:		MOV     InMouse, 0
		retn
EndCritical	ENDP

CODE		ENDS

		END
