mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
Common eTikcetのユーザーアプリは、アプリ本体も残すようにする。 ・GetETicketTypeのcommon eTicket判定を変更。 ・テスト用関数NAMUT_PrintInstalledTitleETicketTypeの追加。 ・TWLランチャー.mmapに上記変更を反映。 git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2825 b08762b0-b915-fc4b-9d8c-17b2551a87ff
192 lines
6.0 KiB
C
192 lines
6.0 KiB
C
/*---------------------------------------------------------------------------*
|
||
Project: TwlIPL
|
||
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$
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
#include <twl.h>
|
||
#include <twl/sea.h>
|
||
#include <twl/lcfg.h>
|
||
#include <twl/na.h>
|
||
#include <nitro/fs/sysarea.h>
|
||
#include <sysmenu/namut.h>
|
||
#include <sysmenu/util.h>
|
||
#include "misc.h"
|
||
#include "MachineSetting.h"
|
||
#include "getSysMenuVersion.h"
|
||
|
||
// extern data-----------------------------------------------------------------
|
||
|
||
// define data-----------------------------------------------------------------
|
||
|
||
// function's prototype-------------------------------------------------------
|
||
static void INTR_VBlank( void );
|
||
|
||
// global variable-------------------------------------------------------------
|
||
int (*g_pNowProcess)( void );
|
||
BOOL g_isValidTSD;
|
||
RTCDrawProperty g_rtcDraw = {
|
||
TRUE, RTC_DATE_TOP_X, RTC_DATE_TOP_Y, RTC_TIME_TOP_X, RTC_TIME_TOP_Y
|
||
};
|
||
|
||
// static variable-------------------------------------------------------------
|
||
|
||
// const data------------------------------------------------------------------
|
||
|
||
|
||
// ============================================================================
|
||
// function's description
|
||
// ============================================================================
|
||
void TwlMain(void)
|
||
{
|
||
|
||
// <20>‰Šú‰»----------------------------------
|
||
OS_Init();
|
||
OS_InitTick();
|
||
|
||
(void)OS_EnableIrq();
|
||
(void)OS_EnableInterrupts();
|
||
|
||
SEA_Init();
|
||
|
||
GX_Init();
|
||
GX_SetPower(GX_POWER_ALL); // Šeƒ<65>ƒWƒbƒN ƒpƒ<70><C692>[ON
|
||
FS_Init( FS_DMA_NOT_USE );
|
||
|
||
SND_Init();
|
||
SNDEX_Init();
|
||
|
||
// Š„‚è<E2809A>ž‚Ý‹–‰Â----------------------------
|
||
(void)OS_SetIrqFunction(OS_IE_V_BLANK, INTR_VBlank);
|
||
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
|
||
(void)GX_VBlankIntr(TRUE);
|
||
|
||
// ƒfƒoƒCƒX<C692>‰Šú‰»-------------------------------
|
||
TP_Init();
|
||
(void)RTC_Init();
|
||
|
||
// ƒVƒXƒeƒ€‚Ì<E2809A>‰Šú‰»------------------
|
||
InitAllocator();
|
||
|
||
// NAMƒ‰ƒCƒuƒ‰ƒŠ<C692>‰Šú‰»
|
||
NAM_Init( Alloc, Free ); // NAMUTƒ‰ƒCƒuƒ‰ƒŠ‚ªNAMƒ‰ƒCƒuƒ‰ƒŠ‚ðŽg—p‚µ‚Ä‚¢‚é
|
||
NAMUT_Init( Alloc, Free );
|
||
|
||
// <20>¦–{—ˆ‚Ȃ烉ƒ“ƒ`ƒƒ<C692>[‚©‚ç‚̃pƒ‰ƒ<E280B0><C692>[ƒ^ƒ`ƒFƒbƒN‚ð<E2809A>s‚¢<E2809A>A
|
||
// <20>‰‰ñ‹N“®ƒV<C692>[ƒPƒ“ƒX‚É“ü‚éƒpƒX‚ª‚ ‚é
|
||
|
||
{
|
||
OS_TPrintf( "LCFGTWLOwnerInfo : 0x%04x\n", sizeof(LCFGTWLOwnerInfo) );
|
||
OS_TPrintf( "LCFGTWLParentalControl : 0x%04x\n", sizeof(LCFGTWLParentalControl) );
|
||
OS_TPrintf( "LCFGTWLSettingsData : 0x%04x\n", sizeof(LCFGTWLSettingsData) );
|
||
}
|
||
|
||
(void) NAMUT_PrintInstalledTitleETicketType();
|
||
|
||
// ::::::::::::::::::::::::::::::::::::::::::::::
|
||
// TWL<57>Ý’èƒf<C692>[ƒ^ƒtƒ@ƒCƒ‹‚̓ǂÝ<E2809A>ž‚Ý
|
||
// ::::::::::::::::::::::::::::::::::::::::::::::
|
||
g_isValidTSD = TRUE;
|
||
{
|
||
u8 *pBuffer = Alloc( LCFG_READ_TEMP );
|
||
if( pBuffer ) {
|
||
// NAND‚©‚çTWL–{‘Ì<E28098>Ý’èƒf<C692>[ƒ^‚ðƒŠ<C692>[ƒh
|
||
BOOL isRead = LCFG_ReadTWLSettings( (u8 (*)[LCFG_READ_TEMP])pBuffer );
|
||
|
||
// ƒŠ<C692>[ƒhޏ”sƒtƒ@ƒCƒ‹‚ª‘¶<E28098>Ý‚·‚é<E2809A>ê<EFBFBD>‡‚Í<E2809A>Aƒtƒ@ƒCƒ‹‚ðƒŠƒJƒoƒŠ
|
||
if( LCFG_RecoveryTWLSettings() ) {
|
||
if( isRead ) {
|
||
// ƒ~ƒ‰<C692>[ƒf<C692>[ƒ^‚Ì‚¤‚¿<E2809A>Aˆê•û‚Å‚àƒŠ<C692>[ƒh‚Å‚«‚Ä‚¢‚½‚Ȃ牽‚à‚µ‚È‚¢<E2809A>B
|
||
}else {
|
||
// ƒŠ<C692>[ƒh‚ÉŠ®‘S‚ÉŽ¸”s‚µ‚Ä‚¢‚½<E2809A>ê<EFBFBD>‡‚Í<E2809A>Aƒtƒ‰ƒbƒVƒ…‰ó‚êƒV<C692>[ƒPƒ“ƒX‚Ö<E2809A>B
|
||
LCFG_TSD_SetFlagFinishedBrokenTWLSettings( FALSE );
|
||
(void)LCFG_WriteTWLSettings( (u8 (*)[ LCFG_WRITE_TEMP ] )pBuffer ); // LCFG_READ_TEMP > LCFG_WRITE_TEMP ‚Ȃ̂Å<E2809A>ApBuffer‚ð‚»‚Ì‚Ü‚Ü—¬—p
|
||
}
|
||
}else {
|
||
// ƒŠƒJƒoƒŠŽ¸”sŽž‚Í<E2809A>AFALTALƒGƒ‰<C692>[
|
||
UTL_SetFatalError( FATAL_ERROR_TWLSETTINGS );
|
||
g_isValidTSD = FALSE;
|
||
}
|
||
Free( pBuffer );
|
||
}else {
|
||
// ƒ<>ƒ‚ƒŠŠm•Û‚ª‚Å‚«‚È‚©‚Á‚½Žž‚Í<E2809A>AFATALƒGƒ‰<C692>[
|
||
g_isValidTSD = FALSE;
|
||
}
|
||
}
|
||
|
||
UTL_CaribrateTP( LCFG_TSD_GetTPCalibrationPtr() );
|
||
|
||
// ::::::::::::::::::::::::::::::::::::::::::::::
|
||
// SystemMenuƒo<C692>[ƒWƒ‡ƒ“etc.‚̓ǂÝ<E2809A>ž‚Ý
|
||
// ::::::::::::::::::::::::::::::::::::::::::::::
|
||
{
|
||
u8 *pBuffer = Alloc( NA_VERSION_DATA_WORK_SIZE );
|
||
|
||
if( pBuffer &&
|
||
ReadSystemMenuVersionData( pBuffer, NA_VERSION_DATA_WORK_SIZE ) ) {
|
||
// ƒŠ<C692>[ƒh<C692>¬Œ÷
|
||
}else {
|
||
// FATALƒGƒ‰<C692>[
|
||
UTL_SetFatalError( FATAL_ERROR_TWLSETTINGS );
|
||
}
|
||
Free( pBuffer );
|
||
}
|
||
|
||
// ƒo<C692>[ƒWƒ‡ƒ“<C692>î•ñ‚Ì•\ަ
|
||
{
|
||
char str_ver[ TWL_SYSMENU_VER_STR_LEN / sizeof(u16) ];
|
||
int len = sizeof(str_ver);
|
||
OS_TPrintf( "SystemMenuVersionData\n" );
|
||
// •¶Žš—ñ
|
||
if( STD_ConvertStringUnicodeToSjis( str_ver, &len, GetSystemMenuVersionString(), NULL, NULL ) == STD_RESULT_SUCCESS ) {
|
||
OS_TPrintf( " Version(str) : %s\n", str_ver );
|
||
}
|
||
// <20>”’l
|
||
OS_TPrintf( " Version(num) : %d.%d\n", GetSystemMenuMajorVersion(), GetSystemMenuMinorVersion() );
|
||
// ƒ†<C692>[ƒU<C692>[—̈æMAXƒTƒCƒY‚Ì•\ަ
|
||
OS_TPrintf( " TotalUserAreadSize : 0x%08x\n", FSi_GetTotalUserAreaSize() );
|
||
// EULA URL‚Ì•\ަ
|
||
OS_TPrintf( " EULA URL : %s\n", GetEULA_URL() );
|
||
// NUP HostName‚Ì•\ަ
|
||
OS_TPrintf( " NUP HostName : %s\n", GetNUP_HostName() );
|
||
// SystemMenuVersion<6F>î•ñ‚̃^ƒCƒ€ƒXƒ^ƒ“ƒv‚̎擾
|
||
OS_TPrintf( " Timestamp : %08x\n", GetSystemMenuVersionTimeStamp() );
|
||
}
|
||
InitBG();
|
||
GetAndDrawRTCData( &g_rtcDraw, TRUE );
|
||
MachineSettingInit();
|
||
// ƒ<>ƒCƒ“ƒ‹<C692>[ƒv----------------------------
|
||
while ( 1 ) {
|
||
OS_WaitIrq( 1, OS_IE_V_BLANK ); // Vƒuƒ‰ƒ“ƒNŠ„‚è<E2809A>ž‚ݑ҂¿
|
||
|
||
ReadKeyPad(); // ƒL<C692>[“ü—͂̎擾
|
||
|
||
(void)g_pNowProcess();
|
||
|
||
GetAndDrawRTCData( &g_rtcDraw, FALSE );
|
||
}
|
||
}
|
||
|
||
|
||
// ============================================================================
|
||
// Š„‚è<E2809A>ž‚Ý<E2809A>ˆ—<CB86>
|
||
// ============================================================================
|
||
|
||
// Vƒuƒ‰ƒ“ƒNŠ„‚è<E2809A>ž‚Ý
|
||
static void INTR_VBlank(void)
|
||
{
|
||
OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Vƒuƒ‰ƒ“ƒNŠ„<C5A0>žƒ`ƒFƒbƒN‚̃Zƒbƒg
|
||
}
|
||
|