diff --git a/twinmax/display.cpp b/twinmax/display.cpp index 7cc79e7..59fc47b 100644 --- a/twinmax/display.cpp +++ b/twinmax/display.cpp @@ -196,11 +196,11 @@ void Display::progress(const short progress, const uint8_t startLine, const uint setPixel(64, endLine, true); } - uint16_t scaledProgress = (progress+7) / 8; + int16_t scaledProgress = (progress+7) / 8; // draw absolute progression if( absolute ){ - for( uint8_t x = 0 ; x < scaledProgress ; x++ ){ + for( uint8_t x = 0 ; x < scaledProgress && x < 128 ; x++ ){ for( uint8_t y = startLine+1 ; y < endLine ; y++ ){ setPixel(x, y, true); } @@ -211,7 +211,7 @@ void Display::progress(const short progress, const uint8_t startLine, const uint // draw left relative progression if( progress < 512 ){ - for( uint8_t x = scaledProgress ; x < 64 ; x++ ){ + for( int16_t x = 64 ; x > scaledProgress && x >= 0 ; x-- ){ for( uint8_t y = startLine+1 ; y < endLine ; y++ ){ setPixel(x, y, true); } @@ -220,7 +220,7 @@ void Display::progress(const short progress, const uint8_t startLine, const uint // draw right relative progression } else { - for( uint8_t x = 64 ; x < scaledProgress ; x++ ){ + for( uint8_t x = 64 ; x < scaledProgress && x < 128 ; x++ ){ for( uint8_t y = startLine+1 ; y < endLine ; y++ ){ setPixel(x, y, true); }