Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 2/Scripts/Global/HUD.txt
1480 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: HUD Object
4
// Script Author: Christian Whitehead/Simon Thomley
5
// Unpacked by Rubberduckycooly's script unpacker
6
// ----------------------------------
7
8
// ========================
9
// Aliases
10
// ========================
11
12
private alias object.value0 : object.drawFunction
13
private alias object.value1 : object.flashingTimer
14
private alias object.value2 : object.timeOver
15
16
// Player Aliases
17
private alias object.type : player.type
18
private alias object.xpos : player.xpos
19
private alias object.ypos : player.ypos
20
private alias object.value0 : player.rings
21
22
// Game Mode Aliases
23
private alias 2 : MODE_TIMEATTACK
24
25
// Global Variable ID Aliases
26
private alias 22 : GLOBAL_PLAYERSCORE
27
private alias 25 : GLOBAL_PLAYERLIVES
28
29
30
// ========================
31
// Function Declarations
32
// ========================
33
34
reserve function HUD_Draw_Standard
35
reserve function HUD_Draw_Mobile
36
37
38
// ========================
39
// Function Definitions
40
// ========================
41
42
private function HUD_Draw_Standard
43
44
#platform: USE_ORIGINS
45
// temp4 will tell whether to draw lives or coins
46
temp4 = game.coinMode
47
48
if game.playMode == BOOT_PLAYMODE_MISSION
49
if game.missionEnd == false
50
game.hudEnable = HUDENABLE_ON
51
end if
52
temp4 = true
53
else
54
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
55
game.hudEnable = HUDENABLE_ON
56
temp4 = false
57
else
58
if game.coinMode != false
59
game.hudEnable = HUDENABLE_ON
60
end if
61
#endplatform
62
63
// Draw the base SCORE/TIME/RINGS text
64
DrawSpriteScreenXY(10, 17, 13)
65
66
#platform: USE_ORIGINS
67
temp2 = stage.minutes
68
temp3 = stage.seconds
69
70
CheckGreater(temp2, 9)
71
temp5 = checkResult
72
CheckNotEqual(object.timeOver, false)
73
checkResult |= temp5
74
75
if checkResult != false
76
temp2 = 9
77
temp3 = 59
78
end if
79
80
if temp2 == 9
81
#endplatform
82
#platform: USE_STANDALONE
83
if stage.minutes == 9
84
#endplatform
85
// Overlay the red TIME text
86
if object.flashingTimer > 7
87
DrawSpriteScreenXY(11, 17, 29)
88
end if
89
end if
90
91
// Overlay the red RINGS text if needed as well
92
#platform: USE_STANDALONE
93
if player[0].rings == 0
94
#endplatform
95
#platform: USE_ORIGINS
96
if player[currentPlayer].rings == 0
97
#endplatform
98
if object.flashingTimer > 7
99
DrawSpriteScreenXY(12, 17, 45)
100
end if
101
end if
102
103
#platform: USE_STANDALONE
104
DrawNumbers(0, 104, 13, player.score, 6, 8, false)
105
#endplatform
106
#platform: USE_ORIGINS
107
arrayPos0 = GLOBAL_PLAYERSCORE // VarName[player.score]
108
arrayPos0 += currentPlayer
109
DrawNumbers(0, 104, 13, global[arrayPos0], 6, 8, false)
110
#endplatform
111
112
if options.gameMode < MODE_TIMEATTACK
113
// Normal game - only minutes and seconds are shown
114
DrawSpriteScreenXY(14, 67, 29)
115
else
116
// Time attack - draw milliseconds alongside of the other values
117
DrawSpriteScreenXY(13, 67, 29)
118
DrawNumbers(0, 104, 29, stage.milliSeconds, 2, 8, true)
119
end if
120
121
// Rest of the time display
122
#platform: USE_STANDALONE
123
DrawNumbers(0, 80, 29, stage.seconds, 2, 8, true)
124
DrawNumbers(0, 56, 29, stage.minutes, 1, 8, true)
125
DrawNumbers(0, 80, 45, player[0].rings, 3, 8, false)
126
#endplatform
127
#platform: USE_ORIGINS
128
DrawNumbers(0, 80, 29, temp3, 2, 8, true)
129
DrawNumbers(0, 56, 29, temp2, 1, 8, true)
130
DrawNumbers(0, 80, 45, player[currentPlayer].rings, 3, 8, false)
131
#endplatform
132
133
if stage.debugMode == true
134
// Player position display
135
136
// XPos display
137
#platform: USE_STANDALONE
138
temp0 = player[0].xpos
139
#endplatform
140
#platform: USE_ORIGINS
141
temp0 = player[currentPlayer].xpos
142
#endplatform
143
temp0 >>= 16
144
Abs(temp0)
145
temp1 = screen.xsize
146
temp1 -= 24
147
DrawNumbers(0, temp1, 13, temp0, 5, 8, true)
148
149
// YPos display
150
#platform: USE_STANDALONE
151
temp0 = player[0].ypos
152
#endplatform
153
#platform: USE_ORIGINS
154
temp0 = player[currentPlayer].ypos
155
#endplatform
156
temp0 >>= 16
157
Abs(temp0)
158
DrawNumbers(0, temp1, 29, temp0, 5, 8, true)
159
160
// Move 42 pixels to the left
161
temp1 -= 42
162
163
// Draw the "X:" and "Y:" icons
164
165
// Use red variant if player is in a negative pos
166
#platform: USE_STANDALONE
167
if player[0].xpos >= 0
168
#endplatform
169
#platform: USE_ORIGINS
170
if player[currentPlayer].xpos >= 0
171
#endplatform
172
DrawSpriteScreenXY(18, temp1, 15)
173
else
174
DrawSpriteScreenXY(36, temp1, 15)
175
end if
176
177
#platform: USE_STANDALONE
178
if player[0].ypos >= 0
179
#endplatform
180
#platform: USE_ORIGINS
181
if player[currentPlayer].ypos >= 0
182
#endplatform
183
DrawSpriteScreenXY(19, temp1, 31)
184
else
185
DrawSpriteScreenXY(37, temp1, 31)
186
end if
187
end if
188
189
#platform: USE_STANDALONE
190
// Lives icon
191
temp0 = stage.playerListPos
192
temp0 += 15
193
DrawSpriteScreenXY(temp0, 16, 212)
194
195
// Character text
196
temp0 += 6
197
DrawSpriteScreenXY(temp0, 33, 213)
198
199
// X between icon and number
200
DrawSpriteScreenXY(20, 38, 222)
201
202
// The actual player lives number
203
DrawNumbers(24, 56, 220, player.lives, 2, 8, false)
204
#endplatform
205
206
#platform: USE_ORIGINS
207
end if
208
end if
209
210
if temp4 == false
211
// Get the character sprites
212
if currentPlayer == 0 // If this is Player 1
213
temp0 = stage.playerListPos
214
else
215
temp0 = vs.player2Type
216
end if
217
218
if temp0 == PLAYER_AMY
219
temp0 = 40
220
temp1 = 41
221
else
222
temp0 += 15
223
temp1 = temp0
224
temp1 += 6
225
end if
226
227
DrawSpriteScreenXY(temp0, 16, 212) // Life icon
228
DrawSpriteScreenXY(temp1, 33, 213) // Character name tag
229
230
// X between icon and number
231
DrawSpriteScreenXY(20, 38, 222)
232
233
// The actual player lives number
234
arrayPos0 = GLOBAL_PLAYERLIVES // VarName[player.lives]
235
arrayPos0 += currentPlayer
236
DrawNumbers(24, 56, 220, global[arrayPos0], 2, 8, false)
237
else
238
if game.playMode != BOOT_PLAYMODE_MISSION
239
// Draw the Coins counter
240
DrawSpriteScreenXY(38, 16, 212)
241
DrawSpriteScreenXY(39, 33, 213)
242
DrawSpriteScreenXY(20, 36, 222)
243
DrawNumbers(24, 59, 220, game.coinCount, 3, 8, false)
244
end if
245
end if
246
#endplatform
247
end function
248
249
250
private function HUD_Draw_Mobile
251
DrawSpriteScreenXY(10, 17, 9)
252
253
if stage.minutes == 9
254
if object.flashingTimer > 7
255
DrawSpriteScreenXY(11, 17, 25)
256
end if
257
end if
258
259
if player[0].rings == 0
260
if object.flashingTimer > 7
261
DrawSpriteScreenXY(12, 17, 41)
262
end if
263
end if
264
265
DrawNumbers(0, 104, 9, player.score, 6, 8, false)
266
267
if options.gameMode < MODE_TIMEATTACK
268
DrawSpriteScreenXY(14, 67, 25)
269
else
270
DrawSpriteScreenXY(13, 67, 25)
271
DrawNumbers(0, 104, 25, stage.milliSeconds, 2, 8, true)
272
end if
273
274
DrawNumbers(0, 80, 25, stage.seconds, 2, 8, true)
275
DrawNumbers(0, 56, 25, stage.minutes, 1, 8, true)
276
DrawNumbers(0, 80, 41, player[0].rings, 3, 8, false)
277
278
if player[0].type == TypeName[Debug Mode]
279
// Player position display, only show it when the player is in Debug Mode (as opposed to Standard's, where it's drawn if Debug Mode is active at all)
280
281
temp0 = player[0].xpos
282
temp0 >>= 16
283
Abs(temp0)
284
temp1 = screen.xsize
285
temp1 -= 16
286
DrawNumbers(0, temp1, 25, temp0, 5, 8, true)
287
288
temp0 = player[0].ypos
289
temp0 >>= 16
290
Abs(temp0)
291
DrawNumbers(0, temp1, 41, temp0, 5, 8, true)
292
293
temp1 -= 42
294
if player[0].xpos >= 0
295
DrawSpriteScreenXY(18, temp1, 27)
296
else
297
DrawSpriteScreenXY(36, temp1, 27)
298
end if
299
300
if player[0].ypos >= 0
301
DrawSpriteScreenXY(19, temp1, 43)
302
else
303
DrawSpriteScreenXY(37, temp1, 43)
304
end if
305
306
DrawSpriteScreenXY(34, screen.xcenter, 16)
307
DrawSpriteScreenXY(35, screen.xcenter, 16)
308
end if
309
310
temp1 = screen.xsize
311
temp1 -= 64
312
313
temp0 = stage.playerListPos
314
315
#platform: USE_STANDALONE
316
temp0 += 15
317
DrawSpriteScreenXY(temp0, temp1, 8)
318
#endplatform
319
320
#platform: USE_ORIGINS
321
// You never see the mobile HUD in Origins yet they updated it in Plus LOL
322
// It wasn't even properly updated, since temp1 is being overwritten the x position of the sprites are now broken
323
if temp0 == PLAYER_AMY
324
temp0 = 40
325
temp1 = 41
326
else
327
temp0 += 15
328
temp1 = temp0
329
temp1 += 6
330
end if
331
DrawSpriteScreenXY(temp0, temp1, 8)
332
#endplatform
333
334
temp1 += 17
335
#platform: USE_STANDALONE
336
temp0 += 6
337
DrawSpriteScreenXY(temp0, temp1, 9)
338
#endplatform
339
#platform: USE_ORIGINS
340
DrawSpriteScreenXY(temp1, temp1, 9) // Using the same value for both spriteframe and xpos LOL
341
#endplatform
342
343
temp1 += 5
344
DrawSpriteScreenXY(20, temp1, 18)
345
346
temp1 += 18
347
DrawNumbers(24, temp1, 16, player.lives, 2, 8, false)
348
end function
349
350
351
// ========================
352
// Events
353
// ========================
354
355
event ObjectDraw
356
// Update flashing red texts
357
#platform: USE_STANDALONE
358
if player[0].rings == 0
359
object.flashingTimer++
360
361
if object.flashingTimer == 16
362
object.flashingTimer = 0
363
end if
364
else
365
if stage.minutes == 9
366
object.flashingTimer++
367
368
if object.flashingTimer == 16
369
object.flashingTimer = 0
370
end if
371
end if
372
end if
373
#endplatform
374
375
#platform: USE_ORIGINS
376
currentPlayer = screen.currentID
377
378
if player[currentPlayer].rings == 0
379
object.flashingTimer = oscillation
380
object.flashingTimer &= 15
381
else
382
if stage.minutes == 9
383
object.flashingTimer = oscillation
384
object.flashingTimer &= 15
385
end if
386
end if
387
388
if game.timeOver != false
389
object.timeOver = true
390
end if
391
#endplatform
392
393
CallFunction(object.drawFunction)
394
end event
395
396
397
event ObjectStartup
398
LoadSpriteSheet("Global/Display.gif")
399
400
// HUD frames
401
SpriteFrame(0, 0, 8, 11, 1, 50) // #0 - Number 0
402
SpriteFrame(0, 0, 8, 11, 10, 50) // #1 - Number 1
403
SpriteFrame(0, 0, 8, 11, 19, 50) // #2 - Number 2
404
SpriteFrame(0, 0, 8, 11, 28, 50) // #3 - Number 3
405
SpriteFrame(0, 0, 8, 11, 1, 62) // #4 - Number 4
406
SpriteFrame(0, 0, 8, 11, 10, 62) // #5 - Number 5
407
SpriteFrame(0, 0, 8, 11, 19, 62) // #6 - Number 6
408
SpriteFrame(0, 0, 8, 11, 28, 62) // #7 - Number 7
409
SpriteFrame(0, 0, 8, 11, 1, 74) // #8 - Number 8
410
SpriteFrame(0, 0, 8, 11, 10, 74) // #9 - Number 9
411
412
// A-F digits are unused
413
414
SpriteFrame(0, 0, 40, 43, 1, 1) // #10 - Score, Time, Rings HUD text
415
SpriteFrame(0, 0, 31, 11, 1, 119) // #11 - Red Time text
416
SpriteFrame(0, 0, 39, 11, 1, 131) // #12 - Red Rings text
417
SpriteFrame(0, 0, 29, 4, 1, 45) // #13 - Timer ticks
418
SpriteFrame(0, 0, 3, 11, 37, 50) // #14 - Timer colon
419
SpriteFrame(0, 0, 16, 16, 83, 18) // #15 - Sonic life icon
420
SpriteFrame(0, 0, 16, 16, 100, 18) // #16 - Tails life icon
421
SpriteFrame(0, 0, 16, 16, 117, 18) // #17 - Knuckles life icon
422
SpriteFrame(0, 0, 8, 8, 1, 98) // #18 - Yellow X Debug Icon
423
SpriteFrame(0, 0, 8, 8, 10, 98) // #19 - Yellow Y Debug Icon
424
SpriteFrame(0, 0, 6, 6, 19, 98) // #20 - Small white x Debug Icon
425
426
SpriteFrame(0, 0, 31, 7, 185, 18) // #21 - Sonic name tag
427
428
// Tails or Miles
429
if options.region == false
430
SpriteFrame(0, 0, 31, 7, 217, 18) // #22 - Tails name tag
431
else
432
SpriteFrame(0, 0, 31, 7, 185, 26) // #22 - Miles name tag
433
end if
434
435
SpriteFrame(0, 0, 31, 7, 217, 26) // #23 - Knuckles name tag
436
437
SpriteFrame(0, 0, 8, 8, 37, 64) // #24 - Small number 0
438
SpriteFrame(0, 0, 8, 8, 46, 64) // #25 - Small number 1
439
SpriteFrame(0, 0, 8, 8, 55, 64) // #26 - Small number 2
440
SpriteFrame(0, 0, 8, 8, 64, 64) // #27 - Small number 3
441
SpriteFrame(0, 0, 8, 8, 73, 64) // #28 - Small number 4
442
SpriteFrame(0, 0, 8, 8, 82, 64) // #29 - Small number 5
443
SpriteFrame(0, 0, 8, 8, 91, 64) // #30 - Small number 6
444
SpriteFrame(0, 0, 8, 8, 100, 64) // #31 - Small number 7
445
SpriteFrame(0, 0, 8, 8, 109, 64) // #32 - Small number 8
446
SpriteFrame(0, 0, 8, 8, 118, 64) // #33 - Small number 9
447
448
SpriteFrame(-16, 0, 8, 8, 127, 64) // #34 - Small debug Plus sign
449
SpriteFrame(8, 0, 8, 8, 136, 64) // #35 - Small debug Minus sign
450
SpriteFrame(0, 0, 8, 8, 25, 98) // #36 - Red X Debug Icon
451
SpriteFrame(0, 0, 8, 8, 34, 98) // #37 - Red Y Debug Icon
452
453
#platform: USE_ORIGINS
454
SpriteFrame(0, 0, 16, 16, 179, 180) // #38 - Coins life icon
455
SpriteFrame(0, 0, 39, 7, 179, 197) // #39 - Coins name tag
456
457
SpriteFrame(0, 0, 16, 16, 120, 47) // #40 - Amy life icon
458
SpriteFrame(0, 0, 31, 7, 217, 34) // #41 - Amy name tag
459
#endplatform
460
461
// Set the HUD's draw function based on the current platform
462
foreach (TypeName[HUD], arrayPos0, ALL_ENTITIES)
463
if engine.deviceType == STANDARD
464
object[arrayPos0].drawFunction = HUD_Draw_Standard
465
else
466
object[arrayPos0].drawFunction = HUD_Draw_Mobile
467
end if
468
next
469
end event
470
471
472
// ========================
473
// Editor Events
474
// ========================
475
476
event RSDKDraw
477
DrawSprite(0)
478
end event
479
480
481
event RSDKLoad
482
LoadSpriteSheet("Global/Display.gif")
483
SpriteFrame(0, 0, 40, 43, 1, 1)
484
485
// This gets set in Stage Setup, but it's just an old CD leftover for time periods and doesn't do anything in this game
486
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
487
end event
488
489