gDPLoadTextureTile_4b [Macro]

Loads part of a 4-bit texture image

Syntax

#include <ultra64.h>        /* gbi.h */
gDPLoadTextureTile_4b(
        Gfx *gdl,
        u32 timg, 
        u32 fmt, 
        u32 width,
        u32 height, 
        u32 uls,
        u32 ult,
        u32 lrs,
        u32 lrt, 
        u32 pal, 
        u32 cms,
        u32 cmt, 
        u32 masks,
        u32 maskt, 
        u32 shifts,
        u32 shiftt )
gsDPLoadTextureTile_4b(
        u32 timg, 
        u32 fmt, 
        u32 width,
        u32 height, 
        u32 uls,
        u32 ult,
        u32 lrs,
        u32 lrt, 
        u32 pal, 
        u32 cms,
        u32 cmt, 
        u32 masks,
        u32 maskt, 
        u32 shifts,
        u32 shiftt )

Arguments

gdl
Display list pointer
 
timg
Address of the texture image (64-bit alignment)
 
fmt
Texture image format:
G_IM_FMT_CI (CI format)
G_IM_FMT_IA (IA format)
G_IM_FMT_I (I format)
 
width
Overall width of texture image (1-4096)
 
height
Overall height of texture image (1-4096)
 
uls
Texture tile's upper-left s coordinate (10.2, 0.0-1023.75)
 
ult
Texture tile's upper-left t coordinate (10.2, 0.0-1023.75)
 
lrs
Texture tile's lower right s coordinate (10.2, 0.0-1023.75)
 
lrt
Texture tile's lower-right t coordinate (10.2, 0.0-1023.75)
 
pal
Location of palette for 4-bit color index texture (4-bit precision, 0-15)
 
cms
s-axis mirror, no-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
t-axis mirror, no-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
s-axis mask (4-bit precision, 0-15)
G_TX_NOMASK (do not mask, 0)
numeric value n (mask, 1-15)
 
maskt
t-axis mask (4-bit precision, 0-15)
G_TX_NOMASK (do not mask, 0)
numeric value n (mask, 1-15)
 
shifts
s-coordinate shift value (4-bit precision, 0-15)
G_TX_NOLOD (do not shift, 0)
numeric value (shift, 1-15)
 
shiftt
t-coordinate shift value (4-bit precision, 0-15)
G_TX_NOLOD (do not shift, 0)
numeric value n(shift, 1-15)

Description

Loads part of a 4-bit texture from DRAM into texture memory (TMEM). The size is implicitly 4 bits, so no size argument is included. This macro can be used to cut out an arbitrary square region from a large texture in DRAM and load that region into TMEM.

This macro is actually comprised of a number of 64-bit GBI commands. Thus, if you need to find out the exact size of the display list, you need to consider how many GBI commands it is comprised of.

Regarding the fmt argument

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 3 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
G_IM_FMT_
(Format)
CI X
IA X
(3/1)
I X


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 (25 X 25). 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). The value 11 corresponds to (<<5), 12 corresponds to (<<4), ..., and 15 corresponds to (<<1), and shift parameter value 0 is for tile 1, value 1 is for tile 2, value 2 is for tile 4, and so on.
 
Normally, use G_TX_NOLOD. Also, if numeric value n is used, see gDPSetTile for more information.

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

Consider a single-detail level (32x16). For the six levels of a MIP map pyramid (32x32, 16x16, 8x8, 4x4, 2x2, and 1x1), assume that the tile descriptor indicating each level have been loaded into TMEM (tile descriptor 1 indicates 32x32, tile descriptor 2 indicates 16x16, ..., and tile descriptor 6 indicates 1x1). When detail mode is enabled by gDPSetTextureDetail, tile descriptor 0 (primitive tile=0) specifies the 32x16 detail level by a 15 (<<1) shift along the s,t axis. This maps a 2x2 detail texel to a single base texel according to the magnification rate. For details, see Section 13.7.5.1, "Detail Texture," in the N64 Programming Manual.

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

Note

The addresses of the pixels at the four corners of the tile must be byte-aligned.

Also, regarding the 4-bit texture data, there is no problem if the width is an even number, but if it is an odd number, then you must prepare 1 bit of dummy data and make sure the per-line bit size is a multiple of 8.

See Also

gDPLoadTextureBlock, gDPLoadTextureBlock_4b, gDPLoadTextureTile, gDPLoadTLUT_pal16, gDPSetTextureDetail, guLoadTextureBlockMipMap, rgb2c

Revision History

02/01/99 Completely rewritten.
03/31/99 Modified the Description.