Path: blob/main/Scripts/Global/HUD.txt
1319 views
//-------------------Sonic CD HUD Script----------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value3 : Object.DrawFunction6#alias Object.Value4 : Object.FlashTimer7#alias Object.Value5 : Object.PrevTimePeriod8#alias Object.Value6 : Object.TimeOver910#alias Object.PropertyValue : Object.CurrentTimePeriod1112// Player Aliases13#alias Player.Value0 : Player.Rings1415#alias 0 : PLAYER_SONIC_A16#alias 1 : PLAYER_TAILS_A1718// Warp Destination19#alias 1 : WARPDEST_PAST20#alias 2 : WARPDEST_FUTURE2122// Device Type23#alias 0 : RETRO_STANDARD2425// Function declarations26#function HUD_DrawStandard27#function HUD_DrawMobile282930function HUD_DrawStandard31#platform: Use_Origins32TempValue6 = game.coinMode3334if game.playMode == BOOT_PLAYMODE_MISSION35// In Missions, don't draw the main HUD here36// Instead, signal to the HE2 part of the engine to draw it from there3738if game.missionEnd == false39game.hudEnable = HUDENABLE_ON40end if4142// These pair of temps aren't really used, at least with what's set here43TempValue1 = 6944TempValue5 = 2124546// In Mission mode, this script is used to monitor Time Period changes47// -> Nothing's still drawn here, though48TempValue6 = true49else50if game.playMode == BOOT_PLAYMODE_BOSSRUSH51// In Boss Rush, have the Engine draw the HUD rather than here from script52game.hudEnable = HUDENABLE_ON5354// Similarly, these pair of values aren't exactly used here, either55TempValue1 = 6956TempValue5 = 2125758// In Boss Rush, we use lives rather than Coins59TempValue6 = false60else61if game.coinMode != false62game.hudEnable = HUDENABLE_ON63end if6465// First, draw the Score/Time/Rings text66DrawSpriteScreenXY(10, 17, 13)6768// Record the current time69TempValue2 = Stage.Minutes70TempValue3 = Stage.Seconds71TempValue4 = Stage.MilliSeconds7273// Check if the timer's minutes are passing 974CheckGreater(TempValue2, 9)7576TempValue5 = CheckResult7778// Or check to see if the Time Over override is active79CheckNotEqual(Object.TimeOver, false)8081// Combine the previous two results into one82CheckResult |= TempValue58384if CheckResult != false // If we exceeded the 10 minutes, display 9'59'9985TempValue2 = 986TempValue3 = 5987TempValue4 = 9988end if8990// Start flashing Time at minute 991if TempValue2 == 992if Object.FlashTimer > 793DrawSpriteScreenXY(11, 17, 29)94end if95end if96#endplatform9798#platform: Use_Standalone99// First, draw the Score/Time/Rings text100DrawSpriteScreenXY(10, 17, 13)101102// Start flashing Time at minute 9103if Stage.Minutes == 9104if Object.FlashTimer > 7105DrawSpriteScreenXY(11, 17, 29)106end if107end if108#endplatform109110// Flash the Rings text if the player doesn't have rings111if Player.Rings == 0112if Object.FlashTimer > 7113DrawSpriteScreenXY(12, 17, 45)114end if115end if116117// Draw the timer's tick marks118DrawSpriteScreenXY(13, 67, 29)119120// Now, draw all the numbers121DrawNumbers(0, 104, 13, Player.Score, 6, 8, false) // Score122123#platform: Use_Standalone124DrawNumbers(0, 104, 29, Stage.MilliSeconds, 2, 8, true) // Milliseconds125DrawNumbers(0, 80, 29, Stage.Seconds, 2, 8, 1) // Seconds126DrawNumbers(0, 56, 29, Stage.Minutes, 1, 8, 1) // Minutes127#endplatform128129#platform: Use_Origins130DrawNumbers(0, 104, 29, TempValue4, 2, 8, true) // Milliseconds131DrawNumbers(0, 80, 29, TempValue3, 2, 8, true) // Seconds132DrawNumbers(0, 56, 29, TempValue2, 1, 8, true) // Minutes133#endplatform134135DrawNumbers(0, 80, 45, Player.Rings, 3, 8, false) // Rings136137if Stage.DebugMode == true // In Debug Mode, draw the position of the Player138// Get the truncated X Position of the Player139TempValue0 = Player.XPos140TempValue0 >>= 16141142// Set screen XPos for this value143TempValue1 = Screen.XSize144TempValue1 -= 24145146// Draw the X Position numbers147DrawNumbers(0, TempValue1, 13, TempValue0, 5, 8, true)148149// Get the truncated Y Position of the Player150TempValue0 = Player.YPos151TempValue0 >>= 16152153if TempValue0 < 0154// YPos is always drawn as positive155FlipSign(TempValue0)156end if157158// Draw the Y Position159DrawNumbers(0, TempValue1, 29, TempValue0, 5, 8, true)160161TempValue1 -= 42162// Draw the X/Y icons163DrawSpriteScreenXY(14, TempValue1, 15)164DrawSpriteScreenXY(21, TempValue1, 31)165end if166#platform: Use_Origins167end if168end if169170if TempValue6 == false // Using Lives171#endplatform172// Get the current Time Period, then add it's equivalent sprite id173TempValue0 = Object.CurrentTimePeriod174TempValue0 += 17175// Now, draw the corresponding life icon for the time period176DrawSpriteScreenXY(TempValue0, 16, 212)177// Draw the X/times icon178DrawSpriteScreenXY(14, 32, 220)179180// Only draw as many digits as the Lives has181if Player.Lives < 10182DrawNumbers(0, 40, 217, Player.Lives, 1, 8, true)183TempValue1 = 52184else185DrawNumbers(0, 48, 217, Player.Lives, 2, 8, true)186TempValue1 = 60187end if188TempValue5 = 214189#platform: Use_Origins190else // Using Coins191// This TempValue0 isn't really used...192TempValue0 = Object.CurrentTimePeriod193// See if the Time Period's changed194if Object.PrevTimePeriod != Object.CurrentTimePeriod195Object.PrevTimePeriod = Object.CurrentTimePeriod196197game.callbackParam0 = Object.CurrentTimePeriod // Signal the new period over to the engine198EngineCallback(NOTIFY_FUTURE_PAST)199end if200201// In Missions, Coins shouldn't be drawn here202if game.playMode != BOOT_PLAYMODE_MISSION203// Get the current Time Period204TempValue0 = Object.CurrentTimePeriod205206// And bump it up by 22 to match the Coins Sprite Frame IDs207TempValue0 += 22208209// Draw the Coins icon210DrawSpriteScreenXY(TempValue0, 16, 212)211212// Draw the two halves of the "COINS" text213DrawSpriteScreenXY(26, 33, 213)214DrawSpriteScreenXY(27, 51, 213)215216// X217DrawSpriteScreenXY(28, 36, 222)218219// And then, the actual Coin count220DrawNumbers(29, 59, 220, game.coinCount, 3, 8, false)221end if222223TempValue1 = 69224TempValue5 = 212225end if226#endplatform227228switch Warp.Destination229// Draw the past sign, flicker it while trying to warp230case WARPDEST_PAST231if Warp.Timer < 100232DrawSpriteScreenXY(15, TempValue1, TempValue5)233else234TempValue0 = Warp.Timer235TempValue0 &= 1236if TempValue0 == 0237DrawSpriteScreenXY(15, TempValue1, TempValue5)238end if239end if240break241242case WARPDEST_FUTURE243// Draw the future sign, flicker it while trying to warp244if Warp.Timer < 100245DrawSpriteScreenXY(16, TempValue1, TempValue5)246else247TempValue0 = Warp.Timer248TempValue0 &= 1249if TempValue0 == 0250DrawSpriteScreenXY(16, TempValue1, TempValue5)251end if252end if253break254end switch255end function256257258function HUD_DrawMobile259// Aside from being inside a function, this is the same code from the original mobile release260261// Draw the Score, Time, Rings text262DrawSpriteScreenXY(10, 17, 9)263264// Start flashing Time at minute 9265if Stage.Minutes == 9266if Object.FlashTimer > 7267DrawSpriteScreenXY(11, 17, 25)268end if269end if270// Flash the Rings text at 0 rings271if Player.Rings == 0272if Object.FlashTimer > 7273DrawSpriteScreenXY(12, 17, 41)274end if275end if276277// Draw the timer's tick marks278DrawSpriteScreenXY(13, 67, 25)279280// Now, draw all the numbers281DrawNumbers(0, 104, 9, Player.Score, 6, 8, false)282283DrawNumbers(0, 104, 25, Stage.MilliSeconds, 2, 8, true) // Milliseconds284DrawNumbers(0, 80, 25, Stage.Seconds, 2, 8, true) // Seconds285DrawNumbers(0, 56, 25, Stage.Minutes, 1, 8, true) // Minutes286287DrawNumbers(0, 80, 41, Player.Rings, 3, 8, false)288289// Debug Mode coordinates drawing290if Stage.DebugMode == true291// Get the truncated X Position of the Player292TempValue0 = Player.XPos293TempValue0 >>= 16294295// Set screen XPos for this value296TempValue1 = Screen.XSize297TempValue1 -= 16298299// Draw the X Position numbers300DrawNumbers(0, TempValue1, 25, TempValue0, 5, 8, true)301302// Get the truncated Y Position of the Player303TempValue0 = Player.YPos304TempValue0 >>= 16305306if TempValue0 < 0307// YPos is always drawn as positive308FlipSign(TempValue0)309310end if311312// Draw the Y Position313DrawNumbers(0, TempValue1, 41, TempValue0, 5, 8, true)314315TempValue1 -= 42316317// Draw the X/Y icons318DrawSpriteScreenXY(14, TempValue1, 27)319DrawSpriteScreenXY(21, TempValue1, 43)320end if321322// Lives Counter323324// Get the X Position to draw the life icon at325TempValue1 = Screen.XSize326TempValue1 -= 48327// Get the current Time Period, then add it's equivalent sprite id328TempValue0 = Object.CurrentTimePeriod329TempValue0 += 17330// Now, draw the corresponding life icon for the time period331DrawSpriteScreenXY(TempValue0, TempValue1, 8)332333TempValue1 += 16334// Draw the X/times icon335DrawSpriteScreenXY(14, TempValue1, 16)336337// Only draw as many digits as the Lives has338if Player.Lives < 10339TempValue1 += 8340DrawNumbers(0, TempValue1, 13, Player.Lives, 1, 8, true)341else342TempValue1 += 16343DrawNumbers(0, TempValue1, 13, Player.Lives, 2, 8, true)344TempValue1 -= 8345end if346347switch Warp.Destination348// Draw the past sign, flicker it while trying to warp349case WARPDEST_PAST350TempValue1 -= 79351if Warp.Timer < 100352DrawSpriteScreenXY(15, TempValue1, 8)353else354TempValue0 = Warp.Timer355TempValue0 &= 1356if TempValue0 == 0357DrawSpriteScreenXY(15, TempValue1, 8)358end if359end if360break361// Draw the future sign, flicker it while trying to warp362case WARPDEST_FUTURE363TempValue1 -= 79364if Warp.Timer < 100365DrawSpriteScreenXY(16, TempValue1, 8)366else367TempValue0 = Warp.Timer368TempValue0 &= 1369if TempValue0 == 0370DrawSpriteScreenXY(16, TempValue1, 8)371end if372end if373break374end switch375376end function377378379sub ObjectDraw380if Player.Rings == 0381Object.FlashTimer++382383if Object.FlashTimer == 16384Object.FlashTimer = 0385end if386else387if Stage.Minutes == 9388Object.FlashTimer++389390if Object.FlashTimer == 16391Object.FlashTimer = 0392end if393end if394end if395396#platform: Use_Origins397if game.timeOver != false398Object.TimeOver = true399end if400#endplatform401402// Call the corresponding drawing function for the HUD403CallFunction(Object.DrawFunction)404end sub405406407sub ObjectStartup408// Standard Platforms and Mobile Platforms have different drawing routines409// In Origins, only the Standard version was updated and the Mobile version was left410if Stage.PlayerListPos == PLAYER_SONIC_A // PLAYER_SONIC in origins411LoadSpriteSheet("Global/Display.gif")412end if413if Stage.PlayerListPos == PLAYER_TAILS_A // PLAYER_TAILS in origins414LoadSpriteSheet("Global/Display_t.gif")415end if416#platform: Use_Origins417if Stage.PlayerListPos == PLAYER_KNUCKLES418LoadSpriteSheet("Global/Display_K.gif")419end if420if Stage.PlayerListPos == PLAYER_AMY421LoadSpriteSheet("Global/Display_A.gif")422end if423424if Engine.DeviceType == RETRO_STANDARD425Object[24].DrawFunction = HUD_DrawStandard426else427Object[24].DrawFunction = HUD_DrawMobile428end if429#endplatform430431// Has to be this way to ensure steam 2011 cd will still work432#platform: Use_Standalone433#platform: Standard434Object[24].DrawFunction = HUD_DrawStandard435#endplatform436#endplatform437438#platform: Use_Standalone439#platform: Mobile440Object[24].DrawFunction = HUD_DrawMobile441#endplatform442#endplatform443444// 0-9 - Number Digits445SpriteFrame(0, 0, 8, 11, 1, 50)446SpriteFrame(0, 0, 8, 11, 10, 50)447SpriteFrame(0, 0, 8, 11, 19, 50)448SpriteFrame(0, 0, 8, 11, 28, 50)449SpriteFrame(0, 0, 8, 11, 1, 62)450SpriteFrame(0, 0, 8, 11, 10, 62)451SpriteFrame(0, 0, 8, 11, 19, 62)452SpriteFrame(0, 0, 8, 11, 28, 62)453SpriteFrame(0, 0, 8, 11, 1, 74)454SpriteFrame(0, 0, 8, 11, 10, 74)455456// 10 - Score, Time, Rings text457SpriteFrame(0, 0, 39, 43, 1, 1)458459// 11 - Red Time text460SpriteFrame(0, 0, 31, 11, 1, 119)461462// 12 - Red Rings text463SpriteFrame(0, 0, 39, 11, 1, 131)464465// 13 - Tick marks466SpriteFrame(0, 0, 29, 4, 1, 45)467468// 14 - Yellow X (used for debug & lives count)469SpriteFrame(0, 0, 8, 8, 1, 98)470471// 15 -Past Sign472SpriteFrame(0, 0, 32, 16, 90, 67)473474// 16 - Future Sign475SpriteFrame(0, 0, 32, 16, 123, 67)476477// 17 - Present Life Icon478SpriteFrame(0, 0, 16, 16, 187, 189)479480// 18 - Past Life Icon481SpriteFrame(0, 0, 16, 16, 204, 189)482483// 19-20 - Future Life Icon (duplicated)484SpriteFrame(0, 0, 16, 16, 237, 223)485SpriteFrame(0, 0, 16, 16, 237, 223)486487// 21 - Debug Y488SpriteFrame(0, 0, 8, 8, 10, 98)489490#platform: Use_Origins491// 22 - Coins Icon492SpriteFrame(0, 0, 16, 16, 186, 108)493494// 23 - Past Coins Icon495SpriteFrame(0, 0, 16, 16, 1, 257)496497// 24-25 - Future Coins Icon (duplicated as well)498SpriteFrame(0, 0, 16, 16, 18, 257)499SpriteFrame(0, 0, 16, 16, 18, 257)500501// 26 - "COI"502SpriteFrame(0, 0, 18, 7, 203, 108)503504// 27 - "NS"505SpriteFrame(0, 0, 18, 7, 203, 116)506507// 28 - Small X (used for the Coins count)508SpriteFrame(0, 0, 6, 6, 186, 125)509510// 29-38 - Small Numbers, for the Coins counter511SpriteFrame(0, 0, 8, 8, 19, 98)512SpriteFrame(0, 0, 8, 8, 28, 98)513SpriteFrame(0, 0, 8, 8, 33, 119)514SpriteFrame(0, 0, 8, 8, 213, 1)515SpriteFrame(0, 0, 8, 8, 213, 10)516SpriteFrame(0, 0, 8, 8, 213, 19)517SpriteFrame(0, 0, 8, 8, 213, 28)518SpriteFrame(0, 0, 8, 8, 213, 37)519SpriteFrame(0, 0, 8, 8, 213, 46)520SpriteFrame(0, 0, 8, 8, 213, 55)521#endplatform522end sub523524525// ========================526// Editor Subs527// ========================528529sub RSDKEdit530if Editor.ReturnVariable == true531switch Editor.VariableID532case EDIT_VAR_PROPVAL // Property Value533case 0 // TimePeriod534CheckResult = Object.PropertyValue535break536end switch537else538switch Editor.VariableID539case EDIT_VAR_PROPVAL // Property Value540case 0 // TimePeriod541Object.PropertyValue = Editor.VariableValue542break543end switch544end if545end sub546547548sub RSDKDraw549DrawSprite(0)550end sub551552553sub RSDKLoad554LoadSpriteSheet("Global/Display.gif")555SpriteFrame(0, 0, 39, 43, 1, 1)556557AddEditorVariable("TimePeriod")558SetActiveVariable("TimePeriod")559AddEnumVariable("Present", 0)560AddEnumVariable("Past", 1)561AddEnumVariable("Good Future", 2)562AddEnumVariable("Bad Future", 3)563end sub564565566