Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/Title/Start.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
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
// Not sure why it skips from 0 to 4, guess there must've been a revision or smth
14
private alias object.value4 : object.attractTimer
15
16
private alias 0 : START_FLASH
17
private alias 1 : START_STARTGAME
18
private alias 2 : START_STARTLVLSEL
19
private alias 3 : START_STARTLVLSEL_OLD
20
private alias 4 : START_STARTATTRACT
21
private alias 5 : START_NOTIFYCALLBACK
22
private alias 6 : START_WAITFORCALLBACK
23
private alias 7 : START_FADETOEXIT
24
private alias 8 : START_EXIT
25
26
27
// ========================
28
// Events
29
// ========================
30
31
event ObjectUpdate
32
switch object.state
33
case START_FLASH
34
CheckTouchRect(0, 0, screen.xsize, screen.ysize)
35
36
#platform: USE_STANDALONE
37
if keyPress[0].start == true
38
checkResult = true
39
end if
40
41
if keyPress[0].buttonA == true
42
checkResult = true
43
end if
44
#endplatform
45
46
if keyPress[0].buttonB == true
47
checkResult = true
48
end if
49
50
#platform: USE_STANDALONE
51
if keyPress[0].buttonC == true
52
checkResult = true
53
end if
54
#endplatform
55
56
#platform: USE_ORIGINS
57
if keyPress[0].start == true
58
checkResult = true
59
end if
60
61
if keyPress[0].buttonA == true
62
checkResult = true
63
end if
64
65
if input.pressButton == true
66
checkResult = true
67
end if
68
#endplatform
69
70
if checkResult > -1
71
#platform: USE_STANDALONE
72
if options.stageSelectFlag == true
73
if checkResult > 0 // This is a fancy way of seeing if two (or more) fingers are on the screen
74
object.state = START_STARTLVLSEL
75
else
76
object.state = START_STARTGAME
77
end if
78
else
79
object.state = START_STARTGAME
80
end if
81
82
PlaySfx(SfxName[Menu Select], false)
83
StopMusic()
84
#endplatform
85
86
#platform: USE_ORIGINS
87
if options.stageSelectFlag == true
88
if checkResult > 0
89
object.state = START_STARTLVLSEL
90
StopMusic()
91
else
92
object.state = START_NOTIFYCALLBACK
93
end if
94
else
95
if keyPress[0].buttonB == true
96
CallNativeFunction2(NotifyCallback, NOTIFY_BACK_TO_MAINMENU, 1)
97
else
98
object.state = START_NOTIFYCALLBACK
99
end if
100
end if
101
#endplatform
102
else
103
object.attractTimer++
104
if object.attractTimer == 360
105
object.state = START_STARTATTRACT
106
end if
107
end if
108
break
109
110
case START_STARTGAME
111
object.timer += 8
112
if object.timer == 320
113
options.attractMode = false
114
player.lives = 3
115
player.continues = 0
116
player.score = 0
117
player.scoreBonus = 50000
118
lampPostID = 0
119
specialStage.listPos = 0
120
specialStage.emeralds = 0
121
specialStage.nextZone = 0
122
123
// New Game - to GHZ1 you go!
124
stage.activeList = REGULAR_STAGE
125
stage.listPos = 0
126
#platform: USE_ORIGINS
127
recWaterState = 0
128
recWaterLevel = 0
129
recMilliSeconds = 0
130
recRing = 0
131
recScore = 0
132
#endplatform
133
134
LoadStage()
135
end if
136
SetScreenFade(0x00, 0x00, 0x00, object.timer)
137
break
138
139
case START_STARTLVLSEL
140
object.timer += 8
141
if object.timer == 320
142
options.attractMode = false
143
player.lives = 3
144
player.continues = 0
145
player.score = 0
146
player.scoreBonus = 50000
147
lampPostID = 0
148
specialStage.listPos = 0
149
specialStage.emeralds = 0
150
specialStage.nextZone = 0
151
152
// Level Select!!
153
stage.activeList = PRESENTATION_STAGE
154
stage.listPos = 5
155
156
LoadStage()
157
end if
158
SetScreenFade(0, 0, 0, object.timer)
159
break
160
161
case START_STARTLVLSEL_OLD // Unused state
162
object.timer += 8
163
if object.timer == 320
164
// The Continue scene...?
165
// This state seems to be a leftover from CD, where its level select code was pretty much the same as this, including going to stage list pos 4
166
options.attractMode = false
167
stage.listPos = 4
168
LoadStage()
169
end if
170
SetScreenFade(0, 0, 0, object.timer)
171
break
172
173
case START_STARTATTRACT
174
object.timer += 8
175
if object.timer == 320
176
player.lives = 3
177
player.continues = 0
178
player.score = 0
179
player.scoreBonus = 50000
180
lampPostID = 0
181
specialStage.listPos = 0
182
specialStage.emeralds = 0
183
specialStage.nextZone = 0
184
185
if attract.stage == 3
186
stage.activeList = SPECIAL_STAGE
187
stage.listPos = 0
188
else
189
stage.activeList = REGULAR_STAGE
190
stage.listPos = attract.stage
191
stage.listPos *= 3
192
end if
193
attract.stage++
194
attract.stage &= 3
195
196
options.attractMode = true
197
credits.screen = 0
198
#platform: USE_ORIGINS
199
if stage.playerListPos == PLAYER_AMY
200
stage.playerListPos = PLAYER_SONIC
201
end if
202
#endplatform
203
204
LoadStage()
205
end if
206
SetScreenFade(0x00, 0x00, 0x00, object.timer)
207
break
208
209
#platform:USE_ORIGINS
210
case START_NOTIFYCALLBACK
211
game.continueFlag = false
212
game.callbackResult = -1
213
if game.playMode == BOOT_PLAYMODE_CLASSIC
214
CallNativeFunction2(NotifyCallback, NOTIFY_CHARACTER_SELECT, true)
215
else
216
CallNativeFunction2(NotifyCallback, NOTIFY_CHARACTER_SELECT, false)
217
end if
218
object.state = START_WAITFORCALLBACK
219
break
220
221
case START_WAITFORCALLBACK
222
if game.callbackResult > 0
223
if game.continueFlag != false
224
game.continueFlag = false
225
object.state = START_FADETOEXIT
226
else
227
object.state = START_STARTGAME
228
end if
229
object.timer = 0
230
StopMusic()
231
else
232
if game.callbackResult == 0
233
object.state = START_FLASH
234
end if
235
end if
236
break
237
238
case START_FADETOEXIT
239
object.timer += 4
240
if object.timer >= 384
241
object.state = START_EXIT
242
end if
243
SetScreenFade(0, 0, 0, object.timer)
244
break
245
246
case START_EXIT
247
engine.state = RESET_GAME
248
SetScreenFade(0, 0, 0, 255)
249
break
250
#endplatform
251
252
end switch
253
end event
254
255
256
event ObjectDraw
257
object.animationTimer++
258
if object.animationTimer > 59
259
object.animationTimer = 0
260
end if
261
262
if object.animationTimer > 29
263
DrawSpriteScreenXY(0, object.xpos, object.ypos)
264
end if
265
end event
266
267
268
event ObjectStartup
269
#platform: USE_ORIGINS
270
CallNativeFunction2(NotifyCallback, NOTIFY_LEVEL_SELECT_MENU, false)
271
#endplatform
272
273
LoadSpriteSheet("Title/Title.gif")
274
275
// In the original S1 releases this was instead a engine.language switch for different languages, although all cases led to the same path
276
277
switch engine.deviceType
278
case STANDARD
279
SpriteFrame(-48, -4, 96, 8, 1, 283)
280
break
281
282
case MOBILE
283
SpriteFrame(-56, -4, 112, 8, 1, 292)
284
break
285
286
end switch
287
end event
288
289
290
// ========================
291
// Editor Events
292
// ========================
293
294
event RSDKDraw
295
DrawSprite(0)
296
end event
297
298
299
event RSDKLoad
300
LoadSpriteSheet("Title/Title.gif")
301
SpriteFrame(-48, -4, 96, 8, 1, 283)
302
303
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
304
end event
305