From 6fafe08b7dc884960582d272d35650d1c9dfdf87 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Thu, 11 May 2023 23:00:53 +0100 Subject: Add some randomness --- game/random.asm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 game/random.asm (limited to 'game/random.asm') diff --git a/game/random.asm b/game/random.asm new file mode 100644 index 0000000..0cb74db --- /dev/null +++ b/game/random.asm @@ -0,0 +1,24 @@ +; +; Random number generator +; +; x[i + 1] = (5 * x[i] + 1) mod 256 +; +; out: y random value +rnd: + ld x, seed + + ld y, [a : x] + ld b, y + + add y, y + add y, y + add y, b + add y, 7 + + ld [a : x], y + + ret + +seed: + .db 0 -- cgit v1.2.3