OAMSprite

struct OAMSprite

Represents a Sprite in OAM memory.

Summary
OAMSpriteRepresents a Sprite in OAM memory.
Variables
attributesThe actual sprite data.
Functions
GetYThe Y-coordinate of the sprite.
GetXThe X-coordinate of the sprite.
GetRSFlagReturns true if rotation/scale are used.
GetA0B9Gets bit 9.
GetObjMode0=Normal, 1=Semi-Transparent, 2=Obj-Window
GetMosaicTrue if Mosaic Effect is enabled for this sprite.
GetCPTrue if 8bit tiles shall be used, False if 4 bit tiles shall be used.
GetObjShape0=square, 1=horizontal, 2=vertical
GetRSGroupThere are 32 transform groups for 128 sprites.
GetFlipXTrue if the sprite has to be flipped horizontally.
GetFlipYTrue if the sprite has to be flipped vertically.
GetObjSizeIDReturns the size ID.
GetTileIDThe id of the upper-left tile.
GetPriorityThe priority relative to backgrounds.
GetPaletteIDThe ID of the palette that has to be used in Tile4 mode.
OAMTransformGroupOAM (Object Attribute Memory) contains both sprite attributes and transformation groups.
Variables
PAPointer to the PA register (you might know it as dx ...
PBPointer to the PB register (you might know it as dmx ...
PCPointer to the PC register (you might know it as dy ...
PDPointer to the PD register (you might know it as dmy ...
OAMSpritesBuilds and handles all OAMSprites and OAMTransformGroups contained in OAM memory.
Variables
oamMemoryPointer to oam memory.
transformsTransformation groups.
Functions
GetTransformationGroupPartEvery part is located at 0x8 offset starting at 0x6.
OAMSpritesBuilds our oamsprites object.
GetSprite
GetTransformGroup

Variables

attributes

uint16_t attributes[3]

The actual sprite data.

Functions

GetY

inline int GetY()

Returns

The Y-coordinate of the sprite.

GetX

inline int GetX()

Returns

The X-coordinate of the sprite.

GetRSFlag

inline bool GetRSFlag()

Returns

Returns true if rotation/scale are used.

GetA0B9

inline bool GetA0B9()

Returns

Gets bit 9.  (If RS Flag is on it means double size, else it means “enabled”).

GetObjMode

inline int GetObjMode()

Returns

0=Normal, 1=Semi-Transparent, 2=Obj-Window

GetMosaic

Returns

True if Mosaic Effect is enabled for this sprite.

GetCP

inline bool GetCP()

Returns

True if 8bit tiles shall be used, False if 4 bit tiles shall be used.

GetObjShape

inline int GetObjShape()

Returns

0=square, 1=horizontal, 2=vertical

GetRSGroup

inline int GetRSGroup()

There are 32 transform groups for 128 sprites.  Some of them share transformations.

Returns

The group ID.

GetFlipX

inline int GetFlipX()

Returns

True if the sprite has to be flipped horizontally.

GetFlipY

inline int GetFlipY()

Returns

True if the sprite has to be flipped vertically.

GetObjSizeID

inline int GetObjSizeID()

Returns

Returns the size ID.  It depends on the obj shape.  See the GetOAMObjWH macro.

GetTileID

inline int GetTileID()

Returns

The id of the upper-left tile.

GetPriority

inline int GetPriority()

Returns

The priority relative to backgrounds.  Lower id sprites ALWAYS have higher priority than higher id ones.  If you have Sprite0 and Sprite1 and Sprite1 has an higher priority relative to background than Sprite0, garbage is displayed.

GetPaletteID

inline int GetPaletteID()

Returns

The ID of the palette that has to be used in Tile4 mode.  In Tile8 mode it is ignored.  See GetCP.

OAMTransformGroup

struct OAMTransformGroup

OAM (Object Attribute Memory) contains both sprite attributes and transformation groups.  Each sprite as you can see above points a transform group.  Here we have translation, rotations and scale info (that might be used to build a transform matrix for gpu accelerated rendering) or computed manually, which is better for an accurate emulation (since today’s gpus might be too much accurate for this task).

Summary
Variables
PAPointer to the PA register (you might know it as dx ...
PBPointer to the PB register (you might know it as dmx ...
PCPointer to the PC register (you might know it as dy ...
PDPointer to the PD register (you might know it as dmy ...

Variables

PA

uint16_t* PA

Pointer to the PA register (you might know it as dx ... yes it is part of a derivative for rotation).

PB

uint16_t* PB

Pointer to the PB register (you might know it as dmx ... yes it is part of a derivative for rotation).

PC

uint16_t* PC

Pointer to the PC register (you might know it as dy ... yes it is part of a derivative for rotation).

PD

uint16_t* PD

Pointer to the PD register (you might know it as dmy ... yes it is part of a derivative for rotation).

OAMSprites

class OAMSprites

Builds and handles all OAMSprites and OAMTransformGroups contained in OAM memory.

See Also

OAMSprite

Summary
Variables
oamMemoryPointer to oam memory.
transformsTransformation groups.
Functions
GetTransformationGroupPartEvery part is located at 0x8 offset starting at 0x6.
OAMSpritesBuilds our oamsprites object.
GetSprite
GetTransformGroup

Variables

oamMemory

int8_t* oamMemory

Pointer to oam memory.

transforms

OAMTransformGroup transforms[32]

Transformation groups.

Functions

GetTransformationGroupPart

inline uint16_t* GetTransformationGroupPart(int id)

Every part is located at 0x8 offset starting at 0x6.  OAM.  A full transformation group is defined by 4 parts.  This gets one Used only internally for initialization

Parameters

idThe id of the group.

Returns

The address of the part.

OAMSprites

OAMSprites(Memory *mem)

Builds our oamsprites object.

Parameters

memA pointer to GBA memory.

GetSprite

inline OAMSprite* GetSprite(int id)

Parameters

idThe id of the sprite.

Returns

A pointer to the OAMSprite object.

GetTransformGroup

inline OAMTransformGroup* GetTransformGroup(int id)

Parameters

idThe id of the group.

Returns

A pointer to the OAMTransformGroup object.

struct OAMSprite
Represents a Sprite in OAM memory.
uint16_t attributes[3]
The actual sprite data.
inline int GetY()
The Y-coordinate of the sprite.
inline int GetX()
The X-coordinate of the sprite.
inline bool GetRSFlag()
Returns true if rotation/scale are used.
inline bool GetA0B9()
Gets bit 9.
inline int GetObjMode()
0=Normal, 1=Semi-Transparent, 2=Obj-Window
inline bool GetCP()
True if 8bit tiles shall be used, False if 4 bit tiles shall be used.
inline int GetObjShape()
0=square, 1=horizontal, 2=vertical
inline int GetRSGroup()
There are 32 transform groups for 128 sprites.
inline int GetFlipX()
True if the sprite has to be flipped horizontally.
inline int GetFlipY()
True if the sprite has to be flipped vertically.
inline int GetObjSizeID()
Returns the size ID.
inline int GetTileID()
The id of the upper-left tile.
inline int GetPriority()
The priority relative to backgrounds.
inline int GetPaletteID()
The ID of the palette that has to be used in Tile4 mode.
struct OAMTransformGroup
OAM (Object Attribute Memory) contains both sprite attributes and transformation groups.
uint16_t* PA
Pointer to the PA register (you might know it as dx ...
uint16_t* PB
Pointer to the PB register (you might know it as dmx ...
uint16_t* PC
Pointer to the PC register (you might know it as dy ...
uint16_t* PD
Pointer to the PD register (you might know it as dmy ...
class OAMSprites
Builds and handles all OAMSprites and OAMTransformGroups contained in OAM memory.
int8_t* oamMemory
Pointer to oam memory.
OAMTransformGroup transforms[32]
Transformation groups.
inline uint16_t* GetTransformationGroupPart(int id)
Every part is located at 0x8 offset starting at 0x6.
OAMSprites(Memory *mem)
Builds our oamsprites object.
inline OAMSprite* GetSprite(int id)
inline OAMTransformGroup* GetTransformGroup(int id)
Close