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 [macro]

Draws a sprite referencing a 2D matrix.

Syntax

#include <ultra64.h> /* gs2dex.h */
gSPObjRectangleR(Gfx *gdl, uObjSprite *sp)
gsSPObjRectangleR(uObjSprite *sp)

Arguments

  • gdl is the pointer to the graphics display list.

  • sp is the pointer to the sprite drawing data structure.

Explanation
References the 2D matrix elements X, Y, BaseScaleX and BaseScaleY, changes the screen coordinate values for drawing, and draws a non-rotating sprite. The 2D matrix is set using g*SPObjSubMatrix.

Notes
To use a number of sprites consider this example, where the sprites A, B and C are lined up horizontally as shown:

The following data is set for each objX, objY.

A: (objX, objY) = ( 0<<2, 0<<2)

B: (objX, objY) = (32<<2, 0<<2)
C: (objX, objY) = (64<<2, 0<<2)

By changing X and Y in these settings, the three sprites can move together as one large sprite. However, gaps may appear between A & B and B & C, as shown below, due to an error in multiplication or other calculations.

In this case, you must take some appropriate action like slightly overlapping the adjacent sprites, as follows:

B: (objX, objY) = ((32<<2)-2, 0<<2)
C: (objX, objY) = ((64<<2)-4, 0<<2)

Cautions
The uObjSubMtx_t structure is shown below. For information about the uObjSprite structure, see g*SPObjRectangle and also refer to the Readme file of the latest version of the S2DEX microcode.

typedef struct {
  s16 X, Y;        /* s10.2  */
  u16 BaseScaleX;  /* u5.10  */
  u16 BaseScaleY;  /* u5.10  */
} uObjSubMtx_t;    /* 8 bytes */

This macro references the values of the 2D matrix elements X, Y, BaseScaleX and BaseScaleY, and determines the vertex coordinates of the sprite using the following formulas:

Upper-left coordinates: (X+objX/BaseScaleX, Y+objY/BaseScaleY)
Lower-right coordinates: (X+(objX+imageW/scaleW)/BaseScaleX-1,
            Y+(objY+imageH/scaleH)/BaseScaleY-1)

Use g*SPObjSubMatrix to change X, Y, BaseScaleX and BaseScaleY. When X = Y = 0 and BaseScaleX = BaseScaleY = 1.0, the result will be the same as with g*SPObjRectangle. Changing the settings of the 2D matrix elements {X, Y, BaseScaleX and BaseScaleY} enables several sprites to be moved or scaled as a unit.

For other functions, see g*SPObjRectangle.

See Also
gSPObjMatrix
gSPObjRectangle
gSPObjSprite
gSPObjSubMatrix

Revision History
2/1/1999 Completely rewritten


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