TwlIPL/build/systemMenu_tools/NandInitializerRed/ARM9.TWL/src/process_font.c
kamikawa df75b3245b 書き込むマイコンファームをSDカードのルートから選択できるようにしました。
その他コード整理。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@1633 b08762b0-b915-fc4b-9d8c-17b2551a87ff
2008-06-16 07:07:43 +00:00

284 lines
7.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

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: TwlSDK - NandInitializer
File: process_font.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$
*---------------------------------------------------------------------------*/
#ifdef USE_WRITE_FONT_DATA
#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_font.h"
#include "process_auto.h"
#include "process_fade.h"
#include "cursor.h"
#include "keypad.h"
/*---------------------------------------------------------------------------*
Œ^’è‹`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
è<E28099>è`
*---------------------------------------------------------------------------*/
#define NUM_OF_MENU_SELECT 2
#define DOT_OF_MENU_SPACE 16
#define CURSOR_ORIGIN_X 32
#define CURSOR_ORIGIN_Y 56
#define ROUND_UP(value, alignment) \
(((u32)(value) + (alignment-1)) & ~(alignment-1))
/*---------------------------------------------------------------------------*
“à•”•Ï<E280A2>è`
*---------------------------------------------------------------------------*/
static s8 sMenuSelectNo;
/*---------------------------------------------------------------------------*
“à•”ŠÖ<C5A0><EFBFBD>錾
*---------------------------------------------------------------------------*/
static BOOL WriteFontData(void);
/*---------------------------------------------------------------------------*
ƒvƒ<76>ƒZƒXŠÖ<C5A0>è`
*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*
Name: font ƒvƒ<76>ƒZƒXO
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* fontProcess0(void)
{
int i;
// •¶Žš—ñSƒNƒŠƒA
kamiFontClear();
// ƒo<C692>[ƒWƒ‡ƒ“•\ަ
kamiFontPrintf(2, 1, FONT_COLOR_BLACK, "Write Font Data");
kamiFontPrintf(0, 2, FONT_COLOR_BLACK, "--------------------------------");
// ƒ<>ƒjƒ…<C692>[ˆê——
kamiFontPrintf(3, 6, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 7, FONT_COLOR_BLACK, "l WRITE FONT DATA l l");
kamiFontPrintf(3, 8, FONT_COLOR_BLACK, "+-------------------+-----+");
kamiFontPrintf(3, 9, FONT_COLOR_BLACK, "l RETURN l l");
kamiFontPrintf(3, 10, FONT_COLOR_BLACK, "+-------------------+-----+");
// ”wŒiSƒNƒŠƒA
for (i=0;i<24;i++)
{
kamiFontFillChar( i, BG_COLOR_TRANS, BG_COLOR_TRANS );
}
// ”wŒi<C592>ã•”
kamiFontFillChar( 0, BG_COLOR_BROWN, BG_COLOR_BROWN );
kamiFontFillChar( 1, BG_COLOR_BROWN, BG_COLOR_BROWN );
kamiFontFillChar( 2, BG_COLOR_BROWN, BG_COLOR_TRANS );
// ƒJ<C692>[ƒ\ƒ<C692>ÁŽ
SetCursorPos((u16)200, (u16)200);
FADE_IN_RETURN( fontProcess1 );
}
/*---------------------------------------------------------------------------*
Name: font ƒvƒ<76>ƒZƒXP
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* fontProcess1(void)
{
#ifndef NAND_INITIALIZER_LIMITED_MODE
// ƒI<C692>[ƒgŽÀ<C5BD>s—p
if (gAutoFlag)
{
sMenuSelectNo = 0;
return fontProcess2;
}
#endif
// 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>[ƒ\ƒ”zu
SetCursorPos((u16)CURSOR_ORIGIN_X, (u16)(CURSOR_ORIGIN_Y + sMenuSelectNo * DOT_OF_MENU_SPACE));
// Œˆ’è
if (kamiPadIsTrigger(PAD_BUTTON_A))
{
return fontProcess2;
}
// ƒgƒbƒvƒ<76>ƒjƒ…<C692>[‚Ö–ß‚é
else if (kamiPadIsTrigger(PAD_BUTTON_B))
{
FADE_OUT_RETURN( TopmenuProcess0 );
}
return fontProcess1;
}
/*---------------------------------------------------------------------------*
Name: font ƒvƒ<76>ƒZƒXQ
Description:
Arguments: None.
Returns: next sequence
*---------------------------------------------------------------------------*/
void* fontProcess2(void)
{
BOOL result;
switch( sMenuSelectNo )
{
case 0:
result = WriteFontData();
if (result)
{
kamiFontPrintf(25, 7, FONT_COLOR_GREEN, "OK");
}
else
{
kamiFontPrintf(25, 7, FONT_COLOR_RED, "NG");
}
break;
case 1:
FADE_OUT_RETURN( TopmenuProcess0 );
}
#ifndef NAND_INITIALIZER_LIMITED_MODE
// Auto—p
if (gAutoFlag)
{
if (result)
{
gAutoProcessResult[AUTO_PROCESS_MENU_FONT_DATA] = AUTO_PROCESS_RESULT_SUCCESS;
FADE_OUT_RETURN( AutoProcess1 );
}
else
{
gAutoProcessResult[AUTO_PROCESS_MENU_FONT_DATA] = AUTO_PROCESS_RESULT_FAILURE;
FADE_OUT_RETURN( AutoProcess2);
}
}
#endif
return fontProcess1;
}
/*---------------------------------------------------------------------------*
<20>ˆ<CB86>ŠÖ<C5A0>è`
*---------------------------------------------------------------------------*/
static BOOL WriteFontData(void)
{
FSFile file;
BOOL open_is_ok;
BOOL read_is_ok;
void* pTempBuf;
u32 file_size;
u32 alloc_size;
BOOL result = TRUE;
// ROMƒtƒ@ƒCƒƒI<C692>[ƒvƒ“
FS_InitFile(&file);
open_is_ok = FS_OpenFile(&file, FONT_DATA_FILE_PATH_IN_ROM);
if (!open_is_ok)
{
OS_Printf("FS_OpenFile(\"%s\") ... ERROR!\n", FONT_DATA_FILE_PATH_IN_ROM);
return FALSE;
}
// ROMƒtƒ@ƒCƒƒŠ<C692>[ƒh
file_size = FS_GetFileLength(&file) ;
alloc_size = ROUND_UP(file_size, 32) ;
pTempBuf = OS_Alloc( alloc_size );
SDK_NULL_ASSERT(pTempBuf);
DC_InvalidateRange(pTempBuf, alloc_size);
read_is_ok = FS_ReadFile( &file, pTempBuf, (s32)file_size );
if (!read_is_ok)
{
kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_ReadFile(\"%s\") ... ERROR!\n", FONT_DATA_FILE_PATH_IN_ROM);
FS_CloseFile(&file);
OS_Free(pTempBuf);
return FALSE;
}
// ROMƒtƒ@ƒCƒƒNƒ<4E><C692>[ƒY
FS_CloseFile(&file);
// ˆêUƒtƒHƒ“ƒgƒf<C692>[ƒ^ð<E2809A>í<EFBFBD>œ·é
(void)FS_DeleteFile(FONT_DATA_FILE_PATH_IN_NAND);
// nand:sys/TWLFontTable.dat<61>ì<EFBFBD>¬
if (!FS_CreateFile(FONT_DATA_FILE_PATH_IN_NAND, FS_PERMIT_R | FS_PERMIT_W))
{
kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_CreateFile(%s) failed.\n", FONT_DATA_FILE_PATH_IN_NAND);
result = FALSE;
}
else
{
// nand:sys/TWLFontTable.datƒI<C692>[ƒvƒ“
FS_InitFile(&file);
open_is_ok = FS_OpenFileEx(&file, FONT_DATA_FILE_PATH_IN_NAND, FS_FILEMODE_W);
if (!open_is_ok)
{
kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_OpenFile(%s) failed.\n", FONT_DATA_FILE_PATH_IN_NAND);
result = FALSE;
}
// nand:sys/TWLFontTable.dat<61>«<E2809A>žÝ
else if (FS_WriteFile(&file, pTempBuf, (s32)file_size) == -1)
{
kamiFontPrintfConsoleEx(CONSOLE_RED, "FS_WritFile() failed.\n");
result = FALSE;
}
(void)FS_CloseFile(&file);
}
OS_Free(pTempBuf);
return result;
}
#endif // USE_WRITE_FONT_DATA