Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/Title/Start.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Start Message Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.timer
13
private alias object.value4 : object.attractTimer
14
private alias object.value5 : object.menuSelection
15
16
// States
17
private alias 0 : START_AWAITACTION
18
private alias 1 : START_NEWGAME // State 1 is this in Standalone..
19
private alias 1 : START_FLASHPRESSBUTTON // ..but it's this in Origins
20
private alias 2 : START_LEVELSELECT
21
private alias 3 : START_CONTINUESCREEN
22
private alias 4 : START_ATTRACTMODE
23
private alias 5 : START_ORIGINSMENU
24
private alias 6 : START_FLASHOPTION
25
private alias 7 : START_1PSENDCALLBACK
26
private alias 8 : START_1PWAITFORCHARSELECT
27
private alias 9 : START_ORIGINSSTARTGAME
28
private alias 10 : START_2PSENDCALLBACK
29
30
// Player List Pos Aliases
31
private alias 3 : PLAYER_SONIC_TAILS_A
32
private alias 5 : PLAYER_AMY_A
33
private alias 6 : PLAYER_AMY_TAILS_A
34
35
// Origins Menu Selection Aliases
36
// (The in-game menu on the title screen, to clarify)
37
private alias 0 : MENU_1PLAYER
38
private alias 1 : MENU_2PLAYERVS
39
40
41
// ========================
42
// Events
43
// ========================
44
45
event ObjectUpdate
46
// In Origins there's a whole new menu on the title screen and that's done in here but there's also the old Standalone script
47
// here with a lot of changes between the two, so do pardon the dust...
48
#platform: USE_ORIGINS
49
CheckTouchRect(0, 0, screen.xsize, screen.ysize) // Funny this is here since mouse input is mapped to buttonA in Origins
50
if keyPress[0].buttonB == true
51
checkResult = 1
52
end if
53
54
if keyPress[0].start == true
55
checkResult = 2
56
end if
57
58
if keyPress[0].buttonA == true
59
checkResult = 2
60
end if
61
62
if input.pressButton == true
63
checkResult = 2
64
end if
65
#endplatform
66
67
switch object.state
68
case START_AWAITACTION
69
#platform: USE_STANDALONE
70
CheckTouchRect(0, 0, screen.xsize, screen.ysize)
71
if keyPress[0].start == true
72
checkResult = true
73
end if
74
75
if keyPress[0].buttonA == true
76
checkResult = true
77
end if
78
79
if keyPress[0].buttonB == true
80
checkResult = true
81
end if
82
83
if keyPress[0].buttonC == true
84
checkResult = true
85
end if
86
#endplatform
87
88
#platform: USE_ORIGINS
89
game.continueFlag = false
90
#endplatform
91
92
if checkResult > -1
93
#platform: USE_STANDALONE
94
if options.stageSelectFlag == true
95
if checkResult > 0
96
object.state = START_LEVELSELECT
97
else
98
object.state = START_NEWGAME
99
end if
100
else
101
object.state = START_NEWGAME
102
end if
103
104
PlaySfx(SfxName[Menu Select], false)
105
StopMusic()
106
#endplatform
107
108
#platform: USE_ORIGINS
109
if options.stageSelectFlag == true
110
object.state = START_LEVELSELECT
111
StopMusic()
112
PlaySfx(SfxName[Menu Select], false)
113
else
114
if keyPress[0].buttonB == true
115
CallNativeFunction2(NotifyCallback, NOTIFY_BACK_TO_MAINMENU, 0)
116
else
117
object.state = START_FLASHPRESSBUTTON
118
end if
119
end if
120
#endplatform
121
else
122
object.attractTimer++
123
if object.attractTimer == 420
124
#platform: USE_ORIGINS
125
object.timer = 0
126
#endplatform
127
object.state = START_ATTRACTMODE
128
end if
129
end if
130
break
131
132
#platform: USE_STANDALONE
133
case START_NEWGAME
134
object.timer += 8
135
if object.timer == 320
136
options.attractMode = false
137
player.lives = 3
138
player.continues = 0
139
player.score = 0
140
player.scoreBonus = 50000
141
starPostID = 0
142
specialStage.listPos = 0
143
specialStage.emeralds = 0
144
specialStage.nextZone = 0
145
146
// New Game - to EHZ1 you go!
147
stage.activeList = REGULAR_STAGE
148
stage.listPos = 0
149
LoadStage()
150
end if
151
SetScreenFade(0x00, 0x00, 0x00, object.timer)
152
break
153
#endplatform
154
155
#platform: USE_ORIGINS
156
case START_FLASHPRESSBUTTON
157
object.animationTimer += 10
158
object.timer++
159
if object.timer >= 30
160
object.animationTimer = 0
161
object.menuSelection = MENU_1PLAYER
162
object.state = START_ORIGINSMENU
163
end if
164
break
165
#endplatform
166
167
case START_LEVELSELECT
168
object.timer += 8
169
if object.timer == 320
170
options.attractMode = false
171
player.lives = 3
172
player.continues = 0
173
player.score = 0
174
player.scoreBonus = 50000
175
starPostID = 0
176
specialStage.listPos = 0
177
specialStage.emeralds = 0
178
specialStage.nextZone = 0
179
180
// Level Select
181
stage.activeList = PRESENTATION_STAGE
182
stage.listPos = 5
183
LoadStage()
184
end if
185
SetScreenFade(0x00, 0x00, 0x00, object.timer)
186
break
187
188
case START_CONTINUESCREEN
189
object.timer += 8
190
if object.timer == 320
191
// Continue Screen...?
192
options.attractMode = false
193
stage.listPos = 4
194
LoadStage()
195
end if
196
SetScreenFade(0x00, 0x00, 0x00, object.timer)
197
break
198
199
case START_ATTRACTMODE
200
object.timer += 8
201
if object.timer >= 320
202
player.lives = 3
203
player.continues = 0
204
player.score = 0
205
player.scoreBonus = 50000
206
starPostID = 0
207
specialStage.listPos = 0
208
specialStage.emeralds = 0
209
specialStage.nextZone = 0
210
211
// Attract Mode time
212
stage.activeList = REGULAR_STAGE
213
stage.listPos = attract.stage
214
stage.listPos <<= 1
215
216
attract.stage++
217
attract.stage &= 3
218
options.attractMode = true
219
credits.screen = 0
220
221
#platform: USE_ORIGINS
222
// Amy isn't allowed to be in the demos, apparently
223
switch stage.playerListPos
224
case PLAYER_AMY_A
225
stage.playerListPos = PLAYER_SONIC
226
break
227
228
case PLAYER_AMY_TAILS_A
229
stage.playerListPos = PLAYER_SONIC_TAILS
230
break
231
end switch
232
#endplatform
233
234
LoadStage()
235
end if
236
SetScreenFade(0x00, 0x00, 0x00, object.timer)
237
break
238
239
#platform: USE_ORIGINS
240
case START_ORIGINSMENU
241
temp0 = false
242
243
if keyPress[0].up == true
244
temp0 = true
245
end if
246
if keyPress[0].down == true
247
temp0 = true
248
end if
249
250
if checkResult > 0
251
object.animationTimer = 0
252
object.timer = 0
253
254
if checkResult > 1
255
object.state = START_FLASHOPTION
256
else
257
object.state = START_AWAITACTION
258
end if
259
260
temp0 = false
261
end if
262
263
if temp0 != false
264
if object.menuSelection == MENU_1PLAYER
265
object.menuSelection = MENU_2PLAYERVS
266
else
267
object.menuSelection = MENU_1PLAYER
268
end if
269
end if
270
break
271
272
case START_FLASHOPTION
273
object.animationTimer += 11
274
if object.animationTimer > 59
275
object.animationTimer = 0
276
end if
277
278
object.timer++
279
if object.timer >= 30
280
object.timer = 0
281
object.animationTimer = 0
282
283
if object.menuSelection == MENU_1PLAYER
284
object.state = START_1PSENDCALLBACK
285
else
286
game.callbackResult = -1
287
CallNativeFunction2(NotifyCallback, NOTIFY_CONTROLLER_SUPPORT, 0) // Opens the controller setup screen on Switch
288
object.state = START_2PSENDCALLBACK
289
end if
290
end if
291
break
292
293
case START_1PSENDCALLBACK
294
game.continueFlag = false
295
game.callbackResult = -1
296
CallNativeFunction2(NotifyCallback, NOTIFY_CHARACTER_SELECT, 0)
297
object.state = START_1PWAITFORCHARSELECT
298
break
299
300
case START_1PWAITFORCHARSELECT
301
if game.callbackResult > 0
302
object.state = START_ORIGINSSTARTGAME
303
if stage.playerListPos > PLAYER_SONIC_TAILS_A // Not really sure what this check is for
304
CallNativeFunction2(NotifyCallback, NOTIFY_1P_VS_SELECT, 0)
305
end if
306
StopMusic()
307
else
308
if game.callbackResult == 0
309
object.state = START_AWAITACTION
310
end if
311
end if
312
// Fall-through
313
314
case START_ORIGINSSTARTGAME
315
object.timer += 8
316
if object.timer >= 320
317
if game.continueFlag != false
318
game.continueFlag = false
319
engine.state = RESET_GAME
320
else
321
options.attractMode = false
322
player.lives = 3
323
player.continues = 0
324
player.score = 0
325
player.scoreBonus = 50000
326
starPostID = 0
327
specialStage.listPos = 0
328
specialStage.emeralds = 0
329
specialStage.nextZone = 0
330
recWaterState = 0
331
recWaterLevel = 0
332
recMilliSeconds = 0
333
recRing = 0
334
recScore = 0
335
336
if object.menuSelection == MENU_1PLAYER
337
// EHZ1
338
stage.activeList = REGULAR_STAGE
339
stage.listPos = 0
340
else
341
// 2P VS menu
342
stage.activeList = PRESENTATION_STAGE
343
stage.listPos = 3
344
end if
345
LoadStage()
346
end if
347
end if
348
SetScreenFade(0, 0, 0, object.timer)
349
break
350
351
case START_2PSENDCALLBACK
352
if game.callbackResult > 0
353
object.state = START_ORIGINSSTARTGAME
354
else
355
if game.callbackResult == 0
356
object.state = START_ORIGINSMENU
357
end if
358
end if
359
break
360
#endplatform
361
end switch
362
end event
363
364
365
event ObjectDraw
366
#platform: USE_STANDALONE
367
object.animationTimer++
368
if object.animationTimer > 59
369
object.animationTimer = 0
370
end if
371
372
if object.animationTimer > 29
373
DrawSpriteScreenXY(0, screen.xcenter, object.ypos)
374
end if
375
#endplatform
376
377
#platform: USE_ORIGINS
378
switch object.state
379
case START_AWAITACTION
380
case START_FLASHPRESSBUTTON
381
case START_LEVELSELECT
382
case START_CONTINUESCREEN
383
case START_ATTRACTMODE
384
object.animationTimer++
385
if object.animationTimer > 59
386
object.animationTimer = 0
387
end if
388
389
if object.animationTimer > 29
390
DrawSpriteScreenXY(0, screen.xcenter, object.ypos)
391
end if
392
break
393
394
case START_ORIGINSMENU
395
case START_FLASHOPTION
396
case START_1PSENDCALLBACK
397
temp0 = object.ypos // temp0: "1 Player" line ypos
398
temp1 = object.ypos // temp1: "2 Player VS" line ypos
399
temp1 += 12
400
if object.menuSelection == MENU_1PLAYER
401
if object.animationTimer < 29
402
DrawSpriteScreenXY(2, screen.xcenter, temp0)
403
end if
404
DrawSpriteScreenXY(3, screen.xcenter, temp1)
405
DrawSpriteScreenXY(5, screen.xcenter, temp0)
406
else
407
DrawSpriteScreenXY(1, screen.xcenter, temp0)
408
if object.animationTimer < 29
409
DrawSpriteScreenXY(4, screen.xcenter, temp1)
410
end if
411
DrawSpriteScreenXY(5, screen.xcenter, temp1)
412
end if
413
break
414
415
case START_1PWAITFORCHARSELECT
416
case START_ORIGINSSTARTGAME
417
case START_2PSENDCALLBACK
418
break
419
end switch
420
#endplatform
421
end event
422
423
424
event ObjectStartup
425
#platform: USE_ORIGINS
426
CallNativeFunction2(NotifyCallback, NOTIFY_LEVEL_SELECT_MENU, false)
427
#endplatform
428
429
LoadSpriteSheet("Title/Title.gif")
430
switch engine.deviceType
431
case STANDARD
432
SpriteFrame(-49, -1, 98, 9, 1, 380) // Press Button - #0
433
break
434
435
case MOBILE
436
SpriteFrame(-57, -1, 114, 9, 1, 390) // Touch To Start - #0
437
break
438
end switch
439
440
#platform: USE_ORIGINS
441
SpriteFrame(-40, -1, 66, 9, 1, 400) // 1 PLAYER - #1
442
SpriteFrame(-40, -1, 66, 9, 92, 400) // 1 PLAYER (Highlighted) - #2
443
SpriteFrame(-40, -1, 90, 9, 1, 410) // 2 PLAYER VS - #3
444
SpriteFrame(-40, -1, 90, 9, 92, 410) // 2 PLAYER VS (Highlighted) - #4
445
SpriteFrame(-60, -5, 16, 16, 104, 370) // Sonic Icon - #5
446
#endplatform
447
end event
448
449
450
// ========================
451
// Editor Events
452
// ========================
453
454
event RSDKDraw
455
DrawSprite(0)
456
end event
457
458
459
event RSDKLoad
460
LoadSpriteSheet("Title/Title.gif")
461
SpriteFrame(-49, -1, 98, 9, 1, 380) // Press Button - #0
462
463
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
464
end event
465
466