Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R4/BGEffectsB2.txt
1319 views
1
//------------------Sonic CD BG Effects Script----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Timer
7
#alias Object.Value1 : Object.CurrentPal
8
#alias Object.Value2 : Object.PalDelay
9
10
// Priority
11
#alias 1 : PRIORITY_ACTIVE
12
13
// Deformation Layer
14
#alias 3 : DEFORM_BG_WATER
15
16
// Function declarations
17
#function BGEffects_Deform_Left
18
#function BGEffects_Deform_Right
19
20
21
function BGEffects_Deform_Left
22
Stage[ArrayPos0].DeformationData1 = 1
23
ArrayPos0++
24
Stage[ArrayPos0].DeformationData1 = 1
25
ArrayPos0++
26
Stage[ArrayPos0].DeformationData1 = 2
27
ArrayPos0++
28
Stage[ArrayPos0].DeformationData1 = 2
29
ArrayPos0++
30
Stage[ArrayPos0].DeformationData1 = 3
31
ArrayPos0++
32
Stage[ArrayPos0].DeformationData1 = 3
33
ArrayPos0++
34
Stage[ArrayPos0].DeformationData1 = 3
35
ArrayPos0++
36
Stage[ArrayPos0].DeformationData1 = 3
37
ArrayPos0++
38
Stage[ArrayPos0].DeformationData1 = 2
39
ArrayPos0++
40
Stage[ArrayPos0].DeformationData1 = 2
41
ArrayPos0++
42
Stage[ArrayPos0].DeformationData1 = 1
43
ArrayPos0++
44
Stage[ArrayPos0].DeformationData1 = 1
45
ArrayPos0++
46
end function
47
48
49
function BGEffects_Deform_Right
50
Stage[ArrayPos0].DeformationData1 = -1
51
ArrayPos0++
52
Stage[ArrayPos0].DeformationData1 = -1
53
ArrayPos0++
54
Stage[ArrayPos0].DeformationData1 = -2
55
ArrayPos0++
56
Stage[ArrayPos0].DeformationData1 = -2
57
ArrayPos0++
58
Stage[ArrayPos0].DeformationData1 = -3
59
ArrayPos0++
60
Stage[ArrayPos0].DeformationData1 = -3
61
ArrayPos0++
62
Stage[ArrayPos0].DeformationData1 = -3
63
ArrayPos0++
64
Stage[ArrayPos0].DeformationData1 = -3
65
ArrayPos0++
66
Stage[ArrayPos0].DeformationData1 = -2
67
ArrayPos0++
68
Stage[ArrayPos0].DeformationData1 = -2
69
ArrayPos0++
70
Stage[ArrayPos0].DeformationData1 = -1
71
ArrayPos0++
72
Stage[ArrayPos0].DeformationData1 = -1
73
ArrayPos0++
74
end function
75
76
77
sub ObjectDraw
78
Object.Timer++
79
if Object.Timer > 1
80
TileLayer[0].DeformationOffsetW++
81
TileLayer[1].DeformationOffsetW++
82
Object.Timer = 0
83
end if
84
85
Object.PalDelay++
86
if Object.PalDelay == 3
87
Object.PalDelay = 0
88
Object.CurrentPal++
89
Object.CurrentPal %= 3
90
end if
91
92
TempValue0 = Stage.WaterLevel
93
TempValue0 -= Screen.YOffset
94
if TempValue0 < 0
95
TempValue0 = 0
96
end if
97
98
if TempValue0 > Screen.YSize
99
TempValue0 = Screen.YSize
100
end if
101
102
#platform: SW_Rendering
103
SetActivePalette(Object.CurrentPal, 0, TempValue0)
104
SetActivePalette(7, TempValue0, Screen.YSize)
105
#endplatform
106
107
#platform: HW_Rendering
108
SetActivePalette(Object.CurrentPal, 0, Screen.YSize)
109
DrawRect(0, TempValue0, Screen.XSize, Screen.YSize, 8, 0, 8, 96)
110
#endplatform
111
end sub
112
113
114
sub ObjectStartup
115
ArrayPos0 = 32
116
while ArrayPos0 < 1056
117
if Object[ArrayPos0].Type == TypeName[BGEffects]
118
Object[ArrayPos0].Priority = PRIORITY_ACTIVE
119
Object[ArrayPos0].DrawOrder = 5
120
// This looks dumb, and is dumb, but it's like that
121
#platform: HW_Rendering
122
Object[ArrayPos0].DrawOrder = 5
123
#endplatform
124
#platform: SW_Rendering
125
Object[ArrayPos0].DrawOrder = 0
126
#endplatform
127
end if
128
ArrayPos0++
129
loop
130
131
#platform: SW_Rendering
132
ArrayPos0 = 0
133
CallFunction(BGEffects_Deform_Left)
134
135
ArrayPos0 = 128
136
CallFunction(BGEffects_Deform_Left)
137
138
ArrayPos0 = 160
139
CallFunction(BGEffects_Deform_Right)
140
141
ArrayPos0 = 256
142
while ArrayPos0 < 576
143
ArrayPos1 = ArrayPos0
144
ArrayPos1 -= 256
145
Stage[ArrayPos0].DeformationData1 = Stage[ArrayPos1].DeformationData1
146
ArrayPos0++
147
loop
148
#endplatform
149
150
SetLayerDeformation(DEFORM_BG_WATER, 128, 4, 0, 0, 0)
151
152
LoadPalette("R4B_WaterPal.act", 7, 0, 0, 256)
153
CopyPalette(0, 1)
154
CopyPalette(0, 2)
155
CopyPalette(0, 3)
156
157
TempValue0 = 0
158
TempValue1 = 0
159
TempValue2 = 16
160
while TempValue0 < 4
161
LoadPalette("R4B_PalCycle.act", TempValue0, 176, TempValue1, TempValue2)
162
TempValue1 += 16
163
TempValue2 += 16
164
TempValue0++
165
loop
166
end sub
167
168
169
// ========================
170
// Editor Subs
171
// ========================
172
173
sub RSDKDraw
174
DrawSprite(0)
175
end sub
176
177
178
sub RSDKLoad
179
LoadSpriteSheet("Global/Display.gif")
180
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
181
182
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
183
end sub
184
185
186