Notes on the Windows port of GNUchess. Daryl Baker 12/30/90 The core algrothms of the program has been preserved intact, however due to the memory management requirements of Windows significant changes to the data structure references were made. The program is ported using Microsoft C 6.0a, Windows 3.0 and the Windows 3.0 Software Developers Kit. To compile enter "nmake -f chess.mak" Source file overview; Windows device independent bitmaps for each piece. Each bitmap consists of an outline (xxxO.bmp), a mask which is used to clear the space to draw the piece (xxxM.bmp), and the bitmap for the piece (xxx.bmp). These are based on the outlines contained in XCHESS. BISHOP.BMP KING.BMP KNIGHT.BMP QUEEN.BMP BISHOPM.BMP KINGM.BMP KNIGHTM.BMP QUEENM.BMP BISHOPO.BMP KINGO.BMP KNIGHTO.BMP QUEENO.BMP PAWN.BMP ROOK.BMP PAWNM.BMP ROOKM.BMP PAWNO.BMP ROOKO.BMP Chess.def is the liker definition file required for linking windows files Resource File: The resouce file contains the definitions for the menus icons, bitmaps, and dialog boxes. CHESS.RC ;The resource file CHESS.ICO ;The program ICON ABOUT.DLG ;Templates for all dialog boxes COLOR.DLG MANUAL.DLG GETNUM.DLG PROMOTE.DLG REVIEW.DLG SAVEOPEN.DLG STATS.DLG TEST.DLG TIMECNT.DLG COLOR.H ;Header files to support dialog functions SAVEOPEN.H STATS.H TIMECNT.H ABOUT.C ;C source to perform dialog functions COLOR.C ;Adjust the colors MANUAL.C ;Prompt the user for a manual entered move NUMDLG.C ;Prompt the user to enter a number PROMOTE.C ;Give the user a choice of what to promote a pawn to REVIEW.C ;Review game moves SAVEOPEN.C ;File open/save prompts STATS.C ;Display search/look ahead lines TEST.C ;Test compute speed TIMECNT.C ;Select duration of game Header files GNUCHESS.H CHESS.H DEFS.H ;Function prototypes The source routines gnuchess.c and uxdsp.c have been broken up into small units (this is mainly to reduce them to smaller sizes to cut compile time and enable me to get a handle on each module's function) BOOK.C ;Opening book routines DSP.C ;Routines from uxdsp.c that do not involve io EVAL.C ;Gnuchess move evaluation routines GLOBALS.C ;Definition for all global varibles INITIALI.C ;Gnuchess initialization routines SEARCH.C ;Gnuchess search engine Windows specifc routines BOARD.C ;Routine to draw board CHESS.C ;Main program CREATE.C ;Creates all sub-windows used in program HITTEST.C ;Handle hit testing the mouse INIT.C ;Windows initializaiton INITMENU.C ;Routine to handle state of memu items MSWDSP.C ;Windows based IO routines for screen PIECE.C ;Routines to draw pieces MAKEVER.C ;Utility routine for updating version.h VERSION.C ;Contains version number Overview of modifications: The routine main has been renamed to init_main in file initiali.c. The first order of business was to move all "large" static data structures to be dynamicly allocated. The following varibles were moved: history, nextdir, nextpos, distdata, taxidata, hashcode, Tree, GameList, ttable In all routines that access these varibles the array references were changed to be consistant with a pointer representation. In violation of good Windows programming these structures are "LOCKED". This is only a penalty in real mode, in standard and 386 enhanced windows can move locked segments without affecting references. Also many of the static read-only data structures were moved to be "based" in the code segment. (as opposed to user definded resources). This saves space in the local heap and since the code segments can be moved this creates a relocatable data structure. A sample: static short _based(_segname("_CODE")) KingOpening[64] = {....}; Openning book. All opening book routines are contained in the file book.c. The opening book would not fit into the local heap. A 32 Kbyte array is allocated from the dynamic heap. This array is used to construct a mini-heap to load the openning book into. If the openning book grows much more this routine will need to be adjusted. Routines were added to "free" the book when it is no longer needed. Also all routines that used the book were fixed to eliminate book=NULL. These routines now call Free_book first. Help File The source files for the help file is stored in several files. The DOC files were created with Word for Windows. The RTF files are created from the DOC files with a Save As. CHESS.DOC ---> CHESS.RTF ;Main help file ARTICLE.DOC ---> ARTICLE.RTF ;An article by Stuart Cracraft on GNU chess ARTICLE2.DOC ---> ARTICLE2.RTF ;Another article COPYRIGHT.DOC ---> COPYRIGHT.RTF ;GNU Chess Copyright notice MOVE-GEN.DOC ---> MOVE-GEN.RTF ;An article about GNU Chess move generator HEURISTI.DOC ---> HEURISTI.RTF ;Article about GNU Chess heuristics MATCH.DOC ---> MATCH.RTF ;Games against MACH.