-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathtitle.asm
416 lines (374 loc) · 8.42 KB
/
title.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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
CopyDebugName:
ld bc, NAME_LENGTH
jp CopyData
PrepareTitleScreen::
; These debug names are already copied later in PrepareOakSpeech.
; Removing the unused copies below has no apparent impact.
; CopyDebugName can also be safely deleted afterwards.
ld hl, DebugNewGamePlayerName
ld de, wPlayerName
call CopyDebugName
ld hl, DebugNewGameRivalName
ld de, wRivalName
call CopyDebugName
xor a
ldh [hWY], a
ld [wLetterPrintingDelayFlags], a
ld hl, wStatusFlags6
ld [hli], a
ASSERT wStatusFlags6 + 1 == wStatusFlags7
ld [hli], a
ASSERT wStatusFlags7 + 1 == wElite4Flags
ld [hl], a
ld a, BANK(Music_TitleScreen)
ld [wAudioROMBank], a
ld [wAudioSavedROMBank], a
DisplayTitleScreen:
call GBPalWhiteOut
ld a, $1
ldh [hAutoBGTransferEnabled], a
xor a
ldh [hTileAnimations], a
ldh [hSCX], a
ld a, $40
ldh [hSCY], a
ld a, $90
ldh [hWY], a
call ClearScreen
call DisableLCD
call LoadFontTilePatterns
ld hl, NintendoCopyrightLogoGraphics
ld de, vTitleLogo2 tile 16
ld bc, 5 tiles
ld a, BANK(NintendoCopyrightLogoGraphics)
call FarCopyData2
ld hl, GameFreakLogoGraphics
ld de, vTitleLogo2 tile (16 + 5)
ld bc, 9 tiles
ld a, BANK(GameFreakLogoGraphics)
call FarCopyData2
ld hl, PokemonLogoGraphics
ld de, vTitleLogo
ld bc, $60 tiles
ld a, BANK(PokemonLogoGraphics)
call FarCopyData2 ; first chunk
ld hl, PokemonLogoGraphics tile $60
ld de, vTitleLogo2
ld bc, $10 tiles
ld a, BANK(PokemonLogoGraphics)
call FarCopyData2 ; second chunk
ld hl, Version_GFX
ld de, vChars2 tile $60 + (10 tiles - (Version_GFXEnd - Version_GFX) * 2) / 2
ld bc, Version_GFXEnd - Version_GFX
ld a, BANK(Version_GFX)
call FarCopyDataDouble
call ClearBothBGMaps
; place tiles for pokemon logo (except for the last row)
hlcoord 2, 1
ld a, $80
ld de, SCREEN_WIDTH
ld c, 6
.pokemonLogoTileLoop
ld b, $10
push hl
.pokemonLogoTileRowLoop ; place tiles for one row
ld [hli], a
inc a
dec b
jr nz, .pokemonLogoTileRowLoop
pop hl
add hl, de
dec c
jr nz, .pokemonLogoTileLoop
; place tiles for the last row of the pokemon logo
hlcoord 2, 7
ld a, $31
ld b, $10
.pokemonLogoLastTileRowLoop
ld [hli], a
inc a
dec b
jr nz, .pokemonLogoLastTileRowLoop
call DrawPlayerCharacter
; put a pokeball in the player's hand
ld hl, wShadowOAMSprite10
ld a, $74
ld [hl], a
; place tiles for title screen copyright
hlcoord 2, 17
ld de, .tileScreenCopyrightTiles
ld b, $10
.tileScreenCopyrightTilesLoop
ld a, [de]
ld [hli], a
inc de
dec b
jr nz, .tileScreenCopyrightTilesLoop
jr .next
.tileScreenCopyrightTiles
db $41,$42,$43,$42,$44,$42,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E ; ©'95.'96.'98 GAME FREAK inc.
.next
call SaveScreenTilesToBuffer2
call LoadScreenTilesFromBuffer2
call EnableLCD
IF DEF(_RED)
ld a, STARTER1 ; which Pokemon to show first on the title screen
ENDC
IF DEF(_BLUE)
ld a, STARTER2 ; which Pokemon to show first on the title screen
ENDC
ld [wTitleMonSpecies], a
call LoadTitleMonSprite
ld a, HIGH(vBGMap0 + $300)
call TitleScreenCopyTileMapToVRAM
call SaveScreenTilesToBuffer1
ld a, $40
ldh [hWY], a
call LoadScreenTilesFromBuffer2
ld a, HIGH(vBGMap0)
call TitleScreenCopyTileMapToVRAM
ld b, SET_PAL_TITLE_SCREEN
call RunPaletteCommand
call GBPalNormal
ld a, %11100100
ldh [rOBP0], a
; make pokemon logo bounce up and down
ld bc, hSCY ; background scroll Y
ld hl, .TitleScreenPokemonLogoYScrolls
.bouncePokemonLogoLoop
ld a, [hli]
and a
jr z, .finishedBouncingPokemonLogo
ld d, a
cp -3
jr nz, .skipPlayingSound
ld a, SFX_INTRO_CRASH
call PlaySound
.skipPlayingSound
ld a, [hli]
ld e, a
call .ScrollTitleScreenPokemonLogo
jr .bouncePokemonLogoLoop
.TitleScreenPokemonLogoYScrolls:
; Controls the bouncing effect of the Pokemon logo on the title screen
db -4,16 ; y scroll amount, number of times to scroll
db 3,4
db -3,4
db 2,2
db -2,2
db 1,2
db -1,2
db 0 ; terminate list with 0
.ScrollTitleScreenPokemonLogo:
; Scrolls the Pokemon logo on the title screen to create the bouncing effect
; Scrolls d pixels e times
call DelayFrame
ld a, [bc] ; background scroll Y
add d
ld [bc], a
dec e
jr nz, .ScrollTitleScreenPokemonLogo
ret
.finishedBouncingPokemonLogo
call LoadScreenTilesFromBuffer1
ld c, 36
call DelayFrames
ld a, SFX_INTRO_WHOOSH
call PlaySound
; scroll game version in from the right
call PrintGameVersionOnTitleScreen
ld a, SCREEN_HEIGHT_PX
ldh [hWY], a
ld d, 144
.scrollTitleScreenGameVersionLoop
ld h, d
ld l, 64
call ScrollTitleScreenGameVersion
ld h, 0
ld l, 80
call ScrollTitleScreenGameVersion
ld a, d
add 4
ld d, a
and a
jr nz, .scrollTitleScreenGameVersionLoop
ld a, HIGH(vBGMap1)
call TitleScreenCopyTileMapToVRAM
call LoadScreenTilesFromBuffer2
call PrintGameVersionOnTitleScreen
call Delay3
call WaitForSoundToFinish
ld a, MUSIC_TITLE_SCREEN
ld [wNewSoundID], a
call PlaySound
xor a
ld [wUnusedFlag], a
; Keep scrolling in new mons indefinitely until the user performs input.
.awaitUserInterruptionLoop
ld c, 200
call CheckForUserInterruption
jr c, .finishedWaiting
call TitleScreenScrollInMon
ld c, 1
call CheckForUserInterruption
jr c, .finishedWaiting
farcall TitleScreenAnimateBallIfStarterOut
call TitleScreenPickNewMon
jr .awaitUserInterruptionLoop
.finishedWaiting
ld a, [wTitleMonSpecies]
call PlayCry
call WaitForSoundToFinish
call GBPalWhiteOutWithDelay3
call ClearSprites
xor a
ldh [hWY], a
inc a
ldh [hAutoBGTransferEnabled], a
call ClearScreen
ld a, HIGH(vBGMap0)
call TitleScreenCopyTileMapToVRAM
ld a, HIGH(vBGMap1)
call TitleScreenCopyTileMapToVRAM
call Delay3
call LoadGBPal
ldh a, [hJoyHeld]
ld b, a
and D_UP | SELECT | B_BUTTON
cp D_UP | SELECT | B_BUTTON
jp z, .doClearSaveDialogue
IF DEF(_DEBUG)
ld a, b
bit BIT_SELECT, a
jp nz, DebugMenu
ENDC
jp MainMenu
.doClearSaveDialogue
farjp DoClearSaveDialogue
TitleScreenPickNewMon:
ld a, HIGH(vBGMap0)
call TitleScreenCopyTileMapToVRAM
.loop
; Keep looping until a mon different from the current one is picked.
call Random
and $f
ld c, a
ld b, 0
ld hl, TitleMons
add hl, bc
ld a, [hl]
ld hl, wTitleMonSpecies
; Can't be the same as before.
cp [hl]
jr z, .loop
ld [hl], a
call LoadTitleMonSprite
ld a, $90
ldh [hWY], a
ld d, 1 ; scroll out
farcall TitleScroll
ret
TitleScreenScrollInMon:
ld d, 0 ; scroll in
farcall TitleScroll
xor a
ldh [hWY], a
ret
ScrollTitleScreenGameVersion:
.wait
ldh a, [rLY]
cp l
jr nz, .wait
ld a, h
ldh [rSCX], a
.wait2
ldh a, [rLY]
cp h
jr z, .wait2
ret
DrawPlayerCharacter:
ld hl, PlayerCharacterTitleGraphics
ld de, vSprites
ld bc, PlayerCharacterTitleGraphicsEnd - PlayerCharacterTitleGraphics
ld a, BANK(PlayerCharacterTitleGraphics)
call FarCopyData2
call ClearSprites
xor a
ld [wPlayerCharacterOAMTile], a
ld hl, wShadowOAM
lb de, $60, $5a
ld b, 7
.loop
push de
ld c, 5
.innerLoop
ld a, d
ld [hli], a ; Y
ld a, e
ld [hli], a ; X
add 8
ld e, a
ld a, [wPlayerCharacterOAMTile]
ld [hli], a ; tile
inc a
ld [wPlayerCharacterOAMTile], a
inc hl
dec c
jr nz, .innerLoop
pop de
ld a, 8
add d
ld d, a
dec b
jr nz, .loop
ret
ClearBothBGMaps:
ld hl, vBGMap0
ld bc, $400 * 2
ld a, " "
jp FillMemory
LoadTitleMonSprite:
ld [wCurPartySpecies], a
ld [wCurSpecies], a
hlcoord 5, 10
call GetMonHeader
jp LoadFrontSpriteByMonIndex
TitleScreenCopyTileMapToVRAM:
ldh [hAutoBGTransferDest + 1], a
jp Delay3
LoadCopyrightAndTextBoxTiles:
xor a
ldh [hWY], a
call ClearScreen
call LoadTextBoxTilePatterns
LoadCopyrightTiles:
ld de, NintendoCopyrightLogoGraphics
ld hl, vChars2 tile $60
lb bc, BANK(NintendoCopyrightLogoGraphics), (GameFreakLogoGraphicsEnd - NintendoCopyrightLogoGraphics) / $10
call CopyVideoData
hlcoord 2, 7
ld de, CopyrightTextString
jp PlaceString
CopyrightTextString:
db $60,$61,$62,$61,$63,$61,$64,$7F,$65,$66,$67,$68,$69,$6A ; ©'95.'96.'98 Nintendo
next $60,$61,$62,$61,$63,$61,$64,$7F,$6B,$6C,$6D,$6E,$6F,$70,$71,$72 ; ©'95.'96.'98 Creatures inc.
next $60,$61,$62,$61,$63,$61,$64,$7F,$73,$74,$75,$76,$77,$78,$79,$7A,$7B ; ©'95.'96.'98 GAME FREAK inc.
db "@"
INCLUDE "data/pokemon/title_mons.asm"
; prints version text (red, blue)
PrintGameVersionOnTitleScreen:
hlcoord 7, 8
ld de, VersionOnTitleScreenText
jp PlaceString
; these point to special tiles specifically loaded for that purpose and are not usual text
VersionOnTitleScreenText:
IF DEF(_RED)
db $60,$61,$7F,$65,$66,$67,$68,$69,"@" ; "Red Version"
ENDC
IF DEF(_BLUE)
db $61,$62,$63,$64,$65,$66,$67,$68,"@" ; "Blue Version"
ENDC
DebugNewGamePlayerName:
db "NINTEN@"
DebugNewGameRivalName:
db "SONY@"