User Tools

Site Tools


kirby64_the_crystal_shards:geometry_blocks

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. ENTRY POINTS
  7. LAYOUTS
  8. TEXTURE SCROLL SETTINGS
  9. TEXTURE SCROLL DATA BLOCKS
  10. ANIMATION REFERENCES

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    numAnimations;  // defines length of the ANIMARION REFS section
    /*0x18*/ segptr Animations;     // segment-offset pointer to the ANIMATION REFS section
    /*0x1C*/ int    lenLayout;      // length of the Layout section
};

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 is used by the game and can be left empty.


ENTRY POINTS

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 EntryPoint
{
    /*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) */
};

Sometimes this is replaced simply by an array of display lists.

struct DisplayListArray
{
    /*0x00*/ segptr[] displayList; /* segment-offset pointer to a display list in the DISPLAY LISTS section*/
};

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. The layoutMode is interpreted bitwise, with the above modes being the only ones used by the game.

Layout structure for each mode:

  • 0x13: No layout, instead the layout pointer references a display list.
  • 0x14: No layout, instead a pointer to a DisplayListArray thats zero terminated.
  • 0x17: An array of GeoTransformGroup structures. Pointer goes to single display list.
  • 0x18: An array of GeoTransformGroup structures. Pointer goes to Entry Point. Length of segptr array is one.
  • 0x1B: An array of GeoTransformGroup structures. Pointer goes to DisplayListArray. Length of segptr array is two.
  • 0x1C: An array of GeoTransformGroup structures. Pointer goes to Entry Point. Length of segptr array is two.
struct GeoTransformGroup // Transform group of display lists
{
    u16    flag;
    u16    command;
    union{
    segptr displayListGroup; // segment-offset pointer to an entry point
    segptr EntryPoint;
    segptr DisplayListPair;
    };
    vec3f  position;         // x, y, z position
    vec3f  rotation;         // x, y, z rotation radians
    vec3f  scale;            // x, y, z scale
};

A command of 0 is used to start a layout, and a command of 12 is used to end it. If the msb of the Display List of Entry Point pointer is set, afterwards another series of layouts will be used for environment effects. These environment effects dont have any pointers but are just placements of Loc, Rot, Scale.


TEXTURE SCROLL SETTINGS

This is an optional section that is enabled when a pointer exists in the Geo Block Header. 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 three subsections (in order):

  1. Main Header
  2. ScrollStruct
  3. Sub Headers

MAIN HEADER

The texture scroll header is an array of segptrs terminated by an 0x99999999. Each segptr in this section points to a subheader.

SUB HEADER

Each subheader is an array of segptrs to texture scroll structs. Each sub header is terminated by an 0x99999999.

TEXTURE SCROLLS

This section is an array of uvScrollData structs each pointed to by an item in the subheader arrays. Following this uvScrollData struct is an optional bank-index list to textures which is also terminated by 0x9999.

struct uvScrollData {
    ushort field_0x0;
    byte fmt1;
    byte siz1;
    uint * textures;
    ushort stretch;
    ushort sharedOffset;
    ushort t0_w;
    ushort t0_h;
    int halve;
    float t0_xShift;
    float t0_yShift;
    float xScale;
    float yScale;
    float field_0x24;
    float field_0x28;
    pointer palettes;
    ushort flags;
    byte fmt2;
    byte siz2;
    ushort w2;
    ushort h2;
    ushort t1_w;
    ushort t1_h;
    float t1_xShift;
    float t1_yShift;
    float field_0x44;
    float field_0x48;
    int field_0x4c;
    struct color prim;
    byte primLODFrac;
    byte field_0x55;
    byte field_0x56;
    undefined field_0x57;
    struct color env;
    struct color blend;
    struct color light1;
    struct color light2;
    int field_0x68;
    int field_0x6c;
    int field_0x70;
    int field_0x74;
};

ANIMATION REFS

Animations references are an array of bank-index pairs. The length of the array is defined in the HEADER section's numAnimations field. When needed, the data for the animation are dma'd by the games file system based on the bank index pair listed. For info on animations see the animations page.

kirby64_the_crystal_shards/geometry_blocks.txt · Last modified: 2020/08/18 15:54 by jesusyoshi54