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
|
HallOfFamePC:
callfar AnimateHallOfFame
call ClearScreen
ld c, 100
call DelayFrames
call DisableLCD
ld a, $a7
ldh [rWX], a
xor a
ldh [rSCX], a
ldh [rSCY], a
ldh [hSCX], a
ldh [hSCY], a
ldh [hWY], a
ldh [rWY], a
call CreditsLoadFont
hlcoord 0, 0
call FillFourRowsWithBlack
hlcoord 0, 14
call FillFourRowsWithBlack
ld a, %11000000
ldh [rBGP], a
call UpdateCGBPal_BGP
call EnableLCD
call StopAllMusic
ld hl, vBGMap1
call CreditsCopyTileMapToVRAM
ld hl, vBGMap0
call CreditsCopyTileMapToVRAM
ld c, BANK(Music_Credits)
ld a, MUSIC_CREDITS
call PlayMusic
ld c, 128
call DelayFrames
xor a
ld [wHoFMonSpecies], a
ld [wNumCreditsMonsDisplayed], a
jp Credits
FadeInCredits:
ld a, 1
ldh [hAutoBGTransferEnabled], a
ld hl, HoFGBPalettes
ld b, 4
.loop
ld a, [hli]
ldh [rBGP], a
call UpdateCGBPal_BGP
ld c, 5
call DelayFrames
dec b
jr nz, .loop
ret
HoFGBPalettes:
dc 3, 0, 0, 0
dc 3, 1, 0, 0
dc 3, 2, 0, 0
dc 3, 3, 0, 0
DisplayCreditsMon:
ld hl, vBGMap1
call CreditsCopyTileMapToVRAM
xor a
ldh [hAutoBGTransferEnabled], a
ld hl, rLCDC
set B_LCDC_BG_MAP, [hl]
call SaveScreenTilesToBuffer2
call FillMiddleOfScreenWithWhite
call GetNextCreditsMon
ld hl, vBGMap0 + 12
call CreditsCopyTileMapToVRAM
xor a
ldh [hAutoBGTransferEnabled], a
call LoadScreenTilesFromBuffer2DisableBGTransfer
ld hl, vBGMap0
call CreditsCopyTileMapToVRAM
ld a, %11111100 ; make the mon a black silhouette
ldh [rBGP], a
call UpdateCGBPal_BGP
ld hl, rLCDC
res B_LCDC_BG_MAP, [hl]
ld a, 1
ldh [hAutoBGTransferEnabled], a
ld b, 0
ld c, 10
call ScrollCreditsMonLeft
call FillLeftHalfOfScreenWithWhite
ld c, 10
call ScrollCreditsMonLeft
call FillRightHalfOfScreenWithWhite
ld c, 8
call ScrollCreditsMonLeft
ld a, %11000000
ldh [rBGP], a
call UpdateCGBPal_BGP
xor a
ldh [hSCX], a
ret
ScrollCreditsMonLeft:
ld a, b
ldh [hSCX], a
add 8
ld b, a
call DelayFrame
dec c
jr nz, ScrollCreditsMonLeft
ret
GetNextCreditsMon:
ld hl, wNumCreditsMonsDisplayed
ld c, [hl]
inc [hl]
ld b, 0
ld hl, CreditsMons
add hl, bc
ld a, [hl]
ld [wCurPartySpecies], a
ld [wCurSpecies], a
hlcoord 8, 6
call GetMonHeader
call LoadFrontSpriteByMonIndex
ret
INCLUDE "data/credits/credits_mons.asm"
CreditsCopyTileMapToVRAM:
ld a, l
ldh [hAutoBGTransferDest], a
ld a, h
ldh [hAutoBGTransferDest + 1], a
ld a, 1
ldh [hAutoBGTransferEnabled], a
jp Delay3
CreditsLoadFont:
call LoadFontTilePatterns
ld hl, vFont
ld bc, ($80 tiles) / 2
call ShiftFontColorIndex
call LoadTextBoxTilePatterns
ld hl, vChars2 tile $60
ld bc, ($20 tiles) / 2
call ShiftFontColorIndex
ld hl, vChars2 tile $7e
ld bc, TILE_SIZE
ld a, $ff ; solid black
call FillMemory
ret
ShiftFontColorIndex:
; Zero every second byte at hl, writing a total of bc bytes.
; When used on VRAM font characters that contain only black and white shades,
; it shifts the color index: black -> light gray, allowing palette-controlled
; text fade-in during the Credits roll, while the black bars remain solid.
ld [hl], 0
inc hl
inc hl
dec bc
ld a, b
or c
jr nz, ShiftFontColorIndex
ret
FillFourRowsWithBlack:
ld bc, SCREEN_WIDTH * 4
ld a, $7e
jp FillMemory
FillMiddleOfScreenWithWhite:
hlcoord 0, 4
ld bc, SCREEN_WIDTH * 10
ld a, ' '
jp FillMemory
FillLeftHalfOfScreenWithWhite:
hlcoord 0, 4
push bc
call FillHalfOfScreenWithWhite
pop bc
ret
FillRightHalfOfScreenWithWhite:
hlcoord 10, 4
push bc
call FillHalfOfScreenWithWhite
pop bc
ret
FillHalfOfScreenWithWhite:
ld b, 10
ld c, 10
ld a, ' '
.loop
push bc
push hl
.innerLoop
ld [hli], a
dec c
jr nz, .innerLoop
pop hl
ld bc, SCREEN_WIDTH
add hl, bc
pop bc
dec b
jr nz, .loop
ret
Credits: ; Roll credits
ld de, CreditsOrder
push de
.nextCreditsScreen
pop de
hlcoord 9, 6
push hl
call FillMiddleOfScreenWithWhite
pop hl
.nextCreditsCommand
ld a, [de]
inc de
push de
cp CRED_TEXT_FADE_MON
jr z, .fadeInTextAndShowMon
cp CRED_TEXT_MON
jr z, .showTextAndShowMon
cp CRED_TEXT_FADE
jr z, .fadeInText
cp CRED_TEXT
jr z, .showText
cp CRED_COPYRIGHT
jr z, .showCopyrightText
cp CRED_THE_END
jr z, .showTheEnd
call PlaceCreditsText
pop de
jr .nextCreditsCommand
.showCopyrightText
farcall LoadCopyrightTiles
pop de
jr .nextCreditsCommand
.fadeInTextAndShowMon
call FadeInCredits
ld c, 102
jr .next1
.showTextAndShowMon
ld c, 122
.next1
call DelayFrames
call DisplayCreditsMon
jr .nextCreditsScreen
.fadeInText
call FadeInCredits
ld c, 132
jr .next2
.showText
ld c, 152
.next2
call DelayFrames
jr .nextCreditsScreen
.showTheEnd
call ShowTheEndGFX
pop de
ret
ShowTheEndGFX:
ld c, 24
call DelayFrames
call FillMiddleOfScreenWithWhite
ld de, TheEndGfx
ld hl, vChars2 tile $60
lb bc, BANK(TheEndGfx), (TheEndGfxEnd - TheEndGfx) / TILE_SIZE
call CopyVideoData
hlcoord 4, 8
ld de, TheEndTextString
call PlaceString
hlcoord 4, 9
inc de
call PlaceString
jp FadeInCredits
TheEndTextString:
; "T H E E N D"
db $60, " ", $62, " ", $64, " ", $64, " ", $66, " ", $68, "@"
db $61, " ", $63, " ", $65, " ", $65, " ", $67, " ", $69, "@"
PlaceCreditsText:
push hl
push hl
ld hl, CreditsTextPointers
ld c, a
ld b, 0
add hl, bc
add hl, bc
ld e, [hl]
inc hl
ld d, [hl]
pop hl
ld a, [de]
inc de
ld c, a
ld b, -1
add hl, bc
call PlaceString
pop hl
ld bc, SCREEN_WIDTH * 2
add hl, bc
ret
INCLUDE "data/credits/credits_order.asm"
INCLUDE "data/credits/credits_text.asm"
TheEndGfx:
INCBIN "gfx/credits/the_end.2bpp"
TheEndGfxEnd:
|