hthomas@irisa.fr (Henry Thomas) (04/12/91)
Submitted-by: Henry Thomas <hthomas@irisa.fr> Posting-number: Volume 18, Issue 13 Archive-name: notation/part02 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 2 (of 3)." # Contents: COPYING drivers.c notation.doc # Wrapped by hthomas@illico on Thu Apr 11 14:44:54 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'COPYING' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'COPYING'\" else echo shar: Extracting \"'COPYING'\" \(12488 characters\) sed "s/^X//" >'COPYING' <<'END_OF_FILE' X X GNU GENERAL PUBLIC LICENSE X Version 1, February 1989 X X Copyright (C) 1989 Free Software Foundation, Inc. X 675 Mass Ave, Cambridge, MA 02139, USA X Everyone is permitted to copy and distribute verbatim copies X of this license document, but changing it is not allowed. X X Preamble X X The license agreements of most software companies try to keep users Xat the mercy of those companies. By contrast, our General Public XLicense is intended to guarantee your freedom to share and change free Xsoftware--to make sure the software is free for all its users. The XGeneral Public License applies to the Free Software Foundation's Xsoftware and to any other program whose authors commit to using it. XYou can use it for your programs, too. X X When we speak of free software, we are referring to freedom, not Xprice. Specifically, the General Public License is designed to make Xsure that you have the freedom to give away or sell copies of free Xsoftware, that you receive source code or can get it if you want it, Xthat you can change the software or use pieces of it in new free Xprograms; and that you know you can do these things. X X To protect your rights, we need to make restrictions that forbid Xanyone to deny you these rights or to ask you to surrender the rights. XThese restrictions translate to certain responsibilities for you if you Xdistribute copies of the software, or if you modify it. X X For example, if you distribute copies of a such a program, whether Xgratis or for a fee, you must give the recipients all the rights that Xyou have. You must make sure that they, too, receive or can get the Xsource code. And you must tell them their rights. X X We protect your rights with two steps: (1) copyright the software, and X(2) offer you this license which gives you legal permission to copy, Xdistribute and/or modify the software. X X Also, for each author's protection and ours, we want to make certain Xthat everyone understands that there is no warranty for this free Xsoftware. If the software is modified by someone else and passed on, we Xwant its recipients to know that what they have is not the original, so Xthat any problems introduced by others will not reflect on the original Xauthors' reputations. X X The precise terms and conditions for copying, distribution and Xmodification follow. X X GNU GENERAL PUBLIC LICENSE X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION X X 0. This License Agreement applies to any program or other work which Xcontains a notice placed by the copyright holder saying it may be Xdistributed under the terms of this General Public License. The X"Program", below, refers to any such program or work, and a "work based Xon the Program" means either the Program or any work containing the XProgram or a portion of it, either verbatim or with modifications. Each Xlicensee is addressed as "you". X X 1. You may copy and distribute verbatim copies of the Program's source Xcode as you receive it, in any medium, provided that you conspicuously and Xappropriately publish on each copy an appropriate copyright notice and Xdisclaimer of warranty; keep intact all the notices that refer to this XGeneral Public License and to the absence of any warranty; and give any Xother recipients of the Program a copy of this General Public License Xalong with the Program. You may charge a fee for the physical act of Xtransferring a copy. X X 2. You may modify your copy or copies of the Program or any portion of Xit, and copy and distribute such modifications under the terms of Paragraph X1 above, provided that you also do the following: X X a) cause the modified files to carry prominent notices stating that X you changed the files and the date of any change; and X X b) cause the whole of any work that you distribute or publish, that X in whole or in part contains the Program or any part thereof, either X with or without modifications, to be licensed at no charge to all X third parties under the terms of this General Public License (except X that you may choose to grant warranty protection to some or all X third parties, at your option). X X c) If the modified program normally reads commands interactively when X run, you must cause it, when started running for such interactive use X in the simplest and most usual way, to print or display an X announcement including an appropriate copyright notice and a notice X that there is no warranty (or else, saying that you provide a X warranty) and that users may redistribute the program under these X conditions, and telling the user how to view a copy of this General X Public License. X X d) You may charge a fee for the physical act of transferring a X copy, and you may at your option offer warranty protection in X exchange for a fee. X XMere aggregation of another independent work with the Program (or its Xderivative) on a volume of a storage or distribution medium does not bring Xthe other work under the scope of these terms. X X 3. You may copy and distribute the Program (or a portion or derivative of Xit, under Paragraph 2) in object code or executable form under the terms of XParagraphs 1 and 2 above provided that you also do one of the following: X X a) accompany it with the complete corresponding machine-readable X source code, which must be distributed under the terms of X Paragraphs 1 and 2 above; or, X X b) accompany it with a written offer, valid for at least three X years, to give any third party free (except for a nominal charge X for the cost of distribution) a complete machine-readable copy of the X corresponding source code, to be distributed under the terms of X Paragraphs 1 and 2 above; or, X X c) accompany it with the information you received as to where the X corresponding source code may be obtained. (This alternative is X allowed only for noncommercial distribution and only if you X received the program in object code or executable form alone.) X XSource code for a work means the preferred form of the work for making Xmodifications to it. For an executable file, complete source code means Xall the source code for all modules it contains; but, as a special Xexception, it need not include source code for modules which are standard Xlibraries that accompany the operating system on which the executable Xfile runs, or for standard header files or definitions files that Xaccompany that operating system. X X 4. You may not copy, modify, sublicense, distribute or transfer the XProgram except as expressly provided under this General Public License. XAny attempt otherwise to copy, modify, sublicense, distribute or transfer Xthe Program is void, and will automatically terminate your rights to use Xthe Program under this License. However, parties who have received Xcopies, or rights to use copies, from you under this General Public XLicense will not have their licenses terminated so long as such parties Xremain in full compliance. X X 5. By copying, distributing or modifying the Program (or any work based Xon the Program) you indicate your acceptance of this license to do so, Xand all its terms and conditions. X X 6. Each time you redistribute the Program (or any work based on the XProgram), the recipient automatically receives a license from the original Xlicensor to copy, distribute or modify the Program subject to these Xterms and conditions. You may not impose any further restrictions on the Xrecipients' exercise of the rights granted herein. X X 7. The Free Software Foundation may publish revised and/or new versions Xof the General Public License from time to time. Such new versions will Xbe similar in spirit to the present version, but may differ in detail to Xaddress new problems or concerns. X XEach version is given a distinguishing version number. If the Program Xspecifies a version number of the license which applies to it and "any Xlater version", you have the option of following the terms and conditions Xeither of that version or of any later version published by the Free XSoftware Foundation. If the Program does not specify a version number of Xthe license, you may choose any version ever published by the Free Software XFoundation. X X 8. If you wish to incorporate parts of the Program into other free Xprograms whose distribution conditions are different, write to the author Xto ask for permission. For software which is copyrighted by the Free XSoftware Foundation, write to the Free Software Foundation; we sometimes Xmake exceptions for this. Our decision will be guided by the two goals Xof preserving the free status of all derivatives of our free software and Xof promoting the sharing and reuse of software generally. X X NO WARRANTY X X 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, XREPAIR OR CORRECTION. X X 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE XPOSSIBILITY OF SUCH DAMAGES. X X END OF TERMS AND CONDITIONS X X Appendix: How to Apply These Terms to Your New Programs X X If you develop a new program, and you want it to be of the greatest Xpossible use to humanity, the best way to achieve this is to make it Xfree software which everyone can redistribute and change under these Xterms. X X To do so, attach the following notices to the program. It is safest to Xattach them to the start of each source file to most effectively convey Xthe exclusion of warranty; and each file should have at least the X"copyright" line and a pointer to where the full notice is found. X X <one line to give the program's name and a brief idea of what it does.> X Copyright (C) 19yy <name of author> X X This program is free software; you can redistribute it and/or modify X it under the terms of the GNU General Public License as published by X the Free Software Foundation; either version 1, or (at your option) X any later version. X X This program is distributed in the hope that it will be useful, X but WITHOUT ANY WARRANTY; without even the implied warranty of X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X GNU General Public License for more details. X X You should have received a copy of the GNU General Public License X along with this program; if not, write to the Free Software X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X XAlso add information on how to contact you by electronic and paper mail. X XIf the program is interactive, make it output a short notice like this Xwhen it starts in an interactive mode: X X Gnomovision version 69, Copyright (C) 19xx name of author X Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. X This is free software, and you are welcome to redistribute it X under certain conditions; type `show c' for details. X XThe hypothetical commands `show w' and `show c' should show the Xappropriate parts of the General Public License. Of course, the Xcommands you use may be called something other than `show w' and `show Xc'; they could even be mouse-clicks or menu items--whatever suits your Xprogram. X XYou should also get your employer (if you work as a programmer) or your Xschool, if any, to sign a "copyright disclaimer" for the program, if Xnecessary. Here a sample; alter the names: X X Yoyodyne, Inc., hereby disclaims all copyright interest in the X program `Gnomovision' (a program to direct compilers to make passes X at assemblers) written by James Hacker. X X <signature of Ty Coon>, 1 April 1989 X Ty Coon, President of Vice X XThat's all there is to it! END_OF_FILE if test 12488 -ne `wc -c <'COPYING'`; then echo shar: \"'COPYING'\" unpacked with wrong size! fi # end of 'COPYING' fi if test -f 'drivers.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'drivers.c'\" else echo shar: Extracting \"'drivers.c'\" \(14158 characters\) sed "s/^X//" >'drivers.c' <<'END_OF_FILE' X#include<stdio.h> X X#include <ctype.h> X#include "chesstype.h" X#include "notation.h" X#include "drivers.h" X X/* postscript characters translation table X one entry per piece X each entry has four fields: X - white piece on white case X - white piece on black case X - black piece on ... X .. X */ X#define PSINDEX(a,b) ((((a)==WHITE)?0:2)+(((b)%2)?0:1)) X Xstatic char * postscript_table[][4] = { X { " ", "x", " ", "x" }, /* void */ X { "k", "\\373", "K", "\\360" }, /* king */ X { "q", "\\317", "Q", "\\316" }, /* queen */ X { "r", "\\250", "R", "\\345" }, /* rook */ X { "b", "\\272", "B", "\\365" }, /* bishop */ X { "n", "\\265", "N", "\\366" }, /* knight */ X { "p", "\\271", "P", "\\270" } /* pawn */ X}; X X/* TeX table for using the chess figure in board design */ Xstatic char * metafont_table[][4] = { X /* W/W W/B B/W B/B */ X { "\\WWW", "\\DDD", "\\WWW", "\\DDD" }, /* void */ X { "\\WKW", "\\WKB", "\\BKW", "\\BKB" }, /* king */ X { "\\WQW", "\\WQB", "\\BQW", "\\BQB" }, /* queen */ X { "\\WRW", "\\WRB", "\\BRW", "\\BRB" }, /* rook */ X { "\\WBW", "\\WBB", "\\BBW", "\\BBB" }, /* bishop */ X { "\\WNW", "\\WNB", "\\BNW", "\\BNB" }, /* knight */ X { "\\WPW", "\\WPB", "\\BPW", "\\BPB" } /* pawn */ X}; X X/* TeX table for using the chess figures in move description */ Xstatic char * latex_table[] = { X "\\FigVoid", "\\FigK", "\\FigQ", "\\FigR", "\\FigB", "\\FigN", "\\FigP" X}; X X/* various tex symbols */ Xstatic char FigDash[] = "\\FigDash"; Xstatic char FigCapt[] = "\\FigCapt"; Xstatic char FigDots[] = "\\FigDots"; Xstatic char FigDot[] = "\\FigDot"; X X#define G_ROQUE "O-O-O" X#define P_ROQUE "O-O" X Xstatic FILE * ftmp ; X X X/* ---------------- output functions ---------------- */ X X/* convert a roque in term of king's move */ Xstatic int roque_to_move(m) X depl * m; X{ X X m->piece = KING; X m->fromcol = 5; X if (m->type == GRANDROQUE) X m->tocol = 3; X else X m->tocol = 7; X X if (m->whiteturn) X m->fromlig = m->tolig = 1; X else X m->fromlig = m->tolig = 8; X X return(TRUE); X} X X/* (kind of) buffering of output */ Xstatic void init_buffer(d,side) X format * d; X int side ; X{ X switch (d->type) { X case D_ASCII: X if (side != BLACK) (void) sprintf(d->white_buffer,"..."); X if (side != WHITE) (void) sprintf(d->black_buffer," "); X break; X case D_TEX: X if (side != BLACK) (void) sprintf(d->white_buffer,"%s",FigDots); X if (side != WHITE) (void) sprintf(d->black_buffer,"~"); X break; X default: X if (side != BLACK) d->white_buffer[0] = '\0' ; X if (side != WHITE) d->black_buffer[0] = '\0' ; X break; X } X} X X/* this procedure is responsible for PRINTING the move */ Xstatic void flush_buffer(d) X format * d; X{ X X /* if we have been inteerupted (by a comment, a board display etc... X if the move is black X we display <movenumber> ... <blackmove> X */ X if ((d->interrupt == TRUE) && (d->iswhiteturn == FALSE)) { X switch (d->type) { X case D_TEX: X (void) fprintf(d->outfile, X "\\noindent\\movenumber{\\bf %s\\FigDot}\\whitemove{%s}\\blackmove{%s}\n", X d->move_buffer,FigDots,d->black_buffer); X break; X case D_GNU: X /* no special case for GNU */ X (void) fprintf(d->outfile,"\t%s\n",d->black_buffer); X break; X default: X (void) fprintf(d->outfile,"%3s.%9s%9s\n", X d->move_buffer,"...",d->black_buffer); X break; X } X d->interrupt = FALSE ; X } else { X /* else (no interrupt) X we display either white or black move X */ X switch (d->type) { X case D_TEX: X if (d->iswhiteturn) X (void) fprintf(d->outfile, X "\\noindent\\movenumber{\\bf %s\\FigDot}\\whitemove{%s}", d->move_buffer,d->white_buffer); X else X (void) fprintf(d->outfile, X "\\blackmove{%s}\n",d->black_buffer); X break; X case D_GNU: X if (d->iswhiteturn) X (void) fprintf(d->outfile,"\t%s",d-> white_buffer); X else X (void) fprintf(d->outfile,"\t%s\n",d->black_buffer); X break; X default: X if (d->iswhiteturn) X (void) fprintf(d->outfile,"%3s.%9s", d->move_buffer,d->white_buffer); X else X (void) fprintf(d->outfile,"%9s\n", d->black_buffer); X break; X } X } /* end printing */ X X /* reset buffer */ X if (! d->iswhiteturn) X init_buffer(d,VOID); X d->interrupt = FALSE; X} X X/* a generic parametrised driver for move output X */ Xstatic void output_move_generic(dr,d) X format * dr; X depl *d; X{ X char ligne[128] ; X char themove[128] ; X char thepiece[16] ; X char debcol[16]; X char frommove[16] ; X char tomove[16] ; X char lie[16] ; X char prom[16]; X X int ambigue = FALSE ; X X ligne[0] = themove[0] = thepiece[0] = debcol[0] = '\0'; X frommove[0] = tomove[0] = lie[0] = prom[0] = '\0' ; X X X (void) sprintf (dr->move_buffer,"%d",d->move); X X if ((d->type == PETITROQUE) && !dr->roque_alg) X (void) sprintf (themove,"%s",P_ROQUE); X if ((d->type == GRANDROQUE) && !dr->roque_alg) X (void) sprintf (themove,"%s",G_ROQUE); X if (dr->roque_alg && X ((d->type == GRANDROQUE) || (d->type == PETITROQUE))) X (void) roque_to_move(d); X X if (dr-> roque_alg || X ((d->type != GRANDROQUE) && (d->type != PETITROQUE))) { X X /* we check here for ambiguous move */ X if ((d->type != GRANDROQUE) && (d->type != PETITROQUE)) { X ambigue = ambiguity (d->piece, d->tolig,d->tocol); X /* if ( (ambigue ) && (d->piece != PAWN )) X * (void) fprintf (stderr,"ambiguity at move %d",tos->move); X */ X } X themove[0] = '\0' ; X if ((dr->output_move_format == SHORTENED) X && (d->type == PRISE) && (d->piece == PAWN)) X (void) sprintf (debcol, "%c",coltoletter(d->fromcol)); X X if (dr->print_piece) X if (d->piece != PAWN || dr->print_pawn) { X if (dr->type == D_TEX ) X (void) sprintf(thepiece,"%s ",latex_table[d->piece]); X else X (void) sprintf(thepiece,"%c",dr->out_table[d->piece]); X } X X if ((dr->output_move_format == ALGEBRAIC)) X (void)sprintf(frommove,"%c%c", X coltoletter(d->fromcol),ligtoletter(d->fromlig)); X if ( ambigue && dr->print_liaison ) { X (void) sprintf(lie,"-"); X (void)sprintf(frommove,"%c%c", X coltoletter(d->fromcol),ligtoletter(d->fromlig)); X debcol[0] = '\0' ; X } X if (d->promotion) { X if (dr->print_piece) { X if (dr->type == D_TEX ) X (void) sprintf(prom,"=%s ",latex_table[d->promotion]); X else X (void) sprintf(prom,"=%c",dr->out_table[d->promotion]); X } X } X X if (dr->print_liaison) { X if ((d->type == PRISE) || (d->type == PROM_ET_PRISE) X || (d->type == EN_PASSANT) ) X (void) sprintf(lie,"%c",'x'); X else X if ((dr->output_move_format == ALGEBRAIC)) X (void) sprintf(lie,"%c",'-'); X } X X (void) sprintf(tomove,"%c%c",coltoletter(d->tocol),ligtoletter(d->tolig)); X X (void) sprintf (themove,"%s%s%s%s%s%s", X thepiece,debcol,frommove,lie, tomove,prom); X } X X if (d->whiteturn) X (void) sprintf (dr->white_buffer, "%s",themove); X else X (void) sprintf (dr->black_buffer, "%s",themove); X X dr->iswhiteturn = d->whiteturn; X X /*fprintf(dr->outfile, "=%d=%d= ",d->move,d->whiteturn);*/ X flush_buffer(dr); X} X X/* ---------------- ascii driver ---------- */ Xstatic void output_init_ascii(dr) Xformat *dr; X{} X Xstatic void output_board_ascii(dr,g) X format * dr; X game * g; X{ X register int i,j; X X dr->interrupt = TRUE; X X (void) fprintf(dr->outfile,"\n\n"); X for (i=8 ; i >=1 ; i--) { X if (dr->coordinates) X (void) fprintf(dr->outfile,"%d ",i); X (void) fputc('|',dr->outfile); X for (j=1 ; j<9 ; j++) { X if (g->board[i][j] != VOID) { X if (g->color[i][j] == WHITE) X (void) fputc(dr->out_table[g->board[i][j]], dr->outfile); X else X (void) fputc(tolower(dr->out_table[g->board[i][j]]),dr->outfile); X } else X (void) fputc ( ((i+j)% 2)?' ':'/', dr->outfile); X (void) fputc('|', dr->outfile); X } X (void) fputc('\n', dr->outfile); X } X if (dr->coordinates) X (void) fprintf(dr->outfile," a b c d e f g h\n"); X (void) fprintf(dr->outfile,"\n"); X} X X/* ---------------- postscript --------- */ X Xstatic void output_board_ps(dr,g) X format *dr; X game * g; X{ X register int i,j; X register int c; X char chaine[MAXTOKLEN]; X X /* header file */ X (void) strcpy(chaine,LIB_DIR); X if ((ftmp = fopen(strcat(chaine,PS_HEADER),"r")) == NULL) X message((stderr,"Can't open ps header file.\n")); X else { X while ((c = getc(ftmp)) != EOF) X (void) fputc(c,dr->outfile); X (void) fclose(ftmp); X } X X (void) fprintf(dr->outfile,"( ________) 72 714 T\n"); X for (i=8 ; i >=1 ; i--) { X (void) fprintf(dr->outfile,"(/"); X for (j=1 ; j<9 ; j++) { X (void) fprintf(dr->outfile,"%s", X postscript_table[g->board[i][j]][PSINDEX(g->color[i][j],(i+j))]); X } X (void) fprintf(dr->outfile,"\\\\) 72 %d T\n",474 + (i-1)*30); X } X (void) fprintf(dr->outfile,"( --------) 72 444 T\n"); X X /* footer file */ X (void) strcpy(chaine,LIB_DIR); X if ((ftmp = fopen(strcat(chaine,PS_FOOTER),"r")) == NULL) X message((stderr,"Can't open ps footer file.\n")); X else { X while ((c = getc(ftmp)) != EOF) X (void) fputc(c,dr->outfile); X (void) fclose(ftmp); X } X} X X/* ---------------- nroff --------------- */ Xstatic void output_init_roff(dr) X format *dr; X{ X} X Xstatic void output_board_roff(dr,g) X format *dr; X game * g; X{ X register int i,j; X X dr->interrupt = TRUE; X X (void) fprintf(dr->outfile,".br\n"); X for (i=8 ; i >=1 ; i--) { X (void) fprintf(dr->outfile,".ce\n "); X for (j=1 ; j<9 ; j++) { X if (g->board[i][j] != VOID) { X if (g->color[i][j] == WHITE) X (void) fputc(dr->out_table[g->board[i][j]], dr->outfile); X else X (void) fputc(tolower(dr->out_table[g->board[i][j]]),dr->outfile); X } else X /*(void) fputc ( ((i+j)% 2)?' ':'/', dr->outfile);*/ X (void) fprintf(dr->outfile,"."); X } X (void) fprintf(dr->outfile,"\n.br\n"); X } X (void) fprintf(dr->outfile,"\n"); X} X X/* ---------------- tex -------------------- */ Xstatic void output_init_tex(dr) X format *dr; X{ X register int c; X char chaine[MAXTOKLEN]; X X /* header file */ X (void) strcpy(chaine,LIB_DIR); X if ((ftmp = fopen(strcat(chaine,TEX_HEADER),"r")) == NULL) X message((stderr,"Can't open tex header file.\n")); X else { X while ((c = getc(ftmp)) != EOF) X (void) fputc(c,dr->outfile); X (void) fclose(ftmp); X } X} X Xstatic void output_board_tex(dr,g) X format *dr; X game * g; X{ X register int i,j; X X dr->interrupt = TRUE; X X (void) fprintf(dr->outfile,"\n\n"); X (void)fprintf(dr->outfile,"$$\\vbox{\\bigskip\\offinterlineskip\\tabskip=0pt\n"); X (void) fprintf(dr->outfile,"\\halign{#\\vvrule &#&#&#&#&#&#&#&#&#\\vvrule \\cr\n"); X (void) fprintf(dr->outfile,"\\noalign{\\hhrule}\n"); X for (i=8 ; i >=1 ; i--) { X (void) fprintf(dr->outfile,"&"); X for (j=1 ; j < 9 ; j++) { X (void) fprintf(dr->outfile,"%s", X metafont_table[g->board[i][j]][PSINDEX(g->color[i][j],(i+j))]); X (void) fprintf(dr->outfile,"&"); X } X (void) fprintf(dr->outfile,"\\cr \n"); X } X (void) fprintf(dr->outfile,"\\noalign{\\hhrule}}}$$"); X (void) fprintf(dr->outfile,""); X (void) fprintf(dr->outfile,"\n\n"); X} X Xstatic void output_end_tex(dr) X format *dr; X{ X (void) fprintf(dr->outfile, "~\n\n\n\\end{document}\n"); X} X X/* ------------------ gnu - xchess ---------- */ X Xstatic void output_init_gnu(dr) X format *dr; X{ X (void) fprintf(dr->outfile, "X Chess -- Mon Dec 10 11:47:18 MET 1990\n"); X (void) fprintf(dr->outfile,"\tGame played on dumbkopft.irisa.fr:0.0\n"); X (void) fprintf(dr->outfile,"\talgebraic\n"); X} X X/* ---------------- driver handler ---------- */ X/* dummy driver */ Xstatic void null_driver() {} X X/* the drivers */ Xvoid output_init(dr) X format *dr ; X{ X dr->out_init(dr); X} X Xvoid output_move(dr,d) X format *dr ; X depl *d; X{ X dr->out_move(dr,d); X} X Xvoid output_board(dr,g) X format *dr ; X game *g ; X{ X dr->out_board(dr,g); X} X Xvoid output_end(dr) X format *dr ; X{ X dr->out_end(dr); X} X X Xformat * new_driver() X{ X format * tmp; X int i; X X tmp = (format *) malloc (sizeof(format)); X ALLOCP(tmp); X /*for (i=0; i < ((sizeof (format))/ sizeof (int)) ; i++) X ((int *) tmp)[i] = 0;*/ X return(tmp); X} X Xvoid init_driver(dr,driver) X format * dr; X int driver; X{ X dr->type = driver ; X X switch (dr->type) { X case D_ASCII: X dr->print_move = TRUE; X dr->print_piece = TRUE; X dr->print_pawn = FALSE; X dr->roque_alg = FALSE; X dr->print_liaison = TRUE; X dr->out_init = output_init_ascii; X dr->out_move = output_move_generic; X dr->out_board = output_board_ascii; X dr->out_end = null_driver; X break; X case D_POST: X dr->out_init = null_driver; X dr->out_move = null_driver; X dr->out_board = output_board_ps; X dr->out_end = null_driver; X break; X case D_TEX: X dr->print_move = TRUE; X dr->print_piece = TRUE; X dr->print_pawn = FALSE; X dr->roque_alg = FALSE; X dr->print_liaison = TRUE; X dr->out_init = output_init_tex; X dr->out_move = output_move_generic; X dr->out_board = output_board_tex; X dr->out_end = output_end_tex; X break; X case D_ROFF: X dr->print_move = TRUE; X dr->print_piece = TRUE; X dr->print_pawn = FALSE; X dr->roque_alg = FALSE; X dr->print_liaison = TRUE; X dr->out_init = output_init_roff; X dr->out_move = output_move_generic; X dr->out_board = output_board_roff; X dr->out_end = null_driver; X break; X case D_XCHESS: X dr->print_move = TRUE; X dr->print_piece = FALSE; X dr->print_pawn = FALSE; X dr->roque_alg = TRUE; X dr->print_liaison = FALSE; X dr->out_init = output_init_gnu; X dr->out_move = output_move_generic; X dr->out_board = null_driver; X dr->out_end = null_driver; X break; X case D_GNU: X dr->print_move = FALSE; X dr->print_piece = FALSE; X dr->print_pawn = FALSE; X dr->roque_alg = TRUE; X dr->print_liaison = FALSE; X dr->out_init = null_driver; X dr->out_move = output_move_generic; X dr->out_board = null_driver; X dr->out_end = null_driver; X break; X default: X error((stderr,"unknown driver")); X break; X } X if (dr->only_board) X dr->out_move = null_driver ; X X dr->variation_level = 0; X dr->iswhiteturn = FALSE ; X dr->interrupt = FALSE; X init_buffer(dr, VOID); X} END_OF_FILE if test 14158 -ne `wc -c <'drivers.c'`; then echo shar: \"'drivers.c'\" unpacked with wrong size! fi # end of 'drivers.c' fi if test -f 'notation.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'notation.doc'\" else echo shar: Extracting \"'notation.doc'\" \(12209 characters\) sed "s/^X//" >'notation.doc' <<'END_OF_FILE' X X X Xnotation(n) MISC. REFERENCE MANUAL PAGES notation(n) X X X XNAME X notation - transform chess notation X X XSYNOPSYS X notation [input file] [-o output file] [options...] X X XDESCRIPTION X This program reads chess games, either full algebraic or X shortened (ie Nf1-g3 or Ng3) and is able to ouptut the board X after any move, in either ascii , postscript, nroff, latex X or xchess save format. This program is also multi-lingual: X it handles english, french, spanish, german, italian and X dutch symbols. X X XOPTIONS X Command line options: X X -a X algebraic move notation output X X -s X shortened move notation output X X -f <language> X specifies the chess symbol input language. The X language can be any of french, english, italian, X spanish, german, dutch. X X -t <language> X specifies the chess symbol output language. Same X options as input language. X X <inputfile> X specifies the input file. If none, keyboard is X assumed. X X -o <outputfile> X specifies the output file. If none, screen is X assumed. X X -c <number>[,<number] X specifies the number of the moves at which to X display the board. If none, board is displayed at X end of file. Several numbers may be specified, as a X comma-separated list. X X -e <number> X display the board at the move number and then stops X X X X XSun Release 4.1 Last change: 10 December 1990 1 X X X X X X Xnotation(n) MISC. REFERENCE MANUAL PAGES notation(n) X X X X -b X display only the board, not the moves X X -d <drivername> X specifies the output driver. It can be any of the X following: ascii, postscript, tex, roff, xchess X (xchess or xboard save format), gnu (gnuan input X format). X X -h X displays help screen X X XINPUT LANGUAGE X The input language has four types of input: moves, X move numbers, comments and keywords. All these are separated X by blanks, TAB or RC. Commas are not accepted. X X X move format: X The moves are accepted in algebraic or shortened X algebraic notation. That means that the following X are equivalent and accepted Nf1-g3 N-f1xg3, Nxg3, X Ng3. The ugly english notation P-K4 is not under- X stood, neither by the program nor me. X X Nota: provided you remove the three first line, X xchess save format is accepted. Also you can have X trailing comments to move, provided there is no X blanks. So Kg4!!, Ra5++ are correct, but not Kg4 !!, X Ra5 ++ because of the separating blank. A future X version might handle these move comments, as well as X + ++, mate, white resigns etc... Castling is recog- X nized with the following 0-0 O-O o-o 0-0-0 O-O-O o- X o-o. "En passant" and promotion are now correctly X handled. For "en passant", you just indicate them X move and it is correctly parsed ex: "d5-d7 e5xd6". X Promotion is indicated with the "=" sign followed by X the new piece name. So you just write "a7-a8=Q" or X "d8=K". X X For example, see the files algebraic.txt and X shortened.txt X X X move numbers: X move numbers are in the form 23. or 36. The full X point is optional. Move numbers are checked against X internal move counter. X X X comments: X X X XSun Release 4.1 Last change: 10 December 1990 2 X X X X X X Xnotation(n) MISC. REFERENCE MANUAL PAGES notation(n) X X X X anything else, except keywords, must be enclosed in X brackets or parenthesis [Here Karpov made a very X bright move ...] (this is also a comment). Comments X are skipped out. A future version might incorporte X them in the output. X X X keywords: X you can insert keywords in the input text to pre- X cisely define what you want: displaying the board, X configuring it... Keywords are detailled in the next X section. X X XKEYWORDS X All keywords are prefixed with @ X X @startplay X begins the play. Obligatory after a @configxxx key- X word. X X @clearboard X clears the board. Used prior to any @configxxx. X X @showboard X displays the board. Can be used anywhere X X @whitesmove X tells the program that is the white's turn of play. X Useful after a @configxxx and @startplay X X @blacksmove X tells the program that it is black's turn X X @configwhite X initializes configuration of white side. Pieces are X then expected, in form of (optional for Pawn) name, X the position. Example @configwhite Ke3 Rg8 e4. X X @configblack X initializes configuration of black side. Pieces are X then expected, in form of (optional for Pawn) name, X the position. Example: @configblack Ka8 Nf6 e6. X X Note that black pieces are given in uppercase! X X @default X resets the board to the default start configuration. X X @special X all following text up to the next cariage return is X not processed, but instead directly print. This X X X XSun Release 4.1 Last change: 10 December 1990 3 X X X X X X Xnotation(n) MISC. REFERENCE MANUAL PAGES notation(n) X X X X allows to insert comments in ascii files, or tex X commands when tex output is selected. X X @null Null keyword. Does nothing. Used for convenience in X programming. X X X See the file keywords.txt for an example of keywords X use. X X XNATIONAL LANGUAGES X Here are the symbols used in the differents languages. () X mean optional in the input. X X X english-name King Queen Rook Bishop Knight Pawn X english K Q R B N (P) X french R D T F C (P) X italian R D T A C (P) X spanish R D T A C (P) X german K D T L S (B) X dutch K D T L P (O) X X X XDRIVERS X ascii this is the default driver, it outputs move and X boards. X X postscript X it generates a file using the font file Cheq X licensed for free by Adobe. It is only able to X display one board per run. Move are not displayed. X You need the font "Cheq", freely distributed by X Adobe. Send a mail to "ps-file-server@adobe.com" X with the body "send Programs chessfont.ps". For use X with "notation", rename the file "Cheq". X X tex this is a latex driver. It uses the TeX/LaTeX chess X macros designed by Piet Tutalaers "rcpt@urc.tue.nl". X The complete distribution is available on X sol.cs.ruu.nl (131.211.80.5) with path X TEX/chess.tar.Z chesscls, provided in the library. X Refer to your local latex guru to install it. X X roff this is a driver for nroff output. It is crude, but X it works. Moves and boards are displayed. X X xchess This driver generates compatible xchess/xboard save X files, thus allowing you to replay a game with X xchess. X X X XSun Release 4.1 Last change: 10 December 1990 4 X X X X X X Xnotation(n) MISC. REFERENCE MANUAL PAGES notation(n) X X X X gnu This driver completely "bare" file, with only the X algebraic move. It is suitable for any low-level X analyser, such as gnuan. X X XEXAMPLES X Try the following commands: X X notation algebraic.txt X this will read the Karpov-Kasparov game 13 (Lyon X 1990) in algebraic form, display move in algebraic X and display board at end of game. X X notation algebraic.txt -a X this will do the same thing, as -a stands for alge- X braic output. X X notation algebraic.txt -s X the game will now be output in shortened algebraic X X notation shortened.txt X there is no problem to read shortened algebraic. X X notation shortened -s -o result X the moves and board will be directed to file result X X notation shortened.txt -s -t french X output will use french notation X X notation a_dutch_file -f dutch -t spanish X game will be translated form dutch to spanish X X notation shortened -c 2 X board after move 2 will be displayed, along with X moves and end-of-game board X X notation shortened -e 2 X board after move 2 will be displayed, along with X moves. The program will then stops X X notation shortened -c 2,5,20 X board after moves 2, 5 and 20 will be displayed, X along with moves and end-of-game board X X notation shortened -c 2,5,20 -b X board after moves 2, 5 and 20 will be displayed, X with end-of-game board, but no moves. X X notation shortened -c 2,5,20 -d tex X the output will be formatted to use with latex. You X can directly latex the output file. X X X X XSun Release 4.1 Last change: 10 December 1990 5 X X X X X X Xnotation(n) MISC. REFERENCE MANUAL PAGES notation(n) X X X X notation shortened -c 2,5,20 -d gnu X you can now replay the game by using xchess -r X out.gnu. X X notation shortened -e 5 -d postscript X Now issue cat lib/Cheq out.ps | lpr to display on a X Laser Printer the board at move 5. You can also X issue sh print-ps out-ps. The postcript driver does X not support the -c option. X X XFILES X algebraic.txt shortened.txt keywords.txt X these are examples of input files X X X ./lib/HELPFILE X this is the on-line helpfile X X X ./lib/(Cheq Header.ps Footer.ps) X these files are needed by the postscript driver X X X ./lib/Header.tex X these file is needed by the (la)tex driver X X X ./lib/chesscls.mf X this file is used the generate the tex font X X XSEE ALSO X xchess(1), chess(6), gnuchess(1), latex(1), nroff(1), lpr(1) X X XDIAGNOSTICS X Errors messages are hoped to be self-explanative. X X XCOMMENTS X The program is quite large, due to the large use of tables X and variables to control its features. The advantage is you X only need the modify these tables to customize it: for X instance adding a new language or tuning the output format X to your own needs. X X XBUGS X Too many. Report them to Henry.Thomas@irisa.fr. X X The postscript driver *might* fais if you try to display the X X X XSun Release 4.1 Last change: 10 December 1990 6 X X X X X X Xnotation(n) MISC. REFERENCE MANUAL PAGES notation(n) X X X X board two times. Anyway, it is not designed to do this. Use X -e option to specify the move at which you want to display X board. X X XAUTHOR X Henry Thomas IRISA-Rennes, FRANCE. E-mail to X Henry.Thomas@irisa.fr or hthomas@irisa.fr. X XTHANKS X Thanks to Jacques Schuurman for the piece description in X Dutch, Dr. Z. Rubinstein, University of Haifa for the X Metafont files, Philippe Louarn for implementing these mac- X ros and explaining me how to use them, Adobe Systems for the X font Cheq, and Jean-Luc Scharbarg for introducing me in the X world of chess. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X XSun Release 4.1 Last change: 10 December 1990 7 X X X END_OF_FILE if test 12209 -ne `wc -c <'notation.doc'`; then echo shar: \"'notation.doc'\" unpacked with wrong size! fi # end of 'notation.doc' fi echo shar: End of archive 2 \(of 3\). cp /dev/null ark2isdone MISSING="" for I in 1 2 3 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 3 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Henry Thomas - IRISA - E-mail: Henry.Thomas@irisa.fr Campus Universitaire de Beaulieu - Phone: (+33)99 36 20 00 +549 35042 RENNES CEDEX FRANCE - Fax: (+33)99 38 38 32 Telex: UNIRISA 950473F Telex Atlas X400: /X121=842950473/@atlas.fr, Fax:/X121=200099383832/@atlas.fr -- ... Words, and the words of men, flicker and flutter and beat Warning, sorrow and gain, salutations and mirth... R. Kipling exit 0 # Just in case... -- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM Sterling Software, IMD UUCP: uunet!sparky!kent Phone: (402) 291-8300 FAX: (402) 291-4362 Please send comp.sources.misc-related mail to kent@uunet.uu.net.