Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Title/Clouds.txt
1319 views
1
//------------------Sonic CD Clouds Script--------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.Scroll
7
8
// Face Buffer flags
9
#alias 0 : FACE_FLAG_TEXTURED_3D
10
11
12
sub ObjectDraw
13
// The clouds move at a speed of 8 per second
14
// No good units to good here so let's just leave it at that, "8"...
15
Object.Scroll += 8
16
17
// Loop it around, once it reaches the end
18
Object.Scroll &= 0x7FF
19
20
// Flip it around, to make the Clouds move towards the screen and not away
21
TempValue0 = Object.Scroll
22
FlipSign(TempValue0)
23
24
MatrixTranslateXYZ(MAT_WORLD, -512, 720, TempValue0)
25
26
Draw3DScene()
27
28
end sub
29
30
31
sub ObjectStartup
32
33
// Load the Clouds Sprite Sheet
34
LoadSpriteSheet("Title/Clouds.gif")
35
36
// No Sprite Frames need to be setup,
37
// since this object is doing fun 3d stuff with UV's instead
38
39
3DScene.NoVertices = 0
40
3DScene.NoFaces = 0
41
42
// Note - the numbers getting set here are 0, but they're gonna be overwritten with 0 again a few lines later too
43
ArrayPos0 = 3DScene.NoVertices
44
ArrayPos1 = 3DScene.NoFaces
45
46
// Reset vertexes to their starting position
47
MatrixTranslateXYZ(MAT_WORLD, 0, 0, 0)
48
MatrixRotateXYZ(MAT_WORLD, 0, 0, 0)
49
MatrixRotateXYZ(MAT_VIEW, 8, 0, 0)
50
51
// Lots of values used here...
52
// - ArrayPos0 is the index of the current Vertex
53
// - ArrarPos1 is the index of the current Face
54
// - TempValue0 is a counter for Cloud rows
55
// - TempValue1 is the X Position of the Cloud
56
// - TempValue2 is the Z Position of the Cloud
57
// - TempValue3 is a counter for Cloud columns
58
// - TempValue4 is the X corner of the cloud sprite for the vertex to use
59
// - TempValue5 is the Y corner of the cloud sprite for the vertex to use
60
61
ArrayPos0 = 0
62
ArrayPos1 = 0
63
TempValue2 = 0
64
TempValue3 = 0
65
TempValue4 = 0
66
TempValue5 = 0
67
68
// Make 10 Cloud columns
69
while TempValue3 < 10
70
71
TempValue0 = 0
72
TempValue1 = -0x2000
73
TempValue4 = 0
74
75
// Make 16 Cloud rows
76
while TempValue0 < 16
77
78
// Setup 4 vertexes, for a face
79
// Each face is to be hold a 64x64 texture
80
81
// Top left corner
82
VertexBuffer[ArrayPos0].x = TempValue1
83
VertexBuffer[ArrayPos0].y = 0
84
VertexBuffer[ArrayPos0].z = TempValue2
85
VertexBuffer[ArrayPos0].u = TempValue4
86
VertexBuffer[ArrayPos0].v = TempValue5
87
ArrayPos0++
88
89
// Bottom left corner
90
TempValue2 += 512
91
VertexBuffer[ArrayPos0].x = TempValue1
92
VertexBuffer[ArrayPos0].y = 0
93
VertexBuffer[ArrayPos0].z = TempValue2
94
VertexBuffer[ArrayPos0].u = TempValue4
95
VertexBuffer[ArrayPos0].v = TempValue5
96
VertexBuffer[ArrayPos0].v += 63
97
ArrayPos0++
98
99
// Top right corner
100
TempValue2 -= 512
101
TempValue1 += 1024
102
VertexBuffer[ArrayPos0].x = TempValue1
103
VertexBuffer[ArrayPos0].y = 0
104
VertexBuffer[ArrayPos0].z = TempValue2
105
VertexBuffer[ArrayPos0].u = TempValue4
106
VertexBuffer[ArrayPos0].u += 63
107
VertexBuffer[ArrayPos0].v = TempValue5
108
ArrayPos0++
109
110
// Bottom right corner
111
TempValue2 += 512
112
VertexBuffer[ArrayPos0].x = TempValue1
113
VertexBuffer[ArrayPos0].y = 0
114
VertexBuffer[ArrayPos0].z = TempValue2
115
VertexBuffer[ArrayPos0].u = TempValue4
116
VertexBuffer[ArrayPos0].u += 63
117
VertexBuffer[ArrayPos0].v = TempValue5
118
VertexBuffer[ArrayPos0].v += 63
119
120
TempValue4 += 64
121
TempValue4 &= 255
122
TempValue2 -= 512
123
124
// Move back to the index of the Top Left corner vertex
125
ArrayPos0 -= 3
126
127
// Now, setup the Face's corners
128
129
// Assign the Top Left Vertex - [ArrayPos0 + 0]
130
FaceBuffer[ArrayPos1].a = ArrayPos0
131
132
// Assign the Top Right Vertex - [ArrayPos0 + 2]
133
FaceBuffer[ArrayPos1].b = ArrayPos0
134
FaceBuffer[ArrayPos1].b += 2
135
136
// Assign the Bottom Left Vertex - [ArrayPos0 + 1]
137
FaceBuffer[ArrayPos1].c = ArrayPos0
138
FaceBuffer[ArrayPos1].c += 1
139
140
// Assign the Bottom Right Vertex - [ArrayPos0 + 3]
141
FaceBuffer[ArrayPos1].d = ArrayPos0
142
FaceBuffer[ArrayPos1].d += 3
143
144
// And then set up the Face's Flag to be a FACE_TEXTURED_3D flag, since the Cloud sprites are to be projected onto the face and all
145
FaceBuffer[ArrayPos1].Flag = FACE_FLAG_TEXTURED_3D
146
147
// Now, get ready for the next face
148
149
// Bump Vertex index by 4
150
ArrayPos0 += 4
151
152
// Face Vertex only needs to be bumped by 1
153
ArrayPos1++
154
155
TempValue0++
156
157
// And then we want it all to actually render too, so bump up the 3DScene rendering values as well
158
3DScene.NoVertices += 4
159
3DScene.NoFaces++
160
161
loop
162
163
// And now, next column
164
TempValue5 += 64
165
TempValue5 &= 255
166
TempValue2 += 512
167
TempValue3++
168
169
loop
170
171
end sub
172
173
174
// ========================
175
// Editor Subs
176
// ========================
177
178
sub RSDKDraw
179
DrawSprite(0)
180
end sub
181
182
183
sub RSDKLoad
184
LoadSpriteSheet("Title/Clouds.gif")
185
SpriteFrame(-128, -128, 256, 256, 0, 0)
186
187
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
188
end sub
189
190