1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - MB - demos - multiboot-wfs - child
3 File: main.c
4
5 Copyright 2005-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 $Date:: 2008-09-29#$
14 $Rev: 8760 $
15 $Author: okajima_manabu $
16 *---------------------------------------------------------------------------*/
17
18 /*---------------------------------------------------------------------------*
19 This sample program runs the WBT library so that wireless multiboot children can use a file system
20
21
22 HOWTO:
23 1. Press the B button to start communication as a child.
24 When a parent with the same wbt-fs demo is found in the surrounding area, communication will automatically begin with that parent.
25
26 2. For information on various features while connected, refer to the parent and child screens as well as comments in the source code.
27
28 *---------------------------------------------------------------------------*/
29
30
31 #ifdef SDK_TWL
32 #include <twl.h>
33 #else
34 #include <nitro.h>
35 #endif
36 #include <nitro/wm.h>
37 #include <nitro/wbt.h>
38 #include <nitro/fs.h>
39
40 #include "wfs.h"
41 #include "wh.h"
42
43 #include "util.h"
44 #include "common.h"
45
46
47 /*---------------------------------------------------------------------------*
48 Function Definitions
49 *---------------------------------------------------------------------------*/
50
51
52 /*---------------------------------------------------------------------------*
53 Name: NitroMain
54
55 Description: Initialization and main loop.
56
57 Arguments: None.
58
59 Returns: None.
60 *---------------------------------------------------------------------------*/
NitroMain(void)61 void NitroMain(void)
62 {
63 /* Initialize render framework for sample */
64 UTIL_Init();
65
66 /*
67 * Initialize the file system.
68 * As a parent, you can also specify the valid DMA channels.
69 * As a child, this will not be used and is simply ignored.
70 */
71 FS_Init(FS_DMA_NOT_USE);
72
73 /* LCD display start */
74 GX_DispOn();
75 GXS_DispOn();
76
77 /* Initialize the WH module */
78 ModeInitialize();
79
80 /* Main loop */
81 for (;;)
82 {
83
84 /* If previous WFS is already running, stop it once. */
85 if (WFS_GetStatus() != WFS_STATE_STOP)
86 {
87 WFS_End();
88 WH_Reset();
89 }
90
91 /* Wait until the child is done */
92 ModeWorking();
93
94 /* Start the child */
95 ModeSelect();
96 /* Wait until the child is done */
97 ModeWorking();
98
99 /* After started, display child screen */
100 ModeChild();
101
102 if (WH_GetSystemState() == WH_SYSSTATE_FATAL)
103 {
104 /* If there is an error, stop here */
105 ModeError();
106 }
107 }
108 }
109
110
111 /*---------------------------------------------------------------------------*
112 End of file
113 *---------------------------------------------------------------------------*/
114