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>
54 _SYSAttachedVideoBuffer sys;
60 BLACK_ON_WHITE = 0 << 10,
61 BLUE_ON_WHITE = 1 << 10,
62 ORANGE_ON_WHITE = 2 << 10,
63 YELLOW_ON_BLUE = 3 << 10,
64 RED_ON_WHITE = 4 << 10,
65 GRAY_ON_WHITE = 5 << 10,
66 WHITE_ON_BLACK = 6 << 10,
67 WHITE_ON_BLUE = 7 << 10,
68 WHITE_ON_TEAL = 8 << 10,
69 BLACK_ON_YELLOW = 9 << 10,
70 DKGRAY_ON_LTGRAY = 10 << 10,
71 GREEN_ON_WHITE = 11 << 10,
72 WHITE_ON_GREEN = 12 << 10,
73 PURPLE_ON_WHITE = 13 << 10,
74 LTBLUE_ON_DKBLUE = 14 << 10,
75 GOLD_ON_WHITE = 15 << 10,
78 BLACK = BLACK_ON_WHITE,
80 ORANGE = ORANGE_ON_WHITE,
83 GREEN = GREEN_ON_WHITE,
84 PURPLE = PURPLE_ON_WHITE,
117 return _SYS_VRAM_BG0_WIDTH;
124 return _SYS_VRAM_BG0_WIDTH;
183 _SYS_vbuf_fill(&sys.vbuf, 0, _SYS_TILE77(index),
sizeInWords());
196 _SYS_vbuf_poke(&sys.vbuf,
offsetof(_SYSVideoRAM, bg0_x) / 2,
206 unsigned word = _SYS_vbuf_peek(&sys.vbuf,
offsetof(_SYSVideoRAM, bg0_x) / 2);
207 return vec<int>(word & 0xFF, word >> 8);
224 _SYS_vbuf_poke(&sys.vbuf,
tileAddr(pos), _SYS_TILE77(tileIndex));
233 void span(
UInt2 pos,
unsigned width,
unsigned tileIndex)
237 _SYS_vbuf_fill(&sys.vbuf,
tileAddr(pos), _SYS_TILE77(tileIndex), width);
249 span(topLeft, size.
x, tileIndex);
267 int wTiles = pixelWidth / 8;
268 int wRemainder = pixelWidth % 8;
271 _SYS_vbuf_fill(&sys.vbuf, addr,
272 _SYS_TILE77(palette ^
SOLID_FG), wTiles);
274 _SYS_vbuf_poke(&sys.vbuf, addr + wTiles,
275 _SYS_TILE77(palette ^ (
H_BARGRAPH + wRemainder - 1)));
290 unsigned lineAddr = addr;
297 _SYS_vbuf_poke(&sys.vbuf, addr++, _SYS_TILE77(
charTile(c, palette)));
#define offsetof(t, m)
Definition: macros.h:368
static unsigned pixelWidth()
Return the width, in pixels, of this mode.
Definition: bg0rom.h:137
void span(UInt2 pos, unsigned width, unsigned tileIndex)
Plot a horizontal span of tiles, given the position of the leftmost tile, and the number of tiles to ...
Definition: bg0rom.h:233
void plot(UInt2 pos, uint16_t tileIndex)
Plot a single tile, at location 'pos', in tile units.
Definition: bg0rom.h:222
First tile in the vertical bargraph series.
Definition: bg0rom.h:95
Generalized two-element cartesian coordinate vector.
Definition: math.h:488
#define ASSERT(_x)
Runtime debug assertion.
Definition: macros.h:205
static unsigned sizeInBytes()
Returns the size of this drawable's tile data, in bytes.
Definition: bg0rom.h:158
static unsigned pixelHeight()
Return the height, in pixel, of this mode.
Definition: bg0rom.h:144
Solid foreground-colored tile.
Definition: bg0rom.h:94
void setPanning(Int2 pixels)
Change the hardware pixel-panning origin for this mode.
Definition: bg0rom.h:195
ColorMode
Color modes, XOR'ed with the tile IDs below.
Definition: bg0rom.h:108
A VRAM accessor for drawing graphics in the BG0_ROM mode.
Definition: bg0rom.h:53
T x
Vector component X.
Definition: math.h:489
static unsigned tileHeight()
Return the height, in tiles, of this mode.
Definition: bg0rom.h:123
static unsigned tileWidth()
Return the width, in tiles, of this mode.
Definition: bg0rom.h:116
Palette
Palette IDs, XOR'ed with the tile IDs below.
Definition: bg0rom.h:59
A lightweight identifier for one Sifteo cube.
Definition: cube.h:85
_SYSVideoBuffer & videoBuffer()
Return the VideoBuffer associated with this drawable.
Definition: bg0rom.h:305
uint16_t tileAddr(UInt2 pos)
Calculate the video buffer address of a particular tile.
Definition: bg0rom.h:174
void erase(uint16_t index=0)
Erase mode-specific VRAM, filling the BG0 buffer with the specified value and resetting the panning r...
Definition: bg0rom.h:182
Int2 getPanning() const
Retrieve the last value set by setPanning(), modulo the layer size in pixels.
Definition: bg0rom.h:205
Solid background-colored tile (space)
Definition: bg0rom.h:93
CubeID cube() const
Return the CubeID associated with this drawable.
Definition: bg0rom.h:312
First character in the font, ASCII space.
Definition: bg0rom.h:92
static UInt2 pixelSize()
Return the size of this mode as a vector, in pixels.
Definition: bg0rom.h:151
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
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: bg0rom.h:246
Tiles
Well-known tile numbers.
Definition: bg0rom.h:91
void hBargraph(Int2 topLeft, unsigned pixelWidth, enum Palette palette=BLACK, unsigned tileHeight=1)
Draw a horizontal bargraph, with its top-left corner position specified in tiles, and its width in pi...
Definition: bg0rom.h:263
First tile in the horizontal bargraph series.
Definition: bg0rom.h:96
void text(Int2 topLeft, const char *str, enum Palette palette=BLACK)
Draw text, using the builtin ROM font, starting at location 'topLeft' in tiles.
Definition: bg0rom.h:287
static uint16_t charTile(char c, enum Palette palette=BLACK)
Calculate the tile index of one character in the ROM font.
Definition: bg0rom.h:213
static unsigned sizeInWords()
Returns the size of this drawable's tile data, in 16-bit words.
Definition: bg0rom.h:165
static UInt2 tileSize()
Return the size of this mode as a vector, in tiles.
Definition: bg0rom.h:130
Vector2< T > vec(T x, T y)
Create a Vector2, from a set of (x,y) coordinates.
Definition: math.h:658