home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / chaos5_3src.lha / chaos / src / Chaos.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-20  |  13.8 KB  |  534 lines

  1. /*  Chaos:            The Chess HAppening Organisation System    V5.3
  2.     Copyright (C)   1993    Jochen Wiedmann
  3.  
  4.     This program is free software; you can redistribute it and/or modify
  5.     it under the terms of the GNU General Public License as published by
  6.     the Free Software Foundation; either version 2 of the License, or
  7.     (at your option) any later version.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU General Public License
  15.     along with this program; if not, write to the Free Software
  16.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.  
  19.     $RCSfile: Chaos.h,v $
  20.     $Revision: 3.3 $
  21.     $Date: 1994/11/19 19:32:01 $
  22.  
  23.     This is the include-file of the program. It defines the constants,
  24.     structures and prototypes.
  25.  
  26.     Computer:    Amiga 1200            Compiler:    Dice 2.07.54 (3.0)
  27.  
  28.     Author:    Jochen Wiedmann
  29.         Am Eisteich 9
  30.       72555 Metzingen
  31.         Tel. 07123 / 14881
  32.         Internet: wiedmann@mailserv.zdv.uni-tuebingen.de
  33. */
  34.  
  35.  
  36. #ifndef CHAOS_H
  37. #define CHAOS_H
  38.  
  39. #ifndef CHAOS_CAT_CATALOG_H
  40. #include "Chaos_Cat.h"
  41. #endif
  42.  
  43. #ifdef AMIGA
  44. #ifndef EXEC_LISTS_H
  45. #include <exec/lists.h>
  46. #endif
  47. #ifndef EXEC_MEMORY_H
  48. #include <exec/memory.h>
  49. #endif
  50. #ifndef EXEC_INTERRUPTS_H
  51. #include <exec/interrupts.h>
  52. #endif
  53. #ifndef DOS_DOS_H
  54. #include <dos/dos.h>
  55. #endif
  56. #ifndef DOS_EXALL_H
  57. #include <dos/exall.h>
  58. #endif
  59. #ifndef INTUITION_INTUITION_H
  60. #include <intuition/intuition.h>
  61. #endif
  62. #ifndef LIBRARIES_IFFPARSE_H
  63. #include <libraries/iffparse.h>
  64. #endif
  65. #ifndef MUI_H
  66. #include <libraries/mui.h>
  67. #endif
  68. #ifndef CLIB_EXEC_PROTOS_H
  69. #include <clib/exec_protos.h>
  70. #endif
  71. #ifndef CLIB_DOS_PROTOS_H
  72. #include <clib/dos_protos.h>
  73. #endif
  74. #ifndef CLIB_INTUITION_PROTOS_H
  75. #include <clib/intuition_protos.h>
  76. #endif
  77. #ifndef CLIB_MUIMASTER_PROTOS_H
  78. #include <clib/muimaster_protos.h>
  79. #endif
  80. #ifndef CLIB_ALIB_PROTOS_H
  81. #include <clib/alib_protos.h>
  82. #endif
  83. #ifndef CLIB_UTILITY_PROTOS_H
  84. #include <clib/utility_protos.h>
  85. #endif
  86. #ifndef CLIB_IFFPARSE_PROTOS_H
  87. #include <clib/iffparse_protos.h>
  88. #endif
  89.  
  90. #ifdef AZTEC_C
  91. #ifndef PRAGMAS_EXEC_LIB_H
  92. #include <pragmas/exec_lib.h>
  93. #endif
  94. #ifndef PRAGMAS_DOS_LIB_H
  95. #include <pragmas/dos_lib.h>
  96. #endif
  97. #ifndef PRAGMAS_INTUITION_LIB_H
  98. #include <pragmas/intuition_lib.h>
  99. #endif
  100. #ifndef PRAGMAS_MUIMASTER_LIB_H
  101. #include <pragmas/muimaster_lib.h>
  102. #endif
  103. #ifndef PRAGMAS_UTILITY_LIB_H
  104. #include <pragmas/utility_lib.h>
  105. #endif
  106. #ifndef PRAGMAS_IFFPARSE_LIB_H
  107. #include <pragmas/iffparse_lib.h>
  108. #endif
  109. #endif    /*  AZTEC_C    */
  110.  
  111. #if defined(_DCC)  ||  defined(__SASC)  ||  defined(__MAXON__)
  112. #ifndef PRAGMAS_EXEC_PRAGMAS_H
  113. #include <pragmas/exec_pragmas.h>
  114. #endif
  115. #ifndef PRAGMAS_DOS_PRAGMAS_H
  116. #include <pragmas/dos_pragmas.h>
  117. #endif
  118. #ifndef PRAGMAS_INTUITION_PRAGMAS_H
  119. #include <pragmas/intuition_pragmas.h>
  120. #endif
  121. #ifndef PRAGMAS_MUIMASTER_PRAGMAS_H
  122. #include <pragmas/muimaster_pragmas.h>
  123. #endif
  124. #ifndef PRAGMAS_UTILITY_PRAGMAS_H
  125. #include <pragmas/utility_pragmas.h>
  126. #endif
  127. #ifndef PRAGMAS_IFFPARSE_PRAGMAS_H
  128. #include <pragmas/iffparse_pragmas.h>
  129. #endif
  130. #endif    /*  _DCC  ||  __SASC  ||  __MAXON__  */
  131.  
  132. #ifdef __GNUC__
  133. #ifndef _INLINE_EXEC_H
  134. #include <inline/exec.h>
  135. #endif
  136. #ifndef _INLINE_DOS_H
  137. #include <inline/dos.h>
  138. #endif
  139. #ifndef _INLINE_INTUITION_H
  140. #include <inline/intuition.h>
  141. #endif
  142. #ifndef _INLINE_MUIMASTER_H
  143. #include <inline/muimaster.h>
  144. #endif
  145. #ifndef _INLINE_UTILITY_H
  146. #include <inline/utility.h>
  147. #endif
  148. #ifndef _INLINE_IFFPARSE_H
  149. #include <inline/iffparse.h>
  150. #endif
  151. #endif    /*  !__GNUC__            */
  152.  
  153. #include <stdlib.h>
  154. #include <string.h>
  155. #include <stdio.h>
  156. #include <time.h>
  157.  
  158. #else    /*  !AMIGA            */
  159. #include <stdio.h>
  160. #include <NonAmiga.h>
  161. #endif    /*  AMIGA            */
  162.  
  163.  
  164.  
  165. #define TRNFILENAME_LEN 512
  166. #define TRNNAME_LEN 60
  167.  
  168. #define TNMODEB_SWISS_PAIRING        0
  169. #define TNMODEB_ROUND_ROBIN        1
  170. #define TNMODEB_BUCHHOLZ        2
  171. #define TNMODEB_EXT_BUCHHOLZ        3
  172. #define TNMODEB_SONNEBORN_BERGER    4
  173. #define TNMODEB_SHIFT_SYSTEM        5
  174. #define TNMODEF_SWISS_PAIRING (1 << TNMODEB_SWISS_PAIRING)
  175. #define TNMODEF_ROUND_ROBIN (1 << TNMODEB_ROUND_ROBIN)
  176. #define TNMODEF_BUCHHOLZ (1 << TNMODEB_BUCHHOLZ)
  177. #define TNMODEF_EXT_BUCHHOLZ (1 << TNMODEB_EXT_BUCHHOLZ)
  178. #define TNMODEF_SONNEBORN_BERGER (1 << TNMODEB_SONNEBORN_BERGER)
  179. #define TNMODE_TABMASK (TNMODEF_BUCHHOLZ|TNMODEF_EXT_BUCHHOLZ| \
  180.             TNMODEF_SONNEBORN_BERGER)
  181. #define TNMODEF_SHIFT_SYSTEM (1 << TNMODEB_SHIFT_SYSTEM)
  182. #define SwissPairingTournament (TrnMode & TNMODEF_SWISS_PAIRING)
  183. #define RoundRobinTournament (TrnMode & TNMODEF_ROUND_ROBIN)
  184.  
  185.  
  186. /*
  187.     The struct Player holds all data of one participant.
  188. */
  189. #define NAMELEN 30
  190. #define BIRTHDAYLEN 10
  191. #define PHONENRLEN 20
  192. #define DWZLEN 10
  193. struct Player
  194.   { struct Node Tn_Node;        /*    This is used to build the alpha-
  195.                     betically sorted list of players.   */
  196.  
  197.     struct Player *LT_Succ;        /*    An internal list is builded when    */
  198.     struct Player *LT_Pred;        /*    pairing the games. These fields     */
  199.                     /*    are used for it.            */
  200.  
  201.     struct Player *RankNext;        /*    Next in list of internal rankings   */
  202.     struct Player *Opponent;        /*    Used for pairings            */
  203.     struct Player *Helpptr;        /*    Used for different things        */
  204.     struct Game *First_Game;        /*    List of games                */
  205.     int Flags;                /*    See below                */
  206.     short Nr;                /*    Used for pairings            */
  207.     short GFlags, BoardNr;        /*    Used for pairings            */
  208.     short Points, Buchholz;        /*    Points, Buchholzpoints and extended */
  209.     long  ExtBuchholz;            /*    Buchholzpoints                */
  210.     short HowMuchWhite;         /*    < 0 = Black; > 0 = White        */
  211.     short HowMuchWhiteLast;        /*    < 0 = Black; > 0 = White        */
  212.     short ELO;                /*    International ELO number        */
  213.     char DWZ[DWZLEN+1];         /*    German rating number            */
  214.     char Name[NAMELEN+1];        /*    Name and prename            */
  215.     char Street[NAMELEN+1];        /*    address                 */
  216.     char Village[NAMELEN+1];
  217.     char PhoneNr[PHONENRLEN+1];
  218.     char ChessClub[NAMELEN+1];        /*    Schachclub des Teilnehmers        */
  219.     char BirthDay[BIRTHDAYLEN+1];   /*    Geburtsdatum des Teilnehmers        */
  220.   };
  221. /*
  222.     Possible Flags in the player structure
  223. */
  224. #define TNFLAGSB_SENIOR 31
  225. #define TNFLAGSB_JUNIOR 30
  226. #define TNFLAGSB_WOMAN    29
  227. #define TNFLAGSB_JUNIORA 28
  228. #define TNFLAGSB_JUNIORB 27
  229. #define TNFLAGSB_JUNIORC 26
  230. #define TNFLAGSB_JUNIORD 25
  231. #define TNFLAGSB_JUNIORE 24
  232. #define TNFLAGSB_WITHDRAWN 0    /*  Player has withdrawn            */
  233. #define TNFLAGSB_HADFREE 1    /*  Player had a free round            */
  234. #define TNFLAGSB_NOTDOWN 2    /*  Internally used for pairings        */
  235. #define TNFLAGSB_SELECTED 3    /*  Internally used for player selections   */
  236. #define TNFLAGSF_SENIOR (1 << TNFLAGSB_SENIOR)
  237. #define TNFLAGSF_JUNIOR (1 << TNFLAGSB_JUNIOR)
  238. #define TNFLAGSF_WOMAN    (1 << TNFLAGSB_WOMAN)
  239. #define TNFLAGSF_JUNIORA (1 << TNFLAGSB_JUNIORA)
  240. #define TNFLAGSF_JUNIORB (1 << TNFLAGSB_JUNIORB)
  241. #define TNFLAGSF_JUNIORC (1 << TNFLAGSB_JUNIORC)
  242. #define TNFLAGSF_JUNIORD (1 << TNFLAGSB_JUNIORD)
  243. #define TNFLAGSF_JUNIORE (1 << TNFLAGSB_JUNIORE)
  244. #define TNFLAGSF_WITHDRAWN (1 << TNFLAGSB_WITHDRAWN)
  245. #define TNFLAGSF_HADFREE (1 << TNFLAGSB_HADFREE)
  246. #define TNFLAGSF_NOTDOWN (1 << TNFLAGSB_NOTDOWN)
  247. #define TNFLAGSF_SELECTED (1 << TNFLAGSB_SELECTED)
  248.  
  249.  
  250.  
  251. /*
  252.     The Game structure holds all data of one game. The games of one
  253.     participant build a linked list. Each game is therefore represented
  254.     by two game structures: One in the white players list and one in the
  255.     black players list.
  256. */
  257. struct Game
  258.   { struct Game *Next;        /*  Pointer to next game            */
  259.     struct Player *Opponent;    /*  Pointer to Opponent             */
  260.     short BoardNr;        /*  Board number                */
  261.     short Result;        /*  Result (-1 = Result is missing)         */
  262.     short Flags;        /*  See below                    */
  263.   };
  264. /*
  265.     Possible flags in the game structure
  266. */
  267. #define GMFLAGSB_NOFIGHT    0
  268. #define GMFLAGSB_POINTFORFREE    1
  269. #define GMFLAGSB_WITHDRAWN    2
  270. #define GMFLAGSB_WHITE        3
  271. #define GMFLAGSF_NOFIGHT (1 << GMFLAGSB_NOFIGHT)
  272. #define GMFLAGSF_POINTFORFREE (1 << GMFLAGSB_POINTFORFREE)
  273. #define GMFLAGSF_WITHDRAWN (1 << GMFLAGSB_WITHDRAWN)
  274. #define GMFLAGSF_WHITE (1 << GMFLAGSB_WHITE)
  275.  
  276.  
  277.  
  278.  
  279. /*
  280.     Possible output devices
  281. */
  282. #define DEVICE_Screen        0
  283. #define DEVICE_PrinterDraft 1
  284. #define DEVICE_PrinterLQ    2
  285. #define DEVICE_FileAscii    3
  286. #define DEVICE_FileTeX        4
  287.  
  288.  
  289.  
  290.  
  291. /*
  292.     The structure GameNode is used to build a list of all games of one round.
  293. */
  294. struct GameNode
  295.   { struct MinNode gn_Node;
  296.     struct Player *White, *Black;
  297.     short BoardNr;
  298.     short Result, Flags;  /*  of White    */
  299.     char Text[80];
  300.   };
  301.  
  302.  
  303.  
  304. /*
  305.     Prototypes of main.c
  306. */
  307. extern struct Library *MUIMasterBase;
  308. extern struct Library *SysBase;
  309. extern struct Library *DOSBase;
  310. extern struct Library *IntuitionBase;
  311. extern struct Library *UtilityBase;
  312. extern struct Library *IconBase;
  313. extern char *AVERSION;
  314. extern char *PVERSION;
  315. extern char *MVERSION;
  316. extern char *VERVERSION;
  317. extern struct List PlayerList;
  318. extern int IsSaved;
  319. extern int OutputDevice;
  320. extern char TrnFileName [TRNFILENAME_LEN+1];
  321. extern int AllowErrorMessage;
  322. extern int NumRounds;
  323. extern struct Player *RankingFirst;
  324. extern int NumPlayers;
  325. extern int NumGamesMissing;
  326. extern char TrnName [TRNNAME_LEN+1];
  327. extern int DefaultWinnerPoints;
  328. extern int DefaultDrawPoints;
  329. extern int WinnerPoints;
  330. extern int DrawPoints;
  331. extern int TrnMode;
  332.  
  333.  
  334. /*
  335.     Prototypes of MaiAmi.c
  336. */
  337. #ifdef AMIGA
  338. extern int MakeIcons;
  339. extern char IconName[TRNFILENAME_LEN+1];
  340. extern char ProgName[TRNFILENAME_LEN+1];
  341. extern APTR App;
  342. extern APTR MainWnd;
  343. #endif
  344.  
  345. extern void OpenLibs(void);
  346. extern void InitRandom(void);
  347. extern void DoStartup(int argc, char *argv[]);
  348. extern void InitMainWnd(void);
  349. extern void ProcessMainWnd(void);
  350. extern void TerminateMainWnd(void);
  351. extern void CloseLibs(void);
  352. extern void ShowError(char *, ...);
  353. extern void MemError(void);
  354. #ifdef AMIGA
  355. extern void MUIError(char *);
  356. #endif    /*  AMIGA   */
  357.  
  358.  
  359. /*
  360.     Prototypes of Memory.c
  361. */
  362. extern void *GetMem(void **, ULONG);
  363. extern void PutMem(void *);
  364. extern void PutMemList(void **);
  365. extern void PutMemAll(void);
  366. extern char *GetStringMem(void **, char *);
  367. extern void MoveMemList(void **, void **);
  368.  
  369.  
  370. /*
  371.     Prototypes of Project.c
  372. */
  373. extern void *TrnMem;
  374. extern void DeleteTournament(char *);
  375. extern int TestSaved(void);
  376. extern int LoadTournament(char *, void **, struct List *);
  377. extern int SaveTournament(char *);
  378. extern void NewTournament(void);
  379. extern void About(void);
  380.  
  381.  
  382. /*
  383.     Prototypes of ProjectAmi.c
  384. */
  385. extern char *FileRequest(char *, char *, char *, int);
  386. extern int AskSave(void);
  387. extern void CreateIcon(char *);
  388. extern void TerminateTrnWnd(void);
  389. extern int InitTrnWnd(char *, int, int);
  390. extern int ProcessTrnWnd(char *, int *, int *);
  391.  
  392.  
  393. /*
  394.     Prototypes of Players.c
  395. */
  396. extern int CheckPlayerValid(struct Player *, int);
  397. extern int AddPlayer(struct Player *);
  398. extern void AddPlayers(void);
  399. extern void ImportPlayers(void);
  400. extern void ModifyPlayer(struct Player *, struct Player *);
  401. extern int ModifyOnePlayer(struct Player *, int);
  402. extern void ModifyPlayers(void);
  403. extern void DeletePlayer(struct Player *);
  404. extern void DeletePlayers(void);
  405.  
  406.  
  407. /*
  408.     Prototypes of PlayersAmi.c
  409. */
  410. extern int AskContinue(char *, ...);
  411. extern int AskExtContinue(char *, char *, ...);
  412. extern int InitPlrWnd(char *);
  413. extern int ProcessPlrWnd(struct Player *, int);
  414. extern void TerminatePlrWnd(void);
  415. extern int ProcessPlrSelWnd(char *, char *, char, int, struct List *);
  416.  
  417.  
  418. /*
  419.     Prototypes of Pairings.c
  420. */
  421. extern struct Game *GameAddress(struct Player *, int);
  422. extern void CreateRankings(void);
  423. extern int GamePossible(struct Player *, struct Player *);
  424. extern int DoPairings(int, int, int);
  425.  
  426.  
  427. /*
  428.     Prototypes of PairingsAmi.c
  429. */
  430. extern int InitSetGames(void);
  431. extern int SetPlayer(struct Player *, int, int);
  432. extern int GetSettings(int);
  433.  
  434.  
  435. /*
  436.     Prototypes of Rounds.c
  437. */
  438. extern void FormatGame(struct GameNode *, int);
  439. extern struct MinList *GetRound(void **, int, int, int);
  440. extern void EnterResult(struct GameNode *, int);
  441. extern void EnterResults(int);
  442.  
  443.  
  444. /*
  445.     Prototypes of RoundsAmi.c
  446. */
  447. extern int GetRoundNr(void);
  448. extern void TerminateRsltWnd(void);
  449. extern int InitRsltWnd(char *, struct MinList *);
  450. extern int ProcessRsltWnd(struct MinList *);
  451.  
  452.  
  453. /*
  454.     Prototypes of Out.c
  455. */
  456. extern int tdwz(struct Player *);
  457. extern void PointsToA(char *, long);
  458. extern int longlprint(char *);
  459. extern int lprint(char *);
  460. extern void OutPlayerList(char *, int, int);
  461. extern void OutInternalRankings(char *, int);
  462. extern void OutRound(char *, int, int);
  463. extern void OutTable(char *, int, int, int);
  464. extern void OutTableProgress(char *, int, int);
  465. extern struct Player *MakeTable(int);
  466. extern void OutCrossTable(char *, int);
  467. extern void OutPlayerCards(char *, int);
  468.  
  469.  
  470. /*
  471.     Prototypes for OutAmi.c
  472. */
  473. extern int CenterText(int);
  474. extern int AskForBirthday(struct Player *);
  475. extern int InitOutput(char *, char *, char *, char *, char *, int, int, int);
  476. extern void ProcessOutput(void);
  477. extern void TerminateOutput(void);
  478.  
  479.  
  480. /*
  481.     Prototypes for OutDWZ.c
  482. */
  483. extern int atotm(char *, struct tm *);
  484. extern void OutDWZReport(char *, int);
  485.  
  486.  
  487. /*
  488.     Debugging stuff
  489. */
  490. #ifdef DEBUG
  491. #define strlen dbg_strlen
  492. extern size_t dbg_strlen(const char *);
  493. #define strcpy dbg_strcpy
  494. extern char *strcpy(char *, const char *);
  495. #define sprintf dbg_sprintf
  496. extern int sprintf(char *dest, const char *fmt, ...);
  497. #define fprintf dbg_fprintf
  498. extern int fprintf(FILE *fh, const char *fmt, ...);
  499. #define printf dbg_printf
  500. extern int printf(const char *fmt, ...);
  501. #endif
  502.  
  503.  
  504.  
  505. #ifdef AMIGA
  506. /*
  507.     Some compiler specific stuff (how to use register arguments)
  508. */
  509. #ifdef _DCC
  510. #define REG(x) __ ## x
  511. #define ASM
  512. #define SAVEDS __geta4
  513. #endif    /*  _DCC    */
  514. #ifdef __SASC
  515. #define REG(x) register __ ## x
  516. #define ASM    __asm
  517. #define SAVEDS __saveds
  518. #endif    /*  __SASC  */
  519. #ifdef AZTEC_C
  520. #define REG(x)
  521. #define ASM
  522. #define SAVEDS
  523. #endif    /*  AZTEC_C */
  524.  
  525.  
  526. /*
  527.     Check if we use 2.0-Includes.
  528. */
  529. #ifdef GFLG_RELSPECIAL
  530. #define V39_INCLUDES
  531. #endif    /*  GFLG_RELSPECIAL */
  532. #endif    /*  AMIGA        */
  533. #endif    /*  !CHAOS_H        */
  534.