diff options
Diffstat (limited to 'Gfx.cpp')
| -rw-r--r-- | Gfx.cpp | 149 |
1 files changed, 71 insertions, 78 deletions
@@ -1,27 +1,26 @@ /* ************************************* - * Includes + * Includes * *************************************/ #include "Gfx.h" /* ************************************* - * Defines + * Defines * *************************************/ /* ************************************* - * Structs and enums + * Structs and enums * *************************************/ /* ************************************* - * Local variables + * Local variables * *************************************/ static bool GfxIsInsideScreenArea(int8_t x, int8_t y, uint8_t w, uint8_t h); void GfxInit(void) { - gb.display.persistence = false; // Clears screen automatically - gb.display.setFont(font3x5); + gb.display.persistence = true; /* Clears screen automatically. */ } void GfxDrawSprite(TYPE_SPRITE* ptrSprite) @@ -31,131 +30,125 @@ void GfxDrawSprite(TYPE_SPRITE* ptrSprite) return; } - if (GfxIsSpriteInsideScreenArea(ptrSprite) != false) - { - int8_t orig_color = gb.display.getColor(); + if (GfxIsSpriteInsideScreenArea(ptrSprite) != false) + { + int8_t orig_color = gb.display.getColor(); - gb.display.setColor(ptrSprite->color, GFX_WHITE); - gb.display.drawBitmap( ptrSprite->x, - ptrSprite->y, - ptrSprite->Data, - ptrSprite->rotation, - ptrSprite->flip ); + gb.display.setColor(ptrSprite->color, GFX_WHITE); + gb.display.drawBitmap( ptrSprite->x, + ptrSprite->y, + ptrSprite->Data, + ptrSprite->rotation, + ptrSprite->flip ); - gb.display.setColor(orig_color); - } + gb.display.setColor(orig_color); + } } bool GfxRefreshNeeded(void) { - return gb.update(); + return gb.update(); } void GfxShowKeyboard(char* str, uint8_t length) { - gb.keyboard(str, length); -} - -void GfxClearScreen(void) -{ - gb.display.fillScreen(GFX_WHITE); - gb.display.clear(); + gb.keyboard(str, length); } bool GfxIsInsideScreenArea(int8_t x, int8_t y, uint8_t w, uint8_t h) { - if ( ( (x + w) >= 0) - && - (x < X_SCREEN_RESOLUTION) - && - ( (y + h) >= 0) - && - (y < Y_SCREEN_RESOLUTION) ) - { - return true; - } + if ( ( (x + w) >= 0) + && + (x < X_SCREEN_RESOLUTION) + && + ( (y + h) >= 0) + && + (y < Y_SCREEN_RESOLUTION) ) + { + return true; + } - return false; + return false; } bool GfxIsSpriteInsideScreenArea(TYPE_SPRITE* spr) { - return GfxIsInsideScreenArea(spr->x, spr->y, spr->w, spr->h); + return GfxIsInsideScreenArea(spr->x, spr->y, spr->w, spr->h); } uint8_t GfxGetWidthFromSpriteData(const uint8_t* sprData) { - // On Gamebuino bitmaps, width is always stored on first byte. - return pgm_read_byte_near(&sprData[0]); + /* On Gamebuino bitmaps, width is always stored on first byte.. */ + return pgm_read_byte_near(&sprData[0]); } uint8_t GfxGetHeightFromSpriteData(const uint8_t* sprData) { - // On Gamebuino bitmaps, height is always stored on second byte. - return pgm_read_byte_near(&sprData[1]); + /* On Gamebuino bitmaps, height is always stored on second byte.. */ + return pgm_read_byte_near(&sprData[1]); } void GfxPrintText_Flash(const __FlashStringHelper * str) { - gb.popup(str, 20 * 3 /* 3 seconds */); + gb.popup(str, 20 * 3 /* 3 seconds */); } void GfxPrintTextFont(const char* str, const uint8_t* font, uint8_t x, uint8_t y) { - uint8_t* orig_font = gb.display.getFont(); + uint8_t* orig_font = gb.display.getFont(); - gb.display.cursorX = x; - gb.display.cursorY = y; + gb.display.cursorX = x; + gb.display.cursorY = y; - gb.display.setFont(font); + gb.display.setFont(font); - gb.display.setColor(GFX_BLACK, GFX_WHITE); + gb.display.setColor(GFX_BLACK, GFX_WHITE); - gb.display.print(str); + gb.display.print(str); - if (orig_font != NULL) - { - gb.display.setFont(orig_font); - } + if (orig_font != NULL) + { + gb.display.setFont(orig_font); + } } void GfxPrintText(const char* str, uint8_t x, uint8_t y) { - GfxPrintTextFont(str, font3x5, x, y); + GfxPrintTextFont(str, font3x5, x, y); } void GfxDrawCircle(uint16_t x, uint16_t y, uint8_t radius, int8_t color) { - if (GfxIsInsideScreenArea(x, y, radius, radius) != false) - { - int8_t orig_color = gb.display.getColor(); - gb.display.setColor(color); - gb.display.drawCircle(x, y, radius); - gb.display.setColor(orig_color); - } + if (GfxIsInsideScreenArea(x, y, radius, radius) != false) + { + int8_t orig_color = gb.display.getColor(); + gb.display.setColor(color); + gb.display.drawCircle(x, y, radius); + gb.display.setColor(orig_color); + } } void GfxDrawFillCircle(uint16_t x, uint16_t y, uint8_t radius, int8_t color) { if (GfxIsInsideScreenArea(x, y, radius, radius) != false) - { + { int8_t orig_color = gb.display.getColor(); - gb.display.setColor(color); - gb.display.fillCircle(x, y, radius); - gb.display.setColor(orig_color); + gb.display.setColor(color); + gb.display.fillCircle(x, y, radius); + gb.display.setColor(orig_color); } } void GfxDrawRectangle(uint8_t x, uint8_t y, uint8_t w, uint8_t h, int8_t color) { - if (GfxIsInsideScreenArea(x, y, w, h) != false) - { - int8_t orig_color = gb.display.getColor(); + if (GfxIsInsideScreenArea(x, y, w, h) != false) + { + int8_t orig_color = gb.display.getColor(); - gb.display.setColor(color); - gb.display.drawRect(x, y, w, h); - gb.display.setColor(orig_color); - } + gb.display.setColor(color); + gb.display.drawRect(x, y, w, h); + gb.display.setColor(orig_color); + } } void GfxDrawLine(uint8_t x0, uint8_t x1, uint8_t y0, uint8_t y1, uint8_t color) @@ -166,12 +159,12 @@ void GfxDrawLine(uint8_t x0, uint8_t x1, uint8_t y0, uint8_t y1, uint8_t color) void GfxFillRectangle(uint8_t x, uint8_t y, uint8_t w, uint8_t h, int8_t color) { - if (GfxIsInsideScreenArea(x, y, w, h) != false) - { - int8_t orig_color = gb.display.getColor(); + if (GfxIsInsideScreenArea(x, y, w, h) != false) + { + int8_t orig_color = gb.display.getColor(); - gb.display.setColor(color); - gb.display.fillRect(x, y, w, h); - gb.display.setColor(orig_color); - } + gb.display.setColor(color); + gb.display.fillRect(x, y, w, h); + gb.display.setColor(orig_color); + } } |
