mirror of
https://github.com/rvtr/TwlIPL.git
synced 2025-10-31 06:01:12 -04:00
・systemMenu_RED内の各タイトルが使用しているmisc.h, misc.c
を独立したフォルダ"misc"に配置して、皆がそれを組み込むよう変更。 ・hyena.TWLコンポーネントでマイコンにセットするホットスタート判定を追加。 ・systemMenuメモリマップのシステム領域クリア部分の変更。 git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@178 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
parent
9f8a558f2c
commit
8d101b1842
@ -33,8 +33,9 @@
|
||||
#include <twl/os/ARM7/codecmode.h>
|
||||
#include <twl/cdc.h>
|
||||
#include <twl/aes.h>
|
||||
#include "nvram_sp.h"
|
||||
#include <twl/mcu.h>
|
||||
#include <sysmenu/boot/common/boot.h>
|
||||
#include <sysmenu/sysmenu_work.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
定数定義
|
||||
@ -81,7 +82,17 @@ TwlSpMain(void)
|
||||
// OS 初期化
|
||||
OS_Init();
|
||||
PrintDebugInfo();
|
||||
|
||||
|
||||
// Cold/Hotスタート判定
|
||||
if( *(vu32 *)HW_RESET_PARAMETER_BUF == 0 ) { // NANDファームが毎回このバッファにマイコンフリーレジスタ値をセットしてくれる
|
||||
u32 data = 1;
|
||||
MCU_SetFreeRegisters( 0, (u8 *)&data, 4 ); // マイコンフリーレジスタにホットスタートフラグをセット
|
||||
SYSM_GetWork()->isHotStart = FALSE;
|
||||
}else {
|
||||
SYSM_GetWork()->isHotStart = TRUE;
|
||||
}
|
||||
SYSM_GetWork()->isARM9Start = TRUE; // ※HW_RED_RESERVEDはNANDファームでクリアしておいて欲しい
|
||||
|
||||
// ヒープ領域設定
|
||||
{
|
||||
void *wram = OS_GetWramSubPrivArenaHi();
|
||||
|
||||
@ -80,6 +80,8 @@ static void BOOTi_ClearREG_RAM( void )
|
||||
reg_SPI_SPICNT = 0;
|
||||
reg_PXI_MAINP_FIFO_CNT = 0x4008;
|
||||
|
||||
*(vu32 *)HW_RESET_PARAMETER_BUF = 0; // リセットバッファをクリア
|
||||
|
||||
// クリアしていないレジスタは、VCOUNT, JOY, PIFCNT, MC-, EXMEMCNT, IME, PAUSE, POWLCDCNT, 他セキュリティ系です。
|
||||
(void)OS_ResetRequestIrqMask((u16)~0);
|
||||
}
|
||||
|
||||
@ -16,9 +16,10 @@
|
||||
# $Author: $
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
SUBDIRS = ../../../libraries_sysmenu/sysmenu \
|
||||
../../../libraries_sysmenu/boot \
|
||||
../../../components/hyena.TWL
|
||||
SUBDIRS = \
|
||||
# ../../../libraries_sysmenu/sysmenu \
|
||||
# ../../../libraries_sysmenu/boot \
|
||||
# ../../../components/hyena.TWL
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
@ -26,21 +27,24 @@ TARGET_FIRM = SYSTEMMENU
|
||||
TARGET_PLATFORM = TWL
|
||||
TWL_ARCHGEN = LIMITED
|
||||
|
||||
TITLEID_LO = LNCR
|
||||
TARGET_WAD = $(BINDIR)/$(TITLEID_LO).wad
|
||||
|
||||
TARGET_BIN = main.srl
|
||||
|
||||
LCFILE_SPEC = ARM9-TS.lsf
|
||||
ROM_SPEC = main.rsf
|
||||
|
||||
LOGO_DIR = Logo
|
||||
MISC_DIR = ../../misc
|
||||
|
||||
SRCS_LOGO = logoDemo.c logoData.c
|
||||
SRCS = main.c launcher.c misc.c $(addprefix $(LOGO_DIR)/, $(SRCS_LOGO))
|
||||
#SRCS_OVERLAY =
|
||||
SRCS = main.c launcher.c \
|
||||
$(addprefix $(LOGO_DIR)/, $(SRCS_LOGO)) \
|
||||
$(MISC_DIR)/src/misc.c
|
||||
|
||||
LINCLUDES = $(SRCDIR)/$(LOGO_DIR)
|
||||
#LLIBRARY_DIRS =
|
||||
#LLIBRARIES =
|
||||
#LDEPENDS_NEF =
|
||||
LINCLUDES = $(MISC_DIR)/include \
|
||||
$(SRCDIR)/$(LOGO_DIR)
|
||||
|
||||
LLIBRARIES += libnam$(TWL_LIBSUFFIX).a \
|
||||
libese$(TWL_LIBSUFFIX).a
|
||||
@ -50,11 +54,15 @@ ADDRESS_DTCM = 0x0e000000
|
||||
DEFAULT_COMP_ARM7 = hyena
|
||||
DEFAULT_MAKEROM_ARM7_BASE = $(TWLIPL_ROOT)/components/$(DEFAULT_COMP_ARM7)/$(TWL_BUILDTYPE_ARM7)/$(DEFAULT_COMP_ARM7)
|
||||
|
||||
MAKEROM_FLAGS += -F
|
||||
MAKEROM_FLAGS += -F
|
||||
|
||||
include $(TWLIPL_ROOT)/build/buildtools/commondefs
|
||||
|
||||
MAKELCF_FLAGS += -DADDRESS_BOOTCORE='0x02e7fc00'
|
||||
MAKELCF_FLAGS += -DADDRESS_BOOTCORE='0x02e7fc00'
|
||||
|
||||
LDIRT_CLEAN = $(TARGET_WAD)
|
||||
INSTALL_TARGETS = $(TARGET_WAD)
|
||||
INSTALL_DIR = $(SDK_NMENU_DATADIR)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -38,6 +38,9 @@ static void DrawBackLightSwitch(void);
|
||||
static void DrawLauncher(u16 nowCsr, const MenuParam *pMenu);
|
||||
|
||||
// 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 int s_csr = 0; // メニューのカーソル位置
|
||||
@ -267,7 +270,7 @@ void LauncherInit( TitleProperty *pTitleList )
|
||||
|
||||
SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 );
|
||||
|
||||
InitGetAndDrawRtcData( RTC_DATE_TOP_X, RTC_DATE_TOP_Y, RTC_TIME_TOP_X, RTC_TIME_TOP_Y );
|
||||
GetAndDrawRTCData( &g_rtcDraw, TRUE );
|
||||
|
||||
GX_SetVisiblePlane( GX_PLANEMASK_BG0 );
|
||||
GX_DispOn();
|
||||
@ -295,14 +298,14 @@ TitleProperty *LauncherMain( TitleProperty *pTitleList )
|
||||
DrawBackLightSwitch();
|
||||
|
||||
// RTC情報の取得&表示
|
||||
GetAndDrawRtcData();
|
||||
GetAndDrawRTCData( &g_rtcDraw, FALSE );
|
||||
|
||||
//--------------------------------------
|
||||
// バックライトON,OFF制御
|
||||
//--------------------------------------
|
||||
if(tpd.disp.touch) {
|
||||
BOOL range = InRangeTp( B_LIGHT_BUTTON_TOP_X*8, B_LIGHT_BUTTON_TOP_Y*8-4,
|
||||
B_LIGHT_BUTTON_BOTTOM_X*8, B_LIGHT_BUTTON_BOTTOM_Y*8-4, &tpd.disp );
|
||||
BOOL range = WithinRangeTP( B_LIGHT_BUTTON_TOP_X * 8, B_LIGHT_BUTTON_TOP_Y * 8 - 4,
|
||||
B_LIGHT_BUTTON_BOTTOM_X * 8, B_LIGHT_BUTTON_BOTTOM_Y * 8 - 4, &tpd.disp );
|
||||
if( range && !touch_bl ) {
|
||||
touch_bl = TRUE;
|
||||
tp_bl_on_off = TRUE;
|
||||
|
||||
@ -25,13 +25,10 @@
|
||||
// define data-----------------------------------------------------------------
|
||||
|
||||
// function's prototype-------------------------------------------------------
|
||||
static void InitAllocator( NNSFndAllocator* pAllocator );
|
||||
static void InitAllocSystem( void );
|
||||
static BOOL CheckBootStatus( void );
|
||||
static void INTR_VBlank( void );
|
||||
|
||||
// global variable-------------------------------------------------------------
|
||||
NNSFndAllocator g_allocator;
|
||||
|
||||
// static variable-------------------------------------------------------------
|
||||
|
||||
@ -74,12 +71,10 @@ void TwlMain( void )
|
||||
(void)GX_VBlankIntr(TRUE);
|
||||
|
||||
// システムの初期化----------------
|
||||
InitAllocator( &g_allocator );
|
||||
CMN_InitFileSystem( &g_allocator );
|
||||
InitAllocator();
|
||||
|
||||
// 各種パラメータの取得--------
|
||||
SYSM_ReadParameters();
|
||||
|
||||
// リセットパラメータの取得--------
|
||||
if( SYSM_GetResetParam()->flags.isLogoSkip ) {
|
||||
if( SYSM_GetResetParam()->bootTitleID ) { // アプリ直接起動の指定があったらロゴデモを飛ばして指定アプリ起動
|
||||
pBootTitle = (TitleProperty *)SYSM_GetResetParam();
|
||||
@ -102,7 +97,7 @@ void TwlMain( void )
|
||||
OS_WaitIrq(1, OS_IE_V_BLANK); // Vブランク割り込み待ち
|
||||
|
||||
ReadKeyPad(); // キー入力の取得
|
||||
ReadTpData(); // TP入力の取得
|
||||
ReadTP(); // TP入力の取得
|
||||
|
||||
(void)SYSM_GetCardTitleList( pTitleList ); // カードアプリリストの取得(スレッドで随時カード挿抜を通知されるものをメインループで取得)
|
||||
|
||||
@ -144,37 +139,6 @@ void TwlMain( void )
|
||||
}
|
||||
|
||||
|
||||
// アロケータの初期化
|
||||
static void InitAllocator( NNSFndAllocator* pAllocator )
|
||||
{
|
||||
u32 arenaLow = MATH_ROUNDUP ((u32)OS_GetMainArenaLo(), 16);
|
||||
u32 arenaHigh = MATH_ROUNDDOWN((u32)OS_GetMainArenaHi(), 16);
|
||||
u32 heapSize = arenaHigh - arenaLow;
|
||||
void* heapMemory = OS_AllocFromMainArenaLo(heapSize, 16);
|
||||
NNSFndHeapHandle heapHandle;
|
||||
SDK_NULL_ASSERT( pAllocator );
|
||||
|
||||
heapHandle = NNS_FndCreateExpHeap(heapMemory, heapSize);
|
||||
SDK_ASSERT( heapHandle != NNS_FND_HEAP_INVALID_HANDLE );
|
||||
|
||||
NNS_FndInitAllocatorForExpHeap(pAllocator, heapHandle, 32);
|
||||
}
|
||||
|
||||
|
||||
// メモリ割り当て
|
||||
void *Alloc( u32 size )
|
||||
{
|
||||
return NNS_FndAllocFromAllocator( &g_allocator, size );
|
||||
}
|
||||
|
||||
|
||||
// メモリ解放
|
||||
void Free( void *pBuffer )
|
||||
{
|
||||
NNS_FndFreeToAllocator( &g_allocator, pBuffer );
|
||||
}
|
||||
|
||||
|
||||
// ブート状態を確認し、ロゴ表示有無を判断する-------
|
||||
static BOOL CheckBootStatus(void)
|
||||
{
|
||||
|
||||
@ -1,156 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlIPL
|
||||
File: misc.h
|
||||
|
||||
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$
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __MISC_H__
|
||||
#define __MISC_H__
|
||||
|
||||
#include <twl.h>
|
||||
#include <sysmenu.h>
|
||||
|
||||
#define NNS_G2D_UNICODE
|
||||
#include <nnsys.h>
|
||||
#include <nnsys/g2d/g2d_Font.h>
|
||||
#include <nnsys/g2d/g2d_CharCanvas.h>
|
||||
#include <nnsys/g2d/g2d_TextCanvas.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// define data----------------------------------------------------------
|
||||
#define TP_CSR_TOUCH_COUNT 2 // TPカーソルのチャタリング吸収のためのカウント値
|
||||
#define TP_CSR_DETACH_COUNT 2 // TPカーソルを「選択」と判定するTPデタッチからのカウント値
|
||||
|
||||
// DrawText での左上寄せ
|
||||
#define TXT_DRAWTEXT_FLAG_DEFAULT (NNS_G2D_VERTICALORIGIN_TOP | NNS_G2D_HORIZONTALORIGIN_LEFT | NNS_G2D_HORIZONTALALIGN_LEFT)
|
||||
|
||||
// TXTColorPalette の色名 16色パレットへのロードを想定
|
||||
enum
|
||||
{
|
||||
// パレット0 TXT_CPALETTE_MAIN
|
||||
TXT_COLOR_NULL=0,
|
||||
TXT_COLOR_WHITE,
|
||||
TXT_COLOR_BLACK,
|
||||
TXT_COLOR_RED,
|
||||
TXT_COLOR_GREEN,
|
||||
TXT_COLOR_BLUE,
|
||||
TXT_COLOR_CYAN,
|
||||
TXT_COLOR_MAGENTA,
|
||||
TXT_COLOR_YELLOW,
|
||||
|
||||
// パレット1 TXT_CPALETTE_USERCOLOR
|
||||
TXT_UCOLOR_NULL=0,
|
||||
TXT_UCOLOR_GRAY,
|
||||
TXT_UCOLOR_BROWN,
|
||||
TXT_UCOLOR_RED,
|
||||
TXT_UCOLOR_PINK,
|
||||
TXT_UCOLOR_ORANGE,
|
||||
TXT_UCOLOR_YELLOW,
|
||||
TXT_UCOLOR_LIMEGREEN,
|
||||
TXT_UCOLOR_DARKGREEN,
|
||||
TXT_UCOLOR_SEAGREEN,
|
||||
TXT_UCOLOR_TURQUOISE,
|
||||
TXT_UCOLOR_BLUE,
|
||||
TXT_UCOLOR_DARKBLUE,
|
||||
TXT_UCOLOR_PURPLE,
|
||||
TXT_UCOLOR_VIOLET,
|
||||
TXT_UCOLOR_MAGENTA,
|
||||
|
||||
// パレット TXT_CPALETTE_4BPP
|
||||
TXT_COLOR_4BPP_NULL=0,
|
||||
TXT_COLOR_4BPP_BG=1,
|
||||
TXT_COLOR_4BPP_TEXT=1
|
||||
};
|
||||
|
||||
|
||||
// 時計表示場所
|
||||
#define RTC_DATE_TOP_X ( 9 * 8 )
|
||||
#define RTC_DATE_TOP_Y ( 10 * 8 )
|
||||
#define RTC_TIME_TOP_X ( 12 * 8 )
|
||||
#define RTC_TIME_TOP_Y ( 12 * 8 )
|
||||
|
||||
|
||||
// キーデータワーク
|
||||
typedef struct {
|
||||
u16 trg; // トリガ入力
|
||||
u16 cont; // ベタ 入力
|
||||
}KeyWork;
|
||||
|
||||
|
||||
// タッチパネルワーク
|
||||
typedef struct {
|
||||
int detached; // 今回のデータ入力でタッチが離れたことを示す。
|
||||
TPData disp; // 今回の入力値(LCD座標)
|
||||
TPData raw; // 今回の入力値(TP 座標)
|
||||
TPData last; // 前回の入力値(LCD座標)
|
||||
}TpWork;
|
||||
|
||||
|
||||
// メニュー要素座標
|
||||
typedef struct MenuPos {
|
||||
BOOL enable;
|
||||
int x;
|
||||
int y;
|
||||
}MenuPos;
|
||||
|
||||
|
||||
// メニュー構成パラメータ構造体
|
||||
typedef struct MenuParam {
|
||||
int num;
|
||||
int normal_color;
|
||||
int select_color;
|
||||
int disable_color;
|
||||
MenuPos *pos;
|
||||
const u16 **str_elem;
|
||||
}MenuParam;
|
||||
|
||||
|
||||
// global variables--------------------------------------------------
|
||||
extern TpWork tpd; // タッチパネルデータ
|
||||
extern KeyWork pad; // キーパッド入力データ
|
||||
extern const u8 *const g_strWeek[ 7 ]; // 曜日文字列
|
||||
|
||||
extern NNSFndAllocator g_allocator; // メモリアロケータ
|
||||
extern NNSG2dFont gFont; // フォント
|
||||
extern NNSG2dCharCanvas gCanvas; // CharCanvas
|
||||
extern NNSG2dTextCanvas gTextCanvas; // TextCanvas
|
||||
|
||||
// function-------------------------------------------------------------
|
||||
void *Alloc( u32 size );
|
||||
void Free( void *pBuffer );
|
||||
|
||||
void InitBG( void );
|
||||
void PutStringUTF16 ( int x, int y, int color, const u16 *strUTF16 );
|
||||
void PutStringUTF16Sub( int x, int y, int color, const u16 *strUTF16 );
|
||||
void PrintfSJIS ( int x, int y, int color, const char *fmt, ... );
|
||||
void PrintfSJISSub( int x, int y, int color, const char *fmt, ... );
|
||||
void ReadKeyPad( void );
|
||||
void ReadTpData( void );
|
||||
BOOL WaitDetachTP( void );
|
||||
void StartDetachTP( void );
|
||||
void DrawMenu( u16 nowCsr, const MenuParam *pMenu );
|
||||
BOOL SelectMenuByTP( u16 *nowCsr, const MenuParam *pMenu );
|
||||
BOOL InRangeTp( int top_x, int top_y, int bottom_x, int bottom_y, TPData *tgt );
|
||||
void InitGetAndDrawRtcData( int drawDatePos_x, int drawDatePos_y, int drawTimePos_x, int drawTimePos_y );
|
||||
void GetAndDrawRtcData( void );
|
||||
void SetBannerIconOBJ( GXOamAttr *pDstOAM, BannerFileV1 *bannerp );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __MISC_H__
|
||||
@ -31,8 +31,13 @@ TARGET_BIN = main.srl
|
||||
|
||||
ROM_SPEC = main.rsf
|
||||
|
||||
SRCS = main.c misc.c \
|
||||
MachineSetting.c setRTC.c selectLanguage.c calibrationTP.c setOwnerInfo.c
|
||||
MISC_DIR = ../../misc
|
||||
|
||||
SRCS = main.c MachineSetting.c \
|
||||
setRTC.c selectLanguage.c calibrationTP.c setOwnerInfo.c \
|
||||
$(MISC_DIR)/src/misc.c
|
||||
|
||||
LINCLUDES = $(MISC_DIR)/include
|
||||
|
||||
|
||||
include $(TWLIPL_ROOT)/build/buildtools/commondefs
|
||||
|
||||
@ -65,16 +65,16 @@ void TwlMain(void)
|
||||
|
||||
// システムの初期化------------------
|
||||
InitAllocator();
|
||||
SYSM_SetAllocFunc( Alloc, Free );
|
||||
|
||||
// ※本来ならランチャーからのパラメータチェックを行い、
|
||||
// 初回起動シーケンスに入るパスがある
|
||||
|
||||
// TWL設定のリード
|
||||
SYSM_SetAllocFunc( Alloc, Free ); // SYSM_ReadTWLSettingsFile()の実行に必要。
|
||||
if( SYSM_ReadTWLSettingsFile() ) {
|
||||
SYSM_CaribrateTP();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
// ファイルシステム切り替え応急処置
|
||||
FS_IdentifyTitle(0x4d534554);//MSET
|
||||
|
||||
@ -1,770 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TwlIPL
|
||||
File: misc.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 "misc.h"
|
||||
|
||||
// define data-----------------------------------------------------------------
|
||||
#define NTR_IPL_FONT_DATA "data/NTR_IPL_font_m.NFTR"
|
||||
|
||||
#define STRING_LENGTH_MAX 256
|
||||
|
||||
#define GRAY(x) GX_RGB(x, x, x)
|
||||
|
||||
enum
|
||||
{
|
||||
TXT_CPALETTE_MAIN,
|
||||
TXT_CPALETTE_USERCOLOR,
|
||||
TXT_CPALETTE_USERCOLORSAMPLE1,
|
||||
TXT_CPALETTE_USERCOLORSAMPLE2,
|
||||
TXT_CPALETTE_4BPP,
|
||||
TXT_NUM_CPALEETE
|
||||
};
|
||||
|
||||
// デモ共通のカラーパレット
|
||||
GXRgb TXTColorPalette[TXT_NUM_CPALEETE * 16] =
|
||||
{
|
||||
GX_RGB(31, 31, 31), GX_RGB(31, 31, 31), GX_RGB( 0, 0, 0), GX_RGB(31, 0, 0),// 基本文字色
|
||||
GX_RGB( 0, 31, 0), GX_RGB( 0, 0, 31), GX_RGB( 0, 31, 31), GX_RGB(31, 0, 31),
|
||||
GX_RGB(31, 31, 0), GX_RGB( 0, 0, 0), GX_RGB( 0, 0, 0), GX_RGB( 0, 0, 0),
|
||||
GX_RGB( 0, 0, 0), GX_RGB( 0, 0, 0), GX_RGB( 0, 0, 0), GX_RGB( 0, 0, 0),
|
||||
|
||||
GX_RGB( 0, 0, 0), GX_RGB(12, 16, 19), GX_RGB(23, 9, 0), GX_RGB(31, 0, 3),// ユーザーカラー領域
|
||||
GX_RGB(31, 17, 31), GX_RGB(31, 18, 0), GX_RGB(30, 28, 0), GX_RGB(21, 31, 0),
|
||||
GX_RGB( 0, 20, 7), GX_RGB( 9, 27, 17), GX_RGB( 6, 23, 30), GX_RGB( 0, 11, 30),
|
||||
GX_RGB( 0, 0, 18), GX_RGB(17, 0, 26), GX_RGB(26, 0, 29), GX_RGB(31, 0, 18),
|
||||
|
||||
GX_RGB( 0, 0, 0), GX_RGB(12, 16, 19), GX_RGB(23, 9, 0), GX_RGB(31, 0, 3),// ユーザーカラーのサンプル領域2
|
||||
GX_RGB(31, 17, 31), GX_RGB(31, 18, 0), GX_RGB(30, 28, 0), GX_RGB(21, 31, 0),
|
||||
GX_RGB(12, 16, 19), GX_RGB(23, 9, 0), GX_RGB(31, 0, 3), GX_RGB(31, 17, 31),
|
||||
GX_RGB(31, 18, 0), GX_RGB(30, 28, 0), GX_RGB(21, 31, 0), GX_RGB( 0, 31, 0),
|
||||
|
||||
GX_RGB( 0, 0, 0), GX_RGB(12, 16, 19), GX_RGB(23, 9, 0), GX_RGB(31, 0, 3),// ユーザーカラーのサンプル領域1
|
||||
GX_RGB(31, 17, 31), GX_RGB(31, 18, 0), GX_RGB(30, 28, 0), GX_RGB(21, 31, 0),
|
||||
GX_RGB( 0, 20, 7), GX_RGB( 9, 27, 17), GX_RGB( 6, 23, 30), GX_RGB( 0, 11, 30),
|
||||
GX_RGB( 0, 0, 18), GX_RGB(17, 0, 26), GX_RGB(26, 0, 29), GX_RGB(31, 0, 18),
|
||||
|
||||
GRAY(31), GRAY(29), GRAY(27), GRAY(25),
|
||||
GRAY(23), GRAY(21), GRAY(19), GRAY(17),
|
||||
GRAY(15), GRAY(14), GRAY(12), GRAY(10),
|
||||
GRAY( 8), GRAY( 6), GRAY( 3), GRAY( 0),
|
||||
};
|
||||
|
||||
// グラデパレットを作るためのマクロ
|
||||
#define MAKECOLOR(r,g,b) GX_RGB( 0, 0, 0), GX_RGB(r, g, b), MC(r,g,b,1), MC(r,g,b,2),\
|
||||
MC(r,g,b,3), MC(r,g,b,4), MC(r,g,b,5), MC(r,g,b,6),\
|
||||
MC(r,g,b,7), MC(r,g,b,8), MC(r,g,b,9), MC(r,g,b,10),\
|
||||
MC(r,g,b,11), MC(r,g,b,12), MC(r,g,b,13), GX_RGB(31, 31, 31)
|
||||
|
||||
#define MC(r,g,b,i) GX_RGB(r+((31-r)*i)/14, g+((31-g)*i)/14, b+((31-b)*i)/14)
|
||||
|
||||
// ユーザーカラーパレット切り替え用
|
||||
GXRgb TempPalette[16 * 16] =
|
||||
{
|
||||
MAKECOLOR(12, 16, 19),
|
||||
MAKECOLOR(23, 9, 0),
|
||||
MAKECOLOR(31, 0, 3),
|
||||
MAKECOLOR(31, 17, 31),
|
||||
MAKECOLOR(31, 18, 0),
|
||||
MAKECOLOR(30, 28, 0),
|
||||
MAKECOLOR(21, 31, 0),
|
||||
MAKECOLOR( 0, 31, 0),
|
||||
MAKECOLOR( 0, 20, 7),
|
||||
MAKECOLOR( 9, 27, 17),
|
||||
MAKECOLOR( 6, 23, 30),
|
||||
MAKECOLOR( 0, 11, 30),
|
||||
MAKECOLOR( 0, 0, 18),
|
||||
MAKECOLOR(17, 0, 26),
|
||||
MAKECOLOR(26, 0, 29),
|
||||
MAKECOLOR(31, 0, 18),
|
||||
};
|
||||
|
||||
// BGキャラクタ
|
||||
const unsigned int bg_char_data[16 * 3] = {
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,// 0000h
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x11111111, 0x44444444, 0x77777777, 0x99999999,// 0001h
|
||||
0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc, 0xcccccccc,
|
||||
0xdddddddd, 0xdddddddd, 0xdddddddd, 0xeeeeeeee,// 0002h
|
||||
0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee,
|
||||
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,// 0003h
|
||||
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
|
||||
};
|
||||
|
||||
// extern data-----------------------------------------------------------------
|
||||
|
||||
// define data-----------------------------------------------------------------
|
||||
#define CANVAS_WIDTH 32 // 文字描画域の幅 (キャラクタ単位)
|
||||
#define CANVAS_HEIGHT 24 // 文字描画域の高さ (キャラクタ単位)
|
||||
#define CANVAS_LEFT 0 // 文字描画域の位置X (キャラクタ単位)
|
||||
#define CANVAS_TOP 0 // 文字描画域の位置Y (キャラクタ単位)
|
||||
|
||||
#define TEXT_HSPACE 1 // 文字列描画時の文字間 (ピクセル単位)
|
||||
#define TEXT_VSPACE 1 // 文字列描画時の行間 (ピクセル単位)
|
||||
|
||||
#define CHARACTER_OFFSET 0 // 使用するキャラクタ列の開始番号
|
||||
|
||||
// RTCデータ表示位置ワーク
|
||||
typedef struct RtcDrawPos{
|
||||
int date_x;
|
||||
int date_y;
|
||||
int time_x;
|
||||
int time_y;
|
||||
}RtcDrawPos;
|
||||
|
||||
// function's prototype-------------------------------------------------------
|
||||
static BOOL WaitDetachTP( void );
|
||||
static void StartDetachTP( void );
|
||||
static void InitScreen( void );
|
||||
static void InitCanvas( void );
|
||||
|
||||
// global variable-------------------------------------------------------------
|
||||
KeyWork pad; // キーパッド入力データ
|
||||
TpWork tpd; // タッチパネル入力データ
|
||||
NNSFndAllocator g_allocator; // メモリアロケータ
|
||||
NNSG2dFont gFont; // フォント
|
||||
NNSG2dCharCanvas gCanvas; // CharCanvas
|
||||
NNSG2dTextCanvas gTextCanvas; // TextCanvas
|
||||
NNSG2dCharCanvas gCanvasSub; // CharCanvas
|
||||
NNSG2dTextCanvas gTextCanvasSub; // TextCanvas
|
||||
|
||||
// static variable-------------------------------------------------------------
|
||||
static int s_detach_count;
|
||||
static RtcDrawPos s_rtcPos;
|
||||
static RTCDate s_rtcDate;
|
||||
static RTCTime s_rtcTime;
|
||||
static u16 s_vcount;
|
||||
|
||||
|
||||
static const u16 sScrnBuf[32 * 32]=
|
||||
{
|
||||
0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,//0
|
||||
0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,0x1001,
|
||||
0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,//1
|
||||
0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,0x1002,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//2
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//3
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//4
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//5
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//6
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//7
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//8
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//9
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//10
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//11
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//12
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//13
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//14
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//15
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//16
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//17
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//18
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//19
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//20
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,//21
|
||||
0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,0x1003,
|
||||
0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,//22
|
||||
0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,0x1802,
|
||||
0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,//23
|
||||
0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,0x1801,
|
||||
};// Buffer for screen data(背景の枠)
|
||||
|
||||
static char s_strBuffer[ STRING_LENGTH_MAX * 2 ] ATTRIBUTE_ALIGN(2);
|
||||
static u16 s_strBufferUTF16[ STRING_LENGTH_MAX ];
|
||||
|
||||
// const data------------------------------------------------------------------
|
||||
|
||||
// 曜日データ表示用文字コード
|
||||
const u8 *const g_strWeek[] ATTRIBUTE_ALIGN(2) = {
|
||||
(const u8 *)"SUN",
|
||||
(const u8 *)"MON",
|
||||
(const u8 *)"TUE",
|
||||
(const u8 *)"WED",
|
||||
(const u8 *)"THU",
|
||||
(const u8 *)"FRI",
|
||||
(const u8 *)"SAT",
|
||||
};
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// メモリ管理
|
||||
// ============================================================================
|
||||
|
||||
// アロケータの初期化
|
||||
void InitAllocator( void )
|
||||
{
|
||||
NNSFndAllocator *pAllocator = &g_allocator;
|
||||
u32 arenaLow = MATH_ROUNDUP ( (u32)OS_GetMainArenaLo(), 16 );
|
||||
u32 arenaHigh = MATH_ROUNDDOWN( (u32)OS_GetMainArenaHi(), 16 );
|
||||
u32 heapSize = arenaHigh - arenaLow;
|
||||
void* heapMemory = OS_AllocFromMainArenaLo( heapSize, 16 );
|
||||
NNSFndHeapHandle heapHandle;
|
||||
SDK_NULL_ASSERT( pAllocator );
|
||||
|
||||
heapHandle = NNS_FndCreateExpHeap( heapMemory, heapSize );
|
||||
SDK_ASSERT( heapHandle != NNS_FND_HEAP_INVALID_HANDLE );
|
||||
|
||||
NNS_FndInitAllocatorForExpHeap( pAllocator, heapHandle, 32 );
|
||||
}
|
||||
|
||||
|
||||
// メモリ割り当て
|
||||
void *Alloc( u32 size )
|
||||
{
|
||||
return NNS_FndAllocFromAllocator( &g_allocator, size );
|
||||
}
|
||||
|
||||
|
||||
// メモリ解放
|
||||
void Free( void *pBuffer )
|
||||
{
|
||||
NNS_FndFreeToAllocator( &g_allocator, pBuffer );
|
||||
}
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// 画面設定
|
||||
// ============================================================================
|
||||
|
||||
// BG初期化
|
||||
void InitBG(void)
|
||||
{
|
||||
// 画面OFF
|
||||
GX_DispOff();
|
||||
GXS_DispOff();
|
||||
|
||||
// VRAMの割り当てを全て解除
|
||||
GX_DisableBankForBG();
|
||||
GX_DisableBankForOBJ();
|
||||
GX_DisableBankForSubBG();
|
||||
GX_DisableBankForSubOBJ();
|
||||
|
||||
// メイン2Dエンジンの出力を下画面に
|
||||
GX_SetDispSelect( GX_DISP_SELECT_SUB_MAIN );
|
||||
|
||||
// メインLCD
|
||||
{
|
||||
// VRAM割り当て
|
||||
GX_SetBankForBG ( GX_VRAM_BG_128_A );
|
||||
GX_SetBankForOBJ( GX_VRAM_OBJ_128_B );
|
||||
|
||||
MI_CpuClearFast( (void *)HW_BG_VRAM, 0x20000 ); // BG -VRAM クリア
|
||||
MI_CpuClearFast( (void *)HW_OBJ_VRAM, 0x20000 ); // OBJ-VRAM クリア
|
||||
|
||||
// カラーパレットを設定
|
||||
GX_LoadBGPltt( TXTColorPalette, 0, sizeof(TXTColorPalette) );
|
||||
|
||||
// BGモード設定
|
||||
GX_SetGraphicsMode( GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_2D );
|
||||
|
||||
GX_SetBGScrOffset ( GX_BGSCROFFSET_0x10000 );
|
||||
GX_SetBGCharOffset( GX_BGCHAROFFSET_0x00000 );
|
||||
}
|
||||
// サブLCD
|
||||
{
|
||||
// VRAM割り当て
|
||||
GX_SetBankForSubBG ( GX_VRAM_SUB_BG_128_C ); // VRAM-C for BGs
|
||||
GX_SetBankForSubOBJ( GX_VRAM_SUB_OBJ_128_D ); // VRAM-D for BGs
|
||||
|
||||
MI_CpuClearFast( (void *)HW_DB_BG_VRAM, 0x20000 ); // BG -VRAM クリア
|
||||
MI_CpuClearFast( (void *)HW_DB_OBJ_VRAM, 0x20000 ); // OBJ -VRAM クリア
|
||||
|
||||
// カラーパレットを設定
|
||||
GXS_LoadBGPltt( TXTColorPalette, 0, sizeof(TXTColorPalette) );
|
||||
|
||||
// BGモード設定
|
||||
GXS_SetGraphicsMode( GX_BGMODE_0 ); // BGMODE is 0
|
||||
}
|
||||
InitScreen();
|
||||
InitCanvas();
|
||||
}
|
||||
|
||||
|
||||
// スクリーン初期化
|
||||
static void InitScreen( void )
|
||||
{
|
||||
// メイン画面 BG 0 を設定
|
||||
G2_SetBG0Control(
|
||||
GX_BG_SCRSIZE_TEXT_256x256, // スクリーンサイズ 256x256
|
||||
GX_BG_COLORMODE_256, // カラーモード 256色
|
||||
GX_BG_SCRBASE_0xf800, // スクリーンベース
|
||||
GX_BG_CHARBASE_0x00000, // キャラクタベース
|
||||
GX_BG_EXTPLTT_01 // 拡張パレットスロット
|
||||
);
|
||||
G2_SetBG1Control(
|
||||
GX_BG_SCRSIZE_TEXT_256x256, // 256pix x 256pix text
|
||||
GX_BG_COLORMODE_16, // use 16 colors mode
|
||||
GX_BG_SCRBASE_0xf000, // screen base offset + 0x0000 is the address for BG #1 screen
|
||||
GX_BG_CHARBASE_0x10000, // character base offset + 0x04000 is the address for BG #0 characters
|
||||
GX_BG_EXTPLTT_01 // use BGExtPltt slot #0 if BGExtPltt is enabled
|
||||
);
|
||||
GX_SetVisiblePlane( GX_PLANEMASK_BG0 | GX_PLANEMASK_BG1);
|
||||
G2_SetBG0Priority(0);
|
||||
G2_SetBG1Priority(1);
|
||||
|
||||
GX_LoadBG1Char(bg_char_data, 0, sizeof(bg_char_data));
|
||||
GX_LoadBG1Scr(sScrnBuf, 0, sizeof(sScrnBuf));
|
||||
|
||||
// サブ画面 BG 0 を設定
|
||||
G2S_SetBG0Control(
|
||||
GX_BG_SCRSIZE_TEXT_256x256, // 256pix x 256pix text
|
||||
GX_BG_COLORMODE_16, // use 16 colors mode
|
||||
GX_BG_SCRBASE_0xf800, // screen base offset + 0x0000 is the address for BG #0 screen
|
||||
GX_BG_CHARBASE_0x00000, // character base offset + 0x04000 is the address for BG #0 characters
|
||||
GX_BG_EXTPLTT_01 // use BGExtPltt slot #0 if BGExtPltt is enabled
|
||||
);
|
||||
GXS_SetVisiblePlane( GX_PLANEMASK_BG0 ); // display only BG #0
|
||||
}
|
||||
|
||||
|
||||
// 文字列描画の初期化
|
||||
static void InitCanvas( void )
|
||||
{
|
||||
CMN_InitFileSystem( &g_allocator );
|
||||
|
||||
// フォントを読み込みます
|
||||
{
|
||||
void* pFontFile;
|
||||
u32 size = CMN_LoadFile( &pFontFile, NTR_IPL_FONT_DATA, &g_allocator);
|
||||
NNS_G2D_ASSERT( size > 0 );
|
||||
NNS_G2dFontInitUTF16(&gFont, pFontFile);
|
||||
// NNS_G2dPrintFont(&gFont);
|
||||
}
|
||||
|
||||
{
|
||||
// CharCanvas の初期化
|
||||
NNS_G2dCharCanvasInitForBG(
|
||||
&gCanvas,
|
||||
(GXCharFmt256*)G2_GetBG0CharPtr() + CHARACTER_OFFSET,
|
||||
CANVAS_WIDTH,
|
||||
CANVAS_HEIGHT,
|
||||
NNS_G2D_CHARA_COLORMODE_256
|
||||
);
|
||||
|
||||
// TextCanvasの初期化
|
||||
NNS_G2dTextCanvasInit(
|
||||
&gTextCanvas,
|
||||
&gCanvas,
|
||||
&gFont,
|
||||
TEXT_HSPACE,
|
||||
TEXT_VSPACE
|
||||
);
|
||||
|
||||
// スクリーンを設定
|
||||
NNS_G2dMapScrToCharText(
|
||||
G2_GetBG0ScrPtr(),
|
||||
CANVAS_WIDTH,
|
||||
CANVAS_HEIGHT,
|
||||
CANVAS_LEFT,
|
||||
CANVAS_TOP,
|
||||
NNS_G2D_TEXT_BG_WIDTH_256,
|
||||
CHARACTER_OFFSET,
|
||||
TXT_CPALETTE_MAIN
|
||||
);
|
||||
}
|
||||
{
|
||||
// CharCanvas の初期化
|
||||
NNS_G2dCharCanvasInitForBG(
|
||||
&gCanvasSub,
|
||||
(GXCharFmt16*)G2S_GetBG0CharPtr() + CHARACTER_OFFSET,
|
||||
CANVAS_WIDTH,
|
||||
CANVAS_HEIGHT,
|
||||
NNS_G2D_CHARA_COLORMODE_16
|
||||
);
|
||||
|
||||
// TextCanvasの初期化
|
||||
NNS_G2dTextCanvasInit(
|
||||
&gTextCanvasSub,
|
||||
&gCanvasSub,
|
||||
&gFont,
|
||||
TEXT_HSPACE,
|
||||
TEXT_VSPACE
|
||||
);
|
||||
|
||||
// スクリーンを設定
|
||||
NNS_G2dMapScrToCharText(
|
||||
G2S_GetBG0ScrPtr(),
|
||||
CANVAS_WIDTH,
|
||||
CANVAS_HEIGHT,
|
||||
CANVAS_LEFT,
|
||||
CANVAS_TOP,
|
||||
NNS_G2D_TEXT_BG_WIDTH_256,
|
||||
CHARACTER_OFFSET,
|
||||
TXT_CPALETTE_MAIN
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// UTF16での直接文字表示
|
||||
void PutStringUTF16( int x, int y, int color, const u16 *strUTF16 )
|
||||
{
|
||||
NNS_G2dTextCanvasDrawText( &gTextCanvas, x, y, color, TXT_DRAWTEXT_FLAG_DEFAULT,
|
||||
strUTF16 );
|
||||
}
|
||||
|
||||
void PutStringUTF16Sub( int x, int y, int color, const u16 *strUTF16 )
|
||||
{
|
||||
NNS_G2dTextCanvasDrawText( &gTextCanvasSub, x, y, color, TXT_DRAWTEXT_FLAG_DEFAULT,
|
||||
strUTF16 );
|
||||
}
|
||||
|
||||
|
||||
// 書式付きで作成した文字列を表示した場合の幅を取得する
|
||||
int GetPrintfWidth( const NNSG2dTextCanvas *pCanvas, const char *fmt, ... )
|
||||
{
|
||||
int srcLen;
|
||||
int dstLen = sizeof(s_strBufferUTF16);
|
||||
va_list vlist;
|
||||
va_start(vlist, fmt);
|
||||
srcLen = STD_TVSNPrintf( s_strBuffer, sizeof(s_strBuffer), fmt, vlist);
|
||||
va_end(vlist);
|
||||
s_strBuffer[ srcLen ] = 0;
|
||||
|
||||
(void)STD_ConvertStringSjisToUnicode( s_strBufferUTF16, &dstLen, s_strBuffer, &srcLen, NULL );
|
||||
s_strBufferUTF16[ dstLen ] = 0;
|
||||
|
||||
return NNS_G2dTextCanvasGetTextWidth( pCanvas, s_strBufferUTF16 );
|
||||
}
|
||||
|
||||
|
||||
// SJISでPrintf形式で文字表示(内部でUTF16に変換)
|
||||
void PrintfSJIS( int x, int y, int color, const char *fmt, ... )
|
||||
{
|
||||
int srcLen;
|
||||
int dstLen = sizeof(s_strBufferUTF16);
|
||||
va_list vlist;
|
||||
va_start(vlist, fmt);
|
||||
srcLen = STD_TVSNPrintf( s_strBuffer, sizeof(s_strBuffer), fmt, vlist);
|
||||
va_end(vlist);
|
||||
s_strBuffer[ srcLen ] = 0;
|
||||
|
||||
(void)STD_ConvertStringSjisToUnicode( s_strBufferUTF16, &dstLen, s_strBuffer, &srcLen, NULL );
|
||||
s_strBufferUTF16[ dstLen ] = 0;
|
||||
|
||||
NNS_G2dTextCanvasDrawText(&gTextCanvas, x, y, color, TXT_DRAWTEXT_FLAG_DEFAULT,
|
||||
s_strBufferUTF16 );
|
||||
}
|
||||
|
||||
void PrintfSJISSub( int x, int y, int color, const char *fmt, ... )
|
||||
{
|
||||
int srcLen;
|
||||
int dstLen = sizeof(s_strBufferUTF16);
|
||||
va_list vlist;
|
||||
va_start(vlist, fmt);
|
||||
srcLen = STD_TVSNPrintf( s_strBuffer, sizeof(s_strBuffer), fmt, vlist);
|
||||
va_end(vlist);
|
||||
s_strBuffer[ srcLen ] = 0;
|
||||
|
||||
(void)STD_ConvertStringSjisToUnicode( s_strBufferUTF16, &dstLen, s_strBuffer, &srcLen, NULL );
|
||||
s_strBufferUTF16[ dstLen ] = 0;
|
||||
|
||||
NNS_G2dTextCanvasDrawText(&gTextCanvasSub, x, y, color, TXT_DRAWTEXT_FLAG_DEFAULT,
|
||||
s_strBufferUTF16 );
|
||||
}
|
||||
|
||||
|
||||
// キー入力読み出し--------------------------------
|
||||
void ReadKeyPad(void)
|
||||
{
|
||||
u16 readData = PAD_Read();
|
||||
pad.trg = (u16)(readData & (readData ^ pad.cont)); // トリガ 入力
|
||||
pad.cont = readData; // ベタ 入力
|
||||
}
|
||||
|
||||
|
||||
// タッチパネルデータの取得-----------------------
|
||||
void ReadTP(void)
|
||||
{
|
||||
TP_GetCalibratedPoint( &tpd.last, &tpd.raw ); // 前回のTPデータを退避
|
||||
|
||||
if( TP_RequestRawSampling(&tpd.raw) ) { // タッチパネルのサンプリング
|
||||
SVC_CpuClear(0x0000, &tpd.raw, sizeof(tpd.raw), 16); // SPI-busyでデータ取得に失敗した時は”データなし”でリターン。
|
||||
return;
|
||||
}
|
||||
TP_GetCalibratedPoint( &tpd.disp, &tpd.raw ); // TP座標からLCD座標に変換。
|
||||
|
||||
if( !WaitDetachTP() ) { // TPデタッチ待ちを行う。
|
||||
SVC_CpuClear(0x0000, &tpd.disp, sizeof(tpd.disp), 16); // SPI-busyでデータ取得に失敗した時は”データなし”でリターン。
|
||||
return;
|
||||
}
|
||||
#if 1
|
||||
if(tpd.disp.touch) { // 現在のTPデータを表示
|
||||
switch ( tpd.disp.validity ) {
|
||||
case TP_VALIDITY_VALID:
|
||||
OS_Printf("( %3d, %3d ) -> ( %3d, %3d )\n", tpd.raw.x, tpd.raw.y, tpd.disp.x, tpd.disp.y);
|
||||
break;
|
||||
case TP_VALIDITY_INVALID_X:
|
||||
OS_Printf("( *%3d, %3d ) -> ( *%3d, %3d )\n", tpd.raw.x, tpd.raw.y, tpd.disp.x, tpd.disp.y);
|
||||
break;
|
||||
case TP_VALIDITY_INVALID_Y:
|
||||
OS_Printf("( %3d, *%3d ) -> ( %3d, *%3d )\n", tpd.raw.x, tpd.raw.y, tpd.disp.x, tpd.disp.y);
|
||||
break;
|
||||
case TP_VALIDITY_INVALID_XY:
|
||||
OS_Printf("( *%3d, *%3d ) -> ( *%3d, *%3d )\n", tpd.raw.x, tpd.raw.y, tpd.disp.x, tpd.disp.y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// TPデタッチを待つ
|
||||
static BOOL WaitDetachTP( void )
|
||||
{
|
||||
// s_detach_countが始動していたら、カウント判定。
|
||||
if(s_detach_count > 0) {
|
||||
if(tpd.disp.touch == 0) { // TPが押されていなければ、カウント進行し規定値で再入力を受け付ける。
|
||||
s_detach_count--;
|
||||
}else {
|
||||
s_detach_count = TP_CSR_DETACH_COUNT;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
// TPデタッチ待ちの開始
|
||||
static void StartDetachTP( void )
|
||||
{
|
||||
s_detach_count = TP_CSR_DETACH_COUNT;
|
||||
}
|
||||
|
||||
|
||||
//======================================================
|
||||
// メニュー制御
|
||||
//======================================================
|
||||
|
||||
// メニュー描画
|
||||
void DrawMenu( u16 nowCsr, const MenuParam *pMenu )
|
||||
{
|
||||
int i;
|
||||
int color;
|
||||
|
||||
for( i = 0; i < pMenu->num; i++ ) {
|
||||
if(i == nowCsr) {
|
||||
if( !pMenu->pos[ i ].enable ) {
|
||||
color = pMenu->disable_color;
|
||||
}else {
|
||||
color = pMenu->select_color;
|
||||
}
|
||||
}else {
|
||||
color = pMenu->normal_color;
|
||||
}
|
||||
PutStringUTF16( pMenu->pos[ i ].x, pMenu->pos[ i ].y, color, (pMenu->str_elem)[ i ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// タッチパネルによるメニュー選択
|
||||
BOOL SelectMenuByTP( u16 *nowCsr, const MenuParam *pMenu )
|
||||
{
|
||||
u16 i;
|
||||
TPData *target;
|
||||
static u16 detach_count = 0;
|
||||
static u16 csr_old = 0xff;
|
||||
static u16 same_csr_count = 0;
|
||||
|
||||
// detach_countが始動していたら、カウント判定。
|
||||
if( detach_count > 0 ) {
|
||||
if( tpd.disp.touch == 0 ) { // TPが押されていなければ、カウント進行し、10カウントでメニュー選択
|
||||
if( ++detach_count == TP_CSR_DETACH_COUNT ) {
|
||||
detach_count = 0;
|
||||
return TRUE;
|
||||
}else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
detach_count=0; // detachカウント値のクリア
|
||||
|
||||
// 通常は、TPデータがメニュー上にあるかどうかを判定。
|
||||
if( tpd.disp.touch ) target = &tpd.disp;
|
||||
else target = &tpd.last;
|
||||
|
||||
for( i = 0; i < pMenu->num; i++ ) {
|
||||
if( tpd.disp.touch ) { // タッチパネルがメニューの要素上でタッチされているなら、
|
||||
NNSG2dTextRect rect = NNS_G2dTextCanvasGetTextRect( &gTextCanvas, (pMenu->str_elem)[ i ] );
|
||||
u16 top_x = (u16)( pMenu->pos[ i ].x ); // メニュー要素のLCD座標を算出
|
||||
u16 top_y = (u16)( pMenu->pos[ i ].y );
|
||||
u16 bottom_x = (u16)( top_x + rect.width );
|
||||
u16 bottom_y = (u16)( top_y + rect.height );
|
||||
|
||||
OS_TPrintf( "MENU[ %d ] : top_x = %02d top_y = %02d bot_x = %02d bot_y = %02d : ",
|
||||
i, top_x, top_y, bottom_x, bottom_y );
|
||||
|
||||
if( WithinRangeTP( top_x, top_y, bottom_x, bottom_y, target ) ) {
|
||||
OS_TPrintf( "InRange\n" );
|
||||
if( tpd.disp.validity == TP_VALIDITY_VALID ) { // カーソルをその要素に移動
|
||||
if( csr_old == i ) {
|
||||
if( same_csr_count < TP_CSR_TOUCH_COUNT ) {
|
||||
same_csr_count++;
|
||||
}else {
|
||||
*nowCsr = i;
|
||||
}
|
||||
return FALSE;
|
||||
}else {
|
||||
csr_old = i;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
OS_TPrintf( "OutRange\n" );
|
||||
}
|
||||
}else { // touch==0
|
||||
if( same_csr_count == TP_CSR_TOUCH_COUNT ) {
|
||||
detach_count = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
same_csr_count = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// 現在のタッチパネル座標が指定領域内にあるかどうかを返す。
|
||||
BOOL WithinRangeTP( int top_x, int top_y, int bottom_x, int bottom_y, TPData *tgt )
|
||||
{
|
||||
if( ( tgt->x >= top_x ) &&
|
||||
( tgt->x <= bottom_x ) &&
|
||||
( tgt->y >= top_y ) &&
|
||||
( tgt->y <= bottom_y ) ) {
|
||||
OS_TPrintf( "\nRANGE : tx=%3d ty=%3d bx=%3d by=%3d : x=%3d y=%3d\n",
|
||||
top_x, top_y, bottom_x, bottom_y, tgt->x, tgt->y );
|
||||
return TRUE;
|
||||
}else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// バナーアイコンOBJのロード
|
||||
void SetBannerIconOBJ( GXOamAttr *pDstOAM, BannerFileV1 *bannerp )
|
||||
{
|
||||
GXS_LoadOBJPltt( bannerp->pltt, 15, BNR_PLTT_SIZE );
|
||||
MI_CpuCopyFast( bannerp->image, (void *)(HW_DB_OBJ_VRAM + 0x20), BNR_IMAGE_SIZE );
|
||||
G2_SetOBJAttr( pDstOAM, // OAM pointer
|
||||
32, // X position
|
||||
32, // Y position
|
||||
0, // Priority
|
||||
GX_OAM_MODE_NORMAL, // Bitmap mode
|
||||
FALSE, // mosaic off
|
||||
GX_OAM_EFFECT_NONE, // affine off
|
||||
GX_OAM_SHAPE_32x32, // 16x16 size
|
||||
GX_OAM_COLOR_16, // 16 color
|
||||
1, // charactor
|
||||
15, // palette
|
||||
0); // affine
|
||||
}
|
||||
|
||||
|
||||
//===============================================
|
||||
// RTCアクセスルーチン
|
||||
//===============================================
|
||||
|
||||
// RTCデータの取得
|
||||
BOOL GetRTCData( RTCDrawProperty *pRTCDraw, BOOL forceGetFlag )
|
||||
{
|
||||
if( forceGetFlag || ( pRTCDraw->vcount++ == 59 ) ) {
|
||||
pRTCDraw->vcount = 0;
|
||||
MI_CpuCopy16( &pRTCDraw->date, &pRTCDraw->date_old, sizeof(RTCDate) );
|
||||
MI_CpuCopy16( &pRTCDraw->time, &pRTCDraw->time_old, sizeof(RTCTime) );
|
||||
(void)RTC_GetDateTime( &pRTCDraw->date, &pRTCDraw->time );
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// RTCデータの表示
|
||||
void DrawRTCData( RTCDrawProperty *pRTCDraw )
|
||||
{
|
||||
void (*pPrintFunc)( int x, int y, int color, const char *fmt, ... ) =
|
||||
( pRTCDraw->isTopLCD ) ? PrintfSJISSub : PrintfSJIS;
|
||||
|
||||
// 前RTC情報の消去
|
||||
{
|
||||
u32 year = pRTCDraw->date_old.year + 2000;
|
||||
pPrintFunc( pRTCDraw->date_x, pRTCDraw->date_y, TXT_COLOR_WHITE, "%04d/%02d/%02d[%3s]",
|
||||
year,
|
||||
pRTCDraw->date_old.month,
|
||||
pRTCDraw->date_old.day,
|
||||
g_strWeek[ pRTCDraw->date_old.week ]
|
||||
);
|
||||
pPrintFunc( pRTCDraw->time_x, pRTCDraw->time_y, TXT_COLOR_WHITE, "%02d:%02d:%02d",
|
||||
pRTCDraw->time_old.hour,
|
||||
pRTCDraw->time_old.minute,
|
||||
pRTCDraw->time_old.second
|
||||
);
|
||||
}
|
||||
// RTC情報の表示
|
||||
{
|
||||
u32 year = pRTCDraw->date.year + 2000;
|
||||
pPrintFunc( pRTCDraw->date_x, pRTCDraw->date_y, TXT_COLOR_BLACK, "%d/%02d/%02d[%3s]",
|
||||
year,
|
||||
pRTCDraw->date.month,
|
||||
pRTCDraw->date.day,
|
||||
g_strWeek[ pRTCDraw->date.week ]
|
||||
);
|
||||
pPrintFunc( pRTCDraw->time_x, pRTCDraw->time_y, TXT_COLOR_BLACK, "%02d:%02d:%02d",
|
||||
pRTCDraw->time.hour,
|
||||
pRTCDraw->time.minute,
|
||||
pRTCDraw->time.second
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// RTCデータの取得&表示
|
||||
void GetAndDrawRTCData( RTCDrawProperty *pRTCDraw, BOOL forceGetFlag )
|
||||
{
|
||||
if( GetRTCData( pRTCDraw, forceGetFlag ) ) {
|
||||
DrawRTCData( pRTCDraw );
|
||||
}
|
||||
}
|
||||
|
||||
// ユーザーカラー領域の切り替え
|
||||
void ChangeUserColor( u8 col )
|
||||
{
|
||||
int l;
|
||||
if(col > 15) return;
|
||||
for(l=0;l<16;l++)
|
||||
{
|
||||
TXTColorPalette[16+l] = TempPalette[16 * col + l];
|
||||
}
|
||||
GX_LoadBGPltt( TXTColorPalette, 0, sizeof(TXTColorPalette) );
|
||||
}
|
||||
@ -31,11 +31,13 @@ TARGET_BIN = main.srl
|
||||
|
||||
ROM_SPEC = main.rsf
|
||||
|
||||
MISC_DIR = ../../MachineSettings/ARM9/src
|
||||
MISC_DIR = ../../misc
|
||||
|
||||
SRCS = main.c PictoChat.c $(MISC_DIR)/misc.c
|
||||
SRCS = main.c PictoChat.c \
|
||||
$(MISC_DIR)/src/misc.c
|
||||
|
||||
LINCLUDES = $(MISC_DIR)/include
|
||||
|
||||
LINCLUDES = $(MISC_DIR)
|
||||
|
||||
include $(TWLIPL_ROOT)/build/buildtools/commondefs
|
||||
|
||||
|
||||
@ -60,7 +60,6 @@ void TwlMain(void)
|
||||
|
||||
// システムの初期化------------------
|
||||
InitAllocator();
|
||||
CMN_InitFileSystem( &g_allocator );
|
||||
|
||||
{
|
||||
// ファイルシステム切り替え応急処置
|
||||
|
||||
@ -76,7 +76,6 @@ enum
|
||||
TXT_COLOR_4BPP_TEXT=1
|
||||
};
|
||||
|
||||
#define TXT_COLOR_USER 17
|
||||
|
||||
// ŽžŒv•\ަ<C5BD>ê<EFBFBD>Š
|
||||
#define RTC_DATE_TOP_X ( 9 * 8 )
|
||||
@ -164,7 +163,6 @@ void SetBannerIconOBJ( GXOamAttr *pDstOAM, BannerFileV1 *bannerp );
|
||||
BOOL GetRTCData( RTCDrawProperty *pRTCDraw, BOOL forceGetFlag );
|
||||
void DrawRTCData( RTCDrawProperty *pRTCDraw );
|
||||
void GetAndDrawRTCData( RTCDrawProperty *pRTCDraw, BOOL forceGetFlag );
|
||||
void ChangeUserColor( u8 col );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@ -74,14 +74,15 @@ typedef struct RtcDrawPos{
|
||||
}RtcDrawPos;
|
||||
|
||||
// function's prototype-------------------------------------------------------
|
||||
static BOOL WaitDetachTP( void );
|
||||
static void StartDetachTP( void );
|
||||
static void InitScreen( void );
|
||||
static void InitCanvas( void );
|
||||
static void GetAndDrawRtcDataCore( BOOL forceGetFlag );
|
||||
|
||||
// global variable-------------------------------------------------------------
|
||||
KeyWork pad; // キーパッド入力データ
|
||||
TpWork tpd; // タッチパネル入力データ
|
||||
|
||||
KeyWork pad; // キーパッド入力データ
|
||||
TpWork tpd; // タッチパネル入力データ
|
||||
NNSFndAllocator g_allocator; // メモリアロケータ
|
||||
NNSG2dFont gFont; // フォント
|
||||
NNSG2dCharCanvas gCanvas; // CharCanvas
|
||||
NNSG2dTextCanvas gTextCanvas; // TextCanvas
|
||||
@ -111,8 +112,45 @@ const u8 *const g_strWeek[] ATTRIBUTE_ALIGN(2) = {
|
||||
(const u8 *)"SAT",
|
||||
};
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// function's description
|
||||
// メモリ管理
|
||||
// ============================================================================
|
||||
|
||||
// アロケータの初期化
|
||||
void InitAllocator( void )
|
||||
{
|
||||
NNSFndAllocator *pAllocator = &g_allocator;
|
||||
u32 arenaLow = MATH_ROUNDUP ( (u32)OS_GetMainArenaLo(), 16 );
|
||||
u32 arenaHigh = MATH_ROUNDDOWN( (u32)OS_GetMainArenaHi(), 16 );
|
||||
u32 heapSize = arenaHigh - arenaLow;
|
||||
void* heapMemory = OS_AllocFromMainArenaLo( heapSize, 16 );
|
||||
NNSFndHeapHandle heapHandle;
|
||||
SDK_NULL_ASSERT( pAllocator );
|
||||
|
||||
heapHandle = NNS_FndCreateExpHeap( heapMemory, heapSize );
|
||||
SDK_ASSERT( heapHandle != NNS_FND_HEAP_INVALID_HANDLE );
|
||||
|
||||
NNS_FndInitAllocatorForExpHeap( pAllocator, heapHandle, 32 );
|
||||
}
|
||||
|
||||
|
||||
// メモリ割り当て
|
||||
void *Alloc( u32 size )
|
||||
{
|
||||
return NNS_FndAllocFromAllocator( &g_allocator, size );
|
||||
}
|
||||
|
||||
|
||||
// メモリ解放
|
||||
void Free( void *pBuffer )
|
||||
{
|
||||
NNS_FndFreeToAllocator( &g_allocator, pBuffer );
|
||||
}
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// 画面設定
|
||||
// ============================================================================
|
||||
|
||||
// BG初期化
|
||||
@ -197,6 +235,8 @@ static void InitScreen( void )
|
||||
// 文字列描画の初期化
|
||||
static void InitCanvas( void )
|
||||
{
|
||||
CMN_InitFileSystem( &g_allocator );
|
||||
|
||||
// フォントを読み込みます
|
||||
{
|
||||
void* pFontFile;
|
||||
@ -285,6 +325,24 @@ void PutStringUTF16Sub( int x, int y, int color, const u16 *strUTF16 )
|
||||
}
|
||||
|
||||
|
||||
// 書式付きで作成した文字列を表示した場合の幅を取得する
|
||||
int GetPrintfWidth( const NNSG2dTextCanvas *pCanvas, const char *fmt, ... )
|
||||
{
|
||||
int srcLen;
|
||||
int dstLen = sizeof(s_strBufferUTF16);
|
||||
va_list vlist;
|
||||
va_start(vlist, fmt);
|
||||
srcLen = STD_TVSNPrintf( s_strBuffer, sizeof(s_strBuffer), fmt, vlist);
|
||||
va_end(vlist);
|
||||
s_strBuffer[ srcLen ] = 0;
|
||||
|
||||
(void)STD_ConvertStringSjisToUnicode( s_strBufferUTF16, &dstLen, s_strBuffer, &srcLen, NULL );
|
||||
s_strBufferUTF16[ dstLen ] = 0;
|
||||
|
||||
return NNS_G2dTextCanvasGetTextWidth( pCanvas, s_strBufferUTF16 );
|
||||
}
|
||||
|
||||
|
||||
// SJISでPrintf形式で文字表示(内部でUTF16に変換)
|
||||
void PrintfSJIS( int x, int y, int color, const char *fmt, ... )
|
||||
{
|
||||
@ -331,7 +389,7 @@ void ReadKeyPad(void)
|
||||
|
||||
|
||||
// タッチパネルデータの取得-----------------------
|
||||
void ReadTpData(void)
|
||||
void ReadTP(void)
|
||||
{
|
||||
TP_GetCalibratedPoint( &tpd.last, &tpd.raw ); // 前回のTPデータを退避
|
||||
|
||||
@ -367,7 +425,7 @@ void ReadTpData(void)
|
||||
|
||||
|
||||
// TPデタッチを待つ
|
||||
BOOL WaitDetachTP( void )
|
||||
static BOOL WaitDetachTP( void )
|
||||
{
|
||||
// s_detach_countが始動していたら、カウント判定。
|
||||
if(s_detach_count > 0) {
|
||||
@ -383,7 +441,7 @@ BOOL WaitDetachTP( void )
|
||||
|
||||
|
||||
// TPデタッチ待ちの開始
|
||||
void StartDetachTP( void )
|
||||
static void StartDetachTP( void )
|
||||
{
|
||||
s_detach_count = TP_CSR_DETACH_COUNT;
|
||||
}
|
||||
@ -444,14 +502,14 @@ BOOL SelectMenuByTP( u16 *nowCsr, const MenuParam *pMenu )
|
||||
if( tpd.disp.touch ) { // タッチパネルがメニューの要素上でタッチされているなら、
|
||||
NNSG2dTextRect rect = NNS_G2dTextCanvasGetTextRect( &gTextCanvas, (pMenu->str_elem)[ i ] );
|
||||
u16 top_x = (u16)( pMenu->pos[ i ].x ); // メニュー要素のLCD座標を算出
|
||||
u16 top_y = (u16)( pMenu->pos[ i ].y - 4 );
|
||||
u16 top_y = (u16)( pMenu->pos[ i ].y );
|
||||
u16 bottom_x = (u16)( top_x + rect.width );
|
||||
u16 bottom_y = (u16)( top_y + rect.height + 4 ); // ※Y座標は±4のマージン
|
||||
u16 bottom_y = (u16)( top_y + rect.height );
|
||||
|
||||
OS_TPrintf( "MENU[ %d ] : top_x = %02d top_y = %02d bot_x = %02d bot_y = %02d : ",
|
||||
i, top_x, top_y, bottom_x, bottom_y );
|
||||
|
||||
if( InRangeTp( top_x, top_y, bottom_x, bottom_y, target ) ) {
|
||||
if( WithinRangeTP( top_x, top_y, bottom_x, bottom_y, target ) ) {
|
||||
OS_TPrintf( "InRange\n" );
|
||||
if( tpd.disp.validity == TP_VALIDITY_VALID ) { // カーソルをその要素に移動
|
||||
if( csr_old == i ) {
|
||||
@ -482,12 +540,14 @@ BOOL SelectMenuByTP( u16 *nowCsr, const MenuParam *pMenu )
|
||||
|
||||
|
||||
// 現在のタッチパネル座標が指定領域内にあるかどうかを返す。
|
||||
BOOL InRangeTp( int top_x, int top_y, int bottom_x, int bottom_y, TPData *tgt )
|
||||
BOOL WithinRangeTP( int top_x, int top_y, int bottom_x, int bottom_y, TPData *tgt )
|
||||
{
|
||||
if( ( tgt->x >= top_x ) &&
|
||||
( tgt->x <= bottom_x ) &&
|
||||
( tgt->y >= top_y ) &&
|
||||
( tgt->y <= bottom_y ) ) {
|
||||
OS_TPrintf( "\nRANGE : tx=%3d ty=%3d bx=%3d by=%3d : x=%3d y=%3d\n",
|
||||
top_x, top_y, bottom_x, bottom_y, tgt->x, tgt->y );
|
||||
return TRUE;
|
||||
}else {
|
||||
return FALSE;
|
||||
@ -495,79 +555,6 @@ BOOL InRangeTp( int top_x, int top_y, int bottom_x, int bottom_y, TPData *tgt )
|
||||
}
|
||||
|
||||
|
||||
//===============================================
|
||||
// RTCアクセスルーチン
|
||||
//===============================================
|
||||
|
||||
// RTCデータ取得&表示の初期化
|
||||
void InitGetAndDrawRtcData( int drawDatePos_x, int drawDatePos_y, int drawTimePos_x, int drawTimePos_y)
|
||||
{
|
||||
s_vcount = 0;
|
||||
s_rtcPos.date_x = drawDatePos_x;
|
||||
s_rtcPos.date_y = drawDatePos_y;
|
||||
s_rtcPos.time_x = drawTimePos_x;
|
||||
s_rtcPos.time_y = drawTimePos_y;
|
||||
|
||||
(void)RTC_GetDateTime( &s_rtcDate, &s_rtcTime);
|
||||
GetAndDrawRtcDataCore( TRUE );
|
||||
}
|
||||
|
||||
|
||||
void GetAndDrawRtcData( void )
|
||||
{
|
||||
GetAndDrawRtcDataCore( FALSE );
|
||||
}
|
||||
|
||||
|
||||
// RTC情報の取得&表示
|
||||
static void GetAndDrawRtcDataCore( BOOL forceGetFlag )
|
||||
{
|
||||
u32 year;
|
||||
RTCDate date_old;
|
||||
RTCTime time_old;
|
||||
|
||||
// RTC情報の取得
|
||||
if( forceGetFlag || ( s_vcount++ == 60 ) ) {
|
||||
s_vcount = 0;
|
||||
MI_CpuCopy16( &s_rtcDate, &date_old, sizeof(RTCDate) );
|
||||
MI_CpuCopy16( &s_rtcTime, &time_old, sizeof(RTCTime) );
|
||||
|
||||
(void)RTC_GetDateTime( &s_rtcDate, &s_rtcTime );
|
||||
|
||||
// 前RTC情報の消去
|
||||
{
|
||||
year = s_rtcDate.year + 2000;
|
||||
PrintfSJISSub( s_rtcPos.date_x, s_rtcPos.date_y, TXT_COLOR_WHITE, "%d/%02d/%02d[%3s]",
|
||||
year,
|
||||
date_old.month,
|
||||
date_old.day,
|
||||
g_strWeek[ date_old.week ]
|
||||
);
|
||||
PrintfSJISSub( s_rtcPos.time_x, s_rtcPos.time_y, TXT_COLOR_WHITE, "%02d:%02d:%02d",
|
||||
time_old.hour,
|
||||
time_old.minute,
|
||||
time_old.second
|
||||
);
|
||||
}
|
||||
// RTC情報の表示
|
||||
{
|
||||
year = s_rtcDate.year + 2000;
|
||||
PrintfSJISSub( s_rtcPos.date_x, s_rtcPos.date_y, TXT_COLOR_BLACK, "%d/%02d/%02d[%3s]",
|
||||
year,
|
||||
s_rtcDate.month,
|
||||
s_rtcDate.day,
|
||||
g_strWeek[ s_rtcDate.week ]
|
||||
);
|
||||
PrintfSJISSub( s_rtcPos.time_x, s_rtcPos.time_y, TXT_COLOR_BLACK, "%02d:%02d:%02d",
|
||||
s_rtcTime.hour,
|
||||
s_rtcTime.minute,
|
||||
s_rtcTime.second
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// バナーアイコンOBJのロード
|
||||
void SetBannerIconOBJ( GXOamAttr *pDstOAM, BannerFileV1 *bannerp )
|
||||
{
|
||||
@ -586,3 +573,68 @@ void SetBannerIconOBJ( GXOamAttr *pDstOAM, BannerFileV1 *bannerp )
|
||||
15, // palette
|
||||
0); // affine
|
||||
}
|
||||
|
||||
|
||||
//===============================================
|
||||
// RTCアクセスルーチン
|
||||
//===============================================
|
||||
|
||||
// RTCデータの取得
|
||||
BOOL GetRTCData( RTCDrawProperty *pRTCDraw, BOOL forceGetFlag )
|
||||
{
|
||||
if( forceGetFlag || ( pRTCDraw->vcount++ == 59 ) ) {
|
||||
pRTCDraw->vcount = 0;
|
||||
MI_CpuCopy16( &pRTCDraw->date, &pRTCDraw->date_old, sizeof(RTCDate) );
|
||||
MI_CpuCopy16( &pRTCDraw->time, &pRTCDraw->time_old, sizeof(RTCTime) );
|
||||
(void)RTC_GetDateTime( &pRTCDraw->date, &pRTCDraw->time );
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// RTCデータの表示
|
||||
void DrawRTCData( RTCDrawProperty *pRTCDraw )
|
||||
{
|
||||
void (*pPrintFunc)( int x, int y, int color, const char *fmt, ... ) =
|
||||
( pRTCDraw->isTopLCD ) ? PrintfSJISSub : PrintfSJIS;
|
||||
|
||||
// 前RTC情報の消去
|
||||
{
|
||||
u32 year = pRTCDraw->date_old.year + 2000;
|
||||
pPrintFunc( pRTCDraw->date_x, pRTCDraw->date_y, TXT_COLOR_WHITE, "%04d/%02d/%02d[%3s]",
|
||||
year,
|
||||
pRTCDraw->date_old.month,
|
||||
pRTCDraw->date_old.day,
|
||||
g_strWeek[ pRTCDraw->date_old.week ]
|
||||
);
|
||||
pPrintFunc( pRTCDraw->time_x, pRTCDraw->time_y, TXT_COLOR_WHITE, "%02d:%02d:%02d",
|
||||
pRTCDraw->time_old.hour,
|
||||
pRTCDraw->time_old.minute,
|
||||
pRTCDraw->time_old.second
|
||||
);
|
||||
}
|
||||
// RTC情報の表示
|
||||
{
|
||||
u32 year = pRTCDraw->date.year + 2000;
|
||||
pPrintFunc( pRTCDraw->date_x, pRTCDraw->date_y, TXT_COLOR_BLACK, "%d/%02d/%02d[%3s]",
|
||||
year,
|
||||
pRTCDraw->date.month,
|
||||
pRTCDraw->date.day,
|
||||
g_strWeek[ pRTCDraw->date.week ]
|
||||
);
|
||||
pPrintFunc( pRTCDraw->time_x, pRTCDraw->time_y, TXT_COLOR_BLACK, "%02d:%02d:%02d",
|
||||
pRTCDraw->time.hour,
|
||||
pRTCDraw->time.minute,
|
||||
pRTCDraw->time.second
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// RTCデータの取得&表示
|
||||
void GetAndDrawRTCData( RTCDrawProperty *pRTCDraw, BOOL forceGetFlag )
|
||||
{
|
||||
if( GetRTCData( pRTCDraw, forceGetFlag ) ) {
|
||||
DrawRTCData( pRTCDraw );
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@ -52,6 +52,8 @@ typedef struct SYSM_work {
|
||||
BOOL isValidTSD; // NITRO設定データ無効フラグ
|
||||
BOOL isOnDebugger; // デバッガ動作か?
|
||||
BOOL isExistCard; // 有効なNTR/TWLカードが存在するか?
|
||||
BOOL isHotStart; // Hot/Coldスタート判定
|
||||
BOOL isARM9Start; // ARM9スタートフラグ
|
||||
u16 cardHeaderCrc16; // システムメニューで計算したROMヘッダCRC16
|
||||
int cloneBootMode;
|
||||
|
||||
@ -68,7 +70,7 @@ typedef struct SYSM_work {
|
||||
#if 1
|
||||
#define SYSM_GetResetParam() ( (ResetParam *)HW_RED_RESERVED )
|
||||
|
||||
#define SYSM_GetWork() ( (SYSM_work *)( HW_RED_RESERVED + sizeof(ResetParam) ) )
|
||||
#define SYSM_GetWork() ( (SYSM_work *)( HW_RED_RESERVED + 0x40 ) )
|
||||
#else
|
||||
// SYSMリセットパラメータの取得
|
||||
#define SYSM_GetResetParam() ( (ResetParam *)0x02000100 )
|
||||
|
||||
Loading…
Reference in New Issue
Block a user