diff options
author | sceptillion <33798691+sceptillion@users.noreply.github.com> | 2017-12-11 00:56:09 -0800 |
---|---|---|
committer | sceptillion <33798691+sceptillion@users.noreply.github.com> | 2017-12-11 00:56:09 -0800 |
commit | 66219cd4afaa5bca25fa722b9194b5c55341a0f6 (patch) | |
tree | ddee139e313dedfe675c8f86126f177192981eaa | |
parent | fdf832bec16cbdcb07afc4a62bb74314202fadf6 (diff) |
create random.h
-rw-r--r-- | include/random.h | 11 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/random.c | 2 |
3 files changed, 14 insertions, 1 deletions
diff --git a/include/random.h b/include/random.h new file mode 100644 index 0000000..53cfdaf --- /dev/null +++ b/include/random.h @@ -0,0 +1,11 @@ +#ifndef GUARD_RANDOM_H +#define GUARD_RANDOM_H + +void SeedRng(u8 *seed); +s32 Random(void); +s32 RandomCapped(s32 cap); +s32 RandomRange(s32 a, s32 b); +s32 GetRngState(void); +void SetRngState(s32 state); + +#endif // GUARD_RANDOM_H @@ -1,4 +1,5 @@ #include "global.h" +#include "random.h" extern char ewram_start[]; @@ -26,7 +27,6 @@ extern char unk_code[]; extern void sub_800CDA8(int); extern void sub_800B540(void); extern void sub_800CF0C(void); -extern void SeedRng(u8 *); extern void sub_8004D78(void); extern void nullsub_9(void); extern void nullsub_6(void); diff --git a/src/random.c b/src/random.c index 5db7394..cfc976c 100644 --- a/src/random.c +++ b/src/random.c @@ -1,4 +1,5 @@ #include "global.h" +#include "random.h" extern s32 gRngState; @@ -26,6 +27,7 @@ s32 RandomCapped(s32 cap) return (((Random() & 0xFFFF) * cap) >> 16) & 0xFFFF; } +// Returns a random number between a and b. s32 RandomRange(s32 a, s32 b) { if (a == b) |