git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

commit 15540103061a591ca7db8bd12169047ffeb57f60
parent 4a5938132cab880956aff5724b2f1bbf8418435b
Author: bbbbbr <bbbbbr@users.noreply.github.com>
Date:   Thu, 27 Jan 2022 20:50:19 -0800

Merge pull request #308 from bbbbbr/docs_4_0_6

Docs: document __rand_seed and add it to rand.h
Diffstat:
Mdocs/pages/10_release_notes.md1+
Mgbdk-lib/include/rand.h16+++++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/docs/pages/10_release_notes.md b/docs/pages/10_release_notes.md @@ -29,6 +29,7 @@ https://github.com/gbdk-2020/gbdk-2020/releases - Fixed random number generation for SMS/GG - Fixed letter `U` appearing as `K` for min font - Fixed define name in crash_handler.h + - Exposed @ref __rand_seed - Toolchain / Utilities - @ref utility_png2asset "png2asset" - Added SMS/GG graphics format support diff --git a/gbdk-lib/include/rand.h b/gbdk-lib/include/rand.h @@ -20,8 +20,9 @@ particularly if read at some variable point in time (such as when the player presses a button). - Only needs to be called once to initialize, buy may be called + Only needs to be called once to initialize, but may be called again to re-initialize with the same or a different seed. + @see rand(), randw() */ #if defined(__PORT_gbz80) @@ -33,6 +34,19 @@ void initrand(uint16_t seed) Z88DK_FASTCALL; #define RAND_MAX 255 #define RANDW_MAX 65535 +/** The random number seed is stored in __rand_seed and can be + saved and restored if needed. + + \code{.c} + // Save + some_uint16 = __rand_seed; + ... + // Restore + __rand_seed = some_uint16; + \endcode +*/ +extern uint16_t __rand_seed; + /** Returns a random byte (8 bit) value. @ref initrand() should be used to initialize the random number generator before using rand()

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.