1 /*---------------------------------------------------------------------------*
2   Project:  TWLSDK - demos - FS - overlay-staticinit
3   File:     mode_1.c
4 
5   Copyright 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   $Date:: 2007-11-06 #$
14   $Rev: 2135 $
15   $Author: yosizaki $
16  *---------------------------------------------------------------------------*/
17 
18 #include <nitro.h>
19 #include "mode.h"
20 #include "DEMO.h"
21 
22 // Include this header when NitroStaticInit() is specified as a static initializer.
23 //
24 #include <nitro/sinit.h>
25 
26 
27 /*---------------------------------------------------------------------------*/
28 /* functions */
29 
30 /*---------------------------------------------------------------------------*
31   Name:         MyUpdateFrame
32 
33   Description:  Updates the internal state by one frame in the current mode.
34 
35   Arguments:    frame_count: Frame count of the current operation
36                 input: Array of input data
37                 player_count: Current number of total players (the number of valid input elements)
38                 own_player_id: Local player number
39 
40   Returns:      Returns FALSE if the current mode ends this frame and TRUE otherwise.
41 
42  *---------------------------------------------------------------------------*/
MyUpdateFrame(int frame_count,const InputData * input,int player_count,int own_player_id)43 static BOOL MyUpdateFrame(int frame_count,
44                           const InputData * input, int player_count, int own_player_id)
45 {
46     (void)frame_count;
47     (void)player_count;
48 
49     // End if anything is pressed
50     return !IS_INPUT_(input[own_player_id], ~0, push);
51 }
52 
53 /*---------------------------------------------------------------------------*
54   Name:         MyDrawFrame
55 
56   Description:  Performs a rendering update based on the internal state in the current mode.
57 
58   Arguments:    frame_count: Frame count of the current operation
59 
60   Returns:      None.
61  *---------------------------------------------------------------------------*/
MyDrawFrame(int frame_count)62 static void MyDrawFrame(int frame_count)
63 {
64     DEMOFillRect(0, 0, GX_LCD_SIZE_X, GX_LCD_SIZE_Y, DEMO_RGB_CLEAR);
65     // Display file name and a simple description of operations
66     DEMOSetBitmapTextColor(GX_RGBA(31, 31, 31, 1));
67     DEMODrawText(0, 10, "%s", __FILE__);
68     DEMODrawText(30, 40, "press any key to return");
69     // Simple frame count display
70     DEMOSetBitmapTextColor(GX_RGBA(31, 31, 16, 1));
71     DEMODrawText(40, 80, "frame count = %d", frame_count);
72 }
73 
74 /*---------------------------------------------------------------------------*
75   Name:         MyEndFrame
76 
77   Description:  Ends the current mode.
78 
79   Arguments:    p_next_mode: The ID indicated by this pointer will be overwritten when the next mode is specified explicitly.
80                                  In the absence of a particular specification, the mode that called the current mode will be selected.
81 
82 
83 
84   Returns:      None.
85  *---------------------------------------------------------------------------*/
MyEndFrame(FSOverlayID * p_next_mode)86 static void MyEndFrame(FSOverlayID *p_next_mode)
87 {
88     // Do nothing and return to the top menu
89     (void)p_next_mode;
90 }
91 
92 /*---------------------------------------------------------------------------*
93   Name:         NitroStaticInit
94 
95   Description:  This is an automatic initialization function as a static initializer.
96 
97   Arguments:    None.
98 
99   Returns:      None.
100  *---------------------------------------------------------------------------*/
NitroStaticInit(void)101 static void NitroStaticInit(void)
102 {
103     UpdateFrame = MyUpdateFrame;
104     DrawFrame = MyDrawFrame;
105     EndFrame = MyEndFrame;
106 
107     // Perform the necessary initialization processes for each mode here
108 
109 }
110