mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
CUP終了後即終了処理に移るように
HOMEメニューが無い場合にエラーアプレットを呼ぶように git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@471 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
dd2b5512cd
commit
2f1ba5cb44
@ -49,18 +49,6 @@ void DrawThreadMain();
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
const size_t DRAWER_STACK_SIZE = 0x4000;
|
|
||||||
nn::os::Thread s_DrawerThread;
|
|
||||||
nn::os::StackBuffer<DRAWER_STACK_SIZE> s_DrawerThreadStack;
|
|
||||||
|
|
||||||
// 終了処理をしても良いかどうか
|
|
||||||
bool s_IsExpectedToFinalize = false;
|
|
||||||
|
|
||||||
// エラーコード表示が必要かどうか
|
|
||||||
bool s_NeedShowErrorCode = false;
|
|
||||||
// エラーコード
|
|
||||||
s32 s_ErrorCode;
|
|
||||||
|
|
||||||
enum LayoutType
|
enum LayoutType
|
||||||
{
|
{
|
||||||
LAYOUT_UPPER_LOGO,
|
LAYOUT_UPPER_LOGO,
|
||||||
@ -80,6 +68,23 @@ enum DrawState
|
|||||||
|
|
||||||
DRAW_STATE_MAX
|
DRAW_STATE_MAX
|
||||||
};
|
};
|
||||||
|
const size_t DRAWER_STACK_SIZE = 0x4000;
|
||||||
|
nn::os::Thread s_DrawerThread;
|
||||||
|
nn::os::StackBuffer<DRAWER_STACK_SIZE> s_DrawerThreadStack;
|
||||||
|
|
||||||
|
// 終了処理をしても良いかどうか
|
||||||
|
bool s_IsExpectedToFinalize = false;
|
||||||
|
|
||||||
|
// エラーコード表示が必要かどうか
|
||||||
|
bool s_NeedShowErrorCode = false;
|
||||||
|
// エラーコード
|
||||||
|
s32 s_ErrorCode;
|
||||||
|
|
||||||
|
// ロゴ表示中の待ちフレーム数をカウント
|
||||||
|
u32 s_WaitCounter = 0;
|
||||||
|
|
||||||
|
// 描画シーケンス
|
||||||
|
u32 s_DrawState = DRAW_STATE_START;
|
||||||
|
|
||||||
struct LayoutAnimation
|
struct LayoutAnimation
|
||||||
{
|
{
|
||||||
@ -444,6 +449,11 @@ void NotifyFinished()
|
|||||||
s_NeedShowErrorCode = false;
|
s_NeedShowErrorCode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsReadyforShowError()
|
||||||
|
{
|
||||||
|
return (DRAW_STATE_LOGO_DRAW == s_DrawState) && (1 < s_WaitCounter);
|
||||||
|
}
|
||||||
|
|
||||||
void ShowError()
|
void ShowError()
|
||||||
{
|
{
|
||||||
NN_LOG("Show Error\n");
|
NN_LOG("Show Error\n");
|
||||||
@ -545,19 +555,15 @@ DrawThreadMain()
|
|||||||
nw::lyt::Layout* pUpperLayout;
|
nw::lyt::Layout* pUpperLayout;
|
||||||
nw::lyt::Layout* pLowerLayout;
|
nw::lyt::Layout* pLowerLayout;
|
||||||
|
|
||||||
u32 drawState = DRAW_STATE_START;
|
|
||||||
|
|
||||||
LayoutAnimation* pUpperLayoutAnim;
|
LayoutAnimation* pUpperLayoutAnim;
|
||||||
LayoutAnimation* pLowerLayoutAnim;
|
LayoutAnimation* pLowerLayoutAnim;
|
||||||
LayoutAnimationIndex upperLayoutAnimIndex;
|
LayoutAnimationIndex upperLayoutAnimIndex;
|
||||||
LayoutAnimationIndex lowerLayoutAnimIndex;
|
LayoutAnimationIndex lowerLayoutAnimIndex;
|
||||||
GetNextLayoutAnimationIndex(upperLayoutAnimIndex, drawState, demoApp.DISPLAY0);
|
GetNextLayoutAnimationIndex(upperLayoutAnimIndex, s_DrawState, demoApp.DISPLAY0);
|
||||||
GetNextLayoutAnimationIndex(lowerLayoutAnimIndex, drawState, demoApp.DISPLAY1);
|
GetNextLayoutAnimationIndex(lowerLayoutAnimIndex, s_DrawState, demoApp.DISPLAY1);
|
||||||
pUpperLayoutAnim = &layoutAnim[upperLayoutAnimIndex.layoutType];
|
pUpperLayoutAnim = &layoutAnim[upperLayoutAnimIndex.layoutType];
|
||||||
pLowerLayoutAnim = &layoutAnim[lowerLayoutAnimIndex.layoutType];
|
pLowerLayoutAnim = &layoutAnim[lowerLayoutAnimIndex.layoutType];
|
||||||
|
|
||||||
// ロゴ表示中の待ちフレーム数をカウント
|
|
||||||
u32 waitCounter = 0;
|
|
||||||
while (mainloop)
|
while (mainloop)
|
||||||
{
|
{
|
||||||
padReader.ReadLatest(&padStatus);
|
padReader.ReadLatest(&padStatus);
|
||||||
@ -583,11 +589,11 @@ DrawThreadMain()
|
|||||||
|
|
||||||
// 下画面描画
|
// 下画面描画
|
||||||
demoApp.SetRenderingTarget(demoApp.DISPLAY1);
|
demoApp.SetRenderingTarget(demoApp.DISPLAY1);
|
||||||
if (drawState == DRAW_STATE_LOGO_DRAW)
|
if (s_DrawState == DRAW_STATE_LOGO_DRAW)
|
||||||
{
|
{
|
||||||
const nw::ut::FloatColor white(1.0f, 1.0f, 1.0f, 1.0f);
|
const nw::ut::FloatColor white(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
demoApp.GetFrameBufferObject().ClearBuffer(white, clearDepth);
|
demoApp.GetFrameBufferObject().ClearBuffer(white, clearDepth);
|
||||||
waitCounter++;
|
s_WaitCounter++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -597,7 +603,7 @@ DrawThreadMain()
|
|||||||
{
|
{
|
||||||
demoApp.GetFrameBufferObject().ClearBuffer(clearColor, clearDepth);
|
demoApp.GetFrameBufferObject().ClearBuffer(clearColor, clearDepth);
|
||||||
|
|
||||||
if(DRAW_STATE_LOGO_FADE_IN <= drawState && drawState <= DRAW_STATE_LOGO_FADE_OUT)
|
if(DRAW_STATE_LOGO_FADE_IN <= s_DrawState && s_DrawState <= DRAW_STATE_LOGO_FADE_OUT)
|
||||||
{
|
{
|
||||||
SetupLowerCamera(drawInfo, *pLowerLayout);
|
SetupLowerCamera(drawInfo, *pLowerLayout);
|
||||||
}
|
}
|
||||||
@ -627,19 +633,19 @@ DrawThreadMain()
|
|||||||
// 1アニメーション終了
|
// 1アニメーション終了
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (drawState < DRAW_STATE_FADE_OUT)
|
if (s_DrawState < DRAW_STATE_FADE_OUT)
|
||||||
{
|
{
|
||||||
// 終了処理を依頼されたときのみロゴフェードアウト以降に進む
|
// 終了処理を依頼されたときのみロゴフェードアウト以降に進む
|
||||||
if (drawState < DRAW_STATE_LOGO_DRAW || s_IsExpectedToFinalize)
|
if (s_DrawState < DRAW_STATE_LOGO_DRAW || s_IsExpectedToFinalize)
|
||||||
{
|
{
|
||||||
// 次のアニメーションへ遷移
|
// 次のアニメーションへ遷移
|
||||||
GetNextLayoutAnimationIndex(upperLayoutAnimIndex, drawState, demoApp.DISPLAY0);
|
GetNextLayoutAnimationIndex(upperLayoutAnimIndex, s_DrawState, demoApp.DISPLAY0);
|
||||||
GetNextLayoutAnimationIndex(lowerLayoutAnimIndex, drawState, demoApp.DISPLAY1);
|
GetNextLayoutAnimationIndex(lowerLayoutAnimIndex, s_DrawState, demoApp.DISPLAY1);
|
||||||
pUpperLayoutAnim = &layoutAnim[upperLayoutAnimIndex.layoutType];
|
pUpperLayoutAnim = &layoutAnim[upperLayoutAnimIndex.layoutType];
|
||||||
pLowerLayoutAnim = &layoutAnim[lowerLayoutAnimIndex.layoutType];
|
pLowerLayoutAnim = &layoutAnim[lowerLayoutAnimIndex.layoutType];
|
||||||
|
|
||||||
drawState++;
|
s_DrawState++;
|
||||||
NN_LOG("State = %d\n", drawState);
|
NN_LOG("State = %d\n", s_DrawState);
|
||||||
NN_LOG(
|
NN_LOG(
|
||||||
"Upper: layout: %d, anim: %d\n", upperLayoutAnimIndex.layoutType, upperLayoutAnimIndex.animIndex);
|
"Upper: layout: %d, anim: %d\n", upperLayoutAnimIndex.layoutType, upperLayoutAnimIndex.animIndex);
|
||||||
NN_LOG(
|
NN_LOG(
|
||||||
@ -661,7 +667,7 @@ DrawThreadMain()
|
|||||||
demoApp.SwapBuffer(demoApp.DISPLAY_BOTH);
|
demoApp.SwapBuffer(demoApp.DISPLAY_BOTH);
|
||||||
|
|
||||||
// ロゴが表示されてからエラー表示を行う
|
// ロゴが表示されてからエラー表示を行う
|
||||||
if(s_NeedShowErrorCode && DRAW_STATE_LOGO_DRAW == drawState && 1 < waitCounter)
|
if(s_NeedShowErrorCode && DRAW_STATE_LOGO_DRAW == s_DrawState && 1 < s_WaitCounter)
|
||||||
{
|
{
|
||||||
ShowError();
|
ShowError();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,5 +20,6 @@ void StartDrawerThread();
|
|||||||
void FinalizeDrawerThread();
|
void FinalizeDrawerThread();
|
||||||
void NotifyFailed(s32 error);
|
void NotifyFailed(s32 error);
|
||||||
void NotifyFinished();
|
void NotifyFinished();
|
||||||
|
bool IsReadyforShowError();
|
||||||
|
|
||||||
#endif /* DRAWER_H_ */
|
#endif /* DRAWER_H_ */
|
||||||
|
|||||||
@ -168,6 +168,15 @@ namespace
|
|||||||
|
|
||||||
return lastResult;
|
return lastResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaitAndNotifyResult(nn::Result result)
|
||||||
|
{
|
||||||
|
while (!IsReadyforShowError())
|
||||||
|
{
|
||||||
|
nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(1));
|
||||||
|
}
|
||||||
|
NotifyFailed(result.GetPrintableBits());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void nnMain()
|
extern "C" void nnMain()
|
||||||
@ -211,16 +220,12 @@ extern "C" void nnMain()
|
|||||||
/******************** CUPの実行 *******************/
|
/******************** CUPの実行 *******************/
|
||||||
bool isHandledError = false;
|
bool isHandledError = false;
|
||||||
result = UpdateSequence(&isHandledError);
|
result = UpdateSequence(&isHandledError);
|
||||||
if (isHandledError == false && result.IsFailure())
|
// エラーが発生する可能性があるがユーザに見せない
|
||||||
{
|
|
||||||
{
|
|
||||||
// TODO:それ以外の場合は、エラーアプレットを表示
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(result == nn::am::ResultNotFound())
|
else if(result == nn::am::ResultNotFound())
|
||||||
{
|
{
|
||||||
// TODO:HOMEメニューが無いエラーをエラーアプレットで表示する
|
// HOMEメニューが無いエラーをエラーアプレットで表示する
|
||||||
|
WaitAndNotifyResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(result.IsSuccess() || result == nn::cup::CTR::ResultUpdateNotRequired()))
|
if (!(result.IsSuccess() || result == nn::cup::CTR::ResultUpdateNotRequired()))
|
||||||
@ -228,23 +233,16 @@ extern "C" void nnMain()
|
|||||||
NotifyFailed(0);
|
NotifyFailed(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
nn::os::Tick before = nn::os::Tick::GetSystemCurrent();
|
|
||||||
const u8 SHUTDOWN_WAIT_SECONDS = 2;
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
// 画面描画
|
// 画面描画
|
||||||
if (result.IsSuccess() || result == nn::cup::CTR::ResultUpdateNotRequired())
|
if (result.IsSuccess() || result == nn::cup::CTR::ResultUpdateNotRequired())
|
||||||
{
|
{
|
||||||
// 成功したので終了処理に入る
|
// 成功したので終了処理に入る
|
||||||
nn::os::Tick current = nn::os::Tick::GetSystemCurrent();
|
|
||||||
if ((current - before).ToTimeSpan().GetSeconds() > SHUTDOWN_WAIT_SECONDS)
|
|
||||||
{
|
|
||||||
NotifyFinished();
|
NotifyFinished();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nn::applet::IsExpectedToProcessPowerButton())
|
if (nn::applet::IsExpectedToProcessPowerButton())
|
||||||
{
|
{
|
||||||
NotifyFinished();
|
NotifyFinished();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user