v1.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
tilebuffer.h
1 /* -*- mode: C; c-basic-offset: 4; intent-tabs-mode: nil -*-
2  *
3  * Sifteo SDK
4  *
5  * Copyright <c> 2012 Sifteo, Inc.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23  * THE SOFTWARE.
24  */
25 
26 #pragma once
27 #ifdef NOT_USERSPACE
28 # error This is a userspace-only header, not allowed by the current build.
29 #endif
30 
31 #include <sifteo/abi.h>
32 #include <sifteo/macros.h>
33 #include <sifteo/math.h>
34 #include <sifteo/asset.h>
35 #include <sifteo/memory.h>
36 #include <sifteo/cube.h>
37 
38 namespace Sifteo {
39 
69 template <unsigned tW, unsigned tH, unsigned tF = 1>
70 struct TileBuffer {
71  struct {
72  _SYSAssetImage image;
73  _SYSCubeID cube;
74  } sys;
75  uint16_t tiles[tW * tH * tF];
76 
77  // Implicit conversion to AssetImage base class
78  operator const AssetImage& () const { return *reinterpret_cast<const AssetImage*>(&sys.image); }
79  operator AssetImage& () { return *reinterpret_cast<AssetImage*>(&sys.image); }
80  operator const AssetImage* () const { return reinterpret_cast<const AssetImage*>(&sys.image); }
81  operator AssetImage* () { return reinterpret_cast<AssetImage*>(&sys.image); }
82 
83  // Implicit conversion to FlatAssetImage
84  operator const FlatAssetImage& () const { return *reinterpret_cast<const FlatAssetImage*>(&sys.image); }
85  operator FlatAssetImage& () { return *reinterpret_cast<FlatAssetImage*>(&sys.image); }
86  operator const FlatAssetImage* () const { return reinterpret_cast<const FlatAssetImage*>(&sys.image); }
87  operator FlatAssetImage* () { return reinterpret_cast<FlatAssetImage*>(&sys.image); }
88 
89  // Implicit conversion to system object
90  operator const _SYSAssetImage& () const { return sys.image; }
91  operator _SYSAssetImage& () { return sys.image; }
92  operator const _SYSAssetImage* () const { return sys.image; }
93  operator _SYSAssetImage* () { return sys.image; }
94 
98  CubeID cube() const {
99  ASSERT(sys.cube != _SYS_CUBE_ID_INVALID);
100  return sys.cube;
101  }
102 
113  sys.cube = cube;
114  }
115 
119  void init() {
120  sys.cube = _SYS_CUBE_ID_INVALID;
121  bzero(sys.image);
122  sys.image.width = tW;
123  sys.image.height = tH;
124  sys.image.frames = tF;
125  sys.image.format = _SYS_AIF_FLAT;
126  sys.image.pData = reinterpret_cast<uint32_t>(&tiles[0]);
127  }
128 
136  init();
137  }
138 
151  init();
152 
153  sys.cube = cube;
154  }
155 
159  static unsigned tileWidth() {
160  return tW;
161  }
162 
166  static unsigned tileHeight() {
167  return tH;
168  }
169 
173  static UInt2 tileSize() {
174  return vec(tileWidth(), tileHeight());
175  }
176 
180  static unsigned pixelWidth() {
181  return tileWidth() * 8;
182  }
183 
187  static unsigned pixelHeight() {
188  return tileHeight() * 8;
189  }
190 
194  static UInt2 pixelSize() {
195  return vec(pixelWidth(), pixelHeight());
196  }
197 
201  static int numFrames() {
202  return tF;
203  }
204 
208  static int numTilesPerFrame() {
209  return tileWidth() * tileHeight();
210  }
211 
215  static int numTiles() {
216  return numFrames() * numTilesPerFrame();
217  }
218 
222  static unsigned sizeInBytes() {
223  return numTiles() * 2;
224  }
225 
229  static unsigned sizeInWords() {
230  return numTiles();
231  }
232 
237  void erase(uint16_t index = 0) {
238  ASSERT(sys.cube != _SYS_CUBE_ID_INVALID);
239  memset16(&tiles[0], index, sizeInWords());
240  }
241 
246  void erase(const PinnedAssetImage &image) {
247  erase(image.tile(sys.cube, 0));
248  }
249 
255  uint16_t tileAddr(UInt2 pos, unsigned frame = 0) const {
256  ASSERT(sys.cube != _SYS_CUBE_ID_INVALID);
257  return pos.x + (pos.y + frame * tileHeight()) * tileWidth();
258  }
259 
266  void plot(unsigned i, uint16_t tileIndex) {
267  ASSERT(sys.cube != _SYS_CUBE_ID_INVALID);
268  ASSERT(i < numTiles());
269  tiles[i] = tileIndex;
270  }
271 
278  void plot(UInt2 pos, uint16_t tileIndex, unsigned frame = 0) {
279  ASSERT(sys.cube != _SYS_CUBE_ID_INVALID);
280  ASSERT(pos.x < tileWidth() && pos.y < tileHeight() && frame < numFrames());
281  tiles[tileAddr(pos, frame)] = tileIndex;
282  }
283 
287  uint16_t tile(unsigned i) const {
288  ASSERT(sys.cube != _SYS_CUBE_ID_INVALID);
289  ASSERT(i < numTiles());
290  return tiles[i];
291  }
292 
297  uint16_t tile(UInt2 pos, unsigned frame = 0) const {
298  ASSERT(sys.cube != _SYS_CUBE_ID_INVALID);
299  ASSERT(pos.x < tileWidth() && pos.y < tileHeight() && frame < numFrames());
300  return tiles[tileAddr(pos, frame)];
301  }
302 
309  void span(UInt2 pos, unsigned width, unsigned tileIndex, unsigned frame = 0)
310  {
311  ASSERT(sys.cube != _SYS_CUBE_ID_INVALID);
312  ASSERT(pos.x <= tileWidth() && width <= tileWidth() &&
313  (pos.x + width) <= tileWidth() && pos.y < tileHeight());
314  memset16(&tiles[tileAddr(pos, frame)], tileIndex, width);
315  }
316 
322  void span(UInt2 pos, unsigned width, const PinnedAssetImage &image, unsigned frame = 0)
323  {
324  span(pos, width, image.tile(sys.cube, 0), frame);
325  }
326 
333  void fill(UInt2 topLeft, UInt2 size, unsigned tileIndex, unsigned frame = 0)
334  {
335  while (size.y) {
336  span(topLeft, size.x, tileIndex, frame);
337  size.y--;
338  topLeft.y++;
339  }
340  }
341 
348  void fill(UInt2 topLeft, UInt2 size, const PinnedAssetImage &image, unsigned frame = 0)
349  {
350  fill(topLeft, size, image.tile(sys.cube, 0), frame);
351  }
352 
362  void image(UInt2 pos, const AssetImage &image, unsigned srcFrame = 0, unsigned destFrame = 0)
363  {
364  ASSERT(sys.cube != _SYS_CUBE_ID_INVALID);
365  ASSERT(pos.x < tileWidth() && pos.x + image.tileWidth() <= tileWidth() &&
366  pos.y < tileHeight() && pos.y + image.tileHeight() <= tileHeight() &&
367  destFrame < numFrames());
368  _SYS_image_memDraw(&tiles[tileAddr(pos, destFrame)], sys.cube, image, tileWidth(), srcFrame);
369  }
370 
380  void image(UInt2 destXY, UInt2 size, const AssetImage &image, UInt2 srcXY,
381  unsigned srcFrame = 0, unsigned destFrame = 0)
382  {
383  ASSERT(sys.cube != _SYS_CUBE_ID_INVALID);
384  ASSERT(destXY.x < tileWidth() && destXY.x + size.x <= tileWidth() &&
385  destXY.y < tileHeight() && destXY.y + size.y <= tileHeight() &&
386  destFrame < numFrames());
387  _SYS_image_memDrawRect(&tiles[tileAddr(destXY, destFrame)], sys.cube,
388  image, tileWidth(), srcFrame, (_SYSInt2*) &srcXY, (_SYSInt2*) &size);
389  }
390 
397  void text(Int2 topLeft, const AssetImage &font, const char *str,
398  unsigned destFrame = 0, char firstChar = ' ')
399  {
400  ASSERT(sys.cube != _SYS_CUBE_ID_INVALID);
401  uint16_t *addr = &tiles[tileAddr(topLeft, destFrame)];
402  uint16_t *lineAddr = addr;
403  char c;
404 
405  while ((c = *str)) {
406  if (c == '\n') {
407  addr = (lineAddr += tileWidth());
408  } else {
409  ASSERT(font.tileWidth() + (font.tileHeight() - 1) * tileWidth() + addr
410  <= numTiles() + tiles);
411  _SYS_image_memDraw(addr, sys.cube, font, tileWidth(), c - firstChar);
412  addr += font.tileWidth();
413  }
414  str++;
415  }
416  }
417 };
418 
419 
447 template <unsigned tW, unsigned tH, unsigned tF = 1>
449  _SYSAssetImage sys;
450  uint16_t tiles[tW * tH * tF];
451 
453  operator const AssetImage& () const { return *reinterpret_cast<const AssetImage*>(&sys); }
454  operator AssetImage& () { return *reinterpret_cast<AssetImage*>(&sys); }
455  operator const AssetImage* () const { return reinterpret_cast<const AssetImage*>(&sys); }
456  operator AssetImage* () { return reinterpret_cast<AssetImage*>(&sys); }
457 
459  operator const FlatAssetImage& () const { return *reinterpret_cast<const FlatAssetImage*>(&sys); }
460  operator FlatAssetImage& () { return *reinterpret_cast<FlatAssetImage*>(&sys); }
461  operator const FlatAssetImage* () const { return reinterpret_cast<const FlatAssetImage*>(&sys); }
462  operator FlatAssetImage* () { return reinterpret_cast<FlatAssetImage*>(&sys); }
463 
465  operator const _SYSAssetImage& () const { return sys; }
466  operator _SYSAssetImage& () { return sys; }
467  operator const _SYSAssetImage* () const { return sys; }
468  operator _SYSAssetImage* () { return sys; }
469 
476  void init() {
477  bzero(sys);
478  sys.width = tW;
479  sys.height = tH;
480  sys.frames = tF;
481  sys.format = _SYS_AIF_FLAT;
482  sys.pData = reinterpret_cast<uint32_t>(&tiles[0]);
483  }
484 
489  init();
490  }
491 
495  static unsigned tileWidth() {
496  return tW;
497  }
498 
502  static unsigned tileHeight() {
503  return tH;
504  }
505 
509  static UInt2 tileSize() {
510  return vec(tileWidth(), tileHeight());
511  }
512 
516  static unsigned pixelWidth() {
517  return tileWidth() * 8;
518  }
519 
523  static unsigned pixelHeight() {
524  return tileHeight() * 8;
525  }
526 
530  static UInt2 pixelSize() {
531  return vec(pixelWidth(), pixelHeight());
532  }
533 
537  static int numFrames() {
538  return tF;
539  }
540 
544  static int numTilesPerFrame() {
545  return tileWidth() * tileHeight();
546  }
547 
551  static int numTiles() {
552  return numFrames() * numTilesPerFrame();
553  }
554 
558  static unsigned sizeInBytes() {
559  return numTiles() * 2;
560  }
561 
565  static unsigned sizeInWords() {
566  return numTiles();
567  }
568 
574  void setAssetGroup(AssetGroup &group) {
575  uint32_t pAssetGroup = reinterpret_cast<uint32_t>(&group.sys);
576  ASSERT(sys.pAssetGroup == 0 || sys.pAssetGroup == pAssetGroup);
577  sys.pAssetGroup = pAssetGroup;
578  }
579 
584  void erase(uint16_t index = 0) {
585  memset16(&tiles[0], index, sizeInWords());
586  }
587 
592  void erase(const PinnedAssetImage &image) {
593  setAssetGroup(image.assetGroup());
594  erase(image.tile(0));
595  }
596 
602  uint16_t tileAddr(UInt2 pos, unsigned frame = 0) {
603  return pos.x + (pos.y + frame * tileHeight()) * tileWidth();
604  }
605 
612  void plot(unsigned i, uint16_t tileIndex) {
613  ASSERT(i < numTiles());
614  tiles[i] = tileIndex;
615  }
616 
623  void plot(UInt2 pos, uint16_t tileIndex, unsigned frame = 0) {
624  ASSERT(pos.x < tileWidth() && pos.y < tileHeight() && frame < numFrames());
625  tiles[tileAddr(pos, frame)] = tileIndex;
626  }
627 
631  uint16_t tile(unsigned i) const {
632  ASSERT(i < numTiles());
633  return tiles[i];
634  }
635 
640  uint16_t tile(UInt2 pos, unsigned frame = 0) const {
641  ASSERT(pos.x < tileWidth() && pos.y < tileHeight() && frame < numFrames());
642  return tiles[tileAddr(pos, frame)];
643  }
644 
651  void span(UInt2 pos, unsigned width, unsigned tileIndex, unsigned frame = 0)
652  {
653  ASSERT(pos.x <= tileWidth() && width <= tileWidth() &&
654  (pos.x + width) <= tileWidth() && pos.y < tileHeight());
655  memset16(&tiles[tileAddr(pos, frame)], tileIndex, width);
656  }
657 
663  void span(UInt2 pos, unsigned width, const PinnedAssetImage &image, unsigned frame = 0)
664  {
665  setAssetGroup(image.assetGroup());
666  span(pos, width, image.tile(0), frame);
667  }
668 
675  void fill(UInt2 topLeft, UInt2 size, unsigned tileIndex, unsigned frame = 0)
676  {
677  while (size.y) {
678  span(topLeft, size.x, tileIndex, frame);
679  size.y--;
680  topLeft.y++;
681  }
682  }
683 
690  void fill(UInt2 topLeft, UInt2 size, const PinnedAssetImage &image, unsigned frame = 0)
691  {
692  setAssetGroup(image.assetGroup());
693  fill(topLeft, size, image.tile(0), frame);
694  }
695 
705  void image(UInt2 pos, const AssetImage &image, unsigned srcFrame = 0, unsigned destFrame = 0)
706  {
707  setAssetGroup(image.assetGroup());
708  ASSERT(pos.x < tileWidth() && pos.x + image.tileWidth() <= tileWidth() &&
709  pos.y < tileHeight() && pos.y + image.tileHeight() <= tileHeight() &&
710  destFrame < numFrames());
711  _SYS_image_memDraw(&tiles[tileAddr(pos, destFrame)],
712  _SYS_CUBE_ID_INVALID, image, tileWidth(), srcFrame);
713  }
714 
724  void image(UInt2 destXY, UInt2 size, const AssetImage &image, UInt2 srcXY,
725  unsigned srcFrame = 0, unsigned destFrame = 0)
726  {
727  setAssetGroup(image.assetGroup());
728  ASSERT(destXY.x < tileWidth() && destXY.x + size.x <= tileWidth() &&
729  destXY.y < tileHeight() && destXY.y + size.y <= tileHeight() &&
730  destFrame < numFrames());
731  _SYS_image_memDrawRect(&tiles[tileAddr(destXY, destFrame)],
732  _SYS_CUBE_ID_INVALID, image, tileWidth(), srcFrame,
733  (_SYSInt2*) &srcXY, (_SYSInt2*) &size);
734  }
735 
742  void text(Int2 topLeft, const AssetImage &font, const char *str,
743  unsigned destFrame = 0, char firstChar = ' ')
744  {
745  setAssetGroup(font.assetGroup());
746  uint16_t *addr = &tiles[tileAddr(topLeft, destFrame)];
747  uint16_t *lineAddr = addr;
748  char c;
749 
750  while ((c = *str)) {
751  if (c == '\n') {
752  addr = (lineAddr += tileWidth());
753  } else {
754  ASSERT(font.tileWidth() + (font.tileHeight() - 1) * tileWidth() + addr
755  <= numTiles() + tiles);
756  _SYS_image_memDraw(addr, _SYS_CUBE_ID_INVALID, font, tileWidth(), c - firstChar);
757  addr += font.tileWidth();
758  }
759  str++;
760  }
761  }
762 };
763 
764 
769 }; // namespace Sifteo
static unsigned pixelWidth()
Return the width, in pixels, of this mode.
Definition: tilebuffer.h:180
void image(UInt2 pos, const AssetImage &image, unsigned srcFrame=0, unsigned destFrame=0)
Draw a full AssetImage frame, with its top-left corner at the specified location. ...
Definition: tilebuffer.h:705
void fill(UInt2 topLeft, UInt2 size, const PinnedAssetImage &image, unsigned frame=0)
Fill a rectangle of identical tiles, using the first tile of a pinned asset.
Definition: tilebuffer.h:348
void init()
Initialize the TileBuffer's AssetImage header.
Definition: tilebuffer.h:119
static unsigned pixelHeight()
Return the height, in pixel, of this mode.
Definition: tilebuffer.h:187
TileBuffer()
Initialize a TileBuffer.
Definition: tilebuffer.h:135
A bundle of compressed tile data, for use by AssetImages.
Definition: group.h:54
static unsigned tileHeight()
Return the height, in tiles, of this mode.
Definition: tilebuffer.h:166
Generalized two-element cartesian coordinate vector.
Definition: math.h:488
AssetGroup & assetGroup() const
Access the AssetGroup instance associated with this AssetImage.
Definition: image.h:73
#define ASSERT(_x)
Runtime debug assertion.
Definition: macros.h:205
void plot(UInt2 pos, uint16_t tileIndex, unsigned frame=0)
Plot a single tile, by relative tile index, at location 'pos' in tile units, on the given frame...
Definition: tilebuffer.h:623
static unsigned tileWidth()
Return the width, in tiles, of this mode.
Definition: tilebuffer.h:159
void fill(UInt2 topLeft, UInt2 size, unsigned tileIndex, unsigned frame=0)
Fill a rectangle of identical tiles, specified as a top-left corner location and a size...
Definition: tilebuffer.h:675
static UInt2 tileSize()
Return the size of this mode as a vector, in tiles.
Definition: tilebuffer.h:509
void erase(const PinnedAssetImage &image)
Erase the buffer, filling it with the first tile from the specified PinnedAssetImage.
Definition: tilebuffer.h:246
int tileWidth() const
The width of this image, in tiles.
Definition: image.h:90
void erase(const PinnedAssetImage &image)
Erase the buffer, filling it with the first tile from the specified PinnedAssetImage.
Definition: tilebuffer.h:592
static UInt2 tileSize()
Return the size of this mode as a vector, in tiles.
Definition: tilebuffer.h:173
A drawable that's backed by plain memory, usable with multiple cubes.
Definition: tilebuffer.h:448
void span(UInt2 pos, unsigned width, const PinnedAssetImage &image, unsigned frame=0)
Plot a horizontal span of tiles, using the first tile of a pinned asset.
Definition: tilebuffer.h:322
An AssetImage in which all tiles are stored sequentially in memory.
Definition: image.h:134
void bzero(void *s, unsigned count)
Write 'n' zero bytes to memory.
Definition: memory.h:114
void erase(uint16_t index=0)
Erase the buffer, filling it with the specified relative tile index value.
Definition: tilebuffer.h:584
static int numTilesPerFrame()
Return the number of tiles in each frame of the image.
Definition: tilebuffer.h:544
AssetGroup & assetGroup() const
Access the AssetGroup instance associated with this AssetImage.
Definition: image.h:140
void plot(UInt2 pos, uint16_t tileIndex, unsigned frame=0)
Plot a single tile, by absolute tile index, at location 'pos' in tile units, on the given frame...
Definition: tilebuffer.h:278
uint16_t tile(unsigned i) const
Returns the index of the tile at linear position 'i' in the image.
Definition: tilebuffer.h:287
uint16_t tileAddr(UInt2 pos, unsigned frame=0) const
Calculate the video buffer address of a particular tile.
Definition: tilebuffer.h:255
void setCube(CubeID cube)
Change the CubeID associated with this drawable.
Definition: tilebuffer.h:112
T x
Vector component X.
Definition: math.h:489
void span(UInt2 pos, unsigned width, unsigned tileIndex, unsigned frame=0)
Plot a horizontal span of tiles, by relative tile index, given the position of the leftmost tile and ...
Definition: tilebuffer.h:651
static UInt2 pixelSize()
Return the size of this mode as a vector, in pixels.
Definition: tilebuffer.h:194
int tileHeight() const
The height of this image, in tiles.
Definition: image.h:93
uint16_t tileAddr(UInt2 pos, unsigned frame=0)
Calculate the video buffer address of a particular tile.
Definition: tilebuffer.h:602
void image(UInt2 destXY, UInt2 size, const AssetImage &image, UInt2 srcXY, unsigned srcFrame=0, unsigned destFrame=0)
Draw part of an AssetImage frame, with its top-left corner at the specified location.
Definition: tilebuffer.h:724
void span(UInt2 pos, unsigned width, const PinnedAssetImage &image, unsigned frame=0)
Plot a horizontal span of tiles, using the first tile of a pinned asset.
Definition: tilebuffer.h:663
A lightweight identifier for one Sifteo cube.
Definition: cube.h:85
static unsigned pixelWidth()
Return the width, in pixels, of this mode.
Definition: tilebuffer.h:516
uint16_t tile(unsigned i) const
Returns the index of the tile at linear position 'i' in the image.
Definition: image.h:160
Any kind of asset image, as defined in your stir script.
Definition: image.h:67
void span(UInt2 pos, unsigned width, unsigned tileIndex, unsigned frame=0)
Plot a horizontal span of tiles, by absolute tile index, given the position of the leftmost tile and ...
Definition: tilebuffer.h:309
void setAssetGroup(AssetGroup &group)
Set the AssetGroup associated with this buffer.
Definition: tilebuffer.h:574
static unsigned sizeInBytes()
Returns the size of this drawable's tile data, in bytes.
Definition: tilebuffer.h:222
static unsigned sizeInWords()
Returns the size of this drawable's tile data, in 16-bit words.
Definition: tilebuffer.h:229
uint16_t tile(UInt2 pos, unsigned frame=0) const
Return the relative index of the tile at the specified (x, y) tile coordinates, and optionally on the...
Definition: tilebuffer.h:640
void plot(unsigned i, uint16_t tileIndex)
Plot a single tile, by relative tile index, at linear position 'i'.
Definition: tilebuffer.h:612
static UInt2 pixelSize()
Return the size of this mode as a vector, in pixels.
Definition: tilebuffer.h:530
void plot(unsigned i, uint16_t tileIndex)
Plot a single tile, by absolute tile index, at linear position 'i'.
Definition: tilebuffer.h:266
Definition: array.h:34
T y
Vector component Y.
Definition: math.h:490
static int numFrames()
Return the number of frames in this image.
Definition: tilebuffer.h:201
void fill(UInt2 topLeft, UInt2 size, unsigned tileIndex, unsigned frame=0)
Fill a rectangle of identical tiles, specified as a top-left corner location and a size...
Definition: tilebuffer.h:333
static int numTiles()
Return the total number of tiles in every frame of the image.
Definition: tilebuffer.h:551
void memset16(uint16_t *dest, uint16_t value, unsigned count)
memset(), with an explicit 16-bit data width
Definition: memory.h:49
void image(UInt2 pos, const AssetImage &image, unsigned srcFrame=0, unsigned destFrame=0)
Draw a full AssetImage frame, with its top-left corner at the specified location. ...
Definition: tilebuffer.h:362
A drawable that's backed by plain memory, instead of by a VideoBuffer.
Definition: tilebuffer.h:70
TileBuffer(CubeID cube)
Initialize a TileBuffer for use.
Definition: tilebuffer.h:150
static unsigned tileHeight()
Return the height, in tiles, of this mode.
Definition: tilebuffer.h:502
uint16_t tile(unsigned i) const
Returns the relative index of the tile at linear position 'i' in the image.
Definition: tilebuffer.h:631
static unsigned sizeInBytes()
Returns the size of this drawable's tile data, in bytes.
Definition: tilebuffer.h:558
void text(Int2 topLeft, const AssetImage &font, const char *str, unsigned destFrame=0, char firstChar= ' ')
Draw text, using an AssetImage as a fixed width font.
Definition: tilebuffer.h:742
void init()
Initialize the RelocatableTileBuffer's AssetImage header.
Definition: tilebuffer.h:476
void erase(uint16_t index=0)
Erase the buffer, filling it with the specified absolute tile index value.
Definition: tilebuffer.h:237
An AssetImage in which all tile indices are stored in a flat array, without any additional compressio...
Definition: image.h:247
void text(Int2 topLeft, const AssetImage &font, const char *str, unsigned destFrame=0, char firstChar= ' ')
Draw text, using an AssetImage as a fixed width font.
Definition: tilebuffer.h:397
void fill(UInt2 topLeft, UInt2 size, const PinnedAssetImage &image, unsigned frame=0)
Fill a rectangle of identical tiles, using the first tile of a pinned asset.
Definition: tilebuffer.h:690
static unsigned tileWidth()
Return the width, in tiles, of this mode.
Definition: tilebuffer.h:495
RelocatableTileBuffer()
Initialize a RelocatableTileBuffer.
Definition: tilebuffer.h:488
static int numFrames()
Return the number of frames in this image.
Definition: tilebuffer.h:537
CubeID cube() const
Return the CubeID associated with this drawable.
Definition: tilebuffer.h:98
static unsigned pixelHeight()
Return the height, in pixel, of this mode.
Definition: tilebuffer.h:523
static int numTilesPerFrame()
Return the number of tiles in each frame of the image.
Definition: tilebuffer.h:208
void image(UInt2 destXY, UInt2 size, const AssetImage &image, UInt2 srcXY, unsigned srcFrame=0, unsigned destFrame=0)
Draw part of an AssetImage frame, with its top-left corner at the specified location.
Definition: tilebuffer.h:380
static unsigned sizeInWords()
Returns the size of this drawable's tile data, in 16-bit words.
Definition: tilebuffer.h:565
uint16_t tile(UInt2 pos, unsigned frame=0) const
Return the index of the tile at the specified (x, y) tile coordinates, and optionally on the specifie...
Definition: tilebuffer.h:297
Vector2< T > vec(T x, T y)
Create a Vector2, from a set of (x,y) coordinates.
Definition: math.h:658
static int numTiles()
Return the total number of tiles in every frame of the image.
Definition: tilebuffer.h:215