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>
49 _SYSAttachedVideoBuffer sys;
55 return _SYS_VRAM_BG0_WIDTH;
62 return _SYS_VRAM_BG0_WIDTH;
112 _SYS_vbuf_fill(&sys.vbuf, 0, _SYS_TILE77(index),
sizeInWords());
133 _SYS_vbuf_poke(&sys.vbuf,
offsetof(_SYSVideoRAM, bg0_x) / 2,
143 unsigned word = _SYS_vbuf_peek(&sys.vbuf,
offsetof(_SYSVideoRAM, bg0_x) / 2);
144 return vec<int>(word & 0xFF, word >> 8);
162 return _SYS_INVERSE_TILE77(_SYS_vbuf_peek(&sys.vbuf,
tileAddr(pos)));
173 _SYS_vbuf_poke(&sys.vbuf,
tileAddr(pos), _SYS_TILE77(tileIndex));
182 void span(
UInt2 pos,
unsigned width,
unsigned tileIndex)
186 _SYS_vbuf_fill(&sys.vbuf,
tileAddr(pos), _SYS_TILE77(tileIndex), width);
196 span(pos, width, image.
tile(sys.cube,0));
208 span(topLeft, size.
x, tileIndex);
222 fill(topLeft, size, image.
tile(sys.cube, 0));
236 _SYS_image_BG0Draw(&sys, image,
tileAddr(pos), frame);
250 _SYS_image_BG0DrawRect(&sys, image,
tileAddr(destXY),
251 frame, (_SYSInt2*) &srcXY, (_SYSInt2*) &size);
263 unsigned lineAddr = addr;
270 _SYS_image_BG0Draw(&sys, font, addr, c - firstChar);
static unsigned sizeInBytes()
Returns the size of this drawable's tile data, in bytes.
Definition: bg0.h:96
#define offsetof(t, m)
Definition: macros.h:368
void fill(UInt2 topLeft, UInt2 size, const PinnedAssetImage &image)
Fill a rectangle of identical tiles, using the first tile of a pinned asset.
Definition: bg0.h:220
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: bg0.h:205
Generalized two-element cartesian coordinate vector.
Definition: math.h:488
void setPanning(Int2 pixels)
Change the hardware pixel-panning origin for this mode.
Definition: bg0.h:132
#define ASSERT(_x)
Runtime debug assertion.
Definition: macros.h:205
int tileWidth() const
The width of this image, in tiles.
Definition: image.h:90
static unsigned tileWidth()
Return the width, in tiles, of this mode.
Definition: bg0.h:54
An AssetImage in which all tiles are stored sequentially in memory.
Definition: image.h:134
uint16_t tileAddr(UInt2 pos)
Calculate the video buffer address of a particular tile.
Definition: bg0.h:152
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: bg0.h:248
void erase(uint16_t index=0)
Erase mode-specific VRAM, filling the BG0 buffer with the specified absolute tile index value and res...
Definition: bg0.h:111
T x
Vector component X.
Definition: math.h:489
void plot(UInt2 pos, uint16_t tileIndex)
Plot a single tile, by absolute tile index, at location 'pos' in tile units.
Definition: bg0.h:171
A VRAM accessor for drawing graphics in the BG0 mode.
Definition: bg0.h:48
int tileHeight() const
The height of this image, in tiles.
Definition: image.h:93
static unsigned sizeInWords()
Returns the size of this drawable's tile data, in 16-bit words.
Definition: bg0.h:103
A lightweight identifier for one Sifteo cube.
Definition: cube.h:85
static UInt2 tileSize()
Return the size of this mode as a vector, in tiles.
Definition: bg0.h:68
CubeID cube() const
Return the CubeID associated with this drawable.
Definition: bg0.h:287
void span(UInt2 pos, unsigned width, unsigned tileIndex)
Plot a horizontal span of tiles, by absolute tile index, given the position of the leftmost tile and ...
Definition: bg0.h:182
uint16_t tile(unsigned i) const
Returns the index of the tile at linear position 'i' in the image.
Definition: image.h:160
Int2 getPanning() const
Retrieve the last value set by setPanning(), modulo the layer size in pixels.
Definition: bg0.h:142
Any kind of asset image, as defined in your stir script.
Definition: image.h:67
uint16_t tile(UInt2 pos)
Retrieve the absolute tile index currently set at the given address. The inverse of plot()...
Definition: bg0.h:160
_SYSVideoBuffer & videoBuffer()
Return the VideoBuffer associated with this drawable.
Definition: bg0.h:280
void erase(const PinnedAssetImage &image)
Erase mode-specific VRAM, filling the BG0 buffer with the first tile from the specified PinnedAssetIm...
Definition: bg0.h:120
static UInt2 pixelSize()
Return the size of this mode as a vector, in pixels.
Definition: bg0.h:89
void span(UInt2 pos, unsigned width, const PinnedAssetImage &image)
Plot a horizontal span of tiles, using the first tile of a pinned asset.
Definition: bg0.h:194
T y
Vector component Y.
Definition: math.h:490
unsigned umod(int a, int b)
Compute the unsigned remainder from dividing two signed integers.
Definition: math.h:208
static unsigned tileHeight()
Return the height, in tiles, of this mode.
Definition: bg0.h:61
static unsigned pixelWidth()
Return the width, in pixels, of this mode.
Definition: bg0.h:75
static unsigned pixelHeight()
Return the height, in pixel, of this mode.
Definition: bg0.h:82
void text(Int2 topLeft, const AssetImage &font, const char *str, char firstChar= ' ')
Draw text, using an AssetImage as a fixed width font.
Definition: bg0.h:260
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: bg0.h:234
Vector2< T > vec(T x, T y)
Create a Vector2, from a set of (x,y) coordinates.
Definition: math.h:658