Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/TouchControls.txt
1319 views
1
//----------Sonic CD DebugMode / TouchControls Script---------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Fade
7
#alias Object.Value1 : Object.PauseFade
8
#alias Object.Value2 : Object.PauseXPos
9
#alias Object.Value3 : Object.AButtonXPos
10
#alias Object.Value4 : Object.DPadXPos
11
#alias Object.Value6 : Object.HelperSprite
12
#alias Object.Rotation : Object.CurrentSelection
13
14
// Ink Effects
15
#alias 2 : INK_ALPHA
16
17
// Player
18
#alias 1 : PLAYER_TAILS_A
19
20
// Control Mode
21
#alias 0 : CONTROLMODE_NORMAL
22
23
// Priority
24
#alias 1 : PRIORITY_ACTIVE
25
#alias 4 : PRIORITY_BOUNDS_DESTROY
26
27
// Function declarations
28
#function DebugMode_ChangeItem
29
30
function DebugMode_ChangeItem
31
switch Object.CurrentSelection
32
case 0
33
case 1
34
case 2
35
case 3
36
case 4
37
case 5
38
case 6
39
case 7
40
case 8
41
case 9
42
case 10
43
case 11
44
case 12
45
case 13
46
case 14
47
case 15
48
case 16
49
case 17
50
case 18
51
case 19
52
case 20
53
case 21
54
case 22
55
case 23
56
case 24
57
case 25
58
Object.Frame = Object.CurrentSelection
59
Object.HelperSprite = 0
60
break
61
62
case 26
63
Object.Frame = 26
64
Object.HelperSprite = 27
65
break
66
67
case 27
68
Object.Frame = 28
69
Object.HelperSprite = 29
70
break
71
end switch
72
end function
73
74
75
sub ObjectMain
76
// a bit messy, isn't it? blame mobile version for not having debug mode :)
77
#platform: Standard
78
TempValue0 = false
79
if KeyDown[1].Left == true
80
Player.XPos -= Player.YVelocity
81
TempValue0 = true
82
end if
83
84
if KeyDown[1].Right == true
85
Player.XPos += Player.YVelocity
86
TempValue0 = true
87
end if
88
89
if KeyDown[1].Up == true
90
Player.YPos -= Player.YVelocity
91
TempValue0 = true
92
end if
93
94
if KeyDown[1].Down == true
95
Player.YPos += Player.YVelocity
96
TempValue0 = true
97
end if
98
99
if TempValue0 == true
100
Player.YVelocity += 0xC00
101
if Player.YVelocity > 0x100000
102
Player.YVelocity = 0x100000
103
end if
104
else
105
Player.YVelocity = 0
106
end if
107
#endplatform
108
109
if KeyPress[1].ButtonB == true
110
#platform: Standard
111
Object.HelperSprite = 0
112
Object.Type = TypeName[Player Object]
113
// THEY #FIXED HIM!!!
114
if Stage.PlayerListPos == PLAYER_TAILS_A // PLAYER_TAILS in origins
115
Object[+1].Type = TypeName[Tails Object]
116
end if
117
Player.Speed = 0
118
Player.Rotation = 0
119
Player.XVelocity = 0
120
Player.YVelocity = 0
121
#endplatform
122
123
#platform: Use_Origins
124
Player.State = Player_State_Air_NoDropDash
125
#endplatform
126
127
#platform: Use_Standalone
128
#platform: Standard
129
Player.State = Player_State_Air
130
#endplatform
131
#endplatform
132
133
#platform: Standard
134
Player.Animation = ANI_WALKING
135
Player.AnimationSpeed = 0
136
Player.Frame = 0
137
138
Player.ControlMode = CONTROLMODE_NORMAL
139
Player.ObjectInteraction = true
140
#endplatform
141
else
142
if KeyPress[0].ButtonA == true
143
#platform: Standard
144
Object.CurrentSelection++
145
#endplatform
146
147
#platform: Use_Origins
148
// These two checks were introduced in Origins 1.0.4, to prevent the player from spawning Coin Monitors in Debug Mode
149
if Object.CurrentSelection == 5
150
Object.CurrentSelection++
151
end if
152
153
if Object.CurrentSelection == 7
154
Object.CurrentSelection++
155
end if
156
#endplatform
157
#platform: Standard
158
if Object.CurrentSelection > 27
159
Object.CurrentSelection = 0
160
end if
161
CallFunction(DebugMode_ChangeItem)
162
#endplatform
163
end if
164
165
if KeyDown[0].ButtonA == true
166
if KeyPress[0].ButtonC == true
167
#platform: Standard
168
Object.CurrentSelection--
169
#endplatform
170
171
#platform: Use_Origins
172
// Similarly to above, this part's also new to Origins 1.0.4 and prevents coin inflation
173
if Object.CurrentSelection == 5
174
Object.CurrentSelection--
175
end if
176
177
if Object.CurrentSelection == 7
178
Object.CurrentSelection--
179
end if
180
#endplatform
181
#platform: Standard
182
if Object.CurrentSelection < 0
183
Object.CurrentSelection = 27
184
end if
185
CallFunction(DebugMode_ChangeItem)
186
#endplatform
187
end if
188
else
189
#platform: Standard
190
if KeyPress[0].ButtonC == true
191
switch Object.CurrentSelection
192
case 0
193
CreateTempObject(TypeName[Ring], 0, Player.XPos, Player.YPos)
194
Object[TempObjectPos].DrawOrder = 4
195
break
196
197
case 1
198
case 2
199
case 3
200
case 4
201
case 5
202
case 6
203
case 7
204
case 8
205
CreateTempObject(TypeName[Monitor], Object.CurrentSelection, Player.XPos, Player.YPos)
206
break
207
208
case 9
209
case 10
210
case 11
211
case 12
212
case 13
213
case 14
214
case 15
215
case 16
216
TempValue0 = Object.CurrentSelection
217
TempValue0 -= 9
218
CreateTempObject(TypeName[Red Spring], TempValue0, Player.XPos, Player.YPos)
219
break
220
221
case 17
222
case 18
223
case 19
224
case 20
225
case 21
226
case 22
227
case 23
228
case 24
229
TempValue0 = Object.CurrentSelection
230
TempValue0 -= 17
231
CreateTempObject(TypeName[Yellow Spring], TempValue0, Player.XPos, Player.YPos)
232
break
233
234
case 25
235
CreateTempObject(TypeName[Lamp Post], 0, Player.XPos, Player.YPos)
236
break
237
238
case 26
239
CreateTempObject(TypeName[Future Post], 0, Player.XPos, Player.YPos)
240
break
241
242
case 27
243
CreateTempObject(TypeName[Past Post], 0, Player.XPos, Player.YPos)
244
break
245
end switch
246
247
Object[TempObjectPos].Priority = PRIORITY_BOUNDS_DESTROY
248
end if
249
#endplatform
250
end if
251
end if
252
end sub
253
254
255
sub ObjectDraw
256
257
#platform: Standard
258
DrawSpriteXY(Object.Frame, Player.XPos, Player.YPos)
259
260
if Object.HelperSprite > 0
261
DrawSpriteXY(Object.HelperSprite, Player.XPos, Player.YPos)
262
end if
263
#endplatform
264
265
#platform: Mobile
266
if Options.TouchControls == false
267
TempValue0 = -1
268
else
269
TempValue0 = Player.ControlMode
270
end if
271
272
if TempValue0 == false
273
if Stage.State != STAGE_PAUSED
274
if Object.Fade < 160
275
Object.Fade += 4
276
Object.PauseFade = Object.Fade
277
Object.PauseFade <<= 1
278
end if
279
280
Object.Alpha = Object.Fade
281
DrawSpriteScreenFX(0, FX_INK, Object.DPadXPos, 160)
282
283
if Player.Left == true
284
Object.Alpha = 160
285
DrawSpriteScreenFX(7, FX_INK, Object.DPadXPos, 160)
286
else
287
Object.Alpha = Object.Fade
288
DrawSpriteScreenFX(3, FX_INK, Object.DPadXPos, 160)
289
end if
290
291
if Player.Down == true
292
Object.Alpha = 160
293
DrawSpriteScreenFX(6, FX_INK, Object.DPadXPos, 160)
294
else
295
Object.Alpha = Object.Fade
296
DrawSpriteScreenFX(2, FX_INK, Object.DPadXPos, 160)
297
end if
298
299
if Player.Right == true
300
Object.Alpha = 160
301
DrawSpriteScreenFX(8, FX_INK, Object.DPadXPos, 160)
302
else
303
Object.Alpha = Object.Fade
304
DrawSpriteScreenFX(4, FX_INK, Object.DPadXPos, 160)
305
end if
306
307
if Player.Up == true
308
Object.Alpha = 160
309
DrawSpriteScreenFX(5, FX_INK, Object.DPadXPos, 160)
310
else
311
Object.Alpha = Object.Fade
312
DrawSpriteScreenFX(1, FX_INK, Object.DPadXPos, 160)
313
end if
314
315
if Player.JumpHold == true
316
Object.Alpha = 160
317
DrawSpriteScreenFX(10, FX_INK, Object.AButtonXPos, 176)
318
else
319
Object.Alpha = Object.Fade
320
DrawSpriteScreenFX(9, FX_INK, Object.AButtonXPos, 176)
321
end if
322
else
323
Object.Fade = 0
324
end if
325
326
if Object.PauseFade < 256
327
Object.Alpha = Object.PauseFade
328
DrawSpriteScreenFX(11, FX_INK, Object.PauseXPos, 8)
329
else
330
DrawSpriteScreenXY(11, Object.PauseXPos, 8)
331
end if
332
else
333
if Object.Fade > 0
334
Object.Fade -= 4
335
Object.PauseFade -= 8
336
end if
337
338
Object.Alpha = Object.Fade
339
if Object.Alpha > 0
340
DrawSpriteScreenFX(0, FX_INK, Object.DPadXPos, 160)
341
DrawSpriteScreenFX(1, FX_INK, Object.DPadXPos, 160)
342
DrawSpriteScreenFX(4, FX_INK, Object.DPadXPos, 160)
343
DrawSpriteScreenFX(2, FX_INK, Object.DPadXPos, 160)
344
DrawSpriteScreenFX(3, FX_INK, Object.DPadXPos, 160)
345
DrawSpriteScreenFX(9, FX_INK, Object.AButtonXPos, 176)
346
end if
347
348
if Object.PauseFade < 0
349
Object.Alpha = 0
350
else
351
Object.Alpha = Object.PauseFade
352
end if
353
354
if Object.PauseFade < 256
355
Object.Alpha = Object.PauseFade
356
DrawSpriteScreenFX(11, FX_INK, Object.PauseXPos, 8)
357
else
358
DrawSpriteScreenXY(11, Object.PauseXPos, 8)
359
end if
360
end if
361
#endplatform
362
end sub
363
364
365
sub ObjectStartup
366
#platform: Standard
367
LoadSpriteSheet("Global/Items.gif")
368
369
SpriteFrame(-8, -8, 16, 16, 1, 1) // #0 - Ring
370
// Monitors
371
SpriteFrame(-16, -16, 32, 32, 18, 1) // #1 - Ring Monitor
372
SpriteFrame(-16, -16, 32, 32, 18, 34) // #2 - Shield Monitor
373
SpriteFrame(-16, -16, 32, 32, 18, 67) // #3 - Invincibility Monitor
374
SpriteFrame(-16, -16, 32, 32, 18, 100) // #4 - Power Sneakers Monitor
375
376
#endplatform
377
378
#platform: Use_Origins
379
CheckEqual(game.coinMode, false)
380
#endplatform
381
382
#platform: Use_Standalone
383
CheckResult = true
384
#endplatform
385
386
#platform: Standard
387
// Originally game.coinMode == false, adapted for compatibility reasons
388
if CheckResult == true
389
SpriteFrame(-16, -16, 32, 32, 18, 133) // #5 - Sonic Monitor
390
SpriteFrame(-16, -16, 32, 32, 18, 166) // #6 - Time Monitor
391
SpriteFrame(-16, -16, 32, 32, 51, 100) // #7 - Tails Monitor
392
SpriteFrame(-16, -16, 32, 32, 51, 133) // #8 - S Monitor
393
else
394
SpriteFrame(-16, -16, 32, 32, 84, 200) // #5 - Coin Monitor
395
SpriteFrame(-16, -16, 32, 32, 18, 166) // #6 - Time Monitor
396
SpriteFrame(-16, -16, 32, 32, 84, 200) // #7 - Coin Monitor
397
SpriteFrame(-16, -16, 32, 32, 51, 133) // #8 - S Monitor
398
end if
399
400
// Springs
401
SpriteFrame(-16, -8, 32, 16, 84, 1) // #9 - Red Spring facing up
402
SpriteFrame(-8, -16, 16, 32, 117, 1) // #10 - Red Spring facing right
403
SpriteFrame(-8, -16, 16, 32, 175, 1) // #11 - Red Spring facing left
404
SpriteFrame(-16, -8, 32, 16, 84, 59) // #12 - Red Spring facing down
405
SpriteFrame(-16, -16, 32, 32, 84, 117) // #13 - Red Spring facing diagonal right
406
SpriteFrame(-16, -16, 32, 32, 117, 165) // #14 - Red Spring facing diagonal left
407
SpriteFrame(-16, -16, 32, 32, 84, 117) // #15 - Red Spring facing diagonal right 2
408
SpriteFrame(-16, -16, 32, 32, 117, 165) // #16 - Red Spring facing diagonal left 2
409
410
// Springs
411
SpriteFrame(-16, -8, 32, 16, 84, 183) // #17 - Yellow Spring facing up
412
SpriteFrame(-8, -16, 16, 32, 215, 116) // #18 - Yellow Spring facing right
413
SpriteFrame(-8, -16, 16, 32, 232, 116) // #19 - Yellow Spring facing left
414
SpriteFrame(-16, -8, 32, 16, 184, 239) // #20 - Yellow Spring facing down
415
SpriteFrame(-16, -16, 32, 32, 183, 165) // #21 - Yellow Spring facing diagonal right
416
SpriteFrame(-16, -16, 32, 32, 216, 182) // #22 - Yellow Spring facing diagonal left
417
SpriteFrame(-16, -16, 32, 32, 183, 165) // #23 - Yellow Spring facing diagonal right 2
418
SpriteFrame(-16, -16, 32, 32, 216, 182) // #24 - Yellow Spring facing diagonal left 2
419
420
SpriteFrame(-8, -40, 16, 64, 1, 137) // #25 - Lamp Post
421
SpriteFrame(-8, -24, 16, 48, 35, 204) // #26 - Time Post Body
422
SpriteFrame(-16, -40, 32, 16, 52, 239) // #27 - Future Post
423
SpriteFrame(-8, -24, 16, 48, 35, 204) // #28 - Time Post Body
424
SpriteFrame(-16, -40, 32, 16, 118, 239) // #29 - Past Post
425
#endplatform
426
427
#platform: Mobile
428
if Options.AttractMode == false
429
LoadSpriteSheet("Global/DPad.gif")
430
431
Object[25].Type = TypeName[Debug Mode]
432
Object[25].Priority = PRIORITY_ACTIVE
433
Object[25].DrawOrder = 6
434
Object[25].InkEffect = INK_ALPHA
435
Object[25].Fade = 0
436
Object[25].PauseFade = 0
437
Object[25].PauseXPos = Screen.XSize
438
Object[25].PauseXPos -= 68
439
Object[25].AButtonXPos = Screen.XSize
440
441
if Engine.PlatformID == RETRO_WP7
442
Object[25].AButtonXPos -= 69
443
Object[25].DPadXPos = 24
444
Options.DPadX = 56
445
else
446
Object[25].AButtonXPos -= 61
447
Object[25].DPadXPos = 16
448
Options.DPadX = 48
449
end if
450
451
// This script is only ever used in normal stages, Special Stages have their own TouchControls script
452
// and yet, this check exists anyway...
453
if Stage.ActiveList == SPECIAL_STAGE
454
Object[25].PauseXPos += 42
455
end if
456
457
SpriteFrame(0, 0, 64, 64, 0, 64) // #0 - D-Pad
458
SpriteFrame(26, 0, 12, 25, 26, 0) // #1 - Up
459
SpriteFrame(26, 38, 12, 26, 26, 38) // #2 - Down
460
SpriteFrame(0, 25, 26, 13, 0, 25) // #3 - Left
461
SpriteFrame(38, 25, 26, 13, 38, 25) // #4 - Right
462
SpriteFrame(26, 0, 12, 25, 116, 64) // #5 - Pressed Up
463
SpriteFrame(26, 38, 12, 26, 116, 102) // #6 - Pressed Down
464
SpriteFrame(0, 25, 26, 13, 89, 101) // #7 - Pressed Left
465
SpriteFrame(38, 25, 26, 13, 89, 115) // #8 - Presset Right
466
SpriteFrame(0, 0, 48, 48, 65, 0) // #9 - A Button
467
SpriteFrame(0, 0, 48, 48, 65, 49) // #10 - Pressed A Button
468
SpriteFrame(0, 0, 16, 16, 72, 111) // #11 - Pause
469
end if
470
#endplatform
471
end sub
472
473
474
// ========================
475
// Editor Subs
476
// ========================
477
478
sub RSDKDraw
479
DrawSprite(0)
480
end sub
481
482
483
sub RSDKLoad
484
LoadSpriteSheet("Global/Items.gif")
485
SpriteFrame(-8, -8, 16, 16, 1, 1) // #0 - Ring
486
487
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
488
end sub
489
490