git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2913 b08762b0-b915-fc4b-9d8c-17b2551a87ff

This commit is contained in:
N1277 2010-01-06 11:21:47 +00:00
parent a86eb03d6b
commit 247bf6124f
29 changed files with 4918 additions and 0 deletions

View File

@ -0,0 +1,209 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlSDK - MB - demos - card_copy
# File: Makefile
#
# Copyright 2007-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$
#----------------------------------------------------------------------------
SUBDIRS = banner
# MBライブラリのサンプルはマルチブート機能を使うため、
# 同じ通信環境(無線あるいは有線)どうしの開発機材を複数必要とします。
# $TwlSDK/bin/ARM9-TS/Release/ ディレクトリにある
# mb_child.bin プログラムが最終実機におけるマルチブート子機と同等の
# 機能を提供するサンプルになっていますので、
# このバイナリをサンプルプログラムと同じ方法で他の機材に読み込み、
# 一緒に実行してください。
#----------------------------------------------------------------------------
TARGET_PLATFORM := TWL
TWL_ARCHGEN := HYBRID
#-------------------------
#-- NAND アプリのビルドを指定します。
TWL_NANDAPP = TRUE
#----------------------------------------------------------------------------
# このプログラムで使用するソースファイルは以下の通りです.
#----------------------------------------------------------------------------
SRCDIR = ./src
INCDIR = ./include
SRCS = main.c \
common.c \
disp.c \
font.c \
child.c \
parent.c \
text.c \
bt.c \
gmain.c
# サンプルの簡略化のため WH モジュールを使用します.
WH_DIR = $(ROOT)/build/demos/wireless_shared/wh
SRCDIR += $(WH_DIR)
INCDIR += $(WH_DIR)
SRCS += $(WH_DIR)/wh.c
# サンプルの簡略化のため MBP モジュールを使用します.
MBP_DIR = $(ROOT)/build/demos/wireless_shared/mbp
SRCDIR += $(MBP_DIR)
INCDIR += $(MBP_DIR)
SRCS += $(MBP_DIR)/mbp.c
#----------------------------------------------------------------------------
# アプリケーションの一般的な設定は以下の通りです.
#----------------------------------------------------------------------------
TARGET_BIN = card_copy.srl
TWL_MAKEROM = TRUE
# プログラムの各セグメントを圧縮する場合はこのフラグを有効にします.
# 圧縮されたセグメントは CARD-ROM 上でのバイナリサイズが削減され
# CARD-ROM またはワイヤレス経由でのロード時間が短縮されるかわりに,
# 実行時は展開のためにいくらかの CPU 時間を消費します.
TWL_COMPRESS = TRUE
# ワイヤレスダウンロード子機としてオーバーレイを使用する場合,
# NITRO_DIGEST を有効にする必要があります.
TWL_DIGEST = TRUE
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/commondefs
do-build: $(TARGETS)
#----------------------------------------------------------------------------
ifeq ($(TARGET_PLATFORM),TWL)
ROM_SPEC = main.TWL.rsf
#LCFILE_SPEC = main.TWL.lsf
else
ROM_SPEC = main.rsf
#LCFILE_SPEC = main.lsf
endif
# MBのコールバック内で複雑な処理をする場合には、lcfファイルで
# IRQスタックサイズを少し大きめに設定しておいた方が安全です。
# 特にOS_Printf()は大量のスタックを消費するので、コールバック内では
# できるだけ軽量版のOS_TPrintf()を使用するようにしてください。
#----------------------------------------------------------------------------
# クローンブート親機としての特別な設定は以下の通りです.
#----------------------------------------------------------------------------
# セキュリティ目的の親機専用領域 .parent セクションを配置するため
# クローンブート用リンク設定テンプレートを指定します.
#
# .parent セクションの内容はDSダウンロードプレイ子機には送信されません.
# このセクションに親機専用かつ必須の関数を配置することによって,
# 傍受された受信内容から親機自身を再現することを不可能にします.
# コードの配置にあたっては, 以下の点に注意してください.
# ・.text/.rodata セクション以外を含まないこと
# ・親機のみが必要とする重要な処理を含むこと
#
# .parent セクションは, 該当するコードについて以下のように配置します.
#
# #include <nitro/parent_begin.h>
#
# void ForParentOnly(void)
# {
# /* 何か親機固有の処理 */
# }
#
# #include <nitro/parent_end.h>
#
# このサンプルデモでは parent.c の全ての関数を .parent セクションに
# 配置しています. 詳細はソースコードを参照ください.
ifeq ($(TARGET_PLATFORM),TWL)
LCFILE_TEMPLATE = $(TWL_SPECDIR)/ARM9-TS-cloneboot-C.lcf.template
else
LCFILE_TEMPLATE = $(NITRO_SPECDIR)/ARM9-TS-cloneboot-C.lcf.template
endif
# 製品版アプリケーションのために各々へ配布された
# 正式なシステムコールライブラリをここで指定します.
# このサンプルでは暫定用として、あらかじめこのディレクトリに,
# SDK 付属版(lib/ARM9-TS/etc/libsyscall.a)のコピーを置いてあります.
# このデモを元にしてアプリケーションを作られる場合は、弊社サポートより
# 配布させていただいている libsyscal.a でこの暫定システムコールを
# 上書きしてください.
LIBSYSCALL = ./etc/libsyscall.a
LIBSYSCALL_CHILD = ./etc/libsyscall_child.bin
#----------------------------------------------------------------------------
# アプリケーションを製品版で実行させるための事前認証手続きは以下の通りです.
#----------------------------------------------------------------------------
# 事前認証手続きはおおよそ以下の流れになります.
# 詳細は「DSダウンロードプレイ解説」を参照ください.
# (/docs/TechnicalNotes/AboutMultiBoot.doc)
#
# (0) クローンブートなら emuchild コマンドで送信用プログラムを用意します.
# そうでなければ main.srl をそのまま用意します.
# この makefile では, 用意したものを bin/sign.srl とします.
#
# (1) 認証コード取得のため, (0) で用意した tmp/sign.srl をサーバへ送付します.
# この作業はご使用のブラウザから手作業で行う必要があります.
# この makefile では, 取得した認証コードを bin/sign.sgn とします.
#
# (2) attachsign コマンドを使用して, (1) で取得した bin/sign.sgn と
# main.srl を結合した最終プログラムを生成します.
# この makefile では, 生成物を main_with_sign.srl とします.
#
# クローンブートの場合は通常のDSダウンロードプレイプログラムと若干異なり,
# 自身のプログラムでなく emuchild で加工したプログラムをサーバへ送付します.
presign:
$(EMUCHILD) \
bin/$(TWL_BUILDTYPE)/$(TARGET_BIN) \
$(LIBSYSCALL_CHILD) \
bin/sign.srl
# 得られた認証コードをバイナリに含める手続きはクローンブートも通常と同様です.
postsign:
$(ATTACHSIGN) \
bin/$(TWL_BUILDTYPE)/$(TARGET_BIN) \
bin/sign.sgn \
main_with_sign.srl && \
$(MAKETAD) \
main_with_sign.srl \
$(MAKETAD_OPTION) \
-o bin/$(TWL_BUILDTYPE)/card_copy.tad
#----------------------------------------------------------------------------
include $(TWLSDK_ROOT)/build/buildtools/modulerules
ifdef TWL_ELFTOBIN
$(TARGETS): $(ELFTOBIN_ARM7)
else #TWL_ELFTOBIN
$(TARGETS): $(MAKEROM_ARM7)
endif #TWL_ELFTOBIN
#===== End of Makefile =====

View File

@ -0,0 +1,49 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlSDK - nandApp - demos - card_backup
# File: Makefile
#
# Copyright 2008 Nintendo. All rights reserved.
#
# These coded instructions, statements, and computer programs contain
# proprietary information of Nintendo of America Inc. and/or Nintendo
# Company Ltd., and are protected by Federal copyright law. They may
# not be disclosed to third parties or copied or duplicated in any form,
# in whole or in part, without the prior written consent of Nintendo.
#
# $Date:: $
# $Rev$
# $Author$
#----------------------------------------------------------------------------
TARGET_PLATFORM = TWL
include $(TWLSDK_ROOT)/build/buildtools/commondefs
MAKEBANNER = $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe
ICON_DIR = ../data
BANNER_ICON = $(ICON_DIR)/myGameIcon.bmp
BANNER_SPEC = banner_v3.bsf
TARGETS = banner.bnr
INSTALL_DIR = .
INSTALL_TARGETS = $(TARGETS)
BANNER_ICON_NAME = $(basename $(BANNER_ICON))
BANNER_ICON_MIDDLE = $(addprefix $(BANNER_ICON_NAME), .nbfs .nbfc .nbfp)
LDIRT_CLEAN = $(TARGETS) \
$(BANNER_ICON_MIDDLE) \
$(TARGETS:.bnr=.srl)
include $(TWLSDK_ROOT)/build/buildtools/modulerules
#----------------------------------------------------------------------------
# build
#----------------------------------------------------------------------------
do-build: $(TARGETS)
$(TARGETS): $(BANNER_SPEC) $(BANNER_ICON) $(BANNER_ICON_MIDDLE)
$(MAKEBANNER) -N $(BANNER_ICON_NAME) $(BANNER_SPEC) $(TARGETS)
#

Binary file not shown.

Binary file not shown.

Binary file not shown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ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η<EFBFBD>ή<EFBFBD>η

View File

@ -0,0 +1,53 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - WBT - demos - wbt-1
File: bt.h
Copyright 2005-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$
*---------------------------------------------------------------------------*/
#ifndef NITRO_BUILD_DEMOS_WBT_WBT1_INCLUDE_BT_H_
#define NITRO_BUILD_DEMOS_WBT_WBT1_INCLUDE_BT_H_
#include <nitro/wbt.h>
/* ブロックデータの数 */
#define NUM_OF_BT_LIST 3
/* 1ブロックデータのサイズ */
#define BT_DATA_SIZE 0x10000
//親機のパケットサイズ
#define BT_PARENT_PACKET_SIZE WC_PARENT_DATA_SIZE_MAX
//子機のパケットサイズ
#define BT_CHILD_PACKET_SIZE WC_CHILD_DATA_SIZE_MAX
#define SDK_MAKEGGID_SYSTEM(num) (0x003FFF00 | (num))
#define GGID_WBT_1 SDK_MAKEGGID_SYSTEM(0x30)
#define WC_PARENT_DATA_SIZE_MAX 128
#define WC_CHILD_DATA_SIZE_MAX 16
/* 親機用ブロック登録関数 */
extern void bt_register_blocks(void);
/* ブロック転送汎用コールバック関数 */
extern void bt_callback(void *arg);
/* 子機用ブロック転送開始関数 */
extern void bt_start(void);
/* 子機用ブロック転送終了関数 */
extern void bt_stop(void);
#endif /* NITRO_BUILD_DEMOS_WBT_WBT1_INCLUDE_BT_H_ */

View File

@ -0,0 +1,162 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - MB - demos - cloneboot
File: common.h
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$
*---------------------------------------------------------------------------*/
#ifndef MB_DEMO_COMMON_H_
#define MB_DEMO_COMMON_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <nitro.h>
#define CARD_GAME_AREA_OFFSET 0x8000 // 32KB
//============================================================================
// 関数宣言
//============================================================================
/*
* multiboot-Model NitroMain() .
* MB_IsMultiBootChild() == FALSE .
*/
void ParentMain(void);
/*
* multiboot-Model NitroMain() .
* MB_IsMultiBootChild() == TRUE .
*/
void ChildMain(void);
/*
* .parent .
* , ParentMain() .
*/
void ParentIdentifier(void);
/* それ以外は全て multiboot-Model と同じです */
void CommonInit();
void ReadKey(void);
u16 GetPressKey(void);
u16 GetTrigKey(void);
void InitAllocateSystem(void);
/*---------------------------------------------------------------------------*
Name: IS_PAD_PRESS
Description:
Arguments:
Returns: TRUE
FALSE
*---------------------------------------------------------------------------*/
static inline BOOL IS_PAD_PRESS(u16 flag)
{
return (GetPressKey() & flag) == flag;
}
/*---------------------------------------------------------------------------*
Name: IS_PAD_TRIGGER
Description:
Arguments:
Returns: TRUE
FALSE
*---------------------------------------------------------------------------*/
static inline BOOL IS_PAD_TRIGGER(u16 flag)
{
return (GetTrigKey() & flag) == flag;
}
/*---------------------------------------------------------------------------*
Name: MpSendCallback
Description: MPデータ送信後に呼び出される関数
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void MpSendCallback(BOOL result);
/*---------------------------------------------------------------------------*
Name: MpReceiveCallback
Description: MPデータ受信時に呼び出される関数
Arguments: aid - aid( 0 )
data - (NULL )
length -
Returns: None.
*---------------------------------------------------------------------------*/
void MpReceiveCallback(u16 aid, u16 *data, u16 length);
/*---------------------------------------------------------------------------*
Name: ModeParent
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void ModeParent(void);
/*---------------------------------------------------------------------------*
Name: ModeChild
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void ModeChild(void);
/*---------------------------------------------------------------------------*
Name: BlockTransferMain
Description:
Arguments: arg - WM
Returns: None.
*---------------------------------------------------------------------------*/
void BlockTransferMain(void);
/*---------------------------------------------------------------------------*
Name: BlockTransferCallback
Description:
Arguments: arg - WM
Returns: None.
*---------------------------------------------------------------------------*/
void BlockTransferCallback(void *arg);
#ifdef __cplusplus
}/* extern "C" */
#endif
#endif // MB_DEMO_COMMON_H_

View File

@ -0,0 +1,87 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - MB - demos - cloneboot
File: disp.h
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$
*---------------------------------------------------------------------------*/
#ifndef MB_DEMO_DISP_H_
#define MB_DEMO_DISP_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <nitro.h>
/*
* .
*/
/* OBJ番号の割り振り */
enum
{
TITLE_STRING_OBJNO = 0,
PARENT_STRING_OBJNO = 10,
CHILD_STRING_OBJNO = 22,
PLIST_STRING_OBJNO = 33,
CLIST_STRING_OBJNO = 39,
CURSOR_OBJNO = 45,
PARENT_NAME_OBJNO = 46,
FILENAME_OBJNO = 82,
MESSAGE_OBJNO = 104
};
/* テキスト用パレットカラー */
enum
{
PLTT_BLACK = 0,
PLTT_BLUE = 1,
PLTT_RED = 2,
PLTT_PURPLE = 3,
PLTT_GREEN = 4,
PLTT_CYAN = 5,
PLTT_YELLOW = 6,
PLTT_WHITE = 7
};
//============================================================================
// 関数宣言
//============================================================================
void DispInit(void);
void DispOn(void);
void DispOff(void);
void DispVBlankFunc(void);
void ObjSet(s32 objNo, s32 x, s32 y, s32 charNo, s32 paletteNo);
void ObjSetString(s32 startobjNo, s32 x, s32 y, const char *string, s32 paletteNo);
void ObjClear(s32 objNo);
void ObjClearRange(s32 start, s32 end);
void ObjSetMessage(const char *message);
void BgPutChar(s32 x, s32 y, s32 palette, s8 c);
void BgPutStringN(s32 x, s32 y, s32 palette, const char *text, s32 num);
void BgPutString(s32 x, s32 y, s32 palette, const char *text);
void BgPrintStr(s32 x, s32 y, s32 palette, const char *text, ...);
void BgSetMessage(s32 palette, const char *text, ...);
void BgClear(void);
void BgColorString(s16 x, s16 y, s16 length, u8 palette);
#ifdef __cplusplus
}/* extern "C" */
#endif
#endif // MB_DEMO_DISP_H_

View File

@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - MB - demos - cloneboot
File: font.h
Copyright 2005-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$
*---------------------------------------------------------------------------*/
#ifndef MB_DEMO_FONT_H_
#define MB_DEMO_FONT_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <nitro/types.h>
extern const u16 samplePlttData[16][16];
extern const u32 sampleFontCharData[8 * 0x100];
#ifdef __cplusplus
}/* extern "C" */
#endif
#endif // MB_DEMO_DISP_H_

View File

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - MB - demos - cloneboot
File: gmain.h
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$
*---------------------------------------------------------------------------*/
#ifndef MB_DEMO_GMAIN_H_
#define MB_DEMO_GMAIN_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <nitro.h>
typedef struct
{
u32 count; // フレーム情報
u16 key; // キー情報
u16 padding;
}
GShareData;
//============================================================================
// 関数宣言
//============================================================================
void GInitDataShare(void);
void GStepDataShare(s32 frame);
void GMain(void);
#ifdef __cplusplus
}/* extern "C" */
#endif
#endif // MB_DEMO_GMAIN_H_

View File

@ -0,0 +1,81 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - WBT - demos - wbt-1
File: font.h
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$
*---------------------------------------------------------------------------*/
#ifndef _TEXT_H_
#define _TEXT_H_
#define NUM_OF_SCREEN 4
#define X_LINE_MAX (32)
#define Y_LINE_MAX (24)
#define LINE_BUF_X_SIZE 32
#define LINE_BUF_Y_SIZE 24
typedef struct LINE_BUF_s
{
int buf[LINE_BUF_X_SIZE];
u16 col[LINE_BUF_X_SIZE];
int last_count;
int cur_count;
struct LINE_BUF_s *prev;
struct LINE_BUF_s *next;
}
LINE_BUF;
typedef struct
{
int *num_x, *num_y;
LINE_BUF *start;
LINE_BUF *cur;
}
TEXT_BUF;
typedef struct
{
TEXT_BUF text_buf;
u16 *screen;
u16 x_line;
u16 y_line;
u16 palette;
u16 padding;
}
TEXT_CTRL;
int init_text_buf_sys(void *heap_start, void *heap_end);
void m_putchar(TEXT_CTRL * tc, int c);
void m_set_palette(TEXT_CTRL * tc, u16 num);
u16 m_get_palette(TEXT_CTRL * tc);
void init_text(TEXT_CTRL * tc, u16 *screen, u16 palette);
void text_buf_to_vram(TEXT_CTRL * tc);
extern TEXT_CTRL *tc[NUM_OF_SCREEN];
void mfprintf(TEXT_CTRL * tc, const char *fmt, ...);
void mprintf(const char *fmt, ...);
#endif /* _TEXT_H_ */

View File

@ -0,0 +1,61 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - MB - demos - cloneboot
File: wh_config.h
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$
*---------------------------------------------------------------------------*/
#ifndef CLONEBOOT_WH_CONFIG_H_
#define CLONEBOOT_WH_CONFIG_H_
//#include <default/wh_config.h>
// 無線で使用するDMA番号
#define WH_DMA_NO 2
// 子機最大数(親機を含まない数)
#define WH_CHILD_MAX 1
// シェア出来るデータの最大サイズ
#define WH_DS_DATA_SIZE 12
// 1回の通信で送れるデータの最大サイズ
// データシェアリングに加えて通常の通信をする場合は、その分だけ
// ここの値を増やしてください。その際は、複数パケット送信による追加の
// ヘッダフッタ分を加算する必要があります。
// 詳しくは docs/TechnicalNotes/WirelessManager.doc を参照してください。
// GUIDELINE : ガイドライン準拠ポイント(6.3.2)
// リファレンスのワイヤレスマネージャ(WM)→図表・情報→無線通信時間計算シート
// で計算した MP 通信1回分の所要時間が 5600 μ秒以下となることを推奨しています。
#define WH_PARENT_MAX_SIZE 16
#define WH_CHILD_MAX_SIZE (WH_CHILD_SIZE + 4)
#define WH_CHILD_SIZE 128
// 1ピクチャーフレームあたりのMP通信回数上限
// データシェアリングとブロック転送など複数のプロトコルを並行する場合は
// この値を1より大きく(または無制限を示す0に)設定する必要があります。
// そうでない場合、もっとも優先度の高い1つのプロトコル以外は
// MP通信を一切実行できなくなってしまいます。
#define WH_MP_FREQUENCY 1
// 通常の MP 通信で使用するポート
#define WH_DATA_PORT 14
// 通常の MP 通信で使用する優先度
#define WH_DATA_PRIO WM_PRIORITY_NORMAL
// データシェアリングで使用するポート
#define WH_DS_PORT 13
#endif /* CLONEBOOT_WH_CONFIG_H_ */

View File

@ -0,0 +1,59 @@
#----------------------------------------------------------------------------
# Project: TwlSDK - MB - demos - cloneboot
# File: main.lsf
#
# Copyright 2004-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$
#----------------------------------------------------------------------------
#
# Twl LCF SPEC FILE
#
Static $(TARGET_NAME)
{
Address $(ADDRESS_STATIC)
Object $(OBJS_STATIC)
Library $(LLIBS) $(GLIBS) $(CW_LIBS)
# increase capacity of IRQ stack.
StackSize 0 0x800
}
Autoload ITCM
{
Address $(ADDRESS_ITCM)
Object * (.itcm)
Object $(OBJS_AUTOLOAD) (.text)
Object $(OBJS_AUTOLOAD) (.rodata)
Object $(OBJS_AUTOLOAD) (.init)
Object $(OBJS_AUTOLOAD) (.ctor)
Object $(OBJS_AUTOLOAD) (.sinit)
}
Autoload DTCM
{
Address $(ADDRESS_DTCM)
Object * (.dtcm)
Object $(OBJS_AUTOLOAD) (.data)
Object $(OBJS_AUTOLOAD) (.sdata)
Object $(OBJS_AUTOLOAD) (.bss)
Object $(OBJS_AUTOLOAD) (.sbss)
}
Ltdautoload LTDMAIN
{
# NITRO/TWL 共有のオーバーレイが在る場合は、さらにその後ろに配置する必要があります。
After $(TARGET_NAME)
Object * (.ltdmain)
Object $(OBJS_LTDAUTOLOAD)
Library $(LLIBS_EX) $(GLIBS_EX)
}

View File

@ -0,0 +1,111 @@
#----------------------------------------------------------------------------
# Project: TwlSDK - MB - demos - cloneboot
# File: main.rsf
#
# Copyright 2005-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$
#----------------------------------------------------------------------------
#
# 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
{
RomSpeedType $(MAKEROM_ROMSPEED)
WramMapping $(MAKEROM_WRAM_MAPPING)
RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin
CardRegion ALL
#
# BANNER FILE: generated from Banner Spec File
#
BannerFile "banner/banner.bnr"
#
# SDCardAccess: sd card access control [TRUE/FALSE]
#
SDCardAccess TRUE
}
AppendProperty
{
#
# Boot allowed Media: [GameCard]
#
Media NAND
#
# InitialCode : Your InitialCode in 4 ascii words
#
InitialCode 0DSC
#
# Public save data size: [0-/0K-/0M-]
#
#PublicSaveDataSize 256K
#
# Private save data size: [0-/0K-/0M-]
#
#PrivateSaveDataSize 256K
#
# Enable SubBannerFile
#SubBannerFile FALSE
}
RomSpec
{
Offset 0x00000000
Segment ALL
Align 512
Padding 0xFF
HostRoot data
Root /data
File icon.char
HostRoot data
Root /data
File icon.plt
}

View File

@ -0,0 +1,44 @@
#----------------------------------------------------------------------------
# Project: TwlSDK - MB - demos - cloneboot
# File: main.lsf
#
# Copyright 2004-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$
#----------------------------------------------------------------------------
#
# Nitro LCF SPEC FILE
#
Static $(TARGET_NAME)
{
Address $(ADDRESS_STATIC)
Object $(OBJS_STATIC)
Library $(LLIBS) $(GLIBS) $(CW_LIBS)
# increase capacity of IRQ stack.
StackSize 0 0x800
}
Autoload ITCM
{
Address $(ADDRESS_ITCM)
Object * (.itcm)
Object $(OBJS_AUTOLOAD) (.text)
}
Autoload DTCM
{
Address $(ADDRESS_DTCM)
Object * (.dtcm)
Object $(OBJS_AUTOLOAD) (.data)
Object $(OBJS_AUTOLOAD) (.bss)
}

View File

@ -0,0 +1,59 @@
#----------------------------------------------------------------------------
# Project: TwlSDK - MB - demos - cloneboot
# File: main.rsf
#
# Copyright 2005-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$
#----------------------------------------------------------------------------
#
# Nitro ROM SPEC FILE
#
Arm9
{
Static "$(MAKEROM_ARM9:r).sbin$(COMPSUFFIX9)"
OverlayDefs "$(MAKEROM_ARM9:r)_defs.sbin$(COMPSUFFIX9)"
OverlayTable "$(MAKEROM_ARM9:r)_table.sbin$(COMPSUFFIX9)"
Elf "$(MAKEROM_ARM9:r).nef"
}
Arm7
{
Static "$(MAKEROM_ARM7:r).sbin$(COMPSUFFIX7)"
OverlayDefs "$(MAKEROM_ARM7:r)_defs.sbin$(COMPSUFFIX7)"
OverlayTable "$(MAKEROM_ARM7:r)_table.sbin$(COMPSUFFIX7)"
Elf "$(MAKEROM_ARM7:r).nef"
}
Property
{
RomSpeedType $(MAKEROM_ROMSPEED)
}
RomSpec
{
Offset 0x00000000
Segment ALL
Align 512
Padding 0xFF
HostRoot data
Root /data
File icon.char
HostRoot data
Root /data
File icon.plt
}

View File

@ -0,0 +1,10 @@
【card_copy操作手順】
1. TWL 開発機へ NMenu または NandInitializer で card_copy.tad をインポート(インポート済みなら不要)
2. TWL メニューから「カードコピーマルチブート」 NAND アプリを起動
3. NTR へ吸い出したい DS カードを差す
4. NTR の DS ダウンロードメニューを起動
5. NTR の DS ダウンロードメニューへ "CardCopyMultiBoot" リストが出たら選択
6. DS カード→無線→ SD カードの転送が開始する
7.「Sent/Received ROM size=....」という表示が出たら、SD カードの card_dump.sin へ
ゲーム領域の吸出し完了

View File

@ -0,0 +1,502 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
#include <nitro/wm.h>
#include <nitro/mb.h>
#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
}

View File

@ -0,0 +1,426 @@
/*---------------------------------------------------------------------------*
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 <twl.h>
#else
#include <nitro.h>
#endif
#include <nitro/wbt.h>
#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;
}
}

View File

@ -0,0 +1,298 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - MB - demos - cloneboot
File: child.c
Copyright 2006-2009 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 <nitro.h>
#include <nitro/wm.h>
#include <nitro/mb.h>
#include "common.h"
#include "disp.h"
#include "gmain.h"
#include "wh.h"
#include "bt.h"
/* このデモで使用する GGID */
#define WH_GGID SDK_MAKEGGID_SYSTEM(0x22)
//============================================================================
// プロトタイプ宣言
//============================================================================
static void ModeConnect(void); // 親機への接続開始
static void ModeError(void); // エラー表示画面
static void ModeWorking(void); // ビジー画面
//static void ChildReceiveCallback(WMmpRecvBuf *data);
static BOOL PulledOutCallback(void);
// ブロック転送状態通知関数
void BlockTransferCallback(void *arg);
//============================================================================
// 変数定義
//============================================================================
static s32 gFrame; // フレームカウンタ
static WMBssDesc gMBParentBssDesc ATTRIBUTE_ALIGN(32);
//============================================================================
// 関数定義
//============================================================================
/*---------------------------------------------------------------------------*
Name: ChildMain
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void ChildMain(void)
{
// 画面、OSの初期化
CommonInit();
CARD_Enable(TRUE);
CARD_SetPulledOutCallback(PulledOutCallback);
CARD_LockRom((u16)OS_GetLockID());
// 自分がマルチブートから起動した子機であるかどうかをチェックします。
if (!MB_IsMultiBootChild())
{
OS_Panic("not found Multiboot child flag!\n");
}
//--------------------------------------------------------------
// マルチブートで起動した場合、一旦リセットされ通信が切断されます。
// ブート後もブートした親機のBssDescを保持しているため、この情報を使って
// 親機へ再接続してください。
// この時、BssDescからMACアドレスのみを取り出してMACアドレス指定で
// 親のスキャンから接続を行なう場合は特に問題ありませんが、保持されている
// BssDescを使って直に親機に接続を行なう場合には、通信サイズや転送モードを
// あらかじめ親子の間で合わせて設定しておく必要があります。
//--------------------------------------------------------------
/*
*
* WMBssDescは32バイトにアラインされている必要があります
* MACアドレスで再スキャンすることなしに再接続させる場合は
* /KS/CSフラグはあらかじめ合わせておいてください
* 0
*/
MB_ReadMultiBootParentBssDesc(&gMBParentBssDesc, WH_PARENT_MAX_SIZE, // 親機最大送信サイズ
WH_CHILD_MAX_SIZE, // 子機最大送信サイズ
0, // キーシェアリングフラグ
0); // 連続転送モードフラグ
// 親を再スキャンすること無しに、接続する場合には親機と子機でtgidを合わせる
// 必要があります。
// 親機は再起動後に無関係のIPLからの接続されるのを避ける為にtgidを変更し、
// 子機側もそれに合わせてtgidを変更する必要があります。
// このデモでは親機、子機ともにtgidを1インクリメントしています。
gMBParentBssDesc.gameInfo.tgid++;
WH_PrintBssDesc( &gMBParentBssDesc );
// 画面初期化
DispInit();
// ヒープの初期化
InitAllocateSystem();
// 割り込み有効
(void)OS_EnableIrq();
(void)OS_EnableInterrupts();
{ /* FS 初期化 */
static u32 fs_tablework[0x100 / 4];
FS_Init(FS_DMA_NOT_USE);
(void)FS_LoadTable(fs_tablework, sizeof(fs_tablework));
}
//********************************
// 無線初期化
if (!WH_Initialize())
{
OS_Panic("WH_Initialize failed.");
}
//********************************
// WH_SetSessionUpdateCallback(BlockTransferCallback);
// WH_SetGgid(WH_GGID);
// LCD表示開始
GX_DispOn();
GXS_DispOn();
// デバッグ文字列出力
OS_TPrintf("MB child: Simple DataSharing demo started.\n");
// キー入力情報取得の空呼び出し(IPL での A ボタン押下対策)
ReadKey();
/* メインルーチン */
for (gFrame = 0; TRUE; gFrame++)
{
// キー入力情報取得
ReadKey();
// スクリーンクリア
// BgClear();
// 通信状態により処理を振り分け
switch (WH_GetSystemState())
{
case WH_SYSSTATE_ERROR:
case WH_SYSSTATE_CONNECT_FAIL:
{
// WM_StartConnect()に失敗した場合にはWM内部のステートが不正になっている為
// 一度WM_ResetでIDLEステートにリセットする必要があります。
WH_Reset();
}
break;
case WH_SYSSTATE_IDLE:
{
static retry = 0;
enum
{
MAX_RETRY = 5
};
if (retry < MAX_RETRY)
{
ModeConnect();
retry++;
break;
}
// MAX_RETRYで親機に接続できなければERROR表示
}
// case WH_SYSSTATE_ERROR:
// ModeError();
break;
case WH_SYSSTATE_BUSY:
case WH_SYSSTATE_SCANNING:
ModeWorking();
break;
case WH_SYSSTATE_CONNECTED:
{
ModeChild();
}
break;
}
// 電波受信強度の表示
{
int level;
level = WH_GetLinkLevel();
BgPrintStr(31, 23, 0xf, "%d", level);
}
// Vブランク待ち
OS_WaitVBlankIntr();
}
}
/*---------------------------------------------------------------------------*
Name: ModeConnect
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
static void ModeConnect(void)
{
//#define USE_DIRECT_CONNECT
// 親機の再スキャンなしに直接接続する場合。
#ifdef USE_DIRECT_CONNECT
//********************************
(void)WH_ChildConnect(WH_CONNECTMODE_MP_CHILD, &gMBParentBssDesc);
// WH_SetReceiver(MpReceiveCallback);
// (void)WH_ChildConnect(WH_CONNECTMODE_DS_CHILD, &gMBParentBssDesc);
// WH_ChildConnect(WH_CONNECTMODE_MP_CHILD, &gMBParentBssDesc, TRUE);
// WH_ChildConnect(WH_CONNECTMODE_KS_CHILD, &gMBParentBssDesc, TRUE);
//********************************
#else
WH_SetGgid(gMBParentBssDesc.gameInfo.ggid);
// 親機の再スキャンを実行する場合。
//********************************
(void)WH_ChildConnectAuto(WH_CONNECTMODE_MP_CHILD, gMBParentBssDesc.bssid,
gMBParentBssDesc.channel);
// WH_ChildConnect(WH_CONNECTMODE_MP_CHILD, &gMBParentBssDesc, TRUE);
// WH_ChildConnect(WH_CONNECTMODE_KS_CHILD, &gMBParentBssDesc, TRUE);
//********************************
#endif
WH_SetReceiver(MpReceiveCallback);
}
/*---------------------------------------------------------------------------*
Name: ModeError
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
static void ModeError(void)
{
BgPrintStr(5, 10, 0x1, "======= ERROR! =======");
if (WH_GetLastError() == WM_ERRCODE_OVER_MAX_ENTRY)
{
BgPrintStr(5, 13, 0xf, "OVER_MAX_ENTRY");
}
}
/*---------------------------------------------------------------------------*
Name: ModeWorking
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
static void ModeWorking(void)
{
BgPrintStr(9, 11, 0xf, "Now working...");
if (IS_PAD_TRIGGER(PAD_BUTTON_START))
{
//********************************
(void)WH_Finalize();
//********************************
}
}
/*---------------------------------------------------------------------------*
Name: PulledOutCallback
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
static BOOL PulledOutCallback(void)
{
return TRUE;
}

View File

@ -0,0 +1,384 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
#include <nitro/wm.h>
#include <nitro/mb.h>
#include "wh.h"
#include "common.h"
#include "disp.h"
#include "text.h"
#include "bt.h"
#define DEFAULT_CHAN 1
extern OSMessageQueue mesgQueue;
static void ModeSelect(void); // 親機/子機 選択画面
static void ModeStartParent(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);
u8 gRecvBuf[1 + WM_NUM_MAX_CHILD][256] ATTRIBUTE_ALIGN(32);
static BOOL gRecvFlag[1 + WM_NUM_MAX_CHILD];
static u32 send_counter[16];
static u32 recv_counter[16];
TEXT_CTRL *tc[NUM_OF_SCREEN];
static BOOL gFirstSendAtChild;
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();
OS_InitThread();
FX_Init();
CARD_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: MpSendCallback
Description: MPデータ送信後に呼び出される関数
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void MpSendCallback(BOOL result)
{
#pragma unused( result )
CARDRomHeader* rh = (void*)CARD_GetRomHeader();
u32 limit = rh->rom_size + CARD_ROM_PAGE_SIZE;
u32 offset = CARD_GAME_AREA_OFFSET + WH_CHILD_SIZE * send_counter[0];
BgSetMessage(PLTT_YELLOW, " Sending: ROM addr=0x%x", offset);
if ( offset < limit )
{
CARD_ReadRom( MI_DMA_NOT_USE, (void*)offset, gSendBuf, WH_CHILD_SIZE );
gSendBuf[WH_CHILD_SIZE] = FALSE;
if ( (offset + WH_CHILD_SIZE) >= limit )
{
gSendBuf[WH_CHILD_SIZE] = TRUE;
}
(void)WH_SendData(gSendBuf, WH_CHILD_MAX_SIZE, NULL);
send_counter[0]++;
}
else
{
BgSetMessage(PLTT_RED, " Sent ROM size=0x%x ", MATH_ROUNDUP(limit, WH_CHILD_SIZE) - CARD_GAME_AREA_OFFSET);
}
}
/*---------------------------------------------------------------------------*
Name: MpReceiveCallback
Description: MPデータ受信時に呼び出される関数
Arguments: aid - aid( 0 )
data - (NULL )
length -
Returns: None.
*---------------------------------------------------------------------------*/
void MpReceiveCallback(u16 aid, u16 *data, u16 length)
{
SDK_MAX_ASSERT(aid, 15);
// 子機
if ( MB_IsMultiBootChild() )
{
if (aid == 0)
{
if (data && *data == TRUE)
{
MpSendCallback( TRUE );
}
}
return;
}
// 親機
if (data != NULL)
{
gRecvFlag[aid] = TRUE;
// コピー元は2バイトアライン(4バイトアラインでない)
if (aid == 0)
{
// 親機から受信した場合
MI_CpuCopy8(data, &gRecvBuf[aid][0], length);
}
else
{
static u32 offset = CARD_GAME_AREA_OFFSET;
offset += WH_CHILD_SIZE;
MI_CpuCopy8(data, &gRecvBuf[aid][0], length);
BgSetMessage(PLTT_YELLOW, " Receiving: ROM addr=0x%x", offset);
if ( gRecvBuf[aid][WH_CHILD_SIZE] == TRUE )
{
BgSetMessage(PLTT_RED, " Received ROM size=0x%x ", offset - CARD_GAME_AREA_OFFSET);
}
(void)OS_SendMessage(&mesgQueue, (OSMessage)&gRecvBuf[aid][0], OS_MESSAGE_BLOCK);
}
}
else
{
gRecvFlag[aid] = 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));
if (!MB_IsMultiBootChild())
{
BgSetMessage(PLTT_YELLOW, " Connect as PARENT");
//********************************
(void)WH_ParentConnect(WH_CONNECTMODE_MP_PARENT, 0x0000, DEFAULT_CHAN); // WH_GetMeasureChannel()
WH_SetReceiver(MpReceiveCallback);
//********************************
}
else
{
static const u8 ANY_PARENT[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
BgSetMessage(PLTT_YELLOW, " Connect as CHILD");
//********************************
(void)WH_ChildConnectAuto(WH_CONNECTMODE_MP_CHILD, ANY_PARENT, DEFAULT_CHAN);
//********************************
}
}
/*---------------------------------------------------------------------------*
Name: ModeParent
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void ModeParent(void)
{
BgPutString(6, 1, PLTT_RED, "Card Copy Multi Boot");
BgPrintStr(11, 3, PLTT_YELLOW, "Parent mode");
// BgPrintStr(4, 3, 0x4, "Send: %08X", gSendBuf[0]);
BgPrintStr(4, 5, 0x4, "Receive:");
{
s32 i;
for (i = 1; i < (WM_NUM_MAX_CHILD + 1); i++)
{
if (gRecvFlag[i])
{
BgPrintStr(5, (s16)(6 + i), 0x4, "Child%02d: %08X", i, gRecvBuf[i][0]);
}
else
{
BgPrintStr(5, (s16)(6 + i), 0x7, "No child");
}
}
}
}
/*---------------------------------------------------------------------------*
Name: ModeChild
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void ModeChild(void)
{
BgPutString(6, 1, PLTT_RED, "Card Copy Multi Boot");
BgPutString(11, 3, PLTT_YELLOW, "Child mode");
if ( !gFirstSendAtChild )
{
BgSetMessage(PLTT_WHITE, " Push A Button to start ");
}
if ( !gFirstSendAtChild ) // (GetTrigKey() & PAD_BUTTON_A) )
{
MpSendCallback( TRUE );
gFirstSendAtChild = TRUE;
}
}

View File

@ -0,0 +1,445 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - MB - demos - cloneboot
File: disp.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 <nitro.h>
#include "disp.h"
//============================================================================
// プロトタイプ宣言
//============================================================================
static void VramClear(void);
static void ObjInitForPrintStr(void);
static void BgInitForPrintStr(void);
//============================================================================
// 定数定義
//============================================================================
#define BGSTR_MAX_LENGTH 32
//============================================================================
// 変数定義
//============================================================================
/* 仮想スクリーン */
static u16 vscr[32 * 32];
/* V ブランク転送用テンポラリ OAM */
static GXOamAttr oamBak[128];
/* 各種描画用 */
extern const u32 sampleFontCharData[8 * 0xe0];
extern const u16 samplePlttData[16][16];
//============================================================================
// 関数定義
//============================================================================
/*---------------------------------------------------------------------------*
Name: BgInitForPrintStr
Description: BG文字描画の初期化 (BG0固定, VRAM-C, BGモード0)
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
static void BgInitForPrintStr(void)
{
GX_SetBankForBG(GX_VRAM_BG_128_C);
G2_SetBG0Control(GX_BG_SCRSIZE_TEXT_256x256, GX_BG_COLORMODE_16, GX_BG_SCRBASE_0xf800, /* SCR ベースブロック 31 */
GX_BG_CHARBASE_0x00000, /* CHR ベースブロック 0 */
GX_BG_EXTPLTT_01);
G2_SetBG0Priority(0);
G2_BG0Mosaic(FALSE);
GX_SetGraphicsMode(GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_2D);
G2_SetBG0Offset(0, 0);
GX_LoadBG0Char(sampleFontCharData, 0, sizeof(sampleFontCharData));
GX_LoadBGPltt(samplePlttData, 0, sizeof(samplePlttData));
MI_CpuFillFast((void *)vscr, 0, sizeof(vscr));
DC_FlushRange(vscr, sizeof(vscr));
DC_WaitWriteBufferEmpty();
GX_LoadBG0Scr(vscr, 0, sizeof(vscr));
}
/*---------------------------------------------------------------------------*
Name: ObjInitForPrintStr
Description: OBJの初期化 (VRAM-B, 2Dモード)
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
static void ObjInitForPrintStr(void)
{
GX_SetBankForOBJ(GX_VRAM_OBJ_128_B);
GX_SetOBJVRamModeChar(GX_OBJVRAMMODE_CHAR_2D);
MI_DmaFill32(3, oamBak, 0xc0, sizeof(oamBak));
GX_LoadOBJ(sampleFontCharData, 0, sizeof(sampleFontCharData));
GX_LoadOBJPltt(samplePlttData, 0, sizeof(samplePlttData));
}
/*---------------------------------------------------------------------------*
Name: VramClear
Description: VRAMクリア
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
static void VramClear(void)
{
GX_SetBankForLCDC(GX_VRAM_LCDC_ALL);
MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE);
(void)GX_DisableBankForLCDC();
MI_CpuFillFast((void *)HW_OAM, 192, HW_OAM_SIZE);
MI_CpuClearFast((void *)HW_PLTT, HW_PLTT_SIZE);
MI_CpuFillFast((void *)HW_DB_OAM, 192, HW_DB_OAM_SIZE);
MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE);
}
/*---------------------------------------------------------------------------*
Name: DispInit
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void DispInit(void)
{
/* 描画設定初期化 */
VramClear();
// OBJ初期化
ObjInitForPrintStr();
// BG初期化
BgInitForPrintStr();
GX_SetVisiblePlane(GX_PLANEMASK_BG0 | GX_PLANEMASK_OBJ);
}
/*---------------------------------------------------------------------------*
Name: DispOn
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void DispOn(void)
{
/* 表示開始 */
GX_DispOn();
GXS_DispOn();
}
/*---------------------------------------------------------------------------*
Name: DispOff
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void DispOff(void)
{
/* 表示開始 */
GX_DispOff();
GXS_DispOff();
}
/*---------------------------------------------------------------------------*
Name: DispVBlankFunc
Description: VBlank処理
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void DispVBlankFunc(void)
{
//---- OAMの更新
DC_FlushRange(oamBak, sizeof(oamBak));
/* DMA操作でIOレジスタへアクセスするのでキャッシュの Wait は不要 */
// DC_WaitWriteBufferEmpty();
MI_DmaCopy32(3, oamBak, (void *)HW_OAM, sizeof(oamBak));
//---- BGスクリーン更新
DC_FlushRange(vscr, sizeof(vscr));
/* DMA操作でIOレジスタへアクセスするのでキャッシュの Wait は不要 */
// DC_WaitWriteBufferEmpty();
GX_LoadBG0Scr(vscr, 0, sizeof(vscr));
}
/*---------------------------------------------------------------------------*
Name: ObjSet
Description: OBJの描画設定
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void ObjSet(s32 objNo, s32 x, s32 y, s32 charNo, s32 paletteNo)
{
G2_SetOBJAttr((GXOamAttr *)&oamBak[objNo],
x,
y,
0,
GX_OAM_MODE_NORMAL,
FALSE,
GX_OAM_EFFECT_NONE, GX_OAM_SHAPE_8x8, GX_OAM_COLOR_16, charNo, paletteNo, 0);
}
/*---------------------------------------------------------------------------*
Name: ObjSetString
Description: OBJで文字を描画
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void ObjSetString(s32 startobjNo, s32 x, s32 y, const char *string, s32 paletteNo)
{
s32 i;
for (i = 0; (string[i] != '\0') && (i < 24); i++)
{
ObjSet(startobjNo + i, x + i * 8, y, (s32)string[i], paletteNo);
}
}
/*---------------------------------------------------------------------------*
Name: ObjClear
Description: OBJ
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void ObjClear(s32 objNo)
{
ObjSet(objNo, 256 * 8, 192 * 8, 0, 0);
}
/*---------------------------------------------------------------------------*
Name: ObjClearRange
Description: OBJ ()
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void ObjClearRange(s32 start, s32 end)
{
s32 i;
for (i = start; i <= end; i++)
{
ObjClear(i);
}
}
/*---------------------------------------------------------------------------*
Name: ObjSetMessage
Description: ( 24)
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void ObjSetMessage(const char *message)
{
ObjSetString(MESSAGE_OBJNO, 4 * 8, 22 * 8, message, 7);
}
/*---------------------------------------------------------------------------*
Name: BgPutStringN
Description: BGのN文字出力
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void BgPutStringN(s32 x, s32 y, s32 palette, const char *text, s32 num)
{
s32 i;
if (num > BGSTR_MAX_LENGTH)
{
num = BGSTR_MAX_LENGTH;
}
for (i = 0; i < num; i++)
{
if (text[i] == '\0')
{
break;
}
BgPutChar(x + i, y, palette, text[i]);
}
}
/*---------------------------------------------------------------------------*
Name: BgPutChar
Description: BG文字出力
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void BgPutChar(s32 x, s32 y, s32 palette, s8 c)
{
vscr[((y * 32) + x) % (32 * 32)] = (u16)((palette << 12) | c);
}
/*---------------------------------------------------------------------------*
Name: BgPutString
Description: BG 32
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void BgPutString(s32 x, s32 y, s32 palette, const char *text)
{
BgPutStringN(x, y, palette, text, BGSTR_MAX_LENGTH);
}
/*---------------------------------------------------------------------------*
Name: BgPrintStr
Description: BG
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void BgPrintStr(s32 x, s32 y, s32 palette, const char *text, ...)
{
char temp[(BGSTR_MAX_LENGTH + 1) * 2];
va_list vlist;
MI_CpuClear8(temp, sizeof(temp));
va_start(vlist, text);
(void)vsnprintf(temp, sizeof(temp) - 1, text, vlist);
va_end(vlist);
BgPutString(x, y, palette, temp);
}
/*---------------------------------------------------------------------------*
Name: BgSetMessage
Description: BGメッセージセット
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void BgSetMessage(s32 palette, const char *text, ...)
{
char temp[(BGSTR_MAX_LENGTH + 1) * 2];
va_list vlist;
MI_CpuClear8(temp, sizeof(temp));
va_start(vlist, text);
(void)vsnprintf(temp, sizeof(temp) - 1, text, vlist);
va_end(vlist);
BgPutString(4, 22, palette, temp);
}
/*---------------------------------------------------------------------------*
Name: BgClear
Description: BGクリア
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void BgClear(void)
{
MI_CpuClearFast(vscr, sizeof(vscr));
}
/*---------------------------------------------------------------------------*
Name: BgColorString
Description:
Arguments: x - x ( × 8 )
y - y ( × 8 )
length -
palette -
Returns: None.
*---------------------------------------------------------------------------*/
void BgColorString(s16 x, s16 y, s16 length, u8 palette)
{
s32 i;
u16 temp;
s32 index;
if (length < 0)
{
return;
}
for (i = 0; i < length; i++)
{
index = ((y * 32) + x + i) % (32 * 32);
temp = vscr[index];
temp &= 0x0fff;
temp |= (palette << 12);
vscr[index] = temp;
}
}

View File

@ -0,0 +1,552 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - MB - demos - cloneboot
File: font.c
Copyright 2005-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 <nitro.h>
/*---------------------- パレットデータ ---------------------------*/
#define RGB555(r,g,b) ( (b) << 10 | (g) <<5 | (r) )
const u16 samplePlttData[16][16] = {
{RGB555(0, 0, 0), RGB555(0, 0, 0), RGB555(0, 0, 0), RGB555(0, 0, 0),}, // Black
{RGB555(31, 31, 31), RGB555(0, 0, 31), RGB555(0, 0, 31), RGB555(0, 0, 31),}, // Blue
{RGB555(31, 31, 31), RGB555(31, 0, 0), RGB555(31, 0, 0), RGB555(31, 0, 0),}, // Red
{RGB555(31, 31, 31), RGB555(31, 0, 31), RGB555(31, 0, 31), RGB555(31, 0, 31),}, // Purple
{RGB555(31, 31, 31), RGB555(0, 31, 0), RGB555(0, 31, 0), RGB555(0, 31, 0),}, // Green
{RGB555(31, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31), RGB555(0, 31, 31),}, // Cyan
{RGB555(31, 31, 31), RGB555(31, 31, 0), RGB555(31, 31, 0), RGB555(31, 31, 0),}, // Yellow
{RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31), RGB555(31, 31, 31),}, // White
};
/*---------------------- フォントデータ -------------------------*/
const u32 sampleFontCharData[8 * 0x100] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0000h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x01010010, 0x01010010, 0x00000110, // 0001h
0x00011010, 0x01100010, 0x00000010, 0x00000010,
0x00000000, 0x01011010, 0x01010010, 0x00010010, // 0002h
0x00100010, 0x00100010, 0x00100001, 0x00100001,
0x00000000, 0x01010001, 0x01010001, 0x01111111, // 0003h
0x00000001, 0x00000001, 0x00000001, 0x01111110,
0x00000000, 0x01010000, 0x01111111, 0x00100000, // 0004h
0x00100000, 0x00010000, 0x00001000, 0x00000110,
0x00000000, 0x01010000, 0x01010100, 0x00001010, // 0005h
0x00010001, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x01011000, 0x01011000, 0x01111111, // 0006h
0x00001000, 0x00101010, 0x01001010, 0x01001001,
0x00000000, 0x01010010, 0x01101111, 0x01010010, // 0007h
0x00010010, 0x00010010, 0x00010010, 0x00001001,
0x00000000, 0x01010010, 0x01011111, 0x00000100, // 0008h
0x00011111, 0x00001000, 0x00000001, 0x00011110,
0x00000000, 0x01010000, 0x01011000, 0x00000110, // 0009h
0x00000001, 0x00000110, 0x00011000, 0x00100000,
0x00000000, 0x01010000, 0x01111101, 0x00010001, // 000ah
0x00010001, 0x00010001, 0x00010001, 0x00001010,
0x00000000, 0x01010000, 0x01011110, 0x00100000, // 000bh
0x00000000, 0x00000001, 0x00000001, 0x00111110,
0x00000000, 0x01010100, 0x01011111, 0x00001000, // 000ch
0x00010000, 0x00000001, 0x00000001, 0x00011110,
0x00000000, 0x01010001, 0x01010001, 0x00000001, // 000dh
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x01010000, 0x01111111, 0x00011000, // 000eh
0x00010100, 0x00010100, 0x00011000, 0x00001100,
0x00000000, 0x01010010, 0x01111111, 0x00010010, // 000fh
0x00010010, 0x00000010, 0x00000010, 0x00111100,
0x00000000, 0x00001110, 0x01010100, 0x01010010, // 0010h
0x00111111, 0x00000100, 0x00000100, 0x00011000,
0x00000000, 0x01010100, 0x01011111, 0x00000100, // 0011h
0x01110100, 0x00000010, 0x00001010, 0x01110010,
0x00000000, 0x01010100, 0x01011111, 0x00000010, // 0012h
0x00011110, 0x00100001, 0x00100000, 0x00011110,
0x00000000, 0x01010000, 0x01011100, 0x00100011, // 0013h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x01010000, 0x01111111, 0x00010000, // 0014h
0x00001000, 0x00001000, 0x00001000, 0x00110000,
0x00000000, 0x01010010, 0x01010010, 0x00001100, // 0015h
0x00000010, 0x00000001, 0x00000001, 0x00111110,
0x00000000, 0x01010001, 0x01111101, 0x00010001, // 0016h
0x00010001, 0x00111001, 0x01010101, 0x00011001,
0x00000000, 0x01010100, 0x01010011, 0x01110010, // 0017h
0x00010001, 0x00010001, 0x00001010, 0x00000100,
0x00000000, 0x01011110, 0x01011000, 0x00000100, // 0018h
0x00101001, 0x01010001, 0x01010001, 0x00001100,
0x00000000, 0x01010000, 0x01011100, 0x00010010, // 0019h
0x00010010, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x01011101, 0x01010001, 0x00111101, // 001ah
0x00010001, 0x00011001, 0x00110101, 0x00001001,
0x00000000, 0x01110001, 0x01011101, 0x00110001, // 001bh
0x00010001, 0x00111001, 0x01010101, 0x00011001,
0x00000000, 0x01110100, 0x01010011, 0x00110010, // 001ch
0x00010001, 0x00010001, 0x00001010, 0x00000100,
0x00000000, 0x01101110, 0x01011000, 0x00100100, // 001dh
0x00101001, 0x01010001, 0x01010001, 0x00001100,
0x00000000, 0x01110000, 0x01011100, 0x00110010, // 001eh
0x00010010, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x01111101, 0x01010001, 0x00111101, // 001fh
0x00010001, 0x00011001, 0x00110101, 0x00001001,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0020h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00001000, 0x00001000, 0x00001000, // 0021h
0x00001000, 0x00001000, 0x00000000, 0x00001000,
0x00000000, 0x01101100, 0x01001000, 0x00100100, // 0022h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00100100, 0x01111111, 0x00100100, // 0023h
0x00100100, 0x01111111, 0x00010010, 0x00010010,
0x00000000, 0x00001000, 0x01111110, 0x00001001, // 0024h
0x00111110, 0x01001000, 0x00111111, 0x00001000,
0x00000000, 0x01000010, 0x00100101, 0x00010010, // 0025h
0x00001000, 0x00100100, 0x01010010, 0x00100001,
0x00000000, 0x00001110, 0x00010001, 0x00001001, // 0026h
0x01000110, 0x00101001, 0x00110001, 0x01001110,
0x00000000, 0x00011000, 0x00010000, 0x00001000, // 0027h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x01110000, 0x00001000, 0x00000100, // 0028h
0x00000100, 0x00000100, 0x00001000, 0x01110000,
0x00000000, 0x00000111, 0x00001000, 0x00010000, // 0029h
0x00010000, 0x00010000, 0x00001000, 0x00000111,
0x00000000, 0x00001000, 0x01001001, 0x00101010, // 002ah
0x00011100, 0x00101010, 0x01001001, 0x00001000,
0x00000000, 0x00001000, 0x00001000, 0x00001000, // 002bh
0x01111111, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002ch
0x00000000, 0x00001100, 0x00001000, 0x00000100,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002dh
0x01111111, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002eh
0x00000000, 0x00000000, 0x00000000, 0x00001100,
0x00000000, 0x01000000, 0x00100000, 0x00010000, // 002fh
0x00001000, 0x00000100, 0x00000010, 0x00000001,
0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0030h
0x01000001, 0x01000001, 0x01000001, 0x00111110,
0x00000000, 0x00011100, 0x00010000, 0x00010000, // 0031h
0x00010000, 0x00010000, 0x00010000, 0x00010000,
0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0032h
0x00111110, 0x00000001, 0x00000001, 0x01111111,
0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0033h
0x00111110, 0x01000000, 0x01000001, 0x00111110,
0x00000000, 0x00100000, 0x00110000, 0x00101000, // 0034h
0x00100100, 0x00100010, 0x01111111, 0x00100000,
0x00000000, 0x01111111, 0x00000001, 0x00111111, // 0035h
0x01000000, 0x01000000, 0x01000001, 0x00111110,
0x00000000, 0x00111110, 0x00000001, 0x00111111, // 0036h
0x01000001, 0x01000001, 0x01000001, 0x00111110,
0x00000000, 0x01111111, 0x00100000, 0x00100000, // 0037h
0x00010000, 0x00010000, 0x00001000, 0x00001000,
0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0038h
0x00111110, 0x01000001, 0x01000001, 0x00111110,
0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0039h
0x01000001, 0x01111110, 0x01000000, 0x00111110,
0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003ah
0x00000000, 0x00000000, 0x00001100, 0x00000000,
0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003bh
0x00000000, 0x00001100, 0x00001000, 0x00000100,
0x00000000, 0x01100000, 0x00011000, 0x00000110, // 003ch
0x00000001, 0x00000110, 0x00011000, 0x01100000,
0x00000000, 0x00000000, 0x01111111, 0x00000000, // 003dh
0x00000000, 0x00000000, 0x01111111, 0x00000000,
0x00000000, 0x00000011, 0x00001100, 0x00110000, // 003eh
0x01000000, 0x00110000, 0x00001100, 0x00000011,
0x00000000, 0x00111110, 0x01000001, 0x01000001, // 003fh
0x00110000, 0x00001000, 0x00000000, 0x00001000,
0x00000000, 0x00011100, 0x00100010, 0x01001001, // 0040h
0x01010101, 0x01010101, 0x01010101, 0x00111010,
0x00000000, 0x00001000, 0x00010100, 0x00010100, // 0041h
0x00100010, 0x00111110, 0x01000001, 0x01000001,
0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0042h
0x00111111, 0x01000001, 0x01000001, 0x00111111,
0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0043h
0x00000001, 0x00000001, 0x01000010, 0x00111100,
0x00000000, 0x00011111, 0x00100001, 0x01000001, // 0044h
0x01000001, 0x01000001, 0x00100001, 0x00011111,
0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0045h
0x01111111, 0x00000001, 0x00000001, 0x01111111,
0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0046h
0x00111111, 0x00000001, 0x00000001, 0x00000001,
0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0047h
0x01111001, 0x01000001, 0x01000010, 0x00111100,
0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0048h
0x01111111, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x00111110, 0x00001000, 0x00001000, // 0049h
0x00001000, 0x00001000, 0x00001000, 0x00111110,
0x00000000, 0x01000000, 0x01000000, 0x01000000, // 004ah
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x01100001, 0x00011001, 0x00000101, // 004bh
0x00000011, 0x00000101, 0x00011001, 0x01100001,
0x00000000, 0x00000001, 0x00000001, 0x00000001, // 004ch
0x00000001, 0x00000001, 0x00000001, 0x01111111,
0x00000000, 0x01000001, 0x01100011, 0x01010101, // 004dh
0x01001001, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x01000001, 0x01000011, 0x01000101, // 004eh
0x01001001, 0x01010001, 0x01100001, 0x01000001,
0x00000000, 0x00011100, 0x00100010, 0x01000001, // 004fh
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0050h
0x00111111, 0x00000001, 0x00000001, 0x00000001,
0x00000000, 0x00011100, 0x00100010, 0x01000001, // 0051h
0x01000001, 0x01011001, 0x00100010, 0x01011100,
0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0052h
0x00111111, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x00111110, 0x01000001, 0x00000001, // 0053h
0x00111110, 0x01000000, 0x01000001, 0x00111110,
0x00000000, 0x01111111, 0x00001000, 0x00001000, // 0054h
0x00001000, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0055h
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x01000001, 0x01000001, 0x00100010, // 0056h
0x00100010, 0x00010100, 0x00010100, 0x00001000,
0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0057h
0x01001001, 0x01010101, 0x01100011, 0x01000001,
0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0058h
0x00001000, 0x00010100, 0x00100010, 0x01000001,
0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0059h
0x00001000, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x01111111, 0x00100000, 0x00010000, // 005ah
0x00001000, 0x00000100, 0x00000010, 0x01111111,
0x00000000, 0x01111100, 0x00000100, 0x00000100, // 005bh
0x00000100, 0x00000100, 0x00000100, 0x01111100,
0x00000000, 0x00100010, 0x00010100, 0x00111110, // 005ch
0x00001000, 0x00111110, 0x00001000, 0x00001000,
0x00000000, 0x00011111, 0x00010000, 0x00010000, // 005dh
0x00010000, 0x00010000, 0x00010000, 0x00011111,
0x00000000, 0x00001000, 0x00010100, 0x00100010, // 005eh
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 005fh
0x00000000, 0x00000000, 0x00000000, 0x01111111,
0x00000000, 0x00010000, 0x00001000, 0x00011000, // 0060h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00011110, 0x00100001, // 0061h
0x00111110, 0x00100001, 0x00100001, 0x01011110,
0x00000000, 0x00000001, 0x00000001, 0x00111111, // 0062h
0x01000001, 0x01000001, 0x01000001, 0x00111111,
0x00000000, 0x00000000, 0x00111100, 0x01000010, // 0063h
0x00000001, 0x00000001, 0x01000010, 0x00111100,
0x00000000, 0x01000000, 0x01000000, 0x01111110, // 0064h
0x01000001, 0x01000001, 0x01000001, 0x01111110,
0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0065h
0x01111111, 0x00000001, 0x01000001, 0x00111110,
0x00000000, 0x00110000, 0x00001000, 0x00001000, // 0066h
0x01111111, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x00000000, 0x01111110, 0x01000001, // 0067h
0x01000001, 0x01111110, 0x01000000, 0x00111110,
0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0068h
0x00111111, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x00001000, 0x00000000, 0x00001000, // 0069h
0x00001000, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x00100000, 0x00000000, 0x00100000, // 006ah
0x00100000, 0x00100001, 0x00100001, 0x00011110,
0x00000000, 0x00000001, 0x00000001, 0x01100001, // 006bh
0x00011001, 0x00000111, 0x00011001, 0x01100001,
0x00000000, 0x00001000, 0x00001000, 0x00001000, // 006ch
0x00001000, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x00000000, 0x00110111, 0x01001001, // 006dh
0x01001001, 0x01001001, 0x01001001, 0x01001001,
0x00000000, 0x00000000, 0x00111111, 0x01000001, // 006eh
0x01000001, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x00000000, 0x00011100, 0x00100010, // 006fh
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x00000000, 0x00111101, 0x01000011, // 0070h
0x01000001, 0x01000011, 0x00111101, 0x00000001,
0x00000000, 0x00000000, 0x01011110, 0x01100001, // 0071h
0x01000001, 0x01100001, 0x01011110, 0x01000000,
0x00000000, 0x00000000, 0x00110001, 0x00001101, // 0072h
0x00000011, 0x00000001, 0x00000001, 0x00000001,
0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0073h
0x00001110, 0x00110000, 0x01000001, 0x00111110,
0x00000000, 0x00000100, 0x00000100, 0x01111111, // 0074h
0x00000100, 0x00000100, 0x00000100, 0x01111000,
0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0075h
0x01000001, 0x01000001, 0x01000001, 0x01111110,
0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0076h
0x00100010, 0x00100010, 0x00010100, 0x00001000,
0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0077h
0x01001001, 0x00101010, 0x00101010, 0x00010100,
0x00000000, 0x00000000, 0x00100001, 0x00010010, // 0078h
0x00001100, 0x00001100, 0x00010010, 0x00100001,
0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0079h
0x00100010, 0x00011100, 0x00001000, 0x00000110,
0x00000000, 0x00000000, 0x00111111, 0x00010000, // 007ah
0x00001000, 0x00000100, 0x00000010, 0x00111111,
0x00000000, 0x00001000, 0x00011110, 0x01100100, // 007bh
0x00011000, 0x00100100, 0x00000100, 0x01111000,
0x00000000, 0x00000000, 0x00011110, 0x00000100, // 007ch
0x00011110, 0x00110101, 0x00101101, 0x00010010,
0x00000000, 0x00000000, 0x00000000, 0x00010001, // 007dh
0x00100001, 0x00100001, 0x00000001, 0x00000010,
0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007eh
0x00011110, 0x00100000, 0x00100000, 0x00011100,
0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007fh
0x00111110, 0x00010000, 0x00001100, 0x00110010,
0x00000000, 0x00000000, 0x00000100, 0x00101111, // 0080h
0x01000100, 0x00011110, 0x00100101, 0x00010110,
0x00000000, 0x00000000, 0x00001010, 0x00011110, // 0081h
0x00101011, 0x00100010, 0x00010100, 0x00000100,
0x00000000, 0x00000000, 0x00001000, 0x00011101, // 0082h
0x00101011, 0x00101001, 0x00011001, 0x00000100,
0x00000000, 0x00000000, 0x00001000, 0x00111000, // 0083h
0x00001000, 0x00011110, 0x00101001, 0x00000110,
0x00000000, 0x00000000, 0x00000000, 0x00011100, // 0084h
0x00100011, 0x00100000, 0x00100000, 0x00011100,
0x00000000, 0x00000110, 0x01001001, 0x00110000, // 0085h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000100, 0x00111111, 0x00000100, // 0086h
0x00111110, 0x01010101, 0x01001101, 0x00100110,
0x00000000, 0x00000000, 0x00100001, 0x01000001, // 0087h
0x01000001, 0x01000001, 0x00000001, 0x00000010,
0x00000000, 0x00111100, 0x00000000, 0x00111110, // 0088h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x00011100, 0x00000000, 0x00111110, // 0089h
0x00010000, 0x00001000, 0x00010100, 0x01100010,
0x00000000, 0x00100100, 0x01011111, 0x00000100, // 008ah
0x00111110, 0x01000101, 0x01000101, 0x00100010,
0x00000000, 0x00100010, 0x01001111, 0x01010010, // 008bh
0x01010010, 0x00010010, 0x00010010, 0x00001001,
0x00000000, 0x00000100, 0x00111110, 0x00001000, // 008ch
0x00111110, 0x00010000, 0x00000010, 0x00111100,
0x00000000, 0x00100000, 0x00011000, 0x00000110, // 008dh
0x00000001, 0x00000110, 0x00011000, 0x00100000,
0x00000000, 0x00100000, 0x01111101, 0x00100001, // 008eh
0x00100001, 0x00100001, 0x00100001, 0x00010010,
0x00000000, 0x00011110, 0x00100000, 0x00000000, // 008fh
0x00000000, 0x00000001, 0x00000001, 0x00111110,
0x00000000, 0x00001000, 0x01111111, 0x00010000, // 0090h
0x00100000, 0x00000010, 0x00000010, 0x00111100,
0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0091h
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x00010000, 0x01111111, 0x00011000, // 0092h
0x00010100, 0x00010100, 0x00011000, 0x00001100,
0x00000000, 0x00100010, 0x01111111, 0x00100010, // 0093h
0x00100010, 0x00000010, 0x00000010, 0x01111100,
0x00000000, 0x00111100, 0x00010000, 0x00001100, // 0094h
0x01111111, 0x00001000, 0x00001000, 0x00110000,
0x00000000, 0x00000100, 0x00011111, 0x00000100, // 0095h
0x01110100, 0x00000010, 0x00001010, 0x01110010,
0x00000000, 0x00001000, 0x01111111, 0x00000100, // 0096h
0x00111100, 0x01000010, 0x01000000, 0x00111100,
0x00000000, 0x00000000, 0x00011100, 0x00100011, // 0097h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x01111111, 0x00010000, 0x00001000, // 0098h
0x00001000, 0x00001000, 0x00001000, 0x00110000,
0x00000000, 0x00000010, 0x00110010, 0x00001100, // 0099h
0x00000010, 0x00000001, 0x00000001, 0x00111110,
0x00000000, 0x00100100, 0x01001111, 0x01000010, // 009ah
0x00010001, 0x00111100, 0x00010010, 0x00001100,
0x00000000, 0x00000010, 0x01111010, 0x01000010, // 009bh
0x00000010, 0x00000010, 0x00001010, 0x01110010,
0x00000000, 0x00100010, 0x00111110, 0x01010010, // 009ch
0x01001011, 0x01101101, 0x01010101, 0x00110010,
0x00000000, 0x00110010, 0x01001011, 0x01000110, // 009dh
0x01000110, 0x01110010, 0x01001011, 0x00110010,
0x00000000, 0x00011100, 0x00101010, 0x01001001, // 009eh
0x01001001, 0x01000101, 0x01000101, 0x00110010,
0x00000000, 0x00100001, 0x01111101, 0x00100001, // 009fh
0x00100001, 0x00111001, 0x01100101, 0x00011001,
0x00000000, 0x00000100, 0x00100011, 0x01100010, // 00a0h
0x00100001, 0x00100001, 0x00010010, 0x00001100,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a1h
0x00000000, 0x00000100, 0x00001010, 0x00000100,
0x00000000, 0x01110000, 0x00010000, 0x00010000, // 00a2h
0x00010000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a3h
0x00001000, 0x00001000, 0x00001000, 0x00001110,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a4h
0x00000000, 0x00000010, 0x00000100, 0x00000100,
0x00000000, 0x00000000, 0x00000000, 0x00011000, // 00a5h
0x00011000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x01111111, 0x01000000, 0x01111111, // 00a6h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x00000000, 0x00111111, 0x00100000, // 00a7h
0x00010100, 0x00001100, 0x00000100, 0x00000010,
0x00000000, 0x00000000, 0x00100000, 0x00100000, // 00a8h
0x00010000, 0x00001111, 0x00001000, 0x00001000,
0x00000000, 0x00000000, 0x00000100, 0x00111111, // 00a9h
0x00100001, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00aah
0x00001000, 0x00001000, 0x00001000, 0x01111111,
0x00000000, 0x00000000, 0x00010000, 0x00111111, // 00abh
0x00011000, 0x00010100, 0x00010010, 0x00011001,
0x00000000, 0x00000000, 0x00000010, 0x00111111, // 00ach
0x00100010, 0x00010010, 0x00000100, 0x00000100,
0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00adh
0x00100000, 0x00100000, 0x00100000, 0x01111111,
0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00aeh
0x00111110, 0x00100000, 0x00100000, 0x00111110,
0x00000000, 0x00000000, 0x00100101, 0x00101010, // 00afh
0x00101010, 0x00100000, 0x00010000, 0x00001110,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00b0h
0x01111111, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x01111111, 0x01000000, 0x00101000, // 00b1h
0x00011000, 0x00001000, 0x00001000, 0x00000100,
0x00000000, 0x01000000, 0x00100000, 0x00011000, // 00b2h
0x00010111, 0x00010000, 0x00010000, 0x00010000,
0x00000000, 0x00001000, 0x01111111, 0x01000001, // 00b3h
0x01000001, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x00000000, 0x00111110, 0x00001000, // 00b4h
0x00001000, 0x00001000, 0x00001000, 0x01111111,
0x00000000, 0x00100000, 0x01111111, 0x00110000, // 00b5h
0x00101000, 0x00100100, 0x00100010, 0x00110001,
0x00000000, 0x00000100, 0x01111111, 0x01000100, // 00b6h
0x01000100, 0x01000100, 0x01000010, 0x00100001,
0x00000000, 0x00000100, 0x00111111, 0x00001000, // 00b7h
0x01111111, 0x00010000, 0x00010000, 0x00010000,
0x00000000, 0x01111100, 0x01000100, 0x01000100, // 00b8h
0x01000010, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x00000010, 0x01111110, 0x00100010, // 00b9h
0x00100001, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00bah
0x01000000, 0x01000000, 0x01000000, 0x01111110,
0x00000000, 0x00100010, 0x01111111, 0x00100010, // 00bbh
0x00100010, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x00000011, 0x00000100, 0x01000011, // 00bch
0x01000100, 0x00100000, 0x00011000, 0x00000111,
0x00000000, 0x01111111, 0x01000000, 0x00100000, // 00bdh
0x00010000, 0x00011000, 0x00100100, 0x01000011,
0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00beh
0x00100010, 0x00000010, 0x00000010, 0x01111100,
0x00000000, 0x01000001, 0x01000010, 0x01000000, // 00bfh
0x00100000, 0x00100000, 0x00011000, 0x00000110,
0x00000000, 0x01111110, 0x01000010, 0x01001110, // 00c0h
0x01110001, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x01100000, 0x00011110, 0x00010000, // 00c1h
0x01111111, 0x00010000, 0x00010000, 0x00001100,
0x00000000, 0x01000101, 0x01001010, 0x01001010, // 00c2h
0x01000000, 0x00100000, 0x00010000, 0x00001110,
0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00c3h
0x00010000, 0x00010000, 0x00001000, 0x00000110,
0x00000000, 0x00000010, 0x00000010, 0x00000110, // 00c4h
0x00011010, 0x01100010, 0x00000010, 0x00000010,
0x00000000, 0x00010000, 0x00010000, 0x01111111, // 00c5h
0x00010000, 0x00010000, 0x00001000, 0x00000110,
0x00000000, 0x00000000, 0x00111110, 0x00000000, // 00c6h
0x00000000, 0x00000000, 0x00000000, 0x01111111,
0x00000000, 0x01111110, 0x01000000, 0x01000100, // 00c7h
0x00101000, 0x00010000, 0x00101000, 0x01000110,
0x00000000, 0x00001000, 0x01111111, 0x00100000, // 00c8h
0x00010000, 0x00011100, 0x01101011, 0x00001000,
0x00000000, 0x01000000, 0x01000000, 0x01000000, // 00c9h
0x00100000, 0x00100000, 0x00011000, 0x00000111,
0x00000000, 0x00010010, 0x00100010, 0x00100010, // 00cah
0x01000010, 0x01000010, 0x01000001, 0x01000001,
0x00000000, 0x00000001, 0x00000001, 0x01111111, // 00cbh
0x00000001, 0x00000001, 0x00000001, 0x01111110,
0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cch
0x01000000, 0x00100000, 0x00010000, 0x00001110,
0x00000000, 0x00000000, 0x00000100, 0x00001010, // 00cdh
0x00010001, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x00001000, 0x00001000, 0x01111111, // 00ceh
0x00001000, 0x00101010, 0x01001010, 0x01001001,
0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cfh
0x00100010, 0x00010100, 0x00001000, 0x00010000,
0x00000000, 0x00001110, 0x01110000, 0x00001110, // 00d0h
0x01110000, 0x00000110, 0x00011000, 0x01100000,
0x00000000, 0x00001000, 0x00001000, 0x00000100, // 00d1h
0x00000100, 0x00100010, 0x01000010, 0x01111111,
0x00000000, 0x01000000, 0x01000000, 0x00100100, // 00d2h
0x00101000, 0x00010000, 0x00101100, 0x01000011,
0x00000000, 0x01111111, 0x00000100, 0x01111111, // 00d3h
0x00000100, 0x00000100, 0x00000100, 0x01111000,
0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00d4h
0x00100010, 0x00010100, 0x00000100, 0x00000100,
0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00d5h
0x00100000, 0x00100000, 0x00100000, 0x01111111,
0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00d6h
0x01111110, 0x01000000, 0x01000000, 0x01111110,
0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00d7h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00d8h
0x01000010, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x00001010, 0x00001010, 0x00001010, // 00d9h
0x01001010, 0x01001010, 0x00101010, 0x00011001,
0x00000000, 0x00000010, 0x00000010, 0x01000010, // 00dah
0x01000010, 0x00100010, 0x00010010, 0x00001110,
0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dbh
0x01000001, 0x01000001, 0x01000001, 0x01111111,
0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dch
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x01000011, 0x01000100, 0x01000000, // 00ddh
0x01000000, 0x00100000, 0x00010000, 0x00001111,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00deh
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00dfh
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00011110, 0x00001000, 0x00000100, // 00e0h
0x00101001, 0x01010001, 0x01010001, 0x00001100,
0x00000000, 0x00000000, 0x00001100, 0x00010010, // 00e1h
0x00010010, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x01111101, 0x00100001, 0x01111101, // 00e2h
0x00100001, 0x00111001, 0x01100101, 0x00011001,
0x00000000, 0x00111100, 0x00010000, 0x00111100, // 00e3h
0x00010000, 0x00011100, 0x00110010, 0x00001100,
0x00000000, 0x00001110, 0x00101000, 0x00101000, // 00e4h
0x00111110, 0x01100101, 0x00100101, 0x00010010,
0x00000000, 0x00000100, 0x00101111, 0x01000100, // 00e5h
0x00000110, 0x01000101, 0x01000101, 0x00111110,
0x00000000, 0x00100010, 0x00100010, 0x00111110, // 00e6h
0x01010010, 0x01010101, 0x01001101, 0x00100110,
0x00000000, 0x00000100, 0x00011111, 0x00000010, // 00e7h
0x00011111, 0x01000010, 0x01000010, 0x00111100,
0x00000000, 0x00010010, 0x00111110, 0x01010011, // 00e8h
0x01000010, 0x00100100, 0x00000100, 0x00000100,
0x00000000, 0x00001000, 0x00111101, 0x01001011, // 00e9h
0x01001001, 0x01001001, 0x00111000, 0x00000100,
0x00000000, 0x00001000, 0x00111000, 0x00001000, // 00eah
0x00001000, 0x00011110, 0x00101001, 0x00000110,
0x00000000, 0x00011000, 0x00100000, 0x00000100, // 00ebh
0x00111010, 0x01000110, 0x01000000, 0x00111000,
0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00ech
0x01000110, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00edh
0x01000011, 0x01001100, 0x01010010, 0x00111100,
0x00000000, 0x00100010, 0x00110011, 0x00101010, // 00eeh
0x00100110, 0x00100010, 0x00100011, 0x01000010,
0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00efh
0x01000011, 0x01000000, 0x01000010, 0x00111100,
0x00000000, 0x00000010, 0x00111011, 0x01000110, // 00f0h
0x01000010, 0x01000011, 0x01000010, 0x00110010,
0x00000000, 0x00000100, 0x00000100, 0x00000010, // 00f1h
0x01000110, 0x01000101, 0x01000101, 0x00111001,
0x00000000, 0x01010100, 0x01111111, 0x00100100, // 00f2h
0x00100100, 0x00100100, 0x00100010, 0x00010001,
0x00000000, 0x01010100, 0x01011111, 0x00000100, // 00f3h
0x00111111, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x01011110, 0x01100010, 0x00100010, // 00f4h
0x00100001, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x01010010, 0x01111110, 0x00100010, // 00f5h
0x00100001, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x01010000, 0x01111111, 0x00100000, // 00f6h
0x00100000, 0x00100000, 0x00100000, 0x00111111,
0x00000000, 0x01010010, 0x01010010, 0x00111111, // 00f7h
0x00010010, 0x00010000, 0x00010000, 0x00001100,
0x00000000, 0x01010011, 0x01010100, 0x00100011, // 00f8h
0x00100100, 0x00010000, 0x00001000, 0x00000111,
0x00000000, 0x01010000, 0x01011111, 0x00010000, // 00f9h
0x00001000, 0x00001100, 0x00010010, 0x00100001,
0x00000000, 0x01010010, 0x01111111, 0x00100010, // 00fah
0x00010010, 0x00000010, 0x00000010, 0x00111100,
0x00000000, 0x01010001, 0x01010010, 0x00100000, // 00fbh
0x00100000, 0x00010000, 0x00001000, 0x00000110,
0x00000000, 0x01011110, 0x01010010, 0x00100110, // 00fch
0x00111001, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x01010000, 0x01011110, 0x00010000, // 00fdh
0x01111111, 0x00010000, 0x00010000, 0x00001100,
0x00000000, 0x00100101, 0x01001010, 0x00101010, // 00feh
0x00100000, 0x00010000, 0x00001000, 0x00000111,
0x00000000, 0x01011110, 0x01010000, 0x00111111, // 00ffh
0x00001000, 0x00001000, 0x00001000, 0x00000110
};

View File

@ -0,0 +1,172 @@
/*---------------------------------------------------------------------------*
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 <nitro.h>
#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();
//********************************
}
}

View File

@ -0,0 +1,97 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - MB - demos - cloneboot
File: main.c
Copyright 2005-2009 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 <twl.h>
#else
#include <nitro.h>
#endif
#include "common.h"
/*
* .
*
* MBライブラリのサンプルはマルチブート機能を使うため
* ()
* $TwlSDK/bin/ARM9-TS/Rom/
* mb_child_NITRO.srl, mb_child_TWL.srl
*
*
*
*
*/
/*
* WH 使
*
* WH
* WH
* wm/dataShare-Model
*/
/******************************************************************************/
//============================================================================
// 関数定義
//============================================================================
/*---------------------------------------------------------------------------*
Name: NitroMain / TwlMain
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
#ifdef SDK_TWL
void TwlMain(void)
#else
void NitroMain(void)
#endif
{
/*
* , multiboot-Model 使
* DSダウンロードプレイ子機プログラムかどうかを判断して
* .
*
*
* 1. CARD
* 2. 8kB
* 3. /
* .
*
*
*
* CARD-ROM .
* , DSダウンロードプレイの親機と子機の間に全く共通点が無ければ
* .
*/
if (!MB_IsMultiBootChild())
{
ParentMain();
}
else
{
ChildMain();
}
/* 制御はここへ及びません */
}

View File

@ -0,0 +1,585 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - MB - demos - cloneboot
File: parent.c
Copyright 2006-2009 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <nitro/wm.h>
#include <nitro/mb.h>
#include "mbp.h"
#include "common.h"
#include "disp.h"
#include "gmain.h"
#include "wh.h"
#include "bt.h"
/******************************************************************************/
void sd_proc(void *p1);
static void GetChannelMain(void);
static BOOL ConnectMain(u16 tgid);
static void PrintChildState(void);
static BOOL JudgeConnectableChild(WMStartParentCallback *cb);
// ブロック転送状態通知関数
void BlockTransferCallback(void *arg);
//============================================================================
// 定数定義
//============================================================================
#define STACK_SIZE 1024
#define THREAD1_PRIO 15
#define MESSAGE_RECV (OSMessage)100
/* このデモで使用する GGID */
#define WH_GGID SDK_MAKEGGID_SYSTEM(0x22)
/* このデモがダウンロードさせるプログラム情報 */
const MBGameRegistry mbGameList = {
/*
* NULL .
* MBP MBP_RegistFile() ,
* MB_RegisterFile() .
*/
NULL,
(u16 *)L"CardCopyMultiBoot", // ゲーム名
(u16 *)L"CardCopyMultiBoot(cloneboot)", // ゲーム内容説明
"/data/icon.char", // アイコンキャラクタデータ
"/data/icon.plt", // アイコンパレットデータ
WH_GGID, // GGID
MBP_CHILD_MAX + 1, // 最大プレイ人数、親機の数も含めた人数
};
//============================================================================
// 変数定義
//============================================================================
OSThread sd_thread;
u32 stack1[STACK_SIZE / sizeof(u32)];
OSMessage mesgBuffer[10];
OSMessageQueue mesgQueue;
FSFile file;
BOOL writable = TRUE;
static s32 gFrame; // フレームカウンタ
extern u8 gRecvBuf[];
//-----------------------
// 通信経路の保持用
//-----------------------
static u16 sChannel = 0;
static const MBPChildInfo *sChildInfo[MBP_CHILD_MAX];
//============================================================================
// 関数定義
//============================================================================
void sd_proc(void *p1)
{
#pragma unused(p1)
OSMessage src;
while (1)
{
writable = TRUE;
(void)WH_SendData(&writable, sizeof(writable), NULL);
(void)OS_ReceiveMessage(&mesgQueue, &src, OS_MESSAGE_BLOCK);
writable = FALSE;
if (FS_WriteFile(&file, (void*)src, WH_CHILD_SIZE) == -1)
{
BgPutString(8, 3, 0x2, "Write SD File error!");
OS_WaitVBlankIntr();
OS_Terminate();
}
if ( ((u8*)src)[WH_CHILD_SIZE] == TRUE )
{
(void)FS_CloseFile(&file);
}
}
}
/*****************************************************************************/
/* 親機専用領域 .parent セクションの定義範囲を開始します */
#include <nitro/parent_begin.h>
/*****************************************************************************/
/*---------------------------------------------------------------------------*
Name: ParentMain
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void ParentMain(void)
{
FSFile dir;
u16 tgid = 0;
// 画面、OSの初期化
CommonInit();
// 画面初期化
DispInit();
// ヒープの初期化
InitAllocateSystem();
// WH に情報を設定
WH_SetGgid(WH_GGID);
// 割り込み有効
(void)OS_EnableIrq();
(void)OS_EnableInterrupts();
DispOn();
// FS 初期化
{
static u32 fs_tablework[0x100 / 4];
FS_Init(FS_DMA_NOT_USE);
(void)FS_LoadTable(fs_tablework, sizeof(fs_tablework));
}
FS_InitFatDriver();
{
static const char *path = "sdmc:/card_dump.sbin";
FS_InitFile(&file);
(void)FS_OpenDirectory(&dir, "sdmc:/", FS_FILEMODE_RW);
(void)FS_CreateFile(path, FS_PERMIT_R|FS_PERMIT_W);
if (!FS_OpenFileEx(&file, path, FS_FILEMODE_RW))
{
BgPutString(8, 1, 0x2, "Cannot open writable SD File!");
OS_WaitVBlankIntr();
OS_Terminate();
}
(void)FS_SetFileLength(&file, 0);
}
while (TRUE)
{
OS_WaitVBlankIntr();
// トラフィックの少ないチャンネルの検索処理
GetChannelMain();
/*
* tgidは親機が起動の度に基本的には前回と違う値を設定します
* tgidで起動しなければ
*
* tgidを保存しておく
*
*/
// マルチブート配信処理
if (ConnectMain(++tgid))
{
// マルチブート子機の起動に成功
break;
}
else
{
// WH モジュールを終了させて繰り返し
WH_Finalize();
while(WH_GetSystemState()==WH_SYSSTATE_BUSY){}
(void)WH_End();
while(WH_GetSystemState()==WH_SYSSTATE_BUSY){}
}
}
//--------------
// マルチブート後は子機がリセットされ通信が一旦切断されます。
// また現状親機も一度MB_End()から通信を終了する必要があります。
// 親子共一度完全に切断された状態で一から通信を確立してください。
//
// またこの時子機のaidがシャッフルされるため、もし必要があれば
// マルチブート前のaidとMACアドレスの組み合わせを保存しておき、
// 再接続時に新しいaidとの結びつけを行なってください。
//--------------
#if !defined(MBP_USING_MB_EX)
if (!WH_Initialize())
{
OS_Panic("WH_Initialize failed.");
}
#endif
// 接続子機の判定用関数を設定
WH_SetJudgeAcceptFunc(JudgeConnectableChild);
// SDスレッド生成
OS_InitMessageQueue(&mesgQueue, &mesgBuffer[0], 10);
OS_CreateThread(&sd_thread, sd_proc, NULL, stack1 + STACK_SIZE / sizeof(u32), STACK_SIZE, THREAD1_PRIO);
/* メインルーチン */
while (TRUE)
{
OS_WaitVBlankIntr();
ReadKey();
// BgClear();
switch (WH_GetSystemState())
{
case WH_SYSSTATE_ERROR:
case WH_SYSSTATE_CONNECT_FAIL:
WH_Reset();
break;
case WH_SYSSTATE_IDLE:
/* ----------------
*
* tgid及びchannelを合わせる必要があります
* channelとマルチブート時のtgid+1
* 使
*
* MACアドレスを指定して再スキャンさせる場合には同じtgid, channelでなくても
*
* ---------------- */
(void)WH_ParentConnect(WH_CONNECTMODE_MP_PARENT, (u16)(tgid + 1), sChannel);
WH_SetReceiver(MpReceiveCallback);
// SDスレッド起動
OS_WakeupThreadDirect(&sd_thread);
break;
case WH_SYSSTATE_CONNECTED:
{
BgPutString(8, 1, 0x2, "Parent mode");
// ModeChild();
}
break;
}
// 子機状態を表示する
ModeParent();
}
}
/*---------------------------------------------------------------------------*
Name: GetChannelMain
Description: 使使調
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void GetChannelMain(void)
{
/*-----------------------------------------------*
* 使調
* 使
* WM_MeasureChannel()IDLE状態になる必要があり
* IDLE状態に止まる事がないので実行できません
* WM_Initializeを呼んで電波使用率を調べてからWM_Endで終了し
* MB_Initを実行する
*-----------------------------------------------*/
if (!WH_Initialize())
{
OS_Panic("WH_Initialize failed.");
}
while (TRUE)
{
ReadKey();
BgClear();
BgSetMessage(PLTT_YELLOW, " Search Channel ");
switch (WH_GetSystemState())
{
//-----------------------------------------
// 初期化完了
case WH_SYSSTATE_IDLE:
// BgSetMessage(PLTT_WHITE, " Push A Button to start ");
// if (IS_PAD_TRIGGER(PAD_BUTTON_A))
{
BgSetMessage(PLTT_YELLOW, "Check Traffic ratio ");
(void)WH_StartMeasureChannel();
}
break;
//-----------------------------------------
// チャンネル検索完了
case WH_SYSSTATE_MEASURECHANNEL:
{
sChannel = WH_GetMeasureChannel();
#if !defined(MBP_USING_MB_EX)
(void)WH_End();
#else
/* IDLE 状態を維持したままマルチブート処理へ */
return;
#endif
}
break;
//-----------------------------------------
// WM終了
case WH_SYSSTATE_STOP:
/* WM_Endが完了したらマルチブート処理へ */
return;
//-----------------------------------------
// ビジー中
case WH_SYSSTATE_BUSY:
break;
//-----------------------------------------
// エラー発生
case WH_SYSSTATE_ERROR:
(void)WH_Reset();
break;
//-----------------------------------------
default:
OS_Panic("Illegal State\n");
}
OS_WaitVBlankIntr(); // Vブランク割込終了待ち
}
}
/*---------------------------------------------------------------------------*
Name: ConnectMain
Description:
Arguments: tgid tgidを指定します.
Returns: TRUE,
FALSE
*---------------------------------------------------------------------------*/
static BOOL ConnectMain(u16 tgid)
{
MBP_Init(mbGameList.ggid, tgid);
while (TRUE)
{
ReadKey();
BgClear();
BgPutString(6, 1, PLTT_RED, "Card Copy Multi Boot");
BgSetMessage(PLTT_YELLOW, " MB Parent ");
switch (MBP_GetState())
{
//-----------------------------------------
// アイドル状態
case MBP_STATE_IDLE:
{
MBP_Start(&mbGameList, sChannel);
}
break;
//-----------------------------------------
// 子機からのエントリー受付中
case MBP_STATE_ENTRY:
{
BgSetMessage(PLTT_YELLOW, " Wait for list on MB menu ");
// BgSetMessage(PLTT_WHITE, " Now Accepting ");
if (IS_PAD_TRIGGER(PAD_BUTTON_B))
{
// Bボタンでマルチブートキャンセル
// MBP_Cancel();
break;
}
// エントリー中の子機が一台でも存在すれば開始可能とする
if (MBP_GetChildBmp(MBP_BMPTYPE_ENTRY) ||
MBP_GetChildBmp(MBP_BMPTYPE_DOWNLOADING) ||
MBP_GetChildBmp(MBP_BMPTYPE_BOOTABLE))
{
BgSetMessage(PLTT_WHITE, " Push START Button to start ");
// if (IS_PAD_TRIGGER(PAD_BUTTON_START))
{
// ダウンロード開始
MBP_StartDownloadAll();
}
}
}
break;
//-----------------------------------------
// プログラム配信処理
case MBP_STATE_DATASENDING:
{
// 全員がダウンロード完了しているならばスタート可能.
if (MBP_IsBootableAll())
{
// ブート開始
MBP_StartRebootAll();
}
}
break;
//-----------------------------------------
// リブート処理
case MBP_STATE_REBOOTING:
{
BgSetMessage(PLTT_WHITE, " Rebooting now ");
}
break;
//-----------------------------------------
// 再接続処理
case MBP_STATE_COMPLETE:
{
// 全員無事に接続完了したらマルチブート処理は終了し
// 通常の親機として無線を再起動する。
BgSetMessage(PLTT_WHITE, " Reconnecting now ");
OS_WaitVBlankIntr();
return TRUE;
}
break;
//-----------------------------------------
// エラー発生
case MBP_STATE_ERROR:
{
// 通信をキャンセルする
MBP_Cancel();
}
break;
//-----------------------------------------
// 通信キャンセル処理中
case MBP_STATE_CANCEL:
// None
break;
//-----------------------------------------
// 通信異常終了
case MBP_STATE_STOP:
OS_WaitVBlankIntr();
return FALSE;
}
// 子機状態を表示する
PrintChildState();
OS_WaitVBlankIntr(); // Vブランク割込終了待ち
}
}
/*---------------------------------------------------------------------------*
Name: PrintChildState
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void PrintChildState(void)
{
static const char *STATE_NAME[] = {
"NONE ",
"CONNECTING ",
"REQUEST ",
"ENTRY ",
"DOWNLOADING",
"BOOTABLE ",
"BOOTING ",
};
enum
{
STATE_DISP_X = 2,
INFO_DISP_X = 15,
BASE_DISP_Y = 2
};
u16 i;
/* 子機リストの表示 */
for (i = 1; i <= MBP_CHILD_MAX; i++)
{
const MBPChildInfo *childInfo;
MBPChildState childState = MBP_GetChildState(i);
const u8 *macAddr;
SDK_ASSERT(childState < MBP_CHILDSTATE_NUM);
// 状態表示
BgPutString(STATE_DISP_X, i + BASE_DISP_Y, PLTT_WHITE, STATE_NAME[childState]);
// ユーザー情報表示
childInfo = MBP_GetChildInfo(i);
macAddr = MBP_GetChildMacAddress(i);
if (macAddr != NULL)
{
BgPrintStr(INFO_DISP_X, i + BASE_DISP_Y, PLTT_WHITE,
"%02x%02x%02x%02x%02x%02x",
macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], macAddr[5]);
}
}
}
/*---------------------------------------------------------------------------*
Name: JudgeConnectableChild
Description:
Arguments: cb .
Returns: TRUE.
FALSE.
*---------------------------------------------------------------------------*/
static BOOL JudgeConnectableChild(WMStartParentCallback *cb)
{
u16 playerNo;
/* cb->aid の子機のマルチブート時のaidをMACアドレスから検索します */
playerNo = MBP_GetPlayerNo(cb->macAddress);
OS_TPrintf("MB child(%d) -> MP child(%d)\n", playerNo, cb->aid);
if (playerNo == 0)
{
return FALSE;
}
sChildInfo[playerNo - 1] = MBP_GetChildInfo(playerNo);
return TRUE;
}
/*****************************************************************************/
/* 親機専用領域 .parent セクションの定義範囲を終了します */
#include <nitro/parent_end.h>
/*****************************************************************************/

View File

@ -0,0 +1,385 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - WBT - demos - wbt-1
File: text.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 <twl.h>
#else
#include <nitro.h>
#endif
#include "text.h"
#define TAB_SIZE 8
/*****************************************************/
static LINE_BUF *lb_free_ptr;
static int x_size = X_LINE_MAX;
static int y_size = Y_LINE_MAX;
static void link_line_buf(LINE_BUF * m, LINE_BUF * s)
{
if (m->next != NULL)
{
s->next = m->next;
(s->next)->prev = s;
}
else
s->next = NULL;
m->next = s;
s->prev = m;
}
static void unlink_line_buf(LINE_BUF * s)
{
if ((s->prev != NULL) && (s->next != NULL))
{
(s->prev)->next = s->next;
(s->next)->prev = s->prev;
s->next = NULL;
s->prev = NULL;
}
else if (s->next != NULL)
{
s->prev = NULL;
(s->next)->prev = NULL;
s->next = NULL;
}
else if (s->prev != NULL)
{
s->next = NULL;
(s->prev)->next = NULL;
s->prev = NULL;
}
}
static LINE_BUF *alloc_line_buf(void)
{
LINE_BUF *tmp;
tmp = lb_free_ptr;
lb_free_ptr = lb_free_ptr->next;
unlink_line_buf(tmp);
tmp->last_count = 0;
tmp->cur_count = 0;
#if 0
for (i = 0; i < LINE_BUF_X_SIZE; i++)
tmp->buf[i] = 0x20;
#endif
return (tmp);
}
static void free_line_buf(LINE_BUF * lb)
{
lb->next = lb_free_ptr;
lb->prev = NULL;
(lb->next)->prev = lb;
lb_free_ptr = lb;
}
static int init_lb_heap(void *heap_start, void *heap_end)
{
int i;
LINE_BUF *lb_heap = (LINE_BUF *) heap_start;
lb_free_ptr = (LINE_BUF *) heap_start;
lb_heap[0].prev = NULL;
i = 0;
while ((u32)&(lb_heap[i + 1]) < (u32)heap_end)
{
link_line_buf(&(lb_heap[i]), &(lb_heap[i + 1]));
i++;
}
lb_heap[i].next = NULL;
return i; /* num of line buffer */
}
static void init_text_buf(TEXT_BUF * tb)
{
tb->num_y = &y_size;
tb->num_x = &x_size;
tb->start = tb->cur = alloc_line_buf();
}
void init_text(TEXT_CTRL * tc, u16 *screen, u16 palette)
{
tc->screen = screen;
tc->x_line = 0;
tc->y_line = 0;
tc->palette = palette;
init_text_buf(&(tc->text_buf));
}
void m_set_palette(TEXT_CTRL * tc, u16 num)
{
tc->palette = (u16)(0x0f & num);
}
u16 m_get_palette(TEXT_CTRL * tc)
{
return tc->palette;
}
static void clear_line(TEXT_CTRL * tc)
{
int i;
i = tc->x_line;
for (; i < X_LINE_MAX; i++)
tc->screen[(tc->y_line * X_LINE_MAX) + i] = 0;
}
static void add_y_line(TEXT_CTRL * tc, u16 num)
{
tc->y_line += num;
if (tc->y_line > Y_LINE_MAX)
{
tc->y_line = 0;
}
}
static void add_x_line(TEXT_CTRL * tc, u16 num)
{
tc->x_line += num;
if (tc->x_line > X_LINE_MAX)
{
tc->x_line = 0;
tc->y_line++;
if (tc->y_line > Y_LINE_MAX)
{
tc->y_line = 0;
}
}
}
static void put_char_vram(TEXT_CTRL * tc, int c, u16 col)
{
switch (c)
{
case '\0':
break;
case '\n':
clear_line(tc);
tc->x_line = 0;
add_y_line(tc, 1);
break;
case '\r':
tc->x_line = 0;
break;
case '\t':
add_x_line(tc, TAB_SIZE);
break;
case '\f':
tc->x_line = 0;
tc->y_line = 0;
clear_line(tc);
break;
case '\b': /* Back Space */
case '\v': /* Vertical Tab */
break;
default:
if ((c < 0x20) || (0x7f < c))
c = 0x20; /* white space */
tc->screen[(tc->y_line * X_LINE_MAX) + tc->x_line] = (u16)((col << 12) | (0x00ff & c));
add_x_line(tc, 1);
}
}
/**********************/
void m_putchar(TEXT_CTRL * tc, int c)
{
int i;
LINE_BUF *tmp;
TEXT_BUF *tb = &(tc->text_buf);
switch (c)
{
case '\0':
break;
case '\n':
if (tb->cur->next == NULL)
{
tmp = tb->cur; /* 表示開始バッファを再計算 */
for (i = 0; i < *(tb->num_y) - 1 && i < LINE_BUF_Y_SIZE; i++)
{
if (tmp->prev == NULL)
break;
tmp = tmp->prev;
}
tb->start = tmp;
while (tmp->prev != NULL)
{ /* いらないバッファを解放 */
tmp = tmp->prev;
unlink_line_buf(tmp);
free_line_buf(tmp);
}
tmp = alloc_line_buf(); /* バッファを1つ取得 */
link_line_buf(tb->cur, tmp); /* 取得したバッファをカレント
*/
tb->cur = tmp; /* カレントバッファを更新 */
tb->cur->cur_count = 0;
tb->cur->last_count = 0;
}
else
{
tb->cur = tb->cur->next;
tb->cur->cur_count = 0;
tb->cur->last_count = 0;
}
break;
case '\r':
tb->cur->cur_count = 0;
break;
case '\t':
tb->cur->cur_count += TAB_SIZE;
if (tb->cur->cur_count > LINE_BUF_X_SIZE)
tb->cur->cur_count = LINE_BUF_X_SIZE;
if (tb->cur->cur_count > tb->cur->last_count)
tb->cur->last_count = tb->cur->cur_count;
break;
case '\f':
tb->cur = tb->start;
tb->cur->cur_count = 0;
tb->cur->last_count = 0;
break;
case '\a': /* BELL */
break;
case '\b': /* Back Space */
if (tb->cur->cur_count > 0)
tb->cur->cur_count--;
break;
case '\v': /* Vertical Tab */
break;
default:
tb->cur->buf[tb->cur->cur_count] = c;
tb->cur->col[tb->cur->cur_count] = tc->palette;
tb->cur->cur_count++;
if (tb->cur->cur_count > LINE_BUF_X_SIZE)
{
tb->cur->cur_count = LINE_BUF_X_SIZE;
break;
}
if (tb->cur->cur_count > tb->cur->last_count)
tb->cur->last_count = tb->cur->cur_count;
break;
}
}
int init_text_buf_sys(void *heap_start, void *heap_end)
{
return init_lb_heap(heap_start, heap_end);
}
void text_buf_to_vram(TEXT_CTRL * tc)
{
int x_line, line_no;
int c;
u16 col;
LINE_BUF *lb;
TEXT_BUF *tb = &(tc->text_buf);
lb = tb->start;
put_char_vram(tc, '\f', (u16)0);
for (line_no = 0; line_no < (*tb->num_y + 1); line_no++)
{
x_line = 0;
if (lb == NULL)
break;
while (x_line < lb->last_count)
{
if (x_line >= (*tb->num_x + 1))
{
break;
}
else
{
c = lb->buf[x_line];
col = lb->col[x_line];
put_char_vram(tc, c, col);
}
x_line++;
}
if (x_line <= *tb->num_x)
{
put_char_vram(tc, '\n', (u16)0);
}
lb = lb->next;
}
for (; line_no <= *tb->num_y; line_no++)
{
put_char_vram(tc, '\n', (u16)0);
}
}
void mprintf(const char *text, ...)
{
va_list vlist;
char temp[32];
s32 i = 0;
va_start(vlist, text);
(void)OS_VSNPrintf(temp, 32, text, vlist);
va_end(vlist);
for (i = 0; i < 33; i++)
{
m_putchar(tc[0], (int)temp[i]);
if (temp[i] == '\n')
{
break;
}
}
if (i > 32)
m_putchar(tc[0], '\n');
}
void mfprintf(TEXT_CTRL * tc, const char *text, ...)
{
va_list vlist;
char temp[32];
s32 i = 0;
va_start(vlist, text);
(void)OS_VSNPrintf(temp, 32, text, vlist);
va_end(vlist);
for (i = 0; i < 33; i++)
{
m_putchar(tc, (int)temp[i]);
if (temp[i] == '\n')
{
break;
}
}
if (i > 32)
m_putchar(tc, '\n');
}