pokeemerald/src/random.c

34 lines
490 B
C
Raw Normal View History

2017-02-03 01:30:08 +01:00
#include "global.h"
#include "random.h"
2017-02-03 01:30:08 +01:00
2017-02-03 18:32:51 +01:00
EWRAM_DATA static u8 sUnknown = 0;
EWRAM_DATA static u32 sRandCount = 0;
2017-02-03 01:30:08 +01:00
2018-04-29 14:21:59 +02:00
// IWRAM common
u32 gRngValue;
u32 gRng2Value;
2018-04-29 14:21:59 +02:00
2017-09-08 18:28:00 +02:00
u16 Random(void)
2017-02-03 01:30:08 +01:00
{
gRngValue = ISO_RANDOMIZE1(gRngValue);
2017-02-03 01:30:08 +01:00
sRandCount++;
return gRngValue >> 16;
}
void SeedRng(u16 seed)
{
gRngValue = seed;
sUnknown = 0;
}
void SeedRng2(u16 seed)
{
gRng2Value = seed;
}
u16 Random2(void)
{
gRng2Value = ISO_RANDOMIZE1(gRng2Value);
2017-02-03 01:30:08 +01:00
return gRng2Value >> 16;
}