Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R7/R7ASetup.txt
1319 views
1
//-----------------Sonic CD R7 A Setup Script-----------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
#alias Object.Value0 : Object.PaletteTimer
7
#alias Object.Value1 : Object.ActivePalette
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
21
// Function declarations
22
#function R7Setup_GetLoopTileInfo
23
24
25
function R7Setup_GetLoopTileInfo
26
// Gets info from out of bounds chunks, located past the signpost
27
28
// Precondition:
29
// - TempValue0 is the chunk ID of the chunk currentbly being checked against
30
31
TempValue3 = Player.XPos
32
TempValue3 >>= 16
33
TempValue3 &= 255
34
TempValue3 += 0x3100
35
36
TempValue0 -= 16
37
TempValue0 >>= 2
38
TempValue0 <<= 8
39
TempValue4 = Player.YPos
40
TempValue4 >>= 16
41
TempValue4 &= 255
42
TempValue4 += TempValue0
43
44
Get16x16TileInfo(TempValue0, TempValue3, TempValue4, TILEINFO_INDEX)
45
end function
46
47
48
sub ObjectMain
49
50
// Palette cycling
51
// Despite banks 0-5 being set up earler, only banks 0-1 are used here
52
Object.PaletteTimer++
53
if Object.PaletteTimer == 5
54
Object.PaletteTimer = 0
55
Object.ActivePalette++
56
Object.ActivePalette &= 1
57
SetActivePalette(Object.ActivePalette, 0, 240)
58
end if
59
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 fire-compatible 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 object into the scene and make it always active
242
Object[19].Type = TypeName[R7 Setup]
243
Object[19].Priority = PRIORITY_ACTIVE
244
245
// Setup the palette cycle
246
247
// First, copy the main palette bank into banks 1-5
248
// (Side note - 1-5? But only banks 0-1 are actually used throughout the stage...)
249
CopyPalette(0, 1)
250
CopyPalette(0, 2)
251
CopyPalette(0, 3)
252
CopyPalette(0, 4)
253
CopyPalette(0, 5)
254
255
// And now insert the modified colors into the alternate palette banks
256
TempValue0 = 0
257
TempValue1 = 0
258
TempValue2 = 32
259
while TempValue0 < 2
260
LoadPalette("R7A_PalCycle.act", TempValue0, 160, TempValue1, TempValue2)
261
TempValue0++
262
TempValue1 += 32
263
TempValue2 += 32
264
loop
265
266
end sub
267
268
269
// ========================
270
// Editor Subs
271
// ========================
272
273
sub RSDKDraw
274
DrawSprite(0)
275
end sub
276
277
278
sub RSDKLoad
279
LoadSpriteSheet("Global/Display.gif")
280
SpriteFrame(-16, -16, 32, 32, 1, 143) // "Script" Icon
281
282
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
283
end sub
284
285