pokecrystal/engine/spawn_points.asm

63 lines
811 B
NASM
Raw Normal View History

INCLUDE "data/maps/spawn_points.asm"
2015-02-11 21:59:59 +00:00
LoadSpawnPoint: ; 1531f
2018-01-23 22:39:09 +00:00
; loads the spawn point in wDefaultSpawnpoint
2015-02-11 21:59:59 +00:00
push hl
push de
2018-01-23 22:39:09 +00:00
ld a, [wDefaultSpawnpoint]
cp SPAWN_N_A
jr z, .spawn_n_a
2015-02-11 21:59:59 +00:00
ld l, a
ld h, 0
add hl, hl
add hl, hl
2015-02-11 21:59:59 +00:00
ld de, SpawnPoints
add hl, de
ld a, [hli]
2018-01-23 22:39:09 +00:00
ld [wMapGroup], a
2015-02-11 21:59:59 +00:00
ld a, [hli]
2018-01-23 22:39:09 +00:00
ld [wMapNumber], a
2015-02-11 21:59:59 +00:00
ld a, [hli]
2018-01-23 22:39:09 +00:00
ld [wXCoord], a
2015-02-11 21:59:59 +00:00
ld a, [hli]
2018-01-23 22:39:09 +00:00
ld [wYCoord], a
.spawn_n_a
2015-02-11 21:59:59 +00:00
pop de
pop hl
ret
; 15344
IsSpawnPoint: ; 15344
; Checks if the map loaded in de is a spawn point. Returns carry if it's a spawn point.
2015-02-11 21:59:59 +00:00
ld hl, SpawnPoints
ld c, 0
.loop
2015-02-11 21:59:59 +00:00
ld a, [hl]
cp SPAWN_N_A
jr z, .nope
2015-02-11 21:59:59 +00:00
cp d
jr nz, .next
2015-02-11 21:59:59 +00:00
inc hl
ld a, [hld]
cp e
jr z, .yes
2015-02-11 21:59:59 +00:00
.next
2015-02-11 21:59:59 +00:00
push bc
ld bc, 4 ; length of a spawn table entry
2015-02-11 21:59:59 +00:00
add hl, bc
pop bc
inc c
jr .loop
2015-02-11 21:59:59 +00:00
.nope
2015-02-11 21:59:59 +00:00
and a
ret
.yes
2015-02-11 21:59:59 +00:00
scf
ret
; 15363