PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Dependents:   Sensitive

Fork of PokittoLib by Jonne Valola

Committer:
spinal
Date:
Wed Oct 18 14:47:54 2017 +0000
Revision:
15:0bbe8f6fae32
Parent:
7:72f87b7c7400
direct lcd stuff used by sensitive

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pokitto 7:72f87b7c7400 1 /**************************************************************************/
Pokitto 7:72f87b7c7400 2 /*!
Pokitto 7:72f87b7c7400 3 @file PokittoDisplay.h
Pokitto 7:72f87b7c7400 4 @author Jonne Valola
Pokitto 7:72f87b7c7400 5
Pokitto 7:72f87b7c7400 6 @section LICENSE
Pokitto 7:72f87b7c7400 7
Pokitto 7:72f87b7c7400 8 Software License Agreement (BSD License)
Pokitto 7:72f87b7c7400 9
Pokitto 7:72f87b7c7400 10 Copyright (c) 2016, Jonne Valola
Pokitto 7:72f87b7c7400 11 All rights reserved.
Pokitto 7:72f87b7c7400 12
Pokitto 7:72f87b7c7400 13 Redistribution and use in source and binary forms, with or without
Pokitto 7:72f87b7c7400 14 modification, are permitted provided that the following conditions are met:
Pokitto 7:72f87b7c7400 15 1. Redistributions of source code must retain the above copyright
Pokitto 7:72f87b7c7400 16 notice, this list of conditions and the following disclaimer.
Pokitto 7:72f87b7c7400 17 2. Redistributions in binary form must reproduce the above copyright
Pokitto 7:72f87b7c7400 18 notice, this list of conditions and the following disclaimer in the
Pokitto 7:72f87b7c7400 19 documentation and/or other materials provided with the distribution.
Pokitto 7:72f87b7c7400 20 3. Neither the name of the copyright holders nor the
Pokitto 7:72f87b7c7400 21 names of its contributors may be used to endorse or promote products
Pokitto 7:72f87b7c7400 22 derived from this software without specific prior written permission.
Pokitto 7:72f87b7c7400 23
Pokitto 7:72f87b7c7400 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
Pokitto 7:72f87b7c7400 25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Pokitto 7:72f87b7c7400 26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Pokitto 7:72f87b7c7400 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
Pokitto 7:72f87b7c7400 28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Pokitto 7:72f87b7c7400 29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Pokitto 7:72f87b7c7400 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
Pokitto 7:72f87b7c7400 31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Pokitto 7:72f87b7c7400 32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Pokitto 7:72f87b7c7400 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Pokitto 7:72f87b7c7400 34 */
Pokitto 7:72f87b7c7400 35 /**************************************************************************/
Pokitto 7:72f87b7c7400 36
Pokitto 7:72f87b7c7400 37
Pokitto 7:72f87b7c7400 38
Pokitto 7:72f87b7c7400 39 /* THE SEGMENT BELOW PERTAINS TO CIRCLE DRAWING FUNCTIONS ONLY
Pokitto 7:72f87b7c7400 40 *
Pokitto 7:72f87b7c7400 41 This is the core graphics library for all our displays, providing a common
Pokitto 7:72f87b7c7400 42 set of graphics primitives (points, lines, circles, etc.). It needs to be
Pokitto 7:72f87b7c7400 43 paired with a hardware-specific library for each display device we carry
Pokitto 7:72f87b7c7400 44 (to handle the lower-level functions).
Pokitto 7:72f87b7c7400 45 Adafruit invests time and resources providing this open source code, please
Pokitto 7:72f87b7c7400 46 support Adafruit & open-source hardware by purchasing products from Adafruit!
Pokitto 7:72f87b7c7400 47 Copyright (c) 2013 Adafruit Industries. All rights reserved.
Pokitto 7:72f87b7c7400 48 Redistribution and use in source and binary forms, with or without
Pokitto 7:72f87b7c7400 49 modification, are permitted provided that the following conditions are met:
Pokitto 7:72f87b7c7400 50 - Redistributions of source code must retain the above copyright notice,
Pokitto 7:72f87b7c7400 51 this list of conditions and the following disclaimer.
Pokitto 7:72f87b7c7400 52 - Redistributions in binary form must reproduce the above copyright notice,
Pokitto 7:72f87b7c7400 53 this list of conditions and the following disclaimer in the documentation
Pokitto 7:72f87b7c7400 54 and/or other materials provided with the distribution.
Pokitto 7:72f87b7c7400 55 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Pokitto 7:72f87b7c7400 56 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Pokitto 7:72f87b7c7400 57 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Pokitto 7:72f87b7c7400 58 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
Pokitto 7:72f87b7c7400 59 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
Pokitto 7:72f87b7c7400 60 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
Pokitto 7:72f87b7c7400 61 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Pokitto 7:72f87b7c7400 62 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Pokitto 7:72f87b7c7400 63 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
Pokitto 7:72f87b7c7400 64 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Pokitto 7:72f87b7c7400 65 POSSIBILITY OF SUCH DAMAGE.
Pokitto 7:72f87b7c7400 66 */
Pokitto 7:72f87b7c7400 67
Pokitto 7:72f87b7c7400 68 #ifndef POKITTODISPLAY_H
Pokitto 7:72f87b7c7400 69 #define POKITTODISPLAY_H
Pokitto 7:72f87b7c7400 70
Pokitto 7:72f87b7c7400 71 #include <stdint.h>
Pokitto 7:72f87b7c7400 72 #include "Pokitto_settings.h"
Pokitto 7:72f87b7c7400 73 #include "PokittoGlobs.h"
Pokitto 7:72f87b7c7400 74 #include "PokittoFonts.h"
Pokitto 7:72f87b7c7400 75 #include "PokittoPalettes.h"
Pokitto 7:72f87b7c7400 76
Pokitto 7:72f87b7c7400 77 // Basic Color definitions
Pokitto 7:72f87b7c7400 78 #define COLOR_BLACK (uint16_t)(0x0000)
Pokitto 7:72f87b7c7400 79 #define COLOR_BLUE (uint16_t)(0x001F)
Pokitto 7:72f87b7c7400 80 #define COLOR_RED (uint16_t)(0xF800)
Pokitto 7:72f87b7c7400 81 #define COLOR_GREEN (uint16_t)(0x07E0)
Pokitto 7:72f87b7c7400 82 #define COLOR_CYAN (uint16_t)(0x07FF)
Pokitto 7:72f87b7c7400 83 #define COLOR_MAGENTA (uint16_t)(0xF81F)
Pokitto 7:72f87b7c7400 84 #define COLOR_YELLOW (uint16_t)(0xFFE0)
Pokitto 7:72f87b7c7400 85 #define COLOR_WHITE (uint16_t)(0xFFFF)
Pokitto 7:72f87b7c7400 86
Pokitto 7:72f87b7c7400 87 // Grayscale Values
Pokitto 7:72f87b7c7400 88 #define COLOR_GRAY_15 (uint16_t)(0x0861) // 15 15 15
Pokitto 7:72f87b7c7400 89 #define COLOR_GRAY_30 (uint16_t)(0x18E3) // 30 30 30
Pokitto 7:72f87b7c7400 90 #define COLOR_GRAY_50 (uint16_t)(0x3186) // 50 50 50
Pokitto 7:72f87b7c7400 91 #define COLOR_GRAY_80 (uint16_t)(0x528A) // 80 80 80
Pokitto 7:72f87b7c7400 92 #define COLOR_GRAY_128 (uint16_t)(0x8410) // 128 128 128
Pokitto 7:72f87b7c7400 93 #define COLOR_GRAY_200 (uint16_t)(0xCE59) // 200 200 200
Pokitto 7:72f87b7c7400 94 #define COLOR_GRAY_225 (uint16_t)(0xE71C) // 225 225 225
Pokitto 7:72f87b7c7400 95
Pokitto 7:72f87b7c7400 96 /** The tables below are palettes, that resemble the Pico 8 palette*/
Pokitto 7:72f87b7c7400 97
Pokitto 7:72f87b7c7400 98 enum defcolors {
Pokitto 7:72f87b7c7400 99 C_BLACK,
Pokitto 7:72f87b7c7400 100 C_DARKBLUE,
Pokitto 7:72f87b7c7400 101 C_PURPLE,
Pokitto 7:72f87b7c7400 102 C_DARKGREEN,
Pokitto 7:72f87b7c7400 103
Pokitto 7:72f87b7c7400 104 C_BROWN,
Pokitto 7:72f87b7c7400 105 C_DARKBROWN,
Pokitto 7:72f87b7c7400 106 C_LIGHTGRAY,
Pokitto 7:72f87b7c7400 107 C_WHITE,
Pokitto 7:72f87b7c7400 108
Pokitto 7:72f87b7c7400 109 C_RED,
Pokitto 7:72f87b7c7400 110 C_ORANGE,
Pokitto 7:72f87b7c7400 111 C_YELLOW,
Pokitto 7:72f87b7c7400 112 C_GREEN,
Pokitto 7:72f87b7c7400 113
Pokitto 7:72f87b7c7400 114 C_BLUE,
Pokitto 7:72f87b7c7400 115 C_DARKGRAY,
Pokitto 7:72f87b7c7400 116 C_PINK,
Pokitto 7:72f87b7c7400 117 C_PEACH
Pokitto 7:72f87b7c7400 118 };
Pokitto 7:72f87b7c7400 119
Pokitto 7:72f87b7c7400 120 const uint16_t def565palette[16] = {
Pokitto 7:72f87b7c7400 121 //kind of like pico8 palette
Pokitto 7:72f87b7c7400 122 0,0x194a,0x792a,0x42a,
Pokitto 7:72f87b7c7400 123 0xaa86,0x5aa9,0xc618,0xff9d,
Pokitto 7:72f87b7c7400 124 0xf809,0xfd00,0xff84,0x72a,
Pokitto 7:72f87b7c7400 125 0x2d7f,0x83b3,0xfbb5,0xfe75
Pokitto 7:72f87b7c7400 126 };
Pokitto 7:72f87b7c7400 127
Pokitto 7:72f87b7c7400 128 #define PALETTE_SIZE 16
Pokitto 7:72f87b7c7400 129 #include <stdint.h>
Pokitto 7:72f87b7c7400 130 #include <stdlib.h>
Pokitto 7:72f87b7c7400 131 #include <string.h>
Pokitto 7:72f87b7c7400 132
Pokitto 7:72f87b7c7400 133
Pokitto 7:72f87b7c7400 134 namespace Pokitto {
Pokitto 7:72f87b7c7400 135
Pokitto 7:72f87b7c7400 136 class Display {
Pokitto 7:72f87b7c7400 137 public:
Pokitto 7:72f87b7c7400 138 Display();
Pokitto 7:72f87b7c7400 139
Pokitto 7:72f87b7c7400 140 // PROPERTIES
Pokitto 7:72f87b7c7400 141 private:
Pokitto 7:72f87b7c7400 142 static uint8_t* canvas;
Pokitto 7:72f87b7c7400 143 static uint8_t bpp;
Pokitto 7:72f87b7c7400 144 static uint8_t m_colordepth;
Pokitto 7:72f87b7c7400 145 public:
Pokitto 7:72f87b7c7400 146 static uint8_t width;
Pokitto 7:72f87b7c7400 147 static uint8_t height;
Pokitto 7:72f87b7c7400 148 static uint8_t screenbuffer[];
Pokitto 7:72f87b7c7400 149
Pokitto 7:72f87b7c7400 150 // PROPERTIES
Pokitto 7:72f87b7c7400 151 static void setColorDepth(uint8_t);
Pokitto 7:72f87b7c7400 152 static uint8_t getColorDepth();
Pokitto 7:72f87b7c7400 153 static uint8_t getBitsPerPixel();
Pokitto 7:72f87b7c7400 154 static uint16_t getWidth();
Pokitto 7:72f87b7c7400 155 static uint16_t getHeight();
Pokitto 7:72f87b7c7400 156 static uint8_t getNumberOfColors();
Pokitto 7:72f87b7c7400 157
Pokitto 7:72f87b7c7400 158 // IMPORTANT PUBLIC STATE MEMBERS
Pokitto 7:72f87b7c7400 159 /** Selected font */
Pokitto 7:72f87b7c7400 160 static const unsigned char * font;
Pokitto 7:72f87b7c7400 161 /** Set if screen is cleared between updates or not*/
Pokitto 7:72f87b7c7400 162 static uint8_t persistence;
Pokitto 7:72f87b7c7400 163 /** Selected drawing color */
Pokitto 7:72f87b7c7400 164 static uint16_t color;
Pokitto 7:72f87b7c7400 165 /** Selected background color */
Pokitto 7:72f87b7c7400 166 static uint16_t bgcolor;
Pokitto 7:72f87b7c7400 167 /** Selected invisible color */
Pokitto 7:72f87b7c7400 168 static uint16_t invisiblecolor;
Pokitto 7:72f87b7c7400 169 /** Direct unbuffered color */
Pokitto 7:72f87b7c7400 170 static uint16_t directcolor;
Pokitto 7:72f87b7c7400 171 /** Direct unbuffered background color */
Pokitto 7:72f87b7c7400 172 static uint16_t directbgcolor;
Pokitto 7:72f87b7c7400 173 /** set color with a command */
Pokitto 7:72f87b7c7400 174 static void setColor(uint8_t);
Pokitto 7:72f87b7c7400 175 /** set color and bgcolor with a command */
Pokitto 7:72f87b7c7400 176 static void setColor(uint8_t,uint8_t);
Pokitto 7:72f87b7c7400 177 /** set invisiblecolor with a command */
Pokitto 7:72f87b7c7400 178 static void setInvisibleColor(uint16_t);
Pokitto 7:72f87b7c7400 179 /** get color */
Pokitto 7:72f87b7c7400 180 static uint8_t getColor();
Pokitto 7:72f87b7c7400 181 /** get background color */
Pokitto 7:72f87b7c7400 182 static uint8_t getBgColor();
Pokitto 7:72f87b7c7400 183 /** get invisible color */
Pokitto 7:72f87b7c7400 184 static uint16_t getInvisibleColor();
Pokitto 7:72f87b7c7400 185
Pokitto 7:72f87b7c7400 186
Pokitto 7:72f87b7c7400 187 /** Initialize display */
Pokitto 7:72f87b7c7400 188 static void begin();
Pokitto 7:72f87b7c7400 189 /** Clear display buffer */
Pokitto 7:72f87b7c7400 190 static void clear();
Pokitto 7:72f87b7c7400 191 /** Scroll by x lines */
Pokitto 7:72f87b7c7400 192 static void scroll(int16_t);
Pokitto 7:72f87b7c7400 193 /** Fill display buffer */
Pokitto 7:72f87b7c7400 194 static void fillScreen(uint16_t);
Pokitto 7:72f87b7c7400 195 /** Send display buffer to display hardware */
Pokitto 7:72f87b7c7400 196 static void update();
Pokitto 7:72f87b7c7400 197 /** Forced update of LCD display memory with a given pixel buffer */
Pokitto 7:72f87b7c7400 198 static void lcdRefresh(unsigned char*);
Pokitto 7:72f87b7c7400 199 /** Clear LCD hardware memory */
Pokitto 7:72f87b7c7400 200 static void clearLCD();
Pokitto 7:72f87b7c7400 201 /** Fill LCD hardware memory */
Pokitto 7:72f87b7c7400 202 static void fillLCD(uint16_t);
Pokitto 7:72f87b7c7400 203 /** Show Pokitto logo at startup*/
Pokitto 7:72f87b7c7400 204 static void showLogo();
Pokitto 7:72f87b7c7400 205 /** Point to another screenbuffer instead of the default one */
Pokitto 7:72f87b7c7400 206 static void setFrameBufferTo(uint8_t*);
Pokitto 7:72f87b7c7400 207
Pokitto 7:72f87b7c7400 208 // COLORS AND PALETTE
Pokitto 7:72f87b7c7400 209 public:
Pokitto 7:72f87b7c7400 210 /** set default palette */
Pokitto 7:72f87b7c7400 211 static void setDefaultPalette();
Pokitto 7:72f87b7c7400 212 /** master palette */
Pokitto 7:72f87b7c7400 213 static uint16_t palette[PALETTE_SIZE];
Pokitto 7:72f87b7c7400 214 /** runtime palette pointer */
Pokitto 7:72f87b7c7400 215 static uint16_t *paletteptr;
Pokitto 7:72f87b7c7400 216 /** convert RGB to 565 color value */
Pokitto 7:72f87b7c7400 217 static uint16_t RGBto565(uint8_t,uint8_t,uint8_t);
Pokitto 7:72f87b7c7400 218 /** linear interpolation between colors */
Pokitto 7:72f87b7c7400 219 static uint16_t interpolateColor(uint16_t, uint16_t, uint8_t);
Pokitto 7:72f87b7c7400 220 /** load an R,G,B triplet palette */
Pokitto 7:72f87b7c7400 221 static void loadRGBPalette(const unsigned char*);
Pokitto 7:72f87b7c7400 222 /** load a ready-made 565 palette */
Pokitto 7:72f87b7c7400 223 static void load565Palette(const uint16_t*);
Pokitto 7:72f87b7c7400 224 /** rotate palette by step */
Pokitto 7:72f87b7c7400 225 static void rotatePalette(int8_t);
Pokitto 7:72f87b7c7400 226 /** tween between two palettes **/
Pokitto 7:72f87b7c7400 227 static void tweenPalette(uint16_t*, const uint16_t*, const uint16_t*, uint8_t);
Pokitto 7:72f87b7c7400 228
Pokitto 7:72f87b7c7400 229 // DIRECT DRAWING (NO BUFFERING)
Pokitto 7:72f87b7c7400 230 /** Direct pixel (not through display buffer) */
Pokitto 7:72f87b7c7400 231 static void directPixel(int16_t,int16_t,uint16_t);
spinal 15:0bbe8f6fae32 232 /** Direct tile 16bit (not through display buffer) */
spinal 15:0bbe8f6fae32 233 static void directTile(int16_t x, int16_t y, int16_t x2, int16_t y2, uint16_t* gfx);
Pokitto 7:72f87b7c7400 234 /** Direct rectangle (not through display buffer) */
Pokitto 7:72f87b7c7400 235 static void directRectangle(int16_t, int16_t,int16_t, int16_t, uint16_t);
Pokitto 7:72f87b7c7400 236 /** Set the cursor for printing to a certain screen position */
Pokitto 7:72f87b7c7400 237 static void setCursor(int16_t,int16_t);
Pokitto 7:72f87b7c7400 238 /** direct bitmap to screen (no buffering) */
Pokitto 7:72f87b7c7400 239 static void directBitmap(int16_t,int16_t,const uint8_t*, uint8_t,uint8_t);
Pokitto 7:72f87b7c7400 240
Pokitto 7:72f87b7c7400 241
Pokitto 7:72f87b7c7400 242 // DRAWING METHODS
Pokitto 7:72f87b7c7400 243 /** Draw pixel at various bit depths */
Pokitto 7:72f87b7c7400 244 static void drawPixel(int16_t,int16_t);
Pokitto 7:72f87b7c7400 245 /** Draw pixel with specific color index at various bit depths */
Pokitto 7:72f87b7c7400 246 static void drawPixel(int16_t x,int16_t y, uint8_t col);
Pokitto 7:72f87b7c7400 247 /** Get pixel at various bit depths */
Pokitto 7:72f87b7c7400 248 static uint8_t getPixel(int16_t,int16_t);
Pokitto 7:72f87b7c7400 249 /** Draw line **/
Pokitto 7:72f87b7c7400 250 static void drawLine(int16_t,int16_t,int16_t,int16_t);
Pokitto 7:72f87b7c7400 251 /** Clip line with screen boundaries, returns 0 if whole line is out of bounds */
Pokitto 7:72f87b7c7400 252 static uint8_t clipLine(int16_t*, int16_t*, int16_t*, int16_t*);
Pokitto 7:72f87b7c7400 253 /** Draw a column real fast */
Pokitto 7:72f87b7c7400 254 static void drawColumn(int16_t, int16_t, int16_t);
Pokitto 7:72f87b7c7400 255 /** Map a 1-bit column real fast */
Pokitto 7:72f87b7c7400 256 static void map1BitColumn(int16_t, int16_t, int16_t, const uint8_t*, uint16_t);
Pokitto 7:72f87b7c7400 257 /** Draw a row real fast */
Pokitto 7:72f87b7c7400 258 static void drawRow(int16_t, int16_t, int16_t);
Pokitto 7:72f87b7c7400 259 /** Legacy drawColumn name, for compatibility - macros are not OK because of scope problems */
Pokitto 7:72f87b7c7400 260 static void drawFastVLine(int16_t, int16_t, int16_t);
Pokitto 7:72f87b7c7400 261 /** Legacy drawRow name, for compatibility - macros are not OK because of scope problems */
Pokitto 7:72f87b7c7400 262 static void drawFastHLine(int16_t, int16_t, int16_t);
Pokitto 7:72f87b7c7400 263 /** Draw rectangle (edges only) */
Pokitto 7:72f87b7c7400 264 static void drawRectangle(int16_t,int16_t,int16_t,int16_t);
Pokitto 7:72f87b7c7400 265 /** Fill rectangle */
Pokitto 7:72f87b7c7400 266 static void fillRectangle(int16_t,int16_t,int16_t,int16_t);
Pokitto 7:72f87b7c7400 267 /** GB compatibility fillRect */
Pokitto 7:72f87b7c7400 268 static void fillRect(int16_t x, int16_t y, int16_t w, int16_t h);
Pokitto 7:72f87b7c7400 269 /** GB compatibility drawRect */
Pokitto 7:72f87b7c7400 270 static void drawRect(int16_t x, int16_t y, int16_t w, int16_t h);
Pokitto 7:72f87b7c7400 271
Pokitto 7:72f87b7c7400 272 // Functions lifted from Adafruit GFX library (see PokittoDisplay.h for license //
Pokitto 7:72f87b7c7400 273 /** Draw circle */
Pokitto 7:72f87b7c7400 274 static void drawCircle(int16_t x0, int16_t y0, int16_t r);
Pokitto 7:72f87b7c7400 275 /** Draw circle helper */
Pokitto 7:72f87b7c7400 276 static void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint16_t cornername);
Pokitto 7:72f87b7c7400 277 /** Fill circle */
Pokitto 7:72f87b7c7400 278 static void fillCircle(int16_t x0, int16_t y0, int16_t r);
Pokitto 7:72f87b7c7400 279 /** Fill circle helper*/
Pokitto 7:72f87b7c7400 280 static void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint16_t cornername, int16_t delta);
Pokitto 7:72f87b7c7400 281 /** draw triangle */
Pokitto 7:72f87b7c7400 282 static void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2);
Pokitto 7:72f87b7c7400 283 /** Fill triangle*/
Pokitto 7:72f87b7c7400 284 static void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2);
Pokitto 7:72f87b7c7400 285 /** Draw rounded rectangle */
Pokitto 7:72f87b7c7400 286 static void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius);
Pokitto 7:72f87b7c7400 287 /** Fill rounded rectangle */
Pokitto 7:72f87b7c7400 288 static void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius);
Pokitto 7:72f87b7c7400 289
Pokitto 7:72f87b7c7400 290 // BITMAPS !
Pokitto 7:72f87b7c7400 291 /** Draw monochromatic bitmap. Used in font rendering */
Pokitto 7:72f87b7c7400 292 static void drawMonoBitmap(int16_t x, int16_t y, const uint8_t* bitmap, uint8_t index);
Pokitto 7:72f87b7c7400 293 /** Draw bitmap */
Pokitto 7:72f87b7c7400 294 static void drawBitmap(int16_t x, int16_t y, const uint8_t* bitmap);
Pokitto 7:72f87b7c7400 295 /** Draw RLE bitmap */
Pokitto 7:72f87b7c7400 296 static void drawRleBitmap(int16_t x, int16_t y, const uint8_t* bitmap);
Pokitto 7:72f87b7c7400 297 /** Draw animated bitmap frame */
Pokitto 7:72f87b7c7400 298 static void drawBitmap(int16_t x, int16_t y, const uint8_t* bitmap, uint8_t frame);
Pokitto 7:72f87b7c7400 299 /** Draw bitmap flipped on x-axis*/
Pokitto 7:72f87b7c7400 300 static void drawBitmapXFlipped(int16_t x, int16_t y, const uint8_t* bitmap);
Pokitto 7:72f87b7c7400 301 /** Draw bitmap with options */
Pokitto 7:72f87b7c7400 302 static void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t rotation, uint8_t flip);
Pokitto 7:72f87b7c7400 303 /** Get pointer to the screen buffer - GB compatibility */
Pokitto 7:72f87b7c7400 304 static uint8_t* getBuffer();
Pokitto 7:72f87b7c7400 305 /** Get pixel in a monochromatic bitmap - GB compatibility */
Pokitto 7:72f87b7c7400 306 static uint8_t getBitmapPixel(const uint8_t*, uint16_t, uint16_t);
Pokitto 7:72f87b7c7400 307 /** Optimized functions for drawing bit columns - used in raytracing */
Pokitto 7:72f87b7c7400 308 static void draw4BitColumn(int16_t x, int16_t y, uint8_t h, uint8_t* bitmap);
Pokitto 7:72f87b7c7400 309
Pokitto 7:72f87b7c7400 310 // PRINTING
Pokitto 7:72f87b7c7400 311 /** direct character to screen (no buffering) */
Pokitto 7:72f87b7c7400 312 static int directChar(int16_t, int16_t, uint16_t);
Pokitto 7:72f87b7c7400 313 /** character to screenbuffer */
Pokitto 7:72f87b7c7400 314 static int bufferChar(int16_t, int16_t, uint16_t);
Pokitto 7:72f87b7c7400 315 /** set the active font */
Pokitto 7:72f87b7c7400 316 static void setFont(const unsigned char * f);
Pokitto 7:72f87b7c7400 317 /** font dimensions */
Pokitto 7:72f87b7c7400 318 static uint8_t fontWidth, fontHeight;
Pokitto 7:72f87b7c7400 319 /** text wrapping */
Pokitto 7:72f87b7c7400 320 static bool textWrap;
Pokitto 7:72f87b7c7400 321 /** GB compatibility drawChar */
Pokitto 7:72f87b7c7400 322 static void drawChar(int8_t x, int8_t y, unsigned char c, uint8_t size);
Pokitto 7:72f87b7c7400 323
Pokitto 7:72f87b7c7400 324 static void enableDirectPrinting(uint8_t m);
Pokitto 7:72f87b7c7400 325 static bool isDirectPrintingEnabled();
Pokitto 7:72f87b7c7400 326 static int print_char(uint8_t x, uint8_t y, unsigned char c);
Pokitto 7:72f87b7c7400 327 static void set_cursor(uint8_t, uint8_t);
Pokitto 7:72f87b7c7400 328 static void write(uint8_t);
Pokitto 7:72f87b7c7400 329 static void write(const char *str);
Pokitto 7:72f87b7c7400 330 static void write(const uint8_t *buffer, uint8_t size);
Pokitto 7:72f87b7c7400 331 static void print(const char[]);
Pokitto 7:72f87b7c7400 332 static void print(char, int base = 0);
Pokitto 7:72f87b7c7400 333 static void print(unsigned char, int base = 0);
Pokitto 7:72f87b7c7400 334 static void print(int, int base = 10);
Pokitto 7:72f87b7c7400 335 static void print(unsigned int, int base = 10);
Pokitto 7:72f87b7c7400 336 static void print(long, int base = 10);
Pokitto 7:72f87b7c7400 337 static void print(unsigned long, int base = 10);
Pokitto 7:72f87b7c7400 338 static void print(double, int base = 2);
Pokitto 7:72f87b7c7400 339 static void print(uint8_t, uint8_t, const char[]);
Pokitto 7:72f87b7c7400 340 static void print(uint8_t, uint8_t, char, int = 0);
Pokitto 7:72f87b7c7400 341 static void print(uint8_t, uint8_t, unsigned char, int = 0);
Pokitto 7:72f87b7c7400 342 static void print(uint8_t, uint8_t, int, int = 10);
Pokitto 7:72f87b7c7400 343 static void print(uint8_t, uint8_t, unsigned int, int = 10);
Pokitto 7:72f87b7c7400 344 static void print(uint8_t, uint8_t, long, int = 10);
Pokitto 7:72f87b7c7400 345 static void print(uint8_t, uint8_t, unsigned long, int = 10);
Pokitto 7:72f87b7c7400 346 static void print(uint8_t, uint8_t, double, int = 2);
Pokitto 7:72f87b7c7400 347 static void println(uint8_t, uint8_t, const char[]);
Pokitto 7:72f87b7c7400 348 static void println(uint8_t, uint8_t, char, int = 0);
Pokitto 7:72f87b7c7400 349 static void println(uint8_t, uint8_t, unsigned char, int = 0);
Pokitto 7:72f87b7c7400 350 static void println(uint8_t, uint8_t, int, int = 10);
Pokitto 7:72f87b7c7400 351 static void println(uint8_t, uint8_t, unsigned int, int = 10);
Pokitto 7:72f87b7c7400 352 static void println(uint8_t, uint8_t, long, int = 10);
Pokitto 7:72f87b7c7400 353 static void println(uint8_t, uint8_t, unsigned long, int = 10);
Pokitto 7:72f87b7c7400 354 static void println(uint8_t, uint8_t, double, int = 2);
Pokitto 7:72f87b7c7400 355 static void println(uint8_t, uint8_t);
Pokitto 7:72f87b7c7400 356 static void println(const char[]);
Pokitto 7:72f87b7c7400 357 static void println(char, int = 0);
Pokitto 7:72f87b7c7400 358 static void println(unsigned char, int = 0);
Pokitto 7:72f87b7c7400 359 static void println(int, int = 10);
Pokitto 7:72f87b7c7400 360 static void println(unsigned int, int = 10);
Pokitto 7:72f87b7c7400 361 static void println(long, int = 10 );
Pokitto 7:72f87b7c7400 362 static void println(unsigned long, int = 10);
Pokitto 7:72f87b7c7400 363 static void println(double, int = 2);
Pokitto 7:72f87b7c7400 364 static void println(void);
Pokitto 7:72f87b7c7400 365
Pokitto 7:72f87b7c7400 366 static int16_t cursorX,cursorY;
Pokitto 7:72f87b7c7400 367 static uint8_t fontSize;
Pokitto 7:72f87b7c7400 368 static int8_t adjustCharStep, adjustLineStep;
Pokitto 7:72f87b7c7400 369 static bool fixedWidthFont;
Pokitto 7:72f87b7c7400 370
Pokitto 7:72f87b7c7400 371 static void inc_txtline();
Pokitto 7:72f87b7c7400 372 static void printNumber(unsigned long, uint8_t);
Pokitto 7:72f87b7c7400 373 static void printFloat(double, uint8_t);
Pokitto 7:72f87b7c7400 374
Pokitto 7:72f87b7c7400 375 /** Tiled mode functions **/
Pokitto 7:72f87b7c7400 376
Pokitto 7:72f87b7c7400 377 static void loadTileset(const uint8_t*);
Pokitto 7:72f87b7c7400 378
Pokitto 7:72f87b7c7400 379 static void setTileBufferTo(uint8_t*);
Pokitto 7:72f87b7c7400 380 static void clearTileBuffer();
Pokitto 7:72f87b7c7400 381 static void shiftTileBuffer(int8_t,int8_t);
Pokitto 7:72f87b7c7400 382
Pokitto 7:72f87b7c7400 383 static void setTile(uint16_t,uint8_t);
Pokitto 7:72f87b7c7400 384 static uint8_t getTile(uint16_t);
Pokitto 7:72f87b7c7400 385 static uint8_t getTile(uint8_t,uint8_t);
Pokitto 7:72f87b7c7400 386
Pokitto 7:72f87b7c7400 387
Pokitto 7:72f87b7c7400 388
Pokitto 7:72f87b7c7400 389 private:
Pokitto 7:72f87b7c7400 390 static uint8_t m_mode;
Pokitto 7:72f87b7c7400 391 static uint16_t m_w,m_h; // store these for faster access when switching printing modes
Pokitto 7:72f87b7c7400 392 /** Pointer to screen buffer */
Pokitto 7:72f87b7c7400 393 static uint8_t* m_scrbuf;
Pokitto 7:72f87b7c7400 394 /** Pointer to tileset */
Pokitto 7:72f87b7c7400 395 static uint8_t* m_tileset;
Pokitto 7:72f87b7c7400 396 /** Pointer to tilebuffer */
Pokitto 7:72f87b7c7400 397 static uint8_t* m_tilebuf;
Pokitto 7:72f87b7c7400 398 /** Pointer to tilecolorbuffer */
Pokitto 7:72f87b7c7400 399 static uint8_t* m_tilecolorbuf;
Pokitto 7:72f87b7c7400 400
Pokitto 7:72f87b7c7400 401 };
Pokitto 7:72f87b7c7400 402
Pokitto 7:72f87b7c7400 403 }
Pokitto 7:72f87b7c7400 404
Pokitto 7:72f87b7c7400 405 #endif // POKITTODISPLAY_H
Pokitto 7:72f87b7c7400 406
Pokitto 7:72f87b7c7400 407
Pokitto 7:72f87b7c7400 408
Pokitto 7:72f87b7c7400 409