1 /*---------------------------------------------------------------------------*
2 Project: Revolution SDK DS-Wireless FileSystem demo
3 File: fsserver.c
4
5 Copyright 2006, 2007 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: fsserver.c,v $
14 Revision 1.5 2007/10/26 08:06:33 seiki_masashi
15 Support for REXDEMOGetAnyMixedPadTrigger.
16
17 Revision 1.4 2007/10/04 09:41:47 seiki_masashi
18 Support for MP_BEACON_PERIOD_AUTO.
19
20 Revision 1.3 2007/08/01 09:36:29 kitase_hirotake
21 Changed TAB to SPACE.
22
23 Revision 1.2 2007/02/09 04:30:11 yosizaki
24 Fixed about includes.
25
26 Revision 1.1 2007/01/16 08:33:30 yosizaki
27 Initial upload.
28
29 $NoKeywords: $
30 *---------------------------------------------------------------------------*/
31
32
33 #include <revolution.h>
34 #include <revolution/mpfs.h>
35 #include <revolution/mem.h>
36
37 #include "rexdemo/demokpad.h"
38 #include "rexdemo/graphic.h"
39
40
41 /*===========================================================================*/
42 /* Declarations */
43
44 void ExecuteWireless(void* (*alloc)(u32), void (*free)(void*), MEMHeapHandle heap, const void *program);
45
46
47 /*===========================================================================*/
48 /* Constants */
49
50 #define MY_GGID 0x003fff23
51 #define MY_PORT 5
52
53
54 /*===========================================================================*/
55 /* Variables */
56
57 /* MP work structure */
58 static MPConfig mpConfig =
59 {
60 NULL,
61 NULL,
62 2, // threadPriority
63 MP_MODE_PARENT, // mode
64 MY_GGID, // ggid
65 MP_TGID_AUTO, // tgid
66 MP_CHANNEL_AUTO, // channel
67 MP_LIFETIME_DEFAULT,// lifeTime
68 MP_BEACON_PERIOD_AUTO, // beaconPeriod
69 4, // maxNodes
70 128, // parentMaxSize
71 14, // childMaxSize
72 TRUE, // entryFlag
73 FALSE, // multiBootFlag
74 0, // frequency
75 0, // userGameInfoLength
76 { 0, }, // userGameInfo
77 NULL, // indicationCallbackFunction
78 /// ... // port configuration (can be set up using MPSetPortConfig)
79 };
80
81
82 /*===========================================================================*/
83 /* Functions */
84
ExecuteWireless(void * (* alloc)(u32),void (* free)(void *),MEMHeapHandle heap,const void * program)85 void ExecuteWireless(void* (*alloc)(u32), void (*free)(void*), MEMHeapHandle heap, const void *program)
86 {
87 MPConfig *config = &mpConfig;
88
89 /* Initialize MPFS */
90 MPFSInit(config, heap, program);
91 config->alloc = alloc;
92 config->free = free;
93
94 /* Startup MP */
95 MPSetPortConfig(config, MY_PORT, MPFSPortCallback, MP_PRIORITY_LOW);
96 (void)MPStartup(config);
97
98 for (;;)
99 {
100 REXDEMOKPadRead();
101
102 /* Update sequence */
103 {
104 if ((REXDEMOGetAnyMixedPadTrigger() & (KPAD_BUTTON_A | (PAD_BUTTON_A << 16))) != 0)
105 {
106 break;
107 }
108 }
109
110 /* DrawFrame */
111 REXDEMOBeginRender();
112 {
113 REXDEMOSetTextColor(REXDEMO_COLOR_WHITE);
114 REXDEMOPrintf(4, 8, 0, "MPFS simple sample");
115 REXDEMOSetTextColor(REXDEMO_COLOR_YELLOW);
116 {
117 REXDEMOPrintf(4, 24, 0, "now running as FS server for DS.");
118 REXDEMOPrintf(40, 44, 0, "(press A to restart new MPDL session)");
119 }
120 }
121
122 REXDEMOWaitRetrace();
123 }
124 (void)MPCleanup();
125 MPFSEnd();
126 }
127
128
129 /*===========================================================================*/
130