===== Extreme-G GFX/Collision Commands =====
Extreme-G uses high level commands to define level models' GFX and collision data.
----
==== 00 end_submesh ====
''00''
Presumably pushes the address of the current display list to some array and ends the current display list.
Emits:
gsSPEndDisplayList()
----
==== 01 vertex_list ====
''01 [NN] [XX XX] [YY YY] [ZZ ZZ] [TI] [RR] [GG] [BB] [...]''
Defines a list of vertices to be used by ''tri1'' and ''tri2'' commands.
''TI'' indexes the level's texture coordinate table to obtain the vertices' S and T texture coordinate values.
^Parameter^Description^
| ''NN'' | Number of vertices |
| ''XXXX'' | X coordinate (signed) |
| ''YYYY'' | Y coordinate (signed) |
| ''ZZZZ'' | Z coordinate (signed) |
| ''TI'' | Texture coordinate index |
| ''RR'' | Vertex color red channel |
| ''GG'' | Vertex color green channel |
| ''BB'' | Vertex color blue channel |
| ... | ... more vertices |
Emits:
gsSPVertex(..., NN)
----
==== 02 level_texture ====
''02 [II]''
Loads a CI8 or CI4 texture into TMEM.
''II'' indexes the level's texture meta table to obtain the texture's CI/TLUT addresses, format, and dimensions.
Texture data is obtained from the level's texture file.
^Parameter^Description^
| ''II'' | Level texture index |
Emits (if the current palette needs to be updated):
gsDPSetTextureImage(...)
gsDPTileSync()
gsDPSetTile(...)
gsSPLoadSync()
gsDPLoadTLUT(...)
gsSPPipeSync()
Emits:
gsDPSetTextureImage(...)
gsDPSetTile(...)
gsDPLoadSync()
gsDPLoadBlock(...)
gsDPPipeSync()
gsDPSetTile(...)
gsDPSetTileSize(...)
----
==== 03 set_primcolor ====
''03 [RR] [GG] [BB]''
Sets the RDP's primcolor register.
Emits:
gsDPSetPrimColor(0, 0, 0, RR, GG, BB)
----
==== 04 tri1 ====
''04 [-aaaaabb] [bbbccccc]'' (bitwise)
Renders a single triangle.
^Parameter^Description^
| ''aaaaa'' | RSP vertex index 0 |
| ''bbbbb'' | RSP vertex index 1 |
| ''ccccc'' | RSP vertex index 2 |
Emits:
gsSP1Triangle(aaaaa, bbbbb, ccccc, 0)
----
==== 05 tri2 ====
''05 [-aaaaabb] [bbbccccc] [-dddddee] [eeefffff]'' (bitwise)
Renders two triangles.
^Parameter^Description^
| ''aaaaa'' | RSP vertex index 0 |
| ''bbbbb'' | RSP vertex index 1 |
| ''ccccc'' | RSP vertex index 2 |
| ''ddddd'' | RSP vertex index 3 |
| ''eeeee'' | RSP vertex index 4 |
| ''fffff'' | RSP vertex index 5 |
Emits:
gsSP2Triangles(aaaaa, bbbbb, ccccc, ddddd, eeeee, fffff, 0)
----
==== 06 setcombine0 ====
''06''
Emits:
gsDPPipeSync()
gsDPSetCombineMode(G_CC_MODULATERGBDECALA, G_CC_PASS2) // FC127FFF FFFFF238
----
==== 07 setcombine1 ====
''07''
Emits:
gsDPPipeSync()
gsDPSetCombineMode(PRIMITIVE, 0, SHADE, 0, 0, 0, 0, 1, G_CC_PASS2) // FC327FFF FFFFFC38
----
==== 08 collision_vertex_list ====
''08 [NN] [XX XX] [YY YY] [ZZ ZZ] [...]''
Defines a list of collision vertices.
^Parameter^Description^
| ''NN'' | Number of vertices |
| ''XX'' | X position |
| ''YY'' | Y position |
| ''ZZ'' | Z position |
| ... | ... More vertices |
----
==== 09 update_vertex_texcoord ====
''09 [VI] [TI]''
Updates a single vertex's S and T texture coordinate values in the RSP's vertex buffer.
''TI'' indexes the level's texture coordinate table.
^Parameter^Description^
| ''VI'' | RSP vertex index |
| ''TI'' | Texture coordinate index |
Emits:
gsSPModifyVertex(VI, G_MWO_POINT_ST, ((table[TI].s / 2) << 16) | (table[TI].t / 2))
----
==== 0A unknown_dl ====
''0A''
Jump to some display list, unknown purpose. The address of the display list is obtained from 801712E8.
Emits:
gsSPDisplayList(...)
----
==== 0B setcombine2 ====
''0B''
Emits:
gsDPSetCombineMode(PRIMITIVE, 0, SHADE, 0, 0, 0, 0, 1, G_CC_PASS2) // FC327FFF FFFFFC38
This command seems the same as command 07 but without the pipesync.
----
==== 0C global_texture ====
''0C [II]''
Loads a CI8 texture into TMEM. ''II'' indexes the table in the "global texture" bank to obtain the texture's CI/TLUT addresses, dimensions, and data.
^Parameter^Description^
| ''II''| Global texture index |
Emits (if the current palette needs to be updated):
gsDPSetTextureImage(...)
gsDPTileSync()
gsDPSetTile(...)
gsSPLoadSync()
gsDPLoadTLUT(...)
gsSPPipeSync()
Emits:
gsDPSetTextureImage(...)
gsDPSetTile(...)
gsDPLoadSync()
gsDPLoadBlock(...)
gsDPPipeSync()
gsDPSetTile(...)
gsDPSetTileSize(...)
----
==== 0D common_texture ====
''0D [II]''
Loads a CI8 texture into TMEM. ''II'' indexes the table in the level's "common texture" bank to obtain the texture's CI/TLUT addresses, dimensions, and data.
^Parameter^Description^
| ''II'' | Common texture index |
Emits (if the current palette needs to be updated):
gsDPSetTextureImage(...)
gsDPTileSync()
gsDPSetTile(...)
gsSPLoadSync()
gsDPLoadTLUT(...)
gsSPPipeSync()
Emits:
gsDPSetTextureImage(...)
gsDPSetTile(...)
gsDPLoadSync()
gsDPLoadBlock(...)
gsDPPipeSync()
gsDPSetTile(...)
gsDPSetTileSize(...)
----
==== 0E nop0 ====
(no operation)
----
==== 0F nop1 ====
(no operation)
----
===== Assembly Information =====
* The function responsible for loading a level and parsing these commands is at 8004F954.
* The jump table for the parser's switch statement is at 8004BA98.
Assembly location of each command:
^ Command ^ ASM Location ^
| 00: end_submesh | 800518FC |
| 01: vertex_list | 8004FF70 |
| 02: level_texture | 800500B8 |
| 03: set_primcolor | 80050AE8 |
| 04: tri1 | 80050B34 |
| 05: tri2 | 80050B84 |
| 06: setcombine0 | 80050C18 |
| 07: setcombine1 | 80050C40 |
| 08: collision_vertex_list | 80050C6C |
| 09: update_vertex_texcoord | 80050D44 |
| 0A: unknown_dl | 80050DBC |
| 0B: setcombine2 | 80050DDC |
| 0C: global_texture | 80050E20 |
| 0D: common_texture | 8005136C |
| 0E: nop0 | 8004FF3C |
| 0F: nop1 | 8004FF3C |