Path: blob/main/Scripts/Menu/SoundMenu.txt
1319 views
//--------------Sonic CD Soundtrack Menu Script---------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.FadeValue6#alias Object.Value1 : Object.SelectedOption7#alias Object.Value2 : Object.EggmanAnimTimer8#alias Object.Value3 : Object.NoteOscillation910//Object[33] is MenuHeading11#alias Object[33].State : MenuHeading.State12#alias Object[33].PropertyValue : MenuHeading.Header1314//Object[-1] is MenuWindow15#alias Object[-1].State : MenuWindow.State1617// Soundtrack Options18#alias -1 : OST_NONE // Touching nothing on mobile19#alias 0 : OST_JP20#alias 1 : OST_US2122// States23#alias 0 : SOUNDMENU_INITIALIZE24#alias 1 : SOUNDMENU_OST_SELECTION25#alias 2 : SOUNDMENU_OST_SELECTED26#alias 3 : SOUNDMENU_BACK27#alias 4 : SOUNDMENU_EXIT28#alias 5 : SOUNDMENU_RETURN_TO_TITLE2930// Menu Heading States31#alias 1 : MENUHEADING_LEAVE_SCREEN3233// Menu Heading Property Values34#alias 5 : MAINMENU_HEADER3536// Menu Window States37#alias 3 : MENUWINDOW_SHRINK3839// Menu Button States40#alias 1 : MENUBUTTON_BUTTONS_IN4142// Presentation Stage43#alias 0 : STAGE_P_TITLE4445// Global SFX46#alias 23 : SFX_G_MENUBUTTON47#alias 27 : SFX_G_SELECT4849// Stage SFX50#alias 1 : SFX_S_BACKBUTTON5152// Languages53#alias 0 : LANG_ENGLISH54#alias 1 : LANG_FRENCH55#alias 2 : LANG_ITALIAN56#alias 3 : LANG_DEUTSCH57#alias 4 : LANG_SPANISH58#alias 5 : LANG_JAPANESE596061sub ObjectMain62switch Object.State63case SOUNDMENU_INITIALIZE6465#platform: Standard66Object.SelectedOption = Options.Soundtrack67#endplatform6869#platform: Mobile70if Options.PhysicalControls == false71Object.SelectedOption = OST_NONE72else73Object.SelectedOption = Options.Soundtrack74end if75#endplatform7677#platform: Use_Origins78if Options.PhysicalControls == false79Object.SelectedOption = OST_NONE80else81Object.SelectedOption = Options.Soundtrack82end if83#endplatform848586if Object.FadeValue < 25687Object.Alpha = Object.FadeValue88Object.FadeValue += 689else90Object.FadeValue = 091Object.Alpha = 25592Object.State = SOUNDMENU_OST_SELECTION93end if94break9596case SOUNDMENU_OST_SELECTION9798#platform: Standard99CheckResult = true100#endplatform101102#platform: Mobile103CheckEqual(Options.PhysicalControls, true)104#endplatform105106#platform: Use_Origins107CheckEqual(Options.PhysicalControls, true)108#endplatform109110// 2011 Steam lacks Options.PhysicalControls, so we force it here first and the other platforms can override it111if CheckResult == true112// Physical Controls113if KeyPress[0].Left == true114Object.SelectedOption--115if Object.SelectedOption < OST_JP116Object.SelectedOption = OST_US117end if118PlaySfx(SFX_G_MENUBUTTON, false)119end if120121if KeyPress[0].Right == true122Object.SelectedOption++123if Object.SelectedOption > OST_US124Object.SelectedOption = OST_JP125end if126PlaySfx(SFX_G_MENUBUTTON, false)127end if128// Enable touch controls if the screen is touched129CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)130if CheckResult > -1131#platform: Mobile132Options.PhysicalControls = false133Object.SelectedOption = OST_NONE134#endplatform135#platform: Use_Origins136Options.PhysicalControls = false137Object.SelectedOption = OST_NONE138#endplatform139end if140else141// Touch Controls142143// Check if JP button is touched144CheckTouchRect(0, 0, Screen.XSize, Screen.YSize)145TempValue3 = CheckResult146TempValue0 = Screen.CenterX147TempValue0 -= 90148TempValue1 = Screen.CenterX149TempValue1 -= 22150CheckTouchRect(TempValue0, 112, TempValue1, 144)151if CheckResult > -1152Object.SelectedOption = OST_JP153else154if TempValue3 < 0155if Object.SelectedOption == OST_JP156KeyPress[0].Start = true157end if158else159if Object.SelectedOption == OST_JP160Object.SelectedOption = OST_NONE161end if162end if163end if164165// Check if US button is touched166TempValue0 = Screen.CenterX167TempValue0 += 22168TempValue1 = Screen.CenterX169TempValue1 += 90170CheckTouchRect(TempValue0, 112, TempValue1, 144)171if CheckResult > -1172Object.SelectedOption = OST_US173else174if TempValue3 < 0175if Object.SelectedOption == OST_US176KeyPress[0].Start = true177end if178else179if Object.SelectedOption == OST_US180Object.SelectedOption = OST_NONE181end if182end if183end if184185CallFunction(MenuHeading_CheckTouchBack)186187// Enable physical controls if a button is pressed188if KeyPress[0].Left == true189Object.SelectedOption = OST_US190191#platform: Use_Origins192Options.PhysicalControls = true193#endplatform194#platform: Mobile195Options.PhysicalControls = true196#endplatform197198end if199if KeyPress[0].Right == true200Object.SelectedOption = OST_JP201202#platform: Use_Origins203Options.PhysicalControls = true204#endplatform205#platform: Mobile206Options.PhysicalControls = true207#endplatform208209end if210end if211212CheckResult = false213214if Object.SelectedOption > OST_NONE // If a button was touched215if KeyPress[0].Start == true216CheckResult = true217end if218219if KeyPress[0].ButtonA == true220CheckResult = true221end if222end if223224if CheckResult == true225Options.Soundtrack = Object.SelectedOption226SaveRAM[38] = Options.Soundtrack227Object.State = SOUNDMENU_OST_SELECTED228StopMusic()229PlaySfx(SFX_G_SELECT, false)230WriteSaveRAM()231#platform: Use_Origins232game.callbackParam0 = Options.Soundtrack233EngineCallback(NOTIFY_SOUND_TRACK)234#endplatform235end if236237if KeyPress[0].ButtonB == true238Object.FadeValue = 248239Object.State = SOUNDMENU_BACK240PlayStageSfx(SFX_S_BACKBUTTON, false)241end if242break243244case SOUNDMENU_OST_SELECTED245if Object.AnimationTimer < 30246Object.AnimationTimer++247else248Object.AnimationTimer = 0249Object.State = SOUNDMENU_BACK250PlayMusic(Options.Soundtrack)251end if252break253254case SOUNDMENU_BACK255#platform: Use_Origins256Object.FadeValue = 0257Object.State = SOUNDMENU_RETURN_TO_TITLE258break259#endplatform260// Making a fallthrough here so standalone datafiles can return to the menus as usual261case SOUNDMENU_EXIT262if Object.FadeValue > 0263Object.Alpha = Object.FadeValue264Object.FadeValue -= 8265else266// Tell the other objects the menu is being exited267Object.Type = TypeName[Blank Object]268MenuWindow.State = MENUWINDOW_SHRINK269//All of this is MenuButton Objects270Object[34].State = MENUBUTTON_BUTTONS_IN271Object[35].State = MENUBUTTON_BUTTONS_IN272Object[36].State = MENUBUTTON_BUTTONS_IN273Object[37].State = MENUBUTTON_BUTTONS_IN274Object[38].State = MENUBUTTON_BUTTONS_IN275Object[39].State = MENUBUTTON_BUTTONS_IN276Object[40].State = MENUBUTTON_BUTTONS_IN277Object[41].State = MENUBUTTON_BUTTONS_IN278Object[42].State = MENUBUTTON_BUTTONS_IN279//End280MenuHeading.State = MENUHEADING_LEAVE_SCREEN281MenuHeading.Header = MAINMENU_HEADER // Set the heading to "MAIN MENU"282end if283break284285#platform: Use_Origins286case SOUNDMENU_RETURN_TO_TITLE287Object.FadeValue += 4288if Object.FadeValue == 384289Stage.ActiveList = PRESENTATION_STAGE290Stage.ListPos = STAGE_P_TITLE291StopMusic()292LoadStage()293end if294SetScreenFade(0, 0, 0, Object.FadeValue)295break296#endplatform297end switch298end sub299300301sub ObjectDraw302// Animate and draw Eggman303TempValue0 = Object.EggmanAnimTimer304TempValue0 >>= 5305DrawSpriteScreenFX(TempValue0, FX_INK, Screen.CenterX, Screen.CenterY)306Object.EggmanAnimTimer++307Object.EggmanAnimTimer &= 63308309// Oscillate and draw the music notes310Sin(TempValue0, Object.NoteOscillation)311TempValue0 >>= 6312TempValue0 += Screen.CenterY313DrawSpriteScreenFX(6, FX_INK, Screen.CenterX, TempValue0)314Sin(TempValue0, Object.NoteOscillation)315TempValue0 >>= 6316FlipSign(TempValue0)317TempValue0 += Screen.CenterY318DrawSpriteScreenFX(7, FX_INK, Screen.CenterX, TempValue0)319Object.NoteOscillation += 2320Object.NoteOscillation &= 511321322// Set up the positioning for the buttons323TempValue0 = Screen.CenterX324TempValue0 -= 56325TempValue1 = Screen.CenterX326TempValue1 += 56327TempValue3 = Screen.CenterY328TempValue3 += 8329330// Draw the JP button331if Object.SelectedOption == OST_JP332TempValue2 = Object.AnimationTimer333TempValue2 &= 3334TempValue2 >>= 1335TempValue2 += 2336DrawSpriteScreenFX(TempValue2, FX_INK, TempValue0, TempValue3)337else338DrawSpriteScreenFX(3, FX_INK, TempValue0, TempValue3)339end if340341// Draw the US button342if Object.SelectedOption == OST_US343TempValue2 = Object.AnimationTimer344TempValue2 &= 3345TempValue2 >>= 1346TempValue2 += 4347DrawSpriteScreenFX(TempValue2, FX_INK, TempValue1, TempValue3)348else349DrawSpriteScreenFX(5, FX_INK, TempValue1, TempValue3)350end if351352// Draw the border for the soundtrack that's currently playing353if Options.Soundtrack == OST_JP354DrawSpriteScreenFX(8, FX_INK, TempValue0, TempValue3)355else356DrawSpriteScreenFX(8, FX_INK, TempValue1, TempValue3)357end if358end sub359360361sub ObjectStartup362switch Engine.Language363case LANG_ENGLISH364LoadSpriteSheet("Menu/MenuGfx2_EN.gif")365break366case LANG_FRENCH367LoadSpriteSheet("Menu/MenuGfx2_FR.gif")368break369case LANG_ITALIAN370LoadSpriteSheet("Menu/MenuGfx2_IT.gif")371break372case LANG_DEUTSCH373LoadSpriteSheet("Menu/MenuGfx2_DE.gif")374break375case LANG_SPANISH376LoadSpriteSheet("Menu/MenuGfx2_ES.gif")377break378case LANG_JAPANESE379LoadSpriteSheet("Menu/MenuGfx2_JP.gif")380break381end switch382383SpriteFrame(-20, -56, 40, 40, 259, 513) // #0 - Eggman 1384SpriteFrame(-20, -56, 40, 40, 259, 554) // #1 - Eggman 2385SpriteFrame(-32, -10, 64, 21, 300, 535) // #2 - JP Selected386SpriteFrame(-32, -10, 64, 21, 300, 513) // #3 - JP Unselected387SpriteFrame(-32, -10, 64, 21, 365, 535) // #4 - US Selected388SpriteFrame(-32, -10, 64, 21, 365, 513) // #5 - US Unselected389SpriteFrame(-46, -48, 11, 19, 300, 557) // #6 - Music Notes 1390SpriteFrame(32, -48, 17, 16, 312, 557) // #7 - Music Notes 2391SpriteFrame(-35, -13, 70, 27, 430, 497) // #8 - Current Soundtrack Border392end sub393394395// ========================396// Editor Subs397// ========================398399sub RSDKDraw400DrawSprite(0)401end sub402403404sub RSDKLoad405LoadSpriteSheet("Menu/MenuGfx2_EN.gif")406SpriteFrame(-20, -56, 40, 40, 259, 513) // #0 - Eggman 1407408SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")409end sub410411412