1 /*---------------------------------------------------------------------------*
2   Project:  Dolphin GD demo
3   File:     gd-tev-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-tev-host.c,v $
14   Revision 1.2  02/20/2006 04:13:10  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     10/04/01 2:48p Hirose
26     Initial check in.
27 
28   $NoKeywords: $
29  *---------------------------------------------------------------------------*/
30 /*---------------------------------------------------------------------------*
31    gd-tev
32      Displaylist demo with multi-texture shader 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-tev.h"
50 
51 /*---------------------------------------------------------------------------*
52    Macro definitions
53  *---------------------------------------------------------------------------*/
54 #define RoundUp32B(x)  (((u32)(x) + 31) & ~31)
55 
56 
57 /*---------------------------------------------------------------------------*
58    Forward references
59  *---------------------------------------------------------------------------*/
60 // defined in gd-win32-ui.c
61 extern void GDReport (char* msg, ...);
62 
63 void        main     ( void );
64 
65 /*---------------------------------------------------------------------------*
66    Application name
67  *---------------------------------------------------------------------------*/
68 char* AppName = "gd-tev-host";
69 
70 /*---------------------------------------------------------------------------*
71    Global variables
72  *---------------------------------------------------------------------------*/
73 static void(*CreateShdDLFunc[NUM_SHADERDLS])() =
74 {
75     CreateShader0DL, CreateShader1DL, CreateShader2DL, CreateShader3DL
76 };
77 
78 /*---------------------------------------------------------------------------*
79    Application main loop
80  *---------------------------------------------------------------------------*/
81 // Function WinMain() is defined in gd-win32-ui.c
main(void)82 void main ( void )
83 {
84     GDGList dlists[NUM_DLS];    // keeps track of all display lists
85     GDGList plists[NUM_PLS];    // keeps track of all patch lists
86 	u32     size;
87 	void*   buffer;
88 	u8*     ptr;
89 	u32     i;
90 	u32     index;
91 
92     // Allocate entire work memory first
93     size   = (SDL_SIZE_MAX + PL_SIZE_MAX * sizeof(u32)) * NUM_SHADERDLS
94            + MDL_SIZE_MAX
95            + 32;
96     buffer = malloc(size);
97 	assert(buffer);
98 
99 	index  = 0;
100 
101     // Make sure 32Bytes alignment
102     ptr = (u8*)RoundUp32B(buffer);
103 
104 
105     // Create multi-texturing shader display lists
106     for ( i = 0 ; i < NUM_SHADERDLS ; ++i )
107     {
108        	dlists[index].ptr = (void*)ptr;
109        	ptr += SDL_SIZE_MAX;
110        	plists[index].ptr = (u32*)ptr;
111       	ptr += PL_SIZE_MAX * sizeof(u32);
112 
113         (*CreateShdDLFunc[i])(dlists[index].ptr, &dlists[index].byteLength,
114                               plists[index].ptr, &plists[index].byteLength);
115 
116         index++;
117     }
118 
119     // Create model display list
120 	dlists[index].ptr = (void*)ptr;
121 	ptr += MDL_SIZE_MAX;
122 
123     CreateModelDL(dlists[index].ptr, &dlists[index].byteLength);
124 
125 
126     GDWriteDLFile("gdTev.gdl", NUM_DLS, NUM_PLS, dlists, plists);
127 
128 	free(buffer);
129 
130 	GDReport("Created file \"gdTev.gdl\" successfully.");
131 }
132 
133 /*============================================================================*/
134