アプリ間連携のサンプルを追加

・CooperationA、CooperationCからCooperationBをパラメタつき起動するサンプル
 ・CooperationBから、呼び出し元アプリを起動・状態復元するサンプル
その他smallfix

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@371 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
yoshida_teruhisa 2007-12-18 05:06:13 +00:00
parent 6e24f589ce
commit d74e44c5ad
31 changed files with 2803 additions and 3 deletions

View File

@ -82,8 +82,13 @@ void TwlMain( void )
// 初回起動シーケンス判定、
// 検査用オート起動カード判定、量産ライン用キーショートカット起動判定等のリード
// 「ダイレクトブートでない」なら、NAND & カードアプリリスト取得
// 「ダイレクトブートでない」なら
if( !pBootTitle ) {
// アプリ間パラメータの呼び出し元アプリ情報をクリア
OSDeliverArgInfo *arginfo = (OSDeliverArgInfo *)HW_PARAM_DELIVER_ARG;
arginfo->gameCode = NULL;
// NAND & カードアプリリスト取得
(void)SYSM_GetNandTitleList( s_titleList, LAUNCHER_TITLE_LIST_NUM ); // NANDアプリリストの取得内蔵アプリはs_titleList[1]から格納される)
(void)SYSM_GetCardTitleList( s_titleList ); // カードアプリリストの取得カードアプリはs_titleList[0]に格納される)
}

View File

@ -99,7 +99,7 @@ static u8 s_color_csr = 0;
static BOOL s_birth_csr = FALSE;
static TWLDate s_temp_birthday;
static u16 s_temp_name[ TWL_NICKNAME_LENGTH + 1 ];
static u16 s_temp_comment[ TWL_NICKNAME_LENGTH + 1 ];
static u16 s_temp_comment[ TWL_COMMENT_LENGTH + 1 ];
static u8 s_temp_name_length;
static u8 s_temp_comment_length;

View File

@ -0,0 +1,59 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlSDK - demos - simpleShoot-1
# File: Makefile
#
# 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: $
#----------------------------------------------------------------------------
SUBDIRS =
#----------------------------------------------------------------------------
TARGET_FIRM = SYSTEMMENU
TARGET_PLATFORM = TWL
TWL_ARCHGEN = LIMITED
TITLEID_LO = COPA
TARGET_TAD = $(BINDIR)/$(TITLEID_LO).tad
TARGET_BIN = main.srl
ROM_SPEC = main.rsf
MISC_DIR = $(TWL_IPL_RED_ROOT)/build/systemMenu_RED/misc
SRCS = main.c CooperationA.c \
$(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c
LINCLUDES = $(MISC_DIR)/include
MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)'
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
LDIRT_CLEAN = $(TARGET_TAD)
INSTALL_TARGETS = $(TARGET_TAD)
INSTALL_DIR = $(SDK_NMENU_DATADIR)
#----------------------------------------------------------------------------
do-build : $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#----------------------------------------------------------------------------
#===== End of Makefile =====

View File

@ -0,0 +1,154 @@
#----------------------------------------------------------------------------
# Project: TwlSDK - include
# File: ROM-BB.rsf
#
# Copyright 2007 Nintendo. All rights reserved.
#
# These coded insructions, 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:: 2007-11-21#$
# $Rev: 240 $
# $Author: yosiokat $
#----------------------------------------------------------------------------
#
# TWL ROM SPEC FILE
#
Arm9
{
Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)"
OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)"
OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)"
Elf "$(MAKEROM_ARM9:r).tef"
}
Arm7
{
Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)"
OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)"
OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)"
Elf "$(MAKEROM_ARM7_BASE:r).tef"
}
Arm9.Ltd
{
Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)"
OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)"
OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)"
}
Arm7.Ltd
{
Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)"
OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)"
OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)"
}
Property
{
###
### Settings for FinalROM
###
#### BEGIN
#
# TITLE NAME: Your product name within 12bytes
#
#TitleName "YourAppName"
#_GameCode $(TITLEID_LO)
#
# MAKER CODE: Your company ID# in 2 ascii words
# issued by NINTENDO
#
#MakerCode "00"
#
# REMASTER VERSION: Mastering version
#
#RomVersion 0
#
# ROM SPEED TYPE: [MROM/1TROM/UNDEFINED]
#
RomSpeedType $(MAKEROM_ROMSPEED)
#
# ROM SIZE: in bit [64M/128M/256M/512M/1G/2G]
#
#RomSize 128M
#RomSize 256M
#
# ROM PADDING: TRUE if finalrom
#
#RomFootPadding TRUE
#
# ROM HEADER TEMPLATE: Provided to every product by NINTENDO
#
#RomHeaderTemplate ./etc/rom_header.template.sbin
#
# BANNER FILE: generated from Banner Spec File
#
BannerFile ../banner/banner.bnr
###
### Setting for TWL
###
#
# BANNER FILE:
#
BannerTWLFile $(TWLSDK_ROOT)/include/twl/specfiles/default.bnr
#
# Boot allowed Media: [GameCard/NAND/SDCard/DownloadPlay]
# possible to choose one or more.
#
BootMedia GameCard NAND SDCard DownloadPlay
#
# Certification FILE:
#
Certificate $(TWLSDK_ROOT)/include/twl/specfiles/default_sgn.sbin
#Certificate ./my_sgn.sbin
#
# Digest parameters:
#
DigestParam 1024 32
#
# WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD]
# don't have to edit
#
WramMapping $(MAKEROM_WRAM_MAPPING)
#
# Codec mode:
# don't have to edit
#
CodecMode $(MAKEROM_CODEC_MODE)
TitleID_Lo $(TITLEID_LO)
TitleID_Hi 0x00010001
PrivateSaveDataSize 16K
# PublicSaveDataSize 16K
###
#### END
}
RomSpec
{
Offset 0x00000000
Segment ALL
HostRoot $(TWL_IPL_RED_ROOT)/build/systemMenu_RED/data
Root /data
File NTR_IPL_font_m.NFTR
}

View File

@ -0,0 +1,633 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File: CooperationA.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:: 2007-10-31#$
$Rev: 91 $
$Author: yosiokat $
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <sysmenu.h>
#include "misc.h"
#include "CooperationA.h"
// define data------------------------------------------
#define RETURN_BUTTON_TOP_X 2
#define RETURN_BUTTON_TOP_Y 21
#define RETURN_BUTTON_BOTTOM_X ( RETURN_BUTTON_TOP_X + 8 )
#define RETURN_BUTTON_BOTTOM_Y ( RETURN_BUTTON_TOP_Y + 2 )
// ソフトウェアキーボードLCD領域
#define CLIST_LT_X 23
#define CLIST_LT_Y 50
#define CLIST_MARGIN 14
#define CLIST_KEY_PER_SEGMENT 5
#define CLIST_SEGMENT_INTERVAL 7
#define COPA_MENU_ELEMENT_NUM 3 // メニューの項目数
#define CHAR_LIST_CHAR_NUM 120
#define CHAR_LIST_MODE_NUM 3
// 特殊キーコード
#define EOM_ (u16)0xe050
#define CODE_BUTTON_TOP_ (u16)0xe051
#define DEL_BUTTON_ (u16)0xe051
#define SPACE_BUTTON_ (u16)0xe052
#define VAR_BUTTON1_ (u16)0xe053
#define VAR_BUTTON2_ (u16)0xe054
#define OK_BUTTON_ (u16)0xe055
#define CANCEL_BUTTON_ (u16)0xe056
#define CODE_BUTTON_BOTTOM_ (u16)0xe057
#define CHAR_USCORE L'_'
#define KEY_PER_LINE 11
#define KEY_START 109 //ソフトウェアキーのカーソルデフォルト位置はキャンセルキー
#define KEY_OK 0xffff
#define KEY_CANCEL 0xfffe
#define PARAM_LENGTH 10
typedef struct CopA_Work
{
u16 csr;
int char_mode;
u16 key_csr;
u16 parameter[ PARAM_LENGTH + 1 ];
u16 temp_parameter[ PARAM_LENGTH + 1 ];
u8 temp_parameter_length;
void(*pNowProcess)(void);
int starx,stary;
} CopA_Work;
// extern data------------------------------------------
// function's prototype declaration---------------------
static void MenuScene( void );
// global variable -------------------------------------
extern RTCDrawProperty g_rtcDraw;
// static variable -------------------------------------
static CopA_Work s_work = (CopA_Work){0,0,0,L"",L"",0,0,0};
// const data -----------------------------------------
static const u16 char_tbl[CHAR_LIST_MODE_NUM][CHAR_LIST_CHAR_NUM];
static const u16 *s_pStrMenu[ COPA_MENU_ELEMENT_NUM ] =
{
L"パラメータ設定",
L"Bを起動",
L"ランチャーに戻る",
};
static MenuPos s_menuPos[] = {
{ TRUE, 4 * 8, 8 * 8 },
{ TRUE, 4 * 8, 10 * 8 },
{ TRUE, 4 * 8, 12 * 8 },
{ TRUE, 4 * 8, 14 * 8 },
};
static const MenuParam s_menuParam = {
COPA_MENU_ELEMENT_NUM,
TXT_COLOR_BLACK,
TXT_COLOR_GREEN,
TXT_COLOR_RED,
&s_menuPos[ 0 ],
(const u16 **)&s_pStrMenu,
};
static const u16 *str_button_char[CHAR_LIST_MODE_NUM] = {
L"かな",
L"カナ",
L"英数",
};
static u16 next_char_mode[CHAR_LIST_MODE_NUM-1];
static const u16 str_button_del[] = L"<EFBFBD>DEL";
static const u16 str_button_space[] = L"SPACE";
static const u16 str_button_ok[] = L"OK";
static const u16 str_button_cancel[] = L"CANCEL";
static const u16 *str_button[] = {
(const u16 *)str_button_del,
(const u16 *)str_button_space,
NULL,
NULL,
(const u16 *)str_button_ok,
(const u16 *)str_button_cancel,
};
//======================================================
// アプリ連携テストプログラムA
//======================================================
// UTF16の文字列長算出
static u8 MY_StrLen( const u16 *pStr )
{
u8 len = 0;
while( *pStr++ ) {
++len;
if( len == 255 ) {
break;
}
}
return len;
}
static void SetSoftKeyboardButton(int mode)
{
int l;
int count = 0;
for(l=0; l<CHAR_LIST_MODE_NUM ;l++)
{
if(l != mode){
str_button[2+count]=str_button_char[l];
next_char_mode[count] = (u16)l;
count++;
}
}
s_work.char_mode = mode;
}
// ソフトウェアキー関係
// キーの表示
static void DrawCharKeys( void )
{
int l;
u16 code;
for( l=0; l<CHAR_LIST_CHAR_NUM; l++ )
{
int color=TXT_COLOR_BLACK;
code = char_tbl[s_work.char_mode][l];
if (s_work.key_csr == l) color = TXT_COLOR_GREEN;
if(code != EOM_)
{
if( (code >= CODE_BUTTON_TOP_) && (code < CODE_BUTTON_BOTTOM_) )
{
int x = code - CODE_BUTTON_TOP_;
PutStringUTF16( CLIST_LT_X + CLIST_MARGIN*(l%KEY_PER_LINE) + CLIST_SEGMENT_INTERVAL*((l%KEY_PER_LINE)/CLIST_KEY_PER_SEGMENT) ,
CLIST_LT_Y + CLIST_MARGIN*(l/KEY_PER_LINE) , color, str_button[x] );
}
else
{
u16 s[2];
s[0] = code;
s[1] = 0;
PutStringUTF16( CLIST_LT_X + CLIST_MARGIN*(l%KEY_PER_LINE) + CLIST_SEGMENT_INTERVAL*((l%KEY_PER_LINE)/CLIST_KEY_PER_SEGMENT) ,
CLIST_LT_Y + CLIST_MARGIN*(l/KEY_PER_LINE) , color, s );
}
}
}
}
// 一文字削除
static void DeleteACharacter( void )
{
u16 *buf;
u8 *length;
buf = s_work.temp_parameter;
length = &s_work.temp_parameter_length;
if(*length > 0) buf[--(*length)] = CHAR_USCORE;
}
static void MenuInit( void )
{
GX_DispOff();
GXS_DispOff();
NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_WHITE );
PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"CooperationA");
GetAndDrawRTCData( &g_rtcDraw, TRUE );
SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 );
GXS_SetVisiblePlane( GX_PLANEMASK_BG0 );
s_work.pNowProcess = MenuScene;
GX_DispOn();
GXS_DispOn();
}
// 選択中文字キー・特殊キーで決定した時の挙動
static void PushKeys( u16 code )
{
u16 *buf;
u8 *length;
u16 max_length;
buf = s_work.temp_parameter;
length = &s_work.temp_parameter_length;
max_length = PARAM_LENGTH;
if( (code >= CODE_BUTTON_TOP_) && (code < CODE_BUTTON_BOTTOM_) )
{
// 特殊キー
switch(code)
{
case VAR_BUTTON1_:
case VAR_BUTTON2_:
SetSoftKeyboardButton(next_char_mode[code - VAR_BUTTON1_]);
break;
case DEL_BUTTON_:
DeleteACharacter();
break;
case SPACE_BUTTON_:
if(*length < max_length) buf[(*length)++] = L' ';
break;
case OK_BUTTON_:
SVC_CpuClear(0, buf + *length, (max_length - *length) * 2, 16);// ゼロクリア
MI_CpuCopy8(buf, s_work.parameter, 2*(PARAM_LENGTH+1));
// セーブ後にキャンセル処理と合流
case CANCEL_BUTTON_:
MenuInit();
break;
default:// unknown code
break;
}
}
else
{
// 普通キー
if(*length < max_length) buf[(*length)++] = code;
}
}
// PadDetectOnKeyのSelectSomethingByTPで使うSelectSomethingFuncの実装
static BOOL SelectSoftwareKeyFunc( u16 *csr, TPData *tgt )
{
// まずは候補となる座標(カーソル単位)を取得
int csrx;
int csry;
int csrxy;
int a;
int b;
NNSG2dTextRect rect;
u16 code;
BOOL ret;
csrx = tgt->x - CLIST_LT_X;
csrx = csrx - (CLIST_SEGMENT_INTERVAL*(csrx/(CLIST_MARGIN*CLIST_KEY_PER_SEGMENT+CLIST_SEGMENT_INTERVAL)));
csrx = csrx / CLIST_MARGIN;
csry = (tgt->y - CLIST_LT_Y) / CLIST_MARGIN;
if(csrx < 0 ) return FALSE;
if ( csrx >= KEY_PER_LINE ) csrx = KEY_PER_LINE - 1;
csrxy = csrx + csry * KEY_PER_LINE;
if ( csrxy < 0 || csrxy >= CHAR_LIST_CHAR_NUM) return FALSE;// 明らかにはみ出した
// 候補座標のキーコード取得
code = char_tbl[s_work.char_mode][csrxy];
if(code == EOM_) return FALSE;
// 候補座標の領域取得
if( (code >= CODE_BUTTON_TOP_) && (code < CODE_BUTTON_BOTTOM_) )
{
int x = code - CODE_BUTTON_TOP_;
rect = NNS_G2dTextCanvasGetTextRect( &gTextCanvas, str_button[x] );
}
else
{
u16 s[2];
s[0] = code;
s[1] = 0;
// rect = NNS_G2dTextCanvasGetTextRect( &gTextCanvas, s );
// 文字幅じゃかなり判定が厳しい……ギリギリまでとってみる
rect.width = CLIST_MARGIN;
rect.height = CLIST_MARGIN;
}
a = CLIST_LT_X + CLIST_MARGIN*(csrxy%KEY_PER_LINE) + CLIST_SEGMENT_INTERVAL*((csrxy%KEY_PER_LINE)/CLIST_KEY_PER_SEGMENT);
b = CLIST_LT_Y + CLIST_MARGIN*(csrxy/KEY_PER_LINE);
// 候補座標の領域にタッチ座標が含まれているかチェック
ret = WithinRangeTP( a, b, a+rect.width, b+rect.height, tgt );
if(ret)
{
*csr = (u16)csrxy;
}
return ret;
}
// ソフトウェアキー上でのキーパッド及びタッチパッド処理
// 先にReadTPしておくこと。
static void PadDetectOnKey( void )
{
SelectSomethingFunc func[1];
BOOL tp_select = FALSE;
//--------------------------------------
// キー入力処理
//--------------------------------------
if( pad.trg & PAD_KEY_RIGHT ){ // カーソルの移動
do
{
if(s_work.key_csr%KEY_PER_LINE != KEY_PER_LINE-1) s_work.key_csr++;
else s_work.key_csr -= KEY_PER_LINE-1;
if( s_work.key_csr == CHAR_LIST_CHAR_NUM ) s_work.key_csr -= s_work.key_csr%KEY_PER_LINE;
}
while(char_tbl[s_work.char_mode][s_work.key_csr]==EOM_);
}
if( pad.trg & PAD_KEY_LEFT ){
do
{
if(s_work.key_csr%KEY_PER_LINE != 0) s_work.key_csr--;
else s_work.key_csr += KEY_PER_LINE-1;
if( s_work.key_csr & 0x8000 ) s_work.key_csr = KEY_PER_LINE-1;
}
while(char_tbl[s_work.char_mode][s_work.key_csr]==EOM_);
}
if( pad.trg & PAD_KEY_DOWN ){ // カーソルの移動
do
{
s_work.key_csr += KEY_PER_LINE;
if( s_work.key_csr >= CHAR_LIST_CHAR_NUM ) s_work.key_csr -= KEY_PER_LINE*(s_work.key_csr/KEY_PER_LINE);
}
while(char_tbl[s_work.char_mode][s_work.key_csr]==EOM_);
}
if( pad.trg & PAD_KEY_UP ){
do
{
if( s_work.key_csr < KEY_PER_LINE ) s_work.key_csr += (CHAR_LIST_CHAR_NUM/KEY_PER_LINE)*KEY_PER_LINE;
else s_work.key_csr -= KEY_PER_LINE;
if( s_work.key_csr >= CHAR_LIST_CHAR_NUM ) s_work.key_csr -= KEY_PER_LINE;
}
while(char_tbl[s_work.char_mode][s_work.key_csr]==EOM_);
}
func[0] = (SelectSomethingFunc)SelectSoftwareKeyFunc;
tp_select = SelectSomethingByTP(&s_work.key_csr, func, 1 );
if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) { // キーが押された
PushKeys( char_tbl[s_work.char_mode][s_work.key_csr] );
}else if( pad.trg & PAD_BUTTON_B ) {
DeleteACharacter();
}
}
// パラメータ編集画面の描画処理
static void DrawSetParameterScene( void )
{
NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL );
PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"PARAMETER" );
PutStringUTF16( 128-60 , 21 , TXT_UCOLOR_G0, s_work.temp_parameter );
DrawCharKeys();
}
// パラメータ編集の初期化
static void SetParameterInit( void )
{
SetSoftKeyboardButton(0);
s_work.key_csr = KEY_START;
// パラメータ用テンポラリバッファの初期化
MI_CpuCopy8(s_work.parameter, s_work.temp_parameter, 2*(PARAM_LENGTH+1));
s_work.temp_parameter_length = MY_StrLen( s_work.temp_parameter );
if( s_work.temp_parameter_length < PARAM_LENGTH ) {
SVC_CpuClear(CHAR_USCORE, &s_work.temp_parameter[ s_work.temp_parameter_length ],
( PARAM_LENGTH - s_work.temp_parameter_length ) * 2, 16);
}
DrawSetParameterScene();
SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 );
GX_SetVisiblePlane ( GX_PLANEMASK_BG0 );
GXS_SetVisiblePlane( GX_PLANEMASK_BG0 );
}
// パラメータ編集メイン
static void SetParameterMain( void )
{
ReadTP();
PadDetectOnKey();
// 描画処理
DrawSetParameterScene();
}
static void DrawMenuScene( void )
{
NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL );
PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"CooperationA");
PutStringUTF16( s_work.starx-6, s_work.stary-6, TXT_UCOLOR_G0, (const u16 *)L"");
PutStringUTF16( 128 , 8*8, TXT_UCOLOR_G0, s_work.parameter );
GetAndDrawRTCData( &g_rtcDraw, TRUE );
// メニュー項目
DrawMenu( s_work.csr, &s_menuParam );
PrintfSJIS( 1*8, 20*8, TXT_COLOR_BLACK, "★の位置:(%d,%d)",s_work.starx, s_work.stary);
}
static void MenuScene(void)
{
BOOL tp_select = FALSE;
static TPData tgt = (TPData){0,0,0,0};
BootFlags tempflag = {TRUE, 0, TRUE, FALSE, FALSE, FALSE, 0};
ReadTP();
//--------------------------------------
// キー入力処理
//--------------------------------------
if( pad.trg & PAD_KEY_DOWN ){ // カーソルの移動
if( ++s_work.csr == COPA_MENU_ELEMENT_NUM ) {
s_work.csr=0;
}
}
if( pad.trg & PAD_KEY_UP ){
if( --s_work.csr & 0x80 ) {
s_work.csr=COPA_MENU_ELEMENT_NUM - 1;
}
}
tp_select = SelectMenuByTP( &s_work.csr, &s_menuParam );
if(tpd.disp.touch)
{
tgt = tpd.disp;
if(s_work.starx != tgt.x) s_work.starx += (((tgt.x - s_work.starx)>>3) + ((tgt.x > s_work.starx) ? 1 : -1) );
if(s_work.stary != tgt.y) s_work.stary += (((tgt.y - s_work.stary)>>3) + ((tgt.y > s_work.stary) ? 1 : -1) );
}
DrawMenuScene();
if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) { // メニュー項目への分岐
if( s_menuPos[ s_work.csr ].enable ) {
switch( s_work.csr ) {
case 0:
SetParameterInit();
s_work.pNowProcess = SetParameterMain;
break;
case 1:
// 現在のアプリ状態をセーブ
{
FSFile f;
FS_InitFile(&f);
if(!FS_SetCurrentDirectory("dataPrv:/")) {MI_CpuCopy8(L"ライトエラー1",s_work.parameter,14); break;}
FS_CreateFile("test.dat", FS_PERMIT_R | FS_PERMIT_W );
if(!FS_OpenFileEx(&f, "test.dat", FS_FILEMODE_W)) {MI_CpuCopy8(L"ライトエラー2",s_work.parameter,14); break;}
if(-1 == FS_WriteFile(&f, &s_work, sizeof(s_work))) {MI_CpuCopy8(L"ライトエラー3",s_work.parameter,14); break;}
if(!FS_CloseFile( &f )) {MI_CpuCopy8(L"ライトエラー4",s_work.parameter,14); break;}
}
// アプリ間パラメータをセット
{
OSDeliverArgInfo *arginfo = (OSDeliverArgInfo *)HW_PARAM_DELIVER_ARG;
// メーカーコードとゲームコードのセット(Launcher側でやるべき)
u16 *maker_code_src_addr = (u16 *)(HW_TWL_ROM_HEADER_BUF + 0x10);
u32 *game_code_src_addr = (u32 *)(HW_TWL_ROM_HEADER_BUF + 0xc);
arginfo->makerCode = *maker_code_src_addr;
// まだゲームコードは証明書の関係でNTRJしか入ってない……ので強制的に値代入
//arginfo->gameCode = *game_code_src_addr;
arginfo->gameCode = 0x41504f43; // 下位から'C','O','P','A'
// アプリ専用部分のセット
MI_CpuCopy8(s_work.parameter, arginfo->buf, 2*(PARAM_LENGTH+1));
}
//B起動
OS_SetResetParamAndResetHardware( 0, 0x00010001434f5042, &tempflag );
break;
case 2:
OS_SetResetParamAndResetHardware( 0, NULL, &tempflag );
//再起動
break;
}
}
}
}
// 初期化
void CooperationAInit( void )
{
ChangeUserColor( TSD_GetUserColor() );
s_work.parameter[0] = 0;
MenuInit();
{
OSDeliverArgInfo *arginfo = (OSDeliverArgInfo *)HW_PARAM_DELIVER_ARG;
if(arginfo->gameCode != NULL)
{
if(STD_CompareNString((const char *)arginfo->buf, "-r", 3) == 0)
{
// セーブしたデータから復帰
FSFile f;
FS_InitFile(&f);
if(!FS_SetCurrentDirectory("dataPrv:/")) {MI_CpuCopy8(L"リードエラー1",s_work.parameter,14); return;}
if(!FS_OpenFileEx(&f, "test.dat", FS_FILEMODE_R)) {return;}
if(-1 == FS_ReadFile(&f, &s_work, sizeof(s_work))) {MI_CpuCopy8(L"リードエラー2",s_work.parameter,14); return;}
if(!FS_CloseFile( &f )) {MI_CpuCopy8(L"リードエラー3",s_work.parameter,14); return;}
}
}
}
}
// メインループ
void CooperationAMain(void)
{
s_work.pNowProcess();
}
//======================================================
// ソフトウェアキーボード用キャラテーブル
//======================================================
static const u16 char_tbl[CHAR_LIST_MODE_NUM][CHAR_LIST_CHAR_NUM] = {
{ // ひらがな
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', DEL_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', SPACE_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', L'', L'', L'', L'',
L'', EOM_, L'', EOM_, L'', VAR_BUTTON1_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', VAR_BUTTON2_,
L'', L'', L'', L'', L'',
L'', EOM_, L'', EOM_, L'', EOM_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', OK_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', L'', L'', L'', L'',
EOM_, EOM_, EOM_, EOM_, EOM_, CANCEL_BUTTON_,
EOM_, EOM_, EOM_, EOM_, EOM_,
EOM_, EOM_, EOM_, EOM_, EOM_,
},
{ // カタカナ
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', DEL_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', SPACE_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', L'', L'', L'', L'',
L'', EOM_, L'', EOM_, L'', VAR_BUTTON1_,
L'', L'', L'', L'', L'',
L'', EOM_, L'', EOM_, L'', VAR_BUTTON2_,
L'', L'', L'', L'', L'',
L'', EOM_, L'', EOM_, L'', EOM_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', OK_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', L'', L'', L'', EOM_,
EOM_, EOM_, EOM_, EOM_, EOM_, CANCEL_BUTTON_,
EOM_, EOM_, EOM_, EOM_, EOM_,
EOM_, EOM_, EOM_, EOM_, EOM_,
},
{ // 英数
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', DEL_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', SPACE_BUTTON_,
L'', L'', L'', L'', L'',
L'', EOM_, EOM_, EOM_, EOM_, EOM_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', VAR_BUTTON1_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', VAR_BUTTON2_,
L'', L'', L'', L'', L'',
L'', EOM_, EOM_, EOM_, EOM_, EOM_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', EOM_, L'', EOM_, L'',
L'', EOM_, L'', EOM_, L'', OK_BUTTON_,
L'', EOM_, L'', EOM_, EOM_,
L'', EOM_, L'', EOM_, L'', EOM_,
EOM_, EOM_, EOM_, EOM_, EOM_,
EOM_, EOM_, EOM_, EOM_, EOM_, CANCEL_BUTTON_,
EOM_, EOM_, EOM_, EOM_, EOM_,
EOM_, EOM_, EOM_, EOM_, EOM_,
},
};

View File

@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File: CooperationA.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:: 2007-10-30#$
$Rev: 73 $
$Author: yosiokat $
*---------------------------------------------------------------------------*/
#ifndef __COOPERATION_A_H__
#define __COOPERATION_A_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <twl.h>
// define data----------------------------------------------------------
void CooperationAInit( void );
void CooperationAMain( void );
#ifdef __cplusplus
}
#endif
#endif // __COOPERATION_A_H__

View File

@ -0,0 +1,109 @@
/*---------------------------------------------------------------------------*
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:: 2007-11-27#$
$Rev: 272 $
$Author: yosiokat $
*---------------------------------------------------------------------------*/
#include <twl.h>
#include "misc.h"
#include "CooperationA.h"
// extern data-----------------------------------------------------------------
// define data-----------------------------------------------------------------
// function's prototype-------------------------------------------------------
static void INTR_VBlank( void );
// global variable-------------------------------------------------------------
// static variable-------------------------------------------------------------
BOOL g_isValidTSD;
RTCDrawProperty g_rtcDraw = {
TRUE, RTC_DATE_TOP_X, RTC_DATE_TOP_Y, RTC_TIME_TOP_X, RTC_TIME_TOP_Y
};
// const data------------------------------------------------------------------
// ============================================================================
// function's description
// ============================================================================
void TwlMain(void)
{
// 初期化----------------------------------
OS_Init();
OS_InitTick();
(void)OS_EnableIrq();
(void)OS_EnableInterrupts();
GX_Init();
GX_SetPower(GX_POWER_ALL); // 各ロジック パワーON
FS_Init( 3 );
// 割り込み許可----------------------------
(void)OS_SetIrqFunction(OS_IE_V_BLANK, INTR_VBlank);
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
(void)GX_VBlankIntr(TRUE);
// デバイス初期化-------------------------------
TP_Init();
(void)RTC_Init();
// システムの初期化------------------
InitAllocator();
// ※本来ならランチャーからのパラメータチェックを行い、
// 初回起動シーケンスに入るパスがある
// TWL設定のリード
SYSM_SetAllocFunc( Alloc, Free ); // SYSM_ReadTWLSettingsFile()の実行に必要。
// ::::::::::::::::::::::::::::::::::::::::::::::
// TWL設定データファイルの読み込み
// ::::::::::::::::::::::::::::::::::::::::::::::
(void)THW_ReadSecureInfo();
g_isValidTSD = SYSM_ReadTWLSettingsFile();
if( g_isValidTSD ) {
SYSM_CaribrateTP();
}
InitBG();
GetAndDrawRTCData( &g_rtcDraw, TRUE );
CooperationAInit();
// メインループ----------------------------
while(1){
OS_WaitIrq(1, OS_IE_V_BLANK); // Vブランク割り込み待ち
ReadKeyPad(); // キー入力の取得
ReadTP(); // TP入力の取得
CooperationAMain();
}
}
// ============================================================================
// 割り込み処理
// ============================================================================
// Vブランク割り込み
static void INTR_VBlank(void)
{
OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Vブランク割込チェックのセット
}

View File

@ -0,0 +1,30 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL
# File: Makefile
#
# 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:: 2007-10-03#$
# $Rev: 1319 $
# $Author: kitase_hirotake $
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = banner ARM9
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,49 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL
# File: Makefile
#
# 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:: 2007-10-03#$
# $Rev: 1319 $
# $Author: kitase_hirotake $
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
ICON_DIR = ./icon
BANNER_ICON = $(ICON_DIR)/gameIcon.bmp
BANNER_SPEC = banner_v3.bsf
TARGETS = banner.bnr
INSTALL_DIR = ./
INSTALL_TARGETS = $(TARGETS)
BANNER_ICON_NAME = $(basename $(BANNER_ICON))
LDIRT_CLEAN = $(TARGETS) \
$(BANNER_ICON_NAME).nbfs \
$(BANNER_ICON_NAME).nbfc \
$(BANNER_ICON_NAME).nbfp \
$(TARGETS:.bnr=.srl)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#----------------------------------------------------------------------------
# build
#----------------------------------------------------------------------------
do-build: $(TARGETS)
$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON)
$(NTEXCONV) -no -bg -bgb -bgnc $(BANNER_ICON) >/dev/null && \
$(MAKEBANNER) -d -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS)
#

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

View File

@ -0,0 +1,59 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlSDK - demos - simpleShoot-1
# File: Makefile
#
# 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: $
#----------------------------------------------------------------------------
SUBDIRS =
#----------------------------------------------------------------------------
TARGET_FIRM = SYSTEMMENU
TARGET_PLATFORM = TWL
TWL_ARCHGEN = LIMITED
TITLEID_LO = COPB
TARGET_TAD = $(BINDIR)/$(TITLEID_LO).tad
TARGET_BIN = main.srl
ROM_SPEC = main.rsf
MISC_DIR = $(TWL_IPL_RED_ROOT)/build/systemMenu_RED/misc
SRCS = main.c CooperationB.c \
$(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c
LINCLUDES = $(MISC_DIR)/include
MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)'
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
LDIRT_CLEAN = $(TARGET_TAD)
INSTALL_TARGETS = $(TARGET_TAD)
INSTALL_DIR = $(SDK_NMENU_DATADIR)
#----------------------------------------------------------------------------
do-build : $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#----------------------------------------------------------------------------
#===== End of Makefile =====

View File

@ -0,0 +1,154 @@
#----------------------------------------------------------------------------
# Project: TwlSDK - include
# File: ROM-BB.rsf
#
# Copyright 2007 Nintendo. All rights reserved.
#
# These coded insructions, 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:: 2007-11-21#$
# $Rev: 240 $
# $Author: yosiokat $
#----------------------------------------------------------------------------
#
# TWL ROM SPEC FILE
#
Arm9
{
Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)"
OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)"
OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)"
Elf "$(MAKEROM_ARM9:r).tef"
}
Arm7
{
Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)"
OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)"
OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)"
Elf "$(MAKEROM_ARM7_BASE:r).tef"
}
Arm9.Ltd
{
Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)"
OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)"
OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)"
}
Arm7.Ltd
{
Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)"
OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)"
OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)"
}
Property
{
###
### Settings for FinalROM
###
#### BEGIN
#
# TITLE NAME: Your product name within 12bytes
#
#TitleName "YourAppName"
#_GameCode $(TITLEID_LO)
#
# MAKER CODE: Your company ID# in 2 ascii words
# issued by NINTENDO
#
#MakerCode "00"
#
# REMASTER VERSION: Mastering version
#
#RomVersion 0
#
# ROM SPEED TYPE: [MROM/1TROM/UNDEFINED]
#
RomSpeedType $(MAKEROM_ROMSPEED)
#
# ROM SIZE: in bit [64M/128M/256M/512M/1G/2G]
#
#RomSize 128M
#RomSize 256M
#
# ROM PADDING: TRUE if finalrom
#
#RomFootPadding TRUE
#
# ROM HEADER TEMPLATE: Provided to every product by NINTENDO
#
#RomHeaderTemplate ./etc/rom_header.template.sbin
#
# BANNER FILE: generated from Banner Spec File
#
BannerFile ../banner/banner.bnr
###
### Setting for TWL
###
#
# BANNER FILE:
#
BannerTWLFile $(TWLSDK_ROOT)/include/twl/specfiles/default.bnr
#
# Boot allowed Media: [GameCard/NAND/SDCard/DownloadPlay]
# possible to choose one or more.
#
BootMedia GameCard NAND SDCard DownloadPlay
#
# Certification FILE:
#
Certificate $(TWLSDK_ROOT)/include/twl/specfiles/default_sgn.sbin
#Certificate ./my_sgn.sbin
#
# Digest parameters:
#
DigestParam 1024 32
#
# WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD]
# don't have to edit
#
WramMapping $(MAKEROM_WRAM_MAPPING)
#
# Codec mode:
# don't have to edit
#
CodecMode $(MAKEROM_CODEC_MODE)
TitleID_Lo $(TITLEID_LO)
TitleID_Hi 0x00010001
# PrivateSaveDataSize 16K
# PublicSaveDataSize 16K
###
#### END
}
RomSpec
{
Offset 0x00000000
Segment ALL
HostRoot $(TWL_IPL_RED_ROOT)/build/systemMenu_RED/data
Root /data
File NTR_IPL_font_m.NFTR
}

View File

@ -0,0 +1,185 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File: CooperationB.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:: 2007-10-31#$
$Rev: 91 $
$Author: yosiokat $
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <sysmenu.h>
#include "misc.h"
#include "CooperationB.h"
// define data------------------------------------------
#define RETURN_BUTTON_TOP_X 2
#define RETURN_BUTTON_TOP_Y 21
#define RETURN_BUTTON_BOTTOM_X ( RETURN_BUTTON_TOP_X + 8 )
#define RETURN_BUTTON_BOTTOM_Y ( RETURN_BUTTON_TOP_Y + 2 )
#define COPB_MENU_ELEMENT_NUM 2 // メニューの項目数
#define PARAM_LENGTH 10
// extern data------------------------------------------
// function's prototype declaration---------------------
static void MenuScene( void );
// global variable -------------------------------------
extern RTCDrawProperty g_rtcDraw;
// static variable -------------------------------------
static u16 s_csr = 0;
static u16 s_parameter[ PARAM_LENGTH + 1 ];
static void(*s_pNowProcess)(void);
static u32 invGameCode;
// const data -----------------------------------------
static const u16 *s_pStrMenu[ COPB_MENU_ELEMENT_NUM ] =
{
L"呼び出し元アプリを起動",
L"ランチャーに戻る",
};
static MenuPos s_menuPos[] = {
{ FALSE, 4 * 8, 8 * 8 },
{ TRUE, 4 * 8, 10 * 8 },
};
static const MenuParam s_menuParam = {
COPB_MENU_ELEMENT_NUM,
TXT_COLOR_BLACK,
TXT_COLOR_GREEN,
TXT_COLOR_RED,
&s_menuPos[ 0 ],
(const u16 **)&s_pStrMenu,
};
//======================================================
// アプリ連携テストプログラムB
//======================================================
static void DrawMenuScene( void )
{
PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"CooperationB");
PutStringUTF16( 1*8, 18*8, TXT_COLOR_BLACK, (const u16 *)L"受け取ったパラメータ:");
PutStringUTF16( 3 * 8 , 20*8, TXT_UCOLOR_G0, s_parameter );
PutStringUTF16( 1*8, 14*8, TXT_COLOR_BLACK, (const u16 *)L"呼び出し元アプリ:");
PrintfSJIS(3*8, 16*8, TXT_COLOR_BLACK, "0x%llx",(u64)0x0001000100000000 + invGameCode);
GetAndDrawRTCData( &g_rtcDraw, TRUE );
// メニュー項目
DrawMenu( s_csr, &s_menuParam );
}
static void MenuInit( void )
{
GX_DispOff();
GXS_DispOff();
NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_WHITE );
PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"CooperationB");
GetAndDrawRTCData( &g_rtcDraw, TRUE );
SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 );
GXS_SetVisiblePlane( GX_PLANEMASK_BG0 );
s_pNowProcess = MenuScene;
MI_CpuClear8(s_parameter, 2*(PARAM_LENGTH+1));
{
OSDeliverArgInfo *arginfo = (OSDeliverArgInfo *)HW_PARAM_DELIVER_ARG;
u8 *gc = (u8 *)&arginfo->gameCode;
invGameCode = (u32)(gc[0]<<24) + (u32)(gc[1]<<16) + (u32)(gc[2]<<8) + (u32)gc[3];
if(invGameCode != NULL)
{
s_menuPos[ 0 ].enable = TRUE;
MI_CpuCopy8(arginfo->buf, s_parameter, 2*(PARAM_LENGTH+1));
}
}
DrawMenuScene();
GX_DispOn();
GXS_DispOn();
}
static void MenuScene(void)
{
BOOL tp_select = FALSE;
BootFlags tempflag = {TRUE, 0, TRUE, FALSE, FALSE, FALSE, 0};
ReadTP();
//--------------------------------------
// キー入力処理
//--------------------------------------
if( pad.trg & PAD_KEY_DOWN ){ // カーソルの移動
if( ++s_csr == COPB_MENU_ELEMENT_NUM ) {
s_csr=0;
}
}
if( pad.trg & PAD_KEY_UP ){
if( --s_csr & 0x80 ) {
s_csr=COPB_MENU_ELEMENT_NUM - 1;
}
}
tp_select = SelectMenuByTP( &s_csr, &s_menuParam );
DrawMenuScene();
if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) { // メニュー項目への分岐
if( s_menuPos[ s_csr ].enable ) {
switch( s_csr ) {
case 0:
if(invGameCode != NULL)
{
// アプリ間パラメータをセット
OSDeliverArgInfo *arginfo = (OSDeliverArgInfo *)HW_PARAM_DELIVER_ARG;
// メーカーコードとゲームコードのセット(Launcher側でやるべき)
u16 *maker_code_src_addr = (u16 *)(HW_TWL_ROM_HEADER_BUF + 0x10);
u32 *game_code_src_addr = (u32 *)(HW_TWL_ROM_HEADER_BUF + 0xc);
arginfo->makerCode = *maker_code_src_addr;
arginfo->gameCode = *game_code_src_addr;
// アプリ専用部分のセット
MI_CpuCopy8("-r", arginfo->buf, 3);
//呼び出し元アプリ起動
OS_SetResetParamAndResetHardware( 0, (u64)0x0001000100000000 + invGameCode, &tempflag );
//OS_SetResetParamAndResetHardware( 0, (u64)0x00010001434f5041, &tempflag );
}
break;
case 1:
OS_SetResetParamAndResetHardware( 0, NULL, &tempflag );
//再起動
break;
}
}
}
}
// 初期化
void CooperationBInit( void )
{
ChangeUserColor( TSD_GetUserColor() );
s_parameter[0] = 0;
MenuInit();
}
// メインループ
void CooperationBMain(void)
{
s_pNowProcess();
}

View File

@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File: CooperationB.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:: 2007-10-30#$
$Rev: 73 $
$Author: yosiokat $
*---------------------------------------------------------------------------*/
#ifndef __COOPERATION_B_H__
#define __COOPERATION_B_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <twl.h>
// define data----------------------------------------------------------
void CooperationBInit( void );
void CooperationBMain( void );
#ifdef __cplusplus
}
#endif
#endif // __COOPERATION_B_H__

View File

@ -0,0 +1,109 @@
/*---------------------------------------------------------------------------*
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:: 2007-11-27#$
$Rev: 272 $
$Author: yosiokat $
*---------------------------------------------------------------------------*/
#include <twl.h>
#include "misc.h"
#include "CooperationB.h"
// extern data-----------------------------------------------------------------
// define data-----------------------------------------------------------------
// function's prototype-------------------------------------------------------
static void INTR_VBlank( void );
// global variable-------------------------------------------------------------
// static variable-------------------------------------------------------------
BOOL g_isValidTSD;
RTCDrawProperty g_rtcDraw = {
TRUE, RTC_DATE_TOP_X, RTC_DATE_TOP_Y, RTC_TIME_TOP_X, RTC_TIME_TOP_Y
};
// const data------------------------------------------------------------------
// ============================================================================
// function's description
// ============================================================================
void TwlMain(void)
{
// 初期化----------------------------------
OS_Init();
OS_InitTick();
(void)OS_EnableIrq();
(void)OS_EnableInterrupts();
GX_Init();
GX_SetPower(GX_POWER_ALL); // 各ロジック パワーON
FS_Init( 3 );
// 割り込み許可----------------------------
(void)OS_SetIrqFunction(OS_IE_V_BLANK, INTR_VBlank);
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
(void)GX_VBlankIntr(TRUE);
// デバイス初期化-------------------------------
TP_Init();
(void)RTC_Init();
// システムの初期化------------------
InitAllocator();
// ※本来ならランチャーからのパラメータチェックを行い、
// 初回起動シーケンスに入るパスがある
// TWL設定のリード
SYSM_SetAllocFunc( Alloc, Free ); // SYSM_ReadTWLSettingsFile()の実行に必要。
// ::::::::::::::::::::::::::::::::::::::::::::::
// TWL設定データファイルの読み込み
// ::::::::::::::::::::::::::::::::::::::::::::::
(void)THW_ReadSecureInfo();
g_isValidTSD = SYSM_ReadTWLSettingsFile();
if( g_isValidTSD ) {
SYSM_CaribrateTP();
}
InitBG();
GetAndDrawRTCData( &g_rtcDraw, TRUE );
CooperationBInit();
// メインループ----------------------------
while(1){
OS_WaitIrq(1, OS_IE_V_BLANK); // Vブランク割り込み待ち
ReadKeyPad(); // キー入力の取得
ReadTP(); // TP入力の取得
CooperationBMain();
}
}
// ============================================================================
// 割り込み処理
// ============================================================================
// Vブランク割り込み
static void INTR_VBlank(void)
{
OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Vブランク割込チェックのセット
}

View File

@ -0,0 +1,30 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL
# File: Makefile
#
# 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:: 2007-10-03#$
# $Rev: 1319 $
# $Author: kitase_hirotake $
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = banner ARM9
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,49 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL
# File: Makefile
#
# 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:: 2007-10-03#$
# $Rev: 1319 $
# $Author: kitase_hirotake $
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
ICON_DIR = ./icon
BANNER_ICON = $(ICON_DIR)/gameIcon.bmp
BANNER_SPEC = banner_v3.bsf
TARGETS = banner.bnr
INSTALL_DIR = ./
INSTALL_TARGETS = $(TARGETS)
BANNER_ICON_NAME = $(basename $(BANNER_ICON))
LDIRT_CLEAN = $(TARGETS) \
$(BANNER_ICON_NAME).nbfs \
$(BANNER_ICON_NAME).nbfc \
$(BANNER_ICON_NAME).nbfp \
$(TARGETS:.bnr=.srl)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#----------------------------------------------------------------------------
# build
#----------------------------------------------------------------------------
do-build: $(TARGETS)
$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON)
$(NTEXCONV) -no -bg -bgb -bgnc $(BANNER_ICON) >/dev/null && \
$(MAKEBANNER) -d -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS)
#

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

View File

@ -0,0 +1,59 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlSDK - demos - simpleShoot-1
# File: Makefile
#
# 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: $
#----------------------------------------------------------------------------
SUBDIRS =
#----------------------------------------------------------------------------
TARGET_FIRM = SYSTEMMENU
TARGET_PLATFORM = TWL
TWL_ARCHGEN = LIMITED
TITLEID_LO = COPC
TARGET_TAD = $(BINDIR)/$(TITLEID_LO).tad
TARGET_BIN = main.srl
ROM_SPEC = main.rsf
MISC_DIR = $(TWL_IPL_RED_ROOT)/build/systemMenu_RED/misc
SRCS = main.c CooperationC.c \
$(MISC_DIR)/src/misc.c $(MISC_DIR)/src/cmn.c
LINCLUDES = $(MISC_DIR)/include
MAKEROM_FLAGS += -DTITLEID_LO='$(TITLEID_LO)'
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
LDIRT_CLEAN = $(TARGET_TAD)
INSTALL_TARGETS = $(TARGET_TAD)
INSTALL_DIR = $(SDK_NMENU_DATADIR)
#----------------------------------------------------------------------------
do-build : $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#----------------------------------------------------------------------------
#===== End of Makefile =====

View File

@ -0,0 +1,154 @@
#----------------------------------------------------------------------------
# Project: TwlSDK - include
# File: ROM-BB.rsf
#
# Copyright 2007 Nintendo. All rights reserved.
#
# These coded insructions, 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:: 2007-11-21#$
# $Rev: 240 $
# $Author: yosiokat $
#----------------------------------------------------------------------------
#
# TWL ROM SPEC FILE
#
Arm9
{
Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)"
OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)"
OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)"
Elf "$(MAKEROM_ARM9:r).tef"
}
Arm7
{
Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)"
OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)"
OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)"
Elf "$(MAKEROM_ARM7_BASE:r).tef"
}
Arm9.Ltd
{
Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)"
OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)"
OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)"
}
Arm7.Ltd
{
Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)"
OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)"
OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)"
}
Property
{
###
### Settings for FinalROM
###
#### BEGIN
#
# TITLE NAME: Your product name within 12bytes
#
#TitleName "YourAppName"
#_GameCode $(TITLEID_LO)
#
# MAKER CODE: Your company ID# in 2 ascii words
# issued by NINTENDO
#
#MakerCode "00"
#
# REMASTER VERSION: Mastering version
#
#RomVersion 0
#
# ROM SPEED TYPE: [MROM/1TROM/UNDEFINED]
#
RomSpeedType $(MAKEROM_ROMSPEED)
#
# ROM SIZE: in bit [64M/128M/256M/512M/1G/2G]
#
#RomSize 128M
#RomSize 256M
#
# ROM PADDING: TRUE if finalrom
#
#RomFootPadding TRUE
#
# ROM HEADER TEMPLATE: Provided to every product by NINTENDO
#
#RomHeaderTemplate ./etc/rom_header.template.sbin
#
# BANNER FILE: generated from Banner Spec File
#
BannerFile ../banner/banner.bnr
###
### Setting for TWL
###
#
# BANNER FILE:
#
BannerTWLFile $(TWLSDK_ROOT)/include/twl/specfiles/default.bnr
#
# Boot allowed Media: [GameCard/NAND/SDCard/DownloadPlay]
# possible to choose one or more.
#
BootMedia GameCard NAND SDCard DownloadPlay
#
# Certification FILE:
#
Certificate $(TWLSDK_ROOT)/include/twl/specfiles/default_sgn.sbin
#Certificate ./my_sgn.sbin
#
# Digest parameters:
#
DigestParam 1024 32
#
# WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD]
# don't have to edit
#
WramMapping $(MAKEROM_WRAM_MAPPING)
#
# Codec mode:
# don't have to edit
#
CodecMode $(MAKEROM_CODEC_MODE)
TitleID_Lo $(TITLEID_LO)
TitleID_Hi 0x00010001
PrivateSaveDataSize 16K
# PublicSaveDataSize 16K
###
#### END
}
RomSpec
{
Offset 0x00000000
Segment ALL
HostRoot $(TWL_IPL_RED_ROOT)/build/systemMenu_RED/data
Root /data
File NTR_IPL_font_m.NFTR
}

View File

@ -0,0 +1,633 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File: CooperationC.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:: 2007-10-31#$
$Rev: 91 $
$Author: yosiokat $
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <sysmenu.h>
#include "misc.h"
#include "CooperationC.h"
// define data------------------------------------------
#define RETURN_BUTTON_TOP_X 2
#define RETURN_BUTTON_TOP_Y 21
#define RETURN_BUTTON_BOTTOM_X ( RETURN_BUTTON_TOP_X + 8 )
#define RETURN_BUTTON_BOTTOM_Y ( RETURN_BUTTON_TOP_Y + 2 )
// ソフトウェアキーボードLCD領域
#define CLIST_LT_X 23
#define CLIST_LT_Y 50
#define CLIST_MARGIN 14
#define CLIST_KEY_PER_SEGMENT 5
#define CLIST_SEGMENT_INTERVAL 7
#define COPA_MENU_ELEMENT_NUM 3 // メニューの項目数
#define CHAR_LIST_CHAR_NUM 120
#define CHAR_LIST_MODE_NUM 3
// 特殊キーコード
#define EOM_ (u16)0xe050
#define CODE_BUTTON_TOP_ (u16)0xe051
#define DEL_BUTTON_ (u16)0xe051
#define SPACE_BUTTON_ (u16)0xe052
#define VAR_BUTTON1_ (u16)0xe053
#define VAR_BUTTON2_ (u16)0xe054
#define OK_BUTTON_ (u16)0xe055
#define CANCEL_BUTTON_ (u16)0xe056
#define CODE_BUTTON_BOTTOM_ (u16)0xe057
#define CHAR_USCORE L'_'
#define KEY_PER_LINE 11
#define KEY_START 109 //ソフトウェアキーのカーソルデフォルト位置はキャンセルキー
#define KEY_OK 0xffff
#define KEY_CANCEL 0xfffe
#define PARAM_LENGTH 10
typedef struct CopA_Work
{
u16 csr;
int char_mode;
u16 key_csr;
u16 parameter[ PARAM_LENGTH + 1 ];
u16 temp_parameter[ PARAM_LENGTH + 1 ];
u8 temp_parameter_length;
void(*pNowProcess)(void);
int starx,stary;
} CopA_Work;
// extern data------------------------------------------
// function's prototype declaration---------------------
static void MenuScene( void );
// global variable -------------------------------------
extern RTCDrawProperty g_rtcDraw;
// static variable -------------------------------------
static CopA_Work s_work = (CopA_Work){0,0,0,L"",L"",0,0,0};
// const data -----------------------------------------
static const u16 char_tbl[CHAR_LIST_MODE_NUM][CHAR_LIST_CHAR_NUM];
static const u16 *s_pStrMenu[ COPA_MENU_ELEMENT_NUM ] =
{
L"パラメータ設定",
L"Bを起動",
L"ランチャーに戻る",
};
static MenuPos s_menuPos[] = {
{ TRUE, 4 * 8, 8 * 8 },
{ TRUE, 4 * 8, 10 * 8 },
{ TRUE, 4 * 8, 12 * 8 },
{ TRUE, 4 * 8, 14 * 8 },
};
static const MenuParam s_menuParam = {
COPA_MENU_ELEMENT_NUM,
TXT_COLOR_BLACK,
TXT_COLOR_GREEN,
TXT_COLOR_RED,
&s_menuPos[ 0 ],
(const u16 **)&s_pStrMenu,
};
static const u16 *str_button_char[CHAR_LIST_MODE_NUM] = {
L"かな",
L"カナ",
L"英数",
};
static u16 next_char_mode[CHAR_LIST_MODE_NUM-1];
static const u16 str_button_del[] = L"<EFBFBD>DEL";
static const u16 str_button_space[] = L"SPACE";
static const u16 str_button_ok[] = L"OK";
static const u16 str_button_cancel[] = L"CANCEL";
static const u16 *str_button[] = {
(const u16 *)str_button_del,
(const u16 *)str_button_space,
NULL,
NULL,
(const u16 *)str_button_ok,
(const u16 *)str_button_cancel,
};
//======================================================
// アプリ連携テストプログラムA
//======================================================
// UTF16の文字列長算出
static u8 MY_StrLen( const u16 *pStr )
{
u8 len = 0;
while( *pStr++ ) {
++len;
if( len == 255 ) {
break;
}
}
return len;
}
static void SetSoftKeyboardButton(int mode)
{
int l;
int count = 0;
for(l=0; l<CHAR_LIST_MODE_NUM ;l++)
{
if(l != mode){
str_button[2+count]=str_button_char[l];
next_char_mode[count] = (u16)l;
count++;
}
}
s_work.char_mode = mode;
}
// ソフトウェアキー関係
// キーの表示
static void DrawCharKeys( void )
{
int l;
u16 code;
for( l=0; l<CHAR_LIST_CHAR_NUM; l++ )
{
int color=TXT_COLOR_BLACK;
code = char_tbl[s_work.char_mode][l];
if (s_work.key_csr == l) color = TXT_COLOR_GREEN;
if(code != EOM_)
{
if( (code >= CODE_BUTTON_TOP_) && (code < CODE_BUTTON_BOTTOM_) )
{
int x = code - CODE_BUTTON_TOP_;
PutStringUTF16( CLIST_LT_X + CLIST_MARGIN*(l%KEY_PER_LINE) + CLIST_SEGMENT_INTERVAL*((l%KEY_PER_LINE)/CLIST_KEY_PER_SEGMENT) ,
CLIST_LT_Y + CLIST_MARGIN*(l/KEY_PER_LINE) , color, str_button[x] );
}
else
{
u16 s[2];
s[0] = code;
s[1] = 0;
PutStringUTF16( CLIST_LT_X + CLIST_MARGIN*(l%KEY_PER_LINE) + CLIST_SEGMENT_INTERVAL*((l%KEY_PER_LINE)/CLIST_KEY_PER_SEGMENT) ,
CLIST_LT_Y + CLIST_MARGIN*(l/KEY_PER_LINE) , color, s );
}
}
}
}
// 一文字削除
static void DeleteACharacter( void )
{
u16 *buf;
u8 *length;
buf = s_work.temp_parameter;
length = &s_work.temp_parameter_length;
if(*length > 0) buf[--(*length)] = CHAR_USCORE;
}
static void MenuInit( void )
{
GX_DispOff();
GXS_DispOff();
NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_WHITE );
PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"CooperationC");
GetAndDrawRTCData( &g_rtcDraw, TRUE );
SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 );
GXS_SetVisiblePlane( GX_PLANEMASK_BG0 );
s_work.pNowProcess = MenuScene;
GX_DispOn();
GXS_DispOn();
}
// 選択中文字キー・特殊キーで決定した時の挙動
static void PushKeys( u16 code )
{
u16 *buf;
u8 *length;
u16 max_length;
buf = s_work.temp_parameter;
length = &s_work.temp_parameter_length;
max_length = PARAM_LENGTH;
if( (code >= CODE_BUTTON_TOP_) && (code < CODE_BUTTON_BOTTOM_) )
{
// 特殊キー
switch(code)
{
case VAR_BUTTON1_:
case VAR_BUTTON2_:
SetSoftKeyboardButton(next_char_mode[code - VAR_BUTTON1_]);
break;
case DEL_BUTTON_:
DeleteACharacter();
break;
case SPACE_BUTTON_:
if(*length < max_length) buf[(*length)++] = L' ';
break;
case OK_BUTTON_:
SVC_CpuClear(0, buf + *length, (max_length - *length) * 2, 16);// ゼロクリア
MI_CpuCopy8(buf, s_work.parameter, 2*(PARAM_LENGTH+1));
// セーブ後にキャンセル処理と合流
case CANCEL_BUTTON_:
MenuInit();
break;
default:// unknown code
break;
}
}
else
{
// 普通キー
if(*length < max_length) buf[(*length)++] = code;
}
}
// PadDetectOnKeyのSelectSomethingByTPで使うSelectSomethingFuncの実装
static BOOL SelectSoftwareKeyFunc( u16 *csr, TPData *tgt )
{
// まずは候補となる座標(カーソル単位)を取得
int csrx;
int csry;
int csrxy;
int a;
int b;
NNSG2dTextRect rect;
u16 code;
BOOL ret;
csrx = tgt->x - CLIST_LT_X;
csrx = csrx - (CLIST_SEGMENT_INTERVAL*(csrx/(CLIST_MARGIN*CLIST_KEY_PER_SEGMENT+CLIST_SEGMENT_INTERVAL)));
csrx = csrx / CLIST_MARGIN;
csry = (tgt->y - CLIST_LT_Y) / CLIST_MARGIN;
if(csrx < 0 ) return FALSE;
if ( csrx >= KEY_PER_LINE ) csrx = KEY_PER_LINE - 1;
csrxy = csrx + csry * KEY_PER_LINE;
if ( csrxy < 0 || csrxy >= CHAR_LIST_CHAR_NUM) return FALSE;// 明らかにはみ出した
// 候補座標のキーコード取得
code = char_tbl[s_work.char_mode][csrxy];
if(code == EOM_) return FALSE;
// 候補座標の領域取得
if( (code >= CODE_BUTTON_TOP_) && (code < CODE_BUTTON_BOTTOM_) )
{
int x = code - CODE_BUTTON_TOP_;
rect = NNS_G2dTextCanvasGetTextRect( &gTextCanvas, str_button[x] );
}
else
{
u16 s[2];
s[0] = code;
s[1] = 0;
// rect = NNS_G2dTextCanvasGetTextRect( &gTextCanvas, s );
// 文字幅じゃかなり判定が厳しい……ギリギリまでとってみる
rect.width = CLIST_MARGIN;
rect.height = CLIST_MARGIN;
}
a = CLIST_LT_X + CLIST_MARGIN*(csrxy%KEY_PER_LINE) + CLIST_SEGMENT_INTERVAL*((csrxy%KEY_PER_LINE)/CLIST_KEY_PER_SEGMENT);
b = CLIST_LT_Y + CLIST_MARGIN*(csrxy/KEY_PER_LINE);
// 候補座標の領域にタッチ座標が含まれているかチェック
ret = WithinRangeTP( a, b, a+rect.width, b+rect.height, tgt );
if(ret)
{
*csr = (u16)csrxy;
}
return ret;
}
// ソフトウェアキー上でのキーパッド及びタッチパッド処理
// 先にReadTPしておくこと。
static void PadDetectOnKey( void )
{
SelectSomethingFunc func[1];
BOOL tp_select = FALSE;
//--------------------------------------
// キー入力処理
//--------------------------------------
if( pad.trg & PAD_KEY_RIGHT ){ // カーソルの移動
do
{
if(s_work.key_csr%KEY_PER_LINE != KEY_PER_LINE-1) s_work.key_csr++;
else s_work.key_csr -= KEY_PER_LINE-1;
if( s_work.key_csr == CHAR_LIST_CHAR_NUM ) s_work.key_csr -= s_work.key_csr%KEY_PER_LINE;
}
while(char_tbl[s_work.char_mode][s_work.key_csr]==EOM_);
}
if( pad.trg & PAD_KEY_LEFT ){
do
{
if(s_work.key_csr%KEY_PER_LINE != 0) s_work.key_csr--;
else s_work.key_csr += KEY_PER_LINE-1;
if( s_work.key_csr & 0x8000 ) s_work.key_csr = KEY_PER_LINE-1;
}
while(char_tbl[s_work.char_mode][s_work.key_csr]==EOM_);
}
if( pad.trg & PAD_KEY_DOWN ){ // カーソルの移動
do
{
s_work.key_csr += KEY_PER_LINE;
if( s_work.key_csr >= CHAR_LIST_CHAR_NUM ) s_work.key_csr -= KEY_PER_LINE*(s_work.key_csr/KEY_PER_LINE);
}
while(char_tbl[s_work.char_mode][s_work.key_csr]==EOM_);
}
if( pad.trg & PAD_KEY_UP ){
do
{
if( s_work.key_csr < KEY_PER_LINE ) s_work.key_csr += (CHAR_LIST_CHAR_NUM/KEY_PER_LINE)*KEY_PER_LINE;
else s_work.key_csr -= KEY_PER_LINE;
if( s_work.key_csr >= CHAR_LIST_CHAR_NUM ) s_work.key_csr -= KEY_PER_LINE;
}
while(char_tbl[s_work.char_mode][s_work.key_csr]==EOM_);
}
func[0] = (SelectSomethingFunc)SelectSoftwareKeyFunc;
tp_select = SelectSomethingByTP(&s_work.key_csr, func, 1 );
if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) { // キーが押された
PushKeys( char_tbl[s_work.char_mode][s_work.key_csr] );
}else if( pad.trg & PAD_BUTTON_B ) {
DeleteACharacter();
}
}
// パラメータ編集画面の描画処理
static void DrawSetParameterScene( void )
{
NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL );
PutStringUTF16( 0, 0, TXT_COLOR_BLUE, (const u16 *)L"PARAMETER" );
PutStringUTF16( 128-60 , 21 , TXT_UCOLOR_G0, s_work.temp_parameter );
DrawCharKeys();
}
// パラメータ編集の初期化
static void SetParameterInit( void )
{
SetSoftKeyboardButton(0);
s_work.key_csr = KEY_START;
// パラメータ用テンポラリバッファの初期化
MI_CpuCopy8(s_work.parameter, s_work.temp_parameter, 2*(PARAM_LENGTH+1));
s_work.temp_parameter_length = MY_StrLen( s_work.temp_parameter );
if( s_work.temp_parameter_length < PARAM_LENGTH ) {
SVC_CpuClear(CHAR_USCORE, &s_work.temp_parameter[ s_work.temp_parameter_length ],
( PARAM_LENGTH - s_work.temp_parameter_length ) * 2, 16);
}
DrawSetParameterScene();
SVC_CpuClear( 0x0000, &tpd, sizeof(TpWork), 16 );
GX_SetVisiblePlane ( GX_PLANEMASK_BG0 );
GXS_SetVisiblePlane( GX_PLANEMASK_BG0 );
}
// パラメータ編集メイン
static void SetParameterMain( void )
{
ReadTP();
PadDetectOnKey();
// 描画処理
DrawSetParameterScene();
}
static void DrawMenuScene( void )
{
NNS_G2dCharCanvasClear( &gCanvas, TXT_COLOR_NULL );
PutStringUTF16( 1 * 8, 0 * 8, TXT_COLOR_BLUE, (const u16 *)L"CooperationC");
PutStringUTF16( s_work.starx-6, s_work.stary-6, TXT_UCOLOR_G0, (const u16 *)L"<EFBFBD>");
PutStringUTF16( 128 , 8*8, TXT_UCOLOR_G0, s_work.parameter );
GetAndDrawRTCData( &g_rtcDraw, TRUE );
// メニュー項目
DrawMenu( s_work.csr, &s_menuParam );
PrintfSJIS( 1*8, 20*8, TXT_COLOR_BLACK, "<EFBFBD>の位置(%d,%d)",s_work.starx, s_work.stary);
}
static void MenuScene(void)
{
BOOL tp_select = FALSE;
static TPData tgt = (TPData){0,0,0,0};
BootFlags tempflag = {TRUE, 0, TRUE, FALSE, FALSE, FALSE, 0};
ReadTP();
//--------------------------------------
// キー入力処理
//--------------------------------------
if( pad.trg & PAD_KEY_DOWN ){ // カーソルの移動
if( ++s_work.csr == COPA_MENU_ELEMENT_NUM ) {
s_work.csr=0;
}
}
if( pad.trg & PAD_KEY_UP ){
if( --s_work.csr & 0x80 ) {
s_work.csr=COPA_MENU_ELEMENT_NUM - 1;
}
}
tp_select = SelectMenuByTP( &s_work.csr, &s_menuParam );
if(tpd.disp.touch)
{
tgt = tpd.disp;
if(s_work.starx != tgt.x) s_work.starx += (((tgt.x - s_work.starx)>>3) + ((tgt.x > s_work.starx) ? 1 : -1) );
if(s_work.stary != tgt.y) s_work.stary += (((tgt.y - s_work.stary)>>3) + ((tgt.y > s_work.stary) ? 1 : -1) );
}
DrawMenuScene();
if( ( pad.trg & PAD_BUTTON_A ) || ( tp_select ) ) { // メニュー項目への分岐
if( s_menuPos[ s_work.csr ].enable ) {
switch( s_work.csr ) {
case 0:
SetParameterInit();
s_work.pNowProcess = SetParameterMain;
break;
case 1:
// 現在のアプリ状態をセーブ
{
FSFile f;
FS_InitFile(&f);
if(!FS_SetCurrentDirectory("dataPrv:/")) {MI_CpuCopy8(L"ライトエラー1",s_work.parameter,14); break;}
FS_CreateFile("test.dat", FS_PERMIT_R | FS_PERMIT_W );
if(!FS_OpenFileEx(&f, "test.dat", FS_FILEMODE_W)) {MI_CpuCopy8(L"ライトエラー2",s_work.parameter,14); break;}
if(-1 == FS_WriteFile(&f, &s_work, sizeof(s_work))) {MI_CpuCopy8(L"ライトエラー3",s_work.parameter,14); break;}
if(!FS_CloseFile( &f )) {MI_CpuCopy8(L"ライトエラー4",s_work.parameter,14); break;}
}
// アプリ間パラメータをセット
{
OSDeliverArgInfo *arginfo = (OSDeliverArgInfo *)HW_PARAM_DELIVER_ARG;
// メーカーコードとゲームコードのセット(Launcher側でやるべき)
u16 *maker_code_src_addr = (u16 *)(HW_TWL_ROM_HEADER_BUF + 0x10);
u32 *game_code_src_addr = (u32 *)(HW_TWL_ROM_HEADER_BUF + 0xc);
arginfo->makerCode = *maker_code_src_addr;
// まだゲームコードは証明書の関係でNTRJしか入ってない……ので強制的に値代入
//arginfo->gameCode = *game_code_src_addr;
arginfo->gameCode = 0x43504f43; // 下位から'C','O','P','C'
// アプリ専用部分のセット
MI_CpuCopy8(s_work.parameter, arginfo->buf, 2*(PARAM_LENGTH+1));
}
//B起動
OS_SetResetParamAndResetHardware( 0, 0x00010001434f5042, &tempflag );
break;
case 2:
OS_SetResetParamAndResetHardware( 0, NULL, &tempflag );
//再起動
break;
}
}
}
}
// 初期化
void CooperationCInit( void )
{
ChangeUserColor( TSD_GetUserColor() );
s_work.parameter[0] = 0;
MenuInit();
{
OSDeliverArgInfo *arginfo = (OSDeliverArgInfo *)HW_PARAM_DELIVER_ARG;
if(arginfo->gameCode != NULL)
{
if(STD_CompareNString((const char *)arginfo->buf, "-r", 3) == 0)
{
// セーブしたデータから復帰
FSFile f;
FS_InitFile(&f);
if(!FS_SetCurrentDirectory("dataPrv:/")) {MI_CpuCopy8(L"リードエラー1",s_work.parameter,14); return;}
if(!FS_OpenFileEx(&f, "test.dat", FS_FILEMODE_R)) {return;}
if(-1 == FS_ReadFile(&f, &s_work, sizeof(s_work))) {MI_CpuCopy8(L"リードエラー2",s_work.parameter,14); return;}
if(!FS_CloseFile( &f )) {MI_CpuCopy8(L"リードエラー3",s_work.parameter,14); return;}
}
}
}
}
// メインループ
void CooperationCMain(void)
{
s_work.pNowProcess();
}
//======================================================
// ソフトウェアキーボード用キャラテーブル
//======================================================
static const u16 char_tbl[CHAR_LIST_MODE_NUM][CHAR_LIST_CHAR_NUM] = {
{ // ひらがな
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', DEL_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', SPACE_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', L'', L'', L'', L'',
L'', EOM_, L'', EOM_, L'', VAR_BUTTON1_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', VAR_BUTTON2_,
L'', L'', L'', L'', L'',
L'', EOM_, L'', EOM_, L'', EOM_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', OK_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', L'', L'', L'', L'',
EOM_, EOM_, EOM_, EOM_, EOM_, CANCEL_BUTTON_,
EOM_, EOM_, EOM_, EOM_, EOM_,
EOM_, EOM_, EOM_, EOM_, EOM_,
},
{ // カタカナ
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', DEL_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', SPACE_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', L'', L'', L'', L'',
L'', EOM_, L'', EOM_, L'', VAR_BUTTON1_,
L'', L'', L'', L'', L'',
L'', EOM_, L'', EOM_, L'', VAR_BUTTON2_,
L'', L'', L'', L'', L'',
L'', EOM_, L'', EOM_, L'', EOM_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', OK_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', L'', L'', L'', EOM_,
EOM_, EOM_, EOM_, EOM_, EOM_, CANCEL_BUTTON_,
EOM_, EOM_, EOM_, EOM_, EOM_,
EOM_, EOM_, EOM_, EOM_, EOM_,
},
{ // 英数
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', DEL_BUTTON_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', SPACE_BUTTON_,
L'', L'', L'', L'', L'',
L'', EOM_, EOM_, EOM_, EOM_, EOM_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', VAR_BUTTON1_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', VAR_BUTTON2_,
L'', L'', L'', L'', L'',
L'', EOM_, EOM_, EOM_, EOM_, EOM_,
L'', L'', L'', L'', L'',
L'', L'', L'', L'', L'', EOM_,
L'', EOM_, L'', EOM_, L'',
L'', EOM_, L'', EOM_, L'', OK_BUTTON_,
L'', EOM_, L'', EOM_, EOM_,
L'', EOM_, L'', EOM_, L'', EOM_,
EOM_, EOM_, EOM_, EOM_, EOM_,
EOM_, EOM_, EOM_, EOM_, EOM_, CANCEL_BUTTON_,
EOM_, EOM_, EOM_, EOM_, EOM_,
EOM_, EOM_, EOM_, EOM_, EOM_,
},
};

View File

@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File: CooperationC.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:: 2007-10-30#$
$Rev: 73 $
$Author: yosiokat $
*---------------------------------------------------------------------------*/
#ifndef __COOPERATION_C_H__
#define __COOPERATION_C_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <twl.h>
// define data----------------------------------------------------------
void CooperationCInit( void );
void CooperationCMain( void );
#ifdef __cplusplus
}
#endif
#endif // __COOPERATION_C_H__

View File

@ -0,0 +1,109 @@
/*---------------------------------------------------------------------------*
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:: 2007-11-27#$
$Rev: 272 $
$Author: yosiokat $
*---------------------------------------------------------------------------*/
#include <twl.h>
#include "misc.h"
#include "CooperationC.h"
// extern data-----------------------------------------------------------------
// define data-----------------------------------------------------------------
// function's prototype-------------------------------------------------------
static void INTR_VBlank( void );
// global variable-------------------------------------------------------------
// static variable-------------------------------------------------------------
BOOL g_isValidTSD;
RTCDrawProperty g_rtcDraw = {
TRUE, RTC_DATE_TOP_X, RTC_DATE_TOP_Y, RTC_TIME_TOP_X, RTC_TIME_TOP_Y
};
// const data------------------------------------------------------------------
// ============================================================================
// function's description
// ============================================================================
void TwlMain(void)
{
// 初期化----------------------------------
OS_Init();
OS_InitTick();
(void)OS_EnableIrq();
(void)OS_EnableInterrupts();
GX_Init();
GX_SetPower(GX_POWER_ALL); // 各ロジック パワーON
FS_Init( 3 );
// 割り込み許可----------------------------
(void)OS_SetIrqFunction(OS_IE_V_BLANK, INTR_VBlank);
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
(void)GX_VBlankIntr(TRUE);
// デバイス初期化-------------------------------
TP_Init();
(void)RTC_Init();
// システムの初期化------------------
InitAllocator();
// ※本来ならランチャーからのパラメータチェックを行い、
// 初回起動シーケンスに入るパスがある
// TWL設定のリード
SYSM_SetAllocFunc( Alloc, Free ); // SYSM_ReadTWLSettingsFile()の実行に必要。
// ::::::::::::::::::::::::::::::::::::::::::::::
// TWL設定データファイルの読み込み
// ::::::::::::::::::::::::::::::::::::::::::::::
(void)THW_ReadSecureInfo();
g_isValidTSD = SYSM_ReadTWLSettingsFile();
if( g_isValidTSD ) {
SYSM_CaribrateTP();
}
InitBG();
GetAndDrawRTCData( &g_rtcDraw, TRUE );
CooperationCInit();
// メインループ----------------------------
while(1){
OS_WaitIrq(1, OS_IE_V_BLANK); // Vブランク割り込み待ち
ReadKeyPad(); // キー入力の取得
ReadTP(); // TP入力の取得
CooperationCMain();
}
}
// ============================================================================
// 割り込み処理
// ============================================================================
// Vブランク割り込み
static void INTR_VBlank(void)
{
OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Vブランク割込チェックのセット
}

View File

@ -0,0 +1,30 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL
# File: Makefile
#
# 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:: 2007-10-03#$
# $Rev: 1319 $
# $Author: kitase_hirotake $
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = banner ARM9
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,49 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL
# File: Makefile
#
# 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:: 2007-10-03#$
# $Rev: 1319 $
# $Author: kitase_hirotake $
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
ICON_DIR = ./icon
BANNER_ICON = $(ICON_DIR)/gameIcon.bmp
BANNER_SPEC = banner_v3.bsf
TARGETS = banner.bnr
INSTALL_DIR = ./
INSTALL_TARGETS = $(TARGETS)
BANNER_ICON_NAME = $(basename $(BANNER_ICON))
LDIRT_CLEAN = $(TARGETS) \
$(BANNER_ICON_NAME).nbfs \
$(BANNER_ICON_NAME).nbfc \
$(BANNER_ICON_NAME).nbfp \
$(TARGETS:.bnr=.srl)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#----------------------------------------------------------------------------
# build
#----------------------------------------------------------------------------
do-build: $(TARGETS)
$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON)
$(NTEXCONV) -no -bg -bgb -bgnc $(BANNER_ICON) >/dev/null && \
$(MAKEBANNER) -d -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS)
#

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

View File

@ -0,0 +1,30 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL
# File: Makefile
#
# 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:: 2007-10-03#$
# $Rev: 1319 $
# $Author: kitase_hirotake $
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = CooperationA CooperationB CooperationC
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -20,7 +20,7 @@ include $(TWLSDK_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = RelocateChecker
SUBDIRS = RelocateChecker AppliCooperation
#----------------------------------------------------------------------------