From: Christoph Egger Date: Thu, 4 Dec 2008 19:08:24 +0000 (+0100) Subject: original 1.0.1 release X-Git-Tag: origin/1.0.1 X-Git-Url: https://repo.or.cz/w/xwelltris.git/commitdiff_plain/b3b0f005bcf1563519d1b9f42d5ad8801f8e0ded original 1.0.1 release --- b3b0f005bcf1563519d1b9f42d5ad8801f8e0ded diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..3bea4cf --- /dev/null +++ b/AUTHORS @@ -0,0 +1,11 @@ + X Welltris Project (tetris like game). + +Main programmer, maintainer and author: + Leonid V. Khramov + +Additional help from: + Irina V. Khramova + +Designer and Web-master: + Leonid V. Khramov + \ No newline at end of file diff --git a/Changelog b/Changelog new file mode 100644 index 0000000..d77f6f7 --- /dev/null +++ b/Changelog @@ -0,0 +1,14 @@ +============================================================================ + Changes for XWelltris project +============================================================================ + +Version is 1.0.0 (11-03-2002): + + -Initial public release + + + + 31-03-2002 Leo + + + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..58bfbe8 --- /dev/null +++ b/INSTALL @@ -0,0 +1,61 @@ +============================================================================== + XWelltris Project - tetris like game +============================================================================== + +1. Installation from source tarball (xwelltris-version.src.tar.gz): + +First of all you need to unpack tarball, use this command : + + gunzip -c xwelltris-version.src.tar.gz | tar xvf - + +After that you can see directory named 'xwelltris-version', change your +current dir to it: + + cd xwelltris-version + +Then you need to configure and make the game: + + ./configure + make + +The default installation path is in /usr/bin and /usr/share/xwelltris dirs. +If you want to install to another dirs, for example in your home subdirs, +you need to say about this in configure: + + ./configure --prefix=/home/user + make + +After make is done with no errors, then install the game: + + make install + +Be sure that your $prefix/bin directory is in your $PATH environment variable. + +That's all, now you can enjoy the game by typing: + + xwelltris + +P.S: XWelltris is the X Window game so it needs Xlibs and X headers to compile +Be shure that you have it installed. + +============================================================================== + +2. Installation from binaries tarball. + +You need to gain root account, then change you dir to '/': + + cd / + gunzip -c /dir_of_xwelltris_tarball/xwelltris-version.tar.gz | tar xvf - + +That's it! + +Now type 'xwelltris' under X Window for playing. + +============================================================================== + +P.S: If You like xwelltris, please, send me a letter with names of +country and city where you are playing the game. It's for my collection. + +Thank you. +Leo (31-03-2002) + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a43ea21 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, 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 show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice 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. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..9e1121a --- /dev/null +++ b/Makefile.in @@ -0,0 +1,52 @@ +# XWelltris - tetris like popular game +# +# Copyright (C) 2002 by Leo Khramov +# email: leo@xnc.dubna.su +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +@MCOMMON@ + + DATAFILES= \ + data/polyomino.dat \ + data/board2.gif \ + data/font2.gif \ + data/topnine.gif \ + data/wellcuts.gif \ + data/wellintro.gif + + SHARE_DATAFILES= \ + data/welltris.scores + + PROGRAM = xwelltris + +all:: $(PROGRAM) + +$(PROGRAM): FORCE + -(cd src && make) + +install: + $(INSD) $(INSTLIB) + $(INSTALL_DATA) $(DATAFILES) $(INSTLIB) + $(INSTALL_SHARE_DATA) $(SHARE_DATAFILES) $(INSTLIB) + $(INSTALL_PROGRAM) $(PROGRAM) $(INSTDIR) + +uninstall: + $(RM) -f $(INSTDIR)/$(PROGRAM) + $(RM) -rf $(INSTLIB) + +clean: + $(RM) -f $(PROGRAM) + -(cd src && make clean) + +FORCE: diff --git a/README b/README new file mode 100644 index 0000000..0ebd818 --- /dev/null +++ b/README @@ -0,0 +1,86 @@ + +============================================================================ + + XWelltris - tetris like game + +============================================================================ + +1. Introduction + + XWelltris is a tetris like popular game. The idea of this game was by + Pogitnov russian programmer. Imaging that you are looking into the glass + from the top. You see four walls and the bottom. The flat 2d figures falling + down from the walls one by one. You can move these figures from one wall to + another or rotate the figure. If the figure leave the wall it moves on the + bottom while another figure is pushed. You need to form full rows and/or + columns on the bottom. When you form such row it disappear and you receive + additional empty space on the bottom and scores :). The more rows disappear + at a time, the more scores you have. If you can't place the whole figure on + the bottom, then it stays on the wall and this wall became frozen (you can't + place figures on it) for a while. After n-th rows were successfuly cleared, + you will receive binus figure and goto to the next level - game speed will + be increased. You task is to play more longer and earn more scores. + +============================================================================ + +2. Installation of the game + + ./configure + make + make install + + More detail installation process described in 'INSTALL' file in this + directory. + +============================================================================ + +3. Playing + + Type 'xwelltris' from the X Window for playing the game. + First of all you see the options screen, where you can customize you game. + The options are: + + - Dutris, Tritris, Tetris, Pentris, Sixtris - game type that define a + number of piece the figure is. Dutris - figures from two pieces only. + Tritris from three pieces. Tetris from four and so on... + + - Mixed. Turn it on and you will play with mixed figures. For example if + you choose tetris type below, then you will play with figure from two, + three and four piece. If thhis option will be off then figures will be + only from four pieces. This option gives you easier game but less + scores. + + - Rotation. This option turn on inner rotation of the game board, one + by one on each level up. This is very funny and more harder to play. + And of couse if harder then more scores at a time :) + + - Next piece. This option turn on showing of next figure that will fall + down on the game board. It's allow you to know and have additional time + for thinking. Of couse if you turn it on you will have less scores. + + + Press 'New game' for playing, then type you name and enjoy playing. + 'Top nine' :) key shows high scores table of current game type (dutris,...) + + And 'Exit' will kill the game. + +============================================================================ + +4. Additional info + + XWelltris stores high scores table in the file named 'welltris.scores'. + First of all it search global welltris.scores in /usr/share/xwelltris. + If this file exists and writable then xwelltris uses it. Otherwise it + create your own welltris.scores in ~/.xwelltris directory + (in your home dir). If you want to clear scores table simple remove + welltris.scores file and xwelltris create it again. + +============================================================================ + +This game implementation is under GNU GPL2 license, so you can modify and +redistribute it with the rules described in 'LICENSE' file in this dir. + + + +(c) 2002 by Leonid V. Khramov aka Leo + diff --git a/README.keys b/README.keys new file mode 100644 index 0000000..f6bf16a --- /dev/null +++ b/README.keys @@ -0,0 +1,32 @@ +========================================================================= +Here are the keys in game XWelltris: + + Move figure right: + -Right Arrow + -Num pad '6' + -Main keyboard 'L' key + + Move figure left: + -Left Arrow + -Num pad '4' + -Main keyboard 'J' key + + Rotate figure: + -Up or Down Arrow + -Num pad '5' + -Main keyboard 'K' key + + Drop figure down: + -Space + -Num pad 'Insert' + + Pause/Unpause game: + -Main keyboard 'P' key + -Pause key + + Quit game: + -Main keyboard 'Q' key + -F10 key + -Escape key + +That's all. diff --git a/config.guess b/config.guess new file mode 100755 index 0000000..ba66165 --- /dev/null +++ b/config.guess @@ -0,0 +1,1371 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. + +timestamp='2001-04-20' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Written by Per Bothner . +# Please send patches to . +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + + +dummy=dummy-$$ +trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int dummy(){}" > $dummy.c + for c in cc gcc c89 ; do + ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 + if test $? = 0 ; then + CC_FOR_BUILD="$c"; break + fi + done + rm -f $dummy.c $dummy.o $dummy.rel + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 8/24/94.) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # Netbsd (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # Determine the machine/vendor (is the vendor relevant). + case "${UNAME_MACHINE}" in + amiga) machine=m68k-unknown ;; + arm32) machine=arm-unknown ;; + atari*) machine=m68k-atari ;; + sun3*) machine=m68k-sun ;; + mac68k) machine=m68k-apple ;; + macppc) machine=powerpc-apple ;; + hp3[0-9][05]) machine=m68k-hp ;; + ibmrt|romp-ibm) machine=romp-ibm ;; + *) machine=${UNAME_MACHINE}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE}" in + i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + cat <$dummy.s + .data +\$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text + .globl main + .align 4 + .ent main +main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main +EOF + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + case `./$dummy` in + 0-0) + UNAME_MACHINE="alpha" + ;; + 1-0) + UNAME_MACHINE="alphaev5" + ;; + 1-1) + UNAME_MACHINE="alphaev56" + ;; + 1-101) + UNAME_MACHINE="alphapca56" + ;; + 2-303) + UNAME_MACHINE="alphaev6" + ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; + esac + fi + rm -f $dummy.s $dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit 0;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy \ + && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + case "${HPUX_REV}" in + 11.[0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + esac ;; + esac + fi ;; + esac + if [ "${HP_ARCH}" = "" ]; then + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` + if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi + rm -f $dummy.c $dummy + fi ;; + esac + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + hppa*:OpenBSD:*:*) + echo hppa-unknown-openbsd + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3D:*:*:*) + echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i386-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit 0 ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + cat >$dummy.c < /* for printf() prototype */ +int main (int argc, char *argv[]) { +#else +int main (argc, argv) int argc; char *argv[]; { +#endif +#ifdef __MIPSEB__ + printf ("%s-unknown-linux-gnu\n", argv[1]); +#endif +#ifdef __MIPSEL__ + printf ("%sel-unknown-linux-gnu\n", argv[1]); +#endif + return 0; +} +EOF + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + ;; + ppc:Linux:*:*) + # Determine Lib Version + cat >$dummy.c < +#if defined(__GLIBC__) +extern char __libc_version[]; +extern char __libc_release[]; +#endif +main(argc, argv) + int argc; + char *argv[]; +{ +#if defined(__GLIBC__) + printf("%s %s\n", __libc_version, __libc_release); +#else + printf("unknown\n"); +#endif + return 0; +} +EOF + LIBC="" + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null + if test "$?" = 0 ; then + ./$dummy | grep 1\.99 > /dev/null + if test "$?" = 0 ; then LIBC="libc1" ; fi + fi + rm -f $dummy.c $dummy + echo powerpc-unknown-linux-gnu${LIBC} + exit 0 ;; + alpha:Linux:*:*) + cat <$dummy.s + .data + \$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + .text + .globl main + .align 4 + .ent main + main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main +EOF + LIBC="" + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + case `./$dummy` in + 0-0) UNAME_MACHINE="alpha" ;; + 1-0) UNAME_MACHINE="alphaev5" ;; + 1-1) UNAME_MACHINE="alphaev56" ;; + 1-101) UNAME_MACHINE="alphapca56" ;; + 2-303) UNAME_MACHINE="alphaev6" ;; + 2-307) UNAME_MACHINE="alphaev67" ;; + esac + objdump --private-headers $dummy | \ + grep ld.so.1 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f $dummy.s $dummy + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit 0 ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit 0 ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit 0 ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit 0 ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + ld_supported_emulations=`cd /; ld --help 2>&1 \ + | sed -ne '/supported emulations:/!d + s/[ ][ ]*/ /g + s/.*supported emulations: *// + s/ .*// + p'` + case "$ld_supported_emulations" in + i*86linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 + ;; + elf_i*86) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + i*86coff) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 + ;; + esac + # Either a pre-BFD a.out linker (linux-gnuoldld) + # or one that does not give us useful --help. + # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. + # If ld does not provide *any* "supported emulations:" + # that means it is gnuoldld. + test -z "$ld_supported_emulations" && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 + case "${UNAME_MACHINE}" in + i*86) + VENDOR=pc; + ;; + *) + VENDOR=unknown; + ;; + esac + # Determine whether the default compiler is a.out or elf + cat >$dummy.c < +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif +#ifdef __ELF__ +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +#else + printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); +#endif + return 0; +} +EOF + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; +# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions +# are messed up and put the nodename in both sysname and nodename. + i*86:DYNIX/ptx:4*:*) + echo i386-sequent-sysv4 + exit 0 ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i*86:*:5:7*) + # Fixed at (any) Pentium or better + UNAME_MACHINE=i586 + if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then + echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} + fi + exit 0 ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit 0 ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + echo `uname -p`-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + if test "${UNAME_MACHINE}" = "x86pc"; then + UNAME_MACHINE=pc + fi + echo `uname -p`-${UNAME_MACHINE}-nto-qnx + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-[KW]:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit 0 ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit 0 ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit 0 ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit 0 ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit 0 ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 +rm -f $dummy.c $dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config.status b/config.status new file mode 100755 index 0000000..a620633 --- /dev/null +++ b/config.status @@ -0,0 +1,379 @@ +#! /bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host condor.solvo.ru: +# +# ./configure --enable-debug --with-sdl +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: ./config.status [--recheck] [--version] [--help]" +for ac_option +do + case "$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running ${CONFIG_SHELL-/bin/sh} ./configure --enable-debug --with-sdl --no-create --no-recursion" + exec ${CONFIG_SHELL-/bin/sh} ./configure --enable-debug --with-sdl --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "./config.status generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "$ac_cs_usage"; exit 0 ;; + *) echo "$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=. +ac_given_INSTALL="/usr/bin/install -c" + +trap 'rm -fr src/Make.common src/makefile src/include/globals.h src/image/makefile Makefile src/include/config.h conftest*; exit 1' 1 2 15 + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\&%]/\\&/g; + s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF +/^[ ]*VPATH[ ]*=[^:]*$/d + +s%@SHELL@%/bin/sh%g +s%@CFLAGS@%-O%g +s%@CPPFLAGS@%%g +s%@CXXFLAGS@%-g -O2%g +s%@FFLAGS@%%g +s%@DEFS@%-DHAVE_CONFIG_H%g +s%@LDFLAGS@%-O%g +s%@LIBS@%-lm %g +s%@exec_prefix@%${prefix}%g +s%@prefix@%/usr%g +s%@program_transform_name@%s,x,x,%g +s%@bindir@%${exec_prefix}/bin%g +s%@sbindir@%${exec_prefix}/sbin%g +s%@libexecdir@%${exec_prefix}/libexec%g +s%@datadir@%${prefix}/share%g +s%@sysconfdir@%${prefix}/etc%g +s%@sharedstatedir@%${prefix}/com%g +s%@localstatedir@%${prefix}/var%g +s%@libdir@%${exec_prefix}/lib%g +s%@includedir@%${prefix}/include%g +s%@oldincludedir@%/usr/include%g +s%@infodir@%${prefix}/info%g +s%@mandir@%${prefix}/man%g +s%@host@%i686-pc-linux-gnu%g +s%@host_alias@%i686-pc-linux-gnu%g +s%@host_cpu@%i686%g +s%@host_vendor@%pc%g +s%@host_os@%linux-gnu%g +s%@CC@%gcc%g +s%@CPP@%gcc -E%g +s%@CXX@%c++%g +s%@INSTALL_PROGRAM@%${INSTALL}%g +s%@INSTALL_SCRIPT@%${INSTALL_PROGRAM}%g +s%@INSTALL_DATA@%${INSTALL} -m 644%g +s%@LN_S@%ln -s%g +s%@SET_MAKE@%%g +s%@RANLIB@%ranlib%g +s%@RM@%/bin/rm%g +s%@CP@%/bin/cp%g +s%@SHAREFLAGS@%%g +s%@LD_SHAREFLAGS@%%g +s%@PLUGINS@%%g +s%@DEB@%-g -DDEBUG_XNC%g +s%@IFACEOBJS@%$(SDLOBJS)%g +s%@IFACELIBS@%`sdl-config --libs` -lSDL_image%g +s%@IFACEINC@%`sdl-config --cflags` -I./sdl%g +s%@X_CFLAGS@%%g +s%@X_PRE_LIBS@%%g +s%@X_LIBS@%%g +s%@X_EXTRA_LIBS@%%g +s%@LIBOBJS@%%g +/@MCOMMON@/r ./src/Make.common +s%@MCOMMON@%%g + +CEOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi + +CONFIG_FILES=${CONFIG_FILES-" src/Make.common src/makefile src/include/globals.h src/image/makefile Makefile"} +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then + CONFIG_HEADERS="src/include/config.h" +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + cat > conftest.frag < conftest.out + rm -f conftest.in + mv conftest.out conftest.in + + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + + + +exit 0 diff --git a/config.sub b/config.sub new file mode 100755 index 0000000..a06a480 --- /dev/null +++ b/config.sub @@ -0,0 +1,1362 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. + +timestamp='2001-04-20' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit 0;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | storm-chaos* | os2-emx*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \ + | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \ + | pyramid | mn10200 | mn10300 | tron | a29k \ + | 580 | i960 | h8300 \ + | x86 | ppcbe | mipsbe | mipsle | shbe | shle \ + | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \ + | hppa64 \ + | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \ + | alphaev6[78] \ + | we32k | ns16k | clipper | i370 | sh | sh[34] \ + | powerpc | powerpcle \ + | 1750a | dsp16xx | pdp10 | pdp11 \ + | mips16 | mips64 | mipsel | mips64el \ + | mips64orion | mips64orionel | mipstx39 | mipstx39el \ + | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \ + | mips64vr5000 | miprs64vr5000el | mcore | s390 | s390x \ + | sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \ + | v850 | c4x \ + | thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \ + | pj | pjl | h8500) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | w65) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + # FIXME: clean up the formatting here. + vax-* | tahoe-* | i*86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \ + | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \ + | arm-* | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \ + | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ + | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \ + | xmp-* | ymp-* \ + | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \ + | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \ + | hppa2.0n-* | hppa64-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \ + | alphaev6[78]-* \ + | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \ + | clipper-* | orion-* \ + | sparclite-* | pdp10-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ + | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \ + | mips16-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \ + | mipstx39-* | mipstx39el-* | mcore-* \ + | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \ + | [cjt]90-* \ + | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \ + | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \ + | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [cjt]90) + basic_machine=${basic_machine}-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i686-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sparclite-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=t3e-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh3 | sh4) + basic_machine=sh-unknown + ;; + sparc | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + c4x*) + basic_machine=c4x-none + os=-coff + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto*) + os=-nto-qnx + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/configure b/configure new file mode 100755 index 0000000..499651e --- /dev/null +++ b/configure @@ -0,0 +1,3822 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_default_prefix=/usr +ac_help="$ac_help + --enable-debug Turn on debugging output" +ac_help="$ac_help + --with-sdl Turn on SDL support instead of X11" +ac_help="$ac_help + --with-x use the X Window System" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=src/main.cxx + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + +if test -z "${CFLAGS}"; then + if test -z "${CCOPTS}"; then + CCOPTS='-O' + fi + CFLAGS="$CCOPTS" +fi + + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + + +# Make sure we can run config.sub. +if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : +else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +fi + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:567: checking host system type" >&5 + +host_alias=$host +case "$host_alias" in +NONE) + case $nonopt in + NONE) + if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) host_alias=$nonopt ;; + esac ;; +esac + +host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$host" 1>&6 + +ARCH=`echo $host | sed 's/\([^-]*\)-[^-]*-\([^-]*\)/\1-\2/'` + + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:593: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:623: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:674: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:706: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 717 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:748: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:753: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:781: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + +echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6 +echo "configure:813: checking for POSIXized ISC" >&5 +if test -d /etc/conf/kconfig.d && + grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 +then + echo "$ac_t""yes" 1>&6 + ISC=yes # If later tests want to check for ISC. + cat >> confdefs.h <<\EOF +#define _POSIX_SOURCE 1 +EOF + + if test "$GCC" = yes; then + CC="$CC -posix" + else + CC="$CC -Xp" + fi +else + echo "$ac_t""no" 1>&6 + ISC= +fi + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:834: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:855: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:872: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:889: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +echo $ac_n "checking for AIX""... $ac_c" 1>&6 +echo "configure:914: checking for AIX" >&5 +cat > conftest.$ac_ext <&5 | + egrep "yes" >/dev/null 2>&1; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF +#define _ALL_SOURCE 1 +EOF + +else + rm -rf conftest* + echo "$ac_t""no" 1>&6 +fi +rm -f conftest* + + +ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6 +echo "configure:939: checking for minix/config.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:949: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + MINIX=yes +else + echo "$ac_t""no" 1>&6 +MINIX= +fi + +if test "$MINIX" = yes; then + cat >> confdefs.h <<\EOF +#define _POSIX_SOURCE 1 +EOF + + cat >> confdefs.h <<\EOF +#define _POSIX_1_SOURCE 2 +EOF + + cat >> confdefs.h <<\EOF +#define _MINIX 1 +EOF + +fi + +for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:991: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CXX="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CXX="$ac_cv_prog_CXX" +if test -n "$CXX"; then + echo "$ac_t""$CXX" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$CXX" && break +done +test -n "$CXX" || CXX="gcc" + + +echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:1023: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 + +ac_ext=C +# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cxx_cross + +cat > conftest.$ac_ext << EOF + +#line 1034 "configure" +#include "confdefs.h" + +int main(){return(0);} +EOF +if { (eval echo configure:1039: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cxx_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cxx_cross=no + else + ac_cv_prog_cxx_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cxx_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6 +if test $ac_cv_prog_cxx_works = no; then + { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:1065: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 +cross_compiling=$ac_cv_prog_cxx_cross + +echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 +echo "configure:1070: checking whether we are using GNU C++" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.C <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gxx=yes +else + ac_cv_prog_gxx=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gxx" 1>&6 + +if test $ac_cv_prog_gxx = yes; then + GXX=yes +else + GXX= +fi + +ac_test_CXXFLAGS="${CXXFLAGS+set}" +ac_save_CXXFLAGS="$CXXFLAGS" +CXXFLAGS= +echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 +echo "configure:1098: checking whether ${CXX-g++} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.cc +if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then + ac_cv_prog_cxx_g=yes +else + ac_cv_prog_cxx_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6 +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS="$ac_save_CXXFLAGS" +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi + +for ac_declaration in \ + ''\ + '#include ' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat > conftest.$ac_ext < +$ac_declaration +int main() { +exit (42); +; return 0; } +EOF +if { (eval echo configure:1147: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + continue +fi +rm -f conftest* + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:1192: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 +echo "configure:1245: checking whether ln -s works" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + rm -f conftestdata +if ln -s X conftestdata 2>/dev/null +then + rm -f conftestdata + ac_cv_prog_LN_S="ln -s" +else + ac_cv_prog_LN_S=ln +fi +fi +LN_S="$ac_cv_prog_LN_S" +if test "$ac_cv_prog_LN_S" = "ln -s"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 +echo "configure:1266: checking whether ${MAKE-make} sets \${MAKE}" >&5 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftestmake <<\EOF +all: + @echo 'ac_maketemp="${MAKE}"' +EOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftestmake +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$ac_t""yes" 1>&6 + SET_MAKE= +else + echo "$ac_t""no" 1>&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +# Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1295: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +# Extract the first word of "rm", so it can be a program name with args. +set dummy rm; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1325: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_RM'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$RM" in + /*) + ac_cv_path_RM="$RM" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_RM="$RM" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_RM="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_RM" && ac_cv_path_RM="rm" + ;; +esac +fi +RM="$ac_cv_path_RM" +if test -n "$RM"; then + echo "$ac_t""$RM" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +# Extract the first word of "cp", so it can be a program name with args. +set dummy cp; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1361: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_CP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$CP" in + /*) + ac_cv_path_CP="$CP" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_CP="$CP" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_CP="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_CP" && ac_cv_path_CP="cp" + ;; +esac +fi +CP="$ac_cv_path_CP" +if test -n "$CP"; then + echo "$ac_t""$CP" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + + + + + + + + + + +case "$ARCH" in + *sco*|*SCO*) + echo $ac_n "checking "SCO-Unix. See if we need -belf"""... $ac_c" 1>&6 +echo "configure:1407: checking "SCO-Unix. See if we need -belf"" >&5 + old_cflags="$CFLAGS" + CFLAGS="$CFLAGS -belf" + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + CMFLAGS="$CMFLAGS -belf" + echo "$ac_t""yes" 1>&6 +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "$ac_t""no" 1>&6 + CFLAGS="$old_cflags" +fi +rm -f conftest* + ;; +esac + + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 +echo "configure:1441: checking for $ac_hdr that defines DIR" >&5 +if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include <$ac_hdr> +int main() { +DIR *dirp = 0; +; return 0; } +EOF +if { (eval echo configure:1454: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then +echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 +echo "configure:1479: checking for opendir in -ldir" >&5 +ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldir $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -ldir" +else + echo "$ac_t""no" 1>&6 +fi + +else +echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 +echo "configure:1520: checking for opendir in -lx" >&5 +ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lx $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -lx" +else + echo "$ac_t""no" 1>&6 +fi + +fi + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1562: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1575: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:1642: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 +echo "configure:1666: checking for sys/wait.h that is POSIX.1 compatible" >&5 +if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#ifndef WEXITSTATUS +#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +#endif +#ifndef WIFEXITED +#define WIFEXITED(stat_val) (((stat_val) & 255) == 0) +#endif +int main() { +int s; +wait (&s); +s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; +; return 0; } +EOF +if { (eval echo configure:1687: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_header_sys_wait_h=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_sys_wait_h=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_header_sys_wait_h" 1>&6 +if test $ac_cv_header_sys_wait_h = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_SYS_WAIT_H 1 +EOF + +fi + +echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 +echo "configure:1708: checking whether time.h and sys/time.h may both be included" >&5 +if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +int main() { +struct tm *tp; +; return 0; } +EOF +if { (eval echo configure:1722: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_header_time=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_time=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_header_time" 1>&6 +if test $ac_cv_header_time = yes; then + cat >> confdefs.h <<\EOF +#define TIME_WITH_SYS_TIME 1 +EOF + +fi + +for ac_hdr in fcntl.h \ + sys/select.h \ + sys/time.h \ + sys/sigevent.h \ + sys/types.h \ + sys/stat.h \ + sys/utsname.h \ + sys/param.h \ + sys/wait.h \ + limits.h \ + unistd.h \ + errno.h \ + strings.h \ + math.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1759: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1769: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + + + +echo $ac_n "checking for pow in -lm""... $ac_c" 1>&6 +echo "configure:1798: checking for pow in -lm" >&5 +ac_lib_var=`echo m'_'pow | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lm $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo m | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + +for ac_func in setlocale +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1847: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + + + +# Check whether --enable-debug or --disable-debug was given. +if test "${enable_debug+set}" = set; then + enableval="$enable_debug" + xncdebug=yes +else + xncdebug=no +fi + + +if test "$xncdebug" = "yes"; then + DEB="-g -DDEBUG_XNC" +else + DEB="" +fi + + +# Check whether --with-sdl or --without-sdl was given. +if test "${with_sdl+set}" = set; then + withval="$with_sdl" + sdl_support=yes +else + sdl_support=no +fi + + +if test "x$sdl_support" = "xyes"; then + echo "SDL is ENABLED *******************" + IFACEOBJS='$(SDLOBJS)' + IFACELIBS='`sdl-config --libs` -lSDL_image' + IFACEINC='`sdl-config --cflags` -I./sdl' +else + echo "X11 is ENABLED *******************" + # If we find X, set shell vars x_includes and x_libraries to the +# paths, otherwise set no_x=yes. +# Uses ac_ vars as temps to allow command line to override cache and checks. +# --without-x overrides everything else, but does not touch the cache. +echo $ac_n "checking for X""... $ac_c" 1>&6 +echo "configure:1938: checking for X" >&5 + +# Check whether --with-x or --without-x was given. +if test "${with_x+set}" = set; then + withval="$with_x" + : +fi + +# $have_x is `yes', `no', `disabled', or empty when we do not yet know. +if test "x$with_x" = xno; then + # The user explicitly disabled X. + have_x=disabled +else + if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then + # Both variables are already set. + have_x=yes + else +if eval "test \"`echo '$''{'ac_cv_have_x'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # One or both of the vars are not set, and there is no cached value. +ac_x_includes=NO ac_x_libraries=NO +rm -fr conftestdir +if mkdir conftestdir; then + cd conftestdir + # Make sure to not put "make" in the Imakefile rules, since we grep it out. + cat > Imakefile <<'EOF' +acfindx: + @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' +EOF + if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then + # GNU make sometimes prints "make[1]: Entering...", which would confuse us. + eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` + # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. + for ac_extension in a so sl; do + if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && + test -f $ac_im_libdir/libX11.$ac_extension; then + ac_im_usrlibdir=$ac_im_libdir; break + fi + done + # Screen out bogus values from the imake configuration. They are + # bogus both because they are the default anyway, and because + # using them would break gcc on systems where it needs fixed includes. + case "$ac_im_incroot" in + /usr/include) ;; + *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;; + esac + case "$ac_im_usrlibdir" in + /usr/lib | /lib) ;; + *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;; + esac + fi + cd .. + rm -fr conftestdir +fi + +if test "$ac_x_includes" = NO; then + # Guess where to find include files, by looking for this one X11 .h file. + test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h + + # First, try using that file with no special directory specified. +cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2005: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + # We can compile using X headers with no special include directory. +ac_x_includes= +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + # Look for the header file in a standard set of common directories. +# Check X11 before X11Rn because it is often a symlink to the current release. + for ac_dir in \ + /usr/X11/include \ + /usr/X11R6/include \ + /usr/X11R5/include \ + /usr/X11R4/include \ + \ + /usr/include/X11 \ + /usr/include/X11R6 \ + /usr/include/X11R5 \ + /usr/include/X11R4 \ + \ + /usr/local/X11/include \ + /usr/local/X11R6/include \ + /usr/local/X11R5/include \ + /usr/local/X11R4/include \ + \ + /usr/local/include/X11 \ + /usr/local/include/X11R6 \ + /usr/local/include/X11R5 \ + /usr/local/include/X11R4 \ + \ + /usr/X386/include \ + /usr/x386/include \ + /usr/XFree86/include/X11 \ + \ + /usr/include \ + /usr/local/include \ + /usr/unsupported/include \ + /usr/athena/include \ + /usr/local/x11r5/include \ + /usr/lpp/Xamples/include \ + \ + /usr/openwin/include \ + /usr/openwin/share/include \ + ; \ + do + if test -r "$ac_dir/$x_direct_test_include"; then + ac_x_includes=$ac_dir + break + fi + done +fi +rm -f conftest* +fi # $ac_x_includes = NO + +if test "$ac_x_libraries" = NO; then + # Check for the libraries. + + test -z "$x_direct_test_library" && x_direct_test_library=Xt + test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc + + # See if we find them without any special options. + # Don't add to $LIBS permanently. + ac_save_LIBS="$LIBS" + LIBS="-l$x_direct_test_library $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + LIBS="$ac_save_LIBS" +# We can link X programs with no special library path. +ac_x_libraries= +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + LIBS="$ac_save_LIBS" +# First see if replacing the include by lib works. +# Check X11 before X11Rn because it is often a symlink to the current release. +for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \ + /usr/X11/lib \ + /usr/X11R6/lib \ + /usr/X11R5/lib \ + /usr/X11R4/lib \ + \ + /usr/lib/X11 \ + /usr/lib/X11R6 \ + /usr/lib/X11R5 \ + /usr/lib/X11R4 \ + \ + /usr/local/X11/lib \ + /usr/local/X11R6/lib \ + /usr/local/X11R5/lib \ + /usr/local/X11R4/lib \ + \ + /usr/local/lib/X11 \ + /usr/local/lib/X11R6 \ + /usr/local/lib/X11R5 \ + /usr/local/lib/X11R4 \ + \ + /usr/X386/lib \ + /usr/x386/lib \ + /usr/XFree86/lib/X11 \ + \ + /usr/lib \ + /usr/local/lib \ + /usr/unsupported/lib \ + /usr/athena/lib \ + /usr/local/x11r5/lib \ + /usr/lpp/Xamples/lib \ + /lib/usr/lib/X11 \ + \ + /usr/openwin/lib \ + /usr/openwin/share/lib \ + ; \ +do + for ac_extension in a so sl; do + if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then + ac_x_libraries=$ac_dir + break 2 + fi + done +done +fi +rm -f conftest* +fi # $ac_x_libraries = NO + +if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then + # Didn't find X anywhere. Cache the known absence of X. + ac_cv_have_x="have_x=no" +else + # Record where we found X for the cache. + ac_cv_have_x="have_x=yes \ + ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" +fi +fi + fi + eval "$ac_cv_have_x" +fi # $with_x != no + +if test "$have_x" != yes; then + echo "$ac_t""$have_x" 1>&6 + no_x=yes +else + # If each of the values was on the command line, it overrides each guess. + test "x$x_includes" = xNONE && x_includes=$ac_x_includes + test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries + # Update the cache value to reflect the command line values. + ac_cv_have_x="have_x=yes \ + ac_x_includes=$x_includes ac_x_libraries=$x_libraries" + echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6 +fi + + if test "$no_x" = yes; then + # Not all programs may use this symbol, but it does not hurt to define it. + cat >> confdefs.h <<\EOF +#define X_DISPLAY_MISSING 1 +EOF + + X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= +else + if test -n "$x_includes"; then + X_CFLAGS="$X_CFLAGS -I$x_includes" + fi + + # It would also be nice to do this for all -L options, not just this one. + if test -n "$x_libraries"; then + X_LIBS="$X_LIBS -L$x_libraries" + # For Solaris; some versions of Sun CC require a space after -R and + # others require no space. Words are not sufficient . . . . + case "`(uname -sr) 2>/dev/null`" in + "SunOS 5"*) + echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6 +echo "configure:2187: checking whether -R must be followed by a space" >&5 + ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries" + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_R_nospace=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_R_nospace=no +fi +rm -f conftest* + if test $ac_R_nospace = yes; then + echo "$ac_t""no" 1>&6 + X_LIBS="$X_LIBS -R$x_libraries" + else + LIBS="$ac_xsave_LIBS -R $x_libraries" + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_R_space=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_R_space=no +fi +rm -f conftest* + if test $ac_R_space = yes; then + echo "$ac_t""yes" 1>&6 + X_LIBS="$X_LIBS -R $x_libraries" + else + echo "$ac_t""neither works" 1>&6 + fi + fi + LIBS="$ac_xsave_LIBS" + esac + fi + + # Check for system-dependent libraries X programs must link with. + # Do this before checking for the system-independent R6 libraries + # (-lICE), since we may need -lsocket or whatever for X linking. + + if test "$ISC" = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" + else + # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X + # libraries were built with DECnet support. And karl@cs.umb.edu says + # the Alpha needs dnet_stub (dnet does not exist). + echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6 +echo "configure:2252: checking for dnet_ntoa in -ldnet" >&5 +ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldnet $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_lib_dnet_dnet_ntoa = no; then + echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6 +echo "configure:2293: checking for dnet_ntoa in -ldnet_stub" >&5 +ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldnet_stub $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" +else + echo "$ac_t""no" 1>&6 +fi + + fi + + # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, + # to get the SysV transport functions. + # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4) + # needs -lnsl. + # The nsl library prevents programs from opening the X display + # on Irix 5.2, according to dickey@clark.net. + echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 +echo "configure:2341: checking for gethostbyname" >&5 +if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char gethostbyname(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname) +choke me +#else +gethostbyname(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_gethostbyname=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_gethostbyname=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_func_gethostbyname = no; then + echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 +echo "configure:2390: checking for gethostbyname in -lnsl" >&5 +ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lnsl $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" +else + echo "$ac_t""no" 1>&6 +fi + + fi + + # lieder@skyler.mavd.honeywell.com says without -lsocket, + # socket/setsockopt and other routines are undefined under SCO ODT + # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary + # on later versions), says simon@lia.di.epfl.ch: it contains + # gethostby* variants that don't use the nameserver (or something). + # -lsocket must be given before -lnsl if both are needed. + # We assume that if connect needs -lnsl, so does gethostbyname. + echo $ac_n "checking for connect""... $ac_c" 1>&6 +echo "configure:2439: checking for connect" >&5 +if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char connect(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_connect) || defined (__stub___connect) +choke me +#else +connect(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2467: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_connect=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_connect=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'connect`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_func_connect = no; then + echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 +echo "configure:2488: checking for connect in -lsocket" >&5 +ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lsocket $X_EXTRA_LIBS $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" +else + echo "$ac_t""no" 1>&6 +fi + + fi + + # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX. + echo $ac_n "checking for remove""... $ac_c" 1>&6 +echo "configure:2531: checking for remove" >&5 +if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char remove(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_remove) || defined (__stub___remove) +choke me +#else +remove(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2559: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_remove=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_remove=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'remove`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_func_remove = no; then + echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6 +echo "configure:2580: checking for remove in -lposix" >&5 +ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lposix $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" +else + echo "$ac_t""no" 1>&6 +fi + + fi + + # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. + echo $ac_n "checking for shmat""... $ac_c" 1>&6 +echo "configure:2623: checking for shmat" >&5 +if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shmat(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shmat) || defined (__stub___shmat) +choke me +#else +shmat(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2651: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_shmat=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_shmat=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'shmat`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + + if test $ac_cv_func_shmat = no; then + echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6 +echo "configure:2672: checking for shmat in -lipc" >&5 +ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lipc $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" +else + echo "$ac_t""no" 1>&6 +fi + + fi + fi + + # Check for libraries that X11R6 Xt/Xaw programs need. + ac_save_LDFLAGS="$LDFLAGS" + test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries" + # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to + # check for ICE first), but we must link in the order -lSM -lICE or + # we get undefined symbols. So assume we have SM if we have ICE. + # These have to be linked with before -lX11, unlike the other + # libraries we check for below, so use a different variable. + # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. + echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6 +echo "configure:2724: checking for IceConnectionNumber in -lICE" >&5 +ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lICE $X_EXTRA_LIBS $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" +else + echo "$ac_t""no" 1>&6 +fi + + LDFLAGS="$ac_save_LDFLAGS" + +fi + + IFACEOBJS='$(X11OBJS) $(X11IMAGE)' + IFACELIBS='$(XLIBS)' + IFACEINC='$(XINC) -I./x11' +fi + + +out_lib=${LIBS} + + +echo $ac_n "checking for working const""... $ac_c" 1>&6 +echo "configure:2777: checking for working const" >&5 +if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} + +; return 0; } +EOF +if { (eval echo configure:2831: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_const=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_c_const=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_c_const" 1>&6 +if test $ac_cv_c_const = no; then + cat >> confdefs.h <<\EOF +#define const +EOF + +fi + +echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 +echo "configure:2852: checking for uid_t in sys/types.h" >&5 +if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "uid_t" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_uid_t=yes +else + rm -rf conftest* + ac_cv_type_uid_t=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_type_uid_t" 1>&6 +if test $ac_cv_type_uid_t = no; then + cat >> confdefs.h <<\EOF +#define uid_t int +EOF + + cat >> confdefs.h <<\EOF +#define gid_t int +EOF + +fi + +echo $ac_n "checking for inline""... $ac_c" 1>&6 +echo "configure:2886: checking for inline" >&5 +if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_inline=$ac_kw; break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done + +fi + +echo "$ac_t""$ac_cv_c_inline" 1>&6 +case "$ac_cv_c_inline" in + inline | yes) ;; + no) cat >> confdefs.h <<\EOF +#define inline +EOF + ;; + *) cat >> confdefs.h <&6 +echo "configure:2926: checking for mode_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#if STDC_HEADERS +#include +#include +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "(^|[^a-zA-Z_0-9])mode_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_mode_t=yes +else + rm -rf conftest* + ac_cv_type_mode_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_mode_t" 1>&6 +if test $ac_cv_type_mode_t = no; then + cat >> confdefs.h <<\EOF +#define mode_t int +EOF + +fi + +echo $ac_n "checking for pid_t""... $ac_c" 1>&6 +echo "configure:2959: checking for pid_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#if STDC_HEADERS +#include +#include +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "(^|[^a-zA-Z_0-9])pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_pid_t=yes +else + rm -rf conftest* + ac_cv_type_pid_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_pid_t" 1>&6 +if test $ac_cv_type_pid_t = no; then + cat >> confdefs.h <<\EOF +#define pid_t int +EOF + +fi + +echo $ac_n "checking for size_t""... $ac_c" 1>&6 +echo "configure:2992: checking for size_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#if STDC_HEADERS +#include +#include +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_size_t=yes +else + rm -rf conftest* + ac_cv_type_size_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_size_t" 1>&6 +if test $ac_cv_type_size_t = no; then + cat >> confdefs.h <<\EOF +#define size_t unsigned +EOF + +fi + +echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 +echo "configure:3025: checking whether struct tm is in sys/time.h or time.h" >&5 +if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +int main() { +struct tm *tp; tp->tm_sec; +; return 0; } +EOF +if { (eval echo configure:3038: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_struct_tm=time.h +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_struct_tm=sys/time.h +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_struct_tm" 1>&6 +if test $ac_cv_struct_tm = sys/time.h; then + cat >> confdefs.h <<\EOF +#define TM_IN_SYS_TIME 1 +EOF + +fi + +echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 +echo "configure:3059: checking return type of signal handlers" >&5 +if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#ifdef signal +#undef signal +#endif +#ifdef __cplusplus +extern "C" void (*signal (int, void (*)(int)))(int); +#else +void (*signal ()) (); +#endif + +int main() { +int i; +; return 0; } +EOF +if { (eval echo configure:3081: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_type_signal=void +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_type_signal=int +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_type_signal" 1>&6 +cat >> confdefs.h <&6 +echo "configure:3106: checking whether ${CC-cc} needs -traditional" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_pattern="Autoconf.*'x'" + cat > conftest.$ac_ext < +Autoconf TIOCGETP +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "$ac_pattern" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_prog_gcc_traditional=yes +else + rm -rf conftest* + ac_cv_prog_gcc_traditional=no +fi +rm -f conftest* + + + if test $ac_cv_prog_gcc_traditional = no; then + cat > conftest.$ac_ext < +Autoconf TCGETA +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "$ac_pattern" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_prog_gcc_traditional=yes +fi +rm -f conftest* + + fi +fi + +echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 + if test $ac_cv_prog_gcc_traditional = yes; then + CC="$CC -traditional" + fi +fi + +echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6 +echo "configure:3152: checking for 8-bit clean memcmp" >&5 +if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_memcmp_clean=no +else + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_func_memcmp_clean=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_func_memcmp_clean=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6 +test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}" + +echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 +echo "configure:3188: checking return type of signal handlers" >&5 +if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#ifdef signal +#undef signal +#endif +#ifdef __cplusplus +extern "C" void (*signal (int, void (*)(int)))(int); +#else +void (*signal ()) (); +#endif + +int main() { +int i; +; return 0; } +EOF +if { (eval echo configure:3210: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_type_signal=void +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_type_signal=int +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_type_signal" 1>&6 +cat >> confdefs.h <&6 +echo "configure:3240: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:3268: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + + + + +CFLAGS=${CFLAGS--O} +LDFLAGS=${LDFLAGS--O} +CPPFLAGS="$CPPFLAGS" + + + + +MCOMMON=./src/Make.common + + + + +case "$ARCH" in + *hppa*|*hpux*) + # do nothing + ;; + *solaris*) + if test "$GCC" = "yes"; then + echo $ac_n "checking "whether we need -fpermissive"""... $ac_c" 1>&6 +echo "configure:3314: checking "whether we need -fpermissive"" >&5 + old_cflags="$CFLAGS" + CFLAGS="-fpermissive $CFLAGS" + if test "$cross_compiling" = yes; then + echo "$ac_t""no" 1>&6 + CFLAGS="$old_cflags" +else + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + if grep 'option `-fpermissive'"'" config.log >/dev/null; then + echo "$ac_t""no" 1>&6 + CFLAGS="$old_cflags" + else + CFLAGS="$old_cflags -fpermissive" + echo "$ac_t""yes" 1>&6 + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + echo "$ac_t""no" 1>&6 + CFLAGS="$old_cflags" +fi +rm -fr conftest* +fi + + fi + ;; + *aix*) + # do nothing + ;; + *darwin*) + # do nothing + ;; + *) + # do nothing + ;; +esac + + + + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "\ + src/Make.common \ + src/makefile \ + src/include/globals.h \ + src/image/makefile \ + Makefile src/include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@host@%$host%g +s%@host_alias@%$host_alias%g +s%@host_cpu@%$host_cpu%g +s%@host_vendor@%$host_vendor%g +s%@host_os@%$host_os%g +s%@CC@%$CC%g +s%@CPP@%$CPP%g +s%@CXX@%$CXX%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@LN_S@%$LN_S%g +s%@SET_MAKE@%$SET_MAKE%g +s%@RANLIB@%$RANLIB%g +s%@RM@%$RM%g +s%@CP@%$CP%g +s%@SHAREFLAGS@%$SHAREFLAGS%g +s%@LD_SHAREFLAGS@%$LD_SHAREFLAGS%g +s%@PLUGINS@%$PLUGINS%g +s%@DEB@%$DEB%g +s%@IFACEOBJS@%$IFACEOBJS%g +s%@IFACELIBS@%$IFACELIBS%g +s%@IFACEINC@%$IFACEINC%g +s%@X_CFLAGS@%$X_CFLAGS%g +s%@X_PRE_LIBS@%$X_PRE_LIBS%g +s%@X_LIBS@%$X_LIBS%g +s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g +s%@LIBOBJS@%$LIBOBJS%g +/@MCOMMON@/r $MCOMMON +s%@MCOMMON@%%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + + + echo "ZINC=" >>src/make.conf + echo "ZLIB=" >>src/make.conf + echo "ZDEP=" >>src/make.conf + echo "PNG=" >>src/make.conf + echo "OPNGS=" >>src/make.conf + echo "PNGINC=" >>src/make.conf + echo "PNGLIB=" >>src/make.conf + echo "PNGDEP=" >>src/make.conf + + + echo "PSEUDO=-DPSEUDOCOLOR" >>src/make.conf + echo "OPSEUDO=" >>src/make.conf + pse="PseudoColor; TrueColor;" + + + echo "XBM=" >>src/make.conf + echo "OXBM=" >>src/make.conf + xbm="" + + echo "BMP=" >>src/make.conf + echo "OBMP=" >>src/make.conf + bmp="" + + echo "XPM=" >>src/make.conf + echo "OXPM=" >>src/make.conf + xpm="" + + echo "PCX=" >>src/make.conf + echo "OPCX=" >>src/make.conf + pcx="" + + echo "TGA=" >>src/make.conf + echo "OTGA=" >>src/make.conf + targa="" + + echo "TIFF=" >>src/make.conf + echo "OTIFF=" >>src/make.conf + echo "TLIB=" >>src/make.conf + tiff="" + + echo "PCD=" >>src/make.conf + echo "OPCDS=" >>src/make.conf + pcd="" + +echo "--------------- X Welltris Project ----------------------" + +echo " +Configuration: + + Source code location: ${srcdir} + C Compiler: ${CC} + C Compiler flags: ${CFLAGS} + C++ Compiler: ${CXX} + Libraries: ${out_lib} + Install path: ${prefix}/bin + Man pages path: ${prefix}/man + X11 versions: ${X_LIBS} + X Visuals: ${pse} + Image library: GIF +" +echo "-----------------------------------------------------------" +echo "" +echo "Type 'make' for building XWelltris binaries, and after that" +echo "do 'make install' as 'root'." +echo "" +echo "Thank you..." + + diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..6ca1df8 --- /dev/null +++ b/configure.in @@ -0,0 +1,288 @@ +dnl# -*- sh -*- +dnl# +dnl# $Id: configure.in,v 1.4 2003/02/27 08:27:51 leo Exp $ +dnl# +dnl# Process this file with autoconf to produce a configure script. +dnl# +AC_INIT(src/main.cxx) + +if test -z "${CFLAGS}"; then + if test -z "${CCOPTS}"; then + CCOPTS='-O' + fi + CFLAGS="$CCOPTS" +fi + +dnl# Checks for programs. +dnl AC_MAKE_SET + +AC_CANONICAL_HOST +changequote(,)dnl +ARCH=`echo $host | sed 's/\([^-]*\)-[^-]*-\([^-]*\)/\1-\2/'` +changequote([,])dnl + +dnl Checks for programs. +AC_PREFIX_DEFAULT(/usr) +AC_ISC_POSIX +AC_AIX +AC_MINIX +dnl AC_PROG_CC +AC_PROG_CXX +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_MAKE_SET +AC_PROG_RANLIB +AC_PATH_PROG(RM, rm, rm) +AC_PATH_PROG(CP, cp, cp) + +AC_SUBST(SHAREFLAGS) +AC_SUBST(LD_SHAREFLAGS) +AC_SUBST(PLUGINS) +AC_SUBST(DEB) +AC_SUBST(IFACEOBJS) +AC_SUBST(IFACELIBS) +AC_SUBST(IFACEINC) + +dnl **************************************************************** +dnl On SCO Unix, there are ELF and COFF binaries. We want elf to +dnl provide for dlopen() and friends. With help from Tamas Laufer! +dnl **************************************************************** + +case "$ARCH" in + *sco*|*SCO*) + AC_MSG_CHECKING("SCO-Unix. See if we need -belf") + old_cflags="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_TRY_COMPILE( + [ + ], + [ + ], + CMFLAGS="$CMFLAGS -belf" + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) + CFLAGS="$old_cflags") + ;; +esac + + +dnl Checks for header files. +AC_HEADER_DIRENT +AC_HEADER_STDC +AC_HEADER_SYS_WAIT +AC_HEADER_TIME +AC_CHECK_HEADERS(fcntl.h \ + sys/select.h \ + sys/time.h \ + sys/sigevent.h \ + sys/types.h \ + sys/stat.h \ + sys/utsname.h \ + sys/param.h \ + sys/wait.h \ + limits.h \ + unistd.h \ + errno.h \ + strings.h \ + math.h) + + +AC_CHECK_LIB(m, pow) +AC_CHECK_FUNCS(setlocale) + +dnl -------------------------------------------------------------------------- +dnl Additional configure options added for xnc + +AC_ARG_ENABLE(debug, [ --enable-debug Turn on debugging output], + xncdebug=yes, + xncdebug=no) + +if test "$xncdebug" = "yes"; then + DEB="-g -DDEBUG_XNC" +else + DEB="" +fi + + +AC_ARG_WITH(sdl, [ --with-sdl Turn on SDL support instead of X11], + sdl_support=yes, + sdl_support=no) + +if test "x$sdl_support" = "xyes"; then + echo "SDL is ENABLED *******************" + IFACEOBJS='$(SDLOBJS)' + IFACELIBS='`sdl-config --libs` -lSDL_image' + IFACEINC='`sdl-config --cflags` -I./sdl' +else + echo "X11 is ENABLED *******************" + AC_PATH_X + AC_PATH_XTRA + IFACEOBJS='$(X11OBJS) $(X11IMAGE)' + IFACELIBS='$(XLIBS)' + IFACEINC='$(XINC) -I./x11' +fi + + +out_lib=${LIBS} + + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_UID_T +AC_C_INLINE +AC_TYPE_MODE_T +AC_TYPE_PID_T +AC_TYPE_SIZE_T +AC_STRUCT_TM +AC_TYPE_SIGNAL + + + + +dnl ---------------------- Checks for library functions ----------------- + +AC_PROG_GCC_TRADITIONAL +AC_FUNC_MEMCMP +AC_TYPE_SIGNAL +AC_CHECK_FUNCS( getcwd \ + mkdir \ + putenv \ + select \ + socket \ + seteuid \ + unsetenv \ + setutent \ + atexit + ) + + + +CFLAGS=${CFLAGS--O} +LDFLAGS=${LDFLAGS--O} +CPPFLAGS="$CPPFLAGS" +AC_SUBST(CFLAGS) +AC_SUBST(CPPFLAGS) +AC_SUBST(LDFLAGS) +AC_SUBST(LIBS) +dnl# common parts of the Makefile +MCOMMON=./src/Make.common +AC_SUBST_FILE(MCOMMON) + + +dnl Some specific OS stuff + +case "$ARCH" in + *hppa*|*hpux*) + # do nothing + ;; + *solaris*) + if test "$GCC" = "yes"; then + AC_MSG_CHECKING("whether we need -fpermissive") + old_cflags="$CFLAGS" + CFLAGS="-fpermissive $CFLAGS" + AC_TRY_RUN( + main() + { exit(0); + }, + if grep 'option `-fpermissive'"'" config.log >/dev/null; then + AC_MSG_RESULT(no) + CFLAGS="$old_cflags" + else + CFLAGS="$old_cflags -fpermissive" + AC_MSG_RESULT(yes) + fi, + AC_MSG_RESULT(no) + CFLAGS="$old_cflags", + AC_MSG_RESULT(no) + CFLAGS="$old_cflags") + fi + ;; + *aix*) + # do nothing + ;; + *darwin*) + # do nothing + ;; + *) + # do nothing + ;; +esac + + + +AC_CONFIG_HEADER(src/include/config.h) +AC_OUTPUT( \ + src/Make.common \ + src/makefile \ + src/include/globals.h \ + src/image/makefile \ + Makefile) + + echo "ZINC=" >>src/make.conf + echo "ZLIB=" >>src/make.conf + echo "ZDEP=" >>src/make.conf + echo "PNG=" >>src/make.conf + echo "OPNGS=" >>src/make.conf + echo "PNGINC=" >>src/make.conf + echo "PNGLIB=" >>src/make.conf + echo "PNGDEP=" >>src/make.conf + + + echo "PSEUDO=-DPSEUDOCOLOR" >>src/make.conf + echo "OPSEUDO=" >>src/make.conf + pse="PseudoColor; TrueColor;" + + + echo "XBM=" >>src/make.conf + echo "OXBM=" >>src/make.conf + xbm="" + + echo "BMP=" >>src/make.conf + echo "OBMP=" >>src/make.conf + bmp="" + + echo "XPM=" >>src/make.conf + echo "OXPM=" >>src/make.conf + xpm="" + + echo "PCX=" >>src/make.conf + echo "OPCX=" >>src/make.conf + pcx="" + + echo "TGA=" >>src/make.conf + echo "OTGA=" >>src/make.conf + targa="" + + echo "TIFF=" >>src/make.conf + echo "OTIFF=" >>src/make.conf + echo "TLIB=" >>src/make.conf + tiff="" + + echo "PCD=" >>src/make.conf + echo "OPCDS=" >>src/make.conf + pcd="" + +echo "--------------- X Welltris Project ----------------------" + +echo " +Configuration: + + Source code location: ${srcdir} + C Compiler: ${CC} + C Compiler flags: ${CFLAGS} + C++ Compiler: ${CXX} + Libraries: ${out_lib} + Install path: ${prefix}/bin + Man pages path: ${prefix}/man + X11 versions: ${X_LIBS} + X Visuals: ${pse} + Image library: GIF +" +echo "-----------------------------------------------------------" +echo "" +echo "Type 'make' for building XWelltris binaries, and after that" +echo "do 'make install' as 'root'." +echo "" +echo "Thank you..." + + diff --git a/data/board2.gif b/data/board2.gif new file mode 100755 index 0000000..54077fb Binary files /dev/null and b/data/board2.gif differ diff --git a/data/font2.gif b/data/font2.gif new file mode 100755 index 0000000..77a0854 Binary files /dev/null and b/data/font2.gif differ diff --git a/data/polyomino.dat b/data/polyomino.dat new file mode 100644 index 0000000..4d35c54 --- /dev/null +++ b/data/polyomino.dat @@ -0,0 +1,412 @@ +/* polyomino.dat -- polyominoes for tetris & welltris */ + +/* Maximum number of squares was chosen to be 6 because if 7, it leaves a */ +/* hole: @@@ */ +/* @ @ */ +/* @@ */ +/* likewise, 3 was chosen for diagonal mode because if 4, it leaves a hole: */ +/* @ */ +/* @ @ */ +/* @ */ + +/* '+' Prelude part */ +/* 1st number = number of squares in a polyomino */ +/* 2nd number = number of distinct polyominoes & rotations & reflections */ +/* 3rd number = number of distinct polyominoes & reflections */ +/* 4th number = number of distinct polyominoes */ +/* 5th number = O do not allow rotation and reflection */ +/* 1 allow rotation but not reflection */ +/* 2 allow rotation and reflection */ +/* 6th number = diagonal mode to consider? 0 or 1 (if 0, no 7-10) */ +/* 7th number = diagonal number of distinct polyominoes & rots & refls */ +/* 8th number = diagonal number of distinct polyominoes & reflections */ +/* 9th number = diagonal number of distinct polyominoes */ +/* 10th number = O do not allow rotation and reflection for diagonal mode */ +/* 1 allow rotation but not reflection for diagonal mode */ +/* 2 allow rotation and reflection for diagonal mode */ + +/* '*' Main parts */ +/* 1st number = n-> consider an n^2 square */ +/* '#' polyomino group (follows a '*') */ +/* 1st number = number of squares in a polyomino */ +/* 2nd number = number of polyominoes (incl rot & refl) in a n^2 square */ +/* 3rd number = if it is there, number of polyominoes (incl rot & refl) */ +/* in a n^2 square with diagonal mode */ +/* The polyomino (follows a '#') */ +/* 1st number = numbered polyomino (there for your benefit) */ +/* 2nd number = rotation pointer (usually the next polyomino) */ +/* 3rd number = reflection pointer */ +/* 4th number = number of rows down to start */ +/* 5th number = start number (0, 1, or 2) */ +/* 0=> starter for no turns permitted (no reflections or rotations) */ +/* 1=> starter for allow rotations and no turns permitted */ +/* 2=> starter for reflections, rotations, and no turns permitted */ +/* Next number (if diagonal mode) = start number for diagonal mode */ +/* The proceeding 2 or 3 numbers are repeated for gradual appearance */ +/* Pieces either JUMPIN or appear GRADUALly */ +/* The last group of n^2 numbers is the actual polyomino */ +/* 0=> empty square */ +/* 1..16=> used square */ +/* '~' debug (preceeds a '#') */ +/* 1st number = number of polyominoes to skip */ + +/* PRELUDE */ +/* + Polyomino States(None Rot Refl) Style Diagonal [States(N R R) Style] */ +/* + 1 1 1 1 0 1 1 1 1 0 */ ++ 2 2 1 1 0 1 4 2 2 0 ++ 3 6 2 2 0 1 20 6 5 1 ++ 4 19 7 5 1 0 ++ 5 63 18 12 2 0 ++ 6 216 60 35 2 0 + +/* MAIN */ +/* * X (polyomino fills X^2 square) */ +/* # Polyomino Number_of_Polyominoes_Normal [Number_of_Polyominoes_Diagonal] */ +/* Ref_Num Ptr_Rot Ptr_Refl (Start_Location Start_N [Start_D])J&G Shape_Array */ +/* * 1 */ +/* # 1 1 */ +/* 0 0 0 0 2 2 1 2 2 16 */ +* 2 +# 2 2 4 +0 1 0 1 2 2 1 0 0 0 0 4 1 +1 0 1 0 0 0 1 2 2 0 2 0 8 + +2 3 3 0 0 2 1 0 2 0 16 16 0 +3 2 2 0 0 0 1 0 0 16 0 0 16 +# 3 4 4 +0 1 3 0 2 2 1 2 2 6 1 8 0 +1 2 2 0 0 0 1 0 0 2 0 12 1 +2 3 1 0 0 0 1 0 0 0 2 4 9 +3 0 0 0 0 0 1 0 0 4 3 0 8 +# 4 1 +0 0 0 0 2 1 2 6 3 12 9 +* 3 +# 3 2 16 +0 1 0 1 2 2 1 0 0 0 0 0 4 5 1 0 0 0 +1 0 1 0 0 0 2 2 2 0 2 0 0 10 0 0 8 0 + +2 3 3 0 0 2 2 0 2 16 0 0 0 16 0 0 0 16 +3 2 2 0 0 0 2 0 0 0 0 16 0 16 0 16 0 0 +4 5 8 1 0 2 2 0 0 0 0 0 0 4 1 16 0 0 +5 6 11 0 0 0 2 0 2 0 2 0 0 8 0 0 0 16 +6 7 10 1 0 0 2 0 0 0 0 0 0 0 16 4 1 0 +7 4 9 0 0 0 2 0 0 0 16 0 0 0 2 0 0 8 +8 9 4 1 0 1 2 0 0 0 0 0 4 1 0 0 0 16 +9 10 7 0 0 0 2 0 0 0 0 16 0 2 0 0 8 0 +10 11 6 1 0 0 2 0 0 0 0 0 16 0 0 0 4 1 +11 8 5 0 0 0 2 0 1 0 0 2 0 0 8 0 16 0 +12 13 12 1 0 2 2 0 0 0 0 0 16 0 16 0 16 0 +13 14 15 0 0 0 2 0 2 0 16 0 0 0 16 0 16 0 +14 15 14 1 0 0 2 0 0 0 0 0 0 16 0 16 0 16 +15 12 13 0 0 0 2 0 0 0 0 16 0 16 0 0 0 16 +# 4 16 +0 1 4 1 2 2 0 0 0 0 6 5 1 8 0 0 +1 2 7 0 0 2 0 0 2 0 0 10 0 0 12 1 +2 3 6 1 0 2 0 0 0 0 0 0 2 4 5 9 +3 0 5 0 0 2 2 0 4 3 0 0 10 0 0 8 +4 5 0 1 1 2 0 0 0 0 4 5 3 0 0 8 +5 6 3 0 0 2 1 0 6 1 0 10 0 0 8 0 +6 7 2 1 0 2 0 0 0 0 2 0 0 12 5 1 +7 4 1 0 0 2 0 0 0 2 0 0 10 0 4 9 +8 9 8 1 2 2 0 0 0 0 4 7 1 0 8 0 +9 10 11 0 0 2 2 0 2 0 0 14 1 0 8 0 +10 11 10 1 0 2 0 0 0 0 0 2 0 4 13 1 +11 8 9 0 0 2 0 0 0 2 0 4 11 0 0 8 +12 13 14 1 2 2 0 0 0 0 4 3 0 0 12 1 +13 12 15 0 0 2 2 0 0 2 0 6 9 0 8 0 +14 15 12 1 1 2 0 0 0 0 0 6 1 4 9 0 +15 14 13 0 0 2 1 0 2 0 0 12 3 0 0 8 +# 5 37 +0 1 0 1 2 2 0 0 0 0 6 5 3 8 0 8 +1 2 3 0 0 2 2 0 6 1 0 10 0 0 12 1 +2 3 2 1 0 2 0 0 0 0 2 0 2 12 5 9 +3 0 1 0 0 2 0 0 4 3 0 0 10 0 4 9 +4 5 8 1 2 2 0 0 0 0 6 7 1 12 9 0 +5 6 11 0 0 2 0 0 2 0 0 14 3 0 12 9 +6 7 10 1 0 2 0 0 0 0 0 6 3 4 13 9 +7 4 9 0 0 2 2 0 6 3 0 12 11 0 0 8 +8 9 4 1 1 2 0 0 0 0 4 7 3 0 12 9 +9 10 7 0 0 2 1 0 6 3 0 14 9 0 8 0 +10 11 6 1 0 2 0 0 0 0 6 3 0 12 13 1 +11 8 5 0 0 2 0 0 0 2 0 6 11 0 12 9 +12 13 12 0 2 2 2 4 7 1 0 10 0 0 8 0 +13 14 15 0 0 2 0 2 0 0 14 5 1 8 0 0 +14 15 14 0 0 2 0 0 2 0 0 10 0 4 13 1 +15 12 13 0 0 2 0 0 0 2 4 5 11 0 0 8 +16 17 19 0 2 2 2 6 5 1 10 0 0 8 0 0 +17 18 18 0 0 2 0 2 0 0 10 0 0 12 5 1 +18 19 17 0 0 2 0 0 0 2 0 0 10 4 5 9 +19 16 16 0 0 2 0 4 5 3 0 0 10 0 0 8 +20 21 22 0 2 2 0 2 0 0 12 5 3 0 0 8 +21 20 23 0 0 2 2 0 6 1 0 10 0 4 9 0 +22 23 20 0 1 2 0 0 0 2 6 5 9 8 0 0 +23 22 21 0 0 2 1 4 3 0 0 10 0 0 12 1 +24 25 25 0 2 2 2 4 3 0 0 12 3 0 0 8 +25 26 24 0 0 2 0 0 6 1 6 9 0 8 0 0 +26 27 27 0 0 2 0 2 0 0 12 3 0 0 12 1 +27 24 26 0 0 2 0 0 0 2 0 6 9 4 9 0 +28 29 32 0 2 2 0 0 2 0 6 13 1 8 0 0 +29 30 35 0 0 2 0 0 2 0 4 11 0 0 12 1 +30 31 34 0 0 2 0 0 0 2 4 7 9 0 8 0 +31 28 33 0 0 2 2 4 3 0 0 14 1 0 8 0 +32 33 28 0 1 2 0 0 2 0 4 13 3 0 0 8 +33 34 31 0 0 2 1 0 6 1 4 11 0 0 8 0 +34 35 30 0 0 2 0 2 0 0 12 7 1 0 8 0 +35 32 29 0 0 2 0 0 2 0 0 14 1 4 9 0 +36 36 36 0 2 2 2 0 2 0 4 15 1 0 8 0 +# 6 46 +0 1 4 0 2 2 0 6 5 3 10 0 8 8 0 0 +1 2 7 0 0 2 0 6 1 0 10 0 0 12 5 1 +2 3 6 0 0 2 0 0 0 2 2 0 10 12 5 9 +3 0 5 0 0 2 2 4 5 3 0 0 10 0 4 9 +4 5 0 0 1 2 0 6 5 3 8 0 10 0 0 8 +5 6 3 0 0 2 1 6 5 1 10 0 0 12 1 0 +6 7 2 0 0 2 0 2 0 0 10 0 2 12 5 9 +7 4 1 0 0 2 0 0 4 3 0 0 10 4 5 9 +8 9 12 0 2 2 2 6 7 1 12 11 0 0 8 0 +9 10 15 0 0 2 0 2 0 0 14 7 1 12 9 0 +10 11 14 0 0 2 0 0 2 0 0 14 3 4 13 9 +11 8 13 0 0 2 0 0 6 3 4 13 11 0 0 8 +12 13 8 0 1 2 1 4 7 3 0 14 9 0 8 0 +13 14 11 0 0 2 0 6 3 0 14 13 1 8 0 0 +14 15 10 0 0 2 0 0 2 0 6 11 0 12 13 1 +15 12 9 0 0 2 0 0 0 2 4 7 11 0 12 9 +16 17 20 0 2 2 0 6 3 0 12 13 3 0 0 8 +17 18 23 0 0 2 0 0 6 1 6 11 0 12 9 0 +18 19 22 0 0 2 0 2 0 0 12 7 3 0 12 9 +19 16 21 0 0 2 2 0 6 3 0 14 9 4 9 0 +20 21 16 0 1 2 0 0 6 3 6 13 9 8 0 0 +21 22 19 0 0 2 1 6 3 0 12 11 0 0 12 1 +22 23 18 0 0 2 0 0 0 2 6 7 9 12 9 0 +23 20 17 0 0 2 0 4 3 0 0 14 3 0 12 9 +24 25 28 0 2 2 2 4 7 1 0 10 0 4 9 0 +25 26 31 0 0 2 0 2 0 0 14 5 3 8 0 8 +26 27 30 0 0 2 0 0 6 1 0 10 0 4 13 1 +27 24 29 0 0 2 0 2 0 2 12 5 11 0 0 8 +28 29 24 0 1 2 1 4 7 1 0 10 0 0 12 1 +29 30 27 0 0 2 0 2 0 2 14 5 9 8 0 0 +30 31 26 0 0 2 0 4 3 0 0 10 0 4 13 1 +31 28 25 0 0 2 0 0 0 2 6 5 11 8 0 8 +32 33 32 0 2 2 0 2 0 2 12 7 9 0 8 0 +33 34 35 0 0 2 2 4 3 0 0 14 1 4 9 0 +34 35 34 0 0 2 0 0 2 0 6 13 3 8 0 8 +35 32 33 0 0 2 0 0 6 1 4 11 0 0 12 1 +36 37 39 0 2 2 2 6 7 1 14 9 0 8 0 0 +37 38 38 0 0 2 0 2 0 0 14 3 0 12 13 1 +38 39 37 0 0 2 0 0 0 2 0 6 11 4 13 9 +39 36 36 0 0 2 0 4 7 3 0 12 11 0 0 8 +40 41 43 0 2 2 2 6 3 0 12 15 1 0 8 0 +41 42 42 0 0 2 0 0 2 0 6 15 1 12 9 0 +42 43 41 0 0 2 0 0 2 0 4 15 3 0 12 9 +43 40 40 0 0 2 0 0 6 3 4 15 9 0 8 0 +44 45 44 1 2 2 0 0 0 0 6 7 3 12 13 9 +45 44 45 0 0 2 2 0 6 3 0 14 11 0 12 9 +* 4 +# 4 2 +0 1 0 2 2 2 0 0 0 0 0 0 0 0 0 4 5 5 1 0 0 0 0 +1 0 1 0 0 3 2 0 0 2 0 0 0 10 0 0 0 10 0 0 0 8 0 +# 5 24 +0 1 4 1 2 2 0 0 0 0 0 6 5 5 1 8 0 0 0 0 0 0 0 +1 2 7 0 0 3 0 0 2 0 0 0 10 0 0 0 10 0 0 0 12 1 0 +2 3 6 1 0 2 0 0 0 0 0 0 0 0 2 4 5 5 9 0 0 0 0 +3 0 5 0 0 3 2 0 4 3 0 0 0 10 0 0 0 10 0 0 0 8 0 +4 5 0 1 1 2 0 0 0 0 0 4 5 5 3 0 0 0 8 0 0 0 0 +5 6 3 0 0 3 1 0 6 1 0 0 10 0 0 0 10 0 0 0 8 0 0 +6 7 2 1 0 2 0 0 0 0 0 2 0 0 0 12 5 5 1 0 0 0 0 +7 4 1 0 0 3 0 0 0 2 0 0 0 10 0 0 0 10 0 0 4 9 0 +8 9 12 1 2 2 0 0 0 0 0 4 7 5 1 0 8 0 0 0 0 0 0 +9 10 15 0 0 3 0 0 2 0 0 0 10 0 0 0 14 1 0 0 8 0 0 +10 11 14 1 0 2 0 0 0 0 0 0 0 2 0 4 5 13 1 0 0 0 0 +11 8 13 0 0 3 2 0 0 2 0 0 4 11 0 0 0 10 0 0 0 8 0 +12 13 8 1 1 2 0 0 0 0 0 4 5 7 1 0 0 8 0 0 0 0 0 +13 14 11 0 0 3 1 0 2 0 0 0 14 1 0 0 10 0 0 0 8 0 0 +14 15 10 1 0 2 0 0 0 0 0 0 2 0 0 4 13 5 1 0 0 0 0 +15 12 9 0 0 3 0 0 0 2 0 0 0 10 0 0 4 11 0 0 0 8 0 +16 17 20 1 2 2 0 0 0 0 0 4 5 3 0 0 0 12 1 0 0 0 0 +17 18 23 0 0 3 2 0 0 2 0 0 6 9 0 0 10 0 0 0 8 0 0 +18 19 22 1 0 2 0 0 0 0 0 4 3 0 0 0 12 5 1 0 0 0 0 +19 16 21 0 0 3 0 0 0 2 0 0 0 10 0 0 6 9 0 0 8 0 0 +20 21 16 1 1 2 0 0 0 0 0 0 6 5 1 4 9 0 0 0 0 0 0 +21 22 19 0 0 3 0 0 2 0 0 0 10 0 0 0 12 3 0 0 0 8 0 +22 23 18 1 0 2 0 0 0 0 0 0 0 6 1 4 5 9 0 0 0 0 0 +23 20 17 0 0 3 1 0 2 0 0 0 12 3 0 0 0 10 0 0 0 8 0 +# 6 136 +0 1 4 1 2 3 0 0 0 0 0 6 5 5 1 10 0 0 0 8 0 0 0 +1 2 7 0 0 3 0 0 2 0 0 0 10 0 0 0 10 0 0 0 12 5 1 +2 3 6 1 0 3 0 0 0 0 0 0 0 0 2 0 0 0 10 4 5 5 9 +3 0 5 0 0 3 2 0 4 5 3 0 0 0 10 0 0 0 10 0 0 0 8 +4 5 0 1 1 3 0 0 0 0 0 4 5 5 3 0 0 0 10 0 0 0 8 +5 6 3 0 0 3 1 0 6 5 1 0 10 0 0 0 10 0 0 0 8 0 0 +6 7 2 1 0 3 0 0 0 0 0 2 0 0 0 10 0 0 0 12 5 5 1 +7 4 1 0 0 3 0 0 0 0 2 0 0 0 10 0 0 0 10 0 4 5 9 +8 9 12 1 2 2 0 0 0 0 0 6 7 5 1 12 9 0 0 0 0 0 0 +9 10 15 0 0 3 0 0 2 0 0 0 10 0 0 0 14 3 0 0 12 9 0 +10 11 14 1 0 2 0 0 0 0 0 0 0 6 3 4 5 13 9 0 0 0 0 +11 8 13 0 0 3 2 0 6 3 0 0 12 11 0 0 0 10 0 0 0 8 0 +12 13 8 1 1 2 0 0 0 0 0 4 5 7 3 0 0 12 9 0 0 0 0 +13 14 11 0 0 3 1 0 6 3 0 0 14 9 0 0 10 0 0 0 8 0 0 +14 15 10 1 0 2 0 0 0 0 0 6 3 0 0 12 13 5 1 0 0 0 0 +15 12 9 0 0 3 0 0 0 2 0 0 0 10 0 0 6 11 0 0 12 9 0 +16 17 20 1 2 2 0 0 0 0 0 6 5 7 1 8 0 8 0 0 0 0 0 +17 18 23 0 0 3 0 0 2 0 0 0 14 1 0 0 10 0 0 0 12 1 0 +18 19 22 1 0 2 0 0 0 0 0 0 2 0 2 4 13 5 9 0 0 0 0 +19 16 21 0 0 3 2 0 4 3 0 0 0 10 0 0 4 11 0 0 0 8 0 +20 21 16 1 1 2 0 0 0 0 0 4 7 5 3 0 8 0 8 0 0 0 0 +21 22 19 0 0 3 1 0 6 1 0 0 10 0 0 0 14 1 0 0 8 0 0 +22 23 18 1 0 2 0 0 0 0 0 2 0 2 0 12 5 13 1 0 0 0 0 +23 20 17 0 0 3 0 0 0 2 0 0 4 11 0 0 0 10 0 0 4 9 0 +24 25 28 1 2 3 0 0 0 0 0 4 7 5 1 0 10 0 0 0 8 0 0 +25 26 31 0 0 3 0 0 2 0 0 0 10 0 0 0 14 5 1 0 8 0 0 +26 27 30 1 0 3 0 0 0 0 0 0 0 2 0 0 0 10 0 4 5 13 1 +27 24 29 0 0 3 2 0 0 0 2 0 4 5 11 0 0 0 10 0 0 0 8 +28 29 24 1 1 3 0 0 0 0 0 4 5 7 1 0 0 10 0 0 0 8 0 +29 30 27 0 0 3 1 0 2 0 0 0 14 5 1 0 10 0 0 0 8 0 0 +30 31 26 1 0 3 0 0 0 0 0 0 2 0 0 0 10 0 0 4 13 5 1 +31 28 25 0 0 3 0 0 0 0 2 0 0 0 10 0 4 5 11 0 0 0 8 +32 33 36 1 2 3 0 0 0 0 0 0 2 0 0 6 13 5 1 8 0 0 0 +33 34 39 0 0 3 0 0 0 2 0 0 0 10 0 0 4 11 0 0 0 12 1 +34 35 38 1 0 3 0 0 0 0 0 0 0 0 2 4 5 7 9 0 0 8 0 +35 32 37 0 0 3 2 0 4 3 0 0 0 14 1 0 0 10 0 0 0 8 0 +36 37 32 1 1 3 0 0 0 0 0 0 0 2 0 4 5 13 3 0 0 0 8 +37 38 35 0 0 3 1 0 0 6 1 0 4 11 0 0 0 10 0 0 0 8 0 +38 39 34 1 0 3 0 0 0 0 0 2 0 0 0 12 7 5 1 0 8 0 0 +39 36 33 0 0 3 0 0 0 2 0 0 0 10 0 0 0 14 1 0 4 9 0 +40 41 44 1 2 3 0 0 0 0 0 0 0 2 0 6 5 13 1 8 0 0 0 +41 42 47 0 0 3 0 0 0 2 0 0 4 11 0 0 0 10 0 0 0 12 1 +42 43 46 1 0 3 0 0 0 0 0 0 0 0 2 4 7 5 9 0 8 0 0 +43 40 45 0 0 3 2 0 4 3 0 0 0 10 0 0 0 14 1 0 0 8 0 +44 45 40 1 1 3 0 0 0 0 0 0 2 0 0 4 13 5 3 0 0 0 8 +45 46 43 0 0 3 1 0 0 6 1 0 0 10 0 0 4 11 0 0 0 8 0 +46 47 42 1 0 3 0 0 0 0 0 2 0 0 0 12 5 7 1 0 0 8 0 +47 44 41 0 0 3 0 0 0 2 0 0 0 14 1 0 0 10 0 0 4 9 0 +48 49 52 1 2 2 0 0 0 0 0 6 5 3 0 8 0 12 1 0 0 0 0 +49 50 55 0 0 3 0 0 0 2 0 0 6 9 0 0 10 0 0 0 12 1 0 +50 51 54 1 0 2 0 0 0 0 0 4 3 0 2 0 12 5 9 0 0 0 0 +51 48 53 0 0 3 2 0 4 3 0 0 0 10 0 0 6 9 0 0 8 0 0 +52 53 48 1 1 2 0 0 0 0 0 0 6 5 3 4 9 0 8 0 0 0 0 +53 54 51 0 0 3 1 0 6 1 0 0 10 0 0 0 12 3 0 0 0 8 0 +54 55 50 1 0 2 0 0 0 0 0 2 0 6 1 12 5 9 0 0 0 0 0 +55 52 49 0 0 3 0 0 2 0 0 0 12 3 0 0 0 10 0 0 4 9 0 +56 57 60 1 2 3 0 0 0 0 0 4 5 3 0 0 0 10 0 0 0 12 1 +57 58 63 0 0 3 2 0 0 0 2 0 6 5 9 0 10 0 0 0 8 0 0 +58 59 62 1 0 3 0 0 0 0 0 4 3 0 0 0 10 0 0 0 12 5 1 +59 56 61 0 0 3 0 0 0 0 2 0 0 0 10 0 6 5 9 0 8 0 0 +60 61 56 1 1 3 0 0 0 0 0 0 6 5 1 0 10 0 0 4 9 0 0 +61 62 59 0 0 3 0 0 2 0 0 0 10 0 0 0 12 5 3 0 0 0 8 +62 63 58 1 0 3 0 0 0 0 0 0 0 6 1 0 0 10 0 4 5 9 0 +63 60 57 0 0 3 1 0 2 0 0 0 12 5 3 0 0 0 10 0 0 0 8 +64 65 68 1 2 3 0 0 0 0 0 4 5 3 0 0 0 14 1 0 0 8 0 +65 66 71 0 0 3 2 0 0 2 0 0 6 13 1 0 10 0 0 0 8 0 0 +66 67 70 1 0 3 0 0 0 0 0 0 2 0 0 4 11 0 0 0 12 5 1 +67 64 69 0 0 3 0 0 0 0 2 0 0 0 10 0 4 7 9 0 0 8 0 +68 69 64 1 1 3 0 0 0 0 0 0 6 5 1 4 11 0 0 0 8 0 0 +69 70 67 0 0 3 0 0 2 0 0 0 10 0 0 0 12 7 1 0 0 8 0 +70 71 66 1 0 3 0 0 0 0 0 0 0 2 0 0 0 14 1 4 5 9 0 +71 68 65 0 0 3 1 0 0 2 0 0 4 13 3 0 0 0 10 0 0 0 8 +72 73 76 1 2 3 0 0 0 0 0 4 5 3 0 0 0 12 3 0 0 0 8 +73 74 79 0 0 3 2 0 0 6 1 0 6 9 0 0 10 0 0 0 8 0 0 +74 75 78 1 0 3 0 0 0 0 0 2 0 0 0 12 3 0 0 0 12 5 1 +75 72 77 0 0 3 0 0 0 0 2 0 0 0 10 0 0 6 9 0 4 9 0 +76 77 72 1 1 3 0 0 0 0 0 0 6 5 1 6 9 0 0 8 0 0 0 +77 78 75 0 0 3 0 0 2 0 0 0 10 0 0 0 12 3 0 0 0 12 1 +78 79 74 1 0 3 0 0 0 0 0 0 0 0 2 0 0 6 9 4 5 9 0 +79 76 73 0 0 3 1 0 4 3 0 0 0 12 3 0 0 0 10 0 0 0 8 +80 81 84 1 2 3 0 0 0 0 0 4 3 0 0 0 14 5 1 0 8 0 0 +81 82 87 0 0 3 0 0 0 2 0 0 0 10 0 0 6 13 1 0 8 0 0 +82 83 86 1 0 3 0 0 0 0 0 0 0 2 0 4 5 11 0 0 0 12 1 +83 80 85 0 0 3 2 0 0 0 2 0 4 7 9 0 0 10 0 0 0 8 0 +84 85 80 1 1 3 0 0 0 0 0 0 0 6 1 4 5 11 0 0 0 8 0 +85 86 83 0 0 3 1 0 2 0 0 0 12 7 1 0 0 10 0 0 0 8 0 +86 87 82 1 0 3 0 0 0 0 0 0 2 0 0 0 14 5 1 4 9 0 0 +87 84 81 0 0 3 0 0 0 2 0 0 0 10 0 0 4 13 3 0 0 0 8 +88 89 92 1 2 3 0 0 0 0 0 4 3 0 0 0 12 7 1 0 0 8 0 +89 90 95 0 0 3 0 0 0 2 0 0 0 14 1 0 6 9 0 0 8 0 0 +90 91 94 1 0 3 0 0 0 0 0 0 2 0 0 4 13 3 0 0 0 12 1 +91 88 93 0 0 3 2 0 0 0 2 0 0 6 9 0 4 11 0 0 0 8 0 +92 93 88 1 1 3 0 0 0 0 0 0 0 6 1 4 7 9 0 0 8 0 0 +93 94 91 0 0 3 1 0 2 0 0 0 12 3 0 0 0 14 1 0 0 8 0 +94 95 90 1 0 3 0 0 0 0 0 0 0 2 0 0 6 13 1 4 9 0 0 +95 92 89 0 0 3 0 0 0 2 0 0 4 11 0 0 0 12 3 0 0 0 8 +96 97 100 1 2 3 0 0 0 0 0 4 3 0 0 0 12 5 3 0 0 0 8 +97 98 103 0 0 3 2 0 0 6 1 0 0 10 0 0 6 9 0 0 8 0 0 +98 99 102 1 0 3 0 0 0 0 0 2 0 0 0 12 5 3 0 0 0 12 1 +99 96 101 0 0 3 0 0 0 0 2 0 0 6 9 0 0 10 0 0 4 9 0 +100 101 96 1 1 3 0 0 0 0 0 0 0 6 1 6 5 9 0 8 0 0 0 +101 102 99 0 0 3 0 0 2 0 0 0 12 3 0 0 0 10 0 0 0 12 1 +102 103 98 1 0 3 0 0 0 0 0 0 0 0 2 0 6 5 9 4 9 0 0 +103 100 97 0 0 3 1 0 4 3 0 0 0 10 0 0 0 12 3 0 0 0 8 +104 105 104 1 2 2 0 0 0 0 0 4 7 7 1 0 12 9 0 0 0 0 0 +105 106 107 0 0 3 2 0 2 0 0 0 14 3 0 0 14 9 0 0 8 0 0 +106 107 106 1 0 2 0 0 0 0 0 0 6 3 0 4 13 13 1 0 0 0 0 +107 104 105 0 0 3 0 0 0 2 0 0 6 11 0 0 12 11 0 0 0 8 0 +108 109 108 1 2 2 0 0 0 0 0 6 5 5 3 8 0 0 8 0 0 0 0 +109 110 111 0 0 3 2 0 6 1 0 0 10 0 0 0 10 0 0 0 12 1 0 +110 111 110 1 0 2 0 0 0 0 0 2 0 0 2 12 5 5 9 0 0 0 0 +111 108 109 0 0 3 0 0 4 3 0 0 0 10 0 0 0 10 0 0 4 9 0 +112 113 114 1 2 2 0 0 0 0 0 4 7 3 0 0 12 13 1 0 0 0 0 +113 112 115 0 0 3 2 0 0 2 0 0 6 11 0 0 14 9 0 0 8 0 0 +114 115 112 1 1 2 0 0 0 0 0 0 6 7 1 4 13 9 0 0 0 0 0 +115 114 113 0 0 3 1 0 2 0 0 0 14 3 0 0 12 11 0 0 0 8 0 +116 117 118 1 2 3 0 0 0 0 0 4 3 0 0 0 12 3 0 0 0 12 1 +117 116 119 0 0 3 2 0 0 0 2 0 0 6 9 0 6 9 0 0 8 0 0 +118 119 116 1 1 3 0 0 0 0 0 0 0 6 1 0 6 9 0 4 9 0 0 +119 118 117 0 0 3 1 0 2 0 0 0 12 3 0 0 0 12 3 0 0 0 8 +120 121 122 1 2 3 0 0 0 0 0 2 0 0 0 14 5 5 1 8 0 0 0 +121 122 121 0 0 3 0 0 0 2 0 0 0 10 0 0 0 10 0 0 4 13 1 +122 123 120 1 0 3 0 0 0 0 0 0 0 0 2 4 5 5 11 0 0 0 8 +123 120 123 0 0 3 2 0 4 7 1 0 0 10 0 0 0 10 0 0 0 8 0 +124 125 126 1 2 3 0 0 0 0 0 0 2 0 0 4 15 5 1 0 8 0 0 +125 126 125 0 0 3 0 0 0 2 0 0 0 10 0 0 4 15 1 0 0 8 0 +126 127 124 1 0 3 0 0 0 0 0 0 0 2 0 4 5 15 1 0 0 8 0 +127 124 127 0 0 3 2 0 0 2 0 0 4 15 1 0 0 10 0 0 0 8 0 +128 129 130 1 2 3 0 0 0 0 0 0 2 0 0 4 13 7 1 0 0 8 0 +129 128 131 0 0 3 2 0 0 2 0 0 0 14 1 0 4 11 0 0 0 8 0 +130 131 128 1 1 3 0 0 0 0 0 0 0 2 0 4 7 13 1 0 8 0 0 +131 128 129 0 0 3 1 0 0 2 0 0 4 11 0 0 0 14 1 0 0 8 0 +132 133 134 1 2 3 0 0 0 0 0 2 0 0 0 12 5 5 3 0 0 0 8 +133 132 135 0 0 3 2 0 0 6 1 0 0 10 0 0 0 10 0 0 4 9 0 +134 135 132 1 1 3 0 0 0 0 0 0 0 0 2 6 5 5 9 8 0 0 0 +135 134 133 0 0 3 1 0 4 3 0 0 0 10 0 0 0 10 0 0 0 12 1 +* 5 +# 5 2 +0 1 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 4 5 5 5 1 0 0 0 0 0 0 0 0 0 0 +1 0 1 0 0 4 2 0 0 2 0 0 0 0 10 0 0 0 0 10 0 0 0 0 10 0 0 0 0 8 0 0 +# 6 32 +0 1 4 2 2 3 0 0 0 0 0 0 0 0 0 0 0 6 5 5 5 1 8 0 0 0 0 0 0 0 0 0 +1 2 7 0 0 4 0 0 0 2 0 0 0 0 10 0 0 0 0 10 0 0 0 0 10 0 0 0 0 12 1 0 +2 3 6 2 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 4 5 5 5 9 0 0 0 0 0 +3 0 5 0 0 4 2 0 0 4 3 0 0 0 0 10 0 0 0 0 10 0 0 0 0 10 0 0 0 0 8 0 +4 5 0 2 1 3 0 0 0 0 0 0 0 0 0 0 0 4 5 5 5 3 0 0 0 0 8 0 0 0 0 0 +5 6 3 0 0 4 1 0 0 6 1 0 0 0 10 0 0 0 0 10 0 0 0 0 10 0 0 0 0 8 0 0 +6 7 2 2 0 3 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 12 5 5 5 1 0 0 0 0 0 +7 4 1 0 0 4 0 0 0 0 2 0 0 0 0 10 0 0 0 0 10 0 0 0 0 10 0 0 0 4 9 0 +8 9 12 2 2 3 0 0 0 0 0 0 0 0 0 0 0 4 7 5 5 1 0 8 0 0 0 0 0 0 0 0 +9 10 15 0 0 4 0 0 0 2 0 0 0 0 10 0 0 0 0 10 0 0 0 0 14 1 0 0 0 8 0 0 +10 11 14 2 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 4 5 5 13 1 0 0 0 0 0 +11 8 13 0 0 4 2 0 0 0 2 0 0 0 4 11 0 0 0 0 10 0 0 0 0 10 0 0 0 0 8 0 +12 13 8 2 1 3 0 0 0 0 0 0 0 0 0 0 0 4 5 5 7 1 0 0 0 8 0 0 0 0 0 0 +13 14 11 0 0 4 1 0 0 2 0 0 0 0 14 1 0 0 0 10 0 0 0 0 10 0 0 0 0 8 0 0 +14 15 10 2 0 3 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 4 13 5 5 1 0 0 0 0 0 +15 12 9 0 0 4 0 0 0 0 2 0 0 0 0 10 0 0 0 0 10 0 0 0 4 11 0 0 0 0 8 0 +16 17 20 2 2 3 0 0 0 0 0 0 0 0 0 0 0 4 5 5 3 0 0 0 0 12 1 0 0 0 0 0 +17 18 23 0 0 4 2 0 0 0 2 0 0 0 6 9 0 0 0 10 0 0 0 0 10 0 0 0 0 8 0 0 +18 19 22 2 0 3 0 0 0 0 0 0 0 0 0 0 0 4 3 0 0 0 0 12 5 5 1 0 0 0 0 0 +19 16 21 0 0 4 0 0 0 0 2 0 0 0 0 10 0 0 0 0 10 0 0 0 6 9 0 0 0 8 0 0 +20 21 16 2 1 3 0 0 0 0 0 0 0 0 0 0 0 0 6 5 5 1 4 9 0 0 0 0 0 0 0 0 +21 22 19 0 0 4 0 0 0 2 0 0 0 0 10 0 0 0 0 10 0 0 0 0 12 3 0 0 0 0 8 0 +22 23 18 2 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 1 4 5 5 9 0 0 0 0 0 0 +23 20 17 0 0 4 1 0 0 2 0 0 0 0 12 3 0 0 0 0 10 0 0 0 0 10 0 0 0 0 8 0 +24 25 24 2 2 3 0 0 0 0 0 0 0 0 0 0 0 4 5 7 5 1 0 0 8 0 0 0 0 0 0 0 +25 26 27 0 0 4 2 0 0 2 0 0 0 0 10 0 0 0 0 14 1 0 0 0 10 0 0 0 0 8 0 0 +26 27 26 2 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 4 5 13 5 1 0 0 0 0 0 +27 24 25 0 0 4 0 0 0 0 2 0 0 0 0 10 0 0 0 4 11 0 0 0 0 10 0 0 0 0 8 0 +28 29 30 2 2 3 0 0 0 0 0 0 0 0 0 0 0 4 5 3 0 0 0 0 12 5 1 0 0 0 0 0 +29 28 31 0 0 4 2 0 0 0 2 0 0 0 0 10 0 0 0 6 9 0 0 0 10 0 0 0 0 8 0 0 +30 31 28 2 1 3 0 0 0 0 0 0 0 0 0 0 0 0 0 6 5 1 4 5 9 0 0 0 0 0 0 0 +31 30 29 0 0 4 1 0 0 2 0 0 0 0 10 0 0 0 0 12 3 0 0 0 0 10 0 0 0 0 8 0 +* 6 +# 6 2 +0 1 0 3 2 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 4 5 5 5 5 1 0 0 0 0 0 0 0 0 0 0 0 0 +1 0 1 0 0 5 2 0 0 0 2 0 0 0 0 0 10 0 0 0 0 0 10 0 0 + 0 0 0 10 0 0 0 0 0 10 0 0 0 0 0 8 0 0 diff --git a/data/topnine.gif b/data/topnine.gif new file mode 100755 index 0000000..0248b06 Binary files /dev/null and b/data/topnine.gif differ diff --git a/data/wellcuts.gif b/data/wellcuts.gif new file mode 100755 index 0000000..955d09f Binary files /dev/null and b/data/wellcuts.gif differ diff --git a/data/wellintro.gif b/data/wellintro.gif new file mode 100755 index 0000000..088aff7 Binary files /dev/null and b/data/wellintro.gif differ diff --git a/data/welltris.scores b/data/welltris.scores new file mode 100644 index 0000000..b1e8bcb --- /dev/null +++ b/data/welltris.scores @@ -0,0 +1,54 @@ +1; ;2002-03-07; 0; 0; 0;0;0;0;0 +1; ;2002-03-07; 0; 0; 0;0;0;0;0 +1; ;2002-03-07; 0; 0; 0;0;0;0;0 +1; ;2002-03-07; 0; 0; 0;0;0;0;0 +1; ;2002-03-07; 0; 0; 0;0;0;0;0 +1; ;2002-03-07; 0; 0; 0;0;0;0;0 +1; ;2002-03-07; 0; 0; 0;0;0;0;0 +1; ;2002-03-07; 0; 0; 0;0;0;0;0 +1; ;2002-03-07; 0; 0; 0;0;0;0;0 +2;Leo ;2002-03-18; 50; 2; 7;1;1;136;0 +2; ;2002-03-16; 0; 0; 3;1;1;356;0 +2; ;2002-03-14; 0; 0; 6;1;0;55;0 +2; ;2002-03-14; 0; 0; 2;1;1;126;1 +2; ;2002-03-07; 0; 0; 0;0;0;0;0 +2; ;2002-03-07; 0; 0; 0;0;0;0;0 +2; ;2002-03-07; 0; 0; 0;0;0;0;0 +2; ;2002-03-07; 0; 0; 0;0;0;0;0 +2; ;2002-03-07; 0; 0; 0;0;0;0;0 +3;Leo ;2002-03-30; 71; 3; 8;1;1;939;0 +3; ;2002-03-30; 0; 0; 8;1;1;223;0 +3; ;2002-03-30; 0; 0; 9;1;1;121;0 +3; ;2002-03-07; 0; 0; 0;0;0;0;0 +3; ;2002-03-07; 0; 0; 0;0;0;0;0 +3; ;2002-03-07; 0; 0; 0;0;0;0;0 +3; ;2002-03-07; 0; 0; 0;0;0;0;0 +3; ;2002-03-07; 0; 0; 0;0;0;0;0 +3; ;2002-03-07; 0; 0; 0;0;0;0;0 +4;Irina ;2002-03-30; 10; 1;11;1;1;2301;0 +4; ;2002-03-29; 0; 0; 0;1;1;2130;0 +4; ;2002-03-22; 0; 0; 0;1;1;2114;0 +4; ;2002-03-29; 0; 0; 0;1;1;1771;0 +4; ;2002-03-29; 0; 0; 0;1;1;1623;0 +4; ;2002-03-22; 0; 0; 0;1;1;2103;0 +4; ;2002-03-16; 0; 0; 0;1;1;2223;0 +4; ;2002-03-16; 0; 0; 0;1;1;1972;0 +4; ;2002-03-14; 0; 0; 0;1;1;2468;1 +5;Leo ;2002-03-14; 10; 10; 6;1;1;120;1 +5; ;2002-03-14; 0; 0; 5;0;0;36;0 +5; ;2002-03-14; 0; 0; 2;1;1;147;1 +5; ;2002-03-14; 0; 0; 3;0;1;26;1 +5; ;2002-03-14; 0; 0; 3;1;1;29;1 +5; ;2002-03-14; 0; 0; 1;0;1;65;1 +5; ;2002-03-07; 0; 0; 0;0;0;0;0 +5; ;2002-03-07; 0; 0; 0;0;0;0;0 +5; ;2002-03-07; 0; 0; 0;0;0;0;0 +6;leo ;2003-02-20; 10405; 3; 7;0;0;28;1 +6;leo ;2003-02-20; 6787; 2; 6;0;0;37;1 +6;leo ;2003-02-20; 6118; 4; 7;0;1;46;1 +6;leo ;2003-02-27; 4482; 3; 7;0;1;56;1 +6;leo ;2003-02-20; 3149; 2; 7;0;1;26;1 +6;leo ;2003-02-20; 1810; 1; 7;0;1;27;1 +6;leo ;2003-02-20; 1778; 1; 6;0;1;17;1 +6;leo ;2003-02-20; 1565; 1; 7;0;0;19;1 +6;leo ;2003-02-20; 1037; 0;10;0;0;20;1 diff --git a/docs/srcdoc/sources b/docs/srcdoc/sources new file mode 100644 index 0000000..6a7a6ba --- /dev/null +++ b/docs/srcdoc/sources @@ -0,0 +1,4 @@ +../../src/*.cxx +../../src/include/*.h +../../src/x11/*.cxx +../../src/x11/*.h diff --git a/install-sh b/install-sh new file mode 100755 index 0000000..e9de238 --- /dev/null +++ b/install-sh @@ -0,0 +1,251 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/makedist b/makedist new file mode 100755 index 0000000..5e62c27 --- /dev/null +++ b/makedist @@ -0,0 +1,220 @@ +#! /bin/sh +#Making distribution for XWELLTRIS + +#Using this dir as temporary for package creation +tmpdir="/tmp" +ourname=$0 +instdir=usr + +create_binaries () +{ +#Binary package creation + vers="$1" + mkdir $tmpdir/xwelltris-$vers + echo -n "Copying binaries to "$tmpdir/xwelltris-$vers" directory....." + curdir=`pwd` + cdr=$curdir + cd $tmpdir/xwelltris-$vers + mkdir -p $instdir/bin + mkdir -p $instdir/doc/xwelltris-$vers + mkdir -p $instdir/share/xwelltris + cp -f $cdr/xwelltris $instdir/bin/ + cp -f $cdr/data/polyomino.dat \ + $cdr/data/board2.gif \ + $cdr/data/font2.gif \ + $cdr/data/topnine.gif \ + $cdr/data/wellcuts.gif \ + $cdr/data/wellintro.gif \ + $instdir/share/xwelltris + + cp -f $cdr/README \ + $cdr/README.keys \ + $cdr/AUTHORS \ + $cdr/LICENSE \ + $cdr/Changelog $instdir/doc/xwelltris-$vers + + echo "...OK" + echo -n "Creating TAR Gzipped $2 package...." + tar -cf $curdir/xwelltris-$vers.$2.tar . + echo -n "......." + gzip $curdir/xwelltris-$vers.$2.tar + cd .. + echo "....OK" + cd $curdir + echo -n "Cleaning tmp directory...." + rm -rf $tmpdir/xwelltris-$vers + echo "OK" + echo "Package was created succesfully." + echo "" + echo "Package name: "$curdir/xwelltris-$vers.$2.tar.gz +} + +create_prompted_binaries () +{ + echo -n "Enter platform: " + read platform + create_binaries $1 "$platform" +} + +create_binaries_for_rpm () +{ + vers="$1" + mkdir $tmpdir/xwelltris-$vers + echo -n "Copying all files to "$tmpdir/xwelltris-$vers" directory....." + cp -rf * $tmpdir/xwelltris-$vers + cp -rf ./.xlaunch $tmpdir/xwelltris-$vers + echo "OK" + curdir=`pwd` + cd $tmpdir/xwelltris-$vers + echo -n "Cleaning directories...." + ./makebinclean-rpm + echo "OK" + cd $tmpdir + echo -n "Creating TAR Gzipped package for RPM...." + tar cf $curdir/xwelltris-$vers.elf.tar xwelltris-$vers + echo -n "....." + gzip $curdir/xwelltris-$vers.elf.tar + echo "....OK" + cd $curdir + echo -n "Cleaning tmp directory...." + rm -rf $tmpdir/xwelltris-$vers + echo "OK" + echo "Package was created succesfully." + echo "Package name: "$curdir/xwelltris-$vers.elf.tar.gz +} + +extract_rpm () +{ + vers="$1" + echo "Extracting rpm spec file to 'xwelltris-$vers.spec' from $ourname" + a=`grep -n 'RPM Spec File' $ourname | grep -v grep | tr ':' ' ' \ + | awk '{print $1}'` + b=`wc -l $ourname | awk '{print $1}'` + tail -n `expr $b - $a + 1` $ourname | sed \ + -e "s/^Version:[^\n]*/Version: $vers/" >xwelltris-$vers.spec +} + +echo "-----------------------------------------------------------------" +echo "XWelltris distribution package creator." +echo "Welcome to creation script v2.2.4" +echo "-----------------------------------------------------------------" +echo -n "Enter XWelltris version: " +read vers + +while : +do +echo "" +echo "Choose one of the following:" +echo "" +echo " 1. Create Linux x86 binaries package.......(Linux.x86.tar.gz)." +echo " 2. Create Linux Alpha binaries package.....(Linux.alpha.tar.gz)." +echo " 3. Create Linux PPC binaries package.......(Linux.PPC.tar.gz)." +echo " 4. Create FreeBSD binaries package.........(FreeBSD.tar.gz)." +echo " 5. Create NetBSD x86 binaries package......(NetBSD.x86.tar.gz)." +echo " 6. Create OpenBSD x86 binaries package.....(OpenBSD.x86.tar.gz)." +echo " 7. Create Solaris x86 binaries package.....(Solaris.x86.tar.gz)." +echo " 8. Create Solaris SPARC binaries package...(Solaris.SPARC.tar.gz)." +echo " 9. Create AIX binaries package.............(AIX.tar.gz)." +echo " 10. Create HP-UX binaries package...........(HP-UX.tar.gz)." +echo " 11. Create DUNIX (OSF1) binaries package....(DUnix.tar.gz)." +echo " 12. Create IRIX binaries package............(IRIX.tar.gz)." +echo " 13. Create QNX binaries package.............(QNX.tar.gz)." +echo " 14. Create prompted binaries package." +echo "" +echo " 19. Extract RPM spec file...................(xwelltris-$vers.spec)." +echo "" +echo " 0. Exit" +echo "" +echo -n "Your choice: " +read choice + +case "$choice" in + 1) create_binaries "$vers" "Linux.x86";; + 2) create_binaries "$vers" "Linux.alpha";; + 3) create_binaries "$vers" "Linux.PPC";; + 4) create_binaries "$vers" "FreeBSD";; + 5) create_binaries "$vers" "NetBSD.x86";; + 6) create_binaries "$vers" "OpenBSD.x86";; + 7) create_binaries "$vers" "Solaris.x86";; + 8) create_binaries "$vers" "Solaris.SPARC";; + 9) create_binaries "$vers" "AIX";; + 10) create_binaries "$vers" "HP-UX";; + 11) create_binaries "$vers" "DUnix";; + 12) create_binaries "$vers" "IRIX";; + 13) create_binaries "$vers" "QNX";; + 14) create_prompted_binaries "$vers";; + 19) extract_rpm "$vers";; + 0) exit 0;; +esac +done +echo "-----------------------------------------------------------------" +exit +#----------------------Cut from this line------------------------------- +#---------------RPM Spec File for XWelltris-------------------- + +%define prefix /usr + +Summary: XWelltris - a tetris like popular game for X Window +Name: xwelltris +Version: +Release: 1 +Copyright: GPL +Packager: Leonid Khramov +Group: X11/Applications +Source0: %{name}-%{version}.src.tar.gz +#Icon: +BuildRoot: /tmp/%{name}-%{version}-root + +%description +This is a small tetris like game for X Window. +Imaging that you are looking into the glass from the top. +You see four walls and the bottom. The flat 2d figures falling +down from the walls one by one. You can move these figures from one wall to +another or rotate them... + +%prep +%setup + +%build +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" LDFLAGS=-s ./configure \ + --prefix=%{prefix} --with-x +make + +%install +rm -rf $RPM_BUILD_ROOT + +install -d "$RPM_BUILD_ROOT"/%{prefix}/{bin,share/xwelltris} + +install xwelltris "$RPM_BUILD_ROOT"/%{prefix}/bin + +mkdir -p "$RPM_BUILD_ROOT"/etc/X11/wmconfig +cat > "$RPM_BUILD_ROOT"/etc/X11/wmconfig/xwelltris < $RPM_BUILD_DIR/file.list-%{name}-%{version} +echo "%attr(-,root,root) %doc README README.keys AUTHORS LICENSE Changelog" \ + >> $RPM_BUILD_DIR/file.list-%{name}-%{version} + +%clean +rm -rf $RPM_BUILD_ROOT +rm -f ../file.list-%{name}-%{version} + +%files -f ../file.list-%{name}-%{version} + + + + diff --git a/src/Make.common.in b/src/Make.common.in new file mode 100644 index 0000000..fff6c5c --- /dev/null +++ b/src/Make.common.in @@ -0,0 +1,63 @@ +# ./Make.common.in -*- Makefile -*- +# Makefile common definisions for XNC Project +# + +srcdir = @srcdir@ +VPATH = @srcdir@ + +SHELL = /bin/sh + +# Installation target directories & other installation stuff +prefix = @prefix@ +exec_prefix = @exec_prefix@ +binprefix = +manprefix = +bindir = @bindir@ +mandir = @mandir@/man1 +manext = 1 + +# Tools & program stuff +CC = @CC@ +CXX = @CXX@ +CPP = @CPP@ +RM = @RM@ +RMF = @RM@ -f +CP = @CP@ +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL@ -s -m 755 +INSTALL_DATA = @INSTALL@ -m 644 +INSTALL_SHARE_DATA = @INSTALL@ -m 666 +INS=@INSTALL@ -m 755 +INSM=@INSTALL@ -m 644 +INSD=@INSTALL@ -d -m 755 +INSOWN=@INSTALL@ +INSTDIR=@prefix@/bin +INSTLIB=@prefix@/share/xwelltris +INSTMAN=@prefix@/man +DEB=@DEB@ +STRIPPING= +XINC=@X_CFLAGS@ +XLIBS=@X_PRE_LIBS@ @X_LIBS@ @X_EXTRA_LIBS@ -lX11 -lXext + +CFLAGS = @CFLAGS@ $(PLUGINFLAGS) +CPPFLAGS = @CPPFLAGS@ #-DHAVE_LIBXPM +LDFLAGS = @LDFLAGS@ +SHAREFLAGS = @SHAREFLAGS@ +LD_SHAREFLAGS= @LD_SHAREFLAGS@ +PLUGINS = @PLUGINS@ +DEFS = @DEFS@ +LIBS = @LIBS@ +INCLUDES=-DHAVE_CONFIG_H -I. -I./.. -I./image -I./include -I../include + +# extra libraries needed by X on some systems, X library location +XLIB = @X_LIBS@ @X_PRE_LIBS@ -lX11 @X_EXTRA_LIBS@ #-L/usr/local/lib -lXpm + + +.SUFFIXES: .cxx .c + +.cxx.o: + $(CXX) -c $(CXXINCLUDES) $(INCLUDES) $(CXXOPT) $< -o $@ + +# End of Make.common + + diff --git a/src/commonfuncs.cxx b/src/commonfuncs.cxx new file mode 100644 index 0000000..3cfd66b --- /dev/null +++ b/src/commonfuncs.cxx @@ -0,0 +1,82 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: commonfuncs.cxx,v 1.3 2003/02/27 08:27:51 leo Exp $ + +#include "commonfuncs.h" + + +//=========================================================================== +/// global find_full_path_for_file(char* fname, char* ret_full_pathname, FMode mode) +/// find file in global and local dirs and return full pathname +/// tags common_funcs +bool find_full_path_for_file(char* name, char* ret_full_pathname, FMode mode) +{ +#ifndef WIN32 + int fd; + char *home=getenv("HOME"); + mode_t fmode=O_RDONLY; + + switch(mode) + { + case ReadOnly: + fmode=O_RDONLY; + break; + case ReadWrite: + fmode=O_RDWR; + break; + } + + do + { + sprintf(ret_full_pathname,"%s/%s",GLOBAL_SEARCH,name); //First check in GLOBAL_SEARCH dir + fd=open(ret_full_pathname,fmode); + if(fd>0) + break; + + sprintf(ret_full_pathname,"%s/%s/%s",home,LOCAL_SEARCH,name); //Then in LOCAL one + fd=open(ret_full_pathname,fmode); + if(fd>0) + break; + + sprintf(ret_full_pathname,"./%s",name); //Then in current dir + fd=open(ret_full_pathname,fmode); + if(fd>0) + break; + + sprintf(ret_full_pathname,"./data/%s",name); //And finally in ./data + fd=open(ret_full_pathname,fmode); + if(fd>0) + break; + + fprintf(stderr,"ERROR: Can't find file %s in:\n\t./\n\t./data\n\t%s/%s\n\t%s\n", + name,home,LOCAL_SEARCH,GLOBAL_SEARCH); + return false; + } while(0); + + close(fd); + return true; +#else + FILE *fp; + sprintf(ret_full_pathname,"data\\%s",name); //And finally in ./data + fp=fopen(ret_full_pathname, "r"); + if(fp) + { + fclose(fp); + return true; + } + return false; +#endif +} diff --git a/src/geometry.cxx b/src/geometry.cxx new file mode 100644 index 0000000..8f1f124 --- /dev/null +++ b/src/geometry.cxx @@ -0,0 +1,192 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: geometry.cxx,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $ + +#include "globals.h" +#include "geometry.h" + + +//imNone means simple clear this area with background image :) + +Geo top_key_exit[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 734, 550, 57, 40 }, //Normal view + { imCuts, 0, 365, 734, 550, 57, 39 }, //Highlighted + { imNone, 0, 0, 734, 550, 57, 40 }, //Pressed +}; + +Geo intro_key_exit[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 734, 550, 57, 40 }, //Normal view + { imCuts, 0, 365, 734, 550, 57, 40 }, //Highlighted + { imNone, 0, 0, 734, 550, 57, 40 }, //Pressed +}; + +Geo intro_key_new_game[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 332, 500, 130, 40 }, //Normal view + { imCuts, 0, 215, 332, 500, 130, 40 }, //Highlighted + { imNone, 0, 0, 332, 500, 130, 40 }, //Pressed +}; + +Geo intro_key_top_nine[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 333, 544, 123, 41 }, //Normal view + { imCuts, 0, 255, 333, 544, 123, 41 }, //Highlighted + { imNone, 0, 0, 333, 544, 123, 41 }, //Pressed +}; + +Geo intro_key_plus[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 720, 400, 25, 25 }, //Normal view + { imNone, 0, 0, 720, 400, 25, 25 }, //Highlighted + { imNone, 0, 0, 720, 400, 25, 25 }, //Pressed +}; + +Geo intro_key_minus[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 640, 405, 25, 17 }, //Normal view + { imNone, 0, 0, 640, 405, 25, 17 }, //Highlighted + { imNone, 0, 0, 640, 405, 25, 17 }, //Pressed +}; + +Geo game_elements[]= { + // image srcx srcy dstx dsty len hei + { imCuts, 160, 0, 130, 120, 296, 215 }, //Pause image + { imCuts, 120, 0, 603, 469, 30, 26 }, //Rotation image + { imCuts, 120, 38, 608, 509, 26, 16 }, //Next piece image + { imCuts, 120, 76, 610, 539, 22, 24 }, //Mixed image +}; + +Geo top_nine_elements[]= { + // image srcx srcy dstx dsty len hei + { imCuts, 90, 365, 704, 119, 25, 26 }, //Rotation image + { imCuts, 115, 365, 729, 119, 33, 26 }, //Next piece image + { imCuts, 148, 365, 762, 119, 18, 26 }, //Mixed image +}; + +Geo intro_sw_rotation[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 640, 225, 93, 34 }, //Normal view + { imCuts, 0, 298, 640, 225, 93, 34 }, //Highlighted + { imCuts, 120, 296, 739, 228, 25, 25 }, //Pressed +}; + +Geo intro_sw_next_piece[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 616, 268, 116, 35 }, //Normal view + { imCuts, 0, 330, 616, 268, 116, 35 }, //Highlighted + { imCuts, 120, 330, 739, 270, 25, 25 }, //Pressed +}; + +Geo intro_sw_mixed[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 65, 379, 71, 35 }, //Normal view + { imCuts, 0, 180, 65, 379, 71, 35 }, //Highlighted + { imCuts, 90, 180, 35, 385, 25, 25 }, //Pressed +}; + +Geo intro_sw_square0[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 65, 115, 75, 38 }, //Normal view + { imCuts, 0, 0, 65, 115, 75, 38 }, //Highlighted + { imCuts, 90, 0, 35, 122, 25, 25 }, //Pressed +}; + +Geo intro_sw_square1[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 65, 158, 77, 38 }, //Normal view + { imCuts, 0, 38, 65, 158, 77, 38 }, //Highlighted + { imCuts, 90, 38, 35, 167, 25, 25 }, //Pressed +}; + +Geo intro_sw_square2[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 65, 205, 70, 34 }, //Normal view + { imCuts, 0, 76, 65, 205, 70, 34 }, //Highlighted + { imCuts, 90, 76, 35, 209, 25, 25 }, //Pressed +}; + +Geo intro_sw_square3[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 65, 248, 89, 35 }, //Normal view + { imCuts, 0, 109, 65, 248, 89, 35 }, //Highlighted + { imCuts, 90, 109, 35, 254, 25, 25 }, //Pressed +}; + +Geo intro_sw_square4[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 65, 292, 78, 35 }, //Normal view + { imCuts, 0, 145, 65, 292, 78, 35 }, //Highlighted + { imCuts, 90, 145, 35, 296, 25, 25 }, //Pressed +}; + +Geo intro_sw_square5[]= { + // image srcx srcy dstx dsty len hei + { imNone, 0, 0, 65, 392, 78, 35 }, //Normal view + { imCuts, 0, 145, 65, 392, 78, 35 }, //Highlighted + { imCuts, 90, 145, 35, 396, 25, 25 }, //Pressed +}; + +Geo intro_inp_player_name[]= { + // image srcx srcy dstx dsty len hei + { imCuts, 170, 215, 211, 205, 357, 154 }, //full view + { imCuts, 0, 0, 240, 297, 299, 30 }, //input area + { imCuts, 90, 145, 35, 296, 25, 25 }, //Pressed +}; + + + +// Array of all objects geometry +GeoObject all_objects[]= { + { "top_key_exit" , top_key_exit }, + { "intro_key_exit" , intro_key_exit }, + { "intro_key_new_game", intro_key_new_game }, + { "intro_key_top_nine", intro_key_top_nine }, + { "intro_key_minus" , intro_key_minus }, + { "intro_key_plus" , intro_key_plus }, + { "the_game" , game_elements }, + { "top_nine_elements" , top_nine_elements }, + { "intro_sw_rotation" , intro_sw_rotation }, + { "intro_sw_next" , intro_sw_next_piece }, + { "intro_sw_mixed" , intro_sw_mixed }, + { "intro_sw_square0" , intro_sw_square0 }, + { "intro_sw_square1" , intro_sw_square1 }, + { "intro_sw_square2" , intro_sw_square2 }, + { "intro_sw_square3" , intro_sw_square3 }, + { "intro_sw_square4" , intro_sw_square4 }, + { "intro_sw_square5" , intro_sw_square5 }, + { "intro_inp_player" , intro_inp_player_name }, + { "empty", 0} +}; + + + +//=========================================================================== +/// global get_geo_by_name(char* fname) +/// find geometry structures for object by given name +/// tags geometry +Geo* get_geo_by_name(char* name) +{ + int i=0; + while(all_objects[i].geo) + { + if(!strcmp(all_objects[i].name,name)) + return all_objects[i].geo; + i++; + } + return 0; +} diff --git a/src/image/accel.c b/src/image/accel.c new file mode 100644 index 0000000..77b0224 --- /dev/null +++ b/src/image/accel.c @@ -0,0 +1,101 @@ +/**************************************************************************** +* Copyright (C) 1996 by Leo Khramov +* email: old@sunct2.jinr.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +#include "accel.h" +#include + +char *imd; +void (*im_coding)(unsigned int,unsigned int,unsigned int,char**); +void im_truetruecoding(unsigned int ir,unsigned int ig,unsigned int ib,char **imdata) +{ + int j; + imd=*imdata; + ir>>=red_rsh; + ir<<=red_lsh; + ig>>=green_rsh; + ig<<=green_lsh; + ib>>=blue_rsh; + ib<<=blue_lsh; + ir=ir | ig | ib; + imd+=bdep; + for(j=0;j>=8; + } + + (*imdata)+=bdep; +} + +void im_truenocoding(unsigned int ir,unsigned int ig,unsigned int ib,char **imdata) +{ + *((*imdata)++)=ir&0xff; + *((*imdata)++)=ig&0xff; + *((*imdata)++)=ib&0xff; +} + +char *im_alloc_true(int l,int h) +{ + if (bdep == 1) { + l *= 3; + } else { + l *= bdep; + if (l % b_pad) + l += b_pad - l % b_pad; + } + return (char*) malloc(l*h); +} + +void im_setzero(char* s,int len) +{ + for ( ; len>0; len--) + *s++ = 0; +} + +void im_memcopy(char *src, char* dest, int len) +{ + + if (src==dest || len<=0) + return; /* nothin' to do */ + + if (srcdest) + { /* do backward copy */ + src = src + len - 1; + dest = dest + len - 1; + for ( ; len>0; len--, src--, dest--) + *dest = *src; + } + + else + { + for ( ; len>0; len--, src++, dest++) + *dest = *src; + } +} + + +extern int vclass; + +unsigned int im_get_linew_true(unsigned int w) +{ + unsigned line_w; + if(vclass==TrueColor) + { + line_w = w * bdep; + if (line_w % b_pad) + line_w += b_pad - line_w % b_pad; + } else + line_w=w*3; //24 bit non-converted images in PseudoColor before convertion. + return line_w; +} diff --git a/src/image/accel.h b/src/image/accel.h new file mode 100644 index 0000000..c21c75c --- /dev/null +++ b/src/image/accel.h @@ -0,0 +1,23 @@ +#ifndef ACCEL_H +#define ACCEL_H +#include +extern int depth,bdep,b_pad,translation; +extern unsigned int rmask,gmask,bmask,rsh,bsh,gsh; +extern unsigned int red_rsh,green_rsh,blue_rsh,red_lsh,green_lsh,blue_lsh; +#ifdef __cplusplus +extern "C" char *im_alloc_true(int l,int h); +extern "C" void im_memcopy(char*,char*,int); +extern "C" void im_setzero(char*,int); +extern "C" unsigned int im_get_linew_true(unsigned int w); +#else +extern char *im_alloc_true(int l,int h); +extern void im_memcopy(char*,char*,int); +extern void im_setzero(char*,int); +#endif +extern void (*im_coding)(unsigned int,unsigned int,unsigned int,char**); +extern void im_truetruecoding(unsigned int ir,unsigned int ig,unsigned int ib,char **imdata); +extern void im_truenocoding(unsigned int ir,unsigned int ig,unsigned int ib,char **imdata); + +#endif +/* ------------ End of file -------------- */ + diff --git a/src/image/convert.cxx b/src/image/convert.cxx new file mode 100644 index 0000000..96f7201 --- /dev/null +++ b/src/image/convert.cxx @@ -0,0 +1,902 @@ + +#define JPEG_IMAGES +#include "picinfo.h" +#include "accel.h" + + +static int im_check_for_small_amount_of_colors(PICINFO& pic, int max_colors, + byte* pic8_buf) +{ + unsigned long colors[256],color; + int i, num_color, j; + byte *p, *pix; + + if (max_colors>256) + max_colors = 256; + + num_color = 0; + + for (i=pic.w*pic.h,p=pic.pic; i>0; i--) + { + //construct RGB 24 bit color + color = (((u_long) *p++) << 16); + color += (((u_long) *p++) << 8); + color += *p++; + + for(j=0;j goto next pixel + continue; + + if (num_color >= max_colors) + return 0; + + colors[num_color++]=color; + } + + + //Now convert pixmap with our pallete + for (i=pic.w*pic.h,p=pic.pic,pix=pic8_buf; i>0; i--,pix++) + { + color = (((u_long) *p++) << 16); + color += (((u_long) *p++) << 8); + color += *p++; + + for(j=0;j>16; + pic.pal[i*3+1] = (colors[i]>>8) & 0xff; + pic.pal[i*3+2] = colors[i] & 0xff; + } + + pic.pic=pic8_buf; + + return 1; +} + +static int slow_quant(byte* pic24, int w, int h, byte* pic8, + byte* rm,byte *gm,byte *bm, int max_colors); + +static int im_do_convertion_to_num_colors(PICINFO& pic, int max_colors, + byte* pic8_buf) +{ + byte *redmap,*greenmap,*bluemap; + int i; + + redmap= new byte[256]; + greenmap= new byte[256]; + bluemap= new byte[256]; + + slow_quant(pic.pic,pic.w,pic.h,pic8_buf, + redmap, greenmap, bluemap, max_colors); + + for(i=0;i 0) + { + /* get pixel value and index into the histogram */ + histp = & histogram[pic24[0] >> C0_SHIFT] + [pic24[1] >> C1_SHIFT] + [pic24[2] >> C2_SHIFT]; + /* increment, check for overflow and undo increment if so. */ + if (++(*histp) <= 0) + (*histp)--; + pic24 += 3; + } +} + + +static boxptr find_biggest_color_pop (boxptr boxlist, int numboxes) +{ + register boxptr boxp; + register int i; + register long maxc = 0; + boxptr which = NULL; + + for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { + if (boxp->colorcount > maxc && boxp->volume > 0) { + which = boxp; + maxc = boxp->colorcount; + } + } + return which; +} + + +static boxptr find_biggest_volume (boxptr boxlist, int numboxes) +{ + register boxptr boxp; + register int i; + register INT32 maxv = 0; + boxptr which = NULL; + + for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { + if (boxp->volume > maxv) { + which = boxp; + maxv = boxp->volume; + } + } + return which; +} + + +static void update_box (boxptr boxp) +{ + hist2d * histogram = sl_histogram; + histptr histp; + int c0,c1,c2; + int c0min,c0max,c1min,c1max,c2min,c2max; + INT32 dist0,dist1,dist2; + long ccount; + + c0min = boxp->c0min; c0max = boxp->c0max; + c1min = boxp->c1min; c1max = boxp->c1max; + c2min = boxp->c2min; c2max = boxp->c2max; + + if (c0max > c0min) + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c0min = c0min = c0; + goto have_c0min; + } + } + have_c0min: + if (c0max > c0min) + for (c0 = c0max; c0 >= c0min; c0--) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c0max = c0max = c0; + goto have_c0max; + } + } + have_c0max: + if (c1max > c1min) + for (c1 = c1min; c1 <= c1max; c1++) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c1min = c1min = c1; + goto have_c1min; + } + } + have_c1min: + if (c1max > c1min) + for (c1 = c1max; c1 >= c1min; c1--) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) + if (*histp++ != 0) { + boxp->c1max = c1max = c1; + goto have_c1max; + } + } + have_c1max: + if (c2max > c2min) + for (c2 = c2min; c2 <= c2max; c2++) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1min][c2]; + for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) + if (*histp != 0) { + boxp->c2min = c2min = c2; + goto have_c2min; + } + } + have_c2min: + if (c2max > c2min) + for (c2 = c2max; c2 >= c2min; c2--) + for (c0 = c0min; c0 <= c0max; c0++) { + histp = & histogram[c0][c1min][c2]; + for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) + if (*histp != 0) { + boxp->c2max = c2max = c2; + goto have_c2max; + } + } + have_c2max: + + dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE; + dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE; + dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE; + boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2; + + ccount = 0; + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++, histp++) + if (*histp != 0) { + ccount++; + } + } + boxp->colorcount = ccount; +} + + +static int median_cut (boxptr boxlist, int numboxes, int desired_colors) +{ + int n,lb; + int c0,c1,c2,cmax; + register boxptr b1,b2; + + while (numboxes < desired_colors) { + /* Select box to split. + * Current algorithm: by population for first half, then by volume. + */ + if (numboxes*2 <= desired_colors) { + b1 = find_biggest_color_pop(boxlist, numboxes); + } else { + b1 = find_biggest_volume(boxlist, numboxes); + } + if (b1 == NULL) /* no splittable boxes left! */ + break; + b2 = &boxlist[numboxes]; /* where new box will go */ + /* Copy the color bounds to the new box. */ + b2->c0max = b1->c0max; b2->c1max = b1->c1max; b2->c2max = b1->c2max; + b2->c0min = b1->c0min; b2->c1min = b1->c1min; b2->c2min = b1->c2min; + /* Choose which axis to split the box on. + */ + c0 = ((b1->c0max - b1->c0min) << C0_SHIFT) * C0_SCALE; + c1 = ((b1->c1max - b1->c1min) << C1_SHIFT) * C1_SCALE; + c2 = ((b1->c2max - b1->c2min) << C2_SHIFT) * C2_SCALE; + cmax = c1; n = 1; + if (c0 > cmax) { cmax = c0; n = 0; } + if (c2 > cmax) { n = 2; } + switch (n) { + case 0: + lb = (b1->c0max + b1->c0min) / 2; + b1->c0max = lb; + b2->c0min = lb+1; + break; + case 1: + lb = (b1->c1max + b1->c1min) / 2; + b1->c1max = lb; + b2->c1min = lb+1; + break; + case 2: + lb = (b1->c2max + b1->c2min) / 2; + b1->c2max = lb; + b2->c2min = lb+1; + break; + } + /* Update stats for boxes */ + update_box(b1); + update_box(b2); + numboxes++; + } + return numboxes; +} + + +static void compute_color (boxptr boxp,int icolor) +{ + /* Current algorithm: mean weighted by pixels (not colors) */ + /* Note it is important to get the rounding correct! */ + hist2d * histogram = sl_histogram; + histptr histp; + int c0,c1,c2; + int c0min,c0max,c1min,c1max,c2min,c2max; + long count; + long total = 0; + long c0total = 0; + long c1total = 0; + long c2total = 0; + + c0min = boxp->c0min; c0max = boxp->c0max; + c1min = boxp->c1min; c1max = boxp->c1max; + c2min = boxp->c2min; c2max = boxp->c2max; + + for (c0 = c0min; c0 <= c0max; c0++) + for (c1 = c1min; c1 <= c1max; c1++) { + histp = & histogram[c0][c1][c2min]; + for (c2 = c2min; c2 <= c2max; c2++) { + if ((count = *histp++) != 0) { + total += count; + c0total += ((c0 << C0_SHIFT) + ((1<>1)) * count; + c1total += ((c1 << C1_SHIFT) + ((1<>1)) * count; + c2total += ((c2 << C2_SHIFT) + ((1<>1)) * count; + } + } + } + + sl_colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); + sl_colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); + sl_colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); +} + + +static void slow_select_colors (int descolors) +/* Master routine for color selection */ +{ + box boxlist[MAXNUMCOLORS]; + int numboxes; + int i; + + /* Initialize one box containing whole space */ + numboxes = 1; + boxlist[0].c0min = 0; + boxlist[0].c0max = 255 >> C0_SHIFT; + boxlist[0].c1min = 0; + boxlist[0].c1max = 255 >> C1_SHIFT; + boxlist[0].c2min = 0; + boxlist[0].c2max = 255 >> C2_SHIFT; + /* Shrink it to actually-used volume and set its statistics */ + update_box(& boxlist[0]); + /* Perform median-cut to produce final box list */ + numboxes = median_cut(boxlist, numboxes, descolors); + /* Compute the representative color for each box, fill colormap */ + for (i = 0; i < numboxes; i++) + compute_color(& boxlist[i], i); + sl_num_colors = numboxes; +} + + +/* log2(histogram cells in update box) for each axis; this can be adjusted */ +#define BOX_C0_LOG (HIST_C0_BITS-3) +#define BOX_C1_LOG (HIST_C1_BITS-3) +#define BOX_C2_LOG (HIST_C2_BITS-3) + +#define BOX_C0_ELEMS (1<> 1; + maxc1 = minc1 + ((1 << BOX_C1_SHIFT) - (1 << C1_SHIFT)); + centerc1 = (minc1 + maxc1) >> 1; + maxc2 = minc2 + ((1 << BOX_C2_SHIFT) - (1 << C2_SHIFT)); + centerc2 = (minc2 + maxc2) >> 1; + + minmaxdist = 0x7FFFFFFFL; + + for (i = 0; i < numcolors; i++) { + /* We compute the squared-c0-distance term, then add in the other two. */ + x = sl_colormap[0][i]; + if (x < minc0) { + tdist = (x - minc0) * C0_SCALE; + min_dist = tdist*tdist; + tdist = (x - maxc0) * C0_SCALE; + max_dist = tdist*tdist; + } else if (x > maxc0) { + tdist = (x - maxc0) * C0_SCALE; + min_dist = tdist*tdist; + tdist = (x - minc0) * C0_SCALE; + max_dist = tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + min_dist = 0; + if (x <= centerc0) { + tdist = (x - maxc0) * C0_SCALE; + max_dist = tdist*tdist; + } else { + tdist = (x - minc0) * C0_SCALE; + max_dist = tdist*tdist; + } + } + + x = sl_colormap[1][i]; + if (x < minc1) { + tdist = (x - minc1) * C1_SCALE; + min_dist += tdist*tdist; + tdist = (x - maxc1) * C1_SCALE; + max_dist += tdist*tdist; + } else if (x > maxc1) { + tdist = (x - maxc1) * C1_SCALE; + min_dist += tdist*tdist; + tdist = (x - minc1) * C1_SCALE; + max_dist += tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + if (x <= centerc1) { + tdist = (x - maxc1) * C1_SCALE; + max_dist += tdist*tdist; + } else { + tdist = (x - minc1) * C1_SCALE; + max_dist += tdist*tdist; + } + } + + x = sl_colormap[2][i]; + if (x < minc2) { + tdist = (x - minc2) * C2_SCALE; + min_dist += tdist*tdist; + tdist = (x - maxc2) * C2_SCALE; + max_dist += tdist*tdist; + } else if (x > maxc2) { + tdist = (x - maxc2) * C2_SCALE; + min_dist += tdist*tdist; + tdist = (x - minc2) * C2_SCALE; + max_dist += tdist*tdist; + } else { + /* within cell range so no contribution to min_dist */ + if (x <= centerc2) { + tdist = (x - maxc2) * C2_SCALE; + max_dist += tdist*tdist; + } else { + tdist = (x - minc2) * C2_SCALE; + max_dist += tdist*tdist; + } + } + + mindist[i] = min_dist; /* save away the results */ + if (max_dist < minmaxdist) + minmaxdist = max_dist; + } + + ncolors = 0; + for (i = 0; i < numcolors; i++) { + if (mindist[i] <= minmaxdist) + colorlist[ncolors++] = (JSAMPLE) i; + } + return ncolors; +} + + +static void find_best_colors (int minc0,int minc1,int minc2,int numcolors, + JSAMPLE colorlist[], JSAMPLE bestcolor[]) +{ + int ic0, ic1, ic2; + int i, icolor; + register INT32 * bptr; /* pointer into bestdist[] array */ + JSAMPLE * cptr; /* pointer into bestcolor[] array */ + INT32 dist0, dist1; /* initial distance values */ + register INT32 dist2; /* current distance in inner loop */ + INT32 xx0, xx1; /* distance increments */ + register INT32 xx2; + INT32 inc0, inc1, inc2; /* initial values for increments */ + /* This array holds the distance to the nearest-so-far color for each cell */ + INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; + + /* Initialize best-distance for each cell of the update box */ + bptr = bestdist; + for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--) + *bptr++ = 0x7FFFFFFFL; + + /* Nominal steps between cell centers ("x" in Thomas article) */ +#define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE) +#define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE) +#define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE) + + for (i = 0; i < numcolors; i++) { + icolor = colorlist[i]; + /* Compute (square of) distance from minc0/c1/c2 to this color */ + inc0 = (minc0 - (int) sl_colormap[0][icolor]) * C0_SCALE; + dist0 = inc0*inc0; + inc1 = (minc1 - (int) sl_colormap[1][icolor]) * C1_SCALE; + dist0 += inc1*inc1; + inc2 = (minc2 - (int) sl_colormap[2][icolor]) * C2_SCALE; + dist0 += inc2*inc2; + /* Form the initial difference increments */ + inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0; + inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1; + inc2 = inc2 * (2 * STEP_C2) + STEP_C2 * STEP_C2; + /* Now loop over all cells in box, updating distance per Thomas method */ + bptr = bestdist; + cptr = bestcolor; + xx0 = inc0; + for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) { + dist1 = dist0; + xx1 = inc1; + for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) { + dist2 = dist1; + xx2 = inc2; + for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) { + if (dist2 < *bptr) { + *bptr = dist2; + *cptr = (JSAMPLE) icolor; + } + dist2 += xx2; + xx2 += 2 * STEP_C2 * STEP_C2; + bptr++; + cptr++; + } + dist1 += xx1; + xx1 += 2 * STEP_C1 * STEP_C1; + } + dist0 += xx0; + xx0 += 2 * STEP_C0 * STEP_C0; + } + } +} + + +static void fill_inverse_cmap (int c0, int c1, int c2) +{ + hist2d * histogram = sl_histogram; + int minc0, minc1, minc2; /* lower left corner of update box */ + int ic0, ic1, ic2; + register JSAMPLE * cptr; /* pointer into bestcolor[] array */ + register histptr cachep; /* pointer into main cache array */ + /* This array lists the candidate colormap indexes. */ + JSAMPLE colorlist[MAXNUMCOLORS]; + int numcolors; /* number of candidate colors */ + /* This array holds the actually closest colormap index for each cell. */ + JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; + + /* Convert cell coordinates to update box ID */ + c0 >>= BOX_C0_LOG; + c1 >>= BOX_C1_LOG; + c2 >>= BOX_C2_LOG; + + minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1); + minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1); + minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1); + + numcolors = find_nearby_colors(minc0, minc1, minc2, colorlist); + + /* Determine the actually nearest colors. */ + find_best_colors(minc0, minc1, minc2, numcolors, colorlist, bestcolor); + + /* Save the best color numbers (plus 1) in the main cache array */ + c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */ + c1 <<= BOX_C1_LOG; + c2 <<= BOX_C2_LOG; + cptr = bestcolor; + for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) { + for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) { + cachep = & histogram[c0+ic0][c1+ic1][c2]; + for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) { + *cachep++ = (histcell) (*cptr++ + 1); + } + } + } +} + +static void slow_map_pixels (byte *pic24,int width,int height, byte* pic8) +{ + register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ + LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */ + LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */ + register FSERRPTR errorptr; /* => fserrors[] at column before current */ + JSAMPROW inptr; /* => current input pixel */ + JSAMPROW outptr; /* => current output pixel */ + histptr cachep; + int dir; /* +1 or -1 depending on direction */ + int dir3; /* 3*dir, for advancing inptr & errorptr */ + int row, col; + int *error_limit = sl_error_limiter; + JSAMPROW colormap0 = sl_colormap[0]; + JSAMPROW colormap1 = sl_colormap[1]; + JSAMPROW colormap2 = sl_colormap[2]; + hist2d * histogram = sl_histogram; + + for (row = 0; row < height; row++) { + +/* if ((row&0x3f) == 0) WaitCursor(); + ProgressMeter(0, height-1, row, "Dither");*/ + + inptr = & pic24[row * width * 3]; + outptr = & pic8[row * width]; + if (sl_on_odd_row) { + /* work right to left in this row */ + inptr += (width-1) * 3; /* so point to rightmost pixel */ + outptr += width-1; + dir = -1; + dir3 = -3; + errorptr = sl_fserrors + (width+1)*3; /* => entry after last column */ + sl_on_odd_row = FALSE; /* flip for next time */ + } else { + /* work left to right in this row */ + dir = 1; + dir3 = 3; + errorptr = sl_fserrors; /* => entry before first real column */ + sl_on_odd_row = TRUE; /* flip for next time */ + } + /* Preset error values: no error propagated to first pixel from left */ + cur0 = cur1 = cur2 = 0; + /* and no error propagated to row below yet */ + belowerr0 = belowerr1 = belowerr2 = 0; + bpreverr0 = bpreverr1 = bpreverr2 = 0; + + for (col = width; col > 0; col--) + { + cur0 = (cur0 + errorptr[dir3+0] + 8) >> 4; + cur1 = (cur1 + errorptr[dir3+1] + 8) >> 4; + cur2 = (cur2 + errorptr[dir3+2] + 8) >> 4; + cur0 = error_limit[cur0]; + cur1 = error_limit[cur1]; + cur2 = error_limit[cur2]; + cur0 += inptr[0]; + cur1 += inptr[1]; + cur2 += inptr[2]; + RANGE(cur0, 0, 255); + RANGE(cur1, 0, 255); + RANGE(cur2, 0, 255); + /* Index into the cache with adjusted pixel value */ + cachep = & histogram[cur0>>C0_SHIFT][cur1>>C1_SHIFT][cur2>>C2_SHIFT]; + /* If we have not seen this color before, find nearest colormap */ + /* entry and update the cache */ + if (*cachep == 0) + fill_inverse_cmap(cur0>>C0_SHIFT, cur1>>C1_SHIFT, cur2>>C2_SHIFT); + /* Now emit the colormap index for this cell */ + { register int pixcode = *cachep - 1; + *outptr = (JSAMPLE) pixcode; + /* Compute representation error for this pixel */ + cur0 -= (int) colormap0[pixcode]; + cur1 -= (int) colormap1[pixcode]; + cur2 -= (int) colormap2[pixcode]; + } + /* Compute error fractions to be propagated to adjacent pixels. + * Add these into the running sums, and simultaneously shift the + * next-line error sums left by 1 column. + */ + { register LOCFSERROR bnexterr, delta; + + bnexterr = cur0; /* Process component 0 */ + delta = cur0 * 2; + cur0 += delta; /* form error * 3 */ + errorptr[0] = (FSERROR) (bpreverr0 + cur0); + cur0 += delta; /* form error * 5 */ + bpreverr0 = belowerr0 + cur0; + belowerr0 = bnexterr; + cur0 += delta; /* form error * 7 */ + bnexterr = cur1; /* Process component 1 */ + delta = cur1 * 2; + cur1 += delta; /* form error * 3 */ + errorptr[1] = (FSERROR) (bpreverr1 + cur1); + cur1 += delta; /* form error * 5 */ + bpreverr1 = belowerr1 + cur1; + belowerr1 = bnexterr; + cur1 += delta; /* form error * 7 */ + bnexterr = cur2; /* Process component 2 */ + delta = cur2 * 2; + cur2 += delta; /* form error * 3 */ + errorptr[2] = (FSERROR) (bpreverr2 + cur2); + cur2 += delta; /* form error * 5 */ + bpreverr2 = belowerr2 + cur2; + belowerr2 = bnexterr; + cur2 += delta; /* form error * 7 */ + } + /* At this point curN contains the 7/16 error value to be propagated + * to the next pixel on the current line, and all the errors for the + * next line have been shifted over. We are therefore ready to move on. + */ + inptr += dir3; /* Advance pixel pointers to next column */ + outptr += dir; + errorptr += dir3; /* advance errorptr to current column */ + } + /* Post-loop cleanup: we must unload the final error values into the + * final fserrors[] entry. Note we need not unload belowerrN because + * it is for the dummy column before or after the actual array. + */ + errorptr[0] = (FSERROR) bpreverr0; /* unload prev errs into array */ + errorptr[1] = (FSERROR) bpreverr1; + errorptr[2] = (FSERROR) bpreverr2; + } +} + + +static void init_error_limit () +/* Allocate and fill in the error_limiter table */ +/* Note this should be done only once. */ +{ + int * table; + int in, out; + + table = (int *) malloc((size_t) ((255*2+1) * sizeof(int))); + if (! table) return; + + table += 255; /* so can index -255 .. +255 */ + sl_error_limiter = table; + +#define STEPSIZE ((255+1)/16) + /* Map errors 1:1 up to +- 255/16 */ + out = 0; + for (in = 0; in < STEPSIZE; in++, out++) { + table[in] = out; table[-in] = -out; + } + /* Map errors 1:2 up to +- 3*255/16 */ + for (; in < STEPSIZE*3; in++, out += (in&1) ? 0 : 1) { + table[in] = out; table[-in] = -out; + } + /* Clamp the rest to final out value (which is (255+1)/8) */ + for (; in <= 255; in++) { + table[in] = out; table[-in] = -out; + } +#undef STEPSIZE +} diff --git a/src/image/image.cxx b/src/image/image.cxx new file mode 100644 index 0000000..13647c1 --- /dev/null +++ b/src/image/image.cxx @@ -0,0 +1,890 @@ +/**************************************************************************** +* Copyright (C) 1996-98 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +#include "image.h" +#include "im_exp.h" + +#define ACCEL_H +#define ABS(x) ((x) > 0 ? (x) : (-(x))) +extern "C" void (*im_coding)(unsigned int,unsigned int,unsigned int,char**); +extern "C" void im_truetruecoding(unsigned int ir,unsigned int ig,unsigned int ib,char **imdata); +extern "C" void im_truenocoding(unsigned int ir,unsigned int ig,unsigned int ib,char **imdata); +XColor col; +int vclass; +Visual *vis; +int pcd_resolution=3; +int depth,bdep,translation,b_pad=1; +int fromMem=0; +Colormap defc; +PICINFO im; +char *trans; +uint rmask,gmask,bmask,rsh,bsh,gsh; +uint red_rsh,green_rsh,blue_rsh,red_lsh,green_lsh,blue_lsh; +XColor *XColorTable; +Colormap lcmp; +int ptnum,cmptype; +char check[256]; +int conv24; + +void (*im_coding256)(char **,int); +void im_256truecoding(char**,int); +void im_256nocoding(char**,int); +void im_256256coding(char**,int); + +unsigned long *global_pal=NULL; + +#ifdef PSEUDOCOLOR +unsigned long XPixelTable[256]; +unsigned long Xfreepix[256]; +byte rpart[256]; +byte gpart[256]; +byte bpart[256]; +#endif +int im_getpixels(unsigned long* pt) +{ +#ifdef PSEUDOCOLOR + if(vclass==PseudoColor) + for(int i=0;ibyte_order=MSBFirst; + return xim; +} +#endif + +char *getpicinfo() +{ + char *tmp=new char[strlen(im.fullInfo)+1]; + strcpy(tmp,im.fullInfo); + return tmp; +} + +void do_masks(uint mask,uint &lsh,uint &rsh) +{ + lsh=rsh=0; + while((mask & 1)==0) {lsh++;mask>>=1;}; + while(mask & 1) {rsh++;mask>>=1;}; + rsh=8-rsh; +} + +void im_reset_coding() +{ + im_coding256=im_256nocoding; + translation=0; +} + +void im_set_coding() +{ + im_coding256=im_256truecoding; + translation=1; +} + +long cmap_distance[256]; +int XCmapNumColors; +XColor *XCmapColorTable=NULL; +Colormap XCmapCmap; + +long im_calc_weight(unsigned short red, + unsigned short green, + unsigned short blue) +{ + double r=(double)red; + double g=(double)green; + double b=(double)blue; + return (long)sqrt(r*r+g*g+b*b); +} + +void im_init_cmap(Colormap XColorMap) +{ + + int i, XNumOfColors; + int screen=DefaultScreen(disp); + + depth=DefaultDepth(disp,screen); + vis=DefaultVisual(disp,screen); + defc=DefaultColormap(disp,screen); + vclass=vis->c_class; + XNumOfColors = DisplayCells(disp,DefaultScreen(disp)); + if(XCmapColorTable == NULL) + XCmapColorTable = (XColor *) malloc(sizeof(XColor) * XNumOfColors); + for (i = 0; i < XNumOfColors; i++) + XCmapColorTable[i].pixel = i; + XQueryColors(disp, XColorMap, XCmapColorTable, XNumOfColors); + + for(i=0;i< XNumOfColors;i++) + { + cmap_distance[i]=im_calc_weight(XCmapColorTable[i].red, + XCmapColorTable[i].green, + XCmapColorTable[i].blue); + } + XCmapNumColors=XNumOfColors; + XCmapCmap=XColorMap; +} + +int im_find_closest_color(XColor* orig, XColor* tocol) +{ + unsigned long weight,distance, Red, Green, Blue, D; + int idx=0,i; + if(vclass==TrueColor) + { + *tocol=*orig; + return 0; + } + Red=orig->red; + Green=orig->green; + Blue=orig->blue; + distance=0xffffffff; + for(i=0;iflags = DoGreen | DoRed | DoBlue; + return 1; +} + +int im_find_closest_color2(XColor* orig, XColor* tocol) +{ + long weight,distance; + int idx=0,i; + if(vclass==TrueColor) + { + *tocol=*orig; + return 0; + } + weight=im_calc_weight(orig->red, orig->green, orig->blue); + distance=ABS(cmap_distance[idx]-weight); + for(i=1;iABS(cmap_distance[i]-weight)) + { + idx=i; + distance=ABS(cmap_distance[i]-weight); + } + *tocol=XCmapColorTable[idx]; + tocol->flags = DoGreen | DoRed | DoBlue; + return 1; +} + +Status im_AllocColor(Display* d, Colormap cmap, XColor *cl) +{ + XColor cl2; + Status st; + if((st=XAllocColor(disp, cmap, cl))!=0) + return st; + if(cmap!=XCmapCmap || XCmapColorTable==NULL) + im_init_cmap(cmap); + im_find_closest_color2(cl, &cl2); + *cl=cl2; + return XAllocColor(disp, cmap, cl); +} + +Status (*pim_AllocColor)(Display*, Colormap, XColor*)=im_AllocColor; + +void init_imagengine() +{ + XImage* xim; + XPixmapFormatValues *pixformat; + int i, count; + int screen=DefaultScreen(disp); + + depth=DefaultDepth(disp,screen); + vis=DefaultVisual(disp,screen); + defc=DefaultColormap(disp,screen); + vclass=vis->c_class; + fprintf(stderr, "**********Image Engine**********\n"); + fprintf(stderr,"* *\n"); + switch(vclass) + { + + case TrueColor: + pixformat = XListPixmapFormats(disp, &count); + for (i=0; ired_mask; + gmask=xim->green_mask; + bmask=xim->blue_mask; +#ifdef PCD_SUPPORT + x11_create_lut(rmask,gmask,bmask); +#endif + do_masks(rmask,red_lsh,red_rsh); + do_masks(gmask,green_lsh,green_rsh); + do_masks(bmask,blue_lsh,blue_rsh); + im_coding=im_truetruecoding; + im_coding256=im_256truecoding; + fprintf(stderr,"*Visual: TrueColor *\n"); + fprintf(stderr,"*Depth: %-3d (%d bytes/pixel) *\n",depth,bdep); + fprintf(stderr,"*RGB: %d:%d:%d *\n",8-red_rsh,8-green_rsh,8-blue_rsh); + fprintf(stderr,"*Colors: %-9d *\n",1<=0;j--) + { + trans[i2-j-1]=(char)((col.pixel>>(j<<3))& 0xff); + } + } + } +} + + +XImage *LoadXImage(char *file,int cmptype,int type) +{ + int i,j,l,lw,x,y; + ulong mask; + char *imdata,*imdat; + int ind; + XImage *xim; + ::cmptype=cmptype; + if(vclass==DirectColor) return NULL; +#ifndef PSEUDOCOLOR + if(vclass==PseudoColor) return NULL; +#endif + if(type==F_AUTO) type=autodetect(file); + switch(type) + { + case F_GIF: + translation=0; + im_clear_pic(); + im_load_gif(file,&im,fromMem); + break; + + case F_JPEG: +#ifdef JPEGSUPPORT + im_clear_pic(); + if(vclass==PseudoColor) + translation= 0; + else + translation= 1; + if(LoadJFIF(file,&im)) + break; + else + { + fprintf(stderr,"Image Engine: LoadJpeg\n"); + return NULL; + }; +#else + return NULL; +#endif + case F_TIFF: +#ifdef TIFFSUPPORT + im_clear_pic(); + translation= 0; + if(LoadTIFF(file,&im)) break;else {fprintf(stderr,"Image Engine: LoadTiff\n");return NULL;}; +#else + return NULL; +#endif + case F_PNG: +#ifdef PNG_SUPPORT + im_clear_pic(); + translation= 0; + if(LoadPNG(file,&im)) break;else {fprintf(stderr,"Image Engine: LoadPNG\n");return NULL;}; +#else + return NULL; +#endif + case F_PCX: +#ifdef PCXSUPPORT + im_clear_pic(); + translation= 0; + if(LoadPCX(file,&im)) break;else {fprintf(stderr,"Image Engine: LoadPcx\n");return NULL;}; +#else + return NULL; +#endif + case F_PCD: +#ifdef PCD_SUPPORT + im_clear_pic(); + if(vclass==PseudoColor) translation=0; + else translation= 1; + if(LoadPCD(file,&im)) break;else {fprintf(stderr,"Image Engine: LoadPcd\n");return NULL;}; +#else + return NULL; +#endif + case F_XBM: +#ifdef XBMSUPPORT + im_clear_pic(); + translation=0; + if(LoadXBM(file,&im)) break;else {fprintf(stderr,"Image Engine: LoadXBM\n");return NULL;}; +#else + return NULL; +#endif + case F_XPM: +#ifdef XPMSUPPORT + im_clear_pic(); + translation=0; + if(LoadXPM(file,&im)) break;else {fprintf(stderr,"Image Engine: LoadXPM\n");return NULL;}; +#else + return NULL; +#endif + case F_BMP: +#ifdef BMPSUPPORT + im_clear_pic(); + translation= 1; + if(LoadBMP(file,&im)) break;else {fprintf(stderr,"Image Engine: LoadBmp\n");return NULL;}; +#else + return NULL; +#endif + case F_TARGA: +#ifdef TGASUPPORT + im_clear_pic(); + translation=0; + if(LoadTarga(file,&im)) break;else {fprintf(stderr,"Image Engine: LoadTGA\n");return NULL;}; +#else + return NULL; +#endif + default: return NULL; + }; +#ifdef PSEUDOCOLOR + if(vclass==PseudoColor) + { + if(im.type==PIC8) + return im_process_pseudo_256(im_get_checked()); + else { + im_convert_true_to_pseudo(im,256); + translation=0; + return im_process_pseudo_256(conv24!=CONV24_FAST ? 230:256); + } + } +#endif + if(im.type==PIC8 && vclass==TrueColor) + { + if(translation==0) + { + translation=1; + im_init_translation(); + translation=0; + lw = im.w * bdep; + if (lw % b_pad) + lw += b_pad - lw % b_pad; + l=im.h*im.w; + imdata=new char[lw*im.h]; + i = 0; + for (y=0; ybyte_order=MSBFirst; + return xim; + } else if(im.type==PIC24 && vclass==TrueColor) + { + if(translation==0) + { + lw = im.w * bdep; + if (lw % b_pad) + lw += b_pad - lw % b_pad; + imdata = new char[lw*im.h]; + mask = 0xff; + i = 0; + for (y=0; y < im.h; y++) { + imdat = imdata + y * lw; + for (x=0; x < im.w; x++, i+=3) + im_truetruecoding(im.pic[i],im.pic[i+1],im.pic[i+2],&imdat); + } + free(im.pic); + } + else + imdata=(char*)im.pic; + if((xim=XCreateImage(disp,vis,depth,ZPixmap,0,imdata,im.w,im.h,b_pad*8,0))==NULL) + { + fprintf(stderr,"Image Engine Error: XCreateImage\n"); + delete imdata; + return NULL; + } + xim->byte_order=MSBFirst; + return xim; + } + return NULL; +} + +XImage* encoding256(PICINFO& im,int ncol) +{ + int i,j,l,k,lw; + ulong mask; + char *trans; + char *imdata; + int ind,delta; + XImage *xim; + trans=new char[256*bdep]; + col.flags=DoRed | DoGreen | DoBlue; + ptnum=0; + for(i=0;i=0;j--) + { + trans[mask-j-1]=(char)((col.pixel>>(j<<3))& 0xff); + } + } + l=im.h*im.w; + lw = im.w * bdep; + if (lw % b_pad) { + lw += b_pad - lw % b_pad; + } + imdata=new char[im.h*lw]; + for (i=0; ibyte_order=MSBFirst; + return xim; +} + +void im_256truecoding(char **data,int ind) +{ + char *ltrans=trans+ind*bdep; + for(int i=0;iwidth,iim->height,depth); + gcw=XCreateGC(disp,im,0,NULL); + l=iim->width;h=iim->height; + XPutImage(disp,im,gcw,iim,0,0,0,0,l,h); + XFreeGC(disp,gcw); + delete iim->data;iim->data=NULL;XDestroyImage(iim); + return im; + } + return 0; +} + +Pixmap LoadPixmapFromMem(char *fname,int type,int& l,int& h, + int cmptype,int siz) +{ + XImage *iim; + Pixmap im; + GC gcw; + fromMem=siz; + iim=LoadXImage(fname,cmptype,type); + fromMem=0; + if(iim) + { + im=XCreatePixmap(disp,DefaultRootWindow(disp), + iim->width,iim->height,depth); + gcw=XCreateGC(disp,im,0,NULL); + l=iim->width;h=iim->height; + XPutImage(disp,im,gcw,iim,0,0,0,0,l,h); + XFreeGC(disp,gcw); + delete iim->data;iim->data=NULL;XDestroyImage(iim); + return im; + } + return 0; +} + +void im_populate_pallete(unsigned long* pal) +{ + global_pal=pal; +} + +void im_clear_global_pal() +{ + global_pal=NULL; +} + diff --git a/src/image/image.h b/src/image/image.h new file mode 100644 index 0000000..6a3d4ab --- /dev/null +++ b/src/image/image.h @@ -0,0 +1,55 @@ +#ifndef IMAGE_H +#define IMAGE_H +#ifdef HAVE_CONFIG_H +#include +#endif +#include "globals.h" +#include +#include +#include "picinfo.h" +#include + +extern Display* disp; +extern Colormap defcmp; +extern int conv24; +extern int vclass; +void init_imagengine(); +int im_convert_true_to_pseudo(PICINFO& pic,int max_colors); +int im_getpixels(unsigned long* pt); +Colormap im_get_colormap(); +void im_freecmp(Colormap XColorMap,unsigned long *pt,int iptnum); +void im_populate_pallete(unsigned long* pal); +void im_clear_global_pal(); +char *getpicinfo(); +Pixmap LoadPixmap(char *fname,int type,int& l,int& h,int cmptype=CMP_AUTO); +Pixmap LoadPixmapFromMem(char *fname,int type,int& l,int& h,int cmptype=CMP_AUTO,int siz=0); +XImage *LoadXImage(char *file,int cmptype,int type); +XImage* encoding256(PICINFO& im,int ncol); +int LoadGIF(char* fname,PICINFO* pinfo); +int deGIF(char* fbu,PICINFO* pinfo,int fsiz); +extern "C" int LoadPCD(char* fname,PICINFO* pinfo); +extern "C" int LoadPNG(char *fname,PICINFO* pinfo); +int LoadXBM(char* fname,PICINFO* pinfo); +int LoadXPM(char* fname,PICINFO* pinfo); +int LoadTarga(char* fname,PICINFO* pinfo); +extern "C" int LoadTIFF(char* ,PICINFO*); +int autodetect(char*); +void im_reset_coding(); +void im_set_coding(); +extern int im_find_closest_color(XColor* orig, XColor* tocol); +extern Status im_AllocColor(Display* d, Colormap cmap, XColor *cl); +extern void (*im_coding256)(char **,int); +extern void im_256truecoding(char**,int); +extern void im_init_translation(); +extern "C" int LoadJFIF(char *fname, PICINFO *pinfo); +extern "C" int LoadPCX(char *fname, PICINFO *pinfo); +extern int LoadBMP(char *fname, PICINFO *pinfo); +extern "C" void x11_create_lut(unsigned long, unsigned long, unsigned long); +extern "C" void set_method(int method); + + +#endif +//////////////////////////////////////////End of file/////////////////////////////////////////// + +/* ------------ End of file -------------- */ + diff --git a/src/image/jpeg.c b/src/image/jpeg.c new file mode 100644 index 0000000..d17988e --- /dev/null +++ b/src/image/jpeg.c @@ -0,0 +1,300 @@ +/* + * example.c + * + * This file illustrates how to use the IJG code as a subroutine library + * to read or write JPEG image files. You should look at this code in + * conjunction with the documentation file libjpeg.doc. + * + * This code will not do anything useful as-is, but it may be helpful as a + * skeleton for constructing routines that call the JPEG library. + * + * We present these routines in the same coding style used in the JPEG code + * (ANSI function definitions, etc); but you are of course free to code your + * routines in a different style if you prefer. + */ + +#include +#define JPEG_IMAGES +#include "picinfo.h" +#include "accel.h" +int myfp; +/* + * Include file for users of JPEG library. + * You will need to have included system headers that define at least + * the typedefs FILE and size_t before you can include jpeglib.h. + * (stdio.h is sufficient on ANSI-conforming systems.) + * You may also wish to include "jerror.h". + */ + +#include +/* + * is used for the optional error recovery mechanism shown in + * the second part of the example. + */ + +#include + + + +/******************** JPEG DECOMPRESSION SAMPLE INTERFACE *******************/ + +/* This half of the example shows how to read data from the JPEG decompressor. + * It's a bit more refined than the above, in that we show: + * (a) how to modify the JPEG library's standard error-reporting behavior; + * (b) how to allocate workspace using the library's memory manager. + * + * Just to make this example a little different from the first one, we'll + * assume that we do not intend to put the whole image into an in-memory + * buffer, but to send it line-by-line someplace else. We need a one- + * scanline-high JSAMPLE array as a work buffer, and we will let the JPEG + * memory manager allocate it for us. This approach is actually quite useful + * because we don't need to remember to deallocate the buffer separately: it + * will go away automatically when the JPEG object is cleaned up. + */ + + +/* + * ERROR HANDLING: + * + * The JPEG library's standard error handler (jerror.c) is divided into + * several "methods" which you can override individually. This lets you + * adjust the behavior without duplicating a lot of code, which you might + * have to update with each future release. + * + * Our example here shows how to override the "error_exit" method so that + * control is returned to the library's caller when a fatal error occurs, + * rather than calling exit() as the standard error_exit method does. + * + * We use C's setjmp/longjmp facility to return control. This means that the + * routine which calls the JPEG library must first execute a setjmp() call to + * establish the return point. We want the replacement error_exit to do a + * longjmp(). But we need to make the setjmp buffer accessible to the + * error_exit routine. To do this, we make a private extension of the + * standard JPEG error handler object. (If we were using C++, we'd say we + * were making a subclass of the regular error handler.) + * + * Here's the extended error handler struct: + */ + +struct my_error_mgr { + struct jpeg_error_mgr pub; /* "public" fields */ + + jmp_buf setjmp_buffer; /* for return to caller */ +}; + +typedef struct my_error_mgr * my_error_ptr; + +/* + * Here's the routine that will replace the standard error_exit method: + */ +static void +my_error_exit (j_common_ptr cinfo) +{ + /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ + my_error_ptr myerr = (my_error_ptr) cinfo->err; + + /* Always display the message. */ + /* We could postpone this until after returning, if we chose. */ + (*cinfo->err->output_message) (cinfo); + + /* Return control to the setjmp point */ + longjmp(myerr->setjmp_buffer, 1); +} + + +/* + * Sample routine for JPEG decompression. We assume that the source file name + * is passed in. We want to return 1 on success, 0 on error. + */ + +int jy=0; +char *mybuf; +int jgray=0; +static int line_w; + +void put_jpegdata(unsigned char* b,int l) +{ + int i; + char *buf; + buf = mybuf; + + if(jgray) + for(i=0;iw=cinfo.image_width; + pc->h=cinfo.image_height; + pc->pic=(byte*) im_alloc_true(pc->w,pc->h); + pc->type=PIC24; + mybuf=(char*) pc->pic; + line_w = im_get_linew_true(pc->w); + if(jgray) + sprintf(pc->fullInfo,"%d x %d JPEG image (Grayscale format)",pc->w,pc->h); + else + sprintf(pc->fullInfo,"%d x %d JPEG image (RGB format)",pc->w,pc->h); + + /* Step 4: set parameters for decompression */ + + /* In this example, we don't need to change any of the defaults set by + * jpeg_read_header(), so we do nothing here. + */ + + /* Step 5: Start decompressor */ + + (void) jpeg_start_decompress(&cinfo); + /* We can ignore the return value since suspension is not possible + * with the stdio data source. + */ + + /* We may need to do some setup of our own at this point before reading + * the data. After jpeg_start_decompress() we have the correct scaled + * output image dimensions available, as well as the output colormap + * if we asked for color quantization. + * In this example, we need to make an output work buffer of the right size. + */ + /* JSAMPLEs per row in output buffer */ + row_stride = cinfo.output_width * cinfo.output_components; + /* Make a one-row-high sample array that will go away when done with image */ + buffer = (*cinfo.mem->alloc_sarray) + ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); + + /* Step 6: while (scan lines remain to be read) */ + /* jpeg_read_scanlines(...); */ + + /* Here we use the library's state variable cinfo.output_scanline as the + * loop counter, so that we don't have to keep track ourselves. + */ + while (cinfo.output_scanline < cinfo.output_height) { + /* jpeg_read_scanlines expects an array of pointers to scanlines. + * Here the array is only one element long, but you could ask for + * more than one scanline at a time if that's more convenient. + */ + (void) jpeg_read_scanlines(&cinfo, buffer, 1); + /* Assume put_scanline_someplace wants a pointer and sample count. */ + put_jpegdata((unsigned char*) buffer[0], row_stride); + } + + /* Step 7: Finish decompression */ + + (void) jpeg_finish_decompress(&cinfo); + /* We can ignore the return value since suspension is not possible + * with the stdio data source. + */ + + /* Step 8: Release JPEG decompression object */ + + /* This is an important step since it will release a good deal of memory. */ + jpeg_destroy_decompress(&cinfo); + + /* After finish_decompress, we can close the input file. + * Here we postpone it until after no more JPEG errors are possible, + * so as to simplify the setjmp error logic above. (Actually, I don't + * think that jpeg_destroy can do an error exit, but why assume anything...) + */ + fclose(infile); + + /* At this point you may want to check to see whether any corrupt-data + * warnings occurred (test whether jerr.pub.num_warnings is nonzero). + */ + + /* And we're done! */ + return 1; +} + + +/* + * SOME FINE POINTS: + * + * In the above code, we ignored the return value of jpeg_read_scanlines, + * which is the number of scanlines actually read. We could get away with + * this because we asked for only one line at a time and we weren't using + * a suspending data source. See libjpeg.doc for more info. + * + * We cheated a bit by calling alloc_sarray() after jpeg_start_decompress(); + * we should have done it beforehand to ensure that the space would be + * counted against the JPEG max_memory setting. In some systems the above + * code would risk an out-of-memory error. However, in general we don't + * know the output image dimensions before jpeg_start_decompress(), unless we + * call jpeg_calc_output_dimensions(). See libjpeg.doc for more about this. + * + * Scanlines are returned in the same order as they appear in the JPEG file, + * which is standardly top-to-bottom. If you must emit data bottom-to-top, + * you can use one of the virtual arrays provided by the JPEG memory manager + * to invert the data. See wrbmp.c for an example. + * + * As with compression, some operating modes may require temporary files. + * On some systems you may need to set up a signal handler to ensure that + * temporary files are deleted if the program is interrupted. See libjpeg.doc. + */ +/* + void main(int argc,char **argv) + { + PICINFO ppp; + LoadJFIF(argv[1],&ppp); + } +*/ diff --git a/src/image/makefile.in b/src/image/makefile.in new file mode 100644 index 0000000..99d2cf6 --- /dev/null +++ b/src/image/makefile.in @@ -0,0 +1,48 @@ +# Image Engine for X Window +# +# Copyright (C) 1996 by Leo Khramov +# email: leo@pop.convey.ru +# Fido: 2:5030/627.15 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +include ../make.conf + +@MCOMMON@ + +.SUFFIXES: .c + +.c.o: + $(CC) -c $(CXXOPT) $(CPPFLAGS) -o $@ $< + + IOBJS= \ + sublib/SDL_error.o \ + sublib/SDL_rwops.o \ + sublib/SDL_surface.o \ + sublib/SDL_to_picinfo.o \ + sublib/IMG_gif.o \ + image.o \ + convert.o \ + accel.o + CXXINCLUDES=$(XINC) -I./sublib + CXXOPT=$(CFLAGS) $(DEFS) $(DEB) $(XINC) -I. -I../include -I./sublib + + +all:: $(IOBJS) + +clean: + $(RM) -f *.o + $(RM) -f sublib/*.o + +FORCE: + + diff --git a/src/image/picinfo.h b/src/image/picinfo.h new file mode 100644 index 0000000..0705723 --- /dev/null +++ b/src/image/picinfo.h @@ -0,0 +1,130 @@ +#ifndef PICINFO_H +#define PICINFO_H +#include "config.h" +#include "globdef.h" +#ifdef HAVE_SYS_SIGEVENT_H +#include +#endif +#include +#include +#include +#include +#include +#include +#ifndef __FreeBSD__ +#elif ! defined __OpenBSD__ +#include +#endif +#include +#include + +/* +#undef PARM +#ifdef __STDC__ +# define PARM(a) a +#else +# define PARM(a) () +# define const +#endif + */ +#define MONO(rr,gg,bb) (((rr)*11+(gg)*16+(bb)*5)>>5) /*0.33r+0.5g+0.17b*/ +#ifndef PCD_DEFS +#define RANGE(a,b,c) {if(ac) a=c;} +#endif + +#define GETWD(x) getcwd(x,sizeof(x)) + +#define True 1 +#define False 0 +#define TRUE 1 +#define FALSE 0 +#define F_COLORS 0 +#define F_FORMAT 1 +#define PIC8 0 +#define PIC24 1 +#define F_FULLCOLOR 0 +#define F_GREYSCALE 1 +#define F_BWDITHER 2 +#define F_REDUCED 3 + +#define CMP_AUTO 0 +#define CMP_OWN 1 +#define CMP_COM 2 +#define F_GIF 0 +#define F_PM 1 +#define F_PBMRAW 2 +#define F_PBMASCII 3 +#define F_XBM 4 +#define F_SUNRAS 5 +#define F_BMP 6 +#define F_PS 7 +#define F_IRIS 8 +#define F_JPEG 9 +#define F_AUTO 11 +#define F_TIFF 10 +#define F_PCX 12 +#define F_TARGA 13 +#define F_XPM 14 +#define F_PCD 15 +#define F_PNG 16 + +#define CONV24_FAST 5 +#define CONV24_SLOW 6 +#define CONV24_BEST 7 + +#define ALG_NONE 0 +#define ALG_BLUR3 2 +#define ALG_BLUR5 3 +#define ALG_BLUR7 4 +#define ALG_BLUR9 1 +#define ALG_EDGE 5 +#define ALG_TINF 6 +#define ALG_OIL 7 +#define ALG_GRAY 8 + +typedef unsigned char byte; +#ifndef JPEG_IMAGES +#ifndef PCD_DEFS +#ifndef u_short +typedef unsigned short u_short; +#endif +#ifndef u_char +typedef unsigned char u_char; +#endif +#ifndef u_int +typedef unsigned int u_int; +#endif +#ifndef u_long +typedef unsigned long u_long; +#endif +#endif +#endif + +extern int numcols; +extern float normaspect; +extern int conv24; +extern int noqcheck; +extern int picType,pWIDE,pHIGH,ncols; +extern byte bMap[256],gMap[256],rMap[256]; +extern byte* pic; +extern byte colAllocOrder[256]; + +typedef struct { byte *pic; /* image data */ + int w, h; /* size */ + int type; /* PIC8 or PIC24 */ + + byte pal[768]; + /* colormap, if PIC8 */ + + int frmType; /* def. Format type to save in */ + int colType; /* def. Color type to save in */ + char fullInfo[128]; /* Format: field in info box */ + char shrtInfo[128]; /* short format info */ + char *comment; /* comment text */ + + int numpages; /* # of page files, if >1 */ + char pagebname[64]; /* basename of page files */ + } PICINFO; +#endif +/* ------------ End of file -------------- */ + diff --git a/src/image/sublib/IMG_gif.c b/src/image/sublib/IMG_gif.c new file mode 100644 index 0000000..99907be --- /dev/null +++ b/src/image/sublib/IMG_gif.c @@ -0,0 +1,606 @@ +/* + SDL_image: An example image loading library for use with SDL + Copyright (C) 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* $Id: IMG_gif.c,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $ */ + +/* This is a GIF image file loading framework */ + +#include +#include + +#include "SDL_image.h" + +#define LOAD_GIF + +#ifdef LOAD_GIF + +/* See if an image is contained in a data source */ +int IMG_isGIF(SDL_RWops *src) +{ + int is_GIF; + char magic[6]; + + is_GIF = 0; + if ( SDL_RWread(src, magic, 6, 1) ) { + if ( (strncmp(magic, "GIF", 3) == 0) && + ((memcmp(magic + 3, "87a", 3) == 0) || + (memcmp(magic + 3, "89a", 3) == 0)) ) { + is_GIF = 1; + } + } + return(is_GIF); +} + +/* Code from here to end of file has been adapted from XPaint: */ +/* +-------------------------------------------------------------------+ */ +/* | Copyright 1990, 1991, 1993 David Koblas. | */ +/* | Copyright 1996 Torsten Martinsen. | */ +/* | Permission to use, copy, modify, and distribute this software | */ +/* | and its documentation for any purpose and without fee is hereby | */ +/* | granted, provided that the above copyright notice appear in all | */ +/* | copies and that both that copyright notice and this permission | */ +/* | notice appear in supporting documentation. This software is | */ +/* | provided "as is" without express or implied warranty. | */ +/* +-------------------------------------------------------------------+ */ + +/* Adapted for use in SDL by Sam Lantinga -- 7/20/98 */ +#define USED_BY_SDL + +#include +#include + +#ifdef USED_BY_SDL +/* Changes to work with SDL: + + Include SDL header file + Use SDL_Surface rather than xpaint Image structure + Define SDL versions of RWSetMsg(), ImageNewCmap() and ImageSetCmap() +*/ +#include "SDL.h" + +#define Image SDL_Surface +#define RWSetMsg IMG_SetError +#define ImageNewCmap(w, h, s) SDL_AllocSurface(SDL_SWSURFACE,w,h,8,0,0,0,0) +#define ImageSetCmap(s, i, R, G, B) do { \ + s->format->palette->colors[i].r = R; \ + s->format->palette->colors[i].g = G; \ + s->format->palette->colors[i].b = B; \ + } while (0) +/* * * * * */ + +#else + +/* Original XPaint sources */ + +#include "image.h" +#include "rwTable.h" + +#define SDL_RWops FILE +#define SDL_RWclose fclose + +#endif /* USED_BY_SDL */ + + +#define MAXCOLORMAPSIZE 256 + +#define TRUE 1 +#define FALSE 0 + +#define CM_RED 0 +#define CM_GREEN 1 +#define CM_BLUE 2 + +#define MAX_LWZ_BITS 12 + +#define INTERLACE 0x40 +#define LOCALCOLORMAP 0x80 +#define BitSet(byte, bit) (((byte) & (bit)) == (bit)) + +#define ReadOK(file,buffer,len) SDL_RWread(file, buffer, len, 1) + +#define LM_to_uint(a,b) (((b)<<8)|(a)) + +static struct { + unsigned int Width; + unsigned int Height; + unsigned char ColorMap[3][MAXCOLORMAPSIZE]; + unsigned int BitPixel; + unsigned int ColorResolution; + unsigned int Background; + unsigned int AspectRatio; + int GrayScale; +} GifScreen; + +static struct { + int transparent; + int delayTime; + int inputFlag; + int disposal; +} Gif89; + +static int ReadColorMap(SDL_RWops * src, int number, + unsigned char buffer[3][MAXCOLORMAPSIZE], int *flag); +static int DoExtension(SDL_RWops * src, int label); +static int GetDataBlock(SDL_RWops * src, unsigned char *buf); +static int GetCode(SDL_RWops * src, int code_size, int flag); +static int LWZReadByte(SDL_RWops * src, int flag, int input_code_size); +static Image *ReadImage(SDL_RWops * src, int len, int height, int, + unsigned char cmap[3][MAXCOLORMAPSIZE], + int gray, int interlace, int ignore); + +Image * +IMG_LoadGIF_RW(SDL_RWops *src) +{ + unsigned char buf[16]; + unsigned char c; + unsigned char localColorMap[3][MAXCOLORMAPSIZE]; + int grayScale; + int useGlobalColormap; + int bitPixel; + int imageCount = 0; + char version[4]; + int imageNumber = 1; + Image *image = NULL; + + if ( src == NULL ) { + goto done; + } + if (!ReadOK(src, buf, 6)) { + RWSetMsg("error reading magic number"); + goto done; + } + if (strncmp((char *) buf, "GIF", 3) != 0) { + RWSetMsg("not a GIF file"); + goto done; + } + strncpy(version, (char *) buf + 3, 3); + version[3] = '\0'; + + if ((strcmp(version, "87a") != 0) && (strcmp(version, "89a") != 0)) { + RWSetMsg("bad version number, not '87a' or '89a'"); + goto done; + } + Gif89.transparent = -1; + Gif89.delayTime = -1; + Gif89.inputFlag = -1; + Gif89.disposal = 0; + + if (!ReadOK(src, buf, 7)) { + RWSetMsg("failed to read screen descriptor"); + goto done; + } + GifScreen.Width = LM_to_uint(buf[0], buf[1]); + GifScreen.Height = LM_to_uint(buf[2], buf[3]); + GifScreen.BitPixel = 2 << (buf[4] & 0x07); + GifScreen.ColorResolution = (((buf[4] & 0x70) >> 3) + 1); + GifScreen.Background = buf[5]; + GifScreen.AspectRatio = buf[6]; + + if (BitSet(buf[4], LOCALCOLORMAP)) { /* Global Colormap */ + if (ReadColorMap(src, GifScreen.BitPixel, GifScreen.ColorMap, + &GifScreen.GrayScale)) { + RWSetMsg("error reading global colormap"); + goto done; + } + } + do { + if (!ReadOK(src, &c, 1)) { + RWSetMsg("EOF / read error on image data"); + goto done; + } + if (c == ';') { /* GIF terminator */ + if (imageCount < imageNumber) { + RWSetMsg("only %d image%s found in file", + imageCount, imageCount > 1 ? "s" : ""); + goto done; + } + } + if (c == '!') { /* Extension */ + if (!ReadOK(src, &c, 1)) { + RWSetMsg("EOF / read error on extention function code"); + goto done; + } + DoExtension(src, c); + continue; + } + if (c != ',') { /* Not a valid start character */ + continue; + } + ++imageCount; + + if (!ReadOK(src, buf, 9)) { + RWSetMsg("couldn't read left/top/width/height"); + goto done; + } + useGlobalColormap = !BitSet(buf[8], LOCALCOLORMAP); + + bitPixel = 1 << ((buf[8] & 0x07) + 1); + + if (!useGlobalColormap) { + if (ReadColorMap(src, bitPixel, localColorMap, &grayScale)) { + RWSetMsg("error reading local colormap"); + goto done; + } + image = ReadImage(src, LM_to_uint(buf[4], buf[5]), + LM_to_uint(buf[6], buf[7]), + bitPixel, localColorMap, grayScale, + BitSet(buf[8], INTERLACE), + imageCount != imageNumber); + } else { + image = ReadImage(src, LM_to_uint(buf[4], buf[5]), + LM_to_uint(buf[6], buf[7]), + GifScreen.BitPixel, GifScreen.ColorMap, + GifScreen.GrayScale, BitSet(buf[8], INTERLACE), + imageCount != imageNumber); + } + } while (image == NULL); + +#ifdef USED_BY_SDL + if ( Gif89.transparent >= 0 ) { + SDL_SetColorKey(image, SDL_SRCCOLORKEY, Gif89.transparent); + } +#endif + +done: + return image; +} + +static int +ReadColorMap(SDL_RWops *src, int number, + unsigned char buffer[3][MAXCOLORMAPSIZE], int *gray) +{ + int i; + unsigned char rgb[3]; + int flag; + + flag = TRUE; + + for (i = 0; i < number; ++i) { + if (!ReadOK(src, rgb, sizeof(rgb))) { + RWSetMsg("bad colormap"); + return 1; + } + buffer[CM_RED][i] = rgb[0]; + buffer[CM_GREEN][i] = rgb[1]; + buffer[CM_BLUE][i] = rgb[2]; + flag &= (rgb[0] == rgb[1] && rgb[1] == rgb[2]); + } + +#if 0 + if (flag) + *gray = (number == 2) ? PBM_TYPE : PGM_TYPE; + else + *gray = PPM_TYPE; +#else + *gray = 0; +#endif + + return FALSE; +} + +static int +DoExtension(SDL_RWops *src, int label) +{ + static unsigned char buf[256]; + char *str; + + switch (label) { + case 0x01: /* Plain Text Extension */ + str = "Plain Text Extension"; + break; + case 0xff: /* Application Extension */ + str = "Application Extension"; + break; + case 0xfe: /* Comment Extension */ + str = "Comment Extension"; + while (GetDataBlock(src, (unsigned char *) buf) != 0); + return FALSE; + case 0xf9: /* Graphic Control Extension */ + str = "Graphic Control Extension"; + (void) GetDataBlock(src, (unsigned char *) buf); + Gif89.disposal = (buf[0] >> 2) & 0x7; + Gif89.inputFlag = (buf[0] >> 1) & 0x1; + Gif89.delayTime = LM_to_uint(buf[1], buf[2]); + if ((buf[0] & 0x1) != 0) + Gif89.transparent = buf[3]; + + while (GetDataBlock(src, (unsigned char *) buf) != 0); + return FALSE; + default: + str = (char *)buf; + sprintf(str, "UNKNOWN (0x%02x)", label); + break; + } + + while (GetDataBlock(src, (unsigned char *) buf) != 0); + + return FALSE; +} + +static int ZeroDataBlock = FALSE; + +static int +GetDataBlock(SDL_RWops *src, unsigned char *buf) +{ + unsigned char count; + + if (!ReadOK(src, &count, 1)) { + /* pm_message("error in getting DataBlock size" ); */ + return -1; + } + ZeroDataBlock = count == 0; + + if ((count != 0) && (!ReadOK(src, buf, count))) { + /* pm_message("error in reading DataBlock" ); */ + return -1; + } + return count; +} + +static int +GetCode(SDL_RWops *src, int code_size, int flag) +{ + static unsigned char buf[280]; + static int curbit, lastbit, done, last_byte; + int i, j, ret; + unsigned char count; + + if (flag) { + curbit = 0; + lastbit = 0; + done = FALSE; + return 0; + } + if ((curbit + code_size) >= lastbit) { + if (done) { + if (curbit >= lastbit) + RWSetMsg("ran off the end of my bits"); + return -1; + } + buf[0] = buf[last_byte - 2]; + buf[1] = buf[last_byte - 1]; + + if ((count = GetDataBlock(src, &buf[2])) == 0) + done = TRUE; + + last_byte = 2 + count; + curbit = (curbit - lastbit) + 16; + lastbit = (2 + count) * 8; + } + ret = 0; + for (i = curbit, j = 0; j < code_size; ++i, ++j) + ret |= ((buf[i / 8] & (1 << (i % 8))) != 0) << j; + + curbit += code_size; + + return ret; +} + +static int +LWZReadByte(SDL_RWops *src, int flag, int input_code_size) +{ + static int fresh = FALSE; + int code, incode; + static int code_size, set_code_size; + static int max_code, max_code_size; + static int firstcode, oldcode; + static int clear_code, end_code; + static int table[2][(1 << MAX_LWZ_BITS)]; + static int stack[(1 << (MAX_LWZ_BITS)) * 2], *sp; + register int i; + + if (flag) { + set_code_size = input_code_size; + code_size = set_code_size + 1; + clear_code = 1 << set_code_size; + end_code = clear_code + 1; + max_code_size = 2 * clear_code; + max_code = clear_code + 2; + + GetCode(src, 0, TRUE); + + fresh = TRUE; + + for (i = 0; i < clear_code; ++i) { + table[0][i] = 0; + table[1][i] = i; + } + for (; i < (1 << MAX_LWZ_BITS); ++i) + table[0][i] = table[1][0] = 0; + + sp = stack; + + return 0; + } else if (fresh) { + fresh = FALSE; + do { + firstcode = oldcode = GetCode(src, code_size, FALSE); + } while (firstcode == clear_code); + return firstcode; + } + if (sp > stack) + return *--sp; + + while ((code = GetCode(src, code_size, FALSE)) >= 0) { + if (code == clear_code) { + for (i = 0; i < clear_code; ++i) { + table[0][i] = 0; + table[1][i] = i; + } + for (; i < (1 << MAX_LWZ_BITS); ++i) + table[0][i] = table[1][i] = 0; + code_size = set_code_size + 1; + max_code_size = 2 * clear_code; + max_code = clear_code + 2; + sp = stack; + firstcode = oldcode = GetCode(src, code_size, FALSE); + return firstcode; + } else if (code == end_code) { + int count; + unsigned char buf[260]; + + if (ZeroDataBlock) + return -2; + + while ((count = GetDataBlock(src, buf)) > 0); + + if (count != 0) { + /* + * pm_message("missing EOD in data stream (common occurence)"); + */ + } + return -2; + } + incode = code; + + if (code >= max_code) { + *sp++ = firstcode; + code = oldcode; + } + while (code >= clear_code) { + *sp++ = table[1][code]; + if (code == table[0][code]) + RWSetMsg("circular table entry BIG ERROR"); + code = table[0][code]; + } + + *sp++ = firstcode = table[1][code]; + + if ((code = max_code) < (1 << MAX_LWZ_BITS)) { + table[0][code] = oldcode; + table[1][code] = firstcode; + ++max_code; + if ((max_code >= max_code_size) && + (max_code_size < (1 << MAX_LWZ_BITS))) { + max_code_size *= 2; + ++code_size; + } + } + oldcode = incode; + + if (sp > stack) + return *--sp; + } + return code; +} + +static Image * +ReadImage(SDL_RWops * src, int len, int height, int cmapSize, + unsigned char cmap[3][MAXCOLORMAPSIZE], + int gray, int interlace, int ignore) +{ + Image *image; + unsigned char c; + int i, v; + int xpos = 0, ypos = 0, pass = 0; + + /* + ** Initialize the compression routines + */ + if (!ReadOK(src, &c, 1)) { + RWSetMsg("EOF / read error on image data"); + return NULL; + } + if (LWZReadByte(src, TRUE, c) < 0) { + RWSetMsg("error reading image"); + return NULL; + } + /* + ** If this is an "uninteresting picture" ignore it. + */ + if (ignore) { + while (LWZReadByte(src, FALSE, c) >= 0); + return NULL; + } + image = ImageNewCmap(len, height, cmapSize); + + for (i = 0; i < cmapSize; i++) + ImageSetCmap(image, i, cmap[CM_RED][i], + cmap[CM_GREEN][i], cmap[CM_BLUE][i]); + + while ((v = LWZReadByte(src, FALSE, c)) >= 0) { +#ifdef USED_BY_SDL + ((Uint8 *)image->pixels)[xpos + ypos * image->pitch] = v; +#else + image->data[xpos + ypos * len] = v; +#endif + ++xpos; + if (xpos == len) { + xpos = 0; + if (interlace) { + switch (pass) { + case 0: + case 1: + ypos += 8; + break; + case 2: + ypos += 4; + break; + case 3: + ypos += 2; + break; + } + + if (ypos >= height) { + ++pass; + switch (pass) { + case 1: + ypos = 4; + break; + case 2: + ypos = 2; + break; + case 3: + ypos = 1; + break; + default: + goto fini; + } + } + } else { + ++ypos; + } + } + if (ypos >= height) + break; + } + + fini: + + return image; +} + +#else + +/* See if an image is contained in a data source */ +int IMG_isGIF(SDL_RWops *src) +{ + return(0); +} + +/* Load a GIF type image from an SDL datasource */ +SDL_Surface *IMG_LoadGIF_RW(SDL_RWops *src) +{ + return(NULL); +} + +#endif /* LOAD_GIF */ diff --git a/src/image/sublib/SDL.h b/src/image/sublib/SDL.h new file mode 100644 index 0000000..a48b0ac --- /dev/null +++ b/src/image/sublib/SDL.h @@ -0,0 +1,12 @@ +#ifndef SDL_H + +#define SDL_H + +// SDL main header (dummy file) for compatibility + +#include "SDL_types.h" +#include "SDL_error.h" +#include "SDL_rwops.h" +#include "SDL_video.h" + +#endif diff --git a/src/image/sublib/SDL_error.c b/src/image/sublib/SDL_error.c new file mode 100644 index 0000000..c068b58 --- /dev/null +++ b/src/image/sublib/SDL_error.c @@ -0,0 +1,56 @@ +/* + Copyright (C) 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org + + Modified for using with XNC image engine by Leo + 26-03-2002. +*/ + +#include "SDL.h" + +/* Very common errors go here */ +void SDL_Error(SDL_errorcode code) +{ + switch (code) { + case SDL_ENOMEM: + SDL_SetError("Out of memory"); + break; + case SDL_EFREAD: + SDL_SetError("Error reading from datastream"); + break; + case SDL_EFWRITE: + SDL_SetError("Error writing to datastream"); + break; + case SDL_EFSEEK: + SDL_SetError("Error seeking in datastream"); + break; + default: + SDL_SetError("Unknown SDL error"); + break; + } +} + +void SDL_SetError (const char *fmt, ...) +{ + fprintf(stderr, "SDL_error: %s\n",fmt); +} + +void SDL_ClearError(void) +{ +} diff --git a/src/image/sublib/SDL_error.h b/src/image/sublib/SDL_error.h new file mode 100644 index 0000000..fd8228d --- /dev/null +++ b/src/image/sublib/SDL_error.h @@ -0,0 +1,62 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_error.h,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $"; +#endif + +/* Simple error message routines for SDL */ + +#ifndef _SDL_error_h +#define _SDL_error_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Public functions */ +extern DECLSPEC void SDL_SetError(const char *fmt, ...); +extern DECLSPEC char * SDL_GetError(void); +extern DECLSPEC void SDL_ClearError(void); + +/* Private error message function - used internally */ +#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) +typedef enum { + SDL_ENOMEM, + SDL_EFREAD, + SDL_EFWRITE, + SDL_EFSEEK, + SDL_LASTERROR +} SDL_errorcode; +extern void SDL_Error(SDL_errorcode code); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_error_h */ diff --git a/src/image/sublib/SDL_image.h b/src/image/sublib/SDL_image.h new file mode 100644 index 0000000..60ce9cc --- /dev/null +++ b/src/image/sublib/SDL_image.h @@ -0,0 +1,94 @@ +/* + SDL_image: An example image loading library for use with SDL + Copyright (C) 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* $Id: SDL_image.h,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $ */ + +/* A simple library to load images of various formats as SDL surfaces */ + +#ifndef _IMG_h +#define _IMG_h + +#include "SDL.h" +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Load an image from an SDL data source. + The 'type' may be one of: "BMP", "GIF", "PNG", etc. + + If the image format supports a transparent pixel, SDL will set the + colorkey for the surface. You can enable RLE acceleration on the + surface afterwards by calling: + SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey); + */ +extern DECLSPEC SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, + char *type); +/* Convenience functions */ +extern DECLSPEC SDL_Surface *IMG_Load(const char *file); +extern DECLSPEC SDL_Surface *IMG_Load_RW(SDL_RWops *src, int freesrc); + +/* Invert the alpha of a surface for use with OpenGL + This function is now a no-op, and only provided for backwards compatibility. +*/ +extern DECLSPEC int IMG_InvertAlpha(int on); + +/* Functions to detect a file type, given a seekable source */ +extern DECLSPEC int IMG_isBMP(SDL_RWops *src); +extern DECLSPEC int IMG_isPNM(SDL_RWops *src); +extern DECLSPEC int IMG_isXPM(SDL_RWops *src); +extern DECLSPEC int IMG_isXCF(SDL_RWops *src); +extern DECLSPEC int IMG_isPCX(SDL_RWops *src); +extern DECLSPEC int IMG_isGIF(SDL_RWops *src); +extern DECLSPEC int IMG_isJPG(SDL_RWops *src); +extern DECLSPEC int IMG_isTIF(SDL_RWops *src); +extern DECLSPEC int IMG_isPNG(SDL_RWops *src); +extern DECLSPEC int IMG_isLBM(SDL_RWops *src); + +/* Individual loading functions */ +extern DECLSPEC SDL_Surface *IMG_LoadBMP_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadGIF_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadTIF_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadLBM_RW(SDL_RWops *src); + +extern DECLSPEC SDL_Surface *IMG_ReadXPMFromArray(char **xpm); + +/* We'll use SDL for reporting errors */ +#define IMG_SetError SDL_SetError +#define IMG_GetError SDL_GetError + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _IMG_h */ diff --git a/src/image/sublib/SDL_mutex.h b/src/image/sublib/SDL_mutex.h new file mode 100644 index 0000000..6737407 --- /dev/null +++ b/src/image/sublib/SDL_mutex.h @@ -0,0 +1,8 @@ +#ifndef SDL_MUTEX_H +#define SDL_MUTEX_H + +// Dummy file created by Leo for compatibility +// Need for compile SDL part of files for XNC +// Leo 25-03-2002 + +#endif diff --git a/src/image/sublib/SDL_rwops.c b/src/image/sublib/SDL_rwops.c new file mode 100644 index 0000000..6c2b076 --- /dev/null +++ b/src/image/sublib/SDL_rwops.c @@ -0,0 +1,275 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_rwops.c,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $"; +#endif + +/* This file provides a general interface for SDL to read and write + data sources. It can easily be extended to files, memory, etc. +*/ + +#include +#include +#include + +#include "SDL_error.h" +#include "SDL_rwops.h" + +/* Functions to read/write stdio file pointers */ + +static int stdio_seek(SDL_RWops *context, int offset, int whence) +{ + if ( fseek(context->hidden.stdio.fp, offset, whence) == 0 ) { + return(ftell(context->hidden.stdio.fp)); + } else { + SDL_Error(SDL_EFSEEK); + return(-1); + } +} +static int stdio_read(SDL_RWops *context, void *ptr, int size, int maxnum) +{ + size_t nread; + + nread = fread(ptr, size, maxnum, context->hidden.stdio.fp); + if ( nread == 0 && ferror(context->hidden.stdio.fp) ) { + SDL_Error(SDL_EFREAD); + } + return(nread); +} +static int stdio_write(SDL_RWops *context, const void *ptr, int size, int num) +{ + size_t nwrote; + + nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp); + if ( nwrote == 0 && ferror(context->hidden.stdio.fp) ) { + SDL_Error(SDL_EFWRITE); + } + return(nwrote); +} +static int stdio_close(SDL_RWops *context) +{ + if ( context ) { + if ( context->hidden.stdio.autoclose ) { + /* WARNING: Check the return value here! */ + fclose(context->hidden.stdio.fp); + } + free(context); + } + return(0); +} + +/* Functions to read/write memory pointers */ + +static int mem_seek(SDL_RWops *context, int offset, int whence) +{ + Uint8 *newpos; + + switch (whence) { + case SEEK_SET: + newpos = context->hidden.mem.base+offset; + break; + case SEEK_CUR: + newpos = context->hidden.mem.here+offset; + break; + case SEEK_END: + newpos = context->hidden.mem.stop+offset; + break; + default: + SDL_SetError("Unknown value for 'whence'"); + return(-1); + } + if ( newpos < context->hidden.mem.base ) { + newpos = context->hidden.mem.base; + } + if ( newpos > context->hidden.mem.stop ) { + newpos = context->hidden.mem.stop; + } + context->hidden.mem.here = newpos; + return(context->hidden.mem.here-context->hidden.mem.base); +} +static int mem_read(SDL_RWops *context, void *ptr, int size, int maxnum) +{ + int num; + + num = maxnum; + if ( (context->hidden.mem.here + (num*size)) > context->hidden.mem.stop ) { + num = (context->hidden.mem.stop-context->hidden.mem.here)/size; + } + memcpy(ptr, context->hidden.mem.here, num*size); + context->hidden.mem.here += num*size; + return(num); +} +static int mem_write(SDL_RWops *context, const void *ptr, int size, int num) +{ + if ( (context->hidden.mem.here + (num*size)) > context->hidden.mem.stop ) { + num = (context->hidden.mem.stop-context->hidden.mem.here)/size; + } + memcpy(context->hidden.mem.here, ptr, num*size); + context->hidden.mem.here += num*size; + return(num); +} +static int mem_close(SDL_RWops *context) +{ + if ( context ) { + free(context); + } + return(0); +} + +/* Functions to create SDL_RWops structures from various data sources */ +#ifdef WIN32 +/* Aggh. You can't (apparently) open a file in an application and + read from it in a DLL. +*/ +static int in_sdl = 0; +#endif + +#ifdef macintosh +/* + * translate unix-style slash-separated filename to mac-style colon-separated + * name; return malloced string + */ +static char *unix_to_mac(const char *file) +{ + int flen = strlen(file); + char *path = malloc(flen + 2); + const char *src = file; + char *dst = path; + if(*src == '/') { + /* really depends on filesystem layout, hope for the best */ + src++; + } else { + /* Check if this is a MacOS path to begin with */ + if(*src != ':') + *dst++ = ':'; /* relative paths begin with ':' */ + } + while(src < file + flen) { + const char *end = strchr(src, '/'); + int len; + if(!end) + end = file + flen; /* last component */ + len = end - src; + if(len == 0 || (len == 1 && src[0] == '.')) { + /* remove repeated slashes and . */ + } else { + if(len == 2 && src[0] == '.' && src[1] == '.') { + /* replace .. with the empty string */ + } else { + memcpy(dst, src, len); + dst += len; + } + if(end < file + flen) + *dst++ = ':'; + } + src = end + 1; + } + *dst++ = '\0'; + return path; +} +#endif /* macintosh */ + +SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) +{ + FILE *fp; + SDL_RWops *rwops; + + rwops = NULL; + +#ifdef macintosh + { + char *mpath = unix_to_mac(file); + fp = fopen(mpath, mode); + free(mpath); + } +#else + fp = fopen(file, mode); +#endif + if ( fp == NULL ) { + SDL_SetError("Couldn't open %s", file); + } else { +#ifdef WIN32 + in_sdl = 1; + rwops = SDL_RWFromFP(fp, 1); + in_sdl = 0; +#else + rwops = SDL_RWFromFP(fp, 1); +#endif + } + return(rwops); +} + +SDL_RWops *SDL_RWFromFP(FILE *fp, int autoclose) +{ + SDL_RWops *rwops; + +#ifdef WIN32 + if ( ! in_sdl ) { + SDL_SetError("You can't pass a FILE pointer to a DLL (??)"); + /*return(NULL);*/ + } +#endif + rwops = SDL_AllocRW(); + if ( rwops != NULL ) { + rwops->seek = stdio_seek; + rwops->read = stdio_read; + rwops->write = stdio_write; + rwops->close = stdio_close; + rwops->hidden.stdio.fp = fp; + rwops->hidden.stdio.autoclose = autoclose; + } + return(rwops); +} + +SDL_RWops *SDL_RWFromMem(void *mem, int size) +{ + SDL_RWops *rwops; + + rwops = SDL_AllocRW(); + if ( rwops != NULL ) { + rwops->seek = mem_seek; + rwops->read = mem_read; + rwops->write = mem_write; + rwops->close = mem_close; + rwops->hidden.mem.base = (Uint8 *)mem; + rwops->hidden.mem.here = rwops->hidden.mem.base; + rwops->hidden.mem.stop = rwops->hidden.mem.base+size; + } + return(rwops); +} + +SDL_RWops *SDL_AllocRW(void) +{ + SDL_RWops *area; + + area = (SDL_RWops *)malloc(sizeof *area); + if ( area == NULL ) { + SDL_OutOfMemory(); + } + return(area); +} + +void SDL_FreeRW(SDL_RWops *area) +{ + free(area); +} diff --git a/src/image/sublib/SDL_rwops.h b/src/image/sublib/SDL_rwops.h new file mode 100644 index 0000000..8e23340 --- /dev/null +++ b/src/image/sublib/SDL_rwops.h @@ -0,0 +1,113 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_rwops.h,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $"; +#endif + +/* This file provides a general interface for SDL to read and write + data sources. It can easily be extended to files, memory, etc. +*/ + +#ifndef _SDL_RWops_h +#define _SDL_RWops_h + +#include + +#include "SDL_types.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This is the read/write operation structure -- very basic */ + +typedef struct SDL_RWops { + /* Seek to 'offset' relative to whence, one of stdio's whence values: + SEEK_SET, SEEK_CUR, SEEK_END + Returns the final offset in the data source. + */ + int (*seek)(struct SDL_RWops *context, int offset, int whence); + + /* Read up to 'num' objects each of size 'objsize' from the data + source to the area pointed at by 'ptr'. + Returns the number of objects read, or -1 if the read failed. + */ + int (*read)(struct SDL_RWops *context, void *ptr, int size, int maxnum); + + /* Write exactly 'num' objects each of size 'objsize' from the area + pointed at by 'ptr' to data source. + Returns 'num', or -1 if the write failed. + */ + int (*write)(struct SDL_RWops *context, const void *ptr, int size, int num); + + /* Close and free an allocated SDL_FSops structure */ + int (*close)(struct SDL_RWops *context); + + Uint32 type; + union { + struct { + int autoclose; + FILE *fp; + } stdio; + struct { + Uint8 *base; + Uint8 *here; + Uint8 *stop; + } mem; + struct { + void *data1; + } unknown; + } hidden; + +} SDL_RWops; + + +/* Functions to create SDL_RWops structures from various data sources */ + +extern DECLSPEC SDL_RWops * SDL_RWFromFile(const char *file, const char *mode); + +extern DECLSPEC SDL_RWops * SDL_RWFromFP(FILE *fp, int autoclose); + +extern DECLSPEC SDL_RWops * SDL_RWFromMem(void *mem, int size); + +extern DECLSPEC SDL_RWops * SDL_AllocRW(void); +extern DECLSPEC void SDL_FreeRW(SDL_RWops *area); + +/* Macros to easily read and write from an SDL_RWops structure */ +#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) +#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, SEEK_CUR) +#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) +#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) +#define SDL_RWclose(ctx) (ctx)->close(ctx) + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_RWops_h */ diff --git a/src/image/sublib/SDL_surface.c b/src/image/sublib/SDL_surface.c new file mode 100644 index 0000000..9b25e3c --- /dev/null +++ b/src/image/sublib/SDL_surface.c @@ -0,0 +1,331 @@ + +#include "SDL.h" + + +/* + * Calculate the pad-aligned scanline width of a surface + */ +Uint16 SDL_CalculatePitch(SDL_Surface *surface) +{ + Uint16 pitch; + + /* Surface should be 4-byte aligned for speed */ + pitch = surface->w*surface->format->BytesPerPixel; + switch (surface->format->BitsPerPixel) + { + case 1: + pitch = (pitch+7)/8; + break; + case 4: + pitch = (pitch+1)/2; + break; + default: + break; + } + pitch = (pitch + 3) & ~3; /* 4-byte aligning */ + return(pitch); +} + +/* + * Free a previously allocated format structure + */ +void SDL_FreeFormat(SDL_PixelFormat *format) +{ + if ( format ) + { + if ( format->palette ) + { + if ( format->palette->colors ) + { + free(format->palette->colors); + } + free(format->palette); + } + free(format); + } +} + +/* Helper functions */ +/* + * Allocate a pixel format structure and fill it according to the given info. + */ +SDL_PixelFormat *SDL_AllocFormat(int bpp, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) +{ + SDL_PixelFormat *format; + Uint32 mask; + + /* Allocate an empty pixel format structure */ + format = (SDL_PixelFormat*)malloc(sizeof(*format)); + if ( format == NULL ) { + SDL_OutOfMemory(); + return(NULL); + } + memset(format, 0, sizeof(*format)); + format->alpha = SDL_ALPHA_OPAQUE; + + /* Set up the format */ + format->BitsPerPixel = bpp; + format->BytesPerPixel = (bpp+7)/8; + switch (bpp) { + case 1: + /* Create the 2 color black-white palette */ + format->palette = (SDL_Palette *)malloc( + sizeof(SDL_Palette)); + if ( format->palette == NULL ) { + SDL_FreeFormat(format); + SDL_OutOfMemory(); + return(NULL); + } + (format->palette)->ncolors = 2; + (format->palette)->colors = (SDL_Color *)malloc( + (format->palette)->ncolors*sizeof(SDL_Color)); + if ( (format->palette)->colors == NULL ) { + SDL_FreeFormat(format); + SDL_OutOfMemory(); + return(NULL); + } + format->palette->colors[0].r = 0xFF; + format->palette->colors[0].g = 0xFF; + format->palette->colors[0].b = 0xFF; + format->palette->colors[1].r = 0x00; + format->palette->colors[1].g = 0x00; + format->palette->colors[1].b = 0x00; + format->Rloss = 8; + format->Gloss = 8; + format->Bloss = 8; + format->Aloss = 8; + format->Rshift = 0; + format->Gshift = 0; + format->Bshift = 0; + format->Ashift = 0; + format->Rmask = 0; + format->Gmask = 0; + format->Bmask = 0; + format->Amask = 0; + break; + + case 4: + /* Create the 16 color VGA palette */ + format->palette = (SDL_Palette *)malloc( + sizeof(SDL_Palette)); + if ( format->palette == NULL ) { + SDL_FreeFormat(format); + SDL_OutOfMemory(); + return(NULL); + } + (format->palette)->ncolors = 16; + (format->palette)->colors = (SDL_Color *)malloc( + (format->palette)->ncolors*sizeof(SDL_Color)); + if ( (format->palette)->colors == NULL ) { + SDL_FreeFormat(format); + SDL_OutOfMemory(); + return(NULL); + } + /* Punt for now, will this ever be used? */ + memset((format->palette)->colors, 0, + (format->palette)->ncolors*sizeof(SDL_Color)); + + /* Palettized formats have no mask info */ + format->Rloss = 8; + format->Gloss = 8; + format->Bloss = 8; + format->Aloss = 8; + format->Rshift = 0; + format->Gshift = 0; + format->Bshift = 0; + format->Ashift = 0; + format->Rmask = 0; + format->Gmask = 0; + format->Bmask = 0; + format->Amask = 0; + break; + + case 8: + /* Create an empty 256 color palette */ + format->palette = (SDL_Palette *)malloc( + sizeof(SDL_Palette)); + if ( format->palette == NULL ) { + SDL_FreeFormat(format); + SDL_OutOfMemory(); + return(NULL); + } + (format->palette)->ncolors = 256; + (format->palette)->colors = (SDL_Color *)malloc( + (format->palette)->ncolors*sizeof(SDL_Color)); + if ( (format->palette)->colors == NULL ) { + SDL_FreeFormat(format); + SDL_OutOfMemory(); + return(NULL); + } + memset((format->palette)->colors, 0, + (format->palette)->ncolors*sizeof(SDL_Color)); + + /* Palettized formats have no mask info */ + format->Rloss = 8; + format->Gloss = 8; + format->Bloss = 8; + format->Aloss = 8; + format->Rshift = 0; + format->Gshift = 0; + format->Bshift = 0; + format->Ashift = 0; + format->Rmask = 0; + format->Gmask = 0; + format->Bmask = 0; + format->Amask = 0; + break; + + default: + /* No palette, just packed pixel info */ + format->palette = NULL; + format->Rshift = 0; + format->Rloss = 8; + if ( Rmask ) { + for ( mask = Rmask; !(mask&0x01); mask >>= 1 ) + ++format->Rshift; + for ( ; (mask&0x01); mask >>= 1 ) + --format->Rloss; + } + format->Gshift = 0; + format->Gloss = 8; + if ( Gmask ) { + for ( mask = Gmask; !(mask&0x01); mask >>= 1 ) + ++format->Gshift; + for ( ; (mask&0x01); mask >>= 1 ) + --format->Gloss; + } + format->Bshift = 0; + format->Bloss = 8; + if ( Bmask ) { + for ( mask = Bmask; !(mask&0x01); mask >>= 1 ) + ++format->Bshift; + for ( ; (mask&0x01); mask >>= 1 ) + --format->Bloss; + } + format->Ashift = 0; + format->Aloss = 8; + if ( Amask ) { + for ( mask = Amask; !(mask&0x01); mask >>= 1 ) + ++format->Ashift; + for ( ; (mask&0x01); mask >>= 1 ) + --format->Aloss; + } + format->Rmask = Rmask; + format->Gmask = Gmask; + format->Bmask = Bmask; + format->Amask = Amask; + break; + } + /* Calculate some standard bitmasks, if necessary + * Note: This could conflict with an alpha mask, if given. + */ + if ( (bpp > 8) && !format->Rmask && !format->Gmask && !format->Bmask ) { + /* R-G-B */ + if ( bpp > 24 ) + bpp = 24; + format->Rloss = 8-(bpp/3); + format->Gloss = 8-(bpp/3)-(bpp%3); + format->Bloss = 8-(bpp/3); + format->Rshift = ((bpp/3)+(bpp%3))+(bpp/3); + format->Gshift = (bpp/3); + format->Bshift = 0; + format->Rmask = ((0xFF>>format->Rloss)<Rshift); + format->Gmask = ((0xFF>>format->Gloss)<Gshift); + format->Bmask = ((0xFF>>format->Bloss)<Bshift); + } + return(format); +} + +/* + * Free a surface created by the above function. + */ +void SDL_FreeSurface (SDL_Surface *surface) +{ + /* Free anything that's not NULL, and not the screen surface */ + if (surface == NULL) + { + return; + } + if ( --surface->refcount > 0 ) { + return; + } + if ( surface->format ) + { + SDL_FreeFormat(surface->format); + surface->format = NULL; + } + if ( surface->pixels && + ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC) ) + { + free(surface->pixels); + } + free(surface); +} + + + +/* Public routines */ +/* + * Create an empty RGB surface of the appropriate depth + */ +SDL_Surface * SDL_CreateRGBSurface (Uint32 flags, + int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) +{ + SDL_Surface *surface; + + flags &= ~SDL_HWSURFACE; + + /* Allocate the surface */ + surface = (SDL_Surface *)malloc(sizeof(*surface)); + if ( surface == NULL ) + { + return(NULL); + } + surface->flags = SDL_SWSURFACE; + + surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask); + + if ( surface->format == NULL ) + { + free(surface); + return(NULL); + } + if ( Amask ) + { + surface->flags |= SDL_SRCALPHA; + } + surface->w = width; + surface->h = height; + surface->pitch = SDL_CalculatePitch(surface); + surface->pixels = NULL; + surface->offset = 0; + // surface->hwdata = NULL; + // surface->locked = 0; + // surface->map = NULL; + surface->format_version = 0; + + if ( surface->w && surface->h ) + { + surface->pixels = (void*)malloc(surface->h*surface->pitch); + if ( surface->pixels == NULL ) + { + SDL_FreeSurface(surface); + return(NULL); + } + /* This is important for bitmaps */ + memset(surface->pixels, 0, surface->h*surface->pitch); + } + + /* The surface is ready to go */ + surface->refcount = 1; + return(surface); +} + +int SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key) +{ + return 0; +} + + diff --git a/src/image/sublib/SDL_to_picinfo.c b/src/image/sublib/SDL_to_picinfo.c new file mode 100644 index 0000000..5a2493b --- /dev/null +++ b/src/image/sublib/SDL_to_picinfo.c @@ -0,0 +1,64 @@ +#define JPEG_IMAGES +#include "SDL.h" +#include "picinfo.h" +#include "SDL_image.h" + +void im_sdl_surface_to_picinfo(SDL_Surface* surface, PICINFO* pic) +{ + int i; + + pic->w=surface->w; + pic->h=surface->h; + + if(surface->format->BytesPerPixel==1) + { + pic->type=PIC8; + pic->pic=(byte*)surface->pixels; + surface->pixels=0; + for(i=0;i<256;i++) + { + pic->pal[i*3] =surface->format->palette->colors[i].r; + pic->pal[i*3+1]=surface->format->palette->colors[i].g; + pic->pal[i*3+2]=surface->format->palette->colors[i].b; + } + SDL_FreeSurface(surface); + } + else + { + pic->type=PIC24; + pic->pic=(byte*)surface->pixels; + surface->pixels=0; + SDL_FreeSurface(surface); + } +} + +int im_load_image_through_loader(char* fname, PICINFO* to_pic, + int from_mem_size, + SDL_Surface* (*img_loader)(SDL_RWops*)) +{ + SDL_RWops *rw; + SDL_Surface *surface; + + if(!from_mem_size) + rw=SDL_RWFromFile(fname,"rb"); + else + rw=SDL_RWFromMem((void*)fname, from_mem_size); + + surface=img_loader(rw); + + SDL_FreeRW(rw); + + im_sdl_surface_to_picinfo(surface,to_pic); + + return 1; +} + +/******************************************************************/ + +int im_load_gif(char* fname, PICINFO* to_pic, int from_mem_size) +{ + + return im_load_image_through_loader(fname,to_pic, + from_mem_size,IMG_LoadGIF_RW); +} + diff --git a/src/image/sublib/SDL_types.h b/src/image/sublib/SDL_types.h new file mode 100644 index 0000000..f5cb43d --- /dev/null +++ b/src/image/sublib/SDL_types.h @@ -0,0 +1,92 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_types.h,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $"; +#endif + +/* General data types used by the SDL library */ + +#ifndef _SDL_types_h +#define _SDL_types_h + +/* The number of elements in a table */ +#define SDL_TABLESIZE(table) (sizeof(table)/sizeof(table[0])) + +/* Basic data types */ +typedef enum { + SDL_FALSE = 0, + SDL_TRUE = 1 +} SDL_bool; +typedef unsigned char Uint8; +typedef signed char Sint8; +typedef unsigned short Uint16; +typedef signed short Sint16; +typedef unsigned int Uint32; +typedef signed int Sint32; + +/* Figure out how to support 64-bit datatypes */ +#if !defined(__STRICT_ANSI__) +#if defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_C) +#define SDL_HAS_64BIT_TYPE long long +#elif defined(_MSC_VER) /* VC++ */ +#define SDL_HAS_64BIT_TYPE __int64 +#endif +#endif /* !__STRICT_ANSI__ */ + +/* The 64-bit type isn't available on EPOC/Symbian OS */ +#ifdef __SYMBIAN32__ +#undef SDL_HAS_64BIT_TYPE +#endif + +/* The 64-bit datatype isn't supported on all platforms */ +#ifdef SDL_HAS_64BIT_TYPE +typedef unsigned SDL_HAS_64BIT_TYPE Uint64; +typedef SDL_HAS_64BIT_TYPE Sint64; +#else +/* This is really just a hack to prevent the compiler from complaining */ +typedef struct { + Uint32 hi; + Uint32 lo; +} Uint64, Sint64; +#endif + +/* Make sure the types really have the right sizes */ +#define SDL_COMPILE_TIME_ASSERT(name, x) \ + typedef int SDL_dummy_ ## name[(x) * 2 - 1] + +SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); +SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); +SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); +SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); +SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); +SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); +SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); +SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); + +#undef SDL_COMPILE_TIME_ASSERT + +/* General keyboard/mouse state definitions */ +enum { SDL_PRESSED = 0x01, SDL_RELEASED = 0x00 }; + +#endif diff --git a/src/image/sublib/SDL_video.h b/src/image/sublib/SDL_video.h new file mode 100644 index 0000000..ae6a9e5 --- /dev/null +++ b/src/image/sublib/SDL_video.h @@ -0,0 +1,891 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_video.h,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $"; +#endif + +/* Header file for access to the SDL raw framebuffer window */ + +#ifndef _SDL_video_h +#define _SDL_video_h + +#include + +#include "SDL_types.h" +#include "SDL_mutex.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Transparency definitions: These define alpha as the opacity of a surface */ +#define SDL_ALPHA_OPAQUE 255 +#define SDL_ALPHA_TRANSPARENT 0 + +/* Useful data types */ +typedef struct { + Sint16 x, y; + Uint16 w, h; +} SDL_Rect; + +typedef struct { + Uint8 r; + Uint8 g; + Uint8 b; + Uint8 unused; +} SDL_Color; + +typedef struct { + int ncolors; + SDL_Color *colors; +} SDL_Palette; + +/* Everything in the pixel format structure is read-only */ +typedef struct SDL_PixelFormat { + SDL_Palette *palette; + Uint8 BitsPerPixel; + Uint8 BytesPerPixel; + Uint8 Rloss; + Uint8 Gloss; + Uint8 Bloss; + Uint8 Aloss; + Uint8 Rshift; + Uint8 Gshift; + Uint8 Bshift; + Uint8 Ashift; + Uint32 Rmask; + Uint32 Gmask; + Uint32 Bmask; + Uint32 Amask; + + /* RGB color key information */ + Uint32 colorkey; + /* Alpha value information (per-surface alpha) */ + Uint8 alpha; +} SDL_PixelFormat; + +/* typedef for private surface blitting functions */ +struct SDL_Surface; +typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect, + struct SDL_Surface *dst, SDL_Rect *dstrect); + +/* This structure should be treated as read-only, except for 'pixels', + which, if not NULL, contains the raw pixel data for the surface. +*/ +typedef struct SDL_Surface { + Uint32 flags; /* Read-only */ + SDL_PixelFormat *format; /* Read-only */ + int w, h; /* Read-only */ + Uint16 pitch; /* Read-only */ + void *pixels; /* Read-write */ + int offset; /* Private */ + + /* Hardware-specific surface info */ + // struct private_hwdata *hwdata; + + /* clipping information */ + // SDL_Rect clip_rect; /* Read-only */ + Uint32 unused1; /* for binary compatibility */ + + /* Allow recursive locks */ + // Uint32 locked; /* Private */ + + /* info for fast blit mapping to other surfaces */ + // struct SDL_BlitMap *map; /* Private */ + + /* format version, bumped at every change to invalidate blit maps */ + unsigned int format_version; /* Private */ + + /* Reference count -- used when freeing surface */ + int refcount; /* Read-mostly */ +} SDL_Surface; + +/* These are the currently supported flags for the SDL_surface */ +/* Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */ +#define SDL_SWSURFACE 0x00000000 /* Surface is in system memory */ +#define SDL_HWSURFACE 0x00000001 /* Surface is in video memory */ +#define SDL_ASYNCBLIT 0x00000004 /* Use asynchronous blits if possible */ +/* Available for SDL_SetVideoMode() */ +#define SDL_ANYFORMAT 0x10000000 /* Allow any video depth/pixel-format */ +#define SDL_HWPALETTE 0x20000000 /* Surface has exclusive palette */ +#define SDL_DOUBLEBUF 0x40000000 /* Set up double-buffered video mode */ +#define SDL_FULLSCREEN 0x80000000 /* Surface is a full screen display */ +#define SDL_OPENGL 0x00000002 /* Create an OpenGL rendering context */ +#define SDL_OPENGLBLIT 0x0000000A /* Create an OpenGL rendering context and use it for blitting */ +#define SDL_RESIZABLE 0x00000010 /* This video mode may be resized */ +#define SDL_NOFRAME 0x00000020 /* No window caption or edge frame */ +/* Used internally (read-only) */ +#define SDL_HWACCEL 0x00000100 /* Blit uses hardware acceleration */ +#define SDL_SRCCOLORKEY 0x00001000 /* Blit uses a source color key */ +#define SDL_RLEACCELOK 0x00002000 /* Private flag */ +#define SDL_RLEACCEL 0x00004000 /* Surface is RLE encoded */ +#define SDL_SRCALPHA 0x00010000 /* Blit uses source alpha blending */ +#define SDL_PREALLOC 0x01000000 /* Surface uses preallocated memory */ + +/* Evaluates to true if the surface needs to be locked before access */ +#define SDL_MUSTLOCK(surface) \ + (surface->offset || \ + ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0)) + + +/* Useful for determining the video hardware capabilities */ +typedef struct { + Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */ + Uint32 wm_available :1; /* Flag: Can you talk to a window manager? */ + Uint32 UnusedBits1 :6; + Uint32 UnusedBits2 :1; + Uint32 blit_hw :1; /* Flag: Accelerated blits HW --> HW */ + Uint32 blit_hw_CC :1; /* Flag: Accelerated blits with Colorkey */ + Uint32 blit_hw_A :1; /* Flag: Accelerated blits with Alpha */ + Uint32 blit_sw :1; /* Flag: Accelerated blits SW --> HW */ + Uint32 blit_sw_CC :1; /* Flag: Accelerated blits with Colorkey */ + Uint32 blit_sw_A :1; /* Flag: Accelerated blits with Alpha */ + Uint32 blit_fill :1; /* Flag: Accelerated color fill */ + Uint32 UnusedBits3 :16; + Uint32 video_mem; /* The total amount of video memory (in K) */ + SDL_PixelFormat *vfmt; /* Value: The format of the video surface */ +} SDL_VideoInfo; + + +/* The most common video overlay formats. + For an explanation of these pixel formats, see: + http://www.webartz.com/fourcc/indexyuv.htm + + For information on the relationship between color spaces, see: + http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html + */ +#define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U (3 planes) */ +#define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V (3 planes) */ +#define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 (1 plane) */ +#define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 (1 plane) */ +#define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 (1 plane) */ + +/* The YUV hardware video overlay */ +typedef struct SDL_Overlay { + Uint32 format; /* Read-only */ + int w, h; /* Read-only */ + int planes; /* Read-only */ + Uint16 *pitches; /* Read-only */ + Uint8 **pixels; /* Read-write */ + + /* Hardware-specific surface info */ + struct private_yuvhwfuncs *hwfuncs; + struct private_yuvhwdata *hwdata; + + /* Special flags */ + Uint32 hw_overlay :1; /* Flag: This overlay hardware accelerated? */ + Uint32 UnusedBits :31; +} SDL_Overlay; + + +/* Public enumeration for setting the OpenGL window attributes. */ +typedef enum { + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE +} SDL_GLattr; + +/* flags for SDL_SetPalette() */ +#define SDL_LOGPAL 0x01 +#define SDL_PHYSPAL 0x02 + +/* Function prototypes */ + +/* These functions are used internally, and should not be used unless you + * have a specific need to specify the video driver you want to use. + * You should normally use SDL_Init() or SDL_InitSubSystem(). + * + * SDL_VideoInit() initializes the video subsystem -- sets up a connection + * to the window manager, etc, and determines the current video mode and + * pixel format, but does not initialize a window or graphics mode. + * Note that event handling is activated by this routine. + * + * If you use both sound and video in your application, you need to call + * SDL_Init() before opening the sound device, otherwise under Win32 DirectX, + * you won't be able to set full-screen display modes. + */ +extern DECLSPEC int SDL_VideoInit(const char *driver_name, Uint32 flags); +extern DECLSPEC void SDL_VideoQuit(void); + +/* This function fills the given character buffer with the name of the + * video driver, and returns a pointer to it if the video driver has + * been initialized. It returns NULL if no driver has been initialized. + */ +extern DECLSPEC char *SDL_VideoDriverName(char *namebuf, int maxlen); + +/* + * This function returns a pointer to the current display surface. + * If SDL is doing format conversion on the display surface, this + * function returns the publicly visible surface, not the real video + * surface. + */ +extern DECLSPEC SDL_Surface * SDL_GetVideoSurface(void); + +/* + * This function returns a read-only pointer to information about the + * video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt' + * member of the returned structure will contain the pixel format of the + * "best" video mode. + */ +extern DECLSPEC const SDL_VideoInfo * SDL_GetVideoInfo(void); + +/* + * Check to see if a particular video mode is supported. + * It returns 0 if the requested mode is not supported under any bit depth, + * or returns the bits-per-pixel of the closest available mode with the + * given width and height. If this bits-per-pixel is different from the + * one used when setting the video mode, SDL_SetVideoMode() will succeed, + * but will emulate the requested bits-per-pixel with a shadow surface. + * + * The arguments to SDL_VideoModeOK() are the same ones you would pass to + * SDL_SetVideoMode() + */ +extern DECLSPEC int SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags); + +/* + * Return a pointer to an array of available screen dimensions for the + * given format and video flags, sorted largest to smallest. Returns + * NULL if there are no dimensions available for a particular format, + * or (SDL_Rect **)-1 if any dimension is okay for the given format. + * + * If 'format' is NULL, the mode list will be for the format given + * by SDL_GetVideoInfo()->vfmt + */ +extern DECLSPEC SDL_Rect ** SDL_ListModes(SDL_PixelFormat *format, Uint32 flags); + +/* + * Set up a video mode with the specified width, height and bits-per-pixel. + * + * If 'bpp' is 0, it is treated as the current display bits per pixel. + * + * If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the + * requested bits-per-pixel, but will return whatever video pixel format is + * available. The default is to emulate the requested pixel format if it + * is not natively available. + * + * If SDL_HWSURFACE is set in 'flags', the video surface will be placed in + * video memory, if possible, and you may have to call SDL_LockSurface() + * in order to access the raw framebuffer. Otherwise, the video surface + * will be created in system memory. + * + * If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle + * updates asynchronously, but you must always lock before accessing pixels. + * SDL will wait for updates to complete before returning from the lock. + * + * If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee + * that the colors set by SDL_SetColors() will be the colors you get. + * Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all + * of the colors exactly the way they are requested, and you should look + * at the video surface structure to determine the actual palette. + * If SDL cannot guarantee that the colors you request can be set, + * i.e. if the colormap is shared, then the video surface may be created + * under emulation in system memory, overriding the SDL_HWSURFACE flag. + * + * If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set + * a fullscreen video mode. The default is to create a windowed mode + * if the current graphics system has a window manager. + * If the SDL library is able to set a fullscreen video mode, this flag + * will be set in the surface that is returned. + * + * If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up + * two surfaces in video memory and swap between them when you call + * SDL_Flip(). This is usually slower than the normal single-buffering + * scheme, but prevents "tearing" artifacts caused by modifying video + * memory while the monitor is refreshing. It should only be used by + * applications that redraw the entire screen on every update. + * + * If SDL_RESIZABLE is set in 'flags', the SDL library will allow the + * window manager, if any, to resize the window at runtime. When this + * occurs, SDL will send a SDL_VIDEORESIZE event to you application, + * and you must respond to the event by re-calling SDL_SetVideoMode() + * with the requested size (or another size that suits the application). + * + * If SDL_NOFRAME is set in 'flags', the SDL library will create a window + * without any title bar or frame decoration. Fullscreen video modes have + * this flag set automatically. + * + * This function returns the video framebuffer surface, or NULL if it fails. + * + * If you rely on functionality provided by certain video flags, check the + * flags of the returned surface to make sure that functionality is available. + * SDL will fall back to reduced functionality if the exact flags you wanted + * are not available. + */ +extern DECLSPEC SDL_Surface *SDL_SetVideoMode + (int width, int height, int bpp, Uint32 flags); + +/* + * Makes sure the given list of rectangles is updated on the given screen. + * If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire + * screen. + * These functions should not be called while 'screen' is locked. + */ +extern DECLSPEC void SDL_UpdateRects + (SDL_Surface *screen, int numrects, SDL_Rect *rects); +extern DECLSPEC void SDL_UpdateRect + (SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h); + +/* + * On hardware that supports double-buffering, this function sets up a flip + * and returns. The hardware will wait for vertical retrace, and then swap + * video buffers before the next video surface blit or lock will return. + * On hardware that doesn not support double-buffering, this is equivalent + * to calling SDL_UpdateRect(screen, 0, 0, 0, 0); + * The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when + * setting the video mode for this function to perform hardware flipping. + * This function returns 0 if successful, or -1 if there was an error. + */ +extern DECLSPEC int SDL_Flip(SDL_Surface *screen); + +/* + * Set the gamma correction for each of the color channels. + * The gamma values range (approximately) between 0.1 and 10.0 + * + * If this function isn't supported directly by the hardware, it will + * be emulated using gamma ramps, if available. If successful, this + * function returns 0, otherwise it returns -1. + */ +extern DECLSPEC int SDL_SetGamma(float red, float green, float blue); + +/* + * Set the gamma translation table for the red, green, and blue channels + * of the video hardware. Each table is an array of 256 16-bit quantities, + * representing a mapping between the input and output for that channel. + * The input is the index into the array, and the output is the 16-bit + * gamma value at that index, scaled to the output color precision. + * + * You may pass NULL for any of the channels to leave it unchanged. + * If the call succeeds, it will return 0. If the display driver or + * hardware does not support gamma translation, or otherwise fails, + * this function will return -1. + */ +extern DECLSPEC int SDL_SetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue); + +/* + * Retrieve the current values of the gamma translation tables. + * + * You must pass in valid pointers to arrays of 256 16-bit quantities. + * Any of the pointers may be NULL to ignore that channel. + * If the call succeeds, it will return 0. If the display driver or + * hardware does not support gamma translation, or otherwise fails, + * this function will return -1. + */ +extern DECLSPEC int SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue); + +/* + * Sets a portion of the colormap for the given 8-bit surface. If 'surface' + * is not a palettized surface, this function does nothing, returning 0. + * If all of the colors were set as passed to SDL_SetColors(), it will + * return 1. If not all the color entries were set exactly as given, + * it will return 0, and you should look at the surface palette to + * determine the actual color palette. + * + * When 'surface' is the surface associated with the current display, the + * display colormap will be updated with the requested colors. If + * SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors() + * will always return 1, and the palette is guaranteed to be set the way + * you desire, even if the window colormap has to be warped or run under + * emulation. + */ +extern DECLSPEC int SDL_SetColors(SDL_Surface *surface, + SDL_Color *colors, int firstcolor, int ncolors); + +/* + * Sets a portion of the colormap for a given 8-bit surface. + * 'flags' is one or both of: + * SDL_LOGPAL -- set logical palette, which controls how blits are mapped + * to/from the surface, + * SDL_PHYSPAL -- set physical palette, which controls how pixels look on + * the screen + * Only screens have physical palettes. Separate change of physical/logical + * palettes is only possible if the screen has SDL_HWPALETTE set. + * + * The return value is 1 if all colours could be set as requested, and 0 + * otherwise. + * + * SDL_SetColors() is equivalent to calling this function with + * flags = (SDL_LOGPAL|SDL_PHYSPAL). + */ +extern DECLSPEC int SDL_SetPalette(SDL_Surface *surface, int flags, + SDL_Color *colors, int firstcolor, + int ncolors); + +/* + * Maps an RGB triple to an opaque pixel value for a given pixel format + */ +extern DECLSPEC Uint32 SDL_MapRGB + (SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b); + +/* + * Maps an RGBA quadruple to a pixel value for a given pixel format + */ +extern DECLSPEC Uint32 SDL_MapRGBA(SDL_PixelFormat *format, + Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* + * Maps a pixel value into the RGB components for a given pixel format + */ +extern DECLSPEC void SDL_GetRGB(Uint32 pixel, SDL_PixelFormat *fmt, + Uint8 *r, Uint8 *g, Uint8 *b); + +/* + * Maps a pixel value into the RGBA components for a given pixel format + */ +extern DECLSPEC void SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt, + Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); + +/* + * Allocate and free an RGB surface (must be called after SDL_SetVideoMode) + * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. + * If the depth is greater than 8 bits, the pixel format is set using the + * flags '[RGB]mask'. + * If the function runs out of memory, it will return NULL. + * + * The 'flags' tell what kind of surface to create. + * SDL_SWSURFACE means that the surface should be created in system memory. + * SDL_HWSURFACE means that the surface should be created in video memory, + * with the same format as the display surface. This is useful for surfaces + * that will not change much, to take advantage of hardware acceleration + * when being blitted to the display surface. + * SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with + * this surface, but you must always lock it before accessing the pixels. + * SDL will wait for current blits to finish before returning from the lock. + * SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits. + * If the hardware supports acceleration of colorkey blits between + * two surfaces in video memory, SDL will try to place the surface in + * video memory. If this isn't possible or if there is no hardware + * acceleration available, the surface will be placed in system memory. + * SDL_SRCALPHA means that the surface will be used for alpha blits and + * if the hardware supports hardware acceleration of alpha blits between + * two surfaces in video memory, to place the surface in video memory + * if possible, otherwise it will be placed in system memory. + * If the surface is created in video memory, blits will be _much_ faster, + * but the surface format must be identical to the video surface format, + * and the only way to access the pixels member of the surface is to use + * the SDL_LockSurface() and SDL_UnlockSurface() calls. + * If the requested surface actually resides in video memory, SDL_HWSURFACE + * will be set in the flags member of the returned surface. If for some + * reason the surface could not be placed in video memory, it will not have + * the SDL_HWSURFACE flag set, and will be created in system memory instead. + */ +#define SDL_AllocSurface SDL_CreateRGBSurface +extern DECLSPEC SDL_Surface *SDL_CreateRGBSurface + (Uint32 flags, int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +extern DECLSPEC SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, + int width, int height, int depth, int pitch, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +extern DECLSPEC void SDL_FreeSurface(SDL_Surface *surface); + +/* + * SDL_LockSurface() sets up a surface for directly accessing the pixels. + * Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write + * to and read from 'surface->pixels', using the pixel format stored in + * 'surface->format'. Once you are done accessing the surface, you should + * use SDL_UnlockSurface() to release it. + * + * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates + * to 0, then you can read and write to the surface at any time, and the + * pixel format of the surface will not change. In particular, if the + * SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you + * will not need to lock the display surface before accessing it. + * + * No operating system or library calls should be made between lock/unlock + * pairs, as critical system locks may be held during this time. + * + * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. + */ +extern DECLSPEC int SDL_LockSurface(SDL_Surface *surface); +extern DECLSPEC void SDL_UnlockSurface(SDL_Surface *surface); + +/* + * Load a surface from a seekable SDL data source (memory or file.) + * If 'freesrc' is non-zero, the source will be closed after being read. + * Returns the new surface, or NULL if there was an error. + * The new surface should be freed with SDL_FreeSurface(). + */ +extern DECLSPEC SDL_Surface * SDL_LoadBMP_RW(SDL_RWops *src, int freesrc); + +/* Convenience macro -- load a surface from a file */ +#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) + +/* + * Save a surface to a seekable SDL data source (memory or file.) + * If 'freedst' is non-zero, the source will be closed after being written. + * Returns 0 if successful or -1 if there was an error. + */ +extern DECLSPEC int SDL_SaveBMP_RW + (SDL_Surface *surface, SDL_RWops *dst, int freedst); + +/* Convenience macro -- save a surface to a file */ +#define SDL_SaveBMP(surface, file) \ + SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) + +/* + * Sets the color key (transparent pixel) in a blittable surface. + * If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL), + * 'key' will be the transparent pixel in the source image of a blit. + * SDL_RLEACCEL requests RLE acceleration for the surface if present, + * and removes RLE acceleration if absent. + * If 'flag' is 0, this function clears any current color key. + * This function returns 0, or -1 if there was an error. + */ +extern DECLSPEC int SDL_SetColorKey + (SDL_Surface *surface, Uint32 flag, Uint32 key); + +/* + * This function sets the alpha value for the entire surface, as opposed to + * using the alpha component of each pixel. This value measures the range + * of transparency of the surface, 0 being completely transparent to 255 + * being completely opaque. An 'alpha' value of 255 causes blits to be + * opaque, the source pixels copied to the destination (the default). Note + * that per-surface alpha can be combined with colorkey transparency. + * + * If 'flag' is 0, alpha blending is disabled for the surface. + * If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface. + * OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the + * surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed. + */ +extern DECLSPEC int SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha); + +/* + * Sets the clipping rectangle for the destination surface in a blit. + * + * If the clip rectangle is NULL, clipping will be disabled. + * If the clip rectangle doesn't intersect the surface, the function will + * return SDL_FALSE and blits will be completely clipped. Otherwise the + * function returns SDL_TRUE and blits to the surface will be clipped to + * the intersection of the surface area and the clipping rectangle. + * + * Note that blits are automatically clipped to the edges of the source + * and destination surfaces. + */ +extern DECLSPEC SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect); + +/* + * Gets the clipping rectangle for the destination surface in a blit. + * 'rect' must be a pointer to a valid rectangle which will be filled + * with the correct values. + */ +extern DECLSPEC void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect); + +/* + * Creates a new surface of the specified format, and then copies and maps + * the given surface to it so the blit of the converted surface will be as + * fast as possible. If this function fails, it returns NULL. + * + * The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those + * semantics. You can also pass SDL_RLEACCEL in the flags parameter and + * SDL will try to RLE accelerate colorkey and alpha blits in the resulting + * surface. + * + * This function is used internally by SDL_DisplayFormat(). + */ +extern DECLSPEC SDL_Surface *SDL_ConvertSurface + (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags); + +/* + * This performs a fast blit from the source surface to the destination + * surface. It assumes that the source and destination rectangles are + * the same size. If either 'srcrect' or 'dstrect' are NULL, the entire + * surface (src or dst) is copied. The final blit rectangles are saved + * in 'srcrect' and 'dstrect' after all clipping is performed. + * If the blit is successful, it returns 0, otherwise it returns -1. + * + * The blit function should not be called on a locked surface. + * + * The blit semantics for surfaces with and without alpha and colorkey + * are defined as follows: + * + * RGBA->RGB: + * SDL_SRCALPHA set: + * alpha-blend (using alpha-channel). + * SDL_SRCCOLORKEY ignored. + * SDL_SRCALPHA not set: + * copy RGB. + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * RGB values of the source colour key, ignoring alpha in the + * comparison. + * + * RGB->RGBA: + * SDL_SRCALPHA set: + * alpha-blend (using the source per-surface alpha value); + * set destination alpha to opaque. + * SDL_SRCALPHA not set: + * copy RGB, set destination alpha to opaque. + * both: + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * source colour key. + * + * RGBA->RGBA: + * SDL_SRCALPHA set: + * alpha-blend (using the source alpha channel) the RGB values; + * leave destination alpha untouched. [Note: is this correct?] + * SDL_SRCCOLORKEY ignored. + * SDL_SRCALPHA not set: + * copy all of RGBA to the destination. + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * RGB values of the source colour key, ignoring alpha in the + * comparison. + * + * RGB->RGB: + * SDL_SRCALPHA set: + * alpha-blend (using the source per-surface alpha value). + * SDL_SRCALPHA not set: + * copy RGB. + * both: + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * source colour key. + * + * If either of the surfaces were in video memory, and the blit returns -2, + * the video memory was lost, so it should be reloaded with artwork and + * re-blitted: + while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) { + while ( SDL_LockSurface(image) < 0 ) + Sleep(10); + -- Write image pixels to image->pixels -- + SDL_UnlockSurface(image); + } + * This happens under DirectX 5.0 when the system switches away from your + * fullscreen application. The lock will also fail until you have access + * to the video memory again. + */ +/* You should call SDL_BlitSurface() unless you know exactly how SDL + blitting works internally and how to use the other blit functions. +*/ +#define SDL_BlitSurface SDL_UpperBlit + +/* This is the public blit function, SDL_BlitSurface(), and it performs + rectangle validation and clipping before passing it to SDL_LowerBlit() +*/ +extern DECLSPEC int SDL_UpperBlit + (SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); +/* This is a semi-private blit function and it performs low-level surface + blitting only. +*/ +extern DECLSPEC int SDL_LowerBlit + (SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); + +/* + * This function performs a fast fill of the given rectangle with 'color' + * The given rectangle is clipped to the destination surface clip area + * and the final fill rectangle is saved in the passed in pointer. + * If 'dstrect' is NULL, the whole surface will be filled with 'color' + * The color should be a pixel of the format used by the surface, and + * can be generated by the SDL_MapRGB() function. + * This function returns 0 on success, or -1 on error. + */ +extern DECLSPEC int SDL_FillRect + (SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color); + +/* + * This function takes a surface and copies it to a new surface of the + * pixel format and colors of the video framebuffer, suitable for fast + * blitting onto the display surface. It calls SDL_ConvertSurface() + * + * If you want to take advantage of hardware colorkey or alpha blit + * acceleration, you should set the colorkey and alpha value before + * calling this function. + * + * If the conversion fails or runs out of memory, it returns NULL + */ +extern DECLSPEC SDL_Surface * SDL_DisplayFormat(SDL_Surface *surface); + +/* + * This function takes a surface and copies it to a new surface of the + * pixel format and colors of the video framebuffer (if possible), + * suitable for fast alpha blitting onto the display surface. + * The new surface will always have an alpha channel. + * + * If you want to take advantage of hardware colorkey or alpha blit + * acceleration, you should set the colorkey and alpha value before + * calling this function. + * + * If the conversion fails or runs out of memory, it returns NULL + */ +extern DECLSPEC SDL_Surface * SDL_DisplayFormatAlpha(SDL_Surface *surface); + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* YUV video surface overlay functions */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* This function creates a video output overlay + Calling the returned surface an overlay is something of a misnomer because + the contents of the display surface underneath the area where the overlay + is shown is undefined - it may be overwritten with the converted YUV data. +*/ +extern DECLSPEC SDL_Overlay *SDL_CreateYUVOverlay(int width, int height, + Uint32 format, SDL_Surface *display); + +/* Lock an overlay for direct access, and unlock it when you are done */ +extern DECLSPEC int SDL_LockYUVOverlay(SDL_Overlay *overlay); +extern DECLSPEC void SDL_UnlockYUVOverlay(SDL_Overlay *overlay); + +/* Blit a video overlay to the display surface. + The contents of the video surface underneath the blit destination are + not defined. + The width and height of the destination rectangle may be different from + that of the overlay, but currently only 2x scaling is supported. +*/ +extern DECLSPEC int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect); + +/* Free a video overlay */ +extern DECLSPEC void SDL_FreeYUVOverlay(SDL_Overlay *overlay); + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* OpenGL support functions. */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Dynamically load a GL driver, if SDL is built with dynamic GL. + * + * SDL links normally with the OpenGL library on your system by default, + * but you can compile it to dynamically load the GL driver at runtime. + * If you do this, you need to retrieve all of the GL functions used in + * your program from the dynamic library using SDL_GL_GetProcAddress(). + * + * This is disabled in default builds of SDL. + */ +extern DECLSPEC int SDL_GL_LoadLibrary(const char *path); + +/* + * Get the address of a GL function (for extension functions) + */ +extern DECLSPEC void *SDL_GL_GetProcAddress(const char* proc); + +/* + * Set an attribute of the OpenGL subsystem before intialization. + */ +extern DECLSPEC int SDL_GL_SetAttribute(SDL_GLattr attr, int value); + +/* + * Get an attribute of the OpenGL subsystem from the windowing + * interface, such as glX. This is of course different from getting + * the values from SDL's internal OpenGL subsystem, which only + * stores the values you request before initialization. + * + * Developers should track the values they pass into SDL_GL_SetAttribute + * themselves if they want to retrieve these values. + */ +extern DECLSPEC int SDL_GL_GetAttribute(SDL_GLattr attr, int* value); + +/* + * Swap the OpenGL buffers, if double-buffering is supported. + */ +extern DECLSPEC void SDL_GL_SwapBuffers(void); + +/* + * Internal functions that should not be called unless you have read + * and understood the source code for these functions. + */ +extern DECLSPEC void SDL_GL_UpdateRects(int numrects, SDL_Rect* rects); +extern DECLSPEC void SDL_GL_Lock(void); +extern DECLSPEC void SDL_GL_Unlock(void); + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* These functions allow interaction with the window manager, if any. */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Sets/Gets the title and icon text of the display window + */ +extern DECLSPEC void SDL_WM_SetCaption(const char *title, const char *icon); +extern DECLSPEC void SDL_WM_GetCaption(char **title, char **icon); + +/* + * Sets the icon for the display window. + * This function must be called before the first call to SDL_SetVideoMode(). + * It takes an icon surface, and a mask in MSB format. + * If 'mask' is NULL, the entire icon surface will be used as the icon. + */ +extern DECLSPEC void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); + +/* + * This function iconifies the window, and returns 1 if it succeeded. + * If the function succeeds, it generates an SDL_APPACTIVE loss event. + * This function is a noop and returns 0 in non-windowed environments. + */ +extern DECLSPEC int SDL_WM_IconifyWindow(void); + +/* + * Toggle fullscreen mode without changing the contents of the screen. + * If the display surface does not require locking before accessing + * the pixel information, then the memory pointers will not change. + * + * If this function was able to toggle fullscreen mode (change from + * running in a window to fullscreen, or vice-versa), it will return 1. + * If it is not implemented, or fails, it returns 0. + * + * The next call to SDL_SetVideoMode() will set the mode fullscreen + * attribute based on the flags parameter - if SDL_FULLSCREEN is not + * set, then the display will be windowed by default where supported. + * + * This is currently only implemented in the X11 video driver. + */ +extern DECLSPEC int SDL_WM_ToggleFullScreen(SDL_Surface *surface); + +/* + * This function allows you to set and query the input grab state of + * the application. It returns the new input grab state. + */ +typedef enum { + SDL_GRAB_QUERY = -1, + SDL_GRAB_OFF = 0, + SDL_GRAB_ON = 1, + SDL_GRAB_FULLSCREEN /* Used internally */ +} SDL_GrabMode; +/* + * Grabbing means that the mouse is confined to the application window, + * and nearly all keyboard input is passed directly to the application, + * and not interpreted by a window manager, if any. + */ +extern DECLSPEC SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode); + +/* Not in public API at the moment - do not use! */ +extern DECLSPEC int SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ diff --git a/src/image/sublib/begin_code.h b/src/image/sublib/begin_code.h new file mode 100644 index 0000000..d455ea2 --- /dev/null +++ b/src/image/sublib/begin_code.h @@ -0,0 +1,100 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +/* This file sets things up for C dynamic library function definitions, + static inlined functions, and structures aligned at 4-byte alignment. + If you don't like ugly C preprocessor code, don't look at this file. :) +*/ + +/* This shouldn't be nested -- included it around code only. */ +#ifdef _begin_code_h +#error Nested inclusion of begin_code.h +#endif +#define _begin_code_h + +/* Some compilers use a special export keyword */ +#ifndef DECLSPEC +# ifdef __BEOS__ +# if defined(__GNUC__) +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC __declspec(export) +# endif +# else +# ifdef WIN32 +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC +# endif +# endif +#endif + +/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ +#ifdef __SYMBIAN32__ +#undef DECLSPEC +#define DECLSPEC +#endif /* __SYMBIAN32__ */ + +/* Force structure packing at 4 byte alignment. + This is necessary if the header is included in code which has structure + packing set to an alternate value, say for loading structures from disk. + The packing is reset to the previous value in close_code.h + */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) +#ifdef _MSC_VER +#pragma warning(disable: 4103) +#endif +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#pragma pack(push,4) +#elif (defined(__MWERKS__) && defined(macintosh)) +#pragma options align=mac68k4byte +#pragma enumsalwaysint on +#endif /* Compiler needs structure packing set */ + +/* Set up compiler-specific options for inlining functions */ +#ifndef SDL_INLINE_OKAY +#ifdef __GNUC__ +#define SDL_INLINE_OKAY +#else +/* Add any special compiler-specific cases here */ +#if defined(_MSC_VER) +#define __inline__ __inline +#define SDL_INLINE_OKAY +#else +#if !defined(__MRC__) && !defined(_SGI_SOURCE) +#define __inline__ inline +#define SDL_INLINE_OKAY +#endif /* Not a funky compiler */ +#endif /* Visual C++ */ +#endif /* GNU C */ +#endif /* SDL_INLINE_OKAY */ + +/* If inlining isn't supported, remove "__inline__", turning static + inlined functions into static functions (resulting in code bloat + in all files which include the offending header files) +*/ +#ifndef SDL_INLINE_OKAY +#define __inline__ +#endif + diff --git a/src/image/sublib/close_code.h b/src/image/sublib/close_code.h new file mode 100644 index 0000000..d3b5c07 --- /dev/null +++ b/src/image/sublib/close_code.h @@ -0,0 +1,41 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@devolution.com +*/ + +/* This file reverses the effects of begin_code.h and should be included + after you finish any function and structure declarations in your headers +*/ + +#undef _begin_code_h + +/* Reset structure packing at previous byte alignment */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#if (defined(__MWERKS__) && defined(macintosh)) +#pragma options align=reset +#pragma enumsalwaysint reset +#else +#pragma pack(pop) +#endif +#endif /* Compiler needs structure packing set */ + diff --git a/src/image/sublib/im_exp.h b/src/image/sublib/im_exp.h new file mode 100644 index 0000000..632d38b --- /dev/null +++ b/src/image/sublib/im_exp.h @@ -0,0 +1,18 @@ +#ifndef IM_EXP_H +#define IM_EXP_H +#include "globals.h" +#include "picinfo.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +extern int im_load_gif(char* fname, PICINFO* to_pic, int from_mem_size); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/image/sublib/makefile.in b/src/image/sublib/makefile.in new file mode 100644 index 0000000..8d1369e --- /dev/null +++ b/src/image/sublib/makefile.in @@ -0,0 +1,93 @@ +# Image Engine for X Window +# +# Copyright (C) 1996 by Leo Khramov +# email: leo@pop.convey.ru +# Fido: 2:5030/627.15 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +include ../../make.conf + +@MCOMMON@ + + IOBJS = SDL_surface.o SDL_rwops.o SDL_error.o SDL_to_picinfo.o \ + IMG_gif.o + CXXINCLUDES=$(XINC) $(JINC) + CXXOPT=-I../.. -I../../include $(CFLAGS) $(DEFS) $(DEB) $(PSEUDO) $(PCX) $(TIFF) $(BMP) $(XBM) $(XPM) $(TGA) $(PCD) $(PNG) + + + +all:: $(IOBJS) + +SDL_surface.o: SDL_surface.c + $(CC) -c SDL_surface.c $(CXXOPT) $(INCLUDES) $(CPPFLAGS) + +SDL_error.o: SDL_error.c + $(CC) -c SDL_error.c $(CXXOPT) $(INCLUDES) $(CPPFLAGS) + +SDL_to_picinfo.o: SDL_to_picinfo.c + $(CC) -c SDL_to_picinfo.c $(CXXOPT) $(INCLUDES) $(CPPFLAGS) + +SDL_rwops.o: SDL_rwops.c + $(CC) -c SDL_rwops.c $(CXXOPT) $(INCLUDES) $(CPPFLAGS) + +IMG_gif.o: IMG_gif.c + $(CC) -c IMG_gif.c $(CXXOPT) $(INCLUDES) $(CPPFLAGS) + +jpeg.o: jpeg.c + $(CC) -c jpeg.c $(CXXOPT) $(INCLUDES) $(CPPFLAGS) + +accel.o: accel.c + $(CC) -c accel.c $(CXXOPT) $(CXXINCLUDES) $(CPPFLAGS) + +pcdr.o: pcdr.c + $(CC) -c pcdr.c $(CXXOPT) $(INCLUDES) $(CPPFLAGS) + +inter.o: inter.c + $(CC) -c inter.c $(CXXOPT) $(INCLUDES) $(CPPFLAGS) + +huff.o: huff.c + $(CC) -c huff.c $(CXXOPT) $(INCLUDES) $(CPPFLAGS) + +file.o: file.c + $(CC) -c file.c $(CXXOPT) $(INCLUDES) $(CPPFLAGS) + +yuv2rgb.o: yuv2rgb.c + $(CC) -c yuv2rgb.c $(CXXOPT) $(INCLUDES) $(CPPFLAGS) + +tiffr.o: tiffr.c + $(CC) -c tiffr.c $(CXXOPT) $(INCLUDES) $(CPPFLAGS) + +png.o: png.c + $(CC) -c png.c $(CXXOPT) $(INCLUDES) $(ZINC) $(PNGINC) $(CPPFLAGS) + +../zlib/libz.a: + cd ../zlib && make + +../libpng/libpng.a: + cd ../libpng && make + +pcxr.o: pcxr.c + $(CC) -c pcxr.c $(CXXOPT) $(INCLUDES) $(CPPFLAGS) + +libie.a: $(IOBJS) + $(RM) -f libie.a + ar rc libie.a $(IOBJS) + @RANLIB@ libie.a + +clean: + $(RM) -f libie.a + $(RM) -f *.o + +FORCE: + + diff --git a/src/include/bilist.h b/src/include/bilist.h new file mode 100644 index 0000000..7890507 --- /dev/null +++ b/src/include/bilist.h @@ -0,0 +1,61 @@ +#ifndef BILIST_H +#define BILIST_H + +template < class TC > class bilist +{ + TC object; + bool usable; + bilist *next,*prev; + public: + bilist() { next=prev=0;usable=false;}; + bilist(TC& obj) { next=prev=0;object=obj;usable=true;}; + + bool add(bilist *plist); + bilist* del(TC& obj); + bool del_self() + { + if(next) + next->set_prev(prev); + if(prev) + prev->set_next(next); + return true; + }; + + bool is_last() {return next==0;}; + bool is_first() {return prev==0;}; + + bilist *get_next() { return next;}; + bilist *get_prev() { return prev;}; + + void set_prev(bilist *plist) { prev=plist;}; + void set_next(bilist *plist) { next=plist;}; + + TC& get_object() { return object;}; +}; + +//here we are using while for searching end of list +template bool bilist::add(bilist *plist) +{ + bilist *ptr=this; + while(ptr->get_next()!=0) + ptr=ptr->get_next(); + ptr->set_next(plist); + plist->set_prev(ptr); + return true; +} + +//and here lets make recursion for diff :) +template bilist* bilist::del(TC& obj) +{ + if(obj==object) + { + del_self(); + return this; + } + if(next) + return next->del(obj); + return 0; //Can't find object in list. +} + +#endif + diff --git a/src/include/commonfuncs.h b/src/include/commonfuncs.h new file mode 100644 index 0000000..9fef973 --- /dev/null +++ b/src/include/commonfuncs.h @@ -0,0 +1,11 @@ +#ifndef COMMONFUNCS_H +#define COMMONFUNCS_H + +#include "globals.h" + +enum FMode { ReadOnly, ReadWrite }; + +extern bool find_full_path_for_file(char* fname, char* ret_full_pathname, + FMode fm=ReadOnly); + +#endif diff --git a/src/include/config.h b/src/include/config.h new file mode 100644 index 0000000..a91dd57 --- /dev/null +++ b/src/include/config.h @@ -0,0 +1,145 @@ +/* src/include/config.h. Generated automatically by configure. */ +/* src/include/config.h.in. Generated automatically from configure.in by autoheader. */ + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* #undef _ALL_SOURCE */ +#endif + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define as __inline if that's what the C compiler calls it. */ +/* #undef inline */ + +/* Define if on MINIX. */ +/* #undef _MINIX */ + +/* Define to `int' if doesn't define. */ +/* #undef mode_t */ + +/* Define to `int' if doesn't define. */ +/* #undef pid_t */ + +/* Define if the system does not provide POSIX.1 features except + with this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define if you need to in order for stat and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define to `unsigned' if doesn't define. */ +/* #undef size_t */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define if your declares struct tm. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define if the X Window System is missing or not being used. */ +/* #undef X_DISPLAY_MISSING */ + +/* Define if you have the atexit function. */ +#define HAVE_ATEXIT 1 + +/* Define if you have the getcwd function. */ +#define HAVE_GETCWD 1 + +/* Define if you have the mkdir function. */ +#define HAVE_MKDIR 1 + +/* Define if you have the putenv function. */ +#define HAVE_PUTENV 1 + +/* Define if you have the select function. */ +#define HAVE_SELECT 1 + +/* Define if you have the seteuid function. */ +#define HAVE_SETEUID 1 + +/* Define if you have the setlocale function. */ +#define HAVE_SETLOCALE 1 + +/* Define if you have the setutent function. */ +#define HAVE_SETUTENT 1 + +/* Define if you have the socket function. */ +#define HAVE_SOCKET 1 + +/* Define if you have the unsetenv function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have the header file. */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the header file. */ +#define HAVE_MATH_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_NDIR_H */ + +/* Define if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_SYS_SIGEVENT_H */ + +/* Define if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the m library (-lm). */ +#define HAVE_LIBM 1 diff --git a/src/include/config.h.in b/src/include/config.h.in new file mode 100644 index 0000000..275ca89 --- /dev/null +++ b/src/include/config.h.in @@ -0,0 +1,144 @@ +/* src/include/config.h.in. Generated automatically from configure.in by autoheader. */ + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +#undef _ALL_SOURCE +#endif + +/* Define to empty if the keyword does not work. */ +#undef const + +/* Define to `int' if doesn't define. */ +#undef gid_t + +/* Define if you have that is POSIX.1 compatible. */ +#undef HAVE_SYS_WAIT_H + +/* Define as __inline if that's what the C compiler calls it. */ +#undef inline + +/* Define if on MINIX. */ +#undef _MINIX + +/* Define to `int' if doesn't define. */ +#undef mode_t + +/* Define to `int' if doesn't define. */ +#undef pid_t + +/* Define if the system does not provide POSIX.1 features except + with this defined. */ +#undef _POSIX_1_SOURCE + +/* Define if you need to in order for stat and other things to work. */ +#undef _POSIX_SOURCE + +/* Define as the return type of signal handlers (int or void). */ +#undef RETSIGTYPE + +/* Define to `unsigned' if doesn't define. */ +#undef size_t + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define if your declares struct tm. */ +#undef TM_IN_SYS_TIME + +/* Define to `int' if doesn't define. */ +#undef uid_t + +/* Define if the X Window System is missing or not being used. */ +#undef X_DISPLAY_MISSING + +/* Define if you have the atexit function. */ +#undef HAVE_ATEXIT + +/* Define if you have the getcwd function. */ +#undef HAVE_GETCWD + +/* Define if you have the mkdir function. */ +#undef HAVE_MKDIR + +/* Define if you have the putenv function. */ +#undef HAVE_PUTENV + +/* Define if you have the select function. */ +#undef HAVE_SELECT + +/* Define if you have the seteuid function. */ +#undef HAVE_SETEUID + +/* Define if you have the setlocale function. */ +#undef HAVE_SETLOCALE + +/* Define if you have the setutent function. */ +#undef HAVE_SETUTENT + +/* Define if you have the socket function. */ +#undef HAVE_SOCKET + +/* Define if you have the unsetenv function. */ +#undef HAVE_UNSETENV + +/* Define if you have the header file. */ +#undef HAVE_DIRENT_H + +/* Define if you have the header file. */ +#undef HAVE_ERRNO_H + +/* Define if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define if you have the header file. */ +#undef HAVE_MATH_H + +/* Define if you have the header file. */ +#undef HAVE_NDIR_H + +/* Define if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_DIR_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_NDIR_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_SIGEVENT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_UTSNAME_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_WAIT_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the m library (-lm). */ +#undef HAVE_LIBM diff --git a/src/include/geometry.h b/src/include/geometry.h new file mode 100644 index 0000000..bb699ba --- /dev/null +++ b/src/include/geometry.h @@ -0,0 +1,23 @@ +#ifndef GEOMETRY_H +#define GEOMETRY_H + +#include "welltris.h" + +struct Geo +{ + Images im; + int fromx, fromy; + int tox,toy; + unsigned int l,h; +}; + +struct GeoObject +{ + char name[GEO_NAME]; + Geo *geo; +}; + +extern Geo* get_geo_by_name(char* name); + + +#endif diff --git a/src/include/globals.h b/src/include/globals.h new file mode 100644 index 0000000..9b5a911 --- /dev/null +++ b/src/include/globals.h @@ -0,0 +1,89 @@ +#ifndef XNC_GLOBALS_H +#define XNC_GLOBALS_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#ifdef HAVE_SYS_SIGEVENT_H +#include +#endif +#include +#include +#ifdef HAVE_STRINGS_H +#include +#endif +#include +#include + +#ifdef HAVE_LIMITS_H +#include +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_SYS_UTSNAME_H +#include +#endif + +#ifdef TIME_WITH_SYS_TIME +#include +#include +#else +#ifdef HAVE_SYS_TIME_H +#include +#else +#include +#endif +#endif + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#ifdef HAVE_SYS_WAIT_H +#include +#endif + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef HAVE_FCNTL_H +#include +#endif + +#include + +#ifdef HAVE_ERRNO_H +#include +#endif + +#ifdef HAVE_MATH_H +#include +#endif + +#include "types.h" +#include "mydebug.h" + +#define MAX2(x1,x2) (x1 +#endif + +#include +#ifdef HAVE_SYS_SIGEVENT_H +#include +#endif +#include +#include +#ifdef HAVE_STRINGS_H +#include +#endif +#include +#include + +#ifdef HAVE_LIMITS_H +#include +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_SYS_UTSNAME_H +#include +#endif + +#ifdef TIME_WITH_SYS_TIME +#include +#include +#else +#ifdef HAVE_SYS_TIME_H +#include +#else +#include +#endif +#endif + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +#ifdef HAVE_SYS_WAIT_H +#include +#endif + +#ifdef HAVE_SYS_SELECT_H +#include +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef HAVE_FCNTL_H +#include +#endif + +#include + +#ifdef HAVE_ERRNO_H +#include +#endif + +#ifdef HAVE_MATH_H +#include +#endif + +#include "types.h" +#include "mydebug.h" + +#define MAX2(x1,x2) (x1 +#ifdef HAVE_SYS_SIGEVENT_H +#include +#endif +#include +#include + +#ifdef __cplusplus +extern "C" int debprintf(const char *format,...); +#else +extern int debprintf(const char *format,...); +#endif + +#ifdef DEBUG_XNC +#ifdef __FILE__ +#ifdef __LINE__ +#define __DEBUG() fprintf(stderr, "%-17s:%4d ", __FILE__, __LINE__) +#endif +#endif + +#ifndef __DEBUG +#define __DEBUG() ((void)0) +#endif + +# define dbgprintf(x) do {__DEBUG(); debprintf x;} while(0) +#else +# define dbgprintf(x) ((void)0) +#endif + +#endif diff --git a/src/include/sysheaders.h b/src/include/sysheaders.h new file mode 100644 index 0000000..e7f8d4c --- /dev/null +++ b/src/include/sysheaders.h @@ -0,0 +1,12 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + diff --git a/src/include/types.h b/src/include/types.h new file mode 100644 index 0000000..fe07f19 --- /dev/null +++ b/src/include/types.h @@ -0,0 +1,23 @@ +#ifndef MYTYPES_H +#define MYTYPES_H + +#ifndef uchar +typedef unsigned char uchar; +#endif + +#ifndef ulong +typedef unsigned long ulong; +#endif + +#ifndef uint +typedef unsigned int uint; +#endif + +#define L_MAXPATH 2048 + +#define YES 1 +#define NO 0 + +#endif +/* ------------ End of file -------------- */ + diff --git a/src/include/version.h b/src/include/version.h new file mode 100644 index 0000000..3c3ccc1 --- /dev/null +++ b/src/include/version.h @@ -0,0 +1,5 @@ +#ifndef WELL_VERSION_H +#define WELL_VERSION_H +#define VERSION "1.0.0" +#endif + diff --git a/src/include/wellclass.h b/src/include/wellclass.h new file mode 100644 index 0000000..e75201e --- /dev/null +++ b/src/include/wellclass.h @@ -0,0 +1,162 @@ +#ifndef WELLCLASS_H +#define WELLCLASS_H + +#include "globals.h" +#include "welltris.h" +#include "wellobject.h" +#include "welldrawing.h" +#include "wellengine.h" +#include "wellimagefont.h" +#include "welltopnine.h" + +//define structures for work with figures +struct thing_t +{ + int squares, polyomino_number; + int xpos, ypos; + int size, color_number; + int bonus, random_rotation, random_reflection; + long random_number; + thing_t() + { + squares=polyomino_number=xpos=ypos=size=0; + color_number=bonus=random_rotation=random_reflection=0; + random_number=0; + }; +}; + +struct Polyominoes +{ + int rotation; + int reflection; + int start_height; + int shape[MAX_SQUARES][MAX_SQUARES]; + int size; +}; + +struct Mode +{ + int number[MAX_MODES][MAX_TYPES]; + int start[MAX_START_POLYOMINOES][MAX_TYPES]; + int turn_style; +}; + +struct Polytris +{ + Polyominoes polyomino[MAX_POLYOMINOES]; + Mode mode[MAX_MODES]; + int diagonal_switch; +}; + +struct Field +{ + int pmid, cid; +}; + + +class WellBase: public WellObject +{ + protected: + Polytris tris[MAX_SQUARES - MIN_SQUARES + 1]; + int frozen_wall[MAX_SIDES]; + thing_t curThing, nextThing; + Field wall[MAX_DEPTH+MAX_WIDTH][MAX_PERIMETER]; + Field base[MAX_WIDTH][MAX_WIDTH]; + + int level, score, rows, rows_levelup; + + bool bonusNow; + + //Options + bool showNext; + bool beep; + bool diagonal; + bool mixed; + bool bonus; + bool grid; + bool cw; + bool gradualAppear; + bool rotation; + int squares, pause, steps_to_rotate; + + //Drawing Engine + + WellDrawingEngine *dre; + WellImageFont *txt_score; + WellImageFont *txt_lines; + WellImageFont *txt_levelup; + WellImageFont *txt_level; + + WellImageFont *txt_first; + WellImageFont *txt_second; + WellImageFont *txt_third; + + Score *player_score; + + ObjectCaller game_over_object; + + char player_name[PLAYER_NAME_LEN]; + + void set_default_options(); + + void read_polyominoes(); + void new_thing(); + void redo_next(); + void put_box(); + bool overlapping(); + bool at_bottom(); + bool at_base_fully(); + bool at_base_partially(); + bool wall_change(thing_t old,thing_t new_t); + bool all_frozen(); + void wall_to_base(int* base_x,int* base_y,int wall_x,int wall_y); + void try_move(Actions move); + void draw_thing_diff(thing_t* old); + void draw_thing(); + void draw_field(); + void fill_lines(); + void freeze_wall(int w); + void defreeze_wall(int w); + void drop_wall(int); + void check_freeze(); + int check_lines(); + void check_update_lines(); + bool process_action(Actions action); + void make_pause(); + void make_rotation(); + + virtual void draw_status(); + virtual void draw_next(); + virtual void clear_next(); + virtual void draw_grid(); + virtual void draw_box(int color, int x, int y); + + public: + WellBase(); + void init(WellEngine*); + void udelay(int msec); + bool move_one_step(Actions); + void game_over(); + void new_game(); + void new_level_calc(); + void redraw_all(); + void set_level(int il) { level=il; dbgprintf(("Level now is %d\n",level));}; + void set_rotation(bool r) { rotation=r;}; + void set_mixed(bool r) { mixed=r;}; + void set_next_piece(bool r) { showNext=r;}; + void set_squares(int i) { squares=i;}; + void set_object_on_game_over(ObjectCaller obj) + { + game_over_object=obj; + }; + void set_player_name(char *pn) + { + strcpy(player_name,pn); + }; + virtual bool process_event(wEvent); + virtual void show(); + virtual void hide(); +}; + +#endif + diff --git a/src/include/welldrawing.h b/src/include/welldrawing.h new file mode 100644 index 0000000..f9dfeb6 --- /dev/null +++ b/src/include/welldrawing.h @@ -0,0 +1,62 @@ +#ifndef DRAWING_H +#define DRAWING_H + +#include "globals.h" +#include "welltris.h" +#include "wellsimpledraw.h" +#include "geometry.h" + +struct FieldPoints +{ + WPoint wall_points[MAX_PERIMETER+1][MAX_DEPTH+1]; + WPoint base_points[MAX_WIDTH+1][MAX_WIDTH+1]; +}; + +class WellDrawingEngine: public WellSimpleDraw +{ + protected: + int num_fields; + unsigned int l,h; + int delta_x,delta_y; + int current_id; + + int pix_max_width; + int pix_base_width; + int pix_base_delta; + int pix_wall_delta; + int pix_max_delta; + int pix_dx,pix_dy; + int center_x,center_y; + int f_step; + + float inner_max_alpha,outer_max_alpha; + + FieldPoints *points; + + public: + virtual void init(int,int,int,unsigned int,unsigned int); + virtual void draw_square(int color, int x, int y); + virtual void draw_trapazoid(int color, int x, int y); + virtual void sync(); + virtual void field_sync() {}; + virtual void bell(int); + virtual void flush_all(); + virtual void flush_dirty(); + virtual void clear_field(int i) {}; + virtual void set_field_id(int id) { current_id=id;}; + virtual void draw_grid() {}; + virtual Actions key_to_action(void* event) { return NOTHING; }; + virtual void calc_grid_points(); + virtual void set_field_sizes(int idx, int idy, + int ipix_wall_delta, + int ipix_base_delta); + virtual void set_inner_alpha(float ialpha) { inner_max_alpha= + ialpha*float(W_PI/180.0);}; + virtual void set_outer_alpha(float ialpha) { outer_max_alpha= + ialpha*float(W_PI/180.0);}; + virtual void outer_rotation(); + virtual void pixmap_copy(Geo *pgeo) {}; +}; + + +#endif diff --git a/src/include/wellengine.h b/src/include/wellengine.h new file mode 100644 index 0000000..bb5de1e --- /dev/null +++ b/src/include/wellengine.h @@ -0,0 +1,93 @@ +#ifndef WELLENGINE_H +#define WELLENGINE_H + +#include "wellobject.h" +#include "bilist.h" +#include "welldrawing.h" +#include "wellimagefont.h" +#include "welltopnine.h" +#include "wellintro.h" +#include "wellkey.h" +#include "wellswitch.h" +#include "wellinput.h" + +class WellBase; + +//Class used in Time queue for delivering time events to objects +struct TimeObject +{ + WellObject* obj; + int ticks_left; + int ticks; + TimeObject() {ticks=ticks_left=0; obj=0;}; + TimeObject(WellObject* wo, int t=1) { obj=wo;ticks_left=ticks=t;}; + void restart_ticks() { ticks_left=ticks; }; + bool operator == (TimeObject& o2) {return o2.obj==obj;}; +}; + +typedef bilist TimeList; //List of objects that want timers +typedef bilist ObjectList; //List of all objects that waht events + +struct WellImage +{ + Images id; //Image id + int l,h; //Size of image + WellImage() { id=imNone; l=h=0;}; +}; + +class WellEngine +{ + protected: + + TimeList timelist; + ObjectList objectlist; + + unsigned int mainl,mainh; // size of main window + bool done_loop_var; + + WellImage images[MAX_IMAGES]; + + virtual void init_mainwindow(int,char**)=0; + virtual int wait_for_timers()=0; + virtual bool process_time_event(); + virtual bool process_event_for_all(wEvent); + + public: + WellEngine(int,char**); + ~WellEngine(); + + virtual void show_main()=0; + virtual void event_loop()=0; + + virtual bool add_timer(WellObject* wo, int ticks); + virtual bool del_timer(WellObject* wo); + virtual bool add_object(WellObject* wo); + virtual bool del_object(WellObject* wo); + virtual void clear_objectlist(); + virtual void done_loop() { done_loop_var=true;}; + + virtual WellDrawingEngine* new_well_drawing_engine(); + virtual WellTopNine* new_well_top_nine(); + virtual WellIntro* new_well_intro(); + virtual WellKey* new_well_key(char*); + virtual WellInput* new_well_input(char*) { return 0;}; + virtual WellSwitch* new_well_switch(char*); + virtual WellImageFont* new_well_image_font(Images id, + unsigned int ifl, + unsigned int ifh, + int idx, int idy) { return 0;}; + + virtual WellBase* new_well_base(); + + virtual bool load_image(Images id, char* name) { return false;}; + virtual void set_main_background_image(Images id) {}; + virtual void screen_copy(Geo*) {}; + virtual void screen_clear(Geo*) {}; + virtual void load_images(); + virtual void udelay(int msec) {}; +}; + +extern WellEngine* default_well_engine; +extern WellEngine* new_well_engine(int argc, char** argv); + +#endif diff --git a/src/include/wellimagefont.h b/src/include/wellimagefont.h new file mode 100644 index 0000000..144dd92 --- /dev/null +++ b/src/include/wellimagefont.h @@ -0,0 +1,37 @@ +#ifndef WELLIMAGEFONT_H +#define WELLIMAGEFONT_H + +#include "globals.h" +#include "welltris.h" +#include "wellsimpledraw.h" + +enum Justify { RightJust, CenterJust, LeftJust }; + +class WellImageFont: public WellSimpleDraw +{ + protected: + Images font_id; + unsigned int font_l, font_h; + int dx,dy; + char text[L_MAXPATH]; + int text_l; + int screen_x,screen_y,screen_l,screen_h; + + virtual void draw_symbol(int ix, int iy, + unsigned int il, + unsigned int ih, + char symb)=0; + public: + WellImageFont(Images id, unsigned int ifl, unsigned int ifh, int idx, int idy); + virtual void set_text(char* itext); + virtual void set_font(unsigned int ifl, unsigned int ifh, + int idx, int idy); + virtual void set_screen_region(int ix, int iy, int il, int ih); + virtual void draw_text(Justify just=LeftJust); + virtual void draw_text(char* text, int text_l, Justify just=LeftJust); + virtual void draw_text(char* text, int text_l, Colors idx, Justify just=LeftJust); + virtual void clear_region()=0; + virtual void clear_region(Colors idx)=0; +}; + +#endif diff --git a/src/include/wellinput.h b/src/include/wellinput.h new file mode 100644 index 0000000..d36304c --- /dev/null +++ b/src/include/wellinput.h @@ -0,0 +1,30 @@ +#ifndef WELLINPUT_H +#define WELLINPUT_H + +#include "globals.h" +#include "wellobject.h" +#include "wellimagefont.h" + +class WellInput: public WellObject +{ + protected: + ObjectCaller object_on_enter; + char buf[L_MAXPATH]; + int buflen,pos,maxlen; + WellImageFont *fnt; + + virtual void draw_text(); + + public: + WellInput(char* keyname); + void set_object_on_enter(ObjectCaller o) { object_on_enter=o;}; + virtual bool process_event(wEvent); + virtual void show(); + virtual void hide(); + virtual void redraw(); + void set_text(char* txt); + void set_max_len(int ml) { maxlen=ml;}; + virtual char* get_text() { return buf;}; +}; + +#endif diff --git a/src/include/wellintro.h b/src/include/wellintro.h new file mode 100644 index 0000000..beb59ed --- /dev/null +++ b/src/include/wellintro.h @@ -0,0 +1,66 @@ +#ifndef WELLINTRO_H +#define WELLINTRO_H + +#include "welltris.h" +#include "wellobject.h" +#include "wellkey.h" +#include "wellimagefont.h" +#include "wellswitch.h" +#include "wellinput.h" + +class WellBase; + +class WellIntro: public WellObject +{ + protected: + ObjectCaller object_on_exit, + object_on_new_game, + object_on_top_nine; + + WellKey *key_exit, *key_new_game, *key_top_nine, + *key_plus, *key_minus; + + WellImageFont *txt_level; + WellBase *well; + + WellSwitch *sw_rotation, *sw_mixed, *sw_next_piece, + *sw_squares[TOTAL_SQUARES]; + + WellInput *inp_player; + + int start_level; + + void draw_start_level(); + char* get_next_token(char* from, char* to); + + public: + WellIntro(); + virtual bool process_event(wEvent); + virtual void show(); + virtual void redraw(); + virtual void hide(); + virtual bool hide_by_call(wEvent); + + void set_object_on_exit(ObjectCaller obj) + + { + object_on_exit=obj; + }; + void set_object_on_new_game(ObjectCaller obj) + + { + object_on_new_game=obj; + }; + void set_object_on_top_nine(ObjectCaller obj) + + { + object_on_top_nine=obj; + }; + void set_well_base(WellBase* o); + void put_all_to_game(); + void load_defaults(); + void load_options(); + void save_options(); +}; + +#endif diff --git a/src/include/wellkey.h b/src/include/wellkey.h new file mode 100644 index 0000000..08444f9 --- /dev/null +++ b/src/include/wellkey.h @@ -0,0 +1,24 @@ +#ifndef WELLKEY_H +#define WELLKEY_H + +#include "wellobject.h" + +class WellKey: public WellObject +{ + protected: + ObjectCaller object_on_press; + bool highlighted; + + bool press(int mx, int my); + bool highlight(int mx, int my); + + public: + WellKey(char* keyname); + void set_object_on_press(ObjectCaller o) { object_on_press=o;}; + virtual bool process_event(wEvent); + virtual void show(); + virtual void hide(); + virtual void redraw(); +}; + +#endif diff --git a/src/include/wellobject.h b/src/include/wellobject.h new file mode 100644 index 0000000..b80ade0 --- /dev/null +++ b/src/include/wellobject.h @@ -0,0 +1,74 @@ +#ifndef WELLOBJECT_H +#define WELLOBJECT_H + +#include "geometry.h" + +enum EvType { + eTimeOut, + eKeyPress, + eMouseMove, + eMousePress, + eExpose, + eDelete, + eFocusOut, + + aEmpty, + aGameOver, + aIntroExit, + aKeyPressed, + aSwitchChanged, + aInputDone +}; + + +enum ButtonState { But1Press, But2Press, But3Press }; + +struct wEvent +{ + EvType type; + void *data; + wEvent(EvType t,void *idata=0) { type=t;data=idata;}; +}; + +struct MouseEvent +{ + int mx,my; + ButtonState bstate; +}; + +//Basic class of all game objects +class WellObject +{ + protected: + bool shown; + Geo *geo; + char object_name[GEO_NAME+1]; + + public: + WellObject() { shown=false; geo=0; object_name[0]=0;}; + virtual bool process_event(wEvent)=0; + virtual void show() { shown=true;}; + virtual bool show_by_call(wEvent) { show(); return true;}; + virtual void hide() { shown=false;}; + virtual bool hide_by_call(wEvent) { hide(); return true;}; + virtual void redraw() {}; + virtual bool redraw_by_call(wEvent) { redraw(); return true;}; +}; + +class ObjectCaller +{ + WellObject *object; + bool (WellObject::*method)(wEvent); + + public: + ObjectCaller() { object=0; method=0;}; + ObjectCaller(WellObject* o,bool (WellObject::*m)(wEvent)) { object=o; method=m;}; + bool call(wEvent ev) + { + if(!object) + return false; + return (object->*method)(ev); + }; +}; + +#endif diff --git a/src/include/wellsimpledraw.h b/src/include/wellsimpledraw.h new file mode 100644 index 0000000..ba85b78 --- /dev/null +++ b/src/include/wellsimpledraw.h @@ -0,0 +1,63 @@ +#ifndef WELLSIMPLEDRAW_H +#define WELLSIMPLEDRAW_H + +#include "bilist.h" + +enum Canvas { screen=0, pixmap=1 }; + +struct WPoint +{ + int x,y; + WPoint() { x=y=0;}; +}; + +struct DirtyRect +{ + int delta_x,delta_y; //here is the delta between dest screen and our dirty screen + int x,y; + unsigned int l,h; + DirtyRect() { x=y=delta_x=delta_y=0;l=h=0;}; + DirtyRect(int dx, int dy, + int ix=0, int iy=0, + unsigned int il=0, unsigned int ih=0) + { + delta_x=dx; delta_y=dy; + x=ix; y=iy; + l=il; h=ih; + }; + int get_src_x() { return x;}; + int get_src_y() { return y;}; + int get_dest_x() { return delta_x+x;}; + int get_dest_y() { return delta_y+y;}; +}; + +typedef bilist DirtyList; + +class WellSimpleDraw +{ + protected: + DirtyList dirty_list; + int max_x,max_y,min_x,min_y; + DirtyRect current_dirty; + int max_dirties; + + public: + WellSimpleDraw(); + ~WellSimpleDraw(); + virtual void new_dirty_rec(int dx=0, int dy=0); + virtual void dirty_add_xy(int,int); + virtual void dirty_add_rec(DirtyRect); + virtual void finish_dirty_rec(); + virtual void clear_dirty_list(); + virtual void draw_line(int x1, int y1, int x2, int y2, int color_idx, + Canvas where=screen) {}; + virtual void draw_rect(int x1, int y1, unsigned int il, + unsigned int ih, int color_idx, + Canvas where=screen) {}; + virtual void fill_rect(int x1, int y1, unsigned int il, + unsigned int ih, int color_idx, + Canvas where=screen) {}; + int get_max_dirties() { return max_dirties;}; +}; + +#endif diff --git a/src/include/wellswitch.h b/src/include/wellswitch.h new file mode 100644 index 0000000..30deef8 --- /dev/null +++ b/src/include/wellswitch.h @@ -0,0 +1,31 @@ +#ifndef WELLSWITCH_H +#define WELLSWITCH_H + +#include "wellobject.h" + +enum SwitchMode { OnlySet, OnlyReset, SetReset}; + +class WellSwitch: public WellObject +{ + protected: + ObjectCaller object_on_switch; + bool highlighted; + bool value; + SwitchMode mode; + + bool press(int mx, int my); + bool highlight(int mx, int my); + + public: + WellSwitch(char* keyname); + void set_object_on_switch(ObjectCaller o) { object_on_switch=o;}; + virtual bool process_event(wEvent); + virtual void show(); + virtual void hide(); + virtual void redraw(); + void set_value(bool v) { value=v; if(shown) redraw();}; + bool get_value() { return value;}; + void set_mode(SwitchMode m) { mode=m;}; +}; + +#endif diff --git a/src/include/welltopnine.h b/src/include/welltopnine.h new file mode 100644 index 0000000..899aaa0 --- /dev/null +++ b/src/include/welltopnine.h @@ -0,0 +1,84 @@ +#ifndef WELLTOPNINE_H +#define WELLTOPNINE_H + +#include "globals.h" +#include "welltris.h" +#include "wellobject.h" +#include "wellimagefont.h" +#include "wellkey.h" + +struct Score +{ + int place; + char player[PLAYER_NAME_LEN+1]; + char date_time[L_DATE]; + int score; + int lines; + int level; + int squares; + bool mixed; + bool rotation; + bool next_piece; + time_t start_t; + int play_time; + + Score(); + void save(FILE* fp); + bool load(FILE* fp); + void set_current_time(); + char* get_next_token(char* from, char* to); + void calc_play_time(); + void set_player(char* pl); + void set_params(int iscore, int ilines, int ilevel) + { + score=iscore; lines=ilines; level=ilevel; + }; +}; + +struct ScoreTable +{ + Score *table[TOP_NINE]; + + ScoreTable(); + ~ScoreTable(); + + void sort_by_score(); + void save(FILE* fp); + void set_squares(int isquares); + Score* set_and_get(int idx, Score *toset); +}; + +class WellTopNine: public WellObject +{ + protected: + ScoreTable tables[MAX_SQUARES]; + WellImageFont* text_lines[TOP_NINE]; + ObjectCaller object_on_exit; + + Score* current_score; + int page; + + WellKey *key_exit; + + public: + WellTopNine(); + + virtual bool process_event(wEvent); + virtual void show(); + virtual void hide(); + virtual void redraw_table(); + bool save_scores(); + bool load_scores(); + Score* try_add_to_table(Score* new_one); + Score* find_challenger(Score* me); + void set_object_on_exit(ObjectCaller o) + { + object_on_exit=o; + }; + void set_page(int pg) { page=pg;}; +}; + +extern WellTopNine *default_top_nine; + + +#endif diff --git a/src/include/welltris.h b/src/include/welltris.h new file mode 100644 index 0000000..aeec493 --- /dev/null +++ b/src/include/welltris.h @@ -0,0 +1,230 @@ +#ifndef WELLTRIS_H +#define WELLTRIS_H +/* +# GENERIC X-BASED WELLTRIS +# +# welltris.h +# +# +# C++ implementation by Leo Khramov, leo@xnc.dubna.su +# +*/ + +/*** random number generator ***/ + +/* insert your favorite */ +extern void SetRNG(long); +extern long LongRNG(); +#define SRAND(X) SetRNG((long) X) +#define LRAND() LongRNG() + +#define NRAND(X) ((int)(LRAND()%(X))) + +/*** macros ***/ + +#define ZLIM(X, Y) (((int) X) < (Y) ? ((int) X) : (Y)) + +/*** constants ***/ + +#ifndef SCOREFILE +#define SCOREFILE "welltris.scores" +#endif +#ifndef POLYOMINOFILE +#define POLYOMINOFILE "polyomino.dat" +#endif + +#define XWELL_DIR ".xwelltris" +#define RC_FILE "xwelltris.rc" + +#define BVOLUME -90 +#define NUM_FLASHES 5 + +#define SAMPLERATE 5000000 +#define FLUSH_DELAY 100000 + +#define MILLION 1000000 +#define PLAYER_NAME_LEN 15 +#define TOP_NINE 9 +#define L_DATE 11 + +#define NUM_LEVELS 19 + + + +#define MAX_WIDTH 8 +#define MAX_DEPTH 12 +#define MAX_SIDES 4 +#define MAX_PERIMETER (MAX_SIDES*MAX_WIDTH) + + +#define EMPTY (-1) +#define NODIAG 0 /* Normal, ie no diagonals */ +#define DIAGONAL 1 /* Normal and diagonal */ +#define NOMIX 0 /* Do not mix lowered number squares with current */ +#define MIXED 1 +#define MAX_MODES 2 +#define NONE 0 /* No rotation or reflection */ +#define NOREFL 1 /* Normal, no reflection allow rotation */ +#define ALL 2 /* Allow reflection or rotation */ +#define MAX_TYPES 3 +#define DEFAULT_SQUARES 4 +#define MIN_SQUARES 2 /* Why not 1 you say? */ +#define MAX_SQUARES 6 +#define TOTAL_SQUARES (MAX_SQUARES - MIN_SQUARES + 1) +#define DEFAULT_DIAGONAL 3 +#define MIN_DIAGONAL 2 +#define MAX_DIAGONAL 3 +#define MAX_POLYOMINOES 216 +#define MAX_START_POLYOMINOES 55 +#define JUMPIN 0 +#define GRADUAL 1 +#define LEGAL(n,g,m,o) ((n>=MIN_SQUARES+m)&&\ + (n<=((g)?MAX_DIAGONAL:MAX_SQUARES)-o)) +#define THRESHOLD(x) ((x)*(x)*4-(x)+1) +#define CHECKUP(x) ((x)%8) +#define CHECKRIGHT(x) (((x)/8)*8+(x)%4) +#define CHECKDOWN(x) (((x)/4)*4+(x)%2) +#define CHECKLEFT(x) (((x)/2)*2) + +/*** types ***/ + +enum Actions { + NOTHING, + FALL, + DROP, + LEFT, + RIGHT, + ROTATE, + REFLECT, + PAUSE_GAME, + END_GAME, + OUTER_ROTATION, + INNER_ROTATION, + LEVEL_UP, + LEVEL_DOWN +}; + +#define SYSCOLORS 7 +#define MAX_GAME_COLORS (MAX_START_POLYOMINOES+SYSCOLORS) +#define COLOR_DELTA MAX_START_POLYOMINOES +#define FREE_COLORS (255 - 211 - SYSCOLORS) +enum Colors {BackColor=COLOR_DELTA, + GridColor=COLOR_DELTA+1, + GridColor2=COLOR_DELTA+2, + FreezeColor=COLOR_DELTA+3, + FlashColor=COLOR_DELTA+4, + BonusColor=COLOR_DELTA+5, + BonusColor2=COLOR_DELTA+6}; + + +enum Images { + imNone=-1, + imBoardBG=0, + imIntroBG=1, + imCuts=2, + imScoreBG=3, + imFont1=4 }; + + +#define MAX_IMAGES 20 + + +#define NEXT_CENTER_X 700 +#define NEXT_CENTER_Y 519 +#define NEXT_BOX_SIZE 15 +#define NEXT_X_SIZE 120 +#define NEXT_Y_SIZE 120 + +//scores region in the game +#define SCORE_REG_X 638 +#define SCORE_REG_Y 112 +#define SCORE_REG_L 126 +#define SCORE_REG_H 30 + +//Lines region in the game +#define LINES_REG_X 775-5*11 +#define LINES_REG_Y 172 +#define LINES_REG_L 55 +#define LINES_REG_H 17 + +//Level up region in the game +#define LEVUP_REG_X 775-4*11 +#define LEVUP_REG_Y 212 +#define LEVUP_REG_L 44 +#define LEVUP_REG_H 17 + +//Level region in the game +#define LEVEL_REG_X 775-3*11 +#define LEVEL_REG_Y 252 +#define LEVEL_REG_L 33 +#define LEVEL_REG_H 17 + +//Challengers region in the game +#define CHAL1_REG_X 613 +#define CHAL1_REG_Y 333 +#define CHAL2_REG_X 613 +#define CHAL2_REG_Y 358 +#define CHAL3_REG_X 613 +#define CHAL3_REG_Y 382 +#define CHAL_REG_L 12*15 +#define CHAL_REG_H 17 + +//Top nine text +#define TOPNINE_TXT_X 30 +#define TOPNINE_TXT_Y 140 +#define TOPNINE_TXT_L 750 +#define TOPNINE_TXT_H 22 +#define TOPNINE_TXT_STEPY 42 + +//challengers display name len in symbols +#define CHAL_NAME_LEN 9 + +//game view and other +#define VIEW_X 30 +#define VIEW_Y 30 +#define VIEW_L 540 +#define VIEW_H 540 + +#define NUM_ROT_STEPS 8 + +//Font sizes, delta ... +#define FONT1_L 10 +#define FONT1_H 18 +#define FONT1_DX 0 +#define FONT1_DY 0 + +#define FONT2_L 19 +#define FONT2_H 30 +#define FONT2_DX 12 +#define FONT2_DY 0 + +#define FONT3_L 15 +#define FONT3_H 23 +#define FONT3_DX 30 +#define FONT3_DY 0 + +#define FONT4_L 15 +#define FONT4_H 24 +#define FONT4_DX 45 +#define FONT4_DY 0 + +#define FONT5_L 15 +#define FONT5_H 24 +#define FONT5_DX 65 +#define FONT5_DY 0 + + +#define GEO_NAME 20 + +//Game geo idexes for wellbase +#define GEO_PAUSE_IDX 0 +#define GEO_ROT_IDX 1 +#define GEO_NEXT_IDX 2 +#define GEO_MIXED_IDX 3 + +#endif + + + + + diff --git a/src/include/xheaders.h b/src/include/xheaders.h new file mode 100644 index 0000000..37883b2 --- /dev/null +++ b/src/include/xheaders.h @@ -0,0 +1,9 @@ + +#include +#include +#include +#include +#include + + + diff --git a/src/main.cxx b/src/main.cxx new file mode 100644 index 0000000..d5abf15 --- /dev/null +++ b/src/main.cxx @@ -0,0 +1,67 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: main.cxx,v 1.3 2003/02/19 09:51:39 leo Exp $ + +/// module description +/// Main module - init the game, create main objects and entering in event loop + +#include "wellengine.h" +#include "wellclass.h" +#include "wellintro.h" + +WellBase *game_object; +WellIntro *game_intro; + +//=========================================================================== +/// global main(int, char**) +/// main function - start of the game +/// tags main +int main(int argc, char** argv) +{ + default_well_engine=new_well_engine(argc,argv); + + game_intro= default_well_engine->new_well_intro(); + default_top_nine=default_well_engine->new_well_top_nine(); + game_object= default_well_engine->new_well_base(); + + default_top_nine->load_scores(); + game_intro->set_well_base(game_object); + game_object->init(default_well_engine); + + game_object->set_object_on_game_over(ObjectCaller(default_top_nine, + &WellObject::show_by_call)); + + game_intro->set_object_on_new_game(ObjectCaller(game_object, + &WellObject::process_event)); + + game_intro->set_object_on_top_nine(ObjectCaller(default_top_nine, + &WellObject::show_by_call)); + + default_top_nine->set_object_on_exit(ObjectCaller(game_intro, + &WellObject::show_by_call)); + default_well_engine->show_main(); + game_intro->show(); + + default_well_engine->event_loop(); + + default_top_nine->save_scores(); + game_intro->save_options(); + + delete game_object; + delete default_top_nine; + delete default_well_engine; + return 0; +} diff --git a/src/makefile.in b/src/makefile.in new file mode 100644 index 0000000..46a3fd0 --- /dev/null +++ b/src/makefile.in @@ -0,0 +1,117 @@ +# XWelltris - a tetris like game +# +# Copyright (C) 2002 by Leo Khramov +# email: leo@xnc.dubna.su +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License 2 for more details. +# +include make.conf + +@MCOMMON@ + +.c.o: + $(CC) -c $(CXXINCLUDES) $(INCLUDES) $(CXXOPT) $< -o $@ + +IFACELIBS=@IFACELIBS@ +IFACEINC=@IFACEINC@ +IFACEOBJS=@IFACEOBJS@ + + X11IMAGE = \ + image/sublib/SDL_error.o \ + image/sublib/SDL_rwops.o \ + image/sublib/SDL_surface.o \ + image/sublib/SDL_to_picinfo.o \ + image/sublib/IMG_gif.o \ + image/image.o \ + image/convert.o \ + image/accel.o + X11OBJS = \ + x11/xwellengine.o \ + x11/xwelldrawing.o \ + x11/xwellinput.o \ + x11/xwellimagefont.o + SDLOBJS = \ + sdl/sdl_gfxprimitives.o \ + sdl/sdlwellengine.o \ + sdl/sdlwellimagefont.o \ + sdl/sdlwellinput.o \ + sdl/sdlwelldrawing.o + + OBJS = \ + mydebug.o \ + main.o \ + rndgen.o \ + geometry.o \ + commonfuncs.o \ + wellclass.o \ + welldrawing.o \ + wellengine.o \ + wellsimpledraw.o \ + wellimagefont.o \ + welltopnine.o \ + wellintro.o \ + wellkey.o \ + wellswitch.o \ + wellinput.o \ + $(IFACEOBJS) + + CXXINCLUDES=$(IFACEINC) + CXXOPT=$(DEFS) $(DEB) $(CFLAGS) + LOCAL_LIBRARIES=$(IFACELIBS) $(LIBS) + +PROGRAM =../xwelltris + +all:: $(PROGRAM) + +image/sublib/SDL_error.o: image/sublib/SDL_error.c + cd image && make sublib/SDL_error.o + +image/sublib/SDL_surface.o: image/sublib/SDL_surface.c + cd image && make sublib/SDL_surface.o + +image/sublib/SDL_rwops.o: image/sublib/SDL_rwops.c + cd image && make sublib/SDL_rwops.o + +image/sublib/SDL_to_picinfo.o: image/sublib/SDL_to_picinfo.c + cd image && make sublib/SDL_to_picinfo.o + +image/sublib/IMG_gif.o: image/sublib/IMG_gif.c + cd image && make sublib/IMG_gif.o + +image/accel.o: image/accel.c + cd image && make accel.o + +image/image.o: image/image.cxx + cd image && make image.o + +image/convert.o: image/convert.cxx + cd image && make convert.o + +$(JLOC): FORCE + -(cd jpeg && make) + + +$(PROGRAM): $(OBJS) + $(CXX) -o $@ $(OBJS) $(DEB) $(STRIPPING) $(CFLAGS) $(LDFLAGS) $(LOCAL_LIBRARIES) + +mydebug.o: mydebug.c + $(CC) -c $< $(CXXOPT) $(CXXINCLUDES) $(INCLUDES) $(CPPFLAGS) + +clean: + $(RM) -f *.o + $(RM) -f */*.o + (cd image && make clean) + +tags: FORCE + etags *.cxx x11/*.cxx sdl/*.cxx include/*.h + +FORCE: diff --git a/src/mydebug.c b/src/mydebug.c new file mode 100644 index 0000000..81caa2f --- /dev/null +++ b/src/mydebug.c @@ -0,0 +1,32 @@ +/**************************************************************************** +* Copyright (C) 2001 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ + +//This file contains C functions useful for debugging xnc -> printing. +#include "mydebug.h" + +int debprintf(const char *format,...) +{ + + va_list args; + int n; + + va_start(args, format); + n = fprintf(stderr, "[dbg] "); + n += vfprintf(stderr, format, args); + va_end(args); + fflush(stderr); + return (n); +} + diff --git a/src/rndgen.cxx b/src/rndgen.cxx new file mode 100644 index 0000000..310f483 --- /dev/null +++ b/src/rndgen.cxx @@ -0,0 +1,46 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: rndgen.cxx,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $ + +/// module description +/// Dr. Park's algorithm published in the Oct. '88 ACM +/// "Random Number Generators: Good Ones Are Hard To Find" +/// His version available at ftp://cs.wm.edu/pub/rngs.tar +/// Present form by many authors. + + +static int Seed = 1; /* This is required to be 32 bits long */ + +//=========================================================================== +/// global SetRNG(long) +/// Set random seed generator, +/// Given an integer, this routine initializes the RNG seed. +/// tags random_gen +void SetRNG(long s) +{ + Seed = (int) s; +} + +//=========================================================================== +/// global LongRNG() +/// Returns an pseudo random integer between 0 and 2147483647, inclusive. +/// tags random_gen +long LongRNG() +{ + if ((Seed = Seed % 44488 * 48271 - Seed / 44488 * 3399) < 0) + Seed += 2147483647; + return (long) (Seed - 1); +} diff --git a/src/sdl/sdl_gfxprimitives.c b/src/sdl/sdl_gfxprimitives.c new file mode 100644 index 0000000..af84a4c --- /dev/null +++ b/src/sdl/sdl_gfxprimitives.c @@ -0,0 +1,3387 @@ +/* + + SDL_gfxPrimitives - Graphics primitives for SDL surfaces + + LGPL (c) A. Schiffler + +*/ + +#include +#include +#include +#include + +#include "SDL.h" + +#include "sdl_gfxprimitives.h" +#include "sdl_gfxprimitives_font.h" + +/* -===================- */ + +/* Define this flag to use surface blits for alpha blended drawing. */ +/* This is usually slower that direct surface calculations. */ + +#undef SURFACE_ALPHA_PIXEL + +/* ----- Defines for pixel clipping tests */ + +#define clip_xmin(surface) surface->clip_rect.x +#define clip_xmax(surface) surface->clip_rect.x+surface->clip_rect.w-1 +#define clip_ymin(surface) surface->clip_rect.y +#define clip_ymax(surface) surface->clip_rect.y+surface->clip_rect.h-1 + +/* ----- Pixel - fast, no blending, no locking, clipping */ + +int fastPixelColorNolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color) +{ + int bpp; + Uint8 *p; + + /* + * Honor clipping setup at pixel level + */ + if ((x >= clip_xmin(dst)) && (x <= clip_xmax(dst)) && (y >= clip_ymin(dst)) && (y <= clip_ymax(dst))) { + + /* + * Get destination format + */ + bpp = dst->format->BytesPerPixel; + p = (Uint8 *) dst->pixels + y * dst->pitch + x * bpp; + switch (bpp) { + case 1: + *p = color; + break; + case 2: + *(Uint16 *) p = color; + break; + case 3: + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + p[0] = (color >> 16) & 0xff; + p[1] = (color >> 8) & 0xff; + p[2] = color & 0xff; + } else { + p[0] = color & 0xff; + p[1] = (color >> 8) & 0xff; + p[2] = (color >> 16) & 0xff; + } + break; + case 4: + *(Uint32 *) p = color; + break; + } /* switch */ + + + } + + return (0); +} + +/* ----- Pixel - fast, no blending, no locking, no clipping */ + +/* (faster but dangerous, make sure we stay in surface bounds) */ + +int fastPixelColorNolockNoclip(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color) +{ + int bpp; + Uint8 *p; + + /* + * Get destination format + */ + bpp = dst->format->BytesPerPixel; + p = (Uint8 *) dst->pixels + y * dst->pitch + x * bpp; + switch (bpp) { + case 1: + *p = color; + break; + case 2: + *(Uint16 *) p = color; + break; + case 3: + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + p[0] = (color >> 16) & 0xff; + p[1] = (color >> 8) & 0xff; + p[2] = color & 0xff; + } else { + p[0] = color & 0xff; + p[1] = (color >> 8) & 0xff; + p[2] = (color >> 16) & 0xff; + } + break; + case 4: + *(Uint32 *) p = color; + break; + } /* switch */ + + return (0); +} + +/* ----- Pixel - fast, no blending, locking, clipping */ + +int fastPixelColor(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color) +{ + int result; + + /* + * Lock the surface + */ + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + return (-1); + } + } + + result = fastPixelColorNolock(dst, x, y, color); + + /* + * Unlock surface + */ + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); + } + + return (result); +} + +/* ----- Pixel - fast, no blending, locking, RGB input */ + +int fastPixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + Uint32 color; + + /* + * Setup color + */ + color = SDL_MapRGBA(dst->format, r, g, b, a); + + /* + * Draw + */ + return (fastPixelColor(dst, x, y, color)); + +} + +/* ----- Pixel - fast, no blending, no locking RGB input */ + +int fastPixelRGBANolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + Uint32 color; + + /* + * Setup color + */ + color = SDL_MapRGBA(dst->format, r, g, b, a); + + /* + * Draw + */ + return (fastPixelColorNolock(dst, x, y, color)); +} + +#ifdef SURFACE_ALPHA_PIXEL + +/* ----- Pixel - using single pixel blit with blending enabled if a<255 */ + +/* Old, slower routine - normally disabled */ + +static SDL_Surface *gfxPrimitivesSinglePixel = NULL; + +int pixelColor(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color) +{ + SDL_Rect srect; + SDL_Rect drect; + int result; + + /* + * Setup source rectangle for pixel + */ + srect.x = 0; + srect.y = 0; + srect.w = 1; + srect.h = 1; + + /* + * Setup destination rectangle for pixel + */ + drect.x = x; + drect.y = y; + drect.w = 1; + drect.h = 1; + + /* + * Create single pixel in 32bit RGBA format + */ + if (gfxPrimitivesSinglePixel == NULL) { + gfxPrimitivesSinglePixel = + SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_HWSURFACE | SDL_SRCALPHA, 1, 1, + 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); + } + + /* + * Draw color into pixel + */ + SDL_FillRect(gfxPrimitivesSinglePixel, &srect, color); + + /* + * Draw pixel onto destination surface + */ + result = SDL_BlitSurface(gfxPrimitivesSinglePixel, &srect, dst, &drect); + + return (result); +} + +#else + +/* PutPixel routine with alpha blending, input color in destination format */ + +/* New, faster routine - default blending pixel */ + +int _putPixelAlpha(SDL_Surface * surface, Sint16 x, Sint16 y, Uint32 color, Uint8 alpha) +{ + Uint32 Rmask = surface->format->Rmask, Gmask = + surface->format->Gmask, Bmask = surface->format->Bmask, Amask = surface->format->Amask; + Uint32 R, G, B, A = 0; + + if (x >= clip_xmin(surface) && x <= clip_xmax(surface) + && y >= clip_ymin(surface) && y <= clip_ymax(surface)) { + + switch (surface->format->BytesPerPixel) { + case 1:{ /* Assuming 8-bpp */ + if (alpha == 255) { + *((Uint8 *) surface->pixels + y * surface->pitch + x) = color; + } else { + Uint8 *pixel = (Uint8 *) surface->pixels + y * surface->pitch + x; + + Uint8 dR = surface->format->palette->colors[*pixel].r; + Uint8 dG = surface->format->palette->colors[*pixel].g; + Uint8 dB = surface->format->palette->colors[*pixel].b; + Uint8 sR = surface->format->palette->colors[color].r; + Uint8 sG = surface->format->palette->colors[color].g; + Uint8 sB = surface->format->palette->colors[color].b; + + dR = dR + ((sR - dR) * alpha >> 8); + dG = dG + ((sG - dG) * alpha >> 8); + dB = dB + ((sB - dB) * alpha >> 8); + + *pixel = SDL_MapRGB(surface->format, dR, dG, dB); + } + } + break; + + case 2:{ /* Probably 15-bpp or 16-bpp */ + if (alpha == 255) { + *((Uint16 *) surface->pixels + y * surface->pitch / 2 + x) = color; + } else { + Uint16 *pixel = (Uint16 *) surface->pixels + y * surface->pitch / 2 + x; + Uint32 dc = *pixel; + + R = ((dc & Rmask) + (((color & Rmask) - (dc & Rmask)) * alpha >> 8)) & Rmask; + G = ((dc & Gmask) + (((color & Gmask) - (dc & Gmask)) * alpha >> 8)) & Gmask; + B = ((dc & Bmask) + (((color & Bmask) - (dc & Bmask)) * alpha >> 8)) & Bmask; + if (Amask) + A = ((dc & Amask) + (((color & Amask) - (dc & Amask)) * alpha >> 8)) & Amask; + + *pixel = R | G | B | A; + } + } + break; + + case 3:{ /* Slow 24-bpp mode, usually not used */ + Uint8 *pix = (Uint8 *) surface->pixels + y * surface->pitch + x * 3; + Uint8 rshift8 = surface->format->Rshift / 8; + Uint8 gshift8 = surface->format->Gshift / 8; + Uint8 bshift8 = surface->format->Bshift / 8; + Uint8 ashift8 = surface->format->Ashift / 8; + + + if (alpha == 255) { + *(pix + rshift8) = color >> surface->format->Rshift; + *(pix + gshift8) = color >> surface->format->Gshift; + *(pix + bshift8) = color >> surface->format->Bshift; + *(pix + ashift8) = color >> surface->format->Ashift; + } else { + Uint8 dR, dG, dB, dA = 0; + Uint8 sR, sG, sB, sA = 0; + + pix = (Uint8 *) surface->pixels + y * surface->pitch + x * 3; + + dR = *((pix) + rshift8); + dG = *((pix) + gshift8); + dB = *((pix) + bshift8); + dA = *((pix) + ashift8); + + sR = (color >> surface->format->Rshift) & 0xff; + sG = (color >> surface->format->Gshift) & 0xff; + sB = (color >> surface->format->Bshift) & 0xff; + sA = (color >> surface->format->Ashift) & 0xff; + + dR = dR + ((sR - dR) * alpha >> 8); + dG = dG + ((sG - dG) * alpha >> 8); + dB = dB + ((sB - dB) * alpha >> 8); + dA = dA + ((sA - dA) * alpha >> 8); + + *((pix) + rshift8) = dR; + *((pix) + gshift8) = dG; + *((pix) + bshift8) = dB; + *((pix) + ashift8) = dA; + } + } + break; + + case 4:{ /* Probably 32-bpp */ + if (alpha == 255) { + *((Uint32 *) surface->pixels + y * surface->pitch / 4 + x) = color; + } else { + Uint32 *pixel = (Uint32 *) surface->pixels + y * surface->pitch / 4 + x; + Uint32 dc = *pixel; + + R = ((dc & Rmask) + (((color & Rmask) - (dc & Rmask)) * alpha >> 8)) & Rmask; + G = ((dc & Gmask) + (((color & Gmask) - (dc & Gmask)) * alpha >> 8)) & Gmask; + B = ((dc & Bmask) + (((color & Bmask) - (dc & Bmask)) * alpha >> 8)) & Bmask; + if (Amask) + A = ((dc & Amask) + (((color & Amask) - (dc & Amask)) * alpha >> 8)) & Amask; + + *pixel = R | G | B | A; + } + } + break; + } + } + + return (0); +} + +/* ----- Pixel - pixel draw with blending enabled if a<255 */ + +int pixelColor(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color) +{ + Uint8 alpha; + Uint32 mcolor; + int result = 0; + + /* + * Lock the surface + */ + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + return (-1); + } + } + + /* + * Setup color + */ + alpha = color & 0x000000ff; + mcolor = + SDL_MapRGBA(dst->format, (color & 0xff000000) >> 24, + (color & 0x00ff0000) >> 16, (color & 0x0000ff00) >> 8, alpha); + + /* + * Draw + */ + result = _putPixelAlpha(dst, x, y, mcolor, alpha); + + /* + * Unlock the surface + */ + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); + } + + return (result); +} + +int pixelColorNolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color) +{ + Uint8 alpha; + Uint32 mcolor; + int result = 0; + + /* + * Setup color + */ + alpha = color & 0x000000ff; + mcolor = + SDL_MapRGBA(dst->format, (color & 0xff000000) >> 24, + (color & 0x00ff0000) >> 16, (color & 0x0000ff00) >> 8, alpha); + + /* + * Draw + */ + result = _putPixelAlpha(dst, x, y, mcolor, alpha); + + return (result); +} + + +/* Filled rectangle with alpha blending, color in destination format */ + +int _filledRectAlpha(SDL_Surface * surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color, Uint8 alpha) +{ + Uint32 Rmask = surface->format->Rmask, Gmask = + surface->format->Gmask, Bmask = surface->format->Bmask, Amask = surface->format->Amask; + Uint32 R, G, B, A = 0; + Sint16 x, y; + + switch (surface->format->BytesPerPixel) { + case 1:{ /* Assuming 8-bpp */ + Uint8 *row, *pixel; + Uint8 dR, dG, dB; + + Uint8 sR = surface->format->palette->colors[color].r; + Uint8 sG = surface->format->palette->colors[color].g; + Uint8 sB = surface->format->palette->colors[color].b; + + for (y = y1; y <= y2; y++) { + row = (Uint8 *) surface->pixels + y * surface->pitch; + for (x = x1; x <= x2; x++) { + pixel = row + x; + + dR = surface->format->palette->colors[*pixel].r; + dG = surface->format->palette->colors[*pixel].g; + dB = surface->format->palette->colors[*pixel].b; + + dR = dR + ((sR - dR) * alpha >> 8); + dG = dG + ((sG - dG) * alpha >> 8); + dB = dB + ((sB - dB) * alpha >> 8); + + *pixel = SDL_MapRGB(surface->format, dR, dG, dB); + } + } + } + break; + + case 2:{ /* Probably 15-bpp or 16-bpp */ + Uint16 *row, *pixel; + Uint32 dR = (color & Rmask), dG = (color & Gmask), dB = (color & Bmask), dA = (color & Amask); + + for (y = y1; y <= y2; y++) { + row = (Uint16 *) surface->pixels + y * surface->pitch / 2; + for (x = x1; x <= x2; x++) { + pixel = row + x; + + R = ((*pixel & Rmask) + ((dR - (*pixel & Rmask)) * alpha >> 8)) & Rmask; + G = ((*pixel & Gmask) + ((dG - (*pixel & Gmask)) * alpha >> 8)) & Gmask; + B = ((*pixel & Bmask) + ((dB - (*pixel & Bmask)) * alpha >> 8)) & Bmask; + if (Amask) + A = ((*pixel & Amask) + ((dA - (*pixel & Amask)) * alpha >> 8)) & Amask; + + *pixel = R | G | B | A; + } + } + } + break; + + case 3:{ /* Slow 24-bpp mode, usually not used */ + Uint8 *row, *pix; + Uint8 dR, dG, dB, dA; + Uint8 rshift8 = surface->format->Rshift / 8; + Uint8 gshift8 = surface->format->Gshift / 8; + Uint8 bshift8 = surface->format->Bshift / 8; + Uint8 ashift8 = surface->format->Ashift / 8; + + Uint8 sR = (color >> surface->format->Rshift) & 0xff; + Uint8 sG = (color >> surface->format->Gshift) & 0xff; + Uint8 sB = (color >> surface->format->Bshift) & 0xff; + Uint8 sA = (color >> surface->format->Ashift) & 0xff; + + for (y = y1; y <= y2; y++) { + row = (Uint8 *) surface->pixels + y * surface->pitch; + for (x = x1; x <= x2; x++) { + pix = row + x * 3; + + dR = *((pix) + rshift8); + dG = *((pix) + gshift8); + dB = *((pix) + bshift8); + dA = *((pix) + ashift8); + + dR = dR + ((sR - dR) * alpha >> 8); + dG = dG + ((sG - dG) * alpha >> 8); + dB = dB + ((sB - dB) * alpha >> 8); + dA = dA + ((sA - dA) * alpha >> 8); + + *((pix) + rshift8) = dR; + *((pix) + gshift8) = dG; + *((pix) + bshift8) = dB; + *((pix) + ashift8) = dA; + } + } + + } + break; + + case 4:{ /* Probably 32-bpp */ + Uint32 *row, *pixel; + Uint32 dR = (color & Rmask), dG = (color & Gmask), dB = (color & Bmask), dA = (color & Amask); + + for (y = y1; y <= y2; y++) { + row = (Uint32 *) surface->pixels + y * surface->pitch / 4; + for (x = x1; x <= x2; x++) { + pixel = row + x; + + R = ((*pixel & Rmask) + ((dR - (*pixel & Rmask)) * alpha >> 8)) & Rmask; + G = ((*pixel & Gmask) + ((dG - (*pixel & Gmask)) * alpha >> 8)) & Gmask; + B = ((*pixel & Bmask) + ((dB - (*pixel & Bmask)) * alpha >> 8)) & Bmask; + if (Amask) + A = ((*pixel & Amask) + ((dA - (*pixel & Amask)) * alpha >> 8)) & Amask; + + *pixel = R | G | B | A; + } + } + } + break; + } + + return (0); +} + +/* Draw rectangle with alpha enabled from RGBA color. */ + +int filledRectAlpha(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) +{ + Uint8 alpha; + Uint32 mcolor; + int result = 0; + + /* + * Lock the surface + */ + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + return (-1); + } + } + + /* + * Setup color + */ + alpha = color & 0x000000ff; + mcolor = + SDL_MapRGBA(dst->format, (color & 0xff000000) >> 24, + (color & 0x00ff0000) >> 16, (color & 0x0000ff00) >> 8, alpha); + + /* + * Draw + */ + result = _filledRectAlpha(dst, x1, y1, x2, y2, mcolor, alpha); + + /* + * Unlock the surface + */ + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); + } + + return (result); +} + +/* Draw horizontal line with alpha enabled from RGBA color */ + +int HLineAlpha(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color) +{ + return (filledRectAlpha(dst, x1, y, x2, y, color)); +} + + +/* Draw vertical line with alpha enabled from RGBA color */ + +int VLineAlpha(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color) +{ + return (filledRectAlpha(dst, x, y1, x, y2, color)); +} + +#endif + + +/* Pixel - using alpha weight on color for AA-drawing */ + +int pixelColorWeight(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color, Uint32 weight) +{ + Uint32 a; + + /* + * Get alpha + */ + a = (color & (Uint32) 0x000000ff); + + /* + * Modify Alpha by weight + */ + a = ((a * weight) >> 8); + + return (pixelColor(dst, x, y, (color & (Uint32) 0xffffff00) | (Uint32) a)); +} + +/* Pixel - using alpha weight on color for AA-drawing - no locking */ + +int pixelColorWeightNolock(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color, Uint32 weight) +{ + Uint32 a; + + /* + * Get alpha + */ + a = (color & (Uint32) 0x000000ff); + + /* + * Modify Alpha by weight + */ + a = ((a * weight) >> 8); + + return (pixelColorNolock(dst, x, y, (color & (Uint32) 0xffffff00) | (Uint32) a)); +} + +int pixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + Uint32 color; + + /* + * Check Alpha + */ + if (a == 255) { + /* + * No alpha blending required + */ + /* + * Setup color + */ + color = SDL_MapRGBA(dst->format, r, g, b, a); + /* + * Draw + */ + return (fastPixelColor(dst, x, y, color)); + } else { + /* + * Alpha blending required + */ + /* + * Draw + */ + return (pixelColor(dst, x, y, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); + } +} + +/* ----- Horizontal line */ + +#ifdef SURFACE_ALPHA_PIXEL +static SDL_Surface *gfxPrimitivesHline = NULL; +#endif + +int hlineColor(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color) +{ + Sint16 left, right, top, bottom; + Uint8 *pixel, *pixellast; + int dx; + int pixx, pixy; + Sint16 w; + Sint16 xtmp; + int result = -1; + Uint8 *colorptr; + +#ifdef SURFACE_ALPHA_PIXEL + Uint32 a; + SDL_Rect srect; + SDL_Rect drect; +#endif + + /* + * Get clipping boundary + */ + left = dst->clip_rect.x; + right = dst->clip_rect.x + dst->clip_rect.w - 1; + top = dst->clip_rect.y; + bottom = dst->clip_rect.y + dst->clip_rect.h - 1; + + /* + * Swap x1, x2 if required + */ + if (x1 > x2) { + xtmp = x1; + x1 = x2; + x2 = xtmp; + } + + /* + * Visible + */ + if ((x1 > right) || (x2 < left) || (y < top) || (y > bottom)) { + return (0); + } + + /* + * Clip x + */ + if (x1 < left) { + x1 = left; + } + if (x2 > right) { + x2 = right; + } + + /* + * Calculate width + */ + w = x2 - x1; + + /* + * Sanity check on width + */ + if (w < 0) { + return (0); + } + + /* + * Alpha check + */ + if ((color & 255) == 255) { + + /* + * No alpha-blending required + */ + + /* + * Setup color + */ + colorptr = (Uint8 *) & color; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], colorptr[2], colorptr[3]); + } else { + color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], colorptr[1], colorptr[0]); + } + + /* + * Lock surface + */ + SDL_LockSurface(dst); + + /* + * More variable setup + */ + dx = w; + pixx = dst->format->BytesPerPixel; + pixy = dst->pitch; + pixel = ((Uint8 *) dst->pixels) + pixx * (int) x1 + pixy * (int) y; + + /* + * Draw + */ + switch (dst->format->BytesPerPixel) { + case 1: + memset(pixel, color, dx); + break; + case 2: + pixellast = pixel + dx + dx; + for (; pixel <= pixellast; pixel += pixx) { + *(Uint16 *) pixel = color; + } + break; + case 3: + pixellast = pixel + dx + dx + dx; + for (; pixel <= pixellast; pixel += pixx) { + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + pixel[0] = (color >> 16) & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = color & 0xff; + } else { + pixel[0] = color & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = (color >> 16) & 0xff; + } + } + break; + default: /* case 4 */ + dx = dx + dx; + pixellast = pixel + dx + dx; + for (; pixel <= pixellast; pixel += pixx) { + *(Uint32 *) pixel = color; + } + break; + } + + /* + * Unlock surface + */ + SDL_UnlockSurface(dst); + + /* + * Set result code + */ + result = 0; + + } else { + + /* + * Alpha blending blit + */ + +#ifdef SURFACE_ALPHA_PIXEL + + /* + * Adjust width for Rect setup + */ + w++; + + /* + * Setup source rectangle for pixel + */ + srect.x = 0; + srect.y = 0; + srect.w = w; + srect.h = 1; + + /* + * Setup rectangle for destination line + */ + drect.x = x1; + drect.y = y; + drect.w = w; + drect.h = 1; + + /* + * Maybe deallocate existing surface if size is too small + */ + if ((gfxPrimitivesHline != NULL) && (gfxPrimitivesHline->w < w)) { + SDL_FreeSurface(gfxPrimitivesHline); + gfxPrimitivesHline = NULL; + } + + /* + * Create horizontal line surface in destination format if necessary + */ + if (gfxPrimitivesHline == NULL) { + gfxPrimitivesHline = + SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_HWSURFACE | SDL_SRCALPHA, w, + 1, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); + } + + /* + * Get alpha + */ + a = (color & (Uint32) 0x000000ff); + + /* + * Toggle alpha blending if necessary, reset otherwise + */ + if (a != 255) { + SDL_SetAlpha(gfxPrimitivesHline, SDL_SRCALPHA, 255); + } else { + SDL_SetAlpha(gfxPrimitivesHline, 0, 255); + } + + /* + * Draw color into pixel + */ + SDL_FillRect(gfxPrimitivesHline, &srect, color); + + /* + * Draw pixel onto destination surface + */ + result = SDL_BlitSurface(gfxPrimitivesHline, &srect, dst, &drect); + +#else + + result = HLineAlpha(dst, x1, x1 + w, y, color); + +#endif + + } + + return (result); +} + +int hlineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (hlineColor(dst, x1, x2, y, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* ----- Vertical line */ + +#ifdef SURFACE_ALPHA_PIXEL +static SDL_Surface *gfxPrimitivesVline = NULL; +#endif + +int vlineColor(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color) +{ + Sint16 left, right, top, bottom; + Uint8 *pixel, *pixellast; + int dy; + int pixx, pixy; + Sint16 h; + Sint16 ytmp; + int result = -1; + Uint8 *colorptr; + +#ifdef SURFACE_ALPHA_PIXEL + SDL_Rect srect; + SDL_Rect drect; + Uint32 a; +#endif + + /* + * Get clipping boundary + */ + left = dst->clip_rect.x; + right = dst->clip_rect.x + dst->clip_rect.w - 1; + top = dst->clip_rect.y; + bottom = dst->clip_rect.y + dst->clip_rect.h - 1; + + /* + * Swap y1, y2 if required + */ + if (y1 > y2) { + ytmp = y1; + y1 = y2; + y2 = ytmp; + } + + /* + * Visible + */ + if ((y2 < top) || (y1 > bottom) || (x < left) || (x > right)) { + return (0); + } + + /* + * Clip y + */ + if (y1 < top) { + y1 = top; + } + if (y2 > bottom) { + y2 = bottom; + } + + /* + * Calculate height + */ + h = y2 - y1; + + /* + * Sanity check on height + */ + if (h < 0) { + return (0); + } + + /* + * Alpha check + */ + if ((color & 255) == 255) { + + /* + * No alpha-blending required + */ + + /* + * Setup color + */ + colorptr = (Uint8 *) & color; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], colorptr[2], colorptr[3]); + } else { + color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], colorptr[1], colorptr[0]); + } + + /* + * Lock surface + */ + SDL_LockSurface(dst); + + /* + * More variable setup + */ + dy = h; + pixx = dst->format->BytesPerPixel; + pixy = dst->pitch; + pixel = ((Uint8 *) dst->pixels) + pixx * (int) x + pixy * (int) y1; + pixellast = pixel + pixy * dy; + + /* + * Draw + */ + switch (dst->format->BytesPerPixel) { + case 1: + for (; pixel <= pixellast; pixel += pixy) { + *(Uint8 *) pixel = color; + } + break; + case 2: + for (; pixel <= pixellast; pixel += pixy) { + *(Uint16 *) pixel = color; + } + break; + case 3: + for (; pixel <= pixellast; pixel += pixy) { + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + pixel[0] = (color >> 16) & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = color & 0xff; + } else { + pixel[0] = color & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = (color >> 16) & 0xff; + } + } + break; + default: /* case 4 */ + for (; pixel <= pixellast; pixel += pixy) { + *(Uint32 *) pixel = color; + } + break; + } + + /* + * Unlock surface + */ + SDL_UnlockSurface(dst); + + /* + * Set result code + */ + result = 0; + + } else { + + /* + * Alpha blending blit + */ + +#ifdef SURFACE_ALPHA_PIXEL + + /* + * Adjust height for Rect setup + */ + h++; + + /* + * Setup source rectangle for pixel + */ + srect.x = 0; + srect.y = 0; + srect.w = 1; + srect.h = h; + + /* + * Setup rectangle for line + */ + drect.x = x; + drect.y = y1; + drect.w = 1; + drect.h = h; + + /* + * Maybe deallocate existing surface if size is too small + */ + if ((gfxPrimitivesVline != NULL) && (gfxPrimitivesVline->h < h)) { + SDL_FreeSurface(gfxPrimitivesVline); + gfxPrimitivesVline = NULL; + } + + /* + * Create horizontal line surface in destination format if necessary + */ + if (gfxPrimitivesVline == NULL) { + gfxPrimitivesVline = + SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_HWSURFACE | SDL_SRCALPHA, 1, + h, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); + } + + /* + * Get alpha + */ + a = (color & (Uint32) 0x000000ff); + + /* + * Toggle alpha blending if necessary, reset otherwise + */ + if (a != 255) { + SDL_SetAlpha(gfxPrimitivesVline, SDL_SRCALPHA, 255); + } else { + SDL_SetAlpha(gfxPrimitivesVline, 0, 255); + } + + /* + * Draw color into pixel + */ + SDL_FillRect(gfxPrimitivesVline, &srect, color); + + /* + * Draw Vline onto destination surface + */ + result = SDL_BlitSurface(gfxPrimitivesVline, &srect, dst, &drect); + +#else + + result = VLineAlpha(dst, x, y1, y1 + h, color); + +#endif + + } + + return (result); +} + +int vlineRGBA(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (vlineColor(dst, x, y1, y2, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* ----- Rectangle */ + +int rectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) +{ + int result; + Sint16 w, h, xtmp, ytmp; + + + /* + * Swap x1, x2 if required + */ + if (x1 > x2) { + xtmp = x1; + x1 = x2; + x2 = xtmp; + } + + /* + * Swap y1, y2 if required + */ + if (y1 > y2) { + ytmp = y1; + y1 = y2; + y2 = ytmp; + } + + /* + * Calculate width&height + */ + w = x2 - x1; + h = y2 - y1; + + /* + * Sanity check + */ + if ((w < 0) || (h < 0)) { + return (0); + } + + /* + * Test for special cases of straight lines or single point + */ + if (x1 == x2) { + if (y1 == y2) { + return (pixelColor(dst, x1, y1, color)); + } else { + return (vlineColor(dst, x1, y1, y2, color)); + } + } else { + if (y1 == y2) { + return (hlineColor(dst, x1, x2, y1, color)); + } + } + + /* + * Draw rectangle + */ + result = 0; + result |= vlineColor(dst, x1, y1, y2, color); + result |= vlineColor(dst, x2, y1, y2, color); + result |= hlineColor(dst, x1, x2, y1, color); + result |= hlineColor(dst, x1, x2, y2, color); + + return (result); + +} + +int rectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (rectangleColor + (dst, x1, y1, x2, y2, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* --------- Clipping routines for box/line */ + +/* Clipping based heavily on code from */ + +/* http://www.ncsa.uiuc.edu/Vis/Graphics/src/clipCohSuth.c */ + +#define CLIP_LEFT_EDGE 0x1 +#define CLIP_RIGHT_EDGE 0x2 +#define CLIP_BOTTOM_EDGE 0x4 +#define CLIP_TOP_EDGE 0x8 +#define CLIP_INSIDE(a) (!a) +#define CLIP_REJECT(a,b) (a&b) +#define CLIP_ACCEPT(a,b) (!(a|b)) + +static int clipEncode(Sint16 x, Sint16 y, Sint16 left, Sint16 top, Sint16 right, Sint16 bottom) +{ + int code = 0; + + if (x < left) { + code |= CLIP_LEFT_EDGE; + } else if (x > right) { + code |= CLIP_RIGHT_EDGE; + } + if (y < top) { + code |= CLIP_TOP_EDGE; + } else if (y > bottom) { + code |= CLIP_BOTTOM_EDGE; + } + return code; +} + +static int clipLine(SDL_Surface * dst, Sint16 * x1, Sint16 * y1, Sint16 * x2, Sint16 * y2) +{ + Sint16 left, right, top, bottom; + int code1, code2; + int draw = 0; + Sint16 swaptmp; + float m; + + /* + * Get clipping boundary + */ + left = dst->clip_rect.x; + right = dst->clip_rect.x + dst->clip_rect.w - 1; + top = dst->clip_rect.y; + bottom = dst->clip_rect.y + dst->clip_rect.h - 1; + + while (1) { + code1 = clipEncode(*x1, *y1, left, top, right, bottom); + code2 = clipEncode(*x2, *y2, left, top, right, bottom); + if (CLIP_ACCEPT(code1, code2)) { + draw = 1; + break; + } else if (CLIP_REJECT(code1, code2)) + break; + else { + if (CLIP_INSIDE(code1)) { + swaptmp = *x2; + *x2 = *x1; + *x1 = swaptmp; + swaptmp = *y2; + *y2 = *y1; + *y1 = swaptmp; + swaptmp = code2; + code2 = code1; + code1 = swaptmp; + } + if (*x2 != *x1) { + m = (*y2 - *y1) / (float) (*x2 - *x1); + } else { + m = 1.0f; + } + if (code1 & CLIP_LEFT_EDGE) { + *y1 += (Sint16) ((left - *x1) * m); + *x1 = left; + } else if (code1 & CLIP_RIGHT_EDGE) { + *y1 += (Sint16) ((right - *x1) * m); + *x1 = right; + } else if (code1 & CLIP_BOTTOM_EDGE) { + if (*x2 != *x1) { + *x1 += (Sint16) ((bottom - *y1) / m); + } + *y1 = bottom; + } else if (code1 & CLIP_TOP_EDGE) { + if (*x2 != *x1) { + *x1 += (Sint16) ((top - *y1) / m); + } + *y1 = top; + } + } + } + + return draw; +} + +/* ----- Filled rectangle (Box) */ + +#ifdef SURFACE_ALPHA_PIXEL +static SDL_Surface *gfxPrimitivesBox = NULL; +#endif + +int boxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) +{ + Uint8 *pixel, *pixellast; + int x, dx; + int dy; + int pixx, pixy; + Sint16 w, h, tmp; + int result; + Uint8 *colorptr; + +#ifdef SURFACE_ALPHA_PIXEL + Uint32 a; + SDL_Rect srect; + SDL_Rect drect; +#endif + + /* + * Clip diagonal and test if we have to draw + */ + if (!(clipLine(dst, &x1, &y1, &x2, &y2))) { + return (0); + } + + /* + * Test for special cases of straight lines or single point + */ + if (x1 == x2) { + if (y1 < y2) { + return (vlineColor(dst, x1, y1, y2, color)); + } else if (y1 > y2) { + return (vlineColor(dst, x1, y2, y1, color)); + } else { + return (pixelColor(dst, x1, y1, color)); + } + } + if (y1 == y2) { + if (x1 < x2) { + return (hlineColor(dst, x1, x2, y1, color)); + } else if (x1 > x2) { + return (hlineColor(dst, x2, x1, y1, color)); + } + } + + /* + * Order coordinates + */ + if (x1 > x2) { + tmp = x1; + x1 = x2; + x2 = tmp; + } + if (y1 > y2) { + tmp = y1; + y1 = y2; + y2 = tmp; + } + + /* + * Calculate width&height + */ + w = x2 - x1; + h = y2 - y1; + + /* + * Alpha check + */ + if ((color & 255) == 255) { + + /* + * No alpha-blending required + */ + + /* + * Setup color + */ + colorptr = (Uint8 *) & color; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], colorptr[2], colorptr[3]); + } else { + color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], colorptr[1], colorptr[0]); + } + + /* + * Lock surface + */ + SDL_LockSurface(dst); + + /* + * More variable setup + */ + dx = w; + dy = h; + pixx = dst->format->BytesPerPixel; + pixy = dst->pitch; + pixel = ((Uint8 *) dst->pixels) + pixx * (int) x1 + pixy * (int) y1; + pixellast = pixel + pixx * dx + pixy * dy; + + /* + * Draw + */ + switch (dst->format->BytesPerPixel) { + case 1: + for (; pixel <= pixellast; pixel += pixy) { + memset(pixel, (Uint8) color, dx); + } + break; + case 2: + pixy -= (pixx * dx); + for (; pixel <= pixellast; pixel += pixy) { + for (x = 0; x < dx; x++) { + *(Uint16 *) pixel = color; + pixel += pixx; + } + } + break; + case 3: + pixy -= (pixx * dx); + for (; pixel <= pixellast; pixel += pixy) { + for (x = 0; x < dx; x++) { + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + pixel[0] = (color >> 16) & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = color & 0xff; + } else { + pixel[0] = color & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = (color >> 16) & 0xff; + } + pixel += pixx; + } + } + break; + default: /* case 4 */ + pixy -= (pixx * dx); + for (; pixel <= pixellast; pixel += pixy) { + for (x = 0; x < dx; x++) { + *(Uint32 *) pixel = color; + pixel += pixx; + } + } + break; + } + + /* + * Unlock surface + */ + SDL_UnlockSurface(dst); + + result = 0; + + } else { + +#ifdef SURFACE_ALPHA_PIXEL + + /* + * Setup source rectangle for pixel + */ + srect.x = 0; + srect.y = 0; + srect.w = w; + srect.h = h; + + /* + * Setup rectangle for line + */ + drect.x = x1; + drect.y = y1; + drect.w = w; + drect.h = h; + + /* + * Maybe deallocate existing surface if size is too small + */ + if ((gfxPrimitivesBox != NULL) + && ((gfxPrimitivesBox->w < w) || (gfxPrimitivesBox->h < h))) { + SDL_FreeSurface(gfxPrimitivesBox); + gfxPrimitivesBox = NULL; + } + + /* + * Create box surface in destination format if necessary + */ + if (gfxPrimitivesBox == NULL) { + gfxPrimitivesBox = + SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_HWSURFACE | SDL_SRCALPHA, w, + h, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); + } + + /* + * Get alpha + */ + a = (color & (Uint32) 0x000000ff); + + /* + * Toggle alpha blending if necessary, reset otherwise + */ + if (a != 255) { + SDL_SetAlpha(gfxPrimitivesBox, SDL_SRCALPHA, 255); + } else { + SDL_SetAlpha(gfxPrimitivesBox, 0, 255); + } + + /* + * Draw color into pixel + */ + SDL_FillRect(gfxPrimitivesBox, &srect, color); + + /* + * Draw pixel onto destination surface + */ + result = SDL_BlitSurface(gfxPrimitivesBox, &srect, dst, &drect); + +#else + + result = filledRectAlpha(dst, x1, y1, x1 + w, y1 + h, color); + +#endif + + } + + return (result); +} + +int boxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (boxColor(dst, x1, y1, x2, y2, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* ----- Line */ + +/* Non-alpha line drawing code adapted from routine */ +/* by Pete Shinners, pete@shinners.org */ +/* Originally from pygame, http://pygame.seul.org */ + +#define ABS(a) (((a)<0) ? -(a) : (a)) + +int lineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) +{ + int pixx, pixy; + int x, y; + int dx, dy; + int ax, ay; + int sx, sy; + int swaptmp; + Uint8 *pixel; + Uint8 *colorptr; + + /* + * Clip line and test if we have to draw + */ + if (!(clipLine(dst, &x1, &y1, &x2, &y2))) { + return (0); + } + + /* + * Test for special cases of straight lines or single point + */ + if (x1 == x2) { + if (y1 < y2) { + return (vlineColor(dst, x1, y1, y2, color)); + } else if (y1 > y2) { + return (vlineColor(dst, x1, y2, y1, color)); + } else { + return (pixelColor(dst, x1, y1, color)); + } + } + if (y1 == y2) { + if (x1 < x2) { + return (hlineColor(dst, x1, x2, y1, color)); + } else if (x1 > x2) { + return (hlineColor(dst, x2, x1, y1, color)); + } + } + + /* + * Variable setup + */ + dx = x2 - x1; + dy = y2 - y1; + sx = (dx >= 0) ? 1 : -1; + sy = (dy >= 0) ? 1 : -1; + + /* Lock surface */ + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + return (-1); + } + } + + /* + * Check for alpha blending + */ + if ((color & 255) == 255) { + + /* + * No alpha blending - use fast pixel routines + */ + + /* + * Setup color + */ + colorptr = (Uint8 *) & color; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], colorptr[2], colorptr[3]); + } else { + color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], colorptr[1], colorptr[0]); + } + + /* + * More variable setup + */ + dx = sx * dx + 1; + dy = sy * dy + 1; + pixx = dst->format->BytesPerPixel; + pixy = dst->pitch; + pixel = ((Uint8 *) dst->pixels) + pixx * (int) x1 + pixy * (int) y1; + pixx *= sx; + pixy *= sy; + if (dx < dy) { + swaptmp = dx; + dx = dy; + dy = swaptmp; + swaptmp = pixx; + pixx = pixy; + pixy = swaptmp; + } + + /* + * Draw + */ + x = 0; + y = 0; + switch (dst->format->BytesPerPixel) { + case 1: + for (; x < dx; x++, pixel += pixx) { + *pixel = color; + y += dy; + if (y >= dx) { + y -= dx; + pixel += pixy; + } + } + break; + case 2: + for (; x < dx; x++, pixel += pixx) { + *(Uint16 *) pixel = color; + y += dy; + if (y >= dx) { + y -= dx; + pixel += pixy; + } + } + break; + case 3: + for (; x < dx; x++, pixel += pixx) { + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + pixel[0] = (color >> 16) & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = color & 0xff; + } else { + pixel[0] = color & 0xff; + pixel[1] = (color >> 8) & 0xff; + pixel[2] = (color >> 16) & 0xff; + } + y += dy; + if (y >= dx) { + y -= dx; + pixel += pixy; + } + } + break; + default: /* case 4 */ + for (; x < dx; x++, pixel += pixx) { + *(Uint32 *) pixel = color; + y += dy; + if (y >= dx) { + y -= dx; + pixel += pixy; + } + } + break; + } + + } else { + + /* + * Alpha blending required - use single-pixel blits + */ + + ax = ABS(dx) << 1; + ay = ABS(dy) << 1; + x = x1; + y = y1; + if (ax > ay) { + int d = ay - (ax >> 1); + + while (x != x2) { + pixelColorNolock (dst, x, y, color); + if (d > 0 || (d == 0 && sx == 1)) { + y += sy; + d -= ax; + } + x += sx; + d += ay; + } + } else { + int d = ax - (ay >> 1); + + while (y != y2) { + pixelColorNolock (dst, x, y, color); + if (d > 0 || ((d == 0) && (sy == 1))) { + x += sx; + d -= ay; + } + y += sy; + d += ax; + } + } + pixelColorNolock (dst, x, y, color); + + } + + /* Unlock surface */ + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); + } + + return (0); +} + +int lineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (lineColor(dst, x1, y1, x2, y2, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* AA Line */ + +#define AAlevels 256 +#define AAbits 8 + +/* + +This implementation of the Wu antialiasing code is based on Mike Abrash's +DDJ article which was reprinted as Chapter 42 of his Graphics Programming +Black Book, but has been optimized to work with SDL and utilizes 32-bit +fixed-point arithmetic. (A. Schiffler). + +*/ + +int aalineColorInt(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color, int draw_endpoint) +{ + Sint32 xx0, yy0, xx1, yy1; + int result; + Uint32 intshift, erracc, erradj; + Uint32 erracctmp, wgt, wgtcompmask; + int dx, dy, tmp, xdir, y0p1, x0pxdir; + + /* + * Clip line and test if we have to draw + */ + if (!(clipLine(dst, &x1, &y1, &x2, &y2))) { + return (0); + } + + /* + * Keep on working with 32bit numbers + */ + xx0 = x1; + yy0 = y1; + xx1 = x2; + yy1 = y2; + + /* + * Reorder points if required + */ + if (yy0 > yy1) { + tmp = yy0; + yy0 = yy1; + yy1 = tmp; + tmp = xx0; + xx0 = xx1; + xx1 = tmp; + } + + /* + * Calculate distance + */ + dx = xx1 - xx0; + dy = yy1 - yy0; + + /* + * Adjust for negative dx and set xdir + */ + if (dx >= 0) { + xdir = 1; + } else { + xdir = -1; + dx = (-dx); + } + + /* + * Check for special cases + */ + if (dx == 0) { + /* + * Vertical line + */ + return (vlineColor(dst, x1, y1, y2, color)); + } else if (dy == 0) { + /* + * Horizontal line + */ + return (hlineColor(dst, x1, x2, y1, color)); + } else if (dx == dy) { + /* + * Diagonal line + */ + return (lineColor(dst, x1, y1, x2, y2, color)); + } + + /* + * Line is not horizontal, vertical or diagonal + */ + result = 0; + + /* + * Zero accumulator + */ + erracc = 0; + + /* + * # of bits by which to shift erracc to get intensity level + */ + intshift = 32 - AAbits; + /* + * Mask used to flip all bits in an intensity weighting + */ + wgtcompmask = AAlevels - 1; + + /* Lock surface */ + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + return (-1); + } + } + + /* + * Draw the initial pixel in the foreground color + */ + result |= pixelColorNolock(dst, x1, y1, color); + + /* + * x-major or y-major? + */ + if (dy > dx) { + + /* + * y-major. Calculate 16-bit fixed point fractional part of a pixel that + * X advances every time Y advances 1 pixel, truncating the result so that + * we won't overrun the endpoint along the X axis + */ + /* + * Not-so-portable version: erradj = ((Uint64)dx << 32) / (Uint64)dy; + */ + erradj = ((dx << 16) / dy) << 16; + + /* + * draw all pixels other than the first and last + */ + x0pxdir = xx0 + xdir; + while (--dy) { + erracctmp = erracc; + erracc += erradj; + if (erracc <= erracctmp) { + /* + * rollover in error accumulator, x coord advances + */ + xx0 = x0pxdir; + x0pxdir += xdir; + } + yy0++; /* y-major so always advance Y */ + + /* + * the AAbits most significant bits of erracc give us the intensity + * weighting for this pixel, and the complement of the weighting for + * the paired pixel. + */ + wgt = (erracc >> intshift) & 255; + result |= pixelColorWeightNolock (dst, xx0, yy0, color, 255 - wgt); + result |= pixelColorWeightNolock (dst, x0pxdir, yy0, color, wgt); + } + + } else { + + /* + * x-major line. Calculate 16-bit fixed-point fractional part of a pixel + * that Y advances each time X advances 1 pixel, truncating the result so + * that we won't overrun the endpoint along the X axis. + */ + /* + * Not-so-portable version: erradj = ((Uint64)dy << 32) / (Uint64)dx; + */ + erradj = ((dy << 16) / dx) << 16; + + /* + * draw all pixels other than the first and last + */ + y0p1 = yy0 + 1; + while (--dx) { + + erracctmp = erracc; + erracc += erradj; + if (erracc <= erracctmp) { + /* + * Accumulator turned over, advance y + */ + yy0 = y0p1; + y0p1++; + } + xx0 += xdir; /* x-major so always advance X */ + /* + * the AAbits most significant bits of erracc give us the intensity + * weighting for this pixel, and the complement of the weighting for + * the paired pixel. + */ + wgt = (erracc >> intshift) & 255; + result |= pixelColorWeightNolock (dst, xx0, yy0, color, 255 - wgt); + result |= pixelColorWeightNolock (dst, xx0, y0p1, color, wgt); + } + } + + /* + * Do we have to draw the endpoint + */ + if (draw_endpoint) { + /* + * Draw final pixel, always exactly intersected by the line and doesn't + * need to be weighted. + */ + result |= pixelColorNolock (dst, x2, y2, color); + } + + /* Unlock surface */ + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); + } + + return (result); +} + +int aalineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) +{ + return (aalineColorInt(dst, x1, y1, x2, y2, color, 1)); +} + +int aalineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + return (aalineColorInt + (dst, x1, y1, x2, y2, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a, 1)); +} + + +/* ----- Circle */ + +/* Note: Based on algorithm from sge library, modified by A. Schiffler */ + +/* with multiple pixel-draw removal and other minor speedup changes. */ + +int circleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color) +{ + int result; + Sint16 x1, y1, x2, y2; + Sint16 cx = 0; + Sint16 cy = r; + Sint16 ocx = (Sint16) 0xffff; + Sint16 ocy = (Sint16) 0xffff; + Sint16 df = 1 - r; + Sint16 d_e = 3; + Sint16 d_se = -2 * r + 5; + Sint16 xpcx, xmcx, xpcy, xmcy; + Sint16 ypcy, ymcy, ypcx, ymcx; + Uint8 *colorptr; + + /* + * Sanity check radius + */ + if (r < 0) { + return (-1); + } + + /* + * Special case for r=0 - draw a point + */ + if (r == 0) { + return (pixelColor(dst, x, y, color)); + } + + /* + * Test if bounding box of circle is visible + */ + x1 = x - r; + y1 = y - r; + x2 = x + r; + y2 = y + r; + if (!(clipLine(dst, &x1, &y1, &x2, &y2))) { + return (0); + } + + /* + * Draw circle + */ + result = 0; + + /* Lock surface */ + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + return (-1); + } + } + + /* + * Alpha Check + */ + if ((color & 255) == 255) { + + /* + * No Alpha - direct memory writes + */ + + /* + * Setup color + */ + colorptr = (Uint8 *) & color; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], colorptr[2], colorptr[3]); + } else { + color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], colorptr[1], colorptr[0]); + } + + /* + * Draw + */ + do { + if ((ocy != cy) || (ocx != cx)) { + xpcx = x + cx; + xmcx = x - cx; + if (cy > 0) { + ypcy = y + cy; + ymcy = y - cy; + result |= fastPixelColorNolock(dst, xmcx, ypcy, color); + result |= fastPixelColorNolock(dst, xpcx, ypcy, color); + result |= fastPixelColorNolock(dst, xmcx, ymcy, color); + result |= fastPixelColorNolock(dst, xpcx, ymcy, color); + } else { + result |= fastPixelColorNolock(dst, xmcx, y, color); + result |= fastPixelColorNolock(dst, xpcx, y, color); + } + ocy = cy; + xpcy = x + cy; + xmcy = x - cy; + if (cx > 0) { + ypcx = y + cx; + ymcx = y - cx; + result |= fastPixelColorNolock(dst, xmcy, ypcx, color); + result |= fastPixelColorNolock(dst, xpcy, ypcx, color); + result |= fastPixelColorNolock(dst, xmcy, ymcx, color); + result |= fastPixelColorNolock(dst, xpcy, ymcx, color); + } else { + result |= fastPixelColorNolock(dst, xmcy, y, color); + result |= fastPixelColorNolock(dst, xpcy, y, color); + } + ocx = cx; + } + /* + * Update + */ + if (df < 0) { + df += d_e; + d_e += 2; + d_se += 2; + } else { + df += d_se; + d_e += 2; + d_se += 4; + cy--; + } + cx++; + } while (cx <= cy); + + /* + * Unlock surface + */ + SDL_UnlockSurface(dst); + + } else { + + /* + * Using Alpha - blended pixel blits + */ + + do { + /* + * Draw + */ + if ((ocy != cy) || (ocx != cx)) { + xpcx = x + cx; + xmcx = x - cx; + if (cy > 0) { + ypcy = y + cy; + ymcy = y - cy; + result |= pixelColorNolock (dst, xmcx, ypcy, color); + result |= pixelColorNolock (dst, xpcx, ypcy, color); + result |= pixelColorNolock (dst, xmcx, ymcy, color); + result |= pixelColorNolock (dst, xpcx, ymcy, color); + } else { + result |= pixelColorNolock (dst, xmcx, y, color); + result |= pixelColorNolock (dst, xpcx, y, color); + } + ocy = cy; + xpcy = x + cy; + xmcy = x - cy; + if (cx > 0) { + ypcx = y + cx; + ymcx = y - cx; + result |= pixelColorNolock (dst, xmcy, ypcx, color); + result |= pixelColorNolock (dst, xpcy, ypcx, color); + result |= pixelColorNolock (dst, xmcy, ymcx, color); + result |= pixelColorNolock (dst, xpcy, ymcx, color); + } else { + result |= pixelColorNolock (dst, xmcy, y, color); + result |= pixelColorNolock (dst, xpcy, y, color); + } + ocx = cx; + } + /* + * Update + */ + if (df < 0) { + df += d_e; + d_e += 2; + d_se += 2; + } else { + df += d_se; + d_e += 2; + d_se += 4; + cy--; + } + cx++; + } while (cx <= cy); + + } /* Alpha check */ + + /* Unlock surface */ + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); + } + + return (result); +} + +int circleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (circleColor(dst, x, y, rad, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* ----- AA Circle */ + +/* AA circle is based on AAellipse */ + +int aacircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color) +{ + return (aaellipseColor(dst, x, y, r, r, color)); +} + +int aacircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (aaellipseColor + (dst, x, y, rad, rad, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* ----- Filled Circle */ + +/* Note: Based on algorithm from sge library with multiple-hline draw removal */ + +/* and other speedup changes. */ + +int filledCircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color) +{ + int result; + Sint16 x1, y1, x2, y2; + Sint16 cx = 0; + Sint16 cy = r; + Sint16 ocx = (Sint16) 0xffff; + Sint16 ocy = (Sint16) 0xffff; + Sint16 df = 1 - r; + Sint16 d_e = 3; + Sint16 d_se = -2 * r + 5; + Sint16 xpcx, xmcx, xpcy, xmcy; + Sint16 ypcy, ymcy, ypcx, ymcx; + + /* + * Sanity check radius + */ + if (r < 0) { + return (-1); + } + + /* + * Special case for r=0 - draw a point + */ + if (r == 0) { + return (pixelColor(dst, x, y, color)); + } + + /* + * Test bounding box + */ + x1 = x - r; + y1 = y - r; + x2 = x + r; + y2 = y + r; + if (!(clipLine(dst, &x1, &y1, &x2, &y2))) { + return (0); + } + + /* + * Draw + */ + result = 0; + do { + xpcx = x + cx; + xmcx = x - cx; + xpcy = x + cy; + xmcy = x - cy; + if (ocy != cy) { + if (cy > 0) { + ypcy = y + cy; + ymcy = y - cy; + result |= hlineColor(dst, xmcx, xpcx, ypcy, color); + result |= hlineColor(dst, xmcx, xpcx, ymcy, color); + } else { + result |= hlineColor(dst, xmcx, xpcx, y, color); + } + ocy = cy; + } + if (ocx != cx) { + if (cx != cy) { + if (cx > 0) { + ypcx = y + cx; + ymcx = y - cx; + result |= hlineColor(dst, xmcy, xpcy, ymcx, color); + result |= hlineColor(dst, xmcy, xpcy, ypcx, color); + } else { + result |= hlineColor(dst, xmcy, xpcy, y, color); + } + } + ocx = cx; + } + /* + * Update + */ + if (df < 0) { + df += d_e; + d_e += 2; + d_se += 2; + } else { + df += d_se; + d_e += 2; + d_se += 4; + cy--; + } + cx++; + } while (cx <= cy); + + return (result); +} + +int filledCircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (filledCircleColor + (dst, x, y, rad, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + + +/* ----- Ellipse */ + +/* Note: Based on algorithm from sge library with multiple-hline draw removal */ + +/* and other speedup changes. */ + +int ellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color) +{ + int result; + Sint16 x1, y1, x2, y2; + int ix, iy; + int h, i, j, k; + int oh, oi, oj, ok; + int xmh, xph, ypk, ymk; + int xmi, xpi, ymj, ypj; + int xmj, xpj, ymi, ypi; + int xmk, xpk, ymh, yph; + Uint8 *colorptr; + + /* + * Sanity check radii + */ + if ((rx < 0) || (ry < 0)) { + return (-1); + } + + /* + * Special case for rx=0 - draw a vline + */ + if (rx == 0) { + return (vlineColor(dst, x, y - ry, y + ry, color)); + } + /* + * Special case for ry=0 - draw a hline + */ + if (ry == 0) { + return (hlineColor(dst, x - rx, x + rx, y, color)); + } + + /* + * Test bounding box + */ + x1 = x - rx; + y1 = y - ry; + x2 = x + rx; + y2 = y + ry; + if (!(clipLine(dst, &x1, &y1, &x2, &y2))) { + return (0); + } + + /* + * Init vars + */ + oh = oi = oj = ok = 0xFFFF; + + /* + * Draw + */ + result = 0; + + /* Lock surface */ + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + return (-1); + } + } + + /* + * Check alpha + */ + if ((color & 255) == 255) { + + /* + * No Alpha - direct memory writes + */ + + /* + * Setup color + */ + colorptr = (Uint8 *) & color; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { + color = SDL_MapRGBA(dst->format, colorptr[0], colorptr[1], colorptr[2], colorptr[3]); + } else { + color = SDL_MapRGBA(dst->format, colorptr[3], colorptr[2], colorptr[1], colorptr[0]); + } + + + if (rx > ry) { + ix = 0; + iy = rx * 64; + + do { + h = (ix + 32) >> 6; + i = (iy + 32) >> 6; + j = (h * ry) / rx; + k = (i * ry) / rx; + + if (((ok != k) && (oj != k)) || ((oj != j) && (ok != j)) || (k != j)) { + xph = x + h; + xmh = x - h; + if (k > 0) { + ypk = y + k; + ymk = y - k; + result |= fastPixelColorNolock(dst, xmh, ypk, color); + result |= fastPixelColorNolock(dst, xph, ypk, color); + result |= fastPixelColorNolock(dst, xmh, ymk, color); + result |= fastPixelColorNolock(dst, xph, ymk, color); + } else { + result |= fastPixelColorNolock(dst, xmh, y, color); + result |= fastPixelColorNolock(dst, xph, y, color); + } + ok = k; + xpi = x + i; + xmi = x - i; + if (j > 0) { + ypj = y + j; + ymj = y - j; + result |= fastPixelColorNolock(dst, xmi, ypj, color); + result |= fastPixelColorNolock(dst, xpi, ypj, color); + result |= fastPixelColorNolock(dst, xmi, ymj, color); + result |= fastPixelColorNolock(dst, xpi, ymj, color); + } else { + result |= fastPixelColorNolock(dst, xmi, y, color); + result |= fastPixelColorNolock(dst, xpi, y, color); + } + oj = j; + } + + ix = ix + iy / rx; + iy = iy - ix / rx; + + } while (i > h); + } else { + ix = 0; + iy = ry * 64; + + do { + h = (ix + 32) >> 6; + i = (iy + 32) >> 6; + j = (h * rx) / ry; + k = (i * rx) / ry; + + if (((oi != i) && (oh != i)) || ((oh != h) && (oi != h) && (i != h))) { + xmj = x - j; + xpj = x + j; + if (i > 0) { + ypi = y + i; + ymi = y - i; + result |= fastPixelColorNolock(dst, xmj, ypi, color); + result |= fastPixelColorNolock(dst, xpj, ypi, color); + result |= fastPixelColorNolock(dst, xmj, ymi, color); + result |= fastPixelColorNolock(dst, xpj, ymi, color); + } else { + result |= fastPixelColorNolock(dst, xmj, y, color); + result |= fastPixelColorNolock(dst, xpj, y, color); + } + oi = i; + xmk = x - k; + xpk = x + k; + if (h > 0) { + yph = y + h; + ymh = y - h; + result |= fastPixelColorNolock(dst, xmk, yph, color); + result |= fastPixelColorNolock(dst, xpk, yph, color); + result |= fastPixelColorNolock(dst, xmk, ymh, color); + result |= fastPixelColorNolock(dst, xpk, ymh, color); + } else { + result |= fastPixelColorNolock(dst, xmk, y, color); + result |= fastPixelColorNolock(dst, xpk, y, color); + } + oh = h; + } + + ix = ix + iy / ry; + iy = iy - ix / ry; + + } while (i > h); + } + + } else { + + if (rx > ry) { + ix = 0; + iy = rx * 64; + + do { + h = (ix + 32) >> 6; + i = (iy + 32) >> 6; + j = (h * ry) / rx; + k = (i * ry) / rx; + + if (((ok != k) && (oj != k)) || ((oj != j) && (ok != j)) || (k != j)) { + xph = x + h; + xmh = x - h; + if (k > 0) { + ypk = y + k; + ymk = y - k; + result |= pixelColorNolock (dst, xmh, ypk, color); + result |= pixelColorNolock (dst, xph, ypk, color); + result |= pixelColorNolock (dst, xmh, ymk, color); + result |= pixelColorNolock (dst, xph, ymk, color); + } else { + result |= pixelColorNolock (dst, xmh, y, color); + result |= pixelColorNolock (dst, xph, y, color); + } + ok = k; + xpi = x + i; + xmi = x - i; + if (j > 0) { + ypj = y + j; + ymj = y - j; + result |= pixelColorNolock (dst, xmi, ypj, color); + result |= pixelColorNolock (dst, xpi, ypj, color); + result |= pixelColorNolock (dst, xmi, ymj, color); + result |= pixelColor(dst, xpi, ymj, color); + } else { + result |= pixelColorNolock (dst, xmi, y, color); + result |= pixelColorNolock (dst, xpi, y, color); + } + oj = j; + } + + ix = ix + iy / rx; + iy = iy - ix / rx; + + } while (i > h); + } else { + ix = 0; + iy = ry * 64; + + do { + h = (ix + 32) >> 6; + i = (iy + 32) >> 6; + j = (h * rx) / ry; + k = (i * rx) / ry; + + if (((oi != i) && (oh != i)) || ((oh != h) && (oi != h) && (i != h))) { + xmj = x - j; + xpj = x + j; + if (i > 0) { + ypi = y + i; + ymi = y - i; + result |= pixelColorNolock (dst, xmj, ypi, color); + result |= pixelColorNolock (dst, xpj, ypi, color); + result |= pixelColorNolock (dst, xmj, ymi, color); + result |= pixelColorNolock (dst, xpj, ymi, color); + } else { + result |= pixelColorNolock (dst, xmj, y, color); + result |= pixelColorNolock (dst, xpj, y, color); + } + oi = i; + xmk = x - k; + xpk = x + k; + if (h > 0) { + yph = y + h; + ymh = y - h; + result |= pixelColorNolock (dst, xmk, yph, color); + result |= pixelColorNolock (dst, xpk, yph, color); + result |= pixelColorNolock (dst, xmk, ymh, color); + result |= pixelColorNolock (dst, xpk, ymh, color); + } else { + result |= pixelColorNolock (dst, xmk, y, color); + result |= pixelColorNolock (dst, xpk, y, color); + } + oh = h; + } + + ix = ix + iy / ry; + iy = iy - ix / ry; + + } while (i > h); + } + + } /* Alpha check */ + + /* Unlock surface */ + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); + } + + return (result); +} + +int ellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (ellipseColor(dst, x, y, rx, ry, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* ----- AA Ellipse */ + +/* Based on code from Anders Lindstroem, based on code from SGE, based on code from TwinLib */ + +int aaellipseColor(SDL_Surface * dst, Sint16 xc, Sint16 yc, Sint16 rx, Sint16 ry, Uint32 color) +{ + int i; + int a2, b2, ds, dt, dxt, t, s, d; + Sint16 x, y, xs, ys, dyt, xx, yy, xc2, yc2; + float cp; + Uint8 weight, iweight; + int result; + + /* Sanity check radius */ + if (rx < 1) + rx = 1; + if (ry < 1) + ry = 1; + + /* Variable setup */ + a2 = rx * rx; + b2 = ry * ry; + + ds = 2 * a2; + dt = 2 * b2; + + xc2 = 2 * xc; + yc2 = 2 * yc; + + dxt = (int) (a2 / sqrt(a2 + b2)); + + t = 0; + s = -2 * a2 * ry; + d = 0; + + x = xc; + y = yc - ry; + + + /* Draw */ + result = 0; + + /* Lock surface */ + if (SDL_MUSTLOCK(dst)) { + if (SDL_LockSurface(dst) < 0) { + return (-1); + } + } + + /* "End points" */ + result |= pixelColorNolock(dst, x, y, color); + result |= pixelColorNolock(dst, xc2 - x, y, color); + result |= pixelColorNolock(dst, x, yc2 - y, color); + result |= pixelColorNolock(dst, xc2 - x, yc2 - y, color); + + for (i = 1; i <= dxt; i++) { + x--; + d += t - b2; + + if (d >= 0) + ys = y - 1; + else if ((d - s - a2) > 0) { + if ((2 * d - s - a2) >= 0) + ys = y + 1; + else { + ys = y; + y++; + d -= s + a2; + s += ds; + } + } else { + y++; + ys = y + 1; + d -= s + a2; + s += ds; + } + + t -= dt; + + /* Calculate alpha */ + if (s != 0.0) { + cp = (float) abs(d) / (float) abs(s); + if (cp > 1.0) { + cp = 1.0; + } + } else { + cp = 1.0; + } + + /* Calculate weights */ + weight = (Uint8) (cp * 255); + iweight = 255 - weight; + + /* Upper half */ + xx = xc2 - x; + result |= pixelColorWeightNolock(dst, x, y, color, iweight); + result |= pixelColorWeightNolock(dst, xx, y, color, iweight); + + result |= pixelColorWeightNolock(dst, x, ys, color, weight); + result |= pixelColorWeightNolock(dst, xx, ys, color, weight); + + /* Lower half */ + yy = yc2 - y; + result |= pixelColorWeightNolock(dst, x, yy, color, iweight); + result |= pixelColorWeightNolock(dst, xx, yy, color, iweight); + + yy = yc2 - ys; + result |= pixelColorWeightNolock(dst, x, yy, color, weight); + result |= pixelColorWeightNolock(dst, xx, yy, color, weight); + } + + dyt = abs(y - yc); + + for (i = 1; i <= dyt; i++) { + y++; + d -= s + a2; + + if (d <= 0) + xs = x + 1; + else if ((d + t - b2) < 0) { + if ((2 * d + t - b2) <= 0) + xs = x - 1; + else { + xs = x; + x--; + d += t - b2; + t -= dt; + } + } else { + x--; + xs = x - 1; + d += t - b2; + t -= dt; + } + + s += ds; + + /* Calculate alpha */ + if (t != 0.0) { + cp = (float) abs(d) / (float) abs(t); + if (cp > 1.0) { + cp = 1.0; + } + } else { + cp = 1.0; + } + + /* Calculate weight */ + weight = (Uint8) (cp * 255); + iweight = 255 - weight; + + /* Left half */ + xx = xc2 - x; + yy = yc2 - y; + result |= pixelColorWeightNolock(dst, x, y, color, iweight); + result |= pixelColorWeightNolock(dst, xx, y, color, iweight); + + result |= pixelColorWeightNolock(dst, x, yy, color, iweight); + result |= pixelColorWeightNolock(dst, xx, yy, color, iweight); + + /* Right half */ + xx = 2 * xc - xs; + result |= pixelColorWeightNolock(dst, xs, y, color, weight); + result |= pixelColorWeightNolock(dst, xx, y, color, weight); + + result |= pixelColorWeightNolock(dst, xs, yy, color, weight); + result |= pixelColorWeightNolock(dst, xx, yy, color, weight); + + + } + + /* Unlock surface */ + if (SDL_MUSTLOCK(dst)) { + SDL_UnlockSurface(dst); + } + + return (result); +} + +int aaellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (aaellipseColor + (dst, x, y, rx, ry, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* ---- Filled Ellipse */ + +/* Note: */ +/* Based on algorithm from sge library with multiple-hline draw removal */ +/* and other speedup changes. */ + +int filledEllipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color) +{ + int result; + Sint16 x1, y1, x2, y2; + int ix, iy; + int h, i, j, k; + int oh, oi, oj, ok; + int xmh, xph; + int xmi, xpi; + int xmj, xpj; + int xmk, xpk; + + /* + * Sanity check radii + */ + if ((rx < 0) || (ry < 0)) { + return (-1); + } + + /* + * Special case for rx=0 - draw a vline + */ + if (rx == 0) { + return (vlineColor(dst, x, y - ry, y + ry, color)); + } + /* + * Special case for ry=0 - draw a hline + */ + if (ry == 0) { + return (hlineColor(dst, x - rx, x + rx, y, color)); + } + + /* + * Test bounding box + */ + x1 = x - rx; + y1 = y - ry; + x2 = x + rx; + y2 = y + ry; + if (!(clipLine(dst, &x1, &y1, &x2, &y2))) { + return (0); + } + + /* + * Init vars + */ + oh = oi = oj = ok = 0xFFFF; + + /* + * Draw + */ + result = 0; + if (rx > ry) { + ix = 0; + iy = rx * 64; + + do { + h = (ix + 32) >> 6; + i = (iy + 32) >> 6; + j = (h * ry) / rx; + k = (i * ry) / rx; + + if ((ok != k) && (oj != k)) { + xph = x + h; + xmh = x - h; + if (k > 0) { + result |= hlineColor(dst, xmh, xph, y + k, color); + result |= hlineColor(dst, xmh, xph, y - k, color); + } else { + result |= hlineColor(dst, xmh, xph, y, color); + } + ok = k; + } + if ((oj != j) && (ok != j) && (k != j)) { + xmi = x - i; + xpi = x + i; + if (j > 0) { + result |= hlineColor(dst, xmi, xpi, y + j, color); + result |= hlineColor(dst, xmi, xpi, y - j, color); + } else { + result |= hlineColor(dst, xmi, xpi, y, color); + } + oj = j; + } + + ix = ix + iy / rx; + iy = iy - ix / rx; + + } while (i > h); + } else { + ix = 0; + iy = ry * 64; + + do { + h = (ix + 32) >> 6; + i = (iy + 32) >> 6; + j = (h * rx) / ry; + k = (i * rx) / ry; + + if ((oi != i) && (oh != i)) { + xmj = x - j; + xpj = x + j; + if (i > 0) { + result |= hlineColor(dst, xmj, xpj, y + i, color); + result |= hlineColor(dst, xmj, xpj, y - i, color); + } else { + result |= hlineColor(dst, xmj, xpj, y, color); + } + oi = i; + } + if ((oh != h) && (oi != h) && (i != h)) { + xmk = x - k; + xpk = x + k; + if (h > 0) { + result |= hlineColor(dst, xmk, xpk, y + h, color); + result |= hlineColor(dst, xmk, xpk, y - h, color); + } else { + result |= hlineColor(dst, xmk, xpk, y, color); + } + oh = h; + } + + ix = ix + iy / ry; + iy = iy - ix / ry; + + } while (i > h); + } + + return (result); +} + + +int filledEllipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (filledEllipseColor + (dst, x, y, rx, ry, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* ----- filled pie */ + +/* Low-speed float pie-calc implementation by drawing polygons. */ + +int filledpieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color) +{ + int result; + Sint16 x1, y1, x2, y2; + double angle, start_angle, end_angle; + double deltaAngle; + double dr; + int posX, posY; + int numpoints, i; + Sint16 *vx, *vy; + + /* + * Sanity check radii + */ + if (rad < 0) { + return (-1); + } + + /* + * Fixup angles + */ + start = start % 360; + end = end % 360; + + /* + * Special case for rad=0 - draw a point + */ + if (rad == 0) { + return (pixelColor(dst, x, y, color)); + } + + /* + * Test bounding box for visibility + */ + x1 = x - rad; + y1 = y - rad; + x2 = x + rad; + y2 = y + rad; + if (!(clipLine(dst, &x1, &y1, &x2, &y2))) { + return (0); + } + + /* + * Variable setup + */ + dr = (double) rad; + deltaAngle = 3.0 / dr; + start_angle = (double) start *(2.0 * M_PI / 360.0); + end_angle = (double) end *(2.0 * M_PI / 360.0); + if (start > end) { + end_angle += (2.0 * M_PI); + } + + /* Count points (rather than calculate it) */ + numpoints = 1; + angle = start_angle; + while (angle <= end_angle) { + angle += deltaAngle; + numpoints++; + } + + /* Check size of array */ + if (numpoints == 1) { + return (pixelColor(dst, x, y, color)); + } else if (numpoints == 2) { + posX = x + (int) (dr * cos(start_angle)); + posY = y + (int) (dr * sin(start_angle)); + return (lineColor(dst, x, y, posX, posY, color)); + } + + /* Allocate vertex array */ + vx = vy = (Uint16 *) malloc(2 * sizeof(Uint16) * numpoints); + if (vx == NULL) { + return (-1); + } + vy += numpoints; + + /* Center */ + vx[0] = x; + vy[0] = y; + + /* Calculate and store vertices */ + i = 1; + angle = start_angle; + while (angle <= end_angle) { + vx[i] = x + (int) (dr * cos(angle)); + vy[i] = y + (int) (dr * sin(angle)); + angle += deltaAngle; + i++; + } + + /* Draw */ + result = filledPolygonColor(dst, vx, vy, numpoints, color); + + /* Free vertex */ + free(vx); + + return (result); +} + +int filledpieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, + Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + return (filledpieColor(dst, x, y, rad, start, end, + ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); + +} + +/* ---- Polygon */ + +int polygonColor(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, int n, Uint32 color) +{ + int result; + int i; + Sint16 *x1, *y1, *x2, *y2; + + /* + * Sanity check + */ + if (n < 3) { + return (-1); + } + + /* + * Pointer setup + */ + x1 = x2 = vx; + y1 = y2 = vy; + x2++; + y2++; + + /* + * Draw + */ + result = 0; + for (i = 1; i < n; i++) { + result |= lineColor(dst, *x1, *y1, *x2, *y2, color); + x1 = x2; + y1 = y2; + x2++; + y2++; + } + result |= lineColor(dst, *x1, *y1, *vx, *vy, color); + + return (result); +} + +int polygonRGBA(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (polygonColor(dst, vx, vy, n, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* ---- AA-Polygon */ + +int aapolygonColor(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, int n, Uint32 color) +{ + int result; + int i; + Sint16 *x1, *y1, *x2, *y2; + + /* + * Sanity check + */ + if (n < 3) { + return (-1); + } + + /* + * Pointer setup + */ + x1 = x2 = vx; + y1 = y2 = vy; + x2++; + y2++; + + /* + * Draw + */ + result = 0; + for (i = 1; i < n; i++) { + result |= aalineColorInt(dst, *x1, *y1, *x2, *y2, color, 0); + x1 = x2; + y1 = y2; + x2++; + y2++; + } + result |= aalineColorInt(dst, *x1, *y1, *vx, *vy, color, 0); + + return (result); +} + +int aapolygonRGBA(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (aapolygonColor(dst, vx, vy, n, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +/* ---- Filled Polygon */ + +int gfxPrimitivesCompareInt(const void *a, const void *b); + +static int *gfxPrimitivesPolyInts = NULL; +static int gfxPrimitivesPolyAllocated = 0; + +int filledPolygonColor(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, int n, int color) +{ + int result; + int i; + int y; + int miny, maxy; + int x1, y1; + int x2, y2; + int ind1, ind2; + int ints; + + /* + * Sanity check + */ + if (n < 3) { + return -1; + } + + /* + * Allocate temp array, only grow array + */ + if (!gfxPrimitivesPolyAllocated) { + gfxPrimitivesPolyInts = (int *) malloc(sizeof(int) * n); + gfxPrimitivesPolyAllocated = n; + } else { + if (gfxPrimitivesPolyAllocated < n) { + gfxPrimitivesPolyInts = (int *) realloc(gfxPrimitivesPolyInts, sizeof(int) * n); + gfxPrimitivesPolyAllocated = n; + } + } + + /* + * Determine Y maxima + */ + miny = vy[0]; + maxy = vy[0]; + for (i = 1; (i < n); i++) { + if (vy[i] < miny) { + miny = vy[i]; + } else if (vy[i] > maxy) { + maxy = vy[i]; + } + } + + /* + * Draw, scanning y + */ + result = 0; + for (y = miny; (y <= maxy); y++) { + ints = 0; + for (i = 0; (i < n); i++) { + if (!i) { + ind1 = n - 1; + ind2 = 0; + } else { + ind1 = i - 1; + ind2 = i; + } + y1 = vy[ind1]; + y2 = vy[ind2]; + if (y1 < y2) { + x1 = vx[ind1]; + x2 = vx[ind2]; + } else if (y1 > y2) { + y2 = vy[ind1]; + y1 = vy[ind2]; + x2 = vx[ind1]; + x1 = vx[ind2]; + } else { + continue; + } + if ((y >= y1) && (y < y2)) { + gfxPrimitivesPolyInts[ints++] = (y - y1) * (x2 - x1) / (y2 - y1) + x1; + } else if ((y == maxy) && (y > y1) && (y <= y2)) { + gfxPrimitivesPolyInts[ints++] = (y - y1) * (x2 - x1) / (y2 - y1) + x1; + } + } + qsort(gfxPrimitivesPolyInts, ints, sizeof(int), gfxPrimitivesCompareInt); + + for (i = 0; (i < ints); i += 2) { + result |= hlineColor(dst, gfxPrimitivesPolyInts[i], gfxPrimitivesPolyInts[i + 1], y, color); + } + } + + return (result); +} + +int filledPolygonRGBA(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (filledPolygonColor + (dst, vx, vy, n, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +int gfxPrimitivesCompareInt(const void *a, const void *b) +{ + return (*(const int *) a) - (*(const int *) b); +} + +/* ---- Character (8x8 internal font) */ + +static SDL_Surface *gfxPrimitivesFont[256]; +static Uint32 gfxPrimitivesFontColor[256]; + +int characterColor(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint32 color) +{ + SDL_Rect srect; + SDL_Rect drect; + int result; + int ix, iy, k; + unsigned char *charpos; + unsigned char bits[8] = { 128, 64, 32, 16, 8, 4, 2, 1 }; + unsigned char *bitpos; + Uint8 *curpos; + int forced_redraw; + + /* + * Setup source rectangle for 8x8 bitmap + */ + srect.x = 0; + srect.y = 0; + srect.w = 8; + srect.h = 8; + + /* + * Setup destination rectangle for 8x8 bitmap + */ + drect.x = x; + drect.y = y; + drect.w = 8; + drect.h = 8; + + /* + * Create new 8x8 bitmap surface if not already present + */ + if (gfxPrimitivesFont[(unsigned char) c] == NULL) { + gfxPrimitivesFont[(unsigned char) c] = + SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_HWSURFACE | SDL_SRCALPHA, 8, 8, + 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); + /* + * Check pointer + */ + if (gfxPrimitivesFont[(unsigned char) c] == NULL) { + return (-1); + } + /* + * Definitely redraw + */ + forced_redraw = 1; + } else { + forced_redraw = 0; + } + + /* + * Check if color has changed + */ + if ((gfxPrimitivesFontColor[(unsigned char) c] != color) || (forced_redraw)) { + /* + * Redraw character + */ + SDL_SetAlpha(gfxPrimitivesFont[(unsigned char) c], SDL_SRCALPHA, 255); + gfxPrimitivesFontColor[(unsigned char) c] = color; + + /* + * Variable setup + */ + k = (unsigned char) c; + k *= 8; + charpos = gfxPrimitivesFontdata; + charpos += k; + + /* + * Clear bitmap + */ + curpos = (Uint8 *) gfxPrimitivesFont[(unsigned char) c]->pixels; + memset(curpos, 0, 8 * 8 * 4); + + /* + * Drawing loop + */ + for (iy = 0; iy < 8; iy++) { + bitpos = bits; + for (ix = 0; ix < 8; ix++) { + if ((*charpos & *bitpos) == *bitpos) { + memcpy(curpos, &color, 4); + } + bitpos++; + curpos += 4;; + } + charpos++; + } + } + + /* + * Draw bitmap onto destination surface + */ + result = SDL_BlitSurface(gfxPrimitivesFont[(unsigned char) c], &srect, dst, &drect); + + return (result); +} + +int characterRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (characterColor(dst, x, y, c, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} + +int stringColor(SDL_Surface * dst, Sint16 x, Sint16 y, char *c, Uint32 color) +{ + int result; + int i, length; + char *curchar; + int curx; + + length = strlen(c); + curchar = c; + curx = x; + result = 0; + for (i = 0; i < length; i++) { + result |= characterColor(dst, curx, y, *curchar, color); + curchar++; + curx += 8; + } + + return (result); +} + +int stringRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, char *c, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + /* + * Draw + */ + return (stringColor(dst, x, y, c, ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a)); +} diff --git a/src/sdl/sdl_gfxprimitives.h b/src/sdl/sdl_gfxprimitives.h new file mode 100644 index 0000000..682db92 --- /dev/null +++ b/src/sdl/sdl_gfxprimitives.h @@ -0,0 +1,155 @@ + +/* + + SDL_gfxPrimitives: graphics primitives for SDL + + LGPL (c) A. Schiffler + +*/ + +#ifndef _SDL_gfxPrimitives_h +#define _SDL_gfxPrimitives_h + +#include +#ifndef M_PI +#define M_PI 3.141592654 +#endif + +#include "SDL.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* ----- Versioning */ + +#define SDL_GFXPRIMITIVES_MAJOR 1 +#define SDL_GFXPRIMITIVES_MINOR 5 + +/* ----- W32 DLL interface */ + +#ifdef WIN32 +#ifdef BUILD_DLL +#define DLLINTERFACE __declspec(dllexport) +#else +#define DLLINTERFACE __declspec(dllimport) +#endif +#else +#define DLLINTERFACE +#endif + +/* ----- Prototypes */ + +/* Note: all ___Color routines expect the color to be in format 0xRRGGBBAA */ + +/* Pixel */ + + DLLINTERFACE int pixelColor(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color); + DLLINTERFACE int pixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* Horizontal line */ + + DLLINTERFACE int hlineColor(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color); + DLLINTERFACE int hlineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* Vertical line */ + + DLLINTERFACE int vlineColor(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color); + DLLINTERFACE int vlineRGBA(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* Rectangle */ + + DLLINTERFACE int rectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); + DLLINTERFACE int rectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, + Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* Filled rectangle (Box) */ + + DLLINTERFACE int boxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); + DLLINTERFACE int boxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, + Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* Line */ + + DLLINTERFACE int lineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); + DLLINTERFACE int lineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, + Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* AA Line */ + DLLINTERFACE int aalineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); + DLLINTERFACE int aalineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, + Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* Circle */ + + DLLINTERFACE int circleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color); + DLLINTERFACE int circleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* AA Circle */ + + DLLINTERFACE int aacircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color); + DLLINTERFACE int aacircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, + Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* Filled Circle */ + + DLLINTERFACE int filledCircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color); + DLLINTERFACE int filledCircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, + Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* Ellipse */ + + DLLINTERFACE int ellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color); + DLLINTERFACE int ellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, + Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* AA Ellipse */ + + DLLINTERFACE int aaellipseColor(SDL_Surface * dst, Sint16 xc, Sint16 yc, Sint16 rx, Sint16 ry, Uint32 color); + DLLINTERFACE int aaellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, + Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* Filled Ellipse */ + + DLLINTERFACE int filledEllipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color); + DLLINTERFACE int filledEllipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, + Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +/* Filled Pie */ + + DLLINTERFACE int filledpieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, + Sint16 start, Sint16 end, Uint32 color); + DLLINTERFACE int filledpieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, + Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* Polygon */ + + DLLINTERFACE int polygonColor(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, int n, Uint32 color); + DLLINTERFACE int polygonRGBA(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, + int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* AA-Polygon */ + + DLLINTERFACE int aapolygonColor(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, int n, Uint32 color); + DLLINTERFACE int aapolygonRGBA(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, + int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* Filled Polygon */ + + DLLINTERFACE int filledPolygonColor(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, int n, int color); + DLLINTERFACE int filledPolygonRGBA(SDL_Surface * dst, Sint16 * vx, + Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* 8x8 Characters/Strings */ + + DLLINTERFACE int characterColor(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint32 color); + DLLINTERFACE int characterRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + DLLINTERFACE int stringColor(SDL_Surface * dst, Sint16 x, Sint16 y, char *c, Uint32 color); + DLLINTERFACE int stringRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, char *c, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +}; +#endif + +#endif /* _SDL_gfxPrimitives_h */ diff --git a/src/sdl/sdl_gfxprimitives_font.h b/src/sdl/sdl_gfxprimitives_font.h new file mode 100644 index 0000000..9dde032 --- /dev/null +++ b/src/sdl/sdl_gfxprimitives_font.h @@ -0,0 +1,3082 @@ + +/* ---- 8x8 font definition ---- */ + +/* LGPL (c) A. Schiffler */ + +#define GFX_FONTDATAMAX (8*256) + +static unsigned char gfxPrimitivesFontdata[GFX_FONTDATAMAX] = { + + /* + * 0 0x00 '^@' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 1 0x01 '^A' + */ + 0x7e, /* 01111110 */ + 0x81, /* 10000001 */ + 0xa5, /* 10100101 */ + 0x81, /* 10000001 */ + 0xbd, /* 10111101 */ + 0x99, /* 10011001 */ + 0x81, /* 10000001 */ + 0x7e, /* 01111110 */ + + /* + * 2 0x02 '^B' + */ + 0x7e, /* 01111110 */ + 0xff, /* 11111111 */ + 0xdb, /* 11011011 */ + 0xff, /* 11111111 */ + 0xc3, /* 11000011 */ + 0xe7, /* 11100111 */ + 0xff, /* 11111111 */ + 0x7e, /* 01111110 */ + + /* + * 3 0x03 '^C' + */ + 0x6c, /* 01101100 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0x7c, /* 01111100 */ + 0x38, /* 00111000 */ + 0x10, /* 00010000 */ + 0x00, /* 00000000 */ + + /* + * 4 0x04 '^D' + */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + 0x7c, /* 01111100 */ + 0xfe, /* 11111110 */ + 0x7c, /* 01111100 */ + 0x38, /* 00111000 */ + 0x10, /* 00010000 */ + 0x00, /* 00000000 */ + + /* + * 5 0x05 '^E' + */ + 0x38, /* 00111000 */ + 0x7c, /* 01111100 */ + 0x38, /* 00111000 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0xd6, /* 11010110 */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + + /* + * 6 0x06 '^F' + */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + 0x7c, /* 01111100 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0x7c, /* 01111100 */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + + /* + * 7 0x07 '^G' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 8 0x08 '^H' + */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xe7, /* 11100111 */ + 0xc3, /* 11000011 */ + 0xc3, /* 11000011 */ + 0xe7, /* 11100111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + + /* + * 9 0x09 '^I' + */ + 0x00, /* 00000000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x42, /* 01000010 */ + 0x42, /* 01000010 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 10 0x0a '^J' + */ + 0xff, /* 11111111 */ + 0xc3, /* 11000011 */ + 0x99, /* 10011001 */ + 0xbd, /* 10111101 */ + 0xbd, /* 10111101 */ + 0x99, /* 10011001 */ + 0xc3, /* 11000011 */ + 0xff, /* 11111111 */ + + /* + * 11 0x0b '^K' + */ + 0x0f, /* 00001111 */ + 0x07, /* 00000111 */ + 0x0f, /* 00001111 */ + 0x7d, /* 01111101 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x78, /* 01111000 */ + + /* + * 12 0x0c '^L' + */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + + /* + * 13 0x0d '^M' + */ + 0x3f, /* 00111111 */ + 0x33, /* 00110011 */ + 0x3f, /* 00111111 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x70, /* 01110000 */ + 0xf0, /* 11110000 */ + 0xe0, /* 11100000 */ + + /* + * 14 0x0e '^N' + */ + 0x7f, /* 01111111 */ + 0x63, /* 01100011 */ + 0x7f, /* 01111111 */ + 0x63, /* 01100011 */ + 0x63, /* 01100011 */ + 0x67, /* 01100111 */ + 0xe6, /* 11100110 */ + 0xc0, /* 11000000 */ + + /* + * 15 0x0f '^O' + */ + 0x18, /* 00011000 */ + 0xdb, /* 11011011 */ + 0x3c, /* 00111100 */ + 0xe7, /* 11100111 */ + 0xe7, /* 11100111 */ + 0x3c, /* 00111100 */ + 0xdb, /* 11011011 */ + 0x18, /* 00011000 */ + + /* + * 16 0x10 '^P' + */ + 0x80, /* 10000000 */ + 0xe0, /* 11100000 */ + 0xf8, /* 11111000 */ + 0xfe, /* 11111110 */ + 0xf8, /* 11111000 */ + 0xe0, /* 11100000 */ + 0x80, /* 10000000 */ + 0x00, /* 00000000 */ + + /* + * 17 0x11 '^Q' + */ + 0x02, /* 00000010 */ + 0x0e, /* 00001110 */ + 0x3e, /* 00111110 */ + 0xfe, /* 11111110 */ + 0x3e, /* 00111110 */ + 0x0e, /* 00001110 */ + 0x02, /* 00000010 */ + 0x00, /* 00000000 */ + + /* + * 18 0x12 '^R' + */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + + /* + * 19 0x13 '^S' + */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + + /* + * 20 0x14 '^T' + */ + 0x7f, /* 01111111 */ + 0xdb, /* 11011011 */ + 0xdb, /* 11011011 */ + 0x7b, /* 01111011 */ + 0x1b, /* 00011011 */ + 0x1b, /* 00011011 */ + 0x1b, /* 00011011 */ + 0x00, /* 00000000 */ + + /* + * 21 0x15 '^U' + */ + 0x3e, /* 00111110 */ + 0x61, /* 01100001 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x86, /* 10000110 */ + 0x7c, /* 01111100 */ + + /* + * 22 0x16 '^V' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x7e, /* 01111110 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 23 0x17 '^W' + */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + + /* + * 24 0x18 '^X' + */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 25 0x19 '^Y' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 26 0x1a '^Z' + */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0xfe, /* 11111110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 27 0x1b '^[' + */ + 0x00, /* 00000000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0xfe, /* 11111110 */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 28 0x1c '^\' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 29 0x1d '^]' + */ + 0x00, /* 00000000 */ + 0x24, /* 00100100 */ + 0x66, /* 01100110 */ + 0xff, /* 11111111 */ + 0x66, /* 01100110 */ + 0x24, /* 00100100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 30 0x1e '^^' + */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 31 0x1f '^_' + */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0x7e, /* 01111110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 32 0x20 ' ' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 33 0x21 '!' + */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 34 0x22 '"' + */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x24, /* 00100100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 35 0x23 '#' + */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x00, /* 00000000 */ + + /* + * 36 0x24 '$' + */ + 0x18, /* 00011000 */ + 0x3e, /* 00111110 */ + 0x60, /* 01100000 */ + 0x3c, /* 00111100 */ + 0x06, /* 00000110 */ + 0x7c, /* 01111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 37 0x25 '%' + */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xcc, /* 11001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x66, /* 01100110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 38 0x26 '&' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 39 0x27 ''' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 40 0x28 '(' + */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x00, /* 00000000 */ + + /* + * 41 0x29 ')' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + + /* + * 42 0x2a '*' + */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0xff, /* 11111111 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 43 0x2b '+' + */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 44 0x2c ',' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + + /* + * 45 0x2d '-' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 46 0x2e '.' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 47 0x2f '/' + */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0xc0, /* 11000000 */ + 0x80, /* 10000000 */ + 0x00, /* 00000000 */ + + /* + * 48 0x30 '0' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xd6, /* 11010110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* + * 49 0x31 '1' + */ + 0x18, /* 00011000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 50 0x32 '2' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0x06, /* 00000110 */ + 0x1c, /* 00011100 */ + 0x30, /* 00110000 */ + 0x66, /* 01100110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 51 0x33 '3' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0x06, /* 00000110 */ + 0x3c, /* 00111100 */ + 0x06, /* 00000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 52 0x34 '4' + */ + 0x1c, /* 00011100 */ + 0x3c, /* 00111100 */ + 0x6c, /* 01101100 */ + 0xcc, /* 11001100 */ + 0xfe, /* 11111110 */ + 0x0c, /* 00001100 */ + 0x1e, /* 00011110 */ + 0x00, /* 00000000 */ + + /* + * 53 0x35 '5' + */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xfc, /* 11111100 */ + 0x06, /* 00000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 54 0x36 '6' + */ + 0x38, /* 00111000 */ + 0x60, /* 01100000 */ + 0xc0, /* 11000000 */ + 0xfc, /* 11111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 55 0x37 '7' + */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + + /* + * 56 0x38 '8' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 57 0x39 '9' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7e, /* 01111110 */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x78, /* 01111000 */ + 0x00, /* 00000000 */ + + /* + * 58 0x3a ':' + */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 59 0x3b ';' + */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + + /* + * 60 0x3c '<' + */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x06, /* 00000110 */ + 0x00, /* 00000000 */ + + /* + * 61 0x3d '=' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 62 0x3e '>' + */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0x00, /* 00000000 */ + + /* + * 63 0x3f '?' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 64 0x40 '@' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xde, /* 11011110 */ + 0xde, /* 11011110 */ + 0xde, /* 11011110 */ + 0xc0, /* 11000000 */ + 0x78, /* 01111000 */ + 0x00, /* 00000000 */ + + /* + * 65 0x41 'A' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 66 0x42 'B' + */ + 0xfc, /* 11111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x7c, /* 01111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0xfc, /* 11111100 */ + 0x00, /* 00000000 */ + + /* + * 67 0x43 'C' + */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 68 0x44 'D' + */ + 0xf8, /* 11111000 */ + 0x6c, /* 01101100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x6c, /* 01101100 */ + 0xf8, /* 11111000 */ + 0x00, /* 00000000 */ + + /* + * 69 0x45 'E' + */ + 0xfe, /* 11111110 */ + 0x62, /* 01100010 */ + 0x68, /* 01101000 */ + 0x78, /* 01111000 */ + 0x68, /* 01101000 */ + 0x62, /* 01100010 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 70 0x46 'F' + */ + 0xfe, /* 11111110 */ + 0x62, /* 01100010 */ + 0x68, /* 01101000 */ + 0x78, /* 01111000 */ + 0x68, /* 01101000 */ + 0x60, /* 01100000 */ + 0xf0, /* 11110000 */ + 0x00, /* 00000000 */ + + /* + * 71 0x47 'G' + */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xce, /* 11001110 */ + 0x66, /* 01100110 */ + 0x3a, /* 00111010 */ + 0x00, /* 00000000 */ + + /* + * 72 0x48 'H' + */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 73 0x49 'I' + */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 74 0x4a 'J' + */ + 0x1e, /* 00011110 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x78, /* 01111000 */ + 0x00, /* 00000000 */ + + /* + * 75 0x4b 'K' + */ + 0xe6, /* 11100110 */ + 0x66, /* 01100110 */ + 0x6c, /* 01101100 */ + 0x78, /* 01111000 */ + 0x6c, /* 01101100 */ + 0x66, /* 01100110 */ + 0xe6, /* 11100110 */ + 0x00, /* 00000000 */ + + /* + * 76 0x4c 'L' + */ + 0xf0, /* 11110000 */ + 0x60, /* 01100000 */ + 0x60, /* 01100000 */ + 0x60, /* 01100000 */ + 0x62, /* 01100010 */ + 0x66, /* 01100110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 77 0x4d 'M' + */ + 0xc6, /* 11000110 */ + 0xee, /* 11101110 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0xd6, /* 11010110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 78 0x4e 'N' + */ + 0xc6, /* 11000110 */ + 0xe6, /* 11100110 */ + 0xf6, /* 11110110 */ + 0xde, /* 11011110 */ + 0xce, /* 11001110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 79 0x4f 'O' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 80 0x50 'P' + */ + 0xfc, /* 11111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x7c, /* 01111100 */ + 0x60, /* 01100000 */ + 0x60, /* 01100000 */ + 0xf0, /* 11110000 */ + 0x00, /* 00000000 */ + + /* + * 81 0x51 'Q' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xce, /* 11001110 */ + 0x7c, /* 01111100 */ + 0x0e, /* 00001110 */ + + /* + * 82 0x52 'R' + */ + 0xfc, /* 11111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x7c, /* 01111100 */ + 0x6c, /* 01101100 */ + 0x66, /* 01100110 */ + 0xe6, /* 11100110 */ + 0x00, /* 00000000 */ + + /* + * 83 0x53 'S' + */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 84 0x54 'T' + */ + 0x7e, /* 01111110 */ + 0x7e, /* 01111110 */ + 0x5a, /* 01011010 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 85 0x55 'U' + */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 86 0x56 'V' + */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* + * 87 0x57 'W' + */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xd6, /* 11010110 */ + 0xd6, /* 11010110 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0x00, /* 00000000 */ + + /* + * 88 0x58 'X' + */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 89 0x59 'Y' + */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 90 0x5a 'Z' + */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0x8c, /* 10001100 */ + 0x18, /* 00011000 */ + 0x32, /* 00110010 */ + 0x66, /* 01100110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 91 0x5b '[' + */ + 0x3c, /* 00111100 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 92 0x5c '\' + */ + 0xc0, /* 11000000 */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x06, /* 00000110 */ + 0x02, /* 00000010 */ + 0x00, /* 00000000 */ + + /* + * 93 0x5d ']' + */ + 0x3c, /* 00111100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 94 0x5e '^' + */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 95 0x5f '_' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + + /* + * 96 0x60 '`' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 97 0x61 'a' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 98 0x62 'b' + */ + 0xe0, /* 11100000 */ + 0x60, /* 01100000 */ + 0x7c, /* 01111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + + /* + * 99 0x63 'c' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc0, /* 11000000 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 100 0x64 'd' + */ + 0x1c, /* 00011100 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 101 0x65 'e' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 102 0x66 'f' + */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x60, /* 01100000 */ + 0xf8, /* 11111000 */ + 0x60, /* 01100000 */ + 0x60, /* 01100000 */ + 0xf0, /* 11110000 */ + 0x00, /* 00000000 */ + + /* + * 103 0x67 'g' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x7c, /* 01111100 */ + 0x0c, /* 00001100 */ + 0xf8, /* 11111000 */ + + /* + * 104 0x68 'h' + */ + 0xe0, /* 11100000 */ + 0x60, /* 01100000 */ + 0x6c, /* 01101100 */ + 0x76, /* 01110110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0xe6, /* 11100110 */ + 0x00, /* 00000000 */ + + /* + * 105 0x69 'i' + */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 106 0x6a 'j' + */ + 0x06, /* 00000110 */ + 0x00, /* 00000000 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + + /* + * 107 0x6b 'k' + */ + 0xe0, /* 11100000 */ + 0x60, /* 01100000 */ + 0x66, /* 01100110 */ + 0x6c, /* 01101100 */ + 0x78, /* 01111000 */ + 0x6c, /* 01101100 */ + 0xe6, /* 11100110 */ + 0x00, /* 00000000 */ + + /* + * 108 0x6c 'l' + */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 109 0x6d 'm' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xec, /* 11101100 */ + 0xfe, /* 11111110 */ + 0xd6, /* 11010110 */ + 0xd6, /* 11010110 */ + 0xd6, /* 11010110 */ + 0x00, /* 00000000 */ + + /* + * 110 0x6e 'n' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xdc, /* 11011100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + + /* + * 111 0x6f 'o' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 112 0x70 'p' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xdc, /* 11011100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x7c, /* 01111100 */ + 0x60, /* 01100000 */ + 0xf0, /* 11110000 */ + + /* + * 113 0x71 'q' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x7c, /* 01111100 */ + 0x0c, /* 00001100 */ + 0x1e, /* 00011110 */ + + /* + * 114 0x72 'r' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xdc, /* 11011100 */ + 0x76, /* 01110110 */ + 0x60, /* 01100000 */ + 0x60, /* 01100000 */ + 0xf0, /* 11110000 */ + 0x00, /* 00000000 */ + + /* + * 115 0x73 's' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x06, /* 00000110 */ + 0xfc, /* 11111100 */ + 0x00, /* 00000000 */ + + /* + * 116 0x74 't' + */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0xfc, /* 11111100 */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x36, /* 00110110 */ + 0x1c, /* 00011100 */ + 0x00, /* 00000000 */ + + /* + * 117 0x75 'u' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 118 0x76 'v' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* + * 119 0x77 'w' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xd6, /* 11010110 */ + 0xd6, /* 11010110 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0x00, /* 00000000 */ + + /* + * 120 0x78 'x' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 121 0x79 'y' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7e, /* 01111110 */ + 0x06, /* 00000110 */ + 0xfc, /* 11111100 */ + + /* + * 122 0x7a 'z' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x4c, /* 01001100 */ + 0x18, /* 00011000 */ + 0x32, /* 00110010 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 123 0x7b '{' + */ + 0x0e, /* 00001110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x70, /* 01110000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x0e, /* 00001110 */ + 0x00, /* 00000000 */ + + /* + * 124 0x7c '|' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 125 0x7d '}' + */ + 0x70, /* 01110000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x0e, /* 00001110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x70, /* 01110000 */ + 0x00, /* 00000000 */ + + /* + * 126 0x7e '~' + */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 127 0x7f '' + */ + 0x00, /* 00000000 */ + 0x10, /* 00010000 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 128 0x80 '€' + */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x0c, /* 00001100 */ + 0x78, /* 01111000 */ + + /* + * 129 0x81 '�' + */ + 0xcc, /* 11001100 */ + 0x00, /* 00000000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 130 0x82 '‚' + */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 131 0x83 'ƒ' + */ + 0x7c, /* 01111100 */ + 0x82, /* 10000010 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 132 0x84 '„' + */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 133 0x85 '…' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 134 0x86 '†' + */ + 0x30, /* 00110000 */ + 0x30, /* 00110000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 135 0x87 '‡' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x7e, /* 01111110 */ + 0x0c, /* 00001100 */ + 0x38, /* 00111000 */ + + /* + * 136 0x88 'ˆ' + */ + 0x7c, /* 01111100 */ + 0x82, /* 10000010 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 137 0x89 '‰' + */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 138 0x8a 'Š' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 139 0x8b '‹' + */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 140 0x8c 'Œ' + */ + 0x7c, /* 01111100 */ + 0x82, /* 10000010 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 141 0x8d '�' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 142 0x8e 'Ž' + */ + 0xc6, /* 11000110 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 143 0x8f '�' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 144 0x90 '�' + */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0xf8, /* 11111000 */ + 0xc0, /* 11000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 145 0x91 '‘' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0xd8, /* 11011000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 146 0x92 '’' + */ + 0x3e, /* 00111110 */ + 0x6c, /* 01101100 */ + 0xcc, /* 11001100 */ + 0xfe, /* 11111110 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xce, /* 11001110 */ + 0x00, /* 00000000 */ + + /* + * 147 0x93 '“' + */ + 0x7c, /* 01111100 */ + 0x82, /* 10000010 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 148 0x94 '”' + */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 149 0x95 '•' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 150 0x96 '–' + */ + 0x78, /* 01111000 */ + 0x84, /* 10000100 */ + 0x00, /* 00000000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 151 0x97 '—' + */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 152 0x98 '˜' + */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7e, /* 01111110 */ + 0x06, /* 00000110 */ + 0xfc, /* 11111100 */ + + /* + * 153 0x99 '™' + */ + 0xc6, /* 11000110 */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* + * 154 0x9a 'š' + */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 155 0x9b '›' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 156 0x9c 'œ' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x64, /* 01100100 */ + 0xf0, /* 11110000 */ + 0x60, /* 01100000 */ + 0x66, /* 01100110 */ + 0xfc, /* 11111100 */ + 0x00, /* 00000000 */ + + /* + * 157 0x9d '�' + */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 158 0x9e 'ž' + */ + 0xf8, /* 11111000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xfa, /* 11111010 */ + 0xc6, /* 11000110 */ + 0xcf, /* 11001111 */ + 0xc6, /* 11000110 */ + 0xc7, /* 11000111 */ + + /* + * 159 0x9f 'Ÿ' + */ + 0x0e, /* 00001110 */ + 0x1b, /* 00011011 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0xd8, /* 11011000 */ + 0x70, /* 01110000 */ + 0x00, /* 00000000 */ + + /* + * 160 0xa0 ' ' + */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x7c, /* 01111100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 161 0xa1 '¡' + */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x38, /* 00111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 162 0xa2 '¢' + */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + + /* + * 163 0xa3 '£' + */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 164 0xa4 '¤' + */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0xdc, /* 11011100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x00, /* 00000000 */ + + /* + * 165 0xa5 '¥' + */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0xe6, /* 11100110 */ + 0xf6, /* 11110110 */ + 0xde, /* 11011110 */ + 0xce, /* 11001110 */ + 0x00, /* 00000000 */ + + /* + * 166 0xa6 '¦' + */ + 0x3c, /* 00111100 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x3e, /* 00111110 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 167 0xa7 '§' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 168 0xa8 '¨' + */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x63, /* 01100011 */ + 0x3e, /* 00111110 */ + 0x00, /* 00000000 */ + + /* + * 169 0xa9 '©' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 170 0xaa 'ª' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x06, /* 00000110 */ + 0x06, /* 00000110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 171 0xab '«' + */ + 0x63, /* 01100011 */ + 0xe6, /* 11100110 */ + 0x6c, /* 01101100 */ + 0x7e, /* 01111110 */ + 0x33, /* 00110011 */ + 0x66, /* 01100110 */ + 0xcc, /* 11001100 */ + 0x0f, /* 00001111 */ + + /* + * 172 0xac '¬' + */ + 0x63, /* 01100011 */ + 0xe6, /* 11100110 */ + 0x6c, /* 01101100 */ + 0x7a, /* 01111010 */ + 0x36, /* 00110110 */ + 0x6a, /* 01101010 */ + 0xdf, /* 11011111 */ + 0x06, /* 00000110 */ + + /* + * 173 0xad '­' + */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 174 0xae '®' + */ + 0x00, /* 00000000 */ + 0x33, /* 00110011 */ + 0x66, /* 01100110 */ + 0xcc, /* 11001100 */ + 0x66, /* 01100110 */ + 0x33, /* 00110011 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 175 0xaf '¯' + */ + 0x00, /* 00000000 */ + 0xcc, /* 11001100 */ + 0x66, /* 01100110 */ + 0x33, /* 00110011 */ + 0x66, /* 01100110 */ + 0xcc, /* 11001100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 176 0xb0 '°' + */ + 0x22, /* 00100010 */ + 0x88, /* 10001000 */ + 0x22, /* 00100010 */ + 0x88, /* 10001000 */ + 0x22, /* 00100010 */ + 0x88, /* 10001000 */ + 0x22, /* 00100010 */ + 0x88, /* 10001000 */ + + /* + * 177 0xb1 '±' + */ + 0x55, /* 01010101 */ + 0xaa, /* 10101010 */ + 0x55, /* 01010101 */ + 0xaa, /* 10101010 */ + 0x55, /* 01010101 */ + 0xaa, /* 10101010 */ + 0x55, /* 01010101 */ + 0xaa, /* 10101010 */ + + /* + * 178 0xb2 '²' + */ + 0x77, /* 01110111 */ + 0xdd, /* 11011101 */ + 0x77, /* 01110111 */ + 0xdd, /* 11011101 */ + 0x77, /* 01110111 */ + 0xdd, /* 11011101 */ + 0x77, /* 01110111 */ + 0xdd, /* 11011101 */ + + /* + * 179 0xb3 '³' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 180 0xb4 '´' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 181 0xb5 'µ' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 182 0xb6 '¶' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf6, /* 11110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 183 0xb7 '·' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 184 0xb8 '¸' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 185 0xb9 '¹' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf6, /* 11110110 */ + 0x06, /* 00000110 */ + 0xf6, /* 11110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 186 0xba 'º' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 187 0xbb '»' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x06, /* 00000110 */ + 0xf6, /* 11110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 188 0xbc '¼' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf6, /* 11110110 */ + 0x06, /* 00000110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 189 0xbd '½' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 190 0xbe '¾' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 191 0xbf '¿' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xf8, /* 11111000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 192 0xc0 'À' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 193 0xc1 'Á' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 194 0xc2 'Â' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 195 0xc3 'Ã' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 196 0xc4 'Ä' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 197 0xc5 'Å' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 198 0xc6 'Æ' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 199 0xc7 'Ç' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x37, /* 00110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 200 0xc8 'È' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x37, /* 00110111 */ + 0x30, /* 00110000 */ + 0x3f, /* 00111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 201 0xc9 'É' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3f, /* 00111111 */ + 0x30, /* 00110000 */ + 0x37, /* 00110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 202 0xca 'Ê' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf7, /* 11110111 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 203 0xcb 'Ë' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0xf7, /* 11110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 204 0xcc 'Ì' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x37, /* 00110111 */ + 0x30, /* 00110000 */ + 0x37, /* 00110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 205 0xcd 'Í' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 206 0xce 'Î' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xf7, /* 11110111 */ + 0x00, /* 00000000 */ + 0xf7, /* 11110111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 207 0xcf 'Ï' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 208 0xd0 'Ð' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 209 0xd1 'Ñ' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 210 0xd2 'Ò' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 211 0xd3 'Ó' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x3f, /* 00111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 212 0xd4 'Ô' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 213 0xd5 'Õ' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 214 0xd6 'Ö' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3f, /* 00111111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 215 0xd7 '×' + */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0xff, /* 11111111 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + + /* + * 216 0xd8 'Ø' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0xff, /* 11111111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 217 0xd9 'Ù' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xf8, /* 11111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 218 0xda 'Ú' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x1f, /* 00011111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 219 0xdb 'Û' + */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + + /* + * 220 0xdc 'Ü' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + + /* + * 221 0xdd 'Ý' + */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + 0xf0, /* 11110000 */ + + /* + * 222 0xde 'Þ' + */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + 0x0f, /* 00001111 */ + + /* + * 223 0xdf 'ß' + */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0xff, /* 11111111 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 224 0xe0 'à' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0xc8, /* 11001000 */ + 0xdc, /* 11011100 */ + 0x76, /* 01110110 */ + 0x00, /* 00000000 */ + + /* + * 225 0xe1 'á' + */ + 0x78, /* 01111000 */ + 0xcc, /* 11001100 */ + 0xcc, /* 11001100 */ + 0xd8, /* 11011000 */ + 0xcc, /* 11001100 */ + 0xc6, /* 11000110 */ + 0xcc, /* 11001100 */ + 0x00, /* 00000000 */ + + /* + * 226 0xe2 'â' + */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0xc0, /* 11000000 */ + 0x00, /* 00000000 */ + + /* + * 227 0xe3 'ã' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x00, /* 00000000 */ + + /* + * 228 0xe4 'ä' + */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + + /* + * 229 0xe5 'å' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xd8, /* 11011000 */ + 0xd8, /* 11011000 */ + 0xd8, /* 11011000 */ + 0x70, /* 01110000 */ + 0x00, /* 00000000 */ + + /* + * 230 0xe6 'æ' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x7c, /* 01111100 */ + 0xc0, /* 11000000 */ + + /* + * 231 0xe7 'ç' + */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + + /* + * 232 0xe8 'è' + */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x3c, /* 00111100 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + + /* + * 233 0xe9 'é' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xfe, /* 11111110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + + /* + * 234 0xea 'ê' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0xee, /* 11101110 */ + 0x00, /* 00000000 */ + + /* + * 235 0xeb 'ë' + */ + 0x0e, /* 00001110 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x3e, /* 00111110 */ + 0x66, /* 01100110 */ + 0x66, /* 01100110 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + + /* + * 236 0xec 'ì' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0xdb, /* 11011011 */ + 0xdb, /* 11011011 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 237 0xed 'í' + */ + 0x06, /* 00000110 */ + 0x0c, /* 00001100 */ + 0x7e, /* 01111110 */ + 0xdb, /* 11011011 */ + 0xdb, /* 11011011 */ + 0x7e, /* 01111110 */ + 0x60, /* 01100000 */ + 0xc0, /* 11000000 */ + + /* + * 238 0xee 'î' + */ + 0x1e, /* 00011110 */ + 0x30, /* 00110000 */ + 0x60, /* 01100000 */ + 0x7e, /* 01111110 */ + 0x60, /* 01100000 */ + 0x30, /* 00110000 */ + 0x1e, /* 00011110 */ + 0x00, /* 00000000 */ + + /* + * 239 0xef 'ï' + */ + 0x00, /* 00000000 */ + 0x7c, /* 01111100 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + + /* + * 240 0xf0 'ð' + */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0xfe, /* 11111110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 241 0xf1 'ñ' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x7e, /* 01111110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 242 0xf2 'ò' + */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 243 0xf3 'ó' + */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x18, /* 00011000 */ + 0x0c, /* 00001100 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + + /* + * 244 0xf4 'ô' + */ + 0x0e, /* 00001110 */ + 0x1b, /* 00011011 */ + 0x1b, /* 00011011 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + + /* + * 245 0xf5 'õ' + */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0xd8, /* 11011000 */ + 0xd8, /* 11011000 */ + 0x70, /* 01110000 */ + + /* + * 246 0xf6 'ö' + */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x7e, /* 01111110 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 247 0xf7 '÷' + */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0x76, /* 01110110 */ + 0xdc, /* 11011100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 248 0xf8 'ø' + */ + 0x38, /* 00111000 */ + 0x6c, /* 01101100 */ + 0x6c, /* 01101100 */ + 0x38, /* 00111000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 249 0xf9 'ù' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 250 0xfa 'ú' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x18, /* 00011000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 251 0xfb 'û' + */ + 0x0f, /* 00001111 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0x0c, /* 00001100 */ + 0xec, /* 11101100 */ + 0x6c, /* 01101100 */ + 0x3c, /* 00111100 */ + 0x1c, /* 00011100 */ + + /* + * 252 0xfc 'ü' + */ + 0x6c, /* 01101100 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x36, /* 00110110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 253 0xfd 'ý' + */ + 0x78, /* 01111000 */ + 0x0c, /* 00001100 */ + 0x18, /* 00011000 */ + 0x30, /* 00110000 */ + 0x7c, /* 01111100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 254 0xfe 'þ' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x3c, /* 00111100 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + + /* + * 255 0xff 'ÿ' + */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + +}; diff --git a/src/sdl/sdlwelldrawing.cxx b/src/sdl/sdlwelldrawing.cxx new file mode 100644 index 0000000..e632682 --- /dev/null +++ b/src/sdl/sdlwelldrawing.cxx @@ -0,0 +1,591 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: sdlwelldrawing.cxx,v 1.4 2003/02/21 11:40:33 leo Exp $ + +/// module description +/// SDL implementation of WellDrawing class - drawing routines for the game. +/// Draw field on pixmap, then maps it to the screen. Uses dirty rectangles +/// algorithm for mapping areas to screen from pixmap + +#include "sdlwelldrawing.h" +#include "sdlwellengine.h" +#include "sdl_gfxprimitives.h" + +//=========================================================================== +/// global SDLWellDrawingEngine() +/// constructor of the class - init's variables. +/// tags SDLWellDrawingEngine +SDLWellDrawingEngine::SDLWellDrawingEngine(SDLWellEngine* myengine) +{ + engine=myengine; + if(engine==0) + engine=static_cast(default_well_engine); + mainw=engine->get_main_window(); + colors=engine->get_colors(); + RGBA=engine->get_RGBA(); +} + +//=========================================================================== +/// global init(int n_fields, int idx, int idy, unsigned il, unsigned ih) +/// init fields - creates x pixmaps and gcs +/// tags SDLWellDrawingEngine +void SDLWellDrawingEngine::init(int inum_fields, int idx, int idy, + unsigned int il, unsigned int ih) +{ + + int i; + SDL_Surface *surface; + + WellDrawingEngine::init(inum_fields,idx,idy,il,ih); + fields=new SDL_Surface*; + + fg_color=colors[GridColor]; + + for(i=0;i<1;i++) + { +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + surface = SDL_CreateRGBSurface(SDL_SWSURFACE, l, h, 32, + 0xff000000, + 0x00ff0000, + 0x0000ff00, + 0x000000ff); +#else + surface = SDL_CreateRGBSurface(SDL_SWSURFACE, l, h, 32, + 0x000000ff, + 0x0000ff00, + 0x00ff0000, + 0xff000000); +#endif + + fields[i]=SDL_DisplayFormat(surface); + SDL_FreeSurface(surface); + if(fields[i]>0) + clear_field(i); + } + bg_color=colors[BackColor]; + fg_color=colors[GridColor]; +} + +//=========================================================================== +/// global draw_square(int color_idx, int i, int j) +/// Draw square (floor polygon) on all fields with given color +/// tags SDLWellDrawingEngine +void SDLWellDrawingEngine::draw_square(int color, int i, int j) +{ + int idx=current_id,sign_x13,sign_y13,sign_x24,sign_y24; + + Uint8 *rcolor=&RGBA[color*4]; + + sign_x13= points[idx].base_points[i+1][j+1].x - + points[idx].base_points[i][j].x; + sign_x13= sign_x13 ? (sign_x13>0 ? 1 : -1) : 0; + + sign_y13= points[idx].base_points[i+1][j+1].y - + points[idx].base_points[i][j].y; + sign_y13= sign_y13 ? (sign_y13>0 ? 1 : -1) : 0; + + sign_x24= points[idx].base_points[i][j+1].x - + points[idx].base_points[i+1][j].x; + sign_x24= sign_x24 ? (sign_x24>0 ? 1 : -1) : 0; + + sign_y24= points[idx].base_points[i][j+1].y - + points[idx].base_points[i+1][j].y; + sign_y24= sign_y24 ? (sign_y24>0 ? 1 : -1) : 0; + + trap_x[0] = points[idx].base_points[i][j].x+sign_x13; + trap_y[0] = points[idx].base_points[i][j].y+sign_y13; + trap_x[1] = points[idx].base_points[i+1][j].x+sign_x24; + trap_y[1] = points[idx].base_points[i+1][j].y+sign_y24; + trap_x[2] = points[idx].base_points[i+1][j+1].x-sign_x13; + trap_y[2] = points[idx].base_points[i+1][j+1].y-sign_y13; + trap_x[3] = points[idx].base_points[i][j+1].x-sign_x24; + trap_y[3] = points[idx].base_points[i][j+1].y-sign_y24; + + filledPolygonRGBA(*fields, trap_x, trap_y, MAX_SIDES, + rcolor[0], + rcolor[1], + rcolor[2], + rcolor[3] + ); + + //Now draw the grid + trap_x[0] = points[idx].base_points[i][j].x; + trap_y[0] = points[idx].base_points[i][j].y; + trap_x[1] = points[idx].base_points[i+1][j].x; + trap_y[1] = points[idx].base_points[i+1][j].y; + trap_x[2] = points[idx].base_points[i+1][j+1].x; + trap_y[2] = points[idx].base_points[i+1][j+1].y; + trap_x[3] = points[idx].base_points[i][j+1].x; + trap_y[3] = points[idx].base_points[i][j+1].y; + + polygonRGBA(*fields, trap_x, trap_y, MAX_SIDES, + RGBA[GridColor2*4], + RGBA[GridColor2*4+1], + RGBA[GridColor2*4+2], + RGBA[GridColor2*4+3] + ); + + new_dirty_rec(delta_x,delta_y); + dirty_add_xy(trap_x[0],trap_y[0]); + dirty_add_xy(trap_x[1],trap_y[1]); + dirty_add_xy(trap_x[2],trap_y[2]); + dirty_add_xy(trap_x[3],trap_y[3]); + finish_dirty_rec(); +} + +//=========================================================================== +/// global draw_trapazoid(int color_idx, int i,int j) +/// draw trapazoid - wall polygon with given color +/// tags SDLWellDrawingEngine +void SDLWellDrawingEngine::draw_trapazoid(int color, int i, int j) +{ + SDL_Surface *win=*fields; + int idx=current_id,sign_x13,sign_y13,sign_x24,sign_y24; + + Uint8 *rcolor=&RGBA[color*4]; + + + sign_x13= points[idx].wall_points[i+1][j+1].x - + points[idx].wall_points[i][j].x; + sign_x13= sign_x13 ? (sign_x13>0 ? 1 : -1) : 0; + + sign_y13= points[idx].wall_points[i+1][j+1].y - + points[idx].wall_points[i][j].y; + sign_y13= sign_y13 ? (sign_y13>0 ? 1 : -1) : 0; + + sign_x24= points[idx].wall_points[i][j+1].x - + points[idx].wall_points[i+1][j].x; + sign_x24= sign_x24 ? (sign_x24>0 ? 1 : -1) : 0; + + sign_y24= points[idx].wall_points[i][j+1].y - + points[idx].wall_points[i+1][j].y; + sign_y24= sign_y24 ? (sign_y24>0 ? 1 : -1) : 0; + + /* + w=i/MASDL_WIDTH; + dbgprintf(("trapazoid [%2d][%2d] = [%d - %d],[%d - %d]\n",i,j, + points[idx].wall_points[i+1][j+1].x, + points[idx].wall_points[i][j].x, + points[idx].wall_points[i+1][j+1].y, + points[idx].wall_points[i][j].y)); + + dbgprintf(("trapazoid2[%2d][%2d] = [%d - %d],[%d - %d]\n",i,j, + points[idx].wall_points[i][j+1].x, + points[idx].wall_points[i+1][j].x, + points[idx].wall_points[i][j+1].y, + points[idx].wall_points[i+1][j].y)); + dbgprintf(("trapazoid [%2d][%2d] = [%d][%d],[%d][%d]\n",i,j, + sign_x13,sign_y13,sign_x24,sign_y24)); + */ + + + trap_x[0] = points[idx].wall_points[i][j].x+sign_x13; + trap_y[0] = points[idx].wall_points[i][j].y+sign_y13; + trap_x[1] = points[idx].wall_points[i+1][j].x+sign_x24; + trap_y[1] = points[idx].wall_points[i+1][j].y+sign_y24; + trap_x[2] = points[idx].wall_points[i+1][j+1].x-sign_x13; + trap_y[2] = points[idx].wall_points[i+1][j+1].y-sign_y13; + trap_x[3] = points[idx].wall_points[i][j+1].x-sign_x24; + trap_y[3] = points[idx].wall_points[i][j+1].y-sign_y24; + filledPolygonRGBA(win, trap_x, trap_y, MAX_SIDES, + rcolor[0], + rcolor[1], + rcolor[2], + rcolor[3] + ); + //Now draw the grid + trap_x[0] = points[idx].wall_points[i][j].x; + trap_y[0] = points[idx].wall_points[i][j].y; + trap_x[1] = points[idx].wall_points[i+1][j].x; + trap_y[1] = points[idx].wall_points[i+1][j].y; + trap_x[2] = points[idx].wall_points[i+1][j+1].x; + trap_y[2] = points[idx].wall_points[i+1][j+1].y; + trap_x[3] = points[idx].wall_points[i][j+1].x; + trap_y[3] = points[idx].wall_points[i][j+1].y; + polygonRGBA(win, trap_x, trap_y, MAX_SIDES, + RGBA[GridColor*4], + RGBA[GridColor*4+1], + RGBA[GridColor*4+2], + RGBA[GridColor*4+3] + ); + + if(idx==current_id) + { + new_dirty_rec(delta_x,delta_y); + dirty_add_xy(trap_x[0],trap_y[0]); + dirty_add_xy(trap_x[1],trap_y[1]); + dirty_add_xy(trap_x[2],trap_y[2]); + dirty_add_xy(trap_x[3],trap_y[3]); + finish_dirty_rec(); + } +} + +//=========================================================================== +/// global draw_grid() +/// draw grid - all wall and floor polygons +/// tags SDLWellDrawingEngine +void SDLWellDrawingEngine::draw_grid() +{ + int idx,i,j; + SDL_Surface* win; + idx=current_id; + + win=*fields; + + for(i=0;iget_object(); + //Here we need to draw dirty rec on the screen -> will be in overloaded childs + from[idx].x=drec.get_src_x(); + from[idx].y=drec.get_src_y(); + from[idx].w=to[idx].w=drec.l; + from[idx].h=to[idx].h=drec.h; + to[idx].x=drec.get_dest_x(); + to[idx].y=drec.get_dest_y(); + + SDL_BlitSurface(*fields, &from[idx], mainw, &to[idx]); + plist->del_self(); + delete plist; + idx++; + } + } while(plist); + + SDL_UpdateRects(mainw, idx, to); + + delete from; + delete to; +} + +//=========================================================================== +/// global key_to_action(void* event) +/// convert keys to actions in the game +/// tags SDLWellDrawingEngine +Actions SDLWellDrawingEngine::key_to_action(void* event) +{ + SDL_Event *ev=(SDL_Event*)event; + switch(ev->key.keysym.sym) + { + case SDLK_KP4: + case SDLK_LEFT: + case SDLK_j: + return RIGHT; + + case SDLK_KP6: + case SDLK_RIGHT: + case SDLK_l: + return LEFT; + + case SDLK_UP: + case SDLK_DOWN: + case SDLK_KP5: + case SDLK_k: + return ROTATE; + + case SDLK_SPACE: + case SDLK_KP0: + return DROP; + + case SDLK_BREAK: + case SDLK_PAUSE: + case SDLK_p: + return PAUSE_GAME; + + case SDLK_F10: + case SDLK_q: + case SDLK_ESCAPE: + return END_GAME; + + case SDLK_KP_MULTIPLY: + return OUTER_ROTATION; + + case SDLK_KP_PLUS: + return LEVEL_UP; + + case SDLK_KP_MINUS: + return LEVEL_DOWN; + + } + return NOTHING; +} + + +//=========================================================================== +/// global draw_line(...) +/// draw line with given coords and color +/// tags SDLWellDrawingEngine +void SDLWellDrawingEngine::draw_line(int x1, int y1, int x2, int y2, int color_idx, + Canvas where) +{ + Uint8 *color=&RGBA[color_idx*4]; + switch(where) + { + case screen: + lineRGBA(mainw,x1,y1,x2,y2, + color[0], + color[1], + color[2], + color[3] + ); + break; + case pixmap: + lineRGBA(*fields,x1,y1,x2,y2, + color[0], + color[1], + color[2], + color[3] + ); + break; + } +} + +//=========================================================================== +/// global draw_rect(...) +/// draw rectangle with given coords and color +/// tags SDLWellDrawingEngine +void SDLWellDrawingEngine::draw_rect(int x1, int y1, + unsigned int il, + unsigned int ih, int color_idx, + Canvas where) +{ + Uint8 *color=&RGBA[color_idx*4]; + switch(where) + { + case screen: + rectangleRGBA(mainw,x1,y1,x1+il-1,y1+ih-1, + color[0], + color[1], + color[2], + color[3] + ); + flush_field(mainw, x1,y1, il, ih); + break; + case pixmap: + rectangleRGBA(*fields,x1,y1,x1+il-1,y1+ih-1, + color[0], + color[1], + color[2], + color[3] + ); + flush_field(*fields, x1,y1, il, ih); + break; + } +} + +//=========================================================================== +/// global fill_rect(...) +/// fill rectangle with given coords and color +/// tags SDLWellDrawingEngine +void SDLWellDrawingEngine::fill_rect(int x1, int y1, + unsigned int il, + unsigned int ih, int color_idx, + Canvas where) +{ + Uint8 *color=&RGBA[color_idx*4]; + switch(where) + { + case screen: + boxRGBA(mainw,x1,y1,x1+il-1,y1+ih-1, + color[0], + color[1], + color[2], + color[3] + ); + flush_field(mainw, x1,y1, il, ih); + break; + case pixmap: + boxRGBA(*fields,x1,y1,x1+il-1,y1+ih-1, + color[0], + color[1], + color[2], + color[3] + ); + flush_field(*fields, x1,y1, il, ih); + break; + } +} + +//=========================================================================== +/// global pixmap_copy(Geo*) +/// copy part of image to the screen +/// tags SDLWellDrawingEngine +void SDLWellDrawingEngine::pixmap_copy(Geo *pgeo) +{ + SDL_Rect src,dest; + if(pgeo->im==imNone) + return; + + src.x=pgeo->fromx; + src.y=pgeo->fromy; + src.w=dest.w=pgeo->l; + src.h=dest.h=pgeo->h; + dest.x=pgeo->tox; + dest.y=pgeo->toy; + + SDL_BlitSurface(engine->get_pixmap_of_image(pgeo->im), + &src, *fields, &dest); + SDL_UpdateRects(*fields, 1, &dest); +} + diff --git a/src/sdl/sdlwelldrawing.h b/src/sdl/sdlwelldrawing.h new file mode 100644 index 0000000..6ab15fb --- /dev/null +++ b/src/sdl/sdlwelldrawing.h @@ -0,0 +1,58 @@ +// docm_prefix(///) +#ifndef SDLWELLDRAWING_H +#define SDLWELLDRAWING_H + +#include "globals.h" +#include "SDL.h" +#include "welldrawing.h" + +class SDLWellEngine; + +struct SDLPoint +{ + int x,y; +}; + +/// module description +/// Definition of the SDLWellDrawingEngine class, +/// public child from WellDrawingEngine -> engine for drawing game field +class SDLWellDrawingEngine:public WellDrawingEngine +{ + protected: + SDLWellEngine *engine; + SDL_Surface **fields; + SDL_Surface *mainw; + Uint32 *colors; + Uint8 *RGBA; + Uint32 bg_color, fg_color; + + Sint16 trap_x[MAX_SIDES]; + Sint16 trap_y[MAX_SIDES]; + + void flush_field(SDL_Surface* win, int ix, int iy, int il, int ih); + + + public: + SDLWellDrawingEngine(SDLWellEngine* myengine); + virtual void init(int,int,int,unsigned int,unsigned int); + virtual void flush_all(); + virtual void flush_dirty(); + virtual void field_sync(); + virtual void draw_grid(); + virtual void draw_square(int color, int i, int j); + virtual void draw_trapazoid(int color, int i, int j); + virtual void sync(); + virtual void clear_field(int i); + virtual Actions key_to_action(void* event); + virtual void draw_line(int x1, int y1, int x2, int y2, int color_idx, + Canvas where=screen); + virtual void draw_rect(int x1, int y1, unsigned int il, + unsigned int ih, int color_idx, + Canvas where=screen); + virtual void fill_rect(int x1, int y1, unsigned int il, + unsigned int ih, int color_idx, + Canvas where=screen); + virtual void pixmap_copy(Geo *pgeo); +}; + +#endif diff --git a/src/sdl/sdlwellengine.cxx b/src/sdl/sdlwellengine.cxx new file mode 100644 index 0000000..bae02e0 --- /dev/null +++ b/src/sdl/sdlwellengine.cxx @@ -0,0 +1,409 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002-2003 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: sdlwellengine.cxx,v 1.5 2003/02/21 11:40:33 leo Exp $ + +/// module description +/// This module contains methods of class SDLWellEngine which implements SDL calls +/// for the game. So this is SDL dependent part. It receives Events, +/// make convertions, many initions and calls. + +#include "version.h" +#include "globals.h" +#include "sdlwellengine.h" +#include "sdlwellimagefont.h" +#include "sdlwellinput.h" +#include "sdlwelldrawing.h" +#include "SDL_image.h" +#include "sdl_gfxprimitives.h" +#include "commonfuncs.h" + +//Colors for welltris pieces and grid (x color names) +static Uint8 game_color_names[MAX_GAME_COLORS][3] = +{ + /* 0 "Red" */ { 255, 0, 0}, + /* 1 "Green" */ { 0,255, 0}, + /* 2 "Blue" */ { 0, 0,255}, + /* 3 "Yellow" */ { 255,255, 0}, + /* 4 "Magenta" */ { 255, 0,255}, + /* 5 "Cyan" */ { 0,255,255}, + /* 6 "FireBrick" */ { 178, 34, 34}, + /* 7 "SpringGreen", */ { 0,255,127}, + /* 8 "CornflowerBlue" */ { 100,149,237}, + /* 9 "Khaki" */ { 240,230,140}, + /*10 "Plum" */ { 221,160,221}, + /*11 "Violet" */ { 238,130,238}, + /*12 "DarkTurquoise" */ { 0,206,209}, + /*13 "Gold" */ { 255,215, 0}, + /*14 "Orchid" */ { 218,112,214}, + /*15 "Turquoise" */ { 64,224,208}, + /*16 "Orange" */ { 255,165, 0}, + /*17 "OrangeRed" */ { 255, 69, 0}, + /*18 "VioletRed" */ { 208, 32,144}, + /*19 "BlueViolet" */ { 138, 43,226}, + /*20 "SeaGreen" */ { 46,139, 87}, + /*21 "Pink" */ { 255,192,203}, + /*22 "ForestGreen" */ { 34,139, 34}, + /*23 "SkyBlue" */ { 135,206,235}, + /*24 "Coral" */ { 255,127, 80}, + /*25 "Wheat" */ { 245,222,179}, + /*26 "GoldenRod" */ { 218,165, 32}, + /*27 "IndianRed" */ { 205, 92, 92}, + /*28 "SpringGreen" */ { 0,255,127}, + /*29 "CornflowerBlue" */ { 100,149,237}, + /*30 "Thistle" */ { 216,191,216}, + /*31 "Aquamarine" */ { 127,255,212}, + /*32 "CadetBlue" */ { 95,158,160}, + /*33 "LightSteelBlue" */ { 176,196,222}, + /*34 "NavyBlue" */ { 0, 0,128}, + /*35 "SteelBlue" */ { 70,130,180}, + /*36 "YellowGreen" */ { 154,205, 50}, + /*37 "DarkViolet" */ { 148, 0,211}, + /*38 "MediumSeaGreen" */ { 60,179,113}, + /*39 "DarkSlateGray" */ { 47, 79, 79}, + /*40 "LightGray" */ { 211,211,211}, + /*41 "MediumVioletRed" */ { 199, 21,133}, + /*42 "Sienna" */ { 160, 82, 45}, + /*43 "MediumAquamarine"*/ { 102,205,170}, + /*44 "MediumBlue" */ { 0, 0,205}, + /*45 "Navy" */ { 0, 0,128}, + /*46 "DarkOliveGreen" */ { 85,107, 47}, + /*47 "DarkGreen" */ { 0,100, 0}, + /*48 "DimGray" */ { 105,105,105}, + /*49 "Tan" */ { 210,180,140}, + /*50 "MediumTurquoise" */ { 72,209,204}, + /*51 "DarkSlateBlue" */ { 72, 61,139}, + /*52 "Maroon" */ { 176, 48, 96}, + /*53 "Gray" */ { 190,190,190}, + /*54 "#303030" */ {0x30,0x30,0x30}, + + /*55 "Black" */ { 0, 0, 0}, + /*56 "#00aa00" */ { 0,0xaa, 0}, + /*56 "#00ee00" */ { 0,0xee, 0}, + /*57 "#aa0000" */ {0xaa, 0, 0}, + /*58 "#aaaaaa" */ {0xaa,0xaa,0xaa}, + /*59 "#cccc00" */ {0xcc,0xcc, 0}, + /*60 "#eeee00" */ {0xee,0xee, 0} +}; + +const unsigned long TIMESTEP=5000l; +const int KEY_TICKS=5; +const int FIRST_KEY_TICKS=25; +//=========================================================================== +/// global new_well_engine(argc,argv) +/// Creates new WellEngine object, SDL realization (create SDLWellEngine) +/// tags new_well_engine +WellEngine* new_well_engine(int argc, char** argv) +{ + return new SDLWellEngine(argc,argv); +} + +//=========================================================================== +/// global SDLWellEngine(argc,argv) +/// Constructor of class that incupsulates work with SDL window +/// This class must always be allocated through 'new' +/// args +/// +argc: number of commanline args +/// +argv: command line args +/// tags SDLWellEngine +SDLWellEngine::SDLWellEngine(int argc, char** argv):WellEngine(argc,argv) +{ + if( SDL_Init(SDL_INIT_VIDEO) < 0 ) + { + fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); + exit(1); + } + init_mainwindow(argc,argv); + init_colors(); + load_images(); + SDL_EnableUNICODE(1); + bg_image=0; +} + +//=========================================================================== +/// global SDLWellEngine(argc,argv) +/// Destructor of class that incupsulates work with SDL window +/// tags SDLWellEngine +SDLWellEngine::~SDLWellEngine() +{ + SDL_Quit(); +} + +//=========================================================================== +/// global init_mainwindow(argc,argv) +/// create main game window and all other stuff around it +/// tags SDLWellEngine +void SDLWellEngine::init_mainwindow(int argc,char **argv) +{ + mainw = SDL_SetVideoMode(mainl, mainh, 16, + SDL_ANYFORMAT); + if( mainw == 0 ) + { + fprintf(stderr, "Unable to set %dx%dx16 video: %s\n",mainl, mainh, + SDL_GetError()); + SDL_Quit(); + exit(1); + } + dbgprintf(("VIDEO_INIT: Set 800x600x%d video mode\n", mainw->format->BitsPerPixel)); +} + +//=========================================================================== +/// global show_main() +/// show main window +/// tags SDLWellEngine +void SDLWellEngine::show_main() +{ + SDL_UpdateRect(mainw, 0,0, mainl, mainh); +} + + +void SDLWellEngine::set_key_event(SDL_Event& event) +{ + key_event=event; + key_event_got=true; + process_event_for_all(wEvent(eKeyPress,&key_event)); + key_ticks=FIRST_KEY_TICKS; +} + +void SDLWellEngine::reset_key_event() +{ + key_event_got=false; +} + +void SDLWellEngine::process_key_event() +{ + if(key_ticks) + { + key_ticks--; + return; + } + process_event_for_all(wEvent(eKeyPress,&key_event)); + key_ticks=KEY_TICKS; +} + + +//=========================================================================== +/// global event_loop() +/// main event loop - process all events and make game moves +/// tags SDLWellEngine +void SDLWellEngine::event_loop() +{ + SDL_Event event; + MouseEvent mev; + done_loop_var=false; + key_event_got=false; + dbgprintf(("Entered in event_loop\n")); + + while(!done_loop_var) + { + while(SDL_PollEvent(&event)) + { + switch (event.type) + { + case SDL_VIDEOEXPOSE: + dbgprintf(("Got expose event - processing\n")); + process_event_for_all(wEvent(eExpose,&event)); + break; + case SDL_KEYDOWN: + dbgprintf(("The '%s' key was pressed!\n", + SDL_GetKeyName(event.key.keysym.sym))); + set_key_event(event); + key_event=event; + key_event_got=true; + break; + + case SDL_KEYUP: + reset_key_event(); + break; + + case SDL_MOUSEMOTION: + mev.mx=event.motion.x; + mev.my=event.motion.y; + mev.bstate=event.motion.state==SDL_BUTTON_LEFT ? But1Press : But2Press; + process_event_for_all(wEvent(eMouseMove,&mev)); + dbgprintf(("Mouse moved by to (%d,%d) with state: %d\n", + event.motion.x, event.motion.y, event.motion.state)); + break; + case SDL_MOUSEBUTTONDOWN: + dbgprintf(("MouseButtonPress event\n")); + mev.mx=event.button.x; + mev.my=event.button.y; + mev.bstate=event.button.button==SDL_BUTTON_LEFT ? But1Press : But2Press; + process_event_for_all(wEvent(eMousePress,&mev)); + break; + case SDL_QUIT: + done_loop_var=true; + } + } + if(key_event_got) + process_key_event(); + udelay(TIMESTEP); + process_time_event(); + } +} + + +//=========================================================================== +/// global wait_for_timers() +/// calculate delay and wait for events and timers +/// tags SDLWellEngine +int SDLWellEngine::wait_for_timers() +{ + return 0; +} + +//=========================================================================== +/// global load_image(Images id, char* name) +/// Load image into memory and register it with given id for use +/// tags SDLWellEngine +bool SDLWellEngine::load_image(Images id, char* name) +{ + char buf[L_MAXPATH]; + + if(id>=MAX_IMAGES) + return false; + + find_full_path_for_file(name,buf); + pics[id]=IMG_Load(buf); + images[id].id=id; + dbgprintf(("Loaded image: %s\n",buf)); + return true; +} + + +//=========================================================================== +/// global set_main_background_image(Images id) +/// set image with given id to background of main window +/// tags SDLWellEngine +void SDLWellEngine::set_main_background_image(Images id) +{ + SDL_Rect dest; + if(images[id].id!=imNone) + { + dest.x = 0; + dest.y = 0; + dest.w = pics[id]->w; + dest.h = pics[id]->h; + SDL_BlitSurface(pics[id], 0, mainw, &dest); + /* Update the changed portion of the screen */ + SDL_UpdateRects(mainw, 1, &dest); + bg_image=pics[id]; + } +} + +//=========================================================================== +/// local init_colors() +/// allocate all nessesary colors +/// tags SDLWellEngine +void SDLWellEngine::init_colors() +{ + int i; + for(i=0;iformat, + game_color_names[i][0], + game_color_names[i][1], + game_color_names[i][2], 255); + game_RGBA[i*4+0]=game_color_names[i][0]; + game_RGBA[i*4+1]=game_color_names[i][1]; + game_RGBA[i*4+2]=game_color_names[i][2]; + game_RGBA[i*4+3]=255; + } +} + + +//=========================================================================== +/// global new_well_image_font() +/// creates image font object - version for SDL Window +/// tags SDLWellEngine +WellImageFont* SDLWellEngine::new_well_image_font(Images id, + unsigned int ifl, + unsigned int ifh, + int idx, int idy) +{ + return new SDLWellImageFont(id,ifl,ifh,idx,idy); +} + +//=========================================================================== +/// global new_well_input(char*) +/// creates new input object - version for SDL Window +/// tags SDLWellEngine +WellInput* SDLWellEngine::new_well_input(char* name) +{ + return new SDLWellInput(name); +} + +//=========================================================================== +/// global new_well_drawing_engine() +/// creates drawing engine for well board - version for SDL Window +/// tags SDLWellEngine +WellDrawingEngine* SDLWellEngine::new_well_drawing_engine() +{ + return new SDLWellDrawingEngine(this); +} + +//=========================================================================== +/// global udelay(int msec) +/// Portable delay :) +/// tags XWellEngine +void SDLWellEngine::udelay(int msec) +{ + SDL_Delay(msec/1000); +} + +//=========================================================================== +/// global screen_copy(Geo*) +/// copy part of image to the screen +/// tags SDLWellEngine +void SDLWellEngine::screen_copy(Geo *pgeo) +{ + SDL_Rect src,dest; + if(pgeo->im==imNone) + { + screen_clear(pgeo); + return; + } + src.x=pgeo->fromx; + src.y=pgeo->fromy; + src.w=dest.w=pgeo->l; + src.h=dest.h=pgeo->h; + dest.x=pgeo->tox; + dest.y=pgeo->toy; + + SDL_BlitSurface(pics[pgeo->im], + &src, mainw, &dest); + SDL_UpdateRects(mainw, 1, &dest); +} + +//=========================================================================== +/// global screen_clear(Geo*) +/// clear part of screen +/// tags SDLWellEngine +void SDLWellEngine::screen_clear(Geo *pgeo) +{ + SDL_Rect dest; + dest.x=pgeo->tox; + dest.y=pgeo->toy; + dest.w=pgeo->l; + dest.h=pgeo->h; + + if(!bg_image) + SDL_FillRect(mainw, &dest, game_colors[BackColor]); + else + SDL_BlitSurface(bg_image, &dest, mainw, &dest); + + SDL_UpdateRects(mainw, 1, &dest); +} + diff --git a/src/sdl/sdlwellengine.h b/src/sdl/sdlwellengine.h new file mode 100644 index 0000000..9a21d65 --- /dev/null +++ b/src/sdl/sdlwellengine.h @@ -0,0 +1,56 @@ +#ifndef SDLWELLENGINE_H +#define SDLWELLENGINE_H + +#include "globals.h" +#include "welltris.h" + +#include "SDL.h" + +#include "wellengine.h" + +class SDLWellEngine:public WellEngine +{ + protected: + SDL_Surface *mainw; + SDL_Surface *pics[MAX_IMAGES]; + Uint32 game_colors[MAX_GAME_COLORS]; + Uint8 game_RGBA[MAX_GAME_COLORS*4]; + SDL_Surface *bg_image; + + SDL_Event key_event; + bool key_event_got; + int key_ticks; + + virtual void init_mainwindow(int,char**); + virtual int wait_for_timers(); + + virtual void init_colors(); + void set_key_event(SDL_Event&); + void reset_key_event(); + void process_key_event(); + + public: + SDLWellEngine(int argc,char** argv); + ~SDLWellEngine(); + virtual void show_main(); + virtual void event_loop(); + virtual bool load_image(Images id, char* name); + virtual void set_main_background_image(Images id); + virtual WellImageFont* new_well_image_font(Images id, + unsigned int ifl, + unsigned int ifh, + int idx, int idy); + virtual WellInput* new_well_input(char*); + virtual WellDrawingEngine* new_well_drawing_engine(); + + SDL_Surface* get_pixmap_of_image(Images id) { return pics[id];}; + SDL_Surface* get_main_window() { return mainw;}; + Uint32* get_colors() { return game_colors;}; + Uint8* get_RGBA() { return game_RGBA;}; + + virtual void udelay(int msec); + virtual void screen_copy(Geo*); + virtual void screen_clear(Geo*); +}; + +#endif diff --git a/src/sdl/sdlwellimagefont.cxx b/src/sdl/sdlwellimagefont.cxx new file mode 100644 index 0000000..010c334 --- /dev/null +++ b/src/sdl/sdlwellimagefont.cxx @@ -0,0 +1,97 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002-2003 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: sdlwellimagefont.cxx,v 1.2 2003/02/20 15:09:41 leo Exp $ + +/// module description +/// SDL version of imagefont - displays text with SDL calls, work with pixmaps +/// loaded thought XWellEngine class + +#include "sdlwellimagefont.h" + +//=========================================================================== +/// global WellImageFont(Images id, unsigned int ifl, unsigned int ifh, int idx, int idy) +/// Constructor of base draw text class +/// tags WellImageFont +SDLWellImageFont::SDLWellImageFont(Images id, unsigned int ifl, unsigned int ifh, + int idx, int idy): + WellImageFont(id,ifl,ifh,idx,idy) +{ + engine=(SDLWellEngine*) default_well_engine; + font_surf=engine->get_pixmap_of_image(id); + mainw=engine->get_main_window(); +} + +//=========================================================================== +/// global clear_region() +/// clear region on screen for making output +/// tags SDLWellImageFont +void SDLWellImageFont::clear_region() +{ + SDL_Rect dest; + dest.x = screen_x; + dest.y = screen_y; + dest.w = screen_l; + dest.h = screen_h; + SDL_FillRect(mainw, &dest, 0); + SDL_UpdateRects(mainw, 1, &dest); +} + +//=========================================================================== +/// global clear_region() +/// clear region on screen for making output +/// tags SDLWellImageFont +void SDLWellImageFont::clear_region(Colors idx) +{ + SDL_Rect dest; + Uint32 *cols=engine->get_colors(); + + dest.x = screen_x; + dest.y = screen_y; + dest.w = screen_l; + dest.h = screen_h; + + SDL_FillRect(mainw, &dest, cols[idx]); + SDL_UpdateRects(mainw, 1, &dest); +} + +//=========================================================================== +/// global draw_symbol(...) +/// draw one symbol from font image to screen +/// tags SDLWellImageFont +void SDLWellImageFont::draw_symbol(int ix, int iy, + unsigned int il, + unsigned int ih, + char symb) +{ + SDL_Rect src,dest; + + if(symb<=32 || symb>=127) + return; + symb-=33; //Translate to our indexation + + dest.x = ix; + dest.y = iy; + dest.w = il; + dest.h = ih; + src.x = dx; + src.y = dy+(int)symb*font_h; + src.w = il; + src.h = ih; + SDL_BlitSurface(font_surf, &src, mainw, &dest); + /* Update the changed portion of the screen */ + SDL_UpdateRects(mainw, 1, &dest); +} + diff --git a/src/sdl/sdlwellimagefont.h b/src/sdl/sdlwellimagefont.h new file mode 100644 index 0000000..b4769d3 --- /dev/null +++ b/src/sdl/sdlwellimagefont.h @@ -0,0 +1,25 @@ +#ifndef SDLWELLIMAGEFONT_H +#define SDLWELLIMAGEFONT_H + +#include "wellimagefont.h" +#include "sdlwellengine.h" + +class SDLWellImageFont: public WellImageFont +{ + protected: + SDLWellEngine *engine; + SDL_Surface *font_surf; + SDL_Surface *mainw; + virtual void draw_symbol(int ix, int iy, + unsigned int il, + unsigned int ih, + char symb); + public: + SDLWellImageFont(Images id, unsigned int ifl, unsigned int ifh, int idx, int idy); + virtual void clear_region(); + virtual void clear_region(Colors); +}; + +#endif + + diff --git a/src/sdl/sdlwellinput.cxx b/src/sdl/sdlwellinput.cxx new file mode 100644 index 0000000..9a299a4 --- /dev/null +++ b/src/sdl/sdlwellinput.cxx @@ -0,0 +1,137 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002-2003 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: sdlwellinput.cxx,v 1.2 2003/02/20 15:09:41 leo Exp $ + +/// module description +/// SDL implementation of WellInput class - make input text from user +/// display it through WellImageFont, convert SDL Key event to symbols + +#include "sdlwellinput.h" +#include "sdl_gfxprimitives.h" +//=========================================================================== +/// global SDLWellInput(char*) +/// constructor - fill name and get geometry +/// tags SDLWellInput +SDLWellInput::SDLWellInput(char* iname) : WellInput(iname) +{ + engine=(SDLWellEngine*) default_well_engine; + mainw=engine->get_main_window(); +} + +//=========================================================================== +/// global process_event(wEvent) +/// stub that process events +/// tags SDLWellInput +bool SDLWellInput::process_event(wEvent ev) +{ + SDL_Event *xev=(SDL_Event*)ev.data; + switch(ev.type) + { + case eKeyPress: + process_key(xev); + return false; + + } + return true; +} + +//=========================================================================== +/// global draw_text() +/// draw text on the screen +/// tags SDLWellInput +void SDLWellInput::draw_text() +{ + fnt->draw_text(buf,buflen,BackColor); + show_cursor(); +} + + +//=========================================================================== +/// global show_cursor() +/// draw cursor on the screen +/// tags SDLWellInput +void SDLWellInput::show_cursor() +{ + SDL_Rect dest; + Uint32 *colors=engine->get_colors(); + + dest.x = geo[1].tox+buflen*FONT2_L; + dest.y = geo[1].toy; + dest.w = FONT2_L; + dest.h = FONT2_H; + + + SDL_FillRect(mainw, &dest, colors[BonusColor2]); + SDL_UpdateRects(mainw, 1, &dest); +} + + +//=========================================================================== +/// global hide_cursor() +/// hide cursor on the screen +/// tags SDLWellInput +void SDLWellInput::hide_cursor() +{ + SDL_Rect dest; + Uint32 *colors=engine->get_colors(); + + dest.x = geo[1].tox+buflen*FONT2_L; + dest.y = geo[1].toy; + dest.w = FONT2_L; + dest.h = FONT2_H; + + SDL_FillRect(mainw, &dest, colors[BackColor]); + SDL_UpdateRects(mainw, 1, &dest); +} + + +//=========================================================================== +/// global process_key(SDLEvent) +/// draw text on the screen +/// tags SDLWellInput + +void SDLWellInput::process_key(SDL_Event *xev) +{ + switch(xev->key.keysym.sym) + { + case SDLK_RETURN: + if(buflen) + object_on_enter.call(wEvent(aInputDone,this)); + break; + + case SDLK_DELETE: + case SDLK_BACKSPACE: + if(buflen>0) + { + hide_cursor(); + buflen--; + buf[buflen]=0; + draw_text(); + } + break; + default: + if(buflenkey.keysym.unicode>=32 && + xev->key.keysym.unicode<128) + { + hide_cursor(); + buf[buflen++]=(char)xev->key.keysym.unicode; + buf[buflen]=0; + draw_text(); + } + } +} + diff --git a/src/sdl/sdlwellinput.h b/src/sdl/sdlwellinput.h new file mode 100644 index 0000000..5baef79 --- /dev/null +++ b/src/sdl/sdlwellinput.h @@ -0,0 +1,25 @@ +#ifndef SDLWELLINPUT_H +#define SDLWELLINPUT_H + +#include "wellinput.h" +#include "sdlwellengine.h" + +class SDLWellInput:public WellInput +{ + SDLWellEngine *engine; + SDL_Surface *mainw; + + virtual void draw_text(); + void process_key(SDL_Event *xev); + void show_cursor(); + void hide_cursor(); + + public: + SDLWellInput(char *iname); + + virtual bool process_event(wEvent); + +}; + + +#endif diff --git a/src/wellclass.cxx b/src/wellclass.cxx new file mode 100644 index 0000000..7f92ce9 --- /dev/null +++ b/src/wellclass.cxx @@ -0,0 +1,1569 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +/* +# Original algorithm with polyominoes by +# +# David A. Bagley, bagleyd@bigfoot.com +# +# Q. Alex Zhao, azhao@cc.gatech.edu +# +$Id: wellclass.cxx,v 1.3 2003/02/21 11:40:33 leo Exp $ + +*/ + +/// module description +/// Main class that is the game itself - contains game board, generate figures +/// drop it to the field, and interacts with the user. + +#include "wellclass.h" +#include "wellengine.h" +#include "welldrawing.h" +#include "commonfuncs.h" + +static int speeds[NUM_LEVELS] = { + 100, 92, 84, 76, 68, 60, 53, 46, 39, 32, 26, 20, 15, 11, 8, 5, 3, 1, 0}; + +//=========================================================================== +/// global WellBase() +/// Constructor of base class - loads polyominoes and init structs +/// tags WellBase +WellBase::WellBase() : WellObject() +{ + int turn_style, number_polyominoes; + + dre=0; + + level=0; + rows=score=0; + pause=steps_to_rotate=0; + player_name[0]=0; + + set_default_options(); + + SRAND(time(NULL)); + read_polyominoes(); + + turn_style = tris[squares - MIN_SQUARES].mode[diagonal].turn_style; + if (turn_style < 0 || turn_style >= MAX_TYPES) + { + fprintf(stderr, "Welltris: corrupted input file %s\n", + POLYOMINOFILE); + fprintf(stderr, "\tturn_style = %d.\n", turn_style); + exit(1); + } + number_polyominoes = + tris[squares - MIN_SQUARES].mode[diagonal].number[mixed][turn_style]; + if (number_polyominoes <= 0 || number_polyominoes > MAX_START_POLYOMINOES) + { + fprintf(stderr, "Welltris: corrupted input file %s\n", + POLYOMINOFILE); + fprintf(stderr, "\tnumber_polyominoes = %d.\n", + number_polyominoes); + exit(1); + } + geo=get_geo_by_name("the_game"); +} + +//=========================================================================== +/// global new_game() +/// set params for new game +/// tags WellBase +void WellBase::new_game() +{ + int i,j; + for (j = 0; j < MAX_DEPTH; j++) + for (i = 0; i < MAX_PERIMETER; i++) + { + wall[j][i].pmid = EMPTY; + wall[j][i].cid = 0; + } + for (j = 0; j < MAX_WIDTH; j++) + for (i = 0; i < MAX_WIDTH; i++) + { + base[j][i].pmid = EMPTY; + base[j][i].cid = 0; + } + for (i = 0; i < MAX_SIDES; i++) + frozen_wall[i] = 0; + + dre->set_inner_alpha(30); + dre->set_outer_alpha(0); + dre->set_field_sizes(20,20,14,18); + dre->calc_grid_points(); + dre->set_field_id(0); + + rows=score=0; + + if(rotation) + steps_to_rotate=level; + else + steps_to_rotate=0; + + new_level_calc(); + + new_thing(); + check_freeze(); + new_thing(); + + player_score=new Score; + player_score->set_player(player_name); + player_score->squares=squares; + player_score->set_params(score,rows,level); + player_score->next_piece=showNext; + player_score->rotation=rotation; + player_score->mixed=mixed; +} + +//=========================================================================== +/// global init(WellEngine*) +/// init class and other related stuff +/// tags WellBase +void WellBase::init(WellEngine* we) +{ + //Additional init's such as read defaults.... + dbgprintf(("WellBase: game board size: %dx%d\n",VIEW_L,VIEW_H)); + //And Draw Engine inits + if(dre==0) + dre=we->new_well_drawing_engine(); + dre->init(NUM_ROT_STEPS,VIEW_X,VIEW_Y,VIEW_L,VIEW_H); + + txt_score=we->new_well_image_font(imFont1,FONT2_L,FONT2_H,FONT2_DX,FONT2_DY); + txt_score->set_screen_region(SCORE_REG_X,SCORE_REG_Y, + SCORE_REG_L,SCORE_REG_H); + + txt_lines=we->new_well_image_font(imFont1,FONT1_L,FONT1_H,FONT1_DX,FONT1_DY); + txt_lines->set_screen_region(LINES_REG_X,LINES_REG_Y, + LINES_REG_L,LINES_REG_H); + + txt_levelup=we->new_well_image_font(imFont1,FONT1_L,FONT1_H,FONT1_DX,FONT1_DY); + txt_levelup->set_screen_region(LEVUP_REG_X,LEVUP_REG_Y, + LEVUP_REG_L,LEVUP_REG_H); + + txt_level=we->new_well_image_font(imFont1,FONT1_L,FONT1_H,FONT1_DX,FONT1_DY); + txt_level->set_screen_region(LEVEL_REG_X,LEVEL_REG_Y, + LEVEL_REG_L,LEVEL_REG_H); + + txt_first=we->new_well_image_font(imFont1,FONT1_L,FONT1_H,FONT1_DX,FONT1_DY); + txt_first->set_screen_region(CHAL1_REG_X,CHAL1_REG_Y, + CHAL_REG_L,CHAL_REG_H); + + txt_second=we->new_well_image_font(imFont1,FONT1_L,FONT1_H,FONT1_DX,FONT1_DY); + txt_second->set_screen_region(CHAL2_REG_X,CHAL2_REG_Y, + CHAL_REG_L,CHAL_REG_H); + + txt_third=we->new_well_image_font(imFont1,FONT1_L,FONT1_H,FONT1_DX,FONT1_DY); + txt_third->set_screen_region(CHAL3_REG_X,CHAL3_REG_Y, + CHAL_REG_L,CHAL_REG_H); + +} + + +//=========================================================================== +/// global new_level_calc() +/// calculate params for new level +/// tags WellBase +void WellBase::new_level_calc() +{ + rows_levelup=THRESHOLD(level); + if(shown) + { + if(rotation) + make_rotation(); + default_well_engine->del_timer(this); + default_well_engine->add_timer(this,speeds[level]); + } +} + +//========================================================================== +/// global set_default_option() +/// set options needed by the game to its default values +/// tags WellBase +void WellBase::set_default_options() +{ + bonusNow=false; + showNext=true; + beep=false; + diagonal=false; + mixed=true; + bonus=true; + grid=true; + cw=true; + gradualAppear=false; + squares=4; + rotation=true; +} + +//=========================================================================== +/// global read_polyominoes() +/// reading polyominoes (our game figures) info from file +/// tags WellBase +void WellBase::read_polyominoes() +{ + char fname[L_MAXPATH]; + int c, i, j, k, sq, polyomino, sum, start, n, size, height, diag, + game, toss = 0; + int counter[MAX_SQUARES - MIN_SQUARES + 1]; + int start_counter[MAX_SQUARES - MIN_SQUARES + 1][MAX_MODES][MAX_TYPES]; + FILE *fp; + + find_full_path_for_file(POLYOMINOFILE,fname,ReadOnly); + + for (sq = 0; sq <= MAX_SQUARES - MIN_SQUARES; sq++) + { + counter[sq] = 0; + for (polyomino = 0; polyomino < MAX_POLYOMINOES; polyomino++) + for (j = 0; j < MAX_SQUARES; j++) + for (i = 0; i < MAX_SQUARES; i++) + tris[sq].polyomino[polyomino].shape[j][i] = 0; + for (j = 0; j < MAX_TYPES; j++) + { + for (polyomino = 0; polyomino < MAX_START_POLYOMINOES; polyomino++) + { + tris[sq].mode[NODIAG].start[polyomino][j] = 0; + tris[sq].mode[DIAGONAL].start[polyomino][j] = 0; + } + start_counter[sq][NODIAG][j] = 0; + start_counter[sq][DIAGONAL][j] = 0; + tris[sq].mode[NODIAG].number[NOMIX][j] = 0; + tris[sq].mode[DIAGONAL].number[NOMIX][j] = 0; + tris[sq].mode[NODIAG].number[MIXED][j] = 0; + tris[sq].mode[DIAGONAL].number[MIXED][j] = 0; + } + tris[sq].mode[NODIAG].turn_style = NONE; + tris[sq].mode[DIAGONAL].turn_style = NONE; + } + if ((fp = fopen(fname, "r")) == (FILE *)NULL) + { + (void) fprintf(stderr, "Can not open input file, %s\n.", POLYOMINOFILE); + exit(1); + } + else + { + while ((c = getc(fp)) != EOF) + { + if (c == '/') + { + while ((c = getc(fp)) != '/') {} + c = getc(fp); + } + if (c == '+') + { + (void) fscanf(fp, "%d", &k); + sq = k - MIN_SQUARES; + for (i = 0; i < MAX_TYPES; i++) + { + (void) fscanf(fp, "%d", &k); + tris[sq].mode[NODIAG].number[NOMIX][i] = k; + } + (void) fscanf(fp, "%d", &k); + tris[sq].mode[NODIAG].turn_style = k; + (void) fscanf(fp, "%d", &k); + tris[sq].diagonal_switch = k; + if (tris[sq].diagonal_switch == true) + { + for (i = 0; i < MAX_TYPES; i++) + { + (void) fscanf(fp, "%d", &k); + tris[sq].mode[DIAGONAL].number[NOMIX][i] = k; + } + (void) fscanf(fp, "%d", &k); + tris[sq].mode[DIAGONAL].turn_style = k; + } + c = getc(fp); + } + if (c == '*') + { + (void) fscanf (fp, "%d", &size); + c = getc(fp); + } + if (c == '~') /* Useful for debugging Things */ + { + (void) fscanf (fp, "%d", &toss); + c = getc(fp); + } + if (c == '#') + { + (void) fscanf(fp, "%d", &k); + sq = k - MIN_SQUARES; + (void) fscanf(fp, "%d", &n); + if (tris[sq].diagonal_switch == true) + (void) fscanf(fp, "%d", &n); + for (polyomino = 0; polyomino <= toss; polyomino++) + while ((c = getc(fp)) != EOF && c != '\n'); + for (polyomino = 0; polyomino < n - toss; polyomino++) + { + sum = polyomino + counter[sq]; + /* This is only there to "read" input file */ + (void) fscanf(fp, "%d", &k); + (void) fscanf(fp, "%d", &k); + tris[sq].polyomino[sum].rotation = + k + counter[sq] - toss; + (void) fscanf(fp, "%d", &k); + tris[sq].polyomino[sum].reflection = + k + counter[sq] - toss; + for (game = JUMPIN; game <= GRADUAL; game++) + { + (void) fscanf(fp, "%d", &height); + if (!gradualAppear && game == JUMPIN) + tris[sq].polyomino[sum].start_height = height; + else if (gradualAppear && game == GRADUAL) + tris[sq].polyomino[sum].start_height = height; + for (diag = NODIAG; diag <= tris[sq].diagonal_switch; diag++) + { + (void) fscanf(fp, "%d", &start); + if (game == JUMPIN) + { + if (sq == 0 || + tris[sq - 1].mode[diag].turn_style == NONE) + { + i = start_counter[sq][diag][NONE]; + tris[sq].mode[diag].start[i][NONE] = sum; + start_counter[sq][diag][NONE]++; + } + if ((sq == 0 || + tris[sq - 1].mode[diag].turn_style < ALL) && + start != NONE) + { + i = start_counter[sq][diag][NOREFL]; + tris[sq].mode[diag].start[i][NOREFL] = sum; + start_counter[sq][diag][NOREFL]++; + } + if (start == ALL) + { + i= start_counter[sq][diag][ALL]; + tris[sq].mode[diag].start[i][ALL] = sum; + start_counter[sq][diag][ALL]++; + } + } + } + } + tris[sq].polyomino[sum].size = size; + for (j = 0; j < size; j++) + for (i = 0; i < size; i++) + { + (void) fscanf(fp, "%d", &k); + tris[sq].polyomino[sum].shape[j][i] = k; + } + } + counter[sq] += n - toss; + toss = 0; + } + } + (void) fclose(fp); + for (i = 0; i <= MAX_SQUARES - MIN_SQUARES; i++) + for (j = 0; j < MAX_TYPES; j++) + for (k = 0; k <= i; k++) + { + tris[i].mode[NODIAG].number[MIXED][j] += + tris[k].mode[NODIAG].number[NOMIX][j]; + if (tris[i].diagonal_switch == true) + /*since k & i are not independent*/ + tris[i].mode[DIAGONAL].number[MIXED][j] += + tris[k].mode[DIAGONAL].number[NOMIX][j]; + } + } +} + + +//=========================================================================== +/// global show() +/// install itself in lists for proper processing events, draw itself. +/// tags WellBase +void WellBase::show() +{ + default_well_engine->set_main_background_image(imBoardBG); + dbgprintf(("WellBase registering event handlers\n")); + shown=true; + default_well_engine->add_timer(this,speeds[level]); + default_well_engine->add_object(this); + dre->clear_field(0); + draw_field(); + draw_thing(); + + redraw_all(); +} + +//=========================================================================== +/// global hide() +/// unregister itself from any events +/// tags WellBase +void WellBase::hide() +{ + shown=false; + dbgprintf(("WellBase unregistering from engine\n")); + default_well_engine->del_timer(this); + default_well_engine->del_object(this); +} + +//=========================================================================== +/// global new_thing() +/// Generate new figure random gen for field +/// tags WellBase +void WellBase::new_thing() +{ + curThing = nextThing; + nextThing.random_number = LRAND(); + nextThing.random_rotation = NRAND(MAX_SIDES); + nextThing.random_reflection = NRAND(2); + nextThing.bonus = bonusNow; + bonusNow = false; + redo_next(); +} + +//=========================================================================== +/// global redo_next() +/// fill nextThing vars with data from polyomino +/// tags WellBase +void WellBase::redo_next() +{ + int turn_style = tris[squares - MIN_SQUARES].mode[diagonal].turn_style; + int next_start, i; + + nextThing.squares = squares - MIN_SQUARES + nextThing.bonus; + nextThing.squares = nextThing.squares > MAX_SQUARES - MIN_SQUARES ? + MAX_SQUARES - MIN_SQUARES: nextThing.squares; + next_start = nextThing.random_number % tris[nextThing.squares]. + mode[diagonal].number[(nextThing.bonus) ? NOMIX : mixed][turn_style]; + nextThing.color_number = next_start; + dbgprintf(("NEXT COLOR number is %d\n",next_start)); + if (mixed && !nextThing.bonus) + { + nextThing.squares = 0; + while (next_start >= + tris[nextThing.squares].mode[diagonal].number[NOMIX][turn_style]) + { + next_start -= + tris[nextThing.squares].mode[diagonal].number[NOMIX][turn_style]; + nextThing.squares++; + } + } + nextThing.polyomino_number = + tris[nextThing.squares].mode[diagonal].start[next_start][turn_style]; + if (tris[nextThing.squares].mode[diagonal].turn_style > NONE) + for (i = 0; i < nextThing.random_rotation; i++) + nextThing.polyomino_number = tris[nextThing.squares].polyomino + [nextThing.polyomino_number].rotation; + if (tris[nextThing.squares].mode[diagonal].turn_style == ALL) + for (i = 0; i < nextThing.random_reflection; i++) + nextThing.polyomino_number = tris[nextThing.squares].polyomino + [nextThing.polyomino_number].reflection; + nextThing.size = + tris[nextThing.squares].polyomino[nextThing.polyomino_number].size; + nextThing.ypos = -tris[nextThing.squares].polyomino + [nextThing.polyomino_number].start_height; +} + + +//=========================================================================== +/// global put_box() +/// Putting figure into game field +/// tags WellBase +void WellBase::put_box() +{ + int i, j, xi, yj; + int x = curThing.xpos, y = curThing.ypos; + + for (i = 0; i < curThing.size; i++) + for (j = 0; j < curThing.size; j++) + if ((y + j >= 0) && tris[curThing.squares].polyomino + [curThing.polyomino_number].shape[j][i]) { + xi = (x + i) % MAX_PERIMETER; + yj = y + j; + if (yj < MAX_DEPTH) { // Draw on the wall of glass + wall[yj][xi].pmid = tris[curThing.squares].polyomino + [curThing.polyomino_number].shape[j][i]; + wall[yj][xi].cid = curThing.color_number; + frozen_wall[xi / MAX_WIDTH] = MAX_SIDES; + } else { // Draw on the floor (base) + int base_i, base_j; + wall_to_base(&base_i, &base_j, xi, yj); + base[base_j][base_i].pmid = tris[curThing.squares].polyomino + [curThing.polyomino_number].shape[j][i]; + base[base_j][base_i].cid = curThing.color_number; + } + } +} + + +//=========================================================================== +/// global overlapping() +/// check overlapping our figure in current position with another ones +/// on game field +/// tags WellBase +bool WellBase::overlapping() +{ + int i, j, xi, yj; + int x = curThing.xpos, y = curThing.ypos; + + for (i = 0; i < curThing.size; i++) + for (j = 0; j < curThing.size; j++) + if (tris[curThing.squares].polyomino + [curThing.polyomino_number].shape[j][i]) { + xi = (x + i) % MAX_PERIMETER; + yj = y + j; + if (yj < MAX_DEPTH) { + if (frozen_wall[xi / MAX_WIDTH]) + return true; + if (gradualAppear) { +/* This method one can turn polyomino to an area above of screen, also + part of the polyomino may not be visible initially */ + if ((yj >= 0) && (wall[yj][xi].pmid >= 0)) + return true; + } else { +/* This method does not allow turning polyomino to an area above screen */ + if ((yj < 0) || (wall[yj][xi].pmid >= 0)) + return true; + } + } + else if (yj < MAX_DEPTH + MAX_WIDTH) { + int base_i, base_j; + wall_to_base(&base_i, &base_j, xi, yj); + if (base[base_j][base_i].pmid >= 0) + return true; + } + else + return true; + } + + return false; +} + +//=========================================================================== +/// global wall_to_base(int* base_x,int* base_y,int wall_x,int wall_y) +/// Translate wall coordinates to floor (base) one. +/// tags WellBase +void WellBase::wall_to_base(int* base_x,int* base_y,int wall_x,int wall_y) +{ + switch (wall_x / MAX_WIDTH) + { + case 0: + *base_x = wall_x; + *base_y = wall_y - MAX_DEPTH; + break; + case 1: + *base_x = MAX_WIDTH - 1 + MAX_DEPTH - wall_y; + *base_y = wall_x - MAX_WIDTH; + break; + case 2: + *base_x = MAX_PERIMETER - 1 - MAX_WIDTH - wall_x; + *base_y = MAX_WIDTH - 1 + MAX_DEPTH - wall_y; + break; + case 3: + *base_x = wall_y - MAX_DEPTH; + *base_y = MAX_PERIMETER - 1 - wall_x; + break; + default: + (void) fprintf (stderr, "wall_to_base kinds range 0-3, got %d.\n", + wall_x / MAX_WIDTH); + exit(-1); + } +} + +//=========================================================================== +/// global at_bottom() +/// Do we at bottom of the glass? (any piece of our figure) +/// tags WellBase +bool WellBase::at_bottom() +{ + int i, j, xi, yj; + int x = curThing.xpos, y = curThing.ypos; + + for (i = 0; i < curThing.size; i++) + for (j = 0; j < curThing.size; j++) + if (tris[curThing.squares].polyomino + [curThing.polyomino_number].shape[j][i]) { + xi = (x + i) % MAX_PERIMETER; + yj = y + j; + if (yj < -1) + return false; + if (yj < MAX_DEPTH - 1) { + if (frozen_wall[xi / MAX_WIDTH]) + return true; + if (wall[yj + 1][xi].pmid >= 0) + return true; + } + else if (yj < MAX_DEPTH + MAX_WIDTH - 1) { + int base_i, base_j; + wall_to_base(&base_i, &base_j, xi, yj + 1); + if (base[base_j][base_i].pmid >= 0) + return true; + } + else + return true; + } + + return false; +} + +//=========================================================================== +/// global at_base_fully() +/// Do we fully on the floor? (all pieces of our figure) +/// tags WellBase +bool WellBase::at_base_fully() +{ + int i, j; + + for (i = 0; i < curThing.size; i++) + for (j = 0; j < curThing.size; j++) + if (curThing.ypos + j < MAX_DEPTH && tris[curThing.squares].polyomino + [curThing.polyomino_number].shape[j][i]) + return false; + return true; +} + +//=========================================================================== +/// global at_base_partially() +/// Do we on the floor? (at least one of our piece) +/// tags WellBase +bool WellBase::at_base_partially() +{ + int i, j; + + for (i = 0; i < curThing.size; i++) + for (j = 0; j < curThing.size; j++) + if (curThing.ypos + j >= MAX_DEPTH && tris[curThing.squares].polyomino + [curThing.polyomino_number].shape[j][i]) + return true; + return false; +} + +//=========================================================================== +/// global wall_change(thing_t old,thing_t new_t) +/// Do we change the wall from last position? +/// tags WellBase +bool WellBase::wall_change(thing_t old,thing_t new_t) +{ + int w = -1, i, j; + int x = curThing.xpos; + + for (i = 0; i < old.size; i++) + for (j = 0; j < old.size; j++) + if (tris[old.squares].polyomino[old.polyomino_number].shape[j][i]) { + if (w == -1) + w = ((x + i) % MAX_PERIMETER) / MAX_WIDTH; + else if (w != ((x + i) % MAX_PERIMETER) / MAX_WIDTH) + return true; + } + for (i = 0; i < new_t.size; i++) + for (j = 0; j < new_t.size; j++) + if (tris[new_t.squares].polyomino[new_t.polyomino_number].shape[j][i]) + if (w != ((x + i) % MAX_PERIMETER) / MAX_WIDTH) + return true; + return false; +} + + +//=========================================================================== +/// global try_move(Actions move) +/// Trying to move/rotate/fall our figure according to the given move action +/// tags WellBase +void WellBase::try_move(Actions move) +{ + thing_t old; + int i; + bool skip = false; + + old = curThing; + + switch (move) { + case FALL: + curThing.ypos ++; + break; + + case DROP: + do { + curThing.ypos ++; + score += level; + } while (!overlapping()); + curThing.ypos --; + break; + + case LEFT: + curThing.xpos = (curThing.xpos + MAX_PERIMETER - 1) % MAX_PERIMETER; + if (at_base_fully() || (at_base_partially() && wall_change(old, curThing))) + skip = true; + break; + + case RIGHT: + curThing.xpos = (curThing.xpos + 1) % MAX_PERIMETER; + if (at_base_fully() || (at_base_partially() && wall_change(old, curThing))) + skip = true; + break; + + case ROTATE: + if (tris[squares - MIN_SQUARES].mode[diagonal].turn_style > NONE) + { + if (cw) + for (i = 0; i < MAX_SIDES - 1; i++) + curThing.polyomino_number = tris[curThing.squares].polyomino + [curThing.polyomino_number].rotation; + else /* ccw */ + curThing.polyomino_number = tris[curThing.squares].polyomino + [curThing.polyomino_number].rotation; + curThing.xpos = old.xpos; + curThing.ypos = old.ypos; + if (at_base_partially() && wall_change(old, curThing)) + skip = true; + } + break; + + case REFLECT: /* reflect on y axis */ + if (tris[squares - MIN_SQUARES].mode[diagonal].turn_style == ALL) + { + curThing.polyomino_number = tris[curThing.squares].polyomino + [curThing.polyomino_number].reflection; + curThing.xpos = old.xpos; + curThing.ypos = old.ypos; + if (at_base_partially() && wall_change(old, curThing)) + skip = true; + } + break; + default: + skip=true; + break; + } + + if (!skip && !overlapping()) + draw_thing_diff(&old); + else + curThing = old; +} + +//=========================================================================== +/// global draw_box(int color,int i,int j) +/// Draw our box (piece of figure) on our virtual square (walls + floor) +/// tags WellBase +void WellBase::draw_box(int color,int i,int j) +{ + if (j < MAX_DEPTH) { //Draw trapazoid on the wall + dre->draw_trapazoid(color, i, j); + } + else { // Draw square on the floor + int base_i, base_j; + wall_to_base(&base_i, &base_j, i, j); + dre->draw_square(color, base_i, base_j); + } +} + +//=========================================================================== +/// global draw_thing() +/// for all squares in figure do draw_box -> draw whole figure on the field +/// tags WellBase +void WellBase::draw_thing() +{ + int i, j, xi; + + for (i = 0; i < curThing.size; i++) + for (j = 0; j < curThing.size; j++) + if (tris[curThing.squares].polyomino + [curThing.polyomino_number].shape[j][i]) { + xi = (curThing.xpos + i) % MAX_PERIMETER; + draw_box(curThing.color_number,xi, curThing.ypos + j); + } +} + +//=========================================================================== +/// global draw_thing_diff(thing_t* old) +/// Make diff between old and new position on figure and Draw its +/// actually Draw new one and clear empty old pieces :) +/// tags WellBase +void WellBase::draw_thing_diff(thing_t* old) +{ + int i, j, ox, oy; + + for (i = 0; i < curThing.size; i++) + for (j = 0; j < curThing.size; j++) + if ((curThing.ypos + j >= 0) && tris[curThing.squares].polyomino + [curThing.polyomino_number].shape[j][i]) + { + draw_box(curThing.color_number, + (curThing.xpos + i) % MAX_PERIMETER, curThing.ypos + j); + } + + for (i = 0; i < curThing.size; i++) + for (j = 0; j < curThing.size; j++) + { + ox = (old->xpos + i - curThing.xpos + MAX_PERIMETER) % MAX_PERIMETER; + oy = old->ypos + j - curThing.ypos; + if (tris[old->squares].polyomino[old->polyomino_number].shape[j][i] && + ((ox >= curThing.size) || (oy < 0) || (oy >= curThing.size) || + !tris[curThing.squares].polyomino + [curThing.polyomino_number].shape[oy][ox])) + { + draw_box(BackColor,(old->xpos + i) % MAX_PERIMETER, old->ypos + j); + } + } +} + +//=========================================================================== +/// global fill_lines() +/// Fill all glass with random squares. Just for test only +/// tags WellBase +void WellBase::fill_lines() +{ + int i, j; + int turn_style = tris[squares - MIN_SQUARES].mode[diagonal].turn_style; + + for (j = 0; j < MAX_DEPTH + MAX_WIDTH; j++) + for (i = 0; i < MAX_PERIMETER; i++) + { + draw_box(NRAND(tris[squares - MIN_SQUARES].mode + [diagonal].number[mixed][turn_style]), + i, j); + } +} + +//=========================================================================== +/// global freeze_wall(int w) +/// Freeze wall - make some blinks while freezing :) +/// tags WellBase +void WellBase::freeze_wall(int w) +{ + int i, j; + + for (j = 0; j < MAX_DEPTH; j++) + for (i = 0; i < MAX_WIDTH; i++) + { + if (wall[j][i+w*MAX_WIDTH].pmid < 0) + dre->draw_trapazoid(FreezeColor, w * MAX_WIDTH + i, j); + } + dre->sync(); + udelay(FLUSH_DELAY); + for (j = 0; j < MAX_DEPTH; j++) + for (i = 0; i < MAX_WIDTH; i++) + { + if (wall[j][i+w*MAX_WIDTH].pmid < 0) + dre->draw_trapazoid (BackColor, w * MAX_WIDTH + i, j); + } + dre->sync(); + udelay(FLUSH_DELAY); + for (j = 0; j < MAX_DEPTH; j++) + for (i = 0; i < MAX_WIDTH; i++) + { + if (wall[j][i+w*MAX_WIDTH].pmid < 0) + dre->draw_trapazoid (FreezeColor, w * MAX_WIDTH + i, j); + } + if (beep) + dre->bell(BVOLUME); + dre->sync(); +} + +//=========================================================================== +/// global defreeze_wall(int w) +/// Return wall to normal state +/// tags WellBase +void WellBase::defreeze_wall(int w) +{ + int i, j; + + for (j = 0; j < MAX_DEPTH; j++) + for (i = 0; i < MAX_WIDTH; i++) + { + if (wall[j][i+w*MAX_WIDTH].pmid < 0) + dre->draw_trapazoid (BackColor, w * MAX_WIDTH + i, j); + } + if (beep) + dre->bell(BVOLUME); + dre->sync(); +} + +void WellBase::udelay(int msec) +{ + default_well_engine->udelay(msec); +} + +//=========================================================================== +/// global draw_field() +/// Draw field with squares and frozen walls +/// tags WellBase +void WellBase::draw_field() +{ + int i, j; + + for (i = 0; i < MAX_PERIMETER; i++) + for (j = 0; j < MAX_DEPTH; j++) + { + if (wall[j][i].pmid >= 0) + dre->draw_trapazoid(wall[j][i].cid, i, j); + else + { + if (frozen_wall[i / MAX_WIDTH]) + dre->draw_trapazoid(FreezeColor, i, j); + else + dre->draw_trapazoid(BackColor, i, j); + } + } + for (i = 0; i < MAX_WIDTH; i++) + for (j = 0; j < MAX_WIDTH; j++) + if (base[j][i].pmid >= 0) + dre->draw_square(base[j][i].cid, i, j); + else + dre->draw_square(BackColor, i, j); + dre->clear_dirty_list(); + dre->field_sync(); +} + +//=========================================================================== +/// global draw_next() +/// Draw next figure (cheating?) +/// Currently not implemented +/// tags WellBase +void WellBase::draw_next() +{ + int x, y; + int i, j; + + Colors color= nextThing.bonus ? BonusColor : GridColor; + Colors color2= nextThing.bonus ? BonusColor2 : GridColor2; + + dbgprintf(("Next color: %d, size: %d\n",nextThing.color_number, + nextThing.size)); + x=NEXT_CENTER_X - nextThing.size*(NEXT_BOX_SIZE+2)/2; + y=NEXT_CENTER_Y - nextThing.size*(NEXT_BOX_SIZE+2)/2; + + for (i = 0; i < nextThing.size; i++) + for (j = 0; j < nextThing.size; j++) + if (tris[nextThing.squares].polyomino + [nextThing.polyomino_number].shape[j][i]) + { + dre->draw_rect(x+ (NEXT_BOX_SIZE+2)*i, y+ (NEXT_BOX_SIZE+2)*j, + NEXT_BOX_SIZE, NEXT_BOX_SIZE, color); + dre->draw_rect(x+ (NEXT_BOX_SIZE+2)*i +1, y+ (NEXT_BOX_SIZE+2)*j +1, + NEXT_BOX_SIZE-2, NEXT_BOX_SIZE-2, color2); + } + dre->sync(); +} + +//=========================================================================== +/// global clear_next() +/// Clear next figure +/// Currently not implemented +/// tags WellBase +void WellBase::clear_next() +{ + dre->fill_rect(NEXT_CENTER_X-NEXT_X_SIZE/2+1,NEXT_CENTER_Y-NEXT_Y_SIZE/2+1, + NEXT_X_SIZE-1,NEXT_Y_SIZE-1,BackColor); +} + +//=========================================================================== +/// global draw_status() +/// draw status of the game, i.e. scores, lines... +/// Currently not implemented +/// tags WellBase +void WellBase::draw_status() +{ + int delta_score; + Score *pscore2=0,*pscore1=0; + char buf[L_MAXPATH]; + char buf2[PLAYER_NAME_LEN]; + + if(!shown) + return; + + dbgprintf(("score: %d, lines: %d, level %d, levelup at: +%d\n", + score, rows, level, rows_levelup - rows)); + sprintf(buf,"%d",score); + txt_score->set_text(buf); + txt_score->draw_text(RightJust); + sprintf(buf,"%d",rows); + txt_lines->set_text(buf); + txt_lines->draw_text(RightJust); + sprintf(buf,"+%d",rows_levelup - rows + 1); + txt_levelup->set_text(buf); + txt_levelup->draw_text(RightJust); + sprintf(buf,"%d",level); + txt_level->set_text(buf); + txt_level->draw_text(RightJust); + dbgprintf(("score done\n")); + pscore2=default_top_nine->find_challenger(player_score); + if(pscore2) + pscore1=default_top_nine->find_challenger(pscore2); + + do { + if(pscore1) + { + delta_score=pscore1->score - player_score->score; + delta_score= delta_score>=100000 ? 99999 : delta_score; + strncpy(buf2,pscore1->player,CHAL_NAME_LEN); + buf2[CHAL_NAME_LEN]=0; + sprintf(buf,"%d.%-9s+%05d",pscore1->place,buf2, + delta_score); + dbgprintf(("draw_status: %s\n",buf)); + txt_first->set_text(buf); + txt_first->draw_text(); + + strncpy(buf2,pscore2->player,CHAL_NAME_LEN); + buf2[CHAL_NAME_LEN]=0; + delta_score=pscore2->score - player_score->score; + delta_score= delta_score>=100000 ? 99999 : delta_score; + sprintf(buf,"%d.%-9s+%05d",pscore2->place,buf2, + delta_score); + txt_second->set_text(buf); + txt_second->draw_text(); + + sprintf(buf,"%d.You are here",pscore2->place+1); + txt_third->set_text(buf); + txt_third->draw_text(); + break; + } + if(pscore2) + { + strncpy(buf2,pscore2->player,CHAL_NAME_LEN); + buf2[CHAL_NAME_LEN]=0; + delta_score=pscore2->score - player_score->score; + delta_score= delta_score>=100000 ? 99999 : delta_score; + sprintf(buf,"%d.%-9s+%05d",pscore2->place,buf2, + delta_score); + txt_first->set_text(buf); + txt_first->draw_text(); + + sprintf(buf,"%d.You are here",pscore2->place+1); + txt_second->set_text(buf); + txt_second->draw_text(); + + txt_third->clear_region(); + break; + } + sprintf(buf,"%d.You are here",1); + txt_first->set_text(buf); + txt_first->draw_text(); + + txt_second->clear_region(); + + txt_third->clear_region(); + } while(0); + + if(rotation) + default_well_engine->screen_copy(&geo[GEO_ROT_IDX]); + if(showNext) + default_well_engine->screen_copy(&geo[GEO_NEXT_IDX]); + if(mixed) + default_well_engine->screen_copy(&geo[GEO_MIXED_IDX]); + dre->sync(); +} + +//=========================================================================== +/// global draw_grid() +/// draw grid of the field +/// tags WellBase +void WellBase::draw_grid() +{ + dre->draw_grid(); +} + +//=========================================================================== +/// global drop_wall(int wall_num) +/// Drop all squres on the wall to the floor after row is cleared +/// tags WellBase +void WellBase::drop_wall(int w) +{ + int i, j, k, l, fits, lines, base_x, base_y; + lines = 0; + for (j = MAX_DEPTH - 1; j >= 0 && lines == 0; j--) + for (i = 0; i < MAX_WIDTH; i++) + if (wall[j][w * MAX_WIDTH + i].pmid != EMPTY) + lines = MAX_DEPTH - j; + if (lines > 0) { + fits = true; + j = 0; + while (j < (MAX_WIDTH / 2 + lines - 1) && fits) { + j++; + for (l = MAX_DEPTH - j; l < MAX_DEPTH; l++) + for (i = 0; i < MAX_WIDTH; i++) + if (wall[l][w * MAX_WIDTH + i].pmid != EMPTY) { + wall_to_base(&base_x, &base_y, + w * MAX_WIDTH + i, l + j); + if (base[base_y][base_x].pmid != EMPTY) + fits = false; + } + } + if (!fits) + j--; + if (j > 0) + { + for (l = MAX_DEPTH - 1; l >= 0; l--) + for (i = 0; i < MAX_WIDTH; i++) + if (wall[l][w * MAX_WIDTH + i].pmid != EMPTY) { + k = w * MAX_WIDTH + i; + if (l + j >= MAX_DEPTH) { + wall_to_base(&base_x, &base_y, k, l + j); + base[base_y][base_x] = wall[l][k]; + wall[l][k].pmid = EMPTY; + dre->draw_trapazoid(BackColor, k, l); + dre->draw_square(wall[l][k].cid, base_x, base_y); + } else { + wall[l + j][k] = wall[l][k]; + wall[l][k].pmid = EMPTY; + dre->draw_trapazoid(BackColor, k, l); + dre->draw_trapazoid(wall[l][k].cid, k, l + j); + } + dre->sync(); + } + if (beep) + dre->bell(BVOLUME); + dre->sync(); + } + } +} + +//=========================================================================== +/// global all_frozen() +/// True if all walls are frozen -> end of the game +/// tags WellBase +bool WellBase::all_frozen() +{ + int w; + + for (w = 0; w < MAX_SIDES; w++) + if (frozen_wall[w] == MAX_SIDES) { + freeze_wall(w); + } + for (w = 0; w < MAX_SIDES; w++) + if (frozen_wall[w] == 0) + return false; + return true; +} + +//=========================================================================== +/// global check_freeze() +/// Check frozen walls - decrease frozen counter and do defreeze +// and dropwall +/// tags WellBase +void WellBase::check_freeze() +{ + int w; + bool all_frozen=true; + + for (w = 0; w < MAX_SIDES; w++) { + if (frozen_wall[w] == 0) + { + all_frozen=false; + drop_wall(w); + } + else + { + frozen_wall[w]--; + if (frozen_wall[w] == 0) + { + defreeze_wall(w); + drop_wall(w); + all_frozen=false; + } + } + } + + if(all_frozen) + { + dbgprintf(("check_freeze - all frozen - doing game_over\n")); + throw aGameOver; + } + + /* not all frozen else this is an infinite loop */ + /* curThing.xpos = (MAX_WIDTH - curThing.size) / 2; */ + curThing.xpos = NRAND(MAX_WIDTH - curThing.size + 1); + do { + w = NRAND(MAX_SIDES); + } while (frozen_wall[w]); //Hmm, very strange method of choosing the wall??? + curThing.xpos += w * MAX_WIDTH; +} + +//=========================================================================== +/// global check_lines() +/// Checking for full lines on the floor and deleting it - make free space +/// tags WellBase +int WellBase::check_lines() +{ + int lSet[2][MAX_WIDTH], nset[2]; + int i, j, k; + + nset[0] = nset[1] = 0; + + //First check horizontal lines, increase nset[0] and lSet[0][line] + for (j = 0; j < MAX_WIDTH; j++) + { + lSet[0][j] = 0; + for (i = 0; i < MAX_WIDTH; i++) + if (base[j][i].pmid >= 0) + lSet[0][j] ++; + if (lSet[0][j] == MAX_WIDTH) + nset[0] ++; + } + //Then the same for vertical ones + for (i = 0; i < MAX_WIDTH; i++) + { + lSet[1][i] = 0; + for (j = 0; j < MAX_WIDTH; j++) + if (base[j][i].pmid >= 0) + lSet[1][i] ++; + if (lSet[1][i] == MAX_WIDTH) + nset[1] ++; + } + if (nset[0] || nset[1]) //If we have full lines + { + // Now flashing full lines awhile + for (k = 0; k < NUM_FLASHES; k++) + { + int color; + color=(k%2) ? BackColor : FlashColor; + for (j = 0; j < MAX_WIDTH; j++) + { + if (lSet[0][j] == MAX_WIDTH) + { + for (i = 0; i < MAX_WIDTH; i++) + dre->draw_square(color, i, j); + } + if (lSet[1][j] == MAX_WIDTH) + { + for (i = 0; i < MAX_WIDTH; i++) + dre->draw_square(color, j, i); + } + } + dre->flush_dirty(); + dre->sync(); + udelay(FLUSH_DELAY/2); + } + + if (nset[0] > 0) //Now delete full horizontal lines + for (j = 0; j < MAX_WIDTH; j++) + if (lSet[0][j] == MAX_WIDTH) + { + if (j < MAX_WIDTH / 2) + //If upper part of field then move other lines down to center + for (i = 0; i < MAX_WIDTH; i++) + { + for (k = j; k > 0; k--) + base[k][i] = base[k - 1][i]; + base[0][i].pmid = EMPTY; + } + else //else move them up + { + for (i = 0; i < MAX_WIDTH; i++) + { + for (k = j; k < MAX_WIDTH - 1; k++) + base[k][i] = base[k + 1][i]; + base[MAX_WIDTH - 1][i].pmid = EMPTY; + } + for (k = j; k < MAX_WIDTH - 1; k++) + //Fixing lSet position of moved lines + lSet[0][k]=lSet[0][k+1]; + lSet[0][MAX_WIDTH-1]=0; + j--; //Fixing index + } + } + if (nset[1] > 0) //Do the same for vertical lines + for (i = 0; i < MAX_WIDTH; i++) + if (lSet[1][i] == MAX_WIDTH) + { + if (i < MAX_WIDTH / 2) + for (j = 0; j < MAX_WIDTH; j++) + { + for (k = i; k > 0; k--) + base[j][k] = base[j][k - 1]; + base[j][0].pmid = EMPTY; + } + else + { + for (j = 0; j < MAX_WIDTH; j++) + { + for (k = i; k < MAX_WIDTH - 1; k++) + base[j][k] = base[j][k + 1]; + base[j][MAX_WIDTH - 1].pmid = EMPTY; + } + for (k = i; k < MAX_WIDTH - 1; k++) + lSet[1][k]=lSet[1][k+1]; + lSet[1][MAX_WIDTH-1]=0; + i--; + } + } + + //Now reDraw new field + for (j = 0; j < MAX_WIDTH; j++) + for (i = 0; i < MAX_WIDTH; i++) + { + if (base[j][i].pmid >= 0) + dre->draw_square(base[j][i].cid, i, j); + else + dre->draw_square(BackColor, i, j); + } + //All done, beeping... + if (beep) + dre->bell(BVOLUME); + dre->flush_dirty(); + dre->sync(); + } + + return (nset[0] + nset[1]); +} + + +//=========================================================================== +/// global check_update_lines() +/// Calculating statistics ans SCORES! :) And redraw status +/// tags WellBase +void WellBase::check_update_lines() +{ + int lines,mult; + int oldrows=rows; + lines = check_lines(); + score += lines + !gradualAppear + !grid; + mult= showNext ? 5 : 7; + mult += (rotation ? 1 : 0); + score += mult * level * level * lines * lines * lines * + squares * squares * (bonus + diagonal + 1) / (16 * (1 + mixed)); + rows += lines; + player_score->set_params(score,rows,level); + if (rows > rows_levelup) + { + level++; + new_level_calc(); + if (bonus) + bonusNow = true; + player_score->set_params(score,rows,level); + draw_status(); + } else + if(oldrows!=rows) + draw_status(); +} + +//=========================================================================== +/// global move_one_step(Actions move) +/// Move figure one step down/left/right +/// tags WellBase +bool WellBase::move_one_step(Actions move) +{ + if ((move == DROP) || ((move == FALL) && at_bottom())) { + try_move(move); + put_box(); + check_update_lines(); + new_thing(); + if (showNext) { + clear_next(); + draw_next(); + } + dre->sync(); /* discard all events */ + if (all_frozen()) + throw aGameOver; + check_freeze(); + if (overlapping()) + throw aGameOver; + check_update_lines(); + draw_thing(); + return true; + } else { + try_move(move); + if (rows > THRESHOLD(level)) { + level++; + draw_status(); + if (bonus) + bonusNow = true; + } + } + return false; +} + +//=========================================================================== +/// global game_over() +/// game is over :( you are looser +/// tags WellBase +void WellBase::game_over() +{ + dbgprintf(("WellBase::game_over() called\n")); + hide(); + player_score->calc_play_time(); + player_score=default_top_nine->try_add_to_table(player_score); + delete player_score; + game_over_object.call(wEvent(aGameOver,this)); +} + +//=========================================================================== +/// global redraw_all() +/// redraw all game +/// tags WellBase +void WellBase::redraw_all() +{ + if(!shown) + return; + + draw_status(); + dre->flush_all(); + clear_next(); + if(showNext) + draw_next(); + dre->flush_all(); + + while(steps_to_rotate>0) + { + make_rotation(); + steps_to_rotate--; + udelay(FLUSH_DELAY/10); + } + + dre->sync(); +} + +//=========================================================================== +/// global make_pause() +/// set/uset game pause +/// tags WellBase +void WellBase::make_pause() +{ + pause^=1; + if(pause) + { + default_well_engine->del_timer(this); + dre->clear_field(0); + dre->pixmap_copy(&geo[GEO_PAUSE_IDX]); + dre->flush_all(); + dre->sync(); + } else + { + default_well_engine->add_timer(this,speeds[level]); + dre->clear_field(0); + draw_field(); + draw_thing(); + redraw_all(); + } +} + +//=========================================================================== +/// global make_rotation() +/// rotate field step by step +/// tags WellBase +void WellBase::make_rotation() +{ + dre->outer_rotation(); + dre->clear_field(0); + draw_field(); + draw_thing(); + dre->flush_all(); + dre->sync(); +} + +//=========================================================================== +/// global process_event() +/// process all events for this game object +/// return false if we don't want to process this event for other objects +/// tags WellBase +bool WellBase::process_event(wEvent ev) +{ + Actions action; + + switch(ev.type) + { + case eTimeOut: + dbgprintf(("WellBase got time out event\n")); + try + { + move_one_step(FALL); + dre->flush_dirty(); + } + catch(EvType) + { + game_over(); + return false; + } + break; + + case eExpose: + dbgprintf(("WellBase got expose event\n")); + redraw_all(); + break; + + case eFocusOut: + if(!pause) + make_pause(); + return false; + + case eKeyPress: + action=dre->key_to_action(ev.data); + try + { + return process_action(action); + } + catch(EvType) + { + game_over(); + return false; + } + + case eDelete: + hide(); + break; + + case aIntroExit: + new_game(); + show(); + break; + } + return true; +} + +//=========================================================================== +/// global process_action(Actions) +/// process actions - moves/drops/other +/// tags WellBase +bool WellBase::process_action(Actions action) +{ + switch(action) + { + case LEFT: + case RIGHT: + case ROTATE: + case FALL: + case DROP: + if(pause) + return false; + move_one_step(action); + dre->flush_dirty(); + return false; + + case PAUSE_GAME: + make_pause(); + return false; + + case OUTER_ROTATION: + if(pause) + return false; + make_rotation(); + return false; + + case END_GAME: + game_over(); + return false; + + case LEVEL_UP: + if(pause) + return false; + if(level+10) + { + level--; + new_level_calc(); + draw_status(); + } + return false; + } + return true; +} diff --git a/src/welldrawing.cxx b/src/welldrawing.cxx new file mode 100644 index 0000000..74e59e2 --- /dev/null +++ b/src/welldrawing.cxx @@ -0,0 +1,220 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: welldrawing.cxx,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $ +#include "globals.h" +#include "welldrawing.h" + +//=========================================================================== +/// global init(int n_fields, int dx, int dy, unsigned l, unsigned h) +/// init indexes and allocate FieldPoints +/// tags WellDrawingEngine +void WellDrawingEngine::init(int inum_fields, int idx, int idy, + unsigned int il, unsigned int ih) +{ + l=il;h=ih; + delta_x=idx; + delta_y=idy; + current_id=0; + num_fields=inum_fields; + points=new FieldPoints[num_fields]; + inner_max_alpha=0.0; + f_step=1; +} + + +//=========================================================================== +/// global flush_dirty() +/// pseudo function that need flush dirty rec to the screen, +/// here it only delete dirty rect from queue +/// tags WellDrawingEngine +void WellDrawingEngine::flush_dirty() +{ + DirtyList *plist; + do + { + plist=dirty_list.get_next(); + if(plist) + { + //Here we need to draw dirty rec on the screen -> will be in overloaded childs + + plist->del_self(); + delete plist; + } + } while(plist); + +} + + +void WellDrawingEngine::draw_square(int color, int x, int y) +{ + +} + +void WellDrawingEngine::draw_trapazoid(int color, int x, int y) +{ + +} + +void WellDrawingEngine::sync() +{ + +} + +void WellDrawingEngine::flush_all() +{ + +} + +void WellDrawingEngine::bell(int) +{ + +} + + +//=========================================================================== +/// global outer_rotation() +/// make shift current field id -> switch to next field -> rotate it +/// tags WellDrawingEngine +void WellDrawingEngine::outer_rotation() +{ + current_id+=f_step; + if(current_id>=num_fields) + { + f_step*=-1; + current_id+=(f_step+f_step); + } + if(current_id<0) + { + f_step*=-1; + current_id+=(f_step+f_step); + } +} + + +//=========================================================================== +/// global set_field_sizes(int dx, int dy, int wall_delta, int base_delta) +/// set and calculate base vars +/// tags WellDrawingEngine +void WellDrawingEngine::set_field_sizes(int idx, int idy, + int ipix_wall_delta, + int ipix_base_delta) +{ + pix_dx=idx; + pix_dy=idy; + pix_wall_delta=ipix_wall_delta; + pix_base_delta=ipix_base_delta; + pix_base_width=pix_base_delta*MAX_WIDTH; + pix_max_delta=pix_wall_delta*MAX_DEPTH; + pix_max_width=pix_base_width + 2*pix_max_delta; +} + +//=========================================================================== +/// global calc_grid_points() +/// calculate all points for each field, rotate it with inner and +/// outer alpha angle +/// tags WellDrawingEngine +void WellDrawingEngine::calc_grid_points() +{ + int gi,i,j,w,x,y,n; + float alpha; + center_x=pix_dx+pix_max_width/2; + center_y=pix_dy+pix_max_width/2; + for(n=0;n x=%4d, y=%4d\n",i,j,x,y)); + x+=pix_dx; + y+=pix_dy; + alpha= + inner_max_alpha*float(j)/float(MAX_DEPTH)*float(n)/float(num_fields-1)+ + float(n)*outer_max_alpha/float(num_fields-1); + + if(alpha!=0.0) //lets make rotation + { + points[n].wall_points[gi][j].x=int( + float((x-center_x))*cos(alpha) - + float((y-center_y))*sin(alpha) + + center_x); + + points[n].wall_points[gi][j].y=int( + float((x-center_x))*sin(alpha) + + float((y-center_y))*cos(alpha) + + center_y); + + } else + { + points[n].wall_points[gi][j].x=x; + points[n].wall_points[gi][j].y=y; + } + } + for(j=0;jget_object(); + obj.ticks_left--; + if(obj.ticks_left<=0) + { + processed=true; + obj.restart_ticks(); + if(!obj.obj->process_event(wEvent(eTimeOut))) + //if we return false -> don't process any objects + break; + } + ptimelist=ptimelist->get_next(); + } + return processed; +} + +//=========================================================================== +/// global add_timer(WellObject*, int N_ticks) +/// add object to time list for ticking every N_ticks +/// tags WellEngine +bool WellEngine::add_timer(WellObject* wo, int ticks) +{ + TimeObject obj(wo,ticks); + TimeList *ptobject=new TimeList(obj); + timelist.add(ptobject); + return true; +} + +//=========================================================================== +/// global del_timer(WellObject*) +/// delete object from time list +/// tags WellEngine +bool WellEngine::del_timer(WellObject* wo) +{ + TimeObject obj(wo); + TimeList *plist=timelist.del(obj); + if(plist) + { + delete plist; + return true; + } + return false; +} + +//=========================================================================== +/// global new_well_drawing_engine() +/// creates drawing engine for well board - must be overloaded in childs +/// tags WellEngine +WellDrawingEngine* WellEngine::new_well_drawing_engine() +{ + return 0; +} + + +//=========================================================================== +/// global process_event_for_all(wEvent) +/// go throuht the list of objects, and call process_event for each +/// if object return false -> break the loop +/// tags WellEngine +bool WellEngine::process_event_for_all(wEvent ev) +{ + bool processed=true; + ObjectList* plist=objectlist.get_next(); + while(plist) + { + if(!plist->get_object()->process_event(ev)) + //if we return false -> don't process any objects + return false; + plist=plist->get_next(); + } + return processed; +} + +//=========================================================================== +/// global add_object(WellObject*) +/// add object to list of objects that want events +/// tags WellEngine +bool WellEngine::add_object(WellObject* wo) +{ + ObjectList *ptobject=new ObjectList(wo); + objectlist.add(ptobject); + return true; +} + +//=========================================================================== +/// global del_object(WellObject*, int N_ticks) +/// delete object from list of objects that want events +/// tags WellEngine +bool WellEngine::del_object(WellObject* wo) +{ + ObjectList *plist=objectlist.del(wo); + if(plist) + { + delete plist; + return true; + } + return false; +} + +//=========================================================================== +/// global clear_objectlist() +/// clear all list of objects +/// tags WellEngine +void WellEngine::clear_objectlist() +{ + ObjectList *plist; + do + { + plist=objectlist.get_next(); + if(plist) + { + plist->del_self(); + delete plist; + } + } while(plist); +} + +//=========================================================================== +/// global load_images() +/// load all images for the game +/// tags WellEngine +void WellEngine::load_images() +{ + fprintf(stderr, "Loading resources.."); + load_image(imBoardBG, "board2.gif"); + fprintf(stderr, ".."); + load_image(imFont1, "font2.gif"); + fprintf(stderr, ".."); + load_image(imIntroBG, "wellintro.gif"); + fprintf(stderr, ".."); + load_image(imScoreBG, "topnine.gif"); + fprintf(stderr, ".."); + load_image(imCuts, "wellcuts.gif"); + fprintf(stderr, "..done\n"); +} + +//=========================================================================== +/// global new_well_intro() +/// creates new introduction object - version for SDL Window +/// tags WellEngine +WellIntro* WellEngine::new_well_intro() +{ + return new WellIntro; +} + +//=========================================================================== +/// global new_well_top_nine() +/// creates new top nine object +/// tags WellEngine +WellTopNine* WellEngine::new_well_top_nine() +{ + return new WellTopNine; +} + + +//=========================================================================== +/// global new_well_key(char*) +/// creates new key object +/// tags WellEngine +WellKey* WellEngine::new_well_key(char* name) +{ + return new WellKey(name); +} + +//=========================================================================== +/// global new_well_switch(char*) +/// creates new switch object +/// tags WellEngine +WellSwitch* WellEngine::new_well_switch(char* name) +{ + return new WellSwitch(name); +} + + +//=========================================================================== +/// global new_well_base() +/// creates new game object +/// tags WellEngine +WellBase* WellEngine::new_well_base() +{ + return new WellBase; +} + + + + + diff --git a/src/wellimagefont.cxx b/src/wellimagefont.cxx new file mode 100644 index 0000000..5850f3b --- /dev/null +++ b/src/wellimagefont.cxx @@ -0,0 +1,141 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: wellimagefont.cxx,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $ + +#include "wellimagefont.h" + +//=========================================================================== +/// global WellImageFont(Images id, unsigned int ifl, unsigned int ifh, int idx, int idy) +/// Constructor of base draw text class +/// tags WellImageFont +WellImageFont::WellImageFont(Images id, unsigned int ifl, unsigned int ifh, + int idx, int idy) +{ + font_id=id; + font_l=ifl; + font_h=ifh; + dx=idx; + dy=idy; + text_l=0; +} + +//=========================================================================== +/// global set_font(...) +/// setting font params +/// tags WellImageFont +void WellImageFont::set_font(unsigned int ifl, unsigned int ifh, + int idx, int idy) +{ + font_l=ifl; + font_h=ifh; + dx=idx; + dy=idy; +} + +//=========================================================================== +/// global set_text(char*) +/// setting text for output +/// tags WellImageFont +void WellImageFont::set_text(char* itext) +{ + strcpy(text,itext); + text_l=strlen(text); +} + + +//=========================================================================== +/// global set_screen_region(int ix, int iy, int il, int ih) +/// setting text for output +/// tags WellImageFont +void WellImageFont::set_screen_region(int ix, int iy, int il, int ih) +{ + screen_x=ix; + screen_y=iy; + screen_l=il; + screen_h=ih; +} + + +//=========================================================================== +/// global draw_text(Justify just) +/// draw text with given justification +/// tags WellImageFont +void WellImageFont::draw_text(Justify just) +{ + draw_text(text,text_l,just); +} + +//=========================================================================== +/// global draw_text(char *text, int text_l, Justify just) +/// draw text with given justification +/// tags WellImageFont +void WellImageFont::draw_text(char* txt, int txt_l, Justify just) +{ + int i,draw_x; + unsigned int draw_h; + + clear_region(); + if(txt_l<=0) + return; + + switch(just) + { + case LeftJust: + draw_x=screen_x; + break; + case RightJust: + draw_x=screen_x+screen_l-txt_l*font_l; + break; + case CenterJust: + draw_x=screen_x+(screen_l-txt_l*font_l)/2; + break; + } + draw_h=(screen_hnew_well_image_font(imFont1,FONT2_L,FONT2_H, + FONT2_DX,FONT2_DY); + fnt->set_screen_region(geo[1].tox, geo[1].toy, geo[1].l, geo[1].h); +} + + +//=========================================================================== +/// global process_event(wEvent) +/// stub that process events +/// tags WellInput +bool WellInput::process_event(wEvent ev) +{ + switch(ev.type) + { + case eKeyPress: + dbgprintf(("WellInput - done\n")); + object_on_enter.call(wEvent(aInputDone,this)); + return false; + + } + return true; +} + +//=========================================================================== +/// global highlight(int mx, int my) +/// highlights key +/// tags WellInput +void WellInput::set_text(char* txt) +{ + if(txt) + { + strcpy(buf,txt); + buflen=strlen(buf); + if(buflen>maxlen) + buflen=maxlen; + buf[buflen]=0; + pos=buflen; + } else + { + buflen=pos=0; + buf[buflen]=0; + } +} + + +//=========================================================================== +/// global draw_text() +/// draw text on the screen +/// tags WellInput +void WellInput::draw_text() +{ + fnt->draw_text(buf,buflen,BackColor); +} + +//=========================================================================== +/// global show() +/// show object +/// tags WellInput +void WellInput::show() +{ + shown=true; + redraw(); + default_well_engine->add_object(this); +} + +//=========================================================================== +/// global redraw() +/// redraw object +/// tags WellInput +void WellInput::redraw() +{ + if(shown) + { + default_well_engine->screen_copy(&geo[0]); + draw_text(); + } +} + +//=========================================================================== +/// global hide() +/// hide object +/// tags WellInput +void WellInput::hide() +{ + shown=false; + default_well_engine->screen_clear(&geo[0]); + default_well_engine->del_object(this); +} + + diff --git a/src/wellintro.cxx b/src/wellintro.cxx new file mode 100644 index 0000000..0b86e6b --- /dev/null +++ b/src/wellintro.cxx @@ -0,0 +1,472 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: wellintro.cxx,v 1.3 2003/02/27 08:27:51 leo Exp $ + +/// module description +/// WellIntro class - implements Introduction screen with options switches +/// new game, top nine and exit keys + +#include "wellclass.h" +#include "wellintro.h" +#include "wellengine.h" +#include "welltopnine.h" +#include "version.h" + +//=========================================================================== +/// global WellIntro() +/// constructor - fill table +/// tags WellIntro +WellIntro::WellIntro() : WellObject() +{ + int i; + char buf[L_MAXPATH]; + start_level=0; + txt_level=default_well_engine->new_well_image_font(imFont1,FONT3_L,FONT3_H, + FONT3_DX,FONT3_DY); + txt_level->set_screen_region(674,403,34,20); + + key_exit=default_well_engine->new_well_key("intro_key_exit"); + key_new_game=default_well_engine->new_well_key("intro_key_new_game"); + key_top_nine=default_well_engine->new_well_key("intro_key_top_nine"); + key_plus=default_well_engine->new_well_key("intro_key_plus"); + key_minus=default_well_engine->new_well_key("intro_key_minus"); + + key_exit->set_object_on_press(ObjectCaller(this,&WellObject::hide_by_call)); + key_new_game->set_object_on_press(ObjectCaller(this,&WellObject::hide_by_call)); + key_top_nine->set_object_on_press(ObjectCaller(this,&WellObject::hide_by_call)); + key_plus->set_object_on_press(ObjectCaller(this,&WellObject::process_event)); + key_minus->set_object_on_press(ObjectCaller(this,&WellObject::process_event)); + + sw_rotation=default_well_engine->new_well_switch("intro_sw_rotation"); + sw_rotation->set_object_on_switch(ObjectCaller(this, + &WellObject::process_event)); + sw_next_piece=default_well_engine->new_well_switch("intro_sw_next"); + sw_next_piece->set_object_on_switch(ObjectCaller(this, + &WellObject::process_event)); + sw_mixed=default_well_engine->new_well_switch("intro_sw_mixed"); + sw_mixed->set_object_on_switch(ObjectCaller(this, + &WellObject::process_event)); + for(i=0;inew_well_switch(buf); + sw_squares[i]->set_object_on_switch(ObjectCaller(this, + &WellObject::process_event)); + sw_squares[i]->set_mode(OnlySet); + } + + inp_player=default_well_engine->new_well_input("intro_inp_player"); + inp_player->set_object_on_enter(ObjectCaller(this, + &WellObject::hide_by_call)); + inp_player->set_max_len(PLAYER_NAME_LEN-1); +} + + +//=========================================================================== +/// global process_event(wEvent) +/// stub that process events +/// tags WellIntro +bool WellIntro::process_event(wEvent ev) +{ + int i; + WellObject* wo=(WellObject*)ev.data; + + switch(ev.type) + { + case eExpose: + redraw(); + break; + case eKeyPress: + hide_by_call(wEvent(aKeyPressed,key_new_game)); + return false; + + case aKeyPressed: + if(wo==key_plus && start_level+10) + { + start_level--; + draw_start_level(); + return true; + } + break; + + case aSwitchChanged: + if(wo==sw_rotation) + { + well->set_rotation(sw_rotation->get_value()); + break; + } + if(wo==sw_next_piece) + { + well->set_next_piece(sw_next_piece->get_value()); + break; + } + if(wo==sw_mixed) + { + well->set_mixed(sw_mixed->get_value()); + break; + } + for(i=0;iset_squares(MIN_SQUARES+i); + } else + sw_squares[i]->set_value(false); + break; + } + return true; +} + +//=========================================================================== +/// global show() +/// show object +/// tags WellIntro +void WellIntro::show() +{ + + dbgprintf(("WellIntro::show() called\n")); + default_well_engine->set_main_background_image(imIntroBG); + default_well_engine->add_object(this); + key_exit->show(); + key_new_game->show(); + key_top_nine->show(); + key_plus->show(); + key_minus->show(); + sw_rotation->show(); + sw_next_piece->show(); + sw_mixed->show(); + for(int i=0;ishow(); + draw_start_level(); + shown=true; +} + +//=========================================================================== +/// global hide() +/// hide object (empty) +/// tags WellIntro +void WellIntro::hide() +{ + if(shown) + { + shown=false; + default_well_engine->del_object(this); + key_exit->hide(); + key_new_game->hide(); + key_top_nine->hide(); + key_plus->hide(); + key_minus->hide(); + sw_rotation->hide(); + sw_next_piece->hide(); + sw_mixed->hide(); + for(int i=0;ihide(); + } +} + + +//=========================================================================== +/// global hide_by_call() +/// hide object +/// tags WellIntro +bool WellIntro::hide_by_call(wEvent ev) +{ + WellObject* wo=(WellObject*)ev.data; + + hide(); + + put_all_to_game(); + save_options(); + + if(wo==inp_player) + { + inp_player->hide(); + return object_on_new_game.call(wEvent(aIntroExit,this)); + } + + if(wo==key_exit) + { + default_well_engine->done_loop(); + return true; + } + + if(wo==key_new_game) + { + inp_player->show(); + } + + if(wo==key_top_nine) + { + return object_on_top_nine.call(wEvent(aIntroExit,this)); + } + + return true; +} + + +//=========================================================================== +/// global draw_start_level() +/// draw start level on the screen +/// tags WellIntro +void WellIntro::draw_start_level() +{ + char buf[L_MAXPATH]; + sprintf(buf,"%02d",start_level); + txt_level->set_text(buf); + txt_level->draw_text(); + well->set_level(start_level); +} + + +//=========================================================================== +/// global redraw() +/// redraw all scene object +/// tags WellIntro +void WellIntro::redraw() +{ + draw_start_level(); + key_exit->redraw(); + key_new_game->redraw(); + key_top_nine->redraw(); + key_plus->redraw(); + key_minus->redraw(); + sw_rotation->redraw(); + sw_next_piece->redraw(); + sw_mixed->redraw(); + for(int i=0;iredraw(); +} + +//=========================================================================== +/// global put_all_to_game() +/// put all values to the game +/// tags WellIntro +void WellIntro::put_all_to_game() +{ + int i; + well->set_rotation(sw_rotation->get_value()); + well->set_mixed(sw_mixed->get_value()); + well->set_next_piece(sw_next_piece->get_value()); + well->set_level(start_level); + for(i=0;iget_value()) + { + well->set_squares(i+MIN_SQUARES); + default_top_nine->set_page(i+1); + dbgprintf(("Set top_nine page to %d\n",i+1)); + } + well->set_player_name(inp_player->get_text()); +} + + +//=========================================================================== +/// global load_defaults() +/// set default values and try to load it from file +/// tags WellIntro +void WellIntro::load_defaults() +{ + sw_rotation->set_value(true); + sw_mixed->set_value(true); + sw_next_piece->set_value(true); + start_level=0; + sw_squares[4-MIN_SQUARES]->set_value(true); + inp_player->set_text(getenv("USER")); + + load_options(); + + put_all_to_game(); +} + +//=========================================================================== +/// global set_well_base(WellBase*) +/// set pointer to the game object, loads and set default values +/// tags WellIntro +void WellIntro::set_well_base(WellBase* o) +{ + well=o; + load_defaults(); +} + +//=========================================================================== +/// global save_options() +/// save options to file +/// tags WellIntro +void WellIntro::save_options() +{ + int i; + char fname[L_MAXPATH]; + FILE *fp; +#ifndef WIN32 + sprintf(fname,"%s/%s",getenv("HOME"),XWELL_DIR); + mkdir(fname,0755); + sprintf(fname,"%s/%s/%s",getenv("HOME"),XWELL_DIR,RC_FILE); +#else + sprintf(fname,"data\\%s", RC_FILE); +#endif + fp=fopen(fname, "w"); + if(fp==0) + { + fprintf(stderr,"Error in opening resource file for writing:\n\t%s\n", + strerror(errno)); + return; + } + + fprintf(fp,"#--------------- Options file for xwelltris %s ----------------#\n",VERSION); + fprintf(fp,"#This file generated automatically, so don't edit it by hands\n\n"); + fprintf(fp, "last_player: %s\n",inp_player->get_text()); + if(sw_rotation->get_value()) + fprintf(fp,"use_rotation: yes\n"); + else + fprintf(fp,"use_rotation: no\n"); + + if(sw_mixed->get_value()) + fprintf(fp,"use_mixed: yes\n"); + else + fprintf(fp,"use_mixed: no\n"); + + if(sw_next_piece->get_value()) + fprintf(fp,"use_next_piece: yes\n"); + else + fprintf(fp,"use_next_piece: no\n"); + + fprintf(fp, "start_level: %d\n",start_level); + + for(i=0;iget_value()) + break; + fprintf(fp, "tris_squares: %d\n", i+MIN_SQUARES); + fprintf(fp,"#------------------ End of file ---------------------#\n"); + + fclose(fp); +} + +//=========================================================================== +/// global load_options() +/// load options from file +/// tags WellIntro +void WellIntro::load_options() +{ + int i,n; + char fname[L_MAXPATH]; + char buf[L_MAXPATH]; + char tok[L_MAXPATH], *pbuf; + FILE* fp; +#ifndef WIN32 + sprintf(fname,"%s/%s/%s",getenv("HOME"),XWELL_DIR,RC_FILE); +#else + sprintf(fname,"data\\%s",RC_FILE); +#endif + fp=fopen(fname, "r"); + if(fp==0) + return; + + while(fgets(buf,L_MAXPATH-1,fp)) + { + if(buf[0]=='#') + continue; + + pbuf=get_next_token(buf,tok); + if(!strcmp(tok,"use_rotation")) + { + get_next_token(pbuf,tok); + if(!strcmp(tok,"yes")) + sw_rotation->set_value(true); + else + sw_rotation->set_value(false); + continue; + } + + if(!strcmp(tok,"use_mixed")) + { + get_next_token(pbuf,tok); + if(!strcmp(tok,"yes")) + sw_mixed->set_value(true); + else + sw_mixed->set_value(false); + continue; + } + + if(!strcmp(tok,"use_next_piece")) + { + get_next_token(pbuf,tok); + if(!strcmp(tok,"yes")) + sw_next_piece->set_value(true); + else + sw_next_piece->set_value(false); + continue; + } + + if(!strcmp(tok,"last_player")) + { + get_next_token(pbuf,tok); + inp_player->set_text(tok); + continue; + } + + if(!strcmp(tok,"start_level")) + { + get_next_token(pbuf,tok); + start_level=atoi(tok); + if(start_level<0 || start_level>=NUM_LEVELS) + start_level=0; + continue; + } + + if(!strcmp(tok,"tris_squares")) + { + get_next_token(pbuf,tok); + n=atoi(tok); + n-=MIN_SQUARES; + if(n<0 || n>=TOTAL_SQUARES) + n=0; + for(i=0;iset_value(n==i ? true : false); + continue; + } + } + fclose(fp); +} + +//=========================================================================== +/// global get_next_token(char* from, char* to) +/// cut buffer by tokens +/// tags WellIntro +char* WellIntro::get_next_token(char* from, char* to) +{ + int delta=0; + char *orig_to=to; + *to=0; + if(*from==':') + from++; + while(*from==' ') + from++; + while(*from!=0 && *from!=':' && *from!='\n' && *from!='\r' && *from!=0) + *to++=*from++; + while(to!=orig_to && *to==' ') + { + to--; + delta=1; + } + to+=delta; + *to=0; + return from; +} + diff --git a/src/wellkey.cxx b/src/wellkey.cxx new file mode 100644 index 0000000..5e6074b --- /dev/null +++ b/src/wellkey.cxx @@ -0,0 +1,145 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: wellkey.cxx,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $ + +/// module description +/// WellKey class implements key (or button) GUI element. It draw key with +/// given images (uses geometry module) then catches mouse events and calls +/// ObjectCaller on press. + +#include "globals.h" +#include "wellkey.h" +#include "wellengine.h" + +//////////////////////////////WellKey class/////////////////////////////// + +//=========================================================================== +/// global WellKey(char*) +/// constructor - fill name and get geometry +/// tags WellKey +WellKey::WellKey(char* iname) : WellObject() +{ + strncpy(object_name,iname,GEO_NAME); + object_name[GEO_NAME]=0; + geo=get_geo_by_name(object_name); +} + + +//=========================================================================== +/// global process_event(wEvent) +/// stub that process events +/// tags WellKey +bool WellKey::process_event(wEvent ev) +{ + MouseEvent *pmev; + switch(ev.type) + { + case eKeyPress: + dbgprintf(("WellKey - pressed\n")); + object_on_press.call(wEvent(aKeyPressed,this)); + return false; + + case eMousePress: + pmev=(MouseEvent*)ev.data; + return !press(pmev->mx,pmev->my); + + case eMouseMove: + pmev=(MouseEvent*)ev.data; + return !highlight(pmev->mx,pmev->my); + + } + return true; +} + +//=========================================================================== +/// global highlight(int mx, int my) +/// highlights key +/// tags WellKey +bool WellKey::highlight(int mx, int my) +{ + if(mx>=geo[1].tox && my>=geo[1].toy && + mxscreen_copy(&geo[1]); //highlighted state + return true; + } + } else + { + if(highlighted) + { + highlighted=false; + dbgprintf(("WellKey DEhighlighted via mouse\n")); + default_well_engine->screen_copy(&geo[0]); //normal state + return true; + } + } + return false; +} + +//=========================================================================== +/// global press(int mx, int my) +/// press key and call object +/// tags WellKey +bool WellKey::press(int mx, int my) +{ + if(mx>=geo[2].tox && my>=geo[2].toy && + mxscreen_copy(&geo[2]); //highlighted state + object_on_press.call(wEvent(aKeyPressed,this)); + return true; + } + return false; +} + +//=========================================================================== +/// global show() +/// show object +/// tags WellKey +void WellKey::show() +{ + shown=true; + redraw(); + default_well_engine->add_object(this); +} + +//=========================================================================== +/// global redraw() +/// redraw object +/// tags WellKey +void WellKey::redraw() +{ + if(shown) + default_well_engine->screen_copy(&geo[0]); +} + +//=========================================================================== +/// global hide() +/// hide object +/// tags WellKey +void WellKey::hide() +{ + shown=false; + default_well_engine->screen_clear(&geo[0]); + default_well_engine->del_object(this); +} + + diff --git a/src/wellsimpledraw.cxx b/src/wellsimpledraw.cxx new file mode 100644 index 0000000..8496ce5 --- /dev/null +++ b/src/wellsimpledraw.cxx @@ -0,0 +1,113 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: wellsimpledraw.cxx,v 1.2 2003/02/19 09:51:39 leo Exp $ + +/// module description +/// WellSimpleDrawing - class that implements simple drawing algorithm +/// with dirty rectangles + +#include "wellsimpledraw.h" + +//=========================================================================== +/// global WellSimpleDraw() +/// constructor of the class - init's variables. +/// tags WellSimpleDraw +WellSimpleDraw::WellSimpleDraw() +{ + max_dirties=0; +} + +//=========================================================================== +/// global ~WellSimpleDraw() +/// destructor of the class. +/// tags WellSimpleDraw +WellSimpleDraw::~WellSimpleDraw() +{ + clear_dirty_list(); +} + +//=========================================================================== +/// global new_dirty_rec(int dx, int dy) +/// create new dirty rec and remember delta position for main screen +/// tags WellSimpleDraw +void WellSimpleDraw::new_dirty_rec(int dx, int dy) +{ + current_dirty.delta_x=dx; + current_dirty.delta_y=dy; + max_x=max_y=-1; + min_x=min_y=99999; //Hope we will never have screen bigger :) +} + +//=========================================================================== +/// global dirty_add_xy(int x, int y) +/// we add dot to current dirty rec - need detect max and min corners +/// tags WellSimpleDraw +void WellSimpleDraw::dirty_add_xy(int x, int y) +{ + if(xmax_x) + max_x=x; + if(ymax_y) + max_y=y; +} + +//=========================================================================== +/// global finish_dirty_rec() +/// finish dots definition of current dirty rec - add it to the dirty queue +/// tags WellSimpleDraw +void WellSimpleDraw::finish_dirty_rec() +{ + current_dirty.x=min_x; + current_dirty.y=min_y; + current_dirty.l=max_x-min_x+1; + current_dirty.h=max_y-min_y+1; + DirtyList *plist=new DirtyList(current_dirty); + dirty_list.add(plist); + max_dirties++; +} + +//=========================================================================== +/// global clear_dirty_list() +/// clear all the list and free allocated memory +/// tags WellSimpleDraw +void WellSimpleDraw::clear_dirty_list() +{ + DirtyList *plist; + do + { + plist=dirty_list.get_next(); + if(plist) + { + plist->del_self(); + delete plist; + } + } while(plist); + max_dirties=0; +} + +//=========================================================================== +/// global dirty_add_rec(DirtyRect r) +/// directly add the whole rec to the dirty queue +/// tags WellSimpleDraw +void WellSimpleDraw::dirty_add_rec(DirtyRect r) +{ + DirtyList *plist=new DirtyList(r); + dirty_list.add(plist); + max_dirties++; +} diff --git a/src/wellswitch.cxx b/src/wellswitch.cxx new file mode 100644 index 0000000..b5b0d6d --- /dev/null +++ b/src/wellswitch.cxx @@ -0,0 +1,157 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: wellswitch.cxx,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $ + +/// module description +/// WellSwitch class implements Switch GUI element, it can be set or reset, +/// uses for switching options + +#include "globals.h" +#include "wellswitch.h" +#include "wellengine.h" + +//////////////////////////////WellSwitch class/////////////////////////////// + +//=========================================================================== +/// global WellSwitch(char*) +/// constructor - fill name and get geometry +/// tags WellSwitch +WellSwitch::WellSwitch(char* iname) : WellObject() +{ + strncpy(object_name,iname,GEO_NAME); + object_name[GEO_NAME]=0; + geo=get_geo_by_name(object_name); + value=false; + mode=SetReset; +} + + +//=========================================================================== +/// global process_event(wEvent) +/// stub that process events +/// tags WellSwitch +bool WellSwitch::process_event(wEvent ev) +{ + MouseEvent *pmev; + switch(ev.type) + { + case eMousePress: + pmev=(MouseEvent*)ev.data; + return !press(pmev->mx,pmev->my); + + case eMouseMove: + pmev=(MouseEvent*)ev.data; + return !highlight(pmev->mx,pmev->my); + + } + return true; +} + +//=========================================================================== +/// global highlight(int mx, int my) +/// highlights key +/// tags WellSwitch +bool WellSwitch::highlight(int mx, int my) +{ + if(mx>=geo[1].tox && my>=geo[1].toy && + mxscreen_copy(&geo[1]); //highlighted state + return true; + } + } else + { + if(highlighted) + { + highlighted=false; + dbgprintf(("WellSwitch DEhighlighted via mouse\n")); + redraw(); + return true; + } + } + return false; +} + +//=========================================================================== +/// global press(int mx, int my) +/// press key and call object +/// tags WellSwitch +bool WellSwitch::press(int mx, int my) +{ + if(mx>=geo[1].tox && my>=geo[1].toy && + mxadd_object(this); +} + +//=========================================================================== +/// global redraw() +/// redraw object +/// tags WellSwitch +void WellSwitch::redraw() +{ + if(shown) + { + default_well_engine->screen_copy(&geo[0]); //normal state + if(value) + default_well_engine->screen_copy(&geo[2]); //value state + else + default_well_engine->screen_clear(&geo[2]); //value state + } +} + +//=========================================================================== +/// global hide() +/// hide object +/// tags WellSwitch +void WellSwitch::hide() +{ + shown=false; + default_well_engine->screen_clear(&geo[0]); + default_well_engine->del_object(this); +} + + diff --git a/src/welltopnine.cxx b/src/welltopnine.cxx new file mode 100644 index 0000000..218f038 --- /dev/null +++ b/src/welltopnine.cxx @@ -0,0 +1,487 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: welltopnine.cxx,v 1.3 2003/02/23 06:33:40 leo Exp $ +#include "welltopnine.h" +#include "wellengine.h" +#include "commonfuncs.h" + +WellTopNine *default_top_nine; + +//=========================================================================== +/// global Score() +/// constructor, set all to zeros and current date +/// tags Score +Score::Score() +{ + player[0]=date_time[0]=0; + level=score=lines=squares=play_time=0; + mixed=rotation=next_piece=false; + set_current_time(); +} + +//=========================================================================== +/// global get_next_token(char* from, char* to) +/// cut buffer by tokens +/// tags Score +char* Score::get_next_token(char* from, char* to) +{ + int delta=0; + char *orig_to=to; + *to=0; + if(*from==';') + from++; + while(*from==' ') + from++; + while(*from!=0 && *from!=';' && *from!='\n' && *from!='\r' && *from!=0) + *to++=*from++; + while(to!=orig_to && *to==' ') + { + to--; + delta=1; + } + to+=delta; + *to=0; + return from; +} + +//=========================================================================== +/// global save(FILE*) +/// save score_line to file +/// tags Score +void Score::save(FILE* fp) +{ + fprintf(fp,"%d;%-12s;%s;%8d;%5d;%2d;%d;%d;%d;%d\n", + squares,player,date_time,score,lines,level, + mixed ? 1 : 0, rotation ? 1 : 0,play_time, + next_piece ? 1 : 0); +} + +//=========================================================================== +/// global load(FILE*) +/// load score_line from file +/// tags Score +bool Score::load(FILE* fp) +{ + char buf[L_MAXPATH]; + char *ptr=buf; + char token[L_MAXPATH]; + while(1) + { + if(fgets(buf,L_MAXPATH-1,fp)==0) + return false; + if(buf[0]=='#') //Skipping comments + continue; + + //squares + ptr=get_next_token(ptr,token); + squares=atoi(token); + //player + ptr=get_next_token(ptr,token); + strncpy(player,token,PLAYER_NAME_LEN-1); + player[PLAYER_NAME_LEN-1]=0; + //date_time + ptr=get_next_token(ptr,token); + strncpy(date_time,token,L_DATE-1); + date_time[L_DATE-1]=0; + //score + ptr=get_next_token(ptr,token); + score=atoi(token); + //lines + ptr=get_next_token(ptr,token); + lines=atoi(token); + //level + ptr=get_next_token(ptr,token); + level=atoi(token); + //mixed + ptr=get_next_token(ptr,token); + mixed= atoi(token) ? true : false; + //rotation + ptr=get_next_token(ptr,token); + rotation= atoi(token) ? true : false; + //play_time + ptr=get_next_token(ptr,token); + play_time=atoi(token); + //rotation + ptr=get_next_token(ptr,token); + next_piece= atoi(token) ? true : false; + break; + } + dbgprintf(("scores: %d;%s;%s;%8d;%5d;%2d;%d;%d\n", + squares,player,date_time,score,lines,level, + mixed ? 1 : 0, rotation ? 1 : 0)); + return true; +} + +//=========================================================================== +/// global set_current_time() +/// set current date and time to date (format YYYY-MM-DD HH:MI) +/// tags Score +void Score::set_current_time() +{ + struct tm *time_str; + time(&start_t); + time_str=localtime(&start_t); + strftime(date_time,L_DATE,"%Y-%m-%d",time_str); +} + +//=========================================================================== +/// global calc_play_time() +/// calculate playing time from start_t till now +/// tags Score +void Score::calc_play_time() +{ + time_t now_t; + time(&now_t); + play_time=now_t - start_t; +} + +//=========================================================================== +/// global set_player(char* pl) +/// set player name +/// tags Score +void Score::set_player(char* name) +{ + if(name) + strncpy(player,name,PLAYER_NAME_LEN); + else + strcpy(player,"unknown"); + player[PLAYER_NAME_LEN-1]=0; +} + +//////////////////////////ScoreTable struct methods///////////////////////// + + + +//=========================================================================== +/// global ScoreTable() +/// constructor of scoretable +/// tags ScoreTable +ScoreTable::ScoreTable() +{ + int i; + for(i=0;iplace=i+1; + } +} + +//=========================================================================== +/// global ~ScoreTable() +/// destructor of scoretable +/// tags ScoreTable +ScoreTable::~ScoreTable() +{ + int i; + for(i=0;iplace=i+1; + + for(j=0;jscorescore) + { + ptr=table[i]; + table[i]=table[j]; + table[j]=ptr; + + table[j]->place=j+1; + table[i]->place=i+1; + } +} + +//=========================================================================== +/// global save(FILE* fp) +/// save table to give file descr +/// tags ScoreTable +void ScoreTable::save(FILE* fp) +{ + int i; + for(i=0;isave(fp); +} + +//=========================================================================== +/// global set_squares(int isquare) +/// set squares to given number +/// tags ScoreTable +void ScoreTable::set_squares(int isquares) +{ + int i; + for(i=0;isquares=isquares; +} + +//=========================================================================== +/// global set_and_get(int idx,Score*) +/// set new Score and get old one. If new == 0 just return old +/// tags ScoreTable +Score* ScoreTable::set_and_get(int idx, Score* new_one) +{ + Score *old_one; + if(idx<0 || idx>=TOP_NINE) + return new_one; + + old_one=table[idx]; + if(new_one) + { + table[idx]=new_one; + table[idx]->place=idx+1; + } + return old_one; +} + + + + +//////////////////////////////WellTopNine class/////////////////////////////// + + + +//=========================================================================== +/// global WellTopNine() +/// constructor - fill table +/// tags WellTopNine +WellTopNine::WellTopNine() : WellObject() +{ + int i; + current_score=0; + page=3; + + geo=get_geo_by_name("top_nine_elements"); + + for(i=0;inew_well_image_font(imFont1, + FONT3_L,FONT3_H, + FONT3_DX,FONT3_DY); + text_lines[i]->set_screen_region(TOPNINE_TXT_X, + TOPNINE_TXT_Y + i*TOPNINE_TXT_STEPY, + TOPNINE_TXT_L,TOPNINE_TXT_H); + } + key_exit=default_well_engine->new_well_key("top_key_exit"); + key_exit->set_object_on_press(ObjectCaller(this,&WellObject::hide_by_call)); +} + +//=========================================================================== +/// global save_scores() +/// save score table to file +/// tags WellTopNine +bool WellTopNine::save_scores() +{ + int i; + char fname[L_MAXPATH]; + + if(!find_full_path_for_file(SCOREFILE,fname,ReadWrite)) + { +#ifndef WIN32 + sprintf(fname, "%s/.xwelltris",getenv("HOME")); + mkdir(fname,0755); + strcat(fname,"/"); + strcat(fname,SCOREFILE); +#endif + } + + FILE* fp=fopen(fname,"w"); + if(!fp) + { + fprintf(stderr,"PANIC: can't save scores file: %s - %s\n", + fname,strerror(errno)); + return false; + } + for(i=0;iload(fp)) + { + i=pscore->squares-1; + pscore=tables[i].set_and_get(idx[i],pscore); + idx[i]++; + } + fclose(fp); + + for(i=0;isquares-1; + current_score=new_one; + if(tables[page].table[TOP_NINE-1]->score < new_one->score) + { + pscore=tables[page].table[TOP_NINE-1]; + tables[page].table[TOP_NINE-1]=new_one; + tables[page].sort_by_score(); + return pscore; + } + return new_one; +} + +//=========================================================================== +/// global find_challenger(Score* me) +/// Find challenger, whose score > than mine +// return 0 if you are the first +/// tags WellTopNine +Score* WellTopNine::find_challenger(Score* me) +{ + int i; + ScoreTable *pcur; + + if(me==0) + return 0; + pcur= &tables[me->squares-1]; + for(i=TOP_NINE-1;i>=0;i--) + if(pcur->table[i]->score > me->score) + return pcur->table[i]; + return 0; +} + + +//=========================================================================== +/// global process_event(wEvent) +/// stub that process events (empty here) +/// tags WellTopNine +bool WellTopNine::process_event(wEvent) +{ + return true; +} + +//=========================================================================== +/// global show() +/// stub that show object (empty) +/// tags WellTopNine +void WellTopNine::show() +{ + key_exit->show(); + default_well_engine->set_main_background_image(imScoreBG); + default_well_engine->add_object(this); + redraw_table(); + shown=true; + save_scores(); +} + +//=========================================================================== +/// global hide() +/// stub that hide object (empty) +/// tags WellTopNine +void WellTopNine::hide() +{ + shown=false; + default_well_engine->del_object(this); + key_exit->hide(); + object_on_exit.call(wEvent(aEmpty,this)); +} + +//=========================================================================== +/// global redraw_table() +/// redraw all data for score table according to current_score and page +/// tags WellTopNine +void WellTopNine::redraw_table() +{ + int i,j; + char buf[L_MAXPATH]; + Score *pscore; + + for(i=0;iplace,pscore->player,pscore->date_time, + pscore->score,pscore->lines,pscore->level); + if(pscore!=current_score) + { + text_lines[i]->set_font(FONT3_L,FONT3_H, + FONT3_DX,FONT3_DY); + text_lines[i]->set_screen_region(TOPNINE_TXT_X, + TOPNINE_TXT_Y + i*TOPNINE_TXT_STEPY, + TOPNINE_TXT_L,TOPNINE_TXT_H); + } else + { + dbgprintf(("Highlighting item %d\n",i)); + text_lines[i]->set_font(FONT5_L,FONT5_H, + FONT5_DX,FONT5_DY); + text_lines[i]->set_screen_region(TOPNINE_TXT_X, + TOPNINE_TXT_Y + i*TOPNINE_TXT_STEPY, + TOPNINE_TXT_L,TOPNINE_TXT_H); + } + text_lines[i]->set_text(buf); + text_lines[i]->draw_text(); + for(j=0;j<3;j++) + { + geo[j].toy=TOPNINE_TXT_Y + i*TOPNINE_TXT_STEPY - 2; + } + if(pscore->rotation) + default_well_engine->screen_copy(&geo[0]); + if(pscore->next_piece) + default_well_engine->screen_copy(&geo[1]); + if(pscore->mixed) + default_well_engine->screen_copy(&geo[2]); + } +} diff --git a/src/x11/xheaders.h b/src/x11/xheaders.h new file mode 100644 index 0000000..37883b2 --- /dev/null +++ b/src/x11/xheaders.h @@ -0,0 +1,9 @@ + +#include +#include +#include +#include +#include + + + diff --git a/src/x11/xwelldrawing.cxx b/src/x11/xwelldrawing.cxx new file mode 100644 index 0000000..30ecae4 --- /dev/null +++ b/src/x11/xwelldrawing.cxx @@ -0,0 +1,457 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: xwelldrawing.cxx,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $ + +/// module description +/// X11 implementation of WellDrawing class - drawing routines for the game. +/// Draw field on pixmap, then maps it to the screen. Uses dirty rectangles +/// algorithm for mapping areas to screen from pixmap + +#include "xwelldrawing.h" +#include "xwellengine.h" + +//=========================================================================== +/// global XWellDrawingEngine() +/// constructor of the class - init's variables. +/// tags XWellDrawingEngine +XWellDrawingEngine::XWellDrawingEngine(XWellEngine* myengine) +{ + xengine=myengine; + if(xengine==0) + xengine=static_cast(default_well_engine); + mainw=xengine->get_main_window(); + colors=xengine->get_colors(); + scr=DefaultScreen(disp); +} + +//=========================================================================== +/// global init(int n_fields, int idx, int idy, unsigned il, unsigned ih) +/// init fields - creates x pixmaps and gcs +/// tags XWellDrawingEngine +void XWellDrawingEngine::init(int inum_fields, int idx, int idy, + unsigned int il, unsigned int ih) +{ + int i; + WellDrawingEngine::init(inum_fields,idx,idy,il,ih); + fields=new Pixmap; + gcs=new GC; + maingc=XCreateGC(disp,mainw,0,0); + XSetBackground(disp,maingc,colors[BackColor]); + XSetForeground(disp,maingc,colors[GridColor]); + XSetGraphicsExposures(disp,maingc,False); + + for(i=0;i<1;i++) + { + fields[i]=XCreatePixmap(disp,mainw,l,h,DefaultDepth(disp,scr)); + if(fields[i]>0) + { + gcs[i]=XCreateGC(disp,fields[i],0,0); + XSetBackground(disp,gcs[i],colors[FreezeColor]); + clear_field(i); + } + } +} + +//=========================================================================== +/// global draw_square(int color_idx, int i, int j) +/// Draw square (floor polygon) on all fields with given color +/// tags XWellDrawingEngine +void XWellDrawingEngine::draw_square(int color, int i, int j) +{ + int idx=current_id,sign_x13,sign_y13,sign_x24,sign_y24; + + XSetForeground(disp,*gcs,colors[color]); + + sign_x13= points[idx].base_points[i+1][j+1].x - + points[idx].base_points[i][j].x; + sign_x13= sign_x13 ? (sign_x13>0 ? 1 : -1) : 0; + + sign_y13= points[idx].base_points[i+1][j+1].y - + points[idx].base_points[i][j].y; + sign_y13= sign_y13 ? (sign_y13>0 ? 1 : -1) : 0; + + sign_x24= points[idx].base_points[i][j+1].x - + points[idx].base_points[i+1][j].x; + sign_x24= sign_x24 ? (sign_x24>0 ? 1 : -1) : 0; + + sign_y24= points[idx].base_points[i][j+1].y - + points[idx].base_points[i+1][j].y; + sign_y24= sign_y24 ? (sign_y24>0 ? 1 : -1) : 0; + + trapazoid_list[0].x = points[idx].base_points[i][j].x+sign_x13; + trapazoid_list[0].y = points[idx].base_points[i][j].y+sign_y13; + trapazoid_list[1].x = points[idx].base_points[i+1][j].x+sign_x24; + trapazoid_list[1].y = points[idx].base_points[i+1][j].y+sign_y24; + trapazoid_list[2].x = points[idx].base_points[i+1][j+1].x-sign_x13; + trapazoid_list[2].y = points[idx].base_points[i+1][j+1].y-sign_y13; + trapazoid_list[3].x = points[idx].base_points[i][j+1].x-sign_x24; + trapazoid_list[3].y = points[idx].base_points[i][j+1].y-sign_y24; + XFillPolygon (disp, *fields, *gcs, trapazoid_list, MAX_SIDES, + Convex, CoordModeOrigin); + //Now draw the grid + trapazoid_list[0].x = points[idx].base_points[i][j].x; + trapazoid_list[0].y = points[idx].base_points[i][j].y; + trapazoid_list[1].x = points[idx].base_points[i+1][j].x; + trapazoid_list[1].y = points[idx].base_points[i+1][j].y; + trapazoid_list[2].x = points[idx].base_points[i+1][j+1].x; + trapazoid_list[2].y = points[idx].base_points[i+1][j+1].y; + trapazoid_list[3].x = points[idx].base_points[i][j+1].x; + trapazoid_list[3].y = points[idx].base_points[i][j+1].y; + XSetForeground(disp,*gcs,colors[GridColor2]); + XDrawLines(disp, *fields, *gcs, trapazoid_list, MAX_SIDES, CoordModeOrigin); + + new_dirty_rec(delta_x,delta_y); + dirty_add_xy(trapazoid_list[0].x,trapazoid_list[0].y); + dirty_add_xy(trapazoid_list[1].x,trapazoid_list[1].y); + dirty_add_xy(trapazoid_list[2].x,trapazoid_list[2].y); + dirty_add_xy(trapazoid_list[3].x,trapazoid_list[3].y); + finish_dirty_rec(); +} + +//=========================================================================== +/// global draw_trapazoid(int color_idx, int i,int j) +/// draw trapazoid - wall polygon with given color +/// tags XWellDrawingEngine +void XWellDrawingEngine::draw_trapazoid(int color, int i, int j) +{ + Window win; + GC gc; + int idx=current_id,w,sign_x13,sign_y13,sign_x24,sign_y24; + + unsigned long rcolor=colors[color]; + + win=*fields; + gc=*gcs; + XSetForeground(disp,gc,rcolor); + + sign_x13= points[idx].wall_points[i+1][j+1].x - + points[idx].wall_points[i][j].x; + sign_x13= sign_x13 ? (sign_x13>0 ? 1 : -1) : 0; + + sign_y13= points[idx].wall_points[i+1][j+1].y - + points[idx].wall_points[i][j].y; + sign_y13= sign_y13 ? (sign_y13>0 ? 1 : -1) : 0; + + sign_x24= points[idx].wall_points[i][j+1].x - + points[idx].wall_points[i+1][j].x; + sign_x24= sign_x24 ? (sign_x24>0 ? 1 : -1) : 0; + + sign_y24= points[idx].wall_points[i][j+1].y - + points[idx].wall_points[i+1][j].y; + sign_y24= sign_y24 ? (sign_y24>0 ? 1 : -1) : 0; + + /* + w=i/MAX_WIDTH; + dbgprintf(("trapazoid [%2d][%2d] = [%d - %d],[%d - %d]\n",i,j, + points[idx].wall_points[i+1][j+1].x, + points[idx].wall_points[i][j].x, + points[idx].wall_points[i+1][j+1].y, + points[idx].wall_points[i][j].y)); + + dbgprintf(("trapazoid2[%2d][%2d] = [%d - %d],[%d - %d]\n",i,j, + points[idx].wall_points[i][j+1].x, + points[idx].wall_points[i+1][j].x, + points[idx].wall_points[i][j+1].y, + points[idx].wall_points[i+1][j].y)); + dbgprintf(("trapazoid [%2d][%2d] = [%d][%d],[%d][%d]\n",i,j, + sign_x13,sign_y13,sign_x24,sign_y24)); + */ + + + trapazoid_list[0].x = points[idx].wall_points[i][j].x+sign_x13; + trapazoid_list[0].y = points[idx].wall_points[i][j].y+sign_y13; + trapazoid_list[1].x = points[idx].wall_points[i+1][j].x+sign_x24; + trapazoid_list[1].y = points[idx].wall_points[i+1][j].y+sign_y24; + trapazoid_list[2].x = points[idx].wall_points[i+1][j+1].x-sign_x13; + trapazoid_list[2].y = points[idx].wall_points[i+1][j+1].y-sign_y13; + trapazoid_list[3].x = points[idx].wall_points[i][j+1].x-sign_x24; + trapazoid_list[3].y = points[idx].wall_points[i][j+1].y-sign_y24; + XFillPolygon (disp, win, gc, trapazoid_list, MAX_SIDES, + Convex, CoordModeOrigin); + //Now draw the grid + trapazoid_list[0].x = points[idx].wall_points[i][j].x; + trapazoid_list[0].y = points[idx].wall_points[i][j].y; + trapazoid_list[1].x = points[idx].wall_points[i+1][j].x; + trapazoid_list[1].y = points[idx].wall_points[i+1][j].y; + trapazoid_list[2].x = points[idx].wall_points[i+1][j+1].x; + trapazoid_list[2].y = points[idx].wall_points[i+1][j+1].y; + trapazoid_list[3].x = points[idx].wall_points[i][j+1].x; + trapazoid_list[3].y = points[idx].wall_points[i][j+1].y; + XSetForeground(disp,gc,colors[GridColor]); + XDrawLines(disp, win, gc, trapazoid_list, MAX_SIDES, CoordModeOrigin); + if(idx==current_id) + { + new_dirty_rec(delta_x,delta_y); + dirty_add_xy(trapazoid_list[0].x,trapazoid_list[0].y); + dirty_add_xy(trapazoid_list[1].x,trapazoid_list[1].y); + dirty_add_xy(trapazoid_list[2].x,trapazoid_list[2].y); + dirty_add_xy(trapazoid_list[3].x,trapazoid_list[3].y); + finish_dirty_rec(); + } +} + +//=========================================================================== +/// global draw_grid() +/// draw grid - all wall and floor polygons +/// tags XWellDrawingEngine +void XWellDrawingEngine::draw_grid() +{ + int idx,i,j,k; + Window win; + GC gc; + idx=current_id; + + gc=*gcs; + win=*fields; + XSetForeground(disp,gc,colors[GridColor]); + for(i=0;iget_object(); + //Here we need to draw dirty rec on the screen -> will be in overloaded childs + XCopyArea(disp,win,mainw,maingc,drec.get_src_x(),drec.get_src_y(), + drec.l,drec.h, + drec.get_dest_x(),drec.get_dest_y()); + + plist->del_self(); + delete plist; + } + } while(plist); + XFlush(disp); +} + +//=========================================================================== +/// global key_to_action(void* event) +/// convert keys to actions in the game +/// tags XWellDrawingEngine +Actions XWellDrawingEngine::key_to_action(void* event) +{ + XEvent *ev=(XEvent*)event; + KeySym ks; + + ks=XLookupKeysym(&ev->xkey, 0); + switch(ks) + { + case XK_KP_Left: + case XK_KP_4: + case XK_Left: + case XK_j: + case XK_J: + return RIGHT; + + case XK_KP_Right: + case XK_KP_6: + case XK_Right: + case XK_l: + case XK_L: + return LEFT; + + case XK_Up: + case XK_Down: + case XK_KP_Begin: + case XK_KP_5: + case XK_k: + case XK_K: + return ROTATE; + + case XK_space: + case XK_KP_0: + case XK_KP_Insert: + return DROP; + + case XK_Pause: + case XK_p: + case XK_P: + return PAUSE_GAME; + + case XK_F10: + case XK_q: + case XK_Q: + case XK_Escape: + return END_GAME; + + case XK_KP_Multiply: + return OUTER_ROTATION; + + case XK_KP_Add: + return LEVEL_UP; + + case XK_KP_Subtract: + return LEVEL_DOWN; + + } + + return NOTHING; +} + + +//=========================================================================== +/// global draw_line(...) +/// draw line with given coords and color +/// tags XWellDrawingEngine +void XWellDrawingEngine::draw_line(int x1, int y1, int x2, int y2, int color_idx, + Canvas where) +{ + switch(where) + { + case screen: + XSetForeground(disp,maingc,colors[color_idx]); + XDrawLine(disp,mainw,maingc,x1,y1,x2,y2); + break; + case pixmap: + XSetForeground(disp,*gcs,colors[color_idx]); + XDrawLine(disp,*fields,*gcs,x1,y1,x2,y2); + break; + } +} + +//=========================================================================== +/// global draw_rect(...) +/// draw rectangle with given coords and color +/// tags XWellDrawingEngine +void XWellDrawingEngine::draw_rect(int x1, int y1, + unsigned int il, + unsigned int ih, int color_idx, + Canvas where) +{ + switch(where) + { + case screen: + XSetForeground(disp,maingc,colors[color_idx]); + XDrawRectangle(disp,mainw,maingc,x1,y1,il,ih); + break; + case pixmap: + XSetForeground(disp,*gcs,colors[color_idx]); + XDrawRectangle(disp,*fields,*gcs,x1,y1,il,ih); + break; + } +} + +//=========================================================================== +/// global fill_rect(...) +/// fill rectangle with given coords and color +/// tags XWellDrawingEngine +void XWellDrawingEngine::fill_rect(int x1, int y1, + unsigned int il, + unsigned int ih, int color_idx, + Canvas where) +{ + switch(where) + { + case screen: + XSetForeground(disp,maingc,colors[color_idx]); + XFillRectangle(disp,mainw,maingc,x1,y1,il,ih); + break; + case pixmap: + XSetForeground(disp,*gcs,colors[color_idx]); + XFillRectangle(disp,*fields,*gcs,x1,y1,il,ih); + break; + } +} + +//=========================================================================== +/// global pixmap_copy(Geo*) +/// copy part of image to the screen +/// tags XWellDrawingEngine +void XWellDrawingEngine::pixmap_copy(Geo *pgeo) +{ + if(pgeo->im==imNone) + return; + XCopyArea(disp,xengine->get_pixmap_of_image(pgeo->im),*fields,*gcs, + pgeo->fromx,pgeo->fromy,pgeo->l,pgeo->h, + pgeo->tox,pgeo->toy); +} + diff --git a/src/x11/xwelldrawing.h b/src/x11/xwelldrawing.h new file mode 100644 index 0000000..370ec57 --- /dev/null +++ b/src/x11/xwelldrawing.h @@ -0,0 +1,50 @@ +// docm_prefix(///) +#ifndef XWELLDRAWING_H +#define XWELLDRAWING_H + +#include "globals.h" + +#include "xheaders.h" + +#include "welldrawing.h" + +class XWellEngine; + +/// module description +/// Definition of the XWellDrawingEngine class, +/// public child from WellDrawingEngine -> engine for drawing game field +class XWellDrawingEngine:public WellDrawingEngine +{ + protected: + XWellEngine *xengine; + Pixmap *fields; + GC *gcs,maingc; + Window mainw; + unsigned long *colors; + int scr; + XPoint trapazoid_list[MAX_SIDES]; + + + public: + XWellDrawingEngine(XWellEngine* myengine); + virtual void init(int,int,int,unsigned int,unsigned int); + virtual void flush_all(); + virtual void flush_dirty(); + virtual void draw_grid(); + virtual void draw_square(int color, int i, int j); + virtual void draw_trapazoid(int color, int i, int j); + virtual void sync(); + virtual void clear_field(int i); + virtual Actions key_to_action(void* event); + virtual void draw_line(int x1, int y1, int x2, int y2, int color_idx, + Canvas where=screen); + virtual void draw_rect(int x1, int y1, unsigned int il, + unsigned int ih, int color_idx, + Canvas where=screen); + virtual void fill_rect(int x1, int y1, unsigned int il, + unsigned int ih, int color_idx, + Canvas where=screen); + virtual void pixmap_copy(Geo *pgeo); +}; + +#endif diff --git a/src/x11/xwellengine.cxx b/src/x11/xwellengine.cxx new file mode 100644 index 0000000..9e2c987 --- /dev/null +++ b/src/x11/xwellengine.cxx @@ -0,0 +1,598 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: xwellengine.cxx,v 1.3 2003/02/20 15:09:41 leo Exp $ + +/// module description +/// This module contains methods of class XWellEngine which implements X11 calls +/// for the game. So this is X11 dependent part. It receives XEvents, +/// make convertions, many initions and calls. + + +#include "version.h" +#include "globals.h" +#include "xwellengine.h" +#include "xwellinput.h" +#include "image/image.h" +#include "bilist.h" +#include "commonfuncs.h" +#include "wellclass.h" + +Display *disp; +Colormap defcmp; + +const unsigned long TIMESTEP=10000l; + +//Colors for welltris pieces and grid (x color names) +static char *game_color_names[MAX_GAME_COLORS] = +{ + /* 0*/ "Red", + /* 1*/ "Green", + /* 2*/ "Blue", + /* 3*/ "Yellow", + /* 4*/ "Magenta", + /* 5*/ "Cyan", + /* 6*/ "FireBrick", + /* 7*/ "SpringGreen", + /* 8*/ "CornflowerBlue", + /* 9*/ "Khaki", + /*10*/ "Plum", + /*11*/ "Violet", + /*12*/ "DarkTurquoise", + /*13*/ "Gold", + /*14*/ "Orchid", + /*15*/ "Turquoise", + /*16*/ "Orange", + /*17*/ "OrangeRed", + /*18*/ "VioletRed", + /*19*/ "BlueViolet", + /*20*/ "SeaGreen", + /*21*/ "Pink", + /*22*/ "ForestGreen", + /*23*/ "SkyBlue", + /*24*/ "Coral", + /*25*/ "Wheat", + /*26*/ "GoldenRod", + /*27*/ "IndianRed", + /*28*/ "SpringGreen", + /*29*/ "CornflowerBlue", + /*30*/ "Thistle", + /*31*/ "Aquamarine", + /*32*/ "CadetBlue", + /*33*/ "LightSteelBlue", + /*34*/ "NavyBlue", + /*35*/ "SteelBlue", + /*36*/ "YellowGreen", + /*37*/ "DarkViolet", + /*38*/ "MediumSeaGreen", + /*39*/ "DarkSlateGray", + /*40*/ "LightGray", + /*41*/ "MediumVioletRed", + /*42*/ "Sienna", + /*43*/ "MediumAquamarine", + /*44*/ "MediumBlue", + /*45*/ "Navy", + /*46*/ "DarkOliveGreen", + /*47*/ "DarkGreen", + /*48*/ "DimGray", + /*49*/ "Tan", + /*50*/ "MediumTurquoise", + /*51*/ "DarkSlateBlue", + /*52*/ "Maroon", + /*53*/ "Gray", + /*54*/ "#303030", + + /*55*/ "Black", + /*56*/ "#00aa00", + /*56*/ "#00ee00", + /*57*/ "#aa0000", + /*58*/ "#aaaaaa", + /*59*/ "#cccc00", + /*60*/ "#eeee00" +}; + + +//=========================================================================== +/// global new_well_engine(argc,argv) +/// Creates new WellEngine object, X11 realization (create XWellEngine) +/// tags new_well_engine +WellEngine* new_well_engine(int argc, char** argv) +{ + return new XWellEngine(argc,argv); +} + +//=========================================================================== +/// global XWellEngine(argc,argv) +/// Constructor of class that incupsulates work with X window +/// This class must always be allocated through 'new' +/// args +/// +argc: number of commanline args +/// +argv: command line args +/// tags XWellEngine +XWellEngine::XWellEngine(int argc, char** argv):WellEngine(argc,argv) +{ + int i; + char *dispchr=0; + for(i=1;iflags=(USSize | PSize | PMinSize | PMaxSize); + pxsh->height=mainh; + pxsh->width=mainl; + pxsh->min_width=pxsh->width; + pxsh->min_height=pxsh->height; + pxsh->max_width=pxsh->width; + pxsh->max_height=pxsh->height; + + mainw=XCreateSimpleWindow(disp,DefaultRootWindow(disp), + 0,0,pxsh->width,pxsh->height, + 0,whitepixel,blackpixel); + if((pch=XAllocClassHint())==NULL) + { + fprintf(stderr,"xwelltris: Error allocating ClassHint\n"); + exit(1); + } + pch->res_name="xwelltris"; + pch->res_class="XWELLTRIS"; + if(XStringListToTextProperty(&winname,1,&wname)==0) + { + fprintf(stderr,"xwelltris: Error creating TextProperty\n"); + exit(1); + } + if(XStringListToTextProperty(&pch->res_name,1,&iname)==0) + { + fprintf(stderr,"xwelltris: Error creating TextProperty\n"); + exit(1); + } + if((pxwmh=XAllocWMHints())==NULL) + { + fprintf(stderr,"welltris: Error allocating WMHints\n"); + exit(0); + } + pxwmh->flags=(InputHint|StateHint); + pxwmh->input=True; + pxwmh->initial_state=NormalState; + XSetWMProperties(disp,mainw,&wname,&iname,argv,argc,pxsh,pxwmh,pch); + + gcv.foreground=whitepixel; + gcv.background=blackpixel; + maingc=XCreateGC(disp,mainw,(GCForeground | GCBackground),&gcv); + xswa.colormap=defcmp; + xswa.bit_gravity=CenterGravity; + XChangeWindowAttributes(disp,mainw,(CWColormap | CWBitGravity),&xswa); + XSelectInput(disp,mainw, + ExposureMask | + FocusChangeMask | + StructureNotifyMask | + KeyPressMask | + ButtonPressMask | + PointerMotionMask | + ButtonReleaseMask | + FocusChangeMask); + wmDeleteWindow = XInternAtom(disp, "WM_DELETE_WINDOW", False); + XSetWMProtocols(disp, mainw, &wmDeleteWindow, 1); + XSetGraphicsExposures(disp,maingc,False); +} + +//=========================================================================== +/// global show_main() +/// show main window +/// tags XWellEngine +void XWellEngine::show_main() +{ + XMapRaised(disp,mainw); + XFlush(disp); +} + +//=========================================================================== +/// global load_image(Images id, char* name) +/// Load image into memory and register it with given id for use +/// tags XWellEngine +bool XWellEngine::load_image(Images id, char* name) +{ + char buf[L_MAXPATH]; + + if(id>=MAX_IMAGES) + return false; + + find_full_path_for_file(name,buf); + image_pixmaps[id]=LoadPixmap(buf,F_AUTO,images[id].l,images[id].h,CMP_OWN); + images[id].id=id; + return true; +} + + +//=========================================================================== +/// global screen_copy(Geo*) +/// copy part of image to the screen +/// tags XWellEngine +void XWellEngine::screen_copy(Geo *pgeo) +{ + if(pgeo->im==imNone) + { + screen_clear(pgeo); + return; + } + XCopyArea(disp,image_pixmaps[pgeo->im],mainw,maingc, + pgeo->fromx,pgeo->fromy,pgeo->l,pgeo->h, + pgeo->tox,pgeo->toy); +} + +//=========================================================================== +/// global screen_clear(Geo*) +/// clear part of screen +/// tags XWellEngine +void XWellEngine::screen_clear(Geo *pgeo) +{ + + XClearArea(disp,mainw,pgeo->tox,pgeo->toy,pgeo->l,pgeo->h,False); +} + +//=========================================================================== +/// global set_main_background_image(Images id) +/// set image with given id to background of main window +/// tags XWellEngine +void XWellEngine::set_main_background_image(Images id) +{ + if(images[id].id!=imNone) + { + XSetWindowBackgroundPixmap(disp,mainw, image_pixmaps[id]); + XClearWindow(disp,mainw); + } +} + + +//=========================================================================== +/// global event_loop() +/// main event loop - process all events and make game moves +/// tags XWellEngine +void XWellEngine::event_loop() +{ + MouseEvent mev; + struct timezone tzone; + int count=0; + done_loop_var=false; + dbgprintf(("Entered in event_loop\n")); + + gettimeofday(&now, &tzone); + gettimeofday(&nexttime, &tzone); + + while(!done_loop_var) + { + if(wait_for_timers()==0) //Time out + { + process_time_event(); + } + + if(XPending(disp)) + { + dbgprintf(("Got xevent: %d for window 0x%x\n",xev.type,xev.xany.window)); + XNextEvent(disp,&xev); + switch(xev.type) + { + case Expose: + dbgprintf(("Expose event\n")); + process_event_for_all(wEvent(eExpose,&xev)); + break; + + case KeyPress: + dbgprintf(("KeyPressed event\n")); + process_event_for_all(wEvent(eKeyPress,&xev)); + break; + + case ButtonPress: + dbgprintf(("MouseButtonPress event\n")); + mev.mx=xev.xbutton.x; + mev.my=xev.xbutton.y; + mev.bstate=xev.xbutton.button==Button1 ? But1Press : But2Press; + process_event_for_all(wEvent(eMousePress,&mev)); + break; + + case MotionNotify: + dbgprintf(("MouseMotion event\n")); + mev.mx=xev.xmotion.x; + mev.my=xev.xmotion.y; + mev.bstate=xev.xbutton.button==Button1 ? But1Press : But2Press; + process_event_for_all(wEvent(eMouseMove,&mev)); + break; + + case ClientMessage: + dbgprintf(("ClientMessage event\n")); + if (xev.xclient.format == 32 && + xev.xclient.data.l[0] == wmDeleteWindow) + { + dbgprintf(("Got WM_DELETE_WINDOW\n")); + process_event_for_all(wEvent(eDelete)); + done_loop_var=true; + } + break; + + case FocusOut: + dbgprintf(("FocusOut event\n")); + process_event_for_all(wEvent(eFocusOut)); + break; + + } + } + } + dbgprintf(("Exiting from event_loop\n")); +} + +//=========================================================================== +/// global wait_for_timers() +/// calculate delay and wait for events and timers +/// tags XWellEngine +int XWellEngine::wait_for_timers() +{ + struct timeval delayt; + struct timezone tzone; + int ret=0; + fd_set writefd, exceptfd, readfd; + + FD_ZERO(&writefd); + FD_ZERO(&exceptfd); + FD_ZERO(&readfd); + FD_SET(xcon, &readfd); + + gettimeofday(&now, &tzone); + delayt.tv_sec = nexttime.tv_sec - now.tv_sec; + delayt.tv_usec = nexttime.tv_usec - now.tv_usec; + correct_to_real_time(delayt); + if (((long) delayt.tv_sec > 0) || + (((long) delayt.tv_sec == 0) && + ((long) delayt.tv_usec > 0))) + { + ret=select(xcon + 1, &readfd, &writefd, &exceptfd, &delayt); + } + if(ret==0) //Timed out + gettimeofday(&now, &tzone); + nexttime.tv_sec=now.tv_sec; + nexttime.tv_usec=now.tv_usec + TIMESTEP; + correct_to_real_time(nexttime); + + return ret; +} + +//=========================================================================== +/// global correct_to_real_time(struct timeval&) +/// corrects timval to real values +/// tags XWellEngine +void XWellEngine::correct_to_real_time(struct timeval& tv) +{ + while (tv.tv_usec < 0) + { + tv.tv_sec --; + tv.tv_usec += MILLION; + } + while (tv.tv_usec >= MILLION) + { + tv.tv_sec ++; + tv.tv_usec -= MILLION; + } +} + + +//=========================================================================== +/// global udelay(int msec) +/// Unix portable delay :) +/// tags XWellEngine +void XWellEngine::udelay(int msec) +{ + struct timeval tout; + tout.tv_sec=0; + tout.tv_usec=msec; + select(0,0,0,0,&tout); +} + + + +//=========================================================================== +/// local init_colors() +/// allocate all nessesary colors +/// tags XWellEngine +void XWellEngine::init_colors() +{ + XColor tmp; + int i; + + colormap=im_get_colormap(); + + if(!colormap) + colormap=defcmp; + else + XSetWindowColormap(disp,mainw,colormap); + + for(i=COLOR_DELTA;iget_pixmap_of_image(id); + mainw=xengine->get_main_window(); + maingc=xengine->get_main_gc(); +} + +//=========================================================================== +/// global clear_region() +/// clear region on screen for making output +/// tags XWellImageFont +void XWellImageFont::clear_region() +{ + XClearArea(disp,mainw,screen_x,screen_y,screen_l,screen_h,False); +} + +//=========================================================================== +/// global clear_region() +/// clear region on screen for making output +/// tags XWellImageFont +void XWellImageFont::clear_region(Colors idx) +{ + unsigned long *cols=xengine->get_colors(); + XSetForeground(disp,maingc,cols[idx]); + XFillRectangle(disp,mainw,maingc,screen_x,screen_y,screen_l,screen_h); +} + +//=========================================================================== +/// global draw_symbol(...) +/// draw one symbol from font image to screen +/// tags XWellImageFont +void XWellImageFont::draw_symbol(int ix, int iy, + unsigned int il, + unsigned int ih, + char symb) +{ + if(symb<=32 || symb>=127) + return; + symb-=33; //Translate to our indexation + XCopyArea(disp,font_pixmap,mainw,maingc, + dx,dy+(int)symb*font_h, + il,ih,ix,iy); +} + diff --git a/src/x11/xwellimagefont.h b/src/x11/xwellimagefont.h new file mode 100644 index 0000000..28a9bd2 --- /dev/null +++ b/src/x11/xwellimagefont.h @@ -0,0 +1,26 @@ +#ifndef XWELLIMAGEFONT_H +#define XWELLIMAGEFONT_H + +#include "wellimagefont.h" +#include "xwellengine.h" + +class XWellImageFont: public WellImageFont +{ + protected: + Pixmap font_pixmap; + XWellEngine *xengine; + Window mainw; + GC maingc; + virtual void draw_symbol(int ix, int iy, + unsigned int il, + unsigned int ih, + char symb); + public: + XWellImageFont(Images id, unsigned int ifl, unsigned int ifh, int idx, int idy); + virtual void clear_region(); + virtual void clear_region(Colors); +}; + +#endif + + diff --git a/src/x11/xwellinput.cxx b/src/x11/xwellinput.cxx new file mode 100644 index 0000000..9d07d40 --- /dev/null +++ b/src/x11/xwellinput.cxx @@ -0,0 +1,101 @@ +// docm_prefix(///) +/**************************************************************************** +* Copyright (C) 2002 by Leo Khramov +* email: leo@xnc.dubna.su +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + ****************************************************************************/ +// $Id: xwellinput.cxx,v 1.1.1.1 2003/01/04 11:37:22 leo Exp $ + +/// module description +/// X11 implementation of WellInput class - make input text from user +/// display it through WellImageFont, convert X11 Key event to symbols + +#include "xwellinput.h" +#include "xwellengine.h" + +//=========================================================================== +/// global XWellInput(char*) +/// constructor - fill name and get geometry +/// tags XWellInput +XWellInput::XWellInput(char* iname) : WellInput(iname) +{ + xengine=(XWellEngine*) default_well_engine; + mainw=xengine->get_main_window(); + maingc=xengine->get_main_gc(); +} + +//=========================================================================== +/// global process_event(wEvent) +/// stub that process events +/// tags XWellInput +bool XWellInput::process_event(wEvent ev) +{ + XEvent *xev=(XEvent*)ev.data; + switch(ev.type) + { + case eKeyPress: + process_key(xev); + return false; + + } + return true; +} + +//=========================================================================== +/// global draw_text() +/// draw text on the screen +/// tags XWellInput +void XWellInput::draw_text() +{ + unsigned long *colors=xengine->get_colors(); + fnt->draw_text(buf,buflen,BackColor); + XSetForeground(disp,maingc,colors[BonusColor2]); + XFillRectangle(disp,mainw,maingc,geo[1].tox+buflen*FONT2_L,geo[1].toy, + FONT2_L,FONT2_H); +} + +//=========================================================================== +/// global process_key(XEvent) +/// draw text on the screen +/// tags XWellInput +void XWellInput::process_key(XEvent *xev) +{ + KeySym ks; + XComposeStatus cs; + + char sym[4]=""; + XLookupString(&xev->xkey, sym, 4, &ks, &cs); + switch(ks) + { + case XK_Return: + if(buflen) + object_on_enter.call(wEvent(aInputDone,this)); + break; + + case XK_Delete: + case XK_BackSpace: + if(buflen>0) + { + buflen--; + buf[buflen]=0; + draw_text(); + } + break; + default: + if(buflen=32 && sym[0]<127) + { + buf[buflen++]=sym[0]; + buf[buflen]=0; + draw_text(); + } + } +} diff --git a/src/x11/xwellinput.h b/src/x11/xwellinput.h new file mode 100644 index 0000000..3ccc787 --- /dev/null +++ b/src/x11/xwellinput.h @@ -0,0 +1,24 @@ +#ifndef XWELLINPUT_H +#define XWELLINPUT_H + +#include "wellinput.h" +#include "xheaders.h" +#include "xwellengine.h" + +class XWellInput:public WellInput +{ + XWellEngine *xengine; + Window mainw; + GC maingc; + + virtual void draw_text(); + void process_key(XEvent *xev); + public: + XWellInput(char *iname); + + virtual bool process_event(wEvent); + +}; + + +#endif