forked from jojobear13/shinpokered
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgary.asm
executable file
·302 lines (271 loc) · 5.03 KB
/
gary.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
GaryScript:
call EnableAutoTextBoxDrawing
ld hl, GaryScriptPointers
ld a, [wGaryCurScript]
jp CallFunctionInTable
ResetGaryScript:
xor a
ld [wJoyIgnore], a
ld [wGaryCurScript], a
ret
GaryScriptPointers:
dw GaryScript0
dw GaryScript1
dw GaryScript2
dw GaryScript3
dw GaryScript4
dw GaryScript5
dw GaryScript6
dw GaryScript7
dw GaryScript8
dw GaryScript9
dw GaryScript10
GaryScript0:
ret
GaryScript1:
ld a, $ff
ld [wJoyIgnore], a
ld hl, wSimulatedJoypadStatesEnd
ld de, GaryEntrance_RLEMovement
call DecodeRLEList
dec a
ld [wSimulatedJoypadStatesIndex], a
call StartSimulatingJoypadStates
ld a, $2
ld [wGaryCurScript], a
ret
GaryEntrance_RLEMovement:
db D_UP,1
db D_RIGHT,1
db D_UP,3
db $ff
GaryScript2:
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
call Delay3
xor a
ld [wJoyIgnore], a
ld a, 9
ld [wGymLeaderNo], a ;joenote - manually set final battle music
ld hl, wFlags_D733
set 5, [hl] ;joenote - set a flag to tell the battle engine that this is the final boss
ld hl, wOptions
res 7, [hl] ; Turn on battle animations to make the battle feel more epic.
ld a, $1
ld [hSpriteIndexOrTextID], a
call DisplayTextID
call Delay3
ld hl, wd72d
set 6, [hl]
set 7, [hl]
ld hl, GaryDefeatedText
ld de, GaryVictoryText
call SaveEndBattleTextPointers
ld a, OPP_SONY3
ld [wCurOpponent], a
; select which team to use during the encounter
ld a, [wRivalStarter]
cp STARTER2
jr nz, .NotStarter2
ld a, $1
jr .saveTrainerId
.NotStarter2
cp STARTER3
jr nz, .NotStarter3
ld a, $2
jr .saveTrainerId
.NotStarter3
ld a, $3
.saveTrainerId
ld [wTrainerNo], a
xor a
ld [hJoyHeld], a
ld a, $3
ld [wGaryCurScript], a
ret
GaryScript3:
ld a, [wIsInBattle]
cp $ff
jp z, ResetGaryScript
call UpdateSprites
SetEvent EVENT_BEAT_CHAMPION_RIVAL
ld a, $f0
ld [wJoyIgnore], a
ld a, $1
ld [hSpriteIndexOrTextID], a
call GaryScript_760c8
ld a, $1
ld [H_SPRITEINDEX], a
call SetSpriteMovementBytesToFF
ld a, $4
ld [wGaryCurScript], a
ret
GaryScript4:
callba Music_Cities1AlternateTempo
ld a, $2
ld [hSpriteIndexOrTextID], a
call GaryScript_760c8
ld a, $2
ld [H_SPRITEINDEX], a
call SetSpriteMovementBytesToFF
ld de, OakEntranceAfterVictoryMovement
ld a, $2
ld [H_SPRITEINDEX], a
call MoveSprite
ld a, HS_CHAMPIONS_ROOM_OAK
ld [wMissableObjectIndex], a
predef ShowObject2
ld a, $5
ld [wGaryCurScript], a
ret
OakEntranceAfterVictoryMovement:
db NPC_MOVEMENT_UP
db NPC_MOVEMENT_UP
db NPC_MOVEMENT_UP
db NPC_MOVEMENT_UP
db NPC_MOVEMENT_UP
db $FF
GaryScript5:
ld a, [wd730]
bit 0, a
ret nz
ld a, PLAYER_DIR_LEFT
ld [wPlayerMovingDirection], a
ld a, $1
ld [H_SPRITEINDEX], a
ld a, SPRITE_FACING_LEFT
ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay
ld a, $2
ld [H_SPRITEINDEX], a
xor a ; SPRITE_FACING_DOWN
ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay
ld a, $3
ld [hSpriteIndexOrTextID], a
call GaryScript_760c8
ld a, $6
ld [wGaryCurScript], a
ret
GaryScript6:
ld a, $2
ld [H_SPRITEINDEX], a
ld a, SPRITE_FACING_RIGHT
ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay
ld a, $4
ld [hSpriteIndexOrTextID], a
call GaryScript_760c8
ld a, $7
ld [wGaryCurScript], a
ret
GaryScript7:
ld a, $2
ld [H_SPRITEINDEX], a
xor a ; SPRITE_FACING_DOWN
ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay
ld a, $5
ld [hSpriteIndexOrTextID], a
call GaryScript_760c8
ld de, OakExitGaryRoomMovement
ld a, $2
ld [H_SPRITEINDEX], a
call MoveSprite
ld a, $8
ld [wGaryCurScript], a
ret
OakExitGaryRoomMovement:
db NPC_MOVEMENT_UP
db NPC_MOVEMENT_UP
db $FF
GaryScript8:
ld a, [wd730]
bit 0, a
ret nz
ld a, HS_CHAMPIONS_ROOM_OAK
ld [wMissableObjectIndex], a
predef HideObject
ld a, $9
ld [wGaryCurScript], a
ret
GaryScript9:
ld a, $ff
ld [wJoyIgnore], a
ld hl, wSimulatedJoypadStatesEnd
ld de, WalkToHallOfFame_RLEMovment
call DecodeRLEList
dec a
ld [wSimulatedJoypadStatesIndex], a
call StartSimulatingJoypadStates
ld a, $a
ld [wGaryCurScript], a
ret
WalkToHallOfFame_RLEMovment:
db D_UP,4
db D_LEFT,1
db $ff
GaryScript10:
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
xor a
ld [wJoyIgnore], a
ld a, $0
ld [wGaryCurScript], a
ret
GaryScript_760c8:
ld a, $f0
ld [wJoyIgnore], a
call DisplayTextID
ld a, $ff
ld [wJoyIgnore], a
ret
GaryTextPointers:
dw GaryText1
dw GaryText2
dw GaryText3
dw GaryText4
dw GaryText5
GaryText1:
TX_ASM
CheckEvent EVENT_BEAT_CHAMPION_RIVAL
ld hl, GaryChampionIntroText
jr z, .printText
ld hl, GaryText_76103
.printText
call PrintText
jp TextScriptEnd
GaryChampionIntroText:
TX_FAR _GaryChampionIntroText
db "@"
GaryDefeatedText:
TX_FAR _GaryDefeatedText
db "@"
GaryVictoryText:
TX_FAR _GaryVictoryText
db "@"
GaryText_76103:
TX_FAR _GaryText_76103
db "@"
GaryText2:
TX_FAR _GaryText2
db "@"
GaryText3:
TX_ASM
ld a, [wPlayerStarter]
ld [wd11e], a
call GetMonName
ld hl, GaryText_76120
call PrintText
jp TextScriptEnd
GaryText_76120:
TX_FAR _GaryText_76120
db "@"
GaryText4:
TX_FAR _GaryText_76125
db "@"
GaryText5:
TX_FAR _GaryText_7612a
db "@"