28 # error This is a userspace-only header, not allowed by the current build.
31 #include <sifteo/abi.h>
32 #include <sifteo/macros.h>
33 #include <sifteo/math.h>
34 #include <sifteo/asset.h>
35 #include <sifteo/video/color.h>
62 _SYSAttachedVideoBuffer sys;
68 return _SYS_VRAM_BG2_WIDTH;
75 return _SYS_VRAM_BG2_WIDTH;
136 _SYS_vbuf_fill(&sys.vbuf, 0, _SYS_TILE77(index),
sizeInWords());
154 _SYS_vbuf_poke(&sys.vbuf,
offsetof(_SYSVideoRAM, bg2_border) / 2,
162 RGB565 result = { _SYS_vbuf_peek(&sys.vbuf,
offsetof(_SYSVideoRAM, bg2_border)) };
172 256.0f * m.
cx + 0.5f,
173 256.0f * m.
cy + 0.5f,
174 256.0f * m.
xx + 0.5f,
175 256.0f * m.
xy + 0.5f,
176 256.0f * m.
yx + 0.5f,
177 256.0f * m.
yy + 0.5f,
179 _SYS_vbuf_write(&sys.vbuf,
offsetof(_SYSVideoRAM, bg2_affine)/2,
180 (
const uint16_t *)&a, 6);
191 _SYS_vbuf_poke(&sys.vbuf,
tileAddr(pos), _SYS_TILE77(tileIndex));
200 void span(
UInt2 pos,
unsigned width,
unsigned tileIndex)
204 _SYS_vbuf_fill(&sys.vbuf,
tileAddr(pos), _SYS_TILE77(tileIndex), width);
216 span(topLeft, size.
x, tileIndex);
232 _SYS_image_BG2Draw(&sys, image,
tileAddr(pos), frame);
245 _SYS_image_BG2DrawRect(&sys, image,
tileAddr(destXY),
246 frame, (_SYSInt2*) &srcXY, (_SYSInt2*) &size);
258 unsigned lineAddr = addr;
265 _SYS_image_BG2Draw(&sys, font, addr, c - firstChar);
#define offsetof(t, m)
Definition: macros.h:368
static UInt2 pixelSize()
Return the size of this mode as a vector, in pixels.
Definition: bg2.h:102
Generalized two-element cartesian coordinate vector.
Definition: math.h:488
static unsigned pixelHeight()
Return the height, in pixel, of this mode.
Definition: bg2.h:95
void image(UInt2 pos, const AssetImage &image, unsigned frame=0)
Draw a full AssetImage frame, with its top-left corner at the specified location. ...
Definition: bg2.h:230
static unsigned sizeInWords()
Returns the size of this drawable's tile data, in 16-bit words.
Definition: bg2.h:116
void fill(UInt2 topLeft, UInt2 size, unsigned tileIndex)
Fill a rectangle of identical tiles, specified as a top-left corner location and a size...
Definition: bg2.h:213
#define ASSERT(_x)
Runtime debug assertion.
Definition: macros.h:205
static unsigned tileWidth()
Return the width, in tiles, of this mode.
Definition: bg2.h:67
float cx
Matrix member cx, the constant offset for X.
Definition: math.h:1043
int tileWidth() const
The width of this image, in tiles.
Definition: image.h:90
float cy
Matrix member cy, the constant offset for Y.
Definition: math.h:1044
void text(Int2 topLeft, const AssetImage &font, const char *str, char firstChar= ' ')
Draw text, using an AssetImage as a fixed width font.
Definition: bg2.h:255
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 t...
Definition: bg2.h:200
A VRAM accessor for drawing graphics in the BG2 mode.
Definition: bg2.h:61
An AssetImage in which all tiles are stored sequentially in memory.
Definition: image.h:134
static unsigned sizeInBytes()
Returns the size of this drawable's tile data, in bytes.
Definition: bg2.h:109
static UInt2 tileSize()
Return the size of this mode as a vector, in tiles.
Definition: bg2.h:81
static unsigned tileHeight()
Return the height, in tiles, of this mode.
Definition: bg2.h:74
float yy
Matrix member yy, the vertical Y delta.
Definition: math.h:1048
T x
Vector component X.
Definition: math.h:489
void setMatrix(const AffineMatrix &m)
Set the current affine transform matrix.
Definition: bg2.h:169
int tileHeight() const
The height of this image, in tiles.
Definition: image.h:93
float xy
Matrix member xy, the horizontal Y delta.
Definition: math.h:1046
A lightweight identifier for one Sifteo cube.
Definition: cube.h:85
RGB565 getBorder() const
Get the last border color set by setBorder().
Definition: bg2.h:161
void erase(const PinnedAssetImage &image)
Erase mode-specific VRAM, filling the BG2 buffer with the first tile from the specified PinnedAssetIm...
Definition: bg2.h:143
CubeID cube() const
Return the CubeID associated with this drawable.
Definition: bg2.h:282
uint16_t tile(unsigned i) const
Returns the index of the tile at linear position 'i' in the image.
Definition: image.h:160
An augmented 3x2 matrix, for doing 2D affine transforms.
Definition: math.h:1042
Any kind of asset image, as defined in your stir script.
Definition: image.h:67
void erase(uint16_t index=0)
Erase mode-specific VRAM, filling the BG2 buffer with the specified absolute tile index value...
Definition: bg2.h:135
T y
Vector component Y.
Definition: math.h:490
float yx
Matrix member yx, the vertical X delta.
Definition: math.h:1047
void plot(UInt2 pos, uint16_t tileIndex)
Plot a single tile, by absolute tile index, at location 'pos' in tile units.
Definition: bg2.h:189
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.
Definition: bg2.h:243
static unsigned pixelWidth()
Return the width, in pixels, of this mode.
Definition: bg2.h:88
void setBorder(RGB565 color)
Set the border color, given an arbitrary 16-bit RGB565 color.
Definition: bg2.h:153
Represents a 16-bit 5:6:5 color, the native format used by our display.
Definition: color.h:50
uint16_t value
The raw color value, as a 16-bit integer.
Definition: color.h:52
uint16_t tileAddr(UInt2 pos)
Calculate the video buffer address of a particular tile.
Definition: bg2.h:125
_SYSVideoBuffer & videoBuffer()
Return the VideoBuffer associated with this drawable.
Definition: bg2.h:275
float xx
Matrix member xx, the horizontal X delta.
Definition: math.h:1045
Vector2< T > vec(T x, T y)
Create a Vector2, from a set of (x,y) coordinates.
Definition: math.h:658