Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R7/R7BSetup.txt
1319 views
1
//-----------------Sonic CD R7 B Setup Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.DeformTimer
7
// Value1 is skipped over...
8
#alias Object.Value2 : Object.FlamesTimer
9
10
// Collision Modes
11
#alias 0 : CMODE_FLOOR
12
13
// Priority
14
#alias 1 : PRIORITY_ACTIVE
15
16
// Tile Info
17
#alias 0 : TILEINFO_INDEX
18
#alias 8 : TILEINFO_ANGLEB
19
20
// Deformation Layer
21
#alias 2 : DEFORM_BG
22
23
// Function declarations
24
#function R7Setup_GetLoopTileInfo
25
26
27
function R7Setup_GetLoopTileInfo
28
// Gets info from out of bounds chunks, located past the signpost
29
30
// Precondition:
31
// - TempValue0 is the chunk ID of the chunk currentbly being checked against
32
33
TempValue3 = Player.XPos
34
TempValue3 >>= 16
35
TempValue3 &= 255
36
TempValue3 += 0x3100
37
38
TempValue0 -= 16
39
TempValue0 >>= 2
40
TempValue0 <<= 8
41
TempValue4 = Player.YPos
42
TempValue4 >>= 16
43
TempValue4 &= 255
44
TempValue4 += TempValue0
45
46
Get16x16TileInfo(TempValue0, TempValue3, TempValue4, TILEINFO_INDEX)
47
end function
48
49
50
sub ObjectMain
51
52
// Make the lake in the BG ripple its surfacec a little bit
53
Object.DeformTimer++
54
if Object.DeformTimer > 1
55
TileLayer[1].DeformationOffset++
56
Object.DeformTimer = 0
57
end if
58
59
// Update the Flames counter too
60
if Object.FlamesTimer > 0
61
Object.FlamesTimer--
62
end if
63
64
end sub
65
66
67
sub ObjectPlayerInteraction
68
69
// "Layers" are managed here
70
// (In reality, chunks are swapped on-the-fly in order to make it appear as if the player's moving behind/in front of them)
71
72
// Get the position of the chunk the player's currently in
73
TempValue1 = Player.XPos
74
TempValue1 >>= 23
75
TempValue2 = Player.YPos
76
TempValue2 >>= 23
77
78
// And find what chunk ID it corresponds to
79
GetTileLayerEntry(TempValue0, 0, TempValue1, TempValue2)
80
81
// If applicable, jump to the loop chunk set it corresponds to
82
switch TempValue0
83
case 16
84
case 17
85
case 18
86
case 19
87
// Loop chunks, open from left side
88
CallFunction(R7Setup_GetLoopTileInfo)
89
if Player.CollisionMode == CMODE_FLOOR
90
if TempValue0 == 1001
91
TempValue1 &= 1022
92
TempValue2 &= 1022
93
SetTileLayerEntry(20, 0, TempValue1, TempValue2)
94
TempValue1++
95
SetTileLayerEntry(21, 0, TempValue1, TempValue2)
96
TempValue1--
97
TempValue2++
98
SetTileLayerEntry(22, 0, TempValue1, TempValue2)
99
TempValue1++
100
SetTileLayerEntry(23, 0, TempValue1, TempValue2)
101
end if
102
else
103
if Player.Speed > 0
104
if TempValue0 == 1003
105
TempValue1 &= 1022
106
TempValue2 &= 1022
107
SetTileLayerEntry(20, 0, TempValue1, TempValue2)
108
TempValue1++
109
SetTileLayerEntry(21, 0, TempValue1, TempValue2)
110
TempValue1--
111
TempValue2++
112
SetTileLayerEntry(22, 0, TempValue1, TempValue2)
113
TempValue1++
114
SetTileLayerEntry(23, 0, TempValue1, TempValue2)
115
end if
116
end if
117
end if
118
break
119
120
case 20
121
case 21
122
case 22
123
case 23
124
// Loop chunks, open from right side
125
CallFunction(R7Setup_GetLoopTileInfo)
126
if Player.CollisionMode == CMODE_FLOOR
127
if TempValue0 == 1000
128
TempValue1 &= 1022
129
TempValue2 &= 1022
130
SetTileLayerEntry(16, 0, TempValue1, TempValue2)
131
TempValue1++
132
SetTileLayerEntry(17, 0, TempValue1, TempValue2)
133
TempValue1--
134
TempValue2++
135
SetTileLayerEntry(18, 0, TempValue1, TempValue2)
136
TempValue1++
137
SetTileLayerEntry(19, 0, TempValue1, TempValue2)
138
end if
139
else
140
if Player.Speed < 0
141
if TempValue0 == 1002
142
TempValue1 &= 1022
143
TempValue2 &= 1022
144
SetTileLayerEntry(16, 0, TempValue1, TempValue2)
145
TempValue1++
146
SetTileLayerEntry(17, 0, TempValue1, TempValue2)
147
TempValue1--
148
TempValue2++
149
SetTileLayerEntry(18, 0, TempValue1, TempValue2)
150
TempValue1++
151
SetTileLayerEntry(19, 0, TempValue1, TempValue2)
152
end if
153
end if
154
end if
155
break
156
157
case 24
158
case 25
159
case 26
160
case 27
161
// Wavy chunks, open from left side
162
CallFunction(R7Setup_GetLoopTileInfo)
163
if TempValue0 == 1001
164
TempValue1 &= 1022
165
TempValue2 &= 1022
166
SetTileLayerEntry(28, 0, TempValue1, TempValue2)
167
TempValue1++
168
SetTileLayerEntry(29, 0, TempValue1, TempValue2)
169
TempValue1--
170
TempValue2++
171
SetTileLayerEntry(30, 0, TempValue1, TempValue2)
172
TempValue1++
173
SetTileLayerEntry(31, 0, TempValue1, TempValue2)
174
end if
175
break
176
177
case 28
178
case 29
179
case 30
180
case 31
181
// Wavy chunks, open from right side
182
CallFunction(R7Setup_GetLoopTileInfo)
183
if TempValue0 == 1000
184
TempValue1 &= 1022
185
TempValue2 &= 1022
186
SetTileLayerEntry(24, 0, TempValue1, TempValue2)
187
TempValue1++
188
SetTileLayerEntry(25, 0, TempValue1, TempValue2)
189
TempValue1--
190
TempValue2++
191
SetTileLayerEntry(26, 0, TempValue1, TempValue2)
192
TempValue1++
193
SetTileLayerEntry(27, 0, TempValue1, TempValue2)
194
end if
195
break
196
197
end switch
198
199
if Object.FlamesTimer == 0
200
201
// Get the absolute version of the Player's speed
202
TempValue0 = Player.Speed
203
if TempValue0 < 0
204
FlipSign(TempValue0)
205
end if
206
207
// Is the player going at a speed above 10 pixels?
208
if TempValue0 > 0xA0000
209
TempValue3 = Player.XPos
210
TempValue3 >>= 16
211
212
TempValue4 = Player.YPos
213
TempValue4 >>= 16
214
TempValue4 += 8
215
216
// See if the player's on a flammable tile
217
Get16x16TileInfo(TempValue0, TempValue3, TempValue4, TILEINFO_ANGLEB)
218
219
if TempValue0 == 1
220
Object.FlamesTimer = 4
221
222
// Spawn a Flame Trail behind the player
223
CreateTempObject(TypeName[Fire Trail], 0, Player.XPos, Player.YPos)
224
if Player.Speed < 0
225
Object[TempObjectPos].Direction = FACING_LEFT
226
else
227
Object[TempObjectPos].Direction = FACING_RIGHT
228
end if
229
Object[TempObjectPos].DrawOrder = 4
230
Object[TempObjectPos].iYPos += Player.CollisionBottom
231
232
end if
233
end if
234
end if
235
236
end sub
237
238
239
sub ObjectStartup
240
241
// Place the setup object into reserved object slt 19 and make it always active
242
Object[19].Type = TypeName[R7 Setup]
243
Object[19].Priority = PRIORITY_ACTIVE
244
245
// Set initial deformation data for the BG water
246
SetLayerDeformation(DEFORM_BG, 128, 8, 0, 0, 0)
247
248
end sub
249
250
251
// ========================
252
// Editor Subs
253
// ========================
254
255
sub RSDKDraw
256
DrawSprite(0)
257
end sub
258
259
260
sub RSDKLoad
261
LoadSpriteSheet("Global/Display.gif")
262
SpriteFrame(-16, -16, 32, 32, 1, 143) // "Script" Icon
263
264
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
265
end sub
266
267