Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/battle/common_text.asm
1271 views
1
PrintBeginningBattleText:
2
ld a, [wIsInBattle]
3
dec a
4
jr nz, .trainerBattle
5
ld a, [wCurMap]
6
cp POKEMON_TOWER_3F
7
jr c, .notPokemonTower
8
cp POKEMON_TOWER_7F + 1
9
jr c, .pokemonTower
10
.notPokemonTower
11
ld a, [wEnemyMonSpecies2]
12
call PlayCry
13
ld hl, WildMonAppearedText
14
ld a, [wMoveMissed]
15
and a
16
jr z, .notFishing
17
ld hl, HookedMonAttackedText
18
.notFishing
19
jr .wildBattle
20
.trainerBattle
21
call .playSFX
22
ld c, 20
23
call DelayFrames
24
ld hl, TrainerWantsToFightText
25
.wildBattle
26
push hl
27
callfar DrawAllPokeballs
28
pop hl
29
call PrintText
30
jr .done
31
.pokemonTower
32
ld b, SILPH_SCOPE
33
call IsItemInBag
34
ld a, [wEnemyMonSpecies2]
35
ld [wCurPartySpecies], a
36
cp RESTLESS_SOUL
37
jr z, .isMarowak
38
ld a, b
39
and a
40
jr z, .noSilphScope
41
callfar LoadEnemyMonData
42
jr .notPokemonTower
43
.noSilphScope
44
ld hl, EnemyAppearedText
45
call PrintText
46
ld hl, GhostCantBeIDdText
47
call PrintText
48
jr .done
49
.isMarowak
50
ld a, b
51
and a
52
jr z, .noSilphScope
53
ld hl, EnemyAppearedText
54
call PrintText
55
ld hl, UnveiledGhostText
56
call PrintText
57
callfar LoadEnemyMonData
58
callfar MarowakAnim
59
ld hl, WildMonAppearedText
60
call PrintText
61
62
.playSFX
63
xor a
64
ld [wFrequencyModifier], a
65
ld a, $80
66
ld [wTempoModifier], a
67
ld a, SFX_SILPH_SCOPE
68
call PlaySound
69
jp WaitForSoundToFinish
70
.done
71
ret
72
73
WildMonAppearedText:
74
text_far _WildMonAppearedText
75
text_end
76
77
HookedMonAttackedText:
78
text_far _HookedMonAttackedText
79
text_end
80
81
EnemyAppearedText:
82
text_far _EnemyAppearedText
83
text_end
84
85
TrainerWantsToFightText:
86
text_far _TrainerWantsToFightText
87
text_end
88
89
UnveiledGhostText:
90
text_far _UnveiledGhostText
91
text_end
92
93
GhostCantBeIDdText:
94
text_far _GhostCantBeIDdText
95
text_end
96
97
PrintSendOutMonMessage:
98
ld hl, wEnemyMonHP
99
ld a, [hli]
100
or [hl]
101
ld hl, GoText
102
jr z, .printText
103
xor a
104
ldh [hMultiplicand], a
105
ld hl, wEnemyMonHP
106
ld a, [hli]
107
ld [wLastSwitchInEnemyMonHP], a
108
ldh [hMultiplicand + 1], a
109
ld a, [hl]
110
ld [wLastSwitchInEnemyMonHP + 1], a
111
ldh [hMultiplicand + 2], a
112
ld a, 25
113
ldh [hMultiplier], a
114
call Multiply
115
ld hl, wEnemyMonMaxHP
116
ld a, [hli]
117
ld b, [hl]
118
srl a
119
rr b
120
srl a
121
rr b
122
ld a, b
123
ld b, 4
124
ldh [hDivisor], a ; enemy mon max HP divided by 4
125
call Divide
126
ldh a, [hQuotient + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP
127
ld hl, GoText ; 70% or greater
128
cp 70
129
jr nc, .printText
130
ld hl, DoItText ; 40% - 69%
131
cp 40
132
jr nc, .printText
133
ld hl, GetmText ; 10% - 39%
134
cp 10
135
jr nc, .printText
136
ld hl, EnemysWeakText ; 0% - 9%
137
.printText
138
jp PrintText
139
140
GoText:
141
text_far _GoText
142
text_asm
143
jr PrintPlayerMon1Text
144
145
DoItText:
146
text_far _DoItText
147
text_asm
148
jr PrintPlayerMon1Text
149
150
GetmText:
151
text_far _GetmText
152
text_asm
153
jr PrintPlayerMon1Text
154
155
EnemysWeakText:
156
text_far _EnemysWeakText
157
text_asm
158
159
PrintPlayerMon1Text:
160
ld hl, PlayerMon1Text
161
ret
162
163
PlayerMon1Text:
164
text_far _PlayerMon1Text
165
text_end
166
167
RetreatMon:
168
ld hl, PlayerMon2Text
169
jp PrintText
170
171
PlayerMon2Text:
172
text_far _PlayerMon2Text
173
text_asm
174
push de
175
push bc
176
ld hl, wEnemyMonHP + 1
177
ld de, wLastSwitchInEnemyMonHP + 1
178
ld b, [hl]
179
dec hl
180
ld a, [de]
181
sub b
182
ldh [hMultiplicand + 2], a
183
dec de
184
ld b, [hl]
185
ld a, [de]
186
sbc b
187
ldh [hMultiplicand + 1], a
188
ld a, 25
189
ldh [hMultiplier], a
190
call Multiply
191
ld hl, wEnemyMonMaxHP
192
ld a, [hli]
193
ld b, [hl]
194
srl a
195
rr b
196
srl a
197
rr b
198
ld a, b
199
ld b, 4
200
ldh [hDivisor], a
201
call Divide
202
pop bc
203
pop de
204
ldh a, [hQuotient + 3] ; a = ((LastSwitchInEnemyMonHP - CurrentEnemyMonHP) / 25) / (EnemyMonMaxHP / 4)
205
; Assuming that the enemy mon hasn't gained HP since the last switch in,
206
; a approximates the percentage that the enemy mon's total HP has decreased
207
; since the last switch in.
208
; If the enemy mon has gained HP, then a is garbage due to wrap-around and
209
; can fall in any of the ranges below.
210
ld hl, EnoughText ; HP stayed the same
211
and a
212
ret z
213
ld hl, ComeBackText ; HP went down 1% - 29%
214
cp 30
215
ret c
216
ld hl, OKExclamationText ; HP went down 30% - 69%
217
cp 70
218
ret c
219
ld hl, GoodText ; HP went down 70% or more
220
ret
221
222
EnoughText:
223
text_far _EnoughText
224
text_asm
225
jr PrintComeBackText
226
227
OKExclamationText:
228
text_far _OKExclamationText
229
text_asm
230
jr PrintComeBackText
231
232
GoodText:
233
text_far _GoodText
234
text_asm
235
jr PrintComeBackText
236
237
PrintComeBackText:
238
ld hl, ComeBackText
239
ret
240
241
ComeBackText:
242
text_far _ComeBackText
243
text_end
244
245