-
Notifications
You must be signed in to change notification settings - Fork 1k
/
common_text.asm
243 lines (222 loc) · 4.18 KB
/
common_text.asm
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
PrintBeginningBattleText:
ld a, [wIsInBattle]
dec a
jr nz, .trainerBattle
ld a, [wCurMap]
cp POKEMON_TOWER_3F
jr c, .notPokemonTower
cp POKEMON_TOWER_7F + 1
jr c, .pokemonTower
.notPokemonTower
ld a, [wEnemyMonSpecies2]
call PlayCry
ld hl, WildMonAppearedText
ld a, [wMoveMissed]
and a
jr z, .notFishing
ld hl, HookedMonAttackedText
.notFishing
jr .wildBattle
.trainerBattle
call .playSFX
ld c, 20
call DelayFrames
ld hl, TrainerWantsToFightText
.wildBattle
push hl
callfar DrawAllPokeballs
pop hl
call PrintText
jr .done
.pokemonTower
ld b, SILPH_SCOPE
call IsItemInBag
ld a, [wEnemyMonSpecies2]
ld [wCurPartySpecies], a
cp RESTLESS_SOUL
jr z, .isMarowak
ld a, b
and a
jr z, .noSilphScope
callfar LoadEnemyMonData
jr .notPokemonTower
.noSilphScope
ld hl, EnemyAppearedText
call PrintText
ld hl, GhostCantBeIDdText
call PrintText
jr .done
.isMarowak
ld a, b
and a
jr z, .noSilphScope
ld hl, EnemyAppearedText
call PrintText
ld hl, UnveiledGhostText
call PrintText
callfar LoadEnemyMonData
callfar MarowakAnim
ld hl, WildMonAppearedText
call PrintText
.playSFX
xor a
ld [wFrequencyModifier], a
ld a, $80
ld [wTempoModifier], a
ld a, SFX_SILPH_SCOPE
call PlaySound
jp WaitForSoundToFinish
.done
ret
WildMonAppearedText:
text_far _WildMonAppearedText
text_end
HookedMonAttackedText:
text_far _HookedMonAttackedText
text_end
EnemyAppearedText:
text_far _EnemyAppearedText
text_end
TrainerWantsToFightText:
text_far _TrainerWantsToFightText
text_end
UnveiledGhostText:
text_far _UnveiledGhostText
text_end
GhostCantBeIDdText:
text_far _GhostCantBeIDdText
text_end
PrintSendOutMonMessage:
ld hl, wEnemyMonHP
ld a, [hli]
or [hl]
ld hl, GoText
jr z, .printText
xor a
ldh [hMultiplicand], a
ld hl, wEnemyMonHP
ld a, [hli]
ld [wLastSwitchInEnemyMonHP], a
ldh [hMultiplicand + 1], a
ld a, [hl]
ld [wLastSwitchInEnemyMonHP + 1], a
ldh [hMultiplicand + 2], a
ld a, 25
ldh [hMultiplier], a
call Multiply
ld hl, wEnemyMonMaxHP
ld a, [hli]
ld b, [hl]
srl a
rr b
srl a
rr b
ld a, b
ld b, 4
ldh [hDivisor], a ; enemy mon max HP divided by 4
call Divide
ldh a, [hQuotient + 3] ; a = (enemy mon current HP * 25) / (enemy max HP / 4); this approximates the current percentage of max HP
ld hl, GoText ; 70% or greater
cp 70
jr nc, .printText
ld hl, DoItText ; 40% - 69%
cp 40
jr nc, .printText
ld hl, GetmText ; 10% - 39%
cp 10
jr nc, .printText
ld hl, EnemysWeakText ; 0% - 9%
.printText
jp PrintText
GoText:
text_far _GoText
text_asm
jr PrintPlayerMon1Text
DoItText:
text_far _DoItText
text_asm
jr PrintPlayerMon1Text
GetmText:
text_far _GetmText
text_asm
jr PrintPlayerMon1Text
EnemysWeakText:
text_far _EnemysWeakText
text_asm
PrintPlayerMon1Text:
ld hl, PlayerMon1Text
ret
PlayerMon1Text:
text_far _PlayerMon1Text
text_end
RetreatMon:
ld hl, PlayerMon2Text
jp PrintText
PlayerMon2Text:
text_far _PlayerMon2Text
text_asm
push de
push bc
ld hl, wEnemyMonHP + 1
ld de, wLastSwitchInEnemyMonHP + 1
ld b, [hl]
dec hl
ld a, [de]
sub b
ldh [hMultiplicand + 2], a
dec de
ld b, [hl]
ld a, [de]
sbc b
ldh [hMultiplicand + 1], a
ld a, 25
ldh [hMultiplier], a
call Multiply
ld hl, wEnemyMonMaxHP
ld a, [hli]
ld b, [hl]
srl a
rr b
srl a
rr b
ld a, b
ld b, 4
ldh [hDivisor], a
call Divide
pop bc
pop de
ldh a, [hQuotient + 3] ; a = ((LastSwitchInEnemyMonHP - CurrentEnemyMonHP) / 25) / (EnemyMonMaxHP / 4)
; Assuming that the enemy mon hasn't gained HP since the last switch in,
; a approximates the percentage that the enemy mon's total HP has decreased
; since the last switch in.
; If the enemy mon has gained HP, then a is garbage due to wrap-around and
; can fall in any of the ranges below.
ld hl, EnoughText ; HP stayed the same
and a
ret z
ld hl, ComeBackText ; HP went down 1% - 29%
cp 30
ret c
ld hl, OKExclamationText ; HP went down 30% - 69%
cp 70
ret c
ld hl, GoodText ; HP went down 70% or more
ret
EnoughText:
text_far _EnoughText
text_asm
jr PrintComeBackText
OKExclamationText:
text_far _OKExclamationText
text_asm
jr PrintComeBackText
GoodText:
text_far _GoodText
text_asm
jr PrintComeBackText
PrintComeBackText:
ld hl, ComeBackText
ret
ComeBackText:
text_far _ComeBackText
text_end