summaryrefslogtreecommitdiff
path: root/scripts/fightingdojo.asm
blob: a491349c0bcfdb61383a9370a93b27ae32d07ccb (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
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
FightingDojoScript: ; 5cd5d (17:4d5d)
	call EnableAutoTextBoxDrawing
	ld hl, FightingDojoTrainerHeaders
	ld de, FightingDojoScriptPointers
	ld a, [W_FIGHTINGDOJOCURSCRIPT]
	call ExecuteCurMapScriptInTable
	ld [W_FIGHTINGDOJOCURSCRIPT], a
	ret

FightingDojoScript_5cd70: ; 5cd70 (17:4d70)
	xor a
	ld [$cd6b], a
	ld [$d642], a
	ld [$da39], a
	ret

FightingDojoScriptPointers: ; 5cd7b (17:4d7b)
	dw FightingDojoScript1
	dw Func_324c
	dw EndTrainerBattle
	dw FightingDojoScript3

FightingDojoScript1: ; 5cd83 (17:4d83)
	ld a, [$d7b1]
	bit 0, a
	ret nz
	call CheckFightingMapTrainers
	ld a, [wTrainerHeaderFlagBit]
	and a
	ret nz
	ld a, [$d7b1]
	bit 1, a
	ret nz
	xor a
	ld [hJoyHeld], a
	ld [$cf0d], a
	ld a, [W_YCOORD]
	cp $3
	ret nz
	ld a, [W_XCOORD]
	cp $4
	ret nz
	ld a, $1
	ld [$cf0d], a
	ld a, $1
	ld [$d528], a
	ld a, $1
	ld [$ff8c], a
	ld a, $8
	ld [$ff8d], a
	call Func_34a6
	ld a, $1
	ld [$ff8c], a
	call DisplayTextID
	ret

FightingDojoScript3: ; 5cdc6 (17:4dc6)
	ld a, [$d057]
	cp $ff
	jp z, FightingDojoScript_5cd70
	ld a, [$cf0d]
	and a
	jr z, .asm_5cde4
	ld a, $1
	ld [$d528], a
	ld a, $1
	ld [$ff8c], a
	ld a, $8
	ld [$ff8d], a
	call Func_34a6

.asm_5cde4
	ld a, $f0
	ld [$cd6b], a
	ld a, [$d7b1]
	or $3e
	ld [$d7b1], a
	ld a, $8
	ld [$ff8c], a
	call DisplayTextID
	xor a
	ld [$cd6b], a
	ld [$d642], a
	ld [$da39], a
	ret

FightingDojoTextPointers: ; 5ce03 (17:4e03)
	dw FightingDojoText1
	dw FightingDojoText2
	dw FightingDojoText3
	dw FightingDojoText4
	dw FightingDojoText5
	dw FightingDojoText6
	dw FightingDojoText7
	dw FightingDojoText8

FightingDojoTrainerHeaders: ; 5ce13 (17:4e13)
FightingDojoTrainerHeader0: ; 5ce13 (17:4e13)
	db $2 ; flag's bit
	db ($4 << 4) ; trainer's view range
	dw $d7b1 ; flag's byte
	dw FightingDojoBattleText1 ; 0x4eac TextBeforeBattle
	dw FightingDojoAfterBattleText1 ; 0x4eb6 TextAfterBattle
	dw FightingDojoEndBattleText1 ; 0x4eb1 TextEndBattle
	dw FightingDojoEndBattleText1 ; 0x4eb1 TextEndBattle

FightingDojoTrainerHeader1: ; 5ce1f (17:4e1f)
	db $3 ; flag's bit
	db ($4 << 4) ; trainer's view range
	dw $d7b1 ; flag's byte
	dw FightingDojoBattleText2 ; 0x4ec5 TextBeforeBattle
	dw FightingDojoAfterBattleText2 ; 0x4ecf TextAfterBattle
	dw FightingDojoEndBattleText2 ; 0x4eca TextEndBattle
	dw FightingDojoEndBattleText2 ; 0x4eca TextEndBattle

FightingDojoTrainerHeader2: ; 5ce2b (17:4e2b)
	db $4 ; flag's bit
	db ($3 << 4) ; trainer's view range
	dw $d7b1 ; flag's byte
	dw FightingDojoBattleText3 ; 0x4ede TextBeforeBattle
	dw FightingDojoAfterBattleText3 ; 0x4ee8 TextAfterBattle
	dw FightingDojoEndBattleText3 ; 0x4ee3 TextEndBattle
	dw FightingDojoEndBattleText3 ; 0x4ee3 TextEndBattle

FightingDojoTrainerHeader3: ; 5ce37 (17:4e37)
	db $5 ; flag's bit
	db ($3 << 4) ; trainer's view range
	dw $d7b1 ; flag's byte
	dw FightingDojoBattleText4 ; 0x4ef7 TextBeforeBattle
	dw FightingDojoAfterBattleText4 ; 0x4f01 TextAfterBattle
	dw FightingDojoEndBattleText4 ; 0x4efc TextEndBattle
	dw FightingDojoEndBattleText4 ; 0x4efc TextEndBattle

	db $ff

FightingDojoText1: ; 5ce44 (17:4e44)
	db $08 ; asm
	ld a, [$d7b1]
	bit 0, a
	jp nz, .continue1
	bit 1, a
	jp nz, .continue2
	ld hl, FightingDojoText_5ce8e
	call PrintText
	ld hl, $d72d
	set 6, [hl]
	set 7, [hl]
	ld hl, FightingDojoText_5ce93
	ld de, FightingDojoText_5ce93
	call PreBattleSaveRegisters
	ldh a, [$8c]
	ld [$cf13], a
	call EngageMapTrainer
	call InitBattleEnemyParameters
	ld a, $3
	ld [W_FIGHTINGDOJOCURSCRIPT], a
	ld [W_CURMAPSCRIPT], a
	jr .asm_9dba4 ; 0x5ce7b
.continue1 ; 0x5ce7d
	ld hl, FightingDojoText_5ce9d
	call PrintText
	jr .asm_9dba4 ; 0x5ce83
.continue2 ; 0x5ce85f
	ld hl, FightingDojoText8
	call PrintText
.asm_9dba4 ; 0x5ce8b
	jp TextScriptEnd

FightingDojoText_5ce8e: ; 5ce8e (17:4e8e)
	TX_FAR _FightingDojoText_5ce8e
	db "@"

FightingDojoText_5ce93: ; 5ce93 (17:4e93)
	TX_FAR _FightingDojoText_5ce93
	db "@"

FightingDojoText8: ; 5ce98 (17:4e98)
	TX_FAR _FightingDojoText_5ce98
	db "@"

FightingDojoText_5ce9d: ; 5ce9d (17:4e9d)
	TX_FAR _FightingDojoText_5ce9d
	db "@"

FightingDojoText2: ; 5cea2 (17:4ea2)
	db $08 ; asm
	ld hl, FightingDojoTrainerHeader0
	call TalkToTrainer
	jp TextScriptEnd

FightingDojoBattleText1: ; 5ceac (17:4eac)
	TX_FAR _FightingDojoBattleText1
	db "@"

FightingDojoEndBattleText1: ; 5ceb1 (17:4eb1)
	TX_FAR _FightingDojoEndBattleText1
	db "@"

FightingDojoAfterBattleText1: ; 5ceb6 (17:4eb6)
	TX_FAR _FightingDojoAfterBattleText1
	db "@"

FightingDojoText3: ; 5cebb (17:4ebb)
	db $08 ; asm
	ld hl, FightingDojoTrainerHeader1
	call TalkToTrainer
	jp TextScriptEnd

FightingDojoBattleText2: ; 5cec5 (17:4ec5)
	TX_FAR _FightingDojoBattleText2
	db "@"

FightingDojoEndBattleText2: ; 5ceca (17:4eca)
	TX_FAR _FightingDojoEndBattleText2
	db "@"

FightingDojoAfterBattleText2: ; 5cecf (17:4ecf)
	TX_FAR _FightingDojoAfterBattleText2
	db "@"

FightingDojoText4: ; 5ced4 (17:4ed4)
	db $08 ; asm
	ld hl, FightingDojoTrainerHeader2
	call TalkToTrainer
	jp TextScriptEnd

FightingDojoBattleText3: ; 5cede (17:4ede)
	TX_FAR _FightingDojoBattleText3
	db "@"

FightingDojoEndBattleText3: ; 5cee3 (17:4ee3)
	TX_FAR _FightingDojoEndBattleText3
	db "@"

FightingDojoAfterBattleText3: ; 5cee8 (17:4ee8)
	TX_FAR _FightingDojoAfterBattleText3
	db "@"

FightingDojoText5: ; 5ceed (17:4eed)
	db $08 ; asm
	ld hl, FightingDojoTrainerHeader3
	call TalkToTrainer
	jp TextScriptEnd

FightingDojoBattleText4: ; 5cef7 (17:4ef7)
	TX_FAR _FightingDojoBattleText4
	db "@"

FightingDojoEndBattleText4: ; 5cefc (17:4efc)
	TX_FAR _FightingDojoEndBattleText4
	db "@"

FightingDojoAfterBattleText4: ; 5cf01 (17:4f01)
	TX_FAR _FightingDojoAfterBattleText4
	db "@"

FightingDojoText6: ; 5cf06 (17:4f06)
; Hitmonlee Poké Ball
	db $08 ; asm
	ld a, [$d7b1]
	and %11000000
	jr z, .GetMon
	ld hl, OtherHitmonText
	call PrintText
	jr .done
.GetMon
	ld a, HITMONLEE
	call DisplayPokedex
	ld hl, WantHitmonleeText
	call PrintText
	call YesNoChoice
	ld a, [$cc26]
	and a
	jr nz, .done
	ld a, [$cf91]
	ld b, a
	ld c, 30
	call GivePokemon
	jr nc, .done

	; once Poké Ball is taken, hide sprite
	ld a, $4a
	ld [$cc4d], a
	ld a, $11
	call Predef
	ld hl, $d7b1
	set 6, [hl]
	set 0, [hl]
.done
	jp TextScriptEnd

WantHitmonleeText: ; 5cf49 (17:4f49)
	TX_FAR _WantHitmonleeText
	db "@"

FightingDojoText7: ; 5cf4e (17:4f4e)
; Hitmonchan Poké Ball
	db $08 ; asm
	ld a, [$d7b1]
	and %11000000
	jr z, .GetMon
	ld hl, OtherHitmonText
	call PrintText
	jr .done
.GetMon
	ld a, HITMONCHAN
	call DisplayPokedex
	ld hl, WantHitmonchanText
	call PrintText
	call YesNoChoice
	ld a, [$cc26]
	and a
	jr nz, .done
	ld a, [$cf91]
	ld b, a
	ld c,30
	call GivePokemon
	jr nc, .done
	ld hl, $d7b1
	set 7, [hl]
	set 0, [hl]

	; once Poké Ball is taken, hide sprite
	ld a, $4b
	ld [$cc4d], a
	ld a, $11
	call Predef
.done
	jp TextScriptEnd

WantHitmonchanText: ; 5cf91 (17:4f91)
	TX_FAR _WantHitmonchanText
	db "@"

OtherHitmonText: ; 5cf96 (17:4f96)
	TX_FAR _OtherHitmonText
	db "@"