שתשת                                        ***************************************
*** 68881/68882/040 FPU Startup 1.2 ***	====== 	MUST BE CALLED AS SUBROUTINE
***************************************		(USER & SUPERVISOR, PC-REL)
*****   Coded by Aga/Vajrayana   ****** ====== 	CPU:  MC68000+
*****    - since 5/VII/1995 -    ****** ====== 	Kick: V1.2+
*****   > Dedicated to Aliel <   ****** ====== 	Libs: V32+
*************************************** ====== 	Chip: OCS+


_FPU_Startup:

._LVOSupervisor	equ	-30
._AttnFlags	equ	296
._AFB_68010	equ	0
._AFB_68881	equ	4

	move.l	4.w,a6
	btst	#._AFB_68881,._AttnFlags+1(a6)
	beq.s	.NoFPU
	btst	#._AFB_68010,._AttnFlags+1(a6)
	beq.s	.No010
	lea	.GetVBR(pc),a5
	jsr	._LVOSupervisor(a6)
.No010:	move.l	_FPU_VBR(pc),a0
	lea	$c0(a0),a0
	lea	_FPU_OSExceptions(pc),a1
	lea	_FPU_NewExceptions(pc),a2
	moveq	#7-1,d0
.FPExLp:move.l	(a0)+,(a1)+
	move.l	(a2)+,d1
	beq.s	.NoVec
	move.l	d1,-4(a0)
.NoVec:	dbra	d0,.FPExLp
	lea	_FPCR(pc),a5
	fmove.l	fpcr,(a5)
	lea	_FPSR(pc),a5
	fmove.l	fpsr,(a5)
	lea	_FPU_Status(pc),a5
	fsave	(a5)
.NoFPU:	rts
.GetVBR:
	movec	vbr,d0
	lea	_FPU_VBR(pc),a5
	move.l	d0,(a5)
	rte
;--------------------------------------
_FPU_Quit:

._AttnFlags	equ	296
._AFB_68881	equ	4

	move.l	4.w,a6
	btst	#._AFB_68881,._AttnFlags+1(a6)
	beq.s	.NoFPU
	frestore _FPU_Status(pc)
	fmove.l	_FPSR(pc),fpsr
	fmove.l	_FPCR(pc),fpcr
	move.l	_FPU_VBR(pc),a0
	lea	$c0(a0),a0
	lea	_FPU_OSExceptions(pc),a1
	moveq	#7-1,d7
.FPExLp:move.l	(a1)+,(a0)+
	dbra	d7,.FPExLp
.NoFPU:	rts
***************************************
_FPCR:			ds.l	1
_FPSR:			ds.l	1
_FPU_Status:		ds.l	1
_FPU_VBR:		ds.l	1
_FPU_OSExceptions:	ds.l	7

;"_FPU_NewExceptions:" needed...

_FPU_NewExceptions
