PokittoLib with changes to lcd refresh etc.

Dependents:   Pokittris

Fork of Pokitto by Pokitto Community Team

This is a fork by user @Spinal, and is used in Pokittris for testing. Do not import this to your own program.

Revision:
10:8cde5d0bafad
Parent:
9:570fdd653f1d
Child:
11:02ad9c807a21
--- a/POKITTO_HW/HWLCD.cpp	Sun Oct 15 16:13:07 2017 +0000
+++ b/POKITTO_HW/HWLCD.cpp	Sun Oct 15 16:50:56 2017 +0000
@@ -160,7 +160,7 @@
     write_data(0x0100); // INV = 1
 
     write_command(0x03); // Entry mode... lets try if this affects the direction
-    write_data(0x1030); // originally 0x1030 1000000110000 BGR,ID1,ID0
+    write_data(0x1038); // originally 0x1030 1000000110000 BGR,ID1,ID0
                         // test 1: 0x1038 1000000111000 BGR,ID1,ID0,AM=1 ->drawing DRAM horizontally
                         // test 4: am=1, id0=0, id1=0, 1000000001000,0x1008 -> same as above, but flipped on long
                         // test 2: am=0, id0=0, 1000000100000, 0x1020 -> flipped on long axis
@@ -375,6 +375,25 @@
 	}
 }
 
+void Pokitto::lcdRefreshRegionMode1(int16_t x0, int16_t y0, int16_t x1, int16_t y1,  uint8_t * scrbuf, uint16_t * paletteptr){
+	if(x1<=x0)x1=x0+1;
+	if(y1<=y0)y1=y0+1;
+	setWindow(y0, x0, y1-1, x1-1);
+    write_command(0x22);
+    uint8_t pix;
+    uint8_t quartWide=(x1-x0)/4;;
+    uint8_t pic;
+    for(int y=y0; y<y1; y++){
+        for(int x=x0; x<x0+quartWide; x++){
+            pic = scrbuf[x+quartWide*y];
+            pix = (pic >> 6)&3; write_data(paletteptr[pix]);
+            pix = (pic >> 4)&3; write_data(paletteptr[pix]);
+            pix = (pic >> 2)&3; write_data(paletteptr[pix]);
+            pix = pic &3;       write_data(paletteptr[pix]);
+        }
+    }
+}
+
 void Pokitto::lcdRefreshMode1(uint8_t * scrbuf, uint16_t* paletteptr) {
 uint16_t x,y,xptr;
 uint16_t scanline[4][176]; // read 4 half-nibbles = 4 pixels at a time