From 08a942a45e6c36bd4ca4919f8d447d720dbaa96b Mon Sep 17 00:00:00 2001 From: mizu Date: Tue, 13 Dec 2011 02:34:46 +0000 Subject: [PATCH] git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@537 385bec56-5757-e545-9c3a-d8741f4650f1 --- trunk/CardSaveData/Mover/Imp/OMakefile | 7 +- trunk/CardSaveData/Mover/Imp/source/main.cpp | 16 +- .../Mover/Imp/source/main_nochk.cpp | 398 ++++ .../Mover/Imp/source/main_test_only.cpp | 163 ++ .../マスタリング時はomakeのIMPOTEE_PATH確認 | 0 trunk/CardSaveData/Mover/body/OMakefile | 21 +- trunk/CardSaveData/Mover/body/body_card1.rsf | 30 + trunk/CardSaveData/Mover/body/body_card2.rsf | 33 + .../Mover/body/romfiles/lang_en.mes | Bin 0 -> 468 bytes .../Mover/body/romfiles/lang_jp.mes | Bin 0 -> 320 bytes .../body/romfiles/langファイルについて.txt | 3 + trunk/CardSaveData/Mover/body/source/main.cpp | 1694 +++++++++++++---- trunk/CardSaveData/Mover/body/source/main.h | 8 + .../Mover/body/source/screen/screen.cpp | 361 ++-- .../Mover/body/source/screen/screen.h | 69 +- trunk/CardSaveData/Mover/body/ver.h | 7 +- trunk/CardSaveData/Mover/release.txt | 5 + 17 files changed, 2253 insertions(+), 562 deletions(-) create mode 100644 trunk/CardSaveData/Mover/Imp/source/main_nochk.cpp create mode 100644 trunk/CardSaveData/Mover/Imp/source/main_test_only.cpp create mode 100644 trunk/CardSaveData/Mover/Imp/マスタリング時はomakeのIMPOTEE_PATH確認 create mode 100644 trunk/CardSaveData/Mover/body/body_card1.rsf create mode 100644 trunk/CardSaveData/Mover/body/body_card2.rsf create mode 100644 trunk/CardSaveData/Mover/body/romfiles/lang_en.mes create mode 100644 trunk/CardSaveData/Mover/body/romfiles/lang_jp.mes create mode 100644 trunk/CardSaveData/Mover/body/romfiles/langファイルについて.txt create mode 100644 trunk/CardSaveData/Mover/body/source/main.h diff --git a/trunk/CardSaveData/Mover/Imp/OMakefile b/trunk/CardSaveData/Mover/Imp/OMakefile index b16c825..c530e20 100644 --- a/trunk/CardSaveData/Mover/Imp/OMakefile +++ b/trunk/CardSaveData/Mover/Imp/OMakefile @@ -23,6 +23,7 @@ SUPPORTED_TARGETS = CTR-*.Process.MPCore.* SOURCES[] = ./source/main.cpp + #./source/main_nochk.cpp ../../common/test_data.cpp ../../common/shfnt.cpp ../../common/sleep.cpp @@ -39,9 +40,9 @@ LIBS += libnn_ps IMPORTEE_CIA = importee.cia -SRC_IMPORTEE_PATH = ../body/images/$(BUILD_TARGET_DIR)/$(BUILD_TYPE_DIR)/CtrSaveDataMover.cia +#SRC_IMPORTEE_PATH = ../body/images/$(BUILD_TARGET_DIR)/$(BUILD_TYPE_DIR)/CtrSaveDataMover.cia #とりあえず、マスタリング時は直おき、配置時に改名 -#SRC_IMPORTEE_PATH = CtrSaveDataMover_master.cia +SRC_IMPORTEE_PATH = CtrSaveDataMover_master.cia # ビルドタイプ別に romfs を作る #ROMFS_ROOT = $`(TARGET.getObjectDirectory)/romfsroot @@ -57,7 +58,7 @@ ROMFS_IMPORTEE_PATH = L\"rom:/$(IMPORTEE_CIA)\" CCFLAGS += -DROMFS_IMPORTEE_PATH=$(ROMFS_IMPORTEE_PATH) ROM_SPEC_FILE = Imp.rsf -DESCRIPTOR = $(CTRSDK_ROOT)/resources/specfiles/repairtool.desc +DESCRIPTOR = $(CTRSDK_ROOT)/resources/specfiles/private/repairtool.desc # バナー、アイコン #CTR_BANNER_SPEC = banner.bsf diff --git a/trunk/CardSaveData/Mover/Imp/source/main.cpp b/trunk/CardSaveData/Mover/Imp/source/main.cpp index 32e77e2..e7936a2 100644 --- a/trunk/CardSaveData/Mover/Imp/source/main.cpp +++ b/trunk/CardSaveData/Mover/Imp/source/main.cpp @@ -300,9 +300,12 @@ void nnMain( void ) s_RenderSystem.SwapBuffers(); shf_SetScale(0.5,0.5); - sprintf(ver,"version %.2f",VERSION); - drawText(250,40,ver); - + if (VERSION != 0.0){ + sprintf(ver,"version %.2f",VERSION); + drawText(250,40,ver); + }else{ + drawText(250,40,VERSION_TXT); + } shf_SetScale(0.7,0.7); if (result.IsFailure())ErrorStop("Initialize");//初期化に失敗 if (READ_BUFFER_SIZE < LIST_LENGTH)ErrorStop("buffer size");//バッファサイズのチェック @@ -350,7 +353,7 @@ void nnMain( void ) //シリアル表示(オプション)後にチェック //デバッガ=15,実機=11 - if (GettedSerLen < 11)ErrorStop("invalid Serial"); + //if (GettedSerLen < 11)ErrorStop("invalid Serial"); fsize = FileRead(SIGN_FILE);//署名リード if(fsize != 256)ErrorStop("sign file");//鍵のbit長は2046固定 @@ -400,9 +403,8 @@ void nnMain( void ) } //プログラムミス、コードバグ対策 - //値が小さいと判定が緩くなるが、動作確認時にスルーしそうなので - //念の為チェック - if (GettedSerLen < 11)ErrorStop("invalid Serial"); + //2011.11 海外は桁が少ないらしい、NOA配布で問題出たので削除 + // if (GettedSerLen < 11)ErrorStop("invalid Serial"); //本体シリアルがリストにあるかチェック n =0; diff --git a/trunk/CardSaveData/Mover/Imp/source/main_nochk.cpp b/trunk/CardSaveData/Mover/Imp/source/main_nochk.cpp new file mode 100644 index 0000000..16a229a --- /dev/null +++ b/trunk/CardSaveData/Mover/Imp/source/main_nochk.cpp @@ -0,0 +1,398 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: main.cpp + + Copyright (C)2009 Nintendo Co., Ltd. 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. + + *---------------------------------------------------------------------------*/ + +//****************** 注意 ********************* +// 作成者が手元でテストするためのインポータ +// シリアルチェックを省いているので +// 部外リリースに使ってはいけない +//*********************************************** + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "demo.h" +#include "../../body/ver.h" +#include "../../../common/sleep.h" +#include "../../../common/common.h" +#include "../../../common/shfnt.h" +#include "../../../common/test_data.h" + +#define INF_FILE "sdmc:/csm_inf.txt" + +#define KEY_LENGTH 2048 + + +extern "C" { + extern u8* PUBLIC_KEY_BEGIN[]; + extern u8* PUBLIC_KEY_END[]; + + const void* PUBLIC_KEY = PUBLIC_KEY_BEGIN; +} + +demo::RenderSystemDrawing s_RenderSystem; +nn::fnd::ExpHeap appHeap; +uptr heapForGx; +void ErrorStop(char *s); +void ErrorPOff(char *s); + +const size_t ROMFS_BUFFER_SIZE = 64*1024;//ROMマウント用 +const size_t READ_BUFFER_SIZE = 64*1024; + +namespace +{ + u8* readBuf; + u8* romfsBuf; + +} +nn::Result result; + + +bool ImportFile(nn::fs::MediaType mediaType, wchar_t* filename) +{ + //nn::Result result; + + nn::fs::FileOutputStream* stream; + result = nn::am::BeginImportProgram(&stream, mediaType); + if (result.IsSuccess()) + { + //NN_LOG("Importing: %ls...", filename); + nn::fs::FileInputStream in(filename); + + while(s32 read = in.Read(readBuf, READ_BUFFER_SIZE)) + { + stream->Write(readBuf, read); + } + result = nn::am::EndImportProgram(stream); + } + return result.IsSuccess(); +} + +#define LIST_MAX 4000 +#define LIST_LENGTH (LIST_MAX * (nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN+1)) +u8 s_list[LIST_MAX][nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN+1];//シリアルリスト +u8 sign[256];//署名 +u8 serialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN+1]; + +//本体シリアル取得 +int GettedSerLen; +bool GetSerial(){ + nn::cfg::CTR::init::Initialize(); + nn::cfg::CTR::system::Initialize(); + result = nn::cfg::CTR::system::GetSerialNo(serialNo); + nn::cfg::CTR::system::Finalize(); + nn::cfg::CTR::init::Finalize(); + serialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN] = 0; + GettedSerLen = strlen((char*)serialNo); + return result.IsSuccess(); +} + + + +//#define setColor(r,g,b,a) s_RenderSystem.SetColor(r,g,b,a) +void setColor(f32 r,f32 g,f32 b,f32 a){ shf_SetColor(r,g,b,a);} +//#define setText(x,y,s) s_RenderSystem.DrawText(x,y,s) +void drawText(u16 x,u16 y,char *s){ shf_DrawText_0( x,y,s);} +//上はASCIIのみ対応したTextWriterへのラッパ +//日本語表示の場合、WideTextWriterを使う(要sft_側の関数追加) + + +nn::hid::PadReader *hpr; +//入力待ち +nn::hid::PadStatus padStatus; +u32 WaitKey(u32 mask) +{ + + while(1){ + hpr->ReadLatest(&padStatus); + if(padStatus.trigger & mask)return padStatus.trigger; + CheckSysBreak(); + int i = nn::ndm::GetDaemonStatus( nn::ndm::DN_CEC ); + if (i !=3 )NN_LOG("DN_CEC %d\n",i); + i = nn::ndm::GetDaemonStatus( nn::ndm::DN_BOSS ); + if (i !=3 )NN_LOG("DN_BOSS %d\n",i); + i = nn::ndm::GetDaemonStatus( nn::ndm::DN_NIM ); + if (i !=3 )NN_LOG("DN_NIM %d\n",i); + i = nn::ndm::GetDaemonStatus( nn::ndm::DN_FRIENDS ); + if (i !=3 )NN_LOG("DN_FRIENDS %d\n",i); + } +} + +//終了 +void endfunc() +{ + appHeap.Free(reinterpret_cast(readBuf)); + appHeap.Free(reinterpret_cast(romfsBuf)); + nn::hid::Finalize(); + SharedFontFinalize(); + nngxWaitVSync(NN_GX_DISPLAY_BOTH);//SDK2.0以降では不要? + s_RenderSystem.Finalize(); +} + + +//エラー +void ErrorCommon(char *s,char *ss) +{ + char str[128]; + nn::am::FinalizeForLocalImporter(); + nn::fs::Unmount("sdmc:"); + nn::fs::Unmount("rom:"); + NN_LOG(s); + NN_LOG(" result = %d\n",result.GetDescription()); + shf_SetScale(0.7,0.7); + setColor(1.0, 0.0, 0.0,1.0); + strcpy(str,"Error: "); + strcat(str,s); + drawText(10,100,str); + drawText(10,140,ss); +} + + +void ErrorStop(char *s) +{ + ErrorCommon(s,"Push Home Button & end"); + s_RenderSystem.SwapBuffers(); + WaitKey(0); +} + +void ErrorPoff(char *s) +{ + ErrorCommon(s,"Push Power Button & Power Off"); + drawText(10,160,"Home Button is invalid"); + s_RenderSystem.SwapBuffers(); + WaitKey(0); +} + + +//改行後の位置を返す、0=見つからなかった +int CrLf(int n,int max) +{ + u8 d; + while(n < max) + { + d = readBuf[n]; + if (d==0x0a)return n+1;//LF + if (d==0x0d)//CR + { + if (n == max-1)return 0;//終端 + n++; + if (readBuf[n]==0x0a)return n+1;//CR+LF + ErrorStop("list broken");//CRのみは異常、署名時にファイル壊れてた? + } + n++; + } + return 0; +} + + +nn::fs::FileInputStream fi; +//ファイルリード +s32 FileRead(char* fname) +{ + s32 size; + result = fi.TryInitialize(fname); + if (result.IsFailure()){//open error + //NN_LOG("desc= %d\n",result.GetDescription()); + return 0; + } + result = fi.TryRead(&size,readBuf,READ_BUFFER_SIZE); + fi.Finalize(); + if (result.IsFailure()){ + //NN_LOG("desc= %d\n",result.GetDescription()); + return 0; + } + return size; +} + + +char ver[16]; +char seri[32]; +void nnMain( void ) +{ + //nn::Result result; + //bool flg_test=false; + //int n; + //s32 fsize; + extern bool prohibitHome;// HOME ボタン禁止 + + nn::os::Initialize(); + nn::fs::Initialize(); + + //DEA-SUPにて推奨のフリーズ暫定対策:無線デーモンを停止 (2011.3.1 現在) + //ただし、スリープ時の"いつのまに通信"は止まらない + //無線は使わないので本体横スイッチ切っとくのが確実 + nn::ndm::Initialize(); + result = nn::ndm::SuspendScheduler(); + NN_LOG("%d",result.GetDescription()); + + //中断処理の準備 + InitSysBreak((uptr)endfunc); + // グラフィックスライブラリの初期化は、以降で行わなければならない + // 他、アプリケーションの初期化処理 + + nn::hid::Initialize(); + nn::hid::PadReader padReader; + hpr = &padReader; + + //result = nn::ns::CTR::InitializeForShell(); + //if (result.IsSuccess()) + result = nn::am::InitializeForLocalImporter(); + + nn::applet::DisableSleep();//スリープ非対応 + + // ヒープの確保 + appHeap.Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize(), nn::os::ALLOCATE_OPTION_LINEAR); + + const u32 s_GxHeapSize = 0x800000; + // RenderSystem の準備 + heapForGx = reinterpret_cast(appHeap.Allocate(s_GxHeapSize)); + s_RenderSystem.Initialize(heapForGx, s_GxHeapSize); + SharedFontInit(); + + // スリープ要求に対する返答を有効にする + // また、蓋の状態チェックを行い蓋が閉じられているならスリープ要求が発生する +// nn::applet::EnableSleep(true); + + s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY0); + s_RenderSystem.Clear(); +// s_RenderSystem.SetFontSize(12); + shf_SetScale(0.8,0.6); + setColor(1.0,1.0,1.0,1.0); + drawText(20,20,"CTR Card Savedata Mover Setup"); + s_RenderSystem.SwapBuffers(); + + shf_SetScale(0.5,0.5); + sprintf(ver,"version %.2f",VERSION); + drawText(250,40,ver); + + shf_SetScale(0.7,0.7); + if (result.IsFailure())ErrorStop("Initialize");//初期化に失敗 + if (READ_BUFFER_SIZE < LIST_LENGTH)ErrorStop("buffer size");//バッファサイズのチェック + + //ファイルバッファ + //カゲマイ上のSDリード速度比較実験で32アラインが良かったので、おまじない + //回数もサイズも少ないので気にする必要ないかも + if (READ_BUFFER_SIZE > appHeap.GetTotalFreeSize())ErrorStop("memory alloc"); + readBuf = reinterpret_cast(appHeap.Allocate(READ_BUFFER_SIZE,32)); + if (ROMFS_BUFFER_SIZE > appHeap.GetTotalFreeSize())ErrorStop("memory alloc"); + romfsBuf = reinterpret_cast(appHeap.Allocate(ROMFS_BUFFER_SIZE,32)); + + + //シリアルチェック + if( GetSerial() == false)ErrorStop("Get Serial");//本体シリの取得に失敗 +/* + result = nn::fs::MountSdmc();//ダイレクトでマウント + if (result.IsSuccess()){ + fsize = FileRead(INF_FILE);//設定ファイルがあるか + if((fsize < 1024) && (fsize > 0))//サイズチェック,増えても1Kは超えない + {//不具合調査時に状況にあわせて現場で作成&変更を想定したオプション + //通常は不要なので無しでも動くようしとく + n = 0; + while(n < fsize) + { + if (readBuf[n] == '-'){ + if (n == fsize-1)break;//終端 + n++; + switch (readBuf[n]){ + case 'p':// -p .. 本体シリアル表示 + strcpy(seri,"s/n: "); + strcat(seri,(char *)serialNo); + shf_SetScale(0.5,0.5); + drawText(10,40,(char*)seri); + shf_SetScale(0.7,0.7); + break; + case 't':// -t .. テストメニュー有効 + flg_test = true; + break; + } + } + n++; + } + } + nn::fs::Unmount("sdmc:"); + } +*/ + u32 mask = 0; + //メニュー表示 + { + drawText(80,100,"Push X : Import"); + drawText(80,140,"Push Y : Delete"); + mask |= nn::hid::BUTTON_X | nn::hid::BUTTON_Y; + } + + //本体機能で消せるようなったら、そっち使うべき + //将来的にdeleteは省いていいかも + +// if (flg_test)//テストメニュー +// { + drawText(80,160,"Push R : Test Data"); + mask |= nn::hid::BUTTON_R; +// } + s_RenderSystem.SwapBuffers(); + + if (mask == 0)ErrorStop("Serial Check");//実行できるメニューないときトラップ + + u32 trg = WaitKey(mask); + if (trg & nn::hid::BUTTON_R){ + shf_SetScale(0.6,0.6); + TestMain();//テストデータへ + } + + nn::fs::MountRom(16, 16, romfsBuf, ROMFS_BUFFER_SIZE); + + shf_SetScale(0.8,0.8); + // CIA のプログラム ID を取得する。 + nn::am::ProgramInfo programInfo; + if (nn::am::GetProgramInfoFromCia(&programInfo, ROMFS_IMPORTEE_PATH).IsFailure())ErrorStop("cia infomation"); + + // Imprting/Delete 表示 + s_RenderSystem.Clear(); + if(trg & nn::hid::BUTTON_X) drawText(10,120,"Importing"); + else drawText(10,120,"Delete"); + s_RenderSystem.SwapBuffers(); + + // HOME ボタン禁止 + //Homeで中断するとアイコンが更新されない、電源OFF画面からHomeは問題なし + prohibitHome = true; + + // 既に存在するものをインポートするとエラーが返ってくるので、あらかじめ消しておく。 + nn::am::DeleteProgram(nn::fs::MEDIA_TYPE_NAND, programInfo.id); + // タイトル鍵が違うケースに対応するために、チケットも消しておく。 + nn::am::DeleteTicket(programInfo.id); + + if(trg & nn::hid::BUTTON_X) + { + // CIA をインポート + if (ImportFile(nn::fs::MEDIA_TYPE_NAND, ROMFS_IMPORTEE_PATH)==false)ErrorPoff("Import"); + } + nn::fs::Unmount("rom:"); + + s_RenderSystem.Clear(); + drawText(10,50,"Complate"); + drawText(10,120,"Push Power Button & Power Off"); + drawText(10,140,"Home Button is invalid"); + s_RenderSystem.SwapBuffers(); + WaitKey(0); + +} + diff --git a/trunk/CardSaveData/Mover/Imp/source/main_test_only.cpp b/trunk/CardSaveData/Mover/Imp/source/main_test_only.cpp new file mode 100644 index 0000000..e34d0ce --- /dev/null +++ b/trunk/CardSaveData/Mover/Imp/source/main_test_only.cpp @@ -0,0 +1,163 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: main.cpp + + Copyright (C)2009 Nintendo Co., Ltd. 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. + + *---------------------------------------------------------------------------*/ + +//****************** 注意 ********************* +// 作成者が手元でテストするためのインポータ +// シリアルチェックを省いているので +// 部外リリースに使ってはいけない +//*********************************************** + +#include +#include +#include +#include +//#include +#include +#include +#include +#include "demo.h" +#include "../../body/ver.h" +#include "../../../common/sleep.h" +#include "../../../common/common.h" +#include "../../../common/shfnt.h" +#include "../../../common/test_data.h" + + +demo::RenderSystemDrawing s_RenderSystem; +nn::fnd::ExpHeap appHeap; +uptr heapForGx; +void ErrorStop(char *s); +void ErrorPOff(char *s); + +nn::Result result; + +//#define setColor(r,g,b,a) s_RenderSystem.SetColor(r,g,b,a) +void setColor(f32 r,f32 g,f32 b,f32 a){ shf_SetColor(r,g,b,a);} +//#define setText(x,y,s) s_RenderSystem.DrawText(x,y,s) +void drawText(u16 x,u16 y,char *s){ shf_DrawText_0( x,y,s);} +//上はASCIIのみ対応したTextWriterへのラッパ +//日本語表示の場合、WideTextWriterを使う(要sft_側の関数追加) + + +nn::hid::PadReader *hpr; +//入力待ち +nn::hid::PadStatus padStatus; +u32 WaitKey(u32 mask) +{ + + while(1){ + hpr->ReadLatest(&padStatus); + if(padStatus.trigger & mask)return padStatus.trigger; + CheckSysBreak(); +// int i = nn::ndm::GetDaemonStatus( nn::ndm::DN_CEC ); + // if (i !=3 )NN_LOG("DN_CEC %d\n",i); + // i = nn::ndm::GetDaemonStatus( nn::ndm::DN_BOSS ); + // if (i !=3 )NN_LOG("DN_BOSS %d\n",i); + //i = nn::ndm::GetDaemonStatus( nn::ndm::DN_NIM ); + // if (i !=3 )NN_LOG("DN_NIM %d\n",i); + // i = nn::ndm::GetDaemonStatus( nn::ndm::DN_FRIENDS ); + // if (i !=3 )NN_LOG("DN_FRIENDS %d\n",i); + } +} + +//終了 +void endfunc() +{ + nn::hid::Finalize(); + SharedFontFinalize(); + nngxWaitVSync(NN_GX_DISPLAY_BOTH);//SDK2.0以降では不要? + s_RenderSystem.Finalize(); +} + + +//エラー +void ErrorCommon(char *s,char *ss) +{ + char str[128]; + nn::fs::Unmount("rom:"); + NN_LOG(s); + NN_LOG(" result = %d\n",result.GetDescription()); + shf_SetScale(0.7,0.7); + setColor(1.0, 0.0, 0.0,1.0); + strcpy(str,"Error: "); + strcat(str,s); + drawText(10,100,str); + drawText(10,140,ss); +} + + +void ErrorStop(char *s) +{ + ErrorCommon(s,"Push Home Button & end"); + s_RenderSystem.SwapBuffers(); + WaitKey(0); +} + +void ErrorPoff(char *s) +{ + ErrorCommon(s,"Push Power Button & Power Off"); + drawText(10,160,"Home Button is invalid"); + s_RenderSystem.SwapBuffers(); + WaitKey(0); +} + +void nnMain( void ) +{ + extern bool prohibitHome;// HOME ボタン禁止 + + nn::os::Initialize(); + nn::fs::Initialize(); + + //DEA-SUPにて推奨のフリーズ暫定対策:無線デーモンを停止 (2011.3.1 現在) + //ただし、スリープ時の"いつのまに通信"は止まらない + //無線は使わないので本体横スイッチ切っとくのが確実 + nn::ndm::Initialize(); + result = nn::ndm::SuspendScheduler(); + NN_LOG("%d",result.GetDescription()); + + //中断処理の準備 + InitSysBreak((uptr)endfunc); + // グラフィックスライブラリの初期化は、以降で行わなければならない + // 他、アプリケーションの初期化処理 + + nn::hid::Initialize(); + nn::hid::PadReader padReader; + hpr = &padReader; + + nn::applet::DisableSleep();//スリープ非対応 + + // ヒープの確保 + appHeap.Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize(), nn::os::ALLOCATE_OPTION_LINEAR); + + const u32 s_GxHeapSize = 0x800000; + // RenderSystem の準備 + heapForGx = reinterpret_cast(appHeap.Allocate(s_GxHeapSize)); + s_RenderSystem.Initialize(heapForGx, s_GxHeapSize); + SharedFontInit(); + + // スリープ要求に対する返答を有効にする + // また、蓋の状態チェックを行い蓋が閉じられているならスリープ要求が発生する +// nn::applet::EnableSleep(true); + + s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY0); + s_RenderSystem.Clear(); +// s_RenderSystem.SetFontSize(12); + + shf_SetScale(0.7,0.7); + if (result.IsFailure())ErrorStop("Initialize");//初期化に失敗 + + TestMain();//テストデータへ + +} + diff --git a/trunk/CardSaveData/Mover/Imp/マスタリング時はomakeのIMPOTEE_PATH確認 b/trunk/CardSaveData/Mover/Imp/マスタリング時はomakeのIMPOTEE_PATH確認 new file mode 100644 index 0000000..e69de29 diff --git a/trunk/CardSaveData/Mover/body/OMakefile b/trunk/CardSaveData/Mover/body/OMakefile index 06cfdf5..d0c22ec 100644 --- a/trunk/CardSaveData/Mover/body/OMakefile +++ b/trunk/CardSaveData/Mover/body/OMakefile @@ -31,15 +31,21 @@ SOURCES[] = ./source/screen/screen.cpp ../../common/savefile/savedata.cpp ../../common/savefile/membak.cpp + ../../common/savefile/exsave.cpp ../../common/savefile/savefile.cpp ../../common/gui/gui.cpp ../../common/shfnt.cpp ../../common/sleep.cpp ../../common/common.cpp -#LIBS += lib_demo libnn_am +LIBS += lib_demo libnn_am #LIBS += libnn_ps +#ExtSavegpɃACRKv +OBJECTS[] = + $`(ObjectFromBinary $(TARGET), ../../common/icon.icn) + + TARGET_PROGRAM = CtrSaveDataMover TITLE = CSM_body @@ -48,8 +54,14 @@ TITLE = CSM_body #ROMFS_ROOT = # Ǝ RSF t@Cw肷ꍇ -ROM_SPEC_FILE = body.rsf -DESCRIPTOR = $(CTRSDK_ROOT)/resources/specfiles/repairtool.desc +ROM_SPEC_FILE = body_card1.rsf +#ROM_SPEC_FILE = body_card2.rsf + +#SDK3.1܂ +#DESCRIPTOR = $(CTRSDK_ROOT)/resources/specfiles/repairtool.desc +#SDK3.2 +DESCRIPTOR = $(CTRSDK_ROOT)/resources/specfiles/private/repairtool.desc +#DESCRIPTOR = ../../repairtool.desc # oi[AACR CTR_BANNER_SPEC = banner_null_icon.bsf @@ -57,7 +69,8 @@ CTR_BANNER_SPEC = banner_null_icon.bsf #Cia o[W:}X^OɍXV邱 #W[rsfŎw(Remasterversion) -MAKECIAFLAGS = -minor 0 -micro 12 +#micro ̏15(4bit) +MAKECIAFLAGS = -minor 1 -micro 1 include $(ROOT_OMAKE)/modulerules diff --git a/trunk/CardSaveData/Mover/body/body_card1.rsf b/trunk/CardSaveData/Mover/body/body_card1.rsf new file mode 100644 index 0000000..ec9e17c --- /dev/null +++ b/trunk/CardSaveData/Mover/body/body_card1.rsf @@ -0,0 +1,30 @@ +# AvP[ṼftHgl +BasicInfo: + # vÕ^Cgw肵܂B + Title : $(TITLE) +# BackupMemoryType: 128KB + BackupMemoryType: None + Logo : Nintendo +# CompanyCode: "00" + ProductCode : "CTR-N-22NA" + +TitleInfo: +# Category: 0x0010 +# Category: SystemApplication + UniqueId: 0xf8014 + Version: 0 + +Rom: + HostRoot : romfiles +# SaveDataSize: 512K + +AccessControlInfo: + UseExtSaveData : true + ExtSaveDataNumber: 0xf8014 + + FileSystemAccess: + - CategoryFileSystemTool + +SystemControlInfo: + RemasterVersion: 2 + diff --git a/trunk/CardSaveData/Mover/body/body_card2.rsf b/trunk/CardSaveData/Mover/body/body_card2.rsf new file mode 100644 index 0000000..130ce4c --- /dev/null +++ b/trunk/CardSaveData/Mover/body/body_card2.rsf @@ -0,0 +1,33 @@ +#Card2p +BasicInfo: + Title : $(TITLE) + BackupMemoryType: None + Logo : Nintendo +# CompanyCode: "00" + ProductCode : "CTR-N-22NA" + MediaSize : 512MB + +TitleInfo: +# Category: 0x0010 +# Category: SystemApplication + UniqueId: 0xf8014 +# Version: 0 + +Rom: + HostRoot : romfiles + SaveDataSize: 256MB + +CardInfo: + CardDevice: None + MediaType: Card2 + +AccessControlInfo: + UseExtSaveData : true + ExtSaveDataNumber: 0xf8014 + + FileSystemAccess: + - CategoryFileSystemTool + +SystemControlInfo: + RemasterVersion: 2 + diff --git a/trunk/CardSaveData/Mover/body/romfiles/lang_en.mes b/trunk/CardSaveData/Mover/body/romfiles/lang_en.mes new file mode 100644 index 0000000000000000000000000000000000000000..74c7528dea05bf2f129359f3ceddd1157a7ddbc3 GIT binary patch literal 468 zcmZuuOAdlC5PfSC?|=vJ5CU=I#%Mf1(~1(Ykb)W$5AU0{2n0h|%$u3_nHDHf;fw?t zHSTDjh&cWh7c8+rhAaCTH_l|(;DCIFr`X|yeZ(E-6*|v4?I=8mmsGM?k+1lvTVkC@ zYR*^~&lQ-=#7%HnMTOu{(XrunOY})y`1N2JxRxcW$^Jbb6NI67mk?e%RkKfiQ%-q~3|*n@FZ3J!v{?`APi+ Dw|h&g literal 0 HcmV?d00001 diff --git a/trunk/CardSaveData/Mover/body/romfiles/lang_jp.mes b/trunk/CardSaveData/Mover/body/romfiles/lang_jp.mes new file mode 100644 index 0000000000000000000000000000000000000000..f37009d87575e0b84de7d894ae1ce7c473a19702 GIT binary patch literal 320 zcmca=u+U(M!E1v&gM$Xk4GtTuH{fO9VpwhP$KWJTY*$5Z7l?lWEVBqmUPltW>mL#A z5twHX<1df|QuQK-KauhORj7$R22KWD26YC}29v>Nz5<)6>z8g23FbT1w)r93b=6=c zP{lo<9Vfu@$oxEmdIO&h7och32Jv9omq1saFhH1g++eZ68=&h?7`y_zN7s+RfcHPh pd~7l?U>TT8Hyd05+6+^VE(%d=7#W@lGELWSEtnQanjZw>0|1NEYmEQ^ literal 0 HcmV?d00001 diff --git a/trunk/CardSaveData/Mover/body/romfiles/langファイルについて.txt b/trunk/CardSaveData/Mover/body/romfiles/langファイルについて.txt new file mode 100644 index 0000000..bae16ae --- /dev/null +++ b/trunk/CardSaveData/Mover/body/romfiles/langファイルについて.txt @@ -0,0 +1,3 @@ +U16ō쐬 +sLF(0A)̂ +DOS̃t@Cʂ擪ɂꍇ(QoCgAAXL["BM")폜 diff --git a/trunk/CardSaveData/Mover/body/source/main.cpp b/trunk/CardSaveData/Mover/body/source/main.cpp index 7da7521..9071a20 100644 --- a/trunk/CardSaveData/Mover/body/source/main.cpp +++ b/trunk/CardSaveData/Mover/body/source/main.cpp @@ -11,7 +11,6 @@ in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ - #include #include #include @@ -20,7 +19,9 @@ //#include #include #include -#include +#include +//#include +#include #include #include //#include @@ -30,29 +31,42 @@ #include "./screen/screen.h" #include "../../../common/common.h" +//ヘッダにフラグのみ、コメントアウトで旧版相当(SD非対応) +#include "main.h" +#ifdef CSM_FLAG_USE_SD +#include "../../../common/savefile/exsave.h" +#endif + nn::fnd::ExpHeap appHeap; uptr heapForGx; //Gui gui; myResult errRes; - //char strBuff[128]; //bool exist; SaveData savedata; nn::os::LightEvent ejectEvnt(false); nn::os::LightEvent insEvnt(false); -MemBak exsave; +#ifdef CSM_FLAG_USE_SD +ExSave exsave; +nn::os::LightEvent ejectEvntSd(false); +nn::os::LightEvent insEvntSd(false); +bool BkupSd = false;//バックアップ先がSDか(ファイルサイズ合計で選択) +#endif +MemBak memsave; //バックアップの状態 bool Active,Formatted; bool exActive,exFormatted; -tArcInfo arcInfo,arcInfo_ex;//アーカイブ情報 +tArcInfo arcInfo,arcInfo2;//アーカイブ情報 +tDcList dcList,dcList2;//ディレクトリ格納 + //プロダクトコードの一致 bool isAgreePCode; -//ベリファイ結果 -//bool failveri; +//SDあり起動 +bool alive_Sd; //Top画面エラー表示 int tmerr; @@ -70,16 +84,103 @@ typedef enum { InEx_None ,InEx_InsCard ,InEx_EjcCard + ,InEx_InsSd + ,InEx_EjcSd }tIsInsEject; +//メッセージ用タグ +enum eMesTag{ +MT_Compair,//コンペア時 +MT_ChkCard,//ユーザセーブの存在チェック時 +MT_ChkBkup,//バックアップ先の存在チェック時 +MT_CrtBkup,//保存先の作成 +MT_FileNot,//ユーザセーブのマウント成功したがファイルが無い +MT_Reading,//リード中 +MT_Complate,//終了 +MT_CardFormat,//ユーザセーブのフォーマット時 +MT_FormatOnly,//フォーマットのみ行ったとき(ファイルなし時) +MT_Writing,//ライト中 +MT_CrtDir1,//ディレクトリ作成中その1 +MT_CrtDir2,//その2(1,2を交互表示) +MT_Copy1,// ファイルコピー +MT_Copy2,//ファイルコピー +MT_Failed,//失敗 +MT_Break,//中断 +MT_Success,//成功 +MT_END +}; + +tChar* MES_NULL = L""; + +//文字数(終端込) +#define MESS_SIZE 32 +//メッセージ格納 +wchar_t Mess[MT_END*MESS_SIZE]; +//メッセージ位置 +int MessPos[MT_END]; + +#define MessTxt(i) (wchar_t*)&Mess[MessPos[i]] + tIsInsEject isInsEject; - extern u8 scr_evnt; +s64 sSize; + +wchar_t wk_dir[20];//拡張セーブ上のリネームファイル用ディレクトリ +int rename_n =0;//リネーム番号 + +wchar_t file_pathw[MAX_PATH_LENGTH]; +wchar_t file_pathw2[MAX_PATH_LENGTH]; +char file_path[MAX_PATH_LENGTH]; +//ドライバの仕様で速度的に4バイトアラインした方がいい(SDK 0.14.23 時点) +char fileBuffer[512] NN_ATTRIBUTE_ALIGN(4);//検証が512単位なので +char fileBuffer_ex[512] NN_ATTRIBUTE_ALIGN(4); +#define FILEBUFF_SIZE sizeof(fileBuffer) + + void WaitUI(); -void PutError(ErcDev dev,int cd=0); +void PutError(TgtDev dev,int cd=0); +RetCode Card2Sd(); +RetCode Sd2Card(); +void CheckSaveDataState(); +void CheckExSaveState(); + +//------------------------------------------------------------ 挿抜チェック +bool CheckInsExit() +{ + + if (ejectEvnt.TryWait()){ + //CARD抜け + CheckSaveDataState(); + isInsEject = InEx_EjcCard; + return true; + } + if (insEvnt.TryWait()){ + //CARD挿入 + CheckSaveDataState(); + isInsEject = InEx_InsCard; + return true; + } +#ifdef CSM_FLAG_USE_SD + if(alive_Sd){ + if (ejectEvntSd.TryWait()){ + //SD抜け + CheckExSaveState(); + isInsEject = InEx_EjcSd; + return true; + } + if (insEvntSd.TryWait()){ + //SD挿入 + CheckExSaveState(); + isInsEject = InEx_InsSd; + return true; + } + } +#endif + return false; +} -//終了処理 +//---------------------------------------------------------------- 終了処理 void endfunc() { @@ -88,8 +189,16 @@ void endfunc() ejectEvnt.Finalize(); insEvnt.Finalize(); +#ifdef CSM_FLAG_USE_SD + if (alive_Sd){ + nn::fs::UnregisterSdmcEjectedEvent(); + nn::fs::UnregisterSdmcInsertedEvent(); + ejectEvntSd.Finalize(); + insEvntSd.Finalize(); + } +#endif savedata.Finalize(); - exsave.Finalize(); + memsave.Finalize(); ScrFinalize(); @@ -99,94 +208,174 @@ void endfunc() void failstop() { NN_LOG("fail %d,stop\n",errRes); - finish(); + + while(1){ + CheckSysBreak(); + } } -char sts[64]; -void PutError(ErcDev dev,int cd) +//エラー表示 +tChar sts[64]; +void PutError(TgtDev dev,int cd) { nn::Result res; switch (dev) { - case ERC_DEV_CARD: res = savedata.LastNnResult;break; - case ERC_DEV_OUT: res = exsave.LastNnResult;break; + case TGT_CARD: res = savedata.LastNnResult;break; + case TGT_MEM: res = memsave.LastNnResult;break; +#ifdef CSM_FLAG_USE_SD + case TGT_SD: res = exsave.LastNnResult;break; +#endif + default: dev = TGT_NONE;//GetDescriptエラー対策 } GetErrorStr(dev,res,cd,sts); scr_Status(sts,COLOR_RED); } +//表示テキストの読込(eMessTagの順) +//テキストはSJISやASCII不可、U-16で保存し文字列は改行(0a0d)で終える +//BOM(先頭2バイトのゴミ ^^; )は付けない事 +void LoadMessText(wchar_t* path) +{ + const size_t ROMFS_BUFFER_SIZE = 1024*8; + static char buffer[ROMFS_BUFFER_SIZE]; + + NN_LOG("reqsize = %d",nn::fs::GetRomRequiredMemorySize(8,8)); + + nn::fs::MountRom(4, 4, buffer, ROMFS_BUFFER_SIZE); + nn::fs::FileReader Reader; + if(Reader.TryInitialize(path).IsFailure()) + { + NN_LOG("fail to read file $s\n",path); + endfunc(); + } + + const u32 size = (u32)Reader.GetSize(); + if (size > (MT_END*MESS_SIZE*2)) + { + NN_LOG("textfile:size over\n"); + endfunc(); + } + + Reader.Read(Mess,size); + int i,n; + for (i=0;i 512) || (size < 0))return false; + savedata.SetPos(pos); + if(savedata.Read(fileBuffer,size) != size ) + { + NN_LOG("%d\n",savedata.LastNnResult.GetDescription()); + if(nn::fs::ResultVerificationFailed::Includes(savedata.LastNnResult)) + {//検証エラー + for (int i = 0; i < size; i++) fileBuffer[i] = 0;//0埋め + }else return false; + } + return true; +} + //-------------------------------------------------- Verifi -wchar_t file_pathw[MAX_PATH_LENGTH]; -char file_path[MAX_PATH_LENGTH]; -//ドライバの仕様で速度的に4バイトアラインした方がいい(SDK 0.14.23 時点) -char fileBuffer[512] NN_ATTRIBUTE_ALIGN(4);//検証が512単位なので -char fileBuffer_ex[512] NN_ATTRIBUTE_ALIGN(4); -#define FILEBUFF_SIZE sizeof(fileBuffer) - -bool Verifi() +bool Verifi(bool flg) { myResult res; int ct,i,msize,rsize; - s64 total=0; + s64 total=0,pos; //セーブデータのマウント res = savedata.Mount(); if(res != RESULT_OK){ - PutError(ERC_DEV_CARD); + //PutError(TGT_CARD); return false; } -//ファイル数の再取得..ファイル多いと時間かかる -//arcInfoの保持があやしい or 出来ない場合に有効にする -/* - scr_Status("Ready to Verifi",COLOR_YELLO); - //情報ファイル - LogAdd("Directry Info"); - if(savedata.GetInfo(&arcInfo)==false) - { - savedata.Unmount(); - PutError(ERC_DEV_CARD); - return ERROR; - } -*/ - //出力デバイスのマウント - res = exsave.Mount(); + //バッファデバイスのマウント + res = memsave.Mount(); if(res != RESULT_OK){ - PutError(ERC_DEV_OUT); + //PutError(TGT_MEM); return false; } - //情報ファイル - if (exsave.GetInfo(&arcInfo_ex) == false) - { - savedata.Unmount(); - exsave.Unmount(); - return false; - }//todo:将来、構造体を変更したらバージョンチェック入れる - - //フォーマット情報の比較 - if ((arcInfo.DirEntry != arcInfo_ex.DirEntry) || - (arcInfo.FileEntry != arcInfo_ex.FileEntry) || - (arcInfo.Dup != arcInfo_ex.Dup)) + //ディレクトリの確認 + //空ディレクトリチェックするアプリあり(マリカ7) + //ファイルなし状態ありえるので先に確認 + if( dcList.num >0 ) { - PutError(ERC_DEV_OUT,ERC_VERIFI); - savedata.Unmount(); - exsave.Unmount(); - return false; + nn::fs::Directory dc; + for(i=0;i FILEBUFF_SIZE ){ @@ -244,62 +434,77 @@ bool Verifi() rsize = fsize; fsize = 0; } - if(savedata.Read(fileBuffer,rsize) != rsize ) + if (ReadBlock(pos,rsize)==false) { - //中身のデータが作成サイズに満たない場合に検証エラーとなる対策 - //読めないブロックは置き換える - //検証は512単位でされるので読めてるとこまで置き換えないよう - //リードサイズは512にしておく - if(nn::fs::ResultVerificationFailed::Includes(savedata.LastNnResult)) - { - for (i = 0; i < rsize; i++) - { - fileBuffer[i] = 0;//0埋め - } - }else{ - res = RESULT_FAIL_READ; - break; - } + res = RESULT_FAIL_READ; + break; } - if(exsave.Read(fileBuffer_ex,rsize) != rsize ) - { + pos += rsize; + if(memsave.Read(fileBuffer_ex,rsize) != rsize ) + {//メモリなので実行時バグ res = RESULT_FAIL; break; } + //verifi + for (i = 0;i MEM_BKUP_SIZE) - { - savedata.Unmount(); - PutError(ERC_DEV_OUT,ERC_WRITE_NS);//容量オーバ - return ERROR; - } //カウント異常なら実行エラー if (arcInfo.FileCount > arcInfo.FileEntry) { savedata.Unmount(); - PutError(ERC_DEV_OTHER,ERC_EXEC); + PutError(TGT_NONE,ERC_EXEC); return ERROR; } + if (arcInfo.DirCount > arcInfo.DirEntry) + { + savedata.Unmount(); + PutError(TGT_NONE,ERC_EXEC); + return ERROR; + } + + if(arcInfo.DirCount >= MAX_DCLIST) + {//ディレクトリ数が多すぎ + savedata.Unmount(); + PutError(TGT_MEM,ERC_EXEC); + return ERROR; + } + + //メモリFSの予想占有サイズ + sSize = arcInfo.total+arcInfo.FileCount*512; - scr_Status("BackUp Check",COLOR_YELLO); - if(exsave.IsExist()){ - if(exsave.Delete()==false) +#ifdef CSM_FLAG_FORCE_SD + return Card2Sd();//デバグ用、強制でSDへ + //警告抑制 unreachable +#pragma diag_suppress 111 +#endif + + //簡易サイズチェック + if (sSize > MEM_BKUP_SIZE) + { +#ifdef CSM_FLAG_USE_SD + if (alive_Sd)return Card2Sd();//SD使用 +#endif + savedata.Unmount(); + PutError(TGT_MEM,ERC_NOSPACE);//容量オーバ + return ERROR; + } +#ifdef CSM_FLAG_USE_SD + //本体メモリ使用 + BkupSd = false; +#endif + + //一時保存が存在したら消す + scr_Status(MessTxt(MT_ChkBkup),COLOR_YELLO); + if(memsave.IsExist()){ + if(memsave.Delete()==false) { savedata.Unmount(); - PutError(ERC_DEV_OUT); + PutError(TGT_MEM); return ERROR; } } - scr_Status("Create Backup",COLOR_YELLO); - res = exsave.Create(arcInfo.DirEntry+1,arcInfo.FileEntry+1); + //一時保存先の作成 + scr_Status(MessTxt(MT_CrtBkup),COLOR_YELLO); + res = memsave.Create(arcInfo.DirEntry+1,arcInfo.FileEntry+1); if (res != RESULT_OK){ savedata.Unmount(); - PutError(ERC_DEV_OUT); + PutError(TGT_MEM); return ERROR; } if (arcInfo.FileCount == 0)//ファイルが無い { - scr_Status("no files",COLOR_YELLO); + scr_Status(MessTxt(MT_FileNot),COLOR_YELLO); savedata.Unmount(); - exsave.Unmount(); + memsave.Unmount(); + strcpy(arcInfo.Pcode,savedata.PrdCode); return SUCCESS;//フォーマットのみ }else{ - scr_Status("file reading",COLOR_SKY); + scr_Status(MessTxt(MT_Reading),COLOR_SKY); savedata.ResetPath(); s64 fsize; res = RESULT_OK; @@ -375,11 +617,13 @@ RetCode Card2Sd() if (res != RESULT_OK) { if (res == RESULT_DIR_LEVEL_OVER){ - PutError(ERC_DEV_CARD,ERC_DIRDEPTH); + //PutError(ERC_DEV_CARD,ERC_DIRDEPTH); + PutError(TGT_NONE,ERC_WORK); break; } if (res == RESULT_PATH_LENGTH_OVER){ - PutError(ERC_DEV_CARD,ERC_PATH); + //PutError(ERC_DEV_CARD,ERC_PATH); + PutError(TGT_NONE,ERC_WORK); break; } res = RESULT_FAIL_OPEN; @@ -400,84 +644,62 @@ RetCode Card2Sd() } fsize = savedata.FileSize; total += fsize; - if (exsave.OpenW(file_pathw,fsize)==false) + if (memsave.OpenW(file_pathw,fsize)==false) { res = RESULT_FAIL_OPENW; //savedata.Close(); break; } - msize=fsize; - while(fsize) - { - if(msize > FILEBUFF_SIZE * 2){ - scr_CountPerMax2(msize-fsize,msize,0); - } - if (fsize>FILEBUFF_SIZE) + + //検証単位の512ずつ + msize=fsize; + pos = 0; + while(fsize) { - rsize = FILEBUFF_SIZE; - fsize -= FILEBUFF_SIZE; - }else{ - rsize = fsize; - fsize = 0; - } - if(savedata.Read(fileBuffer,rsize) != rsize ) - { - //中身のデータが作成サイズに満たない場合に検証エラーとなる対策 - //読めないブロックは置き換える - //検証は512単位でされるので読めてるとこまで置き換えないよう - //リードサイズは512にしておく - if(nn::fs::ResultVerificationFailed::Includes(savedata.LastNnResult)) + if(msize > FILEBUFF_SIZE * 2){ + scr_CountPerMax2(msize-fsize,msize,0); + } + if (fsize>FILEBUFF_SIZE) { - for (int i = 0; i < rsize; i++) - { - fileBuffer[i] = 0;//0埋め - } + rsize = FILEBUFF_SIZE; + fsize -= FILEBUFF_SIZE; }else{ + rsize = fsize; + fsize = 0; + } + if (ReadBlock(pos,rsize)==false) + { res = RESULT_FAIL_READ; break; } + pos += rsize; + if(memsave.Write(fileBuffer,rsize) != rsize ) + { + res = RESULT_FAIL_WRITE; + break; + } } - if(exsave.Write(fileBuffer,rsize) != rsize ) - { - res = RESULT_FAIL_WRITE; - break; - } - } + savedata.Close(); - exsave.CloseW(); + memsave.CloseW(); //todo: ゲージ表示 ct++; } savedata.Close(); - exsave.CloseW(); + memsave.CloseW(); } if (res == RESULT_OK){ if (ct != arcInfo.FileCount)//ファイル数に満たないパス検索終了 {//ディレクトリ情報かパス取得で失敗してると思われる - PutError(ERC_DEV_OTHER,ERC_EXEC); + PutError(TGT_NONE,ERC_EXEC); return ERROR; } - //フォーマット情報を記録 - //Exsaveに2重化が無いので情報取得APIでは不足 - 2011.1 現在 - //プロダクトコードを追加(2011.1.26) - //バージョンを追加(2011.1.27) - if (exsave.OpenSysW()) - { - strcpy(arcInfo.Pcode,savedata.PrdCode); - if(exsave.WriteSys(&arcInfo) ==false) - { - res = RESULT_FAIL_WRITE; - } - }else{ - res = RESULT_FAIL_OPENW; - } - exsave.CloseSysW(); } savedata.Unmount(); - //exsave.Commit(); Nand,SDはコミット入れる - exsave.Unmount(); + //memsave.Commit(); Nand,SDはコミット入れる + memsave.Unmount(); scr_CountPerMax(ct,arcInfo.FileCount); if(total>0)scr_CountPerMax2(0,0,total); @@ -485,35 +707,41 @@ RetCode Card2Sd() switch(res) { case RESULT_OK: - if (Verifi()) + if (Verifi(false)) { - scr_Status("Complate",COLOR_WHITE); + scr_Status(MessTxt(MT_Complate),COLOR_WHITE); + strcpy(arcInfo.Pcode,savedata.PrdCode); return SUCCESS; } - //PutError(ERC_DEV_OTHER,ERC_VERIFI); + PutError(TGT_CARD,ERC_VERIFI); break; case RESULT_FAIL_WRITE: case RESULT_FAIL_OPENW: - //本体メモリなので容量以外でエラーはない - PutError(ERC_DEV_OUT,ERC_WRITE_NS);//容量オーバ + PutError(TGT_MEM,ERC_WRITE); break; case RESULT_FAIL_READ: case RESULT_FAIL_OPEN: - PutError(ERC_DEV_CARD); + PutError(TGT_CARD,ERC_READ); break; + default: + PutError(TGT_NONE,ERC_EXEC); + break; + } - exsave.Delete();//バックアップを削除 + memsave.Delete();//バックアップを削除 return ERROR; } + + bool mkdir; -//---------------------------------------------------------------- SD->CARD -RetCode Sd2Card() +//---------------------------------------------------------------- to CARD +RetCode Ctr2Card() { myResult res; - int ct=0,msize,rsize; + int ct=0; + int msize,rsize; s64 total = 0; - scr_RestoreYesNo();//実行確認 WaitUI();//入力待ち if(isInsEject != InEx_None ){//挿抜? @@ -523,36 +751,76 @@ RetCode Sd2Card() if (scr_evnt != EVNT_YES)return CANCEL;//キャンセル scr_Restore();//画面表示 - scr_Status("Check Backup",COLOR_YELLO); - //保存先のマウント - res = exsave.Mount(); + scr_Status(MessTxt(MT_ChkBkup),COLOR_YELLO); + +#ifdef CSM_FLAG_USE_SD + if (BkupSd)return Sd2Card();//SD使用 +#endif + + //一時保存のマウント + res = memsave.Mount(); if(res != RESULT_OK){ - PutError(ERC_DEV_OUT); + PutError(TGT_MEM); + return ERROR; + } + + //セーブデータのフォーマット&マウント + scr_Status(MessTxt(MT_CardFormat),COLOR_YELLO); + res = savedata.Format(&arcInfo); + if(res != RESULT_OK){ + memsave.Unmount(); + PutError(TGT_CARD); return ERROR; } - //セーブデータのフォーマット&マウント - scr_Status("Card savedata format",COLOR_YELLO); - res = savedata.Format(&arcInfo);//_exの方がいいかも - if(res != RESULT_OK){ - exsave.Unmount(); - PutError(ERC_DEV_CARD); - return ERROR; - } - //パラメータはバックアップ時 - //Top画面開始時、挿入イベントで取得 - if (arcInfo.FileCount == 0)//ファイルが無い + //ディレクトリ作成 + //空ディレクトリもチェックするゲームあるので(マリカ7) + //ファイルの存在と関係なく作成 + if(dcList.num >0) { + int i,rev=0; + for (i=0;i FILEBUFF_SIZE * 2){ scr_CountPerMax2(msize-fsize,msize,0); - if (++itvl & 1)scr_Status("file copying |",COLOR_PARPL); - else scr_Status("file copying -",COLOR_PARPL); - }else scr_MessOnCount2(""); + if (++itvl & 1)scr_Status(MessTxt(MT_Copy1),COLOR_PARPL); + else scr_Status(MessTxt(MT_Copy2),COLOR_PARPL); + }else scr_MessOnCount2(MES_NULL); if (fsize>FILEBUFF_SIZE) { @@ -613,7 +891,7 @@ RetCode Sd2Card() rsize = fsize; fsize = 0; } - if(exsave.Read(fileBuffer,rsize) != rsize ) + if(memsave.Read(fileBuffer,rsize) != rsize ) { res = RESULT_FAIL_READ; break; @@ -625,55 +903,713 @@ RetCode Sd2Card() } } savedata.CloseW(); - exsave.Close(); + memsave.Close(); ct++; } savedata.Close(); - exsave.CloseW(); + memsave.CloseW(); } + savedata.Commit(); savedata.Unmount(); - exsave.Unmount(); + memsave.Unmount(); scr_CountPerMax(ct,arcInfo.FileCount); scr_CountPerMax2(0,0,total); //結果 switch(res){ case RESULT_OK: - if (Verifi()==false)return ERROR; - if(exsave.Delete()){//バックアップを削除 - scr_Status("Complate",COLOR_WHITE); - return SUCCESS; + if (Verifi(true)){ + if(memsave.Delete()){//バックアップを削除 + scr_Status(MessTxt(MT_Complate),COLOR_WHITE); + return SUCCESS; + } } + PutError(TGT_CARD,ERC_VERIFI); + break; + case RESULT_FAIL_WRITE: case RESULT_FAIL_OPENW: - PutError(ERC_DEV_CARD); - return ERROR; + PutError(TGT_CARD,ERC_WRITE); + break; case RESULT_FAIL_READ: case RESULT_FAIL_OPEN: - PutError(ERC_DEV_OUT); - return ERROR; + PutError(TGT_MEM,ERC_READ); + break; + default: + PutError(TGT_NONE,ERC_EXEC); + break; } - //その他、実行時エラー - PutError(ERC_DEV_OTHER); return ERROR; } + +//******************************************** for SD +//パス長オーバのファイルはメモリ上に記録 +//mem:/元ネーム <- リネーム名格納 +//sd:/ワーク/リネーム名 <-データ格納 +//20000ファイル程度まで + +#ifdef CSM_FLAG_USE_SD +bool VerifiSd() +{ + myResult res; + int ct,i,msize,rsize; + s64 total=0,pos; + wchar_t ws[20];//"/"+16文字+"\0" + + + //セーブデータのマウント + res = savedata.Mount(); + if(res != RESULT_OK){ + //PutError(TGT_CARD); + return false; + } + + //出力デバイスのマウント + res = exsave.Mount(); + if(res != RESULT_OK){ + //PutError(TGT_SD); + return false; + } + memsave.Mount(); + + ct =0; + if (arcInfo.FileCount == 0)//ファイルが無い + { + savedata.Unmount(); + exsave.Unmount(); + return true;//フォーマット一致のみ + }else{ + scr_Status(MessTxt(MT_Compair),COLOR_YELLO); + savedata.ResetPath(); + exsave.ResetPath(); + s64 fsize; + res = RESULT_OK; + while(res==RESULT_OK){ + if(CheckInsExit())break;//挿抜による中断 + res = savedata.GetPath(file_pathw); + if (res != RESULT_OK) + { + if (res == RESULT_DIR_LEVEL_OVER){ + break; + } + if (res == RESULT_PATH_LENGTH_OVER){ + break; + } + res = RESULT_FAIL_OPEN; + break; + } + if (file_pathw[0] == 0)break;//root then end + if (ct>=arcInfo.FileCount) + {//カウンタ壊れ、メモリフローの可能性 + res = RESULT_FAIL; + break; + } + if(CheckInsExit())break;//挿抜による中断 + scr_CountPerMax(ct,arcInfo.FileCount); + if (savedata.Open(file_pathw)==false) + { + res = RESULT_FAIL_OPEN; + break; + } + fsize = savedata.FileSize; + total += fsize; + + if (memsave.Open(file_pathw)) + {//リネーム対象 + memsave.Read((char*)ws,18);//リネーム名 + ws[9]=0;ws[10]=0; + wcscpy(file_pathw,wk_dir);//格納先ディレクトリ + wcscat(file_pathw,ws);//パス変換 + memsave.Close(); + } + if(CheckInsExit())break;//挿抜による中断 + if (exsave.Open(file_pathw)==false) + { + res = RESULT_FAIL_OPENW; + //savedata.Close(); + break; + } + if (fsize != exsave.FileSize)//file size + { + res = RESULT_FAIL; + break; + } + + msize=fsize; + if(msize <= FILEBUFF_SIZE ){//一回で読めるサイズならゲージは出さない + scr_CountPerMax2(0,0,-1); + } + pos = 0; + while(fsize) + { + if(msize > FILEBUFF_SIZE ){ + scr_CountPerMax2(msize-fsize,msize,0); + } + if (fsize > FILEBUFF_SIZE) + { + rsize = FILEBUFF_SIZE; + fsize -= FILEBUFF_SIZE; + }else{ + rsize = fsize; + fsize = 0; + } + if(CheckInsExit())break;//挿抜による中断 + if (ReadBlock(pos,rsize)==false) + { + res = RESULT_FAIL_READ; + break; + } + pos += rsize; + if(CheckInsExit())break;//挿抜による中断 + if(exsave.Read(fileBuffer_ex,rsize) != rsize ) + { + res = RESULT_FAIL; + break; + } + for (i = 0;i=arcInfo.FileCount) + {//カウンタ壊れ、メモリフローの可能性 + res = RESULT_FAIL; + break; + } + + scr_CountPerMax(ct,arcInfo.FileCount);//カウンタ表示 + if (exsave.Open(file_pathw)==false) + { + res = RESULT_FAIL_OPEN; + break; + } + fsize = exsave.FileSize; + total += fsize; + + if (savedata.CheckPathBit & cpb_ex ) + {//違反パス名あり? + if (CmpDirW(file_pathw,wk_dir)==1) + {//リネームファイルなら元のパス名を探す + memsave.ResetPath(); + int i=0;bool b=false; + ws[9]=0;ws[10]=0; + while(i差替?? or メモリ破壊?? + res = RESULT_FAIL; + break; + } + } + } + + int rev = 0; + while(1){ + if (savedata.OpenC(file_pathw,fsize,&mkdir)==false) + { + if(mkdir)//ディレクトリのみ作成 + {//深い場合に作成が多いと画面が止まるので + rev++; + if (rev & 1)scr_MessOnCount2(MessTxt(MT_CrtDir1)); + else scr_MessOnCount2(MessTxt(MT_CrtDir2)); + }else{ + res = RESULT_FAIL_OPENW; + //exsave.Close(); + break; + } + }else break; + }//while + if (res != RESULT_OK)break; + + msize = fsize; + int itvl = 0; + while(fsize) + { + if(msize > FILEBUFF_SIZE * 2){ + scr_CountPerMax2(msize-fsize,msize,0); + if (++itvl & 1)scr_Status(MessTxt(MT_Copy1),COLOR_PARPL); + else scr_Status(MessTxt(MT_Copy2),COLOR_PARPL); + }else scr_MessOnCount2(MES_NULL); + + if (fsize>FILEBUFF_SIZE) + { + rsize = FILEBUFF_SIZE; + fsize -= FILEBUFF_SIZE; + }else{ + rsize = fsize; + fsize = 0; + } + if(exsave.Read(fileBuffer,rsize) != rsize ) + { + res = RESULT_FAIL_READ; + break; + } + if(savedata.Write(fileBuffer,rsize) != rsize ) + { + res = RESULT_FAIL_WRITE; + break; + } + }//while + savedata.CloseW(); + exsave.Close(); + ct++; + }//while + savedata.Close(); + exsave.CloseW(); + if(res == RESULT_OK)savedata.Commit(); + + savedata.Unmount(); + exsave.Unmount(); + memsave.Unmount(); + scr_CountPerMax(ct,arcInfo.FileCount); + scr_CountPerMax2(0,0,total); + +//結果 + TgtDev ercd; + int ercc; + switch(res){ + case RESULT_OK: + if (VerifiSd()){ + memsave.Delete(); + if(exsave.Delete()){//バックアップを削除 + scr_Status(MessTxt(MT_Complate),COLOR_WHITE); + return SUCCESS; + } + } + ercd =TGT_CARD;ercc = ERC_VERIFI;//ベリファイエラー + break; + case RESULT_FAIL_WRITE: + case RESULT_FAIL_OPENW: + ercd = TGT_CARD;ercc = ERC_WRITE; + break; + case RESULT_FAIL_READ: + case RESULT_FAIL_OPEN: + ercd = TGT_SD;ercc = ERC_READ; + break; + default: + ercd = TGT_NONE;ercc = ERC_EXEC; + break; + } + return PutErrRetCode(ercd,ercc); +} + + + +//Crad2Ctrより呼ばれる +RetCode Card2Sd() +{ + myResult res; + int ct=0,msize,rsize; + s64 total=0,fsize,pos; + + int i; + wchar_t ws[20];//"/"+16文字+"\0" + + BkupSd = true; + + //拡張セーブが存在したら消す + scr_Status(MessTxt(MT_ChkBkup),COLOR_YELLO); + if(exsave.IsExist()){ + if(exsave.Delete()==false) return PutErrRetCode(TGT_SD); + } + if(CheckInsExit())return INSEXIT;//抜けで"なし"判定の場合 + + //一時保存先の作成 + scr_Status(MessTxt(MT_CrtBkup),COLOR_YELLO); + //拡張セーブで違反になるパス名あり? + if (savedata.CheckPathBit & cpb_ex ) + { + //該当ファイルを変名保存するディレクトリ追加 + res = exsave.Create(arcInfo.DirEntry+1,arcInfo.FileEntry); + }else res = exsave.Create(arcInfo.DirEntry,arcInfo.FileEntry); + if (res != RESULT_OK) return PutErrRetCode(TGT_SD); + + if(CheckInsExit())return INSEXIT;//抜け + + //パラメータはバックアップ時 + //Top画面開始時、挿入イベントで取得 + if (arcInfo.FileCount == 0)//ファイルが無い + { + scr_Status(MessTxt(MT_FileNot),COLOR_YELLO); + strcpy(arcInfo.Pcode,savedata.PrdCode); + savedata.Unmount(); + return SUCCESS;//フォーマットのみ + } + + + //簡易サイズチェック + //SDのクラスタサイズやヘッダでメモリFSより多く占有する + //セクタサイズ4K:2GB、32K:4GB 余裕を見ておく(ファイル数上限での最悪) + //4GBデバイスの移行なら、8G以上のSDを使う + fsize = exsave.GetFreeSize();//取得APIがマウント必須なのでCreate後でないとダメ + //ヘッダ16k+4K(ファイル名+アライメント) ..SDセクタサイズ4Kの前提 + sSize = arcInfo.total + arcInfo.FileCount*20480; + if ((sSize > fsize) || (fsize ==0)) return PutErrRetCode(TGT_SD,ERC_NOSPACE); + + //メモリFS上に作成..ファイル名保存のため、中身はSD上のファイル名 + //拡張セーブは最大パス長がユーザセーブより短いため超えるものは変名 + //オリジナルファイル名で作成したファイルに変更後のファイル名を格納 + //ワークの10MByteで1万ファイルくらい + memsave.Delete(); + memsave.Create(1,arcInfo.FileCount); + memsave.Mount(); + + //read + scr_Status(MessTxt(MT_Reading),COLOR_PARPL); + savedata.ResetPath(); + total=0;ct=0;rename_n=0; + res = RESULT_OK; + while(res==RESULT_OK){ + res = savedata.GetPath(file_pathw); + if (res != RESULT_OK) + { + if ((res != RESULT_DIR_LEVEL_OVER) + && (res != RESULT_PATH_LENGTH_OVER)) res = RESULT_FAIL_OPEN; + break; + } + if (file_pathw[0] == 0)break;//root then end + if (ct>=arcInfo.FileCount) + {//カウンタ壊れ、メモリフローの可能性 + res = RESULT_FAIL; + break; + } + + scr_CountPerMax(ct,arcInfo.FileCount); + if (savedata.Open(file_pathw)==false) + { + res = RESULT_FAIL_OPEN; + break; + } + fsize = savedata.FileSize; + total += fsize; + + //パス名チェック + if (CheckPathEx(file_pathw) == false) + {//メモリFS上にファイル作成(パス名記録のみ目的) + savedata.Close(); + if (memsave.OpenW(file_pathw,512)==false) + { + res = RESULT_FAIL_OPENW; + break; + } + + //リネーム名の格納 + swprintf(ws,16,L"/%8x",rename_n);//リネーム + for (i=1;i<8;i++)if(ws[i]==L' ')ws[i]=L'0'; + rename_n++; + if(memsave.Write( (char*)ws,18) != 18)//wchar 9文字 + { + res = RESULT_WORK_OVER;//ワーク不足 + break; + } + memsave.CloseW(); + }else + { + int rev = 0; + while(1){ + if (exsave.OpenC(file_pathw,fsize,&mkdir)==false) + { + if(mkdir)//ディレクトリのみ作成 + {//深い場合に作成が多いと画面が止まるので + rev++; + if (rev & 1)scr_MessOnCount2(MessTxt(MT_CrtDir1)); + else scr_MessOnCount2(MessTxt(MT_CrtDir2)); + }else{ + res = RESULT_FAIL_OPENW; + //exsave.Close(); + break; + } + }else break; + } + if (res != RESULT_OK)break; + msize = fsize; + int itvl = 0; + pos =0; + while(fsize) + { + if(msize > FILEBUFF_SIZE * 2) + { + scr_CountPerMax2(msize-fsize,msize,0); + if (++itvl & 1)scr_Status(MessTxt(MT_Copy1),COLOR_PARPL); + else scr_Status(MessTxt(MT_Copy2),COLOR_PARPL); + }else scr_MessOnCount2(MES_NULL); + + if (fsize>FILEBUFF_SIZE) + { + rsize = FILEBUFF_SIZE; + fsize -= FILEBUFF_SIZE; + }else{ + rsize = fsize; + fsize = 0; + } + if (ReadBlock(pos,rsize)==false) + { + res = RESULT_FAIL_READ; + break; + } + pos += rsize; + if(exsave.Write(fileBuffer,rsize) != rsize ) + { + NN_LOG("desc = %d\n",savedata.LastNnResult.GetDescription()); + res = RESULT_FAIL_WRITE; + break; + } + }//fsize + ct++; + savedata.Close(); + exsave.CloseW(); + }//else + }//while + + if ((res == RESULT_OK) && (savedata.CheckPathBit & cpb_ex)) + {//違反パスありなら、リネームして保存 + nn::Result result; + nn::fnd::DateTime tm; + //ディレクトリ作成..既存名を避けるため作成後に行う + i = 0; + while(i++ < 10 ){//試行回数(無駄?) + tm = nn::fnd::DateTime::GetNow(); + //退避先ディレクトリ名作成:SDK制限で16文字まで + swprintf(file_pathw,3,L"%3d",tm.GetMilliSecond()); + if (file_pathw[0]==L' ')file_pathw[0] = L'0'; + if (file_pathw[1]==L' ')file_pathw[1] = L'0'; + wcscpy(wk_dir,L"/cSm_");//通常、使われないであろう名前にする + wcscat(wk_dir,file_pathw); + wcscat(wk_dir,L"_zzz"); + exsave.GetRootPath(file_pathw); + wcscat(file_pathw,wk_dir); + result = nn::fs::TryCreateDirectory(file_pathw); + if (result.IsSuccess())break; + if(CheckInsExit())break; + } + if (result.IsFailure()){ + exsave.Unmount(); + memsave.Unmount(); + savedata.Unmount(); + exsave.Delete();//バックアップを削除 + memsave.Delete(); + if(isInsEject != InEx_None )return INSEXIT; + PutError(TGT_SD,ERC_WORK);//退避先が確保できない + return ERROR; + } + + memsave.ResetPath(); + while(res==RESULT_OK){ + res = memsave.GetPath(file_pathw);//リネーム対象ファイル名 + if (file_pathw[0] == 0)break;//root then end + if (ct>=arcInfo.FileCount) + { + res = RESULT_FAIL; + break; + } + + scr_CountPerMax(ct,arcInfo.FileCount); + + if (savedata.Open(file_pathw)==false)//ユーザセーブ開く + { + res = RESULT_FAIL_OPEN; + break; + } + fsize = savedata.FileSize; + + //リネーム名取得 + if (memsave.Open(file_pathw)==false) + { + res = RESULT_FAIL;//メモリからなので通常ありえない + break; + } + if(memsave.Read((char*)ws,18)!=18)//wchar 9文字 + { + res = RESULT_FAIL;//メモリからなので通常ありえない + break; + } + memsave.Close(); + ws[9]=0;//終端 + ws[10]=0; + wcscpy(file_pathw2,wk_dir); + wcscat(file_pathw2,ws); + if (exsave.OpenC(file_pathw2,fsize,&mkdir)==false) + {//エラーもしくは、退避先ディレクトリが無い + res = RESULT_FAIL_OPENW; + break; + } + msize = fsize; + pos =0; + while(fsize) + { + if (fsize>FILEBUFF_SIZE) + { + rsize = FILEBUFF_SIZE; + fsize -= FILEBUFF_SIZE; + }else{ + rsize = fsize; + fsize = 0; + } + if (ReadBlock(pos,rsize)==false) + { + res = RESULT_FAIL_READ; + break; + } + pos += rsize; + if(exsave.Write(fileBuffer,rsize) != rsize ) + { + res = RESULT_FAIL_WRITE; + break; + } + }//while(fsize) + ct++; + savedata.Close(); + exsave.CloseW(); + memsave.Close(); + }//while + }//if + savedata.Unmount(); + exsave.Unmount(); + memsave.Unmount(); + scr_CountPerMax(ct,arcInfo.FileCount); + scr_CountPerMax2(0,0,total); + +//結果 + TgtDev ercd; + int ercc; + switch(res) + { + case RESULT_OK: + if (VerifiSd()) + { + scr_Status(MessTxt(MT_Complate),COLOR_WHITE); + strcpy(arcInfo.Pcode,savedata.PrdCode); + return SUCCESS; + } + ercd = TGT_CARD;ercc = ERC_VERIFI; + break; + case RESULT_FAIL_WRITE: + case RESULT_FAIL_OPENW: + ercd = TGT_SD;ercc = ERC_WRITE;//ライト失敗 + break; + case RESULT_FAIL_READ: + case RESULT_FAIL_OPEN: + ercd = TGT_CARD;ercc = ERC_READ;//リード + break; + case RESULT_WORK_OVER: + ercd = TGT_NONE;ercc = ERC_NOSPACE;//ワーク不足..違反フアイル多すぎ + break; + default: + ercd = TGT_NONE;ercc = ERC_EXEC; + break; + } + exsave.Delete();//バックアップを削除 + memsave.Delete(); + return PutErrRetCode(ercd,ercc); +} + +#endif + //--------------------------------------------------------------- セーブデータの情報取得 //呼ぶ前に tmerr のクリアを忘れない事 void CheckSaveDataState() { - myResult myres; - Formatted = false; Active = false; if (savedata.GetPrdCode()) { - Active = true;//カード - myres = savedata.IsExist();//セーブマウント //NN_LOG("%d",savedata.LastNnResult.GetDescription()); - if (myres == RESULT_OK) + Active = true;//カード + if (savedata.IsExist())//マウントで確認 { Formatted=true; }else{ @@ -687,21 +1623,51 @@ void CheckSaveDataState() void CheckExSaveState() { - exActive = true;//メモリなので常にtrue - //if (exActive){ - exFormatted = exsave.IsExist() && exsave.GetInfo(&arcInfo); - //todo:変更時はバージョンチェック入れる - exsave.Unmount(); - //}else{ - ////arcInfo.Pcode[0] = 0; - // exFormatted = false; - //} +#ifdef CSM_FLAG_USE_SD + if (alive_Sd)exActive = nn::fs::IsSdmcWritable(); + else exActive = true; +#else + exActive = true; +#endif + if (exActive){ +#ifdef CSM_FLAG_USE_SD + if (BkupSd){ + exFormatted = exsave.IsExist(); + exsave.Unmount(); + }else{ +#endif + exFormatted = memsave.IsExist(); + memsave.Unmount(); +#ifdef CSM_FLAG_USE_SD + } +#endif + + }else{ + exFormatted = false; + } +//デバグ時は抜けてもクリアしない +#ifndef CSM_FLAG_DEBUG if (exFormatted==false) arcInfo.Pcode[0] = 0; +#endif scr_PrdCodeEx(arcInfo.Pcode); //プロダクトコードのチェック isAgreePCode = strcmp(savedata.PrdCode,arcInfo.Pcode)==0; } +//SD挿抜 +void Evt_SdInEx() +{ +#ifndef CSM_FLAG_DEBUG + ScrClr(); + scr_TopMenu(Formatted,Active,exFormatted,exActive,tmerr); + scr_Draw(); + failstop();//停止 +#else + CheckExSaveState();//状態更新 + scr_evnt = EVNT_INEX; +#endif +} + //---------------------------------------------------------------- 入力待ち void WaitUI() @@ -711,43 +1677,72 @@ void WaitUI() scr_evnt = EVNT_NONE; while(scr_evnt == EVNT_NONE) { - nn::os::Thread::Yield();//スレッド実行 + //nn::os::Thread::Yield();//スレッド実行 //scr_GetEvnt();//入力イベント CheckSysBreak();//中断処理 +#ifdef CSM_FLAG_USE_SD + //挿抜を検知したらアプリ終了待ちするようする + if (ejectEvntSd.TryWait()){ + isInsEject = InEx_EjcSd; + Evt_SdInEx(); + return; + } + if (insEvntSd.TryWait()){ + isInsEject = InEx_InsSd; + Evt_SdInEx(); + return; + } +#endif //挿抜を検知したら中断して抜ける //トップ以外ではトップメニューへ戻るようする if (ejectEvnt.TryWait()){ - CheckSaveDataState(); isInsEject = InEx_EjcCard; + CheckSaveDataState(); + scr_evnt = EVNT_INEX; return; } if (insEvnt.TryWait()){ - CheckSaveDataState(); isInsEject = InEx_InsCard; + CheckSaveDataState(); + scr_evnt = EVNT_INEX; return; } + nn::os::Thread::Yield();//スレッド実行..タッチ&ボタン取得 } ScrClr();//画面消去 nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(500));//チャタ対策 } -tColStr mess_ReadError = {"[Read] is failed",COLOR_RED}; -tColStr mess_WriteError = {"[Write] is failed",COLOR_RED}; -tColStr mess_ReadOk = {"[Read] is Success",COLOR_GREEN}; -tColStr mess_WriteOk = {"[Write] is Success",COLOR_GREEN}; -tColStr mess_PullOut = {"Pull Out",COLOR_RED}; -tColStr mess_ChkDev = {"check device",COLOR_RED}; -tColStr mess_Insexit = {"Detect Insert or pull out",COLOR_RED}; -tColStr mess_WhenExc = {"When you exchange device",COLOR_WHITE}; -tColStr mess_PoffSys = {"PowerOff or return Top Menu",COLOR_WHITE}; +void InsExtErrPut(tIsInsEject n) +{ + switch (n) + { + case InEx_EjcSd: + case InEx_InsSd://SD insert or exit + PutError(TGT_SD,ERC_PULLOUT); +#ifndef CSM_FLAG_DEBUG + failstop();//stop running +#endif + break; + case InEx_EjcCard: + PutError(TGT_CARD,ERC_DEVICE); + break; + case InEx_InsCard://素早い抜き差しでEjectイベント消える? + PutError(TGT_CARD,ERC_PULLOUT); + break; + default://通常ありえない .. 実行時エラー + PutError(TGT_NONE,ERC_EXEC); + failstop();//stop running + break; + } +} + //---------------------- main loop -------------------------- void nnMain() { - int i; - myResult mres; RetCode retc; //tColStr *colstr[4]; //colstr[2] = &mess_WhenExc; @@ -771,191 +1766,152 @@ void nnMain() nn::applet::DisableSleep();//スリープ非対応 +#ifdef CSM_FLAG_USE_SD + //起動時にSD確認 + alive_Sd = nn::fs::IsSdmcWritable(); +#else + alive_Sd = false; +#endif //Heap appHeap.Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize(), nn::os::ALLOCATE_OPTION_LINEAR); const u32 GxHeapSize = 0x800000; heapForGx = reinterpret_cast(appHeap.Allocate(GxHeapSize)); //画面初期化 - if (ScrInitialize(heapForGx,GxHeapSize) == false)failstop(); + + //メッセージ用テキストの読み込み + bool jp; + // nn::cfg::CTR::Initialize(); + // if (nn::cfg::GetLanguage() == nn::cfg::CFG_LANGUAGE_JAPANESE) + // { + // jp = true; + // LoadMessText(L"rom:/lang_jp.mes"); + //} + //else{ + jp = false; + LoadMessText(L"rom:/lang_en.mes"); + // } + // nn::cfg::Finalize(); + +#ifdef CSM_FLAG_DEBUG + //リリース品と区別するためタイトルに[debug]を付ける(非セキュア品の流出予防) + if (ScrInitialize(heapForGx,GxHeapSize,jp,true) == false)finish(); +#else + if (ScrInitialize(heapForGx,GxHeapSize,jp,false) == false)finish(); +#endif + + + //挿抜イベント ejectEvnt.ClearSignal(); insEvnt.ClearSignal(); nn::fs::RegisterCardEjectedEvent(&ejectEvnt); nn::fs::RegisterCardInsertedEvent(&insEvnt); +#ifdef CSM_FLAG_USE_SD + if (alive_Sd){ + ejectEvntSd.ClearSignal(); + insEvntSd.ClearSignal(); + nn::fs::RegisterSdmcEjectedEvent(&ejectEvntSd); + nn::fs::RegisterSdmcInsertedEvent(&insEvntSd); + //拡張セーブが存在したら消す + if(exsave.IsExist())exsave.Delete(); + } +#endif // スリープ要求に対する返答を有効にする // また、蓋の状態チェックを行い蓋が閉じられているならスリープ要求が発生する //nn::applet::EnableSleep(true); extern u8 scr_evnt; + u8 scr_evntbk; while(1) { - tmerr = 0; - CheckSaveDataState(); //セーブデータの状態取得 - CheckExSaveState(); //同バックアップ + tmerr = 0; + CheckSaveDataState(); //セーブデータの状態取得 + CheckExSaveState(); //同バックアップ if (isAgreePCode==false) tmerr |= SDATA_ERRPUT_PCODE; -// scr_TopMenu(Formatted,Active,exFormatted,exActive,isAgreePCode,failveri); scr_TopMenu(Formatted,Active,exFormatted,exActive,tmerr); - WaitUI();//入力待ち - if (isInsEject != InEx_None){ - ScrClr();//画面消去 - isInsEject= InEx_None; - }else + scr_evntbk = scr_evnt; switch(scr_evnt) { + case EVNT_INEX: + isInsEject= InEx_None; + break; case EVNT_PUSH_B: + case EVNT_PUSH_R: + case EVNT_PUSH_Y: case EVNT_NONE: break; - case EVNT_PUSH_Y: - break; - case EVNT_SEL_READ://リード + case EVNT_SEL_READ://**************************** リード NN_LOG("select read\n"); - retc = Card2Sd(); + retc = Card2Ctr(); switch (retc){ case SUCCESS: //CheckExSaveState(); //状態の更新 - scr_ResultQuit("Success",COLOR_GREEN);//成功とQuitボタン + scr_ResultQuit(MessTxt(MT_Success),COLOR_GREEN);//成功とQuitボタン break; case INSEXIT: //scr_InsExitQuit();//挿抜検知表示 & Quit ScrClr();//画面消去 scr_Backup(); - { - if (isInsEject == InEx_EjcCard)PutError(ERC_DEV_CARD,ERC_DEVICE); - else PutError(ERC_DEV_OTHER); - scr_ResultQuit("Break",COLOR_RED);//エラーとQuitボタン - } + InsExtErrPut(isInsEject); + scr_ResultQuit(MessTxt(MT_Break),COLOR_RED);//エラーとQuitボタン break; case CANCEL: - //scr_ResultQuit("Canseled",COLOR_YELLO);//キャンセル break; default://errors - scr_ResultQuit("Failed",COLOR_RED);//エラーとQuitボタン + if (CheckInsExit())InsExtErrPut(isInsEject);//抜差イベント? + scr_ResultQuit(MessTxt(MT_Failed),COLOR_RED);//エラーとQuitボタン break; } - if (retc == CANCEL)break; - //isInsEject = InEx_None; - while(1){ - WaitUI(); - if (isInsEject != InEx_None){ - isInsEject = InEx_None; - } - if(scr_evnt==EVNT_QUIT)break; - if(scr_evnt==EVNT_PUSH_B)break; - } break; - case EVNT_SEL_WRITE://リストア + case EVNT_SEL_WRITE:// **************************** リストア NN_LOG("select write\n"); - retc = Sd2Card(); + retc = Ctr2Card(); switch (retc){ case SUCCESS: //CheckSaveDataState(); //状態の更新 //CheckExSaveState(); - scr_ResultQuit("Success",COLOR_GREEN);//成功とQuitボタン + scr_ResultQuit(MessTxt(MT_Success),COLOR_GREEN);//成功とQuitボタン break; case INSEXIT: //scr_InsExitQuit();//挿抜検知表示 & Quit ScrClr();//画面消去 - scr_Backup(); - { - if (isInsEject == InEx_EjcCard)PutError(ERC_DEV_CARD,ERC_DEVICE); - else PutError(ERC_DEV_OTHER); - scr_ResultQuit("Break",COLOR_RED);//エラーとQuitボタン - } - break; + scr_Restore(); + InsExtErrPut(isInsEject); + scr_ResultQuit(MessTxt(MT_Break),COLOR_RED);//エラーとQuitボタン case CANCEL: - //scr_ResultQuit("Canseled",COLOR_YELLO);//キャンセル break; default://errors - scr_ResultQuit("Failed",COLOR_RED);//エラーとQuitボタン + if (CheckInsExit())InsExtErrPut(isInsEject);//抜差イベント? + scr_ResultQuit(MessTxt(MT_Failed),COLOR_RED);//エラーとQuitボタン break; } - if (retc == CANCEL)break; - while(1){ - WaitUI(); - if (isInsEject != InEx_None){ - isInsEject= InEx_None; - } - if(scr_evnt==EVNT_QUIT)break; - if(scr_evnt==EVNT_PUSH_B)break; - } break; -/* case EVNT_SEL_END: - NN_LOG("select end\n"); - finish(); - break; - case EVNT_NO: - NN_LOG("select NO\n"); - break; - case EVNT_YES: - NN_LOG("select YES\n"); - break; -*/ - //old debug key - case EVNT_PUSH_L:// ------------------------------- 表示の切り替え - case EVNT_PUSH_DOWN_Y:// ---------------------------------- 表示の切り替え - break; - case EVNT_PUSH_LEFT_X:// ------------------------------------- LEFT + X //バックアップ削除 scr_DelConf();//実行確認 WaitUI(); if (scr_evnt != EVNT_YES)break; - exsave.Delete(); - //CheckExSaveState(); //状態更新 + memsave.Delete(); +#ifdef CSM_FLAG_USE_SD + if(alive_Sd)exsave.Delete(); +#endif break; - case EVNT_PUSH_R:// ------------------------------------------- R - //CARD(NAND)へテストファイル書き込み - //デバグモード時のみ - bool flg; - scr_ConfirmDbg("dummy savedata write OK?");//実行確認 - WaitUI(); - if (scr_evnt != EVNT_YES)break; - for ( i =0;i +#include +#include +#include #include #include #include "screen.h" @@ -162,52 +166,120 @@ void touchQuit(u32 pos NN_IS_UNUSED_VAR) // -------------------------------------------------- R|[lg݌v // +#ifdef USE_WCHAR +/* +tChar* S_Backup = L"Ǎ"; +tChar* S_Restore = L""; +tChar* S_Yes = L"͂"; +tChar* S_No = L""; +tChar* S_Quit = L"߂"; +tChar* S_Space = L"@"; +tChar* S_Execute = L"s܂H"; +tChar* S_HelpBackup = L"[Ǎ] J[hǂ"; +tChar* S_HelpRestore = L"[] J[hɏ"; +tChar* S_Touch = L"^b`Ŏs܂"; +tChar* S_Version = L"u"; +tChar* S_QuitB = L"^b`a{^Ŗ߂܂"; +tChar* S_Insexit = L"foCX̑}m܂"; +tChar* S_RetTop = L"Jnʂɖ߂܂"; +tChar* S_Del = L"@@폜@@"; +tChar* S_Del2 = L"@@@@"; +tChar* S_Del3 = L"Ǐof[^폜܂"; +tChar* S_Title = L"@J[hZ[uڍs"; +tChar* S_InsertCard = L"J[h}ĉ"; +tChar* S_TitleBkup = L"@||@J[hǍ@||"; +tChar* S_TitleRestore = L"@||@J[h֏@||"; +*/ +tChar* S_Backup = L"Backup"; +tChar* S_Restore = L"Restore"; +tChar* S_Yes = L"YES"; +tChar* S_No = L"NO"; +tChar* S_Quit = L"Quit"; +tChar* S_Space = L" "; +tChar* S_Execute = L"Do you execute?"; +tChar* S_HelpBackup = L"[Backup] read from Card"; +tChar* S_HelpRestore = L"[Restore] write to Card"; +tChar* S_Touch = L"Touch below"; +tChar* S_Version = L"version"; +tChar* S_QuitB = L"touch [Quit] or push B"; +tChar* S_Insexit = L"device insert or pull out is detected"; +tChar* S_RetTop = L"return to top menu"; +tChar* S_Del = L" *** DELETE *** "; +tChar* S_Del2 = L" caution!"; +tChar* S_Del3 = L"this is delete backup"; +tChar* S_Title = L" < CTR Card Savedata Mover >"; +tChar* S_InsertCard = L"Please Insert Card"; +tChar* S_TitleBkup = L" --- Backup Card Savedata ---"; +tChar* S_TitleRestore = L"--- Restore Card Savedata ---"; + + +#else +tChar* S_Backup = "Backup"; +tChar* S_Restore = "Restore"; +tChar* S_Yes = "YES"; +tChar* S_No = "NO"; +tChar* S_Quit = "Quit"; +tChar* S_Space = " "; +tChar* S_Execute = "Do you execute?"; +tChar* S_HelpBackup = "[Backup] read from Card"; +tChar* S_HelpRestore = "[Restore] write to Card"; +tChar* S_Touch = "Touch below"; +tChar* S_Version = "version"; +tChar* S_QuitB = "touch [Quit] or push B"; +tChar* S_Insexit = "device insert or pull out is detected"; +tChar* S_RetTop = "return to top menu"; +tChar* S_Del = " *** DELETE *** "; +tChar* S_Del2 = " caution!"; +tChar* S_Del3 = "this is delete backup"; +tChar* S_Title = " < CTR Card Savedata Mover >"; +tChar* S_InsertCard = "Please Insert Card"; +tChar* S_TitleBkup = " --- Backup Card Savedata ---"; +tChar* S_TitleRestore = "--- Restore Card Savedata ---"; +#endif //Top Menu -const tPanel panel_Read = {(uptr)touchRead,"Backup",80+20,30,160,80,PANEL_READ,SCREEN_LOWER}; -const tPanel panel_Write = {(uptr)touchWrite,"Restore",80+20,130,160,80,PANEL_WRITE,SCREEN_LOWER}; +const tPanel panel_Read = {(uptr)touchRead,S_Backup,80+20,30,160,80,PANEL_READ,SCREEN_LOWER}; +const tPanel panel_Write = {(uptr)touchWrite,S_Restore,80+20,130,160,80,PANEL_WRITE,SCREEN_LOWER}; //const tPanel panel_End = {(uptr)touchEnd,"End",80,180,160,30,PANEL_END,SCREEN_LOWER}; //Yes No -const tPanel panel_Yes = {(uptr)touchYes,"YES",40+10,60,80,120,PANEL_YES,SCREEN_LOWER}; -const tPanel panel_No = {(uptr)touchNo,"NO",200+30,60,80,120,PANEL_NO,SCREEN_LOWER}; +const tPanel panel_Yes = {(uptr)touchYes,S_Yes,40+10,60,80,120,PANEL_YES,SCREEN_LOWER}; +const tPanel panel_No = {(uptr)touchNo,S_No,200+30,60,80,120,PANEL_NO,SCREEN_LOWER}; //Quit -const tPanel panel_Quit = {(uptr)touchQuit,"Quit",80+20,60,160,120,PANEL_QUIT,SCREEN_LOWER}; +const tPanel panel_Quit = {(uptr)touchQuit,S_Quit,80+20,60,160,120,PANEL_QUIT,SCREEN_LOWER}; // +/* //foOp //G[\ const tPanel panel_Error = {NULL_PTR,NULL_STR,LOC_CONF_X,LOC_CONF_Y,LOC_CONF_W,LOC_CONF_H,PANEL_ERROR,SCREEN_UPPER}; -const tMessage mess_Title_Err = {"title",10,10,COLOR_RED,8,MESSAGE_ERROR_TITLE,PANEL_ERROR}; -const tMessage mess_Info_Err = {"info",10,22,COLOR_RED,8,MESSAGE_ERROR_INFO,PANEL_ERROR}; -const tMessage mess_Info2_Err = {"info2",10,40,COLOR_RED,8,MESSAGE_ERROR_INFO2,PANEL_ERROR}; -const tMessage mess_Info3_Err = {"info3",10,50,COLOR_RED,8,MESSAGE_ERROR_INFO3,PANEL_ERROR}; +const tMessage mess_Title_Err = {S_Space,10,10,COLOR_RED,8,MESSAGE_ERROR_TITLE,PANEL_ERROR}; +const tMessage mess_Info_Err = {S_Space,10,22,COLOR_RED,8,MESSAGE_ERROR_INFO,PANEL_ERROR}; +const tMessage mess_Info2_Err = {S_Space,10,40,COLOR_RED,8,MESSAGE_ERROR_INFO2,PANEL_ERROR}; +const tMessage mess_Info3_Err = {S_Space,10,50,COLOR_RED,8,MESSAGE_ERROR_INFO3,PANEL_ERROR}; // const tPanel panel_Success = {NULL_PTR,NULL_STR,LOC_CONF_X,LOC_CONF_Y,LOC_CONF_W,LOC_CONF_H,PANEL_SUCCESS,SCREEN_UPPER}; -const tMessage mess_Title_Suc = {"title",10,10,COLOR_GREEN,8,MESSAGE_SUCCESS_TITLE,PANEL_SUCCESS}; -const tMessage mess_Info_Suc = {"info",10,40,COLOR_WHITE,8,MESSAGE_SUCCESS_INFO,PANEL_SUCCESS}; -const tMessage mess_Info2_Suc = {"info2",10,50,COLOR_WHITE,8,MESSAGE_SUCCESS_INFO2,PANEL_SUCCESS}; +const tMessage mess_Title_Suc = {S_Space,10,10,COLOR_GREEN,8,MESSAGE_SUCCESS_TITLE,PANEL_SUCCESS}; +const tMessage mess_Info_Suc = {S_Space,10,40,COLOR_WHITE,8,MESSAGE_SUCCESS_INFO,PANEL_SUCCESS}; +const tMessage mess_Info2_Suc = {S_Space,10,50,COLOR_WHITE,8,MESSAGE_SUCCESS_INFO2,PANEL_SUCCESS}; //smF const tPanel panel_Confirm = {NULL_PTR,NULL_STR,LOC_CONF_X,LOC_CONF_Y,LOC_CONF_W,LOC_CONF_H,PANEL_CONFIRM,SCREEN_UPPER}; -const tMessage mess_conf_Title = {"title",10,10,COLOR_YELLO,8,MESSAGE_CONFIRM_TITLE,PANEL_CONFIRM}; -const tMessage mess_conf_Msg = {"Do you execute?",10,40,COLOR_WHITE,8,MESSAGE_CONFIRM_MSG,PANEL_CONFIRM}; +const tMessage mess_conf_Title = {S_Space,10,10,COLOR_YELLO,8,MESSAGE_CONFIRM_TITLE,PANEL_CONFIRM}; +const tMessage mess_conf_Msg = {S_Execute,10,40,COLOR_WHITE,8,MESSAGE_CONFIRM_MSG,PANEL_CONFIRM}; //gbvj[ -const tPanel panel_topmenu_help = {NULL_PTR,NULL_STR,LOC_CONF_X,LOC_CONF_Y,LOC_CONF_W,LOC_CONF_H,PANEL_TOPMENU,SCREEN_UPPER}; -const tMessage mess_topmenu_help_read = {"[Backup] Card -> bkup",10,4,COLOR_WHITE,8,MESSAGE_TOPMENU_HELP_READ,PANEL_TOPMENU}; -const tMessage mess_topmenu_help_notread = {"[Backup] is Invalid",10,4,COLOR_RED,8,MESSAGE_TOPMENU_HELP_READ,PANEL_TOPMENU}; -const tMessage mess_topmenu_help_write = {"[Restore] bkup -> Card",10,16,COLOR_WHITE,8,MESSAGE_TOPMENU_HELP_WRITE,PANEL_TOPMENU}; -const tMessage mess_topmenu_help_notwrite = {"[Restore] is Invalid",10,16,COLOR_RED,8,MESSAGE_TOPMENU_HELP_WRITE,PANEL_TOPMENU}; -const tMessage mess_topmenu_help_end = {"[End] return to SystemMenu",10,28,COLOR_WHITE,8,MESSAGE_TOPMENU_HELP_END,PANEL_TOPMENU}; -const tMessage mess_topmenu_help_operate = {"touch below",10,48,COLOR_GREEN,8,MESSAGE_TOPMENU_HELP_OPERATE,PANEL_TOPMENU}; +//const tPanel panel_topmenu_help = {NULL_PTR,NULL_STR,LOC_CONF_X,LOC_CONF_Y,LOC_CONF_W,LOC_CONF_H,PANEL_TOPMENU,SCREEN_UPPER}; +//const tMessage mess_topmenu_help_read = {S_HelpBackup,10,4,COLOR_WHITE,8,MESSAGE_TOPMENU_HELP_READ,PANEL_TOPMENU}; +//const tMessage mess_topmenu_help_write = {S_HelpRestore,10,16,COLOR_WHITE,8,MESSAGE_TOPMENU_HELP_WRITE,PANEL_TOPMENU}; +//const tMessage mess_topmenu_help_operate = {S_Touch,10,48,COLOR_GREEN,8,MESSAGE_TOPMENU_HELP_OPERATE,PANEL_TOPMENU}; //O\ const tPanel panel_dbglog = {NULL_PTR,NULL_STR,LOC_LOG_X,LOC_LOG_Y,LOC_LOG_W,LOC_LOG_H,PANEL_DBGLOG,SCREEN_UPPER}; const tMemo memo_dbglog = {LOG_MAX,10,10,COLOR_WHITE,8,MEMO_DBGLOG,PANEL_DBGLOG}; - +*/ //ʏ펞 //^Cg @@ -218,64 +290,58 @@ const tMemo memo_dbglog = {LOG_MAX,10,10,COLOR_WHITE,8,MEMO_DBGLOG,PANEL_DBGLOG} #define LOC_TITL_H 50 #define FONT_SIZE_PRODUCT 10 const tPanel panel_title = {NULL_PTR,NULL_STR,LOC_TITL_X,LOC_TITL_Y,LOC_TITL_W,LOC_TITL_H,PANEL_TITLE,SCREEN_UPPER}; -const tMessage mess_title = {"title",0,0,COLOR_WHITE,FONT_SIZE_TITLE,MESSAGE_TITLE,PANEL_TITLE}; -const tMessage mess_product = {"product",0,LOC_TITL_H - 22,COLOR_WHITE,FONT_SIZE_PRODUCT,MESSAGE_PRODUCT,PANEL_TITLE}; -const tMessage mess_product2 = {"product2",0,LOC_TITL_H - 10,COLOR_WHITE,FONT_SIZE_PRODUCT,MESSAGE_PRODUCT2,PANEL_TITLE}; -const tMessage mess_version = {"version",LOC_TITL_W-FONT_SIZE_PRODUCT*6,FONT_SIZE_TITLE+2,COLOR_WHITE,FONT_SIZE_PRODUCT,MESSAGE_VERSION,PANEL_TITLE}; +const tMessage mess_title = {S_Space,0,0,COLOR_WHITE,FONT_SIZE_TITLE,MESSAGE_TITLE,PANEL_TITLE}; +const tMessage mess_product = {S_Space,0,LOC_TITL_H - 22,COLOR_WHITE,FONT_SIZE_PRODUCT,MESSAGE_PRODUCT,PANEL_TITLE}; +const tMessage mess_product2 = {S_Space,0,LOC_TITL_H - 10,COLOR_WHITE,FONT_SIZE_PRODUCT,MESSAGE_PRODUCT2,PANEL_TITLE}; +const tMessage mess_version = {S_Version,LOC_TITL_W-FONT_SIZE_PRODUCT*6,FONT_SIZE_TITLE+2,COLOR_WHITE,FONT_SIZE_PRODUCT,MESSAGE_VERSION,PANEL_TITLE}; #define LOC_MESS_X 20 #define LOC_MESS_W (400 - LOC_MESS_X*2) #define LOC_MESS_Y (LOC_TITL_Y + LOC_TITL_H + 10) #define LOC_MESS_H (240 - LOC_MESS_Y - 10) //TOPj[ -//\̓OƔr #define FONT_SIZE 10 #define STR_LINE(ln) (FONT_SIZE + 2)*ln const tPanel panel_menu = {NULL_PTR,NULL_STR,LOC_MESS_X,LOC_MESS_Y,LOC_MESS_W,LOC_MESS_H,PANEL_MENU,SCREEN_UPPER}; -const tMessage mess_menu_read = {"[Backup] Card savedata Backup",10,STR_LINE(1),COLOR_WHITE,FONT_SIZE,MESSAGE_MENU_READ,PANEL_MENU}; -const tMessage mess_menu_write = {"[Restore] restore to Card",10,STR_LINE(2),COLOR_WHITE,FONT_SIZE,MESSAGE_MENU_WRITE,PANEL_MENU}; -//const tMessage mess_menu_end = {"[End] close this apprication",10,STR_LINE(3),COLOR_WHITE,FONT_SIZE,MESSAGE_MENU_END,PANEL_MENU}; -const tMessage mess_menu_operate = {"touch below",10,STR_LINE(4),COLOR_GREEN,FONT_SIZE,MESSAGE_MENU_OPERATE,PANEL_MENU}; -const tMessage mess_bkuperr = {"Backup error",10,STR_LINE(6),COLOR_RED,FONT_SIZE,MESSAGE_MENU_ERROR,PANEL_MENU}; -const tMessage mess_carderr = {"CARD error",10,STR_LINE(7),COLOR_YELLO,FONT_SIZE,MESSAGE_MENU_CAUTION,PANEL_MENU}; -const tMessage mess_debug = {"Crush Mode",10,STR_LINE(3),COLOR_YELLO,FONT_SIZE,MESSAGE_MENU_DEBUG,PANEL_MENU}; +const tMessage mess_menu_read = {S_HelpBackup,10,STR_LINE(1),COLOR_WHITE,FONT_SIZE,MESSAGE_MENU_READ,PANEL_MENU}; +const tMessage mess_menu_write = {S_HelpRestore,10,STR_LINE(2),COLOR_WHITE,FONT_SIZE,MESSAGE_MENU_WRITE,PANEL_MENU}; +const tMessage mess_menu_operate = {S_Touch,10,STR_LINE(4),COLOR_GREEN,FONT_SIZE,MESSAGE_MENU_OPERATE,PANEL_MENU}; +const tMessage mess_bkuperr = {S_Space,10,STR_LINE(6),COLOR_RED,FONT_SIZE,MESSAGE_MENU_ERROR,PANEL_MENU}; +const tMessage mess_carderr = {S_Space,10,STR_LINE(7),COLOR_YELLO,FONT_SIZE,MESSAGE_MENU_CAUTION,PANEL_MENU}; //Backup -//const tPanel panel_bkup = {NULL_PTR,NULL_STR,LOC_LOG_X,LOC_LOG_Y,LOC_LOG_W,LOC_LOG_H,PANEL_BKUP,SCREEN_UPPER}; const tPanel panel_bkup = {NULL_PTR,NULL_STR,LOC_MESS_X,LOC_MESS_Y,LOC_MESS_W,LOC_MESS_H,PANEL_BKUP,SCREEN_UPPER}; -const tMessage mess_quit_operate = {"touch [Quit],or Push B",10,STR_LINE(4),COLOR_SKY,FONT_SIZE,MESSAGE_QUIT_OPERATE,PANEL_BKUP}; -const tMessage mess_conf = {"Do you execute?",10,STR_LINE(2),COLOR_WHITE,FONT_SIZE,MESSAGE_CONF,PANEL_BKUP}; -const tMessage mess_result = {"result",10,STR_LINE(2),COLOR_WHITE,FONT_SIZE,MESSAGE_RESULT,PANEL_BKUP}; -const tMessage mess_operate = {"touch below",10,STR_LINE(4),COLOR_GREEN,FONT_SIZE,MESSAGE_OPERATE,PANEL_BKUP}; -const tMessage mess_status = {"status",10,STR_LINE(7),COLOR_WHITE,FONT_SIZE,MESSAGE_STATUS,PANEL_BKUP}; -const tMessage mess_count = {"count",10,STR_LINE(8),COLOR_WHITE,FONT_SIZE,MESSAGE_COUNT,PANEL_BKUP}; -const tMessage mess_count2 = {"count2",10,STR_LINE(9),COLOR_GREEN,FONT_SIZE,MESSAGE_COUNT2,PANEL_BKUP}; +const tMessage mess_quit_operate = {S_QuitB,10,STR_LINE(4),COLOR_SKY,FONT_SIZE,MESSAGE_QUIT_OPERATE,PANEL_BKUP}; +const tMessage mess_conf = {S_Execute,10,STR_LINE(2),COLOR_WHITE,FONT_SIZE,MESSAGE_CONF,PANEL_BKUP}; +const tMessage mess_result = {S_Space,10,STR_LINE(2),COLOR_WHITE,FONT_SIZE,MESSAGE_RESULT,PANEL_BKUP}; +const tMessage mess_operate = {S_Touch,10,STR_LINE(4),COLOR_GREEN,FONT_SIZE,MESSAGE_OPERATE,PANEL_BKUP}; +const tMessage mess_status = {S_Space,10,STR_LINE(7),COLOR_WHITE,FONT_SIZE,MESSAGE_STATUS,PANEL_BKUP}; +const tMessage mess_count = {S_Space,10,STR_LINE(8),COLOR_WHITE,FONT_SIZE,MESSAGE_COUNT,PANEL_BKUP}; +const tMessage mess_count2 = {S_Space,10,STR_LINE(9),COLOR_GREEN,FONT_SIZE,MESSAGE_COUNT2,PANEL_BKUP}; //} -//const tPanel panel_insexit = {NULL_PTR,NULL_STR,LOC_LOG_X,LOC_LOG_Y,LOC_LOG_W,LOC_LOG_H,PANEL_INSEXIT,SCREEN_UPPER}; const tPanel panel_insexit = {NULL_PTR,NULL_STR,LOC_MESS_X,LOC_MESS_Y,LOC_MESS_W,LOC_MESS_H,PANEL_INSEXIT,SCREEN_UPPER}; -const tMessage mess_insexit = {"device insert or pull out is detected",10,STR_LINE(3),COLOR_RED,8,MESSAGE_INSEXT_1,PANEL_INSEXIT}; -const tMessage mess_insexit2 = {"return to top menu",10,STR_LINE(5),COLOR_WHITE,8,MESSAGE_INSEXT_2,PANEL_INSEXIT}; -const tMessage mess_insexit3 = {"please touch or push B",10,STR_LINE(6),COLOR_WHITE,8,MESSAGE_INSEXT_3,PANEL_INSEXIT}; +const tMessage mess_insexit = {S_Insexit,10,STR_LINE(3),COLOR_RED,8,MESSAGE_INSEXT_1,PANEL_INSEXIT}; +const tMessage mess_insexit2 = {S_RetTop,10,STR_LINE(5),COLOR_WHITE,8,MESSAGE_INSEXT_2,PANEL_INSEXIT}; +const tMessage mess_insexit3 = {S_QuitB,10,STR_LINE(6),COLOR_WHITE,8,MESSAGE_INSEXT_3,PANEL_INSEXIT}; //폜mF -//const tPanel panel_delconf = {NULL_PTR,NULL_STR,LOC_CONF_X-10,LOC_CONF_Y,LOC_CONF_W+10,LOC_CONF_H*2,PANEL_DELCONF,SCREEN_UPPER}; const tPanel panel_delconf = {NULL_PTR,NULL_STR,LOC_MESS_X,LOC_MESS_Y-36,LOC_MESS_W,LOC_MESS_H,PANEL_DELCONF,SCREEN_UPPER}; -const tMessage mess_delconf_Title = {" *** DELETE *** ",10,10,COLOR_YELLO,16,MESSAGE_DELCONF_TITLE,PANEL_DELCONF}; -const tMessage mess_delconf_Msg = {" caution!",10,50,COLOR_YELLO,12,MESSAGE_DELCONF_MSG,PANEL_DELCONF}; -const tMessage mess_delconf_Msg2 = {"this is delete backup",10,70,COLOR_YELLO,12,MESSAGE_DELCONF_MSG2,PANEL_DELCONF}; -const tMessage mess_delconf_Msg3 = {"Do you execute?",10,90,COLOR_YELLO,12,MESSAGE_DELCONF_MSG3,PANEL_DELCONF}; +const tMessage mess_delconf_Title = {S_Del,10,10,COLOR_YELLO,16,MESSAGE_DELCONF_TITLE,PANEL_DELCONF}; +const tMessage mess_delconf_Msg = {S_Del2,10,50,COLOR_YELLO,12,MESSAGE_DELCONF_MSG,PANEL_DELCONF}; +const tMessage mess_delconf_Msg2 = {S_Del3,10,70,COLOR_YELLO,12,MESSAGE_DELCONF_MSG2,PANEL_DELCONF}; +const tMessage mess_delconf_Msg3 = {S_Execute,10,90,COLOR_YELLO,12,MESSAGE_DELCONF_MSG3,PANEL_DELCONF}; nn::os::LightEvent stopEvnt(true); -char scr_ver[16]; -char scr_err[32]; -char scr_debug[32]; +tChar scr_ver[16]; +tChar scr_err[32]; +tChar scr_debug[32]; //menu -bool ScrInitialize(uptr heap,u32 size) +bool ScrInitialize(uptr heap,u32 size,bool jp,bool deb) { scr_evnt = EVNT_NONE; holdVal = 0; @@ -291,38 +357,38 @@ bool ScrInitialize(uptr heap,u32 size) gui.PanelSet(&panel_Yes); gui.PanelSet(&panel_No); gui.PanelSet(&panel_Quit); - gui.PanelSet(&panel_Error); - gui.PanelSet(&panel_Success); - gui.PanelSet(&panel_Confirm); +// gui.PanelSet(&panel_Error); +// gui.PanelSet(&panel_Success); +// gui.PanelSet(&panel_Confirm); gui.PanelSet(&panel_delconf); - gui.PanelSet(&panel_topmenu_help); +// gui.PanelSet(&panel_topmenu_help); gui.PanelSet(&panel_title); gui.PanelSet(&panel_menu); gui.PanelSet(&panel_bkup); - gui.PanelSet(&panel_dbglog); +// gui.PanelSet(&panel_dbglog); gui.PanelSet(&panel_insexit); gui.PanelLineStyle(PANEL_TITLE,COLOR_BLACK); - gui.MessSet(&mess_Title_Err); - gui.MessSet(&mess_Info_Err); - gui.MessSet(&mess_Info2_Err); - gui.MessSet(&mess_Info3_Err); - gui.MessSet(&mess_Title_Suc); - gui.MessSet(&mess_Info_Suc); - gui.MessSet(&mess_Info2_Suc); - gui.MessSet(&mess_conf_Title); - gui.MessSet(&mess_conf_Msg); +// gui.MessSet(&mess_Title_Err); +// gui.MessSet(&mess_Info_Err); +// gui.MessSet(&mess_Info2_Err); +// gui.MessSet(&mess_Info3_Err); +// gui.MessSet(&mess_Title_Suc); +// gui.MessSet(&mess_Info_Suc); +// gui.MessSet(&mess_Info2_Suc); +// gui.MessSet(&mess_conf_Title); +// gui.MessSet(&mess_conf_Msg); gui.MessSet(&mess_delconf_Title); gui.MessSet(&mess_delconf_Msg); gui.MessSet(&mess_delconf_Msg2); gui.MessSet(&mess_delconf_Msg3); - gui.MessSet(&mess_topmenu_help_read); - gui.MessSet(&mess_topmenu_help_write); - gui.MessSet(&mess_topmenu_help_end); - gui.MessSet(&mess_topmenu_help_operate); +// gui.MessSet(&mess_topmenu_help_read); +// gui.MessSet(&mess_topmenu_help_write); +// gui.MessSet(&mess_topmenu_help_end); +// gui.MessSet(&mess_topmenu_help_operate); gui.MessSet(&mess_title); gui.MessSet(&mess_version); @@ -337,7 +403,7 @@ bool ScrInitialize(uptr heap,u32 size) gui.MessSet(&mess_operate); gui.MessSet(&mess_bkuperr); gui.MessSet(&mess_carderr); - gui.MessSet(&mess_debug); +// gui.MessSet(&mess_debug); gui.MessSet(&mess_result); gui.MessSet(&mess_status); gui.MessSet(&mess_count); @@ -347,9 +413,9 @@ bool ScrInitialize(uptr heap,u32 size) gui.MessSet(&mess_insexit2); gui.MessSet(&mess_insexit3); - gui.MemoSet(&memo_dbglog); +// gui.MemoSet(&memo_dbglog); - gui.MemoEffective(MESSAGE_PRODUCT); +// gui.MemoEffective(MESSAGE_PRODUCT); gui.MessEffective(MESSAGE_ERROR_TITLE); gui.MessEffective(MESSAGE_ERROR_INFO); gui.MessEffective(MESSAGE_ERROR_INFO2); @@ -376,15 +442,25 @@ bool ScrInitialize(uptr heap,u32 size) gui.MessEffective(MESSAGE_INSEXT_3); gui.MessEffective(MESSAGE_TITLE); gui.MessEffective(MESSAGE_VERSION); - gui.MemoEffective(MEMO_DBGLOG); + // gui.MemoEffective(MEMO_DBGLOG); gui.PanelLineStyle(PANEL_DELCONF,COLOR_YELLO); - sprintf(scr_ver,"ver %.2f",VERSION); +#ifdef USE_WCHAR + if (VERSION != 0.0){ + swprintf(scr_ver,10,L"ver %.2f",VERSION); + if (deb)wcscat(scr_ver,L" DEBUG"); + }else wcscpy(scr_ver,VERSION_TXT_W); +#else + if (VERSION != 0.0){ + sprintf(scr_ver,"ver %.2f",VERSION); + if (deb)strcat(scr_ver," DEBUG"); + }else strcpy(scr_ver,VERSION_TXT); +#endif gui.MessStr(MESSAGE_VERSION,scr_ver); gui.MessStr(MESSAGE_MENU_CAUTION,scr_err); gui.MessStr(MESSAGE_MENU_ERROR,scr_err); - gui.MessStr(MESSAGE_MENU_DEBUG,scr_debug); +// gui.MessStr(MESSAGE_MENU_DEBUG,scr_debug); return true; @@ -416,7 +492,7 @@ void Quit() gui.Draw(); } - +/* //gbvj[ //:J[h void scr_TopMenuDbg(bool formatted,bool insertted)//fobOp @@ -447,12 +523,32 @@ void scr_TopMenuDbg(bool formatted,bool insertted)// gui.PanelEffective(PANEL_TOPMENU); gui.Draw(); } +*/ //ʏ펞 //v_NgR[h //:J[hAgZ[uɋL^ꂽ -char scr_pcode[32]; +tChar scr_pcode[32]; +tChar scr_pcode2[32]; + +#ifdef USE_WCHAR +void scr_PrdCode(char *s) +{ + wcscpy(scr_pcode,L"CARD : "); + if (s[0]==0) wcscat(scr_pcode,L"----"); + else mbstowcs(&scr_pcode[7],s,30); + gui.MessStr(MESSAGE_PRODUCT,scr_pcode); +} + +void scr_PrdCodeEx(char *s) +{ + wcscpy(scr_pcode2,L"BKUP : "); + if (s[0]==0) wcscat(scr_pcode2,L"----"); + else mbstowcs(&scr_pcode2[7],s,30); + gui.MessStr(MESSAGE_PRODUCT2,scr_pcode2); +} +#else void scr_PrdCode(char *s) { strcpy(scr_pcode,"CARD : "); @@ -461,7 +557,6 @@ void scr_PrdCode(char *s) gui.MessStr(MESSAGE_PRODUCT,scr_pcode); } -char scr_pcode2[64]; void scr_PrdCodeEx(char *s) { strcpy(scr_pcode2,"BKUP : "); @@ -469,6 +564,9 @@ void scr_PrdCodeEx(char *s) else strcat(scr_pcode2,s); gui.MessStr(MESSAGE_PRODUCT2,scr_pcode2); } +#endif + + //폜̎smF void scr_DelConf() @@ -478,6 +576,29 @@ void scr_DelConf() YesNo(); } +//G[\ +#ifdef USE_WCHAR +inline void set_err(int i) +{ + swprintf(scr_err,16,L"ERROR %d",i); +} + +inline void set_err(wchar_t* s) +{ + wcscpy(scr_err,s); +} + +#else +inline void set_err(int i) +{ + sprintf(scr_err,"ERROR %d",i); +} + +inline void set_err(char* s) +{ + strcpy(scr_err,s); +} +#endif //Top menu //:foCX @@ -491,11 +612,11 @@ void scr_TopMenu(bool formatted,bool inserted,bool exfm,bool bkupins,int err) u32 mask = 0; mask |= (nn::hid::BUTTON_LEFT | nn::hid::BUTTON_X);//LEFT+X = Delete L - gui.MessStr(MESSAGE_TITLE," < CTR Card Savedata Mover >"); + gui.MessStr(MESSAGE_TITLE,S_Title); - gui.MessEffective(MESSAGE_MENU_ERROR,false,false); - gui.MessEffective(MESSAGE_MENU_CAUTION,false,false); - gui.MessEffective(MESSAGE_MENU_OPERATE,false,false); + gui.MessEffective(MESSAGE_MENU_ERROR,false,false); + gui.MessEffective(MESSAGE_MENU_CAUTION,false,false); + gui.MessEffective(MESSAGE_MENU_OPERATE,false,false); //Е̂ݗL if (formatted && bkupins && (exfm == false)) {//obNAbv @@ -507,13 +628,13 @@ void scr_TopMenu(bool formatted,bool inserted,bool exfm,bool bkupins,int err) mask |= (nn::hid::BUTTON_LEFT | nn::hid::BUTTON_X);//LEFT+X = Delete L gui.PanelEffective(PANEL_READ,false,false); i =0; - if (err & SDATA_ERRPUT_PCODE) i = ERC_DEV_OTHER + ERC_PRODCODE;//v_NgR[hsv + if (err & SDATA_ERRPUT_PCODE) i = TGT_CARD + ERC_PRODCODE;//v_NgR[hsv //else - //if (err & SDATA_ERRPUT_MEDIA) i = ERC_MEDIA + ERC_DEV_CARD;//obNAbvȂ + //if (err & SDATA_ERRPUT_MEDIA) i = ERC_MEDIA + TGT_CARD;//obNAbvȂ if (i !=0 ) { gui.PanelEffective(PANEL_WRITE,false,false); - sprintf(scr_err,"ERROR %d",i); + set_err(i); gui.MessEffective(MESSAGE_MENU_ERROR); } else{ @@ -526,14 +647,14 @@ void scr_TopMenu(bool formatted,bool inserted,bool exfm,bool bkupins,int err) if (inserted == false) { - strcpy(scr_err,"Please Insert Card"); + set_err(S_InsertCard); gui.MessEffective(MESSAGE_MENU_CAUTION); }else{ - if (err & SDATA_ERRPUT_MEDIA) i = ERC_MEDIA + ERC_DEV_CARD;//Z[uf[^}EgłȂ - else if (bkupins == false) i = ERC_DEVICE + ERC_DEV_OUT;//ofoCX - else i = ERC_DEV_OTHER;//s - sprintf(scr_err,"ERROR %d",i); + if (err & SDATA_ERRPUT_MEDIA) i = ERC_MEDIA + TGT_CARD;//Z[uf[^}EgłȂ + else if (bkupins == false) i = ERC_DEVICE + TGT_SD;//ofoCX(SD̂ݔ) + else i = ERC_EXEC;//sG[AtOݒ~XH + set_err(i); gui.MessEffective(MESSAGE_MENU_ERROR); } } @@ -574,7 +695,7 @@ void scr_Backup() { scr_evnt = EVNT_NONE; gui.PanelLineStyle(PANEL_BKUP,COLOR_SKY); - gui.MessStr(MESSAGE_TITLE," --- Backup Card Savedata ---"); + gui.MessStr(MESSAGE_TITLE,S_TitleBkup); gui.PanelEffective(PANEL_TITLE); ClearBkupMess(); gui.Draw(); @@ -593,7 +714,7 @@ void scr_Restore() { scr_evnt = EVNT_NONE; gui.PanelLineStyle(PANEL_BKUP,COLOR_PARPL); - gui.MessStr(MESSAGE_TITLE,"--- Restore Card Savedata ---"); + gui.MessStr(MESSAGE_TITLE,S_TitleRestore); gui.PanelEffective(PANEL_TITLE); ClearBkupMess();//backupƓplg gui.Draw(); @@ -608,7 +729,7 @@ void scr_RestoreYesNo() } -void scr_Status(char *s,eColor col) +void scr_Status(tChar *s,eColor col) { gui.MessCol(MESSAGE_STATUS,col); gui.MessStr(MESSAGE_STATUS,s); @@ -616,7 +737,7 @@ void scr_Status(char *s,eColor col) gui.Draw(); } -void scr_ResultQuit(char *s,eColor col) +void scr_ResultQuit(tChar *s,eColor col) { gui.MessCol(MESSAGE_RESULT,col); gui.MessStr(MESSAGE_RESULT,s); @@ -635,11 +756,15 @@ void scr_InsExitQuit() } // JEg/MAX \ -char str_Counter[128]; -char str_Counter2[128]; +tChar str_Counter[32]; +tChar str_Counter2[32]; void scr_CountPerMax(int ct,int max) { +#ifdef USE_WCHAR + swprintf(str_Counter,30,L"%d / %d",ct,max); +#else sprintf(str_Counter,"%d / %d",ct,max); +#endif gui.MessStr(MESSAGE_COUNT,str_Counter); gui.MessEffective(MESSAGE_COUNT); gui.Draw(); @@ -648,18 +773,29 @@ void scr_CountPerMax(int ct,int max) //Q[Wtotal void scr_CountPerMax2(int ct,int max,int total) { + int i,lv; if (total == -1) str_Counter2[0]=0; else if (total != 0){ // gui.MessCol(MESSAGE_COUNT2,COLOR_WHITE); +#ifdef USE_WCHAR + swprintf(str_Counter2,30,L"total size %d",total); + }else{ +// gui.MessCol(MESSAGE_COUNT2,COLOR_YELLO); + lv = ct/(max/25); + for (i =0;i'; + while ( i < 25 )str_Counter2[i++] = L'|'; + str_Counter2[i] = 0; + } +#else sprintf(str_Counter2,"total size %d",total); }else{ // gui.MessCol(MESSAGE_COUNT2,COLOR_YELLO); - int i; - int lv = ct/(max/25); + lv = ct/(max/25); for (i =0;i'; while ( i < 25 )str_Counter2[i++] = '|'; str_Counter2[i] = 0; } +#endif //sprintf(str_Counter2,"%d / %d",ct,max); gui.MessStr(MESSAGE_COUNT2,str_Counter2); gui.MessEffective(MESSAGE_COUNT2); @@ -667,7 +803,7 @@ void scr_CountPerMax2(int ct,int max,int total) } -void scr_MessOnCount2(char *str) +void scr_MessOnCount2(tChar *str) { // gui.MessCol(MESSAGE_COUNT2,COLOR_YELLO); gui.MessStr(MESSAGE_COUNT2,str); @@ -677,7 +813,7 @@ void scr_MessOnCount2(char *str) //smF -void scr_ConfirmDbg(char *str) +void scr_ConfirmDbg(tChar *str) { scr_evnt = EVNT_NONE; gui.MessStr(MESSAGE_CONFIRM_TITLE,str); @@ -717,23 +853,6 @@ void scr_SuccessQuitDbg(tColStr **s) } -//fobOO -void scr_DgbLog(cStrLst *p) -{ - gui.PanelLineStyle(PANEL_DBGLOG,COLOR_BLUE); - - for (int i=0;igetpos()+1;i++)gui.MemoStr(MEMO_DBGLOG,p->line(i),i); - - gui.PanelEffective(PANEL_DBGLOG); - gui.Draw(); -} - - - -int ScrDbgLogGetMax() -{ - return LOG_MAX; -} void scr_Draw() diff --git a/trunk/CardSaveData/Mover/body/source/screen/screen.h b/trunk/CardSaveData/Mover/body/source/screen/screen.h index 081be50..43b892e 100644 --- a/trunk/CardSaveData/Mover/body/source/screen/screen.h +++ b/trunk/CardSaveData/Mover/body/source/screen/screen.h @@ -23,68 +23,26 @@ enum { EVNT_SEL_WRITE, EVNT_SEL_END, EVNT_ERROR, - EVNT_FATAL + EVNT_FATAL, + EVNT_INEX //}̓CŃZbg }; typedef struct{ - char *str; + tChar *str; eColor color; u8 pad[3]; }tColStr; -#define LST_MAX 30 -#define LST_LENGTH 128 -class cStrLst { -private: - int pos; - int buttom; - char str[LST_MAX][LST_LENGTH]; -public: - cStrLst():pos(0){}; - void add(char *p){ - if (pos>=LST_MAX)return; - //char *s = &str[pos][0]; - int i; - if (pos == buttom) - { - i =0; - while(i < buttom){ strcpy(str[i],str[i+1]);i++;} - }else pos++; - i=0; - while(i < (LST_LENGTH-1)){ //I[o[[h΍ - if (p[i]!=0){ - str[pos][i] = p[i]; - i++; - }else break; - } - str[pos][i] = 0; - //strcpy(str[pos],p); - //for (i =0;i=LST_MAX))return false; - buttom = btm; - return true; - } -}; - - //Topj[ł̃G[\p̃tO -//bit`FbN -#define SDATA_ERRPUT_PCODE 1 -#define SDATA_ERRPUT_MEDIA 2 -#define SDATA_ERRPUT_VERIFI 4 +//bitʒûnq +#define SDATA_ERRPUT_PCODE (1 << 0) +#define SDATA_ERRPUT_MEDIA (1 << 1) +#define SDATA_ERRPUT_VERIFI (1 << 2) +//foO[h̕\ +//#define SDATA_ERRPUT_DEBUG (1>>3) - -bool ScrInitialize(uptr heap,u32 size); +bool ScrInitialize(uptr heap,u32 size,bool jp,bool deb); void ScrFinalize(); void ScrClr(); int ScrDbgLogGetMax(); @@ -94,20 +52,19 @@ void scr_TopMenu(bool formatted,bool inserted,bool exfm,bool sdins,int err); void scr_ErrorQuitDbg(tColStr **s); void scr_SuccessQuitDbg(tColStr **s); void scr_ConfirmDbg(char *str); -void scr_DgbLog(cStrLst *p); void scr_BackupYesNo(); void scr_Backup(); void scr_RestoreYesNo(); void scr_Restore(); void scr_InsExitQuit(); -void scr_Status(char *s,eColor col); -void scr_ResultQuit(char *s,eColor col); +void scr_Status(tChar *s,eColor col); +void scr_ResultQuit(tChar *s,eColor col); void scr_CountPerMax(int ct,int max); void scr_CountPerMax2(int ct,int max,int total); void scr_PrdCode(char *s); void scr_PrdCodeEx(char *s); void scr_DelConf(); -void scr_MessOnCount2(char *str); +void scr_MessOnCount2(tChar *str); void scr_Draw(); void scr_GetEvnt(); diff --git a/trunk/CardSaveData/Mover/body/ver.h b/trunk/CardSaveData/Mover/body/ver.h index 78aaf06..9c6064f 100644 --- a/trunk/CardSaveData/Mover/body/ver.h +++ b/trunk/CardSaveData/Mover/body/ver.h @@ -16,7 +16,10 @@ #ifndef VER_H_ #define VER_H_ -#define VERSION 1.10 - +#define VERSION 1.2 +// ver = 0 ならテキストの方を表示 +//#define VERSION 0.0 +#define VERSION_TXT "TEST ONLY" +#define VERSION_TXT_W L"TEST ONLY" #endif diff --git a/trunk/CardSaveData/Mover/release.txt b/trunk/CardSaveData/Mover/release.txt index cf32e59..affd3ac 100644 --- a/trunk/CardSaveData/Mover/release.txt +++ b/trunk/CardSaveData/Mover/release.txt @@ -29,6 +29,11 @@ CUP [Histry] #\ver@}X^Over # ύXe +v1.20 - body:̃fBNg쐬ȂsC + bZ[W{\ + +v1.10 impFNOAŃC|[goȂ̂Ō`FbN폜 + c[{̂̕ύXȂA}X^Oi͔ѓ v1.10 - Remaster 2.0.12 body:[gfBNg̍ŏȂsC(`Q[eȂ) t@C̊mۃTCY𒴂ɃG[\