Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/DAGarden/MenuControl.txt
1319 views
1
//----------------Sonic CD Menu Control Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Fade // Also used as a timer
7
8
// Little Planet Aliases
9
#alias Object[32].Frame : LittlePlanet.Frame
10
11
// Music Selector Aliases
12
#alias Object[33].Frame : MusicSelector.Frame
13
#alias Object[33].XPos : MusicSelector.XPos
14
#alias Object[33].State : MusicSelector.State
15
#alias Object[33].DrawOrder : MusicSelector.DrawOrder
16
#alias Object[33].Priority : MusicSelector.Priority
17
18
// Touch Buttons Aliases
19
#alias Object[35].PropertyValue : Object.Button1Value
20
#alias Object[36].PropertyValue : Object.Button2Value
21
#alias Object[37].PropertyValue : Object.Button3Value
22
23
// States
24
#alias 0 : MENUCONTROL_SETUP
25
#alias 1 : MENUCONTROL_FADE_IN
26
#alias 2 : MENUCONTROL_IDLE
27
#alias 3 : MENUCONTROL_MUSIC_CONTROLS
28
#alias 4 : MENUCONTROL_SET_MUSIC
29
#alias 5 : MENUCONTROL_TIMETRAVEL
30
#alias 6 : MENUCONTROL_EXIT
31
32
// Music Selector States
33
#alias 0 : MUSICSELECTOR_BLANK
34
#alias 1 : MUSICSELECTOR_STOP_MOVE_L
35
#alias 2 : MUSICSELECTOR_MOVE_L
36
#alias 4 : MUSICSELECTOR_MOVE_R
37
38
// Little Planet Sprite Frame Aliases
39
#alias 0 : LPFRAME_PRESENT
40
#alias 11 : LPFRAME_GOODFUTURE
41
#alias 22 : LPFRAME_BADFUTURE
42
43
// Priority
44
#alias 0 : PRIORITY_BOUNDS
45
#alias 1 : PRIORITY_ACTIVE
46
47
// Presentation Stage
48
#alias 1 : STAGE_P_MENU
49
50
// Device Type
51
#alias 1 : RETRO_MOBILE
52
53
// Function Declarations
54
#function MenuControl_ChangeTrack
55
56
57
function MenuControl_ChangeTrack
58
switch MusicSelector.Frame
59
case 0
60
SetMusicTrack("JP/R1A.ogg", 0, 142428)
61
SetMusicTrack("US/R1A.ogg", 1, 153038)
62
LittlePlanet.Frame = LPFRAME_PRESENT
63
break
64
65
case 1
66
SetMusicTrack("JP/R1C.ogg", 0, 142902)
67
SetMusicTrack("US/R1C.ogg", 1, 152346)
68
LittlePlanet.Frame = LPFRAME_GOODFUTURE
69
break
70
71
case 2
72
SetMusicTrack("JP/R1D.ogg", 0, 1)
73
SetMusicTrack("US/R1D.ogg", 1, 774998)
74
LittlePlanet.Frame = LPFRAME_BADFUTURE
75
break
76
77
case 3
78
SetMusicTrack("JP/R3A.ogg", 0, 358725)
79
SetMusicTrack("US/R3A.ogg", 1, 1)
80
LittlePlanet.Frame = LPFRAME_PRESENT
81
break
82
83
case 4
84
SetMusicTrack("JP/R3C.ogg", 0, 1)
85
SetMusicTrack("US/R3C.ogg", 1, 173494)
86
LittlePlanet.Frame = LPFRAME_GOODFUTURE
87
break
88
89
case 5
90
SetMusicTrack("JP/R3D.ogg", 0, 717648)
91
SetMusicTrack("US/R3D.ogg", 1, 1)
92
LittlePlanet.Frame = LPFRAME_BADFUTURE
93
break
94
95
case 6
96
SetMusicTrack("JP/R4A.ogg", 0, 1)
97
SetMusicTrack("US/R4A.ogg", 1, 415148)
98
LittlePlanet.Frame = LPFRAME_PRESENT
99
break
100
101
case 7
102
SetMusicTrack("JP/R4C.ogg", 0, 1)
103
SetMusicTrack("US/R4C.ogg", 1, 1)
104
LittlePlanet.Frame = LPFRAME_GOODFUTURE
105
break
106
107
case 8
108
SetMusicTrack("JP/R4D.ogg", 0, 1)
109
SetMusicTrack("US/R4D.ogg", 1, 145616)
110
LittlePlanet.Frame = LPFRAME_BADFUTURE
111
break
112
113
case 9
114
SetMusicTrack("JP/R5A.ogg", 0, 1)
115
SetMusicTrack("US/R5A.ogg", 1, 1)
116
LittlePlanet.Frame = LPFRAME_PRESENT
117
break
118
119
case 10
120
SetMusicTrack("JP/R5C.ogg", 0, 367046)
121
SetMusicTrack("US/R5C.ogg", 1, 705830)
122
LittlePlanet.Frame = LPFRAME_GOODFUTURE
123
break
124
125
case 11
126
SetMusicTrack("JP/R5D.ogg", 0, 1)
127
SetMusicTrack("US/R5D.ogg", 1, 93672)
128
LittlePlanet.Frame = LPFRAME_BADFUTURE
129
break
130
131
case 12
132
SetMusicTrack("JP/R6A.ogg", 0, 1)
133
SetMusicTrack("US/R6A.ogg", 1, 926048)
134
LittlePlanet.Frame = LPFRAME_PRESENT
135
break
136
137
case 13
138
SetMusicTrack("JP/R6C.ogg", 0, 1)
139
SetMusicTrack("US/R6C.ogg", 1, 181704)
140
LittlePlanet.Frame = LPFRAME_GOODFUTURE
141
break
142
143
case 14
144
SetMusicTrack("JP/R6D.ogg", 0, 1)
145
SetMusicTrack("US/R6D.ogg", 1, 45355)
146
LittlePlanet.Frame = LPFRAME_BADFUTURE
147
break
148
149
case 15
150
SetMusicTrack("JP/R7A.ogg", 0, 1)
151
SetMusicTrack("US/R7A.ogg", 1, 617728)
152
LittlePlanet.Frame = LPFRAME_PRESENT
153
break
154
155
case 16
156
SetMusicTrack("JP/R7C.ogg", 0, 103060)
157
SetMusicTrack("US/R7C.ogg", 1, 136670)
158
LittlePlanet.Frame = LPFRAME_GOODFUTURE
159
break
160
161
case 17
162
SetMusicTrack("JP/R7D.ogg", 0, 1)
163
SetMusicTrack("US/R7D.ogg", 1, 92324)
164
LittlePlanet.Frame = LPFRAME_BADFUTURE
165
break
166
167
case 18
168
SetMusicTrack("JP/R8A.ogg", 0, 146030)
169
SetMusicTrack("US/R8A.ogg", 1, 1)
170
LittlePlanet.Frame = LPFRAME_PRESENT
171
break
172
173
case 19
174
SetMusicTrack("JP/R8C.ogg", 0, 1)
175
SetMusicTrack("US/R8C.ogg", 1, 1)
176
LittlePlanet.Frame = LPFRAME_GOODFUTURE
177
break
178
179
case 20
180
SetMusicTrack("JP/R8D.ogg", 0, 1)
181
SetMusicTrack("US/R8D.ogg", 1, 563962)
182
LittlePlanet.Frame = LPFRAME_BADFUTURE
183
break
184
185
case 21
186
SetMusicTrack("JP/FinalBoss.ogg", 0, 1)
187
SetMusicTrack("US/FinalBoss.ogg", 1, 1)
188
LittlePlanet.Frame = LPFRAME_PRESENT
189
break
190
191
case 22
192
SetMusicTrack("JP/DAGarden.ogg", 0, 1)
193
SetMusicTrack("US/DAGarden.ogg", 1, 117382)
194
LittlePlanet.Frame = LPFRAME_PRESENT
195
break
196
197
case 23
198
SetMusicTrack("JP/GameOver.ogg", 0, 0)
199
SetMusicTrack("US/GameOver.ogg", 1, 0)
200
LittlePlanet.Frame = LPFRAME_PRESENT
201
break
202
203
case 24
204
SetMusicTrack("JP/ZoneComplete.ogg", 0, 0)
205
SetMusicTrack("US/ZoneComplete.ogg", 1, 0)
206
LittlePlanet.Frame = LPFRAME_PRESENT
207
break
208
209
case 25
210
SetMusicTrack("JP/Boss.ogg", 0, 1)
211
SetMusicTrack("US/Boss.ogg", 1, 196526)
212
LittlePlanet.Frame = LPFRAME_PRESENT
213
break
214
215
case 26
216
SetMusicTrack("JP/Invincibility.ogg", 0, 0)
217
SetMusicTrack("US/Invincibility.ogg", 1, 0)
218
LittlePlanet.Frame = LPFRAME_PRESENT
219
break
220
221
case 27
222
SetMusicTrack("JP/SpeedShoes.ogg", 0, 0)
223
SetMusicTrack("US/SpeedShoes.ogg", 1, 0)
224
LittlePlanet.Frame = LPFRAME_PRESENT
225
break
226
227
case 28
228
SetMusicTrack("JP/TitleScreen.ogg", 0, 0)
229
SetMusicTrack("US/TitleScreen.ogg", 1, 0)
230
LittlePlanet.Frame = LPFRAME_PRESENT
231
break
232
233
case 29
234
SetMusicTrack("JP/SpecialStage.ogg", 0, 1)
235
SetMusicTrack("US/SpecialStage.ogg", 1, 270972)
236
LittlePlanet.Frame = LPFRAME_PRESENT
237
break
238
239
case 30
240
SetMusicTrack("JP/TimeAttack.ogg", 0, 100512)
241
SetMusicTrack("US/DAGarden.ogg", 1, 117382)
242
LittlePlanet.Frame = LPFRAME_PRESENT
243
break
244
end switch
245
246
PlayMusic(Options.Soundtrack)
247
end function
248
249
250
sub ObjectMain
251
switch Object.State
252
case MENUCONTROL_SETUP
253
Object.State = MENUCONTROL_FADE_IN
254
Object.Fade = 384
255
SetScreenFade(0, 0, 0, 255)
256
PlayMusic(Options.Soundtrack)
257
break
258
259
case MENUCONTROL_FADE_IN
260
if Object.Fade > 0
261
Object.Fade -= 8
262
else
263
Object.State = MENUCONTROL_IDLE
264
end if
265
SetScreenFade(0, 0, 0, Object.Fade)
266
break
267
268
case MENUCONTROL_IDLE
269
#platform: Use_Standalone
270
if KeyPress[0].Start == true
271
#endplatform
272
#platform: Use_Origins
273
if KeyPress[0].ButtonB == true
274
#endplatform
275
StopMusic()
276
Object.State = MENUCONTROL_EXIT
277
end if
278
279
if KeyPress[0].ButtonA == true
280
Object.State = MENUCONTROL_MUSIC_CONTROLS
281
MusicSelector.XPos = Screen.XSize
282
MusicSelector.XPos += 96
283
MusicSelector.XPos <<= 16
284
285
MusicSelector.State = MUSICSELECTOR_STOP_MOVE_L
286
MusicSelector.DrawOrder = 5
287
MusicSelector.Priority = PRIORITY_ACTIVE
288
289
Object.Button1Value = 4
290
Object.Button2Value = 5
291
Object.Button3Value = 6
292
end if
293
break
294
295
case MENUCONTROL_MUSIC_CONTROLS
296
if MusicSelector.State == MUSICSELECTOR_BLANK
297
if KeyPress[0].Left == true
298
MusicSelector.State = MUSICSELECTOR_MOVE_L
299
end if
300
301
if KeyPress[0].Right == true
302
MusicSelector.State = MUSICSELECTOR_MOVE_R
303
end if
304
305
if KeyPress[0].ButtonA == true
306
Object.State = MENUCONTROL_SET_MUSIC
307
StopMusic()
308
end if
309
310
#platform: Use_Standalone
311
if KeyPress[0].ButtonB == true
312
#endplatform
313
#platform: Use_Origins
314
if KeyPress[0].Start == true
315
#endplatform
316
Object.State = MENUCONTROL_SET_MUSIC
317
StopMusic()
318
end if
319
320
if KeyPress[0].ButtonC == true
321
Object.State = MENUCONTROL_SET_MUSIC
322
StopMusic()
323
end if
324
end if
325
326
#platform: Use_Standalone
327
if KeyPress[0].Start == true
328
#endplatform
329
#platform: Use_Origins
330
if KeyPress[0].ButtonB == true
331
#endplatform
332
StopMusic()
333
Object.State = MENUCONTROL_EXIT
334
end if
335
break
336
337
case MENUCONTROL_SET_MUSIC
338
if Object.Fade < 288
339
Object.Fade += 8
340
else
341
MusicSelector.XPos = Screen.XSize
342
MusicSelector.XPos += 96
343
MusicSelector.XPos <<= 16
344
345
MusicSelector.State = MUSICSELECTOR_BLANK
346
MusicSelector.Priority = PRIORITY_BOUNDS
347
348
Object.Button1Value = 0
349
Object.Button2Value = 2
350
Object.Button3Value = 7
351
352
CallFunction(MenuControl_ChangeTrack)
353
Object.State++
354
end if
355
SetScreenFade(208, 255, 224, Object.Fade)
356
break
357
358
case MENUCONTROL_TIMETRAVEL
359
if Object.Fade > 0
360
Object.Fade -= 8
361
else
362
Object.State = MENUCONTROL_IDLE
363
end if
364
SetScreenFade(208, 255, 224, Object.Fade)
365
break
366
367
case MENUCONTROL_EXIT
368
if Object.Fade < 384
369
Object.Fade += 8
370
else
371
// Return to the Menu scene
372
Stage.ListPos = STAGE_P_MENU
373
LoadStage()
374
end if
375
SetScreenFade(0, 0, 0, Object.Fade)
376
break
377
end switch
378
end sub
379
380
381
sub ObjectStartup
382
SetMusicTrack("JP/DAGarden.ogg", 0, 1)
383
SetMusicTrack("US/DAGarden.ogg", 1, 117382)
384
Object[0].Type = TypeName[Menu Control]
385
Object[0].DrawOrder = 1
386
Object[0].Priority = PRIORITY_ACTIVE
387
388
#platform: Use_Origins
389
if Engine.DeviceType == RETRO_MOBILE
390
Object[34].DrawOrder = 5
391
Object[35].DrawOrder = 5
392
Object[36].DrawOrder = 5
393
Object[37].DrawOrder = 5
394
395
TempValue0 = Screen.XSize
396
TempValue0 >>= 2
397
398
TempValue1 = TempValue0
399
TempValue1 >>= 1
400
Object[34].iXPos = TempValue1
401
402
TempValue1 += TempValue0
403
Object[35].iXPos = TempValue1
404
405
TempValue1 += TempValue0
406
Object[36].iXPos = TempValue1
407
408
TempValue1 += TempValue0
409
Object[37].iXPos = TempValue1
410
else
411
Object[34].Type = TypeName[Blank Object]
412
Object[35].Type = TypeName[Blank Object]
413
Object[36].Type = TypeName[Blank Object]
414
Object[37].Type = TypeName[Blank Object]
415
end if
416
#endplatform
417
418
#platform: Use_Standalone
419
#platform: Mobile
420
// Setup all the Touch Buttons for the player to tap
421
Object[34].DrawOrder = 5
422
Object[35].DrawOrder = 5
423
Object[36].DrawOrder = 5
424
Object[37].DrawOrder = 5
425
426
TempValue0 = Screen.XSize
427
TempValue0 >>= 2
428
429
TempValue1 = TempValue0
430
TempValue1 >>= 1
431
Object[34].iXPos = TempValue1
432
433
TempValue1 += TempValue0
434
Object[35].iXPos = TempValue1
435
436
TempValue1 += TempValue0
437
Object[36].iXPos = TempValue1
438
439
TempValue1 += TempValue0
440
Object[37].iXPos = TempValue1
441
#endplatform
442
#endplatform
443
444
#platform: Use_Standalone
445
#platform: Standard
446
// Touch controls aren't needed
447
Object[34].Type = TypeName[Blank Object]
448
Object[35].Type = TypeName[Blank Object]
449
Object[36].Type = TypeName[Blank Object]
450
Object[37].Type = TypeName[Blank Object]
451
#endplatform
452
#endplatform
453
end sub
454
455
456
// ========================
457
// Editor Subs
458
// ========================
459
460
sub RSDKDraw
461
DrawSprite(0)
462
end sub
463
464
465
sub RSDKLoad
466
LoadSpriteSheet("Global/Display.gif")
467
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
468
469
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
470
end sub
471
472