1 /*
2 **
3 ** X11 Jewel By David Cooper and Jose Guterman 05/92
4 **
5 */
6
7 #include "general.h"
8 #include "hscore.h"
9 #include "panel.h"
10
11 static int Score;
12 static int Lives;
13 static float Speed;
14 static int Stage;
15 static int Rest;
16 static BOOL _Sound = DEF_SOUND;
17 static BOOL _Paused;
18
19 static float Speeds[]=
20 {
21 1.500, /* Stage 1 */
22 1.250, /* Stage 2 */
23 1.000, /* Stage 3 */
24 0.750, /* Stage 4 */
25 0.500, /* Stage 5 */
26 0.250, /* Stage 6 */
27 0.2375, /* Stage 7 */
28 0.2250, /* Stage 8 */
29 0.2125, /* Stage 9 */
30 0.2000, /* Stage 10 */
31 0.1875, /* Stage 11 */
32 0.1750, /* Stage 12 */
33 0.1625, /* Stage 13 */
34 0.1500, /* Stage 14 */
35 0.1375, /* Stage 15 */
36 0.1250, /* Stage 16 */
37 0.1125, /* Stage 17 */
38 0.1000, /* Stage 18 */
39 0.0875, /* Stage 19 */
40 0.0750, /* Stage 20 */
41 0.0625, /* Stage 21 */
42 0.0500, /* Stage 22 */
43 0.0375, /* Stage 23 */
44 0.0250, /* Stage 24 */
45 0.0125, /* Stage 25 */
46 0.0000, /* Stage 26 */
47 0.0000 /* Stage 27 */
48 };
49
Reset_Score()50 void Reset_Score()
51 {
52 /* set to zero */
53 Score=0;
54 Redraw_Score(Score);
55 }
56
Add_Raw_Score(pts,mult)57 void Add_Raw_Score(pts,mult)
58 int pts, mult;
59 {
60 /* a pts is any value */
61 /* mult is simply the number of times pts is to be added */
62 /* Redraw_Add_Score(pts,mult);*/
63 Score+=(pts*mult);
64 Redraw_Score(Score);
65 }
66
67
Add_Score(pts,iteration)68 void Add_Score(pts,iteration)
69 int pts, iteration;
70 {
71 int Mult=1<<(iteration-1);
72 /* mult is simply the iteration of match algorithm */
73 Redraw_Add_Score(pts,Mult);
74 Score+=(pts*Mult);
75 Redraw_Score(Score);
76 }
77
Get_Score()78 int Get_Score()
79 {
80 return(Score);
81 }
82
Reset_Lives()83 void Reset_Lives()
84 {
85 /* set to default */
86 Lives=INITIAL_LIVES;
87 Redraw_Lives(Lives);
88 }
89
Dec_Lives()90 void Dec_Lives()
91 {
92 /* obvious */
93 Lives--;
94 Redraw_Lives(Lives);
95 if (Lives == 0) /* Sorry my friend you are history... */
96 {
97 End_Game();
98 }
99 }
100
Reset_Stage()101 void Reset_Stage()
102 {
103 /* set stage and speed */
104 Stage=1;
105 Speed=Speeds[0];
106 Redraw_Speed(Speed);
107 Redraw_Stage(Stage);
108 }
109
Inc_Stage()110 void Inc_Stage()
111 {
112 /* set stage and speed */
113 Stage++;
114 if (Stage > MAX_STAGE)
115 {
116 Stage = 1;
117 }
118 Speed=Speeds[Stage-1];
119 Redraw_Speed(Speed);
120 Redraw_Stage(Stage);
121 }
122
Dec_Stage()123 void Dec_Stage()
124 {
125 /* set stage and speed */
126 if (Stage > 1)
127 {
128 Stage--;
129 Speed=Speeds[Stage-1];
130 Redraw_Speed(Speed);
131 Redraw_Stage(Stage);
132 }
133 }
134
Get_Stage()135 int Get_Stage()
136 {
137 return(Stage);
138 }
139
Get_Speed_ms()140 unsigned long Get_Speed_ms()
141 {
142 return((unsigned long)(Speed*1000));
143 }
144
Reset_Rest()145 void Reset_Rest()
146 {
147 Rest=PIECES_PER_STAGE;
148 Redraw_Rest(Rest);
149 }
150
Dec_Rest(val)151 BOOL Dec_Rest(val)
152 {
153 BOOL new_stage;
154
155 new_stage=FALSE;
156 Rest = Rest-val;
157 if (Rest <= 0) /* Time for next stage */
158 {
159 Inc_Stage();
160 Rest = PIECES_PER_STAGE + Rest;
161 new_stage=TRUE;
162 }
163 Redraw_Rest(Rest);
164 return(new_stage);
165 }
166
Reset_Pause()167 void Reset_Pause()
168 {
169 _Paused=FALSE;
170 Redraw_Pause();
171 }
172
Set_Pause()173 void Set_Pause()
174 {
175 _Paused=TRUE;
176 Redraw_Pause();
177 }
178
Toggle_Pause()179 BOOL Toggle_Pause()
180 {
181 _Paused=((_Paused) ? FALSE : TRUE);
182 Redraw_Pause();
183 return(_Paused);
184 }
185
Paused()186 BOOL Paused()
187 {
188 return(_Paused);
189 }
190
Toggle_Sound()191 BOOL Toggle_Sound()
192 {
193 _Sound=((_Sound) ? FALSE : TRUE);
194 Redraw_Sound();
195 return(_Sound);
196 }
197
Sound()198 BOOL Sound()
199 {
200 return(_Sound);
201 }
202
Redraw_Text()203 void Redraw_Text()
204 {
205 /* do all of above */
206 Redraw_Score(Score);
207 Redraw_Lives(Lives);
208 Redraw_Speed(Speed);
209 Redraw_Stage(Stage);
210 Redraw_Rest(Rest);
211 Redraw_Sound();
212 Redraw_Pause();
213 }
214
New_Game()215 void New_Game()
216 {
217 Reset_Score();
218 Reset_Lives();
219 Reset_Stage();
220 Reset_Rest();
221 Reset_Pause();
222 }
223