2017-12-14 20:00:54 -08:00
|
|
|
INCLUDE "data/maps/spawn_points.asm"
|
2015-02-11 13:59:59 -08:00
|
|
|
|
2019-11-18 09:16:50 -08:00
|
|
|
EnterMapSpawnPoint:
|
2018-01-23 14:39:09 -08:00
|
|
|
; loads the spawn point in wDefaultSpawnpoint
|
2015-02-11 13:59:59 -08:00
|
|
|
push hl
|
|
|
|
push de
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wDefaultSpawnpoint]
|
2015-07-15 12:48:44 -07:00
|
|
|
cp SPAWN_N_A
|
|
|
|
jr z, .spawn_n_a
|
2023-10-31 12:25:56 -07:00
|
|
|
cp SPAWN_FROM_RAM
|
|
|
|
jr z, .spawn_from_ram
|
2015-02-11 13:59:59 -08:00
|
|
|
ld l, a
|
|
|
|
ld h, 0
|
2017-12-08 21:50:59 -08:00
|
|
|
add hl, hl
|
|
|
|
add hl, hl
|
2015-02-11 13:59:59 -08:00
|
|
|
ld de, SpawnPoints
|
|
|
|
add hl, de
|
|
|
|
ld a, [hli]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMapGroup], a
|
2015-02-11 13:59:59 -08:00
|
|
|
ld a, [hli]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wMapNumber], a
|
2015-02-11 13:59:59 -08:00
|
|
|
ld a, [hli]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wXCoord], a
|
2015-02-11 13:59:59 -08:00
|
|
|
ld a, [hli]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wYCoord], a
|
2023-10-31 12:25:56 -07:00
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
|
|
|
.spawn_from_ram
|
|
|
|
; exiting from View Map mode
|
|
|
|
ld a, [wBeforeViewMapMapGroup]
|
|
|
|
ld [wMapGroup], a
|
|
|
|
ld a, [wBeforeViewMapMapNumber]
|
|
|
|
ld [wMapNumber], a
|
|
|
|
ld a, [wBeforeViewMapXCoord]
|
|
|
|
ld [wXCoord], a
|
|
|
|
ld a, [wBeforeViewMapYCoord]
|
|
|
|
ld [wYCoord], a
|
2015-07-15 12:48:44 -07:00
|
|
|
.spawn_n_a
|
2015-02-11 13:59:59 -08:00
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
IsSpawnPoint:
|
2015-07-15 12:48:44 -07:00
|
|
|
; Checks if the map loaded in de is a spawn point. Returns carry if it's a spawn point.
|
2015-02-11 13:59:59 -08:00
|
|
|
ld hl, SpawnPoints
|
|
|
|
ld c, 0
|
2015-07-15 12:48:44 -07:00
|
|
|
.loop
|
2015-02-11 13:59:59 -08:00
|
|
|
ld a, [hl]
|
2015-07-15 12:48:44 -07:00
|
|
|
cp SPAWN_N_A
|
|
|
|
jr z, .nope
|
2015-02-11 13:59:59 -08:00
|
|
|
cp d
|
2015-07-15 12:48:44 -07:00
|
|
|
jr nz, .next
|
2015-02-11 13:59:59 -08:00
|
|
|
inc hl
|
|
|
|
ld a, [hld]
|
|
|
|
cp e
|
2015-07-15 12:48:44 -07:00
|
|
|
jr z, .yes
|
2015-02-11 13:59:59 -08:00
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.next
|
2015-02-11 13:59:59 -08:00
|
|
|
push bc
|
2015-07-23 09:59:19 -07:00
|
|
|
ld bc, 4 ; length of a spawn table entry
|
2015-02-11 13:59:59 -08:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
inc c
|
2015-07-15 12:48:44 -07:00
|
|
|
jr .loop
|
2015-02-11 13:59:59 -08:00
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.nope
|
2015-02-11 13:59:59 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-07-15 12:48:44 -07:00
|
|
|
.yes
|
2015-02-11 13:59:59 -08:00
|
|
|
scf
|
|
|
|
ret
|