summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--home/random.asm32
-rw-r--r--shim.sym1
2 files changed, 32 insertions, 1 deletions
diff --git a/home/random.asm b/home/random.asm
new file mode 100644
index 0000000..e150312
--- /dev/null
+++ b/home/random.asm
@@ -0,0 +1,32 @@
+include "constants.asm"
+
+if DEBUG
+SECTION "Random Number Generation", ROM0 [$3270]
+else
+SECTION "Random Number Generation", ROM0 [$3234]
+endc
+
+Random::
+ push bc
+ ldh a, [rLY]
+ ld c, a
+ swap a
+ ld b, a
+ ldh a, [rDIV]
+ adc b
+ ld b, a
+ ldh a, [hRandomAdd]
+ adc b
+ ldh [hRandomAdd], a
+ ldh a, [rLY]
+ swap a
+ ld b, a
+ ldh a, [rDIV]
+ adc b
+ adc c
+ ld b, a
+ ldh a, [hRandomSub]
+ sbc b
+ ldh [hRandomSub], a
+ pop bc
+ ret
diff --git a/shim.sym b/shim.sym
index bdca7c3..ac185f2 100644
--- a/shim.sym
+++ b/shim.sym
@@ -22,7 +22,6 @@
00:23dc LoadWildMons
00:23e5 FadeIn ; This is not OverworldFadeIn, but I don't know what it is
00:2C05 StartMenuCheck
-00:3270 Random
00:3621 WaitBGMap
00:362B SetPalettes
00:3634 ClearPalettes