User Tools

Site Tools


kirby64_the_crystal_shards:geometry_blocks

This is an old revision of the document!


Geometry blocks

Kirby 64's “Geometry blocks” are containers holding display lists, vertices, transformation data, and texture scroll settings for a group of meshes. The high level structure of a geometry block is as follows (in order):

  1. HEADER
  2. VERTICES
  3. DISPLAY LISTS
  4. G_SETTIMG REFERENCES
  5. G_VTX REFERENCES
  6. DISPLAY LIST GROUP DEFINITIONS
  7. LAYOUT
  8. TEXTURE SCROLL SETTINGS
  9. UNKNOWN DATA

This section contains the header. Structure definition below.

struct GeometryBlockHeader
{
    /*0x00*/ segptr layout;      // segment-offset pointer to the LAYOUT section
    /*0x04*/ segptr texScroll;   // segment-offset pointer to the TEXTURE SCROLL section
    /*0x08*/ int    layoutMode;  // interpretation mode of the LAYOUT section
    /*0x0C*/ segptr imgRefs;     // segment-offset pointer to the G_SETTIMG REFERENCES section
    /*0x10*/ segptr vtxRefs;     // segment-offset pointer to the G_VTX REFERENCES section
    /*0x14*/ int    lenUnkData;  // defines length of the UNKNOWN DATA section
    /*0x18*/ segptr unkData;     // segment-offset pointer to the UNKNOWN DATA section
    /*0x1C*/ int    unk1C;       // unknown
};

VERTICES

This section simply contains an array of RSP vertices to be used by the geometry block's display lists.


DISPLAY LISTS

This section contains F3DEX2 display list commands. Instead of containing addresses, the address field of each G_SETTIMG command contains a bank-index pair referencing an image in ROM or RAM.


G_SETTIMG REFERENCES

This section is a zero-terminated array of segment-offset pointers to every G_SETTIMG command in the DISPLAY LISTS section. After a geometry block is loaded into memory, the engine uses this section to convert the G_SETTIMG commands' bank-index pairs to virtual addresses in place, loading images as necessary.


G_VTX REFERENCES

This section is a zero-terminated array of segment-offset pointers to every G_VTX command in the DISPLAY LISTS section. It does not seem to be used by the game.


DISPLAY LIST GROUP DEFINITIONS

This is an optional section that is enabled when using layout mode 0x18 (and possibly others). When enabled, it contains of a list of display list “groups”.

Each group is an array of the following structure:

struct GeoGroupMember
{
    /*0x00*/ int    marker;      // 0x00: start of group, 0x01: continue group, 0x04 end of group
    /*0x04*/ segptr displayList; /* segment-offset pointer to a display list in the DISPLAY LISTS section
                                    (NULL when marker is 0x04) */
};

LAYOUT

The interpretation of this section varies depending on the value of the layoutMode field in the HEADER section. Modes 0x13, 0x14, 0x17, 0x18, 0x1B and 0x1C are used by the game.

Layout structure for each mode:

  • 0x13: Unknown
  • 0x14: A zero-terminated array of segment-offset pointers to display lists in the DISPLAY LISTS section.
  • 0x17: An array of GeoTransformGfx structures.
  • 0x18: An array of GeoTransformGroup structures.
  • 0x1B: Unknown, only used for developer test level
  • 0x1C: Unknown, only used for developer test level
struct GeoTransformGfx  // Transform single display list
{
    int    command;
    segptr displayList; // segment-offset pointer to display list in the DISPLAY LISTS section
    vec3f  position;    // x, y, z position
    vec3f  rotation;    // x, y, z rotation
    vec3f  scale;       // x, y, z scale
};
struct GeoTransformGroup // Transform group of display lists
{
    int    command;
    segptr displayListGroup; /* segment-offset pointer to a display list group definition in the
                                DISPLAY LIST GROUP DEFINITIONS section */
    vec3f  position;         // x, y, z position
    vec3f  rotation;         // x, y, z rotation
    vec3f  scale;            // x, y, z scale
};

TEXTURE SCROLL SETTINGS

This is an optional section that is enabled when (?). When enabled, the engine uses this section to add G_DL branches and dynamic G_SETTILESIZE commands to RSP segment 0x0E. The display lists in the DISPLAY LISTS section may jump to these commands for texture scrolling effects.

This section contains four subsections (in order):

  1. HEADER
  2. UNKNOWN STRUCTURES
  3. LIST A
  4. LIST B

HEADER

struct TexScrollHeader
{
    /*0x04*/ u32    unk00;
    /*0x08*/ segptr listA; // segment-offset pointer to the LIST A section
    /*0x0C*/ segptr listB; // segment-offset pointer to the LIST B section
    /*0x10*/ u32    unk10;
};

UNKNOWN STRUCTURES

Contains structures referenced by LIST A and LIST B. Unknown definition.

LIST A

This section is an array of segment-offsets pointing to structures in the UNKNOWN STRUCTURES section. Terminated by 0x99999999.

LIST B

This section is an array of segment-offsets pointing to structures in the UNKNOWN STRUCTURES section. Terminated by 0x99999999.


UNKNOWN DATA

Unknown data. It looks like an array of bank-index pairs. The length of the array is defined in the HEADER section's lenUnkData field.

kirby64_the_crystal_shards/geometry_blocks.1569615680.txt.gz · Last modified: 2019/09/27 20:21 by shygoo