	format	MS COFF
	extrn	___bb_blitz_blitz
	extrn	___bb_event_event
	extrn	___bb_system_system
	extrn	_bbArrayNew1D
	extrn	_bbEmptyArray
	extrn	_bbEmptyString
	extrn	_bbGCFree
	extrn	_bbHandleFromObject
	extrn	_bbNullObject
	extrn	_bbObjectDowncast
	extrn	_bbObjectNew
	extrn	_bbStringClass
	extrn	_brl_event_EmitEventHook
	extrn	_brl_event_TEvent
	extrn	_brl_hook_AddHook
	extrn	_brl_system_PollSystem
	extrn	_brl_system_WaitSystem
	public	___bb_eventqueue_eventqueue
	public	_brl_eventqueue_CurrentEvent
	public	_brl_eventqueue_EventData
	public	_brl_eventqueue_EventExtra
	public	_brl_eventqueue_EventID
	public	_brl_eventqueue_EventMods
	public	_brl_eventqueue_EventSource
	public	_brl_eventqueue_EventSourceHandle
	public	_brl_eventqueue_EventText
	public	_brl_eventqueue_EventX
	public	_brl_eventqueue_EventY
	public	_brl_eventqueue_PeekEvent
	public	_brl_eventqueue_PollEvent
	public	_brl_eventqueue_PostEvent
	public	_brl_eventqueue_WaitEvent
	section	"code" code
___bb_eventqueue_eventqueue:
	push	ebp
	mov	ebp,esp
	cmp	dword [_57],0
	je	_58
	mov	eax,0
	mov	esp,ebp
	pop	ebp
	ret
_58:
	mov	dword [_57],1
	call	___bb_blitz_blitz
	call	___bb_event_event
	call	___bb_system_system
	mov	eax,dword [_48]
	and	eax,1
	cmp	eax,0
	jne	_49
	push	256
	push	_45
	call	_bbArrayNew1D
	add	esp,8
	inc	dword [eax+4]
	mov	dword [_46],eax
	or	dword [_48],1
_49:
	push	-10000
	push	_bbNullObject
	push	_3
	push	dword [_brl_event_EmitEventHook]
	call	_brl_hook_AddHook
	add	esp,16
	mov	eax,dword [_48]
	and	eax,2
	cmp	eax,0
	jne	_54
	push	_brl_event_TEvent
	call	_bbObjectNew
	add	esp,4
	inc	dword [eax+4]
	mov	dword [_52],eax
	or	dword [_48],2
_54:
	mov	eax,dword [_48]
	and	eax,4
	cmp	eax,0
	jne	_56
	mov	eax,dword [_52]
	inc	dword [eax+4]
	mov	dword [_brl_eventqueue_CurrentEvent],eax
	or	dword [_48],4
_56:
	mov	eax,0
	jmp	_10
_10:
	mov	esp,ebp
	pop	ebp
	ret
_3:
	push	ebp
	mov	ebp,esp
	push	ebx
	mov	ebx,dword [ebp+12]
	push	_brl_event_TEvent
	push	ebx
	call	_bbObjectDowncast
	add	esp,8
	mov	edx,eax
	cmp	edx,_bbNullObject
	setne	al
	movzx	eax,al
	cmp	eax,0
	jne	_60
	mov	eax,_bbNullObject
	jmp	_15
_60:
	mov	eax,dword [edx+8]
	cmp	eax,16385
	je	_63
	cmp	eax,16386
	je	_63
	cmp	eax,2049
	je	_63
	cmp	eax,8193
	je	_63
	push	0
	push	edx
	call	_brl_eventqueue_PostEvent
	add	esp,8
	jmp	_62
_63:
	push	1
	push	edx
	call	_brl_eventqueue_PostEvent
	add	esp,8
	jmp	_62
_62:
	mov	eax,ebx
	jmp	_15
_15:
	pop	ebx
	mov	esp,ebp
	pop	ebp
	ret
_brl_eventqueue_PeekEvent:
	push	ebp
	mov	ebp,esp
	mov	eax,dword [_50]
	cmp	dword [_51],eax
	jne	_64
	call	_brl_system_PollSystem
	mov	eax,dword [_50]
	cmp	dword [_51],eax
	jne	_65
	mov	eax,_bbNullObject
	jmp	_17
_65:
_64:
	mov	edx,dword [_46]
	mov	eax,dword [_51]
	and	eax,255
	mov	eax,dword [edx+eax*4+24]
	jmp	_17
_17:
	mov	esp,ebp
	pop	ebp
	ret
_brl_eventqueue_PollEvent:
	push	ebp
	mov	ebp,esp
	push	ebx
	mov	eax,dword [_50]
	cmp	dword [_51],eax
	jne	_66
	call	_brl_system_PollSystem
	mov	eax,dword [_50]
	cmp	dword [_51],eax
	jne	_67
	mov	ebx,dword [_52]
	inc	dword [ebx+4]
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	dec	dword [eax+4]
	jnz	_71
	push	eax
	call	_bbGCFree
	add	esp,4
_71:
	mov	dword [_brl_eventqueue_CurrentEvent],ebx
	mov	eax,0
	jmp	_19
_67:
_66:
	mov	edx,dword [_46]
	mov	eax,dword [_51]
	and	eax,255
	mov	ebx,dword [edx+eax*4+24]
	inc	dword [ebx+4]
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	dec	dword [eax+4]
	jnz	_75
	push	eax
	call	_bbGCFree
	add	esp,4
_75:
	mov	dword [_brl_eventqueue_CurrentEvent],ebx
	mov	ebx,_bbNullObject
	inc	dword [ebx+4]
	mov	edx,dword [_46]
	mov	eax,dword [_51]
	and	eax,255
	mov	eax,dword [edx+eax*4+24]
	dec	dword [eax+4]
	jnz	_79
	push	eax
	call	_bbGCFree
	add	esp,4
_79:
	mov	edx,dword [_46]
	mov	eax,dword [_51]
	and	eax,255
	mov	dword [edx+eax*4+24],ebx
	add	dword [_51],1
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	mov	eax,dword [eax+8]
	jmp	_19
_19:
	pop	ebx
	mov	esp,ebp
	pop	ebp
	ret
_brl_eventqueue_WaitEvent:
	push	ebp
	mov	ebp,esp
	push	ebx
	jmp	_4
_6:
	call	_brl_system_WaitSystem
_4:
	mov	eax,dword [_50]
	cmp	dword [_51],eax
	je	_6
_5:
	mov	edx,dword [_46]
	mov	eax,dword [_51]
	and	eax,255
	mov	ebx,dword [edx+eax*4+24]
	inc	dword [ebx+4]
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	dec	dword [eax+4]
	jnz	_83
	push	eax
	call	_bbGCFree
	add	esp,4
_83:
	mov	dword [_brl_eventqueue_CurrentEvent],ebx
	mov	ebx,_bbNullObject
	inc	dword [ebx+4]
	mov	edx,dword [_46]
	mov	eax,dword [_51]
	and	eax,255
	mov	eax,dword [edx+eax*4+24]
	dec	dword [eax+4]
	jnz	_87
	push	eax
	call	_bbGCFree
	add	esp,4
_87:
	mov	edx,dword [_46]
	mov	eax,dword [_51]
	and	eax,255
	mov	dword [edx+eax*4+24],ebx
	add	dword [_51],1
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	mov	eax,dword [eax+8]
	jmp	_21
_21:
	pop	ebx
	mov	esp,ebp
	pop	ebp
	ret
_brl_eventqueue_PostEvent:
	push	ebp
	mov	ebp,esp
	push	ebx
	push	esi
	mov	ebx,dword [ebp+8]
	mov	eax,dword [ebp+12]
	cmp	eax,0
	je	_88
	mov	edx,dword [_51]
	jmp	_7
_9:
	mov	ecx,dword [_46]
	mov	eax,edx
	and	eax,255
	mov	esi,dword [ecx+eax*4+24]
	mov	eax,dword [esi+8]
	cmp	eax,dword [ebx+8]
	sete	al
	movzx	eax,al
	cmp	eax,0
	je	_91
	mov	eax,dword [esi+12]
	cmp	eax,dword [ebx+12]
	sete	al
	movzx	eax,al
_91:
	cmp	eax,0
	je	_93
	mov	eax,dword [ebx+16]
	mov	dword [esi+16],eax
	mov	eax,dword [ebx+20]
	mov	dword [esi+20],eax
	mov	eax,dword [ebx+24]
	mov	dword [esi+24],eax
	mov	eax,dword [ebx+28]
	mov	dword [esi+28],eax
	mov	ebx,dword [ebx+32]
	inc	dword [ebx+4]
	mov	eax,dword [esi+32]
	dec	dword [eax+4]
	jnz	_97
	push	eax
	call	_bbGCFree
	add	esp,4
_97:
	mov	dword [esi+32],ebx
	mov	eax,0
	jmp	_25
_93:
	add	edx,1
_7:
	cmp	edx,dword [_50]
	jne	_9
_8:
_88:
	mov	eax,dword [_50]
	sub	eax,dword [_51]
	cmp	eax,256
	jne	_98
	mov	eax,0
	jmp	_25
_98:
	inc	dword [ebx+4]
	mov	edx,dword [_46]
	mov	eax,dword [_50]
	and	eax,255
	mov	eax,dword [edx+eax*4+24]
	dec	dword [eax+4]
	jnz	_102
	push	eax
	call	_bbGCFree
	add	esp,4
_102:
	mov	edx,dword [_46]
	mov	eax,dword [_50]
	and	eax,255
	mov	dword [edx+eax*4+24],ebx
	add	dword [_50],1
	mov	eax,0
	jmp	_25
_25:
	pop	esi
	pop	ebx
	mov	esp,ebp
	pop	ebp
	ret
_brl_eventqueue_EventID:
	push	ebp
	mov	ebp,esp
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	mov	eax,dword [eax+8]
	jmp	_27
_27:
	mov	esp,ebp
	pop	ebp
	ret
_brl_eventqueue_EventData:
	push	ebp
	mov	ebp,esp
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	mov	eax,dword [eax+16]
	jmp	_29
_29:
	mov	esp,ebp
	pop	ebp
	ret
_brl_eventqueue_EventMods:
	push	ebp
	mov	ebp,esp
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	mov	eax,dword [eax+20]
	jmp	_31
_31:
	mov	esp,ebp
	pop	ebp
	ret
_brl_eventqueue_EventX:
	push	ebp
	mov	ebp,esp
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	mov	eax,dword [eax+24]
	jmp	_33
_33:
	mov	esp,ebp
	pop	ebp
	ret
_brl_eventqueue_EventY:
	push	ebp
	mov	ebp,esp
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	mov	eax,dword [eax+28]
	jmp	_35
_35:
	mov	esp,ebp
	pop	ebp
	ret
_brl_eventqueue_EventExtra:
	push	ebp
	mov	ebp,esp
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	mov	eax,dword [eax+32]
	jmp	_37
_37:
	mov	esp,ebp
	pop	ebp
	ret
_brl_eventqueue_EventText:
	push	ebp
	mov	ebp,esp
	push	_bbStringClass
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	push	dword [eax+32]
	call	_bbObjectDowncast
	add	esp,8
	cmp	eax,_bbNullObject
	jne	_104
	mov	eax,_bbEmptyString
_104:
	jmp	_39
_39:
	mov	esp,ebp
	pop	ebp
	ret
_brl_eventqueue_EventSource:
	push	ebp
	mov	ebp,esp
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	mov	eax,dword [eax+12]
	jmp	_41
_41:
	mov	esp,ebp
	pop	ebp
	ret
_brl_eventqueue_EventSourceHandle:
	push	ebp
	mov	ebp,esp
	mov	eax,dword [_brl_eventqueue_CurrentEvent]
	push	dword [eax+12]
	call	_bbHandleFromObject
	add	esp,4
	jmp	_43
_43:
	mov	esp,ebp
	pop	ebp
	ret
	section	"data" data writeable align 8
	align	4
_57:
	dd	0
	align	4
_48:
	dd	0
_45:
	db	":TEvent",0
	align	4
_46:
	dd	_bbEmptyArray
	align	4
_50:
	dd	0
	align	4
_51:
	dd	0
	align	4
_52:
	dd	_bbNullObject
	align	4
_brl_eventqueue_CurrentEvent:
	dd	_bbNullObject
