9 # error This is a userspace-only header, not allowed by the current build.
12 #include <sifteo/abi.h>
13 #include <sifteo/macros.h>
14 #include <sifteo/math.h>
40 RGB565 result = { (r << 11) | (g << 5) | b };
53 return from565( ((
unsigned)r * 31 + 128) / 255,
54 ((
unsigned)g * 63 + 128) / 255,
55 ((
unsigned)b * 31 + 128) / 255 );
63 return from565( r * 31.f + 0.5f,
75 return fromRGB((uint8_t)(rgb >> 16), (uint8_t)(rgb >> 8), (uint8_t)rgb);
82 return (
value >> 11) & 0x1F;
89 return (
value >> 5) & 0x3F;
107 return red5() * 255 / 31;
114 return green6() * 255 / 63;
121 return blue5() * 255 / 31;
143 unsigned invA = 0xff - A;
146 (
blue5() * invA + other.
blue5() * A) / 0xff );
169 _SYSAttachedVideoBuffer *sys;
176 _SYS_vbuf_poke(&sys->vbuf, _SYS_VA_COLORMAP / 2 + index, color.value);
182 void set(uint8_t r, uint8_t g, uint8_t b)
const {
189 void set(
float r,
float g,
float b)
const {
199 void set(uint32_t rgb)
const {
226 RGB565 result = { _SYS_vbuf_peek(&sys->vbuf, _SYS_VA_COLORMAP / 2 + index) };
246 _SYSAttachedVideoBuffer sys;
269 _SYS_vbuf_fill(&sys.vbuf, _SYS_VA_COLORMAP / 2, 0,
NUM_COLORS);
276 _SYS_vbuf_fill(&sys.vbuf, _SYS_VA_COLORMAP / 2, color.
value,
NUM_COLORS);
285 _SYS_vbuf_write(&sys.vbuf, _SYS_VA_COLORMAP / 2 + firstColor,
286 &colors[0].
value, numColors);
302 static const RGB565 colors[] = {
329 (*this)[0].set(color0);
330 (*this)[1].set(color1);
340 void setMono(uint32_t color0, uint32_t color1) {
341 (*this)[0].set(color0);
342 (*this)[1].set(color1);