mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@250 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
0299ada588
commit
0b5e60b37e
@ -23,7 +23,7 @@ SUPPORTED_TARGETS = CTR-*.Process.MPCore.*
|
|||||||
|
|
||||||
SOURCES[] =
|
SOURCES[] =
|
||||||
./source/main.cpp
|
./source/main.cpp
|
||||||
./source/test_data.cpp
|
../../common/test_data.cpp
|
||||||
../../common/shfnt.cpp
|
../../common/shfnt.cpp
|
||||||
../../common/sleep.cpp
|
../../common/sleep.cpp
|
||||||
../../common/common.cpp
|
../../common/common.cpp
|
||||||
|
|||||||
Binary file not shown.
@ -1,673 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*
|
|
||||||
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/hid.h>
|
|
||||||
#include "demo.h"
|
|
||||||
|
|
||||||
nn::Result res;
|
|
||||||
|
|
||||||
nn::fs::FileOutputStream fout;
|
|
||||||
nn::fs::FileInputStream fin;
|
|
||||||
|
|
||||||
nn::fs::Directory dc[256];
|
|
||||||
|
|
||||||
wchar_t file_pathw[1024];
|
|
||||||
char file_path[1024];
|
|
||||||
char file_path2[1024];
|
|
||||||
char src_buff[1024*1024];
|
|
||||||
char get_buff[1024*1024];
|
|
||||||
char str[512];
|
|
||||||
|
|
||||||
|
|
||||||
extern demo::RenderSystemDrawing s_RenderSystem;
|
|
||||||
|
|
||||||
//終了処理
|
|
||||||
extern void finish(void);
|
|
||||||
extern u32 WaitKey(u32 mask);
|
|
||||||
|
|
||||||
extern void setColor(f32 r,f32 g,f32 b,f32 a);
|
|
||||||
extern void drawText(u16 x,u16 y,char *s);
|
|
||||||
void drawText(u16 x,u16 y,char *s,int v)
|
|
||||||
{
|
|
||||||
sprintf(str,s,v);
|
|
||||||
drawText( x,y,str);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------- テストパターン
|
|
||||||
void make_pattern()
|
|
||||||
{
|
|
||||||
int i,j;
|
|
||||||
j=0;
|
|
||||||
for (i=0;i<1024*1024;i++){
|
|
||||||
src_buff[i] = j+i;
|
|
||||||
if (i & 0x100)j++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//TEST ライト
|
|
||||||
s32 size;
|
|
||||||
#define SIZE_TEST1 421888
|
|
||||||
//#define SIZE_TEST1 244736 //dup
|
|
||||||
bool Test1_W()
|
|
||||||
{
|
|
||||||
int total,size2;
|
|
||||||
|
|
||||||
res = nn::fs::FormatSaveData(1,0,false);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"format Fail");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res =nn::fs::MountSaveData();
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"Mount Fail");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res = nn::fs::TryCreateFile(L"data:/test1.bin",SIZE_TEST1);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"Create Fail");
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res = fout.TryInitialize(L"data:/test1.bin",true);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"open Fail");
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
total =0;
|
|
||||||
size2 = 512;
|
|
||||||
//size2 = 4096;
|
|
||||||
//size2 = SIZE_TEST1;
|
|
||||||
while(1){
|
|
||||||
res = fout.TryWrite( &size,&src_buff[total],size2);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"write Fail");
|
|
||||||
fout.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
total += size;
|
|
||||||
sprintf(str,"size %d",total);
|
|
||||||
s_RenderSystem.Clear();
|
|
||||||
drawText(10,80,str);
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
//if (size<512)break;
|
|
||||||
if (total >= SIZE_TEST1)break;
|
|
||||||
if ((SIZE_TEST1 - total) < 512)size2 = SIZE_TEST1 - total ;
|
|
||||||
}
|
|
||||||
fout.Finalize();
|
|
||||||
nn::fs::CommitSaveData();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
NN_LOG("total %d",total);
|
|
||||||
drawText(10,100,"end");
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
nngxWaitVSync(NN_GX_DISPLAY0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//ベリファイ
|
|
||||||
bool Test1_V()
|
|
||||||
{
|
|
||||||
int i,total;
|
|
||||||
|
|
||||||
res = fin.TryInitialize(L"data:/test1.bin");
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"open Fail");
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
total =0;
|
|
||||||
while(1){
|
|
||||||
res = fin.TryRead( &size,&get_buff[total],512);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"read Fail");
|
|
||||||
fin.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//if (size == 0)break;
|
|
||||||
for (i=0;i<size;i++) if (src_buff[total+i] != get_buff[total+i])
|
|
||||||
{
|
|
||||||
drawText(8,100,"verifi Fail at %d",total+i);
|
|
||||||
fin.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
if (total >= SIZE_TEST1)break;
|
|
||||||
|
|
||||||
total += size;
|
|
||||||
s_RenderSystem.Clear();
|
|
||||||
sprintf(str,"now %d",total);
|
|
||||||
drawText(10,80,str);
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
if (size<512)break;
|
|
||||||
}
|
|
||||||
fout.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
drawText(10,100,"end");
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
nngxWaitVSync(NN_GX_DISPLAY0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//ファイル数
|
|
||||||
bool Test2_W(int n)
|
|
||||||
{
|
|
||||||
int total,size2;
|
|
||||||
|
|
||||||
res = nn::fs::FormatSaveData(680,1,false);//dupなしファイル680
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"format Fail");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res =nn::fs::MountSaveData();
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"Mount Fail");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
total =0;
|
|
||||||
int num = 0;
|
|
||||||
size2 = 512;
|
|
||||||
while(1){
|
|
||||||
sprintf(file_path,"data:/test%d.bin",num);
|
|
||||||
// res = nn::fs::TryCreateFile(L"data:/test2.bin",SIZE_TEST1);
|
|
||||||
// if (res.IsFailure()){
|
|
||||||
// drawText(8,100,"Create Fail");
|
|
||||||
// nn::fs::Unmount("data:");
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
res = fout.TryInitialize(file_path,true);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"open Fail");
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res = fout.TryWrite( &size,&src_buff[total],size2);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"write Fail");
|
|
||||||
fout.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
fout.Finalize();
|
|
||||||
total += size;
|
|
||||||
num++;
|
|
||||||
sprintf(str,"size %d , num %d",total,num);
|
|
||||||
s_RenderSystem.Clear();
|
|
||||||
drawText(10,80,str);
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
//if (size<512)break;
|
|
||||||
if (num == n)break;
|
|
||||||
}
|
|
||||||
fout.Finalize();
|
|
||||||
nn::fs::CommitSaveData();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
NN_LOG("total %d",total);
|
|
||||||
drawText(10,100,"end");
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
nngxWaitVSync(NN_GX_DISPLAY0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Test2_V(int n)
|
|
||||||
{
|
|
||||||
int total,size2,i;
|
|
||||||
|
|
||||||
total =0;
|
|
||||||
int num = 0;
|
|
||||||
size2 = 512;
|
|
||||||
while(1){
|
|
||||||
sprintf(file_path,"data:/test%d.bin",num);
|
|
||||||
res = fin.TryInitialize(file_path);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"open Fail");
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res = fin.TryRead( &size,&get_buff[total],size2);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"read Fail");
|
|
||||||
fin.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (i=0;i<size;i++) if (src_buff[total+i] != get_buff[total+i])
|
|
||||||
{
|
|
||||||
drawText(8,100,"verifi Fail at %d",total+i);
|
|
||||||
fin.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
fin.Finalize();
|
|
||||||
|
|
||||||
total += size;
|
|
||||||
num++;
|
|
||||||
sprintf(str,"size %d , num %d",total,num);
|
|
||||||
s_RenderSystem.Clear();
|
|
||||||
drawText(10,80,str);
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
//if (size<512)break;
|
|
||||||
if (num == n)break;
|
|
||||||
}
|
|
||||||
fin.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
NN_LOG("total %d",total);
|
|
||||||
drawText(10,100,"end");
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
nngxWaitVSync(NN_GX_DISPLAY0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DirDepth 80
|
|
||||||
|
|
||||||
//ディレクトリ深度
|
|
||||||
bool Test3_W()
|
|
||||||
{
|
|
||||||
int total,size2;
|
|
||||||
|
|
||||||
res = nn::fs::FormatSaveData(200,200,false);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"format Fail");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res =nn::fs::MountSaveData();
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"Mount Fail");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int num = 0;
|
|
||||||
total =0;
|
|
||||||
size2 = 512;
|
|
||||||
strcpy(file_path,"data:");
|
|
||||||
while(1){
|
|
||||||
sprintf(str,"/%d",num);
|
|
||||||
strcat(file_path,str);
|
|
||||||
res = nn::fs::TryCreateDirectory(file_path);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
sprintf(str,"length = %d",(int)strlen(file_path));
|
|
||||||
drawText(8,110,str);
|
|
||||||
drawText(8,100,"Dir create Fail");
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
strcpy(file_path2,file_path);
|
|
||||||
sprintf(str,"/t%d.bin",num);
|
|
||||||
strcat(file_path2,str);
|
|
||||||
res = fout.TryInitialize(file_path2,true);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"open Fail");
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res = fout.TryWrite( &size,&src_buff[total],size2);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"write Fail");
|
|
||||||
fout.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
fout.Finalize();
|
|
||||||
|
|
||||||
num++;
|
|
||||||
total+=size;
|
|
||||||
s_RenderSystem.Clear();
|
|
||||||
sprintf(str,"num %d",num);
|
|
||||||
drawText(10,80,str);
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
if (num == DirDepth)break;
|
|
||||||
}
|
|
||||||
|
|
||||||
nn::fs::CommitSaveData();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
|
|
||||||
drawText(10,100,"end");
|
|
||||||
sprintf(str,"length = %d",(int)strlen(file_path2));
|
|
||||||
drawText(8,110,str);
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
nngxWaitVSync(NN_GX_DISPLAY0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Test3_V()
|
|
||||||
{
|
|
||||||
int i,total,size2;
|
|
||||||
|
|
||||||
int num = 0;
|
|
||||||
total =0;
|
|
||||||
size2 = 512;
|
|
||||||
strcpy(file_path,"data:");
|
|
||||||
while(1){
|
|
||||||
sprintf(str,"/%d",num);
|
|
||||||
strcat(file_path,str);
|
|
||||||
strcpy(file_path2,file_path);
|
|
||||||
sprintf(str,"/t%d.bin",num);
|
|
||||||
strcat(file_path2,str);
|
|
||||||
res = fin.TryInitialize(file_path2);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"open Fail");
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res = fin.TryRead( &size,&get_buff[total],size2);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"read Fail");
|
|
||||||
fin.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (i=0;i<size;i++) if (src_buff[total+i] != get_buff[total+i])
|
|
||||||
{
|
|
||||||
drawText(8,100,"verifi Fail at %d",total+i);
|
|
||||||
fin.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
fin.Finalize();
|
|
||||||
|
|
||||||
num++;
|
|
||||||
total+=size;
|
|
||||||
s_RenderSystem.Clear();
|
|
||||||
sprintf(str,"num %d",num);
|
|
||||||
drawText(10,80,str);
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
if (num == DirDepth) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
drawText(10,100,"end");
|
|
||||||
sprintf(str,"length = %d",(int)strlen(file_path2));
|
|
||||||
drawText(8,110,str);
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
nngxWaitVSync(NN_GX_DISPLAY0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//max size of name
|
|
||||||
#define max_len 16
|
|
||||||
bool Test4_W()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
res = nn::fs::FormatSaveData(1,0,true);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"format Fail");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res =nn::fs::MountSaveData();
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"Mount Fail");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(str,"data:/");
|
|
||||||
for (i =6;i<max_len+6;i++)str[i] = '-';
|
|
||||||
str[i] = 0;
|
|
||||||
res = fout.TryInitialize(str,true);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"Open Fail");
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res = fout.TryWrite( &size,&src_buff[0],512);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"Write Fail");
|
|
||||||
fout.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
fout.Finalize();
|
|
||||||
nn::fs::CommitSaveData();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return (size == 512);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Test4_V()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
strcpy(str,"data:/");
|
|
||||||
for (i =6;i<max_len+6;i++)str[i] = '-';
|
|
||||||
str[i] = 0;
|
|
||||||
res = fin.TryInitialize(str);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"Open Fail");
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res = fin.TryRead( &size,&get_buff[0],512);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"Read Fail");
|
|
||||||
fin.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
fin.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
if (size != 512)return false;
|
|
||||||
|
|
||||||
for (i=0;i<size;i++) if (src_buff[i] != get_buff[i])
|
|
||||||
{
|
|
||||||
drawText(8,100,"verifi Fail at %d",i);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SIZE_TEST5 (512*100)
|
|
||||||
//生成サイズに満たないデータ
|
|
||||||
bool Test5_W()
|
|
||||||
{
|
|
||||||
int pos;
|
|
||||||
|
|
||||||
res = nn::fs::FormatSaveData(1,0,true);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"format Fail");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res =nn::fs::MountSaveData();
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"Mount Fail");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
res = nn::fs::TryCreateFile(L"data:/test5.bin",SIZE_TEST5);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"Create Fail");
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res = fout.TryInitialize(L"data:/test5.bin",true);
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"open Fail");
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pos =0;
|
|
||||||
while(1){
|
|
||||||
fout.SetPosition(pos);
|
|
||||||
res = fout.TryWrite( &size,&src_buff[pos],512);
|
|
||||||
if (res.IsFailure() || (size!=512)){
|
|
||||||
drawText(8,100,"write Fail");
|
|
||||||
fout.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
sprintf(str,"position %d",pos);
|
|
||||||
s_RenderSystem.Clear();
|
|
||||||
drawText(10,80,str);
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
pos += 1024;//512飛ばす
|
|
||||||
if (pos >= SIZE_TEST5)break;
|
|
||||||
}
|
|
||||||
fout.Finalize();
|
|
||||||
nn::fs::CommitSaveData();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
drawText(10,100,"end");
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
nngxWaitVSync(NN_GX_DISPLAY0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Test5_V()
|
|
||||||
{
|
|
||||||
int i,pos;
|
|
||||||
|
|
||||||
res = fin.TryInitialize(L"data:/test5.bin");
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"open Fail");
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pos =0;
|
|
||||||
while(1){
|
|
||||||
fin.SetPosition(pos);
|
|
||||||
res = fin.TryRead( &size,&get_buff[pos],512);
|
|
||||||
if (res.IsFailure() || (size!=512)){
|
|
||||||
drawText(8,100,"read Fail");
|
|
||||||
fin.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
sprintf(str,"position %d",pos);
|
|
||||||
s_RenderSystem.Clear();
|
|
||||||
drawText(10,80,str);
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
|
|
||||||
for (i=0;i<512;i++) if (src_buff[pos+i] != get_buff[pos+i])
|
|
||||||
{
|
|
||||||
drawText(8,100,"verifi Fail at %d",i);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pos += 1024;//512飛ばす
|
|
||||||
if (pos >= SIZE_TEST5)break;
|
|
||||||
}
|
|
||||||
fin.Finalize();
|
|
||||||
nn::fs::Unmount("data:");
|
|
||||||
drawText(10,100,"end");
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
nngxWaitVSync(NN_GX_DISPLAY0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define menu_ct 6
|
|
||||||
#define menu_max (menu_ct-1)
|
|
||||||
char* menu_str[menu_ct] = {"Casual check","Large size","many files","Deep directry","max size name","data < create size"};
|
|
||||||
|
|
||||||
#define menu_top_Y 80
|
|
||||||
#define menu_top_X 60
|
|
||||||
#define menu_spc 14
|
|
||||||
|
|
||||||
//---------------------------------------------------------------- main
|
|
||||||
void TestMain()
|
|
||||||
{
|
|
||||||
u32 value;
|
|
||||||
int curs = 0;
|
|
||||||
int i;
|
|
||||||
bool sccs;
|
|
||||||
|
|
||||||
//Render
|
|
||||||
setColor(1.0f,1.0f,1.0f,1.0f);
|
|
||||||
|
|
||||||
//TEST PATTERN
|
|
||||||
make_pattern();
|
|
||||||
|
|
||||||
while(1){
|
|
||||||
|
|
||||||
//menu 表示
|
|
||||||
s_RenderSystem.Clear();
|
|
||||||
drawText(8,20," Backup Verifi for SaveDataMover Test ");
|
|
||||||
drawText(8,40," for 512KB Backup");
|
|
||||||
for (i=0;i<menu_ct;i++)drawText(menu_top_X,menu_top_Y+menu_spc*i,menu_str[i]);
|
|
||||||
drawText(menu_top_X-30,menu_top_Y+menu_spc*curs,"->");
|
|
||||||
drawText(menu_top_X,menu_top_Y+menu_spc*(menu_max+2),"push A:Write ,X:Verifi");
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
nngxWaitVSync(NN_GX_DISPLAY0);
|
|
||||||
|
|
||||||
//ボタン待ち
|
|
||||||
value = WaitKey(nn::hid::BUTTON_A | nn::hid::BUTTON_X |nn::hid::BUTTON_UP |nn::hid::BUTTON_DOWN);
|
|
||||||
if (value & nn::hid::BUTTON_A){//ライト
|
|
||||||
sccs = false;
|
|
||||||
s_RenderSystem.Clear();
|
|
||||||
drawText(10,70,"writing");
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
nngxWaitVSync(NN_GX_DISPLAY0);
|
|
||||||
switch(curs){
|
|
||||||
case 0:sccs = Test2_W(10);break;
|
|
||||||
case 1:sccs = Test1_W();break;
|
|
||||||
case 2:sccs = Test2_W(680);break;
|
|
||||||
case 3:sccs = Test3_W();break;
|
|
||||||
case 4:sccs = Test4_W();break;
|
|
||||||
case 5:sccs = Test5_W();break;
|
|
||||||
default:break;
|
|
||||||
}
|
|
||||||
}else if (value & nn::hid::BUTTON_X)
|
|
||||||
{//ベリファイ
|
|
||||||
sccs = false;
|
|
||||||
s_RenderSystem.Clear();
|
|
||||||
drawText(10,70,"verifi");
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
nngxWaitVSync(NN_GX_DISPLAY0);
|
|
||||||
res =nn::fs::MountSaveData();
|
|
||||||
if (res.IsFailure()){
|
|
||||||
drawText(8,100,"Mount Fail");
|
|
||||||
}else
|
|
||||||
switch(curs){
|
|
||||||
case 0:sccs = Test2_V(10);break;
|
|
||||||
case 1:sccs = Test1_V();break;
|
|
||||||
case 2:sccs = Test2_V(680);break;
|
|
||||||
case 3:sccs = Test3_V();break;
|
|
||||||
case 4:sccs = Test4_V();break;
|
|
||||||
case 5:sccs = Test5_V();break;
|
|
||||||
default:break;
|
|
||||||
}
|
|
||||||
}else if (value & nn::hid::BUTTON_UP){
|
|
||||||
if(curs > 0)curs--;
|
|
||||||
}else if(curs < menu_max)curs++;
|
|
||||||
|
|
||||||
if (value & (nn::hid::BUTTON_A | nn::hid::BUTTON_X)){
|
|
||||||
if (sccs == false)drawText(8,120,"Failed");
|
|
||||||
sprintf(str,"desc %d",res.GetDescription());
|
|
||||||
drawText(10,140,str);
|
|
||||||
s_RenderSystem.SwapBuffers();
|
|
||||||
NN_LOG("desc %d",res.GetDescription());
|
|
||||||
WaitKey(nn::hid::BUTTON_B);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*
|
|
||||||
End of file
|
|
||||||
*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
Binary file not shown.
@ -23,7 +23,7 @@ SUPPORTED_TARGETS = CTR-*.Process.MPCore.*
|
|||||||
|
|
||||||
SOURCES[] =
|
SOURCES[] =
|
||||||
./source/main.cpp
|
./source/main.cpp
|
||||||
./source/test_data.cpp
|
../../common/test_data.cpp
|
||||||
../../common/shfnt.cpp
|
../../common/shfnt.cpp
|
||||||
../../common/sleep.cpp
|
../../common/sleep.cpp
|
||||||
../../common/common.cpp
|
../../common/common.cpp
|
||||||
@ -62,8 +62,7 @@ ROM_SPEC_FILE = Imp.rsf
|
|||||||
DESCRIPTOR = $(CTRSDK_ROOT)/resources/specfiles/repairtool.desc
|
DESCRIPTOR = $(CTRSDK_ROOT)/resources/specfiles/repairtool.desc
|
||||||
|
|
||||||
# バナー、アイコン
|
# バナー、アイコン
|
||||||
#CTR_BANNER_SPEC = banner.bsf
|
CTR_BANNER_SPEC = banner.bsf
|
||||||
CTR_BANNER_SPEC = banner_null_icon.bsf
|
|
||||||
|
|
||||||
include $(ROOT_OMAKE)/modulerules
|
include $(ROOT_OMAKE)/modulerules
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@ -31,7 +31,7 @@
|
|||||||
#include "../common/sleep.h"
|
#include "../common/sleep.h"
|
||||||
#include "../common/common.h"
|
#include "../common/common.h"
|
||||||
#include "../common/shfnt.h"
|
#include "../common/shfnt.h"
|
||||||
#include "test_data.h"
|
#include "../common/test_data.h"
|
||||||
|
|
||||||
#define INF_FILE "sdmc:/cts_inf.txt"
|
#define INF_FILE "sdmc:/cts_inf.txt"
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
#ifndef TEST_DATA_H_
|
|
||||||
#define TEST_DATA_H_
|
|
||||||
|
|
||||||
void TestMain();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -50,7 +50,7 @@ ROM_SPEC_FILE = body.rsf
|
|||||||
DESCRIPTOR = $(CTRSDK_ROOT)/resources/specfiles/repairtool.desc
|
DESCRIPTOR = $(CTRSDK_ROOT)/resources/specfiles/repairtool.desc
|
||||||
|
|
||||||
# バナー、アイコン
|
# バナー、アイコン
|
||||||
CTR_BANNER_SPEC = banner_null_icon.bsf
|
CTR_BANNER_SPEC = banner.bsf
|
||||||
|
|
||||||
|
|
||||||
#Cia バージョン:マスタリング毎に更新すること
|
#Cia バージョン:マスタリング毎に更新すること
|
||||||
|
|||||||
@ -15,7 +15,7 @@ TitleInfo:
|
|||||||
Version: 0
|
Version: 0
|
||||||
|
|
||||||
Rom:
|
Rom:
|
||||||
# HostRoot : romfiles
|
HostRoot : romfiles
|
||||||
# SaveDataSize: 512K
|
# SaveDataSize: 512K
|
||||||
|
|
||||||
AccessControlInfo:
|
AccessControlInfo:
|
||||||
|
|||||||
Binary file not shown.
@ -379,22 +379,33 @@ RetCode Card2Sd()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (exsave.OpenW(file_pathw,fsize)==false)
|
bool mkdir;
|
||||||
{
|
int rev;
|
||||||
NN_LOG("%d\n",exsave.LastNnResult.GetDescription());
|
while(1){
|
||||||
if(nn::fs::ResultInvalidArgument::Includes(exsave.LastNnResult))
|
if (exsave.OpenW(file_pathw,fsize,&mkdir)==false)
|
||||||
{//パス名がFAT違反、パス長オーバ
|
|
||||||
if (exsave.OpenVnfW(file_pathw,fsize)==false)//退避ファイル
|
|
||||||
{
|
|
||||||
res = RESULT_FAIL_OPENW;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}else
|
|
||||||
{
|
{
|
||||||
res = RESULT_FAIL_OPENW;
|
if(mkdir)//ディレクトリのみ作成
|
||||||
break;
|
{//深い場合に作成が多いと画面が止まるので
|
||||||
}
|
rev++;
|
||||||
|
if (rev & 1)scr_MessOnCount2("Create Directry -");
|
||||||
|
else scr_MessOnCount2("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;
|
msize=fsize;
|
||||||
|
|||||||
@ -7,40 +7,34 @@
|
|||||||
int GetPosDelmLast(wchar_t *s,int top)
|
int GetPosDelmLast(wchar_t *s,int top)
|
||||||
{
|
{
|
||||||
size_t i = wcslen(s);
|
size_t i = wcslen(s);
|
||||||
if (i < top)return -1;
|
if (i <= top)return 0;
|
||||||
if (i ==top)return 0;
|
|
||||||
i--;
|
i--;
|
||||||
while(i > top-1){
|
while(i > top-1){
|
||||||
if (s[i]==L'/')return i;
|
if (s[i]==L'/')return i;
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//パス名チェック for SD
|
//パス名チェック for SD
|
||||||
//APIで引数エラー(INVALID_ARGUMENT)にならないものをチェック
|
//fs関数で引数エラー(INVALID_ARGUMENT)にならないものをチェック
|
||||||
bool CheckPath(wchar_t *s)
|
bool CheckPath(wchar_t *s)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
size_t n = wcslen(s);
|
size_t n = wcslen(s);
|
||||||
|
|
||||||
if (n > 253)return false;
|
if ((n > 253) || (n==0))return false;
|
||||||
if (n>251)
|
if (n>251)
|
||||||
{//オープン時のディレクトリ名は251まで
|
{//ディレクトリオープン時は251まで
|
||||||
if ((s[252]==L'/') || (s[253]==L'/'))return false;
|
if ((s[251]==L'/') || (s[252]==L'/'))return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i =1;i< n-1;i++)
|
for (i =0;i< n-1;i++)
|
||||||
{
|
{
|
||||||
if (s[i]==L'/')
|
if ((s[i-1] == ' ')||(s[i+1] == ' '))return false;//厳密にはスラッシュ前後と最後尾
|
||||||
{
|
if ((s[i-1] == 0x5c) ||(s[i+1] == 0x5c))return false;//0x5c = 円マーク
|
||||||
//前後の半角スペース: "/ a"、"/a /" -> SD作成時 "/a" に変化
|
|
||||||
if ((s[i-1] == ' ')||(s[i+1] == ' '))return false;
|
|
||||||
if ((s[i-1] == 0x5c) ||(s[i+1] == 0x5c))return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (s[i] == ' ')return false;//最後尾
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -197,7 +197,7 @@ s32 Sdmc::Write(char *buffer,size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
//ライト属性ファイルを開く
|
//ライト属性ファイルを開く
|
||||||
bool Sdmc::OpenW(wchar_t *path,s64 size)
|
bool Sdmc::OpenW(wchar_t *path,s64 size)
|
||||||
{
|
{
|
||||||
@ -227,6 +227,38 @@ bool Sdmc::OpenW(wchar_t *path,s64 size)
|
|||||||
LastNnResult = writer.TryInitialize(expath_w,false);
|
LastNnResult = writer.TryInitialize(expath_w,false);
|
||||||
return LastNnResult.IsSuccess();
|
return LastNnResult.IsSuccess();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool Sdmc::OpenW(wchar_t *path,s64 size,bool *mkdir)
|
||||||
|
{
|
||||||
|
int pos,pos2;
|
||||||
|
|
||||||
|
wcscpy(expath_w,sdmcRoot_w);
|
||||||
|
wcscat(expath_w,path);
|
||||||
|
*mkdir = false;
|
||||||
|
LastNnResult = nn::fs::TryCreateFile(expath_w,size);
|
||||||
|
if(LastNnResult.IsSuccess())
|
||||||
|
{
|
||||||
|
LastNnResult = writer.TryInitialize(expath_w,false);
|
||||||
|
return LastNnResult.IsSuccess();
|
||||||
|
}
|
||||||
|
//ディレクトリがなければディレクトリを作成
|
||||||
|
pos = GetPosDelmLast(expath_w,ROOTLENGTH_SD);//ファイルが存在するディレクトリ
|
||||||
|
if (pos <= 0)return false;//rootかパスが不正
|
||||||
|
wcscpy(expathw_w,expath_w);//ワークにコピー
|
||||||
|
while (LastNnResult.IsFailure()){//ディレクトリ作成できるまで遡る
|
||||||
|
//if(LastNnResult.GetDescription()!=nn::fs::DESCRIPTION_DBM_DIRECTORY_NOT_FOUND)return false;
|
||||||
|
if(nn::fs::ResultNotFound::Includes(LastNnResult)==false)return false;
|
||||||
|
pos2 = GetPosDelmLast(expathw_w,ROOTLENGTH_SD);//境界位置を探す
|
||||||
|
if (pos2 == 0)return false;//root到達
|
||||||
|
expathw_w[pos2] = 0;//境界まで削除 (例) dir1/dir2/file -> dir1/dir2 -> dir1
|
||||||
|
LastNnResult = nn::fs::TryCreateDirectory(expathw_w);
|
||||||
|
}
|
||||||
|
//作成ディレクトリ多いと画面止まるので、作成ごとに抜ける
|
||||||
|
*mkdir = true; // 帰値:false で mkdir=true ならディレクトリ作成のみ
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//パス名エラーで作成できない場合の退避先
|
//パス名エラーで作成できない場合の退避先
|
||||||
//例:FAT規約違反、"/ test"->"/test"、SD格納先ディレクトリでパス長オーバー
|
//例:FAT規約違反、"/ test"->"/test"、SD格納先ディレクトリでパス長オーバー
|
||||||
|
|||||||
@ -50,7 +50,8 @@ public:
|
|||||||
bool Delete();
|
bool Delete();
|
||||||
bool DeleteAll();
|
bool DeleteAll();
|
||||||
void CloseW();
|
void CloseW();
|
||||||
bool OpenW(wchar_t *path,s64 size);
|
//bool OpenW(wchar_t *path,s64 size);
|
||||||
|
bool OpenW(wchar_t *path,s64 size,bool *mkdir);
|
||||||
bool OpenVnfW(wchar_t *path,s64 size);
|
bool OpenVnfW(wchar_t *path,s64 size);
|
||||||
bool OpenVnf(wchar_t *path);
|
bool OpenVnf(wchar_t *path);
|
||||||
void GetRootPath(wchar_t *path);
|
void GetRootPath(wchar_t *path);
|
||||||
|
|||||||
@ -508,7 +508,83 @@ bool Test3_V()
|
|||||||
nngxWaitVSync(NN_GX_DISPLAY0);
|
nngxWaitVSync(NN_GX_DISPLAY0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
//max size of name
|
||||||
|
bool Test4_W()
|
||||||
|
{
|
||||||
|
|
||||||
|
res = nn::fs::FormatSaveData(1,1,true);
|
||||||
|
if (res.IsFailure()){
|
||||||
|
drawText(8,100,"format Fail");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
res =nn::fs::MountSaveData();
|
||||||
|
if (res.IsFailure()){
|
||||||
|
drawText(8,100,"Mount Fail");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(file_path,"data:/0123456789abcdef");//16文字
|
||||||
|
res = nn::fs::TryCreateDirectory(file_path);
|
||||||
|
if (res.IsFailure()){
|
||||||
|
sprintf(str,"length = %d",(int)strlen(file_path)-6);
|
||||||
|
drawText(8,110,str);
|
||||||
|
drawText(8,100,"Dir create Fail");
|
||||||
|
nn::fs::Unmount("data:");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
strcat(file_path,"/0123456789ab.bin");//16文字
|
||||||
|
res = fout.TryInitialize(file_path,true);
|
||||||
|
if (res.IsFailure()){
|
||||||
|
drawText(8,100,"Open Fail");
|
||||||
|
nn::fs::Unmount("data:");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
res = fout.TryWrite( &size,&src_buff[0],512);
|
||||||
|
if (res.IsFailure()){
|
||||||
|
drawText(8,100,"Write Fail");
|
||||||
|
fout.Finalize();
|
||||||
|
nn::fs::Unmount("data:");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
fout.Finalize();
|
||||||
|
nn::fs::CommitSaveData();
|
||||||
|
nn::fs::Unmount("data:");
|
||||||
|
return (size == 512);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Test4_V()
|
||||||
|
{
|
||||||
|
|
||||||
|
strcpy(file_path,"data:/0123456789abcdef");//16文字
|
||||||
|
strcat(file_path,"/0123456789ab.bin");//16文字
|
||||||
|
res = fin.TryInitialize(file_path);
|
||||||
|
if (res.IsFailure()){
|
||||||
|
drawText(8,100,"Open Fail");
|
||||||
|
nn::fs::Unmount("data:");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
res = fin.TryRead( &size,&get_buff[0],512);
|
||||||
|
if (res.IsFailure()){
|
||||||
|
drawText(8,100,"Read Fail");
|
||||||
|
fin.Finalize();
|
||||||
|
nn::fs::Unmount("data:");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
fin.Finalize();
|
||||||
|
nn::fs::Unmount("data:");
|
||||||
|
if (size != 512)return false;
|
||||||
|
|
||||||
|
for (int i=0;i<size;i++) if (src_buff[i] != get_buff[i])
|
||||||
|
{
|
||||||
|
drawText(8,100,"verifi Fail at %d",i);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
//max size of name
|
//max size of name
|
||||||
#define max_len 16
|
#define max_len 16
|
||||||
bool Test4_W()
|
bool Test4_W()
|
||||||
@ -582,6 +658,7 @@ bool Test4_V()
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
#define SIZE_TEST5 (512*100)
|
#define SIZE_TEST5 (512*100)
|
||||||
//生成サイズに満たないデータ
|
//生成サイズに満たないデータ
|
||||||
Loading…
Reference in New Issue
Block a user