1 /*---------------------------------------------------------------------------*
2   Project:  Dolphin/Revolution gx demo
3   File:     frb-gamma.c
4 
5   Copyright 1998-2006 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 /*---------------------------------------------------------------------------*
14     frb-gamma
15         gamma correction mode demo
16  *---------------------------------------------------------------------------*/
17 
18 
19 /*---------------------------------------------------------------------------*
20    Header files
21  *---------------------------------------------------------------------------*/
22 #include <demo.h>
23 #include <math.h>
24 
25 /*---------------------------------------------------------------------------*
26    Macro definitions
27  *---------------------------------------------------------------------------*/
28 #define MAX_Z           0x00ffffff // max value of Z buffer
29 
30 #define NUM_PATTERNS    5
31 #define NUM_COLORBARS   12
32 #define NUM_DONUTS      12
33 
34 
35 #define Clamp(val,min,max) \
36     ((val) = (((val) < (min)) ? (min) : ((val) > (max)) ? (max) : (val)))
37 
38 /*---------------------------------------------------------------------------*
39    Structure definitions
40  *---------------------------------------------------------------------------*/
41 // for entire scene control
42 typedef struct
43 {
44     u32         patternNo;
45     u32         gammaMode;
46     u32         pixMode;
47     u32         colorID;
48     u16         screen_width;
49     u16         screen_height;
50     u8*         vfilter;
51 } MySceneCtrlObj;
52 
53 /*---------------------------------------------------------------------------*
54    Forward references
55  *---------------------------------------------------------------------------*/
56 void        main                ( void );
57 static void DrawInit            ( MySceneCtrlObj* sc );
58 static void DrawTick            ( MySceneCtrlObj* sc );
59 static void AnimTick            ( MySceneCtrlObj* sc );
60 static void DrawColorBars       ( MySceneCtrlObj* sc );
61 static void DrawGammaTestImg    ( MySceneCtrlObj* sc );
62 static void DrawSampleImg       ( MySceneCtrlObj* sc );
63 static void DrawDonuts          ( MySceneCtrlObj* sc );
64 static void DrawLitOcta         ( MySceneCtrlObj* sc );
65 static void PrintIntro          ( void );
66 
67 /*---------------------------------------------------------------------------*
68   Model and texture data
69  *---------------------------------------------------------------------------*/
70 #define NUM_COLORS  13
71 
72 #define ID_BLACK    0
73 #define ID_WHITE    1
74 #define ID_GRAY     8
75 
76 static GXColor MyColorArray[] ATTRIBUTE_ALIGN(32) =
77 {
78     { 0x00, 0x00, 0x00, 0x00 }, // Black
79     { 0xFF, 0xFF, 0xFF, 0xFF }, // White
80     { 0x00, 0xFF, 0xFF, 0xFF }, // Cyan
81     { 0x00, 0xFF, 0x00, 0xFF }, // Green
82     { 0xFF, 0xFF, 0x00, 0xFF }, // Yellow
83     { 0xFF, 0x00, 0x00, 0xFF }, // Red
84     { 0xFF, 0x00, 0xFF, 0xFF }, // Magenta
85     { 0x00, 0x00, 0xFF, 0xFF }, // Blue
86     { 0x80, 0x80, 0x80, 0xFF }, // Gray
87     { 0xFF, 0x80, 0x80, 0xFF }, //
88     { 0x80, 0xFF, 0x80, 0xFF }, //
89     { 0x80, 0x80, 0xFF, 0xFF }, //
90     { 0x40, 0x40, 0x40, 0xFF }  //
91 };
92 
93 /*---------------------------------------------------------------------------*
94    Gamma correction mode data / pixel mode data
95  *---------------------------------------------------------------------------*/
96 static GXGamma GammaTable[3] =
97 {
98     GX_GM_1_0, GX_GM_1_7, GX_GM_2_2
99 };
100 
101 static char* GammaMsg[3] =
102 {
103     "1.0", "1.7", "2.2"
104 };
105 
106 static GXPixelFmt PixModeTable[3] =
107 {
108     GX_PF_RGB8_Z24, GX_PF_RGBA6_Z24, GX_PF_RGBA6_Z24
109 };
110 
111 static GXBool DitherModeTable[3] =
112 {
113     GX_DISABLE, GX_DISABLE, GX_ENABLE
114 };
115 
116 static char* PixModeMsg[3] =
117 {
118     "    RGB8", "    RGBA6", "RGBA6/Dither"
119 };
120 
121 /*---------------------------------------------------------------------------*
122    Global variables
123  *---------------------------------------------------------------------------*/
124 static MySceneCtrlObj   SceneCtrl;          // scene control parameters
125 static TPLPalettePtr    MyTplObj = NULL;    // for TPL file
126 
127 /*---------------------------------------------------------------------------*
128    Application main loop
129  *---------------------------------------------------------------------------*/
main(void)130 void main ( void )
131 {
132     DEMOInit(NULL);       // Init the OS, game pad, graphics and video.
133 
134     DrawInit(&SceneCtrl); // Initialize vertex formats, array pointers
135                           // and default scene settings.
136 
137     PrintIntro();    // Print demo directions
138 
139     while(!(DEMOPadGetButton(0) & PAD_BUTTON_MENU))
140     {
141 		DEMOBeforeRender();
142         DrawTick(&SceneCtrl);    // Draw the model.
143         DEMODoneRender();
144         DEMOPadRead();           // Read controller
145         AnimTick(&SceneCtrl);    // Do animation
146     }
147 
148     OSHalt("End of test");
149 }
150 
151 /*---------------------------------------------------------------------------*
152    Functions
153  *---------------------------------------------------------------------------*/
154 /*---------------------------------------------------------------------------*
155     Name:           DrawInit
156 
157     Description:    Initializes the vertex attribute format and sets up
158                     the array pointer for the indexed data.
159                     This function also initializes scene control parameters.
160 
161     Arguments:      sc : pointer to the structure of scene control parameters
162 
163     Returns:        none
164  *---------------------------------------------------------------------------*/
DrawInit(MySceneCtrlObj * sc)165 static void DrawInit( MySceneCtrlObj* sc )
166 {
167     GXRenderModeObj *rmp;
168 
169     // Get framebuffer size of current rendering mode
170     rmp = DEMOGetRenderModeObj();
171     sc->screen_width  = rmp->fbWidth;
172     sc->screen_height = rmp->efbHeight;
173     sc->vfilter       = rmp->vfilter;
174 
175     // Background color
176     GXSetCopyClear(MyColorArray[ID_BLACK], MAX_Z);
177 
178     // Culling mode
179     GXSetCullMode(GX_CULL_NONE);
180 
181     // Vertex Attribute (VTXFMT0 is used by DEMOPuts library)
182     GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
183     GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_TEX0, GX_TEX_ST, GX_S16, 8);
184     GXSetVtxAttrFmt(GX_VTXFMT1, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
185 
186     // load tpl file
187     TPLGetPalette(&MyTplObj, "gxTests/frb-00.tpl");
188 
189 
190     // Default scene control parameter settings
191 
192     sc->patternNo = 0;
193 
194     // gamma mode & pixel mode
195     sc->gammaMode = 0;
196     sc->pixMode   = 0;
197     sc->colorID   = 1;
198 }
199 
200 /*---------------------------------------------------------------------------*
201     Name:           DrawTick
202 
203     Description:    Draw the model by using given scene parameters
204 
205     Arguments:      sc : pointer to the structure of scene control parameters
206 
207     Returns:        none
208  *---------------------------------------------------------------------------*/
DrawTick(MySceneCtrlObj * sc)209 static void DrawTick( MySceneCtrlObj* sc )
210 {
211     Mtx44  proj;
212 
213     // Set pixel mode and gamma mode
214     GXSetPixelFmt(PixModeTable[sc->pixMode], GX_ZC_LINEAR);
215     GXSetDither(DitherModeTable[sc->pixMode]);
216     GXSetDispCopyGamma(GammaTable[sc->gammaMode]);
217 
218     // Initialize screen space projection
219     MTXOrtho(proj, 0, sc->screen_height, 0, sc->screen_width, 0.0F, 10000.0F);
220     GXSetProjection(proj, GX_ORTHOGRAPHIC);
221 
222     // Draw a pattern
223     switch(sc->patternNo)
224     {
225       case 0:
226         DrawColorBars(sc);
227         break;
228       case 1:
229         DrawGammaTestImg(sc);
230         break;
231       case 2:
232         DrawSampleImg(sc);
233         break;
234       case 3:
235         DrawDonuts(sc);
236         break;
237       case 4:
238       default:
239         DrawLitOcta(sc);
240         break;
241     }
242 
243     // Caption
244     DEMOInitCaption(DM_FT_OPQ, (s16)(sc->screen_width/2), (s16)(sc->screen_height/2));
245     DEMOPrintf(16, 12, 0, "Gamma = %s\n", GammaMsg[sc->gammaMode]);
246     DEMOPuts(200, 12, 0, PixModeMsg[sc->pixMode]);
247 }
248 
249 /*---------------------------------------------------------------------------*
250     Name:           AnimTick
251 
252     Description:    Changes scene parameters according to the pad status.
253 
254     Arguments:      sc : pointer to the structure of scene control parameters
255 
256     Returns:        none
257  *---------------------------------------------------------------------------*/
AnimTick(MySceneCtrlObj * sc)258 static void AnimTick( MySceneCtrlObj* sc )
259 {
260     // Change the pattern
261     if ( DEMOPadGetButtonDown(0) & PAD_BUTTON_A )
262     {
263         sc->patternNo = ++sc->patternNo % NUM_PATTERNS;
264     }
265 
266     // Gamma mode
267     if ( DEMOPadGetButtonDown(0) & PAD_BUTTON_B )
268     {
269         sc->gammaMode = ++sc->gammaMode % 3;
270     }
271 
272     // Pixel mode (8bit/6bit)
273     if ( DEMOPadGetButtonDown(0) & PAD_BUTTON_X )
274     {
275         sc->pixMode = ++sc->pixMode % 3;
276     }
277 
278     // Color ID (used in DrawLitOcta)
279     if ( DEMOPadGetButtonDown(0) & PAD_BUTTON_Y )
280     {
281         sc->colorID = ++sc->colorID % NUM_COLORS;
282     }
283 }
284 
285 /*---------------------------------------------------------------------------*
286     Name:           DrawColorBars
287 
288     Description:    Draw color bars
289 
290     Arguments:      sc : pointer to the structure of scene control parameters
291 
292     Returns:        none
293  *---------------------------------------------------------------------------*/
DrawColorBars(MySceneCtrlObj * sc)294 static void DrawColorBars( MySceneCtrlObj* sc )
295 {
296     u32     i;
297     u8      c0, c1;
298     Mtx     mv;
299 
300     // Turn de-flicker filter on
301     GXSetCopyFilter(GX_FALSE, NULL, GX_TRUE, sc->vfilter);
302 
303     // Transform matrix
304     MTXIdentity(mv);
305     GXLoadPosMtxImm(mv, GX_PNMTX0);
306     GXSetCurrentMtx(GX_PNMTX0);
307 
308     // Lighting off
309     GXSetNumChans(1);
310     GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX,
311                   GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE);
312 
313     // Set TEV operation to use vertex color
314     GXSetNumTexGens(0);
315 	GXSetNumTevStages(1);
316     GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
317     GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
318 
319     // Vertex descriptor
320     GXClearVtxDesc();
321     GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
322     GXSetVtxDesc(GX_VA_CLR0, GX_INDEX8);
323 
324     // Array pointer
325     GXSetArray(GX_VA_CLR0, MyColorArray, sizeof(GXColor));
326 
327     // Draw each color bar
328     GXBegin(GX_QUADS, GX_VTXFMT1, NUM_COLORBARS*4);
329     for ( i = 0 ; i < NUM_COLORBARS ; ++i )
330     {
331         c0 = (u8)((i % 2) ? i : 0);
332         c1 = (u8)((i % 2) ? 0 : i);
333 
334         GXPosition3s16(64,  (s16)(i*32+32), 0);
335         GXColor1x8(c0);
336         GXPosition3s16(576, (s16)(i*32+32), 0);
337         GXColor1x8(c1);
338         GXPosition3s16(576, (s16)(i*32+64), 0);
339         GXColor1x8(c1);
340         GXPosition3s16(64,  (s16)(i*32+64), 0);
341         GXColor1x8(c0);
342    }
343    GXEnd();
344 }
345 
346 /*---------------------------------------------------------------------------*
347     Name:           DrawGammaTestImg
348 
349     Description:    Draw a gamma test pattern
350 
351     Arguments:      sc : pointer to the structure of scene control parameters
352 
353     Returns:        none
354  *---------------------------------------------------------------------------*/
355 // Configuration data
356 struct
357 {
358     u32     x;
359     u32     y;
360     GXColor color0;
361     GXColor color1;
362 }
363 GammaImgConfig[4] =
364 {
365     { 160,  64, { 255, 255, 255, 255 }, { 128, 128, 128, 255 } },
366     { 352,  64, { 255,   0,   0, 255 }, { 128,   0,   0, 255 } },
367     { 160, 256, {   0, 255,   0, 255 }, {   0, 128,   0, 255 } },
368     { 352, 256, {   0,   0, 255, 255 }, {   0,   0, 128, 255 } }
369 };
370 
DrawGammaTestImg(MySceneCtrlObj * sc)371 static void DrawGammaTestImg( MySceneCtrlObj* sc )
372 {
373     u32         i;
374     GXTexObj    tx0, tx1;
375     Mtx         mv;
376 
377     // Turn de-flicker filter off
378     GXSetCopyFilter(GX_FALSE, NULL, GX_FALSE, sc->vfilter);
379 
380     // Lighting off (uses fixed color)
381     GXSetNumChans(1);
382     GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG,
383                   GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE);
384 
385     // Set TEV operation to use one color/texture each
386     GXSetNumTexGens(1);
387     GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
388 	GXSetNumTevStages(1);
389     GXSetTevOp(GX_TEVSTAGE0, GX_MODULATE);
390     GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
391 
392     // Set up textures
393     TPLGetGXTexObjFromPalette(MyTplObj, &tx0, 0);  // Stripe pattern
394     TPLGetGXTexObjFromPalette(MyTplObj, &tx1, 1);  // Reference pattern
395     GXInitTexObjLOD(&tx0, GX_NEAR, GX_NEAR, 0, 0, 0, 0, 0, GX_ANISO_1);
396     GXInitTexObjLOD(&tx1, GX_NEAR, GX_NEAR, 0, 0, 0, 0, 0, GX_ANISO_1);
397 
398     // Vertex descriptor
399     GXClearVtxDesc();
400     GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
401     GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
402 
403     GXSetCurrentMtx(GX_PNMTX0);
404 
405     // Draw four patterns
406     for ( i = 0 ; i < 4 ; ++i )
407     {
408         MTXTrans(mv, GammaImgConfig[i].x, GammaImgConfig[i].y, 0.0F);
409         GXLoadPosMtxImm(mv, GX_PNMTX0);
410 
411         GXSetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_ZERO, GX_LO_SET);
412         GXLoadTexObj(&tx0, GX_TEXMAP0);
413         GXSetChanMatColor(GX_COLOR0A0, GammaImgConfig[i].color0);
414 
415         GXBegin(GX_QUADS, GX_VTXFMT1, 4);
416             GXPosition3s16(  0,   0, 0);
417             GXTexCoord2s16(0x0000, 0x0000);
418             GXPosition3s16(128,   0, 0);
419             GXTexCoord2s16(0x0100, 0x0000);
420             GXPosition3s16(128, 128, 0);
421             GXTexCoord2s16(0x0100, 0x0100);
422             GXPosition3s16(  0, 128, 0);
423             GXTexCoord2s16(0x0000, 0x0100);
424         GXEnd();
425 
426         GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET);
427         GXLoadTexObj(&tx1, GX_TEXMAP0);
428         GXSetChanMatColor(GX_COLOR0A0, GammaImgConfig[i].color1);
429 
430         GXBegin(GX_QUADS, GX_VTXFMT1, 4);
431             GXPosition3s16(  0,   0, 0);
432             GXTexCoord2s16(0x0000, 0x0000);
433             GXPosition3s16(128,   0, 0);
434             GXTexCoord2s16(0x0100, 0x0000);
435             GXPosition3s16(128, 128, 0);
436             GXTexCoord2s16(0x0100, 0x0100);
437             GXPosition3s16(  0, 128, 0);
438             GXTexCoord2s16(0x0000, 0x0100);
439         GXEnd();
440     }
441 
442     GXSetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_ZERO, GX_LO_SET);
443 
444 }
445 
446 /*---------------------------------------------------------------------------*
447     Name:           DrawSampleImg
448 
449     Description:    Draw a sample image
450 
451     Arguments:      sc : pointer to the structure of scene control parameters
452 
453     Returns:        none
454  *---------------------------------------------------------------------------*/
DrawSampleImg(MySceneCtrlObj * sc)455 static void DrawSampleImg( MySceneCtrlObj* sc )
456 {
457     GXTexObj    tx;
458     Mtx         mv;
459 
460     // De-flicker filter on
461     GXSetCopyFilter(GX_FALSE, NULL, GX_TRUE, sc->vfilter);
462 
463     // Transform matrix
464     MTXIdentity(mv);
465     GXLoadPosMtxImm(mv, GX_PNMTX0);
466     GXSetCurrentMtx(GX_PNMTX0);
467 
468     // No color channel
469     GXSetNumChans(0);
470 
471     // Set TEV operation to use vertex color
472     GXSetNumTexGens(1);
473     GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
474 	GXSetNumTevStages(1);
475     GXSetTevOp(GX_TEVSTAGE0, GX_REPLACE);
476     GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
477 
478     // Set up texture
479     TPLGetGXTexObjFromPalette(MyTplObj, &tx, 2);  // Sample image
480     GXLoadTexObj(&tx, GX_TEXMAP0);
481 
482     // Vertex descriptor
483     GXClearVtxDesc();
484     GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
485     GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
486 
487     // Draw a large quad
488     GXBegin(GX_QUADS, GX_VTXFMT1, 4);
489         GXPosition3s16( 64,  96, 0);
490         GXTexCoord2s16(0x0000, 0x0000);
491         GXPosition3s16(576,  96, 0);
492         GXTexCoord2s16(0x0100, 0x0000);
493         GXPosition3s16(576, 352, 0);
494         GXTexCoord2s16(0x0100, 0x0100);
495         GXPosition3s16( 64, 352, 0);
496         GXTexCoord2s16(0x0000, 0x0100);
497     GXEnd();
498 }
499 
500 /*---------------------------------------------------------------------------*
501     Name:           DrawDonuts
502 
503     Description:    Draw doughnuts
504 
505     Arguments:      sc : pointer to the structure of scene control parameters
506 
507     Returns:        none
508  *---------------------------------------------------------------------------*/
DrawDonuts(MySceneCtrlObj * sc)509 static void DrawDonuts( MySceneCtrlObj* sc )
510 {
511     static u32  rot = 0;
512     GXLightObj  lo;
513     u32         i;
514     Mtx         m0, m1, ms;
515 	GXColor		color1 = { 64, 64, 64, 64 };
516 	GXColor		color2 = { 192, 192, 192, 192 };
517 
518     // De-flicker filter on
519     GXSetCopyFilter(GX_FALSE, NULL, GX_TRUE, sc->vfilter);
520 
521     // Z compare on
522     GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
523 
524     // Lighting on
525     GXSetNumChans(1);
526     GXSetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG,
527                   GX_LIGHT0, GX_DF_CLAMP, GX_AF_NONE);
528     GXSetChanAmbColor(GX_COLOR0A0, color1);
529 
530     GXInitLightColor(&lo, color2);
531     GXInitLightPos(&lo, 10000.0F, -10000.0F, 5000.0F);
532     GXLoadLightObjImm(&lo, GX_LIGHT0);
533 
534     // Set TEV operation to use vertex color
535     GXSetNumTexGens(0);
536 	GXSetNumTevStages(1);
537     GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
538     GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
539 
540     // Transform matrix
541     GXSetCurrentMtx(GX_PNMTX0);
542 
543     // Draw each icosahedron
544     MTXScale(ms, 48, 48, 48);
545     for ( i = 0 ; i < NUM_DONUTS ; ++i )
546     {
547         MTXRotDeg(m0, 'y', (rot+i*60));
548         MTXConcat(ms, m0, m1);
549         MTXTrans(m0, ((i%4)+1)*128, (i/4)*112+128, -256);
550         MTXConcat(m0, m1, m1);
551         GXLoadPosMtxImm(m1, GX_PNMTX0);
552 
553         GXSetChanMatColor(GX_COLOR0A0, MyColorArray[i+1]);
554         GXDrawTorus(0.3F, 12, 16);
555     }
556 
557     // Rotation counter
558     rot = ++rot % 360;
559 }
560 
561 /*---------------------------------------------------------------------------*
562     Name:           DrawLitOcta
563 
564     Description:    Draw a lit octahedron
565 
566     Arguments:      sc : pointer to the structure of scene control parameters
567 
568     Returns:        none
569  *---------------------------------------------------------------------------*/
DrawLitOcta(MySceneCtrlObj * sc)570 static void DrawLitOcta( MySceneCtrlObj* sc )
571 {
572     static u32  rot = 0;
573     GXLightObj  lo;
574     Mtx         mv, mr, ms, m1;
575 	GXColor		color1 = { 64, 64, 64, 64 };
576 	GXColor		color2 = { 160, 160, 160, 160 };
577 
578     // De-flicker filter on
579     GXSetCopyFilter(GX_FALSE, NULL, GX_TRUE, sc->vfilter);
580 
581     // Z compare on
582     GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
583 
584     // Lighting on
585     GXSetNumChans(1);
586     GXSetChanCtrl(GX_COLOR0A0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG,
587                   GX_LIGHT0, GX_DF_CLAMP, GX_AF_NONE);
588     GXSetChanAmbColor(GX_COLOR0A0, color1);
589     GXSetChanMatColor(GX_COLOR0A0, MyColorArray[sc->colorID]);
590 
591     GXInitLightColor(&lo, color2);
592     GXInitLightPos(&lo, 10000.0F, -10000.0F, 5000.0F);
593     GXLoadLightObjImm(&lo, GX_LIGHT0);
594 
595     // Set TEV operation to use vertex color
596     GXSetNumTexGens(0);
597 	GXSetNumTevStages(1);
598     GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
599     GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
600 
601     // Transform matrix
602     GXSetCurrentMtx(GX_PNMTX0);
603 
604     // Draw an octahedron
605     MTXTrans(m1, 320, 240, -512);
606     MTXRotDeg(mr, 'y', (f32)rot/2);
607     MTXConcat(m1, mr, mv);
608     MTXScale(ms, 192, 192, 192);
609     MTXConcat(mv, ms, m1);
610 
611     GXLoadPosMtxImm(m1, GX_PNMTX0);
612     GXLoadNrmMtxImm(m1, GX_PNMTX0);
613 
614     GXDrawOctahedron();
615 
616     // Rotation counter
617     rot = ++rot % 720;
618 }
619 
620 /*---------------------------------------------------------------------------*
621     Name:           PrintIntro
622 
623     Description:    Prints the directions on how to use this demo.
624 
625     Arguments:      none
626 
627     Returns:        none
628  *---------------------------------------------------------------------------*/
PrintIntro(void)629 static void PrintIntro( void )
630 {
631     OSReport("\n\n");
632     OSReport("************************************************\n");
633     OSReport("frb-gamma: gamma correction mode demo\n");
634     OSReport("************************************************\n");
635     OSReport("to quit hit the start button\n");
636     OSReport("\n");
637     OSReport("A Button : Change the pattern\n");
638     OSReport("B Button : Change gamma correction mode\n");
639     OSReport("X Button : Change the pixel format\n");
640     OSReport("************************************************\n\n");
641 }
642 
643 /*============================================================================*/
644