Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/Global/DebugMode.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Debug Mode Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
// This object is run from the Player Object slot, so values are the same between the two
13
// `object.` vs `player.` is used in this script to mark what's being run as a Debug Mode object, as opposed to being run from the Player Object
14
15
private alias object.value3 : player.drownTimer
16
private alias object.value4 : player.drownLevel
17
private alias object.value17 : debugMode.currentSelection
18
private alias object.value18 : player.sortedDrawOrder
19
20
private alias object.state : player.state
21
private alias object.xvel : player.xvel
22
private alias object.yvel : player.yvel
23
private alias object.speed : player.speed
24
private alias object.animation : player.animation
25
private alias object.animationSpeed : player.animationSpeed
26
private alias object.frame : player.frame
27
private alias object.controlMode : player.controlMode
28
private alias object.drawOrder : player.drawOrder
29
private alias object.interaction : player.interaction
30
private alias object.tileCollisions : player.tileCollisions
31
private alias object.visible : player.visible
32
33
private alias -1 : DRAWORDER_PLAYER
34
35
36
// ========================
37
// Function Declarations
38
// ========================
39
40
reserve function DebugMode_BlankSpawn
41
reserve function DebugMode_BlankDraw
42
43
44
// ========================
45
// Static Values
46
// ========================
47
48
public value DebugMode_ObjCount = 0
49
private value DebugMode_ExitTimer = 0
50
51
52
// ========================
53
// Tables
54
// ========================
55
56
// Large table to hold the types of every entry
57
public table DebugMode_TypesTable[256]
58
59
// Large table to hold the draw functions of every entry
60
public table DebugMode_DrawTable[256]
61
62
// Large table to hold the spawn functions of every entry
63
public table DebugMode_SpawnTable[256]
64
65
66
// ========================
67
// Function Definitions
68
// ========================
69
70
private function DebugMode_BlankSpawn
71
temp0 = 0
72
end function
73
74
75
private function DebugMode_BlankDraw
76
DrawSprite(0)
77
end function
78
79
80
// ========================
81
// Events
82
// ========================
83
84
event ObjectUpdate
85
if DebugMode_ExitTimer == 0
86
#platform: USE_STANDALONE
87
if options.touchControls == true
88
CheckTouchRect(0, 96, screen.xcenter, screen.ysize)
89
90
if checkResult > -1
91
arrayPos0 = checkResult
92
temp0 = touchscreen[arrayPos0].xpos
93
temp0 -= saveRAM[39]
94
temp1 = touchscreen[arrayPos0].ypos
95
temp1 -= saveRAM[40]
96
ATan2(temp2, temp0, temp1)
97
temp2 += 16
98
temp2 &= 255
99
temp2 >>= 5
100
switch temp2
101
case 0
102
keyDown[0].right = true
103
break
104
105
case 1
106
keyDown[0].right = true
107
keyDown[0].down = true
108
break
109
110
case 2
111
keyDown[0].down = true
112
break
113
114
case 3
115
keyDown[0].down = true
116
keyDown[0].left = true
117
break
118
119
case 4
120
keyDown[0].left = true
121
break
122
123
case 5
124
keyDown[0].left = true
125
keyDown[0].up = true
126
break
127
128
case 6
129
keyDown[0].up = true
130
break
131
132
case 7
133
keyDown[0].up = true
134
keyDown[0].right = true
135
break
136
137
end switch
138
139
end if
140
141
temp0 = screen.xcenter
142
temp0 -= 48
143
144
temp1 = temp0
145
temp1 += 96
146
147
CheckTouchRect(temp0, 0, temp1, 56)
148
if checkResult > -1
149
arrayPos0 = checkResult
150
151
if touchscreen[arrayPos0].xpos > screen.xcenter
152
if touchJump == false
153
debugMode.currentSelection++
154
if debugMode.currentSelection >= DebugMode_ObjCount
155
debugMode.currentSelection = 0
156
end if
157
end if
158
159
touchJump = true
160
else
161
if touchJump == false
162
debugMode.currentSelection--
163
164
if debugMode.currentSelection < 0
165
debugMode.currentSelection += DebugMode_ObjCount
166
end if
167
end if
168
touchJump = true
169
end if
170
else
171
172
CheckTouchRect(screen.xcenter, 96, screen.xsize, 240)
173
174
switch checkResult
175
case -1
176
touchJump = false
177
break
178
179
case 0
180
keyDown[0].buttonC = true
181
if touchJump == false
182
keyPress[0].buttonC |= keyDown[0].buttonC
183
end if
184
touchJump = keyDown[0].buttonC
185
break
186
187
end switch
188
end if
189
190
temp0 = screen.xsize
191
temp0 -= 88
192
193
CheckTouchRect(temp0, 0, screen.xsize, 40)
194
if checkResult > -1
195
if options.stageSelectFlag == true
196
// Start going to level select
197
StopMusic()
198
DebugMode_ExitTimer = 8
199
object.priority = PRIORITY_ALWAYS
200
options.touchControls = false
201
stage.state = STAGE_FROZEN
202
else
203
// Pause the game
204
PlaySfx(SfxName[Menu Back], false)
205
engine.state = 5
206
end if
207
end if
208
209
if keyPress[0].start == true
210
// Pause the game
211
PlaySfx(SfxName[Menu Back], false)
212
engine.state = 5
213
end if
214
end if
215
216
CheckTouchRect(0, 0, 112, 56)
217
218
if checkResult > -1
219
keyDown[0].buttonB = true
220
end if
221
222
if touchDebug == false
223
keyPress[0].buttonB |= keyDown[0].buttonB
224
end if
225
226
touchDebug = keyDown[0].buttonB
227
temp0 = false
228
229
if keyDown[0].left == true
230
object.xpos -= object.yvel
231
temp0 = true
232
end if
233
234
if keyDown[0].right == true
235
object.xpos += object.yvel
236
temp0 = true
237
end if
238
239
if keyDown[0].up == true
240
object.ypos -= object.yvel
241
temp0 = true
242
end if
243
244
if keyDown[0].down == true
245
object.ypos += object.yvel
246
temp0 = true
247
end if
248
#endplatform
249
250
#platform: USE_ORIGINS
251
// They forgot to add the ability to pause in Debug Mode...
252
253
temp0 = false
254
255
if keyDown[1].left == true
256
object.xpos -= object.yvel
257
temp0 = true
258
end if
259
260
if keyDown[1].right == true
261
object.xpos += object.yvel
262
temp0 = true
263
end if
264
265
if keyDown[1].up == true
266
object.ypos -= object.yvel
267
temp0 = true
268
end if
269
270
if keyDown[1].down == true
271
object.ypos += object.yvel
272
temp0 = true
273
end if
274
#endplatform
275
276
if temp0 == true
277
object.yvel += 0xC00
278
if object.yvel > 0x100000
279
object.yvel = 0x100000
280
end if
281
else
282
object.yvel = 0
283
end if
284
285
player.drownTimer = 0
286
player.drownLevel = 0
287
288
if keyPress[0].buttonB == true
289
if DebugMode_ExitTimer == 0
290
// Exit Debug Mode
291
292
if stage.playerListPos == PLAYER_TAILS_A
293
object.type = TypeName[Tails Object]
294
else
295
object.type = TypeName[Player Object]
296
end if
297
298
player.speed = 0
299
player.xvel = 0
300
player.yvel = 0
301
#platform: USE_STANDALONE
302
player.state = Player_State_Air
303
#endplatform
304
#platform: USE_ORIGINS
305
player.state = Player_State_Air_NoDropDash
306
#endplatform
307
player.animation = ANI_WALKING
308
player.animationSpeed = 0
309
player.frame = 0
310
player.controlMode = CONTROLMODE_P1
311
player.drawOrder = DRAWORDER_PLAYER
312
player.sortedDrawOrder = 4
313
player.interaction = true
314
player.tileCollisions = true
315
player.visible = true
316
end if
317
else
318
if keyPress[0].buttonA == true
319
// Go up one on the debug item list
320
debugMode.currentSelection++
321
#platform: USE_ORIGINS
322
// Skip the life/coin monitor (no farming coins!)
323
if debugMode.currentSelection == 5
324
debugMode.currentSelection++
325
end if
326
#endplatform
327
if debugMode.currentSelection >= DebugMode_ObjCount
328
debugMode.currentSelection = 0
329
end if
330
end if
331
332
if keyDown[0].buttonA == true
333
if keyPress[0].buttonC == true
334
// Go down one on the debug item list
335
debugMode.currentSelection--
336
#platform: USE_ORIGINS
337
// Skip the life/coin monitor (no farming coins!)
338
if debugMode.currentSelection == 5
339
debugMode.currentSelection--
340
end if
341
#endplatform
342
if debugMode.currentSelection < 0
343
debugMode.currentSelection += DebugMode_ObjCount
344
end if
345
end if
346
else
347
if keyPress[0].buttonC == true
348
// Place the object
349
GetTableValue(temp0, debugMode.currentSelection, DebugMode_SpawnTable)
350
CallFunction(temp0)
351
object[tempObjectPos].priority = PRIORITY_XBOUNDS_DESTROY
352
end if
353
end if
354
end if
355
else
356
// This goes unused in Origins because you can't pause in Debug Mode!!!
357
358
options.touchControls = false
359
360
DebugMode_ExitTimer += 8
361
SetScreenFade(0, 0, 0, DebugMode_ExitTimer)
362
363
if DebugMode_ExitTimer == 384
364
// Load the level select
365
366
starPostID = 0
367
stage.activeList = PRESENTATION_STAGE
368
stage.listPos = 5
369
LoadStage()
370
end if
371
end if
372
end event
373
374
375
event ObjectDraw
376
// Set this object to the current selection's type selected type
377
GetTableValue(object.type, debugMode.currentSelection, DebugMode_TypesTable)
378
379
// Get the draw function of the selected object
380
GetTableValue(temp0, debugMode.currentSelection, DebugMode_DrawTable)
381
382
// Call said draw function
383
CallFunction(temp0)
384
385
// Restore this object to being a Debug Mode object
386
object.type = TypeName[Debug Mode]
387
end event
388
389
390
event ObjectStartup
391
LoadSpriteSheet("Global/Display.gif")
392
393
// In S1 this would be Sonic's life icon from Sonic CD, here it's blank (or in Origins Plus' case, part of Amy's Act Finish name sprite)
394
SpriteFrame(-8, -8, 16, 16, 188, 239)
395
396
// Reset the tables
397
DebugMode_ObjCount = 0
398
temp0 = 0
399
while temp0 < 256
400
SetTableValue(TypeName[Debug Mode], temp0, DebugMode_TypesTable)
401
SetTableValue(DebugMode_BlankDraw, temp0, DebugMode_DrawTable)
402
SetTableValue(DebugMode_BlankSpawn, temp0, DebugMode_SpawnTable)
403
temp0++
404
loop
405
406
DebugMode_ExitTimer = 0
407
end event
408
409
410
// ========================
411
// Editor Events
412
// ========================
413
414
event RSDKDraw
415
DrawSprite(0)
416
end event
417
418
419
event RSDKLoad
420
LoadSpriteSheet("Global/Display.gif")
421
SpriteFrame(-8, -8, 16, 16, 188, 239) // See above
422
423
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
424
end event
425
426