-
Notifications
You must be signed in to change notification settings - Fork 40
/
field_moves.asm
executable file
·345 lines (288 loc) · 5.53 KB
/
field_moves.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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
; Copied pretty much verbatim from proof-of-concept code by Yenatch.
; Expanded by Mateo to work more like Gen 2, and to fix a bug with Cut requiring the wrong badge.
; Additional comments added by Mateo to clarify existing yenatch code and new Mateo code.
TryFieldMove:: ; predef
call GetPredefRegisters
.Main:
call TrySurf
ret z
call TryCut
ret z
call TryHeadbutt
ret
TrySurf:
; Check if you are already surfing, and don't do anything if you are.
ld a, [wWalkBikeSurfState]
cp 2
jr z, .no
; Check to make sure you are facing a surfable tile.
call IsSurfTile
jr nc, .no
; Check to make sure you aren't on top of a cliff or something.
ld hl,TilePairCollisionsWater
call CheckForTilePairCollisions2
jr c, .no
; Check for a Pokemon in the party with SURF, and for the proper badge to use it.
ld d, SURF
call HasPartyMove
jr nz, .no
ld a, [wObtainedKantoBadges]
bit 4, a ; SOUL_BADGE
jr z, .no
; Are we allowed to surf here?
call Text2_EnterTheText
callba IsSurfingAllowed ; in current Pokered, this is callba IsSurfingAllowed
ld hl,wd728
bit 1,[hl]
res 1,[hl]
jr z,.no2
; Display "The water is calm. Do you want to SURF?" prompt like Gen 2 does.
ld hl,WaterIsCalmTxt
call PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
jr nz, .no2
; Call the Surf routine if you said yes.
call GetPartyMonName2
ld a, SURFBOARD
ld [wcf91], a
ld [wPseudoItemID], a
call UseItem
call Text3_DrakesDeception
.yes
xor a
ret
.no2
call Text3_DrakesDeception
.no
ld a, 1
and a
ret
TryCut: ; yenatch's code originally checked for the SOUL_BADGE like SURF does by mistake.
call IsCutTile
jr nc, .no
; Prints the "This tree can be cut!" message, whether you can CUT yet or not.
call Text2_EnterTheText
ld hl,CanBeCutTxt
call PrintText
call ManualTextScroll
; Makes sure you have a Pokemon with CUT and have the proper badge.
ld d, CUT
call HasPartyMove
jr nz, .no2
ld a, [wObtainedKantoBadges]
bit 1, a ; CASCADE_BADGE
jr z, .no2
; Asks the player if they want to use CUT, the way Gen 2 does.
ld hl,WantToCutTxt
call PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
jr nz, .no2
; Calls the CUT routine if they said Yes.
call GetPartyMonName2
farcall Cut2
call Text3_DrakesDeception
.yes
xor a
ret
.no2
call Text3_DrakesDeception
.no
ld a, 1
and a
ret
TryHeadbutt:
call IsHeadbuttTile
jr nc, .no
; Makes sure you have a Pokemon with HEADBUTT.
ld d, HEADBUTT
call HasPartyMove
jr nz, .no
; Prints the "A Pokemon might be hiding in this tree" message
call Text2_EnterTheText
ld hl,MightBeHiding
call PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
jr nz, .no2
; Calls the HEADBUTT routine if they said Yes.
call GetPartyMonName2
farcall UseHeadbuttOW2
call Text3_DrakesDeception
.yes
xor a
ret
.no2
call Text3_DrakesDeception
.no
ld a, 1
and a
ret
IsHeadbuttTile:
ld a, [wCurMapTileset]
and a ; OVERWORLD
jr z, .overworld
cp FOREST
jr z, .forest
cp PLATEAU
jr z, .plateau
jr .no
.plateau
ld a, [wTileInFrontOfPlayer]
cp $17
jr z, .yes
jr .no
.forest
ld a, [wTileInFrontOfPlayer]
cp $12
jr z, .yes
jr .no
.overworld
ld a, [wTileInFrontOfPlayer]
cp $50
jr z, .yes
.no
and a
ret
.yes
scf
ret
IsSurfTile:
ld a, [wCurMapTileset]
ld hl, WaterTilesets2
ld de,1
call IsInArray
jr nc, .no
ld a, [wCurMapTileset]
cp SHIP_PORT
ld a, [wTileInFrontOfPlayer]
jr z, .ok
cp $48 ; east shore (safari zone)
jr z, .yes
cp $32 ; east shore
jr z, .yes
.ok
cp $14 ; water
jr z, .yes
.no
and a
ret
.yes
scf
ret
; tilesets with water
; originally contained DOJO but that tileset does not exist in Red++
; just make sure this has all tilesets you want to surf in listed
WaterTilesets2: ; Renamed from what Yenatch called it, since that had overlap errors
db OVERWORLD
db FOREST
db SAFARI ; New tileset in Red++
db GYM
db SHIP
db SHIP_PORT
db CAVERN
db FACILITY
db PLATEAU
db ICE_CAVERN
db -1
IsCutTile:
ld a, [wCurMapTileset]
and a ; OVERWORLD
jr z, .overworld
cp GYM
jr z, .gym
jr .no
.gym
ld a, [wTileInFrontOfPlayer]
cp $50 ; gym cut tree
jr z, .yes
jr .no
.overworld ; commented out options would let you run this when talking to tall grass if restored.
ld a, [wTileInFrontOfPlayer]
cp $3d ; cut tree
jr z, .yes
; cp $52 ; grass
; jr z, .yes
; jr .no
.no
and a
ret
.yes
scf
ret
HasPartyMove::
; Return z (optional: in wWhichTrade) if a PartyMon has move d.
; Updates wWhichPokemon.
push bc
push de
push hl
ld a, [wPartyCount]
and a
jr z, .no
ld b, a
ld c, 0
ld hl, wPartyMons + (wPartyMon1Moves - wPartyMon1)
.loop
ld e, NUM_MOVES
.check_move
ld a, [hli]
cp d
jr z, .yes
dec e
jr nz, .check_move
ld a, wPartyMon2 - wPartyMon1 - NUM_MOVES
add l
ld l, a
ld a, 0
adc h
ld h, a
inc c
ld a, c
cp b
jr c, .loop
jr .no
.yes
ld a, c
ld [wWhichPokemon], a
xor a ; probably redundant
ld [wWhichTrade], a
jr .done
.no
ld a, 1
and a
ld [wWhichTrade], a
.done
pop hl
pop de
pop bc
ret
Text2_EnterTheText: ; Gets everything setup to let you display text properly
call EnableAutoTextBoxDrawing
ld a, 1 ; not 0
ld [hSpriteIndexOrTextID], a
farcall DisplayTextIDInit
ret
Text3_DrakesDeception: ; Closes the text out properly to prevent glitches
ld a,[H_LOADEDROMBANK]
push af
jp CloseTextDisplay
CanBeCutTxt:
text "This tree can be"
line "Cut!@@"
WantToCutTxt:
text "Would you like to"
line "use Cut?@@"
WaterIsCalmTxt:
text "The water is calm."
line "Would you like to"
cont "use Surf?@@"
MightBeHiding:
text "A #mon might"
line "be hiding in this"
cont "tree."
para "Want to use"
line "Headbutt?@@"