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/Tag 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 RNG_SEQ_TAG_TOP_UP,
30
31 // For non-gameplay related things such as sound effects or visual effects, so as to not
32 // interfere with important stuff like Shop rolls or Joker effects.
33 RNG_SEQ_MISC,
34
35 RNG_SEQ_MAX
36};
37
41typedef struct
42{
44 u32 seed;
46 u32 states[RNG_SEQ_MAX];
47} RngInfo;
48
53void rng_init(void);
54
58void rng_update(void);
59
67void rng_set_seed(u32 seed);
68
80void rng_shuffle_seed(void);
81
89u32 rng_get_u32(enum RngSequence key);
90
99void rng_restore(RngInfo info);
100
101#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:42
u32 seed
Definition random.h:44