DLMacro

# Display List Descriptive Macros

## Description

These macros pack the geometry command parameters. Parameters with word counts of 1 are defined.

Macros | Corresponding API
GX_PACK_OP(op1, op2, op3, op4) | `Packs command code in u32` type
GX_PACK_SWAPBUFFERS_PARAM(am, zw) | G3*_SwapBuffers
GX_PACK_MTXMODE_PARAM(mode) | G3*_MtxMode
GX_PACK_POPMTX_PARAM(num) | G3*_PopMtx
GX_PACK_STOREMTX_PARAM(num) | G3*_StoreMtx
GX_PACK_RESTOREMTX_PARAM(num) | G3*_RestoreMtx
GX_PACK_LIGHTVECTOR_PARAM(lightID, x, y, z) | G3*_LightVector
GX_PACK_DIFFAMB_PARAM(diffuse, ambient, IsSetVtxColor) | G3*_MaterialColorDiffAmb
GX_PACK_SPECEMI_PARAM(specular, emission, IsShininess) | G3*_MaterialColorSpecEmi
GX_PACK_POLYGONATTR_PARAM(light, polyMode, cullMode, polygonID, alpha, misc) | G3*_PolygonAttr
GX_PACK_BEGIN_PARAM(primitive) | G3*_Begin
GX_PACK_COLOR_PARAM(rgb) | G3*_Color
GX_PACK_NORMAL_PARAM(x, y, z) | G3*_Normal
GX_PACK_VTX10_PARAM(x, y, z) | G3*_Vtx10
GX_PACK_VTXXY_PARAM(x, y) | G3*_VtxXY
GX_PACK_VTXXZ_PARAM(x, z) | G3*_VtxXZ
GX_PACK_VTXYZ_PARAM(y, z) | G3*_VtxYZ
GX_PACK_VTXDIFF_PARAM(x, y, z) | G3*_VtxDiff
GX_PACK_TEXCOORD_PARAM(s, t) | G3*_TexCoord
GX_PACK_TEXIMAGE_PARAM(texFmt, texGen, s, t, repeat, flip, pltt0, addr) | G3*_TexImageParam
GX_PACK_TEXPLTTBASE_PARAM(addr, texFmt) | G3*_TexPlttBase
GX_PACK_VIEWPORT_PARAM(x1, y1, x2, y2) | G3*_ViewPort
GX_PACK_VECTORTEST_PARAM(x, y, z) | G3*_VectorTest

## Definition of macros

    #define GX_PACK_OP(op1, op2, op3, op4) \
        ((u32)((op1) | ((op2) << 8) | ((op3) << 16) | ((op4) << 24)))
    #define GX_PACK_SWAPBUFFERS_PARAM(am, zw) \
        ((u32) (((am) << REG_G3_SWAP_BUFFERS_XS_SHIFT) | \
                ((zw) << REG_G3_SWAP_BUFFERS_DP_SHIFT)))
    #define GX_PACK_MTXMODE_PARAM(mode)    ((u32) ((mode) << REG_G3_MTX_MODE_M_SHIFT))
    #define GX_PACK_POPMTX_PARAM(num)      ((u32) (num))
    #define GX_PACK_STOREMTX_PARAM(num)    ((u32) (num))
    #define GX_PACK_RESTOREMTX_PARAM(num)  ((u32) (num))
    #define GX_PACK_LIGHTVECTOR_PARAM(lightID, x, y, z)        \
        ((u32)GX_VECFX10((x), (y), (z))                      | \
         ((u32)(lightID) << REG_G3_LIGHT_VECTOR_LNUM_SHIFT))
    #define GX_PACK_LIGHTCOLOR_PARAM(lightID, rgb)                   \
        ((u32)((rgb)                                               | \
               ((u32)(lightID) << REG_G3_LIGHT_COLOR_LNUM_SHIFT)))
    #define GX_PACK_DIFFAMB_PARAM(diffuse, ambient, IsSetVtxColor)   \
        ((u32)((diffuse)                                           | \
               ((ambient) << REG_G3_DIF_AMB_AMBIENT_RED_SHIFT)     | \
               ((IsSetVtxColor != FALSE) << REG_G3_DIF_AMB_C_SHIFT)))
    #define GX_PACK_SPECEMI_PARAM(specular, emission, IsShininess)   \
        ((u32)((specular)                                          | \
               ((emission) << REG_G3_SPE_EMI_EMISSION_RED_SHIFT)   | \
               ((IsShininess != FALSE) << REG_G3_SPE_EMI_S_SHIFT)))
    #define GX_PACK_POLYGONATTR_PARAM(light, polyMode, cullMode, polygonID, alpha, misc) \
        ((u32)(((light) << REG_G3_POLYGON_ATTR_LE_SHIFT)     | \
               ((polyMode) << REG_G3_POLYGON_ATTR_PM_SHIFT)  | \
               ((cullMode) << REG_G3_POLYGON_ATTR_BK_SHIFT)  | \
               (misc)                                        | \
               ((polygonID) << REG_G3_POLYGON_ATTR_ID_SHIFT) | \
               ((alpha) << REG_G3_POLYGON_ATTR_ALPHA_SHIFT)))
    #define GX_PACK_BEGIN_PARAM(primitive)                 \
        ((u32)((primitive) << REG_G3_BEGIN_VTXS_TYPE_SHIFT))
    #define GX_PACK_COLOR_PARAM(rgb)       ((u32)(rgb))
    #define GX_PACK_NORMAL_PARAM(x, y, z)  ((u32)GX_VECFX10((x), (y), (z)))
    #define GX_PACK_VTX10_PARAM(x, y, z)   ((u32)GX_VECVTX10((x), (y), (z)))
    #define GX_PACK_VTXXY_PARAM(x, y)      (GX_FX16PAIR((x), (y)))
    #define GX_PACK_VTXXZ_PARAM(x, z)      (GX_FX16PAIR((x), (z)))
    #define GX_PACK_VTXYZ_PARAM(y, z)      (GX_FX16PAIR((y), (z)))
    #define GX_PACK_VTXDIFF_PARAM(x, y, z) (GX_VECVTXDIFF((x), (y), (z)))
    #define GX_PACK_TEXCOORD_PARAM(s, t)   (GX_ST((s), (t)))
    #define GX_PACK_TEXIMAGE_PARAM(texFmt, texGen, s, t, repeat, flip, pltt0, addr) \
        ((u32)(((addr) >> 3)                                    | \
               ((texFmt) << REG_G3_TEXIMAGE_PARAM_TEXFMT_SHIFT) | \
               ((texGen) << REG_G3_TEXIMAGE_PARAM_TGEN_SHIFT)   | \
               ((s) << REG_G3_TEXIMAGE_PARAM_V_SIZE_SHIFT)      | \
               ((t) << REG_G3_TEXIMAGE_PARAM_T_SIZE_SHIFT)      | \
               ((repeat) << REG_G3_TEXIMAGE_PARAM_RS_SHIFT)     | \
               ((flip) << REG_G3_TEXIMAGE_PARAM_FS_SHIFT)       | \
               ((pltt0) << REG_G3_TEXIMAGE_PARAM_TR_SHIFT)))
    #define GX_PACK_TEXPLTTBASE_PARAM(addr, texFmt) \
        ((u32)((addr) >> (4 - ((texFmt) == GX_TEXFMT_PLTT4))))
    #define GX_PACK_VIEWPORT_PARAM(x1, y1, x2, y2)                \
        ((u32)((x1) | ((y1) << 8) | ((x2) << 16) | ((y2) << 24)))
    #define GX_PACK_VECTORTEST_PARAM(x, y, z) ((u32)GX_VECFX10((x), (y), (z)))

## Revision History

02/23/2004 Initial version.

CONFIDENTIAL