************************************************************************
**            Written by Dino Papararo            18-Apr-1998
**
**  FUNCTION
**
**    MandReal -- perform Z = Z^2 + C iteration.
**
**  SYNOPSIS
**
**    WORD MandFPU (WORD Iterations,long double Cre,long double Cim)
**
**
**  DESCRIPTION
**
**  C equivalent function:
**
**	*************************************************************
**	*WORD Real (WORD Iterazioni,long double Cre,long double Cim)*
**	*{                                                          *
**	*register long double zr,zi,zr2,zi2;                        *
**	*                                                           *
**	*  zr = Cre;                                                *
**	*                                                           *
**	*  zi = Cim;                                                *
**	*                                                           *
**	*  zr2 = Cre * Cre;                                         *
**	*                                                           *
**	*  zi2 = Cim * Cim;                                         *
**	*                                                           *
**	*  while ((zr2 + zi2 <= 4.0))                               *
**	*  {                                                        *
**	*     if (--Iterazioni == 0) break;                         *
**	*                                                           *
**	*     zi *= zr;                                             *
**	*                                                           *
**	*     zr  = zr2 - zi2 + Cre;                                *
**	*                                                           *
**	*     zi += zi + Cim;                                       *
**	*                                                           *
**	*     zr2 = zr * zr;                                        *
**	*                                                           *
**	*     zi2 = zi * zi;                                        *
**	*  }                                                        *
**	*                                                           *
**	*  return Iterazioni;                                       *
**	*}                                                          *
**	*************************************************************
**
**  This function tests if a point belongs or not at mandelbrot's set
**
**  Optimized for pipelines of 68882+ coprocessors
**
**  NOTICE: ALL VARIABLES ARE INTO REGISTERS FOR FULL SPEEEED
**
**  d0:Iterations
**
**  fp0:Cre fp1:Cim fp2:Zr fp3:Zi fp4:Zr2 fp5:Zi2 fp6:Dist fp7:MaxDist
************************************************************************



        XDEF  _MandFPU

_MandFPU:

        fmove.x #4,fp7   * MaxDist = 4.0
        fmove.x fp0,fp4  * Zr2 = Cre
        fmove.x fp1,fp5  * Zi2 = Cim
        fmul.x  fp4,fp4  * Zr2 *= Zr2
        fmul.x  fp5,fp5  * Zi2 *= Zi2
        fmove.x fp0,fp2  * Zr = Cre
        fmove.x fp1,fp3  * Zi = Cim

Loop:
        fmove.x fp4,fp6  * Dist = Zr2
        fadd.x  fp5,fp6  * Dist += Zi2
        fcmp.x  fp7,fp6  * Compare Dist with MaxDist
        fbgt    Exit     * if Dist > MaxDist Exit
        
        fmul.x  fp2,fp3  * Zi *= Zr
        fmove.x fp4,fp2  * Zr = Zr2
        fadd.x  fp3,fp3  * Zi += Zi
        fsub.x  fp5,fp2  * Zr -= Zi2
        fadd.x  fp1,fp3  * Zi += Cim
        fadd.x  fp0,fp2  * Zr += Cre

        fmove.x fp3,fp5  * Zi2 = Zi
        fmove.x fp2,fp4  * Zr2 = Zr
        fmul.x  fp5,fp5  * Zi2 *= Zi2
        fmul.x  fp4,fp4  * Zr2 *= Zr2

        dbra.w  d0,Loop  * if --Iterations go to Loop
        moveq.l #0,d0    * Iterations = 0
        
Exit:        
        rts  * return Iterations

        end
        