Platform game written for the GHI/OutrageousCircuits RETRO game device. Navigate the caves collecting all the pickups and avoiding the creatures and haunted mine carts that patrol the caves. Oh and remember to watch out for the poisonous plants... This game demonstrates the ability to have multiple animated sprites where the sprites can overlap the background environment. See how the player moves past the fence and climbs the wall in the 3rd screen.

Dependencies:   mbed

Revision:
4:45ff7fc8a431
Parent:
3:a93fe5f207f5
--- a/LCD_ST7735/LCD_ST7735.cpp	Sat Dec 27 23:24:30 2014 +0000
+++ b/LCD_ST7735/LCD_ST7735.cpp	Fri Jan 02 00:58:50 2015 +0000
@@ -439,6 +439,65 @@
     endBatchCommand();
 }
 
+void LCD_ST7735::drawBitmap(int x, int y, const uint8_t *pbmp, int srcX, int srcY, int srcWidth, int srcHeight, uint16_t foregroundColor, uint16_t backgroundColor)
+{
+    // Clip if out of screen    
+    if ((x >= _width) || (x + srcWidth < 0) || 
+        (y >= _height) || (y + srcHeight < 0))
+    {
+        return;
+    }
+    
+    // Clip X
+    if (x < 0) { srcX += -x; srcWidth += x; x = 0; }
+    if (x + srcWidth >= _width) { srcWidth += _width - (x + srcWidth); }
+    
+    // Clip Y
+    if (y  < 0) {srcY += -y; srcHeight += y; y = 0; }  
+    if (y + srcHeight >= _height) { srcHeight += _height - (y + srcHeight); }
+    
+    uint8_t fch = foregroundColor >> 8;
+    uint8_t fcl = foregroundColor;
+    uint8_t bch = backgroundColor >> 8;
+    uint8_t bcl = backgroundColor;
+    
+    uint16_t w = (*(pbmp + 1) << 8) | (*(pbmp + 0));    
+    pbmp += 4;
+    
+    int stride = w / 8;
+    clip(x, y, srcWidth, srcHeight);
+    
+    int offset = (stride * srcY) + (srcX / 8);
+    int startbits = srcX % 8;
+    
+    beginBatchCommand(CMD_RAMWR);
+    for(int r = 0; r < srcHeight; ++r)
+    {
+        const uint8_t *p = pbmp + offset;
+        
+        uint8_t b = *p;
+        for (int c = 0, shift = startbits; c < srcWidth; ++c, ++shift)
+        {
+            if (shift == 8) 
+            {
+                shift = 0;
+                b = *++p;
+            }
+            
+            if ((b << shift) & 0x80)                            
+            {
+                writeBatchData(fch, fcl);                
+            }
+            else
+            {
+                writeBatchData(bch, bcl);                
+            }
+        }   
+        offset += stride;             
+    }
+    endBatchCommand();
+}
+
 void LCD_ST7735::setForegroundColor(uint16_t color)
 {
     _foregroundColorHigh = color >> 8;