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

   

gSPObjRectangle

Format
gSPObjRectangle(Gfx *gdl, uObjSprite *sp)
gsSPObjRectangle(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.

Use the gSPObjRectangle sprite-drawing macro for non-rotating sprite drawing. The process inside the RSP is to create the TextureRectangle command from the input uObjSprite structure data and send it to the RDP.

The gSPObjRectangle macro draws texture for the rectangle area defined by the upper-left corner screen coordinate (objX, objY), and the lower-right hand corner screen coordinate (objX+imageW/scaleW-1, objY+imageH/scaleH-1). For details about the drawn region and the use of TMEM, please see the "S2DEX Microcode" section of the N64 Programming Manual.

When a sprite is drawn, the scissors box defined by the gDPSetScissor macro is referenced, and automatic drawing area clipping is done. Therefore, it is possible to set negative values for objX and objY.

gSPObjRectangle can be used for 1 cycle, 2 cycle, and copy modes. Drawing speed using copy mode is faster than other modes; however, there are more drawing restrictions using copy mode.

Copy mode does not support bilinear interpolation, subpixel processing, and enlarging/reducing in the X direction. If these operations are attempted in copy mode, they may not be performed properly. In the worst case, the RDP may become uncontrollable. Nintendo recommends that you select the proper mode to perform necessary functions.

The drawing result using gSPObjRectangle will vary depending on the render mode, such as bilinear interpolation. Please refer to, "Setting the Object Render Mode" in the "S2DEX Microcode" section of the N64 Programming Manual for details.

gSPObjRectangle does not reference the 2D matrix setting. For this reason, the 2D matrix setting does not affect its drawing result.

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