From f8e1bc60644b6d7e926bb381ea2fd31e8e42729c Mon Sep 17 00:00:00 2001 From: RocketRobz Date: Mon, 12 Aug 2024 22:09:17 -0600 Subject: [PATCH] Reduce battery usage by only re-drawing 3D screen layer when changed --- quickmenu/arm9/source/graphics/graphics.cpp | 87 ++++- quickmenu/arm9/source/ndsheaderbanner.cpp | 5 +- quickmenu/arm9/source/ndsheaderbanner.h | 2 +- romsel_aktheme/arm9/source/fileBrowse.cpp | 9 + .../arm9/source/graphics/graphics.cpp | 148 +++++---- .../arm9/source/ndsheaderbanner.cpp | 5 +- romsel_aktheme/arm9/source/ndsheaderbanner.h | 2 +- .../arm9/source/graphics/graphics.cpp | 308 +++++++++++------- .../arm9/source/ndsheaderbanner.cpp | 5 +- .../arm9/source/ndsheaderbanner.h | 2 +- .../arm9/source/graphics/graphics.cpp | 108 ++++-- romsel_r4theme/arm9/source/iconTitle.cpp | 34 ++ .../arm9/source/ndsheaderbanner.cpp | 5 +- romsel_r4theme/arm9/source/ndsheaderbanner.h | 2 +- 14 files changed, 475 insertions(+), 247 deletions(-) diff --git a/quickmenu/arm9/source/graphics/graphics.cpp b/quickmenu/arm9/source/graphics/graphics.cpp index 7f00e64c14..8aa79b2f91 100644 --- a/quickmenu/arm9/source/graphics/graphics.cpp +++ b/quickmenu/arm9/source/graphics/graphics.cpp @@ -76,6 +76,7 @@ int progressBarLength = 0; float cursorTargetTL = 0.0f, cursorTargetTR = 0.0f, cursorTargetBL = 0.0f, cursorTargetBR = 0.0f; float cursorTL = 0.0f, cursorTR = 0.0f, cursorBL = 0.0f, cursorBR = 0.0f; +float cursorTLPrev = 0.0f, cursorTRPrev = 0.0f, cursorBLPrev = 0.0f, cursorBRPrev = 0.0f; extern int spawnedtitleboxes; @@ -583,7 +584,7 @@ auto getMenuEntryTexture(MenuEntry entry) { void vBlankHandler() { - if (fadeType == true) { + if (fadeType) { if (!fadeDelay) { screenBrightness--; if (screenBrightness < 0) screenBrightness = 0; @@ -607,13 +608,79 @@ void vBlankHandler() } } + static bool updateFrame = true; + static bool whiteScreenPrev = whiteScreen; + static bool showProgressBarPrev = showProgressBar; + static int progressBarLengthPrev = progressBarLength; + static bool showCursorPrev = showCursor; + static bool startMenuPrev = startMenu; + + if (whiteScreenPrev != whiteScreen) { + whiteScreenPrev = whiteScreen; + updateFrame = true; + } + + if (showProgressBarPrev != showProgressBar) { + showProgressBarPrev = showProgressBar; + updateFrame = true; + } + + if (progressBarLengthPrev != progressBarLength) { + progressBarLengthPrev = progressBarLength; + updateFrame = true; + } + + if (showCursorPrev != showCursor) { + showCursorPrev = showCursor; + updateFrame = true; + } + + if (startMenuPrev != startMenu) { + startMenuPrev = startMenu; + updateFrame = true; + } + + if (!whiteScreen && startMenu) { + for (int i = 0; i < 2; i++) { + if (bnriconisDSi[i] && playBannerSequence(i)) { + updateFrame = true; + } + } + for (int i = 0; i < 7; i++) { + if (moveIconUp[i]) { + iconYpos[i] -= 6; + updateFrame = true; + } + } + } + constexpr float swiftness = 0.25f; cursorTL += (cursorTargetTL - cursorTL) * swiftness; cursorBL += (cursorTargetBL - cursorBL) * swiftness; cursorTR += (cursorTargetTR - cursorTR) * swiftness; cursorBR += (cursorTargetBR - cursorBR) * swiftness; - { + if (cursorTLPrev != cursorTL) { + cursorTLPrev = cursorTL; + updateFrame = true; + } + + if (cursorBLPrev != cursorBL) { + cursorBLPrev = cursorBL; + updateFrame = true; + } + + if (cursorTRPrev != cursorTR) { + cursorTRPrev = cursorTR; + updateFrame = true; + } + + if (cursorBRPrev != cursorBR) { + cursorBRPrev = cursorBR; + updateFrame = true; + } + + if (updateFrame) { glBegin2D(); { if (controlBottomBright) SetBrightness(0, screenBrightness); @@ -643,10 +710,6 @@ void vBlankHandler() } else drawIcon(1, 40, iconYpos[0]+6); if (bnrWirelessIcon[1] > 0) glSprite(207, iconYpos[0]+30, GL_FLIP_NONE, &wirelessicons.images[(bnrWirelessIcon[0]-1) & 31]); } - // Playback animated icon - if (bnriconisDSi[0]==true) { - playBannerSequence(0); - } glSprite(33, iconYpos[1], GL_FLIP_NONE, getMenuEntryTexture(MenuEntry::PICTOCHAT)); glSprite(129, iconYpos[2], GL_FLIP_NONE, getMenuEntryTexture(MenuEntry::DOWNLOADPLAY)); glSprite(33, iconYpos[3], GL_FLIP_NONE, getMenuEntryTexture(MenuEntry::GBA)); @@ -659,10 +722,6 @@ void vBlankHandler() glSprite(10, iconYpos[4], GL_FLIP_NONE, getMenuEntryTexture(MenuEntry::BRIGHTNESS)); } if (bnrWirelessIcon[num] > 0) glSprite(207, iconYpos[3]+30, GL_FLIP_NONE, &wirelessicons.images[(bnrWirelessIcon[1]-1) & 31]); - // Playback animated icon - if (bnriconisDSi[1]==true) { - playBannerSequence(1); - } if (!ms().kioskMode) { glSprite(117, iconYpos[5], GL_FLIP_NONE, getMenuEntryTexture(MenuEntry::SETTINGS)); } @@ -699,14 +758,6 @@ void vBlankHandler() glEnd2D(); GFX_FLUSH = 0; } - - if (!whiteScreen) { - for (int i = 0; i < 7; i++) { - if (moveIconUp[i]) { - iconYpos[i] -= 6; - } - } - } } static void clockNeedleDraw(int angle, u32 length, u16 color) { diff --git a/quickmenu/arm9/source/ndsheaderbanner.cpp b/quickmenu/arm9/source/ndsheaderbanner.cpp index 320a29203c..eaebb5759a 100644 --- a/quickmenu/arm9/source/ndsheaderbanner.cpp +++ b/quickmenu/arm9/source/ndsheaderbanner.cpp @@ -148,7 +148,7 @@ int currentbnriconframeseq[2] = {0}; * Play banner sequence. * @param binFile Banner file. */ -void playBannerSequence(int num) +bool playBannerSequence(int num) { if (bnriconframeseq[num][currentbnriconframeseq[num] + 1] == 0x0100) { // Do nothing if icon isn't animated @@ -179,6 +179,9 @@ void playBannerSequence(int num) if (bnriconframeseq[num][currentbnriconframeseq[num]] == 0x0000) { currentbnriconframeseq[num] = 0; // Reset sequence } + return true; } } + + return false; } diff --git a/quickmenu/arm9/source/ndsheaderbanner.h b/quickmenu/arm9/source/ndsheaderbanner.h index 784d6f19b6..40f05ffefc 100644 --- a/quickmenu/arm9/source/ndsheaderbanner.h +++ b/quickmenu/arm9/source/ndsheaderbanner.h @@ -336,6 +336,6 @@ void clearBannerSequence(int num); * Play banner sequence. * @param binFile Banner file. */ -void playBannerSequence(int num); +bool playBannerSequence(int num); #endif // NDS_HEADER2 diff --git a/romsel_aktheme/arm9/source/fileBrowse.cpp b/romsel_aktheme/arm9/source/fileBrowse.cpp index f06482dbf7..af246f1407 100644 --- a/romsel_aktheme/arm9/source/fileBrowse.cpp +++ b/romsel_aktheme/arm9/source/fileBrowse.cpp @@ -104,6 +104,14 @@ extern touchPosition touch; extern void bgOperations(bool waitFrame); +static inline void doFrameUpdate(void) { + extern bool updateFrame; + while (updateFrame) { + swiWaitForVBlank(); + } + updateFrame = true; +} + int file_count = 0; static int fileStartPos = 0; // The position of the first thing that is not a directory. @@ -513,6 +521,7 @@ void loadIcons(const int screenOffset, std::vector dirContents) { } displayDiskIcon(false); + doFrameUpdate(); updateText(false); } diff --git a/romsel_aktheme/arm9/source/graphics/graphics.cpp b/romsel_aktheme/arm9/source/graphics/graphics.cpp index 078c9aadf8..50f9aef89d 100644 --- a/romsel_aktheme/arm9/source/graphics/graphics.cpp +++ b/romsel_aktheme/arm9/source/graphics/graphics.cpp @@ -58,6 +58,7 @@ int screenBrightness = 0; bool lcdSwapped = false; static bool secondBuffer = false; bool doubleBuffer = true; +bool updateFrame = true; static int colonTimer = 0; static bool showColon = true; @@ -1560,22 +1561,87 @@ static void loadPng(const bool top, const std::string filename) { void vBlankHandler() { - glBegin2D(); - { - if (fadeType) { - screenBrightness--; - if (screenBrightness < 0) screenBrightness = 0; - } else { - screenBrightness++; - if (screenBrightness > 31) screenBrightness = 31; - } - if (ms().macroMode) { - SetBrightness(0, lcdSwapped ? screenBrightness : 31); - SetBrightness(1, !lcdSwapped ? screenBrightness : 31); - } else { - if (controlBottomBright) SetBrightness(0, screenBrightness); - if (controlTopBright) SetBrightness(1, screenBrightness); + if (fadeType) { + screenBrightness--; + if (screenBrightness < 0) screenBrightness = 0; + } else { + screenBrightness++; + if (screenBrightness > 31) screenBrightness = 31; + } + if (ms().macroMode) { + SetBrightness(0, lcdSwapped ? screenBrightness : 31); + SetBrightness(1, !lcdSwapped ? screenBrightness : 31); + } else { + if (controlBottomBright) SetBrightness(0, screenBrightness); + if (controlTopBright) SetBrightness(1, screenBrightness); + } + + static bool showdialogboxPrev = showdialogbox; + static int dialogboxHeightPrev = dialogboxHeight; + + if (showdialogboxPrev != showdialogbox) { + showdialogboxPrev = showdialogbox; + updateFrame = true; + } + + if (showdialogbox && (dialogboxHeightPrev != dialogboxHeight)) { + dialogboxHeightPrev = dialogboxHeight; + updateFrame = true; + } + + if (displayIcons && iconsToDisplay > 0) { + for (int i = 0; i < iconsToDisplay; i++) { + if (bnriconisDSi[i] && playBannerSequence(i)) { + updateFrame = true; + } + } + if (iconScaleEnabled) { + if (!iconScaleDelay) { + if (iconScaleLarge) { + iconScale += 110; + if (iconScale == 110) { + iconShift = 1; + } else if (iconScale == 330) { + iconShift = 2; + } else if (iconScale == 550) { + iconShift = 3; + } else if (iconScale == 660) { + iconScaleLarge = false; + } + } else { + iconScale -= 110; + if (iconScale == 330) { + iconShift = 2; + } else if (iconScale == 110) { + iconShift = 1; + } else if (iconScale == 0) { + iconShift = 0; + iconScaleLarge = true; + } + } + updateFrame = true; + } + if (iconScaleDelay++ == 2) { + iconScaleDelay = 0; + } + } else if (ms().ak_zoomIcons) { + if (iconScaleWait++ == 60) { + iconScaleWait = 0; + iconScaleEnabled = true; + } } + } + + // Blink colon once per second + if (colonTimer >= 60) { + colonTimer = 0; + showColon = !showColon; + } + + colonTimer++; + + if (updateFrame) { + glBegin2D(); // glColor(RGB15(31, 31-(3*blfLevel), 31-(6*blfLevel))); glColor(RGB15(31, 31, 31)); @@ -1591,46 +1657,6 @@ void vBlankHandler() drawIcon(i, 5, 22+(i*38), 0); } // if (bnrWirelessIcon > 0) glSprite(24, 12, GL_FLIP_NONE, &wirelessIcons[(bnrWirelessIcon-1) & 31]); - // Playback animated icons - // if (!stopDSiAnim && bnriconisDSi[i]) { - if (bnriconisDSi[i]) { - playBannerSequence(i); - } - // stopDSiAnimNotif = stopDSiAnim; - } - if (iconScaleEnabled) { - if (!iconScaleDelay) { - if (iconScaleLarge) { - iconScale += 110; - if (iconScale == 110) { - iconShift = 1; - } else if (iconScale == 330) { - iconShift = 2; - } else if (iconScale == 550) { - iconShift = 3; - } else if (iconScale == 660) { - iconScaleLarge = false; - } - } else { - iconScale -= 110; - if (iconScale == 330) { - iconShift = 2; - } else if (iconScale == 110) { - iconShift = 1; - } else if (iconScale == 0) { - iconShift = 0; - iconScaleLarge = true; - } - } - } - if (iconScaleDelay++ == 2) { - iconScaleDelay = 0; - } - } else if (ms().ak_zoomIcons) { - if (iconScaleWait++ == 60) { - iconScaleWait = 0; - iconScaleEnabled = true; - } } } if (showdialogbox) { @@ -1647,18 +1673,12 @@ void vBlankHandler() } else { vblankRefreshCounter++; } - } - glEnd2D(); - GFX_FLUSH = 0; - // Blink colon once per second - if (colonTimer >= 60) { - colonTimer = 0; - showColon = !showColon; + glEnd2D(); + GFX_FLUSH = 0; + updateFrame = false; } - colonTimer++; - if (doubleBuffer) { dmaCopyHalfWordsAsynch(0, topImageWithText[secondBuffer], BG_GFX_SUB, 0x18000); dmaCopyHalfWordsAsynch(1, bottomImageWithBar[secondBuffer], BG_GFX, 0x18000); diff --git a/romsel_aktheme/arm9/source/ndsheaderbanner.cpp b/romsel_aktheme/arm9/source/ndsheaderbanner.cpp index 958ec995f4..19046da196 100644 --- a/romsel_aktheme/arm9/source/ndsheaderbanner.cpp +++ b/romsel_aktheme/arm9/source/ndsheaderbanner.cpp @@ -618,7 +618,7 @@ void clearBannerSequence(int iconnum) * Play banner sequence. * @param binFile Banner file. */ -void playBannerSequence(int iconnum) +bool playBannerSequence(int iconnum) { if (bnriconframeseq[iconnum][currentbnriconframeseq[iconnum] + 1] == 0x0100) { // Do nothing if icon isn't animated @@ -649,6 +649,9 @@ void playBannerSequence(int iconnum) if (bnriconframeseq[iconnum][currentbnriconframeseq[iconnum]] == 0x0000) { currentbnriconframeseq[iconnum] = 0; // Reset sequence } + return true; } } + + return false; } diff --git a/romsel_aktheme/arm9/source/ndsheaderbanner.h b/romsel_aktheme/arm9/source/ndsheaderbanner.h index 9ddf3bfdd7..1209ce0471 100644 --- a/romsel_aktheme/arm9/source/ndsheaderbanner.h +++ b/romsel_aktheme/arm9/source/ndsheaderbanner.h @@ -324,6 +324,6 @@ void clearBannerSequence(int iconnum); * Play banner sequence. * @param binFile Banner file. */ -void playBannerSequence(int iconnum); +bool playBannerSequence(int iconnum); #endif // NDS_HEADER2 diff --git a/romsel_dsimenutheme/arm9/source/graphics/graphics.cpp b/romsel_dsimenutheme/arm9/source/graphics/graphics.cpp index 8ade619bc3..251dc680da 100644 --- a/romsel_dsimenutheme/arm9/source/graphics/graphics.cpp +++ b/romsel_dsimenutheme/arm9/source/graphics/graphics.cpp @@ -183,9 +183,7 @@ int rocketVideo_currentFrame = -1; u8 rocketVideo_fps = 25; u8 rocketVideo_height = 56; int rocketVideo_frameDelay = 0; -int frameDelay = 0; -bool frameDelayEven = true; // For 24FPS -bool rocketVideo_frameDelayEven = true; +bool rocketVideo_frameDelayEven = true; // For 24FPS bool rocketVideo_loadFrame = true; u16* colorTable = NULL; @@ -403,29 +401,78 @@ void vBlankHandler() { needToPlayStopSound = false; } + static bool updateFrame = true; + static bool whiteScreenPrev = whiteScreen; + static bool showSTARTborderPrev = showSTARTborder; + static bool displayGameIconsPrev = displayGameIcons; + static bool showProgressIconPrev = showProgressIcon; + static bool showProgressBarPrev = showProgressBar; + static int progressBarLengthPrev = progressBarLength; + static bool dbox_showIconPrev = dbox_showIcon; + + if (whiteScreenPrev != whiteScreen) { + whiteScreenPrev = whiteScreen; + updateFrame = true; + } + + if (showSTARTborderPrev != showSTARTborder) { + showSTARTborderPrev = showSTARTborder; + updateFrame = true; + } + + if (displayGameIconsPrev != displayGameIcons) { + displayGameIconsPrev = displayGameIcons; + updateFrame = true; + } + + if (showProgressIconPrev != showProgressIcon) { + showProgressIconPrev = showProgressIcon; + updateFrame = true; + } + + if (showProgressBarPrev != showProgressBar) { + showProgressBarPrev = showProgressBar; + updateFrame = true; + } + + if (progressBarLengthPrev != progressBarLength) { + progressBarLengthPrev = progressBarLength; + updateFrame = true; + } + + if (dbox_showIconPrev != dbox_showIcon) { + dbox_showIconPrev = dbox_showIcon; + updateFrame = true; + } + // Move title box/window closer to destination if moved if (ms().theme != TWLSettings::EThemeSaturn) { if (titleboxXpos[ms().secondaryDevice] > titleboxXdest[ms().secondaryDevice]) { titleboxXpos[ms().secondaryDevice] -= std::max((titleboxXpos[ms().secondaryDevice] - titleboxXdest[ms().secondaryDevice]) / titleboxXspeed, 1); + updateFrame = true; } else if (titleboxXpos[ms().secondaryDevice] < titleboxXdest[ms().secondaryDevice]) { titleboxXpos[ms().secondaryDevice] += std::max((titleboxXdest[ms().secondaryDevice] - titleboxXpos[ms().secondaryDevice]) / titleboxXspeed, 1); + updateFrame = true; } if (titlewindowXpos[ms().secondaryDevice] > titlewindowXdest[ms().secondaryDevice]) { titlewindowXpos[ms().secondaryDevice] -= std::max((titlewindowXpos[ms().secondaryDevice] - titlewindowXdest[ms().secondaryDevice]) / titleboxXspeed, 1); + updateFrame = true; } else if (titlewindowXpos[ms().secondaryDevice] < titlewindowXdest[ms().secondaryDevice]) { titlewindowXpos[ms().secondaryDevice] += std::max((titlewindowXdest[ms().secondaryDevice] - titlewindowXpos[ms().secondaryDevice]) / titleboxXspeed, 1); + updateFrame = true; } - } else { // In saturn theme just move instantly + } else if (titleboxXpos[ms().secondaryDevice] != titleboxXdest[ms().secondaryDevice]) { // In saturn theme just move instantly titleboxXpos[ms().secondaryDevice] = titleboxXdest[ms().secondaryDevice]; titlewindowXpos[ms().secondaryDevice] = titlewindowXdest[ms().secondaryDevice]; + updateFrame = true; } if (ms().theme == TWLSettings::ETheme3DS && rotatingCubesLoaded) { playRotatingCubesVideo(); } - if (fadeType == true) { + if (fadeType) { if (!fadeDelay) { screenBrightness -= fadeSleep ? 1 : 1+(ms().theme<4 && fadeSpeed); if (screenBrightness < 0) @@ -463,16 +510,22 @@ void vBlankHandler() { dboxInFrame = true; if (ms().theme == TWLSettings::ETheme3DS) { dbox_movespeed = 0; - dbox_Ypos = 0; + if (dbox_Ypos != 0) { + dbox_Ypos = 0; + updateFrame = true; + } } if (dbox_movespeed <= 1) { if (dbox_Ypos >= 0) { // dbox stopped - dboxStopped = true; - dbox_movespeed = 0; - dbox_Ypos = 0; - bottomScreenBrightness = 127; - REG_BLDY = (0b0100 << 1); + if (!dboxStopped || dbox_Ypos != 0) { + dboxStopped = true; + dbox_movespeed = 0; + dbox_Ypos = 0; + bottomScreenBrightness = 127; + REG_BLDY = (0b0100 << 1); + updateFrame = true; + } } else { // dbox moving into view dbox_movespeed = 1; @@ -496,16 +549,22 @@ void vBlankHandler() { if (bottomScreenBrightness > 103 && bottomScreenBrightness <= 135) REG_BLDY = (0b0100 << 1); } - dbox_Ypos += dbox_movespeed; + if (dbox_movespeed) { + dbox_Ypos += dbox_movespeed; + updateFrame = true; + } } else { // Dialogbox moving down... if (ms().theme == TWLSettings::ETheme3DS || dbox_Ypos <= -192 || dbox_Ypos >= 192) { - dboxInFrame = false; - dboxStopped = false; - dbox_movespeed = 22; - dbox_Ypos = -192; - bottomScreenBrightness = 255; - REG_BLDY = 0; + if (dboxStopped || dbox_Ypos != -192) { + dboxInFrame = false; + dboxStopped = false; + dbox_movespeed = 22; + dbox_Ypos = -192; + bottomScreenBrightness = 255; + REG_BLDY = 0; + updateFrame = true; + } } else { dbox_movespeed += 1; dbox_Ypos += dbox_movespeed; @@ -523,6 +582,8 @@ void vBlankHandler() { REG_BLDY = (0b0011 << 1); if (bottomScreenBrightness > 103 && bottomScreenBrightness <= 135) REG_BLDY = (0b0100 << 1); + + updateFrame = true; } } @@ -550,6 +611,7 @@ void vBlankHandler() { // Update drawing position titleboxYposDropDown[b] = (int)(floorf(dropDownY[b])); + updateFrame = true; } else if (dropBounce[b] < 4) { // Stop dropdown dropDownY[b] = 0.0f; @@ -575,6 +637,12 @@ void vBlankHandler() { if (movingArrowYpos < 59) movingArrowYdirection = true; } + updateFrame = true; + } + + if (applaunchprep && titleboxYmovepos < 192) { + titleboxYmovepos += 5; + updateFrame = true; } if (ms().theme == TWLSettings::EThemeHBL) { @@ -592,9 +660,108 @@ void vBlankHandler() { frontBubblesYpos[i] = frontBubblesYpos_def[i]; } } + updateFrame = true; + } + + // Blink colon once per second + if (colonTimer >= 60) { + colonTimer = 0; + showColon = !showColon; + } + + colonTimer++; + + if (showProgressIcon) { + /*loadingSoundTimer++; + + if (loadingSoundTimer >= 60) { + loadingSoundTimer = 0; + mmEffectEx(&snd_loading); + }*/ + + progressAnimDelay++; + if (progressAnimDelay == 3) { + progressAnimNum++; + if (progressAnimNum > 7) + progressAnimNum = 0; + progressAnimDelay = 0; + updateFrame = true; + } + } + if (displayGameIcons || dbox_showIcon) { + // Playback animated icons + for (int i = 0; i < 41; i++) { + if (bnriconisDSi[i] && playBannerSequence(i) && !updateFrame) { + updateFrame = (displayGameIcons && (ms().theme != TWLSettings::EThemeSaturn)) ? (i >= CURPOS-2 && i <= CURPOS+2) : (i == CURPOS); + } + } } - { + if (ms().theme == TWLSettings::ETheme3DS) { + startBorderZoomAnimDelay++; + if (startBorderZoomAnimDelay == 8) { + startBorderZoomAnimNum++; + if (startBorderZoomAnimSeq[startBorderZoomAnimNum] == 0) { + startBorderZoomAnimNum = 0; + } + startBorderZoomAnimDelay = 0; + updateFrame = true; + } + } else if (startBorderZoomOut) { + if (useRumble) { + rumblePos = !rumblePos; + my_setRumble(rumblePos); + } + startBorderZoomAnimNum++; + if (startBorderZoomAnimSeq[startBorderZoomAnimNum] == 0) { + if (useRumble) { + rumblePos = false; + my_setRumble(rumblePos); + } + startBorderZoomAnimNum = 0; + startBorderZoomOut = false; + } + updateFrame = true; + } else { + startBorderZoomAnimNum = 0; + } + + // if (applaunchprep && ms().theme == TWLSettings::EThemeDSi && launchDotDoFrameChange) { + // launchDotFrame[0]--; + // if (launchDotCurrentChangingFrame >= 1) + // launchDotFrame[1]--; + // if (launchDotCurrentChangingFrame >= 2) + // launchDotFrame[2]--; + // if (launchDotCurrentChangingFrame >= 3) + // launchDotFrame[3]--; + // if (launchDotCurrentChangingFrame >= 4) + // launchDotFrame[4]--; + // if (launchDotCurrentChangingFrame >= 5) + // launchDotFrame[5]--; + // if (launchDotCurrentChangingFrame >= 6) + // launchDotFrame[6]--; + // if (launchDotCurrentChangingFrame >= 7) + // launchDotFrame[7]--; + // if (launchDotCurrentChangingFrame >= 8) + // launchDotFrame[8]--; + // if (launchDotCurrentChangingFrame >= 9) + // launchDotFrame[9]--; + // if (launchDotCurrentChangingFrame >= 10) + // launchDotFrame[10]--; + // if (launchDotCurrentChangingFrame >= 11) + // launchDotFrame[11]--; + // for (int i = 0; i < 12; i++) { + // if (launchDotFrame[i] < 0) + // launchDotFrame[i] = 0; + // } + // launchDotCurrentChangingFrame++; + // if (launchDotCurrentChangingFrame > 11) + // launchDotCurrentChangingFrame = 11; + // } + // if (applaunchprep && ms().theme == TWLSettings::EThemeDSi) + // launchDotDoFrameChange = !launchDotDoFrameChange; + + if (updateFrame) { glBegin2D(); int bg_R = bottomScreenBrightness / 8; @@ -853,7 +1020,6 @@ void vBlankHandler() { } if (applaunchprep) { - if (isDirectory[CURPOS]) { glSprite(96, 87 - titleboxYmovepos, GL_FLIP_NONE, tex().folderImage()); if (customIcon[CURPOS]) @@ -868,10 +1034,7 @@ void vBlankHandler() { drawIcon(112, 96 - titleboxYmovepos, CURPOS); } // Draw dots after selecting a game/app - dots().drawAuto(); - - titleboxYmovepos += 5; } if (showSTARTborder && displayGameIcons && (ms().theme < 4)) { glSprite(96, tc().startBorderRenderY(), GL_FLIP_NONE, @@ -1031,106 +1194,9 @@ void vBlankHandler() { //} glEnd2D(); GFX_FLUSH = 0; - - // Blink colon once per second - if (colonTimer >= 60) { - colonTimer = 0; - showColon = !showColon; - } - - frameDelay = 0; - frameDelayEven = !frameDelayEven; + updateFrame = false; } - colonTimer++; - - if (showProgressIcon) { - /*loadingSoundTimer++; - - if (loadingSoundTimer >= 60) { - loadingSoundTimer = 0; - mmEffectEx(&snd_loading); - }*/ - - progressAnimDelay++; - if (progressAnimDelay == 3) { - progressAnimNum++; - if (progressAnimNum > 7) - progressAnimNum = 0; - progressAnimDelay = 0; - } - } - if (displayGameIcons || dbox_showIcon) { - // Playback animated icons - for (int i = 0; i < 41; i++) { - if (bnriconisDSi[i] == true) { - playBannerSequence(i); - } - } - } - - if (ms().theme == TWLSettings::ETheme3DS) { - startBorderZoomAnimDelay++; - if (startBorderZoomAnimDelay == 8) { - startBorderZoomAnimNum++; - if (startBorderZoomAnimSeq[startBorderZoomAnimNum] == 0) { - startBorderZoomAnimNum = 0; - } - startBorderZoomAnimDelay = 0; - } - } else if (startBorderZoomOut) { - if (useRumble) { - rumblePos = !rumblePos; - my_setRumble(rumblePos); - } - startBorderZoomAnimNum++; - if (startBorderZoomAnimSeq[startBorderZoomAnimNum] == 0) { - if (useRumble) { - rumblePos = false; - my_setRumble(rumblePos); - } - startBorderZoomAnimNum = 0; - startBorderZoomOut = false; - } - } else { - startBorderZoomAnimNum = 0; - } - - // if (applaunchprep && ms().theme == TWLSettings::EThemeDSi && launchDotDoFrameChange) { - // launchDotFrame[0]--; - // if (launchDotCurrentChangingFrame >= 1) - // launchDotFrame[1]--; - // if (launchDotCurrentChangingFrame >= 2) - // launchDotFrame[2]--; - // if (launchDotCurrentChangingFrame >= 3) - // launchDotFrame[3]--; - // if (launchDotCurrentChangingFrame >= 4) - // launchDotFrame[4]--; - // if (launchDotCurrentChangingFrame >= 5) - // launchDotFrame[5]--; - // if (launchDotCurrentChangingFrame >= 6) - // launchDotFrame[6]--; - // if (launchDotCurrentChangingFrame >= 7) - // launchDotFrame[7]--; - // if (launchDotCurrentChangingFrame >= 8) - // launchDotFrame[8]--; - // if (launchDotCurrentChangingFrame >= 9) - // launchDotFrame[9]--; - // if (launchDotCurrentChangingFrame >= 10) - // launchDotFrame[10]--; - // if (launchDotCurrentChangingFrame >= 11) - // launchDotFrame[11]--; - // for (int i = 0; i < 12; i++) { - // if (launchDotFrame[i] < 0) - // launchDotFrame[i] = 0; - // } - // launchDotCurrentChangingFrame++; - // if (launchDotCurrentChangingFrame > 11) - // launchDotCurrentChangingFrame = 11; - // } - // if (applaunchprep && ms().theme == TWLSettings::EThemeDSi) - // launchDotDoFrameChange = !launchDotDoFrameChange; - if (boxArtColorDeband) { //ndmaCopyWordsAsynch(0, tex().frameBuffer(secondBuffer), BG_GFX, 0x18000); dmaCopyHalfWordsAsynch(1, tex().frameBufferBot(secondBuffer), BG_GFX_SUB, 0x18000); diff --git a/romsel_dsimenutheme/arm9/source/ndsheaderbanner.cpp b/romsel_dsimenutheme/arm9/source/ndsheaderbanner.cpp index d5c71dff24..adc2b063af 100644 --- a/romsel_dsimenutheme/arm9/source/ndsheaderbanner.cpp +++ b/romsel_dsimenutheme/arm9/source/ndsheaderbanner.cpp @@ -576,7 +576,7 @@ void clearBannerSequence(int iconnum) * Play banner sequence. * @param binFile Banner file. */ -void playBannerSequence(int iconnum) +bool playBannerSequence(int iconnum) { if (bnriconframeseq[iconnum][currentbnriconframeseq[iconnum] + 1] == 0x0100) { // Do nothing if icon isn't animated @@ -607,6 +607,9 @@ void playBannerSequence(int iconnum) if (bnriconframeseq[iconnum][currentbnriconframeseq[iconnum]] == 0x0000) { currentbnriconframeseq[iconnum] = 0; // Reset sequence } + return true; } } + + return false; } diff --git a/romsel_dsimenutheme/arm9/source/ndsheaderbanner.h b/romsel_dsimenutheme/arm9/source/ndsheaderbanner.h index 98200ef1fe..d4bf3eb814 100644 --- a/romsel_dsimenutheme/arm9/source/ndsheaderbanner.h +++ b/romsel_dsimenutheme/arm9/source/ndsheaderbanner.h @@ -315,6 +315,6 @@ void clearBannerSequence(int iconnum); * Play banner sequence. * @param binFile Banner file. */ -void playBannerSequence(int iconnum); +bool playBannerSequence(int iconnum); #endif // NDS_HEADER2 diff --git a/romsel_r4theme/arm9/source/graphics/graphics.cpp b/romsel_r4theme/arm9/source/graphics/graphics.cpp index 903e95f34f..337918f734 100644 --- a/romsel_r4theme/arm9/source/graphics/graphics.cpp +++ b/romsel_r4theme/arm9/source/graphics/graphics.cpp @@ -61,6 +61,7 @@ int screenBrightness = 0; bool lcdSwapped = false; static bool secondBuffer = false; bool doubleBuffer = true; +bool updateFrame = true; int vblankRefreshCounter = 0; @@ -498,38 +499,77 @@ static void loadPng(const bool top, const int startMenu, const std::string filen void vBlankHandler() { - glBegin2D(); - { - if (fadeType == true) { - if (!fadeDelay) { - screenBrightness--; - if (screenBrightness < 0) screenBrightness = 0; - } - if (!fadeSpeed) { - fadeDelay++; - if (fadeDelay == 3) fadeDelay = 0; - } else { - fadeDelay = 0; - } + if (fadeType) { + if (!fadeDelay) { + screenBrightness--; + if (screenBrightness < 0) screenBrightness = 0; + } + if (!fadeSpeed) { + fadeDelay++; + if (fadeDelay == 3) fadeDelay = 0; } else { - if (!fadeDelay) { - screenBrightness++; - if (screenBrightness > 31) screenBrightness = 31; - } - if (!fadeSpeed) { - fadeDelay++; - if (fadeDelay == 3) fadeDelay = 0; - } else { - fadeDelay = 0; - } + fadeDelay = 0; + } + } else { + if (!fadeDelay) { + screenBrightness++; + if (screenBrightness > 31) screenBrightness = 31; } - if (ms().macroMode) { - SetBrightness(0, lcdSwapped ? (ms().theme==6 ? -screenBrightness : screenBrightness) : (ms().theme==6 ? -31 : 31)); - SetBrightness(1, !lcdSwapped ? (ms().theme==6 ? -screenBrightness : screenBrightness) : (ms().theme==6 ? -31 : 31)); + if (!fadeSpeed) { + fadeDelay++; + if (fadeDelay == 3) fadeDelay = 0; } else { - if (controlBottomBright) SetBrightness(0, ms().theme==6 ? -screenBrightness : screenBrightness); - if (controlTopBright) SetBrightness(1, ms().theme==6 ? -screenBrightness : screenBrightness); + fadeDelay = 0; } + } + if (ms().macroMode) { + SetBrightness(0, lcdSwapped ? (ms().theme==6 ? -screenBrightness : screenBrightness) : (ms().theme==6 ? -31 : 31)); + SetBrightness(1, !lcdSwapped ? (ms().theme==6 ? -screenBrightness : screenBrightness) : (ms().theme==6 ? -31 : 31)); + } else { + if (controlBottomBright) SetBrightness(0, ms().theme==6 ? -screenBrightness : screenBrightness); + if (controlTopBright) SetBrightness(1, ms().theme==6 ? -screenBrightness : screenBrightness); + } + + static bool whiteScreenPrev = whiteScreen; + static bool blackScreenPrev = blackScreen; + static bool startMenuPrev = startMenu; + static bool showdialogboxPrev = showdialogbox; + static int dialogboxHeightPrev = dialogboxHeight; + + if (whiteScreenPrev != whiteScreen) { + whiteScreenPrev = whiteScreen; + updateFrame = true; + } + + if (blackScreenPrev != blackScreen) { + blackScreenPrev = blackScreen; + updateFrame = true; + } + + if (startMenuPrev != startMenu) { + startMenuPrev = startMenu; + updateFrame = true; + } + + if (showdialogboxPrev != showdialogbox) { + showdialogboxPrev = showdialogbox; + updateFrame = true; + } + + if (showdialogbox && (dialogboxHeightPrev != dialogboxHeight)) { + dialogboxHeightPrev = dialogboxHeight; + updateFrame = true; + } + + if (startMenu) { + manualIconNextImg = !manualIconNextImg; + updateFrame = true; + } else if (bnriconisDSi && playBannerSequence()) { + updateFrame = true; + } + + if (updateFrame) { + glBegin2D(); // glColor(RGB15(31, 31-(3*blfLevel), 31-(6*blfLevel))); glColor(RGB15(31, 31, 31)); @@ -544,10 +584,6 @@ void vBlankHandler() glSprite(36, 24, GL_FLIP_NONE, iconboxImage); drawIcon(40, 28); if (bnrWirelessIcon > 0) glSprite(24, 12, GL_FLIP_NONE, &wirelessIcons[(bnrWirelessIcon-1) & 31]); - // Playback animated icons - if (bnriconisDSi) { - playBannerSequence(); - } } } if (showdialogbox) { @@ -569,9 +605,11 @@ void vBlankHandler() } else { vblankRefreshCounter++; } + + glEnd2D(); + GFX_FLUSH = 0; + updateFrame = false; } - glEnd2D(); - GFX_FLUSH = 0; if (doubleBuffer) { extern bool startMenu; @@ -579,8 +617,6 @@ void vBlankHandler() dmaCopyHalfWordsAsynch(1, bottomImage[startMenu][secondBuffer], BG_GFX, 0x18000); secondBuffer = !secondBuffer; } - - manualIconNextImg = !manualIconNextImg; } void graphicsInit() diff --git a/romsel_r4theme/arm9/source/iconTitle.cpp b/romsel_r4theme/arm9/source/iconTitle.cpp index 46c208d8cf..675460e886 100644 --- a/romsel_r4theme/arm9/source/iconTitle.cpp +++ b/romsel_r4theme/arm9/source/iconTitle.cpp @@ -92,6 +92,14 @@ u8 *clearTiles; u16 *blackPalette; u8 *tilesModified; +static inline void doFrameUpdate(void) { + extern bool updateFrame; + while (updateFrame) { + swiWaitForVBlank(); + } + updateFrame = true; +} + void iconTitleInit() { clearTiles = new u8[(32 * 256) / 2](); @@ -172,6 +180,7 @@ void loadIcon(u8 *tilesSrc, u16 *palSrc, bool twl)//(u8(*tilesSrc)[(32 * 32) / 2 (u16*) palSrc, // Image palette (u8*) tilesModified // Raw image data ); + doFrameUpdate(); } void loadFolderIcon() @@ -192,6 +201,7 @@ void loadFolderIcon() (u16*) icon_folderPal, // Image palette (u8*) icon_folderBitmap // Raw image data ); + doFrameUpdate(); } void loadUnkIcon() @@ -212,6 +222,7 @@ void loadUnkIcon() (u16*) icon_unkPal, // Image palette (u8*) icon_unkBitmap // Raw image data ); + doFrameUpdate(); } void loadGBAIcon() @@ -232,6 +243,7 @@ void loadGBAIcon() (u16*) icon_gbaPal, // Image palette (u8*) icon_gbaBitmap // Raw image data ); + doFrameUpdate(); } void loadGBIcon() @@ -252,6 +264,7 @@ void loadGBIcon() (u16*) icon_gbPal, // Image palette (u8*) icon_gbBitmap // Raw image data ); + doFrameUpdate(); } void loadGBCIcon() @@ -272,6 +285,7 @@ void loadGBCIcon() (u16*) icon_gbPal, // Image palette (u8*) icon_gbBitmap+(32*16) // Raw image data ); + doFrameUpdate(); } void loadNESIcon() @@ -292,6 +306,7 @@ void loadNESIcon() (u16*) icon_nesPal, // Image palette (u8*) icon_nesBitmap // Raw image data ); + doFrameUpdate(); } void loadSGIcon() @@ -312,6 +327,7 @@ void loadSGIcon() (u16*) icon_sgPal, // Image palette (u8*) icon_sgBitmap // Raw image data ); + doFrameUpdate(); } void loadSMSIcon() @@ -332,6 +348,7 @@ void loadSMSIcon() (u16*) icon_smsPal, // Image palette (u8*) icon_smsBitmap // Raw image data ); + doFrameUpdate(); } void loadGGIcon() @@ -352,6 +369,7 @@ void loadGGIcon() (u16*) icon_ggPal, // Image palette (u8*) icon_ggBitmap // Raw image data ); + doFrameUpdate(); } void loadMDIcon() @@ -372,6 +390,7 @@ void loadMDIcon() (u16*) icon_mdPal, // Image palette (u8*) icon_mdBitmap // Raw image data ); + doFrameUpdate(); } void loadSNESIcon() @@ -392,6 +411,7 @@ void loadSNESIcon() (u16*) icon_snesPal, // Image palette (u8*) icon_snesBitmap // Raw image data ); + doFrameUpdate(); } void loadPLGIcon() @@ -412,6 +432,7 @@ void loadPLGIcon() (u16*) icon_plgPal, // Image palette (u8*) icon_plgBitmap // Raw image data ); + doFrameUpdate(); } void loadA26Icon() @@ -432,6 +453,7 @@ void loadA26Icon() (u16*) icon_a26Pal, // Image palette (u8*) icon_a26Bitmap // Raw image data ); + doFrameUpdate(); } void loadCOLIcon() @@ -452,6 +474,7 @@ void loadCOLIcon() (u16*) icon_colPal, // Image palette (u8*) icon_colBitmap // Raw image data ); + doFrameUpdate(); } void loadM5Icon() @@ -472,6 +495,7 @@ void loadM5Icon() (u16*) icon_m5Pal, // Image palette (u8*) icon_m5Bitmap // Raw image data ); + doFrameUpdate(); } void loadINTIcon() @@ -492,6 +516,7 @@ void loadINTIcon() (u16*) icon_intPal, // Image palette (u8*) icon_intBitmap // Raw image data ); + doFrameUpdate(); } void loadPCEIcon() @@ -512,6 +537,7 @@ void loadPCEIcon() (u16*) icon_pcePal, // Image palette (u8*) icon_pceBitmap // Raw image data ); + doFrameUpdate(); } void loadWSIcon() @@ -532,6 +558,7 @@ void loadWSIcon() (u16*) icon_wsPal, // Image palette (u8*) icon_wsBitmap // Raw image data ); + doFrameUpdate(); } void loadNGPIcon() @@ -552,6 +579,7 @@ void loadNGPIcon() (u16*) icon_ngpPal, // Image palette (u8*) icon_ngpBitmap // Raw image data ); + doFrameUpdate(); } void loadCPCIcon() @@ -572,6 +600,7 @@ void loadCPCIcon() (u16*) icon_cpcPal, // Image palette (u8*) icon_cpcBitmap // Raw image data ); + doFrameUpdate(); } void loadVIDIcon() @@ -592,6 +621,7 @@ void loadVIDIcon() (u16*) icon_vidPal, // Image palette (u8*) icon_vidBitmap // Raw image data ); + doFrameUpdate(); } void loadIMGIcon() @@ -612,6 +642,7 @@ void loadIMGIcon() (u16*) icon_imgPal, // Image palette (u8*) icon_imgBitmap // Raw image data ); + doFrameUpdate(); } void loadMSXIcon() @@ -632,6 +663,7 @@ void loadMSXIcon() (u16*) icon_msxPal, // Image palette (u8*) icon_msxBitmap // Raw image data ); + doFrameUpdate(); } void loadMINIcon() @@ -652,6 +684,7 @@ void loadMINIcon() (u16*) icon_miniPal, // Image palette (u8*) icon_miniBitmap // Raw image data ); + doFrameUpdate(); } void loadHBIcon() @@ -672,6 +705,7 @@ void loadHBIcon() (u16*) icon_hbPal, // Image palette (u8*) icon_hbBitmap // Raw image data ); + doFrameUpdate(); } /** diff --git a/romsel_r4theme/arm9/source/ndsheaderbanner.cpp b/romsel_r4theme/arm9/source/ndsheaderbanner.cpp index 5bd61fb085..b76f846760 100644 --- a/romsel_r4theme/arm9/source/ndsheaderbanner.cpp +++ b/romsel_r4theme/arm9/source/ndsheaderbanner.cpp @@ -593,7 +593,7 @@ void clearBannerSequence() * Play banner sequence. * @param binFile Banner file. */ -void playBannerSequence() +bool playBannerSequence() { if (bnriconframeseq[currentbnriconframeseq + 1] == 0x0100) { // Do nothing if icon isn't animated @@ -624,6 +624,9 @@ void playBannerSequence() if (bnriconframeseq[currentbnriconframeseq] == 0x0000) { currentbnriconframeseq = 0; // Reset sequence } + return true; } } + + return false; } diff --git a/romsel_r4theme/arm9/source/ndsheaderbanner.h b/romsel_r4theme/arm9/source/ndsheaderbanner.h index e3e349f8db..50dae857f9 100644 --- a/romsel_r4theme/arm9/source/ndsheaderbanner.h +++ b/romsel_r4theme/arm9/source/ndsheaderbanner.h @@ -316,6 +316,6 @@ void clearBannerSequence(); * Play banner sequence. * @param binFile Banner file. */ -void playBannerSequence(); +bool playBannerSequence(); #endif // NDS_HEADER2