splat64 0.34.3__py3-none-any.whl → 0.35.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,711 @@
1
+ """
2
+ Utilities to write assembly-related macros.
3
+ This includes writing files like:
4
+ - include/include_asm.h
5
+ - include/macro.inc
6
+ - include/labels.inc
7
+ - include/gte_macros.inc
8
+ """
9
+
10
+ from pathlib import Path
11
+ import os
12
+
13
+ from . import options, log
14
+
15
+
16
+ def write_all_files():
17
+ write_include_asm_h()
18
+ write_assembly_inc_files()
19
+
20
+
21
+ def _write(filepath: str, contents: str):
22
+ p = Path(os.path.normpath(options.opts.base_path / filepath))
23
+ p.parent.mkdir(parents=True, exist_ok=True)
24
+ with p.open("w", encoding="UTF-8", newline="\n") as f:
25
+ f.write(contents)
26
+
27
+
28
+ def write_include_asm_h():
29
+ if not options.opts.compiler.uses_include_asm:
30
+ # These compilers do not use the `INCLUDE_ASM` macro.
31
+ return
32
+
33
+ file_data = """\
34
+ #ifndef INCLUDE_ASM_H
35
+ #define INCLUDE_ASM_H
36
+
37
+ #if !defined(M2CTX) && !defined(PERMUTER)
38
+
39
+ #ifndef INCLUDE_ASM
40
+ #define INCLUDE_ASM(FOLDER, NAME) \\
41
+ __asm__( \\
42
+ ".section .text\\n" \\
43
+ " .set noat\\n" \\
44
+ " .set noreorder\\n" \\
45
+ " .include \\"" FOLDER "/" #NAME ".s\\"\\n" \\
46
+ " .set reorder\\n" \\
47
+ " .set at\\n" \\
48
+ )
49
+ #endif
50
+ #ifndef INCLUDE_RODATA
51
+ #define INCLUDE_RODATA(FOLDER, NAME) \\
52
+ __asm__( \\
53
+ ".section .rodata\\n" \\
54
+ " .include \\"" FOLDER "/" #NAME ".s\\"\\n" \\
55
+ ".section .text" \\
56
+ )
57
+ #endif
58
+ __asm__(".include \\"include/labels.inc\\"\\n");
59
+
60
+ #else
61
+
62
+ #ifndef INCLUDE_ASM
63
+ #define INCLUDE_ASM(FOLDER, NAME)
64
+ #endif
65
+ #ifndef INCLUDE_RODATA
66
+ #define INCLUDE_RODATA(FOLDER, NAME)
67
+ #endif
68
+
69
+ #endif /* !defined(M2CTX) && !defined(PERMUTER) */
70
+
71
+ #endif /* INCLUDE_ASM_H */
72
+ """
73
+ _write("include/include_asm.h", file_data)
74
+
75
+
76
+ def write_assembly_inc_files():
77
+ func_macros = f"""\
78
+ # A function symbol.
79
+ .macro {options.opts.asm_function_macro} label, visibility=global
80
+ .\\visibility \\label
81
+ .type \\label, @function
82
+ \\label:
83
+ .ent \\label
84
+ .endm
85
+ """
86
+ if options.opts.asm_end_label != "":
87
+ func_macros += f"""
88
+ # The end of a function symbol.
89
+ .macro {options.opts.asm_end_label} label
90
+ .size \\label, . - \\label
91
+ .end \\label
92
+ .endm
93
+ """
94
+ if (
95
+ options.opts.asm_function_alt_macro != ""
96
+ and options.opts.asm_function_alt_macro != options.opts.asm_function_macro
97
+ ):
98
+ func_macros += f"""
99
+ # An alternative entry to a function.
100
+ .macro {options.opts.asm_function_alt_macro} label, visibility=global
101
+ .\\visibility \\label
102
+ .type \\label, @function
103
+ \\label:
104
+ .aent \\label
105
+ .endm
106
+ """
107
+ if (
108
+ options.opts.asm_ehtable_label_macro != ""
109
+ and options.opts.asm_ehtable_label_macro != options.opts.asm_function_macro
110
+ ):
111
+ func_macros += f"""
112
+ # A label referenced by an error handler table.
113
+ .macro {options.opts.asm_ehtable_label_macro} label, visibility=global
114
+ .\\visibility \\label
115
+ \\label:
116
+ .endm
117
+ """
118
+
119
+ jlabel_macro_labelsinc = ""
120
+ jlabel_macro_macroinc = ""
121
+ if (
122
+ options.opts.asm_jtbl_label_macro != ""
123
+ and options.opts.asm_jtbl_label_macro != options.opts.asm_function_macro
124
+ ):
125
+ jlabel_macro_macroinc = f"""
126
+ # A label referenced by a jumptable.
127
+ .macro {options.opts.asm_jtbl_label_macro} label, visibility=global
128
+ .\\visibility \\label
129
+ .type \\label, @function
130
+ \\label:
131
+ .endm
132
+ """
133
+ if options.opts.migrate_rodata_to_functions:
134
+ jlabel_macro_labelsinc = f"""
135
+ # A label referenced by a jumptable.
136
+ .macro {options.opts.asm_jtbl_label_macro} label, visibility=global
137
+ \\label:
138
+ .endm
139
+ """
140
+ else:
141
+ # If the user doesn't migrate rodata, like jumptables, to functions
142
+ # then the user will need jlabels to be global instead of local,
143
+ # so we just reuse the definition from macro.inc
144
+ jlabel_macro_labelsinc = jlabel_macro_macroinc
145
+
146
+ data_macros = ""
147
+ if (
148
+ options.opts.asm_data_macro != ""
149
+ and options.opts.asm_data_macro != options.opts.asm_function_macro
150
+ ):
151
+ data_macros += f"""
152
+ # A data symbol.
153
+ .macro {options.opts.asm_data_macro} label, visibility=global
154
+ .\\visibility \\label
155
+ .type \\label, @object
156
+ \\label:
157
+ .endm
158
+ """
159
+ if options.opts.asm_data_end_label != "":
160
+ data_macros += f"""
161
+ # End of a data symbol.
162
+ .macro {options.opts.asm_data_end_label} label
163
+ .size \\label, . - \\label
164
+ .endm
165
+ """
166
+
167
+ nm_macros = ""
168
+ if options.opts.asm_nonmatching_label_macro != "":
169
+ nm_macros = f"""
170
+ # Label to signal the symbol haven't been matched yet.
171
+ .macro {options.opts.asm_nonmatching_label_macro} label, size=1
172
+ .global \\label\\().NON_MATCHING
173
+ .type \\label\\().NON_MATCHING, @object
174
+ .size \\label\\().NON_MATCHING, \\size
175
+ \\label\\().NON_MATCHING:
176
+ .endm
177
+ """
178
+
179
+ labels_inc = f"""\
180
+ {func_macros}
181
+ {jlabel_macro_labelsinc}
182
+ {data_macros}
183
+ {nm_macros}\
184
+ """
185
+ macros_inc = f"""\
186
+ {func_macros}
187
+ {jlabel_macro_macroinc}
188
+ {data_macros}
189
+ {nm_macros}\
190
+ """
191
+
192
+ if options.opts.compiler.uses_include_asm:
193
+ # File used by original assembler
194
+ preamble = "# This file is used by the original compiler/assembler.\n# Defines the expected assembly macros.\n"
195
+
196
+ if options.opts.platform == "psx":
197
+ preamble += '\n.include "gte_macros.inc"\n'
198
+ _write("include/labels.inc", f"{preamble}\n{labels_inc}")
199
+
200
+ if options.opts.platform in {"n64", "psx"}:
201
+ gas = macros_inc
202
+ elif options.opts.platform in {"ps2", "psp"}:
203
+ # ps2 and psp usually use c++ mangled names, so we need to quote those
204
+ # names when using modern gas to avoid build errors.
205
+ # This means we can't reuse the labels.inc file.
206
+ gas = macros_inc.replace("\\label", '"\\label"').replace(
207
+ '"\\label"\\().NON_MATCHING', '"\\label\\().NON_MATCHING"'
208
+ )
209
+ elif not options.opts.is_unsupported_platform:
210
+ log.error(f"Unknown platform '{options.opts.platform}'")
211
+ else:
212
+ gas = macros_inc
213
+
214
+ if options.opts.platform == "n64":
215
+ gas += """
216
+ # COP0 register aliases
217
+
218
+ .set Index, $0
219
+ .set Random, $1
220
+ .set EntryLo0, $2
221
+ .set EntryLo1, $3
222
+ .set Context, $4
223
+ .set PageMask, $5
224
+ .set Wired, $6
225
+ .set Reserved07, $7
226
+ .set BadVaddr, $8
227
+ .set Count, $9
228
+ .set EntryHi, $10
229
+ .set Compare, $11
230
+ .set Status, $12
231
+ .set Cause, $13
232
+ .set EPC, $14
233
+ .set PRevID, $15
234
+ .set Config, $16
235
+ .set LLAddr, $17
236
+ .set WatchLo, $18
237
+ .set WatchHi, $19
238
+ .set XContext, $20
239
+ .set Reserved21, $21
240
+ .set Reserved22, $22
241
+ .set Reserved23, $23
242
+ .set Reserved24, $24
243
+ .set Reserved25, $25
244
+ .set PErr, $26
245
+ .set CacheErr, $27
246
+ .set TagLo, $28
247
+ .set TagHi, $29
248
+ .set ErrorEPC, $30
249
+ .set Reserved31, $31
250
+
251
+ # Float register aliases
252
+
253
+ .set $fv0, $f0
254
+ .set $fv0f, $f1
255
+ .set $fv1, $f2
256
+ .set $fv1f, $f3
257
+ .set $ft0, $f4
258
+ .set $ft0f, $f5
259
+ .set $ft1, $f6
260
+ .set $ft1f, $f7
261
+ .set $ft2, $f8
262
+ .set $ft2f, $f9
263
+ .set $ft3, $f10
264
+ .set $ft3f, $f11
265
+ .set $fa0, $f12
266
+ .set $fa0f, $f13
267
+ .set $fa1, $f14
268
+ .set $fa1f, $f15
269
+ .set $ft4, $f16
270
+ .set $ft4f, $f17
271
+ .set $ft5, $f18
272
+ .set $ft5f, $f19
273
+ .set $fs0, $f20
274
+ .set $fs0f, $f21
275
+ .set $fs1, $f22
276
+ .set $fs1f, $f23
277
+ .set $fs2, $f24
278
+ .set $fs2f, $f25
279
+ .set $fs3, $f26
280
+ .set $fs3f, $f27
281
+ .set $fs4, $f28
282
+ .set $fs4f, $f29
283
+ .set $fs5, $f30
284
+ .set $fs5f, $f31
285
+ """
286
+ elif options.opts.platform == "psx":
287
+ gas += '\n.include "gte_macros.inc"\n'
288
+ write_gte_macros()
289
+
290
+ if options.opts.generated_macro_inc_content is not None:
291
+ gas += f"\n{options.opts.generated_macro_inc_content}\n"
292
+
293
+ # File used by modern gas
294
+ preamble = (
295
+ "# This file is used by modern gas.\n# Defines the expected assembly macros\n"
296
+ )
297
+ _write("include/macro.inc", f"{preamble}\n{gas}")
298
+
299
+
300
+ def write_gte_macros():
301
+ # Taken directly from https://github.com/Decompollaborate/rabbitizer/blob/develop/docs/r3000gte/gte_macros.s
302
+ # Please try to upstream any fix/update done here.
303
+ gte_macros = """
304
+ ## GTE instructions macros
305
+ ## This macros are meant to be used with GAS and avoid using DMPSX
306
+
307
+ /* RTPS 15 0x4A180001 Perspective transform */
308
+ .macro rtps
309
+ .word 0x4A180001
310
+ .endm
311
+
312
+ /* RTPT 23 0x4A280030 Perspective transform on 3 points */
313
+ .macro rtpt
314
+ .word 0x4A280030
315
+ .endm
316
+
317
+ /* DPCL 8 0x4A680029 Depth Cue Color light */
318
+ .macro dpcl
319
+ .word 0x4A680029
320
+ .endm
321
+
322
+ /* DPCS 8 0x4A780010 Depth Cueing */
323
+ .macro dpcs
324
+ .word 0x4A780010
325
+ .endm
326
+
327
+ /* DPCT 17 0x4AF8002A Depth cue color RGB0,RGB1,RGB2 */
328
+ .macro dpct
329
+ .word 0x4AF8002A
330
+ .endm
331
+
332
+ /* INTPL 8 0x4A980011 Interpolation of vector and far color */
333
+ .macro intpl
334
+ .word 0x4A980011
335
+ .endm
336
+
337
+ /* NCS 14 0x4AC8041E Normal color v0 */
338
+ .macro ncs
339
+ .word 0x4AC8041E
340
+ .endm
341
+
342
+ /* NCT 30 0x4AD80420 Normal color v0, v1, v2 */
343
+ .macro nct
344
+ .word 0x4AD80420
345
+ .endm
346
+
347
+ /* NCDS 19 0x4AE80413 Normal color depth cuev0 */
348
+ .macro ncds
349
+ .word 0x4AE80413
350
+ .endm
351
+
352
+ /* NCDT 44 0x4AF80416 Normal color depth cue v0, v1, v2 */
353
+ .macro ncdt
354
+ .word 0x4AF80416
355
+ .endm
356
+
357
+ /* NCCS 17 0x4B08041B Normal color col. v0 */
358
+ .macro nccs
359
+ .word 0x4B08041B
360
+ .endm
361
+
362
+ /* NCCT 39 0x4B18043F Normal color col.v0, v1, v2 */
363
+ .macro ncct
364
+ .word 0x4B18043F
365
+ .endm
366
+
367
+ /* CDP 13 0x4B280414 Color Depth Queue */
368
+ .macro cdp
369
+ .word 0x4B280414
370
+ .endm
371
+
372
+ /* CC 11 0x4B38041C Color Col. */
373
+ .macro cc
374
+ .word 0x4B38041C
375
+ .endm
376
+
377
+ /* NCLIP 8 0x4B400006 Normal clipping */
378
+ .macro nclip
379
+ .word 0x4B400006
380
+ .endm
381
+
382
+ /* AVSZ3 5 0x4B58002D Average of three Z values */
383
+ .macro avsz3
384
+ .word 0x4B58002D
385
+ .endm
386
+
387
+ /* AVSZ4 6 0x4B68002E Average of four Z values */
388
+ .macro avsz4
389
+ .word 0x4B68002E
390
+ .endm
391
+
392
+
393
+ ## Instructions which take an argument
394
+ # sf : arg is 1 bit wide
395
+ # mx : arg is 2 bit wide
396
+ # v : arg is 2 bit wide
397
+ # cv : arg is 2 bit wide
398
+ # lm : arg is 1 bit wide
399
+
400
+ /* MVMVA 8 0x4A400012 Multiply vector by matrix and vector addition. */
401
+ .macro mvmva sf, mx, v, cv, lm
402
+ .word 0x4A400012 | (\\sf & 0x1) << 19 | (\\mx & 0x3) << 17 | (\\v & 0x3) << 15 | (\\cv & 0x3) << 13 | (\\lm & 0x1) << 10
403
+ .endm
404
+
405
+ /* SQR 5 0x4AA00428 Square of vector */
406
+ .macro sqr sf
407
+ .word 0x4AA00428 | (\\sf & 0x1) << 19
408
+ .endm
409
+
410
+ /* OP 6 0x4B70000C Outer Product */
411
+ .macro op sf
412
+ .word 0x4B70000C | (\\sf & 0x1) << 19
413
+ .endm
414
+
415
+ /* GPF 6 0x4B90003D General purpose interpolation */
416
+ .macro gpf sf
417
+ .word 0x4B90003D | (\\sf & 0x1) << 19
418
+ .endm
419
+
420
+ /* GPL 5 0x4BA0003E general purpose interpolation */
421
+ .macro gpl sf
422
+ .word 0x4BA0003E | (\\sf & 0x1) << 19
423
+ .endm
424
+
425
+
426
+ ## Convenience macros
427
+
428
+ /* rtv0 - 0x4A486012 v0 * rotmatrix */
429
+ .macro rtv0
430
+ # .word 0x4A486012
431
+ MVMVA 1, 0, 0, 3, 0
432
+ .endm
433
+
434
+ /* rtv1 - 0x4A48E012 v1 * rotmatrix */
435
+ .macro rtv1
436
+ # .word 0x4A48E012
437
+ MVMVA 1, 0, 1, 3, 0
438
+ .endm
439
+
440
+ /* rtv2 - 0x4A496012 v2 * rotmatrix */
441
+ .macro rtv2
442
+ # .word 0x4A496012
443
+ MVMVA 1, 0, 2, 3, 0
444
+ .endm
445
+
446
+ /* rtir12 - 0x4A49E012 ir * rotmatrix */
447
+ .macro rtir12
448
+ # .word 0x4A49E012
449
+ MVMVA 1, 0, 3, 3, 0
450
+ .endm
451
+
452
+ /* rtir0 - 0x4A41E012 ir * rotmatrix */
453
+ .macro rtir0
454
+ # .word 0x4A41E012
455
+ MVMVA 0, 0, 3, 3, 0
456
+ .endm
457
+
458
+ /* rtv0tr - 0x4A480012 v0 * rotmatrix + tr vector */
459
+ .macro rtv0tr
460
+ # .word 0x4A480012
461
+ MVMVA 1, 0, 0, 0, 0
462
+ .endm
463
+
464
+ /* rtv1tr - 0x4A488012 v1 * rotmatrix + tr vector */
465
+ .macro rtv1tr
466
+ # .word 0x4A488012
467
+ MVMVA 1, 0, 1, 0, 0
468
+ .endm
469
+
470
+ /* rtv2tr - 0x4A490012 v2 * rotmatrix + tr vector */
471
+ .macro rtv2tr
472
+ # .word 0x4A490012
473
+ MVMVA 1, 0, 2, 0, 0
474
+ .endm
475
+
476
+ /* rtirtr - 0x4A498012 ir * rotmatrix + tr vector */
477
+ .macro rtirtr
478
+ # .word 0x4A498012
479
+ MVMVA 1, 0, 3, 0, 0
480
+ .endm
481
+
482
+ /* rtv0bk - 0x4A482012 v0 * rotmatrix + bk vector */
483
+ .macro rtv0bk
484
+ # .word 0x4A482012
485
+ MVMVA 1, 0, 0, 1, 0
486
+ .endm
487
+
488
+ /* rtv1bk - 0x4A48A012 v1 * rotmatrix + bk vector */
489
+ .macro rtv1bk
490
+ # .word 0x4A48A012
491
+ MVMVA 1, 0, 1, 1, 0
492
+ .endm
493
+
494
+ /* rtv2bk - 0x4A492012 v2 * rotmatrix + bk vector */
495
+ .macro rtv2bk
496
+ # .word 0x4A492012
497
+ MVMVA 1, 0, 2, 1, 0
498
+ .endm
499
+
500
+ /* rtirbk - 0x4A49A012 ir * rotmatrix + bk vector */
501
+ .macro rtirbk
502
+ # .word 0x4A49A012
503
+ MVMVA 1, 0, 3, 1, 0
504
+ .endm
505
+
506
+ /* ll - 0x4A4A6412 v0 * light matrix. Lower limit result to 0 */
507
+ .macro ll
508
+ # .word 0x4A4A6412
509
+ MVMVA 1, 1, 0, 3, 1
510
+ .endm
511
+
512
+ /* llv0 - 0x4A4A6012 v0 * light matrix */
513
+ .macro llv0
514
+ # .word 0x4A4A6012
515
+ MVMVA 1, 1, 0, 3, 0
516
+ .endm
517
+
518
+ /* llv1 - 0x4A4AE012 v1 * light matrix */
519
+ .macro llv1
520
+ # .word 0x4A4AE012
521
+ MVMVA 1, 1, 1, 3, 0
522
+ .endm
523
+
524
+ /* llv2 - 0x4A4B6012 v2 * light matrix */
525
+ .macro llv2
526
+ # .word 0x4A4B6012
527
+ MVMVA 1, 1, 2, 3, 0
528
+ .endm
529
+
530
+ /* llvir - 0x4A4BE012 ir * light matrix */
531
+ .macro llvir
532
+ # .word 0x4A4BE012
533
+ MVMVA 1, 1, 3, 3, 0
534
+ .endm
535
+
536
+ /* llv0tr - 0x4A4A0012 v0 * light matrix + tr vector */
537
+ .macro llv0tr
538
+ # .word 0x4A4A0012
539
+ MVMVA 1, 1, 0, 0, 0
540
+ .endm
541
+
542
+ /* llv1tr - 0x4A4A8012 v1 * light matrix + tr vector */
543
+ .macro llv1tr
544
+ # .word 0x4A4A8012
545
+ MVMVA 1, 1, 1, 0, 0
546
+ .endm
547
+
548
+ /* llv2tr - 0x4A4B0012 v2 * light matrix + tr vector */
549
+ .macro llv2tr
550
+ # .word 0x4A4B0012
551
+ MVMVA 1, 1, 2, 0, 0
552
+ .endm
553
+
554
+ /* llirtr - 0x4A4B8012 ir * light matrix + tr vector */
555
+ .macro llirtr
556
+ # .word 0x4A4B8012
557
+ MVMVA 1, 1, 3, 0, 0
558
+ .endm
559
+
560
+ /* llv0bk - 0x4A4A2012 v0 * light matrix + bk vector */
561
+ .macro llv0bk
562
+ # .word 0x4A4A2012
563
+ MVMVA 1, 1, 0, 1, 0
564
+ .endm
565
+
566
+ /* llv1bk - 0x4A4AA012 v1 * light matrix + bk vector */
567
+ .macro llv1bk
568
+ # .word 0x4A4AA012
569
+ MVMVA 1, 1, 1, 1, 0
570
+ .endm
571
+
572
+ /* llv2bk - 0x4A4B2012 v2 * light matrix + bk vector */
573
+ .macro llv2bk
574
+ # .word 0x4A4B2012
575
+ MVMVA 1, 1, 2, 1, 0
576
+ .endm
577
+
578
+ /* llirbk - 0x4A4BA012 ir * light matrix + bk vector */
579
+ .macro llirbk
580
+ # .word 0x4A4BA012
581
+ MVMVA 1, 1, 3, 1, 0
582
+ .endm
583
+
584
+ /* lc - 0x4A4DA412 v0 * color matrix, Lower limit clamped to 0 */
585
+ .macro lc
586
+ # .word 0x4A4DA412
587
+ MVMVA 1, 2, 3, 1, 1
588
+ .endm
589
+
590
+ /* lcv0 - 0x4A4C6012 v0 * color matrix */
591
+ .macro lcv0
592
+ # .word 0x4A4C6012
593
+ MVMVA 1, 2, 0, 3, 0
594
+ .endm
595
+
596
+ /* lcv1 - 0x4A4CE012 v1 * color matrix */
597
+ .macro lcv1
598
+ # .word 0x4A4CE012
599
+ MVMVA 1, 2, 1, 3, 0
600
+ .endm
601
+
602
+ /* lcv2 - 0x4A4D6012 v2 * color matrix */
603
+ .macro lcv2
604
+ # .word 0x4A4D6012
605
+ MVMVA 1, 2, 2, 3, 0
606
+ .endm
607
+
608
+ /* lcvir - 0x4A4DE012 ir * color matrix */
609
+ .macro lcvir
610
+ # .word 0x4A4DE012
611
+ MVMVA 1, 2, 3, 3, 0
612
+ .endm
613
+
614
+ /* lcv0tr - 0x4A4C0012 v0 * color matrix + tr vector */
615
+ .macro lcv0tr
616
+ # .word 0x4A4C0012
617
+ MVMVA 1, 2, 0, 0, 0
618
+ .endm
619
+
620
+ /* lcv1tr - 0x4A4C8012 v1 * color matrix + tr vector */
621
+ .macro lcv1tr
622
+ # .word 0x4A4C8012
623
+ MVMVA 1, 2, 1, 0, 0
624
+ .endm
625
+
626
+ /* lcv2tr - 0x4A4D0012 v2 * color matrix + tr vector */
627
+ .macro lcv2tr
628
+ # .word 0x4A4D0012
629
+ MVMVA 1, 2, 2, 0, 0
630
+ .endm
631
+
632
+ /* lcirtr - 0x4A4D8012 ir * color matrix + tr vector */
633
+ .macro lcirtr
634
+ # .word 0x4A4D8012
635
+ MVMVA 1, 2, 3, 0, 0
636
+ .endm
637
+
638
+ /* lev0bk - 0x4A4C2012 v0 * color matrix + bk vector */
639
+ .macro lev0bk
640
+ # .word 0x4A4C2012
641
+ MVMVA 1, 2, 0, 1, 0
642
+ .endm
643
+
644
+ /* lev1bk - 0x4A4CA012 v1 * color matrix + bk vector */
645
+ .macro lev1bk
646
+ # .word 0x4A4CA012
647
+ MVMVA 1, 2, 1, 1, 0
648
+ .endm
649
+
650
+ /* lev2bk - 0x4A4D2012 v2 * color matrix + bk vector */
651
+ .macro lev2bk
652
+ # .word 0x4A4D2012
653
+ MVMVA 1, 2, 2, 1, 0
654
+ .endm
655
+
656
+ /* leirbk - 0x4A4DA012 ir * color matrix + bk vector */
657
+ .macro leirbk
658
+ # .word 0x4A4DA012
659
+ MVMVA 1, 2, 3, 1, 0
660
+ .endm
661
+
662
+ /* sqr12 - 0x4AA80428 square of ir 1,19,12 */
663
+ # .macro sqr12
664
+ # # .word 0x4AA80428
665
+ # SQR 1
666
+ # .endm
667
+
668
+ /* sqr0 - 0x4AA80428 square of ir 1,31, 0 */
669
+ # .macro sqr0
670
+ # # .word 0x4AA80428
671
+ # SQR 1
672
+ # .endm
673
+
674
+ /* op12 - 0x4B78000C outer product 1,19,12 */
675
+ .macro op12
676
+ # .word 0x4B78000C
677
+ OP 1
678
+ .endm
679
+
680
+ /* op0 - 0x4B70000C outer product 1,31, 0 */
681
+ .macro op0
682
+ # .word 0x4B70000C
683
+ OP 0
684
+ .endm
685
+
686
+ /* gpf12 - 0x4B98003D general purpose interpolation 1,19,12 */
687
+ .macro gpf12
688
+ # .word 0x4B98003D
689
+ GPF 1
690
+ .endm
691
+
692
+ /* gpf0 - 0x4B90003D general purpose interpolation 1,31, 0 */
693
+ .macro gpf0
694
+ # .word 0x4B90003D
695
+ GPF 0
696
+ .endm
697
+
698
+ /* gpl12 - 0x4BA8003E general purpose interpolation 1,19,12 */
699
+ .macro gpl12
700
+ # .word 0x4BA8003E
701
+ GPL 1
702
+ .endm
703
+
704
+ /* gpl0 - 0x4BA0003E general purpose interpolation 1,31, 0 */
705
+ .macro gpl0
706
+ # .word 0x4BA0003E
707
+ GPL 0
708
+ .endm
709
+ """
710
+
711
+ _write("include/gte_macros.inc", gte_macros)