1 /*---------------------------------------------------------------------------*
2 Project: Dolphin GD demo
3 File: gd-texture-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-texture-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 3 10/11/01 4:05p Carl
22 Added use of color-index texture and TLUT.
23
24 2 10/09/01 11:27a Hirose
25 Moved WinMain to gd-win32-ui.c. Integrated tiny message output
26 function.
27
28 1 9/19/01 4:27p Carl
29 Sources for GD texture 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 // Application name
65 char* AppName = "gd-texture-host";
66
67 // Display lists *************************************************************
68
69 // This DL is used with the "Draw" display list.
70 // It initializes state that will be used by the Draw DL.
71
72 GDLObj InitDLO;
73
74 // This DL draws a textured cube. It must be paired with the Init DL.
75
76 GDLObj DrawDLO;
77
78 // This array indicates the offsets to patch memory addresses for the
79 // primitive data arrays (positions, normals, texture coordinates)
80 // referred to in the Init DL.
81
82 u32 *setArrayOffsets;
83
84 // This array tells us the offsets for where to patch the memory addresses
85 // for the textures in the Draw DL.
86
87 u32 *texAddrOffsets;
88
89 // This array tells us the offsets for where to patch the main memory
90 // addresses for loading the TLUTs in the Init DL.
91
92 u32 *tlutAddrOffsets;
93
94 /*---------------------------------------------------------------------------*
95 Application main loop
96 *---------------------------------------------------------------------------*/
97 // Function WinMain() is defined in gd-win32-ui.c
main(void)98 void main ( void )
99 {
100 GDGList dlists[2]; // keeps track of all display lists
101 GDGList plists[3]; // keeps track of all patch lists
102 u32 numDLs = 2;
103 u32 numPLs = 3;
104
105 CreateDLs();
106
107 dlists[0].ptr = GDGetGDLObjStart(&InitDLO);
108 dlists[0].byteLength = GDGetGDLObjOffset(&InitDLO);
109
110 dlists[1].ptr = GDGetGDLObjStart(&DrawDLO);
111 dlists[1].byteLength = GDGetGDLObjOffset(&DrawDLO);
112
113 plists[0].ptr = setArrayOffsets;
114 plists[0].byteLength = 3 * sizeof(u32);
115
116 plists[1].ptr = texAddrOffsets;
117 plists[1].byteLength = 6 * sizeof(u32);
118
119 plists[2].ptr = tlutAddrOffsets;
120 plists[2].byteLength = 1 * sizeof(u32);
121
122 GDWriteDLFile("gdTextr.gdl", numDLs, numPLs, dlists, plists);
123
124 GDReport("Created file \"gdTextr.gdl\" successfully.");
125 }
126
127