forked from jojobear13/shinpokered
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc_shiny.asm
executable file
·233 lines (222 loc) · 4.26 KB
/
func_shiny.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
;joenote - Custom functions to handle shiny pokemon
ShinyAttractFunction:
;only if the party leader is lvl 100 or more
ld a, [wPartyMon1Level]
cp 100 ;do wPartyMon1Level - 100. set carry if result < 0
ret c ;return if wPartyMon1Level < 100
;and only if it's a chansey
ld a, [wPartyMon1Species]
cp CHANSEY
ret nz
;make a 1 in 255 chance to force shiny DVs on a wild pokemon
call Random
ret nz
ld a, [wFontLoaded]
set 7, a
ld [wFontLoaded], a
ret
;joenote - check if enemy mon has gen2 shiny DVs
;zero flag is set if not shiny
;as a mercy, makes the next encounter shiny via a flag bit if this is a trainer shiny
CheckEnemyShinyDVs:
push hl
ld hl, wEnemyMonDVs
call ShinyDVsChecker
jr z, .end
ld a, $01
and a
.end
pop hl
push af
call nz, .trainer_mercy
pop af
ret
.trainer_mercy
ld a, [wLinkState]
cp LINK_STATE_BATTLING
ret z ;return if this is a link battle
ld a, [wBattleType]
dec a
jr z, .next_enc_shiny ;grant mercy if this is the old man battle
ld a, [wFlags_D733]
bit 6, a
jr nz, .next_enc_shiny ;grant mercy if this is a tower ghost battle
CheckEvent EVENT_10E
jr nz, .next_enc_shiny ;grant mercy if this is the ghost marowak battle
ld a, [wIsInBattle]
cp 2
ret nz ;return if not a trainer battle
.next_enc_shiny
;at this point, player is facing an AI trainer's shiny pokemon or some kind of uncatchable wild pokemon
;so make the next wild encounter shiny
ld a, [wFontLoaded]
set 7, a
ld [wFontLoaded], a
ret
CheckPlayerShinyDVs:
push hl
ld hl, wBattleMonDVs
call ShinyDVsChecker
jr z, .end
ld a, $01
and a
.end
pop hl
ret
CheckLoadedShinyDVs:
push hl
ld hl, wLoadedMonDVs
call ShinyDVsChecker
jr z, .end
ld a, $01
and a
.end
pop hl
ret
ShinyDVsChecker2: ;uses DE instead of HL to better call across banks
ld h, d
ld l, e
ShinyDVsChecker: ;return z flag set if not shiny or cleared z flag if shiny
ld a, [hl] ;load MSB
bit 5, a ;bit 5 of the MSB need to be a 1 for shininess
jr z, .end_zero
and $0F ;now mask out the lesser nybble of the MSB
cp $0A ;need to be a DV of 10 for shininess
jr nz, .end_zero
inc hl
ld a, [hl] ;load LSB
cp a, $AA ;need to be DVs of 10 for shininess
jr nz, .end_zero
ld a, $01
and a
ret
.end_zero
xor a
ret
ShinyPlayerAnimation:
ld a, [wUnusedD366]
bit 0, a
jr nz, .noPlayerShiny
call CheckPlayerShinyDVs
jr z, .noPlayerShiny
push de
ld d, $00
ld e, $B6 ;select an unused power-up animation
callba PlaySelectedAnimation
pop de
call SkipPlayerShinybit
push bc
ld b, SET_PAL_BATTLE
call RunPaletteCommand
pop bc
.noPlayerShiny
ret
ShinyEnemyAnimation:
ld a, [wUnusedD366]
bit 7, a
jr nz, .noEnemyShiny
call CheckEnemyShinyDVs
jr z, .noEnemyShiny
push de
ld d, $01
ld e, $B6 ;select an unused power-up animation
callba PlaySelectedAnimation
pop de
call SkipEnemyShinybit
push bc
ld b, SET_PAL_BATTLE
call RunPaletteCommand
pop bc
.noEnemyShiny
ret
DoPlayerShinybit:
ld a, [wUnusedD366]
res 0, a
ld [wUnusedD366], a
ret
SkipPlayerShinybit:
ld a, [wUnusedD366]
set 0, a
ld [wUnusedD366], a
ret
DoEnemyShinybit:
ld a, [wUnusedD366]
res 7, a
ld [wUnusedD366], a
ret
SkipEnemyShinybit:
ld a, [wUnusedD366]
set 7, a
ld [wUnusedD366], a
ret
ShinyStatusScreen:
ld a, [wPalPacket + 3]
call ShinyDVConvert
ld [wPalPacket + 3], a
call PrintShinySymbolStatus
ret
ShinyPlayerMon:
ld a, [wPalPacket + 5]
call ShinyDVConvert
ld [wPalPacket + 5], a
ret
ShinyEnemyMon:
ld a, [wPalPacket + 7]
call ShinyDVConvert
ld [wPalPacket + 7], a
ret
ShinyDVConvert: ;'a' holds the default value
cp PAL_MEWMON
jr nz, .next1
ld a, PAL_YELLOWMON
jr .endConvert
.next1
cp PAL_BLUEMON
jr nz, .next2
ld a, PAL_PURPLEMON
jr .endConvert
.next2
cp PAL_REDMON
jr nz, .next3
ld a, PAL_PINKMON
jr .endConvert
.next3
cp PAL_CYANMON
jr nz, .next4
ld a, PAL_GREENMON
jr .endConvert
.next4
cp PAL_PURPLEMON
jr nz, .next5
ld a, PAL_GREYMON
jr .endConvert
.next5
cp PAL_BROWNMON
jr nz, .next6
ld a, PAL_REDMON
jr .endConvert
.next6
cp PAL_GREENMON
jr nz, .next7
ld a, PAL_BLUEMON
jr .endConvert
.next7
cp PAL_PINKMON
jr nz, .next8
ld a, PAL_CYANMON
jr .endConvert
.next8
cp PAL_YELLOWMON
jr nz, .next9
ld a, PAL_BROWNMON
jr .endConvert
.next9
cp PAL_GREYMON
jr nz, .endConvert
ld a, PAL_MEWMON
.endConvert
ret
PrintShinySymbolStatus:
coord hl, 8, 1
ld [hl], "<SHINY>"
ret