Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R7/R7DBossSetup.txt
1319 views
1
//--------------Sonic CD R7 D Boss Setup 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
#alias Object.Value1 : Object.ActivePalette
8
9
// Collision Modes
10
#alias 0 : CMODE_FLOOR
11
12
// Priority
13
#alias 1 : PRIORITY_ACTIVE
14
15
// Tile Info
16
#alias 0 : TILEINFO_INDEX
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 += 0x4000
33
TempValue0 -= 16
34
TempValue0 >>= 2
35
TempValue0 <<= 8
36
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
48
Object.Timer++
49
if Object.Timer == 5
50
Object.Timer = 0
51
Object.ActivePalette++
52
Object.ActivePalette %= 6
53
SetActivePalette(Object.ActivePalette, 0, 240)
54
end if
55
56
end sub
57
58
59
sub ObjectPlayerInteraction
60
61
// Manage stage layers
62
63
// Get the chunk ID of the chunk the player's currently in
64
TempValue1 = Player.XPos
65
TempValue1 >>= 23
66
TempValue2 = Player.YPos
67
TempValue2 >>= 23
68
GetTileLayerEntry(TempValue0, 0, TempValue1, TempValue2)
69
70
// If possible, jump to its corresponding entry over here now
71
switch TempValue0
72
case 16
73
case 17
74
case 18
75
case 19
76
// Loop chunks, opening on left side
77
CallFunction(R7Setup_GetLoopTileInfo)
78
if Player.CollisionMode == CMODE_FLOOR
79
if TempValue0 == 1001
80
TempValue1 &= 1022
81
TempValue2 &= 1022
82
SetTileLayerEntry(20, 0, TempValue1, TempValue2)
83
TempValue1++
84
SetTileLayerEntry(21, 0, TempValue1, TempValue2)
85
TempValue1--
86
TempValue2++
87
SetTileLayerEntry(22, 0, TempValue1, TempValue2)
88
TempValue1++
89
SetTileLayerEntry(23, 0, TempValue1, TempValue2)
90
end if
91
else
92
if Player.Speed > 0
93
if TempValue0 == 1003
94
TempValue1 &= 1022
95
TempValue2 &= 1022
96
SetTileLayerEntry(20, 0, TempValue1, TempValue2)
97
TempValue1++
98
SetTileLayerEntry(21, 0, TempValue1, TempValue2)
99
TempValue1--
100
TempValue2++
101
SetTileLayerEntry(22, 0, TempValue1, TempValue2)
102
TempValue1++
103
SetTileLayerEntry(23, 0, TempValue1, TempValue2)
104
end if
105
end if
106
end if
107
break
108
109
case 20
110
case 21
111
case 22
112
case 23
113
// Loop chunks, opening on right side
114
CallFunction(R7Setup_GetLoopTileInfo)
115
if Player.CollisionMode == CMODE_FLOOR
116
if TempValue0 == 1000
117
TempValue1 &= 1022
118
TempValue2 &= 1022
119
SetTileLayerEntry(16, 0, TempValue1, TempValue2)
120
TempValue1++
121
SetTileLayerEntry(17, 0, TempValue1, TempValue2)
122
TempValue1--
123
TempValue2++
124
SetTileLayerEntry(18, 0, TempValue1, TempValue2)
125
TempValue1++
126
SetTileLayerEntry(19, 0, TempValue1, TempValue2)
127
end if
128
else
129
if Player.Speed < 0
130
if TempValue0 == 1002
131
TempValue1 &= 1022
132
TempValue2 &= 1022
133
SetTileLayerEntry(16, 0, TempValue1, TempValue2)
134
TempValue1++
135
SetTileLayerEntry(17, 0, TempValue1, TempValue2)
136
TempValue1--
137
TempValue2++
138
SetTileLayerEntry(18, 0, TempValue1, TempValue2)
139
TempValue1++
140
SetTileLayerEntry(19, 0, TempValue1, TempValue2)
141
end if
142
end if
143
end if
144
break
145
146
case 24
147
case 25
148
case 26
149
case 27
150
// Wavy chunks, opening on left side... or at least they should be
151
// However!
152
// These don't exist in Act 3, so this function call is actually checking against blank chunks...
153
CallFunction(R7Setup_GetLoopTileInfo)
154
if TempValue0 == 1001
155
TempValue1 &= 1022
156
TempValue2 &= 1022
157
SetTileLayerEntry(28, 0, TempValue1, TempValue2)
158
TempValue1++
159
SetTileLayerEntry(29, 0, TempValue1, TempValue2)
160
TempValue1--
161
TempValue2++
162
SetTileLayerEntry(30, 0, TempValue1, TempValue2)
163
TempValue1++
164
SetTileLayerEntry(31, 0, TempValue1, TempValue2)
165
end if
166
break
167
168
case 28
169
case 29
170
case 30
171
case 31
172
// Wavy chunks, opening on right side, but see note above
173
// Same story here
174
CallFunction(R7Setup_GetLoopTileInfo)
175
if TempValue0 == 1000
176
TempValue1 &= 1022
177
TempValue2 &= 1022
178
SetTileLayerEntry(24, 0, TempValue1, TempValue2)
179
TempValue1++
180
SetTileLayerEntry(25, 0, TempValue1, TempValue2)
181
TempValue1--
182
TempValue2++
183
SetTileLayerEntry(26, 0, TempValue1, TempValue2)
184
TempValue1++
185
SetTileLayerEntry(27, 0, TempValue1, TempValue2)
186
end if
187
break
188
189
end switch
190
191
end sub
192
193
194
sub ObjectDraw
195
// Find the XPos to draw the lamp at, since it's supposed to have parallax and loop around the stage
196
Object.XPos = Screen.XOffset
197
Object.XPos /= 420
198
Object.XPos *= 420
199
Object.XPos += 320
200
Object.XPos *= 3
201
Object.XPos >>= 1
202
TempValue0 = Screen.XOffset
203
TempValue0 *= 3
204
TempValue0 >>= 1
205
Object.XPos -= TempValue0
206
Object.YPos = 520
207
208
// And now find the YPos to draw it at, there's also vertical parallax too
209
TempValue0 = Screen.YOffset
210
TempValue0 *= 23
211
TempValue0 >>= 4
212
Object.YPos -= TempValue0
213
214
DrawSpriteScreenXY(0, Object.XPos, Object.YPos)
215
DrawSpriteScreenXY(1, Object.XPos, Object.YPos)
216
DrawSpriteScreenXY(2, Object.XPos, Object.YPos)
217
DrawSpriteScreenXY(3, Object.XPos, Object.YPos)
218
219
end sub
220
221
222
sub ObjectStartup
223
224
LoadSpriteSheet("R7/Objects2.gif")
225
226
// Place the Setup object into slot 19, make it always active, and give it a high draworder so that it's in front of Sonic
227
Object[19].Type = TypeName[R7 Setup]
228
Object[19].Priority = PRIORITY_ACTIVE
229
Object[19].DrawOrder = 5
230
231
// Lamp Post Head
232
SpriteFrame(-24, -24, 48, 24, 173, 26)
233
234
// Lamp Post Post
235
SpriteFrame(-8, 0, 16, 224, 222, 26)
236
SpriteFrame(-8, 224, 16, 224, 222, 26)
237
SpriteFrame(-8, 448, 16, 224, 222, 26)
238
239
// Set initial stage bounds
240
Stage.XBoundary2 -= 288
241
242
// Setup the stage's palette cycle
243
CopyPalette(0, 1)
244
CopyPalette(0, 2)
245
CopyPalette(0, 3)
246
CopyPalette(0, 4)
247
CopyPalette(0, 5)
248
249
TempValue0 = 0
250
TempValue1 = 0
251
TempValue2 = 16
252
while TempValue0 < 6
253
LoadPalette("R7D_PalCycle.act", TempValue0, 160, TempValue1, TempValue2)
254
TempValue0++
255
TempValue1 += 16
256
TempValue2 += 16
257
loop
258
259
end sub
260
261
262
// ========================
263
// Editor Subs
264
// ========================
265
266
sub RSDKDraw
267
DrawSprite(0)
268
DrawSprite(1)
269
end sub
270
271
272
sub RSDKLoad
273
LoadSpriteSheet("R7/Objects2.gif")
274
SpriteFrame(-24, -24, 48, 24, 173, 26)
275
SpriteFrame(-8, 0, 16, 224, 222, 26)
276
277
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
278
end sub
279
280