Path: blob/main/Scripts/Special/BGEffects_S1.txt
1319 views
//-----------------Sonic CD BGEffects Script------------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5// Values 0-1 are unused...6#alias Object.Value2 : Object.PrevAngle7#alias Object.Value3 : Object.FansTimer8#alias Object.Value4 : Object.CrunchersTimer9#alias Object.Value5 : Object.FansSprite10#alias Object.Value6 : Object.CrunchersSprite1112// Priority13#alias 1 : PRIORITY_ACTIVE1415// Deformation Layer16#alias 2 : DEFORM_BG171819sub ObjectDraw20// Animate the Fans21Object.FansTimer++22if Object.FansTimer > 223Object.FansTimer = 024Object.FansSprite++25Object.FansSprite %= 326switch Object.FansSprite27case 028// Fans are 4x4 tiles, with 8 unique tiles in them, so29// 8 tiles need to be updated to change the entire sprite30Copy16x16Tile(260, 420)31Copy16x16Tile(259, 421)32Copy16x16Tile(258, 422)33Copy16x16Tile(257, 423)34Copy16x16Tile(264, 424)35Copy16x16Tile(263, 425)36Copy16x16Tile(262, 426)37Copy16x16Tile(261, 427)38break3940case 141Copy16x16Tile(260, 428)42Copy16x16Tile(259, 429)43Copy16x16Tile(258, 430)44Copy16x16Tile(257, 431)45Copy16x16Tile(264, 432)46Copy16x16Tile(263, 433)47Copy16x16Tile(262, 434)48Copy16x16Tile(261, 435)49break5051case 252Copy16x16Tile(260, 436)53Copy16x16Tile(259, 437)54Copy16x16Tile(258, 438)55Copy16x16Tile(257, 439)56Copy16x16Tile(264, 440)57Copy16x16Tile(263, 441)58Copy16x16Tile(262, 442)59Copy16x16Tile(261, 443)60break6162end switch63end if6465// Animate the Crunchers66Object.CrunchersTimer++67if Object.CrunchersTimer > 568Object.CrunchersTimer = 069Object.CrunchersSprite++70Object.CrunchersSprite &= 371switch Object.CrunchersSprite72case 073// Crunchers are 2x2 tiles, so 4 tiles need to be updated74// in order to completely change their sprite75Copy16x16Tile(99, 444)76Copy16x16Tile(98, 445)77Copy16x16Tile(101, 448)78Copy16x16Tile(100, 449)79break8081case 182Copy16x16Tile(99, 446)83Copy16x16Tile(98, 447)84Copy16x16Tile(101, 450)85Copy16x16Tile(100, 451)86break8788case 289Copy16x16Tile(99, 452)90Copy16x16Tile(98, 453)91Copy16x16Tile(101, 456)92Copy16x16Tile(100, 457)93break9495case 396Copy16x16Tile(99, 454)97Copy16x16Tile(98, 455)98Copy16x16Tile(101, 458)99Copy16x16Tile(100, 459)100break101102end switch103end if104105// Find the difference between the current scroll and last scroll pos106TempValue1 = Object.PrevAngle107TempValue2 = TileLayer[0].Angle108if TempValue1 < TempValue2109TempValue3 = TempValue2110TempValue3 -= TempValue1111if TempValue3 > 256112// Account for looping113TempValue1 += 512114end if115else116TempValue3 = TempValue1117TempValue3 -= TempValue2118if TempValue3 > 256119// Account for looping (but now the other way!)120TempValue2 += 512121end if122end if123124TempValue0 = TempValue1125TempValue0 -= TempValue2126127// Store the current angle for use next frame128Object.PrevAngle = TileLayer[0].Angle129130// Move all the other BG layers in accordance with the difference from last frame131132TempValue1 = 0x02000 // This value isn't used, though it corresponds to the first unused background layer133TempValue2 = 0x20000134TempValue3 = 0x10000135136TempValue1 *= TempValue0 // See above137TempValue2 *= TempValue0138TempValue3 *= TempValue0139140// Presumably there was one more parallax updating here before that got cut, my best guess is that it'd be something like141// HParallax[1].ScrollPos += TempValue1142// That would update the background water in the scene, provided the layer is left enabled143// HParallax[0] is an option too, that would be the unused wave BG layer (disabled too)144145HParallax[2].ScrollPos += TempValue2146HParallax[3].ScrollPos += TempValue3147148end sub149150151sub ObjectStartup152153// Setup stage bounds154Stage.XBoundary1 = 0x3800000 // 896 pixels to the left155Stage.XBoundary2 = 0xC800000 // 3200 pixels to the right156Stage.YBoundary1 = 0x3800000 // 896 pixels upwards157Stage.YBoundary2 = 0xC800000 // 3200 pixels downwards158159// Set the initial BG position160161// Move the first layer 15 pixels to the right162// -> I don't believe this does anything, though, as it's shifting the unused BG layer which later gets disabled anyway...163HParallax[0].ScrollPos += 0xF0000164165#platform: HW_Rendering166// Load the stage map sprite if using the hardware render167168LoadSpriteSheet("Special/SSMap1.gif")169#endplatform170171// Setup all BGEffect objects present in the level172ArrayPos0 = 32173while ArrayPos0 < 1056174if Object[ArrayPos0].Type == TypeName[BGEffects]175176// Set this object to always active177Object[ArrayPos0].Priority = PRIORITY_ACTIVE178179// Make it be among the first things to be processed for drawing180Object[ArrayPos0].DrawOrder = 0181182// Starting angle, assuming that Sonic is starting facing left183Object[ArrayPos0].PrevAngle = 368184185end if186187ArrayPos0++188loop189190SetLayerDeformation(DEFORM_BG, 128, 16, 0, 0, 0)191192end sub193194195// ========================196// Editor Subs197// ========================198199sub RSDKDraw200DrawSprite(0)201end sub202203204sub RSDKLoad205LoadSpriteSheet("Special/SSMap1.gif")206SpriteFrame(-256, -256, 512, 512, 0, 0)207208SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")209end sub210211212