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/SYZ/SYZSetup.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: SYZ 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.palRotateTimer
13
private alias object.value1 : object.palRotateIndex
14
private alias object.value2 : object.rLightTimer
15
16
// Tracks
17
private alias 0 : TRACK_STAGE
18
private alias 2 : TRACK_INVINCIBLE
19
private alias 4 : TRACK_BOSS
20
21
// Reserved object slots
22
private alias 10 : SLOT_ZONESETUP
23
private alias 25 : SLOT_MUSICEVENT_CHANGE
24
25
// Music Events
26
private alias 0 : MUSICEVENT_FADETOBOSS
27
private alias 1 : MUSICEVENT_FADETOSTAGE
28
private alias 2 : MUSICEVENT_TRANSITION
29
30
private alias 0 : MUSICEVENT_FLAG_NOCHANGE
31
private alias 1 : MUSICEVENT_FLAG_SPEEDUP
32
private alias 2 : MUSICEVENT_FLAG_SLOWDOWN
33
34
// Music Loops
35
private alias 101364 : MUSIC_LOOP_SYZ // This is 100712 on the level select...
36
private alias 81128 : MUSIC_LOOP_SYZ_F
37
38
private alias 39528 : MUSIC_LOOP_INV
39
private alias 30436 : MUSIC_LOOP_INV_F
40
41
42
// ========================
43
// Function Declarations
44
// ========================
45
46
reserve function SYZSetup_SpeedUpMusic
47
reserve function SYZSetup_SlowDownMusic
48
49
50
// ========================
51
// Static Values
52
// ========================
53
54
public value SYZSetup_oscillation = 0
55
public value SYZSetup_RLightFrame = 0
56
57
58
// ========================
59
// Tables
60
// ========================
61
62
private table SYZSetup_replay_attract_S
63
0x300000, 0x3BD0000
64
0x00, 100
65
0x08, 33
66
0x38, 1
67
0x28, 19
68
0x00, 22
69
0x04, 18
70
0x30, 1
71
0x20, 2
72
0x28, 39
73
0x00, 10
74
0x08, 7
75
0x00, 13
76
0x08, 11
77
0x00, 17
78
0x08, 14
79
0x00, 20
80
0x04, 15
81
0x00, 30
82
0x38, 1
83
0x28, 11
84
0x20, 29
85
0x28, 8
86
0x20, 39
87
0x00, 7
88
0x04, 27
89
0x06, 2
90
0x02, 32
91
0x00, 14
92
0x04, 45
93
0x00, 37
94
0x08, 8
95
0x00, 20
96
0x30, 1
97
0x24, 7
98
0x04, 49
99
0x34, 1
100
0x24, 18
101
0x04, 28
102
0x00, 20
103
0x08, 9
104
0x00, 19
105
0x02, 9
106
0x32, 1
107
0x22, 5
108
0x02, 7
109
0x32, 1
110
0x22, 4
111
0x02, 5
112
0x32, 1
113
0x22, 4
114
0x02, 33
115
0x00, 73
116
0x08, 69
117
0x00, 16
118
0x04, 45
119
0x00, 62
120
0x08, 19
121
0x00, 4
122
0x04, 39
123
0x00, 36
124
0x04, 9
125
0x00, 16
126
0x08, 7
127
0x00, 7
128
0x02, 17
129
0x00, 23
130
0x08, 18
131
0x38, 1
132
0x28, 41
133
0x08, 16
134
0x00, 32
135
0x02, 14
136
0x00, 2
137
0x08, 25
138
0x00, 11
139
0x04, 9
140
0x00, 44
141
0x08, 5
142
0x00, 14
143
0x08, 45
144
0x00, 52
145
0x04, 38
146
0x34, 1
147
0x24, 5
148
0x00, 13
149
0x08, 7
150
0x00, 21
151
0x08, 8
152
end table
153
154
private table SYZSetup_replay_attract_T
155
0x300000, 0x3C10000
156
0x00, 76
157
0x08, 27
158
0x38, 1
159
0x28, 24
160
0x08, 4
161
0x00, 15
162
0x04, 16
163
0x34, 1
164
0x24, 4
165
0x20, 5
166
0x28, 30
167
0x08, 8
168
0x00, 9
169
0x08, 13
170
0x00, 12
171
0x08, 14
172
0x00, 15
173
0x08, 13
174
0x00, 15
175
0x04, 16
176
0x00, 13
177
0x08, 11
178
0x38, 1
179
0x28, 21
180
0x20, 13
181
0x24, 21
182
0x04, 38
183
0x02, 18
184
0x00, 31
185
0x04, 51
186
0x00, 9
187
0x08, 23
188
0x00, 8
189
0x34, 1
190
0x24, 30
191
0x04, 29
192
0x34, 1
193
0x24, 26
194
0x04, 29
195
0x00, 9
196
0x08, 13
197
0x00, 14
198
0x02, 13
199
0x32, 1
200
0x22, 7
201
0x02, 9
202
0x00, 69
203
0x08, 39
204
0x38, 1
205
0x28, 9
206
0x08, 28
207
0x00, 15
208
0x04, 54
209
0x00, 72
210
0x04, 7
211
0x30, 1
212
0x20, 13
213
0x00, 6
214
0x30, 1
215
0x20, 7
216
0x00, 4
217
0x30, 1
218
0x20, 5
219
0x00, 6
220
0x38, 1
221
0x28, 3
222
0x08, 9
223
0x38, 1
224
0x28, 5
225
0x08, 4
226
0x00, 2
227
0x30, 1
228
0x20, 5
229
0x00, 5
230
0x34, 1
231
0x24, 6
232
0x20, 2
233
0x00, 5
234
0x30, 1
235
0x20, 6
236
0x00, 6
237
0x30, 1
238
0x20, 3
239
0x24, 3
240
0x04, 5
241
0x30, 1
242
0x20, 7
243
0x00, 3
244
0x04, 5
245
0x30, 1
246
0x20, 7
247
0x00, 6
248
0x30, 1
249
0x20, 5
250
0x00, 4
251
0x08, 2
252
0x38, 1
253
0x28, 3
254
0x20, 2
255
0x00, 6
256
0x30, 1
257
0x20, 5
258
0x00, 7
259
0x30, 1
260
0x20, 5
261
0x00, 2
262
0x08, 8
263
0x38, 1
264
0x28, 5
265
0x08, 5
266
0x00, 7
267
0x04, 39
268
0x34, 1
269
0x24, 5
270
0x28, 3
271
0x08, 3
272
0x38, 1
273
0x28, 8
274
0x08, 26
275
0x30, 1
276
0x20, 4
277
0x24, 4
278
0x04, 3
279
0x00, 12
280
0x08, 56
281
0x00, 14
282
0x04, 37
283
0x00, 3
284
0x34, 1
285
0x24, 12
286
0x04, 14
287
0x00, 11
288
0x08, 15
289
0x38, 1
290
0x28, 15
291
0x08, 6
292
0x00, 21
293
0x04, 54
294
0x00, 21
295
0x08, 63
296
0x38, 1
297
0x28, 2
298
0x20, 17
299
0x00, 39
300
end table
301
302
private table SYZSetup_replay_attract_K
303
0x300000, 0x3BD0000
304
0x00, 25
305
0x08, 47
306
0x38, 1
307
0x28, 7
308
0x00, 27
309
0x04, 9
310
0x00, 2
311
0x04, 5
312
0x34, 1
313
0x24, 5
314
0x28, 32
315
0x08, 6
316
0x00, 30
317
0x04, 14
318
0x00, 4
319
0x08, 7
320
0x00, 18
321
0x02, 12
322
0x32, 1
323
0x22, 4
324
0x00, 21
325
0x08, 10
326
0x38, 1
327
0x28, 23
328
0x08, 5
329
0x38, 1
330
0x28, 28
331
0x08, 1
332
0x00, 16
333
0x04, 89
334
0x00, 8
335
0x08, 154
336
0x38, 1
337
0x28, 6
338
0x08, 55
339
0x00, 11
340
0x04, 18
341
0x00, 122
342
0x08, 41
343
0x00, 9
344
0x08, 13
345
0x00, 11
346
0x04, 6
347
0x00, 10
348
0x04, 11
349
0x00, 3
350
0x02, 46
351
0x00, 14
352
0x08, 27
353
0x00, 20
354
0x04, 44
355
0x34, 1
356
0x24, 26
357
0x04, 46
358
0x34, 1
359
0x24, 6
360
0x00, 5
361
0x08, 17
362
0x00, 25
363
0x04, 47
364
0x00, 11
365
0x02, 16
366
0x00, 19
367
0x04, 27
368
0x00, 30
369
0x02, 57
370
0x00, 58
371
0x02, 11
372
0x00, 27
373
0x08, 14
374
0x00, 35
375
0x30, 1
376
0x20, 17
377
0x00, 8
378
0x08, 5
379
0x38, 1
380
0x28, 40
381
0x08, 6
382
0x00, 5
383
0x30, 1
384
0x20, 6
385
0x00, 12
386
0x08, 4
387
0x00, 42
388
0x08, 11
389
0x38, 1
390
0x28, 9
391
0x08, 40
392
0x38, 1
393
0x28, 4
394
end table
395
396
private table SYZSetup_replay_credits_STK
397
0x17500000, 0xBD0000
398
0x00, 31
399
0x08, 36
400
0x00, 12
401
0x08, 38
402
0x00, 4
403
0x02, 221
404
0x00, 68
405
0x02, 91
406
0x00, 40
407
0x30, 1
408
0x20, 96
409
0x00, 3
410
0x02, 13
411
end table
412
413
414
// ========================
415
// Function Definitions
416
// ========================
417
418
private function SYZSetup_SpeedUpMusic
419
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])
420
temp0 = checkResult
421
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)
422
temp0 &= checkResult
423
CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)
424
temp0 &= checkResult
425
if temp0 == false
426
switch music.currentTrack
427
case TRACK_STAGE
428
SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)
429
SwapMusicTrack("SpringYard_F.ogg", TRACK_STAGE, MUSIC_LOOP_SYZ_F, 8000)
430
break
431
432
case TRACK_INVINCIBLE
433
SetMusicTrack("SpringYard_F.ogg", TRACK_STAGE, MUSIC_LOOP_SYZ_F)
434
SwapMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F, 8000)
435
break
436
437
case TRACK_BOSS
438
SetMusicTrack("SpringYard_F.ogg", TRACK_STAGE, MUSIC_LOOP_SYZ_F)
439
SetMusicTrack("Invincibility_F.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV_F)
440
break
441
442
end switch
443
else
444
stage.musicFlag = MUSICEVENT_FLAG_SPEEDUP
445
end if
446
end function
447
448
449
private function SYZSetup_SlowDownMusic
450
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].type, TypeName[Music Event])
451
temp0 = checkResult
452
CheckEqual(object[SLOT_MUSICEVENT_CHANGE].propertyValue, MUSICEVENT_TRANSITION)
453
temp0 &= checkResult
454
CheckEqual(stage.musicFlag, MUSICEVENT_FLAG_NOCHANGE)
455
temp0 &= checkResult
456
if temp0 == false
457
switch music.currentTrack
458
case TRACK_STAGE
459
SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)
460
SwapMusicTrack("SpringYard.ogg", TRACK_STAGE, MUSIC_LOOP_SYZ, 12500)
461
break
462
463
case TRACK_INVINCIBLE
464
SetMusicTrack("SpringYard.ogg", TRACK_STAGE, MUSIC_LOOP_SYZ)
465
SwapMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV, 12500)
466
break
467
468
case TRACK_BOSS
469
SetMusicTrack("SpringYard.ogg", TRACK_STAGE, MUSIC_LOOP_SYZ)
470
SetMusicTrack("Invincibility.ogg", TRACK_INVINCIBLE, MUSIC_LOOP_INV)
471
break
472
473
end switch
474
else
475
stage.musicFlag = MUSICEVENT_FLAG_SLOWDOWN
476
end if
477
end function
478
479
480
// ========================
481
// Events
482
// ========================
483
484
event ObjectUpdate
485
object.palRotateTimer++
486
if object.palRotateTimer == 6
487
object.palRotateTimer = 0
488
object.palRotateIndex++
489
object.palRotateIndex &= 3
490
temp0 = object.palRotateIndex
491
temp0++
492
CopyPalette(temp0, 160, 0, 160, 32)
493
end if
494
495
object.rLightTimer++
496
object.rLightTimer %= 48
497
SYZSetup_RLightFrame = object.rLightTimer
498
SYZSetup_RLightFrame >>= 3
499
500
SYZSetup_oscillation++
501
SYZSetup_oscillation %= 356
502
end event
503
504
505
event ObjectStartup
506
// Set the music track
507
SetMusicTrack("SpringYard.ogg", TRACK_STAGE, MUSIC_LOOP_SYZ)
508
509
// Also set the speed up/slow down functions
510
SpeedUpMusic = SYZSetup_SpeedUpMusic
511
SlowDownMusic = SYZSetup_SlowDownMusic
512
513
// Load colors used for the palette cycle
514
// While the majority of this game uses tables for color data, SYZ instead goes back to the v3 approach of loading colors from an external file into alternate palette banks
515
temp0 = 1 // Palette bank
516
temp1 = 0 // Start Index
517
temp2 = 32 // End Index
518
while temp0 < 5
519
LoadPalette("SYZ_PalCycle.act", temp0, 160, temp1, temp2)
520
temp0++
521
temp1 += 32
522
temp2 += 32
523
loop
524
525
// Set the animal types
526
animalType1 = TypeName[Cucky]
527
animalType2 = TypeName[Picky]
528
529
// Place an SYZ Setup Object into the scene
530
object[SLOT_ZONESETUP].type = TypeName[SYZ Setup]
531
object[SLOT_ZONESETUP].priority = PRIORITY_ACTIVE
532
533
SYZSetup_oscillation = 0
534
SYZSetup_RLightFrame = 0
535
536
if options.attractMode == true
537
switch stage.playerListPos
538
case PLAYER_SONIC_A
539
#platform: USE_ORIGINS
540
case PLAYER_AMY_A
541
#endplatform
542
if credits.screen == 0
543
Player_attractTable = SYZSetup_replay_attract_S
544
Player_attractTableSize = 178
545
Player_attractDuration = 0x708
546
else
547
Player_attractTable = SYZSetup_replay_credits_STK
548
Player_attractTableSize = 28
549
Player_attractDuration = 540
550
end if
551
break
552
553
case PLAYER_TAILS_A
554
if credits.screen == 0
555
Player_attractTable = SYZSetup_replay_attract_T
556
Player_attractTableSize = 290
557
Player_attractDuration = 1800
558
else
559
Player_attractTable = SYZSetup_replay_credits_STK
560
Player_attractTableSize = 28
561
Player_attractDuration = 540
562
end if
563
break
564
565
case PLAYER_KNUCKLES_A
566
if credits.screen == 0
567
Player_attractTable = SYZSetup_replay_attract_K
568
Player_attractTableSize = 182
569
Player_attractDuration = 1800
570
else
571
Player_attractTable = SYZSetup_replay_credits_STK
572
Player_attractTableSize = 28
573
Player_attractDuration = 540
574
end if
575
break
576
577
end switch
578
579
CallFunction(Player_SetupAttractDemo)
580
end if
581
end event
582
583
584
// ========================
585
// Editor Events
586
// ========================
587
588
event RSDKDraw
589
DrawSprite(0)
590
end event
591
592
593
event RSDKLoad
594
LoadSpriteSheet("Global/Display.gif")
595
SpriteFrame(-16, -16, 32, 32, 1, 143)
596
597
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
598
end event
599
600