From 9c5f32d0c9b2fa61d4f3dea16992a5a6f295f86f Mon Sep 17 00:00:00 2001 From: N1277 Date: Thu, 7 Jan 2010 01:31:37 +0000 Subject: [PATCH] =?UTF-8?q?TwlSDK=E5=A4=89=E6=9B=B4=E7=AE=87=E6=89=80?= =?UTF-8?q?=E3=81=AE=E8=A3=9C=E8=B6=B3=E3=80=82=20=E4=B8=8D=E8=A6=81?= =?UTF-8?q?=E3=81=AA=E3=82=BD=E3=83=BC=E3=82=B9=E3=81=AE=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2915 b08762b0-b915-fc4b-9d8c-17b2551a87ff --- build/tests/CardCopyMultiBoot/Makefile | 2 - build/tests/CardCopyMultiBoot/readme.txt | 19 +- build/tests/CardCopyMultiBoot/src/_common.c | 502 -------------------- build/tests/CardCopyMultiBoot/src/bt.c | 426 ----------------- build/tests/CardCopyMultiBoot/src/gmain.c | 172 ------- 5 files changed, 18 insertions(+), 1103 deletions(-) delete mode 100644 build/tests/CardCopyMultiBoot/src/_common.c delete mode 100644 build/tests/CardCopyMultiBoot/src/bt.c delete mode 100644 build/tests/CardCopyMultiBoot/src/gmain.c diff --git a/build/tests/CardCopyMultiBoot/Makefile b/build/tests/CardCopyMultiBoot/Makefile index 6e731a0e..83a76136 100644 --- a/build/tests/CardCopyMultiBoot/Makefile +++ b/build/tests/CardCopyMultiBoot/Makefile @@ -50,8 +50,6 @@ SRCS = main.c \ child.c \ parent.c \ text.c \ - bt.c \ - gmain.c # サンプルの簡略化のため WH モジュールを使用します. diff --git a/build/tests/CardCopyMultiBoot/readme.txt b/build/tests/CardCopyMultiBoot/readme.txt index e1df38df..6f2abc01 100644 --- a/build/tests/CardCopyMultiBoot/readme.txt +++ b/build/tests/CardCopyMultiBoot/readme.txt @@ -7,4 +7,21 @@ 5. NTR の DS ダウンロードメニューへ "CardCopyMultiBoot" リストが出たら選択 6. DS カード→無線→ SD カードの転送が開始する 7.「Sent/Received ROM size=....」という表示が出たら、SD カードの card_dump.sin へ - ゲーム領域の吸出し完了 + ゲーム領域の吸出しが完了 + +【TwlSDK変更箇所】 + +build/libraries/card/common/src/card_common.c + +CARDAccessLevel CARDi_GetAccessLevel(void) +{ + . + . + else if (!OS_IsRunOnTwl()) + { + level = CARD_ACCESS_LEVEL_FULL; // CARD_ACCESS_LEVEL_BACKUP から変更 + } + . + . + return level; +} diff --git a/build/tests/CardCopyMultiBoot/src/_common.c b/build/tests/CardCopyMultiBoot/src/_common.c deleted file mode 100644 index e0d17154..00000000 --- a/build/tests/CardCopyMultiBoot/src/_common.c +++ /dev/null @@ -1,502 +0,0 @@ -/*---------------------------------------------------------------------------* - Project: TwlSDK - MB - demos - cloneboot - File: common.c - - Copyright 2006-2008 Nintendo. All rights reserved. - - These coded instructions, statements, and computer programs contain - proprietary information of Nintendo of America Inc. and/or Nintendo - Company Ltd., and are protected by Federal copyright law. They may - not be disclosed to third parties or copied or duplicated in any form, - in whole or in part, without the prior written consent of Nintendo. - - $Date:: $ - $Rev$ - $Author$ -*---------------------------------------------------------------------------*/ - - -#include -#include -#include - -#include "wh.h" -#include "common.h" -#include "disp.h" -#include "text.h" -#include "bt.h" - - -static void ModeSelect(void); // 親機/子機 選択画面 -static void ModeStartParent(void); // 使用率が低いチャンネルを計算し終えた状態 -static void ModeChild(void); // 子機 通信画面 - -// データ送信時に呼び出される関数 -void ParentSendCallback(void); -void ChildSendCallback(void); - -static void VBlankIntr(void); - -/* - * このデモ全体で使用する共通機能. - */ -static u16 padPress; -static u16 padTrig; - -// データ受信時に呼び出される関数 -void ParentReceiveCallback(u16 aid, u16 *data, u16 length); -void ChildReceiveCallback(u16 aid, u16 *data, u16 length); - -// ブロック転送状態通知関数 -void BlockTransferCallback(void *arg); - -// 表示用送受信バッファ -static u8 gSendBuf[256] ATTRIBUTE_ALIGN(32); -static BOOL gRecvFlag[1 + WM_NUM_MAX_CHILD]; - -static int send_counter[16]; -static int recv_counter[16]; - -static BOOL gFirstSendAtChild = TRUE; - -TEXT_CTRL *tc[NUM_OF_SCREEN]; - -static BOOL wbt_available = FALSE; -static u16 connected_bitmap = 0; - -/*---------------------------------------------------------------------------* - Name: ReadKey - - Description: キーの読み込み処理 - - Arguments: None - - Returns: None - *---------------------------------------------------------------------------*/ -void ReadKey(void) -{ - u16 currData = PAD_Read(); - - padTrig = (u16)(~padPress & currData); - padPress = currData; -} - -/*---------------------------------------------------------------------------* - Name: GetPressKey - - Description: 押下キー取得 - - Arguments: None - - Returns: 押下されているキーのビットマップ - *---------------------------------------------------------------------------*/ -u16 GetPressKey(void) -{ - return padPress; -} - - -/*---------------------------------------------------------------------------* - Name: GetTrigKey - - Description: キートリガ取得 - - Arguments: None - - Returns: キートリガのビットマップ - *---------------------------------------------------------------------------*/ -u16 GetTrigKey(void) -{ - return padTrig; -} - - -/*---------------------------------------------------------------------------* - Name: CommonInit - - Description: 共通初期化関数 - - Arguments: None - - Returns: None - *---------------------------------------------------------------------------*/ -void CommonInit(void) -{ - /* OS 初期化 */ - OS_Init(); - OS_InitTick(); - OS_InitAlarm(); - FX_Init(); - - /* GX 初期化 */ - GX_Init(); - GX_DispOff(); - GXS_DispOff(); - - /* Vブランク割込設定 */ - (void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr); - (void)OS_EnableIrqMask(OS_IE_V_BLANK); - (void)OS_EnableIrqMask(OS_IE_FIFO_RECV); - (void)GX_VBlankIntr(TRUE); - - // キーを一回空読み - ReadKey(); -} - - -/*---------------------------------------------------------------------------* - Name: InitAllocateSystem - - Description: メインメモリ上のアリーナにてメモリ割当てシステムを初期化する。 - - Arguments: None. - - Returns: None. - *---------------------------------------------------------------------------*/ -void InitAllocateSystem(void) -{ - void *tempLo; - OSHeapHandle hh; - - // OS_Initは呼ばれているという前提 - tempLo = OS_InitAlloc(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi(), 1); - OS_SetArenaLo(OS_ARENA_MAIN, tempLo); - hh = OS_CreateHeap(OS_ARENA_MAIN, OS_GetMainArenaLo(), OS_GetMainArenaHi()); - if (hh < 0) - { - OS_Panic("ARM9: Fail to create heap...\n"); - } - hh = OS_SetCurrentHeap(OS_ARENA_MAIN, hh); -} - - - - -/*---------------------------------------------------------------------------* - Name: VBlankIntr - - Description: キートリガ取得 - - Arguments: None - - Returns: None - *---------------------------------------------------------------------------*/ -static void VBlankIntr(void) -{ - DispVBlankFunc(); - - //---- 割り込みチェックフラグ - OS_SetIrqCheckFlag(OS_IE_V_BLANK); -} - -/*---------------------------------------------------------------------------* - Name: BlockTransferMain - - Description: ブロック転送状態通知関数。 - - Arguments: arg - 通知元 WM 関数のコールバックポインタ - - Returns: None. - *---------------------------------------------------------------------------*/ -void BlockTransferMain(void) -{ - // 通信状態により処理を振り分け - switch (WH_GetSystemState()) - { - case WH_SYSSTATE_IDLE: - ModeSelect(); - break; - case WH_SYSSTATE_MEASURECHANNEL: - ModeStartParent(); - break; - case WH_SYSSTATE_ERROR: - case WH_SYSSTATE_CONNECT_FAIL: - WH_Reset(); - break; - case WH_SYSSTATE_FATAL: - break; - case WH_SYSSTATE_SCANNING: - case WH_SYSSTATE_BUSY: - break; - case WH_SYSSTATE_CONNECTED: - // 親機か子機かでさらに分岐する - switch (WH_GetConnectMode()) - { - case WH_CONNECTMODE_MP_PARENT: -// ModeParent(); - break; - case WH_CONNECTMODE_MP_CHILD: - ModeChild(); - break; - } - break; - } -} - -/*---------------------------------------------------------------------------* - Name: BlockTransferCallback - - Description: ブロック転送状態通知関数。 - - Arguments: arg - 通知元 WM 関数のコールバックポインタ - - Returns: None. - *---------------------------------------------------------------------------*/ -void BlockTransferCallback(void *arg) -{ - int connectMode = WH_GetConnectMode(); - - switch (((WMCallback*)arg)->apiid) - { - case WM_APIID_START_MP: - { /* MP ステート開始 */ - WMStartMPCallback *cb = (WMStartMPCallback *)arg; - switch (cb->state) - { - case WM_STATECODE_MP_START: - if (connectMode == WH_CONNECTMODE_MP_PARENT) - { - ParentSendCallback(); - } - else if (connectMode == WH_CONNECTMODE_MP_CHILD) - { - WBT_SetOwnAid(WH_GetCurrentAid()); -// mfprintf(tc[2], "aid = %d\n", WH_GetCurrentAid()); - bt_start(); - ChildSendCallback(); - } - break; - } - } - break; - case WM_APIID_SET_MP_DATA: - { /* 単発の MP 通信完了 */ - if (connectMode == WH_CONNECTMODE_MP_PARENT) - { - if (connected_bitmap != 0) - { - ParentSendCallback(); - } - } - else if (connectMode == WH_CONNECTMODE_MP_CHILD) - { - ChildSendCallback(); - } - } - break; - case WM_APIID_START_PARENT: - { /* 新規の子機接続 */ - WMStartParentCallback *cb = (WMStartParentCallback *)arg; - if (connectMode == WH_CONNECTMODE_MP_PARENT) - { - switch (cb->state) - { - case WM_STATECODE_CONNECTED: - if (connected_bitmap == 0) - { - ParentSendCallback(); - } - connected_bitmap |= (1 << cb->aid); - break; - case WM_STATECODE_DISCONNECTED: - connected_bitmap &= ~(1 << cb->aid); - break; - } - } - } - break; - } -} - - -/*---------------------------------------------------------------------------* - Name: ChildSendCallback - - Description: 子機として親機からのデータ受信時に呼び出される関数。 - - Arguments: None. - - Returns: None. - *---------------------------------------------------------------------------*/ -void ChildSendCallback(void) -{ - const u16 size = (u16)WBT_MpChildSendHook(gSendBuf, WC_CHILD_DATA_SIZE_MAX); - send_counter[0]++; - (void)WH_SendData(gSendBuf, size, NULL); -} - - -/*---------------------------------------------------------------------------* - Name: ParentSendCallback - - Description: 親機として子機へのデータ送信時に呼び出される関数。 - - Arguments: None. - - Returns: None. - *---------------------------------------------------------------------------*/ -void ParentSendCallback(void) -{ - const u16 size = (u16)WBT_MpParentSendHook(gSendBuf, WC_PARENT_DATA_SIZE_MAX); - send_counter[0]++; - (void)WH_SendData(gSendBuf, size, NULL); -} - - -/*---------------------------------------------------------------------------* - Name: ParentReceiveCallback - - Description: 親機として子機からのデータ受信時に呼び出される関数。 - - Arguments: aid - 送信元子機の aid - data - 受信データへのポインタ (NULL で切断通知) - length - 受信データのサイズ - - Returns: None. - *---------------------------------------------------------------------------*/ -void ParentReceiveCallback(u16 aid, u16 *data, u16 length) -{ - BgSetMessage(PLTT_YELLOW, " Receive: p=0x%x, len=0x%x", data, length); - - recv_counter[aid]++; - if (data != NULL) - { - gRecvFlag[aid] = TRUE; - // コピー元は2バイトアライン(4バイトアラインでない) -// recv_counter[aid]++; - WBT_MpParentRecvHook((u8 *)data, length, aid); - } - else - { - gRecvFlag[aid] = FALSE; - } -} - - -/*---------------------------------------------------------------------------* - Name: ChildReceiveCallback - - Description: 子機として親機からのデータ受信時に呼び出される関数。 - - Arguments: aid - 送信元親機の aid (常に 0) - data - 受信データへのポインタ (NULL で切断通知) - length - 受信データのサイズ - - Returns: None. - *---------------------------------------------------------------------------*/ -void ChildReceiveCallback(u16 aid, u16 *data, u16 length) -{ - BgSetMessage(PLTT_YELLOW, " Receive: p=0x%x, len=0x%x", data, length); - - (void)aid; - recv_counter[0]++; - if (data != NULL) - { - gRecvFlag[0] = TRUE; - // コピー元は2バイトアライン(4バイトアラインでない) - WBT_MpChildRecvHook((u8 *)data, length); - } - else - { - gRecvFlag[0] = FALSE; - } -} - -/*---------------------------------------------------------------------------* - Name: ModeSelect - - Description: 親機/子機 選択画面での処理。 - - Arguments: None. - - Returns: None. - *---------------------------------------------------------------------------*/ -static void ModeSelect(void) -{ - // カウンタクリア - MI_CpuClear(send_counter, sizeof(send_counter)); - MI_CpuClear(recv_counter, sizeof(recv_counter)); - - gFirstSendAtChild = TRUE; - - if (wbt_available) - { - bt_stop(); - WBT_End(); - wbt_available = FALSE; - } - - if (!MB_IsMultiBootChild()) - { - BgSetMessage(PLTT_YELLOW, " Connect as PARENT"); - //******************************** - WBT_InitParent(BT_PARENT_PACKET_SIZE, BT_CHILD_PACKET_SIZE, bt_callback); - WH_SetReceiver(ParentReceiveCallback); - bt_register_blocks(); - (void)WH_StartMeasureChannel(); - wbt_available = TRUE; - //******************************** - } - else - { - static const u8 ANY_PARENT[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - BgSetMessage(PLTT_YELLOW, " Connect as CHILD"); - //******************************** - WBT_InitChild(bt_callback); - WH_SetReceiver(ChildReceiveCallback); - (void)WH_ChildConnectAuto(WH_CONNECTMODE_MP_CHILD, ANY_PARENT, 0); - wbt_available = TRUE; - //******************************** - } -} - -/*---------------------------------------------------------------------------* - Name: ModeStartParent - - Description: 使用率の低いチャンネルを計算し終えたときの処理。 - - Arguments: None. - - Returns: None. - *---------------------------------------------------------------------------*/ -static void ModeStartParent(void) -{ - (void)WH_ParentConnect(WH_CONNECTMODE_MP_PARENT, 0x0000, WH_GetMeasureChannel()); -} - -/*---------------------------------------------------------------------------* - Name: ModeChild - - Description: 子機 通信画面での処理。 - - Arguments: None. - - Returns: None. - *---------------------------------------------------------------------------*/ -static void ModeChild(void) -{ - if (gFirstSendAtChild) - { - // 1回目のデータ送信 - ChildSendCallback(); - gFirstSendAtChild = FALSE; - } - -#if 0 - if (gKey.trg & PAD_BUTTON_START) - { - //******************************** - WH_Finalize(); - //******************************** - } - else if (gKey.trg & PAD_BUTTON_Y) - { - bt_start(); - } - else if (gKey.trg & PAD_BUTTON_X) - { - bt_stop(); - } -#endif -} - diff --git a/build/tests/CardCopyMultiBoot/src/bt.c b/build/tests/CardCopyMultiBoot/src/bt.c deleted file mode 100644 index 93c906fd..00000000 --- a/build/tests/CardCopyMultiBoot/src/bt.c +++ /dev/null @@ -1,426 +0,0 @@ -/*---------------------------------------------------------------------------* - Project: TwlSDK - WBT - demos - wbt-1 - File: bt.c - - Copyright 2006-2008 Nintendo. All rights reserved. - - These coded instructions, statements, and computer programs contain - proprietary information of Nintendo of America Inc. and/or Nintendo - Company Ltd., and are protected by Federal copyright law. They may - not be disclosed to third parties or copied or duplicated in any form, - in whole or in part, without the prior written consent of Nintendo. - - $Date:: $ - $Rev$ - $Author$ - *---------------------------------------------------------------------------*/ - -#ifdef SDK_TWL -#include -#else -#include -#endif - -#include -#include "wh.h" -#include "bt.h" -#include "text.h" - -#undef mfprintf -#define mfprintf( ... ) ((void)0) - -#define NOT_USE_ALLOC - -#ifndef SDK_NO_MESSAGE -#define __MY_LINE__ __LINE__ -#else -#define __MY_LINE__ 0 -#endif - -/* 子機用受信ブロック制御データ */ -static int request_block_num; -static int block_info_num = 0; -static OSTick start_tick; -static int bt_loop_count = 0; -static int bt_running = 0; - -/* 子機用受信用バッファ諸々 */ -static WBTBlockInfoTable block_info_table; -static WBTRecvBufTable recv_buf_table; -static WBTPacketBitmapTable recv_buf_packet_bmp_table; -static WBTAidBitmap tbmp = 1; /* リクエスト要求相手(親) */ - -/* 子機用ユーザーデータ送信バッファ */ -static u8 user_data[WBT_SIZE_USER_DATA]; - -#ifdef NOT_USE_ALLOC -WBTBlockInfo block_info[WBT_NUM_OF_AID][NUM_OF_BT_LIST]; -u8 recv_buf[WBT_NUM_OF_AID][BT_DATA_SIZE]; -u32 - recv_pkt_bmp_buf[WBT_NUM_OF_AID][WBT_PACKET_BITMAP_SIZE(BT_DATA_SIZE, BT_PARENT_PACKET_SIZE)]; -#endif - -/* 親機用ブロックデータ */ -static WBTBlockInfoList bt_list[NUM_OF_BT_LIST]; -static u8 bt_data[NUM_OF_BT_LIST][BT_DATA_SIZE]; - -static u8 user_char_id[NUM_OF_BT_LIST][WBT_USER_ID_LEN] = { - "BT text information area 0", - "BT text information area 1", - "BT text information area 2", -#if 0 - "BT text information area 3", - "BT text information area 4" -#endif -}; - - -const char *command_str[] = { - "REQ_NONE", - "REQ_WAIT", - "REQ_SYNC", - "RES_SYNC", - "REQ_GET_BLOCK", - "RES_GET_BLOCK", - "REQ_GET_BLOCKINFO", - "RES_GET_BLOCKINFO", - "REQ_GET_BLOCK_DONE", - "RES_GET_BLOCK_DONE", - "REQ_USER_DATA", - "RES_USER_DATA", - "SYSTEM_CALLBACK", - "PREPARE_SEND_DATA", - "REQ_ERROR", - "RES_ERROR", - "CANCEL" -}; - - - - -static int strlen(char *str) -{ - int i = 0; - while (1) - { - if (*str != '\0') - { - str++; - i++; - } - else - { - break; - } - } - return i; -} - - -/* 親機用ブロック登録関数 */ -void bt_register_blocks(void) -{ - int i; - char *end_string = "This is BlockTransfer test data contents end\n"; - char *ptr; - int offset; - - for (i = 0; i < NUM_OF_BT_LIST; i++) - { - offset = BT_DATA_SIZE - (strlen(end_string) + 1); - *(s32 *)(&(bt_data[i][0])) = offset; - (void)OS_SPrintf((char *)&(bt_data[i][4]), - "This is BlockTransfer test data contents start %d\n", i); - - ptr = (char *)(&(bt_data[i][0]) + offset); - (void)OS_SPrintf((char *)ptr, "%s", end_string); - - (void)WBT_RegisterBlock(&(bt_list[i]), (u32)(10000 + i) /* id 1000以下は不可 */ , - user_char_id[i], &(bt_data[i][0]), BT_DATA_SIZE, 0); - } -} - - -/* 子機用ブロック転送終了関数 */ -void bt_stop(void) -{ - bt_running = 0; - (void)WBT_CancelCurrentCommand(0xffff); -} - - -/* 子機用ブロック転送開始関数 */ -void bt_start(void) -{ - OSIntrMode enabled; - static int init_flag = FALSE; - int i; - - enabled = OS_DisableInterrupts(); - - if (bt_running) - { - (void)OS_RestoreInterrupts(enabled); - return; - } - bt_running = 1; - -#ifdef NOT_USE_ALLOC - - if (init_flag == FALSE) - { - init_flag = TRUE; - for (i = 0; i < WBT_NUM_OF_AID; i++) - { - block_info_table.block_info[i] = &(block_info[i][0]); - recv_buf_table.recv_buf[i] = &(recv_buf[i][0]); - recv_buf_packet_bmp_table.packet_bitmap[i] = &(recv_pkt_bmp_buf[i][0]); - } - } - -#else - - mfprintf(tc[2], "child bt start\n"); - - if (init_flag == FALSE) - - { - init_flag = TRUE; - /* 子機用受信用バッファ諸々の初期化 */ - for (i = 0; i < WBT_NUM_OF_AID; i++) - { - block_info_table.block_info[i] = NULL; - recv_buf_table.recv_buf[i] = NULL; - recv_buf_packet_bmp_table.packet_bitmap[i] = NULL; - } - } - - for (i = 0; i < WBT_NUM_OF_AID; i++) - { - if (block_info_table.block_info[i] != NULL) - { - OS_Free(block_info_table.block_info[i]); - block_info_table.block_info[i] = NULL; - } - if (recv_buf_table.recv_buf[i] != NULL) - { - OS_Free(recv_buf_table.recv_buf[i]); - recv_buf_table.recv_buf[i] = NULL; - } - if (recv_buf_packet_bmp_table.packet_bitmap[i] != NULL) - { - OS_Free(recv_buf_packet_bmp_table.packet_bitmap[i]); - recv_buf_packet_bmp_table.packet_bitmap[i] = NULL; - } - } -#endif - - (void)OS_RestoreInterrupts(enabled); - - (void)WBT_RequestSync(tbmp, /* Sync要求をする相手(親機のみ複数可) */ - bt_callback /* 終了時コールバック */ - ); -} - - -/* ブロック転送汎用コールバック関数 */ -void bt_callback(void *arg) -{ - - WBTCommand *uc = (WBTCommand *)arg; - int peer_aid = WBT_AidbitmapToAid(uc->peer_bmp); /* 通信相手局のAID */ - // mfprintf(tc[2],"aid = %d\n", peer_aid); - - switch (uc->event) - { - case WBT_CMD_RES_SYNC: - /* WBT_RequestSync終了 */ - request_block_num = 0; - block_info_num = uc->sync.num_of_list; /* 相手の持っているブロック数 */ - mfprintf(tc[2], "blockinfo num = %d my_packet_size = %d peer_packet_size = %d\n", block_info_num, uc->sync.my_packet_size, /* 相手の送信データサイズ */ - uc->sync.peer_packet_size /* こちらの送信データサイズ */ - ); -#ifndef NOT_USE_ALLOC - mfprintf(tc[2], "info buf alloc %d\n", peer_aid); - /* ブロック情報テーブルの初期化 */ - block_info_table.block_info[peer_aid] = (WBTBlockInfo *)OS_Alloc(sizeof(WBTBlockInfo)); -#endif - - if (uc->target_bmp == 0) /* すべての相手局からレスポンスがあったか? */ - { - (void)OS_SPrintf((char *)user_data, " %5d\n", bt_loop_count); - - /* ユーザーデータ送信 */ - if (FALSE == WBT_PutUserData(tbmp, /* ユーザーデータを送る相手(親機のみ複数可) */ - user_data, /* ユーザーデータバッファ */ - WBT_SIZE_USER_DATA, /* ユーザーデータサイズ 12以下 */ - bt_callback /* 終了時コールバック */ - )) - { - mfprintf(tc[2], "command invoke error %d\n", __MY_LINE__); - } - } - break; - case WBT_CMD_RES_USER_DATA: - - if (uc->target_bmp == 0) /* すべての相手局からレスポンスがあったか? */ - { - /* ブロックリスト要求 */ - if (FALSE == WBT_GetBlockInfo(tbmp, /* ブロックリスト要求をする相手(親機のみ複数可) */ - request_block_num /* ブロックリストNO */ , - &block_info_table, /* ブロック情報テーブル */ - bt_callback /* 終了時コールバック */ - )) - { - mfprintf(tc[2], "command invoke error %d\n", __MY_LINE__); - } - } - break; - case WBT_CMD_RES_GET_BLOCKINFO: - - /* WBT_GetBlockInfo終了 */ - - mfprintf(tc[2], "blockinfo %d done\n", uc->get.block_id); /* 取得したブロックリストのID */ - mfprintf(tc[2], " info id = %d\n", block_info_table.block_info[peer_aid]->id); /* ブロックID */ - mfprintf(tc[2], " info block size = %d\n", block_info_table.block_info[peer_aid]->block_size); /* ブロックのサイズ */ - mfprintf(tc[2], " info = %s\n", block_info_table.block_info[peer_aid]->user_id); /* ブロックのユーザ定義情報 */ - -#ifndef NOT_USE_ALLOC - /* 受信バッファテーブルの初期化 */ - recv_buf_table.recv_buf[peer_aid] = - (u8 *)OS_Alloc((u32)block_info_table.block_info[peer_aid]->block_size); - mfprintf(tc[2], "recv buf alloc %d\n", peer_aid); - - /* パケット受信番号記録用バッファテーブルの初期化 */ - recv_buf_packet_bmp_table.packet_bitmap[peer_aid] = - (u32 *) - OS_Alloc((u32) - WBT_CalcPacketbitmapSize(block_info_table.block_info[peer_aid]->block_size)); - - mfprintf(tc[2], "recv pkt bmp size = %d\n", - WBT_CalcPacketbitmapSize(block_info_table.block_info[peer_aid]->block_size)); -#endif - - if (uc->target_bmp == 0) /* すべての相手局からレスポンスがあったか? */ - { - - /* ブロック受信要求 */ - if (FALSE == WBT_GetBlock(tbmp, /* ブロック受信要求をする相手(親機のみ複数可) */ - block_info_table.block_info[peer_aid]->id /* ブロックID */ , - &recv_buf_table, /* 受信バッファテーブル */ - (u32)block_info_table.block_info[peer_aid]->block_size, /* ブロックサイズ */ - &recv_buf_packet_bmp_table, /* パケット受信番号記録用バッファテーブル */ - bt_callback /* 終了時コールバック */ - )) - { - mfprintf(tc[2], "command invoke error %d\n", __MY_LINE__); - } - else - { - start_tick = OS_GetTick(); /* 時間計測開始 */ - } - - } - - break; - case WBT_CMD_RES_GET_BLOCK: - /* WBT_GetBlock終了 */ - - mfprintf(tc[2], "get block %d done\n", uc->get.block_id); /* 受信したブロックID */ - mfprintf(tc[2], " time %d msec\n", OS_TicksToMilliSeconds(OS_GetTick() - start_tick)); - - mfprintf(tc[2], " %s\n", &(recv_buf_table.recv_buf[peer_aid][4])); /* 受信したブロックの中身 */ - { - u32 offset; - offset = *(u32 *)&(recv_buf_table.recv_buf[peer_aid][0]); - mfprintf(tc[2], " %s\n", (char *)(&(recv_buf_table.recv_buf[peer_aid][offset]))); - } - -#ifndef NOT_USE_ALLOC - /* 受信バッファテーブルの解放 */ - mfprintf(tc[2], "recv buf free %d\n", peer_aid); - OS_Free(recv_buf_table.recv_buf[peer_aid]); - recv_buf_table.recv_buf[peer_aid] = NULL; - - /* パケット受信番号記録用バッファテーブルの解放 */ - OS_Free(recv_buf_packet_bmp_table.packet_bitmap[peer_aid]); - recv_buf_packet_bmp_table.packet_bitmap[peer_aid] = NULL; - - OS_Free(block_info_table.block_info[peer_aid]); - block_info_table.block_info[peer_aid] = NULL; - - { - mfprintf(tc[2], "info buf alloc %d\n", peer_aid); - /* ブロック情報テーブルの初期化 */ - block_info_table.block_info[peer_aid] = (WBTBlockInfo *)OS_Alloc(sizeof(WBTBlockInfo)); - } -#endif - - if (uc->target_bmp == 0) - { /* 要求したすべての相手局からレスポンスがあったか? */ - - request_block_num++; - - if (request_block_num < block_info_num) - { - - /* ブロックリスト要求 */ - if (FALSE == WBT_GetBlockInfo(tbmp, request_block_num, /* ブロックリストNO */ - &block_info_table, /* ブロック情報テーブル */ - bt_callback /* 終了時コールバック */ - )) - { - mfprintf(tc[2], "command invoke error %d\n", __MY_LINE__); - } - } - else - { - request_block_num = 0; - - bt_loop_count++; - if (bt_loop_count > 99999) - { - bt_loop_count = 0; - } - - (void)OS_SPrintf((char *)user_data, " %05d\n", bt_loop_count); - - /* ユーザーデータ送信 */ - if (FALSE == WBT_PutUserData(tbmp, /* ユーザーデータを送る相手(親機のみ複数可) */ - user_data, /* ユーザーデータバッファ */ - WBT_SIZE_USER_DATA, /* ユーザーデータサイズ 12以下 */ - bt_callback /* 終了時コールバック */ - )) - { - mfprintf(tc[2], "command invoke error %d\n", __MY_LINE__); - } - } - } - break; - case WBT_CMD_REQ_NONE: - mfprintf(tc[2], "WBT user none\n"); - break; - case WBT_CMD_REQ_USER_DATA: - mfprintf(tc[2], "get user data = %s\n", uc->user_data.data); - break; - case WBT_CMD_REQ_GET_BLOCK_DONE: - mfprintf(tc[2], "get peer getblockdone %d done from %d\n", uc->blockdone.block_id, - peer_aid); - break; - case WBT_CMD_REQ_SYNC: - mfprintf(tc[2], "get peer sync from %d\n", peer_aid); - break; - case WBT_CMD_RES_ERROR: - mfprintf(tc[2], "get req error %d from %d\n", peer_aid, uc->result); - break; - case WBT_CMD_REQ_ERROR: - mfprintf(tc[2], "get res error %d from %d\n", peer_aid, uc->result); - break; - case WBT_CMD_CANCEL: - mfprintf(tc[2], "get canncel [%s] command from %d\n", command_str[uc->command], peer_aid); - break; - default: - mfprintf(tc[2], "WBT callback unknown %d\n", uc->event); - break; - } -} diff --git a/build/tests/CardCopyMultiBoot/src/gmain.c b/build/tests/CardCopyMultiBoot/src/gmain.c deleted file mode 100644 index 0b08dc4c..00000000 --- a/build/tests/CardCopyMultiBoot/src/gmain.c +++ /dev/null @@ -1,172 +0,0 @@ -/*---------------------------------------------------------------------------* - Project: TwlSDK - MB - demos - cloneboot - File: gmain.c - - Copyright 2006-2008 Nintendo. All rights reserved. - - These coded instructions, statements, and computer programs contain - proprietary information of Nintendo of America Inc. and/or Nintendo - Company Ltd., and are protected by Federal copyright law. They may - not be disclosed to third parties or copied or duplicated in any form, - in whole or in part, without the prior written consent of Nintendo. - - $Date:: $ - $Rev$ - $Author$ -*---------------------------------------------------------------------------*/ - - -#include - -#include "gmain.h" -#include "common.h" -#include "disp.h" -#include "wh.h" - - - -//============================================================================ -// 変数定義 -//============================================================================ - -//----------------------- -// データシェアリング用 -//----------------------- -static u8 sSendBuf[256] ATTRIBUTE_ALIGN(32); // 送信バッファ( 要32バイトアライン ) -static u8 sRecvBuf[256] ATTRIBUTE_ALIGN(32); // 受信バッファ( 要32バイトアライン ) -static BOOL sRecvFlag[1 + WM_NUM_MAX_CHILD]; // 受信フラグ -static GShareData *sShareDataPtr; - -//----------------------- -// キーシェアリング用 -//----------------------- -static WMKeySet sKeySet; - - -//============================================================================ -// 関数定義 -//============================================================================ - -/*---------------------------------------------------------------------------* - Name: GInitDataShare - - Description: データシェアリング用バッファの初期化設定 - - Arguments: None - - Returns: None - *---------------------------------------------------------------------------*/ -void GInitDataShare(void) -{ - sShareDataPtr = (GShareData *) sSendBuf; - - DC_FlushRange(sSendBuf, 4); - DC_WaitWriteBufferEmpty(); - - // KT_Init(KT_KeyEntriesSample); -} - - -/*---------------------------------------------------------------------------* - Name: GStepDataShare - - Description: データシェアリングの同期を1つ進めます。 - - Arguments: None - - Returns: None - *---------------------------------------------------------------------------*/ -void GStepDataShare(s32 frame) -{ - sShareDataPtr->count = (u32)frame; - sShareDataPtr->key = GetPressKey(); - - switch (WH_GetSystemState()) - { - //------------------------------ - // データシェアリング通信 - case WH_SYSSTATE_DATASHARING: - { - u16 i; - u8 *adr; - - if (!WH_StepDS(sSendBuf)) - { - // データシェア通信失敗 - return; - } - - for (i = 0; i < 16; ++i) - { - adr = (u8 *)WH_GetSharedDataAdr(i); - if (adr != NULL) - { - MI_CpuCopy8(adr, &(sRecvBuf[i * sizeof(GShareData)]), sizeof(GShareData)); - sRecvFlag[i] = TRUE; - } - else - { - sRecvFlag[i] = FALSE; - } - } - } - break; - //------------------------------ - // キーシェアリング通信 - case WH_SYSSTATE_KEYSHARING: - { - (void)WH_GetKeySet(&sKeySet); - if ((sKeySet.key[0] != 0) || (sKeySet.key[1] != 0)) - { - OS_TPrintf("0 -> %04x 1 -> %04x\n", sKeySet.key[0], sKeySet.key[1]); - } - } - } -} - - - - - - -/*---------------------------------------------------------------------------* - Name: GMain - - Description: 親子共通メインルーチン - - Arguments: None - - Returns: None - *---------------------------------------------------------------------------*/ -void GMain(void) -{ - - BgPrintStr(4, 3, 0x4, "Send: %04x-%04x", sShareDataPtr->key, sShareDataPtr->count); - BgPutString(4, 5, 0x4, "Receive:"); - { - s32 i; - - for (i = 0; i < (WM_NUM_MAX_CHILD + 1); i++) - { - if (sRecvFlag[i]) - { - GShareData *sd; - sd = (GShareData *) (&(sRecvBuf[i * sizeof(GShareData)])); - - BgPrintStr(4, (s16)(6 + i), 0x4, - "Player%02d: %04x-%04x", i, sd->key, sd->count & 0xffff); - } - else - { - BgPutString(4, (s16)(6 + i), 0x7, "No child"); - } - } - } - - if (IS_PAD_TRIGGER(PAD_BUTTON_START)) - { - //******************************** - (void)WH_Finalize(); - //******************************** - } -}