summaryrefslogtreecommitdiff
path: root/home/array.asm
diff options
context:
space:
mode:
authorRangi <35663410+Rangi42@users.noreply.github.com>2020-02-23 14:16:26 -0500
committerGitHub <noreply@github.com>2020-02-23 14:16:26 -0500
commitef1c4c5a813595841a2c81105ca0c06e5ea85db0 (patch)
treee5d59ac8f5a649ba4add7f7a3fa64c09ecfbc6b5 /home/array.asm
parent9a927c1b3efa2eca886f346a4fcca0eb57278faf (diff)
parent813d0aa73a16ababcf257d4df57ff3b69879b011 (diff)
Merge pull request #687 from mid-kid/master
Small home/ reorganization
Diffstat (limited to 'home/array.asm')
-rw-r--r--home/array.asm44
1 files changed, 44 insertions, 0 deletions
diff --git a/home/array.asm b/home/array.asm
new file mode 100644
index 000000000..0abf9b7d3
--- /dev/null
+++ b/home/array.asm
@@ -0,0 +1,44 @@
+IsInArray::
+; Find value a for every de bytes in array hl.
+; Return index in b and carry if found.
+
+ ld b, 0
+ ld c, a
+.loop
+ ld a, [hl]
+ cp -1
+ jr z, .NotInArray
+ cp c
+ jr z, .InArray
+ inc b
+ add hl, de
+ jr .loop
+
+.NotInArray:
+ and a
+ ret
+
+.InArray:
+ scf
+ ret
+
+SkipNames::
+; Skip a names.
+ ld bc, NAME_LENGTH
+ and a
+ ret z
+.loop
+ add hl, bc
+ dec a
+ jr nz, .loop
+ ret
+
+AddNTimes::
+; Add bc * a to hl.
+ and a
+ ret z
+.loop
+ add hl, bc
+ dec a
+ jr nz, .loop
+ ret