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

Dependents:   YATTT sd_map_test cPong SnowDemo ... more

PokittoLib

Library for programming Pokitto hardware

How to Use

  1. Import this library to online compiler (see button "import" on the right hand side
  2. DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
  3. Change My_settings.h according to your project
  4. Start coding!
Committer:
Pokitto
Date:
Mon May 21 18:03:14 2018 +0000
Revision:
46:e7e438368e16
Child:
48:30b068b0d9e8
Fixes to sound;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pokitto 46:e7e438368e16 1 /**************************************************************************/
Pokitto 46:e7e438368e16 2 /*!
Pokitto 46:e7e438368e16 3 @file HWLCD.cpp
Pokitto 46:e7e438368e16 4 @author Jonne Valola
Pokitto 46:e7e438368e16 5
Pokitto 46:e7e438368e16 6 @section LICENSE
Pokitto 46:e7e438368e16 7
Pokitto 46:e7e438368e16 8 Software License Agreement (BSD License)
Pokitto 46:e7e438368e16 9
Pokitto 46:e7e438368e16 10 Copyright (c) 2016, Jonne Valola
Pokitto 46:e7e438368e16 11 All rights reserved.
Pokitto 46:e7e438368e16 12
Pokitto 46:e7e438368e16 13 Redistribution and use in source and binary forms, with or without
Pokitto 46:e7e438368e16 14 modification, are permitted provided that the following conditions are met:
Pokitto 46:e7e438368e16 15 1. Redistributions of source code must retain the above copyright
Pokitto 46:e7e438368e16 16 notice, this list of conditions and the following disclaimer.
Pokitto 46:e7e438368e16 17 2. Redistributions in binary form must reproduce the above copyright
Pokitto 46:e7e438368e16 18 notice, this list of conditions and the following disclaimer in the
Pokitto 46:e7e438368e16 19 documentation and/or other materials provided with the distribution.
Pokitto 46:e7e438368e16 20 3. Neither the name of the copyright holders nor the
Pokitto 46:e7e438368e16 21 names of its contributors may be used to endorse or promote products
Pokitto 46:e7e438368e16 22 derived from this software without specific prior written permission.
Pokitto 46:e7e438368e16 23
Pokitto 46:e7e438368e16 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
Pokitto 46:e7e438368e16 25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Pokitto 46:e7e438368e16 26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Pokitto 46:e7e438368e16 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
Pokitto 46:e7e438368e16 28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Pokitto 46:e7e438368e16 29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Pokitto 46:e7e438368e16 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
Pokitto 46:e7e438368e16 31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Pokitto 46:e7e438368e16 32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Pokitto 46:e7e438368e16 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Pokitto 46:e7e438368e16 34 */
Pokitto 46:e7e438368e16 35 /**************************************************************************/
Pokitto 46:e7e438368e16 36
Pokitto 46:e7e438368e16 37 #include "HWLCD.h" //HWLCD.h" #include "HWLCD.h"
Pokitto 46:e7e438368e16 38 #include "Pokitto_settings.h"
Pokitto 46:e7e438368e16 39
Pokitto 46:e7e438368e16 40 #ifndef DISABLEAVRMIN
Pokitto 46:e7e438368e16 41 #define max(a,b) ((a)>(b)?(a):(b))
Pokitto 46:e7e438368e16 42 #define min(a,b) ((a)<(b)?(a):(b))
Pokitto 46:e7e438368e16 43 #endif // DISABLEAVRMIN
Pokitto 46:e7e438368e16 44
Pokitto 46:e7e438368e16 45 #ifdef DISABLEAVRMIN
Pokitto 46:e7e438368e16 46 #include <algorithm>
Pokitto 46:e7e438368e16 47 using std::min;
Pokitto 46:e7e438368e16 48 using std::max;
Pokitto 46:e7e438368e16 49 #endif // DISABLEAVRMIN
Pokitto 46:e7e438368e16 50
Pokitto 46:e7e438368e16 51 #define AB_JUMP 1024 // jump one 1-bit Arduboy screen forward to get next color bit
Pokitto 46:e7e438368e16 52 #define GB_JUMP 504 // jump one 1-bit Gamebuino screen forward to get next color bit
Pokitto 46:e7e438368e16 53
Pokitto 46:e7e438368e16 54 using namespace Pokitto;
Pokitto 46:e7e438368e16 55
Pokitto 46:e7e438368e16 56 uint16_t prevdata=0; // if data does not change, do not adjust LCD bus lines
Pokitto 46:e7e438368e16 57
Pokitto 46:e7e438368e16 58 #if POK_BOARDREV == 2
Pokitto 46:e7e438368e16 59 pwmout_t backlightpwm;
Pokitto 46:e7e438368e16 60 #endif
Pokitto 46:e7e438368e16 61
Pokitto 46:e7e438368e16 62
Pokitto 46:e7e438368e16 63 /**************************************************************************/
Pokitto 46:e7e438368e16 64 /*!
Pokitto 46:e7e438368e16 65 @brief set up the 16-bit bus
Pokitto 46:e7e438368e16 66 */
Pokitto 46:e7e438368e16 67 /**************************************************************************/
Pokitto 46:e7e438368e16 68
Pokitto 46:e7e438368e16 69 static inline void setup_data_16(uint16_t data)
Pokitto 46:e7e438368e16 70 {
Pokitto 46:e7e438368e16 71 //uint32_t p2=0;
Pokitto 46:e7e438368e16 72
Pokitto 46:e7e438368e16 73 //if (data != prevdata) {
Pokitto 46:e7e438368e16 74 //
Pokitto 46:e7e438368e16 75 //prevdata=data;
Pokitto 46:e7e438368e16 76
Pokitto 46:e7e438368e16 77 /** D0...D16 = P2_3 ... P2_18 **/
Pokitto 46:e7e438368e16 78 //p2 = data << 3;
Pokitto 46:e7e438368e16 79
Pokitto 46:e7e438368e16 80 //__disable_irq(); // Disable Interrupts
Pokitto 46:e7e438368e16 81 SET_MASK_P2;
Pokitto 46:e7e438368e16 82 LPC_GPIO_PORT->MPIN[2] = (data<<3); // write bits to port
Pokitto 46:e7e438368e16 83 CLR_MASK_P2;
Pokitto 46:e7e438368e16 84 //__enable_irq(); // Enable Interrupts
Pokitto 46:e7e438368e16 85 //}
Pokitto 46:e7e438368e16 86 }
Pokitto 46:e7e438368e16 87
Pokitto 46:e7e438368e16 88
Pokitto 46:e7e438368e16 89 /**************************************************************************/
Pokitto 46:e7e438368e16 90 /*!
Pokitto 46:e7e438368e16 91 @brief Write a command to the lcd, 16-bit bus
Pokitto 46:e7e438368e16 92 */
Pokitto 46:e7e438368e16 93 /**************************************************************************/
Pokitto 46:e7e438368e16 94 inline void write_command_16(uint16_t data)
Pokitto 46:e7e438368e16 95 {
Pokitto 46:e7e438368e16 96 CLR_CS; // select lcd
Pokitto 46:e7e438368e16 97 CLR_CD; // clear CD = command
Pokitto 46:e7e438368e16 98 SET_RD; // RD high, do not read
Pokitto 46:e7e438368e16 99 setup_data_16(data); // function that inputs the data into the relevant bus lines
Pokitto 46:e7e438368e16 100 CLR_WR_SLOW; // WR low
Pokitto 46:e7e438368e16 101 SET_WR; // WR low, then high = write strobe
Pokitto 46:e7e438368e16 102 SET_CS; // de-select lcd
Pokitto 46:e7e438368e16 103 }
Pokitto 46:e7e438368e16 104
Pokitto 46:e7e438368e16 105 /**************************************************************************/
Pokitto 46:e7e438368e16 106 /*!
Pokitto 46:e7e438368e16 107 @brief Write data to the lcd, 16-bit bus
Pokitto 46:e7e438368e16 108 */
Pokitto 46:e7e438368e16 109 /**************************************************************************/
Pokitto 46:e7e438368e16 110 inline void write_data_16(uint16_t data)
Pokitto 46:e7e438368e16 111 {
Pokitto 46:e7e438368e16 112 CLR_CS;
Pokitto 46:e7e438368e16 113 SET_CD;
Pokitto 46:e7e438368e16 114 SET_RD;
Pokitto 46:e7e438368e16 115 setup_data_16(data);
Pokitto 46:e7e438368e16 116 CLR_WR;
Pokitto 46:e7e438368e16 117 SET_WR;
Pokitto 46:e7e438368e16 118 SET_CS;
Pokitto 46:e7e438368e16 119 }
Pokitto 46:e7e438368e16 120
Pokitto 46:e7e438368e16 121 /**************************************************************************/
Pokitto 46:e7e438368e16 122 /*!
Pokitto 46:e7e438368e16 123 @brief Pump data to the lcd, 16-bit bus, public function
Pokitto 46:e7e438368e16 124 */
Pokitto 46:e7e438368e16 125 /**************************************************************************/
Pokitto 46:e7e438368e16 126 void Pokitto::pumpDRAMdata(uint16_t* data,uint16_t counter)
Pokitto 46:e7e438368e16 127 {
Pokitto 46:e7e438368e16 128 while (counter--) {
Pokitto 46:e7e438368e16 129 CLR_CS;
Pokitto 46:e7e438368e16 130 SET_CD;
Pokitto 46:e7e438368e16 131 SET_RD;
Pokitto 46:e7e438368e16 132 setup_data_16(*data++);
Pokitto 46:e7e438368e16 133 CLR_WR;
Pokitto 46:e7e438368e16 134 SET_WR;
Pokitto 46:e7e438368e16 135 SET_CS;
Pokitto 46:e7e438368e16 136 }
Pokitto 46:e7e438368e16 137 }
Pokitto 46:e7e438368e16 138
Pokitto 46:e7e438368e16 139
Pokitto 46:e7e438368e16 140 /**************************************************************************/
Pokitto 46:e7e438368e16 141 /*!
Pokitto 46:e7e438368e16 142 @brief Point to a (x,y) location in the LCD DRAM
Pokitto 46:e7e438368e16 143 */
Pokitto 46:e7e438368e16 144 /**************************************************************************/
Pokitto 46:e7e438368e16 145 static inline void setDRAMptr(uint8_t xptr, uint8_t yoffset)
Pokitto 46:e7e438368e16 146 {
Pokitto 46:e7e438368e16 147 write_command(0x20); // Vertical DRAM Address
Pokitto 46:e7e438368e16 148 write_data(yoffset);
Pokitto 46:e7e438368e16 149 write_command(0x21); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 150 write_data(xptr); //
Pokitto 46:e7e438368e16 151 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 152 CLR_CS_SET_CD_RD_WR;
Pokitto 46:e7e438368e16 153 }
Pokitto 46:e7e438368e16 154
Pokitto 46:e7e438368e16 155 /**************************************************************************/
Pokitto 46:e7e438368e16 156 /*!
Pokitto 46:e7e438368e16 157 @brief Point to a (x,y) location in the LCD DRAM, public function
Pokitto 46:e7e438368e16 158 */
Pokitto 46:e7e438368e16 159 /**************************************************************************/
Pokitto 46:e7e438368e16 160 void Pokitto::setDRAMpoint(uint8_t xptr, uint8_t yoffset)
Pokitto 46:e7e438368e16 161 {
Pokitto 46:e7e438368e16 162 write_command(0x20); // Vertical DRAM Address
Pokitto 46:e7e438368e16 163 write_data(yoffset);
Pokitto 46:e7e438368e16 164 write_command(0x21); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 165 write_data(xptr); //
Pokitto 46:e7e438368e16 166 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 167 CLR_CS_SET_CD_RD_WR;
Pokitto 46:e7e438368e16 168 }
Pokitto 46:e7e438368e16 169
Pokitto 46:e7e438368e16 170 void Pokitto::initBacklight() {
Pokitto 46:e7e438368e16 171 #if POK_BOARDREV == 2
Pokitto 46:e7e438368e16 172 pwmout_init(&backlightpwm,POK_BACKLIGHT_PIN);
Pokitto 46:e7e438368e16 173 pwmout_period_us(&backlightpwm,5);
Pokitto 46:e7e438368e16 174 pwmout_write(&backlightpwm,POK_BACKLIGHT_INITIALVALUE);
Pokitto 46:e7e438368e16 175 #endif
Pokitto 46:e7e438368e16 176 }
Pokitto 46:e7e438368e16 177
Pokitto 46:e7e438368e16 178 void Pokitto::setBacklight(float value) {
Pokitto 46:e7e438368e16 179 if (value>0.999f) value = 0.999f;
Pokitto 46:e7e438368e16 180 pwmout_write(&backlightpwm,value);
Pokitto 46:e7e438368e16 181 }
Pokitto 46:e7e438368e16 182
Pokitto 46:e7e438368e16 183 void Pokitto::lcdInit() {
Pokitto 46:e7e438368e16 184 initBacklight();
Pokitto 46:e7e438368e16 185
Pokitto 46:e7e438368e16 186 SET_RESET;
Pokitto 46:e7e438368e16 187 wait_ms(10);
Pokitto 46:e7e438368e16 188 CLR_RESET;
Pokitto 46:e7e438368e16 189 wait_ms(10);
Pokitto 46:e7e438368e16 190 SET_RESET;
Pokitto 46:e7e438368e16 191 wait_ms(10);
Pokitto 46:e7e438368e16 192 //************* Start Initial Sequence **********//
Pokitto 46:e7e438368e16 193 write_command(0x01); // driver output control, this also affects direction
Pokitto 46:e7e438368e16 194 write_data(0x11C); // originally: 0x11C 100011100 SS,NL4,NL3,NL2
Pokitto 46:e7e438368e16 195 // NL4...0 is the number of scan lines to drive the screen !!!
Pokitto 46:e7e438368e16 196 // so 11100 is 1c = 220 lines, correct
Pokitto 46:e7e438368e16 197 // test 1: 0x1C 11100 SS=0,NL4,NL3,NL2 -> no effect
Pokitto 46:e7e438368e16 198 // test 2: 0x31C 1100011100 GS=1,SS=1,NL4,NL3,NL2 -> no effect
Pokitto 46:e7e438368e16 199 // test 3: 0x51C 10100011100 SM=1,GS=0,SS=1,NL4,NL3,NL2 -> no effect
Pokitto 46:e7e438368e16 200 // test 4: 0x71C SM=1,GS=1,SS=1,NL4,NL3,NL2
Pokitto 46:e7e438368e16 201 // test 5: 0x
Pokitto 46:e7e438368e16 202 // seems to have no effect... is this perhaps only for RGB mode ?
Pokitto 46:e7e438368e16 203
Pokitto 46:e7e438368e16 204 write_command(0x02); // LCD driving control
Pokitto 46:e7e438368e16 205 write_data(0x0100); // INV = 1
Pokitto 46:e7e438368e16 206
Pokitto 46:e7e438368e16 207 write_command(0x03); // Entry mode... lets try if this affects the direction
Pokitto 46:e7e438368e16 208 write_data(0x1030); // originally 0x1030 1000000110000 BGR,ID1,ID0
Pokitto 46:e7e438368e16 209 // test 1: 0x1038 1000000111000 BGR,ID1,ID0,AM=1 ->drawing DRAM horizontally
Pokitto 46:e7e438368e16 210 // test 4: am=1, id0=0, id1=0, 1000000001000,0x1008 -> same as above, but flipped on long
Pokitto 46:e7e438368e16 211 // test 2: am=0, id0=0, 1000000100000, 0x1020 -> flipped on long axis
Pokitto 46:e7e438368e16 212 // test 3: am=0, id1=0, 1000000010000, 0x1010 -> picture flowed over back to screen
Pokitto 46:e7e438368e16 213
Pokitto 46:e7e438368e16 214
Pokitto 46:e7e438368e16 215 write_command(0x08); // Display control 2
Pokitto 46:e7e438368e16 216 write_data(0x0808); // 100000001000 FP2,BP2
Pokitto 46:e7e438368e16 217
Pokitto 46:e7e438368e16 218 write_command(0x0C); // RGB display interface
Pokitto 46:e7e438368e16 219 write_data(0x0000); // all off
Pokitto 46:e7e438368e16 220
Pokitto 46:e7e438368e16 221 write_command(0x0F); // Frame marker position
Pokitto 46:e7e438368e16 222 write_data(0x0001); // OSC_EN
Pokitto 46:e7e438368e16 223
Pokitto 46:e7e438368e16 224 write_command(0x20); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 225 write_data(0x0000); // 0
Pokitto 46:e7e438368e16 226
Pokitto 46:e7e438368e16 227 write_command(0x21); // Vertical DRAM Address
Pokitto 46:e7e438368e16 228 write_data(0x0000); // 0
Pokitto 46:e7e438368e16 229
Pokitto 46:e7e438368e16 230 //*************Power On sequence ****************//
Pokitto 46:e7e438368e16 231 write_command(0x10);
Pokitto 46:e7e438368e16 232 write_data(0x0000);
Pokitto 46:e7e438368e16 233
Pokitto 46:e7e438368e16 234 write_command(0x11);
Pokitto 46:e7e438368e16 235 write_data(0x1000);
Pokitto 46:e7e438368e16 236 wait_ms(10);
Pokitto 46:e7e438368e16 237 //------------------------ Set GRAM area --------------------------------//
Pokitto 46:e7e438368e16 238 write_command(0x30); // Gate scan position
Pokitto 46:e7e438368e16 239 write_data(0x0000); // if GS=0, 00h=G1, else 00h=G220
Pokitto 46:e7e438368e16 240
Pokitto 46:e7e438368e16 241 write_command(0x31); // Vertical scroll control
Pokitto 46:e7e438368e16 242 write_data(0x00DB); // scroll start line 11011011 = 219
Pokitto 46:e7e438368e16 243
Pokitto 46:e7e438368e16 244 write_command(0x32); // Vertical scroll control
Pokitto 46:e7e438368e16 245 write_data(0x0000); // scroll end line 0
Pokitto 46:e7e438368e16 246
Pokitto 46:e7e438368e16 247 write_command(0x33); // Vertical scroll control
Pokitto 46:e7e438368e16 248 write_data(0x0000); // 0=vertical scroll disabled
Pokitto 46:e7e438368e16 249
Pokitto 46:e7e438368e16 250 write_command(0x34); // Partial screen driving control
Pokitto 46:e7e438368e16 251 write_data(0x00DB); // db = full screen (end)
Pokitto 46:e7e438368e16 252
Pokitto 46:e7e438368e16 253 write_command(0x35); // partial screen
Pokitto 46:e7e438368e16 254 write_data(0x0000); // 0 = start
Pokitto 46:e7e438368e16 255
Pokitto 46:e7e438368e16 256 write_command(0x36); // Horizontal and vertical RAM position
Pokitto 46:e7e438368e16 257 write_data(0x00AF); //end address 175
Pokitto 46:e7e438368e16 258
Pokitto 46:e7e438368e16 259 write_command(0x37);
Pokitto 46:e7e438368e16 260 write_data(0x0000); // start address 0
Pokitto 46:e7e438368e16 261
Pokitto 46:e7e438368e16 262 write_command(0x38);
Pokitto 46:e7e438368e16 263 write_data(0x00DB); //end address 219
Pokitto 46:e7e438368e16 264
Pokitto 46:e7e438368e16 265 write_command(0x39); // start address 0
Pokitto 46:e7e438368e16 266 write_data(0x0000);
Pokitto 46:e7e438368e16 267 wait_ms(10);
Pokitto 46:e7e438368e16 268 write_command(0xff); // start gamma register control
Pokitto 46:e7e438368e16 269 write_data(0x0003);
Pokitto 46:e7e438368e16 270
Pokitto 46:e7e438368e16 271 // ----------- Adjust the Gamma Curve ----------//
Pokitto 46:e7e438368e16 272 write_command(0x50);
Pokitto 46:e7e438368e16 273 write_data(0x0203);
Pokitto 46:e7e438368e16 274
Pokitto 46:e7e438368e16 275 write_command(0x051);
Pokitto 46:e7e438368e16 276 write_data(0x0A09);
Pokitto 46:e7e438368e16 277
Pokitto 46:e7e438368e16 278 write_command(0x52);
Pokitto 46:e7e438368e16 279 write_data(0x0005);
Pokitto 46:e7e438368e16 280
Pokitto 46:e7e438368e16 281 write_command(0x53);
Pokitto 46:e7e438368e16 282 write_data(0x1021);
Pokitto 46:e7e438368e16 283
Pokitto 46:e7e438368e16 284 write_command(0x54);
Pokitto 46:e7e438368e16 285 write_data(0x0602);
Pokitto 46:e7e438368e16 286
Pokitto 46:e7e438368e16 287 write_command(0x55);
Pokitto 46:e7e438368e16 288 write_data(0x0003);
Pokitto 46:e7e438368e16 289
Pokitto 46:e7e438368e16 290 write_command(0x56);
Pokitto 46:e7e438368e16 291 write_data(0x0703);
Pokitto 46:e7e438368e16 292
Pokitto 46:e7e438368e16 293 write_command(0x57);
Pokitto 46:e7e438368e16 294 write_data(0x0507);
Pokitto 46:e7e438368e16 295
Pokitto 46:e7e438368e16 296 write_command(0x58);
Pokitto 46:e7e438368e16 297 write_data(0x1021);
Pokitto 46:e7e438368e16 298
Pokitto 46:e7e438368e16 299 write_command(0x59);
Pokitto 46:e7e438368e16 300 write_data(0x0703);
Pokitto 46:e7e438368e16 301
Pokitto 46:e7e438368e16 302 write_command(0xB0);
Pokitto 46:e7e438368e16 303 write_data(0x2501);
Pokitto 46:e7e438368e16 304
Pokitto 46:e7e438368e16 305 write_command(0xFF);
Pokitto 46:e7e438368e16 306 write_data(0x0000);
Pokitto 46:e7e438368e16 307
Pokitto 46:e7e438368e16 308 write_command(0x07);
Pokitto 46:e7e438368e16 309 write_data(0x1017);
Pokitto 46:e7e438368e16 310 wait_ms(200);
Pokitto 46:e7e438368e16 311 write_command(0x22);
Pokitto 46:e7e438368e16 312
Pokitto 46:e7e438368e16 313 lcdClear();
Pokitto 46:e7e438368e16 314 }
Pokitto 46:e7e438368e16 315
Pokitto 46:e7e438368e16 316 void Pokitto::lcdSleep(void){
Pokitto 46:e7e438368e16 317 write_command(0xFF);
Pokitto 46:e7e438368e16 318 write_data(0x0000);
Pokitto 46:e7e438368e16 319
Pokitto 46:e7e438368e16 320 write_command(0x07);
Pokitto 46:e7e438368e16 321 write_data(0x0000);
Pokitto 46:e7e438368e16 322 wait_ms(50);
Pokitto 46:e7e438368e16 323 write_command(0x10);// Enter Standby mode
Pokitto 46:e7e438368e16 324 write_data(0x0003);
Pokitto 46:e7e438368e16 325 wait_ms(200);
Pokitto 46:e7e438368e16 326
Pokitto 46:e7e438368e16 327 }
Pokitto 46:e7e438368e16 328
Pokitto 46:e7e438368e16 329 void Pokitto::lcdWakeUp (void){
Pokitto 46:e7e438368e16 330
Pokitto 46:e7e438368e16 331 wait_ms(200);
Pokitto 46:e7e438368e16 332 write_command(0xFF);
Pokitto 46:e7e438368e16 333 write_data(0x0000);
Pokitto 46:e7e438368e16 334
Pokitto 46:e7e438368e16 335 write_command(0x10);// Exit Sleep/ Standby mode
Pokitto 46:e7e438368e16 336 write_data(0x0000);
Pokitto 46:e7e438368e16 337 wait_ms(50);
Pokitto 46:e7e438368e16 338 write_command(0x07);
Pokitto 46:e7e438368e16 339 write_data(0x0117);
Pokitto 46:e7e438368e16 340 wait_ms(200);
Pokitto 46:e7e438368e16 341 }
Pokitto 46:e7e438368e16 342
Pokitto 46:e7e438368e16 343 void Pokitto::lcdFillSurface(uint16_t c) {
Pokitto 46:e7e438368e16 344 uint32_t i;
Pokitto 46:e7e438368e16 345 write_command(0x20); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 346 write_data(0x0000); // 0
Pokitto 46:e7e438368e16 347 write_command(0x21); // Vertical DRAM Address
Pokitto 46:e7e438368e16 348 write_data(0);
Pokitto 46:e7e438368e16 349 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 350 setup_data_16(c);
Pokitto 46:e7e438368e16 351 CLR_CS_SET_CD_RD_WR;
Pokitto 46:e7e438368e16 352 for(i=0;i<220*176;i++)
Pokitto 46:e7e438368e16 353 {
Pokitto 46:e7e438368e16 354 CLR_WR;
Pokitto 46:e7e438368e16 355 SET_WR;
Pokitto 46:e7e438368e16 356 }
Pokitto 46:e7e438368e16 357 }
Pokitto 46:e7e438368e16 358
Pokitto 46:e7e438368e16 359 void Pokitto::lcdClear() {
Pokitto 46:e7e438368e16 360 uint32_t i;
Pokitto 46:e7e438368e16 361 write_command(0x20); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 362 write_data(0x0000); // 0
Pokitto 46:e7e438368e16 363 write_command(0x21); // Vertical DRAM Address
Pokitto 46:e7e438368e16 364 write_data(0);
Pokitto 46:e7e438368e16 365 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 366 setup_data_16(0x0000);
Pokitto 46:e7e438368e16 367 CLR_CS_SET_CD_RD_WR;
Pokitto 46:e7e438368e16 368 for(i=0;i<220*176;i++)
Pokitto 46:e7e438368e16 369 {
Pokitto 46:e7e438368e16 370 CLR_WR;
Pokitto 46:e7e438368e16 371 SET_WR;
Pokitto 46:e7e438368e16 372 }
Pokitto 46:e7e438368e16 373 }
Pokitto 46:e7e438368e16 374
Pokitto 46:e7e438368e16 375 void Pokitto::lcdPixel(int16_t x, int16_t y, uint16_t color) {
Pokitto 46:e7e438368e16 376 if ((x < 0) || (x >= POK_LCD_W) || (y < 0) || (y >= POK_LCD_H))
Pokitto 46:e7e438368e16 377 return;
Pokitto 46:e7e438368e16 378 write_command(0x20); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 379 write_data(y); // 0
Pokitto 46:e7e438368e16 380 write_command(0x21); // Vertical DRAM Address
Pokitto 46:e7e438368e16 381 write_data(x);
Pokitto 46:e7e438368e16 382 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 383 CLR_CS_SET_CD_RD_WR;
Pokitto 46:e7e438368e16 384 setup_data_16(color);
Pokitto 46:e7e438368e16 385 CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 386 }
Pokitto 46:e7e438368e16 387
Pokitto 46:e7e438368e16 388 void Pokitto::setWindow(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) {
Pokitto 46:e7e438368e16 389 write_command(0x37); write_data(x1);
Pokitto 46:e7e438368e16 390 write_command(0x36); write_data(x2);
Pokitto 46:e7e438368e16 391 write_command(0x39); write_data(y1);
Pokitto 46:e7e438368e16 392 write_command(0x38); write_data(y2);
Pokitto 46:e7e438368e16 393 write_command(0x20); write_data(x1);
Pokitto 46:e7e438368e16 394 write_command(0x21); write_data(y1);
Pokitto 46:e7e438368e16 395 }
Pokitto 46:e7e438368e16 396
Pokitto 46:e7e438368e16 397 void Pokitto::lcdTile(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t* gfx){
Pokitto 46:e7e438368e16 398 int width=x1-x0;
Pokitto 46:e7e438368e16 399 int height=y1-y0;
Pokitto 46:e7e438368e16 400 if (x0 > POK_LCD_W) return;
Pokitto 46:e7e438368e16 401 if (y0 > POK_LCD_H) return;
Pokitto 46:e7e438368e16 402 if (x0 < 0) x0=0;
Pokitto 46:e7e438368e16 403 if (y0 < 0) y0=0;
Pokitto 46:e7e438368e16 404
Pokitto 46:e7e438368e16 405 setWindow(y0, x0, y1-1, x1-1);
Pokitto 46:e7e438368e16 406 write_command(0x22);
Pokitto 46:e7e438368e16 407
Pokitto 46:e7e438368e16 408 for (int x=0; x<=width*height-1;x++) {
Pokitto 46:e7e438368e16 409 write_data(gfx[x]);
Pokitto 46:e7e438368e16 410 }
Pokitto 46:e7e438368e16 411 setWindow(0, 0, 175, 219);
Pokitto 46:e7e438368e16 412 }
Pokitto 46:e7e438368e16 413
Pokitto 46:e7e438368e16 414
Pokitto 46:e7e438368e16 415 void Pokitto::lcdRectangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color) {
Pokitto 46:e7e438368e16 416 int16_t temp;
Pokitto 46:e7e438368e16 417 if (x0>x1) {temp=x0;x0=x1;x1=temp;}
Pokitto 46:e7e438368e16 418 if (y0>y1) {temp=y0;y0=y1;y1=temp;}
Pokitto 46:e7e438368e16 419 if (x0 > POK_LCD_W) return;
Pokitto 46:e7e438368e16 420 if (y0 > POK_LCD_H) return;
Pokitto 46:e7e438368e16 421 if (x1 > POK_LCD_W) x1=POK_LCD_W;
Pokitto 46:e7e438368e16 422 if (y1 > POK_LCD_H) y1=POK_LCD_H;
Pokitto 46:e7e438368e16 423 if (x0 < 0) x0=0;
Pokitto 46:e7e438368e16 424 if (y0 < 0) y0=0;
Pokitto 46:e7e438368e16 425
Pokitto 46:e7e438368e16 426 int16_t x,y;
Pokitto 46:e7e438368e16 427 for (x=x0; x<=x1;x++) {
Pokitto 46:e7e438368e16 428 write_command(0x20); // Horizontal DRAM Address (=y on pokitto screen)
Pokitto 46:e7e438368e16 429 write_data(y0);
Pokitto 46:e7e438368e16 430 write_command(0x21); // Vertical DRAM Address (=x on pokitto screen)
Pokitto 46:e7e438368e16 431 write_data(x);
Pokitto 46:e7e438368e16 432 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 433
Pokitto 46:e7e438368e16 434 CLR_CS_SET_CD_RD_WR; // go to vram write mode
Pokitto 46:e7e438368e16 435
Pokitto 46:e7e438368e16 436
Pokitto 46:e7e438368e16 437 for (y=y0; y<y1;y++) {
Pokitto 46:e7e438368e16 438 setup_data_16(color); // setup the data (flat color = no change between pixels)
Pokitto 46:e7e438368e16 439 CLR_WR;SET_WR; //CLR_WR;SET_WR;//toggle writeline, pokitto screen writes a column up to down
Pokitto 46:e7e438368e16 440 }
Pokitto 46:e7e438368e16 441 }
Pokitto 46:e7e438368e16 442 }
Pokitto 46:e7e438368e16 443
Pokitto 46:e7e438368e16 444 /***
Pokitto 46:e7e438368e16 445 * Update the screen buffer of 220x176 pixels, 4 colors to LCD.
Pokitto 46:e7e438368e16 446 *
Pokitto 46:e7e438368e16 447 * The update rect is used for drawing only part of the screen buffer to LCD. Because of speed optimizations, the
Pokitto 46:e7e438368e16 448 * x, y, and width of the update rect must be dividable by 4 pixels, and the height must be dividable by 8 pixels.
Pokitto 46:e7e438368e16 449 * Note: The update rect is currently used for 220x176, 4 colors, screen mode only.
Pokitto 46:e7e438368e16 450 * @param scrbuf The screen buffer.
Pokitto 46:e7e438368e16 451 * @param updRectX The update rect.
Pokitto 46:e7e438368e16 452 * @param updRectY The update rect.
Pokitto 46:e7e438368e16 453 * @param updRectW The update rect.
Pokitto 46:e7e438368e16 454 * @param updRectH The update rect.
Pokitto 46:e7e438368e16 455 * @param paletteptr The screen palette.
Pokitto 46:e7e438368e16 456 */
Pokitto 46:e7e438368e16 457 void Pokitto::lcdRefreshMode1(uint8_t * scrbuf, uint8_t updRectX, uint8_t updRectY, uint8_t updRectW, uint8_t updRectH, uint16_t* paletteptr) {
Pokitto 46:e7e438368e16 458
Pokitto 46:e7e438368e16 459 uint16_t x,y,xptr;
Pokitto 46:e7e438368e16 460 uint16_t scanline[4][176]; // read 4 half-nibbles = 4 pixels at a time
Pokitto 46:e7e438368e16 461 uint8_t *d, yoffset=0;
Pokitto 46:e7e438368e16 462
Pokitto 46:e7e438368e16 463 // If not the full screen is updated, check the validity of the update rect.
Pokitto 46:e7e438368e16 464 if ( updRectX != 0 || updRectY != 0 ||updRectW != LCDWIDTH ||updRectH != LCDHEIGHT ) {
Pokitto 46:e7e438368e16 465 uint8_t org_screenx = updRectX;
Pokitto 46:e7e438368e16 466 updRectX &= 0xfc; // Make the value dividable by 4.
Pokitto 46:e7e438368e16 467 updRectW += org_screenx - updRectX;
Pokitto 46:e7e438368e16 468 updRectW = (updRectW + 3) & 0xfc; // Make the value dividable by 4, round up.
Pokitto 46:e7e438368e16 469
Pokitto 46:e7e438368e16 470 uint8_t org_screeny = updRectY;
Pokitto 46:e7e438368e16 471 updRectY &= 0xfc; // Make the value dividable by 4.
Pokitto 46:e7e438368e16 472 updRectH += org_screeny - updRectY;
Pokitto 46:e7e438368e16 473 updRectH = (updRectH + 7) & 0xf8; // Make the value dividable by 8 (because of loop unroll optimization), round up.
Pokitto 46:e7e438368e16 474 }
Pokitto 46:e7e438368e16 475
Pokitto 46:e7e438368e16 476
Pokitto 46:e7e438368e16 477 #ifdef PROJ_SHOW_FPS_COUNTER
Pokitto 46:e7e438368e16 478 xptr = 8;
Pokitto 46:e7e438368e16 479 setDRAMptr(8, 0);
Pokitto 46:e7e438368e16 480 #else
Pokitto 46:e7e438368e16 481 xptr = 0;
Pokitto 46:e7e438368e16 482 setDRAMptr(0, 0);
Pokitto 46:e7e438368e16 483 #endif
Pokitto 46:e7e438368e16 484
Pokitto 46:e7e438368e16 485 for (x=updRectX; x<updRectX+updRectW; x+=4) {
Pokitto 46:e7e438368e16 486 d = scrbuf+(x>>2);// point to beginning of line in data
Pokitto 46:e7e438368e16 487
Pokitto 46:e7e438368e16 488 /** find colours in one scanline **/
Pokitto 46:e7e438368e16 489 uint8_t s=0;
Pokitto 46:e7e438368e16 490 d += (updRectY * 220/4);
Pokitto 46:e7e438368e16 491 for (y=updRectY; y<updRectY+updRectH; y++) {
Pokitto 46:e7e438368e16 492 uint8_t tdata = *d;
Pokitto 46:e7e438368e16 493 uint8_t t4 = tdata & 0x03; tdata >>= 2;// lowest half-nibble
Pokitto 46:e7e438368e16 494 uint8_t t3 = tdata & 0x03; tdata >>= 2;// second lowest half-nibble
Pokitto 46:e7e438368e16 495 uint8_t t2 = tdata & 0x03; tdata >>= 2;// second highest half-nibble
Pokitto 46:e7e438368e16 496 uint8_t t = tdata & 0x03;// highest half-nibble
Pokitto 46:e7e438368e16 497
Pokitto 46:e7e438368e16 498 /** put nibble values in the scanlines **/
Pokitto 46:e7e438368e16 499 scanline[0][y] = paletteptr[t];
Pokitto 46:e7e438368e16 500 scanline[1][y] = paletteptr[t2];
Pokitto 46:e7e438368e16 501 scanline[2][y] = paletteptr[t3];
Pokitto 46:e7e438368e16 502 scanline[3][y] = paletteptr[t4];
Pokitto 46:e7e438368e16 503
Pokitto 46:e7e438368e16 504 d += 220/4; // jump to read byte directly below in screenbuffer
Pokitto 46:e7e438368e16 505 }
Pokitto 46:e7e438368e16 506
Pokitto 46:e7e438368e16 507 #ifdef PROJ_SHOW_FPS_COUNTER
Pokitto 46:e7e438368e16 508 if (x>=8 ) {
Pokitto 46:e7e438368e16 509 #else
Pokitto 46:e7e438368e16 510 {
Pokitto 46:e7e438368e16 511
Pokitto 46:e7e438368e16 512 #endif
Pokitto 46:e7e438368e16 513
Pokitto 46:e7e438368e16 514 // Draw 8 vertical pixels at a time for performance reasons
Pokitto 46:e7e438368e16 515 setDRAMptr(x, updRectY);
Pokitto 46:e7e438368e16 516 for (uint8_t s=updRectY; s<updRectY+updRectH;) {
Pokitto 46:e7e438368e16 517 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 518 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 519 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 520 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 521 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 522 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 523 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 524 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 525 }
Pokitto 46:e7e438368e16 526 setDRAMptr(x+1, updRectY);
Pokitto 46:e7e438368e16 527 for (uint8_t s=updRectY; s<updRectY+updRectH;) {
Pokitto 46:e7e438368e16 528 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 529 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 530 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 531 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 532 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 533 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 534 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 535 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 536 }
Pokitto 46:e7e438368e16 537 setDRAMptr(x+2, updRectY);
Pokitto 46:e7e438368e16 538 for (uint8_t s=updRectY; s<updRectY+updRectH;) {
Pokitto 46:e7e438368e16 539 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 540 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 541 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 542 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 543 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 544 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 545 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 546 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 547 }
Pokitto 46:e7e438368e16 548 setDRAMptr(x+3, updRectY);
Pokitto 46:e7e438368e16 549 for (uint8_t s=updRectY; s<updRectY+updRectH;) {
Pokitto 46:e7e438368e16 550 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 551 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 552 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 553 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 554 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 555 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 556 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 557 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 558 }
Pokitto 46:e7e438368e16 559 }
Pokitto 46:e7e438368e16 560 }
Pokitto 46:e7e438368e16 561
Pokitto 46:e7e438368e16 562 #ifdef POK_SIM
Pokitto 46:e7e438368e16 563 simulator.refreshDisplay();
Pokitto 46:e7e438368e16 564 #endif
Pokitto 46:e7e438368e16 565 }
Pokitto 46:e7e438368e16 566
Pokitto 46:e7e438368e16 567 // Copy sprite pixels to the scanline
Pokitto 46:e7e438368e16 568 #define SPRITE_2BPP_INNER_LOOP(n)\
Pokitto 46:e7e438368e16 569 \
Pokitto 46:e7e438368e16 570 /* If the sprite is enabled and contained in this vertical scanline, copy 4 pixels. */\
Pokitto 46:e7e438368e16 571 if (sprScanlineAddr[(n)] &&\
Pokitto 46:e7e438368e16 572 y >= sprites[(n)].y && y < sprites[(n)].y + sprites[(n)].h ) {\
Pokitto 46:e7e438368e16 573 \
Pokitto 46:e7e438368e16 574 int16_t sprx = sprites[(n)].x;\
Pokitto 46:e7e438368e16 575 uint16_t s_data16b = 0; /* sprite data, 2 bytes */\
Pokitto 46:e7e438368e16 576 \
Pokitto 46:e7e438368e16 577 /* Get pixel block, 4 or 8 pixels horizontally. Use the predefined bitshift mode. */\
Pokitto 46:e7e438368e16 578 /* Note:it is cheapest to compare to 0 first. */\
Pokitto 46:e7e438368e16 579 if (sprScanlineBitshiftMode[(n)] == BITSHIFT_MODE_MIDDLE_BYTE) {\
Pokitto 46:e7e438368e16 580 s_data16b = *(sprScanlineAddr[(n)]);\
Pokitto 46:e7e438368e16 581 uint16_t leftByte = *(sprScanlineAddr[(n)]-1);\
Pokitto 46:e7e438368e16 582 s_data16b = (leftByte << 8) | s_data16b;\
Pokitto 46:e7e438368e16 583 }\
Pokitto 46:e7e438368e16 584 else if (sprScanlineBitshiftMode[(n)] == BITSHIFT_MODE_FIRST_BYTE) {\
Pokitto 46:e7e438368e16 585 s_data16b = *(sprScanlineAddr[(n)]);\
Pokitto 46:e7e438368e16 586 }\
Pokitto 46:e7e438368e16 587 else { /* BITSHIFT_MODE_LAST_BYTE */\
Pokitto 46:e7e438368e16 588 uint16_t leftByte = *(sprScanlineAddr[(n)]-1);\
Pokitto 46:e7e438368e16 589 s_data16b = (leftByte << 8) | s_data16b;\
Pokitto 46:e7e438368e16 590 }\
Pokitto 46:e7e438368e16 591 \
Pokitto 46:e7e438368e16 592 /* Shift sprite pixels according to sprite x. After shifting we have only 4 pixels. */\
Pokitto 46:e7e438368e16 593 uint8_t shiftRight = (sprx&0x3) << 1;\
Pokitto 46:e7e438368e16 594 s_data16b = (s_data16b >> shiftRight);\
Pokitto 46:e7e438368e16 595 \
Pokitto 46:e7e438368e16 596 /* Get individual pixels */\
Pokitto 46:e7e438368e16 597 uint8_t s_t4 = s_data16b & 0x03; s_data16b >>= 2; /* lowest half-nibble */\
Pokitto 46:e7e438368e16 598 uint8_t s_t3 = s_data16b & 0x03; s_data16b >>= 2; /* second lowest half-nibble */\
Pokitto 46:e7e438368e16 599 uint8_t s_t2 = s_data16b & 0x03; s_data16b >>= 2; /* second highest half-nibble */\
Pokitto 46:e7e438368e16 600 uint8_t s_t1 = s_data16b & 0x03; /* highest half-nibble */\
Pokitto 46:e7e438368e16 601 \
Pokitto 46:e7e438368e16 602 /* Store pixels as 16-bit colors from the palette */\
Pokitto 46:e7e438368e16 603 if (s_t4 != transparentColor) p4 = sprites[(n)].palette[s_t4];\
Pokitto 46:e7e438368e16 604 if (s_t3 != transparentColor) p3 = sprites[(n)].palette[s_t3];\
Pokitto 46:e7e438368e16 605 if (s_t2 != transparentColor) p2 = sprites[(n)].palette[s_t2];\
Pokitto 46:e7e438368e16 606 if (s_t1 != transparentColor) p = sprites[(n)].palette[s_t1];\
Pokitto 46:e7e438368e16 607 \
Pokitto 46:e7e438368e16 608 /* Advance scanline address */\
Pokitto 46:e7e438368e16 609 sprScanlineAddr[(n)] += (sprites[(n)].w >> 2);\
Pokitto 46:e7e438368e16 610 }
Pokitto 46:e7e438368e16 611
Pokitto 46:e7e438368e16 612 // Loop unrolling macros
Pokitto 46:e7e438368e16 613 #define UNROLLED_LOOP_1() SPRITE_2BPP_INNER_LOOP(0)
Pokitto 46:e7e438368e16 614 #define UNROLLED_LOOP_2() UNROLLED_LOOP_1() SPRITE_2BPP_INNER_LOOP(1)
Pokitto 46:e7e438368e16 615 #define UNROLLED_LOOP_3() UNROLLED_LOOP_2() SPRITE_2BPP_INNER_LOOP(2)
Pokitto 46:e7e438368e16 616 #define UNROLLED_LOOP_4() UNROLLED_LOOP_3() SPRITE_2BPP_INNER_LOOP(3)
Pokitto 46:e7e438368e16 617 #define UNROLLED_LOOP_5() UNROLLED_LOOP_4() SPRITE_2BPP_INNER_LOOP(4)
Pokitto 46:e7e438368e16 618 #define UNROLLED_LOOP_6() UNROLLED_LOOP_5() SPRITE_2BPP_INNER_LOOP(5)
Pokitto 46:e7e438368e16 619 #define UNROLLED_LOOP_7() UNROLLED_LOOP_6() SPRITE_2BPP_INNER_LOOP(6)
Pokitto 46:e7e438368e16 620 #define UNROLLED_LOOP_8() UNROLLED_LOOP_7() SPRITE_2BPP_INNER_LOOP(7)
Pokitto 46:e7e438368e16 621 #define UNROLLED_LOOP_9() UNROLLED_LOOP_8() SPRITE_2BPP_INNER_LOOP(8)
Pokitto 46:e7e438368e16 622 #define UNROLLED_LOOP_10() UNROLLED_LOOP_9() SPRITE_2BPP_INNER_LOOP(9)
Pokitto 46:e7e438368e16 623 #define UNROLLED_LOOP_11() UNROLLED_LOOP_10() SPRITE_2BPP_INNER_LOOP(10)
Pokitto 46:e7e438368e16 624 #define UNROLLED_LOOP_12() UNROLLED_LOOP_11() SPRITE_2BPP_INNER_LOOP(11)
Pokitto 46:e7e438368e16 625 #define UNROLLED_LOOP_13() UNROLLED_LOOP_12() SPRITE_2BPP_INNER_LOOP(12)
Pokitto 46:e7e438368e16 626 #define UNROLLED_LOOP_14() UNROLLED_LOOP_13() SPRITE_2BPP_INNER_LOOP(13)
Pokitto 46:e7e438368e16 627 #define UNROLLED_LOOP_15() UNROLLED_LOOP_14() SPRITE_2BPP_INNER_LOOP(14)
Pokitto 46:e7e438368e16 628 #define UNROLLED_LOOP_16() UNROLLED_LOOP_15() SPRITE_2BPP_INNER_LOOP(15)
Pokitto 46:e7e438368e16 629 #define UNROLLED_LOOP_N_(n) UNROLLED_LOOP_##n()
Pokitto 46:e7e438368e16 630 #define UNROLLED_LOOP_N(n) UNROLLED_LOOP_N_(n)
Pokitto 46:e7e438368e16 631
Pokitto 46:e7e438368e16 632 /***
Pokitto 46:e7e438368e16 633 * Update the screen buffer of 220x176 pixels, 4 colors and free size 4 color sprites to LCD.
Pokitto 46:e7e438368e16 634 *
Pokitto 46:e7e438368e16 635 * The update rect is used for drawing only part of the screen buffer to LCD. Because of speed optimizations, the
Pokitto 46:e7e438368e16 636 * x, y, and width of the update rect must be dividable by 4 pixels, and the height must be dividable by 8 pixels.
Pokitto 46:e7e438368e16 637 * Note: The update rect is currently used for 220x176, 4 colors, screen mode only.
Pokitto 46:e7e438368e16 638 * If drawSpritesOnly=true, only sprites are fully updated to LCD. However, the dirty rect of the screen buffer is
Pokitto 46:e7e438368e16 639 * drawn behind the sprite current and previous location.
Pokitto 46:e7e438368e16 640 * Note: Sprite is enabled if sprite.bitmapData is not NULL. Also all enabled sprites must be at the beginning of
Pokitto 46:e7e438368e16 641 * the sprites array. No gaps are allowed in the array.
Pokitto 46:e7e438368e16 642 * @param scrbuf The screen buffer.
Pokitto 46:e7e438368e16 643 * @param updRectX The update rect.
Pokitto 46:e7e438368e16 644 * @param updRectY The update rect.
Pokitto 46:e7e438368e16 645 * @param updRectW The update rect.
Pokitto 46:e7e438368e16 646 * @param updRectH The update rect.
Pokitto 46:e7e438368e16 647 * @param paletteptr The screen palette.
Pokitto 46:e7e438368e16 648 * @param sprites The sprite array.
Pokitto 46:e7e438368e16 649 * @param drawSpritesOnly True, if only sprites are drawn. False, if both sprites and the screen buffer are drawn.
Pokitto 46:e7e438368e16 650 */
Pokitto 46:e7e438368e16 651 void Pokitto::lcdRefreshMode1Spr(
Pokitto 46:e7e438368e16 652 uint8_t * scrbuf, uint8_t updRectX, uint8_t updRectY, uint8_t updRectW, uint8_t updRectH, uint16_t* paletteptr,
Pokitto 46:e7e438368e16 653 SpriteInfo* sprites, bool drawSpritesOnly) {
Pokitto 46:e7e438368e16 654
Pokitto 46:e7e438368e16 655 // In direct mode draw only sprites and their dirty rects. Return now if there are no sprites
Pokitto 46:e7e438368e16 656 if (drawSpritesOnly && (sprites == NULL || sprites[0].bitmapData == NULL))
Pokitto 46:e7e438368e16 657 return;
Pokitto 46:e7e438368e16 658
Pokitto 46:e7e438368e16 659 uint16_t x,y;
Pokitto 46:e7e438368e16 660 uint16_t scanline[4][176]; // read 4 half-nibbles (= 4 pixels) at a time
Pokitto 46:e7e438368e16 661 const uint8_t transparentColor = 0; // fixed palette index 0 for transparency
Pokitto 46:e7e438368e16 662
Pokitto 46:e7e438368e16 663 // If not the full screen is updated, check the validity of the update rect.
Pokitto 46:e7e438368e16 664 if ( updRectX != 0 || updRectY != 0 ||updRectW != LCDWIDTH ||updRectH != LCDHEIGHT ) {
Pokitto 46:e7e438368e16 665 uint8_t org_screenx = updRectX;
Pokitto 46:e7e438368e16 666 updRectX &= 0xfc; // Make the value dividable by 4.
Pokitto 46:e7e438368e16 667 updRectW += org_screenx - updRectX;
Pokitto 46:e7e438368e16 668 updRectW = (updRectW + 3) & 0xfc; // Make the value dividable by 4, round up.
Pokitto 46:e7e438368e16 669
Pokitto 46:e7e438368e16 670 uint8_t org_screeny = updRectY;
Pokitto 46:e7e438368e16 671 updRectY &= 0xfc; // Make the value dividable by 4.
Pokitto 46:e7e438368e16 672 updRectH += org_screeny - updRectY;
Pokitto 46:e7e438368e16 673 updRectH = (updRectH + 7) & 0xf8; // Make the value dividable by 8 (because of loop unroll optimization), round up.
Pokitto 46:e7e438368e16 674 }
Pokitto 46:e7e438368e16 675
Pokitto 46:e7e438368e16 676 // Calculate the current amount of sprites
Pokitto 46:e7e438368e16 677 // Note: Sprites must be taken into use from index 0 upwards, because the first sprite with bitmapData==NULL is considered as the last sprite
Pokitto 46:e7e438368e16 678 uint8_t spriteCount = 0;
Pokitto 46:e7e438368e16 679 if (sprites != NULL)
Pokitto 46:e7e438368e16 680 for (;sprites[spriteCount].bitmapData != NULL && spriteCount < SPRITE_COUNT; spriteCount++);
Pokitto 46:e7e438368e16 681
Pokitto 46:e7e438368e16 682 // If drawing the screen buffer, set the start pos to LCD commands only here.
Pokitto 46:e7e438368e16 683 #ifdef PROJ_SHOW_FPS_COUNTER
Pokitto 46:e7e438368e16 684 if (!drawSpritesOnly) setDRAMptr(8, 0);
Pokitto 46:e7e438368e16 685 #else
Pokitto 46:e7e438368e16 686 if (!drawSpritesOnly) setDRAMptr(0, 0);
Pokitto 46:e7e438368e16 687 #endif
Pokitto 46:e7e438368e16 688
Pokitto 46:e7e438368e16 689 //*** GO THROUGH EACH VERTICAL GROUP OF 4 SCANLINES.***
Pokitto 46:e7e438368e16 690
Pokitto 46:e7e438368e16 691 for (x=0; x<LCDWIDTH; x+=4) {
Pokitto 46:e7e438368e16 692
Pokitto 46:e7e438368e16 693 uint8_t *screenBufScanlineAddr = scrbuf + (x>>2);// point to beginning of line in data
Pokitto 46:e7e438368e16 694
Pokitto 46:e7e438368e16 695 /*Prepare scanline start address for sprites that are visible in this vertical scanline. Sprite width cannot exceed the screen width*/
Pokitto 46:e7e438368e16 696 uint8_t *sprScanlineAddr[SPRITE_COUNT]; // Sprite start address for the scanline
Pokitto 46:e7e438368e16 697 uint8_t sprScanlineBitshiftMode[SPRITE_COUNT]; // Sprite bitshift mode for the scanline
Pokitto 46:e7e438368e16 698 const uint8_t BITSHIFT_MODE_MIDDLE_BYTE = 0;
Pokitto 46:e7e438368e16 699 const uint8_t BITSHIFT_MODE_FIRST_BYTE = 1;
Pokitto 46:e7e438368e16 700 const uint8_t BITSHIFT_MODE_LAST_BYTE = 2;
Pokitto 46:e7e438368e16 701 uint8_t scanlineMinY = 255; // Init to uninitialized value. Do not draw by default.
Pokitto 46:e7e438368e16 702 uint8_t scanlineMaxY = 0; // Init to uninitialized value. Do not draw by default.
Pokitto 46:e7e438368e16 703
Pokitto 46:e7e438368e16 704 //*** CALCULATE DIRTY RECTS AND RESOLVE WHICH SPRITES BELONG TO THIS SCANLINE GROUP ***
Pokitto 46:e7e438368e16 705
Pokitto 46:e7e438368e16 706 if (sprites != NULL) {
Pokitto 46:e7e438368e16 707
Pokitto 46:e7e438368e16 708 // Check all the sprites for this scanline. That is used for handling the given update rect
Pokitto 46:e7e438368e16 709 // Note that the last round is when (sprindex == spriteCount). That is used to add the screen buffer
Pokitto 46:e7e438368e16 710 // update rect to the dirty rect.
Pokitto 46:e7e438368e16 711 for (int sprindex = 0; sprindex <= spriteCount; sprindex++) {
Pokitto 46:e7e438368e16 712
Pokitto 46:e7e438368e16 713 int16_t sprx, spry, sprOldX, sprOldY;
Pokitto 46:e7e438368e16 714 uint8_t sprw, sprh;
Pokitto 46:e7e438368e16 715 bool isCurrentSpriteOutOfScreen = false;
Pokitto 46:e7e438368e16 716 bool isOldSpriteOutOfScreen = false;
Pokitto 46:e7e438368e16 717
Pokitto 46:e7e438368e16 718 if (sprindex < spriteCount) {
Pokitto 46:e7e438368e16 719
Pokitto 46:e7e438368e16 720 sprx = sprites[sprindex].x;
Pokitto 46:e7e438368e16 721 spry = sprites[sprindex].y;
Pokitto 46:e7e438368e16 722 sprw = sprites[sprindex].w;
Pokitto 46:e7e438368e16 723 sprh = sprites[sprindex].h;
Pokitto 46:e7e438368e16 724 sprOldX = sprites[sprindex].oldx;
Pokitto 46:e7e438368e16 725 sprOldY = sprites[sprindex].oldy;
Pokitto 46:e7e438368e16 726 }
Pokitto 46:e7e438368e16 727
Pokitto 46:e7e438368e16 728 // Handle the screen buffer update rect after all sprites
Pokitto 46:e7e438368e16 729 else if(!drawSpritesOnly){
Pokitto 46:e7e438368e16 730
Pokitto 46:e7e438368e16 731 sprx = updRectX;
Pokitto 46:e7e438368e16 732 spry = updRectY;
Pokitto 46:e7e438368e16 733 sprw = updRectW;
Pokitto 46:e7e438368e16 734 sprh = updRectH;
Pokitto 46:e7e438368e16 735 sprOldX = updRectX;
Pokitto 46:e7e438368e16 736 sprOldY = updRectY;
Pokitto 46:e7e438368e16 737 isCurrentSpriteOutOfScreen = false;
Pokitto 46:e7e438368e16 738 isOldSpriteOutOfScreen = false;
Pokitto 46:e7e438368e16 739 }
Pokitto 46:e7e438368e16 740
Pokitto 46:e7e438368e16 741 // Check for out-of-screen
Pokitto 46:e7e438368e16 742 if (sprx >= LCDWIDTH || spry >= LCDHEIGHT)
Pokitto 46:e7e438368e16 743 isCurrentSpriteOutOfScreen = true;
Pokitto 46:e7e438368e16 744 if (sprOldX >= LCDWIDTH || sprOldY >= LCDHEIGHT)
Pokitto 46:e7e438368e16 745 isOldSpriteOutOfScreen = true;
Pokitto 46:e7e438368e16 746
Pokitto 46:e7e438368e16 747 // Skip if current and old sprites are out-of-screen
Pokitto 46:e7e438368e16 748 if (isCurrentSpriteOutOfScreen && isOldSpriteOutOfScreen)
Pokitto 46:e7e438368e16 749 continue;
Pokitto 46:e7e438368e16 750
Pokitto 46:e7e438368e16 751 // Detect the dirty rect x-span by combining the previous and current sprite position.
Pokitto 46:e7e438368e16 752 int16_t sprDirtyXMin = min(sprx, sprOldX);
Pokitto 46:e7e438368e16 753 int16_t sprDirtyXMax = max(sprx, sprOldX);
Pokitto 46:e7e438368e16 754 if (isCurrentSpriteOutOfScreen)
Pokitto 46:e7e438368e16 755 sprDirtyXMax = sprOldX;
Pokitto 46:e7e438368e16 756 if (isOldSpriteOutOfScreen)
Pokitto 46:e7e438368e16 757 sprDirtyXMax = sprx;
Pokitto 46:e7e438368e16 758
Pokitto 46:e7e438368e16 759 // Is current x inside the sprite combined dirty rect ?
Pokitto 46:e7e438368e16 760 int16_t sprDirtyXMaxEnd = sprDirtyXMax + sprw - 1 + 4; // Add 4 pixels to dirty rect width (needed?)
Pokitto 46:e7e438368e16 761 if (sprDirtyXMin <= x+3 && x <= sprDirtyXMaxEnd) {
Pokitto 46:e7e438368e16 762
Pokitto 46:e7e438368e16 763 // *** COMBINE DIRTY RECTS FOR THIS SCANLINE GROUP ***
Pokitto 46:e7e438368e16 764
Pokitto 46:e7e438368e16 765 // Dirty rect
Pokitto 46:e7e438368e16 766 int sprDirtyYMin = std::min(spry, sprOldY);
Pokitto 46:e7e438368e16 767 sprDirtyYMin = std::max((int)sprDirtyYMin, 0);
Pokitto 46:e7e438368e16 768 int sprDirtyYMax = std::max(spry, sprOldY);
Pokitto 46:e7e438368e16 769 if (isCurrentSpriteOutOfScreen)
Pokitto 46:e7e438368e16 770 sprDirtyYMax = sprOldY;
Pokitto 46:e7e438368e16 771 if (isOldSpriteOutOfScreen)
Pokitto 46:e7e438368e16 772 sprDirtyYMax = spry;
Pokitto 46:e7e438368e16 773 int sprDirtyYMaxEnd = sprDirtyYMax + sprh - 1;
Pokitto 46:e7e438368e16 774 sprDirtyYMaxEnd = std::min(sprDirtyYMaxEnd, LCDHEIGHT - 1); // Should use LCDHEIGHT instead of screenH? Same with other screen* ?
Pokitto 46:e7e438368e16 775
Pokitto 46:e7e438368e16 776 // Get the scanline min and max y values for drawing
Pokitto 46:e7e438368e16 777 if (sprDirtyYMin < scanlineMinY)
Pokitto 46:e7e438368e16 778 scanlineMinY = sprDirtyYMin;
Pokitto 46:e7e438368e16 779 if (sprDirtyYMaxEnd > scanlineMaxY)
Pokitto 46:e7e438368e16 780 scanlineMaxY = sprDirtyYMaxEnd;
Pokitto 46:e7e438368e16 781
Pokitto 46:e7e438368e16 782 // *** PREPARE SPRITE FOR DRAWING ***
Pokitto 46:e7e438368e16 783
Pokitto 46:e7e438368e16 784 // Check if the sprite should be active for this vertical scanline group.
Pokitto 46:e7e438368e16 785 if (sprindex < spriteCount && // not for update rect
Pokitto 46:e7e438368e16 786 !isCurrentSpriteOutOfScreen && //out-of-screen
Pokitto 46:e7e438368e16 787 sprx <= x+3 && x < sprx + sprw) { // note: cover group of 4 pixels of the scanline (x+3)
Pokitto 46:e7e438368e16 788
Pokitto 46:e7e438368e16 789 // Find the byte number in the sprite data
Pokitto 46:e7e438368e16 790 int16_t byteNum = ((x+3) - sprx)>>2;
Pokitto 46:e7e438368e16 791
Pokitto 46:e7e438368e16 792 // Get the start addres of the spite data in this scanline.
Pokitto 46:e7e438368e16 793 sprScanlineAddr[sprindex] = const_cast<uint8_t*>(sprites[sprindex].bitmapData + byteNum);
Pokitto 46:e7e438368e16 794
Pokitto 46:e7e438368e16 795 // If the sprite goes over the top, it must be clipped from the top.
Pokitto 46:e7e438368e16 796 if(spry < 0)
Pokitto 46:e7e438368e16 797 sprScanlineAddr[sprindex] += (-spry) * (sprw >> 2);
Pokitto 46:e7e438368e16 798
Pokitto 46:e7e438368e16 799 // Select the bitshift mode for the blit algorithm
Pokitto 46:e7e438368e16 800 if (byteNum == 0)
Pokitto 46:e7e438368e16 801 sprScanlineBitshiftMode[sprindex] = BITSHIFT_MODE_FIRST_BYTE;
Pokitto 46:e7e438368e16 802 else if (byteNum >= (sprw >> 2))
Pokitto 46:e7e438368e16 803 sprScanlineBitshiftMode[sprindex] = BITSHIFT_MODE_LAST_BYTE;
Pokitto 46:e7e438368e16 804 else
Pokitto 46:e7e438368e16 805 sprScanlineBitshiftMode[sprindex] = BITSHIFT_MODE_MIDDLE_BYTE;
Pokitto 46:e7e438368e16 806 }
Pokitto 46:e7e438368e16 807 else
Pokitto 46:e7e438368e16 808 sprScanlineAddr[sprindex] = NULL; // Deactive sprite for this scanline
Pokitto 46:e7e438368e16 809 }
Pokitto 46:e7e438368e16 810 else
Pokitto 46:e7e438368e16 811 sprScanlineAddr[sprindex] = NULL; // Deactive sprite for this scanline
Pokitto 46:e7e438368e16 812 }
Pokitto 46:e7e438368e16 813 }
Pokitto 46:e7e438368e16 814
Pokitto 46:e7e438368e16 815 // *** ADJUST THE SCANLINE GROUP HEIGHT ***
Pokitto 46:e7e438368e16 816
Pokitto 46:e7e438368e16 817 // The height must dividable by 8. That is needed because later we copy 8 pixels at a time to the LCD.
Pokitto 46:e7e438368e16 818 if (scanlineMaxY - scanlineMinY + 1 > 0) {
Pokitto 46:e7e438368e16 819 uint8_t scanlineH = scanlineMaxY - scanlineMinY + 1;
Pokitto 46:e7e438368e16 820 uint8_t addW = 8 - (scanlineH & 0x7);
Pokitto 46:e7e438368e16 821
Pokitto 46:e7e438368e16 822 // if height is not dividable by 8, make it be.
Pokitto 46:e7e438368e16 823 if (addW != 0) {
Pokitto 46:e7e438368e16 824 if (scanlineMinY > addW )
Pokitto 46:e7e438368e16 825 scanlineMinY -= addW;
Pokitto 46:e7e438368e16 826 else if( scanlineMaxY + addW < updRectY+updRectH)
Pokitto 46:e7e438368e16 827 scanlineMaxY += addW;
Pokitto 46:e7e438368e16 828 else {
Pokitto 46:e7e438368e16 829 // Draw full height scanline
Pokitto 46:e7e438368e16 830 scanlineMinY = updRectY;
Pokitto 46:e7e438368e16 831 scanlineMaxY = updRectY+updRectH-1;
Pokitto 46:e7e438368e16 832 }
Pokitto 46:e7e438368e16 833 }
Pokitto 46:e7e438368e16 834 }
Pokitto 46:e7e438368e16 835
Pokitto 46:e7e438368e16 836 // *** COMBINE THE SCANLINE GROUP OF THE SCREEN BUFFER AND ALL SPRITES ***
Pokitto 46:e7e438368e16 837
Pokitto 46:e7e438368e16 838 // Find colours in this group of 4 scanlines
Pokitto 46:e7e438368e16 839 screenBufScanlineAddr += (scanlineMinY * 220/4);
Pokitto 46:e7e438368e16 840 for (y=scanlineMinY; y<=scanlineMaxY; y++)
Pokitto 46:e7e438368e16 841 {
Pokitto 46:e7e438368e16 842 // get the screen buffer data first
Pokitto 46:e7e438368e16 843 uint8_t tdata = *screenBufScanlineAddr;
Pokitto 46:e7e438368e16 844 uint8_t t4 = tdata & 0x03; tdata >>= 2;// lowest half-nibble
Pokitto 46:e7e438368e16 845 uint8_t t3 = tdata & 0x03; tdata >>= 2;// second lowest half-nibble
Pokitto 46:e7e438368e16 846 uint8_t t2 = tdata & 0x03; tdata >>= 2;// second highest half-nibble
Pokitto 46:e7e438368e16 847 uint8_t t = tdata & 0x03;// highest half-nibble
Pokitto 46:e7e438368e16 848
Pokitto 46:e7e438368e16 849 // Convert to 16-bit colors in palette
Pokitto 46:e7e438368e16 850 uint16_t p = paletteptr[t];
Pokitto 46:e7e438368e16 851 uint16_t p2 = paletteptr[t2];
Pokitto 46:e7e438368e16 852 uint16_t p3 = paletteptr[t3];
Pokitto 46:e7e438368e16 853 uint16_t p4 = paletteptr[t4];
Pokitto 46:e7e438368e16 854
Pokitto 46:e7e438368e16 855 #if 0
Pokitto 46:e7e438368e16 856 // Dirty rect visual test
Pokitto 46:e7e438368e16 857 p = COLOR_BLUE >> (Core::frameCount % 5);
Pokitto 46:e7e438368e16 858 p2 = COLOR_BLUE >> (Core::frameCount % 5);
Pokitto 46:e7e438368e16 859 p3 = COLOR_BLUE >> (Core::frameCount % 5);
Pokitto 46:e7e438368e16 860 p4 = COLOR_BLUE >> (Core::frameCount % 5);
Pokitto 46:e7e438368e16 861 #endif
Pokitto 46:e7e438368e16 862
Pokitto 46:e7e438368e16 863 // Add active sprite pixels
Pokitto 46:e7e438368e16 864 if (sprites != NULL) {
Pokitto 46:e7e438368e16 865
Pokitto 46:e7e438368e16 866 // Use loop unrolling for speed optimization
Pokitto 46:e7e438368e16 867 UNROLLED_LOOP_N(SPRITE_COUNT)
Pokitto 46:e7e438368e16 868 }
Pokitto 46:e7e438368e16 869
Pokitto 46:e7e438368e16 870 // put the result nibble values in the scanline
Pokitto 46:e7e438368e16 871 scanline[0][y] = p;
Pokitto 46:e7e438368e16 872 scanline[1][y] = p2;
Pokitto 46:e7e438368e16 873 scanline[2][y] = p3;
Pokitto 46:e7e438368e16 874 scanline[3][y] = p4;
Pokitto 46:e7e438368e16 875
Pokitto 46:e7e438368e16 876 screenBufScanlineAddr += 220>>2; // jump to read byte directly below in screenbuffer
Pokitto 46:e7e438368e16 877 }
Pokitto 46:e7e438368e16 878
Pokitto 46:e7e438368e16 879 // *** DRAW THE SCANLINE GROUP TO LCD
Pokitto 46:e7e438368e16 880
Pokitto 46:e7e438368e16 881 #ifdef PROJ_SHOW_FPS_COUNTER
Pokitto 46:e7e438368e16 882 if (x>=8 && scanlineMaxY - scanlineMinY +1 > 0) {
Pokitto 46:e7e438368e16 883 #else
Pokitto 46:e7e438368e16 884 if (scanlineMaxY - scanlineMinY +1 > 0) {
Pokitto 46:e7e438368e16 885 #endif
Pokitto 46:e7e438368e16 886 // Draw 8 vertical pixels at a time for performance reasons
Pokitto 46:e7e438368e16 887
Pokitto 46:e7e438368e16 888 setDRAMptr(x, scanlineMinY);
Pokitto 46:e7e438368e16 889 for (uint8_t s=scanlineMinY;s<=scanlineMaxY;) {
Pokitto 46:e7e438368e16 890 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 891 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 892 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 893 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 894 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 895 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 896 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 897 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 898 }
Pokitto 46:e7e438368e16 899
Pokitto 46:e7e438368e16 900 setDRAMptr(x+1, scanlineMinY);
Pokitto 46:e7e438368e16 901 for (uint8_t s=scanlineMinY;s<=scanlineMaxY;) {
Pokitto 46:e7e438368e16 902 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 903 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 904 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 905 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 906 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 907 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 908 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 909 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 910 }
Pokitto 46:e7e438368e16 911
Pokitto 46:e7e438368e16 912 setDRAMptr(x+2, scanlineMinY);
Pokitto 46:e7e438368e16 913 for (uint8_t s=scanlineMinY;s<=scanlineMaxY;) {
Pokitto 46:e7e438368e16 914 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 915 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 916 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 917 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 918 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 919 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 920 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 921 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 922 }
Pokitto 46:e7e438368e16 923
Pokitto 46:e7e438368e16 924 setDRAMptr(x+3, scanlineMinY);
Pokitto 46:e7e438368e16 925 for (uint8_t s=scanlineMinY;s<=scanlineMaxY;) {
Pokitto 46:e7e438368e16 926 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 927 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 928 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 929 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 930 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 931 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 932 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 933 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 934 }
Pokitto 46:e7e438368e16 935 }
Pokitto 46:e7e438368e16 936 }
Pokitto 46:e7e438368e16 937
Pokitto 46:e7e438368e16 938 // Update old x and y for the sprites
Pokitto 46:e7e438368e16 939 if (sprites != NULL) {
Pokitto 46:e7e438368e16 940 for (int sprindex = 0; sprindex < spriteCount; sprindex++) {
Pokitto 46:e7e438368e16 941 sprites[sprindex].oldx = sprites[sprindex].x;
Pokitto 46:e7e438368e16 942 sprites[sprindex].oldy = sprites[sprindex].y;
Pokitto 46:e7e438368e16 943 }
Pokitto 46:e7e438368e16 944 }
Pokitto 46:e7e438368e16 945
Pokitto 46:e7e438368e16 946 #ifdef POK_SIM
Pokitto 46:e7e438368e16 947 simulator.refreshDisplay();
Pokitto 46:e7e438368e16 948 #endif
Pokitto 46:e7e438368e16 949 }
Pokitto 46:e7e438368e16 950
Pokitto 46:e7e438368e16 951 void Pokitto::lcdRefreshMode2(uint8_t * scrbuf, uint16_t* paletteptr) {
Pokitto 46:e7e438368e16 952 uint16_t x,y;
Pokitto 46:e7e438368e16 953 uint16_t scanline[2][88]; // read two nibbles = pixels at a time
Pokitto 46:e7e438368e16 954 uint8_t *d;
Pokitto 46:e7e438368e16 955
Pokitto 46:e7e438368e16 956 write_command(0x20); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 957 write_data(0); // 0
Pokitto 46:e7e438368e16 958 write_command(0x21); // Vertical DRAM Address
Pokitto 46:e7e438368e16 959 write_data(0);
Pokitto 46:e7e438368e16 960 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 961 CLR_CS_SET_CD_RD_WR;
Pokitto 46:e7e438368e16 962
Pokitto 46:e7e438368e16 963 for(x=0;x<110;x+=2)
Pokitto 46:e7e438368e16 964 {
Pokitto 46:e7e438368e16 965 d = scrbuf+(x>>1);// point to beginning of line in data
Pokitto 46:e7e438368e16 966 /** find colours in one scanline **/
Pokitto 46:e7e438368e16 967 uint8_t s=0;
Pokitto 46:e7e438368e16 968 for(y=0;y<88;y++)
Pokitto 46:e7e438368e16 969 {
Pokitto 46:e7e438368e16 970 uint8_t t = *d >> 4; // higher nibble
Pokitto 46:e7e438368e16 971 uint8_t t2 = *d & 0xF; // lower nibble
Pokitto 46:e7e438368e16 972 /** higher nibble = left pixel in pixel pair **/
Pokitto 46:e7e438368e16 973 scanline[0][s] = paletteptr[t];
Pokitto 46:e7e438368e16 974 scanline[1][s++] = paletteptr[t2];
Pokitto 46:e7e438368e16 975 /** testing only **/
Pokitto 46:e7e438368e16 976 //scanline[0][s] = 0xFFFF*(s&1);
Pokitto 46:e7e438368e16 977 //scanline[1][s] = 0xFFFF*(!(s&1));
Pokitto 46:e7e438368e16 978 //s++;
Pokitto 46:e7e438368e16 979 /** until here **/
Pokitto 46:e7e438368e16 980 d+=110/2; // jump to read byte directly below in screenbuffer
Pokitto 46:e7e438368e16 981 }
Pokitto 46:e7e438368e16 982 s=0;
Pokitto 46:e7e438368e16 983 /** draw scanlines **/
Pokitto 46:e7e438368e16 984 /** leftmost scanline twice**/
Pokitto 46:e7e438368e16 985
Pokitto 46:e7e438368e16 986 #ifdef PROJ_SHOW_FPS_COUNTER
Pokitto 46:e7e438368e16 987 if (x<4) continue;
Pokitto 46:e7e438368e16 988 setDRAMptr(x<<1, 0);
Pokitto 46:e7e438368e16 989 #endif
Pokitto 46:e7e438368e16 990
Pokitto 46:e7e438368e16 991 for (s=0;s<88;) {
Pokitto 46:e7e438368e16 992 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 993 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 994 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 995 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 996 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 997 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 998 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 999 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1000 }
Pokitto 46:e7e438368e16 1001
Pokitto 46:e7e438368e16 1002 for (s=0;s<88;) {
Pokitto 46:e7e438368e16 1003 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1004 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1005 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1006 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1007 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1008 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1009 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1010 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1011 }
Pokitto 46:e7e438368e16 1012 /** rightmost scanline twice**/
Pokitto 46:e7e438368e16 1013 //setDRAMptr(xptr++,yoffset);
Pokitto 46:e7e438368e16 1014 for (s=0;s<88;) {
Pokitto 46:e7e438368e16 1015 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1016 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1017 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1018 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1019 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1020 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1021 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1022 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1023 }
Pokitto 46:e7e438368e16 1024
Pokitto 46:e7e438368e16 1025 for (s=0;s<88;) {
Pokitto 46:e7e438368e16 1026 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1027 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1028 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1029 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1030 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1031 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1032 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1033 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1034 }
Pokitto 46:e7e438368e16 1035 }
Pokitto 46:e7e438368e16 1036 }
Pokitto 46:e7e438368e16 1037
Pokitto 46:e7e438368e16 1038 void Pokitto::lcdRefreshMode3(uint8_t * scrbuf, uint16_t* paletteptr) {
Pokitto 46:e7e438368e16 1039 uint16_t x,y;
Pokitto 46:e7e438368e16 1040 uint16_t scanline[2][176]; // read two nibbles = pixels at a time
Pokitto 46:e7e438368e16 1041 uint8_t *d;
Pokitto 46:e7e438368e16 1042
Pokitto 46:e7e438368e16 1043 write_command(0x20); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 1044 write_data(0); // 0
Pokitto 46:e7e438368e16 1045 write_command(0x21); // Vertical DRAM Address
Pokitto 46:e7e438368e16 1046 write_data(0);
Pokitto 46:e7e438368e16 1047 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 1048 CLR_CS_SET_CD_RD_WR;
Pokitto 46:e7e438368e16 1049
Pokitto 46:e7e438368e16 1050 for(x=0;x<220;x+=2)
Pokitto 46:e7e438368e16 1051 {
Pokitto 46:e7e438368e16 1052 d = scrbuf+(x>>1);// point to beginning of line in data
Pokitto 46:e7e438368e16 1053 /** find colours in one scanline **/
Pokitto 46:e7e438368e16 1054 uint8_t s=0;
Pokitto 46:e7e438368e16 1055 for(y=0;y<176;y++)
Pokitto 46:e7e438368e16 1056 {
Pokitto 46:e7e438368e16 1057 uint8_t t = *d >> 4; // higher nibble
Pokitto 46:e7e438368e16 1058 uint8_t t2 = *d & 0xF; // lower nibble
Pokitto 46:e7e438368e16 1059 /** higher nibble = left pixel in pixel pair **/
Pokitto 46:e7e438368e16 1060 scanline[0][s] = paletteptr[t];
Pokitto 46:e7e438368e16 1061 scanline[1][s++] = paletteptr[t2];
Pokitto 46:e7e438368e16 1062 /** testing only **/
Pokitto 46:e7e438368e16 1063 //scanline[0][s] = 0xFFFF*(s&1);
Pokitto 46:e7e438368e16 1064 //scanline[1][s] = 0xFFFF*(!(s&1));
Pokitto 46:e7e438368e16 1065 //s++;
Pokitto 46:e7e438368e16 1066 /** until here **/
Pokitto 46:e7e438368e16 1067 d+=220/2; // jump to read byte directly below in screenbuffer
Pokitto 46:e7e438368e16 1068 }
Pokitto 46:e7e438368e16 1069 s=0;
Pokitto 46:e7e438368e16 1070 /** draw scanlines **/
Pokitto 46:e7e438368e16 1071 /** leftmost scanline**/
Pokitto 46:e7e438368e16 1072
Pokitto 46:e7e438368e16 1073 #ifdef PROJ_SHOW_FPS_COUNTER
Pokitto 46:e7e438368e16 1074 if (x<8) continue;
Pokitto 46:e7e438368e16 1075 setDRAMptr(x, 0);
Pokitto 46:e7e438368e16 1076 #endif
Pokitto 46:e7e438368e16 1077
Pokitto 46:e7e438368e16 1078 for (s=0;s<176;) {
Pokitto 46:e7e438368e16 1079 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1080 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1081 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1082 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1083 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1084 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1085 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1086 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1087 }
Pokitto 46:e7e438368e16 1088
Pokitto 46:e7e438368e16 1089 /** rightmost scanline**/
Pokitto 46:e7e438368e16 1090 //setDRAMptr(xptr++,yoffset);
Pokitto 46:e7e438368e16 1091 for (s=0;s<176;) {
Pokitto 46:e7e438368e16 1092 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1093 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1094 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1095 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1096 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1097 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1098 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1099 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1100 }
Pokitto 46:e7e438368e16 1101 }
Pokitto 46:e7e438368e16 1102 }
Pokitto 46:e7e438368e16 1103
Pokitto 46:e7e438368e16 1104 void Pokitto::lcdRefreshGB(uint8_t * scrbuf, uint16_t* paletteptr) {
Pokitto 46:e7e438368e16 1105 uint16_t x,y;
Pokitto 46:e7e438368e16 1106 uint16_t scanline[48];
Pokitto 46:e7e438368e16 1107 uint8_t * d;
Pokitto 46:e7e438368e16 1108
Pokitto 46:e7e438368e16 1109 #if POK_STRETCH
Pokitto 46:e7e438368e16 1110 //uint16_t xptr = 8;
Pokitto 46:e7e438368e16 1111 #else
Pokitto 46:e7e438368e16 1112 //xptr = 26;
Pokitto 46:e7e438368e16 1113 #endif
Pokitto 46:e7e438368e16 1114
Pokitto 46:e7e438368e16 1115 write_command(0x20); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 1116 write_data(0); // 0
Pokitto 46:e7e438368e16 1117 write_command(0x21); // Vertical DRAM Address
Pokitto 46:e7e438368e16 1118 write_data(0);
Pokitto 46:e7e438368e16 1119 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 1120 CLR_CS_SET_CD_RD_WR;
Pokitto 46:e7e438368e16 1121
Pokitto 46:e7e438368e16 1122 /** draw border **/
Pokitto 46:e7e438368e16 1123 for (int s=0;s<5*176;) {
Pokitto 46:e7e438368e16 1124 setup_data_16(COLOR_BLACK);CLR_WR;SET_WR;s++;
Pokitto 46:e7e438368e16 1125 }
Pokitto 46:e7e438368e16 1126
Pokitto 46:e7e438368e16 1127 for(x=0;x<84;x++)
Pokitto 46:e7e438368e16 1128 {
Pokitto 46:e7e438368e16 1129
Pokitto 46:e7e438368e16 1130 d = scrbuf + x;// point to beginning of line in data
Pokitto 46:e7e438368e16 1131
Pokitto 46:e7e438368e16 1132 /** find colours in one scanline **/
Pokitto 46:e7e438368e16 1133 uint8_t s=0;
Pokitto 46:e7e438368e16 1134 for(y=0;y<6;y++)
Pokitto 46:e7e438368e16 1135 {
Pokitto 46:e7e438368e16 1136 uint8_t t = *d;
Pokitto 46:e7e438368e16 1137 #if POK_COLORDEPTH > 1
Pokitto 46:e7e438368e16 1138 uint8_t t2 = *(d+504);
Pokitto 46:e7e438368e16 1139 #endif
Pokitto 46:e7e438368e16 1140 #if POK_COLORDEPTH > 2
Pokitto 46:e7e438368e16 1141 uint8_t t3 = *(d+504+504);
Pokitto 46:e7e438368e16 1142 #endif
Pokitto 46:e7e438368e16 1143 #if POK_COLORDEPTH > 3
Pokitto 46:e7e438368e16 1144 uint8_t t4 = *(d+504+504+504);
Pokitto 46:e7e438368e16 1145 #endif
Pokitto 46:e7e438368e16 1146 uint8_t paletteindex = 0;
Pokitto 46:e7e438368e16 1147
Pokitto 46:e7e438368e16 1148 /** bit 1 **/
Pokitto 46:e7e438368e16 1149 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1150 paletteindex = (t & 0x1);
Pokitto 46:e7e438368e16 1151 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1152 paletteindex = ((t & 0x1)) | ((t2 & 0x01)<<1);
Pokitto 46:e7e438368e16 1153 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1154 paletteindex = (t & 0x1) | ((t2 & 0x1)<<1) | ((t3 & 0x1)<<2);
Pokitto 46:e7e438368e16 1155 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1156 paletteindex = (t & 0x1) | ((t2 & 0x1)<<1) | ((t3 & 0x1)<<2) | ((t4 & 0x1)<<3);
Pokitto 46:e7e438368e16 1157 #endif
Pokitto 46:e7e438368e16 1158 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1159
Pokitto 46:e7e438368e16 1160 /** bit 2 **/
Pokitto 46:e7e438368e16 1161 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1162 paletteindex = (t & 0x2)>>1;
Pokitto 46:e7e438368e16 1163 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1164 paletteindex = ((t & 0x2)>>1) | ((t2 & 0x02));
Pokitto 46:e7e438368e16 1165 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1166 paletteindex = ((t & 0x2)>>1) | ((t2 & 0x2)) | ((t3 & 0x2)<<1);
Pokitto 46:e7e438368e16 1167 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1168 paletteindex = ((t & 0x2)>>1) | ((t2 & 0x2)) | ((t3 & 0x2)<<1) | ((t4 & 0x2)<<2);
Pokitto 46:e7e438368e16 1169 #endif
Pokitto 46:e7e438368e16 1170 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1171
Pokitto 46:e7e438368e16 1172 /** bit 3 **/
Pokitto 46:e7e438368e16 1173 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1174 paletteindex = (t & 0x4)>>2;
Pokitto 46:e7e438368e16 1175 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1176 paletteindex = ((t & 4)>>2) | ((t2 & 0x04)>>1);
Pokitto 46:e7e438368e16 1177 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1178 paletteindex = ((t & 0x4)>>2) | ((t2 & 0x4)>>1) | (t3 & 0x4);
Pokitto 46:e7e438368e16 1179 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1180 paletteindex = ((t & 0x4)>>2) | ((t2 & 0x4)>>1) | (t3 & 0x4) | ((t4 & 0x4)<<1);
Pokitto 46:e7e438368e16 1181 #endif
Pokitto 46:e7e438368e16 1182 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1183
Pokitto 46:e7e438368e16 1184 /** bit 4 **/
Pokitto 46:e7e438368e16 1185 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1186 paletteindex = (t & 0x8)>>3;
Pokitto 46:e7e438368e16 1187 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1188 paletteindex = ((t & 0x8)>>3) | ((t2 & 0x08)>>2);
Pokitto 46:e7e438368e16 1189 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1190 paletteindex = ((t & 0x8)>>3) | ((t2 & 0x8)>>2) | ((t3 & 0x8)>>1);
Pokitto 46:e7e438368e16 1191 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1192 paletteindex = ((t & 0x8)>>3) | ((t2 & 0x8)>>2) | ((t3 & 0x8)>>1) | (t4 & 0x8);
Pokitto 46:e7e438368e16 1193 #endif
Pokitto 46:e7e438368e16 1194 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1195
Pokitto 46:e7e438368e16 1196 /** bit 5 **/
Pokitto 46:e7e438368e16 1197 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1198 paletteindex = (t & 0x10)>>4;
Pokitto 46:e7e438368e16 1199 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1200 paletteindex = ((t & 0x10)>>4) | ((t2 & 0x10)>>3);
Pokitto 46:e7e438368e16 1201 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1202 paletteindex = ((t & 0x10)>>4) | ((t2 & 0x10)>>3) | ((t3 & 0x10)>>2);
Pokitto 46:e7e438368e16 1203 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1204 paletteindex = ((t & 0x10)>>4) | ((t2 & 0x10)>>3) | ((t3 & 0x10)>>2) | ((t4 & 0x10)>>1);
Pokitto 46:e7e438368e16 1205 #endif
Pokitto 46:e7e438368e16 1206 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1207
Pokitto 46:e7e438368e16 1208 /** bit 6 **/
Pokitto 46:e7e438368e16 1209 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1210 paletteindex = (t & 0x20)>>5;
Pokitto 46:e7e438368e16 1211 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1212 paletteindex = ((t & 0x20)>>5) | ((t2 & 0x20)>>4);
Pokitto 46:e7e438368e16 1213 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1214 paletteindex = ((t & 0x20)>>5) | ((t2 & 0x20)>>4) | ((t3 & 0x20)>>3);
Pokitto 46:e7e438368e16 1215 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1216 paletteindex = ((t & 0x20)>>5) | ((t2 & 0x20)>>4) | ((t3 & 0x20)>>3) | ((t4 & 0x20)>>2);
Pokitto 46:e7e438368e16 1217 #endif
Pokitto 46:e7e438368e16 1218 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1219
Pokitto 46:e7e438368e16 1220 /** bit 7 **/
Pokitto 46:e7e438368e16 1221 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1222 paletteindex = (t & 0x40)>>6;
Pokitto 46:e7e438368e16 1223 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1224 paletteindex = ((t & 0x40)>>6) | ((t2 & 0x40)>>5);
Pokitto 46:e7e438368e16 1225 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1226 paletteindex = ((t & 0x40)>>6) | ((t2 & 0x40)>>5) | ((t3 & 0x40)>>4) ;
Pokitto 46:e7e438368e16 1227 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1228 paletteindex = ((t & 0x40)>>6) | ((t2 & 0x40)>>5) | ((t3 & 0x40)>>4) | ((t4 & 0x40)>>3);
Pokitto 46:e7e438368e16 1229 #endif
Pokitto 46:e7e438368e16 1230 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1231
Pokitto 46:e7e438368e16 1232 /** bit 8 **/
Pokitto 46:e7e438368e16 1233 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1234 paletteindex = (t & 0x80)>>7;
Pokitto 46:e7e438368e16 1235 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1236 paletteindex = ((t & 0x80)>>7) | ((t2 & 0x80)>>6);
Pokitto 46:e7e438368e16 1237 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1238 paletteindex = ((t & 0x80)>>7) | ((t2 & 0x80)>>6) | ((t3 & 0x80)>>5);
Pokitto 46:e7e438368e16 1239 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1240 paletteindex = ((t & 0x80)>>7) | ((t2 & 0x80)>>6) | ((t3 & 0x80)>>5) | ((t4 & 0x80)>>4);
Pokitto 46:e7e438368e16 1241 #endif
Pokitto 46:e7e438368e16 1242 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1243
Pokitto 46:e7e438368e16 1244 d+=84; // jump to byte directly below
Pokitto 46:e7e438368e16 1245 }
Pokitto 46:e7e438368e16 1246
Pokitto 46:e7e438368e16 1247
Pokitto 46:e7e438368e16 1248 /*write_command(0x20); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 1249 write_data(0x10); // 0
Pokitto 46:e7e438368e16 1250 write_command(0x21); // Vertical DRAM Address
Pokitto 46:e7e438368e16 1251 write_data(xptr++);
Pokitto 46:e7e438368e16 1252 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 1253 CLR_CS_SET_CD_RD_WR;*/
Pokitto 46:e7e438368e16 1254 /** draw border **/
Pokitto 46:e7e438368e16 1255 setup_data_16(COLOR_BLACK);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR; CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1256
Pokitto 46:e7e438368e16 1257 s=0;
Pokitto 46:e7e438368e16 1258
Pokitto 46:e7e438368e16 1259 /** draw scanlines **/
Pokitto 46:e7e438368e16 1260 for (s=0;s<48;) {
Pokitto 46:e7e438368e16 1261 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1262 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1263 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1264 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1265 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1266 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1267 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1268 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1269 }
Pokitto 46:e7e438368e16 1270 /** draw border **/
Pokitto 46:e7e438368e16 1271 setup_data_16(COLOR_BLACK);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR; CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1272
Pokitto 46:e7e438368e16 1273
Pokitto 46:e7e438368e16 1274 /*write_command(0x20); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 1275 write_data(0x10); // 0
Pokitto 46:e7e438368e16 1276 write_command(0x21); // Vertical DRAM Address
Pokitto 46:e7e438368e16 1277 write_data(xptr++);
Pokitto 46:e7e438368e16 1278 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 1279 CLR_CS_SET_CD_RD_WR;*/
Pokitto 46:e7e438368e16 1280 /** draw border **/
Pokitto 46:e7e438368e16 1281 setup_data_16(COLOR_BLACK);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR; CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1282
Pokitto 46:e7e438368e16 1283 for (s=0;s<48;) {
Pokitto 46:e7e438368e16 1284 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1285 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1286 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1287 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1288 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1289 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1290 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1291 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1292 }
Pokitto 46:e7e438368e16 1293
Pokitto 46:e7e438368e16 1294 /** draw border **/
Pokitto 46:e7e438368e16 1295 setup_data_16(COLOR_BLACK);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR; CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1296
Pokitto 46:e7e438368e16 1297
Pokitto 46:e7e438368e16 1298 #if POK_STRETCH
Pokitto 46:e7e438368e16 1299 //if (x>16 && x<68)
Pokitto 46:e7e438368e16 1300 if (x&2)// && x&2)
Pokitto 46:e7e438368e16 1301 {
Pokitto 46:e7e438368e16 1302 /*write_command(0x20); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 1303 write_data(0x10); // 0
Pokitto 46:e7e438368e16 1304 write_command(0x21); // Vertical DRAM Address
Pokitto 46:e7e438368e16 1305 write_data(xptr++);
Pokitto 46:e7e438368e16 1306 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 1307 CLR_CS_SET_CD_RD_WR;*/
Pokitto 46:e7e438368e16 1308 /** draw border **/
Pokitto 46:e7e438368e16 1309 setup_data_16(COLOR_BLACK);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR; CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1310
Pokitto 46:e7e438368e16 1311
Pokitto 46:e7e438368e16 1312 for (s=0;s<48;) {
Pokitto 46:e7e438368e16 1313 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1314 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1315 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1316 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1317 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1318 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1319 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1320 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1321 }
Pokitto 46:e7e438368e16 1322
Pokitto 46:e7e438368e16 1323 /** draw border **/
Pokitto 46:e7e438368e16 1324 setup_data_16(COLOR_BLACK);CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR; CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1325
Pokitto 46:e7e438368e16 1326 }
Pokitto 46:e7e438368e16 1327 #endif
Pokitto 46:e7e438368e16 1328 }
Pokitto 46:e7e438368e16 1329 /** draw border **/
Pokitto 46:e7e438368e16 1330 for (int s=0;s<5*176;) {
Pokitto 46:e7e438368e16 1331 setup_data_16(COLOR_BLACK);CLR_WR;SET_WR;s++;
Pokitto 46:e7e438368e16 1332 }
Pokitto 46:e7e438368e16 1333 }
Pokitto 46:e7e438368e16 1334
Pokitto 46:e7e438368e16 1335
Pokitto 46:e7e438368e16 1336 void Pokitto::lcdRefreshAB(uint8_t * scrbuf, uint16_t* paletteptr) {
Pokitto 46:e7e438368e16 1337 uint16_t x,y;
Pokitto 46:e7e438368e16 1338 uint16_t scanline[64];
Pokitto 46:e7e438368e16 1339 uint8_t *d;
Pokitto 46:e7e438368e16 1340 //lcdClear();
Pokitto 46:e7e438368e16 1341 #if POK_STRETCH
Pokitto 46:e7e438368e16 1342 uint16_t xptr = 14;
Pokitto 46:e7e438368e16 1343 uint8_t yoffset = 24;
Pokitto 46:e7e438368e16 1344 #else
Pokitto 46:e7e438368e16 1345 uint16_t xptr = 0;
Pokitto 46:e7e438368e16 1346 uint8_t yoffset = 0;
Pokitto 46:e7e438368e16 1347 #endif
Pokitto 46:e7e438368e16 1348
Pokitto 46:e7e438368e16 1349 for(x=0;x<128;x++)
Pokitto 46:e7e438368e16 1350 {
Pokitto 46:e7e438368e16 1351 write_command(0x20); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 1352 write_data(yoffset); // 0
Pokitto 46:e7e438368e16 1353 write_command(0x21); // Vertical DRAM Address
Pokitto 46:e7e438368e16 1354 write_data(xptr++);
Pokitto 46:e7e438368e16 1355 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 1356 CLR_CS_SET_CD_RD_WR;
Pokitto 46:e7e438368e16 1357 //setDRAMptr(xptr++,yoffset);
Pokitto 46:e7e438368e16 1358
Pokitto 46:e7e438368e16 1359 d = scrbuf + x;// point to beginning of line in data
Pokitto 46:e7e438368e16 1360
Pokitto 46:e7e438368e16 1361 /** find colours in one scanline **/
Pokitto 46:e7e438368e16 1362 uint8_t s=0;
Pokitto 46:e7e438368e16 1363 for(y=0;y<8;y++)
Pokitto 46:e7e438368e16 1364 {
Pokitto 46:e7e438368e16 1365 uint8_t t = *d;
Pokitto 46:e7e438368e16 1366 #if POK_COLORDEPTH > 1
Pokitto 46:e7e438368e16 1367 uint8_t t2 = *(d+AB_JUMP);
Pokitto 46:e7e438368e16 1368 #endif // POK_COLORDEPTH
Pokitto 46:e7e438368e16 1369 #if POK_COLORDEPTH > 2
Pokitto 46:e7e438368e16 1370 uint8_t t3 = *(d+AB_JUMP+AB_JUMP);
Pokitto 46:e7e438368e16 1371 #endif // POK_COLORDEPTH
Pokitto 46:e7e438368e16 1372 #if POK_COLORDEPTH > 3
Pokitto 46:e7e438368e16 1373 uint8_t t4 = *(d+AB_JUMP+AB_JUMP+AB_JUMP);
Pokitto 46:e7e438368e16 1374 #endif // POK_COLORDEPTH
Pokitto 46:e7e438368e16 1375 uint8_t paletteindex = 0;
Pokitto 46:e7e438368e16 1376
Pokitto 46:e7e438368e16 1377 /** bit 1 **/
Pokitto 46:e7e438368e16 1378 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1379 paletteindex = (t & 0x1);
Pokitto 46:e7e438368e16 1380 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1381 paletteindex = ((t & 0x1)) | ((t2 & 0x01)<<1);
Pokitto 46:e7e438368e16 1382 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1383 paletteindex = (t & 0x1) | ((t2 & 0x1)<<1) | ((t3 & 0x1)<<2);
Pokitto 46:e7e438368e16 1384 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1385 paletteindex = (t & 0x1) | ((t2 & 0x1)<<1) | ((t3 & 0x1)<<2) | ((t4 & 0x1)<<3);
Pokitto 46:e7e438368e16 1386 #endif
Pokitto 46:e7e438368e16 1387 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1388
Pokitto 46:e7e438368e16 1389 /** bit 2 **/
Pokitto 46:e7e438368e16 1390 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1391 paletteindex = (t & 0x2)>>1;
Pokitto 46:e7e438368e16 1392 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1393 paletteindex = ((t & 0x2)>>1) | ((t2 & 0x02));
Pokitto 46:e7e438368e16 1394 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1395 paletteindex = ((t & 0x2)>>1) | ((t2 & 0x2)) | ((t3 & 0x2)<<1);
Pokitto 46:e7e438368e16 1396 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1397 paletteindex = ((t & 0x2)>>1) | ((t2 & 0x2)) | ((t3 & 0x2)<<1) | ((t4 & 0x2)<<2);
Pokitto 46:e7e438368e16 1398 #endif
Pokitto 46:e7e438368e16 1399 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1400
Pokitto 46:e7e438368e16 1401 /** bit 3 **/
Pokitto 46:e7e438368e16 1402 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1403 paletteindex = (t & 0x4)>>2;
Pokitto 46:e7e438368e16 1404 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1405 paletteindex = ((t & 4)>>2) | ((t2 & 0x04)>>1);
Pokitto 46:e7e438368e16 1406 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1407 paletteindex = ((t & 0x4)>>2) | ((t2 & 0x4)>>1) | (t3 & 0x4);
Pokitto 46:e7e438368e16 1408 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1409 paletteindex = ((t & 0x4)>>2) | ((t2 & 0x4)>>1) | (t3 & 0x4) | ((t4 & 0x4)<<1);
Pokitto 46:e7e438368e16 1410 #endif
Pokitto 46:e7e438368e16 1411 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1412
Pokitto 46:e7e438368e16 1413 /** bit 4 **/
Pokitto 46:e7e438368e16 1414 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1415 paletteindex = (t & 0x8)>>3;
Pokitto 46:e7e438368e16 1416 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1417 paletteindex = ((t & 0x8)>>3) | ((t2 & 0x08)>>2);
Pokitto 46:e7e438368e16 1418 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1419 paletteindex = ((t & 0x8)>>3) | ((t2 & 0x8)>>2) | ((t3 & 0x8)>>1);
Pokitto 46:e7e438368e16 1420 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1421 paletteindex = ((t & 0x8)>>3) | ((t2 & 0x8)>>2) | ((t3 & 0x8)>>1) | (t4 & 0x8);
Pokitto 46:e7e438368e16 1422 #endif
Pokitto 46:e7e438368e16 1423 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1424
Pokitto 46:e7e438368e16 1425 /** bit 5 **/
Pokitto 46:e7e438368e16 1426 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1427 paletteindex = (t & 0x10)>>4;
Pokitto 46:e7e438368e16 1428 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1429 paletteindex = ((t & 0x10)>>4) | ((t2 & 0x10)>>3);
Pokitto 46:e7e438368e16 1430 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1431 paletteindex = ((t & 0x10)>>4) | ((t2 & 0x10)>>3) | ((t3 & 0x10)>>2);
Pokitto 46:e7e438368e16 1432 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1433 paletteindex = ((t & 0x10)>>4) | ((t2 & 0x10)>>3) | ((t3 & 0x10)>>2) | ((t4 & 0x10)>>1);
Pokitto 46:e7e438368e16 1434 #endif
Pokitto 46:e7e438368e16 1435 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1436
Pokitto 46:e7e438368e16 1437 /** bit 6 **/
Pokitto 46:e7e438368e16 1438 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1439 paletteindex = (t & 0x20)>>5;
Pokitto 46:e7e438368e16 1440 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1441 paletteindex = ((t & 0x20)>>5) | ((t2 & 0x20)>>4);
Pokitto 46:e7e438368e16 1442 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1443 paletteindex = ((t & 0x20)>>5) | ((t2 & 0x20)>>4) | ((t3 & 0x20)>>3);
Pokitto 46:e7e438368e16 1444 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1445 paletteindex = ((t & 0x20)>>5) | ((t2 & 0x20)>>4) | ((t3 & 0x20)>>3) | ((t4 & 0x20)>>2);
Pokitto 46:e7e438368e16 1446 #endif
Pokitto 46:e7e438368e16 1447 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1448
Pokitto 46:e7e438368e16 1449 /** bit 7 **/
Pokitto 46:e7e438368e16 1450 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1451 paletteindex = (t & 0x40)>>6;
Pokitto 46:e7e438368e16 1452 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1453 paletteindex = ((t & 0x40)>>6) | ((t2 & 0x40)>>5);
Pokitto 46:e7e438368e16 1454 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1455 paletteindex = ((t & 0x40)>>6) | ((t2 & 0x40)>>5) | ((t3 & 0x40)>>4) ;
Pokitto 46:e7e438368e16 1456 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1457 paletteindex = ((t & 0x40)>>6) | ((t2 & 0x40)>>5) | ((t3 & 0x40)>>4) | ((t4 & 0x40)>>3);
Pokitto 46:e7e438368e16 1458 #endif
Pokitto 46:e7e438368e16 1459 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1460
Pokitto 46:e7e438368e16 1461 /** bit 8 **/
Pokitto 46:e7e438368e16 1462 #if POK_COLORDEPTH == 1
Pokitto 46:e7e438368e16 1463 paletteindex = (t & 0x80)>>7;
Pokitto 46:e7e438368e16 1464 #elif POK_COLORDEPTH == 2
Pokitto 46:e7e438368e16 1465 paletteindex = ((t & 0x80)>>7) | ((t2 & 0x80)>>6);
Pokitto 46:e7e438368e16 1466 #elif POK_COLORDEPTH == 3
Pokitto 46:e7e438368e16 1467 paletteindex = ((t & 0x80)>>7) | ((t2 & 0x80)>>6) | ((t3 & 0x80)>>5);
Pokitto 46:e7e438368e16 1468 #elif POK_COLORDEPTH == 4
Pokitto 46:e7e438368e16 1469 paletteindex = ((t & 0x80)>>7) | ((t2 & 0x80)>>6) | ((t3 & 0x80)>>5) | ((t4 & 0x80)>>4);
Pokitto 46:e7e438368e16 1470 #endif
Pokitto 46:e7e438368e16 1471 scanline[s++] = paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1472
Pokitto 46:e7e438368e16 1473 d+=128; // jump to byte directly below
Pokitto 46:e7e438368e16 1474 }
Pokitto 46:e7e438368e16 1475
Pokitto 46:e7e438368e16 1476 s=0;
Pokitto 46:e7e438368e16 1477
Pokitto 46:e7e438368e16 1478 /** draw scanlines **/
Pokitto 46:e7e438368e16 1479 for (s=0;s<64;) {
Pokitto 46:e7e438368e16 1480 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1481 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1482 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1483 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1484 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1485 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1486 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1487 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1488 }
Pokitto 46:e7e438368e16 1489
Pokitto 46:e7e438368e16 1490 #if POK_STRETCH
Pokitto 46:e7e438368e16 1491 if (x&1) {
Pokitto 46:e7e438368e16 1492 write_command(0x20); // Horizontal DRAM Address
Pokitto 46:e7e438368e16 1493 write_data(yoffset); // 0
Pokitto 46:e7e438368e16 1494 write_command(0x21); // Vertical DRAM Address
Pokitto 46:e7e438368e16 1495 write_data(xptr++);
Pokitto 46:e7e438368e16 1496 write_command(0x22); // write data to DRAM
Pokitto 46:e7e438368e16 1497 CLR_CS_SET_CD_RD_WR;
Pokitto 46:e7e438368e16 1498 //setDRAMptr(xptr++,yoffset);
Pokitto 46:e7e438368e16 1499
Pokitto 46:e7e438368e16 1500 for (s=0;s<64;) {
Pokitto 46:e7e438368e16 1501 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1502 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1503 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1504 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1505 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1506 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1507 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1508 setup_data_16(scanline[s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1509 }
Pokitto 46:e7e438368e16 1510 }
Pokitto 46:e7e438368e16 1511 #endif
Pokitto 46:e7e438368e16 1512 }
Pokitto 46:e7e438368e16 1513 }
Pokitto 46:e7e438368e16 1514
Pokitto 46:e7e438368e16 1515 void Pokitto::lcdRefreshModeGBC(uint8_t * scrbuf, uint16_t* paletteptr) {
Pokitto 46:e7e438368e16 1516 uint16_t x,y,xptr;
Pokitto 46:e7e438368e16 1517 uint16_t scanline[4][144]; // read 4 half-nibbles = 4 pixels at a time
Pokitto 46:e7e438368e16 1518 uint8_t *d, yoffset=0;
Pokitto 46:e7e438368e16 1519
Pokitto 46:e7e438368e16 1520 xptr = 0;
Pokitto 46:e7e438368e16 1521 setDRAMptr(xptr,yoffset);
Pokitto 46:e7e438368e16 1522
Pokitto 46:e7e438368e16 1523
Pokitto 46:e7e438368e16 1524 for(x=0;x<160;x+=4)
Pokitto 46:e7e438368e16 1525 {
Pokitto 46:e7e438368e16 1526 d = scrbuf+(x>>2);// point to beginning of line in data
Pokitto 46:e7e438368e16 1527 /** find colours in one scanline **/
Pokitto 46:e7e438368e16 1528 uint8_t s=0;
Pokitto 46:e7e438368e16 1529 for(y=0;y<144;y++)
Pokitto 46:e7e438368e16 1530 {
Pokitto 46:e7e438368e16 1531 uint8_t tdata = *d;
Pokitto 46:e7e438368e16 1532 uint8_t t4 = tdata & 0x03; tdata >>= 2;// lowest half-nibble
Pokitto 46:e7e438368e16 1533 uint8_t t3 = tdata & 0x03; tdata >>= 2;// second lowest half-nibble
Pokitto 46:e7e438368e16 1534 uint8_t t2 = tdata & 0x03; tdata >>= 2;// second highest half-nibble
Pokitto 46:e7e438368e16 1535 uint8_t t = tdata & 0x03;// highest half-nibble
Pokitto 46:e7e438368e16 1536
Pokitto 46:e7e438368e16 1537 /** put nibble values in the scanlines **/
Pokitto 46:e7e438368e16 1538
Pokitto 46:e7e438368e16 1539 scanline[0][s] = paletteptr[t];
Pokitto 46:e7e438368e16 1540 scanline[1][s] = paletteptr[t2];
Pokitto 46:e7e438368e16 1541 scanline[2][s] = paletteptr[t3];
Pokitto 46:e7e438368e16 1542 scanline[3][s++] = paletteptr[t4];
Pokitto 46:e7e438368e16 1543
Pokitto 46:e7e438368e16 1544 d+=160/4; // jump to read byte directly below in screenbuffer
Pokitto 46:e7e438368e16 1545 }
Pokitto 46:e7e438368e16 1546
Pokitto 46:e7e438368e16 1547 s=0;
Pokitto 46:e7e438368e16 1548 /** draw scanlines **/
Pokitto 46:e7e438368e16 1549 for (s=0;s<144;) {
Pokitto 46:e7e438368e16 1550 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1551 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1552 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1553 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1554 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1555 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1556 }
Pokitto 46:e7e438368e16 1557 setDRAMptr(++xptr,yoffset);
Pokitto 46:e7e438368e16 1558 for (s=0;s<144;) {
Pokitto 46:e7e438368e16 1559 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1560 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1561 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1562 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1563 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1564 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1565 }
Pokitto 46:e7e438368e16 1566 setDRAMptr(++xptr,yoffset);
Pokitto 46:e7e438368e16 1567 for (s=0;s<144;) {
Pokitto 46:e7e438368e16 1568 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1569 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1570 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1571 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1572 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1573 setup_data_16(scanline[2][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1574 }
Pokitto 46:e7e438368e16 1575 setDRAMptr(++xptr,yoffset);
Pokitto 46:e7e438368e16 1576 for (s=0;s<144;) {
Pokitto 46:e7e438368e16 1577 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1578 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1579 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1580 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1581 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1582 setup_data_16(scanline[3][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1583 }
Pokitto 46:e7e438368e16 1584 setDRAMptr(++xptr,yoffset);
Pokitto 46:e7e438368e16 1585 }
Pokitto 46:e7e438368e16 1586 }
Pokitto 46:e7e438368e16 1587
Pokitto 46:e7e438368e16 1588
Pokitto 46:e7e438368e16 1589 void Pokitto::lcdRefreshT1(uint8_t* tilebuf, uint8_t* tilecolorbuf, uint8_t* tileset, uint16_t* paletteptr) {
Pokitto 46:e7e438368e16 1590 #ifdef POK_TILEMODE
Pokitto 46:e7e438368e16 1591 uint16_t x,y,data,xptr;
Pokitto 46:e7e438368e16 1592 uint16_t scanline[176];
Pokitto 46:e7e438368e16 1593 uint8_t yoffset=0, tilebyte, tileindex, tilex=0, tiley=0,xcount;
Pokitto 46:e7e438368e16 1594
Pokitto 46:e7e438368e16 1595
Pokitto 46:e7e438368e16 1596 if (!tileset) return;
Pokitto 46:e7e438368e16 1597
Pokitto 46:e7e438368e16 1598 #if LCDWIDTH < POK_LCD_W
Pokitto 46:e7e438368e16 1599 xptr = (POK_LCD_W-LCDWIDTH)/2;
Pokitto 46:e7e438368e16 1600 #else
Pokitto 46:e7e438368e16 1601 xptr = 0;
Pokitto 46:e7e438368e16 1602 #endif
Pokitto 46:e7e438368e16 1603 #if LCDHEIGHT < POK_LCD_H
Pokitto 46:e7e438368e16 1604 yoffset = (POK_LCD_H-LCDHEIGHT)/2;
Pokitto 46:e7e438368e16 1605 #else
Pokitto 46:e7e438368e16 1606 yoffset = 0;
Pokitto 46:e7e438368e16 1607 #endif
Pokitto 46:e7e438368e16 1608
Pokitto 46:e7e438368e16 1609 for(x=0, xcount=0 ;x<LCDWIDTH;x++,xcount++) // loop through vertical columns
Pokitto 46:e7e438368e16 1610 {
Pokitto 46:e7e438368e16 1611 setDRAMptr(xptr++,yoffset); //point to VRAM
Pokitto 46:e7e438368e16 1612
Pokitto 46:e7e438368e16 1613 /** find colours in one scanline **/
Pokitto 46:e7e438368e16 1614 uint8_t s=0, tiley=0;
Pokitto 46:e7e438368e16 1615 //tileindex = tilebuf[tilex*POK_TILES_Y];
Pokitto 46:e7e438368e16 1616 if (xcount==POK_TILE_W) {
Pokitto 46:e7e438368e16 1617 tilex++;
Pokitto 46:e7e438368e16 1618 xcount=0;
Pokitto 46:e7e438368e16 1619 }
Pokitto 46:e7e438368e16 1620
Pokitto 46:e7e438368e16 1621 for(y=0;y<LCDHEIGHT;)
Pokitto 46:e7e438368e16 1622 {
Pokitto 46:e7e438368e16 1623 uint8_t tileval = tilebuf[tilex+tiley*POK_TILES_X]; //get tile number
Pokitto 46:e7e438368e16 1624 uint16_t index = tileval*POK_TILE_W+xcount;
Pokitto 46:e7e438368e16 1625 uint8_t tilebyte = tileset[index]; //get bitmap data
Pokitto 46:e7e438368e16 1626 for (uint8_t ycount=0, bitcount=0; ycount<POK_TILE_H; ycount++, y++, bitcount++) {
Pokitto 46:e7e438368e16 1627 if (bitcount==8) {
Pokitto 46:e7e438368e16 1628 bitcount=0;
Pokitto 46:e7e438368e16 1629 index += 176; //jump to byte below in the tileset bitmap
Pokitto 46:e7e438368e16 1630 tilebyte = tileset[index]; //get bitmap data
Pokitto 46:e7e438368e16 1631 }
Pokitto 46:e7e438368e16 1632 //tilebyte = tile[(tileindex>>4)+*POK_TILE_W]; //tilemaps are 16x16
Pokitto 46:e7e438368e16 1633 //uint8_t paletteindex = ((tilebyte>>(bitcount&0x7)) & 0x1);
Pokitto 46:e7e438368e16 1634 if (!tileval) scanline[s++] = COLOR_MAGENTA*((tilebyte>>bitcount)&0x1);//paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1635 else scanline[s++] = paletteptr[((tilebyte>>bitcount)&0x1)*tileval];//paletteptr[paletteindex];
Pokitto 46:e7e438368e16 1636 }
Pokitto 46:e7e438368e16 1637 tiley++; //move to next tile
Pokitto 46:e7e438368e16 1638 }
Pokitto 46:e7e438368e16 1639 s=0;
Pokitto 46:e7e438368e16 1640
Pokitto 46:e7e438368e16 1641 /** draw scanlines **/
Pokitto 46:e7e438368e16 1642 for (s=0;s<LCDHEIGHT;) {
Pokitto 46:e7e438368e16 1643 setup_data_16(scanline[s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1644 }
Pokitto 46:e7e438368e16 1645 }
Pokitto 46:e7e438368e16 1646 #endif
Pokitto 46:e7e438368e16 1647 }
Pokitto 46:e7e438368e16 1648
Pokitto 46:e7e438368e16 1649
Pokitto 46:e7e438368e16 1650 void Pokitto::lcdRefreshMode13(uint8_t * scrbuf, uint16_t* paletteptr, uint8_t offset){
Pokitto 46:e7e438368e16 1651 uint16_t x,y;
Pokitto 46:e7e438368e16 1652 uint16_t scanline[2][110]; // read two nibbles = pixels at a time
Pokitto 46:e7e438368e16 1653 uint8_t *d;
Pokitto 46:e7e438368e16 1654
Pokitto 46:e7e438368e16 1655 write_command(0x20); write_data(0);
Pokitto 46:e7e438368e16 1656 write_command(0x21); write_data(0);
Pokitto 46:e7e438368e16 1657 write_command(0x22);
Pokitto 46:e7e438368e16 1658 CLR_CS_SET_CD_RD_WR;
Pokitto 46:e7e438368e16 1659
Pokitto 46:e7e438368e16 1660 for(x=0;x<110;x+=2)
Pokitto 46:e7e438368e16 1661 {
Pokitto 46:e7e438368e16 1662 d = scrbuf+x;// point to beginning of line in data
Pokitto 46:e7e438368e16 1663 uint8_t s=0;
Pokitto 46:e7e438368e16 1664 for(y=0;y<88;y++)
Pokitto 46:e7e438368e16 1665 {
Pokitto 46:e7e438368e16 1666 uint8_t t = *d;
Pokitto 46:e7e438368e16 1667 uint8_t t1 = *(d+1);
Pokitto 46:e7e438368e16 1668 scanline[0][s] = paletteptr[(t+offset)&255];
Pokitto 46:e7e438368e16 1669 scanline[1][s++] = paletteptr[(t1+offset)&255];
Pokitto 46:e7e438368e16 1670 d+=110; // jump to read byte directly below in screenbuffer
Pokitto 46:e7e438368e16 1671 }
Pokitto 46:e7e438368e16 1672 s=0;
Pokitto 46:e7e438368e16 1673 for (s=0;s<88;) {
Pokitto 46:e7e438368e16 1674 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1675 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1676 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1677 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1678 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1679 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1680 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1681 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1682 }
Pokitto 46:e7e438368e16 1683 for (s=0;s<88;) {
Pokitto 46:e7e438368e16 1684 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1685 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1686 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1687 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1688 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1689 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1690 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1691 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1692 }
Pokitto 46:e7e438368e16 1693 for (s=0;s<88;) {
Pokitto 46:e7e438368e16 1694 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1695 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1696 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1697 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1698 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1699 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1700 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1701 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1702 }
Pokitto 46:e7e438368e16 1703 for (s=0;s<88;) {
Pokitto 46:e7e438368e16 1704 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1705 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1706 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1707 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1708 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1709 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1710 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1711 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1712 }
Pokitto 46:e7e438368e16 1713 }
Pokitto 46:e7e438368e16 1714
Pokitto 46:e7e438368e16 1715 }
Pokitto 46:e7e438368e16 1716
Pokitto 46:e7e438368e16 1717
Pokitto 46:e7e438368e16 1718
Pokitto 46:e7e438368e16 1719 void Pokitto::lcdRefreshMode14(uint8_t * scrbuf, uint16_t* paletteptr) {
Pokitto 46:e7e438368e16 1720 uint16_t x,y,data,xptr;
Pokitto 46:e7e438368e16 1721 uint16_t scanline[176]; uint16_t* scptr;
Pokitto 46:e7e438368e16 1722 uint8_t *d;
Pokitto 46:e7e438368e16 1723
Pokitto 46:e7e438368e16 1724 write_command(0x20); write_data(0);
Pokitto 46:e7e438368e16 1725 write_command(0x21); write_data(0);
Pokitto 46:e7e438368e16 1726 write_command(0x22);
Pokitto 46:e7e438368e16 1727 CLR_CS_SET_CD_RD_WR;
Pokitto 46:e7e438368e16 1728
Pokitto 46:e7e438368e16 1729 for(x=0;x<220;x++)
Pokitto 46:e7e438368e16 1730 {
Pokitto 46:e7e438368e16 1731 d = scrbuf+x;
Pokitto 46:e7e438368e16 1732 scptr = &scanline[0];
Pokitto 46:e7e438368e16 1733
Pokitto 46:e7e438368e16 1734 /** find colours in one scanline **/
Pokitto 46:e7e438368e16 1735 /*for(y=0;y<22;y++)
Pokitto 46:e7e438368e16 1736 {
Pokitto 46:e7e438368e16 1737
Pokitto 46:e7e438368e16 1738 uint16_t t = *d;
Pokitto 46:e7e438368e16 1739 uint16_t t2 = *(d+POK_BITFRAME);
Pokitto 46:e7e438368e16 1740 uint16_t t3 = *(d+POK_BITFRAME+POK_BITFRAME);
Pokitto 46:e7e438368e16 1741
Pokitto 46:e7e438368e16 1742 *scptr++ = (t & 0x1)*R_MASK | (t2 & 0x1)*G_MASK | (t3 & 0x1)*B_MASK; t >>= 1;t2 >>= 1;t3 >>= 1;
Pokitto 46:e7e438368e16 1743 *scptr++ = (t & 0x1)*R_MASK | (t2 & 0x1)*G_MASK | (t3 & 0x1)*B_MASK; t >>= 1;t2 >>= 1;t3 >>= 1;
Pokitto 46:e7e438368e16 1744 *scptr++ = (t & 0x1)*R_MASK | (t2 & 0x1)*G_MASK | (t3 & 0x1)*B_MASK; t >>= 1;t2 >>= 1;t3 >>= 1;
Pokitto 46:e7e438368e16 1745 *scptr++ = (t & 0x1)*R_MASK | (t2 & 0x1)*G_MASK | (t3 & 0x1)*B_MASK; t >>= 1;t2 >>= 1;t3 >>= 1;
Pokitto 46:e7e438368e16 1746
Pokitto 46:e7e438368e16 1747 *scptr++ = (t & 0x1)*R_MASK | (t2 & 0x1)*G_MASK | (t3 & 0x1)*B_MASK; t >>= 1;t2 >>= 1;t3 >>= 1;
Pokitto 46:e7e438368e16 1748 *scptr++ = (t & 0x1)*R_MASK | (t2 & 0x1)*G_MASK | (t3 & 0x1)*B_MASK; t >>= 1;t2 >>= 1;t3 >>= 1;
Pokitto 46:e7e438368e16 1749 *scptr++ = (t & 0x1)*R_MASK | (t2 & 0x1)*G_MASK | (t3 & 0x1)*B_MASK; t >>= 1;t2 >>= 1;t3 >>= 1;
Pokitto 46:e7e438368e16 1750 *scptr++ = (t & 0x1)*R_MASK | (t2 & 0x1)*G_MASK | (t3 & 0x1)*B_MASK; t >>= 1;t2 >>= 1;t3 >>= 1;
Pokitto 46:e7e438368e16 1751
Pokitto 46:e7e438368e16 1752
Pokitto 46:e7e438368e16 1753 d+=220; // jump to word directly below
Pokitto 46:e7e438368e16 1754 }
Pokitto 46:e7e438368e16 1755 */
Pokitto 46:e7e438368e16 1756 /** alternative way: go through one color at a time **/
Pokitto 46:e7e438368e16 1757 scptr = &scanline[0]; // set to beginning of scanline
Pokitto 46:e7e438368e16 1758 for(y=0;y<22;y++, d +=220)
Pokitto 46:e7e438368e16 1759 {
Pokitto 46:e7e438368e16 1760 uint16_t t = *d & 0xFF;
Pokitto 46:e7e438368e16 1761
Pokitto 46:e7e438368e16 1762 *scptr++ = R_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1763 *scptr++ = R_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1764 *scptr++ = R_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1765 *scptr++ = R_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1766 *scptr++ = R_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1767 *scptr++ = R_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1768 *scptr++ = R_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1769 *scptr++ = R_MASK * (t&0x1);
Pokitto 46:e7e438368e16 1770 }
Pokitto 46:e7e438368e16 1771 scptr = &scanline[0]; // set to beginning of scanline
Pokitto 46:e7e438368e16 1772 d = scrbuf+x+POK_BITFRAME;
Pokitto 46:e7e438368e16 1773 for(y=0;y<22;y++, d +=220)
Pokitto 46:e7e438368e16 1774 {
Pokitto 46:e7e438368e16 1775 uint16_t t = *d & 0xFF;
Pokitto 46:e7e438368e16 1776
Pokitto 46:e7e438368e16 1777 *scptr++ |= G_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1778 *scptr++ |= G_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1779 *scptr++ |= G_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1780 *scptr++ |= G_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1781 *scptr++ |= G_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1782 *scptr++ |= G_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1783 *scptr++ |= G_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1784 *scptr++ |= G_MASK * (t&0x1);
Pokitto 46:e7e438368e16 1785 }
Pokitto 46:e7e438368e16 1786 scptr = &scanline[0]; // set to beginning of scanline
Pokitto 46:e7e438368e16 1787 d = scrbuf+x+POK_BITFRAME*2;
Pokitto 46:e7e438368e16 1788 for(y=0;y<22;y++, d +=220)
Pokitto 46:e7e438368e16 1789 {
Pokitto 46:e7e438368e16 1790 uint16_t t = *d & 0xFF;
Pokitto 46:e7e438368e16 1791
Pokitto 46:e7e438368e16 1792 *scptr++ |= B_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1793 *scptr++ |= B_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1794 *scptr++ |= B_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1795 *scptr++ |= B_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1796 *scptr++ |= B_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1797 *scptr++ |= B_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1798 *scptr++ |= B_MASK * (t&0x1); t >>= 1;
Pokitto 46:e7e438368e16 1799 *scptr++ |= B_MASK * (t&0x1);
Pokitto 46:e7e438368e16 1800 }
Pokitto 46:e7e438368e16 1801
Pokitto 46:e7e438368e16 1802
Pokitto 46:e7e438368e16 1803 #ifdef PROJ_SHOW_FPS_COUNTER
Pokitto 46:e7e438368e16 1804 if (x<8) continue;
Pokitto 46:e7e438368e16 1805 setDRAMptr(x, 0);
Pokitto 46:e7e438368e16 1806 #endif
Pokitto 46:e7e438368e16 1807
Pokitto 46:e7e438368e16 1808 /** draw scanlines **/
Pokitto 46:e7e438368e16 1809 for (int s=0;s<176;) {
Pokitto 46:e7e438368e16 1810 setup_data_16(scanline[s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1811 setup_data_16(scanline[s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1812 setup_data_16(scanline[s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1813 setup_data_16(scanline[s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1814 setup_data_16(scanline[s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1815 setup_data_16(scanline[s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1816 setup_data_16(scanline[s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1817 setup_data_16(scanline[s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1818
Pokitto 46:e7e438368e16 1819 }
Pokitto 46:e7e438368e16 1820
Pokitto 46:e7e438368e16 1821 }
Pokitto 46:e7e438368e16 1822 }
Pokitto 46:e7e438368e16 1823
Pokitto 46:e7e438368e16 1824 //#define ADEKTOSMODE15
Pokitto 46:e7e438368e16 1825
Pokitto 46:e7e438368e16 1826 #ifdef ADEKTOSMODE15
Pokitto 46:e7e438368e16 1827 void Pokitto::lcdRefreshMode15(uint16_t* pal, uint8_t* scrbuf){
Pokitto 46:e7e438368e16 1828 write_command(0x03); write_data(0x1038); //realy only need to call this once
Pokitto 46:e7e438368e16 1829 write_command(0x20); write_data(0);
Pokitto 46:e7e438368e16 1830 write_command(0x21); write_data(0);
Pokitto 46:e7e438368e16 1831
Pokitto 46:e7e438368e16 1832 write_command(0x22);
Pokitto 46:e7e438368e16 1833
Pokitto 46:e7e438368e16 1834 #ifdef PROJ_SHOW_FPS_COUNTER
Pokitto 46:e7e438368e16 1835 for (int x=0,xt=0; x<0x4BA0;x++,xt++) {
Pokitto 46:e7e438368e16 1836 if (xt==110) xt=0;
Pokitto 46:e7e438368e16 1837 if (xt<8) {
Pokitto 46:e7e438368e16 1838 write_data(0);
Pokitto 46:e7e438368e16 1839 write_data(0);
Pokitto 46:e7e438368e16 1840 } else {
Pokitto 46:e7e438368e16 1841 write_data(pal[(((scrbuf[x]) & 0xf0) >> 4)]);
Pokitto 46:e7e438368e16 1842 write_data(pal[( (scrbuf[x]) & 0x0f)]);
Pokitto 46:e7e438368e16 1843 }
Pokitto 46:e7e438368e16 1844
Pokitto 46:e7e438368e16 1845 }
Pokitto 46:e7e438368e16 1846 #else
Pokitto 46:e7e438368e16 1847 for (int x=0; x<0x4BA0;x++) {
Pokitto 46:e7e438368e16 1848 write_data(pal[(((scrbuf[x]) & 0xf0) >> 4)]);
Pokitto 46:e7e438368e16 1849 write_data(pal[( (scrbuf[x]) & 0x0f)]);
Pokitto 46:e7e438368e16 1850 }
Pokitto 46:e7e438368e16 1851 #endif //PROJ_SHOW_FPS_COUNTER
Pokitto 46:e7e438368e16 1852 }
Pokitto 46:e7e438368e16 1853
Pokitto 46:e7e438368e16 1854 #else
Pokitto 46:e7e438368e16 1855
Pokitto 46:e7e438368e16 1856 void Pokitto::lcdRefreshMode15(uint16_t* paletteptr, uint8_t* scrbuf){
Pokitto 46:e7e438368e16 1857 uint16_t x,y,xptr;
Pokitto 46:e7e438368e16 1858 uint16_t scanline[2][176]; // read two nibbles = pixels at a time
Pokitto 46:e7e438368e16 1859 uint8_t *d, yoffset=0;
Pokitto 46:e7e438368e16 1860
Pokitto 46:e7e438368e16 1861 xptr = 0;
Pokitto 46:e7e438368e16 1862 //setDRAMptr(xptr,yoffset);
Pokitto 46:e7e438368e16 1863
Pokitto 46:e7e438368e16 1864 write_command(0x20); write_data(0);
Pokitto 46:e7e438368e16 1865 write_command(0x21); write_data(0);
Pokitto 46:e7e438368e16 1866 write_command(0x22);
Pokitto 46:e7e438368e16 1867 CLR_CS_SET_CD_RD_WR;
Pokitto 46:e7e438368e16 1868
Pokitto 46:e7e438368e16 1869 for(x=0;x<220;x+=2)
Pokitto 46:e7e438368e16 1870 {
Pokitto 46:e7e438368e16 1871 d = scrbuf+(x>>1);// point to beginning of line in data
Pokitto 46:e7e438368e16 1872 // find colours in one scanline
Pokitto 46:e7e438368e16 1873 uint8_t s=0;
Pokitto 46:e7e438368e16 1874 for(y=0;y<176;y++)
Pokitto 46:e7e438368e16 1875 {
Pokitto 46:e7e438368e16 1876 uint8_t t = *d >> 4; // higher nibble
Pokitto 46:e7e438368e16 1877 uint8_t t2 = *d & 0xF; // lower nibble
Pokitto 46:e7e438368e16 1878 // higher nibble = left pixel in pixel pair
Pokitto 46:e7e438368e16 1879 scanline[0][s] = paletteptr[t];
Pokitto 46:e7e438368e16 1880 scanline[1][s++] = paletteptr[t2];
Pokitto 46:e7e438368e16 1881
Pokitto 46:e7e438368e16 1882 d+=220/2; // jump to read byte directly below in screenbuffer
Pokitto 46:e7e438368e16 1883 }
Pokitto 46:e7e438368e16 1884 s=0;
Pokitto 46:e7e438368e16 1885 // draw scanlines
Pokitto 46:e7e438368e16 1886
Pokitto 46:e7e438368e16 1887 #ifdef PROJ_SHOW_FPS_COUNTER
Pokitto 46:e7e438368e16 1888 if (x<8) continue;
Pokitto 46:e7e438368e16 1889 setDRAMptr(x, 0);
Pokitto 46:e7e438368e16 1890 #endif
Pokitto 46:e7e438368e16 1891
Pokitto 46:e7e438368e16 1892 for (s=0;s<176;) {
Pokitto 46:e7e438368e16 1893 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1894 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1895 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1896 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1897 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1898 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1899 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1900 setup_data_16(scanline[0][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1901 }
Pokitto 46:e7e438368e16 1902
Pokitto 46:e7e438368e16 1903 for (s=0;s<176;) {
Pokitto 46:e7e438368e16 1904 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1905 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1906 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1907 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1908 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1909 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1910 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1911 setup_data_16(scanline[1][s++]);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1912 }
Pokitto 46:e7e438368e16 1913 }
Pokitto 46:e7e438368e16 1914 }
Pokitto 46:e7e438368e16 1915 #endif //ADEKTOSMODE15
Pokitto 46:e7e438368e16 1916
Pokitto 46:e7e438368e16 1917 void Pokitto::blitWord(uint16_t c) {
Pokitto 46:e7e438368e16 1918 setup_data_16(c);CLR_WR;SET_WR;
Pokitto 46:e7e438368e16 1919 }
Pokitto 46:e7e438368e16 1920
Pokitto 46:e7e438368e16 1921