pokecrystal-board/engine/spawn_points.asm
Remy Oukaour 7d4486e6a3 Remove all code from main.asm (some labeled INCBINs, like out-of-context graphics, are still present)
engine/routines/ stores isolated out-of-context routines as individual files. It might be preferable later to append them to their related engine/ files in unique little SECTIONs, relying on the linkerscript to place them appropriately; or some other organization method. In the meantime, they're now easily findable apart from main.asm's other content.
2017-12-24 19:35:35 -05:00

63 lines
805 B
NASM

INCLUDE "data/maps/spawn_points.asm"
LoadSpawnPoint: ; 1531f
; loads the spawn point in DefaultSpawnpoint
push hl
push de
ld a, [DefaultSpawnpoint]
cp SPAWN_N_A
jr z, .spawn_n_a
ld l, a
ld h, 0
add hl, hl
add hl, hl
ld de, SpawnPoints
add hl, de
ld a, [hli]
ld [MapGroup], a
ld a, [hli]
ld [MapNumber], a
ld a, [hli]
ld [XCoord], a
ld a, [hli]
ld [YCoord], a
.spawn_n_a
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.
ld hl, SpawnPoints
ld c, 0
.loop
ld a, [hl]
cp SPAWN_N_A
jr z, .nope
cp d
jr nz, .next
inc hl
ld a, [hld]
cp e
jr z, .yes
.next
push bc
ld bc, 4 ; length of a spawn table entry
add hl, bc
pop bc
inc c
jr .loop
.nope
and a
ret
.yes
scf
ret
; 15363