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

   

gSPObjSprite

Format
gSPObjSprite(Gfx *gdl, uObjSprite *sp)
gsSPObjSprite(uObjSprite *sp)
Arguments
  • gdl is the pointer to the display list
  • sp is the pointer to the uObjSprite structure that contains the sprite drawing data
What This Macro Does
It is one of the three sprite-drawing macros that are part of the S2DEX microcode. The sprite mentioned here corresponds to OBJECTs in Super NES programming. Sprites have been used for drawing areas smaller than BG, and historically they have been used as "player characters" quite often. By using the following three S2DEX microcode sprite-drawing macros, you can magnify, reduce, and rotate sprites:
  • gSPObjRectangle
  • gSPObjRectangleR
  • gSPObjSprite
Also using sprites, more natural expression is possible due to the use of bilinear interpolation processing.

To support a sprite�s rotation, a two-dimensional coordinate conversion matrix is used. By setting the matrix elements, a sprite can be rotated freely. The matrix must be set before drawing a sprite. Also, unlike the matrix for Fast3D or F3DEX, there is no matrix stack, so push or pop operations cannot be performed. Matrix multiplication cannot be done either. Only the load operation is possible.

The S2DEX microcode specifications call for using separate GBIs for TMEM loading and sprite drawing. Therefore, before drawing a sprite, you must load the texture used for the sprite by using this texture loading GBI macro:
  • gSPObjLoadTxtr
The sprite drawing mode can be divided into two categories, rotating sprites and non-rotating sprites. For the no-rotation drawing mode, use the gSPObjRectangle or gSPObjRectangleR macro. For rotation drawing mode, use the gSPObjSprite macro.

The uObjSprite data structure holds a sprite�s information. The pointer to the data structure will be given to the sprite drawing macro as a parameter. For detailed information about this and the other data structures used, please see the uObjSprite structure, see the "S2DEX Microcode" section of the N64 Programming Manual.

The gSPObjSprite sprite-drawing macro draws rotating sprites. To rotate a sprite, use the A, B, C, D, X, and Y elements of the 2D matrix. Use gSPObjMatrix to set these elements of the 2D matrix. For more information about this matrix, please see the "S2DEX Microcode" section of the N64 Programming Manual.

A point (x, y) on a non-rotating sprite will move to the point (x�, y�) by performing 2D matrix multiplication as follows:
x�=A * x + B * y + X
y�=C * x + D * y + Y
Each vertex of the sprite moves, and the sprite is drawn in the new region defined by the new vertices.

If the 2D matrix {A, B, C, D} is defined by the rotation matrix as follows, a sprite will make a T rotation. In this case, a sprite will rotate centering around the screen coordinate (X,Y). If scaling is to be added, multiply each element {A, B, C, D} by the scale value. By changing (objX, objY), the rotation center of a sprite (X,Y) can be changed. If objX=objY=0, a Sprite�s rotation center will be the upper left hand vertex. If you wish to rotate a sprite about its center, set objX and objY as follows:
ObjX = -(imageW/scaleW)/2;
objY = -(imageH/scaleH)/2;
Also, similar to gSPObjRectangleR, by adjusting the values of objX and objY, you can rotate multiple sprites as if they were one sprite. Here, as with gSPObjRectangleR, Nintendo recommends drawing sprites in a slightly overlapping fashion to eliminate gaps caused by calculation errors.

By setting (A = D = 1.0, B = C = 0.0), a non-rotating sprite�s location will coincide with a sprite drawn with gSPObjRectangleR by setting BaseScaleX = BaseScaleY = 1.0. Nintendo recommends that you draw a non-rotating sprite with gSPObjRectangle and use gSPObjSprite for rotating Sprites. The gSPObjSprite uses two polygons in combination for drawing, so it requires more RSP/RDP processing than does gSPObjRectangleR.

Also, when you use gSPObjSprite for a non-rotating sprite, a magnified sprite drawing may not coincide with the drawing done by gSPObjRectangle. This is unavoidable because the drawing methods are different (polygon combination versus rectangle drawing).

The setting for the texture to be placed on a sprite is the same as it is for gSPObjRectangle. For the details, please see the "S2DEX Microcode" section of the N64 Programming Manual.

For detailed information on S2DEX microcode GBI macros and data structures, please see the "S2DEX Microcode" area of the N64 Programming Manual.

See Also
S2DEX Microcode
guS2DInitBg


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