(**************************************************************************

     $RCSfile: MathFFP.mod $
  Description: Interface to mathffp.library

   Created by: fjc (Frank Copeland)
    $Revision: 3.2 $
      $Author: fjc $
        $Date: 1994/08/08 00:49:28 $

  Includes Release 40.15

  (C) Copyright 1985-1993 Commodore-Amiga, Inc.
      All Rights Reserved

  Oberon-A interface Copyright © 1994, Frank Copeland.
  This file is part of the Oberon-A Interface.
  See Oberon-A.doc for conditions of use and distribution.

***************************************************************************)

MODULE MathFFP;

(*
** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
** $V- OvflChk       $Z- ZeroVars
*)

IMPORT Exec, SYSTEM;


(*
**      $VER: mathffp.h 36.2 (1.5.90)
**
**      general floating point declarations
*)

CONST

  pi *       = 3.141592653589793;
  twoPi *    = 6.283185307179586; (* Pi * 2.0 *)
  pi2 *      = 1.570796326794696; (* Pi / 2.0 *)
  pi4 *      = 0.785398163397448; (* Pi / 4.0 *)
  e *        = 2.718281828459045;
  log10 *    = 2.302585092994046;

  fpTen *    = 10.0;
  fpOne *    = 1.0;
  fpHalf *   = 0.5;
  fpZero *   = 0.0;


(*-- Library Base variable --------------------------------------------*)

TYPE

  MathFFPBasePtr * = CPOINTER TO MathFFPBase;
  MathFFPBase * = RECORD (Exec.Library) END;

CONST

  name * = "mathffp.library";

VAR

  base * : MathFFPBasePtr;


(*-- Library Functions ------------------------------------------------*)

(*
**      $VER: mathffp_protos.h 1.4 (3.5.90)
*)

(*
 *  There is no need to call any of these functions directly.  They are
 *  called inline by the compiler when translating expressions
 *  involving REAL values.  They are defined here for completeness.
 *)

LIBCALL (base : MathFFPBasePtr) Fix *
  ( parm [0] : REAL )
  : LONGINT;
  -30;
LIBCALL (base : MathFFPBasePtr) Flt *
  ( integer [0] : LONGINT )
  : REAL;
  -36;
LIBCALL (base : MathFFPBasePtr) Cmp *
  ( leftParm  [1] : REAL;
    rightParm [0] : REAL )
  : LONGINT;
  -42;
LIBCALL (base : MathFFPBasePtr) Tst *
  ( parm [1] : REAL )
  : LONGINT;
  -48;
LIBCALL (base : MathFFPBasePtr) Abs *
  ( parm [0] : REAL )
  : REAL;
  -54;
LIBCALL (base : MathFFPBasePtr) Neg *
  ( parm [0] : REAL )
  : REAL;
  -60;
LIBCALL (base : MathFFPBasePtr) Add *
  ( leftParm  [1] : REAL;
    rightParm [0] : REAL )
  : REAL;
  -66;
LIBCALL (base : MathFFPBasePtr) Sub *
  ( leftParm  [1] : REAL;
    rightParm [0] : REAL )
  : REAL;
  -72;
LIBCALL (base : MathFFPBasePtr) Mul *
  ( leftParm  [1] : REAL;
    rightParm [0] : REAL )
  : REAL;
  -78;
LIBCALL (base : MathFFPBasePtr) Div *
  ( leftParm  [1] : REAL;
    rightParm [0] : REAL )
  : REAL;
  -84;

(* --- functions in V33 or higher (distributed as Release 1.2) ---*)

LIBCALL (base : MathFFPBasePtr) Floor *
  ( parm [0] : REAL )
  : REAL;
  -90;
LIBCALL (base : MathFFPBasePtr) Ceil *
  ( parm [0] : REAL )
  : REAL;
  -96;


(*-- Library Base variable --------------------------------------------*)
(* $L- Address globals through A4 *)


(*-----------------------------------*)
PROCEDURE* CloseLib ();

BEGIN (* CloseLib *)
  IF base # NIL THEN Exec.base.CloseLibrary (base) END
END CloseLib;

(*-----------------------------------*)
PROCEDURE OpenLib * (mustOpen : BOOLEAN);

BEGIN (* OpenLib *)
  IF base = NIL THEN
    base :=
      SYSTEM.VAL
        ( MathFFPBasePtr,
          Exec.base.OpenLibrary (name, Exec.libraryMinimum));
    IF base # NIL THEN SYSTEM.SETCLEANUP (CloseLib)
    ELSIF mustOpen THEN HALT (100)
    END;
  END;
END OpenLib;


BEGIN
  base := NIL
END MathFFP.
