Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Special/BGEffects_S6.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
#alias Object.Value0 : Object.DeformTimer
7
#alias Object.Value1 : Object.PaletteTimer
8
#alias Object.Value2 : Object.PrevAngle
9
#alias Object.Value3 : Object.FansTimer
10
#alias Object.Value4 : Object.CrunchersTimer
11
#alias Object.Value5 : Object.FansSprite
12
#alias Object.Value6 : Object.CrunchersSprite
13
14
// Priority
15
#alias 1 : PRIORITY_ACTIVE
16
17
// Deformation Layer
18
#alias 2 : DEFORM_BG
19
20
21
sub ObjectDraw
22
// Animate the fans in the stage
23
Object.FansTimer++
24
if Object.FansTimer > 2
25
Object.FansTimer = 0
26
Object.FansSprite++
27
Object.FansSprite %= 3
28
switch Object.FansSprite
29
case 0
30
// Fans are 4x4 tiles, comprised of 8 unique tiles, so
31
// 8 individual tiles need to be updated to change the entire sprite
32
Copy16x16Tile(37, 348)
33
Copy16x16Tile(38, 349)
34
Copy16x16Tile(39, 350)
35
Copy16x16Tile(40, 351)
36
Copy16x16Tile(41, 352)
37
Copy16x16Tile(42, 353)
38
Copy16x16Tile(43, 354)
39
Copy16x16Tile(44, 355)
40
break
41
42
case 1
43
Copy16x16Tile(37, 356)
44
Copy16x16Tile(38, 357)
45
Copy16x16Tile(39, 358)
46
Copy16x16Tile(40, 359)
47
Copy16x16Tile(41, 360)
48
Copy16x16Tile(42, 361)
49
Copy16x16Tile(43, 362)
50
Copy16x16Tile(44, 363)
51
break
52
53
case 2
54
Copy16x16Tile(37, 364)
55
Copy16x16Tile(38, 365)
56
Copy16x16Tile(39, 366)
57
Copy16x16Tile(40, 367)
58
Copy16x16Tile(41, 368)
59
Copy16x16Tile(42, 369)
60
Copy16x16Tile(43, 370)
61
Copy16x16Tile(44, 371)
62
break
63
64
end switch
65
end if
66
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, each tile unique,
75
// so 4 tiles need to be updated in order to completely change their sprite
76
Copy16x16Tile(134, 372)
77
Copy16x16Tile(135, 373)
78
Copy16x16Tile(136, 376)
79
Copy16x16Tile(137, 377)
80
break
81
82
case 1
83
Copy16x16Tile(134, 374)
84
Copy16x16Tile(135, 375)
85
Copy16x16Tile(136, 378)
86
Copy16x16Tile(137, 379)
87
break
88
89
case 2
90
Copy16x16Tile(134, 380)
91
Copy16x16Tile(135, 381)
92
Copy16x16Tile(136, 384)
93
Copy16x16Tile(137, 385)
94
break
95
96
case 3
97
Copy16x16Tile(134, 382)
98
Copy16x16Tile(135, 383)
99
Copy16x16Tile(136, 386)
100
Copy16x16Tile(137, 387)
101
break
102
103
end switch
104
end if
105
106
// Make the background all loopy
107
Object.DeformTimer++
108
if Object.DeformTimer > 1
109
TileLayer[1].DeformationOffset++
110
Object.DeformTimer = 0
111
end if
112
113
#platform: SW_Rendering
114
// Animate the stage's palette for the background
115
// Palette changing is only available with the Software renderer,
116
// check out the HW Background Object for what's used with the Hardware renderer
117
118
Object.PaletteTimer++
119
120
if Object.PaletteTimer > 3
121
Object.PaletteTimer = 0
122
RotatePalette(209, 221, false)
123
end if
124
#endplatform
125
126
// Find the difference between the current angle and the last angle
127
TempValue1 = Object.PrevAngle
128
TempValue2 = TileLayer[0].Angle
129
if TempValue1 < TempValue2
130
TempValue3 = TempValue2
131
TempValue3 -= TempValue1
132
if TempValue3 > 256
133
TempValue1 += 512
134
end if
135
else
136
TempValue3 = TempValue1
137
TempValue3 -= TempValue2
138
if TempValue3 > 256
139
TempValue2 += 512
140
end if
141
end if
142
143
TempValue0 = TempValue1
144
TempValue0 -= TempValue2
145
146
// Store the current angle for the same process next frame
147
Object.PrevAngle = TileLayer[0].Angle
148
149
// Scroll the BG with parallax
150
TempValue1 = 0x02000 // An eight of a pixel, unused
151
TempValue2 = 0x20000 // 2 pixels
152
153
TempValue1 *= TempValue0 // There was likely some layer this corresponded to, but in the final version, only the buildings layer [1] gets moved
154
TempValue2 *= TempValue0
155
156
// Perhaps the unused value corresponded to the wave background - [0]?
157
HParallax[1].ScrollPos += TempValue2
158
159
end sub
160
161
162
sub ObjectStartup
163
164
// Setup Stage Bounds
165
// Aside from the Robotnik stage (which uses copies of these same numbers), this seems to be the only Special Stage with uneven left/right and top/bottom bounds
166
Stage.XBoundary1 = 0x2800000 // left bounds at 640 pixels
167
Stage.XBoundary2 = 0xD800000 // right bounds at 3456 pixels
168
Stage.YBoundary1 = 0x3000000 // upper bounds at 768 pixels
169
Stage.YBoundary2 = 0xD000000 // lower bounds at 3328 pixels
170
171
// Reset deformation
172
SetLayerDeformation(DEFORM_BG, 64, 64, 0, 0, 0)
173
174
#platform: HW_Rendering
175
// Load the map as a sheet if needed for the hardware renderer
176
177
LoadSpriteSheet("Special/SSMap6.gif")
178
#endplatform
179
180
// Setup all BGEffects objects in the level
181
// (There should only ever be one though)
182
ArrayPos0 = 32
183
while ArrayPos0 < 1056
184
if Object[ArrayPos0].Type == TypeName[BGEffects]
185
// Initialise its values
186
187
// Make the object always active, as the stage should always animate even when its animator object is out of bounds
188
Object[ArrayPos0].Priority = PRIORITY_ACTIVE
189
190
// Make the object the first thing to be drawn
191
Object[ArrayPos0].DrawOrder = 0
192
193
// And setup its starting angle too, assuming Sonic's starting facing left
194
Object[ArrayPos0].PrevAngle = 368
195
196
end if
197
198
ArrayPos0++
199
loop
200
201
end sub
202
203
204
// ========================
205
// Editor Subs
206
// ========================
207
208
sub RSDKDraw
209
DrawSprite(0)
210
end sub
211
212
213
sub RSDKLoad
214
LoadSpriteSheet("Special/SSMap6.gif")
215
SpriteFrame(-256, -256, 512, 512, 0, 0)
216
217
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
218
end sub
219
220