Path: blob/main/Scripts/Special/BGEffects_S8.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_ACTIVE141516sub ObjectDraw17// Animate the fans that are in the level18Object.FansTimer++19if Object.FansTimer > 220Object.FansTimer = 021Object.FansSprite++22Object.FansSprite %= 323switch Object.FansSprite24case 025// Fans are 4x4 tiles, comprised of 8 unique tiles, so26// 8 tiles need to be updated to change the entire sprite27Copy16x16Tile(237, 308)28Copy16x16Tile(238, 309)29Copy16x16Tile(239, 310)30Copy16x16Tile(240, 311)31Copy16x16Tile(241, 312)32Copy16x16Tile(242, 313)33Copy16x16Tile(243, 314)34Copy16x16Tile(244, 315)35break3637case 138Copy16x16Tile(237, 316)39Copy16x16Tile(238, 317)40Copy16x16Tile(239, 318)41Copy16x16Tile(240, 319)42Copy16x16Tile(241, 320)43Copy16x16Tile(242, 321)44Copy16x16Tile(243, 322)45Copy16x16Tile(244, 323)46break4748case 249Copy16x16Tile(237, 324)50Copy16x16Tile(238, 325)51Copy16x16Tile(239, 326)52Copy16x16Tile(240, 327)53Copy16x16Tile(241, 328)54Copy16x16Tile(242, 329)55Copy16x16Tile(243, 330)56Copy16x16Tile(244, 331)57break5859end switch60end if6162// Animate the hungry crunchers throughout the level, too63Object.CrunchersTimer++64if Object.CrunchersTimer > 565Object.CrunchersTimer = 066Object.CrunchersSprite++67Object.CrunchersSprite &= 368switch Object.CrunchersSprite69case 070// Crunchers are 2x2 tiles, so 4 tiles need to be updated71// in order to completely change their sprite72Copy16x16Tile(135, 332)73Copy16x16Tile(136, 333)74Copy16x16Tile(137, 336)75Copy16x16Tile(138, 337)76break7778case 179Copy16x16Tile(135, 334)80Copy16x16Tile(136, 335)81Copy16x16Tile(137, 338)82Copy16x16Tile(138, 339)83break8485case 286Copy16x16Tile(135, 340)87Copy16x16Tile(136, 341)88Copy16x16Tile(137, 344)89Copy16x16Tile(138, 345)90break9192case 393Copy16x16Tile(135, 342)94Copy16x16Tile(136, 343)95Copy16x16Tile(137, 346)96Copy16x16Tile(138, 347)97break9899end switch100end if101102// Find the difference between the current scroll position and the last scroll position... but nothing's really done with the result103// This script was likely just copied over from the other BGEffects scripts, and this was never removed104TempValue1 = Object.PrevAngle105TempValue2 = TileLayer[0].Angle106if TempValue1 < TempValue2107TempValue3 = TempValue2108TempValue3 -= TempValue1109if TempValue3 > 256110TempValue1 += 512111end if112else113TempValue3 = TempValue1114TempValue3 -= TempValue2115if TempValue3 > 256116TempValue2 += 512117end if118end if119120// Object.PrevAngle would normally be updated here, it looks like at least *some* effort was taken to remove the useless code121122end sub123124125sub ObjectStartup126127// Setup stage bounds128// Interestingly, this stage has different widths and heights, not making it a square like the others129Stage.XBoundary1 = 0x2800000 // left bounds at 640 pixels130Stage.XBoundary2 = 0xD800000 // right bounds at 3456 pixels131Stage.YBoundary1 = 0x3000000 // upper bounds at 768 pixels132Stage.YBoundary2 = 0xD000000 // lower bounds at 3328 pixels133134#platform: HW_Rendering135// Load the stage map as a sprite if needed136137LoadSpriteSheet("Special/SSMap8.gif")138#endplatform139140// Center the stage's background so that Robotnik's amazing mug can be in the middle of the screen141TempValue0 = Screen.XSize142TempValue0 -= 320143144// Shouldn't this be <<= 16? If it's going from screen-space to world-space...145TempValue0 <<= 15146147// Base position of 96 pixels148HParallax[0].ScrollPos = 0x600000149150// And then shift it as needed to match up centre screen151HParallax[0].ScrollPos -= TempValue0152153// Cycle through all BGEffects objects and set them up154ArrayPos0 = 32155while ArrayPos0 < 1056156if Object[ArrayPos0].Type == TypeName[BGEffects]157158// Make the object always be run, since fans and tiles should be animated always159Object[ArrayPos0].Priority = PRIORITY_ACTIVE160161// Give it the lowest draw order as well, in order to make it run before other objects' draw events162Object[ArrayPos0].DrawOrder = 0163164// Set the initial starting angle, although it's not really used...165Object[ArrayPos0].PrevAngle = 368166167end if168169ArrayPos0++170loop171172end sub173174175// ========================176// Editor Subs177// ========================178179sub RSDKDraw180DrawSprite(0)181end sub182183184sub RSDKLoad185LoadSpriteSheet("Special/SSMap8.gif")186SpriteFrame(-256, -256, 512, 512, 0, 0)187188SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")189end sub190191192