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/Special/TextMessage.txt
1478 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Text Message 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.timer
13
private alias object.value1 : object.textMessage
14
private alias object.value2 : object.charPos.x
15
private alias object.value3 : object.messageLength
16
private alias object.value4 : object.number
17
private alias object.value5 : object.angleOffset
18
private alias object.value6 : object.scaleSpeed
19
private alias object.value7 : object.rotateSpeed
20
private alias object.value8 : object.spinDirection
21
22
// Property Values
23
private alias 0 : TEXTMESSAGE_COOL
24
private alias 1 : TEXTMESSAGE_NOTENOUGH
25
private alias 2 : TEXTMESSAGE_GETRINGS
26
private alias 3 : TEXTMESSAGE_RINGREMINDER
27
private alias 4 : TEXTMESSAGE_PLAYERPLAYER
28
private alias 5 : TEXTMESSAGE_MOSTRINGSWIN
29
private alias 6 : TEXTMESSAGE_P1WINS
30
private alias 7 : TEXTMESSAGE_P2WINS
31
private alias 8 : TEXTMESSAGE_TIE
32
private alias 9 : TEXTMESSAGE_ANICHARACTER
33
34
// Messages
35
private alias 0 : MESSAGE_COOL
36
private alias 1 : MESSAGE_NOTENOUGH
37
private alias 2 : MESSAGE_RINGS
38
private alias 3 : MESSAGE_GETRINGS1
39
private alias 4 : MESSAGE_GETRINGS2
40
private alias 5 : MESSAGE_GETRINGS3
41
private alias 6 : MESSAGE_RINGTOGO
42
private alias 7 : MESSAGE_RINGSTOGO1
43
private alias 8 : MESSAGE_RINGSTOGO2
44
private alias 9 : MESSAGE_RINGSTOGO3
45
private alias 10 : MESSAGE_PLAYERPLAYER
46
private alias 11 : MESSAGE_MOSTRINGSWINS
47
private alias 12 : MESSAGE_P1WINS
48
private alias 13 : MESSAGE_P2WINS
49
private alias 14 : MESSAGE_TIE
50
51
// Player Aliases
52
private alias object.value0 : player.rings
53
54
// Text Menu Info Type Aliases
55
private alias 0 : TEXTINFO_TEXTDATA
56
private alias 1 : TEXTINFO_TEXTSIZE
57
58
59
// ========================
60
// Function Declarations
61
// ========================
62
63
reserve function TextMessage_DrawMessage
64
reserve function TextMessage_SetupTextChars
65
66
67
// ========================
68
// Function Definitions
69
// ========================
70
71
private function TextMessage_DrawMessage
72
// This function is called to *draw* a line of text
73
74
GetTextInfo(object.messageLength, MENU_1, TEXTINFO_TEXTSIZE, object.textMessage, 0)
75
76
object.charPos.x = object.messageLength
77
object.charPos.x <<= 2
78
FlipSign(object.charPos.x)
79
object.charPos.x += screen.xcenter
80
object.charPos.x += 4
81
82
temp0 = 0
83
while object.messageLength > 0
84
GetTextInfo(temp1, MENU_1, TEXTINFO_TEXTDATA, object.textMessage, temp0)
85
switch temp1
86
case 33 // !
87
DrawSpriteScreenXY(37, object.charPos.x, object.ypos)
88
object.charPos.x += 8
89
break
90
91
case 35 // #
92
temp2 = object.number
93
temp2 /= 100
94
DrawSpriteScreenXY(temp2, object.charPos.x, object.ypos)
95
object.charPos.x += 8
96
break
97
98
case 36 // $
99
temp2 = object.number
100
temp2 %= 100
101
temp2 /= 10
102
DrawSpriteScreenXY(temp2, object.charPos.x, object.ypos)
103
object.charPos.x += 8
104
break
105
106
case 37 // %
107
temp2 = object.number
108
temp2 %= 10
109
DrawSpriteScreenXY(temp2, object.charPos.x, object.ypos)
110
object.charPos.x += 8
111
break
112
113
case 38 // &
114
DrawSpriteScreenXY(38, object.charPos.x, object.ypos)
115
object.charPos.x += 8
116
break
117
118
case 46 // .
119
DrawSpriteScreenXY(36, object.charPos.x, object.ypos)
120
object.charPos.x += 8
121
break
122
123
default
124
object.frame = 0
125
126
// Translate uppercase letters to Sprite Frames
127
if temp1 > 64
128
if temp1 < 91
129
object.frame = temp1
130
object.frame -= 55
131
end if
132
end if
133
134
// Translate lowercase letters to Sprite Frames
135
if temp1 > 96
136
if temp1 < 123
137
object.frame = temp1
138
object.frame -= 87
139
end if
140
end if
141
142
if object.frame > 0
143
DrawSpriteScreenXY(object.frame, object.charPos.x, object.ypos)
144
end if
145
146
object.charPos.x += 8
147
break
148
149
end switch
150
151
temp0++
152
object.messageLength--
153
loop
154
end function
155
156
157
private function TextMessage_SetupTextChars
158
// This function is called to create letter objects for every individual letter in a line, for when the message should separate and fall apart
159
// This is not to be confused with actually drawing the text normally, that's up above
160
161
GetTextInfo(object.messageLength, MENU_1, TEXTINFO_TEXTSIZE, object.textMessage, 0)
162
163
object.charPos.x = object.messageLength
164
object.charPos.x <<= 2
165
FlipSign(object.charPos.x)
166
object.charPos.x += 4
167
object.charPos.x <<= 16
168
169
temp0 = 0
170
temp3 = object.ypos
171
temp3 <<= 16
172
object.angleOffset = 224
173
object.angleOffset /= object.messageLength
174
while object.messageLength > 0
175
GetTextInfo(temp1, MENU_1, TEXTINFO_TEXTDATA, object.textMessage, temp0)
176
object.frame = 255
177
178
switch temp1
179
case 33 // !
180
object.frame = 37
181
break
182
183
case 35 // #
184
temp2 = object.number
185
temp2 /= 100
186
object.frame = temp2
187
break
188
189
case 36 // $
190
temp2 = object.number
191
temp2 %= 100
192
temp2 /= 10
193
object.frame = temp2
194
break
195
196
case 37 // %
197
temp2 = object.number
198
temp2 %= 10
199
object.frame = temp2
200
break
201
202
case 38 // &
203
object.frame = 38
204
break
205
206
case 46 // .
207
object.frame = 36
208
break
209
210
default
211
if temp1 > 64
212
if temp1 < 91
213
object.frame = temp1
214
object.frame -= 55
215
end if
216
end if
217
218
if temp1 > 96
219
if temp1 < 123
220
object.frame = temp1
221
object.frame -= 87
222
end if
223
end if
224
break
225
226
end switch
227
228
if object.frame < 255
229
CreateTempObject(TypeName[Text Message], TEXTMESSAGE_ANICHARACTER, object.charPos.x, temp3)
230
#platform: USE_STANDALONE
231
object[tempObjectPos].drawOrder = 5
232
#endplatform
233
#platform: USE_ORIGINS
234
object[tempObjectPos].drawOrder = 6
235
#endplatform
236
object[tempObjectPos].frame = object.frame
237
238
if object.spinDirection == 0
239
object[tempObjectPos].angle = object.angle
240
else
241
object[tempObjectPos].angle = object.angle
242
FlipSign(object[tempObjectPos].angle)
243
object[tempObjectPos].angle += 0x100
244
object[tempObjectPos].angle &= 0x1FF
245
end if
246
247
object[tempObjectPos].speed = -0x10000
248
object[tempObjectPos].scaleSpeed = 16
249
Rand(object[tempObjectPos].rotateSpeed, 32)
250
object[tempObjectPos].rotateSpeed -= 16
251
end if
252
253
object.angle -= object.angleOffset
254
object.angle &= 0x1FF
255
object.charPos.x += 0x80000
256
temp0++
257
object.messageLength--
258
loop
259
end function
260
261
262
// ========================
263
// Events
264
// ========================
265
266
event ObjectUpdate
267
switch object.propertyValue
268
case TEXTMESSAGE_COOL
269
case TEXTMESSAGE_PLAYERPLAYER
270
if object.timer < 120
271
object.timer++
272
else
273
object.angle = 96
274
CallFunction(TextMessage_SetupTextChars)
275
ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, 0, 0)
276
end if
277
break
278
279
case TEXTMESSAGE_NOTENOUGH
280
if object.timer < 120
281
object.timer++
282
else
283
object.spinDirection = 0
284
object.textMessage = MESSAGE_NOTENOUGH
285
object.ypos = 116
286
object.angle = 96
287
CallFunction(TextMessage_SetupTextChars)
288
289
object.spinDirection = 1
290
object.ypos += 22
291
object.textMessage = MESSAGE_RINGS
292
object.angle = 96
293
CallFunction(TextMessage_SetupTextChars)
294
295
ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, 0, 0)
296
end if
297
break
298
299
case TEXTMESSAGE_GETRINGS
300
case TEXTMESSAGE_MOSTRINGSWIN
301
if object.timer < 90
302
object.timer++
303
else
304
object.angle = 96
305
CallFunction(TextMessage_SetupTextChars)
306
ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, 0, 0)
307
end if
308
break
309
310
case TEXTMESSAGE_RINGREMINDER
311
if stage.player2Enabled == true
312
temp0 = player[2].rings
313
temp0 += player[3].rings
314
else
315
temp0 = player[2].rings
316
end if
317
318
GetTableValue(temp1, SpecialSetup_checkpointID, SpecialSetup_ringCountTable)
319
if temp0 < temp1
320
object.animationTimer = 0
321
else
322
if object.animationTimer < 30
323
object.animationTimer++
324
end if
325
end if
326
327
CheckLower(temp0, temp1)
328
temp2 = checkResult
329
CheckLower(object.animationTimer, 30)
330
temp2 |= checkResult
331
if temp2 == true
332
GetBit(object.visible, object.timer, 2)
333
object.timer++
334
object.timer &= 7
335
object.number = temp1
336
object.number -= temp0
337
if object.number < 0
338
object.number = 0
339
end if
340
else
341
object.visible = false
342
end if
343
break
344
345
case TEXTMESSAGE_P1WINS
346
case TEXTMESSAGE_P2WINS
347
case TEXTMESSAGE_TIE
348
if object.timer < 90
349
object.timer++
350
else
351
object.angle = 96
352
CallFunction(TextMessage_SetupTextChars)
353
ResetObjectEntity(object.entityPos, TypeName[Blank Object], 0, 0, 0)
354
if SpecialSetup_checkpointID < 3
355
player[2].rings = 0
356
player[3].rings = 0
357
end if
358
end if
359
break
360
361
case TEXTMESSAGE_ANICHARACTER
362
object.xpos += object.xvel
363
object.ypos += object.yvel
364
object.scale += object.scaleSpeed
365
object.rotation += object.rotateSpeed
366
object.rotation &= 0x1FF
367
object.speed -= 0x8000
368
object.scaleSpeed++
369
370
Cos(object.yvel, object.angle)
371
object.yvel *= object.speed
372
object.yvel >>= 9
373
374
Sin(object.xvel, object.angle)
375
object.xvel *= object.speed
376
object.xvel >>= 9
377
378
if object.timer < 120
379
object.timer++
380
else
381
object.type = TypeName[Blank Object]
382
end if
383
break
384
385
end switch
386
end event
387
388
389
event ObjectDraw
390
switch object.propertyValue
391
case TEXTMESSAGE_COOL
392
object.ypos = 116
393
object.textMessage = MESSAGE_COOL
394
CallFunction(TextMessage_DrawMessage)
395
break
396
397
case TEXTMESSAGE_NOTENOUGH
398
object.textMessage = MESSAGE_NOTENOUGH
399
object.ypos = 116
400
CallFunction(TextMessage_DrawMessage)
401
402
object.ypos += 22
403
object.textMessage = MESSAGE_RINGS
404
CallFunction(TextMessage_DrawMessage)
405
break
406
407
case TEXTMESSAGE_GETRINGS
408
object.ypos = 116
409
if object.number > 99
410
object.textMessage = MESSAGE_GETRINGS3
411
CallFunction(TextMessage_DrawMessage)
412
else
413
if object.number > 9
414
object.textMessage = MESSAGE_GETRINGS2
415
CallFunction(TextMessage_DrawMessage)
416
else
417
object.textMessage = MESSAGE_GETRINGS1
418
CallFunction(TextMessage_DrawMessage)
419
end if
420
end if
421
break
422
423
case TEXTMESSAGE_RINGREMINDER
424
if object.visible == true
425
object.ypos = 64
426
if object.number > 99
427
object.textMessage = MESSAGE_RINGSTOGO3
428
CallFunction(TextMessage_DrawMessage)
429
else
430
if object.number > 9
431
object.textMessage = MESSAGE_RINGSTOGO2
432
CallFunction(TextMessage_DrawMessage)
433
else
434
if object.number == 1
435
object.textMessage = MESSAGE_RINGTOGO
436
CallFunction(TextMessage_DrawMessage)
437
else
438
object.textMessage = MESSAGE_RINGSTOGO1
439
CallFunction(TextMessage_DrawMessage)
440
end if
441
end if
442
end if
443
end if
444
break
445
446
case TEXTMESSAGE_PLAYERPLAYER
447
object.ypos = 116
448
object.textMessage = MESSAGE_PLAYERPLAYER
449
CallFunction(TextMessage_DrawMessage)
450
break
451
452
case TEXTMESSAGE_MOSTRINGSWIN
453
object.ypos = 116
454
object.textMessage = MESSAGE_MOSTRINGSWINS
455
CallFunction(TextMessage_DrawMessage)
456
break
457
458
case TEXTMESSAGE_P1WINS
459
object.ypos = 116
460
object.textMessage = MESSAGE_P1WINS
461
CallFunction(TextMessage_DrawMessage)
462
break
463
464
case TEXTMESSAGE_P2WINS
465
object.ypos = 116
466
object.textMessage = MESSAGE_P2WINS
467
CallFunction(TextMessage_DrawMessage)
468
break
469
470
case TEXTMESSAGE_TIE
471
object.ypos = 68
472
object.textMessage = MESSAGE_TIE
473
CallFunction(TextMessage_DrawMessage)
474
break
475
476
case TEXTMESSAGE_ANICHARACTER
477
temp0 = object.xpos
478
temp0 >>= 16
479
temp0 += screen.xcenter
480
481
temp1 = object.ypos
482
temp1 >>= 16
483
484
DrawSpriteScreenFX(object.frame, FX_ROTOZOOM, temp0, temp1)
485
break
486
487
end switch
488
end event
489
490
491
event ObjectStartup
492
LoadSpriteSheet("Special/Objects.gif")
493
494
// Here, we set up just about an entire font in Sprite Frames
495
SpriteFrame(-4, -8, 8, 15, 291, 42) // 0
496
SpriteFrame(-4, -8, 8, 15, 300, 42) // 1
497
SpriteFrame(-4, -8, 8, 15, 309, 42) // 2
498
SpriteFrame(-4, -8, 8, 15, 318, 42) // 3
499
SpriteFrame(-4, -8, 8, 15, 327, 42) // 4
500
SpriteFrame(-4, -8, 8, 15, 336, 42) // 5
501
SpriteFrame(-4, -8, 8, 15, 345, 42) // 6
502
SpriteFrame(-4, -8, 8, 15, 354, 42) // 7
503
SpriteFrame(-4, -8, 8, 15, 363, 42) // 8
504
SpriteFrame(-4, -8, 8, 15, 372, 42) // 9
505
SpriteFrame(-4, -8, 8, 15, 291, 26) // A
506
SpriteFrame(-4, -8, 8, 15, 300, 26) // B
507
SpriteFrame(-4, -8, 8, 15, 309, 26) // C
508
SpriteFrame(-4, -8, 8, 15, 318, 26) // D
509
SpriteFrame(-4, -8, 8, 15, 327, 26) // E
510
SpriteFrame(-4, -8, 8, 15, 336, 26) // F
511
SpriteFrame(-4, -8, 8, 15, 345, 26) // G
512
SpriteFrame(-4, -8, 8, 15, 354, 26) // H
513
SpriteFrame(-4, -8, 8, 15, 363, 26) // I
514
SpriteFrame(-4, -8, 8, 15, 372, 26) // J
515
SpriteFrame(-4, -8, 8, 15, 381, 26) // K
516
SpriteFrame(-4, -8, 8, 15, 390, 26) // L
517
SpriteFrame(-4, -8, 8, 15, 399, 26) // M
518
SpriteFrame(-4, -8, 8, 15, 408, 26) // N
519
SpriteFrame(-4, -8, 8, 15, 417, 26) // O
520
SpriteFrame(-4, -8, 8, 15, 426, 26) // P
521
SpriteFrame(-4, -8, 8, 15, 435, 26) // Q
522
SpriteFrame(-4, -8, 8, 15, 444, 26) // R
523
SpriteFrame(-4, -8, 8, 15, 453, 26) // S
524
SpriteFrame(-4, -8, 8, 15, 462, 26) // T
525
SpriteFrame(-4, -8, 8, 15, 471, 26) // U
526
SpriteFrame(-4, -8, 8, 15, 480, 26) // Supposed to be V, actually placeholder dash instead
527
SpriteFrame(-4, -8, 8, 15, 381, 42) // W
528
SpriteFrame(-4, -8, 8, 15, 390, 42) // Supposed to be X, actually placeholder dash instead
529
SpriteFrame(-4, -8, 8, 15, 399, 42) // Y
530
SpriteFrame(-4, -8, 8, 15, 408, 42) // Supposed to be Z, actually placeholder dash instead
531
SpriteFrame(-4, -8, 8, 15, 489, 26) // . (Period)
532
SpriteFrame(-4, -8, 8, 15, 498, 26) // ! (Exclamation mark)
533
SpriteFrame(-12, -8, 24, 15, 417, 42) // VS yellow tag
534
535
SetupMenu(MENU_1, 0, 3, 1)
536
537
// Here, all the texts to be displayed are set up
538
// The characters of #, $, and % are special, they display object.number's hundreds, tens, and ones place, respectively
539
AddMenuEntry(MENU_1, "COOL!", false)
540
AddMenuEntry(MENU_1, "NOT ENOUGH", false)
541
AddMenuEntry(MENU_1, "RINGS ... ", false)
542
AddMenuEntry(MENU_1, "GET % RINGS!", false)
543
AddMenuEntry(MENU_1, "GET $% RINGS!", false)
544
AddMenuEntry(MENU_1, "GET #$% RINGS!", false)
545
AddMenuEntry(MENU_1, "% RING TO GO!", false)
546
AddMenuEntry(MENU_1, "% RINGS TO GO!", false)
547
AddMenuEntry(MENU_1, "$% RINGS TO GO!", false)
548
AddMenuEntry(MENU_1, "#$% RINGS TO GO!", false)
549
AddMenuEntry(MENU_1, "PLAYER & PLAYER", false)
550
AddMenuEntry(MENU_1, "MOST RINGS WINS!", false)
551
AddMenuEntry(MENU_1, "PLAYER ONE WINS!", false)
552
AddMenuEntry(MENU_1, "PLAYER TWO WINS!", false)
553
AddMenuEntry(MENU_1, "TIE!", false)
554
end event
555
556
557
// ========================
558
// Editor Events
559
// ========================
560
561
event RSDKDraw
562
DrawSprite(0)
563
end event
564
565
566
event RSDKLoad
567
LoadSpriteSheet("Global/Display.gif")
568
SpriteFrame(-16, -16, 32, 32, 1, 143)
569
570
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
571
end event
572
573