mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@626 b08762b0-b915-fc4b-9d8c-17b2551a87ff
310 lines
8.3 KiB
C
310 lines
8.3 KiB
C
/*---------------------------------------------------------------------------*
|
||
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ƒX‚O
|
||
|
||
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Œi‘Sƒ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ƒX‚P
|
||
|
||
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>[ƒ\ƒ‹”z’u
|
||
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ƒX‚Q
|
||
|
||
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ƒX‚R
|
||
|
||
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;
|
||
}
|