Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

TileManagerBase Class Reference

Base class for objects that manage tiles. Provides basic tile management functionality required for all types of backgrounds. More...

#include <Backgrounds.hpp>

Inheritance diagram for TileManagerBase:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 TileManagerBase (TileManagerScreen screen, int tile_index, int map_index, TileManagerColors bg_colors, int bg_num)
 Main constructor simply records user setting for later use by load.

virtual ~TileManagerBase ()
 Simple destructor.

virtual uint32 displayCr (void) const
 Returns the value to OR (|) into other values related to this background. Primarily, it enables the display of the appropriate background based on the background number specified to the constructor.

virtual TileErrorCode prepare (const uint16 *tile_data, uint32 bytes_of_tiles, const uint16 *palette_data, uint32 bytes_of_palette)
 Stores the information provided by the user for use later when using load to move the data into video memory.

virtual TileErrorCode load (void)
 Calling this routine actually loads the prepared tiles and palette into memory.

uint16 * map (void)
 Provides public access to the map. Alternatively use one of the subclasses for "nicer" tile usage.


Protected Member Functions

TileErrorCode loadTileData (const uint16 *data, uint32 bytes_of_data)
 Copies bytes_of_data starting at data into the graphics memory for this tileset.

TileErrorCode loadPalette (const uint16 *data, uint32 bytes_of_data)
 Copies bytes_of_data starting at data into the color palette for this tileset.

uint16 * copy16 (uint16 *dest, const uint16 *src, uint32 bytes_of_data)

Protected Attributes

TileManagerScreen _bg_screen
 Records the screen to use for this tileset. Either TOP_SCREEN or BOTTOM_SCREEN.

int _tile_index
 The index to use to determine where to store the tile data in memory.

int _map_index
 The index to use to determine where the screen map is in memory.

int _bg_num
 The background number in use. Values are 0-3.

TileManagerColors _bg_colors
 The type of palette in use with the tileset. Can be either COLORS_16 for a 16 color palette, or COLORS_256 if the tileset uses a 256 color palette.

uint16 * _bg_tiles
 A pointer to the location in memory to store the graphics data.

uint16 * _bg_map
 A pointer to the location in memory where the screen map may be accessed.

uint16 * _bg_palette
 A pointer to the location in memory to store the color palette for the tiles.

const uint16 * _bg_tile_data
 A pointer to the memory specified by the application which is the source of the tile graphics.

uint32 _bg_tile_data_size
 The number of bytes associated with the tile data.

const uint16 * _bg_palette_data
 A pointer to the memory specified by the application which is the source of the color palette for the tiles.

uint32 _bg_palette_data_size
 The number of bytes associated with the palette data.


Detailed Description

Base class for objects that manage tiles. Provides basic tile management functionality required for all types of backgrounds.


Constructor & Destructor Documentation

TileManagerBase::TileManagerBase TileManagerScreen  screen,
int  tile_index,
int  map_index,
TileManagerColors  bg_colors,
int  bg_num
 

Main constructor simply records user setting for later use by load.

Parameters:
screen Whether this TileManagerBase manages tiles for the TOP_SCREEN or BOTTOM_SCREEN.
tile_index The index to use to determine which portion of memory maintains the graphic data for the tiles.
map_index The index to use to determine which portion of memory maintains the indexes of which tiles are to be displayed on the screen.
bg_colors The number of colors in the palette in use for these tiles. Can be either COLOR_16 or COLOR_256. Note that this determines the amount of memory each tile requires. For 16 color tiles, each byte specifies an offset into the color palette to determine the color, so each uint16 stores four pixels worth of information. For 256 color tiles, each uint16 stores two pixels worth of information.
bg_num Which background number (0-3) for which these tiles will be used.


Member Function Documentation

TileErrorCode TileManagerBase::prepare const uint16 *  tile_data,
uint32  bytes_of_tiles,
const uint16 *  palette_data,
uint32  bytes_of_palette
[virtual]
 

Stores the information provided by the user for use later when using load to move the data into video memory.

Parameters:
tile_data A pointer to the graphics data for the tile.
bytes_of_tiles The number of bytes associated with tile_data.
palette_data A pointer to the color palette for the tiles.
bytes_of_palette The number of bytes associated with palette_data.
Return values:
TM_NO_ERROR Data recorded successfully.
TM_TILE_MAP_COLLISION The amount of graphics data is larger than the space provided between the start of the tile area and the map area specified for this set of tiles.
TM_BAD_DATA One of the input parameters was 0.

TileErrorCode TileManagerBase::load void   )  [virtual]
 

Calling this routine actually loads the prepared tiles and palette into memory.

Return values:
TM_NO_ERROR Data loaded successfully.
TM_NO_DATA_PREPARED The prepare method has not been called successfully.
TM_TILE_MAP_COLLISION The amount of graphics data is larger than the space provided between the start of the tile area and the map area specified for this set of tiles.

Reimplemented in TextMap.

uint16 * TileManagerBase::map void   ) 
 

Provides public access to the map. Alternatively use one of the subclasses for "nicer" tile usage.

Returns:
The pointer to the first portion of the map.

TileErrorCode TileManagerBase::loadTileData const uint16 *  data,
uint32  bytes_of_data
[protected]
 

Copies bytes_of_data starting at data into the graphics memory for this tileset.

Parameters:
data A pointer to the start of data to be copied.
bytes_of_data The number of bytes to copy.
Return values:
TM_TILE_MAP_COLLISION The amount of graphics data is larger than the space provided between the start of the tile area and the map area specified for this set of tiles.

TileErrorCode TileManagerBase::loadPalette const uint16 *  data,
uint32  bytes_of_data
[protected]
 

Copies bytes_of_data starting at data into the color palette for this tileset.

Parameters:
data A pointer to the start of data to be copied.
bytes_of_data The number of bytes to copy.

uint16 * TileManagerBase::copy16 uint16 *  dest,
const uint16 *  src,
uint32  bytes_of_data
[protected]
 

Copies bytes_of_data bytes from src to dest 16 bits (2 bytes) at a time.

Parameters:
dest The destination location of the data.
src The source location of the data.
bytes_of_data The number of bytes of data to copy. Must be a multiple of 2. For odd numbers, the last by is not copied.
Returns:
The first position after last dest position written.


The documentation for this class was generated from the following files:
Generated on Fri Apr 22 13:47:46 2005 for PhoenixRising NDS Library by doxygen 1.3.6