The SGADE Documentation

the SGADE The Socrates Gameboy Advance Development Engine

The SGADE is a development library for the Nintendo Gameboy Advance. It's free for all uses and is distributed without guarantees. For more information visit the SGADE page.


Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

SoMath.c File Reference

#include "SoMath.h"

Defines

#define SO_RAND_STATE_VECTOR_LENGTH
 Internal use only. Used by the Mersenne Twister. Length of random state vector.

#define SO_RAND_PERIOD
 Internal use only. Used by the Mersenne Twister. A period parameter.

#define SO_RAND_MAGIC
 Internal use only. Used by the Mersenne Twister. A magic constant.

#define SO_RAND_HI_BIT(u)
 Mask all but highest bit of u.

#define SO_RAND_LO_BIT(u)
 Mask all but lowest bit of u.

#define SO_RAND_LO_BITS(u)
 Mask the highest bit of u.

#define SO_RAND_MIX_BITS(u, v)
 Move hi bit of u to hi bit of v.


Functions

u32 SoMathRandReloadMersenneTwister (void)
 For internal use only.

sofixedpoint SoMathFixedMultiply (sofixedpoint a_A, sofixedpoint a_B)
 Fixed-point multiplication function.

sofixedpoint SoMathFixedMultiplyByFraction (sofixedpoint a_A, sofixedpoint a_B)
 Fixed-point multiplication by fraction function.

sofixedpoint SoMathFixedSqrt (sofixedpoint a_FixedValue)
 Squareroot function.

u32 SoMathRand (void)
 Returns a pseudo random number.

void SoMathRandSeed (u32 a_Seed)
 Seeds the random number generator.


Variables

u32s_RandNext
 Internal use only.

s32 s_RandLeft
 Internal use only.

u32 s_RandState [SO_RAND_STATE_VECTOR_LENGTH+1]
 Internal use only.


Detailed Description

Copyright (C) 2002 by the SGADE authors For conditions of distribution and use, see copyright notice in SoLicense.txt

Author:
Jaap Suter, Mark T. Price
Date:
Sept 22 2001
See the documentation on SoMath.h for more information.


Define Documentation

#define SO_RAND_HI_BIT  
 

Mask all but highest bit of u.

For internal use only.

#define SO_RAND_LO_BIT  
 

Mask all but lowest bit of u.

For internal use only.

#define SO_RAND_LO_BITS  
 

Mask the highest bit of u.

For internal use only.

#define SO_RAND_MIX_BITS u,
 
 

Move hi bit of u to hi bit of v.

For internal use only.


Function Documentation

u32 SoMathRandReloadMersenneTwister void   
 

For internal use only.

Reloads the Mersenne Twister state vector. Implementation taken from the internet. Credits go to Shawn J. Cokus;


Variable Documentation

s32 s_RandLeft [static]
 

Internal use only.

Used by the Mersenne Twister. Can do a *s_RandNext++ this many times before reloading;

u32* s_RandNext [static]
 

Internal use only.

Used by the Mersenne Twister. The next random value is computed from here;

u32 s_RandState[ SO_RAND_STATE_VECTOR_LENGTH + 1 ] [static]
 

Internal use only.

Used by the Mersenne Twister. Random state vector + 1 extra to not violate ANSI C;


Copyright 2002 by the SGADE authors. See SoLicense.h or Visit the SGADE page for more information.