1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - GX - demos - UnitTours/Sub_CharBg_9
3 File: main.c
4
5 Copyright 2003-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 //---------------------------------------------------------------------------
19 // A sample that controls brightness:
20 //
21 // USAGE:
22 // UP, DOWN: Controls brightness
23 //
24 // HOWTO:
25 // 1. Set up the character/palette/screen data same as Sub_CharBG_1.
26 // 2. Specify the planes and brightness by G2S_SetBlendBrightness().
27 // 3. You can also control brightness by G2S_ChangeBlendBrightness().
28 //---------------------------------------------------------------------------
29
30 #ifdef SDK_TWL
31 #include <twl.h>
32 #else
33 #include <nitro.h>
34 #endif
35 #include "DEMO.h"
36 #include "data.h"
37
38 #ifdef SDK_TWL
TwlMain(void)39 void TwlMain(void)
40 #else
41 void NitroMain(void)
42 #endif
43 {
44 int evy = 0;
45
46 //---------------------------------------------------------------------------
47 // Initialize:
48 // They enable IRQ interrupts, initialize VRAM, and set BG #0 for text mode.
49 //---------------------------------------------------------------------------
50 DEMOInitCommon();
51 DEMOInitVRAM();
52 DEMOInitDisplaySubBG0Only();
53
54 //---------------------------------------------------------------------------
55 // Transmitting the character data and the palette data
56 //---------------------------------------------------------------------------
57 GXS_LoadBG0Char(d_yuuyake_schDT, 0, sizeof(d_yuuyake_schDT));
58 GXS_LoadBGPltt(d_yuuyake_sclDT, 0, sizeof(d_yuuyake_sclDT));
59
60 //---------------------------------------------------------------------------
61 // Transmitting the screen data
62 //---------------------------------------------------------------------------
63 GXS_LoadBG0Scr(d_yuuyake_sscDT, 0, sizeof(d_yuuyake_sscDT));
64
65 //---------------------------------------------------------------------------
66 // Setting up brightness control
67 //
68 // Specify planes and brightness(-16...+16)
69 //---------------------------------------------------------------------------
70 G2S_SetBlendBrightness(GX_BLEND_PLANEMASK_BG0, 0);
71
72 DEMOStartDisplay();
73 //---------------------------------------------------------------------------
74 // Main Loop
75 //---------------------------------------------------------------------------
76 while (1)
77 {
78 DEMOReadKey();
79
80 if (DEMO_IS_PRESS(PAD_KEY_UP))
81 evy++;
82 if (DEMO_IS_PRESS(PAD_KEY_DOWN))
83 evy--;
84
85 if (evy < -16)
86 evy = -16;
87 if (evy > 16)
88 evy = 16;
89
90 OS_WaitVBlankIntr(); // Waiting the end of VBlank interrupt
91
92 //---------------------------------------------------------------------------
93 // Change the coefficient for brightness
94 //---------------------------------------------------------------------------
95 G2S_ChangeBlendBrightness(evy);
96 }
97 }
98
99 //---------------------------------------------------------------------------
100 // VBlank interrupt function:
101 //
102 // Interrupt handlers are registered on the interrupt table by OS_SetIRQFunction.
103 // OS_EnableIrqMask selects IRQ interrupts to enable, and
104 // OS_EnableIrq enables IRQ interrupts.
105 // Notice that you have to call 'OS_SetIrqCheckFlag' to check a VBlank interrupt.
106 //---------------------------------------------------------------------------
VBlankIntr(void)107 void VBlankIntr(void)
108 {
109 OS_SetIrqCheckFlag(OS_IE_V_BLANK); // checking VBlank interrupt
110 }
111