TwlIPL/build/systemMenu_RED/NandInitializer/ARM9.TWL/src/process_format.c
kamikawa 196826e6af NANDの擬似フォーマット処理に対応。シーン切り替えにフェード効果を追加。
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@626 b08762b0-b915-fc4b-9d8c-17b2551a87ff
2008-02-08 08:56:10 +00:00

310 lines
8.3 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*---------------------------------------------------------------------------*
Project: TwlSDK - NandInitializer
File: process_format.c
Copyright 2008 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$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <nitro/snd.h>
#include <twl/fatfs.h>
#include <nitro/card.h>
#include "kami_font.h"
#include "kami_pxi.h"
#include "process_topmenu.h"
#include "process_format.h"
#include "process_auto.h"
#include "process_fade.h"
#include "cursor.h"
#include "keypad.h"
#include <sysmenu/namut.h>
/*---------------------------------------------------------------------------*
Œ^’è‹`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
è<E28099>è`
*---------------------------------------------------------------------------*/
#define NUM_OF_MENU_SELECT 5
#define DOT_OF_MENU_SPACE 16
#define CURSOR_ORIGIN_X 32
#define CURSOR_ORIGIN_Y 56
#define CHAR_OF_MENU_SPACE 2
/*---------------------------------------------------------------------------*
“à•”•Ï<E280A2>è`
*---------------------------------------------------------------------------*/
static s8 sMenuSelectNo;
static u8 sLock;
static u8 sFormatResult;
/*---------------------------------------------------------------------------*
“à•”ŠÖ<C5A0><EFBFBD>錾
*---------------------------------------------------------------------------*/
static void FormatCallback(KAMIResult result, void* arg);
/*---------------------------------------------------------------------------*
ƒvƒ<76>ƒZƒXŠÖ<C5A0>è`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: Format ƒvƒ<76>ƒZƒXO
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* FormatProcess0(void)
{
int i;
// •¶Žš—ñSƒNƒŠƒA
kamiFontClear();
// ƒo<C692>[ƒWƒ‡ƒ“•\ަ
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Format Nand Flash");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// ƒ<>ƒjƒ…<C692>[ˆê——
kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l FORMAT <Easy> l l");
kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l FORMAT <Normal> l l");
kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 11, FONT_COLOR_BLACK, "l FORMAT <Fill ff> l l");
kamiFontPrintf(3, 12, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 13, FONT_COLOR_BLACK, "l CHECK DISK l l");
kamiFontPrintf(3, 14, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 15, FONT_COLOR_BLACK, "l RETURN l l");
kamiFontPrintf(3, 16, FONT_COLOR_BLACK, "+-------------------+-----+");
// ”wŒiSƒNƒŠƒA
for (i=0;i<24;i++)
{
kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS );
}
// ”wŒi<C592>ã•”
kamiFontFillChar( 0, BG_COLOR_BLUE, BG_COLOR_BLUE );
kamiFontFillChar( 1, BG_COLOR_BLUE, BG_COLOR_BLUE );
kamiFontFillChar( 2, BG_COLOR_BLUE, BG_COLOR_TRANS );
// ƒJ<C692>[ƒ\ƒ<C692>œŠO
SetCursorPos((u16)200, (u16)200);
FADE_IN_RETURN( FormatProcess1 );
}
/*---------------------------------------------------------------------------*
Name: Format ƒvƒ<76>ƒZƒXP
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* FormatProcess1(void)
{
// ƒI<C692>[ƒgŽÀ<C5BD>s—p
if (gAutoFlag)
{
sMenuSelectNo = 1;
return FormatProcess2;
}
// Iðƒ<C3B0>ƒjƒ…<C692>[Ì•Ï<E280A2>X
if ( kamiPadIsRepeatTrigger(PAD_KEY_UP) )
{
if (--sMenuSelectNo < 0) sMenuSelectNo = NUM_OF_MENU_SELECT -1;
}
else if ( kamiPadIsRepeatTrigger(PAD_KEY_DOWN) )
{
if (++sMenuSelectNo >= NUM_OF_MENU_SELECT) sMenuSelectNo = 0;
}
// ƒJ<C692>[ƒ\ƒ”zu
SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE));
// Œˆ’è
if (kamiPadIsTrigger(PAD_BUTTON_A))
{
return FormatProcess2;
}
// ƒgƒbƒvƒ<76>ƒjƒ…<C692>[‚Ö–ß‚é
else if (kamiPadIsTrigger(PAD_BUTTON_B))
{
FADE_OUT_RETURN( TopmenuProcess0 );
}
return FormatProcess1;
}
/*---------------------------------------------------------------------------*
Name: Format ƒvƒ<76>ƒZƒXQ
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* FormatProcess2(void)
{
if (sLock == FALSE)
{
s16 y_pos = (s16)(7 + sMenuSelectNo * CHAR_OF_MENU_SPACE);
switch( sMenuSelectNo )
{
case 0:
// NAMUT_DrawNandTree();
if (NAMUT_Format())
{
kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK ");
}
else
{
kamiFontPrintf(24, y_pos, FONT_COLOR_RED, " NG ");
}
// NAMUT_DrawNandTree();
return FormatProcess1;
case 1:
sLock = TRUE;
ExeFormatAsync(FORMAT_MODE_QUICK, FormatCallback);
kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " ");
return FormatProcess3;
case 2:
sLock = TRUE;
ExeFormatAsync(FORMAT_MODE_FULL, FormatCallback);
kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " ");
return FormatProcess3;
case 3:
{
FATFSDiskInfo info;
BOOL result = FALSE;
kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " ");
kamiFontLoadScreenData();
FATFS_UnmountDrive("F:");
FATFS_UnmountDrive("G:");
// ŽwèÌNANDƒp<C692>[ƒeƒBƒVƒ‡ƒ“0ðFƒhƒ‰ƒCƒuɃ}ƒEƒ“ƒg
if (FATFS_MountDrive("F", FATFS_MEDIA_TYPE_NAND, 0))
{
// ƒ`ƒFƒbƒNƒfƒBƒXƒNŽÀ<C5BD>s
if (FATFS_CheckDisk("F:", &info, TRUE, TRUE, TRUE))
{
// ŽwèÌNANDƒp<C692>[ƒeƒBƒVƒ‡ƒ“1ðGƒhƒ‰ƒCƒuɃ}ƒEƒ“ƒg
if (FATFS_MountDrive("G", FATFS_MEDIA_TYPE_NAND, 1))
{
// ƒ`ƒFƒbƒNƒfƒBƒXƒNŽÀ<C5BD>s
if (FATFS_CheckDisk("G:", &info, TRUE, TRUE, TRUE))
{
result = TRUE;
}
}
}
}
// ƒfƒtƒHƒƒgƒ}ƒEƒ“ƒg<C692>óÔÉߵĨ­
FATFS_UnmountDrive("G:");
FATFS_MountDrive("G", FATFS_MEDIA_TYPE_SD, 0);
if (result == TRUE) { kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK "); }
else { kamiFontPrintf(24, y_pos, FONT_COLOR_RED, " NG "); }
return FormatProcess1;
}
case 4:
FADE_OUT_RETURN( TopmenuProcess0 );
}
}
return FormatProcess1;
}
static void FormatCallback(KAMIResult result, void* /*arg*/)
{
s16 y_pos = (s16)(7 + sMenuSelectNo * CHAR_OF_MENU_SPACE);
if ( result == KAMI_RESULT_SUCCESS_TRUE )
{
kamiFontPrintf(24, y_pos, FONT_COLOR_GREEN, " OK ");
sFormatResult = TRUE;
}
else
{
kamiFontPrintf(24, y_pos, FONT_COLOR_RED, " NG ");
sFormatResult = FALSE;
}
// ƒ<>ƒbƒN‰ð<E280B0>œ
sLock = FALSE;
}
/*---------------------------------------------------------------------------*
Name: Format ƒvƒ<76>ƒZƒXR
Description: ƒtƒH<C692>[ƒ}ƒbƒgŠ®—¹Ò¿ƒvƒ<76>ƒZƒX
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* FormatProcess3(void)
{
static s32 progress;
s16 y_pos;
// <20>ˆ<CB86><E28094>I—¹”»è
if (sLock == FALSE)
{
progress = 0;
// Auto—p
if (gAutoFlag)
{
if (sFormatResult == TRUE) { FADE_OUT_RETURN( AutoProcess1 ); }
else { FADE_OUT_RETURN( AutoProcess2 ); }
}
return FormatProcess1;
}
if ( sMenuSelectNo == 0 ) { y_pos = 7; }
else { y_pos = 9; }
// <20>i»•\ަ<C5BD>X<EFBFBD>V
if ( ++progress >= 30*5 )
{
progress = 0;
kamiFontPrintf(24, y_pos, FONT_COLOR_BLACK, " ");
}
kamiFontPrintf((s16)(24 + (progress / 30)), y_pos, FONT_COLOR_BLACK, "*");
return FormatProcess3;
}