Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/CPZ/CPZSetup.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: CPZ Setup Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.aniTileTimer
13
// value1 is unused?
14
private alias object.value2 : object.scrollPos
15
16
// Values used for updating the underwater Super Palette
17
private alias object.value6 : object.clrDivisor_R
18
private alias object.value7 : object.clrDivisor_G
19
private alias object.value8 : object.clrDivisor_B
20
private alias object.value9 : object.waterClrDivisor_R
21
private alias object.value10 : object.waterClrDivisor_G
22
private alias object.value11 : object.waterClrDivisor_B
23
24
private alias object.value12 : object.drawingIndex
25
private alias object.value13 : object.rippleTimer
26
private alias object.value14 : object.paletteTimer
27
private alias object.value15 : object.bgTowerLightPalIndex
28
private alias object.value16 : object.rainbowLightPalIndex
29
private alias object.value17 : object.chemLiquidPalIndex1
30
private alias object.value18 : object.chemLiquidPalIndex2
31
private alias object.value19 : object.chemLiquidPalIndex3
32
33
// Tracks
34
private alias 0 : TRACK_STAGE
35
private alias 1 : TRACK_ACTFINISH
36
private alias 2 : TRACK_INVINCIBLE
37
private alias 3 : TRACK_CONTINUE
38
private alias 4 : TRACK_BOSS
39
private alias 5 : TRACK_GAMEOVER
40
private alias 6 : TRACK_DROWNING
41
private alias 7 : TRACK_SUPER
42
43
// Reserved object slots
44
private alias 10 : SLOT_ZONESETUP
45
private alias 25 : SLOT_MUSICEVENT_CHANGE
46
private alias 26 : SLOT_MUSICEVENT_BOSS
47
48
// Music Events
49
private alias 2 : MUSICEVENT_TRANSITION
50
51
private alias 0 : MUSICEVENT_FLAG_NOCHANGE
52
private alias 1 : MUSICEVENT_FLAG_SPEEDUP
53
private alias 2 : MUSICEVENT_FLAG_SLOWDOWN
54
55
// Music Loops
56
private alias 684580 : MUSIC_LOOP_CPZ
57
private alias 547578 : MUSIC_LOOP_CPZ_F
58
59
private alias 38679 : MUSIC_LOOP_INV
60
private alias 30897 : MUSIC_LOOP_INV_F
61
62
// Achievement Aliases
63
private alias 1 : ACHIEVEMENT_CHEMICALFREE
64
65
66
// ========================
67
// Function Declarations
68
// ========================
69
70
reserve function CPZSetup_getClrDivisor
71
reserve function CPZSetup_InitSuperSonicPal
72
reserve function CPZSetup_InitSuperTailsPal
73
reserve function CPZSetup_InitSuperKnuxPal
74
reserve function CPZSetup_InitSuperAmyPal
75
reserve function CPZSetup_SpeedUpMusic
76
reserve function CPZSetup_SlowDownMusic
77
78
79
// ========================
80
// Static Values
81
// ========================
82
83
public value CPZSetup_rotatingStairTimer = 0
84
public value Water_flashTimer = 0
85
public value CPZSetup_enteredWater = 0
86
private value CPZSetup_hasAchievement = 0
87
private value CPZSetup_waterTintActive = 0
88
89
90
// ========================
91
// Tables
92
// ========================
93
94
private table CPZSetup_bgTowerLightPalTable
95
0xE00000, 0xC00000, 0xA00000, 0x800000, 0x600000, 0x400000, 0x200000, 0x400000
96
0x600000, 0x800000, 0xA00000, 0xC00000, 0xE00000, 0xE02000, 0xE04000, 0xE02000
97
end table
98
99
private table CPZSetup_rainbowLightPalTable
100
0x00E000, 0x20C000, 0x40A000, 0x608000, 0x806000, 0xA04000, 0xC02000
101
0xE00000, 0xC00020, 0xA00040, 0x800060, 0x600080, 0x4000A0, 0x2000C0
102
0x0000E0, 0x0020C0, 0x0040A0, 0x006080, 0x008060, 0x00A040, 0x00C020
103
end table
104
105
private table CPZSetup_chemLiquidPalTable
106
0x0040E0, 0x0000C0, 0x0000C0
107
0x0060E0, 0x0020C0, 0x0000C0
108
0x0040E0, 0x0040E0, 0x0000C0
109
0x0020C0, 0x0060E0, 0x0020C0
110
0x0000C0, 0x0040E0, 0x0040C0
111
0x0000C0, 0x0020C0, 0x0040E0
112
0x0000C0, 0x0000C0, 0x0060E0
113
0x0020C0, 0x0000C0, 0x0040E0
114
0x0020E0, 0x0000C0, 0x0020C0
115
end table
116
117
private table CPZSetup_deformationTable
118
1, 2, 1, 3, 1, 2, 2, 1, 2, 3, 1, 2, 1, 2, 0, 0
119
2, 0, 3, 2, 2, 3, 2, 2, 1, 3, 0, 0, 1, 0, 1, 3
120
1, 2, 1, 3, 1, 2, 2, 1, 2, 3, 1, 2, 1, 2, 0, 0
121
2, 0, 3, 2, 2, 3, 2, 2, 1, 3, 0, 0, 1, 0, 1, 3
122
end table
123
124
// Unused palette table, also found in DEZSetup and EndSetup and even Mania's CPZ!
125
// These are actually colors for one of WFZ's palette cycles
126
// However, you won't find this in WFZSetup because in this 2013 remake, WFZ only uses 1 of the 3 palette cycles it had in the original game,
127
// this one being among the 2 that were cut
128
// Why they were cut, I have no idea, but at the very least, it's certainly a mystery how one of them ended up here of all places...
129
private table CPZSetup_unusedPalette
130
0x00E000, 0x00A000, 0x006000, 0x002000, 0x000000, 0x000020, 0x000060, 0x0020A0, 0x0060E0, 0x0020A0, 0x000060, 0x000020, 0x000000, 0x200000, 0x600000, 0xA00000
131
0xE00000, 0xE04000, 0xE00000, 0xA00000, 0x600000, 0x200000, 0x000000, 0x202000, 0x606000, 0xA0A000, 0xE0E000, 0xA0A000, 0x606000, 0x202000, 0x000000, 0x002000
132
0x006000, 0x00A000
133
end table
134
135
private table CPZSetup_replay_attract_S
136
0x380000, 0x1EC0000
137
0x00, 10
138
0x08, 52
139
0x38, 1
140
0x28, 5
141
0x08, 35
142
0x38, 1
143
0x28, 8
144
0x08, 255
145
0x08, 214
146
0x00, 9
147
0x04, 3
148
0x34, 1
149
0x24, 9
150
0x28, 2
151
0x08, 54
152
0x00, 2
153
0x04, 2
154
0x00, 1
155
0x08, 192
156
0x38, 1
157
0x28, 41
158
0x08, 13
159
0x0A, 1
160
0x02, 26
161
0x0A, 2
162
0x08, 16
163
0x00, 2
164
0x04, 22
165
0x00, 8
166
0x08, 34
167
0x38, 1
168
0x28, 3
169
0x08, 32
170
0x00, 1
171
0x04, 10
172
0x00, 1
173
0x08, 10
174
0x00, 16
175
0x04, 39
176
0x00, 1
177
0x02, 20
178
0x00, 1
179
0x04, 29
180
0x00, 37
181
0x04, 12
182
0x00, 4
183
0x04, 4
184
0x00, 24
185
0x30, 1
186
0x20, 4
187
0x04, 7
188
0x00, 20
189
0x04, 30
190
0x00 // There's supposed to be an even amount of entries, since these come in pairs, but I guess this table felt like having an extra value?
191
end table
192
193
private table CPZSetup_replay_attract_T
194
0x380000, 0x1F00000
195
0x00, 53
196
0x08, 45
197
0x38, 1
198
0x28, 6
199
0x08, 34
200
0x38, 1
201
0x28, 9
202
0x08, 55
203
0x38, 1
204
0x28, 21
205
0x08, 249
206
0x38, 1
207
0x28, 12
208
0x08, 84
209
0x38, 1
210
0x28, 21
211
0x08, 138
212
0x38, 1
213
0x28, 9
214
0x2A, 16
215
0x0A, 9
216
0x08, 96
217
0x0A, 4
218
0x02, 9
219
0x0A, 2
220
0x08, 71
221
0x00, 11
222
0x04, 44
223
0x00, 13
224
0x04, 4
225
0x00, 4
226
0x04, 10
227
0x00, 9
228
0x04, 9
229
0x00, 3
230
0x04, 39
231
0x00, 6
232
0x04, 11
233
0x00, 7
234
0x04, 5
235
0x00, 13
236
0x30, 1
237
0x20, 3
238
0x28, 1
239
0x08, 5
240
0x38, 1
241
0x28, 3
242
0x20, 2
243
0x00, 4
244
0x30, 1
245
0x20, 4
246
0x00, 4
247
0x38, 1
248
0x28, 4
249
0x08, 4
250
0x38, 1
251
0x20, 5
252
0x00, 3
253
0x30, 1
254
0x20, 6
255
0x00, 3
256
0x04, 1
257
0x34, 1
258
0x24, 5
259
0x04, 3
260
0x34, 1
261
0x24, 1
262
0x20, 4
263
0x00, 4
264
0x38, 1
265
0x28, 4
266
0x08, 2
267
0x00, 3
268
0x30, 1
269
0x20, 4
270
0x00, 4
271
0x30, 1
272
0x20, 4
273
0x00, 4
274
0x30, 1
275
0x20, 4
276
0x00, 4
277
0x38, 1
278
0x28, 4
279
0x08, 4
280
0x38, 1
281
0x28, 1
282
0x20, 4
283
0x00, 4
284
0x30, 1
285
0x20, 4
286
0x00, 4
287
0x30, 1
288
0x20, 5
289
0x00, 4
290
0x30, 1
291
0x20, 5
292
0x00, 3
293
0x08, 12
294
0x00, 11
295
0x08, 34
296
0x38, 1
297
0x28, 21
298
0x08, 3
299
0x00, 13
300
0x08, 119
301
0x38, 2
302
end table
303
304
private table CPZSetup_replay_attract_K
305
0x380000, 0x1EC0000
306
0x00, 54
307
0x08, 45
308
0x38, 1
309
0x28, 7
310
0x08, 34
311
0x38, 1
312
0x28, 20
313
0x08, 0xFF
314
0x08, 218
315
0x38, 1
316
0x28, 9
317
0x08, 61
318
0x38, 1
319
0x28, 9
320
0x08, 14
321
0x00, 1
322
0x04, 14
323
0x00, 6
324
0x08, 110
325
0x00, 10
326
0x08, 10
327
0x00, 24
328
0x08, 5
329
0x00, 7
330
0x08, 20
331
0x38, 1
332
0x28, 1
333
0x20, 3
334
0x00, 5
335
0x04, 39
336
0x00, 26
337
0x08, 57
338
0x38, 1
339
0x28, 16
340
0x08, 7
341
0x38, 1
342
0x28, 22
343
0x29, 2
344
0x09, 31
345
0x08, 21
346
0x38, 1
347
0x28, 11
348
0x08, 175
349
0x0A, 1
350
0x02, 244
351
0x32, 1
352
0x22, 26
353
0x2A, 1
354
0x28, 1
355
0x08, 4
356
0x38, 1
357
0x28, 24
358
0x08, 2
359
0x00, 25
360
0x08, 5
361
0x38, 1
362
0x28, 10
363
0x08, 32
364
0x00, 1
365
0x04, 23
366
0x00, 4
367
0x08, 20
368
end table
369
370
371
// ========================
372
// Function Definitions
373
// ========================
374
375
// Wacky function to take a normal color and turn it into an underwater color
376
private function CPZSetup_getClrDivisor
377
// Regular Color
378
object.clrDivisor_R = temp1
379
object.clrDivisor_R >>= 16
380
381
object.clrDivisor_G = temp1
382
object.clrDivisor_G >>= 8
383
object.clrDivisor_G &= 0xFF
384
385
object.clrDivisor_B = temp1
386
object.clrDivisor_B &= 0xFF
387
388
// Underwater Color
389
object.waterClrDivisor_R = temp2
390
object.waterClrDivisor_R >>= 16
391
392
object.waterClrDivisor_G = temp2
393
object.waterClrDivisor_G >>= 8
394
object.waterClrDivisor_G &= 0xFF
395
396
object.waterClrDivisor_B = temp2
397
object.waterClrDivisor_B &= 0xFF
398
399
// Minimum of 1 (you cant divide by zero)
400
if object.waterClrDivisor_R == 0
401
object.waterClrDivisor_R = 1
402
end if
403
404
if object.waterClrDivisor_G == 0
405
object.waterClrDivisor_G = 1
406
end if
407
408
if object.waterClrDivisor_B == 0
409
object.waterClrDivisor_B = 1
410
end if
411
412
object.clrDivisor_R <<= 8
413
object.clrDivisor_G <<= 8
414
object.clrDivisor_B <<= 8
415
object.clrDivisor_R /= object.waterClrDivisor_R
416
object.clrDivisor_G /= object.waterClrDivisor_G
417
object.clrDivisor_B /= object.waterClrDivisor_B
418
419
if object.clrDivisor_R == 0
420
object.clrDivisor_R = 0x100
421
end if
422
423
if object.clrDivisor_G == 0
424
object.clrDivisor_G = 0x100
425
end if
426
427
if object.clrDivisor_B == 0
428
object.clrDivisor_B = 0x100
429
end if
430
end function
431
432
433
private function CPZSetup_InitSuperSonicPal
434
temp0 = 0
435
436
// First Set of colors is just the regular underwater palette
437
GetPaletteEntry(1, 2, temp1)
438
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
439
temp0++
440
441
GetPaletteEntry(1, 3, temp1)
442
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
443
temp0++
444
445
GetPaletteEntry(1, 4, temp1)
446
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
447
temp0++
448
449
GetPaletteEntry(1, 5, temp1)
450
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
451
temp0++
452
453
CopyPalette(1, 0, 4, 2, 4)
454
while temp0 < 64
455
GetTableValue(temp1, temp0, Player_SonicSuperPal)
456
SetPaletteEntry(3, 0, temp1)
457
temp0++
458
459
GetTableValue(temp1, temp0, Player_SonicSuperPal)
460
SetPaletteEntry(3, 1, temp1)
461
temp0++
462
463
GetTableValue(temp1, temp0, Player_SonicSuperPal)
464
SetPaletteEntry(3, 2, temp1)
465
temp0++
466
467
GetTableValue(temp1, temp0, Player_SonicSuperPal)
468
SetPaletteEntry(3, 3, temp1)
469
temp0 -= 3
470
471
// Just mix the 2 palettes, we'll use the results as our new colors
472
SetPaletteFade(5, 3, 4, 48, 0, 4)
473
474
GetPaletteEntry(5, 0, temp1)
475
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
476
temp0++
477
478
GetPaletteEntry(5, 1, temp1)
479
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
480
temp0++
481
482
GetPaletteEntry(5, 2, temp1)
483
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
484
temp0++
485
486
GetPaletteEntry(5, 3, temp1)
487
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
488
temp0++
489
loop
490
end function
491
492
493
private function CPZSetup_InitSuperTailsPal
494
temp0 = 0
495
496
GetPaletteEntry(1, 13, temp1)
497
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
498
temp0++
499
500
GetPaletteEntry(1, 17, temp1)
501
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
502
temp0++
503
504
GetPaletteEntry(1, 18, temp1)
505
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
506
temp0++
507
508
GetPaletteEntry(1, 16, temp1)
509
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
510
temp0++
511
512
while temp0 < 24
513
GetPaletteEntry(0, 13, temp1)
514
GetPaletteEntry(1, 13, temp2)
515
516
CallFunction(CPZSetup_getClrDivisor)
517
518
GetTableValue(temp1, temp0, Player_TailsSuperPal)
519
520
temp2 = temp1
521
temp2 >>= 8
522
temp2 &= 0xFF
523
524
temp3 = temp1
525
temp3 &= 0xFF
526
527
temp1 >>= 16
528
529
temp1 *= 0xF8
530
temp1 /= object.clrDivisor_R
531
532
temp2 *= 0xF8
533
temp2 /= object.clrDivisor_G
534
535
temp3 *= 0xF8
536
temp3 /= object.clrDivisor_B
537
538
temp1 &= 0xF0
539
temp2 &= 0xF0
540
temp3 &= 0xF0
541
542
if temp1 > 0xE0
543
temp1 = 0xE0
544
end if
545
546
if temp2 > 0xE0
547
temp2 = 0xE0
548
end if
549
550
if temp3 > 0xE0
551
temp3 = 0xE0
552
end if
553
554
temp1 <<= 16
555
temp2 <<= 8
556
temp1 += temp2
557
temp1 += temp3
558
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
559
temp0++
560
561
562
GetPaletteEntry(0, 17, temp1)
563
GetPaletteEntry(1, 17, temp2)
564
565
CallFunction(CPZSetup_getClrDivisor)
566
567
GetTableValue(temp1, temp0, Player_TailsSuperPal)
568
569
temp2 = temp1
570
temp2 >>= 8
571
temp2 &= 0xFF
572
573
temp3 = temp1
574
temp3 &= 0xFF
575
576
temp1 >>= 16
577
578
temp1 *= 0x100
579
temp1 /= object.clrDivisor_R
580
581
temp2 *= 0x100
582
temp2 /= object.clrDivisor_G
583
584
temp3 *= 0x100
585
temp3 /= object.clrDivisor_B
586
587
temp1 &= 0xF0
588
temp2 &= 0xF0
589
temp3 &= 0xF0
590
591
if temp1 > 0xE0
592
temp1 = 0xE0
593
end if
594
595
if temp2 > 0xE0
596
temp2 = 0xE0
597
end if
598
599
if temp3 > 0xE0
600
temp3 = 0xE0
601
end if
602
603
temp1 <<= 16
604
temp2 <<= 8
605
temp1 += temp2
606
temp1 += temp3
607
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
608
temp0++
609
610
611
GetPaletteEntry(0, 18, temp1)
612
GetPaletteEntry(1, 18, temp2)
613
614
CallFunction(CPZSetup_getClrDivisor)
615
616
GetTableValue(temp1, temp0, Player_TailsSuperPal)
617
618
temp2 = temp1
619
temp2 >>= 8
620
temp2 &= 0xFF
621
622
temp3 = temp1
623
temp3 &= 0xFF
624
625
temp1 >>= 16
626
627
temp1 *= 0x100
628
temp1 /= object.clrDivisor_R
629
630
temp2 *= 0x100
631
temp2 /= object.clrDivisor_G
632
633
temp3 *= 0x100
634
temp3 /= object.clrDivisor_B
635
636
temp1 &= 0xF0
637
temp2 &= 0xF0
638
temp3 &= 0xF0
639
640
if temp1 > 0xE0
641
temp1 = 0xE0
642
end if
643
644
if temp2 > 0xE0
645
temp2 = 0xE0
646
end if
647
648
if temp3 > 0xE0
649
temp3 = 0xE0
650
end if
651
652
temp1 <<= 16
653
temp2 <<= 8
654
temp1 += temp2
655
temp1 += temp3
656
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
657
temp0++
658
659
660
GetPaletteEntry(0, 16, temp1)
661
GetPaletteEntry(1, 16, temp2)
662
663
CallFunction(CPZSetup_getClrDivisor)
664
665
GetTableValue(temp1, temp0, Player_TailsSuperPal)
666
667
temp2 = temp1
668
temp2 >>= 8
669
temp2 &= 0xFF
670
671
temp3 = temp1
672
temp3 &= 0xFF
673
674
temp1 >>= 16
675
676
temp1 *= 0x100
677
temp1 /= object.clrDivisor_R
678
679
temp2 *= 0x100
680
temp2 /= object.clrDivisor_G
681
682
temp3 *= 0x100
683
temp3 /= object.clrDivisor_B
684
685
temp1 &= 0xF0
686
temp2 &= 0xF0
687
temp3 &= 0xF0
688
689
if temp1 > 0xE0
690
temp1 = 0xE0
691
end if
692
693
if temp2 > 0xE0
694
temp2 = 0xE0
695
end if
696
697
if temp3 > 0xE0
698
temp3 = 0xE0
699
end if
700
701
temp1 <<= 16
702
temp2 <<= 8
703
temp1 += temp2
704
temp1 += temp3
705
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
706
temp0++
707
loop
708
end function
709
710
711
private function CPZSetup_InitSuperKnuxPal
712
temp0 = 0
713
714
GetPaletteEntry(1, 26, temp1)
715
SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)
716
temp0++
717
718
GetPaletteEntry(1, 27, temp1)
719
SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)
720
temp0++
721
722
GetPaletteEntry(1, 28, temp1)
723
SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)
724
temp0++
725
end function
726
727
728
private function CPZSetup_InitSuperAmyPal
729
#platform: USE_ORIGINS
730
temp0 = 0
731
732
GetPaletteEntry(1, 54, temp1)
733
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
734
temp0++
735
736
GetPaletteEntry(1, 50, temp1)
737
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
738
temp0++
739
740
GetPaletteEntry(1, 51, temp1)
741
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
742
temp0++
743
744
GetPaletteEntry(1, 52, temp1)
745
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
746
temp0++
747
748
GetPaletteEntry(1, 53, temp1)
749
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
750
temp0++
751
752
while temp0 < 30
753
temp4 = temp0
754
temp4 -= 5
755
756
GetTableValue(temp1, temp4, Player_AmySuperAltPal)
757
758
temp2 = temp1
759
temp2 >>= 8
760
temp2 &= 255
761
762
temp3 = temp1
763
temp3 &= 255
764
765
temp1 >>= 16
766
temp1 += 32
767
if temp1 > 255
768
temp1 = 255
769
end if
770
771
temp2 += 32
772
if temp2 > 255
773
temp2 = 255
774
end if
775
776
temp3 += 32
777
if temp3 > 255
778
temp3 = 255
779
end if
780
781
temp1 <<= 16
782
temp2 <<= 8
783
temp1 += temp2
784
temp1 += temp3
785
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
786
temp0++
787
loop
788
789
temp6 = 25
790
while temp0 < 50
791
temp5 = 0
792
while temp5 < 5
793
temp4 = temp6
794
temp4 += temp5
795
GetTableValue(temp1, temp4, Player_AmySuperAltPal)
796
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
797
temp0++
798
temp5++
799
loop
800
801
temp6 -= 5
802
loop
803
#endplatform
804
end function
805
806
807
private function CPZSetup_SpeedUpMusic
808
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])
809
temp0 = checkResult
810
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)
811
temp0 &= checkResult
812
CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)
813
temp0 &= checkResult
814
if temp0 == false
815
switch music.currentTrack
816
case TRACK_STAGE
817
SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)
818
SwapMusicTrack("ChemicalPlant_F.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ_F, 8000)
819
break
820
821
case TRACK_INVINCIBLE
822
SetMusicTrack("ChemicalPlant_F.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ_F)
823
SwapMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F, 8000)
824
break
825
826
case TRACK_BOSS
827
case TRACK_DROWNING
828
case TRACK_SUPER
829
SetMusicTrack("ChemicalPlant_F.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ_F)
830
SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)
831
break
832
end switch
833
else
834
stage.musicFlag = MUSICEVENT_FLAG_SPEEDUP
835
end if
836
end function
837
838
839
private function CPZSetup_SlowDownMusic
840
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])
841
temp0 = checkResult
842
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)
843
temp0 &= checkResult
844
CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)
845
temp0 &= checkResult
846
if temp0 == false
847
switch music.currentTrack
848
case TRACK_STAGE
849
SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)
850
SwapMusicTrack("ChemicalPlant.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ, 12500)
851
break
852
853
case TRACK_INVINCIBLE
854
SetMusicTrack("ChemicalPlant.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ)
855
SwapMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV, 12500)
856
break
857
858
case TRACK_BOSS
859
case TRACK_DROWNING
860
case TRACK_SUPER
861
SetMusicTrack("ChemicalPlant.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ)
862
SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)
863
break
864
end switch
865
else
866
stage.musicFlag = MUSICEVENT_FLAG_SLOWDOWN
867
end if
868
end function
869
870
871
// ========================
872
// Events
873
// ========================
874
875
event ObjectUpdate
876
#platform: USE_ORIGINS
877
if stage.state != STAGE_FROZEN
878
#endplatform
879
GetTableValue(temp0, 21, StageSetup_oscillationTable)
880
if temp0 == 0
881
CPZSetup_rotatingStairTimer++
882
CPZSetup_rotatingStairTimer &= 3
883
end if
884
885
object.rippleTimer++
886
if object.rippleTimer > 7
887
tileLayer[1].deformationOffset++
888
object.rippleTimer = 0
889
end if
890
891
// Animate the converyor belts in the background
892
object.aniTileTimer++
893
if object.aniTileTimer == 5
894
object.aniTileTimer = 0
895
896
object.frame++
897
object.frame &= 7
898
temp0 = object.frame
899
temp0 += 768
900
Copy16x16Tile(767, temp0)
901
end if
902
903
if Water_flashTimer > 0
904
Water_flashTimer--
905
end if
906
907
// Manage the various cycling palettes throughout the stage
908
object.paletteTimer++
909
if object.paletteTimer == 8
910
object.paletteTimer = 0
911
912
object.bgTowerLightPalIndex++
913
object.bgTowerLightPalIndex &= 15
914
GetTableValue(temp0, object.bgTowerLightPalIndex, CPZSetup_bgTowerLightPalTable)
915
SetPaletteEntry(0, 175, temp0)
916
917
object.rainbowLightPalIndex++
918
object.rainbowLightPalIndex %= 21
919
GetTableValue(temp0, object.rainbowLightPalIndex, CPZSetup_rainbowLightPalTable)
920
SetPaletteEntry(0, 191, temp0)
921
922
object.chemLiquidPalIndex1 += 3
923
object.chemLiquidPalIndex1 %= 27
924
GetTableValue(temp0, object.chemLiquidPalIndex1, CPZSetup_chemLiquidPalTable)
925
SetPaletteEntry(0, 188, temp0)
926
927
object.chemLiquidPalIndex2 += 3
928
object.chemLiquidPalIndex2 %= 27
929
GetTableValue(temp0, object.chemLiquidPalIndex2, CPZSetup_chemLiquidPalTable)
930
SetPaletteEntry(0, 189, temp0)
931
932
object.chemLiquidPalIndex3 += 3
933
object.chemLiquidPalIndex3 %= 27
934
GetTableValue(temp0, object.chemLiquidPalIndex3, CPZSetup_chemLiquidPalTable)
935
SetPaletteEntry(0, 190, temp0)
936
end if
937
938
if CPZSetup_hasAchievement == false
939
if stage.debugMode == false
940
if stage.actNum == 2
941
if object[30].type == TypeName[Act Finish]
942
CPZSetup_hasAchievement = true
943
if CPZSetup_enteredWater == false
944
// Grant the "100% Chemical Free" Achievement
945
CallNativeFunction2(SetAchievement, ACHIEVEMENT_CHEMICALFREE, 100)
946
end if
947
end if
948
end if
949
end if
950
end if
951
#platform: USE_ORIGINS
952
end if
953
954
object.drawingIndex = 0
955
CPZSetup_waterTintActive = 0
956
#endplatform
957
end event
958
959
960
event ObjectDraw
961
#platform: USE_ORIGINS
962
// If this check doesn't pass, the water tint is skipped over, and the foreground Girders are skipped over as well
963
// Unfortunately, this check always passes because the value is always set to 0 as seen above LOL
964
// (Interesting note though - this value does at least reach, but not surpass, 4 in 2PVS where 2 screens are active, does that mean anything?)
965
if CPZSetup_waterTintActive < 4
966
#endplatform
967
if object.drawingIndex == 0
968
// Activating the Water tint
969
970
temp0 = stage.waterLevel
971
temp0 -= screen.yoffset
972
if temp0 < 0
973
temp0 = 0
974
end if
975
if temp0 > screen.ysize
976
temp0 = screen.ysize
977
end if
978
979
SetActivePalette(0, 0, temp0)
980
if Water_flashTimer > 0
981
SetActivePalette(2, temp0, screen.ysize)
982
else
983
SetActivePalette(1, temp0, screen.ysize)
984
end if
985
986
// Add the object to the draw list again, for the Girders
987
AddDrawListEntityRef(2, object.entityPos)
988
else
989
// Drawing the Girders
990
991
temp0 = screen.xoffset
992
temp0 *= 6
993
temp0 >>= 3
994
temp0 &= 0x1FF
995
FlipSign(temp0)
996
temp0 += object.scrollPos
997
998
temp1 = screen.yoffset
999
temp1 >>= 1
1000
temp1 &= 0xFF
1001
FlipSign(temp1)
1002
1003
DrawSpriteScreenXY(0, temp0, temp1)
1004
DrawSpriteScreenXY(1, temp0, temp1)
1005
end if
1006
#platform: USE_ORIGINS
1007
end if
1008
#endplatform
1009
1010
object.drawingIndex ^= 1
1011
#platform: USE_ORIGINS
1012
CPZSetup_waterTintActive++
1013
#endplatform
1014
end event
1015
1016
1017
event ObjectStartup
1018
LoadSpriteSheet("CPZ/Objects.gif")
1019
1020
// Reset the boss flashing color
1021
SetPaletteEntry(0, 192, 0x000000)
1022
1023
// Set the Chemical Plant music, and set its speedup/slowndown functions too
1024
SetMusicTrack("ChemicalPlant.ogg", TRACK_STAGE, MUSIC_LOOP_CPZ)
1025
SpeedUpMusic = CPZSetup_SpeedUpMusic
1026
SlowDownMusic = CPZSetup_SlowDownMusic
1027
1028
// Sprite Frames - Foreground Girder
1029
SpriteFrame(-16, 0, 32, 256, 224, 0)
1030
SpriteFrame(-16, 256, 32, 256, 224, 0)
1031
1032
// Conveyor Belt Tile - Frame 1
1033
Copy16x16Tile(767, 768)
1034
1035
// Locky and Pocky are the ones swimming in these chemicals
1036
animalType1 = TypeName[Locky]
1037
animalType2 = TypeName[Pocky]
1038
1039
// Set object 10 to be a CPZ Setup object
1040
object[SLOT_ZONESETUP].type = TypeName[CPZ Setup]
1041
#platform: USE_STANDALONE
1042
object[SLOT_ZONESETUP].priority = PRIORITY_ACTIVE
1043
#endplatform
1044
#platform: USE_ORIGINS
1045
object[SLOT_ZONESETUP].priority = PRIORITY_ALWAYS
1046
#endplatform
1047
object[SLOT_ZONESETUP].drawOrder = 0
1048
object[SLOT_ZONESETUP].scrollPos = 496
1049
object[SLOT_ZONESETUP].chemLiquidPalIndex2 = 1
1050
object[SLOT_ZONESETUP].chemLiquidPalIndex3 = 2
1051
1052
temp0 = screen.xcenter
1053
temp0 >>= 2
1054
object[SLOT_ZONESETUP].scrollPos -= temp0
1055
1056
CPZSetup_rotatingStairTimer = 0
1057
1058
// Load the water palette
1059
LoadPalette("CPZ_WaterPal.act", 1, 0, 0, 256)
1060
1061
// Init underwater Super palettes
1062
CallFunction(CPZSetup_InitSuperSonicPal)
1063
CallFunction(CPZSetup_InitSuperTailsPal)
1064
CallFunction(CPZSetup_InitSuperKnuxPal)
1065
#platform: USE_ORIGINS
1066
CallFunction(CPZSetup_InitSuperAmyPal)
1067
#endplatform
1068
1069
// Load the eletric flash palette in case the player tries to swim with a lightning shield
1070
LoadPalette("ElectricFlash.act", 2, 0, 0, 256)
1071
1072
Water_flashTimer = 0
1073
1074
// Reset the ripple effect
1075
arrayPos0 = 0
1076
while arrayPos0 < 576
1077
temp0 = arrayPos0
1078
temp0 &= 0x3F
1079
GetTableValue(stage.deformationData2[arrayPos0], temp0, CPZSetup_deformationTable)
1080
arrayPos0++
1081
loop
1082
1083
if options.attractMode == true
1084
switch stage.playerListPos
1085
case PLAYER_SONIC_A
1086
#platform: USE_ORIGINS
1087
case PLAYER_AMY_A // Amy isn't even able to show up in demos, but check for her anyway I guess
1088
#endplatform
1089
Player_attractTable = CPZSetup_replay_attract_S
1090
Player_attractTableSize = 109
1091
Player_attractDuration = 1800
1092
break
1093
1094
case PLAYER_TAILS_A
1095
Player_attractTable = CPZSetup_replay_attract_T
1096
Player_attractTableSize = 216
1097
Player_attractDuration = 1560
1098
break
1099
1100
case PLAYER_KNUCKLES_A
1101
Player_attractTable = CPZSetup_replay_attract_K
1102
Player_attractTableSize = 126
1103
Player_attractDuration = 1680
1104
break
1105
end switch
1106
1107
CallFunction(Player_SetupAttractDemo)
1108
end if
1109
end event
1110
1111
1112
// ========================
1113
// Editor Events
1114
// ========================
1115
1116
event RSDKDraw
1117
DrawSprite(0)
1118
end event
1119
1120
1121
event RSDKLoad
1122
LoadSpriteSheet("Global/Display.gif")
1123
SpriteFrame(-16, -16, 32, 32, 1, 143)
1124
1125
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
1126
end event
1127
1128