From 5283954fa13de13c0284b88384b856f492ffba89 Mon Sep 17 00:00:00 2001 From: nishikawa_takeshi Date: Mon, 22 Jun 2009 01:47:04 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC=E3=82=B9?= =?UTF-8?q?=E3=82=AD=E3=83=83=E3=83=97=E3=83=95=E3=83=A9=E3=82=B0=E7=AB=8B?= =?UTF-8?q?=E3=81=A6=E3=83=84=E3=83=BC=E3=83=AB:=E3=83=95=E3=83=A9?= =?UTF-8?q?=E3=82=B0=E3=82=92=E4=B8=8B=E3=82=8D=E3=81=99=E3=82=AA=E3=83=97?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3-d=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@297 7061adef-622a-194b-ae81-725974e89856 --- .../MasterEditor/MenuSkipFlagTool/main.c | 88 ++++++++++++++++--- 1 file changed, 75 insertions(+), 13 deletions(-) diff --git a/build/tools/MasterEditor/MenuSkipFlagTool/main.c b/build/tools/MasterEditor/MenuSkipFlagTool/main.c index 53173f9..10a1a12 100644 --- a/build/tools/MasterEditor/MenuSkipFlagTool/main.c +++ b/build/tools/MasterEditor/MenuSkipFlagTool/main.c @@ -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計算