mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
0thNUP対応 修正版タグ
CAL由来のセーブデータはCAL値を使うように git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@142 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
b617cebde1
commit
9ccbb0108b
BIN
tags/0thNUP_2/CardCup/CardCup.bsf
Normal file
BIN
tags/0thNUP_2/CardCup/CardCup.bsf
Normal file
Binary file not shown.
22
tags/0thNUP_2/CardCup/CardCup.rsf
Normal file
22
tags/0thNUP_2/CardCup/CardCup.rsf
Normal file
@ -0,0 +1,22 @@
|
||||
BasicInfo:
|
||||
Title : CupCardDemo
|
||||
BackupMemoryType : None
|
||||
Logo: Nintendo
|
||||
|
||||
TitleInfo:
|
||||
Use: Evaluation
|
||||
UniqueId: 0xf802a
|
||||
Version: 0
|
||||
|
||||
SystemControlInfo:
|
||||
AppType : System
|
||||
Dependency:
|
||||
- codec
|
||||
- hid
|
||||
- gsp
|
||||
- dsp
|
||||
|
||||
AccessControlInfo:
|
||||
Priority: 48
|
||||
FileSystemAccess:
|
||||
- CategorySystemApplication
|
||||
46
tags/0thNUP_2/CardCup/OMakefile
Normal file
46
tags/0thNUP_2/CardCup/OMakefile
Normal file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env omake
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: Horizon
|
||||
# File: OMakefile
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# $Rev$
|
||||
#----------------------------------------------------------------------------
|
||||
CTR_APPTYPE=BOTH
|
||||
CTR_MAKE_DEVELOPMENT_IMAGE = true
|
||||
|
||||
SUPPORTED_TARGETS = CTR-T*.Process.MPCore.*
|
||||
|
||||
SAMPLED_DEMOS_COMMON_INCLUDE_DIR = $(dir $(HORIZON_ROOT)/../CTR/SampleDemos/common/include)
|
||||
INCLUDES += $(SAMPLED_DEMOS_COMMON_INCLUDE_DIR)
|
||||
|
||||
SOURCES[] =
|
||||
main.cpp
|
||||
scrollBuffer.cpp
|
||||
|
||||
LIBS += lib_demo \
|
||||
libnn_am \
|
||||
libnn_cup \
|
||||
libnn_ns \
|
||||
libnn_ps
|
||||
|
||||
|
||||
DESCRIPTOR = $(HORIZON_ROOT)/resources/specfiles/HomeMenuTest.desc
|
||||
|
||||
TARGET_PROGRAM = CardCup
|
||||
|
||||
TITLE = CardCup
|
||||
ROM_SPEC_FILE = CardCup.rsf
|
||||
|
||||
CTR_BANNER_SPEC = $(TARGET_PROGRAM).bsf
|
||||
|
||||
include $(ROOT_OMAKE)/modulerules
|
||||
|
||||
build: $(DEFAULT_TARGETS)
|
||||
73
tags/0thNUP_2/CardCup/OMakeroot
Normal file
73
tags/0thNUP_2/CardCup/OMakeroot
Normal file
@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env omake
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: Horizon
|
||||
# File: OMakeroot
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# $Rev:$
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# ディレクトリレイアウトについての説明
|
||||
#
|
||||
# a) ソースコードがルートディレクトリ直下に配置される場合
|
||||
# 例:
|
||||
# /OMakeroot
|
||||
# /foo/bar/OMakefile
|
||||
#
|
||||
# 結果:
|
||||
# OMakefile と同じディレクトリ以下に objects や images が生成されます。
|
||||
#
|
||||
# /foo/bar/objects/...
|
||||
# /foo/bar/images/..
|
||||
#
|
||||
#
|
||||
# b) ソースコードが sources 以下に配置される場合
|
||||
# 例:
|
||||
# /OMakeroot
|
||||
# /sources/foo/bar/OMakefile
|
||||
#
|
||||
# 結果:
|
||||
# ルートディレクトリ以下に objects や images が生成されます。
|
||||
#
|
||||
# /objects/foo/bar/...
|
||||
# /images/foo/bar/...
|
||||
#
|
||||
#
|
||||
|
||||
# ルート環境変数の取得
|
||||
public.HORIZON_ROOT =
|
||||
if $(defined-env HORIZON_ROOT)
|
||||
HORIZON_ROOT = $(absname $(getenv HORIZON_ROOT))
|
||||
export
|
||||
|
||||
if $(defined-env CTRSDK_ROOT)
|
||||
CTRSDK_ROOT = $(absname $(getenv CTRSDK_ROOT))
|
||||
if $(and $(defined-env HORIZON_ROOT), $(not $(equal $(HORIZON_ROOT), $(CTRSDK_ROOT))))
|
||||
eprintln(HORIZON_ROOT と CTRSDK_ROOT が一致しません。同じパスを設定するか、どちらか一方だけを定義して下さい。)
|
||||
exit(1)
|
||||
HORIZON_ROOT = $(CTRSDK_ROOT)
|
||||
export
|
||||
|
||||
if $(not $(HORIZON_ROOT))
|
||||
eprintln($"$$CTRSDK_ROOT が定義されていません")
|
||||
exit(1)
|
||||
|
||||
include $(HORIZON_ROOT)/build/omake/commondefs
|
||||
|
||||
DefineCommandVars()
|
||||
|
||||
.PHONY: all build clean clobber
|
||||
.PHONY: run run-scripts run-emumem
|
||||
|
||||
#
|
||||
# OMakefile の読み込み
|
||||
#
|
||||
.SUBDIRS: .
|
||||
|
||||
BIN
tags/0thNUP_2/CardCup/banner/model.cbmd
Normal file
BIN
tags/0thNUP_2/CardCup/banner/model.cbmd
Normal file
Binary file not shown.
BIN
tags/0thNUP_2/CardCup/banner/sound.cbsd
Normal file
BIN
tags/0thNUP_2/CardCup/banner/sound.cbsd
Normal file
Binary file not shown.
1
tags/0thNUP_2/CardCup/banner/unknown24x24.ctpk
Normal file
1
tags/0thNUP_2/CardCup/banner/unknown24x24.ctpk
Normal file
@ -0,0 +1 @@
|
||||
В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ф8ф8фШчГГГГГГВ╫В╫8фВ╫В╫В╫В╫В╫ГГГГшчфГШФВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫yнВ╫yнВ╫В╫В╫В╫В╫YнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ГГГГШчyнYнВ╫шчшчВ╫В╫фВ╫В╫шчyнШчВ╫yнГГГГyнШФГГГГГшчВ╫В╫В╫В╫YнГyнГВ╫В╫В╫В╫В╫yнфшчГШФГYнyнВ╫В╫В╫yнВ╫╨жВ╫В╫В╫В╫В╫yнВ╫yнВ╫В╫В╫В╫В╫YнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫yнГYнГВ╫В╫В╫В╫В╫фВ╫В╫ГyнГ8фВ╫В╫В╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫
|
||||
1
tags/0thNUP_2/CardCup/banner/unknown48x48.ctpk
Normal file
1
tags/0thNUP_2/CardCup/banner/unknown48x48.ctpk
Normal file
@ -0,0 +1 @@
|
||||
В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫YнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫8ф8фВ╫В╫В╫╨ж8ф╨жГГшчГГГГГГГГГГГГГГГГГГГГГГГВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8ф8фВ╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ГГГГГШФГГГГГГГГГГ жфГГВ╫В╫ жВ╫ГГГГГ жГГВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫шчВ╫шчВ╫В╫В╫В╫В╫ГВ╫ШчВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫╨жВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ГГГГГГГГГГГГГГГГГГШФ8фШчшчВ╫В╫ жВ╫YнВ╫В╫В╫В╫В╫ГГYнyнГГyнфВ╫В╫В╫В╫В╫В╫В╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫шчшчГшчШФВ╫В╫ГГYнГВ╫В╫В╫В╫В╫шчВ╫шчГГГГГГГГГГГГГГГГВ╫В╫YнШч жГГГГГГГГГГГГГГГГГГГГГГГГшч╨жВ╫ жВ╫шчВ╫В╫В╫В╫В╫ШФВ╫ШФВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫шчВ╫yнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫YнВ╫ жГГГГВ╫шчВ╫шчГГГГВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫╨жшчВ╫В╫В╫В╫В╫YнфyнГГГГГГГГГ жГГГГ╨жВ╫YнВ╫ШФYнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫шч жВ╫В╫В╫В╫В╫В╫yнВ╫ГШФВ╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ШФВ╫ГГГГГВ╫ШчВ╫YнГГШФГВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ГГГГ жВ╫шчВ╫ГГГшч жВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫
|
||||
269
tags/0thNUP_2/CardCup/main.cpp
Normal file
269
tags/0thNUP_2/CardCup/main.cpp
Normal file
@ -0,0 +1,269 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
#include <nn/hid.h>
|
||||
#include <nn/os.h>
|
||||
#include <nn/dbg.h>
|
||||
#include <nn/CTR.h>
|
||||
#include <nn/ns.h>
|
||||
#include <nn/ns/CTR/ns_ApiShell.h>
|
||||
#include <nn/ns/CTR/ns_Shell.h>
|
||||
#include <nn/fs/fs_FileSystemBase.h>
|
||||
#include <nn/fs/CTR/MPCore/fs_FileSystemBasePrivate.h>
|
||||
#include <nn/applet/CTR/applet_APIForSystem.h>
|
||||
|
||||
#include <nn/cup.h>
|
||||
|
||||
#include "demo.h"
|
||||
#include "scrollBuffer.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
const int s_GxHeapSize=0x800000;
|
||||
nn::fnd::ExpHeap s_appHeap;
|
||||
uptr s_GxHeap;
|
||||
|
||||
demo::RenderSystemDrawing s_RenderSystem;
|
||||
ScrollBuffer s_scrollBufferInstance;
|
||||
ScrollBuffer *s_scrollBuffer;
|
||||
|
||||
char s_updaterBuffer[1<<20] NN_ATTRIBUTE_ALIGN(4096);
|
||||
|
||||
// デモの初期化
|
||||
void Initialize()
|
||||
{
|
||||
// os の初期化
|
||||
nn::os::Initialize();
|
||||
|
||||
// NuiShellの初期化 (CUPに必須)
|
||||
NN_UTIL_PANIC_IF_FAILED(nn::ns::CTR::InitializeForShell());
|
||||
|
||||
// fsの初期化 (カード確認用)
|
||||
nn::fs::Initialize();
|
||||
|
||||
// appletの初期化
|
||||
//nn::applet::InitializeForSystem( nn::applet::PHOME_MENU_APPLET_ID, nn::applet::TYPE_SYS );
|
||||
//nn::applet::Initialize( nn::applet::TEST2_APPLET_ID);
|
||||
//nn::applet::SetAppletMode();
|
||||
nn::applet::Enable();
|
||||
|
||||
// デバイスメモリの設定
|
||||
const int DEVICE_MEMORY_SIZE = 12*1024 * 1024;
|
||||
NN_UTIL_PANIC_IF_FAILED(nn::os::SetDeviceMemorySize(DEVICE_MEMORY_SIZE));
|
||||
|
||||
// ヒープの初期化
|
||||
s_appHeap.Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize(), nn::os::ALLOCATE_OPTION_LINEAR);
|
||||
|
||||
// 描画インスタンスの初期化
|
||||
s_GxHeap = reinterpret_cast<uptr>(s_appHeap.Allocate(s_GxHeapSize));
|
||||
s_RenderSystem.Initialize(s_GxHeap, s_GxHeapSize);
|
||||
|
||||
// hidの初期化
|
||||
NN_UTIL_PANIC_IF_FAILED(nn::hid::Initialize());
|
||||
|
||||
// 描画インスタンスの初期化
|
||||
s_scrollBufferInstance.Initialize(&s_RenderSystem);
|
||||
s_scrollBuffer=&s_scrollBufferInstance;
|
||||
|
||||
// GPU利用宣言
|
||||
nn::applet::AssignGpuRight();
|
||||
}
|
||||
|
||||
// 消費時間取得用関数群
|
||||
s64 s_StartTick;
|
||||
void SetTick()
|
||||
{
|
||||
s_StartTick=nn::os::Tick::GetSystemCurrent();
|
||||
}
|
||||
s64 GetConsumedMillisec()
|
||||
{
|
||||
s64 endTick=nn::os::Tick::GetSystemCurrent();
|
||||
nn::os::Tick consumed(endTick-s_StartTick);
|
||||
return ((nn::fnd::TimeSpan)consumed).GetMilliSeconds();
|
||||
}
|
||||
|
||||
// 動いていることを知らせるための、くるくる画面表示取得用メソッド
|
||||
const char s_progress[]="-\\|/";
|
||||
int s_progressIndex=0;
|
||||
char GetProgressChar()
|
||||
{
|
||||
s_progressIndex=(s_progressIndex+1)%(sizeof(s_progress)-1);
|
||||
return s_progress[s_progressIndex];
|
||||
}
|
||||
|
||||
nn::Result UpdateCore()
|
||||
{
|
||||
nn::Result result;
|
||||
nn::cup::ProgressInfo info;
|
||||
|
||||
/********************** アップデート*******************/
|
||||
SetTick();
|
||||
s_scrollBuffer->AppendText("Start Card Update")->Render();
|
||||
NN_UTIL_RETURN_IF_FAILED(nn::cup::CTR::DoUpdate());
|
||||
|
||||
// ステータスがStartedになるまで、プログレスは取得できない
|
||||
s_scrollBuffer->AppendText("");
|
||||
do{
|
||||
s_scrollBuffer->ReplaceText(" %c Initializing", GetProgressChar())->Render();
|
||||
result = nn::cup::CTR::GetProgressInfo(&info);
|
||||
NN_UTIL_RETURN_IF_FAILED(result);
|
||||
nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(40));
|
||||
}while(info.state==nn::cup::CTR::UPDATE_STATE_INITIALIZING);
|
||||
|
||||
// 抜けた際のstateがFAILEDかどうか確認
|
||||
if(info.state==nn::cup::CTR::UPDATE_STATE_FAILED){
|
||||
NN_UTIL_RETURN_IF_FAILED(info.lastResult);
|
||||
}
|
||||
s_scrollBuffer->ReplaceText(" - Initialized (%lldmsec)", GetConsumedMillisec());
|
||||
|
||||
/********************* アップデート中 ******************/
|
||||
SetTick();
|
||||
s_scrollBuffer->AppendText("")->Render();
|
||||
do{
|
||||
result = nn::cup::CTR::GetProgressInfo(&info);
|
||||
NN_UTIL_RETURN_IF_FAILED(result);
|
||||
s_scrollBuffer->ReplaceText(" %c Title %d/%d, size %lld/%lld",
|
||||
GetProgressChar(),
|
||||
info.numImportedTitles, info.numTotalTitles,
|
||||
info.importedSize, info.totalSize)->Render();
|
||||
nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(40));
|
||||
|
||||
}while(info.state==nn::cup::CTR::UPDATE_STATE_STARTED);
|
||||
// 抜けた際のstateがFAILEDかどうか確認
|
||||
if(info.state==nn::cup::CTR::UPDATE_STATE_FAILED){
|
||||
NN_UTIL_RETURN_IF_FAILED(info.lastResult);
|
||||
}
|
||||
s_scrollBuffer->AppendText(" - Imported (%lldmsec)", GetConsumedMillisec())->Render();
|
||||
|
||||
/***************** アップデート終了中 ******************/
|
||||
SetTick();
|
||||
s_scrollBuffer->AppendText("")->Render();
|
||||
do{
|
||||
result = nn::cup::CTR::GetProgressInfo(&info);
|
||||
NN_UTIL_RETURN_IF_FAILED(result);
|
||||
s_scrollBuffer->ReplaceText(" %c Update Finalizing", GetProgressChar())->Render();
|
||||
nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(40));
|
||||
}while(info.state==nn::cup::CTR::UPDATE_STATE_FINALIZING);
|
||||
// 抜けた際のstateがFAILEDかどうか確認
|
||||
if(info.state==nn::cup::CTR::UPDATE_STATE_FAILED){
|
||||
NN_UTIL_RETURN_IF_FAILED(info.lastResult);
|
||||
}
|
||||
|
||||
/******************* アップデート終了 *******************/
|
||||
s_scrollBuffer->AppendText(" - Finalized (%lldmsec)", GetConsumedMillisec())->Render();
|
||||
s_scrollBuffer->AppendText("");
|
||||
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
nn::Result UpdateSequence(bool *isHandledError)
|
||||
{
|
||||
nn::Result result;
|
||||
nn::Result lastResult=nn::ResultSuccess();
|
||||
nn::hid::PadReader padReader;
|
||||
|
||||
/********************* CUPの初期化 *******************/
|
||||
s_scrollBuffer->AppendText("Initializing Cup Library")->Render();
|
||||
SetTick(); // 初期化開始前の時間をセット
|
||||
result=nn::cup::CTR::Initialize(s_updaterBuffer,sizeof(s_updaterBuffer));
|
||||
if(result==nn::cup::CTR::ResultUpdatePartitionNotFound()){
|
||||
s_scrollBuffer->AppendText(" - Update Partition Not Found (%lldmsec)", GetConsumedMillisec())->Render();
|
||||
s_scrollBuffer->AppendText("")->Render();
|
||||
*isHandledError=true;
|
||||
return result;
|
||||
}
|
||||
if(result==nn::cup::CTR::ResultUpdateNotRequired()){
|
||||
s_scrollBuffer->AppendText(" - Already Updated (%lldmsec)", GetConsumedMillisec())->Render();
|
||||
s_scrollBuffer->AppendText("")->Render();
|
||||
*isHandledError=true;
|
||||
return result;
|
||||
}
|
||||
if(result==nn::cup::CTR::ResultInvalidUpdatePartitionFormat()){
|
||||
s_scrollBuffer->AppendText(" - Invalid Update Partition (%lldmsec)", GetConsumedMillisec())->Render();
|
||||
s_scrollBuffer->AppendText("")->Render();
|
||||
*isHandledError=true;
|
||||
return result;
|
||||
}
|
||||
NN_UTIL_RETURN_IF_FAILED(result);
|
||||
|
||||
s_scrollBuffer->AppendText(" - Need Update (%lldmsec)", GetConsumedMillisec())->Render();
|
||||
s_scrollBuffer->AppendText("")->Render();
|
||||
|
||||
lastResult=UpdateCore();
|
||||
|
||||
// Initializeに成功した場合のみ、再びInitializeするためにFinalizeが必要
|
||||
SetTick();
|
||||
s_scrollBuffer->AppendText("Finalizing Cup Library")->Render();
|
||||
NN_UTIL_RETURN_IF_FAILED(nn::cup::CTR::Finalize());
|
||||
s_scrollBuffer->AppendText(" - Complete (%lldmsec)", GetConsumedMillisec())->Render();
|
||||
s_scrollBuffer->AppendText("")->Render();
|
||||
|
||||
return lastResult;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void nnMain()
|
||||
{
|
||||
NN_LOG("Start cup demo\n");
|
||||
nn::Result result;
|
||||
Initialize();
|
||||
|
||||
/******************** CUPの実行 *******************/
|
||||
bool isHandledError = false;
|
||||
result = UpdateSequence(&isHandledError);
|
||||
if (isHandledError == false && result.IsFailure())
|
||||
{
|
||||
{
|
||||
// それ以外の場合は、Resultを表示
|
||||
s_scrollBuffer->AppendText(" - Unhandled Error: 0x%08x", result.GetPrintableBits());
|
||||
s_scrollBuffer->AppendText("")->Render();
|
||||
}
|
||||
}
|
||||
|
||||
s_scrollBuffer->AppendText("")->Render();
|
||||
|
||||
for(;;)
|
||||
{
|
||||
s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY0);
|
||||
if(result.IsSuccess() || result == nn::cup::CTR::ResultUpdateNotRequired())
|
||||
{
|
||||
s_RenderSystem.SetClearColor(NN_GX_DISPLAY0, 0, 1, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_RenderSystem.SetClearColor(NN_GX_DISPLAY0, 1, 0, 0, 1);
|
||||
}
|
||||
s_RenderSystem.Clear();
|
||||
s_RenderSystem.SwapBuffers();
|
||||
s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY1);
|
||||
if(result.IsSuccess() || result == nn::cup::CTR::ResultUpdateNotRequired())
|
||||
{
|
||||
s_RenderSystem.SetClearColor(NN_GX_DISPLAY1, 0, 1, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_RenderSystem.SetClearColor(NN_GX_DISPLAY1, 1, 0, 0, 1);
|
||||
}
|
||||
s_scrollBuffer->ReplaceText("%c Finished", GetProgressChar())->Render();
|
||||
|
||||
if ( nn::applet::IsExpectedToCloseApplication() )
|
||||
{
|
||||
nn::applet::PrepareToCloseApplication();
|
||||
nn::applet::CloseApplication();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
89
tags/0thNUP_2/CardCup/scrollBuffer.cpp
Normal file
89
tags/0thNUP_2/CardCup/scrollBuffer.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: scrollBuffer.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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <cstdio>
|
||||
#include "scrollBuffer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
char ScrollBuffer::s_buffers[MAX_BUFFER_LINE][MAX_BUFFER_CHARS];
|
||||
|
||||
char *ScrollBuffer::GetFormattedString(const char *fmt, va_list arg)
|
||||
{
|
||||
static char formattedBuffer[MAX_BUFFER_CHARS];
|
||||
vsnprintf(formattedBuffer, MAX_BUFFER_CHARS, fmt, arg);
|
||||
return formattedBuffer;
|
||||
}
|
||||
|
||||
ScrollBuffer *ScrollBuffer::Update()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
ScrollBuffer *ScrollBuffer::AppendText(const char *fmt, ...)
|
||||
{
|
||||
va_list vlist;
|
||||
va_start(vlist, fmt);
|
||||
|
||||
int nextPosition=(m_tail+1)%MAX_BUFFER_LINE;
|
||||
if(nextPosition==m_head){
|
||||
// ヘッドとビューの移動
|
||||
if(m_head==m_currentView){
|
||||
m_currentView=(m_head+1)%MAX_BUFFER_LINE;
|
||||
}
|
||||
m_head=(m_head+1)%MAX_BUFFER_LINE;
|
||||
|
||||
}
|
||||
strlcpy(s_buffers[m_tail], GetFormattedString(fmt, vlist), MAX_BUFFER_CHARS);
|
||||
m_tail=nextPosition;
|
||||
NN_LOG("cup: %s\n", GetFormattedString(fmt, vlist));
|
||||
|
||||
// ビューの移動
|
||||
if((m_currentView+MAX_DISPLAY_LINES)%MAX_BUFFER_LINE==m_tail){
|
||||
m_currentView=(m_currentView+1)%MAX_BUFFER_LINE;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
ScrollBuffer *ScrollBuffer::ReplaceText(const char *fmt, ...)
|
||||
{
|
||||
va_list vlist;
|
||||
va_start(vlist, fmt);
|
||||
|
||||
NN_ASSERT(m_tail!=m_head);
|
||||
strlcpy(s_buffers[(m_tail-1)%MAX_BUFFER_LINE], GetFormattedString(fmt, vlist), MAX_BUFFER_CHARS);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
void ScrollBuffer::Render()
|
||||
{
|
||||
// 描画前処理
|
||||
m_render->SetRenderTarget(NN_GX_DISPLAY1);
|
||||
m_render->Clear();
|
||||
m_render->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
// リングバッファなので、終端条件を調整
|
||||
int tail=(m_tail<m_head) ? m_tail+ScrollBuffer::MAX_BUFFER_LINE : m_tail;
|
||||
|
||||
for(int i=m_currentView; i<tail; i++){
|
||||
if(i<m_currentView+MAX_DISPLAY_LINES-1){
|
||||
m_render->DrawText(0, (i-m_currentView)*FONT_SIZE, s_buffers[i%MAX_BUFFER_LINE]);
|
||||
}
|
||||
}
|
||||
|
||||
// 描画転送
|
||||
m_render->SwapBuffers();
|
||||
}
|
||||
55
tags/0thNUP_2/CardCup/scrollBuffer.h
Normal file
55
tags/0thNUP_2/CardCup/scrollBuffer.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: scrollBuffer.h
|
||||
|
||||
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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SCROLL_BUFFER_H_
|
||||
#define SCROLL_BUFFER_H_
|
||||
|
||||
#include "demo.h"
|
||||
class ScrollBuffer
|
||||
{
|
||||
private:
|
||||
enum
|
||||
{
|
||||
MAX_BUFFER_LINE=128,
|
||||
MAX_BUFFER_CHARS=80,
|
||||
MAX_DISPLAY_LINES=20,
|
||||
FONT_SIZE=12
|
||||
};
|
||||
// 表示文字のバッファ (リングバッファ)
|
||||
static char s_buffers[MAX_BUFFER_LINE][MAX_BUFFER_CHARS];
|
||||
int m_head;
|
||||
int m_tail;
|
||||
int m_currentView;
|
||||
|
||||
demo::RenderSystemDrawing *m_render;
|
||||
|
||||
char *GetFormattedString(const char *fmt, va_list arg);
|
||||
|
||||
public:
|
||||
ScrollBuffer() :
|
||||
m_head(0), m_tail(0), m_currentView(0)
|
||||
{}
|
||||
void Initialize(demo::RenderSystemDrawing *render)
|
||||
{
|
||||
m_render=render;
|
||||
}
|
||||
|
||||
ScrollBuffer *Update(); // キー入力を参照して、スクロールする
|
||||
ScrollBuffer *AppendText(const char *fmt, ...); // 文字列を追加する
|
||||
ScrollBuffer *ReplaceText(const char *fmt, ...); // 最新の文字列を置換する
|
||||
void Render(); // レンダリング
|
||||
};
|
||||
|
||||
#endif // SCROLL_BUFFER_H
|
||||
247
tags/0thNUP_2/CardSaveDataMover/ImpRun/HwCheckProgram.desc
Normal file
247
tags/0thNUP_2/CardSaveDataMover/ImpRun/HwCheckProgram.desc
Normal file
@ -0,0 +1,247 @@
|
||||
AccessControlDescriptor:
|
||||
AffinityMask: 1
|
||||
AutoGen: true
|
||||
CoreVersion: 2
|
||||
DescVersion: 2
|
||||
Descriptor: |
|
||||
AP///wAABAACAAAAAAAFGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAik8AAAAAAABBUFQ6VQAAAGFj
|
||||
OmkAAAAAYWM6dQAAAABhbTp1AAAAAGNhbTpjAAAAY2RjOkNISwBjZmc6aQAA
|
||||
AGNmZzpub3IAY3NuZDpTTkRkc3A6OkRTUGZzOkxEUgAAZnM6VVNFUgBnc3A6
|
||||
OkdwdWdzcDo6TGNkaGlkOlNQVlJoaWQ6VVNFUmkyYzo6RUVQaXI6dQAAAABt
|
||||
Y3U6OkhXQ21pYzp1AAAAbXA6dQAAAABuZG06dQAAAG5zOnMAAAAAbndtOjpF
|
||||
WFRud206OlVEU3BzOnBzAAAAcHRtOnN5c21wdG06dQAAAHB4aTpkZXYAc29j
|
||||
OlUAAABzc2w6QwAAAHkycjp1AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAD+//vw/7//8ec/APIA8JH/APaR/1D/gf9Y/4H/cP+B/3j/gf9G
|
||||
7OH/AQEA/wACAP7/////////////////////////////////////////////
|
||||
////////////////////////////////////////AAAAAAAAAAAAAAAAAAAA
|
||||
AFcAAAAAAAAAAAAAAAAAAAI=
|
||||
DisableDebug: false
|
||||
EnableInterruptNumbers: []
|
||||
EnableSystemCalls:
|
||||
ArbitrateAddress: 34
|
||||
Break: 60
|
||||
CancelTimer: 28
|
||||
ClearEvent: 25
|
||||
ClearTimer: 29
|
||||
CloseHandle: 35
|
||||
ConnectToPort: 45
|
||||
ControlMemory: 1
|
||||
CreateAddressArbiter: 33
|
||||
CreateEvent: 23
|
||||
CreateMemoryBlock: 30
|
||||
CreateMutex: 19
|
||||
CreateSemaphore: 21
|
||||
CreateThread: 8
|
||||
CreateTimer: 26
|
||||
DuplicateHandle: 39
|
||||
ExitProcess: 3
|
||||
ExitThread: 9
|
||||
GetCurrentProcessorNumber: 17
|
||||
GetHandleInfo: 41
|
||||
GetProcessAffinityMask: 4
|
||||
GetProcessId: 53
|
||||
GetProcessIdOfThread: 54
|
||||
GetProcessIdealProcessor: 6
|
||||
GetProcessInfo: 43
|
||||
GetResourceLimit: 56
|
||||
GetResourceLimitCurrentValues: 58
|
||||
GetResourceLimitLimitValues: 57
|
||||
GetSystemInfo: 42
|
||||
GetSystemTick: 40
|
||||
GetThreadAffinityMask: 13
|
||||
GetThreadContext: 59
|
||||
GetThreadId: 55
|
||||
GetThreadIdealProcessor: 15
|
||||
GetThreadInfo: 44
|
||||
GetThreadPriority: 11
|
||||
MapMemoryBlock: 31
|
||||
OutputDebugString: 61
|
||||
QueryMemory: 2
|
||||
ReleaseMutex: 20
|
||||
ReleaseSemaphore: 22
|
||||
SendSyncRequest1: 46
|
||||
SendSyncRequest2: 47
|
||||
SendSyncRequest3: 48
|
||||
SendSyncRequest4: 49
|
||||
SendSyncRequest: 50
|
||||
SetProcessAffinityMask: 5
|
||||
SetProcessIdealProcessor: 7
|
||||
SetThreadAffinityMask: 14
|
||||
SetThreadIdealProcessor: 16
|
||||
SetThreadPriority: 12
|
||||
SetTimer: 27
|
||||
SignalEvent: 24
|
||||
SleepThread: 10
|
||||
UnmapMemoryBlock: 32
|
||||
WaitSynchronization1: 36
|
||||
WaitSynchronizationN: 37
|
||||
FileSystemAccess:
|
||||
- CategoryHardwareCheck
|
||||
- Core
|
||||
- DirectSdmc
|
||||
- Debug
|
||||
- CtrNandRw
|
||||
- CtrNandRo
|
||||
- CtrNandRoWrite
|
||||
- ExportImportIvs
|
||||
HandleTableSize: 512
|
||||
IORegisterMapping:
|
||||
- 1ff50000-1ff57fff
|
||||
- 1ff70000-1ff77fff
|
||||
- 1ec46000-1ec46fff
|
||||
IdealProcessor: 1
|
||||
IoAccessControl:
|
||||
- FsMountNand
|
||||
- FsMountNandRoWrite
|
||||
- FsMountCardSpi
|
||||
- FsMountTwln
|
||||
- CreateSeed
|
||||
MemoryMapping:
|
||||
- 1f000000-1f5fffff:r
|
||||
MemoryType: Application
|
||||
Priority: 24
|
||||
ProgramId: 0x00040000ffffff00L
|
||||
ServiceAccessControl:
|
||||
- APT:U
|
||||
- ac:i
|
||||
- ac:u
|
||||
- am:u
|
||||
- cam:c
|
||||
- cdc:CHK
|
||||
- cfg:i
|
||||
- cfg:nor
|
||||
- csnd:SND
|
||||
- dsp::DSP
|
||||
- fs:LDR
|
||||
- fs:USER
|
||||
- gsp::Gpu
|
||||
- gsp::Lcd
|
||||
- hid:SPVR
|
||||
- hid:USER
|
||||
- i2c::EEP
|
||||
- ir:u
|
||||
- mcu::HWC
|
||||
- mic:u
|
||||
- mp:u
|
||||
- ndm:u
|
||||
- ns:s
|
||||
- nwm::EXT
|
||||
- nwm::UDS
|
||||
- ps:ps
|
||||
- ptm:sysm
|
||||
- ptm:u
|
||||
- pxi:dev
|
||||
- soc:U
|
||||
- ssl:C
|
||||
- y2r:u
|
||||
Signature: |
|
||||
e0CSCrqD3wPFl2u8hu451WhejFQAZDOZsOkUWq7YOgMSZOxV97TpVvSJtS2Y
|
||||
bFRBowRLK2rYEiEEyl0cUmlKKS8ZuaHmy5FEunsKFqksp9SFq4yjG95RKjK/
|
||||
q9Msu1hvmHo1/YnQbtRZSd9MPlxNB0ed0Ue2HZxL1JMipSz0OAaNT+MNQ2yU
|
||||
JhIpVcKoV6ZbDGuw68CFy51vvERHpr5pXN8QcBkEoR9li1rWf/ZOx4mQuEKv
|
||||
acb3N/c2eLs2x9xY6W07PJ8+XZnO6yM9NLv1kE2Z2+4p1JG6jLNqyP5cwO7k
|
||||
jxzVx4PzDQSHwfegM3kBvZjzA//o4OikZQhdmRQPsQ==
|
||||
StorageId:
|
||||
- 0
|
||||
CommonHeaderKey:
|
||||
D: |
|
||||
2GXY4PQJVuIf0Eq0/ptFqXSsUAoKTEjsvzXEjuq2FeOksquwh1RQ2SWS8Wa/
|
||||
7ddQitmIlC6gQza4FMIvSE+mfNXheE3MQlvBaLLfsf659NE33IeAQpEaZLq7
|
||||
Rv2FUxO+L4DxwtSK/Q7i0Ixl35XOKklhWfks3AUPCeSET17gyd8PpVlKbcZh
|
||||
jK9v5TqzMrooQji65HkXXMp1jf4Xv24Me+1VFRDxPzO0Mo/c+QCrI3NiwwoC
|
||||
gSnjXC3d1mJxkEovOZ8NOxE0YKSY2+7edhoRZSWSIhNWp9a+jMoeTiQaJbqK
|
||||
mZXxIG9akIUMeMCORaTfEukYWk+6DlcCZ/e7yfURQQ==
|
||||
DP: |
|
||||
kSu2W+RJCEsDBXMwxv7C5i0vSGXzw2AuR6wzwD64H2olm8gFPBsCnLoyAdHE
|
||||
DJaMtssBpD7piDBDMlFqZ67ai4oGJFyUgjOAdzvEfsc30HMbfEgUdE9zST8h
|
||||
5qep/HxGtLnJ0699D4MTArkkuxGRgbYh7DRCSp+8xE2N0A2Jd/k=
|
||||
DQ: |
|
||||
ZU1KBdyU4QhHEu+wrIIzf27/6xI1tu5nov0rRVBEsyj7FRr0X+BkF8KcBvT7
|
||||
l9vkiWgPcF3GyjWMwmuAnu8equh3YeVlfbmyseaeGtVzFStCXUWb6uGOOhPU
|
||||
eKDix+LFcPu+s/lpUMgvNWNBvlOczHsBZ/T1TYYK4gqml80qxUU=
|
||||
Exponent: |
|
||||
AQAB
|
||||
InverseQ: |
|
||||
UE3F4n7dFZv4UC/y0/sZ/Gq4fh3bztdKMCWJwQMzXgo7vwFMoLKikx1HsqIN
|
||||
6ufBvEqfzTRqtv43fR+oONOfI1gH5HDtNSpWCcM+heVQ9YjdBqWU2FkFVH+V
|
||||
feByXnjkJG+ojvPjEQd6N0PWc35VYn/Ak/jQVgNmbVrMNGST2vI=
|
||||
Modulus: |
|
||||
5C7+erLWS6NNWNj5akUEmYfRGLTyOCmfONoFwLrr3n7XQ9lDInRJVutjpBr1
|
||||
tIFLgDCVp/u8D8eRVJAUmt4Whjq2aXETRvo/vxptv5s3vEw8bHk/ifkzENv7
|
||||
683VKmFHJ9WyDWd92ShuUbdmwlR6crPD6QsRH4rev2WU/VgUd0qFozV8/Q+i
|
||||
GQaR4otY7d+YI0QECkCcIxst+3LGxrqqA6ooO7v3f6F+NHs50GbmTQyt2sYJ
|
||||
h8MshKb0bMnUjEeN+2CMRCREjlpDesN93YFP57vVHiVHPWmjYMm+dFRfHjhU
|
||||
uXAUOauI26P6U+7u5oHzQQQ2n1VkazElql9X03fYdw==
|
||||
P: |
|
||||
/nfZRR6EX1btIewMjxL+QOlHDng1hrIzYTf6Y2/iaF2X6N4upLdGW/LYSW1K
|
||||
83JNDY4tL5Pa6Ox+xYCfBmPfpKnR6+pee1uT8Z9mJiZxmubbYJ+gAY98RCi4
|
||||
h0FFZ0UfeejRx0KWIwDdxtdhEPEax+7vOhQXw/p2nqZfPZ6d9as=
|
||||
Q: |
|
||||
5Y6jn//0FQq4aMsN9fzUxh+GJev8AlaA+0oHcJAfnPtoejT2xmik/zxyRYe6
|
||||
XL5ZtvF/4mARoejRLt8/wz1Y/IN8V9DVLTLNukcmZxU8B2Kl5zuS2F3EWp/L
|
||||
tU29P0/vCbiHUoH42XtZLVVriR2wkM/j16g82dEbd7KJGWAtxGU=
|
||||
DefaultSpec:
|
||||
AccessControlInfo:
|
||||
AffinityMask: 1
|
||||
FirmwareVersion: 2
|
||||
HandleTableSize: 512
|
||||
IORegisterMapping:
|
||||
- 1ff50000-1ff57fff
|
||||
- 1ff70000-1ff77fff
|
||||
IdealProcessor: 0
|
||||
MemoryMapping:
|
||||
- 1f000000-1f5fffff:r
|
||||
Priority: 16
|
||||
BasicInfo:
|
||||
CompanyCode: "00"
|
||||
Title: default
|
||||
ExeFs:
|
||||
ReadOnly:
|
||||
- RO
|
||||
ReadWrite:
|
||||
- RW
|
||||
Text:
|
||||
- STUP_ENTRY
|
||||
Media:
|
||||
MediaType: Card
|
||||
PlainRegion:
|
||||
- .module_id
|
||||
Rom:
|
||||
DefaultReject:
|
||||
- .*
|
||||
File:
|
||||
- "*"
|
||||
SystemControlInfo:
|
||||
Dependency:
|
||||
ac: 0x0004013000002402L
|
||||
am: 0x0004013000001502L
|
||||
boss: 0x0004013000003402L
|
||||
camera: 0x0004013000001602L
|
||||
cecd: 0x0004013000002602L
|
||||
cfg: 0x0004013000001702L
|
||||
codec: 0x0004013000001802L
|
||||
csnd: 0x0004013000002702L
|
||||
dlp: 0x0004013000002802L
|
||||
dsp: 0x0004013000001a02L
|
||||
friends: 0x0004013000003202L
|
||||
gpio: 0x0004013000001b02L
|
||||
gsp: 0x0004013000001c02L
|
||||
hid: 0x0004013000001d02L
|
||||
http: 0x0004013000002902L
|
||||
i2c: 0x0004013000001e02L
|
||||
ir: 0x0004013000003302L
|
||||
mcu: 0x0004013000001f02L
|
||||
mic: 0x0004013000002002L
|
||||
mp: 0x0004013000002a02L
|
||||
ndm: 0x0004013000002b02L
|
||||
nim: 0x0004013000002c02L
|
||||
nwm: 0x0004013000002d02L
|
||||
pdn: 0x0004013000002102L
|
||||
ptm: 0x0004013000002202L
|
||||
socket: 0x0004013000002e02L
|
||||
spi: 0x0004013000002302L
|
||||
ssl: 0x0004013000002f02L
|
||||
StackSize: 16384
|
||||
TitleInfo:
|
||||
Use: Evaluation
|
||||
16
tags/0thNUP_2/CardSaveDataMover/ImpRun/ImportAndRun.rsf
Normal file
16
tags/0thNUP_2/CardSaveDataMover/ImpRun/ImportAndRun.rsf
Normal file
@ -0,0 +1,16 @@
|
||||
BasicInfo:
|
||||
Title : $(TITLE)
|
||||
BackupMemoryType: None
|
||||
Logo : Nintendo
|
||||
# Companycode: "00"
|
||||
ProductCode : "CTR-N-22MA"
|
||||
# MediaSize: 2GB
|
||||
|
||||
Rom:
|
||||
HostRoot : $(ROMFS_ROOT)
|
||||
|
||||
|
||||
TitleInfo:
|
||||
# UniqueId: 0xffff6
|
||||
UniqueId: 0xf8015
|
||||
Version: 0
|
||||
63
tags/0thNUP_2/CardSaveDataMover/ImpRun/OMakefile
Normal file
63
tags/0thNUP_2/CardSaveDataMover/ImpRun/OMakefile
Normal file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env omake
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: Horizon
|
||||
# File: OMakefile
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# $Rev: 31765 $
|
||||
#----------------------------------------------------------------------------
|
||||
SUPPORTED_TARGETS = CTR-*.Process.MPCore.*
|
||||
|
||||
#demoライブラリ位置指定
|
||||
#SAMPLED_DEMOS_COMMON_INCLUDE_DIR = $(dir ../common/include)
|
||||
SAMPLED_DEMOS_COMMON_INCLUDE_DIR = $(dir ../CTR_SDK/sampledemos/common/include)
|
||||
INCLUDES += $(SAMPLED_DEMOS_COMMON_INCLUDE_DIR)
|
||||
|
||||
|
||||
SOURCES[] =
|
||||
main.cpp
|
||||
sleep.cpp
|
||||
test_data.cpp
|
||||
|
||||
TARGET_PROGRAM = CtrSaveDataMover_imp
|
||||
|
||||
TITLE = Importer
|
||||
|
||||
LIBS += libnn_am lib_demo
|
||||
|
||||
IMPORTEE_CIA = importee.cia
|
||||
|
||||
SRC_IMPORTEE_PATH = ../SaveDataTool/images/$(BUILD_TARGET_DIR)/$(BUILD_TYPE_DIR)/CtrSaveDataMover.cia
|
||||
#とりあえず、マスタリング時は直おき
|
||||
#SRC_IMPORTEE_PATH = CtrSaveDataMover_master.cia
|
||||
|
||||
# ビルドタイプ別に romfs を作る
|
||||
ROMFS_ROOT = $`(TARGET.getObjectDirectory)/romfsroot
|
||||
DEST_IMPORTEE_PATH = $(ROMFS_ROOT)/$(IMPORTEE_CIA)
|
||||
foreach(TARGET, $(BUILDER.getTargets $(SUPPORTED_TARGETS)))
|
||||
$(DEST_IMPORTEE_PATH): $(SRC_IMPORTEE_PATH) $(makeDirectory $(ROMFS_ROOT))
|
||||
cp $< $@
|
||||
ROMFS_DEPENDENCIES = $(DEST_IMPORTEE_PATH)
|
||||
|
||||
# プログラムから参照するためのROMFSのパスとプログラムIDを定義する
|
||||
ROMFS_IMPORTEE_PATH = L\"rom:/$(IMPORTEE_CIA)\"
|
||||
CCFLAGS += -DROMFS_IMPORTEE_PATH=$(ROMFS_IMPORTEE_PATH)
|
||||
|
||||
ROM_SPEC_FILE = ImportAndRun.rsf
|
||||
#DESCRIPTOR = HwCheckProgram.desc
|
||||
DESCRIPTOR = $(CTRSDK_ROOT)/resources/specfiles/repairtool.desc
|
||||
|
||||
# バナー、アイコン
|
||||
CTR_BANNER_SPEC = banner.bsf
|
||||
|
||||
include $(ROOT_OMAKE)/modulerules
|
||||
|
||||
build: $(DEFAULT_TARGETS)
|
||||
|
||||
73
tags/0thNUP_2/CardSaveDataMover/ImpRun/OMakeroot
Normal file
73
tags/0thNUP_2/CardSaveDataMover/ImpRun/OMakeroot
Normal file
@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env omake
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: Horizon
|
||||
# File: OMakeroot
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# $Rev:$
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# ディレクトリレイアウトについての説明
|
||||
#
|
||||
# a) ソースコードがルートディレクトリ直下に配置される場合
|
||||
# 例:
|
||||
# /OMakeroot
|
||||
# /foo/bar/OMakefile
|
||||
#
|
||||
# 結果:
|
||||
# OMakefile と同じディレクトリ以下に objects や images が生成されます。
|
||||
#
|
||||
# /foo/bar/objects/...
|
||||
# /foo/bar/images/..
|
||||
#
|
||||
#
|
||||
# b) ソースコードが sources 以下に配置される場合
|
||||
# 例:
|
||||
# /OMakeroot
|
||||
# /sources/foo/bar/OMakefile
|
||||
#
|
||||
# 結果:
|
||||
# ルートディレクトリ以下に objects や images が生成されます。
|
||||
#
|
||||
# /objects/foo/bar/...
|
||||
# /images/foo/bar/...
|
||||
#
|
||||
#
|
||||
|
||||
# ルート環境変数の取得
|
||||
public.HORIZON_ROOT =
|
||||
if $(defined-env HORIZON_ROOT)
|
||||
HORIZON_ROOT = $(absname $(getenv HORIZON_ROOT))
|
||||
export
|
||||
|
||||
if $(defined-env CTRSDK_ROOT)
|
||||
CTRSDK_ROOT = $(absname $(getenv CTRSDK_ROOT))
|
||||
if $(and $(defined-env HORIZON_ROOT), $(not $(equal $(HORIZON_ROOT), $(CTRSDK_ROOT))))
|
||||
eprintln(HORIZON_ROOT と CTRSDK_ROOT が一致しません。同じパスを設定するか、どちらか一方だけを定義して下さい。)
|
||||
exit(1)
|
||||
HORIZON_ROOT = $(CTRSDK_ROOT)
|
||||
export
|
||||
|
||||
if $(not $(HORIZON_ROOT))
|
||||
eprintln($"$$CTRSDK_ROOT が定義されていません")
|
||||
exit(1)
|
||||
|
||||
include $(HORIZON_ROOT)/build/omake/commondefs
|
||||
|
||||
DefineCommandVars()
|
||||
|
||||
.PHONY: all build clean clobber
|
||||
.PHONY: run run-scripts
|
||||
|
||||
#
|
||||
# OMakefile の読み込み
|
||||
#
|
||||
.SUBDIRS: .
|
||||
|
||||
BIN
tags/0thNUP_2/CardSaveDataMover/ImpRun/banner.bsf
Normal file
BIN
tags/0thNUP_2/CardSaveDataMover/ImpRun/banner.bsf
Normal file
Binary file not shown.
@ -0,0 +1,274 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<NintendoWareIntermediateFile>
|
||||
<GraphicsContentCtr Version="1.3.0" Namespace="">
|
||||
<EditData>
|
||||
<MetaData>
|
||||
<Key>MetaData</Key>
|
||||
<Create Author="" Date="2010-12-02T15:21:10" Source="COMMON.mb">
|
||||
<ToolDescriptions Name="NW4C_Export for Maya 2009 Service Pack 1" Version="1.2.0" />
|
||||
</Create>
|
||||
<Modify Date="2011-02-28T13:27:46">
|
||||
<ToolDescriptions Name="NintendoWare Creative Studio For Banner." Version="1.3.0.30235" />
|
||||
</Modify>
|
||||
</MetaData>
|
||||
<ContentSummaryMetaData>
|
||||
<Key>ContentSummaries</Key>
|
||||
<Values>
|
||||
<ContentSummary ContentTypeName="GraphicsContent">
|
||||
<ObjectSummaries>
|
||||
<ObjectSummary TypeName="SkeletalModel" Name="">
|
||||
<Notes>
|
||||
<Note Name="MaterialCount" Value="1" />
|
||||
<Note Name="ShapeCount" Value="1" />
|
||||
<Note Name="MeshCount" Value="1" />
|
||||
<Note Name="BoneCount" Value="1" />
|
||||
<Note Name="TotalPrimitiveSetCount" Value="1" />
|
||||
<Note Name="TotalNoneSkinningPrimitiveSetCount" Value="1" />
|
||||
<Note Name="TotalRigidSkinningPrimitiveSetCount" Value="0" />
|
||||
<Note Name="TotalSmoothSkinningPrimitiveSetCount" Value="0" />
|
||||
<Note Name="TotalIndexStreamCount" Value="1" />
|
||||
<Note Name="TotalPolygonCount" Value="2" />
|
||||
<Note Name="TotalVertexCount" Value="4" />
|
||||
</Notes>
|
||||
</ObjectSummary>
|
||||
</ObjectSummaries>
|
||||
</ContentSummary>
|
||||
</Values>
|
||||
</ContentSummaryMetaData>
|
||||
</EditData>
|
||||
<Models>
|
||||
<SkeletalModel Name="" IsBranchVisible="true" IsVisible="true" CullingMode="Dynamic" IsNonuniformScalable="false" LayerId="0" NeededBoneCapacity="20">
|
||||
<EditData>
|
||||
<ModelDccToolExportOption ExportStartFrame="0" Magnify="1" AdjustSkinning="None" MeshVisibilityMode="BindByIndex">
|
||||
<Key>ModelDccToolInfo</Key>
|
||||
</ModelDccToolExportOption>
|
||||
<OptimizationLogArrayMetaData Size="1">
|
||||
<Key>OptimizationLogs</Key>
|
||||
<Values>
|
||||
<OptimizationLog Date="2010-12-02T15:21" EditorVersion="1.2.0.27817">
|
||||
<Options NodeCompressionMode="None" IsMergeMeshOwnerBoneEnabled="false" IsCombineMeshEnabled="false" IsCompressMaterialEnabled="false" IsOptimizePlygonPrimitiveEnabled="false" IsConvertOneBoneSkeletalModelToModel="true" IsDeleteUnusedVertexEnabled="false" PositionQuantizeMode="Float" NormalQuantizeMode="Float" TextureQuantizeMode="Float" GroupByIndexStream="false" />
|
||||
</OptimizationLog>
|
||||
</Values>
|
||||
</OptimizationLogArrayMetaData>
|
||||
</EditData>
|
||||
<AnimationGroupDescriptions>
|
||||
<GraphicsAnimationGroupDescription Name="SkeletalAnimation" EvaluationTiming="AfterSceneCulling">
|
||||
<MemberInformationSet>
|
||||
<AnimationMemberDescription BlendOperationName="CalculatedTransform" IsBinarized="true">
|
||||
<Path>Skeleton.Bones["*"].AnimatedTransform</Path>
|
||||
</AnimationMemberDescription>
|
||||
</MemberInformationSet>
|
||||
</GraphicsAnimationGroupDescription>
|
||||
<GraphicsAnimationGroupDescription Name="VisibilityAnimation" EvaluationTiming="BeforeWorldUpdate">
|
||||
<MemberInformationSet>
|
||||
<AnimationMemberDescription BlendOperationName="Bool" IsBinarized="true">
|
||||
<Path>IsVisible</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="Bool" IsBinarized="true">
|
||||
<Path>Meshes["*"].IsVisible</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="Bool" IsBinarized="true">
|
||||
<Path>IsBranchVisible</Path>
|
||||
</AnimationMemberDescription>
|
||||
</MemberInformationSet>
|
||||
</GraphicsAnimationGroupDescription>
|
||||
<GraphicsAnimationGroupDescription Name="MaterialAnimation" EvaluationTiming="AfterSceneCulling">
|
||||
<MemberInformationSet>
|
||||
<AnimationMemberDescription BlendOperationName="RgbaColor" IsBinarized="true">
|
||||
<Path>Materials["*"].MaterialColor.Emission</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="RgbaColor" IsBinarized="true">
|
||||
<Path>Materials["*"].MaterialColor.Ambient</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="RgbaColor" IsBinarized="true">
|
||||
<Path>Materials["*"].MaterialColor.Diffuse</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="RgbaColor" IsBinarized="true">
|
||||
<Path>Materials["*"].MaterialColor.Specular0</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="RgbaColor" IsBinarized="true">
|
||||
<Path>Materials["*"].MaterialColor.Specular1</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="RgbaColor" IsBinarized="true">
|
||||
<Path>Materials["*"].MaterialColor.Constant0</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="RgbaColor" IsBinarized="true">
|
||||
<Path>Materials["*"].MaterialColor.Constant1</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="RgbaColor" IsBinarized="true">
|
||||
<Path>Materials["*"].MaterialColor.Constant2</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="RgbaColor" IsBinarized="true">
|
||||
<Path>Materials["*"].MaterialColor.Constant3</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="RgbaColor" IsBinarized="true">
|
||||
<Path>Materials["*"].MaterialColor.Constant4</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="RgbaColor" IsBinarized="true">
|
||||
<Path>Materials["*"].MaterialColor.Constant5</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="RgbaColor" IsBinarized="true">
|
||||
<Path>Materials["*"].TextureMappers["*"].Sampler.BorderColor</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="Int" IsBinarized="true">
|
||||
<Path>Materials["*"].TextureMappers["*"].Texture</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="RgbaColor" IsBinarized="true">
|
||||
<Path>Materials["*"].FragmentOperation.BlendOperation.BlendColor</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="Vector2" IsBinarized="true">
|
||||
<Path>Materials["*"].TextureCoordinators["*"].Scale</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="Float" IsBinarized="true">
|
||||
<Path>Materials["*"].TextureCoordinators["*"].Rotate</Path>
|
||||
</AnimationMemberDescription>
|
||||
<AnimationMemberDescription BlendOperationName="Vector2" IsBinarized="true">
|
||||
<Path>Materials["*"].TextureCoordinators["*"].Translate</Path>
|
||||
</AnimationMemberDescription>
|
||||
</MemberInformationSet>
|
||||
</GraphicsAnimationGroupDescription>
|
||||
</AnimationGroupDescriptions>
|
||||
<Transform>
|
||||
<Scale X="1" Y="1" Z="1" />
|
||||
<Rotate X="0" Y="0" Z="0" />
|
||||
<Translate X="0" Y="0" Z="0" />
|
||||
</Transform>
|
||||
<Shapes>
|
||||
<SeparateDataShapeCtr>
|
||||
<OrientedBoundingBox>
|
||||
<CenterPosition X="0" Y="0" Z="6.5" />
|
||||
<OrientationMatrix M00="1" M01="0" M02="0" M10="0" M11="1" M12="0" M20="0" M21="0" M22="1" />
|
||||
<Size X="24" Y="12" Z="0" />
|
||||
</OrientedBoundingBox>
|
||||
<PositionOffset X="0" Y="0" Z="0" />
|
||||
<PrimitiveSets>
|
||||
<PrimitiveSetCtr SkinningMode="None">
|
||||
<BoneIndexTable>0</BoneIndexTable>
|
||||
<Primitives>
|
||||
<PrimitiveCtr>
|
||||
<IndexStreams>
|
||||
<UbyteIndexStreamCtr PrimitiveMode="Triangles" Size="6">0 1 2 1 3 2</UbyteIndexStreamCtr>
|
||||
</IndexStreams>
|
||||
</PrimitiveCtr>
|
||||
</Primitives>
|
||||
</PrimitiveSetCtr>
|
||||
</PrimitiveSets>
|
||||
<VertexAttributes>
|
||||
<Vector3VertexStreamCtr Usage="Position" VertexSize="4" Scale="1" QuantizedMode="Float">
|
||||
-12 -6 6.5
|
||||
12 -6 6.5
|
||||
-12 6 6.5
|
||||
12 6 6.5
|
||||
</Vector3VertexStreamCtr>
|
||||
<Vector3VertexAttributeCtr Usage="Normal">0 0 1</Vector3VertexAttributeCtr>
|
||||
<Vector2VertexStreamCtr Usage="TextureCoordinate0" VertexSize="4" Scale="1" QuantizedMode="Float">
|
||||
0 0
|
||||
1 0
|
||||
0 1
|
||||
1 1
|
||||
</Vector2VertexStreamCtr>
|
||||
</VertexAttributes>
|
||||
</SeparateDataShapeCtr>
|
||||
</Shapes>
|
||||
<Materials>
|
||||
<MaterialCtr Name="MT_00" IsCompressible="true" LightSetIndex="0" FogIndex="0" IsFragmentLightEnabled="false" IsVertexLightEnabled="false" IsHemiSphereLightEnabled="false" IsHemiSphereOcclusionEnabled="false" IsFogEnabled="false" TextureCoordinateConfig="Config0120" TranslucencyKind="Layer1" ShaderProgramDescriptionIndex="-1" ShaderBinaryKind="Default">
|
||||
<ShaderReference />
|
||||
<MaterialColor VertexColorScale="1">
|
||||
<Emission R="0" G="0" B="0" A="0" />
|
||||
<Ambient R="1" G="1" B="1" A="0" />
|
||||
<Diffuse R="1" G="1" B="1" A="1" />
|
||||
<Specular0 R="1" G="1" B="1" A="0" />
|
||||
<Specular1 R="0" G="0" B="0" A="0" />
|
||||
<Constant0 R="0" G="0" B="0" A="1" />
|
||||
<Constant1 R="0" G="0" B="0" A="1" />
|
||||
<Constant2 R="0" G="0" B="0" A="1" />
|
||||
<Constant3 R="0" G="0" B="0" A="1" />
|
||||
<Constant4 R="0" G="0" B="0" A="1" />
|
||||
<Constant5 R="0" G="0" B="0" A="1" />
|
||||
</MaterialColor>
|
||||
<Rasterization CullingMode="BackFace" IsPolygonOffsetEnabled="false" PolygonOffsetUnit="0" />
|
||||
<TextureCoordinators>
|
||||
<TextureCoordinatorCtr SourceCoordinate="0" MappingMethod="UvCoordinateMap" ReferenceCamera="0" MatrixMode="DccMaya" ScaleS="1" ScaleT="1" Rotate="0" TranslateS="0" TranslateT="0" />
|
||||
</TextureCoordinators>
|
||||
<TextureMappers>
|
||||
<PixelBasedTextureMapperCtr>
|
||||
<TextureReference>Textures["banner_imp"]@file:Textures/banner_imp.ctex</TextureReference>
|
||||
<StandardTextureSamplerCtr MinFilter="Linear" MagFilter="Linear" WrapS="ClampToEdge" WrapT="ClampToEdge" MinLod="0" LodBias="0">
|
||||
<BorderColor R="0" G="0" B="0" A="1" />
|
||||
</StandardTextureSamplerCtr>
|
||||
</PixelBasedTextureMapperCtr>
|
||||
</TextureMappers>
|
||||
<FragmentShader LayerConfig="ConfigurationType0">
|
||||
<BufferColor R="0" G="0" B="0" A="1" />
|
||||
<FragmentBump BumpTextureIndex="Texture0" BumpMode="NotUsed" IsBumpRenormalize="false" />
|
||||
<FragmentLighting FresnelConfig="No" IsClampHighLight="false" IsDistribution0Enabled="false" IsDistribution1Enabled="false" IsGeometricFactor0Enabled="false" IsGeometricFactor1Enabled="false" IsReflectionEnabled="false" />
|
||||
<FragmentLightingTable>
|
||||
<ReflectanceRSampler IsAbs="true" Input="CosNormalHalf" Scale="One">
|
||||
<NullLookupTableCtr />
|
||||
</ReflectanceRSampler>
|
||||
<ReflectanceGSampler IsAbs="true" Input="CosNormalHalf" Scale="One">
|
||||
<NullLookupTableCtr />
|
||||
</ReflectanceGSampler>
|
||||
<ReflectanceBSampler IsAbs="true" Input="CosNormalHalf" Scale="One">
|
||||
<NullLookupTableCtr />
|
||||
</ReflectanceBSampler>
|
||||
<Distribution0Sampler IsAbs="true" Input="CosNormalHalf" Scale="One">
|
||||
<NullLookupTableCtr />
|
||||
</Distribution0Sampler>
|
||||
<Distribution1Sampler IsAbs="true" Input="CosNormalHalf" Scale="One">
|
||||
<NullLookupTableCtr />
|
||||
</Distribution1Sampler>
|
||||
<FresnelSampler IsAbs="true" Input="CosNormalHalf" Scale="One">
|
||||
<NullLookupTableCtr />
|
||||
</FresnelSampler>
|
||||
</FragmentLightingTable>
|
||||
<TextureCombiners>
|
||||
<TextureCombinerCtr CombineRgb="Replace" CombineAlpha="Replace" ScaleRgb="One" ScaleAlpha="One" Constant="Constant0" BufferInputRgb="PreviousBuffer" BufferInputAlpha="PreviousBuffer">
|
||||
<SourceRgb Source0="Texture0" Source1="FragmentPrimaryColor" Source2="FragmentSecondaryColor" />
|
||||
<OperandRgb Operand0="Color" Operand1="Color" Operand2="Color" />
|
||||
<SourceAlpha Source0="Texture0" Source1="Constant" Source2="Constant" />
|
||||
<OperandAlpha Operand0="Alpha" Operand1="Alpha" Operand2="Alpha" />
|
||||
</TextureCombinerCtr>
|
||||
</TextureCombiners>
|
||||
<AlphaTest IsTestEnabled="false" TestFunction="Always" TestReference="0" />
|
||||
</FragmentShader>
|
||||
<FragmentOperation>
|
||||
<DepthOperation IsTestEnabled="true" TestFunction="Less" IsMaskEnabled="false" />
|
||||
<BlendOperation Mode="Blend" LogicOperation="Copy">
|
||||
<RgbParameter BlendFunctionSource="SourceAlpha" BlendFunctionDestination="OneMinusSourceAlpha" BlendEquation="FuncAdd" />
|
||||
<AlphaParameter BlendFunctionSource="One" BlendFunctionDestination="Zero" BlendEquation="FuncAdd" />
|
||||
<BlendColor R="0" G="0" B="0" A="1" />
|
||||
</BlendOperation>
|
||||
<StencilOperation IsTestEnabled="false" TestFunction="Never" TestReference="0" TestMask="255" FailOperation="Keep" ZFailOperation="Keep" PassOperation="Keep" />
|
||||
</FragmentOperation>
|
||||
</MaterialCtr>
|
||||
</Materials>
|
||||
<Meshes>
|
||||
<Mesh IsVisible="true" RenderPriority="0" MeshNodeName="BONE_00">
|
||||
<EditData>
|
||||
<DccToolSourceNodeMetaData>
|
||||
<Key>DccToolSourceNode</Key>
|
||||
<Values>
|
||||
<NodeName>BONE_00</NodeName>
|
||||
</Values>
|
||||
</DccToolSourceNodeMetaData>
|
||||
</EditData>
|
||||
<SeparateShapeReference>Shapes[0]</SeparateShapeReference>
|
||||
<MaterialReference>Materials["MT_00"]</MaterialReference>
|
||||
</Mesh>
|
||||
</Meshes>
|
||||
<Skeleton RootBoneName="BONE_00" ScalingRule="Standard" IsTranslateAnimationEnabled="true">
|
||||
<Bones>
|
||||
<Bone Name="BONE_00" ParentBoneName="" IsSegmentScaleCompensate="false" IsCompressible="true" IsNeededRendering="true" HasSkinningMatrix="false" BillboardMode="YAxial">
|
||||
<Transform>
|
||||
<Scale X="1" Y="1" Z="1" />
|
||||
<Rotate X="0" Y="0" Z="0" />
|
||||
<Translate X="0" Y="0" Z="0" />
|
||||
</Transform>
|
||||
</Bone>
|
||||
</Bones>
|
||||
</Skeleton>
|
||||
</SkeletalModel>
|
||||
</Models>
|
||||
</GraphicsContentCtr>
|
||||
</NintendoWareIntermediateFile>
|
||||
File diff suppressed because one or more lines are too long
BIN
tags/0thNUP_2/CardSaveDataMover/ImpRun/banner/banner_dummy.bcwav
Normal file
BIN
tags/0thNUP_2/CardSaveDataMover/ImpRun/banner/banner_dummy.bcwav
Normal file
Binary file not shown.
BIN
tags/0thNUP_2/CardSaveDataMover/ImpRun/banner/banner_imp.cbmd
Normal file
BIN
tags/0thNUP_2/CardSaveDataMover/ImpRun/banner/banner_imp.cbmd
Normal file
Binary file not shown.
BIN
tags/0thNUP_2/CardSaveDataMover/ImpRun/banner/icon2_24.ctpk
Normal file
BIN
tags/0thNUP_2/CardSaveDataMover/ImpRun/banner/icon2_24.ctpk
Normal file
Binary file not shown.
BIN
tags/0thNUP_2/CardSaveDataMover/ImpRun/banner/icon2_48.ctpk
Normal file
BIN
tags/0thNUP_2/CardSaveDataMover/ImpRun/banner/icon2_48.ctpk
Normal file
Binary file not shown.
294
tags/0thNUP_2/CardSaveDataMover/ImpRun/main.cpp
Normal file
294
tags/0thNUP_2/CardSaveDataMover/ImpRun/main.cpp
Normal file
@ -0,0 +1,294 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
//#include <nn/srv.h>
|
||||
#include <nn/fs.h>
|
||||
//#include <nn/ns/CTR/ns_ApiShell.h>
|
||||
//#include <nn/ns/CTR/ns_Shell.h>
|
||||
#include <nn/am/am_ApiLocalImporter.h>
|
||||
#include <nn/am/am_ApiSystemMenu.h>
|
||||
#include <nn/applet.h>
|
||||
#include <nn/ndm.h>
|
||||
#include "demo.h"
|
||||
#include "../SaveDataTool/ver.h"
|
||||
#include <stdio.h>
|
||||
#include "sleep.h"
|
||||
#include "test_data.h"
|
||||
|
||||
demo::RenderSystemDrawing s_RenderSystem;
|
||||
nn::fnd::ExpHeap appHeap;
|
||||
uptr heapForGx;
|
||||
|
||||
namespace
|
||||
{
|
||||
bit8 readBuf[64 * 1024];
|
||||
}
|
||||
|
||||
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, sizeof(readBuf)))
|
||||
{
|
||||
stream->Write(readBuf, read);
|
||||
}
|
||||
result = nn::am::EndImportProgram(stream);
|
||||
}
|
||||
return result.IsSuccess();
|
||||
}
|
||||
|
||||
|
||||
//終了処理
|
||||
void finish(void)
|
||||
{
|
||||
|
||||
SleepHandler::Finalize();//SLEEP
|
||||
|
||||
nn::hid::Finalize();
|
||||
|
||||
// nngxFinalize 関数呼び出しと VSync 割り込みが同時に発生すると
|
||||
// 画面が暗転したまま止まる不具合を回避するために VSync 待ちを行う
|
||||
nngxWaitVSync(NN_GX_DISPLAY_BOTH);
|
||||
s_RenderSystem.Finalize();
|
||||
|
||||
nn::fs::Finalize();
|
||||
|
||||
appHeap.Free(reinterpret_cast<void*>(heapForGx));
|
||||
appHeap.Finalize();
|
||||
|
||||
nn::os::SetDeviceMemorySize(0);
|
||||
nn::os::SetHeapSize(0);
|
||||
|
||||
NN_LOG("End\n");
|
||||
nn::applet::PrepareToCloseApplication();
|
||||
nn::applet::CloseApplication();
|
||||
}
|
||||
|
||||
nn::hid::PadReader *hpr;
|
||||
//---------------------------------------------------------------- 入力待ち
|
||||
nn::hid::PadStatus padStatus;
|
||||
u32 WaitKey(u32 mask)
|
||||
{
|
||||
|
||||
while(1){
|
||||
hpr->ReadLatest(&padStatus);
|
||||
if(padStatus.trigger & mask)return padStatus.trigger;
|
||||
|
||||
// 終了要求をチェック
|
||||
if ( nn::applet::IsExpectedToCloseApplication() )
|
||||
{
|
||||
finish();
|
||||
}
|
||||
|
||||
// アプリケーションの遷移処理を行う
|
||||
|
||||
// HOMEボタン処理(グラフィックスライブラリが初期化済みでなければならない)
|
||||
if ( nn::applet::IsExpectedToProcessHomeButton() )
|
||||
{
|
||||
// スリープ要求を REJECT するように
|
||||
nn::applet::DisableSleep();
|
||||
|
||||
nn::applet::ProcessHomeButton();
|
||||
nn::applet::AppletWakeupState wState = nn::applet::WaitForStarting();
|
||||
NN_UNUSED_VAR(wState);
|
||||
|
||||
|
||||
// HOME メニューからの中断やバッテリー不足の要因により
|
||||
// アプリ終了と判断された場合、アプリのメインループを抜けて終了処理へ
|
||||
if ( nn::applet::IsExpectedToCloseApplication() )
|
||||
{
|
||||
// 描画権は渡されていない
|
||||
finish();
|
||||
}
|
||||
|
||||
//nn::applet::EnableSleep(true);
|
||||
|
||||
// グラフィックの設定を戻す
|
||||
nngxUpdateState(NN_GX_STATE_ALL);
|
||||
nngxValidateState(NN_GX_STATE_ALL,GL_TRUE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 電源ボタン処理(グラフィックスライブラリが初期化済みでなければならない)
|
||||
if ( nn::applet::IsExpectedToProcessPowerButton() )
|
||||
{
|
||||
nn::applet::DisableSleep();
|
||||
nn::applet::ProcessPowerButton();
|
||||
nn::applet::AppletWakeupState wState = nn::applet::WaitForStarting();
|
||||
NN_UNUSED_VAR(wState);
|
||||
|
||||
|
||||
// アプリ終了と判断された場合、アプリのメインループを抜けて終了処理へ
|
||||
if ( nn::applet::IsExpectedToCloseApplication() )
|
||||
{
|
||||
// 描画権は渡されていない
|
||||
finish();
|
||||
}
|
||||
|
||||
// nn::applet::EnableSleep(true);
|
||||
|
||||
// グラフィックの設定を戻す
|
||||
nngxUpdateState(NN_GX_STATE_ALL);
|
||||
nngxValidateState(NN_GX_STATE_ALL,GL_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
char ver[16];
|
||||
void nnMain( void )
|
||||
{
|
||||
nn::Result result;
|
||||
|
||||
nn::os::Initialize();
|
||||
nn::fs::Initialize();
|
||||
|
||||
//DEA-SUPにて推奨のフリーズ暫定対策:無線デーモンを停止 (2011.3.1 現在)
|
||||
//ただし、スリープ時の"いつのまに通信"は止まらない
|
||||
//無線は使わないが念の為、本体スイッチで切っとくのが確実
|
||||
nn::ndm::SuspendScheduler();
|
||||
|
||||
SleepHandler::Initialize();
|
||||
|
||||
// アプレットライブラリに関する機能を有効にする
|
||||
nn::applet::Enable(false);
|
||||
// gx, snd, dsp 各ライブラリの Initialize 関数は applet::Enable() の後に呼ばれなければならない
|
||||
// 特に、gx の初期化である nngxInitialize 関数は、Enable() 直後の終了判定の後に行われるべき
|
||||
|
||||
// ロゴ表示時に電源ボタンが押されたなど、既に終了条件が立っていた場合、ここでアプリを終了させる
|
||||
if ( nn::applet::IsExpectedToCloseApplication() )
|
||||
{
|
||||
SleepHandler::Finalize();
|
||||
result = nn::applet::PrepareToCloseApplication();
|
||||
NN_UTIL_PANIC_IF_FAILED( result );
|
||||
nn::applet::CloseApplication();
|
||||
}
|
||||
// グラフィックスライブラリの初期化は、以降で行わなければならない
|
||||
// 他、アプリケーションの初期化処理
|
||||
|
||||
nn::hid::Initialize();
|
||||
nn::hid::PadReader padReader;
|
||||
hpr = &padReader;
|
||||
|
||||
//result = nn::ns::CTR::InitializeForShell();
|
||||
//if (result.IsSuccess())
|
||||
result = nn::am::InitializeForLocalImporter();
|
||||
|
||||
nn::applet::DisableSleep();//スリープ非対応
|
||||
|
||||
const size_t ROMFS_BUFFER_SIZE = 1024 * 64;
|
||||
static char buffer[ROMFS_BUFFER_SIZE];
|
||||
|
||||
// ヒープの確保
|
||||
appHeap.Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize(), nn::os::ALLOCATE_OPTION_LINEAR);
|
||||
|
||||
const u32 s_GxHeapSize = 0x800000;
|
||||
// RenderSystem の準備
|
||||
heapForGx = reinterpret_cast<uptr>(appHeap.Allocate(s_GxHeapSize));
|
||||
s_RenderSystem.Initialize(heapForGx, s_GxHeapSize);
|
||||
s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY0);
|
||||
s_RenderSystem.Clear();
|
||||
s_RenderSystem.SetFontSize(12);
|
||||
s_RenderSystem.SetColor(1.0, 1.0, 1.0,1.0);
|
||||
s_RenderSystem.DrawText(10,20,"CTR Card Savedata Mover Setup");
|
||||
sprintf(ver,"version %.2f",VERSION);
|
||||
s_RenderSystem.DrawText(10,40,ver);
|
||||
|
||||
if (result.IsFailure()){//初期化に失敗
|
||||
s_RenderSystem.SetColor(1.0, 0.0, 0.0,1.0);
|
||||
s_RenderSystem.DrawText(10,70,"Initialize Error");
|
||||
s_RenderSystem.DrawText(10,90,"check *.desc file");
|
||||
s_RenderSystem.DrawText(10,110,"Push B : Quit");
|
||||
s_RenderSystem.SwapBuffers();
|
||||
while(1){
|
||||
padReader.ReadLatest(&padStatus);
|
||||
if(padStatus.trigger & nn::hid::BUTTON_B)break;
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
nn::fs::MountRom(16, 16, buffer, ROMFS_BUFFER_SIZE);
|
||||
|
||||
s_RenderSystem.SetColor(1.0, 1.0, 1.0,1.0);
|
||||
s_RenderSystem.DrawText(10,20,"CTR Card Savedata Mover Setup");
|
||||
sprintf(ver,"version %.2f",VERSION);
|
||||
s_RenderSystem.DrawText(10,40,ver);
|
||||
s_RenderSystem.DrawText(80,100,"Push X : Inport");
|
||||
s_RenderSystem.DrawText(80,140,"Push Y : Delete");
|
||||
s_RenderSystem.DrawText(80,160,"Push R : Test Data");
|
||||
s_RenderSystem.SwapBuffers();
|
||||
|
||||
u32 trg = WaitKey(nn::hid::BUTTON_X | nn::hid::BUTTON_Y | nn::hid::BUTTON_R);
|
||||
if (trg & nn::hid::BUTTON_R)TestMain();//テストデータへ
|
||||
// CIA のプログラム ID を取得する。
|
||||
nn::am::ProgramInfo programInfo;
|
||||
if (nn::am::GetProgramInfoFromCia(&programInfo, ROMFS_IMPORTEE_PATH).IsFailure())
|
||||
{
|
||||
s_RenderSystem.Clear();
|
||||
s_RenderSystem.SetColor(1.0, 0.0, 0.0,1.0);
|
||||
s_RenderSystem.DrawText(10,50,"cia infomation Error");
|
||||
s_RenderSystem.DrawText(10,70,"Push B : Quit");
|
||||
s_RenderSystem.SwapBuffers();
|
||||
|
||||
while(1){
|
||||
padReader.ReadLatest(&padStatus);
|
||||
if(padStatus.trigger & nn::hid::BUTTON_B)break;
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
s_RenderSystem.Clear();
|
||||
if(padStatus.trigger & nn::hid::BUTTON_X)
|
||||
s_RenderSystem.DrawText(50,70,"Inporting");
|
||||
else s_RenderSystem.DrawText(50,70,"Delete");
|
||||
s_RenderSystem.SwapBuffers();
|
||||
|
||||
// 既に存在するものをインポートするとエラーが返ってくるので、あらかじめ消しておく。
|
||||
nn::am::DeleteProgram(nn::fs::MEDIA_TYPE_NAND, programInfo.id);
|
||||
// タイトル鍵が違うケースに対応するために、チケットも消しておく。
|
||||
nn::am::DeleteTicket(programInfo.id);
|
||||
|
||||
if(padStatus.trigger & nn::hid::BUTTON_X)
|
||||
{
|
||||
// CIA をインポート
|
||||
if (ImportFile(nn::fs::MEDIA_TYPE_NAND, ROMFS_IMPORTEE_PATH)==false)
|
||||
{
|
||||
s_RenderSystem.Clear();
|
||||
s_RenderSystem.SetColor(1.0, 0.0, 0.0,1.0);
|
||||
s_RenderSystem.DrawText(50,50,"Impoprt fail");
|
||||
s_RenderSystem.SwapBuffers();
|
||||
}
|
||||
}
|
||||
s_RenderSystem.Clear();
|
||||
s_RenderSystem.DrawText(50,50,"Complate");
|
||||
}
|
||||
|
||||
s_RenderSystem.DrawText(10,80,"Push Power Button & Power Off");
|
||||
s_RenderSystem.SwapBuffers();
|
||||
|
||||
WaitKey(0);
|
||||
|
||||
}
|
||||
|
||||
110
tags/0thNUP_2/CardSaveDataMover/ImpRun/sleep.cpp
Normal file
110
tags/0thNUP_2/CardSaveDataMover/ImpRun/sleep.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: sleep.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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn/applet.h>
|
||||
|
||||
#include "sleep.h"
|
||||
|
||||
//extern nn::os::CriticalSection g_SleepCS;
|
||||
//extern nn::os::LightEvent g_TransitionEvent;
|
||||
//extern nn::os::LightEvent g_AwakeEvent;
|
||||
|
||||
volatile bool SleepHandler::s_IsAfterWakeUp = false;
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
void SleepHandler::Initialize( void )
|
||||
{
|
||||
nn::applet::SetSleepQueryCallback(SleepQueryCallback, 0);
|
||||
nn::applet::SetAwakeCallback(AwakeCallback, 0);
|
||||
// nn::applet::SetSleepCancelCallback(NULL, 0); // CancelCallback は使わないことを推奨します
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
void SleepHandler::Finalize( void )
|
||||
{
|
||||
nn::applet::SetSleepQueryCallback(NULL, 0);
|
||||
nn::applet::SetAwakeCallback(NULL, 0);
|
||||
|
||||
nn::applet::DisableSleep();
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
システムスリープの指示が来ているかどうかを返します。
|
||||
*------------------------------------------------------------------------*/
|
||||
bool SleepHandler::IsSleepRequested( void )
|
||||
{
|
||||
if ( nn::applet::IsExpectedToReplySleepQuery() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
本体スリープ状態に移行させるための処理を行います。
|
||||
グラフィックスなどの処理がスリープに入っても問題ない
|
||||
適切なタイミングで呼び出す必要があります。
|
||||
*------------------------------------------------------------------------*/
|
||||
void SleepHandler::SleepSystem( void )
|
||||
{
|
||||
// SleepHandler::IsSleepRequested() == true における呼び出しが前提
|
||||
|
||||
// 何らかの理由で SleepQuery に対して REJECT を返す場合は、ここで判定して
|
||||
// REJECT を返し、この関数を抜ける
|
||||
|
||||
// ファイルシステム処理中はスリープをしない
|
||||
//if ( g_SleepCS.TryEnter() )
|
||||
{
|
||||
// スリープ前処理
|
||||
|
||||
nn::applet::ReplySleepQuery(nn::applet::REPLY_ACCEPT);
|
||||
|
||||
//g_AwakeEvent.Wait();
|
||||
|
||||
// スリープ復帰時の処理
|
||||
|
||||
// g_SleepCS.Leave();
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
スリープ問い合わせ時に呼ばれるコールバック
|
||||
*------------------------------------------------------------------------*/
|
||||
AppletQueryReply SleepHandler::SleepQueryCallback( uptr arg )
|
||||
{
|
||||
NN_UNUSED_VAR(arg);
|
||||
//g_AwakeEvent.ClearSignal();
|
||||
|
||||
if ( !nn::applet::IsActive() )
|
||||
{
|
||||
// Inactive なとき、メインスレッドは applet::WaitForStarting() で停止状態であり、
|
||||
// 他のスレッドも停止状態になっているはず(アプリケーション側の実装依存)
|
||||
return nn::applet::REPLY_ACCEPT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nn::applet::REPLY_LATER;
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
スリープ復帰時に呼ばれるコールバック
|
||||
*------------------------------------------------------------------------*/
|
||||
void SleepHandler::AwakeCallback( uptr arg )
|
||||
{
|
||||
NN_UNUSED_VAR(arg);
|
||||
//g_AwakeEvent.Signal();
|
||||
|
||||
s_IsAfterWakeUp = true;
|
||||
}
|
||||
46
tags/0thNUP_2/CardSaveDataMover/ImpRun/sleep.h
Normal file
46
tags/0thNUP_2/CardSaveDataMover/ImpRun/sleep.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: sleep.h
|
||||
|
||||
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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef NN_SAMPLE_DEMOS_DEMO2_SLEEP_H_
|
||||
#define NN_SAMPLE_DEMOS_DEMO2_SLEEP_H_
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
本体スリープに関連する処理
|
||||
*------------------------------------------------------------------------*/
|
||||
class SleepHandler
|
||||
{
|
||||
public:
|
||||
SleepHandler() {}
|
||||
~SleepHandler() {}
|
||||
|
||||
static void Initialize( void );
|
||||
static void Finalize( void );
|
||||
static bool IsSleepRequested( void );
|
||||
static void SleepSystem( void );
|
||||
|
||||
static AppletQueryReply SleepQueryCallback( uptr arg );
|
||||
static void AwakeCallback( uptr arg );
|
||||
static void CancelCallback( uptr arg );
|
||||
|
||||
// スリープからの復帰後、1フレーム分描画を待ってから LCD を有効にするためのフラグ
|
||||
static volatile bool s_IsAfterWakeUp;
|
||||
|
||||
private:
|
||||
static nn::os::LightEvent s_AwakeEvent;
|
||||
static bool s_IsInitialized;
|
||||
};
|
||||
|
||||
|
||||
#endif // NN_SAMPLE_DEMOS_DEMO2_SLEEP_H_
|
||||
664
tags/0thNUP_2/CardSaveDataMover/ImpRun/test_data.cpp
Normal file
664
tags/0thNUP_2/CardSaveDataMover/ImpRun/test_data.cpp
Normal file
@ -0,0 +1,664 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
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);
|
||||
|
||||
//---------------------------------------- テストパターン
|
||||
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 20000
|
||||
bool Test1_W()
|
||||
{
|
||||
int total,size2;
|
||||
|
||||
res = nn::fs::FormatSaveData(1,0,true);
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.DrawText(8,100,"format Fail");
|
||||
return false;
|
||||
}
|
||||
res =nn::fs::MountSaveData();
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.DrawText(8,100,"Mount Fail");
|
||||
return false;
|
||||
}
|
||||
res = nn::fs::TryCreateFile(L"data:/test1.bin",SIZE_TEST1);
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.DrawText(8,100,"Create Fail");
|
||||
nn::fs::Unmount("data:");
|
||||
return false;
|
||||
}
|
||||
res = fout.TryInitialize(L"data:/test1.bin",true);
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.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()){
|
||||
s_RenderSystem.DrawText(8,100,"write Fail");
|
||||
fout.Finalize();
|
||||
nn::fs::Unmount("data:");
|
||||
return false;
|
||||
}
|
||||
total += size;
|
||||
sprintf(str,"size %d",total);
|
||||
s_RenderSystem.Clear();
|
||||
s_RenderSystem.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);
|
||||
s_RenderSystem.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()){
|
||||
s_RenderSystem.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()){
|
||||
s_RenderSystem.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])
|
||||
{
|
||||
s_RenderSystem.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);
|
||||
s_RenderSystem.DrawText(10,80,str);
|
||||
s_RenderSystem.SwapBuffers();
|
||||
if (size<512)break;
|
||||
}
|
||||
fout.Finalize();
|
||||
nn::fs::Unmount("data:");
|
||||
s_RenderSystem.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(700,1,false);//dupなしファイル680
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.DrawText(8,100,"format Fail");
|
||||
return false;
|
||||
}
|
||||
res =nn::fs::MountSaveData();
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.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()){
|
||||
// s_RenderSystem.DrawText(8,100,"Create Fail");
|
||||
// nn::fs::Unmount("data:");
|
||||
// return false;
|
||||
// }
|
||||
res = fout.TryInitialize(file_path,true);
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.DrawText(8,100,"open Fail");
|
||||
nn::fs::Unmount("data:");
|
||||
return false;
|
||||
}
|
||||
res = fout.TryWrite( &size,&src_buff[total],size2);
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.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();
|
||||
s_RenderSystem.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);
|
||||
s_RenderSystem.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()){
|
||||
s_RenderSystem.DrawText(8,100,"open Fail");
|
||||
nn::fs::Unmount("data:");
|
||||
return false;
|
||||
}
|
||||
res = fin.TryRead( &size,&get_buff[total],size2);
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.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])
|
||||
{
|
||||
s_RenderSystem.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();
|
||||
s_RenderSystem.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);
|
||||
s_RenderSystem.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()){
|
||||
s_RenderSystem.DrawText(8,100,"format Fail");
|
||||
return false;
|
||||
}
|
||||
res =nn::fs::MountSaveData();
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.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));
|
||||
s_RenderSystem.DrawText(8,110,str);
|
||||
s_RenderSystem.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()){
|
||||
s_RenderSystem.DrawText(8,100,"open Fail");
|
||||
nn::fs::Unmount("data:");
|
||||
return false;
|
||||
}
|
||||
res = fout.TryWrite( &size,&src_buff[total],size2);
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.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);
|
||||
s_RenderSystem.DrawText(10,80,str);
|
||||
s_RenderSystem.SwapBuffers();
|
||||
if (num == DirDepth)break;
|
||||
}
|
||||
|
||||
nn::fs::CommitSaveData();
|
||||
nn::fs::Unmount("data:");
|
||||
|
||||
s_RenderSystem.DrawText(10,100,"end");
|
||||
sprintf(str,"length = %d",(int)strlen(file_path2));
|
||||
s_RenderSystem.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()){
|
||||
s_RenderSystem.DrawText(8,100,"open Fail");
|
||||
nn::fs::Unmount("data:");
|
||||
return false;
|
||||
}
|
||||
res = fin.TryRead( &size,&get_buff[total],size2);
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.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])
|
||||
{
|
||||
s_RenderSystem.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);
|
||||
s_RenderSystem.DrawText(10,80,str);
|
||||
s_RenderSystem.SwapBuffers();
|
||||
if (num == DirDepth) break;
|
||||
}
|
||||
|
||||
nn::fs::Unmount("data:");
|
||||
s_RenderSystem.DrawText(10,100,"end");
|
||||
sprintf(str,"length = %d",(int)strlen(file_path2));
|
||||
s_RenderSystem.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()){
|
||||
s_RenderSystem.DrawText(8,100,"format Fail");
|
||||
return false;
|
||||
}
|
||||
res =nn::fs::MountSaveData();
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.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()){
|
||||
s_RenderSystem.DrawText(8,100,"Open Fail");
|
||||
nn::fs::Unmount("data:");
|
||||
return false;
|
||||
}
|
||||
res = fout.TryWrite( &size,&src_buff[0],512);
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.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()){
|
||||
s_RenderSystem.DrawText(8,100,"Open Fail");
|
||||
nn::fs::Unmount("data:");
|
||||
return false;
|
||||
}
|
||||
res = fin.TryRead( &size,&get_buff[0],512);
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.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])
|
||||
{
|
||||
s_RenderSystem.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()){
|
||||
s_RenderSystem.DrawText(8,100,"format Fail");
|
||||
return false;
|
||||
}
|
||||
res =nn::fs::MountSaveData();
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.DrawText(8,100,"Mount Fail");
|
||||
return false;
|
||||
}
|
||||
|
||||
res = nn::fs::TryCreateFile(L"data:/test5.bin",SIZE_TEST5);
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.DrawText(8,100,"Create Fail");
|
||||
nn::fs::Unmount("data:");
|
||||
return false;
|
||||
}
|
||||
res = fout.TryInitialize(L"data:/test5.bin",true);
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.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)){
|
||||
s_RenderSystem.DrawText(8,100,"write Fail");
|
||||
fout.Finalize();
|
||||
nn::fs::Unmount("data:");
|
||||
return false;
|
||||
}
|
||||
sprintf(str,"position %d",pos);
|
||||
s_RenderSystem.Clear();
|
||||
s_RenderSystem.DrawText(10,80,str);
|
||||
s_RenderSystem.SwapBuffers();
|
||||
pos += 1024;//512飛ばす
|
||||
if (pos >= SIZE_TEST5)break;
|
||||
}
|
||||
fout.Finalize();
|
||||
nn::fs::CommitSaveData();
|
||||
nn::fs::Unmount("data:");
|
||||
s_RenderSystem.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()){
|
||||
s_RenderSystem.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)){
|
||||
s_RenderSystem.DrawText(8,100,"read Fail");
|
||||
fin.Finalize();
|
||||
nn::fs::Unmount("data:");
|
||||
return false;
|
||||
}
|
||||
sprintf(str,"position %d",pos);
|
||||
s_RenderSystem.Clear();
|
||||
s_RenderSystem.DrawText(10,80,str);
|
||||
s_RenderSystem.SwapBuffers();
|
||||
|
||||
for (i=0;i<512;i++) if (src_buff[pos+i] != get_buff[pos+i])
|
||||
{
|
||||
s_RenderSystem.DrawText(8,100,"verifi Fail at %d",i);
|
||||
return false;
|
||||
}
|
||||
pos += 1024;//512飛ばす
|
||||
if (pos >= SIZE_TEST5)break;
|
||||
}
|
||||
fin.Finalize();
|
||||
nn::fs::Unmount("data:");
|
||||
s_RenderSystem.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
|
||||
s_RenderSystem.SetColor(1.0f,1.0f,1.0f,1.0f);
|
||||
|
||||
//TEST PATTERN
|
||||
make_pattern();
|
||||
|
||||
while(1){
|
||||
|
||||
//menu 表示
|
||||
s_RenderSystem.Clear();
|
||||
s_RenderSystem.DrawText(8,20," Backup Verifi for SaveDataMover Test ");
|
||||
s_RenderSystem.DrawText(8,40," for 512KB Backup");
|
||||
for (i=0;i<menu_ct;i++)s_RenderSystem.DrawText(menu_top_X,menu_top_Y+menu_spc*i,menu_str[i]);
|
||||
s_RenderSystem.DrawText(menu_top_X-30,menu_top_Y+menu_spc*curs,"->");
|
||||
s_RenderSystem.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();
|
||||
s_RenderSystem.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();
|
||||
s_RenderSystem.DrawText(10,70,"verifi");
|
||||
s_RenderSystem.SwapBuffers();
|
||||
nngxWaitVSync(NN_GX_DISPLAY0);
|
||||
res =nn::fs::MountSaveData();
|
||||
if (res.IsFailure()){
|
||||
s_RenderSystem.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)s_RenderSystem.DrawText(8,120,"Failed");
|
||||
sprintf(str,"desc %d",res.GetDescription());
|
||||
s_RenderSystem.DrawText(10,140,str);
|
||||
s_RenderSystem.SwapBuffers();
|
||||
NN_LOG("desc %d",res.GetDescription());
|
||||
WaitKey(nn::hid::BUTTON_B);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
End of file
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
6
tags/0thNUP_2/CardSaveDataMover/ImpRun/test_data.h
Normal file
6
tags/0thNUP_2/CardSaveDataMover/ImpRun/test_data.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef TEST_DATA_H_
|
||||
#define TEST_DATA_H_
|
||||
|
||||
void TestMain();
|
||||
|
||||
#endif
|
||||
Binary file not shown.
@ -0,0 +1,449 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: ConsoleBackup.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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
#include <nn/version.h>
|
||||
#include <nn/ptm/CTR/ptm_ApiSysmenu.h>
|
||||
#include <nn/mcu.h>
|
||||
#include <nn/cfg/CTR/cfg_Api.h>
|
||||
#include <nn/cfg/CTR/cfg_ApiInit.h>
|
||||
#include <nn/cfg/CTR/cfg_ApiSys.h>
|
||||
#include <nn/ps.h>
|
||||
#include <nn/nwm.h>
|
||||
#include <nn/ac.h>
|
||||
#include <nn/friends.h>
|
||||
#include <nn/friends/CTR/friends_ApiPrivate.h>
|
||||
#include <nn/fs/CTR/fs_ArchiveTypesForSystem.h>
|
||||
#include <nn/fs/CTR/MPCore/fs_FileSystemBasePrivate.h>
|
||||
#include <nn/fs/fs_ApiSysSaveData.h>
|
||||
#include <nn/cfg/CTR/cfg_ApiNor.h>
|
||||
#include <nn/os/os_SharedInfo.h>
|
||||
#include <nn/pl/CTR/pl_Version.h>
|
||||
#include <nn/fs/fs_ApiSharedExtSaveData.h>
|
||||
#include <nn/nim.h>
|
||||
#include <nn/ndm.h>
|
||||
|
||||
#include "demo.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "ConsoleBackup.h"
|
||||
#include "DrawSystemState.h"
|
||||
#include "FileName.h"
|
||||
#include "Controller.h"
|
||||
#include "SimplePlayer.h"
|
||||
#include "Exporter.h"
|
||||
#include "CommonLogger.h"
|
||||
#include "SDMountManager.h"
|
||||
#include "HeapManager.h"
|
||||
#include "PlayHistoryManager.h"
|
||||
#include "common_Types.h"
|
||||
#include "VersionDetect.h"
|
||||
#include "HardwareInfo.h"
|
||||
|
||||
// svnリビジョン埋め込み用
|
||||
#include "version.h"
|
||||
#ifndef BACKUP_VERSION_NUM
|
||||
#define BACKUP_VERSION_NUM 0
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
// グラフィックスに割り当てるメモリ
|
||||
const size_t s_GxHeapSize = 0x800000;
|
||||
|
||||
|
||||
// バッテリ残量
|
||||
u8 batteryRemain = 100;
|
||||
|
||||
// シリアルナンバー
|
||||
u8 s_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN];
|
||||
|
||||
// デバイスID
|
||||
bit32 s_DeviceId;
|
||||
|
||||
// シリアルナンバーが読めるかどうか
|
||||
bool s_CanReadSerialNumber = false;
|
||||
|
||||
// IVSへのポインタ
|
||||
void* sp_Ivs;
|
||||
|
||||
size_t s_SizeofIvs;
|
||||
|
||||
// IVSが読めるかどうか
|
||||
bool s_CanReadIvs = false;
|
||||
|
||||
// バージョン情報
|
||||
common::VerDef s_VerData;
|
||||
|
||||
nn::Handle s_McuSession;
|
||||
|
||||
} // namespace <unnamed>
|
||||
|
||||
namespace ConsoleBackup{
|
||||
|
||||
bool IsAdapterConnected()
|
||||
{
|
||||
return nn::ptm::CTR::GetAdapterState() == nn::ptm::CTR::ADAPTERSTATE_CONNECTED;
|
||||
}
|
||||
|
||||
bool IsBatteryLower()
|
||||
{
|
||||
return batteryRemain <= 10;
|
||||
}
|
||||
|
||||
bool CanReadIVS()
|
||||
{
|
||||
return s_CanReadIvs;
|
||||
}
|
||||
|
||||
bool CanReadSerialNumber()
|
||||
{
|
||||
return s_CanReadSerialNumber;
|
||||
}
|
||||
|
||||
void GetSerialNumber(u8** serial, size_t* size)
|
||||
{
|
||||
*serial = s_SerialNo;
|
||||
*size = nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN;
|
||||
}
|
||||
|
||||
void GetIvs(void** ivs, size_t* size)
|
||||
{
|
||||
*ivs = sp_Ivs;
|
||||
*size = s_SizeofIvs;
|
||||
}
|
||||
|
||||
bit32 GetDeviceId()
|
||||
{
|
||||
return s_DeviceId;
|
||||
}
|
||||
|
||||
void GetVersionData(common::VerDef* version)
|
||||
{
|
||||
*version = s_VerData;
|
||||
}
|
||||
|
||||
nn::Handle GetMcuHandle()
|
||||
{
|
||||
return s_McuSession;
|
||||
}
|
||||
|
||||
|
||||
extern "C" void nnMain(void)
|
||||
{
|
||||
nn::Result result;
|
||||
|
||||
// os の初期化
|
||||
nn::os::Initialize();
|
||||
|
||||
// fs の初期化
|
||||
nn::fs::Initialize();
|
||||
|
||||
// appletの初期化
|
||||
nn::applet::Enable( false );
|
||||
|
||||
// hid の初期化
|
||||
result = nn::hid::Initialize();
|
||||
NN_UTIL_PANIC_IF_FAILED(result);
|
||||
|
||||
// ndmの初期化
|
||||
result = nn::ndm::Initialize();
|
||||
NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result);
|
||||
|
||||
// デーモンの自律動作を停止
|
||||
result = nn::ndm::Suspend(nn::ndm::DN_CEC);
|
||||
NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result);
|
||||
result = nn::ndm::Suspend(nn::ndm::DN_BOSS);
|
||||
NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result);
|
||||
result = nn::ndm::Suspend(nn::ndm::DN_FRIENDS);
|
||||
NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result);
|
||||
result = nn::ndm::Suspend(nn::ndm::DN_NIM);
|
||||
NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result);
|
||||
|
||||
// cfg の初期化
|
||||
nn::cfg::CTR::init::Initialize();
|
||||
nn::cfg::CTR::system::Initialize();
|
||||
|
||||
// 時計設定用ptm初期化
|
||||
nn::ptm::CTR::InitializeForSystemMenu();
|
||||
|
||||
// ps の初期化
|
||||
nn::ps::Initialize();
|
||||
|
||||
// friendsの初期化
|
||||
result = nn::friends::detail::Initialize();
|
||||
|
||||
// mcuの初期化
|
||||
nn::mcu::CTR::InitializeHwCheck(&s_McuSession);
|
||||
|
||||
nn::mcu::CTR::HwCheck mcu(s_McuSession);
|
||||
|
||||
// ヒープの確保
|
||||
common::HeapManager::GetHeap()->Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize(), nn::os::ALLOCATE_OPTION_LINEAR);
|
||||
|
||||
// RenderSystem の準備
|
||||
uptr heapForGx = reinterpret_cast<uptr>(common::HeapManager::GetHeap()->Allocate(s_GxHeapSize));
|
||||
demo::RenderSystemDrawing s_RenderSystem;
|
||||
s_RenderSystem.Initialize(heapForGx, s_GxHeapSize);
|
||||
|
||||
// サウンドスレッドの起動
|
||||
common::InitializeSimplePlayer();
|
||||
|
||||
// ログ描画の初期化
|
||||
common::Logger::GetLoggerInstance()->Initialize(CONSOLE_WIDTH, CONSOLE_HEIGHT, CONSOLE_MAX_LINE, &s_RenderSystem);
|
||||
|
||||
// RenderSystemを作ってからログが出せる
|
||||
common::Logger::InitializeEjectThread();
|
||||
common::Logger::SetEjectHandler(OnSdEjected);
|
||||
// 起動時に削除
|
||||
common::Logger::GetLoggerInstance()->ClearLog();
|
||||
|
||||
COMMON_LOGGER("\n");
|
||||
COMMON_LOGGER("CTR Console Backup start\n");
|
||||
|
||||
// ボタン入力
|
||||
nn::hid::PadReader s_PadReader;
|
||||
nn::hid::PadStatus padStatus;
|
||||
|
||||
// データの準備
|
||||
|
||||
// 完全性検証SEEDの取得
|
||||
result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
nn::fs::FileInputStream fis;
|
||||
|
||||
result = fis.TryInitialize(common::IVS_NAND_PATHNAME);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
s64 fileSize = fis.GetSize();
|
||||
s32 ret;
|
||||
void* addr = NULL;
|
||||
addr = common::HeapManager::GetHeap()->Allocate(fileSize);
|
||||
if (addr != NULL)
|
||||
{
|
||||
sp_Ivs = addr;
|
||||
s_SizeofIvs = fileSize;
|
||||
result = fis.TryRead(&ret, addr, fileSize);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
s_CanReadIvs = true;
|
||||
}
|
||||
// 後でIVSを参照するのでFreeしない
|
||||
}
|
||||
}
|
||||
fis.Finalize();
|
||||
}
|
||||
// 一旦アンマウントしておく
|
||||
nn::fs::Unmount(common::NAND_ARCHIVE_NAME);
|
||||
|
||||
// リージョンの取得
|
||||
nn::cfg::CTR::CfgRegionCode region;
|
||||
region = nn::cfg::CTR::GetRegion();
|
||||
|
||||
// シリアルナンバーの取得
|
||||
std::memset(s_SerialNo, '\0',
|
||||
nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN);
|
||||
result = nn::cfg::CTR::system::GetSerialNo(s_SerialNo);
|
||||
if(result.IsSuccess())
|
||||
{
|
||||
s_CanReadSerialNumber = true;
|
||||
}
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
common::HardwareInfo hwInfo;
|
||||
hwInfo.AddCheckDigit(reinterpret_cast<char*>(s_SerialNo));
|
||||
|
||||
// デバイスIDの取得
|
||||
result = nn::ps::CTR::GetDeviceId(&s_DeviceId);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
bit64 infraDeviceId;
|
||||
result = nn::nim::CTR::InitializeForShop();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
result = nn::nim::CTR::Shop::GetInfraDeviceId(s_DeviceId, &infraDeviceId);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
result = nn::nim::CTR::FinalizeForShop();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
// MACアドレスの取得
|
||||
nn::nwm::Mac mac;
|
||||
char8 macAddress[nn::nwm::Mac::MAC_STRING_SIZE];
|
||||
|
||||
result = nn::nwm::GetMacAddress(mac);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
mac.GetString(macAddress);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
// フレンドコードの取得
|
||||
nn::friends::CTR::FriendKey friendKey;
|
||||
result = nn::friends::CTR::GetMyFriendKey(&friendKey);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
u64 friendCode = nn::friends::CTR::FriendKeyToFriendCode(friendKey);
|
||||
|
||||
// バージョンの取得
|
||||
common::GetSystemVersion(&s_VerData, region);
|
||||
|
||||
// 情報出力
|
||||
COMMON_LOGGER("CTR Console Backup %s Rev.%s\n", __DATE__, BACKUP_VERSION_NUM);
|
||||
COMMON_LOGGER("System Ver. %d.%d.%d-%d\n", s_VerData.cup.majorVersion, s_VerData.cup.minorVersion, s_VerData.cup.microVersion,
|
||||
s_VerData.nup.majorVersion);
|
||||
COMMON_LOGGER("System Region %s\n", nn::cfg::CTR::GetRegionCodeA3(region));
|
||||
COMMON_LOGGER("Serial Number %s\n", s_SerialNo);
|
||||
COMMON_LOGGER("Device ID %llu\n", infraDeviceId);
|
||||
COMMON_LOGGER("MAC Address %s\n", macAddress);
|
||||
COMMON_LOGGER("Friend Code %04u-%04u-%04u\n",
|
||||
static_cast<u32>(friendCode / 100000000ULL % 10000ULL),
|
||||
static_cast<u32>(friendCode / 10000ULL % 10000ULL),
|
||||
static_cast<u32>(friendCode % 10000ULL) );
|
||||
|
||||
|
||||
bool flip = false;
|
||||
bool continueBackup = false;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
bool nextStep = false;
|
||||
s_PadReader.ReadLatest(&padStatus);
|
||||
|
||||
// AまたはSTARTボタンで進行
|
||||
if(padStatus.trigger & nn::hid::BUTTON_A ||
|
||||
padStatus.trigger & nn::hid::BUTTON_START)
|
||||
{
|
||||
nextStep = true;
|
||||
}
|
||||
|
||||
// LまたはRボタンで上下画面フリップ
|
||||
if(padStatus.trigger & nn::hid::BUTTON_R ||
|
||||
padStatus.trigger & nn::hid::BUTTON_L)
|
||||
{
|
||||
flip = !flip;
|
||||
}
|
||||
|
||||
// コンソールスクロール
|
||||
if(padStatus.hold & nn::hid::BUTTON_UP)
|
||||
{
|
||||
common::Logger::GetLoggerInstance()->ScrollUp();
|
||||
}
|
||||
|
||||
// コンソールスクロール
|
||||
if(padStatus.hold & nn::hid::BUTTON_DOWN)
|
||||
{
|
||||
common::Logger::GetLoggerInstance()->ScrollDown();
|
||||
}
|
||||
|
||||
if(padStatus.hold & nn::hid::BUTTON_LEFT)
|
||||
{
|
||||
common::Logger::GetLoggerInstance()->ScrollToBegin();
|
||||
}
|
||||
|
||||
if(padStatus.hold & nn::hid::BUTTON_RIGHT)
|
||||
{
|
||||
common::Logger::GetLoggerInstance()->ScrollToEnd();
|
||||
}
|
||||
|
||||
|
||||
// 情報更新
|
||||
// バッテリ
|
||||
mcu.GetBatteryRemain(&batteryRemain);
|
||||
// ACアダプタ
|
||||
std::string adapterState;
|
||||
if(IsAdapterConnected())
|
||||
{
|
||||
adapterState += ::std::string("Connected");
|
||||
}
|
||||
else
|
||||
{
|
||||
adapterState += ::std::string("Not Connected");
|
||||
}
|
||||
|
||||
// 操作用メッセージ
|
||||
// 進捗確認メッセージを兼ねる?
|
||||
::std::vector<std::string> operationMessage;
|
||||
|
||||
ControlState(operationMessage, nextStep, continueBackup);
|
||||
|
||||
nn::util::FloatColor titleColor;
|
||||
|
||||
titleColor.r = 0.3f;
|
||||
titleColor.g = 0.f;
|
||||
titleColor.b = 0.2f;
|
||||
|
||||
// 上画面表示
|
||||
common::DrawSystemState("CTR Console Backup",
|
||||
s_RenderSystem,
|
||||
titleColor,
|
||||
flip,
|
||||
adapterState,
|
||||
BACKUP_VERSION_NUM,
|
||||
&s_VerData,
|
||||
batteryRemain,
|
||||
infraDeviceId,
|
||||
friendCode,
|
||||
GetProgress(),
|
||||
macAddress,
|
||||
operationMessage,
|
||||
region,
|
||||
s_SerialNo
|
||||
);
|
||||
|
||||
s_RenderSystem.SwapBuffers();
|
||||
|
||||
// デフォルトで下画面に描画するもの
|
||||
s_RenderSystem.SetRenderTarget(common::GetRenderTarget(NN_GX_DISPLAY1, flip));
|
||||
if(IsBackupSucceeded())
|
||||
{
|
||||
s_RenderSystem.SetClearColor(common::GetRenderTarget(NN_GX_DISPLAY1, flip), SUCCESS_COLOR);
|
||||
}
|
||||
if(IsBackupFailed())
|
||||
{
|
||||
s_RenderSystem.SetClearColor(common::GetRenderTarget(NN_GX_DISPLAY1, flip), FAIL_COLOR);
|
||||
}
|
||||
s_RenderSystem.Clear();
|
||||
s_RenderSystem.SetColor(1.f, 1.f, 1.f);
|
||||
|
||||
common::Logger::GetLoggerInstance()->DrawConsole();
|
||||
s_RenderSystem.SwapBuffers();
|
||||
|
||||
|
||||
s_RenderSystem.WaitVsync(NN_GX_DISPLAY_BOTH);
|
||||
|
||||
// 電源長押しで終了
|
||||
if ( nn::applet::IsExpectedToCloseApplication())
|
||||
{
|
||||
common::Logger::GetLoggerInstance()->Finalize();
|
||||
// アンマウント
|
||||
nn::fs::Unmount(common::NAND_ARCHIVE_NAME);
|
||||
nn::fs::Unmount(common::SDMC_ARCHIVE_NAME);
|
||||
s_RenderSystem.Finalize();
|
||||
|
||||
nn::mcu::CTR::FinalizeHwCheck(&s_McuSession);
|
||||
nn::friends::detail::Finalize();
|
||||
nn::ps::Finalize();
|
||||
nn::ptm::CTR::FinalizeForSystemMenu();
|
||||
nn::cfg::CTR::system::Finalize();
|
||||
nn::cfg::CTR::init::Finalize();
|
||||
nn::hid::Finalize();
|
||||
nn::fs::Finalize();
|
||||
|
||||
nn::applet::PrepareToCloseApplication();
|
||||
nn::applet::CloseApplication();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: ConsoleBackup.h
|
||||
|
||||
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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef NN_CONSOLEBACKUP_H_
|
||||
#define NN_CONSOLEBACKUP_H_
|
||||
|
||||
#include <nn.h>
|
||||
#include "VersionDetect.h"
|
||||
|
||||
namespace ConsoleBackup
|
||||
{
|
||||
|
||||
bool IsAdapterConnected();
|
||||
bool IsBatteryLower();
|
||||
bool CanReadIVS();
|
||||
bool CanReadSerialNumber();
|
||||
void GetSerialNumber(u8** serial, size_t* size);
|
||||
void GetIvs(void** ivs, size_t* size);
|
||||
nn::Handle GetMcuHandle();
|
||||
void GetVersionData(common::VerDef* version);
|
||||
bit32 GetDeviceId();
|
||||
|
||||
const u32 CONSOLE_WIDTH = 38;
|
||||
const u32 CONSOLE_HEIGHT = 24;
|
||||
const u32 CONSOLE_MAX_LINE = 1000;
|
||||
|
||||
}
|
||||
|
||||
/* NN_CONSOLEBACKUP_H_ */
|
||||
#endif
|
||||
@ -0,0 +1,52 @@
|
||||
BasicInfo:
|
||||
Title : ConsoleBackup
|
||||
ProductCode: ConsoleBackup
|
||||
BackupMemoryType: None
|
||||
|
||||
TitleInfo:
|
||||
Use: Evaluation
|
||||
Category: Application
|
||||
UniqueId: 0xf8021
|
||||
Version: 0
|
||||
|
||||
SystemControlInfo:
|
||||
AppType : Application
|
||||
StackSize : 0x4000
|
||||
Dependency :
|
||||
- gpio
|
||||
- pdn
|
||||
- spi
|
||||
- i2c
|
||||
- mcu
|
||||
- ptm
|
||||
- codec
|
||||
- cfg
|
||||
- hid
|
||||
- gsp
|
||||
- friends
|
||||
- nim
|
||||
- ac
|
||||
- ndm
|
||||
|
||||
AccessControlInfo:
|
||||
Priority : 16
|
||||
DisableDebug : true
|
||||
|
||||
FileSystemAccess:
|
||||
- DirectSdmc
|
||||
- Debug
|
||||
- Core
|
||||
- CategoryFileSystemTool
|
||||
|
||||
IoAccessControl:
|
||||
- FsMountCardSpi
|
||||
- FsMountNand
|
||||
- FsMountTwln
|
||||
|
||||
Option:
|
||||
FreeProductCode: true
|
||||
|
||||
|
||||
Rom:
|
||||
# ROM に含めるファイルシステムのルートパスを指定します。
|
||||
HostRoot: "$(ROMFS_ROOT)"
|
||||
313
tags/0thNUP_2/ConsoleDataMigration/ConsoleBackup/Controller.cpp
Normal file
313
tags/0thNUP_2/ConsoleDataMigration/ConsoleBackup/Controller.cpp
Normal file
@ -0,0 +1,313 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: Controller.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Controller.h"
|
||||
#include "FileChecker.h"
|
||||
#include "ConsoleBackup.h"
|
||||
#include "Exporter.h"
|
||||
#include "SimplePlayer.h"
|
||||
#include "CommonLogger.h"
|
||||
|
||||
#include <nn.h>
|
||||
|
||||
namespace ConsoleBackup
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
typedef enum BackupState
|
||||
{
|
||||
STARTUP, // 初期値
|
||||
EXPORT_TWL_SOUND, // TWLサウンド領域の吸出し中
|
||||
EXPORT_TWL_PHOTO, // TWL写真領域の吸出し中
|
||||
EXPORT_CTR_NAND, // 吸出し中
|
||||
DELETE_NIM, // nimのシステムセーブデータ削除
|
||||
DONE, // 吸出し完了
|
||||
FINISHED, // SDカード抜き完了
|
||||
FAIL // 失敗
|
||||
} BackupState;
|
||||
|
||||
|
||||
// APSettingの書式が無い警告サウンドを鳴らしたかどうか
|
||||
bool s_ExistAPSettingAnnotation = false;
|
||||
// SDに書き込みできない警告サウンドを鳴らしたかどうか
|
||||
bool s_SdWriteProetctAnnotation = false;
|
||||
|
||||
BackupState s_BackupState = STARTUP;
|
||||
bool s_PlayedStartCursor = false;
|
||||
bool s_PlayedSdPullOutCursor = false;
|
||||
bool s_PlayedFinishedSound = false;
|
||||
bool s_PlayedFailSound = false;
|
||||
|
||||
} // namespace <unnamed>
|
||||
|
||||
bool NeedsAcAdateper()
|
||||
{
|
||||
return IsBatteryLower() && !IsAdapterConnected();
|
||||
}
|
||||
|
||||
void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep, bool& continueBackup)
|
||||
{
|
||||
// 状態遷移Controller
|
||||
switch (s_BackupState)
|
||||
{
|
||||
|
||||
// 起動時
|
||||
case STARTUP:
|
||||
{
|
||||
bool error = false;
|
||||
// 完全性検証SEEDを読めるか?
|
||||
if (CanReadIVS())
|
||||
{
|
||||
// SDカードが挿入されているか?
|
||||
if (nn::fs::IsSdmcInserted())
|
||||
{
|
||||
// SDカードに書き込みできるか?
|
||||
if (!nn::fs::IsSdmcWritable())
|
||||
{
|
||||
if (!s_SdWriteProetctAnnotation)
|
||||
{
|
||||
s_SdWriteProetctAnnotation = true;
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
}
|
||||
operationMessage.push_back(::std::string("Can*t Write SD Card!!\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
// 無線設定ファイルがあるか?
|
||||
if (common::ExistsAPSetting())
|
||||
{
|
||||
// 書き込み中に抜かないように
|
||||
if (nextStep)
|
||||
{
|
||||
// シリアルナンバーを読み取れるか?
|
||||
if (!CanReadSerialNumber())
|
||||
{
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
COMMON_LOGGER("Can't Read Serial Number\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error = true;
|
||||
if (!s_ExistAPSettingAnnotation)
|
||||
{
|
||||
s_ExistAPSettingAnnotation = true;
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
}
|
||||
operationMessage.push_back(::std::string("Accsess_Point_Setting does not exist!"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error = true;
|
||||
operationMessage.push_back(::std::string("Insert SD Card!!"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error = true;
|
||||
operationMessage.push_back(::std::string("Can't Read IVS!!"));
|
||||
}
|
||||
|
||||
// ACアダプタが必要か?
|
||||
if (NeedsAcAdateper())
|
||||
{
|
||||
error = true;
|
||||
operationMessage.push_back(::std::string("Connect AC Adapter!!"));
|
||||
}
|
||||
|
||||
// エラーが無ければ進行用メッセージ表示
|
||||
if(!error)
|
||||
{
|
||||
operationMessage.push_back(::std::string("Push A or START Button"));
|
||||
if(!s_PlayedStartCursor)
|
||||
{
|
||||
common::PlaySound(common::SOUND_CURSOR);
|
||||
s_PlayedStartCursor = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (nextStep && !error)
|
||||
{
|
||||
COMMON_LOGGER("Start Export Data\n");
|
||||
s_BackupState = EXPORT_TWL_SOUND;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// TWLサウンド領域の吸出し中
|
||||
case EXPORT_TWL_SOUND:
|
||||
{
|
||||
static bool init = true;
|
||||
if(init)
|
||||
{
|
||||
// データを書き込む
|
||||
ExportTwlSoundData();
|
||||
init = false;
|
||||
}
|
||||
|
||||
// 処理が完了した
|
||||
if (IsExportFinished())
|
||||
{
|
||||
FinalizeExportThread();
|
||||
s_BackupState = EXPORT_TWL_PHOTO;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// TWL写真領域の吸出し中
|
||||
case EXPORT_TWL_PHOTO:
|
||||
{
|
||||
static bool init = true;
|
||||
if(init)
|
||||
{
|
||||
// データを書き込む
|
||||
ExportTwlPhotoData();
|
||||
init = false;
|
||||
}
|
||||
|
||||
// 処理が完了した
|
||||
if (IsExportFinished())
|
||||
{
|
||||
FinalizeExportThread();
|
||||
s_BackupState = EXPORT_CTR_NAND;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// 吸出し中
|
||||
case EXPORT_CTR_NAND:
|
||||
{
|
||||
continueBackup = true;
|
||||
|
||||
// ACアダプタが必要か?
|
||||
if (NeedsAcAdateper())
|
||||
{
|
||||
continueBackup = false;
|
||||
operationMessage.push_back(::std::string("Connect AC Adapter!!"));
|
||||
}
|
||||
|
||||
// データを書き込む
|
||||
ExportData();
|
||||
|
||||
// 処理が完了した
|
||||
if (continueBackup && IsExportFinished())
|
||||
{
|
||||
FinalizeExportThread();
|
||||
COMMON_LOGGER("Export NAND Data Finished.\n");
|
||||
|
||||
if(GetProgress() > 99)
|
||||
{
|
||||
s_BackupState = DELETE_NIM;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_BackupState = FAIL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// nimのシステムセーブデータ削除
|
||||
case DELETE_NIM:
|
||||
{
|
||||
DeleteNimSaveData();
|
||||
s_BackupState = DONE;
|
||||
}
|
||||
break;
|
||||
|
||||
// 吸出し完了
|
||||
case DONE:
|
||||
{
|
||||
operationMessage.push_back(::std::string("Backup Done. Pull Out SD Card."));
|
||||
if(!s_PlayedSdPullOutCursor)
|
||||
{
|
||||
common::PlaySound(common::SOUND_CURSOR);
|
||||
s_PlayedSdPullOutCursor = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// SDカード抜き完了
|
||||
case FINISHED:
|
||||
{
|
||||
operationMessage.push_back(::std::string("Backup Succeeded!!\n"));
|
||||
if(!s_PlayedFinishedSound)
|
||||
{
|
||||
common::PlaySound(common::SOUND_OK);
|
||||
s_PlayedFinishedSound = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// 吸出し失敗
|
||||
case FAIL:
|
||||
{
|
||||
operationMessage.push_back(::std::string("Backup Failed."));
|
||||
if(!s_PlayedFailSound)
|
||||
{
|
||||
common::PlaySound(common::SOUND_NG);
|
||||
s_PlayedFailSound = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool InProgress()
|
||||
{
|
||||
return s_BackupState == EXPORT_CTR_NAND;
|
||||
}
|
||||
|
||||
bool IsBackupSucceeded()
|
||||
{
|
||||
return s_BackupState == FINISHED;
|
||||
}
|
||||
|
||||
bool IsBackupFailed()
|
||||
{
|
||||
return s_BackupState == FAIL;
|
||||
}
|
||||
|
||||
void OnSdEjected()
|
||||
{
|
||||
if(s_BackupState == DONE || s_BackupState == FINISHED)
|
||||
{
|
||||
s_BackupState = FINISHED;
|
||||
}
|
||||
else
|
||||
{
|
||||
common::InitializeFileCheck();
|
||||
InitializeState();
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeState()
|
||||
{
|
||||
s_BackupState = STARTUP;
|
||||
s_PlayedFailSound = false;
|
||||
s_PlayedFinishedSound = false;
|
||||
s_ExistAPSettingAnnotation = false;
|
||||
s_PlayedStartCursor = false;
|
||||
s_PlayedSdPullOutCursor = false;
|
||||
s_SdWriteProetctAnnotation = false;
|
||||
}
|
||||
|
||||
} // namespace ConsoleBackup
|
||||
@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: Contoroller.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CONTOROLLER_H_
|
||||
#define CONTOROLLER_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace ConsoleBackup
|
||||
{
|
||||
|
||||
void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep, bool& continueBackup);
|
||||
bool InProgress();
|
||||
bool IsBackupSucceeded();
|
||||
bool IsBackupFailed();
|
||||
void OnSdEjected();
|
||||
void InitializeState();
|
||||
|
||||
}
|
||||
|
||||
#endif /* CONTOROLLER_H_ */
|
||||
570
tags/0thNUP_2/ConsoleDataMigration/ConsoleBackup/Exporter.cpp
Normal file
570
tags/0thNUP_2/ConsoleDataMigration/ConsoleBackup/Exporter.cpp
Normal file
@ -0,0 +1,570 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: Exporter.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
#include <cwchar>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include <nn/fs/CTR/fs_ArchiveTypesForSystem.h>
|
||||
#include <nn/fs/CTR/MPCore/fs_FileSystemBasePrivate.h>
|
||||
#include <nn/cfg/CTR/cfg_Api.h>
|
||||
#include <nn/cfg/CTR/cfg_ApiNor.h> // cfg:norの初期化に必要
|
||||
#include <nn/cfg/CTR/cfg_NtrSettings.h>
|
||||
#include <nn/ps/CTR/ps_API.h>
|
||||
#include <nn/drivers/aes/CTR/ARM946ES/driverAes_Types.h>
|
||||
#include <nn/crypto/crypto_SwAesCtrContext.h>
|
||||
#include <nn/mcu.h>
|
||||
|
||||
#include "Exporter.h"
|
||||
#include "CommonLogger.h"
|
||||
#include "SDMountManager.h"
|
||||
#include "ConsoleBackup.h"
|
||||
#include "HeapManager.h"
|
||||
#include "SdReaderWriter.h"
|
||||
#include "FileName.h"
|
||||
#include "FileTransfer.h"
|
||||
#include "common_Types.h"
|
||||
#include "Aes_define.h"
|
||||
#include "PlayHistoryManager.h"
|
||||
#include "VersionDetect.h"
|
||||
|
||||
namespace ConsoleBackup
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
common::SdReaderWriter s_SdWriter;
|
||||
common::NtrNorData s_NtrNorData;
|
||||
common::CfgCountryLanguage s_CountryLanguage;
|
||||
|
||||
::std::string s_SysSaveRoot;
|
||||
|
||||
const size_t EXPORT_THREAD_STACK_SIZE = 0x4000;
|
||||
nn::os::Thread s_ExportThread;
|
||||
nn::os::StackBuffer<EXPORT_THREAD_STACK_SIZE> s_ExportThreadStack;
|
||||
|
||||
wchar_t s_RootName[256];
|
||||
|
||||
}
|
||||
|
||||
void DeleteTrash(std::wstring currentDirectory)
|
||||
{
|
||||
// TODO: リードオンリーのファイルが消去できない
|
||||
|
||||
COMMON_LOGGER("Delete Trash.\n");
|
||||
|
||||
nn::fs::FileInputStream fis;
|
||||
nn::fs::Directory dir;
|
||||
nn::Result result;
|
||||
std::vector<nn::fs::DirectoryEntry> entryList; //カレントディレクトリのエントリ一覧を格納
|
||||
std::vector<nn::fs::DirectoryEntry>::iterator entryIndex;
|
||||
|
||||
common::SdMountManager::Mount();
|
||||
|
||||
result = dir.TryInitialize(currentDirectory.c_str());
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
nn::fs::DirectoryEntry entry;
|
||||
s32 numEntry;
|
||||
for (;;)
|
||||
{
|
||||
result = dir.TryRead(&numEntry, &entry, 1);
|
||||
if (result.IsFailure())
|
||||
{
|
||||
dir.Finalize();
|
||||
}
|
||||
if (numEntry == 0)
|
||||
{
|
||||
// ルートディレクトリを閉じる
|
||||
dir.Finalize();
|
||||
|
||||
// ルートディレクトリの子を開く
|
||||
for (entryIndex = entryList.begin(); entryIndex != entryList.end(); entryIndex++)
|
||||
{
|
||||
// ディレクトリなら削除する
|
||||
if (entryIndex->attributes.isDirectory)
|
||||
{
|
||||
NN_LOG("Try Delete %ls%ls/\n", currentDirectory.c_str(), entryIndex->entryName);
|
||||
result = nn::fs::TryDeleteDirectoryRecursively((currentDirectory + ::std::wstring(
|
||||
entryIndex->entryName)).c_str());
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
}
|
||||
// ファイルならログとAP設定以外は削除する
|
||||
else
|
||||
{
|
||||
if (std::wcscmp(entryIndex->entryName, common::AP_SETTING_FILENAME) != 0 && std::wcscmp(
|
||||
entryIndex->entryName, common::LOG_FILENAME) != 0)
|
||||
{
|
||||
NN_LOG("Try Delete %ls%ls\n", currentDirectory.c_str(), entryIndex->entryName);
|
||||
result = nn::fs::TryDeleteFile(
|
||||
(currentDirectory + ::std::wstring(entryIndex->entryName)).c_str());
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 削除完了
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// vectorに保存する
|
||||
entryList.push_back(entry);
|
||||
if (entry.attributes.isDirectory)
|
||||
{
|
||||
NN_LOG("%ls%ls/\n", currentDirectory.c_str(), entry.entryName);
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("%ls%ls\n", currentDirectory.c_str(), entry.entryName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("failed initialize directory\n");
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
dir.Finalize();
|
||||
}
|
||||
|
||||
common::SdMountManager::Unmount();
|
||||
}
|
||||
|
||||
void WriteRegionData()
|
||||
{
|
||||
COMMON_LOGGER("Export Region Data.\n");
|
||||
|
||||
nn::cfg::CTR::CfgRegionCode region;
|
||||
region = nn::cfg::CTR::GetRegion();
|
||||
|
||||
s_SdWriter.WriteBuf(common::REGION_DATA_PATHNAME, ®ion, sizeof(nn::cfg::CTR::CfgRegionCode));
|
||||
}
|
||||
|
||||
void WriteCountryLanguageData()
|
||||
{
|
||||
COMMON_LOGGER("Export Country and Language Data.\n");
|
||||
|
||||
nn::Result result;
|
||||
|
||||
nn::cfg::nor::CTR::Initialize();
|
||||
|
||||
// 国設定
|
||||
s_CountryLanguage.country = nn::cfg::CTR::GetCountry();
|
||||
if (s_CountryLanguage.country != nn::cfg::CTR::CFG_COUNTRY_UNKNOWN)
|
||||
{
|
||||
// 言語設定
|
||||
s_CountryLanguage.language = nn::cfg::CTR::GetLanguage();
|
||||
|
||||
s_SdWriter.WriteBuf(common::COUNTRY_SETTING_PATHNAME, &s_CountryLanguage, sizeof(s_CountryLanguage));
|
||||
}
|
||||
}
|
||||
|
||||
void WriteNorData()
|
||||
{
|
||||
COMMON_LOGGER("Export NOR Data.\n");
|
||||
|
||||
nn::Result result;
|
||||
|
||||
nn::cfg::nor::CTR::Initialize();
|
||||
|
||||
NN_LOG("Get NTR User Setting\n");
|
||||
|
||||
// NTR設定
|
||||
result = nn::cfg::nor::CTR::GetNtrSetting(&s_NtrNorData.ntrConfig.ncd, &s_NtrNorData.ntrConfig.ncd_ex);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
// TWL WiFi設定
|
||||
result = nn::cfg::nor::CTR::ReadTwlWifiSetting(0, s_NtrNorData.TwlWiFiSetting, common::TWL_WIFI_SETTING_SIZE);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
// NTR WiFi設定
|
||||
result = nn::cfg::nor::CTR::ReadNtrWifiSetting(0, s_NtrNorData.NtrWiFiSetting, common::NTR_WIFI_SETTING_SIZE);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
s_SdWriter.WriteBuf(common::NOR_PATHNAME, &s_NtrNorData, sizeof(common::NtrNorData));
|
||||
}
|
||||
|
||||
void WriteSerialNumber()
|
||||
{
|
||||
COMMON_LOGGER("Export Serial Number.\n");
|
||||
|
||||
u8* serial;
|
||||
size_t size;
|
||||
GetSerialNumber(&serial, &size);
|
||||
|
||||
s_SdWriter.WriteBuf(common::SERIAL_PATHNAME, serial, size);
|
||||
}
|
||||
|
||||
void WriteDeviceId()
|
||||
{
|
||||
COMMON_LOGGER("Export Device ID.\n");
|
||||
|
||||
bit32 deviceId = GetDeviceId();
|
||||
|
||||
s_SdWriter.WriteBuf(common::DEVICE_ID_PATHNAME, &deviceId, sizeof(deviceId));
|
||||
}
|
||||
|
||||
void WriteIvs()
|
||||
{
|
||||
COMMON_LOGGER("Export IVS.\n");
|
||||
|
||||
bit8 iv[AES_BLOCK_SIZE] =
|
||||
{
|
||||
0xdf, 0x0f, 0xf9, 0x1b, 0x34, 0x47, 0x70, 0x7f,
|
||||
0x7d, 0x06, 0x85, 0xe6, 0xe7, 0xb6, 0x4e, 0xe9
|
||||
};
|
||||
|
||||
void* ivs;
|
||||
size_t size;
|
||||
GetIvs(&ivs, &size);
|
||||
|
||||
void* enc;
|
||||
nn::Result result;
|
||||
enc = common::HeapManager::GetHeap()->Allocate(size);
|
||||
if(enc != NULL)
|
||||
{
|
||||
// AES暗号化する
|
||||
nn::crypto::Initialize();
|
||||
|
||||
nn::crypto::SwAesCtrContext swAesCtrContest;
|
||||
|
||||
swAesCtrContest.Initialize(iv, common::key, sizeof(common::key));
|
||||
swAesCtrContest.Encrypt(enc, ivs, size);
|
||||
|
||||
s_SdWriter.WriteBuf(common::IVS_PATHNAME, enc, size);
|
||||
|
||||
common::HeapManager::GetHeap()->Free(enc);
|
||||
}
|
||||
}
|
||||
|
||||
// IVSからセーブデータディレクトリ名を生成する
|
||||
void GetSaveDataDirectoryRoot()
|
||||
{
|
||||
nn::Result result;
|
||||
using namespace nn::dbg;
|
||||
|
||||
const size_t SEED_SIZE = 16;
|
||||
bit8 hash[nn::crypto::Sha256Context::HASH_SIZE];
|
||||
const size_t SYS_SAVE_ROOT_LENGTH = 16;
|
||||
char rootHash[SYS_SAVE_ROOT_LENGTH];
|
||||
char rootStr[SYS_SAVE_ROOT_LENGTH * 2 + 1];
|
||||
|
||||
void* addr;
|
||||
size_t size;
|
||||
GetIvs(&addr, &size);
|
||||
|
||||
// 最後の16バイトのハッシュを使う
|
||||
nn::crypto::CalculateSha256(hash, &reinterpret_cast<bit8*> (addr)[size - SEED_SIZE], SEED_SIZE);
|
||||
|
||||
for (u8 i = 0; i < SEED_SIZE / 4; i++)
|
||||
{
|
||||
for (u8 j = 0; j < SEED_SIZE / 4; j++)
|
||||
{
|
||||
rootHash[i * 4 + j] = hash[i * 4 + 3 - j];
|
||||
}
|
||||
}
|
||||
|
||||
// 得られたハッシュから文字列を生成
|
||||
for (s32 k = 0; k < SEED_SIZE; k++)
|
||||
{
|
||||
for (s32 i = 6; i < 8; ++i)
|
||||
{
|
||||
bit32 n = (rootHash[k] >> ((7 - i) * 4)) & 0xf;
|
||||
NN_TASSERT_(n < 16);
|
||||
rootStr[i - 6 + k * 2] = static_cast<char> (n < 10 ? '0' + n : 'a' + (n - 10));
|
||||
}
|
||||
}
|
||||
rootStr[SYS_SAVE_ROOT_LENGTH * 2] = '\0';
|
||||
|
||||
// セーブデータディレクトリ名を保存する
|
||||
s_SysSaveRoot = ::std::string(rootStr);
|
||||
|
||||
NN_LOG("%s\n", s_SysSaveRoot.c_str());
|
||||
}
|
||||
|
||||
void CreateTwlDirectory(enum common::TWL_PATH_INDEX path)
|
||||
{
|
||||
NN_ASSERT(path < common::TWL_PATHNAME_MAX);
|
||||
|
||||
s_SdWriter.CreateDirectory((::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) +
|
||||
std::wstring(common::SD_TWL_ROOTNAME_TABLE[path])).c_str());
|
||||
}
|
||||
|
||||
void WriteTwlData(enum common::TWL_PATH_INDEX path)
|
||||
{
|
||||
NN_ASSERT(path < common::TWL_PATHNAME_MAX);
|
||||
|
||||
nn::Result result;
|
||||
|
||||
result = nn::fs::MountSpecialArchive(common::TWL_ARCHIVE_NAME_TABLE[path], common::TWL_FS_ARCHIVE_KIND[path]);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
result = common::SdMountManager::Mount();
|
||||
|
||||
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
|
||||
NN_LOG("AllocatableSize = %d\n", bufSize);
|
||||
|
||||
u32 fileNum = 0;
|
||||
u32 fileSize = 0;
|
||||
common::CalculateFileNum(::std::wstring(common::NAND_TWL_ROOT_PATHNAME_WITH_SLASH_TABLE[path]), fileNum, fileSize);
|
||||
|
||||
nn::fs::Unmount(common::NAND_ARCHIVE_NAME);
|
||||
|
||||
NN_LOG("File Number = %d\n", fileNum);
|
||||
NN_LOG("File Size = %d\n", fileSize);
|
||||
// 進捗表示用
|
||||
common::InitializeTransferProgress(fileSize);
|
||||
|
||||
void* buf = common::HeapManager::GetHeap()->Allocate(bufSize);
|
||||
if (buf != NULL)
|
||||
{
|
||||
wchar_t archiveName[256];
|
||||
::std::mbstowcs(archiveName, common::TWL_ARCHIVE_NAME_TABLE[path], std::strlen(common::TWL_ARCHIVE_NAME_TABLE[path]) + 1);
|
||||
std::wstring archiveString(archiveName);
|
||||
common::CopyDirectory(
|
||||
(archiveString + ::std::wstring(L"/")).c_str(),
|
||||
(common::SDMC_ROOT_DIRECTORY_PATH + ::std::wstring(common::SD_TWL_ROOTNAME_TABLE[path])).c_str(),
|
||||
buf, bufSize);
|
||||
|
||||
common::HeapManager::GetHeap()->Free(buf);
|
||||
}
|
||||
|
||||
common::SdMountManager::Unmount();
|
||||
nn::fs::Unmount(common::TWL_ARCHIVE_NAME_TABLE[path]);
|
||||
|
||||
}
|
||||
|
||||
void WriteTwlPhotoData()
|
||||
{
|
||||
COMMON_LOGGER("Export Twl Photo Data.\n");
|
||||
CreateTwlDirectory(common::TWL_PHOTO);
|
||||
WriteTwlData(common::TWL_PHOTO);
|
||||
}
|
||||
|
||||
void WriteTwlSoundData()
|
||||
{
|
||||
COMMON_LOGGER("Export Twl Sound Data.\n");
|
||||
CreateTwlDirectory(common::TWL_SOUND);
|
||||
WriteTwlData(common::TWL_SOUND);
|
||||
}
|
||||
|
||||
void ExportTwlPhotoData()
|
||||
{
|
||||
s_ExportThread.Start(WriteTwlPhotoData, s_ExportThreadStack);
|
||||
}
|
||||
|
||||
void ExportTwlSoundData()
|
||||
{
|
||||
// 不要なデータを削除する
|
||||
DeleteTrash(common::SDMC_ROOT_DIRECTORY_PATH);
|
||||
|
||||
s_ExportThread.Start(WriteTwlSoundData, s_ExportThreadStack);
|
||||
}
|
||||
|
||||
|
||||
void WriteMcuRtcData()
|
||||
{
|
||||
COMMON_LOGGER("Export RTC Data.\n");
|
||||
nn::Result result;
|
||||
nn::Handle handle = GetMcuHandle();
|
||||
|
||||
if(handle.IsValid())
|
||||
{
|
||||
nn::mcu::CTR::HwCheck mcu(handle);
|
||||
|
||||
nn::mcu::CTR::RtcData rtc;
|
||||
result = mcu.GetRtcAll(&rtc);
|
||||
NN_LOG("RTC = 20%02d/%02d/%02d %02d:%02d:%02d\n", rtc.m_Year, rtc.m_Month, rtc.m_Day, rtc.m_Hour, rtc.m_Minute, rtc.m_Second);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
s_SdWriter.WriteBuf(common::MCU_RTC_PATHNAME, &rtc, sizeof(rtc));
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("invalid handle\n");
|
||||
}
|
||||
}
|
||||
|
||||
void ExportThreadFunc()
|
||||
{
|
||||
nn::Result result;
|
||||
|
||||
result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
result = common::SdMountManager::Mount();
|
||||
|
||||
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
|
||||
NN_LOG("AllocatableSize = %d\n", bufSize);
|
||||
|
||||
void* buf = common::HeapManager::GetHeap()->Allocate(bufSize);
|
||||
if (buf != NULL)
|
||||
{
|
||||
|
||||
common::CopyDirectory(
|
||||
(::std::wstring(common::NAND_DATA_ROOT_PATHNAME_WITH_SLASH) + ::std::wstring(s_RootName) + ::std::wstring(L"/")).c_str(),
|
||||
(common::SDMC_ROOT_DIRECTORY_PATH + ::std::wstring(common::SD_SAVEDATA_ROOT_NAME) + ::std::wstring(s_RootName) + ::std::wstring(L"/")).c_str(),
|
||||
buf, bufSize);
|
||||
|
||||
common::HeapManager::GetHeap()->Free(buf);
|
||||
}
|
||||
|
||||
common::SdMountManager::Unmount();
|
||||
nn::fs::Unmount(common::NAND_ARCHIVE_NAME);
|
||||
|
||||
NN_LOG("Export Thread Finalize\n");
|
||||
}
|
||||
|
||||
nn::Result WriteSaveData()
|
||||
{
|
||||
// NANDからSDカードに書き出し
|
||||
nn::Result result;
|
||||
|
||||
result = nn::fs::MountSpecialArchive(common::NAND_ARCHIVE_NAME, nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
u32 fileNum = 0;
|
||||
u32 fileSize = 0;
|
||||
common::CalculateFileNum(::std::wstring(common::NAND_DATA_ROOT_PATHNAME_WITH_SLASH), fileNum, fileSize);
|
||||
|
||||
nn::fs::Unmount(common::NAND_ARCHIVE_NAME);
|
||||
|
||||
NN_LOG("File Number = %d\n", fileNum);
|
||||
NN_LOG("File Size = %d\n", fileSize);
|
||||
// 進捗表示用
|
||||
common::InitializeTransferProgress(fileSize);
|
||||
|
||||
::std::mbstowcs(s_RootName, s_SysSaveRoot.c_str(), s_SysSaveRoot.size() + 1);
|
||||
|
||||
NN_LOG("%ls\n", (::std::wstring(common::NAND_DATA_ROOT_PATHNAME_WITH_SLASH) + ::std::wstring(s_RootName) + ::std::wstring(L"/")).c_str());
|
||||
|
||||
// セーブデータディレクトリ以下のデータをSDカードにコピー
|
||||
// コピー用ディレクトリ作成
|
||||
s_SdWriter.CreateDirectory((::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) + ::std::wstring(
|
||||
common::SD_SAVEDATA_ROOT_NAME)).c_str());
|
||||
s_SdWriter.CreateDirectory((::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) + ::std::wstring(
|
||||
common::SD_SAVEDATA_ROOT_NAME) + ::std::wstring(s_RootName) + ::std::wstring(L"/")).c_str());
|
||||
|
||||
COMMON_LOGGER("Export NAND Data Start...\n");
|
||||
|
||||
// SDにコピーするためのスレッドの作成
|
||||
s_ExportThread.Start(ExportThreadFunc, s_ExportThreadStack);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void FinalizeExportThread()
|
||||
{
|
||||
s_ExportThread.Join();
|
||||
s_ExportThread.Finalize();
|
||||
}
|
||||
|
||||
void WriteVersionData()
|
||||
{
|
||||
COMMON_LOGGER("Export Version Data.\n");
|
||||
|
||||
common::VerDef versionData;
|
||||
GetVersionData(&versionData);
|
||||
|
||||
s_SdWriter.WriteBuf(common::VERSION_DATA_PATHNAME, &versionData, sizeof(common::VerDef));
|
||||
}
|
||||
|
||||
void WritePlayHistory()
|
||||
{
|
||||
common::PlayHistoryManager historyManager;
|
||||
|
||||
COMMON_LOGGER("Export PlayHistory\n");
|
||||
historyManager.Export();
|
||||
}
|
||||
|
||||
void DeleteNimSaveData()
|
||||
{
|
||||
nn::Result result;
|
||||
::std::wstring nimSaveDataPath =
|
||||
::std::wstring(common::SDMC_ROOT_DIRECTORY_PATH) +
|
||||
::std::wstring(common::SD_SAVEDATA_ROOT_NAME) +
|
||||
::std::wstring(s_RootName) +
|
||||
::std::wstring(L"/") +
|
||||
std::wstring(common::NIM_SAVEDATA_DIRECTORY_NAME);
|
||||
|
||||
common::SdMountManager::Mount();
|
||||
|
||||
NN_LOG("%ls\n", nimSaveDataPath.c_str());
|
||||
result = nn::fs::TryDeleteDirectoryRecursively(nimSaveDataPath.c_str());
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
common::SdMountManager::Unmount();
|
||||
}
|
||||
|
||||
|
||||
void ExportData()
|
||||
{
|
||||
static bool init = true;
|
||||
|
||||
if (init)
|
||||
{
|
||||
// リージョンデータをSDに書き込む
|
||||
WriteRegionData();
|
||||
|
||||
// 国データと言語データをSDに書き込む
|
||||
WriteCountryLanguageData();
|
||||
|
||||
// NORデータをSDカードに書き込む
|
||||
WriteNorData();
|
||||
|
||||
// シリアルナンバーをSDカードに書き込む
|
||||
WriteSerialNumber();
|
||||
|
||||
// デバイスIDをSDカードに書き込む
|
||||
WriteDeviceId();
|
||||
|
||||
// 完全性検証SEEDをSDカードに書き込む
|
||||
WriteIvs();
|
||||
|
||||
// IVSからセーブデータディレクトリ名を計算
|
||||
GetSaveDataDirectoryRoot();
|
||||
|
||||
// プレイ履歴をSDに書き出す
|
||||
//WritePlayHistory();
|
||||
|
||||
// RTCをSDに書き出す
|
||||
WriteMcuRtcData();
|
||||
|
||||
// バージョン情報をSDに書き出す
|
||||
WriteVersionData();
|
||||
|
||||
// NANDのセーブデータをSDに書き出す
|
||||
WriteSaveData();
|
||||
|
||||
init = false;
|
||||
}
|
||||
}
|
||||
|
||||
u32 GetProgress()
|
||||
{
|
||||
return common::GetProgress();
|
||||
}
|
||||
|
||||
bool IsExportFinished()
|
||||
{
|
||||
return !s_ExportThread.IsAlive();
|
||||
}
|
||||
|
||||
}
|
||||
36
tags/0thNUP_2/ConsoleDataMigration/ConsoleBackup/Exporter.h
Normal file
36
tags/0thNUP_2/ConsoleDataMigration/ConsoleBackup/Exporter.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: Exporter.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef EXPORTER_H_
|
||||
#define EXPORTER_H_
|
||||
|
||||
#include <nn.h>
|
||||
|
||||
namespace ConsoleBackup
|
||||
{
|
||||
|
||||
void ExportTwlPhotoData();
|
||||
void ExportTwlSoundData();
|
||||
void ExportData();
|
||||
void DeleteNimSaveData();
|
||||
|
||||
u32 GetProgress();
|
||||
bool IsExportFinished();
|
||||
void FinalizeExportThread();
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif /* EXPORTER_H_ */
|
||||
84
tags/0thNUP_2/ConsoleDataMigration/ConsoleBackup/OMakefile
Normal file
84
tags/0thNUP_2/ConsoleDataMigration/ConsoleBackup/OMakefile
Normal file
@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env omake
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: Horizon
|
||||
# File: OMakefile
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# $Rev$
|
||||
#----------------------------------------------------------------------------
|
||||
SUPPORTED_TARGETS = CTR-T*.Process.MPCore.*
|
||||
#MAKECSU = true
|
||||
#INSTALL_SDK_TOOL = true
|
||||
CTR_APPTYPE = BOTH
|
||||
CTR_MAKE_DEVELOPMENT_IMAGE = true
|
||||
|
||||
TARGET_PROGRAM = ConsoleBackup
|
||||
|
||||
SAMPLED_DEMOS_COMMON_INCLUDE_DIR = $(dir $(HORIZON_ROOT)/../CTR/SampleDemos/common/include)
|
||||
INCLUDES += $(SAMPLED_DEMOS_COMMON_INCLUDE_DIR) \
|
||||
../common
|
||||
|
||||
SOURCES[] =
|
||||
ConsoleBackup.cpp
|
||||
Controller.cpp
|
||||
Exporter.cpp
|
||||
../common/HardwareInfo.cpp
|
||||
../common/DrawSystemState.cpp
|
||||
../common/FileTransfer.cpp
|
||||
../common/FileChecker.cpp
|
||||
../common/SdReaderWriter.cpp
|
||||
../common/HeapManager.cpp
|
||||
../common/SdLogger.cpp
|
||||
../common/wave.cpp
|
||||
../common/SimplePlayer.cpp
|
||||
../common/LogConsole.cpp
|
||||
../common/CommonLogger.cpp
|
||||
../common/SdMountManager.cpp
|
||||
../common/PlayHistoryManager.cpp
|
||||
../common/VersionDetect.cpp
|
||||
|
||||
CTR_BANNER_SPEC = $(TARGET_PROGRAM).bsf
|
||||
|
||||
ROMFS_ROOT = ../common/romfiles
|
||||
|
||||
LIBS += libnn_cfg \
|
||||
libnn_driversEeprom \
|
||||
libnn_driversi2c \
|
||||
libnn_driversCal \
|
||||
libnn_crypto \
|
||||
libnn_driversCodec \
|
||||
libnn_spi \
|
||||
libnn_gpio \
|
||||
libnn_pdn \
|
||||
libnn_mcu \
|
||||
libnn_i2c \
|
||||
libnn_driversCamera \
|
||||
libnn_ps \
|
||||
libnn_driversRsa \
|
||||
lib_demo \
|
||||
libnn_nwm \
|
||||
libnn_friends \
|
||||
libnn_nim \
|
||||
|
||||
INSTALL_SDK_TOOL = true
|
||||
|
||||
ROM_SPEC_FILE = $(TARGET_PROGRAM).rsf
|
||||
DESCRIPTOR = $(HORIZON_ROOT)/resources/specfiles/_private/RepairTool.desc
|
||||
|
||||
include $(ROOT_OMAKE)/modulerules
|
||||
|
||||
VERSION_H = $(file version.h)
|
||||
|
||||
$(VERSION_H): $(SOURCES)
|
||||
section
|
||||
bash genversion.sh
|
||||
|
||||
RequireSetup($(VERSION_H))
|
||||
build: $(VERSION_H) $(DEFAULT_TARGETS)
|
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ф8ф8фШчГГГГГГВ╫В╫8фВ╫В╫В╫В╫В╫ГГГГшчфГШФВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫yнВ╫yнВ╫В╫В╫В╫В╫YнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ГГГГШчyнYнВ╫шчшчВ╫В╫фВ╫В╫шчyнШчВ╫yнГГГГyнШФГГГГГшчВ╫В╫В╫В╫YнГyнГВ╫В╫В╫В╫В╫yнфшчГШФГYнyнВ╫В╫В╫yнВ╫╨жВ╫В╫В╫В╫В╫yнВ╫yнВ╫В╫В╫В╫В╫YнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫yнГYнГВ╫В╫В╫В╫В╫фВ╫В╫ГyнГ8фВ╫В╫В╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫
|
||||
@ -0,0 +1 @@
|
||||
В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫YнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫8ф8фВ╫В╫В╫╨ж8ф╨жГГшчГГГГГГГГГГГГГГГГГГГГГГГВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8ф8фВ╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ГГГГГШФГГГГГГГГГГ жфГГВ╫В╫ жВ╫ГГГГГ жГГВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫шчВ╫шчВ╫В╫В╫В╫В╫ГВ╫ШчВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫╨жВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ГГГГГГГГГГГГГГГГГГШФ8фШчшчВ╫В╫ жВ╫YнВ╫В╫В╫В╫В╫ГГYнyнГГyнфВ╫В╫В╫В╫В╫В╫В╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫шчшчГшчШФВ╫В╫ГГYнГВ╫В╫В╫В╫В╫шчВ╫шчГГГГГГГГГГГГГГГГВ╫В╫YнШч жГГГГГГГГГГГГГГГГГГГГГГГГшч╨жВ╫ жВ╫шчВ╫В╫В╫В╫В╫ШФВ╫ШФВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫шчВ╫yнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫YнВ╫ жГГГГВ╫шчВ╫шчГГГГВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫╨жшчВ╫В╫В╫В╫В╫YнфyнГГГГГГГГГ жГГГГ╨жВ╫YнВ╫ШФYнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫шч жВ╫В╫В╫В╫В╫В╫yнВ╫ГШФВ╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ШФВ╫ГГГГГВ╫ШчВ╫YнГГШФГВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ГГГГ жВ╫шчВ╫ГГГшч жВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫
|
||||
3
tags/0thNUP_2/ConsoleDataMigration/ConsoleBackup/genversion.sh
Executable file
3
tags/0thNUP_2/ConsoleDataMigration/ConsoleBackup/genversion.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash -f
|
||||
|
||||
echo "#define BACKUP_VERSION_NUM \"`svnversion -n`\"" > version.h
|
||||
Binary file not shown.
@ -0,0 +1,469 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: ConsoleRestore.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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
#include <nn/version.h>
|
||||
#include <nn/ptm/CTR/ptm_ApiSysmenu.h>
|
||||
#include <nn/mcu.h>
|
||||
#include <nn/cfg/CTR/cfg_Api.h>
|
||||
#include <nn/cfg/CTR/cfg_ApiInit.h>
|
||||
#include <nn/cfg/CTR/cfg_ApiSys.h>
|
||||
#include <nn/ps.h>
|
||||
#include <nn/nwm.h>
|
||||
#include <nn/ac.h>
|
||||
#include <nn/friends.h>
|
||||
#include <nn/friends/CTR/friends_ApiPrivate.h>
|
||||
#include <nn/fs/CTR/fs_ArchiveTypesForSystem.h>
|
||||
#include <nn/fs/CTR/MPCore/fs_FileSystemBasePrivate.h>
|
||||
#include <nn/fs/fs_ApiSysSaveData.h>
|
||||
#include <nn/cfg/CTR/cfg_ApiNor.h>
|
||||
#include <nn/am/am_ApiSystemMenu.h>
|
||||
#include <nn/os/os_SharedInfo.h>
|
||||
#include <nn/ndm.h>
|
||||
#include <nn/nim.h>
|
||||
#include "demo.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "ConsoleRestore.h"
|
||||
#include "DrawSystemState.h"
|
||||
#include "Controller.h"
|
||||
#include "SimplePlayer.h"
|
||||
#include "CommonLogger.h"
|
||||
#include "SDMountManager.h"
|
||||
#include "HeapManager.h"
|
||||
#include "VersionDetect.h"
|
||||
#include "HardwareInfo.h"
|
||||
|
||||
// svnリビジョン埋め込み用
|
||||
#include "version.h"
|
||||
#ifndef RESTORE_VERSION_NUM
|
||||
#define RESOTRE_VERSION_NUM 0
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
// グラフィックスに割り当てるメモリ
|
||||
const size_t s_GxHeapSize = 0x800000;
|
||||
|
||||
demo::RenderSystemDrawing s_RenderSystem;
|
||||
nn::Handle s_McuSession;
|
||||
|
||||
// バッテリ残量
|
||||
u8 batteryRemain = 100;
|
||||
|
||||
// シリアルナンバー
|
||||
u8 s_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN];
|
||||
|
||||
// デバイスID
|
||||
bit32 s_DeviceId;
|
||||
|
||||
// シリアルナンバーが読めるかどうか
|
||||
bool s_CanReadSerialNumber = false;
|
||||
|
||||
// IVSへのポインタ
|
||||
void* sp_Ivs;
|
||||
|
||||
size_t s_SizeofIvs;
|
||||
|
||||
// IVSが読めるかどうか
|
||||
bool s_CanReadIvs = false;
|
||||
|
||||
// バージョン情報
|
||||
common::VerDef s_VerData;
|
||||
|
||||
} // namespace <unnamed>
|
||||
|
||||
namespace ConsoleRestore{
|
||||
|
||||
bool IsAdapterConnected()
|
||||
{
|
||||
return nn::ptm::CTR::GetAdapterState() == nn::ptm::CTR::ADAPTERSTATE_CONNECTED;
|
||||
}
|
||||
|
||||
bool IsBatteryLower()
|
||||
{
|
||||
return batteryRemain <= 10;
|
||||
}
|
||||
|
||||
bool CanReadIVS()
|
||||
{
|
||||
return s_CanReadIvs;
|
||||
}
|
||||
|
||||
bool CanReadSerialNumber()
|
||||
{
|
||||
return s_CanReadSerialNumber;
|
||||
}
|
||||
|
||||
void GetSerialNumber(u8** serial, size_t* size)
|
||||
{
|
||||
*serial = s_SerialNo;
|
||||
*size = nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN;
|
||||
}
|
||||
|
||||
void GetIvs(void** ivs, size_t* size)
|
||||
{
|
||||
*ivs = sp_Ivs;
|
||||
*size = s_SizeofIvs;
|
||||
}
|
||||
|
||||
bit32 GetDeviceId()
|
||||
{
|
||||
return s_DeviceId;
|
||||
}
|
||||
|
||||
void GetVersionData(common::VerDef* version)
|
||||
{
|
||||
*version = s_VerData;
|
||||
}
|
||||
|
||||
void FinalizeAll()
|
||||
{
|
||||
common::Logger::GetLoggerInstance()->Finalize();
|
||||
// アンマウント
|
||||
nn::fs::Unmount("nand:");
|
||||
nn::fs::Unmount("sdmc:");
|
||||
s_RenderSystem.Finalize();
|
||||
|
||||
nn::mcu::CTR::FinalizeHwCheck(&s_McuSession);
|
||||
nn::friends::detail::Finalize();
|
||||
nn::ps::Finalize();
|
||||
nn::ptm::CTR::FinalizeForSystemMenu();
|
||||
nn::cfg::CTR::system::Finalize();
|
||||
nn::cfg::CTR::init::Finalize();
|
||||
nn::hid::Finalize();
|
||||
nn::fs::Finalize();
|
||||
|
||||
nn::applet::PrepareToCloseApplication();
|
||||
nn::applet::CloseApplication();
|
||||
}
|
||||
|
||||
nn::Handle GetMcuHandle()
|
||||
{
|
||||
return s_McuSession;
|
||||
}
|
||||
|
||||
extern "C" void nnMain(void)
|
||||
{
|
||||
nn::Result result;
|
||||
|
||||
// os の初期化
|
||||
nn::os::Initialize();
|
||||
|
||||
// fs の初期化
|
||||
nn::fs::Initialize();
|
||||
|
||||
// appletの初期化
|
||||
nn::applet::Enable( false );
|
||||
|
||||
// hid の初期化
|
||||
result = nn::hid::Initialize();
|
||||
NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result);
|
||||
|
||||
// ndmの初期化
|
||||
result = nn::ndm::Initialize();
|
||||
NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result);
|
||||
|
||||
// デーモンの自律動作を停止
|
||||
result = nn::ndm::Suspend(nn::ndm::DN_CEC);
|
||||
NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result);
|
||||
result = nn::ndm::Suspend(nn::ndm::DN_BOSS);
|
||||
NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result);
|
||||
result = nn::ndm::Suspend(nn::ndm::DN_FRIENDS);
|
||||
NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result);
|
||||
result = nn::ndm::Suspend(nn::ndm::DN_NIM);
|
||||
NN_ERR_THROW_FATAL_IF_FATAL_ONLY(result);
|
||||
|
||||
// cfg の初期化
|
||||
nn::cfg::CTR::init::Initialize();
|
||||
nn::cfg::CTR::system::Initialize();
|
||||
|
||||
// 時計設定用ptm初期化
|
||||
nn::ptm::CTR::InitializeForSystemMenu();
|
||||
|
||||
// ps の初期化
|
||||
nn::ps::Initialize();
|
||||
|
||||
// friendsの初期化
|
||||
result = nn::friends::detail::Initialize();
|
||||
|
||||
// mcuの初期化
|
||||
nn::mcu::CTR::InitializeHwCheck(&s_McuSession);
|
||||
nn::mcu::CTR::HwCheck mcu(s_McuSession);
|
||||
|
||||
// amの初期化
|
||||
nn::am::InitializeForSystemMenu();
|
||||
|
||||
// ヒープの確保
|
||||
common::HeapManager::GetHeap()->Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize(), nn::os::ALLOCATE_OPTION_LINEAR);
|
||||
|
||||
// RenderSystem の準備
|
||||
uptr heapForGx = reinterpret_cast<uptr>(common::HeapManager::GetHeap()->Allocate(s_GxHeapSize));
|
||||
s_RenderSystem.Initialize(heapForGx, s_GxHeapSize);
|
||||
|
||||
// サウンドスレッドの起動
|
||||
common::InitializeSimplePlayer();
|
||||
|
||||
// ログ描画の初期化
|
||||
common::Logger::GetLoggerInstance()->Initialize(CONSOLE_WIDTH, CONSOLE_HEIGHT, CONSOLE_MAX_LINE, &s_RenderSystem);
|
||||
|
||||
// RenderSystemを作ってからログが出せる
|
||||
common::Logger::InitializeEjectThread();
|
||||
common::Logger::SetEjectHandler(OnSdEjected);
|
||||
COMMON_LOGGER("\n");
|
||||
COMMON_LOGGER("CTR Console Restore start\n");
|
||||
|
||||
// ボタン入力
|
||||
nn::hid::PadReader s_PadReader;
|
||||
nn::hid::PadStatus padStatus;
|
||||
|
||||
// データの準備
|
||||
|
||||
// 完全性検証SEEDの取得
|
||||
result = nn::fs::MountSpecialArchive("nand:", nn::fs::CTR::ARCHIVE_TYPE_CTR_NAND);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
nn::fs::FileInputStream fis;
|
||||
|
||||
result = fis.TryInitialize(L"nand:/private/movable.sed");
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
s64 fileSize = fis.GetSize();
|
||||
s32 ret;
|
||||
void* addr = NULL;
|
||||
addr = common::HeapManager::GetHeap()->Allocate(fileSize);
|
||||
if (addr != NULL)
|
||||
{
|
||||
sp_Ivs = addr;
|
||||
s_SizeofIvs = fileSize;
|
||||
result = fis.TryRead(&ret, addr, fileSize);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
s_CanReadIvs = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
fis.Finalize();
|
||||
}
|
||||
// 一旦アンマウントしておく
|
||||
nn::fs::Unmount("nand:");
|
||||
|
||||
// リージョンの取得
|
||||
nn::cfg::CTR::CfgRegionCode region;
|
||||
region = nn::cfg::CTR::GetRegion();
|
||||
|
||||
// シリアルナンバーの取得
|
||||
std::memset(s_SerialNo, '\0',
|
||||
nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN);
|
||||
result = nn::cfg::CTR::system::GetSerialNo(s_SerialNo);
|
||||
common::HardwareInfo hwInfo;
|
||||
hwInfo.AddCheckDigit(reinterpret_cast<char*>(s_SerialNo));
|
||||
if(result.IsSuccess())
|
||||
{
|
||||
s_CanReadSerialNumber = true;
|
||||
}
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
// デバイスIDの取得
|
||||
result = nn::ps::CTR::GetDeviceId(&s_DeviceId);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
bit64 infraDeviceId;
|
||||
result = nn::nim::CTR::InitializeForShop();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
result = nn::nim::CTR::Shop::GetInfraDeviceId(s_DeviceId, &infraDeviceId);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
result = nn::nim::CTR::FinalizeForShop();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
// MACアドレスの取得
|
||||
nn::nwm::Mac mac;
|
||||
char8 macAddress[nn::nwm::Mac::MAC_STRING_SIZE];
|
||||
|
||||
result = nn::nwm::GetMacAddress(mac);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
mac.GetString(macAddress);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
// フレンドコードの取得
|
||||
nn::friends::CTR::FriendKey friendKey;
|
||||
result = nn::friends::CTR::GetMyFriendKey(&friendKey);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
u64 friendCode = nn::friends::CTR::FriendKeyToFriendCode(friendKey);
|
||||
|
||||
// バージョンの取得
|
||||
common::GetSystemVersion(&s_VerData, region);
|
||||
|
||||
// 情報出力
|
||||
COMMON_LOGGER("CTR Console Restore %s Rev.%s\n", __DATE__, RESTORE_VERSION_NUM);
|
||||
COMMON_LOGGER("System Ver. %d.%d.%d-%d\n", s_VerData.cup.majorVersion, s_VerData.cup.minorVersion, s_VerData.cup.microVersion,
|
||||
s_VerData.nup.majorVersion);
|
||||
COMMON_LOGGER("System Region %s\n", nn::cfg::CTR::GetRegionCodeA3(region));
|
||||
COMMON_LOGGER("Serial Number %s\n", s_SerialNo);
|
||||
COMMON_LOGGER("Device ID %llu\n", infraDeviceId);
|
||||
COMMON_LOGGER("MAC Address %s\n", macAddress);
|
||||
COMMON_LOGGER("Friend Code %04u-%04u-%04u\n",
|
||||
static_cast<u32>(friendCode / 100000000ULL % 10000ULL),
|
||||
static_cast<u32>(friendCode / 10000ULL % 10000ULL),
|
||||
static_cast<u32>(friendCode % 10000ULL) );
|
||||
|
||||
|
||||
bool flip = false;
|
||||
bool continueRestore = false;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
bool nextStep = false;
|
||||
|
||||
s_PadReader.ReadLatest(&padStatus);
|
||||
|
||||
// AまたはSTARTボタンで進行
|
||||
if(padStatus.trigger & nn::hid::BUTTON_A ||
|
||||
padStatus.trigger & nn::hid::BUTTON_START)
|
||||
{
|
||||
nextStep = true;
|
||||
}
|
||||
|
||||
// LまたはRボタンで上下画面フリップ
|
||||
if(padStatus.trigger & nn::hid::BUTTON_R ||
|
||||
padStatus.trigger & nn::hid::BUTTON_L)
|
||||
{
|
||||
flip = !flip;
|
||||
}
|
||||
|
||||
// コンソールスクロール
|
||||
if(padStatus.hold & nn::hid::BUTTON_UP)
|
||||
{
|
||||
common::Logger::GetLoggerInstance()->ScrollUp();
|
||||
}
|
||||
|
||||
// コンソールスクロール
|
||||
if(padStatus.hold & nn::hid::BUTTON_DOWN)
|
||||
{
|
||||
common::Logger::GetLoggerInstance()->ScrollDown();
|
||||
}
|
||||
|
||||
if(padStatus.hold & nn::hid::BUTTON_LEFT)
|
||||
{
|
||||
common::Logger::GetLoggerInstance()->ScrollToBegin();
|
||||
}
|
||||
|
||||
if(padStatus.hold & nn::hid::BUTTON_RIGHT)
|
||||
{
|
||||
common::Logger::GetLoggerInstance()->ScrollToEnd();
|
||||
}
|
||||
|
||||
// 情報更新
|
||||
// バッテリ
|
||||
mcu.GetBatteryRemain(&batteryRemain);
|
||||
// ACアダプタ
|
||||
std::string adapterState;
|
||||
if(IsAdapterConnected())
|
||||
{
|
||||
adapterState += ::std::string("Connected");
|
||||
}
|
||||
else
|
||||
{
|
||||
adapterState += ::std::string("Not Connected");
|
||||
}
|
||||
|
||||
// 操作用メッセージ
|
||||
// 進捗確認メッセージを兼ねる?
|
||||
::std::vector<std::string> operationMessage;
|
||||
|
||||
ControlState(operationMessage, nextStep, continueRestore);
|
||||
|
||||
nn::util::FloatColor titleColor;
|
||||
|
||||
if(GetRestoreMode() == RESTORE_MODE_RESTORE)
|
||||
{
|
||||
titleColor.r = 0.1f;
|
||||
titleColor.g = 0.25f;
|
||||
titleColor.b = 0.1f;
|
||||
}
|
||||
else if(GetRestoreMode() == RESTORE_MODE_NUP_ONLY)
|
||||
{
|
||||
titleColor.r = 0.35f;
|
||||
titleColor.g = 0.35f;
|
||||
titleColor.b = 0.f;
|
||||
}
|
||||
|
||||
// 上画面表示
|
||||
common::DrawSystemState("CTR Console Restore",
|
||||
s_RenderSystem,
|
||||
titleColor,
|
||||
flip,
|
||||
adapterState,
|
||||
RESTORE_VERSION_NUM,
|
||||
&s_VerData,
|
||||
batteryRemain,
|
||||
infraDeviceId,
|
||||
friendCode,
|
||||
GetProgress(),
|
||||
macAddress,
|
||||
operationMessage,
|
||||
region,
|
||||
s_SerialNo
|
||||
);
|
||||
|
||||
if (GetRestoreMode() == RESTORE_MODE_NUP_ONLY)
|
||||
{
|
||||
const u8 spaceSize = 10;
|
||||
const u8 lineBottom = 23;
|
||||
const u32 screenWidth = 400;
|
||||
|
||||
s_RenderSystem.SetColor(1.f, 1.f, 1.f);
|
||||
s_RenderSystem.DrawText(0, lineBottom * spaceSize, "NUP-Only Mode");
|
||||
s_RenderSystem.SetColor(titleColor.r, titleColor.g, titleColor.b);
|
||||
s_RenderSystem.FillRectangle(0, lineBottom * spaceSize, screenWidth, spaceSize);
|
||||
s_RenderSystem.SetColor(1.f, 1.f, 1.f);
|
||||
}
|
||||
|
||||
s_RenderSystem.SwapBuffers();
|
||||
|
||||
// デフォルトで下画面に描画するもの
|
||||
s_RenderSystem.SetRenderTarget(common::GetRenderTarget(NN_GX_DISPLAY1, flip));
|
||||
if(IsRestoreSucceeded())
|
||||
{
|
||||
s_RenderSystem.SetClearColor(common::GetRenderTarget(NN_GX_DISPLAY1, flip), SUCCESS_COLOR);
|
||||
}
|
||||
else if(IsRestoreFailed())
|
||||
{
|
||||
s_RenderSystem.SetClearColor(common::GetRenderTarget(NN_GX_DISPLAY1, flip), FAIL_COLOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_RenderSystem.SetClearColor(common::GetRenderTarget(NN_GX_DISPLAY1, flip), NORMAL_COLOR);
|
||||
}
|
||||
s_RenderSystem.Clear();
|
||||
s_RenderSystem.SetColor(1.f, 1.f, 1.f);
|
||||
|
||||
common::Logger::GetLoggerInstance()->DrawConsole();
|
||||
s_RenderSystem.SwapBuffers();
|
||||
|
||||
|
||||
s_RenderSystem.WaitVsync(NN_GX_DISPLAY_BOTH);
|
||||
|
||||
// 電源長押しで終了
|
||||
if ( nn::applet::IsExpectedToCloseApplication())
|
||||
{
|
||||
FinalizeAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: ConsoleRestore.h
|
||||
|
||||
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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef NN_CONSOLERESTORE_H_
|
||||
#define NN_CONSOLERESTORE_H_
|
||||
|
||||
#include <nn.h>
|
||||
#include "VersionDetect.h"
|
||||
|
||||
namespace ConsoleRestore
|
||||
{
|
||||
|
||||
bool IsAdapterConnected();
|
||||
bool IsBatteryLower();
|
||||
bool CanReadIVS();
|
||||
bool CanReadSerialNumber();
|
||||
void GetSerialNumber(u8** serial, size_t* size);
|
||||
void GetIvs(void** ivs, size_t* size);
|
||||
nn::Handle GetMcuHandle();
|
||||
void GetVersionData(common::VerDef* version);
|
||||
bit32 GetDeviceId();
|
||||
|
||||
void FinalizeAll();
|
||||
|
||||
const u32 CONSOLE_WIDTH = 38;
|
||||
const u32 CONSOLE_HEIGHT = 24;
|
||||
const u32 CONSOLE_MAX_LINE = 1000;
|
||||
|
||||
}
|
||||
|
||||
// 描画色の定義
|
||||
#define WHITE_COLOR 1.f, 1.f, 1.f, 1.f
|
||||
#define GRAY_COLOR 0.5, 0.5, 0.5, 1.f
|
||||
#define RED_COLOR 1.f, 0.f, 0.f, 1.f
|
||||
#define GREEN_COLOR 0.f, 1.f, 0.f, 1.f
|
||||
#define BLUE_COLOR 0.f, 0.f, 1.f, 1.f
|
||||
#define SUCCESS_COLOR 0.f, 0.6f,0.f, 1.f
|
||||
#define FAIL_COLOR 0.6f, 0.f,0.f, 1.f
|
||||
#define NORMAL_COLOR 0.f, 0.f, 0.f, 1.f
|
||||
|
||||
/* NN_CONSOLERESTORE_H_ */
|
||||
#endif
|
||||
@ -0,0 +1,52 @@
|
||||
BasicInfo:
|
||||
Title : ConsoleRestore
|
||||
ProductCode: ConsoleRestore
|
||||
BackupMemoryType: None
|
||||
|
||||
TitleInfo:
|
||||
Use: Evaluation
|
||||
Category: Application
|
||||
UniqueId: 0xf8022
|
||||
Version: 0
|
||||
|
||||
SystemControlInfo:
|
||||
AppType : Application
|
||||
StackSize : 0x4000
|
||||
Dependency :
|
||||
- gpio
|
||||
- pdn
|
||||
- spi
|
||||
- i2c
|
||||
- mcu
|
||||
- ptm
|
||||
- codec
|
||||
- cfg
|
||||
- hid
|
||||
- gsp
|
||||
- friends
|
||||
- nim
|
||||
- ac
|
||||
- ndm
|
||||
|
||||
AccessControlInfo:
|
||||
Priority : 16
|
||||
DisableDebug : true
|
||||
|
||||
FileSystemAccess:
|
||||
- DirectSdmc
|
||||
- Debug
|
||||
- Core
|
||||
- CategoryFileSystemTool
|
||||
|
||||
IoAccessControl:
|
||||
- FsMountCardSpi
|
||||
- FsMountNand
|
||||
- FsMountTwln
|
||||
|
||||
Option:
|
||||
FreeProductCode: true
|
||||
|
||||
|
||||
Rom:
|
||||
# ROM に含めるファイルシステムのルートパスを指定します。
|
||||
HostRoot: "$(ROMFS_ROOT)"
|
||||
898
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/Controller.cpp
Normal file
898
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/Controller.cpp
Normal file
@ -0,0 +1,898 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: Controller.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
#include <nn/ns.h>
|
||||
#include <nn/CTR/CTR_DeliverArg.h>
|
||||
#include <nn/fs/CTR/MPCore/fs_FileSystemBasePrivate.h>
|
||||
#include <nn/ptm/CTR/ptm_ApiSysmenu.h>
|
||||
#include <nn/ptm/CTR/ptm_ApiSystem.h>
|
||||
#include <nn/pl/CTR/pl_PlayHistoryApiSysmenu.h>
|
||||
|
||||
#include "Controller.h"
|
||||
#include "FileChecker.h"
|
||||
#include "ConsoleRestore.h"
|
||||
#include "SimplePlayer.h"
|
||||
#include "CommonLogger.h"
|
||||
#include "Importer.h"
|
||||
#include "Updater.h"
|
||||
#include "NtpClient.h"
|
||||
|
||||
namespace ConsoleRestore
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
typedef enum RestoreState
|
||||
{
|
||||
STARTUP, // 初期値
|
||||
SERIAL_IS_NOT_IN_SD, // シリアルナンバーファイルがSDカードにないことを表示
|
||||
SERIAL_IN_SD, // シリアルナンバーの情報を表示
|
||||
UPDATE_IN_PROGRESS, // アップデート中
|
||||
UPDATE_DONE, // アップデート完了
|
||||
NUP_ONLY_WAIT_SD_EJECT, // NUP_ONLYモードでSDカード抜き待ち
|
||||
NUP_ONLY_WAIT_NEXT, // NUP_ONLYモードでキー入力待ち
|
||||
RESTORE_TWL_SOUND, // TWLサウンドの書き込み中
|
||||
RESTORE_TWL_PHOTO, // TWL写真の書き込み中
|
||||
RESTORE_IN_PROGRESS, // 書き込み中
|
||||
POST_RESTORE, // 書き込み後の処理
|
||||
RESTORE_DONE, // 書き込み完了
|
||||
REBOOTING, // 再起動を行う
|
||||
ERASE, // 削除処理を行う
|
||||
HISTORY_RECOVER, // プレイ履歴の書き戻しを行う
|
||||
TIME_ADJUST, // 時計あわせを行う
|
||||
WAIT_SD_EJECT, // SDカードぬき待ち
|
||||
ALL_DONE, // すべて完了
|
||||
SHUTDOWN, // シャットダウン中
|
||||
FAIL // 失敗
|
||||
} RestoreState;
|
||||
|
||||
// Restore状態管理
|
||||
RestoreState s_RestoreState = STARTUP;
|
||||
// Restoreモード管理
|
||||
RestoreMode s_RestoreMode = RESTORE_MODE_RESTORE;
|
||||
|
||||
// インターネット設定を読んだかどうか
|
||||
bool s_ReadSettingDone = false;
|
||||
// インターネット設定を読んだ結果
|
||||
bool s_ReadSettingSuccess = false;
|
||||
// NUP専用モードかどうか
|
||||
bool s_NupOnlyMode = false;
|
||||
|
||||
// APSettingの書式が無い警告サウンドを鳴らしたかどうか
|
||||
bool s_ExistAPSettingAnnotation = false;
|
||||
// APSettingの書式が違っている警告サウンドを鳴らしたかどうか
|
||||
bool s_APSettingAnnotation = false;
|
||||
// シリアルナンバーがない警告サウンドを鳴らしたかどうか
|
||||
bool s_SerialNumberAnnotation = false;
|
||||
// 失敗サウンドを鳴らしたかどうか
|
||||
bool s_PlayedFailSound = false;
|
||||
// 操作開始サウンドを鳴らしたかどうか
|
||||
bool s_PlayedStartCursor = false;
|
||||
// リブート開始前サウンドを鳴らしたかどうか
|
||||
bool s_PlayedRebootCursor = false;
|
||||
// SD抜き出し前サウンドを鳴らしたかどうか
|
||||
bool s_PlayedSdPullOutCursor = false;
|
||||
// バージョンデータが無い警告サウンドを鳴らしたかどうか
|
||||
bool s_ExistsVersionDataAnnotation = false;
|
||||
// バージョンデータを読んだかどうか
|
||||
bool s_ReadVersionDone = false;
|
||||
// SDに書き込みできない警告サウンドを鳴らしたかどうか
|
||||
bool s_SdWriteProetctAnnotation = false;
|
||||
|
||||
// ネットワークアップデートを開始したかどうか
|
||||
bool s_ExecuteFgNup = false;
|
||||
// FGNUPを何回リトライしたか
|
||||
u32 s_FgNupRetryCount = 0;
|
||||
|
||||
|
||||
} // namespace <unnamed>
|
||||
|
||||
bool NeedsAcAdater()
|
||||
{
|
||||
return IsBatteryLower() && !IsAdapterConnected();
|
||||
}
|
||||
|
||||
bool CheckAndReadAPSetting(::std::vector<std::string>& operationMessage)
|
||||
{
|
||||
using namespace common;
|
||||
|
||||
if (!ExistsAPSetting())
|
||||
{
|
||||
if(!s_ExistAPSettingAnnotation)
|
||||
{
|
||||
s_ExistAPSettingAnnotation = true;
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
}
|
||||
operationMessage.push_back(::std::string("Accsess_Point_Setting does not exist!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 設定ファイルからAP設定を読み込む
|
||||
if (!s_ReadSettingDone)
|
||||
{
|
||||
s_ReadSettingDone = true;
|
||||
s_ReadSettingSuccess = ReadSetting(&s_NupOnlyMode);
|
||||
}
|
||||
|
||||
if(s_NupOnlyMode)
|
||||
{
|
||||
s_RestoreMode = RESTORE_MODE_NUP_ONLY;
|
||||
}
|
||||
|
||||
if (!s_ReadSettingSuccess)
|
||||
{
|
||||
operationMessage.push_back(::std::string("Invalid Accsess_Point_Setting format!"));
|
||||
if(!s_APSettingAnnotation)
|
||||
{
|
||||
s_APSettingAnnotation = true;
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return s_ReadSettingSuccess;
|
||||
}
|
||||
|
||||
bool CheckAndReadVersionData(::std::vector<std::string>& operationMessage)
|
||||
{
|
||||
using namespace common;
|
||||
|
||||
if (!ExistsVersionData())
|
||||
{
|
||||
if(!s_ExistsVersionDataAnnotation)
|
||||
{
|
||||
s_ExistsVersionDataAnnotation = true;
|
||||
common::PlaySound(common::SOUND_ANNOTATION);
|
||||
}
|
||||
operationMessage.push_back(::std::string("Version Data does not exist!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// バージョン情報ファイルを読み込む
|
||||
if (!s_ReadVersionDone)
|
||||
{
|
||||
s_ReadVersionDone = true;
|
||||
ReadVersionData();
|
||||
}
|
||||
|
||||
return s_ReadSettingSuccess;
|
||||
}
|
||||
|
||||
void PutAliveMessage(::std::vector<std::string>& operationMessage, const char* str)
|
||||
{
|
||||
std::string message = std::string(str);
|
||||
static u8 i = 0;
|
||||
if (i < 0xff / 4)
|
||||
{
|
||||
operationMessage.push_back(message + std::string(" /"));
|
||||
}
|
||||
else if (i < 0xff * 2 / 4)
|
||||
{
|
||||
operationMessage.push_back(message + std::string(" |"));
|
||||
}
|
||||
else if (i < 0xff * 3 / 4)
|
||||
{
|
||||
operationMessage.push_back(message + std::string(" \\"));
|
||||
}
|
||||
else
|
||||
{
|
||||
operationMessage.push_back(message + std::string(" -"));
|
||||
}
|
||||
i += 4;
|
||||
}
|
||||
|
||||
void ExecSyncMcuRtc()
|
||||
{
|
||||
if(!common::ExistsRtcSyncFinishedFile())
|
||||
{
|
||||
ImportMcuRtc();
|
||||
// 時計を無効化する
|
||||
CreateRtcSyncFinishedFile();
|
||||
}
|
||||
}
|
||||
|
||||
// Zero NUP限定コード
|
||||
bool NeedsNup()
|
||||
{
|
||||
if(AlreadyExecutedNup() || s_NupOnlyMode)
|
||||
{
|
||||
return !common::ExistsUpdateCheckedFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep, bool& continueRestore)
|
||||
{
|
||||
using namespace common;
|
||||
|
||||
// 状態遷移Controller
|
||||
switch (s_RestoreState)
|
||||
{
|
||||
// 起動時
|
||||
case STARTUP:
|
||||
{
|
||||
bool error = false;
|
||||
bool needsUpdate = false;
|
||||
bool needsErase = false;
|
||||
bool validApSetting = false;
|
||||
|
||||
// SDカードが挿入されているか?
|
||||
if (nn::fs::IsSdmcInserted())
|
||||
{
|
||||
// SDカードに書き込みできるか?
|
||||
if (!nn::fs::IsSdmcWritable())
|
||||
{
|
||||
if (!s_SdWriteProetctAnnotation)
|
||||
{
|
||||
s_SdWriteProetctAnnotation = true;
|
||||
PlaySound(SOUND_ANNOTATION);
|
||||
}
|
||||
operationMessage.push_back(::std::string("Can*t Write SD Card!!\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
CheckAndReadVersionData(operationMessage);
|
||||
validApSetting = CheckAndReadAPSetting(operationMessage);
|
||||
if (!validApSetting)
|
||||
{
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// NUPが必要か?
|
||||
if (!NeedsNup())
|
||||
{
|
||||
if (s_NupOnlyMode)
|
||||
{
|
||||
s_RestoreState = NUP_ONLY_WAIT_SD_EJECT;
|
||||
|
||||
// リストア状態チェックファイルをすべて削除
|
||||
DeleteAllCheckFiles();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// SDカードに書き込み完了ファイルがあるか?
|
||||
if (!ExistsWriteFinishedFile())
|
||||
{
|
||||
// IVSを読めるか?
|
||||
if (CanReadIVS())
|
||||
{
|
||||
// 本体初期化完了ファイルがあるか?
|
||||
if (ExistsConsoleInitializedFile())
|
||||
{
|
||||
// SDカードにシリアルナンバーがあるか?
|
||||
if (!ExistsSerialNumberFile())
|
||||
{
|
||||
COMMON_LOGGER("Can't Read Serial Number in SD Card!!\n");
|
||||
error = true;
|
||||
s_RestoreState = SERIAL_IS_NOT_IN_SD;
|
||||
}
|
||||
else
|
||||
{
|
||||
::std::string serial(reinterpret_cast<char*> (ReadSerialNumber()));
|
||||
operationMessage.push_back(::std::string("Serial Number in SD : ") + serial);
|
||||
}
|
||||
|
||||
|
||||
// SDカードにリージョンデータがあるか?
|
||||
if (ExistsRegionData())
|
||||
{
|
||||
// リージョンデータは一致しているか?
|
||||
if (!EqualsRegionDataandRegion())
|
||||
{
|
||||
COMMON_LOGGER("Current Region and Region in SD differ!!\n");
|
||||
error = true;
|
||||
s_RestoreState = FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 移行不能なのでFAIL
|
||||
COMMON_LOGGER("Can't Read Region in SD Card!!\n");
|
||||
error = true;
|
||||
s_RestoreState = FAIL;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ExistsIVSFile())
|
||||
{
|
||||
// 移行不能なのでFAIL
|
||||
COMMON_LOGGER("Can't Read IVS in SD Card!!\n");
|
||||
error = true;
|
||||
s_RestoreState = FAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
COMMON_LOGGER("Initialize Console\n");
|
||||
|
||||
// 本体初期化完了ファイルを作る
|
||||
CreateConsoleInitializedFile();
|
||||
|
||||
// ファイルシステムの初期化を行う
|
||||
InitializeFileSystem();
|
||||
error = true;
|
||||
s_RestoreState = REBOOTING;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error = true;
|
||||
operationMessage.push_back(::std::string("Can't Read IVS!!"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (validApSetting)
|
||||
{
|
||||
// 削除処理を行う
|
||||
needsErase = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (validApSetting)
|
||||
{
|
||||
// ネットワークアップデートを行う
|
||||
needsUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error = true;
|
||||
operationMessage.push_back(::std::string("Insert SD Card!!"));
|
||||
}
|
||||
|
||||
// ACアダプタが必要か?
|
||||
if (NeedsAcAdater())
|
||||
{
|
||||
error = true;
|
||||
operationMessage.push_back(::std::string("Connect AC Adapter!!"));
|
||||
}
|
||||
|
||||
// エラーが無ければ進行用メッセージ表示
|
||||
if (!error)
|
||||
{
|
||||
operationMessage.push_back(::std::string("Push A or START Button"));
|
||||
if(needsUpdate)
|
||||
{
|
||||
operationMessage.push_back(::std::string("Network Update Mode"));
|
||||
}
|
||||
else if(needsErase)
|
||||
{
|
||||
operationMessage.push_back(::std::string("Clock Sync Mode"));
|
||||
}
|
||||
else
|
||||
{
|
||||
operationMessage.push_back(::std::string("Import Data Mode"));
|
||||
}
|
||||
|
||||
if(!s_PlayedStartCursor)
|
||||
{
|
||||
PlaySound(SOUND_CURSOR);
|
||||
s_PlayedStartCursor = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (nextStep && !error)
|
||||
{
|
||||
if (needsUpdate)
|
||||
{
|
||||
COMMON_LOGGER("Start Network Update\n");
|
||||
s_RestoreState = UPDATE_IN_PROGRESS;
|
||||
}
|
||||
else if(needsErase)
|
||||
{
|
||||
COMMON_LOGGER("Erase Trash\n");
|
||||
s_RestoreState = ERASE;
|
||||
}
|
||||
else
|
||||
{
|
||||
COMMON_LOGGER("Start Import Data\n");
|
||||
// Zero NUP限定
|
||||
// RTC同期を行う
|
||||
// NUPされない場合があるのでここで同期
|
||||
ExecSyncMcuRtc();
|
||||
|
||||
s_RestoreState = RESTORE_TWL_SOUND;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// シリアルナンバーがSDカードにないこと警告
|
||||
case SERIAL_IS_NOT_IN_SD:
|
||||
{
|
||||
operationMessage.push_back(::std::string("Serial Number Is Not In SD Card"));
|
||||
operationMessage.push_back(::std::string("Push A or START Button"));
|
||||
operationMessage.push_back(::std::string("Import Data Mode"));
|
||||
|
||||
if (!s_SerialNumberAnnotation)
|
||||
{
|
||||
s_SerialNumberAnnotation = true;
|
||||
PlaySound(SOUND_ANNOTATION);
|
||||
}
|
||||
|
||||
if (nextStep)
|
||||
{
|
||||
s_RestoreState = RESTORE_TWL_SOUND;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// アップデート中
|
||||
case UPDATE_IN_PROGRESS:
|
||||
{
|
||||
continueRestore = true;
|
||||
|
||||
// ACアダプタが必要か?
|
||||
if (NeedsAcAdater())
|
||||
{
|
||||
continueRestore = false;
|
||||
operationMessage.push_back(::std::string("Connect AC Adapter!!"));
|
||||
}
|
||||
|
||||
// アップデートを行う
|
||||
if(!s_ExecuteFgNup)
|
||||
{
|
||||
ImportCountryLanguageData();
|
||||
StartFGNetworkUpdate();
|
||||
s_ExecuteFgNup = true;
|
||||
}
|
||||
|
||||
// 動いていることを表示
|
||||
{
|
||||
PutAliveMessage(operationMessage, "Updating");
|
||||
}
|
||||
|
||||
|
||||
if (IsNetworkUpdateFinished())
|
||||
{
|
||||
FinishFGNetworkUpdate();
|
||||
// エラーがあったら表示する
|
||||
if(GetUpdateResult().IsFailure())
|
||||
{
|
||||
// APが見つからない
|
||||
if(GetUpdateResult() == nn::ac::ResultNotFoundAccessPoint())
|
||||
{
|
||||
COMMON_LOGGER("No Access Point Found!");
|
||||
}
|
||||
}
|
||||
|
||||
if (GetUpdateResult().IsSuccess())
|
||||
{
|
||||
COMMON_LOGGER("Network Update Finished.\n");
|
||||
// アップデート完了ファイルを作成
|
||||
CreateUpdateFinishedFile();
|
||||
|
||||
s_RestoreState = UPDATE_DONE;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s_FgNupRetryCount++ < RETRY_MAX)
|
||||
{
|
||||
// エラーのためやり直す
|
||||
COMMON_LOGGER_RESULT_IF_FAILED(GetUpdateResult());
|
||||
COMMON_LOGGER("Network Update Failed. Retrying... %d\n", s_FgNupRetryCount);
|
||||
|
||||
// FGNUP用のスレッドを作るとこからやり直し
|
||||
s_ExecuteFgNup = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_RestoreState = FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// アップデート完了
|
||||
case UPDATE_DONE:
|
||||
{
|
||||
operationMessage.push_back(::std::string("Network Update Done."));
|
||||
operationMessage.push_back(::std::string("Press A or START Button to Reboot"));
|
||||
|
||||
if(!s_PlayedRebootCursor)
|
||||
{
|
||||
PlaySound(SOUND_CURSOR);
|
||||
s_PlayedRebootCursor = true;
|
||||
}
|
||||
|
||||
if (nextStep)
|
||||
{
|
||||
s_RestoreState = REBOOTING;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
// TWLサウンド領域の書き込み中
|
||||
case RESTORE_TWL_SOUND:
|
||||
{
|
||||
static bool init = true;
|
||||
if (init)
|
||||
{
|
||||
// データを書き込む
|
||||
ImportTwlSoundData();
|
||||
init = false;
|
||||
}
|
||||
|
||||
// 処理が完了した
|
||||
if (IsImportFinished())
|
||||
{
|
||||
FinalizeImportThread();
|
||||
s_RestoreState = RESTORE_TWL_PHOTO;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// TWL写真領域の書き込み
|
||||
case RESTORE_TWL_PHOTO:
|
||||
{
|
||||
static bool init = true;
|
||||
if (init)
|
||||
{
|
||||
// データを書き込む
|
||||
ImportTwlPhotoData();
|
||||
init = false;
|
||||
}
|
||||
|
||||
// 処理が完了した
|
||||
if (IsImportFinished())
|
||||
{
|
||||
FinalizeImportThread();
|
||||
s_RestoreState = RESTORE_IN_PROGRESS;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
// 書き込み中
|
||||
case RESTORE_IN_PROGRESS:
|
||||
{
|
||||
continueRestore = true;
|
||||
|
||||
// ACアダプタが必要か?
|
||||
if (NeedsAcAdater())
|
||||
{
|
||||
continueRestore = false;
|
||||
operationMessage.push_back(::std::string("Connect AC Adapter!!"));
|
||||
}
|
||||
|
||||
// データを読み込む
|
||||
ImportData();
|
||||
|
||||
// 処理が完了した
|
||||
if (continueRestore && IsImportFinished())
|
||||
{
|
||||
COMMON_LOGGER("Import NAND Data Finished.\n");
|
||||
|
||||
if (GetProgress() > 99)
|
||||
{
|
||||
s_RestoreState = POST_RESTORE;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_RestoreState = FAIL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// リブート中
|
||||
case REBOOTING:
|
||||
{
|
||||
static bool init = true;
|
||||
|
||||
if (init)
|
||||
{
|
||||
// ErrDispから引用
|
||||
// 権限をもらえば成功するはず
|
||||
nn::Result result = nn::ns::CTR::InitializeForShell();
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
COMMON_LOGGER("System Reboot.\n");
|
||||
|
||||
nn::ns::CTR::HardwareResetAsync(nn::CTR::MEMORY_ARRANGE_NORMAL);
|
||||
while (!nn::applet::IsExpectedToCloseApplication())
|
||||
{
|
||||
nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(5));
|
||||
}
|
||||
|
||||
nn::ns::CTR::FinalizeForShell();
|
||||
|
||||
// INFO: リブートは非同期のため処理は継続
|
||||
}
|
||||
init = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// 書き込み後の処理
|
||||
case POST_RESTORE:
|
||||
{
|
||||
operationMessage.push_back(::std::string("Post Process..."));
|
||||
// 書き込み完了ファイルを作成
|
||||
CreateWriteFinishedFile();
|
||||
|
||||
s_RestoreState = RESTORE_DONE;
|
||||
}
|
||||
break;
|
||||
|
||||
// 書き込み完了
|
||||
case RESTORE_DONE:
|
||||
{
|
||||
operationMessage.push_back(::std::string("Restore Done."));
|
||||
operationMessage.push_back(::std::string("Press A or START Button to Reboot"));
|
||||
|
||||
if(!s_PlayedRebootCursor)
|
||||
{
|
||||
PlaySound(SOUND_CURSOR);
|
||||
s_PlayedRebootCursor = true;
|
||||
}
|
||||
|
||||
if (nextStep)
|
||||
{
|
||||
s_RestoreState = REBOOTING;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// 削除処理
|
||||
case ERASE:
|
||||
{
|
||||
Cleanup();
|
||||
s_RestoreState = HISTORY_RECOVER;
|
||||
}
|
||||
break;
|
||||
|
||||
// 削除処理
|
||||
case HISTORY_RECOVER:
|
||||
{
|
||||
static bool init = true;
|
||||
if (init)
|
||||
{
|
||||
// ptmのセーブデータ移行後に時計を無効化する
|
||||
nn::ptm::CTR::InvalidateSystemTime();
|
||||
|
||||
// cfgの本体固有値をcal値で初期化する
|
||||
InitializeHardwareDependentSetting();
|
||||
|
||||
init = false;
|
||||
}
|
||||
|
||||
s_RestoreState = TIME_ADJUST;
|
||||
}
|
||||
|
||||
|
||||
// 時計あわせ
|
||||
case TIME_ADJUST:
|
||||
{
|
||||
static bool init = true;
|
||||
if(init)
|
||||
{
|
||||
COMMON_LOGGER("Adjust Time\n");
|
||||
AdjustTime();
|
||||
init = false;
|
||||
}
|
||||
|
||||
// 動いていることを表示
|
||||
{
|
||||
PutAliveMessage(operationMessage, "Sync Clock");
|
||||
}
|
||||
|
||||
if(IsTimeAdjustFinished())
|
||||
{
|
||||
if(IsTimeAdjustSuccessed())
|
||||
{
|
||||
s_RestoreState = WAIT_SD_EJECT;
|
||||
}
|
||||
else
|
||||
{
|
||||
s_RestoreState = FAIL;
|
||||
}
|
||||
|
||||
// リストア状態チェックファイルをすべて削除
|
||||
DeleteAllCheckFiles();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// すべて完了
|
||||
case WAIT_SD_EJECT:
|
||||
{
|
||||
operationMessage.push_back(::std::string("ALL Done. Pull Out SD Card."));
|
||||
// SDカード抜けのみで次の状態に遷移する
|
||||
|
||||
if (!s_PlayedSdPullOutCursor)
|
||||
{
|
||||
common::PlaySound(common::SOUND_CURSOR);
|
||||
s_PlayedSdPullOutCursor = true;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
// すべて完了
|
||||
case ALL_DONE:
|
||||
{
|
||||
operationMessage.push_back(::std::string("Restore Succeeded!!"));
|
||||
static bool init = true;
|
||||
if (init)
|
||||
{
|
||||
PlaySound(SOUND_OK);
|
||||
init = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// 書き込み失敗
|
||||
case FAIL:
|
||||
{
|
||||
static bool init = true;
|
||||
if(init)
|
||||
{
|
||||
// 状態初期化
|
||||
DeleteAllCheckFiles();
|
||||
init = false;
|
||||
}
|
||||
|
||||
operationMessage.push_back(::std::string("Failed."));
|
||||
if (!s_PlayedFailSound)
|
||||
{
|
||||
PlaySound(SOUND_NG);
|
||||
s_PlayedFailSound = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NUP_ONLY_WAIT_SD_EJECT:
|
||||
{
|
||||
operationMessage.push_back(::std::string("Update Done. Pull Out SD Card."));
|
||||
|
||||
// SDカード抜けのみで次の状態に遷移する
|
||||
if (!s_PlayedSdPullOutCursor)
|
||||
{
|
||||
common::PlaySound(common::SOUND_CURSOR);
|
||||
s_PlayedSdPullOutCursor = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NUP_ONLY_WAIT_NEXT:
|
||||
{
|
||||
operationMessage.push_back(::std::string("A or START Button to Shutdown."));
|
||||
|
||||
if(nextStep)
|
||||
{
|
||||
s_RestoreState = SHUTDOWN;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SHUTDOWN:
|
||||
{
|
||||
// 本体初期化を行う
|
||||
InitializeFileSystem();
|
||||
|
||||
// シャットダウンする
|
||||
nn::ptm::CTR::ShutdownAsync(0, nn::fnd::TimeSpan::FromSeconds(0));
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool InProgress()
|
||||
{
|
||||
return s_RestoreState == RESTORE_IN_PROGRESS;
|
||||
}
|
||||
|
||||
bool IsRestoreSucceeded()
|
||||
{
|
||||
return s_RestoreState == ALL_DONE;
|
||||
}
|
||||
|
||||
bool IsRestoreFailed()
|
||||
{
|
||||
return s_RestoreState == FAIL;
|
||||
}
|
||||
|
||||
void OnSdEjected()
|
||||
{
|
||||
if(s_RestoreState == WAIT_SD_EJECT || s_RestoreState == ALL_DONE)
|
||||
{
|
||||
s_RestoreState = ALL_DONE;
|
||||
}
|
||||
else if(s_RestoreState == NUP_ONLY_WAIT_SD_EJECT || s_RestoreState == NUP_ONLY_WAIT_NEXT)
|
||||
{
|
||||
s_RestoreState = NUP_ONLY_WAIT_NEXT;
|
||||
}
|
||||
// FAILのときは一旦電源を切らないと動かないようにしておく
|
||||
else if(s_RestoreState != FAIL)
|
||||
{
|
||||
InitializeState();
|
||||
ClearFileReadResult();
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeState()
|
||||
{
|
||||
s_RestoreState = STARTUP;
|
||||
s_RestoreMode = RESTORE_MODE_RESTORE;
|
||||
|
||||
common::InitializeFileCheck();
|
||||
|
||||
s_ExistAPSettingAnnotation = false;
|
||||
s_ReadSettingDone = false;
|
||||
s_ReadSettingSuccess = false;
|
||||
s_APSettingAnnotation = false;
|
||||
s_SerialNumberAnnotation = false;
|
||||
s_PlayedFailSound = false;
|
||||
s_ExecuteFgNup = false;
|
||||
s_FgNupRetryCount = 0;
|
||||
s_PlayedStartCursor = false;
|
||||
s_PlayedRebootCursor = false;
|
||||
s_PlayedSdPullOutCursor = false;
|
||||
s_NupOnlyMode = false;
|
||||
s_ReadVersionDone = false;
|
||||
s_SdWriteProetctAnnotation = false;
|
||||
}
|
||||
|
||||
u32 GetProgress()
|
||||
{
|
||||
if(s_RestoreState == RESTORE_TWL_SOUND ||
|
||||
s_RestoreState == RESTORE_TWL_PHOTO ||
|
||||
s_RestoreState == RESTORE_IN_PROGRESS ||
|
||||
s_RestoreState == POST_RESTORE ||
|
||||
s_RestoreState == RESTORE_DONE)
|
||||
{
|
||||
return GetImportProgress();
|
||||
}
|
||||
else if(s_RestoreState == UPDATE_IN_PROGRESS ||
|
||||
s_RestoreState == UPDATE_DONE)
|
||||
{
|
||||
return GetUpdateProgress();
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RestoreMode GetRestoreMode()
|
||||
{
|
||||
return s_RestoreMode;
|
||||
}
|
||||
|
||||
} // namespace ConsoleRestore
|
||||
@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: Contoroller.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CONTOROLLER_H_
|
||||
#define CONTOROLLER_H_
|
||||
|
||||
#include <nn.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace ConsoleRestore
|
||||
{
|
||||
|
||||
typedef enum RestoreMode
|
||||
{
|
||||
RESTORE_MODE_RESTORE,
|
||||
RESTORE_MODE_NUP_ONLY
|
||||
} RestoreMode;
|
||||
|
||||
const u32 RETRY_MAX = 3;
|
||||
|
||||
void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep, bool& continueRestore);
|
||||
bool InProgress();
|
||||
bool IsRestoreSucceeded();
|
||||
bool IsRestoreFailed();
|
||||
u32 GetProgress();
|
||||
|
||||
void OnSdEjected();
|
||||
void InitializeState();
|
||||
RestoreMode GetRestoreMode();
|
||||
|
||||
}
|
||||
|
||||
#endif /* CONTOROLLER_H_ */
|
||||
1486
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/Importer.cpp
Normal file
1486
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/Importer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
95
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/Importer.h
Normal file
95
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/Importer.h
Normal file
@ -0,0 +1,95 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: Importer.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IMPORTER_H_
|
||||
#define IMPORTER_H_
|
||||
|
||||
#include <nn.h>
|
||||
#include "FileName.h"
|
||||
#include <nn/ac/CTR/private/ac_NetworkSetting.h>
|
||||
|
||||
namespace ConsoleRestore
|
||||
{
|
||||
|
||||
bool EqualsDeviceIdFileandDeviceId();
|
||||
bool EqualsRegionDataandRegion();
|
||||
u8* ReadSerialNumber();
|
||||
|
||||
void FinalizeImportThread();
|
||||
bool IsImportFinished();
|
||||
void ImportTwlSoundData();
|
||||
void ImportTwlPhotoData();
|
||||
void ImportData();
|
||||
void CreateWriteFinishedFile();
|
||||
void CreateUpdateFinishedFile();
|
||||
void CreateConsoleInitializedFile();
|
||||
void CreateRtcSyncFinishedFile();
|
||||
u32 GetImportProgress();
|
||||
|
||||
// NANDのごみを削除する
|
||||
void Cleanup();
|
||||
|
||||
const wchar_t* const CHECK_FILENAME_TABLE[] =
|
||||
{
|
||||
common::UPDATE_CHECK_PATHNAME,
|
||||
common::INITIALIZED_CHECK_PATHNAME,
|
||||
common::WRITE_FINISHED_CHECK_PATHNAME,
|
||||
common::RTC_SYNC_CHECK_PATHNAME,
|
||||
};
|
||||
|
||||
void DeleteAllCheckFiles();
|
||||
|
||||
struct TimeZone
|
||||
{
|
||||
u32 hour;
|
||||
u32 minutes;
|
||||
bool isMinus;
|
||||
NN_PADDING3;
|
||||
};
|
||||
|
||||
bool ReadSetting(bool* nupOnly);
|
||||
char* GetNtpServerName();
|
||||
TimeZone GetTimeZone();
|
||||
|
||||
struct CheckedNetworkSetting
|
||||
{
|
||||
nn::ac::CTR::NetworkSetting setting;
|
||||
bool isValid;
|
||||
NN_PADDING3;
|
||||
};
|
||||
|
||||
CheckedNetworkSetting* GetTempNetworkSetting();
|
||||
void ImportCountryLanguageData();
|
||||
void ImportMcuRtc();
|
||||
|
||||
// TWL写真領域を初期化してから本体初期化を行う
|
||||
void InitializeFileSystem();
|
||||
|
||||
void ClearFileReadResult();
|
||||
|
||||
// プレイ履歴を読み込みます。ptmのセーブデータ移行後に呼び出す必要があります
|
||||
void ImportPlayHistory();
|
||||
|
||||
// cfgのハードウェア固有領域をcal値で初期化します
|
||||
void InitializeHardwareDependentSetting();
|
||||
|
||||
// SDカード上のバージョン情報を読みます
|
||||
void ReadVersionData();
|
||||
// 移行元本体がNUP済みかどうか
|
||||
bool AlreadyExecutedNup();
|
||||
|
||||
}
|
||||
|
||||
#endif /* IMPORTER_H_ */
|
||||
376
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/NtpClient.cpp
Normal file
376
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/NtpClient.cpp
Normal file
@ -0,0 +1,376 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: NtpClient.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
#include <nn/socket.h>
|
||||
#include <nn/ac.h>
|
||||
#include <nn/ptm.h>
|
||||
#include <nn/ptm/CTR/ptm_ApiSysmenu.h>
|
||||
#include <nn/ac/private/ac.h>
|
||||
#include <nn/ac/CTR/private/ac_InternalApi.h>
|
||||
#include <nn/ac/CTR/private/ac_NetworkSetting.h>
|
||||
#include <nn/math.h>
|
||||
|
||||
#include "Importer.h"
|
||||
#include "CommonLogger.h"
|
||||
|
||||
namespace ConsoleRestore
|
||||
{
|
||||
|
||||
namespace {
|
||||
|
||||
const size_t NTP_THREAD_STACK_SIZE = 0x1000;
|
||||
nn::os::Thread s_NtpThread;
|
||||
nn::os::StackBuffer<NTP_THREAD_STACK_SIZE> s_NtpThreadStack;
|
||||
bool s_NtpSyncSuccessed = false;
|
||||
|
||||
|
||||
struct NTP_Packet{ // NTPパケット
|
||||
u32 controlWord;
|
||||
u32 rootDelay;
|
||||
u32 rootDispersion;
|
||||
u32 referenceId;
|
||||
s64 referenceTimestamp;
|
||||
s64 startTimestamp;
|
||||
s64 receiveTimestamp;
|
||||
u32 transmitTimestampSeconds;
|
||||
u32 transmitTimestampFractions;
|
||||
};
|
||||
|
||||
const size_t TIMEOUT_MILLISECOND = 5000; // タイムアウト ミリ秒数
|
||||
NTP_Packet s_NTPSendPacket; // 送信するNTPパケット
|
||||
NTP_Packet s_NTPRecvPacket; // 受信するNTPパケット
|
||||
const u32 NTP_PORT_NUM = 123;
|
||||
|
||||
nn::Result InitializeNetwork(void)
|
||||
{
|
||||
nn::Result result;
|
||||
nn::ac::Config config;
|
||||
|
||||
result = nn::ac::Initialize();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
// 接続要求用のパラメータを作成
|
||||
result = nn::ac::CreateDefaultConfig(&config);
|
||||
if (result.IsFailure())
|
||||
{
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// デバッグ用に接続テストを無効化
|
||||
nn::ac::DebugSetNetworkArea(&config, nn::ac::NETWORK_AREA_LAN);
|
||||
|
||||
// 接続要求を発行
|
||||
result = nn::ac::ConnectWithoutEula(config);
|
||||
if (result.IsFailure())
|
||||
{
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
nn::Result FinalizeNetwork(void)
|
||||
{
|
||||
nn::Result result;
|
||||
|
||||
// 接続要求用のパラメータを作成
|
||||
result = nn::ac::Close();
|
||||
NN_UTIL_RETURN_IF_FAILED(result);
|
||||
|
||||
result = nn::ac::Finalize();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
bool GetNtpTime(u32* ntpTime)
|
||||
{
|
||||
nn::Result result;
|
||||
|
||||
bool retval = true;
|
||||
NN_LOG("Initializing network.\n");
|
||||
|
||||
// 本体に書き込まれているネットワーク設定を使ってネットワーク接続を初期化
|
||||
result = InitializeNetwork();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
{
|
||||
NN_LOG("Initializing socket..\n");
|
||||
|
||||
// 一つのスレッドからソケット API を利用する
|
||||
const s32 sessionCount = 1;
|
||||
// ソケットの送受信バッファとして 64 KB を割り当て
|
||||
const size_t bufferSizeForSockets = 65536;
|
||||
// ソケットライブラリに必要なワークサイズを求める
|
||||
const size_t workSizeForLibrary = nn::socket::GetRequiredMemorySize(bufferSizeForSockets, sessionCount);
|
||||
|
||||
// ワークメモリを確保して 4KB にアラインにする
|
||||
u8* pWorkMemory = new u8[workSizeForLibrary + 4096];
|
||||
uptr workMemoryAddress = nn::math::RoundUp<uptr>(reinterpret_cast<uptr> (pWorkMemory), 4096);
|
||||
|
||||
// ソケットライブラリの初期化
|
||||
result = nn::socket::Initialize(workMemoryAddress, workSizeForLibrary, bufferSizeForSockets, sessionCount);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
{
|
||||
s32 ret;
|
||||
nn::socket::InAddr addr, netmask;
|
||||
ret = nn::socket::GetPrimaryAddress(reinterpret_cast<u8*> (&addr), reinterpret_cast<u8*> (&netmask));
|
||||
NN_ASSERT(ret == 0);
|
||||
COMMON_LOGGER("host : %s\n", nn::socket::InetNtoA(addr));
|
||||
COMMON_LOGGER("netmask : %s\n", nn::socket::InetNtoA(netmask));
|
||||
|
||||
nn::socket::InAddr dns1, dns2;
|
||||
ret = nn::socket::GetResolver(reinterpret_cast<u8*> (&dns1), reinterpret_cast<u8*> (&dns2));
|
||||
if (ret == 0)
|
||||
{
|
||||
COMMON_LOGGER("dns1 : %s\n", nn::socket::InetNtoA(dns1));
|
||||
COMMON_LOGGER("dns2 : %s\n", nn::socket::InetNtoA(dns2));
|
||||
}
|
||||
|
||||
nn::socket::InAddr gateway;
|
||||
ret = nn::socket::GetDefaultGateway(reinterpret_cast<u8*> (&gateway));
|
||||
if (ret == 0)
|
||||
{
|
||||
COMMON_LOGGER("gateway : %s\n", nn::socket::InetNtoA(gateway));
|
||||
}
|
||||
|
||||
COMMON_LOGGER("\n");
|
||||
#ifndef NN_SWITCH_DISABLE_DEBUG_PRINT
|
||||
nn::socket::DumpRoutingTable();
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
s32 socket = nn::socket::Socket(nn::socket::PF_INET, nn::socket::SOCK_DGRAM, 0);
|
||||
NN_LOG("socket = %d\n", socket);
|
||||
|
||||
// クライアントアドレスの設定
|
||||
nn::socket::SockAddrIn host_addr;
|
||||
host_addr.len = sizeof(nn::socket::SockAddrIn);
|
||||
host_addr.family = nn::socket::AF_INET;
|
||||
host_addr.addr.addr = 0;
|
||||
host_addr.port = nn::socket::HtoNs(NTP_PORT_NUM);
|
||||
|
||||
// ローカルアドレスをバインド
|
||||
s32 ret = nn::socket::Bind(socket, &host_addr);
|
||||
NN_LOG("bind = %d\n", ret);
|
||||
|
||||
// ********************************************************************************
|
||||
// NTPパケットを生成して送る
|
||||
// ********************************************************************************
|
||||
|
||||
// サーバアドレスの設定
|
||||
nn::socket::SockAddrIn serverSockAddrIn;
|
||||
serverSockAddrIn.len = sizeof(nn::socket::SockAddrIn);
|
||||
serverSockAddrIn.family = nn::socket::AF_INET;
|
||||
|
||||
// GetHostByNameを使う場合
|
||||
nn::socket::HostEnt* serverHostent;
|
||||
u64 serveraddr = 0;
|
||||
serverHostent = nn::socket::GetHostByName(GetNtpServerName());
|
||||
if (serverHostent == NULL)
|
||||
{
|
||||
COMMON_LOGGER("Error: GetHostByName %s\n", GetNtpServerName());
|
||||
retval = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// サーバのホスト情報からIPアドレスをコピー
|
||||
serveraddr = *(reinterpret_cast<u64 *> (serverHostent->addrList[0]));
|
||||
}
|
||||
serverSockAddrIn.addr.addr = serveraddr;
|
||||
COMMON_LOGGER("Destination address: %s\n", nn::socket::InetNtoA(serverSockAddrIn.addr));
|
||||
serverSockAddrIn.port = nn::socket::HtoNs(NTP_PORT_NUM); // ポート番号
|
||||
|
||||
// NTPパケットをSNTP用に初期化する
|
||||
s_NTPSendPacket.controlWord = nn::socket::HtoNl(0x0B000000);
|
||||
s_NTPSendPacket.rootDelay = 0;
|
||||
s_NTPSendPacket.rootDispersion = 0;
|
||||
s_NTPSendPacket.referenceId = 0;
|
||||
s_NTPSendPacket.referenceTimestamp = 0;
|
||||
s_NTPSendPacket.startTimestamp = 0;
|
||||
s_NTPSendPacket.receiveTimestamp = 0;
|
||||
s_NTPSendPacket.transmitTimestampSeconds = 0;
|
||||
s_NTPSendPacket.transmitTimestampFractions = 0;
|
||||
|
||||
// サーバを指定してNTPパケットを送信する
|
||||
if ((ret = nn::socket::SendTo(socket, reinterpret_cast<const void*> (&s_NTPSendPacket), sizeof(s_NTPSendPacket), 0,
|
||||
&serverSockAddrIn)) < 0)
|
||||
{
|
||||
COMMON_LOGGER("Error: Failed Send to Server, %d\n", ret);
|
||||
retval = false;
|
||||
}
|
||||
|
||||
NN_LOG("SendTo finished\n");
|
||||
|
||||
// 受信待ち
|
||||
nn::socket::PollFd pollFd;
|
||||
pollFd.fd = socket;
|
||||
pollFd.events = nn::socket::POLLRDNORM;
|
||||
if ((ret = nn::socket::Poll(&pollFd, 1, TIMEOUT_MILLISECOND)) < 0)
|
||||
{
|
||||
COMMON_LOGGER("Error: recv error, %d\n", ret);
|
||||
retval = false;
|
||||
}
|
||||
|
||||
NN_LOG("Poll Finished\n");
|
||||
|
||||
switch (pollFd.revents)
|
||||
{
|
||||
case nn::socket::POLLERR: // ソケットにエラーが発生しました。
|
||||
COMMON_LOGGER("Error: POLLERR %s %d\n", __FILE__, __LINE__);
|
||||
retval = false;
|
||||
break;
|
||||
case nn::socket::POLLHUP: // ストリーム・ソケットが未接続です。
|
||||
COMMON_LOGGER("Error: POLLHUP %s %d\n", __FILE__, __LINE__);
|
||||
retval = false;
|
||||
break;
|
||||
case nn::socket::POLLNVAL: // 不正なソケット記述子です。
|
||||
COMMON_LOGGER("Error: POLLNVAL %s %d\n", __FILE__, __LINE__);
|
||||
retval = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// サーバから時刻情報を受信する
|
||||
// サーバを指定して受信を行う
|
||||
// 受信するまで待たされる
|
||||
if ((ret = nn::socket::RecvFrom(socket, reinterpret_cast<void*> (&s_NTPRecvPacket), sizeof(s_NTPRecvPacket), nn::socket::MSG_DONTWAIT,
|
||||
&serverSockAddrIn)) < 0)
|
||||
{
|
||||
COMMON_LOGGER("Error: RecvFrom, %d\n", ret);
|
||||
retval = false;
|
||||
}
|
||||
|
||||
NN_LOG("RecvFrom finished\n");
|
||||
|
||||
// NTPサーバから取得した時刻を現地時間に変換する
|
||||
*ntpTime = nn::socket::NtoHl(s_NTPRecvPacket.transmitTimestampSeconds) - 2208988800; /* 1970/01/01 からの秒数に変換 */
|
||||
NN_LOG("ntp_time = %d\n", ntpTime);
|
||||
|
||||
nn::socket::Close(socket);
|
||||
NN_UNUSED_VAR(ret);
|
||||
}
|
||||
|
||||
NN_LOG("Finalizing socket..\n");
|
||||
// ソケットライブラリの終了
|
||||
result = nn::socket::Finalize();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
}
|
||||
|
||||
NN_LOG("Finalizing network.\n");
|
||||
result = FinalizeNetwork();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void RestoreCurrentInternetSetting()
|
||||
{
|
||||
COMMON_LOGGER("Restore Current Internet Setting\n");
|
||||
nn::Result result;
|
||||
if (GetTempNetworkSetting()->isValid)
|
||||
{
|
||||
result = nn::ac::CTR::UpdateNetworkSetting(0, GetTempNetworkSetting()->setting);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 無効の場合は消去しておく
|
||||
result = nn::ac::CTR::RemoveNetworkSetting(0);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED(result);
|
||||
}
|
||||
|
||||
result = nn::ac::FlushNetworkSetting();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED(result);
|
||||
|
||||
result = nn::ac::FinalizeInternal();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void NtpThreadFunc()
|
||||
{
|
||||
// NTP時間を取得する
|
||||
u32 ntpTime;
|
||||
if (GetNtpTime(&ntpTime))
|
||||
{
|
||||
// タイムゾーンを考慮してDateTimeに変換する
|
||||
TimeZone timeZone = GetTimeZone();
|
||||
|
||||
// 1970/01/01
|
||||
nn::fnd::DateTime utc = nn::fnd::DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
nn::fnd::DateTime current = utc + nn::fnd::TimeSpan::FromSeconds(ntpTime);
|
||||
|
||||
if (timeZone.isMinus)
|
||||
{
|
||||
current -= (nn::fnd::TimeSpan::FromHours(timeZone.hour) + nn::fnd::TimeSpan::FromMinutes(timeZone.minutes));
|
||||
}
|
||||
else
|
||||
{
|
||||
current += nn::fnd::TimeSpan::FromHours(timeZone.hour) + nn::fnd::TimeSpan::FromMinutes(timeZone.minutes);
|
||||
}
|
||||
|
||||
// SWCを書き込む
|
||||
nn::ptm::CTR::SetUserTime(current);
|
||||
|
||||
COMMON_LOGGER("Set User Time %04d/%02d/%02d %02d:%02d:%02d\n",
|
||||
current.GetYear(), current.GetMonth(), current.GetDay(), current.GetHour(), current.GetMinute(), current.GetSecond());
|
||||
|
||||
s_NtpSyncSuccessed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
COMMON_LOGGER("Failed Get Ntp Time\n");
|
||||
s_NtpSyncSuccessed = false;
|
||||
}
|
||||
|
||||
// インターネット設定を元に戻す
|
||||
RestoreCurrentInternetSetting();
|
||||
}
|
||||
|
||||
bool IsTimeAdjustFinished()
|
||||
{
|
||||
// Initialize済みかつ終了
|
||||
return s_NtpThread.IsValid() && !s_NtpThread.IsAlive();
|
||||
}
|
||||
|
||||
bool IsTimeAdjustSuccessed()
|
||||
{
|
||||
return s_NtpSyncSuccessed;
|
||||
}
|
||||
|
||||
void AdjustTime()
|
||||
{
|
||||
nn::Result result;
|
||||
|
||||
result = nn::ac::CTR::InitializeInternal();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED(result);
|
||||
|
||||
if(IsTimeAdjustFinished())
|
||||
{
|
||||
s_NtpThread.Join();
|
||||
s_NtpThread.Finalize();
|
||||
}
|
||||
s_NtpThread.Start( NtpThreadFunc, s_NtpThreadStack);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: NtpClient.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef NTPCLIENT_H_
|
||||
#define NTPCLIENT_H_
|
||||
|
||||
namespace ConsoleRestore
|
||||
{
|
||||
|
||||
u32 AdjustTime();
|
||||
bool IsTimeAdjustFinished();
|
||||
bool IsTimeAdjustSuccessed();
|
||||
|
||||
}
|
||||
|
||||
#endif /* NTPCLIENT_H_ */
|
||||
89
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/OMakefile
Normal file
89
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/OMakefile
Normal file
@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env omake
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: Horizon
|
||||
# File: OMakefile
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# $Rev$
|
||||
#----------------------------------------------------------------------------
|
||||
SUPPORTED_TARGETS = CTR-T*.Process.MPCore.*
|
||||
#MAKECSU = true
|
||||
#INSTALL_SDK_TOOL = true
|
||||
CTR_APPTYPE = BOTH
|
||||
CTR_MAKE_DEVELOPMENT_IMAGE = true
|
||||
|
||||
TARGET_PROGRAM = ConsoleRestore
|
||||
|
||||
SAMPLED_DEMOS_COMMON_INCLUDE_DIR = $(dir $(HORIZON_ROOT)/../CTR/SampleDemos/common/include)
|
||||
INCLUDES += $(SAMPLED_DEMOS_COMMON_INCLUDE_DIR) \
|
||||
../common
|
||||
|
||||
SOURCES[] =
|
||||
ConsoleRestore.cpp
|
||||
Controller.cpp
|
||||
Importer.cpp
|
||||
Updater.cpp
|
||||
Ntpclient.cpp
|
||||
../common/HardwareInfo.cpp
|
||||
../common/DrawSystemState.cpp
|
||||
../common/FileTransfer.cpp
|
||||
../common/FileChecker.cpp
|
||||
../common/SdReaderWriter.cpp
|
||||
../common/HeapManager.cpp
|
||||
../common/SdLogger.cpp
|
||||
../common/wave.cpp
|
||||
../common/SimplePlayer.cpp
|
||||
../common/LogConsole.cpp
|
||||
../common/CommonLogger.cpp
|
||||
../common/SdMountManager.cpp
|
||||
../common/configLoader.cpp
|
||||
../common/PlayHistoryManager.cpp
|
||||
../common/VersionDetect.cpp
|
||||
|
||||
CTR_BANNER_SPEC = $(TARGET_PROGRAM).bsf
|
||||
|
||||
ROMFS_ROOT = ../common/romfiles
|
||||
|
||||
LIBS += libnn_cfg \
|
||||
libnn_driversEeprom \
|
||||
libnn_driversi2c \
|
||||
libnn_driversCal \
|
||||
libnn_crypto \
|
||||
libnn_driversCodec \
|
||||
libnn_spi \
|
||||
libnn_gpio \
|
||||
libnn_pdn \
|
||||
libnn_mcu \
|
||||
libnn_i2c \
|
||||
libnn_driversCamera \
|
||||
libnn_ps \
|
||||
libnn_driversRsa \
|
||||
lib_demo \
|
||||
libnn_nwm \
|
||||
libnn_friends \
|
||||
libnn_ns \
|
||||
libnn_am \
|
||||
libnn_nim \
|
||||
|
||||
INSTALL_SDK_TOOL = true
|
||||
|
||||
ROM_SPEC_FILE = $(TARGET_PROGRAM).rsf
|
||||
DESCRIPTOR = $(HORIZON_ROOT)/resources/specfiles/_private/RepairTool.desc
|
||||
|
||||
include $(ROOT_OMAKE)/modulerules
|
||||
|
||||
VERSION_H = $(file version.h)
|
||||
|
||||
$(VERSION_H): $(SOURCES)
|
||||
section
|
||||
bash genversion.sh
|
||||
|
||||
RequireSetup($(VERSION_H))
|
||||
build: version.h $(DEFAULT_TARGETS)
|
||||
249
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/Updater.cpp
Normal file
249
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/Updater.cpp
Normal file
@ -0,0 +1,249 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: Updater.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn/os.h>
|
||||
#include <nn/Handle.h>
|
||||
#include <nn/dbg.h>
|
||||
#include <nn/nim.h>
|
||||
#include <nn/cfg.h>
|
||||
#include <nn/cfg/CTR/cfg_ApiInit.h>
|
||||
#include <nn/ac/private/ac.h>
|
||||
#include <nn/ac/CTR/private/ac_InternalApi.h>
|
||||
|
||||
#include "CommonLogger.h"
|
||||
|
||||
namespace ConsoleRestore
|
||||
{
|
||||
|
||||
using namespace ES_NAMESPACE;
|
||||
using namespace EC_NAMESPACE;
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
GetCustomerSupportCode
|
||||
-------------------------------------------------------------------- */
|
||||
#define NIM_UPDATER_RESULT_CHECK(result) \
|
||||
do { \
|
||||
if (result.IsFailure()) \
|
||||
{ \
|
||||
ECCustomerSupportCode csc; \
|
||||
NN_UTIL_PANIC_IF_FAILED( \
|
||||
nn::nim::Updater::GetCustomerSupportCode(&csc)); \
|
||||
COMMON_LOGGER("CSCode: %d\n", csc); \
|
||||
nn::dbg::PrintResult(result); \
|
||||
s_Result = result; \
|
||||
goto LABEL_FINALIZE; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
nn::Result s_Result = nn::ResultSuccess();
|
||||
|
||||
const size_t UPDATER_THREAD_STACK_SIZE = 0x1000;
|
||||
nn::os::Thread s_UpdaterThread;
|
||||
nn::os::StackBuffer<UPDATER_THREAD_STACK_SIZE> s_UpdaterThreadStack;
|
||||
|
||||
u64 s_Progress = 0;
|
||||
|
||||
}
|
||||
|
||||
nn::Result PrintNetworkSetting()
|
||||
{
|
||||
nn::ac::NetworkSetting networkSetting;
|
||||
NN_UTIL_RETURN_IF_FAILED(nn::ac::LoadNetworkSetting(0, networkSetting));
|
||||
COMMON_LOGGER("SSID: %s\n", networkSetting.wireless.essidSecurity.ssid);
|
||||
COMMON_LOGGER("DNS : %d.%d.%d.%d\n",
|
||||
networkSetting.ip.dns[0][0], networkSetting.ip.dns[0][1],
|
||||
networkSetting.ip.dns[0][2], networkSetting.ip.dns[0][3]);
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
|
||||
nn::Result ConnectNetwork()
|
||||
{
|
||||
nn::Result result = nn::ResultSuccess();
|
||||
nn::ac::Config config;
|
||||
|
||||
result = nn::ac::CreateDefaultConfig(&config);
|
||||
NN_UTIL_RETURN_IF_FAILED(result);
|
||||
|
||||
result = nn::ac::ConnectWithoutEula(config);
|
||||
NN_UTIL_RETURN_IF_FAILED(result);
|
||||
|
||||
NN_LOG("Success nn::ac::ConnectWithoutEula\n");
|
||||
|
||||
NN_UTIL_RETURN_IF_FAILED(PrintNetworkSetting());
|
||||
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
nn::Result InitializeInternal()
|
||||
{
|
||||
nn::Result result = nn::ResultSuccess();
|
||||
|
||||
result = nn::ac::InitializeInternal();
|
||||
NN_UTIL_RETURN_IF_FAILED(result);
|
||||
|
||||
result = ConnectNetwork();
|
||||
NN_UTIL_RETURN_IF_FAILED(result);
|
||||
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
nn::Result FinalizeInternal()
|
||||
{
|
||||
nn::Result result = nn::ResultSuccess();
|
||||
|
||||
nn::ac::CloseAll();
|
||||
|
||||
result = nn::ac::FinalizeInternal();
|
||||
NN_UTIL_RETURN_IF_FAILED(result);
|
||||
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
void UpdateThreadFunc()
|
||||
{
|
||||
nn::Result result;
|
||||
|
||||
NN_LOG("********************UpdateThreadFunc Start********************\n");
|
||||
nn::cfg::CTR::init::Initialize();
|
||||
nn::cfg::CfgCountryCode country;
|
||||
nn::cfg::CfgRegionCode region;
|
||||
const char *regionStr;
|
||||
const char *countryStr;
|
||||
NN_UNUSED_VAR(regionStr);
|
||||
NN_UNUSED_VAR(countryStr);
|
||||
|
||||
country = nn::cfg::GetCountry();
|
||||
region = nn::cfg::GetRegion();
|
||||
countryStr = nn::cfg::GetCountryCodeA2(country);
|
||||
regionStr = nn::cfg::GetRegionCodeA3(region);
|
||||
|
||||
COMMON_LOGGER("[Updater] country:%2d:%s\n", country, countryStr);
|
||||
COMMON_LOGGER("[Updater] region :%2d:%s\n", region, regionStr);
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
Initialize
|
||||
-------------------------------------------------------------------- */
|
||||
NN_LOG("[Updater] nn::nim::InitializeForUpdater\n");
|
||||
result = nn::nim::InitializeForUpdater();
|
||||
NIM_UPDATER_RESULT_CHECK(result);
|
||||
|
||||
NN_LOG("[Updater] InitializeInternal\n");
|
||||
result = InitializeInternal();
|
||||
NIM_UPDATER_RESULT_CHECK(result);
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
StartNetworkUpdate
|
||||
-------------------------------------------------------------------- */
|
||||
NN_LOG("[Updater] nn::nim::Updater::StartNetworkUpdate()\n");
|
||||
result = nn::nim::Updater::StartNetworkUpdate();
|
||||
NIM_UPDATER_RESULT_CHECK(result);
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
GetProgress
|
||||
-------------------------------------------------------------------- */
|
||||
NN_LOG("[Updater] nn::nim::Updater::GetProgress()\n");
|
||||
|
||||
while(true)
|
||||
{
|
||||
nn::nim::NetworkUpdateProgress progress;
|
||||
NIM_UPDATER_RESULT_CHECK(nn::nim::Updater::GetProgress(&progress));
|
||||
NIM_UPDATER_RESULT_CHECK(progress.lastResult);
|
||||
NN_LOG("\x1b[1A\x1b[K");
|
||||
NN_LOG("Downloading %2lld/%2lld %8lld/%8lld (%d)\n",
|
||||
progress.downloadedTitleNum,
|
||||
progress.totalTitleNum,
|
||||
progress.currentDownloadedSize,
|
||||
progress.currentTotalSize,
|
||||
progress.state);
|
||||
|
||||
// ゼロ除算を防ぐ
|
||||
if(progress.totalTitleNum == 0)
|
||||
{
|
||||
progress.totalTitleNum++;
|
||||
progress.downloadedTitleNum++;
|
||||
}
|
||||
if(progress.state > nn::nim::CTR::NUP_STATE_CHECKING)
|
||||
{
|
||||
s_Progress = progress.downloadedTitleNum * 100 / progress.totalTitleNum;
|
||||
}
|
||||
|
||||
if (progress.state == nn::nim::NUP_STATE_NO_NEED)
|
||||
{
|
||||
COMMON_LOGGER("[Updater] No need to NetworkUpdate\n");
|
||||
s_Progress = 100;
|
||||
break;
|
||||
}
|
||||
if (progress.state == nn::nim::NUP_STATE_FINISHED)
|
||||
{
|
||||
COMMON_LOGGER("[Updater] Finished NetworkUpdate\n");
|
||||
s_Progress = 100;
|
||||
break;
|
||||
}
|
||||
|
||||
nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(300));
|
||||
}
|
||||
|
||||
LABEL_FINALIZE:
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
Finalize
|
||||
-------------------------------------------------------------------- */
|
||||
NN_LOG("[Updater] nn::nim::FinalizeForUpdater\n");
|
||||
result = nn::nim::FinalizeForUpdater();
|
||||
NIM_UPDATER_RESULT_CHECK(result);
|
||||
|
||||
result = FinalizeInternal();
|
||||
NIM_UPDATER_RESULT_CHECK(result);
|
||||
|
||||
NN_LOG("[Updater] Finish nim Updater demo.\n");
|
||||
|
||||
}
|
||||
|
||||
void StartFGNetworkUpdate()
|
||||
{
|
||||
NN_LOG("Start FGNetworkUpdate\n");
|
||||
s_Result = nn::ResultSuccess();
|
||||
s_UpdaterThread.Start(UpdateThreadFunc, s_UpdaterThreadStack);
|
||||
}
|
||||
|
||||
void FinishFGNetworkUpdate()
|
||||
{
|
||||
NN_LOG("Finalize FGNetworkUpdate\n");
|
||||
s_UpdaterThread.Join();
|
||||
s_UpdaterThread.Finalize();
|
||||
}
|
||||
|
||||
bool IsNetworkUpdateFinished()
|
||||
{
|
||||
return !s_UpdaterThread.IsAlive();
|
||||
}
|
||||
|
||||
u32 GetUpdateProgress()
|
||||
{
|
||||
return s_Progress;
|
||||
}
|
||||
|
||||
nn::Result GetUpdateResult()
|
||||
{
|
||||
return s_Result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
32
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/Updater.h
Normal file
32
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/Updater.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: Updater.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef UPDATER_H_
|
||||
#define UPDATER_H_
|
||||
|
||||
#include <nn.h>
|
||||
|
||||
namespace ConsoleRestore
|
||||
{
|
||||
|
||||
void StartFGNetworkUpdate();
|
||||
void FinishFGNetworkUpdate();
|
||||
bool IsNetworkUpdateFinished();
|
||||
u32 GetUpdateProgress();
|
||||
nn::Result GetUpdateResult();
|
||||
|
||||
}
|
||||
|
||||
#endif /* UPDATER_H_ */
|
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ф8ф8фШчГГГГГГВ╫В╫8фВ╫В╫В╫В╫В╫ГГГГшчфГШФВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫yнВ╫yнВ╫В╫В╫В╫В╫YнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ГГГГШчyнYнВ╫шчшчВ╫В╫фВ╫В╫шчyнШчВ╫yнГГГГyнШФГГГГГшчВ╫В╫В╫В╫YнГyнГВ╫В╫В╫В╫В╫yнфшчГШФГYнyнВ╫В╫В╫yнВ╫╨жВ╫В╫В╫В╫В╫yнВ╫yнВ╫В╫В╫В╫В╫YнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫yнГYнГВ╫В╫В╫В╫В╫фВ╫В╫ГyнГ8фВ╫В╫В╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫
|
||||
@ -0,0 +1 @@
|
||||
В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫YнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫8ф8фВ╫В╫В╫╨ж8ф╨жГГшчГГГГГГГГГГГГГГГГГГГГГГГВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8ф8фВ╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ГГГГГШФГГГГГГГГГГ жфГГВ╫В╫ жВ╫ГГГГГ жГГВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫шчВ╫шчВ╫В╫В╫В╫В╫ГВ╫ШчВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫╨жВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ГГГГГГГГГГГГГГГГГГШФ8фШчшчВ╫В╫ жВ╫YнВ╫В╫В╫В╫В╫ГГYнyнГГyнфВ╫В╫В╫В╫В╫В╫В╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫шчшчГшчШФВ╫В╫ГГYнГВ╫В╫В╫В╫В╫шчВ╫шчГГГГГГГГГГГГГГГГВ╫В╫YнШч жГГГГГГГГГГГГГГГГГГГГГГГГшч╨жВ╫ жВ╫шчВ╫В╫В╫В╫В╫ШФВ╫ШФВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫шчВ╫yнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫YнВ╫ жГГГГВ╫шчВ╫шчГГГГВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫╨жшчВ╫В╫В╫В╫В╫YнфyнГГГГГГГГГ жГГГГ╨жВ╫YнВ╫ШФYнВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫шч жВ╫В╫В╫В╫В╫В╫yнВ╫ГШФВ╫В╫фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ШФВ╫ГГГГГВ╫ШчВ╫YнГГШФГВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫ГГГГ жВ╫шчВ╫ГГГшч жВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫8фВ╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫В╫
|
||||
3
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/genversion.sh
Executable file
3
tags/0thNUP_2/ConsoleDataMigration/ConsoleRestore/genversion.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash -f
|
||||
|
||||
echo "#define RESTORE_VERSION_NUM \"`svnversion -n`\"" > version.h
|
||||
24
tags/0thNUP_2/ConsoleDataMigration/OMakefile
Normal file
24
tags/0thNUP_2/ConsoleDataMigration/OMakefile
Normal file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env omake
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: Horizon
|
||||
# File: OMakefile
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# $Rev$
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
#.SUBDIRS: $(glob D, *)
|
||||
.SUBDIRS: $(exist-dirs \
|
||||
common \
|
||||
ConsoleBackup \
|
||||
ConsoleRestore \
|
||||
)
|
||||
|
||||
DefineDefaultRules()
|
||||
73
tags/0thNUP_2/ConsoleDataMigration/OMakeroot
Normal file
73
tags/0thNUP_2/ConsoleDataMigration/OMakeroot
Normal file
@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env omake
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: Horizon
|
||||
# File: OMakeroot
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# $Rev:$
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
# ディレクトリレイアウトについての説明
|
||||
#
|
||||
# a) ソースコードがルートディレクトリ直下に配置される場合
|
||||
# 例:
|
||||
# /OMakeroot
|
||||
# /foo/bar/OMakefile
|
||||
#
|
||||
# 結果:
|
||||
# OMakefile と同じディレクトリ以下に objects や images が生成されます。
|
||||
#
|
||||
# /foo/bar/objects/...
|
||||
# /foo/bar/images/..
|
||||
#
|
||||
#
|
||||
# b) ソースコードが sources 以下に配置される場合
|
||||
# 例:
|
||||
# /OMakeroot
|
||||
# /sources/foo/bar/OMakefile
|
||||
#
|
||||
# 結果:
|
||||
# ルートディレクトリ以下に objects や images が生成されます。
|
||||
#
|
||||
# /objects/foo/bar/...
|
||||
# /images/foo/bar/...
|
||||
#
|
||||
#
|
||||
|
||||
# ルート環境変数の取得
|
||||
public.HORIZON_ROOT =
|
||||
if $(defined-env HORIZON_ROOT)
|
||||
HORIZON_ROOT = $(absname $(getenv HORIZON_ROOT))
|
||||
export
|
||||
|
||||
if $(defined-env CTRSDK_ROOT)
|
||||
CTRSDK_ROOT = $(absname $(getenv CTRSDK_ROOT))
|
||||
if $(and $(defined-env HORIZON_ROOT), $(not $(equal $(HORIZON_ROOT), $(CTRSDK_ROOT))))
|
||||
eprintln(HORIZON_ROOT と CTRSDK_ROOT が一致しません。同じパスを設定するか、どちらか一方だけを定義して下さい。)
|
||||
exit(1)
|
||||
HORIZON_ROOT = $(CTRSDK_ROOT)
|
||||
export
|
||||
|
||||
if $(not $(HORIZON_ROOT))
|
||||
eprintln($"$$CTRSDK_ROOT が定義されていません")
|
||||
exit(1)
|
||||
|
||||
include $(HORIZON_ROOT)/build/omake/commondefs
|
||||
|
||||
DefineCommandVars()
|
||||
|
||||
.PHONY: all build clean clobber
|
||||
.PHONY: run run-scripts run-emumem
|
||||
|
||||
#
|
||||
# OMakefile の読み込み
|
||||
#
|
||||
.SUBDIRS: .
|
||||
|
||||
10
tags/0thNUP_2/ConsoleDataMigration/Readme.txt
Normal file
10
tags/0thNUP_2/ConsoleDataMigration/Readme.txt
Normal file
@ -0,0 +1,10 @@
|
||||
【ビルド環境】
|
||||
|
||||
・SDK
|
||||
Horizon 0_14 branch r33437
|
||||
+ Horizon trunk r33597のcfgライブラリの変更をマージ
|
||||
+ Horizon 1_0 branch r33839のRepairTool.descをマージ
|
||||
|
||||
・cygwin
|
||||
・svnversion
|
||||
|
||||
28
tags/0thNUP_2/ConsoleDataMigration/common/Aes_define.h
Normal file
28
tags/0thNUP_2/ConsoleDataMigration/common/Aes_define.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: Aes_define.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef AES_DEFINE_H_
|
||||
#define AES_DEFINE_H_
|
||||
|
||||
namespace common
|
||||
{
|
||||
bit8 key[AES_KEY_SIZE] =
|
||||
{
|
||||
0x81, 0x35, 0xc6, 0x54, 0x19, 0x1a, 0x47, 0x2a,
|
||||
0x6b, 0x78, 0xbe, 0x25, 0x90, 0xf6, 0xee, 0x74
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* AES_DEFINE_H_ */
|
||||
117
tags/0thNUP_2/ConsoleDataMigration/common/CommonLogger.cpp
Normal file
117
tags/0thNUP_2/ConsoleDataMigration/common/CommonLogger.cpp
Normal file
@ -0,0 +1,117 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: CommonLogger.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "CommonLogger.h"
|
||||
#include "LogConsole_Private.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
static CommonLogger s_CommonLogger;
|
||||
|
||||
}
|
||||
|
||||
CommonLogger::CommonLogger()
|
||||
{
|
||||
// TODO 自動生成されたコンストラクター・スタブ
|
||||
|
||||
}
|
||||
|
||||
CommonLogger::~CommonLogger()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
void CommonLogger::Initialize(u32 width, u32 height, u32 maxLine, demo::RenderSystemDrawing* renderSystem)
|
||||
{
|
||||
m_CriticalSection.Initialize();
|
||||
GetConsoleInstance()->Initialize(width, height, maxLine, renderSystem);
|
||||
}
|
||||
|
||||
void CommonLogger::Finalize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CommonLogger::Print(const char* fmt, ...)
|
||||
{
|
||||
nn::os::CriticalSection::ScopedLock lock(m_CriticalSection);
|
||||
va_list vlist;
|
||||
|
||||
va_start(vlist, fmt);
|
||||
|
||||
nn::dbg::detail::VPrintf(fmt, vlist);
|
||||
GetSdInstance()->Print(fmt, vlist);
|
||||
GetConsoleInstance()->AddText(fmt, vlist);
|
||||
|
||||
va_end(vlist);
|
||||
}
|
||||
|
||||
void CommonLogger::PrintResult(const char* fmt, ...)
|
||||
{
|
||||
nn::os::CriticalSection::ScopedLock lock(m_CriticalSection);
|
||||
va_list vlist;
|
||||
|
||||
va_start(vlist, fmt);
|
||||
|
||||
GetSdInstance()->Print(fmt, vlist);
|
||||
|
||||
va_end(vlist);
|
||||
}
|
||||
|
||||
void CommonLogger::ClearLog()
|
||||
{
|
||||
nn::os::CriticalSection::ScopedLock lock(m_CriticalSection);
|
||||
GetSdInstance()->Clear();
|
||||
}
|
||||
|
||||
void CommonLogger::ScrollUp()
|
||||
{
|
||||
GetConsoleInstance()->ScrollUp();
|
||||
}
|
||||
|
||||
void CommonLogger::ScrollDown()
|
||||
{
|
||||
GetConsoleInstance()->ScrollDown();
|
||||
}
|
||||
|
||||
void CommonLogger::ScrollToBegin()
|
||||
{
|
||||
GetConsoleInstance()->ScrollToBegin();
|
||||
}
|
||||
|
||||
void CommonLogger::ScrollToEnd()
|
||||
{
|
||||
GetConsoleInstance()->ScrollToEnd();
|
||||
}
|
||||
|
||||
void CommonLogger::DrawConsole()
|
||||
{
|
||||
GetConsoleInstance()->Print();
|
||||
}
|
||||
|
||||
CommonLogger* GetLoggerInstance()
|
||||
{
|
||||
return &s_CommonLogger;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
84
tags/0thNUP_2/ConsoleDataMigration/common/CommonLogger.h
Normal file
84
tags/0thNUP_2/ConsoleDataMigration/common/CommonLogger.h
Normal file
@ -0,0 +1,84 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: CommonLogger.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef COMMONLOGGER_H_
|
||||
#define COMMONLOGGER_H_
|
||||
|
||||
#include <nn.h>
|
||||
#include "demo.h"
|
||||
|
||||
#include "SdLogger.h"
|
||||
#include "LogConsole.h"
|
||||
|
||||
#define COMMON_LOGGER( ... ) (void)common::Logger::GetLoggerInstance()->Print(__VA_ARGS__)
|
||||
#define COMMON_LOGGER_RESULT(result, func) \
|
||||
(void)nn::dbg::PrintResult(result); \
|
||||
(void)common::Logger::GetLoggerInstance()->PrintResult("Func = %s\n", func); \
|
||||
(void)common::Logger::GetLoggerInstance()->PrintResult("Result = %X\n", result.GetPrintableBits()); \
|
||||
|
||||
#define COMMON_LOGGER_RESULT_WITH_LINE(result, line, func) \
|
||||
(void)nn::dbg::detail::Printf("%s\n", func); \
|
||||
(void)nn::dbg::detail::Printf("%d\n", line); \
|
||||
(void)nn::dbg::PrintResult(result); \
|
||||
(void)common::Logger::GetLoggerInstance()->PrintResult("Func = %s\n", func); \
|
||||
(void)common::Logger::GetLoggerInstance()->PrintResult("line = %d\n", line); \
|
||||
(void)common::Logger::GetLoggerInstance()->PrintResult("Result = %X\n", result.GetPrintableBits()); \
|
||||
|
||||
#define COMMON_LOGGER_RESULT_IF_FAILED(result) \
|
||||
if(result.IsFailure()) \
|
||||
{ \
|
||||
COMMON_LOGGER_RESULT(result, __func__); \
|
||||
} \
|
||||
|
||||
#define COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result) \
|
||||
if(result.IsFailure()) \
|
||||
{ \
|
||||
COMMON_LOGGER_RESULT_WITH_LINE(result, __LINE__, __func__); \
|
||||
} \
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
|
||||
class CommonLogger
|
||||
{
|
||||
public:
|
||||
CommonLogger();
|
||||
~CommonLogger();
|
||||
|
||||
void Initialize(u32 width, u32 height, u32 maxLine, demo::RenderSystemDrawing* renderSystem);
|
||||
void Finalize();
|
||||
|
||||
void Print(const char* fmt, ...);
|
||||
void PrintResult(const char* fmt, ...);
|
||||
void ClearLog();
|
||||
void ScrollUp();
|
||||
void ScrollDown();
|
||||
void ScrollToBegin();
|
||||
void ScrollToEnd();
|
||||
void DrawConsole();
|
||||
private:
|
||||
nn::os::CriticalSection m_CriticalSection;
|
||||
};
|
||||
|
||||
CommonLogger* GetLoggerInstance();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* COMMONLOGGER_H_ */
|
||||
120
tags/0thNUP_2/ConsoleDataMigration/common/DrawSystemState.cpp
Normal file
120
tags/0thNUP_2/ConsoleDataMigration/common/DrawSystemState.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: DrawSystemState.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "DrawSystemState.h"
|
||||
|
||||
const u16 PROGRESS_MAX_LINES = 129;
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
u32 GetRenderTarget(u32 target, bool flip)
|
||||
{
|
||||
if(flip)
|
||||
{
|
||||
if(target == NN_GX_DISPLAY0)
|
||||
{
|
||||
return NN_GX_DISPLAY1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NN_GX_DISPLAY0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawSystemState
|
||||
(
|
||||
const char* toolName,
|
||||
demo::RenderSystemDrawing& renderSystem,
|
||||
nn::util::FloatColor titleColor,
|
||||
bool flip,
|
||||
std::string& adapterState,
|
||||
const char* toolVersion,
|
||||
common::VerDef* mVerData,
|
||||
u8 batteryRemain,
|
||||
u64 deviceId,
|
||||
u64 friendCode,
|
||||
u32 progress,
|
||||
char8* macAddress,
|
||||
::std::vector<std::string>& operationMessage,
|
||||
nn::cfg::CTR::CfgRegionCode region,
|
||||
u8* s_SerialNo
|
||||
)
|
||||
{
|
||||
// デフォルトで上画面に描画するもの
|
||||
renderSystem.SetRenderTarget(GetRenderTarget(NN_GX_DISPLAY0, flip));
|
||||
renderSystem.SetClearColor(GetRenderTarget(NN_GX_DISPLAY0, flip), NORMAL_COLOR);
|
||||
|
||||
|
||||
renderSystem.Clear();
|
||||
renderSystem.SetColor(1.f, 1.f, 1.f);
|
||||
u32 line = 0;
|
||||
|
||||
size_t fontSize = 8;
|
||||
size_t spaceSize = fontSize + 2;
|
||||
renderSystem.SetFontSize(fontSize);
|
||||
|
||||
renderSystem.DrawText(0, line++ * spaceSize, "%s %s Rev.%s", toolName, __DATE__, toolVersion);
|
||||
renderSystem.SetColor(titleColor.r, titleColor.g, titleColor.b);
|
||||
renderSystem.FillRectangle(0, (line - 1) * spaceSize, 400, spaceSize);
|
||||
renderSystem.SetColor(1.f, 1.f, 1.f);
|
||||
renderSystem.DrawText(0, line++ * spaceSize, "");
|
||||
|
||||
fontSize += 2;
|
||||
spaceSize = fontSize + 2;
|
||||
renderSystem.SetFontSize(fontSize);
|
||||
renderSystem.DrawText(0, line++ * spaceSize, "System Ver. %d.%d.%d-%d", mVerData->cup.majorVersion, mVerData->cup.minorVersion, mVerData->cup.microVersion,
|
||||
mVerData->nup.majorVersion);
|
||||
renderSystem.DrawText(0, line++ * spaceSize, "System Region %s", nn::cfg::CTR::GetRegionCodeA3(region));
|
||||
renderSystem.DrawText(0, line++ * spaceSize, "Serial No. %s", s_SerialNo);
|
||||
renderSystem.DrawText(0, line++ * spaceSize, "Device ID %llu", deviceId);
|
||||
renderSystem.DrawText(0, line++ * spaceSize, "MAC Address %s", macAddress);
|
||||
renderSystem.DrawText(0, line++ * spaceSize, "Friend Code %04u-%04u-%04u", static_cast<u32> (friendCode
|
||||
/ 100000000ULL % 10000ULL), static_cast<u32> (friendCode / 10000ULL % 10000ULL),
|
||||
static_cast<u32> (friendCode % 10000ULL));
|
||||
|
||||
renderSystem.DrawText(0, line++ * spaceSize, "Battery %d%%", batteryRemain);
|
||||
renderSystem.DrawText(0, line++ * spaceSize, "AC Adaper %s", adapterState.c_str());
|
||||
renderSystem.DrawText(0, line++ * spaceSize, "Progress %02d%%", progress);
|
||||
renderSystem.SetColor(0.f, 0.2f, 0.f);
|
||||
renderSystem.DrawLine(19 * fontSize, (line - 1) * spaceSize, 19 * fontSize + PROGRESS_MAX_LINES, (line - 1)
|
||||
* spaceSize);
|
||||
renderSystem.DrawLine(19 * fontSize, (line - 1) * spaceSize, 19 * fontSize, (line) * spaceSize);
|
||||
renderSystem.DrawLine(19 * fontSize, (line) * spaceSize, 19 * fontSize + PROGRESS_MAX_LINES, (line) * spaceSize);
|
||||
renderSystem.DrawLine(19 * fontSize + PROGRESS_MAX_LINES, (line - 1) * spaceSize, 19 * fontSize
|
||||
+ PROGRESS_MAX_LINES, (line) * spaceSize + 1);
|
||||
renderSystem.SetColor(0.f, 0.5f, 0.f);
|
||||
renderSystem.FillRectangle(19 * fontSize, (line - 1) * spaceSize, progress * PROGRESS_MAX_LINES / 100 + 1,
|
||||
spaceSize);
|
||||
|
||||
renderSystem.SetColor(1.f, 1.f, 1.f);
|
||||
renderSystem.DrawText(0, line++ * spaceSize, "");
|
||||
|
||||
::std::vector<std::string>::iterator it;
|
||||
for (it = operationMessage.begin(); it != operationMessage.end(); it++)
|
||||
{
|
||||
renderSystem.DrawText(0, line++ * spaceSize, "%s", it->c_str());
|
||||
}
|
||||
|
||||
fontSize -= 2;
|
||||
renderSystem.SetFontSize(fontSize);
|
||||
}
|
||||
|
||||
}
|
||||
70
tags/0thNUP_2/ConsoleDataMigration/common/DrawSystemState.h
Normal file
70
tags/0thNUP_2/ConsoleDataMigration/common/DrawSystemState.h
Normal file
@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: DrawSystemState.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef DRAWSYSTEMSTATE_H_
|
||||
#define DRAWSYSTEMSTATE_H_
|
||||
|
||||
#include <nn.h>
|
||||
#include "demo.h"
|
||||
#include <nn/cfg/CTR/cfg_RegionCode.h>
|
||||
#include <nn/os/os_SharedInfo.h>
|
||||
#include <nn/cfg/CTR/cfg_Api.h>
|
||||
#include <nn/cfg/CTR/cfg_ApiInit.h>
|
||||
#include <nn/cfg/CTR/cfg_ApiSys.h>
|
||||
#include <nn/util/util_Color.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "common_Types.h"
|
||||
|
||||
// 描画色の定義
|
||||
#define WHITE_COLOR 1.f, 1.f, 1.f, 1.f
|
||||
#define GRAY_COLOR 0.5, 0.5, 0.5, 1.f
|
||||
#define RED_COLOR 1.f, 0.f, 0.f, 1.f
|
||||
#define GREEN_COLOR 0.f, 1.f, 0.f, 1.f
|
||||
#define BLUE_COLOR 0.f, 0.f, 1.f, 1.f
|
||||
#define SUCCESS_COLOR 0.f, 0.6f,0.f, 1.f
|
||||
#define FAIL_COLOR 0.6f, 0.f,0.f, 1.f
|
||||
#define NORMAL_COLOR 0.f, 0.f, 0.f, 1.f
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
u32 GetRenderTarget(u32 target, bool flip = false);
|
||||
|
||||
void DrawSystemState
|
||||
(
|
||||
const char* toolName,
|
||||
demo::RenderSystemDrawing& renderSystem,
|
||||
nn::util::FloatColor titleColor,
|
||||
bool flip,
|
||||
std::string& adapterState,
|
||||
const char* toolVersion,
|
||||
common::VerDef* mVerData,
|
||||
u8 batteryRemain,
|
||||
u64 deviceId,
|
||||
u64 friendCode,
|
||||
u32 progress,
|
||||
char8* macAddress,
|
||||
::std::vector<std::string>& operationMessage,
|
||||
nn::cfg::CTR::CfgRegionCode region,
|
||||
u8* s_SerialNo
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* DRAWSYSTEMSTATE_H_ */
|
||||
128
tags/0thNUP_2/ConsoleDataMigration/common/FileChecker.cpp
Normal file
128
tags/0thNUP_2/ConsoleDataMigration/common/FileChecker.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: FileChecker.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
#include "FileChecker.h"
|
||||
#include "SdMountManager.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
bool s_FileExistsChecked[EXISTS_MAX];
|
||||
bool s_FileExistsCheckeResult[EXISTS_MAX];
|
||||
|
||||
bool CheckFileExists(const wchar_t* path)
|
||||
{
|
||||
nn::Result result;
|
||||
bool exist = false;
|
||||
result = common::SdMountManager::Mount();
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
nn::fs::FileInputStream fis;
|
||||
|
||||
result = fis.TryInitialize(path);
|
||||
if(result.IsSuccess())
|
||||
{
|
||||
exist = true;
|
||||
}
|
||||
fis.Finalize();
|
||||
}
|
||||
|
||||
common::SdMountManager::Unmount();
|
||||
|
||||
|
||||
return exist;
|
||||
}
|
||||
|
||||
bool ExistsFile(FileExistsCheck index)
|
||||
{
|
||||
if(index > EXISTS_MAX)
|
||||
{
|
||||
NN_LOG("Invalid File index!!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(s_FileExistsChecked[index])
|
||||
{
|
||||
return s_FileExistsCheckeResult[index];
|
||||
}
|
||||
|
||||
s_FileExistsChecked[index] = true;
|
||||
s_FileExistsCheckeResult[index] = CheckFileExists(FILENAME_TABLE[index]);
|
||||
return s_FileExistsCheckeResult[index];
|
||||
}
|
||||
|
||||
bool ExistsUpdateCheckedFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_UPDATE_FINISHED);
|
||||
}
|
||||
|
||||
bool ExistsSerialNumberFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_SERIAL_NUMBER);
|
||||
}
|
||||
|
||||
bool ExistsIVSFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_IVS);
|
||||
}
|
||||
|
||||
bool ExistsConsoleInitializedFile()
|
||||
{
|
||||
// どちらかのファイルがあれば初期化済み
|
||||
return ExistsFile(EXISTS_CONSOLE_INTIALIZED);
|
||||
}
|
||||
|
||||
bool ExistsWriteFinishedFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_WRITE_FINISHED);
|
||||
}
|
||||
|
||||
bool ExistsAPSetting()
|
||||
{
|
||||
return ExistsFile(EXISTS_AP_SETTING);
|
||||
}
|
||||
|
||||
bool ExistsRtcSyncFinishedFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_RTC_SYNC_FINISHED);
|
||||
}
|
||||
|
||||
bool ExistsCountryLanguageFile()
|
||||
{
|
||||
return ExistsFile(EXISTS_COUNTRY_LANGUAGE);
|
||||
}
|
||||
|
||||
bool ExistsVersionData()
|
||||
{
|
||||
return ExistsFile(EXISTS_VERSION_DATA);
|
||||
}
|
||||
|
||||
bool ExistsRegionData()
|
||||
{
|
||||
return ExistsFile(EXISTS_REGION_DATA);
|
||||
}
|
||||
|
||||
void InitializeFileCheck()
|
||||
{
|
||||
for(u32 i = 0; i < EXISTS_MAX; i++)
|
||||
{
|
||||
s_FileExistsChecked[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
69
tags/0thNUP_2/ConsoleDataMigration/common/FileChecker.h
Normal file
69
tags/0thNUP_2/ConsoleDataMigration/common/FileChecker.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: FileChecker.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef FILECHECKER_H_
|
||||
#define FILECHECKER_H_
|
||||
|
||||
#include "FileName.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
typedef enum FILE_EXISTS_CHECK
|
||||
{
|
||||
EXISTS_UPDATE_FINISHED,
|
||||
EXISTS_SERIAL_NUMBER,
|
||||
EXISTS_IVS,
|
||||
EXISTS_CONSOLE_INTIALIZED,
|
||||
EXISTS_WRITE_FINISHED,
|
||||
EXISTS_AP_SETTING,
|
||||
EXISTS_RTC_SYNC_FINISHED,
|
||||
EXISTS_COUNTRY_LANGUAGE,
|
||||
EXISTS_VERSION_DATA,
|
||||
EXISTS_REGION_DATA,
|
||||
EXISTS_MAX
|
||||
} FileExistsCheck;
|
||||
|
||||
const wchar_t* const FILENAME_TABLE[EXISTS_MAX] =
|
||||
{
|
||||
common::UPDATE_CHECK_PATHNAME,
|
||||
common::SERIAL_PATHNAME,
|
||||
common::IVS_PATHNAME,
|
||||
common::INITIALIZED_CHECK_PATHNAME,
|
||||
common::WRITE_FINISHED_CHECK_PATHNAME,
|
||||
common::AP_SETTING_PATHNAME,
|
||||
common::RTC_SYNC_CHECK_PATHNAME,
|
||||
common::COUNTRY_SETTING_PATHNAME,
|
||||
common::VERSION_DATA_PATHNAME,
|
||||
common::REGION_DATA_PATHNAME
|
||||
};
|
||||
|
||||
bool CheckFileExists(const wchar_t* path);
|
||||
bool ExistsUpdateCheckedFile();
|
||||
bool ExistsSerialNumberFile();
|
||||
bool ExistsIVSFile();
|
||||
bool ExistsConsoleInitializedFile();
|
||||
bool ExistsWriteFinishedFile();
|
||||
bool ExistsAPSetting();
|
||||
bool ExistsRtcSyncFinishedFile();
|
||||
bool ExistsCountryLanguageFile();
|
||||
bool ExistsVersionData();
|
||||
bool ExistsRegionData();
|
||||
|
||||
void InitializeFileCheck();
|
||||
|
||||
}
|
||||
|
||||
#endif /* FILECHECKER_H_ */
|
||||
92
tags/0thNUP_2/ConsoleDataMigration/common/FileName.h
Normal file
92
tags/0thNUP_2/ConsoleDataMigration/common/FileName.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: FileName.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef FILENAME_H_
|
||||
#define FILENAME_H_
|
||||
|
||||
#include <nn/fs/CTR/fs_ArchiveTypesForSystem.h>
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
const char* const NAND_ARCHIVE_NAME = "nand:";
|
||||
const char* const SDMC_ARCHIVE_NAME = "sdmc:";
|
||||
const char* const NAND_TWL_PHOTO_ARCHIVE_NAME = "twlp:";
|
||||
const char* const NAND_TWL_SOUND_ARCHIVE_NAME = "twls:";
|
||||
|
||||
const wchar_t* const LOG_ROOT_DIRECTORY_PATH = L"sdmc:/CTR_Console_Repair";
|
||||
const wchar_t* const SD_SAVEDATA_ROOT_NAME = L"CTR_Console_Repair/CTRBackup/";
|
||||
const wchar_t* const SD_SAVEDATA_TWL_PHOTO_ROOT_NAME = L"CTR_Console_Repair/TWLPhotoBackup/";
|
||||
const wchar_t* const SD_SAVEDATA_TWL_SOUND_ROOT_NAME = L"CTR_Console_Repair/TWLSoundBackup/";
|
||||
const wchar_t* const NIM_SAVEDATA_DIRECTORY_NAME = L"sysdata/0001002c";
|
||||
const wchar_t* const LOG_PATHNAME = L"CTR_Console_Repair/Migration_Log.txt";
|
||||
const wchar_t* const LOG_FILENAME = L"Migration_Log.txt";
|
||||
const wchar_t* const COUNTRY_SETTING_PATHNAME = L"sdmc:/CTR_Console_Repair/CountrySetting.bin";
|
||||
const wchar_t* const AP_SETTING_FILENAME = L"CTR_Repair_Accsess_Point_Setting.txt";
|
||||
const wchar_t* const AP_SETTING_PATHNAME = L"sdmc:/CTR_Repair_Accsess_Point_Setting.txt";
|
||||
const wchar_t* const NOR_PATHNAME = L"sdmc:/CTR_Console_Repair/NtrNorSetting.bin";
|
||||
const wchar_t* const SERIAL_PATHNAME = L"sdmc:/CTR_Console_Repair/serial.bin";
|
||||
const wchar_t* const MCU_RTC_PATHNAME = L"sdmc:/CTR_Console_Repair/rtc.bin";
|
||||
const wchar_t* const IVS_NAND_PATHNAME = L"nand:/private/movable.sed";
|
||||
const wchar_t* const IVS_PATHNAME = L"sdmc:/CTR_Console_Repair/movable.sed";
|
||||
const wchar_t* const NAND_DATA_ROOT_PATHNAME_WITH_SLASH = L"nand:/data/";
|
||||
const wchar_t* const NAND_TWL_PHOTO_DATA_ROOT_PATHNAME_WITH_SLASH = L"twlp:/";
|
||||
const wchar_t* const NAND_TWL_SOUND_DATA_ROOT_PATHNAME_WITH_SLASH = L"twls:/";
|
||||
const wchar_t* const SDMC_ROOT_DIRECTORY_PATH = L"sdmc:/";
|
||||
const wchar_t* const WRITE_FINISHED_CHECK_PATHNAME = L"sdmc:/CTR_Console_Repair/WriteFinished";
|
||||
const wchar_t* const UPDATE_CHECK_PATHNAME = L"sdmc:/CTR_Console_Repair/UpdateFinished";
|
||||
const wchar_t* const INITIALIZED_CHECK_PATHNAME = L"sdmc:/CTR_Console_Repair/ConsoleInitialized";
|
||||
const wchar_t* const RTC_SYNC_CHECK_PATHNAME = L"sdmc:/CTR_Console_Repair/RtcSyncFinished";
|
||||
const wchar_t* const PLAYHISTORY_PATHNAME = L"sdmc:/CTR_Console_Repair/playhistory.bin";
|
||||
const wchar_t* const PLAYHISTORY_COUNT_PATHNAME = L"sdmc:/CTR_Console_Repair/playhistoryCount.bin";
|
||||
const wchar_t* const CFG_CALIBRATION_PATHNAME = L"sdmc:/CTR_Console_Repair/cfgCalibration.bin";
|
||||
const wchar_t* const VERSION_DATA_PATHNAME = L"sdmc:/CTR_Console_Repair/version.bin";
|
||||
const wchar_t* const REGION_DATA_PATHNAME = L"sdmc:/CTR_Console_Repair/Region.bin";
|
||||
const wchar_t* const DEVICE_ID_PATHNAME = L"sdmc:/CTR_Console_Repair/deviceId.bin";
|
||||
|
||||
enum TWL_PATH_INDEX
|
||||
{
|
||||
TWL_PHOTO = 0,
|
||||
TWL_SOUND,
|
||||
TWL_PATHNAME_MAX
|
||||
};
|
||||
|
||||
const char* const TWL_ARCHIVE_NAME_TABLE[TWL_PATHNAME_MAX] =
|
||||
{
|
||||
common::NAND_TWL_PHOTO_ARCHIVE_NAME,
|
||||
common::NAND_TWL_SOUND_ARCHIVE_NAME
|
||||
};
|
||||
|
||||
const wchar_t* const SD_TWL_ROOTNAME_TABLE[TWL_PATHNAME_MAX] =
|
||||
{
|
||||
common::SD_SAVEDATA_TWL_PHOTO_ROOT_NAME,
|
||||
common::SD_SAVEDATA_TWL_SOUND_ROOT_NAME
|
||||
};
|
||||
|
||||
const wchar_t* const NAND_TWL_ROOT_PATHNAME_WITH_SLASH_TABLE[TWL_PATHNAME_MAX] =
|
||||
{
|
||||
common::NAND_TWL_PHOTO_DATA_ROOT_PATHNAME_WITH_SLASH,
|
||||
common::NAND_TWL_SOUND_DATA_ROOT_PATHNAME_WITH_SLASH
|
||||
};
|
||||
|
||||
const u32 TWL_FS_ARCHIVE_KIND[TWL_PATHNAME_MAX] =
|
||||
{
|
||||
nn::fs::CTR::ARCHIVE_TYPE_TWL_PHOTO,
|
||||
nn::fs::CTR::ARCHIVE_TYPE_TWL_SOUND
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* FILENAME_H_ */
|
||||
249
tags/0thNUP_2/ConsoleDataMigration/common/FileTransfer.cpp
Normal file
249
tags/0thNUP_2/ConsoleDataMigration/common/FileTransfer.cpp
Normal file
@ -0,0 +1,249 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: FileTransfer.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "FileTransfer.h"
|
||||
#include <vector>
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
u64 s_TotalFileSize;
|
||||
u64 s_FinishedFileSize = 0;
|
||||
u64 s_Progress = 0;
|
||||
|
||||
}
|
||||
|
||||
nn::Result CalculateFileNum(std::wstring currentDirectory, u32& fileNum, u32& fileSize)
|
||||
{
|
||||
nn::fs::FileInputStream fis;
|
||||
nn::fs::Directory dir;
|
||||
nn::Result result;
|
||||
std::vector<nn::fs::DirectoryEntry> entryList; //カレントディレクトリのエントリ一覧を格納
|
||||
std::vector<nn::fs::DirectoryEntry>::iterator entryIndex;
|
||||
|
||||
result = dir.TryInitialize(currentDirectory.c_str());
|
||||
|
||||
if(result.IsSuccess())
|
||||
{
|
||||
nn::fs::DirectoryEntry entry;
|
||||
s32 numEntry;
|
||||
for(;;)
|
||||
{
|
||||
result = dir.TryRead(&numEntry, &entry, 1);
|
||||
if(result.IsFailure())
|
||||
{
|
||||
dir.Finalize();
|
||||
return result;
|
||||
}
|
||||
if(numEntry == 0)
|
||||
{
|
||||
// カレントディレクトリを閉じる
|
||||
dir.Finalize();
|
||||
|
||||
// カレントディレクトリの子を開く
|
||||
for(entryIndex = entryList.begin(); entryIndex != entryList.end(); entryIndex++)
|
||||
{
|
||||
if(entryIndex->attributes.isDirectory)
|
||||
{
|
||||
CalculateFileNum(currentDirectory + std::wstring(entryIndex->entryName) + std::wstring(L"/"), fileNum, fileSize);
|
||||
}
|
||||
}
|
||||
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
entryList.push_back(entry);
|
||||
fileNum++;
|
||||
fileSize+= entry.entrySize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("failed initialize directory\n");
|
||||
dir.Finalize();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ディレクトリ間のコピー
|
||||
// アーカイブ越しのコピーが可能
|
||||
// アーカイブにマウントした状態で呼び出す必要あり
|
||||
// 書き込み先のディレクトリはあらかじめ消去しておくこと。
|
||||
// 引数はスラッシュ付き
|
||||
bool CopyDirectory(const wchar_t * from_path, const wchar_t * to_path, void* buf, const size_t bufSize)
|
||||
{
|
||||
nn::fs::Directory from_dir;
|
||||
nn::fs::DirectoryEntry entry;
|
||||
s32 numread = 0;
|
||||
std::wostringstream target_from;
|
||||
std::wostringstream target_to;
|
||||
bool ret_value = true;
|
||||
|
||||
nn::Result result = from_dir.TryInitialize(from_path);
|
||||
|
||||
if (result.IsFailure())
|
||||
{
|
||||
nn::dbg::PrintResult(result);
|
||||
return false;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
result = from_dir.TryRead(&numread, &entry, 1);
|
||||
if (result.IsFailure() || numread != 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (std::wcscmp(entry.entryName, L".") == 0 || std::wcscmp(entry.entryName, L"..") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
target_from.str(L"");
|
||||
target_from.clear(std::stringstream::goodbit);
|
||||
target_from << from_path << entry.entryName;
|
||||
|
||||
target_to.str(L"");
|
||||
target_to.clear(std::stringstream::goodbit);
|
||||
target_to << to_path << entry.entryName;
|
||||
|
||||
// ディレクトリの場合
|
||||
if (entry.attributes.isDirectory)
|
||||
{
|
||||
// ディレクトリ作成
|
||||
NN_LOG("Create Directory %ls\n", target_to.str().c_str());
|
||||
result = nn::fs::TryCreateDirectory(target_to.str().c_str());
|
||||
if (result.IsFailure())
|
||||
{
|
||||
nn::dbg::PrintResult(result);
|
||||
ret_value = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
target_from << L"/";
|
||||
target_to << L"/";
|
||||
// 再帰処理
|
||||
if (!CopyDirectory(target_from.str().c_str(), target_to.str().c_str(), buf, bufSize))
|
||||
{
|
||||
ret_value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ファイルの場合
|
||||
else
|
||||
{
|
||||
// ファイル作成
|
||||
nn::fs::FileInputStream from_file;
|
||||
nn::fs::FileOutputStream to_file;
|
||||
s64 filesize;
|
||||
s32 readsize;
|
||||
s32 writesize;
|
||||
|
||||
NN_LOG("Copy File %ls\n", target_from.str().c_str());
|
||||
|
||||
// 読み込み対象ファイル開く
|
||||
result = from_file.TryInitialize(target_from.str().c_str());
|
||||
|
||||
if (result.IsFailure())
|
||||
{
|
||||
nn::dbg::PrintResult(result);
|
||||
ret_value = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 読み込み対象ファイルのサイズ取得
|
||||
result = from_file.TryGetSize(&filesize);
|
||||
if (result.IsFailure())
|
||||
{
|
||||
nn::dbg::PrintResult(result);
|
||||
ret_value = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 書き込み対象ファイル作成
|
||||
result = nn::fs::TryCreateFile(target_to.str().c_str(), filesize);
|
||||
result = to_file.TryInitialize(target_to.str().c_str(), false);
|
||||
if (result.IsFailure())
|
||||
{
|
||||
nn::dbg::PrintResult(result);
|
||||
ret_value = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
result = from_file.TryRead(&readsize, buf, bufSize);
|
||||
|
||||
if (result.IsFailure())
|
||||
{
|
||||
nn::dbg::PrintResult(result);
|
||||
ret_value = false;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (readsize == 0)
|
||||
{
|
||||
result = to_file.TryFlush();
|
||||
if (result.IsFailure())
|
||||
{
|
||||
nn::dbg::PrintResult(result);
|
||||
ret_value = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = to_file.TryWrite(&writesize, buf, readsize, false);
|
||||
s_FinishedFileSize += readsize;
|
||||
s_Progress = s_FinishedFileSize * 100/ s_TotalFileSize;
|
||||
NN_LOG("finish = %lld, total = %lld, progress = %lld\n", s_FinishedFileSize, s_TotalFileSize, s_Progress);
|
||||
if (result.IsFailure())
|
||||
{
|
||||
nn::dbg::PrintResult(result);
|
||||
ret_value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
to_file.Finalize();
|
||||
}
|
||||
}
|
||||
from_file.Finalize();
|
||||
}
|
||||
}
|
||||
|
||||
from_dir.Finalize();
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
u32 GetProgress()
|
||||
{
|
||||
return s_Progress;
|
||||
}
|
||||
|
||||
void InitializeTransferProgress(u64 totalSize)
|
||||
{
|
||||
s_TotalFileSize = totalSize;
|
||||
s_FinishedFileSize = 0;
|
||||
}
|
||||
|
||||
}
|
||||
33
tags/0thNUP_2/ConsoleDataMigration/common/FileTransfer.h
Normal file
33
tags/0thNUP_2/ConsoleDataMigration/common/FileTransfer.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: FileTransfer.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef FILETRANSFER_H_
|
||||
#define FILETRANSFER_H_
|
||||
|
||||
#include <nn.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
nn::Result CalculateFileNum(std::wstring currentDirectory, u32& fileNum, u32& fileSize);
|
||||
bool CopyDirectory(const wchar_t * from_path, const wchar_t * to_path, void* buf, const size_t bufSize);
|
||||
u32 GetProgress();
|
||||
void InitializeTransferProgress(u64 totalSize);
|
||||
|
||||
}
|
||||
|
||||
#endif /* FILETRANSFER_H_ */
|
||||
69
tags/0thNUP_2/ConsoleDataMigration/common/HardwareInfo.cpp
Normal file
69
tags/0thNUP_2/ConsoleDataMigration/common/HardwareInfo.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: HardwareInfo.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
#include "HardwareInfo.h"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
HardwareInfo::HardwareInfo()
|
||||
{
|
||||
// TODO 自動生成されたコンストラクター・スタブ
|
||||
|
||||
}
|
||||
|
||||
HardwareInfo::~HardwareInfo()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
// NULL終端されたシリアルナンバーを受け取る
|
||||
// NULL終端された場所にチェックデジットを付加して新たにNULL終端する
|
||||
void HardwareInfo::AddCheckDigit(char* serial)
|
||||
{
|
||||
size_t len = std::strlen(serial);
|
||||
|
||||
u8 digit = 0;
|
||||
bool odd = true;
|
||||
for(u8 i = len - 1; i > 0 && std::isdigit(serial[i]); i--)
|
||||
{
|
||||
if(odd)
|
||||
{
|
||||
digit += (serial[i] - '0') * 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
digit += (serial[i] - '0');
|
||||
}
|
||||
odd = !odd;
|
||||
}
|
||||
|
||||
if(digit % 10 != 0)
|
||||
{
|
||||
serial[len] = 10 - (digit % 10) + '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
serial[len] = '0';
|
||||
}
|
||||
|
||||
serial[len + 1] = '\0';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
33
tags/0thNUP_2/ConsoleDataMigration/common/HardwareInfo.h
Normal file
33
tags/0thNUP_2/ConsoleDataMigration/common/HardwareInfo.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: HardwareInfo.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef HARDWAREINFO_H_
|
||||
#define HARDWAREINFO_H_
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
class HardwareInfo
|
||||
{
|
||||
public:
|
||||
HardwareInfo();
|
||||
virtual ~HardwareInfo();
|
||||
|
||||
void AddCheckDigit(char* serial);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* HARDWAREINFO_H_ */
|
||||
39
tags/0thNUP_2/ConsoleDataMigration/common/HeapManager.cpp
Normal file
39
tags/0thNUP_2/ConsoleDataMigration/common/HeapManager.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: HeapManager.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "HeapManager.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
nn::fnd::ThreadSafeExpHeap HeapManager::s_AppHeap;
|
||||
|
||||
HeapManager::HeapManager()
|
||||
{
|
||||
// TODO 自動生成されたコンストラクター・スタブ
|
||||
|
||||
}
|
||||
|
||||
HeapManager::~HeapManager()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
nn::fnd::ThreadSafeExpHeap* HeapManager::GetHeap()
|
||||
{
|
||||
return &s_AppHeap;
|
||||
}
|
||||
|
||||
}
|
||||
40
tags/0thNUP_2/ConsoleDataMigration/common/HeapManager.h
Normal file
40
tags/0thNUP_2/ConsoleDataMigration/common/HeapManager.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: HeapManager.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef HEAPMANAGER_H_
|
||||
#define HEAPMANAGER_H_
|
||||
|
||||
#include <nn.h>
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
class HeapManager
|
||||
{
|
||||
public:
|
||||
HeapManager();
|
||||
virtual ~HeapManager();
|
||||
|
||||
static nn::fnd::ThreadSafeExpHeap* GetHeap();
|
||||
|
||||
private:
|
||||
// デバイスメモリ管理用拡張ヒープ
|
||||
static nn::fnd::ThreadSafeExpHeap s_AppHeap;
|
||||
|
||||
};
|
||||
|
||||
} // namespace common
|
||||
|
||||
#endif /* HEAPMANAGER_H_ */
|
||||
171
tags/0thNUP_2/ConsoleDataMigration/common/LogConsole.cpp
Normal file
171
tags/0thNUP_2/ConsoleDataMigration/common/LogConsole.cpp
Normal file
@ -0,0 +1,171 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: LogConsole.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "LogConsole.h"
|
||||
#include <nn/nstd.h>
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
const size_t FONT_WIDTH = 8;
|
||||
const size_t FONT_HEIGHT = 10;
|
||||
|
||||
static LogConsole s_LogConsole;
|
||||
|
||||
LogConsole* GetConsoleInstance()
|
||||
{
|
||||
return &s_LogConsole;
|
||||
}
|
||||
|
||||
LogConsole::LogConsole()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LogConsole::~LogConsole()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LogConsole::Initialize(u32 width, u32 height, u32 maxLine, demo::RenderSystemDrawing* renderSystem)
|
||||
{
|
||||
m_Width = width;
|
||||
m_Height = height;
|
||||
m_MaxLine = maxLine;
|
||||
m_RenderSystem = renderSystem;
|
||||
m_CurrentViewLine = 0;
|
||||
m_LineNum = 0;
|
||||
}
|
||||
|
||||
void LogConsole::AddText(const char* fmt, ::std::va_list arg)
|
||||
{
|
||||
s32 stringSize;
|
||||
const size_t STRING_BUFFER_SIZE = 256;
|
||||
char formatStr[STRING_BUFFER_SIZE];
|
||||
|
||||
stringSize = nn::nstd::TVSNPrintf(formatStr, sizeof(formatStr), fmt, arg);
|
||||
::std::string str(formatStr);
|
||||
|
||||
size_t addedText = 0;
|
||||
while (addedText < stringSize)
|
||||
{
|
||||
if(m_LineNum >= m_MaxLine)
|
||||
{
|
||||
// 満杯なので先頭を削除する
|
||||
::std::vector<std::string>::iterator it;
|
||||
it = m_Log.begin();
|
||||
m_Log.erase(it);
|
||||
m_LineNum--;
|
||||
}
|
||||
|
||||
// 部分文字列を追加
|
||||
AddWrapedText(str.substr(addedText, m_Width).c_str());
|
||||
m_LineNum++;
|
||||
|
||||
// 画面領域以上追加したら末尾にスクロールする
|
||||
if(m_LineNum > m_Height)
|
||||
{
|
||||
ScrollToEnd();
|
||||
}
|
||||
|
||||
|
||||
if(stringSize - addedText > m_Width)
|
||||
{
|
||||
addedText += m_Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
addedText += stringSize - addedText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LogConsole::ScrollUp()
|
||||
{
|
||||
if(m_CurrentViewLine > 0)
|
||||
{
|
||||
m_CurrentViewLine--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LogConsole::ScrollDown()
|
||||
{
|
||||
if (m_LineNum > m_Height)
|
||||
{
|
||||
if (m_CurrentViewLine < m_LineNum - m_Height)
|
||||
{
|
||||
m_CurrentViewLine++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void LogConsole::ScrollToBegin()
|
||||
{
|
||||
m_CurrentViewLine = 0;
|
||||
}
|
||||
|
||||
void LogConsole::ScrollToEnd()
|
||||
{
|
||||
if(m_LineNum > m_Height)
|
||||
{
|
||||
m_CurrentViewLine = m_LineNum - m_Height;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LogConsole::Print()
|
||||
{
|
||||
::std::vector<std::string>::iterator it;
|
||||
|
||||
it = m_Log.begin();
|
||||
it += m_CurrentViewLine;
|
||||
|
||||
u32 count = 0;
|
||||
for(; it != m_Log.end() && count < m_Height && count < m_MaxLine; it++)
|
||||
{
|
||||
m_RenderSystem->DrawText(0, count++ * 10, "%s", it->c_str());
|
||||
}
|
||||
|
||||
if(m_LineNum > m_Height)
|
||||
{
|
||||
DrawScrollBar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LogConsole::AddWrapedText(const char* str)
|
||||
{
|
||||
m_Log.push_back(::std::string(str));
|
||||
}
|
||||
|
||||
void LogConsole::DrawScrollBar()
|
||||
{
|
||||
m_RenderSystem->SetColor(0.4f, 0.4f, 0.4f);
|
||||
m_RenderSystem->DrawLine((m_Width + 1) * FONT_WIDTH, 0, (m_Width + 2) * FONT_WIDTH - 1, 0);
|
||||
m_RenderSystem->DrawLine((m_Width + 1)* FONT_WIDTH, 0, (m_Width + 1)* FONT_WIDTH, m_Height * FONT_HEIGHT);
|
||||
m_RenderSystem->DrawLine((m_Width + 2) * FONT_WIDTH - 1, 0, (m_Width + 2) * FONT_WIDTH - 1, m_Height * FONT_HEIGHT);
|
||||
m_RenderSystem->DrawLine((m_Width + 1)* FONT_WIDTH, m_Height * FONT_HEIGHT - 1, (m_Width + 2) * FONT_WIDTH - 1, m_Height * FONT_HEIGHT - 1);
|
||||
|
||||
u32 y = (m_Height * FONT_HEIGHT - 2) * m_CurrentViewLine / m_MaxLine;
|
||||
m_RenderSystem->SetColor(0.7f, 0.7f, 0.7f);
|
||||
m_RenderSystem->FillRectangle((m_Width + 1) * FONT_WIDTH, y + 1, FONT_WIDTH - 1, FONT_HEIGHT - 4);
|
||||
|
||||
m_RenderSystem->SetColor(1.f, 1.f, 1.f);
|
||||
}
|
||||
|
||||
} //namespace ConsoleBackup
|
||||
68
tags/0thNUP_2/ConsoleDataMigration/common/LogConsole.h
Normal file
68
tags/0thNUP_2/ConsoleDataMigration/common/LogConsole.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: LogConsole.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef LOGCONSOLE_H_
|
||||
#define LOGCONSOLE_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <nn/fnd.h>
|
||||
#include "demo.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
//! @brief 画面にテキストコンソールを描画します
|
||||
class LogConsole
|
||||
{
|
||||
|
||||
public:
|
||||
LogConsole();
|
||||
~LogConsole();
|
||||
|
||||
void Initialize(u32 width, u32 height, u32 maxLine, demo::RenderSystemDrawing* renderSystem);
|
||||
|
||||
void AddText(const char* fmt, ::std::va_list arg);
|
||||
void ScrollUp();
|
||||
void ScrollDown();
|
||||
void ScrollToBegin();
|
||||
void ScrollToEnd();
|
||||
void Print();
|
||||
|
||||
private:
|
||||
void AddWrapedText(const char* str);
|
||||
void DrawScrollBar();
|
||||
|
||||
::std::vector<std::string> m_Log;
|
||||
|
||||
//! @brief コンソールの列数
|
||||
u32 m_Width;
|
||||
//! @brief コンソールの行数
|
||||
u32 m_Height;
|
||||
//! @brief コンソールのログの最大行数
|
||||
u32 m_MaxLine;
|
||||
//! @brief 描画のためのRenderSystemDrawingへのポインタ
|
||||
demo::RenderSystemDrawing* m_RenderSystem;
|
||||
//! @brief 追加したログの行数
|
||||
u32 m_LineNum;
|
||||
//! @brief 表示を開始するログの行数
|
||||
u32 m_CurrentViewLine;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* LOGCONSOLE_H_ */
|
||||
@ -0,0 +1,28 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: LogConsole_Private.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef LOGCONSOLE_PRIVATE_H_
|
||||
#define LOGCONSOLE_PRIVATE_H_
|
||||
|
||||
#include "LogConsole.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
LogConsole* GetConsoleInstance();
|
||||
|
||||
}
|
||||
|
||||
#endif /* LOGCONSOLE_PRIVATE_H_ */
|
||||
18
tags/0thNUP_2/ConsoleDataMigration/common/OMakefile
Normal file
18
tags/0thNUP_2/ConsoleDataMigration/common/OMakefile
Normal file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env omake
|
||||
#----------------------------------------------------------------------------
|
||||
# Project: Horizon
|
||||
# File: OMakefile
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# $Rev$
|
||||
#----------------------------------------------------------------------------
|
||||
include $(ROOT_OMAKE)/modulerules
|
||||
|
||||
DefineDefaultRules()
|
||||
218
tags/0thNUP_2/ConsoleDataMigration/common/PlayHistoryManager.cpp
Normal file
218
tags/0thNUP_2/ConsoleDataMigration/common/PlayHistoryManager.cpp
Normal file
@ -0,0 +1,218 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: PlayHistoryManager.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn/pl.h>
|
||||
#include <nn/pl/CTR/pl_PlayHistoryApiSysmenu.h>
|
||||
|
||||
#include "PlayHistoryManager.h"
|
||||
#include "HeapManager.h"
|
||||
#include "SdMountManager.h"
|
||||
#include "SdReaderWriter.h"
|
||||
#include "CommonLogger.h"
|
||||
#include "FileName.h"
|
||||
#include "ProgramId.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
PlayHistoryManager::PlayHistoryManager()
|
||||
{
|
||||
// TODO 自動生成されたコンストラクター・スタブ
|
||||
|
||||
}
|
||||
|
||||
PlayHistoryManager::~PlayHistoryManager()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
void PlayHistoryManager::Export()
|
||||
{
|
||||
nn::Result result;
|
||||
SdMountManager::Mount();
|
||||
SdReaderWriter sd;
|
||||
|
||||
size_t historyNum = nn::pl::CTR::GetPlayHistoryLength();
|
||||
if ( historyNum == 0)
|
||||
{
|
||||
NN_LOG("No Play Event\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// SDに書き込む
|
||||
result = sd.WriteBuf(common::PLAYHISTORY_COUNT_PATHNAME, reinterpret_cast<void*>(&historyNum),
|
||||
sizeof(historyNum));
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
nn::pl::CTR::PlayEvent* pEvent;
|
||||
pEvent = reinterpret_cast<nn::pl::CTR::PlayEvent*> (HeapManager::GetHeap()->Allocate(
|
||||
sizeof(nn::pl::CTR::PlayEvent) * historyNum));
|
||||
if ( pEvent == NULL )
|
||||
{
|
||||
NN_LOG("Failed to Allocate Heap\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// 一番古いデータから素直に全部読み込む
|
||||
nn::pl::CTR::GetPlayHistory(pEvent, 0, historyNum);
|
||||
|
||||
// SDに書き込む
|
||||
result = sd.WriteBuf(common::PLAYHISTORY_PATHNAME, reinterpret_cast<void*>(pEvent),
|
||||
sizeof(nn::pl::CTR::PlayEvent) * historyNum);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
HeapManager::GetHeap()->Free(pEvent);
|
||||
|
||||
SdMountManager::Unmount();
|
||||
}
|
||||
|
||||
void PlayHistoryManager::GetPlayHistoryNums(size_t* nums)
|
||||
{
|
||||
nn::Result result;
|
||||
|
||||
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
|
||||
void* buf = common::HeapManager::GetHeap()->Allocate(bufSize);
|
||||
if (buf != NULL)
|
||||
{
|
||||
common::SdReaderWriter sdReader;
|
||||
|
||||
size_t readSize;
|
||||
result = sdReader.ReadBuf(common::PLAYHISTORY_COUNT_PATHNAME, buf, bufSize, &readSize);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
*nums = *reinterpret_cast<size_t*> (buf);
|
||||
}
|
||||
}
|
||||
HeapManager::GetHeap()->Free(buf);
|
||||
}
|
||||
|
||||
void PlayHistoryManager::Import()
|
||||
{
|
||||
nn::Result result;
|
||||
SdMountManager::Mount();
|
||||
SdReaderWriter sd;
|
||||
|
||||
SdMountManager::Mount();
|
||||
|
||||
// プレイ履歴の件数を取得する
|
||||
size_t historyNum = 0;
|
||||
|
||||
GetPlayHistoryNums(&historyNum);
|
||||
|
||||
if(historyNum == 0)
|
||||
{
|
||||
NN_LOG("No PlayHistory found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
size_t bufSize = common::HeapManager::GetHeap()->GetAllocatableSize();
|
||||
void* buf = common::HeapManager::GetHeap()->Allocate(bufSize);
|
||||
if (buf != NULL)
|
||||
{
|
||||
common::SdReaderWriter sdReader;
|
||||
|
||||
size_t readSize;
|
||||
result = sdReader.ReadBuf(common::PLAYHISTORY_PATHNAME, buf, bufSize, &readSize);
|
||||
if(result.IsSuccess())
|
||||
{
|
||||
nn::pl::CTR::PlayEvent* pEvent = reinterpret_cast<nn::pl::CTR::PlayEvent*>(buf);
|
||||
NN_LOG("history num = %d\n", historyNum);
|
||||
|
||||
// プレイ履歴を無効化する
|
||||
nn::pl::CTR::ClearPlayHistory();
|
||||
|
||||
// データ移行ツールを無視して書き込む
|
||||
for(u32 i = 0; i < historyNum; i++)
|
||||
{
|
||||
COMMON_LOGGER("Importing PlayHistory %d/%d", i, historyNum);
|
||||
if ((pEvent[i].GetProgramId() & WITHOUT_VALIATION_MASK) != CONSOLE_BACKUP_PROGRAM_ID
|
||||
&& (pEvent[i].GetProgramId() & WITHOUT_VALIATION_MASK) != CONSOLE_RESTORE_PROGRAM_ID)
|
||||
{
|
||||
NN_LOG("%05d 0x%16llx : %X : %d\n", i, pEvent[i].GetProgramId(), pEvent[i].GetEventType(),
|
||||
pEvent[i].minutes);
|
||||
|
||||
nn::pl::CTR::NotifyPlayEvent(pEvent[i].GetEventType(), pEvent[i].GetProgramId(),
|
||||
pEvent[i].GetEventTime());
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("Skipped\n");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
common::HeapManager::GetHeap()->Free(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("Failed Allocate Heap!! %s, %d", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
SdMountManager::Unmount();
|
||||
}
|
||||
|
||||
void PlayHistoryManager::Dump()
|
||||
{
|
||||
nn::Result result;
|
||||
|
||||
s32 playEventLength = nn::pl::CTR::GetPlayHistoryLength();
|
||||
if ( playEventLength == 0 )
|
||||
{
|
||||
NN_LOG("No Play Event\n");
|
||||
return;
|
||||
}
|
||||
|
||||
nn::pl::CTR::PlayEvent* playEvent = reinterpret_cast<nn::pl::CTR::PlayEvent*> (HeapManager::GetHeap()->Allocate(
|
||||
sizeof(nn::pl::CTR::PlayEvent) * playEventLength));
|
||||
if ( playEvent == NULL )
|
||||
{
|
||||
NN_LOG("Failed to Allocate Heap\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// 一番古いデータから素直に全部読み込む
|
||||
(void)nn::pl::CTR::GetPlayHistory(playEvent, 0, playEventLength);
|
||||
|
||||
// 取得したデータを順番にすべて表示していく
|
||||
s32 restPlayEventLength = playEventLength;
|
||||
s32 displayCount = 0;
|
||||
|
||||
nn::pl::CTR::PlayEvent* pEvent;
|
||||
while ( restPlayEventLength > 0 )
|
||||
{
|
||||
// 一気に表示できるところまで表示する
|
||||
int line;
|
||||
for ( line = 0; line < 24; line++ )
|
||||
{
|
||||
pEvent = &playEvent[displayCount];
|
||||
NN_LOG("0x%16llx : %X : %d\n", pEvent->GetProgramId(), pEvent->eventType, pEvent->minutes);
|
||||
restPlayEventLength--;
|
||||
displayCount++;
|
||||
if(restPlayEventLength <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
NN_UNUSED_VAR(pEvent);
|
||||
|
||||
HeapManager::GetHeap()->Free(playEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: PlayHistoryManager.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PLAYHISTORYMANAGER_H_
|
||||
#define PLAYHISTORYMANAGER_H_
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
//! @brief データ移行ツールの履歴を消しながらプレイ履歴を移行するためのクラスです。
|
||||
class PlayHistoryManager
|
||||
{
|
||||
public:
|
||||
PlayHistoryManager();
|
||||
virtual ~PlayHistoryManager();
|
||||
|
||||
//! @brief SDカードに出力します。
|
||||
void Export();
|
||||
|
||||
//! @brief SDカードからプレイ履歴に書き込みます
|
||||
void Import();
|
||||
|
||||
//! @brief デバッグ用。プレイ履歴をデバッグ出力します。
|
||||
void Dump();
|
||||
|
||||
private:
|
||||
void GetPlayHistoryNums(size_t* nums);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* PLAYHISTORYMANAGER_H_ */
|
||||
28
tags/0thNUP_2/ConsoleDataMigration/common/ProgramId.h
Normal file
28
tags/0thNUP_2/ConsoleDataMigration/common/ProgramId.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: ProgramId.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PROGRAMID_H_
|
||||
#define PROGRAMID_H_
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
const u64 CONSOLE_BACKUP_PROGRAM_ID = 0x000400000f802200L;
|
||||
const u64 CONSOLE_RESTORE_PROGRAM_ID = 0x000400000f802300L;
|
||||
const u64 WITHOUT_VALIATION_MASK = 0xffffffffffffff00L;
|
||||
|
||||
}
|
||||
|
||||
#endif /* PROGRAMID_H_ */
|
||||
267
tags/0thNUP_2/ConsoleDataMigration/common/SdLogger.cpp
Normal file
267
tags/0thNUP_2/ConsoleDataMigration/common/SdLogger.cpp
Normal file
@ -0,0 +1,267 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: SdLogger.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "SdLogger.h"
|
||||
#include <string>
|
||||
#include "SDMountManager.h"
|
||||
#include "FileName.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
|
||||
static SdLogger s_SdLogger;
|
||||
static nn::os::LightEvent s_SdEjectedEvent;
|
||||
static nn::os::LightEvent s_SdInsertedEvent;
|
||||
|
||||
const size_t SDMC_EVENT_THREAD_STACK_SIZE = 1024;
|
||||
nn::os::Thread s_SdmcEjectedEventThread;
|
||||
nn::os::StackBuffer<SDMC_EVENT_THREAD_STACK_SIZE> s_SdmcEjectedEventThreadStack;
|
||||
|
||||
nn::os::Thread s_SdmcInsertedEventThread;
|
||||
nn::os::StackBuffer<SDMC_EVENT_THREAD_STACK_SIZE> s_SdmcInsertedEventThreadStack;
|
||||
|
||||
void (*s_SdEjectedEventFunc)() = NULL;
|
||||
void (*s_SdInsertedEventFunc)() = NULL;
|
||||
|
||||
void PrintResultIfFailed(nn::Result result, u32 line = 0)
|
||||
{
|
||||
if (result.IsFailure())
|
||||
{
|
||||
if(line != 0)
|
||||
{
|
||||
NN_LOG("%s, %d\n", __FILE__, line);
|
||||
}
|
||||
nn::dbg::PrintResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
void SdmcEjectedEventThreadFunc()
|
||||
{
|
||||
NN_LOG("********************:SD Ejected Event Thread Start**********************\n");
|
||||
|
||||
for(;;)
|
||||
{
|
||||
s_SdEjectedEvent.Wait();
|
||||
NN_LOG("********************:SD Card Ejected**********************\n");
|
||||
|
||||
if(s_SdEjectedEventFunc != NULL)
|
||||
{
|
||||
s_SdEjectedEventFunc();
|
||||
}
|
||||
SdMountManager::ForceUnmount();
|
||||
s_SdEjectedEvent.ClearSignal();
|
||||
s_SdLogger.Inactivate();
|
||||
}
|
||||
}
|
||||
|
||||
void SdmcInsertedEventThreadFunc()
|
||||
{
|
||||
NN_LOG("********************:SD Inserted Event Thread Start**********************\n");
|
||||
|
||||
for(;;)
|
||||
{
|
||||
s_SdInsertedEvent.Wait();
|
||||
NN_LOG("********************:SD Card Inserted*********************\n");
|
||||
|
||||
if(s_SdInsertedEventFunc != NULL)
|
||||
{
|
||||
s_SdInsertedEventFunc();
|
||||
}
|
||||
s_SdInsertedEvent.ClearSignal();
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeEjectThread()
|
||||
{
|
||||
s_SdEjectedEvent.Initialize(true);
|
||||
s_SdInsertedEvent.Initialize(true);
|
||||
nn::fs::RegisterSdmcEjectedEvent(&s_SdEjectedEvent);
|
||||
nn::fs::RegisterSdmcInsertedEvent(&s_SdInsertedEvent);
|
||||
|
||||
// SDカード抜けを検知するためのスレッド作成
|
||||
s_SdmcEjectedEventThread.Start(SdmcEjectedEventThreadFunc, s_SdmcEjectedEventThreadStack);
|
||||
|
||||
// SDカード挿入を検知するためのスレッド作成
|
||||
s_SdmcInsertedEventThread.Start(SdmcInsertedEventThreadFunc, s_SdmcInsertedEventThreadStack);
|
||||
|
||||
}
|
||||
void SetEjectHandler(void (*func)())
|
||||
{
|
||||
s_SdEjectedEventFunc = func;
|
||||
}
|
||||
|
||||
void SetInsertHandler(void (*func)())
|
||||
{
|
||||
s_SdInsertedEventFunc = func;
|
||||
}
|
||||
|
||||
SdLogger::SdLogger() : m_TryActivate(false), m_Permitted(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SdLogger* GetSdInstance()
|
||||
{
|
||||
return &s_SdLogger;
|
||||
}
|
||||
|
||||
void SdLogger::Print(const char* fmt, ::std::va_list arg)
|
||||
{
|
||||
Activate();
|
||||
if(!m_Permitted)
|
||||
{
|
||||
NN_LOG("SD Write Not Permitted\n");
|
||||
return;
|
||||
}
|
||||
|
||||
nn::Result result;
|
||||
result = SdMountManager::Mount();
|
||||
if (result.IsFailure())
|
||||
{
|
||||
PrintResultIfFailed(result, __LINE__);
|
||||
}
|
||||
|
||||
s32 stringSize;
|
||||
const size_t STRING_BUFFER_SIZE = 256;
|
||||
char str[STRING_BUFFER_SIZE];
|
||||
|
||||
stringSize = nn::nstd::TVSNPrintf(str, sizeof(str), fmt, arg);
|
||||
|
||||
::std::wstring log(common::SDMC_ROOT_DIRECTORY_PATH);
|
||||
log += common::LOG_PATHNAME;
|
||||
|
||||
// ディレクトリが無ければ作る
|
||||
nn::fs::Directory dir;
|
||||
result = dir.TryInitialize(common::LOG_ROOT_DIRECTORY_PATH);
|
||||
if(result.IsFailure())
|
||||
{
|
||||
result = nn::fs::TryCreateDirectory(common::LOG_ROOT_DIRECTORY_PATH);
|
||||
}
|
||||
|
||||
result = sd.TryInitialize(log.c_str(), true);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
// 追記する
|
||||
// サイズ取得
|
||||
s64 fileSize;
|
||||
result = sd.TryGetSize(&fileSize);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
// 末尾に移動
|
||||
result = sd.TrySetPosition(fileSize);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
s32 writeSize;
|
||||
result = sd.TryWrite(&writeSize, str, stringSize, true);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
result = sd.TryFlush();
|
||||
if (result.IsFailure())
|
||||
{
|
||||
NN_LOG("SD TryFlush failed\n");
|
||||
PrintResultIfFailed(result, __LINE__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("SD TryWrite failed\n");
|
||||
PrintResultIfFailed(result, __LINE__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("SD TrySetPosition failed\n");
|
||||
PrintResultIfFailed(result, __LINE__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("SD TryGetSize failed\n");
|
||||
PrintResultIfFailed(result, __LINE__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("SD TryInitialize failed, %s, %d\n", __FILE__, __LINE__);
|
||||
PrintResultIfFailed(result, __LINE__);
|
||||
}
|
||||
|
||||
dir.Finalize();
|
||||
sd.Finalize();
|
||||
SdMountManager::Unmount();
|
||||
}
|
||||
|
||||
void SdLogger::Clear()
|
||||
{
|
||||
Activate();
|
||||
if(!m_Permitted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
nn::Result result;
|
||||
SdMountManager::Mount();
|
||||
|
||||
::std::wstring log(common::SDMC_ROOT_DIRECTORY_PATH);
|
||||
log += common::LOG_PATHNAME;
|
||||
|
||||
result = nn::fs::TryDeleteFile(log.c_str());
|
||||
if(result.IsFailure())
|
||||
{
|
||||
nn::dbg::PrintResult(result);
|
||||
}
|
||||
|
||||
SdMountManager::Unmount();
|
||||
}
|
||||
|
||||
void SdLogger::Inactivate()
|
||||
{
|
||||
m_TryActivate = false;
|
||||
m_Permitted = false;
|
||||
}
|
||||
|
||||
void SdLogger::Activate()
|
||||
{
|
||||
if(m_TryActivate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
nn::Result result;
|
||||
result = common::SdMountManager::Mount();
|
||||
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
nn::fs::FileInputStream fis;
|
||||
|
||||
result = fis.TryInitialize(common::AP_SETTING_PATHNAME);
|
||||
if(result.IsSuccess())
|
||||
{
|
||||
m_Permitted = true;
|
||||
}
|
||||
fis.Finalize();
|
||||
}
|
||||
|
||||
common::SdMountManager::Unmount();
|
||||
m_TryActivate = true;
|
||||
}
|
||||
|
||||
} // namespace Logger
|
||||
} // namespace ConsoleBackup
|
||||
|
||||
|
||||
57
tags/0thNUP_2/ConsoleDataMigration/common/SdLogger.h
Normal file
57
tags/0thNUP_2/ConsoleDataMigration/common/SdLogger.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: SdLogger.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SDLOGGER_H_
|
||||
#define SDLOGGER_H_
|
||||
|
||||
#include <nn.h>
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
|
||||
class SdLogger
|
||||
{
|
||||
public:
|
||||
SdLogger();
|
||||
~SdLogger() {};
|
||||
|
||||
void Print(const char* fmt, ::std::va_list arg);
|
||||
void Clear();
|
||||
void Inactivate();
|
||||
|
||||
private:
|
||||
void Activate();
|
||||
|
||||
nn::fs::FileOutputStream sd;
|
||||
bool m_TryActivate;
|
||||
bool m_Permitted;
|
||||
NN_PADDING2;
|
||||
|
||||
};
|
||||
|
||||
void InitializeEjectThread();
|
||||
// SDカードが抜けた時に呼ばれるコールバック
|
||||
void SetEjectHandler(void (*func)());
|
||||
// SDカードが挿入された時に呼ばれるコールバック
|
||||
void SetInsertHandler(void (*func)());
|
||||
SdLogger* GetSdInstance();
|
||||
|
||||
} // namespace Logger
|
||||
} // namespace ConsoleBackup
|
||||
|
||||
#endif /* SDLOGGER_H_ */
|
||||
67
tags/0thNUP_2/ConsoleDataMigration/common/SdMountManager.cpp
Normal file
67
tags/0thNUP_2/ConsoleDataMigration/common/SdMountManager.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: SdMountManager.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
#include "SdMountManager.h"
|
||||
#include "FileName.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
u32 SdMountManager::m_MountCounter = 0;
|
||||
|
||||
SdMountManager::SdMountManager()
|
||||
{
|
||||
// TODO 自動生成されたコンストラクター・スタブ
|
||||
|
||||
}
|
||||
|
||||
SdMountManager::~SdMountManager()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
nn::Result SdMountManager::Mount()
|
||||
{
|
||||
nn::Result result = nn::ResultSuccess();
|
||||
|
||||
if(m_MountCounter == 0)
|
||||
{
|
||||
result = nn::fs::MountSdmc();
|
||||
}
|
||||
m_MountCounter++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
nn::Result SdMountManager::Unmount()
|
||||
{
|
||||
nn::Result result = nn::ResultSuccess();
|
||||
if(m_MountCounter != 0 && --m_MountCounter == 0)
|
||||
{
|
||||
result = nn::fs::Unmount(common::SDMC_ARCHIVE_NAME);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
nn::Result SdMountManager::ForceUnmount()
|
||||
{
|
||||
m_MountCounter = 0;
|
||||
return nn::fs::Unmount(common::SDMC_ARCHIVE_NAME);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
42
tags/0thNUP_2/ConsoleDataMigration/common/SdMountManager.h
Normal file
42
tags/0thNUP_2/ConsoleDataMigration/common/SdMountManager.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: SdMountManager.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SDMOUNTMANAGER_H_
|
||||
#define SDMOUNTMANAGER_H_
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
//! @brief SDカードのMount状態を管理するためのクラスです
|
||||
class SdMountManager
|
||||
{
|
||||
public:
|
||||
SdMountManager();
|
||||
virtual ~SdMountManager();
|
||||
|
||||
//! @brief マウントが必要ならマウントします。
|
||||
static nn::Result Mount();
|
||||
//! @brief アンマウントが必要ならアンマウントします。
|
||||
static nn::Result Unmount();
|
||||
//! @brief 強制的にアンマウントします。
|
||||
static nn::Result ForceUnmount();
|
||||
|
||||
private:
|
||||
static u32 m_MountCounter;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* SDMOUNTMANAGER_H_ */
|
||||
153
tags/0thNUP_2/ConsoleDataMigration/common/SdReaderWriter.cpp
Normal file
153
tags/0thNUP_2/ConsoleDataMigration/common/SdReaderWriter.cpp
Normal file
@ -0,0 +1,153 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: SdReaderWriter.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "SdReaderWriter.h"
|
||||
#include "SdMountManager.h"
|
||||
#include "CommonLogger.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
nn::Result SdReaderWriter::Initialize()
|
||||
{
|
||||
nn::Result result;
|
||||
|
||||
// 初期化済みなら何もしない
|
||||
if(m_IsInitialized)
|
||||
{
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
result = SdMountManager::Mount();
|
||||
if(result.IsSuccess())
|
||||
{
|
||||
m_IsInitialized = true;
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nn::Result SdReaderWriter::Finalize()
|
||||
{
|
||||
nn::Result result;
|
||||
result = SdMountManager::Unmount();
|
||||
|
||||
m_IsInitialized = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
nn::Result SdReaderWriter::WriteBuf(const wchar_t* path, void* buf, size_t size)
|
||||
{
|
||||
NN_ASSERT(path != NULL);
|
||||
NN_ASSERT(size > 0);
|
||||
|
||||
nn::Result result;
|
||||
result = Initialize();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
result = file.TryInitialize(path, nn::fs::OPEN_MODE_WRITE | nn::fs::OPEN_MODE_CREATE);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
s32 writeSize;
|
||||
result = file.TryWrite(&writeSize, buf, size, true);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
result = file.TryFlush();
|
||||
if (result.IsFailure())
|
||||
{
|
||||
NN_LOG("SD TryFlush failed\n");
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("SD TryWrite failed\n");
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("SD TryInitialize failed\n");
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
}
|
||||
|
||||
file.Finalize();
|
||||
|
||||
result = Finalize();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
nn::Result SdReaderWriter::ReadBuf(const wchar_t* path, void* buf, size_t size, size_t* totalSize)
|
||||
{
|
||||
NN_ASSERT(path != NULL);
|
||||
NN_ASSERT(size > 0);
|
||||
|
||||
nn::Result result;
|
||||
if(!m_IsInitialized)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
result = file.TryInitialize(path, nn::fs::OPEN_MODE_READ);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
s32 readSize;
|
||||
result = file.TryRead(&readSize, buf, size);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
// TODO バッファを超えるサイズのファイル読み込み
|
||||
*totalSize = readSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("SD TryRead failed\n");
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NN_LOG("SD TryInitialize failed\n");
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
}
|
||||
|
||||
file.Finalize();
|
||||
return result;
|
||||
}
|
||||
|
||||
void SdReaderWriter::CreateDirectory(const wchar_t* path)
|
||||
{
|
||||
nn::Result result;
|
||||
|
||||
if(!m_IsInitialized)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
NN_LOG("Create Directory %ls\n", path);
|
||||
result = nn::fs::TryCreateDirectory(path);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
result = Finalize();
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
64
tags/0thNUP_2/ConsoleDataMigration/common/SdReaderWriter.h
Normal file
64
tags/0thNUP_2/ConsoleDataMigration/common/SdReaderWriter.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: SdReaderWriter.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SDWRITER_H_
|
||||
#define SDWRITER_H_
|
||||
|
||||
#include <nn.h>
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
//! @brief SDカードに書き込むためのクラスです。
|
||||
class SdReaderWriter
|
||||
{
|
||||
public :
|
||||
SdReaderWriter() : m_IsInitialized(false) {};
|
||||
~SdReaderWriter() {};
|
||||
|
||||
//! @brief 渡されたバッファからサイズ分指定されたパス名で書きこみます
|
||||
//! @param[in] path sdmc:で始まる出力パス名。予めディレクトリを作っておく必要があります。
|
||||
//! @param[in] buf 入力データへのポインタ
|
||||
//! @param[in] size 入力データのサイズ
|
||||
nn::Result WriteBuf(const wchar_t* path, void* buf, size_t size);
|
||||
|
||||
//! @brief 渡されたバッファへサイズ分指定されたパス名から読み込みます
|
||||
//! @param[in] path sdmc:で始まる入力パス名
|
||||
//! @param[in] buf 出力バッファへのポインタ
|
||||
//! @param[in] size バッファサイズ
|
||||
//! @param[out] totalSize 読み込んだデータのサイズ
|
||||
nn::Result ReadBuf(const wchar_t* path, void* buf, size_t size, size_t* totalSize);
|
||||
|
||||
|
||||
//! @brief 渡されたディレクトリ名のディレクトリを作成します
|
||||
void CreateDirectory(const wchar_t* path);
|
||||
|
||||
private:
|
||||
//! @brief 初期化します。
|
||||
nn::Result Initialize();
|
||||
|
||||
//! @brief 終了します。
|
||||
nn::Result Finalize();
|
||||
|
||||
nn::fs::FileStream file;
|
||||
|
||||
NN_PADDING3;
|
||||
bool m_IsInitialized;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* SDWRITER_H_ */
|
||||
240
tags/0thNUP_2/ConsoleDataMigration/common/SimplePlayer.cpp
Normal file
240
tags/0thNUP_2/ConsoleDataMigration/common/SimplePlayer.cpp
Normal file
@ -0,0 +1,240 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: SimplePlayer.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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
#include <nn/os.h>
|
||||
#include <nn/fnd.h>
|
||||
#include <nn/fs.h>
|
||||
#include <nn/hid.h>
|
||||
#include <nn/snd.h>
|
||||
|
||||
#include <string.h>
|
||||
#include "SimplePlayer.h"
|
||||
#include "wave.h"
|
||||
#include "HeapManager.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
const int nFiles = 4; // 使用できる voice の最大値は 24
|
||||
const char* apFileNames[nFiles] =
|
||||
{
|
||||
"rom:/ok.wav",
|
||||
"rom:/ng.wav",
|
||||
"rom:/cursor.wav",
|
||||
"rom:/annotation.wav"
|
||||
};
|
||||
|
||||
nn::snd::CTR::Voice* apVoice[nFiles];
|
||||
nn::snd::CTR::WaveBuffer aBuffer[nFiles];
|
||||
WaveFmt fmt[nFiles];
|
||||
WaveData data[nFiles];
|
||||
u8* apMemory[nFiles];
|
||||
|
||||
nn::os::CriticalSection s_CriticalSection;
|
||||
bool s_SoundThreadInitialized = false;
|
||||
|
||||
// サウンドスレッド関連
|
||||
const int SOUND_THREAD_STACK_SIZE = 4096;
|
||||
nn::os::StackBuffer<SOUND_THREAD_STACK_SIZE> s_SoundThreadStack;
|
||||
nn::os::Thread threadSound;
|
||||
bool threadSoundFlag;
|
||||
void SoundThreadFunc()
|
||||
{
|
||||
// サウンド出力をステレオに
|
||||
nn::snd::SetSoundOutputMode(nn::snd::OUTPUT_MODE_STEREO);
|
||||
|
||||
// マスターボリュームを設定
|
||||
nn::snd::SetMasterVolume( 1.0 );
|
||||
|
||||
NN_LOG("Loading wav files...\n");
|
||||
|
||||
// ファイルを開く
|
||||
for (int i = 0; i < nFiles; i++)
|
||||
{
|
||||
if (apFileNames[i] == NULL) continue;
|
||||
|
||||
nn::snd::Voice* pVoice = NULL;
|
||||
|
||||
nn::fs::FileReader fileReader;
|
||||
nn::Result result = fileReader.TryInitialize(apFileNames[i]);
|
||||
NN_UTIL_PANIC_IF_FAILED(result);
|
||||
if (::std::strcmp(::std::strrchr(apFileNames[i], '.'), ".wav") == false)
|
||||
{
|
||||
// 連続メモリ領域の取得、確認
|
||||
apMemory[i] = reinterpret_cast<u8*>(HeapManager::GetHeap()->Allocate(GetWaveLength(fileReader), 32));
|
||||
if (apMemory[i] == NULL)
|
||||
{
|
||||
NN_LOG("Failed to allocate continuous memory\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Wave データを読み込み、キャッシュを無効に
|
||||
data[i].buf = apMemory[i];
|
||||
LoadWave(fileReader, &fmt[i], &data[i]);
|
||||
nn::snd::FlushDataCache(reinterpret_cast<uptr>(apMemory[i]), data[i].size);
|
||||
|
||||
NN_LOG("%s (%1dch, %5dHz, %2d-bit wav file)\n",
|
||||
apFileNames[i], fmt[i].channel, fmt[i].sample_rate, fmt[i].quantum_bits);
|
||||
|
||||
pVoice = apVoice[i] = nn::snd::AllocVoice(128, NULL, NULL);
|
||||
NN_TASSERT_(pVoice);
|
||||
|
||||
nn::snd::SampleFormat format = (fmt[i].quantum_bits == 8) ?
|
||||
nn::snd::SAMPLE_FORMAT_PCM8 :
|
||||
nn::snd::SAMPLE_FORMAT_PCM16;
|
||||
|
||||
pVoice->SetChannelCount( fmt[i].channel );
|
||||
pVoice->SetSampleFormat( format );
|
||||
|
||||
nn::snd::InitializeWaveBuffer(&aBuffer[i]);
|
||||
aBuffer[i].bufferAddress = apMemory[i];
|
||||
aBuffer[i].sampleLength = nn::snd::GetSampleLength(data[i].size, format, fmt[i].channel);
|
||||
aBuffer[i].loopFlag = false;
|
||||
|
||||
fileReader.Finalize();
|
||||
|
||||
// 音量の設定
|
||||
nn::snd::MixParam mix;
|
||||
mix.mainBus[nn::snd::CHANNEL_INDEX_FRONT_LEFT ] = 0.707f; // メインボリューム (L)
|
||||
mix.mainBus[nn::snd::CHANNEL_INDEX_FRONT_RIGHT] = 0.707f; // メインボリューム (R)
|
||||
pVoice->SetMixParam(mix);
|
||||
pVoice->SetVolume(1.0f);
|
||||
|
||||
// pitch の設定
|
||||
pVoice->SetSampleRate(fmt[i].sample_rate);
|
||||
pVoice->SetPitch(1.0f);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 再生開始
|
||||
for (int i = 0; i < nFiles; i++)
|
||||
{
|
||||
if (apFileNames[i] != NULL)
|
||||
{
|
||||
apVoice[i]->SetState( nn::snd::Voice::STATE_PLAY );
|
||||
}
|
||||
}
|
||||
|
||||
s_SoundThreadInitialized = true;
|
||||
|
||||
threadSoundFlag = true;
|
||||
while (threadSoundFlag)
|
||||
{
|
||||
nn::snd::WaitForDspSync(); // DSP からのデータ受信を待つ。
|
||||
|
||||
|
||||
s_CriticalSection.Enter(); // メインスレッドとの排他制御
|
||||
nn::snd::SendParameterToDsp(); // パラメータを DSP に送信。
|
||||
s_CriticalSection.Leave(); // メインスレッドとの排他制御
|
||||
}
|
||||
|
||||
// 再生終了
|
||||
for (int i = 0; i < nFiles; i++)
|
||||
{
|
||||
if (apVoice[i])
|
||||
{
|
||||
nn::snd::FreeVoice(apVoice[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeSimplePlayer()
|
||||
{
|
||||
NN_LOG("Initialize SimplePlayer\n");
|
||||
|
||||
nn::Result result;
|
||||
|
||||
const size_t ROMFS_BUFFER_SIZE = 1024 * 64;
|
||||
static char buffer[ROMFS_BUFFER_SIZE];
|
||||
NN_UTIL_PANIC_IF_FAILED(
|
||||
nn::fs::MountRom(16, 16, buffer, ROMFS_BUFFER_SIZE));
|
||||
|
||||
// dsp, snd の初期化
|
||||
result = nn::dsp::Initialize();
|
||||
NN_UTIL_PANIC_IF_FAILED(result);
|
||||
result = nn::dsp::LoadDefaultComponent();
|
||||
NN_UTIL_PANIC_IF_FAILED(result);
|
||||
result = nn::snd::Initialize();
|
||||
NN_UTIL_PANIC_IF_FAILED(result);
|
||||
|
||||
s_CriticalSection.Initialize();
|
||||
|
||||
// サウンドスレッドを起動(DSP 割り込みイベント待ち)
|
||||
threadSound.Start(SoundThreadFunc, s_SoundThreadStack);
|
||||
}
|
||||
|
||||
void PlaySound(u8 index)
|
||||
{
|
||||
NN_ASSERT(index <= nFiles);
|
||||
|
||||
while(!s_SoundThreadInitialized)
|
||||
{
|
||||
nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(1));
|
||||
}
|
||||
|
||||
nn::snd::CTR::Voice* pVoice = apVoice[index];
|
||||
|
||||
if (!pVoice->IsPlaying())
|
||||
{
|
||||
nn::snd::InitializeWaveBuffer(&aBuffer[index]);
|
||||
aBuffer[index].bufferAddress = apMemory[index];
|
||||
nn::snd::SampleFormat format = (fmt[index].quantum_bits == 8) ? nn::snd::SAMPLE_FORMAT_PCM8
|
||||
: nn::snd::SAMPLE_FORMAT_PCM16;
|
||||
|
||||
aBuffer[index].sampleLength = nn::snd::GetSampleLength(data[index].size, format, fmt[index].channel);
|
||||
aBuffer[index].loopFlag = false;
|
||||
|
||||
pVoice->AppendWaveBuffer(&aBuffer[index]);
|
||||
NN_LOG("[voice%d] %s (pitch = %f)\n",
|
||||
index,
|
||||
(pVoice->GetState() == nn::snd::Voice::STATE_PAUSE ? "pause" : "play "),
|
||||
pVoice->GetPitch());
|
||||
}
|
||||
}
|
||||
|
||||
void FinalizeSimplePlayer()
|
||||
{
|
||||
nn::Result result;
|
||||
|
||||
// サウンドスレッドの破棄
|
||||
threadSoundFlag = false;
|
||||
threadSound.Join();
|
||||
|
||||
// SND の終了処理
|
||||
result = nn::snd::Finalize();
|
||||
NN_UTIL_PANIC_IF_FAILED(result);
|
||||
|
||||
s_CriticalSection.Finalize();
|
||||
|
||||
// DSP の終了処理
|
||||
result = nn::dsp::UnloadComponent();
|
||||
NN_UTIL_PANIC_IF_FAILED(result);
|
||||
nn::dsp::Finalize();
|
||||
|
||||
|
||||
NN_LOG("Finalize SimplePlayer\n");
|
||||
|
||||
}
|
||||
|
||||
} // namespace ConsoleBackup
|
||||
/*---------------------------------------------------------------------------*
|
||||
End of file
|
||||
*---------------------------------------------------------------------------*/
|
||||
37
tags/0thNUP_2/ConsoleDataMigration/common/SimplePlayer.h
Normal file
37
tags/0thNUP_2/ConsoleDataMigration/common/SimplePlayer.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: SimplePlayer.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SIMPLEPLAYER_H_
|
||||
#define SIMPLEPLAYER_H_
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
enum SoundEffect
|
||||
{
|
||||
SOUND_OK,
|
||||
SOUND_NG,
|
||||
SOUND_CURSOR,
|
||||
SOUND_ANNOTATION
|
||||
};
|
||||
|
||||
void InitializeSimplePlayer();
|
||||
void FinalizeSimplePlayer();
|
||||
void PlaySound(u8 index);
|
||||
|
||||
} // namespace ConsoleBackup
|
||||
|
||||
|
||||
#endif /* SIMPLEPLAYER_H_ */
|
||||
120
tags/0thNUP_2/ConsoleDataMigration/common/VersionDetect.cpp
Normal file
120
tags/0thNUP_2/ConsoleDataMigration/common/VersionDetect.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: VersionDetect.cpp
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <nn.h>
|
||||
#include <nn/fs.h>
|
||||
#include <nn/fs/CTR/MPCore/fs_FileSystemBasePrivate.h>
|
||||
|
||||
#include "VersionDetect.h"
|
||||
#include "HeapManager.h"
|
||||
#include "CommonLogger.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
void GetCupVersion(nn::pl::CTR::CardUpdateVersion* cup, nn::cfg::CTR::CfgRegionCode region)
|
||||
{
|
||||
nn::Result result;
|
||||
const size_t BUF_SIZE = 1024;
|
||||
u8 buf[BUF_SIZE];
|
||||
// CUPバージョン
|
||||
{
|
||||
result = nn::fs::MountContent("cver:", nn::fs::MEDIA_TYPE_NAND, common::cCupVerId[region], 0, 1, 1, buf,
|
||||
BUF_SIZE);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
nn::fs::FileInputStream fis;
|
||||
|
||||
result = fis.TryInitialize(L"cver:/version.bin");
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
s64 fileSize = fis.GetSize();
|
||||
NN_LOG("version.bin size = %lld\n", fileSize);
|
||||
s32 ret;
|
||||
void* addr = NULL;
|
||||
addr = common::HeapManager::GetHeap()->Allocate(fileSize);
|
||||
if (addr != NULL)
|
||||
{
|
||||
result = fis.TryRead(&ret, addr, fileSize);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
nn::pl::CTR::CardUpdateVersion* ver_buf = reinterpret_cast<nn::pl::CTR::CardUpdateVersion*> (addr);
|
||||
|
||||
std::memcpy(cup, ver_buf, sizeof(nn::pl::CTR::CardUpdateVersion));
|
||||
}
|
||||
common::HeapManager::GetHeap()->Free(addr);
|
||||
}
|
||||
}
|
||||
fis.Finalize();
|
||||
|
||||
nn::fs::Unmount("cver:");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GetNupVersion(nn::pl::CTR::NetworkUpdateVersion* nup, nn::cfg::CTR::CfgRegionCode region)
|
||||
{
|
||||
nn::Result result;
|
||||
const size_t BUF_SIZE = 1024;
|
||||
u8 buf[BUF_SIZE];
|
||||
|
||||
// NUPバージョン
|
||||
{
|
||||
result = nn::fs::MountContent("nver:", nn::fs::MEDIA_TYPE_NAND, common::cNupVerId[region], 0, 1, 1, buf,
|
||||
BUF_SIZE);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
|
||||
nn::fs::FileInputStream fis;
|
||||
|
||||
result = fis.TryInitialize(L"nver:/version.bin");
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
s64 fileSize = fis.GetSize();
|
||||
NN_LOG("version.bin size = %lld\n", fileSize);
|
||||
s32 ret;
|
||||
void* addr = NULL;
|
||||
addr = common::HeapManager::GetHeap()->Allocate(fileSize);
|
||||
if (addr != NULL)
|
||||
{
|
||||
result = fis.TryRead(&ret, addr, fileSize);
|
||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||
if (result.IsSuccess())
|
||||
{
|
||||
nn::pl::CTR::NetworkUpdateVersion* ver_buf =
|
||||
reinterpret_cast<nn::pl::CTR::NetworkUpdateVersion*> (addr);
|
||||
|
||||
std::memcpy(nup, ver_buf, sizeof(nn::pl::CTR::NetworkUpdateVersion));
|
||||
}
|
||||
common::HeapManager::GetHeap()->Free(addr);
|
||||
}
|
||||
}
|
||||
|
||||
fis.Finalize();
|
||||
nn::fs::Unmount("nver:");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GetSystemVersion(common::VerDef* mVerData, nn::cfg::CTR::CfgRegionCode region)
|
||||
{
|
||||
GetCupVersion(&mVerData->cup, region);
|
||||
GetNupVersion(&mVerData->nup, region);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
30
tags/0thNUP_2/ConsoleDataMigration/common/VersionDetect.h
Normal file
30
tags/0thNUP_2/ConsoleDataMigration/common/VersionDetect.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: VersionDetect.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef VERSIONDETECT_H_
|
||||
#define VERSIONDETECT_H_
|
||||
|
||||
#include <nn/cfg/CTR/cfg_RegionCode.h>
|
||||
#include "common_Types.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
void GetSystemVersion(common::VerDef* mVerData, nn::cfg::CTR::CfgRegionCode region);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* VERSIONDETECT_H_ */
|
||||
85
tags/0thNUP_2/ConsoleDataMigration/common/common_Types.h
Normal file
85
tags/0thNUP_2/ConsoleDataMigration/common/common_Types.h
Normal file
@ -0,0 +1,85 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: Horizon
|
||||
File: common_Types.h
|
||||
|
||||
Copyright 2009 Nintendo. 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.
|
||||
|
||||
$Rev$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef COMMON_TYPES_H_
|
||||
#define COMMON_TYPES_H_
|
||||
|
||||
#include <nn/cfg/CTR/cfg_NtrSettings.h>
|
||||
#include <nn/cfg/CTR/cfg_CountryCode.h>
|
||||
#include <nn/cfg/CTR/cfg_LanguageCode.h>
|
||||
#include <nn/cfg/CTR/detail/cfg_DataStructures.h>
|
||||
#include <nn/pl/CTR/pl_SharedDataTitleId.h>
|
||||
#include <nn/pl/CTR/pl_Version.h>
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
const u32 NTR_WIFI_SETTING_SIZE = 0x400; // NTR Wifi 設定のサイズ
|
||||
const u32 TWL_WIFI_SETTING_SIZE = 0x600; // TWL Wifi 設定のサイズ
|
||||
|
||||
|
||||
// NOR領域のみにある設定データ用構造体
|
||||
struct NtrNorData
|
||||
{
|
||||
nn::cfg::CTR::NtrConfig ntrConfig;
|
||||
u8 TwlWiFiSetting[TWL_WIFI_SETTING_SIZE];
|
||||
u8 NtrWiFiSetting[NTR_WIFI_SETTING_SIZE];
|
||||
};
|
||||
|
||||
struct CfgCountryLanguage
|
||||
{
|
||||
enum nn::cfg::CTR::CfgCountryCode country;
|
||||
enum nn::cfg::CTR::CfgLanguageCode language;
|
||||
NN_PADDING1;
|
||||
};
|
||||
|
||||
struct VerDef
|
||||
{
|
||||
nn::pl::CTR::CardUpdateVersion cup;
|
||||
nn::pl::CTR::NetworkUpdateVersion nup;
|
||||
};
|
||||
|
||||
struct CfgCalData
|
||||
{
|
||||
nn::cfg::CTR::detail::TouchPanelCfgData touchPanelCfgData;
|
||||
nn::cfg::CTR::detail::LcdFlickerCfgData lcdFlickerCfgData;
|
||||
nn::cfg::CTR::detail::FcramCfgData fcramCfgData;
|
||||
nn::cfg::CTR::detail::RtcCfgData rtcCfgData;
|
||||
nn::cfg::CTR::detail::GyroscopeCfgData gyroscopeCfgData;
|
||||
nn::cfg::CTR::detail::AccelCfgData accelCfgData;
|
||||
nn::cfg::CTR::detail::CodecCfgData codecCfgData;
|
||||
nn::cfg::CTR::detail::McuSlideVolumeRangeCfgData mcuSlideVolumeRangeCfgData;
|
||||
NN_PADDING2;
|
||||
|
||||
};
|
||||
|
||||
// TODO:リージョン追加時に範囲外アクセスにならないよう注意
|
||||
const nn::ProgramId cCupVerId[] =
|
||||
{
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_CUP_VERSION_JP,
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_CUP_VERSION_US,
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_CUP_VERSION_EU,
|
||||
};
|
||||
|
||||
const nn::ProgramId cNupVerId[] =
|
||||
{
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_JP,
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_US,
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_EU,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* COMMON_TYPES_H_ */
|
||||
181
tags/0thNUP_2/ConsoleDataMigration/common/configLoader.cpp
Normal file
181
tags/0thNUP_2/ConsoleDataMigration/common/configLoader.cpp
Normal file
@ -0,0 +1,181 @@
|
||||
#include <wchar.h>
|
||||
#include <nn/fs.h>
|
||||
#include <cstdlib>
|
||||
#include "configLoader.h"
|
||||
|
||||
namespace common
|
||||
{
|
||||
|
||||
Result ConfigFileLoader::Initialize(const wchar_t* fileName, void* buffer, const size_t bufferSize)
|
||||
{
|
||||
s64 fileSize;
|
||||
FileInputStream fi;
|
||||
NN_UTIL_RETURN_IF_FAILED(fi.TryInitialize(fileName));
|
||||
NN_UTIL_RETURN_IF_FAILED(fi.TryGetSize(&fileSize));
|
||||
|
||||
// NULL終端ぶん読めるサイズを減らす
|
||||
if (fileSize > bufferSize - sizeof(wchar_t))
|
||||
{
|
||||
NN_TLOG_("Too Large File\n");
|
||||
return Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON, nn::Result::DESCRIPTION_TOO_LARGE);
|
||||
}
|
||||
|
||||
m_Buffer = static_cast<wchar_t*>(buffer);
|
||||
NN_UTIL_RETURN_IF_FAILED(fi.TryRead(&m_UsedBufferSize, m_Buffer, fileSize));
|
||||
NN_LOG("config size = %d\n", m_UsedBufferSize);
|
||||
return ParseData();
|
||||
}
|
||||
|
||||
void ConfigFileLoader::Finalize()
|
||||
{
|
||||
m_Buffer = 0;
|
||||
m_ParamNum = 0;
|
||||
}
|
||||
|
||||
Result ConfigFileLoader::ParseData()
|
||||
{
|
||||
if (!m_Buffer)
|
||||
{
|
||||
return Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_INVALID_STATE, nn::Result::MODULE_COMMON, nn::Result::DESCRIPTION_NOT_INITIALIZED);
|
||||
}
|
||||
|
||||
int pos = 0;
|
||||
|
||||
// ビッグエンディアンでないことを確認
|
||||
NN_ASSERTMSG(m_Buffer[0] != 0xfffe, "Invalid Config File's Endian\n");
|
||||
|
||||
if (m_Buffer[0] == 0xfeff)
|
||||
{
|
||||
// UTF-16 BOMの調整
|
||||
pos++;
|
||||
}
|
||||
|
||||
m_ParamNum = 0;
|
||||
m_ParamName[m_ParamNum] = &(m_Buffer[pos]);
|
||||
m_ParamValue[m_ParamNum] = L"";
|
||||
m_Buffer[m_UsedBufferSize / sizeof(wchar_t)] = L'\0'; // NULL終端しておく
|
||||
|
||||
// ダブルクウォート中なら : も文字として読み取る
|
||||
bool inEscape = false;
|
||||
// # で行末までコメント
|
||||
bool inComment = false;
|
||||
// : で行頭から:までがkey、:から行末までがvalue
|
||||
bool inSettingKeyValue = false;
|
||||
|
||||
while (pos < m_UsedBufferSize / sizeof(m_Buffer[0]))
|
||||
{
|
||||
switch (m_Buffer[pos])
|
||||
{
|
||||
case L'"':
|
||||
{
|
||||
inEscape = !inEscape;
|
||||
}
|
||||
break;
|
||||
|
||||
case L'#':
|
||||
{
|
||||
inComment = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case L':':
|
||||
{
|
||||
if (inEscape || inComment)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (inSettingKeyValue)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
inSettingKeyValue = true;
|
||||
}
|
||||
m_Buffer[pos] = L'\0';
|
||||
m_ParamValue[m_ParamNum++] = &(m_Buffer[pos + 1]);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case L'\r':
|
||||
case L'\n':
|
||||
{
|
||||
if (inComment)
|
||||
{
|
||||
inComment = false;
|
||||
}
|
||||
if (inSettingKeyValue)
|
||||
{
|
||||
inSettingKeyValue = false;
|
||||
}
|
||||
|
||||
m_Buffer[pos] = L'\0';
|
||||
m_ParamName[m_ParamNum] = &(m_Buffer[pos + 1]);
|
||||
m_ParamValue[m_ParamNum] = L"";
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (PARAM_MAX_NUM <= m_ParamNum)
|
||||
{
|
||||
NN_TLOG_("Too Many Params\n");
|
||||
return Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON,
|
||||
nn::Result::DESCRIPTION_TOO_LARGE);
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
s32 ConfigFileLoader::SearchParamName(const wchar_t *paramName)
|
||||
{
|
||||
if (!m_Buffer)
|
||||
{
|
||||
NN_TLOG_("ConfigFileLoader not initialized.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (s32 i = 0; i < m_ParamNum; i++)
|
||||
{
|
||||
if (wcscmp(m_ParamName[i], paramName) == 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
const wchar_t *ConfigFileLoader::ReadAsWChar(const wchar_t *paramName)
|
||||
{
|
||||
s32 idx = SearchParamName(paramName);
|
||||
if (idx < 0)
|
||||
{
|
||||
NN_LOG("Unknown Parameter Name %ls\n", paramName);
|
||||
}
|
||||
return (idx < 0) ? NULL : m_ParamValue[idx];
|
||||
}
|
||||
|
||||
const char *ConfigFileLoader::ReadAsChar(const wchar_t *paramName)
|
||||
{
|
||||
memset(m_ReadCharBuffer, 0, sizeof(m_ReadCharBuffer));
|
||||
const wchar_t *value = ReadAsWChar(paramName);
|
||||
if(value == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
wcstombs(m_ReadCharBuffer, value, sizeof(m_ReadCharBuffer));
|
||||
// NULL終端する
|
||||
m_ReadCharBuffer[sizeof(m_ReadCharBuffer) - 1] = '\0';
|
||||
return m_ReadCharBuffer;
|
||||
}
|
||||
|
||||
int ConfigFileLoader::ReadAsInteger(const wchar_t *paramName)
|
||||
{
|
||||
return atoi(ReadAsChar(paramName));
|
||||
}
|
||||
|
||||
}
|
||||
78
tags/0thNUP_2/ConsoleDataMigration/common/configLoader.h
Normal file
78
tags/0thNUP_2/ConsoleDataMigration/common/configLoader.h
Normal file
@ -0,0 +1,78 @@
|
||||
#ifndef NN_CONFIG_LOADER_H_
|
||||
#define NN_CONFIG_LOADER_H_
|
||||
|
||||
|
||||
namespace common
|
||||
{
|
||||
using namespace nn;
|
||||
using namespace nn::fs;
|
||||
using namespace std;
|
||||
|
||||
class ConfigFileLoader
|
||||
{
|
||||
private:
|
||||
static const int PARAM_VALUE_MAX_STRING_LENGTH = 128;
|
||||
static const int PARAM_MAX_NUM = 64;
|
||||
|
||||
char m_ReadCharBuffer[PARAM_VALUE_MAX_STRING_LENGTH];
|
||||
wchar_t *m_ParamName[PARAM_MAX_NUM];
|
||||
wchar_t *m_ParamValue[PARAM_MAX_NUM];
|
||||
wchar_t *m_Buffer;
|
||||
|
||||
s32 m_UsedBufferSize;
|
||||
s32 m_ParamNum;
|
||||
|
||||
public:
|
||||
ConfigFileLoader() : m_Buffer(0), m_UsedBufferSize(0), m_ParamNum(0)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
@brief ConfigFileLoader を初期化します.
|
||||
|
||||
使用するファイルが存在するアーカイブは,あらかじめマウントしておく必要があります.
|
||||
読み込みに使用するバッファを確保し,引数 buffer に与える必要があります.
|
||||
Finalize を呼ぶまでこのバッファは開放しないでください.
|
||||
|
||||
読み込ませることのできるフォーマット
|
||||
・エンコーディング:UTF-16
|
||||
・バイトオーダ :リトルエンディアン
|
||||
・改行記号 :不問
|
||||
|
||||
半角コロンを含む行のみパラメータ記述行として読み込み,含まない行は無視します.
|
||||
半角コロンより前の文字はすべてパラメータ名として取得し,
|
||||
半角コロンより後の文字はすべてパラメータの値として取得します.
|
||||
ParameterName : ParameterValue;
|
||||
と記述すると
|
||||
パラメータ名は L"ParameterName "
|
||||
パラメータ値は L" ParameterValue;"
|
||||
となります.
|
||||
|
||||
@param[in] fileName 設定ファイル名
|
||||
@param[in] buffer ファイル読み込み用のバッファ
|
||||
@param[in] bufferSize 上記 buffer の大きさ
|
||||
|
||||
@return 結果を返します.
|
||||
|
||||
*/
|
||||
Result Initialize(const wchar_t* fileName, void* buffer, const size_t bufferSize);
|
||||
void Finalize();
|
||||
|
||||
// スレッドセーフです.
|
||||
const wchar_t *ReadAsWChar(const wchar_t *paramName);
|
||||
|
||||
// スレッドセーフではありません.
|
||||
const char *ReadAsChar(const wchar_t *paramName);
|
||||
|
||||
// スレッドセーフです.
|
||||
int ReadAsInteger(const wchar_t *paramName);
|
||||
|
||||
private:
|
||||
Result ParseData();
|
||||
s32 SearchParamName(const wchar_t *paramName);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // NN_CONFIG_LOADER_H_
|
||||
Binary file not shown.
BIN
tags/0thNUP_2/ConsoleDataMigration/common/romfiles/cursor.wav
Normal file
BIN
tags/0thNUP_2/ConsoleDataMigration/common/romfiles/cursor.wav
Normal file
Binary file not shown.
BIN
tags/0thNUP_2/ConsoleDataMigration/common/romfiles/ng.wav
Normal file
BIN
tags/0thNUP_2/ConsoleDataMigration/common/romfiles/ng.wav
Normal file
Binary file not shown.
BIN
tags/0thNUP_2/ConsoleDataMigration/common/romfiles/ok.wav
Normal file
BIN
tags/0thNUP_2/ConsoleDataMigration/common/romfiles/ok.wav
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user