Path: blob/main/Scripts/Credits/CreditsControl.txt
1319 views
//--------------Sonic CD Credits Control Script---------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Timer6// Value1 is unused...7#alias Object.Value2 : Object.Scroll8#alias Object.Value3 : Object.EndCredits910// Text Font Aliases11#alias Object.Value1 : Object.TargetLine1213// States14#alias 0 : CREDITSCONTROL_INIT15#alias 1 : CREDITSCONTROL_FADEIN16#alias 2 : CREDITSCONTROL_MAIN17#alias 3 : CREDITSCONTROL_FADEOUT1819// Soundtrack20#alias 0 : OST_JP2122// Presentation Stage23#alias 1 : STAGE_P_MENU2425// Priority26#alias 1 : PRIORITY_ACTIVE2728// Engine States29#alias 8 : ENGINE_WAIT3031// Text Info type32#alias 0 : TEXTINFO_TEXTDATA33#alias 1 : TEXTINFO_TEXTSIZE34#alias 2 : TEXTINFO_ROWCOUNT353637sub ObjectMain38switch Object.State39case CREDITSCONTROL_INIT4041// Object.Scroll should be 0 at this point, so this is42// essentially resetting the Camera Y Offset to be 043Screen.YOffset = Object.Scroll4445// Center the camera to be around 256 pixels in, to make sure the text is centered46TempValue0 = 25647TempValue0 -= Screen.CenterX4849Screen.XOffset = TempValue05051// This Object is what draws the backgound, so it needs to draw low52Object.DrawOrder = 05354if Object.Timer < 855// Hold for a moment...5657Object.Timer++58else59// Start fading in6061Object.Timer = 25462PlayMusic(0)63Object.State++64end if6566// Set the screen to be black for now67SetScreenFade(0, 0, 0, 255)68break6970case CREDITSCONTROL_FADEIN71if Object.Timer > 072SetScreenFade(0, 0, 0, Object.Timer)7374Object.Timer -= 875else76Object.State++77end if78break7980case CREDITSCONTROL_MAIN81Object.Scroll++8283// Speed up the credits if the player wants84if KeyDown[0].ButtonA == true85Object.Scroll++86end if8788if KeyDown[0].ButtonC == true89Object.Scroll++90end if9192TempValue0 = Object.Scroll93TempValue0 >>= 19495Screen.YOffset = TempValue09697// If at the end of the Credits, then fade out98if Object.Scroll > Object.EndCredits99Object.State = CREDITSCONTROL_FADEOUT100Object.Timer = 0101end if102103// And then, let the Player just skip the Credits if they want to104105if KeyPress[0].Start == true106Object.State = CREDITSCONTROL_FADEOUT107Object.Timer = 0108end if109110if KeyPress[0].ButtonB == true111Object.State = CREDITSCONTROL_FADEOUT112Object.Timer = 0113end if114115CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)116if CheckResult > -1117Object.State = CREDITSCONTROL_FADEOUT118Object.Timer = 0119end if120break121122case CREDITSCONTROL_FADEOUT123if Object.Timer < 320124Object.Timer += 8125Music.Volume -= 2126else127StopMusic()128129// Go back to the menu now130#platform: Use_Origins // Call Origins movie131Engine.State = ENGINE_WAIT132133// Unlock ending on the Museum134game.callbackParam0 = true135EngineCallback(NOTIFY_STATS_MOVIE)136#endplatform137138#platform: Use_Standalone139Stage.ActiveList = PRESENTATION_STAGE140Stage.ListPos = STAGE_P_MENU141LoadStage()142#endplatform143end if144145// Have a maximum fade value of 255, since that's all that a byte can hold146TempValue0 = Object.Timer147if TempValue0 > 255148TempValue0 = 255149end if150151SetScreenFade(0, 0, 0, TempValue0)152break153154end switch155156end sub157158159sub ObjectDraw160161// The scene doesn't have a background or anything, so draw a Black Rectangle here to avoid frame smear162DrawRect(0, 0, Screen.XSize, Screen.YSize, 0, 0, 0, 255)163164end sub165166167sub ObjectStartup168// There's no exact "credits" song for either region, per se, so169// these tracks are used instead170if Options.Soundtrack == OST_JP171SetMusicTrack("JP/TimeAttack.ogg", 0, 100512)172else173SetMusicTrack("US/DAGarden.ogg", 0, 117382)174end if175176// Note: On Standard Platforms (ie PC 2012 & consoles) "Data/Game/Credits_Console.txt" is used instead177// (Though, Origins does indeed use the "Mobile" file, and mobile versions of couse do too)178LoadTextFile(MENU_1, "Data/Game/Credits_Mobile.txt", false)179180// In this scene, we control the camera manually181Screen.CameraEnabled = false182183// Place the Credits Control object into the scene184Object[0].Type = TypeName[Credits Control]185186// Make sure that it's always active, since it's the master control in this scene187Object[0].Priority = PRIORITY_ACTIVE188189// Get the row count of how many entries there are in the credits file190GetTextInfo(TempValue1, MENU_1, TEXTINFO_ROWCOUNT, 0, 0)191192// Find the first unoccupied object slot in the stage193ArrayPos0 = 32194while Object[ArrayPos0].Type != TypeName[Blank Object]195ArrayPos0++196loop197198// Create all the Credits text199// - TempValue0 is the current line being read from the file200// - TempValue2 is the X Position to spawn the text at (stays constant)201// - TempValue3 is the Y Position to spawn the text at202203// Starting values:204205// Starting line should be 0 (ofc)206TempValue0 = 0207208// X Position should be 256 pixels to the right209TempValue2 = 0x1000000210211// Starting Y Position should be 256 pixels as well212TempValue3 = 0x1000000213214// Now, let's enter the loop!215while TempValue0 < TempValue1216217// Get what type of entry it is218// [Reading the number inside the brackets]219GetTextInfo(TempValue4, MENU_1, TEXTINFO_TEXTDATA, TempValue0, 1)220221// Get the length of the entry222GetTextInfo(TempValue5, MENU_1, TEXTINFO_TEXTSIZE, TempValue0, 0)223224if TempValue5 == 0225// This is a blank line, so don't put any text on the current line and instead create a new line 22 pixels tall226TempValue3 += 0x160000227else228if TempValue4 == 48 // '0' character229ResetObjectEntity(ArrayPos0, TypeName[Text Font 1], 0, TempValue2, TempValue3)230Object[ArrayPos0].TargetLine = TempValue0231ArrayPos0++232233// 22 pixels difference234TempValue3 += 0x160000235else236if TempValue4 == 49 // '1' character237ResetObjectEntity(ArrayPos0, TypeName[Text Font 2], 0, TempValue2, TempValue3)238Object[ArrayPos0].TargetLine = TempValue0239ArrayPos0++240241// 14 pixels difference242TempValue3 += 0xE0000243else244if TempValue4 == 50 // '2' character245ResetObjectEntity(ArrayPos0, TypeName[Text Font 3], 0, TempValue2, TempValue3)246Object[ArrayPos0].TargetLine = TempValue0247ArrayPos0++248249// 14 pixels difference250TempValue3 += 0xE0000251end if252end if253end if254end if255256TempValue0++257loop258259TempValue3 -= 0xE0000 // 14 pixels260Object[0].EndCredits = TempValue3261Object[0].EndCredits >>= 15262263end sub264265266// ========================267// Editor Subs268// ========================269270sub RSDKDraw271DrawSprite(0)272end sub273274275sub RSDKLoad276LoadSpriteSheet("Global/Display.gif")277SpriteFrame(-16, -16, 32, 32, 1, 143) // "Script" Icon278279SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")280end sub281282283