Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Special/BGEffects_S7.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 in the level
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
Copy16x16Tile(269, 484)
27
Copy16x16Tile(270, 485)
28
Copy16x16Tile(271, 486)
29
Copy16x16Tile(272, 487)
30
Copy16x16Tile(273, 488)
31
Copy16x16Tile(274, 489)
32
Copy16x16Tile(275, 490)
33
Copy16x16Tile(276, 491)
34
break
35
36
case 1
37
Copy16x16Tile(269, 492)
38
Copy16x16Tile(270, 493)
39
Copy16x16Tile(271, 494)
40
Copy16x16Tile(272, 495)
41
Copy16x16Tile(273, 496)
42
Copy16x16Tile(274, 497)
43
Copy16x16Tile(275, 498)
44
Copy16x16Tile(276, 499)
45
break
46
47
case 2
48
Copy16x16Tile(269, 500)
49
Copy16x16Tile(270, 501)
50
Copy16x16Tile(271, 502)
51
Copy16x16Tile(272, 503)
52
Copy16x16Tile(273, 504)
53
Copy16x16Tile(274, 505)
54
Copy16x16Tile(275, 506)
55
Copy16x16Tile(276, 507)
56
break
57
58
end switch
59
end if
60
61
// Animate the crunchers in the level
62
Object.CrunchersTimer++
63
if Object.CrunchersTimer > 5
64
Object.CrunchersTimer = 0
65
Object.CrunchersSprite++
66
Object.CrunchersSprite &= 3
67
switch Object.CrunchersSprite
68
case 0
69
Copy16x16Tile(129, 508)
70
Copy16x16Tile(130, 509)
71
Copy16x16Tile(134, 512)
72
Copy16x16Tile(135, 513)
73
break
74
75
case 1
76
Copy16x16Tile(129, 510)
77
Copy16x16Tile(130, 511)
78
Copy16x16Tile(134, 514)
79
Copy16x16Tile(135, 515)
80
break
81
82
case 2
83
Copy16x16Tile(129, 516)
84
Copy16x16Tile(130, 517)
85
Copy16x16Tile(134, 520)
86
Copy16x16Tile(135, 521)
87
break
88
89
case 3
90
Copy16x16Tile(129, 518)
91
Copy16x16Tile(130, 519)
92
Copy16x16Tile(134, 522)
93
Copy16x16Tile(135, 523)
94
break
95
96
end switch
97
end if
98
99
// Move all the BG layers based on the scroll difference from last frame
100
101
TempValue1 = Object.PrevAngle
102
TempValue2 = TileLayer[0].Angle
103
if TempValue1 < TempValue2
104
TempValue3 = TempValue2
105
TempValue3 -= TempValue1
106
if TempValue3 > 256
107
TempValue1 += 512
108
end if
109
else
110
TempValue3 = TempValue1
111
TempValue3 -= TempValue2
112
if TempValue3 > 256
113
TempValue2 += 512
114
end if
115
end if
116
117
TempValue0 = TempValue1
118
TempValue0 -= TempValue2
119
120
// Store the current angle so that the same thing can be done next frame
121
Object.PrevAngle = TileLayer[0].Angle
122
123
TempValue1 = 0x10000
124
TempValue2 = 0x20000
125
TempValue3 = 0x30000
126
127
TempValue1 *= TempValue0
128
TempValue2 *= TempValue0
129
TempValue3 *= TempValue0
130
131
HParallax[0].ScrollPos += TempValue1
132
HParallax[1].ScrollPos += TempValue2
133
HParallax[2].ScrollPos += TempValue3
134
135
end sub
136
137
138
sub ObjectStartup
139
140
Stage.XBoundary1 = 0x2800000 // left bounds of 640 pixels
141
Stage.XBoundary2 = 0xD800000 // right bounds of 3456 pixels
142
Stage.YBoundary1 = 0x2800000 // upper bounds of 640 pixels
143
Stage.YBoundary2 = 0xD800000 // lower bounds of 3456 pixels
144
145
#platform: HW_Rendering
146
// Load the Sprite version of the stage map if needed
147
148
LoadSpriteSheet("Special/SSMap7.gif")
149
#endplatform
150
151
// Set the initial BG positions, offset by 128 pixels
152
HParallax[0].ScrollPos += 0x800000
153
HParallax[2].ScrollPos -= 0x800000
154
155
// Setup any and all BGEffects objects that may be present in the level
156
// Though, there should only ever be one
157
158
ArrayPos0 = 32
159
while ArrayPos0 < 1056
160
if Object[ArrayPos0].Type == TypeName[BGEffects]
161
162
// Set the object to always active
163
Object[ArrayPos0].Priority = PRIORITY_ACTIVE
164
165
// Give it a low draw order
166
Object[ArrayPos0].DrawOrder = 0
167
168
// And set its starting angle
169
// But all other stages use 368... why is this one different?
170
Object[ArrayPos0].Value2 = 256
171
172
end if
173
174
ArrayPos0++
175
loop
176
177
end sub
178
179
180
// ========================
181
// Editor Subs
182
// ========================
183
184
sub RSDKDraw
185
DrawSprite(0)
186
end sub
187
188
189
sub RSDKLoad
190
LoadSpriteSheet("Special/SSMap7.gif")
191
SpriteFrame(-256, -256, 512, 512, 0, 0)
192
193
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
194
end sub
195
196