1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - GX - demos - UnitTours/2D_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 2D_CharBG_1.
26 // 2. Specify the planes and brightness by G2_SetBlendBrightness().
27 // 3. You can also control brightness by G2_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 DEMOInitDisplayBG0Only();
53
54 //---------------------------------------------------------------------------
55 // Transmitting the character data and the palette data
56 //---------------------------------------------------------------------------
57 GX_LoadBG0Char(d_yuuyake_schDT, 0, sizeof(d_yuuyake_schDT));
58 GX_LoadBGPltt(d_yuuyake_sclDT, 0, sizeof(d_yuuyake_sclDT));
59
60 //---------------------------------------------------------------------------
61 // Transmitting the screen data
62 //---------------------------------------------------------------------------
63 GX_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 G2_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 #ifdef SDK_AUTOTEST
91 evy = 8; // default params for testing.
92 GX_SetBankForLCDC(GX_VRAM_LCDC_C);
93 EXT_TestSetVRAMForScreenShot(GX_VRAM_LCDC_C);
94 EXT_TestScreenShot(100, 0x44F02A2A);
95 EXT_TestTickCounter();
96 #endif //SDK_AUTOTEST
97
98 OS_WaitVBlankIntr(); // Waiting the end of VBlank interrupt
99
100 //---------------------------------------------------------------------------
101 // Change the coefficient for brightness
102 //---------------------------------------------------------------------------
103 G2_ChangeBlendBrightness(evy);
104 }
105 }
106
107 //---------------------------------------------------------------------------
108 // VBlank interrupt function:
109 //
110 // Interrupt handlers are registered on the interrupt table by OS_SetIRQFunction.
111 // OS_EnableIrqMask selects IRQ interrupts to enable, and
112 // OS_EnableIrq enables IRQ interrupts.
113 // Notice that you have to call 'OS_SetIrqCheckFlag' to check a VBlank interrupt.
114 //---------------------------------------------------------------------------
VBlankIntr(void)115 void VBlankIntr(void)
116 {
117 OS_SetIrqCheckFlag(OS_IE_V_BLANK); // checking VBlank interrupt
118 }
119