* Committed new random generator.

This commit is contained in:
daniel 1999-11-09 20:14:12 +00:00
parent 7fc2e3bf91
commit ec77ff77ee
3 changed files with 66 additions and 4 deletions

View File

@ -882,9 +882,35 @@ end;
{$endif not HASSAVEREGISTERS}
{The values behind the xors are very important! These values seem to work
well, propably there are better ones, but most are worse!! (DM)}
procedure do_random1;assembler;
asm
movl randseed,%eax
incl %eax
rorl $3,%eax
xorl $0x4b65af1,%eax
movl %eax,randseed
end;
procedure do_random2;assembler;
asm
movl seed2,%eax
incl %eax
rorl $3,%eax
xorl $0x65b9fa14,%eax
movl %eax,seed2
end;
{
$Log$
Revision 1.58 1999-10-30 17:39:05 peter
Revision 1.59 1999-11-09 20:14:12 daniel
* Committed new random generator.
Revision 1.58 1999/10/30 17:39:05 peter
* memorymanager expanded with allocmem/reallocmem
Revision 1.57 1999/10/08 14:40:54 pierre

View File

@ -36,11 +36,15 @@ type
PByte = ^Byte;
const
{$IFDEF OLDRANDOM}
{ Random / Randomize constants }
OldRandSeed : Cardinal = 0;
InitialSeed : Boolean = TRUE;
Seed2 : Cardinal = 0;
Seed3 : Cardinal = 0;
{$ELSE}
seed2:cardinal=0;
{$ENDIF}
{ For Error Handling.}
ErrorBase : Longint = 0;
@ -174,6 +178,8 @@ End;
{$endif RTLLITE}
{$ifdef OLDRANDOM}
{****************************************************************************
Random function routines
@ -248,6 +254,26 @@ begin
Seed3 := (Random(65000) * Random(65000)) mod 765241;
end;
{$ELSE OLDRANDOM}
function random:real;
begin
do_random1;
do_random2;
random:=randseed;
random:=seed2+random/(65536.0*65536.0);
random:=random/(65536.0*65536.0);
end;
function random(l:cardinal):cardinal;
begin
do_random1;
random:=randseed mod l;
end;
{$ENDIF RANDOM}
{ Include processor specific routines }
{$I math.inc}
@ -580,7 +606,10 @@ end;
{
$Log$
Revision 1.69 1999-11-06 14:35:39 peter
Revision 1.70 1999-11-09 20:14:12 daniel
* Committed new random generator.
Revision 1.69 1999/11/06 14:35:39 peter
* truncated log
Revision 1.68 1999/10/26 12:31:00 peter

View File

@ -179,7 +179,11 @@ Function Swap (X:Int64):Int64;
{$endif}
{$endif RTLLITE}
Function Random(l:Longint):Longint;
{$IFNDEF OLDRANDOM}
Function Random(l:cardinal):cardinal;
{$ELSE}
Function Random(l:longint):longint;
{$ENDIF}
Function Random:real;
Procedure Randomize;
@ -398,7 +402,10 @@ const
{
$Log$
Revision 1.65 1999-11-06 14:35:39 peter
Revision 1.66 1999-11-09 20:14:12 daniel
* Committed new random generator.
Revision 1.65 1999/11/06 14:35:39 peter
* truncated log
Revision 1.64 1999/10/27 14:19:10 florian