Random number generation demo. More...
Functions | |
| int | main (void) |
| Entry point — gameLoopRun never returns. | |
| static void | on_init (void) |
| One-time setup. Static labels + first random + screen on. | |
| static void | on_update (void) |
| Per-frame: read input, regenerate on A, re-seed on B, print value. | |
Variables | |
| u16 | current_value |
| Current random value to display. | |
Random number generation demo.
Generates and displays random 16-bit numbers on button press. Demonstrates the LFSR-based pseudo-random number generator and how to seed it for varied sequences.
Every game needs randomness — enemy spawn positions, item drops, damage variance, shuffle order. The SNES has no hardware RNG, so we use a software PRNG seeded from the frame counter at game start.
Ported from PVSnesLib "random" example by alekmaul.
| int main | ( | void | ) |
Entry point — gameLoopRun never returns.
|
static |
One-time setup. Static labels + first random + screen on.
|
static |
Per-frame: read input, regenerate on A, re-seed on B, print value.
The framework calls this once per VBlank — padPressed() reads the NMI-updated joypad buffer and returns only the bits that just transitioned (single-press detection), so holding the button down keeps producing the same number until release.
| u16 current_value |
Current random value to display.