Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/movie/oak_speech/oak_speech.asm
2064 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
; bug: switching ROM Bank should not happen outside of Home Bank
121
; This code does nothing, as PlaySound does all necessary Bank switch
122
; It looks like a leftover from an early development stage
123
ldh [hLoadedROMBank], a
124
ld [rROMB], a
125
ld c, 4
126
call DelayFrames
127
ld de, RedSprite
128
ld hl, vSprites
129
lb bc, BANK(RedSprite), $0C
130
call CopyVideoData
131
ld de, ShrinkPic1
132
lb bc, BANK(ShrinkPic1), $00
133
call IntroDisplayPicCenteredOrUpperRight
134
ld c, 4
135
call DelayFrames
136
ld de, ShrinkPic2
137
lb bc, BANK(ShrinkPic2), $00
138
call IntroDisplayPicCenteredOrUpperRight
139
call ResetPlayerSpriteData
140
ldh a, [hLoadedROMBank]
141
push af
142
ld a, BANK(Music_PalletTown)
143
ld [wAudioROMBank], a
144
ld [wAudioSavedROMBank], a
145
ld a, 10
146
ld [wAudioFadeOutControl], a
147
ld a, SFX_STOP_ALL_MUSIC
148
ld [wNewSoundID], a
149
call PlaySound
150
pop af
151
; bug: switching ROM Bank should not happen outside of Home Bank
152
ldh [hLoadedROMBank], a
153
ld [rROMB], a
154
ld c, 20
155
call DelayFrames
156
hlcoord 6, 5
157
ld b, 7
158
ld c, 7
159
call ClearScreenArea
160
call LoadTextBoxTilePatterns
161
ld a, 1
162
ld [wUpdateSpritesEnabled], a
163
ld c, 50
164
call DelayFrames
165
call GBFadeOutToWhite
166
jp ClearScreen
167
168
OakSpeechText1:
169
text_far _OakSpeechText1
170
text_end
171
172
OakSpeechText2:
173
text_far _OakSpeechText2A
174
; BUG: The cry played does not match the sprite displayed.
175
sound_cry_nidorina
176
text_far _OakSpeechText2B
177
text_end
178
179
IntroducePlayerText:
180
text_far _IntroducePlayerText
181
text_end
182
183
IntroduceRivalText:
184
text_far _IntroduceRivalText
185
text_end
186
187
OakSpeechText3:
188
text_far _OakSpeechText3
189
text_end
190
191
FadeInIntroPic:
192
ld hl, IntroFadePalettes
193
ld b, 6
194
.next
195
ld a, [hli]
196
ldh [rBGP], a
197
ld c, 10
198
call DelayFrames
199
dec b
200
jr nz, .next
201
ret
202
203
IntroFadePalettes:
204
dc 1, 1, 1, 0
205
dc 2, 2, 2, 0
206
dc 3, 3, 3, 0
207
dc 3, 3, 2, 0
208
dc 3, 3, 1, 0
209
dc 3, 2, 1, 0
210
211
MovePicLeft:
212
ld a, 119
213
ldh [rWX], a
214
call DelayFrame
215
216
ld a, %11100100
217
ldh [rBGP], a
218
.next
219
call DelayFrame
220
ldh a, [rWX]
221
sub 8
222
cp $FF
223
ret z
224
ldh [rWX], a
225
jr .next
226
227
DisplayPicCenteredOrUpperRight:
228
call GetPredefRegisters
229
IntroDisplayPicCenteredOrUpperRight:
230
; b = bank
231
; de = address of compressed pic
232
; c: 0 = centred, non-zero = upper-right
233
push bc
234
ld a, b
235
call UncompressSpriteFromDE
236
ld hl, sSpriteBuffer1
237
ld de, sSpriteBuffer0
238
ld bc, 2 * SPRITEBUFFERSIZE
239
call CopyData
240
ld de, vFrontPic
241
call InterlaceMergeSpriteBuffers
242
pop bc
243
ld a, c
244
and a
245
hlcoord 15, 1
246
jr nz, .next
247
hlcoord 6, 4
248
.next
249
xor a
250
ldh [hStartTileID], a
251
predef_jump CopyUncompressedPicToTilemap
252
253