1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-23 07:31:31 +00:00

Initial import, 0.1 + pk 0.2.4-B1

This commit is contained in:
Rodney W. Grimes 1993-06-12 14:49:13 +00:00
commit 9002c02abc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/tcpdump/; revision=2
150 changed files with 40089 additions and 0 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.
======================================================================

View File

@ -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

View File

@ -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.

View File

@ -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

15
gnu/games/chess/Makefile Normal file
View File

@ -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>

View File

@ -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.
======================================================================

View File

@ -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)

View File

@ -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 */

View File

@ -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

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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, 0x1f, 0xb8, 0x3b, 0xf8, 0xff,
0xf8, 0x07, 0xe0, 0x1f, 0xc0, 0x3f, 0xb8, 0x3b, 0xfc, 0x07, 0xe2, 0x07,
0xf0, 0xcf, 0x9f, 0x7f, 0x30, 0x18, 0xfe, 0xf3, 0xcf, 0x0f, 0xf0, 0xe7,
0x3f, 0xfe, 0xf0, 0x1f, 0x7e, 0xfc, 0xdf, 0x0f, 0xf0, 0xf3, 0xff, 0xfc,
0xf1, 0x1f, 0x3f, 0xff, 0x9f, 0x0f, 0xf8, 0xfb, 0xff, 0xfd, 0xf3, 0x9f,
0xbf, 0xff, 0xbf, 0x1f, 0xf8, 0xf9, 0xff, 0xf9, 0xe3, 0x8f, 0xdf, 0xff,
0x3f, 0x1f, 0xf8, 0xfd, 0xff, 0xf3, 0xef, 0xcf, 0xcf, 0xff, 0x7f, 0x1f,
0xf8, 0xfd, 0xff, 0xe7, 0xef, 0xef, 0xef, 0xff, 0x7f, 0x1f, 0xfc, 0xfd,
0xff, 0xcf, 0xff, 0xff, 0xe7, 0x3f, 0x7c, 0x3f, 0xfc, 0x3c, 0xfc, 0xdf,
0xff, 0xfe, 0xf3, 0x3d, 0x7c, 0x3f, 0xfc, 0x3e, 0xfc, 0x9e, 0x7f, 0xfc,
0xf9, 0x39, 0x7c, 0x3f, 0xfc, 0x3e, 0x7c, 0xbe, 0x3f, 0xf8, 0xf9, 0x3b,
0x7c, 0x3f, 0xfc, 0x3e, 0x78, 0x3f, 0x7f, 0xfc, 0xfc, 0x3b, 0x7f, 0x3f,
0xfc, 0xfe, 0x7b, 0x7f, 0xff, 0xfe, 0xfe, 0x9b, 0x7f, 0x3f, 0xf8, 0xfe,
0xbb, 0x7f, 0xfe, 0x7f, 0xfe, 0xdb, 0x79, 0x1f, 0xf8, 0xfe, 0xb3, 0xff,
0xfe, 0x7f, 0xff, 0xcb, 0x7c, 0x1f, 0xf8, 0x9e, 0xb7, 0xff, 0xfe, 0x7f,
0xff, 0x2b, 0x3e, 0x1f, 0xf8, 0x3e, 0xa6, 0xff, 0xfc, 0x7f, 0xff, 0xa3,
0xbf, 0x1f, 0xf8, 0xfe, 0xa8, 0xff, 0xfd, 0x3e, 0xff, 0xd3, 0xbf, 0x1f,
0xf8, 0xfd, 0x83, 0xff, 0x7d, 0xbc, 0xff, 0xc3, 0xbf, 0x1f, 0xf0, 0xfd,
0x8f, 0xff, 0x39, 0xb8, 0xff, 0xe3, 0xbf, 0x1f, 0xf0, 0xfd, 0x9f, 0xff,
0x7b, 0xbc, 0xff, 0xf1, 0x9f, 0x0f, 0xf0, 0xf9, 0xbf, 0xff, 0xfb, 0xbe,
0xff, 0xfd, 0xdf, 0x0f, 0xf0, 0xfb, 0x3f, 0xff, 0xf3, 0x9f, 0xff, 0xfd,
0xdf, 0x0f, 0xf0, 0xf3, 0x7f, 0xff, 0xf7, 0xdf, 0xff, 0xfc, 0xdf, 0x0f,
0xe0, 0xf7, 0x7f, 0xfe, 0xf7, 0xdf, 0xff, 0xfe, 0xdf, 0x07, 0xe0, 0xf7,
0xff, 0xfe, 0xf7, 0xdf, 0x7f, 0xfe, 0xcf, 0x07, 0xe0, 0xe7, 0xff, 0xfe,
0xf7, 0xdf, 0x7f, 0xff, 0xef, 0x07, 0xc0, 0xef, 0xff, 0xfc, 0xef, 0xee,
0x7f, 0xff, 0xe7, 0x03, 0xc0, 0xcf, 0xff, 0xfd, 0x6f, 0xec, 0x3f, 0xff,
0xf7, 0x03, 0x80, 0xdf, 0xff, 0xf9, 0xef, 0xee, 0xbf, 0xff, 0xf3, 0x01,
0x80, 0x9f, 0xff, 0xfb, 0xef, 0xef, 0x9f, 0xff, 0xfb, 0x01, 0x00, 0xbf,
0xff, 0xfb, 0xef, 0xef, 0xdf, 0xff, 0xf9, 0x00, 0x00, 0x7e, 0xff, 0xf3,
0xef, 0xef, 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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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, 0x3f, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xef,
0x07, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x7f, 0xf3, 0xff, 0xcf, 0x7f, 0x00,
0xe0, 0xff, 0xff, 0xff, 0x1f, 0xfd, 0xff, 0xdf, 0x07, 0x00, 0xe0, 0xff,
0xff, 0xff, 0x83, 0xff, 0xf3, 0x9f, 0xff, 0x00, 0xf0, 0xff, 0xff, 0x7f,
0x80, 0xff, 0xf9, 0xbf, 0x0f, 0x00, 0xf0, 0xff, 0xff, 0x00, 0x80, 0x7f,
0xfc, 0x7f, 0xff, 0x01, 0xf8, 0x3f, 0x7f, 0x00, 0x80, 0x81, 0xff, 0x7f,
0x1e, 0x00, 0x18, 0x9f, 0x3f, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0xfe, 0x07,
0x98, 0x8f, 0x1f, 0x00, 0xc0, 0xff, 0xcf, 0x7f, 0x3e, 0x00, 0xf8, 0x87,
0x0f, 0x00, 0xe0, 0xff, 0xe3, 0xff, 0xfe, 0x07, 0xf0, 0xc3, 0x07, 0x00,
0xf0, 0x1f, 0xfc, 0xff, 0x3c, 0x00, 0xf0, 0xe1, 0x03, 0x00, 0xf0, 0xc0,
0xff, 0xff, 0xfc, 0x0f, 0x60, 0xe0, 0x01, 0x00, 0xf8, 0xff, 0xff, 0xff,
0x7c, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xfc, 0x0f,
0x00, 0x70, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x7c, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xf9, 0x0f, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff,
0xff, 0xff, 0xf9, 0x0f, 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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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,
0xc0, 0x07, 0xe0, 0x07, 0xe0, 0x03, 0x00, 0x1f, 0x3c, 0x00, 0xc0, 0x07,
0xe0, 0x07, 0xe0, 0x03, 0x00, 0x1f, 0x70, 0x00, 0xc0, 0x0f, 0xe0, 0x07,
0xf0, 0x03, 0x00, 0x0e, 0x60, 0x00, 0xc0, 0x0f, 0xe0, 0x07, 0xf0, 0x03,
0x00, 0x03, 0xe0, 0x00, 0xc0, 0x0f, 0xf0, 0x0f, 0xf0, 0x03, 0x80, 0x03,
0xc0, 0x01, 0xc0, 0x1f, 0xf0, 0x0f, 0xf8, 0x03, 0x80, 0x01, 0xc0, 0x01,
0xc0, 0x1f, 0xf0, 0x0f, 0xf8, 0x03, 0xc0, 0x01, 0xc0, 0x03, 0xc0, 0x1f,
0xf0, 0x0f, 0xf8, 0x03, 0xe0, 0x01, 0xc0, 0x07, 0xc0, 0x1f, 0xf0, 0x0f,
0xf8, 0x03, 0xe0, 0x01, 0xc0, 0x07, 0xc0, 0x3f, 0xf0, 0x0f, 0xfc, 0x03,
0xf0, 0x01, 0xc0, 0x0f, 0xc0, 0x3f, 0xf0, 0x0f, 0xfc, 0x03, 0xf8, 0x01,
0x80, 0x1f, 0xc0, 0x3f, 0xf0, 0x0f, 0xfc, 0x03, 0xf8, 0x01, 0x80, 0x1f,
0xc0, 0x7f, 0xf0, 0x0f, 0xfe, 0x03, 0xfc, 0x01, 0x80, 0x3f, 0xc0, 0x7f,
0xf8, 0x1f, 0xfe, 0x03, 0xfc, 0x00, 0x80, 0x3f, 0xc0, 0x7f, 0xf8, 0x1f,
0xfe, 0x03, 0xfe, 0x00, 0x80, 0x7f, 0xc0, 0xff, 0xf8, 0x1f, 0xff, 0x03,
0xff, 0x00, 0x80, 0xff, 0xc0, 0xff, 0xf8, 0x1f, 0xff, 0x03, 0xff, 0x00,
0x00, 0xff, 0xc0, 0xff, 0xf8, 0x1f, 0xff, 0x83, 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};

View File

@ -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,
0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0xe0, 0x07, 0x80, 0x07,
0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0xe0, 0x07, 0x80, 0x07, 0x00, 0x00,
0x00, 0x00, 0xe0, 0x03, 0xf0, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00,
0xe0, 0x07, 0xf0, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07,
0xf0, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x7e, 0x00, 0xe0, 0x07, 0xf0, 0x0f,
0xe0, 0x07, 0x00, 0x00, 0x7f, 0x00, 0xe0, 0x0f, 0xf0, 0x0f, 0xe0, 0x07,
0x00, 0x1f, 0x7f, 0x00, 0xe0, 0x0f, 0xf0, 0x0f, 0xe0, 0x07, 0x80, 0x3f,
0x7f, 0x00, 0xe0, 0x0f, 0xf0, 0x0f, 0xf0, 0x07, 0x80, 0x3f, 0x7f, 0x00,
0xe0, 0x0f, 0xf0, 0x0f, 0xf0, 0x07, 0x80, 0x3f, 0xff, 0x00, 0xe0, 0x1f,
0xf0, 0x0f, 0xf0, 0x07, 0x80, 0x3f, 0xfe, 0x00, 0xe0, 0x1f, 0xf0, 0x0f,
0xf8, 0x07, 0x80, 0x1f, 0xfc, 0x01, 0xe0, 0x1f, 0xf8, 0x1f, 0xf8, 0x07,
0x80, 0x1f, 0xf0, 0x03, 0xe0, 0x3f, 0xf8, 0x1f, 0xf8, 0x07, 0xc0, 0x0f,
0xf0, 0x07, 0xe0, 0x3f, 0xf8, 0x1f, 0xfc, 0x07, 0xe0, 0x03, 0xe0, 0x07,
0xe0, 0x3f, 0xf8, 0x1f, 0xfc, 0x07, 0xf0, 0x03, 0xe0, 0x0f, 0xe0, 0x7f,
0xf8, 0x1f, 0xfc, 0x07, 0xf0, 0x03, 0xe0, 0x1f, 0xe0, 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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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);
}

View File

@ -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,
0xff, 0x01, 0xf8, 0xff, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0x01,
0xf8, 0xff, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0x01, 0xff, 0xff,
0x07, 0xfc, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0xfd, 0x01, 0x00, 0xfc, 0xfd,
0x1f, 0x00, 0x00, 0xc0, 0xff, 0x07, 0xfc, 0xff, 0x01, 0xff, 0x1f, 0x00,
0x00, 0xc0, 0x1f, 0xf0, 0xff, 0xff, 0x7f, 0xc0, 0x1f, 0x00, 0x00, 0x40,
0xc0, 0xff, 0x07, 0x00, 0xff, 0x1f, 0x10, 0x00, 0x00, 0xc0, 0xff, 0x1f,
0xf0, 0x7f, 0xc0, 0xff, 0x1f, 0x00, 0x00, 0xc0, 0x7f, 0xc0, 0xfd, 0xff,
0x1d, 0xf0, 0x1f, 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, 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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

File diff suppressed because it is too large Load Diff

View File

@ -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 */

File diff suppressed because it is too large Load Diff

View File

@ -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 */

View File

@ -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};

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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.

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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};

View File

@ -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

View File

@ -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();

View File

@ -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, 0x82,
0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 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, 0x82,
0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 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, 0x82,
0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 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, 0x82,
0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82, 0x41, 0x0f, 0x0f, 0x0f, 0x0f, 0x82,
0x41, 0x00, 0x00, 0x00, 0x00, 0x82, 0xc1, 0xff, 0xff, 0xff, 0xff, 0x83,
0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 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};

View File

@ -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};

File diff suppressed because it is too large Load Diff

2307
gnu/games/chess/gnuchess.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,97 @@
/*
This file contains code for CHESS.
Copyright (C) 1986, 1987, 1988 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.
*/
/* Header file for GNU CHESS */
#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 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 maxdepth 30
#define true 1
#define false 0
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;
};
extern char mvstr1[5],mvstr2[5];
extern struct leaf Tree[2000],*root;
extern short TrPnt[maxdepth],board[64],color[64];
extern short row[64],column[64],locn[8][8];
extern short atak[2][64],PawnCnt[2][8];
extern short castld[2],kingmoved[2];
extern short c1,c2,*atk1,*atk2,*PC1,*PC2;
extern short mate,post,opponent,computer,Sdepth,Awindow,Bwindow,dither;
extern long ResponseTime,ExtraTime,Level,et,et0,time0,cputimer,ft;
extern long NodeCnt,evrate,ETnodes,EvalNodes,HashCnt;
extern short quit,reverse,bothsides,hashflag,InChk,player,force,easy,beep,meter;
extern short timeout,xwndw;
extern struct GameRec GameList[240];
extern short GameCnt,Game50,epsquare,lpost,rcptr,contempt;
extern short MaxSearchDepth;
extern struct BookEntry *Book;
extern struct TimeControlRec TimeControl;
extern short TCflag,TCmoves,TCminutes,OperatorTime;
extern short otherside[3];
extern short Stboard[64];
extern short Stcolor[64];
extern unsigned short hint,PrVar[maxdepth];
#define HZ 60

357
gnu/games/chess/move.c Normal file
View File

@ -0,0 +1,357 @@
/* move generator hes@log-sv.se 890318
Modified: 890606 NEWMOVE Levels 1-6 for easier debugging */
#include "move.h"
#include "gnuchess.h"
short distdata[64][64];
short taxidata[64][64];
void Initialize_dist() {
register short a,b,d,di;
/* init taxi and dist data */
for(a=0;a<64;a++)
for(b=0;b<64;b++) {
d = abs(column[a]-column[b]);
di = abs(row[a]-row[b]);
taxidata[a][b] = d + di;
distdata[a][b] = (d > di ? d : di);
};
}
#if (NEWMOVE > 1)
struct sqdata posdata[3][8][64][64];
static short direc[8][8] = {
0, 0, 0, 0, 0, 0, 0, 0, /* no_piece = 0 */
-10,-11, -9, 0, 0, 0, 0, 0, /* wpawn = 1 */
-21,-19,-12, -8, 21, 19, 12, 8, /* knight = 2 */
-11, -9, 11, 9, 0, 0, 0, 0, /* bishop = 3 */
-10, -1, 10, 1, 0, 0, 0, 0, /* rook = 4 */
-11, -9,-10, -1, 11, 9, 10, 1, /* queen = 5 */
-11, -9,-10, -1, 11, 9, 10, 1, /* king = 6 */
0, 0, 0, 0, 0, 0, 0, 0};/* no_piece = 7 */
static short dc[3] = {-1,1,0};
static short max_steps [8] = {0,2,1,7,7,7,1,0};
static short unmap[120] = {
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1, 0, 1, 2, 3, 4, 5, 6, 7,-1,
-1, 8, 9,10,11,12,13,14,15,-1,
-1,16,17,18,19,20,21,22,23,-1,
-1,24,25,26,27,28,29,30,31,-1,
-1,32,33,34,35,36,37,38,39,-1,
-1,40,41,42,43,44,45,46,47,-1,
-1,48,49,50,51,52,53,54,55,-1,
-1,56,57,58,59,60,61,62,63,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
void Initialize_moves() {
short c,ptyp,po,p0,d,di,s;
struct sqdata *p;
short dest[8][8];
short steps[8];
short sorted[8];
/* init posdata */
for(c=0;c<3;c++)
for(ptyp=0;ptyp<8;ptyp++)
for(po=0;po<64;po++)
for(p0=0;p0<64;p0++) {
posdata[c][ptyp][po][p0].nextpos = po;
posdata[c][ptyp][po][p0].nextdir = po;
};
/* dest is a function of dir and step */
for(c=0;c<2;c++)
for(ptyp=1;ptyp<7;ptyp++)
for(po=21;po<99;po++)
if (unmap[po] >= 0) {
p = posdata[c][ptyp][unmap[po]];
for(d=0;d<8;d++) {
dest[d][0] = unmap[po];
if (dc[c]*direc[ptyp][d] != 0) {
p0=po;
for(s=0;s<max_steps[ptyp];s++) {
p0 = p0 + dc[c]*direc[ptyp][d];
/* break if (off board) or
(pawns move two steps from home square) */
if (unmap[p0] < 0 ||
(ptyp == pawn && s>0 && (d>0 || Stboard[unmap[po]] != ptyp)))
break;
else
dest[d][s] = unmap[p0];
}
}
else s=0;
/* sort dest in number of steps order */
steps[d] = s;
for(di=d;di>0;di--)
if (steps[sorted[di-1]] < s)
sorted[di] = sorted[di-1];
else
break;
sorted[di] = d;
}
/* update posdata, pawns have two threads (capture and no capture) */
p0=unmap[po];
if (ptyp == pawn) {
for(s=0;s<steps[0];s++) {
p[p0].nextpos = dest[0][s];
p0 = dest[0][s];
}
p0=unmap[po];
for(d=1;d<3;d++) {
p[p0].nextdir = dest[d][0];
p0 = dest[d][0];
}
}
else {
p[p0].nextdir = dest[sorted[0]][0];
for(d=0;d<8;d++)
for(s=0;s<steps[sorted[d]];s++) {
p[p0].nextpos = dest[sorted[d]][s];
p0 = dest[sorted[d]][s];
if (d < 7)
p[p0].nextdir = dest[sorted[d+1]][0];
/* else is already initialised */
}
}
#ifdef DEBUG
printf("Ptyp:%d Position:%d\n{",ptyp,unmap[po]);
for(p0=0;p0<63;p0++) printf("%d,",p[p0].nextpos);
printf("%d};\n",p[63].nextpos);
for(p0=0;p0<63;p0++) printf("%d,",p[p0].nextdir);
printf("%d};\n",p[63].nextdir);
#endif DEBUG
}
}
#endif
#if (NEWMOVE > 2)
int SqAtakd(sq,side)
short sq,side;
/*
See if any piece with color 'side' ataks sq. First check pawns
Then Queen, Bishop, Rook and King and last Knight.
*/
{
register short u;
register struct sqdata *p;
p = posdata[1-side][pawn][sq];
u = p[sq].nextdir; /* follow captures thread */
while (u != sq) {
if (board[u] == pawn && color[u] == side) return(true);
u = p[u].nextdir;
}
/* king capture */
if (distance(sq,PieceList[side][0]) == 1) return(true);
/* try a queen bishop capture */
p = posdata[side][bishop][sq];
u = p[sq].nextpos;
while (u != sq) {
if (color[u] == neutral) {
u = p[u].nextpos;
}
else {
if (color[u] == side &&
(board[u] == queen || board[u] == bishop))
return(true);
u = p[u].nextdir;
}
}
/* try a queen rook capture */
p = posdata[side][rook][sq];
u = p[sq].nextpos;
while (u != sq) {
if (color[u] == neutral) {
u = p[u].nextpos;
}
else {
if (color[u] == side &&
(board[u] == queen || board[u] == rook))
return(true);
u = p[u].nextdir;
}
}
/* try a knight capture */
p = posdata[side][knight][sq];
u = p[sq].nextpos;
while (u != sq) {
if (color[u] == neutral) {
u = p[u].nextpos;
}
else {
if (color[u] == side && board[u] == knight) return(true);
u = p[u].nextdir;
}
}
return(false);
}
#endif
#if (NEWMOVE > 3)
BRscan(sq,s,mob)
short sq,*s,*mob;
/*
Find Bishop and Rook mobility, XRAY attacks, and pins. Increment the
hung[] array if a pin is found.
*/
{
register short u,piece,pin;
register struct sqdata *p;
short *Kf;
Kf = Kfield[c1];
*mob = 0;
piece = board[sq];
p = posdata[color[sq]][piece][sq];
u = p[sq].nextpos;
pin = -1; /* start new direction */
while (u != sq) {
*s += Kf[u];
if (color[u] == neutral) {
(*mob)++;
if (p[u].nextpos == p[u].nextdir) pin = -1; /* oops new direction */
u = p[u].nextpos;
}
else if (pin < 0) {
if (board[u] == pawn || board[u] == king)
u = p[u].nextdir;
else {
if (p[u].nextpos != p[u].nextdir)
pin = u; /* not on the edge and on to find a pin */
u = p[u].nextpos;
}
}
else if (color[u] == c2 && (board[u] > piece || atk2[u] == 0))
{
if (color[pin] == c2)
{
*s += PINVAL;
if (atk2[pin] == 0 ||
atk1[pin] > control[board[pin]]+1)
++hung[c2];
}
else *s += XRAY;
pin = -1; /* new direction */
u = p[u].nextdir;
}
else {
pin = -1; /* new direction */
u = p[u].nextdir;
}
}
}
#endif
#if (NEWMOVE >= 5)
CaptureList(side,xside,ply)
short side,xside,ply;
{
register short u,sq;
register struct sqdata *p;
short i,piece,*PL;
struct leaf *node;
TrPnt[ply+1] = TrPnt[ply];
node = &Tree[TrPnt[ply]];
PL = PieceList[side];
for (i = 0; i <= PieceCnt[side]; i++)
{
sq = PL[i];
piece = board[sq];
p = posdata[side][piece][sq];
if (piece == pawn) {
u = p[sq].nextdir; /* follow captures thread */
while (u != sq) {
if (color[u] == xside) {
node->f = sq; node->t = u;
node->flags = capture;
if (u < 8 || u > 55)
{
node->flags |= promote;
node->score = valueQ;
}
else
node->score = value[board[u]] + svalue[board[u]] - piece;
++node;
++TrPnt[ply+1];
}
u = p[u].nextdir;
}
}
else {
u = p[sq].nextpos;
while (u != sq) {
if (color[u] == neutral)
u = p[u].nextpos;
else {
if (color[u] == xside) {
node->f = sq; node->t = u;
node->flags = capture;
node->score = value[board[u]] + svalue[board[u]] - piece;
++node;
++TrPnt[ply+1];
}
u = p[u].nextdir;
}
}
}
}
}
#endif
#if (NEWMOVE > 5)
GenMoves(ply,sq,side,xside)
short ply,sq,side,xside;
/*
Generate moves for a piece. The moves are taken from the
precalulated array posdata. If the board is free, next move
is choosen from nextpos else from nextdir.
*/
{
register short u,piece;
register struct sqdata *p;
piece = board[sq];
p = posdata[side][piece][sq];
if (piece == pawn) {
u = p[sq].nextdir; /* follow captures thread */
while (u != sq) {
if (color[u] == xside) LinkMove(ply,sq,u,xside);
u = p[u].nextdir;
}
u = p[sq].nextpos; /* and follow no captures thread */
while (u != sq) {
if (color[u] == neutral && (u != sq+16 || color[u-8] == neutral)
&& (u != sq-16 || color[u+8] == neutral)) {
LinkMove(ply,sq,u,xside);
}
u = p[u].nextpos;
}
}
else {
u = p[sq].nextpos;
while (u != sq) {
if (color[u] == neutral) {
LinkMove(ply,sq,u,xside);
u = p[u].nextpos;
}
else {
if (color[u] == xside) LinkMove(ply,sq,u,xside);
u = p[u].nextdir;
}
}
}
}
#endif

81
gnu/games/chess/move.h Normal file
View File

@ -0,0 +1,81 @@
/* header file for move generator hes 890318
Modified: 890510 minor bug fixed in Newataks
890606 NEWMOVE levels 1-6 */
#if (NEWMOVE >= 1)
extern short distdata[64][64];
extern short taxidata[64][64];
#define taxicab(a,b) taxidata[a][b]
#define distance(a,b) distdata[a][b]
extern void Initialize_dist();
#endif
#if (NEWMOVE >= 2)
struct sqdata {
short nextpos;
short nextdir;
};
extern struct sqdata posdata[3][8][64][64];
extern void Initialize_moves();
#define ataks(side,a)\
{\
register short u,c,sq;\
register struct sqdata *p;\
short i,piece,*PL;\
\
for (u = 64; u; a[--u] = 0); \
PL = PieceList[side];\
for (i = 0; i <= PieceCnt[side]; i++)\
{\
sq = PL[i];\
piece = board[sq];\
c = control[piece];\
p = posdata[side][piece][sq];\
if (piece == pawn) {\
u = p[sq].nextdir; /* follow captures thread */\
while (u != sq) {\
a[u] = ++a[u] | c;\
u = p[u].nextdir;\
}\
}\
else {\
u = p[sq].nextpos;\
while (u != sq) {\
a[u] = ++a[u] | c;\
if (color[u] == neutral)\
u = p[u].nextpos;\
else\
u = p[u].nextdir;\
}\
}\
}\
}
#endif
#if (NEWMOVE >= 3)
extern short PieceList[2][16];
extern int Sqatakd();
#endif
#if (NEWMOVE > 3)
extern short Kfield[2][64],PINVAL,control[7],hung[2],XRAY;
extern BRscan();
#endif
#if (NEWMOVE > 4)
#define valueQ 1100
extern short PieceCnt[2],value[7],svalue[64];
extern CaptureList();
#endif
#if (NEWMOVE > 5)
extern GenMoves();
#endif

791
gnu/games/chess/nondsp.c Normal file
View File

@ -0,0 +1,791 @@
/*
UNIX & MSDOS NON-DISPLAY, AND CHESSTOOL interface 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 <dos.h>
#include <stdlib.h>
#include <time.h>
#else
#include <sys/param.h>
#include <sys/times.h>
#include <sys/file.h>
struct tms tmbuf1,tmbuf2;
int TerminateSearch(),Die();
#endif MSDOS
#include "gnuchess.h"
#ifdef NEWMOVE
#include "move.h"
#endif
#define printz printf
#define scanz scanf
int mycnt1,mycnt2;
Initialize()
{
mycnt1 = mycnt2 = 0;
#ifndef MSDOS
#endif
#ifdef CHESSTOOL
setlinebuf(stdout);
/*
setvbuf(stdout,NULL,_IOLBF,BUFSIZ);
*/
printf("Chess\n");
if (Level == 0 && !TCflag) Level = 15;
#endif CHESSTOOL
}
ExitChess()
{
ListGame();
exit(0);
}
#ifndef MSDOS
Die()
{
char s[80];
printz("Abort? ");
scanz("%s",s);
if (strcmp(s,"yes") == 0) ExitChess();
}
TerminateSearch()
{
timeout = true;
bothsides = false;
}
#endif MSDOS
InputCommand()
/*
Process the users command. If easy mode is OFF (the computer is
thinking on opponents time) and the program is out of book, then make
the 'hint' move on the board and call SelectMove() to find a response.
The user terminates the search by entering ^C (quit siqnal) before
entering a command. If the opponent does not make the hint move, then
set Sdepth to zero.
*/
{
int i;
short ok,tmp;
long cnt,rate,t1,t2;
unsigned short mv;
char s[80];
ok = quit = false;
player = opponent;
ft = 0;
if (hint > 0 && !easy && Book == NULL)
{
fflush(stdout);
time0 = time((long *)0);
algbr(hint>>8,hint & 0xFF,false);
strcpy(s,mvstr1);
tmp = epsquare;
if (VerifyMove(s,1,&mv))
{
SelectMove(computer,2);
VerifyMove(mvstr1,2,&mv);
if (Sdepth > 0) Sdepth--;
}
ft = time((long *)0) - time0;
epsquare = tmp;
}
#ifndef MSDOS
#endif
while (!(ok || quit))
{
PromptForMove();
i = scanz("%s",s);
if (i == EOF || s[0] == 0) ExitChess();
player = opponent;
ok = VerifyMove(s,0,&mv);
if (ok && mv != hint)
{
Sdepth = 0;
ft = 0;
}
if (strcmp(s,"bd") == 0)
{
ClrScreen();
UpdateDisplay(0,0,1,0);
}
if (strcmp(s,"quit") == 0) quit = true;
if (strcmp(s,"post") == 0) post = !post;
if (strcmp(s,"set") == 0) EditBoard();
if (strcmp(s,"go") == 0) ok = true;
if (strcmp(s,"help") == 0) help();
if (strcmp(s,"force") == 0) force = !force;
if (strcmp(s,"book") == 0) Book = NULL;
if (strcmp(s,"new") == 0) NewGame();
if (strcmp(s,"list") == 0) ListGame();
if (strcmp(s,"level") == 0) SelectLevel();
if (strcmp(s,"hash") == 0) hashflag = !hashflag;
if (strcmp(s,"beep") == 0) beep = !beep;
if (strcmp(s,"Awindow") == 0) ChangeAlphaWindow();
if (strcmp(s,"Bwindow") == 0) ChangeBetaWindow();
if (strcmp(s,"rcptr") == 0) rcptr = !rcptr;
if (strcmp(s,"hint") == 0) GiveHint();
if (strcmp(s,"zero") == 0) ZeroTTable();
if (strcmp(s,"both") == 0)
{
bothsides = !bothsides;
Sdepth = 0;
SelectMove(opponent,1);
ok = true;
}
if (strcmp(s,"reverse") == 0)
{
reverse = !reverse;
ClrScreen();
UpdateDisplay(0,0,1,0);
}
if (strcmp(s,"switch") == 0)
{
computer = otherside[computer];
opponent = otherside[opponent];
force = false;
Sdepth = 0;
ok = true;
}
if (strcmp(s,"white") == 0)
{
computer = white; opponent = black;
ok = true; force = false;
Sdepth = 0;
}
if (strcmp(s,"black") == 0)
{
computer = black; opponent = white;
ok = true; force = false;
Sdepth = 0;
}
if (strcmp(s,"undo") == 0 && GameCnt >= 0) Undo();
if (strcmp(s,"remove") == 0 && GameCnt >= 1)
{
Undo(); Undo();
}
if (strcmp(s,"get") == 0) GetGame();
if (strcmp(s,"save") == 0) SaveGame();
if (strcmp(s,"depth") == 0) ChangeSearchDepth();
if (strcmp(s,"random") == 0) dither = 6;
if (strcmp(s,"easy") == 0) easy = !easy;
if (strcmp(s,"contempt") == 0) SetContempt();
if (strcmp(s,"xwndw") == 0) ChangeXwindow();
if (strcmp(s,"test") == 0)
{
t1 = time(0);
cnt = 0;
for (i = 0; i < 10000; i++)
{
MoveList(opponent,2);
cnt += TrPnt[3] - TrPnt[2];
}
t2 = time(0);
rate = cnt / (t2-t1);
printz("cnt= %ld rate= %ld\n",cnt,rate);
}
}
ElapsedTime(1);
if (force)
{
computer = opponent; opponent = otherside[computer];
}
#ifndef MSDOS
(void) times(&tmbuf1);
#ifdef CHESSTOOL
printf("%d. %s\n",++mycnt2,s);
#endif CHESSTOOL
#endif MSDOS
}
help()
{
ClrScreen();
printz("CHESS command summary\n");
printz("g1f3 move from g1 to f3\n");
printz("nf3 move knight to f3\n");
printz("o-o castle king side\n");
printz("o-o-o castle queen side\n");
printz("set edit board\n");
printz("switch sides with computer\n");
printz("white computer plays white\n");
printz("black computer plays black\n");
printz("reverse board display\n");
printz("both computer match\n");
printz("random randomize play\n");
printz("undo undo last move\n");
printz("time change level\n");
printz("depth set search depth\n");
printz("post principle variation\n");
printz("hint suggest a move\n");
printz("bd redraw board\n");
printz("clock set time control\n");
printz("force enter game moves\n");
printz("list game to chess.lst\n");
printz("save game to file\n");
printz("get game from file\n");
printz("new start new game\n");
printz("quit exit CHESS\n");
printz("Computer: ");
if (computer == white) printz("WHITE\n"); else printz("BLACK\n");
printz("Opponent: ");
if (opponent == white) printz("WHITE\n"); else printz("BLACK\n");
printz("Response time: %ld",Level," sec.\n");
printz("Easy mode: ");
if (easy) printz("ON\n"); else printz("OFF\n");
printz("Depth: %d\n",MaxSearchDepth);
printz("Random: ");
if (dither) printz("ON\n"); else printz("OFF\n");
printz("Transposition table: ");
if (hashflag) printz("ON\n"); else printz("OFF\n");
UpdateDisplay(0,0,1,0);
}
EditBoard()
/*
Set up a board position. Pieces are entered by typing the piece
followed by the location. For example, Nf3 will place a knight on
square f3.
*/
{
short a,r,c,sq;
char s[80];
ClrScreen();
UpdateDisplay(0,0,1,0);
printz(". exit to main\n");
printz("# clear board\n");
printz("enter piece & location: \n");
a = white;
do
{
scanz("%s",s);
if (s[0] == '#')
{
for (sq = 0; sq < 64; sq++)
{
board[sq] = no_piece; color[sq] = neutral;
}
UpdateDisplay(0,0,1,0);
}
if (s[0] == 'c' || s[0] == 'C') a = otherside[a];
c = s[1]-'a'; r = s[2]-'1';
if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
{
sq = locn[r][c];
color[sq] = a;
if (s[0] == 'p') board[sq] = pawn;
else if (s[0] == 'n') board[sq] = knight;
else if (s[0] == 'b') board[sq] = bishop;
else if (s[0] == 'r') board[sq] = rook;
else if (s[0] == 'q') board[sq] = queen;
else if (s[0] == 'k') board[sq] = king;
else { board[sq] = no_piece; color[sq] = neutral; }
}
}
while (s[0] != '.');
if (board[4] != king) kingmoved[white] = 10;
if (board[60] != king) kingmoved[black] = 10;
GameCnt = -1; Game50 = 0; Sdepth = 0;
InitializeStats();
ClrScreen();
UpdateDisplay(0,0,1,0);
}
ShowDepth(ch)
char ch;
{
}
ShowResults(score,bstline,ch)
short score;
unsigned short bstline[];
char ch;
{
#ifndef CHESSTOOL
register int i;
printz("%2d%c %5d %4ld %7ld ",Sdepth,ch,score,et,NodeCnt);
for (i = 1; bstline[i] > 0; i++)
{
algbr((short)(bstline[i] >> 8),(short)(bstline[i] & 0xFF),false);
if (i == 9 || i == 17) printz("\n ");
printz("%5s ",mvstr1);
}
printz("\n");
#endif
}
SearchStartStuff(side)
short side;
{
#ifndef MSDOS
#endif
#ifndef CHESSTOOL
printz("\nMove# %d Target= %ld Clock: %ld\n",
TCmoves-TimeControl.moves[side]+1,
ResponseTime,TimeControl.clock[side]);
#endif
}
OutputMove()
{
#ifdef CHESSTOOL
printz("%d. ... %s\n",++mycnt1,mvstr1);
if (root->flags & draw)
{
printz("Draw\n");
ListGame();
exit(0);
}
if (root->score == -9999)
{
if (opponent == white) printz("White\n"); else printz("Black\n");
ListGame();
exit(0);
}
if (root->score == 9998)
{
if (computer == white) printz("White\n"); else printz("Black\n");
ListGame();
exit(0);
}
#else
printz("Nodes= %ld Eval= %ld Hash= %ld Rate= %ld ",
NodeCnt,EvalNodes,HashCnt,evrate);
printz("CPU= %.2ld:%.2ld.%.2ld\n\n",
cputimer/6000,(cputimer % 6000)/100,cputimer % 100);
if (root->flags & epmask) UpdateDisplay(0,0,1,0);
else UpdateDisplay(root->f,root->t,0,root->flags & cstlmask);
printz("My move is: %s\n\n",mvstr1);
if (beep) printz("%c",7);
if (root->flags & draw) printz("Draw game!\n");
else if (root->score == -9999) printz("opponent mates!\n");
else if (root->score == 9998) printz("computer mates!\n");
else if (root->score < -9000) printz("opponent will soon mate!\n");
else if (root->score > 9000) printz("computer will soon mate!\n");
#endif CHESSTOOL
}
ElapsedTime(iop)
short iop;
/*
Determine the time that has passed since the search was started. If
the elapsed time exceeds the target (ResponseTime+ExtraTime) then set
timeout to true which will terminate the search.
*/
{
et = time((long *)0) - time0;
if (et < 0) et = 0;
ETnodes += 50;
if (et > et0 || iop == 1)
{
if (et > ResponseTime+ExtraTime && Sdepth > 1) timeout = true;
et0 = et;
if (iop == 1)
{
time0 = time((long *)0); et0 = 0;
}
#ifdef MSDOS
cputimer = 100*et;
if (et > 0) evrate = NodeCnt/(et+ft); else evrate = 0;
if (kbhit() && Sdepth > 1)
{
timeout = true;
bothsides = false;
}
#else
(void) times(&tmbuf2);
cputimer = 100*(tmbuf2.tms_utime - tmbuf1.tms_utime) / HZ;
if (cputimer > 0) evrate = (100*NodeCnt)/(cputimer+100*ft);
else evrate = 0;
#endif MSDOS
ETnodes = NodeCnt + 50;
}
}
SetTimeControl()
{
if (TCflag)
{
TimeControl.moves[white] = TimeControl.moves[black] = TCmoves;
TimeControl.clock[white] = TimeControl.clock[black] = 60*(long)TCminutes;
}
else
{
TimeControl.moves[white] = TimeControl.moves[black] = 0;
TimeControl.clock[white] = TimeControl.clock[black] = 0;
Level = 60*(long)TCminutes;
}
et = 0;
ElapsedTime(1);
}
ClrScreen()
{
#ifndef CHESSTOOL
printz("\n");
#endif
}
UpdateDisplay(f,t,flag,iscastle)
short f,t,flag,iscastle;
{
#ifndef CHESSTOOL
short r,c,l;
if (flag)
{
printz("\n");
for (r = 7; r >= 0; r--)
{
for (c = 0; c <= 7; c++)
{
if (reverse) l = locn[7-r][7-c]; else l = locn[r][c];
if (color[l] == neutral) printz(" -");
else if (color[l] == white) printz(" %c",qxx[board[l]]);
else printz(" %c",pxx[board[l]]);
}
printz("\n");
}
printz("\n");
}
#endif CHESSTOOL
}
GetOpenings()
/*
Read in the Opening Book file and parse the algebraic notation for a
move into an unsigned integer format indicating the from and to
square. Create a linked list of opening lines of play, with
entry->next pointing to the next line and entry->move pointing to a
chunk of memory containing the moves. More Opening lines of up to 256
half moves may be added to gnuchess.book.
*/
{
FILE *fd;
int c,i,j,side;
char buffr[2048];
struct BookEntry *entry;
unsigned short mv,*mp,tmp[100];
if ((fd = fopen("gnuchess.book","r")) != NULL)
{
/*
setvbuf(fd,buffr,_IOFBF,2048);
*/
Book = NULL;
i = 0; side = white;
while ((c = parse(fd,&mv,side)) >= 0)
if (c == 1)
{
tmp[++i] = mv;
side = otherside[side];
}
else if (c == 0 && i > 0)
{
entry = (struct BookEntry *)malloc(sizeof(struct BookEntry));
mp = (unsigned short *)malloc((i+1)*sizeof(unsigned short));
entry->mv = mp;
entry->next = Book;
Book = entry;
for (j = 1; j <= i; j++) *(mp++) = tmp[j];
*mp = 0;
i = 0; side = white;
}
fclose(fd);
}
}
int parse(fd,mv,side)
FILE *fd;
unsigned short *mv;
short side;
{
int c,i,r1,r2,c1,c2;
char s[100];
while ((c = getc(fd)) == ' ');
i = 0; s[0] = c;
while (c != ' ' && c != '\n' && c != EOF) s[++i] = c = getc(fd);
s[++i] = '\0';
if (c == EOF) return(-1);
if (s[0] == '!' || i < 3)
{
while (c != '\n' && c != EOF) c = getc(fd);
return(0);
}
if (s[4] == 'o')
if (side == black) *mv = 0x3C3A; else *mv = 0x0402;
else if (s[0] == 'o')
if (side == black) *mv = 0x3C3E; else *mv = 0x0406;
else
{
c1 = s[0] - 'a'; r1 = s[1] - '1';
c2 = s[2] - 'a'; r2 = s[3] - '1';
*mv = (locn[r1][c1]<<8) + locn[r2][c2];
}
return(1);
}
GetGame()
{
FILE *fd;
char fname[40];
int c;
short sq;
unsigned short m;
printz("Enter file name: ");
scanz("%s",fname);
if (fname[0] == '\0') strcpy(fname,"chess.000");
if ((fd = fopen(fname,"r")) != NULL)
{
fscanf(fd,"%hd%hd%hd",&computer,&opponent,&Game50);
fscanf(fd,"%hd%hd%hd%hd",
&castld[white],&castld[black],
&kingmoved[white],&kingmoved[black]);
fscanf(fd,"%hd%hd",&TCflag,&OperatorTime);
fscanf(fd,"%ld%ld%hd%hd",
&TimeControl.clock[white],&TimeControl.clock[black],
&TimeControl.moves[white],&TimeControl.moves[black]);
for (sq = 0; sq < 64; sq++)
{
fscanf(fd,"%hd",&m);
board[sq] = (m >> 8); color[sq] = (m & 0xFF);
if (color[sq] == 0) color[sq] = neutral; else --color[sq];
}
GameCnt = -1; c = '?';
while (c != EOF)
{
++GameCnt;
c = fscanf(fd,"%hd%hd%hd%ld%hd%hd%hd",&GameList[GameCnt].gmove,
&GameList[GameCnt].score,&GameList[GameCnt].depth,
&GameList[GameCnt].nodes,&GameList[GameCnt].time,
&GameList[GameCnt].piece,&GameList[GameCnt].color);
if (GameList[GameCnt].color == 0) GameList[GameCnt].color = neutral;
else --GameList[GameCnt].color;
}
GameCnt--;
if (TimeControl.clock[white] > 0) TCflag = true;
computer--; opponent--;
}
fclose(fd);
InitializeStats();
UpdateDisplay(0,0,1,0);
Sdepth = 0;
}
SaveGame()
{
FILE *fd;
char fname[40];
short sq,i,c;
printz("Enter file name: ");
scanz("%s",fname);
if (fname[0] == '\0' || access(fname,W_OK) == -1) strcpy(fname,"chess.000");
fd = fopen(fname,"w");
fprintf(fd,"%d %d %d\n",computer+1,opponent+1,Game50);
fprintf(fd,"%d %d %d %d\n",
castld[white],castld[black],kingmoved[white],kingmoved[black]);
fprintf(fd,"%d %d\n",TCflag,OperatorTime);
fprintf(fd,"%ld %ld %d %d\n",
TimeControl.clock[white],TimeControl.clock[black],
TimeControl.moves[white],TimeControl.moves[black]);
for (sq = 0; sq < 64; sq++)
{
if (color[sq] == neutral) c = 0; else c = color[sq]+1;
fprintf(fd,"%d\n",256*board[sq] + c);
}
for (i = 0; i <= GameCnt; i++)
{
if (GameList[i].color == neutral) c = 0;
else c = GameList[i].color + 1;
fprintf(fd,"%d %d %d %ld %d %d %d\n",
GameList[i].gmove,GameList[i].score,GameList[i].depth,
GameList[i].nodes,GameList[i].time,
GameList[i].piece,c);
}
fclose(fd);
}
ListGame()
{
FILE *fd;
short i,f,t;
fd = fopen("chess.lst","w");
fprintf(fd,"\n");
fprintf(fd," score depth nodes time ");
fprintf(fd," score depth nodes time\n");
for (i = 0; i <= GameCnt; i++)
{
f = GameList[i].gmove>>8; t = (GameList[i].gmove & 0xFF);
algbr(f,t,false);
if ((i % 2) == 0) fprintf(fd,"\n"); else fprintf(fd," ");
fprintf(fd,"%5s %5d %2d %6ld %5d",mvstr1,
GameList[i].score,GameList[i].depth,
GameList[i].nodes,GameList[i].time);
}
fprintf(fd,"\n\n");
fclose(fd);
}
Undo()
/*
Undo the most recent half-move.
*/
{
short f,t;
f = GameList[GameCnt].gmove>>8;
t = GameList[GameCnt].gmove & 0xFF;
if (board[t] == king && distance(t,f) > 1)
castle(GameList[GameCnt].color,f,t,2);
else
{
board[f] = board[t]; color[f] = color[t];
board[t] = GameList[GameCnt].piece;
color[t] = GameList[GameCnt].color;
if (board[f] == king) --kingmoved[color[f]];
}
if (TCflag) ++TimeControl.moves[color[f]];
GameCnt--; mate = false; Sdepth = 0;
UpdateDisplay(0,0,1,0);
InitializeStats();
}
ShowMessage(s)
char *s;
{
#ifndef CHESSTOOL
printz("%s\n");
#endif CHESSTOOL
}
ShowSidetomove()
{
}
PromptForMove()
{
#ifndef CHESSTOOL
printz("\nYour move is? ");
#endif CHESSTOOL
}
ShowCurrentMove(pnt,f,t)
short pnt,f,t;
{
}
ChangeAlphaWindow()
{
printz("window: ");
scanz("%hd",&Awindow);
}
ChangeBetaWindow()
{
printz("window: ");
scanz("%hd",&Bwindow);
}
GiveHint()
{
algbr((short)(hint>>8),(short)(hint & 0xFF),false);
printz("try %s\n",mvstr1);
}
SelectLevel()
{
OperatorTime = 30000;
printz("Enter #moves #minutes: ");
scanz("%hd %hd",&TCmoves,&TCminutes);
printz("Operator time= ");
scanz("%hd",&OperatorTime);
TCflag = (TCmoves > 1);
SetTimeControl();
}
ChangeSearchDepth()
{
printz("depth= ");
scanz("%hd",&MaxSearchDepth);
}
SetContempt()
{
printz("contempt= ");
scanz("%hd",&contempt);
}
ChangeXwindow()
{
printz("xwndw= ");
scanz("%hd",&xwndw);
}

View File

@ -0,0 +1,36 @@
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)pathnames.h 5.1 (Berkeley) 5/2/90
*/
#define _PATH_CHESSBOOK "/usr/share/games/gnuchess.book"

933
gnu/games/chess/uxdsp.c Normal file
View File

@ -0,0 +1,933 @@
/*
ALPHA interface 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>
#include <sys/param.h>
#include <sys/times.h>
#include <sys/file.h>
#include <curses.h>
#include <signal.h>
#include "gnuchess.h"
#ifdef NEWMOVE
#include "move.h"
#endif
#include "pathnames.h"
struct tms tmbuf1,tmbuf2;
void TerminateSearch(),Die();
#define scanz fflush(stdout),scanw
#define printz printw
Initialize()
{
signal(SIGINT,Die); signal(SIGQUIT,Die);
initscr();
crmode();
}
ExitChess()
{
nocrmode();
endwin();
exit(0);
}
void
Die()
{
char s[80];
signal(SIGINT,SIG_IGN);
signal(SIGQUIT,SIG_IGN);
ShowMessage("Abort? ");
scanz("%s",s);
if (strcmp(s,"yes") == 0) ExitChess();
signal(SIGINT,Die); signal(SIGQUIT,Die);
}
void
TerminateSearch()
{
signal(SIGINT,SIG_IGN);
signal(SIGQUIT,SIG_IGN);
timeout = true;
bothsides = false;
signal(SIGINT,Die); signal(SIGQUIT,Die);
}
InputCommand()
/*
Process the users command. If easy mode is OFF (the computer is
thinking on opponents time) and the program is out of book, then make
the 'hint' move on the board and call SelectMove() to find a response.
The user terminates the search by entering ^C (quit siqnal) before
entering a command. If the opponent does not make the hint move, then
set Sdepth to zero.
*/
{
short ok,i,tmp;
long cnt,rate,t1,t2;
unsigned short mv;
char s[80];
ok = quit = false;
player = opponent;
ShowSidetomove();
ft = 0;
if (hint > 0 && !easy && Book == NULL)
{
fflush(stdout);
time0 = time((long *)0);
algbr(hint>>8,hint & 0xFF,false);
strcpy(s,mvstr1);
tmp = epsquare;
if (VerifyMove(s,1,&mv))
{
PromptForMove();
SelectMove(computer,2);
VerifyMove(mvstr1,2,&mv);
if (Sdepth > 0) Sdepth--;
}
ft = time((time_t *)0) - time0;
epsquare = tmp;
}
signal(SIGINT,Die); signal(SIGQUIT,Die);
while (!(ok || quit))
{
PromptForMove();
scanz("%s",s);
player = opponent;
ok = VerifyMove(s,0,&mv);
if (ok && mv != hint)
{
Sdepth = 0;
ft = 0;
}
if (strcmp(s,"bd") == 0)
{
ClrScreen();
UpdateDisplay(0,0,1,0);
}
if (strcmp(s,"quit") == 0) quit = true;
if (strcmp(s,"post") == 0) post = !post;
if (strcmp(s,"edit") == 0) EditBoard();
if (strcmp(s,"go") == 0) ok = true;
if (strcmp(s,"help") == 0) help();
if (strcmp(s,"force") == 0) force = !force;
if (strcmp(s,"book") == 0) Book = NULL;
if (strcmp(s,"undo") == 0 && GameCnt >= 0) Undo();
if (strcmp(s,"new") == 0) NewGame();
if (strcmp(s,"list") == 0) ListGame();
if (strcmp(s,"level") == 0) SelectLevel();
if (strcmp(s,"hash") == 0) hashflag = !hashflag;
if (strcmp(s,"beep") == 0) beep = !beep;
if (strcmp(s,"Awindow") == 0) ChangeAlphaWindow();
if (strcmp(s,"Bwindow") == 0) ChangeBetaWindow();
if (strcmp(s,"hint") == 0) GiveHint();
if (strcmp(s,"both") == 0)
{
bothsides = !bothsides;
Sdepth = 0;
SelectMove(opponent,1);
ok = true;
}
if (strcmp(s,"reverse") == 0)
{
reverse = !reverse;
ClrScreen();
UpdateDisplay(0,0,1,0);
}
if (strcmp(s,"switch") == 0)
{
computer = otherside[computer];
opponent = otherside[opponent];
force = false;
Sdepth = 0;
ok = true;
}
if (strcmp(s,"white") == 0)
{
computer = white; opponent = black;
ok = true; force = false;
Sdepth = 0;
}
if (strcmp(s,"black") == 0)
{
computer = black; opponent = white;
ok = true; force = false;
Sdepth = 0;
}
if (strcmp(s,"remove") == 0 && GameCnt >= 1)
{
Undo(); Undo();
}
if (strcmp(s,"get") == 0) GetGame();
if (strcmp(s,"save") == 0) SaveGame();
if (strcmp(s,"depth") == 0) ChangeSearchDepth();
if (strcmp(s,"random") == 0) dither = 6;
if (strcmp(s,"easy") == 0) easy = !easy;
if (strcmp(s,"contempt") == 0) SetContempt();
if (strcmp(s,"xwndw") == 0) ChangeXwindow();
if (strcmp(s,"test") == 0)
{
t1 = time(0);
cnt = 0;
for (i = 0; i < 10000; i++)
{
MoveList(opponent,2);
cnt += TrPnt[3] - TrPnt[2];
}
t2 = time(0);
rate = cnt / (t2-t1);
gotoXY(50,24);
printz("cnt= %ld rate= %ld",cnt,rate);
ClrEoln();
}
if (strcmp(s,"p") == 0) ShowPostnValues();
if (strcmp(s,"debug") == 0) DoDebug();
}
ClearMessage();
ElapsedTime(1);
if (force)
{
computer = opponent; opponent = otherside[computer];
}
(void) times(&tmbuf1);
signal(SIGINT,TerminateSearch); signal(SIGQUIT,TerminateSearch);
}
EditBoard()
/*
Set up a board position. Pieces are entered by typing the piece
followed by the location. For example, Nf3 will place a knight on
square f3.
*/
{
short a,r,c,sq;
char s[80];
ClrScreen();
UpdateDisplay(0,0,1,0);
gotoXY(50,2); printz(". Exit to main");
gotoXY(50,3); printz("# Clear board");
gotoXY(49,5); printz("Enter piece & location: ");
a = white;
do
{
gotoXY(73,5); ClrEoln(); scanz("%s",s);
if (s[0] == '#')
{
for (sq = 0; sq < 64; sq++)
{
board[sq] = no_piece; color[sq] = neutral;
}
UpdateDisplay(0,0,1,0);
}
if (s[0] == 'c' || s[0] == 'C') a = otherside[a];
c = s[1]-'a'; r = s[2]-'1';
if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
{
sq = locn[r][c];
color[sq] = a;
if (s[0] == 'p') board[sq] = pawn;
else if (s[0] == 'n') board[sq] = knight;
else if (s[0] == 'b') board[sq] = bishop;
else if (s[0] == 'r') board[sq] = rook;
else if (s[0] == 'q') board[sq] = queen;
else if (s[0] == 'k') board[sq] = king;
else { board[sq] = no_piece; color[sq] = neutral; }
DrawPiece(sq);
}
}
while (s[0] != '.');
if (board[4] != king) kingmoved[white] = 10;
if (board[60] != king) kingmoved[black] = 10;
GameCnt = -1; Game50 = 0; Sdepth = 0;
InitializeStats();
ClrScreen();
UpdateDisplay(0,0,1,0);
}
help()
{
ClrScreen();
gotoXY(28,1); printz("CHESS command summary");
gotoXY(1,3); printz("g1f3 move from g1 to f3");
gotoXY(1,4); printz("nf3 move knight to f3");
gotoXY(1,5); printz("o-o castle king side");
gotoXY(1,6); printz("o-o-o castle queen side");
gotoXY(1,7); printz("edit edit board");
gotoXY(1,8); printz("switch sides with computer");
gotoXY(1,9); printz("white computer plays white");
gotoXY(1,10); printz("black computer plays black");
gotoXY(1,11); printz("reverse board display");
gotoXY(1,12); printz("both computer match");
gotoXY(1,13); printz("random randomize play");
gotoXY(1,14); printz("undo undo last move");
gotoXY(42,3); printz("level change level");
gotoXY(42,4); printz("depth set search depth");
gotoXY(42,5); printz("post principle variation");
gotoXY(42,6); printz("hint suggest a move");
gotoXY(42,7); printz("bd redraw board");
gotoXY(42,8); printz("force enter game moves");
gotoXY(42,9); printz("list game to chess.lst");
gotoXY(42,10); printz("save game to file");
gotoXY(42,11); printz("get game from file");
gotoXY(42,12); printz("new start new game");
gotoXY(42,13); printz("quit exit CHESS");
gotoXY(10,21); printz("Computer: ");
if (computer == white) printz("WHITE"); else printz("BLACK");
gotoXY(10,22); printz("Opponent: ");
if (opponent == white) printz("WHITE"); else printz("BLACK");
gotoXY(10,23); printz("Level: %ld",Level," sec.");
gotoXY(10,24); printz("Easy mode: ");
if (easy) printz("ON"); else printz("OFF");
gotoXY(40,21); printz("Depth: %d",MaxSearchDepth);
gotoXY(40,22); printz("Random: ");
if (dither) printz("ON"); else printz("OFF");
gotoXY(40,23); printz("Transposition table: ");
if (hashflag) printz("ON"); else printz("OFF");
refresh();
while (getchar() != 27);
ClrScreen();
UpdateDisplay(0,0,1,0);
}
ShowDepth(ch)
char ch;
{
gotoXY(50,4); printz("Depth= %d%c ",Sdepth,ch); ClrEoln();
}
ShowResults(score,bstline,ch)
short score;
unsigned short bstline[];
char ch;
{
short d,e,ply;
if (post && player == computer)
{
e = lpost;
gotoXY(50,5); printz("Score= %d",score); ClrEoln();
d = 8; gotoXY(50,d); ClrEoln();
for (ply = 1; bstline[ply] > 0; ply++)
{
algbr(bstline[ply] >> 8,bstline[ply] & 0xFF,false);
if (ply == 5 || ply == 9 || ply == 13 || ply == 17)
{
gotoXY(50,++d); ClrEoln();
}
printz("%5s ",mvstr1);
}
ClrEoln();
lpost = d;
while (++d <= e)
{
gotoXY(50,d); ClrEoln();
}
}
}
SearchStartStuff(side)
short side;
{
short i;
signal(SIGINT,TerminateSearch); signal(SIGQUIT,TerminateSearch);
if (player == computer)
for (i = 5; i < 14; i++)
{
gotoXY(50,i); ClrEoln();
}
}
OutputMove()
{
if (root->flags & epmask) UpdateDisplay(0,0,1,0);
else UpdateDisplay(root->f,root->t,0,root->flags & cstlmask);
gotoXY(50,17); printz("My move is: %s",mvstr1);
if (beep) putchar(7);
ClrEoln();
gotoXY(50,24);
if (root->flags & draw) printz("Draw game!");
else if (root->score == -9999) printz("opponent mates!");
else if (root->score == 9998) printz("computer mates!");
else if (root->score < -9000) printz("opponent will soon mate!");
else if (root->score > 9000) printz("computer will soon mate!");
ClrEoln();
if (post)
{
gotoXY(50,22); printz("Nodes= %6ld",NodeCnt); ClrEoln();
gotoXY(50,23); printz("Nodes/Sec= %4ld",evrate); ClrEoln();
}
}
ElapsedTime(iop)
/*
Determine the time that has passed since the search was started. If
the elapsed time exceeds the target (ResponseTime+ExtraTime) then set
timeout to true which will terminate the search.
*/
short iop;
{
et = time((time_t *)0) - time0;
if (et < 0) et = 0;
ETnodes += 50;
if (et > et0 || iop == 1)
{
if (et > ResponseTime+ExtraTime && Sdepth > 1) timeout = true;
et0 = et;
if (iop == 1)
{
time0 = time((time_t *)0); et0 = 0;
}
(void) times(&tmbuf2);
cputimer = 100*(tmbuf2.tms_utime - tmbuf1.tms_utime) / HZ;
if (cputimer > 0) evrate = (100*NodeCnt)/(cputimer+100*ft);
else evrate = 0;
ETnodes = NodeCnt + 50;
UpdateClocks();
}
}
UpdateClocks()
{
short m,s;
m = et/60; s = (et - 60*m);
if (TCflag)
{
m = (TimeControl.clock[player] - et) / 60;
s = TimeControl.clock[player] - et - 60*m;
}
if (m < 0) m = 0;
if (s < 0) s = 0;
if (player == white)
if (reverse) gotoXY(20,2); else gotoXY(20,23);
else
if (reverse) gotoXY(20,23); else gotoXY(20,2);
printz("%d:%2d ",m,s);
if (post)
{
gotoXY(50,22); printz("Nodes= %6ld",NodeCnt);
gotoXY(50,23); printz("Nodes/Sec= %4ld",evrate);
}
refresh();
}
SetTimeControl()
{
if (TCflag)
{
TimeControl.moves[white] = TimeControl.moves[black] = TCmoves;
TimeControl.clock[white] = TimeControl.clock[black] = 60*(long)TCminutes;
}
else
{
TimeControl.moves[white] = TimeControl.moves[black] = 0;
TimeControl.clock[white] = TimeControl.clock[black] = 0;
Level = 60*(long)TCminutes;
}
et = 0;
ElapsedTime(1);
}
gotoXY(x,y)
short x,y;
{
move(y-1,x-1);
}
ClrScreen()
{
clear(); refresh();
}
ClrEoln()
{
clrtoeol(); refresh();
}
DrawPiece(sq)
short sq;
{
short r,c; char x;
if (reverse) r = 7-row[sq]; else r = row[sq];
if (reverse) c = 7-column[sq]; else c = column[sq];
if (color[sq] == black) x = '*'; else x = ' ';
gotoXY(5+5*c,5+2*(7-r)); printz("%c%c ",x,pxx[board[sq]]);
}
UpdateDisplay(f,t,flag,iscastle)
short f,t,flag,iscastle;
{
short i,l,z;
if (flag)
{
gotoXY(56,2); printz("CHESS");
i = 3;
gotoXY(3,++i);
printz("|----|----|----|----|----|----|----|----|");
while (i<19)
{
gotoXY(1,++i);
if (reverse) z = (i/2)-1; else z = 10-(i/2);
printz("%d | | | | | | | | |",z);
gotoXY(3,++i);
if (i < 19)
printz("+----+----+----+----+----+----+----+----+");
}
printz("|----|----|----|----|----|----|----|----|");
gotoXY(3,21);
if (reverse) printz(" h g f e d c b a");
else printz(" a b c d e f g h");
if (reverse) gotoXY(5,23); else gotoXY(5,2);
if (computer == black) printz("Computer"); else printz("Human ");
if (reverse) gotoXY(5,2); else gotoXY(5,23);
if (computer == white) printz("Computer"); else printz("Human ");
for (l = 0; l < 64; l++) DrawPiece(l);
}
else
{
DrawPiece(f); DrawPiece(t);
if (iscastle)
if (t > f)
{ DrawPiece(f+3); DrawPiece(t-1); }
else
{ DrawPiece(f-4); DrawPiece(t+1); }
}
refresh();
}
GetOpenings()
/*
Read in the Opening Book file and parse the algebraic notation for a
move into an unsigned integer format indicating the from and to
square. Create a linked list of opening lines of play, with
entry->next pointing to the next line and entry->move pointing to a
chunk of memory containing the moves. More Opening lines of up to 256
half moves may be added to gnuchess.book.
*/
{
FILE *fd;
int c,i,j,side;
struct BookEntry *entry;
unsigned short mv,*mp,tmp[100];
if ((fd = fopen(_PATH_CHESSBOOK,"r")) != NULL)
{
Book = NULL;
i = 0; side = white;
while ((c = parse(fd,&mv,side)) >= 0)
if (c == 1)
{
tmp[++i] = mv;
side = otherside[side];
}
else if (c == 0 && i > 0)
{
entry = (struct BookEntry *)malloc(sizeof(struct BookEntry));
mp = (unsigned short *)malloc((i+1)*sizeof(unsigned short));
entry->mv = mp;
entry->next = Book;
Book = entry;
for (j = 1; j <= i; j++) *(mp++) = tmp[j];
*mp = 0;
i = 0; side = white;
}
fclose(fd);
}
else
{
fprintf(stderr, "\nchess: can't read %s.\n", _PATH_CHESSBOOK);
exit(1);
}
}
int parse(fd,mv,side)
FILE *fd;
unsigned short *mv;
short side;
{
int c,i,r1,r2,c1,c2;
char s[100];
while ((c = getc(fd)) == ' ');
i = 0; s[0] = c;
while (c != ' ' && c != '\n' && c != EOF) s[++i] = c = getc(fd);
s[++i] = '\0';
if (c == EOF) return(-1);
if (s[0] == '!' || i < 3)
{
while (c != '\n' && c != EOF) c = getc(fd);
return(0);
}
if (s[4] == 'o')
if (side == black) *mv = 0x3C3A; else *mv = 0x0402;
else if (s[0] == 'o')
if (side == black) *mv = 0x3C3E; else *mv = 0x0406;
else
{
c1 = s[0] - 'a'; r1 = s[1] - '1';
c2 = s[2] - 'a'; r2 = s[3] - '1';
*mv = (locn[r1][c1]<<8) + locn[r2][c2];
}
return(1);
}
GetGame()
{
FILE *fd;
char fname[40];
int c;
short sq;
unsigned short m;
ShowMessage("File name: ");
scanz("%s",fname);
if (fname[0] == '\0') strcpy(fname,"chess.000");
if ((fd = fopen(fname,"r")) != NULL)
{
fscanf(fd,"%hd%hd%hd",&computer,&opponent,&Game50);
fscanf(fd,"%hd%hd%hd%hd",
&castld[white],&castld[black],
&kingmoved[white],&kingmoved[black]);
fscanf(fd,"%hd%hd",&TCflag,&OperatorTime);
fscanf(fd,"%ld%ld%hd%hd",
&TimeControl.clock[white],&TimeControl.clock[black],
&TimeControl.moves[white],&TimeControl.moves[black]);
for (sq = 0; sq < 64; sq++)
{
fscanf(fd,"%hd",&m);
board[sq] = (m >> 8); color[sq] = (m & 0xFF);
if (color[sq] == 0) color[sq] = neutral; else --color[sq];
}
GameCnt = -1; c = '?';
while (c != EOF)
{
++GameCnt;
c = fscanf(fd,"%hd%hd%hd%ld%hd%hd%hd",&GameList[GameCnt].gmove,
&GameList[GameCnt].score,&GameList[GameCnt].depth,
&GameList[GameCnt].nodes,&GameList[GameCnt].time,
&GameList[GameCnt].piece,&GameList[GameCnt].color);
if (GameList[GameCnt].color == 0) GameList[GameCnt].color = neutral;
else --GameList[GameCnt].color;
}
GameCnt--;
if (TimeControl.clock[white] > 0) TCflag = true;
computer--; opponent--;
}
fclose(fd);
InitializeStats();
UpdateDisplay(0,0,1,0);
Sdepth = 0;
}
SaveGame()
{
FILE *fd;
char fname[40];
short sq,i,c;
ShowMessage("File name: ");
scanz("%s",fname);
if (fname[0] == '\0' || access(fname,W_OK) == -1) strcpy(fname,"chess.000");
fd = fopen(fname,"w");
fprintf(fd,"%d %d %d\n",computer+1,opponent+1,Game50);
fprintf(fd,"%d %d %d %d\n",
castld[white],castld[black],kingmoved[white],kingmoved[black]);
fprintf(fd,"%d %d\n",TCflag,OperatorTime);
fprintf(fd,"%ld %ld %d %d\n",
TimeControl.clock[white],TimeControl.clock[black],
TimeControl.moves[white],TimeControl.moves[black]);
for (sq = 0; sq < 64; sq++)
{
if (color[sq] == neutral) c = 0; else c = color[sq]+1;
fprintf(fd,"%d\n",256*board[sq] + c);
}
for (i = 0; i <= GameCnt; i++)
{
if (GameList[i].color == neutral) c = 0;
else c = GameList[i].color + 1;
fprintf(fd,"%d %d %d %ld %d %d %d\n",
GameList[i].gmove,GameList[i].score,GameList[i].depth,
GameList[i].nodes,GameList[i].time,
GameList[i].piece,c);
}
fclose(fd);
}
ListGame()
{
FILE *fd;
short i,f,t;
fd = fopen("chess.lst","w");
fprintf(fd,"\n");
fprintf(fd," score depth nodes time ");
fprintf(fd," score depth nodes time\n");
for (i = 0; i <= GameCnt; i++)
{
f = GameList[i].gmove>>8; t = (GameList[i].gmove & 0xFF);
algbr(f,t,false);
if ((i % 2) == 0) fprintf(fd,"\n"); else fprintf(fd," ");
fprintf(fd,"%5s %5d %2d %6ld %5d",mvstr1,
GameList[i].score,GameList[i].depth,
GameList[i].nodes,GameList[i].time);
}
fprintf(fd,"\n\n");
fclose(fd);
}
Undo()
/*
Undo the most recent half-move.
*/
{
short f,t;
f = GameList[GameCnt].gmove>>8;
t = GameList[GameCnt].gmove & 0xFF;
if (board[t] == king && distance(t,f) > 1)
castle(GameList[GameCnt].color,f,t,2);
else
{
board[f] = board[t]; color[f] = color[t];
board[t] = GameList[GameCnt].piece;
color[t] = GameList[GameCnt].color;
if (board[f] == king) --kingmoved[color[f]];
}
if (TCflag) ++TimeControl.moves[color[f]];
GameCnt--; mate = false; Sdepth = 0;
UpdateDisplay(0,0,1,0);
InitializeStats();
}
ShowMessage(s)
char *s;
{
gotoXY(50,24); printz("%s",s); ClrEoln();
}
ClearMessage()
{
gotoXY(50,24); ClrEoln();
}
ShowSidetomove()
{
gotoXY(50,14);
if (player == white) printz("%2d: WHITE",1+(GameCnt+1)/2);
else printz("%2d: BLACK",1+(GameCnt+1)/2);
ClrEoln();
}
PromptForMove()
{
gotoXY(50,19); printz("Your move is? "); ClrEoln();
}
ShowCurrentMove(pnt,f,t)
short pnt,f,t;
{
algbr(f,t,false);
gotoXY(50,7); printz("(%2d) %4s",pnt,mvstr1);
}
ChangeAlphaWindow()
{
ShowMessage("window: ");
scanz("%hd",&Awindow);
}
ChangeBetaWindow()
{
ShowMessage("window: ");
scanz("%hd",&Bwindow);
}
GiveHint()
{
char s[40];
algbr((short)(hint>>8),(short)(hint & 0xFF),false);
strcpy(s,"try ");
strcat(s,mvstr1);
ShowMessage(s);
}
ChangeSearchDepth()
{
ShowMessage("depth= ");
scanz("%hd",&MaxSearchDepth);
}
SetContempt()
{
ShowMessage("contempt= ");
scanz("%hd",&contempt);
}
ChangeXwindow()
{
ShowMessage("xwndw= ");
scanz("%hd",&xwndw);
}
SelectLevel()
{
ClrScreen();
gotoXY(32,2); printz("CHESS");
gotoXY(20,4); printz(" 1. 60 moves in 5 minutes");
gotoXY(20,5); printz(" 2. 60 moves in 15 minutes");
gotoXY(20,6); printz(" 3. 60 moves in 30 minutes");
gotoXY(20,7); printz(" 4. 40 moves in 30 minutes");
gotoXY(20,8); printz(" 5. 40 moves in 60 minutes");
gotoXY(20,9); printz(" 6. 40 moves in 120 minutes");
gotoXY(20,10); printz(" 7. 40 moves in 240 minutes");
gotoXY(20,11); printz(" 8. 1 move in 15 minutes");
gotoXY(20,12); printz(" 9. 1 move in 60 minutes");
gotoXY(20,13); printz("10. 1 move in 600 minutes");
OperatorTime = 0; TCmoves = 60; TCminutes = 5;
gotoXY(20,17); printz("Enter Level: ");
refresh();
scanz("%ld",&Level);
switch (Level)
{
case 1 : TCmoves = 60; TCminutes = 5; break;
case 2 : TCmoves = 60; TCminutes = 15; break;
case 3 : TCmoves = 60; TCminutes = 30; break;
case 4 : TCmoves = 40; TCminutes = 30; break;
case 5 : TCmoves = 40; TCminutes = 60; break;
case 6 : TCmoves = 40; TCminutes = 120; break;
case 7 : TCmoves = 40; TCminutes = 240; break;
case 8 : TCmoves = 1; TCminutes = 15; break;
case 9 : TCmoves = 1; TCminutes = 60; break;
case 10 : TCmoves = 1; TCminutes = 600; break;
}
TCflag = (TCmoves > 1);
SetTimeControl();
ClrScreen();
UpdateDisplay(0,0,1,0);
}
ShowPostnValues()
{
short i,r,c;
ExaminePosition();
for (i = 0; i < 64; i++)
{
if (reverse) r = 7-row[i]; else r = row[i];
if (reverse) c = 7-column[i]; else c = column[i];
gotoXY(4+5*c,5+2*(7-r));
c1 = color[i]; c2 = otherside[c1];
PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
atk1 = atak[c1]; atk2 = atak[c2];
if (color[i] == neutral) printz(" ");
else printz("%3d ",SqValue(i,opponent));
}
ScorePosition(opponent,&i);
gotoXY(50,24);
printz("Score= %d",i); ClrEoln();
}
DoDebug()
{
short k,p,i,r,c,tp,tc;
char s[40];
ExaminePosition();
ShowMessage("Enter piece: ");
scanz("%s",s);
if (s[0] == 'w') k = white; else k = black;
if (s[1] == 'p') p = pawn;
else if (s[1] == 'n') p = knight;
else if (s[1] == 'b') p = bishop;
else if (s[1] == 'r') p = rook;
else if (s[1] == 'q') p = queen;
else if (s[1] == 'k') p = king;
else p = no_piece;
for (i = 0; i < 64; i++)
{
if (reverse) r = 7-row[i]; else r = row[i];
if (reverse) c = 7-column[i]; else c = column[i];
gotoXY(4+5*c,5+2*(7-r));
tp = board[i]; tc = color[i];
board[i] = p; color[i] = k;
c1 = k; c2 = otherside[c1];
PC1 = PawnCnt[c1]; PC2 = PawnCnt[c2];
atk1 = atak[c1]; atk2 = atak[c2];
printz("%3d ",SqValue(i,opponent));
board[i] = tp; color[i] = tc;
}
ScorePosition(opponent,&i);
gotoXY(50,24);
printz("Score= %d",i); ClrEoln();
}

View File

@ -0,0 +1,7 @@
# @(#)Makefile 0.1 (RWGrimes) 3/25/93
MAN4= mem.0 spkr.0
MLINKS= mem.4 kmem.4
MANSUBDIR=/i386
.include <bsd.prog.mk>

View File

@ -0,0 +1,82 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)mem.4 5.3 (Berkeley) 5/2/91
.\"
.Dd May 2, 1991
.Dt MEM 4 i386
.Os
.Sh NAME
.Nm mem ,
.Nm kmem
.Nd memory files
.Sh DESCRIPTION
The special file
.Nm /dev/mem
is an interface to the physical memory of the computer.
Byte offsets in this file are interpreted as physical memory addresses.
Reading and writing this file is equivalent to reading and writing
memory itself.
Only offsets within the bounds of
.Nm /dev/mem
are allowed.
.Pp
Kernel virtual memory is accessed through the interface
.Nm /dev/kmem
in the same manner as
.Nm /dev/mem .
Only kernel virtual addresses that are currently mapped to memory are allowed.
.Pp
On
.Tn ISA
the
.Tn I/O
memory space begins at physical address 0x000a0000
and runs to 0x00100000.
The
per-process data
size
for the current process
is
.Dv UPAGES
long, and ends at virtual
address 0xfe000000.
.Sh FILES
.Bl -tag -width Pa -compact
.It Pa /dev/mem
.It Pa /dev/kmem
.El
.Sh HISTORY
The
.Nm mem ,
.Nm kmem
files appeared in
.At v6 .

View File

@ -0,0 +1,117 @@
.TH SPKR 4
.SH NAME
spkr \- console speaker device driver
.SH DESCRIPTION
The speaker device driver allows applications to control the PC console
speaker on an IBM-PC-compatible machine running UNIX.
.PP
Only one process may have this device open at any given time; open() and
close() are used to lock and relinquish it. An attempt to open() when
another process has the device locked will return -1 with an EBUSY error
indication. Writes to the device are interpreted as 'play strings' in a
simple ASCII melody notation. An ioctl() for tone generation at arbitrary
frequencies is also supported.
.PP
Sound-generation does \fInot\fR monopolize the processor; in fact, the driver
spends most of its time sleeping while the PC hardware is emitting
tones. Other processes may emit beeps while the driver is running.
.PP
Applications may call ioctl() on a speaker file descriptor to control the
speaker driver directly; definitions for the ioctl() interface are in
sys/spkr.h. The tone_t structure used in these calls has two fields,
specifying a frequency (in hz) and a duration (in 1/100ths of a second).
A frequency of zero is interpreted as a rest.
.PP
At present there are two such ioctls. SPKRTONE accepts a pointer to a
single tone structure as third argument and plays it. SPKRTUNE accepts a
pointer to the first of an array of tone structures and plays them in
continuous sequence; this array must be terminated by a final member with
a zero duration.
.PP
The play-string language is modelled on the PLAY statement conventions of
IBM BASIC 2.0. The MB, MF and X primitives of PLAY are not useful in a UNIX
environment and are omitted. The `octave-tracking' feature is also new.
.PP
There are 84 accessible notes numbered 1-83 in 7 octaves, each running from
C to B, numbered 0-6; the scale is equal-tempered A440 and octave 3 starts
with middle C. By default, the play function emits half-second notes with the
last 1/16th second being `rest time'.
.PP
Play strings are interpreted left to right as a series of play command groups;
letter case is ignored. Play command groups are as follows:
.PP
CDEFGAB -- letters A through G cause the corresponding note to be played in the
current octave. A note letter may optionally be followed by an \fIaccidental
sign\fR, one of # + or -; the first two of these cause it to be sharped one
half-tone, the last causes it to be flatted one half-tone. It may also be
followed by a time value number and by sustain dots (see below). Time values
are interpreted as for the L command below;.
.PP
O <n> -- if <n> is numeric, this sets the current octave. <n> may also be one
of 'L' or 'N' to enable or disable octave-tracking (it is disabled by default).
When octave-tracking is on, interpretation of a pair of letter notes will
change octaves if necessary in order to make the smallest possible jump between
notes. Thus "olbc" will be played as "olb>c", and "olcb" as "olc<b". Octave
locking is disabled for one letter note following by >, < and O[0123456].
.PP
> -- bump the current octave up one.
.PP
< -- drop the current octave down one.
.PP
N <n> -- play note n, n being 1 to 84 or 0 for a rest of current time value.
May be followedv by sustain dots.
.PP
L <n> -- sets the current time value for notes. The default is L4, quarter
notes. The lowest possible value is 1; values up to 64 are accepted. L1 sets
whole notes, L2 sets half notes, L4 sets quarter notes, etc..
.PP
P <n> -- pause (rest), with <n> interpreted as for L. May be followed by
sustain dots. May also be written '~'.
.PP
T <n> -- Sets the number of quarter notes per minute; default is 120. Musical
names for common tempi are:
.TS
a a a.
Tempo Beats Per Minute
very slow Larghissimo
Largo 40-60
Larghetto 60-66
Grave
Lento
Adagio 66-76
slow Adagietto
Andante 76-108
medium Andantino
Moderato 108-120
fast Allegretto
Allegro 120-168
Vivace
Veloce
Presto 168-208
very fast Prestissimo
.TE
.PP
M[LNS] -- set articulation. MN (N for normal) is the default; the last 1/8th of
the note's value is rest time. You can set ML for legato (no rest space) or
MS (staccato) 1/4 rest space.
.PP
Notes (that is, CDEFGAB or N command character groups) may be followed by
sustain dots. Each dot causes the note's value to be lengthened by one-half
for each one. Thus, a note dotted once is held for 3/2 of its undotted value;
dotted twice, it is held 9/4, and three times would give 27/8.
.PP
Whitespace in play strings is simply skipped and may be used to separate
melody sections.
.SH BUGS
Due to roundoff in the pitch tables and slop in the tone-generation and timer
hardware (neither of which was designed for precision), neither pitch accuracy
nor timings will be mathematically exact. There is no volume control.
.PP
In play strings which are very long (longer than your system's physical I/O
blocks) note suffixes or numbers may occasionally be parsed incorrectly due
to crossing a block boundary.
.SH FILES
/dev/speaker -- speaker device file
.SH AUTHOR
Eric S. Raymond (esr@snark.thyrsus.com) Feb 1990

82
share/man/man4/mem.4 Normal file
View File

@ -0,0 +1,82 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)mem.4 5.3 (Berkeley) 5/2/91
.\"
.Dd May 2, 1991
.Dt MEM 4 i386
.Os
.Sh NAME
.Nm mem ,
.Nm kmem
.Nd memory files
.Sh DESCRIPTION
The special file
.Nm /dev/mem
is an interface to the physical memory of the computer.
Byte offsets in this file are interpreted as physical memory addresses.
Reading and writing this file is equivalent to reading and writing
memory itself.
Only offsets within the bounds of
.Nm /dev/mem
are allowed.
.Pp
Kernel virtual memory is accessed through the interface
.Nm /dev/kmem
in the same manner as
.Nm /dev/mem .
Only kernel virtual addresses that are currently mapped to memory are allowed.
.Pp
On
.Tn ISA
the
.Tn I/O
memory space begins at physical address 0x000a0000
and runs to 0x00100000.
The
per-process data
size
for the current process
is
.Dv UPAGES
long, and ends at virtual
address 0xfe000000.
.Sh FILES
.Bl -tag -width Pa -compact
.It Pa /dev/mem
.It Pa /dev/kmem
.El
.Sh HISTORY
The
.Nm mem ,
.Nm kmem
files appeared in
.At v6 .

117
share/man/man4/spkr.4 Normal file
View File

@ -0,0 +1,117 @@
.TH SPKR 4
.SH NAME
spkr \- console speaker device driver
.SH DESCRIPTION
The speaker device driver allows applications to control the PC console
speaker on an IBM-PC-compatible machine running UNIX.
.PP
Only one process may have this device open at any given time; open() and
close() are used to lock and relinquish it. An attempt to open() when
another process has the device locked will return -1 with an EBUSY error
indication. Writes to the device are interpreted as 'play strings' in a
simple ASCII melody notation. An ioctl() for tone generation at arbitrary
frequencies is also supported.
.PP
Sound-generation does \fInot\fR monopolize the processor; in fact, the driver
spends most of its time sleeping while the PC hardware is emitting
tones. Other processes may emit beeps while the driver is running.
.PP
Applications may call ioctl() on a speaker file descriptor to control the
speaker driver directly; definitions for the ioctl() interface are in
sys/spkr.h. The tone_t structure used in these calls has two fields,
specifying a frequency (in hz) and a duration (in 1/100ths of a second).
A frequency of zero is interpreted as a rest.
.PP
At present there are two such ioctls. SPKRTONE accepts a pointer to a
single tone structure as third argument and plays it. SPKRTUNE accepts a
pointer to the first of an array of tone structures and plays them in
continuous sequence; this array must be terminated by a final member with
a zero duration.
.PP
The play-string language is modelled on the PLAY statement conventions of
IBM BASIC 2.0. The MB, MF and X primitives of PLAY are not useful in a UNIX
environment and are omitted. The `octave-tracking' feature is also new.
.PP
There are 84 accessible notes numbered 1-83 in 7 octaves, each running from
C to B, numbered 0-6; the scale is equal-tempered A440 and octave 3 starts
with middle C. By default, the play function emits half-second notes with the
last 1/16th second being `rest time'.
.PP
Play strings are interpreted left to right as a series of play command groups;
letter case is ignored. Play command groups are as follows:
.PP
CDEFGAB -- letters A through G cause the corresponding note to be played in the
current octave. A note letter may optionally be followed by an \fIaccidental
sign\fR, one of # + or -; the first two of these cause it to be sharped one
half-tone, the last causes it to be flatted one half-tone. It may also be
followed by a time value number and by sustain dots (see below). Time values
are interpreted as for the L command below;.
.PP
O <n> -- if <n> is numeric, this sets the current octave. <n> may also be one
of 'L' or 'N' to enable or disable octave-tracking (it is disabled by default).
When octave-tracking is on, interpretation of a pair of letter notes will
change octaves if necessary in order to make the smallest possible jump between
notes. Thus "olbc" will be played as "olb>c", and "olcb" as "olc<b". Octave
locking is disabled for one letter note following by >, < and O[0123456].
.PP
> -- bump the current octave up one.
.PP
< -- drop the current octave down one.
.PP
N <n> -- play note n, n being 1 to 84 or 0 for a rest of current time value.
May be followedv by sustain dots.
.PP
L <n> -- sets the current time value for notes. The default is L4, quarter
notes. The lowest possible value is 1; values up to 64 are accepted. L1 sets
whole notes, L2 sets half notes, L4 sets quarter notes, etc..
.PP
P <n> -- pause (rest), with <n> interpreted as for L. May be followed by
sustain dots. May also be written '~'.
.PP
T <n> -- Sets the number of quarter notes per minute; default is 120. Musical
names for common tempi are:
.TS
a a a.
Tempo Beats Per Minute
very slow Larghissimo
Largo 40-60
Larghetto 60-66
Grave
Lento
Adagio 66-76
slow Adagietto
Andante 76-108
medium Andantino
Moderato 108-120
fast Allegretto
Allegro 120-168
Vivace
Veloce
Presto 168-208
very fast Prestissimo
.TE
.PP
M[LNS] -- set articulation. MN (N for normal) is the default; the last 1/8th of
the note's value is rest time. You can set ML for legato (no rest space) or
MS (staccato) 1/4 rest space.
.PP
Notes (that is, CDEFGAB or N command character groups) may be followed by
sustain dots. Each dot causes the note's value to be lengthened by one-half
for each one. Thus, a note dotted once is held for 3/2 of its undotted value;
dotted twice, it is held 9/4, and three times would give 27/8.
.PP
Whitespace in play strings is simply skipped and may be used to separate
melody sections.
.SH BUGS
Due to roundoff in the pitch tables and slop in the tone-generation and timer
hardware (neither of which was designed for precision), neither pitch accuracy
nor timings will be mathematically exact. There is no volume control.
.PP
In play strings which are very long (longer than your system's physical I/O
blocks) note suffixes or numbers may occasionally be parsed incorrectly due
to crossing a block boundary.
.SH FILES
/dev/speaker -- speaker device file
.SH AUTHOR
Eric S. Raymond (esr@snark.thyrsus.com) Feb 1990

View File

@ -0,0 +1,5 @@
# @(#)Makefile 5.3 (Berkeley) 5/11/90
PROG= symorder
.include <bsd.prog.mk>

View File

@ -0,0 +1,81 @@
.\" Copyright (c) 1980, 1990 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)symorder.1 6.5 (Berkeley) 4/22/91
.\"
.Dd April 22, 1991
.Dt SYMORDER 1
.Os BSD 3
.Sh NAME
.Nm symorder
.Nd rearrange name list
.Sh SYNOPSIS
.Nm symorder
.Fl t Ar symlist file
.Sh DESCRIPTION
The file
.Ar symlist
contains a list of symbols to be found in
.Ar file,
one symbol per line.
.Pp
The symbol table of
.Ar file
is updated in place;
symbols read from
.Ar symlist
are relocated to the beginning of the table and in the order given.
.Bl -tag -width flag
.It Fl t
Restrict the symbol table to the symbols listed in
.Ar symlist .
.El
.Pp
This program was specifically designed to cut down on the
overhead of getting symbols from
.Pa /vmunix.
.Sh DIAGNOSTICS
The
.Nm symorder
utility exits 0 on success, 1 if a symbol
listed in the
.Ar symlist
file was not found in the symbol
table, and >1 if an error occurs.
.Sh SEE ALSO
.Xr nm 3 ,
.Xr nlist 3 ,
.Xr strip 3
.Sh HISTORY
The
.Nm
command appeared in
.Bx 3.0 .

281
usr.bin/symorder/symorder.c Normal file
View File

@ -0,0 +1,281 @@
/*
* Copyright (c) 1980 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1980 The Regents of the University of California.\n\
All rights reserved.\n";
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)symorder.c 5.8 (Berkeley) 4/1/91";
#endif /* not lint */
/*
* symorder - reorder symbol table
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <a.out.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SPACE 500
#define OKEXIT 0
#define NOTFOUNDEXIT 1
#define ERREXIT 2
struct nlist order[SPACE];
struct exec exec;
struct stat stb;
struct nlist *newtab, *symtab;
off_t sa;
int nsym, strtabsize, symfound, small;
char *kfile, *newstrings, *strings, asym[BUFSIZ];
main(argc, argv)
int argc;
char **argv;
{
extern char *optarg;
extern int optind;
register struct nlist *p, *symp;
register FILE *f;
register int i;
register char *start, *t;
int ch, n, o;
while ((ch = getopt(argc, argv, "t")) != EOF)
switch(ch) {
case 't':
small = 1;
break;
case '?':
default:
usage();
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
if ((f = fopen(argv[0], "r")) == NULL)
error(argv[0]);
for (p = order; fgets(asym, sizeof(asym), f) != NULL;) {
for (t = asym; isspace(*t); ++t);
if (!*(start = t))
continue;
while (*++t);
if (*--t == '\n')
*t = '\0';
p->n_un.n_name = strdup(start);
++p;
++nsym;
}
(void)fclose(f);
kfile = argv[1];
if ((f = fopen(kfile, "r")) == NULL)
error(kfile);
if ((o = open(kfile, O_WRONLY)) < 0)
error(kfile);
/* read exec header */
if ((fread(&exec, sizeof(exec), 1, f)) != 1)
badfmt("no exec header");
if (N_BADMAG(exec))
badfmt("bad magic number");
if (exec.a_syms == 0)
badfmt("stripped");
(void)fstat(fileno(f), &stb);
if (stb.st_size < N_STROFF(exec) + sizeof(off_t))
badfmt("no string table");
/* seek to and read the symbol table */
sa = N_SYMOFF(exec);
(void)fseek(f, sa, SEEK_SET);
n = exec.a_syms;
if (!(symtab = (struct nlist *)malloc(n)))
error(NULL);
if (fread((void *)symtab, 1, n, f) != n)
badfmt("corrupted symbol table");
/* read string table size and string table */
if (fread((void *)&strtabsize, sizeof(int), 1, f) != 1 ||
strtabsize <= 0)
badfmt("corrupted string table");
strings = malloc(strtabsize);
if (strings == NULL)
error(NULL);
/*
* Subtract four from strtabsize since strtabsize includes itself,
* and we've already read it.
*/
if (fread(strings, 1, strtabsize - sizeof(int), f) !=
strtabsize - sizeof(int))
badfmt("corrupted string table");
newtab = (struct nlist *)malloc(n);
if (newtab == (struct nlist *)NULL)
error(NULL);
i = n / sizeof(struct nlist);
reorder(symtab, newtab, i);
free((void *)symtab);
symtab = newtab;
newstrings = malloc(strtabsize);
if (newstrings == NULL)
error(NULL);
t = newstrings;
for (symp = symtab; --i >= 0; symp++) {
if (symp->n_un.n_strx == 0)
continue;
if (small && inlist(symp) < 0) continue;
symp->n_un.n_strx -= sizeof(int);
(void)strcpy(t, &strings[symp->n_un.n_strx]);
symp->n_un.n_strx = (t - newstrings) + sizeof(int);
t += strlen(t) + 1;
}
/* update shrunk sizes */
if(small) {
strtabsize = t - newstrings + sizeof(int);
n = symfound * sizeof(struct nlist);
/* fix exec sym size */
(void)lseek(o, 0, SEEK_SET);
exec.a_syms = n;
if (write(o, (void *)&exec, sizeof(exec)) != sizeof(exec))
error(kfile);
}
(void)lseek(o, sa, SEEK_SET);
if (write(o, (void *)symtab, n) != n)
error(kfile);
if (write(o, (void *)&strtabsize, sizeof(int)) != sizeof(int))
error(kfile);
if (write(o, newstrings, strtabsize - sizeof(int)) !=
strtabsize - sizeof(int))
error(kfile);
if (small) ftruncate(o, lseek(o, 0, SEEK_CUR));
if ((i = nsym - symfound) > 0) {
(void)printf("symorder: %d symbol%s not found:\n",
i, i == 1 ? "" : "s");
for (i = 0; i < nsym; i++)
if (order[i].n_value == 0)
printf("%s\n", order[i].n_un.n_name);
exit(NOTFOUNDEXIT);
}
exit(OKEXIT);
}
reorder(st1, st2, entries)
register struct nlist *st1, *st2;
int entries;
{
register struct nlist *p;
register int i, n;
for (p = st1, n = entries; --n >= 0; ++p)
if (inlist(p) != -1)
++symfound;
for (p = st2 + symfound, n = entries; --n >= 0; ++st1) {
i = inlist(st1);
if (i == -1)
*p++ = *st1;
else
st2[i] = *st1;
}
}
inlist(p)
register struct nlist *p;
{
register char *nam;
register struct nlist *op;
if (p->n_type & N_STAB)
return (-1);
if (p->n_un.n_strx == 0)
return (-1);
if (p->n_un.n_strx >= strtabsize)
badfmt("corrupted symbol table");
nam = &strings[p->n_un.n_strx - sizeof(int)];
for (op = &order[nsym]; --op >= order; ) {
if (strcmp(op->n_un.n_name, nam) != 0)
continue;
op->n_value = 1;
return (op - order);
}
return (-1);
}
badfmt(why)
char *why;
{
(void)fprintf(stderr,
"symorder: %s: %s: %s\n", kfile, why, strerror(EFTYPE));
exit(ERREXIT);
}
error(n)
char *n;
{
int sverr;
sverr = errno;
(void)fprintf(stderr, "symorder: ");
if (n)
(void)fprintf(stderr, "%s: ", n);
(void)fprintf(stderr, "%s\n", strerror(sverr));
exit(ERREXIT);
}
usage()
{
(void)fprintf(stderr, "usage: symorder [-t] symlist file\n");
exit(ERREXIT);
}

4
usr.sbin/dbsym/Makefile Normal file
View File

@ -0,0 +1,4 @@
PROG= dbsym
NOMAN= noman
.include <bsd.prog.mk>

192
usr.sbin/dbsym/dbsym.c Normal file
View File

@ -0,0 +1,192 @@
/* Written by Pace Willisson (pace@blitz.com)
* and placed in the public domain.
*/
#include <stdio.h>
#include <a.out.h>
char *malloc ();
#define FILE_OFFSET(vadr) (((vadr) & ~0xff000000)-N_DATADDR(hdr)+N_DATOFF(hdr))
struct nlist *old_syms;
int num_old_syms;
char *old_strtab;
int old_strtab_size;
struct nlist *new_syms;
int num_new_syms;
int new_syms_bytes;
char *new_strtab;
int new_strtab_size;
int db_symtabsize_adr;
int db_symtab_adr;
int avail;
usage ()
{
fprintf (stderr, "usage: dbsym file\n");
exit (1);
}
struct exec hdr;
main (argc, argv)
char **argv;
{
FILE *f;
char *name;
extern int optind;
int c, i;
int need;
char *buf, *p;
struct nlist *nsp, *sp;
int len;
while ((c = getopt (argc, argv, "")) != EOF) {
switch (c) {
default:
usage ();
}
}
if (optind >= argc)
usage ();
name = argv[optind++];
if (optind != argc)
usage ();
if ((f = fopen (name, "r+")) == NULL) {
fprintf (stderr, "can't open %s\n", name);
exit (1);
}
if (fread ((char *)&hdr, sizeof hdr, 1, f) != 1) {
fprintf (stderr, "can't read header\n");
exit (1);
}
if (N_BADMAG (hdr)) {
fprintf (stderr, "bad magic number\n");
exit (1);
}
if (hdr.a_syms == 0) {
fprintf (stderr, "no symbols\n");
exit (1);
}
fseek (f, N_STROFF (hdr), 0);
if (fread ((char *)&old_strtab_size, sizeof (int), 1, f) != 1) {
fprintf (stderr, "can't read old strtab size\n");
exit (1);
}
if ((old_syms = (struct nlist *)malloc (hdr.a_syms)) == NULL
|| ((old_strtab = malloc (old_strtab_size)) == NULL)
|| ((new_syms = (struct nlist *)malloc (hdr.a_syms)) == NULL)
|| ((new_strtab = malloc (old_strtab_size)) == NULL)) {
fprintf (stderr, "out of memory\n");
exit (1);
}
fseek (f, N_SYMOFF (hdr), 0);
if (fread ((char *)old_syms, hdr.a_syms, 1, f) != 1) {
fprintf (stderr, "can't read symbols\n");
exit (1);
}
fseek (f, N_STROFF (hdr), 0);
if (fread ((char *)old_strtab, old_strtab_size, 1, f) != 1) {
fprintf (stderr, "can't read string table\n");
exit (1);
}
num_old_syms = hdr.a_syms / sizeof (struct nlist);
new_strtab_size = 4;
nsp = new_syms;
for (i = 0, sp = old_syms; i < num_old_syms; i++, sp++) {
if (sp->n_type & N_STAB)
continue;
if (sp->n_un.n_strx == 0)
continue;
if (sp->n_value < 0xfe000000)
continue;
if (sp->n_value >= 0xff000000)
continue;
name = old_strtab + sp->n_un.n_strx;
len = strlen (name);
if (len == 0)
continue;
if (len >= 2 && name[len - 2] == '.' && name[len - 1] == 'o')
continue;
if (strcmp (name, "gcc_compiled.") == 0)
continue;
*nsp = *sp;
nsp->n_un.n_strx = new_strtab_size;
strcpy (new_strtab + new_strtab_size, name);
new_strtab_size += len + 1;
nsp++;
if (strcmp (name, "_db_symtab") == 0)
db_symtab_adr = sp->n_value;
if (strcmp (name, "_db_symtabsize") == 0)
db_symtabsize_adr = sp->n_value;
}
if (db_symtab_adr == 0 || db_symtabsize_adr == 0) {
fprintf (stderr, "couldn't find db_symtab symbols\n");
exit (1);
}
*(int *)new_strtab = new_strtab_size;
num_new_syms = nsp - new_syms;
new_syms_bytes = num_new_syms * sizeof (struct nlist);
need = sizeof (int)
+ num_new_syms * sizeof (struct nlist)
+ new_strtab_size;
fseek (f, FILE_OFFSET (db_symtabsize_adr), 0);
if (fread ((char *)&avail, sizeof (int), 1, f) != 1) {
fprintf (stderr, "can't read symtabsize\n");
exit (1);
}
printf ("dbsym: need %d; avail %d\n", need, avail);
if (need > avail) {
fprintf (stderr, "not enough room in db_symtab array\n");
exit (1);
}
fseek (f, FILE_OFFSET (db_symtab_adr), 0);
fwrite ((char *)&new_syms_bytes, sizeof (int), 1, f);
fwrite ((char *)new_syms, new_syms_bytes, 1, f);
fwrite (new_strtab, new_strtab_size, 1, f);
fflush (f);
if (feof (f) || ferror (f)) {
fprintf (stderr, "write error\n");
exit (1);
}
exit (0);
}

View File

@ -0,0 +1,5 @@
# @(#)Makefile 0.1 (RGrimes) 4/4/93
SUBDIR= tcpdump tcpslice
.include <bsd.subdir.mk>

View File

@ -0,0 +1,3 @@
# @(#)Makefile.inc 5.1 (Berkeley) 5/11/90
BINDIR?= /usr/local/bin

View File

@ -0,0 +1,24 @@
# @(#)Makefile 0.1 (RWGrimes) 3/24/93
PROG= tcpdump
CFLAGS+=-DCSLIP -I.
MAN1= tcpdump.0
SRCS= version.c addrtoname.c bpf_dump.c bpf_filter.c bpf_image.c etherent.c \
gencode.c inet.c md.c nametoaddr.c optimize.c os.c pcap.c \
print-arp.c print-atalk.c print-bootp.c print-domain.c \
print-egp.c print-ether.c print-fddi.c print-icmp.c print-ip.c \
print-nfs.c print-ntp.c print-null.c print-ospf.c print-ppp.c \
print-rip.c print-sl.c print-snmp.c print-sunrpc.c print-tcp.c \
print-tftp.c print-udp.c savefile.c tcpdump.c tcpgram.c \
tcplex.c util.c
.PATH: /sys/net
CLEANFILES+= tcpgram.c tcplex.c y.tab.h y.tab.c version.c version.h
version.c version.h: VERSION
rm -f version.c ; \
sed 's/.*/char version[] = "&";/' $(.CURDIR)/VERSION > version.c
set `sed 's/\([0-9]*\)\.\([0-9]*\).*/\1 \2/' $(.CURDIR)/VERSION` ; \
{ echo '#define VERSION_MAJOR' $$1 ; \
echo '#define VERSION_MINOR' $$2 ; } > version.h
.include <bsd.prog.mk>

View File

@ -0,0 +1 @@
2.2.1

View File

@ -0,0 +1,478 @@
/*
* Copyright (c) 1988, 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Internet, ethernet, port, and protocol string to address
* and address to string conversion routines
*/
#ifndef lint
static char rcsid[] =
"@(#) $Header: addrtoname.c,v 1.14 92/05/25 14:29:07 mccanne Exp $ (LBL)";
#endif
#include <stdio.h>
#include <strings.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <arpa/inet.h>
#include <signal.h>
#include "interface.h"
#include "addrtoname.h"
#include "nametoaddr.h"
#include "etherent.h"
/*
* hash tables for whatever-to-name translations
*/
#define HASHNAMESIZE 4096
struct hnamemem {
u_long addr;
char *name;
struct hnamemem *nxt;
};
struct hnamemem hnametable[HASHNAMESIZE];
struct hnamemem tporttable[HASHNAMESIZE];
struct hnamemem uporttable[HASHNAMESIZE];
struct hnamemem eprototable[HASHNAMESIZE];
struct enamemem {
u_short e_addr0;
u_short e_addr1;
u_short e_addr2;
char *e_name;
struct enamemem *e_nxt;
};
struct enamemem enametable[HASHNAMESIZE];
/*
* A faster replacement for inet_ntoa().
*/
char *
intoa(addr)
u_long addr;
{
register char *cp;
register u_int byte;
register int n;
static char buf[sizeof(".xxx.xxx.xxx.xxx")];
NTOHL(addr);
cp = &buf[sizeof buf];
*--cp = '\0';
n = 4;
do {
byte = addr & 0xff;
*--cp = byte % 10 + '0';
byte /= 10;
if (byte > 0) {
*--cp = byte % 10 + '0';
byte /= 10;
if (byte > 0)
*--cp = byte + '0';
}
*--cp = '.';
addr >>= 8;
} while (--n > 0);
return cp + 1;
}
static u_long f_netmask;
static u_long f_localnet;
static u_long netmask;
/*
* "getname" is written in this atrocious way to make sure we don't
* wait forever while trying to get hostnames from yp.
*/
#include <setjmp.h>
jmp_buf getname_env;
static void
nohostname()
{
longjmp(getname_env, 1);
}
/*
* Return a name for the IP address pointed to by ap. This address
* is assumed to be in network byte order.
*/
char *
getname(ap)
u_char *ap;
{
register struct hnamemem *p;
register struct hostent *hp;
register char *cp;
u_long addr;
#ifndef TCPDUMP_ALIGN
addr = *(u_long *)ap;
#else
/*
* Deal with alignment.
*/
switch ((int)ap & 3) {
case 0:
addr = *(u_long *)ap;
break;
case 2:
#if BYTE_ORDER == LITTLE_ENDIAN
addr = ((u_long)*(u_short *)(ap + 2) << 16) |
(u_long)*(u_short *)ap;
#else
addr = ((u_long)*(u_short *)ap << 16) |
(u_long)*(u_short *)(ap + 2);
#endif
break;
default:
#if BYTE_ORDER == LITTLE_ENDIAN
addr = ((u_long)ap[0] << 24) |
((u_long)ap[1] << 16) |
((u_long)ap[2] << 8) |
(u_long)ap[3];
#else
addr = ((u_long)ap[3] << 24) |
((u_long)ap[2] << 16) |
((u_long)ap[1] << 8) |
(u_long)ap[0];
#endif
break;
}
#endif
p = &hnametable[addr & (HASHNAMESIZE-1)];
for (; p->nxt; p = p->nxt) {
if (p->addr == addr)
return (p->name);
}
p->addr = addr;
p->nxt = (struct hnamemem *)calloc(1, sizeof (*p));
/*
* Only print names when:
* (1) -n was not given.
* (2) Address is foreign and -f was given. If -f was not
* present, f_netmask and f_local are 0 and the second
* test will succeed.
* (3) The host portion is not 0 (i.e., a network address).
* (4) The host portion is not broadcast.
*/
if (!nflag && (addr & f_netmask) == f_localnet
&& (addr &~ netmask) != 0 && (addr | netmask) != 0xffffffff) {
if (!setjmp(getname_env)) {
(void)signal(SIGALRM, nohostname);
(void)alarm(20);
hp = gethostbyaddr((char *)&addr, 4, AF_INET);
(void)alarm(0);
if (hp) {
char *index();
char *dotp;
u_int len = strlen(hp->h_name) + 1;
p->name = (char *)malloc(len);
(void)strcpy(p->name, hp->h_name);
if (Nflag) {
/* Remove domain qualifications */
dotp = index(p->name, '.');
if (dotp)
*dotp = 0;
}
return (p->name);
}
}
}
cp = intoa(addr);
p->name = (char *)malloc((unsigned)(strlen(cp) + 1));
(void)strcpy(p->name, cp);
return (p->name);
}
static char hex[] = "0123456789abcdef";
/* Find the hash node that corresponds the ether address 'ep'. */
static inline struct enamemem *
lookup_emem(ep)
u_char *ep;
{
register u_int i, j, k;
struct enamemem *tp;
k = (ep[0] << 8) | ep[1];
j = (ep[2] << 8) | ep[3];
i = (ep[4] << 8) | ep[5];
tp = &enametable[(i ^ j) & (HASHNAMESIZE-1)];
while (tp->e_nxt)
if (tp->e_addr0 == i &&
tp->e_addr1 == j &&
tp->e_addr2 == k)
return tp;
else
tp = tp->e_nxt;
tp->e_addr0 = i;
tp->e_addr1 = j;
tp->e_addr2 = k;
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
return tp;
}
char *
etheraddr_string(ep)
register u_char *ep;
{
register u_int i, j;
register char *cp;
register struct enamemem *tp;
tp = lookup_emem(ep);
if (tp->e_name)
return tp->e_name;
#ifdef ETHER_SERVICE
if (!nflag) {
cp = ETHER_ntohost(ep);
if (cp) {
tp->e_name = cp;
return cp;
}
}
#endif
tp->e_name = cp = (char *)malloc(sizeof("00:00:00:00:00:00"));
if (j = *ep >> 4)
*cp++ = hex[j];
*cp++ = hex[*ep++ & 0xf];
for (i = 5; (int)--i >= 0;) {
*cp++ = ':';
if (j = *ep >> 4)
*cp++ = hex[j];
*cp++ = hex[*ep++ & 0xf];
}
*cp = '\0';
return (tp->e_name);
}
char *
etherproto_string(port)
u_short port;
{
register char *cp;
register struct hnamemem *tp;
register u_long i = port;
for (tp = &eprototable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
if (tp->addr == i)
return (tp->name);
tp->name = cp = (char *)malloc(sizeof("0000"));
tp->addr = i;
tp->nxt = (struct hnamemem *)calloc(1, sizeof (*tp));
NTOHS(port);
*cp++ = hex[port >> 12 & 0xf];
*cp++ = hex[port >> 8 & 0xf];
*cp++ = hex[port >> 4 & 0xf];
*cp++ = hex[port & 0xf];
*cp++ = '\0';
return (tp->name);
}
char *
tcpport_string(port)
u_short port;
{
register struct hnamemem *tp;
register int i = port;
for (tp = &tporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
if (tp->addr == i)
return (tp->name);
tp->name = (char *)malloc(sizeof("00000"));
tp->addr = i;
tp->nxt = (struct hnamemem *)calloc(1, sizeof (*tp));
(void)sprintf(tp->name, "%d", i);
return (tp->name);
}
char *
udpport_string(port)
register u_short port;
{
register struct hnamemem *tp;
register int i = port;
for (tp = &uporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
if (tp->addr == i)
return (tp->name);
tp->name = (char *)malloc(sizeof("00000"));
tp->addr = i;
tp->nxt = (struct hnamemem *)calloc(1, sizeof(*tp));
(void)sprintf(tp->name, "%d", i);
return (tp->name);
}
static void
init_servarray()
{
struct servent *sv;
register struct hnamemem *table;
register int i;
while (sv = getservent()) {
NTOHS(sv->s_port);
i = sv->s_port & (HASHNAMESIZE-1);
if (strcmp(sv->s_proto, "tcp") == 0)
table = &tporttable[i];
else if (strcmp(sv->s_proto, "udp") == 0)
table = &uporttable[i];
else
continue;
while (table->name)
table = table->nxt;
if (nflag) {
char buf[32];
(void)sprintf(buf, "%d", sv->s_port);
table->name = (char *)malloc((unsigned)strlen(buf)+1);
(void)strcpy(table->name, buf);
} else {
table->name =
(char *)malloc((unsigned)strlen(sv->s_name)+1);
(void)strcpy(table->name, sv->s_name);
}
table->addr = sv->s_port;
table->nxt = (struct hnamemem *)calloc(1, sizeof(*table));
}
endservent();
}
#include "etherproto.h"
/* Static data base of ether protocol types. */
struct eproto eproto_db[] = {
{ "pup", ETHERTYPE_PUP },
{ "xns", ETHERTYPE_NS },
{ "ip", ETHERTYPE_IP },
{ "arp", ETHERTYPE_ARP },
{ "rarp", ETHERTYPE_REVARP },
{ "sprite", ETHERTYPE_SPRITE },
{ "mopdl", ETHERTYPE_MOPDL },
{ "moprc", ETHERTYPE_MOPRC },
{ "decnet", ETHERTYPE_DN },
{ "lat", ETHERTYPE_LAT },
{ "lanbridge", ETHERTYPE_LANBRIDGE },
{ "vexp", ETHERTYPE_VEXP },
{ "vprod", ETHERTYPE_VPROD },
{ "atalk", ETHERTYPE_ATALK },
{ "atalkarp", ETHERTYPE_AARP },
{ "loopback", ETHERTYPE_LOOPBACK },
{ (char *)0, 0 }
};
static void
init_eprotoarray()
{
register int i;
register struct hnamemem *table;
for (i = 0; eproto_db[i].s; i++) {
int j = ntohs(eproto_db[i].p) & (HASHNAMESIZE-1);
table = &eprototable[j];
while (table->name)
table = table->nxt;
table->name = eproto_db[i].s;
table->addr = ntohs(eproto_db[i].p);
table->nxt = (struct hnamemem *)calloc(1, sizeof(*table));
}
}
static void
init_etherarray()
{
#ifndef ETHER_SERVICE
FILE *fp;
struct etherent *ep;
struct enamemem *tp;
fp = fopen(ETHERS_FILE, "r");
if (fp == 0)
/* No data base; will have to settle for
numeric addresses. */
return;
while (ep = next_etherent(fp)) {
tp = lookup_emem(ep->addr);
tp->e_name = (char *)malloc((unsigned)strlen(ep->name)+1);
strcpy(tp->e_name, ep->name);
}
#endif
}
/*
* Initialize the address to name translation machinery. We map all
* non-local IP addresses to numeric addresses if fflag is true (i.e.,
* to prevent blocking on the nameserver). localnet is the IP address
* of the local network. mask is its subnet mask.
*/
void
init_addrtoname(fflag, localnet, mask)
int fflag;
u_long localnet;
u_long mask;
{
netmask = mask;
if (fflag) {
f_localnet = localnet;
f_netmask = mask;
}
if (nflag)
/*
* Simplest way to suppress names.
*/
return;
init_etherarray();
init_servarray();
init_eprotoarray();
}

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 1988, 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: addrtoname.h,v 1.5 92/03/17 13:41:37 mccanne Exp $ (LBL)
*/
/* Name to address translation routines. */
extern char *etheraddr_string();
extern char *etherproto_string();
extern char *tcpport_string();
extern char *udpport_string();
extern char *getname();
extern char *intoa();
extern void init_addrtoname();
extern void no_foreign_names();
#define ipaddr_string(p) getname((u_char *)(p))

View File

@ -0,0 +1,156 @@
/*
* Copyright (c) 1988 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX).
*
* @(#) $Header: appletalk.h,v 1.6 90/10/03 22:14:26 leres Exp $ (LBL)
*/
/* Datagram Delivery Protocol */
struct atDDP {
u_short length;
u_short checksum;
u_short dstNet;
u_short srcNet;
u_char dstNode;
u_char srcNode;
u_char dstSkt;
u_char srcSkt;
u_char type;
};
struct atShortDDP {
u_short length;
u_char dstSkt;
u_char srcSkt;
u_char type;
};
#define ddpMaxWKS 0x7F
#define ddpMaxData 586
#define ddpLengthMask 0x3FF
#define ddpHopShift 10
#define ddpSize 13 /* size of DDP header (avoid struct padding) */
#define ddpSSize 5
#define ddpWKS 128 /* boundary of DDP well known sockets */
#define ddpRTMP 1 /* RTMP type */
#define ddpRTMPrequest 5 /* RTMP request type */
#define ddpNBP 2 /* NBP type */
#define ddpATP 3 /* ATP type */
#define ddpECHO 4 /* ECHO type */
#define ddpIP 22 /* IP type */
#define ddpARP 23 /* ARP type */
#define ddpKLAP 0x4b /* Kinetics KLAP type */
/* AppleTalk Transaction Protocol */
struct atATP {
u_char control;
u_char bitmap;
u_short transID;
long userData;
};
#define atpReqCode 0x40
#define atpRspCode 0x80
#define atpRelCode 0xC0
#define atpXO 0x20
#define atpEOM 0x10
#define atpSTS 0x08
#define atpFlagMask 0x3F
#define atpControlMask 0xF8
#define atpMaxNum 8
#define atpMaxData 578
/* AppleTalk Echo Protocol */
struct atEcho {
u_char echoFunction;
u_char *echoData;
};
#define echoSkt 4 /* the echoer socket */
#define echoSize 1 /* size of echo header */
#define echoRequest 1 /* echo request */
#define echoReply 2 /* echo request */
/* Name Binding Protocol */
struct atNBP {
u_char control;
u_char id;
};
struct atNBPtuple {
u_short net;
u_char node;
u_char skt;
u_char enumerator;
};
#define nbpBrRq 0x10
#define nbpLkUp 0x20
#define nbpLkUpReply 0x30
#define nbpNIS 2
#define nbpTupleMax 15
#define nbpHeaderSize 2
#define nbpTupleSize 5;
/* Routing Table Maint. Protocol */
#define rtmpSkt 1 /* number of RTMP socket */
#define rtmpSize 4 /* minimum size */
#define rtmpTupleSize 3
/* Zone Information Protocol */
struct zipHeader {
u_char command;
u_char netcount;
};
#define zipHeaderSize 2
#define zipQuery 1
#define zipReply 2
#define zipTakedown 3
#define zipBringup 4
#define ddpZIP 6
#define zipSkt 6
#define GetMyZone 7
#define GetZoneList 8
/*
* UDP port range used for ddp-in-udp encapsulation is 16512-16639
* for client sockets (128-255) and 200-327 for server sockets
* (0-127). We also try to recognize the pre-April 88 server
* socket range of 768-895.
*/
#define atalk_port(p) \
(((unsigned)((p) - 16512) < 128) || \
((unsigned)((p) - 200) < 128) || \
((unsigned)((p) - 768) < 128))

View File

@ -0,0 +1,103 @@
/* @(#) $Header: bootp.h,v 1.2 90/05/29 21:29:16 leres Exp $ (LBL) */
/*
* Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
*
* This file specifies the "implementation-independent" BOOTP protocol
* information which is common to both client and server.
*
* Copyright 1988 by Carnegie Mellon.
*
* Permission to use, copy, modify, and distribute this program for any
* purpose and without fee is hereby granted, provided that this copyright
* and permission notice appear on all copies and supporting documentation,
* the name of Carnegie Mellon not be used in advertising or publicity
* pertaining to distribution of the program without specific prior
* permission, and notice be given in supporting documentation that copying
* and distribution is by permission of Carnegie Mellon and Stanford
* University. Carnegie Mellon makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
struct bootp {
unsigned char bp_op; /* packet opcode type */
unsigned char bp_htype; /* hardware addr type */
unsigned char bp_hlen; /* hardware addr length */
unsigned char bp_hops; /* gateway hops */
unsigned long bp_xid; /* transaction ID */
unsigned short bp_secs; /* seconds since boot began */
unsigned short bp_unused;
struct in_addr bp_ciaddr; /* client IP address */
struct in_addr bp_yiaddr; /* 'your' IP address */
struct in_addr bp_siaddr; /* server IP address */
struct in_addr bp_giaddr; /* gateway IP address */
unsigned char bp_chaddr[16]; /* client hardware address */
unsigned char bp_sname[64]; /* server host name */
unsigned char bp_file[128]; /* boot file name */
unsigned char bp_vend[64]; /* vendor-specific area */
};
/*
* UDP port numbers, server and client.
*/
#define IPPORT_BOOTPS 67
#define IPPORT_BOOTPC 68
#define BOOTREPLY 2
#define BOOTREQUEST 1
/*
* Vendor magic cookie (v_magic) for CMU
*/
#define VM_CMU "CMU"
/*
* Vendor magic cookie (v_magic) for RFC1048
*/
#define VM_RFC1048 { 99, 130, 83, 99 }
/*
* RFC1048 tag values used to specify what information is being supplied in
* the vendor field of the packet.
*/
#define TAG_PAD ((unsigned char) 0)
#define TAG_SUBNET_MASK ((unsigned char) 1)
#define TAG_TIME_OFFSET ((unsigned char) 2)
#define TAG_GATEWAY ((unsigned char) 3)
#define TAG_TIME_SERVER ((unsigned char) 4)
#define TAG_NAME_SERVER ((unsigned char) 5)
#define TAG_DOMAIN_SERVER ((unsigned char) 6)
#define TAG_LOG_SERVER ((unsigned char) 7)
#define TAG_COOKIE_SERVER ((unsigned char) 8)
#define TAG_LPR_SERVER ((unsigned char) 9)
#define TAG_IMPRESS_SERVER ((unsigned char) 10)
#define TAG_RLP_SERVER ((unsigned char) 11)
#define TAG_HOSTNAME ((unsigned char) 12)
#define TAG_BOOTSIZE ((unsigned char) 13)
#define TAG_END ((unsigned char) 255)
/*
* "vendor" data permitted for CMU bootp clients.
*/
struct cmu_vend {
unsigned char v_magic[4]; /* magic number */
unsigned long v_flags; /* flags/opcodes, etc. */
struct in_addr v_smask; /* Subnet mask */
struct in_addr v_dgate; /* Default gateway */
struct in_addr v_dns1, v_dns2; /* Domain name servers */
struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */
struct in_addr v_ts1, v_ts2; /* Time servers */
unsigned char v_unused[25]; /* currently unused */
};
/* v_flags values */
#define VF_SMASK 1 /* Subnet mask field contains valid data */

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static char rcsid[] =
"@(#) $Header: bpf_dump.c,v 1.1 92/01/29 13:25:30 mccanne Exp $ (LBL)";
#endif
#include <sys/types.h>
#include <sys/time.h>
#include <net/bpf.h>
void
bpf_dump(p, option)
struct bpf_program *p;
int option;
{
struct bpf_insn *insn;
int i;
int n = p->bf_len;
insn = p->bf_insns;
if (option > 2) {
printf("%d\n", n);
for (i = 0; i < n; ++insn, ++i) {
printf("%lu %lu %lu %lu\n", insn->code,
insn->jt, insn->jf, insn->k);
}
return ;
}
if (option > 1) {
for (i = 0; i < n; ++insn, ++i)
printf("{ 0x%x, %d, %d, 0x%08x },\n",
insn->code, insn->jt, insn->jf, insn->k);
return;
}
for (i = 0; i < n; ++insn, ++i) {
#ifdef BDEBUG
extern int bids[];
printf(bids[i] > 0 ? "[%02d]" : " -- ", bids[i] - 1);
#endif
puts(bpf_image(insn, i));
}
}

View File

@ -0,0 +1,282 @@
/*
* Copyright (c) 1988-1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static char rcsid[] =
"@(#) $Header: bpf_image.c,v 1.10 92/01/26 21:01:16 mccanne Exp $ (LBL)";
#endif
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <net/bpf.h>
char *
bpf_image(p, n)
struct bpf_insn *p;
int n;
{
int v;
char *fmt, *op;
static char image[256];
char operand[64];
v = p->k;
switch (p->code) {
default:
op = "unimp";
fmt = "0x%x";
v = p->code;
break;
case BPF_RET|BPF_K:
op = "ret";
fmt = "#%d";
break;
case BPF_RET|BPF_A:
op = "ret";
fmt = "";
break;
case BPF_LD|BPF_W|BPF_ABS:
op = "ld";
fmt = "[%d]";
break;
case BPF_LD|BPF_H|BPF_ABS:
op = "ldh";
fmt = "[%d]";
break;
case BPF_LD|BPF_B|BPF_ABS:
op = "ldb";
fmt = "[%d]";
break;
case BPF_LD|BPF_W|BPF_LEN:
op = "ld";
fmt = "#pktlen";
break;
case BPF_LD|BPF_W|BPF_IND:
op = "ld";
fmt = "[x + %d]";
break;
case BPF_LD|BPF_H|BPF_IND:
op = "ldh";
fmt = "[x + %d]";
break;
case BPF_LD|BPF_B|BPF_IND:
op = "ldb";
fmt = "[x + %d]";
break;
case BPF_LD|BPF_IMM:
op = "ld";
fmt = "#0x%x";
break;
case BPF_LDX|BPF_IMM:
op = "ldx";
fmt = "#0x%x";
break;
case BPF_LDX|BPF_MSH|BPF_B:
op = "ldxb";
fmt = "4*([%d]&0xf)";
break;
case BPF_LD|BPF_MEM:
op = "ld";
fmt = "M[%d]";
break;
case BPF_LDX|BPF_MEM:
op = "ldx";
fmt = "M[%d]";
break;
case BPF_ST:
op = "st";
fmt = "M[%d]";
break;
case BPF_STX:
op = "stx";
fmt = "M[%d]";
break;
case BPF_JMP|BPF_JA:
op = "ja";
fmt = "%d";
v = n + p->k;
break;
case BPF_JMP|BPF_JGT|BPF_K:
op = "jgt";
fmt = "#0x%x";
break;
case BPF_JMP|BPF_JGE|BPF_K:
op = "jge";
fmt = "#0x%x";
break;
case BPF_JMP|BPF_JEQ|BPF_K:
op = "jeq";
fmt = "#0x%x";
break;
case BPF_JMP|BPF_JSET|BPF_K:
op = "jset";
fmt = "#0x%x";
break;
case BPF_JMP|BPF_JGT|BPF_X:
op = "jgt";
fmt = "x";
break;
case BPF_JMP|BPF_JGE|BPF_X:
op = "jge";
fmt = "x";
break;
case BPF_JMP|BPF_JEQ|BPF_X:
op = "jeq";
fmt = "x";
break;
case BPF_JMP|BPF_JSET|BPF_X:
op = "jset";
fmt = "x";
break;
case BPF_ALU|BPF_ADD|BPF_X:
op = "add";
fmt = "x";
break;
case BPF_ALU|BPF_SUB|BPF_X:
op = "sub";
fmt = "x";
break;
case BPF_ALU|BPF_MUL|BPF_X:
op = "mul";
fmt = "x";
break;
case BPF_ALU|BPF_DIV|BPF_X:
op = "div";
fmt = "x";
break;
case BPF_ALU|BPF_AND|BPF_X:
op = "and";
fmt = "x";
break;
case BPF_ALU|BPF_OR|BPF_X:
op = "or";
fmt = "x";
break;
case BPF_ALU|BPF_LSH|BPF_X:
op = "lsh";
fmt = "x";
break;
case BPF_ALU|BPF_RSH|BPF_X:
op = "rsh";
fmt = "x";
break;
case BPF_ALU|BPF_ADD|BPF_K:
op = "add";
fmt = "#%d";
break;
case BPF_ALU|BPF_SUB|BPF_K:
op = "sub";
fmt = "#%d";
break;
case BPF_ALU|BPF_MUL|BPF_K:
op = "mul";
fmt = "#%d";
break;
case BPF_ALU|BPF_DIV|BPF_K:
op = "div";
fmt = "#%d";
break;
case BPF_ALU|BPF_AND|BPF_K:
op = "and";
fmt = "#%d";
break;
case BPF_ALU|BPF_OR|BPF_K:
op = "or";
fmt = "#%d";
break;
case BPF_ALU|BPF_LSH|BPF_K:
op = "lsh";
fmt = "#%d";
break;
case BPF_ALU|BPF_RSH|BPF_K:
op = "rsh";
fmt = "#%d";
break;
case BPF_ALU|BPF_NEG:
op = "neg";
fmt = "";
break;
case BPF_MISC|BPF_TAX:
op = "tax";
fmt = "";
break;
case BPF_MISC|BPF_TXA:
op = "txa";
fmt = "";
break;
}
(void)sprintf(operand, fmt, v);
(void)sprintf(image,
(BPF_CLASS(p->code) == BPF_JMP &&
BPF_OP(p->code) != BPF_JA) ?
"(%03d) %-8s %-16s jt %d\tjf %d"
: "(%03d) %-8s %s",
n, op, operand, n + 1 + p->jt, n + 1 + p->jf);
return image;
}

View File

@ -0,0 +1,144 @@
/*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static char rcsid[] =
"@(#) $Header: etherent.c,v 1.2 90/09/20 23:16:06 mccanne Exp $ (LBL)";
#endif
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#include "interface.h"
#ifndef ETHER_SERVICE
#include "etherent.h"
/* Hex digit to integer. */
static inline int
xdtoi(c)
{
if (isdigit(c))
return c - '0';
else if (islower(c))
return c - 'a' + 10;
else
return c - 'A' + 10;
}
static inline int
skip_space(f)
FILE *f;
{
int c;
do {
c = getc(f);
} while (isspace(c) && c != '\n');
return c;
}
static inline int
skip_line(f)
FILE *f;
{
int c;
do
c = getc(f);
while (c != '\n' && c != EOF);
return c;
}
struct etherent *
next_etherent(fp)
FILE *fp;
{
register int c, d, i;
char *bp;
static struct etherent e;
static int nline = 1;
top:
while (nline) {
/* Find addr */
c = skip_space(fp);
if (c == '\n')
continue;
/* If this is a comment, or first thing on line
cannot be etehrnet address, skip the line. */
else if (!isxdigit(c))
c = skip_line(fp);
else {
/* must be the start of an address */
for (i = 0; i < 6; i += 1) {
d = xdtoi(c);
c = getc(fp);
if (c != ':') {
d <<= 4;
d |= xdtoi(c);
c = getc(fp);
}
e.addr[i] = d;
if (c != ':')
break;
c = getc(fp);
}
nline = 0;
}
if (c == EOF)
return 0;
}
/* If we started a new line, 'c' holds the char past the ether addr,
which we assume is white space. If we are continuning a line,
'c' is garbage. In either case, we can throw it away. */
c = skip_space(fp);
if (c == '\n') {
nline = 1;
goto top;
}
else if (c == '#') {
(void)skip_line(fp);
nline = 1;
goto top;
}
else if (c == EOF)
return 0;
/* Must be a name. */
bp = e.name;
/* Use 'd' to prevent buffer overflow. */
d = sizeof(e.name) - 1;
do {
*bp++ = c;
c = getc(fp);
} while (!isspace(c) && c != EOF && --d > 0);
*bp = '\0';
if (c == '\n')
nline = 1;
return &e;
}
#endif

View File

@ -0,0 +1,34 @@
/*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* @(#) $Header: etherent.h,v 1.2 90/09/20 23:16:17 mccanne Exp $ (LBL)
*/
/* File name of ethernet address data base. */
#define ETHERS_FILE "/etc/ethers"
struct etherent {
u_char addr[6];
char name[122];
};
struct etherent *next_etherent();

Some files were not shown because too many files have changed in this diff Show More