1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - PAD - demos - padRead
3   File:     main.c
4 
5   Copyright 2007-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:: 2009-01-14 #$
14   $Rev: 9835 $
15   $Author: sasaki_yu $
16  *---------------------------------------------------------------------------*/
17 #ifdef SDK_TWL
18 #include <twl.h>
19 #else
20 #include <nitro.h>
21 #endif
22 
23 #include "DEMO.h"
24 
25 
26 /*---------------------------------------------------------------------------*
27   Name:         TwlMain / NitroMain
28 
29   Description:  main
30 
31   Arguments:    None
32 
33   Returns:      None
34  *---------------------------------------------------------------------------*/
35 #ifdef SDK_TWL
TwlMain(void)36 void TwlMain(void)
37 #else
38 void NitroMain(void)
39 #endif
40 {
41     DEMOInitCommon();
42     DEMOInitVRAM();
43     DEMOInitDisplayBitmap();
44     DEMOHookConsole();
45 
46     DEMOStartDisplay();
47     DEMOSetBitmapGroundColor(DEMO_RGB_CLEAR);
48 
49     for (;;)
50     {
51         /* *INDENT-OFF* */
52         typedef struct PadAssignment
53         {
54             int         posX;
55             int         posY;
56             int         bit;
57             const char *name;
58         }
59         PadAssignment;
60         static const PadAssignment assignment_table[] =
61         {
62             { 200,  90, PAD_BUTTON_A,         "A", },
63             { 180,  95, PAD_BUTTON_B,         "B", },
64             { 110,  95, PAD_BUTTON_SELECT,    "S", },
65             { 130,  95, PAD_BUTTON_START,     "S", },
66             {  70,  90, PAD_KEY_RIGHT,        "R", },
67             {  50,  90, PAD_KEY_LEFT,         "L", },
68             {  60,  80, PAD_KEY_UP,           "U", },
69             {  60, 100, PAD_KEY_DOWN,         "D", },
70             { 180,  50, PAD_BUTTON_R,         "R", },
71             {  60,  50, PAD_BUTTON_L,         "L", },
72             { 200,  75, PAD_BUTTON_X,         "X", },
73             { 180,  80, PAD_BUTTON_Y,         "Y", },
74             { 200, 120, PAD_BUTTON_DEBUG,     "D", },
75         };
76         /* *INDENT-ON* */
77         static const u32 assignment_table_max = sizeof(assignment_table) / sizeof(*assignment_table);
78         int     i;
79         u16     bits;
80 
81         DEMOFillRect(0, 0, GX_LCD_SIZE_X, GX_LCD_SIZE_Y, GX_RGBA( 0, 0, 0, 1));
82         bits = PAD_Read();
83         for (i = 0; i < assignment_table_max; ++i)
84         {
85             const PadAssignment *p = &assignment_table[i];
86             DEMOSetBitmapTextColor((GXRgb)(((bits & p->bit) != 0) ? GX_RGBA(31, 31, 0, 1) : GX_RGBA(16, 16, 16, 1)));
87             DEMODrawText(p->posX, p->posY, "%s", p->name);
88         }
89         DEMOSetBitmapTextColor(GX_RGBA(31, 31, 31, 1));
90         DEMODrawText(10, 0, "PAD_DetectFold:%s", PAD_DetectFold() ? "true" : "false");
91         DEMO_DrawFlip();
92 
93         OS_WaitVBlankIntr();
94     }
95 }
96 
97 /*====== End of main.c ======*/
98