1 /*- 2 # X-BASED CUBES 3 # 4 # CubesP.h 5 # 6 ### 7 # 8 # Copyright (c) 1994 - 99 David Albert Bagley, bagleyd@tux.org 9 # 10 # All Rights Reserved 11 # 12 # Permission to use, copy, modify, and distribute this software and 13 # its documentation for any purpose and without fee is hereby granted, 14 # provided that the above copyright notice appear in all copies and 15 # that both that copyright notice and this permission notice appear in 16 # supporting documentation, and that the name of the author not be 17 # used in advertising or publicity pertaining to distribution of the 18 # software without specific, written prior permission. 19 # 20 # This program is distributed in the hope that it will be "playable", 21 # but WITHOUT ANY WARRANTY; without even the implied warranty of 22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 23 # 24 */ 25 26 /* Private header file for Cubes */ 27 28 #ifndef _CubesP_h 29 #define _CubesP_h 30 31 #include "Cubes.h" 32 33 /*** random number generator ***/ 34 #if HAVE_RAND48 35 #define SRAND srand48 36 #define LRAND lrand48 37 #define MAXRAND (2147483648.0) 38 #else /* HAVE_RAND48 */ 39 #if HAVE_RANDOM 40 #define SRAND srand48 41 #define LRAND lrand48 42 #define MAXRAND (2147483648.0) 43 #else /* HAVE_RANDOM */ 44 #if HAVE_RAND 45 #define SRAND srand48 46 #define LRAND lrand48 47 #ifdef AIXV3 48 #define MAXRAND (2147483648.0) 49 #else 50 #define MAXRAND (32768.0) 51 #endif 52 #endif /* HAVE_RAND */ 53 #endif /* HAVE_RANDOM */ 54 #endif /* HAVE_RAND48 */ 55 56 #ifndef SRAND 57 extern void SetRNG(long int s); 58 59 #define SRAND(X) SetRNG((long) X) 60 #endif 61 #ifndef LRAND 62 extern long LongRNG(void); 63 64 #define LRAND() LongRNG() 65 #endif 66 #ifndef MAXRAND 67 #define MAXRAND (2147483648.0) 68 #endif 69 70 #define NRAND(X) ((int)(LRAND()%(X))) 71 72 #define SYMBOL ':' 73 74 #define TOP 0 75 #define RIGHT 1 76 #define BOTTOM 2 77 #define LEFT 3 78 #define IN 4 79 #define OUT 5 80 #define COORD 6 81 82 /* The following is in xcubes.c also */ 83 #define MINCUBES 1 84 85 #define DEFAULTCUBES 3 86 87 #define ABS(a) (((a)<0)?(-a):(a)) 88 #define SIGN(a) (((a)<0)?(-1):1) 89 #define MIN(a,b) (((int)(a)<(int)(b))?(int)(a):(int)(b)) 90 #define MAX(a,b) (((int)(a)>(int)(b))?(int)(a):(int)(b)) 91 92 typedef struct _CubesPart { 93 Pixel foreground; 94 Pixel brickColor, borderColor; 95 int *brickOfPosition, spacePosition; 96 int currentPosition, currentRow[3]; 97 Boolean started, vertical, mono, reverse; 98 int depth; 99 int base; 100 int sizeX, sizeY, sizeZ, sizeRect, sizeBlock; 101 XPoint offset; 102 XPoint brickSize, faceSize, puzzleSize; 103 XPoint delta, puzzleOffset, digitOffset; 104 GC puzzleGC; 105 GC brickGC; 106 GC borderGC; 107 GC inverseGC; 108 char *username; 109 XtCallbackList select; 110 } CubesPart; 111 112 typedef struct _CubesRec { 113 CorePart core; 114 CubesPart cubes; 115 } CubesRec; 116 117 /* This gets around C's inability to do inheritance */ 118 typedef struct _CubesClassPart { 119 int ignore; 120 } CubesClassPart; 121 122 typedef struct _CubesClassRec { 123 CoreClassPart core_class; 124 CubesClassPart cubes_class; 125 } CubesClassRec; 126 127 extern CubesClassRec cubesClassRec; 128 extern int *startPosition; 129 130 extern int MoveCubesDir(CubesWidget w, int direction); 131 132 #if 0 133 extern void SolveBricks(); /* For future auto-solver */ 134 135 #endif 136 extern void DrawAllBricks(CubesWidget w); 137 extern Boolean CheckSolved(CubesWidget w); 138 extern void InitMoves(void); 139 extern void PutMove(int direction); 140 extern void GetMove(int *direction); 141 extern int MadeMoves(void); 142 extern void FlushMoves(CubesWidget w); 143 extern int NumMoves(void); 144 extern void ScanMoves(FILE * fp, CubesWidget w, int moves); 145 extern void PrintMoves(FILE * fp); 146 extern void ScanStartPosition(FILE * fp, CubesWidget w); 147 extern void PrintStartPosition(FILE * fp, CubesWidget w); 148 extern void SetStartPosition(CubesWidget w); 149 150 #endif /* _CubesP_h */ 151