The SGADE Documentation

the SGADE 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.


Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

SoSpriteManager.c File Reference

#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.

SoSpriteSoSpriteManagerRequestSprite (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 SoRotationAndScales_RotationAndScales
 Rotation and Scale overlay array.


Detailed Description

Copyright (C) 2002 by the SGADE authors For conditions of distribution and use, see copyright notice in SoLicense.txt

Author:
Jaap Suter
Date:
Sep 19 2001
See the SoSpriteManager module for more information.


Define Documentation

#define SO_NUM_SPRITES
 

Total number of sprites available in OAM;.

For internal use only.

#define SO_REAL_OAM
 

For internal use only.

Start of the GBA's real object attribute memory (as opposed to the shadow OAM we also use).


Variable Documentation

u8 s_FreeSpriteIndexStack[ SO_NUM_SPRITES ] [static]
 

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;

bool s_Initialized [static]
 

For internal use only.

This variable becomes true, once the sprite manager is initialized. This is to prevent subsequent re-initializing;

volatile SoRotationAndScale* s_RotationAndScales [static]
 

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.

SoSprite s_ShadowOAM[ SO_NUM_SPRITES ] [static]
 

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.

u8 s_TopOfFreeSpriteIndexStack [static]
 

Stack pointer.

For internal use only.


Copyright 2002 by the SGADE authors. See SoLicense.h or Visit the SGADE page for more information.