From 7cb4fe0944b839f28dfd96a88a772cd6a8b58019 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Thu, 2 Nov 2023 17:16:25 -0600 Subject: reorganized project files (part 1) (just moved files, didn't change the contents yet, and nothing will work without updating #includes and build scripts and stuff) --- fsm/random.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 fsm/random.c (limited to 'fsm/random.c') diff --git a/fsm/random.c b/fsm/random.c new file mode 100644 index 0000000..91fd929 --- /dev/null +++ b/fsm/random.c @@ -0,0 +1,16 @@ +// fsm-random.c: Random number generator for SpaghettiMonster. +// Copyright (C) 2017-2023 Selene ToyKeeper +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#ifdef USE_PSEUDO_RAND +uint8_t pseudo_rand() { + static uint16_t offset = 1024; + // loop from 1024 to 4095 + offset = ((offset + 1) & 0x0fff) | 0x0400; + pseudo_rand_seed += 0b01010101; // 85 + return pgm_read_byte(offset) + pseudo_rand_seed; +} +#endif + -- cgit v1.2.3