summaryrefslogtreecommitdiff
path: root/home/pikachu.asm
blob: ae6acfe3b62b79568666060fc4280d1aa1f7e47d (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
Func_1510::
	push hl
	ld hl, wPikachuOverworldStateFlags
	set 7, [hl]
	ld hl, wSpritePikachuStateData1ImageIndex ; pikachu data?
	ld [hl], $ff
	pop hl
	ret

Func_151d::
	push hl
	ld hl, wPikachuOverworldStateFlags
	res 7, [hl]
	pop hl
	ret

EnablePikachuOverworldSpriteDrawing::
	push hl
	ld hl, wPikachuOverworldStateFlags
	res 3, [hl]
	pop hl
	ret

DisablePikachuOverworldSpriteDrawing::
	push hl
	ld hl, wPikachuOverworldStateFlags
	set 3, [hl]
	ld hl, wSpritePikachuStateData1ImageIndex ; pikachu data?
	ld [hl], $ff
	pop hl
	ret

DisablePikachuFollowingPlayer::
	push hl
	ld hl, wPikachuOverworldStateFlags
	set 1, [hl]
	pop hl
	ret

EnablePikachuFollowingPlayer::
	push hl
	ld hl, wPikachuOverworldStateFlags
	res 1, [hl]
	pop hl
	ret

CheckPikachuFollowingPlayer::
	push hl
	ld hl, wPikachuOverworldStateFlags
	bit 1, [hl]
	pop hl
	ret

SpawnPikachu::
	ld a, [hl]
	dec a
	swap a
	ldh [hTilePlayerStandingOn], a
	homecall SpawnPikachu_
	ret

Pikachu_IsInArray::
	ld b, $0
	ld c, a
.loop
	inc b
	ld a, [hli]
	cp $ff
	jr z, .not_in_array
	cp c
	jr nz, .loop
	dec b
	dec hl
	scf
	ret

.not_in_array
	dec b
	dec hl
	and a
	ret

GetPikachuMovementScriptByte::
	push hl
	push bc
	ldh a, [hLoadedROMBank]
	push af
	ld a, [wPikachuMovementScriptBank]
	call BankswitchCommon
	ld hl, wPikachuMovementScriptAddress
	ld c, [hl]
	inc hl
	ld b, [hl]
	ld a, [bc]
	inc bc
	ld [hl], b
	dec hl
	ld [hl], c
	ld c, a
	pop af
	call BankswitchCommon
	ld a, c
	pop bc
	pop hl
	ret

ApplyPikachuMovementData::
	ldh a, [hLoadedROMBank]
	ld b, a
	push af
	ld a, BANK(ApplyPikachuMovementData_)
	call BankswitchCommon
	call ApplyPikachuMovementData_
	pop af
	call BankswitchCommon
	ret