Path: blob/main/Scripts/Special/BGEffects_S3.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 in the level19Object.FansTimer++20if Object.FansTimer > 221Object.FansTimer = 022Object.FansSprite++23Object.FansSprite %= 324switch Object.FansSprite25case 026// Fans are 4x4 tiles, comprised of 8 unique tiles, so27// 8 individual tiles need to be updated to change the entire sprite28Copy16x16Tile(296, 520)29Copy16x16Tile(297, 521)30Copy16x16Tile(298, 522)31Copy16x16Tile(299, 523)32Copy16x16Tile(300, 524)33Copy16x16Tile(301, 525)34Copy16x16Tile(302, 526)35Copy16x16Tile(303, 527)36break3738case 139Copy16x16Tile(296, 528)40Copy16x16Tile(297, 529)41Copy16x16Tile(298, 530)42Copy16x16Tile(299, 531)43Copy16x16Tile(300, 532)44Copy16x16Tile(301, 533)45Copy16x16Tile(302, 534)46Copy16x16Tile(303, 535)47break4849case 250Copy16x16Tile(296, 536)51Copy16x16Tile(297, 537)52Copy16x16Tile(298, 538)53Copy16x16Tile(299, 539)54Copy16x16Tile(300, 540)55Copy16x16Tile(301, 541)56Copy16x16Tile(302, 542)57Copy16x16Tile(303, 543)58break5960end switch61end if6263// Animate the Crunchers in the level64Object.CrunchersTimer++65if Object.CrunchersTimer > 566Object.CrunchersTimer = 067Object.CrunchersSprite++68Object.CrunchersSprite &= 369switch Object.CrunchersSprite70case 071// Crunchers are 2x2 tiles, so 4 tiles need to be updated72// in order to completely change their sprite73Copy16x16Tile(189, 544)74Copy16x16Tile(190, 545)75Copy16x16Tile(191, 548)76Copy16x16Tile(192, 549)77break7879case 180Copy16x16Tile(189, 546)81Copy16x16Tile(190, 547)82Copy16x16Tile(191, 550)83Copy16x16Tile(192, 551)84break8586case 287Copy16x16Tile(189, 552)88Copy16x16Tile(190, 553)89Copy16x16Tile(191, 556)90Copy16x16Tile(192, 557)91break9293case 394Copy16x16Tile(189, 554)95Copy16x16Tile(190, 555)96Copy16x16Tile(191, 558)97Copy16x16Tile(192, 559)98break99100end switch101end if102103// Handle the palette animation104Object.AnimationTimer++105if Object.AnimationTimer > 7106Object.AnimationTimer = 0107Object.ActivePalette++108Object.ActivePalette &= 3109SetActivePalette(Object.ActivePalette, 0, Screen.YSize)110end if111112// Find the difference between the current scroll pos and last scroll pos113TempValue1 = Object.PrevAngle114TempValue2 = TileLayer[0].Angle115116if TempValue1 < TempValue2117TempValue3 = TempValue2118TempValue3 -= TempValue1119if TempValue3 > 256120// Account for looping121TempValue1 += 512122end if123else124TempValue3 = TempValue1125TempValue3 -= TempValue2126if TempValue3 > 256127// Account for looping128TempValue2 += 512129end if130end if131132TempValue0 = TempValue1133TempValue0 -= TempValue2134135// Store the current angle for calculations next frame136Object.PrevAngle = TileLayer[0].Angle137138// Move the other BG layers in accordance with the difference found139140TempValue1 = 0x40000141TempValue2 = 0x30000142TempValue3 = 0x10000143TempValue4 = 0x20000144145TempValue1 *= TempValue0146TempValue2 *= TempValue0147TempValue3 *= TempValue0148TempValue4 *= TempValue0149150HParallax[1].ScrollPos += TempValue1151HParallax[2].ScrollPos += TempValue2152HParallax[3].ScrollPos += TempValue3153HParallax[4].ScrollPos += TempValue4154155end sub156157158sub ObjectStartup159160// Set stage bounds161Stage.XBoundary1 = 0x3400000 // 832 pixels to the left162Stage.XBoundary2 = 0xCC00000 // 3264 pixels to the right163Stage.YBoundary1 = 0x3400000 // 832 pixels upwards164Stage.YBoundary2 = 0xCC00000 // 3264 pixels downwards165166#platform: HW_Rendering167// Load the map sheet if needed for HW rendering168169LoadSpriteSheet("Special/SSMap3.gif")170#endplatform171172// Setup all BGEffects in the level173ArrayPos0 = 32174while ArrayPos0 < 1056175if Object[ArrayPos0].Type == TypeName[BGEffects]176177// Set the object to always active178Object[ArrayPos0].Priority = PRIORITY_ACTIVE179180// Make the object among the first to have its draw code be run181Object[ArrayPos0].DrawOrder = 0182183// Set the starting angle184// (Assuming Sonic starts facing left)185Object[ArrayPos0].PrevAngle = 368186187end if188189ArrayPos0++190loop191192// Setup the alternate palettes193TempValue0 = 1194while TempValue0 < 4195// Shift the palette a bit between loops196RotatePalette(202, 205, true)197CopyPalette(0, TempValue0)198TempValue0++199loop200201// And shift it one last time, to restore the palette to what it was originally202RotatePalette(202, 205, true)203204end sub205206207// ========================208// Editor Subs209// ========================210211sub RSDKDraw212DrawSprite(0)213end sub214215216sub RSDKLoad217LoadSpriteSheet("Special/SSMap3.gif")218SpriteFrame(-256, -256, 512, 512, 0, 0)219220SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")221end sub222223224