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/SLZ/RotatingStair.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
3
// Script Description: Rotating Stair 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.blockPos1.x
13
private alias object.value1 : object.blockPos1.y
14
private alias object.value2 : object.blockPos2.x
15
private alias object.value3 : object.blockPos2.y
16
private alias object.value4 : object.blockPos3.x
17
private alias object.value5 : object.blockPos3.y
18
private alias object.value6 : object.blockPos4.x
19
private alias object.value7 : object.blockPos4.y
20
private alias object.value8 : object.blockPos5.x
21
private alias object.value9 : object.blockPos5.y
22
private alias object.value10 : object.blockPos6.x
23
private alias object.value11 : object.blockPos6.y
24
private alias object.value12 : object.blockPos7.x
25
private alias object.value13 : object.blockPos7.y
26
private alias object.value14 : object.blockPos8.x
27
private alias object.value15 : object.blockPos8.y
28
29
private alias object.value16 : object.startPos.x
30
private alias object.value17 : object.startPos.y
31
32
// Player Aliases
33
private alias object.xpos : player.xpos
34
private alias object.ypos : player.ypos
35
private alias object.gravity : player.gravity
36
37
38
// ========================
39
// Function Declarations
40
// ========================
41
42
reserve function RotatingStair_DebugDraw
43
reserve function RotatingStair_DebugSpawn
44
reserve function RotatingStair_ProcessBlock
45
46
47
// ========================
48
// Function Definitions
49
// ========================
50
51
private function RotatingStair_DebugDraw
52
temp0 = object.xpos
53
temp0 -= 0x700000
54
temp1 = object.ypos
55
temp1 -= 0x700000
56
temp2 = 0
57
while temp2 < 8
58
DrawSpriteXY(0, temp0, temp1)
59
temp0 += 0x200000
60
temp1 += 0x200000
61
temp2++
62
loop
63
end function
64
65
66
private function RotatingStair_DebugSpawn
67
CreateTempObject(TypeName[Rotating Stair], 0, object.xpos, object.ypos)
68
object[tempObjectPos].startPos.x = object.xpos
69
object[tempObjectPos].startPos.y = object.ypos
70
end function
71
72
73
private function RotatingStair_ProcessBlock
74
temp1 = temp5
75
GetTableValue(temp0, temp3, StageSetup_oscillationTable)
76
temp0 <<= 8
77
if temp3 == 20
78
temp0 >>= 1
79
end if
80
81
switch temp4
82
case 0
83
temp0 -= temp1
84
temp0 += object.startPos.x
85
temp6 = temp0
86
FlipSign(temp1)
87
temp1 += object.startPos.y
88
temp7 = temp1
89
break
90
91
case 1
92
temp0 -= temp1
93
FlipSign(temp0)
94
temp0 += object.startPos.y
95
temp7 = temp0
96
temp1 += object.startPos.x
97
temp6 = temp1
98
break
99
100
case 2
101
temp0 -= temp1
102
FlipSign(temp0)
103
temp0 += object.startPos.x
104
temp6 = temp0
105
temp1 += object.startPos.y
106
temp7 = temp1
107
break
108
109
case 3
110
temp0 -= temp1
111
temp0 += object.startPos.y
112
temp7 = temp0
113
FlipSign(temp1)
114
temp1 += object.startPos.x
115
temp6 = temp1
116
break
117
118
end switch
119
120
temp6 &= 0xFFFF0000
121
temp7 &= 0xFFFF0000
122
temp0 = temp6
123
temp0 -= object.xpos
124
temp1 = temp7
125
temp1 -= object.ypos
126
127
foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
128
BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
129
if checkResult == COL_TOP
130
player[currentPlayer].xpos += temp0
131
player[currentPlayer].ypos += temp1
132
end if
133
134
if player[currentPlayer].gravity == 0
135
if checkResult == COL_BOTTOM
136
CallFunction(Player_Kill)
137
end if
138
end if
139
next
140
end function
141
142
143
// ========================
144
// Events
145
// ========================
146
147
event ObjectUpdate
148
temp4 = SLZSetup_rotateTimer
149
temp5 = 0x100000
150
temp3 = 20
151
object.xpos = object.blockPos1.x
152
object.ypos = object.blockPos1.y
153
CallFunction(RotatingStair_ProcessBlock)
154
object.blockPos1.x = temp6
155
object.blockPos1.y = temp7
156
157
temp4 ^= 2
158
object.xpos = object.blockPos2.x
159
object.ypos = object.blockPos2.y
160
CallFunction(RotatingStair_ProcessBlock)
161
object.blockPos2.x = temp6
162
object.blockPos2.y = temp7
163
164
temp4 ^= 2
165
temp5 = 0x300000
166
temp3 = 22
167
object.xpos = object.blockPos3.x
168
object.ypos = object.blockPos3.y
169
CallFunction(RotatingStair_ProcessBlock)
170
object.blockPos3.x = temp6
171
object.blockPos3.y = temp7
172
temp4 ^= 2
173
174
object.xpos = object.blockPos4.x
175
object.ypos = object.blockPos4.y
176
CallFunction(RotatingStair_ProcessBlock)
177
object.blockPos4.x = temp6
178
object.blockPos4.y = temp7
179
180
temp4 ^= 2
181
temp5 = 0x500000
182
temp3 = 24
183
object.xpos = object.blockPos5.x
184
object.ypos = object.blockPos5.y
185
CallFunction(RotatingStair_ProcessBlock)
186
object.blockPos5.x = temp6
187
object.blockPos5.y = temp7
188
189
temp4 ^= 2
190
object.xpos = object.blockPos6.x
191
object.ypos = object.blockPos6.y
192
CallFunction(RotatingStair_ProcessBlock)
193
object.blockPos6.x = temp6
194
object.blockPos6.y = temp7
195
196
temp4 ^= 2
197
temp5 = 0x700000
198
temp3 = 26
199
object.xpos = object.blockPos7.x
200
object.ypos = object.blockPos7.y
201
CallFunction(RotatingStair_ProcessBlock)
202
object.blockPos7.x = temp6
203
object.blockPos7.y = temp7
204
205
temp4 ^= 2
206
object.xpos = object.blockPos8.x
207
object.ypos = object.blockPos8.y
208
CallFunction(RotatingStair_ProcessBlock)
209
object.blockPos8.x = temp6
210
object.blockPos8.y = temp7
211
212
object.xpos = object.startPos.x
213
object.ypos = object.startPos.y
214
end event
215
216
217
event ObjectDraw
218
DrawSpriteXY(0, object.blockPos1.x, object.blockPos1.y)
219
DrawSpriteXY(0, object.blockPos2.x, object.blockPos2.y)
220
DrawSpriteXY(0, object.blockPos3.x, object.blockPos3.y)
221
DrawSpriteXY(0, object.blockPos4.x, object.blockPos4.y)
222
DrawSpriteXY(0, object.blockPos5.x, object.blockPos5.y)
223
DrawSpriteXY(0, object.blockPos6.x, object.blockPos6.y)
224
DrawSpriteXY(0, object.blockPos7.x, object.blockPos7.y)
225
DrawSpriteXY(0, object.blockPos8.x, object.blockPos8.y)
226
end event
227
228
229
event ObjectStartup
230
LoadSpriteSheet("SLZ/Objects.gif")
231
SpriteFrame(-16, -16, 32, 32, 67, 26)
232
233
foreach (TypeName[Rotating Stair], arrayPos0, ALL_ENTITIES)
234
object[arrayPos0].startPos.x = object[arrayPos0].xpos
235
object[arrayPos0].startPos.y = object[arrayPos0].ypos
236
next
237
238
SetTableValue(TypeName[Rotating Stair], DebugMode_ObjCount, DebugMode_TypesTable)
239
SetTableValue(RotatingStair_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
240
SetTableValue(RotatingStair_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
241
DebugMode_ObjCount++
242
end event
243
244
245
// ========================
246
// Editor Events
247
// ========================
248
249
event RSDKDraw
250
temp0 = object.xpos
251
temp0 -= 0x700000
252
temp1 = object.ypos
253
temp1 -= 0x700000
254
temp2 = 0
255
while temp2 < 8
256
DrawSpriteXY(0, temp0, temp1)
257
temp0 += 0x200000
258
temp1 += 0x200000
259
temp2++
260
loop
261
end event
262
263
264
event RSDKLoad
265
LoadSpriteSheet("SLZ/Objects.gif")
266
SpriteFrame(-16, -16, 32, 32, 67, 26)
267
268
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
269
end event
270
271