GBAlatro
A Demake of Balatro for the GBA
Loading...
Searching...
No Matches
random.h
Go to the documentation of this file.
1
10#ifndef RANDOM_H
11#define RANDOM_H
12
13#include <tonc.h>
14
19{
20 RNG_SEQ_CARD_SHUFFLE,
21 RNG_SEQ_BLIND,
22 RNG_SEQ_SHOP_ITEMS,
23 RNG_SEQ_SKIP_TAGS,
24
25 // Each Joker with a random effect has its own independent RNG sequence
26 RNG_SEQ_JOKER_MISPRINT,
27 RNG_SEQ_JOKER_RESERVED_PARKING,
28 RNG_SEQ_JOKER_BUSINESS_CARD,
29
30 // For non-gameplay related things such as sound effects or visual effects, so as to not
31 // interfere with important stuff like Shop rolls or Joker effects.
32 RNG_SEQ_MISC,
33
34 RNG_SEQ_MAX
35};
36
40typedef struct
41{
43 u32 seed;
45 u32 states[RNG_SEQ_MAX];
46} RngInfo;
47
52void rng_init(void);
53
57void rng_update(void);
58
66void rng_set_seed(u32 seed);
67
79void rng_shuffle_seed(void);
80
88u32 rng_get_u32(enum RngSequence key);
89
98void rng_restore(RngInfo info);
99
100#endif // RANDOM_H
void rng_update(void)
Accumulates CPU cycles for RNG seed generation, call exaclty once per frame.
Definition random.c:22
void rng_shuffle_seed(void)
Sets a new randomized seed for the RNG using a source of entropy.
Definition random.c:27
u32 rng_get_u32(enum RngSequence key)
Get the next "randomly" generated number in the sequence corresponding to the given type.
Definition random.c:56
void rng_set_seed(u32 seed)
Set the rng seed to the chosen value, and reset the step counter to 0. The seed will be capped at MAX...
Definition random.c:33
RngSequence
Keys to different independent RNG sequences.
Definition random.h:19
void rng_restore(RngInfo info)
Restore RNG info struct in the GameVariables. Sets the seed and restores the state for each independe...
Definition random.c:77
void rng_init(void)
Starts counting CPU cycles, which will be used by rng_shuffle_seed to generate a more random seed....
Definition random.c:16
Information to track and restore RNG state.
Definition random.h:41
u32 seed
Definition random.h:43