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::BG2Drawable Struct Reference

A VRAM accessor for drawing graphics in the BG2 mode. More...

#include <sifteo/video/bg2.h>

Public Member Functions

CubeID cube () const
 Return the CubeID associated with this drawable.
 
void erase (uint16_t index=0)
 Erase mode-specific VRAM, filling the BG2 buffer with the specified absolute tile index value. More...
 
void erase (const PinnedAssetImage &image)
 Erase mode-specific VRAM, filling the BG2 buffer with the first tile from the specified PinnedAssetImage.
 
void fill (UInt2 topLeft, UInt2 size, unsigned tileIndex)
 Fill a rectangle of identical tiles, specified as a top-left corner location and a size. More...
 
RGB565 getBorder () const
 Get the last border color set by setBorder().
 
void image (UInt2 pos, const AssetImage &image, unsigned frame=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 frame=0)
 Draw part of an AssetImage frame, with its top-left corner at the specified location. More...
 
void plot (UInt2 pos, uint16_t tileIndex)
 Plot a single tile, by absolute tile index, at location 'pos' in tile units. More...
 
void setBorder (RGB565 color)
 Set the border color, given an arbitrary 16-bit RGB565 color. More...
 
void setMatrix (const AffineMatrix &m)
 Set the current affine transform matrix.
 
void span (UInt2 pos, unsigned width, unsigned tileIndex)
 Plot a horizontal span of tiles, by absolue tile index, given the position of the leftmost tile and the number of tiles to plot. More...
 
void text (Int2 topLeft, const AssetImage &font, const char *str, char firstChar= ' ')
 Draw text, using an AssetImage as a fixed width font. More...
 
uint16_t tileAddr (UInt2 pos)
 Calculate the video buffer address of a particular tile. More...
 
_SYSVideoBuffer & videoBuffer ()
 Return the VideoBuffer associated with this drawable.
 

Static Public Member Functions

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

A VRAM accessor for drawing graphics in the BG2 mode.

This is a special-purpose mode for doing scaling, rotation, and other effects using an affine transform matrix.

Conceptually, this mode is a 256x256-pixel canvas, repeating forever in both axes, in which the top-left quadrant is a 16x16-tile drawable, and the other three quadrants are painted with a solid "border" color.

This arrangement allows you to treat the 16x16 area as "centered" on the screen, with the border color poking through when that image is scaled down or rotated.

Note that the border color is not part of the Colormap, it is a separate piece of state that can be set through the BG2Drawable.

Member Function Documentation

void Sifteo::BG2Drawable::erase ( uint16_t  index = 0)
inline

Erase mode-specific VRAM, filling the BG2 buffer with the specified absolute tile index value.

Does not modify the affine transform or the border color.

void Sifteo::BG2Drawable::fill ( UInt2  topLeft,
UInt2  size,
unsigned  tileIndex 
)
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.

void Sifteo::BG2Drawable::image ( UInt2  pos,
const AssetImage image,
unsigned  frame = 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.

void Sifteo::BG2Drawable::image ( UInt2  destXY,
UInt2  size,
const AssetImage image,
UInt2  srcXY,
unsigned  frame = 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.

void Sifteo::BG2Drawable::plot ( UInt2  pos,
uint16_t  tileIndex 
)
inline

Plot a single tile, by absolute tile index, at location 'pos' in tile units.

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

void Sifteo::BG2Drawable::setBorder ( RGB565  color)
inline

Set the border color, given an arbitrary 16-bit RGB565 color.

This color is displayed 'outside' the 16x16-tile drawable region, in the other three quadrants of the virtual 256x256-pixel plane.

void Sifteo::BG2Drawable::span ( UInt2  pos,
unsigned  width,
unsigned  tileIndex 
)
inline

Plot a horizontal span of tiles, by absolue 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.

void Sifteo::BG2Drawable::text ( Int2  topLeft,
const AssetImage font,
const char *  str,
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.

uint16_t Sifteo::BG2Drawable::tileAddr ( UInt2  pos)
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: