Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Special/BGEffects_S8.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 that are 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
// Fans are 4x4 tiles, comprised of 8 unique tiles, so
27
// 8 tiles need to be updated to change the entire sprite
28
Copy16x16Tile(237, 308)
29
Copy16x16Tile(238, 309)
30
Copy16x16Tile(239, 310)
31
Copy16x16Tile(240, 311)
32
Copy16x16Tile(241, 312)
33
Copy16x16Tile(242, 313)
34
Copy16x16Tile(243, 314)
35
Copy16x16Tile(244, 315)
36
break
37
38
case 1
39
Copy16x16Tile(237, 316)
40
Copy16x16Tile(238, 317)
41
Copy16x16Tile(239, 318)
42
Copy16x16Tile(240, 319)
43
Copy16x16Tile(241, 320)
44
Copy16x16Tile(242, 321)
45
Copy16x16Tile(243, 322)
46
Copy16x16Tile(244, 323)
47
break
48
49
case 2
50
Copy16x16Tile(237, 324)
51
Copy16x16Tile(238, 325)
52
Copy16x16Tile(239, 326)
53
Copy16x16Tile(240, 327)
54
Copy16x16Tile(241, 328)
55
Copy16x16Tile(242, 329)
56
Copy16x16Tile(243, 330)
57
Copy16x16Tile(244, 331)
58
break
59
60
end switch
61
end if
62
63
// Animate the hungry crunchers throughout the level, too
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
// Crunchers are 2x2 tiles, so 4 tiles need to be updated
72
// in order to completely change their sprite
73
Copy16x16Tile(135, 332)
74
Copy16x16Tile(136, 333)
75
Copy16x16Tile(137, 336)
76
Copy16x16Tile(138, 337)
77
break
78
79
case 1
80
Copy16x16Tile(135, 334)
81
Copy16x16Tile(136, 335)
82
Copy16x16Tile(137, 338)
83
Copy16x16Tile(138, 339)
84
break
85
86
case 2
87
Copy16x16Tile(135, 340)
88
Copy16x16Tile(136, 341)
89
Copy16x16Tile(137, 344)
90
Copy16x16Tile(138, 345)
91
break
92
93
case 3
94
Copy16x16Tile(135, 342)
95
Copy16x16Tile(136, 343)
96
Copy16x16Tile(137, 346)
97
Copy16x16Tile(138, 347)
98
break
99
100
end switch
101
end if
102
103
// Find the difference between the current scroll position and the last scroll position... but nothing's really done with the result
104
// This script was likely just copied over from the other BGEffects scripts, and this was never removed
105
TempValue1 = Object.PrevAngle
106
TempValue2 = TileLayer[0].Angle
107
if TempValue1 < TempValue2
108
TempValue3 = TempValue2
109
TempValue3 -= TempValue1
110
if TempValue3 > 256
111
TempValue1 += 512
112
end if
113
else
114
TempValue3 = TempValue1
115
TempValue3 -= TempValue2
116
if TempValue3 > 256
117
TempValue2 += 512
118
end if
119
end if
120
121
// Object.PrevAngle would normally be updated here, it looks like at least *some* effort was taken to remove the useless code
122
123
end sub
124
125
126
sub ObjectStartup
127
128
// Setup stage bounds
129
// Interestingly, this stage has different widths and heights, not making it a square like the others
130
Stage.XBoundary1 = 0x2800000 // left bounds at 640 pixels
131
Stage.XBoundary2 = 0xD800000 // right bounds at 3456 pixels
132
Stage.YBoundary1 = 0x3000000 // upper bounds at 768 pixels
133
Stage.YBoundary2 = 0xD000000 // lower bounds at 3328 pixels
134
135
#platform: HW_Rendering
136
// Load the stage map as a sprite if needed
137
138
LoadSpriteSheet("Special/SSMap8.gif")
139
#endplatform
140
141
// Center the stage's background so that Robotnik's amazing mug can be in the middle of the screen
142
TempValue0 = Screen.XSize
143
TempValue0 -= 320
144
145
// Shouldn't this be <<= 16? If it's going from screen-space to world-space...
146
TempValue0 <<= 15
147
148
// Base position of 96 pixels
149
HParallax[0].ScrollPos = 0x600000
150
151
// And then shift it as needed to match up centre screen
152
HParallax[0].ScrollPos -= TempValue0
153
154
// Cycle through all BGEffects objects and set them up
155
ArrayPos0 = 32
156
while ArrayPos0 < 1056
157
if Object[ArrayPos0].Type == TypeName[BGEffects]
158
159
// Make the object always be run, since fans and tiles should be animated always
160
Object[ArrayPos0].Priority = PRIORITY_ACTIVE
161
162
// Give it the lowest draw order as well, in order to make it run before other objects' draw events
163
Object[ArrayPos0].DrawOrder = 0
164
165
// Set the initial starting angle, although it's not really used...
166
Object[ArrayPos0].PrevAngle = 368
167
168
end if
169
170
ArrayPos0++
171
loop
172
173
end sub
174
175
176
// ========================
177
// Editor Subs
178
// ========================
179
180
sub RSDKDraw
181
DrawSprite(0)
182
end sub
183
184
185
sub RSDKLoad
186
LoadSpriteSheet("Special/SSMap8.gif")
187
SpriteFrame(-256, -256, 512, 512, 0, 0)
188
189
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
190
end sub
191
192