*	Created by TT-Digger v6.1
*	Tue Sep 28 08:01:18 1999

*	TTD_6.1

	origin = e346a8
BM_E346A8:	; !main XGEM dispatcher
LE346A8:
	tst	d0				; XGEM terminate call ?
	beq.s	XGEM_terminate
	cmpi	#$00C8,d0			; XGEM AES call ?
	beq.s	AES_or_appl_yield
	cmpi	#$00C9,d0			; XGEM _appl_yield call ?
	beq.s	AES_or_appl_yield
	move.l	$00009144.l,-(a7)		; push link to other dispatchers
	rts					; goto other dispatchers

XGEM_terminate:
	clr	-(a7)				; XGEM Terminate => Pterm0
	move	#$004C,-(a7)	; Pterm
	trap	#1		; Gemdos
AES_or_appl_yield:
	jsr	save_sr_set_intmask.l		; disable interrupts
	move	usp,a0				; a0 -> usp
	movem.l	d1-d7/a0-a6,-(a0)		; push 14 regs on user stack
	move	a0,usp				; update usp accordingly
	movea.l	taskframe_p.l,a6		; a6 -> taskframe
	movea.l	$0008(a6),a6			; a6 -> task data block
	move	#$0001,(a6)			; mark taskframe in use
	move.l	a0,$0042(a6)			; save external USP
	move.l	a7,$0046(a6)			; save external SSP
	movea.l	$003E(a6),a7			; set internal SSP
	jsr	restore_sr.l			; reenable interrupts
	cmp	#$00C8,d0			; normal AES call ?
	bne.s	done_AES_dispatch		; else skip AES dispatcher
	move.l	d1,-(a7)			; push -> aes_pb as arg
	jsr	AES_dispatch_sub.l		; call AES dispatcher sub
	addq.l	#4,a7				; clean stack
done_AES_dispatch:
	jsr	multitasker.l			; call multitasker
	clr	d0				; return value = zero
	jsr	save_sr_set_intmask.l		; disable interrupts
	movea.l	taskframe_p.l,a0		; a0 -> taskframe
	movea.l	$0008(a0),a0			; a0 -> task data block
	clr	(a0)				; mark taskframe free
	move.l	a7,$003E(a0)			; save internal SSP
	movea.l	$0046(a0),a7			; set external SSP
	movea.l	$0042(a0),a0			; a0 = external USP
	movem.l	(a0)+,d1-d7/a0-a6		; pull 14 regs from user stack
	move	a0,usp				; update USP accordingly
	jsr	restore_sr.l			; reenable interrupts
	rte					; exit, maybe in other task


