Path: blob/master/Sonic 2/Scripts/Global/DebugMode.txt
1478 views
// ----------------------------------1// RSDK Project: Sonic 22// Script Description: Debug Mode Object3// Script Author: Christian Whitehead/Simon Thomley4// Unpacked by Rubberduckycooly's script unpacker5// ----------------------------------67// ========================8// Aliases9// ========================1011// This object is run from the Player Object slot, so values are the same between the two12// `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 Object1314private alias object.value3 : player.drownTimer15private alias object.value4 : player.drownLevel16private alias object.value17 : debugMode.currentSelection17private alias object.value18 : player.sortedDrawOrder1819private alias object.state : player.state20private alias object.xvel : player.xvel21private alias object.yvel : player.yvel22private alias object.speed : player.speed23private alias object.animation : player.animation24private alias object.animationSpeed : player.animationSpeed25private alias object.frame : player.frame26private alias object.controlMode : player.controlMode27private alias object.drawOrder : player.drawOrder28private alias object.interaction : player.interaction29private alias object.tileCollisions : player.tileCollisions30private alias object.visible : player.visible3132private alias -1 : DRAWORDER_PLAYER333435// ========================36// Function Declarations37// ========================3839reserve function DebugMode_BlankSpawn40reserve function DebugMode_BlankDraw414243// ========================44// Static Values45// ========================4647public value DebugMode_ObjCount = 048private value DebugMode_ExitTimer = 0495051// ========================52// Tables53// ========================5455// Large table to hold the types of every entry56public table DebugMode_TypesTable[256]5758// Large table to hold the draw functions of every entry59public table DebugMode_DrawTable[256]6061// Large table to hold the spawn functions of every entry62public table DebugMode_SpawnTable[256]636465// ========================66// Function Definitions67// ========================6869private function DebugMode_BlankSpawn70temp0 = 071end function727374private function DebugMode_BlankDraw75DrawSprite(0)76end function777879// ========================80// Events81// ========================8283event ObjectUpdate84if DebugMode_ExitTimer == 085#platform: USE_STANDALONE86if options.touchControls == true87CheckTouchRect(0, 96, screen.xcenter, screen.ysize)8889if checkResult > -190arrayPos0 = checkResult91temp0 = touchscreen[arrayPos0].xpos92temp0 -= saveRAM[39]93temp1 = touchscreen[arrayPos0].ypos94temp1 -= saveRAM[40]95ATan2(temp2, temp0, temp1)96temp2 += 1697temp2 &= 25598temp2 >>= 599switch temp2100case 0101keyDown[0].right = true102break103104case 1105keyDown[0].right = true106keyDown[0].down = true107break108109case 2110keyDown[0].down = true111break112113case 3114keyDown[0].down = true115keyDown[0].left = true116break117118case 4119keyDown[0].left = true120break121122case 5123keyDown[0].left = true124keyDown[0].up = true125break126127case 6128keyDown[0].up = true129break130131case 7132keyDown[0].up = true133keyDown[0].right = true134break135136end switch137138end if139140temp0 = screen.xcenter141temp0 -= 48142143temp1 = temp0144temp1 += 96145146CheckTouchRect(temp0, 0, temp1, 56)147if checkResult > -1148arrayPos0 = checkResult149150if touchscreen[arrayPos0].xpos > screen.xcenter151if touchJump == false152debugMode.currentSelection++153if debugMode.currentSelection >= DebugMode_ObjCount154debugMode.currentSelection = 0155end if156end if157158touchJump = true159else160if touchJump == false161debugMode.currentSelection--162163if debugMode.currentSelection < 0164debugMode.currentSelection += DebugMode_ObjCount165end if166end if167touchJump = true168end if169else170171CheckTouchRect(screen.xcenter, 96, screen.xsize, 240)172173switch checkResult174case -1175touchJump = false176break177178case 0179keyDown[0].buttonC = true180if touchJump == false181keyPress[0].buttonC |= keyDown[0].buttonC182end if183touchJump = keyDown[0].buttonC184break185186end switch187end if188189temp0 = screen.xsize190temp0 -= 88191192CheckTouchRect(temp0, 0, screen.xsize, 40)193if checkResult > -1194if options.stageSelectFlag == true195// Start going to level select196StopMusic()197DebugMode_ExitTimer = 8198object.priority = PRIORITY_ALWAYS199options.touchControls = false200stage.state = STAGE_FROZEN201else202// Pause the game203PlaySfx(SfxName[Menu Back], false)204engine.state = 5205end if206end if207208if keyPress[0].start == true209// Pause the game210PlaySfx(SfxName[Menu Back], false)211engine.state = 5212end if213end if214215CheckTouchRect(0, 0, 112, 56)216217if checkResult > -1218keyDown[0].buttonB = true219end if220221if touchDebug == false222keyPress[0].buttonB |= keyDown[0].buttonB223end if224225touchDebug = keyDown[0].buttonB226temp0 = false227228if keyDown[0].left == true229object.xpos -= object.yvel230temp0 = true231end if232233if keyDown[0].right == true234object.xpos += object.yvel235temp0 = true236end if237238if keyDown[0].up == true239object.ypos -= object.yvel240temp0 = true241end if242243if keyDown[0].down == true244object.ypos += object.yvel245temp0 = true246end if247#endplatform248249#platform: USE_ORIGINS250// They forgot to add the ability to pause in Debug Mode...251252temp0 = false253254if keyDown[1].left == true255object.xpos -= object.yvel256temp0 = true257end if258259if keyDown[1].right == true260object.xpos += object.yvel261temp0 = true262end if263264if keyDown[1].up == true265object.ypos -= object.yvel266temp0 = true267end if268269if keyDown[1].down == true270object.ypos += object.yvel271temp0 = true272end if273#endplatform274275if temp0 == true276object.yvel += 0xC00277if object.yvel > 0x100000278object.yvel = 0x100000279end if280else281object.yvel = 0282end if283284player.drownTimer = 0285player.drownLevel = 0286287if keyPress[0].buttonB == true288if DebugMode_ExitTimer == 0289// Exit Debug Mode290291if stage.playerListPos == PLAYER_TAILS_A292object.type = TypeName[Tails Object]293else294object.type = TypeName[Player Object]295end if296297player.speed = 0298player.xvel = 0299player.yvel = 0300#platform: USE_STANDALONE301player.state = Player_State_Air302#endplatform303#platform: USE_ORIGINS304player.state = Player_State_Air_NoDropDash305#endplatform306player.animation = ANI_WALKING307player.animationSpeed = 0308player.frame = 0309player.controlMode = CONTROLMODE_P1310player.drawOrder = DRAWORDER_PLAYER311player.sortedDrawOrder = 4312player.interaction = true313player.tileCollisions = true314player.visible = true315end if316else317if keyPress[0].buttonA == true318// Go up one on the debug item list319debugMode.currentSelection++320#platform: USE_ORIGINS321// Skip the life/coin monitor (no farming coins!)322if debugMode.currentSelection == 5323debugMode.currentSelection++324end if325#endplatform326if debugMode.currentSelection >= DebugMode_ObjCount327debugMode.currentSelection = 0328end if329end if330331if keyDown[0].buttonA == true332if keyPress[0].buttonC == true333// Go down one on the debug item list334debugMode.currentSelection--335#platform: USE_ORIGINS336// Skip the life/coin monitor (no farming coins!)337if debugMode.currentSelection == 5338debugMode.currentSelection--339end if340#endplatform341if debugMode.currentSelection < 0342debugMode.currentSelection += DebugMode_ObjCount343end if344end if345else346if keyPress[0].buttonC == true347// Place the object348GetTableValue(temp0, debugMode.currentSelection, DebugMode_SpawnTable)349CallFunction(temp0)350object[tempObjectPos].priority = PRIORITY_XBOUNDS_DESTROY351end if352end if353end if354else355// This goes unused in Origins because you can't pause in Debug Mode!!!356357options.touchControls = false358359DebugMode_ExitTimer += 8360SetScreenFade(0, 0, 0, DebugMode_ExitTimer)361362if DebugMode_ExitTimer == 384363// Load the level select364365starPostID = 0366stage.activeList = PRESENTATION_STAGE367stage.listPos = 5368LoadStage()369end if370end if371end event372373374event ObjectDraw375// Set this object to the current selection's type selected type376GetTableValue(object.type, debugMode.currentSelection, DebugMode_TypesTable)377378// Get the draw function of the selected object379GetTableValue(temp0, debugMode.currentSelection, DebugMode_DrawTable)380381// Call said draw function382CallFunction(temp0)383384// Restore this object to being a Debug Mode object385object.type = TypeName[Debug Mode]386end event387388389event ObjectStartup390LoadSpriteSheet("Global/Display.gif")391392// 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)393SpriteFrame(-8, -8, 16, 16, 188, 239)394395// Reset the tables396DebugMode_ObjCount = 0397temp0 = 0398while temp0 < 256399SetTableValue(TypeName[Debug Mode], temp0, DebugMode_TypesTable)400SetTableValue(DebugMode_BlankDraw, temp0, DebugMode_DrawTable)401SetTableValue(DebugMode_BlankSpawn, temp0, DebugMode_SpawnTable)402temp0++403loop404405DebugMode_ExitTimer = 0406end event407408409// ========================410// Editor Events411// ========================412413event RSDKDraw414DrawSprite(0)415end event416417418event RSDKLoad419LoadSpriteSheet("Global/Display.gif")420SpriteFrame(-8, -8, 16, 16, 188, 239) // See above421422SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")423end event424425426