1 /*---------------------------------------------------------------------------*
2 Project: Dolphin GD demo
3 File: gd-init-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-init-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 3 10/09/01 11:27a Hirose
22 Moved WinMain to gd-win32-ui.c. Integrated tiny message output
23 function.
24
25 2 10/04/01 4:59p Carl
26 Fixed patch list length parameter.
27
28 1 9/25/01 6:23p Carl
29 Sources for GD init demo.
30
31 $NoKeywords: $
32 *---------------------------------------------------------------------------*/
33
34 #include <windows.h>
35
36 #include <revolution/gd.h>
37
38 #include <assert.h>
39 #include <stdarg.h>
40 #include <stdio.h>
41 #include <stdlib.h>
42
43 /*---------------------------------------------------------------------------*/
44
45 #define ASSERT assert
46 #define OSRoundUp32B(x) (((u32)(x) + 31) & ~31)
47 #define OSAlloc(x) ((void*)OSRoundUp32B(malloc((x)+31)))
48 #define OSFree(x) free(x)
49
50 /*---------------------------------------------------------------------------*
51 Forward references
52 *---------------------------------------------------------------------------*/
53 void main ( void );
54
55 // Externs:
56
57 extern void CreateDLs ( void );
58
59 extern void GDReport (char* msg, ...);
60
61 /*---------------------------------------------------------------------------*
62 Global variables
63 *---------------------------------------------------------------------------*/
64 char* AppName = "gd-init-host";
65
66 // Display lists *************************************************************
67
68 // This DL is used with the "Draw" display list.
69 // It initializes state that will be used by the Draw DL.
70
71 GDLObj InitDLO;
72
73 // This DL draws a cube.
74
75 GDLObj DrawDLO;
76
77 // This array indicates the offsets to patch memory addresses for the
78 // primitive data arrays (positions, colors) referred to in the Init DL.
79
80 u32 *setArrayOffsets;
81
82 /*---------------------------------------------------------------------------*
83 Application main loop
84 *---------------------------------------------------------------------------*/
85 // Function WinMain() is defined in gd-win32-ui.c
main(void)86 void main ( void )
87 {
88 GDGList dlists[2]; // keeps track of all display lists
89 GDGList plists[2]; // keeps track of all patch lists
90 u32 numDLs = 2;
91 u32 numPLs = 1;
92
93 CreateDLs();
94
95 dlists[0].ptr = GDGetGDLObjStart(&InitDLO);
96 dlists[0].byteLength = GDGetGDLObjOffset(&InitDLO);
97
98 dlists[1].ptr = GDGetGDLObjStart(&DrawDLO);
99 dlists[1].byteLength = GDGetGDLObjOffset(&DrawDLO);
100
101 plists[0].ptr = setArrayOffsets;
102 plists[0].byteLength = 2 * sizeof(u32);
103
104 GDWriteDLFile("gdInit.gdl", numDLs, numPLs, dlists, plists);
105
106 GDReport("Created file \"gdInit.gdl\" successfully.");
107 }
108
109