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>
15 #include <sifteo/asset.h>
51 BG1Mask result = { 0, 0, 0, 0, 0, 0, 0, 0 };
65 unsigned xBits = ((1 << size.
x) - 1) << topLeft.
x;
66 unsigned yBits = ((1 << size.
y) - 1) << topLeft.
y;
68 unsigned row0 = yBits & 0x0001 ? xBits : 0;
69 unsigned row1 = yBits & 0x0002 ? xBits : 0;
70 unsigned row2 = yBits & 0x0004 ? xBits : 0;
71 unsigned row3 = yBits & 0x0008 ? xBits : 0;
72 unsigned row4 = yBits & 0x0010 ? xBits : 0;
73 unsigned row5 = yBits & 0x0020 ? xBits : 0;
74 unsigned row6 = yBits & 0x0040 ? xBits : 0;
75 unsigned row7 = yBits & 0x0080 ? xBits : 0;
76 unsigned row8 = yBits & 0x0100 ? xBits : 0;
77 unsigned row9 = yBits & 0x0200 ? xBits : 0;
78 unsigned rowA = yBits & 0x0400 ? xBits : 0;
79 unsigned rowB = yBits & 0x0800 ? xBits : 0;
80 unsigned rowC = yBits & 0x1000 ? xBits : 0;
81 unsigned rowD = yBits & 0x2000 ? xBits : 0;
82 unsigned rowE = yBits & 0x4000 ? xBits : 0;
83 unsigned rowF = yBits & 0x8000 ? xBits : 0;
102 _SYS_memset32(&row10, 0, 8);
109 return (uint16_t*)
this;
111 const uint16_t *
rows()
const {
112 return (
const uint16_t*)
this;
120 void plot(
unsigned x,
unsigned y) {
140 for (
unsigned y = 0; y < size.
y; y++)
141 for (
unsigned x = 0; x < size.
x; x++)
142 plot(topLeft.
x + x, topLeft.
y + y);
147 row10 |= other.row10;
148 row32 |= other.row32;
149 row54 |= other.row54;
150 row76 |= other.row76;
151 row98 |= other.row98;
152 rowBA |= other.rowBA;
153 rowDC |= other.rowDC;
154 rowFE |= other.rowFE;
160 row10 &= other.row10;
161 row32 &= other.row32;
162 row54 &= other.row54;
163 row76 &= other.row76;
164 row98 &= other.row98;
165 rowBA &= other.rowBA;
166 rowDC &= other.rowDC;
167 rowFE &= other.rowFE;
173 row10 ^= other.row10;
174 row32 ^= other.row32;
175 row54 ^= other.row54;
176 row76 ^= other.row76;
177 row98 ^= other.row98;
178 rowBA ^= other.rowBA;
179 rowDC ^= other.rowDC;
180 rowFE ^= other.rowFE;
267 _SYSAttachedVideoBuffer sys;
273 return _SYS_VRAM_BG1_WIDTH;
280 return _SYS_VRAM_BG1_WIDTH;
315 return _SYS_VRAM_BG1_TILES;
325 _SYS_vbuf_fill(&sys.vbuf, _SYS_VA_BG1_TILES / 2,
343 void fill(uint16_t index = 0) {
344 _SYS_vbuf_fill(&sys.vbuf, _SYS_VA_BG1_TILES / 2,
371 _SYS_vbuf_fill(&sys.vbuf, _SYS_VA_BG1_BITMAP/2, 0, _SYS_VRAM_BG1_WIDTH);
388 _SYS_vbuf_write(&sys.vbuf,
offsetof(_SYSVideoRAM, bg1_bitmap)/2,
415 _SYS_vbuf_fill(&sys.vbuf,
416 offsetof(_SYSVideoRAM, bg1_bitmap)/2 + topLeft.
y,
417 ((1 << size.
x) - 1) << topLeft.
x, size.
y);
431 unsigned x = pixels.
x & 0xFF;
432 unsigned y = pixels.
y & 0xFF;
433 _SYS_vbuf_poke(&sys.vbuf,
offsetof(_SYSVideoRAM, bg1_x) / 2, x | (y << 8));
440 unsigned word = _SYS_vbuf_peek(&sys.vbuf,
offsetof(_SYSVideoRAM, bg0_x) / 2);
441 return vec<int>((int8_t)(word & 0xFF), (int8_t)(word >> 8));
448 void plot(
unsigned locationIndex, uint16_t tileIndex) {
450 _SYS_vbuf_poke(&sys.vbuf, _SYS_VA_BG1_TILES / 2 + locationIndex,
451 _SYS_TILE77(tileIndex));
460 void span(
unsigned locationIndex,
unsigned count,
unsigned tileIndex)
463 (locationIndex + count) <
numTiles());
464 _SYS_vbuf_fill(&sys.vbuf, _SYS_VA_BG1_TILES / 2 + locationIndex,
465 _SYS_TILE77(tileIndex), count);
481 _SYS_image_BG1Draw(&sys, image, (_SYSInt2*) &pos, frame);
497 _SYS_image_BG1DrawRect(&sys, image, (_SYSInt2*) &destXY,
498 frame, (_SYSInt2*) &srcXY, (_SYSInt2*) &size);
517 _SYS_image_BG1MaskedDraw(&sys, image, key.
tile(sys.cube, 0), frame);
538 _SYS_image_BG1MaskedDrawRect(&sys, image, key.
tile(sys.cube, 0), frame,
539 (_SYSInt2*) &srcXY, (_SYSInt2*) &size);
558 _SYS_image_BG1Draw(&sys, font, (_SYSInt2*) &pos, c - firstChar);