Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Menu/SoundMenu.txt
1319 views
1
//--------------Sonic CD Soundtrack Menu Script---------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.FadeValue
7
#alias Object.Value1 : Object.SelectedOption
8
#alias Object.Value2 : Object.EggmanAnimTimer
9
#alias Object.Value3 : Object.NoteOscillation
10
11
//Object[33] is MenuHeading
12
#alias Object[33].State : MenuHeading.State
13
#alias Object[33].PropertyValue : MenuHeading.Header
14
15
//Object[-1] is MenuWindow
16
#alias Object[-1].State : MenuWindow.State
17
18
// Soundtrack Options
19
#alias -1 : OST_NONE // Touching nothing on mobile
20
#alias 0 : OST_JP
21
#alias 1 : OST_US
22
23
// States
24
#alias 0 : SOUNDMENU_INITIALIZE
25
#alias 1 : SOUNDMENU_OST_SELECTION
26
#alias 2 : SOUNDMENU_OST_SELECTED
27
#alias 3 : SOUNDMENU_BACK
28
#alias 4 : SOUNDMENU_EXIT
29
#alias 5 : SOUNDMENU_RETURN_TO_TITLE
30
31
// Menu Heading States
32
#alias 1 : MENUHEADING_LEAVE_SCREEN
33
34
// Menu Heading Property Values
35
#alias 5 : MAINMENU_HEADER
36
37
// Menu Window States
38
#alias 3 : MENUWINDOW_SHRINK
39
40
// Menu Button States
41
#alias 1 : MENUBUTTON_BUTTONS_IN
42
43
// Presentation Stage
44
#alias 0 : STAGE_P_TITLE
45
46
// Global SFX
47
#alias 23 : SFX_G_MENUBUTTON
48
#alias 27 : SFX_G_SELECT
49
50
// Stage SFX
51
#alias 1 : SFX_S_BACKBUTTON
52
53
// Languages
54
#alias 0 : LANG_ENGLISH
55
#alias 1 : LANG_FRENCH
56
#alias 2 : LANG_ITALIAN
57
#alias 3 : LANG_DEUTSCH
58
#alias 4 : LANG_SPANISH
59
#alias 5 : LANG_JAPANESE
60
61
62
sub ObjectMain
63
switch Object.State
64
case SOUNDMENU_INITIALIZE
65
66
#platform: Standard
67
Object.SelectedOption = Options.Soundtrack
68
#endplatform
69
70
#platform: Mobile
71
if Options.PhysicalControls == false
72
Object.SelectedOption = OST_NONE
73
else
74
Object.SelectedOption = Options.Soundtrack
75
end if
76
#endplatform
77
78
#platform: Use_Origins
79
if Options.PhysicalControls == false
80
Object.SelectedOption = OST_NONE
81
else
82
Object.SelectedOption = Options.Soundtrack
83
end if
84
#endplatform
85
86
87
if Object.FadeValue < 256
88
Object.Alpha = Object.FadeValue
89
Object.FadeValue += 6
90
else
91
Object.FadeValue = 0
92
Object.Alpha = 255
93
Object.State = SOUNDMENU_OST_SELECTION
94
end if
95
break
96
97
case SOUNDMENU_OST_SELECTION
98
99
#platform: Standard
100
CheckResult = true
101
#endplatform
102
103
#platform: Mobile
104
CheckEqual(Options.PhysicalControls, true)
105
#endplatform
106
107
#platform: Use_Origins
108
CheckEqual(Options.PhysicalControls, true)
109
#endplatform
110
111
// 2011 Steam lacks Options.PhysicalControls, so we force it here first and the other platforms can override it
112
if CheckResult == true
113
// Physical Controls
114
if KeyPress[0].Left == true
115
Object.SelectedOption--
116
if Object.SelectedOption < OST_JP
117
Object.SelectedOption = OST_US
118
end if
119
PlaySfx(SFX_G_MENUBUTTON, false)
120
end if
121
122
if KeyPress[0].Right == true
123
Object.SelectedOption++
124
if Object.SelectedOption > OST_US
125
Object.SelectedOption = OST_JP
126
end if
127
PlaySfx(SFX_G_MENUBUTTON, false)
128
end if
129
// Enable touch controls if the screen is touched
130
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
131
if CheckResult > -1
132
#platform: Mobile
133
Options.PhysicalControls = false
134
Object.SelectedOption = OST_NONE
135
#endplatform
136
#platform: Use_Origins
137
Options.PhysicalControls = false
138
Object.SelectedOption = OST_NONE
139
#endplatform
140
end if
141
else
142
// Touch Controls
143
144
// Check if JP button is touched
145
CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)
146
TempValue3 = CheckResult
147
TempValue0 = Screen.CenterX
148
TempValue0 -= 90
149
TempValue1 = Screen.CenterX
150
TempValue1 -= 22
151
CheckTouchRect(TempValue0, 112, TempValue1, 144)
152
if CheckResult > -1
153
Object.SelectedOption = OST_JP
154
else
155
if TempValue3 < 0
156
if Object.SelectedOption == OST_JP
157
KeyPress[0].Start = true
158
end if
159
else
160
if Object.SelectedOption == OST_JP
161
Object.SelectedOption = OST_NONE
162
end if
163
end if
164
end if
165
166
// Check if US button is touched
167
TempValue0 = Screen.CenterX
168
TempValue0 += 22
169
TempValue1 = Screen.CenterX
170
TempValue1 += 90
171
CheckTouchRect(TempValue0, 112, TempValue1, 144)
172
if CheckResult > -1
173
Object.SelectedOption = OST_US
174
else
175
if TempValue3 < 0
176
if Object.SelectedOption == OST_US
177
KeyPress[0].Start = true
178
end if
179
else
180
if Object.SelectedOption == OST_US
181
Object.SelectedOption = OST_NONE
182
end if
183
end if
184
end if
185
186
CallFunction(MenuHeading_CheckTouchBack)
187
188
// Enable physical controls if a button is pressed
189
if KeyPress[0].Left == true
190
Object.SelectedOption = OST_US
191
192
#platform: Use_Origins
193
Options.PhysicalControls = true
194
#endplatform
195
#platform: Mobile
196
Options.PhysicalControls = true
197
#endplatform
198
199
end if
200
if KeyPress[0].Right == true
201
Object.SelectedOption = OST_JP
202
203
#platform: Use_Origins
204
Options.PhysicalControls = true
205
#endplatform
206
#platform: Mobile
207
Options.PhysicalControls = true
208
#endplatform
209
210
end if
211
end if
212
213
CheckResult = false
214
215
if Object.SelectedOption > OST_NONE // If a button was touched
216
if KeyPress[0].Start == true
217
CheckResult = true
218
end if
219
220
if KeyPress[0].ButtonA == true
221
CheckResult = true
222
end if
223
end if
224
225
if CheckResult == true
226
Options.Soundtrack = Object.SelectedOption
227
SaveRAM[38] = Options.Soundtrack
228
Object.State = SOUNDMENU_OST_SELECTED
229
StopMusic()
230
PlaySfx(SFX_G_SELECT, false)
231
WriteSaveRAM()
232
#platform: Use_Origins
233
game.callbackParam0 = Options.Soundtrack
234
EngineCallback(NOTIFY_SOUND_TRACK)
235
#endplatform
236
end if
237
238
if KeyPress[0].ButtonB == true
239
Object.FadeValue = 248
240
Object.State = SOUNDMENU_BACK
241
PlayStageSfx(SFX_S_BACKBUTTON, false)
242
end if
243
break
244
245
case SOUNDMENU_OST_SELECTED
246
if Object.AnimationTimer < 30
247
Object.AnimationTimer++
248
else
249
Object.AnimationTimer = 0
250
Object.State = SOUNDMENU_BACK
251
PlayMusic(Options.Soundtrack)
252
end if
253
break
254
255
case SOUNDMENU_BACK
256
#platform: Use_Origins
257
Object.FadeValue = 0
258
Object.State = SOUNDMENU_RETURN_TO_TITLE
259
break
260
#endplatform
261
// Making a fallthrough here so standalone datafiles can return to the menus as usual
262
case SOUNDMENU_EXIT
263
if Object.FadeValue > 0
264
Object.Alpha = Object.FadeValue
265
Object.FadeValue -= 8
266
else
267
// Tell the other objects the menu is being exited
268
Object.Type = TypeName[Blank Object]
269
MenuWindow.State = MENUWINDOW_SHRINK
270
//All of this is MenuButton Objects
271
Object[34].State = MENUBUTTON_BUTTONS_IN
272
Object[35].State = MENUBUTTON_BUTTONS_IN
273
Object[36].State = MENUBUTTON_BUTTONS_IN
274
Object[37].State = MENUBUTTON_BUTTONS_IN
275
Object[38].State = MENUBUTTON_BUTTONS_IN
276
Object[39].State = MENUBUTTON_BUTTONS_IN
277
Object[40].State = MENUBUTTON_BUTTONS_IN
278
Object[41].State = MENUBUTTON_BUTTONS_IN
279
Object[42].State = MENUBUTTON_BUTTONS_IN
280
//End
281
MenuHeading.State = MENUHEADING_LEAVE_SCREEN
282
MenuHeading.Header = MAINMENU_HEADER // Set the heading to "MAIN MENU"
283
end if
284
break
285
286
#platform: Use_Origins
287
case SOUNDMENU_RETURN_TO_TITLE
288
Object.FadeValue += 4
289
if Object.FadeValue == 384
290
Stage.ActiveList = PRESENTATION_STAGE
291
Stage.ListPos = STAGE_P_TITLE
292
StopMusic()
293
LoadStage()
294
end if
295
SetScreenFade(0, 0, 0, Object.FadeValue)
296
break
297
#endplatform
298
end switch
299
end sub
300
301
302
sub ObjectDraw
303
// Animate and draw Eggman
304
TempValue0 = Object.EggmanAnimTimer
305
TempValue0 >>= 5
306
DrawSpriteScreenFX(TempValue0, FX_INK, Screen.CenterX, Screen.CenterY)
307
Object.EggmanAnimTimer++
308
Object.EggmanAnimTimer &= 63
309
310
// Oscillate and draw the music notes
311
Sin(TempValue0, Object.NoteOscillation)
312
TempValue0 >>= 6
313
TempValue0 += Screen.CenterY
314
DrawSpriteScreenFX(6, FX_INK, Screen.CenterX, TempValue0)
315
Sin(TempValue0, Object.NoteOscillation)
316
TempValue0 >>= 6
317
FlipSign(TempValue0)
318
TempValue0 += Screen.CenterY
319
DrawSpriteScreenFX(7, FX_INK, Screen.CenterX, TempValue0)
320
Object.NoteOscillation += 2
321
Object.NoteOscillation &= 511
322
323
// Set up the positioning for the buttons
324
TempValue0 = Screen.CenterX
325
TempValue0 -= 56
326
TempValue1 = Screen.CenterX
327
TempValue1 += 56
328
TempValue3 = Screen.CenterY
329
TempValue3 += 8
330
331
// Draw the JP button
332
if Object.SelectedOption == OST_JP
333
TempValue2 = Object.AnimationTimer
334
TempValue2 &= 3
335
TempValue2 >>= 1
336
TempValue2 += 2
337
DrawSpriteScreenFX(TempValue2, FX_INK, TempValue0, TempValue3)
338
else
339
DrawSpriteScreenFX(3, FX_INK, TempValue0, TempValue3)
340
end if
341
342
// Draw the US button
343
if Object.SelectedOption == OST_US
344
TempValue2 = Object.AnimationTimer
345
TempValue2 &= 3
346
TempValue2 >>= 1
347
TempValue2 += 4
348
DrawSpriteScreenFX(TempValue2, FX_INK, TempValue1, TempValue3)
349
else
350
DrawSpriteScreenFX(5, FX_INK, TempValue1, TempValue3)
351
end if
352
353
// Draw the border for the soundtrack that's currently playing
354
if Options.Soundtrack == OST_JP
355
DrawSpriteScreenFX(8, FX_INK, TempValue0, TempValue3)
356
else
357
DrawSpriteScreenFX(8, FX_INK, TempValue1, TempValue3)
358
end if
359
end sub
360
361
362
sub ObjectStartup
363
switch Engine.Language
364
case LANG_ENGLISH
365
LoadSpriteSheet("Menu/MenuGfx2_EN.gif")
366
break
367
case LANG_FRENCH
368
LoadSpriteSheet("Menu/MenuGfx2_FR.gif")
369
break
370
case LANG_ITALIAN
371
LoadSpriteSheet("Menu/MenuGfx2_IT.gif")
372
break
373
case LANG_DEUTSCH
374
LoadSpriteSheet("Menu/MenuGfx2_DE.gif")
375
break
376
case LANG_SPANISH
377
LoadSpriteSheet("Menu/MenuGfx2_ES.gif")
378
break
379
case LANG_JAPANESE
380
LoadSpriteSheet("Menu/MenuGfx2_JP.gif")
381
break
382
end switch
383
384
SpriteFrame(-20, -56, 40, 40, 259, 513) // #0 - Eggman 1
385
SpriteFrame(-20, -56, 40, 40, 259, 554) // #1 - Eggman 2
386
SpriteFrame(-32, -10, 64, 21, 300, 535) // #2 - JP Selected
387
SpriteFrame(-32, -10, 64, 21, 300, 513) // #3 - JP Unselected
388
SpriteFrame(-32, -10, 64, 21, 365, 535) // #4 - US Selected
389
SpriteFrame(-32, -10, 64, 21, 365, 513) // #5 - US Unselected
390
SpriteFrame(-46, -48, 11, 19, 300, 557) // #6 - Music Notes 1
391
SpriteFrame(32, -48, 17, 16, 312, 557) // #7 - Music Notes 2
392
SpriteFrame(-35, -13, 70, 27, 430, 497) // #8 - Current Soundtrack Border
393
end sub
394
395
396
// ========================
397
// Editor Subs
398
// ========================
399
400
sub RSDKDraw
401
DrawSprite(0)
402
end sub
403
404
405
sub RSDKLoad
406
LoadSpriteSheet("Menu/MenuGfx2_EN.gif")
407
SpriteFrame(-20, -56, 40, 40, 259, 513) // #0 - Eggman 1
408
409
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
410
end sub
411
412