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

   

gSPVertex

Format
#include "gbi.h"

typedef struct {
   short ob[3]; /* x, y, z */
   unsigned short flag;
   short tc[2]; /* texture coordination */
   unsigned char cn[4]; /* color  alpha */
} Vtx_t;

typedef struct {
   short ob[3]; /* x, y, z */
   unsigned short flag;
   short tc[2]; /* texture coordination */
   signed char n[3]; /* Normal */
   unsigned char a; /* Alpha */
 } Vtx_tn;

typedef union {
   Vtx_t v; /* for color */
   Vtx_tn n; /* for normal */
   long long int 
      force_structure_alignment;
} Vtx;

gSPVertex(Gfx *pkt, Vtx *v,
   u32 n, u32 v0);
gsSPVertex(Vtx *v, u32 n,
   u32 v0);
Arguments
  • pkt is the pointer to the graphics display list
  • v is the pointer to the vertex list (segment address)
  • n is the number of vertices
  • v0 is the load vertex by index vo(0~15) in vertex buffer
What This Macro Does
It loads an internal vertex buffer in the RSP with points that are used by gSP1Triangle macros to generate polygons. This vertex cache can hold up to 16 vertices, and the vertex loading can begin at any entry (index) within the cache. The vertex coordinates (x,y,z) are encoded in signed 2's complement, 16-bit integers. The texture coordinates (s,t) are encoded in S10.5 format. A vertex either has a color or a normal (for shading). These values are 8-bit values. The colors and alphas are treated as 8-bit unsigned values (0-255), but the normals are treated as 8-bit signed values (-128 to 127). Therefore, the appropriate member of the union to use (.v. or .n.) depends on whether you are using colors or normals.

Normal coordinates range from -1.0 to 1.0. A value of -1.0 is represented as -128, and a value of 1.0 is represented as 128, but because the maximum positive value of a signed byte is 127, a value of 1.0 can't really be represented. Therefore, 0.992 is the maximum representable positive value, which is good enough for this purpose.

The flag value of the Vtx structure currently has no meaning.

The coordinates (x,y,z) are transformed using the current 4x4 projection and model view matrices, and (s,t) are transformed using the scale defined by gSPTexture.

Example
To load vertex cache entry 2,3,4, use this code:

gSPVertex(glistp++, v, 3, 2);

The range of n or v0 has been changed along with the change in vertex cache size. The number of vertices which can be loaded at once is less than 32, so it is necessary to split the load when loading more than 32 vertices. Please use gSPVertex multiple times when loading more than 32 vertexes.

Note
Because the RSP geometry transformation engine uses a vertex list with triangle list architecture, it is quite powerful. A simple one-triangle macro retains maximum performance.


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
Nintendo of America Inc. All rights reserved
Nintendo and N64 are registered trademarks of Nintendo
Last updated January 1998