Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/R7/R7CBossSetup.txt
1319 views
1
//--------------Sonic CD R7 C Boss Setup Script---------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Priority
6
#alias 1 : PRIORITY_ACTIVE
7
8
// Collision Mode
9
#alias 0 : CMODE_FLOOR
10
11
// Tile Info
12
#alias 0 : TILEINFO_INDEX
13
14
// Function declarations
15
#function R7Setup_GetLoopTileInfo
16
17
18
function R7Setup_GetLoopTileInfo
19
// Gets info from out of bounds chunks, located past the signpost
20
21
// Precondition:
22
// - TempValue0 is the chunk ID of the chunk currentbly being checked against
23
24
TempValue3 = Player.XPos
25
TempValue3 >>= 16
26
TempValue3 &= 255
27
TempValue3 += 0x4000
28
29
TempValue0 -= 16
30
TempValue0 >>= 2
31
TempValue0 <<= 8
32
TempValue4 = Player.YPos
33
TempValue4 >>= 16
34
TempValue4 &= 255
35
TempValue4 += TempValue0
36
37
Get16x16TileInfo(TempValue0, TempValue3, TempValue4, TILEINFO_INDEX)
38
end function
39
40
41
sub ObjectPlayerInteraction
42
// "Layers" are managed here
43
// (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)
44
45
// Get the position of the chunk the player's currently in
46
TempValue1 = Player.XPos
47
TempValue1 >>= 23
48
TempValue2 = Player.YPos
49
TempValue2 >>= 23
50
51
// And find what chunk ID it holds
52
GetTileLayerEntry(TempValue0, 0, TempValue1, TempValue2)
53
54
// If applicable, jump to the loop chunk set it corresponds to
55
switch TempValue0
56
case 16
57
case 17
58
case 18
59
case 19
60
// Loop chunks, open from left side
61
CallFunction(R7Setup_GetLoopTileInfo)
62
if Player.CollisionMode == CMODE_FLOOR
63
if TempValue0 == 1001
64
TempValue1 &= 1022
65
TempValue2 &= 1022
66
SetTileLayerEntry(20, 0, TempValue1, TempValue2)
67
TempValue1++
68
SetTileLayerEntry(21, 0, TempValue1, TempValue2)
69
TempValue1--
70
TempValue2++
71
SetTileLayerEntry(22, 0, TempValue1, TempValue2)
72
TempValue1++
73
SetTileLayerEntry(23, 0, TempValue1, TempValue2)
74
end if
75
else
76
if Player.Speed > 0
77
if TempValue0 == 1003
78
TempValue1 &= 1022
79
TempValue2 &= 1022
80
SetTileLayerEntry(20, 0, TempValue1, TempValue2)
81
TempValue1++
82
SetTileLayerEntry(21, 0, TempValue1, TempValue2)
83
TempValue1--
84
TempValue2++
85
SetTileLayerEntry(22, 0, TempValue1, TempValue2)
86
TempValue1++
87
SetTileLayerEntry(23, 0, TempValue1, TempValue2)
88
end if
89
end if
90
end if
91
break
92
93
case 20
94
case 21
95
case 22
96
case 23
97
// Loop chunks, open from right side
98
CallFunction(R7Setup_GetLoopTileInfo)
99
if Player.CollisionMode == CMODE_FLOOR
100
if TempValue0 == 1000
101
TempValue1 &= 1022
102
TempValue2 &= 1022
103
SetTileLayerEntry(16, 0, TempValue1, TempValue2)
104
TempValue1++
105
SetTileLayerEntry(17, 0, TempValue1, TempValue2)
106
TempValue1--
107
TempValue2++
108
SetTileLayerEntry(18, 0, TempValue1, TempValue2)
109
TempValue1++
110
SetTileLayerEntry(19, 0, TempValue1, TempValue2)
111
end if
112
else
113
if Player.Speed < 0
114
if TempValue0 == 1002
115
TempValue1 &= 1022
116
TempValue2 &= 1022
117
SetTileLayerEntry(16, 0, TempValue1, TempValue2)
118
TempValue1++
119
SetTileLayerEntry(17, 0, TempValue1, TempValue2)
120
TempValue1--
121
TempValue2++
122
SetTileLayerEntry(18, 0, TempValue1, TempValue2)
123
TempValue1++
124
SetTileLayerEntry(19, 0, TempValue1, TempValue2)
125
end if
126
end if
127
end if
128
break
129
130
case 24
131
case 25
132
case 26
133
case 27
134
// Wavy chunks, open from left side
135
// Note - These don't actually exist in Act 3! So the function is comparing against blank chunks...
136
CallFunction(R7Setup_GetLoopTileInfo)
137
if TempValue0 == 1001
138
TempValue1 &= 1022
139
TempValue2 &= 1022
140
SetTileLayerEntry(28, 0, TempValue1, TempValue2)
141
TempValue1++
142
SetTileLayerEntry(29, 0, TempValue1, TempValue2)
143
TempValue1--
144
TempValue2++
145
SetTileLayerEntry(30, 0, TempValue1, TempValue2)
146
TempValue1++
147
SetTileLayerEntry(31, 0, TempValue1, TempValue2)
148
end if
149
break
150
151
case 28
152
case 29
153
case 30
154
case 31
155
// Wavy chunks, open from right side, but they don't actually exist
156
// See note above
157
CallFunction(R7Setup_GetLoopTileInfo)
158
if TempValue0 == 1000
159
TempValue1 &= 1022
160
TempValue2 &= 1022
161
SetTileLayerEntry(24, 0, TempValue1, TempValue2)
162
TempValue1++
163
SetTileLayerEntry(25, 0, TempValue1, TempValue2)
164
TempValue1--
165
TempValue2++
166
SetTileLayerEntry(26, 0, TempValue1, TempValue2)
167
TempValue1++
168
SetTileLayerEntry(27, 0, TempValue1, TempValue2)
169
end if
170
break
171
172
end switch
173
174
end sub
175
176
177
sub ObjectDraw
178
179
// Find the XPos to draw it at, keeping the screen width in mind
180
Object.XPos = Screen.XOffset
181
Object.XPos /= 420
182
Object.XPos *= 420
183
Object.XPos += 320
184
Object.XPos *= 3
185
Object.XPos >>= 1
186
TempValue0 = Screen.XOffset
187
TempValue0 *= 3
188
TempValue0 >>= 1
189
Object.XPos -= TempValue0
190
191
Object.YPos = 520
192
TempValue0 = Screen.YOffset
193
TempValue0 *= 23
194
TempValue0 >>= 4
195
Object.YPos -= TempValue0
196
197
// Draw the street lamp
198
DrawSpriteScreenXY(0, Object.XPos, Object.YPos)
199
DrawSpriteScreenXY(1, Object.XPos, Object.YPos)
200
DrawSpriteScreenXY(2, Object.XPos, Object.YPos)
201
DrawSpriteScreenXY(3, Object.XPos, Object.YPos)
202
203
end sub
204
205
206
sub ObjectStartup
207
208
LoadSpriteSheet("R7/Objects2.gif")
209
210
// Place a Setup object in reserved object slot 19 and make it always active
211
Object[19].Type = TypeName[R7 Setup]
212
Object[19].Priority = PRIORITY_ACTIVE
213
Object[19].DrawOrder = 5
214
215
// Street Lamps
216
SpriteFrame(-24, -24, 48, 24, 207, 1)
217
218
// Street Lamp Post Frames
219
SpriteFrame(-8, 0, 16, 224, 239, 26)
220
SpriteFrame(-8, 224, 16, 224, 239, 26)
221
SpriteFrame(-8, 448, 16, 224, 239, 26)
222
223
// Set initial stage bounds
224
Stage.XBoundary2 -= 288
225
226
end sub
227
228
229
// ========================
230
// Editor Subs
231
// ========================
232
233
sub RSDKDraw
234
DrawSprite(0)
235
DrawSprite(1)
236
end sub
237
238
239
sub RSDKLoad
240
LoadSpriteSheet("R7/Objects2.gif")
241
SpriteFrame(-24, -24, 48, 24, 207, 1)
242
SpriteFrame(-8, 0, 16, 224, 239, 26)
243
244
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
245
end sub
246
247