1 /*---------------------------------------------------------------------------*
2   Project:  Dolphin GD demo
3   File:     gd-light-host.c
4 
5   Copyright 2001 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   $Log: gd-light-host.c,v $
14   Revision 1.2  02/20/2006 04:13:09  mitu
15   changed include path from dolphin/ to revolution/.
16 
17   Revision 1.1  02/08/2006 11:19:43  mitu
18   1st version.
19 
20 
21     2     10/09/01 11:27a Hirose
22     Moved WinMain to gd-win32-ui.c. Integrated tiny message output
23     function.
24 
25     1     9/21/01 4:06p Hirose
26     Initial check in.
27 
28   $NoKeywords: $
29  *---------------------------------------------------------------------------*/
30 /*---------------------------------------------------------------------------*
31    gd-light
32      Displaylist demo with lighting commands
33      [Host program for creating off-line display list file]
34  *---------------------------------------------------------------------------*/
35 
36 
37 /*---------------------------------------------------------------------------*
38    Header file includes
39  *---------------------------------------------------------------------------*/
40 #include <windows.h>
41 
42 #include <revolution/gd.h>
43 
44 #include <assert.h>
45 #include <stdarg.h>
46 #include <stdio.h>
47 #include <stdlib.h>
48 
49 #include "gd-light.h"
50 
51 /*---------------------------------------------------------------------------*
52    Macro definitions
53  *---------------------------------------------------------------------------*/
54 #define RoundUp32B(x)  (((u32)(x) + 31) & ~31)
55 
56 /*---------------------------------------------------------------------------*
57    Forward references
58  *---------------------------------------------------------------------------*/
59 // defined in gd-win32-ui.c
60 extern void GDReport (char* msg, ...);
61 
62 void        main     ( void );
63 
64 /*---------------------------------------------------------------------------*
65    Application name
66  *---------------------------------------------------------------------------*/
67 char* AppName = "gd-light-host";
68 
69 /*---------------------------------------------------------------------------*
70    Global variables
71  *---------------------------------------------------------------------------*/
72 static void* DisplayListBuffer;
73 static u32*  PatchListBuffer;
74 
75 /*---------------------------------------------------------------------------*
76    Application main loop
77  *---------------------------------------------------------------------------*/
78 // Function WinMain() is defined in gd-win32-ui.c
main(void)79 void main ( void )
80 {
81     GDGList dlists[1]; // keeps track of all display lists
82     GDGList plists[1]; // keeps track of all patch lists
83     u32     numDLs = 1;
84     u32     numPLs = 1;
85 	u32     size;
86 	void*   buffer;
87 
88     size = MODELDL_SIZE_MAX + MODELDL_NUM_PATCHES * sizeof(u32) + 32;
89     buffer = malloc(size);
90 	assert(buffer);
91 
92 	DisplayListBuffer = (void*)RoundUp32B(buffer);
93 	PatchListBuffer   = (u32*)((u32)DisplayListBuffer + MODELDL_SIZE_MAX);
94 
95     size = CreateModelDL(DisplayListBuffer, PatchListBuffer);
96 
97     dlists[0].ptr        = DisplayListBuffer;
98     dlists[0].byteLength = size;
99     plists[0].ptr        = PatchListBuffer;
100     plists[0].byteLength = MODELDL_NUM_PATCHES * sizeof(u32);
101 
102     GDWriteDLFile("gdLight.gdl", numDLs, numPLs, dlists, plists);
103 
104 	free(buffer);
105 
106 	GDReport("Created file \"gdLight.gdl\" successfully.");
107 }
108 
109 /*============================================================================*/
110