StartFromWB:
	suba.l	a1,a1			; Clear a0
	movea.l	4.w,a6			; Exec base in a6
	CallLib FindTask		; Find Task
	movea.l	d0,a4			; Save task
	tst.l	$AC(a4)			; check for CLI-structure
	bne.s	End_Startup		; Started from CLI

					; Started from WB
	lea	$5C(a4),a0
	CallLib	WaitPort		; Wait for message
	lea	$5C(a4),a0
	CallLib	GetMsg			; Get message
	move.l	d0,StartupWB		; Save message
End_Startup:
	bsr	MainProg
ExitToWB:
	tst.l	StartupWB		; Check if started from WB
	beq.s	ExitToDOS		; No!
	movea.l	4.w,a6			; Get execbase
	CallLib Forbid			; Forbid
	movea.l	StartupWB(pc),a1	; get message in a1
	CallLib	ReplyMsg		; and reply it
ExitToDOS:
	moveq	#0,d0			; We don't want any returncode
	rts				; exit
