1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - MB - demos - multiboot
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   $Date:: 2008-09-18#$
14   $Rev: 8573 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 #if !defined(NITRO_MB_DEMO_MULTIBOOT_DATA_H_)
18 #define NITRO_MB_DEMO_MULTIBOOT_DATA_H_
19 
20 
21 #include <nitro.h>
22 #include <nitro/mb.h>
23 
24 
25 /*
26  * Common definitions for the entire multiboot demo.
27  */
28 
29 
30 /******************************************************************************/
31 /* Constants */
32 
33 /*
34  * Game group ID
35  *
36  * 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.
37  *
38  *
39  */
40 #define SDK_MAKEGGID_SYSTEM(num)    (0x003FFF00 | (num))
41 #define MY_GGID         SDK_MAKEGGID_SYSTEM(0x20)
42 
43 /*
44  * Channel for the parent device to distribute
45  *
46  * The multiboot child cycles through all possible channels, so use one of the values permitted by the WM library (currently 1, 7, and 13).
47  *
48  *
49  * Make this variable to avoid communication congestion in user applications.
50  * 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.
51  *
52  *
53  */
54 #define PARENT_CHANNEL  13
55 
56 /* The maximum number of child device lists to display */
57 #define DISP_LIST_NUM   (15)
58 
59 /* DMA number to allocate to the MB library */
60 #define MB_DMA_NO       2
61 
62 /* The total number of games that this demo registers */
63 #define GAME_PROG_MAX   2
64 
65 /* The multiboot game program information that this demo provides */
66 extern const MBGameRegistry mbGameList[GAME_PROG_MAX];
67 
68 /* The game sequence state value of this demo */
69 enum
70 {
71     STATE_NONE,
72     STATE_MENU,
73     STATE_MB_PARENTINIT,
74     STATE_MB_PARENT
75 };
76 
77 
78 /******************************************************************************/
79 /* Variables */
80 
81 /* The work region to be allocated to the MB library */
82 extern u32 cwork[MB_SYSTEM_BUF_SIZE / sizeof(u32)];
83 
84 /* The game sequence state of this demo */
85 extern u8 prog_state;
86 
87 
88 /******************************************************************************/
89 /* Functions */
90 
91 /* Key trigger detection */
92 u16     ReadKeySetTrigger(u16 keyset);
93 
94 /* Rotate the val value the offset amount in within the min - max range */
95 BOOL    RotateU8(u8 *val, u8 min, u8 max, s8 offset);
96 
97 /* Parent device initialization */
98 void    ParentInit(void);
99 
100 /* Parent device main process in each single frame */
101 void    ParentMain(void);
102 
103 /* Initialize the file buffer pointer */
104 void    InitFileBuffer(void);
105 
106 /* Set parent device MP send size */
107 void    SetParentSendSize(u16 p_size);
108 
109 /* Get parent device MP send size */
110 u16     GetParentSendSize(void);
111 
112 /* Set maximum number of child device connections */
113 void    SetMaxEntry(u8 num);
114 
115 /* Get the maximum number of child device connections */
116 u8      GetMaxEntry(void);
117 
118 /* Configure parent device auto operations */
119 void    SetAutoOperation(u8 fAccept, u8 fSend, u8 fBoot);
120 
121 #endif /* !defined(NITRO_MB_DEMO_MULTIBOOT_DATA_H_) */
122