Path: blob/main/Scripts/R8/FadeScreen.txt
1319 views
//----------------Sonic CD Fade Screen Script-----------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.Timer6#alias Object.Value1 : Object.Timer78// Player Aliases9#alias Object[0].Value0 : Player.Rings1011// States12#alias 0 : FADESCREEN_SETUP13#alias 1 : FADESCREEN_AMY14#alias 2 : FADESCREEN_FINALFEVER15#alias 3 : FADESCREEN_BLANK16#alias 4 : FADESCREEN_BOSSRUSH // Origins Exclusive1718// Property Values19#alias 0 : CUTSCENE_ENDING20#alias 1 : CUTSCENE_FINALFEVER2122// Game Mode Aliases23#alias 1 : MODE_SAVEGAME24#alias 2 : MODE_TIMEATTACK2526// Presentation Stages27#alias 0 : STAGE_P_TITLE28#alias 2 : STAGE_P_TATTACK29#alias 7 : STAGE_P_STAFFCREDITS30#alias 8 : STAGE_P_TAILSUNLOCK3132// Soundstrack33#alias 0 : OST_JP3435// Players36#alias 0 : PLAYER_SONIC_A37#alias 1 : PLAYER_TAILS_A3839// Engine States40#alias 1 : ENGINE_MAINGAME41#alias 8 : ENGINE_WAIT4243// Callbacks44#alias 4 : CALLBACK_FINISHGAME_NOTIFY4546sub ObjectMain47switch Object.State48case FADESCREEN_SETUP49if Object.Timer < 48050Object.Timer += 451Music.Volume--52else53Object.Timer = 22454if Object.PropertyValue == CUTSCENE_ENDING55Object.State++56else57Object.State += 258end if59end if6061if Object.PropertyValue == CUTSCENE_FINALFEVER62SetScreenFade(0, 0, 0, Object.Timer)63else64SetScreenFade(224, 224, 224, Object.Timer)65end if66break6768case FADESCREEN_AMY69if Object.Timer > 070Music.Volume--71Object.Timer -= 1672else73StopMusic()7475#platform: Use_Origins76EngineCallback(NOTIFY_BOSS_END)77TempValue0 = false78if game.playMode == BOOT_PLAYMODE_BOSSRUSH79TempValue0 = true80else81// Check if the player is replaying the stage from My Data & Rankings82if game.oneStageFlag != false83TempValue0 = true84EngineCallback(NOTIFY_ACT_FINISH)85game.callbackResult = -1 // Reset any callback result86game.callbackParam0 = 1 // 0 - Normal Retry, anything else - Show current and best time87game.callbackParam1 = Stage.ListPos // Get current stage88game.callbackParam2 = 0 // Unknown89EngineCallback(NOTIFY_STAGE_RETRY)90end if91end if92#endplatform93#platform: Use_Standalone94TempValue0 = false95#endplatform96if TempValue0 != false97Object.State = FADESCREEN_BOSSRUSH98else99if Options.GameMode == MODE_TIMEATTACK100TimeAttack.Result = Stage.Seconds101TimeAttack.Result *= 100102TempValue0 = Stage.Minutes103TempValue0 *= 6000104TimeAttack.Result += TempValue0105TimeAttack.Result += Stage.MilliSeconds106107TempValue0 = Stage.ListPos108TempValue0 %= 10109TempValue0 >>= 2110TempValue1 = Stage.ListPos111TempValue1 /= 10112TempValue1 *= 3113TempValue0 += TempValue1114TempValue0++115TempValue1 = Stage.Seconds116TempValue1 *= 100117TempValue2 = Stage.Minutes118TempValue2 *= 6000119TempValue1 += TempValue2120TempValue1 += Stage.MilliSeconds121SetLeaderboard(TempValue0, TempValue1)122Stage.ListPos = STAGE_P_TATTACK123else124EngineCallback(CALLBACK_FINISHGAME_NOTIFY)125if Player.Score > 0126if Options.GameMode == MODE_SAVEGAME127if Stage.DebugMode == false128SetLeaderboard(0, Player.Score)129end if130end if131end if132#platform: Use_Origins133game.callbackParam0 = StageStatsUsabilityParam1 // Enemies destroyed by any means134game.callbackParam1 = StageStatsUsabilityParam2 // Enemies destroyed by rolling135game.callbackParam2 = 0136EngineCallback(NOTIFY_STATS_ENEMY)137138game.callbackParam0 = Player.Rings139EngineCallback(NOTIFY_STATS_RING)140141game.callbackParam0 = StageStatsUsabilityParam5 // Lamp Post related142EngineCallback(NOTIFY_STATS_PARAM_1)143144game.callbackParam0 = 0 // Unknown145game.callbackParam1 = StageStatsUsabilityParam4 // Unknown146game.callbackParam2 = 0 // Unknown147EngineCallback(NOTIFY_STATS_CHARA_ACTION)148149EngineCallback(NOTIFY_ACT_FINISH)150151StageStatsUsabilityParam1 = 0152StageStatsUsabilityParam2 = 0153StageStatsUsabilityParam3 = 0154StageStatsUsabilityParam4 = 0155StatsUsabilityParam1 = 0156StatsUsabilityParam2 = 0157StatsUsabilityParam3 = 0158StatsUsabilityParam4 = 0159160if SpecialStage.TimeStones > 126 // 0b1111110, each '1' bit represents an obtained time stone161EngineCallback(NOTIFY_GOOD_ENDING)162else163if Good_Future_List > 0x3FFE // 0b11111111111110, each '1' bit represents a zone with the robot transporters destroyed164EngineCallback(NOTIFY_GOOD_ENDING)165end if166end if167#endplatform168169#platform: Use_Standalone170if Stage.PlayerListPos == PLAYER_SONIC_A171#endplatform172if SpecialStage.TimeStones > 126 // 0b1111110, each '1' bit represents an obtained time stone173LoadVideo("Good_Ending")174else175if Good_Future_List > 0x3FFE // 0b11111111111110, each '1' bit represents a zone with the robot transporters destroyed176LoadVideo("Good_Ending")177else178LoadVideo("Bad_Ending")179end if180end if181#platform: Use_Standalone182end if183#endplatform184185// Because of the way mobile cd worked (using the phone's native video player)186// it needed to reproduce separated videos depending of the soundtrack option187// for the sake of clarity and simplicity, the mobile code got commented out188//#platform: Use_Standalone189// if Stage.PlayerListPos == PLAYER_SONIC_A190//#endplatform191// if SpecialStage.TimeStones > 126 // 0b1111110, each '1' bit represents an obtained time stone192// if Options.Soundtrack == OST_JP193// LoadVideo("Good_Ending")194// else195// LoadVideo("Good_EndingUS")196// end if197// else198// if Good_Future_List > 0x3FFE // 0b11111111111110, each '1' bit represents a zone with the robot transporters destroyed199// if Options.Soundtrack == OST_JP200// LoadVideo("Good_Ending")201// else202// LoadVideo("Good_EndingUS")203// end if204// else205// if Options.Soundtrack == OST_JP206// LoadVideo("Bad_Ending")207// else208// LoadVideo("Bad_EndingUS")209// end if210// end if211// end if212//#platform: Use_Standalone213// end if214//#endplatform215216if SaveRAM[36] == false // Is Tails unlocked?217#platform: Use_Origins218if game.playMode == BOOT_PLAYMODE_CLASSIC219Stage.ListPos = STAGE_P_TITLE220Engine.State = ENGINE_WAIT221else222SaveRAM[36] = true223WriteSaveRAM()224Stage.ListPos = STAGE_P_TAILSUNLOCK225end if226#endplatform227228#platform: Use_Standalone229SaveRAM[36] = true230WriteSaveRAM()231Stage.ListPos = STAGE_P_TAILSUNLOCK232#endplatform233else234Stage.ListPos = STAGE_P_TITLE235#platform: Use_Origins236Engine.State = ENGINE_WAIT237#endplatform238end if239240#platform: Use_Decomp241// We don't really want to softlock the game, do we?242if Engine.State == ENGINE_WAIT243Engine.State = ENGINE_MAINGAME244end if245#endplatform246247#platform: Use_Origins248// Unlock ending on the Museum249game.callbackParam0 = true250EngineCallback(NOTIFY_STATS_MOVIE)251#endplatform252253#platform: Use_Standalone254// Originally the game checked if the player was using Sonic or Tails255// This got removed in Origins, but since it covers this whole thing, this workaround should do256if Stage.PlayerListPos == PLAYER_TAILS_A257Stage.ListPos = STAGE_P_STAFFCREDITS258end if259#endplatform260end if261Stage.ActiveList = PRESENTATION_STAGE262LoadStage()263end if264265end if266SetScreenFade(Object.Timer, Object.Timer, Object.Timer, 255)267break268269case FADESCREEN_FINALFEVER270if Object.Timer > 0271Music.Volume--272Object.Timer -= 16273else274StopMusic()275Stage.ListPos += 2 // Would load Final Fever (if it was there), assuming you're in R83C276LoadStage()277end if278break279280case FADESCREEN_BLANK281break282283case FADESCREEN_BOSSRUSH284SetScreenFade(255, 255, 255, 255)285break286end switch287end sub288289290// ========================291// Editor Subs292// ========================293294sub RSDKDraw295DrawSprite(0)296end sub297298299sub RSDKLoad300LoadSpriteSheet("Global/Display.gif")301SpriteFrame(-16, -16, 32, 32, 1, 143) // #0 - "Script" Icon302303SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")304end sub305306307