From e81ac251cb589f8af90170225b26242d9efc05f0 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 1 Jun 2020 17:11:15 +0200 Subject: [PATCH] fix relative progress bounds --- twinmax/display.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); }