The Socrates Gameboy Advance Development Engine
The SGADE is a development library for the Nintendo Gameboy
Advance. It's free for all uses and is distributed without guarantees.
For more information visit
the SGADE page.
Files | |
| file | SoSpriteManager.c |
| file | SoSpriteManager.h |
Functions | |
| void | SoSpriteManagerInitialize (void) |
| Initializes the sprite manager. | |
| void | SoSpriteManagerUpdate (void) |
| Updates the sprite attributes in real object attribute memory. | |
| void | SoSpriteManagerEnableSprites (void) |
| Enables sprite rendering. | |
| void | SoSpriteManagerDisableSprites (void) |
| Disables sprites rendering. | |
| SoSprite * | SoSpriteManagerRequestSprite (void) |
| Returns a pointer to an available sprite. | |
| void | SoSpriteManagerRelease (SoSprite *a_Sprite) |
| Releases a sprite. | |
| void | SoSpriteManagerSetMosaic (u32 a_HorizontalSize, u32 a_VerticalSize) |
| Sets the sprite mosaic values. | |
| u32 | SoSpriteManagerGetHorizontalMosaic (void) |
| Returns the horizontal sprite mosaic value;. | |
| u32 | SoSpriteManagerGetVerticalMosaic (void) |
| Returns the vertical sprite mosaic value;. | |
| void | SoSpriteManagerSetRotationAndScale (u32 a_Index, s32 a_Angle, u32 a_FixedScaleX, u32 a_FixedScaleY) |
| Sets the rotation and scale values for the given index. | |
Singleton
This module manages all sprites.
It handles the GBA's object attribute memory. This module does NOT manage the actual sprite memory (where characters are located). The SoSpriteMemManager module is for that. Of course these two modules do interact in some way. Upon studying this module, I suggest you take a look at the SoSprite and SoSpriteMemManager modules too.
Most of the ideas behind this implementation came from Rafael Baptista's excellent article on GBA resource management that was originally posted on http://www.gamasutra.com Unfortunately the article was removed from the site due to legal reasons.
Note that this module uses the interrupt manager. If the interrupt manager is not already initialized, it will initialize it in its own initialize routine.
This module does more than just manage OAM; it also handles sprite mosaic values, rotation and scale settings, etc. etc. In short everything sprite related that doesn't belong to a particular sprite instance (because then it would be in SoSprite).
|
|
Disables sprites rendering.
Disables the visibility of all sprites and deinstalls the shadow-to-real-oam copy routine during VBlank. |
|
|
Enables sprite rendering.
Ofcourse you have to have a sprite and some character data the sprite uses, in order to see a sprite, but without this routine the sprites would all be invisible. This also enables the shadow-to-real-oam copy routine in VBlank. |
|
|
Returns the horizontal sprite mosaic value;.
|
|
|
Returns the vertical sprite mosaic value;.
|
|
|
Initializes the sprite manager.
Should be the first function you call before you call any other SoSpriteManager function. Make sure you have already called SoDisplayInitialize too. |
|
|
Releases a sprite.
|
|
|
Returns a pointer to an available sprite.
This is the only way to obtain a sprite. You can instantiate a sprite structure yourself but it will be useless. You have to ask the sprite manager for a sprite by using this function. This routine will never fail. In debug mode an assertion will be triggered when there are no more sprites available. Because of the fixed memory environment you can safely assume that if it works in debug, it'll work in release. |
|
||||||||||||
|
Sets the sprite mosaic values.
|
|
||||||||||||||||||||
|
Sets the rotation and scale values for the given index.
With this method you can set the rotation and scale for the given index. After that, tell a sprite to use this index, and he'll rotate and scale accordingly (if you have sprite rotation and scaling enabled for that sprite). See the Pern Project (http://www.thepernproject.com) or other Nintendo references for more information on this system. |
|
|
Updates the sprite attributes in real object attribute memory.
This function copied the shadow object attribute memory to the real object attribute memory. Without calling this function you won't ever see your sprites.
|