I can almost simply put it into my display.h and .cpp files and call it in sketch. Just needs a lil tweaking.
for instance.... I need this bit of code written so I can use the draw from command to create tilemaps easily and cheaply.
- Code: Select all
//GAMEBUINO
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) {
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(x, y, color);
}
}
}
}
}
so I can use it with these
- Code: Select all
void Display::drawTilemap(int x, int y, const uint8_t *tilemap, const uint8_t **spritesheet, uint16_t color) {
drawTilemap(x, y, tilemap, spritesheet, 0, 0, LCDWIDTH, LCDHEIGHT, color);
}
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, uint16_t color) {
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)) {
drawBitmap1(drawX, drawY, spritesheet[tile], tile_width, tile_height, color);
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, color);
}
}
}
}
ive only created a couple simple functions so I don't know how to proceed.
thank you also sutchig as adding those includes fixed the tx rx problem.but...........
now im having problems with the teensy 3.2`s print.h file which defines BYTE as 0, don't know what to do about that either. it wont compile because of byte in the pff.h file
I'm also getting a dstatus does not name a type in diskio #28:1
On the DrawBitMapfromSD example it has two draw bit map commands the drawbitmapfromSD and function and another that's says draw inverted color bitmap from SRAM. Am I to understand that the actual drawbitmapfromSD function uses the drawBitMap from sram function in order to actually put it together and draw the bitmap from the data retrieved from the drawbitmapfromSD function? If that made any since at all.
Edit: ok I'm having problems with both byte in the petitfatfs integer.h and teensy's print.h with the define byte 0. I've tried a couple things like undefinining it and marking it out but I'm pretty marking it out in print.h is not going to work And I'm still having trouble with the RX TX stuff. Error still points to loop_until_byte_is_set specifically the variable spif,