Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/home/array2.asm
1270 views
1
CallFunctionInTable::
2
; Call function a in jumptable hl.
3
; de is not preserved.
4
push hl
5
push de
6
push bc
7
add a
8
ld d, 0
9
ld e, a
10
add hl, de
11
ld a, [hli]
12
ld h, [hl]
13
ld l, a
14
ld de, .returnAddress
15
push de
16
jp hl
17
.returnAddress
18
pop bc
19
pop de
20
pop hl
21
ret
22
23
IsInArray::
24
; Search an array at hl for the value in a.
25
; Entry size is de bytes.
26
; Return count b and carry if found.
27
ld b, 0
28
29
IsInRestOfArray::
30
ld c, a
31
.loop
32
ld a, [hl]
33
cp -1
34
jr z, .notfound
35
cp c
36
jr z, .found
37
inc b
38
add hl, de
39
jr .loop
40
41
.notfound
42
and a
43
ret
44
45
.found
46
scf
47
ret
48
49