Forked para SNOCC
Fork of RA8875 by
Diff: GraphicsDisplay.cpp
- Revision:
- 109:7b94f06f085b
- Parent:
- 104:8d1d3832a215
diff -r f9ccffcb84f1 -r 7b94f06f085b GraphicsDisplay.cpp --- a/GraphicsDisplay.cpp Sat Mar 05 16:20:11 2016 +0000 +++ b/GraphicsDisplay.cpp Sat Mar 05 19:22:13 2016 +0000 @@ -133,7 +133,7 @@ return noerror; } -RetCode_t GraphicsDisplay::fill(int x, int y, int w, int h, color_t color) +RetCode_t GraphicsDisplay::fill(loc_t x, loc_t y, dim_t w, dim_t h, color_t color) { return fillrect(x,y, x+w, y+h, color); } @@ -143,7 +143,7 @@ return fill(0, 0, width(), height(), _background); } -RetCode_t GraphicsDisplay::blit(int x, int y, int w, int h, const int * color) +RetCode_t GraphicsDisplay::blit(loc_t x, loc_t y, dim_t w, dim_t h, const int * color) { window(x, y, w, h); _StartGraphicsStream(); @@ -171,12 +171,12 @@ //... -const uint8_t * GraphicsDisplay::getCharMetrics(const unsigned char c, uint8_t * width, uint8_t * height) +const uint8_t * GraphicsDisplay::getCharMetrics(const unsigned char c, dim_t * width, dim_t * height) { uint16_t offsetToCharLookup; uint16_t firstChar = font[3] * 256 + font[2]; uint16_t lastChar = font[5] * 256 + font[4]; - uint8_t charHeight = font[6]; + dim_t charHeight = font[6]; const unsigned char * charRecord; // width, data, data, data, ... INFO("first:%d, last:%d, c:%d", firstChar, lastChar, c); @@ -185,7 +185,7 @@ // 8 bytes of preamble to the first level lookup table offsetToCharLookup = 8 + 4 * (c - firstChar); // 4-bytes: width(pixels), 16-bit offset from table start, 0 - uint8_t charWidth = font[offsetToCharLookup]; + dim_t charWidth = font[offsetToCharLookup]; charRecord = font + font[offsetToCharLookup + 2] * 256 + font[offsetToCharLookup + 1]; //INFO("hgt:%d, wdt:%d", charHeight, charWidth); if (width) @@ -195,26 +195,11 @@ return charRecord; } -int GraphicsDisplay::fontblit(int x, int y, const unsigned char c) + +int GraphicsDisplay::fontblit(loc_t x, loc_t y, const unsigned char c) { - #if 0 - uint16_t offsetToCharLookup; - uint16_t firstChar = font[3] * 256 + font[2]; - uint16_t lastChar = font[5] * 256 + font[4]; - uint8_t charHeight = font[6]; - const unsigned char * charRecord; // width, data, data, data, ... - - INFO("first:%d, last:%d, c:%d", firstChar, lastChar, c); - if (c < firstChar || c > lastChar) - return 0; // advance zero pixels since it was unprintable... - - // 8 bytes of preamble to the first level lookup table - offsetToCharLookup = 8 + 4 * (c - firstChar); // 4-bytes: width(pixels), 16-bit offset from table start, 0 - uint8_t charWidth = font[offsetToCharLookup]; - charRecord = font + font[offsetToCharLookup + 2] * 256 + font[offsetToCharLookup + 1]; -#endif - const unsigned char * charRecord; // width, data, data, data, ... - uint8_t charWidth, charHeight; + const uint8_t * charRecord; // width, data, data, data, ... + dim_t charWidth, charHeight; charRecord = getCharMetrics(c, &charWidth, &charHeight); if (charRecord) { INFO("hgt:%d, wdt:%d", charHeight, charWidth); @@ -223,28 +208,7 @@ // charWidth = width() - x; //if (y + charHeight >= height()) // charHeight = height() - y; - window(x, y, charWidth, charHeight); - _StartGraphicsStream(); - while (charHeight--) { - uint8_t pixels = charWidth; - uint8_t bitmask = 0x01; - - while (pixels) { - uint8_t byte = *charRecord; - INFO("byte, mask: %02X, %02X", byte, bitmask); - color_t c = (byte & bitmask) ? _foreground : _background; - _putp(c); - bitmask <<= 1; - if (pixels > 1 && bitmask == 0) { - bitmask = 0x01; - charRecord++; - } - pixels--; - } - charRecord++; - } - _EndGraphicsStream(); - WindowMax(); + booleanStream(x,y,charWidth, charHeight, charRecord); return charWidth; } else { return 0;