1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - GX - demos - UnitTours/2D_Oam_1
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 displays a sphere using character OBJ:
20 //
21 // HOWTO:
22 // 1. Transfer object character data by GX_LoadOBJ().
23 // 2. Transfer object palette data by GX_LoadOBJPltt().
24 // 3. Specify the attributes for objects by G2_SetOBJAttr() and etc. .
25 // 4. Transfer the copy of object attribute memory by GX_LoadOAM().
26 //
27 // Do not forget to flush the corresponding cache if you modified the data
28 // before transfer.
29 //---------------------------------------------------------------------------
30
31 #ifdef SDK_TWL
32 #include <twl.h>
33 #else
34 #include <nitro.h>
35 #endif
36 #include "DEMO.h"
37 #include "data.h"
38
39 static GXOamAttr sOamBak[128]; // Buffer for OAM
40
41 #ifdef SDK_TWL
TwlMain(void)42 void TwlMain(void)
43 #else
44 void NitroMain(void)
45 #endif
46 {
47 //---------------------------------------------------------------------------
48 // Initialize:
49 // They enable IRQ interrupts, initialize VRAM, and make OBJ visible
50 //---------------------------------------------------------------------------
51 DEMOInitCommon();
52 DEMOInitVRAM();
53 DEMOInitDisplayOBJOnly();
54
55 //---------------------------------------------------------------------------
56 // Transmitting the character data and the palette data
57 //---------------------------------------------------------------------------
58 GX_LoadOBJ(d_64_256_obj_schDT, 0, sizeof(d_64_256_obj_schDT));
59 GX_LoadOBJPltt(d_64_256_obj_sclDT, 0, sizeof(d_64_256_obj_sclDT));
60
61 DEMOStartDisplay();
62 //---------------------------------------------------------------------------
63 // Main Loop
64 //---------------------------------------------------------------------------
65 while (1)
66 {
67 G2_SetOBJAttr(&sOamBak[0], // a pointer to the attributes
68 0, // x
69 0, // y
70 0, // priority
71 GX_OAM_MODE_NORMAL, // OBJ mode
72 FALSE, // mosaic
73 GX_OAM_EFFECT_NONE, // flip/affine/no display/affine(double)
74 GX_OAM_SHAPE_64x64, // size and shape
75 GX_OAM_COLORMODE_256, // OBJ character data are in 256-color format
76 0, // character name
77 0, // color param
78 0 // affine param
79 );
80
81 // Store the data in the main memory, and invalidate the cache.
82 DC_FlushRange(sOamBak, sizeof(sOamBak));
83 /* I/O register is accessed using DMA operation, so cache wait is not needed */
84 // DC_WaitWriteBufferEmpty();
85
86 #ifdef SDK_AUTOTEST
87 GX_SetBankForLCDC(GX_VRAM_LCDC_C);
88 EXT_TestSetVRAMForScreenShot(GX_VRAM_LCDC_C);
89 EXT_TestScreenShot(100, 0xA2DDCE80);
90 EXT_TestTickCounter();
91 #endif //SDK_AUTOTEST
92
93 OS_WaitVBlankIntr(); // Waiting for the end of V-Blank interrupt
94
95 GX_LoadOAM(sOamBak, 0, sizeof(sOamBak));
96
97 MI_DmaFill32(3, sOamBak, 192, sizeof(sOamBak)); // Let out of the screen if not display
98 }
99
100 }
101
102 //---------------------------------------------------------------------------
103 // V-Blank interrupt function:
104 //
105 // Interrupt handlers are registered on the interrupt table by OS_SetIRQFunction.
106 // OS_EnableIrqMask selects IRQ interrupts to enable, and
107 // OS_EnableIrq enables IRQ interrupts.
108 // Notice that you have to call 'OS_SetIrqCheckFlag' to check a V-Blank interrupt.
109 //---------------------------------------------------------------------------
VBlankIntr(void)110 void VBlankIntr(void)
111 {
112 OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Checking V-Blank interrupt
113 }
114