//-----------------Sonic CD Title Card Script-----------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
// Aliases
#alias Object.Value0 : Object.BarPos
#alias Object.Value1 : Object.TextPos
#alias Object.Value2 : Object.TextSize
#alias Object.Value3 : Object.Timer
#alias Object.Value4 : Object.FadeR
#alias Object.Value5 : Object.FadeG
#alias Object.Value6 : Object.FadeB
#alias Object.Value7 : Object.CharPos
// Player Aliases
#alias Object[0].Value4 : Player.InvincibleTimer
// HUD Alias
#alias Object[24].PropertyValue : HUD.CurrentTimePeriod
// States
#alias 0 : TITLECARD_FADEIN
#alias 1 : TITLECARD_SLIDEIN
#alias 2 : TITLECARD_DISPLAY
#alias 3 : TITLECARD_SLIDEOUT
// Soundtrack
#alias 0 : OST_JP
// Players
#alias 0 : PLAYER_SONIC
// Time Period Aliases
#alias 0 : TIME_PRESENT
#alias 1 : TIME_PAST
#alias 2 : TIME_GOOD_FUTURE
#alias 3 : TIME_BAD_FUTURE
// ControlMode Aliases
#alias -1 : CONTROLMODE_NONE
#alias 0 : CONTROLMODE_NORMAL
// Priority
#alias 1 : PRIORITY_ACTIVE
sub ObjectPlayerInteraction
Player.Timer = 0
end sub
sub ObjectDraw
switch Object.State
case TITLECARD_FADEIN
Player.ControlMode = CONTROLMODE_NONE
Player.Up = false
Player.Down = false
Player.Left = false
Player.Right = false
Player.JumpPress = false
Player.JumpHold = false
// Check if the player comes from warping, if not, blank speed
if Warp.XPos < 1
Player.Speed = 0
end if
if Object.Timer > 0
if Object.Timer == 256
PlayMusic(0)
if Warp.XPos > 0
// Restore values post-warp
Player.XPos = Warp.XPos
Player.YPos = Warp.YPos
Player.XVelocity = Warp.XVelocity
Player.YVelocity = Warp.YVelocity
Player.Speed = Warp.XVelocity
Player.State = Warp.State
Stage.MilliSeconds = Rec_Milliseconds
Stage.Seconds = Rec_Seconds
Stage.Minutes = Rec_Minutes
Player.InvincibleTimer = 8000
end if
Warp.Timer = 0
Warp.Frame = 0
end if
SetScreenFade(Object.FadeR, Object.FadeG, Object.FadeB,
Object.Timer)
Object.Timer -= 8
else
Fade_Colour = 0
// the title card animation doesn't play out if you come from a
warp or restarted from a checkpoint
CheckEqual(Warp.XPos, 0)
TempValue0 = CheckResult
CheckLower(LampPost.Check, 32)
TempValue0 &= CheckResult
if TempValue0 == true
Object.State = TITLECARD_SLIDEIN
Object.Timer = 0
else
Player.ControlMode = CONTROLMODE_NORMAL
Stage.TimeEnabled = true
ResetObjectEntity(20, TypeName[Blank Object], 0, 0, 0)
Warp.XPos = 0
end if
end if
break
case TITLECARD_SLIDEIN
TempValue0 = 144
TempValue0 += Object.CharPos
if Object.TextPos > TempValue0
// Slide the text to the left
Object.TextPos -= 8
else
if Object.BarPos == 0
Object.State = TITLECARD_DISPLAY
end if
end if
if Object.BarPos < 0
// Move the Bar down
Object.BarPos += 8
end if
break
case TITLECARD_DISPLAY
// Hold for a moment to let the Player see what a nice Title Card this
is
if Object.Timer == 90
// Time's up, start sliding out!
Object.State = TITLECARD_SLIDEOUT
else
Object.Timer++
end if
break
case TITLECARD_SLIDEOUT
if Object.TextPos < 408
// Move the text to the right, and...
Object.TextPos += 16
// ...move the bar upwards as well
Object.BarPos -= 16
else
// Free Sonic's control, and enable the stage timer.
Player.ControlMode = CONTROLMODE_NORMAL
Stage.TimeEnabled = true
// The Title Card's job is done, despawn it
ResetObjectEntity(20, TypeName[Blank Object], 0, 0, 0)
Warp.XPos = 0
end if
break
end switch
// Before drawing, make sure this object hasn't been blanked already
// (Under certain circumstances, this can otherwise cause major graphical
issues!!)
if Object.Type > TypeName[Blank Object]
TempValue0 = 136
TempValue0 += Object.CharPos
// Draw the Red Bar
DrawSpriteScreenXY(0, TempValue0, Object.BarPos)
// And then, draw the act number
DrawSpriteScreenXY(Stage.ActNo, Object.TextPos, 80)
// And then draw the Zone text, the Sonic CD bar, and the weird three
lines
DrawSpriteScreenXY(4, Object.TextPos, 80)
DrawSpriteScreenXY(5, Object.TextPos, 80)
DrawSpriteScreenXY(6, Object.TextPos, 80)
DrawSpriteScreenXY(7, Object.TextPos, 80)
#platform: Use_Decomp // Creates a black rectangle that fills the empty space on
wider resolutions
Tempvalue0 = Object.TextPos
TempValue0 += 220
DrawRect(TempValue0, 163, Screen.XSize, 9, 0, 0, 0, 255)
#endplatform
// And then Draw the Round Name
// (Letters start at Sprite Frame 8)
TempValue0 = 8
while TempValue0 < Object.TextSize
DrawSpriteScreenXY(TempValue0, Object.TextPos, 80)
TempValue0++
loop
end if
end sub
sub ObjectStartup
LoadSpriteSheet("Global/Display.gif")
switch HUD.CurrentTimePeriod
case TIME_PRESENT
switch SaveRam[513]
case 0 // Original
SetMusicTrack("JP/R2A.ogg", 0, true)
break
case 1 //US
SetMusicTrack("US/R2A.ogg", 0, true)
break
case 2 // EU
SetMusicTrack("EU/R2A.ogg", 0, true)
break
case 3 // Alt. Mix 0
SetMusicTrack("ALT0/R2A.ogg", 0, true)
break
end switch
break
case TIME_PAST
switch SaveRam[514]
case 0 // JP
SetMusicTrack("R2B.ogg", 0, true)
break
case 1 // EU
SetMusicTrack("EU/R2B.ogg", 0, true)
break
case 2 // Alt.Mix 0
SetMusicTrack("ALT0/R2B.ogg", 0, true)
break
case 3 // Alt.Mix 1
SetMusicTrack("ALT1/R2B.ogg", 0, true)
break
end switch
break
case TIME_GOOD_FUTURE
switch SaveRam[515]
case 0 // JP
SetMusicTrack("JP/R2C.ogg", 0, true)
break
case 1 // Sonic Stream
SetMusicTrack("JP/R2C_SonicStream.ogg", 0, true)
break
case 2 //US
SetMusicTrack("US/R2C.ogg", 0, true)
break
case 3 // EU
SetMusicTrack("EU/R2C.ogg", 0, true)
break
case 4 // Alt. Mix0
SetMusicTrack("ALT0/R2C.ogg", 0, true)
break
end switch
break
case TIME_BAD_FUTURE
switch SaveRam[516]
case 0 // JP
SetMusicTrack("JP/R2D.ogg", 0, true)
break
case 1 //US
SetMusicTrack("US/R2D.ogg", 0, true)
break
case 2 // EU
SetMusicTrack("EU/R2D.ogg", 0, true)
break
case 3 // Alt. Mix0
SetMusicTrack("ALT0/R2D.ogg", 0, true)
break
case 4 // Alt.Mix 1
SetMusicTrack("ALT1/R2D.ogg", 0, true)
break
end switch
break
end switch
Flower_TypeNo = TypeName[Flower]
Object[20].Type = TypeName[Title Card]
// Different Fade-In times depending on if this is a new level load or if the
Player is warping in
if Warp.XPos > 0
// If the Player is warping in, have a shorter fade-in time
Object[20].Timer = 256
else
Object[20].Timer = 384
end if
// In the... Desert Dazzle boss Zone, set a Roof to be active...?
if Stage.ActNo == 3
Player.RoofBarrier = true
end if
// Make the Title Card always active, and have it draw above everything
Object[20].Priority = PRIORITY_ACTIVE
Object[20].DrawOrder = 6
// Set initial Bar & Text Positions
Object[20].BarPos = -216
Object[20].TextPos = 336
Object[20].CharPos = Screen.CenterX
Object[20].CharPos -= 160
if Object[20].CharPos > 3
Object[20].CharPos -= 4
end if
Object[20].CharPos &= 248
Object[20].TextPos += Object[20].CharPos
Object[20].TextPos += Object[20].CharPos
switch SaveRam[512]
case 0
Object[20].TextSize = 13 // "Dubious Depths" is 13 letters long.
break
case 1
Object[20].TextSize = 12 // "Ridicule Root" is 12 letters long.
break
case 2
Object[20].TextSize = 10 // "Relic Ruins" is 10 letters long. No relic
ruins? :(
break
end switch
// Bump the value by 8 to correspond with the order of the Sprite Frames
Object[20].TextSize += 8
// Preserve the colour used from the last fade. Fade_Colour is stored as
RRGGBB, in hex
Object[20].FadeR = Fade_Colour
Object[20].FadeR >>= 16
Object[20].FadeG = Fade_Colour
Object[20].FadeG &= 0x00FF00
Object[20].FadeG >>= 8
Object[20].FadeB = Fade_Colour
Object[20].FadeB &= 0x0000FF
// 0 - Red Bar Frame
SpriteFrame(0, 0, 32, 200, 223, 1)
// 1-3 - Act Bubbles
SpriteFrame(96, 96, 48, 48, 41, 1)
SpriteFrame(96, 96, 48, 48, 90, 1)
SpriteFrame(96, 96, 48, 48, 139, 1)
// 4 - "Zone" text
SpriteFrame(64, 97, 48, 16, 41, 67)
// 5 - Main part of the "SONIC THE HEGDEHOG CD" bar
// Workaround for steam datafile to show this sprite correctly
#platform: Use_Origins
SpriteFrame(72, 81, 160, 16, 49, 50) // #5 - Sonic The Hedgehog CD
#endplatform
#platform: Use_Standalone
#platform: Standard
SpriteFrame(64, 81, 160, 16, 41, 50)// #5 - Sonic The Hedgehog CD
#endplatform
#endplatform
#platform: Use_Standalone
#platform: Mobile
SpriteFrame(72, 81, 160, 16, 49, 50)// #5 - Sonic The Hedgehog CD
#endplatform
#endplatform
// 6 - Continuation of the Sonic CD bar
SpriteFrame(16, 81, 160, 16, 41, 50)
// 7 - Set of three lines
SpriteFrame(100, 32, 24, 48, 188, 1)
// 8-19 - Individual letters spelling out Dubious Depths
switch SaveRam[512]
case 0
SpriteFrame(0, 0, 17, 55, 180, 133) // #8 - D
SpriteFrame(18, 32, 11, 23, 92, 108) // #9 - U
SpriteFrame(30, 32, 11, 23, 55, 84) // #10 - B
SpriteFrame(42, 32, 5, 23, 131, 84) // #11 - I
SpriteFrame(48, 32, 11, 23, 199, 84) // #12 - O
SpriteFrame(60, 32, 11, 23, 92, 108) // #13 - U
SpriteFrame(72, 32, 10, 23, 70, 108) // #14 - S
SpriteFrame(0, 56, 17, 55, 180, 133) // #15 - D
SpriteFrame(18, 56, 9, 23, 88, 84) // #16 - E
SpriteFrame(28, 56, 10, 23, 211, 84) // #17 - P
SpriteFrame(39, 56, 10, 23, 81, 108) // #18 - T
SpriteFrame(49, 56, 11, 23, 119, 84) // #19 - H
SpriteFrame(61, 56, 10, 23, 70, 108) // #20 - S
break
case 1
SpriteFrame(0, -1, 22, 56, 198, 132) // #8 - R
SpriteFrame(24, 32, 5, 23, 131, 84) // #9 - I
SpriteFrame(31, 32, 11, 23, 76, 84) // #10 - D
SpriteFrame(43, 32, 5, 23, 131, 84) // #11 - I
SpriteFrame(49, 32, 9, 23, 176, 108) // #12 - С
SpriteFrame(59, 32, 11, 23, 92, 108) // #13 - U
SpriteFrame(71, 32, 9, 23, 159, 84) // #14 - L
SpriteFrame(81, 32, 9, 23, 88, 84) // #15 - E
SpriteFrame(0, 55, 22, 56, 198, 132) // #16 - R
SpriteFrame(24, 56, 11, 23, 199, 84) // #17 - O
SpriteFrame(36, 56, 11, 23, 199, 84) // #18 - O
SpriteFrame(48, 56, 10, 23, 81, 108) // #19 - T
break
case 2
SpriteFrame(0, -1, 22, 56, 198, 132) // #8 - R
SpriteFrame(24, 32, 9, 23, 88, 84) // #9 - E
SpriteFrame(34, 32, 9, 23, 159, 84) // #10 - L
SpriteFrame(44, 32, 5, 23, 131, 84) // #11 - I
SpriteFrame(50, 32, 9, 23, 176, 108) // #12 - С
SpriteFrame(0, 55, 22, 56, 198, 132) // #13 - R
SpriteFrame(24, 56, 11, 23, 92, 108) // #14 - U
SpriteFrame(36, 56, 5, 23, 131, 84) // #15 - I
SpriteFrame(42, 56, 11, 23, 187, 84) // #16 - N
SpriteFrame(54, 56, 10, 23, 70, 108) // #17 - S
break
end switch
#platform: Use_Origins
// They copy pasted this through all the title cards. This script isn't even
used and yet it's Mission-ready LOL
if game.playMode == BOOT_PLAYMODE_MISSION
TempValue0 = true
else
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
TempValue0 = true
else
TempValue0 = false
end if
end if
if TempValue0 != false
PlayMusic(0)
game.missionCondition = 0
game.missionEnd = false
Player.ControlMode = CONTROLMODE_NORMAL
Stage.TimeEnabled = true
ResetObjectEntity(20, TypeName[Blank Object], 0, 0, 0)
Warp.XPos = 0
end if
#endplatform
end sub
// ========================
// Editor Subs
// ========================
sub RSDKDraw
Object.TextSize = 12
Object.TextSize += 8
TempValue0 = 136
TempValue0 += Object.CharPos
TempValue0 <<= 16
TempValue1 = 0x500000
TempValue1 += Object.YPos
DrawSpriteXY(0, Object.XPos, Object.YPos)
DrawSpriteXY(Stage.ActNo, Object.XPos, TempValue1)
DrawSpriteXY(4, Object.XPos, TempValue1)
DrawSpriteXY(5, Object.XPos, TempValue1)
DrawSpriteXY(6, Object.XPos, TempValue1)
DrawSpriteXY(7, Object.XPos, TempValue1)
TempValue0 = 8
while TempValue0 < Object.TextSize
DrawSpriteXY(TempValue0, Object.XPos, TempValue1)
TempValue0++
loop
end sub
sub RSDKLoad
LoadSpriteSheet("Global/Display.gif")
// 0 - Red Bar Frame
SpriteFrame(0, 0, 32, 200, 223, 1)
// 1-3 - Act Bubbles
SpriteFrame(96, 96, 48, 48, 41, 1)
SpriteFrame(96, 96, 48, 48, 90, 1)
SpriteFrame(96, 96, 48, 48, 139, 1)
// 4 - "Zone" text
SpriteFrame(64, 97, 48, 16, 41, 67)
// 5 - Main part of the "SONIC THE HEGDEHOG CD" bar
SpriteFrame(64, 81, 160, 16, 41, 50)
// 6 - Continuation of the Sonic CD bar
SpriteFrame(16, 81, 160, 16, 41, 50)
// 7 - Set of three lines
SpriteFrame(100, 32, 24, 48, 188, 1)
// 8-19 - Individual letters spelling out Dubious Depths
SpriteFrame(0, 0, 17, 55, 180, 133) // #8 - D
SpriteFrame(18, 32, 11, 23, 92, 108) // #9 - U
SpriteFrame(28, 32, 11, 23, 55, 84) // #10 - B
SpriteFrame(39, 32, 9, 23, 88, 84) // #11 - E
SpriteFrame(49, 32, 12, 23, 57, 108) // #12 - R
SpriteFrame(62, 32, 10, 23, 81, 108) // #13 - T
SpriteFrame(0, 56, 17, 55, 180, 133) // #14 - D
SpriteFrame(18, 56, 11, 23, 43, 84) // #15 - A
SpriteFrame(30, 56, 10, 23, 158, 108) // #16 - Z
SpriteFrame(41, 56, 10, 23, 158, 108) // #17 - Z
SpriteFrame(52, 56, 9, 23, 159, 84) // #18 - L
SpriteFrame(62, 56, 9, 23, 88, 84) // #19 - E
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end sub