1 #ifndef _global_h
2 #	include "global.h"
3 #endif
4 
5 //
6 // Im Modul global.C werden s�mtliche Spielparameter wie Gr��en,
7 // Kr�fte ... festgehalten, damit sie an einer lokalen Stelle zugreifbar
8 // sind. Die zugeordneten Werte sind Voreinstellungen, die durch eine
9 // Konfigurationsdatei (wenn vorhanden) �berschrieben werden k�nnen.
10 //
11 
12 #ifndef _real_h
13 #	include "real.h"
14 #endif
15 #ifndef _cannon_h
16 #	include "cannon.h"
17 #endif
18 #ifndef _carrom_h
19 #	include "carrom.h"
20 #endif
21 #ifndef _game_h
22 #	include "game.h"
23 #endif
24 #ifndef _goal_h
25 #	include "goal.h"
26 #endif
27 #ifndef _hockey_h
28 #	include "hockey.h"
29 #endif
30 #ifndef _curling_h
31 #	include "curling.h"
32 #endif
33 #ifndef _pball_h
34 #	include "pball.h"
35 #endif
36 #ifndef _pool_h
37 #	include "pool.h"
38 #endif
39 #ifndef _pool8_h
40 #	include "pool8.h"
41 #endif
42 #ifndef _snooker_h
43 #	include "snooker.h"
44 #endif
45 #ifndef _pocket_h
46 #	include "pocket.h"
47 #endif
48 
49 
50 Real Billard::PresetA			= -25.0;
51 Real Billard::PresetHaft		= 5.0;
52 #ifndef __TURBOC__
53 Real Billard::SlowGranularity	= 0.25;
54 #else
55 Real Billard::SlowGranularity	= 0.5;
56 #endif
57 Real Billard::FrameOffset		= 20.0;
58 Real Billard::InnerCushion		=  4.0;
59 Real Billard::OuterCushion		=  8.0;
60 
61 
62 
63 Real Cannon::BallRadius		=   6.15 / 2;
64 Real Cannon::TableWidth		= 224.0;
65 Real Cannon::TableHeight	= 112.0;
66 
67 
68 Real Carrom::Offset           = 0.01;
69 Real Carrom::PresetA				= -400.0;
70 Real Carrom::PresetHaft			= 5.0;
71 Real Carrom::SlowGranularity	= 0.125;
72 Real Carrom::FrameOffset		= 14.0;
73 Real Carrom::ToPocket			=  2.0;
74 Real Carrom::Cushion				=  6.0;
75 Real Carrom::TableWidth			= 73.0;
76 Real Carrom::TableHeight		= 73.0;
77 Real Carrom::PocketRadius		=  6.20 / 2;
78 Real Carrom::StoneRadius		=  3.30 / 2;
79 Real Carrom::StrikerRadius		=  4.35 / 2;
80 Real Carrom::StoneWeight		=  4.;		//  4 g
81 Real Carrom::StrikerWeight		= 10.;		// 10 g
82 
83 Real Carrom::ChargeGranularity	= 0.05;	// seconds
84 Real Carrom::ChargeSpeed			= 400.;	// Charge per second
85 Real Carrom::MaxCharge				= 400.;
86 Real Carrom::ShootTime				= 0.1;	// seconds
87 Real Carrom::PocketFrame	= 2.0;
88 Real Carrom::PocketWidth	= 8.5;
89 
90 Real CarromDemo::PresetA			= 0.0;
91 Real CarromDemo::SlowGranularity	= 1.0;
92 
93 
94 
95 Real Game::PresetA			= -10.0;
96 Real Game::PresetHaft		= 10.0;
97 Real Game::SlowGranularity	= 0.1;
98 Real Game::NormalBallSize	= 1.2;
99 
100 #ifndef __TURBOC__
101 Real Game::ChargeGranularity	= 0.01;	// seconds
102 Real Game::ChargeSpeed			= 250.;	// Charge per second
103 Real Game::MaxCharge				= 300.;
104 Real Game::ShootTime				= 0.1;	// seconds
105 #else
106 Real Game::ChargeGranularity	= 0.05;	// seconds
107 Real Game::ChargeSpeed			= 250.;	// Charge per second
108 Real Game::MaxCharge				= 300.;
109 Real Game::ShootTime				= 0.2;	// seconds
110 #endif
111 
112 
113 Real Hockey::PresetA				= -100.0;
114 Real Hockey::PresetHaft			= 5.;
115 Real Hockey::SlowGranularity	= 0.125;
116 Real Hockey::FrameOffset		=   5.0;
117 Real Hockey::TableWidth			=  100.0;
118 Real Hockey::TableHeight		=   70.0;
119 Real Hockey::GoalSize			=  20.0;
120 Real Hockey::DiscRadius			=   4.0;
121 Real Hockey::HandRadius			=   6.0;
122 Real Hockey::DiscWeight			=  4.;		//  4 g
123 Real Hockey::HandWeight			= 10.;		// 10 g
124 Real Hockey::GoalFrame			= 0.9;
125 Real Hockey::GoalHeight			= 10.0;
126 Real TestHockey::PresetA			= -400.0;
127 Real TestHockey::SlowGranularity	= 0.01;
128 
129 
130 Real Curling::PresetA				= -50.0;
131 Real Curling::PresetHaft			= 5.;
132 Real Curling::SlowGranularity	= 0.125;
133 Real Curling::FrameOffset		=   0.0;
134 Real Curling::TableWidth			=  100.0;
135 Real Curling::TableHeight		=   40.0;
136 Real Curling::GoalSize			=  20.0;
137 Real Curling::Offset					=  0.5;
138 Real Curling::CurlRadius			=  2.0;
139 Real Curling::CurlWeight			=  4.;		//  4 g
140 Real Curling::KeeperFrame			= 0.9;
141 Real Curling::KeeperHeight			= 6.0;
142 
143 
144 Real Pool::Offset       = 0.05;
145 Real Pool::EdgeRadius	= 0.3;
146 Real Pool::EdgeAngle		= 50.;
147 Real Pool::MidAngle		= 30.;
148 Real Pool::TableWidth	= 200.0;
149 Real Pool::TableHeight	= 100.0;
150 Real Pool::PocketRadius	=   8.00 / 2.;
151 Real Pool::BallRadius	=   5.72 / 2.;
152 Real Pool::PocketFrame  = 2.0;
153 Real Pool::PocketHeight   = 10.0;
154 
155 Real Pool8Demo::PresetA			= 0.0;
156 Real Pool8Demo::SlowGranularity	= 1.0;
157 
158 Real PBallTop::WarpTime				= 0.02;	// Zeit zum Sprung auf Cursorposition
159 Real PBallTop::LockedQueueDelay	= 0.25;	// Nachlauf des gelock'ten Queue
160 
161 Real Snooker::TableWidth	= 350.0;
162 Real Snooker::TableHeight	= 175.0;
163 Real Snooker::BallRadius	=   5.24 / 2;
164 
165 Real SnookerDemo::PresetA			= 0.0;
166 Real SnookerDemo::SlowGranularity	= 1.0;
167 
168 
169 /* ========================================================================== */
170 /* ====                DO NOT EDIT BEYOND THIS LINE                      ==== */
171 /* ========================================================================== */
172 
173 typedef struct {
174 	const char	*name;
175 	Real			*val_addr;
176 } KonfiParam;
177 
178 static KonfiParam konfi[] = {
179 { "Billard::FrameOffset",  &Billard::FrameOffset },
180 { "Billard::InnerCushion",  &Billard::InnerCushion },
181 { "Billard::OuterCushion",  &Billard::OuterCushion },
182 { "Billard::PresetA",  &Billard::PresetA },
183 { "Billard::PresetHaft",  &Billard::PresetHaft },
184 { "Billard::SlowGranularity",  &Billard::SlowGranularity },
185 { "Cannon::BallRadius",  &Cannon::BallRadius },
186 { "Cannon::TableHeight",  &Cannon::TableHeight },
187 { "Cannon::TableWidth",  &Cannon::TableWidth },
188 { "Carrom::ChargeGranularity",  &Carrom::ChargeGranularity },
189 { "Carrom::ChargeSpeed",  &Carrom::ChargeSpeed },
190 { "Carrom::Cushion",  &Carrom::Cushion },
191 { "Carrom::FrameOffset",  &Carrom::FrameOffset },
192 { "Carrom::MaxCharge",  &Carrom::MaxCharge },
193 { "Carrom::Offset",  &Carrom::Offset },
194 { "Carrom::PocketFrame",  &Carrom::PocketFrame },
195 { "Carrom::PocketRadius",  &Carrom::PocketRadius },
196 { "Carrom::PocketWidth",  &Carrom::PocketWidth },
197 { "Carrom::PresetA",  &Carrom::PresetA },
198 { "Carrom::PresetHaft",  &Carrom::PresetHaft },
199 { "Carrom::ShootTime",  &Carrom::ShootTime },
200 { "Carrom::SlowGranularity",  &Carrom::SlowGranularity },
201 { "Carrom::StoneRadius",  &Carrom::StoneRadius },
202 { "Carrom::StoneWeight",  &Carrom::StoneWeight },
203 { "Carrom::StrikerRadius",  &Carrom::StrikerRadius },
204 { "Carrom::StrikerWeight",  &Carrom::StrikerWeight },
205 { "Carrom::TableHeight",  &Carrom::TableHeight },
206 { "Carrom::TableWidth",  &Carrom::TableWidth },
207 { "Carrom::ToPocket",  &Carrom::ToPocket },
208 { "CarromDemo::PresetA",  &CarromDemo::PresetA },
209 { "CarromDemo::SlowGranularity",  &CarromDemo::SlowGranularity },
210 { "Curling::CurlRadius",  &Curling::CurlRadius },
211 { "Curling::CurlWeight",  &Curling::CurlWeight },
212 { "Curling::FrameOffset",  &Curling::FrameOffset },
213 { "Curling::GoalSize",  &Curling::GoalSize },
214 { "Curling::KeeperFrame",  &Curling::KeeperFrame },
215 { "Curling::KeeperHeight",  &Curling::KeeperHeight },
216 { "Curling::Offset",  &Curling::Offset },
217 { "Curling::PresetA",  &Curling::PresetA },
218 { "Curling::PresetHaft",  &Curling::PresetHaft },
219 { "Curling::SlowGranularity",  &Curling::SlowGranularity },
220 { "Curling::TableHeight",  &Curling::TableHeight },
221 { "Curling::TableWidth",  &Curling::TableWidth },
222 { "Game::ChargeGranularity",  &Game::ChargeGranularity },
223 { "Game::ChargeSpeed",  &Game::ChargeSpeed },
224 { "Game::MaxCharge",  &Game::MaxCharge },
225 { "Game::NormalBallSize",  &Game::NormalBallSize },
226 { "Game::PresetA",  &Game::PresetA },
227 { "Game::PresetHaft",  &Game::PresetHaft },
228 { "Game::ShootTime",  &Game::ShootTime },
229 { "Game::SlowGranularity",  &Game::SlowGranularity },
230 { "Hockey::DiscRadius",  &Hockey::DiscRadius },
231 { "Hockey::DiscWeight",  &Hockey::DiscWeight },
232 { "Hockey::FrameOffset",  &Hockey::FrameOffset },
233 { "Hockey::GoalFrame",  &Hockey::GoalFrame },
234 { "Hockey::GoalHeight",  &Hockey::GoalHeight },
235 { "Hockey::GoalSize",  &Hockey::GoalSize },
236 { "Hockey::HandRadius",  &Hockey::HandRadius },
237 { "Hockey::HandWeight",  &Hockey::HandWeight },
238 { "Hockey::PresetA",  &Hockey::PresetA },
239 { "Hockey::PresetHaft",  &Hockey::PresetHaft },
240 { "Hockey::SlowGranularity",  &Hockey::SlowGranularity },
241 { "Hockey::TableHeight",  &Hockey::TableHeight },
242 { "Hockey::TableWidth",  &Hockey::TableWidth },
243 { "PBallTop::LockedQueueDelay",  &PBallTop::LockedQueueDelay },
244 { "PBallTop::WarpTime",  &PBallTop::WarpTime },
245 { "Pool8Demo::PresetA",  &Pool8Demo::PresetA },
246 { "Pool8Demo::SlowGranularity",  &Pool8Demo::SlowGranularity },
247 { "Pool::BallRadius",  &Pool::BallRadius },
248 { "Pool::EdgeAngle",  &Pool::EdgeAngle },
249 { "Pool::EdgeRadius",  &Pool::EdgeRadius },
250 { "Pool::MidAngle",  &Pool::MidAngle },
251 { "Pool::Offset",  &Pool::Offset },
252 { "Pool::PocketFrame",  &Pool::PocketFrame },
253 { "Pool::PocketHeight",  &Pool::PocketHeight },
254 { "Pool::PocketRadius",  &Pool::PocketRadius },
255 { "Pool::TableHeight",  &Pool::TableHeight },
256 { "Pool::TableWidth",  &Pool::TableWidth },
257 { "Snooker::BallRadius",  &Snooker::BallRadius },
258 { "Snooker::TableHeight",  &Snooker::TableHeight },
259 { "Snooker::TableWidth",  &Snooker::TableWidth },
260 { "SnookerDemo::PresetA",  &SnookerDemo::PresetA },
261 { "SnookerDemo::SlowGranularity",  &SnookerDemo::SlowGranularity },
262 { "TestHockey::PresetA",  &TestHockey::PresetA },
263 { "TestHockey::SlowGranularity",  &TestHockey::SlowGranularity },
264 { 0, 0 }			// end konfi
265 };
266 
show_defaults()267 void show_defaults() {
268 	for (unsigned i=0;i<sizeof(konfi)/sizeof(KonfiParam)-1U;i++) {
269 		printf( "%s = %g\n", konfi[i].name, (double)*konfi[i].val_addr );
270 	}
271 }
272 
load_konfi()273 void load_konfi() {
274 FILE		*fp;
275 char		buffer[80];
276 
277 	fp = fopen( PRESET_FILE, "r" );
278 	if (!fp) {
279 		sprintf(buffer,"%s/%s",DATA_DIRECTORY,PRESET_FILE);
280 		fp = fopen( buffer, "r" );
281 		if (!fp)		return;
282 	}
283 
284 	while( fgets( buffer, sizeof(buffer), fp )) {
285 		if (strstr(buffer,"::")) {
286 			char *ptr = buffer;
287 			while( (ptr)&&!isspace(*ptr)&&*ptr!='=' )		ptr++;
288 			if (!ptr)			break;
289 			*ptr++ = '\0';
290 			while( (ptr)&&isspace(*ptr)||*ptr=='=' )   	ptr++;
291 			if (!ptr)			break;
292 
293 			int i;
294 			for (i=sizeof(konfi)/sizeof(KonfiParam)-2;i>=0;i--) {
295 				if (!strcmp(buffer,konfi[i].name)) {
296 					(*konfi[i].val_addr) = Real(atof(ptr));
297 					break;
298 				}
299 			}
300 			if (i<0) {
301 				printf( "%s: unknown parameter in %s", PRESET_FILE, buffer );
302 			}
303 		}
304 	}
305 	fclose(fp);
306 }
307 
308 #ifdef DEBUG
309 
310 /* ========================================================================== */
311 
312 typedef struct {
313 	const char		*name;
314 	unsigned long	mask;
315 } DebugFlag;
316 
317 static DebugFlag dbg[] = {
318 { "AbortCalc",  AbortCalc },
319 { "AbortReCalc",  AbortReCalc },
320 { "AfterCollision",  AfterCollision },
321 { "BMover",  BMover },
322 { "BState",  BState },
323 { "BeforCollision",  BeforCollision },
324 { "CheckBoundary",  CheckBoundary },
325 { "CollCalc",  CollCalc },
326 { "ForceCalc",  ForceCalc },
327 { "GameState",  GameState },
328 { "Intro",  Intro },
329 { "Loops",  Loops },
330 { "Motion",  Motion },
331 { "MoveAll",  MoveAll },
332 { "ObjectInfo",  ObjectInfo },
333 { "PBallHit",  PBallHit },
334 { "PointerMove",  PointerMove },
335 { "ShowColors",  ShowColors },
336 { "ShowLight",  ShowLight },
337 { "ShowRings",  ShowRings },
338 { "ShowTurns",  ShowTurns },
339 { "StickLevel",  StickLevel },
340 { "Sync",  Sync },
341 { "TCTrace",  TCTrace },
342 { "UnixTrace",  UnixTrace },
343 { "XWallHit",  XWallHit },
344 { "YWallHit",  YWallHit },
345 { "__Moves",  __Moves },
346 { "__Rings",  __Rings },
347 { "__ShowAll",  __ShowAll },
348 { "xdb",  xdb },
349 { "xwd",  xwd },
350 { 0, 0 }		// end dbg
351 };
352 
show_flags()353 void show_flags() {
354 int	width = 0;
355 
356 	for (int i=0;i<sizeof(dbg)/sizeof(DebugFlag)-1;i++) {
357 		if (strlen(dbg[i].name)>width)		width = strlen(dbg[i].name);
358 	}
359 	width++;
360 	int cols = 79/width;
361 	int rows = (sizeof(dbg)/sizeof(DebugFlag)-1)/cols+1;
362 	for (int r=0;r<rows;r++) {
363 		for (int c=0;c<cols;c++) {
364 			int entry = rows*c+r;
365 			if (entry<sizeof(dbg)/sizeof(DebugFlag)-1)
366 								printf( "%-*s", width, dbg[entry].name );
367 		}
368 		printf( "\n" );
369 	}
370 }
371 
set_debug(const char * flag_name)372 int set_debug( const char *flag_name ) {
373 	for (int i=0;i<sizeof(dbg)/sizeof(DebugFlag)-1;i++) {
374 		if (!strcmp(flag_name,dbg[i].name)) {
375 			debug |= dbg[i].mask;
376 			return 0;
377 		}
378 	}
379 	return 1;
380 }
381 
382 
383 #endif
384