summaryrefslogtreecommitdiff
path: root/home/tables.asm
diff options
context:
space:
mode:
authorehw <Knuckles500@gmail.com>2018-06-05 11:03:34 -0400
committerGitHub <noreply@github.com>2018-06-05 11:03:34 -0400
commita62cf40b29a814188c545e47d7534b6ea3aebcc1 (patch)
tree3db618e96e50af65d6831e4ce2540fb0435a954e /home/tables.asm
parent771d125c7564a0ff1e511733114d53ad0521c3f8 (diff)
parentc4c2b3cc6ede5259a1246c195a8c1d58e6d3a35d (diff)
Merge pull request #4 from pret/master
Merge master
Diffstat (limited to 'home/tables.asm')
-rwxr-xr-xhome/tables.asm27
1 files changed, 27 insertions, 0 deletions
diff --git a/home/tables.asm b/home/tables.asm
new file mode 100755
index 0000000..dc9cebe
--- /dev/null
+++ b/home/tables.asm
@@ -0,0 +1,27 @@
+INCLUDE "constants.asm"
+
+SECTION "FindItemInTable", ROM0[$35F8]
+
+; find value a from table hl with row length de
+; returns carry and row index b if successful
+FindItemInTable: ; 00:35F8
+ ld b, 0
+ ld c, a
+
+.loop
+ ld a, [hl]
+ cp -1
+ jr z, .fail
+ cp c
+ jr z, .success
+ inc b
+ add hl, de
+ jr .loop
+
+.fail
+ and a
+ ret
+
+.success
+ scf
+ ret