FOOT.CPP 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /******************************************************************************
  2. ******************************************************************************/
  3. //
  4. // Actua Soccer. (Token Main Routine) 1.9.94
  5. //
  6. // Programmed by Andy Findlay.
  7. //
  8. /******************************************************************************
  9. ******************************************************************************/
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. // Audio includes...
  13. #include "config.h" // Config file
  14. #include "basemem.h" //
  15. #include "sos.h" // SOS stuff
  16. #include "timer.h" // Timers for Audio
  17. #include "digi.h" // Digital Sound
  18. #include "midi.h" // MIDI Sound
  19. #include "audio.h" // SOS header
  20. #include "global.h"
  21. #include "3deng.h"
  22. #include "defines.h"
  23. #include "mouse.h"
  24. #include "front.h"
  25. #include "eurofrnt\euro_int.h"
  26. #include "mallocx.h"
  27. #ifdef ECTS
  28. extern void write_config_file();
  29. #endif
  30. struct goal_info
  31. {
  32. char used;
  33. int scorer;
  34. int time;
  35. };
  36. typedef struct
  37. {
  38. goal_info goal_data;
  39. } goal_table;
  40. goal_table goals[3*32]={0,0,0};
  41. extern void claim_key_int(void);
  42. extern void release_key_int(void);
  43. extern char practice;
  44. // NETWORK.C
  45. extern "C" void read_joystick(char j,int *x, int *y, int *sw);
  46. extern "C" void read_joy1(int *x, int *y, int *sw);
  47. extern "C" void read_joy2(int *x, int *y, int *sw);
  48. extern "C" void calibrate_joy(char j,unsigned short *x,unsigned short *y);
  49. extern "C" void calibrate_logpad(unsigned short *x,unsigned short *y);
  50. extern "C" void get_joy_dir1(int *x,int *y,int *f);
  51. extern "C" void get_joy_dir2(int *x,int *y,int *f);
  52. extern "C" void get_user_inputs();
  53. extern "C" void process_user_inputs();
  54. extern "C" volatile int Teams[MAX_NET_USERS],Players[MAX_NET_USERS];
  55. extern "C" volatile int net_quit;
  56. extern "C" volatile char paused;
  57. extern "C" volatile char pause_request;
  58. extern "C" volatile char keys[256];
  59. extern "C" volatile char key_togs[256];
  60. extern "C" unsigned char machine_no;
  61. extern "C" void NetTest(void);
  62. extern "C" void Network_Play_Ready(void);
  63. extern "C" void Quit_Network_Play(void);
  64. extern "C" void __far nethandler(void);
  65. extern "C" unsigned int NetworkHandle;
  66. extern "C" short wConsoleNode;
  67. extern "C" int network_on;
  68. extern "C" volatile int count;
  69. extern "C" volatile int tick;
  70. extern "C" volatile int ftick;
  71. extern "C" volatile int writeptr;
  72. extern "C" volatile int readptr;
  73. extern "C" int game_speed; // Currently declared in network.c
  74. extern "C" char old_mf;
  75. extern "C" char logpad_on;
  76. extern "C" char joystick1_on;
  77. extern "C" char joystick2_on;
  78. extern "C" unsigned short joy1_cnt_x,joy1_cnt_y;
  79. extern "C" unsigned short joy2_cnt_x,joy2_cnt_y;
  80. extern "C" int joy1_max_x,joy1_max_y,joy1_min_x,joy1_min_y;
  81. extern "C" int joy2_max_x,joy2_max_y,joy2_min_x,joy2_min_y;
  82. extern "C" char calibrated_1,calibrated_2;
  83. // Externed game functions...
  84. extern void add_team_user(short t,short c);
  85. extern void add_fixed_user(short p,short c);
  86. extern void init_keyboard();
  87. extern void init_users();
  88. extern void init_team();
  89. extern short conv_conts_back(char c);
  90. extern setup_info setup;
  91. extern short rand_seed;
  92. extern int match(int argc, char **argv);
  93. match_data match_info;
  94. extern team_info game_data[];
  95. extern int players;
  96. extern int avg1_rate,avg1_power,avg1_bcontrol,avg1_flair,
  97. avg1_vision,avg1_accuracy,avg1_fitness,avg1_disc;
  98. extern int avg2_rate,avg2_power,avg2_bcontrol,avg2_flair,
  99. avg2_vision,avg2_accuracy,avg2_fitness,avg2_disc;
  100. extern char audio_version;
  101. extern char need_result;
  102. extern short injury_time;
  103. extern "C" int num_of_users; // Currently in network.c
  104. extern char say_names;
  105. extern "C" volatile char net_half;
  106. extern "C" void foot_init_net();
  107. extern "C" void foot_uninit_net();
  108. extern int performance;
  109. int w95;
  110. short no_front_users;
  111. /******************************************************************************
  112. *****************************************************************************/
  113. void mem_test()
  114. {
  115. int i=get_mem_info();
  116. printf("Free memory = %d\n",i);
  117. setup.M8=(i>=MEM8);
  118. if (setup.verbose)
  119. if (setup.M8)
  120. puts("Initialising 8 meg game");
  121. else
  122. {
  123. puts("Initialising 4 meg game");
  124. printf("Need to free %d more bytes to run 8 meg version\n",MEM8-i);
  125. }
  126. }
  127. /******************************************************************************
  128. *****************************************************************************/
  129. int go_audio()
  130. {
  131. // Initialise Audio Config...
  132. if(ReadConfigFile())
  133. {
  134. printf("Error! Cannot read Config File.\n");
  135. return(EXIT_FAILURE);
  136. }
  137. if(InitialiseDIGI(22050,IDF_VERBOSE)) // Initialise Digital Sound Drivers
  138. return(EXIT_FAILURE);
  139. return(FALSE);
  140. }
  141. /******************************************************************************
  142. ******************************************************************************/
  143. // Process command line options...
  144. void get_command_line(int argc, char **argv)
  145. {
  146. short opt,id;
  147. for (int i=1; i<argc; i++)
  148. {
  149. opt=-1;
  150. id=100;
  151. // Look for switch!
  152. if (!strcmp(argv[i],"-i"))
  153. // Inputs...
  154. {
  155. if (!strcmp(argv[i+1],"j1"))
  156. opt=JOY1_CTRL;
  157. if (!strcmp(argv[i+1],"j2"))
  158. opt=JOY2_CTRL;
  159. if (!strcmp(argv[i+1],"k1"))
  160. opt=KEY1_CTRL;
  161. if (!strcmp(argv[i+1],"k2"))
  162. opt=KEY2_CTRL;
  163. if (!strcmp(argv[i+1],"m"))
  164. opt=MOUSE_CTRL;
  165. if (!strcmp(argv[i+1],"lp"))
  166. opt=LOGPAD_CTRL;
  167. if (!strcmp(argv[i+1],"g1"))
  168. opt=GRAV1_CTRL;
  169. if (!strcmp(argv[i+1],"g2"))
  170. opt=GRAV2_CTRL;
  171. if (!strcmp(argv[i+1],"n"))
  172. opt=NET_CTRL;
  173. if (opt>0)
  174. // Look for user id!
  175. {
  176. if (!strcmp(argv[i+2],"a"))
  177. id=TEAM_A;
  178. else
  179. if (!strcmp(argv[i+2],"b"))
  180. id=TEAM_B;
  181. else
  182. {
  183. id=atoi(argv[i+2]);
  184. if ((id<1) || (id>players) || (id==1) || (id==12))
  185. id=100;
  186. }
  187. i+=2;
  188. }
  189. if (id==100)
  190. i=argc;
  191. else
  192. {
  193. if (id<0)
  194. {
  195. if (id==-1)
  196. game_data[setup.team_a].player_control+=1<<no_front_users;
  197. else
  198. game_data[setup.team_b].player_control+=1<<no_front_users;
  199. match_info.control_methods[no_front_users++]=conv_conts_back(opt);
  200. }
  201. else
  202. add_fixed_user(id,opt);
  203. #ifndef FRONT_END
  204. if (opt==JOY1_CTRL)
  205. joystick1_on=TRUE;
  206. if (opt==JOY2_CTRL)
  207. joystick2_on=TRUE;
  208. if (opt==LOGPAD_CTRL)
  209. logpad_on=TRUE;
  210. #endif
  211. }
  212. }
  213. if (!strcmp(argv[i],"-s"))
  214. // Stats...
  215. {
  216. if (!strcmp(argv[i+1],"ds"))
  217. opt=0;
  218. if (!strcmp(argv[i+1],"vi"))
  219. opt=1;
  220. if (!strcmp(argv[i+1],"bc"))
  221. opt=2;
  222. if (!strcmp(argv[i+1],"sp"))
  223. opt=3;
  224. if (!strcmp(argv[i+1],"fl"))
  225. opt=4;
  226. if (!strcmp(argv[i+1],"ac"))
  227. opt=5;
  228. if (!strcmp(argv[i+1],"pp"))
  229. opt=6;
  230. if (!strcmp(argv[i+1],"st"))
  231. opt=7;
  232. if (opt>=0)
  233. {
  234. if (!strcmp(argv[i+2],"a"))
  235. {
  236. int avg=atoi(argv[i+3]);
  237. if (avg>0 && avg<129)
  238. {
  239. id=0;
  240. switch(opt)
  241. {
  242. case(0):
  243. avg1_disc=avg;
  244. break;
  245. case(1):
  246. avg1_vision=avg;
  247. break;
  248. case(2):
  249. avg1_bcontrol=avg;
  250. break;
  251. case(3):
  252. avg1_rate=avg;
  253. break;
  254. case(4):
  255. avg1_flair=avg;
  256. break;
  257. case(5):
  258. avg1_accuracy=avg;
  259. break;
  260. case(6):
  261. avg1_power=avg;
  262. break;
  263. case(7):
  264. avg1_fitness=avg;
  265. break;
  266. }
  267. }
  268. }
  269. else
  270. {
  271. if (!strcmp(argv[i+2],"b"))
  272. {
  273. int avg=atoi(argv[i+3]);
  274. if (avg>0 && avg<129)
  275. {
  276. id=0;
  277. switch(opt)
  278. {
  279. case(0):
  280. avg2_disc=avg;
  281. break;
  282. case(1):
  283. avg2_vision=avg;
  284. break;
  285. case(2):
  286. avg2_bcontrol=avg;
  287. break;
  288. case(3):
  289. avg2_rate=avg;
  290. break;
  291. case(4):
  292. avg2_flair=avg;
  293. break;
  294. case(5):
  295. avg2_accuracy=avg;
  296. break;
  297. case(6):
  298. avg2_power=avg;
  299. break;
  300. case(7):
  301. avg2_fitness=avg;
  302. break;
  303. }
  304. }
  305. }
  306. }
  307. }
  308. else
  309. id=100;
  310. if (id==100)
  311. i=argc;
  312. else
  313. i+=3;
  314. }
  315. if (!strcmp(argv[i],"-r"))
  316. // Random seed...
  317. {
  318. #ifdef ECTS
  319. machine_no=atoi(argv[i+1]);
  320. #else
  321. rand_seed=atoi(argv[i+1]);
  322. #endif
  323. }
  324. if (!strcmp(argv[i],"-a"))
  325. // Choose team...
  326. {
  327. setup.team_a=atoi(argv[i+1]);
  328. }
  329. if (!strcmp(argv[i],"-b"))
  330. // Choose team...
  331. {
  332. setup.team_b=atoi(argv[i+1]);
  333. setup.team_b_kit=atoi(argv[i+1]);
  334. }
  335. }
  336. }
  337. /*
  338. void GOAL_SCORED(int t,int s,int tm)
  339. {
  340. }
  341. */
  342. /******************************************************************************
  343. *****************************************************************************/
  344. void SubstituePlayers(int a,int b,int c)
  345. {
  346. }
  347. /******************************************************************************
  348. *****************************************************************************/
  349. /* Front End Emulator */
  350. extern char var_start,var_end;
  351. extern void init_joys();
  352. void test_w95()
  353. {
  354. //
  355. union REGS regs;
  356. struct SREGS sregs;
  357. memset(&sregs,0,sizeof(sregs)); //clr sregs
  358. regs.w.ax=0x1600;
  359. int386x(0x2F,&regs,&regs,&sregs);
  360. w95=regs.w.ax & 0xff;
  361. if (w95==3 || w95==4)
  362. {
  363. //running in windows 95!!!
  364. if (setup.verbose)
  365. printf("Running windows 95 version\n");
  366. w95=TRUE;
  367. }
  368. else
  369. {
  370. if (setup.verbose)
  371. printf("Running DOS version\n");
  372. w95=FALSE;
  373. }
  374. }
  375. int main(int argc, char **argv)
  376. {
  377. w95=0; // Windows flag!
  378. test_w95();
  379. no_front_users=0;
  380. num_of_users=0;
  381. init_joys();
  382. performance=31; // Pentium speed!
  383. setup.team_a=36;
  384. setup.team_b=1;
  385. setup.team_b_kit=1;
  386. setup.stadium=setup.team_b;
  387. setup.start_res=0;
  388. setup.vidi_type=0; // 0=norm, 1=filtered
  389. setup.verbose=0;
  390. setup.screen_size=0;
  391. setup.detail.stadia=1; // 0=simple,1=complex
  392. setup.detail.pitch=2; // 0=simple,1=lo,2=hi
  393. setup.detail.sky=1; // 0=off,1=on
  394. setup.detail.players=1; // 0=simple,1=full
  395. setup.detail.lines=1; // 0=simple,1=full
  396. setup.detail.shadows=1; // 0=simple,1=full
  397. #ifdef ONE_MACHINE
  398. // game_data[setup.team_a].player_control=1;
  399. // game_data[setup.team_b].player_control=2;
  400. // match_info.control_methods[0]=2;
  401. // match_info.control_methods[1]=0;
  402. #else
  403. game_data[setup.team_a].player_control=0;
  404. game_data[setup.team_b].player_control=0;
  405. #endif
  406. #ifdef ECTS
  407. setup.M8=1;
  408. #else
  409. mem_test();
  410. #endif
  411. #ifdef MEG4
  412. setup.M8=0;
  413. #endif
  414. // setup.M8=0;
  415. // Setup Subs...
  416. for (int i=11; i<15; i++)
  417. {
  418. game_data[setup.team_a].players[i].flags=1;
  419. game_data[setup.team_b].players[i].flags=1;
  420. }
  421. InitialiseTimer(); // Initialise timers for sound drivers
  422. EUROmatch_info.camera=0;
  423. EUROmatch_info.audio=FALSE;
  424. EUROmatch_info.timeit=FALSE;
  425. EUROmatch_info.offside=TRUE;
  426. EUROmatch_info.bookings=TRUE;
  427. EUROmatch_info.freekicks=TRUE;
  428. EUROmatch_info.substitutes=TRUE;
  429. EUROmatch_info.time=3;
  430. EUROmatch_info.tac_1=0;
  431. EUROmatch_info.tac_2=0;
  432. match_info.CompetitionType=2;
  433. // match_info.CompetitionType=PRACTICE;
  434. // match_info.CompetitionType=PENALTIES;
  435. EUROmatch_info.crowd=0x1fff; // Crowd noise level!
  436. EUROmatch_info.pitch=0x7fff; // Pitch noise level!
  437. EUROmatch_info.commentary=0x7fff; // Commentary level!
  438. EUROmatch_info.master=0x7fff; // Master noise level!
  439. EUROmatch_info.referee_vision=120;
  440. EUROmatch_info.referee_discipline=80;
  441. EUROmatch_info.rand=3523;
  442. match_info.GameType=0; // 0 Arcade 1 Simulation...
  443. match_info.referee=0;
  444. EUROmatch_info.wind=0;
  445. // EUROmatch_info.tga_enable=TRUE;
  446. net_half=1; // Network game time...
  447. say_names=TRUE;
  448. audio_version=EUROmatch_info.audio;
  449. if (audio_version)
  450. {
  451. if (go_audio())
  452. {
  453. UnInitialiseTimer();
  454. return(FALSE);
  455. }
  456. }
  457. network_on=0;
  458. // Timer stuff...
  459. ftick=0;
  460. tick=0;
  461. count=0;
  462. game_speed=REAL_SPEED;
  463. readptr=writeptr=0;
  464. AddTimer(TIMER_SPEED,nethandler,NetworkHandle);
  465. injury_time=0;
  466. claim_key_int();
  467. init_users();
  468. init_team();
  469. machine_no=1;
  470. get_command_line(argc,argv);
  471. InitMouse();
  472. init_keyboard();
  473. if (logpad_on)
  474. calibrate_logpad(&joy1_cnt_x,&joy1_cnt_y);
  475. if (joystick1_on)
  476. {
  477. calibrate_joy(0,&joy1_cnt_x,&joy1_cnt_y);
  478. calibrated_1=TRUE;
  479. #ifdef ECTS
  480. write_config_file();
  481. #endif
  482. }
  483. if (joystick2_on)
  484. {
  485. calibrate_joy(1,&joy2_cnt_x,&joy2_cnt_y);
  486. calibrated_2=TRUE;
  487. #ifdef ECTS
  488. write_config_file();
  489. #endif
  490. }
  491. #ifndef NET_GAME
  492. old_mf=TRUE;
  493. #else
  494. old_mf=FALSE;
  495. #endif
  496. #ifdef NET_GAME
  497. foot_init_net();
  498. #endif
  499. /**** Call Game ****/
  500. match(argc,argv);
  501. #ifdef NET_GAME
  502. foot_uninit_net();
  503. #endif
  504. RemoveTimer(NetworkHandle);
  505. if (audio_version)
  506. {
  507. UnInitialiseDIGI(); // Uninitialise SOS
  508. }
  509. UnInitialiseTimer();
  510. release_key_int();
  511. return(0);
  512. }