メニュースキップフラグ立てツール:フラグを下ろすオプション-dを追加。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@297 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
nishikawa_takeshi 2009-06-22 01:47:04 +00:00
parent 894c3ce600
commit 5283954fa1

View File

@ -47,6 +47,9 @@
typedef struct _SContext
{
// オプション
BOOL isDisable; // フラグを下ろすモード
// 入出力ファイル
FILE *ifp;
FILE *ofp;
}
@ -81,13 +84,14 @@ BOOL DebugMode = FALSE;
void usage()
{
printf( "-----------------------------------------------------------------------------\n" );
printf( "Usage: MenuSkipFlagTool.exe input_file output_file flag\n" );
printf( "Usage: MenuSkipFlagTool.exe input_file output_file enable-flag\n" );
printf( " input_file : a ROM data file (generated by makerom.TWL).\n" );
printf( " output_file : a destination file.\n" );
printf( " enable-flag : 1 or 0. If 1, menu-skip flag will be enabled.\n" );
printf( "\nOption:\n" );
printf( "-h : print help only.\n" );
printf( "-f : force to overwrite a output_file.\n" );
printf( "-d : disable the mesu-skip flag, when enable-flag is 1.\n" );
printf( "-----------------------------------------------------------------------------\n" );
}
@ -111,7 +115,7 @@ int main(int argc, char *argv[])
memset( &context, 0, sizeof(SContext) );
// オプション
while( (opt = getopt(argc, argv, "hf")) >= 0 )
while( (opt = getopt(argc, argv, "hfd")) >= 0 )
{
switch( opt )
{
@ -123,6 +127,10 @@ int main(int argc, char *argv[])
case 'f':
bForceOverwrite = TRUE;
break;
case 'd':
context.isDisable = TRUE;
break;
default: // オプション引数が指定されていないときにも実行される
usage();
@ -259,20 +267,39 @@ static BOOL iEnableFlag( SContext *pContext )
printf("\n*** Error: Illegal platform (%d). ***\n", rh.s.platform_code);
}
printf("InitialCode : %c%c%c%c\n", rh.s.game_code[0], rh.s.game_code[1], rh.s.game_code[2], rh.s.game_code[3]);
// TWLとNTRとで分岐
if( (rh.s.platform_code == 0) && (rh.s.enable_signature == 0) ) // enable_signature が立っている特殊なアプリを含む (PictoChatなど)
if( (rh.s.platform_code == 0) && (rh.s.enable_signature == 0) ) // enable_signature が立っている特殊なアプリはTWLとみなす (PictoChat/DS-download-play)
{
printf( "Platform(TWL/NTR): 0x%02X (NTR)\n", rh.s.platform_code );
// フラグを立てる
if( rh.s.inspect_card == 0 )
if( pContext->isDisable )
{
rh.s.inspect_card = 0x1;
printf( "Menu-skip flag : Disable -> Enable\n" );
// フラグを下ろすモード
if( rh.s.inspect_card != 0 )
{
rh.s.inspect_card = 0;
printf( "Menu-skip flag : Enable -> Disable\n" );
}
else
{
printf( "Menu-skip flag : Already Disabled\n" );
}
}
else
{
printf( "Menu-skip flag : Already Enabled\n" );
// フラグを立てるモード(通常)
if( rh.s.inspect_card == 0 )
{
rh.s.inspect_card = 0x1;
printf( "Menu-skip flag : Disable -> Enable\n" );
}
else
{
printf( "Menu-skip flag : Already Enabled\n" );
}
}
// ヘッダCRC計算
@ -282,8 +309,26 @@ static BOOL iEnableFlag( SContext *pContext )
}
else
{
printf( "Platform(TWL/NTR): 0x%02X (%s)\n",
rh.s.platform_code, (rh.s.platform_code == PLATFORM_CODE_TWL_HYBLID)?"TWL Hybrid":"TWL Limited" );
switch(rh.s.platform_code)
{
case PLATFORM_CODE_NTR: // PictoChat/DlPlay
printf( "Platform(TWL/NTR): 0x%02X (NTR for TWL, PictoChat or DS-Download-play)\n", rh.s.platform_code );
break;
case PLATFORM_CODE_TWL_HYBLID:
printf( "Platform(TWL/NTR): 0x%02X (TWL Hybrid)\n", rh.s.platform_code );
break;
case PLATFORM_CODE_TWL_LIMITED:
printf( "Platform(TWL/NTR): 0x%02X (TWL Limited)\n", rh.s.platform_code );
break;
default: // unreachable
printf( "Platform(TWL/NTR): 0x%02X (Illegal)\n", rh.s.platform_code );
printf("\n*** Error: Illegal platform (%d). ***\n", rh.s.platform_code);
return FALSE;
break;
}
// 署名を外す
if( !DecryptSignRomHeader( &rh ) )
@ -294,14 +339,31 @@ static BOOL iEnableFlag( SContext *pContext )
printf( "Decrypt the sign : Succeeded\n" );
// フラグを立てる
if( rh.s.inspect_card == 0 )
if( pContext->isDisable )
{
rh.s.inspect_card = 0x1;
printf( "Menu-skip flag : Disable -> Enable\n" );
// フラグを下ろすモード
if( rh.s.inspect_card != 0 )
{
rh.s.inspect_card = 0;
printf( "Menu-skip flag : Enable -> Disable\n" );
}
else
{
printf( "Menu-skip flag : Already Disabled\n" );
}
}
else
{
printf( "Menu-skip flag : Already Enabled\n" );
// フラグを立てるモード(通常)
if( rh.s.inspect_card == 0 )
{
rh.s.inspect_card = 0x1;
printf( "Menu-skip flag : Disable -> Enable\n" );
}
else
{
printf( "Menu-skip flag : Already Enabled\n" );
}
}
// ヘッダCRC計算