forked from Vortyne/pureRGB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCinnabarLabFossilRoom.asm
401 lines (359 loc) · 8.55 KB
/
CinnabarLabFossilRoom.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
CinnabarLabFossilRoom_Script:
jp EnableAutoTextBoxDrawing
CinnabarLabFossilRoom_TextPointers:
def_text_pointers
dw_const CinnabarLabFossilRoomScientist1Text, TEXT_CINNABARLABFOSSILROOM_SCIENTIST1
dw_const CinnabarLabFossilRoomScientist2Text, TEXT_CINNABARLABFOSSILROOM_SCIENTIST2
dw_const CinnabarLabFossilRoomColorChangerText, TEXT_CINNABARLABFOSSILROOM_COLOR_CHANGER
Lab4Script_GetFossilsInBag:
; construct a list of all fossils in the player's bag
xor a
ld [wFilteredBagItemsCount], a
ld de, wFilteredBagItems
ld hl, FossilsList
.loop
ld a, [hli]
and a
jr z, .done
push hl
push de
ld [wd11e], a
ld b, a
predef GetQuantityOfItemInBag
pop de
pop hl
ld a, b
and a
jr z, .loop
; A fossil's in the bag
ld a, [wd11e]
ld [de], a
inc de
push hl
ld hl, wFilteredBagItemsCount
inc [hl]
pop hl
jr .loop
.done
ld a, $ff
ld [de], a
ret
FossilsList:
db DOME_FOSSIL
db HELIX_FOSSIL
db OLD_AMBER
db 0 ; end
CinnabarLabFossilRoomScientist1Text:
text_asm
CheckEvent EVENT_GAVE_FOSSIL_TO_LAB
jr nz, .check_done_reviving
ld hl, .Text
rst _PrintText
call Lab4Script_GetFossilsInBag
ld a, [wFilteredBagItemsCount]
and a
jr z, .no_fossils
farcall GiveFossilToCinnabarLab
jr .done
.no_fossils
ld hl, .NoFossilsText
rst _PrintText
.done
rst TextScriptEnd
.check_done_reviving
CheckEventAfterBranchReuseA EVENT_LAB_STILL_REVIVING_FOSSIL, EVENT_GAVE_FOSSIL_TO_LAB
jr z, .done_reviving
ld hl, .GoForAWalkText
rst _PrintText
jr .done
.done_reviving
call LoadFossilItemAndMonNameBank1D
ld hl, .FossilIsBackToLifeText
rst _PrintText
SetEvent EVENT_LAB_HANDING_OVER_FOSSIL_MON
ld a, [wFossilMon]
ld b, a
ld c, 30
call GivePokemon
jr nc, .done
ResetEvents EVENT_GAVE_FOSSIL_TO_LAB, EVENT_LAB_STILL_REVIVING_FOSSIL, EVENT_LAB_HANDING_OVER_FOSSIL_MON
jr .done
.Text:
text_far _CinnabarLabFossilRoomScientist1Text
text_end
.NoFossilsText:
text_far _CinnabarLabFossilRoomScientist1NoFossilsText
text_end
.GoForAWalkText:
text_far _CinnabarLabFossilRoomScientist1GoForAWalkText
text_end
.FossilIsBackToLifeText:
text_far _CinnabarLabFossilRoomScientist1FossilIsBackToLifeText
text_end
CinnabarLabFossilRoomScientist2Text:
text_asm
ld a, TRADE_FOR_SAILOR
ld [wWhichTrade], a
predef DoInGameTradeDialogue
rst TextScriptEnd
LoadFossilItemAndMonNameBank1D:
farjp LoadFossilItemAndMonName
; PureRGBnote: ADDED: new NPC who will allow you to change color palettes of your pokemon to alternate and back a limited number of times
; per playthrough. Beating professor oak the first time will get you 10 extra color changes.
; If you run out, it's time to go and catch alternate palette pokemon in the wild instead. Most pokemon are available in alternate palette somewhere.
; A few, like legendaries and starters, are not.
; Everything below this point is code for the color changer npc.
CinnabarLabFossilRoomColorChangerText:
text_asm
ld a, [wOptions2]
bit BIT_ALT_PKMN_PALETTES, a ; do we have alt palettes enabled
jr nz, .altPalettesEnabled
; we don't have alt palettes turned on, so no need to have his whole big script
ld hl, LabColorChangerResearchingColors
rst _PrintText
rst TextScriptEnd
.altPalettesEnabled
CheckEvent EVENT_MET_LAB_COLOR_CHANGER
jr nz, .skipToColorChangeDialog
SetEvent EVENT_MET_LAB_COLOR_CHANGER
ld hl, LabColorChangerGreeting
rst _PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
jr nz, .noDeutsch
ld hl, LabColorChangerGreetingYes
jr .doneGreeting
.noDeutsch
ld hl, LabColorChangerGreetingNo
.doneGreeting
rst _PrintText
.skipToColorChangeDialog
CheckEvent EVENT_BEAT_PROF_OAK_ONCE
call nz, VasIsDas
call GetAvailableColorChanges
and a
jp z, .noChangesLeft
ld a, AMOUNT_LEFT_BOX
ld [wTextBoxID], a
call DisplayTextBoxID
ld hl, LabColorChangerStart
rst _PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
jp nz, .noColorChange
ld hl, LabColorChangerNext
rst _PrintText
.showPartySelection
call SaveScreenTilesToBuffer2
xor a ; NORMAL_PARTY_MENU
ld [wPartyMenuTypeOrMessageID], a
dec a
ld [wUpdateSpritesEnabled], a
call DisplayPartyMenu
jr c, .noPartySelection
xor a
ld [wMonDataLocation], a
call LoadMonData
callfar InGameTrade_RestoreScreen
ld hl, LabColorChangerPics
rst _PrintText
call SaveScreenTilesToBuffer2
call ShowBeforeAfterImages
callfar InGameTrade_RestoreScreen
ld hl, LabColorChangerPicsShown
rst _PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
jr nz, .showPartySelection
ld hl, LabColorChangerStartColorChange
rst _PrintText
call DoColorSwap
ld hl, LabColorChangerColorChangeDone
rst _PrintText
.noColorChange
ld hl, LabColorChangerGoodbye
rst _PrintText
.done
xor a
ld [wUnusedC000], a
rst TextScriptEnd
.noPartySelection
callfar InGameTrade_RestoreScreen
jr .noColorChange
.noChangesLeft
ld hl, LabColorChangerNoChangesLeft
rst _PrintText
jr .noColorChange
VasIsDas:
CheckEvent EVENT_LAB_COLOR_CHANGER_FULL_CHANGES
ret nz
ld hl, LabColorChangerVasIsDas
rst _PrintText
SetEvent EVENT_LAB_COLOR_CHANGER_FULL_CHANGES
ret
; stores the amount of color changes available to use in wUnusedC000
GetAvailableColorChanges:
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits
ld a, [wNumSetBits]
ld b, 15
CheckEventHL EVENT_LAB_COLOR_CHANGER_FULL_CHANGES
jr z, .startCount
ld b, 25
.startCount
cp 150
jr nc, .doneCount
.count
dec b
add 10
cp 150
jr nc, .doneCount
jr .count
.doneCount
ld a, [wColorSwapsUsed]
ld c, a
ld a, b
sub c
ld [wUnusedC000], a
ret
ShowBeforeAfterImages:
call GBPalWhiteOut ; zero all palettes
call ClearScreen
call UpdateSprites
ld hl, wd72c
set 1, [hl]
ld a, $33 ; 3/7 volume
ldh [rNR50], a
ld b, SET_PAL_BEFORE_AFTER
call RunPaletteCommand
call Delay3
call GBPalNormal
ld a, [wcf91]
ld [wd0b5], a ; getmonheader input pokemon
call GetMonHeader ; load pokemon picture location
hlcoord 1, 1
call LoadFlippedFrontSpriteByMonIndex ; draw pokemon picture
hlcoord 11, 4
ld de, BeforeString
call PlaceString
hlcoord 1, 9
call LoadFlippedFrontSpriteByMonIndex ; draw pokemon picture
hlcoord 11, 12
ld de, AfterString
call PlaceString
ld a, [wcf91]
call PlayCry ; play pokemon cry
.waitForButtonPress
call JoypadLowSensitivity
ldh a, [hJoy5]
and A_BUTTON | B_BUTTON
jr z, .waitForButtonPress
ld hl, wd72c
res 1, [hl]
ld a, $77
ldh [rNR50], a ; full volume
ret
BeforeString:
db "BEFORE@"
AfterString:
db "AFTER@"
DoColorSwap:
ld a, [wColorSwapsUsed]
inc a
ld [wColorSwapsUsed], a
ld a, [wWhichPokemon]
ld hl, wPartyMon1Flags
ld bc, wPartyMon2 - wPartyMon1
call AddNTimes ; we are jumping to the index of the chosen pokemon by incrementing N times where N = a
ld a, [hl] ; hl points to the flags data of the chosen pokemon now
and 1 ; only the first bit of flags is used for alt color palette setting
xor 1 ; toggle the value
ld [hl], a ; store it
call GBFadeOutToBlack
call FiddlingAroundSounds
call GBFadeInFromBlack
ld a, [wUnusedC000] ; wUnusedC000 contains the number displayed in AMOUNT_LEFT_BOX currently
dec a
ld [wUnusedC000], a
ld a, AMOUNT_LEFT_BOX
ld [wTextBoxID], a
call DisplayTextBoxID ; redisplay amount left box with decremented value
call PlayDefaultMusic
ret
FiddlingAroundSounds:
ld a, SFX_STOP_ALL_MUSIC
rst _PlaySound
ld a, SFX_TRADE_MACHINE
rst _PlaySound
ld c, 40
rst _DelayFrames
ld a, SFX_NOISE_INSTRUMENT05
rst _PlaySound
ld c, 12
rst _DelayFrames
ld a, SFX_NOISE_INSTRUMENT05
rst _PlaySound
ld c, 12
rst _DelayFrames
ld a, SFX_NOISE_INSTRUMENT05
rst _PlaySound
ld c, 40
rst _DelayFrames
ld b, 20
.loop
ld a, SFX_TURN_OFF_PC
rst _PlaySound
ld c, 2
rst _DelayFrames
dec b
jr nz, .loop
ld c, 60
rst _DelayFrames
ret
LabColorChangerGreeting:
text_far _LabColorChangerGreeting
text_end
LabColorChangerGreetingYes:
text_far _LabColorChangerGreetingYes
text_end
LabColorChangerGreetingNo:
text_far _LabColorChangerGreetingNo
text_end
LabColorChangerVasIsDas:
text_far _LabColorChangerVasIsDas
sound_get_item_2
text_promptbutton
text_end
LabColorChangerNoChangesLeft:
text_far _LabColorChangerNoChangesLeft
text_end
LabColorChangerStart:
text_far _LabColorChangerStart
text_end
LabColorChangerGoodbye:
text_far _LabColorChangerGoodbye
text_end
LabColorChangerNext:
text_far _LabColorChangerNext
text_end
LabColorChangerPics:
text_far _LabColorChangerPics
text_end
LabColorChangerPicsShown:
text_far _LabColorChangerPicsShown
text_end
LabColorChangerStartColorChange:
text_far _LabColorChangerStartColorChange
text_end
LabColorChangerColorChangeDone:
text_far _LabColorChangerColorChangeDone
sound_get_item_2
text_promptbutton
text_end
LabColorChangerResearchingColors:
text_far _LabColorChangerResearchingColors
text_end