1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - wireless_shared - demos - mbp 3 File: mbp.h 4 5 Copyright 2006-2009 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Date:: 2009-06-04#$ 14 $Rev: 10698 $ 15 $Author: okubata_ryoma $ 16 *---------------------------------------------------------------------------*/ 17 18 #ifndef NITROSDK_DEMO_WIRELESSSHARED_MBP_H_ 19 #define NITROSDK_DEMO_WIRELESSSHARED_MBP_H_ 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #include <nitro/mb.h> 26 27 28 /******************************************************************************/ 29 /* Constants */ 30 31 /* 32 * Game group ID 33 * 34 * You can now set a GGID for individual files with the MBGameRegistry structure, so you may not need to specify values with the MB_Init function in the future. 35 * 36 * 37 */ 38 39 /* 40 * Channel for the parent device to distribute 41 * 42 * The multiboot child cycles through all possible channels, so you may use one of the values permitted by the WM library (currently 3, 8, and 13). 43 * 44 * 45 * Make this variable to avoid communication congestion in user applications. 46 * Applications will decide when to change channels, but it is possible that the user will be given the opportunity to press a Restart button, for example, to deal with poor responsiveness. 47 * 48 * 49 */ 50 51 /* Maximum number of connectable child devices */ 52 #define MBP_CHILD_MAX (15) 53 54 /* DMA number to allocate to the MB library */ 55 #define MBP_DMA_NO (2) 56 57 /* 58 * Switch that uses the MB_StartParentFromIdle and MB_EndToIdle functions in the MB library. 59 * You can run multiboot processing through the IDLE state. 60 */ 61 #define MBP_USING_MB_EX 62 63 /* 64 * Switch to start sending data in advance to a child entry. 65 * Because data is sent immediately after entry, you can decrease the time spent waiting for downloads if you start before the maximum number of children is reached. 66 * 67 */ 68 #define MBP_USING_PREVIOUS_DOWNLOAD 69 70 71 /* MB parent device state */ 72 typedef struct 73 { 74 u16 state; // Parent state 75 u16 connectChildBmp; // Flag for all connected children 76 u16 requestChildBmp; // Flag for children that are requesting entry 77 u16 entryChildBmp; // Flag for children that are waiting for data 78 u16 downloadChildBmp; // Flag for children that are downloading data 79 u16 bootableChildBmp; // Flag for children that have completed downloading 80 u16 rebootChildBmp; // Flag for children that sent boot 81 } 82 MBPState; 83 84 85 /* Connected child device state */ 86 typedef struct 87 { 88 MBUserInfo user; 89 u8 macAddress[6]; 90 u16 playerNo; 91 } 92 MBPChildInfo; 93 94 95 /* The game sequence state value of this demo */ 96 enum 97 { 98 MBP_STATE_STOP, // Stop state 99 MBP_STATE_IDLE, // Idle state (Init done) 100 MBP_STATE_ENTRY, // Child entry accepting 101 MBP_STATE_DATASENDING, // MP data transmitting 102 MBP_STATE_REBOOTING, // Child rebooting 103 MBP_STATE_COMPLETE, // Child reboot completed 104 MBP_STATE_CANCEL, // Cancelling multiboot 105 MBP_STATE_ERROR, // Error occurred 106 MBP_STATE_NUM 107 }; 108 109 /* Type of connected state bitmap */ 110 typedef enum 111 { 112 MBP_BMPTYPE_CONNECT, // Connected child information 113 MBP_BMPTYPE_REQUEST, // Information of the child requesting connection 114 MBP_BMPTYPE_ENTRY, // Information of the child waiting for downloading after the entry 115 MBP_BMPTYPE_DOWNLOADING, // Information on the child that is downloading 116 MBP_BMPTYPE_BOOTABLE, // Bootable child 117 MBP_BMPTYPE_REBOOT, // Reboot completed child 118 MBP_BMPTYPE_NUM 119 } 120 MBPBmpType; 121 122 /* Multiboot child device state */ 123 typedef enum 124 { 125 MBP_CHILDSTATE_NONE, // No connection 126 MBP_CHILDSTATE_CONNECTING, // Connecting 127 MBP_CHILDSTATE_REQUEST, // Requesting connection 128 MBP_CHILDSTATE_ENTRY, // Undergoing entry 129 MBP_CHILDSTATE_DOWNLOADING, // Downloading 130 MBP_CHILDSTATE_BOOTABLE, // Boot waiting 131 MBP_CHILDSTATE_REBOOT, // Rebooting 132 MBP_CHILDSTATE_NUM 133 } 134 MBPChildState; 135 136 137 /******************************************************************************/ 138 /* Variables */ 139 140 /* Parent device initialization */ 141 void MBP_Init(u32 ggid, u32 tgid); 142 void MBP_Start(const MBGameRegistry *gameInfo, u16 channel); 143 144 /* Parent device main process in each single frame */ 145 const MBPState *MBP_Main(void); 146 147 void MBP_KickChild(u16 child_aid); 148 void MBP_AcceptChild(u16 child_aid); 149 void MBP_StartRebootAll(void); 150 void MBP_StartDownload(u16 child_aid); 151 void MBP_StartDownloadAll(void); 152 BOOL MBP_IsBootableAll(void); 153 154 void MBP_Cancel(void); 155 156 u16 MBP_GetState(void); 157 u16 MBP_GetChildBmp(MBPBmpType bmpType); 158 void MBP_GetConnectState(MBPState * state); 159 const u8 *MBP_GetChildMacAddress(u16 aid); 160 MBPChildState MBP_GetChildState(u16 aid); 161 u16 MBP_GetPlayerNo(const u8 *macAddress); 162 const MBPChildInfo *MBP_GetChildInfo(u16 child_aid); 163 164 165 #ifdef __cplusplus 166 }/* extern "C" */ 167 #endif 168 169 #endif // NITROSDK_DEMO_WIRELESSSHARED_MBP_H_ 170