tileMap() function update to color

hi guys

iv e been working on a gaming library that supports a color oled screen. I seem to have fixed everything but the tile map function and definition and I really don’t know how to fix it. I tried adding color arguments to the old bitmap functions which seems to work in a way but it still points to two definitions with in the tileMap() routines function definition…

cpp definition all bitmap plus tilemap

void Display::drawBitmap(int8_t x, int8_t y, const uint8_t *bitmap) {
   int8_t w = pgm_read_byte(bitmap);
   int8_t h = pgm_read_byte(bitmap + 1);
   bitmap = bitmap + 2; //add an offset to the pointer to start after the width and height
   drawBitmap(x,y,w,h,bitmap);
}

void Display::drawBitmap(int8_t x, int8_t y, int8_t w,int8_t h, const uint8_t *bitmap, uint8_t dx, uint8_t dy, uint8_t dw, uint8_t dh) {
    int8_t i, j, byteWidth = (w + 7) / 8;
    dw += dx;
    dh += dy;
    int8_t largest = 0;
    int8_t largesty = 0;
    for (j = 0; j < h; j++) {
        for (i = 0; i < w; i++) {
            if (pgm_read_byte(bitmap + j * byteWidth + i / 8) & (B10000000 >> (i % 8))) {
                int8_t drawX = x + i;
                int8_t drawY = y + j;
                
                if(drawX >= dx && drawX < dw && drawY >= dy && drawY < dh){
                    drawPixel(drawX, drawY);
                }
            }
        }
    }
}

boolean Display::getBitmapPixel(const uint8_t* bitmap, uint8_t x, uint8_t y){
  return pgm_read_byte(bitmap+2 + y * ((pgm_read_byte(bitmap)+7)/8) + (x >> 3)) & (B10000000 >> (x % 8));
}

void Display::drawBitmap(int8_t x, int8_t y, const uint8_t *bitmap,
        uint8_t rotation, uint8_t flip) {
    if((rotation == NOROT) && (flip == NOFLIP)){
        drawBitmap(x,y,bitmap); //use the faster algorithm
        return;
    }
    uint8_t w = pgm_read_byte(bitmap);
    uint8_t h = pgm_read_byte(bitmap + 1);
    bitmap = bitmap + 2; //add an offset to the pointer to start after the width and height
#if (ENABLE_BITMAPS > 0)
    int8_t i, j, //coordinates in the raw bitmap
            k, l, //coordinates in the rotated/flipped bitmap
            byteNum, bitNum, byteWidth = (w + 7) >> 3;

    rotation %= 4;

    for (i = 0; i < w; i++) {
        byteNum = i / 8;
        bitNum = i % 8;
        for (j = 0; j < h; j++) {
            if (pgm_read_byte(bitmap + j * byteWidth + byteNum) & (B10000000 >> bitNum)) {
                switch (rotation) {
                    case NOROT: //no rotation
                        k = i;
                        l = j;
                        break;
                    case ROTCCW: //90° counter-clockwise
                        k = j;
                        l = w - i - 1;
                        break;
                    case ROT180: //180°
                        k = w - i - 1;
                        l = h - j - 1;
                        break;
                    case ROTCW: //90° clockwise
                        k = h - j - 1;
                        l = i;
                        break;
                }
                if (flip) {
                    flip %= 4;
                    if (flip & B00000001) { //horizontal flip
                        k = w - k - 1;
                    }
                    if (flip & B00000010) { //vertical flip
                        l = h - l;
                    }
                }
                k += x; //place the bitmap on the screen
                l += y;
                drawPixel(k, l);
            }
        }
    }
#else
    drawRect(x, y, w, h);
#endif
}

void Display::drawTilemap(int x, int y, const uint8_t *tilemap, const uint8_t **spritesheet){
    drawTilemap(x,y,tilemap,spritesheet,0,0,LCDWIDTH,LCDHEIGHT);
}
void Display::drawTilemap(int x, int y, const uint8_t *tilemap, const uint8_t **spritesheet,uint8_t dx,uint8_t dy,uint8_t dw,uint8_t dh){
    uint8_t tilemap_width = pgm_read_byte(tilemap);
    uint8_t tilemap_height = pgm_read_byte(tilemap + 1);
    uint8_t tile_width = pgm_read_byte(tilemap + 2);
    uint8_t tile_height = pgm_read_byte(tilemap + 3);
    tilemap += 4; // now the first tiyleis at tilemap
    uint8_t ddw = dw + dx;
    uint8_t ddh = dh + dy;
    uint8_t maxDdx = (dw - x + tile_width - 1) / tile_width;
    uint8_t maxDdy = (dh - y + tile_height - 1) / tile_height;
    if(tilemap_width < maxDdx){
        maxDdx = tilemap_width;
    }
    if(tilemap_height < maxDdy){
        maxDdy = tilemap_height;
    }
    int8_t startDdx = (-x) / tile_width;
    int8_t startDdy = (-y) / tile_height;
    if(startDdx < 0){
        startDdx = 0;
    }
    if(startDdy < 0){
        startDdy = 0;
    }
	if(flagcollision)numcolision = 0;                                 //Line 735 - clear numcolision - ADD by Summoner123

    for(uint8_t ddy = startDdy;ddy < maxDdy;ddy++){
        for(uint8_t ddx = startDdx;ddx < maxDdx;ddx++){
            int8_t drawX = ddx*tile_width + x + dx;
            int8_t drawY = ddy*tile_height + y + dy;
            uint8_t tile = pgm_read_byte(tilemap + ddy*tilemap_width + ddx);
            if(drawX >= dx && drawY >= dy && drawX <= (ddw-tile_width) && drawY <= (ddh-tile_height)){
                drawBitmap(drawX,drawY,tile_width,tile_height,spritesheet[tile]);

				if(flagcollision){
			solid[numcolision].x = drawX;                     //Save X coordinate      - ADD by Summoner123
            solid[numcolision].y = drawY;                     //Save Y coordinate      - ADD by Summoner123
            solid[numcolision].spritecol = spritesheet[tile]; //Save Sprite of tile    - ADD by Summoner123
            numcolision++;                                    //Increment numcolision  - ADD by Summoner123
            				}
				}else{ // we need to draw a partial bitmap
                drawBitmap(drawX,drawY,tile_width,tile_height,spritesheet[tile],dx,dy,dw,dh);
            }
        }
    }
}

here is the .h

void drawBitmap(int16_t x, int16_t y, const uint16_t *bitmap);
	void drawBitmap(int16_t x, int16_t y, int16_t w, int16_t h , const uint16_t *bitmap);
	void drawBitmap(int16_t x, int16_t y, const uint16_t *bitmap, uint16_t rotation, uint16_t flip);
	void drawBitmap(int16_t x, int16_t y, int16_t w, int16_t h, const uint16_t *bitmap, uint16_t dx, uint16_t dy, uint16_t dw, uint16_t dh);
	boolean getBitmapPixel(const uint16_t* bitmap, uint16_t x, uint16_t y);

	
	void drawTilemap(int x, int y, const uint8_t *tilemap, const uint8_t **spritesheet);
	void drawTilemap(int x, int y, const uint8_t *tilemap, const uint8_t **spritesheet,uint8_t dx,uint8_t dy,uint8_t dw,uint8_t dh);

shetch

#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;

#define GREEN 0x0400 

const byte green_square[] PROGMEM ={16,16,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,};



void setup() {
  gb.begin();
  gb.titleScreen(F("test"));

}

void loop() {
 if(gb.update()){
  gb.display.drawBitmap(70, 70, green_square, 16, 16, GREEN);
 }

}

the errors point to this in the tilemap definition…

drawBitmap(drawX,drawY,tile_width,tile_height,spritesheet[tile]);

drawBitmap(drawX,drawY,tile_width,tile_height,spritesheet[tile],dx,dy,dw,dh);

drawTilemap(x,y,tilemap,spritesheet,0,0,LCDWIDTH,LCDHEIGHT);

Do I need to add color arguments to the tilemap cpp and .h elements how do fix the above errors?

EDITED::::::

OK the code above includes the unmodified bitmap functions as copied from the original gamebuino code. I just got finished re-doing the file so im down to the bitmap and tile map functions. The display file is too big to fit in one post so the included zip has the code but here are the errors.

Arduino: 1.6.11 (Windows 7), TD: 1.30-beta3, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz optimize speed (overclock), US English"

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:649:6: error: prototype for 'void Display::drawBitmap(int8_t, int8_t, const uint8_t*, uint8_t, uint8_t, uint16_t)' does not match any in class 'Display'

 void Display::drawBitmap(int8_t x, int8_t y, const uint8_t *bitmap, uint8_t rotation, uint8_t flip, uint16_t color) {

      ^

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:625:6: error: candidates are: void Display::drawBitmap(int8_t, int8_t, int8_t, int8_t, const uint8_t*, uint8_t, uint8_t, uint8_t, uint8_t, uint16_t)

 void Display::drawBitmap(int8_t x, int8_t y, int8_t w, int8_t h, const uint8_t *bitmap, uint8_t dx, uint8_t dy, uint8_t dw, uint8_t dh, uint16_t color) {

      ^

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:612:6: error:                 void Display::drawBitmap(int8_t, int8_t, int8_t, int8_t, const uint8_t*, uint16_t)

 void Display::drawBitmap(int8_t x, int8_t y, int8_t w, int8_t h, const uint8_t *bitmap, uint16_t color) {

      ^

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:605:6: error:                 void Display::drawBitmap(int8_t, int8_t, const uint8_t*, uint16_t)

 void Display::drawBitmap(int8_t x, int8_t y, const uint8_t *bitmap, uint16_t color) {

      ^

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp: In member function 'void Display::drawTilemap(int, int, const uint8_t*, const uint8_t**, uint8_t, uint8_t, uint8_t, uint8_t)':

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:742:72: error: no matching function for call to 'Display::drawBitmap(int8_t&, int8_t&, uint8_t&, uint8_t&, const uint8_t*&)'

     drawBitmap(drawX, drawY, tile_width, tile_height, spritesheet[tile]);

                                                                        ^

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:742:72: note: candidates are:

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:605:6: note: void Display::drawBitmap(int8_t, int8_t, const uint8_t*, uint16_t)

 void Display::drawBitmap(int8_t x, int8_t y, const uint8_t *bitmap, uint16_t color) {

      ^

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:605:6: note:   candidate expects 4 arguments, 5 provided

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:612:6: note: void Display::drawBitmap(int8_t, int8_t, int8_t, int8_t, const uint8_t*, uint16_t)

 void Display::drawBitmap(int8_t x, int8_t y, int8_t w, int8_t h, const uint8_t *bitmap, uint16_t color) {

      ^

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:612:6: note:   candidate expects 6 arguments, 5 provided

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:625:6: note: void Display::drawBitmap(int8_t, int8_t, int8_t, int8_t, const uint8_t*, uint8_t, uint8_t, uint8_t, uint8_t, uint16_t)

 void Display::drawBitmap(int8_t x, int8_t y, int8_t w, int8_t h, const uint8_t *bitmap, uint8_t dx, uint8_t dy, uint8_t dw, uint8_t dh, uint16_t color) {

      ^

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:625:6: note:   candidate expects 10 arguments, 5 provided

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:752:88: error: no matching function for call to 'Display::drawBitmap(int8_t&, int8_t&, uint8_t&, uint8_t&, const uint8_t*&, uint8_t&, uint8_t&, uint8_t&, uint8_t&)'

     drawBitmap(drawX, drawY, tile_width, tile_height, spritesheet[tile], dx, dy, dw, dh);

                                                                                        ^

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:752:88: note: candidates are:

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:605:6: note: void Display::drawBitmap(int8_t, int8_t, const uint8_t*, uint16_t)

 void Display::drawBitmap(int8_t x, int8_t y, const uint8_t *bitmap, uint16_t color) {

      ^

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:605:6: note:   candidate expects 4 arguments, 9 provided

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:612:6: note: void Display::drawBitmap(int8_t, int8_t, int8_t, int8_t, const uint8_t*, uint16_t)

 void Display::drawBitmap(int8_t x, int8_t y, int8_t w, int8_t h, const uint8_t *bitmap, uint16_t color) {

      ^

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:612:6: note:   candidate expects 6 arguments, 9 provided

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:625:6: note: void Display::drawBitmap(int8_t, int8_t, int8_t, int8_t, const uint8_t*, uint8_t, uint8_t, uint8_t, uint8_t, uint16_t)

 void Display::drawBitmap(int8_t x, int8_t y, int8_t w, int8_t h, const uint8_t *bitmap, uint8_t dx, uint8_t dy, uint8_t dw, uint8_t dh, uint16_t color) {

      ^

C:\Users\duhjoker\Documents\Arduino\libraries\Gamebuinocolor\src\DISPLAYRGB.cpp:625:6: note:   candidate expects 10 arguments, 9 provided

Error compiling for board Teensy 3.2 / 3.1.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

sketch

#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;

#define GREEN 0x0400 

const byte green_square[] PROGMEM ={16,16,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,
 B11111111,B11111111,};



void setup() {
  gb.begin();
  gb.titleScreen(F("test"));

}

void loop() {
 if(gb.update()){
  gb.display.drawBitmap(70, 70, 16, 16, green_square, GREEN);
 }

}

I don’t get the problem is. the functions in the h file match the definitions or prototype or whatever in the cpp file exactly. the only thing I have done is add the color arguments.