User Tools

Site Tools


super_mario_64:geometry_layout_commands

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
super_mario_64:geometry_layout_commands [2018/10/18 02:21]
AloXado320 [00: Branch and Store]
super_mario_64:geometry_layout_commands [2018/10/21 19:10]
David [14: Billboard Model and Translate (and Load Display List or Start Geo Layout)] Added documentation to the geo layout 0x14 command.
Line 16: Line 16:
 ===== Geometry Layout Commands ===== ===== Geometry Layout Commands =====
 ==== 00: Branch and Store ==== ==== 00: Branch and Store ====
-Branches to segmented address and stores 2 return addresses. ​This command is used only on one object ["Mr. Blizzard"​ from Cool, Cool Mountain]+Branches to segmented address and stores 2 return addresses.
  
 ''​00 00 00 00 [<color darkred>​SS SS SS SS</​color>​]''​ ''​00 00 00 00 [<color darkred>​SS SS SS SS</​color>​]''​
Line 89: Line 89:
 ---- ----
  
-==== 06: Unused ====+==== 06: Store Current Node Pointer To Table (Unused==== 
 + 
 +''​06 00 [<color darkred>​XX XX</​color>​]''​ 
 + 
 +Stores the pointer of the last node into the table at address (*0x8038BCAC). This table is usually empty except for the first entry (index 0), which holds the pointer to the node created by the geo layout 0x0F command. The size of the table is defined by the geo layout 0x08 command. 
 + 
 +| <color darkred>​X</​color>​ | Index in table to store pointer | 
 + 
 +  Example in a geometry layout: 
 +  0A 01 002D 0064 4E20 8029AA3C // Set camera frustum (FOV = 45, Near = 100, Far = 20000) 
 +  06 00 00 01 // Store pointer of the 0x0A command node to address ((*0x8038BCAC) + 4)
  
 ---- ----
  
-==== 07: Unused ====+==== 07: Set/OR/AND Node Flags (Unused==== 
 + 
 +''​06 [<color darkred>​OP</​color>​] [<color darkgreen>​VV VV</​color>​]''​ 
 + 
 +Does an operation on the flags of the current node. (Flags are at offset 0x02 of the GraphNode structure) 
 + 
 +| <color darkred>​OP</​color>​ | Operation (0 = Set flags to value, 1 = OR flags with value, 2 = AND flags with value) | 
 +| <color darkgreen>​V</​color>​ | Value | 
 + 
 +  Example in a geometry layout: 
 +  0A 01 002D 0064 4E20 8029AA3C // Set camera frustum (FOV = 45, Near = 100, Far = 20000) 
 +  07 00 00 01 // Set Node flags of 0x0A command to be 0x0001 
 +  07 01 01 00 // OR Node flags with 0x0100 
 +  07 02 00 01 // AND Node flags with 0x0001
  
 ---- ----
Line 102: Line 125:
 ''​08 00 00 [<color darkgrey>​AA</​color>​] [<color darkred>​XX XX</​color>​] [<color darkgreen>​YY YY</​color>​] [<color darkblue>​WW WW</​color>​] [<color purple>​HH HH</​color>​]''​ ''​08 00 00 [<color darkgrey>​AA</​color>​] [<color darkred>​XX XX</​color>​] [<color darkgreen>​YY YY</​color>​] [<color darkblue>​WW WW</​color>​] [<color purple>​HH HH</​color>​]''​
  
-| <color darkgrey>​A</​color>​ | Either 00 (mario faceor 0A (all other levels) |+| <color darkgrey>​A</​color>​ | Number of entries ​(minus 2to allocate in pointer table at address ​(*0x8038BCAC). Usually set to 0x0A for levels, and 0 for mario face. Used with the geometry layout 0x06 command.  ​|
 | <color darkred>​X</​color>​ | X position | | <color darkred>​X</​color>​ | X position |
 | <color darkgreen>​Y</​color>​ | Y position | | <color darkgreen>​Y</​color>​ | Y position |
Line 112: Line 135:
 ---- ----
  
-==== 09: ?? ==== +==== 09: Set Background Frustum Matrix ​==== 
-Only used in geo layout of levels.+Sets the frustum matrix for level backgrounds.
  
-''​09 00 00 [<color darkred>​AA</​color>​]''​+It is unknown if this command is actually necessary or not. You can remove this command from a level's geometry layout and it won't affect the background, and changing the scale value has no visible effect either.
  
-| <color darkred>​A</​color>​ | Always ​0x64 |+''​09 00 [<color darkred>​AA AA</​color>​]''​ 
 + 
 +| <color darkred>​A</​color>​ | Scale of near plane, usually set to 0x64. Gets converted to a float and then divided by 100.0f ​|
  
 Length: 4 Length: 4
 +
 +<code c>
 +/* 
 +  Note: This is a simplified version of the code to explain what the 0x09 command does. 
 +  It is not a 1 to 1 translation of the actual source code.
 +
 +  All addresses are from the US ROM.
 +*/
 +
 +void proc_8027BA98(struct GraphNode_Geo09* geo09_node)
 +{
 +  if(geo09_node->​children != 0)
 +  {
 +    struct GraphNode_Geo08* screenRenderArea = 0x8032DEF0;
 +
 +    // These variables come from the geo layout 0x08 command.
 +    short x_pos = (short)screenRenderArea->​_0x16;​
 +    short y_pos = (short)screenRenderArea->​_0x18;​
 +    short width = (short)screenRenderArea->​_0x1A;​
 +    short height = (short)screenRenderArea->​_0x1C;​
 +
 +    // Near scale is the parameter you set with the 0x09 command.
 +    float nearScale = (float)geo09_node->​_0x14;​
 +
 +    // Reserve 0x40 bytes to store result matrix.
 +    Mtx* m = proc_80278F2C(0x40);​
 +
 +    // Calculate frustum matrix
 +    guFrustum(
 +      m, // Pointer to 4x4 matrix resulting from calculation
 +      ((x_pos - width) / 2.0f) * nearScale, // Near plane'​s lower-left x coordinate
 +      ((x_pos + width) / 2.0f) * nearScale, // Near plane'​s upper-right x coordinate
 +      ((y_pos + height) / 2.0f) * nearScale, // Near plane'​s lower-left y coordinate
 +      ((y_pos - height) / 2.0f) * nearScale, // Near plane'​s upper-right y coordinate
 +      -2.0f, // Distance from viewpoint to near clipping plane
 +      2.0f, // Distance from viewpoint to far clipping plane
 +      1.0f // Scale for matrix elements
 +    );
 +
 +    int** ptrToMasterDL = 0x8033B06C;
 +
 +    // Add Fast3D cmd 0xB4 (G_RDPHALF_1) to master display list
 +    *((*ptrToMasterDL) + 0) = 0xB4000000;
 +    *((*ptrToMasterDL) + 4) = 0x0000FFFF;
 +
 +    *ptrToMasterDL += 8; // Move by 8 bytes.
 +
 +    // Add matrix command to master display list to process the matrix '​m'​.
 +    // Parameters used: G_MTX_PUSH and G_MTX_LOAD
 +    *((*ptrToMasterDL) + 0) = 0x01030040;
 +    *((*ptrToMasterDL) + 4) = m & 0x1FFFFFFF;
 +
 +    *ptrToMasterDL += 8; // Move by 8 bytes.
 +
 +    proc_8027DEA8(geo09_node->​children);​ // Process children of this GeoNode
 +  }
 +}</​code>​
  
 ---- ----
Line 239: Line 321:
  
 ---- ----
-==== 13: Load Display List ==== +==== 11: Translate Node (and Load Display List or Start Geo Layout) ==== 
-Loads display list with drawing layer and offsets the model on X/Y/Z axis.+Applies translation to the child nodes, and a display list if one is specified. You can start a geometry layout with this command to set the offset for the entire model. You cannot start a geometry layout and load a display list at the same time, as it will cause the game to freeze (white-screen). 
 + 
 + 
 + 
 +''​11 [<color orange>​B</​color>​][<​color lightgrey>​L</​color>​] [<color darkred>​XX XX</​color>​] [<color darkgreen>​YY YY</​color>​] [<color darkblue>​ZZ ZZ</​color>​] {<color purple>​AA AA AA AA</​color>​}''​ 
 + 
 +| <color orange>​B</​color>​ | Include last 4 bytes if set to 8 (command will be C bytes long instead of 8) | 
 +| <color darkgrey>​L</​color>​ | Drawing layer if <color orange>​B</​color>​ is set, otherwise will always be zero | 
 +| <color darkred>​X</​color>​ | X translation offset (s16) | 
 +| <color darkgreen>​Y</​color>​ | Y translation offset (s16) | 
 +| <color darkblue>​Z</​color>​ | Z translation offset (s16) | 
 +| <color purple>​A</​color>​ | Segmented address with display list if <color orange>​B</​color>​ is set. \\ Also creates a joint of some kind? (Does not work with animations?​) | 
 + 
 +Length: 8-C (variable) 
 + 
 +Note: You can't just use the 8-byte version of 0x11 command just anywhere. It seems like the command needs a joint in it's parent node(s) for it to work properly (created from geo layout commands 0x11, 0x12, and 0x13). 
 + 
 +  0B000000 
 +  04000000 
 +    11 00 0000 0100 0000 // This will cause a crash 
 +    04000000 
 +      15 01 00 00 0700A290 
 +    05000000 
 +  05000000 
 +  01000000 
 +   
 +  0B000000 
 +  04000000 
 +    11 80 0000 0100 0000 00000000 // This will work, since it creates a joint. 
 +    04000000 
 +      15 01 00 00 0700A290 
 +    05000000 
 +  05000000 
 +  01000000 
 +   
 +  11 00 0000 0100 0000 // This will also work, since it is starting the geo layout. 
 +  04000000 
 +      15 01 00 00 0700A290 
 +  05000000 
 +  01000000 
 +   
 +  0B000000 
 +  04000000 
 +    ​13 01 0000 0000 0000 00000000 
 +    04000000 
 +      11 00 0000 0100 0000 // This will also work, since there is a joint above it. 
 +      04000000 
 +        15 01 00 00 0700A290 
 +      05000000 
 +    05000000 
 +  05000000 
 +  01000000 
 + 
 +---- 
 +==== 12Rotate Node (and Load Display List or Start Geo Layout) ==== 
 +Applies rotation to the child nodes, and a display list if one is specified. You can start a geometry layout with this command to set the rotation for the entire model. You cannot start a geometry layout and load a display list at the same time, as it will cause the game to freeze (white-screen). 
 + 
 +''​12 [<color orange>​B</​color>​][<​color lightgrey>​L</​color>​] [<color darkred>​RX RX</​color>​] [<color darkgreen>​RY RY</​color>​] [<color darkblue>​RZ RZ</​color>​] {<color purple>​AA AA AA AA</​color>​}''​ 
 + 
 +| <color orange>​B</​color>​ | Include last 4 bytes if set to 8 (command will be C bytes long instead of 8) | 
 +| <color darkgrey>​L</​color>​ | Drawing layer if <color orange>​B</​color>​ is set, otherwise will always be zero | 
 +| <color darkred>​RX</​color>​ | X rotation (s16) | 
 +| <color darkgreen>​RY</​color>​ | Y rotation (s16) | 
 +| <color darkblue>​RZ</​color>​ | Z rotation (s16) | 
 +| <color purple>​A</​color>​ | Segmented address with display list if <color orange>​B</​color>​ is set.\\ Also creates a joint of some kind? (Does not work with animations?​) | 
 + 
 +Length: 8-C (variable) 
 + 
 +Note: You can't just use the 8-byte version of 0x12 command just anywhere. It seems like the command needs a joint in it's parent node(s) for it to work properly (created from geo layout commands 0x11, 0x12, and 0x13). 
 + 
 +(see geo layout command 0x11 for examples) 
 + 
 +---- 
 +==== 13: Load Display List With Offset ​==== 
 +Loads display list with drawing layer and offsets the model and the node's children ​on X/Y/Z axis.
  
 ''​13 [<color darkgray>​LL</​color>​] [<color darkred>​XX XX</​color>​] [<color darkgreen>​YY YY</​color>​] [<color darkblue>​ZZ ZZ</​color>​] [<color purple>​AA AA AA AA</​color>​]''​ ''​13 [<color darkgray>​LL</​color>​] [<color darkred>​XX XX</​color>​] [<color darkgreen>​YY YY</​color>​] [<color darkblue>​ZZ ZZ</​color>​] [<color purple>​AA AA AA AA</​color>​]''​
Line 254: Line 410:
 ---- ----
  
-==== 14: Billboard Model ==== +==== 14: Billboard Model and Translate (and Load Display List or Start Geo Layout) ​==== 
-Billboards ​the model without needing the use of 0x21 in the behavior script.+Almost identical with the geometry layout 0x11 command, except that it will billboard the node and it's children ​without needing the use of 0x21 in the behavior script. You can start a geometry layout with this command to billboard and set the offset for the entire model. You cannot start a geometry layout and load a display list at the same time, as it will cause the game to freeze (white-screen).
  
-''​14 ​00 00 00 00 00 00 00''​+''​14 ​[<color orange>​B</​color>​][<​color lightgrey>​L</​color>​] [<color darkred>​XX XX</​color>​] [<color darkgreen>​YY YY</​color>​] [<color darkblue>​ZZ ZZ</​color>​] {<color purple>​AA AA AA AA</​color>​}''​
  
-Length: 8+| <color orange>​B</​color>​ | Include last 4 bytes if set to 8 (command will be C bytes long instead of 8) | 
 +| <color darkgrey>​L</​color>​ | Drawing layer if <color orange>​B</​color>​ is set, otherwise will always be zero | 
 +| <color darkred>​X</​color>​ | X translation offset (s16) | 
 +| <color darkgreen>​Y</​color>​ | Y translation offset (s16) | 
 +| <color darkblue>​Z</​color>​ | Z translation offset (s16) | 
 +| <color purple>​A</​color>​ | Segmented address with display list if <color orange>​B</​color>​ is set. \\ Also creates a joint of some kind? (Does not work with animations?​) | 
 + 
 +Length: 8-C (variable)
  
 ---- ----
super_mario_64/geometry_layout_commands.txt · Last modified: 2019/11/03 14:23 by jesusyoshi54