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/Halfpipe.txt
1483 views
1
// ----------------------------------
2
// RSDK Project: Sonic 2
3
// Script Description: Halfpipe 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.value1 : object.moveStep
13
private alias object.value2 : object.transformIDHalfpipe
14
private alias object.value3 : object.nextTransformIDHalfpipe
15
private alias object.value4 : object.halfpipeTranslation.x
16
private alias object.value5 : object.halfpipeTranslation.y
17
private alias object.value6 : object.halfpipeTranslation.z
18
private alias object.value7 : object.halfpipeRotation.x
19
private alias object.value8 : object.halfpipeRotation.y
20
private alias object.value9 : object.halfpipeRotation.z
21
private alias object.value10 : object.newHalfpipeRotation.x
22
private alias object.value11 : object.newHalfpipeRotation.y
23
private alias object.value12 : object.newHalfpipeRotation.z
24
private alias object.value13 : object.playerPos.z
25
private alias object.value14 : object.worldTranslation.x
26
private alias object.value15 : object.worldTranslation.y
27
private alias object.value16 : object.worldTranslation.z
28
private alias object.value17 : object.worldRotation.x
29
private alias object.value18 : object.worldRotation.y
30
private alias object.value19 : object.worldRotation.z
31
private alias object.value20 : object.transformIDWorld
32
private alias object.value21 : object.nextTransformIDWorld
33
private alias object.value22 : object.localPos.z
34
private alias object.value23 : object.moveSpeed
35
36
// Stage Object Aliases
37
// value0 isn't used here
38
private alias object.value1 : stageObject.localPos.x
39
private alias object.value2 : stageObject.localPos.y
40
private alias object.value3 : stageObject.localPos.z
41
private alias object.value4 : stageObject.worldPos.x
42
private alias object.value5 : stageObject.worldPos.y
43
private alias object.value6 : stageObject.worldPos.z
44
45
private alias object.value7 : stageObject.shadowsEnabled
46
private alias object.value8 : stageObject.localShadowPos.x
47
private alias object.value9 : stageObject.localShadowPos.y
48
// value10 isn't used here
49
private alias object.value11 : stageObject.worldShadowPos.x
50
private alias object.value12 : stageObject.worldShadowPos.y
51
private alias object.value13 : stageObject.worldShadowPos.z
52
private alias object.value14 : stageObject.worldShadowPos.u
53
54
// Player Aliases
55
private alias object.xpos : player.xpos
56
private alias object.ypos : player.ypos
57
58
// Tile Flag Aliases
59
private alias 1 : TILE_ENDMARKER
60
61
// Tile Info ID Aliases
62
private alias 6 : TILEINFO_ANGLEA
63
64
// Face Buffer Flag Aliases
65
private alias 4 : FACE_FADED
66
private alias 5 : FACE_TEXTURED_C
67
68
69
// ========================
70
// Function Declarations
71
// ========================
72
73
reserve function Halfpipe_SetupVertices
74
reserve function Halfpipe_SetupFaces
75
76
77
// ========================
78
// Static Values
79
// ========================
80
81
private value Halfpipe_vertexInfoTable = 0
82
private value Halfpipe_vertexCount = 0
83
private value Halfpipe_faceInfoTable = 0
84
private value Halfpipe_vertexTableID = 0
85
private value Halfpipe_prevVertexCount = 0
86
private value Halfpipe_faceCount = 0
87
private value Halfpipe_rotateOffset.x = 0
88
private value Halfpipe_rotateOffset.y = 0
89
private value Halfpipe_rotateOffset.z = 0
90
private value Halfpipe_tempTranslate.x = 0
91
private value Halfpipe_tempTranslate.y = 0
92
private value Halfpipe_tempTranslate.z = 0
93
private value Halfpipe_worldRotate.x = 0
94
private value Halfpipe_worldRotate.y = 0
95
private value Halfpipe_worldRotate.z = 0
96
private value Halfpipe_transformPos = 0
97
private value Halfpipe_checkpointTexCount = 0
98
99
100
// ========================
101
// Tables
102
// ========================
103
104
private table Halfpipe_translateXTable[40]
105
private table Halfpipe_translateYTable[40]
106
private table Halfpipe_translateZTable[40]
107
108
private table Halfpipe_rotateXTable[40]
109
private table Halfpipe_rotateYTable[40]
110
private table Halfpipe_rotateZTable[40]
111
112
public table Halfpipe_checkpointFaceTable[4]
113
114
private table Halfpipe_vertexOffsetTable
115
19, 19, 19, 19, 17, 17, 45, 17
116
end table
117
118
// These values correspond to tile angles in the scene
119
// (Do note, TILE_ENDMARKER is separate from these, even if it has a numerical angle value of 1)
120
private table Halfpipe_matTransformTable
121
0
122
2, 4, 6, 8, 10, 12, 14, 16
123
-2, -4, -6, -8, -10, -12, -14, -16
124
end table
125
126
private table Halfpipe_vertexTablePtrs[8]
127
128
private table Halfpipe_vertexTable1
129
38
130
-0x4000, 0x1100, 0x0000
131
-0x4400, 0xD00, 0x0000
132
-0x3C00, 0xD00, 0x0000
133
-0x4000, 0x900, 0x0000
134
-0x4000, -0x91C, 0x0000
135
-0x3A37, -0x1A96, 0x0000
136
-0x305E, -0x29E9, 0x0000
137
-0x2298, -0x35D7, 0x0000
138
-0x1208, -0x3D68, 0x0000
139
0x0000, -0x4000, 0x0000
140
0x1208, -0x3D68, 0x0000
141
0x2298, -0x35D7, 0x0000
142
0x305E, -0x29E9, 0x0000
143
0x3A37, -0x1A96, 0x0000
144
0x4000, -0x91C, 0x0000
145
0x4000, 0x900, 0x0000
146
0x4000, 0x1100, 0x0000
147
0x3C00, 0xD00, 0x0000
148
0x4400, 0xD00, 0x0000
149
-0x4000, 0x1100, 0x0000
150
-0x4400, 0xD00, 0x0000
151
-0x3C00, 0xD00, 0x0000
152
-0x4000, 0x900, 0x0000
153
-0x4000, -0x91C, 0x0000
154
-0x3A37, -0x1A96, 0x0000
155
-0x305E, -0x29E9, 0x0000
156
-0x2298, -0x35D7, 0x0000
157
-0x1208, -0x3D68, 0x0000
158
0x0000, -0x4000, 0x0000
159
0x1208, -0x3D68, 0x0000
160
0x2298, -0x35D7, 0x0000
161
0x305E, -0x29E9, 0x0000
162
0x3A37, -0x1A96, 0x0000
163
0x4000, -0x91C, 0x0000
164
0x4000, 0x900, 0x0000
165
0x4000, 0x1100, 0x0000
166
0x3C00, 0xD00, 0x0000
167
0x4400, 0xD00, 0x0000
168
end table
169
170
private table Halfpipe_faceTable1
171
22
172
0, 1, 3, 2, 3
173
0, 1, 20, 19, 2
174
0, 2, 21, 19, 2
175
1, 20, 22, 3, 2
176
2, 21, 22, 3, 2
177
3, 22, 23, 4, 1
178
4, 23, 24, 5, 0
179
5, 24, 25, 6, 0
180
6, 25, 26, 7, 0
181
7, 26, 27, 8, 1
182
8, 27, 28, 9, 0
183
9, 28, 29, 10, 0
184
10, 29, 30, 11, 1
185
11, 30, 31, 12, 0
186
12, 31, 32, 13, 0
187
13, 32, 33, 14, 0
188
14, 33, 34, 15, 1
189
16, 17, 15, 18, 3
190
16, 35, 36, 17, 2
191
17, 36, 15, 34, 2
192
16, 35, 37, 18, 2
193
18, 37, 34, 15, 2
194
end table
195
196
private table Halfpipe_faceTable2
197
20
198
0, 1, 20, 19, 2
199
0, 2, 21, 19, 2
200
1, 20, 22, 3, 2
201
2, 21, 22, 3, 2
202
3, 22, 23, 4, 1
203
4, 23, 24, 5, 0
204
5, 24, 25, 6, 0
205
6, 25, 26, 7, 0
206
7, 26, 27, 8, 1
207
8, 27, 28, 9, 0
208
9, 28, 29, 10, 0
209
10, 29, 30, 11, 1
210
11, 30, 31, 12, 0
211
12, 31, 32, 13, 0
212
13, 32, 33, 14, 0
213
14, 33, 34, 15, 1
214
16, 35, 36, 17, 2
215
17, 36, 15, 34, 2
216
16, 35, 37, 18, 2
217
18, 37, 34, 15, 2
218
end table
219
220
private table Halfpipe_vertexTable2
221
34
222
-0x4000, 0x900, 0x0000
223
-0x4000, -0x91C, 0x0000
224
-0x3A37, -0x1A96, 0x0000
225
-0x305E, -0x29E9, 0x0000
226
-0x2298, -0x35D7, 0x0000
227
-0x2059, -0x36DE, 0x0000
228
-0x1449, -0x3C5D, 0x0000
229
-0x1208, -0x3D68, 0x0000
230
0x0000, -0x4000, 0x0000
231
0x1208, -0x3D68, 0x0000
232
0x1449, -0x3C5D, 0x0000
233
0x2059, -0x36DE, 0x0000
234
0x2298, -0x35D7, 0x0000
235
0x305E, -0x29E9, 0x0000
236
0x3A37, -0x1A96, 0x0000
237
0x4000, -0x91C, 0x0000
238
0x4000, 0x900, 0x0000
239
-0x4000, 0x900, 0x0000
240
-0x4000, -0x91C, 0x0000
241
-0x3A37, -0x1A96, 0x0000
242
-0x305E, -0x29E9, 0x0000
243
-0x2298, -0x35D7, 0x0000
244
-0x1ED7, -0x378F, 0x0000
245
-0x15CB, -0x3BAF, 0x0000
246
-0x1208, -0x3D68, 0x0000
247
0x0000, -0x4000, 0x0000
248
0x1208, -0x3D68, 0x0000
249
0x15CB, -0x3BAF, 0x0000
250
0x1ED7, -0x378F, 0x0000
251
0x2298, -0x35D7, 0x0000
252
0x305E, -0x29E9, 0x0000
253
0x3A37, -0x1A96, 0x0000
254
0x4000, -0x91C, 0x0000
255
0x4000, 0x900, 0x0000
256
end table
257
258
private table Halfpipe_faceTable3
259
16
260
0, 17, 18, 1, 1
261
1, 18, 19, 2, 0
262
2, 19, 20, 3, 0
263
3, 20, 21, 4, 0
264
4, 21, 22, 5, 1
265
5, 22, 23, 6, 2
266
6, 23, 24, 7, 1
267
7, 24, 25, 8, 0
268
8, 25, 26, 9, 0
269
9, 26, 27, 10, 1
270
10, 27, 28, 11, 2
271
11, 28, 29, 12, 1
272
12, 29, 30, 13, 0
273
13, 30, 31, 14, 0
274
14, 31, 32, 15, 0
275
15, 32, 33, 16, 1
276
end table
277
278
private table Halfpipe_vertexTable3
279
51
280
-0x4000, 0x900, 0x0000
281
-0x4000, -0x91C, 0x0000
282
-0x3A37, -0x1A96, 0x0000
283
-0x305E, -0x29E9, 0x0000
284
-0x2298, -0x35D7, 0x0000
285
-0x1ED7, -0x378F, 0x0000
286
-0x15CB, -0x3BAF, 0x0000
287
-0x1208, -0x3D68, 0x0000
288
0x0000, -0x4000, 0x0000
289
0x1208, -0x3D68, 0x0000
290
0x15CB, -0x3BAF, 0x0000
291
0x1ED7, -0x378F, 0x0000
292
0x2298, -0x35D7, 0x0000
293
0x305E, -0x29E9, 0x0000
294
0x3A37, -0x1A96, 0x0000
295
0x4000, -0x91C, 0x0000
296
0x4000, 0x900, 0x0000
297
-0x4000, 0x900, 0x0000
298
-0x4000, -0x91C, 0x0000
299
-0x3A37, -0x1A96, 0x0000
300
-0x305E, -0x29E9, 0x0000
301
-0x2298, -0x35D7, 0x0000
302
-0x1E46, -0x37D1, 0x0000
303
-0x165C, -0x3B6D, 0x0000
304
-0x1208, -0x3D68, 0x0000
305
0x0000, -0x4000, 0x0000
306
0x1208, -0x3D68, 0x0000
307
0x165C, -0x3B6D, 0x0000
308
0x1E46, -0x37D1, 0x0000
309
0x2298, -0x35D7, 0x0000
310
0x305E, -0x29E9, 0x0000
311
0x3A37, -0x1A96, 0x0000
312
0x4000, -0x91C, 0x0000
313
0x4000, 0x900, 0x0000
314
-0x4000, 0x900, 0x0000
315
-0x4000, -0x91C, 0x0000
316
-0x3A37, -0x1A96, 0x0000
317
-0x305E, -0x29E9, 0x0000
318
-0x2298, -0x35D7, 0x0000
319
-0x1D55, -0x383F, 0x0000
320
-0x174D, -0x3AFF, 0x0000
321
-0x1208, -0x3D68, 0x0000
322
0x0000, -0x4000, 0x0000
323
0x1208, -0x3D68, 0x0000
324
0x174D, -0x3AFF, 0x0000
325
0x1D55, -0x383F, 0x0000
326
0x2298, -0x35D7, 0x0000
327
0x305E, -0x29E9, 0x0000
328
0x3A37, -0x1A96, 0x0000
329
0x4000, -0x91C, 0x0000
330
0x4000, 0x900, 0x0000
331
end table
332
333
private table Halfpipe_faceTable4
334
32
335
0, 17, 18, 1, 1
336
1, 18, 19, 2, 0
337
2, 19, 20, 3, 0
338
3, 20, 21, 4, 0
339
4, 21, 22, 5, 1
340
5, 22, 23, 6, 2
341
6, 23, 24, 7, 1
342
7, 24, 25, 8, 0
343
8, 25, 26, 9, 0
344
9, 26, 27, 10, 1
345
10, 27, 28, 11, 2
346
11, 28, 29, 12, 1
347
12, 29, 30, 13, 0
348
13, 30, 31, 14, 0
349
14, 31, 32, 15, 0
350
15, 32, 33, 16, 1
351
17, 34, 35, 18, 1
352
18, 35, 36, 19, 1
353
19, 36, 37, 20, 1
354
20, 37, 38, 21, 1
355
21, 38, 39, 22, 1
356
22, 39, 40, 23, 2
357
23, 40, 41, 24, 1
358
24, 41, 42, 25, 1
359
25, 42, 43, 26, 1
360
26, 43, 44, 27, 1
361
27, 44, 45, 28, 2
362
28, 45, 46, 29, 1
363
29, 46, 47, 30, 1
364
30, 47, 48, 31, 1
365
31, 48, 49, 32, 1
366
32, 49, 50, 33, 1
367
end table
368
369
private table Halfpipe_vertexTable4
370
79
371
-0x3800, 0xA00, 0x0000
372
-0x3800, 0xA00, 0x0000
373
-0x3800, 0xA00, 0x0000
374
-0x3800, 0xA00, 0x0000
375
-0x2E00, 0x2400, 0x0000
376
-0x2E00, 0x2400, 0x0000
377
-0x2E00, 0x2400, 0x0000
378
-0x2E00, 0x2400, 0x0000
379
-0x1A00, 0x3600, 0x0000
380
-0x1A00, 0x3600, 0x0000
381
-0x1A00, 0x3600, 0x0000
382
-0x1A00, 0x3600, 0x0000
383
0x0000, 0x4000, 0x0000
384
0x0000, 0x4000, 0x0000
385
0x0000, 0x4000, 0x0000
386
0x0000, 0x4000, 0x0000
387
0x1A00, 0x3600, 0x0000
388
0x1A00, 0x3600, 0x0000
389
0x1A00, 0x3600, 0x0000
390
0x1A00, 0x3600, 0x0000
391
0x2E00, 0x2400, 0x0000
392
0x2E00, 0x2400, 0x0000
393
0x2E00, 0x2400, 0x0000
394
0x2E00, 0x2400, 0x0000
395
0x3800, 0xA00, 0x0000
396
0x3800, 0xA00, 0x0000
397
0x3800, 0xA00, 0x0000
398
0x3800, 0xA00, 0x0000
399
-0x4000, 0x900, 0x0000
400
-0x4000, -0x91C, 0x0000
401
-0x3A37, -0x1A96, 0x0000
402
-0x305E, -0x29E9, 0x0000
403
-0x2298, -0x35D7, 0x0000
404
-0x1D55, -0x383F, 0x0000
405
-0x174D, -0x3AFF, 0x0000
406
-0x1208, -0x3D68, 0x0000
407
0x0000, -0x4000, 0x0000
408
0x1208, -0x3D68, 0x0000
409
0x174D, -0x3AFF, 0x0000
410
0x1D55, -0x383F, 0x0000
411
0x2298, -0x35D7, 0x0000
412
0x305E, -0x29E9, 0x0000
413
0x3A37, -0x1A96, 0x0000
414
0x4000, -0x91C, 0x0000
415
0x4000, 0x900, 0x0000
416
-0x4000, 0x900, 0x0000
417
-0x4000, -0x91C, 0x0000
418
-0x3A37, -0x1A96, 0x0000
419
-0x305E, -0x29E9, 0x0000
420
-0x2298, -0x35D7, 0x0000
421
-0x1C64, -0x38AD, 0x0000
422
-0x183E, -0x3A91, 0x0000
423
-0x1208, -0x3D68, 0x0000
424
0x0000, -0x4000, 0x0000
425
0x1208, -0x3D68, 0x0000
426
0x183E, -0x3A91, 0x0000
427
0x1C64, -0x38AD, 0x0000
428
0x2298, -0x35D7, 0x0000
429
0x305E, -0x29E9, 0x0000
430
0x3A37, -0x1A96, 0x0000
431
0x4000, -0x91C, 0x0000
432
0x4000, 0x900, 0x0000
433
-0x4000, 0x900, 0x0000
434
-0x4000, -0x91C, 0x0000
435
-0x3A37, -0x1A96, 0x0000
436
-0x305E, -0x29E9, 0x0000
437
-0x2298, -0x35D7, 0x0000
438
-0x1BD3, -0x38EF, 0x0000
439
-0x18CF, -0x3A50, 0x0000
440
-0x1208, -0x3D68, 0x0000
441
0x0000, -0x4000, 0x0000
442
0x1208, -0x3D68, 0x0000
443
0x18CF, -0x3A50, 0x0000
444
0x1BD3, -0x38EF, 0x0000
445
0x2298, -0x35D7, 0x0000
446
0x305E, -0x29E9, 0x0000
447
0x3A37, -0x1A96, 0x0000
448
0x4000, -0x91C, 0x0000
449
0x4000, 0x900, 0x0000
450
end table
451
452
private table Halfpipe_faceTable5
453
39
454
0, 1, 2, 3, 5
455
4, 5, 6, 7, 5
456
8, 9, 10, 11, 5
457
12, 13, 14, 15, 5
458
16, 17, 18, 19, 5
459
20, 21, 22, 23, 5
460
24, 25, 26, 27, 5
461
28, 45, 46, 29, 1
462
29, 46, 47, 30, 1
463
30, 47, 48, 31, 1
464
31, 48, 49, 32, 1
465
32, 49, 50, 33, 1
466
33, 50, 51, 34, 2
467
34, 51, 52, 35, 1
468
35, 52, 53, 36, 1
469
36, 53, 54, 37, 1
470
37, 54, 55, 38, 1
471
38, 55, 56, 39, 2
472
39, 56, 57, 40, 1
473
40, 57, 58, 41, 1
474
41, 58, 59, 42, 1
475
42, 59, 60, 43, 1
476
43, 60, 61, 44, 1
477
45, 62, 63, 46, 1
478
46, 63, 64, 47, 0
479
47, 64, 65, 48, 0
480
48, 65, 66, 49, 0
481
49, 66, 67, 50, 1
482
50, 67, 68, 51, 2
483
51, 68, 69, 52, 1
484
52, 69, 70, 53, 0
485
53, 70, 71, 54, 0
486
54, 71, 72, 55, 1
487
55, 72, 73, 56, 2
488
56, 73, 74, 57, 1
489
57, 74, 75, 58, 0
490
58, 75, 76, 59, 0
491
59, 76, 77, 60, 0
492
60, 77, 78, 61, 1
493
end table
494
495
private table Halfpipe_vertexTable5
496
34
497
-0x4000, 0x900, 0x0000
498
-0x4000, -0x91C, 0x0000
499
-0x3A37, -0x1A96, 0x0000
500
-0x305E, -0x29E9, 0x0000
501
-0x2298, -0x35D7, 0x0000
502
-0x1BD3, -0x38EF, 0x0000
503
-0x18CF, -0x3A50, 0x0000
504
-0x1208, -0x3D68, 0x0000
505
0x0000, -0x4000, 0x0000
506
0x1208, -0x3D68, 0x0000
507
0x18CF, -0x3A50, 0x0000
508
0x1BD3, -0x38EF, 0x0000
509
0x2298, -0x35D7, 0x0000
510
0x305E, -0x29E9, 0x0000
511
0x3A37, -0x1A96, 0x0000
512
0x4000, -0x91C, 0x0000
513
0x4000, 0x900, 0x0000
514
-0x4000, 0x900, 0x0000
515
-0x4000, -0x91C, 0x0000
516
-0x3A37, -0x1A96, 0x0000
517
-0x305E, -0x29E9, 0x0000
518
-0x2298, -0x35D7, 0x0000
519
-0x1A51, -0x39A0, 0x0000
520
-0x1A51, -0x39A0, 0x0000
521
-0x1208, -0x3D68, 0x0000
522
0x0000, -0x4000, 0x0000
523
0x1208, -0x3D68, 0x0000
524
0x1A51, -0x39A0, 0x0000
525
0x1A51, -0x39A0, 0x0000
526
0x2298, -0x35D7, 0x0000
527
0x305E, -0x29E9, 0x0000
528
0x3A37, -0x1A96, 0x0000
529
0x4000, -0x91C, 0x0000
530
0x4000, 0x900, 0x0000
531
end table
532
533
private table Halfpipe_faceTable6
534
16
535
0, 17, 18, 1, 1
536
1, 18, 19, 2, 0
537
2, 19, 20, 3, 0
538
3, 20, 21, 4, 0
539
4, 21, 22, 5, 1
540
5, 22, 23, 6, 2
541
6, 23, 24, 7, 1
542
7, 24, 25, 8, 0
543
8, 25, 26, 9, 0
544
9, 26, 27, 10, 1
545
10, 27, 28, 11, 2
546
11, 28, 29, 12, 1
547
12, 29, 30, 13, 0
548
13, 30, 31, 14, 0
549
14, 31, 32, 15, 0
550
15, 32, 33, 16, 1
551
end table
552
553
554
// ========================
555
// Function Definitions
556
// ========================
557
558
private function Halfpipe_SetupVertices
559
temp1 = object[0].xpos
560
temp1 >>= 16
561
temp1 += 376
562
temp2 = object[0].ypos
563
temp2 >>= 16
564
565
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEA)
566
if temp0 == TILE_ENDMARKER
567
temp2 += 128
568
temp2 &= 0xFF80
569
object[0].iypos = temp2
570
end if
571
temp1 += 16
572
573
temp3 = Halfpipe_worldRotate.y
574
temp3 += 0x40
575
temp3 &= 0x1FF
576
temp3 >>= 7
577
switch temp3
578
case 0
579
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEA)
580
GetTableValue(Halfpipe_rotateOffset.x, temp0, Halfpipe_matTransformTable)
581
temp1 += 16
582
583
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEA)
584
GetTableValue(Halfpipe_rotateOffset.y, temp0, Halfpipe_matTransformTable)
585
temp1 += 16
586
587
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEA)
588
GetTableValue(Halfpipe_rotateOffset.z, temp0, Halfpipe_matTransformTable)
589
break
590
591
case 1
592
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEA)
593
GetTableValue(Halfpipe_rotateOffset.z, temp0, Halfpipe_matTransformTable)
594
temp1 += 16
595
596
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEA)
597
GetTableValue(Halfpipe_rotateOffset.y, temp0, Halfpipe_matTransformTable)
598
temp1 += 16
599
600
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEA)
601
GetTableValue(Halfpipe_rotateOffset.x, temp0, Halfpipe_matTransformTable)
602
break
603
604
case 2
605
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEA)
606
GetTableValue(Halfpipe_rotateOffset.x, temp0, Halfpipe_matTransformTable)
607
FlipSign(Halfpipe_rotateOffset.x)
608
temp1 += 16
609
610
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEA)
611
GetTableValue(Halfpipe_rotateOffset.y, temp0, Halfpipe_matTransformTable)
612
temp1 += 16
613
614
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEA)
615
GetTableValue(Halfpipe_rotateOffset.z, temp0, Halfpipe_matTransformTable)
616
FlipSign(Halfpipe_rotateOffset.z)
617
break
618
619
case 3
620
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEA)
621
GetTableValue(Halfpipe_rotateOffset.z, temp0, Halfpipe_matTransformTable)
622
FlipSign(Halfpipe_rotateOffset.z)
623
temp1 += 16
624
625
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEA)
626
GetTableValue(Halfpipe_rotateOffset.y, temp0, Halfpipe_matTransformTable)
627
temp1 += 16
628
629
Get16x16TileInfo(temp0, temp1, temp2, TILEINFO_ANGLEA)
630
GetTableValue(Halfpipe_rotateOffset.x, temp0, Halfpipe_matTransformTable)
631
FlipSign(Halfpipe_rotateOffset.x)
632
break
633
634
end switch
635
636
temp0 = stage.curYBoundary2
637
temp0 <<= 16
638
639
object[0].ypos += 0x80000
640
if object[0].ypos >= temp0
641
object[0].ypos -= temp0
642
end if
643
644
object[0].localPos.z += 0x80000
645
if object[0].localPos.z >= temp0
646
object[0].localPos.z -= temp0
647
end if
648
649
MatrixRotateXYZ(MAT_WORLD, Halfpipe_worldRotate.x, Halfpipe_worldRotate.y, Halfpipe_worldRotate.z)
650
MatrixTranslateXYZ(MAT_TEMP, Halfpipe_tempTranslate.x, Halfpipe_tempTranslate.y, Halfpipe_tempTranslate.z)
651
MatrixMultiply(MAT_WORLD, MAT_TEMP)
652
653
temp0 = true
654
while temp0 == true
655
if object[arrayPos5].ypos < object[0].ypos
656
object[arrayPos5].priority = PRIORITY_ACTIVE
657
if stageObject[arrayPos5].shadowsEnabled == true
658
vertexBuffer[4094].x = stageObject[arrayPos5].localPos.x
659
vertexBuffer[4094].y = stageObject[arrayPos5].localPos.y
660
vertexBuffer[4094].z = 0
661
vertexBuffer[4095].x = stageObject[arrayPos5].localShadowPos.x
662
vertexBuffer[4095].y = stageObject[arrayPos5].localShadowPos.y
663
vertexBuffer[4095].z = 0
664
TransformVertices(MAT_WORLD, 0xFFE, 0x1000)
665
666
stageObject[arrayPos5].localPos.z = object[0].localPos.z
667
stageObject[arrayPos5].worldPos.x = vertexBuffer[4094].x
668
stageObject[arrayPos5].worldPos.y = vertexBuffer[4094].y
669
stageObject[arrayPos5].worldPos.z = vertexBuffer[4094].z
670
stageObject[arrayPos5].worldShadowPos.x = vertexBuffer[4095].x
671
stageObject[arrayPos5].worldShadowPos.y = vertexBuffer[4095].y
672
stageObject[arrayPos5].worldShadowPos.z = vertexBuffer[4095].z
673
else
674
vertexBuffer[4095].x = stageObject[arrayPos5].localPos.x
675
vertexBuffer[4095].y = stageObject[arrayPos5].localPos.y
676
vertexBuffer[4095].z = 0
677
TransformVertices(MAT_WORLD, 0xFFF, 0x1000)
678
679
stageObject[arrayPos5].localPos.z = object[0].localPos.z
680
stageObject[arrayPos5].worldPos.x = vertexBuffer[4095].x
681
stageObject[arrayPos5].worldPos.y = vertexBuffer[4095].y
682
stageObject[arrayPos5].worldPos.z = vertexBuffer[4095].z
683
end if
684
685
arrayPos5++
686
else
687
temp0 = false
688
end if
689
loop
690
691
temp2 = Halfpipe_vertexTableID
692
temp2 &= 7
693
GetTableValue(Halfpipe_vertexInfoTable, temp2, Halfpipe_vertexTablePtrs)
694
Halfpipe_vertexTableID++
695
696
temp0 = 0
697
arrayPos0 = Halfpipe_vertexCount
698
GetTableValue(temp1, temp0, Halfpipe_vertexInfoTable)
699
temp0++
700
while temp1 > 0
701
GetTableValue(vertexBuffer[arrayPos0].x, temp0, Halfpipe_vertexInfoTable)
702
temp0++
703
GetTableValue(vertexBuffer[arrayPos0].y, temp0, Halfpipe_vertexInfoTable)
704
temp0++
705
GetTableValue(vertexBuffer[arrayPos0].z, temp0, Halfpipe_vertexInfoTable)
706
temp0++
707
arrayPos0++
708
temp1--
709
loop
710
711
SetTableValue(Halfpipe_tempTranslate.x, Halfpipe_transformPos, Halfpipe_translateXTable)
712
SetTableValue(Halfpipe_tempTranslate.y, Halfpipe_transformPos, Halfpipe_translateYTable)
713
SetTableValue(Halfpipe_tempTranslate.z, Halfpipe_transformPos, Halfpipe_translateZTable)
714
SetTableValue(Halfpipe_worldRotate.x, Halfpipe_transformPos, Halfpipe_rotateXTable)
715
SetTableValue(Halfpipe_worldRotate.y, Halfpipe_transformPos, Halfpipe_rotateYTable)
716
SetTableValue(Halfpipe_worldRotate.z, Halfpipe_transformPos, Halfpipe_rotateZTable)
717
718
switch temp2
719
case 0
720
case 1
721
case 2
722
case 3
723
case 4
724
case 7
725
GetTableValue(temp0, temp2, Halfpipe_vertexOffsetTable)
726
temp0 += Halfpipe_vertexCount
727
TransformVertices(MAT_WORLD, Halfpipe_vertexCount, temp0)
728
vertexBuffer[4095].x = 0
729
vertexBuffer[4095].y = 0
730
vertexBuffer[4095].z = 0x2000
731
TransformVertices(MAT_WORLD, 0xFFF, 0x1000)
732
733
Halfpipe_tempTranslate.x = vertexBuffer[4095].x
734
Halfpipe_tempTranslate.y = vertexBuffer[4095].y
735
Halfpipe_tempTranslate.z = vertexBuffer[4095].z
736
Halfpipe_worldRotate.x += Halfpipe_rotateOffset.x
737
Halfpipe_worldRotate.y += Halfpipe_rotateOffset.y
738
Halfpipe_worldRotate.z += Halfpipe_rotateOffset.z
739
MatrixRotateXYZ(MAT_WORLD, Halfpipe_worldRotate.x, Halfpipe_worldRotate.y, Halfpipe_worldRotate.z)
740
MatrixTranslateXYZ(MAT_TEMP, Halfpipe_tempTranslate.x, Halfpipe_tempTranslate.y, Halfpipe_tempTranslate.z)
741
MatrixMultiply(MAT_WORLD, MAT_TEMP)
742
TransformVertices(MAT_WORLD, temp0, arrayPos0)
743
break
744
745
case 5
746
GetTableValue(temp0, temp2, Halfpipe_vertexOffsetTable)
747
temp0 += Halfpipe_vertexCount
748
TransformVertices(MAT_WORLD, Halfpipe_vertexCount, temp0)
749
vertexBuffer[4094].x = 0
750
vertexBuffer[4094].y = 0
751
vertexBuffer[4094].z = 0xC00
752
vertexBuffer[4095].x = 0
753
vertexBuffer[4095].y = 0
754
vertexBuffer[4095].z = 0x2000
755
TransformVertices(MAT_WORLD, 0xFFE, 0x1000)
756
757
Halfpipe_tempTranslate.x = vertexBuffer[4094].x
758
Halfpipe_tempTranslate.y = vertexBuffer[4094].y
759
Halfpipe_tempTranslate.z = vertexBuffer[4094].z
760
temp3 = Halfpipe_rotateOffset.x
761
temp3 *= 12
762
temp3 >>= 5
763
Halfpipe_worldRotate.x += temp3
764
temp3 = Halfpipe_rotateOffset.y
765
temp3 *= 12
766
temp3 >>= 5
767
Halfpipe_worldRotate.y += temp3
768
temp3 = Halfpipe_rotateOffset.z
769
temp3 *= 12
770
temp3 >>= 5
771
Halfpipe_worldRotate.z += temp3
772
MatrixRotateXYZ(MAT_WORLD, Halfpipe_worldRotate.x, Halfpipe_worldRotate.y, Halfpipe_worldRotate.z)
773
MatrixTranslateXYZ(MAT_TEMP, Halfpipe_tempTranslate.x, Halfpipe_tempTranslate.y, Halfpipe_tempTranslate.z)
774
MatrixMultiply(MAT_WORLD, MAT_TEMP)
775
temp1 = temp0
776
temp1 += 17
777
TransformVertices(MAT_WORLD, temp0, temp1)
778
779
Halfpipe_tempTranslate.x = vertexBuffer[4095].x
780
Halfpipe_tempTranslate.y = vertexBuffer[4095].y
781
Halfpipe_tempTranslate.z = vertexBuffer[4095].z
782
GetTableValue(Halfpipe_worldRotate.x, Halfpipe_transformPos, Halfpipe_rotateXTable)
783
GetTableValue(Halfpipe_worldRotate.y, Halfpipe_transformPos, Halfpipe_rotateYTable)
784
GetTableValue(Halfpipe_worldRotate.z, Halfpipe_transformPos, Halfpipe_rotateZTable)
785
Halfpipe_worldRotate.x += Halfpipe_rotateOffset.x
786
Halfpipe_worldRotate.y += Halfpipe_rotateOffset.y
787
Halfpipe_worldRotate.z += Halfpipe_rotateOffset.z
788
MatrixRotateXYZ(MAT_WORLD, Halfpipe_worldRotate.x, Halfpipe_worldRotate.y, Halfpipe_worldRotate.z)
789
MatrixTranslateXYZ(MAT_TEMP, Halfpipe_tempTranslate.x, Halfpipe_tempTranslate.y, Halfpipe_tempTranslate.z)
790
MatrixMultiply(MAT_WORLD, MAT_TEMP)
791
TransformVertices(MAT_WORLD, temp1, arrayPos0)
792
break
793
794
case 6
795
GetTableValue(temp0, temp2, Halfpipe_vertexOffsetTable)
796
temp0 += Halfpipe_vertexCount
797
TransformVertices(MAT_WORLD, Halfpipe_vertexCount, temp0)
798
799
vertexBuffer[4094].x = 0
800
vertexBuffer[4094].y = 0
801
vertexBuffer[4094].z = 0x1400
802
vertexBuffer[4095].x = 0
803
vertexBuffer[4095].y = 0
804
vertexBuffer[4095].z = 0x2000
805
TransformVertices(MAT_WORLD, 0xFFE, 0x1000)
806
807
Halfpipe_tempTranslate.x = vertexBuffer[4094].x
808
Halfpipe_tempTranslate.y = vertexBuffer[4094].y
809
Halfpipe_tempTranslate.z = vertexBuffer[4094].z
810
temp3 = Halfpipe_rotateOffset.x
811
temp3 *= 20
812
temp3 >>= 5
813
Halfpipe_worldRotate.x += temp3
814
temp3 = Halfpipe_rotateOffset.y
815
temp3 *= 20
816
temp3 >>= 5
817
Halfpipe_worldRotate.y += temp3
818
temp3 = Halfpipe_rotateOffset.z
819
temp3 *= 20
820
temp3 >>= 5
821
Halfpipe_worldRotate.z += temp3
822
MatrixRotateXYZ(MAT_WORLD, Halfpipe_worldRotate.x, Halfpipe_worldRotate.y, Halfpipe_worldRotate.z)
823
MatrixTranslateXYZ(MAT_TEMP, Halfpipe_tempTranslate.x, Halfpipe_tempTranslate.y, Halfpipe_tempTranslate.z)
824
MatrixMultiply(MAT_WORLD, MAT_TEMP)
825
temp1 = temp0
826
temp1 += 17
827
TransformVertices(MAT_WORLD, temp0, temp1)
828
829
Halfpipe_tempTranslate.x = vertexBuffer[4095].x
830
Halfpipe_tempTranslate.y = vertexBuffer[4095].y
831
Halfpipe_tempTranslate.z = vertexBuffer[4095].z
832
GetTableValue(Halfpipe_worldRotate.x, Halfpipe_transformPos, Halfpipe_rotateXTable)
833
GetTableValue(Halfpipe_worldRotate.y, Halfpipe_transformPos, Halfpipe_rotateYTable)
834
GetTableValue(Halfpipe_worldRotate.z, Halfpipe_transformPos, Halfpipe_rotateZTable)
835
Halfpipe_worldRotate.x += Halfpipe_rotateOffset.x
836
Halfpipe_worldRotate.y += Halfpipe_rotateOffset.y
837
Halfpipe_worldRotate.z += Halfpipe_rotateOffset.z
838
MatrixRotateXYZ(MAT_WORLD, Halfpipe_worldRotate.x, Halfpipe_worldRotate.y, Halfpipe_worldRotate.z)
839
MatrixTranslateXYZ(MAT_TEMP, Halfpipe_tempTranslate.x, Halfpipe_tempTranslate.y, Halfpipe_tempTranslate.z)
840
MatrixMultiply(MAT_WORLD, MAT_TEMP)
841
TransformVertices(MAT_WORLD, temp1, arrayPos0)
842
break
843
844
end switch
845
846
Halfpipe_transformPos++
847
Halfpipe_transformPos %= 40
848
Halfpipe_vertexCount = arrayPos0
849
if Halfpipe_vertexCount >= Halfpipe_prevVertexCount
850
Halfpipe_vertexCount = 0
851
end if
852
end function
853
854
855
private function Halfpipe_SetupFaces
856
temp0 = 0
857
arrayPos0 = scene3D.faceCount
858
GetTableValue(temp1, temp0, Halfpipe_faceInfoTable)
859
temp0++
860
while temp1 > 0
861
GetTableValue(faceBuffer[arrayPos0].a, temp0, Halfpipe_faceInfoTable)
862
faceBuffer[arrayPos0].a += Halfpipe_vertexCount
863
temp0++
864
865
GetTableValue(faceBuffer[arrayPos0].b, temp0, Halfpipe_faceInfoTable)
866
faceBuffer[arrayPos0].b += Halfpipe_vertexCount
867
temp0++
868
869
GetTableValue(faceBuffer[arrayPos0].c, temp0, Halfpipe_faceInfoTable)
870
faceBuffer[arrayPos0].c += Halfpipe_vertexCount
871
temp0++
872
873
GetTableValue(faceBuffer[arrayPos0].d, temp0, Halfpipe_faceInfoTable)
874
faceBuffer[arrayPos0].d += Halfpipe_vertexCount
875
temp0++
876
877
GetTableValue(temp2, temp0, Halfpipe_faceInfoTable)
878
temp0++
879
880
switch temp2
881
case 0
882
faceBuffer[arrayPos0].flag = FACE_FADED
883
faceBuffer[arrayPos0].color = SpecialSetup_StageColor1
884
break
885
886
case 1
887
faceBuffer[arrayPos0].flag = FACE_FADED
888
faceBuffer[arrayPos0].color = SpecialSetup_StageColor2
889
break
890
891
case 2
892
faceBuffer[arrayPos0].flag = FACE_FADED
893
faceBuffer[arrayPos0].color = 0xFFE0E000
894
break
895
896
case 3
897
faceBuffer[arrayPos0].flag = FACE_FADED
898
faceBuffer[arrayPos0].color = 0xFFE0A020
899
break
900
901
case 5
902
faceBuffer[arrayPos0].flag = FACE_TEXTURED_C
903
arrayPos1 = faceBuffer[arrayPos0].a
904
vertexBuffer[arrayPos1].u = 17
905
vertexBuffer[arrayPos1].v = 17
906
907
arrayPos2 = Halfpipe_checkpointTexCount
908
arrayPos2 %= 7
909
if arrayPos2 == 0
910
arrayPos2 = Halfpipe_checkpointTexCount
911
arrayPos2 /= 7
912
SetTableValue(arrayPos1, arrayPos2, Halfpipe_checkpointFaceTable)
913
end if
914
915
Halfpipe_checkpointTexCount++
916
917
arrayPos1 = faceBuffer[arrayPos0].b
918
vertexBuffer[arrayPos1].u = 0x800
919
vertexBuffer[arrayPos1].v = 0x800
920
921
arrayPos1 = faceBuffer[arrayPos0].c
922
vertexBuffer[arrayPos1].u = 16
923
vertexBuffer[arrayPos1].v = 16
924
break
925
926
end switch
927
928
arrayPos0++
929
scene3D.faceCount++
930
temp1--
931
loop
932
end function
933
934
935
// ========================
936
// Events
937
// ========================
938
939
event ObjectUpdate
940
scene3D.vertexCount = Halfpipe_prevVertexCount
941
scene3D.faceCount = Halfpipe_faceCount
942
943
// Yep, this check has absolutely no chance of failing
944
// This is likely a leftover from development, probably checking if a button was held down or something
945
// Anyway, this handles progressing forwards through the stage
946
if true == true
947
object.moveStep += object.moveSpeed
948
temp0 = object.moveSpeed
949
temp0 <<= 13
950
object.playerPos.z += temp0
951
if object.moveStep > 63
952
object.moveStep -= 64
953
CallFunction(Halfpipe_SetupVertices)
954
object.transformIDHalfpipe++
955
object.transformIDHalfpipe %= 40
956
object.nextTransformIDHalfpipe++
957
object.nextTransformIDHalfpipe %= 40
958
object.transformIDWorld++
959
object.transformIDWorld %= 40
960
object.nextTransformIDWorld++
961
object.nextTransformIDWorld %= 40
962
end if
963
end if
964
965
// ------------------------
966
// HALFPIPE TRANSFORMATIONS
967
// ------------------------
968
969
// Translation
970
971
GetTableValue(object.halfpipeTranslation.x, object.transformIDHalfpipe, Halfpipe_translateXTable)
972
GetTableValue(temp0, object.nextTransformIDHalfpipe, Halfpipe_translateXTable)
973
temp0 -= object.halfpipeTranslation.x
974
temp0 *= object.moveStep
975
temp0 >>= 6
976
object.halfpipeTranslation.x += temp0
977
FlipSign(object.halfpipeTranslation.x)
978
979
GetTableValue(object.halfpipeTranslation.y, object.transformIDHalfpipe, Halfpipe_translateYTable)
980
GetTableValue(temp0, object.nextTransformIDHalfpipe, Halfpipe_translateYTable)
981
temp0 -= object.halfpipeTranslation.y
982
temp0 *= object.moveStep
983
temp0 >>= 6
984
object.halfpipeTranslation.y += temp0
985
FlipSign(object.halfpipeTranslation.y)
986
987
GetTableValue(object.halfpipeTranslation.z, object.transformIDHalfpipe, Halfpipe_translateZTable)
988
GetTableValue(temp0, object.nextTransformIDHalfpipe, Halfpipe_translateZTable)
989
temp0 -= object.halfpipeTranslation.z
990
temp0 *= object.moveStep
991
temp0 >>= 6
992
object.halfpipeTranslation.z += temp0
993
FlipSign(object.halfpipeTranslation.z)
994
995
// Rotation
996
997
GetTableValue(temp1, object.transformIDHalfpipe, Halfpipe_rotateXTable)
998
GetTableValue(temp0, object.nextTransformIDHalfpipe, Halfpipe_rotateXTable)
999
temp0 -= temp1
1000
temp0 *= object.moveStep
1001
temp0 >>= 6
1002
temp1 += temp0
1003
temp1 <<= 1
1004
if object.newHalfpipeRotation.x != temp1
1005
temp0 = temp1
1006
temp0 -= object.newHalfpipeRotation.x
1007
temp0 >>= 1
1008
if temp0 == 0
1009
if object.newHalfpipeRotation.x < temp1
1010
object.newHalfpipeRotation.x++
1011
else
1012
object.newHalfpipeRotation.x--
1013
end if
1014
else
1015
object.newHalfpipeRotation.x += temp0
1016
end if
1017
end if
1018
1019
GetTableValue(temp1, object.transformIDHalfpipe, Halfpipe_rotateYTable)
1020
GetTableValue(temp0, object.nextTransformIDHalfpipe, Halfpipe_rotateYTable)
1021
temp0 -= temp1
1022
temp0 *= object.moveStep
1023
temp0 >>= 6
1024
temp1 += temp0
1025
temp1 <<= 1
1026
if object.newHalfpipeRotation.y != temp1
1027
temp0 = temp1
1028
temp0 -= object.newHalfpipeRotation.y
1029
temp0 >>= 2
1030
if temp0 == 0
1031
if object.newHalfpipeRotation.y < temp1
1032
object.newHalfpipeRotation.y++
1033
else
1034
object.newHalfpipeRotation.y--
1035
end if
1036
else
1037
object.newHalfpipeRotation.y += temp0
1038
end if
1039
end if
1040
1041
GetTableValue(temp1, object.transformIDHalfpipe, Halfpipe_rotateZTable)
1042
GetTableValue(temp0, object.nextTransformIDHalfpipe, Halfpipe_rotateZTable)
1043
temp0 -= temp1
1044
temp0 *= object.moveStep
1045
temp0 >>= 6
1046
temp1 += temp0
1047
temp1 <<= 1
1048
if object.newHalfpipeRotation.z != temp1
1049
temp0 = temp1
1050
temp0 -= object.newHalfpipeRotation.z
1051
temp0 >>= 1
1052
if temp0 == 0
1053
if object.newHalfpipeRotation.z < temp1
1054
object.newHalfpipeRotation.z++
1055
else
1056
object.newHalfpipeRotation.z--
1057
end if
1058
else
1059
object.newHalfpipeRotation.z += temp0
1060
end if
1061
end if
1062
1063
object.halfpipeRotation.x = object.newHalfpipeRotation.x
1064
object.halfpipeRotation.y = object.newHalfpipeRotation.y
1065
object.halfpipeRotation.z = object.newHalfpipeRotation.z
1066
object.halfpipeRotation.x >>= 1
1067
object.halfpipeRotation.y >>= 1
1068
object.halfpipeRotation.z >>= 1
1069
1070
// ------------------------
1071
// WORLD TRANSFORMATIONS
1072
// ------------------------
1073
1074
// Translation
1075
1076
GetTableValue(object.worldTranslation.x, object.transformIDWorld, Halfpipe_translateXTable)
1077
GetTableValue(temp0, object.nextTransformIDWorld, Halfpipe_translateXTable)
1078
temp0 -= object.worldTranslation.x
1079
temp0 *= object.moveStep
1080
temp0 >>= 6
1081
object.worldTranslation.x += temp0
1082
1083
GetTableValue(object.worldTranslation.y, object.transformIDWorld, Halfpipe_translateYTable)
1084
GetTableValue(temp0, object.nextTransformIDWorld, Halfpipe_translateYTable)
1085
temp0 -= object.worldTranslation.y
1086
temp0 *= object.moveStep
1087
temp0 >>= 6
1088
object.worldTranslation.y += temp0
1089
1090
GetTableValue(object.worldTranslation.z, object.transformIDWorld, Halfpipe_translateZTable)
1091
GetTableValue(temp0, object.nextTransformIDWorld, Halfpipe_translateZTable)
1092
temp0 -= object.worldTranslation.z
1093
temp0 *= object.moveStep
1094
temp0 >>= 6
1095
object.worldTranslation.z += temp0
1096
1097
// Rotation
1098
1099
GetTableValue(object.worldRotation.x, object.transformIDWorld, Halfpipe_rotateXTable)
1100
GetTableValue(temp0, object.nextTransformIDWorld, Halfpipe_rotateXTable)
1101
temp0 -= object.worldRotation.x
1102
temp0 *= object.moveStep
1103
temp0 >>= 6
1104
object.worldRotation.x += temp0
1105
1106
GetTableValue(object.worldRotation.y, object.transformIDWorld, Halfpipe_rotateYTable)
1107
GetTableValue(temp0, object.nextTransformIDWorld, Halfpipe_rotateYTable)
1108
temp0 -= object.worldRotation.y
1109
temp0 *= object.moveStep
1110
temp0 >>= 6
1111
object.worldRotation.y += temp0
1112
1113
GetTableValue(object.worldRotation.z, object.transformIDWorld, Halfpipe_rotateZTable)
1114
GetTableValue(temp0, object.nextTransformIDWorld, Halfpipe_rotateZTable)
1115
temp0 -= object.worldRotation.z
1116
temp0 *= object.moveStep
1117
temp0 >>= 6
1118
object.worldRotation.z += temp0
1119
end event
1120
1121
1122
event ObjectDraw
1123
MatrixTranslateXYZ(MAT_WORLD, object.halfpipeTranslation.x, object.halfpipeTranslation.y, object.halfpipeTranslation.z)
1124
MatrixRotateXYZ(MAT_VIEW, object.halfpipeRotation.x, object.halfpipeRotation.y, object.halfpipeRotation.z)
1125
MatrixInverse(MAT_VIEW)
1126
MatrixRotateXYZ(MAT_TEMP, -8, 0, 0)
1127
MatrixMultiply(MAT_VIEW, MAT_TEMP)
1128
1129
#platform: USE_STANDALONE
1130
// In Standalone, we're only looking at the main player's position
1131
1132
temp0 = player[2].xpos
1133
temp0 *= -0x40
1134
temp0 >>= 9
1135
1136
temp1 = player[2].ypos
1137
temp1 *= -0x60
1138
temp1 >>= 9
1139
temp1 -= 0x200
1140
#endplatform
1141
1142
#platform: USE_ORIGINS
1143
// In Origins, however, the routine was rearranged so that...
1144
1145
temp0 = player[2].xpos
1146
temp1 = player[2].ypos
1147
1148
// ...we can take the average between P1 and P2's positions in multiplayer
1149
if options.vsMode == true
1150
temp0 += player[3].xpos
1151
temp1 += player[3].ypos
1152
temp0 >>= 1
1153
temp1 >>= 1
1154
end if
1155
1156
temp0 *= -0x40
1157
temp0 >>= 9
1158
1159
temp1 *= -0x60
1160
temp1 >>= 9
1161
temp1 -= 0x200
1162
#endplatform
1163
1164
MatrixTranslateXYZ(MAT_TEMP, temp0, temp1, 0)
1165
MatrixMultiply(MAT_VIEW, MAT_TEMP)
1166
Draw3DScene()
1167
end event
1168
1169
1170
event ObjectStartup
1171
LoadSpriteSheet("Special/Objects.gif")
1172
1173
object[0].type = TypeName[Halfpipe]
1174
object[0].priority = PRIORITY_ACTIVE
1175
object[0].xpos = 0x1C00000
1176
object[0].ypos = 0
1177
object[0].playerPos.z = 0
1178
object[0].localPos.z = 0
1179
object[0].moveStep = 0
1180
object[0].transformIDHalfpipe = 0
1181
object[0].nextTransformIDHalfpipe = 1
1182
object[0].transformIDWorld = 2
1183
object[0].nextTransformIDWorld = 3
1184
object[0].moveSpeed = 17
1185
1186
Halfpipe_vertexCount = 0
1187
Halfpipe_vertexTableID = 0
1188
Halfpipe_transformPos = 0
1189
Halfpipe_prevVertexCount = 0x1000
1190
Halfpipe_tempTranslate.x = 0
1191
Halfpipe_tempTranslate.y = 0
1192
Halfpipe_tempTranslate.z = 0
1193
#platform: USE_DECOMP
1194
// Not in the original, probably should be though
1195
// This fixes the special stage warping bug
1196
Halfpipe_worldRotate.x = 0
1197
Halfpipe_worldRotate.y = 0
1198
Halfpipe_worldRotate.z = 0
1199
1200
// (Origins doesn't fix this either, which is why Special Stages appear weird for a moment when restarting one)
1201
#endplatform
1202
1203
arrayPos5 = 32
1204
SetTableValue(Halfpipe_vertexTable1, 0, Halfpipe_vertexTablePtrs)
1205
SetTableValue(Halfpipe_vertexTable1, 1, Halfpipe_vertexTablePtrs)
1206
SetTableValue(Halfpipe_vertexTable1, 2, Halfpipe_vertexTablePtrs)
1207
SetTableValue(Halfpipe_vertexTable1, 3, Halfpipe_vertexTablePtrs)
1208
SetTableValue(Halfpipe_vertexTable2, 4, Halfpipe_vertexTablePtrs)
1209
SetTableValue(Halfpipe_vertexTable3, 5, Halfpipe_vertexTablePtrs)
1210
SetTableValue(Halfpipe_vertexTable4, 6, Halfpipe_vertexTablePtrs)
1211
SetTableValue(Halfpipe_vertexTable5, 7, Halfpipe_vertexTablePtrs)
1212
Halfpipe_checkpointTexCount = 0
1213
scene3D.faceCount = 0
1214
1215
temp7 = 0
1216
while temp7 < 4
1217
Halfpipe_faceInfoTable = Halfpipe_faceTable1
1218
CallFunction(Halfpipe_SetupFaces)
1219
CallFunction(Halfpipe_SetupVertices)
1220
1221
Halfpipe_faceInfoTable = Halfpipe_faceTable2
1222
CallFunction(Halfpipe_SetupFaces)
1223
CallFunction(Halfpipe_SetupVertices)
1224
1225
Halfpipe_faceInfoTable = Halfpipe_faceTable2
1226
CallFunction(Halfpipe_SetupFaces)
1227
CallFunction(Halfpipe_SetupVertices)
1228
1229
Halfpipe_faceInfoTable = Halfpipe_faceTable2
1230
CallFunction(Halfpipe_SetupFaces)
1231
CallFunction(Halfpipe_SetupVertices)
1232
1233
Halfpipe_faceInfoTable = Halfpipe_faceTable3
1234
CallFunction(Halfpipe_SetupFaces)
1235
CallFunction(Halfpipe_SetupVertices)
1236
1237
Halfpipe_faceInfoTable = Halfpipe_faceTable4
1238
CallFunction(Halfpipe_SetupFaces)
1239
CallFunction(Halfpipe_SetupVertices)
1240
1241
Halfpipe_faceInfoTable = Halfpipe_faceTable5
1242
CallFunction(Halfpipe_SetupFaces)
1243
CallFunction(Halfpipe_SetupVertices)
1244
1245
Halfpipe_faceInfoTable = Halfpipe_faceTable6
1246
CallFunction(Halfpipe_SetupFaces)
1247
CallFunction(Halfpipe_SetupVertices)
1248
1249
temp7++
1250
loop
1251
1252
scene3D.vertexCount = Halfpipe_vertexCount
1253
Halfpipe_prevVertexCount = Halfpipe_vertexCount
1254
Halfpipe_faceCount = scene3D.faceCount
1255
Halfpipe_vertexCount = 0
1256
scene3D.projectionX = 216
1257
scene3D.projectionY = 216
1258
scene3D.fogStrength = 0x50
1259
scene3D.fogColor = 0x000000
1260
end event
1261
1262
1263
// ========================
1264
// Editor Events
1265
// ========================
1266
1267
event RSDKDraw
1268
DrawSprite(0)
1269
end event
1270
1271
1272
event RSDKLoad
1273
LoadSpriteSheet("Global/Display.gif")
1274
SpriteFrame(-16, -16, 32, 32, 1, 143)
1275
1276
SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
1277
end event
1278
1279