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  

SoSpriteMemManager.c File Reference

#include "SoSpriteMemManager.h"
#include "SoTileSet.h"
#include "SoDMA.h"
#include "SoDebug.h"

Defines

#define SO_SPRITE_MEMORY
 Start of sprite (tile, character, whatever) memory.

#define SO_SPRITE_MEMORY_SIZE
 Number of bytes available for sprite tiles;.

#define SO_MIN_SPRITE_BLOCK_SIZE
 An 8x8 4 bit palettized tile takes up 32 bytes;.

#define SO_SPRITE_BLOCK_SIZE_SHIFT
 2^5 == 32, this value can be used to divide by the blocksize.

#define SO_MAX_NUM_SPRITE_BLOCKS
 SO_SPRITE_TILE_MEM_SIZE / MIN_SPRITE_BLOCK_SIZE == 1024;.

#define SO_SPRITE_BLOCK_FREE
 Value to mark a block as free.

#define SO_SPRITE_BLOCK_USED
 Value to mark a block as used.

#define SO_SPRITE_BLOCK_CONTINUE

Functions

void SoSpriteMemManagerInitialize (void)
 Initializes the sprite memory manager.

u32 SoSpriteMemManagerSearchFreeSlot (u32 numBlocksInSet)
 Searches in sprite memory for a free slot and returns it.

u32 SoSpriteMemManagerLoad (const SoSpriteAnimation *a_Animation)
 Loads a animation in sprite memory and returns the index in sprite memory.

u32 SoSpriteMemManagerLoadFrame (u16 a_Frame, const SoSpriteAnimation *a_Animation)
 Load an individual animation frame into memory.

void SoSpriteMemManagerCopyFrame (u32 a_Index, u16 a_Frame, const SoSpriteAnimation *a_Animation)
 Copy an individual animation frame into memory.

void SoSpriteMemManagerCopyFromImage (u32 a_Index, SoImage *a_Image)
 Copies an image in sprite memory.

u32 SoSpriteMemManagerLoadFromImage (SoImage *a_Image)
 Loads an image in sprite memory and returns the index in sprite memory.

void SoSpriteMemManagerRelease (u32 a_Index)
 Releases a given tileset index from memory.

void SoSpriteMemManagerSetInBitmappedMode (bool a_Enable)
 Use when you are in mode 3, 4, or 5 when using sprites.


Variables

bool s_Initialized
 This becomes true once the sprite memory manager is initialized;.

u8 s_SpriteAllocationTable [SO_MAX_NUM_SPRITE_BLOCKS]
 This is for smart sprite memory managment;.

bool s_InBitmappedMode

Detailed Description

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

Author:
Jaap Suter, Gabriele Scibilia
Date:
June 28, 2003
See the SoSpriteMemManager module for more information.


Define Documentation

#define SO_MAX_NUM_SPRITE_BLOCKS
 

SO_SPRITE_TILE_MEM_SIZE / MIN_SPRITE_BLOCK_SIZE == 1024;.

For internal use only.

#define SO_MIN_SPRITE_BLOCK_SIZE
 

An 8x8 4 bit palettized tile takes up 32 bytes;.

For internal use only.

#define SO_SPRITE_BLOCK_CONTINUE
 

For internal use only.

Value to mark a block as continued (same as the one before that, either free or used)

#define SO_SPRITE_BLOCK_FREE
 

Value to mark a block as free.

For internal use only.

#define SO_SPRITE_BLOCK_SIZE_SHIFT
 

2^5 == 32, this value can be used to divide by the blocksize.

For internal use only.

#define SO_SPRITE_BLOCK_USED
 

Value to mark a block as used.

For internal use only.

#define SO_SPRITE_MEMORY
 

Start of sprite (tile, character, whatever) memory.

For internal use only.

#define SO_SPRITE_MEMORY_SIZE
 

Number of bytes available for sprite tiles;.

For internal use only.


Function Documentation

u32 SoSpriteMemManagerSearchFreeSlot u32    numBlocksInSet
 

Searches in sprite memory for a free slot and returns it.

Helper function internally used by the SoSpriteMemManagerLoad and SoSpriteMemManagerLoadFromImage public methods.

For internal use only.


Variable Documentation

bool s_InBitmappedMode [static]
 

For internal use only.

This is true when the GBA is in bitmapped modes (3, 4 or 5). We need to know this, because we can only use half of the available character data in that case;

bool s_Initialized [static]
 

This becomes true once the sprite memory manager is initialized;.

For internal use only.

u8 s_SpriteAllocationTable[ SO_MAX_NUM_SPRITE_BLOCKS ] [static]
 

This is for smart sprite memory managment;.

For internal use only.


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