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:
N2614 2011-11-01 07:18:02 +00:00
parent dd2b5512cd
commit 2f1ba5cb44
3 changed files with 49 additions and 44 deletions

View File

@ -49,18 +49,6 @@ void DrawThreadMain();
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
{
LAYOUT_UPPER_LOGO,
@ -80,6 +68,23 @@ enum DrawState
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
{
@ -444,6 +449,11 @@ void NotifyFinished()
s_NeedShowErrorCode = false;
}
bool IsReadyforShowError()
{
return (DRAW_STATE_LOGO_DRAW == s_DrawState) && (1 < s_WaitCounter);
}
void ShowError()
{
NN_LOG("Show Error\n");
@ -545,19 +555,15 @@ DrawThreadMain()
nw::lyt::Layout* pUpperLayout;
nw::lyt::Layout* pLowerLayout;
u32 drawState = DRAW_STATE_START;
LayoutAnimation* pUpperLayoutAnim;
LayoutAnimation* pLowerLayoutAnim;
LayoutAnimationIndex upperLayoutAnimIndex;
LayoutAnimationIndex lowerLayoutAnimIndex;
GetNextLayoutAnimationIndex(upperLayoutAnimIndex, drawState, demoApp.DISPLAY0);
GetNextLayoutAnimationIndex(lowerLayoutAnimIndex, drawState, demoApp.DISPLAY1);
GetNextLayoutAnimationIndex(upperLayoutAnimIndex, s_DrawState, demoApp.DISPLAY0);
GetNextLayoutAnimationIndex(lowerLayoutAnimIndex, s_DrawState, demoApp.DISPLAY1);
pUpperLayoutAnim = &layoutAnim[upperLayoutAnimIndex.layoutType];
pLowerLayoutAnim = &layoutAnim[lowerLayoutAnimIndex.layoutType];
// ロゴ表示中の待ちフレーム数をカウント
u32 waitCounter = 0;
while (mainloop)
{
padReader.ReadLatest(&padStatus);
@ -583,11 +589,11 @@ DrawThreadMain()
// 下画面描画
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);
demoApp.GetFrameBufferObject().ClearBuffer(white, clearDepth);
waitCounter++;
s_WaitCounter++;
}
else
{
@ -597,7 +603,7 @@ DrawThreadMain()
{
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);
}
@ -627,19 +633,19 @@ DrawThreadMain()
// 1アニメーション終了
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(lowerLayoutAnimIndex, drawState, demoApp.DISPLAY1);
GetNextLayoutAnimationIndex(upperLayoutAnimIndex, s_DrawState, demoApp.DISPLAY0);
GetNextLayoutAnimationIndex(lowerLayoutAnimIndex, s_DrawState, demoApp.DISPLAY1);
pUpperLayoutAnim = &layoutAnim[upperLayoutAnimIndex.layoutType];
pLowerLayoutAnim = &layoutAnim[lowerLayoutAnimIndex.layoutType];
drawState++;
NN_LOG("State = %d\n", drawState);
s_DrawState++;
NN_LOG("State = %d\n", s_DrawState);
NN_LOG(
"Upper: layout: %d, anim: %d\n", upperLayoutAnimIndex.layoutType, upperLayoutAnimIndex.animIndex);
NN_LOG(
@ -661,7 +667,7 @@ DrawThreadMain()
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();
}

View File

@ -20,5 +20,6 @@ void StartDrawerThread();
void FinalizeDrawerThread();
void NotifyFailed(s32 error);
void NotifyFinished();
bool IsReadyforShowError();
#endif /* DRAWER_H_ */

View File

@ -168,6 +168,15 @@ namespace
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()
@ -211,16 +220,12 @@ extern "C" void nnMain()
/******************** CUPの実行 *******************/
bool isHandledError = false;
result = UpdateSequence(&isHandledError);
if (isHandledError == false && result.IsFailure())
{
{
// TODO:それ以外の場合は、エラーアプレットを表示
}
}
// エラーが発生する可能性があるがユーザに見せない
}
else if(result == nn::am::ResultNotFound())
{
// TODO:HOMEメニューが無いエラーをエラーアプレットで表示する
// HOMEメニューが無いエラーをエラーアプレットで表示する
WaitAndNotifyResult(result);
}
if (!(result.IsSuccess() || result == nn::cup::CTR::ResultUpdateNotRequired()))
@ -228,21 +233,14 @@ extern "C" void nnMain()
NotifyFailed(0);
}
nn::os::Tick before = nn::os::Tick::GetSystemCurrent();
const u8 SHUTDOWN_WAIT_SECONDS = 2;
for(;;)
{
// 画面描画
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();
break;
}
NotifyFinished();
break;
}
if (nn::applet::IsExpectedToProcessPowerButton())