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

   

gSPObjRectangleR

Format
gSPObjRectangleR(Gfx *gdl, uObjSprite *sp)
gsSPObjRectangleR(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's 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 gSPObjRectangleR macro like gSPObjRectangle is used for drawing non-rotating sprites. Unlike gSPObjRectangle however, gSPObjRectangleR changes drawing screen coordinates by referring to the 2D matrix data structure's X, Y, BaseScaleX, and BaseScaleY elements. It determines the vertex coordinates of a sprite by using the following formula.

Upper-left coordinate:
( X + objX / BaseScaleX, Y+objY/BaseScaleY )
Lower-right coordinate:
( X + (objX + imageW / scaleW) / BaseScaleX - 1,
Y + (objY + imageH / scaleH) / BaseScaleY - 1 )
To change the values in X, Y, BaseScaleX, and BaseScaleY, use the gSPObjSubMatrix macro. When X = Y = 0 and BaseScaleX = BaseScaleY = 1.0, the result is the same as using gSPObjRectangle.

By changing the values in X, Y, BaseScaleX, and BaseScaleY elements of the 2D matrix, you enable multiple sprites to be moved or their scale changed, as if they were one sprite. For more information about this, 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