v1.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
Public Member Functions | Static Public Member Functions | List of all members
Sifteo::RelocatableTileBuffer< tW, tH, tF > Struct Template Reference

A drawable that's backed by plain memory, usable with multiple cubes. More...

#include <sifteo/video/tilebuffer.h>

Public Member Functions

void erase (uint16_t index=0)
 Erase the buffer, filling it with the specified relative tile index value.
 
void erase (const PinnedAssetImage &image)
 Erase the buffer, filling it with the first tile from the specified PinnedAssetImage.
 
void fill (UInt2 topLeft, UInt2 size, unsigned tileIndex, unsigned frame=0)
 Fill a rectangle of identical tiles, specified as a top-left corner location and a size. More...
 
void fill (UInt2 topLeft, UInt2 size, const PinnedAssetImage &image, unsigned frame=0)
 Fill a rectangle of identical tiles, using the first tile of a pinned asset. More...
 
void image (UInt2 pos, const AssetImage &image, unsigned srcFrame=0, unsigned destFrame=0)
 Draw a full AssetImage frame, with its top-left corner at the specified location. More...
 
void image (UInt2 destXY, UInt2 size, const AssetImage &image, UInt2 srcXY, unsigned srcFrame=0, unsigned destFrame=0)
 Draw part of an AssetImage frame, with its top-left corner at the specified location. More...
 
void init ()
 Initialize the RelocatableTileBuffer's AssetImage header. More...
 
 operator const _SYSAssetImage & () const
 Implicit conversion to system object.
 
 operator const AssetImage & () const
 Implicit conversion to AssetImage base class.
 
 operator const FlatAssetImage & () const
 Implicit conversion to FlatAssetImage.
 
void plot (unsigned i, uint16_t tileIndex)
 Plot a single tile, by relative tile index, at linear position 'i'. More...
 
void plot (UInt2 pos, uint16_t tileIndex, unsigned frame=0)
 Plot a single tile, by relative tile index, at location 'pos' in tile units, on the given frame. More...
 
 RelocatableTileBuffer ()
 Initialize a RelocatableTileBuffer.
 
void setAssetGroup (AssetGroup &group)
 Set the AssetGroup associated with this buffer. More...
 
void span (UInt2 pos, unsigned width, unsigned tileIndex, unsigned frame=0)
 Plot a horizontal span of tiles, by relative tile index, given the position of the leftmost tile and the number of tiles to plot. More...
 
void span (UInt2 pos, unsigned width, const PinnedAssetImage &image, unsigned frame=0)
 Plot a horizontal span of tiles, using the first tile of a pinned asset. More...
 
void text (Int2 topLeft, const AssetImage &font, const char *str, unsigned destFrame=0, char firstChar= ' ')
 Draw text, using an AssetImage as a fixed width font. More...
 
uint16_t tile (unsigned i) const
 Returns the relative index of the tile at linear position 'i' in the image.
 
uint16_t tile (UInt2 pos, unsigned frame=0) const
 Return the relative index of the tile at the specified (x, y) tile coordinates, and optionally on the specified frame number.
 
uint16_t tileAddr (UInt2 pos, unsigned frame=0)
 Calculate the video buffer address of a particular tile. More...
 

Static Public Member Functions

static int numFrames ()
 Return the number of frames in this image.
 
static int numTiles ()
 Return the total number of tiles in every frame of the image.
 
static int numTilesPerFrame ()
 Return the number of tiles in each frame of the image.
 
static unsigned pixelHeight ()
 Return the height, in pixel, of this mode.
 
static UInt2 pixelSize ()
 Return the size of this mode as a vector, in pixels.
 
static unsigned pixelWidth ()
 Return the width, in pixels, of this mode.
 
static unsigned sizeInBytes ()
 Returns the size of this drawable's tile data, in bytes.
 
static unsigned sizeInWords ()
 Returns the size of this drawable's tile data, in 16-bit words.
 
static unsigned tileHeight ()
 Return the height, in tiles, of this mode.
 
static UInt2 tileSize ()
 Return the size of this mode as a vector, in tiles.
 
static unsigned tileWidth ()
 Return the width, in tiles, of this mode.
 

Detailed Description

template<unsigned tW, unsigned tH, unsigned tF = 1>
struct Sifteo::RelocatableTileBuffer< tW, tH, tF >

A drawable that's backed by plain memory, usable with multiple cubes.

Template parameters specify the width and height of the buffer, in tiles, and optionally the number of frames.

This is a variation on TileBuffer, but instead of storing per-cube (already relocated) tile indices, this stores per-asset-group (relocatable) indices.

A RelocatableTileBuffer can only be used with assets from a single group, and that group must be set during initialization. But, in return, the RelocatableTileBuffer may be drawn to any cube that has that group installed.

In memory, we store a flat array of 16-bit un-relocated tile indices.

RelocatableTileBuffers can be used as assets. In particular, they can be freely converted to FlatAssetImage or AssetImage instances. This means you can use them to do off-screen rendering, and then draw that rendering to any other drawable.

Note that RelocatableTileBuffers are not POD types. The underlying AssetImage header we build in RAM needs to be initialized by the constructor.

Member Function Documentation

template<unsigned tW, unsigned tH, unsigned tF = 1>
void Sifteo::RelocatableTileBuffer< tW, tH, tF >::fill ( UInt2  topLeft,
UInt2  size,
unsigned  tileIndex,
unsigned  frame = 0 
)
inline

Fill a rectangle of identical tiles, specified as a top-left corner location and a size.

All coordinates must be in range. This function performs no clipping.

template<unsigned tW, unsigned tH, unsigned tF = 1>
void Sifteo::RelocatableTileBuffer< tW, tH, tF >::fill ( UInt2  topLeft,
UInt2  size,
const PinnedAssetImage image,
unsigned  frame = 0 
)
inline

Fill a rectangle of identical tiles, using the first tile of a pinned asset.

All coordinates must be in range. This function performs no clipping.

template<unsigned tW, unsigned tH, unsigned tF = 1>
void Sifteo::RelocatableTileBuffer< tW, tH, tF >::image ( UInt2  pos,
const AssetImage image,
unsigned  srcFrame = 0,
unsigned  destFrame = 0 
)
inline

Draw a full AssetImage frame, with its top-left corner at the specified location.

Locations are specified in tile units, relative to the top-left of the 18x18 grid.

All coordinates must be in range. This function performs no clipping.

template<unsigned tW, unsigned tH, unsigned tF = 1>
void Sifteo::RelocatableTileBuffer< tW, tH, tF >::image ( UInt2  destXY,
UInt2  size,
const AssetImage image,
UInt2  srcXY,
unsigned  srcFrame = 0,
unsigned  destFrame = 0 
)
inline

Draw part of an AssetImage frame, with its top-left corner at the specified location.

Locations are specified in tile units, relative to the top-left of the 18x18 grid.

All coordinates must be in range. This function performs no clipping.

template<unsigned tW, unsigned tH, unsigned tF = 1>
void Sifteo::RelocatableTileBuffer< tW, tH, tF >::init ( )
inline

Initialize the RelocatableTileBuffer's AssetImage header.

This resets the AssetGroup associated with the buffer, so it may again be used with assets from any group. The contents of the buffer are not cleared.

template<unsigned tW, unsigned tH, unsigned tF = 1>
void Sifteo::RelocatableTileBuffer< tW, tH, tF >::plot ( unsigned  i,
uint16_t  tileIndex 
)
inline

Plot a single tile, by relative tile index, at linear position 'i'.

All coordinates must be in range. This function performs no clipping.

template<unsigned tW, unsigned tH, unsigned tF = 1>
void Sifteo::RelocatableTileBuffer< tW, tH, tF >::plot ( UInt2  pos,
uint16_t  tileIndex,
unsigned  frame = 0 
)
inline

Plot a single tile, by relative tile index, at location 'pos' in tile units, on the given frame.

All coordinates must be in range. This function performs no clipping.

template<unsigned tW, unsigned tH, unsigned tF = 1>
void Sifteo::RelocatableTileBuffer< tW, tH, tF >::setAssetGroup ( AssetGroup group)
inline

Set the AssetGroup associated with this buffer.

If the same asset group is already associated, this is a no-op.

template<unsigned tW, unsigned tH, unsigned tF = 1>
void Sifteo::RelocatableTileBuffer< tW, tH, tF >::span ( UInt2  pos,
unsigned  width,
unsigned  tileIndex,
unsigned  frame = 0 
)
inline

Plot a horizontal span of tiles, by relative tile index, given the position of the leftmost tile and the number of tiles to plot.

All coordinates must be in range. This function performs no clipping.

template<unsigned tW, unsigned tH, unsigned tF = 1>
void Sifteo::RelocatableTileBuffer< tW, tH, tF >::span ( UInt2  pos,
unsigned  width,
const PinnedAssetImage image,
unsigned  frame = 0 
)
inline

Plot a horizontal span of tiles, using the first tile of a pinned asset.

All coordinates must be in range. This function performs no clipping.

template<unsigned tW, unsigned tH, unsigned tF = 1>
void Sifteo::RelocatableTileBuffer< tW, tH, tF >::text ( Int2  topLeft,
const AssetImage font,
const char *  str,
unsigned  destFrame = 0,
char  firstChar = ' ' 
)
inline

Draw text, using an AssetImage as a fixed width font.

Each character is represented by a consecutive 'frame' in the image. Characters not present in the font will be skipped.

template<unsigned tW, unsigned tH, unsigned tF = 1>
uint16_t Sifteo::RelocatableTileBuffer< tW, tH, tF >::tileAddr ( UInt2  pos,
unsigned  frame = 0 
)
inline

Calculate the video buffer address of a particular tile.

All coordinates must be in range. This function performs no clipping.


The documentation for this struct was generated from the following file: