Remove unused fast random stuff.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2544 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1 +1 @@
|
||||
uqm_CFILES="fastrand.c random.c sqrt.c"
|
||||
uqm_CFILES="random.c sqrt.c"
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
//Copyright Paul Reiche, Fred Ford. 1992-2002
|
||||
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "mthintrn.h"
|
||||
#include "random.h" /* get the externs for error checking */
|
||||
|
||||
/* ----------------------------GLOBAL DATA-------------------------------- */
|
||||
|
||||
DWORD random_table[TABLE_SIZE];
|
||||
COUNT fast_index = 0; /* fast random cycling index */
|
||||
|
||||
/* ----------------------------PROTOTYPES--------------------------------- */
|
||||
|
||||
DWORD indexed_random_table(COUNT index);
|
||||
void reseed_fast_random(void);
|
||||
DWORD fast_random(void);
|
||||
DWORD seed_fast_random(DWORD seed);
|
||||
|
||||
/*****************************************************************************
|
||||
* FUNC: DWORD seed_fast_random(DWORD seed)
|
||||
*
|
||||
* DESC:generate a small table of random numbers for later use by fast_random()
|
||||
*
|
||||
* NOTES: the table has a prime number of entries
|
||||
*
|
||||
* HISTORY: Created By Robert Leyland
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
DWORD
|
||||
seed_fast_random(DWORD seed)
|
||||
{
|
||||
DWORD retval;
|
||||
COUNT index;
|
||||
|
||||
retval = TFB_SeedRandom(seed);
|
||||
|
||||
for( index = 0; index < TABLE_SIZE; index++ )
|
||||
random_table[index] = TFB_Random();
|
||||
|
||||
fast_index = 0; /* must be set to the start of the table for
|
||||
repeatability... */
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* FUNC: DWORD fast_random()
|
||||
*
|
||||
* DESC:return the next random number from the random number table
|
||||
*
|
||||
* NOTES:
|
||||
*
|
||||
* HISTORY: Created By Robert Leyland
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
DWORD
|
||||
fast_random(void)
|
||||
{
|
||||
fast_index++;
|
||||
if( fast_index == TABLE_SIZE )
|
||||
fast_index = 0;
|
||||
|
||||
return( random_table[fast_index] );
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* FUNC: void reseed_fast_random()
|
||||
*
|
||||
* DESC:shifts the table pointer by calling the "real" random
|
||||
*
|
||||
* NOTES:
|
||||
*
|
||||
* HISTORY: Created By Robert Leyland
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
void
|
||||
reseed_fast_random(void)
|
||||
{
|
||||
fast_index = (COUNT)(TFB_Random() % TABLE_SIZE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* FUNC: DWORD indexed_random_table(COUNT index)
|
||||
*
|
||||
* DESC:return a "random" number from the random number table, as indexed
|
||||
* for repeatability
|
||||
*
|
||||
* NOTES:used by texturing functions
|
||||
*
|
||||
* HISTORY: Created By Robert Leyland
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
DWORD
|
||||
indexed_random_table(COUNT index)
|
||||
{
|
||||
if( index > TABLE_SIZE ) /* only do % if really needed */
|
||||
index = index % TABLE_SIZE;
|
||||
|
||||
return(random_table[index]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,27 +28,13 @@
|
||||
|
||||
/* ----------------------------DEFINES------------------------------------ */
|
||||
|
||||
#ifndef SLOW_N_STUPID
|
||||
#define TABLE_SIZE 1117 /* a "nice" prime number */
|
||||
#define _FAST_ fast_random()
|
||||
#else /* FAST_N_UGLY */
|
||||
#define TABLE_SIZE ( (1 << 10) - 1 )
|
||||
#define _FAST_ ( random_table[ fast_index++ & TABLE_SIZE ] )
|
||||
#endif
|
||||
|
||||
|
||||
#define FASTRAND(n) ( (int) ( (unsigned int)_FAST_ % (n) ) )
|
||||
#define SFASTRAND(n) ( (int)_FAST_ % (n) )
|
||||
#define AND_FASTRAND(n) ( (int)_FAST_ & (n) )
|
||||
|
||||
#define RAND(n) ( (int) ( (unsigned int)TFB_Random() % (n) ) )
|
||||
#define SRAND(n) ( (int)TFB_Random() % (n) )
|
||||
#define AND_RAND(n) ( (int)TFB_Random() & (n) )
|
||||
|
||||
#define INDEXED_RANDOM(x) (random_table[x])
|
||||
|
||||
/* ----------------------------GLOBALS/EXTERNS---------------------------- */
|
||||
|
||||
extern DWORD random_table[TABLE_SIZE];
|
||||
extern COUNT fast_index; /* fast random cycling index */
|
||||
DWORD TFB_SeedRandom (DWORD seed);
|
||||
DWORD TFB_Random (void);
|
||||
|
||||
|
||||
@@ -20,9 +20,8 @@
|
||||
#define _MATHLIB_H
|
||||
|
||||
#include "compiler.h"
|
||||
#include "math/random.h"
|
||||
|
||||
extern DWORD TFB_SeedRandom (DWORD seed);
|
||||
extern DWORD TFB_Random (void);
|
||||
extern COUNT square_root (DWORD value);
|
||||
|
||||
#endif /* _MATHLIB_H */
|
||||
|
||||
Reference in New Issue
Block a user