Forked para SNOCC
Fork of RA8875 by
GraphicsDisplay.cpp@29:422616aa04bd, 2014-01-19 (annotated)
- Committer:
- WiredHome
- Date:
- Sun Jan 19 04:24:16 2014 +0000
- Revision:
- 29:422616aa04bd
- Parent:
- 23:a50ded45dbaf
- Child:
- 31:c72e12cd5c67
Initial support for soft fonts compatible with mikroe font creator.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dreschpe | 0:de9d1462a835 | 1 | /* mbed GraphicsDisplay Display Library Base Class |
dreschpe | 0:de9d1462a835 | 2 | * Copyright (c) 2007-2009 sford |
dreschpe | 0:de9d1462a835 | 3 | * Released under the MIT License: http://mbed.org/license/mit |
dreschpe | 0:de9d1462a835 | 4 | */ |
WiredHome | 19:3f82c1161fd2 | 5 | |
dreschpe | 0:de9d1462a835 | 6 | #include "GraphicsDisplay.h" |
dreschpe | 0:de9d1462a835 | 7 | |
WiredHome | 29:422616aa04bd | 8 | #define DEBUG "GD" |
WiredHome | 29:422616aa04bd | 9 | // ... |
WiredHome | 29:422616aa04bd | 10 | // INFO("Stuff to show %d", var); // new-line is automatically appended |
WiredHome | 29:422616aa04bd | 11 | // |
WiredHome | 29:422616aa04bd | 12 | #if (defined(DEBUG) && !defined(TARGET_LPC11U24)) |
WiredHome | 29:422616aa04bd | 13 | #define INFO(x, ...) std::printf("[INF %s %3d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); |
WiredHome | 29:422616aa04bd | 14 | #define WARN(x, ...) std::printf("[WRN %s %3d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); |
WiredHome | 29:422616aa04bd | 15 | #define ERR(x, ...) std::printf("[ERR %s %3d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); |
WiredHome | 29:422616aa04bd | 16 | #else |
WiredHome | 29:422616aa04bd | 17 | #define INFO(x, ...) |
WiredHome | 29:422616aa04bd | 18 | #define WARN(x, ...) |
WiredHome | 29:422616aa04bd | 19 | #define ERR(x, ...) |
WiredHome | 29:422616aa04bd | 20 | #endif |
WiredHome | 29:422616aa04bd | 21 | |
WiredHome | 29:422616aa04bd | 22 | // #define LOCALFONT |
WiredHome | 29:422616aa04bd | 23 | |
WiredHome | 29:422616aa04bd | 24 | #ifdef LOCALFONT |
dreschpe | 0:de9d1462a835 | 25 | const unsigned char FONT8x8[97][8] = { |
WiredHome | 29:422616aa04bd | 26 | 0x08, 0x08, 0x08, 0X00, 0X00, 0X00, 0X00, 0X00, // columns, rows, num_bytes_per_char |
WiredHome | 29:422616aa04bd | 27 | 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, // space 0x20 |
WiredHome | 29:422616aa04bd | 28 | 0x30, 0x78, 0x78, 0x30, 0x30, 0X00, 0x30, 0X00, // ! |
WiredHome | 29:422616aa04bd | 29 | 0x6C, 0x6C, 0x6C, 0X00, 0X00, 0X00, 0X00, 0X00, // " |
WiredHome | 29:422616aa04bd | 30 | 0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0X00, // # |
WiredHome | 29:422616aa04bd | 31 | 0x18, 0x3E, 0x60, 0x3C, 0x06, 0x7C, 0x18, 0X00, // $ |
WiredHome | 29:422616aa04bd | 32 | 0X00, 0x63, 0x66, 0x0C, 0x18, 0x33, 0x63, 0X00, // % |
WiredHome | 29:422616aa04bd | 33 | 0x1C, 0x36, 0x1C, 0x3B, 0x6E, 0x66, 0x3B, 0X00, // & |
WiredHome | 29:422616aa04bd | 34 | 0x30, 0x30, 0x60, 0X00, 0X00, 0X00, 0X00, 0X00, // ' |
WiredHome | 29:422616aa04bd | 35 | 0x0C, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0C, 0X00, // ( |
WiredHome | 29:422616aa04bd | 36 | 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0X00, // ) |
WiredHome | 29:422616aa04bd | 37 | 0X00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0X00, 0X00, // * |
WiredHome | 29:422616aa04bd | 38 | 0X00, 0x30, 0x30, 0xFC, 0x30, 0x30, 0X00, 0X00, // + |
WiredHome | 29:422616aa04bd | 39 | 0X00, 0X00, 0X00, 0X00, 0X00, 0x18, 0x18, 0x30, // , |
WiredHome | 29:422616aa04bd | 40 | 0X00, 0X00, 0X00, 0x7E, 0X00, 0X00, 0X00, 0X00, // - |
WiredHome | 29:422616aa04bd | 41 | 0X00, 0X00, 0X00, 0X00, 0X00, 0x18, 0x18, 0X00, // . |
WiredHome | 29:422616aa04bd | 42 | 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0X00, // / (forward slash) |
WiredHome | 29:422616aa04bd | 43 | 0x3E, 0x63, 0x63, 0x6B, 0x63, 0x63, 0x3E, 0X00, // 0 0x30 |
WiredHome | 29:422616aa04bd | 44 | 0x18, 0x38, 0x58, 0x18, 0x18, 0x18, 0x7E, 0X00, // 1 |
WiredHome | 29:422616aa04bd | 45 | 0x3C, 0x66, 0x06, 0x1C, 0x30, 0x66, 0x7E, 0X00, // 2 |
WiredHome | 29:422616aa04bd | 46 | 0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C, 0X00, // 3 |
WiredHome | 29:422616aa04bd | 47 | 0x0E, 0x1E, 0x36, 0x66, 0x7F, 0x06, 0x0F, 0X00, // 4 |
WiredHome | 29:422616aa04bd | 48 | 0x7E, 0x60, 0x7C, 0x06, 0x06, 0x66, 0x3C, 0X00, // 5 |
WiredHome | 29:422616aa04bd | 49 | 0x1C, 0x30, 0x60, 0x7C, 0x66, 0x66, 0x3C, 0X00, // 6 |
WiredHome | 29:422616aa04bd | 50 | 0x7E, 0x66, 0x06, 0x0C, 0x18, 0x18, 0x18, 0X00, // 7 |
WiredHome | 29:422616aa04bd | 51 | 0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C, 0X00, // 8 |
WiredHome | 29:422616aa04bd | 52 | 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x0C, 0x38, 0X00, // 9 |
WiredHome | 29:422616aa04bd | 53 | 0X00, 0x18, 0x18, 0X00, 0X00, 0x18, 0x18, 0X00, // : |
WiredHome | 29:422616aa04bd | 54 | 0X00, 0x18, 0x18, 0X00, 0X00, 0x18, 0x18, 0x30, // ; |
WiredHome | 29:422616aa04bd | 55 | 0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C, 0X00, // < |
WiredHome | 29:422616aa04bd | 56 | 0X00, 0X00, 0x7E, 0X00, 0X00, 0x7E, 0X00, 0X00, // = |
WiredHome | 29:422616aa04bd | 57 | 0x30, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0X00, // > |
WiredHome | 29:422616aa04bd | 58 | 0x3C, 0x66, 0x06, 0x0C, 0x18, 0X00, 0x18, 0X00, // ? |
WiredHome | 29:422616aa04bd | 59 | 0x3E, 0x63, 0x6F, 0x69, 0x6F, 0x60, 0x3E, 0X00, // @ 0x40 |
WiredHome | 29:422616aa04bd | 60 | 0x18, 0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, 0X00, // A |
WiredHome | 29:422616aa04bd | 61 | 0x7E, 0x33, 0x33, 0x3E, 0x33, 0x33, 0x7E, 0X00, // B |
WiredHome | 29:422616aa04bd | 62 | 0x1E, 0x33, 0x60, 0x60, 0x60, 0x33, 0x1E, 0X00, // C |
WiredHome | 29:422616aa04bd | 63 | 0x7C, 0x36, 0x33, 0x33, 0x33, 0x36, 0x7C, 0X00, // D |
WiredHome | 29:422616aa04bd | 64 | 0x7F, 0x31, 0x34, 0x3C, 0x34, 0x31, 0x7F, 0X00, // E |
WiredHome | 29:422616aa04bd | 65 | 0x7F, 0x31, 0x34, 0x3C, 0x34, 0x30, 0x78, 0X00, // F |
WiredHome | 29:422616aa04bd | 66 | 0x1E, 0x33, 0x60, 0x60, 0x67, 0x33, 0x1F, 0X00, // G |
WiredHome | 29:422616aa04bd | 67 | 0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0X00, // H |
WiredHome | 29:422616aa04bd | 68 | 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0X00, // I |
WiredHome | 29:422616aa04bd | 69 | 0x0F, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3C, 0X00, // J |
WiredHome | 29:422616aa04bd | 70 | 0x73, 0x33, 0x36, 0x3C, 0x36, 0x33, 0x73, 0X00, // K |
WiredHome | 29:422616aa04bd | 71 | 0x78, 0x30, 0x30, 0x30, 0x31, 0x33, 0x7F, 0X00, // L |
WiredHome | 29:422616aa04bd | 72 | 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0X00, // M |
WiredHome | 29:422616aa04bd | 73 | 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x63, 0x63, 0X00, // N |
WiredHome | 29:422616aa04bd | 74 | 0x3E, 0x63, 0x63, 0x63, 0x63, 0x63, 0x3E, 0X00, // O |
WiredHome | 29:422616aa04bd | 75 | 0x7E, 0x33, 0x33, 0x3E, 0x30, 0x30, 0x78, 0X00, // P 0x50 |
WiredHome | 29:422616aa04bd | 76 | 0x3C, 0x66, 0x66, 0x66, 0x6E, 0x3C, 0x0E, 0X00, // Q |
WiredHome | 29:422616aa04bd | 77 | 0x7E, 0x33, 0x33, 0x3E, 0x36, 0x33, 0x73, 0X00, // R |
WiredHome | 29:422616aa04bd | 78 | 0x3C, 0x66, 0x30, 0x18, 0x0C, 0x66, 0x3C, 0X00, // S |
WiredHome | 29:422616aa04bd | 79 | 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x3C, 0X00, // T |
WiredHome | 29:422616aa04bd | 80 | 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7E, 0X00, // U |
WiredHome | 29:422616aa04bd | 81 | 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0X00, // V |
WiredHome | 29:422616aa04bd | 82 | 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0X00, // W |
WiredHome | 29:422616aa04bd | 83 | 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0X00, // X |
WiredHome | 29:422616aa04bd | 84 | 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x3C, 0X00, // Y |
WiredHome | 29:422616aa04bd | 85 | 0x7F, 0x63, 0x46, 0x0C, 0x19, 0x33, 0x7F, 0X00, // Z |
WiredHome | 29:422616aa04bd | 86 | 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0X00, // [ |
WiredHome | 29:422616aa04bd | 87 | 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0X00, // \ (back slash) |
WiredHome | 29:422616aa04bd | 88 | 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0X00, // ] |
WiredHome | 29:422616aa04bd | 89 | 0x08, 0x1C, 0x36, 0x63, 0X00, 0X00, 0X00, 0X00, // ^ |
WiredHome | 29:422616aa04bd | 90 | 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0xFF, // _ |
WiredHome | 29:422616aa04bd | 91 | 0x18, 0x18, 0x0C, 0X00, 0X00, 0X00, 0X00, 0X00, // ` 0x60 |
WiredHome | 29:422616aa04bd | 92 | 0X00, 0X00, 0x3C, 0x06, 0x3E, 0x66, 0x3B, 0X00, // a |
WiredHome | 29:422616aa04bd | 93 | 0x70, 0x30, 0x3E, 0x33, 0x33, 0x33, 0x6E, 0X00, // b |
WiredHome | 29:422616aa04bd | 94 | 0X00, 0X00, 0x3C, 0x66, 0x60, 0x66, 0x3C, 0X00, // c |
WiredHome | 29:422616aa04bd | 95 | 0x0E, 0x06, 0x3E, 0x66, 0x66, 0x66, 0x3B, 0X00, // d |
WiredHome | 29:422616aa04bd | 96 | 0X00, 0X00, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0X00, // e |
WiredHome | 29:422616aa04bd | 97 | 0x1C, 0x36, 0x30, 0x78, 0x30, 0x30, 0x78, 0X00, // f |
WiredHome | 29:422616aa04bd | 98 | 0X00, 0X00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x7C, // g |
WiredHome | 29:422616aa04bd | 99 | 0x70, 0x30, 0x36, 0x3B, 0x33, 0x33, 0x73, 0X00, // h |
WiredHome | 29:422616aa04bd | 100 | 0x18, 0X00, 0x38, 0x18, 0x18, 0x18, 0x3C, 0X00, // i |
WiredHome | 29:422616aa04bd | 101 | 0x06, 0X00, 0x06, 0x06, 0x06, 0x66, 0x66, 0x3C, // j |
WiredHome | 29:422616aa04bd | 102 | 0x70, 0x30, 0x33, 0x36, 0x3C, 0x36, 0x73, 0X00, // k |
WiredHome | 29:422616aa04bd | 103 | 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0X00, // l |
WiredHome | 29:422616aa04bd | 104 | 0X00, 0X00, 0x66, 0x7F, 0x7F, 0x6B, 0x63, 0X00, // m |
WiredHome | 29:422616aa04bd | 105 | 0X00, 0X00, 0x7C, 0x66, 0x66, 0x66, 0x66, 0X00, // n |
WiredHome | 29:422616aa04bd | 106 | 0X00, 0X00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0X00, // o |
WiredHome | 29:422616aa04bd | 107 | 0X00, 0X00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78, // p |
WiredHome | 29:422616aa04bd | 108 | 0X00, 0X00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F, // q |
WiredHome | 29:422616aa04bd | 109 | 0X00, 0X00, 0x6E, 0x3B, 0x33, 0x30, 0x78, 0X00, // r |
WiredHome | 29:422616aa04bd | 110 | 0X00, 0X00, 0x3E, 0x60, 0x3C, 0x06, 0x7C, 0X00, // s |
WiredHome | 29:422616aa04bd | 111 | 0x08, 0x18, 0x3E, 0x18, 0x18, 0x1A, 0x0C, 0X00, // t |
WiredHome | 29:422616aa04bd | 112 | 0X00, 0X00, 0x66, 0x66, 0x66, 0x66, 0x3B, 0X00, // u |
WiredHome | 29:422616aa04bd | 113 | 0X00, 0X00, 0x66, 0x66, 0x66, 0x3C, 0x18, 0X00, // v |
WiredHome | 29:422616aa04bd | 114 | 0X00, 0X00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0X00, // w |
WiredHome | 29:422616aa04bd | 115 | 0X00, 0X00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0X00, // x |
WiredHome | 29:422616aa04bd | 116 | 0X00, 0X00, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x7C, // y |
WiredHome | 29:422616aa04bd | 117 | 0X00, 0X00, 0x7E, 0x4C, 0x18, 0x32, 0x7E, 0X00, // z |
WiredHome | 29:422616aa04bd | 118 | 0x0E, 0x18, 0x18, 0x70, 0x18, 0x18, 0x0E, 0X00, // { |
WiredHome | 29:422616aa04bd | 119 | 0x0C, 0x0C, 0x0C, 0X00, 0x0C, 0x0C, 0x0C, 0X00, // | |
WiredHome | 29:422616aa04bd | 120 | 0x70, 0x18, 0x18, 0x0E, 0x18, 0x18, 0x70, 0X00, // } |
WiredHome | 29:422616aa04bd | 121 | 0x3B, 0x6E, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, // ~ |
WiredHome | 29:422616aa04bd | 122 | 0x1C, 0x36, 0x36, 0x1C, 0X00, 0X00, 0X00, 0X00 // DEL |
WiredHome | 23:a50ded45dbaf | 123 | }; |
WiredHome | 29:422616aa04bd | 124 | #endif // LOCALFONT |
WiredHome | 19:3f82c1161fd2 | 125 | |
WiredHome | 29:422616aa04bd | 126 | GraphicsDisplay::GraphicsDisplay(const char *name) |
WiredHome | 29:422616aa04bd | 127 | : TextDisplay(name) |
WiredHome | 19:3f82c1161fd2 | 128 | { |
WiredHome | 29:422616aa04bd | 129 | font = NULL; |
WiredHome | 19:3f82c1161fd2 | 130 | //foreground(0xFFFF); |
WiredHome | 19:3f82c1161fd2 | 131 | //background(0x0000); |
dreschpe | 0:de9d1462a835 | 132 | } |
WiredHome | 19:3f82c1161fd2 | 133 | |
WiredHome | 29:422616aa04bd | 134 | RetCode_t GraphicsDisplay::set_font(const unsigned char * _font) |
WiredHome | 19:3f82c1161fd2 | 135 | { |
WiredHome | 29:422616aa04bd | 136 | font = _font; |
WiredHome | 29:422616aa04bd | 137 | INFO("set_font(%lu) %lu", _font, font); |
WiredHome | 29:422616aa04bd | 138 | return noerror; // trusting them, but it might be good to put some checks in here... |
dreschpe | 0:de9d1462a835 | 139 | } |
dreschpe | 0:de9d1462a835 | 140 | |
WiredHome | 29:422616aa04bd | 141 | #ifdef LOCALFONT |
WiredHome | 29:422616aa04bd | 142 | int GraphicsDisplay::character(int x, int y, int value) |
WiredHome | 29:422616aa04bd | 143 | { |
WiredHome | 29:422616aa04bd | 144 | INFO("character(%d,%d,%c)", x, t, value); |
WiredHome | 29:422616aa04bd | 145 | if (value <= 0x1F && value >= 7F) |
WiredHome | 29:422616aa04bd | 146 | return 0; |
WiredHome | 29:422616aa04bd | 147 | |
WiredHome | 29:422616aa04bd | 148 | return blitbit(x, y, FONT8X8[0][0], FONT8X8[0][1], |
WiredHome | 29:422616aa04bd | 149 | (char *)&(FONT8x8[value - 0x1F][0])); |
WiredHome | 29:422616aa04bd | 150 | } |
WiredHome | 29:422616aa04bd | 151 | #else |
WiredHome | 29:422616aa04bd | 152 | int GraphicsDisplay::character(int x, int y, int c) |
WiredHome | 29:422616aa04bd | 153 | { |
WiredHome | 29:422616aa04bd | 154 | unsigned int offset; |
WiredHome | 29:422616aa04bd | 155 | const unsigned char * charRecord; |
WiredHome | 29:422616aa04bd | 156 | |
WiredHome | 29:422616aa04bd | 157 | if (c <= 0x1F || c >= 0x7F) |
WiredHome | 29:422616aa04bd | 158 | return 0; |
WiredHome | 29:422616aa04bd | 159 | offset = font[0]; // bytes / char |
WiredHome | 29:422616aa04bd | 160 | charRecord = &font[((c - ' ') * offset) + 4]; // start of char bitmap |
WiredHome | 29:422616aa04bd | 161 | return fontblit(x, y, font, charRecord); |
WiredHome | 29:422616aa04bd | 162 | } |
WiredHome | 29:422616aa04bd | 163 | #endif |
WiredHome | 19:3f82c1161fd2 | 164 | |
WiredHome | 29:422616aa04bd | 165 | void GraphicsDisplay::window(unsigned int x, unsigned int y, unsigned int w, unsigned int h) |
WiredHome | 19:3f82c1161fd2 | 166 | { |
dreschpe | 0:de9d1462a835 | 167 | // current pixel location |
dreschpe | 0:de9d1462a835 | 168 | _x = x; |
dreschpe | 0:de9d1462a835 | 169 | _y = y; |
dreschpe | 0:de9d1462a835 | 170 | // window settings |
dreschpe | 0:de9d1462a835 | 171 | _x1 = x; |
dreschpe | 0:de9d1462a835 | 172 | _x2 = x + w - 1; |
dreschpe | 0:de9d1462a835 | 173 | _y1 = y; |
dreschpe | 0:de9d1462a835 | 174 | _y2 = y + h - 1; |
dreschpe | 0:de9d1462a835 | 175 | } |
WiredHome | 19:3f82c1161fd2 | 176 | |
WiredHome | 19:3f82c1161fd2 | 177 | void GraphicsDisplay::putp(int colour) |
WiredHome | 19:3f82c1161fd2 | 178 | { |
dreschpe | 0:de9d1462a835 | 179 | // put pixel at current pixel location |
dreschpe | 0:de9d1462a835 | 180 | pixel(_x, _y, colour); |
dreschpe | 0:de9d1462a835 | 181 | // update pixel location based on window settings |
dreschpe | 0:de9d1462a835 | 182 | _x++; |
dreschpe | 0:de9d1462a835 | 183 | if(_x > _x2) { |
dreschpe | 0:de9d1462a835 | 184 | _x = _x1; |
dreschpe | 0:de9d1462a835 | 185 | _y++; |
dreschpe | 0:de9d1462a835 | 186 | if(_y > _y2) { |
dreschpe | 0:de9d1462a835 | 187 | _y = _y1; |
dreschpe | 0:de9d1462a835 | 188 | } |
dreschpe | 0:de9d1462a835 | 189 | } |
dreschpe | 0:de9d1462a835 | 190 | } |
dreschpe | 0:de9d1462a835 | 191 | |
WiredHome | 19:3f82c1161fd2 | 192 | void GraphicsDisplay::fill(int x, int y, int w, int h, int colour) |
WiredHome | 19:3f82c1161fd2 | 193 | { |
dreschpe | 0:de9d1462a835 | 194 | window(x, y, w, h); |
dreschpe | 0:de9d1462a835 | 195 | for(int i=0; i<w*h; i++) { |
dreschpe | 0:de9d1462a835 | 196 | putp(colour); |
dreschpe | 0:de9d1462a835 | 197 | } |
dreschpe | 0:de9d1462a835 | 198 | } |
WiredHome | 19:3f82c1161fd2 | 199 | |
WiredHome | 19:3f82c1161fd2 | 200 | RetCode_t GraphicsDisplay::cls() |
WiredHome | 19:3f82c1161fd2 | 201 | { |
dreschpe | 0:de9d1462a835 | 202 | fill(0, 0, width(), height(), _background); |
WiredHome | 19:3f82c1161fd2 | 203 | return noerror; |
dreschpe | 0:de9d1462a835 | 204 | } |
WiredHome | 19:3f82c1161fd2 | 205 | |
WiredHome | 29:422616aa04bd | 206 | void GraphicsDisplay::blit(int x, int y, int w, int h, const int * colour) |
WiredHome | 19:3f82c1161fd2 | 207 | { |
dreschpe | 0:de9d1462a835 | 208 | window(x, y, w, h); |
dreschpe | 0:de9d1462a835 | 209 | for(int i=0; i<w*h; i++) { |
dreschpe | 0:de9d1462a835 | 210 | putp(colour[i]); |
dreschpe | 0:de9d1462a835 | 211 | } |
dreschpe | 0:de9d1462a835 | 212 | } |
WiredHome | 19:3f82c1161fd2 | 213 | |
WiredHome | 29:422616aa04bd | 214 | int GraphicsDisplay::blitbit(int x, int y, int w, int h, const char * colour) |
WiredHome | 19:3f82c1161fd2 | 215 | { |
WiredHome | 29:422616aa04bd | 216 | _foreground = 0xFFFF; |
WiredHome | 29:422616aa04bd | 217 | INFO("blitbit(%d,%d, %d,%d, %02X) [%04X,%04X]", x,y, w,h, *colour, _foreground, _background); |
WiredHome | 29:422616aa04bd | 218 | INFO("%lu %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", |
WiredHome | 29:422616aa04bd | 219 | colour, |
WiredHome | 29:422616aa04bd | 220 | colour[0], colour[1], colour[2], colour[3], colour[4], colour[5], colour[6], colour[7], |
WiredHome | 29:422616aa04bd | 221 | colour[8], colour[9], colour[10], colour[11], colour[12], colour[13], colour[14], colour[15]); |
dreschpe | 0:de9d1462a835 | 222 | window(x, y, w, h); |
WiredHome | 29:422616aa04bd | 223 | for (int i = 0; i < w*h; i++) { |
dreschpe | 0:de9d1462a835 | 224 | char byte = colour[i >> 3]; |
dreschpe | 0:de9d1462a835 | 225 | int offset = i & 0x7; |
WiredHome | 29:422616aa04bd | 226 | if (offset == 0) |
WiredHome | 29:422616aa04bd | 227 | INFO(" %2d = %02X", i>>3, byte); |
dreschpe | 0:de9d1462a835 | 228 | int c = ((byte << offset) & 0x80) ? _foreground : _background; |
dreschpe | 0:de9d1462a835 | 229 | putp(c); |
WiredHome | 29:422616aa04bd | 230 | //wait_ms(100); |
dreschpe | 0:de9d1462a835 | 231 | } |
WiredHome | 29:422616aa04bd | 232 | return w; |
WiredHome | 29:422616aa04bd | 233 | } |
WiredHome | 29:422616aa04bd | 234 | |
WiredHome | 29:422616aa04bd | 235 | |
WiredHome | 29:422616aa04bd | 236 | int GraphicsDisplay::fontblit(int x, int y, const unsigned char * fontTable, const unsigned char * fontChar) |
WiredHome | 29:422616aa04bd | 237 | { |
WiredHome | 19:3f82c1161fd2 | 238 | _foreground = 0xFFFF; |
WiredHome | 29:422616aa04bd | 239 | //int fontWidth = font[1]; // get hor size of font |
WiredHome | 29:422616aa04bd | 240 | int fontHeight = font[2]; // get vert size of font |
WiredHome | 29:422616aa04bd | 241 | int bytesPerLine = font[3]; // bytes per line |
WiredHome | 29:422616aa04bd | 242 | int charWidth = fontChar[0]; // width of this character |
WiredHome | 29:422616aa04bd | 243 | int px, py; |
WiredHome | 29:422616aa04bd | 244 | window(x, y, charWidth, fontHeight); |
WiredHome | 29:422616aa04bd | 245 | |
WiredHome | 29:422616aa04bd | 246 | for (py = 0; py < fontHeight; py++) { |
WiredHome | 29:422616aa04bd | 247 | int bitmask = 1 << (py & 7); |
WiredHome | 29:422616aa04bd | 248 | |
WiredHome | 29:422616aa04bd | 249 | for (px = 0; px < charWidth; px++) { |
WiredHome | 29:422616aa04bd | 250 | int offset = (py / 8) + px * bytesPerLine; |
WiredHome | 29:422616aa04bd | 251 | unsigned char byte = fontChar[offset + 1]; // skip the char's # bits wide value |
WiredHome | 29:422616aa04bd | 252 | int c = (byte & bitmask) ? _foreground : _background; |
WiredHome | 29:422616aa04bd | 253 | putp(c); |
WiredHome | 29:422616aa04bd | 254 | } |
WiredHome | 29:422616aa04bd | 255 | } |
WiredHome | 29:422616aa04bd | 256 | return charWidth; |
dreschpe | 0:de9d1462a835 | 257 | } |
dreschpe | 0:de9d1462a835 | 258 | |
WiredHome | 29:422616aa04bd | 259 | |
WiredHome | 29:422616aa04bd | 260 | |
WiredHome | 19:3f82c1161fd2 | 261 | int GraphicsDisplay::columns() |
WiredHome | 19:3f82c1161fd2 | 262 | { |
WiredHome | 19:3f82c1161fd2 | 263 | return width() / 8; |
dreschpe | 0:de9d1462a835 | 264 | } |
dreschpe | 0:de9d1462a835 | 265 | |
WiredHome | 19:3f82c1161fd2 | 266 | int GraphicsDisplay::rows() |
WiredHome | 19:3f82c1161fd2 | 267 | { |
WiredHome | 19:3f82c1161fd2 | 268 | return height() / 8; |
WiredHome | 19:3f82c1161fd2 | 269 | } |
WiredHome | 19:3f82c1161fd2 | 270 |