1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - MB - demos - multiboot
3 File: common.c
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
18 #ifdef SDK_TWL
19 #include <twl.h>
20 #else
21 #include <nitro.h>
22 #endif
23
24
25 #include "common.h"
26
27
28 /*
29 * Common features used by this entire demo
30 */
31
32
33 /******************************************************************************/
34 /* Constants */
35
36 /* The array of program information that this demo downloads */
37 const MBGameRegistry mbGameList[GAME_PROG_MAX] = {
38 {
39 "/em.srl", // The file path of the multiboot child device binary
40 L"edgeDemo", // Game name
41 L"edgemarking demo\ntesttesttest", // Game content description
42 "/data/icon.char", // Icon character data file path
43 "/data/icon.plt", // Icon palette data file path
44 0x12123434, // GameGroupID(GGID)
45 16, // Max number of players
46 },
47 {
48 "/pol_toon.srl",
49 L"PolToon",
50 L"toon rendering",
51 "/data/icon.char",
52 "/data/icon.plt",
53 0x56567878,
54 8,
55 },
56 };
57
58
59 /******************************************************************************/
60 /* Variables */
61
62 /* The work region to be allocated to the MB library */
63 u32 cwork[MB_SYSTEM_BUF_SIZE / sizeof(u32)];
64
65 /* The game sequence state of this demo */
66 u8 prog_state;
67
68
69 /******************************************************************************/
70 /* Functions */
71
72 /* Key trigger detection */
ReadKeySetTrigger(u16 keyset)73 u16 ReadKeySetTrigger(u16 keyset)
74 {
75 static u16 cont = 0xffff; /* Measures to handle A Button presses inside IPL */
76 u16 trigger = (u16)(keyset & (keyset ^ cont));
77 cont = keyset;
78 return trigger;
79 }
80
81 /* Rotate the val value the offset amount within the min - max range */
RotateU8(u8 * val,u8 min,u8 max,s8 offset)82 BOOL RotateU8(u8 *val, u8 min, u8 max, s8 offset)
83 {
84 int lVal = (int)*val - min;
85 int div = max - min + 1;
86
87 if (div == 0)
88 return FALSE;
89
90 lVal = (lVal + offset + div) % div + min;
91
92 *val = (u8)lVal;
93 return TRUE;
94 }
95