diff options
author | Pokeglitch <pokeglitchx@gmail.com> | 2018-06-04 14:29:20 -0400 |
---|---|---|
committer | Pokeglitch <pokeglitchx@gmail.com> | 2018-06-04 14:29:20 -0400 |
commit | 1f01b4d3300dbb3a5b507910feda967e62c41ac7 (patch) | |
tree | f1d3774bef378b993ee8af0850324adabaf2711b /home/tables.asm | |
parent | 00899db6ab22268bc9ec4ea7c55c183a69731b7f (diff) |
Added Inventory Add/Remove routines
Diffstat (limited to 'home/tables.asm')
-rwxr-xr-x | home/tables.asm | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/home/tables.asm b/home/tables.asm new file mode 100755 index 0000000..6831d10 --- /dev/null +++ b/home/tables.asm @@ -0,0 +1,32 @@ +INCLUDE "constants.asm"
+
+SECTION "FindItemInTable", ROM0[$35F8]
+
+; Inputs:
+; hl = start of table to check
+; de = row size
+; a = item to search for
+; Outputs:
+; carry = item found
+; b = row index of item
+FindItemInTable: ; 00:35F8
+ ld b, 0
+ ld c, a
+
+.nextItem
+ ld a, [hl] ; load the next item
+ cp $FF ; is the list finished?
+ jr z, .fail ; if so, then fail
+ cp c ; does this item match?
+ jr z, .success ; if so, then set the carry flag
+ inc b ; increase the row index count
+ add hl, de ; move the next row
+ jr .nextItem ; check the next item
+
+.fail
+ and a ; unset the carry flag to indicate failure
+ ret
+
+.success
+ scf ; set the carry flag to indicate success
+ ret
\ No newline at end of file |