Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-CD-2011-Script-Decompilation
Path: blob/main/Scripts/Global/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
#alias Object.Value3 : Object.DrawFunction
7
#alias Object.Value4 : Object.FlashTimer
8
#alias Object.Value5 : Object.PrevTimePeriod
9
#alias Object.Value6 : Object.TimeOver
10
11
#alias Object.PropertyValue : Object.CurrentTimePeriod
12
13
// Player Aliases
14
#alias Player.Value0 : Player.Rings
15
16
#alias 0 : PLAYER_SONIC_A
17
#alias 1 : PLAYER_TAILS_A
18
19
// Warp Destination
20
#alias 1 : WARPDEST_PAST
21
#alias 2 : WARPDEST_FUTURE
22
23
// Device Type
24
#alias 0 : RETRO_STANDARD
25
26
// Function declarations
27
#function HUD_DrawStandard
28
#function HUD_DrawMobile
29
30
31
function HUD_DrawStandard
32
#platform: Use_Origins
33
TempValue6 = game.coinMode
34
35
if game.playMode == BOOT_PLAYMODE_MISSION
36
// In Missions, don't draw the main HUD here
37
// Instead, signal to the HE2 part of the engine to draw it from there
38
39
if game.missionEnd == false
40
game.hudEnable = HUDENABLE_ON
41
end if
42
43
// These pair of temps aren't really used, at least with what's set here
44
TempValue1 = 69
45
TempValue5 = 212
46
47
// In Mission mode, this script is used to monitor Time Period changes
48
// -> Nothing's still drawn here, though
49
TempValue6 = true
50
else
51
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
52
// In Boss Rush, have the Engine draw the HUD rather than here from script
53
game.hudEnable = HUDENABLE_ON
54
55
// Similarly, these pair of values aren't exactly used here, either
56
TempValue1 = 69
57
TempValue5 = 212
58
59
// In Boss Rush, we use lives rather than Coins
60
TempValue6 = false
61
else
62
if game.coinMode != false
63
game.hudEnable = HUDENABLE_ON
64
end if
65
66
// First, draw the Score/Time/Rings text
67
DrawSpriteScreenXY(10, 17, 13)
68
69
// Record the current time
70
TempValue2 = Stage.Minutes
71
TempValue3 = Stage.Seconds
72
TempValue4 = Stage.MilliSeconds
73
74
// Check if the timer's minutes are passing 9
75
CheckGreater(TempValue2, 9)
76
77
TempValue5 = CheckResult
78
79
// Or check to see if the Time Over override is active
80
CheckNotEqual(Object.TimeOver, false)
81
82
// Combine the previous two results into one
83
CheckResult |= TempValue5
84
85
if CheckResult != false // If we exceeded the 10 minutes, display 9'59'99
86
TempValue2 = 9
87
TempValue3 = 59
88
TempValue4 = 99
89
end if
90
91
// Start flashing Time at minute 9
92
if TempValue2 == 9
93
if Object.FlashTimer > 7
94
DrawSpriteScreenXY(11, 17, 29)
95
end if
96
end if
97
#endplatform
98
99
#platform: Use_Standalone
100
// First, draw the Score/Time/Rings text
101
DrawSpriteScreenXY(10, 17, 13)
102
103
// Start flashing Time at minute 9
104
if Stage.Minutes == 9
105
if Object.FlashTimer > 7
106
DrawSpriteScreenXY(11, 17, 29)
107
end if
108
end if
109
#endplatform
110
111
// Flash the Rings text if the player doesn't have rings
112
if Player.Rings == 0
113
if Object.FlashTimer > 7
114
DrawSpriteScreenXY(12, 17, 45)
115
end if
116
end if
117
118
// Draw the timer's tick marks
119
DrawSpriteScreenXY(13, 67, 29)
120
121
// Now, draw all the numbers
122
DrawNumbers(0, 104, 13, Player.Score, 6, 8, false) // Score
123
124
#platform: Use_Standalone
125
DrawNumbers(0, 104, 29, Stage.MilliSeconds, 2, 8, true) // Milliseconds
126
DrawNumbers(0, 80, 29, Stage.Seconds, 2, 8, 1) // Seconds
127
DrawNumbers(0, 56, 29, Stage.Minutes, 1, 8, 1) // Minutes
128
#endplatform
129
130
#platform: Use_Origins
131
DrawNumbers(0, 104, 29, TempValue4, 2, 8, true) // Milliseconds
132
DrawNumbers(0, 80, 29, TempValue3, 2, 8, true) // Seconds
133
DrawNumbers(0, 56, 29, TempValue2, 1, 8, true) // Minutes
134
#endplatform
135
136
DrawNumbers(0, 80, 45, Player.Rings, 3, 8, false) // Rings
137
138
if Stage.DebugMode == true // In Debug Mode, draw the position of the Player
139
// Get the truncated X Position of the Player
140
TempValue0 = Player.XPos
141
TempValue0 >>= 16
142
143
// Set screen XPos for this value
144
TempValue1 = Screen.XSize
145
TempValue1 -= 24
146
147
// Draw the X Position numbers
148
DrawNumbers(0, TempValue1, 13, TempValue0, 5, 8, true)
149
150
// Get the truncated Y Position of the Player
151
TempValue0 = Player.YPos
152
TempValue0 >>= 16
153
154
if TempValue0 < 0
155
// YPos is always drawn as positive
156
FlipSign(TempValue0)
157
end if
158
159
// Draw the Y Position
160
DrawNumbers(0, TempValue1, 29, TempValue0, 5, 8, true)
161
162
TempValue1 -= 42
163
// Draw the X/Y icons
164
DrawSpriteScreenXY(14, TempValue1, 15)
165
DrawSpriteScreenXY(21, TempValue1, 31)
166
end if
167
#platform: Use_Origins
168
end if
169
end if
170
171
if TempValue6 == false // Using Lives
172
#endplatform
173
// Get the current Time Period, then add it's equivalent sprite id
174
TempValue0 = Object.CurrentTimePeriod
175
TempValue0 += 17
176
// Now, draw the corresponding life icon for the time period
177
DrawSpriteScreenXY(TempValue0, 16, 212)
178
// Draw the X/times icon
179
DrawSpriteScreenXY(14, 32, 220)
180
181
// Only draw as many digits as the Lives has
182
if Player.Lives < 10
183
DrawNumbers(0, 40, 217, Player.Lives, 1, 8, true)
184
TempValue1 = 52
185
else
186
DrawNumbers(0, 48, 217, Player.Lives, 2, 8, true)
187
TempValue1 = 60
188
end if
189
TempValue5 = 214
190
#platform: Use_Origins
191
else // Using Coins
192
// This TempValue0 isn't really used...
193
TempValue0 = Object.CurrentTimePeriod
194
// See if the Time Period's changed
195
if Object.PrevTimePeriod != Object.CurrentTimePeriod
196
Object.PrevTimePeriod = Object.CurrentTimePeriod
197
198
game.callbackParam0 = Object.CurrentTimePeriod // Signal the new period over to the engine
199
EngineCallback(NOTIFY_FUTURE_PAST)
200
end if
201
202
// In Missions, Coins shouldn't be drawn here
203
if game.playMode != BOOT_PLAYMODE_MISSION
204
// Get the current Time Period
205
TempValue0 = Object.CurrentTimePeriod
206
207
// And bump it up by 22 to match the Coins Sprite Frame IDs
208
TempValue0 += 22
209
210
// Draw the Coins icon
211
DrawSpriteScreenXY(TempValue0, 16, 212)
212
213
// Draw the two halves of the "COINS" text
214
DrawSpriteScreenXY(26, 33, 213)
215
DrawSpriteScreenXY(27, 51, 213)
216
217
// X
218
DrawSpriteScreenXY(28, 36, 222)
219
220
// And then, the actual Coin count
221
DrawNumbers(29, 59, 220, game.coinCount, 3, 8, false)
222
end if
223
224
TempValue1 = 69
225
TempValue5 = 212
226
end if
227
#endplatform
228
229
switch Warp.Destination
230
// Draw the past sign, flicker it while trying to warp
231
case WARPDEST_PAST
232
if Warp.Timer < 100
233
DrawSpriteScreenXY(15, TempValue1, TempValue5)
234
else
235
TempValue0 = Warp.Timer
236
TempValue0 &= 1
237
if TempValue0 == 0
238
DrawSpriteScreenXY(15, TempValue1, TempValue5)
239
end if
240
end if
241
break
242
243
case WARPDEST_FUTURE
244
// Draw the future sign, flicker it while trying to warp
245
if Warp.Timer < 100
246
DrawSpriteScreenXY(16, TempValue1, TempValue5)
247
else
248
TempValue0 = Warp.Timer
249
TempValue0 &= 1
250
if TempValue0 == 0
251
DrawSpriteScreenXY(16, TempValue1, TempValue5)
252
end if
253
end if
254
break
255
end switch
256
end function
257
258
259
function HUD_DrawMobile
260
// Aside from being inside a function, this is the same code from the original mobile release
261
262
// Draw the Score, Time, Rings text
263
DrawSpriteScreenXY(10, 17, 9)
264
265
// Start flashing Time at minute 9
266
if Stage.Minutes == 9
267
if Object.FlashTimer > 7
268
DrawSpriteScreenXY(11, 17, 25)
269
end if
270
end if
271
// Flash the Rings text at 0 rings
272
if Player.Rings == 0
273
if Object.FlashTimer > 7
274
DrawSpriteScreenXY(12, 17, 41)
275
end if
276
end if
277
278
// Draw the timer's tick marks
279
DrawSpriteScreenXY(13, 67, 25)
280
281
// Now, draw all the numbers
282
DrawNumbers(0, 104, 9, Player.Score, 6, 8, false)
283
284
DrawNumbers(0, 104, 25, Stage.MilliSeconds, 2, 8, true) // Milliseconds
285
DrawNumbers(0, 80, 25, Stage.Seconds, 2, 8, true) // Seconds
286
DrawNumbers(0, 56, 25, Stage.Minutes, 1, 8, true) // Minutes
287
288
DrawNumbers(0, 80, 41, Player.Rings, 3, 8, false)
289
290
// Debug Mode coordinates drawing
291
if Stage.DebugMode == true
292
// Get the truncated X Position of the Player
293
TempValue0 = Player.XPos
294
TempValue0 >>= 16
295
296
// Set screen XPos for this value
297
TempValue1 = Screen.XSize
298
TempValue1 -= 16
299
300
// Draw the X Position numbers
301
DrawNumbers(0, TempValue1, 25, TempValue0, 5, 8, true)
302
303
// Get the truncated Y Position of the Player
304
TempValue0 = Player.YPos
305
TempValue0 >>= 16
306
307
if TempValue0 < 0
308
// YPos is always drawn as positive
309
FlipSign(TempValue0)
310
311
end if
312
313
// Draw the Y Position
314
DrawNumbers(0, TempValue1, 41, TempValue0, 5, 8, true)
315
316
TempValue1 -= 42
317
318
// Draw the X/Y icons
319
DrawSpriteScreenXY(14, TempValue1, 27)
320
DrawSpriteScreenXY(21, TempValue1, 43)
321
end if
322
323
// Lives Counter
324
325
// Get the X Position to draw the life icon at
326
TempValue1 = Screen.XSize
327
TempValue1 -= 48
328
// Get the current Time Period, then add it's equivalent sprite id
329
TempValue0 = Object.CurrentTimePeriod
330
TempValue0 += 17
331
// Now, draw the corresponding life icon for the time period
332
DrawSpriteScreenXY(TempValue0, TempValue1, 8)
333
334
TempValue1 += 16
335
// Draw the X/times icon
336
DrawSpriteScreenXY(14, TempValue1, 16)
337
338
// Only draw as many digits as the Lives has
339
if Player.Lives < 10
340
TempValue1 += 8
341
DrawNumbers(0, TempValue1, 13, Player.Lives, 1, 8, true)
342
else
343
TempValue1 += 16
344
DrawNumbers(0, TempValue1, 13, Player.Lives, 2, 8, true)
345
TempValue1 -= 8
346
end if
347
348
switch Warp.Destination
349
// Draw the past sign, flicker it while trying to warp
350
case WARPDEST_PAST
351
TempValue1 -= 79
352
if Warp.Timer < 100
353
DrawSpriteScreenXY(15, TempValue1, 8)
354
else
355
TempValue0 = Warp.Timer
356
TempValue0 &= 1
357
if TempValue0 == 0
358
DrawSpriteScreenXY(15, TempValue1, 8)
359
end if
360
end if
361
break
362
// Draw the future sign, flicker it while trying to warp
363
case WARPDEST_FUTURE
364
TempValue1 -= 79
365
if Warp.Timer < 100
366
DrawSpriteScreenXY(16, TempValue1, 8)
367
else
368
TempValue0 = Warp.Timer
369
TempValue0 &= 1
370
if TempValue0 == 0
371
DrawSpriteScreenXY(16, TempValue1, 8)
372
end if
373
end if
374
break
375
end switch
376
377
end function
378
379
380
sub ObjectDraw
381
if Player.Rings == 0
382
Object.FlashTimer++
383
384
if Object.FlashTimer == 16
385
Object.FlashTimer = 0
386
end if
387
else
388
if Stage.Minutes == 9
389
Object.FlashTimer++
390
391
if Object.FlashTimer == 16
392
Object.FlashTimer = 0
393
end if
394
end if
395
end if
396
397
#platform: Use_Origins
398
if game.timeOver != false
399
Object.TimeOver = true
400
end if
401
#endplatform
402
403
// Call the corresponding drawing function for the HUD
404
CallFunction(Object.DrawFunction)
405
end sub
406
407
408
sub ObjectStartup
409
// Standard Platforms and Mobile Platforms have different drawing routines
410
// In Origins, only the Standard version was updated and the Mobile version was left
411
if Stage.PlayerListPos == PLAYER_SONIC_A // PLAYER_SONIC in origins
412
LoadSpriteSheet("Global/Display.gif")
413
end if
414
if Stage.PlayerListPos == PLAYER_TAILS_A // PLAYER_TAILS in origins
415
LoadSpriteSheet("Global/Display_t.gif")
416
end if
417
#platform: Use_Origins
418
if Stage.PlayerListPos == PLAYER_KNUCKLES
419
LoadSpriteSheet("Global/Display_K.gif")
420
end if
421
if Stage.PlayerListPos == PLAYER_AMY
422
LoadSpriteSheet("Global/Display_A.gif")
423
end if
424
425
if Engine.DeviceType == RETRO_STANDARD
426
Object[24].DrawFunction = HUD_DrawStandard
427
else
428
Object[24].DrawFunction = HUD_DrawMobile
429
end if
430
#endplatform
431
432
// Has to be this way to ensure steam 2011 cd will still work
433
#platform: Use_Standalone
434
#platform: Standard
435
Object[24].DrawFunction = HUD_DrawStandard
436
#endplatform
437
#endplatform
438
439
#platform: Use_Standalone
440
#platform: Mobile
441
Object[24].DrawFunction = HUD_DrawMobile
442
#endplatform
443
#endplatform
444
445
// 0-9 - Number Digits
446
SpriteFrame(0, 0, 8, 11, 1, 50)
447
SpriteFrame(0, 0, 8, 11, 10, 50)
448
SpriteFrame(0, 0, 8, 11, 19, 50)
449
SpriteFrame(0, 0, 8, 11, 28, 50)
450
SpriteFrame(0, 0, 8, 11, 1, 62)
451
SpriteFrame(0, 0, 8, 11, 10, 62)
452
SpriteFrame(0, 0, 8, 11, 19, 62)
453
SpriteFrame(0, 0, 8, 11, 28, 62)
454
SpriteFrame(0, 0, 8, 11, 1, 74)
455
SpriteFrame(0, 0, 8, 11, 10, 74)
456
457
// 10 - Score, Time, Rings text
458
SpriteFrame(0, 0, 39, 43, 1, 1)
459
460
// 11 - Red Time text
461
SpriteFrame(0, 0, 31, 11, 1, 119)
462
463
// 12 - Red Rings text
464
SpriteFrame(0, 0, 39, 11, 1, 131)
465
466
// 13 - Tick marks
467
SpriteFrame(0, 0, 29, 4, 1, 45)
468
469
// 14 - Yellow X (used for debug & lives count)
470
SpriteFrame(0, 0, 8, 8, 1, 98)
471
472
// 15 -Past Sign
473
SpriteFrame(0, 0, 32, 16, 90, 67)
474
475
// 16 - Future Sign
476
SpriteFrame(0, 0, 32, 16, 123, 67)
477
478
// 17 - Present Life Icon
479
SpriteFrame(0, 0, 16, 16, 187, 189)
480
481
// 18 - Past Life Icon
482
SpriteFrame(0, 0, 16, 16, 204, 189)
483
484
// 19-20 - Future Life Icon (duplicated)
485
SpriteFrame(0, 0, 16, 16, 237, 223)
486
SpriteFrame(0, 0, 16, 16, 237, 223)
487
488
// 21 - Debug Y
489
SpriteFrame(0, 0, 8, 8, 10, 98)
490
491
#platform: Use_Origins
492
// 22 - Coins Icon
493
SpriteFrame(0, 0, 16, 16, 186, 108)
494
495
// 23 - Past Coins Icon
496
SpriteFrame(0, 0, 16, 16, 1, 257)
497
498
// 24-25 - Future Coins Icon (duplicated as well)
499
SpriteFrame(0, 0, 16, 16, 18, 257)
500
SpriteFrame(0, 0, 16, 16, 18, 257)
501
502
// 26 - "COI"
503
SpriteFrame(0, 0, 18, 7, 203, 108)
504
505
// 27 - "NS"
506
SpriteFrame(0, 0, 18, 7, 203, 116)
507
508
// 28 - Small X (used for the Coins count)
509
SpriteFrame(0, 0, 6, 6, 186, 125)
510
511
// 29-38 - Small Numbers, for the Coins counter
512
SpriteFrame(0, 0, 8, 8, 19, 98)
513
SpriteFrame(0, 0, 8, 8, 28, 98)
514
SpriteFrame(0, 0, 8, 8, 33, 119)
515
SpriteFrame(0, 0, 8, 8, 213, 1)
516
SpriteFrame(0, 0, 8, 8, 213, 10)
517
SpriteFrame(0, 0, 8, 8, 213, 19)
518
SpriteFrame(0, 0, 8, 8, 213, 28)
519
SpriteFrame(0, 0, 8, 8, 213, 37)
520
SpriteFrame(0, 0, 8, 8, 213, 46)
521
SpriteFrame(0, 0, 8, 8, 213, 55)
522
#endplatform
523
end sub
524
525
526
// ========================
527
// Editor Subs
528
// ========================
529
530
sub RSDKEdit
531
if Editor.ReturnVariable == true
532
switch Editor.VariableID
533
case EDIT_VAR_PROPVAL // Property Value
534
case 0 // TimePeriod
535
CheckResult = Object.PropertyValue
536
break
537
end switch
538
else
539
switch Editor.VariableID
540
case EDIT_VAR_PROPVAL // Property Value
541
case 0 // TimePeriod
542
Object.PropertyValue = Editor.VariableValue
543
break
544
end switch
545
end if
546
end sub
547
548
549
sub RSDKDraw
550
DrawSprite(0)
551
end sub
552
553
554
sub RSDKLoad
555
LoadSpriteSheet("Global/Display.gif")
556
SpriteFrame(0, 0, 39, 43, 1, 1)
557
558
AddEditorVariable("TimePeriod")
559
SetActiveVariable("TimePeriod")
560
AddEnumVariable("Present", 0)
561
AddEnumVariable("Past", 1)
562
AddEnumVariable("Good Future", 2)
563
AddEnumVariable("Bad Future", 3)
564
end sub
565
566