1 /*
2   File:        Types.h
3   Description: Various basic types definitions
4   Program:     BlockOut
5   Author:      Jean-Luc PONS
6 
7   This program is free software; you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation; either version 2 of the License, or
10   (at your option) any later version.
11 
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16 */
17 
18 #include "GLApp/GLApp.h"
19 
20 #ifndef TYPESH
21 #define TYPESH
22 
23 #define STR(x) ((char *)x)
24 
25 #ifdef WINDOWS
26 
27 typedef unsigned __int32 uint32;
28 typedef __int32 int32;
29 
30 #else
31 
32 typedef unsigned int uint32;
33 typedef int int32;
34 
35 #endif
36 
37 //-----------------------------------------------------------------------------
38 // Global definitions
39 //-----------------------------------------------------------------------------
40 
41 #define PI                 3.1415926535f
42 #define STARTZ             0.87f
43 #define FAR_DISTANCE       10.0f
44 #define MAX_CUBE           50
45 #define NB_POLYCUBE        41
46 
47 // Vertex format
48 #define VERTEX_FORMAT      (D3DFVF_XYZ)
49 #define FACEVERTEX_FORMAT  (D3DFVF_XYZ | D3DFVF_NORMAL)
50 #define TFACEVERTEX_FORMAT  (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1)
51 
52 // Max pit dimension
53 #define MAX_PITWIDTH       7
54 #define MAX_PITHEIGHT      7
55 #define MAX_PITDEPTH       18
56 
57 // Min pit dimension
58 #define MIN_PITWIDTH       3
59 #define MIN_PITHEIGHT      3
60 #define MIN_PITDEPTH       6
61 
62 // Block set
63 #define BLOCKSET_FLAT      0
64 #define BLOCKSET_BASIC     1
65 #define BLOCKSET_EXTENDED  2
66 
67 // Animation speed
68 #define ASPEED_SLOW        0
69 #define ASPEED_FAST        10
70 
71 // Face transparency
72 #define FTRANS_MIN         0
73 #define FTRANS_MAX         10
74 
75 // Game state
76 #define GAME_PLAYING       1
77 #define GAME_PAUSED        2
78 #define GAME_OVER          3
79 #define GAME_DEMO          4
80 
81 // Screen resoltion
82 #define RES_640x480        0
83 #define RES_800x600        1
84 #define RES_1024x768       2
85 #define RES_1280x1024      3
86 #define RES_1600x1200      4
87 
88 // Game style
89 #define STYLE_CLASSIC      0
90 #define STYLE_MARBLE       1
91 #define STYLE_ARCADE       2
92 
93 // Game sound
94 #define SOUND_BLOCKOUT2    0
95 #define SOUND_BLOCKOUT     1
96 
97 // Frame limiter
98 #define FR_NOLIMIT     0
99 #define FR_LIMIT50     1
100 #define FR_LIMIT60     2
101 #define FR_LIMIT75     3
102 #define FR_LIMIT100    4
103 #define FR_LIMITVSYNC  5
104 
105 // Line width
106 #define LINEW_MIN    0
107 #define LINEW_MAX    10
108 
109 //-----------------------------------------------------------------------------
110 // Structure definitions
111 //-----------------------------------------------------------------------------
112 typedef struct {
113 
114   int x;
115   int y;
116 
117 } POINT2D;
118 
119 typedef struct  {
120 
121   float x;
122   float y;
123   float z;
124 
125 } VERTEX;
126 
127 typedef struct {
128 
129   int x;
130   int y;
131   int z;
132 
133 } BLOCKITEM;
134 
135 typedef struct {
136 
137   BLOCKITEM p1;
138   BLOCKITEM p2;
139   int orientation;
140 
141 } EDGE;
142 
143 typedef struct {
144 
145   VERTEX p;
146   VERTEX o;
147 
148 } CORNER;
149 
150 typedef struct {
151 
152   int r0;
153   int r1;
154   int r2;
155 
156 } ORIENTATION;
157 
158 typedef struct SCORERECLINK {
159 
160   int32  setupId;
161   int32  score;
162   int32  nbCube;
163   int32  nbLine1;
164   int32  nbLine2;
165   int32  nbLine3;
166   int32  nbLine4;
167   int32  nbLine5;
168   int32  startLevel;
169   uint32 date;
170   char   name[11];
171   BYTE   emptyPit;
172   int32  scoreId;
173   float  gameTime;
174 
175   SCORERECLINK *next;
176 
177 } SCOREREC;
178 
179 typedef struct {
180 
181   char  name[11];
182   int32 rank;
183   int32 highScore;
184 
185 } PLAYER_INFO;
186 
187 typedef struct {
188 
189   int32 rotate;
190   int32 tx;
191   int32 ty;
192   int32 tz;
193 
194 } AI_MOVE;
195 
196 //-----------------------------------------------------------------------------
197 // Util functions
198 //-----------------------------------------------------------------------------
199 
200 extern VERTEX v(float x,float y,float z);
201 extern void Normalize(VERTEX *v);
202 extern int fround(float x);
203 extern char *FormatTime(float seconds);
204 extern char *FormatDate(uint32 time);
205 extern char *FormatDateShort(uint32 time);
206 extern int CreateTexture(int width,int height,char *imgName,GLuint *hmap);
207 extern char GetChar(BYTE *keys);
208 #ifndef WINDOWS
209 extern void ZeroMemory(void *buff,int size);
210 #endif
211 extern BOOL DirExists(char *dirname);
212 extern BOOL CheckEnv();
213 extern char *LID(char *fileName);
214 extern char *LHD(char *fileName);
215 
216 
217 #endif /* TYPESH */
218