summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2012-05-30 21:11:21 -0500
committerBryan Bishop <kanzure@gmail.com>2012-05-30 21:11:21 -0500
commit92b42d4aebe9a9ea355dfd734b2a0032683c5dc2 (patch)
tree940094c9f4478cb02bc7c4333550ec2839e66997
parent441959d6f1c67573f06afb096cc7a22c980c8080 (diff)
copy in IsInArray from pokered
-rw-r--r--main.asm27
1 files changed, 26 insertions, 1 deletions
diff --git a/main.asm b/main.asm
index 16878e72f..bc825df1a 100644
--- a/main.asm
+++ b/main.asm
@@ -195,7 +195,32 @@ GetFarHalfword: ; 0x305d
ret
; 0x306b
-INCBIN "baserom.gbc",$306b,$30fe-$306b
+INCBIN "baserom.gbc",$306b,$30e1-$306b
+
+IsInArray: ; 30e1
+; searches an array at hl for the value in a.
+; skips (de - 1) bytes between reads, so to check every byte, de should be 1.
+; if found, returns count in b and sets carry.
+ ld b,0
+ ld c,a
+.loop\@
+ ld a,[hl]
+ cp a,$FF
+ jr z,.NotInArray\@
+ cp c
+ jr z,.InArray\@
+ inc b
+ add hl,de
+ jr .loop\@
+.NotInArray\@
+ and a
+ ret
+.InArray\@
+ scf
+ ret
+; 0x30f4
+
+INCBIN "baserom.gbc",$30f4,$30fe - $30f4
AddNTimes: ; 0x30fe
and a