1 /*---------------------------------------------------------------------------* 2 Project: NitroSDK - WM - demos - wireless-all 3 File: common.h 4 5 Copyright 2006-2008 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 $Log: common.h,v $ 14 Revision 1.2 2006/04/10 13:37:12 yosizaki 15 Cleaned up source code indent. 16 17 Revision 1.1 2006/04/10 13:07:32 yosizaki 18 Initial upload. 19 20 $NoKeywords: $ 21 *---------------------------------------------------------------------------*/ 22 #ifndef WM_DEMO_WIRELESS_ALL_COMMON_H_ 23 #define WM_DEMO_WIRELESS_ALL_COMMON_H_ 24 25 #ifdef SDK_TWL 26 #include <twl.h> 27 #else 28 #include <nitro.h> 29 #endif 30 31 #include "mbp.h" 32 #include "wh.h" 33 #include "wfs.h" 34 35 36 /*****************************************************************************/ 37 /* declaration */ 38 39 /* Key input structure used for data sharing */ 40 typedef struct 41 { 42 u32 count; /* Frame info */ 43 u16 key; /* Key information */ 44 u16 padding; 45 } 46 GShareData; 47 48 SDK_COMPILER_ASSERT(sizeof(GShareData) <= WH_DS_DATA_SIZE); 49 50 51 /*****************************************************************************/ 52 /* Constants */ 53 54 /* Palette color for text */ 55 enum 56 { 57 PLTT_BLACK = 0, 58 PLTT_BLUE = 1, 59 PLTT_RED = 2, 60 PLTT_PURPLE = 3, 61 PLTT_GREEN = 4, 62 PLTT_CYAN = 5, 63 PLTT_YELLOW = 6, 64 PLTT_WHITE = 7, 65 66 PLTT_LINK_ICON /* Palette for the wireless link strength display icon */ 67 }; 68 69 70 /*****************************************************************************/ 71 /* Functions */ 72 73 #ifdef __cplusplus 74 extern "C" { 75 #endif 76 77 /*---------------------------------------------------------------------------* 78 Name: InitCommon 79 80 Description: Common initialization functions 81 82 Arguments: None. 83 84 Returns: None. 85 *---------------------------------------------------------------------------*/ 86 void InitCommon(void); 87 88 /*---------------------------------------------------------------------------* 89 Name: IS_PAD_PRESS 90 91 Description: Determines own key status. 92 93 Arguments: The key flag for determination. 94 95 Returns: TRUE if the specified key is being pressed; FALSE otherwise. 96 97 *---------------------------------------------------------------------------*/ 98 BOOL IS_PAD_PRESS(u16 flag); 99 100 /*---------------------------------------------------------------------------* 101 Name: IS_PAD_TRIGGER 102 103 Description: Determines own key trigger status. 104 105 Arguments: The key flag for determination. 106 107 Returns: TRUE if specified key trigger is enabled; FALSE if not enabled. 108 109 *---------------------------------------------------------------------------*/ 110 BOOL IS_PAD_TRIGGER(u16 flag); 111 112 /*---------------------------------------------------------------------------* 113 Name: GetCurrentInput 114 115 Description: Gets current key input of the specified player. 116 117 Arguments: aid -- The player acquiring the key input. 118 119 Returns: Returns a valid address if the latest data sharing succeeds; otherwise, returns NULL. 120 121 *---------------------------------------------------------------------------*/ 122 GShareData *GetCurrentInput(int aid); 123 124 /*---------------------------------------------------------------------------* 125 Name: GetCurrentChannel 126 127 Description: Gets the currently selected wireless channel. 128 129 Arguments: None. 130 131 Returns: Returns the currently selected wireless channel. 132 *---------------------------------------------------------------------------*/ 133 u16 GetCurrentChannel(void); 134 135 /*---------------------------------------------------------------------------* 136 Name: SetCurrentChannel 137 138 Description: Sets the current wireless channel. 139 140 Arguments: channel -- Channel to be set. 141 142 Returns: None. 143 *---------------------------------------------------------------------------*/ 144 void SetCurrentChannel(u16 channel); 145 146 /*---------------------------------------------------------------------------* 147 Name: LoadLinkIcon 148 149 Description: Loads the link icon into VRAM. 150 151 Arguments: id -- The load target's character ID. 152 palette -- The load target's palette. 153 level -- The link strength. 154 155 Returns: None. 156 *---------------------------------------------------------------------------*/ 157 void LoadLinkIcon(int id, int palette, int level); 158 159 /*---------------------------------------------------------------------------* 160 Name: PrintString 161 162 Description: Draws the background text. 163 164 Arguments: x -- The rendering x grid position. 165 y -- The rendering y grid position. 166 palette -- The palette index. 167 format -- The format string. 168 169 Returns: None. 170 *---------------------------------------------------------------------------*/ 171 void PrintString(int x, int y, int palette, const char *format, ...); 172 173 /*---------------------------------------------------------------------------* 174 Name: WaitNextFrame 175 176 Description: Initializes rendering while waiting for the next picture frame. 177 178 Arguments: None. 179 180 Returns: Returns TRUE when key input is updated. 181 *---------------------------------------------------------------------------*/ 182 BOOL WaitNextFrame(void); 183 184 /*---------------------------------------------------------------------------* 185 Name: WaitWHState 186 187 Description: Waits until entering the specified WH state. 188 189 Arguments: state -- The state whose transition is awaited. 190 191 Returns: None. 192 *---------------------------------------------------------------------------*/ 193 void WaitWHState(int state); 194 195 /*---------------------------------------------------------------------------* 196 Name: MeasureChannel 197 198 Description: Measures the wireless use rates for each useable channel. 199 Blocks and displays internally until completed. 200 201 Arguments: None. 202 203 Returns: The channel with the lowest rate of wireless use. 204 *---------------------------------------------------------------------------*/ 205 u16 MeasureChannel(void); 206 207 /*---------------------------------------------------------------------------* 208 Name: ExecuteDownloadServer 209 210 Description: Runs DS Download Play parent process. 211 212 Arguments: None. 213 214 Returns: None. 215 *---------------------------------------------------------------------------*/ 216 void ExecuteDownloadServer(void); 217 218 /*---------------------------------------------------------------------------* 219 Name: StartWirelessParent 220 221 Description: Launches data sharing parent mode. 222 223 Arguments: None. 224 225 Returns: None. 226 *---------------------------------------------------------------------------*/ 227 void StartWirelessParent(void); 228 229 /*---------------------------------------------------------------------------* 230 Name: StartWirelessChild 231 232 Description: Launches data sharing child mode. 233 234 Arguments: None. 235 236 Returns: None. 237 *---------------------------------------------------------------------------*/ 238 void StartWirelessChild(void); 239 240 /*---------------------------------------------------------------------------* 241 Name: ExecuteDataSharing 242 243 Description: Main process for data sharing. 244 WFS process in background. 245 246 Arguments: None. 247 248 Returns: None. 249 *---------------------------------------------------------------------------*/ 250 void ExecuteDataSharing(void); 251 252 253 #ifdef __cplusplus 254 }/* extern "C" */ 255 #endif 256 257 #endif // WM_DEMO_WIRELESS_ALL_COMMON_H_ 258