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/2PVS/SSResultSingle.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: SS Single Result 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.value1 : object.iconSheet
14
private alias object.value2 : object.textSheet
15
private alias object.value3 : object.checkpoint1Winner
16
private alias object.value4 : object.checkpoint2Winner
17
private alias object.value5 : object.checkpoint3Winner
18
private alias object.value6 : object.checkpoint1Rings1P
19
private alias object.value7 : object.checkpoint2Rings1P
20
private alias object.value8 : object.checkpoint3Rings1P
21
private alias object.value9 : object.checkpoint1Rings2P
22
private alias object.value10 : object.checkpoint2Rings2P
23
private alias object.value11 : object.checkpoint3Rings2P
24
private alias object.value12 : object.wins1P
25
private alias object.value13 : object.wins2P
26
private alias object.value14 : object.overallWinner
27
private alias object.value15 : object.stageID
28
29
// States
30
private alias 0 : SSRESULTSINGLE_SETUP
31
private alias 1 : SSRESULTSINGLE_WAITING
32
private alias 2 : SSRESULTSINGLE_SHOWRESULTS
33
private alias 3 : SSRESULTSINGLE_LOADSTAGE
34
private alias 4 : SSRESULTSINGLE_FADEOUT
35
36
// 2PVSSetup Aliases
37
private alias object.value0 : 2PVSSetup.timer
38
39
// 2PVSSetup States
40
private alias 1 : 2PVSSETUP_FADEIN
41
private alias 4 : 2PVSSETUP_TOSPECIALSTAGE
42
43
44
// ========================
45
// Events
46
// ========================
47
48
event ObjectUpdate
49
switch object.state
50
case SSRESULTSINGLE_SETUP
51
SetupMenu(MENU_1, 0, 3, 0)
52
53
LoadSpriteSheet("LevelSelect/Icons.gif")
54
object.iconSheet = object.spriteSheet
55
56
LoadSpriteSheet("LevelSelect/Text.gif")
57
object.textSheet = object.spriteSheet
58
59
menu1.selection = -1
60
if vs.tieBreaker == false
61
object.stageID = vs.listPos
62
object.stageID -= 4
63
else
64
if vs.activeList == SPECIAL_STAGE
65
object.stageID = 2
66
else
67
object.stageID = 3
68
end if
69
end if
70
71
object.checkpoint1Rings1P = vs.checkpoint1P
72
object.checkpoint1Rings1P &= 0xFF
73
74
object.checkpoint2Rings1P = vs.checkpoint1P
75
object.checkpoint2Rings1P >>= 8
76
object.checkpoint2Rings1P &= 0xFF
77
78
object.checkpoint3Rings1P = vs.checkpoint1P
79
object.checkpoint3Rings1P >>= 16
80
81
object.checkpoint1Rings2P = vs.checkpoint2P
82
object.checkpoint1Rings2P &= 0xFF
83
84
object.checkpoint2Rings2P = vs.checkpoint2P
85
object.checkpoint2Rings2P >>= 8
86
object.checkpoint2Rings2P &= 0xFF
87
88
object.checkpoint3Rings2P = vs.checkpoint2P
89
object.checkpoint3Rings2P >>= 16
90
91
switch object.stageID
92
case 0
93
AddMenuEntry(MENU_1, "@@@@@@@SPECIAL STAGE@@@* 1 *", true)
94
break
95
96
case 1
97
AddMenuEntry(MENU_1, "@@@@@@@SPECIAL STAGE@@@* 2 *", true)
98
break
99
100
case 2
101
AddMenuEntry(MENU_1, "@@@@@@@SPECIAL STAGE@@@* 3 *", true)
102
break
103
104
case 3
105
AddMenuEntry(MENU_1, "@@@@@@@SPECIAL STAGE", true)
106
break
107
108
end switch
109
110
AddMenuEntry(MENU_1, "@", true)
111
AddMenuEntry(MENU_1, "@", true)
112
AddMenuEntry(MENU_1, "@", true)
113
AddMenuEntry(MENU_1, "@@@@@@@@@@@@@@1P@@@@@@2P@@@@WINS", true)
114
AddMenuEntry(MENU_1, "@", true)
115
AddMenuEntry(MENU_1, "CHECKPOINT", true)
116
AddMenuEntry(MENU_1, "@", true)
117
AddMenuEntry(MENU_1, "@@@* 1 *", true)
118
AddMenuEntry(MENU_1, "@", true)
119
AddMenuEntry(MENU_1, "@@@* 2 *", true)
120
AddMenuEntry(MENU_1, "@", true)
121
AddMenuEntry(MENU_1, "@@@* 3 *", true)
122
AddMenuEntry(MENU_1, "@", true)
123
AddMenuEntry(MENU_1, "@", true)
124
AddMenuEntry(MENU_1, "@* TOTAL *@@@@@@@@@:", true)
125
126
object.wins1P = 0
127
object.wins2P = 0
128
if object.checkpoint1Rings1P == object.checkpoint1Rings2P
129
object.checkpoint1Winner = 3
130
else
131
if object.checkpoint1Rings1P > object.checkpoint1Rings2P
132
object.checkpoint1Winner = 1
133
object.wins1P++
134
else
135
object.checkpoint1Winner = 2
136
object.wins2P++
137
end if
138
end if
139
140
if object.checkpoint2Rings1P == object.checkpoint2Rings2P
141
object.checkpoint2Winner = 3
142
else
143
if object.checkpoint2Rings1P > object.checkpoint2Rings2P
144
object.checkpoint2Winner = 1
145
object.wins1P++
146
else
147
object.checkpoint2Winner = 2
148
object.wins2P++
149
end if
150
end if
151
152
if object.checkpoint3Rings1P == object.checkpoint3Rings2P
153
object.checkpoint3Winner = 3
154
else
155
if object.checkpoint3Rings1P > object.checkpoint3Rings2P
156
object.checkpoint3Winner = 1
157
object.wins1P++
158
else
159
object.checkpoint3Winner = 2
160
object.wins2P++
161
end if
162
end if
163
164
if object.wins1P == object.wins2P
165
object.overallWinner = 18
166
else
167
if object.wins1P > object.wins2P
168
object.overallWinner = 14
169
else
170
object.overallWinner = 16
171
end if
172
end if
173
174
arrayPos0 = vs.match
175
arrayPos0 <<= 2
176
if vs.tieBreaker == false
177
arrayPos0 += object.stageID
178
else
179
arrayPos0 += 2
180
end if
181
arrayPos0 += 0x400
182
saveRAM[arrayPos0] = object.wins2P
183
saveRAM[arrayPos0] <<= 4
184
saveRAM[arrayPos0] += object.wins1P
185
if object.stageID == 1
186
arrayPos0++
187
saveRAM[arrayPos0] = 0
188
arrayPos0++
189
saveRAM[arrayPos0] = 7
190
end if
191
192
object.state++
193
break
194
195
case SSRESULTSINGLE_WAITING
196
CallNativeFunction2(ReceiveEntity, 0x400, true)
197
ResetObjectEntity(0x400, TypeName[Blank Object], 0, 0, 0)
198
object.state++
199
break
200
201
case SSRESULTSINGLE_SHOWRESULTS
202
if object.timer < 60
203
object.timer++
204
else
205
CheckTouchRect(0, 0, screen.xsize, screen.ysize)
206
if keyPress[0].start == true
207
checkResult = 0
208
end if
209
210
if keyPress[0].buttonA == true
211
checkResult = 0
212
end if
213
214
if keyPress[0].buttonB == true
215
checkResult = 0
216
end if
217
218
if keyPress[0].buttonC == true
219
checkResult = 0
220
end if
221
222
if checkResult > -1
223
object.timer = 0
224
if vs.tieBreaker == true
225
object.state = SSRESULTSINGLE_FADEOUT
226
else
227
if object.stageID == 0
228
vs.listPos++
229
stage.activeList = vs.activeList
230
stage.listPos = vs.listPos
231
object.state = SSRESULTSINGLE_LOADSTAGE
232
object[0].state = 2PVSSETUP_TOSPECIALSTAGE
233
PlaySfx(SfxName[Warp], false)
234
else
235
CallFunction(ActResults_CheckTieBreaker)
236
if checkResult == true
237
stage.activeList = SPECIAL_STAGE
238
stage.listPos = 6
239
object.state = SSRESULTSINGLE_LOADSTAGE
240
object[0].state = 2PVSSETUP_TOSPECIALSTAGE
241
PlaySfx(SfxName[Warp], false)
242
vs.tieBreaker = true
243
else
244
object.state = SSRESULTSINGLE_FADEOUT
245
end if
246
end if
247
end if
248
end if
249
end if
250
break
251
252
case SSRESULTSINGLE_LOADSTAGE
253
break
254
255
case SSRESULTSINGLE_FADEOUT
256
if object.timer < 256
257
object.timer += 16
258
SetScreenFade(0x00, 0x00, 0x00, object.timer)
259
else
260
if vs.activeList == SPECIAL_STAGE
261
ResetObjectEntity(1, TypeName[SS Results], 0, 0, 0)
262
else
263
ResetObjectEntity(1, TypeName[Zone Results], 0, 0, 0)
264
end if
265
object[1].priority = PRIORITY_ACTIVE
266
object[0].state = 2PVSSETUP_FADEIN
267
2PVSSetup[0].timer = 384
268
SetScreenFade(0x00, 0x00, 0x00, 0xFF)
269
end if
270
break
271
272
end switch
273
274
object.animationTimer++
275
object.animationTimer &= 15
276
end event
277
278
279
event ObjectDraw
280
object.spriteSheet = object.iconSheet
281
DrawSpriteScreenXY(0, screen.xcenter, 17)
282
283
// 1P Results
284
temp0 = screen.xcenter
285
temp0 += 8
286
DrawNumbers(4, temp0, 129, object.checkpoint1Rings1P, 3, 8, false)
287
DrawNumbers(4, temp0, 145, object.checkpoint2Rings1P, 3, 8, false)
288
DrawNumbers(4, temp0, 161, object.checkpoint3Rings1P, 3, 8, false)
289
290
// 2P Results
291
temp0 = screen.xcenter
292
temp0 += 72
293
DrawNumbers(4, temp0, 129, object.checkpoint1Rings2P, 3, 8, false)
294
DrawNumbers(4, temp0, 145, object.checkpoint2Rings2P, 3, 8, false)
295
DrawNumbers(4, temp0, 161, object.checkpoint3Rings2P, 3, 8, false)
296
297
// Wins
298
temp0 = screen.xcenter
299
temp0 += 8
300
DrawNumbers(4, temp0, 185, object.wins1P, 1, 8, true)
301
temp0 += 32
302
DrawNumbers(4, temp0, 185, object.wins2P, 1, 8, true)
303
304
// Winners
305
temp0 = screen.xcenter
306
temp0 += 112
307
DrawSpriteScreenXY(object.checkpoint1Winner, temp0, 129)
308
DrawSpriteScreenXY(object.checkpoint2Winner, temp0, 145)
309
DrawSpriteScreenXY(object.checkpoint3Winner, temp0, 161)
310
temp0 = object.animationTimer
311
temp0 >>= 3
312
temp0 += object.overallWinner
313
DrawSpriteScreenXY(temp0, screen.xcenter, 210)
314
315
object.spriteSheet = object.textSheet
316
temp0 = screen.xcenter
317
temp0 -= 128
318
DrawMenu(MENU_1, temp0, 64)
319
end event
320
321
322
event ObjectStartup
323
LoadSpriteSheet("LevelSelect/Icons.gif")
324
LoadSpriteSheet("LevelSelect/Text.gif")
325
326
SpriteFrame(-48, 0, 96, 14, 1, 136) // RESULT - #0
327
SpriteFrame(-8, 0, 16, 7, 98, 136) // 1P text - #1
328
SpriteFrame(-8, 0, 16, 7, 115, 136) // 2P text - #2
329
SpriteFrame(-16, 0, 32, 7, 132, 136) // TIED text - #3
330
SpriteFrame(0, 0, 8, 7, 175, 140) // 0 - #4
331
SpriteFrame(0, 0, 8, 7, 183, 140) // 1 - #5
332
SpriteFrame(0, 0, 8, 7, 191, 140) // 2 - #6
333
SpriteFrame(0, 0, 8, 7, 199, 140) // 3 - #7
334
SpriteFrame(0, 0, 8, 7, 207, 140) // 4 - #8
335
SpriteFrame(0, 0, 8, 7, 215, 140) // 5 - #9
336
SpriteFrame(0, 0, 8, 7, 223, 140) // 6 - #10
337
SpriteFrame(0, 0, 8, 7, 231, 140) // 7 - #11
338
SpriteFrame(0, 0, 8, 7, 239, 140) // 8 - #12
339
SpriteFrame(0, 0, 8, 7, 247, 140) // 9 - #13
340
SpriteFrame(-47, 0, 91, 12, 1, 110) // 1P WINS - #14
341
SpriteFrame(-47, 0, 91, 12, 1, 123) // 1P WINS (Flashing) - #15
342
SpriteFrame(-47, 0, 91, 12, 93, 110) // 2P WINS - #16
343
SpriteFrame(-47, 0, 91, 12, 93, 123) // 2P WINS (Flashing) - #17
344
SpriteFrame(-22, 0, 44, 12, 1, 385) // TIED - #18
345
SpriteFrame(-22, 0, 44, 12, 1, 398) // TIED (Flashing) - #19
346
347
foreach (TypeName[SS Single Result], arrayPos0, ALL_ENTITIES)
348
object[arrayPos0].priority = PRIORITY_ACTIVE
349
next
350
end event
351
352
353
// ========================
354
// Editor Events
355
// ========================
356
357
event RSDKDraw
358
DrawSprite(0)
359
end event
360
361
362
event RSDKLoad
363
LoadSpriteSheet("LevelSelect/Icons.gif")
364
SpriteFrame(-48, 0, 96, 14, 1, 136) // RESULT - #0
365
366
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
367
end event
368
369