Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/LZ/LZSetup.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: LZ 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.deformTimer
13
private alias object.value1 : object.paletteTimer1
14
private alias object.value2 : object.beltPaletteTimer
15
private alias object.value3 : object.beltPaletteIndex
16
private alias object.value4 : object.waterfallLoopTimer
17
private alias object.value5 : object.playingWaterfallLoop
18
private alias object.value6 : object.clrDivisor_R
19
private alias object.value7 : object.clrDivisor_G
20
private alias object.value8 : object.clrDivisor_B
21
private alias object.value9 : object.waterClrDivisor_R
22
private alias object.value10 : object.waterClrDivisor_G
23
private alias object.value11 : object.waterClrDivisor_B
24
25
// Player Aliases
26
private alias object.state : player.state
27
private alias object.xpos : player.xpos
28
private alias object.ypos : player.ypos
29
private alias object.xvel : player.xvel
30
private alias object.speed : player.speed
31
private alias object.gravity : player.gravity
32
private alias object.animation : player.animation
33
private alias object.direction : player.direction
34
private alias object.collisionBottom : player.collisionBottom
35
36
// Tile Info ID Aliases
37
private alias 0 : TILEINFO_INDEX
38
private alias 1 : TILEINFO_DIRECTION
39
private alias 8 : TILEINFO_ANGLEB
40
41
// Tile Flag Aliases
42
private alias 1 : TILE_WATERSLIDE
43
44
// Tracks
45
private alias 0 : TRACK_STAGE
46
private alias 2 : TRACK_INVINCIBLE
47
private alias 4 : TRACK_BOSS
48
private alias 6 : TRACK_DROWNING
49
50
// Reserved Object Slot Aliases
51
private alias 10 : SLOT_ZONESETUP
52
private alias 25 : SLOT_MUSICEVENT_CHANGE
53
54
// Music Events
55
private alias 0 : MUSICEVENT_FADETOBOSS
56
private alias 1 : MUSICEVENT_FADETOSTAGE
57
private alias 2 : MUSICEVENT_TRANSITION
58
59
private alias 0 : MUSICEVENT_FLAG_NOCHANGE
60
private alias 1 : MUSICEVENT_FLAG_SPEEDUP
61
private alias 2 : MUSICEVENT_FLAG_SLOWDOWN
62
63
// Music Loops
64
private alias 84444 : MUSIC_LOOP_LZ
65
private alias 67538 : MUSIC_LOOP_LZ_F
66
67
private alias 1 : MUSIC_LOOP_SBZ
68
private alias 1 : MUSIC_LOOP_SBZ_F
69
70
private alias 39528 : MUSIC_LOOP_INV
71
private alias 30436 : MUSIC_LOOP_INV_F
72
73
74
// ========================
75
// Function Declarations
76
// ========================
77
78
reserve function LZSetup_SetupRippleDeform1
79
reserve function LZSetup_SetupRippleDeform2
80
reserve function LZSetup_getClrDivisor
81
reserve function LZSetup_InitSuperSonicPal
82
reserve function LZSetup_InitSuperTailsPal
83
reserve function LZSetup_InitSuperKnuxPal
84
reserve function LZSetup_InitSuperAmyPal
85
reserve function LZSetup_SpeedUpMusicLZ
86
reserve function LZSetup_SlowDownMusicLZ
87
reserve function LZSetup_SpeedUpMusicSBZ3
88
reserve function LZSetup_SlowDownMusicSBZ3
89
90
91
// ========================
92
// Static Values
93
// ========================
94
95
public value Water_flashTimer = 0 // Uses "Water_" since all water objects use it from the setup so its easier to make new objs this way
96
public value LZSetup_beltDirection = 0
97
98
99
// ========================
100
// Tables
101
// ========================
102
103
private table LZSetup_beltPalDelayTable
104
2, 2, 1
105
end table
106
107
108
private table LZSetup_replay_credits_STK
109
0xA000000, 0x62C0000
110
0x08, 49
111
0x00, 9
112
0x08, 102
113
0x00, 86
114
0x02, 13
115
0x00, 11
116
0x02, 10
117
0x00, 9
118
0x02, 13
119
0x00, 7
120
0x08, 13
121
0x38, 1
122
0x28, 3
123
0x08, 38
124
0x00, 27
125
0x01, 13
126
0x00, 13
127
0x02, 13
128
0x00, 10
129
0x02, 7
130
0x08, 9
131
0x38, 1
132
0x28, 4
133
0x08, 27
134
0x00, 13
135
0x02, 12
136
0x00, 12
137
0x02, 10
138
0x00, 15
139
0x02, 7
140
0x00, 14
141
0x02, 10
142
0x00, 35
143
0x30, 1
144
0x20, 4
145
0x00, 8
146
0x02, 6
147
end table
148
149
150
private function LZSetup_SetupRippleDeform1
151
stage.deformationData1[arrayPos0] = 1
152
arrayPos0++
153
154
stage.deformationData1[arrayPos0] = 1
155
arrayPos0++
156
157
stage.deformationData1[arrayPos0] = 2
158
arrayPos0++
159
160
stage.deformationData1[arrayPos0] = 2
161
arrayPos0++
162
163
stage.deformationData1[arrayPos0] = 3
164
arrayPos0++
165
166
stage.deformationData1[arrayPos0] = 3
167
arrayPos0++
168
169
stage.deformationData1[arrayPos0] = 3
170
arrayPos0++
171
172
stage.deformationData1[arrayPos0] = 3
173
arrayPos0++
174
175
stage.deformationData1[arrayPos0] = 2
176
arrayPos0++
177
178
stage.deformationData1[arrayPos0] = 2
179
arrayPos0++
180
181
stage.deformationData1[arrayPos0] = 1
182
arrayPos0++
183
184
stage.deformationData1[arrayPos0] = 1
185
arrayPos0++
186
end function
187
188
189
private function LZSetup_SetupRippleDeform2
190
stage.deformationData1[arrayPos0] = -1
191
arrayPos0++
192
193
stage.deformationData1[arrayPos0] = -1
194
arrayPos0++
195
196
stage.deformationData1[arrayPos0] = -2
197
arrayPos0++
198
199
stage.deformationData1[arrayPos0] = -2
200
arrayPos0++
201
202
stage.deformationData1[arrayPos0] = -3
203
arrayPos0++
204
205
stage.deformationData1[arrayPos0] = -3
206
arrayPos0++
207
208
stage.deformationData1[arrayPos0] = -3
209
arrayPos0++
210
211
stage.deformationData1[arrayPos0] = -3
212
arrayPos0++
213
214
stage.deformationData1[arrayPos0] = -2
215
arrayPos0++
216
217
stage.deformationData1[arrayPos0] = -2
218
arrayPos0++
219
220
stage.deformationData1[arrayPos0] = -1
221
arrayPos0++
222
223
stage.deformationData1[arrayPos0] = -1
224
arrayPos0++
225
end function
226
227
228
// Wacky function to take a normal color and turn it into an underwater color
229
private function LZSetup_getClrDivisor
230
// Regular Color
231
object.clrDivisor_R = temp1
232
object.clrDivisor_R >>= 16
233
234
object.clrDivisor_G = temp1
235
object.clrDivisor_G >>= 8
236
object.clrDivisor_G &= 0xFF
237
238
object.clrDivisor_B = temp1
239
object.clrDivisor_B &= 0xFF
240
241
// Underwater Color
242
object.waterClrDivisor_R = temp2
243
object.waterClrDivisor_R >>= 16
244
245
object.waterClrDivisor_G = temp2
246
object.waterClrDivisor_G >>= 8
247
object.waterClrDivisor_G &= 0xFF
248
249
object.waterClrDivisor_B = temp2
250
object.waterClrDivisor_B &= 0xFF
251
252
// Minimum of 1 (don't wanna divide by 0!)
253
if object.waterClrDivisor_R == 0
254
object.waterClrDivisor_R = 1
255
end if
256
257
if object.waterClrDivisor_G == 0
258
object.waterClrDivisor_G = 1
259
end if
260
261
if object.waterClrDivisor_B == 0
262
object.waterClrDivisor_B = 1
263
end if
264
265
object.clrDivisor_R <<= 8
266
object.clrDivisor_G <<= 8
267
object.clrDivisor_B <<= 8
268
269
object.clrDivisor_R /= object.waterClrDivisor_R
270
object.clrDivisor_G /= object.waterClrDivisor_G
271
object.clrDivisor_B /= object.waterClrDivisor_B
272
273
if object.clrDivisor_R == 0
274
object.clrDivisor_R = 0x100
275
end if
276
277
if object.clrDivisor_G == 0
278
object.clrDivisor_G = 0x100
279
end if
280
281
if object.clrDivisor_B == 0
282
object.clrDivisor_B = 0x100
283
end if
284
end function
285
286
287
private function LZSetup_InitSuperSonicPal
288
temp0 = 0
289
290
// First Set of colors is just the regular underwater palette
291
GetPaletteEntry(1, 2, temp1)
292
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
293
temp0++
294
295
GetPaletteEntry(1, 3, temp1)
296
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
297
temp0++
298
299
GetPaletteEntry(1, 4, temp1)
300
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
301
temp0++
302
303
GetPaletteEntry(1, 5, temp1)
304
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
305
temp0++
306
307
while temp0 < 64
308
GetPaletteEntry(0, 2, temp1) // Regular color
309
GetPaletteEntry(1, 2, temp2) // Underwater color
310
311
CallFunction(LZSetup_getClrDivisor)
312
313
GetTableValue(temp1, temp0, Player_SonicSuperPal)
314
315
// Get the green in the color
316
temp2 = temp1
317
temp2 >>= 8
318
temp2 &= 0xFF
319
320
// Get the blue in the color
321
temp3 = temp1
322
temp3 &= 0xFF
323
324
// Get the red in the color
325
temp1 >>= 16
326
327
temp1 *= 0xE0
328
temp1 /= object.clrDivisor_R
329
330
temp2 *= 0xE0
331
temp2 /= object.clrDivisor_G
332
333
temp3 *= 0xE0
334
temp3 /= object.clrDivisor_B
335
336
// Max of 0xE0
337
// -> Note that this game uses the "raw" colors from the original game rather than
338
// "corrected" colors seen in many emulators
339
// With this system, the brighest a color can be is E0E0E0, with all
340
// the reds, greens, and blues having a max of 224, or E0
341
temp1 &= 0xF0
342
temp2 &= 0xF0
343
temp3 &= 0xF0
344
if temp1 > 0xE0
345
temp1 = 0xE0
346
end if
347
if temp2 > 0xE0
348
temp2 = 0xE0
349
end if
350
if temp3 > 0xE0
351
temp3 = 0xE0
352
end if
353
354
temp1 <<= 16
355
temp2 <<= 8
356
temp1 += temp2
357
temp1 += temp3
358
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
359
temp0++
360
361
// Color 2
362
GetPaletteEntry(0, 3, temp1) // Regular color
363
GetPaletteEntry(1, 3, temp2) // Underwater color
364
365
CallFunction(LZSetup_getClrDivisor)
366
367
GetTableValue(temp1, temp0, Player_SonicSuperPal)
368
369
temp2 = temp1
370
temp2 >>= 8
371
temp2 &= 0xFF
372
373
temp3 = temp1
374
temp3 &= 0xFF
375
376
temp1 >>= 16
377
378
temp1 *= 0xE8
379
temp1 /= object.clrDivisor_R
380
381
temp2 *= 0xE8
382
temp2 /= object.clrDivisor_G
383
384
temp3 *= 0xE8
385
temp3 /= object.clrDivisor_B
386
387
temp1 &= 0xF0
388
temp2 &= 0xF0
389
temp3 &= 0xF0
390
if temp1 > 0xE0
391
temp1 = 0xE0
392
end if
393
if temp2 > 0xE0
394
temp2 = 0xE0
395
end if
396
if temp3 > 0xE0
397
temp3 = 0xE0
398
end if
399
400
temp1 <<= 16
401
temp2 <<= 8
402
temp1 += temp2
403
temp1 += temp3
404
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
405
temp0++
406
407
// Color 3
408
GetPaletteEntry(0, 4, temp1) // Regular color
409
GetPaletteEntry(1, 4, temp2) // Underwater color
410
411
CallFunction(LZSetup_getClrDivisor)
412
413
GetTableValue(temp1, temp0, Player_SonicSuperPal)
414
415
temp2 = temp1
416
temp2 >>= 8
417
temp2 &= 0xFF
418
419
temp3 = temp1
420
temp3 &= 0xFF
421
422
temp1 >>= 16
423
424
temp1 *= 0xF4
425
temp1 /= object.clrDivisor_R
426
427
temp2 *= 0xF4
428
temp2 /= object.clrDivisor_G
429
430
temp3 *= 0xF4
431
temp3 /= object.clrDivisor_B
432
433
temp1 &= 0xF0
434
temp2 &= 0xF0
435
temp3 &= 0xF0
436
if temp1 > 0xE0
437
temp1 = 0xE0
438
end if
439
if temp2 > 0xE0
440
temp2 = 0xE0
441
end if
442
if temp3 > 0xE0
443
temp3 = 0xE0
444
end if
445
446
temp1 <<= 16
447
temp2 <<= 8
448
temp1 += temp2
449
temp1 += temp3
450
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
451
temp0++
452
453
// Color 4
454
GetPaletteEntry(0, 5, temp1) // Regular color
455
GetPaletteEntry(1, 5, temp2) // Underwater color
456
457
CallFunction(LZSetup_getClrDivisor)
458
459
GetTableValue(temp1, temp0, Player_SonicSuperPal)
460
temp2 = temp1
461
temp2 >>= 8
462
temp2 &= 0xFF
463
464
temp3 = temp1
465
temp3 &= 0xFF
466
467
temp1 >>= 16
468
469
temp1 *= 0x100
470
temp1 /= object.clrDivisor_R
471
472
temp2 *= 0x100
473
temp2 /= object.clrDivisor_G
474
475
temp3 *= 0x100
476
temp3 /= object.clrDivisor_B
477
478
temp1 &= 0xF0
479
temp2 &= 0xF0
480
temp3 &= 0xF0
481
if temp1 > 0xE0
482
temp1 = 0xE0
483
end if
484
if temp2 > 0xE0
485
temp2 = 0xE0
486
end if
487
if temp3 > 0xE0
488
temp3 = 0xE0
489
end if
490
491
temp1 <<= 16
492
temp2 <<= 8
493
temp1 += temp2
494
temp1 += temp3
495
SetTableValue(temp1, temp0, Player_SonicSuperAltPal)
496
temp0++
497
loop
498
end function
499
500
501
private function LZSetup_InitSuperTailsPal
502
temp0 = 0
503
504
GetPaletteEntry(1, 13, temp1)
505
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
506
temp0++
507
508
GetPaletteEntry(1, 17, temp1)
509
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
510
temp0++
511
512
GetPaletteEntry(1, 18, temp1)
513
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
514
temp0++
515
516
GetPaletteEntry(1, 16, temp1)
517
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
518
temp0++
519
520
while temp0 < 24
521
// Color 1
522
GetPaletteEntry(0, 13, temp1)
523
GetPaletteEntry(1, 13, temp2)
524
525
CallFunction(LZSetup_getClrDivisor)
526
527
GetTableValue(temp1, temp0, Player_TailsSuperPal)
528
529
temp2 = temp1
530
temp2 >>= 8
531
temp2 &= 0xFF
532
533
temp3 = temp1
534
temp3 &= 0xFF
535
536
temp1 >>= 16
537
538
temp1 *= 0xF8
539
temp1 /= object.clrDivisor_R
540
541
temp2 *= 0xF8
542
temp2 /= object.clrDivisor_G
543
544
temp3 *= 0xF8
545
temp3 /= object.clrDivisor_B
546
547
temp1 &= 0xF0
548
temp2 &= 0xF0
549
temp3 &= 0xF0
550
if temp1 > 0xE0
551
temp1 = 0xE0
552
end if
553
if temp2 > 0xE0
554
temp2 = 0xE0
555
end if
556
if temp3 > 0xE0
557
temp3 = 0xE0
558
end if
559
560
temp1 <<= 16
561
temp2 <<= 8
562
temp1 += temp2
563
temp1 += temp3
564
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
565
temp0++
566
567
// Color 2
568
GetPaletteEntry(0, 17, temp1)
569
GetPaletteEntry(1, 17, temp2)
570
571
CallFunction(LZSetup_getClrDivisor)
572
573
GetTableValue(temp1, temp0, Player_TailsSuperPal)
574
575
temp2 = temp1
576
temp2 >>= 8
577
temp2 &= 0xFF
578
579
temp3 = temp1
580
temp3 &= 0xFF
581
582
temp1 >>= 16
583
584
temp1 *= 0x100
585
temp1 /= object.clrDivisor_R
586
587
temp2 *= 0x100
588
temp2 /= object.clrDivisor_G
589
590
temp3 *= 0x100
591
temp3 /= object.clrDivisor_B
592
593
temp1 &= 0xF0
594
temp2 &= 0xF0
595
temp3 &= 0xF0
596
if temp1 > 0xE0
597
temp1 = 0xE0
598
end if
599
if temp2 > 0xE0
600
temp2 = 0xE0
601
end if
602
if temp3 > 0xE0
603
temp3 = 0xE0
604
end if
605
606
temp1 <<= 16
607
temp2 <<= 8
608
temp1 += temp2
609
temp1 += temp3
610
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
611
temp0++
612
613
// Color 3
614
GetPaletteEntry(0, 18, temp1)
615
GetPaletteEntry(1, 18, temp2)
616
617
CallFunction(LZSetup_getClrDivisor)
618
619
GetTableValue(temp1, temp0, Player_TailsSuperPal)
620
621
temp2 = temp1
622
temp2 >>= 8
623
temp2 &= 0xFF
624
625
temp3 = temp1
626
temp3 &= 0xFF
627
628
temp1 >>= 16
629
630
temp1 *= 0x100
631
temp1 /= object.clrDivisor_R
632
633
temp2 *= 0x100
634
temp2 /= object.clrDivisor_G
635
636
temp3 *= 0x100
637
temp3 /= object.clrDivisor_B
638
639
temp1 &= 0xF0
640
temp2 &= 0xF0
641
temp3 &= 0xF0
642
if temp1 > 0xE0
643
temp1 = 0xE0
644
end if
645
if temp2 > 0xE0
646
temp2 = 0xE0
647
end if
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
// Color 4
660
GetPaletteEntry(0, 16, temp1)
661
GetPaletteEntry(1, 16, temp2)
662
663
CallFunction(LZSetup_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
if temp1 > 0xE0
689
temp1 = 0xE0
690
end if
691
692
if temp2 > 0xE0
693
temp2 = 0xE0
694
end if
695
696
if temp3 > 0xE0
697
temp3 = 0xE0
698
end if
699
700
temp1 <<= 16
701
temp2 <<= 8
702
temp1 += temp2
703
temp1 += temp3
704
SetTableValue(temp1, temp0, Player_TailsSuperAltPal)
705
temp0++
706
loop
707
end function
708
709
710
private function LZSetup_InitSuperKnuxPal
711
temp0 = 0
712
713
GetPaletteEntry(1, 26, temp1)
714
SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)
715
temp0++
716
717
GetPaletteEntry(1, 27, temp1)
718
SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)
719
temp0++
720
721
GetPaletteEntry(1, 28, temp1)
722
SetTableValue(temp1, temp0, Player_KnuxSuperAltPal)
723
temp0++
724
end function
725
726
private function LZSetup_InitSuperAmyPal
727
#platform: USE_ORIGINS
728
temp0 = 0
729
GetPaletteEntry(1, 66, temp1)
730
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
731
temp0++
732
GetPaletteEntry(1, 67, temp1)
733
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
734
temp0++
735
GetPaletteEntry(1, 68, temp1)
736
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
737
temp0++
738
GetPaletteEntry(1, 64, temp1)
739
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
740
temp0++
741
GetPaletteEntry(1, 65, temp1)
742
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
743
temp0++
744
while temp0 < 30
745
temp4 = temp0
746
temp4 -= 5
747
GetTableValue(temp1, temp4, Player_AmySuperAltPal)
748
temp2 = temp1
749
temp2 >>= 8
750
temp2 &= 255
751
temp3 = temp1
752
temp3 &= 255
753
temp1 >>= 16
754
temp1 += 32
755
if temp1 > 255
756
temp1 = 255
757
end if
758
temp2 += 32
759
if temp2 > 255
760
temp2 = 255
761
end if
762
temp3 += 32
763
if temp3 > 255
764
temp3 = 255
765
end if
766
temp1 <<= 16
767
temp2 <<= 8
768
temp1 += temp2
769
temp1 += temp3
770
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
771
temp0++
772
loop
773
temp6 = 25
774
while temp0 < 50
775
temp5 = 0
776
while temp5 < 5
777
temp4 = temp6
778
temp4 += temp5
779
GetTableValue(temp1, temp4, Player_AmySuperAltPal)
780
SetTableValue(temp1, temp0, Player_AmySuperAltPal)
781
temp0++
782
temp5++
783
loop
784
temp6 -= 5
785
loop
786
#endplatform
787
end function
788
789
790
private function LZSetup_SpeedUpMusicLZ
791
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])
792
temp0 = checkResult
793
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)
794
temp0 &= checkResult
795
CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)
796
temp0 &= checkResult
797
if temp0 == false
798
switch music.currentTrack
799
case TRACK_STAGE
800
SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)
801
SwapMusicTrack("Labyrinth_F.ogg", TRACK_STAGE, MUSIC_LOOP_LZ_F, 8000)
802
break
803
804
case TRACK_INVINCIBLE
805
SetMusicTrack("Labyrinth_F.ogg", TRACK_STAGE, MUSIC_LOOP_LZ_F)
806
SwapMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F, 8000)
807
break
808
809
case TRACK_BOSS
810
case TRACK_DROWNING
811
SetMusicTrack("Labyrinth_F.ogg", TRACK_STAGE, MUSIC_LOOP_LZ_F)
812
SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)
813
break
814
815
end switch
816
else
817
stage.musicFlag = MUSICEVENT_FLAG_SPEEDUP
818
end if
819
end function
820
821
822
private function LZSetup_SlowDownMusicLZ
823
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])
824
temp0 = checkResult
825
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)
826
temp0 &= checkResult
827
CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)
828
temp0 &= checkResult
829
if temp0 == false
830
switch music.currentTrack
831
case TRACK_STAGE
832
SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)
833
SwapMusicTrack("Labyrinth.ogg", TRACK_STAGE, MUSIC_LOOP_LZ, 12500)
834
break
835
836
case TRACK_INVINCIBLE
837
SetMusicTrack("Labyrinth.ogg", TRACK_STAGE, MUSIC_LOOP_LZ)
838
SwapMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV, 12500)
839
break
840
841
case TRACK_BOSS
842
case TRACK_DROWNING
843
SetMusicTrack("Labyrinth.ogg", TRACK_STAGE, MUSIC_LOOP_LZ)
844
SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)
845
break
846
847
end switch
848
else
849
stage.musicFlag = MUSICEVENT_FLAG_SLOWDOWN
850
end if
851
end function
852
853
854
private function LZSetup_SpeedUpMusicSBZ3
855
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])
856
temp0 = checkResult
857
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)
858
temp0 &= checkResult
859
CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)
860
temp0 &= checkResult
861
if temp0 == false
862
switch music.currentTrack
863
case TRACK_STAGE
864
SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)
865
SwapMusicTrack("ScrapBrain_F.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ_F, 8000)
866
break
867
868
case TRACK_INVINCIBLE
869
SetMusicTrack("ScrapBrain_F.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ_F)
870
SwapMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F, 8000)
871
break
872
873
case TRACK_BOSS
874
case TRACK_DROWNING
875
SetMusicTrack("ScrapBrain_F.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ_F)
876
SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)
877
break
878
879
end switch
880
else
881
stage.musicFlag = MUSICEVENT_FLAG_SPEEDUP
882
end if
883
end function
884
885
886
private function LZSetup_SlowDownMusicSBZ3
887
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])
888
temp0 = checkResult
889
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)
890
temp0 &= checkResult
891
CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)
892
temp0 &= checkResult
893
if temp0 == false
894
switch music.currentTrack
895
case TRACK_STAGE
896
SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)
897
SwapMusicTrack("ScrapBrain.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ, 12500)
898
break
899
900
case TRACK_INVINCIBLE
901
SetMusicTrack("ScrapBrain.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ)
902
SwapMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV, 12500)
903
break
904
905
case TRACK_BOSS
906
case TRACK_DROWNING
907
SetMusicTrack("ScrapBrain.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ)
908
SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)
909
break
910
911
end switch
912
else
913
stage.musicFlag = MUSICEVENT_FLAG_SLOWDOWN
914
end if
915
end function
916
917
918
// ========================
919
// Events
920
// ========================
921
922
event ObjectUpdate
923
object.deformTimer++
924
if object.deformTimer > 1
925
tileLayer[0].deformationOffsetW++
926
tileLayer[1].deformationOffsetW++
927
object.deformTimer = 0
928
end if
929
930
object.paletteTimer1++
931
if object.paletteTimer1 == 3
932
object.paletteTimer1 = 0
933
RotatePalette(0, 171, 174, false)
934
RotatePalette(1, 171, 174, false)
935
end if
936
937
if object.beltPaletteTimer > 0
938
object.beltPaletteTimer--
939
else
940
object.beltPaletteIndex++
941
object.beltPaletteIndex %= 3
942
GetTableValue(object.beltPaletteTimer, object.beltPaletteIndex, LZSetup_beltPalDelayTable)
943
944
RotatePalette(0, 187, 189, LZSetup_beltDirection)
945
RotatePalette(1, 187, 189, LZSetup_beltDirection)
946
end if
947
948
// Handle Player Tile Interactions
949
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
950
temp1 = player[currentPlayer].xpos
951
temp1 >>= 16
952
953
temp2 = player[currentPlayer].ypos
954
temp2 >>= 16
955
temp2 += player[currentPlayer].collisionBottom
956
temp2--
957
958
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_INDEX)
959
960
// Check if it's a waterfall tile
961
CheckEqual(temp0, 71)
962
temp3 = checkResult
963
CheckEqual(temp0, 72)
964
temp3 |= checkResult
965
966
if temp3 == true
967
// Force unstick Knuckles, if needed
968
969
CheckEqual(player[currentPlayer].state, Player_State_GlideLeft)
970
temp3 = checkResult
971
CheckEqual(player[currentPlayer].state, Player_State_GlideRight)
972
temp3 |= checkResult
973
CheckEqual(player[currentPlayer].state, Player_State_Climb)
974
temp3 |= checkResult
975
CheckEqual(player[currentPlayer].state, Player_State_LedgePullUp)
976
temp3 |= checkResult
977
if temp3 == true
978
if player[currentPlayer].state == Player_State_GlideLeft
979
FlipSign(player[currentPlayer].xvel)
980
FlipSign(player[currentPlayer].speed)
981
end if
982
983
player[currentPlayer].state = Player_State_GlideDrop
984
player[currentPlayer].animation = ANI_GLIDING_DROP
985
end if
986
end if
987
988
if player[currentPlayer].gravity == GRAVITY_GROUND
989
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEB)
990
if temp0 == TILE_WATERSLIDE
991
player[currentPlayer].state = Player_State_WaterSlide
992
993
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_DIRECTION)
994
switch temp0
995
case FLIP_NONE
996
case FLIP_Y
997
player[currentPlayer].direction = FACING_LEFT
998
break
999
1000
case FLIP_X
1001
case FLIP_XY
1002
player[currentPlayer].direction = FACING_RIGHT
1003
break
1004
1005
end switch
1006
end if
1007
end if
1008
next
1009
1010
if player[0].state == Player_State_WaterSlide
1011
if object.waterfallLoopTimer == 0
1012
if object.playingWaterfallLoop == false
1013
PlaySfx(SfxName[Waterfall], false)
1014
StopSfx(SfxName[Waterfall Loop])
1015
object.playingWaterfallLoop = true
1016
else
1017
StopSfx(SfxName[Waterfall])
1018
PlaySfx(SfxName[Waterfall Loop], false)
1019
end if
1020
end if
1021
1022
object.waterfallLoopTimer++
1023
object.waterfallLoopTimer &= 0x3F
1024
else
1025
if object.waterfallLoopTimer != 0
1026
object.waterfallLoopTimer++
1027
object.waterfallLoopTimer &= 0x3F
1028
else
1029
object.waterfallLoopTimer = 0
1030
object.playingWaterfallLoop = false
1031
end if
1032
end if
1033
1034
if Water_flashTimer > 0
1035
Water_flashTimer--
1036
end if
1037
end event
1038
1039
1040
event ObjectDraw
1041
// Change the palette to the underwater one after the water level's Y Pos
1042
temp0 = stage.waterLevel
1043
temp0 -= screen.yoffset
1044
1045
// Enforce a minimum of 0
1046
if temp0 < 0
1047
temp0 = 0
1048
end if
1049
1050
// Enforce a maximum of the screen's vertical size
1051
if temp0 > screen.ysize
1052
temp0 = screen.ysize
1053
end if
1054
1055
// Set the above water palette from the upper part of the screen
1056
SetActivePalette(0, 0, temp0)
1057
1058
// Set the underwater palette for the bottom part of the screen
1059
if Water_flashTimer > 0
1060
// Use the lightning palette if needed
1061
SetActivePalette(2, temp0, screen.ysize)
1062
else
1063
// Otherwise, use the normal water palette
1064
SetActivePalette(1, temp0, screen.ysize)
1065
end if
1066
end event
1067
1068
1069
event ObjectStartup
1070
// If in acts 1-3, set the normal Labyrinth music
1071
if stage.actNum < 4
1072
// Set the speed up/slow down functions, too
1073
SetMusicTrack("Labyrinth.ogg", TRACK_STAGE, MUSIC_LOOP_LZ)
1074
SpeedUpMusic = LZSetup_SpeedUpMusicLZ
1075
SlowDownMusic = LZSetup_SlowDownMusicLZ
1076
else
1077
// If in "act 4" - AKA SBZ 3 - then use Scrap Brain's music instead
1078
SetMusicTrack("ScrapBrain.ogg", TRACK_STAGE, MUSIC_LOOP_SBZ)
1079
SpeedUpMusic = LZSetup_SpeedUpMusicSBZ3
1080
SlowDownMusic = LZSetup_SlowDownMusicSBZ3
1081
end if
1082
1083
// Pecky and Rocky are the inhabitants of this labyrinth
1084
animalType1 = TypeName[Pecky]
1085
animalType2 = TypeName[Rocky]
1086
1087
// Place an LZ Setup Object into the scene
1088
object[SLOT_ZONESETUP].type = TypeName[LZ Setup]
1089
object[SLOT_ZONESETUP].priority = PRIORITY_ACTIVE
1090
object[SLOT_ZONESETUP].drawOrder = 0
1091
1092
// Start the initial palette cycle stuff
1093
GetTableValue(object[SLOT_ZONESETUP].beltPaletteTimer, 0, LZSetup_beltPalDelayTable)
1094
1095
// Set stage deformation data
1096
// (FG layer properties)
1097
1098
arrayPos0 = 0
1099
CallFunction(LZSetup_SetupRippleDeform1)
1100
1101
arrayPos0 = 128
1102
CallFunction(LZSetup_SetupRippleDeform1)
1103
1104
arrayPos0 = 160
1105
CallFunction(LZSetup_SetupRippleDeform2)
1106
1107
arrayPos0 = 0x100
1108
while arrayPos0 < 576
1109
arrayPos1 = arrayPos0
1110
arrayPos1 -= 0x100
1111
stage.deformationData1[arrayPos0] = stage.deformationData1[arrayPos1]
1112
arrayPos0++
1113
loop
1114
1115
SetLayerDeformation(3, 128, 4, 0, 0, 0)
1116
1117
if stage.actNum < 4
1118
// If in acts 1-3, then only load the LZ underwater palette
1119
LoadPalette("LZ_WaterPal.act", 1, 0, 0, 256)
1120
else
1121
// SBZ3: Load not only the water palette, but also the main stage palette
1122
LoadPalette("SBZ3_Pal.act", 0, 128, 128, 192)
1123
LoadPalette("SBZ3_WaterPal.act", 1, 0, 0, 256)
1124
end if
1125
1126
// Set up Super colors
1127
CallFunction(LZSetup_InitSuperSonicPal)
1128
CallFunction(LZSetup_InitSuperTailsPal)
1129
CallFunction(LZSetup_InitSuperKnuxPal)
1130
#platform: USE_ORIGINS
1131
CallFunction(LZSetup_InitSuperAmyPal)
1132
#endplatform
1133
1134
// Load the eletric flash palette in case the player gets wet with a lightning shield
1135
LoadPalette("ElectricFlash.act", 2, 0, 0, 256)
1136
1137
// Reset the flash timer
1138
Water_flashTimer = 0
1139
1140
if options.attractMode == true
1141
if credits.screen > 0
1142
Player_attractTable = LZSetup_replay_credits_STK
1143
Player_attractTableSize = 76
1144
Player_attractDuration = 540
1145
end if
1146
1147
CallFunction(Player_SetupAttractDemo)
1148
end if
1149
end event
1150
1151
1152
// ========================
1153
// Editor Events
1154
// ========================
1155
1156
event RSDKDraw
1157
DrawSprite(0)
1158
end event
1159
1160
1161
event RSDKLoad
1162
LoadSpriteSheet("Global/Display.gif")
1163
SpriteFrame(-16, -16, 32, 32, 1, 143)
1164
1165
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
1166
end event
1167
1168