Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Special/HUD.txt
1319 views
1
//--------------------Sonic CD HUD Script---------------------//
2
//--------Scripted by Christian Whitehead 'The Taxman'--------//
3
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//
4
5
// Aliases
6
// Not all of these are used here in the HUD script, some are just used as a way for other objects to globally transmit values
7
#alias Object.Value0 : Object.UFOsCount // Initially set via a loop in the UFO script
8
#alias Object.Value1 : Object.TimeSeconds // Displayed time
9
#alias Object.Value2 : Object.TimeFrames // Hidden and used for time processing, this value is managed by Special Setup instead of here
10
#alias Object.Value3 : Object.Rings
11
#alias Object.Value4 : Object.LastUFOType // Used by UFOs for ring streak bonus
12
#alias Object.Value5 : Object.SpeedShoes // Used to transmit between player and UFO
13
#alias Object.Value6 : Object.BonusUFONo // "No" akin to Entity No, not as in "is there no UFO?"
14
#alias Object.Value7 : Object.WaterTimer // Used in making time deplete faster when wet
15
16
// Game Mode Aliases
17
#alias 2 : MODE_TIMEATTACK
18
19
// Priority
20
#alias 1 : PRIORITY_ACTIVE
21
22
23
sub ObjectDraw
24
// Find the initial X Position to draw the HUD elements
25
TempValue1 = Screen.CenterX
26
TempValue1 -= 128
27
28
// Draw the "UFO" graphic
29
DrawSpriteScreenXY(10, TempValue1, 10)
30
31
// Draw the first digit of the UFOs counter
32
TempValue0 = Object.UFOsCount
33
TempValue0 /= 10
34
TempValue1 += 24
35
DrawSpriteScreenXY(TempValue0, TempValue1, 11)
36
37
// Draw the second digit of the UFOs counter
38
TempValue0 = Object.UFOsCount
39
TempValue0 %= 10
40
TempValue1 += 8
41
DrawSpriteScreenXY(TempValue0, TempValue1, 11)
42
43
// Draw the "Time" Graphic
44
TempValue1 += 48
45
DrawSpriteScreenXY(11, TempValue1, 16)
46
47
if Options.GameMode < MODE_TIMEATTACK
48
// In one of the normal game modes, where this object is the one keeping track of the time
49
50
// First digit of time
51
TempValue0 = Object.TimeSeconds
52
TempValue0 /= 100
53
TempValue1 += 40
54
DrawSpriteScreenXY(TempValue0, TempValue1, 11)
55
56
// Second digit of time
57
TempValue0 = Object.TimeSeconds
58
TempValue0 %= 100
59
TempValue0 /= 10
60
TempValue1 += 8
61
DrawSpriteScreenXY(TempValue0, TempValue1, 11)
62
63
// Last digit of time
64
TempValue0 = Object.TimeSeconds
65
TempValue0 %= 10
66
TempValue1 += 8
67
DrawSpriteScreenXY(TempValue0, TempValue1, 11)
68
69
TempValue1 += 64
70
else
71
// In Time Attack, where the global Stage.* variables are used for tracking time instead
72
73
// First things first, cap the timer at half an hour
74
// That's quite a while... why are you still here?
75
// (Note - this wasn't in the initial version of the game, it came from a mobile update & Origins)
76
if Stage.Minutes > 29
77
Stage.Minutes = 30
78
Stage.Seconds = 0
79
Stage.MilliSeconds = 0
80
end if
81
82
// Now, actually draw the number
83
84
// First draw the minutes
85
TempValue1 += 40
86
DrawNumbers(0, TempValue1, 11, Stage.Minutes, 2, 8, 1)
87
88
// Then draw the seconds tick
89
TempValue1 += 8
90
DrawSpriteScreenXY(13, TempValue1, 11)
91
92
// And draw the following seconds
93
TempValue1 += 16
94
DrawNumbers(0, TempValue1, 11, Stage.Seconds, 2, 8, 1)
95
96
// Then draw the milliseconds tick
97
TempValue1 += 8
98
DrawSpriteScreenXY(14, TempValue1, 11)
99
100
// And draw its corresponding milliseconds
101
TempValue1 += 16
102
DrawNumbers(0, TempValue1, 11, Stage.MilliSeconds, 2, 8, 1)
103
104
// And the add the remaining X space left to temp1, in order to make other HUD elements appear in their right positions
105
TempValue1 += 32
106
107
end if
108
109
// Draw the "Rings" Graphic
110
DrawSpriteScreenXY(12, TempValue1, 16)
111
112
// Draw the first digit of the Rings counter
113
TempValue0 = Object.Rings
114
TempValue0 /= 100
115
TempValue1 += 32
116
DrawSpriteScreenXY(TempValue0, TempValue1, 11)
117
118
// Then draw the second digit of the Rings counter
119
TempValue0 = Object.Rings
120
TempValue0 %= 100
121
TempValue0 /= 10
122
TempValue1 += 8
123
DrawSpriteScreenXY(TempValue0, TempValue1, 11)
124
125
// And finally, draw the last, third digit of the Rings counter
126
TempValue0 = Object.Rings
127
TempValue0 %= 10
128
TempValue1 += 8
129
DrawSpriteScreenXY(TempValue0, TempValue1, 11)
130
131
end sub
132
133
134
sub ObjectStartup
135
136
LoadSpriteSheet("Special/Objects.gif")
137
138
// Place the HUD object into reserved object slot 4 and initialise its values
139
Object[4].Type = TypeName[HUD]
140
141
// The object should always be run, regardless if it's within camera bounds or not
142
Object[4].Priority = PRIORITY_ACTIVE
143
144
// Make the HUD draw ontop of all other sprites, too
145
Object[4].DrawOrder = 6
146
147
// Reset the last cleared UFO type
148
// (Needs to be set to -1 and not just default 0 because the Rings UFO uses type 0)
149
Object[4].LastUFOType = -1
150
151
// 0-9 - Numbers 0-9
152
SpriteFrame(0, 0, 8, 13, 206, 84)
153
SpriteFrame(0, 0, 8, 13, 215, 84)
154
SpriteFrame(0, 0, 8, 13, 224, 84)
155
SpriteFrame(0, 0, 8, 13, 233, 84)
156
SpriteFrame(0, 0, 8, 13, 242, 84)
157
SpriteFrame(0, 0, 8, 13, 206, 98)
158
SpriteFrame(0, 0, 8, 13, 215, 98)
159
SpriteFrame(0, 0, 8, 13, 224, 98)
160
SpriteFrame(0, 0, 8, 13, 233, 98)
161
SpriteFrame(0, 0, 8, 13, 242, 98)
162
163
// 10 - UFO Counter Graphic
164
SpriteFrame(0, 0, 24, 16, 206, 58)
165
166
// 11 - Time Graphic
167
SpriteFrame(0, 0, 24, 8, 231, 58)
168
169
// 12 - Rings Graphic
170
SpriteFrame(0, 0, 31, 8, 206, 75)
171
172
// 13 - Single Tick Graphic
173
SpriteFrame(0, 0, 8, 13, 224, 112)
174
175
// 14 - Double Tick Graphic
176
SpriteFrame(0, 0, 8, 13, 233, 112)
177
178
end sub
179
180
181
// ========================
182
// Editor Subs
183
// ========================
184
185
sub RSDKDraw
186
DrawSprite(0)
187
end sub
188
189
190
sub RSDKLoad
191
LoadSpriteSheet("Special/Objects.gif")
192
SpriteFrame(0, 0, 24, 16, 206, 58)
193
194
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
195
end sub
196
197