mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
NandInitializer, NandInitializerProduction, NandInitializerRED のソースツリーを systemMenu_tools フォルダに移動 git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@1312 b08762b0-b915-fc4b-9d8c-17b2551a87ff
235 lines
6.3 KiB
C
235 lines
6.3 KiB
C
/*---------------------------------------------------------------------------*
|
||
Project: SystemUpdater
|
||
File: process_import.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 <twl/nam.h>
|
||
#include <twl/lcfg.h>
|
||
#include <sysmenu/namut.h>
|
||
#include "kami_font.h"
|
||
#include "import.h"
|
||
#include "hw_info.h"
|
||
#include "TWLHWInfo_api.h"
|
||
#include "graphics.h"
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Œ^’è‹`
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
’è<E28099>”’è‹`
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
#define THREAD_STACK_SIZE (16*1024)
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
“à•”•Ï<E280A2>”’è‹`
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
static u32 sCurrentProgress;
|
||
static vu8 sNowImport = FALSE;
|
||
static vu8 sProgress = FALSE;
|
||
static u8 sStack[THREAD_STACK_SIZE];
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
“à•”ŠÖ<C5A0>”<EFBFBD>錾
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
static void ProgressThread(void* arg);
|
||
static void Destructor(void* arg);
|
||
void ProgressDraw(f32 ratio);
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
<20>ˆ—<CB86>ŠÖ<C5A0>”’è‹`
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Name: kamiImportTad
|
||
|
||
Description: .tad ƒtƒ@ƒCƒ‹ƒCƒ“ƒ|<7C>[ƒg
|
||
|
||
Arguments: no
|
||
|
||
Returns: None.
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
s32 kamiImportTad(int no, int total, const char* path)
|
||
{
|
||
NAMTadInfo tadInfo;
|
||
OSThread thread;
|
||
s32 nam_result;
|
||
|
||
kamiFontPrintfMain( 4, 9, 8, "Now Updating... %d / %d", no, total );
|
||
kamiFontLoadScreenData();
|
||
|
||
// tadƒtƒ@ƒCƒ‹‚Ì<E2809A>î•ñŽæ“¾
|
||
nam_result = NAM_ReadTadInfo(&tadInfo, path);
|
||
if ( nam_result != NAM_OK )
|
||
{
|
||
return nam_result;
|
||
}
|
||
|
||
// ES‚ÌŽd—l‚Ō¢ e-ticket ‚ª‚ ‚邯<E2809A>V‚µ‚¢ e-ticket ‚ðŽg‚Á‚½ƒCƒ“ƒ|<7C>[ƒg‚ª‚Å‚«‚È‚¢
|
||
// Žb’è‘Ήž‚Æ‚µ‚ÄŠY“–ƒ^ƒCƒgƒ‹‚ðŠ®‘S<E28098>í<EFBFBD>œ‚µ‚Ä‚©‚çƒCƒ“ƒ|<7C>[ƒg‚·‚é
|
||
nam_result = NAM_DeleteTitleCompletely(tadInfo.titleInfo.titleId);
|
||
if ( nam_result != NAM_OK )
|
||
{
|
||
kamiFontPrintfConsole(CONSOLE_RED, "Fail! RetCode=%x\n", nam_result);
|
||
return FALSE;
|
||
}
|
||
|
||
// ƒCƒ“ƒ|<7C>[ƒgŠJŽnƒtƒ‰ƒO‚ð—§‚Ä‚é
|
||
sNowImport = TRUE;
|
||
|
||
// <20>i’»ƒXƒŒƒbƒh<C692>ì<EFBFBD>¬
|
||
MI_CpuClear8(sStack, THREAD_STACK_SIZE);
|
||
OS_CreateThread(&thread, ProgressThread, NULL,
|
||
(void*)((u32)sStack + THREAD_STACK_SIZE), THREAD_STACK_SIZE, OS_GetCurrentThread()->priority - 1);
|
||
OS_WakeupThreadDirect(&thread);
|
||
|
||
// ImportŠJŽn
|
||
nam_result = NAM_ImportTad( path );
|
||
|
||
// ƒCƒ“ƒ|<7C>[ƒgŠJŽnƒtƒ‰ƒO‚ð‰º‚°‚é
|
||
sNowImport = FALSE;
|
||
|
||
// <20>i’»ƒXƒŒƒbƒh‚ÌŽ©—Í<E28094>I—¹‚ð‘Ò‚Â
|
||
while (sProgress){};
|
||
|
||
// InstalledSoftBoxCount, FreeSoftBoxCount ‚Ì’l‚ðŒ»<C592>Ý‚ÌNAND‚Ì<E2809A>ó‘Ô‚É<E2809A>‡‚킹‚Ä<E2809A>X<EFBFBD>V‚µ‚Ü‚·<E2809A>B
|
||
UpdateNandBoxCount();
|
||
|
||
return nam_result;
|
||
}
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Name: ProgressThread
|
||
|
||
Description: .tad ƒtƒ@ƒCƒ‹ƒCƒ“ƒ|<7C>[ƒg‚Ì<E2809A>i’»‚ð•\ަ‚·‚éƒXƒŒƒbƒh<C692>B
|
||
<09>i’»‚ª100%‚É’B‚·‚邯<E2809A>ˆ—<CB86>‚𔲂¯‚é<E2809A>B
|
||
|
||
Arguments: arg - Žg—p‚µ‚È‚¢<E2809A>B
|
||
|
||
Returns: None.
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
static void ProgressThread(void* /*arg*/)
|
||
{
|
||
u32 currentSize;
|
||
u32 totalSize = 0;
|
||
u32 totalSizeBk = 0;
|
||
|
||
sProgress = TRUE;
|
||
|
||
while (sNowImport)
|
||
{
|
||
NAM_GetProgress(¤tSize, &totalSize);
|
||
|
||
if ((totalSize > 0 && totalSize == currentSize) || totalSizeBk > totalSize)
|
||
{
|
||
// Šù‚ɃCƒ“ƒ|<7C>[ƒg‚ª<E2809A>I—¹
|
||
ProgressDraw((f32)1.0);
|
||
break;
|
||
}
|
||
else if (totalSize > 0)
|
||
{
|
||
ProgressDraw((f32)currentSize/totalSize);
|
||
}
|
||
|
||
totalSizeBk = totalSize;
|
||
|
||
// Vƒuƒ‰ƒ“ƒN‘Ò‚¿
|
||
OS_WaitVBlankIntr();
|
||
}
|
||
|
||
sProgress = FALSE;
|
||
}
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Name: ProgressDraw
|
||
|
||
Description: ƒCƒ“ƒ|<7C>[ƒg‚Ì<E2809A>i’»‚ð•\ަ‚µ‚Ü‚·
|
||
|
||
Arguments:
|
||
|
||
Returns: None.
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
void ProgressDraw(f32 ratio)
|
||
{
|
||
s16 x = (s16)(30 + (226 - 30)*ratio);
|
||
|
||
// 3D<33>‰Šú‰»
|
||
G3X_Reset();
|
||
G3_Identity();
|
||
G3_PolygonAttr(GX_LIGHTMASK_NONE, GX_POLYGONMODE_DECAL, GX_CULL_NONE, 0, 31, 0);
|
||
|
||
// ƒOƒŠ<C692>[ƒ“ƒo<C692>[
|
||
DrawQuad( 30, 90, x, 95, GX_RGB(12, 25, 12));
|
||
|
||
// ƒOƒŒ<C692>[ƒo<C692>[
|
||
DrawQuad( 30, 90, 226, 95, GX_RGB(28, 28, 28));
|
||
|
||
// ƒOƒŒ<C692>[ƒ_ƒCƒAƒ<41>ƒO
|
||
DrawQuad( 20, 60, 236, 110, GX_RGB(25, 25, 25));
|
||
|
||
// 3DƒXƒ<58>ƒbƒv
|
||
G3_SwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W);
|
||
}
|
||
|
||
/*---------------------------------------------------------------------------*
|
||
Name: DrawResult
|
||
|
||
Description: <20>ˆ—<CB86>Œ‹‰Ê‚ð•\ަ‚µ‚Ü‚·<E2809A>B
|
||
|
||
Arguments:
|
||
|
||
Returns: None.
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
void DrawResult(BOOL result)
|
||
{
|
||
// 3D<33>‰Šú‰»
|
||
G3X_Reset();
|
||
G3_Identity();
|
||
G3_PolygonAttr(GX_LIGHTMASK_NONE, GX_POLYGONMODE_DECAL, GX_CULL_NONE, 0, 31, 0);
|
||
|
||
// "Now Updating.." ‚ð<E2809A>Á‹Ž
|
||
kamiFontPrintfMain( 0, 9, 7, " ");
|
||
|
||
if (result)
|
||
{
|
||
kamiFontPrintfMain( 9, 10, 7, "Update Success!");
|
||
// ƒOƒŠ<C692>[ƒ“ƒ_ƒCƒAƒ<41>ƒO
|
||
DrawQuad( 50, 50, 206, 120, GX_RGB(12, 25, 12));
|
||
}
|
||
else
|
||
{
|
||
kamiFontPrintfMain( 9, 10, 7, "Update Failure!");
|
||
// ƒŒƒbƒhƒ_ƒCƒAƒ<41>ƒO
|
||
DrawQuad( 50, 50, 206, 120, GX_RGB(31, 0, 0));
|
||
}
|
||
|
||
kamiFontLoadScreenData();
|
||
|
||
// 3DƒXƒ<58>ƒbƒv
|
||
G3_SwapBuffers(GX_SORTMODE_AUTO, GX_BUFFERMODE_W);
|
||
}
|
||
|