summaryrefslogtreecommitdiff
path: root/home/tables.asm
blob: c005ffca4feacd9ca7eece206b71ae1d0cca148c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
INCLUDE "constants.asm"
	
SECTION "home/tables.asm", ROM0

; find value a from table hl with row length de
; returns carry and row index b if successful
FindItemInTable:
	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