Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/movie/oak_speech/oak_speech.asm
1271 views
1
PrepareOakSpeech:
2
ld a, [wLetterPrintingDelayFlags]
3
push af
4
ld a, [wOptions]
5
push af
6
; Retrieve BIT_DEBUG_MODE set in DebugMenu for StartNewGameDebug.
7
; BUG: StartNewGame carries over BIT_ALWAYS_ON_BIKE from previous save files,
8
; which causes CheckForceBikeOrSurf to not return.
9
; To fix this in debug builds, reset BIT_ALWAYS_ON_BIKE here or in StartNewGame.
10
; In non-debug builds, the instructions can be removed.
11
ld a, [wStatusFlags6]
12
push af
13
ld hl, wPlayerName
14
ld bc, wBoxDataEnd - wPlayerName
15
xor a
16
call FillMemory
17
ld hl, wSpriteDataStart
18
ld bc, wSpriteDataEnd - wSpriteDataStart
19
xor a
20
call FillMemory
21
pop af
22
ld [wStatusFlags6], a
23
pop af
24
ld [wOptions], a
25
pop af
26
ld [wLetterPrintingDelayFlags], a
27
ld a, [wOptionsInitialized]
28
and a
29
call z, InitOptions
30
; These debug names are used for StartNewGameDebug.
31
; TestBattle uses the debug names from DebugMenu.
32
; A variant of this process is performed in PrepareTitleScreen.
33
ld hl, DebugNewGamePlayerName
34
ld de, wPlayerName
35
ld bc, NAME_LENGTH
36
call CopyData
37
ld hl, DebugNewGameRivalName
38
ld de, wRivalName
39
ld bc, NAME_LENGTH
40
jp CopyData
41
42
OakSpeech:
43
ld a, SFX_STOP_ALL_MUSIC
44
call PlaySound
45
ld a, BANK(Music_Routes2)
46
ld c, a
47
ld a, MUSIC_ROUTES2
48
call PlayMusic
49
call ClearScreen
50
call LoadTextBoxTilePatterns
51
call PrepareOakSpeech
52
predef InitPlayerData2
53
ld hl, wNumBoxItems
54
ld a, POTION
55
ld [wCurItem], a
56
ld a, 1
57
ld [wItemQuantity], a
58
call AddItemToInventory
59
ld a, [wDefaultMap]
60
ld [wDestinationMap], a
61
call PrepareForSpecialWarp
62
xor a
63
ldh [hTileAnimations], a
64
ld a, [wStatusFlags6]
65
bit BIT_DEBUG_MODE, a
66
jp nz, .skipSpeech
67
ld de, ProfOakPic
68
lb bc, BANK(ProfOakPic), $00
69
call IntroDisplayPicCenteredOrUpperRight
70
call FadeInIntroPic
71
ld hl, OakSpeechText1
72
call PrintText
73
call GBFadeOutToWhite
74
call ClearScreen
75
ld a, NIDORINO
76
ld [wCurSpecies], a
77
ld [wCurPartySpecies], a
78
call GetMonHeader
79
hlcoord 6, 4
80
call LoadFlippedFrontSpriteByMonIndex
81
call MovePicLeft
82
ld hl, OakSpeechText2
83
call PrintText
84
call GBFadeOutToWhite
85
call ClearScreen
86
ld de, RedPicFront
87
lb bc, BANK(RedPicFront), $00
88
call IntroDisplayPicCenteredOrUpperRight
89
call MovePicLeft
90
ld hl, IntroducePlayerText
91
call PrintText
92
call ChoosePlayerName
93
call GBFadeOutToWhite
94
call ClearScreen
95
ld de, Rival1Pic
96
lb bc, BANK(Rival1Pic), $00
97
call IntroDisplayPicCenteredOrUpperRight
98
call FadeInIntroPic
99
ld hl, IntroduceRivalText
100
call PrintText
101
call ChooseRivalName
102
.skipSpeech
103
call GBFadeOutToWhite
104
call ClearScreen
105
ld de, RedPicFront
106
lb bc, BANK(RedPicFront), $00
107
call IntroDisplayPicCenteredOrUpperRight
108
call GBFadeInFromWhite
109
ld a, [wStatusFlags3]
110
and a ; ???
111
jr nz, .next
112
ld hl, OakSpeechText3
113
call PrintText
114
.next
115
ldh a, [hLoadedROMBank]
116
push af
117
ld a, SFX_SHRINK
118
call PlaySound
119
pop af
120
ldh [hLoadedROMBank], a
121
ld [rROMB], a
122
ld c, 4
123
call DelayFrames
124
ld de, RedSprite
125
ld hl, vSprites
126
lb bc, BANK(RedSprite), $0C
127
call CopyVideoData
128
ld de, ShrinkPic1
129
lb bc, BANK(ShrinkPic1), $00
130
call IntroDisplayPicCenteredOrUpperRight
131
ld c, 4
132
call DelayFrames
133
ld de, ShrinkPic2
134
lb bc, BANK(ShrinkPic2), $00
135
call IntroDisplayPicCenteredOrUpperRight
136
call ResetPlayerSpriteData
137
ldh a, [hLoadedROMBank]
138
push af
139
ld a, BANK(Music_PalletTown)
140
ld [wAudioROMBank], a
141
ld [wAudioSavedROMBank], a
142
ld a, 10
143
ld [wAudioFadeOutControl], a
144
ld a, SFX_STOP_ALL_MUSIC
145
ld [wNewSoundID], a
146
call PlaySound
147
pop af
148
ldh [hLoadedROMBank], a
149
ld [rROMB], a
150
ld c, 20
151
call DelayFrames
152
hlcoord 6, 5
153
ld b, 7
154
ld c, 7
155
call ClearScreenArea
156
call LoadTextBoxTilePatterns
157
ld a, 1
158
ld [wUpdateSpritesEnabled], a
159
ld c, 50
160
call DelayFrames
161
call GBFadeOutToWhite
162
jp ClearScreen
163
OakSpeechText1:
164
text_far _OakSpeechText1
165
text_end
166
OakSpeechText2:
167
text_far _OakSpeechText2A
168
; BUG: The cry played does not match the sprite displayed.
169
sound_cry_nidorina
170
text_far _OakSpeechText2B
171
text_end
172
IntroducePlayerText:
173
text_far _IntroducePlayerText
174
text_end
175
IntroduceRivalText:
176
text_far _IntroduceRivalText
177
text_end
178
OakSpeechText3:
179
text_far _OakSpeechText3
180
text_end
181
182
FadeInIntroPic:
183
ld hl, IntroFadePalettes
184
ld b, 6
185
.next
186
ld a, [hli]
187
ldh [rBGP], a
188
ld c, 10
189
call DelayFrames
190
dec b
191
jr nz, .next
192
ret
193
194
IntroFadePalettes:
195
dc 1, 1, 1, 0
196
dc 2, 2, 2, 0
197
dc 3, 3, 3, 0
198
dc 3, 3, 2, 0
199
dc 3, 3, 1, 0
200
dc 3, 2, 1, 0
201
202
MovePicLeft:
203
ld a, 119
204
ldh [rWX], a
205
call DelayFrame
206
207
ld a, %11100100
208
ldh [rBGP], a
209
.next
210
call DelayFrame
211
ldh a, [rWX]
212
sub 8
213
cp $FF
214
ret z
215
ldh [rWX], a
216
jr .next
217
218
DisplayPicCenteredOrUpperRight:
219
call GetPredefRegisters
220
IntroDisplayPicCenteredOrUpperRight:
221
; b = bank
222
; de = address of compressed pic
223
; c: 0 = centred, non-zero = upper-right
224
push bc
225
ld a, b
226
call UncompressSpriteFromDE
227
ld hl, sSpriteBuffer1
228
ld de, sSpriteBuffer0
229
ld bc, $310
230
call CopyData
231
ld de, vFrontPic
232
call InterlaceMergeSpriteBuffers
233
pop bc
234
ld a, c
235
and a
236
hlcoord 15, 1
237
jr nz, .next
238
hlcoord 6, 4
239
.next
240
xor a
241
ldh [hStartTileID], a
242
predef_jump CopyUncompressedPicToTilemap
243
244