mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
678 lines
22 KiB
C++
678 lines
22 KiB
C++
/*---------------------------------------------------------------------------*
|
||
Project: Horizon
|
||
File: main.cpp
|
||
|
||
Copyright (C)2010 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 <wchar.h>
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
#include <stdio.h>
|
||
#include <nn.h>
|
||
//#include <nn/os.h>
|
||
#include <nn/applet.h>
|
||
#include <nn/ndm.h>
|
||
//#include <nn/ndm/ndm_DebugControl.h>
|
||
#include <nn/fs/ctr/mpcore/fs_FileSystemBasePrivate.h>
|
||
#include <nn/fs/fs_Parameters.h>
|
||
#include "../../../common/savefile/savefile.h"
|
||
#include "../../../common/savefile/savedata.h"
|
||
#include "../../../common/savefile/sdmcwo.h"
|
||
#include "../../../common/common.h"
|
||
#include "./screen/screen.h"
|
||
|
||
|
||
nn::fnd::ExpHeap appHeap;
|
||
uptr heapForGx;
|
||
|
||
myResult errRes;
|
||
|
||
SaveData savedata;
|
||
nn::os::LightEvent ejectEvnt(false);
|
||
nn::os::LightEvent insEvnt(false);
|
||
Sdmcwo exsave;
|
||
nn::os::LightEvent ejectEvntSd(false);
|
||
nn::os::LightEvent insEvntSd(false);
|
||
|
||
//バックアップの状態
|
||
bool Active,Formatted;
|
||
bool exActive;
|
||
tArcInfo arcInfo,arcInfo_ex;//アーカイブ情報
|
||
tDcList dcList,dcList2;//ディレクトリ格納
|
||
|
||
//Top画面エラー表示
|
||
int tmerr;
|
||
|
||
//結果
|
||
typedef enum {
|
||
SUCCESS
|
||
,ERROR
|
||
,CANCEL
|
||
,INSEXIT
|
||
}RetCode;
|
||
|
||
//挿抜イベント時に設定
|
||
typedef enum {
|
||
InEx_None
|
||
,InEx_InsCard
|
||
,InEx_EjcCard
|
||
,InEx_InsSd
|
||
,InEx_EjcSd
|
||
}tIsInsEject;
|
||
|
||
tIsInsEject isInsEject;
|
||
|
||
extern u8 scr_evnt;
|
||
void WaitUI();
|
||
void PutError(TgtDev dev,int cd=0);
|
||
bool CheckInsExit();
|
||
|
||
|
||
//終了処理
|
||
void endfunc()
|
||
{
|
||
|
||
nn::fs::UnregisterCardEjectedEvent();
|
||
nn::fs::UnregisterCardInsertedEvent();
|
||
ejectEvnt.Finalize();
|
||
insEvnt.Finalize();
|
||
nn::fs::UnregisterSdmcEjectedEvent();
|
||
nn::fs::UnregisterSdmcInsertedEvent();
|
||
ejectEvntSd.Finalize();
|
||
insEvntSd.Finalize();
|
||
|
||
savedata.Finalize();
|
||
exsave.Finalize();
|
||
|
||
ScrFinalize();
|
||
|
||
}
|
||
|
||
//エラー停止
|
||
void failstop()
|
||
{
|
||
NN_LOG("fail %d,stop\n",errRes);
|
||
finish();
|
||
}
|
||
|
||
|
||
|
||
wchar_t file_pathw[MAX_PATH_LENGTH];
|
||
wchar_t file_pathw2[MAX_PATH_LENGTH];
|
||
char file_path[MAX_PATH_LENGTH];
|
||
//カゲマイ報告の速度実測でFSで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)
|
||
|
||
//エラー表示
|
||
wchar_t sts[64];
|
||
void PutError(TgtDev dev,int cd)
|
||
{
|
||
nn::Result res;
|
||
switch (dev)
|
||
{
|
||
case TGT_CARD: res = savedata.LastNnResult;break;
|
||
case TGT_SD: res = exsave.LastNnResult;break;
|
||
}
|
||
GetErrorStr(dev,res,cd,(tChar*)sts);
|
||
scr_Status(sts,COLOR_RED);
|
||
}
|
||
|
||
//デバグ用ウエイト
|
||
void waitSec(int sec)
|
||
{
|
||
nn::os::Tick tm,tn;
|
||
tm = nn::os::Tick::GetSystemCurrent();
|
||
while(1)
|
||
{
|
||
tn = nn::os::Tick::GetSystemCurrent()-tm;
|
||
if(tn.ToTimeSpan().GetSeconds() > sec)break;
|
||
}
|
||
}
|
||
|
||
|
||
wchar_t mes[128];
|
||
//保存先のディレクトリ削除
|
||
bool TryDeleteDir()
|
||
{
|
||
if(exsave.Delete())return true;
|
||
//フォルダ削除に失敗したら手削除
|
||
wcscpy(mes,L"Illegal folder [ ");
|
||
wcscat(mes,exsave.DirName);//フォルダ名
|
||
wcscat(mes,L" ]");
|
||
//scr_Status(sts,COLOR_RED);
|
||
scr_MessOnCount(mes);
|
||
return false;
|
||
}
|
||
|
||
//情報ファイルの占有サイズ計算
|
||
//vnfは発生見込み低い上、面倒なので作成時エラー任せ
|
||
size_t GetSysSpace(size_t cl)
|
||
{
|
||
size_t sz;
|
||
int sn;
|
||
sn = sizeof(FormatParameters) / cl;
|
||
if ((sizeof(FormatParameters) % cl) > 0)sn++;
|
||
sz = sn*cl;
|
||
sn = sizeof(AdditionalInfo) / cl;
|
||
if ((sizeof(AdditionalInfo) % cl) > 0)sn++;
|
||
sz += sn*cl;
|
||
return sz;
|
||
}
|
||
|
||
//---------------------------------------------------------------------- CARD to SD
|
||
RetCode Card2Sd()
|
||
{
|
||
myResult res;
|
||
int ct=0,msize,rsize;
|
||
s64 total=0,free_size;
|
||
|
||
scr_BackupYesNo();//実行確認
|
||
WaitUI();//入力待ち
|
||
if(isInsEject != InEx_None )return INSEXIT;//挿抜による中断
|
||
if (scr_evnt != EVNT_YES)return CANCEL;//キャンセル
|
||
scr_Backup();//画面表示
|
||
|
||
|
||
//保存先ディレクトリ作成
|
||
//ディレクトリ作成時にクラスタサイズ、空き容量を取得
|
||
scr_Status(L"Create Dir to SD",COLOR_YELLO);
|
||
if (exsave.Create() == false)
|
||
{
|
||
PutError(TGT_SD);
|
||
return ERROR;
|
||
}
|
||
|
||
//セーブデータのマウント
|
||
scr_Status(L"Mount SaveData",COLOR_YELLO);
|
||
res = savedata.Mount();
|
||
if(res != RESULT_OK){
|
||
exsave.Unmount();
|
||
TryDeleteDir();
|
||
PutError(TGT_CARD);
|
||
return ERROR;
|
||
}
|
||
|
||
//ディレクトリ情報
|
||
scr_Status(L"Get Directry",COLOR_YELLO);
|
||
if(savedata.GetInfo(&arcInfo,&dcList,exsave.ClasterSize)==false)
|
||
{
|
||
savedata.Unmount();
|
||
exsave.Unmount();
|
||
PutError(TGT_CARD);
|
||
TryDeleteDir();
|
||
return ERROR;
|
||
}
|
||
strcpy(arcInfo.Pcode,savedata.PrdCode);
|
||
|
||
if ((arcInfo.total + GetSysSpace(exsave.ClasterSize)) > exsave.FreeSize)
|
||
{//容量不足
|
||
savedata.Unmount();
|
||
exsave.Unmount();
|
||
PutError(TGT_SD,ERC_NOSPACE);
|
||
TryDeleteDir();
|
||
return ERROR;
|
||
}
|
||
|
||
//カウント異常
|
||
if (arcInfo.FileCount > arcInfo.FileEntry){
|
||
savedata.Unmount();
|
||
exsave.Unmount();
|
||
PutError(TGT_NONE,ERC_EXEC);
|
||
TryDeleteDir();
|
||
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;
|
||
}
|
||
|
||
bool mkdir;
|
||
//ディレクトリ作成
|
||
//空ディレクトリもチェックするゲームあるので(マリカ7)
|
||
//ファイルの存在と関係なく作成
|
||
if(dcList.num >0)
|
||
{
|
||
int i,rev=0;
|
||
for (i=0;i<dcList.num;i++)
|
||
{
|
||
exsave.GetRootPath(file_pathw2);//格納先ルート取得
|
||
ChainPath(file_pathw2,&dcList.name[i][6]);//"save:/"の次から
|
||
if (CheckPath(file_pathw2)==false)//パス名チェック..エラーにならず化けるもの
|
||
{
|
||
if (exsave.OpenVnfW(file_pathw2,0)==false)//ディレクトリ退避
|
||
{
|
||
res = RESULT_FAIL_OPENW;
|
||
}else exsave.CloseW();
|
||
}else{
|
||
while(1){
|
||
if (exsave.MakeDir(file_pathw2,&mkdir)==false)
|
||
{
|
||
if(mkdir==false){//作成失敗
|
||
if (exsave.OpenVnfW(file_pathw2,0)==false)//ディレクトリ退避
|
||
{
|
||
res = RESULT_FAIL_OPENW;
|
||
}else exsave.CloseW();
|
||
break;
|
||
}
|
||
}else break;
|
||
}
|
||
}
|
||
if (res != RESULT_OK)break;
|
||
rev^=1;
|
||
//if (rev & 1)scr_Status(MessTxt(MT_CrtDir1),COLOR_YELLO);
|
||
//else scr_Status(MessTxt(MT_CrtDir2),COLOR_YELLO);
|
||
if (rev & 1)scr_Status(L"Create Directry -",COLOR_YELLO);
|
||
else scr_Status(L"Create Directry |",COLOR_YELLO);
|
||
}
|
||
if (res != RESULT_OK)
|
||
{
|
||
exsave.Unmount();
|
||
savedata.Unmount();
|
||
PutError(TGT_CARD);
|
||
return ERROR;
|
||
}
|
||
}
|
||
|
||
if (arcInfo.FileCount == 0)//ファイルが無い
|
||
{
|
||
scr_Status(L"no files",COLOR_YELLO);
|
||
savedata.Unmount();
|
||
exsave.Unmount();
|
||
TryDeleteDir();
|
||
return SUCCESS;//何もしない
|
||
}else{
|
||
//ファイルコピー
|
||
scr_Status(L"file copying",COLOR_SKY);
|
||
savedata.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){
|
||
PutError(TGT_CARD,ERC_EXEC);
|
||
break;
|
||
}
|
||
if (res == RESULT_PATH_LENGTH_OVER){
|
||
PutError(TGT_CARD,ERC_EXEC);
|
||
break;
|
||
}
|
||
res = RESULT_FAIL_OPEN;
|
||
break;
|
||
}
|
||
if (file_pathw[0] == 0)break;//ルートなら終了
|
||
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(CheckInsExit())break;//挿抜による中断
|
||
|
||
//SDで支障あるパス名の場合は別ファイルに格納する
|
||
exsave.GetRootPath(file_pathw2);//格納先ルート取得
|
||
ChainPath(file_pathw2,file_pathw);//実パス名に変換
|
||
if (CheckPath(file_pathw2)==false)//パス名チェック..エラーにならず化けるもの
|
||
{
|
||
if (exsave.OpenVnfW(file_pathw,fsize)==false)//退避ファイル
|
||
{
|
||
res = RESULT_FAIL_OPENW;
|
||
break;
|
||
}
|
||
}else{
|
||
//int rev;
|
||
while(1){
|
||
if (exsave.OpenC(file_pathw,fsize,&mkdir)==false)
|
||
{
|
||
if(mkdir)//ディレクトリ作成のみ
|
||
{//ディレクトリは作成済みなので作成されたらエラー
|
||
res = RESULT_FAIL_OPENW;
|
||
break;
|
||
//rev++;
|
||
//if (rev & 1)scr_MessOnCount2(L"Create Directry -");
|
||
//else scr_MessOnCount2(L"Create Directry |");
|
||
}else{
|
||
NN_LOG("%d\n",exsave.LastNnResult.GetDescription());
|
||
if(nn::fs::ResultInvalidArgument::Includes(exsave.LastNnResult))
|
||
{//パス名エラー
|
||
if (exsave.OpenVnfW(file_pathw,fsize)==false)//退避ファイル
|
||
{
|
||
res = RESULT_FAIL_OPENW;
|
||
}
|
||
break;
|
||
}else{
|
||
res = RESULT_FAIL_OPENW;
|
||
break;
|
||
}
|
||
}
|
||
}else break;
|
||
}
|
||
if (res != RESULT_OK)break;
|
||
}
|
||
|
||
msize=fsize;
|
||
while(fsize)
|
||
{
|
||
if(msize > FILEBUFF_SIZE * 2){//サイズが大きい場合にゲージ表示
|
||
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(savedata.Read(fileBuffer,rsize) != rsize )//リード
|
||
{
|
||
//中身のデータが作成サイズに満たない場合に検証エラーとなる対策
|
||
//読めないブロックは置き換える
|
||
//検証は512単位でされるので読めてるとこまで置き換えないよう
|
||
//リードサイズは512にしておく
|
||
if(nn::fs::ResultVerificationFailed::Includes(savedata.LastNnResult))
|
||
{
|
||
for (int i = 0; i < rsize; i++)
|
||
{
|
||
fileBuffer[i] = 0;//0埋め
|
||
}
|
||
}else{
|
||
res = RESULT_FAIL_READ;
|
||
break;
|
||
}
|
||
}
|
||
if(CheckInsExit())break;//挿抜による中断
|
||
if(exsave.Write(fileBuffer,rsize) != rsize )//ライト
|
||
{
|
||
res = RESULT_FAIL_WRITE;
|
||
if(exsave.LastNnResult.IsSuccess()){//容量不足でオープンすると書けるとこまで書いてエラーとならない
|
||
if (exsave.GetFreeSize(&free_size)){
|
||
if (free_size == 0 ) res = RESULT_DEVICE_FULL;//空き無し
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
savedata.Close();
|
||
exsave.CloseW();
|
||
if(isInsEject != InEx_None )break;//挿抜による中断
|
||
ct++;
|
||
}
|
||
savedata.Close();
|
||
exsave.CloseW();
|
||
}
|
||
savedata.Unmount();
|
||
exsave.Unmount();
|
||
|
||
//結果
|
||
scr_CountPerMax(ct,arcInfo.FileCount);
|
||
scr_CountPerMax2(0,0,-1);
|
||
if(isInsEject != InEx_None )
|
||
{//挿抜による中断
|
||
if(TryDeleteDir())return INSEXIT;
|
||
return ERROR;//デリート失敗表示
|
||
}else{
|
||
if (res == RESULT_OK)
|
||
{
|
||
if (ct == arcInfo.FileCount)//ファイル数一致?
|
||
{
|
||
if(exsave.WriteSys(&arcInfo))//フォーマット情報
|
||
{
|
||
//成功
|
||
wcscpy(sts,L"output folder [ ");
|
||
wcscat(sts,exsave.DirName);//保存先
|
||
wcscat(sts,L" ]");
|
||
scr_Status(sts,COLOR_WHITE);
|
||
|
||
scr_CountPerMax(ct,arcInfo.FileCount);//ファイル数
|
||
scr_CountPerMax2(0,0,total);//総サイズ
|
||
return SUCCESS;
|
||
}
|
||
res = RESULT_FAIL_WRITE;
|
||
if(exsave.LastNnResult.IsSuccess()){//容量不足でオープンすると書けるとこまで書いてエラーとならない
|
||
if (exsave.GetFreeSize(&free_size)){
|
||
if (free_size == 0 ) res = RESULT_DEVICE_FULL;//空き無し
|
||
}
|
||
}
|
||
}else{
|
||
NN_LOG("file count error\n");
|
||
res = RESULT_FAIL;
|
||
}
|
||
}
|
||
//失敗
|
||
if (res == RESULT_DEVICE_FULL)PutError(TGT_SD,ERC_NOSPACE);
|
||
else if ((res == RESULT_FAIL_WRITE) || (res== RESULT_FAIL_OPENW)) PutError(TGT_SD);
|
||
else if ((res == RESULT_FAIL_READ) || (res== RESULT_FAIL_OPEN)) PutError(TGT_CARD);
|
||
else if (res == RESULT_FAIL_VERIFI) PutError(TGT_SD,ERC_VERIFI);
|
||
else PutError(TGT_NONE,ERC_EXEC);
|
||
TryDeleteDir();//ディレクトリごと削除
|
||
}
|
||
return ERROR;
|
||
|
||
}
|
||
|
||
|
||
//--------------------------------------------------------------- セーブデータの情報取得
|
||
//呼ぶ前に tmerr のクリアを忘れない事
|
||
void CheckSaveDataState()
|
||
{
|
||
Formatted = false;
|
||
Active = false;
|
||
|
||
if (savedata.GetPrdCode())
|
||
{
|
||
Active = true;//カードあり
|
||
if ( savedata.IsExist())//セーブ確認
|
||
{
|
||
Formatted=true;
|
||
}else{
|
||
tmerr |= SDATA_ERRPUT_MEDIA;
|
||
}
|
||
}
|
||
scr_PrdCode(savedata.PrdCode);
|
||
}
|
||
|
||
//エクスポート先の状態確認
|
||
void CheckExSaveState()
|
||
{
|
||
exActive = nn::fs::IsSdmcInserted() && nn::fs::IsSdmcWritable();
|
||
}
|
||
|
||
//------------------------------------------------------------ 挿抜チェック
|
||
bool CheckInsExit()
|
||
{
|
||
|
||
if (ejectEvnt.TryWait()){
|
||
//CARD抜け
|
||
CheckSaveDataState();
|
||
isInsEject = InEx_EjcCard;
|
||
return true;
|
||
}
|
||
if (insEvnt.TryWait()){
|
||
//CARD挿入
|
||
CheckSaveDataState();
|
||
isInsEject = InEx_InsCard;
|
||
return true;
|
||
}
|
||
if (ejectEvntSd.TryWait()){
|
||
//SD抜け
|
||
CheckExSaveState();
|
||
isInsEject = InEx_EjcSd;
|
||
return true;
|
||
}
|
||
if (insEvntSd.TryWait()){
|
||
//SD挿入
|
||
CheckExSaveState();
|
||
isInsEject = InEx_InsSd;
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
|
||
//---------------------------------------------------------------- 入力待ち
|
||
void WaitUI()
|
||
{
|
||
tmerr = 0;
|
||
scr_Draw();//画面更新
|
||
scr_evnt = EVNT_NONE;
|
||
while(scr_evnt == EVNT_NONE)
|
||
{
|
||
nn::os::Thread::Yield();//スレッド実行
|
||
//scr_GetEvnt();//入力イベント
|
||
|
||
CheckSysBreak();//中断処理
|
||
|
||
//挿抜を検知したら中断して抜ける
|
||
//トップ以外ではトップメニューへ戻るようする
|
||
if (CheckInsExit())return;
|
||
}
|
||
ScrClr();//画面消去
|
||
nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(500));//チャタ対策
|
||
}
|
||
|
||
|
||
//---------------------- main loop --------------------------
|
||
void nnMain()
|
||
{
|
||
|
||
RetCode retc;
|
||
isInsEject = InEx_None;
|
||
|
||
//NN_LOG("Start\n");
|
||
nn::os::Initialize();
|
||
nn::fs::Initialize();
|
||
|
||
//DEA-SUPにて推奨のフリーズ暫定対策:無線デーモンを停止 (2011.3.1 現在)
|
||
//スリープ中は止まらないので、本体スイッチ切るのが確実
|
||
//SDK2.2以降で対策不要となったが、点滅が鬱陶しいので残しとく
|
||
nn::ndm::Initialize();
|
||
nn::ndm::SuspendScheduler();
|
||
|
||
//中断処理の準備
|
||
InitSysBreak((uptr)endfunc);
|
||
// グラフィックスライブラリの初期化は、以降で行わなければならない
|
||
// 他、アプリケーションの初期化処理
|
||
|
||
nn::applet::DisableSleep();//スリープ非対応
|
||
|
||
//Heap
|
||
appHeap.Initialize(nn::os::GetDeviceMemoryAddress(),
|
||
nn::os::GetDeviceMemorySize(), nn::os::ALLOCATE_OPTION_LINEAR);
|
||
const u32 GxHeapSize = 0x800000;
|
||
heapForGx = reinterpret_cast<uptr>(appHeap.Allocate(GxHeapSize));
|
||
//画面初期化
|
||
if (ScrInitialize(heapForGx,GxHeapSize) == false)failstop();
|
||
ejectEvnt.ClearSignal();
|
||
insEvnt.ClearSignal();
|
||
nn::fs::RegisterCardEjectedEvent(&ejectEvnt);
|
||
nn::fs::RegisterCardInsertedEvent(&insEvnt);
|
||
ejectEvntSd.ClearSignal();
|
||
insEvntSd.ClearSignal();
|
||
nn::fs::RegisterSdmcEjectedEvent(&ejectEvntSd);
|
||
nn::fs::RegisterSdmcInsertedEvent(&insEvntSd);
|
||
|
||
// スリープ要求に対する返答を有効にする
|
||
// また、蓋の状態チェックを行い蓋が閉じられているならスリープ要求が発生する
|
||
//nn::applet::EnableSleep(true);
|
||
|
||
extern u8 scr_evnt;
|
||
while(1)
|
||
{
|
||
tmerr = 0;
|
||
CheckSaveDataState(); //セーブデータの状態取得
|
||
CheckExSaveState(); //SD挿入状態
|
||
scr_TopMenu(Formatted,Active,exActive,tmerr);
|
||
|
||
WaitUI();//入力待ち
|
||
if (isInsEject != InEx_None){
|
||
ScrClr();//画面消去
|
||
isInsEject= InEx_None;
|
||
}else
|
||
switch(scr_evnt)
|
||
{
|
||
case EVNT_SEL_READ://リード
|
||
NN_LOG("select read\n");
|
||
retc = Card2Sd();
|
||
switch (retc)
|
||
{
|
||
case SUCCESS:
|
||
//CheckExSaveState(); //状態の更新
|
||
scr_ResultQuit(L"Success",COLOR_GREEN);//成功とQuitボタン
|
||
break;
|
||
case INSEXIT:
|
||
//scr_InsExitQuit();//挿抜検知表示 & Quit
|
||
ScrClr();//画面消去
|
||
scr_Backup();
|
||
if (isInsEject == InEx_EjcCard)PutError(TGT_CARD,ERC_DEVICE);
|
||
else if (isInsEject == InEx_EjcSd)PutError(TGT_SD,ERC_DEVICE);
|
||
else PutError(TGT_NONE);
|
||
scr_ResultQuit(L"Break",COLOR_RED);//エラーとQuitボタン
|
||
break;
|
||
case CANCEL:break;
|
||
default://errors
|
||
scr_ResultQuit(L"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_PUSH_LEFT_X:// ------------------------------------- LEFT + X
|
||
//バックアップ削除
|
||
scr_DelConf();//実行確認
|
||
WaitUI();
|
||
if (scr_evnt != EVNT_YES)break;
|
||
exsave.DeleteAll();//全削除
|
||
//CheckExSaveState(); //状態更新
|
||
break;
|
||
|
||
}
|
||
}//while()
|
||
|
||
}
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
End of file
|
||
*---------------------------------------------------------------------------*/
|
||
|