mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
ApplicationJump の画面表示に間違いがあったので修正。 AppJumpChecker のドキュメント更新。 git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2367 b08762b0-b915-fc4b-9d8c-17b2551a87ff
314 lines
8.8 KiB
C
314 lines
8.8 KiB
C
/*---------------------------------------------------------------------------*
|
||
Project: TwlSDK - tests - appjumpTest - Card
|
||
File: main.c
|
||
|
||
Copyright 2008 Nintendo. All rights reserved.
|
||
|
||
These coded instructions, statements, and computer programs contain
|
||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||
Company Ltd., and are protected by Federal copyright law. They may
|
||
not be disclosed to third parties or copied or duplicated in any form,
|
||
in whole or in part, without the prior written consent of Nintendo.
|
||
|
||
$Date:: $
|
||
$Rev$
|
||
$Author$
|
||
*---------------------------------------------------------------------------*/
|
||
#include "common.h"
|
||
#include "screen.h"
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
変数 定義
|
||
*---------------------------------------------------------------------------*/
|
||
// キー入力
|
||
static KeyInfo gKey;
|
||
|
||
// アプリ間パラメータ
|
||
static AppParam gAppParam;
|
||
// アプリ間パラメータとして文字列をセットするかどうか
|
||
static BOOL gIsSetDelArg = TRUE;
|
||
// アプリ間パラメータとして引き渡された文字列を格納するバッファ(6つまで)
|
||
static char gStrAppParam[6][APPJUMP_STRING_LENGTH + 1] ATTRIBUTE_ALIGN(32);
|
||
// アプリ間パラメータとして引き渡された文字列の個数
|
||
static int gArgc;
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Prototype
|
||
*---------------------------------------------------------------------------*/
|
||
static void AddDeliverArg(OSDeliverArgInfo *argInfo, BOOL isReturn);
|
||
|
||
/*---------------------------------------------------------------------------*/
|
||
|
||
void TwlMain(void)
|
||
{
|
||
OSDeliverArgInfo argInfo;
|
||
|
||
int result;
|
||
int argSize =sizeof(u32);
|
||
|
||
InitCommon();
|
||
InitScreen();
|
||
|
||
GX_DispOn();
|
||
GXS_DispOn();
|
||
|
||
ClearScreen();
|
||
|
||
// キー入力情報取得の空呼び出し(IPL での A ボタン押下対策)
|
||
ReadKey(&gKey);
|
||
|
||
OS_InitDeliverArgInfo(&argInfo, sizeof(AppParam));
|
||
OS_DecodeDeliverArg();
|
||
|
||
/* アプリ間パラメータ(バイナリデータの取得) */
|
||
if ( OS_DELIVER_ARG_SUCCESS != (result = OS_GetBinaryFromDeliverArg( &gAppParam, &argSize, sizeof(AppParam))) )
|
||
{
|
||
PutMainScreen(1, 16, 0xf1, "ERROR!: READ_ERROR (%d)", result);
|
||
|
||
OS_WaitVBlankIntr();
|
||
OS_Terminate();
|
||
}
|
||
|
||
/* アプリ間パラメータ(文字列)の取得 */
|
||
if ((gArgc = OS_GetDeliverArgc()) > 0)
|
||
{
|
||
int i;
|
||
|
||
OS_TPrintf("argc = %d\n", gArgc);
|
||
|
||
for (i=0; i < gArgc-1 && i < 6; i++)
|
||
{
|
||
STD_StrLCpy(gStrAppParam[i], (const char*)OS_GetDeliverArgv(i+1), APPJUMP_STRING_LENGTH);
|
||
gStrAppParam[i][APPJUMP_STRING_LENGTH] = '\0';
|
||
}
|
||
}
|
||
|
||
while(TRUE)
|
||
{
|
||
int i;
|
||
|
||
// 自動テスト中に、ユーザのキー入力による終了指示を受け付けるためにウエイトを入れる
|
||
if (gAppParam.isAutoJump == 1)
|
||
{
|
||
OSTick tick = OS_GetTick();
|
||
|
||
PutMainScreen(1, 9, 0xf8, "executing auto app jump...");
|
||
PutMainScreen(1, 11, 0xff, "wait 2 seconds...");
|
||
PutMainScreen(1, 13, 0xff, "START: quit auto app jump");
|
||
do {
|
||
ReadKey(&gKey);
|
||
|
||
if (gKey.trg & PAD_BUTTON_START)
|
||
{
|
||
break;
|
||
}
|
||
|
||
OS_WaitVBlankIntr();
|
||
} while (OS_TicksToSeconds(OS_GetTick() - tick) < 2);
|
||
}
|
||
else
|
||
{
|
||
// キー入力情報取得
|
||
ReadKey(&gKey);
|
||
}
|
||
|
||
// 画面クリア
|
||
ClearScreen();
|
||
|
||
// メイン画面描画
|
||
PutMainScreen(0, 2, 0xf4, " ****** This APP is CARD ****** ");
|
||
PutMainScreen(0, 5, 0xff, " APP JUMP : %u times ", gAppParam.jumpCount);
|
||
PutMainScreen(0, 7, 0xff, " DELIVERED PARAM (recent 6 app)");
|
||
|
||
for (i=0; i<gArgc-1; i++)
|
||
{
|
||
if ( i==0 )
|
||
{
|
||
PutMainScreen(2, 8, 0xf2, "%d : %s", i+1, gStrAppParam[i]); // 最新の履歴のみ色をつける
|
||
}
|
||
else
|
||
{
|
||
PutMainScreen(2, 8+i, 0xff, "%d : %s", i+1, gStrAppParam[i]);
|
||
}
|
||
}
|
||
|
||
// サブ画面描画
|
||
PutSubScreen(0, 0, 0xf4, " ------- APP JUMP TEST -------- ");
|
||
|
||
if (gIsSetDelArg)
|
||
{
|
||
PutSubScreen(0, 2, 0xf8, " DELIVER ARG: ON");
|
||
}
|
||
else
|
||
{
|
||
PutSubScreen(0, 2, 0xff, " DELIVER ARG: OFF");
|
||
}
|
||
|
||
if (gAppParam.isAutoJump)
|
||
{
|
||
PutSubScreen(0, 4, 0xf8, " AUTO JUMP TEST: ON");
|
||
}
|
||
else
|
||
{
|
||
PutSubScreen(0, 4, 0xff, " AUTO JUMP TEST: OFF");
|
||
}
|
||
|
||
PutSubScreen(0, 14, 0xf4, " ------------------------------- ");
|
||
PutSubScreen(0, 16, 0xff, " A: JUMP TO NAND-1 APP");
|
||
PutSubScreen(0, 17, 0xff, " Y: JUMP TO NAND-2 APP");
|
||
PutSubScreen(0, 18, 0xff, " X: JUMP TO SELF");
|
||
PutSubScreen(0, 19, 0xff, " B: RETURN JUMP");
|
||
|
||
PutSubScreen(0, 21, 0xff, " L R: SWITCH DELIVER ARG ON/OFF");
|
||
PutSubScreen(0, 22, 0xff, " STR: SWITCH AUTO TEST ON/OFF");
|
||
|
||
if (gKey.trg & PAD_KEY_DOWN)
|
||
{
|
||
}
|
||
else if (gKey.trg & PAD_KEY_UP)
|
||
{
|
||
}
|
||
|
||
if (gKey.trg & PAD_BUTTON_START)
|
||
{
|
||
// 自動テストフラグをスイッチ
|
||
gAppParam.isAutoJump ^= 1;
|
||
}
|
||
|
||
if (gKey.trg & PAD_BUTTON_A)
|
||
{
|
||
AddDeliverArg(&argInfo, FALSE);
|
||
// NAND-1 アプリへジャンプ
|
||
if( !OS_DoApplicationJump( NANDAPP1_TITLEID, OS_APP_JUMP_NORMAL ))
|
||
{
|
||
OS_TPrintf("Failed to Jump.\n");
|
||
PutMainScreen(1, 16, 0xf1, "ERROR!: Failed to Jump.");
|
||
}
|
||
break;
|
||
}
|
||
if (gKey.trg & PAD_BUTTON_Y)
|
||
{
|
||
AddDeliverArg(&argInfo, FALSE);
|
||
|
||
// NAND-2 アプリへジャンプ
|
||
if ( !OS_DoApplicationJump( NANDAPP2_TITLEID, OS_APP_JUMP_NORMAL ))
|
||
{
|
||
OS_TPrintf("Failed to Jump.\n");
|
||
PutMainScreen(1, 16, 0xf1, "ERROR!: Failed to Jump.");
|
||
}
|
||
break;
|
||
}
|
||
if (gKey.trg & PAD_BUTTON_X || gAppParam.isAutoJump == 1)
|
||
{
|
||
AddDeliverArg(&argInfo, FALSE);
|
||
// 自分自身へジャンプ
|
||
if( !OS_DoApplicationJump( OS_GetTitleId(), OS_APP_JUMP_NORMAL ))
|
||
{
|
||
OS_TPrintf("Failed to Jump.\n");
|
||
PutMainScreen(1, 16, 0xf1, "ERROR!: Failed to Jump.");
|
||
}
|
||
break;
|
||
}
|
||
if (gKey.trg & PAD_BUTTON_B)
|
||
{
|
||
AddDeliverArg(&argInfo, TRUE);
|
||
// ジャンプ元のアプリへ戻る
|
||
if ( !OS_ReturnToPrevApplication() )
|
||
{
|
||
OS_TPrintf("Failed to Return Jump.\n");
|
||
PutMainScreen(1, 16, 0xf1, "ERROR!: Failed to Return Jump.");
|
||
}
|
||
break;
|
||
}
|
||
|
||
if (gKey.trg & PAD_BUTTON_L || gKey.trg & PAD_BUTTON_R)
|
||
{
|
||
// アプリ間パラメータとして文字列を引き渡すかどうかのフラグを ON/OFF する
|
||
gIsSetDelArg = !gIsSetDelArg;
|
||
}
|
||
|
||
// Vブランク待ち
|
||
OS_WaitVBlankIntr();
|
||
}
|
||
|
||
// Vブランク待ち 最後に画面を更新してから終了
|
||
OS_WaitVBlankIntr();
|
||
OS_Terminate();
|
||
}
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Name: AddDeliverArg
|
||
|
||
Description: アプリジャンプ先へ引き渡すパラメータを追加。
|
||
|
||
Arguments: argInfo :
|
||
isReturn : ジャンプ元への復帰ならば TRUE
|
||
|
||
Returns: None.
|
||
*---------------------------------------------------------------------------*/
|
||
static void AddDeliverArg(OSDeliverArgInfo *argInfo, BOOL isReturn)
|
||
{
|
||
int result;
|
||
char argument[APPJUMP_STRING_LENGTH + 1];
|
||
gAppParam.jumpCount++;
|
||
|
||
OS_InitDeliverArgInfo(argInfo, sizeof(AppParam));
|
||
|
||
// アプリジャンプ回数を +1 してセット
|
||
result = OS_SetBinaryToDeliverArg( &(gAppParam), sizeof(AppParam) );
|
||
|
||
if(result != OS_DELIVER_ARG_SUCCESS)
|
||
{
|
||
OS_Warning("Failed to Set DeliverArgument.");
|
||
}
|
||
|
||
if (gIsSetDelArg)
|
||
{
|
||
int i;
|
||
|
||
// 文字列をセット
|
||
MI_CpuClear8(argument, APPJUMP_STRING_LENGTH + 1);
|
||
if (isReturn)
|
||
{
|
||
STD_TSPrintf(argument, "Returned from CARD");
|
||
}
|
||
else
|
||
{
|
||
STD_TSPrintf(argument, "Jumped from CARD");
|
||
}
|
||
OS_SetStringToDeliverArg(argument);
|
||
|
||
// 今まで引き渡されたパラメータ文字列を引き継がせる
|
||
for (i=0; i <= 4 && i < gArgc; i++)
|
||
{
|
||
MI_CpuClear8(argument, APPJUMP_STRING_LENGTH + 1);
|
||
STD_StrLCpy( argument, gStrAppParam[i], APPJUMP_STRING_LENGTH );
|
||
result = OS_SetStringToDeliverArg(argument);
|
||
OS_TPrintf("arg = %s : result = %d\n", argument, result);
|
||
}
|
||
}
|
||
OS_EncodeDeliverArg();
|
||
}
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Name: VBlankIntr
|
||
|
||
Description: Vブランク割込みハンドラ。
|
||
|
||
Arguments: None.
|
||
|
||
Returns: None.
|
||
*---------------------------------------------------------------------------*/
|
||
void VBlankIntr(void)
|
||
{
|
||
// テキスト表示を更新
|
||
UpdateScreen();
|
||
|
||
// IRQ チェックフラグをセット
|
||
OS_SetIrqCheckFlag(OS_IE_V_BLANK);
|
||
}
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
End of file
|
||
*---------------------------------------------------------------------------*/
|