**Function**

gSPObjRectangleR

*Draws a sprite referencing a 2D matrix*

**Syntax**

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

**Arguments**

**gdl**- the pointer to the display list.
**sp**- the pointer to the sprite drawing data structure.

**Description**

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.

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)

**Comment**

The uObjSubMtx_t structure is shown below.

* For information about the uObjSprite structure, see g*SPObjRectangle and also refer to the "4.2.1 uObjSprite structure" in 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 **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)
ower-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, and gSPObjSubMatrix

**Revision History**

02/01/99 Entirely revised.