mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08:00
58 lines
612 B
NASM
58 lines
612 B
NASM
IsInArray::
|
|
; Find value a for every de bytes in array hl.
|
|
; Return index in b and carry if found.
|
|
|
|
ld b, 0
|
|
ld c, a
|
|
.loop
|
|
ld a, [hl]
|
|
cp -1
|
|
jr z, .NotInArray
|
|
cp c
|
|
jr z, .InArray
|
|
inc b
|
|
add hl, de
|
|
jr .loop
|
|
|
|
.NotInArray:
|
|
and a
|
|
ret
|
|
|
|
.InArray:
|
|
scf
|
|
ret
|
|
|
|
SkipNames::
|
|
; Skip a names.
|
|
ld bc, NAME_LENGTH
|
|
and a
|
|
ret z
|
|
.loop
|
|
add hl, bc
|
|
dec a
|
|
jr nz, .loop
|
|
ret
|
|
|
|
AddNTimes::
|
|
; Add bc * a to hl.
|
|
and a
|
|
ret z
|
|
.loop
|
|
add hl, bc
|
|
dec a
|
|
jr nz, .loop
|
|
ret
|
|
|
|
; advance c [b]-terminated table entries in hl
|
|
AdvanceNEntries::
|
|
ld a, c
|
|
and a
|
|
ret z
|
|
.loop
|
|
ld a, [hli]
|
|
cp b
|
|
jr nz, .loop
|
|
dec c
|
|
jr nz, .loop
|
|
ret
|