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-17#$
14 $Rev: 8556 $
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 #include <nitro.h>
32 #include "DEMO.h"
33 #include "data.h"
34
35 static GXOamAttr sOamBak[128]; // Buffer for OAM
36
NitroMain()37 void NitroMain()
38 {
39 //---------------------------------------------------------------------------
40 // Initialize:
41 // They enable IRQ interrupts, initialize VRAM, and make OBJ visible.
42 //---------------------------------------------------------------------------
43 DEMOInitCommon();
44 DEMOInitVRAM();
45 DEMOInitDisplayOBJOnly();
46
47 //---------------------------------------------------------------------------
48 // Transmitting the character data and the palette data
49 //---------------------------------------------------------------------------
50 GX_LoadOBJ(d_64_256_obj_schDT, 0, sizeof(d_64_256_obj_schDT));
51 GX_LoadOBJPltt(d_64_256_obj_sclDT, 0, sizeof(d_64_256_obj_sclDT));
52
53 DEMOStartDisplay();
54 //---------------------------------------------------------------------------
55 // Main Loop
56 //---------------------------------------------------------------------------
57 while (1)
58 {
59 G2_SetOBJAttr(&sOamBak[0], // Pointer to the attributes
60 0, // X
61 0, // Y
62 0, // Priority
63 GX_OAM_MODE_NORMAL, // OBJ mode
64 FALSE, // Mosaic
65 GX_OAM_EFFECT_NONE, // Flip/affine/no display/affine(double)
66 GX_OAM_SHAPE_64x64, // Size and shape
67 GX_OAM_COLORMODE_256, // OBJ character data are in 256-color format
68 0, // Character name
69 0, // Color param
70 0 // Affine param
71 );
72
73 // Store the data in main memory and invalidate the cache
74 DC_FlushRange(sOamBak, sizeof(sOamBak));
75 /* I/O register is accessed using DMA operation, so cache wait is not needed */
76 // DC_WaitWriteBufferEmpty();
77
78 #ifdef SDK_AUTOTEST
79 GX_SetBankForLCDC(GX_VRAM_LCDC_C);
80 EXT_TestSetVRAMForScreenShot(GX_VRAM_LCDC_C);
81 EXT_TestScreenShot(100, 0xA2DDCE80);
82 EXT_TestTickCounter();
83 #endif //SDK_AUTOTEST
84
85 OS_WaitVBlankIntr(); // Waiting the end of V-Blank interrupt
86
87 GX_LoadOAM(sOamBak, 0, sizeof(sOamBak));
88
89 MI_DmaFill32(3, sOamBak, 192, sizeof(sOamBak)); // Let out of the screen if not display
90 }
91
92 }
93
94 //---------------------------------------------------------------------------
95 // V-Blank interrupt function:
96 //
97 // Interrupt handlers are registered on the interrupt table by OS_SetIRQFunction.
98 // OS_EnableIrqMask selects IRQ interrupts to enable, and
99 // OS_EnableIrq enables IRQ interrupts.
100 // Notice that you have to call OS_SetIrqCheckFlag to check a V-Blank interrupt.
101 //---------------------------------------------------------------------------
VBlankIntr(void)102 void VBlankIntr(void)
103 {
104 OS_SetIrqCheckFlag(OS_IE_V_BLANK); // Checking V-Blank interrupt
105 }
106