home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 5
/
ctrom5b.zip
/
ctrom5b
/
OS2
/
SPEL
/
UCHESS
/
UCHESSRC
/
MAIN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-07
|
244KB
|
9,009 lines
// InputThread is the guy who runs the UI
// while main thread does chesswork
// need to load the strings "new" "get" and "save"
// for load/save/new games when in menu, then set
// done to 1!!!
// NOTE THAT THE INPUT THREAD HAS TO BE THE ONE TO
// GETGAME AND SAVE GAME THOUGH!! so it must all change
/*#define EIGHT_BIT_SCREEN 1 */
#define BLANKDATA 0xffff
/* main.c - C source for GNU CHESS
*
* Copyright (c) 1988,1989,1990 John Stanback
* Copyright (c) 1992 Free Software Foundation
*
* This file is part of GNU CHESS.
*
* GNU Chess is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* GNU Chess is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Chess; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define INCL_HELP
#define INCL_DOS
#define INCL_WIN
#define INCL_GPI
int MaxX,MaxY;
int ForceMini=0;
int ForceMax=0;
int ForceMicro=0;
char globaltitle[32];
extern int backsrchaborted;
int myGameCnt=0;
int OrigComputer,OrigOpponent;
char MsgBuf[8][48];
int CheckIllegal = 0;
extern int IllegalMove;
#include "version.h"
#include "gnuchess.h"
#include <signal.h>
#include <ctype.h>
#include <dos.h>
#include <conio.h>
#include "bobs.h"
#include "UChess.h"
CHAR szLibName[HELPLIBRARYNAMELEN];
CHAR szWindowTitle[HELPLIBRARYNAMELEN];
HWND hwndHelpInstance;
int fHelpEnabled=0; /* flag to determine if help is enabled */
extern char mvstr[8][8];
int ETABLE=ETABLE_CONST;
int etblsize=ETABLE_CONST;
extern struct etable *etab[2];
int GlobalFilType = FDS_OPEN_DIALOG;
HEV replyhandle;
//UCHAR semname[16]="\\SEM32\\UCSEM";
UCHAR replyname[16]="\\SEM32\\RPLYSEM";
PFNWP OldFrameProc;
#ifdef AMIGA
#define EXCLUDE_PATT 0xffffff00L
#define __USE_SYSBASE
#include <exec/types.h>
#include <exec/exec.h>
#include <exec/semaphores.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <dos/dostags.h>
#include <proto/graphics.h>
#include <graphics/gfxbase.h>
#include <proto/intuition.h>
#include <utility/tagitem.h>
#include <graphics/modeid.h>
#include <lhlib.h>
#include <libraries/asl.h>
#include <proto/icon.h>
#include <proto/asl.h>
#include <workbench/startup.h>
#include <workbench/workbench.h>
struct TmpRas temp_rast;
unsigned char *tempras_bitplane=(unsigned char *)0L;
#define mySetABPenDrMd(a,b,c,d) if (gfxversion > 38) {SetABPenDrMd(a,b,c,d);} else {SetAPen(a,b);SetDrMd(a,d);}
struct __iobuf __iob[1];
struct SignalSemaphore mySemaphore; // should be all zeroed
#endif //AMIGA
ULONG flCreateFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_MINMAX | FCF_ACCELTABLE
| FCF_SIZEBORDER | FCF_SHELLPOSITION | FCF_TASKLIST | FCF_ICON | FCF_MENU;
int MainThreadStarted=0;
QMSG qmsg;
HMQ hmq;
// These variables are for the BOB routines
int cyClient,cxClient;
HAB hab;
HWND hwndClient;
HWND hwndFrame;
unsigned char UC_Title[32]="UChess P5:";
int global_promote_char=0;
char DisplayPromoteRequestor(void);
VOID InitHelp(VOID);
VOID HelpHelpForHelp(/*MPARAM*/);
VOID HelpExtended(/*MPARAM*/);
//VOID HelpKeys(/*MPARAM*/);
VOID HelpIndex(/*MPARAM*/);
VOID DisplayHelpPanel(LONG);
VOID DestroyHelpInstance(VOID);
MRESULT EXPENTRY myFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
MRESULT EXPENTRY SkillFunc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
MRESULT EXPENTRY PromoteFunc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
MRESULT EXPENTRY AboutDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
MRESULT EXPENTRY TimeControlFunc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
MRESULT EXPENTRY SetPlayersFunc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
void AnimCastle(char *);
void AnimEnPassant(char *);
void WaitRealThink(void);
void WaitThinkAhead(void);
void PutPieceBack(void);
VOID HelpAbout(void);
LONG MainCommand(HWND hwnd, MPARAM mp1/*, MPARAM mp2*/);
void DrawChessPieces(HPS);
void TransBlit(BOB *,HPS,HPS,LONG,PPOINTL);
void TransBlit2(BOB *,HPS,HPS,LONG,PPOINTL);
VOID FixSysMenu(HWND hwndDlg);
#define PAWNBOB 0
#define KNIGHTBOB 1
#define BISHOPBOB 2
#define ROOKBOB 3
#define QUEENBOB 4
#define KINGBOB 5
int MouseX=0,MouseY=0;
int ButtonDown=0;
int ReturnHit=0;
extern HDC winhdc;
HBITMAP WhiteBitMap,BlackBitMap,textBitMap;
CHAR szClientClass[16] = "UChess Window";
long ScreenWidth=0;
long ScreenHeight=0;
long ScreenColors=0;
int EditMode=0;
extern HPS hpsMemory;
unsigned char PieceFileNames[2][6][24]={
"CPAWN2.BMP","CKNIGHT2.BMP","CBISHOP2.BMP",
"CROOK2.BMP","CQUEEN2.BMP","CKING2.BMP",
"CPAWN1.BMP","CKNIGHT1.BMP","CBISHOP1.BMP",
"CROOK1.BMP","CQUEEN1.BMP","CKING1.BMP"};
extern int SafeBlit;
int WinNotInited=1;
int GotSize=0;
MRESULT EXPENTRY ClientWndProc(HWND,ULONG,MPARAM,MPARAM);
#define PEL_DEPTH 8
#define NUMCOLORS (1<<PEL_DEPTH)
int oldflageasy=0;
unsigned int CurrBobColor=0;
unsigned int CurrBobIndex=0;
BOB *TheBob[2][6]; // all pieces are a BOB
//HMTX mySemaphore; // taken care of by DrawSemaphore
extern int backsrcshaborted;
extern int bookflag;
#define LN2 693147 /* .693147 */
#define LOGE_34 3526361 /* log2(34) = ln(34)/ln(2) = 5.087463 */
#define LOGE_16 2772589 /* ln(16) = */
void SetTimeControl2 (int);
void calc_pgm_rating(void);
void DoEasy(void);
void DoIntermediate(void);
void DoAdvanced(void);
int GetScreenMode(void);
void QueryTimeValues(HWND);
void QueryPlayerValues(HWND);
void QueryPromoteValues(HWND);
void QuerySkillValues(HWND);
/* this table index ln(2)*1e6 - ln(1202)*1e6 by 6's */
/* so take (#secs - 2)/6 for index into this table */
//char UCProcName[16]="UCTurbo Engine";
//char InputPortName[16]="UC Port";
//struct TagItem ProcTagList[8] = {
//{NP_Entry,(ULONG)InputThread},
//{NP_StackSize,4096L},
//{NP_Name,(ULONG)UCProcName},
//{0,0}
//};
//struct MsgPort *InputReply=(struct MsgPort *)0L;
//struct MsgPort *InThreadPort;
ULONG Global_Message;
extern INTSIZE amigaboard[64],amigacolor[64];
extern int RealThink;
int opindex=0;
int OpEntryRecvd=0;
int InputThreadState=0;
char OpEntryStr[64]={0,0,0,0};
char lOpEntryStr[64]={0,0,0,0};
long OrigResponse;
int log_e[]={
693147, 2079442, 2639057, 2995732, 3258097, 3465736, 3637586, 3784190,
3912023, 4025352, 4127134, 4219508, 4304065, 4382027, 4454347, 4521789,
4584967, 4644391, 4700480, 4753590, 4804021, 4852030, 4897840, 4941642,
4983607, 5023881, 5062595, 5099866, 5135798, 5170484, 5204007, 5236442,
5267858, 5298317, 5327876, 5356586, 5384495, 5411646, 5438079, 5463832,
5488938, 5513429, 5537334, 5560682, 5583496, 5605802, 5627621, 5648974,
5669881, 5690359, 5710427, 5730100, 5749393, 5768321, 5786897, 5805135,
5823046, 5840642, 5857933, 5874931, 5891644, 5908083, 5924256, 5940171,
5955837, 5971262, 5986452, 6001415, 6016157, 6030685, 6045005, 6059123,
6073045, 6086775, 6100319, 6113682, 6126869, 6139885, 6152733, 6165418,
6177944, 6190315, 6202536, 6214608, 6226537, 6238325, 6249975, 6261492,
6272877, 6284134, 6295266, 6306275, 6317165, 6327937, 6338594, 6349139,
6359574, 6369901, 6380123, 6390241, 6400257, 6410175, 6419995, 6429719,
6439350, 6448889, 6458338, 6467699, 6476972, 6486161, 6495266, 6504288,
6513230, 6522093, 6530878, 6539586, 6548219, 6556778, 6565265, 6573680,
6582025, 6590301, 6598509, 6606650, 6614726, 6622736, 6630683, 6638568,
6646391, 6654153, 6661855, 6669498, 6677083, 6684612, 6692084, 6699500,
6706862, 6714171, 6721426, 6728629, 6735780, 6742881, 6749931, 6756932,
6763885, 6770789, 6777647, 6784457, 6791221, 6797940, 6804615, 6811244,
6817831, 6824374, 6830874, 6837333, 6843750, 6850126, 6856462, 6862758,
6869014, 6875232, 6881411, 6887553, 6893656, 6899723, 6905753, 6911747,
6917706, 6923629, 6929517, 6935370, 6941190, 6946976, 6952729, 6958448,
6964136, 6969791, 6975414, 6981006, 6986566, 6992096, 6997596, 7003065,
7008505, 7013915, 7019297, 7024649, 7029973, 7035269, 7040536, 7045777,
7050989, 7056175, 7061334, 7066467, 7071573, 7076654, 7081709, 7086738,
7091742};
/* Structure for transparent images */
void Undo(void);
char vstring[64]={AVSTR};
extern int SecsPerMove;
int lastpiece=BLANKDATA;
#ifdef AMIGA
#define PTRHEIGHT 55
#endif //AMIGA
long piecechar[12]={'p','n','b','r','q','k',
'P','N','B','R','Q','K'};
char oldboard[8][8];
int BACKPEN=1;
int BLACK=1;
//int Picasso=0L;
ULONG bpen;
int PlayMode = 2;
int global_tmp_score=0;
int previous_score=0;
extern short int ISZERO;
extern int thinkahead;
unsigned long int next = 1;
int doswap=0;
int doundo=0;
int doauto=0;
int gfxversion=0L;
int v15Khz=0L;
int teston=0;
int cmptr_sec,cmptr_min,hum_sec,hum_min;
#ifdef AMIGA
struct TagItem myTagList[8] = {
{SA_DisplayID,VGAPRODUCT_KEY},
{SA_Overscan,OSCAN_STANDARD},
{0,0},
{0,0},
{0,0}
};
#define WINDOWSIGNAL (1L<<(wG->UserPort->mp_SigBit))
ULONG globalsignalset=0L;
#define WINDOWSIGNAL (1L<<(wG->UserPort->mp_SigBit))
ULONG globalsignalset=0L;
#endif
int MoveNowOK=0;
ULONG RTG_ModeID=0x0L;
int Super72=0;
int RTG=0;
int SYSTEM_BOBS=1;
int ResignOffered=0;
//ULONG tmppal[4];
void TimeCalc (void);
int FasterDisplay=0;
int trying_again=0;
int SupervisorMode=0;
int MenuStripSet = 0;
int GlobalTgtDepth=4; // was 3
long OrigCol,OrigRow,DestCol,DestRow;
#ifdef AMIGA
UWORD chip myPointer[]={
0,0,
31744,0,
4096,0,
4096,0,
4096,0,
4096,0,
5120,0,
5120,0,
1024,0,
1920,0,
1152,0,
1152,0,
1152,0,
256,0,
0,0,
768,0,
256,0,
256,0,
256,0,
896,0,
0,0,
896,0,
576,0,
576,0,
576,0,
576,0,
0,0,
512,0,
512,0,
576,0,
640,0,
896,0,
640,0,
576,0,
0,0,
256,0,
0,0,
768,0,
256,0,
256,0,
256,0,
896,0,
0,0,
0,0,
896,0,
576,0,
576,0,
576,0,
576,0,
0,0,
960,0,
576,0,
576,0,
960,0,
64,0,
960,0,
0,0
};
struct TransImage
{
struct Image *ti_IM; /* The plain image */
struct BitMap *ti_sBM; /* Shadow bitmap */
struct RastPort *ti_sRP; /* Shadow rastport */
struct BitMap ti_BM; /* Image bitmap */
struct RastPort ti_RP; /* Image rastport */
};
struct Image BobImage;
struct TransImage *BobTransImage;
struct TransImage *AllocTransImage (struct Image * im);
VOID FreeTransImage (struct TransImage * ti);
VOID ClipBlitTrans (struct RastPort *, WORD, WORD, struct RastPort *, WORD, WORD, WORD, WORD, struct RastPort *);
struct BitMap *AllocShadowBM (UWORD, UWORD, UWORD);
VOID FreeShadowBM (struct BitMap *);
struct RastPort *AllocShadowRP (struct BitMap *);
VOID FreeShadowRP (struct RastPort *);
#define TDEPTH 4
#define THEIGHT 400 /* tmp ht */
#define TBLOCKPEN 4 /* was 9 */
#define MENUPEN 11
#ifdef EIGHT_BIT_SCREEN
int DEPTH=8;
#ifdef MANYP
int HEIGHT=480;
int USERBOX=480-168;
int COMPUTERBOX=480-60;
int BACKGNDTEXTCOLOR=0xe0; /* for 256 use 0xe0 */
int BOBHEIGHT=55; /* 55 for 480 screens */
int ROW8B=24; /* 24 for 480 screens */
int MBLOCKPEN=251;
#endif
#else
int DEPTH=4;
#endif
#endif // AMIGA
#include "Chess256.c"
TID myTID;
int TCadd = 0;
int thinking2=0; /* look for move now menu selection in elasped time when set */
int TIMEYCOORD1=480-120;
int TIMEYCOORD2=480-230;
int SYSBOXLEN=102;
int HEIGHT=480;
int USERBOX=480-168;
int SYSTEMBOX=480-233;
int COMPUTERBOX=480-60;
int BACKGNDTEXTCOLOR=0xe0; /* for 256 use 0xe0 */
int BOBHEIGHT=55; /* 55 for 480 screens 46 for 400 lines */
int ROW8B=480-24; /* 24 for 480 screens 20 for 400 line screens*/
int MBLOCKPEN=9;
#define MENUBARHT 11
#define WIDTH 640
#define VIEWMODES (HIRES|LACE)
int BOBDEPTH=8;
#define BOARDWIDTH 640
#define BOARDWIDINW 40
#define BOARDSIZE (480*DEPTH*BOARDWIDINW*sizeof(WORD))
#define BOARDBLOCKSIZE ((BOARDSIZE+(BOARDWIDINW*sizeof(WORD))*(480+2))+(BOARDWIDINW*sizeof(WORD)))
#define BOBWIDTH 64 /* only 59 pixels are really used, rest are tranparent */
#define BOBWIDINW 4
#define BOBSIZE (BOBHEIGHT*BOBDEPTH*BOBWIDINW*sizeof(WORD))
#define BOBBLOCKSIZE ((BOBSIZE)+(BOBWIDINW*sizeof(WORD)*(BOBHEIGHT+2))+(BOBWIDINW*sizeof(WORD)))
#define BOBLW ((BOBBLOCKSIZE)/4)
#define BOBMEMASK 0
#define BOBHITMASK 0
int BOBPLANEPICK=0xf; /* if 16 colors should be 0xf if 256 should be 0xff */
#define BOBPLANEONOFF 0x0
#define SQUAREWIDTH 59
#define ROUNDEDSQUAREWIDTH 64
#define SQUAREHEIGHT BOBHEIGHT
#define COLA (16)
#define COLB (16+SQUAREWIDTH)
#define COLC (16+SQUAREWIDTH*2)
#define COLD (16+SQUAREWIDTH*3)
#define COLE (16+SQUAREWIDTH*4)
#define COLF (16+SQUAREWIDTH*5)
#define COLG (16+SQUAREWIDTH*6)
#define COLH (16+SQUAREWIDTH*7)
//#define ROW7 (ROW8-SQUAREHEIGHT)
#define ROW8 (ROW8B-SQUAREHEIGHT)
#define ROW7 (ROW8B-SQUAREHEIGHT*2)
#define ROW6 (ROW8B-SQUAREHEIGHT*3)
#define ROW5 (ROW8B-SQUAREHEIGHT*4)
#define ROW4 (ROW8B-SQUAREHEIGHT*5)
#define ROW3 (ROW8B-SQUAREHEIGHT*6)
#define ROW2 (ROW8B-SQUAREHEIGHT*7)
#define ROW1 (ROW8B-SQUAREHEIGHT*8)
UWORD *BlankImageData;
UWORD *WhiteImageData[6];
UWORD *BlackImageData[6];
void LoadBobImage(long);
long ColArray[8]={COLA,COLB,COLC,COLD,COLE,COLF,COLG,COLH};
long RowArray[8];
#ifdef AMIGA
struct VSprite *SpriteHead;
struct VSprite *SpriteTail;
struct GelsInfo *myGelsInfo;
struct VSprite *BobVSprite;
struct Bob *TheBob;
struct BitMap *WhiteBitMap,*BlackBitMap;
struct BitMap *textBitMap=(struct BitMap *)0L;
struct TextFont *myTextFont;
extern struct GfxBase *Gfxbase;
long __stack=50000L;
ULONG tt;
struct RastPort *rpG;
struct ViewPort *vP;
struct Screen *sC=0L;
struct Window *wG=0L;
struct Window *wGEdit;
unsigned char cookedchar[128]={'~',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0', /* 10 */
'-',
'=',
' ',
' ',
'0',
'Q', /* 16 */
'W',
'E',
'R',
'T', /* 20 */
'Y',
'U',
'I',
'O',
'P', /* 25 */
'[',
']',
' ',
'1',
'2',
'3',
'A',
'S',
'D',
'F',
'G',
'H',
'J',
'K',
'L', /* 40 */
':',
'"',
13,
' ',
'4',
'5',
'6',
' ',
'Z',
'X', /* 50 */
'C',
'V',
'B',
'N',
'M', /* 55 */
',',
'.',
'/',
' ',
'.',
'7',
'8',
'9',
' ',
7,
8,
13,
13,
27,
7
};
char *Orig_PlanePtr;
struct BitMap *myBitMap;
struct BitMap *OrigmyBitMap=0L;
UWORD myPalette[16]=
{
0xfbc, 0x632, 0x455, 0x842, 0x549, 0xa53, 0x787, 0xa56,
0x967, 0xa85, 0x3ab, 0xaaa, 0xe88, 0xdb8, 0x333, 0xeee
};
#ifdef OLDPAL
{
0x0, 0x222, 0x410, 0x333,
0x621, 0x624, 0x952, 0x665,
0x974, 0x887, 0xb85, 0xaa9,
0xbb7, 0xcc8, 0xcc9, 0xddc};
#endif
struct TextAttr TOPAZ80 = {
(STRPTR)"topaz.font",
TOPAZ_EIGHTY,0,0
};
SHORT BorderVectors6[] = {
0,0,
44,0,
44,19,
0,19,
0,0
};
struct Border Border6 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
BorderVectors6, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText IText93 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
12,6, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"OK", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget Gadget9 = {
NULL, /* next gadget */
109,64, /* origin XY of hit box relative to window TopLeft */
43,18, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&Border6, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&IText93, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
UBYTE Gadget8SIBuff[8];
struct StringInfo Gadget8SInfo = {
Gadget8SIBuff, /* buffer where text will be edited */
NULL, /* optional undo buffer */
0, /* character position in buffer */
5, /* maximum number of characters to allow */
0, /* first displayed character buffer position */
0,0,0,0,0, /* Intuition initialized and maintained variables */
0, /* Rastport of gadget */
0, /* initial value for integer gadgets */
NULL /* alternate keymap (fill in if you set the flag) */
};
SHORT BorderVectors7[] = {
0,0,
45,0 /* was 45 */,
45,14, /* was 17 */
0,14,
0,0
};
struct Border Border7 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
BorderVectors7, /* pointer to XY vectors */
NULL /* next border in list */
};
struct Gadget Gadget8 = {
&Gadget9, /* next gadget */
136,32, /* origin XY of hit box relative to window TopLeft */
44,16, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
STRGADGET, /* gadget type flags */
(APTR)&Border7, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&Gadget8SInfo, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
UBYTE Gadget6SIBuff[8];
struct StringInfo Gadget6SInfo = {
Gadget6SIBuff, /* buffer where text will be edited */
NULL, /* optional undo buffer */
0, /* character position in buffer */
4, /* maximum number of characters to allow */
0, /* first displayed character buffer position */
0,0,0,0,0, /* Intuition initialized and maintained variables */
0, /* Rastport of gadget */
0, /* initial value for integer gadgets */
NULL /* alternate keymap (fill in if you set the flag) */
};
struct Border Border9 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
BorderVectors7, /* pointer to XY vectors */
NULL /* next border in list */
};
struct Gadget Gadget6 = {
&Gadget8, /* next gadget */
14,32, /* origin XY of hit box relative to window TopLeft */
44,16, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
STRGADGET, /* gadget type flags */
(APTR)&Border9, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&Gadget6SInfo, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
struct Gadget Gadget6b = {
&Gadget9, /* next gadget */
14,32, /* origin XY of hit box relative to window TopLeft */
44,16, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
STRGADGET, /* gadget type flags */
(APTR)&Border9, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&Gadget6SInfo, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
struct IntuiText IText47 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
195,36, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Minutes.", /* pointer to text */
NULL /* next IntuiText structure */
};
struct IntuiText IText46 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
64,35, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Moves in", /* pointer to text */
&IText47 /* next IntuiText structure */
};
#define IntuiTextList5 IText46
struct NewWindow NewWindowStructure5 = {
161,23, /* window XY origin relative to TopLeft of screen */
270,90, /* window width and height */
0,TBLOCKPEN, /* detail and block pens */
GADGETUP, /* IDCMP flags */
SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH, /* other window flags */
&Gadget6, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
"Computer Time Ctrl", /* window title */
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
5,5, /* minimum width and height */
0xffff,0xffff, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
};
struct ExtNewScreen NewScreenStructure = {
0,0, /* screen XY origin relative to View */
WIDTH,THEIGHT, /* screen width and height */
4, /* screen depth (number of bitplanes) */
0,TBLOCKPEN, /* detail and block pens */
VIEWMODES, /* display modes for this screen */
CUSTOMBITMAP|CUSTOMSCREEN, /* screen type */
&TOPAZ80, /* pointer to default screen font */
VERSTRING, /* screen title */
NULL, /* first in list of custom screen gadgets */
NULL /* pointer to custom BitMap structure */
};
struct ExtNewScreen NewScreenStructure2 = {
0,0, /* screen XY origin relative to View */
WIDTH,480, /* screen width and height */
8, /* screen depth (number of bitplanes) */
0,251, /* detail and block pens */
VIEWMODES, /* display modes for this screen */
CUSTOMSCREEN|SCREENBEHIND, /* screen type */
&TOPAZ80, /* pointer to default screen font */
" ", /* screen title */
NULL, /* first in list of custom screen gadgets */
NULL /* pointer to custom BitMap structure */
};
struct IntuiText IText37 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"New Game", /* pointer to text */
NULL /* next IntuiText structure */
};
struct IntuiText IText1r = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Set Depth", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem3r = {
NULL, /* next MenuItem structure */
0,32, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText1r, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText1 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Set Time", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem3 = {
&MenuItem3r, /* next MenuItem structure */
0,24, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText1, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText2x = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Rate Pgm", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem3x = {
&MenuItem3, /* next MenuItem structure */
0,16, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText2x, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText2 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Test", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem2 = {
&MenuItem3x, /* next MenuItem structure */
0,8, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText2, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText3 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Hint", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem1 = {
&MenuItem2, /* next MenuItem structure */
0,0, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText3, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'H', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct Menu Menu4 = {
NULL, /* next Menu structure */
162,0, /* XY origin of Menu hit box relative to screen TopLeft */
63,0, /* Menu hit box width and height */
MENUENABLED, /* Menu flags */
"Special", /* text of Menu name */
&MenuItem1 /* MenuItem linked list pointer */
};
struct IntuiText IText4cc = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Easy", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem8cc = {
NULL, /* next MenuItem structure */
0,80, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP, /* Item flags */
EXCLUDE_PATT^(0x400), /* each bit mutually-excludes a same-level Item */
(APTR)&IText4cc, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'E', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText4dd = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Intrmdt", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem8dd = {
&MenuItem8cc, /* next MenuItem structure */
0,72, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP, /* Item flags */
EXCLUDE_PATT^(0x200), /* each bit mutually-excludes a same-level Item */
(APTR)&IText4dd, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'I', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText4ee = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Advancd", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem8ee = {
&MenuItem8dd, /* next MenuItem structure */
0,64, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKED+CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+HIGHCOMP, /* Item flags */
EXCLUDE_PATT^(0x100), /* each bit mutually-excludes a same-level Item */
(APTR)&IText4ee, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'A', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText4aa = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Supvsr", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem8aa = {
&MenuItem8ee, /* next MenuItem structure */
0,56, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText4aa, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'Y', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText4ab = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Book", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem8ab = {
&MenuItem8aa, /* next MenuItem structure */
0,48, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKIT+CHECKED+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText4ab, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'B', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText4a = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"ShwThnk", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem8a = {
&MenuItem8ab, /* next MenuItem structure */
0,40, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText4a, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'V', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText4 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Thinking", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem8 = {
&MenuItem8a, /* next MenuItem structure */
0,32, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ/*+ITEMENABLED*/+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText4, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'T', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText5 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Undo", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem7 = {
&MenuItem8, /* next MenuItem structure */
0,24, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText5, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'U', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText6 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Move Now", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem6 = {
&MenuItem7, /* next MenuItem structure */
0,16, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText6, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'M', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText7 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"AutoPlay", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem5 = {
&MenuItem6, /* next MenuItem structure */
0,8, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText7, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText8 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Swap Sides", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem4 = {
&MenuItem5, /* next MenuItem structure */
0,0, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText8, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'S', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct Menu Menu3 = {
&Menu4, /* next Menu structure */
92,0, /* XY origin of Menu hit box relative to screen TopLeft */
63,0, /* Menu hit box width and height */
MENUENABLED, /* Menu flags */
"Control", /* text of Menu name */
&MenuItem4 /* MenuItem linked list pointer */
};
struct IntuiText IText9 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"ReverseBoard", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem11 = {
NULL, /* next MenuItem structure */
0,16, /* XY of Item hitbox relative to TopLeft of parent hitbox */
96,8, /* hit box width and height */
ITEMTEXT+/*ITEMENABLED+*/HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText9, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText10 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Edit Board", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem10 = {
&MenuItem11, /* next MenuItem structure */
0,8, /* XY of Item hitbox relative to TopLeft of parent hitbox */
96,8, /* hit box width and height */
ITEMTEXT+HIGHCOMP+ITEMENABLED, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText10, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText11 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"2-D", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem9 = {
&MenuItem10, /* next MenuItem structure */
0,0, /* XY of Item hitbox relative to TopLeft of parent hitbox */
96,8, /* hit box width and height */
CHECKED+CHECKIT+ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText11, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct Menu Menu2 = {
&Menu3, /* next Menu structure */
46,0, /* XY origin of Menu hit box relative to screen TopLeft */
39,0, /* Menu hit box width and height */
MENUENABLED, /* Menu flags */
"View", /* text of Menu name */
&MenuItem9 /* MenuItem linked list pointer */
};
struct IntuiText IText12 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Quit", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem15 = {
NULL, /* next MenuItem structure */
0,40, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText12, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'Q', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText13a = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"List Game", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem14a = {
&MenuItem15, /* next MenuItem structure */
0,32, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText13a,/* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText13 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Save Game", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem14 = {
&MenuItem14a, /* next MenuItem structure */
0,24, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText13, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText14 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Load Game", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem13 = {
&MenuItem14, /* next MenuItem structure */
0,16, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText14, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct MenuItem MenuItem28 = {
&MenuItem13, /* next MenuItem structure */
0,8, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText37, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText IText15 = {
MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"About..", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem MenuItem12 = {
&MenuItem28, /* next MenuItem structure */
0,0, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText15, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct Menu Menu1 = {
&Menu2, /* next Menu structure */
0,0, /* XY origin of Menu hit box relative to screen TopLeft */
39,0, /* Menu hit box width and height */
MENUENABLED, /* Menu flags */
"File", /* text of Menu name */
&MenuItem12 /* MenuItem linked list pointer */
};
#define MenuList1 Menu1
struct NewWindow NewWindowStructure1 = {
0,0, /* window XY origin relative to TopLeft of screen */
WIDTH,THEIGHT, /* window width and height */
0,TBLOCKPEN, /* detail and block pens */
MOUSEBUTTONS|MENUPICK|RAWKEY, /* IDCMP flags */
BACKDROP+BORDERLESS+ACTIVATE+NOCAREREFRESH, /* other window flags */
NULL, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
" ", /* window title */
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
WIDTH,THEIGHT, /* minimum width and height */
0xffff,0xffff, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
};
SHORT BorderVectors1[] = {
0,0,
81,0,
81,38,
0,38,
0,0
};
struct Border Border1 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
BorderVectors1, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText IText16 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
31,15, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"OK", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget Gadget1 = {
NULL, /* next gadget */
155,233, /* origin XY of hit box relative to window TopLeft */
80,37, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&Border1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&IText16, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
#define GadgetList2 Gadget1
struct IntuiText IText22 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
143,130, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"of Computers.", /* pointer to text */
NULL /* next IntuiText structure */
};
struct IntuiText IText21 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
115,117, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"For the Amiga Family", /* pointer to text */
&IText22 /* next IntuiText structure */
};
struct IntuiText IText20 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
104,102, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Chess Program Available", /* pointer to text */
&IText21 /* next IntuiText structure */
};
struct IntuiText IText19 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
108,87, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"The strongest Playing", /* pointer to text */
&IText20 /* next IntuiText structure */
};
struct IntuiText IText18 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
126,31, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"by Roger Uzun", /* pointer to text */
&IText19 /* next IntuiText structure */
};
struct IntuiText IText17 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
131,18, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
VERSTRING, /* pointer to text */
&IText18 /* next IntuiText structure */
};
struct NewWindow NewWindowStructure2 = {
125,30, /* window XY origin relative to TopLeft of screen */
390,290, /* window width and height */
0,TBLOCKPEN, /* detail and block pens */
VANILLAKEY|GADGETUP, /* IDCMP flags */
SIMPLE_REFRESH+NOCAREREFRESH+ACTIVATE, /* other window flags */
&Gadget1, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
#ifdef _M68040
"UChess Pro", /* window title */
#else
#ifndef TINYCHESS
"UChess Jr.", /* window title */
#else
"UChess Tiny", /* window title */
#endif
#endif
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
5,5, /* minimum width and height */
0xffff,0xffff, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
};
SHORT aBorderVectors1[] = {
0,0,
77,0,
77,25,
0,25,
0,0
};
struct Border aBorder1 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
aBorderVectors1, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText aIText1 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
16,8, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"KNIGHT", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget aGadget4 = {
NULL, /* next gadget */
55,124, /* origin XY of hit box relative to window TopLeft */
76,24, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&aBorder1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&aIText1, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
SHORT aBorderVectors2[] = {
0,0,
77,0,
77,25,
0,25,
0,0
};
struct Border aBorder2 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
aBorderVectors2, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText aIText2 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
15,8, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"BISHOP", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget aGadget3 = {
&aGadget4, /* next gadget */
55,92, /* origin XY of hit box relative to window TopLeft */
76,24, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&aBorder2, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&aIText2, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
SHORT aBorderVectors3[] = {
0,0,
77,0,
77,25,
0,25,
0,0
};
struct Border aBorder3 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
aBorderVectors3, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText aIText3 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
19,8, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"ROOK", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget aGadget2 = {
&aGadget3, /* next gadget */
55,60, /* origin XY of hit box relative to window TopLeft */
76,24, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&aBorder3, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&aIText3, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
SHORT aBorderVectors4[] = {
0,0,
77,0,
77,25,
0,25,
0,0
};
struct Border aBorder4 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
aBorderVectors4, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText aIText4 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
16,8, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"QUEEN", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget aGadget1 = {
&aGadget2, /* next gadget */
55,28, /* origin XY of hit box relative to window TopLeft */
76,24, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&aBorder4, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&aIText4, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
struct IntuiText aIText5 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
33,14, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Promote Pawn to", /* pointer to text */
NULL /* next IntuiText structure */
};
struct NewWindow NewWindowStructure6 = {
220,35, /* window XY origin relative to TopLeft of screen */
200,170, /* window width and height */
0,TBLOCKPEN, /* detail and block pens */
GADGETUP, /* IDCMP flags */
SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH, /* other window flags */
&aGadget1, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
"Promote Piece", /* window title */
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
5,5, /* minimum width and height */
0xffff,0xffff, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
};
#define MOVENOWMENUNUM 0x42
#define THINKMENUNUM 0x82
#define SHOWMENUNUM 0xa2
#define BOOKMENUNUM 0xc2
#define SUPERMENUNUM 0xe2
#define ADVANCEDMENUNUM 0x102
#define INTERMEDIATEMENUNUM 0x122
#define EASYMENUNUM 0x142
SHORT pBorderVectors1[] = {
0,0,
68,0,
68,31,
0,31,
0,0
};
struct Border pBorder1 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
pBorderVectors1, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText pIText1 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
13,11, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"DONE", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget pGadget4 = {
NULL, /* next gadget */
104,172, /* origin XY of hit box relative to window TopLeft */
67,30, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&pBorder1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&pIText1, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
SHORT pBorderVectors2[] = {
0,0,
68,0,
68,31,
0,31,
0,0
};
struct Border pBorder2 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
pBorderVectors2, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText pIText2 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
117,132, /* was 13,11 XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"WHITE", /* pointer to text */
NULL /* next IntuiText structure */
};
struct IntuiText pIText2a = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
117,132, /* was 13,11 XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"BLACK", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget pGadget3 = {
&pGadget4, /* next gadget */
104,121, /* origin XY of hit box relative to window TopLeft */
67,30, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&pBorder2, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
SHORT pBorderVectors3[] = {
0,0,
68,0,
68,31,
0,31,
0,0
};
struct Border pBorder3 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
pBorderVectors3, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText pIText3 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
0,12, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Clear BD", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget pGadget2 = {
&pGadget3, /* next gadget */
105,82, /* origin XY of hit box relative to window TopLeft */
67,30, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&pBorder3, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&pIText3, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
UBYTE pppSIBuff[4];
struct StringInfo pppSInfo = {
pppSIBuff, /* buffer where text will be edited */
NULL, /* optional undo buffer */
0, /* character position in buffer */
4, /* maximum number of characters to allow */
0, /* first displayed character buffer position */
0,0,0,0,0, /* Intuition initialized and maintained variables */
0, /* Rastport of gadget */
0, /* initial value for integer gadgets */
NULL /* alternate keymap (fill in if you set the flag) */
};
SHORT pBorderVectors4[] = {
0,0,
55,0,
55,16, /* was 55,24 and 0, 24 */
0,16,
0,0
};
struct Border pBorder4 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
pBorderVectors4, /* pointer to XY vectors */
NULL /* next border in list */
};
struct Gadget pGadget1 = {
&pGadget2, /* next gadget */
180,57, /* origin XY of hit box relative to window TopLeft */
54,15, /* was 54, 23 hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
STRGADGET, /* gadget type flags */
(APTR)&pBorder4, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&pppSInfo, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
struct IntuiText pIText8a = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
32,44, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"use space to clr a square", /* pointer to text */
NULL /* next IntuiText structure */
};
struct IntuiText pIText7 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
26,34, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Bd is updated after edit session", /* pointer to text */
&pIText8a /* next IntuiText structure */
};
struct IntuiText pIText6 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
68,62, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Piece to add", /* pointer to text */
&pIText7 /* next IntuiText structure */
};
struct IntuiText pIText5 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
59,24, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"pa1 for pawn at a1, etc.", /* pointer to text */
&pIText6 /* next IntuiText structure */
};
struct IntuiText pIText4 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
63,14, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Enter Pieces in format", /* pointer to text */
&pIText5 /* next IntuiText structure */
};
struct NewWindow pNewWindowStructure1 = {
170,30, /* window XY origin relative to TopLeft of screen */
300,220, /* window width and height */
0,TBLOCKPEN, /* detail and block pens */
GADGETUP+CLOSEWINDOW, /* IDCMP flags */
WINDOWCLOSE+SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH, /* other window flags */
&pGadget1, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
"Edit Board", /* window title */
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
5,5, /* minimum width and height */
0xffff,0xffff, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
};
#endif // AMIGA
void WaitRealThink()
{
int i=5*7;
while (RealThink)
{
MoveNow();
DosSleep(250L);
i--;
if (!i)
{
WinMessageBox(HWND_DESKTOP,hwndClient,"Chess Engine still busy","THREAD SYNCH ERROR",0,MB_OK);
return;
}
}
}
void WaitThinkAhead()
{
int i=5*7;
if ((thinkahead)&&(!flag.bothsides))
{
if (!TCflag)
backsrchaborted = 1;
while (thinkahead)
{
flag.back = true;
DosSleep(250L);
i--;
if (!i)
{
WinMessageBox(HWND_DESKTOP,hwndClient,"Chess Engine still busy","THREAD SYNCH ERROR",0,MB_OK);
return;
}
}
}
}
LONG MainCommand(HWND hwnd, MPARAM mp1/*, MPARAM mp2*/)
{
// int i;
if ((EditMode)&&(SHORT1FROMMP(mp1) != IDM_EXIT))
{
DosBeep(1280,500);
ShowMessage("Not during edit!");
return 0;
}
switch(SHORT1FROMMP(mp1))
{
case IDM_NEWGAME:
WaitRealThink();
WaitThinkAhead();
NewGame();
break;
case IDM_VERBOSE:
flag.post = !flag.post;
if (!flag.post)
ShowMessage("Verbse off");
else
ShowMessage("Verbse on");
break;
case IDM_LOOK:
flag.beep = !flag.beep;
if (!flag.beep)
ShowMessage("Beep off");
else
ShowMessage("Beep on");
break;
case IDM_EDIT:
if (!ButtonDown)
{
if (RealThink)
{
ShowMessage("Turn");
ShowMessage("Not Your");
DosBeep(1280,170);
break;
}
WaitThinkAhead();
CurrBobColor = white;
CurrBobIndex = PAWNBOB;
EditMode = 2;
WinDlgBox(HWND_DESKTOP,
hwndClient,
(PFNWP)AboutDlgProc,
0,
IDD_EDIT,
(PVOID)NULL);
ShowMessage("to exit");
ShowMessage("press 'x'");
ShowMessage("Edit on");
}
break;
case IDM_SKILL:
WaitRealThink();
WaitThinkAhead();
WinDlgBox(HWND_DESKTOP,hwnd,SkillFunc,0,IDD_SKILL,0);
break;
case IDM_CALC:
WaitRealThink();
WaitThinkAhead();
strcpy(lOpEntryStr,"calc");
strcpy(OpEntryStr,"calc");
opindex = 0;
ReturnHit = 1;
break;
case IDM_TEST:
if (RealThink)
{
ShowMessage("Turn");
ShowMessage("Not Your");
DosBeep(1280,170);
break;
}
WaitThinkAhead();
strcpy(lOpEntryStr,"test");
strcpy(OpEntryStr,"test");
opindex = 0;
ReturnHit = 1;
break;
case IDM_TAKEBACK:
if (RealThink)
{
ShowMessage("your Turn!");
ShowMessage("It's not");
DosBeep(1280,175);
break;
}
if (Mate)
{
ShowMessage("checkmate!");
ShowMessage("Not after");
DosBeep(1280,175);
break;
}
WaitThinkAhead();
TakeBack();
break;
case IDM_LOADGAME:
if (RealThink)
{
ShowMessage("your Turn!");
ShowMessage("It's not");
DosBeep(1280,175);
break;
}
WaitThinkAhead();
GetGame();
break;
case IDM_LISTGAME:
if (RealThink)
{
ShowMessage("your Turn!");
ShowMessage("It's not");
DosBeep(1280,175);
break;
}
WaitThinkAhead();
ListGame(0xff);
break;
case IDM_SAVEGAME:
if (RealThink)
{
ShowMessage("your Turn!");
ShowMessage("It's not");
DosBeep(1280,175);
break;
}
WaitThinkAhead();
SaveGame();
break;
case IDM_TIMECONTROL:
if (!SupervisorMode)
WinDlgBox(HWND_DESKTOP,hwnd,TimeControlFunc,0,IDD_TIMEDLG,0);
else
WinMessageBox(HWND_DESKTOP,hwnd,"Computer not playing!","Invalid Selection",0,MB_OK);
break;
case IDM_PLAYERS:
if (RealThink)
{
ShowMessage("Turn");
ShowMessage("Not Your");
DosBeep(1280,170);
break;
}
WaitThinkAhead();
WinDlgBox(HWND_DESKTOP,hwnd,SetPlayersFunc,0,IDD_PLAYERS,0);
break;
case IDM_HINT:
if (RealThink)
{
DosBeep(1280,75);
ShowMessage("turn!");
ShowMessage("not your");
}
else
GiveHint();
break;
case IDM_MOVENOW:
WaitRealThink();
#ifdef OLDWAYWT
i = 14;
while ((RealThink)&&(i))
{
i--;
MoveNow();
DosSleep(400);
}
if (RealThink)
{
ShowMessage("Plse wait");
ShowMessage("thinking..");
ShowMessage("Pgm still");
}
#endif
break;
case IDM_EXIT:
DestroyHelpInstance();
DosExit(1,0);
break;
case IDM_HELPHELPFORHELP:
HelpHelpForHelp(/*mp2*/);
break;
case IDM_HELPEXTENDED:
HelpExtended(/*mp2*/);
break;
#ifdef WORKS
case IDM_HELPKEYS:
HelpKeys(/*mp2*/);
break;
#endif
case HM_QUERY_KEYS_HELP:
return (PANEL_KEYSHELP);
case IDM_HELPINDEX:
HelpIndex(/*mp2*/);
break;
case IDM_HELPPRODUCTINFO:
HelpAbout();
break;
}
return 0;
}
VOID InitHelp(VOID)
{
HELPINIT hini;
/* If we return because of an error, Help will be disabled */
fHelpEnabled = FALSE;
/* Initialize help init structure */
hini.cb = sizeof(HELPINIT);
hini.ulReturnCode = 0;
/* If tutorial added, add name here */
hini.pszTutorialName = (PSZ)NULL;
hini.phtHelpTable = (PHELPTABLE)MAKELONG(UCHESS_HELP_TABLE, 0xFFFF);
hini.hmodHelpTableModule = 0;
hini.hmodAccelActionBarModule = 0;
hini.idAccelTable = 0;
hini.idActionBar = 0;
if(!WinLoadString(hab,
0,
IDS_HELPWINDOWTITLE,
HELPLIBRARYNAMELEN,
(PSZ)szWindowTitle))
{
DisplayError("Cannot load help str1");
return;
}
hini.pszHelpWindowTitle = (PSZ)szWindowTitle;
/* If debugging, show panel ids, else don't */
hini.fShowPanelId = CMIC_HIDE_PANEL_ID;
if(!WinLoadString(hab,
0,
IDS_HELPLIBRARYNAME,
HELPLIBRARYNAMELEN,
(PSZ)szLibName))
{
DisplayError("Cannot load str2!");
return;
}
hini.pszHelpLibraryName = (PSZ)szLibName;
/* Creating help instance */
hwndHelpInstance = WinCreateHelpInstance(hab, &hini);
if(hwndHelpInstance == 0L || hini.ulReturnCode)
{
DisplayError("Cannot Create Help!");
return;
}
/* Associate help instance with main frame */
if(!WinAssociateHelpInstance(hwndHelpInstance, hwndFrame))
{
DisplayError("Cannot assoc Help");
return;
}
/* Help manager is successfully initialized so set flag to TRUE */
fHelpEnabled = TRUE;
return;
} /* InitHelp() */
VOID DestroyHelpInstance(VOID)
{
if(hwndHelpInstance != 0L)
{
WinDestroyHelpInstance(hwndHelpInstance);
}
return;
} /* DestroyHelpInstance() */
VOID HelpHelpForHelp(/*MPARAM mp2*/)
{
/* This just displays the system help for help panel */
if(fHelpEnabled)
if((LONG)WinSendMsg(hwndHelpInstance, HM_DISPLAY_HELP,
(MPARAM)0L, (MPARAM)0L))
{
ShowMessage("Help Err");
}
/* This routine currently doesn't use the mp2 parameter but *\
* it is referenced here to prevent an 'Unreferenced Parameter'
\* warning at compile time. */
return;
} /* HelpHelpForHelp() */
VOID HelpExtended(/*MPARAM mp2*/)
{
/* This just displays the system extended help panel */
if(fHelpEnabled)
if((LONG)WinSendMsg(hwndHelpInstance, HM_EXT_HELP,
(MPARAM)0L,(MPARAM)0L))
ShowMessage("Help Err");
/* This routine currently doesn't use the mp2 parameter but *\
* it is referenced here to prevent an 'Unreferenced Parameter'
\* warning at compile time. */
return;
} /* HelpExtended() */
#ifdef WORKS
VOID HelpKeys(/*MPARAM mp2*/)
{
/* This just displays the system keys help panel */
if(fHelpEnabled)
if((LONG)WinSendMsg(hwndHelpInstance, HM_KEYS_HELP,
(MPARAM)0L,(MPARAM)0L))
{
ShowMessage("Help err");
}
/* This routine currently doesn't use the mp2 parameter but *\
* it is referenced here to prevent an 'Unreferenced Parameter'
\* warning at compile time. */
return;
} /* HelpKeys() */
#endif
VOID HelpIndex(/*MPARAM mp2*/)
{
/* This just displays the system help index panel */
if(fHelpEnabled)
if((LONG)WinSendMsg(hwndHelpInstance, HM_HELP_INDEX,
(MPARAM)0L,(MPARAM)0L))
ShowMessage("Help err");
/* This routine currently doesn't use the mp2 parameter but *\
* it is referenced here to prevent an 'Unreferenced Parameter'
\* warning at compile time. */
return;
} /* HelpIndex() */
VOID FixSysMenu(HWND hwndDlg)
{
HWND hwndMenu; /* Handle to system menu */
hwndMenu = WinWindowFromID(hwndDlg, FID_SYSMENU);
WinSendMsg(hwndMenu, /* Delete Restore from the system menu */
MM_DELETEITEM,
MPFROM2SHORT(SC_RESTORE, TRUE),
MPFROMP(NULL));
WinSendMsg(hwndMenu, /* Delete Size from the system menu */
MM_DELETEITEM,
MPFROM2SHORT(SC_SIZE, TRUE),
MPFROMP(NULL));
WinSendMsg(hwndMenu, /* Delete Minimize from the system menu */
MM_DELETEITEM,
MPFROM2SHORT(SC_MINIMIZE, TRUE),
MPFROMP(NULL));
WinSendMsg(hwndMenu, /* Delete Maximize from the system menu */
MM_DELETEITEM,
MPFROM2SHORT(SC_MAXIMIZE, TRUE),
MPFROMP(NULL));
return;
}
void QueryTimeValues(hwnd)
HWND hwnd;
{
char str[48];
sprintf(str,"%d",TCmoves);
WinSetDlgItemText(hwnd,IDC_NUMMOVES,str);
sprintf(str,"%d",TCminutes);
WinSetDlgItemText(hwnd,IDC_NUMMINS,str);
sprintf(str,"%d",MaxSearchDepth);
WinSetDlgItemText(hwnd,IDC_DEPTH,str);
if (!TCflag)
{
WinSendDlgItemMsg(hwnd,IDC_FIXEDDEPTH,BM_SETCHECK,MPFROM2SHORT(TRUE,0),NULL);
}
if (!flag.easy)
{
WinSendDlgItemMsg(hwnd,IDC_EASY,BM_SETCHECK,MPFROM2SHORT(TRUE,0),NULL);
}
if (Book)
{
WinSendDlgItemMsg(hwnd,IDC_BOOK,BM_SETCHECK,MPFROM2SHORT(TRUE,0),NULL);
}
}
void QueryPromoteValues(hwnd)
HWND hwnd;
{
WinSendDlgItemMsg(hwnd,IDC_QUEEN,BM_SETCHECK,MPFROM2SHORT(TRUE,0),NULL);
}
void QueryPlayerValues(hwnd)
HWND hwnd;
{
if (SupervisorMode)
{
WinSendDlgItemMsg(hwnd,IDC_NEITHER,BM_SETCHECK,MPFROM2SHORT(TRUE,0),NULL);
}
else if (flag.bothsides)
{
WinSendDlgItemMsg(hwnd,IDC_BOTH,BM_SETCHECK,MPFROM2SHORT(TRUE,0),NULL);
}
else if (opponent == white)
{
WinSendDlgItemMsg(hwnd,IDC_BLACK,BM_SETCHECK,MPFROM2SHORT(TRUE,0),NULL);
}
else if (opponent == black)
{
WinSendDlgItemMsg(hwnd,IDC_WHITE,BM_SETCHECK,MPFROM2SHORT(TRUE,0),NULL);
}
}
void QuerySkillValues(hwnd)
HWND hwnd;
{
if (PlayMode == 0)
{
WinSendDlgItemMsg(hwnd,IDC_BEGIN,BM_SETCHECK,MPFROM2SHORT(TRUE,0),NULL);
}
else if (PlayMode == 1)
{
WinSendDlgItemMsg(hwnd,IDC_INTER,BM_SETCHECK,MPFROM2SHORT(TRUE,0),NULL);
}
else if (PlayMode == 2)
{
WinSendDlgItemMsg(hwnd,IDC_ADVAN,BM_SETCHECK,MPFROM2SHORT(TRUE,0),NULL);
}
}
MRESULT EXPENTRY TimeControlFunc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
MRESULT checked,hard,tmpbk;
char str[64],str2[64],str3[64];
int dun;
MRESULT sRC;
switch(msg)
{
case WM_INITDLG:
FixSysMenu(hwnd);
QueryTimeValues(hwnd);
return (MRESULT)0L;
case WM_COMMAND:
WinQueryDlgItemText(hwnd,IDC_NUMMOVES,64,str);
WinQueryDlgItemText(hwnd,IDC_NUMMINS,64,str2);
WinQueryDlgItemText(hwnd,IDC_DEPTH,64,str3);
checked = WinSendDlgItemMsg(hwnd,IDC_FIXEDDEPTH,BM_QUERYCHECK,NULL,NULL);
hard = WinSendDlgItemMsg(hwnd,IDC_EASY,BM_QUERYCHECK,NULL,NULL);
tmpbk = WinSendDlgItemMsg(hwnd,IDC_BOOK,BM_QUERYCHECK,NULL,NULL);
WinDismissDlg(hwnd, TRUE);
if (((tmpbk)&&(!Book))||((!tmpbk)&&(Book)))
{
Book = Book ? 0 : BOOKFAIL;
bookflag = Book;
}
if (hard)
{
flag.easy = 0;
}
else
{
flag.easy = 1;
}
if (checked)
TCflag = false;
else
TCflag = true;
if (TCflag)
{
MaxSearchDepth = MAXDEPTH;
strcat(str," ");
strcat(str,str2);
TCflag = true;
SelectLevel(str);
et = 0;
dun = player;
player = white;
UpdateClocks();
player = black;
UpdateClocks();
player = dun;
}
else
{
TCminutes = 10;
TCmoves = 60;
MaxSearchDepth = atoi(str3);
if (MaxSearchDepth < 2)
MaxSearchDepth = 2;
if (MaxSearchDepth > MAXDEPTH)
MaxSearchDepth = MAXDEPTH;
}
return (MRESULT)0L;
default:
sRC = WinDefDlgProc(hwnd, msg, mp1, mp2);
return sRC;
}
}
MRESULT EXPENTRY SetPlayersFunc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
MRESULT checked[4];
MRESULT sRC;
switch(msg)
{
case WM_INITDLG:
FixSysMenu(hwnd);
QueryPlayerValues(hwnd);
return (MRESULT)0L;
case WM_COMMAND:
checked[0] = WinSendDlgItemMsg(hwnd,IDC_BLACK,BM_QUERYCHECK,NULL,NULL);
checked[1] = WinSendDlgItemMsg(hwnd,IDC_WHITE,BM_QUERYCHECK,NULL,NULL);
checked[2] = WinSendDlgItemMsg(hwnd,IDC_BOTH,BM_QUERYCHECK,NULL,NULL);
checked[3] = WinSendDlgItemMsg(hwnd,IDC_NEITHER,BM_QUERYCHECK,NULL,NULL);
WinDismissDlg(hwnd, TRUE);
if (checked[3]) // supervisor
{
if (!SupervisorMode)
{
flag.force = false;
flag.bothsides = 0;
ShowMessage("mode set");
ShowMessage("Supervsr");
DoSuper();
}
}
else if (checked[0])
{
flag.force = false;
if (SupervisorMode)
flag.easy = oldflageasy;
SupervisorMode = 0;
flag.bothsides = 0;
if (opponent != white)
{ // switch
strcpy(lOpEntryStr,"switch");
strcpy(OpEntryStr,"switch");
opindex = 0;
ReturnHit = 1;
}
}
else if (checked[1])
{
flag.force = false;
if (SupervisorMode)
flag.easy = oldflageasy;
SupervisorMode = 0;
flag.bothsides = 0;
if (opponent != black)
{ // switch
strcpy(lOpEntryStr,"switch");
strcpy(OpEntryStr,"switch");
opindex = 0;
ReturnHit = 1;
}
}
else if (checked[2])
{
if (SupervisorMode)
flag.easy = oldflageasy;
SupervisorMode = 0;
strcpy(lOpEntryStr,"both");
strcpy(OpEntryStr,"both");
opindex = 0;
ReturnHit = 1;
ShowMessage("on");
ShowMessage("Autoplay");
#ifdef XXX
WinMessageBox(HWND_DESKTOP,hwnd,"Not yet Implemented","Under Construction",0,MB_OK);
#endif
}
return (MRESULT)0L;
default:
sRC = WinDefDlgProc(hwnd, msg, mp1, mp2);
return sRC;
}
}
MRESULT EXPENTRY myFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
PTRACKINFO pti = (PTRACKINFO)mp2;
MRESULT mr;
switch(msg)
{
case WM_QUERYTRACKINFO:
/* first call the original frame window procedure */
mr = (*OldFrameProc)(hwnd,msg,mp1,mp2);
/* restrict maximum SIZE of this window */
pti->ptlMaxTrackSize.x = MaxX;
pti->ptlMaxTrackSize.y = MaxY;
return ((MRESULT)TRUE);
default :
return((MRESULT)(*OldFrameProc)(hwnd,msg,mp1,mp2));
}
// return((MRESULT)FALSE);
}
MRESULT EXPENTRY SkillFunc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
MRESULT checked[4];
MRESULT sRC;
switch(msg)
{
case WM_INITDLG:
FixSysMenu(hwnd);
QuerySkillValues(hwnd);
return (MRESULT)0L;
case WM_COMMAND:
checked[0] = WinSendDlgItemMsg(hwnd,IDC_BEGIN,BM_QUERYCHECK,NULL,NULL);
checked[1] = WinSendDlgItemMsg(hwnd,IDC_INTER,BM_QUERYCHECK,NULL,NULL);
checked[2] = WinSendDlgItemMsg(hwnd,IDC_ADVAN,BM_QUERYCHECK,NULL,NULL);
if (checked[0]) // beginner
{
if (PlayMode != 0)
{
PlayMode = 0;
NewGame();
}
}
else if (checked[1]) // intermed
{
if (PlayMode != 1)
{
PlayMode = 1;
NewGame();
}
}
else if (checked[2]) // advanced
{
if (PlayMode != 2)
{
PlayMode = 2;
NewGame();
}
}
WinDismissDlg(hwnd, TRUE);
return (MRESULT)0L;
default:
sRC = WinDefDlgProc(hwnd, msg, mp1, mp2);
return sRC;
}
}
MRESULT EXPENTRY PromoteFunc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
MRESULT checked[4];
MRESULT sRC;
switch(msg)
{
case WM_INITDLG:
FixSysMenu(hwnd);
QueryPromoteValues(hwnd);
return (MRESULT)0L;
case WM_COMMAND:
checked[0] = WinSendDlgItemMsg(hwnd,IDC_QUEEN,BM_QUERYCHECK,NULL,NULL);
checked[1] = WinSendDlgItemMsg(hwnd,IDC_ROOK,BM_QUERYCHECK,NULL,NULL);
checked[2] = WinSendDlgItemMsg(hwnd,IDC_KNIGHT,BM_QUERYCHECK,NULL,NULL);
checked[3] = WinSendDlgItemMsg(hwnd,IDC_BISHOP,BM_QUERYCHECK,NULL,NULL);
if (checked[0]) // queen
{
global_promote_char = 'q';
}
else if (checked[1]) // rook
{
global_promote_char = 'r';
}
else if (checked[2]) // knight
{
global_promote_char = 'n';
}
else if (checked[3]) // bishop
{
global_promote_char = 'b';
}
WinDismissDlg(hwnd, TRUE);
return (MRESULT)0L;
default:
sRC = WinDefDlgProc(hwnd, msg, mp1, mp2);
return sRC;
}
}
MRESULT EXPENTRY AboutDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
MRESULT sRC;
switch(msg)
{
case WM_INITDLG:
FixSysMenu(hwnd);
return (MRESULT)0L;
case WM_COMMAND:
WinDismissDlg(hwnd, TRUE);
return (MRESULT)0L;
default:
sRC = WinDefDlgProc(hwnd, msg, mp1, mp2);
return sRC;
}
}
VOID HelpAbout()
{
/* Display the AboutBox dialog */
WinDlgBox(HWND_DESKTOP,
hwndClient,
(PFNWP)AboutDlgProc,
0,
IDD_PRODUCTINFO,
(PVOID)NULL);
return;
} /* HelpAbout() */
MRESULT EXPENTRY ClientWndProc(hwnd,msg,mp1,mp2)
HWND hwnd;
ULONG msg;
MPARAM mp1;
MPARAM mp2;
{
int PromoteChar;
POINTL myPoint;
RECTL rc;
HPS hps;
int ch;
POINTL apts[4];
char fname[48];
char mvnstr[64];
int i;
int ycoord;
static int first=1;
APIRET rcd;
int keytype,keycode;
int tmovenum;
int r,c,l,piece,sq;
int tmp1,tmp2;
PSWP pSwp;
switch (msg)
{
case WM_CREATE :
WinNotInited = 0;
break;
case WM_MINMAXFRAME:
pSwp = (PSWP)mp1;
if ( (pSwp) && (pSwp->fl & SWP_MAXIMIZE) )
{
pSwp->cx = MaxX;
pSwp->cy = MaxY;
return (MRESULT)TRUE;
}
else
{
return( WinDefWindowProc(hwnd,msg,mp1,mp2) );
}
case WM_COMMAND:
if (flag.bothsides)
{
ShowMessage("off");
ShowMessage("Autoplay");
flag.back = true;
flag.bothsides = false;
DosSleep(600);
DrawAmigaBoard();
break;
}
MainCommand(hwnd, mp1/*, mp2*/);
break;
case WM_BUTTON1DOWN:
if (WinQueryActiveWindow(HWND_DESKTOP) != hwndFrame)
{
return(WinDefWindowProc(hwnd,msg,mp1,mp2));
}
if (flag.bothsides)
{
ShowMessage("off");
ShowMessage("Autoplay");
flag.back = true;
flag.bothsides = false;
DosSleep(600);
DrawAmigaBoard();
break;
}
if (EditMode)
{ // put piece down
MouseX = MOUSEMSG(&msg)->x;
MouseY = MOUSEMSG(&msg)->y;
if (EditMode == 2)
{
TheBob[CurrBobColor][CurrBobIndex]->XPos = MouseX - 16;
TheBob[CurrBobColor][CurrBobIndex]->YPos = MouseY - 12;
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
EditMode = 1;
}
if (((MouseY >= (ROW1)) && (MouseY <= ROW8B) &&
(MouseX <= (COLH+BOBWIDTH)) && (MouseX >= COLA)))
{ // mouse down in bounds
if (MouseX < COLB)
DestCol = 0;
else if (MouseX < COLC)
DestCol = 1;
else if (MouseX < COLD)
DestCol = 2;
else if (MouseX < COLE)
DestCol = 3;
else if (MouseX < COLF)
DestCol = 4;
else if (MouseX < COLG)
DestCol = 5;
else if (MouseX < COLH)
DestCol = 6;
else
DestCol = 7;
if (MouseY < ROW2)
DestRow = 0;
else if (MouseY < ROW3)
DestRow = 1;
else if (MouseY < ROW4)
DestRow = 2;
else if (MouseY < ROW5)
DestRow = 3;
else if (MouseY < ROW6)
DestRow = 4;
else if (MouseY < ROW7)
DestRow = 5;
else if (MouseY < ROW8)
DestRow = 6;
else
DestRow = 7;
sq = locn (DestRow, DestCol);
if ((CurrBobColor == -1)||(CurrBobIndex == -1))
{
color[sq] = amigacolor[sq] = neutral;
amigaboard[sq] = board[sq] = no_piece;
}
else
{ // bob index good
color[sq] = amigacolor[sq] = CurrBobColor;
switch (CurrBobIndex)
{
case KINGBOB : amigaboard[sq] = board[sq] = king;break;
case QUEENBOB : amigaboard[sq] = board[sq] = queen;break;
case ROOKBOB : amigaboard[sq] = board[sq] = rook;break;
case BISHOPBOB : amigaboard[sq] = board[sq] = bishop;break;
case KNIGHTBOB : amigaboard[sq] = board[sq] = knight;break;
case PAWNBOB : amigaboard[sq] = board[sq] = pawn;break;
default : color[sq] = amigacolor[sq] = neutral;board[sq] = amigaboard[sq] = no_piece;break;
}
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
DosSleep(100);
} // bobindex good
} // mouse down in bounds
DrawAmigaBoard();
DosSleep(100);
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
{
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
}
break;
}
if ((!ButtonDown) &&(!(flag.quit || flag.mate || flag.force))
&&(!RealThink))
{
MouseX = MOUSEMSG(&msg)->x;
MouseY = MOUSEMSG(&msg)->y;
if (((MouseY >= (ROW1)) && (MouseY <= ROW8B) &&
(MouseX <= (COLH+BOBWIDTH)) && (MouseX >= COLA)))
{
if (MouseX < COLB)
OrigCol = 0;
else if (MouseX < COLC)
OrigCol = 1;
else if (MouseX < COLD)
OrigCol = 2;
else if (MouseX < COLE)
OrigCol = 3;
else if (MouseX < COLF)
OrigCol = 4;
else if (MouseX < COLG)
OrigCol = 5;
else if (MouseX < COLH)
OrigCol = 6;
else
OrigCol = 7;
if (MouseY < ROW2)
OrigRow = 0;
else if (MouseY < ROW3)
OrigRow = 1;
else if (MouseY < ROW4)
OrigRow = 2;
else if (MouseY < ROW5)
OrigRow = 3;
else if (MouseY < ROW6)
OrigRow = 4;
else if (MouseY < ROW7)
OrigRow = 5;
else if (MouseY < ROW8)
OrigRow = 6;
else
OrigRow = 7;
r = OrigRow;
c = OrigCol;
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if ((amigacolor[l] == neutral)||(opponent != amigacolor[l]))
{
return(WinDefWindowProc(hwnd,msg,mp1,mp2));
//break;
}
else if (amigacolor[l] == white)
piece = qxx[amigaboard[l]]; /* white are lower case pieces */
else
piece = pxx[amigaboard[l]]; /* black are upper case pieces */
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[OrigCol]; // tgt left bottom
apts[0].y = RowArray[OrigRow]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
tmp1 = OrigRow & 1;
tmp2 = OrigCol & 1;
rcd = DosRequestMutexSem(DrawSemaphore,3000);
if (rcd)
return(FALSE);
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
GpiSetBitmap(hpsMemory,WhiteBitMap);
}
else
{
GpiSetBitmap(hpsMemory,BlackBitMap);
}
GpiBitBlt(hwClientPS,hpsMemory,4,(PPOINTL)apts,ROP_SRCCOPY,BBO_IGNORE);
DosReleaseMutexSem(DrawSemaphore);
LoadBobImage(piece);
TheBob[CurrBobColor][CurrBobIndex]->XPos = MouseX - 16;
TheBob[CurrBobColor][CurrBobIndex]->YPos = MouseY - 12;
//#ifdef OKTODRAW
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
//#endif // OK to draw
CheckIllegal = IllegalMove = 0;
ButtonDown = 1;
} // mouse in bounds
} // no special conditions
break;
case WM_BUTTON1UP:
if ((ButtonDown) &&(!(flag.quit || flag.mate || flag.force))
&&(!RealThink))
{
ButtonDown = 0;
MouseX = MOUSEMSG(&msg)->x;
MouseY = MOUSEMSG(&msg)->y;
if (((MouseY >= (ROW1)) && (MouseY <= ROW8B) &&
(MouseX <= (COLH+BOBWIDTH)) && (MouseX >= COLA)))
{ // mouse down in bounds
if (MouseX < COLB)
DestCol = 0;
else if (MouseX < COLC)
DestCol = 1;
else if (MouseX < COLD)
DestCol = 2;
else if (MouseX < COLE)
DestCol = 3;
else if (MouseX < COLF)
DestCol = 4;
else if (MouseX < COLG)
DestCol = 5;
else if (MouseX < COLH)
DestCol = 6;
else
DestCol = 7;
if (MouseY < ROW2)
DestRow = 0;
else if (MouseY < ROW3)
DestRow = 1;
else if (MouseY < ROW4)
DestRow = 2;
else if (MouseY < ROW5)
DestRow = 3;
else if (MouseY < ROW6)
DestRow = 4;
else if (MouseY < ROW7)
DestRow = 5;
else if (MouseY < ROW8)
DestRow = 6;
else
DestRow = 7;
if ((DestRow == OrigRow)&&(DestCol == OrigCol))
{
//#ifdef OKTODRAW
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
//#endif
CheckIllegal = 1;
PutPieceBack();
}
else
{ // try to do the move
CheckIllegal = 1;
//#ifdef OKTODRAW
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
//#endif
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[DestCol]; // tgt left bottom
apts[0].y = RowArray[DestRow]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
tmp1 = DestRow & 1;
tmp2 = DestCol & 1;
rcd = DosRequestMutexSem(DrawSemaphore,3000);
if (rcd)
return(FALSE);
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
GpiSetBitmap(hpsMemory,WhiteBitMap);
}
else
{
GpiSetBitmap(hpsMemory,BlackBitMap);
}
GpiBitBlt(hwClientPS,hpsMemory,4,(PPOINTL)apts,ROP_SRCCOPY,BBO_IGNORE);
DosReleaseMutexSem(DrawSemaphore);
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = BOBWIDTH - 1; // src rt top
apts[3].y = BOBHEIGHT - 1; // src rt top
apts[0].x = ColArray[DestCol]; // tgt left bottom
apts[0].y = RowArray[DestRow]; // tgt left bottom
apts[1].x = apts[0].x + BOBWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + BOBHEIGHT - 1; // tgt rt top
r = OrigRow;
c = OrigCol;
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if (amigacolor[l] == white)
piece = qxx[amigaboard[l]]; /* white are lower case pieces */
else if (amigacolor[l] == black)
piece = pxx[amigaboard[l]]; /* black are upper case pieces */
else
piece = BLANKDATA;
if (piece != BLANKDATA)
{
LoadBobImage(piece);
TransBlit2(TheBob[CurrBobColor][CurrBobIndex],hwClientPS,hpsMemory,4L,(PPOINTL)apts);
}
MouseDropped = 1;
if (((piece == 'p')&&(DestRow == 7))||/* possible prom wht */
((piece == 'P')&&(!DestRow))) /* possible blk promotion */
{
PromoteChar = DisplayPromoteRequestor();
}
else
{
PromoteChar = 0;
}
if (computer == white)
{
tmovenum = (myGameCnt)>>1;
}
else
{
tmovenum = (myGameCnt+1)>>1; // was +2
}
tmovenum++;
lOpEntryStr[0] = OrigCol + 'a';
lOpEntryStr[1] = OrigRow + '1';
lOpEntryStr[2] = DestCol + 'a';
lOpEntryStr[3] = DestRow + '1';
lOpEntryStr[4] = PromoteChar;
lOpEntryStr[5] = 0;
mysprintf(mvnstr,"%d: ",tmovenum);
strcat(mvnstr,lOpEntryStr);
strcpy(OpEntryStr,lOpEntryStr);
opindex = 0;
myPoint.x = 520;
myPoint.y = USERBOX-10;
rc.xLeft = 520;
rc.yBottom = myPoint.y-4;
rc.xRight = 621;
rc.yTop = rc.yBottom + 14 + 4;
rcd = DosRequestMutexSem(DrawSemaphore,2000);
if (!rcd)
{
WinFillRect(hwClientPS,&rc,BACKGNDTEXTCOLOR);
GpiCharStringAt(hwClientPS, &myPoint, strlen(mvnstr),
(PSZ)mvnstr);
DosReleaseMutexSem(DrawSemaphore);
}
if ((thinkahead)&&(!flag.bothsides))
{ // code to abort quickly and drop piece!
if (!TCflag)
backsrchaborted = 1;
if (!flag.timeout)
{
flag.back = true;
}
} // code to abort
ReturnHit = 1;
} // try to do the move
} // mouse down in bounds
else // mouse out of bounds
{
//#ifdef OKTODRAW
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
//#endif
CheckIllegal = 1;
DestRow = -1;
DestCol = -1;
PutPieceBack();
} // mouse out of bounds
}
break;
case WM_MOUSEMOVE:
if (((ButtonDown) &&(!(flag.quit || flag.mate || flag.force))
&&(!RealThink))||(EditMode))
{
if ((CurrBobColor == -1)||(CurrBobIndex == -1))
break;
MouseX = MOUSEMSG(&msg)->x;
MouseY = MOUSEMSG(&msg)->y;
tmp1 = TheBob[CurrBobColor][CurrBobIndex]->XPos - 16;
tmp1 = TheBob[CurrBobColor][CurrBobIndex]->YPos - 12;
tmp1 = abs(tmp1 - MouseX);
tmp2 = abs(tmp2 - MouseY);
if (((tmp2 > 3)||(tmp2 > 3))||(EditMode == 2))
{
TheBob[CurrBobColor][CurrBobIndex]->XPos = MouseX - 16;
TheBob[CurrBobColor][CurrBobIndex]->YPos = MouseY - 12;
if (EditMode == 2)
{
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
EditMode = 1;
}
DrawGList();
}
}
break;
case WM_CHAR:
if (flag.bothsides)
{
ShowMessage("off");
ShowMessage("Autoplay");
flag.back = true;
flag.bothsides = false;
DosSleep(600);
DrawAmigaBoard();
break;
}
keytype = SHORT1FROMMP(mp1);
if (keytype & KC_CHAR)
{
keycode =SHORT1FROMMP(mp2);
ch = tolower(keycode);
if (EditMode)
{ // change bob or just exit edit mode
if (ch == 'x')
{
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
EditMode = 0;
ShowMessage("Edit off");
DestRow = DestCol = 0;
for (sq = 0; sq < 64; sq++)
{
if ((board[sq] == king)&&(color[sq] == white))
{
if (DestRow)
{
color[sq] = neutral;
board[sq] = no_piece;
}
DestRow = 1;
}
if ((board[sq] == king)&&(color[sq] == black))
{
if (DestCol)
{
color[sq] = neutral;
board[sq] = no_piece;
}
DestCol = 1;
}
}
if ((!DestCol)||(!DestRow))
{
for(i=0;i<64;i++)
{
color[i] = neutral;
board[i] = no_piece;
}
color[8] = white;
board[8] = pawn;
color[62-8] = black;
board[62-8] = pawn;
color[0] = white;
board[0] = king;
color[62] = black;
board[62] = king;
}
for (sq = 0; sq < 64; sq++)
Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
flag.regularstart = false;
Book = 0;
GameCnt = 0;
Game50 = 1;
ISZERO = 1;
ZeroRPT ();
Sdepth = 0;
InitializeStats ();
MoveMem128(board,amigaboard);
MoveMem128(color,amigacolor);
DrawAmigaBoard();
break;
} // ch == 'x'
switch (keycode)
{
case 'p':
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
TheBob[white][PAWNBOB]->XPos = MouseX;
TheBob[white][PAWNBOB]->YPos = MouseY;
CurrBobColor = white;
CurrBobIndex = PAWNBOB;
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
break;
case 'P':
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
TheBob[black][PAWNBOB]->XPos = MouseX;
TheBob[black][PAWNBOB]->YPos = MouseY;
CurrBobColor = black;
CurrBobIndex = PAWNBOB;
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
break;
case 'n':
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
TheBob[white][KNIGHTBOB]->XPos = MouseX;
TheBob[white][KNIGHTBOB]->YPos = MouseY;
CurrBobColor = white;
CurrBobIndex = KNIGHTBOB;
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
break;
case 'N':
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
TheBob[black][KNIGHTBOB]->XPos = MouseX;
TheBob[black][KNIGHTBOB]->YPos = MouseY;
CurrBobColor = black;
CurrBobIndex = KNIGHTBOB;
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
break;
case 'b':
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
TheBob[white][BISHOPBOB]->XPos = MouseX;
TheBob[white][BISHOPBOB]->YPos = MouseY;
CurrBobColor = white;
CurrBobIndex = BISHOPBOB;
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
break;
case 'B':
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
TheBob[black][BISHOPBOB]->XPos = MouseX;
TheBob[black][BISHOPBOB]->YPos = MouseY;
CurrBobColor = black;
CurrBobIndex = BISHOPBOB;
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
break;
case 'r':
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
TheBob[white][ROOKBOB]->XPos = MouseX;
TheBob[white][ROOKBOB]->YPos = MouseY;
CurrBobColor = white;
CurrBobIndex = ROOKBOB;
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
break;
case 'R':
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
TheBob[black][ROOKBOB]->XPos = MouseX;
TheBob[black][ROOKBOB]->YPos = MouseY;
CurrBobColor = black;
CurrBobIndex = ROOKBOB;
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
break;
case 'q':
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
TheBob[white][QUEENBOB]->XPos = MouseX;
TheBob[white][QUEENBOB]->YPos = MouseY;
CurrBobColor = white;
CurrBobIndex = QUEENBOB;
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
break;
case 'Q':
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
TheBob[black][QUEENBOB]->XPos = MouseX;
TheBob[black][QUEENBOB]->YPos = MouseY;
CurrBobColor = black;
CurrBobIndex = QUEENBOB;
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
break;
case 'k':
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
TheBob[white][KINGBOB]->XPos = MouseX;
TheBob[white][KINGBOB]->YPos = MouseY;
CurrBobColor = white;
CurrBobIndex = KINGBOB;
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
break;
case 'K':
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
TheBob[black][KINGBOB]->XPos = MouseX;
TheBob[black][KINGBOB]->YPos = MouseY;
CurrBobColor = black;
CurrBobIndex = KINGBOB;
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
break;
case ' ':
if ((CurrBobColor != -1)&&(CurrBobIndex != -1))
RemBob(TheBob[CurrBobColor][CurrBobIndex]);
CurrBobColor = -1;
CurrBobIndex = -1;
break;
case 9: // tab clear the board
for (sq = 0; sq < 64; sq++)
{
board[sq] = no_piece;
color[sq] = neutral;
}
MoveMem128(board,amigaboard);
MoveMem128(color,amigacolor);
DrawAmigaBoard();
DrawGList();
break;
} // switch
break;
} // edit mode
if (((ch >= 'a')&&(ch <= 'z'))||((ch >= '0')&&(ch <= '9'))||(ch == '-'))
{
if (opindex < 12)
{
lOpEntryStr[opindex++] = ch;
lOpEntryStr[opindex] = 0;
}
}
else if (( ch == 8)&&(opindex))
{
opindex--;
lOpEntryStr[opindex] = 0;
}
else if (((ch == 10)||(ch == 13))&&(opindex)&&(!RealThink))
{
MouseDropped = 0;
strcpy(OpEntryStr,lOpEntryStr);
opindex = 0;
ReturnHit = 1;
break;
}
if (computer == white)
{
tmovenum = (myGameCnt)>>1;
}
else
{
tmovenum = (myGameCnt+1)>>1; // was +2
}
tmovenum++;
mysprintf(mvnstr,"%d: ",tmovenum);
strcat(mvnstr,lOpEntryStr);
myPoint.x = 520;
myPoint.y = USERBOX-10;
rc.xLeft = 520;
rc.yBottom = myPoint.y-4;
rc.xRight = 621;
rc.yTop = rc.yBottom + 14 + 4;
rcd = DosRequestMutexSem(DrawSemaphore,2000);
if (!rcd)
{
WinFillRect(hwClientPS,&rc,BACKGNDTEXTCOLOR);
GpiCharStringAt(hwClientPS, &myPoint, strlen(mvnstr),
(PSZ)mvnstr);
DosReleaseMutexSem(DrawSemaphore);
}
} // normal key pressed
break;
case WM_PAINT:
rcd = DosRequestMutexSem(DrawSemaphore,1000L);
if (rcd)
return(FALSE);
if (first)
{
first = 0;
hps = WinBeginPaint( hwnd, (HPS)NULL, &rc );
WinEndPaint( hps );
DosReleaseMutexSem(DrawSemaphore);
return((MRESULT)FALSE);
}
hps = WinBeginPaint( hwnd, (HPS)NULL, &rc );
if (!LoadFullBitmap(hps,NULL,FALSE,BigColorPalette))
{
return(FALSE);
}
DosSleep(34);
DrawChessPieces(hps);
if ((EditMode == 1)&&(CurrBobIndex != -1)&&(CurrBobColor != -1))
{
TheBob[CurrBobColor][CurrBobIndex]->OldX =
TheBob[CurrBobColor][CurrBobIndex]->OldY = -1;
EditMode = 2;
SystemBobList = NULL;
}
strcpy(fname,UC_Title);
myPoint.x = 511;
myPoint.y = COMPUTERBOX+10;
GpiCharStringAt(hps, &myPoint, strlen(fname),
(PSZ)fname);
myPoint.x = 511;
myPoint.y = USERBOX+10;
strcpy(fname,"Puny Human:");
GpiCharStringAt(hps, &myPoint, strlen(fname),
(PSZ)fname);
if (hum_min != -1)
{
mysprintf2(fname,"%d:%02d ",hum_min,hum_sec);
myPoint.x = 540;
myPoint.y = TIMEYCOORD2+6;
GpiCharStringAt(hps,&myPoint,strlen(fname),(PSZ)fname);
mysprintf2(fname,"%d:%02d ",cmptr_min,cmptr_sec);
myPoint.x = 540;
myPoint.y = TIMEYCOORD1+6;
GpiCharStringAt(hps,&myPoint,strlen(fname),(PSZ)fname);
}
ycoord = SYSTEMBOX-2; // was - 6
myPoint.x = 510;
for(i=0;i<8;i++)
{
if (MsgBuf[i][0])
{
myPoint.y = ycoord;
GpiCharStringAt(hps,&myPoint,strlen(MsgBuf[i]),(PSZ)MsgBuf[i]);
ycoord -= 15;
}
}
WinEndPaint( hps );
DosReleaseMutexSem(DrawSemaphore);
if (EditMode)
DosSleep(300);
break;
case WM_ERASEBACKGROUND:
// Return TRUE to cause PM to paint the window background
// in SYSCLR_WINDOW.
return (MRESULT)( TRUE );
case WM_SIZE:
cxClient = SHORT1FROMMP( mp2 );
GotSize = 1;
cyClient = SHORT2FROMMP( mp2 );
break;
default:
return(WinDefWindowProc(hwnd,msg,mp1,mp2));
} // switch msg
return((MRESULT)FALSE);
}
void mysprintf(char *,char *,int);
void mysprintf2(char *,char *,int,int);
// >>should be OK for PM<<
void SetTimeControl2 (color)
int color;
{
int tmp;
int other;
other = color ^ 1;
if (TCflag)
{
TimeControl.moves[color] = TCmoves;
TimeControl.clock[color] += (6000L * TCminutes + TCseconds * 100);
tmp = (TCminutes*60+TCseconds)/TCmoves;
if (color == computer)
{
SecsPerMove = tmp;
if (tmp < 10)
{
GlobalTgtDepth = 3; // was 2
}
else if (tmp < 180)
{
GlobalTgtDepth = 4; // was 3
}
else
GlobalTgtDepth = 5; // was 4
}
TimeControl.moves[other] = TCmoves;
TimeControl.clock[other] += (6000L * TCminutes + TCseconds * 100);
tmp = (TCminutes*60+TCseconds)/TCmoves;
if (other == computer)
{
SecsPerMove = tmp;
if (tmp < 10)
{
GlobalTgtDepth = 3; // was 2
}
else if (tmp < 180)
{
GlobalTgtDepth = 4; // was 3
}
else
GlobalTgtDepth = 5; // was 4
}
}
else
{
TimeControl.moves[color] = 0;
TimeControl.clock[color] = 0;
TimeControl.moves[other] = 0;
TimeControl.clock[other] = 0;
}
flag.onemove = (TCmoves == 1);
et = 0;
ElapsedTime (1);
}
#ifdef AMIGA
void DoEasy()
{
PlayMode = 0;
//Bob->XPos = WIDTH-1-BOBWIDTH;
//Bob->YPos = HEIGHT-1-BOBHEIGHT;
//RemBob(TheBob[CurrBobColor][CurrBobIndex]);
NewGame();
}
void DoAdvanced()
{
PlayMode = 2;
// RemBob(TheBob[CurrBobColor][CurrBobIndex]);
// BobVSprite->X = WIDTH-1-BOBWIDTH;
// BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
// LoadBobImage(BLANKDATA);
// if (SYSTEM_BOBS)
// {
// SortGList(rpG);
// DrawGList(rpG,vP);
// }
// MakeVPort(GfxBase->ActiView,vP);
// MrgCop(GfxBase->ActiView);
// WaitTOF();
// RethinkDisplay();
NewGame();
}
void DoIntermediate()
{
PlayMode = 1;
// RemBob(TheBob[CurrBobColor][CurrBobIndex]);
// BobVSprite->X = WIDTH-1-BOBWIDTH;
// BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
// LoadBobImage(BLANKDATA);
// if (SYSTEM_BOBS)
// {
// SortGList(rpG);
// DrawGList(rpG,vP);
// }
// MakeVPort(GfxBase->ActiView,vP);
// MrgCop(GfxBase->ActiView);
// WaitTOF();
// RethinkDisplay();
NewGame();
f}
#endif // amiga
void mysprintf(ostr,fstr,num)
char *ostr,*fstr;
int num;
{ // formats string "%d: xxx"
int index;
int thou,hun,ten,one,rem;
if (num < 0)
{
num = -num;
index = 1;
strcpy(ostr,"-");
}
else
{
index = 0;
ostr[0] = 0;
}
thou = num / 1000;
rem = num-(num / 1000)*1000;
hun = (rem / 100);
rem = rem-(hun * 100);
ten = rem / 10;
rem = rem-(ten * 10);
one = rem;
if (thou)
{
ostr[index++] = thou+'0';
}
if ((hun)||(thou))
{
ostr[index++] = hun+'0';
}
if ((ten)||(hun)||(thou))
{
ostr[index++] = ten+'0';
}
ostr[index++] = one+'0';
ostr[index] = 0;
strcat(ostr,&fstr[2]);
}
void mysprintf2(ostr,fstr,num,num2)
char *ostr,*fstr;
int num,num2;
{ // formats string "%d: xxx"
int index;
int thou,hun,ten,one,rem;
if (num < 0)
{
num = -num;
index = 1;
strcpy(ostr,"-");
}
else
{
index = 0;
ostr[0] = 0;
}
thou = num / 1000;
rem = num-(num / 1000)*1000;
hun = (rem / 100);
rem = rem-(hun * 100);
ten = rem / 10;
rem = rem-(ten * 10);
one = rem;
if (thou)
{
ostr[index++] = thou+'0';
}
if ((hun)||(thou))
{
ostr[index++] = hun+'0';
}
if ((ten)||(hun)||(thou))
{
ostr[index++] = ten+'0';
}
ostr[index++] = one+'0';
ostr[index++] = ':';
ten = num2 / 10;
one = num2 % 10;
ostr[index++] = ten+'0';
ostr[index++] = one+'0';
ostr[index] = 0;
strcat(ostr,&fstr[7]);
}
void
gsrand (unsigned int seed);
void calc_pgm_rating()
{
/* 34 secs on an RS/6000 which is about 2338, so to rate itself
rating = 2338 - 75*(log2(time) - log2(34)) */
unsigned long st;
unsigned long endst;
double secs;
int rating;
int tmpbk,Old,oldtc;
int OldPM;
char tstr[32],tstr2[32];
OldPM = PlayMode;
PlayMode = 2;
tmpbk = Book;
oldtc = TCflag;
Old = MaxSearchDepth;
NewGame ();
UpdateDisplay (0, 0, 1, 0);
MaxSearchDepth = 6;
Book = 0;
TCflag = 0;
computer = computer ^ 1;
opponent = opponent ^ 1;
xwndw = (computer == white) ? WXWNDW : BXWNDW;
flag.force = false;
Sdepth = 0;
ShowMessage("Calculating.");
ShowMessage("Please wait.");
// SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
flag.beep = 0;
st = clock();
SelectMove (computer, 1);
endst = clock();
secs = (endst - st);
secs = secs / CLOCKS_PER_SEC;
st = secs;
// ClearPointer(wG);
if (st<4)
st = 4;
st = (st - 2)/6;
if (st > 200)
{
strcpy(tstr,"too slow Cannot rate");
}
else
{
if (st < 4)
st = 4;
#ifdef PL_60
rating = 2350 - (((75*log_e[st]) - (75*LOGE_34))/LN2);
#else /* patch level 61 */
rating = 2350 - (((75*log_e[st]) - (75*LOGE_16))/LN2);
#endif
rating -= 40;
sprintf(tstr,"USCF %04d",rating);
}
Book = tmpbk;
MaxSearchDepth = Old;
TCflag = oldtc;
PlayMode = OldPM;
NewGame ();
UpdateDisplay (0, 0, 1, 0);
sprintf(tstr2,"%1.2lf secs",secs);
ShowMessage(tstr2);
ShowMessage(tstr);
}
int DoResign()
{
ULONG response;
// struct EasyStruct resignES = {
// sizeof (struct EasyStruct),
// 0,
// "Resignation Alert",
// "Accept UChess's Resignation",
// "Yes|No",
// };
//ULONG iflags=0L;
//UCHAR volname[4]={0,0,0,0};
ResignOffered = -1;
response = WinMessageBox(HWND_DESKTOP,hwndClient,"Accept resignation","UChess Resigns",0,MB_YESNO);
if (response == MBID_YES)
return(0xff);
else
return(0);
// Delay(30L);
// DisplayBeep(0L);
/* return 0 if no resign accepted, yes if accepted */
// return(EasyRequest( wG, &resignES, &iflags, volname ));
}
void GetEditText(s,color)
char *s;
int *color;
{ /* gets the edit string from the user */
/* returns # for clr bd, c for change colors and pa1 to put a pawn at a1*/
/* YOU MUST RETURN THE STRING IN ALL LOWER CASE! */
if (*color == white)
s[0] = 0; // to shut up compiler for now
#ifdef NEEDTODO
int dun;
long code,class;
int i;
APTR object;
struct IntuiMessage *message;
dun = 0;
s[0] = 0;
pppSIBuff[0] = '\0';
ActivateGadget(&pGadget1,wGEdit,NULL);
do {
WaitPort(wGEdit->UserPort);
while(message = (struct IntuiMessage *)GetMsg(wGEdit->UserPort))
{
code = message->Code;
object = message->IAddress;
class = message->Class;
ReplyMsg((struct Message *)message);
if (class == CLOSEWINDOW)
{
strcpy(s,".");
dun = 1;
}
else if (class == GADGETUP)
{ /* text */
if (object == (APTR)&pGadget1)
{
if (pppSIBuff[0])
{
dun = 1;
strcpy(s,pppSIBuff);
for(i=0;i<4;i++)
s[i] = tolower(s[i]);
}
}
else if (object == (APTR)&pGadget2)
{
dun = 1;
strcpy(s,"#");
}
else if (object == (APTR)&pGadget3)
{ /* white/black */
if (*color == white)
*color = black;
else
*color = white;
SetDrMd(wGEdit->RPort,JAM1);
SetAPen(wGEdit->RPort,0L);
RectFill(wGEdit->RPort,107,124,167,145);
if (*color == white)
PrintIText(wGEdit->RPort,&pIText2,0L,0L); /* white label */
else
PrintIText(wGEdit->RPort,&pIText2a,0L,0L); /* white label */
}
else if (object == (APTR)&pGadget4)
{ /* done */
strcpy(s,".");
dun = 1;
}
}
}
} while (!dun);
DisplayBeep(0L);
#endif // NEEDTODO
}
void CloseAmigaEditWindow()
{
#ifdef NEEDTODO
struct IntuiMessage *message;
while(message = (struct IntuiMessage *)GetMsg(wGEdit->UserPort))
{
ReplyMsg((struct Message *)message);
}
CloseWindow(wGEdit);
// if (DEPTH >= 6)
// {
// SetRGB32(vP,1,tmppal[0],tmppal[1],tmppal[2]);
// }
// else
// {
// SetRGB4(vP,1,((tmppal[0]>>8)&0xf),((tmppal[0]>>4)&0xf),((tmppal[0])&0xf));
// }
#endif //need to do
}
int OpenAmigaEditWindow() /* opens a window for edit board */
{
#ifdef NEEDTODO
if (!(wGEdit = OpenWindow(&pNewWindowStructure1)))
{
DisplayBeep(0L);
return(0);
}
// if (DEPTH >= 6)
// {
// tmppal[0] = BigColorPalette[4];
// tmppal[1] = BigColorPalette[5];
// tmppal[2] = BigColorPalette[6];
// SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
// }
// else
// {
// tmppal[0] = myPalette[1];
// SetRGB4(vP,1,0xa,0xa,0xa);
// }
pppSIBuff[0] = 0;
pppSIBuff[3] = 0;
PrintIText(wGEdit->RPort,&pIText4,0L,0L);
PrintIText(wGEdit->RPort,&pIText2,0L,0L); /* white label */
#endif // NEEDTODO
return(1);
}
#ifdef AMIGA
void EnableMoveNow()
{
if (MenuStripSet)
{
MoveNowOK = 1;
OnMenu(wG,MOVENOWMENUNUM);
}
}
void DisableMoveNow()
{
if (MenuStripSet)
{
MoveNowOK = 0;
OffMenu(wG,MOVENOWMENUNUM);
}
}
#endif
int GetFileName(char *s)
{
HWND hwnd;
FILEDLG myFilD;
HWND hwndDlg;
hwnd = hwndClient;
memset(&myFilD,0,sizeof(FILEDLG));
myFilD.pszTitle = globaltitle;
myFilD.cbSize = sizeof(FILEDLG);
myFilD.fl = FDS_HELPBUTTON | FDS_CENTER; // also FDS_SAVEAS_DIALOG
myFilD.fl |= GlobalFilType;
myFilD.szFullFile[0] = 0;
hwndDlg = WinFileDlg(HWND_DESKTOP,hwnd,&myFilD);
if ((hwndDlg && (myFilD.lReturn == DID_OK)))
{// myFilD.szFullFile has the filename
strcpy(s,myFilD.szFullFile);
return(0xff);
}
return(0);
#ifdef NEEDTODO
int tmp;
struct FileRequester *myFileReq;
struct TagItem Tags[2] = {
{ASLFR_Window,0L},
{0,0}
};
Tags[0].ti_Data = (ULONG)wG;
myFileReq = AllocAslRequest(ASL_FileRequest,Tags);
if (myFileReq)
{
tmp = AslRequest(myFileReq,Tags);
if (!tmp)
{
FreeAslRequest(myFileReq);
return(0);
}
strcpy(s,myFileReq->fr_Drawer);
if (s[0])
{
if ((s[strlen(s)-1] != ':')&&(s[strlen(s)-1] != '/'))
{
strcat(s,"/");
}
}
strcat(s,myFileReq->fr_File);
FreeAslRequest(myFileReq);
return(0xff);
}
else
return(0);
#endif
}
#ifdef AMIGA
int GetScreenMode()
{
int tmp;
struct ScreenModeRequester *myScreenReq;
struct TagItem Tags[4] = {
{ASLSM_InitialDisplayID,HIRES|LACE|DEFAULT_MONITOR_ID},
{ASLSM_InitialAutoScroll,FALSE},
{0,0}
};
myScreenReq = AllocAslRequest(ASL_ScreenModeRequest,0L);
if (myScreenReq)
{
tmp = AslRequest(myScreenReq,Tags);
if (!tmp)
{
FreeAslRequest(myScreenReq);
return(0);
}
RTG_ModeID = myScreenReq->sm_DisplayID;
FreeAslRequest(myScreenReq);
return(0xff);
}
else
return(0);
}
#endif // AMIGA
void
UpdateClocks (void)
{
POINTL myPoint;
char tempstr[16];
APIRET rc;
long ycoord;
INTSIZE ref_min,ref_sec;
ULONG max_time;
INTSIZE m, s;
RECTL myRect;
int score_diff;
m = (INTSIZE) (et / 6000);
s = (INTSIZE) (et - 6000 * (long) m) / 100;
if (TCflag)
{
m = (INTSIZE) ((TimeControl.clock[player] - et) / 6000);
s = (INTSIZE) ((TimeControl.clock[player] - et - 6000 * (long) m) / 100);
}
if (m < 0)
m = 0;
if (s < 0)
s = 0;
if (player == computer)
{
ref_min = cmptr_min;
ref_sec = cmptr_sec;
ycoord = TIMEYCOORD1;
}
else
{
ref_min = hum_min;
ref_sec = hum_sec;
ycoord = TIMEYCOORD2;
}
if ((ref_min != m)||(ref_sec != s))
{
mysprintf2(tempstr,"%d:%02d ",m,s);
rc = DosRequestMutexSem(DrawSemaphore,5000);
if (rc)
{
return;
}
//Move(rpG,540,ycoord);
//mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
//RectFill(rpG,540,ycoord-6,621,ycoord+5);
//mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
#ifdef AMIGA
Move(rpG,540,ycoord);
Text(rpG,tempstr,strlen(tempstr));
#else
myRect.xLeft = 540;
myRect.yBottom = ycoord+6;
myRect.xRight = 621;
myRect.yTop = ycoord + 6 + 14;
WinFillRect(hwClientPS,&myRect,BACKGNDTEXTCOLOR);
myPoint.x = 540;
myPoint.y = ycoord+6;
GpiCharStringAt(hwClientPS,&myPoint,strlen(tempstr),(PSZ)tempstr);
#endif
DosReleaseMutexSem(DrawSemaphore);
if (player == computer)
{
score_diff = global_tmp_score - previous_score;
cmptr_min = m;
cmptr_sec = s;
if (TCflag)
{
max_time = s + m*60;
if ((TimeControl.moves[computer] < ((TCmoves/2)-2))&&(Sdepth > GlobalTgtDepth)&&
(score_diff >= -55)&&(ResponseTime < 9999998)&&
(max_time<(((TimeControl.moves[computer]-1)*SecsPerMove)>>1)))
{//have little time available on 2nd half of game
flag.back = true;
}
if ((!m)&&(s <= 1)&&(Sdepth > MINDEPTH))
{
flag.back = true;
}
if ((Sdepth > MINDEPTH)&&(!m)&&
(s<((TimeControl.moves[player]-1)*5)))
{ // less than 1 min left on clock, less than 5 secs/move!
flag.back = true;
}
}
//printf("prev score = %d global_tmp_score = %d\n",previous_score,global_tmp_score);
//printf("score_diff = %d Sdepth = %d GlobalTgtDepth = %d\n",score_diff,Sdepth,GlobalTgtDepth);
if (((score_diff > -16))&&(Sdepth > GlobalTgtDepth)
&&(OrigResponse > 2500)&&(global_tmp_score > -55))
{ // more than 25 secs/move and am not losing by too much
ycoord = OrigResponse >> 1;
if (ycoord > 3101)
ycoord = 3101;
max_time = OrigResponse + ycoord; // 1.5Xorig OR orig + 31 whichver is smaller
//printf("max time = %lu et = %lu\n",max_time,et);
}
else if (Sdepth > (GlobalTgtDepth))
max_time = (OrigResponse<<1) + ExtraTime + 101;
else
max_time = ((OrigResponse<<1) + ExtraTime + OrigResponse);
if ((TCflag) && (!trying_again) && (ResponseTime < 9999998) && (Sdepth > MINDEPTH)
&& ((et) >= max_time))
{
//printf("Considering the move!\n");
if (score_diff >= -75)
{
flag.back = true;
}
}
}
else // human player
{
hum_min = m;
hum_sec = s;
}
} // 1 sec or more has elapsed
}
char DisplayPromoteRequestor()
{
global_promote_char = 'q';
WinDlgBox(HWND_DESKTOP,hwndClient,PromoteFunc,0,IDD_PROMOTE,0);
return(global_promote_char);
#ifdef NEEDTODO
// ULONG tmp[4];
int dun;
struct IntuiMessage *message;
struct Window *wG3;
UWORD code;
ULONG class;
APTR object;
// if (DEPTH >= 6)
// {
// tmp[0] = BigColorPalette[4];
// tmp[1] = BigColorPalette[5];
// tmp[2] = BigColorPalette[6];
// SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
// }
// else
// {
// tmp[0] = myPalette[1];
// SetRGB4(vP,1,0xa,0xa,0xa);
// }
if (!(wG3 = OpenWindow(&NewWindowStructure6)))
{
DisplayBeep(0L);
return('q');
}
PrintIText(wG3->RPort,&aIText5,0L,0L);
dun = 0;
do {
WaitPort(wG3->UserPort);
while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
{
code = message->Code;
object = message->IAddress;
class = message->Class;
ReplyMsg((struct Message *)message);
dun = 1;
if (object == (APTR)&aGadget1)
{
retchar = 'q';
}
else if (object == (APTR)&aGadget2)
{
retchar = 'r';
}
else if (object == (APTR)&aGadget3)
{
retchar = 'b';
}
else if (object == (APTR)&aGadget4)
{
retchar = 'n';
}
}
} while (!dun);
CloseWindow(wG3);
// if (DEPTH >= 6)
// {
// SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
// }
// else
// {
// SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
// }
#endif // NEEDTODO
}
#ifdef AMIGA
void tFreeBitMap(struct BitMap *);
void sFreeBitMap(struct BitMap *);
struct BitMap *tAllocBitMap(int,int,int,int,struct BitMap *);
struct BitMap *sAllocBitMap(int,int,int,int,struct BitMap *);
struct BitMap *tAllocBitMap(wid,ht,depth,flags,friend)
int wid,ht,depth,flags;
struct BitMap *friend;
{
int i;
unsigned long tt;
LONG image_data;
ULONG planes;
struct BitMap *tmp;
if (gfxversion < 39)
{
planes = RASSIZE(wid,ht);
if (!(tmp = AllocMem(sizeof (struct BitMap),MEMF_CLEAR)))
{
return(0);
}
InitBitMap(tmp,depth,wid,ht);
tt = planes*depth;
if (!(tmp->Planes[0] = AllocMem(tt,MEMF_CHIP|MEMF_CLEAR)))
{
FreeMem(tmp,sizeof(struct BitMap));
return(0);
}
image_data = (LONG)tmp->Planes[0];
for(i=1;i<depth;i++)
{
tmp->Planes[i] = (PLANEPTR) (image_data + i * planes);
}
}
else
{
tmp = AllocBitMap(wid,ht,depth,flags,friend);
}
return(tmp);
}
struct BitMap *sAllocBitMap(wid,ht,depth,flags,friend)
int wid,ht,depth,flags;
struct BitMap *friend;
{
int i;
unsigned long tt;
ULONG image_data;
ULONG planes;
struct BitMap *tmp;
if (!(tmp = AllocMem(sizeof (struct BitMap),MEMF_CLEAR)))
{
return(0);
}
InitBitMap(tmp,8,640,480);
planes = RASSIZE(640,480);
tmp->BytesPerRow = 640;
tmp->Flags = 0x0;
tmp->Rows = 480;
tmp->Depth = 8;
tmp->pad = 32860;
tt = planes*8;
if (!(tmp->Planes[0] = AllocMem(tt,MEMF_CHIP|MEMF_CLEAR)))
{
FreeMem(tmp,sizeof(struct BitMap));
return(0);
}
image_data = (ULONG)tmp->Planes[0];
planes = 0x50;
for(i=1;i<depth;i++)
{
tmp->Planes[i] = (PLANEPTR) (image_data + i * planes);
}
return(tmp);
}
void tFreeBitMap(bmap)
struct BitMap *bmap;
{
ULONG numbytes;
if (gfxversion < 39)
{
numbytes = bmap->Rows*bmap->BytesPerRow*bmap->Depth;
FreeMem(bmap->Planes[0],numbytes);
FreeMem(bmap,sizeof(struct BitMap));
}
else
{
FreeBitMap(bmap);
}
}
void sFreeBitMap(bmap)
struct BitMap *bmap;
{
ULONG numbytes,planes;
planes = RASSIZE(640,480);
numbytes = planes*8;
FreeMem(bmap->Planes[0],numbytes);
FreeMem(bmap,sizeof(struct BitMap));
}
int HandleEvent(object)
APTR object;
{
int tmpdone=0;
UWORD nextcode;
struct MenuItem *myMenuItem;
do {
if (!RealThink)
{
if (object == (APTR)&MenuItem15) { DoQuit();return(1); }
if (object == (APTR)&MenuItem1) { DoHint(); }
if (object == (APTR)&MenuItem12) { DoAbout(); }
//if (object == (APTR)&MenuItem6) { }
if (object == (APTR)&MenuItem13) { LoadAGame(); }
if (object == (APTR)&MenuItem14) { SaveAGame(); }
if (object == (APTR)&MenuItem14a) { ListAGame(); }
if (object == (APTR)&MenuItem9) { Go2D(); }
if (object == (APTR)&MenuItem10) { EditBoard(); }
if (object == (APTR)&MenuItem11) { DoReverse(); }
if (object == (APTR)&MenuItem4) { DoSwap(); }
if (object == (APTR)&MenuItem5) { DoAutoPlay(); }
if (object == (APTR)&MenuItem7) { TakeBack(); }
if (object == (APTR)&MenuItem8) { DoThinking(); }
if (object == (APTR)&MenuItem8a) { DoShwThnk(); }
if (object == (APTR)&MenuItem8aa) { DoSuper(); }
if (object == (APTR)&MenuItem8ab) { DoBookToggle(); }
if (object == (APTR)&MenuItem8ee) {strcpy(OpEntryStr,"advan");tmpdone = 1;}
if (object == (APTR)&MenuItem8dd) {strcpy(OpEntryStr,"interm");tmpdone = 1;}
if (object == (APTR)&MenuItem8cc) {strcpy(OpEntryStr,"easy");tmpdone = 1;}
if (object == (APTR)&MenuItem2) { DoTest(); }
if (object == (APTR)&MenuItem3) { SetTime(); }
if (object == (APTR)&MenuItem3x) { strcpy(OpEntryStr,"calc");tmpdone = 1;}
if (object == (APTR)&MenuItem3r) { ChangeSearchDepth();}
if (object == (APTR)&MenuItem28)
{
#ifndef OLDNEW
tmpdone = 1;
strcpy(OpEntryStr,"new");
#else
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
WaitTOF();
RethinkDisplay();
NewGame();
#endif
}
} // !RealThink
else
{ // realthink
if (object == (APTR)&MenuItem15) {MoveNow();while (RealThink) Delay(20L);DoQuit();return(1);}
if (object == (APTR)&MenuItem6) { MoveNow(); }
if (object == (APTR)&MenuItem8ab) { DoBookToggle(); }
if (object == (APTR)&MenuItem8) { DoThinking(); }
if (object == (APTR)&MenuItem8aa) { MoveNow();while (RealThink) Delay(20L);DoSuper(); }
if (object == (APTR)&MenuItem8a) { DoShwThnk(); }
if (object == (APTR)&MenuItem8ee) {MoveNow();while (RealThink) Delay(20L);strcpy(OpEntryStr,"advan");tmpdone = 1;}
if (object == (APTR)&MenuItem8dd) {MoveNow();while (RealThink) Delay(20L);strcpy(OpEntryStr,"interm");tmpdone = 1;}
if (object == (APTR)&MenuItem8cc) {MoveNow();Delay(50L);strcpy(OpEntryStr,"easy");tmpdone = 1;}
}
myMenuItem = (struct MenuItem *)object;
nextcode = myMenuItem->NextSelect;
if (nextcode != MENUNULL)
{
object = (APTR)ItemAddress(&MenuList1,nextcode);
}
} while (nextcode != MENUNULL);
return(tmpdone);
}
#endif // AMIGA
#ifdef NEEDTODO
void DoAbout()
{
int done=0;
struct IntuiMessage *message;
struct Window *wG3;
ULONG class,code;
if (!(wG3 = OpenWindow(&NewWindowStructure2)))
{
DisplayBeep(0L);
return;
}
PrintIText(wG3->RPort,&IText17,0L,0L);
do {
WaitPort(wG3->UserPort);
while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
{
class = message->Class;
code = message->Code;
ReplyMsg((struct Message *)message);
if (class == GADGETUP)
done = 1;
else if (class == VANILLAKEY)
{
if ((code == 13)||(code == 10))
done = 1;
}
}
} while (!done);
CloseWindow(wG3);
}
#endif // nEEDTODO
void LoadAGame(void)
{
// strcpy(OpEntryStr,"get");
if (thinkahead)
{
flag.back = true;
while (thinkahead)
{
DosSleep(500L);
}
}
GetGame();
}
void SaveAGame(void)
{
// strcpy(OpEntryStr,"save");
if (thinkahead)
{
flag.back = true;
while (thinkahead)
{
DosSleep(500L);
}
}
SaveGame();
}
void ListAGame(void)
{
if (thinkahead)
{
flag.back = true;
while (thinkahead)
{
DosSleep(500L);
}
}
ListGame(0xff);
}
void DoQuit(void)
{
flag.quit = true;
}
void Go2D(void)
{
}
void DoReverse(void)
{
}
void DoSwap(void)
{
doswap = 1;
}
void DoAutoPlay(void)
{
hint = 0;
//SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
doauto = 1;
}
void MoveNow(void)
{
if ((RealThink))
{
// if (!flag.timeout)
// {
flag.back = true;
flag.musttimeout = true;
// }
flag.bothsides = false;
}
}
void TakeBack(void)
{
// char mvnstr[16];
// int currpiece;
// long tmp1,tmp2;
int r,c,l;
MoveMem128(amigaboard,board);
MoveMem128(amigacolor,color);
doundo = 1;
hint = 0;
if (GameCnt <= 0)
return;
for (r = 7; r >= 0; r--)
{
for (c = 0; c <= 7; c++)
{
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if (amigacolor[l] == neutral)
oldboard[r][c] = ' ';
else if (amigacolor[l] == white)
oldboard[r][c] = qxx[amigaboard[l]];
else
oldboard[r][c] = pxx[amigaboard[l]];
}
}
Undo();
DrawAmigaBoard();
// THIS ALL NEEDS TO BE DONE FOR PM OS2!!!!
#ifdef NEEDTODO
for (r = 7; r >= 0; r--)
{
for (c = 0; c <= 7; c++)
{
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if ((color[l] == neutral)&&(oldboard[r][c] != ' '))
{
tmp1 = r & 1L;
tmp2 = c & 1L;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
}
else
{
if (color[l] == white)
currpiece = qxx[board[l]];
else
currpiece = pxx[board[l]];
if (currpiece != oldboard[r][c])
{
tmp1 = r & 1L;
tmp2 = c & 1L;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
LoadBobImage(currpiece);
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[c],RowArray[r],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
}
}
}
}
}
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
}
if (computer != black)
mysprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
else
mysprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
ObtainSemaphore(&mySemaphore);
mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
RectFill(rpG,520,USERBOX,621,USERBOX+30);
Move(rpG,520,USERBOX+6);
mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
Text(rpG,mvnstr,strlen(mvnstr));
ReleaseSemaphore(&mySemaphore);
#endif // NEEDTODO
}
void DoThinking(void)
{
flag.easy = !flag.easy;
}
void DoShwThnk(void)
{
flag.post = !flag.post;
}
void DoSuper(void)
{
SupervisorMode = !SupervisorMode;
if (SupervisorMode)
{ // going into supervisor mode
oldflageasy = flag.easy;
flag.easy = 1;
}
else
{ // leaving supervisor mode, restore easy flag
flag.easy = oldflageasy;
}
}
void DoBookToggle(void)
{
Book = Book ? 0 : BOOKFAIL;
bookflag = Book;
}
void DoHint(void)
{
GiveHint();
}
void DoTest(void)
{
teston = 1;
}
int SetAmigaDepth()
{
int dun=6;
//struct IntuiMessage *message;
//struct Window *wG3;
//UWORD code;
//ULONG class;
//APTR object;
// ULONG tmp[3];
// if (DEPTH >= 6)
// {
// tmp[0] = BigColorPalette[4];
// tmp[1] = BigColorPalette[5];
// tmp[2] = BigColorPalette[6];
// SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
// }
// else
// {
// tmp[0] = myPalette[1];
// SetRGB4(vP,1,0xa,0xa,0xa);
// }
#ifdef NEEDTODO
mysprintf(Gadget6SIBuff,"%d",MaxSearchDepth);
NewWindowStructure5.FirstGadget = &Gadget6b;
if (!(wG3 = OpenWindow(&NewWindowStructure5)))
{
DisplayBeep(0L);
return(0);
}
Move(wG3->RPort,66,39);
Text(wG3->RPort,"Depth",5);
ActivateGadget(&Gadget6,wG3,NULL);
dun = 0;
do {
WaitPort(wG3->UserPort);
while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
{
code = message->Code;
object = message->IAddress;
class = message->Class;
ReplyMsg((struct Message *)message);
#ifdef SELECTIVEBB
if (object != (APTR)&Gadget6b)
{
dun = 1;
}
#else
dun = 1;
#endif
}
} while (!dun);
CloseWindow(wG3);
// if (DEPTH >= 6)
// {
// SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
// }
// else
// {
// SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
// }
dun = atoi(Gadget6SIBuff);
if (dun > (MAXDEPTH-1))
dun = MAXDEPTH -1;
if (dun < MINDEPTH)
dun = MINDEPTH;
NewWindowStructure5.FirstGadget = &Gadget6;
#endif //NEEDTODO
return(dun);
}
#ifdef NEEDED
void SetTime(void)
{
int dun;
char str[128];
//struct IntuiMessage *message;
//struct Window *wG3;
//UWORD code;
//ULONG class;
//APTR object;
// ULONG tmp[3];
//struct Gadget *tg;
// if (DEPTH >= 6)
// {
// tmp[0] = BigColorPalette[4];
// tmp[1] = BigColorPalette[5];
// tmp[2] = BigColorPalette[6];
// SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
// }
//else
// {
// tmp[0] = myPalette[1];
// SetRGB4(vP,1,0xa,0xa,0xa);
// }
#ifdef AMIGA
mysprintf(Gadget6SIBuff,"%d",TCmoves);
mysprintf(Gadget8SIBuff,"%d",(TCminutes));
if (!(wG3 = OpenWindow(&NewWindowStructure5)))
{
DisplayBeep(0L);
return;
}
PrintIText(wG3->RPort,&IText46,0L,0L);
ActivateGadget(&Gadget6,wG3,NULL);
dun = 0;
do {
WaitPort(wG3->UserPort);
while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
{
code = message->Code;
object = message->IAddress;
class = message->Class;
ReplyMsg((struct Message *)message);
if (object != (APTR)&Gadget9)
{
if (object == (APTR)&Gadget6)
{
tg = &Gadget8;
ActivateGadget(tg,wG3,NULL);
}
else if (object == (APTR)&Gadget8)
dun = 1;
}
else
{
dun = 1;
}
}
} while (!dun);
CloseWindow(wG3);
// if (DEPTH >= 6)
// {
// SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
// }
// else
// {
// SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
// }
strcpy(str,Gadget6SIBuff);
strcat (str," ");
strcat(str,Gadget8SIBuff);
#endif // AMIGA
strcpy(str,"60 10"); // hard code for now
SelectLevel(str);
et = 0;
dun = player;
player = white;
UpdateClocks();
player = black;
UpdateClocks();
player = dun;
}
#endif
void DisplayError(str)
char *str;
{
//RECTL myRect={0,0,639,479};
//POINTL myPoint;
FILE *fh;
if (WinNotInited)
{
fh = fopen("uc_error.log","w");
if (!fh)
DosExit(1,0);
fprintf(fh,"%s\n",str);
fclose(fh);
return;
}
WinMessageBox(HWND_DESKTOP,hwndClient,str,"UChess Pgm Err",0,MB_OK);
#ifdef AMIGA
struct IntuiMessage *message;
struct Window *wG3;
char c2;
char helpstr[64];
BPTR mywindow;
long temp;
DisplayBeep(0L);
if (wG)
{
if (!(wG3 = OpenWindow(&NewWindowStructure2)))
{
DisplayBeep(0L);
return;
}
Move(wG3->RPort,2,25);
Text(wG3->RPort,str,strlen(str));
WaitPort(wG3->UserPort);
while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
ReplyMsg((struct Message *)message);
CloseWindow(wG3);
}
else
{ // open on wb screen
(void)WBenchToFront();
strcpy(helpstr,"RAW:120/10/400/100/Program Error");
if (!(mywindow = Open(helpstr,MODE_NEWFILE)))
{
DisplayBeep(0L);
return;
}
strcat(str,"\n\n\n");
temp = strlen(str);
if (Write(mywindow,str,temp) != temp)
{
DisplayBeep(0L);
Close(mywindow);
return;
}
strcpy(helpstr," Press any key to continue...");
temp = strlen(helpstr);
if (Write(mywindow,helpstr,temp) != temp)
{
DisplayBeep(0L);
Close(mywindow);
return;
}
Read(mywindow,&c2,1L);
Close(mywindow);
}
#endif // AMIGA
}
//struct Library *LhBase;
//struct LhBuffer *myLHBuffer;
int LoadBobData(void);
void FreeBobData(void);
int InitmyGels(void);
void ClosemyGels(void);
void LoadBobImage(piece)
long piece; /* loads bob with pieces image */
{
// For OS2_PM this routine needs to just set the correct
// indices so that the current bob becomes the one we want
if (piece == BLANKDATA)
{
lastpiece = piece;
return; // for OS2 this should not matter
}
if (piece >= 'a') // white piece
{
CurrBobColor = white;
}
else
{
CurrBobColor = black;
}
switch (tolower(piece))
{
case 'p' :
CurrBobIndex = PAWNBOB;
break;
case 'n' :
CurrBobIndex = KNIGHTBOB;
break;
case 'b' :
CurrBobIndex = BISHOPBOB;
break;
case 'r' :
CurrBobIndex = ROOKBOB;
break;
case 'q' :
CurrBobIndex = QUEENBOB;
break;
case 'k' :
CurrBobIndex = KINGBOB;
break;
default :
ShowMessage("Piece Err");
DosBeep(1380,1000);
DosSleep(1500);
DosExit(1,0);
}
lastpiece = piece;
#ifdef AMIGA
int i;
UWORD *temp;
LONG image_data;
WORD planes = RASSIZE (BOBWIDTH, BOBHEIGHT);
if (piece == BLANKDATA)
{
temp = BlankImageData;
}
else if (piece >= 'a') /* white pieces */
{
if (piece == 'p')
temp = WhiteImageData[0];
else if (piece == 'n')
temp = WhiteImageData[1];
else if (piece == 'b')
temp = WhiteImageData[2];
else if (piece == 'r')
temp = WhiteImageData[3];
else if (piece == 'q')
temp = WhiteImageData[4];
else if (piece == 'k')
temp = WhiteImageData[5];
}
else /* black pieces */
{
if (piece == 'P')
temp = BlackImageData[0];
else if (piece == 'N')
temp = BlackImageData[1];
else if (piece == 'B')
temp = BlackImageData[2];
else if (piece == 'R')
temp = BlackImageData[3];
else if (piece == 'Q')
temp = BlackImageData[4];
else if (piece == 'K')
temp = BlackImageData[5];
}
BobImage.ImageData = BobVSprite->ImageData = temp;
image_data = (LONG) BobImage.ImageData;
/* Map the image data to planes */
for (i = 0L; i < BOBDEPTH; ++i)
BobTransImage->ti_BM.Planes[i] = (PLANEPTR) (image_data + i * planes);
temp += (BOBHEIGHT*BOBDEPTH*BOBWIDINW);
TheBob->ImageShadow = BobVSprite->CollMask = temp;
temp += ((BOBHEIGHT+2)*BOBWIDINW);
BobVSprite->BorderLine = temp;
BobImage.ImageData = BobVSprite->ImageData;
BobTransImage->ti_sBM->Planes[0] = (char *)TheBob->ImageShadow;
for (i = 1; i < BOBDEPTH; i++)
BobTransImage->ti_sBM->Planes[i] = BobTransImage->ti_sBM->Planes[0];
lastpiece = piece;
#endif // NEEDTODO
}
int LoadBobData()
{
int i,j;
unsigned char *imagebuffer;
APIRET rc;
rc = DosAllocMem((PPVOID)&imagebuffer,BOBWIDTH*BOBHEIGHT,
PAG_READ|PAG_WRITE|PAG_COMMIT);
if (rc)
exit(0);
for(i=0;i<2;i++)
{
for(j=0;j<6;j++)
{
if (!LoadBMPImage(&PieceFileNames[i][j][0],imagebuffer,BOBWIDTH,BOBHEIGHT))
{
DisplayError("Cannot get Piece Images");
DosExit(1,0);
}
TheBob[i][j] = CreateBob(BOBWIDTH,BOBHEIGHT,8,imagebuffer,BigColorPalette);
if (TheBob[i][j] == NULL)
{
DisplayError("Cannot Create BOB");
DosExit(1,0);
}
TheBob[i][j]->XPos = 0;
TheBob[i][j]->YPos = 0;
}
}
DosFreeMem(imagebuffer);
return(1);
#ifdef NEEDTODO
USHORT len;
long templong;
BPTR fh;
UBYTE *srcbuf;
int i;
if (!(srcbuf = AllocMem(BOBBLOCKSIZE,0L)))
{
return(0);
}
if (DEPTH < 6)
{
if (!(fh = Open("uchess:Pieces.lzw",MODE_OLDFILE)))
{
return(0);
}
}
else if (FasterDisplay)
{
if (!(fh = Open("uchess:Pieces64.lzw",MODE_OLDFILE)))
{
return(0);
}
}
else
{
if (!(fh = Open("uchess:Pieces256.lzw",MODE_OLDFILE)))
{
return(0);
}
}
if (!(LhBase = OpenLibrary(LH_NAME,LH_VERSION)))
{
DisplayError("Cannot open lh.lib\n");
return(0);
}
if (!(myLHBuffer = CreateBuffer(TRUE))) /* small buffer for only decomp*/
{
DisplayError("Cannot Create Buffer\n");
CloseLibrary(LhBase);
return(0);
}
for(i=0;i<6;i++)
{
if (Read(fh,(char *)&len,2L) != 2L)
{
Close(fh);
return(0);
}
templong = len;
if (Read(fh,srcbuf,templong) != templong)
{
Close(fh);
return(0);
}
if (!(WhiteImageData[i] =
(UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
{
return(0);
}
LoadBobImage(piecechar[i]);
myLHBuffer->lh_Src = (APTR)srcbuf;
myLHBuffer->lh_Dst = (APTR)BobVSprite->ImageData;
myLHBuffer->lh_SrcSize = templong;
myLHBuffer->lh_DstSize = BOBBLOCKSIZE;
LhDecode(myLHBuffer);
InitMasks(BobVSprite);
if (Read(fh,(char *)&len,2L) != 2L)
{
Close(fh);
return(0);
}
templong = len;
if (Read(fh,srcbuf,templong) != templong)
{
Close(fh);
return(0);
}
if (!(BlackImageData[i] =
(UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
{
return(0);
}
LoadBobImage(piecechar[i+6]);
myLHBuffer->lh_Src = (APTR)srcbuf;
myLHBuffer->lh_Dst = (APTR)BobVSprite->ImageData;
myLHBuffer->lh_SrcSize = templong;
myLHBuffer->lh_DstSize = BOBBLOCKSIZE;
LhDecode(myLHBuffer);
InitMasks(BobVSprite);
}
Close(fh);
FreeMem(srcbuf,BOBBLOCKSIZE);
DeleteBuffer(myLHBuffer);
CloseLibrary(LhBase);
LoadBobImage(BLANKDATA);
#endif // NEEDTODO
}
void FreeBobData()
{
#ifdef NEEDTODO
int i;
for(i=0;i<6;i++)
{
FreeMem((char *)WhiteImageData[i],BOBBLOCKSIZE);
FreeMem((char *)BlackImageData[i],BOBBLOCKSIZE);
}
FreeMem((char *)BlankImageData,BOBBLOCKSIZE);
#endif // NEEDTODO
}
int InitmyGels()
{
if (!InitGels())
{
DisplayError("Cannot Init Gels!");
return(0);
}
if (!LoadBobData())
{
DisplayError("Cannot Load/Create Bobs");
return(0);
}
return(1);
#ifdef NEEDTODO
#ifdef EXTRAINIT
struct BitMap tmpBitMap;
#endif
int i;
UWORD *temp;
if (!(SpriteHead = (struct VSprite *)
AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(SpriteTail = (struct VSprite *)
AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(BobVSprite = (struct VSprite *)
AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(TheBob = (struct Bob *)
AllocMem(sizeof(struct Bob),MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(myGelsInfo = (struct GelsInfo *)
AllocMem(sizeof(struct GelsInfo),MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(myGelsInfo->nextLine = (WORD *)AllocMem(sizeof(WORD)*32,
MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(myGelsInfo->lastColor = (WORD **)AllocMem(sizeof(WORD)*32,
MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(myGelsInfo->collHandler = (struct collTable *)
AllocMem(sizeof(struct collTable),MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(TheBob->SaveBuffer = (WORD *)
AllocMem(sizeof(SHORT)*BOBWIDINW*BOBHEIGHT*BOBDEPTH,MEMF_CHIP|MEMF_CLEAR)))
{
return(0);
}
if (!(temp = BobVSprite->ImageData =
(UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
{
return(0);
}
BlankImageData = temp;
temp += (BOBHEIGHT*BOBDEPTH*BOBWIDINW);
TheBob->ImageShadow = BobVSprite->CollMask = temp;
temp += ((BOBHEIGHT+2)*BOBWIDINW);
BobVSprite->BorderLine = temp;
#ifdef DBL_BUFF
if (!(TheBob->DBuffer = (struct DBufPacket *)AllocMem
(sizeof(struct DBufPacket),MEMF_CHIP|MEMF_CLEAR)))
{
return(0);
}
if (!(TheBob->DBuffer->BufBuffer =
(WORD *)AllocRaster(BOBWIDTH,BOBHEIGHT*BOBDEPTH)))
{
return(0);
}
#endif
BOBPLANEPICK = 1;
for(i=0;i<DEPTH;i++)
{
BOBPLANEPICK *= 2;
}
BOBPLANEPICK--;
BobImage.LeftEdge = 0;
BobImage.TopEdge = 0;
BobImage.Width = BOBWIDTH;
BobImage.Height = BOBHEIGHT;
BobImage.Depth = BOBDEPTH;
BobImage.ImageData = BobVSprite->ImageData;
BobImage.PlanePick = BOBPLANEPICK;
BobImage.PlaneOnOff = BOBPLANEONOFF;
BobImage.NextImage = NULL;
if (!(BobTransImage = AllocTransImage(&BobImage)))
{
return(0);
}
if (SYSTEM_BOBS)
{
myGelsInfo->leftmost = COLA;
myGelsInfo->rightmost = COLH+BOBWIDTH+1;
myGelsInfo->topmost = ROW8;
myGelsInfo->bottommost = ROW1+BOBHEIGHT+1;
rpG->GelsInfo = myGelsInfo;
InitGels((struct VSprite *)SpriteHead,SpriteTail,myGelsInfo);
WaitTOF();
}
BobVSprite->Flags = SAVEBACK | OVERLAY;
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
BobVSprite->Height = BOBHEIGHT;
BobVSprite->Width = BOBWIDINW;
BobVSprite->Depth = BOBDEPTH;
BobVSprite->MeMask = BOBMEMASK;
BobVSprite->HitMask = BOBHITMASK;
BobVSprite->VSBob = TheBob;
BobVSprite->PlanePick = BOBPLANEPICK;
BobVSprite->PlaneOnOff = BOBPLANEONOFF;
BobVSprite->VUserExt = 0;
TheBob->BobVSprite = BobVSprite;
if (!LoadBobData())
{
DisplayError("Cannot Load BOB data\n");
//CloseWindow(wG);
CloseScreen(sC);
}
InitMasks(BobVSprite);
#endif // NEEDTODO
}
void ClosemyGels()
{
int i,j;
CloseGels();
for(i=0;i<2;i++)
for(j=0;j<6;j++)
FreeBob(TheBob[i][j]);
#ifdef NEEDTODO
FreeBobData();
#ifdef DBL_BUFF
FreeRaster((PLANEPTR)TheBob->DBuffer->BufBuffer,BOBWIDTH,BOBHEIGHT*BOBDEPTH);
FreeMem((char *)TheBob->DBuffer,sizeof(struct DBufPacket));
#endif
FreeTransImage(BobTransImage);
FreeMem((char *)TheBob->SaveBuffer,
sizeof(SHORT)*BOBWIDINW*BOBHEIGHT*BOBDEPTH);
FreeMem((char *)myGelsInfo->collHandler,sizeof(struct collTable));
FreeMem((char *)myGelsInfo->lastColor,sizeof(WORD)*32);
FreeMem((char *)myGelsInfo->nextLine,sizeof(WORD)*32);
FreeMem((char *)myGelsInfo,sizeof(struct GelsInfo));
FreeMem((char *)TheBob,sizeof(struct Bob));
FreeMem((char *)BobVSprite,sizeof(struct VSprite));
FreeMem((char *)SpriteTail,sizeof(struct VSprite));
FreeMem((char *)SpriteHead,sizeof(struct VSprite));
#endif // NEEDTODO
}
#ifdef AMIGA
struct TransImage *
AllocTransImage (struct Image * im)
{
if (im)
{
LONG msize = sizeof (struct TransImage);
struct TransImage *ti;
if (ti = (struct TransImage *) AllocMem (msize, MEMF_CLEAR))
{
LONG image_data = (LONG) im->ImageData;
UWORD depth = im->Depth;
UWORD width = im->Width;
UWORD height = im->Height;
WORD planes = RASSIZE (width, height);
WORD i;
/* Remember the image */
ti->ti_IM = im;
/* Initialize the Image bitmap */
InitBitMap (&ti->ti_BM, depth, width, height);
/* Map the image data to planes */
for (i = 0L; i < depth; ++i)
ti->ti_BM.Planes[i] = (PLANEPTR) (image_data + i * planes);
/* Initialize the Image rastport */
InitRastPort (&ti->ti_RP);
ti->ti_RP.BitMap = &ti->ti_BM;
if (ti->ti_sBM = AllocShadowBM (depth, width, height))
{
if (ti->ti_sRP = AllocShadowRP (ti->ti_sBM))
{
return (ti);
}
FreeShadowBM (ti->ti_sBM);
}
FreeMem ((APTR) ti, msize);
}
}
return (NULL);
}
VOID
FreeTransImage (struct TransImage * ti)
{
if (ti)
{
LONG msize = sizeof (struct TransImage);
/* Free the shadow RastPort */
FreeShadowRP (ti->ti_sRP);
/* Free the shadow BitMap */
FreeShadowBM (ti->ti_sBM);
/* Free the temporary buffer */
FreeMem ((APTR) ti, msize);
}
}
VOID
FreeShadowBM (struct BitMap *sbm)
{
if (sbm)
{
#ifdef ALLOCFORREAL
LONG msize;
msize = RASSIZE (8 * (sbm->BytesPerRow), sbm->Rows);
if (sbm->Planes[0])
{
FreeMem ((APTR)sbm->Planes[0], msize);
}
#else
FreeMem ((APTR)sbm, sizeof (struct BitMap));
#endif
}
}
VOID
FreeShadowRP (struct RastPort *srp)
{
if (srp)
{
FreeMem (srp, sizeof (struct RastPort));
}
}
struct BitMap *
AllocShadowBM (UWORD depth, UWORD width, UWORD height)
{
LONG msize = sizeof (struct BitMap);
struct BitMap *bm;
WORD i;
/* Allocate a bitmap */
if (bm = (struct BitMap *) AllocMem (msize, MEMF_CLEAR))
{
#ifdef ALLOCFORREAL
LONG rsize = RASSIZE (width, height);
#endif
/* Initialize the bitmap */
InitBitMap (bm, depth, width, height);
#ifdef ALLOCFORREAL
/* Allocate one plane */
if (bm->Planes[0] = (PLANEPTR) AllocMem (rsize, MEMF_CHIP | MEMF_CLEAR))
{
/* All planes point to the first plane */
for (i = 1; i < depth; i++)
bm->Planes[i] = bm->Planes[0];
return (bm);
}
FreeMem ((APTR) bm, msize);
#else
bm->Planes[0] = (char *)TheBob->ImageShadow;
for (i = 1; i < depth; i++)
bm->Planes[i] = bm->Planes[0];
return (bm);
#endif
}
return (NULL);
}
struct RastPort *
AllocShadowRP (struct BitMap *bm)
{
LONG msize = sizeof (struct RastPort);
struct RastPort *rp;
/* Allocate a RastPort */
if (rp = (struct RastPort *) AllocMem (msize, MEMF_CHIP))
{
/* Initialize the new RastPort */
InitRastPort (rp);
/* Point the RastPort's BitMap... */
rp->BitMap = bm;
}
return (rp);
}
VOID
ClipBlitTrans (
struct RastPort *rp, /* source RastPort */
WORD sx, WORD sy, /* source top-left edge */
struct RastPort *drp, /* destination RastPort */
WORD dx, WORD dy, /* destination top-left edge */
WORD width, WORD height, /* width & height of image to blit */
struct RastPort *Srp) /* shadow RastPort */
{
/* make the shadow */
ClipBlit (rp, sx, sy, Srp, 0, 0, width, height, 0xe0);
ClipBlit (Srp, 0, 0, drp, dx, dy, width, height, 0x20); /* blit cookie cutter outline */
ClipBlit (rp, sx, sy, drp, dx, dy, width, height, 0xe0); /* now fill in image */
}
#endif // AMIGA
int myLoadFullBitMap(int);
int myLoadFullBitMap(first)
int first;
{
// InitGels MUST be called FIRST!!!
APIRET rc;
BITMAPINFO2 *bmi2;
POINTL myPoint;
int i;
POINTL apts[4];
char fname[64];
if (!LoadFullBitmap(hwClientPS,"CHESS.BMP",TRUE,BigColorPalette))
{
DisplayError("Cannot load full bitmap from disk");
DosExit(1,0);
}
strcpy(fname,UC_Title);
rc = DosRequestMutexSem(DrawSemaphore,5000);
if (rc)
return(0);
myPoint.x = 511;
myPoint.y = COMPUTERBOX+10;
GpiCharStringAt(hwClientPS, &myPoint, strlen(fname),
(PSZ)fname);
myPoint.x = 511;
myPoint.y = USERBOX+10;
strcpy(fname,"Puny Human:");
GpiCharStringAt(hwClientPS, &myPoint, strlen(fname),
(PSZ)fname);
DosReleaseMutexSem(DrawSemaphore);
if (!first)
return(1);
// Now I need to create the Black and WhiteBitMaps and blit the image into them
// use SQUAREWIDTH and SQUAREHEIGHT
bmi2 = calloc(sizeof(BITMAPINFOHEADER2)+(sizeof(RGB2)*256),1);
if (bmi2 == NULL)
{
return(0);
}
for(i=0;i<256;i++)
{ // each rgb2 entry in the palette is 4 bytes long
bmi2->argbColor[i].bRed = BigColorPalette[i*4];
bmi2->argbColor[i].bGreen = BigColorPalette[i*4+1];
bmi2->argbColor[i].bBlue = BigColorPalette[i*4+2];
}
bmi2->cbFix = sizeof(BITMAPINFOHEADER2);
bmi2->cx = SQUAREWIDTH;
bmi2->cy = SQUAREHEIGHT;
bmi2->cPlanes = 1;
bmi2->cBitCount = 8;
bmi2->cbImage = (ROUNDEDSQUAREWIDTH*SQUAREHEIGHT);
bmi2->cxResolution = cxClient;
bmi2->cyResolution = cyClient;
bmi2->cclrUsed = 256;
bmi2->cclrImportant = 256;
bmi2->ulColorEncoding = BCE_RGB;
WhiteBitMap = GpiCreateBitmap(hwClientPS,(PBITMAPINFOHEADER2)bmi2,
0L,NULL,bmi2);
if (WhiteBitMap == NULL)
return(0);
BlackBitMap = GpiCreateBitmap(hwClientPS,(PBITMAPINFOHEADER2)bmi2,
0L,NULL,bmi2);
if (BlackBitMap == NULL)
return(0);
bmi2->cx = 160;
bmi2->cy = 160;
bmi2->cbImage = (160*160);
textBitMap = GpiCreateBitmap(hwClientPS,(PBITMAPINFOHEADER2)bmi2,
0L,NULL,bmi2);
if (textBitMap == NULL)
return(0);
apts[2].x = COLB; // src left bottom
apts[2].y = (ROW5) - SQUAREHEIGHT; // src left bottom
apts[3].x = apts[2].x + SQUAREWIDTH - 1; // src rt top
apts[3].y = apts[2].y + SQUAREHEIGHT - 1; // src rt top
apts[0].x = 0; // tgt left bottom
apts[0].y = 0; // tgt left bottom
apts[1].x = SQUAREWIDTH - 1; // tgt rt top
apts[1].y = SQUAREHEIGHT - 1; // tgt rt top
GpiSetBitmap(hpsMemory,WhiteBitMap);
GpiBitBlt(hpsMemory,hwClientPS,4,(PPOINTL)apts,ROP_SRCCOPY,BBO_IGNORE);
apts[2].x = COLA; // src left bottom
apts[2].y = (ROW5) - SQUAREHEIGHT; // src left bottom
apts[3].x = apts[2].x + SQUAREWIDTH - 1; // src rt top
apts[3].y = apts[2].y + SQUAREHEIGHT - 1; // src rt top
apts[0].x = 0; // tgt left bottom
apts[0].y = 0; // tgt left bottom
apts[1].x = SQUAREWIDTH - 1; // tgt rt top
apts[1].y = SQUAREHEIGHT - 1; // tgt rt top
GpiSetBitmap(hpsMemory,BlackBitMap);
GpiBitBlt(hpsMemory,hwClientPS,4,(PPOINTL)apts,ROP_SRCCOPY,BBO_IGNORE);
DosFreeMem(bmi2);
// now copy in image data from the full board
// use COLB ROW5 for white, COLA, ROW5 for BLACK
return(1);
#ifdef NEEDTODO
unsigned long i;
char errstr[40];
char fname[80];
long count;
USHORT len;
char *srcbuf;
ULONG tt;
BPTR fh;
BPTR fp;
struct BitMap *tmpBitMap;
struct BitMap *PlanarBitMap;
struct FileInfoBlock *myFileInfoBlock;
//LONG tmp1,tmp2;
//char tstr[40];
if (DEPTH < 6)
strcpy(fname,"uchess:Chess.lzw");
else if (FasterDisplay)
strcpy(fname,"uchess:Chess64.lzw");
else
strcpy(fname,"uchess:Chess256.lzw");
if (!(myFileInfoBlock =
(struct FileInfoBlock *)AllocMem(sizeof(struct FileInfoBlock),MEMF_PUBLIC)))
{
DisplayError("No Mem now for finfo block");
return(0);
}
if (!(fp = Lock(fname,ACCESS_READ)))
{
FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
return(0);
}
if (!(Examine(fp,myFileInfoBlock)))
{
DisplayError("Cannot get finfo");
UnLock(fp);
FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
return(0);
}
UnLock(fp);
count = myFileInfoBlock->fib_Size - 2L;
FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
/* before unpacking the bitmap, save the titlebar area in a tmp bitmap */
if (!RTG)
{
if (!(tmpBitMap = tAllocBitMap(WIDTH,MENUBARHT,DEPTH,BMF_CLEAR,myBitMap)))
{
return(0);
}
BltBitMap(myBitMap,0,0,tmpBitMap,0L,0L,WIDTH,MENUBARHT,0xc0L,0xffL,0L);
}
else
{
if (!(tmpBitMap = tAllocBitMap(WIDTH,MENUBARHT,DEPTH,BMF_CLEAR,0L)))
{
return(0);
}
BltBitMap(sC->RastPort.BitMap,0,0,tmpBitMap,0L,0L,WIDTH,MENUBARHT,0xc0L,0xffL,0L);
}
if (!(srcbuf = AllocMem(count,0L)))
{
sprintf(errstr,"Cannot allocate lharc %d byte buffer",count);
DisplayError(errstr);
return(0);
}
if (!(LhBase = OpenLibrary(LH_NAME,LH_VERSION)))
{
DisplayError("Cannot open lh.lib");
return(0);
}
if (!(myLHBuffer = CreateBuffer(TRUE))) /* small buffer for only decomp*/
{
DisplayError("Cannot Create Buffer");
CloseLibrary(LhBase);
return(0);
}
if (!(fh = Open(fname,MODE_OLDFILE)))
{
DisplayError("Cannot open chess file");
return(0);
}
if (Read(fh,(char *)&len,2L) != 2L)
{
DisplayError("Cannot read chess file");
Close(fh);
return(0);
}
if (Read(fh,srcbuf,count) != count)
{
DisplayError("Cannot read chess file2");
Close(fh);
return(0);
}
Close(fh);
if ((RTG)&&(!OrigmyBitMap))
{ // allocate the BitMap to unpack to
if (!(OrigmyBitMap = myBitMap = sAllocBitMap(WIDTH,HEIGHT,DEPTH,BMF_INTERLEAVED|BMF_CLEAR|BMF_DISPLAYABLE,
0L)))
{
return(0);
}
}
myLHBuffer->lh_Src = (APTR)srcbuf;
myLHBuffer->lh_Dst = (APTR)myBitMap->Planes[0];
myLHBuffer->lh_SrcSize = count;
tt = WIDTH/8L;
tt = tt*HEIGHT;
tt = tt*DEPTH;
myLHBuffer->lh_DstSize = tt;
LhDecode(myLHBuffer);
FreeMem(srcbuf,count);
DeleteBuffer(myLHBuffer);
CloseLibrary(LhBase);
BltBitMap(tmpBitMap,0,0,myBitMap,0L,0L,WIDTH,MENUBARHT,0xc0L,0xffL,0L);
tFreeBitMap(tmpBitMap);
if (RTG)
{
if (!(PlanarBitMap = tAllocBitMap(WIDTH,HEIGHT/10,DEPTH,BMF_CLEAR,0L)))
{
return(0);
}
for(i=0;i<10;i++)
{
BltBitMap(myBitMap,0,(i*(HEIGHT/10)),PlanarBitMap,0,0,WIDTH,(HEIGHT/10),0xc0L,0xffL,0L);
BltBitMap(PlanarBitMap,0,0,sC->RastPort.BitMap,0,(i*(HEIGHT/10)),WIDTH,(HEIGHT/10),0xc0L,0xffL,0L);
}
// then free the non-interleaved bitmap...
tFreeBitMap(PlanarBitMap);
}
#ifdef _M68040
strcpy(fname,"UChess Pro:");
#else
#ifndef TINYCHESS
strcpy(fname,"UChess Jr.:");
#else
strcpy(fname,"UChess Tiny:");
#endif
#endif
ObtainSemaphore(&mySemaphore);
mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
Move(rpG,511,COMPUTERBOX-10);
Text(rpG,fname,strlen(fname));
Move(rpG,511,USERBOX-10);
strcpy(fname,"Puny Human:");
Text(rpG,fname,strlen(fname));
ReleaseSemaphore(&mySemaphore);
if (!RTG)
{
BltBitMap(myBitMap,COLB,ROW5,WhiteBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
BltBitMap(myBitMap,COLA,ROW5,BlackBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
}
else
{
BltBitMap(sC->RastPort.BitMap,COLB,ROW5,WhiteBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
BltBitMap(sC->RastPort.BitMap,COLA,ROW5,BlackBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
}
RethinkDisplay();
if (RTG)
{
myBitMap = sC->RastPort.BitMap;
sFreeBitMap(OrigmyBitMap);
OrigmyBitMap = 0L;
}
if (!textBitMap)
{
if (!(textBitMap = tAllocBitMap(160,160,DEPTH,BMF_CLEAR,myBitMap)))
{
DisplayBeep(0L);
Delay(10L);
DisplayBeep(0L);
Delay(15L);
DisplayBeep(0L);
Delay(25L);
DisplayBeep(0L);
return(0);
}
}
#endif
}
#ifdef AMIGA
int mAllocBitMap(void);
int mAllocBitMap()
{
if (!RTG)
{
if (!(OrigmyBitMap = myBitMap = tAllocBitMap(WIDTH,HEIGHT,DEPTH,BMF_INTERLEAVED|BMF_CLEAR|BMF_DISPLAYABLE,
0L)))
{
return(0);
}
tempras_bitplane = AllocMem(WIDTH*HEIGHT/8,MEMF_CLEAR|MEMF_CHIP);
if (!tempras_bitplane)
{
return(0);
}
}
else
{
if (!(OrigmyBitMap = myBitMap = sAllocBitMap(WIDTH,HEIGHT,DEPTH,BMF_INTERLEAVED|BMF_CLEAR|BMF_DISPLAYABLE,
0L)))
{
return(0);
}
}
if (RTG)
{
if ((RTG_ModeID == VGAPRODUCT_KEY)||
(RTG_ModeID == (HIRES|LACE|DEFAULT_MONITOR_ID))||
(RTG_ModeID == (HIRES|LACE|PAL_MONITOR_ID))||
(RTG_ModeID == (HIRES|LACE|NTSC_MONITOR_ID)) ||
(RTG_ModeID == (HIRES|LACE|DBLPAL_MONITOR_ID))||
(RTG_ModeID == (HIRES|LACE|DBLNTSC_MONITOR_ID)) ||
(RTG_ModeID == (LORES_KEY|LACE|DEFAULT_MONITOR_ID))||
(RTG_ModeID == (LORES_KEY|LACE|PAL_MONITOR_ID))||
(RTG_ModeID == (LORES_KEY|LACE|NTSC_MONITOR_ID)) ||
(RTG_ModeID == (LORES_KEY|LACE|DBLPAL_MONITOR_ID))||
(RTG_ModeID == (LORES_KEY|LACE|DBLNTSC_MONITOR_ID)) ||
(RTG_ModeID == (HIRES|DEFAULT_MONITOR_ID))||
(RTG_ModeID == (HIRES|PAL_MONITOR_ID))||
(RTG_ModeID == (HIRES|NTSC_MONITOR_ID)) ||
(RTG_ModeID == (HIRES|DBLNTSC_MONITOR_ID)) ||
(RTG_ModeID == (HIRES|DBLPAL_MONITOR_ID)) ||
(RTG_ModeID == (LORES_KEY|DEFAULT_MONITOR_ID))||
(RTG_ModeID == (LORES_KEY|PAL_MONITOR_ID))||
(RTG_ModeID == (LORES_KEY|NTSC_MONITOR_ID)) ||
(RTG_ModeID == (LORES_KEY|DBLPAL_MONITOR_ID)) ||
(RTG_ModeID == (LORES_KEY|DBLNTSC_MONITOR_ID)) ||
(RTG_ModeID == (SUPER72_MONITOR_ID | SUPERLACE_KEY)))
{
myTagList[3].ti_Tag = SA_Interleaved;
myTagList[3].ti_Data = TRUE;
}
NewScreenStructure.Type = CUSTOMSCREEN | NS_EXTENDED; // no custom bitmap
NewScreenStructure.CustomBitMap = 0L;
if (!(WhiteBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
BMF_CLEAR,0L)))
{
return(0);
}
if (!(BlackBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
BMF_CLEAR,0L)))
{
return(0);
}
}
else
{
NewScreenStructure.CustomBitMap = myBitMap;
if (!(WhiteBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
BMF_CLEAR,myBitMap)))
{
return(0);
}
if (!(BlackBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
BMF_CLEAR,myBitMap)))
{
return(0);
}
}
return(1);
}
void FreeTheBitMap(void);
void FreeTheBitMap()
{
tFreeBitMap(BlackBitMap);
tFreeBitMap(WhiteBitMap);
if (OrigmyBitMap)
if (!RTG)
tFreeBitMap(OrigmyBitMap);
else
sFreeBitMap(OrigmyBitMap);
if (textBitMap)
tFreeBitMap(textBitMap);
}
#endif // AMIGA
void PM_ShutDown(void);
int PM_Startup(void);
int AmigaStarted = 0;
int PM_Startup()
{
APIRET rc;
// Semaphore for screen is DrawSemaphore, I do not need another one
// rc = DosCreateMutexSem("\\SEM32\\UChessMut",&mySemaphore,0L,0L);
// if (rc)
// {
// DisplayError("Cannot open mutex sem\n");
// return(0);
// }
rc = DosCreateThread(&myTID,(PFNTHREAD)InputThread,0L,0L,16384L);
if (rc)
{
DisplayError("Cannot start thread\n");
return(0);
}
DosSleep(250L);
while (InputThreadState < 1)
DosSleep(200L);
if (InputThreadState != 1)
{
DisplayError("Trbl with child process");
return(0);
}
Global_Message = 0L;
flag.post = true;
RowArray[0] = ROW1;
RowArray[1] = ROW2;
RowArray[2] = ROW3;
RowArray[3] = ROW4;
RowArray[4] = ROW5;
RowArray[5] = ROW6;
RowArray[6] = ROW7;
RowArray[7] = ROW8;
USERBOX=480-168;
SYSTEMBOX = USERBOX - 112;
SYSBOXLEN = 102;
AmigaStarted = 1;
#ifdef AMIGA
if (!(myTextFont = OpenFont(&TOPAZ80)))
{
return(0);
}
if (gfxversion < 39)
DEPTH = 4;
else if (RTG)
{ // use screen requestor to ask guy what he wants
if (!GetScreenMode())
{
return(0);
}
DEPTH = 8; // only support 8 bit RTG screens
myTagList[0].ti_Data = RTG_ModeID;
myTagList[2].ti_Tag = SA_AutoScroll;
myTagList[2].ti_Data = TRUE;
}
else
{
if (v15Khz)
{
myTagList[0].ti_Data = HIRES|LACE|DEFAULT_MONITOR_ID;
myTagList[2].ti_Data = TRUE;
myTagList[2].ti_Tag = SA_AutoScroll;
}
if (Super72)
myTagList[0].ti_Data = (SUPER72_MONITOR_ID | SUPERLACE_KEY);
NewScreenStructure2.Type |= NS_EXTENDED;
NewScreenStructure2.Extension = myTagList;
NewScreenStructure2.Height = 480;
NewScreenStructure2.Depth = 8;
NewScreenStructure2.BlockPen = 251;
if ((sC = OpenScreen((struct NewScreen *)&NewScreenStructure2)))
{
CloseScreen(sC);
DEPTH = 8;
}
else
{
myTagList[0].ti_Data = HIRES|LACE|DEFAULT_MONITOR_ID;
myTagList[2].ti_Tag = SA_AutoScroll;
myTagList[2].ti_Data = TRUE;
if ((sC = OpenScreen((struct NewScreen *)&NewScreenStructure2)))
{
CloseScreen(sC);
DEPTH = 8;
}
else
{
myTagList[2].ti_Tag = 0;
myTagList[2].ti_Data = 0;
myTagList[0].ti_Data = HIRES|LACE;
DEPTH = 4;
}
}
}
if (DEPTH == 8)
{
BLACK = 2;
if (FasterDisplay)
{
DEPTH = 6;
MBLOCKPEN = 0;//61;
BACKGNDTEXTCOLOR = 57;
BACKPEN =61;
}
else
{
MBLOCKPEN = 0;//251;
BACKGNDTEXTCOLOR = 0xe0;
BACKPEN = 251;
}
TIMEYCOORD1 = 120;
TIMEYCOORD2 = 230;
USERBOX=168;
SYSTEMBOX = USERBOX + 112;
SYSBOXLEN = 102;
COMPUTERBOX=60;
BOBDEPTH = DEPTH;
ROW8 = 24;
BOBHEIGHT = 55;
HEIGHT = 480;
NewScreenStructure.Type |= NS_EXTENDED;
NewScreenStructure.Extension = myTagList;
NewScreenStructure.Height = HEIGHT;
NewScreenStructure.Depth = DEPTH;
NewScreenStructure.BlockPen = BACKPEN;
NewWindowStructure1.Height = HEIGHT;
NewWindowStructure1.MaxHeight = HEIGHT;
NewWindowStructure1.BlockPen = BACKPEN;
NewWindowStructure2.BlockPen = BACKPEN;
NewWindowStructure5.BlockPen = BACKPEN;
NewWindowStructure6.BlockPen = BACKPEN;
pNewWindowStructure1.BlockPen = BACKPEN;
Border6.FrontPen = Border7.FrontPen =
Border9.FrontPen = Border1.FrontPen = BACKPEN;
aBorder1.FrontPen = aBorder2.FrontPen =
aBorder3.FrontPen = aBorder4.FrontPen =
pBorder1.FrontPen = pBorder2.FrontPen =
pBorder3.FrontPen = pBorder4.FrontPen = BACKPEN;
pIText1.FrontPen =
pIText2.FrontPen =
pIText2a.FrontPen =
pIText3.FrontPen =
pIText4.FrontPen =
pIText5.FrontPen =
pIText6.FrontPen =
pIText7.FrontPen =
pIText8a.FrontPen =
IText93.FrontPen =
IText47.FrontPen =
IText46.FrontPen =
IText37.FrontPen =
IText1.FrontPen =
IText1r.FrontPen =
IText2.FrontPen =
IText2x.FrontPen =
IText3.FrontPen =
IText4.FrontPen =
IText4aa.FrontPen =
IText4ab.FrontPen =
IText4cc.FrontPen =
IText4dd.FrontPen =
IText4ee.FrontPen =
IText4a.FrontPen =
IText5.FrontPen =
IText6.FrontPen =
IText7.FrontPen =
IText8.FrontPen =
IText9.FrontPen =
IText10.FrontPen =
IText11.FrontPen =
IText12.FrontPen =
IText13.FrontPen =
IText13a.FrontPen =
IText14.FrontPen =
IText15.FrontPen =
IText16.FrontPen =
IText22.FrontPen =
IText21.FrontPen =
IText20.FrontPen =
IText19.FrontPen =
IText18.FrontPen =
aIText1.FrontPen =
aIText2.FrontPen =
aIText3.FrontPen =
aIText4.FrontPen =
aIText5.FrontPen =
IText17.FrontPen = BACKPEN;
IText37.BackPen =
IText1.BackPen =
IText1r.BackPen =
IText2.BackPen =
IText2x.BackPen =
IText3.BackPen =
IText4.BackPen =
IText4aa.BackPen =
IText4ab.BackPen =
IText4cc.BackPen =
IText4dd.BackPen =
IText4ee.BackPen =
IText4a.BackPen =
IText5.BackPen =
IText6.BackPen =
IText7.BackPen =
IText8.BackPen =
IText9.BackPen =
IText10.BackPen =
IText11.BackPen =
IText12.BackPen =
IText13.BackPen =
IText13a.BackPen =
IText14.BackPen =
IText15.BackPen = BACKPEN;
IText37.FrontPen =
IText1.FrontPen =
IText1r.FrontPen =
IText2.FrontPen =
IText2x.FrontPen =
IText3.FrontPen =
IText4.FrontPen =
IText4aa.FrontPen =
IText4ab.FrontPen =
IText4cc.FrontPen =
IText4dd.FrontPen =
IText4ee.FrontPen =
IText4a.FrontPen =
IText5.FrontPen =
IText6.FrontPen =
IText7.FrontPen =
IText8.FrontPen =
IText9.FrontPen =
IText10.FrontPen =
IText11.FrontPen =
IText12.FrontPen =
IText13.FrontPen =
IText13a.FrontPen =
IText14.FrontPen =
IText15.FrontPen = MBLOCKPEN;
}
if (!(mAllocBitMap()))
{
CloseFont(myTextFont);
return(0);
}
if (!(sC = OpenScreen((struct NewScreen *)&NewScreenStructure)))
{
if (RTG)
{
myTagList[2].ti_Tag = 0; // kill autoscroll and try again
myTagList[2].ti_Data = 0;
if (!(sC = OpenScreen((struct NewScreen *)&NewScreenStructure)))
{
//FreeTheBitMap();
CloseFont(myTextFont);
DisplayError("256 color screen in this mode not avail");
return(0);
}
}
else // not rtg
{
FreeTheBitMap();
CloseFont(myTextFont);
DisplayError("FATAL:Screen mode not avail");
return(0);
}
}
vP = &sC->ViewPort;
if (DEPTH >= 6)
{
if (!FasterDisplay)
LoadRGB32(&(sC->ViewPort),BigColorPalette);
else
LoadRGB32(&(sC->ViewPort),Big64Palette);
}
else
LoadRGB4(&(sC->ViewPort),myPalette,16);
if (gfxversion > 38)
{
NewWindowStructure1.Flags |= WFLG_NEWLOOKMENUS;
}
NewWindowStructure1.Screen = sC;
pNewWindowStructure1.Screen = sC;
NewWindowStructure2.Screen = sC;
NewWindowStructure5.Screen = sC;
NewWindowStructure6.Screen = sC;
InitSemaphore(&mySemaphore);
if (!(InputReply = CreatePort(0L,0L)))
{
DisplayError("Cannot create reply");
return(0);
}
if (!CreateNewProc(ProcTagList))
{
DisplayError("Cannot create new proc");
return(0);
}
Delay(15L);
while (InputThreadState < 1)
Delay(10L);
if (InputThreadState != 1)
{
DisplayError("Trbl with child process");
return(0);
}
Forbid();
if (!(InThreadPort = FindPort(InputPortName)))
{
Permit();
DisplayError("Cannot find input port");
return(0);
}
Permit();
Global_Message.myData = 0L;
Global_Message.MainMsg.mn_Length = sizeof(Global_Message);
Global_Message.MainMsg.mn_Node.ln_Type = NT_MESSAGE;
Global_Message.MainMsg.mn_ReplyPort = InputReply;
rpG = wG->RPort; /* get a rastport pointer for the window */
if (!RTG)
{
InitTmpRas(&temp_rast,tempras_bitplane,WIDTH*HEIGHT/8);
rpG->TmpRas = &temp_rast;
}
SetFont(rpG,myTextFont);
Delay(25L); /* crashes from wb if I do not do this! */
SetDrMd(rpG,JAM1);
if (!InitmyGels())
{
CloseScreen(sC);
CloseFont(myTextFont);
// FreeTheBitMap();
return(0);
}
else
{
if (!myLoadFullBitMap(1)) // first time
{
//CloseWindow(wG);
CloseScreen(sC);
return(0);
}
// finish GEL init and add the bob
if (SYSTEM_BOBS)
AddBob(TheBob,rpG);
WaitTOF();
MakeScreen(sC);
RethinkDisplay();
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
WaitTOF();
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
WaitTOF();
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
WaitTOF();
MakeScreen(sC);
RethinkDisplay();
WaitTOF();
AmigaStarted = 1;
if (gfxversion > 38)
bpen = GetBPen(rpG);
return(1);
}
#else // FOR NOW THIS IS MY TEMP INIT PROC
return(1);
#endif // NEEDTODO
}
void PM_ShutDown()
{
#ifdef NEEDTODO
int tmpargcnt;
// need to wake up the input thread so it can exit 1st
Global_Message.myData = 0xff;
Forbid();
PutMsg(InThreadPort,(struct Message *)&Global_Message);
Permit();
tmpargcnt = 0;
Delay(25L);
while ((InputThreadState < 2)&&(tmpargcnt < 10))
{
tmpargcnt++;
Delay(25L);
}
ClosemyGels();
CloseScreen(sC);
if (!RTG)
{
if (tempras_bitplane)
FreeMem(tempras_bitplane,WIDTH*HEIGHT/8);
}
FreeTheBitMap();
CloseFont(myTextFont);
if (InputReply)
DeletePort(InputReply);
#endif // NEEDTODO
}
void ShowMessage(str)
char *str;
{
char tstr[2][16];
POINTL myPoint;
int i,j;
RECTL myRect;
int ycoord,nums;
APIRET rc;
i = strlen(str);
if (str[i-1] == '\n')
{
str[i-1] = 0;
}
// just keep 4 lines of text around I guess, in a buffer 12 chars max
if (i > 24)
str[24] = 0;
if (i > 12)
{
nums = 2;
strcpy(tstr[0],&str[12]);
str[12] = 0;
strcpy(tstr[1],str);
}
else
{
strcpy(tstr[0],str);
nums = 1;
}
for(j=0;j<nums;j++)
{
for(i=7;i>0;i--)
strcpy(MsgBuf[i],MsgBuf[i-1]);
strcpy(MsgBuf[0],tstr[j]);
MsgBuf[0][12] = 0;
}
if (WinNotInited)
return;
ycoord = SYSTEMBOX-2; // was - 6
/* scroll down 3 lines (36 pixels) */
myRect.xLeft = 510;
myRect.yBottom = SYSTEMBOX-SYSBOXLEN - 9;
myRect.xRight = 621;
myRect.yTop = SYSTEMBOX+14;
myPoint.x = 510;
rc = DosRequestMutexSem(DrawSemaphore,2000);
if (rc)
return;
// STILL NEED TO DO THESE BLTBITMAPS FOR OS/2!!! TMP!!!
// now fill the area at top of system box with backgnd color
WinFillRect(hwClientPS,&myRect,BACKGNDTEXTCOLOR);
for(i=0;i<8;i++)
{
if (MsgBuf[i][0])
{
myPoint.y = ycoord;
GpiCharStringAt(hwClientPS,&myPoint,strlen(MsgBuf[i]),(PSZ)MsgBuf[i]);
ycoord -= 15;
}
}
DosReleaseMutexSem(DrawSemaphore);
}
void DisplayComputerMove(str)
char *str;
{
char tstr[16];
int done = 0;
int i=0;
int j,k,lim;
RECTL rc;
POINTL myPoint;
APIRET rcd;
int ycoord;
if (WinNotInited)
return;
if (str[strlen(str)-1] == '\n')
{
str[strlen(str)-1] = 0;
}
rc.xLeft = 520;
rc.yBottom = COMPUTERBOX-36;
rc.xRight = 621;
rc.yTop = COMPUTERBOX+4;
rcd = DosRequestMutexSem(DrawSemaphore,2000);
if (rcd)
return;
WinFillRect(hwClientPS,&rc,BACKGNDTEXTCOLOR);
//RectFill(rpG,520,COMPUTERBOX,621,COMPUTERBOX+30);
myPoint.x = 520;
ycoord = COMPUTERBOX-10;
do {
j = i;
if (strlen(str) <= 12)
{
done = 1;
strcpy(tstr,str);
}
else
{
lim = j + 12;
if (lim >= strlen(str))
{
done = 1;
lim = strlen(str);
}
for(k=0;i<lim;i++,k++)
tstr[k] = str[i];
tstr[k] = 0;
}
myPoint.y = ycoord;
GpiCharStringAt(hwClientPS, &myPoint, strlen(tstr),
(PSZ)tstr);
//Move(rpG,520,ycoord);
//Text(rpG,tstr,strlen(tstr));
ycoord -= 12;
} while (!done);
DosReleaseMutexSem(DrawSemaphore);
}
#ifdef NEEDTODO
void DoLegalMove(str)
char *str;
{
long mpiece;
char piece;
int r,c,l;
int ecol,erow,scol,srow,side,tmp1,tmp2,incrx,incry,i;
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
if (SYSTEM_BOBS)
{
RemIBob(TheBob,rpG,vP);
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
r = str[3] - '1';
c = str[2] - 'a';
tmp1 = r & 1;
tmp2 = c & 1;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
RethinkDisplay();
WaitTOF();
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if ((color[l] == neutral))
{
ExitChess();
return;
}
else if (color[l] == white)
piece = qxx[board[l]]; /* white are lower case pieces */
else
piece = pxx[board[l]]; /* black are upper case pieces */
if ((DestRow == 7)||(!DestRow))
{ /* possible promotion */
mpiece = piece;
LoadBobImage(mpiece);
}
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[DestCol],RowArray[DestRow],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
if (SYSTEM_BOBS)
{
AddBob(TheBob,rpG);
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
if (piece >= 'a')
{
mpiece = 'r';
srow = 0;
erow = 0;
side = white;
if (str[2] == 'g') /* king side white */
{
scol = 7;
ecol = 5;
}
else
{
ecol = 3;
scol = 0;
}
}
else
{
mpiece = 'R';
srow = 7;
erow = 7;
side = black;
if (str[2] == 'g') /* king side black */
{
scol = 7;
ecol = 5;
}
else
{
ecol = 3;
scol = 0;
}
}
if (Castled[side])
{
Castled[side] = 0;
tmp1 = srow & 1;
tmp2 = scol & 1;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
BobVSprite->X = ColArray[scol];
BobVSprite->Y = RowArray[srow];
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
LoadBobImage(mpiece);
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
incry = (RowArray[erow] - RowArray[srow])/8;
incrx = (ColArray[ecol] - ColArray[scol])/8;
for(i=0;i<8;i++)
{
BobVSprite->X += incrx;
BobVSprite->Y += incry;
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
if (SYSTEM_BOBS)
{
RemIBob(TheBob,rpG,vP);
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[ecol],RowArray[erow],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
LoadBobImage(BLANKDATA);
if (SYSTEM_BOBS)
{
AddBob(TheBob,rpG);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
else /* check EnPassant */
{
side ^= 1;
if (myEnPassant[side])
{
myEnPassant[side] = 0;
scol = str[2] - 'a';
if (str[3] == '3') /* white is removed from bd at 4*/
{
srow = 3;
}
else /* black is removed at pos 5 */
{
srow = 4;
}
tmp1 = srow & 1;
tmp2 = scol & 1;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
}
}
}
#endif // NEEDTODO
void DrawChessPieces(tgthps)
HPS tgthps;
{
int bcolor,bpiece;
POINTL apts[4];
int r,c,l;
int piece;
for(r=0;r<8;r++)
for(c=0;c<8;c++)
{
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if (amigacolor[l] == white)
piece = qxx[amigaboard[l]]; /* white are lower case pieces */
else
piece = pxx[amigaboard[l]]; /* black are upper case pieces */
if (amigacolor[l] != neutral)
{
if (piece >= 'a') // white piece
{
bcolor = white;
}
else
{
bcolor = black;
}
switch (tolower(piece))
{
case 'p' :
bpiece = PAWNBOB;
break;
case 'n' :
bpiece = KNIGHTBOB;
break;
case 'b' :
bpiece = BISHOPBOB;
break;
case 'r' :
bpiece = ROOKBOB;
break;
case 'q' :
bpiece = QUEENBOB;
break;
case 'k' :
bpiece = KINGBOB;
break;
}
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = BOBWIDTH - 1; // src rt top
apts[3].y = BOBHEIGHT - 1; // src rt top
apts[0].x = ColArray[c]; // tgt left bottom
apts[0].y = RowArray[r]; // tgt left bottom
apts[1].x = apts[0].x + BOBWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + BOBHEIGHT - 1; // tgt rt top
TransBlit(TheBob[bcolor][bpiece],tgthps,hpsMemory,4L,(PPOINTL)apts);
} // color not neut
} // for c
}// drawpieces
void PutPieceBack()
{
POINTL apts[4];
APIRET rc;
int tmp1,tmp2;
int r,c,l,piece;
if (CheckIllegal)
{
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[OrigCol]; // tgt left bottom
apts[0].y = RowArray[OrigRow]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
tmp1 = OrigRow & 1;
tmp2 = OrigCol & 1;
rc = DosRequestMutexSem(DrawSemaphore,3000);
if (rc)
return;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
GpiSetBitmap(hpsMemory,WhiteBitMap);
}
else
{
GpiSetBitmap(hpsMemory,BlackBitMap);
}
GpiBitBlt(hwClientPS,hpsMemory,4,(PPOINTL)apts,ROP_SRCCOPY,BBO_IGNORE);
DosReleaseMutexSem(DrawSemaphore);
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = BOBWIDTH - 1; // src rt top
apts[3].y = BOBHEIGHT - 1; // src rt top
apts[0].x = ColArray[OrigCol]; // tgt left bottom
apts[0].y = RowArray[OrigRow]; // tgt left bottom
apts[1].x = apts[0].x + BOBWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + BOBHEIGHT - 1; // tgt rt top
TransBlit2(TheBob[CurrBobColor][CurrBobIndex],hwClientPS,hpsMemory,4L,(PPOINTL)apts);
// Now I need to put the target square back the way it was
if (((OrigRow != DestRow)||(OrigCol != DestCol))&&((DestRow != -1)&&(DestCol != -1)))
{
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[DestCol]; // tgt left bottom
apts[0].y = RowArray[DestRow]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
tmp1 = DestRow & 1;
tmp2 = DestCol & 1;
rc = DosRequestMutexSem(DrawSemaphore,3000);
if (rc)
return;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
GpiSetBitmap(hpsMemory,WhiteBitMap);
}
else
{
GpiSetBitmap(hpsMemory,BlackBitMap);
}
GpiBitBlt(hwClientPS,hpsMemory,4,(PPOINTL)apts,ROP_SRCCOPY,BBO_IGNORE);
DosReleaseMutexSem(DrawSemaphore);
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = BOBWIDTH - 1; // src rt top
apts[3].y = BOBHEIGHT - 1; // src rt top
apts[0].x = ColArray[OrigCol]; // tgt left bottom
apts[0].y = RowArray[OrigRow]; // tgt left bottom
apts[1].x = apts[0].x + BOBWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + BOBHEIGHT - 1; // tgt rt top
r = OrigRow;
c = OrigCol;
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if (amigacolor[l] == white)
piece = qxx[amigaboard[l]]; /* white are lower case pieces */
else if (amigacolor[l] == black)
piece = pxx[amigaboard[l]]; /* black are upper case pieces */
else
piece = BLANKDATA;
if (piece != BLANKDATA)
{
LoadBobImage(piece);
TransBlit2(TheBob[CurrBobColor][CurrBobIndex],hwClientPS,hpsMemory,4L,(PPOINTL)apts);
}
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = BOBWIDTH - 1; // src rt top
apts[3].y = BOBHEIGHT - 1; // src rt top
apts[0].x = ColArray[DestCol]; // tgt left bottom
apts[0].y = RowArray[DestRow]; // tgt left bottom
apts[1].x = apts[0].x + BOBWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + BOBHEIGHT - 1; // tgt rt top
r = DestRow;
c = DestCol;
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if (amigacolor[l] == white)
piece = qxx[amigaboard[l]]; /* white are lower case pieces */
else if (amigacolor[l] == black)
piece = pxx[amigaboard[l]]; /* black are upper case pieces */
else
piece = BLANKDATA;
if (piece != BLANKDATA)
{
LoadBobImage(piece);
TransBlit2(TheBob[CurrBobColor][CurrBobIndex],hwClientPS,hpsMemory,4L,(PPOINTL)apts);
}
} // fix up the dest square
CheckIllegal = 0;
}
}
void DrawAmigaBoard()
{
HPS tgthps;
int bcolor,bpiece;
POINTL apts[4];
int r,c,l,tmp1,tmp2;
int piece;
APIRET rcd;
tgthps = hwClientPS;
rcd = DosRequestMutexSem(DrawSemaphore,2000);
if (rcd)
return;
for(r=0;r<8;r++)
for(c=0;c<8;c++)
{
tmp1 = r & 1;
tmp2 = c & 1;
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[c]; // tgt left bottom
apts[0].y = RowArray[r]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
GpiSetBitmap(hpsMemory,WhiteBitMap);
}
else
{
GpiSetBitmap(hpsMemory,BlackBitMap);
}
GpiBitBlt(hwClientPS,hpsMemory,4,(PPOINTL)apts,ROP_SRCCOPY,BBO_IGNORE);
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if (amigacolor[l] == white)
piece = qxx[amigaboard[l]]; /* white are lower case pieces */
else
piece = pxx[amigaboard[l]]; /* black are upper case pieces */
if (amigacolor[l] != neutral)
{
if (piece >= 'a') // white piece
{
bcolor = white;
}
else
{
bcolor = black;
}
switch (tolower(piece))
{
case 'p' :
bpiece = PAWNBOB;
break;
case 'n' :
bpiece = KNIGHTBOB;
break;
case 'b' :
bpiece = BISHOPBOB;
break;
case 'r' :
bpiece = ROOKBOB;
break;
case 'q' :
bpiece = QUEENBOB;
break;
case 'k' :
bpiece = KINGBOB;
break;
}
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = BOBWIDTH - 1; // src rt top
apts[3].y = BOBHEIGHT - 1; // src rt top
apts[0].x = ColArray[c]; // tgt left bottom
apts[0].y = RowArray[r]; // tgt left bottom
apts[1].x = apts[0].x + BOBWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + BOBHEIGHT - 1; // tgt rt top
TransBlit(TheBob[bcolor][bpiece],tgthps,hpsMemory,4L,(PPOINTL)apts);
} // color not neut
} // for c
DosReleaseMutexSem(DrawSemaphore);
}
//#define INPUTSIGNAL (1<<InputPort->mp_SigBit)
void InputThread()
{
ULONG SysInfo[16];
int BorderX,BorderY,MenuHt,TitleHt;
APIRET rc;
int i;
//ULONG postcnt;
int xleft,ybottom;
// Init The Port We will use to communicate
InputThreadState = 0; // tell world not ready yet...
// this thread needs to open the PM window
// and prepare the event semaphore to talk
// to main chess engine with
// open the PM window...
// rc = DosCreateEventSem(semname,&semhandle,0,0);
// if (rc)
// {
// DisplayError("InputThread cannot create event sem\n");
// InputThreadState = 2;
// DosExit(1,0);
// }
rc = DosQuerySysInfo(QSV_VERSION_MAJOR,QSV_TOTPHYSMEM,SysInfo,16L*4L);
if (rc)
{
DosExit(1,0);
}
if (ForceMax)
{
ttblsize = 120001;
etblsize = 14001;
strcpy(UC_Title,"UChess Max: ");
}
else
{ // normal sizes
ttblsize = 74000;
etblsize = 8100;
}
if ((SysInfo[6] < 16000000L)||(ForceMini))
{
ttblsize = 32768;
etblsize = 3072;
strcpy(UC_Title,"UChess mini: ");
}
if ((SysInfo[6] < 7900000L)||(ForceMicro))
{
ttblsize = 16000;
etblsize = 900;
strcpy(UC_Title,"UChess baby: ");
}
ETABLE = etblsize;
rc = DosAllocMem((PPVOID)&etab[0],sizeof(struct etable)*etblsize,
(ULONG)(PAG_READ|PAG_WRITE|PAG_COMMIT));
if (rc)
{
DosExit(1,0);
}
rc = DosAllocMem((PPVOID)&etab[1],sizeof(struct etable)*etblsize,
(ULONG)(PAG_READ|PAG_WRITE|PAG_COMMIT));
if (rc)
{
DosExit(1,0);
}
rc = DosCreateEventSem(replyname,&replyhandle,0,0);
if (rc)
{
DisplayError("InputThread cannot create reply sem\n");
InputThreadState = 2;
DosExit(1,0);
}
InputThreadState = 1;
// NOW the main thread can just boogie and I will wait for it
// now create the event semaphone
while (!MainThreadStarted)
{
DosSleep(250);
}
hab= WinInitialize(0);
hmq = WinCreateMsgQueue(hab,0);
WinRegisterClass(hab,
szClientClass,
ClientWndProc,
CS_SIZEREDRAW,
0 );
TitleHt = WinQuerySysValue(HWND_DESKTOP,SV_CYTITLEBAR);
if (!TitleHt)
{
DosBeep(1280,1000);
TitleHt = 16;
}
BorderX = WinQuerySysValue(HWND_DESKTOP,SV_CXBORDER);
if (!BorderX)
{
DosBeep(1280,1000);
BorderX = 4;
}
BorderY = WinQuerySysValue(HWND_DESKTOP,SV_CYBORDER);
if (!BorderY)
{
DosBeep(1280,1000);
BorderY = 4;
}
MenuHt = WinQuerySysValue(HWND_DESKTOP,SV_CYMENU);
if (!MenuHt)
{
DosBeep(1280,1000);
MenuHt = 16;
}
hwndFrame = WinCreateStdWindow(
HWND_DESKTOP,
WS_VISIBLE,
&flCreateFlags,
szClientClass,
VERSTRING,
0,
NULLHANDLE,
MENU_ID,
&hwndClient);
if (!hwndFrame)
{
DosExit(1,0);
}
OldFrameProc = WinSubclassWindow(hwndFrame, myFrameProc);
winhdc = WinOpenWindowDC(hwndClient);
if (!DevQueryCaps(winhdc,CAPS_WIDTH,1,(PLONG)&ScreenWidth))
DosExit(1,0);
if (!DevQueryCaps(winhdc,CAPS_HEIGHT,1,(PLONG)&ScreenHeight))
DosExit(1,0);
if (!DevQueryCaps(winhdc,CAPS_COLORS,1,(PLONG)&ScreenColors))
DosExit(1,0);
if (ScreenColors < 256)
{
DisplayError("UChess requires 256 colors (or more)");
DosExit(1,0);
}
xleft = (ScreenWidth - WIDTH - 8)/2;
ybottom = (ScreenHeight - HEIGHT - 28 - 22)/2;
MaxX = WIDTH + BorderX*4+2;
MaxY = HEIGHT + BorderY*4 + MenuHt + TitleHt+4;
WinSetWindowPos(hwndFrame,HWND_TOP,xleft,ybottom,WIDTH+BorderX*4+1,
HEIGHT+BorderY*4 + MenuHt + TitleHt+1,SWP_SIZE|SWP_MOVE|SWP_SHOW);
do {
DosSleep(34);
} while (WinNotInited);
if (!GotSize)
DosExit(1,0);
InitHelp();
if (!InitmyGels())
{
DisplayError("Cannot initmy gel system");
DosExit(1,0);
}
else
{
if (!myLoadFullBitMap(1))
{
DisplayError("Cannot load the disk bitmap");
DosExit(1,0);
}
}
ShowMessage("UChess ready");
DosBeep(800,100);
while (WinGetMsg(hab,&qmsg,NULLHANDLE,0,0))
{
// in here I have to route input via msgs to other process
WinDispatchMsg(hab,&qmsg);
if (((qmsg.msg == WM_CLOSE)||(qmsg.msg == WM_QUIT))&&(qmsg.hwnd == hwndClient))
{
DestroyHelpInstance();
DosExit(1,0);
}
else
{ // here we must process the event, and send something to reply handle
// if needed
if (ReturnHit)
{
ReturnHit = 0;
if (strlen(OpEntryStr))
{ // strlen not 0
if (!(stricmp(OpEntryStr,"hint")))
{
GiveHint();
}
else if (!(stricmp(OpEntryStr,"quit")))
{
DosExit(1,0);
}
else if (RealThink)
{
OpEntryStr[0] = 0;
}
else // not hint
{
if ((!ResignOffered)&&(!flag.mate)&&(PlayMode == 2)&&(!flag.quit))
{
if (global_tmp_score < -975)
{
if (DoResign())
{
flag.mate = true;
flag.back = true;
Mate = 1;
ShowMessage("You Win!");
ShowMessage("UChess Resigns");
}
}
} // check on resigning
if (!flag.bothsides)
{
flag.back = true;
flag.musttimeout = true;
}
if ((!OpEntryRecvd)&&(!RealThink)) // do not set if already set by movenow
OpEntryRecvd = 1;
i = 5;
do {
rc = DosPostEventSem(replyhandle); // let caller know you are done
if (rc)
{
ShowMessage("Sem retry");
DosSleep(250);
}
i--;
} while ((rc)&&(i>0));
if (rc)
{
ShowMessage("Event Err");
DosBeep(1380,500);
DosSleep(1000);
DosExit(1,0);
}
} // not hint and not computers turn
} // strlen not 0
}
}
}
#ifdef AMIGAWAY
do {
rc = DosWaitEventSem(semhandle,SEM_INDEFINITE_WAIT);
if (rc)
{
DosExit(1,1);
}
DosResetEventSem(semhandle,&postcnt);
if (!flag.quit)
{ // !flag.quit
if (Global_Message == 1L) // do get op entry
{
OpEntryRecvd = 0;
do {
GetOperatorEntry(); // TMP DEBUG COMMENTED OUT!
if ((!OpEntryRecvd)&&(!RealThink)) // do not set if already set by movenow
OpEntryRecvd = 1;
if (OpEntryRecvd)
DosPostEventSem(replyhandle); // let caller know you are done
} while (!OpEntryRecvd);
}
} //flag.quit
} while ((Global_Message != 0xff));
#endif
// NOW CLOSE THE PM WINDOW
InputThreadState = 2;
DosExit(0,0);
}
#ifdef NEEDTODO
void GetOperatorEntry(void)
{
char *str;
char PromoteChar;
char mvnstr[32];
ULONG signals;
char tempstr[40];
struct IntuiMessage *message;
long done=0;
long done2;
int ilen=0;
int r,c,l,piece;
long class,code;
int MouseX,MouseY;
long tmp1,tmp2;
int tmovenum;
static int movenum;
str = OpEntryStr;
if (CheckIllegal)
{
CheckIllegal = 0;
if (IllegalMove)
{ /* put guy back! */
IllegalMove = 0;
if (SYSTEM_BOBS)
{
RemIBob(TheBob,rpG,vP);
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
if (SYSTEM_BOBS)
AddBob(TheBob,rpG);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
}
while (message = (struct IntuiMessage *)GetMsg(wG->UserPort))
{
ReplyMsg((struct Message *)message);
}
// when an illegal move is made
// the tmovenum used to be 1 too many for computer == black
if (!thinkahead)
{
if (computer == white)
{
movenum = (GameCnt)>>1;
}
else
{
movenum = (GameCnt+1)>>1; // was +2
}
}
else
{
movenum++;
}
if (!GameCnt)
tmovenum = 1;
else
{
if (thinkahead)
{
if (computer == white)
{
tmovenum = movenum - 1;
}
else
tmovenum = movenum;
}
else
{
tmovenum = movenum + 1;
}
}
if (tmovenum < 1)
tmovenum = 1;
mysprintf(mvnstr,"%d: ",tmovenum);
ObtainSemaphore(&mySemaphore);
mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
RectFill(rpG,520,USERBOX,621,USERBOX+30);
Move(rpG,520,USERBOX+6);
mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
Text(rpG,mvnstr,strlen(mvnstr));
ReleaseSemaphore(&mySemaphore);
tempstr[0] = 0;
PromoteChar = 0;
OnMenu(wG,SHOWMENUNUM);
OnMenu(wG,SUPERMENUNUM);
OnMenu(wG,THINKMENUNUM);
OnMenu(wG,BOOKMENUNUM);
do {
// if (!globalmessage_valid)
// signals = Wait(globalsignalset);
WaitPort(wG->UserPort);
// if ((signals & WINDOWSIGNAL)||(globalmessage_valid))
// {
// message = (struct IntuiMessage *)1;
while ((message = (struct IntuiMessage *)GetMsg(wG->UserPort)))
{
//if (!globalmessage_valid)
//message = (struct IntuiMessage *)GetMsg(wG->UserPort);
//if ((message)) //||(globalmessage_valid))
//{
// if (!globalmessage_valid)
// {
class = message->Class;
code = message->Code;
MouseX = message->MouseX;
MouseY = message->MouseY;
ReplyMsg((struct Message *)message);
// }
// else
// {
// class = globalmessage.Class;
// code = globalmessage.Code;
// MouseX = globalmessage.MouseX;
// MouseY = globalmessage.MouseY;
// globalmessage_valid = 0L;
// }
if (RealThink)
{ // we are in the middle of Selectmove iop == 1!!
if (class == MENUPICK)
{
if (code != MENUNULL)
{
done = HandleEvent((APTR)ItemAddress(&MenuList1,code));
if (done)
strcpy(tempstr,OpEntryStr);
}
}
else if ((class == MOUSEBUTTONS)&&(code == SELECTDOWN))
{
if (flag.bothsides)
{
if (!flag.timeout)
{
flag.back = true;
}
flag.bothsides = false;
}
}
}
else if ( class == MENUPICK ) /* MenuItems */
{ // ! realthink
if (code != MENUNULL)
{
done = HandleEvent((APTR)ItemAddress(&MenuList1,code));
if (done)
strcpy(tempstr,OpEntryStr);
if (flag.quit)
done = 1;
else if (!done)
{
if (teston)
{
done = 1;
teston = 0;
strcpy(tempstr,"test");
}
else if (doswap)
{
done = 1;
doswap = 0;
strcpy(tempstr,"switch");
}
else if (doauto)
{
done = 1;
doauto = 0;
strcpy(tempstr,"both");
}
else if (doundo)
{
done = 1;
doundo = 0;
strcpy(tempstr,"help");
}
}
}
}
else if ((class == RAWKEY) && (!RealThink))
{
if (code < 80)
{
code = cookedchar[code];
if ((code == 13)||(code == 10))
{
if (tempstr[0])
done = 1;
}
else if ((code == 7)&&(ilen)) /* backspace */
{
tempstr[strlen(tempstr)-1] = '\0';
mysprintf(mvnstr,"%d: ",tmovenum);
ObtainSemaphore(&mySemaphore);
mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
RectFill(rpG,520,USERBOX,621,USERBOX+30);
mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
Move(rpG,520,USERBOX+6);
Text(rpG,mvnstr,strlen(mvnstr));
Text(rpG,tempstr,strlen(tempstr));
ReleaseSemaphore(&mySemaphore);
ilen--;
}
else if ((isalnum(code)||(code == '-')||(code == '/')) && (strlen(tempstr) < 12))
{
tempstr[ilen] = tolower(code);
ilen++;
tempstr[ilen] = 0;
mysprintf(mvnstr,"%d: ",tmovenum);
ObtainSemaphore(&mySemaphore);
mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
Move(rpG,520,USERBOX+6);
Text(rpG,mvnstr,strlen(mvnstr));
Text(rpG,tempstr,strlen(tempstr));
ReleaseSemaphore(&mySemaphore);
}
} /* code < 80 */
}
else if ((class == MOUSEBUTTONS)&&(!(flag.quit || flag.mate || flag.force))
&&(!RealThink))
{
if ((code == SELECTDOWN) &&
((MouseY <= (ROW1+SQUAREHEIGHT)) && (MouseY >= ROW8) && (MouseX <= (COLH+BOBWIDTH)) &&
(MouseX >= COLA)))
{
if (MouseX < COLB)
OrigCol = 0;
else if (MouseX < COLC)
OrigCol = 1;
else if (MouseX < COLD)
OrigCol = 2;
else if (MouseX < COLE)
OrigCol = 3;
else if (MouseX < COLF)
OrigCol = 4;
else if (MouseX < COLG)
OrigCol = 5;
else if (MouseX < COLH)
OrigCol = 6;
else
OrigCol = 7;
if (MouseY < ROW7)
OrigRow = 7;
else if (MouseY < ROW6)
OrigRow = 6;
else if (MouseY < ROW5)
OrigRow = 5;
else if (MouseY < ROW4)
OrigRow = 4;
else if (MouseY < ROW3)
OrigRow = 3;
else if (MouseY < ROW2)
OrigRow = 2;
else if (MouseY < ROW1)
OrigRow = 1;
else
OrigRow = 0;
tmp1 = OrigRow & 1L;
tmp2 = OrigCol & 1L;
done2 = 0;
r = OrigRow;
c = OrigCol;
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if ((amigacolor[l] == neutral)||(opponent != amigacolor[l]))
{
done2 = 1;
}
else if (amigacolor[l] == white)
piece = qxx[amigaboard[l]]; /* white are lower case pieces */
else
piece = pxx[amigaboard[l]]; /* black are upper case pieces */
if (!done2)
{
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[OrigCol],
RowArray[OrigRow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[OrigCol],
RowArray[OrigRow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
CheckIllegal = 1;
IllegalMove = 0;
/* NOW POSITION BOB AND LOAD IN ITS CORRECT PIECE IMAGE */
LoadBobImage(piece);
BobVSprite->X = MouseX - 24;
BobVSprite->Y = MouseY - 16;
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
ModifyIDCMP(wG,NewWindowStructure1.IDCMPFlags | INTUITICKS);
do {
signals = Wait(globalsignalset);
if (signals & WINDOWSIGNAL)
{
while ( (message = (struct IntuiMessage *)
GetMsg(wG->UserPort) ))
{
class = message->Class;
code = message->Code;
MouseX = message->MouseX;
MouseY = message->MouseY;
ReplyMsg((struct Message *)message);
if (!done2)
{
if ((class == MOUSEBUTTONS)&&(code == SELECTUP))
{ /* now try and make the move */
done2 = 1;
if ((MouseX > (COLH+SQUAREWIDTH)) || (MouseX < COLA) ||
(MouseY < ROW8) || (MouseY > (ROW1+BOBHEIGHT)))
{ /* Put the Piece Back */
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
tmp1 = lastpiece;
LoadBobImage(BLANKDATA);
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
RemIBob(TheBob,rpG,vP);
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
LoadBobImage(tmp1);
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
if (SYSTEM_BOBS)
{
AddBob(TheBob,rpG);
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
else
{
done = 1; /* try the move */
if (MouseX < COLB)
DestCol = 0;
else if (MouseX < COLC)
DestCol = 1;
else if (MouseX < COLD)
DestCol = 2;
else if (MouseX < COLE)
DestCol = 3;
else if (MouseX < COLF)
DestCol = 4;
else if (MouseX < COLG)
DestCol = 5;
else if (MouseX < COLH)
DestCol = 6;
else
DestCol = 7;
if (MouseY < ROW7)
DestRow = 7;
else if (MouseY < ROW6)
DestRow = 6;
else if (MouseY < ROW5)
DestRow = 5;
else if (MouseY < ROW4)
DestRow = 4;
else if (MouseY < ROW3)
DestRow = 3;
else if (MouseY < ROW2)
DestRow = 2;
else if (MouseY < ROW1)
DestRow = 1;
else
DestRow = 0;
if ((DestRow == OrigRow) && (DestCol == OrigCol))
{
done = 0;
tmp1 = lastpiece;
LoadBobImage(BLANKDATA);
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
RemIBob(TheBob,rpG,vP);
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
LoadBobImage(tmp1);
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
if (SYSTEM_BOBS)
{
AddBob(TheBob,rpG);
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
else
{
MouseDropped = 1;
if (((piece == 'p')&&(DestRow == 7))||/* possible prom wht */
((piece == 'P')&&(!DestRow))) /* possible blk promotion */
{
PromoteChar = DisplayPromoteRequestor();
}
tempstr[4] = 0;
tempstr[0] = OrigCol + 'a';
tempstr[1] = OrigRow + '1';
tempstr[2] = DestCol + 'a';
tempstr[3] = DestRow + '1';
mysprintf(mvnstr,"%d: ",tmovenum);
ObtainSemaphore(&mySemaphore);
mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
Move(rpG,520,USERBOX+6);
Text(rpG,mvnstr,strlen(mvnstr));
Text(rpG,tempstr,strlen(tempstr));
ReleaseSemaphore(&mySemaphore);
if ((thinkahead)&&(!flag.bothsides))
{ // code to abort quickly and drop piece!
(void)SetTaskPri((struct Task *)myproc,procpri);
if (!TCflag)
backsrchaborted = 1;
if (!flag.timeout)
{
flag.back = true;
}
}
}
}
}
else if (class == INTUITICKS)
{
BobVSprite->X = MouseX - 24;
BobVSprite->Y = MouseY - 16;
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
} /* ! done2 */
}
} /* signals & WINDOWSIGNAL */
} while (!done2);
ModifyIDCMP(wG,NewWindowStructure1.IDCMPFlags);
while ( (message = (struct IntuiMessage *)
GetMsg(wG->UserPort) ))
{
ReplyMsg((struct Message *)message);
}
}
}
//} // if message
// if (done)
// {
// while ((message = (struct IntuiMessage *)GetMsg(wG->UserPort)))
// ReplyMsg((struct Message *)message);
// }
} /* while message */
//} /* signals & windowsignal */
} while (!done);
OffMenu(wG,SHOWMENUNUM);
OffMenu(wG,BOOKMENUNUM);
OffMenu(wG,SUPERMENUNUM);
OffMenu(wG,THINKMENUNUM);
if (tempstr[0])
{
if (tempstr[2] == '-')
{
for(ilen=2;ilen<strlen(tempstr);ilen++)
tempstr[ilen] = tempstr[ilen+1];
}
if (tempstr[4] == '/')
{
for(ilen=4;ilen<strlen(tempstr);ilen++)
tempstr[ilen] = tempstr[ilen+1];
}
}
if ((!PromoteChar)&&((strlen(tempstr) == 2) || (strlen(tempstr) == 4)))
{
r = tempstr[1] - '1';
if ((strlen(tempstr) == 2)&&(opponent == white))
{
r--;
}
else if ((strlen(tempstr) == 2)&&(opponent == black))
{
r++;
}
c = tempstr[0] - 'a';
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if ((amigacolor[l] == neutral)||(opponent != amigacolor[l]))
{
done2 = 1;
}
else if (amigacolor[l] == white)
piece = qxx[amigaboard[l]]; /* white are lower case pieces */
else
piece = pxx[amigaboard[l]]; /* black are upper case pieces */
if (strlen(tempstr) == 4)
{
r = tempstr[3] - '1';
}
else
{
if (opponent == white)
{
r++;
}
else
{
r--;
}
}
if (((piece == 'p')&&(r == 7))||/* possible prom wht */
((piece == 'P')&&(!r))) /* possible blk promotion */
{
PromoteChar = DisplayPromoteRequestor();
if (strlen(tempstr) == 2)
{
if (!r)
{
tempstr[4] = 0;
tempstr[3] = tempstr[1];
tempstr[2] = tempstr[0];
tempstr[1]++;
}
else
{
tempstr[4] = 0;
tempstr[3] = tempstr[1];
tempstr[2] = tempstr[0];
tempstr[1]--;
}
}
}
}
if (PromoteChar)
{
ilen = strlen(tempstr);
tempstr[ilen] = PromoteChar;
tempstr[ilen+1] = 0;
}
strcpy(str,tempstr);
if (!(stricmp(str,"new")))
{
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
if (SYSTEM_BOBS)
{
SortGList(rpG);
DrawGList(rpG,vP);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
WaitTOF();
RethinkDisplay();
}
}
#endif // NEEDTODO
void AnimCastle(str)
char *str;
{
POINTL apts[4],apts2[4];
APIRET rc;
int r,c;
int bobcolor;
// king is moved must now erase old castle, and draw new one
Castled[opponent] = 0;
rc = DosRequestMutexSem(DrawSemaphore,3000);
if (rc)
return;
if (str[1] == '1') // white
{
bobcolor = white;
if (tolower(str[2]) == 'c')
{ // queen side
c = 3; // col d
r = 0; // row 1
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[0]; // tgt left bottom
apts[0].y = RowArray[0]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
GpiSetBitmap(hpsMemory,WhiteBitMap);
}
else
{ // king side
c = 5; // col f
r = 0; // row 1
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[7]; // tgt left bottom
apts[0].y = RowArray[0]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
GpiSetBitmap(hpsMemory,BlackBitMap);
}
}
else if (str[1] == '8') // black
{
bobcolor = black;
if (tolower(str[2]) == 'c')
{ // queen side
c = 3; // col d
r = 7; // row 8
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[0]; // tgt left bottom
apts[0].y = RowArray[7]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
GpiSetBitmap(hpsMemory,BlackBitMap);
}
else
{ // king side
c = 5; // col f
r = 7; // row 8
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[7]; // tgt left bottom
apts[0].y = RowArray[7]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
GpiSetBitmap(hpsMemory,WhiteBitMap);
}
}
else // mistake
{
DosReleaseMutexSem(DrawSemaphore);
return;
}
GpiBitBlt(hwClientPS,hpsMemory,4,(PPOINTL)apts,ROP_SRCCOPY,BBO_IGNORE);
apts2[2].x = 0; // src left bottom
apts2[2].y = 0; // src left bottom
apts2[3].x = BOBWIDTH - 1; // src rt top
apts2[3].y = BOBHEIGHT - 1; // src rt top
apts2[0].x = ColArray[c]; // tgt left bottom
apts2[0].y = RowArray[r]; // tgt left bottom
apts2[1].x = apts2[0].x + BOBWIDTH - 1; // tgt rt top
apts2[1].y = apts2[0].y + BOBHEIGHT - 1; // tgt rt top
TransBlit(TheBob[bobcolor][ROOKBOB],hwClientPS,hpsMemory,4L,(PPOINTL)apts2);
DosReleaseMutexSem(DrawSemaphore);
}
void AnimEnPassant(str)
char *str;
{
APIRET rcd;
POINTL apts[4];
int r,c,tmp1,tmp2;
myEnPassant[opponent^1] = 0;
// in this case I have to remove the pawn directly behind or in front of me
// I made the EnPassant move, so I took his pawn
// if I am white it is in the row one prior to mine me
// if I am black it is in the row one in front of mine
if (opponent == white) // I am white
{
if (str[3] != '6')
{
return;
}
r = 4; // row 5
c = tolower(str[2]) - 'a';
}
else
{
if (str[3] != '3')
{
return;
}
r = 3; // row 4
c = tolower(str[2]) - 'a';
}
if ((c < 0)||(c > 7))
return;
tmp1 = r & 1;
tmp2 = c & 1;
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[c]; // tgt left bottom
apts[0].y = RowArray[r]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
rcd = DosRequestMutexSem(DrawSemaphore,2000);
if (rcd)
return;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
GpiSetBitmap(hpsMemory,WhiteBitMap);
}
else
{
GpiSetBitmap(hpsMemory,BlackBitMap);
}
GpiBitBlt(hwClientPS,hpsMemory,4,(PPOINTL)apts,ROP_SRCCOPY,BBO_IGNORE);
DosReleaseMutexSem(DrawSemaphore);
}
void AnimateAmigaMove(str,piece)
char *str;
char piece; /* black are upper case pieces, white lower case */
{
int side;
int tmp1,tmp2;
int srow,scol,erow,ecol,incrx,incry,i;
POINTL apts[4];
APIRET rc;
long mpiece;
if ((piece == ' ')||(flag.quit))
return;
mpiece = piece;
if (!MouseDropped)
{
scol = str[0] - 'a';
srow = str[1] - '1';
ecol = str[2] - 'a';
erow = str[3] - '1';
tmp1 = srow & 1;
tmp2 = scol & 1;
rc = DosRequestMutexSem(DrawSemaphore,3000);
if (rc)
return;
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[scol]; // tgt left bottom
apts[0].y = RowArray[srow]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
GpiSetBitmap(hpsMemory,WhiteBitMap);
}
else
{
GpiSetBitmap(hpsMemory,BlackBitMap);
}
GpiBitBlt(hwClientPS,hpsMemory,4,(PPOINTL)apts,ROP_SRCCOPY,BBO_IGNORE);
tmp1 = erow & 1;
tmp2 = ecol & 1;
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[ecol]; // tgt left bottom
apts[0].y = RowArray[erow]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
GpiSetBitmap(hpsMemory,WhiteBitMap);
}
else
{
GpiSetBitmap(hpsMemory,BlackBitMap);
}
GpiBitBlt(hwClientPS,hpsMemory,4,(PPOINTL)apts,ROP_SRCCOPY,BBO_IGNORE);
DosReleaseMutexSem(DrawSemaphore);
LoadBobImage(mpiece);
TheBob[CurrBobColor][CurrBobIndex]->XPos = ColArray[scol];
TheBob[CurrBobColor][CurrBobIndex]->YPos = RowArray[srow];
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
incry = (RowArray[erow] - RowArray[srow])/8;
incrx = (ColArray[ecol] - ColArray[scol])/8;
for(i=0;i<8;i++)
{
if (i == 7)
{
TheBob[CurrBobColor][CurrBobIndex]->XPos = ColArray[ecol];
TheBob[CurrBobColor][CurrBobIndex]->YPos = RowArray[erow];
}
else
{
TheBob[CurrBobColor][CurrBobIndex]->XPos += incrx;
TheBob[CurrBobColor][CurrBobIndex]->YPos += incry;
}
DrawGList();
}
RemBobNR(TheBob[CurrBobColor][CurrBobIndex]); // do not erase when removing it!
if (piece >= 'a')
{
mpiece = 'r';
srow = 0;
erow = 0;
side = white;
if (str[2] == 'g') /* king side white */
{
scol = 7;
ecol = 5;
}
else
{
ecol = 3;
scol = 0;
}
}
else
{
mpiece = 'R';
srow = 7;
erow = 7;
side = black;
if (str[2] == 'g') /* king side black */
{
scol = 7;
ecol = 5;
}
else
{
ecol = 3;
scol = 0;
}
}
if (Castled[side])
{
Castled[side] = 0;
tmp1 = srow & 1;
tmp2 = scol & 1;
rc = DosRequestMutexSem(DrawSemaphore,3000);
if (rc)
return;
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[scol]; // tgt left bottom
apts[0].y = RowArray[srow]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
GpiSetBitmap(hpsMemory,WhiteBitMap);
}
else
{
GpiSetBitmap(hpsMemory,BlackBitMap);
}
GpiBitBlt(hwClientPS,hpsMemory,4,(PPOINTL)apts,ROP_SRCCOPY,BBO_IGNORE);
DosReleaseMutexSem(DrawSemaphore);
LoadBobImage(mpiece);
TheBob[CurrBobColor][CurrBobIndex]->XPos = ColArray[scol];
TheBob[CurrBobColor][CurrBobIndex]->YPos = RowArray[srow];
AddBob(TheBob[CurrBobColor][CurrBobIndex]);
DrawGList();
incry = (RowArray[erow] - RowArray[srow])/8;
incrx = (ColArray[ecol] - ColArray[scol])/8;
for(i=0;i<8;i++)
{
if (i == 7)
{
TheBob[CurrBobColor][CurrBobIndex]->XPos = ColArray[ecol];
TheBob[CurrBobColor][CurrBobIndex]->YPos = RowArray[erow];
}
else
{
TheBob[CurrBobColor][CurrBobIndex]->XPos += incrx;
TheBob[CurrBobColor][CurrBobIndex]->YPos += incry;
}
DrawGList();
}
RemBobNR(TheBob[CurrBobColor][CurrBobIndex]);
}
else /* check EnPassant */
{
side ^= 1;
if (myEnPassant[side])
{
myEnPassant[side] = 0;
scol = str[2] - 'a';
if (str[3] == '3') /* white is removed from bd at 4*/
{
srow = 3;
}
else /* black is removed at pos 5 */
{
srow = 4;
}
tmp1 = srow & 1;
tmp2 = scol & 1;
rc = DosRequestMutexSem(DrawSemaphore,3000);
if (rc)
return;
apts[2].x = 0; // src left bottom
apts[2].y = 0; // src left bottom
apts[3].x = SQUAREWIDTH - 1; // src rt top
apts[3].y = SQUAREHEIGHT - 1; // src rt top
apts[0].x = ColArray[scol]; // tgt left bottom
apts[0].y = RowArray[srow]; // tgt left bottom
apts[1].x = apts[0].x + SQUAREWIDTH - 1; // tgt rt top
apts[1].y = apts[0].y + SQUAREHEIGHT - 1; // tgt rt top
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
GpiSetBitmap(hpsMemory,WhiteBitMap);
}
else
{
GpiSetBitmap(hpsMemory,BlackBitMap);
}
GpiBitBlt(hwClientPS,hpsMemory,4,(PPOINTL)apts,ROP_SRCCOPY,BBO_IGNORE);
DosReleaseMutexSem(DrawSemaphore);
}
}
} // !MOUSE DROPPED
}
#ifdef AMIGA
void GetTimeString(str)
char *str;
{
}
#endif
char *ColorStr[2];
char *CP[CPSIZE];
/*
* In a networked enviroment gnuchess might be compiled on different hosts
* with different random number generators, that is not acceptable if they
* are going to share the same transposition table.
*/
unsigned int urand (void);
unsigned long hashkey, hashbd;
#ifdef LONGINTS2
struct hashval hashcode[2][7][64];
#else
struct hashval hashcode[2][7][64];
#endif
#ifdef CACHE
#ifdef ttblsz
struct hashentry *ttable[2];
unsigned int ttblsize=ttblsz;
#endif
#else
#ifdef ttblsz
struct hashentry ttable[2][vttblsz + MAXrehash];
unsigned int ttblsize=ttblsz;
#endif
#endif
char savefile[128] = "";
char listfile[128] = "";
#ifdef HISTORY
unsigned char history[32768];
#endif
INTSIZE rpthash[2][256];
struct leaf Tree[TREE];
struct leaf *root;
INTSIZE TrPnt[MAXDEPTH];
INTSIZE PieceList[2][64], PawnCnt[2][8];
INTSIZE castld[2], Mvboard[64];
INTSIZE svalue[64];
struct flags flag;
INTSIZE opponent, computer, WAwindow, WBwindow, BAwindow, BBwindow, dither, INCscore;
long ResponseTime, ExtraTime, MaxResponseTime, et, et0, time0, ft;
long GenCnt, NodeCnt, ETnodes, EvalNodes, HashCnt, HashAdd, FHashCnt, FHashAdd, HashCol,
THashCol, filesz;
long replus, reminus;
INTSIZE HashDepth = HASHDEPTH, HashMoveLimit = HASHMOVELIMIT;
INTSIZE player, xwndw, rehash;
struct GameRec GameList[MAXMOVES + MAXDEPTH];
INTSIZE Sdepth, GameCnt, Game50, MaxSearchDepth;
INTSIZE epsquare, contempt;
int Book;
struct TimeControlRec TimeControl;
INTSIZE TCflag, TCmoves, TCminutes, TCseconds, OperatorTime;
INTSIZE XCmoves[3], XCminutes[3], XCseconds[3], XC, XCmore;
const INTSIZE otherside[3] =
{black, white, neutral};
unsigned INTSIZE hint;
INTSIZE int TOflag; /* force search re-init if we backup search */
INTSIZE mtl[2], pmtl[2], hung[2];
INTSIZE Pindex[64];
INTSIZE PieceCnt[2];
INTSIZE FROMsquare, TOsquare;
INTSIZE HasKnight[2], HasBishop[2], HasRook[2], HasQueen[2];
INTSIZE ChkFlag[MAXDEPTH], CptrFlag[MAXDEPTH], PawnThreat[MAXDEPTH];
INTSIZE Pscore[MAXDEPTH], Tscore[MAXDEPTH];
const INTSIZE qrook[3] =
{0, 56, 0};
const INTSIZE krook[3] =
{7, 63, 0};
const INTSIZE kingP[3] =
{4, 60, 0};
const INTSIZE rank7[3] =
{6, 1, 0};
const INTSIZE sweep[8] =
{false, false, false, true, true, true, false, false};
unsigned INTSIZE killr0[MAXDEPTH], killr1[MAXDEPTH];
unsigned INTSIZE killr2[MAXDEPTH], killr3[MAXDEPTH];
unsigned INTSIZE PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4;
#ifdef USE_SIDEBIT
unsigned INTSIZE sidebit;
#endif
#ifdef KILLT
INTSIZE killt[0x4000];
#endif
const INTSIZE value[7] =
{0, valueP, valueN, valueB, valueR, valueQ, valueK};
const INTSIZE control[7] =
{0, ctlP, ctlN, ctlB, ctlR, ctlQ, ctlK};
INTSIZE stage, stage2, Developed[2];
FILE *hashfile;
unsigned int starttime;
INTSIZE int ahead = true, hash = true;
#if defined CHESSTOOL || defined XBOARD
void
TerminateChess (int sig)
{
ExitChess();
}
#endif
int timeopp[MINGAMEIN], timecomp[MINGAMEIN];
int compptr, oppptr;
inline void
TimeCalc ()
{
/* adjust number of moves remaining in gamein games */
int increment = 0;
int topsum = 0;
int tcompsum = 0;
int me,him;
int i;
/* dont do anything til you have enough numbers */
if (GameCnt < (MINGAMEIN * 2)) return;
/* calculate average time in sec for last MINGAMEIN moves */
for (i = 0; i < MINGAMEIN; i++)
{
tcompsum += timecomp[i];
topsum += timeopp[i];
}
topsum /= (100 * MINGAMEIN);
tcompsum /= (100 * MINGAMEIN);
/* if I have less time than opponent add another move */
me = TimeControl.clock[computer]/100;
him = TimeControl.clock[opponent]/100;
if(me < him) increment += 2;
/* if I am losing more time with each move add another */
/*if ( !((me - him) > 60) && tcompsum > topsum) increment++;*/
if ( tcompsum > topsum) increment +=2;
/* but dont let moves go below MINMOVES */
else if (TimeControl.moves[computer] < MINMOVES && !increment) increment++;
/* if I am doing really well use more time per move */
else if (me > him && tcompsum < topsum) increment = -1;
TimeControl.moves[computer] += increment;
}
/* hmm.... shouldn`t main be moved to the interface routines */
void main (argc,argv)
int argc;
char *argv[];
{
// char cstring[40];
char *xwin = 0;
char *Lang = NULL;
int l,src_row,src_col,dest_row,dest_col,piece;
if (argc > 1)
{
if ((!stricmp(argv[1],"max"))||(!stricmp(argv[1],"maxi")))
{
ForceMax = 1;
}
else
{
ForceMax = 0;
}
if (!stricmp(argv[1],"mini"))
{
ForceMini = 1;
}
else
{
ForceMini = 0;
}
if ((!stricmp(argv[1],"micro"))||(!stricmp(argv[1],"baby")))
{
ForceMicro = 1;
}
else
{
ForceMicro = 0;
}
}
#ifdef AMIGA
int tmpargcnt;
struct WBStartup *startmsg;
struct ExecBase **execbaseptr=(struct ExecBase **)4L;
UWORD cpuid;
struct ExecBase *execbase;
BPTR fp;
APTR tempxx;
struct WBArg *mywbptr;
struct DiskObject *dob;
execbase = *execbaseptr;
cpuid = execbase->AttnFlags;
if (!(cpuid & AFF_68020))
{
exit(0);
}
gfxversion = GfxBase->LibNode.lib_Version;
if (gfxversion < 37)
exit(-1);
if (!aargc)
{
startmsg = (struct WBStartup *)aargv;
mywbptr = startmsg->sm_ArgList;
if (dob = GetDiskObject (mywbptr->wa_Name))
{
xwin = FindToolType(dob->do_ToolTypes,"PRI");
if (xwin)
{
procpri = xwin[0] - '0';
if (procpri < 0)
procpri = 0;
if (procpri > 4)
procpri = 4;
}
xwin = FindToolType(dob->do_ToolTypes,"COLORS");
if (xwin)
{
if ((xwin[0] == '1')&&(xwin[1] == '6'))
gfxversion = 37;
else if ((xwin[0] == '6')&&(xwin[1] == '4'))
FasterDisplay = 1;
}
xwin = FindToolType(dob->do_ToolTypes,"MONITOR");
if (xwin)
{
if ((xwin[0] == '1')&&(xwin[1] == '5'))
v15Khz = 1;
}
xwin = FindToolType(dob->do_ToolTypes,"FASTAGA");
if (xwin)
{
if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
FasterDisplay = 1;
}
xwin = FindToolType(dob->do_ToolTypes,"SUPER72");
if (xwin)
{
if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
Super72 = 1;
}
xwin = FindToolType(dob->do_ToolTypes,"RTG");
if (xwin)
{
if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
RTG = 1;
}
// xwin = FindToolType(dob->do_ToolTypes,"PICASSO");
// if (xwin)
// {
// if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
// Picasso = 1;
// }
xwin = FindToolType(dob->do_ToolTypes,"NO_BOBS");
if (xwin)
{
if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
SYSTEM_BOBS = 0;
}
FreeDiskObject (dob);
}
xwin = 0L;
}
else if (aargc > 1)
{
for(tmpargcnt=1;tmpargcnt<aargc;tmpargcnt++)
{
if (!(strcmp(aargv[tmpargcnt],"16")))
{
gfxversion = 37;
}
else if (!(stricmp(aargv[tmpargcnt],"Super72")))
{
Super72 = 1;
}
else if (!(stricmp(aargv[tmpargcnt],"RTG")))
{
RTG = 1;
}
else if (!(stricmp(aargv[tmpargcnt],"NOBOBS")))
{
SYSTEM_BOBS = 0;
}
else if (!(stricmp(aargv[tmpargcnt],"15KHZ")))
{
v15Khz = 1;
}
// else if (!(stricmp(aargv[tmpargcnt],"PICASSO")))
// {
// Picasso = 1;
// }
else if ((!(stricmp(aargv[tmpargcnt],"FASTAGA")))||((!(strcmp(aargv[tmpargcnt],"64")))))
{
FasterDisplay = 1;
}
else if (strcmp(aargv[tmpargcnt],"256"))
{
procpri=atoi(aargv[tmpargcnt]);
if (procpri < 0)
procpri = 0;
if (procpri > 4)
procpri = 4;
}
}
}
if (gfxversion < 39)
RTG = Super72 = 0;
if (RTG)
{
FasterDisplay = 0;
v15Khz = 0;
}
// if (!RTG)
// Picasso = 0;
Delay(3L);
myproc = (struct Process *)FindTask(0L);
tempxx = myproc->pr_WindowPtr;
Delay(3L);
myproc->pr_WindowPtr = (APTR)-1L;
if (!(fp = Open("uchess:uchess.lang",MODE_OLDFILE)))
{
system("Assign >nil: uchess: \"\"");
}
else
Close(fp);
myproc->pr_WindowPtr = tempxx;
#endif // AMIGA
#ifdef ttblsz
ttblsize = ttblsz;
rehash = -1;
#endif /* ttblsz */
gsrand (starttime = ((unsigned int) time (0L))); /* init urand */
flag.easy = 0; // was 0
#ifndef AMIGA
// if (argc > 2)
// {
// if (argv[1][0] == '-' && argv[1][1] == 'L')
// {
// Lang = argv[2];
// argv += 2;
// argc -= 2;
// }
// }
#endif
InitConst (Lang);
ColorStr[0] = CP[118];
ColorStr[1] = CP[119];
#ifndef AMIGA
#ifdef IWANTTHIS
while (argc > 1 && ((argv[1][0] == '-') || (argv[1][0] == '+')))
{
switch (argv[1][1])
{
case 'a':
ahead = ((argv[1][0] == '-') ? false : true);
break;
case 'h':
hash = ((argv[1][0] == '-') ? false : true);
break;
case 's':
argc--;
argv++;
if (argc > 1)
strcpy (savefile, argv[1]);
break;
case 'l':
argc--;
argv++;
if (argc > 1)
strcpy (listfile, argv[1]);
break;
#if ttblsz
case 'r':
if (argc > 2)
rehash = atoi (argv[2]);
argc--;
argv++;
if (rehash > MAXrehash)
rehash = MAXrehash;
break;
case 'T':
if (argc > 2)
ttblsize = atoi (argv[2]);
argc--;
argv++;
if (ttblsize > 0 && ttblsize < 24)
ttblsize = (1 << ttblsize);
else
ttblsize = ttblsz;
break;
#ifdef HASHFILE
case 't': /* create or test persistent transposition
* table */
hashfile = fopen (HASHFILE, RWA_ACC);
if (hashfile)
{
fseek (hashfile, 0L, SEEK_END);
filesz = (ftell (hashfile) / sizeof (struct fileentry)) - 1;
}
if (hashfile != NULL)
{
long i, j;
int nr[MAXDEPTH];
struct fileentry n;
/*ShowMessage (CP[49]);*/
for (i = 0; i < MAXDEPTH; i++)
nr[i] = 0;
fseek (hashfile, 0L, SEEK_END);
i = ftell (hashfile) / sizeof (struct fileentry);
fseek (hashfile, 0L, SEEK_SET);
for (j = 0; j < i + 1; j++)
{
fread (&n, sizeof (struct fileentry), 1, hashfile);
if (n.depth)
{
nr[n.depth]++;
nr[0]++;
}
}
sprintf (astr,CP[109],
nr[0], i);
/*ShowMessage(astr);*/
for (j = 1; j < MAXDEPTH; j++)
/*
printf ("%d ", nr[j]);
printf ("\n")*/;
}
return 0;
case 'c': /* create or test persistent transposition
* table */
if (argc > 2)
filesz = atoi (argv[2]);
if (filesz > 0 && filesz < 24)
filesz = (1 << filesz) - 1 + MAXrehash;
else
filesz = Deffilesz + MAXrehash;
if ((hashfile = fopen (HASHFILE, RWA_ACC)) == NULL)
hashfile = fopen (HASHFILE, WA_ACC);
if (hashfile != NULL)
{
long j;
struct fileentry n;
/*printf (CP[66]);*/
for (j = 0; j < 32; j++)
n.bd[j] = 0;
n.f = n.t = 0;
n.flags = 0;
n.depth = 0;
n.sh = n.sl = 0;
for (j = 0; j < filesz + 1; j++)
fwrite (&n, sizeof (struct fileentry), 1, hashfile);
fclose (hashfile);
}
/* else
printf (CP[50], HASHFILE);*/
return (0);
#endif /* HASHFILE */
#endif /* ttblsz */
case 'x':
xwin = &argv[1][2];
break;
case 'v':
/* fprintf (stderr, CP[102], version, patchlevel);*/
exit (1);
default:
/*fprintf (stderr, CP[113]);*/
exit (1);
}
argv++;
argc--;
}
#endif // I want this all startup
#endif // ndef amiga
XC = 0;
MaxResponseTime = 0;
#if defined CHESSTOOL || defined XBOARD
signal (SIGTERM, TerminateChess);
TCflag = true;
TCmoves = 40;
TCminutes = 120;
TCseconds = 0;
TCadd = 0;
OperatorTime = 0;
#else
/* TCflag = false;*/
/* OperatorTime = 0;*/
TCflag = true;
TCmoves = 60;
TCminutes = 10;
TCseconds = 0;
OperatorTime = 0;
#endif
#ifdef IWANTHIS
if (argc == 2)
{
char *p;
MaxResponseTime = 100L*strtol(argv[1], &p, 10);
if (*p == ':')
MaxResponseTime = 60L*MaxResponseTime +
100L*strtol(++p, (char **) NULL, 10);
TCflag = false;
TCmoves = 0;
TCminutes = 0;
TCseconds = 0;
}
if (argc >= 3)
{
char *p;
if (argc > 9)
{
/* printf ("%s\n", CP[220]);*/
exit (1);
}
TCmoves = atoi (argv[1]);
TCminutes = strtol (argv[2], &p, 10);
if (*p == ':')
TCseconds = strtol (p + 1, (char **) NULL, 10);
else
TCseconds = 0;
TCflag = true;
argc -= 3;
argv += 3;
while (argc > 1)
{
XCmoves[XC] = atoi (argv[0]);
XCminutes[XC] = strtol (argv[1], &p, 10);
if (*p == ':')
XCseconds[XC] = strtol (p + 1, (char **) NULL, 10);
else
XCseconds[XC] = 0;
if (XCmoves[XC] && (XCminutes[XC] || XCseconds[XC]))
XC++;
else
{
/*printf (CP[220]);*/
exit (1);
}
argc -= 2;
argv += 2;
}
if (argc)
{
/*printf ("%s\n", CP[220]);*/
exit (1);
}
}
#endif /* IWANTHIS */
#ifdef AMIGA
(void)SetTaskPri((struct Task *)myproc,procpri);
Delay(3L);
if (!AmigaStartup())
{
exit(2);
}
#else
if (!(PM_Startup()))
{
exit(2);
}
#endif
Initialize ();
#ifndef CACHE
#ifdef ttblsz
Initialize_ttable ();
#endif /* ttblsz */
#endif
Initialize_dist ();
Initialize_moves ();
FirstTime = 1;
NewGame ();
flag.easy = 0; // I want to start with thinking on so should be 0
flag.hash = hash;
if (xwin)
xwndw = atoi (xwin);
hashfile = NULL;
#if ttblsz
#ifdef HASHFILE
hashfile = fopen (HASHFILE, RWA_ACC);
if (hashfile)
{
fseek (hashfile, 0L, SEEK_END);
filesz = ftell (hashfile) / sizeof (struct fileentry) - 1;
}
#if !defined CHESSTOOL && !defined XBOARD
else
ShowMessage (CP[98]);
#endif
#endif /* HASHFILE */
#endif /* ttblsz */
#ifdef AMIGA
SetMenuStrip(wG,&MenuList1); /* attach any Menu */
MenuStripSet = 1;
EnableMoveNow();
#endif
while (!(flag.quit))
{
oppptr = (oppptr + 1) % MINGAMEIN;
if (flag.bothsides && !flag.mate)
{
//SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
SelectMove (opponent, 1);
MoveMem128(color,amigacolor);
MoveMem128(board,amigaboard);
DosSleep(350);
}
else
{
InputCommand ();
}
if (opponent == black)
if (flag.gamein || TCadd)
{
TimeCalc ();
}
else if (TimeControl.moves[opponent] == 0)
{
if (XC)
if (XCmore < XC)
{
TCmoves = XCmoves[XCmore];
TCminutes = XCminutes[XCmore];
TCseconds = XCseconds[XCmore];
XCmore++;
}
SetTimeControl2 (opponent);
}
compptr = (compptr + 1) % MINGAMEIN;
if (SupervisorMode)
{
computer = computer ^ 1;
opponent = opponent ^ 1;
xwndw = (computer == white) ? WXWNDW : BXWNDW;
flag.force = false;
Sdepth = 0;
}
else if (!(flag.quit || flag.mate || flag.force))
{
//SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
SelectMove (computer, 1);
if (Mate)
{
src_col = tolower(mvstr[0][0]) - 'a';
src_row = mvstr[0][1] - '1';
dest_col = tolower(mvstr[0][2]) - 'a';
dest_row = mvstr[0][3] - '1';
if ((src_col >= 0) && (src_col <= 7) && (src_row >= 0) && (src_row <= 7) &&
(dest_col >= 0) && (dest_col <= 7) && (dest_row >= 0) && (dest_row <= 7))
{ // in bounds
l = ((flag.reverse) ? locn (7 - src_row, 7 - src_col) : locn (src_row, src_col));
piece = board[l]; /* white are lower case pieces */
board[l] = 0;
color[l] = neutral;
l = ((flag.reverse) ? locn (7 - dest_row, 7 - dest_col) : locn (dest_row, dest_col));
if ((piece == pawn)&&((dest_row == 7)||(!dest_row)))
piece = queen;
board[l] = piece;
color[l] = computer;
MoveMem128(board,amigaboard);
MoveMem128(color,amigacolor);
DrawAmigaBoard();
} // in bounds
} // mate
if (computer == black)
if (flag.gamein)
{
TimeCalc ();
}
else if (TimeControl.moves[computer] == 0)
{
if (XC)
if (XCmore < XC)
{
TCmoves = XCmoves[XCmore];
TCminutes = XCminutes[XCmore];
TCseconds = XCseconds[XCmore];
XCmore++;
}
SetTimeControl2 (computer);
}
}
if ((flag.mate)&&(!Mate)&&(!DrawnGame))
ShowMessage("CheckMate");
if (Mate)
{
ShowMessage(MateString);
}
else if (DrawnGame)
{
ShowMessage("Draw..");
}
#ifdef AMIGAWAY
else if ((!flag.mate)&&(PlayMode == 2)&&(!ResignOffered)&&(!flag.quit))
{
if (1)//(global_tmp_score < -950)
{
if (DoResign())
{
//ClearPointer(wG);
flag.mate = true;
flag.back = true;
Mate = 1;
ShowMessage("You Win!");
ShowMessage("UChess Resigns");
}
}
}
#endif // AMIGAWAY
}
#if ttblsz
#ifdef HASHFILE
if (hashfile)
fclose (hashfile);
#endif /* HASHFILE */
#endif /* ttblsz */
ExitChess ();
}