NCFGを破壊するツールのコミット

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2040 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
(no author) 2008-07-31 01:04:56 +00:00
parent b7917072d9
commit dad64ade70
4 changed files with 270 additions and 0 deletions

View File

@ -0,0 +1,66 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlWiFi - NCFG - demos - ncfg-1
# File: Makefile
#
# Copyright 2007 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.
#
# $Date:: $
# $Rev$
# $Author$
#----------------------------------------------------------------------------
SUBDIRS = $(ROOT)/build/demos/gx/UnitTours/DEMOLib
#----------------------------------------------------------------------------
TARGET_PLATFORM = TWL
TWL_ARCHGEN := LIMITED
TARGET_NAME = NCFGTest
TARGET_BIN = $(TARGET_NAME).srl
SRCS = main.c
ROM_SPEC = $(TARGET_NAME).autogen.rsf
ROM_SPEC_TEMPLATE = $(ROOT)/include/twl/specfiles/ROM-TS_sys.rsf
ROM_SPEC_PARAM = MakerCode=01 \
BannerFile=./banner/banner.bnr \
GameCode=4S03 \
TitleName=$(TARGET_NAME) \
AppType=USER \
MAKEROM := $(TWL_TOOLSDIR)/bin/makerom.TWL.exe
#-------------------------
# ƒCƒ“ƒXƒg<C692>Žwè
ifneq ($(TWL_IPL_RED_ROOT),)
INSTALL_DIR = $(TWL_IPL_RED_ROOT)/debugsoft/$(TARGET_NAME)
INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN)
endif
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/commondefs
include $(TWLWIFI_ROOT)/build/buildtools/commondefs.demos
include $(TWLSDK_ROOT)/build/buildtools/commondefs.gx.demolib
#----------------------------------------------------------------------------
do-build: $(TARGETS)
include $(TWLWIFI_ROOT)/build/buildtools/modulerules
include $(TWLSDK_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

Binary file not shown.

View File

@ -0,0 +1,21 @@
NCFGの修復仕様まとめ
接続設定のCRCをチェックし、エラーがある場合はその設定を初期化します。
IPアドレスの設定や、接続タイプ等が全てクリアされる状態
Nitroのときのように、接続設定を異常にすると、も道連れになりクリアされるというようなことはありません。
より、詳細な仕様は影舞に記されています。
http://phoenix.boy.nintendo.co.jp/~twl-wifi/kagemai/html/user.cgi?project=twl-wifi&action=view_report&id=84
http://phoenix.boy.nintendo.co.jp/~twl-wifi/kagemai/html/user.cgi?project=twl-wifi&action=view_report&id=83
一部抜粋
- CRC エラーの接続先は、個別に消去します。
- 全領域 CRC エラーだった場合は、初回起動だと見なし、消去のみを行い、
エラーを返しません。
- 設定がされていた領域で消去が発生した場合は、エラーを通知します。
- それ以外の場合は、エラーを返しません。
(元々設定されていなかった領域で消去が発生した場合も含む)

View File

@ -0,0 +1,183 @@
/*---------------------------------------------------------------------------*
Project: TwlWiFi - NCFG - demos - ncfg-1
File: main.c
Copyright 2007 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.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
NVRAM
*---------------------------------------------------------------------------*/
#include <nitro.h>
#include <nitroWiFi.h>
#include <nitroWiFi/ncfg.h>
#include <DEMO.h>
#include <nitro/pad.h>
//#include <nitro/std.h>
//#include <nitro/fs.h>
static void MainLoop(void);
//static void VBlankIntr(void);
static void ReadNCFG(s32 index, u8* out);
static void WriteNCFG(s32 index);
static void InitDEMOSystem(void);
static u32 UpdateCursor(u32 val, u32 max, u16 key);
static const char* SLOT_NAME[] = {
"SLOT_1", "SLOT_2", "SLOT_3", "SLOT_EX_1", "SLOT_EX_2", "SLOT_EX_3"
};
static const u32 SLOT_NUM = sizeof(SLOT_NAME) / sizeof(char*);
void NitroMain()
{
OS_Init();
FX_Init();
GX_Init();
// GX_DispOff();
// GXS_DispOff();
// V ブランク割り込み設定
OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
(void)GX_VBlankIntr(TRUE);
// 割り込み許可
(void)OS_EnableIrq();
(void)OS_EnableInterrupts();
InitDEMOSystem();
(void)PAD_Read();
OS_TPrintf("UP DOWN - SELECT NCFG SLOT\n");
OS_TPrintf("A - OVERWRITE NCFG\n");
MainLoop();
OS_Terminate();
}
static u32 UpdateCursor(u32 val, u32 max, u16 key)
{
if(key & PAD_KEY_DOWN)
{
val = (val + 1) % max;
}
if(key & PAD_KEY_UP)
{
val = (val + max - 1) % max;
}
return val;
}
static void MainLoop(void)
{
u32 index = 0;
s32 slot_index[] =
{
NCFG_SLOT_1,
NCFG_SLOT_2,
NCFG_SLOT_3,
NCFG_SLOT_EX_1,
NCFG_SLOT_EX_2,
NCFG_SLOT_EX_3,
};
u16 key = 0, old_key = 0, trig = 0;
while(1)
{
s32 i = 0;
old_key = key;
key = PAD_Read();
trig = (u16)(key & (key ^ old_key));
index = UpdateCursor(index, SLOT_NUM, trig);
if(trig & PAD_BUTTON_A)
{
WriteNCFG(slot_index[index]);
OS_TPrintf("%s was modified\n", SLOT_NAME[index]);
}
for(i = 0; i < SLOT_NUM; ++i)
{
DEMODrawText(0, i * 8, ((index == i) ? "*" : " "));
DEMODrawText(8, i * 8, "%s\n", SLOT_NAME[i]);
}
DEMO_DrawFlip();
OS_WaitVBlankIntr();
}
}
static void ReadNCFG(s32 index, u8* out)
{
static u8 buf[512];
FSFile fp;
s32 result;
FS_InitFile(&fp);
result = NCFG_ReadBackupMemory(buf, sizeof(buf), index);
OS_TPrintf("NCFG_ReadBackupMemory(%d): %d\n", index, result);
if ( result >= 0 )
{
// OS_TPrintfEx("% *.16b", result, buf);
OS_TPrintfEx("% 256.16b", buf);
OS_TPrintf("\n");
}
MI_CpuCopy8(buf, out, sizeof(buf));
}
static void WriteNCFG(s32 index)
{
static u8 buf[512];
s32 result;
ReadNCFG(index, buf);
MI_CpuCopy("abcdefg", buf, 7);
result = NCFG_WriteBackupMemory(index, buf, sizeof(buf));
OS_TPrintf("NCFG_WriteBackupMemory(%d): %d\n", index, result);
OS_TPrintfEx("% 256.16b", buf);
OS_TPrintf("\n");
}
/*---------------------------------------------------------------------------*
Name: InitDEMOSystem
Description:
Arguments:
Returns:
*---------------------------------------------------------------------------*/
static void InitDEMOSystem(void)
{
// 画面表示の初期化。
DEMOInitCommon();
DEMOInitVRAM();
DEMOInitDisplayBitmap();
DEMOHookConsole();
DEMOSetBitmapTextColor(GX_RGBA(31, 31, 31, 1));
DEMOSetBitmapGroundColor(DEMO_RGB_CLEAR);
DEMOStartDisplay();
}