Debian Codegraph @

apps/demos/drop/TsPieces.c++

raw
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 _______________________________________________________________________
39 ______________ S I L I C O N G R A P H I C S I N C . ____________
40 |
41 | $Revision: 1.2 $
42 |
43 | Classes : TsEll, TsTee, TsZee, TsLTri, TsMTri, TsRTri
44 |
45 | Author : Dave Immel
46 |
47 ______________ S I L I C O N G R A P H I C S I N C . ____________
48 _______________________________________________________________________
49 */
50
51 #include <cstring>
52 #include "TsPieces.h"
53
54 static int ellTable[24][4] = {
55 { 4, 13, 22, 23},
56 { 12, 13, 14, 5},
57 { 22, 13, 4, 3},
58 { 14, 13, 12, 21},
59 { 10, 13, 16, 17},
60 { 12, 13, 14, 11},
61 { 16, 13, 10, 9},
62 { 14, 13, 12, 15},
63 { 22, 13, 4, 5},
64 { 14, 13, 12, 3},
65 { 4, 13, 22, 21},
66 { 12, 13, 14, 23},
67 { 16, 13, 10, 11},
68 { 14, 13, 12, 9},
69 { 10, 13, 16, 15},
70 { 12, 13, 14, 17},
71 { 4, 13, 22, 19},
72 { 16, 13, 10, 1},
73 { 22, 13, 4, 7},
74 { 10, 13, 16, 25},
75 { 4, 13, 22, 25},
76 { 10, 13, 16, 7},
77 { 22, 13, 4, 1},
78 { 16, 13, 10, 19}};
79
80 static int teeTable[24][4] = {
81 { 4, 13, 22, 14},
82 { 12, 13, 14, 4},
83 { 22, 13, 4, 12},
84 { 14, 13, 12, 22},
85 { 10, 13, 16, 14},
86 { 12, 13, 14, 10},
87 { 16, 13, 10, 12},
88 { 14, 13, 12, 16},
89 { 22, 13, 4, 14},
90 { 14, 13, 12, 4},
91 { 4, 13, 22, 12},
92 { 12, 13, 14, 22},
93 { 16, 13, 10, 14},
94 { 14, 13, 12, 10},
95 { 10, 13, 16, 12},
96 { 12, 13, 14, 16},
97 { 4, 13, 22, 10},
98 { 16, 13, 10, 4},
99 { 22, 13, 4, 16},
100 { 10, 13, 16, 22},
101 { 4, 13, 22, 16},
102 { 10, 13, 16, 4},
103 { 22, 13, 4, 10},
104 { 16, 13, 10, 22}};
105
106 static int zeeTable[24][4] = {
107 { 4, 13, 14, 23},
108 { 12, 13, 4, 5},
109 { 23, 14, 13, 4},
110 { 5, 4, 13, 12},
111 { 10, 13, 14, 17},
112 { 12, 13, 10, 11},
113 { 17, 14, 13, 10},
114 { 11, 10, 13, 12},
115 { 22, 13, 14, 5},
116 { 14, 13, 4, 3},
117 { 5, 14, 13, 22},
118 { 3, 4, 13, 14},
119 { 16, 13, 14, 11},
120 { 14, 13, 10, 9},
121 { 11, 14, 13, 16},
122 { 9, 10, 13, 14},
123 { 4, 13, 10, 19},
124 { 16, 13, 4, 1},
125 { 19, 10, 13, 4},
126 { 1, 4, 13, 16},
127 { 4, 13, 16, 25},
128 { 10, 13, 4, 7},
129 { 25, 16, 13, 4},
130 { 7, 4, 13, 10}};
131
132
133 static int ltriTable[24][4] = {
134 { 0, 9, 12, 1},
135 { 9, 10, 13, 0},
136 { 10, 1, 4, 9},
137 { 1, 0, 3, 10},
138 { 9, 12, 3, 10},
139 { 12, 13, 4, 9},
140 { 13, 10, 1, 12},
141 { 10, 9, 0, 13},
142 { 12, 3, 0, 13},
143 { 13, 12, 9, 4},
144 { 4, 13, 10, 3},
145 { 3, 4, 1, 12},
146 { 3, 0, 9, 4},
147 { 4, 3, 12, 1},
148 { 1, 4, 13, 0},
149 { 0, 1, 10, 3},
150 { 3, 12, 13, 0},
151 { 12, 9, 10, 3},
152 { 9, 0, 1, 12},
153 { 0, 3, 4, 9},
154 { 1, 10, 9, 4},
155 { 10, 13, 12, 1},
156 { 13, 4, 3, 10},
157 { 4, 0, 1, 13}};
158
159
160 static int mtriTable[24][4] = {
161 { 0, 9, 12, 10},
162 { 9, 10, 13, 1},
163 { 10, 1, 4, 0},
164 { 1, 0, 3, 9},
165 { 9, 12, 3, 13},
166 { 12, 13, 4, 10},
167 { 13, 10, 1, 9},
168 { 10, 9, 0, 12},
169 { 12, 3, 0, 4},
170 { 13, 12, 9, 3},
171 { 4, 13, 10, 12},
172 { 3, 4, 1, 13},
173 { 3, 0, 9, 1},
174 { 4, 3, 12, 0},
175 { 1, 4, 13, 3},
176 { 0, 1, 10, 4},
177 { 3, 12, 13, 9},
178 { 12, 9, 10, 0},
179 { 9, 0, 1, 3},
180 { 0, 3, 4, 12},
181 { 1, 10, 9, 13},
182 { 10, 13, 12, 4},
183 { 13, 4, 3, 1},
184 { 4, 0, 1, 10}};
185
186
187 static int rtriTable[24][4] = {
188 { 0, 9, 12, 13},
189 { 9, 10, 13, 4},
190 { 10, 1, 4, 3},
191 { 1, 0, 3, 12},
192 { 9, 12, 3, 4},
193 { 12, 13, 4, 1},
194 { 13, 10, 1, 0},
195 { 10, 9, 0, 3},
196 { 12, 3, 0, 1},
197 { 13, 12, 9, 0},
198 { 4, 13, 10, 9},
199 { 3, 4, 1, 10},
200 { 3, 0, 9, 10},
201 { 4, 3, 12, 9},
202 { 1, 4, 13, 12},
203 { 0, 1, 10, 13},
204 { 3, 12, 13, 10},
205 { 12, 9, 10, 1},
206 { 9, 0, 1, 4},
207 { 0, 3, 4, 13},
208 { 1, 10, 9, 12},
209 { 10, 13, 12, 3},
210 { 13, 4, 3, 0},
211 { 4, 0, 1, 9}};
212
213
214
215 ////////////////////////////////////////////////////////////////////////
216 //
217 // Description:
218 // Constructor for the TsEll.
219 //
220 // Use: public
221
222 TsEll::TsEll()
223
224 //
225 ////////////////////////////////////////////////////////////////////////
226 {
227 numBlocks = 4;
228 memcpy ((void *)piecePositionTable,
229 (const void *)ellTable,
230 24*4*sizeof(int));
231 }
232
233
234 ////////////////////////////////////////////////////////////////////////
235 //
236 // Description:
237 // Destructor for TsEll.
238 //
239 // Use: public
240
241 TsEll::~TsEll()
242
243 //
244 ////////////////////////////////////////////////////////////////////////
245 {
246 }
247
248 ////////////////////////////////////////////////////////////////////////
249 //
250 // Description:
251 // Constructor for the TsTee.
252 //
253 // Use: public
254
255 TsTee::TsTee()
256
257 //
258 ////////////////////////////////////////////////////////////////////////
259 {
260 numBlocks = 4;
261 memcpy ((void *)piecePositionTable,
262 (const void *)teeTable,
263 24*4*sizeof(int));
264 }
265
266
267 ////////////////////////////////////////////////////////////////////////
268 //
269 // Description:
270 // Destructor for TsTee.
271 //
272 // Use: public
273
274 TsTee::~TsTee()
275
276 //
277 ////////////////////////////////////////////////////////////////////////
278 {
279 }
280
281 ////////////////////////////////////////////////////////////////////////
282 //
283 // Description:
284 // Constructor for the TsZee.
285 //
286 // Use: public
287
288 TsZee::TsZee()
289
290 //
291 ////////////////////////////////////////////////////////////////////////
292 {
293 numBlocks = 4;
294 memcpy ((void *)piecePositionTable,
295 (const void *)zeeTable,
296 24*4*sizeof(int));
297 }
298
299
300 ////////////////////////////////////////////////////////////////////////
301 //
302 // Description:
303 // Destructor for TsZee.
304 //
305 // Use: public
306
307 TsZee::~TsZee()
308
309 //
310 ////////////////////////////////////////////////////////////////////////
311 {
312 }
313
314
315 ////////////////////////////////////////////////////////////////////////
316 //
317 // Description:
318 // Constructor for the TsLTri.
319 //
320 // Use: public
321
322 TsLTri::TsLTri()
323
324 //
325 ////////////////////////////////////////////////////////////////////////
326 {
327 numBlocks = 4;
328 memcpy ((void *)piecePositionTable,
329 (const void *)ltriTable,
330 24*4*sizeof(int));
331 }
332
333
334 ////////////////////////////////////////////////////////////////////////
335 //
336 // Description:
337 // Destructor for TsLTri.
338 //
339 // Use: public
340
341 TsLTri::~TsLTri()
342
343 //
344 ////////////////////////////////////////////////////////////////////////
345 {
346 }
347
348 ////////////////////////////////////////////////////////////////////////
349 //
350 // Description:
351 // Constructor for the TsMTri.
352 //
353 // Use: public
354
355 TsMTri::TsMTri()
356
357 //
358 ////////////////////////////////////////////////////////////////////////
359 {
360 numBlocks = 4;
361 memcpy ((void *)piecePositionTable,
362 (const void *)mtriTable,
363 24*4*sizeof(int));
364 }
365
366
367 ////////////////////////////////////////////////////////////////////////
368 //
369 // Description:
370 // Destructor for TsMTri.
371 //
372 // Use: public
373
374 TsMTri::~TsMTri()
375
376 //
377 ////////////////////////////////////////////////////////////////////////
378 {
379 }
380
381 ////////////////////////////////////////////////////////////////////////
382 //
383 // Description:
384 // Constructor for the TsRTri.
385 //
386 // Use: public
387
388 TsRTri::TsRTri()
389
390 //
391 ////////////////////////////////////////////////////////////////////////
392 {
393 numBlocks = 4;
394 memcpy ((void *)piecePositionTable,
395 (const void *)rtriTable,
396 24*4*sizeof(int));
397 }
398
399
400 ////////////////////////////////////////////////////////////////////////
401 //
402 // Description:
403 // Destructor for TsRTri.
404 //
405 // Use: public
406
407 TsRTri::~TsRTri()
408
409 //
410 ////////////////////////////////////////////////////////////////////////
411 {
412 }
413
414
415
416
417
418