home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / apps.to.go / Kibitz / Chess.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-06  |  7.2 KB  |  212 lines  |  [TEXT/MPS ]

  1. #ifndef __CHESS__
  2. #define __CHESS__
  3.  
  4. #ifndef __TYPES__
  5. #include <types.h>
  6. #endif
  7.  
  8. #ifndef __APPLEEVENTS__
  9. #include <AppleEvents.h>
  10. #endif
  11.  
  12. #ifndef __PRINTING__
  13. #include <Printing.h>
  14. #endif
  15.  
  16. #ifndef __SPEECH__
  17. #include "Speech.h"
  18. #endif
  19.  
  20.  
  21. #define KSIDEPIECE 16
  22.  
  23. #define WHITE 0
  24. #define BLACK 1
  25.  
  26. #define QSIDE 0
  27. #define KSIDE 1
  28.  
  29. #define EMPTY    0
  30. #define PAWN    1
  31. #define KNIGHT    2
  32. #define BISHOP    3
  33. #define ROOK    4
  34. #define QUEEN    5
  35. #define KING    6
  36.  
  37. #define BP PAWN            /* Black pawn    */
  38. #define BN KNIGHT        /* Black knight    */
  39. #define BB BISHOP        /* Black bishop    */
  40. #define BR ROOK            /* Black rook    */
  41. #define BQ QUEEN        /* Black queen    */
  42. #define BK KING            /* Black king    */
  43.  
  44. #define WP -PAWN        /* White pawn    */
  45. #define WN -KNIGHT        /* White knight    */
  46. #define WB -BISHOP        /* White bishop    */
  47. #define WR -ROOK        /* White rook    */
  48. #define WQ -QUEEN        /* White queen    */
  49. #define WK -KING        /* White king    */
  50.  
  51. #define BKB (BB+KSIDEPIECE)
  52. #define BKN (BN+KSIDEPIECE)
  53. #define BKR (BR+KSIDEPIECE)
  54.  
  55. #define WKB (WB-KSIDEPIECE)
  56. #define WKN (WN-KSIDEPIECE)
  57. #define WKR (WR-KSIDEPIECE)
  58.  
  59. #define OBNDS 32767        /* Out of bounds. */
  60.  
  61. #define START_IBNDS    21        /* Start of in-bounds for the board. */
  62. #define END_IBNDS    99        /* End of in-bounds for the board. */
  63.  
  64. #define BKPOS    25
  65. #define WKPOS    95
  66.  
  67. #define kGameContinues    0
  68. #define kYouWin            1
  69. #define kYouLose        2
  70. #define kStalemate        3
  71. #define kDrawBy50        4
  72. #define kDrawByRep        5
  73. #define kYouWinOnTime    6
  74. #define kYouLoseOnTime    7
  75. #define kWhiteResigns    8
  76. #define kBlackResigns    9
  77. #define kDrawGame        10
  78. #define kWhiteWins        11
  79. #define kBlackWins        12
  80. #define kDrawButtonText    13
  81.  
  82. #define kMessageDoc        -1
  83.  
  84. #if defined(powerc) || defined (__powerc)
  85. #pragma options align=mac68k
  86. #endif
  87. typedef struct {
  88.     short    kingLoc;
  89.     short    kingMoves;
  90.     short    rookMoves[2];
  91. } KingInfo;
  92. #if defined(powerc) || defined(__powerc)
  93. #pragma options align=reset
  94. #endif
  95.  
  96. typedef struct {
  97.     short    moveFrom;
  98.     short    moveTo;
  99.     long    value;
  100. } MoveElement;
  101. typedef MoveElement MoveListAry[];
  102. typedef MoveListAry *MoveListPtr, **MoveListHndl;
  103.  
  104. typedef struct {
  105.     short    moveFrom;
  106.     short    moveTo;
  107.     short    pieceCaptured;
  108.     short    pieceCapturedFrom;        /* For undoing en-passant. */
  109.     short    promoteTo;                /* For undoing promotions and recording games. */
  110. } GameElement;
  111. typedef GameElement GameListAry[];
  112. typedef GameListAry *GameListPtr, **GameListHndl;
  113.  
  114. typedef struct {
  115.     GameElement    move;
  116.     short        enPasMove;
  117.     short        enPasPawnLoc;
  118. } MoveRec;
  119.  
  120. #if defined(powerc) || defined (__powerc)
  121. #pragma options align=mac68k
  122. #endif
  123. typedef struct {
  124.  
  125.     short            version;            /* The file format version.                   */
  126.  
  127.     Boolean            printRecValid;        /* True if print record has been created.  */
  128.     TPrint            print;                /* Print record for file.                   */
  129.  
  130.     short            theBoard[120];        /* The current board position.               */
  131.     KingInfo        king[2];            /* King locations and castling info.       */
  132.     short            enPasMove;            /* Where an en-passant could occur.           */
  133.     short            enPasPawnLoc;        /* Location of en-passant-capture.           */
  134.     short            arngEnPasMove;        /* Initial arranged en-pas move.           */
  135.     short            arngEnPasPawnLoc;    /* Initial arranged en-pas capture.           */
  136.     short            numLegalMoves;        /* # of moves in legal move list.           */
  137.     short            gameIndex;            /* Index into game record.                   */
  138.     short            numGameMoves;        /* Size of game record.                       */
  139.     short            myColor;            /* True if I am playing black.               */
  140.     short            startColor;            /* True if black started game.               */
  141.     short            arrangeBoard;        /* True if in arrange-board mode.           */
  142.     short            palettePiece;        /* Piece hilited in arrange-board palette. */
  143.     unsigned long    defaultTime[2];        /* Default ticks for white/black.           */
  144.     unsigned long    timeLeft[2];        /* Ticks remaining for white/black.           */
  145.     Boolean            invertBoard;        /* True, display board inverted.           */
  146.     short            endFileInfo1;        /* Above info is saved to disk.               */
  147.  
  148.     Str32            reconnectZone;        /* Zone of opponent.                       */
  149.     Str32            reconnectMachine;    /* Machine of opponent.                       */
  150.     Str255            reconnectPath;        /* Full path of opponent's copy of Kibitz. */
  151.     Str32            reconnectApp;        /* Name of opponent's copy of Kibitz.       */
  152.     Boolean            justBoardWindow;    /* Just the board shows if true.           */
  153.     Boolean            docIsTemplate;        /* Doc opens as Untitled, file closed.       */
  154.     Boolean            keepCMWhite;        /* True if computer moves white pieces.    */
  155.     Boolean            keepCMBlack;        /* True if computer moves black pieces.    */
  156.     short            endFileInfo2;        /* Above info is saved to disk.               */
  157.                                         /* Above info saved in later version.       */
  158.  
  159.     Boolean            twoPlayer;            /* True if playing over the net.           */
  160.     long            gameID_0;            /* Used to match up incoming moves.           */
  161.     long            gameID_1;            /* Used to match up incoming moves.           */
  162.     short            sendReason;            /* Reason for sending the game.               */
  163.     short            drawBtnState;        /* State of the draw button.                */
  164.     AEAddressDesc    locOfOpponent;        /* AppleEvents address of opponent.           */
  165.     short            endSendInfo;        /* Above is send game info.                   */
  166.  
  167.     short            resync;                /* Non-zero if resync needed.               */
  168.     Boolean            creator;            /* True if this guy originated game.       */
  169.     unsigned long    displayTime[2];        /* Time shown (is <= timeLeft).               */
  170.     unsigned long    freezeTime[2];        /* Time left when clock stopped.           */
  171.     unsigned long    timerRefTick;        /* Reference tick for timer.               */
  172.     unsigned long    compMoveTick;        /* Tick when computer moved last.           */
  173.     unsigned long    gotUpdateTick;        /* Tick when we received new game info.       */
  174.     Boolean            compMovesWhite;        /* True if computer moves white pieces.    */
  175.     Boolean            compMovesBlack;        /* True if computer moves black pieces.    */
  176.     Str32            opponentName;        /* User name of opponent.                   */
  177.     Str32            opponentZone;        /* Zone of opponent.                       */
  178.     Str32            opponentMachine;    /* Machine of opponent.                       */
  179.     unsigned long    timeLastReceive;    /* Time that last move/message received.   */
  180.     short            endLocalInfo;        /* Above info is for one machine only.       */
  181.  
  182.     Boolean            configColorChange;    /* True if color change has been posted.   */
  183.     short            configColor;        /* Color change value to be applied.       */
  184.     Boolean            configTimeChange;    /* True if time change has been posted.       */
  185.     unsigned long    configTime[2];        /* Time change value to be applied.           */
  186.     short            endConfigInfo;        /* Above info is config setting which will */
  187.                                         /* not be applied until a NULL event.       */
  188.  
  189.     MoveListHndl    legalMoves;            /* Handle of legal moves.                   */
  190.     GameListHndl    gameMoves;            /* Handle of game record (saved to disk).  */
  191.     TEHandle        message[2];            /* Handles to in/out messages.               */
  192.     Handle            sound;                /* Handle to recorded sound.               */
  193.     Boolean            doSpeech;
  194.     VoiceSpec        theVoice;
  195.     ControlHandle    sendMessage;        /* Handle to send button.                   */
  196.     ControlHandle    beepOnMove;            /* Handle to move-beep checkbox.           */
  197.     ControlHandle    beepOnMssg;            /* Handle to mssg-beep checkbox.           */
  198.     ControlHandle    gameSlider;            /* Handle to slider custom control.           */
  199.     ControlHandle    wbStart[2];            /* Handles to arrange board controls.       */
  200.     ControlHandle    resign;                /* Handle to resign button.                   */
  201.     ControlHandle    draw;                /* Handle to draw button.                   */
  202.     ControlHandle    record;                /* Handle to record sound button.           */
  203.     ControlHandle    sendSnd;            /* Handle to send sound button.               */
  204.     short            endControls;        /* Above info is reference to controls.       */
  205.  
  206. } TheDoc, *TheDocPtr, **TheDocHndl;
  207. #if defined(powerc) || defined(__powerc)
  208. #pragma options align=reset
  209. #endif
  210.  
  211. #endif
  212.