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
|
gSPZMultMPMtxFormatgSPZMultMPMtx(Gfx *gp, u32 mid, u32 src, u32 num, u32 dest)Arguments
This Z-Sort microcode GBI macro regards the data in the user area's src position as the 16-bit x, y, and z values. This source data is multiplied by the 4x4 matrix specified by mid and that result (X, Y, Z, W) is normalized by W=1. The screen coordinate value is then obtained by transforming the ViewPort to the obtained coordinates. Also, at this time, the flags for the FOG parameter and clipping processing are calculated and that data is stored in the dest position. Next, 6 is added to src and 16 to dest, and the process proceeds to the next vertex. The num number of vertices are all processed. The formats of the coordinate values to be input and output at this point are defined as the zVtxSrc and zVtxDest structures in the header file gZ-Sort.h. For detailed information about these structures, please see the "Z-Sort Microcode" area of the N64 Programming Manual. The size of the zVtxSrc structure is 6 bytes, so pay special attention to the 8-byte alignment when transferring DMA using gSPZSetUMem. When the transfer size must be a multiple of 8, the DMA transfer size must be rounded off to a multiple of 8. The size of the zVtxDest structure is 16 bytes, so only the 128-byte area in the 2048-byte user area can be protected. As a result, the num range is from 1 to 128. (In reality, because light and other processes are also performed, the range is usually smaller than this.) At this time, the num * 16-byte area from the dest address can be rewritten, except when num is 3 or less. In this case, the 64-byte area from the position specified by dest is overwritten. For example, when num is 3 and dest is 0, the correct value after transformation can be stored at address 0-47 and meaningless data can be written to address 48-63. Be careful here because the value of the source of address 48-63 will be destroyed. This specification is necessary for improving the calculation speed. The routine for this GBI macro is illustrated below. Be sure that the unprocessed src is not overwritten by the dest output to allow the src and dest areas to be overlapped. In libZ-Sort of the sample program cubes-1, with src set to 1200-1919 and dest set to 0-1919, a maximum of 120 vertices can be processed. for (i = 0; i < num; i ++) { *dest = MultMP (*src); src += 6; dest += 16; }The member variable invw is found as shown below from the coordinate values (X, Y, Z, W) after multiplying the coordinate value of each vertex (x, y, z, 1) by the MxP matrix. However, perspNorm is the parameter for normalizing the perspective transformation set by guPerspNormalize. invw = (1<<30)/(perspNorm * W):There is a lot more information about this macro available in the "Z-Sort Microcode" area of the N64 Programming Manual. See Also Z-Sort Microcode gSPZRdpCmd gSPZSetUMem gSPZGetUMem gSPZSetMtx gSPZGetMtx gSPZMtxCat gSPZMtxTrnsp3x3 gSPZViewPort gSPZMultMPMtx gSPZSetAmbient gSPZSetDefuse gSPZSetLookAt gSPZXfmLights gSPZLight gSPZLightMaterial gSPZMixS16 gSPZMixS8 gSPZMixU8 gSPZSegment gSPZSetSubDL gSPZLinkSubDL gSPZSendMessage gSPZWaitSignal gSPZSegment gSPZPerspNormalize
|