Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Special/BGEffects_S2.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
17
sub ObjectDraw
18
// Animate the Fans
19
Object.FansTimer++
20
if Object.FansTimer > 2
21
Object.FansTimer = 0
22
Object.FansSprite++
23
Object.FansSprite %= 3
24
switch Object.FansSprite
25
case 0
26
// Fans are 4x4 tiles, with 8 unique tiles in them, so
27
// 8 tiles need to be updated to change the entire sprite
28
Copy16x16Tile(122, 428)
29
Copy16x16Tile(123, 429)
30
Copy16x16Tile(124, 430)
31
Copy16x16Tile(125, 431)
32
Copy16x16Tile(126, 432)
33
Copy16x16Tile(127, 433)
34
Copy16x16Tile(128, 434)
35
Copy16x16Tile(129, 435)
36
break
37
38
case 1
39
Copy16x16Tile(122, 436)
40
Copy16x16Tile(123, 437)
41
Copy16x16Tile(124, 438)
42
Copy16x16Tile(125, 439)
43
Copy16x16Tile(126, 440)
44
Copy16x16Tile(127, 441)
45
Copy16x16Tile(128, 442)
46
Copy16x16Tile(129, 443)
47
break
48
49
case 2
50
Copy16x16Tile(122, 444)
51
Copy16x16Tile(123, 445)
52
Copy16x16Tile(124, 446)
53
Copy16x16Tile(125, 447)
54
Copy16x16Tile(126, 448)
55
Copy16x16Tile(127, 449)
56
Copy16x16Tile(128, 450)
57
Copy16x16Tile(129, 451)
58
break
59
60
end switch
61
end if
62
63
// Animate the Crunchers
64
Object.CrunchersTimer++
65
if Object.CrunchersTimer > 5
66
Object.CrunchersTimer = 0
67
Object.CrunchersSprite++
68
Object.CrunchersSprite &= 3
69
switch Object.CrunchersSprite
70
case 0
71
Copy16x16Tile(157, 452)
72
Copy16x16Tile(158, 453)
73
Copy16x16Tile(159, 456)
74
Copy16x16Tile(160, 457)
75
break
76
77
case 1
78
Copy16x16Tile(157, 454)
79
Copy16x16Tile(158, 455)
80
Copy16x16Tile(159, 458)
81
Copy16x16Tile(160, 459)
82
break
83
84
case 2
85
Copy16x16Tile(157, 460)
86
Copy16x16Tile(158, 461)
87
Copy16x16Tile(159, 464)
88
Copy16x16Tile(160, 465)
89
break
90
91
case 3
92
Copy16x16Tile(157, 462)
93
Copy16x16Tile(158, 463)
94
Copy16x16Tile(159, 466)
95
Copy16x16Tile(160, 467)
96
break
97
98
end switch
99
end if
100
101
// Find the difference between the current scroll and last scroll pos
102
TempValue1 = Object.PrevAngle
103
TempValue2 = TileLayer[0].Angle
104
if TempValue1 < TempValue2
105
TempValue3 = TempValue2
106
TempValue3 -= TempValue1
107
if TempValue3 > 256
108
// Account for looping
109
TempValue1 += 512
110
end if
111
else
112
TempValue3 = TempValue1
113
TempValue3 -= TempValue2
114
if TempValue3 > 256
115
// Account for looping
116
TempValue2 += 512
117
end if
118
end if
119
120
TempValue0 = TempValue1
121
TempValue0 -= TempValue2
122
123
// Store the current angle for use next frame
124
Object.PrevAngle = TileLayer[0].Angle
125
126
// Move all the other BG layers in accordance with the difference from last frame
127
TempValue1 = 0x20000
128
TempValue2 = 0x10000
129
130
TempValue1 *= TempValue0
131
TempValue2 *= TempValue0
132
133
HParallax[0].ScrollPos += TempValue1
134
HParallax[1].ScrollPos += TempValue2
135
136
end sub
137
138
139
sub ObjectStartup
140
141
// Set stage bounds
142
Stage.XBoundary1 = 0x3800000 // 896 pixels to the left
143
Stage.XBoundary2 = 0xC800000 // 3200 pixels to the right
144
Stage.YBoundary1 = 0x3800000 // 896 pixels upwards
145
Stage.YBoundary2 = 0xC800000 // 3200 pixels downwards
146
147
#platform: HW_Rendering
148
// Load the stage map if using the hardware render
149
150
LoadSpriteSheet("Special/SSMap2.gif")
151
#endplatform
152
153
// Setup all BGEffect objects present in the level
154
ArrayPos0 = 32
155
while ArrayPos0 < 1056
156
if Object[ArrayPos0].Type == TypeName[BGEffects]
157
158
// Set the object to always be active
159
Object[ArrayPos0].Priority = PRIORITY_ACTIVE
160
161
// Place the object among the first to be drawn
162
Object[ArrayPos0].DrawOrder = 0
163
164
// And set its starting angle, assuming that Sonic is facing left
165
Object[ArrayPos0].PrevAngle = 368
166
167
end if
168
169
ArrayPos0++
170
loop
171
172
end sub
173
174
175
// ========================
176
// Editor Subs
177
// ========================
178
179
sub RSDKDraw
180
DrawSprite(0)
181
end sub
182
183
184
sub RSDKLoad
185
LoadSpriteSheet("Special/SSMap2.gif")
186
SpriteFrame(-256, -256, 512, 512, 0, 0)
187
188
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
189
end sub
190
191