Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/AttractMode.txt
1319 views
1
//----------------Sonic CD Attract Mode Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value1 : Object.DemoTime
7
#alias Object.Value2 : Object.DemoLength
8
#alias Object.Value3 : Object.DemoInput
9
10
// States
11
#alias 0 : ATTRACTMODE_SETUP
12
#alias 1 : ATTRACTMODE_HANDLE_INPUT
13
14
// Control Modes
15
#alias 0 : CONTROLMODE_NORMAL
16
17
// Demo ID Aliases
18
#alias 0 : DEMO_R11A
19
#alias 1 : DEMO_SS1
20
#alias 2 : DEMO_R43C
21
#alias 3 : DEMO_SS6
22
#alias 4 : DEMO_R82A
23
24
// Priority
25
#alias 1 : PRIORITY_ACTIVE
26
27
// Engine & CallBacks
28
#alias 2 : MESSAGE_LOSTFOCUS
29
30
// Player Aliases
31
#alias 0 : PLAYER_SONIC_A
32
#alias 1 : PLAYER_TAILS_A
33
34
// Presentation Stages
35
#alias 0 : STAGE_P_TITLE
36
37
// Text Info type
38
#alias 0 : TEXTINFO_TEXTDATA
39
#alias 1 : TEXTINFO_TEXTSIZE
40
41
42
sub ObjectMain
43
switch Object.State
44
case ATTRACTMODE_SETUP
45
if Player.ControlMode == CONTROLMODE_NORMAL
46
Object.State++
47
Object.DemoInput = Object.DemoLength
48
Object.DemoInput -= 60
49
end if
50
break
51
52
case ATTRACTMODE_HANDLE_INPUT
53
54
// Get the inputs for the current frame
55
GetTextInfo(TempValue0, MENU_1, TEXTINFO_TEXTDATA, 0, Object.DemoTime)
56
57
// Set all the input stuff as needed
58
GetBit(Player.Up, TempValue0, 0)
59
GetBit(Player.Down, TempValue0, 1)
60
GetBit(Player.Left, TempValue0, 2)
61
GetBit(Player.Right, TempValue0, 3)
62
GetBit(Player.JumpPress, TempValue0, 4)
63
GetBit(Player.JumpHold, TempValue0, 5)
64
65
if Object.DemoTime < Object.DemoLength
66
Object.DemoTime++
67
else
68
StopMusic()
69
Options.AttractMode = false
70
Stage.ActiveList = PRESENTATION_STAGE
71
Stage.ListPos = STAGE_P_TITLE
72
Transporter_Destroyed = false
73
MetalSonic_Destroyed = false
74
Good_Future = false
75
LoadStage()
76
LampPost.Check = 0
77
78
Engine.HapticsEnabled = SaveRAM[40]
79
end if
80
81
if Object.DemoTime >= Object.DemoInput
82
// Fade out
83
84
Music.Volume -= 2
85
86
Screen.CameraEnabled = false
87
88
TempValue0 = Object.DemoTime
89
TempValue0 -= Object.DemoInput
90
TempValue0 <<= 3
91
if TempValue0 > 255
92
TempValue0 = 255
93
end if
94
95
SetScreenFade(0, 0, 0, TempValue0)
96
else
97
if KeyPress[0].ButtonA == true
98
Object.DemoTime = Object.DemoInput
99
end if
100
101
if KeyPress[0].ButtonB == true
102
Object.DemoTime = Object.DemoInput
103
end if
104
105
if KeyPress[0].ButtonC == true
106
Object.DemoTime = Object.DemoInput
107
end if
108
109
if KeyPress[0].AnyStart == true
110
Object.DemoTime = Object.DemoInput
111
end if
112
113
#platform: Mobile
114
CheckTouchRect(0, 0, Screen.XSize, 240)
115
if CheckResult > -1
116
Object.DemoTime = Object.DemoInput
117
end if
118
119
if Engine.Message == MESSAGE_LOSTFOCUS
120
Object.DemoTime = Object.DemoInput
121
end if
122
#endplatform
123
124
end if
125
break
126
end switch
127
128
end sub
129
130
131
sub ObjectDraw
132
133
if Object[20].Type != TypeName[Title Card]
134
Object.AnimationTimer++
135
Object.AnimationTimer %= 60
136
137
if Object.AnimationTimer > 29
138
// Code would be here, presumably?
139
// This entire ObjectDraw sub exists, but nothing's actually drawn...
140
141
// A fit guess would be the "Demo" sprite from below, but since it doesn't show up in the original game
142
// it may have been removed for accuracy reasons
143
end if
144
end if
145
146
end sub
147
148
149
sub ObjectStartup
150
151
// This Object never draws anything anyway, but load a sheet and set up Sprite Frames anyway
152
if Stage.ActiveList == REGULAR_STAGE
153
// Load the corresponding Display sheet for the current character
154
if Stage.PlayerListPos == PLAYER_SONIC_A
155
LoadSpriteSheet("Global/Display.gif")
156
end if
157
if Stage.PlayerListPos == PLAYER_TAILS_A
158
LoadSpriteSheet("Global/Display_t.gif")
159
end if
160
#platform: Use_Origins
161
if Stage.PlayerListPos == PLAYER_KNUCKLES
162
LoadSpriteSheet("Global/Display_k.gif")
163
end if
164
if Stage.PlayerListPos == PLAYER_AMY
165
LoadSpriteSheet("Global/Display_a.gif")
166
end if
167
#endplatform
168
169
// "Demo" - unused
170
SpriteFrame(-17, -5, 34, 11, 1, 176)
171
else
172
LoadSpriteSheet("Special/Objects.gif")
173
174
// "Demo" - unused
175
SpriteFrame(-17, -5, 34, 11, 83, 168)
176
end if
177
178
ArrayPos0 = 32
179
while ArrayPos0 < 1056
180
if Object[ArrayPos0].Type == TypeName[Attract Mode]
181
if Options.AttractMode == true
182
183
// Make the Object always active, regardless of where it's located in the stage
184
Object[ArrayPos0].Priority = PRIORITY_ACTIVE
185
186
// Give it a high Draw Order as well... though nothing's ever really drawn by this Object
187
Object[ArrayPos0].DrawOrder = 6
188
189
switch Object[ArrayPos0].PropertyValue
190
case DEMO_R11A
191
// Palmtree Panic Act 1, Present
192
193
LoadTextFile(MENU_1, "Data/Game/Demos/Key11a.bin", 0)
194
LampPost.Check = 0
195
break
196
197
case DEMO_SS1
198
// Special Stage 1
199
200
LoadTextFile(MENU_1, "Data/Game/Demos/Special1.bin", 0)
201
LampPost.Check = 0
202
break
203
204
case DEMO_R43C
205
// Tidal Tempest 3, Good Future
206
207
LoadTextFile(MENU_1, "Data/Game/Demos/Key43c.bin", 0)
208
209
// Move the Player to where the Attract Mode object is placed
210
Player.XPos = Object[ArrayPos0].XPos
211
Player.YPos = Object[ArrayPos0].YPos
212
213
LampPost.Check = 33
214
break
215
216
case DEMO_SS6
217
// Special Stage 6
218
219
LoadTextFile(MENU_1, "Data/Game/Demos/Special6.bin", 0)
220
LampPost.Check = 0
221
break
222
223
case DEMO_R82A
224
// Metallic Madness 2, Present
225
226
LoadTextFile(MENU_1, "Data/Game/Demos/Key82a.bin", 0)
227
228
// Move the Player to where the Attract Mode object's placed
229
Player.XPos = Object[ArrayPos0].XPos
230
Player.YPos = Object[ArrayPos0].YPos
231
232
LampPost.Check = 33
233
break
234
235
end switch
236
237
// Get how long the Demo is, and store it in the Attract Mode Object
238
GetTextInfo(Object[ArrayPos0].DemoLength, MENU_1, TEXTINFO_TEXTSIZE, 0, 0)
239
240
else
241
242
// If Attract Mode isn't active, then remove the Object
243
Object[ArrayPos0].Type = TypeName[Blank Object]
244
245
end if
246
end if
247
248
ArrayPos0++
249
loop
250
end sub
251
252
253
// ========================
254
// Editor Subs
255
// ========================
256
257
sub RSDKEdit
258
if Editor.ReturnVariable == true
259
switch Editor.VariableID
260
case EDIT_VAR_PROPVAL // Property Value
261
case 0 // DemoID
262
CheckResult = Object.PropertyValue
263
break
264
end switch
265
else
266
switch Editor.VariableID
267
case EDIT_VAR_PROPVAL // Property Value
268
case 0 // DemoID
269
Object.PropertyValue = Editor.VariableValue
270
break
271
end switch
272
end if
273
end sub
274
275
276
sub RSDKDraw
277
DrawSprite(0)
278
end sub
279
280
281
sub RSDKLoad
282
LoadSpriteSheet("Global/Display.gif")
283
SpriteFrame(-17, -5, 34, 11, 1, 176) // "Demo"
284
285
AddEditorVariable("DemoID")
286
SetActiveVariable("DemoID")
287
AddEnumVariable("Palmtree Panic 1", 0)
288
AddEnumVariable("Special Zone 1", 1)
289
AddEnumVariable("Tidal Tempest 3", 2)
290
AddEnumVariable("Special Zone 6", 3)
291
AddEnumVariable("Metallic Madness 2", 4)
292
end sub
293
294