; Version: 2.94 ; Created: Friday, October 20, 1989 at 9:16:04 PM ; File: FixMath.a ; ; Copyright Apple Computer, Inc. 1984-1990 ; All Rights Reserved ; ; These calls support three types of fixed point numbers, each 32 bits long. ; The bits are interpreted as shown. The '-' represents the sign bit. ; ; Type <---------Integer Portion--------> <-------Fractional Portion------> ;LongInt -xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx. ;Fixed -xxxxxxx xxxxxxxx.xxxxxxxx xxxxxxxx ;Fract -x.xxxxxxxx xxxxxxxx xxxxxxxx xxxxxx ; ; Type LongInt can represent integers between +/-2147483647. Type Fixed can ; represent fractional quantities between +/-32768, with about 5 digits of ; accuracy. Type Fract can represent fractional quantities between +/-2 with ; about 9 digits of accuracy. These numeric representations are useful for ; applications that do not require the accuracy of the floating point routines, ; and which need to run as fast as possible. The Graf3D three dimensional ; graphics package resides on top of these routines. Although FixMul is in the ; file ToolTraps, it is shown below to show how it handles different types. ; Additional fixed point routines are described in the Inside Macintosh chapter, ; “Toolbox Utilities.” ; FUNCTION FixMul(x, y: Fixed): Fixed; ; FixMul returns x * y. Note that FixMul effects "type * Fixed --> type": ; Fixed * Fixed --> Fixed ; LONGINT * Fixed --> LONGINT ; Fixed * LONGINT --> LONGINT ; Fract * Fixed --> Fract ; Fixed * Fract --> Fract ; FUNCTION FracMul(x, y: Fract): Fract; ; FracMul returns x * y. Note that FracMul effects "type * Fract --> type": ; Fract * Fract --> Fract ; LONGINT * Fract --> LONGINT ; Fract * LONGINT --> LONGINT ; Fixed * Fract --> Fixed ; Fract * Fixed --> Fixed ; FUNCTION FixDiv(x, y: Fixed): Fixed; ; FixDiv returns x / y. Note that FixDiv effects "type / type --> Fixed": ; Fixed / Fixed --> Fixed ; LONGINT / LONGINT --> Fixed ; Fract / Fract --> Fixed ; LONGINT / Fixed --> LONGINT ; Fract / Fixed --> Fract ; FUNCTION FracDiv(x, y: Fract): Fract; ; FracDiv returns x / y. Note that FracDiv effects "type / type --> Fract": ; Fract / Fract --> Fract ; LONGINT / LONGINT --> Fract ; Fixed / Fixed --> Fract ; LONGINT / Fract --> LONGINT ; Fixed / Fract --> Fixed ; FUNCTION FracSqrt(x: Fract): Fract; ; FracSqrt returns the square root of x. Both argument and result are regarded ; as unsigned. ; FUNCTION FracCos(x: Fixed): Fract; ; FUNCTION FracSin(x: Fixed): Fract; ; FracCos and FracSin return the cosine and sine, respectively, given the ; argument x in radians. ;The following routines are accessed via the glue code ;which will call the trap on a 128K ROM machine IF &TYPE('__IncludingFixMath__') = 'UNDEFINED' THEN __IncludingFixMath__ SET 1 _FracCos OPWORD $A847 _FracSin OPWORD $A848 _FracSqrt OPWORD $A849 _FracMul OPWORD $A84A _FracDiv OPWORD $A84B _FixDiv OPWORD $A84D ENDIF ; ...already included