aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodney W. Grimes <rgrimes@FreeBSD.org>1993-06-12 14:49:13 +0000
committerRodney W. Grimes <rgrimes@FreeBSD.org>1993-06-12 14:49:13 +0000
commit9002c02abc587664acb357c6879d8ca08664dd0b (patch)
tree515fc124b039c993c5762b23524842c4aebcaa06
downloadsrc-9002c02abc5.tar.gz
src-9002c02abc5.zip
Initial import, 0.1 + pk 0.2.4-B1
Notes
Notes: svn path=/cvs2svn/branches/tcpdump/; revision=2
-rw-r--r--gnu/games/chess/DOCUMENTATION/ARTICLE66
-rw-r--r--gnu/games/chess/DOCUMENTATION/ARTICLE.2123
-rw-r--r--gnu/games/chess/DOCUMENTATION/CHANGES362
-rw-r--r--gnu/games/chess/DOCUMENTATION/COPYING123
-rw-r--r--gnu/games/chess/DOCUMENTATION/GENERAL34
-rw-r--r--gnu/games/chess/DOCUMENTATION/HEURISTICS122
-rw-r--r--gnu/games/chess/DOCUMENTATION/MAN-PAGE161
-rw-r--r--gnu/games/chess/Makefile15
-rw-r--r--gnu/games/chess/Xchess/COPYING124
-rw-r--r--gnu/games/chess/Xchess/Makefile136
-rw-r--r--gnu/games/chess/Xchess/ScrollText34
-rw-r--r--gnu/games/chess/Xchess/XCircle.c162
-rw-r--r--gnu/games/chess/Xchess/bishop.bitmap71
-rw-r--r--gnu/games/chess/Xchess/bishop_mask.bitmap71
-rw-r--r--gnu/games/chess/Xchess/bishop_outline.bitmap71
-rw-r--r--gnu/games/chess/Xchess/bishop_small.bitmap15
-rw-r--r--gnu/games/chess/Xchess/bishop_small_outline.bitmap15
-rw-r--r--gnu/games/chess/Xchess/board.c179
-rw-r--r--gnu/games/chess/Xchess/button.c337
-rw-r--r--gnu/games/chess/Xchess/clock.c291
-rw-r--r--gnu/games/chess/Xchess/control.c515
-rw-r--r--gnu/games/chess/Xchess/jail.c327
-rw-r--r--gnu/games/chess/Xchess/king.bitmap71
-rw-r--r--gnu/games/chess/Xchess/king_mask.bitmap71
-rw-r--r--gnu/games/chess/Xchess/king_outline.bitmap71
-rw-r--r--gnu/games/chess/Xchess/king_small.bitmap15
-rw-r--r--gnu/games/chess/Xchess/king_small_outline.bitmap15
-rw-r--r--gnu/games/chess/Xchess/knight.bitmap71
-rw-r--r--gnu/games/chess/Xchess/knight_mask.bitmap71
-rw-r--r--gnu/games/chess/Xchess/knight_outline.bitmap71
-rw-r--r--gnu/games/chess/Xchess/knight_small.bitmap15
-rw-r--r--gnu/games/chess/Xchess/knight_small_outline.bitmap15
-rw-r--r--gnu/games/chess/Xchess/message.c101
-rw-r--r--gnu/games/chess/Xchess/parse.c386
-rw-r--r--gnu/games/chess/Xchess/pawn.bitmap71
-rw-r--r--gnu/games/chess/Xchess/pawn_mask.bitmap71
-rw-r--r--gnu/games/chess/Xchess/pawn_outline.bitmap71
-rw-r--r--gnu/games/chess/Xchess/pawn_small.bitmap15
-rw-r--r--gnu/games/chess/Xchess/pawn_small_outline.bitmap15
-rw-r--r--gnu/games/chess/Xchess/popup.c112
-rw-r--r--gnu/games/chess/Xchess/program.c200
-rw-r--r--gnu/games/chess/Xchess/queen.bitmap71
-rw-r--r--gnu/games/chess/Xchess/queen_mask.bitmap71
-rw-r--r--gnu/games/chess/Xchess/queen_outline.bitmap71
-rw-r--r--gnu/games/chess/Xchess/queen_small.bitmap15
-rw-r--r--gnu/games/chess/Xchess/queen_small_outline.bitmap15
-rw-r--r--gnu/games/chess/Xchess/record.c315
-rw-r--r--gnu/games/chess/Xchess/rook.bitmap71
-rw-r--r--gnu/games/chess/Xchess/rook_mask.bitmap71
-rw-r--r--gnu/games/chess/Xchess/rook_outline.bitmap71
-rw-r--r--gnu/games/chess/Xchess/rook_small.bitmap15
-rw-r--r--gnu/games/chess/Xchess/rook_small_outline.bitmap15
-rw-r--r--gnu/games/chess/Xchess/scrollText.c1858
-rw-r--r--gnu/games/chess/Xchess/scrollText.h32
-rw-r--r--gnu/games/chess/Xchess/scrollText/scrollText.c1858
-rw-r--r--gnu/games/chess/Xchess/scrollText/scrollText.h32
-rw-r--r--gnu/games/chess/Xchess/shade.bitmap71
-rw-r--r--gnu/games/chess/Xchess/std.c425
-rw-r--r--gnu/games/chess/Xchess/std.h105
-rw-r--r--gnu/games/chess/Xchess/valid.c264
-rw-r--r--gnu/games/chess/Xchess/window.c952
-rw-r--r--gnu/games/chess/Xchess/window.c.bm928
-rw-r--r--gnu/games/chess/Xchess/xchess.1217
-rw-r--r--gnu/games/chess/Xchess/xchess.c205
-rw-r--r--gnu/games/chess/Xchess/xchess.c.150197
-rw-r--r--gnu/games/chess/Xchess/xchess.cur9
-rw-r--r--gnu/games/chess/Xchess/xchess.game8
-rw-r--r--gnu/games/chess/Xchess/xchess.h301
-rw-r--r--gnu/games/chess/Xchess/xchess.icon28
-rw-r--r--gnu/games/chess/Xchess/xchess_mask.cur7
-rw-r--r--gnu/games/chess/gnuchess.book3878
-rw-r--r--gnu/games/chess/gnuchess.c2307
-rw-r--r--gnu/games/chess/gnuchess.h97
-rw-r--r--gnu/games/chess/move.c357
-rw-r--r--gnu/games/chess/move.h81
-rw-r--r--gnu/games/chess/nondsp.c791
-rw-r--r--gnu/games/chess/pathnames.h36
-rw-r--r--gnu/games/chess/uxdsp.c933
-rw-r--r--share/man/man4/man4.i386/Makefile7
-rw-r--r--share/man/man4/man4.i386/mem.482
-rw-r--r--share/man/man4/man4.i386/spkr.4117
-rw-r--r--share/man/man4/mem.482
-rw-r--r--share/man/man4/spkr.4117
-rw-r--r--usr.bin/symorder/Makefile5
-rw-r--r--usr.bin/symorder/symorder.181
-rw-r--r--usr.bin/symorder/symorder.c281
-rw-r--r--usr.sbin/dbsym/Makefile4
-rw-r--r--usr.sbin/dbsym/dbsym.c192
-rw-r--r--usr.sbin/tcpdump/Makefile5
-rw-r--r--usr.sbin/tcpdump/Makefile.inc3
-rw-r--r--usr.sbin/tcpdump/tcpdump/Makefile24
-rw-r--r--usr.sbin/tcpdump/tcpdump/VERSION1
-rw-r--r--usr.sbin/tcpdump/tcpdump/addrtoname.c478
-rw-r--r--usr.sbin/tcpdump/tcpdump/addrtoname.h36
-rw-r--r--usr.sbin/tcpdump/tcpdump/appletalk.h156
-rw-r--r--usr.sbin/tcpdump/tcpdump/bootp.h103
-rw-r--r--usr.sbin/tcpdump/tcpdump/bpf_dump.c61
-rw-r--r--usr.sbin/tcpdump/tcpdump/bpf_image.c282
-rw-r--r--usr.sbin/tcpdump/tcpdump/etherent.c144
-rw-r--r--usr.sbin/tcpdump/tcpdump/etherent.h34
-rw-r--r--usr.sbin/tcpdump/tcpdump/etherproto.h70
-rw-r--r--usr.sbin/tcpdump/tcpdump/extract.h49
-rw-r--r--usr.sbin/tcpdump/tcpdump/gencode.c1384
-rw-r--r--usr.sbin/tcpdump/tcpdump/gencode.h156
-rw-r--r--usr.sbin/tcpdump/tcpdump/inet.c172
-rw-r--r--usr.sbin/tcpdump/tcpdump/interface.h111
-rw-r--r--usr.sbin/tcpdump/tcpdump/md.c35
-rw-r--r--usr.sbin/tcpdump/tcpdump/md.h40
-rw-r--r--usr.sbin/tcpdump/tcpdump/mib.h1256
-rw-r--r--usr.sbin/tcpdump/tcpdump/nametoaddr.c258
-rw-r--r--usr.sbin/tcpdump/tcpdump/nametoaddr.h43
-rw-r--r--usr.sbin/tcpdump/tcpdump/ntp.h117
-rw-r--r--usr.sbin/tcpdump/tcpdump/optimize.c1871
-rw-r--r--usr.sbin/tcpdump/tcpdump/os.c26
-rw-r--r--usr.sbin/tcpdump/tcpdump/os.h85
-rw-r--r--usr.sbin/tcpdump/tcpdump/ospf.h223
-rw-r--r--usr.sbin/tcpdump/tcpdump/pcap.c209
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-arp.c100
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-atalk.c478
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-bootp.c263
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-domain.c287
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-egp.c347
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-ether.c123
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-fddi.c236
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-icmp.c207
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-ip.c313
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-nfs.c466
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-ntp.c277
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-null.c117
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-ospf.c586
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-ppp.c102
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-rip.c116
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-sl.c246
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-snmp.c1043
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-sunrpc.c136
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-tcp.c287
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-tftp.c149
-rw-r--r--usr.sbin/tcpdump/tcpdump/print-udp.c141
-rw-r--r--usr.sbin/tcpdump/tcpdump/savefile.c303
-rw-r--r--usr.sbin/tcpdump/tcpdump/savefile.h75
-rw-r--r--usr.sbin/tcpdump/tcpdump/tcpdump.11067
-rw-r--r--usr.sbin/tcpdump/tcpdump/tcpdump.c347
-rw-r--r--usr.sbin/tcpdump/tcpdump/tcpgram.y232
-rw-r--r--usr.sbin/tcpdump/tcpdump/tcplex.l146
-rw-r--r--usr.sbin/tcpdump/tcpdump/util.c278
-rw-r--r--usr.sbin/tcpdump/tcpslice/Makefile18
-rw-r--r--usr.sbin/tcpdump/tcpslice/gwtm2secs.c75
-rw-r--r--usr.sbin/tcpdump/tcpslice/search.c563
-rw-r--r--usr.sbin/tcpdump/tcpslice/tcpslice.1260
-rw-r--r--usr.sbin/tcpdump/tcpslice/tcpslice.c645
150 files changed, 40089 insertions, 0 deletions
diff --git a/gnu/games/chess/DOCUMENTATION/ARTICLE b/gnu/games/chess/DOCUMENTATION/ARTICLE
new file mode 100644
index 000000000000..b2ab331d21d5
--- /dev/null
+++ b/gnu/games/chess/DOCUMENTATION/ARTICLE
@@ -0,0 +1,66 @@
+[This article was reproduced from a GNU Bulletin.]
+
+ GNU Chess
+ by Stuart Cracraft
+ copyright 1987 Stuart Cracraft
+
+
+ GNU Chess is a communal chess program. Contributors donate their
+time and effort in order to make it a stronger, better, sleeker program.
+Contributions take many forms: interfaces to high-resolution displays,
+opening book treatises, speedups of the underlying algorithms, additions
+of extra heuristics. These contributions are then distributed to the
+large user-base so that all may enjoy the fruits of our labor. The
+original and continuing purpose of this project is to permanently end
+the rampant hoarding of computer chess software that has been the
+case for the past 20 years.
+
+ Many people have contributed to GNU Chess. Their contributions have
+improved the program from being a patzer (weak program) to being a
+grandpatzer (decently strong program). In its growth since initial
+release, GNU Chess has gone from approximately class D to expert
+strength. It beats the Fidelity Excel commercial unit rather handily.
+
+ GNU Chess's structure is a hybrid of the Shannon Type-A and
+Type-B methods. It conducts a full-width search to a fixed-depth
+and then continues with a quiescence search for many more ply.
+This quiescence search helps the program find positions which
+can be safely evaluated and which are not too turbulent. If
+a terminal position is too turbulent, the evaluation will be
+highly inaccurate. Additional searching by investigating series
+of captures, checks, and other potentially imbalance-producing
+moves is quite helpful.
+
+ GNU Chess will sacrifice pieces in order to reach known winning
+endings. Also, it uses a trade-down bonus to encourage the stronger
+side to trade off certain types of pieces thus reaching a more
+simplified and therefore ostensibly "clearer" position.
+
+ GNU Chess has certain types of knowledge regarding easier endgames.
+This allows it to play these endings somewhat better than might be
+expected.
+
+ GNU Chess has time heuristics that it uses to improve its handling
+of time-controls and hasten its making of "obvious" moves.
+
+ GNU Chess is interfaced to the SUN Windows and X Windows
+display protocols and can display its pieces in elaborate format,
+similar to chess diagrams.
+
+ GNU Chess has an opening book which consists of many variations
+from MCO (Modern Chess Openings).
+
+ For comparison purposes, GNU Chess running on a VAX 8650 is
+stronger than the famous Chess 4.5 running on a CDC 6400.
+
+ We wish to acknowledge the contributions of the following
+individuals: (in alphabetical order) Jim Aspnes, Wayne Christopher,
+Steve Dougherty, David Goldberg, Richard Greenblatt, David Kittinger,
+Richard Stallman, John Stanback, and Ken Thompson.
+
+ Contact information: The author may be reached by a variety of
+methods. Via U.S. mail: Stuart Cracraft, 5 Via Amistosa, Suite G,
+Rancho Santa Margarita, Ca. 92688 USA.
+ By Internet: 'cracraft at wheaties.ai.mit.edu'
+The author may also be contacted via the Free Software Foundation, Inc.
+675 Massachusetts Ave.,Cambridge MA 02139.
diff --git a/gnu/games/chess/DOCUMENTATION/ARTICLE.2 b/gnu/games/chess/DOCUMENTATION/ARTICLE.2
new file mode 100644
index 000000000000..031ae18f9e4b
--- /dev/null
+++ b/gnu/games/chess/DOCUMENTATION/ARTICLE.2
@@ -0,0 +1,123 @@
+
+
+ GNU Chess: Experiences Learned
+ with Communal Sharing
+ by Stuart Cracraft
+ (and contributors to the GNU Project)
+
+
+Limited sharing has characterized the computer chess community
+for the past two decades. Occasional research articles give hints
+and suggestions for useful features, but rarely reveal the real
+details of the critically important advances. We will here
+describe an effort underway (titled "GNU Chess") to create a more
+open and friendly environment of sharing.
+
+GNU Chess is part of Project GNU, a large-scale effort in which
+the philosophical goals are far-reaching. We will not go into any
+great depth about these goals as they relate to the larger pro-
+ject, because these are described elsewhere [1]. However, we will
+mention the basic issues and the changes we hope to encourage.
+
+The start of the GNU Chess project was a natural result of the
+experiences gleaned in writing a chess program. While the author
+was at a progressive academic location [2], he was able to con-
+ceive the idea of a communal chess program only after much heart-
+ache. During the period of writing the initial version (which
+has since undergone many improvements and whole revisions), it
+became clear that the best features and most useful hints, the
+very best of the heuristics, were hidden and difficult to find in
+the literature.
+
+Sprinkled across many books, research papers, magazine articles,
+accumulated in the community, during the past 25 years, there was
+literally a void of true, empirical programs. Locating usable
+programs was difficult. Many programs were the result of academic
+work in "ivory towers", and hence were inaccessible to the common
+man. Other programs were sequestered in research think-tanks. Na-
+turally, developers of commercial programs carefully guarded
+their source in order to protect their investment. On the other
+hand, a few chess program source listings had actually been pub-
+lished, but these were not really very strong, often written in a
+non-general language, and frequently more pedantic than practi-
+cal.
+
+The idea of a reasonably strong communal program solidified.
+When we refer to a communal program, we do not regard this as
+public-domain software. Rather, we refer to a program which is
+under the shared authority of a number of individuals, the prin-
+cipal contributors. These individuals have experienced and real-
+ized the positive results of a sharing community and the rapid
+improvements that come through contributing in such a community.
+Further, these individuals devote time and energy to coordinating
+the contributions of other individuals. While they exercise a
+certain editorial right, this is usually not exercised arbitrari-
+ly; instead, a discussion is often undertaken.
+
+Eventually, a working C program that played chess was available.
+The coordinating institution for Project GNU [3], accepted our
+suggestion of inclusion of a chess program in the GNU distribu-
+tion. Initial distribution of GNU Chess commenced in October of
+1986. Interest in the project increased rapidly.
+
+Contributions came in from many places and people. Interfaces to
+X-windows and SUN-windows were donated, thus allowing very fancy
+chess fonts on bit-mapped screens. Also, contributions involving
+large portions of opening books such as MCO and collections of
+master games were added to the distribution. Additionally,
+tree-search modifications and heuristics were provided, and occa-
+sionally even entire rewrites.
+
+The program advanced in strength by several USCF class intervals
+during a period of less than one year. During this time, many
+unusual features and enhancements were added to the program, usu-
+ally under the coordination of two or more people, with one work-
+ing in a distant-advisory capacity to the other. Frequently, gra-
+duate students would give up significant time from their thesis
+work to devote energy to contributing. Their corporate counter-
+parts would often give up project time to make their donation.
+
+Contributors would often enter the project in a very forceful way
+and then having made their contribution, learn the viability of
+communal sharing once others had stepped in and contributed to
+them, thus providing considerable reinforcement. Frequently, con-
+tributors would then go into "hibernation" for a long period of
+time, but most of them remained open to contributing and were
+helpful when asked to reprogram their particular contribution in
+a more recent version.
+
+GNU Chess has made great strides in relatively little time. It
+has run on many different hardware architectures and has been
+compiled by a number of C compilers [4]. A sampling of the com-
+puters on which the program has run is: National 32032, Vax
+11/750, 8550, 8600, 8650, Motorola 68020, CCI 5/32, CCI 6/32
+(tahoe), Cray XMP.
+
+It is our belief that GNU Chess will stimulate graduate research
+in computer chess theory and practice. When students are able to
+easily obtain a state-of-the-art program in order to test out
+their ideas, they will no longer need to reinvent the wheel. The
+students will be able to investigate their research areas much
+more thoroughly, because they will spend more time on the specif-
+ic research areas they are concerned about. Basically, GNU Chess
+"frees up" time in order to get on to more fundamental issues.
+
+We also feel that as other researchers gain trust in the GNU
+Chess project, they will be more likely to release their results
+directly and rapidly, through journal articles, or directly to
+the GNU project, and in fact become contributors and join the
+present list [5]. At the very least, a communal, ever-growing
+program will encourage the few "closeted" researchers to be some-
+what more open in their approach to disseminating advances.
+
+In whatever form it takes, the progress toward elaboration of
+machine chess is ongoing, and we hope that GNU chess will be
+helpful to the community. Copies of GNU Chess source and "book",
+as well as additional experimental code are available from the
+Free Software Foundation [3] or the author [6].
+
+
+[1] The GNU Manifesto, Richard Stallman, Free Software Foundation, Inc.
+
+[2] University of Southern California, Information Sciences Institute.
+
diff --git a/gnu/games/chess/DOCUMENTATION/CHANGES b/gnu/games/chess/DOCUMENTATION/CHANGES
new file mode 100644
index 000000000000..9866075ab8a8
--- /dev/null
+++ b/gnu/games/chess/DOCUMENTATION/CHANGES
@@ -0,0 +1,362 @@
+ GNU CHESS HISTORY
+ (#include "../version.h")
+
+August 1, 1989 -- Jay Scott
+He proofread the opening book and made
+corrections.
+
+June 21, 1989 -- Hes @log-se.sv
+He contributed new move generation routines (move.c move.h) to speedup
+move generation and the overall program, by about 15-30%
+
+June 9, 1989 -- Tim Radzy (unet!nplab4!radz@ames.arc.nasa.gov)
+He fixed a bug in xchess/board.c. In a post-game new-game situation,
+castling wouldn't be permitted under circumstances. Tim made
+it possible to castle again.
+
+May 12, 1989 -- Joe Garbarini (garbarini%kegger@circus.llnl.gov)
+Recommended changes to documentation vis a vis chesstool usage.
+
+May 5, 1989 -- Jouko Holopainen (jhol@tolsun.oulu.fi)
+Wrote code to support underpromotion.
+Changed interface to accept ECO/Informator style moves.
+
+April 30, 1989 -- Various GNU contributors
+setlinebuf() modification for xchess/chesstool.
+check for zero division in time printout.
+
+January 17, 1989 -- Anders Thulin
+Provided extensive addition to the opening book for his
+favorite opening the Vienna Game. This was drawn from ECO.
+
+November 23, 1988 -- Stuart Cracraft
+Installed new version of Xchess that is better debugged, works on
+the next version of X. Thanks to Wayne Christopher and Arturo Perez.
+
+August 28, 1988 -- Stuart Cracraft
+Removed a sacrifice line from the Giuoco Piano entry in the opening
+book; the program didn't seem to like the positions it got from this line.
+
+December 30, 1987 -- John Stanback
+Wrote a short blurb on the heuristics contained in GNU Chess. It resides
+in the subdirectory DOCUMENTATION as the file HEURISTICS.
+
+December 17, 1987 -- John Stanback
+Modified criteria for positional evaluation in quiescence search
+to include positions in which the estimated score lies within
+the alpha-beta window; fixed a bug in the king proximity to pawns heuristic;
+fixed a bug involving passed pawn heuristics;
+
+December 16, 1987 -- Stuart Cracraft
+Added automatic 'list' upon exit (both in display, non-display, and
+chesstool mode); command-line setting of tournament time controls
+bug fixed.
+
+December 14, 1987 -- John Stanback
+GNU defeated the commercial product 'Fidelity Excellence' 5.5-4.5 in
+a 10-game match. It was running at about 500 nodes per second (typical
+of its speed on a VAX 8650) and this would indicate its strength
+would be about USCF 1875-1900.
+
+December 4, 1987 -- John Stanback
+Man page added. Command line arguments now specify regular clock
+settings if so desired (useful for SUN players). Thinking
+on opponent's time is now disabled by default. Estimated
+rating is 1850 at 500 nodes per second.
+
+October 20, 1987 -- Stuart Cracraft
+Fixed GNU/SUN interaction. Chesstool and its features now
+seem to fully work.
+
+October 5, 1987 -- Ken Thompson
+GNU beat Belle (actually drew due to a bug, but
+Ken kept GNU playing through to the win) while
+running on a Cray XMP-48. In this 3-1 time handicap game
+Belle outsearched Cray GNU by 10-1 (even with the handicap).
+
+September 26, 1987 -- John Stanback at HP
+Hash table functioning. Thinking on opponent's
+time functioning.
+
+August 20, 1987 -- Mike Meyer at Berkeley
+Mike ran GNU Chess on a Cray 1 supercomputer.
+The system was very heavily loaded, so the
+program was not as speedy as with the Cray below.
+
+August 16, 1987 -- David Goldberg at SUN
+He added "chesstool" support so that this
+version of GNU Chess can run under the
+display manager "chesstool".
+
+August 15, 1987 -- John Stanback at HP
+Hash tables, more heuristics, a modified
+search which is more efficient. He also
+discovered a bug in the piece-exchanger. This
+would cause the program to exchange pieces suboptimally.
+With this fix, the program should play much
+more strongly.
+
+August 13, 1987 -- Ken Thompson at Bell Labs
+Ken ran GNU Chess on a Cray XMP supercomputer
+ (among other processors). The program got
+ about 3000-4000 chess positions per second
+ which is comprable to today's fastest bit-slice
+ commercial machines. Also, he had GNU Chess
+ play two games against Belle.
+
+July 19, 1987 -- Jay Scott & John Stanback
+ Many positional heuristics have been added.
+
+July 18, 1987 -- Stuart Cracraft
+ Improvements have been made to the opening
+ book. It is mostly an MCO book, containing
+ major variations from many of the major openings
+ and particularly in-depth on Sicilian.
+
+May 11, 1987 -- John Stanback at HP
+ He donated his chess program, a fairly mature
+ and strong program.
+
+May 1, 1987 -- Stuart Cracraft
+ He added several bug fixes various people
+ had reported. He also changed makemove() so that
+ the calling syntax is makemove(movelist,index,board)
+ rather than makemove(move,board). Having the latter
+ tickled a bug in at least one manufacturer's C-compiler,
+ so rather than write fancy code, we simplified it.
+
+April 25, 1987-- Jim Aspnes at MIT
+He added all sorts of useful capabilities,
+including positional evaluation in the tree
+search using a table-driven algorithm,
+modifying transposition table code in order
+to work properly, though it doesn't improve
+speed too much, checkmates/stalemates detected
+in the search, en passant captures allowed,
+detect repeated positions, iterative deepening,
+quicker quiescence search, tournament time controls,
+sqattacked sped up by a factor of 4, compile-time
+debugging options.
+
+January 2, 1987 -- Stuart Cracraft
+ He added a few more Tal games to the collection.
+
+January 2, 1987 -- Jim Aspnes at MIT
+ He contributed MCO variations for the Catalan,
+ Queen's Indian, and Reti openings.
+
+December 29, 1986 -- Jim Aspnes at MIT
+ He contributed all MCO variations of the Najdorf
+ to the opening book. He also contributed a LISP
+ macro (written in GNU Emacs Lisp) to convert
+ xchess game formats to GNU Chess opening book
+ format.
+
+December 14, 1986 -- Ken Thompson at Bell Labs
+ He contributed almost 200 games by Tal to
+ our collection of Tal-games, bringing the
+ total number of Tal positions in the book
+ to 10,692. Total book positions now 13,207.
+ These reside in bookin, bookin.bdg, bookin.tal.
+ Note that presently, only bookin and bookin.tal
+ can be used. The new Tal positions came in a
+ slightly different format, which we have chosen
+ to adopt as our standard format. All book
+ games in bookin and bookin.bdg will gradually
+ change into the new standard format.
+
+December 11, 1986 -- Stuart Cracraft
+ Added "averages" for node-count per move,
+ cpu per move, rate per move to list_history
+ and write_history.
+ New version of Xchess installed.
+ Started typing in Tal games into "bookin.tal".
+ Added "total book positions" printout to "book"
+ and "enter" statistics printout.
+
+December 10, 1986 -- Stuart Cracraft
+ Implemented aspiration search in normal
+ alpha-beta search. Speedups of 3% to 40%
+ have been noticed in most positions.
+ Occasionally a slower search will result,
+ but it is thought these are worth the
+ usual speedups.
+
+December 9, 1986 -- Stuart Cracraft
+ Fixed minor bug in write_history()
+ Added another Tal game, 2nd game of 1st world
+ championship match with Botvinnik, a Benoni.
+
+December 9, 1986 -- Stuart Cracraft
+ Enhanced parallelism. All parallel processors
+ now communicate via a shared data file and
+ are kept running (in idle loops watching the
+ shared data file). This saves us a few seconds
+ on each move since the 'rsh' need not be invoked
+ more than once (at the beginning). Since the
+ shared data file is now implemented, we will
+ next work towards a "parallel anarchy" in which
+ any processor can use any other processor in
+ order to reduce its search. The current scheme
+ with the program being only as fast as its slowest
+ processor, is quite inefficient.
+
+December 1, 1986 -- Jim Aspnes at MIT
+ Added a couple of Master games from
+ Modern Chess Openings 12 (a Fischer game,
+ and a Matanovic game).
+
+November 30, 1986 -- Stuart Cracraft
+ Added parallelism. Can now handle multiple
+ processors (sharing same disk). Later we will
+ add the capability to use processors not sharing
+ the same disk. Modified README and MAN-PAGE.
+
+November 26, 1986 -- Stuart Cracraft
+ Fixed a few bugs in book-mailing mechanism.
+ Fixed a bug regarding situations where only
+ one move is available.
+ Fixed a bug in read_history() that caused
+ Black queenside castles to be mishandled.
+
+November 25, 1986 -- Stuart Cracraft
+ Added two pawn heuristics. Reward pawns moving into
+ a phalanx of pawns. A phalanx is two or more
+ horizontally-connected pawns. Likewise, penalize
+ pawns leaving a phalanx of pawns. The penalty for
+ leaving is a little more than the reward for
+ entering.
+
+November 24, 1986 -- Stuart Cracraft
+ A user reported an unbelievable bug. Investigation
+ of this bug led to the discovery that GNU Chess was
+ not picking the move judged best by the tree search
+ in all cases. This resulted in the bug showing
+ itself which further showed that the program was
+ selecting an inferior move. This may result in an
+ improvement to the program's play.
+
+November 24, 1986 -- Stuart Cracraft
+ Added two heuristics. Penalize king moves if
+ the king hasn't castled yet. Also, penalize pawn
+ moves which produce doubled pawns. Should
+ probably have something for isolated pawns
+ too.
+
+November 23, 1986 -- Wayne Christopher at Berkeley
+ New version of X chess display front-end.
+ Fixed bugs include multiple pieces, runs
+ on SUNS & Bobcats, loads saved games.
+
+November 23, 1986 -- Stuart Cracraft
+ Cleaned up some minor bugs regarding history.
+ Added "Illegal command" error message at Wayne's
+ request.
+
+November 22, 1986 -- David Goldberg at SUN Microsystems
+ He complained that GNU Chess was memory-hungry.
+ A few minor modifications to hash.c reduced
+ uninitialized data space 87% and text space
+ 12%. This should make it easier for GNU Chess
+ to run on small computers.
+
+November 22, 1986 -- Stuart Cracraft
+ "read" command was working, but needed
+ additional tweaking so that history
+ array would be printed by list_history().
+
+November 19, 1986 -- Stuart Cracraft
+ Added "read" command which reads a history
+ file (game listing) and restores the board
+ to as if the person was still playing that.
+ particular game. Generally cleaned up
+ history mechanism, made it more orthogonal.
+ Revised README. Added doc to MAN-PAGE.
+
+November 16, 1986 -- Stuart Cracraft
+ More opening book bugs found and fixed.
+ Added capability to accept abbreviated-algebraic notation
+ for entering "book" games from files.
+ Added approximately 2500 new positions to
+ opening book from games involving the
+ opening called Blackmar-Diemer Gambit,
+ a hoary line developed by Diemer in
+ Germany years ago.
+
+November 15, 1986 -- Wayne Christopher at Berkeley
+ He modified the move generator, resulting in
+ a 28% speedup.
+
+November 14, 1986 -- Stuart Cracraft
+ He documented a lot of the GNU Chess modules
+ with brief comments for each function. More
+ extensive internal documentation may go in
+ later.
+
+November 14, 1986 -- Wayne Christopher at Berkeley
+ He created the Xchess interface for
+ GNU Chess to have windowing with X windows.
+
+November 14, 1986 -- Stuart Cracraft
+ He added a "randomization" feature to
+ the opening book. This will cause the
+ program to select randomly from alternate
+ variations whenever -DBEST is removed
+ from Makefile's CFLAGS. If this is not
+ removed, the opening play selects the
+ first move found in the book as it appears
+ "in order" in the human-readable book.
+
+November 14, 1986 -- David Goldberg at SUN Microsystems
+ He responded to a query about dbm(3) which
+ eventually resulted in the fixing of a subtle
+ bug in the book code which was causing the
+ program to sometimes hash to the incorrect
+ address and thereby produce a book move which
+ didn't even exist in the book. Thanks David!
+
+November 14, 1986 -- Stuart Cracraft
+ He added the "oboard" routine in util.c. This
+ is the reverse of the already extant "iboard"
+ (same module). These two routines translate
+ between GNU Chess internal format and
+ Forsythe notation.
+
+November 10, 1986 -- Stuart Cracraft
+ He added the "enter" command. This causes
+ the current game to be entered in the book.
+ Then, GNU Chess tries to mail this new entry
+ to the book maintainers (for inclusion in
+ the master copy of the book).
+
+November 9, 1986 -- Stuart Cracraft
+He added code for an opening book. MAN-PAGE
+and README were modified accordingly.
+
+November 8, 1986 -- Stuart Cracraft
+Checks and mates are now noticed at ply-1.
+This is a more complete fix to the Oct 31 fix.
+
+October 31, 1986 -- Stuart Cracraft
+First attempt at fix to bug which causes
+program to check human's king when program
+itself is in check.
+
+October 31, 1986 -- Mly at MIT
+Reported a bug which caused program to crash
+when an illegal human move was played. Fixed.
+Also, program was unable to play as White. Fixed.
+
+October 22, 1986 -- Stuart Cracraft
+Pps now rewards moves which liberate bishops.
+
+October 19, 1986 -- Stuart Cracraft
+Added bitmapper routines to distribution.
+Added version notice.
+
+October 19, 1986 -- David Goldberg at SUN Microsystems
+Interfaced GNU Chess with SUN's chesstool.
+
+October 18, 1986 -- Initial release date.
+
+
diff --git a/gnu/games/chess/DOCUMENTATION/COPYING b/gnu/games/chess/DOCUMENTATION/COPYING
new file mode 100644
index 000000000000..17847b71307f
--- /dev/null
+++ b/gnu/games/chess/DOCUMENTATION/COPYING
@@ -0,0 +1,123 @@
+ GNU CHESS GENERAL PUBLIC LICENSE
+
+ Copyright (C) 1986,1987 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license, but changing it is not allowed.
+
+ The license agreements of most software companies keep you at the
+mercy of those companies. By contrast, our general public license is
+intended to give everyone the right to share GNU Chess. To make
+sure that you get the rights we want you to have, we need to make
+restrictions that forbid anyone to deny you these rights or to ask you
+to surrender the rights. Hence this license agreement.
+
+ Specifically, we want to make sure that you have the right to give
+away copies of GNU Chess, that you receive source code or else can get it
+if you want it, that you can change GNU Chess or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To make sure that everyone has such rights, we have to forbid you to
+deprive anyone else of these rights. For example, if you distribute
+copies of GNU Chess, you must give the recipients all the rights that you
+have. You must make sure that they, too, receive or can get the
+source code. And you must tell them their rights.
+
+ Also, for our own protection, we must make certain that everyone
+finds out that there is no warranty for GNU Chess. If GNU Chess is
+modified by someone else and passed on, we want its recipients to know
+that what they have is not what we distributed, so that any problems
+introduced by others will not reflect on our reputation.
+
+ Therefore the Free Software Foundation, Inc. makes the following
+terms which say what you must do to be allowed to distribute or change
+GNU Chess.
+
+ COPYING POLICIES
+
+ 1. You may copy and distribute verbatim copies of GNU Chess source
+code as you receive it, in any medium, provided that you conspicuously
+and appropriately publish on each file a valid copyright notice
+"Copyright (C) 1986,1987 Free Software Foundation, Inc.", containing the
+year of last change for the file in question; keep intact the notices
+on all files that refer to this License Agreement and to the absence
+of any warranty; and give any other recipients of the GNU Chess
+program a copy of this License Agreement along with the program.
+
+ 2. You may modify your copy or copies of GNU Chess source code or
+any portion of it, and copy and distribute such modifications under
+the terms of Paragraph 1 above, provided that you also do the following:
+
+ a) cause the modified files to carry prominent notices stating
+ who last changed such files and the date of any change; and
+
+ b) cause the whole of any work that you distribute or publish,
+ that in whole or in part contains or is a derivative of GNU Chess
+ or any part thereof, to be freely distributed
+ and licensed to all third parties on terms identical to those
+ contained in this License Agreement (except that you may choose
+ to grant more extensive warranty protection to third parties,
+ at your option).
+
+ c) if the modified program serves as a text editor, cause it
+ when started running in the simplest and usual way, to print
+ an announcement including a valid copyright notice ("Copyright
+ (C)", the year of authorship, and all copyright owners' names),
+ saying that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of
+ this License Agreement.
+
+ 3. You may copy and distribute GNU Chess or any portion of it in
+compiled, executable or object code form under the terms of Paragraphs
+1 and 2 above provided that you do the following:
+
+ a) cause each such copy of GNU Chess to be accompanied by the
+ corresponding machine-readable source code; or
+
+ b) cause each such copy of GNU Chess to be accompanied by a
+ written offer, with no time limit, to give any third party
+ free (except for a nominal shipping charge) machine readable
+ copy of the corresponding source code; or
+
+ c) in the case of a recipient of GNU Chess in compiled, executable
+ or object code form (without the corresponding source code) you
+ shall cause copies you distribute to be accompanied by a copy
+ of the written offer of source code which you received along
+ with the copy of GNU Chess.
+
+ 4. You may not copy, sublicense, distribute or transfer GNU Chess
+except as expressly provided under this License Agreement. Any attempt
+otherwise to copy, sublicense, distribute or transfer GNU Chess is void and
+your rights to use GNU Chess under this License agreement shall be
+automatically terminated. However, parties who have received computer
+software programs from you with this License Agreement will not have
+their licenses terminated so long as such parties remain in full compliance.
+
+Your comments and suggestions about our licensing policies and our
+software are welcome! Please contact the Free Software Foundation, Inc.,
+1000 Mass Ave, Cambridge, MA 02138, or call (617) 876-3296.
+
+ NO WARRANTY
+
+ BECAUSE GNU CHESS IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
+NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
+WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
+AND/OR OTHER PARTIES PROVIDE GNU CHESS "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+PROGRAM IS WITH YOU. SHOULD THE GNU CHESS PROGRAM PROVE DEFECTIVE,
+YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL FREE SOFTWARE
+FOUNDATION, INC., AND/OR ANY OTHER PARTY WHO MAY MODIFY AND
+REDISTRIBUTE GNU CHESS AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
+DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
+INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
+BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
+FAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY
+FREE SOFTWARE FOUNDATION, INC.) THE PROGRAM, EVEN IF YOU HAVE BEEN
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY
+OTHER PARTY.
+======================================================================
diff --git a/gnu/games/chess/DOCUMENTATION/GENERAL b/gnu/games/chess/DOCUMENTATION/GENERAL
new file mode 100644
index 000000000000..aafb7ed335e3
--- /dev/null
+++ b/gnu/games/chess/DOCUMENTATION/GENERAL
@@ -0,0 +1,34 @@
+ GNU Chess
+
+Copyright (C) 1987 Stuart Cracraft
+ (Copying permission notice at the end.)
+
+GNU Chess is your program (as long as you follow the copyright and
+licensing rules listed in the file COPYING). Your contributioinspire current and future software
+developers.
+
+This document
+-------------
+This document is not meant to be a an introduction to computer chess.
+The following books are excellent introductions and treatises.
+They are listed in order of difficulty:
+
+ Computer Chess (2nd edition), by David Welsh and Boris Bazcynski
+ The Joy of Computer Chess, by David Levy
+ Chess Skill in Man and Machine (2nd edition), by Peter Frey
+
+
+Current Distribution
+--------------------
+The most recent distribution of GNU Chess contains the following
+main-level files and directories:
+
+ Filename Purpose
+ ------------------------------------------------------
+ README Pointer to main README below.
+ gnuchess.c Most recent version of GNU Chess
+ nondsp.c Non-display interface, and chesstool/xchess interface
+ uxdsp.c Unix (curses) display interface
+ ansidsp.c ANSI display interface
+ gnuchess.book Most recent version of opening book
+
diff --git a/gnu/games/chess/DOCUMENTATION/HEURISTICS b/gnu/games/chess/DOCUMENTATION/HEURISTICS
new file mode 100644
index 000000000000..254b34472abe
--- /dev/null
+++ b/gnu/games/chess/DOCUMENTATION/HEURISTICS
@@ -0,0 +1,122 @@
+This file contains a description of GNU's heuristics.
+ Copyright (C) 1986, 1987 Free Software Foundation, Inc.
+
+This file is part of CHESS.
+
+CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+CHESS, but only under the conditions described in the
+CHESS General Public License. A copy of this license is
+supposed to have been given to you along with CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+ -- requested by main author
+Heuristic descriptions for CHESS.
+
+Revision: 12-16-87
+
+Copyright (c) 1987 by John Stanback
+
+ Here is a brief description of the heuristics used in the positional
+ evaluator of the GNU Chess program. Many heuristics are functions of the
+ stage of the game which is based on the total non-pawn material remaining
+ for both sides.
+
+
+PAWNS
+ The material value of a pawn is 100 points. Isolated pawns get a
+ penalty depending on which file they occupy:
+ (12,14,16,20,20,16,14,12) for files (a..h).
+ Doubled pawns (which are not also isolated) get a penalty of 12
+ points. Backward pawns (defined simply as not being defended by a
+ pawn with the square in front also not defended by a a pawn) are
+ penalized 6 points. A 4 point penalty is also invoked for each attack
+ by the opponent to a backward pawn and for a backward pawn on a
+ half-open file. Pawn Advancement in the centre is given a bonus of
+ about 4 points per rank in the opening increasing to about 8 points
+ per rank in the ending. Advancement on the edges is given a lower
+ bonus. Pawns on the e and d files and on the 2nd rank are given a 10
+ point penalty. An additional penalty of 15 points is invoked if these
+ pawns are also blocked. Pawns within 2 squares of the king are given
+ a 10 point bonus. Passed pawns are given a bonus for increasing rank
+ which is a function of stage of the game and of whether the opponent
+ blocks or attacks one or more squares in front of the pawn or if the
+ opponents king is in the square of the pawn. This bonus ranges from
+ about 15 points for a pawn on the second rank up to about 300 points
+ for a passed pawn on the 7th rank which can't be stopped from
+ queening.
+
+
+KNIGHTS
+ The material value of a knight is 330 points. The main heuristic for
+ knights is a bonus for proximity to the centre. This varies from 0
+ points in the corners to 30 points in the centre. Knights are also
+ given a bonus for being within 2 squares of each enemy piece. This
+ bonus is a function of the stage of the game, equalling 4 points in
+ the end game. A penalty of 1 point per square is given for distance
+ from either king. A bonus of up to 8 points (depends on stage) is
+ given for knights which can't be driven away by enemy pawns.
+
+
+BISHOPS
+ The material value of a bishop is 330 points. Bishops are given a
+ bonus as material falls off the board equalling 10 points in the end
+ game. Bishops get a bonus for mobility and Xray mobility thru pieces
+ but not pawns. This bonus ranges from -4 points for a totally blocked
+ bishop up to 18 points for a bishop attacking 12 or more squares.
+ Xray attacks on an enemy R,Q,K or any undefended piece are given an 8
+ point bonus. Bishops are given a bonus of 14 points if they lie on
+ the edge of the board up to 22 points if the lie in the centre. A
+ bishop is given a bonus of up to 5 points for each attack to a square
+ adjacent to the enemy king.
+
+
+ROOKS
+ The material value of a rook is 520 points. Rook mobility is handled
+ similiarly to bishops with a bonus of 0 points if blocked up to 20
+ points if attacking 12 squares or more. A bonus of 8 points for Xray
+ attacks is handled as it is for bishops. Rooks are given a bonus of
+ 10 points for occupying a file with no friendly pawns and a bonus of
+ 4 points if no enemy pawns lie on that file. After the opening Rooks
+ are penalized slightly depending on "taxicab" distance to the enemy
+ king.
+
+
+QUEENS
+ The material value of a queen is 980 points. The only heuristic for a
+ queen is that after the opening it is penalized slightly for
+ "taxicab" distance to the enemy king.
+
+
+KINGS
+ Kings are given a penalty for proximity to the centre in the opening
+ and a bonus for proximity to the centre in the endgame. The penalty
+ is about 24 points for being in the centre in the opening with a
+ bonus of about 36 points for being in the centre in the endgame.
+ Kings are penalized for lying on an open or half-open file or if the
+ adjacent file closest to the corner is open or half-open. This
+ penalty is up to 23 points in the opening and goes to zero in the end
+ game. The King is penalized up to 8 points if there are no pawns
+ immediately adjacent. A penalty is invoked depending on the number of
+ "safe" checks available by the opponent. This penalty ranges from 6
+ points for one such check to 50 points for 4 or more. Depending on
+ game stage, Kings are given up to 10 points for castling and a
+ penalty of up to 40 points for moving before castling.
+
+
+SPECIAL
+ If more than one piece is "hung" (attacked and not defended or
+ attacked by an enemy piece of lower value) an extra penalty of 10
+ points is invoked for that side and the search may be extended one
+ ply. Pinned or trapped pieces are treated similarly. A special mating
+ routine is used if one side has only a king and the other has mating
+ material.
+
diff --git a/gnu/games/chess/DOCUMENTATION/MAN-PAGE b/gnu/games/chess/DOCUMENTATION/MAN-PAGE
new file mode 100644
index 000000000000..bbf0aa4abf98
--- /dev/null
+++ b/gnu/games/chess/DOCUMENTATION/MAN-PAGE
@@ -0,0 +1,161 @@
+.TH Chess GNU
+.SH NAME
+Chess \- GNU Chess
+.SH SYNOPSIS
+.B Chess
+[
+.B arg1 arg2
+]
+.SH DESCRIPTION
+.I Chess
+plays a game of chess against the user or it plays against itself.
+.PP
+.I Chess
+has a simple alpha-numeric board display or it can be compiled for
+use with the CHESSTOOL program on a SUN workstation.
+The program gets its opening moves from the file gnuchess.book which
+should be located in the same directory as gnuchess.
+To invoke the prgram, type 'gnuchess' or type 'chesstool gnuchess'
+on a SUN workstation where 'CHESSTOOL' is installed.
+The 'gnuchess' command can be followed by up to 2 command line arguments.
+If one argument is given it determines the programs search time in
+seconds. If two arguments are given, they will be used to set tournament
+time controls with the first argument being the number of moves and the second
+being the total clock time in minutes. Thus, entering 'chess 60 5' will set
+the clocks for 5 minutes (300 seconds) for the first 60 moves.
+If no argument is given the program will prompt the user for level of
+play.
+For use with CHESSTOOL, see the documentation on that program.
+.PP
+Once
+.I Chess
+is invoked, the program will display the board and prompt the user
+for a move. To enter a move, use the notation 'e2e4' where the first
+letter-number pair indicates the origination square
+and the second letter-number pair indicates the destination square.
+An alternative is to use the notation 'nf3' where
+the first letter indicates the piece type (p,n,b,r,q,k).
+To castle, type the origin and destination squares
+of the king just as you would do for a regular move, or type
+"o-o" for kingside castling and "o-o-o" for queenside.
+.SH COMMANDS
+.PP
+In addition to legal moves, the following commands are available as responses.
+.PP
+.I beep
+-- causes the program to beep after each move.
+.PP
+.I bd
+-- updates the current board position on the display.
+.PP
+.I book
+-- turns off use of the opening library.
+.PP
+.I both
+-- causes the computer to play both sides of a chess game.
+.PP
+.I black
+-- causes the computer to take the black pieces with the move
+and begin searching.
+.PP
+.I level
+-- allows the user to set time controls such as
+60 moves in 5 minutes etc. In tournament mode, the program will
+vary the time it takes for each
+move depending on the situation. If easy mode is disabled (using
+the 'easy' command), the program
+will often respond with its move immediately, saving time on
+its clock for use later on.
+.PP
+.I depth
+-- allows the user to change the
+search depth of the program. The maximum depth is 29 ply.
+Normally the depth is set to 29 and the computer terminates
+its search based on elapsed time rather than depth.
+Using the depth command allows setting depth to say
+4 ply and setting response time to a large number such as
+9999 seconds. The program will then search until all moves
+have been examined to a depth of 4 ply (with extensions up
+to 11 additional ply for sequences of checks and captures).
+.PP
+.I easy
+-- toggles easy mode (thinking on opponents time)
+on and off. The default is easy mode ON. If easy mode is disabled,
+the user must enter a 'break' or '^C' to get the programs
+attention before entering each move.
+.PP
+.I edit
+-- allows the user to set up a board position.
+In this mode, the '#' command will clear the board, the 'c'
+command will toggle piece color, and the '.' command will exit
+setup mode. Pieces are entered by typing a letter (p,n,b,r,q,k) for
+the piece followed by the coordinate. For example "pb3" would
+place a pawn on square b3.
+.PP
+.I force
+-- allows the user to enter moves for both
+sides. To get the program to play after a sequence of moves
+has been entered use the 'white' or 'black' commands.
+.PP
+.I get
+-- retrieves a game from disk. The program will
+prompt the user for a file name.
+.PP
+.I help
+-- displays a short description of the commands.
+.PP
+.I hint
+-- causes the program to supply the user with
+its predicted move.
+.PP
+.I list
+-- writes the game moves and some statistics
+on search depth, nodes, and time to the file 'chess.lst'.
+.PP
+.I new
+-- starts a new game.
+.PP
+.I post
+-- causes the program to display the principle
+variation and the score during the search. A score of
+100 is equivalent to a 1 pawn advantage for the computer.
+.PP
+.I random
+-- causes the program to randomize its move
+selection slightly.
+.PP
+.I reverse
+-- causes the board display to be reversed. That
+is, the white pieces will now appear at the top of the board.
+.PP
+.I quit
+-- exits the game.
+.PP
+.I save
+-- saves a game to disk. The program will prompt
+the user for a file name.
+.PP
+.I switch
+-- causes the program to switch places with
+the opponent and begin searching.
+.PP
+.I undo
+-- undoes the last move whether it was the computer's
+or the human's. You may also type "remove". This is equivalent
+to two "undo's" (e.g. retract one move for each side).
+.PP
+.I white
+-- causes the computer to take the white pieces
+with the move and begin searching.
+.SH BUGS
+.PP
+Pawn promotion to pieces other than a queen is not allowed.
+En-Passant does not work properly with CHESSTOOOL.
+The transposition table may not work properly in some
+positions so the default is to turn this off.
+.fi
+.SH SEE ALSO
+.nf
+chesstool(6)
+.fi
+
diff --git a/gnu/games/chess/Makefile b/gnu/games/chess/Makefile
new file mode 100644
index 000000000000..d5fa6f48f53c
--- /dev/null
+++ b/gnu/games/chess/Makefile
@@ -0,0 +1,15 @@
+# @(#)Makefile 5.4 (Berkeley) 5/11/90
+
+PROG= chess
+SRCS= gnuchess.c uxdsp.c move.c
+CFLAGS+=-DNEWMOVE=12
+MAN6= chess.0
+DPADD= ${LIBCURSES} ${LIBTERM}
+LDADD= -lcurses -ltermlib
+HIDEGAME=hidegame
+
+beforeinstall:
+ install -c -o ${BINOWN} -g ${BINGRP} -m 444 ${.CURDIR}/gnuchess.book \
+ ${DESTDIR}/usr/share/games
+
+.include <bsd.prog.mk>
diff --git a/gnu/games/chess/Xchess/COPYING b/gnu/games/chess/Xchess/COPYING
new file mode 100644
index 000000000000..5905c3292de1
--- /dev/null
+++ b/gnu/games/chess/Xchess/COPYING
@@ -0,0 +1,124 @@
+
+ GNU X-CHESS GENERAL PUBLIC LICENSE
+
+ Copyright (C) 1986 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license, but changing it is not allowed.
+
+ The license agreements of most software companies keep you at the
+mercy of those companies. By contrast, our general public license is
+intended to give everyone the right to share GNU X-Chess. To make
+sure that you get the rights we want you to have, we need to make
+restrictions that forbid anyone to deny you these rights or to ask you
+to surrender the rights. Hence this license agreement.
+
+ Specifically, we want to make sure that you have the right to give
+away copies of GNU X-Chess, that you receive source code or else can get it
+if you want it, that you can change GNU X-Chess or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To make sure that everyone has such rights, we have to forbid you to
+deprive anyone else of these rights. For example, if you distribute
+copies of GNU X-Chess, you must give the recipients all the rights that you
+have. You must make sure that they, too, receive or can get the
+source code. And you must tell them their rights.
+
+ Also, for our own protection, we must make certain that everyone
+finds out that there is no warranty for GNU X-Chess. If GNU X-Chess is
+modified by someone else and passed on, we want its recipients to know
+that what they have is not what we distributed, so that any problems
+introduced by others will not reflect on our reputation.
+
+ Therefore the Free Software Foundation, Inc. makes the following
+terms which say what you must do to be allowed to distribute or change
+GNU X-Chess.
+
+ COPYING POLICIES
+
+ 1. You may copy and distribute verbatim copies of GNU X-Chess source
+code as you receive it, in any medium, provided that you conspicuously
+and appropriately publish on each file a valid copyright notice
+"Copyright (C) 1986 Free Software Foundation, Inc.", containing the
+year of last change for the file in question; keep intact the notices
+on all files that refer to this License Agreement and to the absence
+of any warranty; and give any other recipients of the GNU X-Chess
+program a copy of this License Agreement along with the program.
+
+ 2. You may modify your copy or copies of GNU X-Chess source code or
+any portion of it, and copy and distribute such modifications under
+the terms of Paragraph 1 above, provided that you also do the following:
+
+ a) cause the modified files to carry prominent notices stating
+ who last changed such files and the date of any change; and
+
+ b) cause the whole of any work that you distribute or publish,
+ that in whole or in part contains or is a derivative of GNU X-Chess
+ or any part thereof, to be freely distributed
+ and licensed to all third parties on terms identical to those
+ contained in this License Agreement (except that you may choose
+ to grant more extensive warranty protection to third parties,
+ at your option).
+
+ c) if the modified program serves as a text editor, cause it
+ when started running in the simplest and usual way, to print
+ an announcement including a valid copyright notice ("Copyright
+ (C)", the year of authorship, and all copyright owners' names),
+ saying that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of
+ this License Agreement.
+
+ 3. You may copy and distribute GNU X-Chess or any portion of it in
+compiled, executable or object code form under the terms of Paragraphs
+1 and 2 above provided that you do the following:
+
+ a) cause each such copy of GNU X-Chess to be accompanied by the
+ corresponding machine-readable source code; or
+
+ b) cause each such copy of GNU X-Chess to be accompanied by a
+ written offer, with no time limit, to give any third party
+ free (except for a nominal shipping charge) machine readable
+ copy of the corresponding source code; or
+
+ c) in the case of a recipient of GNU X-Chess in compiled, executable
+ or object code form (without the corresponding source code) you
+ shall cause copies you distribute to be accompanied by a copy
+ of the written offer of source code which you received along
+ with the copy of GNU X-Chess.
+
+ 4. You may not copy, sublicense, distribute or transfer GNU X-Chess
+except as expressly provided under this License Agreement. Any attempt
+otherwise to copy, sublicense, distribute or transfer GNU X-Chess is void and
+your rights to use GNU X-Chess under this License agreement shall be
+automatically terminated. However, parties who have received computer
+software programs from you with this License Agreement will not have
+their licenses terminated so long as such parties remain in full compliance.
+
+Your comments and suggestions about our licensing policies and our
+software are welcome! Please contact the Free Software Foundation, Inc.,
+1000 Mass Ave, Cambridge, MA 02138, or call (617) 876-3296.
+
+ NO WARRANTY
+
+ BECAUSE GNU X-CHESS IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
+NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT
+WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
+AND/OR OTHER PARTIES PROVIDE GNU X-CHESS "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+PROGRAM IS WITH YOU. SHOULD THE GNU X-CHESS PROGRAM PROVE DEFECTIVE,
+YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL FREE SOFTWARE
+FOUNDATION, INC., AND/OR ANY OTHER PARTY WHO MAY MODIFY AND
+REDISTRIBUTE GNU X-CHESS AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
+DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
+INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
+BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
+FAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY
+FREE SOFTWARE FOUNDATION, INC.) THE PROGRAM, EVEN IF YOU HAVE BEEN
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY
+OTHER PARTY.
+======================================================================
diff --git a/gnu/games/chess/Xchess/Makefile b/gnu/games/chess/Xchess/Makefile
new file mode 100644
index 000000000000..c6afd8ffb3f2
--- /dev/null
+++ b/gnu/games/chess/Xchess/Makefile
@@ -0,0 +1,136 @@
+# RCS Info: $Revision: 1.5 $ on $Date: 86/11/26 12:09:19 $
+# $Source: /users/faustus/xchess/RCS/Makefile,v $
+# Copyright (c) 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
+#
+# Makefile for xchess.
+
+#CC = cc -O -m68010 -L/pub.MC68010/lib -L/usr.MC68010/lib
+CC = cc -O
+
+CFILES =\
+ board.c\
+ button.c\
+ clock.c\
+ control.c\
+ jail.c\
+ message.c\
+ parse.c\
+ popup.c\
+ program.c\
+ record.c\
+ std.c\
+ valid.c\
+ window.c\
+ XCircle.c
+
+COBJS =\
+ board.o\
+ button.o\
+ clock.o\
+ control.o\
+ jail.o\
+ message.o\
+ parse.o\
+ popup.o\
+ program.o\
+ record.o\
+ std.o\
+ valid.o\
+ window.o\
+ XCircle.o
+
+HFILES =\
+ std.h\
+ xchess.h
+
+SOURCE = $(CFILES)
+
+ALLFILES = $(SOURCE) $(HFILES)
+
+INCLUDE = -I.
+
+DEFINES = -DDEF_PROGRAM=\"gnuchess\"
+
+CFLAGS = $(DEFINES) $(INCLUDE)
+LINTFLAGS = -u -z -lc -DLINT $(DEFINES) $(INCLUDE)
+LINTLIB = ../lib/llib-lX.ln
+#LDFLAGS = -L/usr2/X/lib -z -lX -lm
+LDFLAGS = -loldX -lX11 -z -lX -lm
+GPLDFLAGS = -z -loldX -lX11 -lXMenu_p -lX -lm_p -g -pg
+
+.c.o: $*.c
+ $(CC) $(CFLAGS) -c $*.c
+.s.o: $*.s
+ $(CC) $(CFLAGS) -c $*.s
+
+all: xchess scrollText.o
+ @echo "All done."
+
+everything: all tags depend lint wc
+ @echo "All done."
+
+xchess: xchess.o $(COBJS) scrollText.o
+ $(CC) -o xchess xchess.o $(COBJS) scrollText.o \
+ $(LDFLAGS)
+
+scrollText.o: scrollText.h scrollText.c
+
+gpxchess: xchess.o $(COBJS)
+ $(CC) -o gpxchess xchess.o $(COBJS) scrollText/libScroll.a \
+ $(GPLDFLAGS)
+
+lint: $(SOURCE)
+ lint $(LINTFLAGS) $(SOURCE) $(LINTLIB) | \
+ grep -v "multiply declared"
+
+qgrind: $(ALLFILES)
+ qgrind -lc $(ALLFILES)
+
+vgrind: $(ALLFILES)
+ vgrind -lc $(ALLFILES)
+
+opt: all
+
+reopt: all
+
+install: all
+
+source: $(SOURCE)
+
+tags: $(ALLFILES)
+ ctags -w -t *.c *.h > /dev/null 2>&1
+
+wc: $(ALLFILES)
+ @wc $(ALLFILES)
+
+print: $(ALLFILES)
+ @pr $(ALLFILES)
+
+clean:
+ rm -f *.o *.a *.out xchess tags foo tmp
+
+tar:
+ tar -cf xchess.tar Makefile *.h *.c *.bitmap *.icon *.cur *.1\
+ scrollText/Makefile scrollText/*.h scrollText/*.c scrollText/*.1\
+ scrollText/*.3
+
+$(ALLFILES):
+ co $@
+
+depend: $(SOURCE)
+ cc -M $(CFLAGS) $(CFILES) > makedep
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+#-----------------------------------------------------------------
+# DO NOT DELETE THIS LINE -- make depend uses it
+# DEPENDENCIES MUST END AT END OF FILE
+
+xchess.o $(COBJS): $(HFILES)
+
diff --git a/gnu/games/chess/Xchess/ScrollText b/gnu/games/chess/Xchess/ScrollText
new file mode 100644
index 000000000000..782a54f48548
--- /dev/null
+++ b/gnu/games/chess/Xchess/ScrollText
@@ -0,0 +1,34 @@
+Subject: File: scrollText.h
+
+/*
+ * Scrollable Text Window Header File
+ *
+ * David Harrison
+ * University of California, Berkeley
+ * 1986
+ *
+ * This file contains definitions for a scrollable text window
+ * with scroll bar support.
+ */
+
+int TxtGrab();
+ /* Take hold of a previously created window */
+
+#define TXT_NO_COLOR -1
+
+int TxtAddFont();
+ /* Loads a new font for use later */
+int TxtWinP();
+ /* Returns non-zero value if the window is text window */
+int TxtClear();
+ /* Clears text window and resets text buffer */
+
+int TxtWriteStr();
+ /* Writes a string to window with immediate update */
+int TxtJamStr();
+ /* Write a string without causing update to screen */
+
+int TxtRepaint();
+ /* Repaints entire scrollable text window */
+int TxtFilter();
+ /* Handles events related to text window */
diff --git a/gnu/games/chess/Xchess/XCircle.c b/gnu/games/chess/Xchess/XCircle.c
new file mode 100644
index 000000000000..d2144bcab849
--- /dev/null
+++ b/gnu/games/chess/Xchess/XCircle.c
@@ -0,0 +1,162 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.2 $ on $Date: 86/11/23 17:17:04 $
+ * $Source: /users/faustus/xchess/RCS/XCircle.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ */
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/X10.h>
+#include <math.h>
+
+#define PI 3.1415926535897932384
+
+#define MAXVERTS 1000
+
+void
+XCircle(win, x, y, rad, start, end, width, height, pixel, func, planes)
+ Window win;
+ int x, y, rad;
+ double start, end;
+ int pixel;
+ int width, height;
+ int func, planes;
+{
+ Vertex verts[MAXVERTS];
+ double xp, yp, ang;
+ int lx, ly, xpt, ypt, i;
+ double gradincr = 2 / (double) rad;
+ int bk = 0;
+
+ while (end >= PI * 2)
+ end -= PI * 2;
+ while (start >= PI * 2)
+ start -= PI * 2;
+ while (end < 0)
+ end += PI * 2;
+ while (start < 0)
+ start += PI * 2;
+ if (end == start) {
+ if (end < gradincr)
+ end = end + PI * 2 - gradincr / 2;
+ else
+ end -= gradincr / 2;
+ }
+ for (ang = start, i = 0; i < MAXVERTS; ) {
+
+ xp = x + rad * cos(ang);
+ yp = y + rad * sin(ang);
+
+ xpt = xp;
+ ypt = yp;
+
+ if (!i || (lx != xpt) || (ly != ypt)) {
+ verts[i].x = xpt;
+ verts[i].y = ypt;
+ verts[i].flags = 0;
+ i++;
+ }
+ lx = xpt;
+ ly = ypt;
+ if (bk)
+ break;
+ if (((ang < end) && (ang + gradincr > end)) || ((end < start)
+ && (ang + gradincr > 2 * PI)
+ && (ang + gradincr - 2 * PI > end))) {
+ ang = end;
+ bk = 1;
+ } else if (ang == end) {
+ break;
+ } else {
+ ang += gradincr;
+ }
+ if (ang >= PI * 2)
+ ang -= PI * 2;
+ }
+
+ /* Now draw the thing.. */
+ XDraw(win, verts, i, width, height, pixel, func, planes);
+
+ return;
+}
+
+#ifdef notdef VertexCurved is screwed up
+
+void
+XCircle(win, x, y, rad, start, end, width, height, pixel, func, planes)
+ Window win;
+ int x, y, rad;
+ double start, end;
+ int pixel;
+ int width, height;
+ int func, planes;
+{
+ Vertex verts[7];
+ int i, j, sv, ev;
+ int dp = 0;
+
+ for (i = j = 0 ; i < 4; i++) {
+ verts[j].x = x + rad * cos((double) (PI * i / 2));
+ verts[j].y = y + rad * sin((double) (PI * i / 2));
+ verts[j].flags = VertexCurved;
+ if ((start >= PI * i / 2) && (start < PI * (i + 1) / 2) &&
+ (start != end)) {
+ j++;
+ verts[j].x = x + rad * cos(start);
+ verts[j].y = y + rad * sin(start);
+ verts[j].flags = VertexCurved;
+ sv = j;
+ } else if ((end >= PI * i / 2) && (end < PI * (i + 1) / 2)
+ && (start != end)) {
+ j++;
+ verts[j].x = x + rad * cos(end);
+ verts[j].y = y + rad * sin(end);
+ verts[j].flags = VertexCurved;
+ ev = j;
+ }
+ j++;
+ }
+ verts[0].flags |= VertexStartClosed;
+ verts[j].x = verts[0].x;
+ verts[j].y = verts[0].y;
+ verts[j].flags = (verts[0].flags & ~VertexStartClosed) |
+ VertexEndClosed;
+ for (i = 0; i < 15; i++) {
+ if (dp)
+ verts[i % 7].flags |= VertexDontDraw;
+ if (i % 7 == ev)
+ dp = 1;
+ else if (i % 7 == sv)
+ dp = 0;
+ }
+ XDraw(win, verts, j + 1, width, height, pixel, func, planes);
+
+ return;
+}
+
+#endif notdef
+
diff --git a/gnu/games/chess/Xchess/bishop.bitmap b/gnu/games/chess/Xchess/bishop.bitmap
new file mode 100644
index 000000000000..dc068ddf1cfa
--- /dev/null
+++ b/gnu/games/chess/Xchess/bishop.bitmap
@@ -0,0 +1,71 @@
+
+#define bishop_width 80
+#define bishop_height 80
+static char bishop_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8f,
+ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8f, 0x0f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8f, 0x0f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x0f, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x9f,
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x10, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xf8, 0xff, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfc, 0xff, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff,
+ 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x23, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf8, 0x67, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xf8, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0xff, 0xf8, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0x1f, 0xc0, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0xc0,
+ 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0xc0, 0x5f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xf8, 0x7f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0xff, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0xff, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
+ 0xff, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xf8,
+ 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xf8, 0x7f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xf8, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0,
+ 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
+ 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff,
+ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfe, 0xfd, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0xf8,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x70, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x70, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xfa, 0xf8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0xfd, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f,
+ 0xfc, 0xfd, 0xc1, 0xff, 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xfd,
+ 0xff, 0xff, 0x07, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff,
+ 0x3f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0xc0, 0xff, 0xff, 0x3f, 0xf0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x80,
+ 0x0f, 0xf0, 0x0f, 0xc0, 0x7f, 0x00, 0x1f, 0x00, 0x00, 0xc0, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/bishop_mask.bitmap b/gnu/games/chess/Xchess/bishop_mask.bitmap
new file mode 100644
index 000000000000..ca17bb3dae0d
--- /dev/null
+++ b/gnu/games/chess/Xchess/bishop_mask.bitmap
@@ -0,0 +1,71 @@
+
+#define bishop_mask_width 80
+#define bishop_mask_height 80
+static char bishop_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0x8f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0xdf, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xdf,
+ 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xdf, 0x1f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xdf, 0x1f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0xdf, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0x8f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
+ 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x3f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x3f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
+ 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
+ 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff,
+ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x7f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
+ 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
+ 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff,
+ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
+ 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfc, 0x3f, 0xfc, 0xff, 0xe3, 0xff, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x01, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0x01,
+ 0x00, 0xf8, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0x01, 0x00, 0xe0,
+ 0xff, 0xff, 0x7f, 0xf8, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0x1f, 0xf8,
+ 0x1f, 0xe0, 0xff, 0x80, 0xff, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/bishop_outline.bitmap b/gnu/games/chess/Xchess/bishop_outline.bitmap
new file mode 100644
index 000000000000..9772328c2984
--- /dev/null
+++ b/gnu/games/chess/Xchess/bishop_outline.bitmap
@@ -0,0 +1,71 @@
+
+#define bishop_outline_width 80
+#define bishop_outline_height 80
+static char bishop_outline_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8d,
+ 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x88, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x8d, 0x0d, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x0f, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x98,
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x70, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x40, 0x10, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x18, 0xc0, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x08, 0x80, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0c, 0x80, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80,
+ 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x22, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x66, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x05, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x01, 0x05, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0xe0, 0x3d, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x20,
+ 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xe0, 0x3d, 0x50, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x05, 0x70, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x05, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x20, 0x00, 0x05, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x05, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05,
+ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x05, 0x40, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
+ 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0xc0, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
+ 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x30, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x07,
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x8d, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x8d, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x06, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x02, 0x02, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x18, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x18, 0xc7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f,
+ 0x0c, 0x85, 0xc1, 0xff, 0x01, 0x00, 0x00, 0x00, 0x0e, 0xf0, 0x87, 0x0d,
+ 0x7f, 0x00, 0x07, 0x00, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x08, 0x00, 0x00,
+ 0x3c, 0x00, 0x00, 0x70, 0x00, 0x00, 0xe0, 0x18, 0x00, 0x00, 0xe0, 0x00,
+ 0x00, 0xc0, 0xf8, 0x1f, 0x38, 0x70, 0xc0, 0xff, 0x31, 0x00, 0x00, 0x80,
+ 0x0f, 0xf0, 0x0f, 0xc0, 0x7f, 0x00, 0x1f, 0x00, 0x00, 0xc0, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/bishop_small.bitmap b/gnu/games/chess/Xchess/bishop_small.bitmap
new file mode 100644
index 000000000000..5525ecd03c2d
--- /dev/null
+++ b/gnu/games/chess/Xchess/bishop_small.bitmap
@@ -0,0 +1,15 @@
+
+#define bishop_small_width 32
+#define bishop_small_height 32
+static char bishop_small_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x00, 0x70, 0x1c, 0x00,
+ 0x00, 0x70, 0x1c, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x60, 0x16, 0x00,
+ 0x00, 0x60, 0x22, 0x00, 0x00, 0xf0, 0x23, 0x00, 0x00, 0xf0, 0x21, 0x00,
+ 0x00, 0xf8, 0x21, 0x00, 0x00, 0xf8, 0x23, 0x00, 0x00, 0xf8, 0x23, 0x00,
+ 0x00, 0xf8, 0x27, 0x00, 0x00, 0x38, 0x27, 0x00, 0x00, 0x3c, 0x2f, 0x00,
+ 0x00, 0x0c, 0x2c, 0x00, 0x00, 0x0e, 0x3c, 0x00, 0x00, 0x3e, 0x3f, 0x00,
+ 0x00, 0x3e, 0x3f, 0x00, 0x00, 0x3e, 0x3f, 0x00, 0x00, 0x3e, 0x3f, 0x00,
+ 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00,
+ 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00,
+ 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0xe0, 0xff, 0xff, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/bishop_small_outline.bitmap b/gnu/games/chess/Xchess/bishop_small_outline.bitmap
new file mode 100644
index 000000000000..8d29a812e29e
--- /dev/null
+++ b/gnu/games/chess/Xchess/bishop_small_outline.bitmap
@@ -0,0 +1,15 @@
+
+#define bishop_small_outline_width 32
+#define bishop_small_outline_height 32
+static char bishop_small_outline_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x00, 0x50, 0x14, 0x00,
+ 0x00, 0x70, 0x1c, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x60, 0x16, 0x00,
+ 0x00, 0x60, 0x22, 0x00, 0x00, 0xf0, 0x23, 0x00, 0x00, 0x10, 0x21, 0x00,
+ 0x00, 0x18, 0x21, 0x00, 0x00, 0x08, 0x23, 0x00, 0x00, 0x08, 0x22, 0x00,
+ 0x00, 0x08, 0x26, 0x00, 0x00, 0x08, 0x24, 0x00, 0x00, 0xcc, 0x2c, 0x00,
+ 0x00, 0xc4, 0x28, 0x00, 0x00, 0xf6, 0x3b, 0x00, 0x00, 0xf2, 0x23, 0x00,
+ 0x00, 0xc2, 0x20, 0x00, 0x00, 0xc2, 0x20, 0x00, 0x00, 0xc2, 0x20, 0x00,
+ 0x00, 0xc2, 0x60, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00,
+ 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00,
+ 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0xe0, 0xff, 0xff, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/board.c b/gnu/games/chess/Xchess/board.c
new file mode 100644
index 000000000000..4c5b9347d8e6
--- /dev/null
+++ b/gnu/games/chess/Xchess/board.c
@@ -0,0 +1,179 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.4 $ on $Date: 86/11/23 17:17:15 $
+ * $Source: /users/faustus/xchess/RCS/board.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ * Stuff to deal with the board.
+ */
+
+#include "xchess.h"
+
+board *chessboard;
+
+void
+board_setup()
+{
+ chessboard = alloc(board);
+ board_init(chessboard);
+ return;
+}
+
+void
+board_init(b)
+ board *b;
+{
+ int i, j;
+
+ for (i = 0; i < 2; i++)
+ for (j = 0; j < SIZE; j++)
+ b->square[i][j].color = BLACK;
+ for (i = 2; i < 6; i++)
+ for (j = 0; j < SIZE; j++)
+ b->square[i][j].color = NONE;
+ for (i = 6; i < 8; i++)
+ for (j = 0; j < SIZE; j++)
+ b->square[i][j].color = WHITE;
+ for (i = 0; i < SIZE; i++)
+ b->square[1][i].type = b->square[6][i].type =
+ PAWN;
+ b->square[0][0].type = b->square[7][0].type = ROOK;
+ b->square[0][1].type = b->square[7][1].type = KNIGHT;
+ b->square[0][2].type = b->square[7][2].type = BISHOP;
+ b->square[0][3].type = b->square[7][3].type = QUEEN;
+ b->square[0][4].type = b->square[7][4].type = KING;
+ b->square[0][5].type = b->square[7][5].type = BISHOP;
+ b->square[0][6].type = b->square[7][6].type = KNIGHT;
+ b->square[0][7].type = b->square[7][7].type = ROOK;
+ b->black_cant_castle_k = false;
+ b->black_cant_castle_q = false;
+ b->white_cant_castle_k = false;
+ b->white_cant_castle_q = false;
+
+ return;
+}
+
+void
+board_drawall()
+{
+ int i, j;
+
+ for (i = 0; i < SIZE; i++)
+ for (j = 0; j < SIZE; j++)
+ if (chessboard->square[i][j].color != NONE) {
+ win_drawpiece(&chessboard->square[i][j], i,
+ j, WHITE);
+ if (!oneboard)
+ win_drawpiece(&chessboard->square[i][j],
+ i, j, BLACK);
+ }
+ return;
+}
+
+void
+board_move(b, m)
+ board *b;
+ move *m;
+{
+ switch (m->type) {
+
+ case MOVE:
+ case CAPTURE:
+ b->square[m->fromy][m->fromx].color = NONE;
+ b->square[m->toy][m->tox].color = m->piece.color;
+ b->square[m->toy][m->tox].type = m->piece.type;
+ if ((m->piece.type == PAWN) && (((m->piece.color == BLACK) &&
+ (m->toy == 7)) || ((m->piece.color == WHITE) &&
+ (m->toy == 0))))
+ b->square[m->toy][m->tox].type = QUEEN;
+ if (m->enpassant)
+ b->square[m->toy + ((m->piece.color == WHITE) ? 1 :
+ -1)][m->tox].color = NONE;
+ break;
+
+ case KCASTLE:
+ if (m->piece.color == WHITE) {
+ b->square[7][5].color = m->piece.color;
+ b->square[7][5].type = ROOK;
+ b->square[7][6].color = m->piece.color;
+ b->square[7][6].type = KING;
+ b->square[7][4].color = NONE;
+ b->square[7][7].color = NONE;
+ } else {
+ b->square[0][5].color = m->piece.color;
+ b->square[0][5].type = ROOK;
+ b->square[0][6].color = m->piece.color;
+ b->square[0][6].type = KING;
+ b->square[0][4].color = NONE;
+ b->square[0][7].color = NONE;
+ }
+ break;
+
+ case QCASTLE:
+ if (m->piece.color == WHITE) {
+ b->square[7][3].color = m->piece.color;
+ b->square[7][3].type = ROOK;
+ b->square[7][2].color = m->piece.color;
+ b->square[7][2].type = KING;
+ b->square[7][4].color = NONE;
+ b->square[7][0].color = NONE;
+ } else {
+ b->square[0][3].color = m->piece.color;
+ b->square[0][3].type = ROOK;
+ b->square[0][2].color = m->piece.color;
+ b->square[0][2].type = KING;
+ b->square[0][4].color = NONE;
+ b->square[0][0].color = NONE;
+ }
+ break;
+
+ default:
+ fprintf(stderr, "Bad move type %d\n", m->type);
+ }
+
+ if (m->piece.type == KING) {
+ if (m->piece.color == WHITE)
+ b->white_cant_castle_q =
+ b->white_cant_castle_k= true;
+ else
+ b->black_cant_castle_q =
+ b->black_cant_castle_k= true;
+ } else if (m->piece.type == ROOK) {
+ if (m->piece.color == WHITE) {
+ if (m->fromx == 0)
+ b->white_cant_castle_q = true;
+ else if (m->fromx == 7)
+ b->white_cant_castle_k = true;
+ } else {
+ if (m->fromx == 0)
+ b->black_cant_castle_q = true;
+ else if (m->fromx == 7)
+ b->black_cant_castle_k = true;
+ }
+ }
+
+ return;
+}
+
diff --git a/gnu/games/chess/Xchess/button.c b/gnu/games/chess/Xchess/button.c
new file mode 100644
index 000000000000..67bf3c86942f
--- /dev/null
+++ b/gnu/games/chess/Xchess/button.c
@@ -0,0 +1,337 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.4 $ on $Date: 86/11/26 12:09:41 $
+ * $Source: /users/faustus/xchess/RCS/button.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ * Do stuff with the buttons.
+ * The configuration we're using is: Draw Back Pause
+ * Resign Fwd Flip
+ * Reset Save Easy (Switch)
+ */
+
+#include "xchess.h"
+
+typedef enum choice { NOCHOICE, DRAW, RESIGN, REPLAY, SWITCH, FORE, SAVE,
+ STOP, FLIP, RESTART, EASY } choice;
+
+static struct but {
+ char *label;
+ int x, y;
+ int width, height;
+ choice which;
+} buts[] = {
+ { "Draw", 0, 20, 108, 29, DRAW } ,
+ { "Back", 109, 20, 108, 29, REPLAY } ,
+ { "Pause", 219, 20, 108, 29, STOP } ,
+ { "Resign", 0, 50, 108, 29, RESIGN } ,
+ { "Fwd", 109, 50, 108, 29, FORE } ,
+ { "Flip", 219, 50, 108, 29, FLIP } ,
+ { "Reset", 0, 80, 108, 29, RESTART } ,
+ { "Save", 109, 80, 108, 29, SAVE } ,
+#define EASY_OFFSET 8
+ { "Switch", 219, 80, 108, 29, SWITCH }
+/* { "NoEasy", 219, 80, 108, 29, EASY }*/
+} ;
+static int easy = 1;
+
+void
+button_draw(win)
+ windata *win;
+{
+ int i, x, numbuts = sizeof (buts) / sizeof (struct but);
+
+ XSetState(win->display, DefaultGC(win->display, 0),
+ win->border.pixel, WhitePixel(win->display, 0),
+ GXcopy, AllPlanes);
+ XSetLineAttributes(win->display, DefaultGC(win->display, 0),
+ BORDER_WIDTH, LineSolid, CapButt,
+ JoinMiter);
+
+ XDrawLine(win->display, win->buttonwin,
+ DefaultGC(win->display, 0),
+ 0, 29, BUTTON_WIDTH, 29);
+ XDrawLine(win->display, win->buttonwin,
+ DefaultGC(win->display, 0),
+ 0, 60, BUTTON_WIDTH, 60);
+ XDrawLine(win->display, win->buttonwin,
+ DefaultGC(win->display, 0),
+ 108, 0, 108, BUTTON_HEIGHT);
+ XDrawLine(win->display, win->buttonwin,
+ DefaultGC(win->display, 0),
+ 219, 0, 219, BUTTON_HEIGHT);
+
+ XSetFont(win->display, DefaultGC(win->display, 0), win->large->fid);
+ XSetForeground(win->display, DefaultGC(win->display, 0),
+ win->textcolor.pixel);
+ XSetBackground(win->display, DefaultGC(win->display, 0),
+ win->textback.pixel);
+
+ for (i = 0; i < numbuts; i++) {
+ x = (buts[i].width -
+ XTextWidth(win->large, buts[i].label,
+ strlen(buts[i].label))) / 2;
+
+ XDrawImageString(win->display, win->buttonwin,
+ DefaultGC(win->display, 0),
+ buts[i].x + x, buts[i].y, buts[i].label,
+ strlen(buts[i].label));
+ }
+ return;
+}
+
+void
+button_service(win, event)
+ windata *win;
+ XEvent *event;
+{
+ XKeyEvent *ev = &event->xkey;
+ choice c;
+ int i, numbuts = sizeof (buts) / sizeof (struct but);
+ char *s;
+
+ ev->y += 15;
+ for (i = 0; i < numbuts; i++)
+ if ((ev->x >= buts[i].x) && (ev->x <= buts[i].x +
+ buts[i].width) && (ev->y >= buts[i].y) &&
+ (ev->y <= buts[i].y + buts[i].height)) {
+ c = buts[i].which;
+ break;
+ }
+ if ((i == numbuts) || (c == NOCHOICE)) {
+ message_add(win, "Bad choice.\n", true);
+ return;
+ }
+
+ if (loading_flag && (c != STOP)) {
+ message_add(win, "You can only use PAUSE now\n", true);
+ return;
+ }
+
+ switch (c) {
+ case DRAW:
+ if (!oneboard) {
+ message_add(win, "Just a sec...\n", false);
+ if (!pop_question(((win == win1) ? win2 : win1),
+"The other player wants\nto call the game a draw.\nDo you agree?\n")) {
+ message_add(win,
+ "The other player declines the draw\n", false);
+ return;
+ }
+ }
+ message_add(win1, "Draw agreed.\n", false);
+ if (!oneboard)
+ message_add(win2, "Draw agreed.\n", false);
+ cleanup("Draw agreed.");
+ break;
+
+ case RESIGN:
+ if (!pop_question(win, "Are you sure\nyou want to resign?"))
+ return;
+ if ((oneboard && !progflag) || (nexttomove == win->color)) {
+ if (nexttomove == WHITE)
+ s = "White resigns.";
+ else
+ s = "Black resigns.";
+ if (oneboard) {
+ message_add(win, s, false);
+ message_add(win, "\n", false);
+ } else {
+ message_add(win1, s, false);
+ message_add(win, "\n", false);
+ message_add(win2, s, false);
+ message_add(win, "\n", false);
+ }
+ sleep(5);
+ cleanup(s);
+ } else {
+ message_add(win, "It's not your turn.\n", true);
+ }
+ break;
+
+ case REPLAY:
+ if (!oneboard) {
+ message_add(win, "Just a sec...\n", false);
+ if (!pop_question(((win == win1) ? win2 : win1),
+"The other player wants\nto take back his last move.\nDo you let him?\n")) {
+ message_add(win,
+ "The other player refuses...\n", false);
+ return;
+ }
+ }
+ if (!moves) {
+ message_add(win, "Can't back up...\n", true);
+ break;
+ }
+ message_add(win1, "Replaying...\n", false);
+ if (!oneboard)
+ message_add(win2, "Replaying...\n", false);
+ replay();
+ if (progflag)
+ replay();
+ break;
+
+ case FORE:
+ if (!oneboard) {
+ message_add(win, "Just a sec...\n", false);
+ if (!pop_question(((win == win1) ? win2 : win1),
+"The other player wants\nto do a 'fore'.\nIs that ok with you?\n")) {
+ message_add(win,
+ "The other player refuses...\n", false);
+ return;
+ }
+ }
+ if (!foremoves) {
+ message_add(win, "Can't go forward...\n", true);
+ break;
+ }
+ message_add(win1, "Moving forward...\n", false);
+ if (!oneboard)
+ message_add(win2, "Moving forward...\n", false);
+ forward();
+ break;
+
+ case SWITCH:
+ message_add(win, "You can't switch yet.\n", false);
+ break;
+
+ case SAVE:
+ if (saveflag) {
+ message_add(win,
+ "Game is already being logged in file '", true);
+ message_add(win, record_file, true);
+ message_add(win, "'.\n", true);
+ } else {
+ message_add(win, "Saving game to file '", false);
+ message_add(win, record_file, false);
+ message_add(win, "'.\n", false);
+ record_save();
+ }
+ break;
+
+ case STOP:
+ if (loading_flag) {
+ loading_paused = (loading_paused ? false : true);
+ message_add(win, loading_paused ?
+ "Stopped.\nHit 'Pause' again to restart.\n" :
+ "Restarted.\n", false);
+ } else if (clock_started) {
+ if (!oneboard) {
+ message_add(win, "Just a sec...\n", false);
+ if (!pop_question(((win == win1) ? win2 : win1),
+"The other player wants\nto stop the clock.\nDo you let him?\n")) {
+ message_add(win,
+ "The other player refuses to pause.\n",
+ false);
+ return;
+ }
+ }
+ message_add(win1,
+ "Clock stopped.\nHit 'Pause' again to restart.\n",
+ false);
+ if (!oneboard)
+ message_add(win2,
+ "Clock stopped.\nHit 'Pause' again to restart.\n",
+ false);
+ clock_started = false;
+ } else {
+ if (!oneboard) {
+ message_add(win, "Just a sec...\n", false);
+ if (!pop_question(((win == win1) ? win2 : win1),
+"The other player wants\nto start the clock again.\nIs that ok?\n")) {
+ message_add(win,
+ "The other player refuses to resume.\n",
+ false);
+ return;
+ }
+ }
+ message_add(win1, "Clock restarted.\n", false);
+ if (!oneboard)
+ message_add(win2, "Clock restarted.\n", false);
+ clock_started = true;
+ }
+ break;
+
+ case FLIP:
+ message_add(win, "Flipping window...\n", false);
+ win->flipped = win->flipped ? false : true;
+ win_redraw(win, (XEvent *) NULL);
+ break;
+
+ case RESTART:
+ if (!oneboard) {
+ message_add(win, "Just a sec...\n", false);
+ if (!pop_question(((win == win1) ? win2 : win1),
+"The other player wants\nto restart the game.\nDo you agree?\n")) {
+ message_add(win,
+ "The other player refuses to reset\n", false);
+ return;
+ }
+ }
+ message_add(win, "Restarting game.\n", false);
+ restart();
+ break;
+ case EASY:
+ if (oneboard) {
+ int x;
+ if (easy)
+ easy = 0;
+ else
+ easy = 1;
+
+ if (easy)
+ buts[EASY_OFFSET].label = " Easy ";
+ else
+ buts[EASY_OFFSET].label = "NoEasy";
+
+ program_easy(easy);
+
+ x = (buts[EASY_OFFSET].width -
+ XTextWidth(win->large,
+ buts[EASY_OFFSET].label,
+ strlen(buts[EASY_OFFSET].label))) / 2;
+
+ XSetFont(win->display, DefaultGC(win->display,
+ 0), win->large->fid);
+ XSetForeground(win->display,
+ DefaultGC(win->display, 0),
+ win->textcolor.pixel);
+ XSetBackground(win->display,
+ DefaultGC(win->display, 0),
+ win->textback.pixel);
+
+ XDrawImageString(win->display,
+ win->buttonwin,
+ DefaultGC(win->display, 0),
+ buts[EASY_OFFSET].x + x,
+ buts[EASY_OFFSET].y,
+ buts[EASY_OFFSET].label,
+ strlen(buts[EASY_OFFSET].label));
+ }
+ break;
+ }
+ return;
+}
+
diff --git a/gnu/games/chess/Xchess/clock.c b/gnu/games/chess/Xchess/clock.c
new file mode 100644
index 000000000000..a7b3c3264e3c
--- /dev/null
+++ b/gnu/games/chess/Xchess/clock.c
@@ -0,0 +1,291 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.4 $ on $Date: 86/11/26 12:09:47 $
+ * $Source: /users/faustus/xchess/RCS/clock.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ * Do stuff with the clocks. The way things work is as follows. We call
+ * clock_init to draw the clocks initially, but they don't actually start
+ * running until we call clock_switch for the first time.
+ */
+
+#include "xchess.h"
+
+int movesperunit = 0;
+int timeunit = 0;
+bool clock_started = false;
+int whiteseconds, blackseconds;
+
+static bool white_running = true;
+static long lastwhite, lastblack;
+static bool firstmove = true;
+
+extern void dohands(), hilight();
+
+#define PI 3.1415926535897932384
+
+void
+clock_draw(win, col)
+ windata *win;
+ color col;
+{
+ int i;
+ char buf[BSIZE];
+ int x = CLOCK_WIDTH / 2, y = CLOCK_WIDTH / 2;
+ int xp, yp;
+ int rad = CLOCK_WIDTH / 2 - 10;
+ Window w = ((col == WHITE) ? win->wclockwin : win->bclockwin);
+
+ /* Draw a clock face and the hands. */
+ XCircle(w, x, y, rad, 0.0, 0.0, 1, 1, win->textcolor.pixel, GXcopy,
+ AllPlanes);
+ rad -= 8;
+
+ XSetFont(win->display, DefaultGC(win->display, 0),
+ win->small->fid);
+ XSetForeground(win->display, DefaultGC(win->display, 0),
+ win->textcolor.pixel);
+ XSetBackground(win->display, DefaultGC(win->display, 0),
+ win->textback.pixel);
+ for (i = 1; i <= 12; i++) {
+ xp = x + rad * cos(PI * 3 / 2 + i * PI / 6) - 4;
+ yp = y + rad * sin(PI * 3 / 2 + i * PI / 6) - 5;
+ sprintf(buf, "%d", i);
+ XDrawString(win->display, w, DefaultGC(win->display, 0),
+ xp, yp, buf, strlen(buf));
+ }
+
+ dohands(win, col);
+
+ if (white_running) {
+ hilight(win, WHITE, true);
+ hilight(win, BLACK, false);
+ } else {
+ hilight(win, WHITE, false);
+ hilight(win, BLACK, true);
+ }
+ return;
+}
+
+void
+clock_init(win, col)
+ windata *win;
+ color col;
+{
+ whiteseconds = blackseconds = 0;
+ clock_started = false;
+ firstmove = true;
+ clock_draw(win, col);
+
+ return;
+}
+
+void
+clock_update()
+{
+ int now = time((long *) NULL);
+ int i;
+
+ if (!clock_started) {
+ lastwhite = lastblack = now;
+ return;
+ }
+
+ if (white_running) {
+ whiteseconds += now - lastwhite;
+ lastwhite = now;
+ dohands(win1, WHITE);
+ if (!oneboard)
+ dohands(win2, WHITE);
+ if (timeunit) {
+ i = whiteseconds / timeunit;
+ if ((i > 0) && (whiteseconds > i * timeunit) &&
+ (whiteseconds < i * timeunit + 10) &&
+ (movesperunit * i > movenum)) {
+ message_add(win1,
+ "White has exceeded his time limit\n",
+ true);
+ if (!oneboard) {
+ message_add(win2,
+ "White has exceeded his time limit\n",
+ true);
+ }
+ timeunit = 0;
+ }
+ }
+ } else {
+ blackseconds += now - lastblack;
+ lastblack = now;
+ dohands(win1, BLACK);
+ if (!oneboard)
+ dohands(win2, BLACK);
+ if (timeunit) {
+ i = blackseconds / timeunit;
+ if ((i > 0) && (blackseconds > i * timeunit) &&
+ (blackseconds < i * timeunit + 10) &&
+ (movesperunit * i > movenum)) {
+ message_add(win1,
+ "Black has exceeded his time limit\n",
+ true);
+ if (!oneboard) {
+ message_add(win2,
+ "Black has exceeded his time limit\n",
+ true);
+ }
+ timeunit = 0;
+ }
+ }
+ }
+ return;
+}
+
+void
+clock_switch()
+{
+ if (firstmove) {
+ clock_started = true;
+ firstmove = false;
+ lastwhite = lastblack = time((long *) NULL);
+ }
+ if (white_running) {
+ white_running = false;
+ lastblack = time((long *) NULL);
+ hilight(win1, WHITE, false);
+ hilight(win1, BLACK, true);
+ if (!oneboard) {
+ hilight(win2, WHITE, false);
+ hilight(win2, BLACK, true);
+ }
+ } else {
+ white_running = true;
+ lastwhite = time((long *) NULL);
+ hilight(win1, WHITE, true);
+ hilight(win1, BLACK, false);
+ if (!oneboard) {
+ hilight(win2, WHITE, true);
+ hilight(win2, BLACK, false);
+ }
+ }
+ return;
+}
+
+static void
+dohands(win, col)
+ windata *win;
+ color col;
+{
+ int cx = CLOCK_WIDTH / 2, cy = CLOCK_WIDTH / 2;
+ double *h = (col == WHITE) ? win->whitehands : win->blackhands;
+ Window w = (col == WHITE) ? win->wclockwin : win->bclockwin;
+ long secs = (col == WHITE) ? whiteseconds : blackseconds;
+ int rad, x, y, i;
+
+ /* First erase the old hands. */
+ XSetState(win->display, DefaultGC(win->display, 0),
+ win->textback.pixel, win->textback.pixel,
+ GXcopy, AllPlanes);
+
+ rad = CLOCK_WIDTH / 2 - 30;
+ for (i = 0; i < 3; i++) {
+ x = cx + rad * sin(PI - h[i]);
+ y = cy + rad * cos(PI - h[i]);
+ XSetLineAttributes(win->display,
+ DefaultGC(win->display, 0),
+ i, LineSolid, 0, 0);
+ XDrawLine(win->display, w, DefaultGC(win->display, 0),
+ cx, cy, x, y);
+ rad -= 8;
+ }
+
+ h[0] = (secs % 60) * 2 * PI / 60;
+ h[1] = ((secs / 60) % 60) * 2 * PI / 60;
+ h[2] = ((secs / 3600) % 12) * 2 * PI / 12;
+
+ /* Now draw the new ones. */
+
+ XSetState(win->display, DefaultGC(win->display, 0),
+ win->textcolor.pixel, win->textback.pixel,
+ GXcopy, AllPlanes);
+
+ rad = CLOCK_WIDTH / 2 - 30;
+ for (i = 0; i < 3; i++) {
+ x = cx + rad * sin(PI - h[i]);
+ y = cy + rad * cos(PI - h[i]);
+ XSetLineAttributes(win->display,
+ DefaultGC(win->display, 0),
+ i, LineSolid, 0, 0);
+ XDrawLine(win->display, w, DefaultGC(win->display, 0),
+ cx, cy, x, y);
+ rad -= 8;
+ }
+ XFlush(win->display);
+ return;
+}
+
+static void
+hilight(win, col, on)
+ windata *win;
+ color col;
+ bool on;
+{
+ Window w = (col == WHITE) ? win->wclockwin : win->bclockwin;
+ char *s = (col == WHITE) ? " WHITE " : " BLACK ";
+ int x;
+
+
+ x = XTextWidth(win->large, s, strlen(s));
+ if (on)
+ XSetState(win->display, DefaultGC(win->display, 0),
+ win->textback.pixel,
+ win->textcolor.pixel,
+ GXcopy,
+ AllPlanes);
+ else
+ XSetState(win->display, DefaultGC(win->display, 0),
+ win->textcolor.pixel,
+ win->textback.pixel,
+ GXcopy, AllPlanes);
+
+ XSetLineAttributes(win->display, DefaultGC(win->display, 0),
+ BORDER_WIDTH, LineSolid, CapButt, JoinMiter);
+ XSetFont(win->display, DefaultGC(win->display, 0),
+ win->large->fid);
+
+ XDrawLine(win->display, w, DefaultGC(win->display, 0),
+ 0, CLOCK_HEIGHT - 26,
+ CLOCK_WIDTH, CLOCK_HEIGHT - 26);
+
+ XDrawImageString(win->display, w, DefaultGC(win->display, 0),
+ (CLOCK_WIDTH - x) / 2, CLOCK_HEIGHT,
+ s, strlen(s));
+
+ if (on)
+ XSetState(win->display, DefaultGC(win->display, 0),
+ win->textcolor.pixel,
+ win->textback.pixel,
+ GXcopy, AllPlanes);
+ return;
+}
+
diff --git a/gnu/games/chess/Xchess/control.c b/gnu/games/chess/Xchess/control.c
new file mode 100644
index 000000000000..ad2e1d7994fd
--- /dev/null
+++ b/gnu/games/chess/Xchess/control.c
@@ -0,0 +1,515 @@
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.4 $ on $Date: 86/11/23 17:17:32 $
+ * $Source: /users/faustus/xchess/RCS/control.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ * Deal with input from the user.
+ */
+
+#include "xchess.h"
+
+move *moves;
+move *foremoves;
+color nexttomove = WHITE;
+bool noisyflag = false;
+
+move *lastmove;
+static move *thismove;
+
+static void screen_move();
+
+void
+button_pressed(event, win)
+ XEvent *event;
+ windata *win;
+{
+ int x, y;
+ XKeyEvent *ev = (XKeyEvent *) event;
+
+ if (!oneboard && (win->color != nexttomove)) {
+ message_add(win, "Wrong player!\n", true);
+ return;
+ }
+ if (progflag && (nexttomove == (blackflag ? WHITE : BLACK))) {
+ message_add(win, "Wait for the computer...\n", true);
+ return;
+ }
+ if (loading_flag) {
+ message_add(win, "You'd better not do that now...\n", true);
+ return;
+ }
+
+ /* Figure out what piece he is pointing at. */
+ x = ev->x / (SQUARE_WIDTH + BORDER_WIDTH);
+ y = ev->y / (SQUARE_HEIGHT + BORDER_WIDTH);
+
+ if (win->flipped) {
+ y = SIZE - y - 1;
+ x = SIZE - x - 1;
+ }
+
+ if ((x < 0) || (x >= SIZE) || (y < 0) || (y >= SIZE)) {
+ fprintf(stderr, "Bad coords (%d, %d)\n", x, y);
+ return;
+ }
+
+ if (oneboard && (chessboard->square[y][x].color != nexttomove)) {
+ message_add(win, "Wrong player!\n", true);
+ return;
+ } else if (!oneboard && (chessboard->square[y][x].color !=
+ win->color)) {
+ message_add(win, "Can't move that\n", true);
+ return;
+ }
+
+ thismove = alloc(move);
+ thismove->fromx = x;
+ thismove->fromy = y;
+ thismove->piece.color = chessboard->square[y][x].color;
+ thismove->piece.type = chessboard->square[y][x].type;
+
+ if (debug)
+ fprintf(stderr, "%s selected his %s at (%d, %d)...\n",
+ colornames[(int) thismove->piece.color],
+ piecenames[(int) thismove->piece.type],
+ thismove->fromy, thismove->fromx);
+ return;
+}
+
+void
+button_released(event, win)
+ XEvent *event;
+ windata *win;
+{
+ int x, y;
+ XKeyEvent *ev = (XKeyEvent *) event;
+
+ if (!thismove) {
+ /* fprintf(stderr, "Error: button hasn't been pressed\n"); */
+ return;
+ }
+ if (loading_flag)
+ return;
+
+ /* Figure out what piece he is pointing at. */
+ x = ev->x / (SQUARE_WIDTH + BORDER_WIDTH);
+ y = ev->y / (SQUARE_HEIGHT + BORDER_WIDTH);
+
+ if (win->flipped) {
+ y = SIZE - y - 1;
+ x = SIZE - x - 1;
+ }
+
+ if ((x < 0) || (x >= SIZE) || (y < 0) || (y >= SIZE)) {
+ fprintf(stderr, "Bad coords (%d, %d)\n", x, y);
+ return;
+ }
+
+ if ((thismove->fromx == x) && (thismove->fromy == y)) {
+ message_add(win, "Hey, you touch it, you move it, buddy.\n",
+ true);
+ return;
+ }
+ if (chessboard->square[y][x].color == thismove->piece.color) {
+ message_add(win, "Can't put one piece on top of another\n",
+ true);
+ return;
+ }
+
+ thismove->tox = x;
+ thismove->toy = y;
+ thismove->taken.color = chessboard->square[y][x].color;
+ thismove->taken.type = chessboard->square[y][x].type;
+ if (thismove->taken.color != NONE)
+ thismove->type = CAPTURE;
+ else if ((thismove->piece.type == KING) && (thismove->fromx == 4) &&
+ (thismove->tox == 6) &&
+ (thismove->toy == thismove->fromy))
+ thismove->type = KCASTLE;
+ else if ((thismove->piece.type == KING) && (thismove->tox == 2) &&
+ (thismove->fromx == 4) &&
+ (thismove->toy == thismove->fromy))
+ thismove->type = QCASTLE;
+ else
+ thismove->type = MOVE;
+
+ /* Now check the en-passant case... */
+ if ((thismove->type == MOVE) && ((thismove->tox == thismove->fromx + 1)
+ || (thismove->tox == thismove->fromx - 1)) &&
+ (thismove->piece.type == PAWN) && lastmove &&
+ (lastmove->tox == lastmove->fromx) && (lastmove->fromx
+ == thismove->tox) && ((lastmove->fromy + lastmove->toy)
+ / 2 == thismove->toy)) {
+ thismove->type = CAPTURE;
+ thismove->enpassant = true;
+ thismove->taken = lastmove->piece;
+ }
+
+ if (!valid_move(thismove, chessboard)) {
+ message_add(win, "Invalid move.\n", true);
+ return;
+ }
+
+ if (debug)
+ fprintf(stderr, "\t... and moved it to (%d, %d), type %s\n",
+ thismove->toy, thismove->tox,
+ movetypenames[(int) thismove->type]);
+ move_piece(thismove);
+
+ if (thismove->check) {
+ message_add(win1, "Check.\n", true);
+ if (!oneboard) {
+ message_add(win2, "Check.\n", true);
+ }
+ }
+
+ if (!moves)
+ moves = lastmove = thismove;
+ else
+ lastmove = lastmove->next = thismove;
+
+ if (progflag)
+ program_send(thismove);
+
+ thismove = NULL;
+ nexttomove = ((nexttomove == WHITE) ? BLACK : WHITE);
+ clock_switch();
+
+ return;
+}
+
+void
+prog_move(m)
+ move *m;
+{
+ if (debug)
+ fprintf(stderr, "program moves from (%d, %d) to (%d, %d)\n",
+ m->fromy, m->fromx, m->toy, m->tox);
+ move_piece(m);
+
+ if (!moves)
+ moves = lastmove = m;
+ else
+ lastmove = lastmove->next = m;
+
+ nexttomove = ((nexttomove == WHITE) ? BLACK : WHITE);
+ clock_switch();
+
+ return;
+}
+
+void
+move_piece(m)
+ move *m;
+{
+ /* Update the screen... */
+ screen_move(m);
+
+ /* Move the piece on the board... */
+ board_move(chessboard, m);
+
+ /* And record it... */
+ record_move(m);
+
+ if (noisyflag) {
+ XBell(win1->display, 50);
+ XBell(win2->display, 50);
+ }
+ return;
+}
+
+static void
+screen_move(m)
+ move *m;
+{
+ piece pp;
+
+ switch (m->type) {
+ case CAPTURE:
+ jail_add(&m->taken);
+ /* FALLTHRU */
+
+ case MOVE:
+ win_erasepiece(m->fromy, m->fromx, WHITE);
+ if (win_flashmove)
+ win_flash(m, WHITE);
+ win_drawpiece(&m->piece, m->toy, m->tox, WHITE);
+ if (m->enpassant)
+ win_erasepiece(m->toy + ((m->piece.color == WHITE) ?
+ 1 : -1), m->tox, WHITE);
+ if (!oneboard) {
+ win_erasepiece(m->fromy, m->fromx, BLACK);
+ if (win_flashmove)
+ win_flash(m, BLACK);
+ win_drawpiece(&m->piece, m->toy, m->tox, BLACK);
+ if (m->enpassant)
+ win_erasepiece(m->toy + ((m->piece.color ==
+ WHITE) ? 1 : -1), m->tox, WHITE);
+ }
+ if ((m->piece.type == PAWN) && (((m->piece.color == BLACK) &&
+ (m->toy == 7)) || ((m->piece.color == WHITE) &&
+ (m->toy == 0)))) {
+ pp.color = m->piece.color;
+ pp.type = QUEEN;
+ win_drawpiece(&pp, m->toy, m->tox, WHITE);
+ if (!oneboard)
+ win_drawpiece(&m->piece, m->toy, m->tox, BLACK);
+ }
+ break;
+
+ case KCASTLE:
+ if (m->piece.color == WHITE) {
+ win_erasepiece(7, 4, WHITE);
+ win_erasepiece(7, 7, WHITE);
+ if (win_flashmove)
+ win_flash(m, WHITE);
+ win_drawpiece(&m->piece, 7, 6, WHITE);
+ win_drawpiece(&chessboard->square[7][7], 7, 5, WHITE);
+ if (!oneboard) {
+ win_erasepiece(7, 4, BLACK);
+ win_erasepiece(7, 7, BLACK);
+ if (win_flashmove)
+ win_flash(m, BLACK);
+ win_drawpiece(&m->piece, 7, 6, BLACK);
+ win_drawpiece(&chessboard->square[7][7], 7, 5,
+ BLACK);
+ }
+ } else {
+ win_erasepiece(0, 4, WHITE);
+ win_erasepiece(0, 7, WHITE);
+ if (win_flashmove)
+ win_flash(m, WHITE);
+ win_drawpiece(&m->piece, 0, 6, WHITE);
+ win_drawpiece(&chessboard->square[0][7], 0, 5, WHITE);
+ if (!oneboard) {
+ win_erasepiece(0, 4, BLACK);
+ win_erasepiece(0, 7, BLACK);
+ if (win_flashmove)
+ win_flash(m, BLACK);
+ win_drawpiece(&m->piece, 0, 6, BLACK);
+ win_drawpiece(&chessboard->square[0][7], 0, 5,
+ BLACK);
+ }
+ }
+ break;
+
+ case QCASTLE:
+ if (m->piece.color == WHITE) {
+ win_erasepiece(7, 4, WHITE);
+ win_erasepiece(7, 0, WHITE);
+ if (win_flashmove)
+ win_flash(m, WHITE);
+ win_drawpiece(&m->piece, 7, 2, WHITE);
+ win_drawpiece(&chessboard->square[7][0], 7, 3, WHITE);
+ if (!oneboard) {
+ win_erasepiece(7, 4, BLACK);
+ win_erasepiece(7, 0, BLACK);
+ if (win_flashmove)
+ win_flash(m, BLACK);
+ win_drawpiece(&m->piece, 7, 2, BLACK);
+ win_drawpiece(&chessboard->square[7][7], 7, 3,
+ BLACK);
+ }
+ } else {
+ win_erasepiece(0, 4, WHITE);
+ win_erasepiece(0, 0, WHITE);
+ if (win_flashmove)
+ win_flash(m, WHITE);
+ win_drawpiece(&m->piece, 0, 2, WHITE);
+ win_drawpiece(&chessboard->square[0][0], 0, 3, WHITE);
+ if (!oneboard) {
+ win_erasepiece(0, 4, BLACK);
+ win_erasepiece(0, 0, BLACK);
+ if (win_flashmove)
+ win_flash(m, BLACK);
+ win_drawpiece(&m->piece, 0, 2, BLACK);
+ win_drawpiece(&chessboard->square[0][7], 0, 3,
+ BLACK);
+ }
+ }
+ break;
+
+ default:
+ fprintf(stderr, "Bad move type %d\n", m->type);
+ }
+ return;
+}
+
+/* Retract the last move made... */
+
+void
+replay()
+{
+ move *m = lastmove, bm;
+
+ memset(&bm, 0, sizeof(bm));
+ switch (m->type) {
+ case MOVE:
+ bm.type = MOVE;
+ bm.piece = m->piece;
+ bm.fromx = m->tox;
+ bm.fromy = m->toy;
+ bm.tox = m->fromx;
+ bm.toy = m->fromy;
+ board_move(chessboard, &bm);
+ screen_move(&bm);
+ break;
+
+ case CAPTURE:
+ bm.type = MOVE;
+ bm.piece = m->piece;
+ bm.fromx = m->tox;
+ bm.fromy = m->toy;
+ bm.tox = m->fromx;
+ bm.toy = m->fromy;
+ board_move(chessboard, &bm);
+ screen_move(&bm);
+ chessboard->square[m->toy][m->tox] = m->taken;
+ bm.piece = m->taken;
+ bm.fromx = bm.tox = m->tox;
+ bm.fromy = bm.toy = m->toy;
+ screen_move(&bm);
+ jail_remove(&m->taken);
+ break;
+
+ case KCASTLE:
+ bm.type = MOVE;
+ bm.piece.type = KING;
+ bm.piece.color = m->piece.color;
+ bm.fromx = 6;
+ bm.tox = 4;
+ bm.fromy = bm.toy = (m->piece.color == WHITE) ? 7 : 0;
+ board_move(chessboard, &bm);
+ screen_move(&bm);
+ bm.type = MOVE;
+ bm.piece.type = ROOK;
+ bm.piece.color = m->piece.color;
+ bm.fromx = 5;
+ bm.tox = 7;
+ bm.fromy = bm.toy = (m->piece.color == WHITE) ? 7 : 0;
+ board_move(chessboard, &bm);
+ screen_move(&bm);
+ if (m->piece.color == WHITE)
+ chessboard->white_cant_castle_k = false;
+ else
+ chessboard->black_cant_castle_k = false;
+ break;
+
+ case QCASTLE:
+ bm.type = MOVE;
+ bm.piece.type = KING;
+ bm.piece.color = m->piece.color;
+ bm.fromx = 2;
+ bm.tox = 4;
+ bm.fromy = bm.toy = (m->piece.color == WHITE) ? 7 : 0;
+ board_move(chessboard, &bm);
+ screen_move(&bm);
+ bm.type = MOVE;
+ bm.piece.type = ROOK;
+ bm.piece.color = m->piece.color;
+ bm.fromx = 3;
+ bm.tox = 0;
+ bm.fromy = bm.toy = (m->piece.color == WHITE) ? 7 : 0;
+ board_move(chessboard, &bm);
+ screen_move(&bm);
+ if (m->piece.color == WHITE)
+ chessboard->white_cant_castle_q = false;
+ else
+ chessboard->black_cant_castle_q = false;
+ break;
+ }
+ record_back();
+
+ nexttomove = ((nexttomove == WHITE) ? BLACK : WHITE);
+ clock_switch();
+
+ if (!moves->next) {
+ moves->next = foremoves;
+ foremoves = moves;
+ moves = lastmove = NULL;
+ } else {
+ for (m = moves; m->next; m = m->next)
+ lastmove = m;
+ lastmove->next->next = foremoves;
+ foremoves = lastmove->next;
+ lastmove->next = NULL;
+ }
+
+ if (progflag)
+ program_undo();
+
+ return;
+}
+
+/* Put back the last move undone. */
+
+void
+forward()
+{
+ prog_move(foremoves);
+ foremoves = foremoves->next;
+ return;
+}
+
+/* End the game. */
+
+void
+cleanup(s)
+ char *s;
+{
+ if (progflag)
+ program_end();
+ record_end(s);
+ XSync(win1->display, 0);
+ if (!oneboard) {
+ XSync(win2->display, 0);
+ }
+ exit(0);
+}
+
+void
+restart()
+{
+ moves = lastmove = thismove = NULL;
+ nexttomove = WHITE;
+
+ clock_init(win1, WHITE);
+ clock_init(win1, BLACK);
+ jail_init(win1);
+ if (!oneboard) {
+ clock_init(win2, WHITE);
+ clock_init(win2, BLACK);
+ jail_init(win2);
+ }
+ board_init(chessboard);
+ win_restart();
+ record_reset();
+ if (progflag) {
+ program_end();
+ program_init(progname);
+ }
+ return;
+}
+
diff --git a/gnu/games/chess/Xchess/jail.c b/gnu/games/chess/Xchess/jail.c
new file mode 100644
index 000000000000..e5e60642430a
--- /dev/null
+++ b/gnu/games/chess/Xchess/jail.c
@@ -0,0 +1,327 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.3 $ on $Date: 86/11/26 12:09:54 $
+ * $Source: /users/faustus/xchess/RCS/jail.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ */
+
+#include "xchess.h"
+
+#include "pawn_small.bitmap"
+#include "rook_small.bitmap"
+#include "knight_small.bitmap"
+#include "bishop_small.bitmap"
+#include "queen_small.bitmap"
+#include "king_small.bitmap"
+
+#include "pawn_small_outline.bitmap"
+#include "rook_small_outline.bitmap"
+#include "knight_small_outline.bitmap"
+#include "bishop_small_outline.bitmap"
+#include "queen_small_outline.bitmap"
+#include "king_small_outline.bitmap"
+
+static bool pos[32];
+
+static piecetype pcs[] = { KING, QUEEN, ROOK, ROOK, BISHOP, BISHOP, KNIGHT,
+ KNIGHT, PAWN, PAWN, PAWN, PAWN, PAWN, PAWN, PAWN, PAWN } ;
+
+extern int piecepos();
+extern char *bitsget();
+
+void
+jail_init(win)
+ windata *win;
+{
+ int i;
+
+ for (i = 0; i < 32; i++)
+ pos[i] = false;
+ jail_draw(win);
+ return;
+}
+
+#define JAIL_HEADER "Captured Pieces"
+
+void
+jail_draw(win)
+ windata *win;
+{
+ int i;
+ char *bits;
+ Pixmap tmpPM;
+ piece p;
+
+ i = XTextWidth(win->large, JAIL_HEADER, strlen(JAIL_HEADER));
+ XSetFont(win->display, DefaultGC(win->display, 0),
+ win->large->fid);
+ XSetForeground(win->display, DefaultGC(win->display, 0),
+ win->textcolor.pixel);
+ XSetBackground(win->display, DefaultGC(win->display, 0),
+ win->textback.pixel);
+
+ XDrawImageString(win->display, win->jailwin,
+ DefaultGC(win->display, 0),
+ (JAIL_WIDTH - i) / 2, 20, JAIL_HEADER,
+ strlen(JAIL_HEADER));
+
+ XSetForeground(win->display, DefaultGC(win->display, 0),
+ win->blackpiece.pixel);
+ XSetBackground(win->display, DefaultGC(win->display, 0),
+ win->textback.pixel);
+ XSetFillStyle(win->display, DefaultGC(win->display, 0),
+ FillSolid);
+ XSetFunction(win->display, DefaultGC(win->display, 0),
+ GXcopy);
+
+ for (i = 0; i < 16; i++)
+ if (pos[i]) {
+ p.color = WHITE;
+ p.type = pcs[i];
+ bits = bitsget(&p);
+ tmpPM = XCreateBitmapFromData(win->display,
+ win->jailwin, bits,
+ 32, 32);
+
+ XCopyPlane(win->display, tmpPM, win->jailwin,
+ DefaultGC(win->display, 0),
+ 0, 0, 32, 32,
+ 5 + (i % 8) * 32, 25 + (i / 8) * 32,
+ 1);
+ XFreePixmap(win->display, tmpPM);
+ } else {
+ XFillRectangle(win->display, win->jailwin,
+ DefaultGC(win->display, 0),
+ 5 + (i % 8) * 32,
+ 25 + (i / 8) * 32,
+ 32, 32);
+ }
+ for (i = 0; i < 16; i++)
+ if (pos[i + 16]) {
+ p.color = BLACK;
+ p.type = pcs[i];
+ bits = bitsget(&p);
+ tmpPM = XCreateBitmapFromData(win->display,
+ win->jailwin, bits,
+ 32, 32);
+
+ XCopyPlane(win->display, tmpPM, win->jailwin,
+ DefaultGC(win->display, 0),
+ 0, 0, 32, 32,
+ 5 + (i % 8) * 32, 94 + (i / 8) * 32,
+ 1);
+ XFreePixmap(win->display, tmpPM);
+ } else {
+ XFillRectangle(win->display, win->jailwin,
+ DefaultGC(win->display, 0),
+ 5 + (i % 8) * 32, 94 + (i / 8) * 32,
+ 32, 32);
+ }
+
+ return;
+}
+
+void
+jail_add(p)
+ piece *p;
+{
+ int i = piecepos(p, false);
+ char *bits;
+ Pixmap tmpPM;
+
+ pos[i] = true;
+
+ bits = bitsget(p);
+
+ XSetState(win1->display, DefaultGC(win1->display, 0),
+ win1->blackpiece.pixel,
+ win1->textback.pixel,
+ GXcopy,
+ AllPlanes);
+
+ tmpPM = XCreateBitmapFromData(win1->display,
+ win1->jailwin, bits,
+ 32, 32);
+
+ XCopyPlane(win1->display, tmpPM, win1->jailwin,
+ DefaultGC(win1->display, 0),
+ 0, 0, 32, 32,
+ 5 + (i % 8) * 32, ((i >= 16) ? 30 : 25) + (i / 8) * 32,
+ 1);
+ XFreePixmap(win1->display, tmpPM);
+
+ if (!oneboard) {
+ XSetState(win2->display, DefaultGC(win2->display, 0),
+ win2->blackpiece.pixel,
+ win2->textback.pixel,
+ GXcopy,
+ AllPlanes);
+
+
+ tmpPM = XCreateBitmapFromData(win2->display,
+ win2->jailwin, bits,
+ 32, 32);
+
+ XCopyPlane(win2->display, tmpPM, win2->jailwin,
+ DefaultGC(win2->display, 0),
+ 0, 0, 32, 32,
+ 5 + (i % 8) * 32, ((i >= 16) ? 30 : 25) + (i / 8) * 32,
+ 1);
+ XFreePixmap(win2->display, tmpPM);
+ }
+
+ return;
+}
+
+void
+jail_remove(p)
+ piece *p;
+{
+ int i = piecepos(p, true);
+
+ pos[i] = false;
+
+
+ XSetForeground(win1->display,
+ DefaultGC(win1->display, 0),
+ win1->blackpiece.pixel);
+ XSetBackground(win1->display,
+ DefaultGC(win1->display, 0),
+ win1->textback.pixel);
+ XSetFillStyle(win1->display,
+ DefaultGC(win1->display, 0),
+ FillSolid);
+
+ XFillRectangle(win1->display, win1->jailwin,
+ DefaultGC(win1->display, 0),
+ 5 + (i % 8) * 32,
+ ((i >= 16) ? 30 : 25) + (i / 8) * 32,
+ 32, 32);
+
+ if (!oneboard) {
+ XSetForeground(win2->display,
+ DefaultGC(win2->display, 0),
+ win2->blackpiece.pixel);
+ XSetBackground(win2->display,
+ DefaultGC(win2->display, 0),
+ win2->textback.pixel);
+ XSetFillStyle(win2->display,
+ DefaultGC(win2->display, 0),
+ FillSolid);
+
+ XFillRectangle(win2->display, win2->jailwin,
+ DefaultGC(win2->display, 0),
+ 5 + (i % 8) * 32,
+ ((i >= 16) ? 30 : 25) + (i / 8) * 32,
+ 32, 32);
+ }
+
+ return;
+}
+
+static char *bitsget(p)
+ piece *p;
+{
+ char *bits;
+
+ switch (p->type) {
+ case PAWN:
+ bits = (p->color == WHITE) ? pawn_small_outline_bits :
+ pawn_small_bits;
+ break;
+
+ case ROOK:
+ bits = (p->color == WHITE) ? rook_small_outline_bits :
+ rook_small_bits;
+ break;
+
+ case KNIGHT:
+ bits = (p->color == WHITE) ? knight_small_outline_bits :
+ knight_small_bits;
+ break;
+
+ case BISHOP:
+ bits = (p->color == WHITE) ? bishop_small_outline_bits :
+ bishop_small_bits;
+ break;
+
+ case QUEEN:
+ bits = (p->color == WHITE) ? queen_small_outline_bits :
+ queen_small_bits;
+ break;
+
+ case KING:
+ bits = (p->color == WHITE) ? king_small_outline_bits :
+ king_small_bits;
+ break;
+ }
+ return (bits);
+}
+
+static int
+piecepos(p, there)
+ piece *p;
+ bool there;
+{
+ int i, base = (p->color == WHITE) ? 0 : 16;
+
+ switch (p->type) {
+ case PAWN:
+ for (i = base + 8; (i < base + 15) && pos[i]; i++)
+ ;
+ if (there && !pos[i])
+ i--;
+ break;
+
+ case KING:
+ /* Hmm... */
+ i = base;
+ break;
+
+ case QUEEN:
+ i = base + 1;
+ break;
+
+ case ROOK:
+ i = base + 2;
+ if ((there && pos[i + 1]) || (!there && pos[i]))
+ i++;
+ break;
+
+ case BISHOP:
+ i = base + 4;
+ if ((there && pos[i + 1]) || (!there && pos[i]))
+ i++;
+ break;
+
+ case KNIGHT:
+ i = base + 6;
+ if ((there && pos[i + 1]) || (!there && pos[i]))
+ i++;
+ break;
+ }
+ return (i);
+}
diff --git a/gnu/games/chess/Xchess/king.bitmap b/gnu/games/chess/Xchess/king.bitmap
new file mode 100644
index 000000000000..dd9178a2ed9e
--- /dev/null
+++ b/gnu/games/chess/Xchess/king.bitmap
@@ -0,0 +1,71 @@
+
+#define king_width 80
+#define king_height 80
+static char king_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x30, 0x18, 0x00, 0xfc, 0x1f, 0x00,
+ 0x00, 0xfe, 0x7f, 0x00, 0xb8, 0x3b, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff,
+ 0xff, 0x00, 0xb8, 0x3b, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x03,
+ 0xb8, 0x3b, 0xe0, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0x0f, 0xb8, 0x3b,
+ 0xf0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x1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xef, 0xdf, 0xff, 0x7e, 0x00, 0x00, 0x7e, 0xfe, 0xff, 0xef, 0xef,
+ 0xff, 0x7f, 0x7e, 0x00, 0x00, 0xfc, 0xfc, 0xff, 0xef, 0xef, 0xff, 0x7f,
+ 0x3f, 0x00, 0x00, 0xfc, 0xf9, 0xff, 0xef, 0xef, 0xff, 0x3f, 0x1f, 0x00,
+ 0x00, 0xf8, 0xfb, 0x03, 0xe0, 0x0f, 0x00, 0x9f, 0x1f, 0x00, 0x00, 0xf0,
+ 0x03, 0xf8, 0xff, 0xff, 0x7f, 0xc0, 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xbf,
+ 0xf7, 0xde, 0xfb, 0xff, 0x07, 0x00, 0x00, 0xc0, 0xff, 0x1d, 0x63, 0x8c,
+ 0x71, 0xff, 0x03, 0x00, 0x00, 0x80, 0xef, 0xb8, 0xf7, 0xde, 0x3b, 0xee,
+ 0x01, 0x00, 0x00, 0x00, 0xc7, 0xfd, 0xff, 0xff, 0x7f, 0xc7, 0x00, 0x00,
+ 0x00, 0x00, 0xee, 0xff, 0x00, 0x00, 0xfc, 0x6f, 0x00, 0x00, 0x00, 0x00,
+ 0xfe, 0x03, 0xfe, 0xff, 0x01, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf8,
+ 0x7f, 0xfc, 0x7f, 0x60, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x1f, 0xf0,
+ 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xff, 0x07, 0xc0, 0xff, 0x63,
+ 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x1f, 0xf0, 0xff, 0x60, 0x00, 0x00,
+ 0x00, 0x00, 0x06, 0xfc, 0x7f, 0xfc, 0x3f, 0x60, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0xff, 0xff, 0xff, 0xff, 0x60, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xff,
+ 0x00, 0x00, 0xfc, 0x63, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x03, 0xfe, 0xff,
+ 0x01, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x06, 0xf8, 0xff, 0xff, 0x7f, 0x60,
+ 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/king_mask.bitmap b/gnu/games/chess/Xchess/king_mask.bitmap
new file mode 100644
index 000000000000..e1bb523cad10
--- /dev/null
+++ b/gnu/games/chess/Xchess/king_mask.bitmap
@@ -0,0 +1,71 @@
+
+#define king_mask_width 80
+#define king_mask_height 80
+static char king_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0xf8, 0x3f, 0x00, 0xfe,
+ 0x3f, 0x00, 0x00, 0xff, 0xff, 0x00, 0xfc, 0x3f, 0x80, 0xff, 0x7f, 0x00,
+ 0x80, 0xff, 0xff, 0x01, 0xfc, 0x7f, 0xc0, 0xff, 0xff, 0x00, 0xc0, 0xff,
+ 0xff, 0x07, 0xfc, 0x7f, 0xe0, 0xff, 0xff, 0x01, 0xe0, 0xff, 0xff, 0x1f,
+ 0xfc, 0x7f, 0xf8, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0x3f, 0xfc, 0x7f,
+ 0xfc, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0x7f, 0xfc, 0x7f, 0xfe, 0xff,
+ 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xff, 0xfc, 0x7f, 0xff, 0xff, 0xff, 0x1f,
+ 0xf8, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
+ 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
+ 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x1f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
+ 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf0, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x07, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07,
+ 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00,
+ 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xf8, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
+ 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/king_outline.bitmap b/gnu/games/chess/Xchess/king_outline.bitmap
new file mode 100644
index 000000000000..173651c28efa
--- /dev/null
+++ b/gnu/games/chess/Xchess/king_outline.bitmap
@@ -0,0 +1,71 @@
+
+#define king_outline_width 80
+#define king_outline_height 80
+static char king_outline_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1c,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x3c,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x0c, 0x60, 0x00, 0xfc, 0x1f, 0x00,
+ 0x00, 0x0e, 0x70, 0x00, 0x84, 0x43, 0x00, 0x07, 0x70, 0x00, 0x00, 0x03,
+ 0xc0, 0x00, 0xc4, 0x46, 0x80, 0x01, 0xc0, 0x00, 0x80, 0x01, 0x80, 0x03,
+ 0x44, 0x44, 0xe0, 0x00, 0x80, 0x01, 0xc0, 0x00, 0x00, 0x0e, 0x44, 0x44,
+ 0x30, 0x00, 0x00, 0x03, 0x60, 0x00, 0x00, 0x18, 0x44, 0x44, 0x18, 0x00,
+ 0x07, 0x06, 0x20, 0xe0, 0x3f, 0x30, 0xc4, 0x46, 0x0c, 0xf8, 0x1d, 0x04,
+ 0x30, 0x30, 0x60, 0x60, 0x8c, 0x63, 0x06, 0x0c, 0x30, 0x0c, 0x10, 0x18,
+ 0xc0, 0xc1, 0x08, 0x20, 0x82, 0x03, 0x20, 0x0c, 0x10, 0x0c, 0x00, 0x83,
+ 0x09, 0x20, 0xc3, 0x00, 0x60, 0x08, 0x18, 0x04, 0x00, 0x02, 0x8b, 0xa3,
+ 0x41, 0x00, 0x40, 0x18, 0x08, 0x06, 0x00, 0x06, 0x7a, 0xb6, 0x20, 0x00,
+ 0xc0, 0x10, 0x08, 0x02, 0x00, 0x0c, 0x3e, 0x7c, 0x30, 0x00, 0x80, 0x10,
+ 0x08, 0x02, 0x00, 0x18, 0x18, 0x18, 0x10, 0x00, 0x80, 0x10, 0x0c, 0x02,
+ 0x00, 0x30, 0x00, 0x00, 0x18, 0xc0, 0x83, 0x30, 0x04, 0xc3, 0x03, 0x20,
+ 0x00, 0x01, 0x0c, 0xc2, 0x83, 0x20, 0x04, 0xc1, 0x03, 0x61, 0x80, 0x03,
+ 0x06, 0xc6, 0x83, 0x20, 0x04, 0xc1, 0x83, 0x41, 0xc0, 0x07, 0x06, 0xc4,
+ 0x83, 0x20, 0x04, 0xc1, 0x87, 0xc0, 0x80, 0x03, 0x03, 0xc4, 0x80, 0x20,
+ 0x0c, 0x01, 0x84, 0x80, 0x00, 0x01, 0x01, 0x64, 0x80, 0x30, 0x08, 0x01,
+ 0x44, 0x80, 0x01, 0x80, 0x01, 0x24, 0x86, 0x10, 0x08, 0x01, 0x4c, 0x00,
+ 0x01, 0x80, 0x00, 0x34, 0x83, 0x10, 0x08, 0x61, 0x48, 0x00, 0x01, 0x80,
+ 0x00, 0xd4, 0xc1, 0x10, 0x08, 0xc1, 0x59, 0x00, 0x03, 0x80, 0x00, 0x5c,
+ 0x40, 0x10, 0x08, 0x01, 0x57, 0x00, 0x02, 0xc1, 0x00, 0x2c, 0x40, 0x10,
+ 0x18, 0x02, 0x7c, 0x00, 0x82, 0x43, 0x00, 0x3c, 0x40, 0x18, 0x10, 0x02,
+ 0x70, 0x00, 0xc6, 0x47, 0x00, 0x1c, 0x40, 0x18, 0x10, 0x02, 0x60, 0x00,
+ 0x84, 0x43, 0x00, 0x0e, 0x60, 0x08, 0x10, 0x06, 0x40, 0x00, 0x04, 0x41,
+ 0x00, 0x02, 0x20, 0x08, 0x10, 0x04, 0xc0, 0x00, 0x0c, 0x60, 0x00, 0x02,
+ 0x20, 0x0c, 0x30, 0x0c, 0x80, 0x00, 0x08, 0x20, 0x00, 0x03, 0x20, 0x0c,
+ 0x20, 0x08, 0x80, 0x01, 0x08, 0x20, 0x00, 0x01, 0x20, 0x04, 0x20, 0x08,
+ 0x00, 0x01, 0x08, 0x20, 0x80, 0x01, 0x30, 0x04, 0x60, 0x18, 0x00, 0x01,
+ 0x08, 0x20, 0x80, 0x00, 0x10, 0x06, 0x40, 0x10, 0x00, 0x03, 0x10, 0x11,
+ 0x80, 0x00, 0x18, 0x02, 0xc0, 0x30, 0x00, 0x02, 0x90, 0x13, 0xc0, 0x00,
+ 0x08, 0x03, 0x80, 0x20, 0x00, 0x06, 0x10, 0x11, 0x40, 0x00, 0x04, 0x01,
+ 0x80, 0x61, 0x00, 0x04, 0x10, 0x10, 0x60, 0x00, 0x84, 0x01, 0x00, 0x41,
+ 0x00, 0x04, 0x10, 0x10, 0x20, 0x00, 0xc6, 0x00, 0x00, 0x83, 0x00, 0x0c,
+ 0x10, 0x10, 0x20, 0x00, 0x41, 0x00, 0x00, 0x82, 0x01, 0x00, 0x10, 0x10,
+ 0x00, 0x80, 0x61, 0x00, 0x00, 0x06, 0x01, 0x00, 0x10, 0x10, 0x00, 0x80,
+ 0x30, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x10, 0x10, 0x00, 0xc0, 0x10, 0x00,
+ 0x00, 0x18, 0x02, 0xff, 0x1f, 0xf0, 0xff, 0x60, 0x18, 0x00, 0x00, 0x30,
+ 0xfe, 0x01, 0x00, 0x00, 0x80, 0x3f, 0x0c, 0x00, 0x00, 0x20, 0x00, 0x40,
+ 0x08, 0x21, 0x04, 0x00, 0x06, 0x00, 0x00, 0xc0, 0x00, 0xe2, 0x9c, 0x73,
+ 0x8e, 0x00, 0x03, 0x00, 0x00, 0x80, 0x11, 0x47, 0x08, 0x21, 0xc4, 0x11,
+ 0x01, 0x00, 0x00, 0x00, 0x3b, 0x02, 0x00, 0x00, 0x80, 0xb8, 0x00, 0x00,
+ 0x00, 0x00, 0x12, 0x00, 0xff, 0xff, 0x03, 0x90, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0xfc, 0x01, 0x00, 0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x07,
+ 0x80, 0x03, 0x80, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xe0, 0x0f,
+ 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0xf8, 0x3f, 0x00, 0x5c,
+ 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0xe0, 0x0f, 0x00, 0x5f, 0x00, 0x00,
+ 0x00, 0x00, 0xfa, 0x03, 0x80, 0x03, 0xc0, 0x5f, 0x00, 0x00, 0x00, 0x00,
+ 0xfa, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00,
+ 0xff, 0xff, 0x03, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfc, 0x01, 0x00,
+ 0xfe, 0x40, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x07, 0x00, 0x00, 0x80, 0x5f,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/king_small.bitmap b/gnu/games/chess/Xchess/king_small.bitmap
new file mode 100644
index 000000000000..38bb2b7e88b8
--- /dev/null
+++ b/gnu/games/chess/Xchess/king_small.bitmap
@@ -0,0 +1,15 @@
+
+#define king_small_width 32
+#define king_small_height 32
+static char king_small_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0x00, 0x00, 0x80, 0x9f, 0x00, 0x00, 0x70, 0x20, 0x00,
+ 0x00, 0x0c, 0x40, 0x00, 0x00, 0x02, 0x80, 0x01, 0x80, 0x01, 0x00, 0x03,
+ 0x40, 0x00, 0x00, 0x06, 0x40, 0x60, 0x30, 0x08, 0x20, 0x60, 0x30, 0x10,
+ 0x20, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0x80,
+ 0x10, 0x00, 0x02, 0x80, 0x10, 0x00, 0x01, 0x80, 0x10, 0x01, 0x01, 0x80,
+ 0x10, 0x03, 0x1f, 0x84, 0x10, 0x02, 0x00, 0x84, 0x10, 0x06, 0x00, 0x86,
+ 0x20, 0x1c, 0x00, 0x42, 0x20, 0xf0, 0xff, 0x43, 0x20, 0x00, 0x00, 0x40,
+ 0x40, 0x00, 0x00, 0x20, 0x40, 0x00, 0x00, 0x20, 0x80, 0x01, 0x00, 0x18,
+ 0x00, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/king_small_outline.bitmap b/gnu/games/chess/Xchess/king_small_outline.bitmap
new file mode 100644
index 000000000000..18d569e9d7b9
--- /dev/null
+++ b/gnu/games/chess/Xchess/king_small_outline.bitmap
@@ -0,0 +1,15 @@
+
+#define king_small_outline_width 32
+#define king_small_outline_height 32
+static char king_small_outline_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x90, 0x00, 0x06, 0x10, 0xb1, 0x00,
+ 0x22, 0x12, 0xe1, 0x00, 0x24, 0x92, 0x9f, 0x00, 0x40, 0x72, 0xa0, 0x50,
+ 0x04, 0x0e, 0x40, 0x50, 0x40, 0x02, 0x80, 0x71, 0xc8, 0x01, 0x00, 0x73,
+ 0xd8, 0x00, 0x00, 0x46, 0xd8, 0x60, 0x30, 0x08, 0xa0, 0x60, 0x30, 0x10,
+ 0x20, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0x80,
+ 0x10, 0x00, 0x02, 0x80, 0x10, 0x00, 0x01, 0x80, 0x10, 0x01, 0x01, 0x80,
+ 0x10, 0x03, 0x1f, 0x84, 0x10, 0x02, 0x00, 0x84, 0x10, 0x06, 0x00, 0x86,
+ 0x20, 0x1c, 0x00, 0x42, 0x20, 0xf0, 0xff, 0x43, 0x20, 0x00, 0x00, 0x40,
+ 0x40, 0x00, 0x00, 0x20, 0x40, 0x00, 0x00, 0x20, 0x80, 0x01, 0x00, 0x18,
+ 0x00, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/knight.bitmap b/gnu/games/chess/Xchess/knight.bitmap
new file mode 100644
index 000000000000..c5b1de1997f4
--- /dev/null
+++ b/gnu/games/chess/Xchess/knight.bitmap
@@ -0,0 +1,71 @@
+
+#define knight_width 80
+#define knight_height 80
+static char knight_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x38, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
+ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
+ 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xbf, 0xff,
+ 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0xfe, 0x0f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xf8, 0xff, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0x0f, 0xfc, 0xe3, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf0, 0xe1, 0xf3, 0xcf, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfd,
+ 0xff, 0x1f, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0xfe, 0x7f,
+ 0xfe, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xff, 0x1f, 0xfe, 0xff, 0xfc, 0x07,
+ 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xf1, 0x7f, 0x00, 0x00,
+ 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xe7, 0x1f, 0x00, 0x00, 0x00, 0xe0,
+ 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0x03, 0x00, 0x00, 0xf0, 0xff, 0xff,
+ 0xff, 0xff, 0x9f, 0x3f, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff,
+ 0x3f, 0xff, 0x07, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe,
+ 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfc, 0x07, 0x00,
+ 0x00, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xfd, 0x01, 0x00, 0x00, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0xff, 0xfb, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0xff, 0xbf, 0xff, 0xf3, 0x03, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x9f,
+ 0xff, 0xf7, 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, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
+ 0xf9, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xf9, 0x1f,
+ 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xf1, 0x01, 0x00, 0x00,
+ 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xf1, 0x3f, 0x00, 0x00, 0x00, 0xf0,
+ 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
+ 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff,
+ 0xf3, 0x01, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f,
+ 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00,
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0x00, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xf3, 0x01, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f,
+ 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00,
+ 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0xe0, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xf3, 0x01, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f,
+ 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00,
+ 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0xfc, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xf3, 0x01, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xf3, 0x3f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xf3, 0x01, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/knight_mask.bitmap b/gnu/games/chess/Xchess/knight_mask.bitmap
new file mode 100644
index 000000000000..97d288c60554
--- /dev/null
+++ b/gnu/games/chess/Xchess/knight_mask.bitmap
@@ -0,0 +1,71 @@
+
+#define knight_mask_width 80
+#define knight_mask_height 80
+static char knight_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x0f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfc, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
+ 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x7f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf0, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
+ 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00,
+ 0xfc, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
+ 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xf8,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xfc, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x0f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00,
+ 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x80, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xc0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x7f, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x7f, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xf8, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xf8, 0xff, 0xff, 0xff,
+ 0xc7, 0xff, 0xff, 0xff, 0xff, 0x01, 0xfc, 0xff, 0xff, 0xff, 0xc1, 0xff,
+ 0xff, 0xff, 0xff, 0x03, 0xfc, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0xff,
+ 0xff, 0x0f, 0xfc, 0xff, 0xff, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0xfc, 0xff, 0x7f, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xfc, 0xdf,
+ 0x3f, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xfc, 0xef, 0x1f, 0x00,
+ 0xf8, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xf7, 0x0f, 0x00, 0xfc, 0xff,
+ 0xff, 0xff, 0xff, 0x1f, 0xf8, 0xfb, 0x07, 0x00, 0xfc, 0xff, 0xff, 0xff,
+ 0xff, 0x1f, 0xf0, 0xf9, 0x03, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x1f,
+ 0x00, 0xf8, 0x01, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0xf8,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x80,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x1f, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
+ 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
+ 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xfc,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
+ 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
+ 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xc0, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
+ 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf8, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
+ 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/knight_outline.bitmap b/gnu/games/chess/Xchess/knight_outline.bitmap
new file mode 100644
index 000000000000..a1ab938b773f
--- /dev/null
+++ b/gnu/games/chess/Xchess/knight_outline.bitmap
@@ -0,0 +1,71 @@
+
+#define knight_outline_width 80
+#define knight_outline_height 80
+static char knight_outline_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x38, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
+ 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf9, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x0f, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x20, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x80,
+ 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xf0, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x30, 0x58, 0x07, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x18, 0x4c,
+ 0x04, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x78, 0x07, 0x00,
+ 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x23, 0xe0, 0x01, 0x00, 0x00, 0x04,
+ 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00,
+ 0x00, 0xc0, 0x08, 0x00, 0x00, 0x40, 0x00, 0x10, 0x00, 0x00, 0x00, 0x60,
+ 0x04, 0x00, 0x00, 0x40, 0x00, 0xf0, 0x03, 0x00, 0x00, 0x30, 0x02, 0x00,
+ 0x00, 0x60, 0x00, 0x20, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x20,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x80,
+ 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x20, 0x00, 0x80, 0x07, 0x00,
+ 0x00, 0x26, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x13,
+ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x1f, 0x00, 0x00, 0x09, 0x40, 0x00,
+ 0x00, 0x18, 0x08, 0x00, 0x02, 0x00, 0x80, 0x05, 0xc0, 0x00, 0x00, 0x0c,
+ 0x0c, 0x00, 0x3e, 0x00, 0x80, 0x00, 0x80, 0x00, 0xc0, 0x03, 0x06, 0x00,
+ 0x04, 0x00, 0xc0, 0x00, 0x80, 0x01, 0x70, 0x01, 0xc3, 0x00, 0x7c, 0x00,
+ 0x60, 0x00, 0x00, 0x03, 0x1e, 0x81, 0x41, 0x00, 0x04, 0x00, 0x20, 0x00,
+ 0x00, 0xce, 0x83, 0x61, 0x60, 0x00, 0xfc, 0x00, 0x30, 0x00, 0x80, 0x7f,
+ 0x80, 0x1c, 0x30, 0x00, 0x08, 0x00, 0x10, 0xe0, 0xc1, 0x00, 0x80, 0x07,
+ 0x10, 0x00, 0xf8, 0x01, 0x18, 0x30, 0x61, 0x00, 0x80, 0x00, 0x08, 0x00,
+ 0x10, 0x00, 0x08, 0x98, 0x31, 0x00, 0xc0, 0x00, 0x0c, 0x00, 0xf0, 0x07,
+ 0x08, 0x8c, 0x18, 0x00, 0x40, 0x00, 0x03, 0x00, 0x20, 0x00, 0x18, 0x86,
+ 0x0c, 0x00, 0x60, 0xc0, 0x01, 0x00, 0xe0, 0x07, 0x10, 0xc3, 0x06, 0x00,
+ 0x30, 0x30, 0x00, 0x00, 0x20, 0x00, 0xf0, 0x61, 0x02, 0x00, 0x10, 0x1e,
+ 0x00, 0x00, 0xe0, 0x0f, 0x60, 0x30, 0x02, 0x00, 0x98, 0x03, 0x00, 0x00,
+ 0x40, 0x00, 0x00, 0x10, 0x02, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xc0, 0x0f,
+ 0x00, 0xb0, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xc0,
+ 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f,
+ 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x30,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
+ 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
+ 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
+ 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/knight_small.bitmap b/gnu/games/chess/Xchess/knight_small.bitmap
new file mode 100644
index 000000000000..77c74517f0f6
--- /dev/null
+++ b/gnu/games/chess/Xchess/knight_small.bitmap
@@ -0,0 +1,15 @@
+
+#define knight_small_width 32
+#define knight_small_height 32
+static char knight_small_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80, 0x00, 0x00, 0xee, 0x7f, 0x02,
+ 0x00, 0xfe, 0x7f, 0x01, 0x00, 0xff, 0xff, 0x04, 0x00, 0xff, 0xff, 0x02,
+ 0x80, 0xff, 0xff, 0x09, 0xc0, 0xfc, 0xff, 0x07, 0xe0, 0xfc, 0xff, 0x11,
+ 0xe0, 0xff, 0xff, 0x0d, 0xe0, 0xff, 0xff, 0x03, 0xf0, 0xff, 0xff, 0x3f,
+ 0xf0, 0xff, 0xff, 0x03, 0xf0, 0xff, 0xff, 0x7f, 0xf8, 0xff, 0xff, 0x07,
+ 0xfc, 0xc7, 0xff, 0x7f, 0xfe, 0xc1, 0xff, 0x07, 0xfa, 0xc1, 0xff, 0x7f,
+ 0xce, 0xc0, 0xff, 0x07, 0x6c, 0xc0, 0xff, 0x7f, 0x28, 0xe0, 0xff, 0x07,
+ 0x00, 0xe0, 0xff, 0x7f, 0x00, 0xe0, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0x7f,
+ 0x00, 0xf0, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0x7f, 0x00, 0xf8, 0xff, 0x0f,
+ 0x00, 0xf8, 0xff, 0x7f, 0x00, 0xfc, 0xff, 0x0f, 0x00, 0xff, 0xff, 0x7f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/knight_small_outline.bitmap b/gnu/games/chess/Xchess/knight_small_outline.bitmap
new file mode 100644
index 000000000000..c0e738c6db4c
--- /dev/null
+++ b/gnu/games/chess/Xchess/knight_small_outline.bitmap
@@ -0,0 +1,15 @@
+
+#define knight_small_outline_width 32
+#define knight_small_outline_height 32
+static char knight_small_outline_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80, 0x00, 0x00, 0xee, 0x7f, 0x02,
+ 0x00, 0x3a, 0x40, 0x01, 0x00, 0x03, 0xc0, 0x04, 0x00, 0x01, 0x80, 0x02,
+ 0x80, 0x01, 0x80, 0x09, 0xc0, 0x0c, 0x00, 0x07, 0x60, 0x0c, 0x00, 0x11,
+ 0x20, 0x00, 0x00, 0x0d, 0x20, 0x00, 0x00, 0x03, 0x30, 0x00, 0x00, 0x3e,
+ 0x10, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x7e, 0x18, 0x7c, 0x00, 0x04,
+ 0x0c, 0x47, 0x00, 0x7c, 0x06, 0x41, 0x00, 0x04, 0xf2, 0x41, 0x00, 0x7c,
+ 0xde, 0x40, 0x00, 0x04, 0x6c, 0x40, 0x00, 0x7c, 0x28, 0x60, 0x00, 0x04,
+ 0x00, 0x20, 0x00, 0x7c, 0x00, 0x20, 0x00, 0x08, 0x00, 0x30, 0x00, 0x78,
+ 0x00, 0x10, 0x00, 0x08, 0x00, 0x10, 0x00, 0x78, 0x00, 0x18, 0x00, 0x08,
+ 0x00, 0x08, 0x00, 0x78, 0x00, 0x0c, 0x00, 0x08, 0x00, 0xff, 0xff, 0x7f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/message.c b/gnu/games/chess/Xchess/message.c
new file mode 100644
index 000000000000..8b85e9c77f83
--- /dev/null
+++ b/gnu/games/chess/Xchess/message.c
@@ -0,0 +1,101 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.4 $ on $Date: 86/11/26 12:10:22 $
+ * $Source: /users/faustus/xchess/RCS/message.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ * Do stuff with the message window. Font 0 is the normal font, font 1
+ * is large, and font 2 is normal red.
+ */
+
+#include "xchess.h"
+
+#define MESSAGE_HEADER "\n1 XChess Messages0\n"
+
+void
+message_init(win)
+ windata *win;
+{
+ TxtGrab(win->display, win->messagewin, "xchess", win->medium,
+ win->textback.pixel, win->textcolor.pixel,
+ win->cursorcolor.pixel);
+ TxtAddFont(win->display, win->messagewin, 1, win->large, win->textcolor.pixel);
+ TxtAddFont(win->display, win->messagewin, 2, win->medium, win->errortext.pixel);
+ TxtAddFont(win->display, win->messagewin, 3, win->medium, win->playertext.pixel);
+
+ TxtWriteStr(win->display, win->messagewin, MESSAGE_HEADER);
+ return;
+}
+
+void
+message_add(win, string, err)
+ windata *win;
+ char *string;
+ bool err;
+{
+ if (err) {
+ TxtWriteStr(win->display, win->messagewin, "2");
+ TxtWriteStr(win->display, win->messagewin, string);
+ TxtWriteStr(win->display, win->messagewin, "0");
+ XBell(win->display, 50);
+ } else
+ TxtWriteStr(win->display, win->messagewin, string);
+
+ XSync(win->display, 0);
+ return;
+}
+
+void
+message_send(win, event)
+ windata *win;
+ XEvent *event;
+{
+ XKeyEvent *ev = &event->xkey;
+ KeySym keysym;
+ windata *ow = (win == win1) ? win2 : win1;
+ char buf[BSIZE], *s;
+ int i;
+
+ i = XLookupString(ev, buf, sizeof(buf) - 1, &keysym, &s);
+ buf[i] = '\0';
+ for (s = buf; *s; s++)
+ if (*s == '\r')
+ *s = '\n';
+ else if (*s == '\177')
+ *s = '';
+
+ TxtWriteStr(win->display, win->messagewin, "3");
+ TxtWriteStr(win->display, win->messagewin, buf);
+ TxtWriteStr(win->display, win->messagewin, "0");
+ XSync(win->display, 0);
+ if (ow) {
+ TxtWriteStr(ow->display, ow->messagewin, "3");
+ TxtWriteStr(ow->display, ow->messagewin, buf);
+ TxtWriteStr(ow->display, ow->messagewin, "0");
+ XSync(ow->display, 0);
+ }
+ return;
+}
+
diff --git a/gnu/games/chess/Xchess/parse.c b/gnu/games/chess/Xchess/parse.c
new file mode 100644
index 000000000000..c66cc38bdbfe
--- /dev/null
+++ b/gnu/games/chess/Xchess/parse.c
@@ -0,0 +1,386 @@
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.2 $ on $Date: 86/11/23 17:17:59 $
+ * $Source: /users/faustus/xchess/RCS/parse.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ * Parse a sequence of chess moves...
+ */
+
+#include "xchess.h"
+
+bool loading_flag = false;
+bool loading_paused = false;
+
+static char *line;
+
+/* Load a record file in. This returns a number of things -- the board, the
+ * list of moves, and whose turn it is.
+ */
+
+void
+load_game(file)
+ char *file;
+{
+ FILE *fp;
+ char buf[BSIZE];
+ bool eflag;
+ move *m;
+ board *tmpboard = alloc(board);
+
+ if (eq(file, "xchess.game") && saveflag) {
+ message_add(win1,
+ "Oops, I just overwrote the\nfile xchess.game...\n",
+ true);
+ message_add(win1, "I hope you had another copy.\n", true);
+ return;
+ }
+ if (!(fp = fopen(file, "r"))) {
+ perror(file);
+ return;
+ }
+
+ /* Get a few lines... */
+ fgets(buf, BSIZE, fp);
+ message_add(win1, buf, false);
+ if (!oneboard)
+ message_add(win2, buf, false);
+
+ fgets(buf, BSIZE, fp);
+ message_add(win1, buf, false);
+ if (!oneboard)
+ message_add(win2, buf, false);
+
+ fgets(buf, BSIZE, fp);
+ if (eq(buf, "\tenglish\n"))
+ eflag = true;
+ else if (eq(buf, "\talgebraic\n"))
+ eflag = false;
+ else {
+ fprintf(stderr, "Can't decide whether this is english...\n");
+ return;
+ }
+
+ board_init(tmpboard);
+ line = NULL;
+ m = parse_file(fp, tmpboard, eflag);
+ tfree(tmpboard);
+
+ /* Now apply these moves to the board we were given... */
+ loading_flag = true;
+ while (m) {
+ if (!quickflag)
+ XSync(win1->display, 0);
+ win_process(true);
+ if (!quickflag)
+ sleep(1);
+ if (!loading_paused) {
+ prog_move(m);
+ m = m->next;
+ }
+ }
+ loading_flag = false;
+ if (line)
+ message_add(win1, line, false);
+
+ while (fgets(buf, BSIZE, fp))
+ message_add(win1, buf, false);
+
+ fclose(fp);
+
+ return;
+}
+
+/* Given a starting position (usually the beginning board configuration),
+ * read in a file of moves.
+ */
+
+move *
+parse_file(fp, b, english)
+ FILE *fp;
+ board *b;
+ bool english;
+{
+ move *mvs = NULL, *end = NULL;
+ char buf[BSIZE], *s, *t;
+
+ while (fgets(buf, BSIZE, fp)) {
+ if (*buf == '#')
+ continue;
+ s = buf;
+
+ /* The move number... */
+ if (!(t = gettok(&s)))
+ break;
+ if (!isdigit(*t)) {
+ line = copy(buf);
+ break;
+ }
+
+ if (!(t = gettok(&s)))
+ break;
+ if (end)
+ end = end->next = (english ? parse_move(b, t, WHITE) :
+ parse_imove(b, t, WHITE));
+ else
+ mvs = end = (english ? parse_move(b, t, WHITE) :
+ parse_imove(b, t, WHITE));
+ if (!end) {
+ fprintf(stderr, "Can't parse %s\n", buf);
+ return (NULL);
+ }
+ board_move(b, end);
+
+ if (!(t = gettok(&s)))
+ break;
+ if (end)
+ end = end->next = (english ? parse_move(b, t, BLACK) :
+ parse_imove(b, t, BLACK));
+ else
+ mvs = end = (english ? parse_move(b, t, BLACK) :
+ parse_imove(b, t, BLACK));
+ if (!end) {
+ fprintf(stderr, "Can't parse %s\n", buf);
+ return (NULL);
+ }
+ board_move(b, end);
+ }
+
+ return (mvs);
+}
+
+/* Parse a move. The move format accepted is as follows -
+ * move: spec-spec
+ * capture: specxspec
+ * kcastle: 2 o's
+ * qcastle: 3 o's
+ * A spec is either piece/pos, piece, or just pos. A pos consists of a column
+ * name followed by a row number. If the column name is kr, kn, kb, k, q,
+ * qb, qn, or qr, then the row number is according to the english system,
+ * or if it is a-h then it is according to the international system.
+ *
+ *** As of now the spec must include the position.
+ */
+
+move *
+parse_move(b, str, w)
+ board *b;
+ char *str;
+ color w;
+{
+ move *m = alloc(move);
+ char *s;
+ char spec1[16], spec2[16];
+ int i, j;
+
+if (debug) fprintf(stderr, "parsing %s\n", str);
+
+ /* Check for castles. */
+ for (s = str, i = 0; *s; s++)
+ if ((*s == 'o') || (*s == 'O'))
+ i++;
+ if (i == 2) {
+ m->type = KCASTLE;
+ m->piece.type = KING;
+ m->piece.color = w;
+ return (m);
+ } else if (i == 3) {
+ m->type = QCASTLE;
+ m->piece.type = KING;
+ m->piece.color = w;
+ return (m);
+ }
+ if (index(str, '-'))
+ m->type = MOVE;
+ else if (index(str, 'x'))
+ m->type = CAPTURE;
+ else
+ return (NULL);
+ for (i = 0; str[i]; i++)
+ if ((str[i] == 'x') || (str[i] == '-'))
+ break;
+ else
+ spec1[i] = str[i];
+ spec1[i] = '\0';
+ for (i++, j = 0; str[i]; i++, j++)
+ if ((str[i] == 'x') || (str[i] == '-'))
+ break;
+ else
+ spec2[j] = str[i];
+ spec2[j] = '\0';
+
+ /* Now decode the specifications. */
+ s = spec1;
+ switch (*s) {
+ case 'p': case 'P':
+ m->piece.type = PAWN; break;
+ case 'r': case 'R':
+ m->piece.type = ROOK; break;
+ case 'n': case 'N':
+ m->piece.type = KNIGHT; break;
+ case 'b': case 'B':
+ m->piece.type = BISHOP; break;
+ case 'q': case 'Q':
+ m->piece.type = QUEEN; break;
+ case 'k': case 'K':
+ m->piece.type = KING; break;
+ default:
+ return (NULL);
+ }
+ m->piece.color = w;
+ s += 2;
+
+ /* Now get the {q,k}{,b,n,r}n string... */
+ if ((s[0] == 'q') && (s[1] == 'r'))
+ m->fromx = 0, s += 2;
+ else if ((s[0] == 'q') && (s[1] == 'n'))
+ m->fromx = 1, s += 2;
+ else if ((s[0] == 'q') && (s[1] == 'b'))
+ m->fromx = 2, s += 2;
+ else if ((s[0] == 'q') && isdigit(s[1]))
+ m->fromx = 3, s += 1;
+ else if ((s[0] == 'k') && isdigit(s[1]))
+ m->fromx = 4, s += 1;
+ else if ((s[0] == 'k') && (s[1] == 'b'))
+ m->fromx = 5, s += 2;
+ else if ((s[0] == 'k') && (s[1] == 'n'))
+ m->fromx = 6, s += 2;
+ else if ((s[0] == 'k') && (s[1] == 'r'))
+ m->fromx = 7, s += 2;
+ m->fromy = ((w == WHITE) ? (SIZE - atoi(s)) : (atoi(s) - 1));
+
+ if ((b->square[m->fromy][m->fromx].color != w) ||
+ (b->square[m->fromy][m->fromx].type != m->piece.type)) {
+ fprintf(stderr, "Error: bad stuff\n");
+ return (NULL);
+ }
+
+ s = spec2;
+ if (m->type == CAPTURE) {
+ switch (*s) {
+ case 'p': case 'P':
+ m->taken.type = PAWN; break;
+ case 'r': case 'R':
+ m->taken.type = ROOK; break;
+ case 'n': case 'N':
+ m->taken.type = KNIGHT; break;
+ case 'b': case 'B':
+ m->taken.type = BISHOP; break;
+ case 'q': case 'Q':
+ m->taken.type = QUEEN; break;
+ case 'k': case 'K':
+ m->taken.type = KING; break;
+ default:
+ return (NULL);
+ }
+ m->taken.color = ((w == WHITE) ? BLACK : WHITE);
+ s += 2;
+ }
+
+ /* Now get the {q,k}{,b,n,r}n string... */
+ if ((s[0] == 'q') && (s[1] == 'r'))
+ m->tox = 0, s += 2;
+ else if ((s[0] == 'q') && (s[1] == 'n'))
+ m->tox = 1, s += 2;
+ else if ((s[0] == 'q') && (s[1] == 'b'))
+ m->tox = 2, s += 2;
+ else if ((s[0] == 'q') && isdigit(s[1]))
+ m->tox = 3, s += 1;
+ else if ((s[0] == 'k') && isdigit(s[1]))
+ m->tox = 4, s += 1;
+ else if ((s[0] == 'k') && (s[1] == 'b'))
+ m->tox = 5, s += 2;
+ else if ((s[0] == 'k') && (s[1] == 'n'))
+ m->tox = 6, s += 2;
+ else if ((s[0] == 'k') && (s[1] == 'r'))
+ m->tox = 7, s += 2;
+ m->toy = ((w == WHITE) ? (SIZE - atoi(s)) : (atoi(s) - 1));
+
+ if ((m->type == CAPTURE) && ((b->square[m->toy][m->tox].color !=
+ m->taken.color) || (b->square[m->toy][m->tox].type !=
+ m->taken.type))) {
+ fprintf(stderr, "Error: bad stuff\n");
+ return (NULL);
+ }
+
+ return (m);
+}
+
+/* Parse an algebraic notation move. This is a lot easier... */
+
+move *
+parse_imove(b, buf, w)
+ board *b;
+ char *buf;
+ color w;
+{
+ char *s;
+ move *m = alloc(move);
+ int n;
+
+if (debug) fprintf(stderr, "(alg) parsing %s\n", buf);
+
+ for (s = buf, n = 0; *s; s++)
+ if ((*s == 'o') || (*s == 'O'))
+ n++;
+ s = buf;
+
+ if (n == 2)
+ m->type = KCASTLE;
+ else if (n == 3)
+ m->type = QCASTLE;
+ else {
+ m->fromx = *s++ - 'a';
+ m->fromy = SIZE - (*s++ - '0');
+ m->tox = *s++ - 'a';
+ m->toy = SIZE - (*s++ - '0');
+ m->piece = b->square[m->fromy][m->fromx];
+ m->taken = b->square[m->toy][m->tox];
+ if (m->taken.color == NONE)
+ m->type = MOVE;
+ else
+ m->type = CAPTURE;
+ /* for pawns we must account for en passant */
+ if (m->piece.type == PAWN) {
+ if (m->type == MOVE && m->fromx != m->tox) {
+ m->enpassant = 1;
+ m->type = CAPTURE;
+ }
+ }
+ }
+
+ if (m->piece.color != w) {
+ fprintf(stderr, "Error: parse_imove: piece of wrong color!\n");
+ return (NULL);
+ }
+ if ((m->piece.type == KING) && (m->fromy == m->toy) && (m->fromx == 4)
+ && (m->tox == 6))
+ m->type = KCASTLE;
+ else if ((m->piece.type == KING) && (m->fromy == m->toy) &&
+ (m->fromx == 4) && (m->tox == 2))
+ m->type = QCASTLE;
+
+ return (m);
+}
+
diff --git a/gnu/games/chess/Xchess/pawn.bitmap b/gnu/games/chess/Xchess/pawn.bitmap
new file mode 100644
index 000000000000..5c3ff76dbf68
--- /dev/null
+++ b/gnu/games/chess/Xchess/pawn.bitmap
@@ -0,0 +1,71 @@
+
+#define pawn_width 80
+#define pawn_height 80
+static char pawn_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf8, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
+ 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf8, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff,
+ 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff,
+ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
+ 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
+ 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0,
+ 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff,
+ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
+ 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff,
+ 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x03, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00,
+ 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00,
+ 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xfe, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x1f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/pawn_mask.bitmap b/gnu/games/chess/Xchess/pawn_mask.bitmap
new file mode 100644
index 000000000000..724875c59972
--- /dev/null
+++ b/gnu/games/chess/Xchess/pawn_mask.bitmap
@@ -0,0 +1,71 @@
+
+#define pawn_mask_width 80
+#define pawn_mask_height 80
+static char pawn_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff,
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
+ 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff,
+ 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff,
+ 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
+ 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
+ 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf0, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
+ 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
+ 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
+ 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff,
+ 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfc, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
+ 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
+ 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff,
+ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x0f,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xf0, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x0f, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x80, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x3f, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x3f, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
+ 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/pawn_outline.bitmap b/gnu/games/chess/Xchess/pawn_outline.bitmap
new file mode 100644
index 000000000000..0c4a3a13229a
--- /dev/null
+++ b/gnu/games/chess/Xchess/pawn_outline.bitmap
@@ -0,0 +1,71 @@
+
+#define pawn_outline_width 80
+#define pawn_outline_height 80
+static char pawn_outline_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x70,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x18, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x80, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x30, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
+ 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00,
+ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00,
+ 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x20, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
+ 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x40, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
+ 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x30, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00,
+ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0xff, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x78, 0xc0, 0x81, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x07, 0xc0, 0x7f, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
+ 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x18, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/pawn_small.bitmap b/gnu/games/chess/Xchess/pawn_small.bitmap
new file mode 100644
index 000000000000..88ff7bbcd16f
--- /dev/null
+++ b/gnu/games/chess/Xchess/pawn_small.bitmap
@@ -0,0 +1,15 @@
+
+#define pawn_small_width 32
+#define pawn_small_height 32
+static char pawn_small_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xf0, 0x0f, 0x00,
+ 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00,
+ 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf0, 0x0f, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x80, 0xff, 0xff, 0x01,
+ 0x80, 0xff, 0xff, 0x01, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xf0, 0x0f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xfc, 0x3f, 0x00,
+ 0x00, 0xff, 0xff, 0x00, 0xe0, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0x0f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/pawn_small_outline.bitmap b/gnu/games/chess/Xchess/pawn_small_outline.bitmap
new file mode 100644
index 000000000000..e860f43f3d50
--- /dev/null
+++ b/gnu/games/chess/Xchess/pawn_small_outline.bitmap
@@ -0,0 +1,15 @@
+
+#define pawn_small_outline_width 32
+#define pawn_small_outline_height 32
+static char pawn_small_outline_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x30, 0x0c, 0x00,
+ 0x00, 0x18, 0x18, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x10, 0x00,
+ 0x00, 0x08, 0x10, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x30, 0x0c, 0x00,
+ 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, 0x80, 0x3f, 0xfc, 0x01,
+ 0x80, 0x3f, 0xfc, 0x01, 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00,
+ 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00,
+ 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00,
+ 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00, 0x00, 0x20, 0x04, 0x00,
+ 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x0c, 0x30, 0x00,
+ 0x00, 0x07, 0xe0, 0x00, 0xe0, 0x01, 0x80, 0x07, 0xf0, 0xff, 0xff, 0x0f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/popup.c b/gnu/games/chess/Xchess/popup.c
new file mode 100644
index 000000000000..2e19ee5b4c35
--- /dev/null
+++ b/gnu/games/chess/Xchess/popup.c
@@ -0,0 +1,112 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.2 $ on $Date: 86/11/26 12:10:38 $
+ * $Source: /users/faustus/xchess/RCS/popup.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * faustus@cad.berkeley.edu, ucbvax!faustus
+ * Permission is granted to modify and re-distribute this code in any manner
+ * as long as this notice is preserved. All standard disclaimers apply.
+ *
+ * A simple pop-up menu system.
+ */
+
+#include "xchess.h"
+
+/* Open a small window with some text in it and two buttons -- yes and no.
+ * Use black and white pixel, and the medium font.
+ */
+
+bool
+pop_question(win, text)
+ windata *win;
+ char *text;
+{
+ char *s, *t;
+ int nlines = 1, ncols = 0, i = 0, j;
+ int x, y;
+ Window w;
+ bool ch;
+ XEvent ev;
+
+ for (s = text; *s; s++) {
+ if ((*s == '\n') && s[1])
+ nlines++;
+ if ((*s == '\n') || !s[1]) {
+ if (i > ncols)
+ ncols = i;
+ i = 0;
+ } else
+ i++;
+ }
+
+ if (ncols < 12)
+ ncols = 12;
+ nlines += 4;
+ ncols += 4;
+
+ x = (BASE_WIDTH - ncols * win->medium->max_bounds.width) / 2;
+ y = (BASE_HEIGHT - nlines * win->medium->max_bounds.ascent) / 2;
+
+ w = XCreateSimpleWindow(win->display, win->basewin,
+ x, y, ncols * win->medium->max_bounds.width,
+ nlines * win->medium->ascent,
+ BORDER_WIDTH, win->border.pixel,
+ win->textback.pixel);
+ XMapRaised(win->display, w);
+ XSetFont(win->display, DefaultGC(win->display, 0),
+ win->medium->fid);
+
+ for (i = 0, s = text; i < nlines - 4; i++) {
+ for (t = s, j = 0; *t && (*t != '\n'); t++, j++)
+ ;
+ XDrawString(win->display, w, DefaultGC(win->display, 0),
+ (ncols - j) / 2 * win->medium->max_bounds.width,
+ (i + 1) * win->medium->ascent,
+ s, j);
+ s = t + 1;
+ }
+ XDrawString(win->display, w, DefaultGC(win->display, 0),
+ (ncols - 8) * win->medium->max_bounds.width / 4,
+ (nlines - 2) * win->medium->ascent,
+ "YES", 3);
+ XDrawString(win->display, w, DefaultGC(win->display, 0),
+ (ncols - 4) * win->medium->max_bounds.width * 3 / 4,
+ (nlines - 2) * win->medium->ascent,
+ "NO", 2);
+
+ XSync(win->display, 0);
+ XSelectInput(win->display, w, ButtonPressMask);
+ XWindowEvent(win->display, w, ButtonPressMask, &ev);
+ x = ev.xkey.x;
+ y = ev.xkey.y;
+
+ if (x > ncols * win->medium->max_bounds.width / 2)
+ ch = false;
+ else
+ ch = true;
+
+ XDestroyWindow(win->display, w);
+ XSync(win->display, 0);
+ return (ch);
+}
+
diff --git a/gnu/games/chess/Xchess/program.c b/gnu/games/chess/Xchess/program.c
new file mode 100644
index 000000000000..876f29cb466c
--- /dev/null
+++ b/gnu/games/chess/Xchess/program.c
@@ -0,0 +1,200 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.2 $ on $Date: 86/11/23 17:18:10 $
+ * $Source: /users/faustus/xchess/RCS/program.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ * The interface to whichever chess playing program we are using...
+ */
+
+#include "xchess.h"
+#include <signal.h>
+#include <sys/time.h>
+
+static int pid;
+static FILE *from;
+static FILE *to;
+static bool easy = 1;
+
+bool
+program_init(name)
+ char *name;
+{
+ int toprog[2], fromprog[2];
+ char buf[BSIZE];
+ char time[10];
+ char moves[10];
+
+ pipe(toprog);
+ pipe(fromprog);
+
+ if (!(pid = fork())) {
+ /* Start up the program. */
+ dup2(toprog[0], 0);
+ dup2(fromprog[1], 1);
+ close(toprog[0]);
+ close(toprog[1]);
+ close(fromprog[0]);
+ close(fromprog[1]);
+ sprintf (time, "%d", timeunit/60);
+ sprintf (moves, "%d", movesperunit);
+ if (proghost)
+ execl("/usr/ucb/rsh", "rsh", proghost, name,
+ moves, time,
+ (char *) NULL);
+ else
+ execl(name, name, moves, time, (char *) NULL);
+ perror(name);
+ exit(1);
+ }
+
+ close(toprog[0]);
+ close(fromprog[1]);
+
+ from = fdopen(fromprog[0], "r");
+ setbuf(from, NULL);
+ to = fdopen(toprog[1], "w");
+ setbuf(to, NULL);
+
+ /* Get the first line... */
+ fgets(buf, BSIZE, from);
+ if (debug)
+ fprintf(stderr, "program says %s", buf);
+ if (blackflag) {
+ fputs("switch\n", to);
+ fflush(to);
+ fgets(buf, BSIZE, from);
+ if (debug)
+ fprintf(stderr, "program says %s", buf);
+ message_add(win1, "GNU Chess playing white\n", false);
+ } else
+ message_add(win1, "GNU Chess playing black\n", false);
+
+ return (true);
+}
+
+void
+program_end()
+{
+ fclose(from);
+ fclose(to);
+ kill(pid, SIGTERM);
+ return;
+}
+
+void
+program_send(m)
+ move *m;
+{
+ char buf[BSIZE];
+
+ if ((m->type == MOVE) || (m->type == CAPTURE))
+ sprintf(buf, "%c%d%c%d\n", 'a' + m->fromx, SIZE - m->fromy,
+ 'a' + m->tox, SIZE - m->toy);
+ else if (m->type == KCASTLE)
+ strcpy(buf, (m->piece.color == WHITE) ? "e1g1\n" : "e8g8\n");
+ else if (m->type == QCASTLE)
+ strcpy(buf, (m->piece.color == WHITE) ? "e1c1\n" : "e8c8\n");
+
+ if (debug)
+ fprintf(stderr, "sending program %s", buf);
+ if (!easy)
+ kill (pid, SIGINT);
+
+ fputs(buf, to);
+ fflush(to);
+
+ /* One junk line... */
+ fgets(buf, BSIZE, from);
+ if (debug)
+ fprintf(stderr, "program says %s", buf);
+ return;
+}
+
+move *
+program_get()
+{
+ int rfd = (1 << fileno(from)), wfd = 0, xfd = 0;
+ static struct timeval notime = { 0, 0 };
+ char buf[BSIZE], *s;
+ move *m;
+ int i;
+
+ /* Do a poll... */
+
+ if (!(i = select(32, &rfd, &wfd, &xfd, &notime)) &&
+ !from->_cnt) { /* Bad stuff... */
+ if (debug)
+ fprintf(stderr, "poll: nothing\n");
+ return (NULL);
+ }
+ if (i == -1) {
+ perror("select");
+ return (NULL);
+ }
+
+ fgets(buf, BSIZE, from);
+ if (*buf == '\n' || *buf == '\0') {
+ message_add(win1, "program died", false);
+ return (NULL);
+ }
+
+ if (debug)
+ fprintf(stderr, "got from program %s", buf);
+
+ for (s = buf; !isalpha(*s); s++)
+ ;
+ m = parse_imove(chessboard, s, nexttomove);
+ if (m == NULL)
+ return (NULL);
+
+ if (!valid_move(m, chessboard)) {
+ fprintf(stderr, "Error: move %s is invalid!!\n", buf);
+ return (NULL);
+ }
+
+ /*
+ fgets(buf, BSIZE, from);
+ if (debug)
+ fprintf(stderr, "program says %s", buf);
+ */
+ message_add(win1, buf, false);
+ return (m);
+}
+
+void
+program_undo()
+{
+ fputs("undo\n", to);
+ return;
+}
+void
+program_easy (mode)
+ bool mode;
+
+{
+ fputs("easy\n", to);
+ easy = mode;
+}
diff --git a/gnu/games/chess/Xchess/queen.bitmap b/gnu/games/chess/Xchess/queen.bitmap
new file mode 100644
index 000000000000..ab3817a123a9
--- /dev/null
+++ b/gnu/games/chess/Xchess/queen.bitmap
@@ -0,0 +1,71 @@
+
+#define queen_width 80
+#define queen_height 80
+static char queen_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x80, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x80, 0x01, 0x00, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x80, 0x01, 0x80, 0x0f, 0x00, 0x00,
+ 0x00, 0x00, 0xf0, 0x01, 0xc0, 0x03, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0x00, 0xc0, 0x03, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
+ 0xc0, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0x03,
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0x03, 0x00, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0x03, 0x00, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0x01, 0xc0, 0x03, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x01, 0xc0, 0x03, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
+ 0xe0, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xe0, 0x07,
+ 0xc0, 0x03, 0x00, 0x00, 0x1c, 0x00, 0xc0, 0x03, 0xe0, 0x07, 0xc0, 0x03,
+ 0x00, 0x00, 0x3e, 0x00, 0xc0, 0x03, 0xe0, 0x07, 0xc0, 0x03, 0x00, 0x0e,
+ 0x3e, 0x00, 0xc0, 0x07, 0xe0, 0x07, 0xe0, 0x03, 0x00, 0x1f, 0x3e, 0x00,
+ 0x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0xff, 0x00, 0x00, 0xff,
+ 0xc1, 0xff, 0xf9, 0x9f, 0xff, 0x83, 0xff, 0x00, 0x00, 0xff, 0xc3, 0xff,
+ 0xf9, 0x9f, 0xff, 0xc3, 0xff, 0x00, 0x00, 0xff, 0xc3, 0xff, 0xf9, 0x9f,
+ 0xff, 0xe3, 0x7f, 0x00, 0x00, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xe3,
+ 0x7f, 0x00, 0x00, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x7f, 0x00,
+ 0x00, 0xfe, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x7f, 0x00, 0x00, 0xfe,
+ 0xdf, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x7f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
+ 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x01, 0x80,
+ 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf8, 0xff, 0x03, 0xfc, 0x3f, 0xc0, 0xff,
+ 0x1f, 0x00, 0x00, 0xf0, 0x01, 0xf8, 0x7f, 0xfe, 0x1f, 0x80, 0x1f, 0x00,
+ 0x00, 0x30, 0xfc, 0xff, 0x1f, 0xf8, 0xff, 0x3f, 0x0c, 0x00, 0x00, 0xe0,
+ 0xe7, 0xff, 0x07, 0xe0, 0xff, 0xe7, 0x07, 0x00, 0x00, 0xc0, 0x81, 0xff,
+ 0x1f, 0xf8, 0xff, 0x81, 0x03, 0x00, 0x00, 0x80, 0x00, 0xfe, 0x7f, 0xfe,
+ 0x7f, 0x00, 0x03, 0x00, 0x00, 0x80, 0x81, 0xff, 0xff, 0xff, 0xff, 0x81,
+ 0x01, 0x00, 0x00, 0x00, 0xe7, 0xff, 0x01, 0x80, 0xff, 0xe7, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x03, 0xfc, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x80,
+ 0x01, 0xf8, 0xff, 0xff, 0x1f, 0x80, 0x01, 0x00, 0x00, 0x80, 0xfc, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x01, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x01, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
+ 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xe0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/queen_mask.bitmap b/gnu/games/chess/Xchess/queen_mask.bitmap
new file mode 100644
index 000000000000..76a5904e8340
--- /dev/null
+++ b/gnu/games/chess/Xchess/queen_mask.bitmap
@@ -0,0 +1,71 @@
+
+#define queen_mask_width 80
+#define queen_mask_height 80
+static char queen_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x60, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01,
+ 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xc0, 0x03,
+ 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xc0, 0x03, 0xc0, 0x1f,
+ 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xe0, 0x07, 0xc0, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0xf8, 0x03, 0xe0, 0x07, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00,
+ 0xf8, 0x01, 0xe0, 0x07, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01,
+ 0xe0, 0x07, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0xe0, 0x07,
+ 0x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0, 0x7f, 0xf8, 0x1f,
+ 0xfc, 0x07, 0xf8, 0x03, 0xe0, 0x1f, 0xe0, 0x7f, 0xf8, 0x1f, 0xfe, 0x07,
+ 0xf8, 0x03, 0xe0, 0x3f, 0xe0, 0x7f, 0xf8, 0x1f, 0xfe, 0x07, 0xfc, 0x03,
+ 0xe0, 0x3f, 0xe0, 0xff, 0xf8, 0x1f, 0xfe, 0x07, 0xfe, 0x03, 0xc0, 0x7f,
+ 0xe0, 0xff, 0xfc, 0x3f, 0xff, 0x07, 0xfe, 0x03, 0xc0, 0xff, 0xe0, 0xff,
+ 0xfd, 0x3f, 0xff, 0x07, 0xff, 0x03, 0xc0, 0xff, 0xe1, 0xff, 0xfd, 0xff,
+ 0xff, 0x87, 0xff, 0x03, 0xc0, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0x87,
+ 0xff, 0x01, 0xc0, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0x01,
+ 0xc0, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0x01, 0x80, 0xff,
+ 0xef, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xe7, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xf7, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+ 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00,
+ 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x7f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
+ 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xf8,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xf0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x07, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
+ 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xc0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xc0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x03, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x07, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00,
+ 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/queen_outline.bitmap b/gnu/games/chess/Xchess/queen_outline.bitmap
new file mode 100644
index 000000000000..2527216b3966
--- /dev/null
+++ b/gnu/games/chess/Xchess/queen_outline.bitmap
@@ -0,0 +1,71 @@
+
+#define queen_outline_width 80
+#define queen_outline_height 80
+static char queen_outline_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x60, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x80, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x01, 0x80, 0x01, 0x00, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x80, 0x01, 0x80, 0x0d, 0x00, 0x00,
+ 0x00, 0x00, 0xb0, 0x01, 0xc0, 0x03, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0x00, 0x40, 0x02, 0x80, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
+ 0x40, 0x02, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x02,
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x02, 0x00, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x40, 0x02, 0x00, 0x03, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0x01, 0x40, 0x02, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x01, 0x40, 0x02, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01,
+ 0x60, 0x06, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x40, 0x03, 0x20, 0x04,
+ 0xc0, 0x02, 0x00, 0x00, 0x1c, 0x00, 0x40, 0x02, 0x20, 0x04, 0x40, 0x02,
+ 0x00, 0x00, 0x36, 0x00, 0x40, 0x02, 0x20, 0x04, 0x40, 0x02, 0x00, 0x0e,
+ 0x22, 0x00, 0x40, 0x06, 0x20, 0x04, 0x60, 0x02, 0x00, 0x1b, 0x36, 0x00,
+ 0x40, 0x04, 0x20, 0x04, 0x20, 0x02, 0x00, 0x11, 0x3c, 0x00, 0x40, 0x04,
+ 0x20, 0x04, 0x20, 0x02, 0x00, 0x1b, 0x70, 0x00, 0x40, 0x0c, 0x20, 0x04,
+ 0x30, 0x02, 0x00, 0x0e, 0x60, 0x00, 0x40, 0x08, 0x20, 0x04, 0x10, 0x02,
+ 0x00, 0x03, 0xe0, 0x00, 0x40, 0x08, 0x30, 0x0c, 0x10, 0x02, 0x80, 0x03,
+ 0xc0, 0x01, 0x40, 0x18, 0x10, 0x08, 0x18, 0x02, 0x80, 0x01, 0x40, 0x01,
+ 0x40, 0x10, 0x10, 0x08, 0x08, 0x02, 0xc0, 0x01, 0x40, 0x03, 0x40, 0x10,
+ 0x10, 0x08, 0x08, 0x02, 0x60, 0x01, 0x40, 0x06, 0x40, 0x10, 0x10, 0x08,
+ 0x08, 0x02, 0x20, 0x01, 0x40, 0x04, 0x40, 0x30, 0x10, 0x08, 0x0c, 0x02,
+ 0x30, 0x01, 0xc0, 0x0c, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x18, 0x01,
+ 0x80, 0x18, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x08, 0x01, 0x80, 0x10,
+ 0x40, 0x60, 0x10, 0x08, 0x06, 0x02, 0x8c, 0x01, 0x80, 0x30, 0x40, 0x40,
+ 0x18, 0x18, 0x02, 0x02, 0x84, 0x00, 0x80, 0x20, 0x40, 0x40, 0x08, 0x10,
+ 0x02, 0x02, 0x86, 0x00, 0x80, 0x60, 0x40, 0xc0, 0x08, 0x10, 0x03, 0x02,
+ 0x83, 0x00, 0x80, 0xc1, 0x40, 0x80, 0x08, 0x10, 0x01, 0x02, 0x81, 0x00,
+ 0x00, 0x81, 0x40, 0x80, 0x08, 0x10, 0x01, 0x82, 0x81, 0x00, 0x00, 0x81,
+ 0x41, 0x80, 0x09, 0x90, 0x01, 0x82, 0x80, 0x00, 0x00, 0x01, 0x43, 0x00,
+ 0x09, 0x90, 0x00, 0xc2, 0xc0, 0x00, 0x00, 0x01, 0x42, 0x00, 0x09, 0x90,
+ 0x00, 0x62, 0x40, 0x00, 0x00, 0x01, 0x46, 0x00, 0x0f, 0xf0, 0x00, 0x22,
+ 0x40, 0x00, 0x00, 0x03, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x32, 0x40, 0x00,
+ 0x00, 0x02, 0x48, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x40, 0x00, 0x00, 0x02,
+ 0x58, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x40, 0x00, 0x00, 0x02, 0x70, 0x00,
+ 0x00, 0x00, 0x00, 0x0e, 0x40, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x60, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00,
+ 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x0c, 0x00, 0x00, 0xfe, 0x7f,
+ 0x00, 0x00, 0x30, 0x00, 0x00, 0x18, 0x00, 0xfc, 0x03, 0xc0, 0x3f, 0x00,
+ 0x10, 0x00, 0x00, 0x10, 0xfe, 0x07, 0x80, 0x01, 0xe0, 0x7f, 0x18, 0x00,
+ 0x00, 0x30, 0x03, 0x00, 0xe0, 0x07, 0x00, 0xc0, 0x0c, 0x00, 0x00, 0x60,
+ 0x18, 0x00, 0xf8, 0x1f, 0x00, 0x18, 0x06, 0x00, 0x00, 0x40, 0x7e, 0x00,
+ 0xe0, 0x07, 0x00, 0x7e, 0x02, 0x00, 0x00, 0x40, 0xff, 0x01, 0x80, 0x01,
+ 0x80, 0xff, 0x02, 0x00, 0x00, 0x40, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e,
+ 0x02, 0x00, 0x00, 0xc0, 0x18, 0x00, 0xfe, 0x7f, 0x00, 0x18, 0x03, 0x00,
+ 0x00, 0x80, 0x00, 0xfc, 0x03, 0xc0, 0x3f, 0x00, 0x01, 0x00, 0x00, 0x80,
+ 0xfe, 0x07, 0x00, 0x00, 0xe0, 0x7f, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
+ 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x60,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0xe0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/queen_small.bitmap b/gnu/games/chess/Xchess/queen_small.bitmap
new file mode 100644
index 000000000000..d7ee50e9b820
--- /dev/null
+++ b/gnu/games/chess/Xchess/queen_small.bitmap
@@ -0,0 +1,15 @@
+
+#define queen_small_width 32
+#define queen_small_height 32
+static char queen_small_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00,
+ 0x80, 0x81, 0xc0, 0x00, 0x80, 0x81, 0xc0, 0x00, 0x00, 0xc1, 0x41, 0x00,
+ 0x00, 0xc1, 0x41, 0x00, 0x02, 0xc3, 0x61, 0x20, 0x06, 0xc3, 0x61, 0x30,
+ 0x04, 0xc3, 0x61, 0x10, 0x0c, 0xc3, 0x61, 0x18, 0x08, 0xc7, 0x71, 0x08,
+ 0x18, 0xc6, 0x31, 0x0c, 0x38, 0xc6, 0x31, 0x0e, 0x30, 0xce, 0x39, 0x06,
+ 0x70, 0xce, 0x39, 0x07, 0x60, 0xee, 0x3b, 0x03, 0xe0, 0xee, 0xbb, 0x03,
+ 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0x01,
+ 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0xff, 0x7f, 0x00,
+ 0x80, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/queen_small_outline.bitmap b/gnu/games/chess/Xchess/queen_small_outline.bitmap
new file mode 100644
index 000000000000..0b624b9587bc
--- /dev/null
+++ b/gnu/games/chess/Xchess/queen_small_outline.bitmap
@@ -0,0 +1,15 @@
+
+#define queen_small_outline_width 32
+#define queen_small_outline_height 32
+static char queen_small_outline_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00,
+ 0x80, 0x81, 0xc0, 0x00, 0x80, 0x81, 0xc0, 0x00, 0x00, 0xc1, 0x41, 0x00,
+ 0x00, 0x41, 0x41, 0x00, 0x02, 0x43, 0x61, 0x20, 0x06, 0x43, 0x61, 0x30,
+ 0x04, 0x43, 0x61, 0x10, 0x0c, 0x43, 0x61, 0x18, 0x08, 0x47, 0x71, 0x08,
+ 0x18, 0x46, 0x31, 0x0c, 0x38, 0x46, 0x31, 0x0e, 0x30, 0x4e, 0x39, 0x06,
+ 0x70, 0x4e, 0x29, 0x07, 0x60, 0x6a, 0x2b, 0x03, 0xe0, 0x2a, 0xab, 0x03,
+ 0xe0, 0x3b, 0xee, 0x03, 0x40, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x80, 0x01,
+ 0x80, 0xfc, 0x9f, 0x00, 0x80, 0x01, 0xc0, 0x00, 0x00, 0x01, 0x40, 0x00,
+ 0x80, 0xfd, 0xdf, 0x00, 0xf0, 0x00, 0x80, 0x07, 0xf0, 0xff, 0xff, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/record.c b/gnu/games/chess/Xchess/record.c
new file mode 100644
index 000000000000..d9459b3a64f0
--- /dev/null
+++ b/gnu/games/chess/Xchess/record.c
@@ -0,0 +1,315 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.4 $ on $Date: 86/11/23 17:18:20 $
+ * $Source: /users/faustus/xchess/RCS/record.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ * Deal with recording moves.
+ */
+
+#include "xchess.h"
+
+#undef smartass
+
+bool record_english = true;
+char *record_file = DEF_RECORD_FILE;
+int movenum = 0;
+bool saveflag = false;
+
+static char *colnames[] = { "qr", "qn", "qb", "q", "k", "kb", "kn", "kr" } ;
+static char *pcnames[] = { "P", "R", "N", "B", "Q", "K" } ;
+
+static char *movestring();
+static char *tstring();
+static FILE *backup;
+
+#define RECORD_HEADER "\n1 XChess Game Record0\n"
+
+void
+record_init(win)
+ windata *win;
+{
+ int i;
+
+ i = XTextWidth(win->medium, RECORD_HEADER,
+ sizeof(RECORD_HEADER) - 1);
+ i = (40 * win->small->max_bounds.width - i *
+ win->medium->max_bounds.width) /
+ win->medium->max_bounds.width / 2;
+ TxtGrab(win->display, win->recwin, "xchess", win->small, win->textback.pixel,
+ win->textcolor.pixel, win->cursorcolor.pixel);
+ TxtAddFont(win->display, win->recwin, 1, win->medium, win->textcolor.pixel);
+ for (; i > 0; i++)
+ TxtWriteStr(win->display, win->recwin, " ");
+ TxtWriteStr(win->display, win->recwin, RECORD_HEADER);
+
+ if (saveflag) {
+ if (!(backup = fopen(record_file, "w"))) {
+ perror(record_file);
+ saveflag = false;
+ } else {
+ fprintf(backup, "X Chess -- %s\n", datestring());
+ if (dispname2)
+ fprintf(backup, "\tWhite on %s, black on %s\n",
+ dispname1, dispname2);
+ else
+ fprintf(backup, "\tGame played on %s\n",
+ dispname1);
+ fprintf(backup, "\t%s\n", record_english ? "english" :
+ "algebraic");
+ fflush(backup);
+ }
+ }
+
+ movenum = 0;
+ return;
+}
+
+void
+record_reset()
+{
+ TxtWriteStr(win1->display, win1->recwin, "\n\n1 New Game0\n\n");
+ if (!oneboard) {
+ TxtWriteStr(win2->display, win2->recwin, "\n\n1 New Game0\n\n");
+ }
+ movenum = 0;
+ if (saveflag) {
+ fprintf(backup, "\n\nNew Game\n\n");
+ fflush(backup);
+ }
+ return;
+}
+
+void
+record_end(s)
+ char *s;
+{
+ char buf[BSIZE];
+
+ sprintf(buf, "\n%s\n", s);
+ TxtWriteStr(win1->display, win1->recwin, s);
+ if (!oneboard) {
+ TxtWriteStr(win2->display, win2->recwin, s);
+ }
+ if (saveflag) {
+ fprintf(backup, "\n%s\n", s);
+ fprintf(backup, "Time: white: %s, ", tstring(whiteseconds));
+ fprintf(backup, "black: %s\n", tstring(blackseconds));
+ fclose(backup);
+ }
+ return;
+}
+
+void
+record_save()
+{
+ move *m;
+ FILE *fp;
+ int i;
+ char *s;
+
+ if (!(fp = fopen(record_file, "w"))) {
+ perror(record_file);
+ return;
+ }
+ fprintf(fp, "X Chess -- %s\n", datestring());
+ if (dispname2)
+ fprintf(fp, "\tWhite on %s, black on %s\n",
+ dispname1, dispname2);
+ else
+ fprintf(fp, "\tGame played on %s\n", dispname1);
+ fprintf(fp, "\t%s\n", record_english ? "english" : "algebraic");
+
+ for (m = moves, i = 1; m; i++) {
+ s = movestring(m);
+ fprintf(fp, "%2d. %-16s ", i, s);
+ m = m->next;
+ if (m)
+ s = movestring(m);
+ else
+ s = "";
+ fprintf(fp, "%s\n", s);
+ if (m)
+ m = m->next;
+ }
+ fclose(fp);
+ return;
+}
+
+void
+record_move(m)
+ move *m;
+{
+ char *s, buf[BSIZE];
+
+ s = movestring(m);
+
+ if (m->piece.color == WHITE) {
+ movenum++;
+ sprintf(buf, "%2d. %-16s ", movenum, s);
+ } else {
+ sprintf(buf, "%s\n", s);
+ }
+ TxtWriteStr(win1->display, win1->recwin, buf);
+ if (!oneboard) {
+ TxtWriteStr(win2->display, win2->recwin, buf);
+ }
+ if (saveflag) {
+ fprintf(backup, "%s", buf);
+ fflush(backup);
+ }
+
+ return;
+}
+
+void
+record_back()
+{
+ extern move *lastmove;
+ move *m = lastmove;
+ char *s = movestring(m);
+ char buf[BSIZE];
+ long i;
+
+ if (m->piece.color == WHITE) {
+ sprintf(buf, "%2d. %-16s ", movenum, s);
+ } else {
+ sprintf(buf, "%s\n", s);
+ }
+ s = buf;
+ for (i = 0; *s != '\0'; i++)
+ *s++ = ''; /* control H, backspace */
+
+ TxtWriteStr(win1->display, win1->recwin, buf);
+ if (!oneboard) {
+ TxtWriteStr(win2->display, win2->recwin, buf);
+ }
+
+ if (nexttomove == BLACK)
+ movenum--;
+ if (saveflag) {
+ fseek(backup, -i, 1);
+ fflush(backup);
+ }
+
+ return;
+}
+
+static char *
+movestring(m)
+ move *m;
+{
+ int fy, ty;
+ static char buf[BSIZE];
+
+ if (!record_english || (m->piece.color == WHITE)) {
+ fy = SIZE - m->fromy;
+ ty = SIZE - m->toy;
+ } else {
+ fy = m->fromy + 1;
+ ty = m->toy + 1;
+ }
+
+ switch (m->type) {
+ case MOVE:
+ if (record_english)
+ sprintf(buf, "%s/%s%d-%s%d%s", pcnames[(int) m->piece.
+ type], colnames[m->fromx], fy,
+ colnames[m->tox], ty, m->check ? "+" :
+ "");
+ else
+ sprintf(buf, "%c%d%c%d", 'a' + m->fromx, fy, 'a' +
+ m->tox, ty);
+ break;
+ case CAPTURE:
+ if (record_english)
+ sprintf(buf, "%s/%s%dx%s/%s%d%s%s",
+ pcnames[(int) m->piece.type],
+ colnames[m->fromx], fy,
+ pcnames[(int) m->taken.type],
+ colnames[m->tox], ty,
+ m->enpassant ? "e.p." : "",
+ m->check ? "+" : "");
+ else
+ sprintf(buf, "%c%d%c%d", 'a' + m->fromx, fy, 'a' +
+ m->tox, ty);
+ break;
+
+ case KCASTLE:
+ if (record_english)
+ sprintf(buf, "O-O%s", m->check ? "ch" : "");
+ else if (m->piece.color == WHITE)
+ strcpy(buf, "e1g1");
+ else
+ strcpy(buf, "e8g8");
+ break;
+
+ case QCASTLE:
+ if (record_english)
+ sprintf(buf, "O-O-O%s", m->check ? "ch" : "");
+ else if (m->piece.color == WHITE)
+ strcpy(buf, "e1c1");
+ else
+ strcpy(buf, "e8c8");
+ break;
+
+ default:
+ sprintf(buf, "something strange");
+ break;
+ }
+ if ((m->piece.type == PAWN) && (((m->piece.color == BLACK) &&
+ (m->toy == 7)) || ((m->piece.color == WHITE) &&
+ (m->toy == 0))))
+ strcat(buf, "(Q)");
+
+#ifdef smartass
+ if (!(random() % 50))
+ strcat(buf, "?");
+ else if (!(random() % 50))
+ strcat(buf, "!");
+ else if (!(random() % 500))
+ strcat(buf, "???");
+ else if (!(random() % 500))
+ strcat(buf, "!!!");
+#endif smartass
+
+ return (buf);
+}
+
+static char *
+tstring(s)
+ int s;
+{
+ static char buf[64];
+
+ if (s > 3600)
+ sprintf(buf, "%dh %dm %ds", s / 3600, (s % 3600) / 60, s % 60);
+ else if (s > 60)
+ sprintf(buf, "%dm %ds", (s % 3600) / 60, s % 60);
+ else
+ sprintf(buf, "%ds", s);
+ return (buf);
+}
+
diff --git a/gnu/games/chess/Xchess/rook.bitmap b/gnu/games/chess/Xchess/rook.bitmap
new file mode 100644
index 000000000000..f274614eb9cb
--- /dev/null
+++ b/gnu/games/chess/Xchess/rook.bitmap
@@ -0,0 +1,71 @@
+
+#define rook_width 80
+#define rook_height 80
+static char rook_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0xf8, 0xff, 0x00, 0x3c,
+ 0x00, 0x00, 0x00, 0x80, 0xff, 0x01, 0xf8, 0xff, 0x00, 0xfc, 0x0f, 0x00,
+ 0x00, 0xc0, 0xff, 0x01, 0xf8, 0xff, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0xc0,
+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c0, 0x7f, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
+ 0xff, 0xfe, 0x07, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe,
+ 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
+ 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe,
+ 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0xff, 0xff, 0xfe, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
+ 0x0f, 0x80, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xe0, 0x3f,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
+ 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff,
+ 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0xff, 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
+ 0xfd, 0xff, 0xfd, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
+ 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd,
+ 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0xff, 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
+ 0xff, 0xfd, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xfd,
+ 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
+ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x07, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00,
+ 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x20, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/rook_mask.bitmap b/gnu/games/chess/Xchess/rook_mask.bitmap
new file mode 100644
index 000000000000..c04441655879
--- /dev/null
+++ b/gnu/games/chess/Xchess/rook_mask.bitmap
@@ -0,0 +1,71 @@
+
+#define rook_mask_width 80
+#define rook_mask_height 80
+static char rook_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfc, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03, 0xfc, 0xff,
+ 0x01, 0x7e, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x03, 0xfc, 0xff, 0x01, 0xfe,
+ 0x1f, 0x00, 0x00, 0xe0, 0xff, 0x03, 0xfc, 0xff, 0x01, 0xfe, 0x3f, 0x00,
+ 0x00, 0xe0, 0xff, 0x03, 0xfc, 0xff, 0x01, 0xfe, 0x3f, 0x00, 0x00, 0xe0,
+ 0xff, 0x03, 0xfc, 0xff, 0x1f, 0xfe, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0x83,
+ 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
+ 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x3f, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
+ 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
+ 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
+ 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
+ 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
+ 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
+ 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
+ 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
+ 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00,
+ 0xe0, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
+ 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff,
+ 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x0f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x1f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
+ 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x7f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00,
+ 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/rook_outline.bitmap b/gnu/games/chess/Xchess/rook_outline.bitmap
new file mode 100644
index 000000000000..f30107a3f277
--- /dev/null
+++ b/gnu/games/chess/Xchess/rook_outline.bitmap
@@ -0,0 +1,71 @@
+
+#define rook_outline_width 80
+#define rook_outline_height 80
+static char rook_outline_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x80,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x08, 0x80, 0x00, 0x3c,
+ 0x00, 0x00, 0x00, 0x80, 0x3f, 0x01, 0x08, 0x80, 0x00, 0xe4, 0x0f, 0x00,
+ 0x00, 0xc0, 0x00, 0x01, 0x08, 0x80, 0x00, 0x04, 0x18, 0x00, 0x00, 0x40,
+ 0x00, 0x01, 0x08, 0x80, 0x00, 0x04, 0x10, 0x00, 0x00, 0x40, 0x00, 0x01,
+ 0x08, 0x80, 0x00, 0x04, 0x10, 0x00, 0x00, 0x40, 0x00, 0x01, 0x0f, 0x80,
+ 0x07, 0x04, 0x10, 0x00, 0x00, 0x40, 0x00, 0xfd, 0x01, 0x00, 0xfc, 0x05,
+ 0x10, 0x00, 0x00, 0x40, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x10, 0x00,
+ 0x00, 0x40, 0x00, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x10, 0x00, 0x00, 0x40,
+ 0x00, 0xf0, 0x07, 0x00, 0x7f, 0x00, 0x10, 0x00, 0x00, 0x40, 0xc0, 0x1f,
+ 0x00, 0x00, 0xc0, 0x1f, 0x10, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x02, 0x00,
+ 0x02, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
+ 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00,
+ 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x80, 0xff, 0xff, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff,
+ 0x00, 0x01, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
+ 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
+ 0xf0, 0x7f, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x1f, 0xc0,
+ 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
+ 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00,
+ 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
+ 0x02, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff,
+ 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
+ 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10,
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x00, 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
+ 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x02,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x1f,
+ 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00,
+ 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
+ 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x07, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00,
+ 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x60,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x20, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/rook_small.bitmap b/gnu/games/chess/Xchess/rook_small.bitmap
new file mode 100644
index 000000000000..ddee75660d4b
--- /dev/null
+++ b/gnu/games/chess/Xchess/rook_small.bitmap
@@ -0,0 +1,15 @@
+
+#define rook_small_width 32
+#define rook_small_height 32
+static char rook_small_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x73, 0xce, 0x03, 0xc0, 0x73, 0xce, 0x03, 0xc0, 0x73, 0xce, 0x03,
+ 0xc0, 0x73, 0xce, 0x03, 0xc0, 0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00,
+ 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00,
+ 0xe0, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/rook_small_outline.bitmap b/gnu/games/chess/Xchess/rook_small_outline.bitmap
new file mode 100644
index 000000000000..523521b963b7
--- /dev/null
+++ b/gnu/games/chess/Xchess/rook_small_outline.bitmap
@@ -0,0 +1,15 @@
+
+#define rook_small_outline_width 32
+#define rook_small_outline_height 32
+static char rook_small_outline_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x73, 0xce, 0x03, 0x40, 0x52, 0x4a, 0x02, 0x40, 0x52, 0x4a, 0x02,
+ 0x40, 0x52, 0x4a, 0x02, 0xc0, 0xff, 0xff, 0x03, 0x00, 0x01, 0x80, 0x00,
+ 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
+ 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
+ 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
+ 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
+ 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
+ 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
+ 0xe0, 0xff, 0xff, 0x07, 0x20, 0x00, 0x00, 0x04, 0xe0, 0xff, 0xff, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/scrollText.c b/gnu/games/chess/Xchess/scrollText.c
new file mode 100644
index 000000000000..432071086d15
--- /dev/null
+++ b/gnu/games/chess/Xchess/scrollText.c
@@ -0,0 +1,1858 @@
+/*
+ * A Scrollable Text Output Window
+ *
+ * David Harrison
+ * University of California, Berkeley
+ * 1986
+ *
+ * The following is an implementation for a scrollable text output
+ * system. It handles exposure events only (other interactions are
+ * under user control). For scrolling, a always present scroll bar
+ * is implemented. It detects size changes and compensates accordingly.
+ */
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/X10.h>
+#include <sys/types.h>
+#include "scrollText.h"
+
+extern char *malloc();
+extern char *realloc();
+#define alloc(type) (type *) malloc(sizeof(type))
+#define numalloc(type, num) (type *) malloc((unsigned) (num * sizeof(type)))
+#define MAXINT 2147483647
+
+extern XAssocTable *XCreateAssocTable();
+extern caddr_t XLookUpAssoc();
+
+static XAssocTable *textWindows = (XAssocTable *) 0;
+
+#define NOOPTION -1 /* Option hasn't been set yet */
+#define NORMSCROLL 0 /* Smooth scroll on LineToTop and TopToHere */
+#define JUMPSCROLL 1 /* Jump scrolling on LineToTop and TopToHere */
+
+static int ScrollOption = NOOPTION;
+
+typedef char *Generic;
+
+#define DEFAULT_GC textInfo->fontGC[textInfo->curFont]
+
+#define BARSIZE 15
+#define BARBORDER 1
+#define MAXFONTS 8
+#define INITBUFSIZE 1024
+#define INITLINES 50
+#define INITEXPARY 50
+#define XPADDING 2
+#define YPADDING 2
+#define INTERLINE 5
+#define INTERSPACE 1
+#define CURSORWIDTH 2
+#define EXPANDPERCENT 40
+#define BUFSIZE 1024
+#define CUROFFSET 1
+#define MAXFOREIGN 250
+#define NOINDEX -1
+
+/* The wrap line indicator */
+#define WRAPINDSIZE 7
+#define STEMOFFSET 5
+#define arrow_width 7
+#define arrow_height 5
+static char arrow_bits[] = {
+ 0x24, 0x26, 0x3f, 0x06, 0x04};
+
+#define NEWLINE '\n'
+#define BACKSPACE '\010'
+#define NEWFONT '\006'
+#define LOWCHAR '\040'
+#define HIGHCHAR '\176'
+
+#define CHARMASK 0x00ff /* Character mask */
+#define FONTMASK 0x0700 /* Character font */
+#define FONTSHIFT 8 /* Shift amount */
+
+#define WRAPFLAG 0x01 /* Line wrap flag */
+
+/*
+ * Lines are represented by a pointer into the overall array of
+ * 16-bit characters. The lower eight bits is used to indicate the character
+ * (in ASCII), and the next two bits are used to indicate the font
+ * the character should be drawn in.
+ */
+
+typedef struct txtLine {
+ int lineLength; /* Current line length */
+ int lineHeight; /* Full height of line in pixels */
+ int lineBaseLine; /* Current baseline of the line */
+ int lineWidth; /* Drawing position at end of line */
+ int lineText; /* Offset into master buffer */
+ int lineFlags; /* Line wrap flag is here */
+};
+
+
+/*
+ * For ExposeCopy events, we queue up the redraw requests collapsing
+ * them into line redraw requests until the CopyExpose event arrives.
+ * The queue is represented as a dynamic array of the following
+ * structure:
+ */
+
+typedef struct expEvent {
+ int lineIndex; /* Index of line to redraw */
+ int ypos; /* Drawing position of line */
+};
+
+
+/*
+ * The text buffer is represented using a dynamic counted array
+ * of 16-bit quantities. This array expands as needed.
+ * For the screen representation, a dynamic counted array
+ * of line structures is used. This array points into the
+ * text buffer to denote the start of each line and its parameters.
+ * The windows are configured as one overall window which contains
+ * the scroll bar as a sub-window along its right edge. Thus,
+ * the text drawing space is actually w-BARSIZE.
+ */
+
+#define NOTATBOTTOM 0x01 /* Need to scroll to bottom before appending */
+#define FONTNUMWAIT 0x02 /* Waiting for font number */
+#define COPYEXPOSE 0x04 /* Need to process a copy expose event */
+#define SCREENWRONG 0x08 /* TxtJamStr has invalidated screen contents */
+
+typedef struct txtWin {
+ /* Basic text buffer */
+ int bufAlloc; /* Allocated size of buffer */
+ int bufSpot; /* Current writing position in buffer */
+ short *mainBuffer; /* Main buffer of text */
+
+ /* Line information */
+ int numLines; /* Number of display lines in buffer */
+ int allocLines; /* Number of lines allocated */
+ struct txtLine **txtBuffer; /* Dynamic array of lines */
+
+ /* Current Window display information */
+ Window mainWindow; /* Text display window */
+ Window scrollBar; /* Subwindow for scroll bar */
+ Pixmap arrowMap; /* line wrap indicator */
+ int bgPix, fgPix; /* Background and cursor */
+ GC CursorGC; /* gc for the cursor */
+ GC bgGC; /* gc for erasing things */
+ GC fontGC[MAXFONTS]; /* gc for doing fonts */
+ XFontStruct theFonts[MAXFONTS];/* Display fonts */
+ int theColors[MAXFONTS]; /* foregrounds of the fonts */
+ int curFont; /* current font for tracking */
+ int w, h; /* Current size */
+ int startLine; /* Top line in display */
+ int endLine; /* Bottom line in display */
+ int bottomSpace; /* Space at bottom of screen */
+ int flagWord; /* If non-zero, not at end */
+
+ /* For handling ExposeCopy events */
+ int exposeSize; /* Current size of array */
+ int exposeAlloc; /* Allocated size */
+ struct expEvent **exposeAry;/* Array of line indices */
+
+ /* Drawing position information */
+ int curLine; /* Current line in buffer */
+ int curX; /* Current horizontal positi */
+ int curY; /* Current vertical drawing */
+};
+
+/* Flags for the various basic character handling functions */
+
+#define DODISP 0x01 /* Update the display */
+#define NONEWLINE 0x02 /* Dont append newline */
+
+
+
+static int InitLine(newLine)
+struct txtLine *newLine; /* Newly created line structure */
+/*
+ * This routine initializes a newly created line structure.
+ */
+{
+ newLine->lineLength = 0;
+ newLine->lineHeight = 0;
+ newLine->lineBaseLine = 0;
+ newLine->lineWidth = XPADDING;
+ newLine->lineText = NOINDEX;
+ newLine->lineFlags = 0;
+ return 1;
+}
+
+
+
+
+int TxtGrab(display, txtWin, program, mainFont, bg, fg, cur)
+Display *display; /* display window is on */
+Window txtWin; /* Window to take over as scrollable text */
+char *program; /* Program name for Xdefaults */
+XFontStruct *mainFont; /* Primary text font */
+int bg, fg, cur; /* Background, foreground, and cursor colors */
+/*
+ * This routine takes control of 'txtWin' and makes it into a scrollable
+ * text output window. It will create a sub-window for the scroll bar
+ * with a background of 'bg' and an bar with color 'fg'. Both fixed width
+ * and variable width fonts are supported. Additional fonts can be loaded
+ * using 'TxtAddFont'. Returns 0 if there were problems, non-zero if
+ * everything went ok.
+ */
+{
+ struct txtWin *newWin; /* Text package specific information */
+ XWindowAttributes winInfo; /* Window information */
+ int index;
+ XGCValues gc_val;
+
+ if (textWindows == (XAssocTable *) 0) {
+ textWindows = XCreateAssocTable(32);
+ if (textWindows == (XAssocTable *) 0) return(0);
+ }
+ if (XGetWindowAttributes(display, txtWin, &winInfo) == 0) return 0;
+
+ if (ScrollOption == NOOPTION) {
+ /* Read to see if the user wants jump scrolling or not */
+ if (XGetDefault(display, program, "JumpScroll")) {
+ ScrollOption = JUMPSCROLL;
+ } else {
+ ScrollOption = NORMSCROLL;
+ }
+ }
+
+ /* Initialize local structure */
+ newWin = alloc(struct txtWin);
+
+ /* Initialize arrow pixmap */
+ newWin->arrowMap = XCreatePixmapFromBitmapData(display, txtWin,
+ arrow_bits,
+ arrow_width, arrow_height,
+ cur, bg,
+ DisplayPlanes(display, 0));
+
+ newWin->bufAlloc = INITBUFSIZE;
+ newWin->bufSpot = 0;
+ newWin->mainBuffer = numalloc(short, INITBUFSIZE);
+
+ newWin->numLines = 1;
+ newWin->allocLines = INITLINES;
+ newWin->txtBuffer = numalloc(struct txtLine *, INITLINES);
+ for (index = 0; index < INITLINES; index++) {
+ newWin->txtBuffer[index] = alloc(struct txtLine);
+ InitLine(newWin->txtBuffer[index]);
+ }
+
+ /* Window display information */
+ newWin->mainWindow = txtWin;
+ newWin->w = winInfo.width;
+ newWin->h = winInfo.height;
+ newWin->startLine = 0;
+ newWin->endLine = 0;
+ newWin->bottomSpace = winInfo.height
+ - YPADDING - mainFont->ascent - mainFont->descent - INTERLINE;
+ newWin->flagWord = 0;
+ newWin->bgPix = bg;
+ newWin->fgPix = fg;
+
+ /* Scroll Bar Creation */
+ newWin->scrollBar = XCreateSimpleWindow(display, txtWin,
+ winInfo.width - BARSIZE,
+ 0, BARSIZE - (2*BARBORDER),
+ winInfo.height - (2*BARBORDER),
+ BARBORDER,
+ fg, bg);
+ XSelectInput(display, newWin->scrollBar, ExposureMask|ButtonReleaseMask);
+ XMapRaised(display, newWin->scrollBar);
+
+ /* Font and Color Initialization */
+ newWin->theFonts[0] = *mainFont;
+ newWin->theColors[0] = fg;
+ gc_val.function = GXcopy;
+ gc_val.plane_mask = AllPlanes;
+ gc_val.foreground = fg;
+ gc_val.background = bg;
+ gc_val.graphics_exposures = 1;
+ gc_val.font = mainFont->fid;
+ gc_val.line_width = 1;
+ gc_val.line_style = LineSolid;
+
+ newWin->fontGC[0] = XCreateGC(display, txtWin,
+ GCFunction | GCPlaneMask |
+ GCForeground | GCBackground |
+ GCGraphicsExposures | GCFont,
+ &gc_val);
+
+ gc_val.foreground = cur;
+ newWin->CursorGC = XCreateGC(display, txtWin,
+ GCFunction | GCPlaneMask |
+ GCForeground | GCBackground |
+ GCLineStyle | GCLineWidth,
+ &gc_val);
+
+ gc_val.foreground = bg;
+ newWin->bgGC = XCreateGC(display, txtWin,
+ GCFunction | GCPlaneMask |
+ GCForeground | GCBackground |
+ GCGraphicsExposures | GCFont,
+ &gc_val);
+
+
+ for (index = 1; index < MAXFONTS; index++) {
+ newWin->theFonts[index].fid = 0;
+ newWin->fontGC[index] = 0;
+ }
+
+
+ /* Initialize size of first line */
+ newWin->txtBuffer[0]->lineHeight = newWin->theFonts[0].ascent +
+ newWin->theFonts[0].descent;
+ newWin->txtBuffer[0]->lineText = 0;
+
+ /* ExposeCopy array initialization */
+ newWin->exposeSize = 0;
+ newWin->exposeAlloc = INITEXPARY;
+ newWin->exposeAry = numalloc(struct expEvent *, INITEXPARY);
+ for (index = 0; index < newWin->exposeAlloc; index++)
+ newWin->exposeAry[index] = alloc(struct expEvent);
+ /* Put plus infinity in last slot for sorting purposes */
+ newWin->exposeAry[0]->lineIndex = MAXINT;
+
+ /* Drawing Position Information */
+ newWin->curLine = 0;
+ newWin->curX = 0;
+ newWin->curY = YPADDING + mainFont->ascent + mainFont->descent;
+
+ /* Attach it to both windows */
+ XMakeAssoc(display, textWindows, (XID) txtWin, (caddr_t) newWin);
+ XMakeAssoc(display, textWindows, (XID) newWin->scrollBar, (caddr_t) newWin);
+ return 1;
+}
+
+
+int TxtRelease(display, w)
+Display *display;
+Window w; /* Window to release */
+/*
+ * This routine releases all resources associated with the
+ * specified window which are consumed by the text
+ * window package. This includes the entire text buffer, line start
+ * array, and the scroll bar window. However, the window
+ * itself is NOT destroyed. The routine will return zero if
+ * the window is not owned by the text window package.
+ */
+{
+ struct txtWin *textInfo;
+ int index;
+
+ if ((textInfo = (struct txtWin *) XLookUpAssoc(display,
+ textWindows, (XID) w)) == 0)
+ return 0;
+
+ for (index = 0; index < MAXFONTS; index++)
+ if (textInfo->fontGC[index] != 0)
+ XFreeGC(display, textInfo->fontGC[index]);
+
+ free((Generic) textInfo->mainBuffer);
+ for (index = 0; index < textInfo->numLines; index++) {
+ free((Generic) textInfo->txtBuffer[index]);
+ }
+ free((Generic) textInfo->txtBuffer);
+ XDestroyWindow(display, textInfo->scrollBar);
+ for (index = 0; index < textInfo->exposeSize; index++) {
+ free((Generic) textInfo->exposeAry[index]);
+ }
+ free((Generic) textInfo->exposeAry);
+ XDeleteAssoc(display, textWindows, (XID) w);
+ free((Generic) textInfo);
+ return 1;
+}
+
+
+
+static int RecompBuffer(textInfo)
+struct txtWin *textInfo; /* Text window information */
+/*
+ * This routine recomputes all line breaks in a buffer after
+ * a change in window size or font. This is done by throwing
+ * away the old line start array and recomputing it. Although
+ * a lot of this work is also done elsewhere, it has been included
+ * inline here for efficiency.
+ */
+{
+ int startPos, endSize, linenum;
+ register int index, chsize, curfont;
+ register short *bufptr;
+ register XFontStruct *fontptr;
+ register struct txtLine *lineptr;
+ char theChar;
+
+ /* Record the old position so we can come back to it */
+ for (startPos = textInfo->txtBuffer[textInfo->startLine]->lineText;
+ (startPos > 0) && (textInfo->mainBuffer[startPos] != '\n');
+ startPos--)
+ /* null loop body */;
+
+ /* Clear out the old line start array */
+ for (index = 0; index < textInfo->numLines; index++) {
+ InitLine(textInfo->txtBuffer[index]);
+ }
+
+ /* Initialize first line */
+ textInfo->txtBuffer[0]->lineHeight =
+ textInfo->theFonts[0].ascent + textInfo->theFonts[0].descent;
+ textInfo->txtBuffer[0]->lineText = 0;
+
+ /* Process the text back into lines */
+ endSize = textInfo->w - BARSIZE - WRAPINDSIZE;
+ bufptr = textInfo->mainBuffer;
+ lineptr = textInfo->txtBuffer[0];
+ linenum = 0;
+ fontptr = &(textInfo->theFonts[0]);
+ curfont = 0;
+ for (index = 0; index < textInfo->bufSpot; index++) {
+ theChar = bufptr[index] & CHARMASK;
+
+ if ((bufptr[index] & FONTMASK) != curfont) {
+ int newFontNum, heightDiff;
+
+ /* Switch fonts */
+ newFontNum = (bufptr[index] & FONTMASK) >> FONTSHIFT;
+ if (textInfo->theFonts[newFontNum].fid != 0) {
+ /* Valid font */
+ curfont = bufptr[index] & FONTMASK;
+ fontptr = &(textInfo->theFonts[newFontNum]);
+ heightDiff = (fontptr->ascent + fontptr->descent) -
+ lineptr->lineHeight;
+ if (heightDiff < 0) heightDiff = 0;
+ lineptr->lineHeight += heightDiff;
+ }
+ }
+ if (theChar == '\n') {
+ /* Handle new line */
+ if (linenum >= textInfo->allocLines-1)
+ /* Expand number of lines */
+ ExpandLines(textInfo);
+ linenum++;
+ lineptr = textInfo->txtBuffer[linenum];
+ /* Initialize next line */
+ lineptr->lineHeight = fontptr->ascent + fontptr->descent;
+ lineptr->lineText = index+1;
+ /* Check to see if its the starting line */
+ if (index == startPos) textInfo->startLine = linenum;
+ } else {
+ /* Handle normal character */
+ chsize = CharSize(textInfo, linenum, index);
+ if (lineptr->lineWidth + chsize > endSize) {
+ /* Handle line wrap */
+ lineptr->lineFlags |= WRAPFLAG;
+ if (linenum >= textInfo->allocLines-1)
+ /* Expand number of lines */
+ ExpandLines(textInfo);
+ linenum++;
+ lineptr = textInfo->txtBuffer[linenum];
+ /* Initialize next line */
+ lineptr->lineHeight = fontptr->ascent + fontptr->descent;
+ lineptr->lineText = index;
+ lineptr->lineLength = 1;
+ lineptr->lineWidth += chsize;
+ } else {
+ /* Handle normal addition of character */
+ lineptr->lineLength += 1;
+ lineptr->lineWidth += chsize;
+ }
+ }
+ }
+ /* We now have a valid line array. Let's clean up some other fields. */
+ textInfo->numLines = linenum+1;
+ if (startPos == 0) {
+ textInfo->startLine = 0;
+ }
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ textInfo->curLine = linenum;
+ /* Check to see if we are at the bottom */
+ if (textInfo->endLine >= textInfo->numLines-1) {
+ textInfo->curY = textInfo->h - textInfo->bottomSpace -
+ lineptr->lineHeight;
+ textInfo->flagWord &= (~NOTATBOTTOM);
+ } else {
+ textInfo->flagWord |= NOTATBOTTOM;
+ }
+ return 1;
+}
+
+
+
+
+int TxtAddFont(display, textWin, fontNumber, newFont, newColor)
+Display *display;
+Window textWin; /* Scrollable text window */
+int fontNumber; /* Place to add font (0-7) */
+XFontStruct *newFont; /* Font to add */
+int newColor; /* Color of font */
+/*
+ * This routine loads a new font so that it can be used in a previously
+ * created text window. There are eight font slots numbered 0 through 7.
+ * If there is already a font in the specified slot, it will be replaced
+ * and an automatic redraw of the window will take place. See TxtWriteStr
+ * for details on using alternate fonts. The color specifies the foreground
+ * color of the text. The default foreground color is used if this
+ * parameter is TXT_NO_COLOR. Returns a non-zero value if
+ * everything went well.
+ */
+{
+ struct txtWin *textInfo;
+ int redrawFlag;
+ XGCValues gc_val;
+
+ if ((fontNumber < 0) || (fontNumber >= MAXFONTS)) return 0;
+ if ((textInfo = (struct txtWin *)
+ XLookUpAssoc(display, textWindows, (XID) textWin)) == 0)
+ return 0;
+ if (newColor == TXT_NO_COLOR) {
+ newColor = textInfo->fgPix;
+ }
+
+ gc_val.font = newFont->fid;
+ gc_val.foreground = newColor;
+ gc_val.background = textInfo->bgPix;
+ gc_val.plane_mask = AllPlanes;
+ gc_val.graphics_exposures = 1;
+ gc_val.function = GXcopy;
+
+ if (textInfo->fontGC[fontNumber] != 0)
+ {
+ XChangeGC(display, textInfo->fontGC[fontNumber],
+ GCFont | GCForeground, &gc_val);
+ }
+ else
+ textInfo->fontGC[fontNumber] = XCreateGC(display, textWin,
+ GCFont |
+ GCForeground |
+ GCBackground |
+ GCFunction |
+ GCPlaneMask |
+ GCGraphicsExposures,
+ &gc_val);
+
+
+ redrawFlag = (textInfo->theFonts[fontNumber].fid != 0) &&
+ (((newFont) && (newFont->fid != textInfo->theFonts[fontNumber].fid)) ||
+ (newColor != textInfo->theColors[fontNumber]));
+ if (newFont) {
+ textInfo->theFonts[fontNumber] = *newFont;
+ }
+ textInfo->theColors[fontNumber] = newColor;
+
+ if (redrawFlag) {
+ RecompBuffer(textInfo);
+ XClearWindow(display, textWin);
+ TxtRepaint(display, textWin);
+ }
+ return 1;
+}
+
+
+
+int TxtWinP(display, w)
+Display *display;
+Window w;
+/*
+ * Returns a non-zero value if the window has been previously grabbed
+ * using TxtGrab and 0 if it has not.
+ */
+{
+ if (XLookUpAssoc(display, textWindows, (XID) w))
+ return(1);
+ else return(0);
+}
+
+
+
+static int FindEndLine(textInfo, botSpace)
+struct txtWin *textInfo;
+int *botSpace;
+/*
+ * Given the starting line in 'textInfo->startLine', this routine
+ * determines the index of the last line that can be drawn given the
+ * current size of the screen. If there are not enough lines to
+ * fill the screen, the index of the last line will be returned.
+ * The amount of empty bottom space is returned in 'botSpace'.
+ */
+{
+ int index, height, lineHeight;
+
+ height = YPADDING;
+ index = textInfo->startLine;
+ while (index < textInfo->numLines) {
+ lineHeight = textInfo->txtBuffer[index]->lineHeight + INTERLINE;
+ if (height + lineHeight > textInfo->h) break;
+ height += lineHeight;
+ index++;
+ }
+ if (botSpace) {
+ *botSpace = textInfo->h - height;
+ }
+ return index - 1;
+}
+
+
+
+static int UpdateScroll(display, textInfo)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+/*
+ * This routine computes the current extent of the scroll bar
+ * indicator and repaints the bar with the correct information.
+ */
+{
+ int top, bottom;
+
+ if (textInfo->numLines > 1) {
+ top = textInfo->startLine * (textInfo->h - 2*BARBORDER) /
+ (textInfo->numLines - 1);
+ bottom = textInfo->endLine * (textInfo->h - 2*BARBORDER) /
+ (textInfo->numLines - 1);
+ } else {
+ top = 0;
+ bottom = textInfo->h - (2*BARBORDER);
+ }
+
+ /* Draw it - make sure there is a little padding */
+ if (top == 0) top++;
+ if (bottom == textInfo->h-(2*BARBORDER)) bottom--;
+
+ XFillRectangle(display, textInfo->scrollBar,
+ textInfo->bgGC,
+ 0, 0, BARSIZE, top-1);
+ XFillRectangle(display, textInfo->scrollBar,
+ DEFAULT_GC, top, BARSIZE - (2*BARBORDER) - 2,
+ bottom - top);
+ XFillRectangle(display, textInfo->scrollBar, DEFAULT_GC,
+ 0, bottom+1, BARSIZE,
+ textInfo->h - (2 * BARBORDER) - bottom);
+
+ return 1;
+}
+
+
+
+
+int TxtClear(display, w)
+Display *display;
+Window w;
+/*
+ * This routine clears a scrollable text window. It resets the current
+ * writing position to the upper left hand corner of the screen.
+ * NOTE: THIS ALSO CLEARS THE CONTENTS OF THE TEXT WINDOW BUFFER AND
+ * RESETS THE SCROLL BAR. Returns 0 if the window is not a text window.
+ * This should be used *instead* of XClear.
+ */
+{
+ struct txtWin *textInfo;
+ int index;
+
+ if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)) == 0)
+ return 0;
+
+ /* Zero out the arrays */
+ textInfo->bufSpot = 0;
+ for (index = 0; index < textInfo->numLines; index++) {
+ InitLine(textInfo->txtBuffer[index]);
+ }
+ textInfo->txtBuffer[0]->lineHeight =
+ textInfo->theFonts[textInfo->curFont].ascent +
+ textInfo->theFonts[textInfo->curFont].descent;
+
+ textInfo->numLines = 1;
+ textInfo->startLine = 0;
+ textInfo->endLine = 0;
+ textInfo->curLine = 0;
+ textInfo->curX = 0;
+ textInfo->curY = YPADDING + textInfo->theFonts[textInfo->curFont].ascent
+ + textInfo->theFonts[textInfo->curFont].descent;
+
+ textInfo->bottomSpace = textInfo->h - YPADDING -
+ textInfo->theFonts[textInfo->curFont].ascent - INTERLINE -
+ textInfo->theFonts[textInfo->curFont].descent;
+ /* Actually clear the window */
+ XClearWindow(display, w);
+
+ /* Draw the current cursor */
+ XFillRectangle(display, w, textInfo->CursorGC,
+ XPADDING + CUROFFSET, textInfo->curY,
+ CURSORWIDTH,
+ textInfo->theFonts[textInfo->curFont].ascent +
+ textInfo->theFonts[textInfo->curFont].descent);
+
+ /* Update the scroll bar */
+ UpdateScroll(display, textInfo);
+ return 1;
+}
+
+
+static int WarpToBottom(display, textInfo)
+Display *display;
+struct txtWin *textInfo; /* Text Information */
+/*
+ * This routine causes the specified text window to display its
+ * last screen of information. It updates the scroll bar
+ * to the appropriate spot. The implementation scans backward
+ * through the buffer to find an appropriate starting spot for
+ * the window.
+ */
+{
+ int index, height, lineHeight;
+
+ index = textInfo->numLines-1;
+ height = 0;
+ while (index >= 0) {
+ lineHeight = textInfo->txtBuffer[index]->lineHeight + INTERLINE;
+ if (height + lineHeight > textInfo->h) break;
+ height += lineHeight;
+ index--;
+ }
+ textInfo->startLine = index + 1;
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ textInfo->curY = textInfo->h - textInfo->bottomSpace -
+ textInfo->txtBuffer[textInfo->endLine]->lineHeight;
+ XClearWindow(display, textInfo->mainWindow);
+ TxtRepaint(display, textInfo->mainWindow);
+ return 1;
+}
+
+
+
+static int UpdateExposures(display, textInfo)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+/*
+ * Before a new scrolling action occurs, the text window package
+ * must handle all COPYEXPOSE events generated by the last scrolling
+ * action. This routine is called to do this. Foreign events (those
+ * not handled by TxtFilter) are queued up and replaced on the queue
+ * after the processing of the exposure events is complete.
+ */
+{
+#if 0
+ XEvent foreignQueue[MAXFOREIGN];
+ int index, lastItem = 0;
+
+ while (textInfo->flagWord & COPYEXPOSE) {
+ XNextEvent(display, &(foreignQueue[lastItem]));
+ if (!TxtFilter(display, &(foreignQueue[lastItem])))
+ lastItem++;
+ if (lastItem >= MAXFOREIGN) {
+ printf("Too many foreign events to queue!\n");
+ textInfo->flagWord &= (~COPYEXPOSE);
+ }
+ }
+ for (index = 0; index < lastItem; index++) {
+ XPutBackEvent(display, &(foreignQueue[index]));
+ }
+#endif
+ return 1;
+}
+
+
+static int ScrollDown(display,textInfo)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+/*
+ * This routine scrolls the indicated text window down by one
+ * line. The line below the current line must exist. The window
+ * is scrolled so that the line below the last line is fully
+ * displayed. This may cause many lines to scroll off the top.
+ * Scrolling is done using XCopyArea. The exposure events should
+ * be caught using ExposeCopy.
+ */
+{
+ int lineSum, index, targetSpace, freeSpace, updateFlag;
+
+ lineSum = 0;
+ if (textInfo->endLine + 1 >= textInfo->numLines) return 0;
+ targetSpace = textInfo->txtBuffer[textInfo->endLine+1]->lineHeight +
+ INTERLINE;
+ if (textInfo->bottomSpace < targetSpace) {
+ index = textInfo->startLine;
+ while (index < textInfo->endLine) {
+ lineSum += (textInfo->txtBuffer[index]->lineHeight + INTERLINE);
+ if (textInfo->bottomSpace + lineSum >= targetSpace) break;
+ index++;
+ }
+
+ /* Must move upward by 'lineSum' pixels */
+ XCopyArea(display, textInfo->mainWindow, textInfo->mainWindow,
+ DEFAULT_GC, 0, lineSum,
+ textInfo->w - BARSIZE, textInfo->h,
+ 0, 0);
+
+ textInfo->flagWord |= COPYEXPOSE;
+ /* Repair the damage to the structures */
+ textInfo->startLine = index + 1;
+ updateFlag = 1;
+ } else {
+ updateFlag = 0;
+ }
+ /* More lines might be able to fit. Let's check. */
+ freeSpace = textInfo->bottomSpace + lineSum - targetSpace;
+ index = textInfo->endLine + 1;
+ while (index < textInfo->numLines-1) {
+ if (freeSpace - textInfo->txtBuffer[index+1]->lineHeight - INTERLINE < 0)
+ break;
+ freeSpace -= (textInfo->txtBuffer[index+1]->lineHeight + INTERLINE);
+ index++;
+ }
+ textInfo->endLine = index;
+ textInfo->bottomSpace = freeSpace;
+ if (updateFlag) {
+ UpdateExposures(display, textInfo);
+ }
+ UpdateScroll(display, textInfo);
+ return 1;
+}
+
+
+
+
+static int ExpandLines(textInfo)
+struct txtWin *textInfo; /* Text Information */
+/*
+ * This routine allocates and initializes additional space in
+ * the line start array (txtBuffer). The new space
+ * is allocated using realloc. The expansion factor is a percentage
+ * given by EXPANDPERCENT.
+ */
+{
+ int newSize, index;
+
+ newSize = textInfo->allocLines;
+ newSize += (newSize * EXPANDPERCENT) / 100;
+
+ textInfo->txtBuffer = (struct txtLine **)
+ realloc((char *) textInfo->txtBuffer,
+ (unsigned) (newSize * sizeof(struct txtLine *)));
+ for (index = textInfo->allocLines; index < newSize; index++) {
+ textInfo->txtBuffer[index] = alloc(struct txtLine);
+ InitLine(textInfo->txtBuffer[index]);
+ }
+ textInfo->allocLines = newSize;
+ return 1;
+}
+
+static int ExpandBuffer(textInfo)
+struct txtWin *textInfo; /* Text information */
+/*
+ * Expands the basic character buffer using realloc. The expansion
+ * factor is a percentage given by EXPANDPERCENT.
+ */
+{
+ int newSize;
+
+ newSize = textInfo->bufAlloc + (textInfo->bufAlloc * EXPANDPERCENT) / 100;
+ textInfo->mainBuffer = (short *)
+ realloc((char *) textInfo->mainBuffer, (unsigned) newSize * sizeof(short));
+ textInfo->bufAlloc = newSize;
+ return 1;
+}
+
+
+
+static int HandleNewLine(display, textInfo, flagWord)
+Display *display;
+struct txtWin *textInfo; /* Text Information */
+int flagWord; /* DODISP or NONEWLINE or both */
+/*
+ * This routine initializes the next line for drawing by setting
+ * its height to the current font height, scrolls the screen down
+ * one line, and updates the current drawing position to the
+ * left edge of the newly cleared line. If DODISP is specified,
+ * the screen will be updated (otherwise not). If NONEWLINE is
+ * specified, no newline character will be added to the text buffer
+ * (this is for line wrap).
+ */
+{
+ struct txtLine *curLine, *nextLine;
+
+ /* Check to see if a new line must be allocated */
+ if (textInfo->curLine >= textInfo->allocLines-1)
+ /* Expand the number of lines */
+ ExpandLines(textInfo);
+ textInfo->numLines += 1;
+
+ /* Then we initialize the next line */
+ nextLine = textInfo->txtBuffer[textInfo->numLines-1];
+ nextLine->lineHeight =
+ textInfo->theFonts[textInfo->curFont].ascent +
+ textInfo->theFonts[textInfo->curFont].descent;
+
+ curLine = textInfo->txtBuffer[textInfo->curLine];
+ if (flagWord & DODISP) {
+ /* Scroll down a line if required */
+ if ((textInfo->curY + curLine->lineHeight +
+ nextLine->lineHeight + (INTERLINE * 2)) > textInfo->h)
+ {
+ ScrollDown(display, textInfo);
+ }
+ else
+ {
+ /* Update the bottom space appropriately */
+ textInfo->bottomSpace -= (nextLine->lineHeight + INTERLINE);
+ textInfo->endLine += 1;
+ }
+ /* Update drawing position */
+ textInfo->curY = textInfo->h -
+ (textInfo->bottomSpace + nextLine->lineHeight);
+ }
+
+ /* Move down a line */
+ textInfo->curLine += 1;
+ if (!(flagWord & NONEWLINE)) {
+ /* Append end-of-line to text buffer */
+ if (textInfo->bufSpot >= textInfo->bufAlloc) {
+ /* Allocate more space in main text buffer */
+ ExpandBuffer(textInfo);
+ }
+ textInfo->mainBuffer[(textInfo->bufSpot)++] =
+ (textInfo->curFont << FONTSHIFT) | '\n';
+ }
+ nextLine->lineText = textInfo->bufSpot;
+ textInfo->curX = 0;
+ return 1;
+}
+
+
+
+static int CharSize(textInfo, lineNum, charNum)
+struct txtWin *textInfo; /* Current Text Information */
+int lineNum; /* Line in buffer */
+int charNum; /* Character in line */
+/*
+ * This routine determines the size of the specified character.
+ * It takes in account the font of the character and whether its
+ * fixed or variable. The size includes INTERSPACE spacing between
+ * the characters.
+ */
+{
+ register XFontStruct *charFont;
+ register short *theLine;
+ register short theChar;
+
+ theLine = &(textInfo->mainBuffer[textInfo->txtBuffer[lineNum]->lineText]);
+ theChar = theLine[charNum] & CHARMASK;
+ charFont = &(textInfo->theFonts[(theChar & FONTMASK) >> FONTSHIFT]);
+ if (theChar <= charFont->min_char_or_byte2 ||
+ theChar >= charFont->max_char_or_byte2 ||
+ charFont->per_char == 0)
+ return charFont->max_bounds.width + 1;
+ else
+ return charFont->per_char[theChar].width + 1;
+}
+
+
+
+
+
+static int HandleBackspace(display, textInfo, flagWord)
+Display *display;
+struct txtWin *textInfo; /* Text Information */
+int flagWord; /* DODISP or nothing */
+/*
+ * This routine handles a backspace found in the input stream. The
+ * character before the current writing position will be erased and
+ * the drawing position will move back one character. If the writing
+ * position is at the left margin, the drawing position will move
+ * up to the previous line. If it is a line that has been wrapped,
+ * the character at the end of the previous line will be erased.
+ */
+{
+ struct txtLine *thisLine, *prevLine;
+ int chSize;
+
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+ /* First, determine whether we need to go back a line */
+ if (thisLine->lineLength == 0) {
+ /* Bleep if at top of buffer */
+ if (textInfo->curLine == 0) {
+ XBell(display, 50);
+ return 0;
+ }
+
+ /* See if we have to scroll in the other direction */
+ if ((flagWord & DODISP) && (textInfo->curY <= YPADDING)) {
+ /* This will display the last lines of the buffer */
+ WarpToBottom(display, textInfo);
+ }
+
+ /* Set drawing position at end of previous line */
+ textInfo->curLine -= 1;
+ prevLine = textInfo->txtBuffer[textInfo->curLine];
+ textInfo->numLines -= 1;
+ if (flagWord & DODISP) {
+ textInfo->curY -= (prevLine->lineHeight + INTERLINE);
+ textInfo->bottomSpace += (thisLine->lineHeight + INTERLINE);
+ textInfo->endLine -= 1;
+ }
+
+ /* We are unlinewrapping if the previous line has flag set */
+ if (prevLine->lineFlags & WRAPFLAG) {
+ /* Get rid of line wrap indicator */
+ if (flagWord & DODISP) {
+ XFillRectangle(display, textInfo->mainWindow,
+ textInfo->bgGC,
+ textInfo->w - BARSIZE - WRAPINDSIZE,
+ textInfo->curY, WRAPINDSIZE,
+ prevLine->lineHeight);
+ }
+ prevLine->lineFlags &= (~WRAPFLAG);
+ /* Call recursively to wipe out the ending character */
+ HandleBackspace(display, textInfo, flagWord);
+ } else {
+ /* Delete the end-of-line in the primary buffer */
+ textInfo->bufSpot -= 1;
+ }
+ } else {
+ /* Normal deletion of character */
+ chSize =
+ CharSize(textInfo, textInfo->curLine,
+ textInfo->txtBuffer[textInfo->curLine]->lineLength - 1);
+ /* Move back appropriate amount and wipe it out */
+ thisLine->lineWidth -= chSize;
+ if (flagWord & DODISP) {
+ XFillRectangle(display, textInfo->mainWindow,
+ textInfo->bgGC,
+ thisLine->lineWidth, textInfo->curY,
+ chSize, thisLine->lineHeight);
+ }
+ /* Delete from buffer */
+ textInfo->txtBuffer[textInfo->curLine]->lineLength -= 1;
+ textInfo->bufSpot -= 1;
+ }
+ return 1;
+}
+
+
+
+static int DrawLineWrap(display, win, x, y, h, col)
+Display *display;
+Window win; /* What window to draw it in */
+int x, y; /* Position of upper left corner */
+int h; /* Height of indicator */
+int col; /* Color of indicator */
+/*
+ * This routine draws a line wrap indicator at the end of a line.
+ * Visually, it is an arrow of the specified height directly against
+ * the scroll bar border. The bitmap used for the arrow is stored
+ * in 'arrowMap' with size 'arrow_width' and 'arrow_height'.
+ */
+{
+ struct txtWin *textInfo;
+
+ textInfo = (struct txtWin *)XLookUpAssoc(display, textWindows,
+ (XID) win);
+
+ /* First, draw the arrow */
+ XCopyArea(display, textInfo->arrowMap, textInfo->mainWindow,
+ textInfo->CursorGC,
+ 0, 0, arrow_width, arrow_height,
+ x, y + h - arrow_height, 1);
+
+ /* Then draw the stem */
+ XDrawLine(display, textInfo->mainWindow, textInfo->CursorGC,
+ x + STEMOFFSET, y,
+ x + STEMOFFSET, y + h - arrow_height);
+ return 1;
+}
+
+
+
+
+static int DrawLine(display, textInfo, lineIndex, ypos)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+int lineIndex; /* Index of line to draw */
+int ypos; /* Y position for line */
+/*
+ * This routine destructively draws the indicated line in the
+ * indicated window at the indicated position. It does not
+ * clear to end of line however. It draws a line wrap indicator
+ * if needed but does not draw a cursor.
+ */
+{
+ int index, startPos, curFont, theColor, curX, saveX, fontIndex;
+ struct txtLine *someLine;
+ char lineBuffer[BUFSIZE], *glyph;
+ short *linePointer;
+ XFontStruct *theFont;
+ XGCValues gc;
+
+ /* First, we draw the text */
+ index = 0;
+ curX = XPADDING;
+ someLine = textInfo->txtBuffer[lineIndex];
+ linePointer = &(textInfo->mainBuffer[someLine->lineText]);
+ while (index < someLine->lineLength) {
+ startPos = index;
+ saveX = curX;
+ curFont = linePointer[index] & FONTMASK;
+ fontIndex = curFont >> FONTSHIFT;
+ theFont = &(textInfo->theFonts[fontIndex]);
+ theColor = textInfo->theColors[fontIndex];
+ glyph = &(lineBuffer[0]);
+ while ((index < someLine->lineLength) &&
+ ((linePointer[index] & FONTMASK) == curFont))
+ {
+ *glyph = linePointer[index] & CHARMASK;
+ index++;
+ curX += CharSize(textInfo, lineIndex, index);
+ glyph++;
+ }
+
+ /* Flush out the glyphs */
+ XFillRectangle(display, textInfo->mainWindow,
+ textInfo->bgGC,
+ saveX, ypos,
+ textInfo->w - BARSIZE,
+ someLine->lineHeight + YPADDING + INTERLINE);
+
+ XDrawString(display, textInfo->mainWindow,
+ textInfo->fontGC[fontIndex],
+ saveX, ypos,
+ lineBuffer, someLine->lineLength);
+ }
+ /* Then the line wrap indicator (if needed) */
+ if (someLine->lineFlags & WRAPFLAG) {
+ DrawLineWrap(display, textInfo->mainWindow,
+ textInfo->w - BARSIZE - WRAPINDSIZE,
+ ypos, someLine->lineHeight,
+ textInfo->fgPix);
+ }
+ return 1;
+}
+
+
+
+
+static int HandleNewFont(display, fontNum, textInfo, flagWord)
+Display *display;
+int fontNum; /* Font number */
+struct txtWin *textInfo; /* Text information */
+int flagWord; /* DODISP or nothing */
+/*
+ * This routine handles a new font request. These requests take
+ * the form "^F<digit>". The parsing is done in TxtWriteStr.
+ * This routine is called only if the form is valid. It may return
+ * a failure (0 status) if the requested font is not loaded.
+ * If the new font is larger than any of the current
+ * fonts on the line, it will change the line height and redisplay
+ * the line.
+ */
+{
+ struct txtLine *thisLine;
+ int heightDiff, baseDiff, redrawFlag;
+
+ if (textInfo->theFonts[fontNum].fid == 0) {
+ return 0;
+ } else {
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+ textInfo->curFont = fontNum;
+ redrawFlag = 0;
+ heightDiff = textInfo->theFonts[fontNum].ascent +
+ textInfo->theFonts[fontNum].descent -
+ thisLine->lineHeight;
+
+ if (heightDiff > 0) {
+ redrawFlag = 1;
+ } else {
+ heightDiff = 0;
+ }
+
+ if (redrawFlag) {
+ if (flagWord & DODISP) {
+ /* Clear current line */
+ XFillRectangle(display, textInfo->mainWindow,
+ textInfo->bgGC,
+ 0, textInfo->curY, textInfo->w,
+ thisLine->lineHeight);
+
+ /* Check to see if it requires scrolling */
+ if ((textInfo->curY + thisLine->lineHeight + heightDiff +
+ INTERLINE) > textInfo->h)
+ {
+ /*
+ * General approach: "unscroll" the last line up
+ * and then call ScrollDown to do the right thing.
+ */
+ textInfo->endLine -= 1;
+ textInfo->bottomSpace += thisLine->lineHeight +
+ INTERLINE;
+
+ XFillRectangle(display, textInfo->mainWindow,
+ textInfo->bgGC,
+ 0, textInfo->h - textInfo->bottomSpace,
+ textInfo->w, textInfo->bottomSpace);
+
+ thisLine->lineHeight += heightDiff;
+ ScrollDown(display, textInfo);
+ textInfo->curY = textInfo->h -
+ (textInfo->bottomSpace + INTERLINE +
+ thisLine->lineHeight);
+ }
+ else
+ {
+ /* Just update bottom space */
+ textInfo->bottomSpace -= heightDiff;
+ thisLine->lineHeight += heightDiff;
+ }
+ /* Redraw the current line */
+ DrawLine(display, textInfo, textInfo->curLine, textInfo->curY);
+ } else {
+ /* Just update line height */
+ thisLine->lineHeight += heightDiff;
+ }
+ }
+ return 1;
+ }
+}
+
+
+
+int TxtWriteStr(display, w, str)
+Display *display;
+Window w; /* Text window */
+register char *str; /* 0 terminated string */
+/*
+ * This routine writes a string to the specified text window.
+ * The following notes apply:
+ * - Text is always appended to the end of the text buffer.
+ * - If the scroll bar is positioned such that the end of the
+ * text is not visible, an automatic scroll to the bottom
+ * will be done before the appending of text.
+ * - Non-printable ASCII characters are not displayed.
+ * - The '\n' character causes the current text position to
+ * advance one line and start at the left.
+ * - Tabs are not supported.
+ * - Lines too long for the screen will be wrapped and a line wrap
+ * indication will be drawn.
+ * - Backspace clears the previous character. It will do the right
+ * thing if asked to backspace past a wrapped line.
+ * - A new font can be chosen using the sequence '^F<digit>' where
+ * <digit> is 0-7. The directive will be ignored if
+ * there is no font in the specified slot.
+ * Returns 0 if something went wrong.
+ */
+{
+ register int fontIndex;
+ register struct txtWin *textInfo;
+ register struct txtLine *thisLine;
+
+ if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)) == 0)
+ return 0;
+
+ /* See if screen needs to be updated */
+ if (textInfo->flagWord & SCREENWRONG) {
+ TxtRepaint(display, textInfo->mainWindow);
+ }
+
+ /* See if we have to scroll down to the bottom */
+ if (textInfo->flagWord & NOTATBOTTOM) {
+ WarpToBottom(display, textInfo);
+ textInfo->flagWord &= (~NOTATBOTTOM);
+ }
+
+ /* Undraw the current cursor */
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+
+ XFillRectangle(display, w, textInfo->bgGC,
+ thisLine->lineWidth + CUROFFSET,
+ textInfo->curY,
+ CURSORWIDTH,
+ thisLine->lineHeight);
+
+ for ( /* str is ok */ ; (*str != 0) ; str++) {
+ /* Check to see if we are waiting on a font */
+ if (textInfo->flagWord & FONTNUMWAIT) {
+ textInfo->flagWord &= (~FONTNUMWAIT);
+ fontIndex = *str - '0';
+ if ((fontIndex >= 0) && (fontIndex < MAXFONTS)) {
+ /* Handle font -- go get next character */
+ if (HandleNewFont(display, fontIndex, textInfo, DODISP))
+ continue;
+ }
+ }
+
+ /* Inline code for handling normal character case */
+ if ((*str >= LOWCHAR) && (*str <= HIGHCHAR)) {
+ register XFontStruct *thisFont;
+ register struct txtLine *thisLine;
+ register int charWidth;
+ int thisColor;
+
+ /* Determine size of character */
+ thisFont = &(textInfo->theFonts[textInfo->curFont]);
+ thisColor = textInfo->theColors[textInfo->curFont];
+ if (*str <= thisFont->min_char_or_byte2 ||
+ *str >= thisFont->max_char_or_byte2 ||
+ thisFont->per_char == 0)
+ charWidth = thisFont->max_bounds.width + 1;
+ else
+ charWidth = thisFont->per_char[*str].width + 1;
+
+ /* Check to see if line wrap is required */
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+ if (thisLine->lineWidth + charWidth >
+ (textInfo->w-BARSIZE-WRAPINDSIZE))
+ {
+ DrawLineWrap(display, textInfo->mainWindow,
+ textInfo->w-BARSIZE-WRAPINDSIZE,
+ textInfo->curY, thisLine->lineHeight,
+ textInfo->fgPix);
+ thisLine->lineFlags |= WRAPFLAG;
+ /* Handle the spacing problem the same way as a newline */
+ HandleNewLine(display, textInfo, DODISP | NONEWLINE);
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+ }
+
+ /* Ready to draw character */
+ XDrawString(display, textInfo->mainWindow,
+ DEFAULT_GC,
+ textInfo->curX += charWidth,
+ textInfo->curY + thisLine->lineHeight,
+ str, 1);
+
+ /* Append character onto main buffer */
+ if (textInfo->bufSpot >= textInfo->bufAlloc)
+ /* Make room for more characters */
+ ExpandBuffer(textInfo);
+ textInfo->mainBuffer[(textInfo->bufSpot)++] =
+ (textInfo->curFont << FONTSHIFT) | (*str);
+
+ /* Update the line start array */
+ thisLine->lineLength += 1;
+ thisLine->lineWidth += charWidth;
+ } else if (*str == NEWLINE) {
+ HandleNewLine(display, textInfo, DODISP);
+ } else if (*str == NEWFONT) {
+ /* Go into waiting for font number mode */
+ textInfo->flagWord |= FONTNUMWAIT;
+ } else if (*str == BACKSPACE) {
+ HandleBackspace(display, textInfo, DODISP);
+ } else {
+ /* Ignore all others */
+ }
+ }
+ /* Draw the cursor in its new position */
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+
+ XFillRectangle(display, w, textInfo->CursorGC,
+ thisLine->lineWidth + CUROFFSET,
+ textInfo->curY /* + thisLine->lineHeight */,
+ CURSORWIDTH, thisLine->lineHeight);
+
+ return 1;
+}
+
+
+
+int TxtJamStr(display, w, str)
+Display *display;
+Window w; /* Text window */
+register char *str; /* NULL terminated string */
+/*
+ * This is the same as TxtWriteStr except the screen is NOT updated.
+ * After a call to this routine, TxtRepaint should be called to
+ * update the screen. This routine is meant to be used to load
+ * a text buffer with information and then allow the user to
+ * scroll through it at will.
+ */
+{
+ register int fontIndex;
+ register struct txtWin *textInfo;
+
+ if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)
+ ) == 0)
+ return 0;
+
+ for ( /* str is ok */ ; (*str != 0) ; str++) {
+ /* Check to see if we are waiting on a font */
+ if (textInfo->flagWord & FONTNUMWAIT) {
+ textInfo->flagWord &= (~FONTNUMWAIT);
+ fontIndex = *str - '0';
+ if ((fontIndex >= 0) && (fontIndex < MAXFONTS)) {
+ if (HandleNewFont(display, fontIndex, textInfo, 0)) {
+ /* Handled font -- go get next character */
+ continue;
+ }
+ }
+ }
+ /* Inline code for handling normal character case */
+ if ((*str >= LOWCHAR) && (*str <= HIGHCHAR)) {
+ register XFontStruct *thisFont;
+ register struct txtLine *thisLine;
+ register int charWidth;
+
+ /* Determine size of character */
+ thisFont = &(textInfo->theFonts[textInfo->curFont]);
+
+ if (*str <= thisFont->min_char_or_byte2 ||
+ *str >= thisFont->max_char_or_byte2 ||
+ thisFont->per_char == 0)
+ charWidth = thisFont->max_bounds.width + 1;
+ else
+ charWidth = thisFont->per_char[*str].width + 1;
+
+ /* Check to see if line wrap is required */
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+ if (thisLine->lineWidth + charWidth >
+ (textInfo->w-BARSIZE-WRAPINDSIZE))
+ {
+ thisLine->lineFlags |= WRAPFLAG;
+ /* Handle the spacing problem the same way as a newline */
+ HandleNewLine(display, textInfo, NONEWLINE);
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+ }
+ /* Append character onto main buffer */
+ if (textInfo->bufSpot >= textInfo->bufAlloc)
+ /* Make room for more characters */
+ ExpandBuffer(textInfo);
+ textInfo->mainBuffer[(textInfo->bufSpot)++] =
+ (textInfo->curFont << FONTSHIFT) | (*str);
+
+ /* Update the line start array */
+ thisLine->lineLength += 1;
+ thisLine->lineWidth += charWidth;
+ } else if (*str == NEWLINE) {
+ HandleNewLine(display, textInfo, 0);
+ } else if (*str == NEWFONT) {
+ /* Go into waiting for font number mode */
+ textInfo->flagWord |= FONTNUMWAIT;
+ } else if (*str == BACKSPACE) {
+ HandleBackspace(display, textInfo, 0);
+ } else {
+ /* Ignore all others */
+ }
+ }
+ textInfo->flagWord |= SCREENWRONG;
+ return 1;
+}
+
+
+
+int TxtRepaint(display,w)
+Display *display;
+Window w;
+/*
+ * Repaints the given scrollable text window. The routine repaints
+ * the entire window. For handling exposure events, the TxtFilter
+ * routine should be used.
+ */
+{
+ struct txtWin *textInfo;
+ int index, ypos;
+
+ if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)
+ ) == 0)
+ return 0;
+
+ /* Check to see if the screen is up to date */
+ if (textInfo->flagWord & SCREENWRONG) {
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ textInfo->flagWord &= (~SCREENWRONG);
+ }
+
+ ypos = YPADDING;
+ index = textInfo->startLine;
+ for (;;) {
+ DrawLine(display, textInfo, index, ypos);
+ if (index >= textInfo->endLine) break;
+ ypos += (textInfo->txtBuffer[index]->lineHeight + INTERLINE);
+ index++;
+ }
+ /* Draw the cursor (if on screen) */
+ if (textInfo->endLine == textInfo->curLine) {
+ XFillRectangle(display, w, textInfo->CursorGC,
+ textInfo->txtBuffer[index]->lineWidth + CUROFFSET,
+ ypos /* + textInfo->txtBuffer[index]->lineHeight */,
+ CURSORWIDTH, textInfo->txtBuffer[index]->lineHeight);
+
+ }
+ /* Update the scroll bar */
+ UpdateScroll(display, textInfo);
+ return 1;
+}
+
+
+
+static int InsertIndex(textInfo, thisIndex, ypos)
+struct txtWin *textInfo; /* Text Window Information */
+int thisIndex; /* Line index of exposed line */
+int ypos; /* Drawing position of line */
+/*
+ * This routine inserts the supplied line index into the copy
+ * exposure array for 'textInfo'. The array is kept sorted
+ * from lowest to highest using insertion sort. The array
+ * is dynamically expanded if needed.
+ */
+{
+ struct expEvent *newItem;
+ int newSize, index, downIndex;
+
+ /* Check to see if we need to expand it */
+ if ((textInfo->exposeSize + 3) >= textInfo->exposeAlloc) {
+ newSize = textInfo->exposeAlloc +
+ (textInfo->exposeAlloc * EXPANDPERCENT / 100);
+ textInfo->exposeAry = (struct expEvent **)
+ realloc((char *) textInfo->exposeAry,
+ (unsigned) (newSize * sizeof(struct expEvent *)));
+ for (index = textInfo->exposeAlloc; index < newSize; index++)
+ textInfo->exposeAry[index] = alloc(struct expEvent);
+ textInfo->exposeAlloc = newSize;
+ }
+ /* Find spot for insertion. NOTE: last spot has big number */
+ for (index = 0; index <= textInfo->exposeSize; index++) {
+ if (textInfo->exposeAry[index]->lineIndex >= thisIndex) {
+ if (textInfo->exposeAry[index]->lineIndex > thisIndex) {
+ /* Insert before this entry */
+ newItem = textInfo->exposeAry[textInfo->exposeSize+1];
+ for (downIndex = textInfo->exposeSize;
+ downIndex >= index;
+ downIndex--)
+ {
+ textInfo->exposeAry[downIndex+1] =
+ textInfo->exposeAry[downIndex];
+ }
+ /* Put a free structure at this spot */
+ textInfo->exposeAry[index] = newItem;
+ /* Fill it in */
+ textInfo->exposeAry[index]->lineIndex = thisIndex;
+ textInfo->exposeAry[index]->ypos = ypos;
+ /* Break out of loop */
+ textInfo->exposeSize += 1;
+ }
+ break;
+ }
+ }
+ return 1;
+}
+
+
+
+static int ScrollUp(display, textInfo)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+/*
+ * This routine scrolls the indicated text window up by one
+ * line. The line above the current line must exist. The
+ * window is scrolled so that the line above the start line
+ * is displayed at the top of the screen. This may cause
+ * many lines to scroll off the bottom. The scrolling is
+ * done using XCopyArea. The exposure events should be caught
+ * by ExposeCopy.
+ */
+{
+ int targetSpace;
+
+ /* Make sure all exposures have been handled by now */
+ if (textInfo->startLine == 0) return 0;
+ targetSpace = textInfo->txtBuffer[textInfo->startLine-1]->lineHeight +
+ INTERLINE;
+ /* Move the area downward by the target amount */
+ XCopyArea(display, textInfo->mainWindow, textInfo->mainWindow,
+ DEFAULT_GC,
+ 0, YPADDING, textInfo->w - BARSIZE,
+ textInfo->h, 0, targetSpace);
+
+ textInfo->flagWord |= COPYEXPOSE;
+ /* Update the text window parameters */
+ textInfo->startLine -= 1;
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+
+ /* Clear out bottom space region */
+ XClearArea(display, textInfo->mainWindow,
+ 0, textInfo->h - textInfo->bottomSpace,
+ textInfo->w, textInfo->bottomSpace);
+
+ UpdateExposures(display, textInfo);
+ UpdateScroll(display, textInfo);
+
+ return 1;
+}
+
+
+static int ScrollToSpot(display, textInfo, ySpot)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+int ySpot; /* Button position in scroll window */
+/*
+ * This routine scrolls the specified text window relative to the
+ * position of the mouse in the scroll bar. The center of the screen
+ * will be positioned to correspond to the mouse position.
+ */
+{
+ int targetLine, aboveLines;
+
+ targetLine = textInfo->numLines * ySpot / textInfo->h;
+ textInfo->startLine = targetLine;
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ aboveLines = 0;
+ /* Make the target line the *center* of the window */
+ while ((textInfo->startLine > 0) &&
+ (aboveLines < textInfo->endLine - targetLine))
+ {
+ textInfo->startLine -= 1;
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ aboveLines++;
+ }
+ if (textInfo->endLine == textInfo->numLines-1) {
+ WarpToBottom(display, textInfo);
+ } else {
+ XClearWindow(display, textInfo->mainWindow);
+ TxtRepaint(display, textInfo->mainWindow);
+ }
+ return 1;
+}
+
+
+
+static int LineToTop(display, textInfo, pos)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+int pos; /* Y position of mouse */
+/*
+ * This routine scrolls the screen down until the line at the
+ * mouse position is at the top of the screen. It stops
+ * if it can't scroll the buffer down that far. If the
+ * global 'ScrollOption' is NORMSCROLL, a smooth scroll
+ * is used. Otherwise, it jumps to the right position
+ * and repaints the screen.
+ */
+{
+ int index, sum;
+
+ /* First, we find the current line */
+ sum = 0;
+ for (index = textInfo->startLine; index <= textInfo->endLine; index++) {
+ if (sum + textInfo->txtBuffer[index]->lineHeight + INTERLINE> pos) break;
+ sum += textInfo->txtBuffer[index]->lineHeight + INTERLINE;
+ }
+ /* We always want to scroll down at least one line */
+ if (index == textInfo->startLine) index++;
+ if (ScrollOption == NORMSCROLL) {
+ /* Scroll down until 'index' is the starting line */
+ while ((textInfo->startLine < index) && ScrollDown(display, textInfo))
+ {
+ /* Empty Loop Body */
+ }
+ } else {
+ /* Immediately jump to correct spot */
+ textInfo->startLine = index;
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ if (textInfo->endLine == textInfo->numLines-1) {
+ WarpToBottom(display, textInfo);
+ } else {
+ XClearWindow(display, textInfo->mainWindow);
+ TxtRepaint(display, textInfo->mainWindow);
+ }
+ }
+ /* Check to see if at end of buffer */
+ if (textInfo->endLine >= textInfo->numLines-1) {
+ textInfo->flagWord &= (~NOTATBOTTOM);
+ }
+ return 1;
+}
+
+
+
+static int TopToHere(display, textInfo, pos)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+int pos; /* Y position of mouse */
+/*
+ * This routine scrolls the screen up until the top line of
+ * the screen is at the current Y position of the mouse. Again,
+ * it will stop if it can't scroll that far. If the global
+ * 'ScrollOption' is NORMSCROLL, a smooth scroll is used.
+ * If it's not, it will simply redraw the screen at the
+ * correct spot.
+ */
+{
+ int sum, target, linesup, index;
+
+ target = pos - textInfo->txtBuffer[textInfo->startLine]->lineHeight;
+ /* We always want to scroll up at least one line */
+ if (target <= 0) target = 1;
+ sum = 0;
+ linesup = 0;
+ /* Check to see if we are at the top anyway */
+ if (textInfo->startLine == 0) return 0;
+ if (ScrollOption == NORMSCROLL) {
+ /* Scroll up until sum of new top lines greater than target */
+ while ((sum < target) && ScrollUp(display, textInfo)) {
+ sum += textInfo->txtBuffer[textInfo->startLine]->lineHeight;
+ linesup++;
+ }
+ } else {
+ /* Search backward to find index */
+ index = textInfo->startLine - 1;
+ while ((index > 0) && (sum < target)) {
+ sum += textInfo->txtBuffer[index]->lineHeight;
+ linesup++;
+ index--;
+ }
+ /* Go directly to the index */
+ textInfo->startLine = index;
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ XClearWindow(display, textInfo->mainWindow);
+ TxtRepaint(display, textInfo->mainWindow);
+ }
+ /* If we scrolled, assert we are not at bottom of buffer */
+ if (linesup > 0) {
+ textInfo->flagWord |= NOTATBOTTOM;
+ }
+ return 1;
+}
+
+
+
+int TxtFilter(display, evt)
+Display *display;
+XEvent *evt;
+/*
+ * This routine handles events associated with scrollable text windows.
+ * It will handle all exposure events and any button released events
+ * in the scroll bar of a text window. It does NOT handle any other
+ * events. If it cannot handle the event, it will return 0.
+ */
+{
+ XExposeEvent *expose = &evt->xexpose;
+ XButtonEvent *btEvt = &evt->xbutton;
+ XGraphicsExposeEvent *gexpose = &evt->xgraphicsexpose;
+ XNoExposeEvent *noexpose = &evt->xnoexpose;
+ struct txtWin *textInfo;
+ int index, ypos;
+ Window w, sw;
+
+ if (textWindows == (XAssocTable *) 0) {
+ textWindows = XCreateAssocTable(32);
+ if (textWindows == (XAssocTable *) 0) return(0);
+ }
+ if (evt->type == Expose) {
+ w = expose->window;
+ sw = 0;
+ }
+ else if (evt->type == GraphicsExpose) {
+ w = gexpose->drawable;
+ sw = 0;
+ }
+ else if (evt->type == NoExpose) {
+ w = noexpose->drawable;
+ sw = 0;
+ }
+ else if (evt->type == ButtonRelease) {
+ w = btEvt->window;
+ sw = btEvt->subwindow;
+ }
+ else
+ return 0;
+
+ if ((textInfo = (struct txtWin *)
+ XLookUpAssoc(display, textWindows, (XID) w)) == 0)
+ return 0;
+
+ /* Determine whether it's main window or not */
+ if ((w == textInfo->mainWindow) && (sw == 0)) {
+ /* Main Window - handle exposures */
+ switch (evt->type) {
+ case Expose:
+ ypos = 0 /*YPADDING*/;
+ for (index = textInfo->startLine;
+ index <= textInfo->endLine;
+ index++)
+ {
+ int lh = textInfo->txtBuffer[index]->lineHeight;
+
+ if (((ypos + lh) >= expose->y) &&
+ (ypos <= (expose->y + expose->height)))
+ {
+ /* Intersection region */
+ /* Draw line immediately */
+ DrawLine(display, textInfo, index, ypos);
+ /* And possibly draw cursor */
+ if (textInfo->curLine == index) {
+ XFillRectangle(display, w, textInfo->CursorGC,
+ textInfo->txtBuffer[index]->lineWidth +
+ CUROFFSET,
+ ypos,
+ CURSORWIDTH,
+ lh);
+ }
+ }
+ ypos += lh + INTERLINE;
+ }
+ break;
+ case GraphicsExpose:
+ ypos = 0 /*YPADDING*/;
+ for (index = textInfo->startLine;
+ index <= textInfo->endLine;
+ index++)
+ {
+ int lh = textInfo->txtBuffer[index]->lineHeight;
+
+ if (((ypos + lh) >= gexpose->y) &&
+ (ypos <= (gexpose->y + gexpose->height)))
+ {
+ /* Intersection region */
+ /* Draw line immediately */
+ DrawLine(display, textInfo, index, ypos);
+ /* And possibly draw cursor */
+ if (textInfo->curLine == index) {
+ XFillRectangle(display, w, textInfo->CursorGC,
+ textInfo->txtBuffer[index]->lineWidth +
+ CUROFFSET,
+ ypos,
+ CURSORWIDTH,
+ lh);
+ }
+ }
+ ypos += lh + INTERLINE;
+ }
+ break;
+ case NoExpose:
+ break;
+ default:
+ /* Not one of our events */
+ return 0;
+ }
+ } else {
+ switch (evt->type) {
+ case Expose:
+ UpdateScroll(display, textInfo);
+ break;
+ case ButtonRelease:
+ /* Find out which button */
+ switch (btEvt->button) {
+ case Button1:
+ /* Scroll up until top line is at mouse position */
+ TopToHere(display, textInfo, btEvt->y);
+ break;
+ case Button2:
+ /* Scroll to spot relative to position */
+ ScrollToSpot(display, textInfo, btEvt->y);
+ if (textInfo->endLine >= textInfo->numLines-1) {
+ textInfo->flagWord &= (~NOTATBOTTOM);
+ } else {
+ textInfo->flagWord |= NOTATBOTTOM;
+ }
+ break;
+ case Button3:
+ /* Scroll down until pointed line is at top */
+ LineToTop(display, textInfo, btEvt->y);
+ break;
+ }
+ break;
+ default:
+ /* Not one of our events */
+ return 0;
+ }
+ }
+ return 1;
+}
diff --git a/gnu/games/chess/Xchess/scrollText.h b/gnu/games/chess/Xchess/scrollText.h
new file mode 100644
index 000000000000..d9d05b08dc0b
--- /dev/null
+++ b/gnu/games/chess/Xchess/scrollText.h
@@ -0,0 +1,32 @@
+/*
+ * Scrollable Text Window Header File
+ *
+ * David Harrison
+ * University of California, Berkeley
+ * 1986
+ *
+ * This file contains definitions for a scrollable text window
+ * with scroll bar support.
+ */
+
+int TxtGrab();
+ /* Take hold of a previously created window */
+
+#define TXT_NO_COLOR -1
+
+int TxtAddFont();
+ /* Loads a new font for use later */
+int TxtWinP();
+ /* Returns non-zero value if the window is text window */
+int TxtClear();
+ /* Clears text window and resets text buffer */
+
+int TxtWriteStr();
+ /* Writes a string to window with immediate update */
+int TxtJamStr();
+ /* Write a string without causing update to screen */
+
+int TxtRepaint();
+ /* Repaints entire scrollable text window */
+int TxtFilter();
+ /* Handles events related to text window */
diff --git a/gnu/games/chess/Xchess/scrollText/scrollText.c b/gnu/games/chess/Xchess/scrollText/scrollText.c
new file mode 100644
index 000000000000..432071086d15
--- /dev/null
+++ b/gnu/games/chess/Xchess/scrollText/scrollText.c
@@ -0,0 +1,1858 @@
+/*
+ * A Scrollable Text Output Window
+ *
+ * David Harrison
+ * University of California, Berkeley
+ * 1986
+ *
+ * The following is an implementation for a scrollable text output
+ * system. It handles exposure events only (other interactions are
+ * under user control). For scrolling, a always present scroll bar
+ * is implemented. It detects size changes and compensates accordingly.
+ */
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/X10.h>
+#include <sys/types.h>
+#include "scrollText.h"
+
+extern char *malloc();
+extern char *realloc();
+#define alloc(type) (type *) malloc(sizeof(type))
+#define numalloc(type, num) (type *) malloc((unsigned) (num * sizeof(type)))
+#define MAXINT 2147483647
+
+extern XAssocTable *XCreateAssocTable();
+extern caddr_t XLookUpAssoc();
+
+static XAssocTable *textWindows = (XAssocTable *) 0;
+
+#define NOOPTION -1 /* Option hasn't been set yet */
+#define NORMSCROLL 0 /* Smooth scroll on LineToTop and TopToHere */
+#define JUMPSCROLL 1 /* Jump scrolling on LineToTop and TopToHere */
+
+static int ScrollOption = NOOPTION;
+
+typedef char *Generic;
+
+#define DEFAULT_GC textInfo->fontGC[textInfo->curFont]
+
+#define BARSIZE 15
+#define BARBORDER 1
+#define MAXFONTS 8
+#define INITBUFSIZE 1024
+#define INITLINES 50
+#define INITEXPARY 50
+#define XPADDING 2
+#define YPADDING 2
+#define INTERLINE 5
+#define INTERSPACE 1
+#define CURSORWIDTH 2
+#define EXPANDPERCENT 40
+#define BUFSIZE 1024
+#define CUROFFSET 1
+#define MAXFOREIGN 250
+#define NOINDEX -1
+
+/* The wrap line indicator */
+#define WRAPINDSIZE 7
+#define STEMOFFSET 5
+#define arrow_width 7
+#define arrow_height 5
+static char arrow_bits[] = {
+ 0x24, 0x26, 0x3f, 0x06, 0x04};
+
+#define NEWLINE '\n'
+#define BACKSPACE '\010'
+#define NEWFONT '\006'
+#define LOWCHAR '\040'
+#define HIGHCHAR '\176'
+
+#define CHARMASK 0x00ff /* Character mask */
+#define FONTMASK 0x0700 /* Character font */
+#define FONTSHIFT 8 /* Shift amount */
+
+#define WRAPFLAG 0x01 /* Line wrap flag */
+
+/*
+ * Lines are represented by a pointer into the overall array of
+ * 16-bit characters. The lower eight bits is used to indicate the character
+ * (in ASCII), and the next two bits are used to indicate the font
+ * the character should be drawn in.
+ */
+
+typedef struct txtLine {
+ int lineLength; /* Current line length */
+ int lineHeight; /* Full height of line in pixels */
+ int lineBaseLine; /* Current baseline of the line */
+ int lineWidth; /* Drawing position at end of line */
+ int lineText; /* Offset into master buffer */
+ int lineFlags; /* Line wrap flag is here */
+};
+
+
+/*
+ * For ExposeCopy events, we queue up the redraw requests collapsing
+ * them into line redraw requests until the CopyExpose event arrives.
+ * The queue is represented as a dynamic array of the following
+ * structure:
+ */
+
+typedef struct expEvent {
+ int lineIndex; /* Index of line to redraw */
+ int ypos; /* Drawing position of line */
+};
+
+
+/*
+ * The text buffer is represented using a dynamic counted array
+ * of 16-bit quantities. This array expands as needed.
+ * For the screen representation, a dynamic counted array
+ * of line structures is used. This array points into the
+ * text buffer to denote the start of each line and its parameters.
+ * The windows are configured as one overall window which contains
+ * the scroll bar as a sub-window along its right edge. Thus,
+ * the text drawing space is actually w-BARSIZE.
+ */
+
+#define NOTATBOTTOM 0x01 /* Need to scroll to bottom before appending */
+#define FONTNUMWAIT 0x02 /* Waiting for font number */
+#define COPYEXPOSE 0x04 /* Need to process a copy expose event */
+#define SCREENWRONG 0x08 /* TxtJamStr has invalidated screen contents */
+
+typedef struct txtWin {
+ /* Basic text buffer */
+ int bufAlloc; /* Allocated size of buffer */
+ int bufSpot; /* Current writing position in buffer */
+ short *mainBuffer; /* Main buffer of text */
+
+ /* Line information */
+ int numLines; /* Number of display lines in buffer */
+ int allocLines; /* Number of lines allocated */
+ struct txtLine **txtBuffer; /* Dynamic array of lines */
+
+ /* Current Window display information */
+ Window mainWindow; /* Text display window */
+ Window scrollBar; /* Subwindow for scroll bar */
+ Pixmap arrowMap; /* line wrap indicator */
+ int bgPix, fgPix; /* Background and cursor */
+ GC CursorGC; /* gc for the cursor */
+ GC bgGC; /* gc for erasing things */
+ GC fontGC[MAXFONTS]; /* gc for doing fonts */
+ XFontStruct theFonts[MAXFONTS];/* Display fonts */
+ int theColors[MAXFONTS]; /* foregrounds of the fonts */
+ int curFont; /* current font for tracking */
+ int w, h; /* Current size */
+ int startLine; /* Top line in display */
+ int endLine; /* Bottom line in display */
+ int bottomSpace; /* Space at bottom of screen */
+ int flagWord; /* If non-zero, not at end */
+
+ /* For handling ExposeCopy events */
+ int exposeSize; /* Current size of array */
+ int exposeAlloc; /* Allocated size */
+ struct expEvent **exposeAry;/* Array of line indices */
+
+ /* Drawing position information */
+ int curLine; /* Current line in buffer */
+ int curX; /* Current horizontal positi */
+ int curY; /* Current vertical drawing */
+};
+
+/* Flags for the various basic character handling functions */
+
+#define DODISP 0x01 /* Update the display */
+#define NONEWLINE 0x02 /* Dont append newline */
+
+
+
+static int InitLine(newLine)
+struct txtLine *newLine; /* Newly created line structure */
+/*
+ * This routine initializes a newly created line structure.
+ */
+{
+ newLine->lineLength = 0;
+ newLine->lineHeight = 0;
+ newLine->lineBaseLine = 0;
+ newLine->lineWidth = XPADDING;
+ newLine->lineText = NOINDEX;
+ newLine->lineFlags = 0;
+ return 1;
+}
+
+
+
+
+int TxtGrab(display, txtWin, program, mainFont, bg, fg, cur)
+Display *display; /* display window is on */
+Window txtWin; /* Window to take over as scrollable text */
+char *program; /* Program name for Xdefaults */
+XFontStruct *mainFont; /* Primary text font */
+int bg, fg, cur; /* Background, foreground, and cursor colors */
+/*
+ * This routine takes control of 'txtWin' and makes it into a scrollable
+ * text output window. It will create a sub-window for the scroll bar
+ * with a background of 'bg' and an bar with color 'fg'. Both fixed width
+ * and variable width fonts are supported. Additional fonts can be loaded
+ * using 'TxtAddFont'. Returns 0 if there were problems, non-zero if
+ * everything went ok.
+ */
+{
+ struct txtWin *newWin; /* Text package specific information */
+ XWindowAttributes winInfo; /* Window information */
+ int index;
+ XGCValues gc_val;
+
+ if (textWindows == (XAssocTable *) 0) {
+ textWindows = XCreateAssocTable(32);
+ if (textWindows == (XAssocTable *) 0) return(0);
+ }
+ if (XGetWindowAttributes(display, txtWin, &winInfo) == 0) return 0;
+
+ if (ScrollOption == NOOPTION) {
+ /* Read to see if the user wants jump scrolling or not */
+ if (XGetDefault(display, program, "JumpScroll")) {
+ ScrollOption = JUMPSCROLL;
+ } else {
+ ScrollOption = NORMSCROLL;
+ }
+ }
+
+ /* Initialize local structure */
+ newWin = alloc(struct txtWin);
+
+ /* Initialize arrow pixmap */
+ newWin->arrowMap = XCreatePixmapFromBitmapData(display, txtWin,
+ arrow_bits,
+ arrow_width, arrow_height,
+ cur, bg,
+ DisplayPlanes(display, 0));
+
+ newWin->bufAlloc = INITBUFSIZE;
+ newWin->bufSpot = 0;
+ newWin->mainBuffer = numalloc(short, INITBUFSIZE);
+
+ newWin->numLines = 1;
+ newWin->allocLines = INITLINES;
+ newWin->txtBuffer = numalloc(struct txtLine *, INITLINES);
+ for (index = 0; index < INITLINES; index++) {
+ newWin->txtBuffer[index] = alloc(struct txtLine);
+ InitLine(newWin->txtBuffer[index]);
+ }
+
+ /* Window display information */
+ newWin->mainWindow = txtWin;
+ newWin->w = winInfo.width;
+ newWin->h = winInfo.height;
+ newWin->startLine = 0;
+ newWin->endLine = 0;
+ newWin->bottomSpace = winInfo.height
+ - YPADDING - mainFont->ascent - mainFont->descent - INTERLINE;
+ newWin->flagWord = 0;
+ newWin->bgPix = bg;
+ newWin->fgPix = fg;
+
+ /* Scroll Bar Creation */
+ newWin->scrollBar = XCreateSimpleWindow(display, txtWin,
+ winInfo.width - BARSIZE,
+ 0, BARSIZE - (2*BARBORDER),
+ winInfo.height - (2*BARBORDER),
+ BARBORDER,
+ fg, bg);
+ XSelectInput(display, newWin->scrollBar, ExposureMask|ButtonReleaseMask);
+ XMapRaised(display, newWin->scrollBar);
+
+ /* Font and Color Initialization */
+ newWin->theFonts[0] = *mainFont;
+ newWin->theColors[0] = fg;
+ gc_val.function = GXcopy;
+ gc_val.plane_mask = AllPlanes;
+ gc_val.foreground = fg;
+ gc_val.background = bg;
+ gc_val.graphics_exposures = 1;
+ gc_val.font = mainFont->fid;
+ gc_val.line_width = 1;
+ gc_val.line_style = LineSolid;
+
+ newWin->fontGC[0] = XCreateGC(display, txtWin,
+ GCFunction | GCPlaneMask |
+ GCForeground | GCBackground |
+ GCGraphicsExposures | GCFont,
+ &gc_val);
+
+ gc_val.foreground = cur;
+ newWin->CursorGC = XCreateGC(display, txtWin,
+ GCFunction | GCPlaneMask |
+ GCForeground | GCBackground |
+ GCLineStyle | GCLineWidth,
+ &gc_val);
+
+ gc_val.foreground = bg;
+ newWin->bgGC = XCreateGC(display, txtWin,
+ GCFunction | GCPlaneMask |
+ GCForeground | GCBackground |
+ GCGraphicsExposures | GCFont,
+ &gc_val);
+
+
+ for (index = 1; index < MAXFONTS; index++) {
+ newWin->theFonts[index].fid = 0;
+ newWin->fontGC[index] = 0;
+ }
+
+
+ /* Initialize size of first line */
+ newWin->txtBuffer[0]->lineHeight = newWin->theFonts[0].ascent +
+ newWin->theFonts[0].descent;
+ newWin->txtBuffer[0]->lineText = 0;
+
+ /* ExposeCopy array initialization */
+ newWin->exposeSize = 0;
+ newWin->exposeAlloc = INITEXPARY;
+ newWin->exposeAry = numalloc(struct expEvent *, INITEXPARY);
+ for (index = 0; index < newWin->exposeAlloc; index++)
+ newWin->exposeAry[index] = alloc(struct expEvent);
+ /* Put plus infinity in last slot for sorting purposes */
+ newWin->exposeAry[0]->lineIndex = MAXINT;
+
+ /* Drawing Position Information */
+ newWin->curLine = 0;
+ newWin->curX = 0;
+ newWin->curY = YPADDING + mainFont->ascent + mainFont->descent;
+
+ /* Attach it to both windows */
+ XMakeAssoc(display, textWindows, (XID) txtWin, (caddr_t) newWin);
+ XMakeAssoc(display, textWindows, (XID) newWin->scrollBar, (caddr_t) newWin);
+ return 1;
+}
+
+
+int TxtRelease(display, w)
+Display *display;
+Window w; /* Window to release */
+/*
+ * This routine releases all resources associated with the
+ * specified window which are consumed by the text
+ * window package. This includes the entire text buffer, line start
+ * array, and the scroll bar window. However, the window
+ * itself is NOT destroyed. The routine will return zero if
+ * the window is not owned by the text window package.
+ */
+{
+ struct txtWin *textInfo;
+ int index;
+
+ if ((textInfo = (struct txtWin *) XLookUpAssoc(display,
+ textWindows, (XID) w)) == 0)
+ return 0;
+
+ for (index = 0; index < MAXFONTS; index++)
+ if (textInfo->fontGC[index] != 0)
+ XFreeGC(display, textInfo->fontGC[index]);
+
+ free((Generic) textInfo->mainBuffer);
+ for (index = 0; index < textInfo->numLines; index++) {
+ free((Generic) textInfo->txtBuffer[index]);
+ }
+ free((Generic) textInfo->txtBuffer);
+ XDestroyWindow(display, textInfo->scrollBar);
+ for (index = 0; index < textInfo->exposeSize; index++) {
+ free((Generic) textInfo->exposeAry[index]);
+ }
+ free((Generic) textInfo->exposeAry);
+ XDeleteAssoc(display, textWindows, (XID) w);
+ free((Generic) textInfo);
+ return 1;
+}
+
+
+
+static int RecompBuffer(textInfo)
+struct txtWin *textInfo; /* Text window information */
+/*
+ * This routine recomputes all line breaks in a buffer after
+ * a change in window size or font. This is done by throwing
+ * away the old line start array and recomputing it. Although
+ * a lot of this work is also done elsewhere, it has been included
+ * inline here for efficiency.
+ */
+{
+ int startPos, endSize, linenum;
+ register int index, chsize, curfont;
+ register short *bufptr;
+ register XFontStruct *fontptr;
+ register struct txtLine *lineptr;
+ char theChar;
+
+ /* Record the old position so we can come back to it */
+ for (startPos = textInfo->txtBuffer[textInfo->startLine]->lineText;
+ (startPos > 0) && (textInfo->mainBuffer[startPos] != '\n');
+ startPos--)
+ /* null loop body */;
+
+ /* Clear out the old line start array */
+ for (index = 0; index < textInfo->numLines; index++) {
+ InitLine(textInfo->txtBuffer[index]);
+ }
+
+ /* Initialize first line */
+ textInfo->txtBuffer[0]->lineHeight =
+ textInfo->theFonts[0].ascent + textInfo->theFonts[0].descent;
+ textInfo->txtBuffer[0]->lineText = 0;
+
+ /* Process the text back into lines */
+ endSize = textInfo->w - BARSIZE - WRAPINDSIZE;
+ bufptr = textInfo->mainBuffer;
+ lineptr = textInfo->txtBuffer[0];
+ linenum = 0;
+ fontptr = &(textInfo->theFonts[0]);
+ curfont = 0;
+ for (index = 0; index < textInfo->bufSpot; index++) {
+ theChar = bufptr[index] & CHARMASK;
+
+ if ((bufptr[index] & FONTMASK) != curfont) {
+ int newFontNum, heightDiff;
+
+ /* Switch fonts */
+ newFontNum = (bufptr[index] & FONTMASK) >> FONTSHIFT;
+ if (textInfo->theFonts[newFontNum].fid != 0) {
+ /* Valid font */
+ curfont = bufptr[index] & FONTMASK;
+ fontptr = &(textInfo->theFonts[newFontNum]);
+ heightDiff = (fontptr->ascent + fontptr->descent) -
+ lineptr->lineHeight;
+ if (heightDiff < 0) heightDiff = 0;
+ lineptr->lineHeight += heightDiff;
+ }
+ }
+ if (theChar == '\n') {
+ /* Handle new line */
+ if (linenum >= textInfo->allocLines-1)
+ /* Expand number of lines */
+ ExpandLines(textInfo);
+ linenum++;
+ lineptr = textInfo->txtBuffer[linenum];
+ /* Initialize next line */
+ lineptr->lineHeight = fontptr->ascent + fontptr->descent;
+ lineptr->lineText = index+1;
+ /* Check to see if its the starting line */
+ if (index == startPos) textInfo->startLine = linenum;
+ } else {
+ /* Handle normal character */
+ chsize = CharSize(textInfo, linenum, index);
+ if (lineptr->lineWidth + chsize > endSize) {
+ /* Handle line wrap */
+ lineptr->lineFlags |= WRAPFLAG;
+ if (linenum >= textInfo->allocLines-1)
+ /* Expand number of lines */
+ ExpandLines(textInfo);
+ linenum++;
+ lineptr = textInfo->txtBuffer[linenum];
+ /* Initialize next line */
+ lineptr->lineHeight = fontptr->ascent + fontptr->descent;
+ lineptr->lineText = index;
+ lineptr->lineLength = 1;
+ lineptr->lineWidth += chsize;
+ } else {
+ /* Handle normal addition of character */
+ lineptr->lineLength += 1;
+ lineptr->lineWidth += chsize;
+ }
+ }
+ }
+ /* We now have a valid line array. Let's clean up some other fields. */
+ textInfo->numLines = linenum+1;
+ if (startPos == 0) {
+ textInfo->startLine = 0;
+ }
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ textInfo->curLine = linenum;
+ /* Check to see if we are at the bottom */
+ if (textInfo->endLine >= textInfo->numLines-1) {
+ textInfo->curY = textInfo->h - textInfo->bottomSpace -
+ lineptr->lineHeight;
+ textInfo->flagWord &= (~NOTATBOTTOM);
+ } else {
+ textInfo->flagWord |= NOTATBOTTOM;
+ }
+ return 1;
+}
+
+
+
+
+int TxtAddFont(display, textWin, fontNumber, newFont, newColor)
+Display *display;
+Window textWin; /* Scrollable text window */
+int fontNumber; /* Place to add font (0-7) */
+XFontStruct *newFont; /* Font to add */
+int newColor; /* Color of font */
+/*
+ * This routine loads a new font so that it can be used in a previously
+ * created text window. There are eight font slots numbered 0 through 7.
+ * If there is already a font in the specified slot, it will be replaced
+ * and an automatic redraw of the window will take place. See TxtWriteStr
+ * for details on using alternate fonts. The color specifies the foreground
+ * color of the text. The default foreground color is used if this
+ * parameter is TXT_NO_COLOR. Returns a non-zero value if
+ * everything went well.
+ */
+{
+ struct txtWin *textInfo;
+ int redrawFlag;
+ XGCValues gc_val;
+
+ if ((fontNumber < 0) || (fontNumber >= MAXFONTS)) return 0;
+ if ((textInfo = (struct txtWin *)
+ XLookUpAssoc(display, textWindows, (XID) textWin)) == 0)
+ return 0;
+ if (newColor == TXT_NO_COLOR) {
+ newColor = textInfo->fgPix;
+ }
+
+ gc_val.font = newFont->fid;
+ gc_val.foreground = newColor;
+ gc_val.background = textInfo->bgPix;
+ gc_val.plane_mask = AllPlanes;
+ gc_val.graphics_exposures = 1;
+ gc_val.function = GXcopy;
+
+ if (textInfo->fontGC[fontNumber] != 0)
+ {
+ XChangeGC(display, textInfo->fontGC[fontNumber],
+ GCFont | GCForeground, &gc_val);
+ }
+ else
+ textInfo->fontGC[fontNumber] = XCreateGC(display, textWin,
+ GCFont |
+ GCForeground |
+ GCBackground |
+ GCFunction |
+ GCPlaneMask |
+ GCGraphicsExposures,
+ &gc_val);
+
+
+ redrawFlag = (textInfo->theFonts[fontNumber].fid != 0) &&
+ (((newFont) && (newFont->fid != textInfo->theFonts[fontNumber].fid)) ||
+ (newColor != textInfo->theColors[fontNumber]));
+ if (newFont) {
+ textInfo->theFonts[fontNumber] = *newFont;
+ }
+ textInfo->theColors[fontNumber] = newColor;
+
+ if (redrawFlag) {
+ RecompBuffer(textInfo);
+ XClearWindow(display, textWin);
+ TxtRepaint(display, textWin);
+ }
+ return 1;
+}
+
+
+
+int TxtWinP(display, w)
+Display *display;
+Window w;
+/*
+ * Returns a non-zero value if the window has been previously grabbed
+ * using TxtGrab and 0 if it has not.
+ */
+{
+ if (XLookUpAssoc(display, textWindows, (XID) w))
+ return(1);
+ else return(0);
+}
+
+
+
+static int FindEndLine(textInfo, botSpace)
+struct txtWin *textInfo;
+int *botSpace;
+/*
+ * Given the starting line in 'textInfo->startLine', this routine
+ * determines the index of the last line that can be drawn given the
+ * current size of the screen. If there are not enough lines to
+ * fill the screen, the index of the last line will be returned.
+ * The amount of empty bottom space is returned in 'botSpace'.
+ */
+{
+ int index, height, lineHeight;
+
+ height = YPADDING;
+ index = textInfo->startLine;
+ while (index < textInfo->numLines) {
+ lineHeight = textInfo->txtBuffer[index]->lineHeight + INTERLINE;
+ if (height + lineHeight > textInfo->h) break;
+ height += lineHeight;
+ index++;
+ }
+ if (botSpace) {
+ *botSpace = textInfo->h - height;
+ }
+ return index - 1;
+}
+
+
+
+static int UpdateScroll(display, textInfo)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+/*
+ * This routine computes the current extent of the scroll bar
+ * indicator and repaints the bar with the correct information.
+ */
+{
+ int top, bottom;
+
+ if (textInfo->numLines > 1) {
+ top = textInfo->startLine * (textInfo->h - 2*BARBORDER) /
+ (textInfo->numLines - 1);
+ bottom = textInfo->endLine * (textInfo->h - 2*BARBORDER) /
+ (textInfo->numLines - 1);
+ } else {
+ top = 0;
+ bottom = textInfo->h - (2*BARBORDER);
+ }
+
+ /* Draw it - make sure there is a little padding */
+ if (top == 0) top++;
+ if (bottom == textInfo->h-(2*BARBORDER)) bottom--;
+
+ XFillRectangle(display, textInfo->scrollBar,
+ textInfo->bgGC,
+ 0, 0, BARSIZE, top-1);
+ XFillRectangle(display, textInfo->scrollBar,
+ DEFAULT_GC, top, BARSIZE - (2*BARBORDER) - 2,
+ bottom - top);
+ XFillRectangle(display, textInfo->scrollBar, DEFAULT_GC,
+ 0, bottom+1, BARSIZE,
+ textInfo->h - (2 * BARBORDER) - bottom);
+
+ return 1;
+}
+
+
+
+
+int TxtClear(display, w)
+Display *display;
+Window w;
+/*
+ * This routine clears a scrollable text window. It resets the current
+ * writing position to the upper left hand corner of the screen.
+ * NOTE: THIS ALSO CLEARS THE CONTENTS OF THE TEXT WINDOW BUFFER AND
+ * RESETS THE SCROLL BAR. Returns 0 if the window is not a text window.
+ * This should be used *instead* of XClear.
+ */
+{
+ struct txtWin *textInfo;
+ int index;
+
+ if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)) == 0)
+ return 0;
+
+ /* Zero out the arrays */
+ textInfo->bufSpot = 0;
+ for (index = 0; index < textInfo->numLines; index++) {
+ InitLine(textInfo->txtBuffer[index]);
+ }
+ textInfo->txtBuffer[0]->lineHeight =
+ textInfo->theFonts[textInfo->curFont].ascent +
+ textInfo->theFonts[textInfo->curFont].descent;
+
+ textInfo->numLines = 1;
+ textInfo->startLine = 0;
+ textInfo->endLine = 0;
+ textInfo->curLine = 0;
+ textInfo->curX = 0;
+ textInfo->curY = YPADDING + textInfo->theFonts[textInfo->curFont].ascent
+ + textInfo->theFonts[textInfo->curFont].descent;
+
+ textInfo->bottomSpace = textInfo->h - YPADDING -
+ textInfo->theFonts[textInfo->curFont].ascent - INTERLINE -
+ textInfo->theFonts[textInfo->curFont].descent;
+ /* Actually clear the window */
+ XClearWindow(display, w);
+
+ /* Draw the current cursor */
+ XFillRectangle(display, w, textInfo->CursorGC,
+ XPADDING + CUROFFSET, textInfo->curY,
+ CURSORWIDTH,
+ textInfo->theFonts[textInfo->curFont].ascent +
+ textInfo->theFonts[textInfo->curFont].descent);
+
+ /* Update the scroll bar */
+ UpdateScroll(display, textInfo);
+ return 1;
+}
+
+
+static int WarpToBottom(display, textInfo)
+Display *display;
+struct txtWin *textInfo; /* Text Information */
+/*
+ * This routine causes the specified text window to display its
+ * last screen of information. It updates the scroll bar
+ * to the appropriate spot. The implementation scans backward
+ * through the buffer to find an appropriate starting spot for
+ * the window.
+ */
+{
+ int index, height, lineHeight;
+
+ index = textInfo->numLines-1;
+ height = 0;
+ while (index >= 0) {
+ lineHeight = textInfo->txtBuffer[index]->lineHeight + INTERLINE;
+ if (height + lineHeight > textInfo->h) break;
+ height += lineHeight;
+ index--;
+ }
+ textInfo->startLine = index + 1;
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ textInfo->curY = textInfo->h - textInfo->bottomSpace -
+ textInfo->txtBuffer[textInfo->endLine]->lineHeight;
+ XClearWindow(display, textInfo->mainWindow);
+ TxtRepaint(display, textInfo->mainWindow);
+ return 1;
+}
+
+
+
+static int UpdateExposures(display, textInfo)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+/*
+ * Before a new scrolling action occurs, the text window package
+ * must handle all COPYEXPOSE events generated by the last scrolling
+ * action. This routine is called to do this. Foreign events (those
+ * not handled by TxtFilter) are queued up and replaced on the queue
+ * after the processing of the exposure events is complete.
+ */
+{
+#if 0
+ XEvent foreignQueue[MAXFOREIGN];
+ int index, lastItem = 0;
+
+ while (textInfo->flagWord & COPYEXPOSE) {
+ XNextEvent(display, &(foreignQueue[lastItem]));
+ if (!TxtFilter(display, &(foreignQueue[lastItem])))
+ lastItem++;
+ if (lastItem >= MAXFOREIGN) {
+ printf("Too many foreign events to queue!\n");
+ textInfo->flagWord &= (~COPYEXPOSE);
+ }
+ }
+ for (index = 0; index < lastItem; index++) {
+ XPutBackEvent(display, &(foreignQueue[index]));
+ }
+#endif
+ return 1;
+}
+
+
+static int ScrollDown(display,textInfo)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+/*
+ * This routine scrolls the indicated text window down by one
+ * line. The line below the current line must exist. The window
+ * is scrolled so that the line below the last line is fully
+ * displayed. This may cause many lines to scroll off the top.
+ * Scrolling is done using XCopyArea. The exposure events should
+ * be caught using ExposeCopy.
+ */
+{
+ int lineSum, index, targetSpace, freeSpace, updateFlag;
+
+ lineSum = 0;
+ if (textInfo->endLine + 1 >= textInfo->numLines) return 0;
+ targetSpace = textInfo->txtBuffer[textInfo->endLine+1]->lineHeight +
+ INTERLINE;
+ if (textInfo->bottomSpace < targetSpace) {
+ index = textInfo->startLine;
+ while (index < textInfo->endLine) {
+ lineSum += (textInfo->txtBuffer[index]->lineHeight + INTERLINE);
+ if (textInfo->bottomSpace + lineSum >= targetSpace) break;
+ index++;
+ }
+
+ /* Must move upward by 'lineSum' pixels */
+ XCopyArea(display, textInfo->mainWindow, textInfo->mainWindow,
+ DEFAULT_GC, 0, lineSum,
+ textInfo->w - BARSIZE, textInfo->h,
+ 0, 0);
+
+ textInfo->flagWord |= COPYEXPOSE;
+ /* Repair the damage to the structures */
+ textInfo->startLine = index + 1;
+ updateFlag = 1;
+ } else {
+ updateFlag = 0;
+ }
+ /* More lines might be able to fit. Let's check. */
+ freeSpace = textInfo->bottomSpace + lineSum - targetSpace;
+ index = textInfo->endLine + 1;
+ while (index < textInfo->numLines-1) {
+ if (freeSpace - textInfo->txtBuffer[index+1]->lineHeight - INTERLINE < 0)
+ break;
+ freeSpace -= (textInfo->txtBuffer[index+1]->lineHeight + INTERLINE);
+ index++;
+ }
+ textInfo->endLine = index;
+ textInfo->bottomSpace = freeSpace;
+ if (updateFlag) {
+ UpdateExposures(display, textInfo);
+ }
+ UpdateScroll(display, textInfo);
+ return 1;
+}
+
+
+
+
+static int ExpandLines(textInfo)
+struct txtWin *textInfo; /* Text Information */
+/*
+ * This routine allocates and initializes additional space in
+ * the line start array (txtBuffer). The new space
+ * is allocated using realloc. The expansion factor is a percentage
+ * given by EXPANDPERCENT.
+ */
+{
+ int newSize, index;
+
+ newSize = textInfo->allocLines;
+ newSize += (newSize * EXPANDPERCENT) / 100;
+
+ textInfo->txtBuffer = (struct txtLine **)
+ realloc((char *) textInfo->txtBuffer,
+ (unsigned) (newSize * sizeof(struct txtLine *)));
+ for (index = textInfo->allocLines; index < newSize; index++) {
+ textInfo->txtBuffer[index] = alloc(struct txtLine);
+ InitLine(textInfo->txtBuffer[index]);
+ }
+ textInfo->allocLines = newSize;
+ return 1;
+}
+
+static int ExpandBuffer(textInfo)
+struct txtWin *textInfo; /* Text information */
+/*
+ * Expands the basic character buffer using realloc. The expansion
+ * factor is a percentage given by EXPANDPERCENT.
+ */
+{
+ int newSize;
+
+ newSize = textInfo->bufAlloc + (textInfo->bufAlloc * EXPANDPERCENT) / 100;
+ textInfo->mainBuffer = (short *)
+ realloc((char *) textInfo->mainBuffer, (unsigned) newSize * sizeof(short));
+ textInfo->bufAlloc = newSize;
+ return 1;
+}
+
+
+
+static int HandleNewLine(display, textInfo, flagWord)
+Display *display;
+struct txtWin *textInfo; /* Text Information */
+int flagWord; /* DODISP or NONEWLINE or both */
+/*
+ * This routine initializes the next line for drawing by setting
+ * its height to the current font height, scrolls the screen down
+ * one line, and updates the current drawing position to the
+ * left edge of the newly cleared line. If DODISP is specified,
+ * the screen will be updated (otherwise not). If NONEWLINE is
+ * specified, no newline character will be added to the text buffer
+ * (this is for line wrap).
+ */
+{
+ struct txtLine *curLine, *nextLine;
+
+ /* Check to see if a new line must be allocated */
+ if (textInfo->curLine >= textInfo->allocLines-1)
+ /* Expand the number of lines */
+ ExpandLines(textInfo);
+ textInfo->numLines += 1;
+
+ /* Then we initialize the next line */
+ nextLine = textInfo->txtBuffer[textInfo->numLines-1];
+ nextLine->lineHeight =
+ textInfo->theFonts[textInfo->curFont].ascent +
+ textInfo->theFonts[textInfo->curFont].descent;
+
+ curLine = textInfo->txtBuffer[textInfo->curLine];
+ if (flagWord & DODISP) {
+ /* Scroll down a line if required */
+ if ((textInfo->curY + curLine->lineHeight +
+ nextLine->lineHeight + (INTERLINE * 2)) > textInfo->h)
+ {
+ ScrollDown(display, textInfo);
+ }
+ else
+ {
+ /* Update the bottom space appropriately */
+ textInfo->bottomSpace -= (nextLine->lineHeight + INTERLINE);
+ textInfo->endLine += 1;
+ }
+ /* Update drawing position */
+ textInfo->curY = textInfo->h -
+ (textInfo->bottomSpace + nextLine->lineHeight);
+ }
+
+ /* Move down a line */
+ textInfo->curLine += 1;
+ if (!(flagWord & NONEWLINE)) {
+ /* Append end-of-line to text buffer */
+ if (textInfo->bufSpot >= textInfo->bufAlloc) {
+ /* Allocate more space in main text buffer */
+ ExpandBuffer(textInfo);
+ }
+ textInfo->mainBuffer[(textInfo->bufSpot)++] =
+ (textInfo->curFont << FONTSHIFT) | '\n';
+ }
+ nextLine->lineText = textInfo->bufSpot;
+ textInfo->curX = 0;
+ return 1;
+}
+
+
+
+static int CharSize(textInfo, lineNum, charNum)
+struct txtWin *textInfo; /* Current Text Information */
+int lineNum; /* Line in buffer */
+int charNum; /* Character in line */
+/*
+ * This routine determines the size of the specified character.
+ * It takes in account the font of the character and whether its
+ * fixed or variable. The size includes INTERSPACE spacing between
+ * the characters.
+ */
+{
+ register XFontStruct *charFont;
+ register short *theLine;
+ register short theChar;
+
+ theLine = &(textInfo->mainBuffer[textInfo->txtBuffer[lineNum]->lineText]);
+ theChar = theLine[charNum] & CHARMASK;
+ charFont = &(textInfo->theFonts[(theChar & FONTMASK) >> FONTSHIFT]);
+ if (theChar <= charFont->min_char_or_byte2 ||
+ theChar >= charFont->max_char_or_byte2 ||
+ charFont->per_char == 0)
+ return charFont->max_bounds.width + 1;
+ else
+ return charFont->per_char[theChar].width + 1;
+}
+
+
+
+
+
+static int HandleBackspace(display, textInfo, flagWord)
+Display *display;
+struct txtWin *textInfo; /* Text Information */
+int flagWord; /* DODISP or nothing */
+/*
+ * This routine handles a backspace found in the input stream. The
+ * character before the current writing position will be erased and
+ * the drawing position will move back one character. If the writing
+ * position is at the left margin, the drawing position will move
+ * up to the previous line. If it is a line that has been wrapped,
+ * the character at the end of the previous line will be erased.
+ */
+{
+ struct txtLine *thisLine, *prevLine;
+ int chSize;
+
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+ /* First, determine whether we need to go back a line */
+ if (thisLine->lineLength == 0) {
+ /* Bleep if at top of buffer */
+ if (textInfo->curLine == 0) {
+ XBell(display, 50);
+ return 0;
+ }
+
+ /* See if we have to scroll in the other direction */
+ if ((flagWord & DODISP) && (textInfo->curY <= YPADDING)) {
+ /* This will display the last lines of the buffer */
+ WarpToBottom(display, textInfo);
+ }
+
+ /* Set drawing position at end of previous line */
+ textInfo->curLine -= 1;
+ prevLine = textInfo->txtBuffer[textInfo->curLine];
+ textInfo->numLines -= 1;
+ if (flagWord & DODISP) {
+ textInfo->curY -= (prevLine->lineHeight + INTERLINE);
+ textInfo->bottomSpace += (thisLine->lineHeight + INTERLINE);
+ textInfo->endLine -= 1;
+ }
+
+ /* We are unlinewrapping if the previous line has flag set */
+ if (prevLine->lineFlags & WRAPFLAG) {
+ /* Get rid of line wrap indicator */
+ if (flagWord & DODISP) {
+ XFillRectangle(display, textInfo->mainWindow,
+ textInfo->bgGC,
+ textInfo->w - BARSIZE - WRAPINDSIZE,
+ textInfo->curY, WRAPINDSIZE,
+ prevLine->lineHeight);
+ }
+ prevLine->lineFlags &= (~WRAPFLAG);
+ /* Call recursively to wipe out the ending character */
+ HandleBackspace(display, textInfo, flagWord);
+ } else {
+ /* Delete the end-of-line in the primary buffer */
+ textInfo->bufSpot -= 1;
+ }
+ } else {
+ /* Normal deletion of character */
+ chSize =
+ CharSize(textInfo, textInfo->curLine,
+ textInfo->txtBuffer[textInfo->curLine]->lineLength - 1);
+ /* Move back appropriate amount and wipe it out */
+ thisLine->lineWidth -= chSize;
+ if (flagWord & DODISP) {
+ XFillRectangle(display, textInfo->mainWindow,
+ textInfo->bgGC,
+ thisLine->lineWidth, textInfo->curY,
+ chSize, thisLine->lineHeight);
+ }
+ /* Delete from buffer */
+ textInfo->txtBuffer[textInfo->curLine]->lineLength -= 1;
+ textInfo->bufSpot -= 1;
+ }
+ return 1;
+}
+
+
+
+static int DrawLineWrap(display, win, x, y, h, col)
+Display *display;
+Window win; /* What window to draw it in */
+int x, y; /* Position of upper left corner */
+int h; /* Height of indicator */
+int col; /* Color of indicator */
+/*
+ * This routine draws a line wrap indicator at the end of a line.
+ * Visually, it is an arrow of the specified height directly against
+ * the scroll bar border. The bitmap used for the arrow is stored
+ * in 'arrowMap' with size 'arrow_width' and 'arrow_height'.
+ */
+{
+ struct txtWin *textInfo;
+
+ textInfo = (struct txtWin *)XLookUpAssoc(display, textWindows,
+ (XID) win);
+
+ /* First, draw the arrow */
+ XCopyArea(display, textInfo->arrowMap, textInfo->mainWindow,
+ textInfo->CursorGC,
+ 0, 0, arrow_width, arrow_height,
+ x, y + h - arrow_height, 1);
+
+ /* Then draw the stem */
+ XDrawLine(display, textInfo->mainWindow, textInfo->CursorGC,
+ x + STEMOFFSET, y,
+ x + STEMOFFSET, y + h - arrow_height);
+ return 1;
+}
+
+
+
+
+static int DrawLine(display, textInfo, lineIndex, ypos)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+int lineIndex; /* Index of line to draw */
+int ypos; /* Y position for line */
+/*
+ * This routine destructively draws the indicated line in the
+ * indicated window at the indicated position. It does not
+ * clear to end of line however. It draws a line wrap indicator
+ * if needed but does not draw a cursor.
+ */
+{
+ int index, startPos, curFont, theColor, curX, saveX, fontIndex;
+ struct txtLine *someLine;
+ char lineBuffer[BUFSIZE], *glyph;
+ short *linePointer;
+ XFontStruct *theFont;
+ XGCValues gc;
+
+ /* First, we draw the text */
+ index = 0;
+ curX = XPADDING;
+ someLine = textInfo->txtBuffer[lineIndex];
+ linePointer = &(textInfo->mainBuffer[someLine->lineText]);
+ while (index < someLine->lineLength) {
+ startPos = index;
+ saveX = curX;
+ curFont = linePointer[index] & FONTMASK;
+ fontIndex = curFont >> FONTSHIFT;
+ theFont = &(textInfo->theFonts[fontIndex]);
+ theColor = textInfo->theColors[fontIndex];
+ glyph = &(lineBuffer[0]);
+ while ((index < someLine->lineLength) &&
+ ((linePointer[index] & FONTMASK) == curFont))
+ {
+ *glyph = linePointer[index] & CHARMASK;
+ index++;
+ curX += CharSize(textInfo, lineIndex, index);
+ glyph++;
+ }
+
+ /* Flush out the glyphs */
+ XFillRectangle(display, textInfo->mainWindow,
+ textInfo->bgGC,
+ saveX, ypos,
+ textInfo->w - BARSIZE,
+ someLine->lineHeight + YPADDING + INTERLINE);
+
+ XDrawString(display, textInfo->mainWindow,
+ textInfo->fontGC[fontIndex],
+ saveX, ypos,
+ lineBuffer, someLine->lineLength);
+ }
+ /* Then the line wrap indicator (if needed) */
+ if (someLine->lineFlags & WRAPFLAG) {
+ DrawLineWrap(display, textInfo->mainWindow,
+ textInfo->w - BARSIZE - WRAPINDSIZE,
+ ypos, someLine->lineHeight,
+ textInfo->fgPix);
+ }
+ return 1;
+}
+
+
+
+
+static int HandleNewFont(display, fontNum, textInfo, flagWord)
+Display *display;
+int fontNum; /* Font number */
+struct txtWin *textInfo; /* Text information */
+int flagWord; /* DODISP or nothing */
+/*
+ * This routine handles a new font request. These requests take
+ * the form "^F<digit>". The parsing is done in TxtWriteStr.
+ * This routine is called only if the form is valid. It may return
+ * a failure (0 status) if the requested font is not loaded.
+ * If the new font is larger than any of the current
+ * fonts on the line, it will change the line height and redisplay
+ * the line.
+ */
+{
+ struct txtLine *thisLine;
+ int heightDiff, baseDiff, redrawFlag;
+
+ if (textInfo->theFonts[fontNum].fid == 0) {
+ return 0;
+ } else {
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+ textInfo->curFont = fontNum;
+ redrawFlag = 0;
+ heightDiff = textInfo->theFonts[fontNum].ascent +
+ textInfo->theFonts[fontNum].descent -
+ thisLine->lineHeight;
+
+ if (heightDiff > 0) {
+ redrawFlag = 1;
+ } else {
+ heightDiff = 0;
+ }
+
+ if (redrawFlag) {
+ if (flagWord & DODISP) {
+ /* Clear current line */
+ XFillRectangle(display, textInfo->mainWindow,
+ textInfo->bgGC,
+ 0, textInfo->curY, textInfo->w,
+ thisLine->lineHeight);
+
+ /* Check to see if it requires scrolling */
+ if ((textInfo->curY + thisLine->lineHeight + heightDiff +
+ INTERLINE) > textInfo->h)
+ {
+ /*
+ * General approach: "unscroll" the last line up
+ * and then call ScrollDown to do the right thing.
+ */
+ textInfo->endLine -= 1;
+ textInfo->bottomSpace += thisLine->lineHeight +
+ INTERLINE;
+
+ XFillRectangle(display, textInfo->mainWindow,
+ textInfo->bgGC,
+ 0, textInfo->h - textInfo->bottomSpace,
+ textInfo->w, textInfo->bottomSpace);
+
+ thisLine->lineHeight += heightDiff;
+ ScrollDown(display, textInfo);
+ textInfo->curY = textInfo->h -
+ (textInfo->bottomSpace + INTERLINE +
+ thisLine->lineHeight);
+ }
+ else
+ {
+ /* Just update bottom space */
+ textInfo->bottomSpace -= heightDiff;
+ thisLine->lineHeight += heightDiff;
+ }
+ /* Redraw the current line */
+ DrawLine(display, textInfo, textInfo->curLine, textInfo->curY);
+ } else {
+ /* Just update line height */
+ thisLine->lineHeight += heightDiff;
+ }
+ }
+ return 1;
+ }
+}
+
+
+
+int TxtWriteStr(display, w, str)
+Display *display;
+Window w; /* Text window */
+register char *str; /* 0 terminated string */
+/*
+ * This routine writes a string to the specified text window.
+ * The following notes apply:
+ * - Text is always appended to the end of the text buffer.
+ * - If the scroll bar is positioned such that the end of the
+ * text is not visible, an automatic scroll to the bottom
+ * will be done before the appending of text.
+ * - Non-printable ASCII characters are not displayed.
+ * - The '\n' character causes the current text position to
+ * advance one line and start at the left.
+ * - Tabs are not supported.
+ * - Lines too long for the screen will be wrapped and a line wrap
+ * indication will be drawn.
+ * - Backspace clears the previous character. It will do the right
+ * thing if asked to backspace past a wrapped line.
+ * - A new font can be chosen using the sequence '^F<digit>' where
+ * <digit> is 0-7. The directive will be ignored if
+ * there is no font in the specified slot.
+ * Returns 0 if something went wrong.
+ */
+{
+ register int fontIndex;
+ register struct txtWin *textInfo;
+ register struct txtLine *thisLine;
+
+ if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)) == 0)
+ return 0;
+
+ /* See if screen needs to be updated */
+ if (textInfo->flagWord & SCREENWRONG) {
+ TxtRepaint(display, textInfo->mainWindow);
+ }
+
+ /* See if we have to scroll down to the bottom */
+ if (textInfo->flagWord & NOTATBOTTOM) {
+ WarpToBottom(display, textInfo);
+ textInfo->flagWord &= (~NOTATBOTTOM);
+ }
+
+ /* Undraw the current cursor */
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+
+ XFillRectangle(display, w, textInfo->bgGC,
+ thisLine->lineWidth + CUROFFSET,
+ textInfo->curY,
+ CURSORWIDTH,
+ thisLine->lineHeight);
+
+ for ( /* str is ok */ ; (*str != 0) ; str++) {
+ /* Check to see if we are waiting on a font */
+ if (textInfo->flagWord & FONTNUMWAIT) {
+ textInfo->flagWord &= (~FONTNUMWAIT);
+ fontIndex = *str - '0';
+ if ((fontIndex >= 0) && (fontIndex < MAXFONTS)) {
+ /* Handle font -- go get next character */
+ if (HandleNewFont(display, fontIndex, textInfo, DODISP))
+ continue;
+ }
+ }
+
+ /* Inline code for handling normal character case */
+ if ((*str >= LOWCHAR) && (*str <= HIGHCHAR)) {
+ register XFontStruct *thisFont;
+ register struct txtLine *thisLine;
+ register int charWidth;
+ int thisColor;
+
+ /* Determine size of character */
+ thisFont = &(textInfo->theFonts[textInfo->curFont]);
+ thisColor = textInfo->theColors[textInfo->curFont];
+ if (*str <= thisFont->min_char_or_byte2 ||
+ *str >= thisFont->max_char_or_byte2 ||
+ thisFont->per_char == 0)
+ charWidth = thisFont->max_bounds.width + 1;
+ else
+ charWidth = thisFont->per_char[*str].width + 1;
+
+ /* Check to see if line wrap is required */
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+ if (thisLine->lineWidth + charWidth >
+ (textInfo->w-BARSIZE-WRAPINDSIZE))
+ {
+ DrawLineWrap(display, textInfo->mainWindow,
+ textInfo->w-BARSIZE-WRAPINDSIZE,
+ textInfo->curY, thisLine->lineHeight,
+ textInfo->fgPix);
+ thisLine->lineFlags |= WRAPFLAG;
+ /* Handle the spacing problem the same way as a newline */
+ HandleNewLine(display, textInfo, DODISP | NONEWLINE);
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+ }
+
+ /* Ready to draw character */
+ XDrawString(display, textInfo->mainWindow,
+ DEFAULT_GC,
+ textInfo->curX += charWidth,
+ textInfo->curY + thisLine->lineHeight,
+ str, 1);
+
+ /* Append character onto main buffer */
+ if (textInfo->bufSpot >= textInfo->bufAlloc)
+ /* Make room for more characters */
+ ExpandBuffer(textInfo);
+ textInfo->mainBuffer[(textInfo->bufSpot)++] =
+ (textInfo->curFont << FONTSHIFT) | (*str);
+
+ /* Update the line start array */
+ thisLine->lineLength += 1;
+ thisLine->lineWidth += charWidth;
+ } else if (*str == NEWLINE) {
+ HandleNewLine(display, textInfo, DODISP);
+ } else if (*str == NEWFONT) {
+ /* Go into waiting for font number mode */
+ textInfo->flagWord |= FONTNUMWAIT;
+ } else if (*str == BACKSPACE) {
+ HandleBackspace(display, textInfo, DODISP);
+ } else {
+ /* Ignore all others */
+ }
+ }
+ /* Draw the cursor in its new position */
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+
+ XFillRectangle(display, w, textInfo->CursorGC,
+ thisLine->lineWidth + CUROFFSET,
+ textInfo->curY /* + thisLine->lineHeight */,
+ CURSORWIDTH, thisLine->lineHeight);
+
+ return 1;
+}
+
+
+
+int TxtJamStr(display, w, str)
+Display *display;
+Window w; /* Text window */
+register char *str; /* NULL terminated string */
+/*
+ * This is the same as TxtWriteStr except the screen is NOT updated.
+ * After a call to this routine, TxtRepaint should be called to
+ * update the screen. This routine is meant to be used to load
+ * a text buffer with information and then allow the user to
+ * scroll through it at will.
+ */
+{
+ register int fontIndex;
+ register struct txtWin *textInfo;
+
+ if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)
+ ) == 0)
+ return 0;
+
+ for ( /* str is ok */ ; (*str != 0) ; str++) {
+ /* Check to see if we are waiting on a font */
+ if (textInfo->flagWord & FONTNUMWAIT) {
+ textInfo->flagWord &= (~FONTNUMWAIT);
+ fontIndex = *str - '0';
+ if ((fontIndex >= 0) && (fontIndex < MAXFONTS)) {
+ if (HandleNewFont(display, fontIndex, textInfo, 0)) {
+ /* Handled font -- go get next character */
+ continue;
+ }
+ }
+ }
+ /* Inline code for handling normal character case */
+ if ((*str >= LOWCHAR) && (*str <= HIGHCHAR)) {
+ register XFontStruct *thisFont;
+ register struct txtLine *thisLine;
+ register int charWidth;
+
+ /* Determine size of character */
+ thisFont = &(textInfo->theFonts[textInfo->curFont]);
+
+ if (*str <= thisFont->min_char_or_byte2 ||
+ *str >= thisFont->max_char_or_byte2 ||
+ thisFont->per_char == 0)
+ charWidth = thisFont->max_bounds.width + 1;
+ else
+ charWidth = thisFont->per_char[*str].width + 1;
+
+ /* Check to see if line wrap is required */
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+ if (thisLine->lineWidth + charWidth >
+ (textInfo->w-BARSIZE-WRAPINDSIZE))
+ {
+ thisLine->lineFlags |= WRAPFLAG;
+ /* Handle the spacing problem the same way as a newline */
+ HandleNewLine(display, textInfo, NONEWLINE);
+ thisLine = textInfo->txtBuffer[textInfo->curLine];
+ }
+ /* Append character onto main buffer */
+ if (textInfo->bufSpot >= textInfo->bufAlloc)
+ /* Make room for more characters */
+ ExpandBuffer(textInfo);
+ textInfo->mainBuffer[(textInfo->bufSpot)++] =
+ (textInfo->curFont << FONTSHIFT) | (*str);
+
+ /* Update the line start array */
+ thisLine->lineLength += 1;
+ thisLine->lineWidth += charWidth;
+ } else if (*str == NEWLINE) {
+ HandleNewLine(display, textInfo, 0);
+ } else if (*str == NEWFONT) {
+ /* Go into waiting for font number mode */
+ textInfo->flagWord |= FONTNUMWAIT;
+ } else if (*str == BACKSPACE) {
+ HandleBackspace(display, textInfo, 0);
+ } else {
+ /* Ignore all others */
+ }
+ }
+ textInfo->flagWord |= SCREENWRONG;
+ return 1;
+}
+
+
+
+int TxtRepaint(display,w)
+Display *display;
+Window w;
+/*
+ * Repaints the given scrollable text window. The routine repaints
+ * the entire window. For handling exposure events, the TxtFilter
+ * routine should be used.
+ */
+{
+ struct txtWin *textInfo;
+ int index, ypos;
+
+ if ((textInfo = (struct txtWin *) XLookUpAssoc(display, textWindows, (XID) w)
+ ) == 0)
+ return 0;
+
+ /* Check to see if the screen is up to date */
+ if (textInfo->flagWord & SCREENWRONG) {
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ textInfo->flagWord &= (~SCREENWRONG);
+ }
+
+ ypos = YPADDING;
+ index = textInfo->startLine;
+ for (;;) {
+ DrawLine(display, textInfo, index, ypos);
+ if (index >= textInfo->endLine) break;
+ ypos += (textInfo->txtBuffer[index]->lineHeight + INTERLINE);
+ index++;
+ }
+ /* Draw the cursor (if on screen) */
+ if (textInfo->endLine == textInfo->curLine) {
+ XFillRectangle(display, w, textInfo->CursorGC,
+ textInfo->txtBuffer[index]->lineWidth + CUROFFSET,
+ ypos /* + textInfo->txtBuffer[index]->lineHeight */,
+ CURSORWIDTH, textInfo->txtBuffer[index]->lineHeight);
+
+ }
+ /* Update the scroll bar */
+ UpdateScroll(display, textInfo);
+ return 1;
+}
+
+
+
+static int InsertIndex(textInfo, thisIndex, ypos)
+struct txtWin *textInfo; /* Text Window Information */
+int thisIndex; /* Line index of exposed line */
+int ypos; /* Drawing position of line */
+/*
+ * This routine inserts the supplied line index into the copy
+ * exposure array for 'textInfo'. The array is kept sorted
+ * from lowest to highest using insertion sort. The array
+ * is dynamically expanded if needed.
+ */
+{
+ struct expEvent *newItem;
+ int newSize, index, downIndex;
+
+ /* Check to see if we need to expand it */
+ if ((textInfo->exposeSize + 3) >= textInfo->exposeAlloc) {
+ newSize = textInfo->exposeAlloc +
+ (textInfo->exposeAlloc * EXPANDPERCENT / 100);
+ textInfo->exposeAry = (struct expEvent **)
+ realloc((char *) textInfo->exposeAry,
+ (unsigned) (newSize * sizeof(struct expEvent *)));
+ for (index = textInfo->exposeAlloc; index < newSize; index++)
+ textInfo->exposeAry[index] = alloc(struct expEvent);
+ textInfo->exposeAlloc = newSize;
+ }
+ /* Find spot for insertion. NOTE: last spot has big number */
+ for (index = 0; index <= textInfo->exposeSize; index++) {
+ if (textInfo->exposeAry[index]->lineIndex >= thisIndex) {
+ if (textInfo->exposeAry[index]->lineIndex > thisIndex) {
+ /* Insert before this entry */
+ newItem = textInfo->exposeAry[textInfo->exposeSize+1];
+ for (downIndex = textInfo->exposeSize;
+ downIndex >= index;
+ downIndex--)
+ {
+ textInfo->exposeAry[downIndex+1] =
+ textInfo->exposeAry[downIndex];
+ }
+ /* Put a free structure at this spot */
+ textInfo->exposeAry[index] = newItem;
+ /* Fill it in */
+ textInfo->exposeAry[index]->lineIndex = thisIndex;
+ textInfo->exposeAry[index]->ypos = ypos;
+ /* Break out of loop */
+ textInfo->exposeSize += 1;
+ }
+ break;
+ }
+ }
+ return 1;
+}
+
+
+
+static int ScrollUp(display, textInfo)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+/*
+ * This routine scrolls the indicated text window up by one
+ * line. The line above the current line must exist. The
+ * window is scrolled so that the line above the start line
+ * is displayed at the top of the screen. This may cause
+ * many lines to scroll off the bottom. The scrolling is
+ * done using XCopyArea. The exposure events should be caught
+ * by ExposeCopy.
+ */
+{
+ int targetSpace;
+
+ /* Make sure all exposures have been handled by now */
+ if (textInfo->startLine == 0) return 0;
+ targetSpace = textInfo->txtBuffer[textInfo->startLine-1]->lineHeight +
+ INTERLINE;
+ /* Move the area downward by the target amount */
+ XCopyArea(display, textInfo->mainWindow, textInfo->mainWindow,
+ DEFAULT_GC,
+ 0, YPADDING, textInfo->w - BARSIZE,
+ textInfo->h, 0, targetSpace);
+
+ textInfo->flagWord |= COPYEXPOSE;
+ /* Update the text window parameters */
+ textInfo->startLine -= 1;
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+
+ /* Clear out bottom space region */
+ XClearArea(display, textInfo->mainWindow,
+ 0, textInfo->h - textInfo->bottomSpace,
+ textInfo->w, textInfo->bottomSpace);
+
+ UpdateExposures(display, textInfo);
+ UpdateScroll(display, textInfo);
+
+ return 1;
+}
+
+
+static int ScrollToSpot(display, textInfo, ySpot)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+int ySpot; /* Button position in scroll window */
+/*
+ * This routine scrolls the specified text window relative to the
+ * position of the mouse in the scroll bar. The center of the screen
+ * will be positioned to correspond to the mouse position.
+ */
+{
+ int targetLine, aboveLines;
+
+ targetLine = textInfo->numLines * ySpot / textInfo->h;
+ textInfo->startLine = targetLine;
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ aboveLines = 0;
+ /* Make the target line the *center* of the window */
+ while ((textInfo->startLine > 0) &&
+ (aboveLines < textInfo->endLine - targetLine))
+ {
+ textInfo->startLine -= 1;
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ aboveLines++;
+ }
+ if (textInfo->endLine == textInfo->numLines-1) {
+ WarpToBottom(display, textInfo);
+ } else {
+ XClearWindow(display, textInfo->mainWindow);
+ TxtRepaint(display, textInfo->mainWindow);
+ }
+ return 1;
+}
+
+
+
+static int LineToTop(display, textInfo, pos)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+int pos; /* Y position of mouse */
+/*
+ * This routine scrolls the screen down until the line at the
+ * mouse position is at the top of the screen. It stops
+ * if it can't scroll the buffer down that far. If the
+ * global 'ScrollOption' is NORMSCROLL, a smooth scroll
+ * is used. Otherwise, it jumps to the right position
+ * and repaints the screen.
+ */
+{
+ int index, sum;
+
+ /* First, we find the current line */
+ sum = 0;
+ for (index = textInfo->startLine; index <= textInfo->endLine; index++) {
+ if (sum + textInfo->txtBuffer[index]->lineHeight + INTERLINE> pos) break;
+ sum += textInfo->txtBuffer[index]->lineHeight + INTERLINE;
+ }
+ /* We always want to scroll down at least one line */
+ if (index == textInfo->startLine) index++;
+ if (ScrollOption == NORMSCROLL) {
+ /* Scroll down until 'index' is the starting line */
+ while ((textInfo->startLine < index) && ScrollDown(display, textInfo))
+ {
+ /* Empty Loop Body */
+ }
+ } else {
+ /* Immediately jump to correct spot */
+ textInfo->startLine = index;
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ if (textInfo->endLine == textInfo->numLines-1) {
+ WarpToBottom(display, textInfo);
+ } else {
+ XClearWindow(display, textInfo->mainWindow);
+ TxtRepaint(display, textInfo->mainWindow);
+ }
+ }
+ /* Check to see if at end of buffer */
+ if (textInfo->endLine >= textInfo->numLines-1) {
+ textInfo->flagWord &= (~NOTATBOTTOM);
+ }
+ return 1;
+}
+
+
+
+static int TopToHere(display, textInfo, pos)
+Display *display;
+struct txtWin *textInfo; /* Text window information */
+int pos; /* Y position of mouse */
+/*
+ * This routine scrolls the screen up until the top line of
+ * the screen is at the current Y position of the mouse. Again,
+ * it will stop if it can't scroll that far. If the global
+ * 'ScrollOption' is NORMSCROLL, a smooth scroll is used.
+ * If it's not, it will simply redraw the screen at the
+ * correct spot.
+ */
+{
+ int sum, target, linesup, index;
+
+ target = pos - textInfo->txtBuffer[textInfo->startLine]->lineHeight;
+ /* We always want to scroll up at least one line */
+ if (target <= 0) target = 1;
+ sum = 0;
+ linesup = 0;
+ /* Check to see if we are at the top anyway */
+ if (textInfo->startLine == 0) return 0;
+ if (ScrollOption == NORMSCROLL) {
+ /* Scroll up until sum of new top lines greater than target */
+ while ((sum < target) && ScrollUp(display, textInfo)) {
+ sum += textInfo->txtBuffer[textInfo->startLine]->lineHeight;
+ linesup++;
+ }
+ } else {
+ /* Search backward to find index */
+ index = textInfo->startLine - 1;
+ while ((index > 0) && (sum < target)) {
+ sum += textInfo->txtBuffer[index]->lineHeight;
+ linesup++;
+ index--;
+ }
+ /* Go directly to the index */
+ textInfo->startLine = index;
+ textInfo->endLine = FindEndLine(textInfo, &(textInfo->bottomSpace));
+ XClearWindow(display, textInfo->mainWindow);
+ TxtRepaint(display, textInfo->mainWindow);
+ }
+ /* If we scrolled, assert we are not at bottom of buffer */
+ if (linesup > 0) {
+ textInfo->flagWord |= NOTATBOTTOM;
+ }
+ return 1;
+}
+
+
+
+int TxtFilter(display, evt)
+Display *display;
+XEvent *evt;
+/*
+ * This routine handles events associated with scrollable text windows.
+ * It will handle all exposure events and any button released events
+ * in the scroll bar of a text window. It does NOT handle any other
+ * events. If it cannot handle the event, it will return 0.
+ */
+{
+ XExposeEvent *expose = &evt->xexpose;
+ XButtonEvent *btEvt = &evt->xbutton;
+ XGraphicsExposeEvent *gexpose = &evt->xgraphicsexpose;
+ XNoExposeEvent *noexpose = &evt->xnoexpose;
+ struct txtWin *textInfo;
+ int index, ypos;
+ Window w, sw;
+
+ if (textWindows == (XAssocTable *) 0) {
+ textWindows = XCreateAssocTable(32);
+ if (textWindows == (XAssocTable *) 0) return(0);
+ }
+ if (evt->type == Expose) {
+ w = expose->window;
+ sw = 0;
+ }
+ else if (evt->type == GraphicsExpose) {
+ w = gexpose->drawable;
+ sw = 0;
+ }
+ else if (evt->type == NoExpose) {
+ w = noexpose->drawable;
+ sw = 0;
+ }
+ else if (evt->type == ButtonRelease) {
+ w = btEvt->window;
+ sw = btEvt->subwindow;
+ }
+ else
+ return 0;
+
+ if ((textInfo = (struct txtWin *)
+ XLookUpAssoc(display, textWindows, (XID) w)) == 0)
+ return 0;
+
+ /* Determine whether it's main window or not */
+ if ((w == textInfo->mainWindow) && (sw == 0)) {
+ /* Main Window - handle exposures */
+ switch (evt->type) {
+ case Expose:
+ ypos = 0 /*YPADDING*/;
+ for (index = textInfo->startLine;
+ index <= textInfo->endLine;
+ index++)
+ {
+ int lh = textInfo->txtBuffer[index]->lineHeight;
+
+ if (((ypos + lh) >= expose->y) &&
+ (ypos <= (expose->y + expose->height)))
+ {
+ /* Intersection region */
+ /* Draw line immediately */
+ DrawLine(display, textInfo, index, ypos);
+ /* And possibly draw cursor */
+ if (textInfo->curLine == index) {
+ XFillRectangle(display, w, textInfo->CursorGC,
+ textInfo->txtBuffer[index]->lineWidth +
+ CUROFFSET,
+ ypos,
+ CURSORWIDTH,
+ lh);
+ }
+ }
+ ypos += lh + INTERLINE;
+ }
+ break;
+ case GraphicsExpose:
+ ypos = 0 /*YPADDING*/;
+ for (index = textInfo->startLine;
+ index <= textInfo->endLine;
+ index++)
+ {
+ int lh = textInfo->txtBuffer[index]->lineHeight;
+
+ if (((ypos + lh) >= gexpose->y) &&
+ (ypos <= (gexpose->y + gexpose->height)))
+ {
+ /* Intersection region */
+ /* Draw line immediately */
+ DrawLine(display, textInfo, index, ypos);
+ /* And possibly draw cursor */
+ if (textInfo->curLine == index) {
+ XFillRectangle(display, w, textInfo->CursorGC,
+ textInfo->txtBuffer[index]->lineWidth +
+ CUROFFSET,
+ ypos,
+ CURSORWIDTH,
+ lh);
+ }
+ }
+ ypos += lh + INTERLINE;
+ }
+ break;
+ case NoExpose:
+ break;
+ default:
+ /* Not one of our events */
+ return 0;
+ }
+ } else {
+ switch (evt->type) {
+ case Expose:
+ UpdateScroll(display, textInfo);
+ break;
+ case ButtonRelease:
+ /* Find out which button */
+ switch (btEvt->button) {
+ case Button1:
+ /* Scroll up until top line is at mouse position */
+ TopToHere(display, textInfo, btEvt->y);
+ break;
+ case Button2:
+ /* Scroll to spot relative to position */
+ ScrollToSpot(display, textInfo, btEvt->y);
+ if (textInfo->endLine >= textInfo->numLines-1) {
+ textInfo->flagWord &= (~NOTATBOTTOM);
+ } else {
+ textInfo->flagWord |= NOTATBOTTOM;
+ }
+ break;
+ case Button3:
+ /* Scroll down until pointed line is at top */
+ LineToTop(display, textInfo, btEvt->y);
+ break;
+ }
+ break;
+ default:
+ /* Not one of our events */
+ return 0;
+ }
+ }
+ return 1;
+}
diff --git a/gnu/games/chess/Xchess/scrollText/scrollText.h b/gnu/games/chess/Xchess/scrollText/scrollText.h
new file mode 100644
index 000000000000..d9d05b08dc0b
--- /dev/null
+++ b/gnu/games/chess/Xchess/scrollText/scrollText.h
@@ -0,0 +1,32 @@
+/*
+ * Scrollable Text Window Header File
+ *
+ * David Harrison
+ * University of California, Berkeley
+ * 1986
+ *
+ * This file contains definitions for a scrollable text window
+ * with scroll bar support.
+ */
+
+int TxtGrab();
+ /* Take hold of a previously created window */
+
+#define TXT_NO_COLOR -1
+
+int TxtAddFont();
+ /* Loads a new font for use later */
+int TxtWinP();
+ /* Returns non-zero value if the window is text window */
+int TxtClear();
+ /* Clears text window and resets text buffer */
+
+int TxtWriteStr();
+ /* Writes a string to window with immediate update */
+int TxtJamStr();
+ /* Write a string without causing update to screen */
+
+int TxtRepaint();
+ /* Repaints entire scrollable text window */
+int TxtFilter();
+ /* Handles events related to text window */
diff --git a/gnu/games/chess/Xchess/shade.bitmap b/gnu/games/chess/Xchess/shade.bitmap
new file mode 100644
index 000000000000..a32ac80611ce
--- /dev/null
+++ b/gnu/games/chess/Xchess/shade.bitmap
@@ -0,0 +1,71 @@
+
+#define shade_width 80
+#define shade_height 80
+static char shade_bits[] = {
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22,
+ 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x11, 0x11, 0x11, 0x11,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
+ 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+ 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x88, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88};
diff --git a/gnu/games/chess/Xchess/std.c b/gnu/games/chess/Xchess/std.c
new file mode 100644
index 000000000000..c839b912314a
--- /dev/null
+++ b/gnu/games/chess/Xchess/std.c
@@ -0,0 +1,425 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.1 $ on $Date: 86/11/01 17:08:40 $
+ * $Source: /users/faustus/xchess/RCS/std.c,v $
+ * Copyright (c) 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
+ *
+ * Utility routines.
+ */
+
+#include "std.h"
+
+#ifndef IBMPC
+#include <sys/types.h>
+#endif not IBMPC
+#ifdef UNIX
+#include <signal.h>
+#include <pwd.h>
+#endif UNIX
+#ifdef BSD
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif BSD
+
+extern char **environ;
+
+bool
+prefix(p, s)
+ register char *p, *s;
+{
+ while (*p && (*p == *s))
+ p++, s++;
+ if (!*p)
+ return (true);
+ else
+ return (false);
+}
+
+/* Create a copy of a string. */
+
+char *
+copy(str)
+ char *str;
+{
+ char *p, *tmalloc();
+
+ p = tmalloc(strlen(str) + 1);
+ strcpy(p, str);
+ return(p);
+}
+
+/* Determine whether sub is a substring of str. */
+
+bool
+substring(sub, str)
+ register char *str, *sub;
+{
+ register char *s;
+
+ while(*str) {
+ if(*str == *sub) {
+ for(s = sub; *s; s++)
+ if(*s != *str++)
+ break;
+ if(*s == '\0')
+ return (true);
+ }
+ str++;
+ }
+ return (false);
+}
+
+/* Malloc num bytes and initialize to zero. Fatal error if the space can't
+ * be malloc'd.
+ */
+
+char *
+tmalloc(num)
+ register int num;
+{
+ register char *s;
+ char *malloc();
+
+ s = malloc((unsigned) num);
+ if (!s) {
+ fatal("malloc: can't allocate %d bytes", num);
+ }
+ bzero(s, num);
+ return(s);
+}
+
+char *
+trealloc(ptr, num)
+ char *ptr;
+ int num;
+{
+ register char *s;
+ char *realloc();
+
+ s = realloc(ptr, (unsigned) num);
+ if (!s) {
+ fatal("realloc: can't allocate %d bytes", num);
+ }
+ /* Well, this won't be zeroed... Too bad... */
+ return(s);
+}
+
+/* Append one character to a string. Don't check for overflow. */
+
+void
+appendc(s, c)
+ char *s, c;
+{
+ while (*s)
+ s++;
+ *s++ = c;
+ *s = '\0';
+ return;
+}
+
+int
+scannum(str)
+ char *str;
+{
+ int i = 0;
+
+ while(isdigit(*str))
+ i = i * 10 + *(str++) - '0';
+ return(i);
+}
+
+/* Case insensitive prefix. */
+
+bool
+ciprefix(p, s)
+ register char *p, *s;
+{
+ while (*p) {
+ if ((isupper(*p) ? tolower(*p) : *p) !=
+ (isupper(*s) ? tolower(*s) : *s))
+ return(false);
+ p++;
+ s++;
+ }
+ return (true);
+}
+
+/* Case insensitive strcmp... */
+
+bool
+cieq(p, s)
+ register char *p, *s;
+{
+ while (*p) {
+ if ((isupper(*p) ? tolower(*p) : *p) !=
+ (isupper(*s) ? tolower(*s) : *s))
+ return(false);
+ p++;
+ s++;
+ }
+ return (!*s);
+}
+
+#ifdef BSD
+
+/* Return the date. Return value is static data. */
+
+char *
+datestring()
+{
+ register char *tzn;
+ struct tm *tp;
+ static char tbuf[40];
+ char *ap;
+ struct timeval tv;
+ struct timezone tz;
+ char *timezone(), *asctime();
+ int i;
+ struct tm *localtime();
+
+ (void) gettimeofday(&tv, &tz);
+ tp = localtime((time_t *) &tv.tv_sec);
+ ap = asctime(tp);
+ tzn = timezone(tz.tz_minuteswest, tp->tm_isdst);
+ sprintf(tbuf, "%.20s", ap);
+ if (tzn)
+ strcat(tbuf, tzn);
+ strcat(tbuf, ap + 19);
+ i = strlen(tbuf);
+ tbuf[i - 1] = '\0';
+ return (tbuf);
+}
+
+#else BSD
+
+/* Give it a try... */
+
+char *
+datestring()
+{
+ long i;
+ static char buf[64];
+
+ i = time(0);
+ strcpy(buf, ctime(&i));
+ buf[strlen(buf) - 1] = '\0'; /* Kill the nl. */
+ return (buf);
+}
+
+#endif
+
+/* How many seconds have elapsed in running time. */
+
+int
+seconds()
+{
+#ifdef BSD
+ struct rusage ruse;
+
+ getrusage(RUSAGE_SELF, &ruse);
+ return (ruse.ru_utime.tv_sec);
+#else BSD
+#endif BSD
+}
+
+/* A few things that may not exist on non-unix systems. */
+
+#ifndef BSD
+
+#ifndef index
+
+char *
+index(s, c)
+ register char *s;
+ register char c;
+{
+ while ((*s != c) && (*s != '\0'))
+ s++;
+ if (*s == '\0')
+ return ((char *) 0);
+ else
+ return (s);
+}
+
+#endif not index
+
+#ifndef rindex
+
+char *
+rindex(s, c)
+ register char *s;
+ register char c;
+{
+ register char *t;
+
+ for (t = s; *t != '\0'; t++);
+ while ((*t != c) && (t != s))
+ t--;
+ if (t == s)
+ return ((char *) 0);
+ else
+ return (t);
+}
+
+#endif not rindex
+
+#ifndef bcopy
+
+void
+bcopy(from, to, num)
+ register char *from, *to;
+ register int num;
+{
+ while (num-- > 0)
+ *to++ = *from++;
+ return;
+}
+
+#endif not bcopy
+
+#ifndef bzero
+
+void
+bzero(ptr, num)
+ register char *ptr;
+ register int num;
+{
+ while (num-- > 0)
+ *ptr++ = '\0';
+ return;
+}
+
+#endif not bzero
+
+/* This might not be around... If not then forget about sorting... */
+
+void qsort() {}
+
+#endif BSD
+
+char *
+gettok(s)
+ char **s;
+{
+ char buf[BSIZE];
+ int i = 0;
+
+ while (isspace(**s))
+ (*s)++;
+ if (!**s)
+ return (NULL);
+ while (**s && !isspace(**s))
+ buf[i++] = *(*s)++;
+ buf[i] = '\0';
+ while (isspace(**s))
+ (*s)++;
+ return (copy(buf));
+}
+
+/* Die horribly. */
+
+/* VARARGS1 */
+void
+fatal(s, args)
+ char *s;
+{
+ fputs("Internal Error: ", stderr);
+ _doprnt(s, &args, stderr);
+ putc('\n', stderr);
+
+ kill(getpid(), SIGIOT);
+ /* NOTREACHED */
+}
+
+void
+setenv(name, value)
+ char *name, *value;
+{
+ int i;
+ char **xx, *s;
+
+ s = tmalloc(strlen(name) + 2);
+ sprintf(s, "%s=", name);
+
+ /* Copy the old environment... */
+ for (i = 0; environ[i]; i++)
+ if (prefix(s, environ[i]))
+ break;
+ if (!environ[i]) {
+ xx = (char **) tmalloc((i + 2) * sizeof (char *));
+ for (i = 0; environ[i]; i++)
+ xx[i] = environ[i];
+ xx[i + 1] = NULL;
+ environ = xx;
+ } else
+ xx = environ;
+
+ xx[i] = tmalloc(strlen(name) + strlen(value) + 2);
+ sprintf(xx[i], "%s=%s", name, value);
+ return;
+}
+
+char *
+getusername()
+{
+ int i = getuid();
+ struct passwd *pw = getpwuid(i);
+
+ return (pw ? pw->pw_name : NULL);
+}
+
+char *
+gethome()
+{
+ int i = getuid();
+ struct passwd *pw = getpwuid(i);
+
+ return (pw ? pw->pw_dir : "/strange");
+}
+
+char *
+tildexpand(s)
+ char *s;
+{
+ struct passwd *pw;
+ char *n, buf[64];
+ int i;
+
+ if (*s != '~')
+ return (copy(s));
+
+ for (s++, i = 0; *s != '/'; s++, i++)
+ buf[i] = *s;
+ buf[i] = '\0';
+ if (!i)
+ pw = getpwuid(getuid());
+ else
+ pw = getpwnam(buf);
+ if (!pw)
+ return (s);
+ n = tmalloc(strlen(s) + strlen(pw->pw_dir) + 1);
+ strcpy(n, pw->pw_dir);
+ strcat(n, s);
+ return (n);
+}
+
diff --git a/gnu/games/chess/Xchess/std.h b/gnu/games/chess/Xchess/std.h
new file mode 100644
index 000000000000..fc8fa6460dcb
--- /dev/null
+++ b/gnu/games/chess/Xchess/std.h
@@ -0,0 +1,105 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.2 $ on $Date: 86/11/23 17:18:32 $
+ * $Source: /users/faustus/xchess/RCS/std.h,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ *
+ * Standard definitions.
+ */
+
+#define UNIX
+#define BSD
+
+#ifndef FILE
+#include <stdio.h>
+#endif
+#ifndef isalpha
+#include <ctype.h>
+#endif
+#ifndef HUGE
+#include <math.h>
+#endif
+#include <strings.h>
+
+typedef int bool;
+
+#define false 0
+#define true 1
+
+/* Externs defined in std.c */
+
+extern char *tmalloc();
+extern char *trealloc();
+extern char *copy();
+extern char *datestring();
+extern char *getusername();
+extern char *gethome();
+extern char *gettok();
+extern char *tildexpand();
+extern void fatal();
+extern void setenv();
+extern void appendc();
+extern int scannum();
+extern int seconds();
+extern bool prefix();
+extern bool ciprefix();
+extern bool cieq();
+extern bool substring();
+
+/* Externs from libc */
+
+extern char *getenv();
+extern int errno;
+extern char *sys_errlist[];
+
+/* Should use BSIZE instead of BUFSIZ... */
+
+#define BSIZE 512
+
+/* Some standard macros. */
+
+#define eq(a,b) (!strcmp((a), (b)))
+#define isalphanum(c) (isalpha(c) || isdigit(c))
+#define alloc(strname) ((struct strname *) tmalloc(sizeof(struct strname)))
+#define tfree(ptr) { if (ptr) free((char *) ptr); ptr = 0; }
+#define hexnum(c) ((((c) >= '0') && ((c) <= '9')) ? ((c) - '0') : ((((c) >= \
+ 'a') && ((c) <= 'f')) ? ((c) - 'a' + 10) : ((((c) >= 'A') && \
+ ((c) <= 'F')) ? ((c) - 'A' + 10) : 0)))
+
+#ifndef BSD
+#define random rand
+#define srandom srand
+#endif BSD
+
+#ifdef VMS
+
+#define EXIT_NORMAL 1
+#define EXIT_BAD 0
+
+#else VMS
+
+#define EXIT_NORMAL 0
+#define EXIT_BAD 1
+
+#endif VMS
+
diff --git a/gnu/games/chess/Xchess/valid.c b/gnu/games/chess/Xchess/valid.c
new file mode 100644
index 000000000000..3dcdb004d320
--- /dev/null
+++ b/gnu/games/chess/Xchess/valid.c
@@ -0,0 +1,264 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.3 $ on $Date: 86/11/23 17:18:35 $
+ * $Source: /users/faustus/xchess/RCS/valid.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ * Validate a move.
+ */
+
+#include "xchess.h"
+
+extern bool ischeck(), couldmove();
+
+bool
+valid_move(m, b)
+ move *m;
+ board *b;
+{
+ board tb;
+
+ /* First check that the piece can make the move at all... */
+ if (!couldmove(m, b))
+ return (false);
+
+ /* Now see if the king is in check now. */
+ bcopy((char *) b, (char *) &tb, sizeof (board));
+ board_move(&tb, m);
+ if (ischeck(&tb, m->piece.color))
+ return (false);
+
+ if (ischeck(&tb, ((m->piece.color == WHITE) ? BLACK : WHITE)))
+ m->check = true;
+
+ return (true);
+}
+
+static bool
+couldmove(m, b)
+ move *m;
+ board *b;
+{
+ int x, y;
+
+ switch (m->type) {
+ case KCASTLE:
+ if ((m->piece.color == WHITE) && (b->white_cant_castle_k) ||
+ (m->piece.color == BLACK) &&
+ (b->black_cant_castle_k))
+ return (false);
+ if ((b->square[m->fromy][5].color != NONE) ||
+ (b->square[m->fromy][6].color != NONE))
+ return (false);
+ if (ischeck(b, m->piece.color))
+ return (false);
+ break;
+
+ case QCASTLE:
+ if ((m->piece.color == WHITE) && (b->white_cant_castle_q) ||
+ (m->piece.color == BLACK) &&
+ (b->black_cant_castle_q))
+ return (false);
+ if ((b->square[m->fromy][1].color != NONE) ||
+ (b->square[m->fromy][2].color != NONE) ||
+ (b->square[m->fromy][3].color != NONE))
+ return (false);
+ if (ischeck(b, m->piece.color))
+ return (false);
+ break;
+
+ case MOVE:
+ case CAPTURE:
+ /* There is one special case here, that of taking a pawn
+ * en passant. In this case we change the move field to
+ * CAPTURE if it's ok.
+ */
+ switch (m->piece.type) {
+ case PAWN:
+ if ((m->type == MOVE) && (m->fromx == m->tox)) {
+ /* A normal move. */
+ if ((m->piece.color == WHITE) && (m->fromy ==
+ m->toy + 1))
+ break;
+ if ((m->piece.color == WHITE) && (m->fromy ==
+ 6) && (m->toy == 4) &&
+ (b->square[5][m->fromx].color
+ == NONE))
+ break;
+ if ((m->piece.color == BLACK) && (m->fromy ==
+ m->toy - 1))
+ break;
+ if ((m->piece.color == BLACK) && (m->fromy ==
+ 1) && (m->toy == 3) &&
+ (b->square[2][m->fromx].color
+ == NONE))
+ break;
+ return (false);
+ } else if (m->type == CAPTURE) {
+ if ((((m->piece.color == WHITE) && (m->fromy ==
+ m->toy + 1)) || ((m->piece.color ==
+ BLACK) && (m->fromy == m->toy -
+ 1))) && ((m->fromx == m->tox + 1) ||
+ (m->fromx == m->tox - 1)))
+ break;
+ /* Now maybe it's enpassant... We've already
+ * checked for some of these things in the
+ * calling routine.
+ */
+ if (m->enpassant) {
+ if (b->square[(m->piece.color == WHITE)
+ ? 3 : 4][m->tox].color ==
+ ((m->piece.color == WHITE) ?
+ BLACK : WHITE))
+ break;
+ }
+ return (false);
+ }
+ return (false);
+
+ case ROOK:
+ if (m->fromx == m->tox) {
+ for (y = m->fromy + ((m->fromy > m->toy) ? -1 :
+ 1); y != m->toy; y += ((m->fromy
+ > m->toy) ? -1 : 1))
+ if (b->square[y][m->tox].color != NONE)
+ return (false);
+ break;
+ }
+ if (m->fromy == m->toy) {
+ for (x = m->fromx + ((m->fromx > m->tox) ? -1 :
+ 1); x != m->tox; x += ((m->fromx
+ > m->tox) ? -1 : 1))
+ if (b->square[m->toy][x].color != NONE)
+ return (false);
+ break;
+ }
+ return (false);
+
+ case KNIGHT:
+ x = m->fromx - m->tox;
+ y = m->fromy - m->toy;
+ if ((((x == 2) || (x == -2)) &&
+ ((y == 1) || (y == -1))) ||
+ (((x == 1) || (x == -1)) &&
+ ((y == 2) || (y == -2))))
+ break;
+ return (false);
+
+ case BISHOP:
+ x = m->fromx - m->tox;
+ y = m->fromy - m->toy;
+ if ((x != y) && (x != - y))
+ return (false);
+ for (x = m->fromx + ((m->fromx > m->tox) ? -1 : 1), y =
+ m->fromy + ((m->fromy > m->toy) ? -1 :
+ 1); x != m->tox;
+ x += ((m->fromx > m->tox) ? -1 : 1),
+ y += ((m->fromy > m->toy) ? -1 : 1))
+ if (b->square[y][x].color != NONE)
+ return (false);
+ break;
+
+ case QUEEN:
+ if (m->fromx == m->tox) {
+ for (y = m->fromy + ((m->fromy > m->toy) ? -1 :
+ 1); y != m->toy; y += ((m->fromy
+ > m->toy) ? -1 : 1))
+ if (b->square[y][m->tox].color != NONE)
+ return (false);
+ break;
+ }
+ if (m->fromy == m->toy) {
+ for (x = m->fromx + ((m->fromx > m->tox) ? -1 :
+ 1); x != m->tox; x += ((m->fromx
+ > m->tox) ? -1 : 1))
+ if (b->square[m->toy][x].color != NONE)
+ return (false);
+ break;
+ }
+ x = m->fromx - m->tox;
+ y = m->fromy - m->toy;
+ if ((x != y) && (x != - y))
+ return (false);
+ for (x = m->fromx + ((m->fromx > m->tox) ? -1 : 1), y =
+ m->fromy + ((m->fromy > m->toy) ? -1 :
+ 1); x != m->tox;
+ x += ((m->fromx > m->tox) ? -1 : 1),
+ y += ((m->fromy > m->toy) ? -1 : 1))
+ if (b->square[y][x].color != NONE)
+ return (false);
+ break;
+
+ case KING:
+ x = m->fromx - m->tox;
+ y = m->fromy - m->toy;
+ if ((x >= -1) && (x <= 1) && (y >= -1) && (y <= 1))
+ break;
+ return (false);
+ }
+ break;
+ }
+ return (true);
+}
+
+/* Say whether either king is in check... If move is non-NULL, say whether he
+ * in in check after the move takes place. We do this in a rather stupid way.
+ */
+
+static bool
+ischeck(b, col)
+ board *b;
+ color col;
+{
+ int x, y, kx, ky;
+ move ch;
+
+ for (x = 0; x < SIZE; x++)
+ for (y = 0; y < SIZE; y++)
+ if ((b->square[y][x].color == col) &&
+ (b->square[y][x].type == KING)) {
+ kx = x;
+ ky = y;
+ }
+
+ for (x = 0; x < SIZE; x++)
+ for (y = 0; y < SIZE; y++)
+ if (b->square[y][x].color == ((col == WHITE) ?
+ BLACK : WHITE)) {
+ ch.type = CAPTURE;
+ ch.piece.color = b->square[y][x].color;
+ ch.piece.type = b->square[y][x].type;
+ ch.fromx = x;
+ ch.fromy = y;
+ ch.tox = kx;
+ ch.toy = ky;
+ ch.enpassant = false;
+ if (couldmove(&ch, b))
+ return (true);
+ }
+
+ return (false);
+}
+
diff --git a/gnu/games/chess/Xchess/window.c b/gnu/games/chess/Xchess/window.c
new file mode 100644
index 000000000000..4aae06d9ad90
--- /dev/null
+++ b/gnu/games/chess/Xchess/window.c
@@ -0,0 +1,952 @@
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.5 $ on $Date: 86/11/26 12:11:15 $
+ * $Source: /users/faustus/xchess/RCS/window.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ * Deal with the two (or one) windows.
+ */
+
+#include "xchess.h"
+#include <X11/Xutil.h>
+#include <sys/time.h>
+
+#include "pawn.bitmap"
+#include "rook.bitmap"
+#include "knight.bitmap"
+#include "bishop.bitmap"
+#include "queen.bitmap"
+#include "king.bitmap"
+
+#include "pawn_outline.bitmap"
+#include "rook_outline.bitmap"
+#include "knight_outline.bitmap"
+#include "bishop_outline.bitmap"
+#include "queen_outline.bitmap"
+#include "king_outline.bitmap"
+
+#include "pawn_mask.bitmap"
+#include "rook_mask.bitmap"
+#include "knight_mask.bitmap"
+#include "bishop_mask.bitmap"
+#include "queen_mask.bitmap"
+#include "king_mask.bitmap"
+
+#include "shade.bitmap"
+
+#include "xchess.cur"
+#include "xchess_mask.cur"
+
+#include "xchess.icon"
+
+windata *win1, *win2;
+bool win_flashmove = false;
+
+extern bool setup();
+extern void service(), drawgrid(), icon_refresh();
+
+bool
+win_setup(disp1, disp2)
+ char *disp1, *disp2;
+{
+ win1 = alloc(windata);
+ if (!oneboard)
+ win2 = alloc(windata);
+
+ if (!setup(disp1, win1) || (!oneboard && !setup(disp2, win2)))
+ return (false);
+
+ if (blackflag) {
+ win1->color = BLACK;
+ win1->flipped = true;
+ } else
+ win1->color = WHITE;
+ win_drawboard(win1);
+
+ if (!oneboard) {
+ win2->color = BLACK;
+ win2->flipped = true;
+ win_drawboard(win2);
+ }
+
+ return(true);
+}
+
+/* Draw the chess board... */
+
+void
+win_drawboard(win)
+ windata *win;
+{
+ int i, j;
+
+ drawgrid(win);
+
+ /* Now toss on the squares... */
+ for (i = 0; i < SIZE; i++)
+ for (j = 0; j < SIZE; j++)
+ win_erasepiece(j, i, win->color);
+
+ return;
+}
+
+/* Draw one piece. */
+
+void
+win_drawpiece(p, y, x, wnum)
+ piece *p;
+ int y, x;
+ color wnum;
+{
+ char *bits, *maskbits, *outline;
+ windata *win;
+ char buf[BSIZE];
+ XImage *tmpImage;
+ Pixmap tmpPM, maskPM;
+ XGCValues gc;
+
+ if (oneboard || (wnum == win1->color))
+ win = win1;
+ else
+ win = win2;
+
+ if (win->flipped) {
+ y = SIZE - y - 1;
+ x = SIZE - x - 1;
+ }
+
+ /*
+ if (debug)
+ fprintf(stderr, "draw a %s at (%d, %d) on board %d\n",
+ piecenames[(int) p->type], y, x, wnum);
+ */
+
+ if ((x < 0) || (x > 7) || (y < 0) || (y > 7)) exit(1);
+
+ switch (p->type) {
+ case PAWN:
+ bits = pawn_bits;
+ maskbits = pawn_mask_bits;
+ outline = pawn_outline_bits;
+ break;
+
+ case ROOK:
+ bits = rook_bits;
+ maskbits = rook_mask_bits;
+ outline = rook_outline_bits;
+ break;
+
+ case KNIGHT:
+ bits = knight_bits;
+ maskbits = knight_mask_bits;
+ outline = knight_outline_bits;
+ break;
+
+ case BISHOP:
+ bits = bishop_bits;
+ maskbits = bishop_mask_bits;
+ outline = bishop_outline_bits;
+ break;
+
+ case QUEEN:
+ bits = queen_bits;
+ maskbits = queen_mask_bits;
+ outline = queen_outline_bits;
+ break;
+
+ case KING:
+ bits = king_bits;
+ maskbits = king_mask_bits;
+ outline = king_outline_bits;
+ break;
+
+ default:
+ fprintf(stderr,
+ "Internal Error: win_drawpiece: bad piece type %d\n",
+ p->type);
+ }
+
+ /* There are two things we can do... If this is a black and white
+ * display, we have to shade the square and use an outline if the piece
+ * is white. We also have to use a mask... Since we don't want
+ * to use up too many bitmaps, create the mask bitmap, put the bits,
+ * and then destroy it.
+ */
+ if (win->bnw && (p->color == WHITE))
+ bits = outline;
+ if (win->bnw && !iswhite(win, x, y)) {
+ XSetState(win->display, DefaultGC(win->display, 0),
+ BlackPixel(win->display, 0),
+ WhitePixel(win->display, 0), GXcopy, AllPlanes);
+
+ tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
+ shade_bits, SQUARE_WIDTH, SQUARE_HEIGHT);
+
+ XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
+ 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
+
+ XFreePixmap(win->display, tmpPM);
+
+ XSetFunction(win->display, DefaultGC(win->display, 0),
+ GXandInverted);
+ maskPM = XCreateBitmapFromData(win->display, win->boardwin,
+ maskbits, SQUARE_WIDTH, SQUARE_HEIGHT);
+ XCopyPlane(win->display, maskPM, win->boardwin, DefaultGC(win->display, 0),
+ 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
+ XFreePixmap(win->display, maskPM);
+
+ XSetFunction(win->display, DefaultGC(win->display, 0),
+ GXor);
+ tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
+ bits, SQUARE_WIDTH, SQUARE_HEIGHT);
+ XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
+ 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
+ XFreePixmap(win->display, tmpPM);
+
+ XSetFunction(win->display, DefaultGC(win->display, 0), GXcopy);
+
+ } else if (win->bnw){
+ XSetState(win->display, DefaultGC(win->display, 0),
+ BlackPixel(win->display, 0),
+ WhitePixel(win->display, 0), GXcopy, AllPlanes);
+
+ tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
+ bits, SQUARE_WIDTH, SQUARE_HEIGHT);
+ XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
+ 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
+ XFreePixmap(win->display, tmpPM);
+ } else {
+ XSetState(win->display, DefaultGC(win->display, 0),
+ ((p->color == WHITE) ? win->whitepiece.pixel :
+ win->blackpiece.pixel),
+ (iswhite(win, x, y) ? win->whitesquare.pixel :
+ win->blacksquare.pixel),
+ GXcopy, AllPlanes);
+ tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
+ bits, SQUARE_WIDTH, SQUARE_HEIGHT);
+ XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
+ 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
+ XFreePixmap(win->display, tmpPM);
+ }
+
+ if (!record_english) {
+ gc.foreground = win->textcolor.pixel;
+ if (iswhite(win, x, y) || win->bnw)
+ gc.background = win->whitesquare.pixel;
+ else
+ gc.background = win->blacksquare.pixel;
+
+ gc.font = win->small->fid;
+
+ XChangeGC(win->display, DefaultGC(win->display, 0),
+ GCForeground | GCBackground | GCFont, &gc);
+
+ if (!x) {
+ sprintf(buf, " %d", SIZE - y);
+ XDrawImageString(win->display, win->boardwin,
+ DefaultGC(win->display, 0),
+ 1, (y + 1) * (SQUARE_HEIGHT +
+ BORDER_WIDTH) - BORDER_WIDTH +
+ win->small->max_bounds.ascent - 1, buf, 2);
+ }
+ if (y == SIZE - 1) {
+ sprintf(buf, "%c", 'A' + x);
+ XDrawImageString(win->display, win->boardwin,
+ DefaultGC(win->display, 0),
+ x * (SQUARE_WIDTH + BORDER_WIDTH) + 1,
+ SIZE * (SQUARE_HEIGHT + BORDER_WIDTH) - BORDER_WIDTH +
+ win->small->max_bounds.ascent - 1, buf, 1);
+ }
+ }
+ return;
+}
+
+void
+win_erasepiece(y, x, wnum)
+ int y, x;
+ color wnum;
+{
+ windata *win;
+ char buf[BSIZE];
+ XGCValues gc;
+ Pixmap tmpPM;
+
+ if (oneboard || (wnum == win1->color))
+ win = win1;
+ else
+ win = win2;
+
+ if (win->flipped) {
+ y = SIZE - y - 1;
+ x = SIZE - x - 1;
+ }
+
+ /*
+ if (debug)
+ fprintf(stderr, "erase square (%d, %d) on board %d\n", y, x,
+ wnum);
+ */
+
+ if ((x < 0) || (x > 7) || (y < 0) || (y > 7)) exit(1);
+
+ if (win->bnw && !iswhite(win, x, y)) {
+ XSetState(win->display, DefaultGC(win->display, 0),
+ BlackPixel(win->display, 0),
+ WhitePixel(win->display, 0), GXcopy, AllPlanes);
+ tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
+ shade_bits, SQUARE_WIDTH, SQUARE_HEIGHT);
+
+ XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
+ 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
+
+ XFreePixmap(win->display, tmpPM);
+ } else {
+ XSetFillStyle(win->display, DefaultGC(win->display, 0),
+ FillSolid);
+ XSetForeground(win->display, DefaultGC(win->display, 0),
+ iswhite(win, x, y) ? win->whitesquare.pixel :
+ win->blacksquare.pixel);
+ XFillRectangle(win->display, win->boardwin,
+ DefaultGC(win->display, 0),
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH),
+ SQUARE_WIDTH, SQUARE_HEIGHT);
+ }
+
+ if (!record_english) {
+ gc.foreground = win->textcolor.pixel;
+ if (iswhite(win, x, y) || win->bnw)
+ gc.background = win->whitesquare.pixel;
+ else
+ gc.background = win->blacksquare.pixel;
+
+ gc.font = win->small->fid;
+
+ XChangeGC(win->display, DefaultGC(win->display, 0),
+ GCForeground | GCBackground | GCFont, &gc);
+
+ if (!x) {
+ sprintf(buf, " %d", SIZE - y);
+ XDrawImageString(win->display, win->boardwin,
+ DefaultGC(win->display, 0),
+ 1, (y + 1) * (SQUARE_HEIGHT +
+ BORDER_WIDTH) - BORDER_WIDTH +
+ win->small->max_bounds.ascent - 1, buf, 2);
+ }
+ if (y == SIZE - 1) {
+ sprintf(buf, "%c", 'A' + x);
+ XDrawImageString(win->display, win->boardwin,
+ DefaultGC(win->display, 0),
+ x * (SQUARE_WIDTH + BORDER_WIDTH) + 1,
+ SIZE * (SQUARE_HEIGHT + BORDER_WIDTH) - BORDER_WIDTH +
+ win->small->max_bounds.ascent - 1, buf, 1);
+ }
+ }
+
+
+ return;
+}
+
+void
+win_flash(m, wnum)
+ move *m;
+ color wnum;
+{
+ windata *win;
+ int sx, sy, ex, ey, i;
+
+ if (oneboard || (wnum == win1->color))
+ win = win1;
+ else
+ win = win2;
+
+ if (win->flipped) {
+ sx = SIZE - m->fromx - 1;
+ sy = SIZE - m->fromy - 1;
+ ex = SIZE - m->tox - 1;
+ ey = SIZE - m->toy - 1;
+ } else {
+ sx = m->fromx;
+ sy = m->fromy;
+ ex = m->tox;
+ ey = m->toy;
+ }
+ sx = sx * (SQUARE_WIDTH + BORDER_WIDTH) + SQUARE_WIDTH / 2;
+ sy = sy * (SQUARE_HEIGHT + BORDER_WIDTH) + SQUARE_HEIGHT / 2;
+ ex = ex * (SQUARE_WIDTH + BORDER_WIDTH) + SQUARE_WIDTH / 2;
+ ey = ey * (SQUARE_HEIGHT + BORDER_WIDTH) + SQUARE_HEIGHT / 2;
+
+ XSetFunction(win->display, DefaultGC(win->display, 0), GXinvert);
+ XSetLineAttributes(win->display, DefaultGC(win->display, 0),
+ 0, LineSolid, 0, 0);
+ for (i = 0; i < num_flashes * 2; i++) {
+ XDrawLine(win->display,win->boardwin,
+ DefaultGC(win->display, 0),
+ sx, sy, ex, ey);
+ }
+
+ XSetFunction(win->display, DefaultGC(win->display, 0), GXcopy);
+ return;
+}
+
+/* Handle input from the players. */
+
+void
+win_process(quick)
+ bool quick;
+{
+ int i, rfd = 0, wfd = 0, xfd = 0;
+ struct timeval timeout;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = (quick ? 0 : 500000);
+
+ if (XPending(win1->display))
+ service(win1);
+ if (!oneboard) {
+ if (XPending(win1->display))
+ service(win2);
+ }
+
+ if (oneboard)
+ rfd = 1 << win1->display->fd;
+ else
+ rfd = (1 << win1->display->fd) | (1 << win2->display->fd);
+ if (!(i = select(32, &rfd, &wfd, &xfd, &timeout)))
+ return;
+ if (i == -1) {
+ perror("select");
+ exit(1);
+ }
+ if (rfd & (1 << win1->display->fd))
+ service(win1);
+ if (!oneboard && (rfd & (1 << win2->display->fd)))
+ service(win2);
+
+ return;
+}
+
+static void
+service(win)
+ windata *win;
+{
+ XEvent ev;
+
+ while(XPending(win->display)) {
+ XNextEvent(win->display, &ev);
+ if (TxtFilter(win->display, &ev))
+ continue;
+
+ if (ev.xany.window == win->boardwin) {
+ switch (ev.type) {
+ case ButtonPress:
+ button_pressed(&ev, win);
+ break;
+
+ case ButtonRelease:
+ button_released(&ev, win);
+ break;
+
+ case Expose:
+ /* Redraw... */
+ win_redraw(win, &ev);
+ break;
+
+ case 0:
+ case NoExpose:
+ break;
+ default:
+ fprintf(stderr, "Bad event type %d\n", ev.type);
+ exit(1);
+ }
+ } else if (ev.xany.window == win->wclockwin) {
+ switch (ev.type) {
+ case Expose:
+ clock_draw(win, WHITE);
+ break;
+
+ case 0:
+ case NoExpose:
+ break;
+ default:
+ fprintf(stderr, "Bad event type %d\n", ev.type);
+ exit(1);
+ }
+ } else if (ev.xany.window == win->bclockwin) {
+ switch (ev.type) {
+ case Expose:
+ clock_draw(win, BLACK);
+ break;
+
+ case 0:
+ case NoExpose:
+ break;
+ default:
+ fprintf(stderr, "Bad event type %d\n", ev.type);
+ exit(1);
+ }
+ } else if (ev.xany.window == win->jailwin) {
+ switch (ev.type) {
+ case Expose:
+ jail_draw(win);
+ break;
+
+ case 0:
+ case NoExpose:
+ break;
+ default:
+ fprintf(stderr, "Bad event type %d\n", ev.type);
+ exit(1);
+ }
+ } else if (ev.xany.window == win->buttonwin) {
+ switch (ev.type) {
+ case ButtonPress:
+ button_service(win, &ev);
+ break;
+
+ case Expose:
+ button_draw(win);
+ break;
+
+ case 0:
+ case NoExpose:
+ break;
+ default:
+ fprintf(stderr, "Bad event type %d\n", ev.type);
+ exit(1);
+ }
+ } else if (ev.xany.window == win->icon) {
+ icon_refresh(win);
+ } else if (ev.xany.window == win->basewin) {
+ message_send(win, &ev);
+ } else {
+ fprintf(stderr, "Internal Error: service: bad win\n");
+ fprintf(stderr, "window = %d, event = %d\n", ev.xany.window,
+ ev.type);
+ }
+ }
+ return;
+}
+
+void
+win_redraw(win, event)
+ windata *win;
+ XEvent *event;
+{
+ XExposeEvent *ev = &event->xexpose;
+ int x1, y1, x2, y2, i, j;
+
+ drawgrid(win);
+ if (ev) {
+ x1 = ev->x / (SQUARE_WIDTH + BORDER_WIDTH);
+ y1 = ev->y / (SQUARE_HEIGHT + BORDER_WIDTH);
+ x2 = (ev->x + ev->width) / (SQUARE_WIDTH + BORDER_WIDTH);
+ y2 = (ev->y + ev->height) / (SQUARE_HEIGHT + BORDER_WIDTH);
+ } else {
+ x1 = 0;
+ y1 = 0;
+ x2 = SIZE - 1;
+ y2 = SIZE - 1;
+ }
+
+ if (x1 < 0) x1 = 0;
+ if (y1 < 0) y1 = 0;
+ if (x2 < 0) x2 = 0;
+ if (y2 < 0) y2 = 0;
+ if (x1 > SIZE - 1) x1 = SIZE - 1;
+ if (y1 > SIZE - 1) y1 = SIZE - 1;
+ if (x2 > SIZE - 1) x2 = SIZE - 1;
+ if (y2 > SIZE - 1) y2 = SIZE - 1;
+
+ if (win->flipped) {
+ y1 = SIZE - y2 - 1;
+ y2 = SIZE - y1 - 1;
+ x1 = SIZE - x2 - 1;
+ x2 = SIZE - x1 - 1;
+ }
+
+ for (i = x1; i <= x2; i++)
+ for (j = y1; j <= y2; j++) {
+ if (chessboard->square[j][i].color == NONE)
+ win_erasepiece(j, i, WHITE);
+ else
+ win_drawpiece(&chessboard->square[j][i], j, i,
+ WHITE);
+ if (!oneboard) {
+ if (chessboard->square[j][i].color == NONE)
+ win_erasepiece(j, i, BLACK);
+ else
+ win_drawpiece(&chessboard->square[j][i],
+ j, i, BLACK);
+ }
+ }
+
+ return;
+}
+
+static bool
+setup(dispname, win)
+ char *dispname;
+ windata *win;
+{
+ char buf[BSIZE], *s;
+ Pixmap bm, bmask;
+ Cursor cur;
+ extern char *program, *recfile;
+ XSizeHints xsizes;
+
+
+ if (!(win->display = XOpenDisplay(dispname)))
+ return (false);
+
+
+ /* Now get boolean defaults... */
+ if ((s = XGetDefault(win->display, program, "noisy")) && eq(s, "on"))
+ noisyflag = true;
+ if ((s = XGetDefault(win->display, program, "savemoves")) && eq(s, "on"))
+ saveflag = true;
+ if ((s = XGetDefault(win->display, program, "algebraic")) && eq(s, "on"))
+ record_english = false;
+ if ((s = XGetDefault(win->display, program, "blackandwhite")) && eq(s, "on"))
+ bnwflag = true;
+ if ((s = XGetDefault(win->display, program, "quickrestore")) && eq(s, "on"))
+ quickflag = true;
+ if ((s = XGetDefault(win->display, program, "flash")) && eq(s, "on"))
+ win_flashmove = true;
+
+ /* ... numeric variables ... */
+ if (s = XGetDefault(win->display, program, "numflashes"))
+ num_flashes = atoi(s);
+ if (s = XGetDefault(win->display, program, "flashsize"))
+ flash_size = atoi(s);
+
+ /* ... and strings. */
+ if (s = XGetDefault(win->display, program, "progname"))
+ progname = s;
+ if (s = XGetDefault(win->display, program, "proghost"))
+ proghost = s;
+ if (s = XGetDefault(win->display, program, "recordfile"))
+ recfile = s;
+ if (s = XGetDefault(win->display, program, "blackpiece"))
+ black_piece_color = s;
+ if (s = XGetDefault(win->display, program, "whitepiece"))
+ white_piece_color = s;
+ if (s = XGetDefault(win->display, program, "blacksquare"))
+ black_square_color = s;
+ if (s = XGetDefault(win->display, program, "whitesquare"))
+ white_square_color = s;
+ if (s = XGetDefault(win->display, program, "bordercolor"))
+ border_color = s;
+ if (s = XGetDefault(win->display, program, "textcolor"))
+ text_color = s;
+ if (s = XGetDefault(win->display, program, "textback"))
+ text_back = s;
+ if (s = XGetDefault(win->display, program, "errortext"))
+ error_text = s;
+ if (s = XGetDefault(win->display, program, "playertext"))
+ player_text = s;
+ if (s = XGetDefault(win->display, program, "cursorcolor"))
+ cursor_color = s;
+
+ if ((DisplayPlanes(win->display, 0) == 1) || bnwflag)
+ win->bnw = true;
+
+ /* Allocate colors... */
+ if (win->bnw) {
+ win->blackpiece.pixel = BlackPixel (win->display, 0);
+ win->whitepiece.pixel = WhitePixel (win->display, 0);
+ win->blacksquare.pixel = BlackPixel (win->display, 0);
+ win->whitesquare.pixel = WhitePixel (win->display, 0);
+ win->border.pixel = BlackPixel (win->display, 0);
+ win->textcolor.pixel = BlackPixel (win->display, 0);
+ win->textback.pixel = WhitePixel (win->display, 0);
+ win->playertext.pixel = BlackPixel (win->display, 0);
+ win->errortext.pixel = BlackPixel (win->display, 0);
+ win->cursorcolor.pixel = BlackPixel (win->display, 0) ;
+ } else {
+ if (!XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ black_piece_color, &win->blackpiece) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ white_piece_color, &win->whitepiece) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ black_square_color, &win->blacksquare) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ white_square_color, &win->whitesquare) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ border_color, &win->border) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ text_color, &win->textcolor) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ text_back, &win->textback) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ error_text, &win->errortext) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ player_text, &win->playertext) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ cursor_color, &win->cursorcolor) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->blackpiece) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->whitepiece) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->blacksquare) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->whitesquare) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->border) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->textcolor) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->textback) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->errortext) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->playertext) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->cursorcolor))
+ fprintf(stderr, "Can't get colors...\n");
+ }
+
+ /* Get fonts... */
+ if ((win->small = XLoadQueryFont(win->display,SMALL_FONT)) ==
+ NULL)
+ fprintf(stderr, "Can't get small font...\n");
+
+ if ((win->medium = XLoadQueryFont(win->display,MEDIUM_FONT))
+ == NULL)
+ fprintf(stderr, "Can't get medium font...\n");
+
+ if ((win->large = XLoadQueryFont(win->display,LARGE_FONT)) ==
+ NULL)
+ fprintf(stderr, "Can't get large font...\n");
+
+
+ /* Create the windows... */
+
+ win->basewin =
+ XCreateSimpleWindow(win->display,DefaultRootWindow(win->display),
+ BASE_XPOS, BASE_YPOS,
+ BASE_WIDTH, BASE_HEIGHT, 0,
+ BlackPixel(win->display, 0),
+ WhitePixel(win->display, 0));
+ win->boardwin = XCreateSimpleWindow(win->display,win->basewin,
+ BOARD_XPOS, BOARD_YPOS,
+ BOARD_WIDTH, BOARD_HEIGHT,
+ BORDER_WIDTH,
+ win->border.pixel,
+ WhitePixel(win->display, 0));
+ win->recwin = XCreateSimpleWindow(win->display,win->basewin,
+ RECORD_XPOS, RECORD_YPOS,
+ RECORD_WIDTH, RECORD_HEIGHT,
+ BORDER_WIDTH, win->border.pixel,
+ win->textback.pixel);
+ win->jailwin = XCreateSimpleWindow(win->display,win->basewin,
+ JAIL_XPOS, JAIL_YPOS,
+ JAIL_WIDTH, JAIL_HEIGHT,
+ BORDER_WIDTH,
+ win->border.pixel,
+ win->textback.pixel);
+ win->wclockwin = XCreateSimpleWindow(win->display,win->basewin,
+ WCLOCK_XPOS, WCLOCK_YPOS,
+ CLOCK_WIDTH, CLOCK_HEIGHT,
+ BORDER_WIDTH, win->border.pixel,
+ win->textback.pixel);
+ win->bclockwin = XCreateSimpleWindow(win->display,win->basewin,
+ BCLOCK_XPOS, BCLOCK_YPOS,
+ CLOCK_WIDTH, CLOCK_HEIGHT,
+ BORDER_WIDTH, win->border.pixel,
+ win->textback.pixel);
+ win->messagewin = XCreateSimpleWindow(win->display,win->basewin,
+ MESS_XPOS, MESS_YPOS,
+ MESS_WIDTH, MESS_HEIGHT,
+ BORDER_WIDTH, win->border.pixel,
+ win->textback.pixel);
+ win->buttonwin = XCreateSimpleWindow(win->display,win->basewin,
+ BUTTON_XPOS, BUTTON_YPOS,
+ BUTTON_WIDTH, BUTTON_HEIGHT,
+ BORDER_WIDTH, win->border.pixel,
+ win->textback.pixel);
+
+ /* Let's define an icon... */
+ win->iconpixmap = XCreatePixmapFromBitmapData(win->display,
+ win->basewin, icon_bits,
+ icon_width, icon_height,
+ win->blacksquare.pixel,
+ win->whitesquare.pixel,
+ 1);
+ xsizes.flags = PSize | PMinSize | PPosition;
+ xsizes.min_width = BASE_WIDTH;
+ xsizes.min_height = BASE_HEIGHT;
+ xsizes.x = BASE_XPOS;
+ xsizes.y = BASE_YPOS;
+ XSetStandardProperties(win->display, win->basewin,
+ program, program, win->iconpixmap,
+ 0, NULL, &xsizes);
+
+ bm = XCreateBitmapFromData(win->display,
+ win->basewin, xchess_bits,
+ xchess_width, xchess_height);
+ bmask = XCreateBitmapFromData(win->display,
+ win->basewin, xchess_mask_bits,
+ xchess_width, xchess_height);
+ cur = XCreatePixmapCursor(win->display, bm, bmask,
+ &win->cursorcolor,
+ &WhitePixel(win->display, 0),
+ xchess_x_hot, xchess_y_hot);
+ XFreePixmap(win->display, bm);
+ XFreePixmap(win->display, bmask);
+
+ XDefineCursor(win->display,win->basewin, cur);
+
+ XMapSubwindows(win->display,win->basewin);
+ XMapRaised(win->display,win->basewin);
+
+ XSelectInput(win->display,win->basewin, KeyPressMask);
+ XSelectInput(win->display,win->boardwin,
+ ButtonPressMask | ButtonReleaseMask | ExposureMask);
+ XSelectInput(win->display,win->recwin,
+ ButtonReleaseMask | ExposureMask);
+ XSelectInput(win->display,win->jailwin, ExposureMask);
+ XSelectInput(win->display,win->wclockwin, ExposureMask);
+ XSelectInput(win->display,win->bclockwin, ExposureMask);
+ XSelectInput(win->display,win->messagewin,
+ ButtonReleaseMask | ExposureMask);
+ XSelectInput(win->display,win->buttonwin,
+ ButtonPressMask | ExposureMask);
+
+ message_init(win);
+ record_init(win);
+ button_draw(win);
+ jail_init(win);
+ clock_init(win, WHITE);
+ clock_init(win, BLACK);
+ if (timeunit) {
+ if (timeunit > 1800)
+ sprintf(buf, "%d moves every %.2lg hours.\n",
+ movesperunit, ((double) timeunit) / 3600);
+ else if (timeunit > 30)
+ sprintf(buf, "%d moves every %.2lg minutes.\n",
+ movesperunit, ((double) timeunit) / 60);
+ else
+ sprintf(buf, "%d moves every %d seconds.\n",
+ movesperunit, timeunit);
+ message_add(win, buf, false);
+ }
+ return (true);
+}
+
+static void
+drawgrid(win)
+ windata *win;
+{
+ int i;
+ XGCValues gc;
+
+ gc.function = GXcopy;
+ gc.plane_mask = AllPlanes;
+ gc.foreground = win->border.pixel;
+ gc.line_width = 0;
+ gc.line_style = LineSolid;
+
+ XChangeGC(win->display,
+ DefaultGC(win->display, 0),
+ GCFunction | GCPlaneMask | GCForeground |
+ GCLineWidth | GCLineStyle, &gc);
+
+ /* Draw the lines... horizontal, */
+ for (i = 1; i < SIZE; i++)
+ XDrawLine(win->display, win->boardwin,
+ DefaultGC(win->display, 0), 0,
+ i * (SQUARE_WIDTH + BORDER_WIDTH) -
+ BORDER_WIDTH / 2,
+ SIZE * (SQUARE_WIDTH + BORDER_WIDTH),
+ i * (SQUARE_WIDTH + BORDER_WIDTH) -
+ BORDER_WIDTH / 2);
+
+ /* and vertical... */
+ for (i = 1; i < SIZE; i++)
+ XDrawLine(win->display, win->boardwin,
+ DefaultGC(win->display, 0),
+ i * (SQUARE_WIDTH + BORDER_WIDTH) -
+ BORDER_WIDTH / 2, 0,
+ i * (SQUARE_WIDTH + BORDER_WIDTH) -
+ BORDER_WIDTH / 2,
+ SIZE * (SQUARE_WIDTH + BORDER_WIDTH));
+ return;
+}
+
+void
+win_restart()
+{
+ win1->flipped = false;
+ win_redraw(win1, (XEvent *) NULL);
+ if (!oneboard) {
+ win2->flipped = true;
+ win_redraw(win2, (XEvent *) NULL);
+ }
+ return;
+}
+
+static void
+icon_refresh(win)
+ windata *win;
+{
+ XCopyArea(win->display, win->iconpixmap, win->icon,
+ DefaultGC(win->display, 0),
+ 0, 0, icon_width, icon_height, 0, 0);
+ return;
+}
+
diff --git a/gnu/games/chess/Xchess/window.c.bm b/gnu/games/chess/Xchess/window.c.bm
new file mode 100644
index 000000000000..19134d0cdc14
--- /dev/null
+++ b/gnu/games/chess/Xchess/window.c.bm
@@ -0,0 +1,928 @@
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.5 $ on $Date: 86/11/26 12:11:15 $
+ * $Source: /users/faustus/xchess/RCS/window.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ * Deal with the two (or one) windows.
+ */
+
+#include "xchess.h"
+#include <sys/time.h>
+
+#include "pawn.bitmap"
+#include "rook.bitmap"
+#include "knight.bitmap"
+#include "bishop.bitmap"
+#include "queen.bitmap"
+#include "king.bitmap"
+
+#include "pawn_outline.bitmap"
+#include "rook_outline.bitmap"
+#include "knight_outline.bitmap"
+#include "bishop_outline.bitmap"
+#include "queen_outline.bitmap"
+#include "king_outline.bitmap"
+
+#include "pawn_mask.bitmap"
+#include "rook_mask.bitmap"
+#include "knight_mask.bitmap"
+#include "bishop_mask.bitmap"
+#include "queen_mask.bitmap"
+#include "king_mask.bitmap"
+
+#include "shade.bitmap"
+
+#include "xchess.cur"
+#include "xchess_mask.cur"
+
+#include "xchess.icon"
+
+windata *win1, *win2;
+bool win_flashmove = false;
+
+extern bool setup();
+extern void service(), drawgrid(), icon_refresh();
+
+bool
+win_setup(disp1, disp2)
+ char *disp1, *disp2;
+{
+ win1 = alloc(windata);
+ if (!oneboard)
+ win2 = alloc(windata);
+
+ if (!setup(disp1, win1) || (!oneboard && !setup(disp2, win2)))
+ return (false);
+
+ if (blackflag) {
+ win1->color = BLACK;
+ win1->flipped = true;
+ } else
+ win1->color = WHITE;
+ win_drawboard(win1);
+
+ if (!oneboard) {
+ win2->color = BLACK;
+ win2->flipped = true;
+ win_drawboard(win2);
+ }
+
+ return(true);
+}
+
+/* Draw the chess board... */
+
+void
+win_drawboard(win)
+ windata *win;
+{
+ int i, j;
+
+ drawgrid(win);
+
+ /* Now toss on the squares... */
+ for (i = 0; i < SIZE; i++)
+ for (j = 0; j < SIZE; j++)
+ win_erasepiece(j, i, win->color);
+
+ return;
+}
+
+/* Draw one piece. */
+
+void
+win_drawpiece(p, y, x, wnum)
+ piece *p;
+ int y, x;
+ color wnum;
+{
+ char *bits, *maskbits, *outline;
+ windata *win;
+ char buf[BSIZE];
+ XImage *tmpImage;
+ Pixmap tmpPM, maskPM;
+ XGCValues gc;
+
+ if (oneboard || (wnum == win1->color))
+ win = win1;
+ else
+ win = win2;
+
+ if (win->flipped) {
+ y = SIZE - y - 1;
+ x = SIZE - x - 1;
+ }
+
+ /*
+ if (debug)
+ fprintf(stderr, "draw a %s at (%d, %d) on board %d\n",
+ piecenames[(int) p->type], y, x, wnum);
+ */
+
+ if ((x < 0) || (x > 7) || (y < 0) || (y > 7)) exit(1);
+
+ switch (p->type) {
+ case PAWN:
+ bits = pawn_bits;
+ maskbits = pawn_mask_bits;
+ outline = pawn_outline_bits;
+ break;
+
+ case ROOK:
+ bits = rook_bits;
+ maskbits = rook_mask_bits;
+ outline = rook_outline_bits;
+ break;
+
+ case KNIGHT:
+ bits = knight_bits;
+ maskbits = knight_mask_bits;
+ outline = knight_outline_bits;
+ break;
+
+ case BISHOP:
+ bits = bishop_bits;
+ maskbits = bishop_mask_bits;
+ outline = bishop_outline_bits;
+ break;
+
+ case QUEEN:
+ bits = queen_bits;
+ maskbits = queen_mask_bits;
+ outline = queen_outline_bits;
+ break;
+
+ case KING:
+ bits = king_bits;
+ maskbits = king_mask_bits;
+ outline = king_outline_bits;
+ break;
+
+ default:
+ fprintf(stderr,
+ "Internal Error: win_drawpiece: bad piece type %d\n",
+ p->type);
+ }
+
+ /* There are two things we can do... If this is a black and white
+ * display, we have to shade the square and use an outline if the piece
+ * is white. We also have to use a mask... Since we don't want
+ * to use up too many bitmaps, create the mask bitmap, put the bits,
+ * and then destroy it.
+ */
+ if (win->bnw && (p->color == WHITE))
+ bits = outline;
+ if (win->bnw && !iswhite(win, x, y)) {
+ XSetState(win->display, DefaultGC(win->display, 0),
+ BlackPixel(win->display, 0),
+ WhitePixel(win->display, 0), GXcopy, AllPlanes);
+
+ tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
+ shade_bits, SQUARE_WIDTH, SQUARE_HEIGHT);
+
+ XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
+ 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
+
+ XFreePixmap(win->display, tmpPM);
+
+ XSetFunction(win->display, DefaultGC(win->display, 0),
+ GXandInverted);
+ maskPM = XCreateBitmapFromData(win->display, win->boardwin,
+ maskbits, SQUARE_WIDTH, SQUARE_HEIGHT);
+ XCopyPlane(win->display, maskPM, win->boardwin, DefaultGC(win->display, 0),
+ 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
+ XFreePixmap(win->display, maskPM);
+
+ XSetFunction(win->display, DefaultGC(win->display, 0),
+ GXor);
+ tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
+ bits, SQUARE_WIDTH, SQUARE_HEIGHT);
+ XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
+ 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
+ XFreePixmap(win->display, tmpPM);
+
+ XSetFunction(win->display, DefaultGC(win->display, 0), GXcopy);
+
+ } else if (win->bnw){
+ XSetState(win->display, DefaultGC(win->display, 0),
+ BlackPixel(win->display, 0),
+ WhitePixel(win->display, 0), GXcopy, AllPlanes);
+
+ tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
+ bits, SQUARE_WIDTH, SQUARE_HEIGHT);
+ XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
+ 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
+ XFreePixmap(win->display, tmpPM);
+ } else {
+ XSetState(win->display, DefaultGC(win->display, 0),
+ ((p->color == WHITE) ? win->whitepiece.pixel :
+ win->blackpiece.pixel),
+ (iswhite(win, x, y) ? win->whitesquare.pixel :
+ win->blacksquare.pixel),
+ GXcopy, AllPlanes);
+ tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
+ bits, SQUARE_WIDTH, SQUARE_HEIGHT);
+ XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
+ 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
+ XFreePixmap(win->display, tmpPM);
+ }
+
+ if (!record_english) {
+ gc.foreground = win->textcolor.pixel;
+ if (iswhite(win, x, y) || win->bnw)
+ gc.background = win->whitesquare.pixel;
+ else
+ gc.background = win->blacksquare.pixel;
+
+ gc.font = win->small->fid;
+
+ XChangeGC(win->display, DefaultGC(win->display, 0),
+ GCForeground | GCBackground | GCFont, &gc);
+
+ if (!x) {
+ sprintf(buf, " %d", SIZE - y);
+ XDrawImageString(win->display, win->boardwin,
+ DefaultGC(win->display, 0),
+ 1, (y + 1) * (SQUARE_HEIGHT +
+ BORDER_WIDTH) - BORDER_WIDTH +
+ win->small->max_bounds.ascent - 1, buf, 2);
+ }
+ if (y == SIZE - 1) {
+ sprintf(buf, "%c", 'A' + x);
+ XDrawImageString(win->display, win->boardwin,
+ DefaultGC(win->display, 0),
+ x * (SQUARE_WIDTH + BORDER_WIDTH) + 1,
+ SIZE * (SQUARE_HEIGHT + BORDER_WIDTH) - BORDER_WIDTH +
+ win->small->max_bounds.ascent - 1, buf, 1);
+ }
+ }
+ return;
+}
+
+void
+win_erasepiece(y, x, wnum)
+ int y, x;
+ color wnum;
+{
+ windata *win;
+ char buf[BSIZE];
+ XGCValues gc;
+ Pixmap tmpPM;
+
+ if (oneboard || (wnum == win1->color))
+ win = win1;
+ else
+ win = win2;
+
+ if (win->flipped) {
+ y = SIZE - y - 1;
+ x = SIZE - x - 1;
+ }
+
+ /*
+ if (debug)
+ fprintf(stderr, "erase square (%d, %d) on board %d\n", y, x,
+ wnum);
+ */
+
+ if ((x < 0) || (x > 7) || (y < 0) || (y > 7)) exit(1);
+
+ if (win->bnw && !iswhite(win, x, y)) {
+ XSetState(win->display, DefaultGC(win->display, 0),
+ BlackPixel(win->display, 0),
+ WhitePixel(win->display, 0), GXcopy, AllPlanes);
+ tmpPM = XCreateBitmapFromData(win->display, win->boardwin,
+ shade_bits, SQUARE_WIDTH, SQUARE_HEIGHT);
+
+ XCopyPlane(win->display, tmpPM, win->boardwin, DefaultGC(win->display, 0),
+ 0, 0, SQUARE_WIDTH, SQUARE_HEIGHT,
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH), 1);
+
+ XFreePixmap(win->display, tmpPM);
+ } else {
+ XSetFillStyle(win->display, DefaultGC(win->display, 0),
+ FillSolid);
+ XSetForeground(win->display, DefaultGC(win->display, 0),
+ iswhite(win, x, y) ? win->whitesquare.pixel :
+ win->blacksquare.pixel);
+ XFillRectangle(win->display, win->boardwin,
+ DefaultGC(win->display, 0),
+ x * (SQUARE_WIDTH + BORDER_WIDTH),
+ y * (SQUARE_HEIGHT + BORDER_WIDTH),
+ SQUARE_WIDTH, SQUARE_HEIGHT);
+ }
+
+ if (!record_english) {
+ gc.foreground = win->textcolor.pixel;
+ if (iswhite(win, x, y) || win->bnw)
+ gc.background = win->whitesquare.pixel;
+ else
+ gc.background = win->blacksquare.pixel;
+
+ gc.font = win->small->fid;
+
+ XChangeGC(win->display, DefaultGC(win->display, 0),
+ GCForeground | GCBackground | GCFont, &gc);
+
+ if (!x) {
+ sprintf(buf, " %d", SIZE - y);
+ XDrawImageString(win->display, win->boardwin,
+ DefaultGC(win->display, 0),
+ 1, (y + 1) * (SQUARE_HEIGHT +
+ BORDER_WIDTH) - BORDER_WIDTH +
+ win->small->max_bounds.ascent - 1, buf, 2);
+ }
+ if (y == SIZE - 1) {
+ sprintf(buf, "%c", 'A' + x);
+ XDrawImageString(win->display, win->boardwin,
+ DefaultGC(win->display, 0),
+ x * (SQUARE_WIDTH + BORDER_WIDTH) + 1,
+ SIZE * (SQUARE_HEIGHT + BORDER_WIDTH) - BORDER_WIDTH +
+ win->small->max_bounds.ascent - 1, buf, 1);
+ }
+ }
+
+
+ return;
+}
+
+void
+win_flash(m, wnum)
+ move *m;
+ color wnum;
+{
+ windata *win;
+ int sx, sy, ex, ey, i;
+
+ if (oneboard || (wnum == win1->color))
+ win = win1;
+ else
+ win = win2;
+
+ if (win->flipped) {
+ sx = SIZE - m->fromx - 1;
+ sy = SIZE - m->fromy - 1;
+ ex = SIZE - m->tox - 1;
+ ey = SIZE - m->toy - 1;
+ } else {
+ sx = m->fromx;
+ sy = m->fromy;
+ ex = m->tox;
+ ey = m->toy;
+ }
+ sx = sx * (SQUARE_WIDTH + BORDER_WIDTH) + SQUARE_WIDTH / 2;
+ sy = sy * (SQUARE_HEIGHT + BORDER_WIDTH) + SQUARE_HEIGHT / 2;
+ ex = ex * (SQUARE_WIDTH + BORDER_WIDTH) + SQUARE_WIDTH / 2;
+ ey = ey * (SQUARE_HEIGHT + BORDER_WIDTH) + SQUARE_HEIGHT / 2;
+
+ for (i = 0; i < num_flashes * 2; i++)
+ XDrawLine(win->display,win->boardwin,
+ DefaultGC(win->display, 0),
+ sx, sy, ex, ey);
+ return;
+}
+
+/* Handle input from the players. */
+
+void
+win_process(quick)
+ bool quick;
+{
+ int i, rfd = 0, wfd = 0, xfd = 0;
+ struct timeval timeout;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = (quick ? 0 : 500000);
+
+ if (XPending(win1->display))
+ service(win1);
+ if (!oneboard) {
+ if (XPending(win1->display))
+ service(win2);
+ }
+
+ if (oneboard)
+ rfd = 1 << win1->display->fd;
+ else
+ rfd = (1 << win1->display->fd) | (1 << win2->display->fd);
+ if (!(i = select(32, &rfd, &wfd, &xfd, &timeout)))
+ return;
+ if (i == -1) {
+ perror("select");
+ exit(1);
+ }
+ if (rfd & (1 << win1->display->fd))
+ service(win1);
+ if (!oneboard && (rfd & (1 << win2->display->fd)))
+ service(win2);
+
+ return;
+}
+
+static void
+service(win)
+ windata *win;
+{
+ XEvent ev;
+
+ while(XPending(win->display)) {
+ XNextEvent(win->display, &ev);
+ if (TxtFilter(win->display, &ev))
+ continue;
+
+ if (ev.xany.window == win->boardwin) {
+ switch (ev.type) {
+ case ButtonPress:
+ button_pressed(&ev, win);
+ break;
+
+ case ButtonRelease:
+ button_released(&ev, win);
+ break;
+
+ case Expose:
+ /* Redraw... */
+ win_redraw(win, &ev);
+ break;
+
+ case 0:
+ case NoExpose:
+ break;
+ default:
+ fprintf(stderr, "Bad event type %d\n", ev.type);
+ exit(1);
+ }
+ } else if (ev.xany.window == win->wclockwin) {
+ switch (ev.type) {
+ case Expose:
+ clock_draw(win, WHITE);
+ break;
+
+ case 0:
+ case NoExpose:
+ break;
+ default:
+ fprintf(stderr, "Bad event type %d\n", ev.type);
+ exit(1);
+ }
+ } else if (ev.xany.window == win->bclockwin) {
+ switch (ev.type) {
+ case Expose:
+ clock_draw(win, BLACK);
+ break;
+
+ case 0:
+ case NoExpose:
+ break;
+ default:
+ fprintf(stderr, "Bad event type %d\n", ev.type);
+ exit(1);
+ }
+ } else if (ev.xany.window == win->jailwin) {
+ switch (ev.type) {
+ case Expose:
+ jail_draw(win);
+ break;
+
+ case 0:
+ case NoExpose:
+ break;
+ default:
+ fprintf(stderr, "Bad event type %d\n", ev.type);
+ exit(1);
+ }
+ } else if (ev.xany.window == win->buttonwin) {
+ switch (ev.type) {
+ case ButtonPress:
+ button_service(win, &ev);
+ break;
+
+ case Expose:
+ button_draw(win);
+ break;
+
+ case 0:
+ case NoExpose:
+ break;
+ default:
+ fprintf(stderr, "Bad event type %d\n", ev.type);
+ exit(1);
+ }
+ } else if (ev.xany.window == win->icon) {
+ icon_refresh(win);
+ } else if (ev.xany.window == win->basewin) {
+ message_send(win, &ev);
+ } else {
+ fprintf(stderr, "Internal Error: service: bad win\n");
+ fprintf(stderr, "window = %d, event = %d\n", ev.xany.window,
+ ev.type);
+ }
+ }
+ return;
+}
+
+void
+win_redraw(win, event)
+ windata *win;
+ XEvent *event;
+{
+ XExposeEvent *ev = &event->xexpose;
+ int x1, y1, x2, y2, i, j;
+
+ drawgrid(win);
+ if (ev) {
+ x1 = ev->x / (SQUARE_WIDTH + BORDER_WIDTH);
+ y1 = ev->y / (SQUARE_HEIGHT + BORDER_WIDTH);
+ x2 = (ev->x + ev->width) / (SQUARE_WIDTH + BORDER_WIDTH);
+ y2 = (ev->y + ev->height) / (SQUARE_HEIGHT + BORDER_WIDTH);
+ } else {
+ x1 = 0;
+ y1 = 0;
+ x2 = SIZE - 1;
+ y2 = SIZE - 1;
+ }
+
+ if (x1 < 0) x1 = 0;
+ if (y1 < 0) y1 = 0;
+ if (x2 < 0) x2 = 0;
+ if (y2 < 0) y2 = 0;
+ if (x1 > SIZE - 1) x1 = SIZE - 1;
+ if (y1 > SIZE - 1) y1 = SIZE - 1;
+ if (x2 > SIZE - 1) x2 = SIZE - 1;
+ if (y2 > SIZE - 1) y2 = SIZE - 1;
+
+ if (win->flipped) {
+ y1 = SIZE - y2 - 1;
+ y2 = SIZE - y1 - 1;
+ x1 = SIZE - x2 - 1;
+ x2 = SIZE - x1 - 1;
+ }
+
+ for (i = x1; i <= x2; i++)
+ for (j = y1; j <= y2; j++) {
+ if (chessboard->square[j][i].color == NONE)
+ win_erasepiece(j, i, WHITE);
+ else
+ win_drawpiece(&chessboard->square[j][i], j, i,
+ WHITE);
+ if (!oneboard) {
+ if (chessboard->square[j][i].color == NONE)
+ win_erasepiece(j, i, BLACK);
+ else
+ win_drawpiece(&chessboard->square[j][i],
+ j, i, BLACK);
+ }
+ }
+
+ return;
+}
+
+static bool
+setup(dispname, win)
+ char *dispname;
+ windata *win;
+{
+ char buf[BSIZE], *s;
+ Pixmap bm, bmask;
+ Cursor cur;
+ extern char *program, *recfile;
+
+
+ if (!(win->display = XOpenDisplay(dispname)))
+ return (false);
+
+
+ /* Now get boolean defaults... */
+ if ((s = XGetDefault(win->display, program, "noisy")) && eq(s, "on"))
+ noisyflag = true;
+ if ((s = XGetDefault(win->display, program, "savemoves")) && eq(s, "on"))
+ saveflag = true;
+ if ((s = XGetDefault(win->display, program, "algebraic")) && eq(s, "on"))
+ record_english = false;
+ if ((s = XGetDefault(win->display, program, "blackandwhite")) && eq(s, "on"))
+ bnwflag = true;
+ if ((s = XGetDefault(win->display, program, "quickrestore")) && eq(s, "on"))
+ quickflag = true;
+ if ((s = XGetDefault(win->display, program, "flash")) && eq(s, "on"))
+ win_flashmove = true;
+
+ /* ... numeric variables ... */
+ if (s = XGetDefault(win->display, program, "numflashes"))
+ num_flashes = atoi(s);
+ if (s = XGetDefault(win->display, program, "flashsize"))
+ flash_size = atoi(s);
+
+ /* ... and strings. */
+ if (s = XGetDefault(win->display, program, "progname"))
+ progname = s;
+ if (s = XGetDefault(win->display, program, "proghost"))
+ proghost = s;
+ if (s = XGetDefault(win->display, program, "recordfile"))
+ recfile = s;
+ if (s = XGetDefault(win->display, program, "blackpiece"))
+ black_piece_color = s;
+ if (s = XGetDefault(win->display, program, "whitepiece"))
+ white_piece_color = s;
+ if (s = XGetDefault(win->display, program, "blacksquare"))
+ black_square_color = s;
+ if (s = XGetDefault(win->display, program, "whitesquare"))
+ white_square_color = s;
+ if (s = XGetDefault(win->display, program, "bordercolor"))
+ border_color = s;
+ if (s = XGetDefault(win->display, program, "textcolor"))
+ text_color = s;
+ if (s = XGetDefault(win->display, program, "textback"))
+ text_back = s;
+ if (s = XGetDefault(win->display, program, "errortext"))
+ error_text = s;
+ if (s = XGetDefault(win->display, program, "playertext"))
+ player_text = s;
+ if (s = XGetDefault(win->display, program, "cursorcolor"))
+ cursor_color = s;
+
+ if ((DisplayPlanes(win->display, 0) == 1) || bnwflag)
+ win->bnw = true;
+
+ /* Allocate colors... */
+ if (win->bnw) {
+ win->blackpiece.pixel = BlackPixel (win->display, 0);
+ win->whitepiece.pixel = WhitePixel (win->display, 0);
+ win->blacksquare.pixel = BlackPixel (win->display, 0);
+ win->whitesquare.pixel = WhitePixel (win->display, 0);
+ win->border.pixel = BlackPixel (win->display, 0);
+ win->textcolor.pixel = BlackPixel (win->display, 0);
+ win->textback.pixel = WhitePixel (win->display, 0);
+ win->playertext.pixel = BlackPixel (win->display, 0);
+ win->errortext.pixel = BlackPixel (win->display, 0);
+ win->cursorcolor.pixel = BlackPixel (win->display, 0) ;
+ } else {
+ if (!XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ black_piece_color, &win->blackpiece) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ white_piece_color, &win->whitepiece) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ black_square_color, &win->blacksquare) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ white_square_color, &win->whitesquare) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ border_color, &win->border) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ text_color, &win->textcolor) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ text_back, &win->textback) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ error_text, &win->errortext) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ player_text, &win->playertext) ||
+ !XParseColor(win->display,
+ DefaultColormap(win->display, 0),
+ cursor_color, &win->cursorcolor) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->blackpiece) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->whitepiece) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->blacksquare) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->whitesquare) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->border) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->textcolor) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->textback) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->errortext) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->playertext) ||
+ !XAllocColor(win->display,
+ DefaultColormap(win->display, 0),
+ &win->cursorcolor))
+ fprintf(stderr, "Can't get color...\n");
+ }
+
+ /* Get fonts... */
+ win->small = XLoadQueryFont(win->display,SMALL_FONT);
+ win->medium = XLoadQueryFont(win->display,MEDIUM_FONT);
+ win->large = XLoadQueryFont(win->display,LARGE_FONT);
+
+ /* Create the windows... */
+
+ win->basewin =
+ XCreateSimpleWindow(win->display,DefaultRootWindow(win->display),
+ BASE_XPOS, BASE_YPOS,
+ BASE_WIDTH, BASE_HEIGHT, 0,
+ BlackPixel(win->display, 0),
+ WhitePixel(win->display, 0));
+ win->boardwin = XCreateSimpleWindow(win->display,win->basewin,
+ BOARD_XPOS, BOARD_YPOS,
+ BOARD_WIDTH, BOARD_HEIGHT,
+ BORDER_WIDTH,
+ win->border.pixel,
+ WhitePixel(win->display, 0));
+ win->recwin = XCreateSimpleWindow(win->display,win->basewin,
+ RECORD_XPOS, RECORD_YPOS,
+ RECORD_WIDTH, RECORD_HEIGHT,
+ BORDER_WIDTH, win->border.pixel,
+ win->textback.pixel);
+ win->jailwin = XCreateSimpleWindow(win->display,win->basewin,
+ JAIL_XPOS, JAIL_YPOS,
+ JAIL_WIDTH, JAIL_HEIGHT,
+ BORDER_WIDTH,
+ win->border.pixel,
+ win->textback.pixel);
+ win->wclockwin = XCreateSimpleWindow(win->display,win->basewin,
+ WCLOCK_XPOS, WCLOCK_YPOS,
+ CLOCK_WIDTH, CLOCK_HEIGHT,
+ BORDER_WIDTH, win->border.pixel,
+ win->textback.pixel);
+ win->bclockwin = XCreateSimpleWindow(win->display,win->basewin,
+ BCLOCK_XPOS, BCLOCK_YPOS,
+ CLOCK_WIDTH, CLOCK_HEIGHT,
+ BORDER_WIDTH, win->border.pixel,
+ win->textback.pixel);
+ win->messagewin = XCreateSimpleWindow(win->display,win->basewin,
+ MESS_XPOS, MESS_YPOS,
+ MESS_WIDTH, MESS_HEIGHT,
+ BORDER_WIDTH, win->border.pixel,
+ win->textback.pixel);
+ win->buttonwin = XCreateSimpleWindow(win->display,win->basewin,
+ BUTTON_XPOS, BUTTON_YPOS,
+ BUTTON_WIDTH, BUTTON_HEIGHT,
+ BORDER_WIDTH, win->border.pixel,
+ win->textback.pixel);
+
+ /* Let's define an icon... */
+ win->iconpixmap = XCreatePixmapFromBitmapData(win->display,
+ win->basewin, icon_bits,
+ icon_width, icon_height,
+ win->blacksquare.pixel,
+ win->whitesquare.pixel,
+ 1);
+
+ bm = XCreateBitmapFromData(win->display,
+ win->basewin, xchess_bits,
+ xchess_width, xchess_height);
+ bmask = XCreateBitmapFromData(win->display,
+ win->basewin, xchess_mask_bits,
+ xchess_width, xchess_height);
+ cur = XCreatePixmapCursor(win->display, bm, bmask,
+ &win->cursorcolor,
+ &WhitePixel(win->display, 0),
+ xchess_x_hot, xchess_y_hot);
+ XFreePixmap(win->display, bm);
+ XFreePixmap(win->display, bmask);
+
+ XDefineCursor(win->display,win->basewin, cur);
+
+ XMapSubwindows(win->display,win->basewin);
+ XMapRaised(win->display,win->basewin);
+
+ XSelectInput(win->display,win->basewin, KeyPressMask);
+ XSelectInput(win->display,win->boardwin,
+ ButtonPressMask | ButtonReleaseMask | ExposureMask);
+ XSelectInput(win->display,win->recwin,
+ ButtonReleaseMask | ExposureMask);
+ XSelectInput(win->display,win->jailwin, ExposureMask);
+ XSelectInput(win->display,win->wclockwin, ExposureMask);
+ XSelectInput(win->display,win->bclockwin, ExposureMask);
+ XSelectInput(win->display,win->messagewin,
+ ButtonReleaseMask | ExposureMask);
+ XSelectInput(win->display,win->buttonwin,
+ ButtonPressMask | ExposureMask);
+
+ message_init(win);
+ record_init(win);
+ button_draw(win);
+ jail_init(win);
+ clock_init(win, WHITE);
+ clock_init(win, BLACK);
+ if (timeunit) {
+ if (timeunit > 1800)
+ sprintf(buf, "%d moves every %.2lg hours.\n",
+ movesperunit, ((double) timeunit) / 3600);
+ else if (timeunit > 30)
+ sprintf(buf, "%d moves every %.2lg minutes.\n",
+ movesperunit, ((double) timeunit) / 60);
+ else
+ sprintf(buf, "%d moves every %d seconds.\n",
+ movesperunit, timeunit);
+ message_add(win, buf, false);
+ }
+
+ return (true);
+}
+
+static void
+drawgrid(win)
+ windata *win;
+{
+ int i;
+ XGCValues gc;
+
+ gc.function = GXcopy;
+ gc.plane_mask = AllPlanes;
+ gc.foreground = win->border.pixel;
+ gc.line_width = 0;
+ gc.line_style = LineSolid;
+
+ XChangeGC(win->display,
+ DefaultGC(win->display, 0),
+ GCFunction | GCPlaneMask | GCForeground |
+ GCLineWidth | GCLineStyle, &gc);
+
+ /* Draw the lines... horizontal, */
+ for (i = 1; i < SIZE; i++)
+ XDrawLine(win->display, win->boardwin,
+ DefaultGC(win->display, 0), 0,
+ i * (SQUARE_WIDTH + BORDER_WIDTH) -
+ BORDER_WIDTH / 2,
+ SIZE * (SQUARE_WIDTH + BORDER_WIDTH),
+ i * (SQUARE_WIDTH + BORDER_WIDTH) -
+ BORDER_WIDTH / 2);
+
+ /* and vertical... */
+ for (i = 1; i < SIZE; i++)
+ XDrawLine(win->display, win->boardwin,
+ DefaultGC(win->display, 0),
+ i * (SQUARE_WIDTH + BORDER_WIDTH) -
+ BORDER_WIDTH / 2, 0,
+ i * (SQUARE_WIDTH + BORDER_WIDTH) -
+ BORDER_WIDTH / 2,
+ SIZE * (SQUARE_WIDTH + BORDER_WIDTH));
+ return;
+}
+
+void
+win_restart()
+{
+ win1->flipped = false;
+ win_redraw(win1, (XEvent *) NULL);
+ if (!oneboard) {
+ win2->flipped = true;
+ win_redraw(win2, (XEvent *) NULL);
+ }
+ return;
+}
+
+static void
+icon_refresh(win)
+ windata *win;
+{
+ XCopyArea(win->display, win->iconpixmap, win->icon,
+ DefaultGC(win->display, 0),
+ 0, 0, icon_width, icon_height, 0, 0);
+ return;
+}
+
diff --git a/gnu/games/chess/Xchess/xchess.1 b/gnu/games/chess/Xchess/xchess.1
new file mode 100644
index 000000000000..e6875136100c
--- /dev/null
+++ b/gnu/games/chess/Xchess/xchess.1
@@ -0,0 +1,217 @@
+
+.TH XCHESS 1 "14 Nov 1986" "X Version 10"
+.SH NAME
+xchess \- X chess display
+.SH SYNOPSIS
+.B xchess
+[ option ... ] [ white-display ] [ black-display ]
+.SH DESCRIPTION
+.PP
+.B xchess
+is a chess display program which allows players to play a game on either
+one or two displays, or play a chess-playing program. It uses the
+.B X
+window system. If one or no display names are given, it will open up one
+window and both black and white at the same board. If two displays are
+given,
+.B xchess
+will accept moves from each player in his turn. Black's board will be drawn
+with his pieces at the bottom.
+.PP
+.B xchess
+will not allow a player to make an illegal move. It accepts all legal moves,
+including castling and pawn capture \fIen passant\fR.
+.SH OPTIONS
+.TP 8
+.B -d
+Turn on debugging.
+.TP 8
+.B -f record-file
+Use \fBrecord-file\fR for saving the game when the \fBSave\fR button is
+selected, or if the \fB-s\fR flag is given. The default is "xchess.game".
+.TP 8
+.B -r saved-game
+Start with the position at the end of the saved game in the named file.
+This file may be the result of the \fBSave\fR command, and may be in
+either English or International format. When reading moves, one move
+it made per second.
+.TP 8
+.B -q
+Don't pause for a second every time a move is made when a game is being
+restored.
+.TP 8
+.B -v
+Whenever a piece is moved, outline the path with a "lightning bolt".
+This option and the \fB-n\fR option are useful if you don't want to miss
+an opponent's move when he makes it.
+.TP 8
+.B -i
+Use International format for recording moves (squares numbered 1-8, a-h)
+as opposed to English (e.g, \fIp/k4xp/q5\fR).
+.TP 8
+.B -t moves/timeunit
+Allows \fBtimeunit\fR seconds for every \fBmoves\fR moves. If either player
+exceeds this allowance both recieve a message saying informing them of
+this fact.
+.TP 8
+.B -c
+Play the computer.
+.B xchess
+will start up a chess-playing program (currently the only one it knows
+how to talk to is \fBGNU Chess\fR).
+.TP 8
+.B -p program
+The name of the program to use if the \fB-c\fR option is given. The
+default is "/usr/public/gnuchess". Note that \fBgnuchess\fR must be
+compiled with the \fIcompat\fR flag (in the file "main.c") set to 1.
+.TP 8
+.B -b
+If the \fB-c\fR flag was given, have the computer play white.
+.TP 8
+.B -bnw
+If the display has more than one display plane (i.e, is color), pretend
+it's black and white.
+.TP 8
+.B -s
+Save the moves in the record file as they are made. This is useful if
+you don't want your game to be lost when \fBxchess\fR core dumps.
+.TP 8
+.B -n
+Be noisy \- beep after every move is made.
+.TP 8
+.B -h host
+Run GNU Chess on the specified \fBhost\fR.
+.TP 8
+.B -R
+Randomly chose who plays white and who plays black, if two displays are
+given.
+.SH CONTROLS
+.PP
+The window is divided up into several sub-windows. The pieces are moved by
+pushing down any mouse button on top of the piece, moving to the destination
+square, and releasing it. Castling is done by moving the king to the
+right square. If you push down on a piece and then let the button
+up without moving it, you must move that piece. ("Touch it, move it.")
+.PP
+The progress of the game is listed in the "Game Record" window. Error
+messages and such things are printed in the "Message" window. Both these
+windows have scroll bars that you can use to move around.
+There are also windows for clocks and for a record of the pieces captured.
+.PP
+If you type any keys in the window, the text will go into the message
+window of both players. This provides a simple communication facility.
+.PP
+There are 9 buttons in the control window. They are as follows:
+.TP 8
+.B Draw
+Both players must push this button to agree on a draw (just one is ok
+if only one display is being used).
+.TP 8
+.B Resign
+The player whose turn it is to move resigns.
+.TP 8
+.B Reset
+Start over from the beginning.
+.TP 8
+.B Back
+Retract a move. If two displays are being used the other player will be
+asked to confirm this.
+.TP 8
+.B Fwd
+This will re-play the most recently retracted move. This button in conjunction
+with \fBBack\fR is useful for "scrolling around" in a saved game.
+.TP 8
+.B Save
+Save the game in the record file.
+.TP 8
+.B Flip
+Rotate the board so that Black will have his pieces at the bottom.
+.TP 8
+.B Switch
+Change the mapping of boards to players.
+.TP 8
+.B Pause
+This button has two functions. When a game is being restored, pieces will
+be moved once a second. Hitting \fBPause\fR will stop this process, and
+hitting it again will restart it. During the time that it is stopped no
+other action can be made except restarting it. While a game is being played,
+\fBPause\fR will stop the clock and restart it.
+.SH DEFAULTS
+.PP
+\fBxchess\fR uses the following \fI.Xdefaults\fR:
+.TP 8
+.B Noisy
+The -n flag.
+.TP 8
+.B SaveMoves
+The -s flag.
+.TP 8
+.B Algebraic
+The -i flag.
+.TP 8
+.B BlackAndWhite
+The -bnw flag.
+.TP 8
+.B QuickRestore
+The -q flag.
+.TP 8
+.B Flash
+The -v flag.
+.TP 8
+.B NumFlashes
+How many times to flash the move. The default is 5.
+.TP 8
+.B FlashWidth
+How big to make the lightning bolt. The default is 10 pixels.
+.TP 8
+.B ProgName
+The -p option. This may also be changed in the Makefile (-DDEF_PROG_NAME).
+.TP 8
+.B ProgHost
+The -h option.
+.TP 8
+.B RecordFile
+The -f option.
+.TP 8
+.B BlackPiece
+The color of the black pieces.
+.TP 8
+.B WhitePiece
+The color of the white pieces.
+.TP 8
+.B BorderColor
+The color of the borders.
+.TP 8
+.B BlackSquare
+The color of the black squares.
+.TP 8
+.B WhiteSquare
+The color of the white squares.
+.TP 8
+.B TextColor
+The color of routine messages and the move record text.
+.TP 8
+.B ErrorText
+The color of error messages.
+.TP 8
+.B PlayerText
+The color of player-entered text.
+.TP 8
+.B TextBack
+The background color for the two text windows.
+.TP 8
+.B CursorColor
+The color of the mouse and the text cursors.
+.SH "SEE ALSO"
+X(8), gnuchess(1), chess(5)
+.SH AUTHOR
+Wayne A. Christopher (faustus@ic.berkeley.edu)
+.SH BUGS
+.PP
+Checkmate and stalemate are not detected, so the appropriate player must resign
+or agree to a draw respectively.
+.PP
+\fBSwitch\fR doesn't work.
+.PP
+If you are playing \fBgnuchess\fR, and you select Undo a few times so that it
+is \fBgnuchess\fR's turn to move, it won't do anything.
diff --git a/gnu/games/chess/Xchess/xchess.c b/gnu/games/chess/Xchess/xchess.c
new file mode 100644
index 000000000000..6de6502ddd28
--- /dev/null
+++ b/gnu/games/chess/Xchess/xchess.c
@@ -0,0 +1,205 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.2 $ on $Date: 89/04/28 08:44:02 $
+ * $Source: /usr/local/src/source/X.V11R3/contrib/games/xchess/Xchess/RCS/xchess.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ */
+
+#define USAGE "xchess [ -d ] [ -f recordfile ] [ -r savedfile ] [ -i ]\n\
+\t[ -t moves/timeunit ] [ -c ] [ -p program ] [ -b ] [ -bnw ] [ -s ]\n\
+\t[ -n ] [ -h host ] [ -v ] [ -R ] [ whitedisplay ] [ blackdisplay ]"
+
+#include <signal.h>
+#include "xchess.h"
+
+bool debug = false;
+bool oneboard = false;
+bool bnwflag = false;
+bool progflag = false;
+bool blackflag = false;
+bool quickflag = false;
+
+char *progname = DEF_PROGRAM;
+char *proghost = NULL;
+char *piecenames[] = { "pawn", "rook", "knight", "bishop", "queen", "king" } ;
+char *colornames[] = { "white", "black", "none" } ;
+char *movetypenames[] = { "move", "qcastle", "kcastle", "capture" } ;
+char *dispname1 = NULL, *dispname2 = NULL;
+
+char *black_piece_color = BLACK_PIECE_COLOR;
+char *white_piece_color = WHITE_PIECE_COLOR;
+char *black_square_color = BLACK_SQUARE_COLOR;
+char *white_square_color = WHITE_SQUARE_COLOR;
+char *border_color = BORDER_COLOR;
+char *text_color = TEXT_COLOR;
+char *text_back = TEXT_BACK;
+char *error_text = ERROR_TEXT;
+char *player_text = PLAYER_TEXT;
+char *cursor_color = CURSOR_COLOR;
+
+int num_flashes = NUM_FLASHES;
+int flash_size = FLASH_SIZE;
+char *program;
+char *recfile = NULL;
+
+#ifdef notdef
+/*
+ * Serves no purpose.
+ */
+die () {
+fprintf(stderr, "child proc changed status?!\n");
+}
+#endif
+
+void
+main(ac, av)
+ char **av;
+{
+ bool randflag = false;
+ move *m;
+ char *s;
+
+ program = av[0];
+
+#ifdef notdef
+ signal(SIGCHLD, die);
+#endif
+
+ /* Process args. */
+ av++; ac--;
+ while (ac > 0 && **av == '-') {
+ if (eq(*av, "-d")) {
+ debug = true;
+ } else if (eq(*av, "-f")) {
+ av++; ac--;
+ if (*av)
+ record_file = *av;
+ else
+ goto usage;
+ } else if (eq(*av, "-r")) {
+ av++; ac--;
+ if (*av)
+ recfile = *av;
+ else
+ goto usage;
+ } else if (eq(*av, "-i")) {
+ record_english = false;
+ } else if (eq(*av, "-R")) {
+ randflag = true;
+ } else if (eq(*av, "-v")) {
+ win_flashmove = true;
+ } else if (eq(*av, "-q")) {
+ quickflag = true;
+ } else if (eq(*av, "-t")) {
+ av++; ac--;
+ if (*av) {
+ movesperunit = atoi(*av);
+ if (s = index(*av, '/'))
+ timeunit = atoi(s + 1) * 60;
+ else
+ timeunit = 60;
+ } else
+ goto usage;
+ } else if (eq(*av, "-p")) {
+ av++; ac--;
+ if (*av)
+ progname = *av;
+ else
+ goto usage;
+ } else if (eq(*av, "-h")) {
+ av++; ac--;
+ if (*av)
+ proghost = *av;
+ else
+ goto usage;
+ } else if (eq(*av, "-b")) {
+ blackflag = true;
+ } else if (eq(*av, "-c")) {
+ progflag = true;
+ } else if (eq(*av, "-bnw")) {
+ bnwflag = true;
+ } else if (eq(*av, "-s")) {
+ saveflag = true;
+ } else if (eq(*av, "-n")) {
+ noisyflag = true;
+ } else
+ goto usage;
+ av++; ac--;
+ }
+ if (ac > 0)
+ dispname1 = av[0];
+ if (ac > 1)
+ dispname2 = av[1];
+ if (ac > 2)
+ goto usage;
+
+ if (!dispname2)
+ oneboard = true;
+
+ srandom(getpid());
+
+ if (!oneboard && randflag && (random() % 2)) {
+ s = dispname1;
+ dispname1 = dispname2;
+ dispname2 = s;
+ }
+
+ if (!dispname1)
+ dispname1 = getenv("DISPLAY");
+
+ /* Set up the board. */
+ board_setup();
+
+ /* Create the windows. */
+ win_setup(dispname1, dispname2);
+
+ board_drawall();
+
+ /* Start the program if necessary. */
+ if (progflag)
+ if (!program_init(progname))
+ exit(1);
+
+ if (recfile)
+ load_game(recfile);
+
+ /* Go into a loop of prompting players alternately for moves, checking
+ * them, and updating things.
+ */
+ for (;;) {
+ win_process(false);
+ clock_update();
+ if (progflag && ((!blackflag && (nexttomove == BLACK)) ||
+ (blackflag && (nexttomove == WHITE)))) {
+ m = program_get();
+ if (m)
+ prog_move(m);
+ }
+ }
+
+usage: fprintf(stderr, "Usage: %s\n", USAGE);
+ exit(1);
+}
+
diff --git a/gnu/games/chess/Xchess/xchess.c.150 b/gnu/games/chess/Xchess/xchess.c.150
new file mode 100644
index 000000000000..2c17906c3571
--- /dev/null
+++ b/gnu/games/chess/Xchess/xchess.c.150
@@ -0,0 +1,197 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.5 $ on $Date: 86/11/26 12:11:32 $
+ * $Source: /users/faustus/xchess/RCS/xchess.c,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ */
+
+#define USAGE "xchess [ -d ] [ -f recordfile ] [ -r savedfile ] [ -i ]\n\
+\t[ -t moves/timeunit ] [ -c ] [ -p program ] [ -b ] [ -bnw ] [ -s ]\n\
+\t[ -n ] [ -h host ] [ -v ] [ -R ] [ whitedisplay ] [ blackdisplay ]"
+
+#include <signal.h>
+#include "xchess.h"
+
+bool debug = false;
+bool oneboard = false;
+bool bnwflag = false;
+bool progflag = false;
+bool blackflag = false;
+bool quickflag = false;
+
+char *progname = DEF_PROGRAM;
+char *proghost = NULL;
+char *piecenames[] = { "pawn", "rook", "knight", "bishop", "queen", "king" } ;
+char *colornames[] = { "white", "black", "none" } ;
+char *movetypenames[] = { "move", "qcastle", "kcastle", "capture" } ;
+char *dispname1 = NULL, *dispname2 = NULL;
+
+char *black_piece_color = BLACK_PIECE_COLOR;
+char *white_piece_color = WHITE_PIECE_COLOR;
+char *black_square_color = BLACK_SQUARE_COLOR;
+char *white_square_color = WHITE_SQUARE_COLOR;
+char *border_color = BORDER_COLOR;
+char *text_color = TEXT_COLOR;
+char *text_back = TEXT_BACK;
+char *error_text = ERROR_TEXT;
+char *player_text = PLAYER_TEXT;
+char *cursor_color = CURSOR_COLOR;
+
+int num_flashes = NUM_FLASHES;
+int flash_size = FLASH_SIZE;
+char *program;
+char *recfile = NULL;
+
+die () {
+fprintf(stderr, "child proc changed status?!\n");
+}
+
+void
+main(ac, av)
+ char **av;
+{
+ bool randflag = false;
+ move *m;
+ char *s;
+
+ program = av[0];
+
+ signal(SIGCHLD, die);
+ /* Process args. */
+ av++; ac--;
+ while (ac > 0 && **av == '-') {
+ if (eq(*av, "-d")) {
+ debug = true;
+ } else if (eq(*av, "-f")) {
+ av++; ac--;
+ if (*av)
+ record_file = *av;
+ else
+ goto usage;
+ } else if (eq(*av, "-r")) {
+ av++; ac--;
+ if (*av)
+ recfile = *av;
+ else
+ goto usage;
+ } else if (eq(*av, "-i")) {
+ record_english = false;
+ } else if (eq(*av, "-R")) {
+ randflag = true;
+ } else if (eq(*av, "-v")) {
+ win_flashmove = true;
+ } else if (eq(*av, "-q")) {
+ quickflag = true;
+ } else if (eq(*av, "-t")) {
+ av++; ac--;
+ if (*av) {
+ movesperunit = atoi(*av);
+ if (s = index(*av, '/'))
+ timeunit = atoi(s + 1) * 60;
+ else
+ timeunit = 60;
+ } else
+ goto usage;
+ } else if (eq(*av, "-p")) {
+ av++; ac--;
+ if (*av)
+ progname = *av;
+ else
+ goto usage;
+ } else if (eq(*av, "-h")) {
+ av++; ac--;
+ if (*av)
+ proghost = *av;
+ else
+ goto usage;
+ } else if (eq(*av, "-b")) {
+ blackflag = true;
+ } else if (eq(*av, "-c")) {
+ progflag = true;
+ } else if (eq(*av, "-bnw")) {
+ bnwflag = true;
+ } else if (eq(*av, "-s")) {
+ saveflag = true;
+ } else if (eq(*av, "-n")) {
+ noisyflag = true;
+ } else
+ goto usage;
+ av++; ac--;
+ }
+ if (ac > 0)
+ dispname1 = av[0];
+ if (ac > 1)
+ dispname2 = av[1];
+ if (ac > 2)
+ goto usage;
+
+ if (!dispname2)
+ oneboard = true;
+
+ srandom(getpid());
+
+ if (!oneboard && randflag && (random() % 2)) {
+ s = dispname1;
+ dispname1 = dispname2;
+ dispname2 = s;
+ }
+
+ if (!dispname1)
+ dispname1 = getenv("DISPLAY");
+
+ /* Set up the board. */
+ board_setup();
+
+ /* Create the windows. */
+ win_setup(dispname1, dispname2);
+
+ board_drawall();
+
+ /* Start the program if necessary. */
+ if (progflag)
+ if (!program_init(progname))
+ exit(1);
+
+ if (recfile)
+ load_game(recfile);
+
+ /* Go into a loop of prompting players alternately for moves, checking
+ * them, and updating things.
+ */
+ for (;;) {
+ win_process(false);
+ clock_update();
+ if (progflag && ((!blackflag && (nexttomove == BLACK)) ||
+ (blackflag && (nexttomove == WHITE)))) {
+ m = program_get();
+ if (m)
+ prog_move(m);
+ }
+ }
+
+usage: fprintf(stderr, "Usage: %s\n", USAGE);
+ exit(1);
+}
+
diff --git a/gnu/games/chess/Xchess/xchess.cur b/gnu/games/chess/Xchess/xchess.cur
new file mode 100644
index 000000000000..ef3750dbdd7f
--- /dev/null
+++ b/gnu/games/chess/Xchess/xchess.cur
@@ -0,0 +1,9 @@
+
+#define xchess_width 16
+#define xchess_height 16
+#define xchess_x_hot 9
+#define xchess_y_hot 8
+static char xchess_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xf8, 0x00, 0xfe, 0x80, 0xff,
+ 0xc0, 0xff, 0x60, 0xff, 0xb0, 0xfd, 0xd8, 0x66, 0x6c, 0x3b, 0x76, 0x1d,
+ 0x98, 0x1d, 0xcc, 0x0c, 0x60, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/Xchess/xchess.game b/gnu/games/chess/Xchess/xchess.game
new file mode 100644
index 000000000000..2302334080c7
--- /dev/null
+++ b/gnu/games/chess/Xchess/xchess.game
@@ -0,0 +1,8 @@
+
+X Chess -- Sun Sep 18 18:01:17 EDT 1988
+ Game played on pitcairn:0
+ english
+ 1. P/kb2-kb4 P/k2-k3
+ 2. P/k2-k4
+Draw agreed.
+Time: white: 6s, black: 43s
diff --git a/gnu/games/chess/Xchess/xchess.h b/gnu/games/chess/Xchess/xchess.h
new file mode 100644
index 000000000000..355731d8b403
--- /dev/null
+++ b/gnu/games/chess/Xchess/xchess.h
@@ -0,0 +1,301 @@
+
+/* This file contains code for X-CHESS.
+ Copyright (C) 1986 Free Software Foundation, Inc.
+
+This file is part of X-CHESS.
+
+X-CHESS is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the X-CHESS General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+X-CHESS, but only under the conditions described in the
+X-CHESS General Public License. A copy of this license is
+supposed to have been given to you along with X-CHESS so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+/* RCS Info: $Revision: 1.5 $ on $Date: 86/11/26 12:11:39 $
+ * $Source: /users/faustus/xchess/RCS/xchess.h,v $
+ * Copyright (c) 1986 Wayne A. Christopher, U. C. Berkeley CAD Group
+ * Permission is granted to do anything with this code except sell it
+ * or remove this message.
+ *
+ * Definitions for the X chess program.
+ */
+
+#include "std.h"
+#include <X11/Xlib.h>
+#include "scrollText/scrollText.h"
+
+#define SIZE 8
+
+typedef enum piecetype { PAWN, ROOK, KNIGHT, BISHOP, QUEEN, KING } piecetype;
+typedef enum movetype { MOVE, QCASTLE, KCASTLE, CAPTURE } movetype;
+typedef enum color { WHITE, BLACK, NONE } color;
+
+typedef struct piece {
+ enum piecetype type;
+ enum color color;
+} piece;
+
+/* The board has y=0 and black at the top... This probably isn't the best
+ * place to keep track of who can castle, but it's part of the game state...
+ */
+
+typedef struct board {
+ piece square[SIZE][SIZE];
+ bool white_cant_castle_k;
+ bool white_cant_castle_q;
+ bool black_cant_castle_k;
+ bool black_cant_castle_q;
+} board;
+
+typedef struct move {
+ movetype type;
+ piece piece;
+ piece taken;
+ int fromx, fromy;
+ int tox, toy;
+ struct move *next;
+ bool enpassant;
+ bool check;
+} move;
+
+#define iswhite(win, i, j) (!(((i) + (j)) % 2))
+
+/* Stuff for the display. */
+
+typedef struct windata {
+ Display *display;
+ Window basewin;
+ Window boardwin;
+ Window recwin;
+ Window wclockwin;
+ Window bclockwin;
+ Window messagewin;
+ Window buttonwin;
+ Window jailwin;
+ Window icon;
+ Pixmap iconpixmap;
+ XColor blackpiece;
+ XColor whitepiece;
+ XColor blacksquare;
+ XColor whitesquare;
+ XColor border;
+ XColor textcolor;
+ XColor textback;
+ XColor errortext;
+ XColor playertext;
+ XColor cursorcolor;
+ XFontStruct *small;
+ XFontStruct *medium;
+ XFontStruct *large;
+ bool bnw;
+ color color;
+ bool flipped;
+ double whitehands[3];
+ double blackhands[3];
+ char *txtassoc;
+} windata;
+
+#define SMALL_FONT "6x10"
+#define MEDIUM_FONT "8x13"
+#define LARGE_FONT "9x15"
+#define JAIL_FONT "6x10"
+
+#define SQUARE_WIDTH 80
+#define SQUARE_HEIGHT 80
+
+#define BORDER_WIDTH 3
+
+#define BOARD_WIDTH 8 * SQUARE_WIDTH + 7 * BORDER_WIDTH
+#define BOARD_HEIGHT 8 * SQUARE_HEIGHT + 7 * BORDER_WIDTH
+#define BOARD_XPOS 0
+#define BOARD_YPOS 0
+
+#define RECORD_WIDTH 265 /* 40 chars * 6 pixels / character. */
+#define RECORD_HEIGHT 433
+#define RECORD_XPOS BOARD_WIDTH + BORDER_WIDTH
+#define RECORD_YPOS 0
+
+#define JAIL_WIDTH RECORD_WIDTH
+#define JAIL_HEIGHT 163
+#define JAIL_XPOS RECORD_XPOS
+#define JAIL_YPOS RECORD_YPOS + RECORD_HEIGHT + BORDER_WIDTH
+
+#define CLOCK_WIDTH 131
+#define CLOCK_HEIGHT 131 + BORDER_WIDTH + 20
+#define WCLOCK_XPOS RECORD_XPOS
+#define WCLOCK_YPOS RECORD_HEIGHT + JAIL_HEIGHT + BORDER_WIDTH * 2
+#define BCLOCK_XPOS WCLOCK_XPOS + CLOCK_WIDTH + BORDER_WIDTH
+#define BCLOCK_YPOS WCLOCK_YPOS
+
+#define MESS_WIDTH 329
+#define MESS_HEIGHT 92
+#define MESS_XPOS 0
+#define MESS_YPOS BOARD_HEIGHT + BORDER_WIDTH
+
+#define BUTTON_WIDTH MESS_WIDTH
+#define BUTTON_HEIGHT MESS_HEIGHT
+#define BUTTON_XPOS MESS_WIDTH + BORDER_WIDTH
+#define BUTTON_YPOS MESS_YPOS
+
+#define BASE_WIDTH BOARD_WIDTH + RECORD_WIDTH + BORDER_WIDTH * 3
+#define BASE_HEIGHT BOARD_HEIGHT + MESS_HEIGHT + BORDER_WIDTH * 3
+
+#define BASE_XPOS 50
+#define BASE_YPOS 50
+
+#define BLACK_PIECE_COLOR "#202020"
+#define WHITE_PIECE_COLOR "#FFFFCC"
+#define BLACK_SQUARE_COLOR "#77A26D"
+#define WHITE_SQUARE_COLOR "#C8C365"
+#define BORDER_COLOR "#902E39"
+#define TEXT_COLOR "#006D6D"
+#define TEXT_BACK "#FFFFDD"
+#define ERROR_TEXT "Red"
+#define PLAYER_TEXT "Blue"
+#define CURSOR_COLOR "#FF606F"
+
+#define DEF_RECORD_FILE "xchess.game"
+
+#define NUM_FLASHES 5
+#define FLASH_SIZE 10
+
+/* xchess.c */
+
+extern void main();
+extern bool debug;
+extern char *progname;
+extern char *proghost;
+extern char *piecenames[];
+extern char *colornames[];
+extern char *movetypenames[];
+extern char *dispname1, *dispname2;
+extern bool oneboard;
+extern bool bnwflag;
+extern bool progflag;
+extern bool blackflag;
+extern bool quickflag;
+extern int num_flashes;
+extern int flash_size;
+extern char *black_piece_color;
+extern char *white_piece_color;
+extern char *black_square_color;
+extern char *white_square_color;
+extern char *border_color;
+extern char *text_color;
+extern char *text_back;
+extern char *error_text;
+extern char *player_text;
+extern char *cursor_color;
+
+/* board.c */
+
+extern void board_setup();
+extern void board_drawall();
+extern void board_move();
+extern board *chessboard;
+extern void board_init();
+
+/* window.c */
+
+extern bool win_setup();
+extern void win_redraw();
+extern void win_restart();
+extern void win_drawboard();
+extern void win_drawpiece();
+extern void win_erasepiece();
+extern void win_process();
+extern void win_flash();
+extern windata *win1, *win2;
+extern bool win_flashmove;
+
+/* control.c */
+
+extern void button_pressed();
+extern void button_released();
+extern void move_piece();
+extern void prog_move();
+extern move *moves;
+extern move *foremoves;
+extern color nexttomove;
+extern void replay();
+extern void forward();
+extern void cleanup();
+extern void restart();
+extern bool noisyflag;
+
+/* valid.c */
+
+extern bool valid_move();
+
+/* record.c */
+
+extern void record_move();
+extern void record_reset();
+extern void record_save();
+extern void record_back();
+extern void record_init();
+extern void record_end();
+extern bool record_english;
+extern char *record_file;
+extern int movenum;
+extern bool saveflag;
+
+/* message.c */
+
+extern void message_init();
+extern void message_add();
+extern void message_send();
+
+/* clock.c */
+
+extern void clock_init();
+extern void clock_draw();
+extern void clock_update();
+extern void clock_switch();
+extern bool clock_started;
+extern int movesperunit;
+extern int timeunit;
+extern int whiteseconds;
+extern int blackseconds;
+
+/* button.c */
+
+extern void button_draw();
+extern void button_service();
+
+/* jail.c */
+
+extern void jail_init();
+extern void jail_draw();
+extern void jail_add();
+extern void jail_remove();
+
+/* program.c */
+extern bool program_init();
+extern void program_end();
+extern void program_send();
+extern void program_undo();
+extern move *program_get();
+
+/* parse.c */
+
+extern void load_game();
+extern move *parse_file();
+extern move *parse_move();
+extern move *parse_imove();
+extern bool loading_flag;
+extern bool loading_paused;
+
+/* popup.c */
+
+extern bool pop_question();
+
diff --git a/gnu/games/chess/Xchess/xchess.icon b/gnu/games/chess/Xchess/xchess.icon
new file mode 100644
index 000000000000..78c68f1ba46b
--- /dev/null
+++ b/gnu/games/chess/Xchess/xchess.icon
@@ -0,0 +1,28 @@
+
+#define icon_width 48
+#define icon_height 48
+static char icon_bits[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0xc1, 0xff, 0xff, 0xff, 0xff, 0x83, 0x41, 0x00, 0x00, 0x00, 0x00, 0x82,
+ 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82,
+ 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82, 0x41, 0xf0, 0xf0, 0xf0, 0xf0, 0x82,
+ 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0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0x41, 0xc4, 0x89, 0x3c, 0xcf, 0x83,
+ 0x41, 0x24, 0x88, 0x04, 0x41, 0x80, 0x81, 0x22, 0x88, 0x04, 0x41, 0x80,
+ 0x01, 0x21, 0xf8, 0x1c, 0xcf, 0x83, 0x81, 0x22, 0x88, 0x04, 0x08, 0x82,
+ 0x41, 0x24, 0x88, 0x04, 0x08, 0x82, 0x41, 0xc4, 0x89, 0x3c, 0xcf, 0x83,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
diff --git a/gnu/games/chess/Xchess/xchess_mask.cur b/gnu/games/chess/Xchess/xchess_mask.cur
new file mode 100644
index 000000000000..6408b7e0b915
--- /dev/null
+++ b/gnu/games/chess/Xchess/xchess_mask.cur
@@ -0,0 +1,7 @@
+
+#define xchess_mask_width 16
+#define xchess_mask_height 16
+static char xchess_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xf8, 0x00, 0xfe, 0x80, 0xff,
+ 0xc0, 0xff, 0x60, 0xff, 0xb0, 0xfd, 0xd8, 0x66, 0x6c, 0x3b, 0x76, 0x1d,
+ 0x98, 0x1d, 0xcc, 0x0c, 0x60, 0x00, 0x00, 0x00};
diff --git a/gnu/games/chess/gnuchess.book b/gnu/games/chess/gnuchess.book
new file mode 100644
index 000000000000..7e8a3b5d756e
--- /dev/null
+++ b/gnu/games/chess/gnuchess.book
@@ -0,0 +1,3878 @@
+!
+! Opening Library for CHESS
+!
+! Copyright (C) 1986, 1987, 1988 Free Software Foundation, Inc.
+! Copyright (c) 1987 by Stuart Cracraft and John Stanback
+!
+! This file is part of CHESS.
+!
+! CHESS is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY. No author or distributor
+! accepts responsibility to anyone for the consequences of using it
+! or for whether it serves any particular purpose or works at all,
+! unless he says so in writing. Refer to the CHESS General Public
+! License for full details.
+!
+! Everyone is granted permission to copy, modify and redistribute
+! CHESS, but only under the conditions described in the
+! CHESS General Public License. A copy of this license is
+! supposed to have been given to you along with CHESS so you
+! can know your rights and responsibilities. It should be in a
+! file named COPYING. Among other things, the copyright notice
+! and this notice must be preserved on all copies.
+!
+!
+!
+! Four Knight's Game
+e2e4 e7e5
+g1f3 b8c6
+b1c3 g8f6
+f1b5 f8b4
+o-o o-o
+d2d3 b4c3
+b2c3 d7d6
+c1g5 d8e7
+f1e1 c6d8
+d3d4 d8e6
+! Giuoco Piano
+e2e4 e7e5
+g1f3 b8c6
+f1c4 f8c5
+d2d3 g8f6
+b1c3 d7d6
+c1g5 h7h6
+g5f6 d8f6
+c3d5 f6d8
+! Two Knights Defence
+e2e4 e7e5
+g1f3 b8c6
+f1c4 g8f6
+f3g5 d7d5
+e4d5 c6a5
+c4b5 c7c6
+d5c6 b7c6
+b5e2 h7h6
+! Two Knights Defence -- Max Lange Attack
+e2e4 e7e5
+g1f3 b8c6
+f1c4 g8f6
+d2d4 e5d4
+o-o f8c5
+e4e5 d7d5
+e5f6 d5c4
+f6g7 h8g8
+! Petrov's Defence
+e2e4 e7e5
+g1f3 g8f6
+f3e5 d7d6
+e5f3 f6e4
+d2d4 d6d5
+f1d3 f8d6
+o-o o-o
+c2c4 c8g4
+c4d5 f7f5
+b1c3 b8d7
+! Petrov's Defence
+e2e4 e7e5
+g1f3 g8f6
+d2d4 e5d4
+e4e5 f6e4
+d1d4 d7d5
+!
+! Vienna Game
+e2e4 e7e5
+b1c3 f8c5
+g1f3 d7d6
+d2d4 e5d4
+f3d4 g8f6
+c1g5 h7h6
+g5h4 b1c3
+!
+e2e4 e7e5
+b1c3 b8c6
+g1f3 g7g6
+d2d4 e5d4
+c3d5 f8g7
+c1g5 c6e7
+f3d4 c7c6
+d5c3 h7h6
+! - - - - - -
+! ECO C25/1-2
+e2e4 e7e5
+b1c3 f8c5
+f1c4 d7d6
+d2d3 c8e6
+c4e6 f7f6
+d1h5 e7d7
+c1e3 c5b6
+g1e2 b8c6
+o-o g8f6
+h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 e5d4
+f3d4 g8f6
+c1g5 h7h6
+g5h4 b1c3
+! Three Knights Game
+e2e4 e7e5
+b1c3 b8c6
+g1f3 g7g6
+d2d4 e5d4
+c3d5 f8g7
+c1g5 c6e7
+f3d4 c7c6
+d5c3 h7h6
+! Bishop's Opening
+e2e4 e7e5
+f1c4 g8f6
+d2d4 e5d4
+g1f3 f6e4
+d1d4 e4c5
+o-o c5e6
+f1e1 c7c6
+b1c3 d7d5
+c4d3 f8e7
+! Ruy Lopez -- Classical Defence
+e2e4 e7e5
+g1f3 b8c6
+f1b5 f8c5
+c2c3 g8f6
+d2d4 e5d4
+e4e5 f6e4
+o-o d7d5
+! Ruy Lopez -- Birds Defence
+e2e4 e7e5
+g1f3 b8c6
+f1b5 c6d4
+b5a4 f8c5
+o-o d4f3
+d1f3 g8e7
+d2d3 o-o
+c1e3 c5b6
+b1c3 d7d6
+! Ruy Lopez -- Schliemann Defence
+e2e4 e7e5
+g1f3 b8c6
+f1b5 f7f5
+b1c3 f5e4
+c3e4 d7d5
+f3e5 d5e4
+e5c6 d8d5
+c2c4 d5d6
+c6a7 c8d7
+! Ruy Lopez -- Old Steinitz Defence
+e2e4 e7e5
+g1f3 b8c6
+f1b5 d7d6
+d2d4 c8d7
+b1c3 g8f6
+o-o f8e7
+f1e1 e5d4
+f3d4 o-o
+d4f5 f8e8
+! Ruy Lopez -- Old Steinitz Defence
+e2e4 e7e5
+g1f3 b8c6
+f1b5 d7d6
+d2d4 c8d7
+b1c3 g8f6
+b5c6 d7c6
+d1d3 e5d4
+f3d4 f8e7
+c1g5 c6d7
+! Ruy Lopez -- Modern Steinitz Defence
+e2e4 e7e5
+g1f3 b8c6
+f1b5 a7a6
+b5a4 d7d6
+d2d4 b7b5
+a4b3 c6d4
+f3d4 e5d4
+c2c3 d4c3
+b1c3 c8b7
+! Ruy Lopez -- Open Defence
+e2e4 e7e5
+g1f3 b8c6
+f1b5 a7a6
+b5a4 g8f6
+o-o f6e4
+d2d4 b7b5
+a4b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4e5 c8f5
+f1d3 f5d3
+d1d3 e7e6
+b1c3 d8b6
+b1d2 c6c5
+d4c5 f8c5
+! Caro-Kann Defence
+e2e4 c7c6
+b1c3 d7d5
+g1f3 c8g4
+h2h3 g4f3
+d1f3 e7e6
+d2d4 g8f6
+f1d3 d5e4
+c3e4 d8d4
+c2c3 d4d8
+! French Defence -- Classical
+e2e4 e7e6
+d2d4 d7d5
+b1c3 g8f6
+c1g5 f8e7
+e4e5 f6d7
+g5e7 d8e7
+d1d2 o-o
+f2f4 c7c5
+g1f3 b8c6
+o-o-o c5c4
+! French Defence -- MacCutcheon
+e2e4 e7e6
+d2d4 d7d5
+b1c3 g8f6
+c1g5 c8g4
+e4e5 h7h6
+g5d2 g4f3
+g2f3 f6e4
+d1g4 e8f8
+h2h4 c7c5
+! French Defence -- Rubenstein
+e2e4 e7e6
+d2d4 d7d5
+b1c3 d5e4
+c3e4 b8d7
+g1f3 g8f6
+e4f6 d7f6
+f1d3 b7b6
+d1e2 c8b7
+c1g5 f8e7
+! French Defence -- Winawer
+e2e4 e7e6
+d2d4 d7d5
+b1c3 f8b4
+e4e5 c7c5
+a2a3 b4c3
+b2c3 b8d7
+d1g4 o-o
+g1f3 b8c6
+f1e3 f7f5
+! French Defence -- Tarrasch
+e2e4 e7e6
+d2d4 d7d5
+b1d2 b8c6
+g1f3 g8f6
+e4e5 f6d7
+d2b3 f7f6
+f1b5 f8e7
+c1f4 o-o
+! Sicilian Defence -- Dragon Variation
+e2e4 c7c5
+g1f3 b8c6
+d2d4 c5d4
+f3d4 g8f6
+b1c3 d7d6
+f1e2 g7g6
+c1e3 f8g7
+o-o o-o
+d4b3 c8e6
+f2f4 c6a5
+f4f5 e6c4
+! Sicilian Defence -- Dragon Variation
+e2e4 c7c5
+g1f3 b8c6
+d2d4 c5d4
+f3d4 g7g6
+b1c3 f8g7
+c1e3 g8f6
+f1c4 o-o
+! Sicilian Defence -- Boleslavsky Variation
+e2e4 c7c5
+g1f3 b8c6
+d2d4 c5d4
+f3d4 g8f6
+b1c3 d7d6
+f1e2 e7e5
+d4b3 f8e7
+o-o o-o
+c1e3 c8e6
+! Sicilian Defence -- Najdorf
+e2e4 c7c5
+g1f3 d7d6
+d2d4 c5d4
+f3d4 g8f6
+b1c3 a7a6
+c1g5 e7e6
+d1d2 f8e7
+o-o-o o-o
+! Sicilian Defence -- Najdorf
+e2e4 c7c5
+g1f3 d7d6
+d2d4 c5d4
+f3d4 g8f6
+b1c3 a7a6
+f1e2 e7e5
+d4b3 f8e7
+o-o o-o
+f2f4 b7b5
+a2a3 c8b7
+! Sicilian Defence -- Najdorf
+e2e4 c7c5
+g1f3 d7d6
+d2d4 c5d4
+f3d4 g8f6
+b1c3 a7a6
+g2g3 e7e5
+d4e2 c8e6
+f1g2 b7b5
+o-o b8d7
+! Sicilian Defence -- Closed
+e2e4 c7c5
+b1c3 b8c6
+g2g3 g7g6
+f1g2 f8g7
+d2d3 e7e6
+c1e3 d7d6
+g1e2 c6d4
+d1d2 d8h4
+o-o g8d7
+! Nimzowitsch Defence
+e2e4 b8c6
+d2d4 d7d5
+e4e5 f7f6
+g1f3 c1g4
+f1e2 e7e6
+e5f6 g8f6
+c2c3 f8d6
+c1g5 d8d7
+! Queens Gambit Accepted
+d2d4 d7d5
+c2c4 d5c4
+g1f3 g8f6
+e2e3 e7e6
+f1c4 c7c5
+o-o a7a6
+d1e2 b7b5
+c4d3 c5d4
+e3d4 b8c6
+! Queens Gambit -- Catalan
+d2d4 d7d5
+c2c4 e7e6
+g2g3 g8f6
+g1f3 f8e7
+f1g2 o-o
+o-o f6d7
+d1c2 c7c6
+b1d2 b7b6
+e2e4 c8b7
+b2b3 a8c8
+! Queens Gambit Declined -- Orthodox
+d2d4 d7d5
+c2c4 e7e6
+b1c3 g8f6
+c1g5 f8e7
+e2e3 o-o
+g1f3 b8d7
+a1c1 c7c6
+f8d3 d5c4
+f1c4 f6d5
+! Queens Gambit Declined -- Cambridge Springs
+d2d4 d7d5
+c2c4 e7e6
+b1c3 g8f6
+c1g5 b8d7
+e2e3 c7c6
+g1f3 d8a5
+f3d2 f8b4
+d1c2 o-o
+g5h4 c6c5
+! Queens Gambit Declined -- Exchange Var.
+d2d4 d7d5
+c2c4 e7e6
+b1c3 g8f6
+c1g5 b8d7
+c4d5 e6d5
+e2e3 c7c6
+f1d3 f8e7
+d1c2 o-o
+g1e2 f8e8
+! Queens Gambit Declined -- Semi-Tarrasch
+d2d4 d7d5
+c2c4 e7e6
+b1c3 g8f6
+g1f3 c7c5
+c4d5 c5d4
+d1d4 e6d5
+e2e4 b8c6
+f1b5 f6e4
+! Queens Gambit Declined -- Tarrasch
+d2d4 d7d5
+c2c4 e7e6
+b1c3 c7c5
+c4d5 e6d5
+g1f3 b8c6
+g2g3 g8f6
+f1g2 f8e7
+o-o o-o
+! Queens Gambit Declined -- Vienna
+d2d4 d7d5
+c2c4 e7e6
+g1f3 g8f6
+f1b5 f8b4
+b1c3 d5c4
+e2e4 c7c5
+e4e5 c5d4
+d1a4 b8c6
+o-o-o c1d2
+! Queens Gambit Declined -- Slav (Marshall Gambit)
+d2d4 d7d5
+c2c4 c7c6
+b1c3 e7e6
+e2e4 d4e4
+c3e4 f8b4
+c1d2 d8d4
+d2b4 d4e4
+f1e2 b8a6
+b4d6 b7b6
+! Queens Gambit --Slav (Krause)
+d2d4 d7d5
+c2c4 c7c6
+g1f3 g8f6
+b1c3 d5c4
+a2a4 c8f5
+f3e5 e7e6
+f2f3 f8b4
+c1g5 h7h6
+g5f6 d8f6
+e2e4 f5h7
+! Modern Benoni Counter Gambit
+d2d4 g8f6
+c2c4 c7c5
+d4d5 e7e6
+b1c3 e6d5
+c4d5 d7d6
+e2e4 g7g6
+f1d3 f8g7
+g1e2 o-o
+o-o a7a6
+a2a4 d8c7
+! Queens Pawn Game
+d2d4 d7d5
+g1f3 g8f6
+c1f4 c7c5
+e2e3 b8c6
+c2c3 d8b6
+d1c1 c8f5
+d4c5 b6c5
+b1d2 a8c8
+f3d4 c6d4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2c3 c7c5
+f1c4 f8g7
+g1e2 o-o
+o-o c5d4
+c3d4 b8c6
+! Grunfeld Defence -- Smyslov
+d2d4 g8f6
+c2c4 g7g6
+b1c3 d7d5
+g1f3 f8g7
+d1b3 d5c4
+b3c4 o-o
+e2e4 c8g4
+c1e3 f6d7
+o-o-o b8c6
+! Grunfeld Defence
+d2d4 g8f6
+c2c4 g7g6
+b1c3 d7d5
+c1f4 f8g7
+d2d3 o-o
+c4d5 f6d5
+c3d5 d8d5
+f4c7 b8c6
+! Kings Indian Defence -- Classical
+d2d4 g8f6
+c2c4 g7g6
+b1c3 f8g7
+e2e4 d7d6
+g1f3 o-o
+f1e2 e7e5
+o-o b8c6
+c1e3 f8e8
+d4e5 d6e5
+! Kings Indian Defence -- 4 pawns attack
+d2d4 g8f6
+c2c4 g7g6
+b1c3 f8g7
+e2e4 d7d6
+f2f4 c7c5
+g1f3 o-o
+d4d5 e7e6
+f1d3 e6d5
+c4d5 d8b6
+! Kings Indian Defence -- Samisch
+d2d4 g8f6
+c2c4 g7g6
+b1c3 f8g7
+e2e4 d7d6
+f2f3 o-o
+c1e3 e7e5
+d4d5 c7c6
+g1e2 c6d5
+c3d5 f6d5
+! Kings Indian Defence -- Main Line
+d2d4 g8f6
+c2c4 g7g6
+g2g3 f8g7
+f1g2 o-o
+b1c3 d7d6
+g1f3 b8d7
+o-o e7e5
+e2e4 c7c6
+h2h3 d8b6
+! Kings Indian Defence
+d2d4 g8f6
+c2c4 g7g6
+b1c3 f8g7
+g1f3 o-o
+c1f4 d7d6
+h2h3 b8d7
+e2e3 c7c6
+! Dutch Defence
+d2d4 f7f5
+g2g3 e7e6
+f1g2 g8f6
+g1f3 f8e7
+o-o o-o
+c2c4 d7d6
+b1c3 d8e8
+d1c2 e8h5
+b2b3 b8c6
+c1a3 a7a5
+! English Opening
+c2c4 e7e5
+b1c3 g8f6
+g1f3 b8c6
+e2e4 f8b4
+d2d3 d7d6
+f1e2 o-o
+o-o b4c3
+b2c3 d8e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1e2 e7e6
+b1d2 f8e7
+d2f1 d8a5
+! # col. 52d; Brasket-Evans, U.S. Open Chp. 1960
+e2e4 c7c5
+g1f3 d7d6
+c2c3 g8f6
+d2d3 g7g6
+g2g3 f8g7
+b1d2 o-o
+f1g2 e7e5
+o-o b8c6
+a2a4 h7h6
+d2b1 d8a5
+! # col. 53h; Ciocaltea-Fischer, Varna 1962
+e2e4 c7c5
+g1f3 d7d6
+g2g3 g7g6
+f1g2 f8g7
+o-o b8c6
+c2c3 e7e5
+d2d3 g8e7
+f3h4 o-o
+f2f4 e5f4
+g3f4 f7f5
+b1d2 g8h8
+d2f3
+! # col. 54k; Tarjan-Mednis, U.S. Chp. 1973
+e2e4 c7c5
+g1f3 b8c6
+d2d4 c5d4
+f3d4 g8f6
+b1c3 e7e6
+f1e2 g7g6
+d4b3
+! e2e4 c7c5
+g1f3 d7d6
+b1c3 g8f6
+e4e5 d6e5
+f3e5 a7a6
+f1e2 e7e6
+o-o d8c7
+e5c4 b7b5
+c4e3 f8d6
+h2h3 b8c6
+a2a4 b5b4
+c3b1 c8b7
+d2d3 c6d4
+b1d2 o-o
+d2f3 d4e2
+d1e2 f8e8
+e3c4 e6e5
+f3g5 e5e4
+c4d6 c7d6
+g5e4 f6e4
+d3e4 b7e4
+c1e3 d6c6
+! # col. 55o; Medina-Pomar, Santander 1947
+e2e4 c7c5
+g1f3 d7d6
+b2b4 c5b4
+d2d4 g8f6
+f1d3 d6d5
+b1d2 d5e4
+d2e4 b8d7
+e4g5 d8c7
+c2c4 h7h6
+g5h3 g7g5
+h3g1 f8g7
+g1e2 e7e5
+e2g3 e5e4
+d1e2 o-o
+! # col. 56e; del Corral-Benko, Mallorca 1968
+e2e4 c7c5
+g1f3 d7d6
+f1b5 c8d7
+b5d7 d8d7
+o-o b8c6
+f1e1 g8f6
+c2c3 e7e6
+d2d3 f8e7
+a2a4 o-o
+b1d2 d7c7
+! # col. 57g; Radovich-Lombardy, Leipzig 1960
+e2e4 c7c5
+g1f3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b3 f6g4
+d1e2 c6d4
+c3d5 d4e2
+d5b6 a7b6
+e1e2 h7h6
+g5h4 g7g5
+h4g3 g5f4
+g3f4 f8g7
+c2c3 d7c6
+! # col. 64j; Liberzo-Stein, USSR Chp. 1969-70. Complete game (draw).
+e2e4 c7c5
+g1f3 b8c6
+d2d4 c5d4
+f3d4 g8f6
+b1c3 d7d6
+c1g5 c8d7
+d1d3 c6d4
+d3d4 d8a5
+f2f4 e7e5
+d4d3 f8e7
+o-o-o d7c6
+c1b1 e5f4
+g5f4 o-o
+f1e2 f8e8
+e2f3 e7f8
+c3d5 f6d7
+d3d2 a5d2
+d1d2 a8c8
+h1d1 d7e5
+b2b3
+! # col. 65m; Bronstein-Stein, USSR 1969
+e2e4 c7c5
+g1f3 b8c6
+d2d4 c5d4
+f3d4 g8f6
+b1c3 d7d6
+c1g5 c8d7
+d1d3 c6d4
+d3d4 d8a5
+f1e2 e7e5
+d4d3 a5c7
+e2g4 f8e7
+g5f6 e7f6
+o-o-o f6e7
+c3b5 d7b5
+d3b5 c7c6
+b5d5 c6d5
+d1d5
+! # col. 66b; Benko-R. Byrne, US Open Chp. 1968
+e2e4 c7c5
+g1f3 b8c6
+d2d4 c5d4
+f3d4 g8f6
+b1c3 d7d6
+c1g5 c8d7
+d1d2 a8c8
+o-o-o c6d4
+d2d4 d8a5
+g5d2 a7a6
+f1c4 a5c5
+d4c5 c8c5
+c4b3 g7g6
+d2e3 c5c8
+e3d4 f8g7
+c3d5 f6h5
+d4g7 h5g7
+e4e5 c8c6
+d5b4 c6b6
+! # col. 66b alternate; Polgar-Nagy, Hungarian Chp. 1972
+e2e4 c7c5
+g1f3 b8c6
+d2d4 c5d4
+f3d4 g8f6
+b1c3 d7d6
+c1g5 c8d7
+d1d2 a8c8
+o-o-o c6d4
+d2d4 d8a5
+g5d2 e7e5
+d4d3 a7a6
+c1b1 h7h6
+f2f3 a5c7
+g2g3 f8e7
+h2h4 b7b5
+! # col. 67c; Suetin-Gheorghiu, Hast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c3 c8b7
+o-o
+! # col. 21
+d2d4 g8f6
+c2c4 e7e6
+g2g3 e6e5
+g1f3 e5d4
+f3d4 d7d5
+f1g2 d5c4
+d1a4 c7c6
+a4c4 f8e7
+o-o o-o
+f1d1
+! # col. 22
+d2d4 g8f6
+c2c4 e7e6
+g2g3 c7c5
+g1f3 c5d4
+f3d4 d7d5
+f1g2 e6e5
+d4f3 d5d4
+o-o b8c6
+e2e3 f8e7
+e3d4 e5d4
+! # col. 23g
+d2d4 g8f6
+c2c4 e7e6
+g2g3 c7c5
+g1f3 c5d4
+f3d4 b8c6
+f1g2 d8b6
+d4c2 f8c5
+e2e3 o-o
+b1c3 b6a6
+d1d2 f8d8
+a2a3 d7d5
+b2b4 d5d4
+c3e4
+! # col. 24j; Smyslov-Petrosian, Moscow 1967
+d2d4 g8f6
+c2c4 e7e6
+g2g3 f8b4
+b1d2 c7c5
+d4c5 b4c5
+f1g2 b8c6
+g1f3 b7b6
+o-o c8b7
+a2a3 o-o
+b2b4 c5e7
+c1b2 a8c8
+d1b1
+! # col. 25
+d2d4 g8f6
+c2c4 e7e6
+g2g3 f8b4
+c1d2 b4d2
+d1d2 f6e4
+d2c2 f7f5
+f2f3 e4f6
+e2e4 f5e4
+f3e4 e6e5
+! # Alternate openings leading to the Catalan, line C
+g1f3 d7d5
+c2c4 e7e6
+g2g3 g8f6
+d2d4
+! # line D
+c2c4 g8f6
+d2d4 e7e6
+g2g3 d7d5
+! # line E
+d2d4 g8f6
+c2c4 e7e6
+g2g3 d7d5
+! # The Reti Opening, col. 1c; Muller-Lilenthal, Budapest 1933
+g1f3 d7d5
+c2c4 c7c6
+b2b3 g8f6
+g2g3 c8f5
+c1b2 e7e6
+f1g2 b8d7
+o-o f8d6
+d2d3 o-o
+b1c3 d8e7
+f1e1 e6e5
+c4d5 c6d5
+e2e4 d5e4
+d3e4 f5g6
+! # col. 2g; Bilek-Geller, Sousse 1967
+g1f3 d7d5
+c2c4 c7c6
+b2b3 g8f6
+g2g3 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2 f8d8
+f1d1
+! # col. 9h; Abroshin-Krykov corr. 1960
+g1f3 d7d5
+c2c4 e7e6
+g2g3 g8f6
+f1g2 d5c4
+d1a4 c8d7
+a4c4 d7c6
+o-o c6d5
+c4a4 d8d7
+a4c2 b8c6
+b1c3 d5f3
+g2f3 c6d4
+c2d3 c7c6
+! # col. 10m; Teti-Tartakover, Semmering 1926
+g1f3 d7d5
+c2c4 e7e6
+g2g3 d5c4
+d1a4 c8d7
+a4c4 c7c5
+f3e5 b8c6
+e5d7 d8d7
+f1g2 g8f6
+d2d3 f8e7
+o-o c6d4
+b1c3 a8d8
+a2a4 f6d5
+! # Barcza System, col. 11
+g1f3 d7d5
+g2g3 g8f6
+f1g2 c8f5
+o-o c7c6
+c2c4 d5c4
+b1a3 e7e5
+a3c4 e5e4
+f3e1 f8c5
+d2d3 o-o
+c1e3 b8d7
+! # col. 12d; Benko-Petrosian, Curacao 1962
+g1f3 d7d5
+g2g3 g8f6
+f1g2 c8f5
+o-o c7c6
+d2d3 b8d7
+b1d2 h7h6
+d1e1 e7e6
+e2e4 f5h7
+e1e2 f8e7
+e4e5 f6g8
+d2b3 e7f8
+c2c4 g8e7
+b3d4 e7f5
+d4f5 h7f5
+c4d5 c6d5
+d3d4 a7a5
+c1e3 f8e7
+f1c1 o-o
+! # col. 13f; Bronstein-O'Kelly, Beverwijk 1963
+g1f3 d7d5
+g2g3 g8f6
+f1g2 c7c5
+o-o e7e6
+d2d3 b8c6
+b1d2 f8e7
+e2e4 o-o
+f1e1 d8c7
+e4e5 f6d7
+d1e2 b7b5
+h2h4 a7a5
+d2f1 c8a6
+f1h2 c6b4
+h4h5
+! # col. 14i; Evans-Olafsson, Dallas 1957
+g1f3 d7d5
+g2g3 g8f6
+f1g2 g7g6
+o-o f8g7
+d2d3 o-o
+b1d2 b8c6
+e2e4 e7e5
+c2c3 a7a5
+f1e1 d5e4
+d3e4 f6d7
+d1e2 b7b6
+d2c4 c8a6
+g2f1 d8f6
+! # col. 15
+g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Fischer-Ivkov, Santa Monica 1966
+g1f3 d7d5
+g2g3 e7e6
+f1g2 c7c5
+o-o b8c6
+d2d3 f8d6
+e2e4 g8e7
+b1d2 o-o
+f3h4 b7b6
+f2f4 d5e4
+d3e4 c8a6
+f1e1 c5c4
+c2c3
+! # col. 23
+g1f3 d7d5
+g2g3 b8d7
+c2c4 e7e6
+f1g2 g8f6
+b1c3 f8e7
+o-o o-o
+d2d3 c7c5
+c4d5 e6d5
+c1g5 b7b6
+! # col. 24g; Benko-Bisguier, US Chp. 1976-7
+g1f3 d7d5
+g2g3 g8f6
+f1g2 b7b6
+c2c4 e7e6
+c4d5 e6d5
+o-o f8d6
+d2d4 o-o
+b1c3 c7c6
+f3e5 c8b7
+c1g5 h7h6
+g5f6 d8f6
+f2f4 f8d8
+e2e4
+! # col. 25; Rabinovich-Rauser, Moscow 1934
+g1f3 d7d5
+b2b3 c8g4
+c1b2 b8d7
+c2c4 e7e6
+e2e3 g8f6
+f1e2 c7c6
+f3d4 g4e2
+d1e2 f8d6
+f2f4 o-o
+! # col. 26e; Evans-Najdorf, Dallas 1967
+g1f3 c7c5
+g2g3 b8c6
+f1g2 g7g6
+o-o f8g7
+e2e4 d7d6
+c2c3 e7e5
+d2d3 g8h6
+f3e1 o-o
+f2f4 e5f4
+c1f4 h6g4
+b1a3 g4e5
+g1h1 d8b6
+d1d2 c8e6
+! # col. 27h; Van den Pol-Barden, Holland v. England 1960
+g1f3 f7f5
+g2g3 g8f6
+f1g2 g7g6
+d2d3 f8g7
+b1d2 d7d6
+e2e4 e7e5
+d2c4 o-o
+e4f5 g6f5
+c1e3 b8c6
+d3d4 e5e4
+! # col. 28m; Gufeld-Bokuchava, USSR Chp. prelims 1968
+g1f3 f7f5
+g2g3 g8f6
+f1g2 e7e6
+c2c4 f8e7
+o-o o-o
+d2d3 d7d6
+b1c3 b8c6
+a1b1 a7a5
+a2a3 d8e8
+b2b4 a5b4
+a3b4 e6e5
+! # col. 29p; Lundin-Tartakover, Groningen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f8g7
+c1b2 o-o
+b1c3 d7d5
+c3d5 f6d5
+b2g7 g8g7
+c4d5 d8d5
+d2d4 b8a6
+! # col. 38h; Geller-Kholmov, Moscow 1969
+g1f3 g8f6
+c2c4 b7b6
+g2g3 c8b7
+f1g2 e7e6
+o-o f8e7
+b2b3 o-o
+c1b2 d7d5
+e2e3 b8d7
+b1c3 f6e4
+c4d5 e4c3
+b2c3 e6d5
+! # col. 39
+g1f3 g8f6
+b2b3 g7g6
+c2c4 f8g7
+c1b2 o-o
+g2g3 c7c5
+f1g2 b7b6
+o-o c8b7
+b1c3 e7e6
+a1b1 d8e7
+! # col. 40o; Lombardy-Burger, US Chp. 1969-70
+g1f3 g8f6
+b2b3 d7d5
+c1b2 e7e6
+e2e3 f8e7
+c2c4 o-o
+d2d4 b7b6
+f1d3 c8b7
+o-o b8d7
+b1d2 c7c5
+d1e2 f6e4
+a1c1 a8c8
+!
diff --git a/gnu/games/chess/gnuchess.c b/gnu/games/chess/gnuchess.c
new file mode 100644
index 000000000000..ac62953678d3
--- /dev/null
+++ b/gnu/games/chess/gnuchess.c
@@ -0,0 +1,2307 @@
+/*
+ C source for CHESS
+
+ Revision: 4-25-88
+
+ Copyright (C) 1986, 1987, 1988 Free Software Foundation, Inc.
+ Copyright (c) 1988 John Stanback
+
+ This file is part of CHESS.
+
+ CHESS is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY. No author or distributor
+ accepts responsibility to anyone for the consequences of using it
+ or for whether it serves any particular purpose or works at all,
+ unless he says so in writing. Refer to the CHESS General Public
+ License for full details.
+
+ Everyone is granted permission to copy, modify and redistribute
+ CHESS, but only under the conditions described in the
+ CHESS General Public License. A copy of this license is
+ supposed to have been given to you along with CHESS so you
+ can know your rights and responsibilities. It should be in a
+ file named COPYING. Among other things, the copyright notice
+ and this notice must be preserved on all copies.
+*/
+
+
+#include <stdio.h>
+#include <ctype.h>
+
+#ifdef MSDOS
+#include <stdlib.h>
+#include <time.h>
+#include <alloc.h>
+#define ttblsz 4096
+#else
+#include <sys/param.h>
+#include <sys/times.h>
+#define ttblsz 16384
+#define huge
+#endif MSDOS
+
+#include "move.h"
+
+#define neutral 2
+#define white 0
+#define black 1
+#define no_piece 0
+#define pawn 1
+#define knight 2
+#define bishop 3
+#define rook 4
+#define queen 5
+#define king 6
+#define valueP 100
+#define valueN 350
+#define valueB 355
+#define valueR 550
+#define valueQ 1100
+#define valueK 1200
+#define ctlP 0x4000
+#define ctlN 0x2800
+#define ctlB 0x1800
+#define ctlR 0x0400
+#define ctlQ 0x0200
+#define ctlK 0x0100
+#define ctlBQ 0x1200
+#define ctlRQ 0x0600
+#define ctlNN 0x2000
+#define pxx " PNBRQK"
+#define qxx " pnbrqk"
+#define rxx "12345678"
+#define cxx "abcdefgh"
+#define check 0x0001
+#define capture 0x0002
+#define draw 0x0004
+#define promote 0x0008
+#define cstlmask 0x0010
+#define epmask 0x0020
+#define exact 0x0040
+#define pwnthrt 0x0080
+#define truescore 0x0001
+#define lowerbound 0x0002
+#define upperbound 0x0004
+#define maxdepth 30
+#define true 1
+#define false 0
+#define absv(x) ((x) < 0 ? -(x) : (x))
+#if (NEWMOVE < 1)
+#define taxicab(a,b) (abs(column[a]-column[b]) + abs(row[a]-row[b]))
+#endif
+struct leaf
+ {
+ short f,t,score,reply;
+ unsigned short flags;
+ };
+struct GameRec
+ {
+ unsigned short gmove;
+ short score,depth,time,piece,color;
+ long nodes;
+ };
+struct TimeControlRec
+ {
+ short moves[2];
+ long clock[2];
+ };
+struct BookEntry
+ {
+ struct BookEntry *next;
+ unsigned short *mv;
+ };
+struct hashval
+ {
+ unsigned long bd;
+ unsigned short key;
+ };
+struct hashentry
+ {
+ unsigned long hashbd;
+ unsigned short mv,flags;
+ short score,depth;
+ };
+
+char mvstr1[5],mvstr2[5];
+struct leaf Tree[2000],*root;
+short TrPnt[maxdepth],board[64],color[64];
+short row[64],column[64],locn[8][8],Pindex[64],svalue[64];
+short PieceList[2][16],PieceCnt[2],atak[2][64],PawnCnt[2][8];
+short castld[2],kingmoved[2],mtl[2],pmtl[2],emtl[2],hung[2];
+short c1,c2,*atk1,*atk2,*PC1,*PC2,EnemyKing;
+short mate,post,opponent,computer,Sdepth,Awindow,Bwindow,dither;
+long ResponseTime,ExtraTime,Level,et,et0,time0,cputimer,ft;
+long NodeCnt,evrate,ETnodes,EvalNodes,HashCnt;
+short quit,reverse,bothsides,hashflag,InChk,player,force,easy,beep;
+short wking,bking,FROMsquare,TOsquare,timeout,Zscore,zwndw,xwndw,slk;
+short INCscore;
+short HasPawn[2],HasKnight[2],HasBishop[2],HasRook[2],HasQueen[2];
+short ChkFlag[maxdepth],CptrFlag[maxdepth],PawnThreat[maxdepth];
+short Pscore[maxdepth],Tscore[maxdepth],Threat[maxdepth];
+struct GameRec GameList[240];
+short GameCnt,Game50,epsquare,lpost,rcptr,contempt;
+short MaxSearchDepth;
+struct BookEntry *Book;
+struct TimeControlRec TimeControl;
+short TCflag,TCmoves,TCminutes,OperatorTime;
+short otherside[3]={1,0,2};
+short rank7[3]={6,1,0};
+short map[64]=
+ {0,1,2,3,4,5,6,7,
+ 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
+ 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,
+ 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,
+ 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,
+ 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,
+ 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,
+ 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77};
+short unmap[120]=
+ {0,1,2,3,4,5,6,7,-1,-1,-1,-1,-1,-1,-1,-1,
+ 8,9,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,
+ 16,17,18,19,20,21,22,23,-1,-1,-1,-1,-1,-1,-1,-1,
+ 24,25,26,27,28,29,30,31,-1,-1,-1,-1,-1,-1,-1,-1,
+ 32,33,34,35,36,37,38,39,-1,-1,-1,-1,-1,-1,-1,-1,
+ 40,41,42,43,44,45,46,47,-1,-1,-1,-1,-1,-1,-1,-1,
+ 48,49,50,51,52,53,54,55,-1,-1,-1,-1,-1,-1,-1,-1,
+ 56,57,58,59,60,61,62,63};
+short Dcode[120]=
+ {0,1,1,1,1,1,1,1,0,0,0,0,0,0,0x0E,0x0F,
+ 0x10,0x11,0x12,0,0,0,0,0,0,0,0,0,0,0,0x0F,0x1F,
+ 0x10,0x21,0x11,0,0,0,0,0,0,0,0,0,0,0x0F,0,0,
+ 0x10,0,0,0x11,0,0,0,0,0,0,0,0,0x0F,0,0,0,
+ 0x10,0,0,0,0x11,0,0,0,0,0,0,0x0F,0,0,0,0,
+ 0x10,0,0,0,0,0x11,0,0,0,0,0x0F,0,0,0,0,0,
+ 0x10,0,0,0,0,0,0x11,0,0,0x0F,0,0,0,0,0,0,
+ 0x10,0,0,0,0,0,0,0x11};
+short Stboard[64]=
+ {rook,knight,bishop,queen,king,bishop,knight,rook,
+ pawn,pawn,pawn,pawn,pawn,pawn,pawn,pawn,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ pawn,pawn,pawn,pawn,pawn,pawn,pawn,pawn,
+ rook,knight,bishop,queen,king,bishop,knight,rook};
+short Stcolor[64]=
+ {white,white,white,white,white,white,white,white,
+ white,white,white,white,white,white,white,white,
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
+ black,black,black,black,black,black,black,black,
+ black,black,black,black,black,black,black,black};
+short sweep[7]= {false,false,false,true,true,true,false};
+short Dpwn[3]={4,6,0};
+short Dstart[7]={6,4,8,4,0,0,0};
+short Dstop[7]={7,5,15,7,3,7,7};
+short Dir[16]={1,0x10,-1,-0x10,0x0F,0x11,-0x0F,-0x11,
+ 0x0E,-0x0E,0x12,-0x12,0x1F,-0x1F,0x21,-0x21};
+short Pdir[34]={0,0x38,0,0,0,0,0,0,0,0,0,0,0,0,0x02,0x35,
+ 0x38,0x35,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0x02,
+ 0,0x02};
+short pbit[7]={0,0x01,0x02,0x04,0x08,0x10,0x20};
+unsigned short killr0[maxdepth],killr1[maxdepth],killr2[maxdepth];
+unsigned short killr3[maxdepth],PrVar[maxdepth];
+unsigned short PV,hint,Swag0,Swag1,Swag2,Swag3,Swag4;
+unsigned short hashkey;
+unsigned long hashbd;
+struct hashval hashcode[2][7][64];
+struct hashentry huge *ttable,*ptbl;
+unsigned char history[8192];
+
+short Mwpawn[64],Mbpawn[64],Mknight[2][64],Mbishop[2][64];
+short Mking[2][64],Kfield[2][64];
+short value[7]={0,valueP,valueN,valueB,valueR,valueQ,valueK};
+short control[7]={0,ctlP,ctlN,ctlB,ctlR,ctlQ,ctlK};
+short PassedPawn0[8]={0,60,80,120,200,360,600,800};
+short PassedPawn1[8]={0,30,40,60,100,180,300,800};
+short PassedPawn2[8]={0,15,25,35,50,90,140,800};
+short PassedPawn3[8]={0,5,10,15,20,30,140,800};
+short ISOLANI[8] = {-12,-16,-20,-24,-24,-20,-16,-12};
+short BACKWARD[8] = {-6,-10,-15,-21,-28,-28,-28,-28};
+short BMBLTY[14] = {-2,0,2,4,6,8,10,12,13,14,15,16,16,16};
+short RMBLTY[14] = {0,2,4,6,8,10,11,12,13,14,14,14,14,14};
+short Kthreat[16] = {0,-8,-20,-36,-52,-68,-80,-80,-80,-80,-80,-80,
+ -80,-80,-80,-80};
+short KNIGHTPOST,KNIGHTSTRONG,BISHOPSTRONG,KATAK,KBNKsq;
+short PEDRNK2B,PWEAKH,PADVNCM,PADVNCI,PAWNSHIELD,PDOUBLED,PBLOK;
+short RHOPN,RHOPNX,KHOPN,KHOPNX,KSFTY;
+short ATAKD,HUNGP,HUNGX,KCASTLD,KMOVD,XRAY,PINVAL;
+short stage,stage2,Zwmtl,Zbmtl,Developed[2],PawnStorm;
+short PawnBonus,BishopBonus,RookBonus;
+short KingOpening[64]=
+ { 0, 0, -4,-10,-10, -4, 0, 0,
+ -4, -4, -8,-12,-12, -8, -4, -4,
+ -12,-16,-20,-20,-20,-20,-16,-12,
+ -16,-20,-24,-24,-24,-24,-20,-16,
+ -16,-20,-24,-24,-24,-24,-20,-16,
+ -12,-16,-20,-20,-20,-20,-16,-12,
+ -4, -4, -8,-12,-12, -8, -4, -4,
+ 0, 0, -4,-10,-10, -4, 0, 0};
+short KingEnding[64]=
+ { 0, 6,12,18,18,12, 6, 0,
+ 6,12,18,24,24,18,12, 6,
+ 12,18,24,30,30,24,18,12,
+ 18,24,30,36,36,30,24,18,
+ 18,24,30,36,36,30,24,18,
+ 12,18,24,30,30,24,18,12,
+ 6,12,18,24,24,18,12, 6,
+ 0, 6,12,18,18,12, 6, 0};
+short DyingKing[64]=
+ { 0, 8,16,24,24,16, 8, 0,
+ 8,32,40,48,48,40,32, 8,
+ 16,40,56,64,64,56,40,16,
+ 24,48,64,72,72,64,48,24,
+ 24,48,64,72,72,64,48,24,
+ 16,40,56,64,64,56,40,16,
+ 8,32,40,48,48,40,32, 8,
+ 0, 8,16,24,24,16, 8, 0};
+short KBNK[64]=
+ {99,90,80,70,60,50,40,40,
+ 90,80,60,50,40,30,20,40,
+ 80,60,40,30,20,10,30,50,
+ 70,50,30,10, 0,20,40,60,
+ 60,40,20, 0,10,30,50,70,
+ 50,30,10,20,30,40,60,80,
+ 40,20,30,40,50,60,80,90,
+ 40,40,50,60,70,80,90,99};
+short pknight[64]=
+ { 0, 4, 8,10,10, 8, 4, 0,
+ 4, 8,16,20,20,16, 8, 4,
+ 8,16,24,28,28,24,16, 8,
+ 10,20,28,32,32,28,20,10,
+ 10,20,28,32,32,28,20,10,
+ 8,16,24,28,28,24,16, 8,
+ 4, 8,16,20,20,16, 8, 4,
+ 0, 4, 8,10,10, 8, 4, 0};
+short pbishop[64]=
+ {14,14,14,14,14,14,14,14,
+ 14,22,18,18,18,18,22,14,
+ 14,18,22,22,22,22,18,14,
+ 14,18,22,22,22,22,18,14,
+ 14,18,22,22,22,22,18,14,
+ 14,18,22,22,22,22,18,14,
+ 14,22,18,18,18,18,22,14,
+ 14,14,14,14,14,14,14,14};
+short PawnAdvance[64]=
+ { 0, 0, 0, 0, 0, 0, 0, 0,
+ 4, 4, 4, 0, 0, 4, 4, 4,
+ 6, 8, 2,10,10, 2, 8, 6,
+ 6, 8,12,16,16,12, 8, 6,
+ 8,12,16,24,24,16,12, 8,
+ 12,16,24,32,32,24,16,12,
+ 12,16,24,32,32,24,16,12,
+ 0, 0, 0, 0, 0, 0, 0, 0};
+
+
+main(argc,argv)
+int argc; char *argv[];
+{
+#ifdef MSDOS
+ ttable = (struct hashentry huge *)farmalloc(ttblsz *
+ (unsigned long)sizeof(struct hashentry));
+#else
+ ttable = (struct hashentry *)malloc(ttblsz *
+ (unsigned long)sizeof(struct hashentry));
+#endif
+ Level = 0; TCflag = false; OperatorTime = 0;
+ if (argc == 2) Level = atoi(argv[1]);
+ if (argc == 3)
+ {
+ TCmoves = atoi(argv[1]); TCminutes = atoi(argv[2]); TCflag = true;
+ }
+ Initialize();
+ NewGame();
+#if (NEWMOVE > 0)
+ Initialize_dist();
+#if (NEWMOVE > 1)
+ Initialize_moves();
+#endif
+#endif
+ while (!(quit))
+ {
+ if (bothsides && !mate) SelectMove(opponent,1); else InputCommand();
+ if (!(quit || mate || force)) SelectMove(computer,1);
+ }
+ ExitChess();
+}
+
+
+
+/* ............ INTERFACE ROUTINES ........................... */
+
+int VerifyMove(s,iop,mv)
+char s[];
+short iop;
+unsigned short *mv;
+
+/*
+ Compare the string 's' to the list of legal moves available for the
+ opponent. If a match is found, make the move on the board.
+*/
+
+{
+static short pnt,tempb,tempc,tempsf,tempst,cnt;
+static struct leaf xnode;
+struct leaf *node;
+
+ *mv = 0;
+ if (iop == 2)
+ {
+ UnmakeMove(opponent,&xnode,&tempb,&tempc,&tempsf,&tempst);
+ return(false);
+ }
+ cnt = 0;
+ MoveList(opponent,2);
+ pnt = TrPnt[2];
+ while (pnt < TrPnt[3])
+ {
+ node = &Tree[pnt++];
+ algbr(node->f,node->t,(short) node->flags & cstlmask);
+ if (strcmp(s,mvstr1) == 0 || strcmp(s,mvstr2) == 0)
+ {
+ cnt++; xnode = *node;
+ }
+ }
+ if (cnt == 1)
+ {
+ MakeMove(opponent,&xnode,&tempb,&tempc,&tempsf,&tempst);
+ if (SqAtakd(PieceList[opponent][0],computer))
+ {
+ UnmakeMove(opponent,&xnode,&tempb,&tempc,&tempsf,&tempst);
+ ShowMessage("Illegal Move!!");
+ return(false);
+ }
+ else
+ {
+ if (iop == 1) return(true);
+ if (xnode.flags & epmask) UpdateDisplay(0,0,1,0);
+ else UpdateDisplay(xnode.f,xnode.t,0,xnode.flags & cstlmask);
+ if (xnode.flags & cstlmask) Game50 = GameCnt;
+ else if (board[xnode.t] == pawn || (xnode.flags & capture))
+ Game50 = GameCnt;
+ GameList[GameCnt].depth = GameList[GameCnt].score = 0;
+ GameList[GameCnt].nodes = 0;
+ ElapsedTime(1);
+ GameList[GameCnt].time = (short)et;
+ TimeControl.clock[opponent] -= et;
+ --TimeControl.moves[opponent];
+ *mv = (xnode.f << 8) + xnode.t;
+ algbr(xnode.f,xnode.t,false);
+ return(true);
+ }
+ }
+ if (cnt > 1) ShowMessage("Ambiguous Move!");
+ return(false);
+}
+
+
+NewGame()
+
+/*
+ Reset the board and other variables to start a new game.
+*/
+
+{
+short l,r,c,p;
+
+ mate = quit = reverse = bothsides = post = false;
+ hashflag = force = PawnStorm = false;
+ beep = rcptr = easy = true;
+ lpost = NodeCnt = epsquare = et0 = 0;
+ dither = 0;
+ Awindow = 90;
+ Bwindow = 90;
+ xwndw = 90;
+ MaxSearchDepth = 29;
+ contempt = 0;
+ GameCnt = -1; Game50 = 0;
+ Zwmtl = Zbmtl = 0;
+ Developed[white] = Developed[black] = false;
+ castld[white] = castld[black] = false;
+ kingmoved[white] = kingmoved[black] = 0;
+ PawnThreat[0] = CptrFlag[0] = Threat[0] = false;
+ Pscore[0] = 12000; Tscore[0] = 12000;
+ opponent = white; computer = black;
+ for (r = 0; r < 8; r++)
+ for (c = 0; c < 8; c++)
+ {
+ l = 8*r+c; locn[r][c] = l;
+ row[l] = r; column[l] = c;
+ board[l] = Stboard[l]; color[l] = Stcolor[l];
+ }
+ for (c = white; c <= black; c++)
+ for (p = pawn; p <= king; p++)
+ for (l = 0; l < 64; l++)
+ {
+ hashcode[c][p][l].key = (unsigned short)rand();
+ hashcode[c][p][l].bd = ((unsigned long)rand() << 16) +
+ (unsigned long)rand();
+ }
+ ClrScreen();
+ if (TCflag) SetTimeControl();
+ else if (Level == 0) SelectLevel();
+ UpdateDisplay(0,0,1,0);
+ InitializeStats();
+ time0 = time((long *)0);
+ ElapsedTime(1);
+ GetOpenings();
+}
+
+
+algbr(f,t,iscastle)
+short f,t,iscastle;
+{
+ mvstr1[0] = cxx[column[f]]; mvstr1[1] = rxx[row[f]];
+ mvstr1[2] = cxx[column[t]]; mvstr1[3] = rxx[row[t]];
+ mvstr2[0] = qxx[board[f]];
+ mvstr2[1] = mvstr1[2]; mvstr2[2] = mvstr1[3];
+ mvstr1[4] = '\0'; mvstr2[3] = '\0';
+ if (iscastle)
+ if (t > f) strcpy(mvstr2,"o-o");
+ else strcpy(mvstr2,"o-o-o");
+}
+
+
+/* ............ MOVE GENERATION & SEARCH ROUTINES .............. */
+
+SelectMove(side,iop)
+short side,iop;
+
+/*
+ Select a move by calling function search() at progressively deeper
+ ply until time is up or a mate or draw is reached. An alpha-beta
+ window of -90 to +90 points is set around the score returned from the
+ previous iteration. If Sdepth != 0 then the program has correctly
+ predicted the opponents move and the search will start at a depth of
+ Sdepth+1 rather than a depth of 1.
+*/
+
+{
+static short i,alpha,beta,score,tempb,tempc,tempsf,tempst,xside,rpt;
+
+ timeout = false;
+ xside = otherside[side];
+ if (iop != 2) player = side;
+ if (TCflag)
+ {
+ if (((TimeControl.moves[side] + 3) - OperatorTime) != 0)
+ ResponseTime = (TimeControl.clock[side]) /
+ (TimeControl.moves[side] + 3) -
+ OperatorTime;
+ else ResponseTime = 0;
+ ResponseTime += (ResponseTime*TimeControl.moves[side])/(2*TCmoves+1);
+ }
+ else ResponseTime = Level;
+ if (iop == 2) ResponseTime = 999;
+ if (Sdepth > 0 && root->score > Zscore-zwndw) ResponseTime -= ft;
+ else if (ResponseTime < 1) ResponseTime = 1;
+ ExtraTime = 0;
+ ExaminePosition();
+ ScorePosition(side,&score);
+ ShowSidetomove();
+
+ if (Sdepth == 0)
+ {
+ ZeroTTable();
+ SearchStartStuff(side);
+ for (i = 0; i < 8192; i++) history[i] = 0;
+ FROMsquare = TOsquare = -1;
+ PV = 0;
+ if (iop != 2) hint = 0;
+ for (i = 0; i < maxdepth; i++)
+ PrVar[i] = killr0[i] = killr1[i] = killr2[i] = killr3[i] = 0;
+ alpha = score-90; beta = score+90;
+ rpt = 0;
+ TrPnt[1] = 0; root = &Tree[0];
+ MoveList(side,1);
+ for (i = TrPnt[1]; i < TrPnt[2]; i++) pick(i,TrPnt[2]-1);
+ if (Book != NULL) OpeningBook();
+ if (Book != NULL) timeout = true;
+ NodeCnt = ETnodes = EvalNodes = HashCnt = 0;
+ Zscore = 0; zwndw = 20;
+ }
+
+ while (!timeout && Sdepth < MaxSearchDepth)
+ {
+ Sdepth++;
+ ShowDepth(' ');
+ score = search(side,1,Sdepth,alpha,beta,PrVar,&rpt);
+ for (i = 1; i <= Sdepth; i++) killr0[i] = PrVar[i];
+ if (score < alpha)
+ {
+ ShowDepth('-');
+ ExtraTime = 10*ResponseTime;
+ ZeroTTable();
+ score = search(side,1,Sdepth,-9000,beta,PrVar,&rpt);
+ }
+ if (score > beta && !(root->flags & exact))
+ {
+ ShowDepth('+');
+ ExtraTime = 0;
+ ZeroTTable();
+ score = search(side,1,Sdepth,alpha,9000,PrVar,&rpt);
+ }
+ score = root->score;
+ if (!timeout)
+ for (i = TrPnt[1]+1; i < TrPnt[2]; i++) pick(i,TrPnt[2]-1);
+ ShowResults(score,PrVar,'.');
+ for (i = 1; i <= Sdepth; i++) killr0[i] = PrVar[i];
+ if (score > Zscore-zwndw && score > Tree[1].score+250) ExtraTime = 0;
+ else if (score > Zscore-3*zwndw) ExtraTime = ResponseTime;
+ else ExtraTime = 3*ResponseTime;
+ if (root->flags & exact) timeout = true;
+ if (Tree[1].score < -9000) timeout = true;
+ if (4*et > 2*ResponseTime + ExtraTime) timeout = true;
+ if (!timeout)
+ {
+ Tscore[0] = score;
+ if (Zscore == 0) Zscore = score;
+ else Zscore = (Zscore+score)/2;
+ }
+ zwndw = 20+abs(Zscore/12);
+ beta = score + Bwindow;
+ if (Zscore < score) alpha = Zscore - Awindow - zwndw;
+ else alpha = score - Awindow - zwndw;
+ }
+
+ score = root->score;
+ if (rpt >= 2 || score < -12000) root->flags |= draw;
+ if (iop == 2) return(0);
+ if (Book == NULL) hint = PrVar[2];
+ ElapsedTime(1);
+
+ if (score > -9999 && rpt <= 2)
+ {
+ MakeMove(side,root,&tempb,&tempc,&tempsf,&tempst);
+ algbr(root->f,root->t,(short) root->flags & cstlmask);
+ }
+ else mvstr1[0] = '\0';
+ OutputMove();
+ if (score == -9999 || score == 9998) mate = true;
+ if (mate) hint = 0;
+ if (root->flags & cstlmask) Game50 = GameCnt;
+ else if (board[root->t] == pawn || (root->flags & capture))
+ Game50 = GameCnt;
+ GameList[GameCnt].score = score;
+ GameList[GameCnt].nodes = NodeCnt;
+ GameList[GameCnt].time = (short)et;
+ GameList[GameCnt].depth = Sdepth;
+ if (TCflag)
+ {
+ TimeControl.clock[side] -= (et + OperatorTime);
+ if (--TimeControl.moves[side] == 0) SetTimeControl();
+ }
+ if ((root->flags & draw) && bothsides) quit = true;
+ if (GameCnt > 238) quit = true;
+ player = xside;
+ Sdepth = 0;
+ fflush(stdin);
+ return(0);
+}
+
+
+OpeningBook()
+
+/*
+ Go thru each of the opening lines of play and check for a match with
+ the current game listing. If a match occurs, generate a random number.
+ If this number is the largest generated so far then the next move in
+ this line becomes the current "candidate". After all lines are
+ checked, the candidate move is put at the top of the Tree[] array and
+ will be played by the program. Note that the program does not handle
+ book transpositions.
+*/
+
+{
+short j,pnt;
+unsigned short m,*mp;
+unsigned r,r0;
+struct BookEntry *p;
+
+ srand((unsigned)time0);
+ r0 = m = 0;
+ p = Book;
+ while (p != NULL)
+ {
+ mp = p->mv;
+ for (j = 0; j <= GameCnt; j++)
+ if (GameList[j].gmove != *(mp++)) break;
+ if (j > GameCnt)
+ if ((r=rand()) > r0)
+ {
+ r0 = r; m = *mp;
+ hint = *(++mp);
+ }
+ p = p->next;
+ }
+
+ for (pnt = TrPnt[1]; pnt < TrPnt[2]; pnt++)
+ if ((Tree[pnt].f<<8) + Tree[pnt].t == m) Tree[pnt].score = 0;
+ pick(TrPnt[1],TrPnt[2]-1);
+ if (Tree[TrPnt[1]].score < 0) Book = NULL;
+}
+
+
+#define UpdateSearchStatus\
+{\
+ if (post) ShowCurrentMove(pnt,node->f,node->t);\
+ if (pnt > TrPnt[1])\
+ {\
+ d = best-Zscore; e = best-node->score;\
+ if (best < alpha) ExtraTime = 10*ResponseTime;\
+ else if (d > -zwndw && e > 4*zwndw) ExtraTime = -ResponseTime/3;\
+ else if (d > -zwndw) ExtraTime = 0;\
+ else if (d > -3*zwndw) ExtraTime = ResponseTime;\
+ else if (d > -9*zwndw) ExtraTime = 3*ResponseTime;\
+ else ExtraTime = 5*ResponseTime;\
+ }\
+}
+
+int search(side,ply,depth,alpha,beta,bstline,rpt)
+short side,ply,depth,alpha,beta,*rpt;
+unsigned short bstline[];
+
+/*
+ Perform an alpha-beta search to determine the score for the current
+ board position. If depth <= 0 only capturing moves, pawn promotions
+ and responses to check are generated and searched, otherwise all
+ moves are processed. The search depth is modified for check evasions,
+ certain re-captures and threats. Extensions may continue for up to 11
+ ply beyond the nominal search depth.
+*/
+
+#define prune (cf && score+node->score < alpha)
+#define ReCapture (rcptr && score > alpha && score < beta &&\
+ ply > 2 && CptrFlag[ply-1] && CptrFlag[ply-2])
+#define MateThreat (ply < Sdepth+4 && ply > 4 &&\
+ ChkFlag[ply-2] && ChkFlag[ply-4] &&\
+ ChkFlag[ply-2] != ChkFlag[ply-4])
+
+{
+register short j,pnt;
+short best,tempb,tempc,tempsf,tempst;
+short xside,pbst,d,e,cf,score,rcnt;
+unsigned short mv,nxtline[maxdepth];
+struct leaf *node,tmp;
+
+ NodeCnt++;
+ xside = otherside[side];
+ if (depth < 0) depth = 0;
+
+ if (ply <= Sdepth+3) repetition(rpt); else *rpt = 0;
+ if (*rpt >= 2) return(0);
+
+ score = evaluate(side,xside,ply,alpha,beta);
+ if (score > 9000)
+ {
+ bstline[ply] = 0;
+ return(score);
+ }
+
+ if (depth > 0)
+ {
+ if (InChk || PawnThreat[ply-1] || ReCapture) ++depth;
+ }
+ else
+ {
+ if (score >= alpha &&
+ (InChk || PawnThreat[ply-1] || Threat[ply-1])) ++depth;
+ else if (score <= beta && MateThreat) ++depth;
+ }
+
+ if (depth > 0 && hashflag && ply > 1)
+ {
+ ProbeTTable(side,depth,&alpha,&beta,&score);
+ bstline[ply] = PV;
+ bstline[ply+1] = 0;
+ if (beta == -20000) return(score);
+ if (alpha > beta) return(alpha);
+ }
+
+ if (Sdepth == 1) d = 7; else d = 11;
+ if (ply > Sdepth+d || (depth < 1 && score > beta)) return(score);
+
+ if (ply > 1)
+ if (depth > 0) MoveList(side,ply);
+ else CaptureList(side,xside,ply);
+
+ if (TrPnt[ply] == TrPnt[ply+1]) return(score);
+
+ cf = (depth < 1 && ply > Sdepth+1 && !ChkFlag[ply-2] && !slk);
+
+ if (depth > 0) best = -12000; else best = score;
+ if (best > alpha) alpha = best;
+
+ for (pnt = pbst = TrPnt[ply];
+ pnt < TrPnt[ply+1] && best <= beta;
+ pnt++)
+ {
+ if (ply > 1) pick(pnt,TrPnt[ply+1]-1);
+ node = &Tree[pnt];
+ mv = (node->f << 8) + node->t;
+ nxtline[ply+1] = 0;
+
+ if (prune) break;
+ if (ply == 1) UpdateSearchStatus;
+
+ if (!(node->flags & exact))
+ {
+ MakeMove(side,node,&tempb,&tempc,&tempsf,&tempst);
+ CptrFlag[ply] = (node->flags & capture);
+ PawnThreat[ply] = (node->flags & pwnthrt);
+ Tscore[ply] = node->score;
+ PV = node->reply;
+ node->score = -search(xside,ply+1,depth-1,-beta,-alpha,
+ nxtline,&rcnt);
+ if (abs(node->score) > 9000) node->flags |= exact;
+ else if (rcnt == 1) node->score /= 2;
+ if (rcnt >= 2 || GameCnt-Game50 > 99 ||
+ (node->score == 9999-ply && !ChkFlag[ply]))
+ {
+ node->flags |= draw; node->flags |= exact;
+ if (side == computer) node->score = contempt;
+ else node->score = -contempt;
+ }
+ node->reply = nxtline[ply+1];
+ UnmakeMove(side,node,&tempb,&tempc,&tempsf,&tempst);
+ }
+ if (node->score > best && !timeout)
+ {
+ if (depth > 0)
+ if (node->score > alpha && !(node->flags & exact))
+ node->score += depth;
+ best = node->score; pbst = pnt;
+ if (best > alpha) alpha = best;
+ for (j = ply+1; nxtline[j] > 0; j++) bstline[j] = nxtline[j];
+ bstline[j] = 0;
+ bstline[ply] = mv;
+ if (ply == 1)
+ {
+ if (best == alpha)
+ {
+ tmp = Tree[pnt];
+ for (j = pnt-1; j >= 0; j--) Tree[j+1] = Tree[j];
+ Tree[0] = tmp;
+ pbst = 0;
+ }
+ if (Sdepth > 2)
+ if (best > beta) ShowResults(best,bstline,'+');
+ else if (best < alpha) ShowResults(best,bstline,'-');
+ else ShowResults(best,bstline,'&');
+ }
+ }
+ if (NodeCnt > ETnodes) ElapsedTime(0);
+ if (timeout) return(-Tscore[ply-1]);
+ }
+
+ node = &Tree[pbst];
+ mv = (node->f<<8) + node->t;
+ if (hashflag && ply <= Sdepth && *rpt == 0 && best == alpha)
+ PutInTTable(side,best,depth,alpha,beta,mv);
+ if (depth > 0)
+ {
+ j = (node->f<<6) + node->t; if (side == black) j |= 0x1000;
+ if (history[j] < 150) history[j] += 2*depth;
+ if (node->t != (GameList[GameCnt].gmove & 0xFF))
+ if (best <= beta) killr3[ply] = mv;
+ else if (mv != killr1[ply])
+ {
+ killr2[ply] = killr1[ply];
+ killr1[ply] = mv;
+ }
+ if (best > 9000) killr0[ply] = mv; else killr0[ply] = 0;
+ }
+ return(best);
+}
+
+
+evaluate(side,xside,ply,alpha,beta)
+short side,xside,ply,alpha,beta;
+
+/*
+ Compute an estimate of the score by adding the positional score from
+ the previous ply to the material difference. If this score falls
+ inside a window which is 180 points wider than the alpha-beta window
+ (or within a 50 point window during quiescence search) call
+ ScorePosition() to determine a score, otherwise return the estimated
+ score. If one side has only a king and the other either has no pawns
+ or no pieces then the function ScoreLoneKing() is called.
+*/
+
+{
+short s,evflag;
+
+ hung[white] = hung[black] = 0;
+ slk = ((mtl[white] == valueK && (pmtl[black] == 0 || emtl[black] == 0)) ||
+ (mtl[black] == valueK && (pmtl[white] == 0 || emtl[white] == 0)));
+ s = -Pscore[ply-1] + mtl[side] - mtl[xside];
+ s -= INCscore;
+
+ if (slk) evflag = false;
+ else evflag =
+ (ply == 1 || ply < Sdepth ||
+ ((ply == Sdepth+1 || ply == Sdepth+2) &&
+ (s > alpha-xwndw && s < beta+xwndw)) ||
+ (ply > Sdepth+2 && s >= alpha-25 && s <= beta+25));
+
+ if (evflag)