Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R4/BGEffectsC.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
// 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
TempValue0 = Stage.WaterLevel
86
TempValue0 -= Screen.YOffset
87
if TempValue0 < 0
88
TempValue0 = 0
89
end if
90
91
if TempValue0 > Screen.YSize
92
TempValue0 = Screen.YSize
93
end if
94
95
SetActivePalette(BGAnimation.CurrentPal, 0, TempValue0)
96
97
#platform: SW_Rendering
98
SetActivePalette(7, TempValue0, Screen.YSize)
99
#endplatform
100
101
#platform: HW_Rendering
102
DrawRect(0, TempValue0, Screen.XSize, Screen.YSize, 0, 160, 48, 104)
103
#endplatform
104
end sub
105
106
107
sub ObjectStartup
108
ArrayPos0 = 32
109
while ArrayPos0 < 1056
110
if Object[ArrayPos0].Type == TypeName[BGEffects]
111
Object[ArrayPos0].Priority = PRIORITY_ACTIVE
112
Object[ArrayPos0].DrawOrder = 5
113
// This looks dumb, and is dumb, but it's like that
114
#platform: HW_Rendering
115
Object[ArrayPos0].DrawOrder = 5
116
#endplatform
117
#platform: SW_Rendering
118
Object[ArrayPos0].DrawOrder = 0
119
#endplatform
120
end if
121
ArrayPos0++
122
loop
123
124
#platform: SW_Rendering
125
ArrayPos0 = 0
126
CallFunction(BGEffects_Deform_Left)
127
128
ArrayPos0 = 128
129
CallFunction(BGEffects_Deform_Left)
130
131
ArrayPos0 = 160
132
CallFunction(BGEffects_Deform_Right)
133
134
ArrayPos0 = 256
135
while ArrayPos0 < 576
136
ArrayPos1 = ArrayPos0
137
ArrayPos1 -= 256
138
Stage[ArrayPos0].DeformationData1 = Stage[ArrayPos1].DeformationData1
139
ArrayPos0++
140
loop
141
#endplatform
142
143
SetLayerDeformation(DEFORM_BG_WATER, 128, 4, 0, 0, 0)
144
145
LoadPalette("R4C_WaterPal.act", 7, 0, 0, 256)
146
end sub
147
148
149
// ========================
150
// Editor Subs
151
// ========================
152
153
sub RSDKDraw
154
DrawSprite(0)
155
end sub
156
157
158
sub RSDKLoad
159
LoadSpriteSheet("Global/Display.gif")
160
SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon
161
162
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
163
end sub
164
165
166