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.
#include "SoSpriteManager.h"#include "SoIntManager.h"#include "SoMath.h"#include "SoDebug.h"#include "SoTables.h"#include "SoDisplay.h"#include "SoDMA.h"#include "SoKeys.h"Data Structures | |
| struct | SoRotationAndScale |
| Sprite rotation and scaling structure. More... | |
Defines | |
| #define | SO_REAL_OAM |
| #define | SO_NUM_SPRITES |
| Total number of sprites available in OAM;. | |
Functions | |
| void | SoSpriteManagerUpdate (void) |
| Updates the sprite attributes in real object attribute memory. | |
| void | SoSpriteManagerInitialize (void) |
| Initializes the sprite manager. | |
| SoSprite * | SoSpriteManagerRequestSprite (void) |
| Returns a pointer to an available sprite. | |
| void | SoSpriteManagerRelease (SoSprite *a_Sprite) |
| Releases a sprite. | |
| void | SoSpriteManagerEnableSprites (void) |
| Enables sprite rendering. | |
| void | SoSpriteManagerDisableSprites (void) |
| Disables sprites rendering. | |
| void | SoSpriteManagerSetRotationAndScale (u32 a_Index, s32 a_Angle, u32 a_FixedScaleX, u32 a_FixedScaleY) |
| Sets the rotation and scale values for the given index. | |
| 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;. | |
Variables | |
| SoSprite | s_ShadowOAM [SO_NUM_SPRITES] |
| Shadow object attribute memory. | |
| u8 | s_FreeSpriteIndexStack [SO_NUM_SPRITES] |
| Stack to keep track of which sprites are free and which are not. | |
| u8 | s_TopOfFreeSpriteIndexStack |
| Stack pointer. | |
| bool | s_Initialized |
| volatile SoRotationAndScale * | s_RotationAndScales |
| Rotation and Scale overlay array. | |
|
|
Total number of sprites available in OAM;.
For internal use only.
|
|
|
For internal use only. Start of the GBA's real object attribute memory (as opposed to the shadow OAM we also use). |
|
|
Stack to keep track of which sprites are free and which are not.
For internal use only.
We use a stack to keep track of free sprite indices. This allows for speedy sprite requests. The stack grows upwards, and is push -> increment (the stack pointer points to the free slot). As a consequence s_FreeSpriteIndexStack[ s_TopOfFreeSpriteIndexStack ] always points to a free sprite location except when s_TopOfFreeSpriteIndexStack equals SO_NUM_SPRITES; |
|
|
For internal use only. This variable becomes true, once the sprite manager is initialized. This is to prevent subsequent re-initializing; |
|
|
Rotation and Scale overlay array.
We overlay an array of 32 rotation and scale settings over the shadow OAM. This way we can easily acces individual rotation and scale attributes. |
|
|
Shadow object attribute memory.
For internal use only.
Because the real OAM can only be updated during VBlank (and HBlank if enabled) we use a shadowing system. We keep an array of shadow-sprites in regular RAM, and copy this to OAM (VRam) each VBlank. This way we can update the sprite attributes whenever we like, and we are always sure the OAM will be updated accordingly. |
|
|
Stack pointer.
For internal use only.
|