Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/DAGarden/LittlePlanet.txt
1319 views
1
//---------------Sonic CD Little Planet Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value1 : Object.ZoomDepth
7
#alias Object.Value2 : Object.RotationLimit
8
#alias Object.Value3 : Object.RotationSpeed
9
#alias Object.Value4 : Object.RotationDirection
10
#alias Object.Value5 : Object.ZoomIn
11
#alias Object.Value6 : Object.Drag
12
#alias Object.Value7 : Object.TouchInput
13
14
// MenuControl Alias
15
#alias Object[0].State : MenuControl.State
16
17
// MenuControl States
18
#alias 2 : MENUCONTROL_IDLE
19
20
sub ObjectMain
21
if MenuControl.State == MENUCONTROL_IDLE
22
// Update Little Planet control
23
// Most of the things here are for physical controllers - touch input is handled in the Touch Buttons object
24
25
// Planet Movement
26
if KeyDown[0].Left == true
27
if Object.XPos > -0x400
28
Object.XPos--
29
end if
30
end if
31
32
if KeyDown[0].Right == true
33
if Object.XPos < 0x400
34
Object.XPos++
35
end if
36
end if
37
38
if KeyDown[0].Up == true
39
Object.YPos--
40
end if
41
42
if KeyDown[0].Down == true
43
Object.YPos++
44
end if
45
46
// Rotation
47
// Previously ButtonB, Origins change
48
if KeyDown[0].Start == true // Increase rotation speed
49
if Object.RotationDirection == FACING_LEFT
50
if Object.RotationSpeed < 256
51
Object.RotationSpeed += 2
52
end if
53
else
54
if Object.RotationSpeed > -256
55
Object.RotationSpeed -= 2
56
end if
57
end if
58
end if
59
60
if KeyPress[0].Start == true // Flip Rotation
61
Object.RotationDirection++
62
Object.RotationDirection &= 1
63
Object.RotationSpeed = 0
64
end if
65
66
// Zooming
67
if KeyDown[0].ButtonC == true // Zoom In/Out
68
if Object.ZoomIn == false
69
if Object.ZoomDepth < 0x4000
70
Object.ZoomDepth += 8
71
end if
72
else
73
if Object.ZoomDepth > 48
74
Object.ZoomDepth -= 8
75
end if
76
end if
77
end if
78
79
if KeyPress[0].ButtonC == true // Switch Zoom In / Zoom Out
80
Object.ZoomIn++
81
Object.ZoomIn &= 1
82
end if
83
84
// Touch Input Planet Movement
85
CheckTouchRect(0, 32, Screen.XSize, 208)
86
if CheckResult > -1
87
if Object.TouchInput != CheckResult
88
Object.Drag = false
89
end if
90
ArrayPos0 = CheckResult
91
if Object.Drag == false
92
Object.Drag = true
93
Object.TouchInput = CheckResult
94
Object[0].XPos = TouchScreen[ArrayPos0].XPos
95
Object[0].YPos = TouchScreen[ArrayPos0].YPos
96
Object[1].XPos = Object.XPos
97
Object[1].YPos = Object.YPos
98
else
99
TempValue0 = TouchScreen[ArrayPos0].XPos
100
TempValue0 -= Object[0].XPos
101
TempValue0 *= Object.ZoomDepth
102
TempValue0 >>= 11
103
TempValue0 += Object[1].XPos
104
TempValue1 = TempValue0
105
TempValue1 -= Object.XPos
106
if TempValue1 < 0
107
FlipSign(TempValue1)
108
end if
109
if TempValue1 < 14
110
Object.XPos = TempValue0
111
end if
112
TempValue0 = TouchScreen[ArrayPos0].YPos
113
TempValue0 -= Object[0].YPos
114
TempValue0 *= Object.ZoomDepth
115
TempValue0 >>= 11
116
TempValue0 += Object[1].YPos
117
TempValue1 = TempValue0
118
TempValue1 -= Object.YPos
119
if TempValue1 < 0
120
FlipSign(TempValue1)
121
end if
122
if TempValue1 < 14
123
Object.YPos = TempValue0
124
end if
125
end if
126
else
127
Object.Drag = false
128
end if
129
end if
130
131
Object.RotationLimit += Object.RotationSpeed
132
if Object.RotationLimit < 0
133
Object.RotationLimit += 0x2000
134
end if
135
Object.RotationLimit &= 0x1FFF
136
137
Object.Rotation = Object.RotationLimit
138
Object.Rotation >>= 4
139
end sub
140
141
142
sub ObjectDraw
143
if Object.Frame == 22
144
DrawRect(0, 32, Screen.XSize, 176, 64, 64, 32, 176)
145
end if
146
147
if Object.ZoomDepth > 0
148
TempValue0 = Object.XPos
149
TempValue0 <<= 11
150
TempValue0 /= Object.ZoomDepth
151
TempValue0 += Screen.CenterX
152
153
TempValue1 = Object.YPos
154
TempValue1 <<= 11
155
TempValue1 /= Object.ZoomDepth
156
TempValue1 += 120
157
158
Object.Scale = 0x20000
159
Object.Scale /= Object.ZoomDepth
160
DrawSpriteScreenFX(Object.Frame, FX_ROTOZOOM, TempValue0, TempValue1)
161
162
TempValue2 = Object.AnimationTimer
163
TempValue2 >>= 3
164
TempValue3 = Object.Frame
165
switch TempValue2
166
case 0
167
TempValue3++
168
DrawSpriteScreenFX(TempValue3, FX_ROTOZOOM, TempValue0, TempValue1)
169
break
170
171
case 1
172
TempValue3 += 2
173
DrawSpriteScreenFX(TempValue3, FX_ROTOZOOM, TempValue0, TempValue1)
174
break
175
176
case 2
177
TempValue3 += 3
178
DrawSpriteScreenFX(TempValue3, FX_ROTOZOOM, TempValue0, TempValue1)
179
break
180
181
case 3
182
TempValue3 += 4
183
DrawSpriteScreenFX(TempValue3, FX_ROTOZOOM, TempValue0, TempValue1)
184
break
185
186
case 4
187
TempValue3 += 5
188
DrawSpriteScreenFX(TempValue3, FX_ROTOZOOM, TempValue0, TempValue1)
189
break
190
191
case 24
192
TempValue3 += 6
193
DrawSpriteScreenFX(TempValue3, FX_ROTOZOOM, TempValue0, TempValue1)
194
break
195
196
case 25
197
TempValue3 += 7
198
DrawSpriteScreenFX(TempValue3, FX_ROTOZOOM, TempValue0, TempValue1)
199
break
200
201
case 26
202
TempValue3 += 8
203
DrawSpriteScreenFX(TempValue3, FX_ROTOZOOM, TempValue0, TempValue1)
204
break
205
206
case 27
207
TempValue3 += 9
208
DrawSpriteScreenFX(TempValue3, FX_ROTOZOOM, TempValue0, TempValue1)
209
break
210
211
case 28
212
TempValue3 += 10
213
DrawSpriteScreenFX(TempValue3, FX_ROTOZOOM, TempValue0, TempValue1)
214
break
215
216
end switch
217
Object.AnimationTimer++
218
Object.AnimationTimer &= 511
219
end if
220
end sub
221
222
223
sub ObjectStartup
224
LoadSpriteSheet("DAGarden/LittlePlanet.gif")
225
226
SpriteFrame(-126, -126, 252, 252, 0, 0) // #0 - Little Planet
227
SpriteFrame(95, -70, 16, 16, 256, 257) // #1 - Vulkan Smoke Frame 0
228
SpriteFrame(91, -75, 24, 24, 256, 274) // #2 - Vulkan Smoke Frame 1
229
SpriteFrame(92, -88, 32, 32, 256, 299) // #3 - Vulkan Smoke Frame 2
230
SpriteFrame(86, -92, 40, 40, 256, 332) // #4 - Vulkan Smoke Frame 3
231
SpriteFrame(85, -94, 40, 40, 256, 373) // #5 - Vulkan Smoke Frame 4
232
SpriteFrame(76, -90, 16, 16, 273, 257) // #6 - Vulkan Smoke Frame 5
233
SpriteFrame(75, -97, 24, 24, 281, 274) // #7 - Vulkan Smoke Frame 6
234
SpriteFrame(73, -104, 32, 32, 289, 299) // #8 - Vulkan Smoke Frame 7
235
SpriteFrame(76, -107, 32, 32, 297, 332) // #9 - Vulkan Smoke Frame 8
236
SpriteFrame(75, -110, 32, 32, 297, 365) // #10 - Vulkan Smoke Frame 9
237
SpriteFrame(-126, -126, 252, 252, 256, 0) // #11 - Little Planet Good Future
238
SpriteFrame(95, -70, 16, 16, 330, 257) // #12 - GF Vulkan Smoke Frame 0
239
SpriteFrame(91, -75, 24, 24, 330, 274) // #13 - GF Vulkan Smoke Frame 1
240
SpriteFrame(92, -88, 32, 32, 330, 299) // #14 - GF Vulkan Smoke Frame 2
241
SpriteFrame(86, -92, 40, 40, 330, 332) // #15 - GF Vulkan Smoke Frame 3
242
SpriteFrame(85, -94, 40, 40, 330, 373) // #16 - GF Vulkan Smoke Frame 4
243
SpriteFrame(76, -90, 16, 16, 347, 257) // #17 - GF Vulkan Smoke Frame 5
244
SpriteFrame(75, -97, 24, 24, 355, 274) // #18 - GF Vulkan Smoke Frame 6
245
SpriteFrame(73, -104, 32, 32, 363, 299) // #19 - GF Vulkan Smoke Frame 7
246
SpriteFrame(76, -107, 32, 32, 371, 332) // #20 - GF Vulkan Smoke Frame 8
247
SpriteFrame(75, -110, 32, 32, 371, 365) // #21 - GF Vulkan Smoke Frame 9
248
SpriteFrame(-126, -126, 252, 252, 0, 256) // #22 - Little Planet Bad Future
249
SpriteFrame(95, -70, 16, 16, 404, 257) // #23 - BF Vulkan Smoke Frame 0
250
SpriteFrame(91, -75, 24, 24, 404, 274) // #24 - BF Vulkan Smoke Frame 1
251
SpriteFrame(92, -88, 32, 32, 404, 299) // #25 - BF Vulkan Smoke Frame 2
252
SpriteFrame(86, -92, 40, 40, 404, 332) // #26 - BF Vulkan Smoke Frame 3
253
SpriteFrame(85, -94, 40, 40, 404, 373) // #27 - BF Vulkan Smoke Frame 4
254
SpriteFrame(76, -90, 16, 16, 421, 257) // #28 - BF Vulkan Smoke Frame 5
255
SpriteFrame(75, -97, 24, 24, 429, 274) // #29 - BF Vulkan Smoke Frame 6
256
SpriteFrame(73, -104, 32, 32, 437, 299) // #30 - BF Vulkan Smoke Frame 7
257
SpriteFrame(76, -107, 32, 32, 445, 332) // #31 - BF Vulkan Smoke Frame 8
258
SpriteFrame(75, -110, 32, 32, 445, 365) // #32 - BF Vulkan Smoke Frame 9
259
260
ArrayPos0 = 32
261
while ArrayPos0 < 1056
262
if Object[ArrayPos0].Type == TypeName[Little Planet]
263
Object[ArrayPos0].XPos = 0
264
Object[ArrayPos0].YPos = 0
265
Object[ArrayPos0].ZoomDepth = 384
266
Object[ArrayPos0].RotationSpeed = -8
267
end if
268
ArrayPos0++
269
loop
270
end sub
271
272
273
// ========================
274
// Editor Subs
275
// ========================
276
277
sub RSDKDraw
278
DrawSprite(0)
279
end sub
280
281
282
sub RSDKLoad
283
LoadSpriteSheet("DAGarden/LittlePlanet.gif")
284
SpriteFrame(-126, -126, 252, 252, 0, 0) // #0 - Little Planet
285
286
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
287
end sub
288
289