Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-Sonic-2-2013-Script-Decompilation
Path: blob/master/Sonic 1/Scripts/Global/HUD.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 1
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.flashTimer
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 Modes Aliases
23
private alias 2 : MODE_TIMEATTACK
24
25
26
// ========================
27
// Function Declarations
28
// ========================
29
30
reserve function HUD_Draw_Standard
31
reserve function HUD_Draw_Mobile
32
33
34
// ========================
35
// Function Definitions
36
// ========================
37
38
private function HUD_Draw_Standard
39
#platform: USE_ORIGINS
40
// temp4 will tell whether to draw lives or coins
41
temp4 = game.coinMode
42
43
if game.playMode == BOOT_PLAYMODE_MISSION
44
if game.missionEnd == false
45
game.hudEnable = HUDENABLE_ON
46
end if
47
temp4 = true
48
else
49
50
if game.playMode == BOOT_PLAYMODE_BOSSRUSH
51
game.hudEnable = HUDENABLE_ON
52
temp4 = false
53
else
54
55
if game.coinMode != false
56
game.hudEnable = HUDENABLE_ON
57
end if
58
#endplatform
59
60
DrawSpriteScreenXY(10, 17, 13)
61
62
#platform: USE_ORIGINS
63
temp1 = stage.minutes
64
temp2 = stage.seconds
65
66
CheckGreater(temp1, 9)
67
temp3 = checkResult
68
CheckNotEqual(object.timeOver, false)
69
checkResult |= temp3
70
71
if checkResult != false
72
temp1 = 9
73
temp2 = 59
74
end if
75
76
if temp1 == 9
77
#endplatform
78
79
#platform: USE_STANDALONE
80
if stage.minutes == 9
81
#endplatform
82
if object.flashTimer > 7
83
DrawSpriteScreenXY(11, 17, 29)
84
end if
85
end if
86
87
if player[0].rings == 0
88
if object.flashTimer > 7
89
DrawSpriteScreenXY(12, 17, 45)
90
end if
91
end if
92
93
DrawNumbers(0, 104, 13, player.score, 6, 8, false)
94
95
if options.gameMode < MODE_TIMEATTACK
96
// In standard mode, only seconds & minutes are shown, along with their corresponding ticks
97
DrawSpriteScreenXY(14, 67, 29)
98
else
99
// If in time attack, draw extended time with milliseconds (and its extra ticks)
100
DrawSpriteScreenXY(13, 67, 29)
101
DrawNumbers(0, 104, 29, stage.milliSeconds, 2, 8, true)
102
end if
103
104
// Rest of the time display, kept the same between modes
105
#platform: USE_STANDALONE
106
DrawNumbers(0, 80, 29, stage.seconds, 2, 8, true)
107
DrawNumbers(0, 56, 29, stage.minutes, 1, 8, true)
108
#endplatform
109
#platform: USE_ORIGINS
110
DrawNumbers(0, 80, 29, temp2, 2, 8, true)
111
DrawNumbers(0, 56, 29, temp1, 1, 8, true)
112
#endplatform
113
114
DrawNumbers(0, 80, 45, player[0].rings, 3, 8, false)
115
116
if stage.debugMode == true
117
// If the player is in debug mode, draw X and Y positions
118
119
// First get the absolute X pos value, truncated down to essentially ixpos
120
temp0 = player[0].xpos
121
temp0 >>= 16
122
Abs(temp0)
123
124
// Get position to draw it
125
temp1 = screen.xsize
126
temp1 -= 24
127
128
// Draw the XPos value
129
DrawNumbers(0, temp1, 13, temp0, 5, 8, true)
130
131
// Then get absolute Y pos value, also truncated down to iypos
132
temp0 = player[0].ypos
133
temp0 >>= 16
134
Abs(temp0)
135
136
// Draw the YPos value
137
DrawNumbers(0, temp1, 29, temp0, 5, 8, true)
138
139
temp1 -= 42
140
141
// If XPos is in the negatives, draw the red version of the "X:" icon
142
if player[0].xpos >= 0
143
#platform: USE_STANDALONE
144
DrawSpriteScreenXY(18, temp1, 15)
145
#endplatform
146
#platform: USE_ORIGINS
147
DrawSpriteScreenXY(21, temp1, 15)
148
#endplatform
149
else
150
#platform: USE_STANDALONE
151
DrawSpriteScreenXY(36, temp1, 15)
152
#endplatform
153
#platform: USE_ORIGINS
154
DrawSpriteScreenXY(42, temp1, 15)
155
#endplatform
156
end if
157
158
// Same for YPos - if negative, draw red version of "Y:" icon
159
if player[0].ypos >= 0
160
#platform: USE_STANDALONE
161
DrawSpriteScreenXY(19, temp1, 31)
162
#endplatform
163
#platform: USE_ORIGINS
164
DrawSpriteScreenXY(22, temp1, 31)
165
#endplatform
166
else
167
#platform: USE_STANDALONE
168
DrawSpriteScreenXY(37, temp1, 31)
169
#endplatform
170
#platform: USE_ORIGINS
171
DrawSpriteScreenXY(43, temp1, 31)
172
#endplatform
173
end if
174
end if
175
#platform: USE_ORIGINS
176
end if
177
end if
178
179
if temp4 == false
180
#endplatform
181
// Draw life indicator
182
temp0 = stage.playerListPos
183
temp0 += 15
184
DrawSpriteScreenXY(temp0, 16, 212)
185
#platform: USE_STANDALONE
186
temp0 += 6
187
#endplatform
188
#platform: USE_ORIGINS
189
temp0 += 9
190
#endplatform
191
192
DrawSpriteScreenXY(temp0, 33, 213)
193
#platform: USE_STANDALONE
194
DrawSpriteScreenXY(20, 38, 222)
195
DrawNumbers(24, 56, 220, player.lives, 2, 8, false)
196
#endplatform
197
#platform: USE_ORIGINS
198
DrawSpriteScreenXY(23, 38, 222)
199
DrawNumbers(30, 56, 220, player.lives, 2, 8, false)
200
else
201
if game.playMode != BOOT_PLAYMODE_MISSION
202
// Draw coins indicator
203
DrawSpriteScreenXY(44, 16, 212)
204
DrawSpriteScreenXY(45, 33, 213)
205
DrawSpriteScreenXY(23, 36, 222)
206
DrawNumbers(30, 59, 220, game.coinCount, 3, 8, false)
207
end if
208
end if
209
#endplatform
210
end function
211
212
213
private function HUD_Draw_Mobile
214
DrawSpriteScreenXY(10, 17, 9)
215
216
if stage.minutes == 9
217
if object.flashTimer > 7
218
DrawSpriteScreenXY(11, 17, 25)
219
end if
220
end if
221
222
if player[0].rings == 0
223
if object.flashTimer > 7
224
DrawSpriteScreenXY(12, 17, 41)
225
end if
226
end if
227
228
DrawNumbers(0, 104, 9, player.score, 6, 8, false)
229
if options.gameMode < MODE_TIMEATTACK
230
DrawSpriteScreenXY(14, 67, 25)
231
else
232
DrawSpriteScreenXY(13, 67, 25)
233
DrawNumbers(0, 104, 25, stage.milliSeconds, 2, 8, true)
234
end if
235
DrawNumbers(0, 80, 25, stage.seconds, 2, 8, true)
236
DrawNumbers(0, 56, 25, stage.minutes, 1, 8, true)
237
DrawNumbers(0, 80, 41, player[0].rings, 3, 8, false)
238
239
if player[0].type == TypeName[Debug Mode]
240
temp0 = player[0].xpos
241
temp0 >>= 16
242
Abs(temp0)
243
temp1 = screen.xsize
244
temp1 -= 16
245
DrawNumbers(0, temp1, 25, temp0, 5, 8, true)
246
temp0 = player[0].ypos
247
temp0 >>= 16
248
Abs(temp0)
249
DrawNumbers(0, temp1, 41, temp0, 5, 8, true)
250
temp1 -= 42
251
if player[0].xpos >= 0
252
#platform: USE_STANDALONE
253
DrawSpriteScreenXY(18, temp1, 27)
254
#endplatform
255
#platform: USE_ORIGINS
256
DrawSpriteScreenXY(21, temp1, 27)
257
#endplatform
258
259
else
260
#platform: USE_STANDALONE
261
DrawSpriteScreenXY(36, temp1, 27)
262
#endplatform
263
#platform: USE_ORIGINS
264
DrawSpriteScreenXY(42, temp1, 27)
265
#endplatform
266
end if
267
268
// Same for YPos - if negative, draw red version of "Y:" icon
269
if player[0].ypos >= 0
270
271
#platform: USE_STANDALONE
272
DrawSpriteScreenXY(19, temp1, 43)
273
#endplatform
274
#platform: USE_ORIGINS
275
DrawSpriteScreenXY(22, temp1, 43)
276
#endplatform
277
else
278
279
#platform: USE_STANDALONE
280
DrawSpriteScreenXY(37, temp1, 43)
281
#endplatform
282
#platform: USE_ORIGINS
283
DrawSpriteScreenXY(43, temp1, 43)
284
#endplatform
285
end if
286
#platform: USE_STANDALONE
287
DrawSpriteScreenXY(34, screen.xcenter, 16)
288
DrawSpriteScreenXY(35, screen.xcenter, 16)
289
#endplatform
290
#platform: USE_ORIGINS
291
DrawSpriteScreenXY(40, screen.xcenter, 16)
292
DrawSpriteScreenXY(41, screen.xcenter, 16)
293
#endplatform
294
295
end if
296
temp1 = screen.xsize
297
temp1 -= 64
298
temp0 = stage.playerListPos
299
temp0 += 15
300
DrawSpriteScreenXY(temp0, temp1, 8)
301
temp1 += 17
302
#platform: USE_STANDALONE
303
temp0 += 6
304
#endplatform
305
#platform: USE_ORIGINS
306
temp0 += 9
307
#endplatform
308
DrawSpriteScreenXY(temp0, temp1, 9)
309
temp1 += 5
310
#platform: USE_STANDALONE
311
DrawSpriteScreenXY(20, temp1, 18)
312
#endplatform
313
#platform: USE_ORIGINS
314
DrawSpriteScreenXY(23, temp1, 18)
315
#endplatform
316
317
temp1 += 18
318
#platform: USE_STANDALONE
319
DrawNumbers(24, temp1, 16, player.lives, 2, 8, false)
320
#endplatform
321
#platform: USE_ORIGINS
322
DrawNumbers(30, temp1, 16, player.lives, 2, 8, false)
323
#endplatform
324
end function
325
326
327
// ========================
328
// Events
329
// ========================
330
331
event ObjectDraw
332
// Progress HUD flashing
333
// 0 ring flashing takes priority over time over flashing
334
if player[0].rings == 0
335
object.flashTimer++
336
if object.flashTimer == 16
337
object.flashTimer = 0
338
end if
339
else
340
if stage.minutes == 9
341
object.flashTimer++
342
if object.flashTimer == 16
343
object.flashTimer = 0
344
end if
345
end if
346
end if
347
348
#platform: USE_ORIGINS
349
if game.timeOver != false
350
object.timeOver = true
351
end if
352
#endplatform
353
354
CallFunction(object.drawFunction)
355
end event
356
357
358
event ObjectStartup
359
LoadSpriteSheet("Global/Display.gif")
360
361
// HUD frames (numbers are formatted as Standalone/Origins)
362
SpriteFrame(0, 0, 8, 11, 1, 50) // 0/ 0 - Number 0
363
SpriteFrame(0, 0, 8, 11, 10, 50) // 1/ 1 - Number 1
364
SpriteFrame(0, 0, 8, 11, 19, 50) // 2/ 2 - Number 2
365
SpriteFrame(0, 0, 8, 11, 28, 50) // 3/ 3 - Number 3
366
SpriteFrame(0, 0, 8, 11, 1, 62) // 4/ 4 - Number 4
367
SpriteFrame(0, 0, 8, 11, 10, 62) // 5/ 5 - Number 5
368
SpriteFrame(0, 0, 8, 11, 19, 62) // 6/ 6 - Number 6
369
SpriteFrame(0, 0, 8, 11, 28, 62) // 7/ 7 - Number 7
370
SpriteFrame(0, 0, 8, 11, 1, 74) // 8/ 8 - Number 8
371
SpriteFrame(0, 0, 8, 11, 10, 74) // 9/ 9 - Number 9
372
SpriteFrame(0, 0, 39, 43, 1, 1) // 10/10 - Score, Times, Ring text
373
SpriteFrame(0, 0, 31, 11, 1, 119) // 11/11 - Red Time text
374
SpriteFrame(0, 0, 39, 11, 1, 131) // 12/12 - Red Rings text
375
SpriteFrame(0, 0, 29, 4, 1, 45) // 13/13 - Timer tick marks
376
SpriteFrame(0, 0, 3, 11, 37, 50) // 14/14 - : (Colon)
377
SpriteFrame(0, 0, 16, 16, 43, 107) // 15/15 - Sonic life icon
378
SpriteFrame(0, 0, 16, 16, 60, 107) // 16/16 - Tails life icon
379
SpriteFrame(0, 0, 16, 16, 77, 107) // 17/17 - Knuckles life icon
380
#platform: USE_ORIGINS
381
SpriteFrame(0, 0, 16, 16, 0, 0) // XX/18 - Padding for Amy icon (her character ID is 5)
382
SpriteFrame(0, 0, 16, 16, 0, 0) // XX/19 - Padding for Amy icon (her character ID is 5)
383
SpriteFrame(0, 0, 16, 16, 239, 174) // XX/20 - Amy life icon
384
#endplatform
385
SpriteFrame(0, 0, 8, 8, 1, 98) // 18/21 - Yellow "X" debug icon
386
SpriteFrame(0, 0, 8, 8, 10, 98) // 19/22 - Yellow "Y" debug icon
387
SpriteFrame(0, 0, 6, 6, 19, 98) // 20/23 - White small x debug icon
388
SpriteFrame(0, 0, 31, 7, 144, 43) // 21/24 - Sonic name tag
389
390
// Determine between Tails or Miles based on region setting
391
if options.region == 0
392
SpriteFrame(0, 0, 31, 7, 176, 43) // 22/25 - Tails name tag
393
else
394
SpriteFrame(0, 0, 31, 7, 176, 51) // 22/25 - Miles name tag
395
end if
396
397
SpriteFrame(0, 0, 31, 7, 144, 51) // 23/26 - Knuckles name tag
398
#platform: USE_ORIGINS
399
SpriteFrame(0, 0, 31, 7, 0, 0) // XX/27 - Padding for Amy name tag (her character ID is 5)
400
SpriteFrame(0, 0, 31, 7, 0, 0) // XX/28 - Padding for Amy name tag (her character ID is 5)
401
SpriteFrame(0, 0, 31, 7, 182, 183) // XX/29 - Amy name tag
402
#endplatform
403
SpriteFrame(0, 0, 8, 8, 37, 64) // 24/30 - Small number 0
404
SpriteFrame(0, 0, 8, 8, 46, 64) // 25/31 - Small number 1
405
SpriteFrame(0, 0, 8, 8, 55, 64) // 26/32 - Small number 2
406
SpriteFrame(0, 0, 8, 8, 64, 64) // 27/33 - Small number 3
407
SpriteFrame(0, 0, 8, 8, 73, 64) // 28/34 - Small number 4
408
SpriteFrame(0, 0, 8, 8, 82, 64) // 29/35 - Small number 5
409
SpriteFrame(0, 0, 8, 8, 91, 64) // 30/36 - Small number 6
410
SpriteFrame(0, 0, 8, 8, 100, 64) // 31/37 - Small number 7
411
SpriteFrame(0, 0, 8, 8, 109, 64) // 32/38 - Small number 8
412
SpriteFrame(0, 0, 8, 8, 118, 64) // 33/39 - Small number 9
413
SpriteFrame(-16, 0, 8, 8, 127, 64) // 34/40 - Small debug minus sign
414
SpriteFrame(8, 0, 8, 8, 136, 64) // 35/41 - Small debug plus sign
415
SpriteFrame(0, 0, 8, 8, 145, 64) // 36/42 - Red "X" debug icon
416
SpriteFrame(0, 0, 8, 8, 154, 64) // 37/43 - Red "Y" debug icon
417
418
#platform: USE_ORIGINS
419
SpriteFrame(0, 0, 16, 16, 199, 141) // XX/44 - Coins life icon
420
SpriteFrame(0, 0, 39, 7, 182, 158) // XX/45 - Coins name tag
421
#endplatform
422
423
foreach (TypeName[HUD], arrayPos0, ALL_ENTITIES)
424
if engine.deviceType == STANDARD
425
object[arrayPos0].drawFunction = HUD_Draw_Standard
426
else
427
object[arrayPos0].drawFunction = HUD_Draw_Mobile
428
end if
429
next
430
end event
431
432
433
// ========================
434
// Editor Events
435
// ========================
436
437
event RSDKDraw
438
DrawSprite(0)
439
end event
440
441
442
event RSDKLoad
443
LoadSpriteSheet("Global/Display.gif")
444
SpriteFrame(0, 0, 39, 43, 1, 1)
445
446
// Strangely enough, this does get set in Stage Setup
447
// It's just an old leftover behaviour from CD, though, and has no real effect on anything
448
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
449
end event
450
451