Path: blob/main/Scripts/Special/BGEffects_S6.txt
1319 views
//-----------------Sonic CD BGEffects Script------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.DeformTimer6#alias Object.Value1 : Object.PaletteTimer7#alias Object.Value2 : Object.PrevAngle8#alias Object.Value3 : Object.FansTimer9#alias Object.Value4 : Object.CrunchersTimer10#alias Object.Value5 : Object.FansSprite11#alias Object.Value6 : Object.CrunchersSprite1213// Priority14#alias 1 : PRIORITY_ACTIVE1516// Deformation Layer17#alias 2 : DEFORM_BG181920sub ObjectDraw21// Animate the fans in the stage22Object.FansTimer++23if Object.FansTimer > 224Object.FansTimer = 025Object.FansSprite++26Object.FansSprite %= 327switch Object.FansSprite28case 029// Fans are 4x4 tiles, comprised of 8 unique tiles, so30// 8 individual tiles need to be updated to change the entire sprite31Copy16x16Tile(37, 348)32Copy16x16Tile(38, 349)33Copy16x16Tile(39, 350)34Copy16x16Tile(40, 351)35Copy16x16Tile(41, 352)36Copy16x16Tile(42, 353)37Copy16x16Tile(43, 354)38Copy16x16Tile(44, 355)39break4041case 142Copy16x16Tile(37, 356)43Copy16x16Tile(38, 357)44Copy16x16Tile(39, 358)45Copy16x16Tile(40, 359)46Copy16x16Tile(41, 360)47Copy16x16Tile(42, 361)48Copy16x16Tile(43, 362)49Copy16x16Tile(44, 363)50break5152case 253Copy16x16Tile(37, 364)54Copy16x16Tile(38, 365)55Copy16x16Tile(39, 366)56Copy16x16Tile(40, 367)57Copy16x16Tile(41, 368)58Copy16x16Tile(42, 369)59Copy16x16Tile(43, 370)60Copy16x16Tile(44, 371)61break6263end switch64end if6566Object.CrunchersTimer++67if Object.CrunchersTimer > 568Object.CrunchersTimer = 069Object.CrunchersSprite++70Object.CrunchersSprite &= 371switch Object.CrunchersSprite72case 073// Crunchers are 2x2 tiles, each tile unique,74// so 4 tiles need to be updated in order to completely change their sprite75Copy16x16Tile(134, 372)76Copy16x16Tile(135, 373)77Copy16x16Tile(136, 376)78Copy16x16Tile(137, 377)79break8081case 182Copy16x16Tile(134, 374)83Copy16x16Tile(135, 375)84Copy16x16Tile(136, 378)85Copy16x16Tile(137, 379)86break8788case 289Copy16x16Tile(134, 380)90Copy16x16Tile(135, 381)91Copy16x16Tile(136, 384)92Copy16x16Tile(137, 385)93break9495case 396Copy16x16Tile(134, 382)97Copy16x16Tile(135, 383)98Copy16x16Tile(136, 386)99Copy16x16Tile(137, 387)100break101102end switch103end if104105// Make the background all loopy106Object.DeformTimer++107if Object.DeformTimer > 1108TileLayer[1].DeformationOffset++109Object.DeformTimer = 0110end if111112#platform: SW_Rendering113// Animate the stage's palette for the background114// Palette changing is only available with the Software renderer,115// check out the HW Background Object for what's used with the Hardware renderer116117Object.PaletteTimer++118119if Object.PaletteTimer > 3120Object.PaletteTimer = 0121RotatePalette(209, 221, false)122end if123#endplatform124125// Find the difference between the current angle and the last angle126TempValue1 = Object.PrevAngle127TempValue2 = TileLayer[0].Angle128if TempValue1 < TempValue2129TempValue3 = TempValue2130TempValue3 -= TempValue1131if TempValue3 > 256132TempValue1 += 512133end if134else135TempValue3 = TempValue1136TempValue3 -= TempValue2137if TempValue3 > 256138TempValue2 += 512139end if140end if141142TempValue0 = TempValue1143TempValue0 -= TempValue2144145// Store the current angle for the same process next frame146Object.PrevAngle = TileLayer[0].Angle147148// Scroll the BG with parallax149TempValue1 = 0x02000 // An eight of a pixel, unused150TempValue2 = 0x20000 // 2 pixels151152TempValue1 *= TempValue0 // There was likely some layer this corresponded to, but in the final version, only the buildings layer [1] gets moved153TempValue2 *= TempValue0154155// Perhaps the unused value corresponded to the wave background - [0]?156HParallax[1].ScrollPos += TempValue2157158end sub159160161sub ObjectStartup162163// Setup Stage Bounds164// Aside from the Robotnik stage (which uses copies of these same numbers), this seems to be the only Special Stage with uneven left/right and top/bottom bounds165Stage.XBoundary1 = 0x2800000 // left bounds at 640 pixels166Stage.XBoundary2 = 0xD800000 // right bounds at 3456 pixels167Stage.YBoundary1 = 0x3000000 // upper bounds at 768 pixels168Stage.YBoundary2 = 0xD000000 // lower bounds at 3328 pixels169170// Reset deformation171SetLayerDeformation(DEFORM_BG, 64, 64, 0, 0, 0)172173#platform: HW_Rendering174// Load the map as a sheet if needed for the hardware renderer175176LoadSpriteSheet("Special/SSMap6.gif")177#endplatform178179// Setup all BGEffects objects in the level180// (There should only ever be one though)181ArrayPos0 = 32182while ArrayPos0 < 1056183if Object[ArrayPos0].Type == TypeName[BGEffects]184// Initialise its values185186// Make the object always active, as the stage should always animate even when its animator object is out of bounds187Object[ArrayPos0].Priority = PRIORITY_ACTIVE188189// Make the object the first thing to be drawn190Object[ArrayPos0].DrawOrder = 0191192// And setup its starting angle too, assuming Sonic's starting facing left193Object[ArrayPos0].PrevAngle = 368194195end if196197ArrayPos0++198loop199200end sub201202203// ========================204// Editor Subs205// ========================206207sub RSDKDraw208DrawSprite(0)209end sub210211212sub RSDKLoad213LoadSpriteSheet("Special/SSMap6.gif")214SpriteFrame(-256, -256, 512, 512, 0, 0)215216SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")217end sub218219220