Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Special/BGEffects_S1.txt
1319 views
1
//-----------------Sonic CD BGEffects Script------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
// Values 0-1 are unused...
7
#alias Object.Value2 : Object.PrevAngle
8
#alias Object.Value3 : Object.FansTimer
9
#alias Object.Value4 : Object.CrunchersTimer
10
#alias Object.Value5 : Object.FansSprite
11
#alias Object.Value6 : Object.CrunchersSprite
12
13
// Priority
14
#alias 1 : PRIORITY_ACTIVE
15
16
// Deformation Layer
17
#alias 2 : DEFORM_BG
18
19
20
sub ObjectDraw
21
// Animate the Fans
22
Object.FansTimer++
23
if Object.FansTimer > 2
24
Object.FansTimer = 0
25
Object.FansSprite++
26
Object.FansSprite %= 3
27
switch Object.FansSprite
28
case 0
29
// Fans are 4x4 tiles, with 8 unique tiles in them, so
30
// 8 tiles need to be updated to change the entire sprite
31
Copy16x16Tile(260, 420)
32
Copy16x16Tile(259, 421)
33
Copy16x16Tile(258, 422)
34
Copy16x16Tile(257, 423)
35
Copy16x16Tile(264, 424)
36
Copy16x16Tile(263, 425)
37
Copy16x16Tile(262, 426)
38
Copy16x16Tile(261, 427)
39
break
40
41
case 1
42
Copy16x16Tile(260, 428)
43
Copy16x16Tile(259, 429)
44
Copy16x16Tile(258, 430)
45
Copy16x16Tile(257, 431)
46
Copy16x16Tile(264, 432)
47
Copy16x16Tile(263, 433)
48
Copy16x16Tile(262, 434)
49
Copy16x16Tile(261, 435)
50
break
51
52
case 2
53
Copy16x16Tile(260, 436)
54
Copy16x16Tile(259, 437)
55
Copy16x16Tile(258, 438)
56
Copy16x16Tile(257, 439)
57
Copy16x16Tile(264, 440)
58
Copy16x16Tile(263, 441)
59
Copy16x16Tile(262, 442)
60
Copy16x16Tile(261, 443)
61
break
62
63
end switch
64
end if
65
66
// Animate the Crunchers
67
Object.CrunchersTimer++
68
if Object.CrunchersTimer > 5
69
Object.CrunchersTimer = 0
70
Object.CrunchersSprite++
71
Object.CrunchersSprite &= 3
72
switch Object.CrunchersSprite
73
case 0
74
// Crunchers are 2x2 tiles, so 4 tiles need to be updated
75
// in order to completely change their sprite
76
Copy16x16Tile(99, 444)
77
Copy16x16Tile(98, 445)
78
Copy16x16Tile(101, 448)
79
Copy16x16Tile(100, 449)
80
break
81
82
case 1
83
Copy16x16Tile(99, 446)
84
Copy16x16Tile(98, 447)
85
Copy16x16Tile(101, 450)
86
Copy16x16Tile(100, 451)
87
break
88
89
case 2
90
Copy16x16Tile(99, 452)
91
Copy16x16Tile(98, 453)
92
Copy16x16Tile(101, 456)
93
Copy16x16Tile(100, 457)
94
break
95
96
case 3
97
Copy16x16Tile(99, 454)
98
Copy16x16Tile(98, 455)
99
Copy16x16Tile(101, 458)
100
Copy16x16Tile(100, 459)
101
break
102
103
end switch
104
end if
105
106
// Find the difference between the current scroll and last scroll pos
107
TempValue1 = Object.PrevAngle
108
TempValue2 = TileLayer[0].Angle
109
if TempValue1 < TempValue2
110
TempValue3 = TempValue2
111
TempValue3 -= TempValue1
112
if TempValue3 > 256
113
// Account for looping
114
TempValue1 += 512
115
end if
116
else
117
TempValue3 = TempValue1
118
TempValue3 -= TempValue2
119
if TempValue3 > 256
120
// Account for looping (but now the other way!)
121
TempValue2 += 512
122
end if
123
end if
124
125
TempValue0 = TempValue1
126
TempValue0 -= TempValue2
127
128
// Store the current angle for use next frame
129
Object.PrevAngle = TileLayer[0].Angle
130
131
// Move all the other BG layers in accordance with the difference from last frame
132
133
TempValue1 = 0x02000 // This value isn't used, though it corresponds to the first unused background layer
134
TempValue2 = 0x20000
135
TempValue3 = 0x10000
136
137
TempValue1 *= TempValue0 // See above
138
TempValue2 *= TempValue0
139
TempValue3 *= TempValue0
140
141
// Presumably there was one more parallax updating here before that got cut, my best guess is that it'd be something like
142
// HParallax[1].ScrollPos += TempValue1
143
// That would update the background water in the scene, provided the layer is left enabled
144
// HParallax[0] is an option too, that would be the unused wave BG layer (disabled too)
145
146
HParallax[2].ScrollPos += TempValue2
147
HParallax[3].ScrollPos += TempValue3
148
149
end sub
150
151
152
sub ObjectStartup
153
154
// Setup stage bounds
155
Stage.XBoundary1 = 0x3800000 // 896 pixels to the left
156
Stage.XBoundary2 = 0xC800000 // 3200 pixels to the right
157
Stage.YBoundary1 = 0x3800000 // 896 pixels upwards
158
Stage.YBoundary2 = 0xC800000 // 3200 pixels downwards
159
160
// Set the initial BG position
161
162
// Move the first layer 15 pixels to the right
163
// -> I don't believe this does anything, though, as it's shifting the unused BG layer which later gets disabled anyway...
164
HParallax[0].ScrollPos += 0xF0000
165
166
#platform: HW_Rendering
167
// Load the stage map sprite if using the hardware render
168
169
LoadSpriteSheet("Special/SSMap1.gif")
170
#endplatform
171
172
// Setup all BGEffect objects present in the level
173
ArrayPos0 = 32
174
while ArrayPos0 < 1056
175
if Object[ArrayPos0].Type == TypeName[BGEffects]
176
177
// Set this object to always active
178
Object[ArrayPos0].Priority = PRIORITY_ACTIVE
179
180
// Make it be among the first things to be processed for drawing
181
Object[ArrayPos0].DrawOrder = 0
182
183
// Starting angle, assuming that Sonic is starting facing left
184
Object[ArrayPos0].PrevAngle = 368
185
186
end if
187
188
ArrayPos0++
189
loop
190
191
SetLayerDeformation(DEFORM_BG, 128, 16, 0, 0, 0)
192
193
end sub
194
195
196
// ========================
197
// Editor Subs
198
// ========================
199
200
sub RSDKDraw
201
DrawSprite(0)
202
end sub
203
204
205
sub RSDKLoad
206
LoadSpriteSheet("Special/SSMap1.gif")
207
SpriteFrame(-256, -256, 512, 512, 0, 0)
208
209
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
210
end sub
211
212