00001 /*! \file 00002 * X-Forge Util <br> 00003 * Copyright 2000-2003 Fathammer Ltd 00004 * 00005 * \brief Implementation of a 'fast' random class. 00006 * 00007 * \note This is the initial implementation of a 'fast' random (noise) 00008 * function. It is not meant to generate too good random numbers, and is 00009 * just meant as a 'noise' function (visual effects). 00010 * 00011 * $Id: XFuFastRandom.cpp,v 1.4 2003/05/29 14:25:48 jetro Exp $ 00012 * $Date: 2003/05/29 14:25:48 $ 00013 * $Revision: 1.4 $ 00014 */ 00015 00016 #include <xfcore/XFcCore.h> 00017 #include <xfutil/XFuFastRandom.h> 00018 00019 00020 XFuFastRandom::XFuFastRandom() 00021 { 00022 seed(XFcCore::getTick()); 00023 } 00024 00025 00026 XFuFastRandom::XFuFastRandom(UINT32 aSeed) 00027 { 00028 seed(aSeed); 00029 } 00030 00031 00032 void XFuFastRandom::seed(UINT32 aSeed) 00033 { 00034 UINT32 s = aSeed & 31; 00035 UINT32 t = aSeed ^ 0x14951C57; 00036 mSeed2 = (t >> s) + (t << (32 - s)); 00037 s = (aSeed >> 5) & 31; 00038 t = aSeed ^ 0x6C691B25; 00039 mSeed1 = (t >> s) + (t << (32 - s)); 00040 }
![]() | ||||
![]() |
Confidential Copyright © 2002-2003 Fathammer | with doxygen by Dimitri van Heesch |