Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R7/R7CSetup.txt
1319 views
1
//-----------------Sonic CD R7 C Setup Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value2 : Object.FlamesTimer
7
8
// Collision Modes
9
#alias 0 : CMODE_FLOOR
10
11
// Priority
12
#alias 1 : PRIORITY_ACTIVE
13
14
// Tile Info
15
#alias 0 : TILEINFO_INDEX
16
#alias 8 : TILEINFO_ANGLEB
17
18
19
// Function declarations
20
#function R7Setup_GetLoopTileInfo
21
22
23
function R7Setup_GetLoopTileInfo
24
// Gets info from out of bounds chunks, located past the signpost
25
26
// Precondition:
27
// - TempValue0 is the chunk ID of the chunk currentbly being checked against
28
29
TempValue3 = Player.XPos
30
TempValue3 >>= 16
31
TempValue3 &= 255
32
TempValue3 += 0x3100
33
34
TempValue0 -= 16
35
TempValue0 >>= 2
36
TempValue0 <<= 8
37
TempValue4 = Player.YPos
38
TempValue4 >>= 16
39
TempValue4 &= 255
40
TempValue4 += TempValue0
41
42
Get16x16TileInfo(TempValue0, TempValue3, TempValue4, TILEINFO_INDEX)
43
end function
44
45
46
sub ObjectMain
47
if Object.FlamesTimer > 0
48
Object.FlamesTimer--
49
end if
50
end sub
51
52
53
sub ObjectPlayerInteraction
54
55
// "Layers" are managed here
56
// (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)
57
58
// Get the position of the chunk the player's currently in
59
TempValue1 = Player.XPos
60
TempValue1 >>= 23
61
TempValue2 = Player.YPos
62
TempValue2 >>= 23
63
64
// And find what chunk ID it is
65
GetTileLayerEntry(TempValue0, 0, TempValue1, TempValue2)
66
67
// If applicable, jump to the loop chunk set it corresponds to
68
switch TempValue0
69
case 16
70
case 17
71
case 18
72
case 19
73
// Loop chunks, from left side
74
CallFunction(R7Setup_GetLoopTileInfo)
75
if Player.CollisionMode == CMODE_FLOOR
76
if TempValue0 == 1001
77
TempValue1 &= 1022
78
TempValue2 &= 1022
79
SetTileLayerEntry(20, 0, TempValue1, TempValue2)
80
TempValue1++
81
SetTileLayerEntry(21, 0, TempValue1, TempValue2)
82
TempValue1--
83
TempValue2++
84
SetTileLayerEntry(22, 0, TempValue1, TempValue2)
85
TempValue1++
86
SetTileLayerEntry(23, 0, TempValue1, TempValue2)
87
end if
88
else
89
if Player.Speed > 0
90
if TempValue0 == 1003
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
end if
103
end if
104
break
105
106
case 20
107
case 21
108
case 22
109
case 23
110
// Loop chunks, from right side
111
CallFunction(R7Setup_GetLoopTileInfo)
112
if Player.CollisionMode == CMODE_FLOOR
113
if TempValue0 == 1000
114
TempValue1 &= 1022
115
TempValue2 &= 1022
116
SetTileLayerEntry(16, 0, TempValue1, TempValue2)
117
TempValue1++
118
SetTileLayerEntry(17, 0, TempValue1, TempValue2)
119
TempValue1--
120
TempValue2++
121
SetTileLayerEntry(18, 0, TempValue1, TempValue2)
122
TempValue1++
123
SetTileLayerEntry(19, 0, TempValue1, TempValue2)
124
end if
125
else
126
if Player.Speed < 0
127
if TempValue0 == 1002
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
end if
140
end if
141
break
142
143
case 24
144
case 25
145
case 26
146
case 27
147
// Wave chunks, from left side
148
CallFunction(R7Setup_GetLoopTileInfo)
149
if TempValue0 == 1001
150
TempValue1 &= 1022
151
TempValue2 &= 1022
152
SetTileLayerEntry(28, 0, TempValue1, TempValue2)
153
TempValue1++
154
SetTileLayerEntry(29, 0, TempValue1, TempValue2)
155
TempValue1--
156
TempValue2++
157
SetTileLayerEntry(30, 0, TempValue1, TempValue2)
158
TempValue1++
159
SetTileLayerEntry(31, 0, TempValue1, TempValue2)
160
end if
161
break
162
163
case 28
164
case 29
165
case 30
166
case 31
167
// Wave chunks, from right side
168
CallFunction(R7Setup_GetLoopTileInfo)
169
if TempValue0 == 1000
170
TempValue1 &= 1022
171
TempValue2 &= 1022
172
SetTileLayerEntry(24, 0, TempValue1, TempValue2)
173
TempValue1++
174
SetTileLayerEntry(25, 0, TempValue1, TempValue2)
175
TempValue1--
176
TempValue2++
177
SetTileLayerEntry(26, 0, TempValue1, TempValue2)
178
TempValue1++
179
SetTileLayerEntry(27, 0, TempValue1, TempValue2)
180
end if
181
break
182
183
end switch
184
185
if Object.FlamesTimer == 0
186
187
TempValue0 = Player.Speed
188
if TempValue0 < 0
189
FlipSign(TempValue0)
190
end if
191
192
// See if the player's going above a rate of 10 pixels per frame
193
if TempValue0 > 0xA0000
194
195
// Get the player's positions
196
TempValue3 = Player.XPos
197
TempValue3 >>= 16
198
199
TempValue4 = Player.YPos
200
TempValue4 >>= 16
201
TempValue4 += 8
202
203
// See if the player is on a special flame tile
204
Get16x16TileInfo(TempValue0, TempValue3, TempValue4, TILEINFO_ANGLEB)
205
206
if TempValue0 == 1
207
Object.FlamesTimer = 4
208
209
// If so, spawn a Fire Trail behind Sonic
210
CreateTempObject(TypeName[Fire Trail], 0, Player.XPos, Player.YPos)
211
if Player.Speed < 0
212
Object[TempObjectPos].Direction = FACING_LEFT
213
else
214
Object[TempObjectPos].Direction = FACING_RIGHT
215
end if
216
Object[TempObjectPos].DrawOrder = 4
217
Object[TempObjectPos].iYPos += Player.CollisionBottom
218
219
end if
220
end if
221
end if
222
end sub
223
224
225
sub ObjectStartup
226
227
// Place a Setup object into slot 19 and set it to always be active
228
Object[19].Type = TypeName[R7 Setup]
229
Object[19].Priority = PRIORITY_ACTIVE
230
231
end sub
232
233
234
// ========================
235
// Editor Subs
236
// ========================
237
238
sub RSDKDraw
239
DrawSprite(0)
240
end sub
241
242
243
sub RSDKLoad
244
LoadSpriteSheet("Global/Display.gif")
245
SpriteFrame(-16, -16, 32, 32, 1, 143) // "Script" Icon
246
247
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
248
end sub
249
250