From b95b326352199c1b8933315292ed9cb2ba1c7472 Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Mon, 18 Nov 2019 14:08:07 +0800 Subject: [PATCH] correct menu flicker at the end of scrolling Signed-off-by: Vincent-FK --- RetroFE/Source/Menu/MenuMode.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/RetroFE/Source/Menu/MenuMode.cpp b/RetroFE/Source/Menu/MenuMode.cpp index c098370..2ae5ff2 100644 --- a/RetroFE/Source/Menu/MenuMode.cpp +++ b/RetroFE/Source/Menu/MenuMode.cpp @@ -3,6 +3,9 @@ #include "../SDL.h" /// -------------- DEFINES -------------- +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) + //#define MENU_DEBUG #define MENU_ERROR @@ -847,19 +850,19 @@ void MenuMode::launch( ) } /// --------- Handle Scroll effect --------- - if (scroll>0){ - scroll+=SCROLL_SPEED_PX; - screen_refresh = 1; - } - if (scroll<0){ - scroll-=SCROLL_SPEED_PX; - screen_refresh = 1; - } - if (scroll>MENU_ZONE_HEIGHT || scroll<-MENU_ZONE_HEIGHT) { + if (scroll>=MENU_ZONE_HEIGHT || scroll<=-MENU_ZONE_HEIGHT) { prevItem=menuItem; scroll=0; screen_refresh = 1; } + else if (scroll>0){ + scroll+=MIN(SCROLL_SPEED_PX, MENU_ZONE_HEIGHT-scroll); + screen_refresh = 1; + } + else if (scroll<0){ + scroll-=MIN(SCROLL_SPEED_PX, MENU_ZONE_HEIGHT+scroll); + screen_refresh = 1; + } /// --------- Handle FPS --------- cur_ms = SDL_GetTicks();