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