Add a replication of MSVC2003's rand() algorithm
This actually affects how the game sounds. Seriously, listen to the dialogue boxes. Now it matches the original.
This commit is contained in:
parent
e4fcf6a5e1
commit
22c967ca3a
5 changed files with 26 additions and 3 deletions
1
Makefile
1
Makefile
|
@ -115,6 +115,7 @@ SOURCES = \
|
||||||
src/Organya \
|
src/Organya \
|
||||||
src/PixTone \
|
src/PixTone \
|
||||||
src/Profile \
|
src/Profile \
|
||||||
|
src/Random \
|
||||||
src/Resource \
|
src/Resource \
|
||||||
src/SelStage \
|
src/SelStage \
|
||||||
src/Shoot \
|
src/Shoot \
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "NpcHit.h"
|
#include "NpcHit.h"
|
||||||
#include "NpcTbl.h"
|
#include "NpcTbl.h"
|
||||||
#include "Profile.h"
|
#include "Profile.h"
|
||||||
|
#include "Random.h"
|
||||||
#include "SelStage.h"
|
#include "SelStage.h"
|
||||||
#include "Shoot.h"
|
#include "Shoot.h"
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
|
@ -54,7 +55,7 @@ BOOL bContinue;
|
||||||
int Random(int min, int max)
|
int Random(int min, int max)
|
||||||
{
|
{
|
||||||
const int range = max - min + 1;
|
const int range = max - min + 1;
|
||||||
return min + rand() % range;
|
return min + msvc_rand() % range;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PutNumber4(int x, int y, int value, BOOL bZero)
|
void PutNumber4(int x, int y, int value, BOOL bZero)
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
|
#include "Random.h"
|
||||||
|
|
||||||
static signed char gWaveModelTable[6][256];
|
static signed char gWaveModelTable[6][256];
|
||||||
|
|
||||||
void MakeWaveTables(void)
|
void MakeWaveTables(void)
|
||||||
|
@ -54,9 +56,9 @@ void MakeWaveTables(void)
|
||||||
gWaveModelTable[4][i] = -0x40;
|
gWaveModelTable[4][i] = -0x40;
|
||||||
|
|
||||||
// White noise wave
|
// White noise wave
|
||||||
srand(0);
|
msvc_srand(0);
|
||||||
for (i = 0; i < 256; ++i)
|
for (i = 0; i < 256; ++i)
|
||||||
gWaveModelTable[5][i] = (signed char)(rand() & 0xFF) / 2;
|
gWaveModelTable[5][i] = (signed char)(msvc_rand() & 0xFF) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData)
|
BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData)
|
||||||
|
|
15
src/Random.cpp
Normal file
15
src/Random.cpp
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#include "Random.h"
|
||||||
|
|
||||||
|
// A replication of MSVC's rand algorithm
|
||||||
|
static unsigned long next = 1;
|
||||||
|
|
||||||
|
int msvc_rand(void)
|
||||||
|
{
|
||||||
|
next = ((next) * 214013 + 2531011);
|
||||||
|
return ((next) >> 16) & 0x7FFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
void msvc_srand(unsigned int seed)
|
||||||
|
{
|
||||||
|
next = seed;
|
||||||
|
}
|
4
src/Random.h
Normal file
4
src/Random.h
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
int msvc_rand(void);
|
||||||
|
void msvc_srand(unsigned int seed);
|
Loading…
Add table
Reference in a new issue