N64® Functions Menu

al - Audio Library Functions
gDP - DP GBI Macros
gdSP - General GBI Macros
gSP - SP GBI Macros
gt - Turbo Microcode RDP
gu - Graphics Utilities
Math - Math Functions
nuSys - NuSystem
os - N64 Operating System
sp - Sprite Library Functions
uh - Host to Target IO
64DD - N64 Disk Drive

Nintendo® Confidential

## gDPSetTile [macro]

Sets tile descriptor parameters.

Syntax

    #include <ultra64.h>  /* gbi.h */
    gDPSetTile(
            Gfx *gdl,
            u32 fmt,
            u32 siz,
            u32 line,
            u32 tmem,
            u32 tile,
            u32 palette,
            u32 cmt,
            u32 cms,
            u32 maskt,
            u32 masks,
            u32 shiftt,
            u32 shifts,
    gsDPSetTile(
            u32 fmt,
            u32 siz,
            u32 line,
            u32 tmem,
            u32 tile,
            u32 palette,
            u32 cmt,
            u32 maskt,
            u32 shiftt,
            u32 cms,
            u32 masks,
            u32 shifts )

Arguments

- gdl is the pointer to graphics display list.

- fmt is the texture image format:
  G_IM_FMT_RGBA (RGBA format)
  G_IM_FMT_YUV (YUV format)
  G_IM_FMT_CI (CI format)
  G_IM_FMT_IA (IA format)
  G_IM_FMT_I (I format)

- siz is the pixel component size:
  G_IM_SIZ_4b (4 bits/texel)
  G_IM_SIZ_8b (8 bits/texel)
  G_IM_SIZ_16b (16 bits/texel)
  G_IM_SIZ_32b (32 bits/texel)

- line is the size of one row (s axis) of the texture tile (9-bit precision, 0~511).

- tmem is the address of texture tile origin (9-bit precision, 0~511)

- tile is the index of tile descriptors for which parameters are being set (3-bit precision, 0~7).

- palette is the position of the palette for 4-bit color index texture (4-bit precision, 0~15).

- cms is the s-axis mirror, wrap and clamp flags
  G_TX_MIRROR (enable mirror operations)
  G_TX_NOMIRROR (disable mirror operations)
  G_TX_WRAP (enable wrap operations)
  G_TX_CLAMP (enable clamp operations)

- cmt is the t-axis mirror, wrap and clamp flags
  G_TX_MIRROR (enable mirror operations)
  G_TX_NOMIRROR (disable mirror operations)
  G_TX_WRAP (enable wrap operations)
  G_TX_CLAMP (enable clamp operations)

- masks is the s-axis mask (4-bit precision, 0~15)
  G_TX_NOMASK (do not mask, 0)
  numeric value n (mask, 1~15)

- maskt is the t-axis mask (4-bit precision, 0~15)
  G_TX_NOMASK (do not mask, 0)
  numeric value n (mask, 1~15)

- shifts is the s-coordinate shift value (for low-level detail texture, 4-bit precision, 0~15).
  G_TX_NOLOD (do not shift, 0)
  numeric value n (shift, 1~15)

- shiftt is the t-coordinate shift value (for low-level detail texture, 4-bit precision, 0~15).
  G_TX_NOLOD (do not shift, 0)
  numeric value n (shift, 1~15)

Explanation
Sets texture tile information. This function is used in multi-tile texture modes such as MIP-mapping, detail and sharpen. Think of the 8 tile descriptors as TMEM addresses describing each texture tile. Multiple tile descriptors can specify the same texture tile in TMEM. Each tile descriptor has a sequence of parameters which together describe the texture memory region.

To set a multi-tile mode, load a number of texture tiles by using any gDPLoadTexture* macro. Each texture tile is described by a tile descriptor which indicates the location in TMEM with its parameters (arguments). For example, a texture tile MIP-map pyramid is loaded by using the gDPLoadTextureBlock* macro or several gDPLoadTextureTile* macros. The minimum descriptor number, which indicates the highest level (largest map), and the maximum descriptor number, which indicates the lowest level (smallest map), are described by consecutive tile descriptors. The indexing of these tiles is controlled by the cycle type (see gDPSetCycleType), the maximum number of primitive tiles and MIP-map levels (see gSPTexture), the detail mode (see gDPSetTextureDetail), and whether LOD is on or off (see gDPSetTextureLOD). (For information about primitive tiles, see Section 13.7.2, "LOD Disabled" in the N64 Online Programming Manual).

To perform MIP mapping, the RDP must be in 2-cycle mode with LOD enabled. The index within a texture tile is based on the texel/pixel ratio calculated by the RDP for each pixel. Filtering into a MIP-map level is controlled by gDPSetTextureFilter. Interpolation between two MIP-map levels is controlled by setting the color combiner (CC) to the appropriate mode (see gDPSetCombineMode). In detail texture mode, the texture tile used to add detail in accordance with the magnification is specified with a primitive tile. The degree to which the detail texture is blended with the original texture is controlled by the LOD limit parameter set by gDPSetPrimColor (see gDPSet*Color).

Regarding the fmt argument:

G_IM_FMT_RGBA
  Each texel comprises four elements of information: RGB (red, green, blue) and alpha (opacity).
G_IM_FMT_YUV
  Each texel comprises a Y (intensity) component and a UV (color difference) component.
G_IM_FMT_CI
  Each texel is comprised of index information specifying palette data.
G_IM_FMT_IA
  Each texel is comprised of I (intensity) information and alpha information.
G_IM_FMT_I
  Each texel is a texture with only I information. Since this is extremely compact, it is useful when only a few colors are being used.

You can choose from among 10 different texture image formats. The table shows the valid combinations of format and size. Select the format that best suits the texture compression method and type.

| G_IM_SIZ_ (Size)
4b | 8b | 16b | 32b
G_IM_FMT_ (Format) | RGBA |  |  | X (5/5/5/1) | X (8/8/8/8)
YUV |  |  | X |
CI | X | X |  |
IA | X (3/1) | X (4/4) | X (8/8) |
I | X | X |  |

Regarding the tmem argument:

  Indicates the tile offset position.

Regarding the palette argument:

  This 8-bit index, which specifies an address in the high-half of TMEM, is comprised of the 4MSB (high-order 4-bit) palette position and the 4LSB (low-order 4-bit) color index.

Regarding the cms and cmt arguments:

  Multiple specifications can be made with a bit sum of the following flags:

  G_TX_MIRROR
    Enables mirroring. Mirror textures can be used for textures with axial symmetry, like a tree. Symmetric textures are an effective way to reduce texture volume.
  G_TX_NOMIRROR
    Disables mirroring.
  G_TX_WRAP
    Enables wrapping. A wrapped texture repeats a texel. The wrapping cycle can be specified by a mask.
  G_TX_CLAMP
    Enables clamping. A clamped texture repeats the edge texel color when sampling outside of the texture map. Clamping is performed at the boundary of the texture tile.

Regarding the masks and maskt arguments:

G_TX_NOMASK (0)
  No mask is used.
numeric value n (1~15)
  Specifies the wrap position with the value of n. The low-order n bits of the s,t texel coordinates are used for texture sampling.

Texture sampling utilizes the low-order n bits of the s,t texture coordinates. You would set to 5 to wrap a texture with a boundary of 32x32 (25x25). Set to 0 to perform clamping.

Regarding the shifts and shiftt arguments:

G_TX_NOLOD (0)
  No shifting is performed.
numeric value n (1~15)
  Shifts the s,t texel coordinate by n bits. This enables the sampling of low-level LOD maps and detail textures.

The values specified by shifts and shiftt (the shift parameter values) represent the amount by which the s,t coordinates are shifted to the left or to the right. This is used for the MIP-mapping, detail, and sharp mode settings. The values 0~10 are interpreted as right shifts, and the values 11~15 are interpreted as left shifts (see the table below).

Shift parameter value | Shift amount
0 | No shift
1 | >> 1
2 | >> 2
...
9 | >> 9
10 | >> 10
11 | << 5
12 | << 4
13 | << 3
14 | << 2
15 | << 1

For details about each argument, see Section 13.4, "Tile Attributes," in the N64 Online Programming Manual. For information about using this macro, see Section 13.5, "Tile Descriptor Loading."

Notes
Since each row of the texture tile occupies contiguous TMEM (64-bit) words, the row end is extended to achieve TMEM word alignment.

Also, note that operation is not currently guaranteed for G_IM_FMT_YUV (YUV format).

Example

    /* Various settings related to texture */
    // Set cycle type
    gDPSetCycleType(gp++, G_CYC_2CYCLE);
    // Set LOD/MIP map
    gDPSetTextureLOD(gp++, G_TL_TILE);
    // Set geometry pipeline mode
    gSPSetGeometryMode(gp++, G_ZBUFFER | G_CULL_BACK | G_LIGHTING | G_TEXTURE_GEN);
    // Set rendering mode
    gDPSetRenderMode(gp++, G_RM_PASS, G_RM_AA_ZB_OPA_SURF2);
    // Set color combiner mode
    gDPSetCombineMode(gp++, G_CC_HILITERGBDECALA, G_CC_HILITERGBA2);
    // Enable texture and specify scale
    gSPTexture(gp++, 0x07c0, 0x07c0, 0, G_TX_RENDERTILE, G_ON);
    /* Load texture block */
    gDPLoadTextureBlock_4b
    (gp++, I4spec, G_IM_FMT_I, 32, 32, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, 5, 5, G_TX_NOLOD, G_TX_NOLOD);
    /* Set texture tile descriptors */
    gDPSetTile(gp++, G_IM_FMT_I, G_IM_SIZ_4b, ((((32)>>1)+7)>>3), 0, 1, 0, G_TX_WRAP|G_TX_NOMIRROR, 5, G_TX_NOLOD, G_TX_WRAP|G_TX_NOMIRROR, 5, G_TX_NOLOD);

See Also
gDPSetBlendColor
gDPSetEnvColor
gDPSetFillColor
gDPSetFogColor
gDPSetPrimColor
gDPSetTextureDetail
gDPSetTextureFilter
gDPSetTextureLOD
gDPSetTextureLUT
gDPSetTexturePersp
gSPTexture

Revision History
2/1/99 Completely rewritten.

Nintendo® Confidential Warning: all information in this document is confidential and covered by a non-disclosure agreement. You are responsible for keeping this information confidential and protected. Nintendo will vigorously enforce this responsibility.
Copyright © 1998-1999
Nintendo of America Inc. All rights reserved
Nintendo and N64 are registered trademarks of Nintendo
Last Updated April, 1999