Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Title/Sega.txt
1319 views
1
//--------------------Sonic CD Sega Script--------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
#alias Object.Value1 : Object.RectAlpha
8
#alias Object.Value3 : Object.Unused
9
10
// There is an Object.Value7 used by the decomp in Logo
11
// to figure out what version of the mountains display
12
// since this is the only object loaded at the start
13
14
// States
15
#alias 0 : SEGA_SETUP
16
#alias 1 : SEGA_FADEIN
17
#alias 2 : SEGA_JINGLE
18
#alias 3 : SEGA_FADEOUT
19
#alias 4 : SEGA_END
20
21
// Ink Effect Aliases
22
#alias 2 : INK_ALPHA
23
24
// Stage SFX
25
#alias 0 : SFX_S_SEGA
26
27
// Callbacks & Engine States
28
#alias 0 : CALLBACK_DISPLAYLOGOS
29
#alias 7 : CALLBACK_EXIT_SELECTED
30
31
#alias 5 : ENGINE_ENTER_HIRESMODE
32
33
// game.titleMode Aliases
34
#alias 0 : DONT_SKIP_LOGOS
35
#alias 1 : SKIP_LOGOS // this is set by HE2
36
37
// game.mainMenuMode Aliases
38
#alias 0 : MAINMENUMODE_NONE // Starts with this, but gets swapped on MenuButton
39
40
41
sub ObjectMain
42
switch Object.State
43
case SEGA_SETUP
44
// Setup not only the Object, but some other useful game values as well
45
46
ReadSaveRAM()
47
// First, restore the Soundtrack setting to what it should be
48
Options.Soundtrack = SaveRAM[38]
49
50
// Some more initialisation code follows, varies between platforms
51
52
#platform: Use_Origins
53
if game.titleMode != DONT_SKIP_LOGOS
54
55
game.titleMode = DONT_SKIP_LOGOS
56
Object.State = SEGA_END
57
58
else
59
if game.mainMenuMode != MAINMENUMODE_NONE
60
61
// If returning from another Menu (ie Soundtrack) then just skip to the end
62
// and don't play the Sega screen again
63
// -> This value isn't reset here though, it's reset a few lines down
64
65
Object.State = SEGA_END
66
67
else
68
69
// Nope, nothing special is needed, so let's just show the normal Sega splash!
70
71
Object.State = SEGA_FADEIN
72
73
end if
74
end if
75
76
Object.Timer = 480
77
#endplatform
78
79
#platform: Use_Standalone
80
// Origins has all these settings on the wrapper side of things,
81
// so this isn't needed there
82
if SaveRAM[32] == true
83
Engine.BGMVolume = SaveRAM[33]
84
Engine.SFXVolume = SaveRAM[34]
85
end if
86
Options.Soundtrack = SaveRAM[38]
87
Object.State = SEGA_FADEIN
88
Object.Timer = 384
89
90
Engine.State = ENGINE_ENTER_HIRESMODE
91
#endplatform
92
93
Object.Alpha = 255
94
Object.InkEffect = INK_ALPHA
95
96
// Start the screen off all black
97
SetScreenFade(0, 0, 0, 255)
98
99
// And move the Object to the centre of the screen
100
Object.iXPos = Screen.CenterX
101
102
#platform: Use_Origins
103
game.mainMenuMode = MAINMENUMODE_NONE
104
#endplatform
105
break
106
107
case SEGA_FADEIN
108
if Object.Timer > 0
109
// Fade in, 8 by 8
110
Object.Timer -= 8
111
else
112
if Engine.OnlineActive < 2
113
// Make sure the Engine's ready to go too before moving on just yet!
114
Object.State = SEGA_JINGLE
115
end if
116
end if
117
118
SetScreenFade(0, 0, 0, Object.Timer)
119
break
120
121
case SEGA_JINGLE
122
// Hold for a moment, to let the player bask in this wonderful screen
123
124
Object.Timer++
125
126
if Object.Timer == 160
127
// Nope that's over, off we go again
128
129
Object.Timer = 0
130
Object.State = SEGA_FADEOUT
131
end if
132
133
if Object.Timer == 2
134
// Play the SFX almost immediatly after entering this state
135
PlayStageSfx(SFX_S_SEGA, false)
136
end if
137
break
138
139
case SEGA_FADEOUT
140
// Do note - this state is kinda messed up, they forget a break at the end so
141
// this state doesn't reallly fade out
142
143
#platform: Use_Standalone
144
if Object.RectAlpha < 256
145
Object.RectAlpha += 8
146
endif
147
#endplatform
148
149
if Object.Alpha > 7
150
Object.Alpha -= 8
151
else
152
if Object.Timer == 16
153
154
#platform: Use_Standalone
155
ResetObjectEntity(Object.EntityNo, TypeName[CWLogo], 0, Object.XPos, Object.YPos)
156
Object.Unused = 96
157
#endplatform
158
159
#platform: Use_Origins
160
// this never even hits in origins and yet they changed it anyway lol
161
162
ResetObjectEntity(Object.EntityNo, TypeName[Sonic], 0, Object.XPos, Object.YPos)
163
#endplatform
164
165
Object.InkEffect = INK_ALPHA
166
Object.Alpha = 0
167
Object.Timer = 0
168
else
169
Object.Timer++
170
end if
171
end if
172
173
// No break used here so it falls through
174
// On Origins, this means the Fade Out doesn't really happen...
175
// Standalone doesn't have the following state at all though so it doesn't need to worry about the missing break
176
177
case SEGA_END
178
#platform: Use_Origins
179
// The name's a bit odd - this Object is used to skip the sequence,
180
// but it's also how the sequence ends, thanks to the missing break from above
181
182
// For simplicity here, I've just chosen to stick with "End"
183
184
// But anyway, this state just moves on with the title sequence, nothing too special
185
186
ResetObjectEntity(Object.EntityNo, TypeName[Sonic], 0, Object.XPos, Object.YPos)
187
Object.InkEffect = INK_ALPHA
188
Object.Alpha = 0
189
Object.Timer = 0
190
191
// There's even a break here, isn't that cool?
192
break
193
#endplatform
194
195
end switch
196
197
// If you really wanna i guess
198
if Engine.PlatformID == RETRO_WP7
199
if KeyPress[0].ButtonB == true
200
EngineCallback(CALLBACK_EXIT_SELECTED)
201
end if
202
end if
203
204
end sub
205
206
207
208
sub ObjectDraw
209
// First, draw the background
210
DrawRect(0, 0, Screen.XSize, Screen.YSize, 0, 0, 96, 255)
211
212
#platform: Use_Origins
213
// Using the pixel art version of the sprite
214
215
if Object.Alpha > 8
216
DrawSpriteFX(0, FX_INK, Object.XPos, Object.YPos)
217
end if
218
#endplatform
219
220
#platform: Use_Standalone
221
// Using the High-Quality version of the sprite
222
223
Object.Scale = 128
224
DrawSpriteFX(0, FX_SCALE, Object.XPos, Object.YPos)
225
226
// Draw another blue layer on top of it, to give it a blue fade
227
DrawRect(0, 0, Screen.XSize, Screen.YSize, 0, 0, 96, Object.RectAlpha)
228
#endplatform
229
230
end sub
231
232
233
sub ObjectStartup
234
235
#platform: Use_Origins
236
// Using the pixel version of the sprite
237
238
LoadSpriteSheet("Title/Title.gif")
239
SpriteFrame(-49, -16, 98, 31, 106, 1)
240
241
#endplatform
242
243
#platform: Use_Standalone
244
// Using the High-Quality version of the sprite
245
246
LoadSpriteSheet("Title/Sega.gif")
247
SpriteFrame(-255, -87, 510, 174, 1, 1)
248
#endplatform
249
250
end sub
251
252
253
// ========================
254
// Editor Subs
255
// ========================
256
257
sub RSDKDraw
258
DrawSprite(0)
259
end sub
260
261
262
sub RSDKLoad
263
LoadSpriteSheet("Title/Title.gif")
264
SpriteFrame(-49,-16,98,31,106,1)
265
266
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
267
end sub
268
269