Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/movie/evolution.asm
1271 views
1
EvolveMon:
2
push hl
3
push de
4
push bc
5
ld a, [wCurPartySpecies]
6
push af
7
ld a, [wCurSpecies]
8
push af
9
xor a
10
ld [wLowHealthAlarm], a
11
ld [wChannelSoundIDs + CHAN5], a
12
dec a ; SFX_STOP_ALL_MUSIC
13
ld [wNewSoundID], a
14
call PlaySound
15
ld a, $1
16
ldh [hAutoBGTransferEnabled], a
17
ld a, SFX_TINK
18
call PlaySound
19
call Delay3
20
xor a
21
ldh [hAutoBGTransferEnabled], a
22
ldh [hTileAnimations], a
23
ld a, [wEvoOldSpecies]
24
ld [wWholeScreenPaletteMonSpecies], a
25
ld c, 0
26
call EvolutionSetWholeScreenPalette
27
ld a, [wEvoNewSpecies]
28
ld [wCurPartySpecies], a
29
ld [wCurSpecies], a
30
call Evolution_LoadPic
31
ld de, vFrontPic
32
ld hl, vBackPic
33
ld bc, 7 * 7
34
call CopyVideoData
35
ld a, [wEvoOldSpecies]
36
ld [wCurPartySpecies], a
37
ld [wCurSpecies], a
38
call Evolution_LoadPic
39
ld a, $1
40
ldh [hAutoBGTransferEnabled], a
41
ld a, [wEvoOldSpecies]
42
call PlayCry
43
call WaitForSoundToFinish
44
ld c, BANK(Music_SafariZone)
45
ld a, MUSIC_SAFARI_ZONE
46
call PlayMusic
47
ld c, 80
48
call DelayFrames
49
ld c, 1 ; set PAL_BLACK instead of mon palette
50
call EvolutionSetWholeScreenPalette
51
lb bc, $1, $10
52
.animLoop
53
push bc
54
call Evolution_CheckForCancel
55
jr c, .evolutionCancelled
56
call Evolution_BackAndForthAnim
57
pop bc
58
inc b
59
dec c
60
dec c
61
jr nz, .animLoop
62
xor a
63
ld [wEvoCancelled], a
64
ld a, $31
65
ld [wEvoMonTileOffset], a
66
call Evolution_ChangeMonPic ; show the new species pic
67
ld a, [wEvoNewSpecies]
68
.done
69
ld [wWholeScreenPaletteMonSpecies], a
70
ld a, SFX_STOP_ALL_MUSIC
71
ld [wNewSoundID], a
72
call PlaySound
73
ld a, [wWholeScreenPaletteMonSpecies]
74
call PlayCry
75
ld c, 0
76
call EvolutionSetWholeScreenPalette
77
pop af
78
ld [wCurSpecies], a
79
pop af
80
ld [wCurPartySpecies], a
81
pop bc
82
pop de
83
pop hl
84
ld a, [wEvoCancelled]
85
and a
86
ret z
87
scf
88
ret
89
.evolutionCancelled
90
pop bc
91
ld a, 1
92
ld [wEvoCancelled], a
93
ld a, [wEvoOldSpecies]
94
jr .done
95
96
EvolutionSetWholeScreenPalette:
97
ld b, SET_PAL_POKEMON_WHOLE_SCREEN
98
jp RunPaletteCommand
99
100
Evolution_LoadPic:
101
call GetMonHeader
102
hlcoord 7, 2
103
jp LoadFlippedFrontSpriteByMonIndex
104
105
Evolution_BackAndForthAnim:
106
; show the mon change back and forth between the new and old species b times
107
ld a, $31
108
ld [wEvoMonTileOffset], a
109
call Evolution_ChangeMonPic
110
ld a, -$31
111
ld [wEvoMonTileOffset], a
112
call Evolution_ChangeMonPic
113
dec b
114
jr nz, Evolution_BackAndForthAnim
115
ret
116
117
Evolution_ChangeMonPic:
118
push bc
119
xor a
120
ldh [hAutoBGTransferEnabled], a
121
hlcoord 7, 2
122
lb bc, 7, 7
123
ld de, SCREEN_WIDTH - 7
124
.loop
125
push bc
126
.innerLoop
127
ld a, [wEvoMonTileOffset]
128
add [hl]
129
ld [hli], a
130
dec c
131
jr nz, .innerLoop
132
pop bc
133
add hl, de
134
dec b
135
jr nz, .loop
136
ld a, 1
137
ldh [hAutoBGTransferEnabled], a
138
call Delay3
139
pop bc
140
ret
141
142
Evolution_CheckForCancel:
143
call DelayFrame
144
push bc
145
call JoypadLowSensitivity
146
ldh a, [hJoy5]
147
pop bc
148
and PAD_B
149
jr nz, .pressedB
150
.notAllowedToCancel
151
dec c
152
jr nz, Evolution_CheckForCancel
153
and a
154
ret
155
.pressedB
156
ld a, [wForceEvolution]
157
and a
158
jr nz, .notAllowedToCancel
159
scf
160
ret
161
162