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@2307 b08762b0-b915-fc4b-9d8c-17b2551a87ff
309 lines
9.9 KiB
C
309 lines
9.9 KiB
C
/*---------------------------------------------------------------------------*
|
||
Project: TwlIPL
|
||
File: DS_Chat.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 <sysmenu.h>
|
||
#include "TWLHWInfo_api.h"
|
||
#include "TWLSettings_api.h"
|
||
#include "misc.h"
|
||
#include "HWInfoWriter.h"
|
||
#include "hwi.h"
|
||
|
||
// define data------------------------------------------
|
||
#define WRITER_ELEMENT_NUM 7
|
||
#define MSG_X 3
|
||
#define MSG_Y 18
|
||
|
||
// extern data------------------------------------------
|
||
|
||
// function's prototype declaration---------------------
|
||
static void WriteHWInfoFile( u8 region, BOOL isDisableWireless );
|
||
static void DeleteHWInfoFile( void );
|
||
static void DispMessage( int x, int y, u16 color, const u16 *pMsg );
|
||
|
||
// global variable -------------------------------------
|
||
RTCDrawProperty g_rtcDraw = {
|
||
TRUE, RTC_DATE_TOP_X, RTC_DATE_TOP_Y, RTC_TIME_TOP_X, RTC_TIME_TOP_Y
|
||
};
|
||
|
||
// static variable -------------------------------------
|
||
static u16 s_csr;
|
||
static u8 *s_pPrivKeyBuffer = NULL;
|
||
static LCFGReadResult (*s_pReadSecureInfoFunc)( void );
|
||
static BOOL s_isReadTSD;
|
||
static u8 s_region_old;
|
||
static BOOL s_isDisableWireless;
|
||
|
||
// const data -----------------------------------------
|
||
static const u16 *const s_pStrWriter[ WRITER_ELEMENT_NUM ] = {
|
||
(const u16 *)L"Write HW Info REGION=JAPAN",
|
||
(const u16 *)L"Write HW Info REGION=AMERICA",
|
||
(const u16 *)L"Write HW Info REGION=EUROPE",
|
||
(const u16 *)L"Write HW Info REGION=AUSTRALIA",
|
||
(const u16 *)L"Write HW Info REGION=CHINA",
|
||
(const u16 *)L"Write HW Info REGION=KOREA",
|
||
(const u16 *)L"Delete HW Info",
|
||
};
|
||
|
||
static MenuPos s_writerPos[] = {
|
||
{ TRUE, 3 * 8, 4 * 8 },
|
||
{ TRUE, 3 * 8, 6 * 8 },
|
||
{ TRUE, 3 * 8, 8 * 8 },
|
||
{ TRUE, 3 * 8, 10 * 8 },
|
||
{ TRUE, 3 * 8, 12 * 8 },
|
||
{ TRUE, 3 * 8, 14 * 8 },
|
||
{ TRUE, 3 * 8, 16 * 8 },
|
||
};
|
||
|
||
|
||
static const MenuParam s_writerParam = {
|
||
WRITER_ELEMENT_NUM,
|
||
TXT_COLOR_BLACK,
|
||
TXT_COLOR_GREEN,
|
||
TXT_COLOR_RED,
|
||
&s_writerPos[ 0 ],
|
||
(const u16 **)&s_pStrWriter,
|
||
};
|
||
|
||
static const char *strRegion[] = {
|
||
"JAPAN",
|
||
"AMERICA",
|
||
"EUROPE",
|
||
"AUSTRALIA",
|
||
"CHINA",
|
||
"KOREA",
|
||
};
|
||
|
||
|
||
//======================================================
|
||
// HW<48><57><EFBFBD>C<F1838983>^<5E>[
|
||
//======================================================
|
||
const char *pWireless[] = {
|
||
"Enable Wireless",
|
||
"Force disable Wireless",
|
||
};
|
||
|
||
// HW<48><57><EFBFBD>C<F1838983>^<5E>[<5B>̏<EFBFBD><CC8F><EFBFBD><EFBFBD><EFBFBD>
|
||
void HWInfoWriterInit( void )
|
||
{
|
||
|
||
GX_DispOff();
|
||
GXS_DispOff();
|
||
|
||
InitBG();
|
||
|
||
NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_WHITE );
|
||
|
||
PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"HW Info Writer");
|
||
GetAndDrawRTCData( &g_rtcDraw, TRUE );
|
||
|
||
{
|
||
char *pMode = NULL;
|
||
switch ( HWI_Init( Alloc, Free ) ) {
|
||
case HWI_INIT_SUCCESS_NO_SIGNATRUE_MODE:
|
||
pMode = "No";
|
||
break;
|
||
case HWI_INIT_SUCCESS_PRO_SIGNATURE_MODE:
|
||
pMode = "Pro";
|
||
break;
|
||
case HWI_INIT_SUCCESS_DEV_SIGNATURE_MODE:
|
||
pMode = "Dev";
|
||
break;
|
||
}
|
||
PrintfSJIS( 14 * 8, 0 * 8, TXT_COLOR_RED, "[%s Signature MODE]", pMode );
|
||
}
|
||
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ON/OFF<46><46><EFBFBD><EFBFBD><EFBFBD>̕\<5C><>
|
||
s_isDisableWireless = OS_IsForceDisableWireless();
|
||
PrintfSJIS( 3 * 8, 2 * 8, TXT_COLOR_BLACK, pWireless[ s_isDisableWireless ] );
|
||
|
||
OS_TPrintf( "region = %d\n", OS_GetRegion() );
|
||
PrintfSJISSub( 2 * 8, 16 * 8, TXT_COLOR_BLACK, "Region = %s", strRegion[ OS_GetRegion() ] );
|
||
PrintfSJISSub( 2 * 8, 18 * 8, TXT_COLOR_BLACK, "SerialNo = %s", LCFG_THW_GetSerialNoPtr() );
|
||
if ( 1 )
|
||
{
|
||
int i;
|
||
u8 titleID_Lo[ 4 ];
|
||
u8 gameCode[ 5 ] = { 0, 0, 0, 0, 0 };
|
||
LCFG_THW_GetLauncherTitleID_Lo( titleID_Lo );
|
||
for( i = 0; i < 4; i++ ) gameCode[ i ] = titleID_Lo[ 4 - i - 1 ];
|
||
PrintfSJISSub( 2 * 8, 20 * 8, TXT_COLOR_BLACK, "LauncherTitleID_Lo = %s", gameCode );
|
||
}
|
||
s_region_old = OS_GetRegion();
|
||
s_csr = 0;
|
||
DrawMenu( s_csr, &s_writerParam );
|
||
|
||
GXS_SetVisiblePlane( GX_PLANEMASK_BG0 );
|
||
GX_DispOn();
|
||
GXS_DispOn();
|
||
}
|
||
|
||
|
||
// HW<48><57><EFBFBD>C<F1838983>^<5E>[<5B>̃<EFBFBD><CC83>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD>[<5B>v
|
||
void HWInfoWriterMain( void )
|
||
{
|
||
// <20>J<EFBFBD>[<5B>\<5C><><EFBFBD>ړ<EFBFBD>
|
||
if( pad.trg & PAD_KEY_DOWN ){
|
||
if( ++s_csr == WRITER_ELEMENT_NUM ) {
|
||
s_csr = 0;
|
||
}
|
||
}
|
||
if( pad.trg & PAD_KEY_UP ){
|
||
if( --s_csr & 0x8000 ) {
|
||
s_csr = WRITER_ELEMENT_NUM - 1;
|
||
}
|
||
}
|
||
DrawMenu( s_csr, &s_writerParam );
|
||
|
||
if( pad.trg & PAD_BUTTON_START ) {
|
||
PrintfSJIS( 3 * 8, 2 * 8, TXT_COLOR_WHITE, pWireless[ s_isDisableWireless ] );
|
||
s_isDisableWireless ^= 0x01;
|
||
PrintfSJIS( 3 * 8, 2 * 8, TXT_COLOR_BLACK, pWireless[ s_isDisableWireless ] );
|
||
}
|
||
|
||
// <20><><EFBFBD>s
|
||
if( pad.trg == PAD_BUTTON_A ) {
|
||
if( s_csr == WRITER_ELEMENT_NUM - 1 ) {
|
||
OS_TPrintf( "Delete start.\n" );
|
||
(void)DeleteHWInfoFile();
|
||
}else {
|
||
OS_TPrintf( "Write start.\n" );
|
||
WriteHWInfoFile( (u8)s_csr, s_isDisableWireless );
|
||
}
|
||
}
|
||
|
||
GetAndDrawRTCData( &g_rtcDraw, FALSE );
|
||
}
|
||
|
||
|
||
// HW<48><57><EFBFBD><EFBFBD><EFBFBD>S<EFBFBD>̂̃<CC82><CC83>C<EFBFBD>g
|
||
static void WriteHWInfoFile( u8 region, BOOL isDisableWireless )
|
||
{
|
||
static const u16 *pMsgSecureWriting = (const u16 *)L"Writing Secure File...";
|
||
static const u16 *pMsgNormalWriting = (const u16 *)L"Writing Normal File...";
|
||
static const u16 *pMsgHWIDSignWriting = (const u16 *)L"Writing HWID Sign File...";
|
||
static const u16 *pMsgSucceeded = (const u16 *)L"Succeeded!";
|
||
static const u16 *pMsgFailed = (const u16 *)L"Failed!";
|
||
|
||
// -------------------------------------
|
||
// <20>Z<EFBFBD>L<EFBFBD><4C><EFBFBD>A<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̃<EFBFBD><CC83>C<EFBFBD>g
|
||
// -------------------------------------
|
||
(void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLACK, pMsgSecureWriting );
|
||
|
||
if( HWI_WriteHWSecureInfoFile( region, NULL, isDisableWireless ) ) {
|
||
(void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded );
|
||
}else {
|
||
(void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_RED, pMsgFailed );
|
||
}
|
||
|
||
// -------------------------------------
|
||
// <20>m<EFBFBD>[<5B>}<7D><><EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̃<EFBFBD><CC83>C<EFBFBD>g (<28>ڍs<DA8D>\<5C>ȃ<EFBFBD><C883>j<EFBFBD>[<5B>NID<49>̂<EFBFBD><CC82>߃Z<DF83>L<EFBFBD><4C><EFBFBD>A<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̌<EFBFBD><CC8C>Ń<EFBFBD><C583>C<EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>j
|
||
// -------------------------------------
|
||
(void)PutStringUTF16( MSG_X * 8, MSG_Y * 8, TXT_COLOR_BLACK, pMsgNormalWriting );
|
||
|
||
if( HWI_WriteHWNormalInfoFile() ) {
|
||
(void)PutStringUTF16( ( MSG_X + 20 ) * 8, MSG_Y * 8, TXT_COLOR_BLUE, pMsgSucceeded );
|
||
}else {
|
||
(void)PutStringUTF16( ( MSG_X + 20 ) * 8, MSG_Y * 8, TXT_COLOR_RED, pMsgFailed );
|
||
}
|
||
|
||
// -------------------------------------
|
||
// HWID<49><44><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̃<EFBFBD><CC83>C<EFBFBD>g
|
||
// -------------------------------------
|
||
(void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 4 ) * 8, TXT_COLOR_BLACK, pMsgHWIDSignWriting );
|
||
|
||
if( HWI_WriteHWIDSignFile() ) {
|
||
(void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 4 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded );
|
||
}else {
|
||
(void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 4 ) * 8, TXT_COLOR_RED, pMsgFailed );
|
||
}
|
||
|
||
// <20><><EFBFBD>[<5B>W<EFBFBD><57><EFBFBD><EFBFBD><EFBFBD>̍X<CC8D>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>R<EFBFBD>[<5B>h<EFBFBD>ɔ<EFBFBD><C994>f<EFBFBD><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>B<EFBFBD>i<EFBFBD>K<EFBFBD><4B><EFBFBD>Z<EFBFBD>L<EFBFBD><4C><EFBFBD>A<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̃<EFBFBD><CC83>C<EFBFBD>g<EFBFBD><67><EFBFBD>Ɏ<EFBFBD><C98E>s<EFBFBD>j
|
||
HWI_ModifyLanguage( region );
|
||
|
||
// <20><><EFBFBD>b<EFBFBD>Z<EFBFBD>[<5B>W<EFBFBD><57><EFBFBD><EFBFBD><EFBFBD>莞<EFBFBD>ԕ\<5C><><EFBFBD><EFBFBD><EFBFBD>ď<EFBFBD><C48F><EFBFBD>
|
||
DispMessage( 0, 0, TXT_COLOR_NULL, NULL );
|
||
NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_WHITE,
|
||
MSG_X * 8 , MSG_Y * 8, ( 32 - MSG_X ) * 8, ( MSG_Y + 4 ) * 8 );
|
||
|
||
PrintfSJISSub( 2 * 8, 16 * 8, TXT_COLOR_WHITE, "Region = %s", strRegion[ s_region_old ] );
|
||
PrintfSJISSub( 2 * 8, 16 * 8, TXT_COLOR_BLACK, "Region = %s", strRegion[ LCFG_THW_GetRegion() ] );
|
||
s_region_old = LCFG_THW_GetRegion();
|
||
}
|
||
|
||
// HWInfo<66>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̍폜
|
||
static void DeleteHWInfoFile( void )
|
||
{
|
||
static const u16 *pMsgSecureDeleting = (const u16 *)L"Deteting Secure File...";
|
||
static const u16 *pMsgNormalDeleting = (const u16 *)L"Deleting Normal File...";
|
||
static const u16 *pMsgHWIDSignDeleting = (const u16 *)L"Deteting HWID Sign File.";
|
||
static const u16 *pMsgSucceeded = (const u16 *)L"Succeeded!";
|
||
static const u16 *pMsgFailed = (const u16 *)L"Failed!";
|
||
|
||
// -------------------------------------
|
||
// <20>Z<EFBFBD>L<EFBFBD><4C><EFBFBD>A<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̍폜
|
||
// -------------------------------------
|
||
(void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLACK, pMsgSecureDeleting );
|
||
if( HWI_DeleteHWSecureInfoFile() ) {
|
||
(void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded );
|
||
}else {
|
||
(void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 2 ) * 8, TXT_COLOR_RED, pMsgFailed );
|
||
}
|
||
|
||
// -------------------------------------
|
||
// <20>m<EFBFBD>[<5B>}<7D><><EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̍폜
|
||
// -------------------------------------
|
||
(void)PutStringUTF16( MSG_X * 8, MSG_Y * 8, TXT_COLOR_BLACK, pMsgNormalDeleting );
|
||
if( HWI_DeleteHWNormalInfoFile() ) {
|
||
(void)PutStringUTF16( ( MSG_X + 20 ) * 8, MSG_Y * 8, TXT_COLOR_BLUE, pMsgSucceeded );
|
||
}else {
|
||
(void)PutStringUTF16( ( MSG_X + 20 ) * 8, MSG_Y * 8, TXT_COLOR_RED, pMsgFailed );
|
||
}
|
||
|
||
// -------------------------------------
|
||
// HWID<49><44><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̍폜
|
||
// -------------------------------------
|
||
(void)PutStringUTF16( MSG_X * 8, ( MSG_Y + 4 ) * 8, TXT_COLOR_BLACK, pMsgHWIDSignDeleting );
|
||
if( HWI_DeleteHWIDSignFile() ) {
|
||
(void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 4 ) * 8, TXT_COLOR_BLUE, pMsgSucceeded );
|
||
}else {
|
||
(void)PutStringUTF16( ( MSG_X + 20 ) * 8, ( MSG_Y + 4 ) * 8, TXT_COLOR_RED, pMsgFailed );
|
||
}
|
||
|
||
DispMessage( 0, 0, TXT_COLOR_NULL, NULL );
|
||
NNS_G2dCharCanvasClearArea( &gCanvas, TXT_COLOR_WHITE,
|
||
MSG_X * 8 , MSG_Y * 8, ( 32 - MSG_X ) * 8, ( MSG_Y + 4 ) * 8 );
|
||
}
|
||
|
||
// <20><><EFBFBD>b<EFBFBD>Z<EFBFBD>[<5B>W<EFBFBD>\<5C><>
|
||
static void DispMessage( int x, int y, u16 color, const u16 *pMsg )
|
||
{
|
||
OSTick start = OS_GetTick();
|
||
// <20><><EFBFBD>b<EFBFBD>Z<EFBFBD>[<5B>W<EFBFBD>\<5C><>
|
||
if( pMsg ) {
|
||
(void)PutStringUTF16( x, y, color, pMsg );
|
||
}
|
||
// <20>E<EFBFBD>F<EFBFBD>C<EFBFBD>g
|
||
while( OS_TicksToSeconds( OS_GetTick() - start ) < 2 ) {
|
||
OS_SpinWait( 0x1000 );
|
||
}
|
||
// <20><><EFBFBD>b<EFBFBD>Z<EFBFBD>[<5B>W<EFBFBD><57><EFBFBD><EFBFBD>
|
||
if( pMsg ) {
|
||
(void)PutStringUTF16( x, y, TXT_COLOR_WHITE, pMsg );
|
||
}
|
||
}
|