From 141c7817a07d1af1395d32997de710f787fcc0de Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 15 Nov 2016 14:08:58 +0100 Subject: [PATCH] Cleanup --- source/config.c | 2 +- source/draw.c | 2 +- source/pin.c | 2 +- source/screen.c | 36 ++++++++++++------------------------ source/screen.h | 2 +- source/utils.c | 2 +- 6 files changed, 17 insertions(+), 29 deletions(-) diff --git a/source/config.c b/source/config.c index 391216f..f697917 100644 --- a/source/config.c +++ b/source/config.c @@ -355,7 +355,7 @@ void configMenu(bool isSdMode, bool oldPinStatus, u32 oldPinMode) if(isMultiOption) drawString(multiOptionsText[selectedOption], true, 10, multiOptions[selectedOption].posY, COLOR_RED); else drawString(singleOptionsText[singleSelected], true, 10, singleOptions[singleSelected].posY, COLOR_RED); - clearScreens(false, true, false); + drawString(optionsDescription[oldSelectedOption], false, 10, 10, COLOR_BLACK); drawString(optionsDescription[selectedOption], false, 10, 10, COLOR_WHITE); } else diff --git a/source/draw.c b/source/draw.c index 4852a74..1dcf821 100644 --- a/source/draw.c +++ b/source/draw.c @@ -46,7 +46,7 @@ bool loadSplash(void) else { initScreens(); - clearScreens(true, true, true); + clearScreens(true); if(isTopSplashValid) isTopSplashValid = fileRead(fbs[1].top_left, topSplashFile, SCREEN_TOP_FBSIZE) == SCREEN_TOP_FBSIZE; if(isBottomSplashValid) isBottomSplashValid = fileRead(fbs[1].bottom, bottomSplashFile, SCREEN_BOTTOM_FBSIZE) == SCREEN_BOTTOM_FBSIZE; diff --git a/source/pin.c b/source/pin.c index 185230e..238d216 100644 --- a/source/pin.c +++ b/source/pin.c @@ -46,7 +46,7 @@ static char pinKeyToLetter(u32 pressed) void newPin(bool allowSkipping, u32 pinMode) { - clearScreens(true, true, false); + clearScreens(false); u8 length = 4 + 2 * (pinMode - 1); diff --git a/source/screen.c b/source/screen.c index 58d0c4a..9b44da6 100644 --- a/source/screen.c +++ b/source/screen.c @@ -127,14 +127,10 @@ void swapFramebuffers(bool isAlternate) invokeArm11Function(ARM11); } -void clearScreens(bool clearTop, bool clearBottom, bool clearAlternate) +void clearScreens(bool isAlternate) { - static bool clearTopTmp, - clearBottomTmp; static volatile struct fb *fbTmp; - clearTopTmp = clearTop; - clearBottomTmp = clearBottom; - fbTmp = clearAlternate ? &fbs[1] : &fbs[0]; + fbTmp = isAlternate ? &fbs[1] : &fbs[0]; void __attribute__((naked)) ARM11(void) { @@ -146,29 +142,21 @@ void clearScreens(bool clearTop, bool clearBottom, bool clearAlternate) vu32 *REGs_PSC0 = (vu32 *)0x10400010, *REGs_PSC1 = (vu32 *)0x10400020; - if(clearTopTmp) - { - REGs_PSC0[0] = (u32)fbTmp->top_left >> 3; //Start address - REGs_PSC0[1] = (u32)(fbTmp->top_left + SCREEN_TOP_FBSIZE) >> 3; //End address - REGs_PSC0[2] = 0; //Fill value - REGs_PSC0[3] = (2 << 8) | 1; //32-bit pattern; start - } + REGs_PSC0[0] = (u32)fbTmp->top_left >> 3; //Start address + REGs_PSC0[1] = (u32)(fbTmp->top_left + SCREEN_TOP_FBSIZE) >> 3; //End address + REGs_PSC0[2] = 0; //Fill value + REGs_PSC0[3] = (2 << 8) | 1; //32-bit pattern; start - if(clearBottomTmp) - { - REGs_PSC1[0] = (u32)fbTmp->bottom >> 3; //Start address - REGs_PSC1[1] = (u32)(fbTmp->bottom + SCREEN_BOTTOM_FBSIZE) >> 3; //End address - REGs_PSC1[2] = 0; //Fill value - REGs_PSC1[3] = (2 << 8) | 1; //32-bit pattern; start - } + REGs_PSC1[0] = (u32)fbTmp->bottom >> 3; //Start address + REGs_PSC1[1] = (u32)(fbTmp->bottom + SCREEN_BOTTOM_FBSIZE) >> 3; //End address + REGs_PSC1[2] = 0; //Fill value + REGs_PSC1[3] = (2 << 8) | 1; //32-bit pattern; start - while(!((!clearTopTmp || (REGs_PSC0[3] & 2)) && (!clearBottomTmp || (REGs_PSC1[3] & 2)))); + while(!((REGs_PSC0[3] & 2) && (REGs_PSC1[3] & 2))); WAIT_FOR_ARM9(); } - flushDCacheRange(&clearTopTmp, 1); - flushDCacheRange(&clearBottomTmp, 1); flushDCacheRange((void *)fbTmp, sizeof(struct fb)); flushDCacheRange(&fbTmp, 4); invokeArm11Function(ARM11); @@ -305,6 +293,6 @@ void initScreens(void) needToSetup = false; } - clearScreens(true, true, false); + clearScreens(false); swapFramebuffers(false); } \ No newline at end of file diff --git a/source/screen.h b/source/screen.h index 9fd41ca..22ccce2 100644 --- a/source/screen.h +++ b/source/screen.h @@ -53,5 +53,5 @@ extern CfgData configData; void deinitScreens(void); void swapFramebuffers(bool isAlternate); void updateBrightness(u32 brightnessIndex); -void clearScreens(bool clearTop, bool clearBottom, bool clearAlternate); +void clearScreens(bool isAlternate); void initScreens(void); \ No newline at end of file diff --git a/source/utils.c b/source/utils.c index c82b3d5..28d31c1 100644 --- a/source/utils.c +++ b/source/utils.c @@ -90,7 +90,7 @@ u32 waitInput(bool isMenu) void mcuPowerOff(void) { - if(!ISFIRMLAUNCH && ARESCREENSINITED) clearScreens(true, true, false); + if(!ISFIRMLAUNCH && ARESCREENSINITED) clearScreens(false); //Ensure that all memory transfers have completed and that the data cache has been flushed flushEntireDCache();