**
**	MandelSquare - AmigaDOS 2.0/3.0 Mandelbrot set explorer
**
**	FPInit.asm, fpu setup/cleanup routines
**
**	Copyright © 1991-1992 by Olaf `Olsen' Barthel
**		All Rights Reserved
**

	include	"exec/types.i"
	include	"exec/execbase.i"

CALL	macro
	xref	_LVO\1
	jsr	_LVO\1(a6)
	endm

	XDEF	___fpinit
	XDEF	___fpterm

	XREF	__XCEXIT

	csect	text,0,0,1,2

	;	VOID __fpinit(VOID);
	;
	;		This routine is called by the c.o startup code
	;	in order to set up and initialize math libraries or, just
	;	like done here, to check for the presence of an
	;	'881/'882/'040 chip.

___fpinit:	
	move.l	(4).w,a6		; Grab SysBase

	cmp.w	#37,LIB_VERSION(a6)	; Kickstart 2.x?
	blt.s	2$

	move.w	AttnFlags(a6),d0	; Get attention flags

	IFND	M68040

	btst	#AFB_68020,d0		; '020 or higher installed?
	beq.s	2$

	btst	#AFB_68881,d0		; '881 or higher installed?
	bne.s	1$

	ENDC

	btst	#AFB_68040,d0		; If no '881 present, an '040
	beq.s	2$			; will do as well

1$	rts

2$	move.l	#1,-(sp)		; Exit & fail
	jmp	__XCEXIT

	;	VOID __fpexit(VOID);
	;
	;		This routine is called by the c.o startup code
	;	in order to close and release math libraries or. In this
	;	case it does not do anything.

___fpterm:
	rts

	end
