マスタエディタ:NAND消費サイズの算出を作成。GUIはまだ。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@114 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
nishikawa_takeshi 2009-01-16 09:07:20 +00:00
parent a613d6b098
commit d30dd83d52
7 changed files with 155 additions and 14 deletions

View File

@ -110,6 +110,7 @@ ECSrlResult RCSrl::readFromFile( System::String ^filename )
// ROMヘッダの値をROM固有情報フィールドに反映させる // ROMヘッダの値をROM固有情報フィールドに反映させる
(void)this->setRomInfo(); (void)this->setRomInfo();
(void)this->calcNandUsedSize( fp ); // NAND消費サイズ
// すべて設定したあとにMRC // すべて設定したあとにMRC
{ {
@ -967,3 +968,26 @@ ECSrlResult RCSrl::searchLicenses(FILE *fp)
return ECSrlResult::NOERROR; return ECSrlResult::NOERROR;
} //RCSrl::searchLicenses } //RCSrl::searchLicenses
// -------------------------------------------------------------------
// NAND消費サイズを計算する
// -------------------------------------------------------------------
void RCSrl::calcNandUsedSize(FILE *fp)
{
this->hNandUsedSize = gcnew MasterEditorTWL::RCNandUsedSize;
this->hNandUsedSize->IsMediaNand = this->IsMediaNand;
this->hNandUsedSize->IsUseSubBanner = this->IsSubBanner;
// SRLの情報を登録
this->hNandUsedSize->PublicSaveSize = this->PublicSize;
this->hNandUsedSize->PrivateSaveSize = this->PrivateSize;
fseek( fp, 0, SEEK_END );
this->hNandUsedSize->SrlSize = ftell(fp);
//System::Diagnostics::Debug::WriteLine( "SRL " + MasterEditorTWL::transSizeToString(this->hNandUsedSize->SrlSizeRoundUp) );
//System::Diagnostics::Debug::WriteLine( "PUB " + MasterEditorTWL::transSizeToString(this->hNandUsedSize->PublicSaveSizeRoundUp) );
//System::Diagnostics::Debug::WriteLine( "PRI " + MasterEditorTWL::transSizeToString(this->hNandUsedSize->PrivateSaveSizeRoundUp) );
//System::Diagnostics::Debug::WriteLine( "TMD " + MasterEditorTWL::transSizeToString(this->hNandUsedSize->TmdSizeRoundUp) );
//System::Diagnostics::Debug::WriteLine( "SUB " + MasterEditorTWL::transSizeToString(this->hNandUsedSize->SubBannerSizeRoundUp) );
//System::Diagnostics::Debug::WriteLine( "ALL " + MasterEditorTWL::transSizeToString(this->hNandUsedSize->NandUsedSize) );
}//RCSrl::calcNandUsedSize()

View File

@ -7,6 +7,7 @@
#include <twl/types.h> #include <twl/types.h>
#include <twl/os/common/format_rom.h> #include <twl/os/common/format_rom.h>
#include <twl/os/common/ownerInfoEx.h> #include <twl/os/common/ownerInfoEx.h>
#include "utility.h"
namespace MasterEditorTWL namespace MasterEditorTWL
{ {
@ -51,7 +52,7 @@ namespace MasterEditorTWL
SECURE, SECURE,
LAUNCHER, LAUNCHER,
ILLEGAL, // 不定 ILLEGAL, // 不定
}; }; //ECAppType
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Type : ref class // Type : ref class
@ -94,7 +95,7 @@ namespace MasterEditorTWL
{ {
System::UInt32 get(){ return (this->code); } System::UInt32 get(){ return (this->code); }
} }
}; }; //RCSDKVersion
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Type : ref class // Type : ref class
@ -134,7 +135,7 @@ namespace MasterEditorTWL
{ {
System::String^ get(){ return System::String::Copy(this->hPublisher); } System::String^ get(){ return System::String::Copy(this->hPublisher); }
} }
}; }; //RCLicense
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Type : ref class // Type : ref class
@ -214,7 +215,7 @@ namespace MasterEditorTWL
else else
return (gcnew array<System::Object^>{this->hNameE, this->begin.ToString("X04")+"h", this->end.ToString("X04")+"h", this->hMsgE}); return (gcnew array<System::Object^>{this->hNameE, this->begin.ToString("X04")+"h", this->end.ToString("X04")+"h", this->hMsgE});
} }
}; }; //RCMrcError
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Type : value class // Type : value class
@ -244,7 +245,7 @@ namespace MasterEditorTWL
{ {
System::UInt32 get(){ return this->end; } System::UInt32 get(){ return this->end; }
} }
}; }; //VCReservedArea
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Type : ref class // Type : ref class
@ -280,7 +281,101 @@ namespace MasterEditorTWL
this->hReservedAreaList = gcnew System::Collections::Generic::List<VCReservedArea>; this->hReservedAreaList = gcnew System::Collections::Generic::List<VCReservedArea>;
this->hReservedAreaList->Clear(); this->hReservedAreaList->Clear();
} }
}; }; //RCMrcExternalCheckItems
// -------------------------------------------------------------------
// Type : ref class
// Name : RCNandUsedSize
//
// Description : アプリのインポート時NAND消費サイズクラス
//
// Role : 構造体としてデータをまとめておく
// -------------------------------------------------------------------
ref class RCNandUsedSize
{
public:
property System::UInt32 SrlSize;
property System::UInt32 PublicSaveSize;
property System::UInt32 PrivateSaveSize;
property System::Boolean IsMediaNand; // NANDアプリかどうか
property System::Boolean IsUseSubBanner; // サブバナーを使用するかどうか
public:
static const System::UInt32 TmdSize = 16 * 1024;
static const System::UInt32 SubBannerSize = 16 * 1024;
private:
static const System::UInt32 NandClusterSize = 16 * 1024;
static const System::UInt32 ShopBlockSize = 128 * 1024;
public:
property System::UInt32 SrlSizeRoundUp
{
System::UInt32 get()
{
if( !this->IsMediaNand )
{
return 0;
}
return (MasterEditorTWL::roundUp( this->SrlSize, NandClusterSize ));
}
}
property System::UInt32 PublicSaveSizeRoundUp
{
System::UInt32 get(){ return (MasterEditorTWL::roundUp( this->PublicSaveSize, NandClusterSize )); }
}
property System::UInt32 PrivateSaveSizeRoundUp
{
System::UInt32 get(){ return (MasterEditorTWL::roundUp( this->PrivateSaveSize, NandClusterSize )); }
}
property System::UInt32 TmdSizeRoundUp
{
System::UInt32 get()
{
if( !this->IsMediaNand )
{
return 0;
}
return (MasterEditorTWL::roundUp( this->TmdSize, NandClusterSize ));
}
}
property System::UInt32 SubBannerSizeRoundUp
{
System::UInt32 get()
{
if( !this->IsUseSubBanner )
{
return 0;
}
return (MasterEditorTWL::roundUp( this->SubBannerSize, NandClusterSize ));
}
}
property System::UInt32 NandUsedSize // 全体のNAND消費サイズは変数で持たず property で提供
{
System::UInt32 get()
{
// NAND消費量の計算式
// 以下のファイルをNANDクラスタ単位(=16KB)に切り上げて合計する
//
// SRLの実ファイルサイズ
// Publicセーブデータサイズ
// Privateセーブデータサイズ
// TMDサイズ(=16KB固定)
// サブバナーサイズ(使用時には16KB固定 不使用時には0KB)
if( !this->IsMediaNand )
{
return 0; // カードアプリのとき0
}
System::UInt32 size = this->SrlSizeRoundUp + this->PublicSaveSizeRoundUp + this->PrivateSaveSizeRoundUp
+ this->TmdSizeRoundUp + this->SubBannerSizeRoundUp;
return size;
}
}
property System::UInt32 NandUsedSizeBlock // ショップでのブロック数
{
System::UInt32 get()
{
return (MasterEditorTWL::roundUp( this->NandUsedSize, ShopBlockSize ));
}
}
}; //RCNandUsedSize
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Type : ref class // Type : ref class
@ -314,26 +409,29 @@ namespace MasterEditorTWL
property cli::array<System::Int32> ^hArrayParentalIndex; // 表示用のコンボボックスのインデックス property cli::array<System::Int32> ^hArrayParentalIndex; // 表示用のコンボボックスのインデックス
property System::Boolean IsUnnecessaryRating; // レーティング表示不要フラグ property System::Boolean IsUnnecessaryRating; // レーティング表示不要フラグ
// TWL<EFBFBD>ępŹîń <EFBFBD>ęŇŹWÂ\ // TWL専用情報 Read Only
property System::UInt32 NormalRomOffset; property System::UInt32 NormalRomOffset;
property System::UInt32 KeyTableRomOffset; property System::UInt32 KeyTableRomOffset;
property System::String ^hTitleIDLo; property System::String ^hTitleIDLo;
property System::UInt32 TitleIDHi; property System::UInt32 TitleIDHi;
property System::Boolean IsAppLauncher; // TitleIDLoからわかるアプリ種別 property System::Boolean IsAppLauncher; // TitleIDLoからわかるアプリ種別
property System::Boolean IsAppUser; // TitleIDHiからわかるアプリ種別 property System::Boolean IsAppUser; // TitleIDHiからわかるアプリ種別
property System::Boolean IsAppSystem; // property System::Boolean IsAppSystem; //
property System::Boolean IsAppSecure; // property System::Boolean IsAppSecure; //
property System::Boolean IsLaunch; // property System::Boolean IsLaunch; //
property System::Boolean IsMediaNand; // property System::Boolean IsMediaNand; //
property System::Boolean IsDataOnly; // property System::Boolean IsDataOnly; //
property System::UInt16 PublisherCode; // property System::UInt16 PublisherCode; //
property System::UInt32 PublicSize;
property System::UInt32 PrivateSize;
property System::Boolean IsNormalJump; property System::Boolean IsNormalJump;
property System::Boolean IsTmpJump; property System::Boolean IsTmpJump;
property System::Boolean HasDSDLPlaySign; // ROMヘッダ外のSRLからわかる署名の有無 property System::Boolean HasDSDLPlaySign; // ROMヘッダ外のSRLからわかる署名の有無
property System::Boolean IsOldDevEncrypt; // 旧開発用暗号フラグが立っている property System::Boolean IsOldDevEncrypt; // 旧開発用暗号フラグが立っている
property System::Boolean IsSCFGAccess; // SCFGレジスタをロックしている property System::Boolean IsSCFGAccess; // SCFGレジスタをロックしている
property System::UInt32 PublicSize; // セーブデータサイズ
property System::UInt32 PrivateSize;
// NAND消費サイズ
RCNandUsedSize ^hNandUsedSize;
// TWL拡張フラグ Read Only // TWL拡張フラグ Read Only
property System::Boolean IsCodecTWL; property System::Boolean IsCodecTWL;
@ -420,6 +518,7 @@ namespace MasterEditorTWL
ECSrlResult searchSDKVersion( FILE *fp ); // SDKバージョンを取得する ECSrlResult searchSDKVersion( FILE *fp ); // SDKバージョンを取得する
ECSrlResult searchLicenses( FILE *fp ); // 使用ライセンスを取得する ECSrlResult searchLicenses( FILE *fp ); // 使用ライセンスを取得する
ECAppType selectAppType( ROM_Header *prh ); // TitleIDからアプリ種別を決定する ECAppType selectAppType( ROM_Header *prh ); // TitleIDからアプリ種別を決定する
void calcNandUsedSize( FILE *fp ); // NAND消費サイズを計算する
// MRC(Master ROM Checker)機能 // MRC(Master ROM Checker)機能
ECSrlResult mrc( FILE *fp ); ECSrlResult mrc( FILE *fp );

View File

@ -576,3 +576,16 @@ System::Boolean MasterEditorTWL::IsSDKVersionRC( u32 target )
} }
return false; return false;
} }
// ----------------------------------------------------------------------
// src を base 単位に切り上げる
// ----------------------------------------------------------------------
System::UInt32 MasterEditorTWL::roundUp( const System::UInt32 src, const System::UInt32 base )
{
System::UInt32 div = src / base;
if( src % base )
{
div++;
}
return (div*base);
}

View File

@ -193,4 +193,9 @@ namespace MasterEditorTWL
// //
System::Boolean IsSDKVersionRC( u32 target ); System::Boolean IsSDKVersionRC( u32 target );
//
// src を base 単位に切り上げる
//
System::UInt32 roundUp( const System::UInt32 src, const System::UInt32 base );
} // end of namespace MasterEditorTWL } // end of namespace MasterEditorTWL