Path: blob/main/Scripts/Special/BGEffects_S4.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.CrunchersSprite11#alias Object.Value7 : Object.ActivePalette1213// Priority14#alias 1 : PRIORITY_ACTIVE151617sub ObjectDraw18// Animate the Fans throughout the level19Object.FansTimer++20if Object.FansTimer > 221Object.FansTimer = 022Object.FansSprite++23Object.FansSprite %= 324switch Object.FansSprite25case 026// Fans are 4x4 tiles, with 8 unique tiles in them, so27// 8 tiles need to be updated to change the entire sprite28Copy16x16Tile(328, 484)29Copy16x16Tile(329, 485)30Copy16x16Tile(330, 486)31Copy16x16Tile(331, 487)32Copy16x16Tile(332, 488)33Copy16x16Tile(333, 489)34Copy16x16Tile(334, 490)35Copy16x16Tile(335, 491)36break3738case 139Copy16x16Tile(328, 492)40Copy16x16Tile(329, 493)41Copy16x16Tile(330, 494)42Copy16x16Tile(331, 495)43Copy16x16Tile(332, 496)44Copy16x16Tile(333, 497)45Copy16x16Tile(334, 498)46Copy16x16Tile(335, 499)47break4849case 250Copy16x16Tile(328, 500)51Copy16x16Tile(329, 501)52Copy16x16Tile(330, 502)53Copy16x16Tile(331, 503)54Copy16x16Tile(332, 504)55Copy16x16Tile(333, 505)56Copy16x16Tile(334, 506)57Copy16x16Tile(335, 507)58break5960end switch61end if6263// Animate the palettes64Object.AnimationTimer++65if Object.AnimationTimer > 766Object.AnimationTimer = 067Object.ActivePalette++68Object.ActivePalette &= 369SetActivePalette(Object.ActivePalette, 0, Screen.YSize)70end if7172// Animate the Crunchers throughout the level73Object.CrunchersTimer++74if Object.CrunchersTimer > 575Object.CrunchersTimer = 076Object.CrunchersSprite++77Object.CrunchersSprite &= 378switch Object.CrunchersSprite79case 080// Crunchers are 2x2 tiles, so 4 tiles need to be updated81// in order to completely change their sprite82Copy16x16Tile(134, 508)83Copy16x16Tile(135, 509)84Copy16x16Tile(136, 512)85Copy16x16Tile(137, 513)86break8788case 189Copy16x16Tile(134, 510)90Copy16x16Tile(135, 511)91Copy16x16Tile(136, 514)92Copy16x16Tile(137, 515)93break9495case 296Copy16x16Tile(134, 516)97Copy16x16Tile(135, 517)98Copy16x16Tile(136, 520)99Copy16x16Tile(137, 521)100break101102case 3103Copy16x16Tile(134, 518)104Copy16x16Tile(135, 519)105Copy16x16Tile(136, 522)106Copy16x16Tile(137, 523)107break108109end switch110end if111112// Find the difference between the current scoll position and the last scroll position113TempValue1 = Object.PrevAngle114TempValue2 = TileLayer[0].Angle115116if TempValue1 < TempValue2117TempValue3 = TempValue2118TempValue3 -= TempValue1119if TempValue3 > 256120TempValue1 += 512121end if122else123TempValue3 = TempValue1124TempValue3 -= TempValue2125if TempValue3 > 256126TempValue2 += 512127end if128end if129130TempValue0 = TempValue1131TempValue0 -= TempValue2132133// Store the current angle for use next frame134Object.PrevAngle = TileLayer[0].Angle135136// Scroll the BG in accordance with the difference from before137138TempValue1 = 0x08000139TempValue2 = 0x10000140TempValue3 = 0x20000141142TempValue1 *= TempValue0143TempValue2 *= TempValue0144TempValue3 *= TempValue0145146HParallax[0].ScrollPos += TempValue1147HParallax[1].ScrollPos += TempValue2148HParallax[2].ScrollPos += TempValue3149150end sub151152153sub ObjectStartup154155// Set stage bounds156Stage.XBoundary1 = 0x3000000 // left bounds at 768 pixels157Stage.XBoundary2 = 0xD000000 // right bounds at 3328 pixels158Stage.YBoundary1 = 0x3800000 // upper bounds at 896 pixels159Stage.YBoundary2 = 0xC800000 // lower bounds at 3200 pixels160161#platform: HW_Rendering162// Load the Special Stage map if needed for Hardware Rendering163164LoadSpriteSheet("Special/SSMap4.gif")165#endplatform166167// Setup all BGEffects in the level168ArrayPos0 = 32169while ArrayPos0 < 1056170if Object[ArrayPos0].Type == TypeName[BGEffects]171172// Make the object always be run173Object[ArrayPos0].Priority = PRIORITY_ACTIVE174175// The object should have its draw code run before others176Object[ArrayPos0].DrawOrder = 0177178// Assuming Sonic's starting facing left, set the starting angle179Object[ArrayPos0].PrevAngle = 368180181end if182183ArrayPos0++184loop185186// Setup the animated palettes187TempValue0 = 1188while TempValue0 < 4189RotatePalette(224, 227, true)190RotatePalette(240, 243, true)191CopyPalette(0, TempValue0)192TempValue0++193loop194195// Rotate it one more time, to restore the palette to what it was originally196RotatePalette(224, 227, true)197RotatePalette(240, 243, true)198199end sub200201202// ========================203// Editor Subs204// ========================205206sub RSDKDraw207DrawSprite(0)208end sub209210211sub RSDKLoad212LoadSpriteSheet("Special/SSMap4.gif")213SpriteFrame(-256, -256, 512, 512, 0, 0)214215SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")216end sub217218219