From a97c03a0c2da781d3c30b09f6f550b7069a37187 Mon Sep 17 00:00:00 2001 From: N2614 Date: Mon, 2 May 2011 09:33:26 +0000 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=20=E9=96=A2=E6=95=B0=E5=90=8D=E3=80=81=E5=A4=89?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E3=81=AE=E5=A4=89=E6=9B=B4=20=E4=BD=BF?= =?UTF-8?q?=E3=82=8F=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@246 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../sources/ConsoleBackup/ConsoleBackup.cpp | 2 +- .../sources/ConsoleBackup/Controller.cpp | 8 +-- .../sources/ConsoleBackup/Controller.h | 15 +++++ .../sources/ConsoleBackup/Exporter.cpp | 2 +- .../sources/ConsoleBackup/Exporter.h | 21 ++++++- .../sources/ConsoleRestore/Controller.cpp | 8 +-- .../sources/ConsoleRestore/Controller.h | 22 ++++++++ .../sources/ConsoleRestore/Importer.cpp | 2 +- .../sources/ConsoleRestore/Importer.h | 55 ++++++++++++++++++- .../sources/ConsoleRestore/NtpClient.h | 5 ++ .../sources/ConsoleRestore/Shop.h | 15 ++++- .../sources/ConsoleRestore/TitleDownloader.h | 8 ++- .../sources/ConsoleRestore/Updater.h | 9 +++ .../sources/common/CommonLogger.cpp | 4 +- .../sources/common/CommonLogger.h | 31 ++++++++--- .../sources/common/DrawSystemState.h | 5 ++ .../sources/common/FileChecker.cpp | 5 -- .../sources/common/FileChecker.h | 35 +++++++----- .../sources/common/FileTransfer.cpp | 10 ---- .../sources/common/FileTransfer.h | 21 +++++++ .../sources/common/LogConsole.h | 11 ++++ .../sources/common/ResFont.h | 9 ++- .../sources/common/SdLogger.h | 10 ++++ .../sources/common/SimplePlayer.cpp | 4 +- .../sources/common/SimplePlayer.h | 19 +++++-- .../sources/common/Util.h | 42 ++++++++++++++ .../sources/common/VersionDetect.h | 1 + .../sources/common/common_Types.h | 4 ++ .../ConsoleBackup/Exporter/test_Exporter.cpp | 2 +- 29 files changed, 318 insertions(+), 67 deletions(-) diff --git a/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.cpp b/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.cpp index f0e6be4..a7a0ef9 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.cpp @@ -132,7 +132,7 @@ extern "C" void nnMain(void) common::Logger::InitializeEjectThread(); common::Logger::SetEjectHandler(OnSdEjected); // 起動時に削除 - common::Logger::GetLoggerInstance()->ClearLog(); + common::Logger::GetLoggerInstance()->ClearSdLog(); COMMON_LOGGER("\n"); COMMON_LOGGER("CTR Console Backup start\n"); diff --git a/trunk/ConsoleDataMigration/sources/ConsoleBackup/Controller.cpp b/trunk/ConsoleDataMigration/sources/ConsoleBackup/Controller.cpp index 3b4b98d..43a50b6 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleBackup/Controller.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleBackup/Controller.cpp @@ -168,7 +168,7 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector& operationMessage, bool& nextStep, bool& continueBackup); + +// バックアップ処理中かどうか bool InProgress(); + +// バックアップが完了したかどうか bool IsBackupSucceeded(); + +// バックアップが失敗したかどうか bool IsBackupFailed(); + +// SDカードが抜き出されたときに実行したい関数 void OnSdEjected(); + +// 状態を初期化する void InitializeState(); } diff --git a/trunk/ConsoleDataMigration/sources/ConsoleBackup/Exporter.cpp b/trunk/ConsoleDataMigration/sources/ConsoleBackup/Exporter.cpp index 7620da5..9594c24 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleBackup/Exporter.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleBackup/Exporter.cpp @@ -883,7 +883,7 @@ u32 GetProgress() return common::GetProgress(); } -bool IsExportFinished() +bool IsExportThreadFinished() { return s_ExportThread.IsValid() && !s_ExportThread.IsAlive(); } diff --git a/trunk/ConsoleDataMigration/sources/ConsoleBackup/Exporter.h b/trunk/ConsoleDataMigration/sources/ConsoleBackup/Exporter.h index 4266f8c..83d39d3 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleBackup/Exporter.h +++ b/trunk/ConsoleDataMigration/sources/ConsoleBackup/Exporter.h @@ -22,16 +22,33 @@ namespace ConsoleBackup { +// 出力ファイルリストのコンテキストを初期化する。出力ファイルリストを +// 生成する前に必ず呼び出す必要がある void InitializeFileListContext(); -void ExportTwlTitleList(); + +// 新たにスレッドを起動して、DSiWareのセーブデータをSDカードに出力する void ExportTwlSaveData(); + +// 新たにスレッドを起動して、TWL写真領域のデータをSDカードに出力する void ExportTwlPhotoData(); + +// 新たにスレッドを起動して、TWLサウンド領域のデータをSDカードに出力する void ExportTwlSoundData(); + +// 本体固有情報をSDカードに出力する +// 新たにスレッドを起動して、CTR領域のセーブデータをSDカードに出力する void ExportData(common::HardwareStateManager& manager); + +// NIMのセーブデータをSDカードから削除する void DeleteNimSaveData(); +// 出力スレッドの進捗を返す u32 GetProgress(); -bool IsExportFinished(); + +// 出力スレッドが終了したかどうか +bool IsExportThreadFinished(); + +// 出力スレッドを終了する void FinalizeExportThread(); diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Controller.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Controller.cpp index 5f07c68..4cda91e 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Controller.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Controller.cpp @@ -1051,7 +1051,7 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector& operationMessage, bool& nextStep); + +// リストア処理中かどうか bool InProgress(); + +// リストアが完了したかどうか bool IsRestoreSucceeded(); + +// リストアが失敗したかどうか bool IsRestoreFailed(); + +// 書き込みスレッドの進捗を返す u32 GetProgress(); + +// SDカードが抜き出されたときに実行したい関数 void OnSdEjected(); + +// SDカードが挿入されたときに実行したい関数 void OnSdInserted(); + +// 状態を初期化する void InitializeState(); + +// リストア状態を取得する RestoreMode GetRestoreMode(); } diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.cpp index ca7f51e..2abf898 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.cpp @@ -909,7 +909,7 @@ void FinalizeImportThread() s_ImportThread.Finalize(); } -bool IsImportFinished() +bool IsImportThreadFinished() { return s_ImportThread.IsValid() && !s_ImportThread.IsAlive(); } diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.h b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.h index fe2260d..4f0a49a 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.h +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.h @@ -25,29 +25,66 @@ namespace ConsoleRestore { +// SDカードのデバイスIDファイルと本体のデバイスIDが一致しているかどうか nn::Result EqualsDeviceIdFileandDeviceId(common::HardwareStateManager& manager); + +// SDカードのリージョンと本体のリージョンが一致しているかどうか nn::Result EqualsRegionDataandRegion(); + +// シリアルナンバーを取得する nn::Result ReadSerialNumber(u8* serial); + +// 出力ファイル一覧を読み込む nn::Result SetupFileList(); +// インポート用のスレッドを終了する void FinalizeImportThread(); -bool IsImportFinished(); + +// インポート用のスレッドが終了したかどうか +bool IsImportThreadFinished(); + +// 新たにスレッドを立て、TWLサウンド領域をインポートする void ImportTwlSoundData(); + +// 新たにスレッドを立て、TWL-NAND領域をインポートする void ImportTwlSaveData(); + +// 新たにスレッドを立て、TWL写真領域をインポートする void ImportTwlPhotoData(); + +// 本体固有データを読み込む +// 新たにスレッドを立て、CTRセーブデータ領域をインポートする nn::Result ImportData(); + +// インポート完了ファイルを作る void CreateWriteFinishedFile(); + +// ネットワークアップデート完了ファイルを作る void CreateUpdateFinishedFile(); + +// 本体初期化完了ファイルを作る void CreateConsoleInitializedFile(); + +// RTC書き込み完了ファイルを作る void CreateRtcSyncFinishedFile(); + +// IVSダウンロード完了ファイルを作る void CreateDownloadIvsFinishedFile(); + +// アカウント削除完了ファイルを作る void CreateDeleteAccountFinishedFile(); + +// アカウント移行完了ファイルを作る void CreateTransferAccountFinishedFile(); + +// インポートスレッドの進捗を取得する u32 GetImportProgress(); // NANDのごみを削除する void Cleanup(); + +// ファイルが存在するかどうか確認するためのテーブル const wchar_t* const CHECK_FILENAME_TABLE[] = { common::UPDATE_CHECK_PATHNAME, @@ -59,6 +96,7 @@ const wchar_t* const CHECK_FILENAME_TABLE[] = common::TRANSFER_ACCOUNT_CHECK_PATHNAME }; +// ファイル存在確認をクリアする void DeleteAllCheckFiles(); struct TimeZone @@ -69,8 +107,15 @@ struct TimeZone NN_PADDING3; }; +// ネットワーク設定ファイルを読み込む bool ReadSetting(bool* nupOnly, bool* getIvs); + +// ネットワーク設定ファイルからNTPサーバの名前を取得する +// 先にReadSettingが成功している必要がある char* GetNtpServerName(); + +// ネットワーク設定ファイルからタイムゾーンを取得する +// 先にReadSettingが成功している必要がある TimeZone GetTimeZone(); struct CheckedNetworkSetting @@ -80,13 +125,21 @@ struct CheckedNetworkSetting NN_PADDING3; }; +// SDカードから読み込んだネットワーク設定ファイルから生成した +// インターネット設定へのポインタを取得する +// インターネット設定は内部のバッファに読み込む CheckedNetworkSetting* GetTempNetworkSetting(); + +// 国設定を読み込む nn::Result ImportCountryLanguageData(); + +// RTCを読み込む nn::Result ImportMcuRtc(common::HardwareStateManager& manager); // TWL写真領域を初期化してから本体初期化を行う void InitializeFileSystem(); +// SDカードのファイルと本体情報の比較結果をクリアする void ClearFileReadResult(); // プレイ履歴を読み込みます。ptmのセーブデータ移行後に呼び出す必要があります diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/NtpClient.h b/trunk/ConsoleDataMigration/sources/ConsoleRestore/NtpClient.h index 7c7bcf1..0e9514e 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/NtpClient.h +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/NtpClient.h @@ -19,8 +19,13 @@ namespace ConsoleRestore { +// 新たにスレッドを立て、NTPサーバと同期する u32 AdjustTime(); + +// NTPサーバとの同期が終了したかどうか bool IsTimeAdjustFinished(); + +// NTPサーバとの同期が完了したかどうか bool IsTimeAdjustSuccessed(); } diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Shop.h b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Shop.h index c3b513e..8dac86e 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Shop.h +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Shop.h @@ -19,11 +19,12 @@ #include #include -const char* const CONSOLE_RESTORE_TIN = "987654321"; - namespace ConsoleRestore { +// ショップサーバにConsoleResotoreが接続するためのTINコード +const char* const CONSOLE_RESTORE_TIN = "987654321"; + typedef enum SHOP_OPERATION { SHOP_OPERATION_CONNECT, // Shop::ConnectしてCloseするだけ @@ -35,6 +36,7 @@ typedef enum SHOP_OPERATION } ShopOperation; +// ショップ操作のモード表示用文字列(デバッグ用) const char* const SHOP_OPERATION_STR[] = { "Connect", @@ -44,10 +46,19 @@ const char* const SHOP_OPERATION_STR[] = "Download Title" }; +// 新たにスレッドを立て、ショップ操作を開始する void StartShopOperationSingle(ShopOperation op, nn::nim::TitleConfig config); + +// 新たにスレッドを立て、ショップ操作を開始する void StartShopOperationSingle(ShopOperation op); + +// ショップ操作スレッドを終了する void FinalizeShopOperationSingle(); + +// ショップ操作スレッドが終了したかどうか bool IsShopOperationSingleFinished(); + +// ショップ操作のResultを取得する nn::Result GetShopOperationSingleResult(); } diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.h b/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.h index 453c1dd..043ef6b 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.h +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.h @@ -21,17 +21,23 @@ namespace ConsoleRestore { +// 新たにスレッドを立て、タイトルのダウンロードを開始する void StartTitleDownload(); + +// タイトルのダウンロードスレッドを終了する bool DownloadTitleFinished(); + +// タイトルのダウンロードスレッドが成功したかどうか bool DownloadTitleSucceeded(); - +// ショップからタイトルをダウンロードするためのクラス class TitleDownloader { public: TitleDownloader(); virtual ~TitleDownloader(); + // タイトルのダウンロードを開始する void Start(); NN_PADDING4; diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Updater.h b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Updater.h index 32e6798..7802590 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Updater.h +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Updater.h @@ -21,10 +21,19 @@ namespace ConsoleRestore { +// 新たにスレッドを立て、ネットワークアップデートを開始する void StartFGNetworkUpdate(); + +// ネットワークアップデートスレッドを終了する void FinishFGNetworkUpdate(); + +// ネットワークアップデートスレッドが終了したかどうか bool IsNetworkUpdateFinished(); + +// ネットワークアップデートの進捗を取得する u32 GetUpdateProgress(); + +// ネットワークアップデートのResultを取得する nn::Result GetUpdateResult(); } diff --git a/trunk/ConsoleDataMigration/sources/common/CommonLogger.cpp b/trunk/ConsoleDataMigration/sources/common/CommonLogger.cpp index 773a3e2..1202aec 100644 --- a/trunk/ConsoleDataMigration/sources/common/CommonLogger.cpp +++ b/trunk/ConsoleDataMigration/sources/common/CommonLogger.cpp @@ -64,7 +64,7 @@ void CommonLogger::Print(const char* fmt, ...) va_end(vlist); } -void CommonLogger::PrintResult(const char* fmt, ...) +void CommonLogger::PrintResultSdLog(const char* fmt, ...) { nn::os::CriticalSection::ScopedLock lock(m_CriticalSection); va_list vlist; @@ -76,7 +76,7 @@ void CommonLogger::PrintResult(const char* fmt, ...) va_end(vlist); } -void CommonLogger::ClearLog() +void CommonLogger::ClearSdLog() { nn::os::CriticalSection::ScopedLock lock(m_CriticalSection); GetSdInstance()->Clear(); diff --git a/trunk/ConsoleDataMigration/sources/common/CommonLogger.h b/trunk/ConsoleDataMigration/sources/common/CommonLogger.h index 2105eae..caa15e5 100644 --- a/trunk/ConsoleDataMigration/sources/common/CommonLogger.h +++ b/trunk/ConsoleDataMigration/sources/common/CommonLogger.h @@ -20,21 +20,20 @@ #include "demo.h" #include "SdLogger.h" -#include "LogConsole.h" #define COMMON_LOGGER( ... ) (void)common::Logger::GetLoggerInstance()->Print(__VA_ARGS__) #define COMMON_LOGGER_RESULT(result, func) \ (void)nn::dbg::PrintResult(result); \ - (void)common::Logger::GetLoggerInstance()->PrintResult("Func = %s\n", func); \ - (void)common::Logger::GetLoggerInstance()->PrintResult("Result = %X\n", result.GetPrintableBits()); \ + (void)common::Logger::GetLoggerInstance()->PrintResultSdLog("Func = %s\n", func); \ + (void)common::Logger::GetLoggerInstance()->PrintResultSdLog("Result = %X\n", result.GetPrintableBits()); \ #define COMMON_LOGGER_RESULT_WITH_LINE(result, line, func) \ (void)nn::dbg::detail::Printf("%s\n", func); \ (void)nn::dbg::detail::Printf("%d\n", line); \ (void)nn::dbg::PrintResult(result); \ - (void)common::Logger::GetLoggerInstance()->PrintResult("Func = %s\n", func); \ - (void)common::Logger::GetLoggerInstance()->PrintResult("line = %d\n", line); \ - (void)common::Logger::GetLoggerInstance()->PrintResult("Result = %X\n", result.GetPrintableBits()); \ + (void)common::Logger::GetLoggerInstance()->PrintResultSdLog("Func = %s\n", func); \ + (void)common::Logger::GetLoggerInstance()->PrintResultSdLog("line = %d\n", line); \ + (void)common::Logger::GetLoggerInstance()->PrintResultSdLog("Result = %X\n", result.GetPrintableBits()); \ #define COMMON_LOGGER_RESULT_IF_FAILED(result) \ if(result.IsFailure()) \ @@ -54,6 +53,7 @@ namespace common namespace Logger { +// SDカードのログと下画面ログを同時に扱うためのクラス class CommonLogger { public: @@ -63,13 +63,28 @@ public: void Initialize(u32 width, u32 height, u32 maxLine, demo::RenderSystemDrawing* renderSystem); void Finalize(); + // SDログに書き込み、下画面ログ出力のためのバッファに溜め込む void Print(const char* fmt, ...); - void PrintResult(const char* fmt, ...); - void ClearLog(); + + // SDログのみにResult値を出力する + void PrintResultSdLog(const char* fmt, ...); + + // SDカードのログファイルを消去する + void ClearSdLog(); + + // 下画面ログを上スクロールする void ScrollUp(); + + // 下画面ログを下スクロールする void ScrollDown(); + + // 下画面ログの先頭にスクロールする void ScrollToBegin(); + + // 下画面ログの末尾にスクロールする void ScrollToEnd(); + + // バッファに溜め込まれた文字列を下画面ログに書き込む void DrawConsole(); private: nn::os::CriticalSection m_CriticalSection; diff --git a/trunk/ConsoleDataMigration/sources/common/DrawSystemState.h b/trunk/ConsoleDataMigration/sources/common/DrawSystemState.h index 8fabcfa..8acab14 100644 --- a/trunk/ConsoleDataMigration/sources/common/DrawSystemState.h +++ b/trunk/ConsoleDataMigration/sources/common/DrawSystemState.h @@ -43,8 +43,13 @@ namespace common { +// 現在の描画先ディスプレイを返す +// target NN_GX_DISPLAY0 または NN_GX_DISPLAY1 +// flip 上下画面を入れ替えているかどうか u32 GetRenderTarget(u32 target, bool flip = false); +// システム状態を描画する +// InitializeResFont()、demo::RenderSystemDrawing.Initializeが呼び出されている必要がある void DrawSystemState ( const char* toolName, diff --git a/trunk/ConsoleDataMigration/sources/common/FileChecker.cpp b/trunk/ConsoleDataMigration/sources/common/FileChecker.cpp index adbf808..5f8dd4b 100644 --- a/trunk/ConsoleDataMigration/sources/common/FileChecker.cpp +++ b/trunk/ConsoleDataMigration/sources/common/FileChecker.cpp @@ -116,11 +116,6 @@ bool ExistsCountryLanguageFile() return ExistsFile(EXISTS_COUNTRY_LANGUAGE); } -bool ExistsVersionData() -{ - return ExistsFile(EXISTS_VERSION_DATA); -} - bool ExistsRegionData() { return ExistsFile(EXISTS_REGION_DATA); diff --git a/trunk/ConsoleDataMigration/sources/common/FileChecker.h b/trunk/ConsoleDataMigration/sources/common/FileChecker.h index a6821c5..3d5faf8 100644 --- a/trunk/ConsoleDataMigration/sources/common/FileChecker.h +++ b/trunk/ConsoleDataMigration/sources/common/FileChecker.h @@ -21,24 +21,25 @@ namespace common { +// チェックしたいファイルのリスト typedef enum FILE_EXISTS_CHECK { - EXISTS_UPDATE_FINISHED, - EXISTS_SERIAL_NUMBER, - EXISTS_IVS, - EXISTS_CONSOLE_INTIALIZED, - EXISTS_WRITE_FINISHED, - EXISTS_AP_SETTING, - EXISTS_RTC_SYNC_FINISHED, - EXISTS_COUNTRY_LANGUAGE, - EXISTS_VERSION_DATA, - EXISTS_REGION_DATA, - EXISTS_DELETE_ACCOUNT, - EXISTS_TRANSFER_ACCOUNT, - EXISTS_DOWNLOAD_IVS, + EXISTS_UPDATE_FINISHED, // ネットワークアップデート完了 + EXISTS_SERIAL_NUMBER, // シリアルナンバー + EXISTS_IVS, // IVS + EXISTS_CONSOLE_INTIALIZED, // 本体初期化完了 + EXISTS_WRITE_FINISHED, // 書き込み完了 + EXISTS_AP_SETTING, // 無線設定ファイル + EXISTS_RTC_SYNC_FINISHED, // RTC書き込み完了 + EXISTS_COUNTRY_LANGUAGE, // 国設定書き込み完了 + EXISTS_REGION_DATA, // リージョン + EXISTS_DELETE_ACCOUNT, // アカウント削除完了 + EXISTS_TRANSFER_ACCOUNT, // アカウント移行完了 + EXISTS_DOWNLOAD_IVS, // IVSダウロード完了 EXISTS_MAX } FileExistsCheck; +// チェックしたいファイルのリストに対応したパス const wchar_t* const FILENAME_TABLE[EXISTS_MAX] = { common::UPDATE_CHECK_PATHNAME, @@ -49,14 +50,15 @@ const wchar_t* const FILENAME_TABLE[EXISTS_MAX] = common::AP_SETTING_PATHNAME, common::RTC_SYNC_CHECK_PATHNAME, common::COUNTRY_SETTING_PATHNAME, - common::VERSION_DATA_PATHNAME, common::REGION_DATA_PATHNAME, common::DELETE_ACCOUNT_CHECK_PATHNAME, common::TRANSFER_ACCOUNT_CHECK_PATHNAME, common::DOWNLOAD_IVS_CHECK_PATHNAME }; +// ファイルが存在するかどうか bool CheckFileExists(const wchar_t* path); + bool ExistsUpdateCheckedFile(); bool ExistsSerialNumberFile(); bool ExistsIVSFile(); @@ -65,14 +67,17 @@ bool ExistsWriteFinishedFile(); bool ExistsAPSetting(); bool ExistsRtcSyncFinishedFile(); bool ExistsCountryLanguageFile(); -bool ExistsVersionData(); bool ExistsRegionData(); bool ExistsDeleteAccountChecked(); bool ExistsTransferAccountChecked(); bool ExistsDownloadIvsCheckedFile(); +// ファイルチェックの結果を初期化する +// 一度チェックするとその結果を保持するため +// ファイルを作成したり削除した時に呼ぶ必要がある void ClearFileCheck(FileExistsCheck index); +// 全てのファイルチェックの結果を初期化する void InitializeFileCheck(); } diff --git a/trunk/ConsoleDataMigration/sources/common/FileTransfer.cpp b/trunk/ConsoleDataMigration/sources/common/FileTransfer.cpp index 6198b31..4678c06 100644 --- a/trunk/ConsoleDataMigration/sources/common/FileTransfer.cpp +++ b/trunk/ConsoleDataMigration/sources/common/FileTransfer.cpp @@ -134,8 +134,6 @@ bool ExistsInList(ImportDataList* fileList, const wchar_t* path, bool isDirector return returnValue; } -// 単一のディレクトリを作成する -// アーカイブはマウント済みにしておく void ExportTwlSaveDirectory(const wchar_t* dirPath, nn::fs::FileOutputStream* list, nn::crypto::Sha256Context* listContext) { @@ -147,8 +145,6 @@ void ExportTwlSaveDirectory(const wchar_t* dirPath, nn::fs::FileOutputStream* li AddPathNameAndUpdateContext(list, dirPath, -1, listContext); } -// 単一のファイルをコピーする -// アーカイブはマウント済みにしておく bool ExportTwlSaveFile(const wchar_t* from_path, const wchar_t* to_path, void* buf, const size_t bufSize, nn::fs::FileOutputStream* list, nn::crypto::Sha256Context* listContext) { @@ -309,12 +305,6 @@ bool ExportTwlSaveFile(const wchar_t* from_path, const wchar_t* to_path, void* b } -// ディレクトリ間のコピー -// アーカイブ越しのコピーが可能 -// アーカイブにマウントした状態で呼び出す必要あり -// 書き込み先のディレクトリはあらかじめ消去しておくこと。 -// 引数はスラッシュ付き -// TODO:分割して短くする bool CopyDirectory(ImportDataList* fileList, const wchar_t * from_path, const wchar_t * to_path, void* buf, const size_t bufSize, bool encode, nn::fs::FileOutputStream* list, nn::crypto::Sha256Context* listContext) { diff --git a/trunk/ConsoleDataMigration/sources/common/FileTransfer.h b/trunk/ConsoleDataMigration/sources/common/FileTransfer.h index 10505f0..625b65a 100644 --- a/trunk/ConsoleDataMigration/sources/common/FileTransfer.h +++ b/trunk/ConsoleDataMigration/sources/common/FileTransfer.h @@ -24,16 +24,37 @@ namespace common { +// currentDirectory以下のファイル数、ファイルサイズを再帰的に計算する nn::Result CalculateFileNum(std::wstring currentDirectory, u32& fileNum, s64& fileSize); + +// 単一のディレクトリを作成する +// アーカイブはマウント済みにしておく void ExportTwlSaveDirectory(const wchar_t* dirPath, nn::fs::FileOutputStream* list, nn::crypto::Sha256Context* listContext); + +// 単一のファイルをコピーする +// アーカイブはマウント済みにしておく bool ExportTwlSaveFile(const wchar_t* from_path, const wchar_t* to_path, void* buf, const size_t bufSize, nn::fs::FileOutputStream* list, nn::crypto::Sha256Context* listContext); + +// ディレクトリ間のコピー +// アーカイブ越しのコピーが可能 +// アーカイブにマウントした状態で呼び出す必要あり +// 書き込み先のディレクトリはあらかじめ消去しておくこと。 +// 引数はスラッシュ付き +// TODO:分割して短くする bool CopyDirectory(ImportDataList* fileList, const wchar_t * from_path, const wchar_t * to_path, void* buf, const size_t bufSize, bool encode, nn::fs::FileOutputStream* list, nn::crypto::Sha256Context* listContext); + +// ファイル転送の進捗を取得する +// InitializeTransferProgress で設定した値を100とする割合が返される u32 GetProgress(); + +// ファイル転送の目標値を設定する void InitializeTransferProgress(u64 totalSize); +// wchar_t* を char* に変換する。 +// 内部のバッファを使用するためスレッドアンセーフ const char* GetCharStr(const wchar_t* path); } diff --git a/trunk/ConsoleDataMigration/sources/common/LogConsole.h b/trunk/ConsoleDataMigration/sources/common/LogConsole.h index b8a7d52..9b120bc 100644 --- a/trunk/ConsoleDataMigration/sources/common/LogConsole.h +++ b/trunk/ConsoleDataMigration/sources/common/LogConsole.h @@ -34,11 +34,22 @@ public: void Initialize(u32 width, u32 height, u32 maxLine, demo::RenderSystemDrawing* renderSystem); + // コンソールに描画する文字列を追加する void AddText(const char* fmt, ::std::va_list arg); + + // 上スクロールする void ScrollUp(); + + // 下スクロールする void ScrollDown(); + + // 先頭にスクロールする void ScrollToBegin(); + + // 末尾にスクロールする void ScrollToEnd(); + + // AddTextで追加された文字列を描画する void Print(); private: diff --git a/trunk/ConsoleDataMigration/sources/common/ResFont.h b/trunk/ConsoleDataMigration/sources/common/ResFont.h index ca53420..379a0bb 100644 --- a/trunk/ConsoleDataMigration/sources/common/ResFont.h +++ b/trunk/ConsoleDataMigration/sources/common/ResFont.h @@ -21,9 +21,16 @@ namespace common { +// ResFontを初期化する。 void InitializeResFont(); -void DrawResFont(s32 display); + +// 文字列の描画時に実行したいハンドラを設定する void SetDrawTextHandler(void (*func)()); + +// SetDrawTextHandler で設定した関数を使って文字列を描画する +void DrawResFont(s32 display); + +// 内部で保持しているTextWriterへのポインタを返す nn::font::TextWriter* GetTextWriter(); diff --git a/trunk/ConsoleDataMigration/sources/common/SdLogger.h b/trunk/ConsoleDataMigration/sources/common/SdLogger.h index 2dc736f..6d543f2 100644 --- a/trunk/ConsoleDataMigration/sources/common/SdLogger.h +++ b/trunk/ConsoleDataMigration/sources/common/SdLogger.h @@ -30,8 +30,13 @@ public: SdLogger(); ~SdLogger() {}; + // SDログに文字列を出力する void Print(const char* fmt, ::std::va_list arg); + + // SDログを削除する void Clear(); + + // 内部状態を初期化する。SDカード挿抜時に呼ばれることを期待 void Inactivate(); private: @@ -44,11 +49,16 @@ private: }; +// SDカード挿抜用のスレッドを初期化する void InitializeEjectThread(); + // SDカードが抜けた時に呼ばれるコールバック void SetEjectHandler(void (*func)()); + // SDカードが挿入された時に呼ばれるコールバック void SetInsertHandler(void (*func)()); + +// 内部で保持しているインスタンスへのポインタを返す SdLogger* GetSdInstance(); } // namespace Logger diff --git a/trunk/ConsoleDataMigration/sources/common/SimplePlayer.cpp b/trunk/ConsoleDataMigration/sources/common/SimplePlayer.cpp index 97e8a76..b04e2ad 100644 --- a/trunk/ConsoleDataMigration/sources/common/SimplePlayer.cpp +++ b/trunk/ConsoleDataMigration/sources/common/SimplePlayer.cpp @@ -181,9 +181,9 @@ void InitializeSimplePlayer() threadSound.Start(SoundThreadFunc, s_SoundThreadStack); } -void PlaySound(u8 index) +void PlaySound(SoundEffect index) { - NN_ASSERT(index <= nFiles); + NN_ASSERT(index < SOUND_MAX); while(!s_SoundThreadInitialized) { diff --git a/trunk/ConsoleDataMigration/sources/common/SimplePlayer.h b/trunk/ConsoleDataMigration/sources/common/SimplePlayer.h index b7fe76e..2f73c78 100644 --- a/trunk/ConsoleDataMigration/sources/common/SimplePlayer.h +++ b/trunk/ConsoleDataMigration/sources/common/SimplePlayer.h @@ -19,19 +19,26 @@ namespace common { -enum SoundEffect +typedef enum SoundEffect { SOUND_OK, SOUND_NG, SOUND_CURSOR, - SOUND_ANNOTATION -}; + SOUND_ANNOTATION, + SOUND_MAX +} SoundEffect; + +// サウンドを鳴らすための初期化を行う void InitializeSimplePlayer(); -void FinalizeSimplePlayer(); -void PlaySound(u8 index); -} // namespace ConsoleBackup +// 終了処理を行う +void FinalizeSimplePlayer(); + +// サウンドを鳴らす +void PlaySound(SoundEffect index); + +} // namespace common #endif /* SIMPLEPLAYER_H_ */ diff --git a/trunk/ConsoleDataMigration/sources/common/Util.h b/trunk/ConsoleDataMigration/sources/common/Util.h index 4fb6a4f..17151c0 100644 --- a/trunk/ConsoleDataMigration/sources/common/Util.h +++ b/trunk/ConsoleDataMigration/sources/common/Util.h @@ -36,28 +36,70 @@ public: void Initialize(); void Finalize(); + // シリアルナンバーにモジュラス10 ウェイト3・1(M10W31)でチェックデジットを付加する static void AddCheckDigit(char* serial); + + // IVSから計算されるセーブデータディレクトリ名を取得する static void GetSaveDataDirectoryRoot(::std::string& sysSaveRoot, void* ivs, size_t size); + // ACアダプタが接続されているかどうか bool IsAdapterConnected(); + + // バッテリ残量が10%未満かどうか bool IsBatteryLower(); + + // IVSを読み取れるかどうか bool CanReadIVS(); + + // シリアルナンバーを読み取れるかどうか bool CanReadSerialNumber(); + + // シリアルナンバーを取得する void GetSerialNumber(u8** serial, size_t* size); + + // シリアルナンバーを返す u8* GetSerialNumber(); + + // IVSを取得する void GetIvs(void** ivs, size_t* size); + + // 32bitデバイスIDを返す bit32 GetDeviceId(); + + // CUPメジャーバージョンを返す u8 GetCupMajorVersion(); + + // CUPマイナーバージョンを返す u8 GetCupMinorVersion(); + + // CUPマイクロバージョンを返す u8 GetCupMicroVersion(); + + // NUPバージョンを返す u8 GetNupVersion(); + + // MCUプロセスに接続するためのハンドルを返す nn::Handle GetMcuHandle(); + + // バッテリ残量を0~100で返す u32 GetBatteryRemain(); + + // 64bitインフラデバイスIDを返す u64 GetInfraDeviceId(); + + // フレンドコードを返す u64 GetFriendcode(); + + // MACアドレスを返す char8* GetMacAddress(); + + // リージョンコードを返す nn::cfg::CTR::CfgRegionCode GetRegion(); + + // リージョンコードを3文字のアルファベットに置き換えた文字列を返す const char* GetRegionCodeA3(); + + // バージョン情報を取得する void GetVersionData(common::VerDef* version); diff --git a/trunk/ConsoleDataMigration/sources/common/VersionDetect.h b/trunk/ConsoleDataMigration/sources/common/VersionDetect.h index 652ed09..9b41b56 100644 --- a/trunk/ConsoleDataMigration/sources/common/VersionDetect.h +++ b/trunk/ConsoleDataMigration/sources/common/VersionDetect.h @@ -22,6 +22,7 @@ namespace common { +// リージョンコードに基づいてバージョン情報を取得する void GetSystemVersion(common::VerDef* mVerData, nn::cfg::CTR::CfgRegionCode region); } diff --git a/trunk/ConsoleDataMigration/sources/common/common_Types.h b/trunk/ConsoleDataMigration/sources/common/common_Types.h index 7d56462..e36889c 100644 --- a/trunk/ConsoleDataMigration/sources/common/common_Types.h +++ b/trunk/ConsoleDataMigration/sources/common/common_Types.h @@ -60,6 +60,7 @@ struct VerDef nn::pl::CTR::NetworkUpdateVersion nup; }; +// CALに依存するCFGパラメータ struct CfgCalData { nn::cfg::CTR::detail::TouchPanelCfgData touchPanelCfgData; @@ -89,6 +90,7 @@ const nn::ProgramId cNupVerId[] = nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_EU, }; +// SDに出力するデータのヘッダ struct BackupDataHeader { s64 size; // パディングを含まないファイルサイズ @@ -96,6 +98,7 @@ struct BackupDataHeader NN_PADDING4; }; +// SDから読み込むファイルリストのエントリ struct ImportDataEntry { std::string fileName; @@ -105,6 +108,7 @@ struct ImportDataEntry typedef std::vector ImportDataList; +// TWLセーブデータリストのエントリ struct SavePathInfo { std::wstring name; diff --git a/trunk/ConsoleDataMigration/sources/tests/ConsoleBackup/Exporter/test_Exporter.cpp b/trunk/ConsoleDataMigration/sources/tests/ConsoleBackup/Exporter/test_Exporter.cpp index 436e3d6..486e320 100644 --- a/trunk/ConsoleDataMigration/sources/tests/ConsoleBackup/Exporter/test_Exporter.cpp +++ b/trunk/ConsoleDataMigration/sources/tests/ConsoleBackup/Exporter/test_Exporter.cpp @@ -98,7 +98,7 @@ void ExporterTest::ExportTwlSaveData() NN_LOG("WriteTwlTitleData\n"); ConsoleBackup::ExportTwlSaveData(); - while (!ConsoleBackup::IsExportFinished()) + while (!ConsoleBackup::IsExportThreadFinished()) { nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(10)); }