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):
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 };
This section simply contains an array of RSP vertices to be used by the geometry block's 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.
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.
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.
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*/ };
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:
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.
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):
The texture scroll header is an array of segptrs terminated by an 0x99999999. Each segptr in this section points to a subheader.
Each subheader is an array of segptrs to texture scroll structs. Each sub header is terminated by an 0x99999999.
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; };
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.