diff options
author | pfero <ohpee@loves.dicksinhisan.us> | 2018-06-05 10:14:50 +0200 |
---|---|---|
committer | pfero <ohpee@loves.dicksinhisan.us> | 2018-06-05 10:14:50 +0200 |
commit | 1a7f8044799a2d52c1124c7e791ca423449df00b (patch) | |
tree | 5abd1f90bdd1099223f13ee6963607c4b5dee69a /home/tables.asm | |
parent | c0fdb258d360790e20e08e9e36e474aa4213325c (diff) | |
parent | 26393f7ee27c3a61770d3a72c12043f9c4f8c9ea (diff) |
Merge branch 'master' of https://github.com/Pokeglitch/pokegold-spaceworld
Diffstat (limited to 'home/tables.asm')
-rwxr-xr-x | home/tables.asm | 27 |
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
|