TwlIPL/build/systemMenu_tools/SystemUpdater/ARM9.TWL/src/import.c
yosiokat c9bb993854 HWInfoWriter, ImportJump, SystemUpdater
NandInitializer, NandInitializerProduction, NandInitializerRED 
のソースツリーを systemMenu_tools フォルダに移動

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@1312 b08762b0-b915-fc4b-9d8c-17b2551a87ff
2008-05-12 08:47:02 +00:00

235 lines
6.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: 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(&currentSize, &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);
}