summaryrefslogtreecommitdiff
path: root/engine/overworld/spawn_points.asm
blob: 81b04b08233d4603d0cbe18f69e7814c1fe46204 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
INCLUDE "constants.asm"

SECTION "LoadSpawnPoint", ROMX[$4791], BANK[$03]

LoadSpawnPoint: ; 03:4791
; loads the spawn point in wDefaultSpawnpoint
	push hl
	push de
	ld a, [wDefaultSpawnpoint]
	and a
	jr z, .skip
	dec a
	ld l, a
	ld h, 0
	add hl, hl
	add hl, hl
	ld de, SpawnPoints
	add hl, de
	ld a, [hli]
	ld [wMapGroup], a
	ld a, [hli]
	ld [wMapId], a
	ld a, [hli]
	ld [wXCoord], a
	ld a, [hli]
	ld [wYCoord], a
.skip
	pop de
	pop hl
	ret
	
IsSpawnPoint: ; 03:47b6
; Checks if the map loaded in de is a spawn point.
; Returns carry if it's a spawn point.
	ld hl, SpawnPoints
	ld c, 1
.loop
	ld a, [hl]
	cp SPAWN_N_A
	jr z, .fail
	cp d
	jr nz, .next
	inc hl
	ld a, [hld]
	cp e
	jr z, .succeed
.next
	push bc
	ld bc, SPAWN_POINT_SIZE
	add hl, bc
	pop bc
	inc c
	jr .loop
.fail
	and a
	ret
.succeed
	scf
	ret