Path: blob/main/Scripts/Menu/BGAnimation.txt
1319 views
//------------Sonic CD Background Animation Script------------//1//--------Scripted by Christian Whitehead 'The Taxman'--------//2//-------Unpacked By Rubberduckycooly's Script Unpacker-------//34// Aliases5#alias Object.Value0 : Object.AngleFull6#alias Object.Value1 : Object.AngleRounded7#alias Object.Value2 : Object.BackBGSonicXPos8#alias Object.Value3 : Object.FrontBGSonicXPos9#alias Object.Value4 : Object.ZPos1011// Ink Effects12#alias 1 : INK_BLEND1314// Priority15#alias 1 : PRIORITY_ACTIVE1617// Face Buffer Flags18#alias 2 : FACE_FLAG_COLOURED_3D192021sub ObjectDraw22// The "Full" value ranges from 0 to 1023, using 10 bits23Object.AngleFull++24Object.AngleFull &= 10232526// The "Rounded" value, however, ranges from 0 to 511, using 9 bits, as RSDK's anlges are 512-based rather than 1024-based27Object.AngleRounded = Object.AngleFull28Object.AngleRounded >>= 12930// From this rounded value, now we actually do stuff3132// First, manage the depth of the BG33Sin(Object.ZPos, Object.AngleRounded)34Object.ZPos += 0x500035MatrixTranslateXYZ(MAT_WORLD, 0, 0, Object.ZPos)3637// Now, handle the rotating of the BG38TempValue0 = Object.AngleRounded39MatrixRotateXYZ(MAT_VIEW, 0, 0, TempValue0)4041// Draw the rectangles here, notably before we draw the Sonic sprites42Draw3DScene()4344// Now after we've drawn the 3d stuff, draw Sonic himself4546Object.BackBGSonicXPos = Screen.CenterX47Object.BackBGSonicXPos -= 448DrawSpriteScreenFX(0, FX_INK, Object.BackBGSonicXPos, Screen.CenterY)4950Object.FrontBGSonicXPos = Screen.CenterX51Object.FrontBGSonicXPos += 452DrawSpriteScreenFX(0, FX_INK, Object.FrontBGSonicXPos, Screen.CenterY)53end sub545556sub ObjectStartup57// So this is removing the stage's FG layer but,58// the stage's configuration in the act file already has it set up like that anyway...59Stage[0].ActiveLayer = 96061LoadSpriteSheet("Menu/MenuGfx1_EN.gif")6263SpriteFrame(-160, -104, 320, 224, 0, 0) // #0 - Sonic Background6465ArrayPos0 = 3266while ArrayPos0 < 105667if Object[ArrayPos0].Type == TypeName[BG Animation]68Object[ArrayPos0].Priority = PRIORITY_ACTIVE69Object[ArrayPos0].DrawOrder = 270Object[ArrayPos0].InkEffect = INK_BLEND71end if7273ArrayPos0++74loop7576// The three rotating rectanlges in the background are actually 3d elements, let's setup them up here7778// First, reset all the matrix values79MatrixTranslateXYZ(MAT_WORLD, 0, 0, 0)80MatrixRotateXYZ(MAT_VIEW, 0, 0, 0)8182// Three rectanlges, four edges per rectanlge, yup that makes 12 corners in total!833DScene.NoVertices = 12843DScene.NoFaces = 38586// Set the vertex coordinates for the first rectangle8788// 0 - Top left89VertexBuffer[0].x = -0xC80090VertexBuffer[0].y = 0xC80091VertexBuffer[0].z = 2569293// 1 - Top right94VertexBuffer[1].x = 0xC0095VertexBuffer[1].y = 0xC80096VertexBuffer[1].z = 2569798// 2 - Bottom left99VertexBuffer[2].x = -0xC800100VertexBuffer[2].y = 0x3000101VertexBuffer[2].z = 256102103// 3 - Bottom right104VertexBuffer[3].x = 0xC00105VertexBuffer[3].y = 0x3000106VertexBuffer[3].z = 256107108// Set the faces of the first rectangle109FaceBuffer[0].a = 0110FaceBuffer[0].b = 1111FaceBuffer[0].c = 2112FaceBuffer[0].d = 3113114FaceBuffer[0].Flag = FACE_FLAG_COLOURED_3D115116// Setting the color of the first rectangle, giving it a green of sorts (0x80E040)117FaceBuffer[0].Color = 128118FaceBuffer[0].Color <<= 16119TempValue0 = 224120TempValue0 <<= 8121FaceBuffer[0].Color += TempValue0122FaceBuffer[0].Color += 64123FaceBuffer[0].Color += 0x7F000000 // Half transparency124125// Now, set up the second rectanlge126127// 4 - Top left128VertexBuffer[4].x = -0xC800129VertexBuffer[4].y = 0x3000130VertexBuffer[4].z = 256131132// 5 - Top right133VertexBuffer[5].x = 0xC00134VertexBuffer[5].y = 0x3000135VertexBuffer[5].z = 256136137// 6 - Bottom left138VertexBuffer[6].x = -0xC800139VertexBuffer[6].y = -0xC800140VertexBuffer[6].z = 256141142// 7 - Bottom right143VertexBuffer[7].x = 0xC00144VertexBuffer[7].y = -0xC800145VertexBuffer[7].z = 256146147// Set the faces of the second rectangle148FaceBuffer[1].a = 4149FaceBuffer[1].b = 5150FaceBuffer[1].c = 6151FaceBuffer[1].d = 7152153FaceBuffer[1].Flag = FACE_FLAG_COLOURED_3D154155// Setting the color of the second rectangle, this one gets a cool orange (0xE0A060)156FaceBuffer[1].Color = 224157FaceBuffer[1].Color <<= 16158TempValue0 = 160159TempValue0 <<= 8160FaceBuffer[1].Color += TempValue0161FaceBuffer[1].Color += 96162FaceBuffer[1].Color += 0x7F000000 // Once again, half transparency163164// And last but not least, set up the third rectangle165166// 8 - Top left167VertexBuffer[8].x = 0xB00168VertexBuffer[8].y = 0xC800169VertexBuffer[8].z = 256170171// 9 - Top right172VertexBuffer[9].x = 0xC800173VertexBuffer[9].y = 0xC800174VertexBuffer[9].z = 256175176// 10 - Bottom left177VertexBuffer[10].x = 0xB00178VertexBuffer[10].y = -0xC800179VertexBuffer[10].z = 256180181// 11 - Bottom right182VertexBuffer[11].x = 0xC800183VertexBuffer[11].y = -0xC800184VertexBuffer[11].z = 256185186// Set the faces of the third rectangle187FaceBuffer[2].a = 8188FaceBuffer[2].b = 9189FaceBuffer[2].c = 10190FaceBuffer[2].d = 11191192FaceBuffer[2].Flag = FACE_FLAG_COLOURED_3D193194// Setting the color of the a rectangle one last time, the third one gets a nice blue (0x8080E0)195FaceBuffer[2].Color = 128196FaceBuffer[2].Color <<= 16197TempValue0 = 128198TempValue0 <<= 8199FaceBuffer[2].Color += TempValue0200FaceBuffer[2].Color += 224201FaceBuffer[2].Color += 0x7F000000202end sub203204205// ========================206// Editor Subs207// ========================208209sub RSDKDraw210DrawSprite(0)211end sub212213214sub RSDKLoad215LoadSpriteSheet("Menu/MenuGfx1_EN.gif")216SpriteFrame(-160, -104, 320, 224, 0, 0) // Sonic Background217218SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")219end sub220221222