commit dbc223eb843f97c021c45b86a681d468a0fbecd5 Author: Ville Lindholm Date: Thu May 28 16:35:31 2026 +0300 Initial commit Import existing source tree; original VCS history is no longer available. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..a43ea21 --- /dev/null +++ b/COPYING @@ -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/COPYING.LIB b/COPYING.LIB new file mode 100644 index 0000000..9033c8f --- /dev/null +++ b/COPYING.LIB @@ -0,0 +1,478 @@ +********************************************************************* +* IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! * +* * +* "Kobo Deluxe" is a game based on the work of many programmers, * +* artists, porters, testers and devoted fans. * +* * +* In order to make the new code useful to more people, even in * +* closed source productions, I am making it available under * +* the terms of the GNU LGPL. * +* * +* However, note that the GNU LGPL only applies to * +* *some* of the files in this distribution, not all of them! * +* * +* If you are going to reuse all or part of "Kobo Deluxe", please * +* read the terms stated in the header of *each file* first. * +* * +* IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! * +********************************************************************* + + Below this line follows an unmodified copy of the GNU LGPL +--------------------------------------------------------------------- + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +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 and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, 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 library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete 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 distribute a copy of this License along with the +Library. + + 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 Library or any portion +of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +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 Library, 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 Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you 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. + + If distribution of 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 satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be 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. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + + 9. 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 Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +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 with +this License. + + 11. 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 Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library 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 Library. + +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. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library 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. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser 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 Library +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 Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +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 + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. 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 LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..a68d5e0 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,1312 @@ +Kobo Deluxe v0.5.1 + * Fixed segfault with weird audio buffer sizes. + * *Maybe* clears the screen a bit sooner... (One + could see a magnified desktop or garbage display + for a moment on some systems.) + * When there is no profile, the automatic New Player + dialog sends you on to the main menu, rather than + back to the intro. + * Added a bunch of AGW explosion sounds. + * Added new "big ship" launch and escape sound. + * Fixed infinite loop bug in filemapper_t::get_next(). + (Thanks Joey Hess!) + * New "core destroyed" sound. + * When compiled with PROFILE_AUDIO, the 'R' key + reloads all sound effects. + * Integer atan2() approximation for sprite rotation. + * "Fixed" cubic resampler. (There will be a jump of one + sample when switching to/from cubic interpolation.) + * New player fire sounds, including overheat warning. + * Tweaked various sounds and related logic. + * 10% health award for core destroyed, and another 25% + for stage cleared. (No more 100% for stage cleared!) + * Health can now be up to 200%, but will decrease + quickly towards 100%. + * Destupified the bargraph_t value() interface... + * Waveform info after loading with logverbosity >= 2. + * Added pause sound. + * Added "Safe video settings" message when "escape + hammering" is detected. + * Explosions can now actually show the first frame. + * Explosion "random start frame" removed. + * Initial white flash for explosions. + * Fewer bonus lives! (We have the health bonus now...) + * Default and rock explos assume half speed of objects. + * Added player bolt impact fx. + * Improved player explosion. + * Bomb detonation fx directed at the player. + * Fixed a positional audio wrap bug. + * Configurable "Cannon Sound Suppression." + * Configurable overheat warning buzzer. + * Doubled rock health for Newbie skill. + +Kobo Deluxe v0.5.0 + * Added 'autoshot' command line switch for grabbing + ingame screenshot series. + * Added animated rocks. + * Added 88.2, 96, 176.4 and 192 kHz sample rates. + * Default video mode changed to 640x480. + * Option 'internalres' considered obsolete. (Was + never implemented.) + * s_filter_scale() fallback from Scale2x and + Diamond2x for non 2x factor changed to bilinear. + * Newbie mode changes: + * Three alternating nose/wing guns. + * Two alternating rearward wing guns. + * Fixed nonsense values for the SDL_GL_DOUBLEBUFFER + attribute. (Thanks, Sam Palmer!) + * Fixed Y/N buttons in the requester dialogs. + * Some new explosions, enemy bullets and other gfx. + * Fixed segfault in myship.cpp in (the extremely + unlikely) case of running out of sprite objects. + * 'pushmove' now counts as a cheat. (No highscores.) + * Added simple parallax starfield, along with none/ + old/parallax starfield style switch. + * Intro mode now sets it's own fixed logic rate. + * Enemy definitions now have "death handlers". + * Invisible enemies no longer allocate sprites. + * Background color fade in damage noise flash and + noise-out effects. + * Map now marks cores as needed to select orientation + specific core tiles. + * Broken base branches are left as is. + * No dithering for the logo mask! (Thanks again, + Sam Palmer! :-) + * Separated map tile index from map state bits. + * Added alternate straight sections in bases. + * OpenGL vsync is now optional. + * Added 'S' key for screenshot. (PrintScreen is + stolen by some desktop environments.) + * Larger fps counter, for 1000+ rates... + * Corrected cs_engine_t.time type. Animation should + be smooth and reliable now! + * Tweaked screen.png a little. (Contrast, AA, ...) + * "Audio Options" renamed "Sound Options". + * Rocks are now destructible again (255 hits in + Classic mode; other values in new skill levels). + They also have an explosion all of their own. + * Special detonation animation for bombs. + * Bullets, player, enemies etc in separate layers. + * More firepower in the "Gamer" skill level. + * Benchmark based progress bar. + * Framework overlay now rendered as small tiles in + the corners of the playfield window, to avoid full + window impact on slow video cards in OpenGL mode. + * glSDL: + * Now compiles with OpenGL disabled. (Thanks, + Michael Sterrett!) + * Gamer mode changes: + * Higher firing rate. + * Added "videopages" option to make smart refresh work + with triple buffered displays, and for disabling + smart refresh if all else fails. + * Fixed weird audio fragment sizes. + * Fixed cubic interpolation -1 sample index bug in + a_mixers.h. + * Graphics loader refactored; gets parameters from a + table, and provides more verbose error messages. + * New "Boomerang" fighters with 16 rotations. + * New fighter ship. (Replaces the teal missile.) + * New gray, red and blue missiles. + * Disabled colorkey filter in gfxengine. + * New "loading" logo. + * Slightly slower (more readable) scroll text. + * Added window_t::textwidth_fxp(), to fix the unsmooth + text scrolling. + * Added "How to play" screen. + * Added "Highscores only for Classic mode!" notice. + * Added optional mouse capture when playing. Pause or + abort game to release! + * Added joystick selection. (Thanks, Erik Auerswald!) + * Decided the substantial change in appearance calls + for a minor version bump, so: 0.5.0. + * The -help switch is now handled as a proper command, + avoiding the stupid "unknown argument" error. + * Added -options_man command to output option docs in + Un*x man format. + * Updated the Un*x man file, and replaced the README + with a rendition of the man file. + * Made a new README from the man file. + * New counter font. + * Fixed some minor compiler warnings. + * Updated the TODO. + +Kobo Deluxe v0.4.1 + * Got fed up with these "pre" version codes that + don't fit into package versioning systems and + look generally silly. + * Implemented logic/audio timeline sync for + constant sound effect latency. Events are no + longer quantized to buffers. + * Improved the latency selector a bit. + * Latency calculations now assume 2 fragments for + SDL. (We use 3 fragments for OSS.) + * Latency calculation now picks the *closest* + buffer size; not the biggest one with lower or + equal latency. + * Removed "games" from the install paths on Un*x + systems, and moved the score files to the more + correct $(sharedstatedir). The install target + now works as expected for an autoconf build. + * Reverb and limiter controls replaced with the + simplified "Ambience" and "Volume Boost" + controls. + * Mega stoopid bug fixed: If video initialization + failed after changing video settings from the + options menu, the game would start back up + anyway - without a display! + * kobo.cpp now keeps a copy of the preferences, + so safe settings can be restored should reinit + inside the run/reinit loop fail. + * LoadRAW_S8() became LoadRAW(), and can now load + "raw" files with an 8 byte header containing "RAW" + followed by the audio_formats_t format code, and + a 32 bit sample rate in big endian format. The + MSB of the format code byte is set if the + waveform is looped. + * Implemented SaveRAW(). (Always saves in the above + format.) + * Implemented quick hack sound caching by providing + a script that saves all sounds to disk, and + alternative loader scripts that use those instead + of the AGW sounds. This currently generates 2 MB + of raw audio data. + * Added window_t::refresh() to enable the engine + to correctly handle windows that aren't repainted + every frame. + * Added endian swapping code for 16 and 32 bit raw + audio files. Files are in big endian, so this + code is only compiled on little endian archs. + * The mixers in a_tools.h now test for the zero + samples in debug builds. + * Removed in-game music pausing/restarting. + * Game Over no longer stops the game logic. + * Player profiles cannot be symlinks. (Security.) + * When loading a "raw" file, audio_wave_load() + takes looped/one-shot from the file. + * AGW w_load() and w_save() now tells EEL about + errors! (Kinda' handy... :-) + * Replaced "fine.raw" with "breakdown1.agw". + (The "fortress destroyed" sound.) + * Replaced "shot.raw" with "missile1.agw". + (The player fire sound.) + * Fixed sound FX bug: _enemy::hit() used x and y + fields of _enemy objects after release(). + * Another sleeping bug: _myship::explode() + generated lots of huge, nasty coordinates. + * Removed "expl3.raw" completely, and removed + "bomb.raw" from "core destroyed." + * Added a logger with redirection capabilities. + * Fixed mouse control bug; the crosshair hot-spot + offset was wrong in some resolutions, because + of the border that's put around the screen in + certain resolutions and in windowed modes. + * display_t refactored to use refresh(). + * Added dashboard.(cpp|h) and refactored the health + bar to use refresh(). + * The framework is now rendered through refresh(). + * Removed the pixel_* cruft in the _screen class. + * The _radar class becomes radar_window_t, which + is a window_t with callback driven rendering. + * window_t gets offscreen window/surface support. + * gfxengine now whines a little if it has to change + the buffering mode from the requested one. + * The health bar is only visible if there's more + than one health point maximum. (So, it's no longer + visible in Classic Mode.) + * gfxengine_t should now initialize the dirtyrect + management for page flipping properly. + * Removed the odd "OpenGL" resolutions in the video + options. + * No buffering mode for OpenGL in video options. + * Removed AC_FUNC_MALLOC. Who needs malloc(0)...? + * Added logfile and logformat options. + * Removed all extern "C" clauses around C includes. + * Fixed the "selector tube" heights; the surfaces + were much taller than the images. + * Tweaked the cleanalpha filter parameters. + * Optimized the dither filter; it doesn't *have* + to touch all the data to just do nothing... :-) + * Optimized the image processing filters. + * Added "No Alpha Blending" feature. + * Moved the sprite filters into filters.h. + * loadrect() renamed copyrect() and is now + applying scaling to coordinates like all other + calls. + * SemiTriple removed from buffering modes. You get + the same setup with doublebuffer(1); shadow(1). + * Old retrace sync cruft removed. + * ESC from any "normal" state now gives you some + version of the main menu. + * Added brightness/contrast filter. + * Moved less h/w related stuff from "Video Options" + into a new "Graphics Options" section. + * Added generic 'flags' field to filter arguments, + and threw in a global s_filter_flags as well. + * Removed window dependency from gamestate.(cpp|h) + and changed the license to LGPL. + * Upgraded to glSDL 0.7, w/ dynamic OpenGL loading. + * Added "Random" and "4x4 Filter" dithering methods. + * All graphics converted to PNG format. + * Added support for scaling to (almost) arbitrary + resolutions, including lower than the native + resolution of the graphics. + * The command line usage message now generates the + list of recognized options from the prefs object. + * Buffer overflow bug in new_player_t fixed. (?) + (Thanks to Donny Viszneki for reporting it!) + * Fixed a free()/delete bug in filemapper_t. + * Rewrote most of the radar display code. + * Removed unused scrolling cruft in window_t. + * Changed version to 0.4.1. Too many 0.4something. + * Made the player ship cursor flash slightly. + * Fixed missing slash before the config file name. + (Never noticed this before, as it apparently + affects only Mac OS X.) + * Fixed the title screen cheat mode indicator. + * Thanks to Antonio Messina, who managed to break + the game logic desipte a broken arm: + * Fixed difficulty wrap at stage 1601. + * Added option always_fire. + * Fixed missing gamecontrol_t constructor. + * Bilinear scaling without oversampling is now + actually *without* oversampling. + * Optimization: Scaling checks for clipping or + clamping only near the edges of surfaces. + * The SDL audio callback now deals with "evil" + buffer sizes. (Thanks to Hans de Goede!) + * Losing window focus now pauses the game. (Thanks, + Marianne Ibbotson!) + * Upgraded to glSDL 0.8. + * gfxengine no longer shuts down the SDL video + subsystem when hiding, as this causes problems + with glSDL for no gain. + * Implemented selectable Newbie, Oldie and Elite + skill levels. + * kobo_form_t:xoffs now also works for button(). + * Added kobo_form_t:medium(). + * Added "spread" fire for Newbie mode. + * Lower rear fire rate for Elite mode. + * Max number of saved scores per profile increased + to 100. + * Added cannon heat/cooling simulation. + * Added Video Mode Manager vidmodes.[ch] + * Some ships flying around in intro mode. + * New screen layout. + * Optimized and improved the video noise effect. + * Menu highlight bar: + * Faster movement. + * Parallax "slime" effect. + * Zoom-to-size effect. + * Made more room for extreme scores in Hall of Fame. + * Red noise to indicate damage. + * Snappier health bar. + * Added gun temperature bars. + * Upgraded to glSDL 0.9. (Colorkey fix.) + * Sound control cleanup; added sound.(h|cpp). + * Changed to Classic mode + four "New Mode" skill + levels; Newbie, Gamer, Elite and God. + * maxfps default changed from disabled to 100. + * Added CharOffset table to SoFont, to avoid mixing + actual character positions up with source blitting + extents. + * Fixed rectangle size calculations and rounding in + the graphics engine. (Improves rendering accuracy + in "odd" resolutions.) + * Fixed screen border refresh. + * Added hotspot logic to the sprite engine. + * New player "plasma bolts" and two new explosions. + * Incomplete base destruction bug fixed (?) + * Fractional frame times use double instead of float. + * Added configurable time filter. + * Default scale mode changed to Bilinear. + * Bilinear+Oversampling removed from config menu. + * Added "Strictly Regulated" frame rate limiter. + * Options moved to "System Options": + * Maximum Frame Rate + * Strictly Regulated Frame Rate + * Time Filter + * Motion Interpolation + * Removed some unimplemented video driver enums. + * Current score and stage is now checked when + quitting from within a game. + * Image filters are now removed properly. + * Added window centering for "some platforms". + * Hammering on Escape is trapped and aborts the + game when loading, or switches to a safe video mode + when running. + * Some refactoring to hunt down memory leaks and other + issues. Most statically allocated objects gone. + * Sped up the slow, annoying nibble effects. + * "Weird characters" in New Player name editor fixed. + * Proper Yes/No dialog for exit and abort game. + * Unused song ballad1 + instruments removed. + * "Dummy" score file (for WinZIP) is now minimal, no + scores, no stages finished. + +Kobo Deluxe v0.4pre10 (Unofficial Debian/PPC fix release) + * #include "config.h" was missing in e_getargs.c... + * Applied security fix for saving the user config. + * Added default case in glSDL's _print_glerror(), + since I get flooded with warnings otherwise. + (All GL_* are in an enum in my new GL.h.) + * Added max_FPS feature, to restrict the frame + rate. Useful on video drivers without retrace + sync and/or when you want to reduce CPU load. + (Thanks to Martijn van Oosterhout for the + original patch!) + * Added man page, contributed by Joey Hess. + * Fixed some minor typos in the man page. + * Added resolutions 1600x1200 and 1920x1440 and + 2048x1536, for extreme/insane users. ;-) + * Removed 57 unused AGW scripts. (These belong to + Audiality, which is now a separate project.) + * Updated and shortened the scroll text. + * Added monitor noise effect with sound effect. + * Fixed two related bugs in s_filter_scale() that + would 1) cause NEAREST to be one pixel off + vertically and 2) linear interpolation modes to + be off by half a pixel horizontally. + * Tweaked the death explosion, so it expands, + decays and ends, instead of just rolling for as + long as the player is dead, as it used to be. + * Added Game Over sound effect. + * Dead player no longer takes hits. (This avoids + the hysterical thumping of bullets hitting the + non-existent ship during the death sequence.) + * Added README.osx, which points out that you may + have to create the score-dir to make Kobo DL + work. This applies to other archs as well, so + perhaps I should put it in an FAQ or something? + (Thanks to Adam Marks the the Mac OS X binary!) + * Tweaked launch.agw. (More turbine; less noise.) + * Added Get Ready sound effect. + * Exiting pause mode now throws you right back + in the game. (No "get ready" state.) + * Added configurable "get ready" countdown. + * "Get ready" countdown now ends by starting the + game, rather than entering pause mode. + * Controls are reset whenever you get a new ship. + * Improved the loading status screen a bit. + * Added shrinking and green->red fading bar + during the last second of the "Get Ready" + countdown. (0.7 s in "Quick Start" mode.) + * Added a critical error state with a red + flashing box and stuff. This shows up if a + player profile cannot be created, or if + starting a game fails for some reason. + * The game now remembers the last map played + until you quit, instead of resetting to the + last completed map all the time. (Thanks to + David Andersson for the idea!) + * Fixes backported from Audiality: + * midi_process() was called even if MIDI + input was not enabled, resulting in the + engine waiting for data on stdin once + per buffer... *heh* Fixed. + * OSS MIDI input fixed. (When soft through + was disabled, the device would be opened + write only! The drivers I used before + obviously always opened RDWR...) + * Poly and mono Patch Plugins now + initialize the primary output and send + busses for voices. (So *that's* why my + mixes broke... Oops!) + * New, properly working envelope generator + backported from Audiality. + * VE_ISET event eliminated - only IRAMP + is used for ramped voice controls. + * glSDL changes for glSDL-0.4: + * "no TexInfo" changed from 0xffffffff to + 0, since SDL 1.2.5 and up inits the + unused1 field to that, specifically for + glSDL. + * Added compile time and runtime warnings + for SDL versions prior to 1.2.5. + +Kobo Deluxe v0.4pre9 (Debian/PPC fix release; first try) + * EEL changes: + * Stole eel_get_argsv() from the not yet + released Audiality 0.1.0. (Fixed some + more va_list issues.) + * glSDL changes for glSDL-0.4: + * Added (gl)SDL_SaveBMP(). + * "Fixed" OpenGL pixel format for + glReadPixels. (Maybe I got the glSDL pixel + format wrong? Dunno, and I'm on an ATI card + and driver so I don't trust anything...) + * Fixed _glSDL_BlitFromGL() (I think...) + * Removed the "Intelligent Display Abstraction + Layer" for now, as it's not yet usable. + * Added screen() property to gfxengine_t, to have + a standard way of rendering to the full screen + area. + * Added gfxengine_t::clear() method. + * Added coarse clipping to SoFont. (The scroller + made the coords wrap in 1280x1024. *heh*) + +Kobo Deluxe v0.4pre9 (unreleased) + * Started hacking the "Intelligent Display Abstraction + Layer". + * glSDL changes for glSDL-0.4: + * Fixed C++ issue with IMG_Load(). + * Fixed stupid M$isms: Textures are now + *uploaded* to the card. + * SDL_OPENGLBLIT removed. (Used only to + prevent certain unimplemented stuff from + causing *really* Bad Things to happen.) + * Depth buffer silliness fixed. (We don't + use the depth buffer...) + * "fake_screen" is now a real surface. + * Implemented blitting from the screen. + * Implemented blitting within the screen. + * Implemented screen locking/unlocking. + * Fixed prototype for glSDL_GetVideoSurface(). + * EEL changes: + * Added eel_load_from_mem(). (Thanks to + Florian Schulze!) + * Cleaned up the EEL script management + code a little. + * Using va_copy() in e_getargs.c, since + assignments are not legal on all + platforms. (Thanks, Andreas Heck!) + +Kobo Deluxe v0.4pre8 + * Added Extreme Pickyness Mode (--enable-epm). + (Unfortunately, this is not enough to ensure that + stuff compiles on gcc 3.x. Guess I'll just have to + install gcc3, or rely on gcc3 users reporting all + warnings and errors.) + * Some const string issues fixed. (Returning a const + string as "char *" and the like.) + * Removed all AdLib stuff and support for non- + standard MIDI file variants. However cool it might + be to play those files, I have no use for it and + can't maintain it in this project. + * Removed old bogus stuff from the comments in + filemap.h. + * Minor cleanups in filemap.cpp. + * Some GCC3 fixes in score.cpp. (String copying...) + * Scroll text updated. + * Improved scroller "speed throttling". + * Returning to the intro now restores the "demo" map. + * Added Electric Fence to the Extreme Pickyness Mode. + * Started cleaning up the C code using Splint. (Can + someone please donate a FlexLint license...? :-) + * load_sounds() in kobo.cpp fixed; it wouldn't load + the music if the sound effects were loaded with + a previous call. + * Somewhere along the way, I managed to get the + intro to generate a new demo map on every intro + screen switch. Fixed. + * Audio engine changes: + * Added OSS 'pollaudio' for debugging. + * Fixed index outside array in + audio_wave_free()! + * Tightened up the API - signs only where + needed and things like that. + * 0 dB peak amplitude for 32 bit waveforms + changed to [-1.0, +1.0]. + * ptab_init() now takes an integer argument. + (No implicit float->fixp16:16 conversion.) + * Ports and "clients" are now named for + debugging/tracing, although client names + exist only if AEV_TRACING is compiled in. + * Cleaned up audio event system names. + Everything is now aev_, and most + names have been significantly shortened. + * Added aev_init() macro for ports! (Aargh!) + * Open/close of subsystems cleaned up. All + subsystems now have audio_*_open/close() + calls, and should (hopefully) clean up + properly when closed. + * Audio engine open/close API changed; + the full sequence is now: + audio_open() (optional) + audio_start() + audio_stop() (optional) + audio_close() + Note that the waveform and scripting + subsystems will still initialize + themselves automatically if used before + calling audio_open(). + ! The last two seem to have fixed the + issues with restarting the engine on + Linux! Remains to see if that was the + whole problem... + BENCHMARK: speed1.agw renders in 27.2 s. + speed2.agw renders in 21.5 s. + Total: 48.7 s. + * Added block based processing framework. + * Implemented block read, write and add. + * Added block based envelope processing. + * Using the new envelope interface - but + still processing one sample at a time. + (BENCHMARK: speed.agw renders in 34.2 s!) + * Using 32 frame blocks in wca_filter() + and wca_gain(). + (BENCHMARK: speed.agw renders in 33.6 s. + wca_filter() disabled: 31 s.) + * Converted wca_osc() to block based + processing, and made some minor + optimizations. + * WCA_SYNC for WCA_NOISE fixed. Each sync + pulse now shifts in a new value through + the S&H as well. + * Fixed bug in spectrum oscillators: They + would produce no output with a mod1 input + of less than 1.0. They now produce pure + sine, as originally intended. + * HSPECTRUM and PHSPECTRUM fixed: They + actually didn't separate roll-off control + for odd and even harmonics at all! (Thus, + they were basically just broken versions + of SPECTRUM...) + * SPECTRUM modulation mapping unified; MOD1 + now always controls the overtone stepping. + * The new AHSPECTRUM replaces PHSPECTRUM. + * HSPECTRUM becomes a AHSPECTRUM with + multiplicative overtone stepping control. + BENCHMARK: speed1.agw: 10.2 s. 167% faster. + speed2.agw: 17.7 s. 21% faster. + Total: 27.9 s. 75% faster. + Obviously, the optimizations worked out + rather well. Next, we'll try to do something + about those spectrum oscillators... + +Kobo Deluxe v0.4pre7 + * Old samples boosted by 70%, to compensate for the + lack of an illogical amplification factor in the + new engine. :-) + * The screwed up scroll position during the "Game + Over" state fixed. + * "Early bullets", flickering and other crap fixed. + * gfxengine_t and sprite.[ch]: Added clampcolor() and + s_clampcolor (for specifying what color and alpha + to assume for areas outside images), and changed + the color format to Uint8 in the range [0,255], to + be consistent with the change in window_t. + * manage: Selecting a starting stage before staring + a game now preserves the actual map that is + generated. You don't get a new version of the + same level, but the exact map you're looking at + before starting the game. + * radar: Fixed potential color allocation bug when + changing video mode; it used to initialize only + once during the game life time... + * radar: Tweaked colors, and made the the blue + launcher nodes visible on the radar. + * Options 'cheat' and 'indicator' are now commands + rather than switches, so they cannot be saved in + the configuration by accident. + * Split the "push move" mode off from 'indicator' + into a feature of it's own, activated with + the 'pushmove' command. + * Game and Control options moved to the top of the + options main menu. + * Scrolling radar implemented. Can be disabled in + Game Options, to work like the old version. + * gfxengine_t make slightly more robust WRT calls + being made while the screen is closed. + * Switching between fullscreen and windowed modes + can now be done at any time with the usual ALT+ENTER + shortcut. :-) Special case activates pause mode if + it's done in the middle of a game. + * Random number generator split in two; pubrand and + gamerand, and get_seed() member added, as a + preparation for demo recording and playback. + * 'P' and the mighty strange Pause Key parsed and + routed to the pause function. (This is also used + internally, as a neat way of telling whatever state + might be active to pause.) + * Touched up the screen framework artwork a little. + * Optimized background rendering some. (Occasional + clipped extra row and column of tiles eliminated.) + * Stupid bug in window_t::invalidate() found and + killed: gfxengine_t clips invalidated rects, so we + need to make sure our window is selected! + * window_t now supports background images. clear() + takes an optional SDL_Rect, and blits from the + image, if there is one, or fills with the + background color as in previous versions.) + * Background graphics in the displays and the radar + screen! :-) + * Added dither plugin with hard-coded 2x2 filter. + * Added options to turn dithering off. + * Added kludge for OpenGL cards that can't handle + RGBA8, but turns it into RGBA4, and a switch to + enable it if required. + * sprite: S_BLITMODE_NORMAL renamed S_BLITMODE_AUTO. + (Makes more sense!) + * Option broken_numdia (Broken NumPad Diagonals) + added - I want to use the page up/down keys for + other stuff, even if *some* systems can't decode + the numpad correctly! :-/ + * Added the algorithmically constructed sound + effect "SOUND_LAUNCH". + * Separated the AGW scripting engine core from the + audio engine and made it the "Extensible Embeddable + Language". (a_agw.[ch] now contain only the AGW + extension to EEL.) + * Added the algorithmically constructed sound + effect "SOUND_LAUNCH2", for the "blue balls". + * Fixed some bugs in filemapper_t. + * Any jerking, flickering etc when entering a new + stage should now be *completely* eliminated. I + think... ;-) + * Intro doesn't conflict with stage 100 any more. + * Implemented 2D positional sound effects. :-) + * Added screenshot feature. (OpenGL not implemented, + as the current glSDL cannot read the screen surface.) + Saves BMP only, and is connected to PrintScreen and + SysReq. + * EEL now uses the same callback prototype for all + extensions, whether they are commands, operators + or functions. + * Ported Jeremy Sheeley's player profiles patch + from 0.3, and tweaked the user interface a little. + * Fixed double initialization of the manage object. + * Extended the score file format into a more powerful, + versionned "profile file format". + * file.(h|cpp) and parts of score.(h|cpp) replaced + with pfile.(h|cpp), which implements a generic, + portable "toolkit" for platform independent binary + data file access. + * Added game.(h|cpp), which collects all configurable + game parameters in one place. + * The "speed" parameter is now considered a cheat, + and is no more available from within the game. + * Last player profile is remembered in the config. + * Added optional "Diagonals Emphasis Filter". (I'd + say it only makes control feel sluggish most of the + time, but it might work for someone... I'm open to + suggestions if anyone has an idea for a smarter + filter.) + * Eliminated extra calls to score_manager_t::record(). + * Start level selection in intro mode removed. + * Implemented collision/health system. When two + "collidable" objects collide, the damage of each + object is subtracted from the health of the other. + (Object properties set so that the game will + play exactly like the original with the single + player default settings for the player ship.) + * Turned the "shield = -1" feature into 'shootable'. + * Added health bar. + * Threw in detection and fix to read broken 73 byte + scorefiles from older Win32 versions. (Seems like + the new code works right on Win32 as well, BTW.) + * Various fixes and additions to filemapper_t. + (Scanning multiple directories, most importantly.) + * Removed "./scores" from the SCORES path for now, + as it's actually the same place as the default + score dir on Win32. (You'd get all profiles and + scores twice, that is.) + * Removed "bgm.raw" as it's not used anymore. + * No hyphen before the "pre" from now on! + * glSDL changes: + * Applications can now set the colorkey of + of surface *after* SDL_DisplayFormat() - + although it will just discard the TexInfo, + resulting in the surface being converted + before the first blit, and after every + change in the surface. + * Silly intermediate buffer eliminated in + _DownloadTexture(). + * glSDL automatically stretches resolutions + below 640x480 using an integer factor. + * Audio engine changes: + * Benchmarking tries to use gettimeofday() if + not compiled for x86 CPUs. + * a_tools.h got some cleaning up, some new + macros, and mixing functions optimized with + a Duff's Device variant. + * __mastervol() is obsoleted by the groups, + and was killed to save some cycles. (It ate + almost 1% of my P-III 933!) + * Ditched the "Smart Stereo" Limiter - it's + not loud enough, and should be replaced with + something that drives the signal non-linear + to squeeze more power in when the signal + isn't panned center. + * Dropped the saturating 32->16 bit converter, + and fixed the limiter so that it reliably + *limits* the signal the way it should. + * Limiter does no longer invert the signal. + * Added ACC_PRIORITY. + * Added controls for Channel Inserts. + * Channel default controls (used in DETACH + mode) removed. Just expect channel controls + to stay where you leave them, and + everything should be fine - and faster! + * Implemented dynamic voice allocation. + * ACC_DETACH now effectively means + "polyphonic mode". "Detached" voices are + still owned by the channel that launched + them - but just as before, channel + controls don't affect voices directly after + they're launched. (Even that may change + eventually...) + * Ripped mid.cpp and mid.h from the AdLib FM + player AdPlug 1.1. Started stripping off + the FM stuff and converting it to C and the + "midisock" interface. + * Added primitive VU-meter to the voice mixer. + * Implemented audio_wave_convert(), using the + voice mixer in interpolated 16x oversampled + mode. + * Added simple enhancer and noise gate + functions to the init time wave API. + * Hacked basic polyphony support into a_midicon. + * ACC_RANDTRIG is now *really* a 16:16 fixp + value, to allow finer control of the + randomize depth. (Next, I'll make the section + end marker fixed point, to allow sub sample + accurate loop timing - as well as finer + RETRIG and RANDTRIG control. :-) + * Fabricated a nice 3'rd degree LUT for + various MIDI -> Linear Control mapping. + * Introduced a more solid scheme for keeping + track of allocated voices. + * audio_channel_play() now takes 16:16 linear + pitch and 16:16 volume, instead of the bogus + MIDI format arguments. + * Added audio_wave_filter(). + * DETACH mode split into ADM_POLY and + ADM_FULL, to natively support the slightly + different ways DETACH mode is used by + midicon and for sound effects. + * Added cubic (4-point) interpolation, based + on a formula by Olli Niemitalo. Low freq + sines sound *perfect* - no audible distortion + whatsoever. It sounds great up to 1:1, but + runs into trouble in the upper half of the + octave above 1:1 - linear 2X+ sounds better + from there and up. The best part is that the + CPU usage is somewhere in between linear 2X + and linear 4X on a P-III. + * Volume ramping bug fixed: The "boot strap" + values calculated when starting new voices + were wrong, and resulted in an undesired + fade in over one buffer. + * "Playing" indicator below the per-voice VUs. + * Waveform size restrictions eliminated! (Well, + you'd probably have trouble with 2+ GB on 32 + bit systems... ;-) + * Dynamic voice allocation now always starts + with voice 0 in the first pass, when looking + for unused voices. (The other passes are still + starting at the voice after the last voice + allocated, to favor the "oldest" voice when + there are multiple equivalent choices.) + * Implemented MIDI CCs 120, 121, 123, 126 & 127. + * Added SILENT and RESTING states to the plugin + API, to deal with silent output efficiently. + * Optimized bus handling; now, bus send buffer + clearing and other stuff isn't even considered + unless a bus actually is in use. + * Implemented the Bus Control MIDI CCs. (39...55 + on the first AUDIO_MAX_BUSSES channels.) + * Reverb SNR improved. The internal precision is + now 8 bits higher than that of the I/O, which + produces "perfect" results down to the LSB in + the final output. + * Implemented CCs 88, 89 and 91; "primary bus", + "send bus" and "send level". + * Added SINEMORPH, SPECTRUM, and LSPECTRUM + oscillators. + * Changed ACC_PITCH to fixed point linear freq, + where the integer bits correspond to MIDI + pitch. That is, 60.0 now does what 1.0 used + to do, and to step up one octave, add 12.0 + instead of multiplying by 2.0. + * Various oscillators and stuff added to the + Waveform Construction API. + * Added bandlimiting or oversampling to all + Waveform Construction API oscillators. + * Modulation API cleaned up. + * Voice mixer code cleaned up a bit. + * Voices now use timestamped events for control. + * "Plugin style" API for patches separates the + channel->voice bindings from the engine core. + BENCHMARKING NOTE: Right now it takes 60 seconds to + load and render the 72 AGW sounds I've created + so far. Although most of the code is currently + *very* inefficient, only the SPECTRUM oscillators + are really so slow that it matters. + * Audio Voice Mixer benchmark results, 20020111: + (P-III 933, 48 kHz, 20 ms latency, playing + an 8 kHz 8 bit stereo sample in 32 voices, + compiler optimizations disabled. Unit is percent + of total CPU time.) + ----------------------------------------------- + Very Low: 6.9% + Low: 14.5% + Normal: 10.1% + High: 17.9% + Very High: 136% (overload!) + + (Same, but with gcc/g++ -O3 optimization.) + ----------------------------------------------- + Very Low: 3.5% + Low: 6.5% + Normal: 4.6% + High: 7.9% + Very High: 78% (causes underruns) + + Obviously, on this machine, the "Normal" mode, + which is using plain linear interpolation, is + almost as fast as the "Very Low" mode, whereas + the "Low" mode is more expensive. This is to be + expected from CPUs with fast multiplications. + * Audio Voice Mixer benchmark results, 20020503: + (Same machine, same settings, same test, but with + the new cubic interpolating mixer, internal + fragment size limit, timestamped events etc. With + -O3 optimizations.) + ----------------------------------------------- + Very Low: 4.5% + Low: 6.8% + Normal: 5.5% + High: 8.2% + Very High: 9.5% + + Higher loads occur only when pushing the pitch more + than ~1.5 octaves above fs in "Very High" quality. + (That results in linear interpolation w/ 4x+ + oversampling, which is pretty slow.) + + +*** The Audio Engine: Why the GPLed files? + + The sound code used in Kobo Deluxe was originally written + by Masanao Izumo , for XKobo 1.11+. + Masanao also added the sound effect samples that are still + being used. + + You may have noticed that, while most, if not all of the + current audio engine is new code, which is LGPLed, a few + files (a_globals.[ch] and audio.[ch]) are GPLed, and + contain a copyright notice mentioning Masanao Izumo. + + This effectively means that the whole audio engine has + to be used under the terms of the GPL; not the LGPL. + + As this will probably be too restrective for many of the + users the engine is targetting, I've contacted Masanao + for a resolution, but have yet to receive a response. + + David Olofson + +Kobo Deluxe v0.4-pre6 + * I've compiled with -Wall and nearly all of the + additional warning switches (not activated by -Wall) + to verify all code. Many things that non-gcc + compilers could complain about should be fixed in + this version. + * "Video Driver" option not shown if there's only one + choice. (Which is the case if you build w/o OpenGL.) + * Exit with ESCAPE from config menues fixed - now + cancels any changes and plays the appropriate sfx. + * Solaris package building script 'buildpkg.sh' and + required configure.in fix by Andreas Spångberg added. + * String copy bug in cfgparse.cpp fixed. (Andreas + Spångberg.) + * Switching between windowed and fullscreen modes no + more results the screen being offset. + * Screen centering fixed. + * Border in windowed mode fixed. + * Cleaned up audio config menu, and added volume + controls for sfx, (future) intro music and in-game + music. (Note that the "Master Volume" is still + there, and it's still digital...) + * Icreased the number of volume levels available in + the audio config menu. (Used to be 25% increments.) + * Added redefined() and accept() to config_parser_t. + * Non-interactive widgets handled correctly in menues. + * Added headers to configuration menues. + * Added 'unit' string to ct_spin_t. + * window_t::select() now comes in a private flavor + without checks. + * Config menues now make use of OS_UPDATE_* flags in + addition to the OS_CANCEL tag, to allow instant + effect controls to cancel/undo properly. + * config_form_t now has a virtual member undo_hook() + that's called by undo(). (Used to make ESC exit work.) + * Audio engine changes: + * Channels are separated into voices (mixing) + and channels (control abstraction) levels. + * Groups added for easy channel management. + * The API provides access to channels and + groups, but not direct access to voices. + * All fixed point values are now 16:16. + * API variants with float arguments added. + * AC_DETACH added. (Easy SFX control.) + * Panning/balance control added. + * Added "waves" to get rid of sample pointers. + * AC_SPEED removed. (Obsoleted by the internal + conversion to original wave sample rates.) + * Fixed bug in reverb: Right input missing! + * Another reverb bug: The delay buffer was too + short for >=32000 kHz with the current taps. + * Implemented AC_RETRIG and AC_RANDTRIG. + * Improved resampling frequency accuracy. + * Improved looping accuracy and quality. + * Added MIDI input implementation for OSS and + ALSA raw MIDI interfaces. + * Fixed potential crash bug; mixing buffer + size variable would be wrong if the desired + buffer size couldn't be set! + * Added higher quality voice resamplers. + * sound.[ch] replaced by a_wave.[ch]. + * Auto trig w/ timeout on the oscilloscope. + * 8 & 16 bit mono + 16 bit stereo added. + * Engine code restructured and modularized. + * "Waveform Construction API" added. + * Channel->bus->master mixing architecture. + * FX plugin API added. (Internal, for now.) + * Reverb LPF cutoff made configurable and + independent of the sample rate. + * Added generic "browsing" API to config_parser_t. + * Added a copy of LGPL 2.1, and started sorting out + which licence applies where. (Basically, the old code + is GPL, while most of the new code I've written from + scratch is LGPL.) + * Added window_t::center_token[_fxp]() for nice columns. + * Started documenting a little... + * Added "Audio CPU Load" screen for gcc/x86. (Needs + high resolution timestamping, and I'm using RDTSC for + now.) + * Added text alignment system for the ct_* widgets, to + make use of the new center_token() methods. + * Various tweaks and adjustments. + * Credits updated. + +Kobo Deluxe v0.4-pre5 + * New versioning rules introduced; + * Any -preX suffix should *always* be included + in AM_INIT_AUTOMAKE(). + * No more development snapshots - every package + released has a version number of it's own, + with a -preX suffix if appropriate. + * Surface leak when reloading graphics fixed. + * gfxengine_t::unload() now takes -1 (default) for + unloading all banks. + * gfxengine_t::unload() also destroys SoFont objects! + * Void pointer arithmetics and some bogus braces fixed. + (Thanks, Riki!) + * Moved sound effects out into files. (Raw format for + now, as WAV doesn't support signed 8 bit data...) + * Minor sound code cleanups. + * bgmfile.[ch] removed. (Used to be Linux only anyway...) + * config_parser_t created. (prefs_t is now derived from + that class, and contains no parsing code whatsoever.) + Also eliminates duplication of "command" decoding for + non-config stuff like -showcfg, -debug and -fps. + * SDL_VIDEOEXPOSE is *finally* at least handled! :-) + * Removed gcc-only compiler flags and fixed other stuff + that caused trouble with some compilers. (Thanks to + Andreas Spångberg for the Solaris patch!) + * Menu and state code cleaned up a little. + * Configuration menu split up into Video, Audio, + Controls and Game. + * ct_list_t now interprets change(0) (ie button press + or similar) as change(1), rather than just ignoring + it. + +Kobo Deluxe v0.4-pre4 + * Replaced corrupted README.jp. + * Delayed fps printout to program exit, as some setups + have serious trouble with output to the console while + running the game. + * Fixed a sleeping bug in the gl_blendfunc() wrapper. + * It's now possible to quit gracefully while loading + data. (Check when updating the progress bar.) + * Old style mouse control is back. (Not that I + understand how anyone could play with that... :-) + * Bigger and more visible mouse crosshair. + * Added 'mouse' switch and 'mousemode' variable to + config. (MMD_RELATIVE not yet implemented!) + * Video config cleaned up - unsupported OpenGL + settings removed. + * Radar window code cleaned up and simplified. + * window_t::alloc_color renamed to map_rgb, which is + more appropriate. The new version takes either three + Uint8 components (rather than X style Uint16), or an + Uint32 for "HTML style" hex codes. + * Diagonal rocket sprites lined up with diagonal Kobo + (the player's ship! :-) sprites. (The ship has an + offset of +1 pixel in y in the gfx) + * Added missing (8'th) frame to explosion animation. + * glSDL: + * Some tiling bugs fixed. + * Single tile case optimized. + * Vertical tiling implemented. + * Horizontal and vertical tiling across multiple + textures implemented! (Not both h & v, though.) + * Off-screen blits are culled. + * Benchmark results: + P-III 933, Matrox G400, XFree86 4.1.0-17mdk: + Resolution SDL 2D glSDL ratio + ----------------------------------------------- + 1280x1024 16 60 3.8 + 960x720 28 102 3.6 + 640x480 62 202 3.3 + 320x240 227 205 0.9 + + Note that OpenGL is pumping quite a bit more pixels + than SDL's RLE blitter in this game, due to the alpha + blended window frame. Here are the results with no + frame: + P-III 933, Matrox G400, XFree86 4.1.0-17mdk: + Resolution SDL 2D glSDL ratio + ----------------------------------------------- + 1280x1024 18 93 5.2 + 960x720 32 163 5.1 + 640x480 70 205 2.9 + 320x240 256 205 0.8 + Notice how glSDL appears to win even more in higher + resolutions, while it loses a little to SDL 2D in the + low end, where fill rate becomes next to insignificant + to OpenGL. + +Kobo Deluxe v0.4-pre3 + * Hitting the window close button now causes a "brutal" + quit, just like hitting ctrl-C in the console. + * Mac OS X OpenGL build script fix. + * Now uses SDL_opengl.h if present. (Dunno if the check + is totally portable, though - but if it fail, at least + things shouldn't be worse than with the old way.) + * Implemented tiling of wide surfaces. + * Does *not* support multiple textures, so it + won't help with wide *and* tall surfaces, that + simply won't fit in one texture. (Sorry, + 256x256 people! ;-) + * The rendering loop for tall surface tiling is + missing... (Mostly a matter of cut'n'paste + + search'n'replace.) + * Anyway, this means that Kobo Deluxe now + RENDERS PERFECTLY ON OPENGL! :-) + +Kobo Deluxe v0.4-pre2 + * The glSDL layer: + * Now uses handles instead of pointers! + * Various bugs and stability issues fixed. + --> Still misses vital features. + --> Leaks textures - or at least TexInfos. + * Some double buffer compatibility issues fixed. + * "Stall" when rebuilding menues fixed. + +Kobo Deluxe v0.4-pre1 + * Build with OpenGL on X fixed - without breaking Win32 + and Mac OS X! + * Added dummy score file to keep stupid WinZip from + removing 'scoredir'... + * Added README.jp translated by Tsuyoshi Iguchi (?). + +Kobo Deluxe v0.3 + * Name officially changed to 'Kobo Deluxe' + * Upgraded to sfifo-1.2. + * Various configure script fixes. + * Added README file. + * Updated logo. + * Added filemapper_t, to handle paths on all platforms. + * Rearranged main loop to handle re-initialization. + * Fixed garbage after name in score files. + * Rearranged score management code slightly. + * Added prefs_t, which can parse, read and write options + from/to command line args and files. + * Kobo now tries to save a backup of the user score file + in the user's home dir. + * Cleaned up the game state system a bit, and added + confirmation dialogs before aborting game or quitting + Kobo. + * Added various eye candy. + * Added "Options" page. + * Class myship now releases the player ship object as well + when turned off. (myship, and a bunch of other objects, + won't be destroyed and re-created when reinitializing.) + * Moved graphics/ and audio/ from source to include path. + * Added sound effects to the user interface. + * Added Mac OS X fixes by Max Horn + * Quits on window close event (Max Horn ) + * Paths for Mac OS X bundles added. + * Fixed +/- keys for selecting level. (Thanks Max!) + * Automatic timed logo/highscore switch added. + * Credits screen added. + * Simple scroll text added. + * Win32 and Mac OS X bundle install styles added. + * Added feedback delay based reverb with LP filters. + * Added limiter/AGC with threshold and release params. + * Joystick support; Samuel Hart . + * Filter plugin support added to "sprite". + * Plugins added: rgb8, rgba8, cleanalpha, key2alpha, scale + and displayformat. + * Implemented the "size" feature with three different + scaling filter modes. + * Sprite and tile "palettes" separated for correct scaling. + * Added various "fade out" effects. + * Added "LOADING" screen. + * Added "Screen Buffer Mode" setting with single, double, + semi triple and half buffering modes. (Note that the game + doesn't yet support all of them properly.) + * Added FPS counter. (-fps switch) + * Progress bar while loading and converting data. + * gamestatemanager_t instead of those switch() statements... + * Added "Get Ready" and "Game Over" states. + * Improved filemapper_t and score_t portability. (I think...) + * Removed annoying key state clearing. + * SoFont: + * CleanSurface() now only cleans the top row. + * Fixed rounding when spacer width is odd. + * No testing of '|' (for cursor) if the font + doesn't have it. + * CS engine: + * Freeing free objects won't crash the engine. + * Safer and (probably) faster wrapping code. + * "width" and "height" replace "size" option. + * Cleaned up config_form_t and added a "rebuild" action for + dynamic configuration panels. + * Added config options and gfxengine_t::driver(). (No OpenGL + code yet. OpenGL options hidden in "options".) + * Added a thin black border in windowed mode. + * Proper clipping done by window_t::invalidate() and + gfxengine_t::invalidate(). + * Sprite and text calls for fixed point coordinates added. + * Fixed gfxengine_t::loadrect() - it dropped the RLE! + * Added contrast and offset parameters to cleanalpha plugin. + * Audio engine: + * Added "nearest sample" resampling support. + * Improved sample looping accuracy. + * Added "samplerate" option. + * Random pitch effect on some sound effects. + * Improved pause mode. (Switches to "get ready".) + * BTN_FIRE can now be used to start game from intro. + * Cleanup + fix: SHIPS display is now updated correctly. + * Added quick hack OpenGL rendering layer. (64 bit broken!) + * "Escape" in pause mode now sends you to "Abort Game?". + * Added AdvanceMAME "Scale2x" scaling filter. + * Gave up on Scale2x + fuzziness factor - it just won't work + for 256+ color graphics. (It's still there, though.) + * Added Diamond2x scaling filter - The Best so far! Also + very fast, even without serious optimizations. + * Various scaling filter bug fixes and cleanups. + * C++ extension changed from '.C' to '.cpp'. + * Linux/i586/VGA vidsync hack removed. + * Added main menu with "Start Game!", "Options" etc. + * sprite.c: Size check for loading sprite palettes. + * Added rotating tube effect for menu highlighting. + +*** Name changed to "Kobo Deluxe". + +SKobo v0.2 + * "sprite.c" now uses SDL_DisplayFormatAlpha(). + * Various autoconf checks added and implemented. + * Audio ported to SDL. (OSS support remains.) + * "-latency XXX" argument to set maximum desired audio + latency in milliseconds. Default is 50 ms. + * Added control API to audio engine. (Moved looping there.) + * Initial Win32 support: + * Hacked temporary kludge in score.C + * Added _snprintf define for snprintf() + +SKobo v0.1 update (forgot to mention this...) + * GIMPed new "Kobo Next Generation" logo. + * Added the display_t class, which inherits from window_t, + and forms a display with a caption and text field. + * Added GIMPed framework for the whole screen. + * Re-implemented the "starfield" by grabbing 64 starry + tiles from an XKobo screenshot. + * Centered radar screen vertically, moving "stage" and + "ships" down below the radar screen. + * Added "HIGHSCORE" display. + +SKobo v0.1 + * Removed all X specific code. + * Added graphics and control system code from Project Spitfire. + * Wrote gfxengine_t class. (Control system + video wrapper.) + * Rearranged source tree and switched to autoconf/automake. + * Wrote window_t class. (Clipping, scrolling etc.) + * Fixed some bugs in sprite.c and cs.c. (*heh*) + * Added text using the C++ version of SFont; SoFont. + * Changed audiodev_t to open in nonblocking mode, to avoid the + game going to sleep if the device is busy. SKobo disables + sound FX if the audio device cannot be opened. + * Pixeled new font and GIMPed a temorary logo. + * Added alpha blended frame with rounded corners. + * Added scrolling background (level 20) in intro mode. + * Selecting starting level now shows the selected level in + the radar display and intro screen background. + * Enlarged the core diameter by two pixels. + +*** David Olofson forks from 'V1.11+-do3', and + calls the new branch SKobo, with version numbers starting over + at 0.1. + +V1.11+-do3 + * Cleaned up audio code and API. + * Added sample looping feature. + * Changed mixed fp/integer mixer into integer-only. + * Increased internal mixer level to avoid dropping bits. + * Fixed silly bug from -do2: The original sound was indeed + in stereo! <:*) + +V1.11+-do2 + * Adjusted sound effects reference level. (Louder sfx.) + +V1.11+-do1 + * Ported sound to OSS + * Sound is enabled by default (use -nosound to disable) + * Made audio run asynchronously with lock-free command FIFO + +*** David Olofson picks up XKobo 1.11+ from Izumo, + adding '-doX' to the version code. + +V1.11+ + * SGI sound added. + * Triple size mode added. + +*** Masanao Izumo picks up XKobo 1.11, appending + '+' to the version code. + +V1.11 + * ?? + +V1.10 + * fixed an endianness problem of score files + * secure score files + +V1.9 + * take measure against system calls interrupted by SIGALRM + * '-hiscores' option + * bonus ships + +V1.8 + * add close() in file.C + +V1.7 + * enabled to move on diagonals using the numeric keypad + +V1.6 + * support for Solaris 2 + +V1.5 + * ceased to use semaphores + * fixed a strange usage of setitimer + * '-wait' option + +V1.4 + * '-cheat' option + * enabled to play using a mouse + * enabled to compile with gcc-2.7.0 + +V1.3 + * fixed a bug about '-fit' option + * enabled to select a stage to play + +V1.2 + * support for TrueColor X server + * '-fit' option + * '-doublesize' option + +V1.1 + * first uploaded to tsx-11.mit.edu diff --git a/Info.plist.in b/Info.plist.in new file mode 100644 index 0000000..85b6f39 --- /dev/null +++ b/Info.plist.in @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + @EXEFILE@ + CFBundleGetInfoString + @VERSION@, Copyright 2001 David Olofson + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + @PACKAGE@ + CFBundlePackageType + APPL + CFBundleShortVersionString + @VERSION@ + CFBundleSignature + ???? + CFBundleVersion + @VERSION@ + NSMainNibFile + SDLMain.nib + NSPrincipalClass + NSApplication + NSHumanReadableCopyright + Copyright 2001 David Olofson + + diff --git a/KoboPlayer b/KoboPlayer new file mode 100644 index 0000000..6ec7491 Binary files /dev/null and b/KoboPlayer differ diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..5bb9240 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,110 @@ +if BUILD_MACOSX_BUNDLE +bundle_contents = @PACKAGE@.app/Contents +else +if BUILD_SIMPLE_BUNDLE +bundle_contents = @PACKAGE@ +endif +endif + +kobo_scoredir=@SCOREDIR@ + +INCLUDES = -DKOBO_DATA_DIR=\""@DATADIR@"\" \ + -DKOBO_SCORE_DIR=\""$(kobo_scoredir)"\" \ + -DKOBO_CONFIG_DIR=\""@CONFIGDIR@"\" \ + -DKOBO_CONFIG_FILE=\""@CONFIGFILE@"\" \ + -DSYSCONF_DIR=\""$(sysconfdir)"\" \ + -Isound -Igraphics -Ieel -Idata/sfx @LOCALCFLAGS@ + +SUBDIRS = graphics sound data eel + +bin_PROGRAMS = kobodl + +GRAPHICS_LIB = graphics/libgraphics.a @MATHLIB@ +SOUND_LIB = sound/libsound.a @AUDIO_LIBS@ +EEL_LIB = eel/libeel.a + +kobodl_SOURCES = enemies.cpp enemy.cpp pfile.cpp gamectl.cpp manage.cpp map.cpp \ + myship.cpp radar.cpp random.cpp scenes.cpp score.cpp screen.cpp \ + filemap.cpp prefs.cpp cfgform.cpp options.cpp gamestate.cpp \ + states.cpp form.cpp cfgparse.cpp game.cpp kobo.cpp logger.c \ + dashboard.cpp sound.cpp +kobodl_LDADD = $(GRAPHICS_LIB) $(SOUND_LIB) $(EEL_LIB) + +kobodl_LDFLAGS = -o $(EXEFILE) + +man_MANS = kobodl.6 + +CLEANFILES = $(EXEFILE) Info.plist log.html + +AUTOMAKE_OPTIONS = foreign + +EXTRA_DIST = *.h Info.plist.in KoboPlayer COPYING.LIB *.txt \ + README.jp README.sfont README.xkobo README.xkobo.jp README.osx \ + README.html \ + cfg-work cfg-beta cfg-release cfg-profile cfg-cross-release \ + cfg-work-opt buildpkg.sh kobodl.6 icons.tar.gz + + +if BUILD_MACOSX_BUNDLE + +@PACKAGE@_bundle: ${EXEFILE} + mkdir -p $(bundle_contents)/MacOS + echo "APPL????" > $(bundle_contents)/PkgInfo + $(INSTALL_DATA) Info.plist $(bundle_contents) + $(INSTALL_PROGRAM) ${EXEFILE} $(bundle_contents)/MacOS/ + +install-exec-hook: @PACKAGE@_bundle + rm -rf $(DESTDIR)$(prefix)/@PACKAGE@.app + mkdir -p $(DESTDIR)$(prefix)/ + cp -r @PACKAGE@.app $(DESTDIR)$(prefix)/ + +clean-local: + rm -rf $(bundle_contents) + +else + +if BUILD_SIMPLE_BUNDLE + +@PACKAGE@_bundle: ${EXEFILE} + $(INSTALL_PROGRAM) ${EXEFILE} $(bundle_contents)/ + +install-exec-hook: @PACKAGE@_bundle + rm -rf $(DESTDIR)/$(prefix)/@PACKAGE@ + mkdir -p $(DESTDIR)/$(prefix)/ + cp COPYING @PACKAGE@/COPYING.txt + cp COPYING.LIB @PACKAGE@/COPYING_LIB.txt + cp ChangeLog @PACKAGE@/ChangeLog.txt + cp TODO @PACKAGE@/TODO.txt + cp README @PACKAGE@/README.txt + cp README.jp @PACKAGE@/README_jp.txt + cp README.sfont @PACKAGE@/sfont.txt + cp README.xkobo @PACKAGE@/xkobo.txt + cp README.xkobo.jp @PACKAGE@/xkobo_jp.txt + cp KoboPlayer @PACKAGE@/scores/42 + cp -r @PACKAGE@ $(DESTDIR)/$(prefix)/ + +clean-local: + rm -rf $(bundle_contents) + +else +@PACKAGE@_bundle: + +install-exec-hook: + +clean-local: + +endif + +endif + + +if UNIX_SCOREDIR + +install-data-hook: $(DESTDIR)$(kobo_scoredir) + chmod a+w $(DESTDIR)$(kobo_scoredir) + +else + +install-data-hook: + +endif diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..5f5c6ed --- /dev/null +++ b/Makefile.in @@ -0,0 +1,885 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +bin_PROGRAMS = kobodl$(EXEEXT) +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Info.plist.in \ + $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/aconfig.h.in $(top_srcdir)/configure COPYING \ + COPYING.LIB ChangeLog TODO acconfig.h compile config.guess \ + config.sub depcomp install-sh missing mkinstalldirs +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno configure.status.lineno +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = aconfig.h +CONFIG_CLEAN_FILES = Info.plist +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man6dir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_kobodl_OBJECTS = enemies.$(OBJEXT) enemy.$(OBJEXT) pfile.$(OBJEXT) \ + gamectl.$(OBJEXT) manage.$(OBJEXT) map.$(OBJEXT) \ + myship.$(OBJEXT) radar.$(OBJEXT) random.$(OBJEXT) \ + scenes.$(OBJEXT) score.$(OBJEXT) screen.$(OBJEXT) \ + filemap.$(OBJEXT) prefs.$(OBJEXT) cfgform.$(OBJEXT) \ + options.$(OBJEXT) gamestate.$(OBJEXT) states.$(OBJEXT) \ + form.$(OBJEXT) cfgparse.$(OBJEXT) game.$(OBJEXT) \ + kobo.$(OBJEXT) logger.$(OBJEXT) dashboard.$(OBJEXT) \ + sound.$(OBJEXT) +kobodl_OBJECTS = $(am_kobodl_OBJECTS) +am__DEPENDENCIES_1 = graphics/libgraphics.a +am__DEPENDENCIES_2 = sound/libsound.a +am__DEPENDENCIES_3 = eel/libeel.a +kobodl_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_3) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I. +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +SOURCES = $(kobodl_SOURCES) +DIST_SOURCES = $(kobodl_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +man6dir = $(mandir)/man6 +NROFF = nroff +MANS = $(man_MANS) +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUDIO_LIBS = @AUDIO_LIBS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_MACOSX_BUNDLE_FALSE = @BUILD_MACOSX_BUNDLE_FALSE@ +BUILD_MACOSX_BUNDLE_TRUE = @BUILD_MACOSX_BUNDLE_TRUE@ +BUILD_SIMPLE_BUNDLE_FALSE = @BUILD_SIMPLE_BUNDLE_FALSE@ +BUILD_SIMPLE_BUNDLE_TRUE = @BUILD_SIMPLE_BUNDLE_TRUE@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONFIGDIR = @CONFIGDIR@ +CONFIGFILE = @CONFIGFILE@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXEFILE = @EXEFILE@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LOCALCFLAGS = @LOCALCFLAGS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MATHLIB = @MATHLIB@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POW_LIB = @POW_LIB@ +RANLIB = @RANLIB@ +SCOREDIR = @SCOREDIR@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +UNIX_SCOREDIR_FALSE = @UNIX_SCOREDIR_FALSE@ +UNIX_SCOREDIR_TRUE = @UNIX_SCOREDIR_TRUE@ +VERSION = @VERSION@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@bundle_contents = @PACKAGE@ +@BUILD_MACOSX_BUNDLE_TRUE@bundle_contents = @PACKAGE@.app/Contents +kobo_scoredir = @SCOREDIR@ +INCLUDES = -DKOBO_DATA_DIR=\""@DATADIR@"\" \ + -DKOBO_SCORE_DIR=\""$(kobo_scoredir)"\" \ + -DKOBO_CONFIG_DIR=\""@CONFIGDIR@"\" \ + -DKOBO_CONFIG_FILE=\""@CONFIGFILE@"\" \ + -DSYSCONF_DIR=\""$(sysconfdir)"\" \ + -Isound -Igraphics -Ieel -Idata/sfx @LOCALCFLAGS@ + +SUBDIRS = graphics sound data eel +GRAPHICS_LIB = graphics/libgraphics.a @MATHLIB@ +SOUND_LIB = sound/libsound.a @AUDIO_LIBS@ +EEL_LIB = eel/libeel.a +kobodl_SOURCES = enemies.cpp enemy.cpp pfile.cpp gamectl.cpp manage.cpp map.cpp \ + myship.cpp radar.cpp random.cpp scenes.cpp score.cpp screen.cpp \ + filemap.cpp prefs.cpp cfgform.cpp options.cpp gamestate.cpp \ + states.cpp form.cpp cfgparse.cpp game.cpp kobo.cpp logger.c \ + dashboard.cpp sound.cpp + +kobodl_LDADD = $(GRAPHICS_LIB) $(SOUND_LIB) $(EEL_LIB) +kobodl_LDFLAGS = -o $(EXEFILE) +man_MANS = kobodl.6 +CLEANFILES = $(EXEFILE) Info.plist log.html +AUTOMAKE_OPTIONS = foreign +EXTRA_DIST = *.h Info.plist.in KoboPlayer COPYING.LIB *.txt \ + README.jp README.sfont README.xkobo README.xkobo.jp README.osx \ + README.html \ + cfg-work cfg-beta cfg-release cfg-profile cfg-cross-release \ + cfg-work-opt buildpkg.sh kobodl.6 icons.tar.gz + +all: aconfig.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +.SUFFIXES: .c .cpp .o .obj +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ + cd $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) + +aconfig.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/aconfig.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status aconfig.h +$(srcdir)/aconfig.h.in: $(am__configure_deps) $(top_srcdir)/acconfig.h + cd $(top_srcdir) && $(AUTOHEADER) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f aconfig.h stamp-h1 +Info.plist: $(top_builddir)/config.status $(srcdir)/Info.plist.in + cd $(top_builddir) && $(SHELL) ./config.status $@ +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +kobodl$(EXEEXT): $(kobodl_OBJECTS) $(kobodl_DEPENDENCIES) + @rm -f kobodl$(EXEEXT) + $(CXXLINK) $(kobodl_LDFLAGS) $(kobodl_OBJECTS) $(kobodl_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfgform.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfgparse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dashboard.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enemies.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enemy.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filemap.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/form.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/game.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gamectl.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gamestate.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kobo.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logger.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/manage.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/myship.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pfile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prefs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/radar.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/random.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scenes.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/score.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/screen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sound.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/states.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: +install-man6: $(man6_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + test -z "$(man6dir)" || $(mkdir_p) "$(DESTDIR)$(man6dir)" + @list='$(man6_MANS) $(dist_man6_MANS) $(nodist_man6_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.6*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 6*) ;; \ + *) ext='6' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man6dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man6dir)/$$inst"; \ + done +uninstall-man6: + @$(NORMAL_UNINSTALL) + @list='$(man6_MANS) $(dist_man6_MANS) $(nodist_man6_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.6*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 6*) ;; \ + *) ext='6' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f '$(DESTDIR)$(man6dir)/$$inst'"; \ + rm -f "$(DESTDIR)$(man6dir)/$$inst"; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) aconfig.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) aconfig.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) aconfig.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) aconfig.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + mkdir $(distdir) + $(mkdir_p) $(distdir)/. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-recursive +all-am: Makefile $(PROGRAMS) $(MANS) aconfig.h +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man6dir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic clean-local mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-man + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-data-hook + +install-exec-am: install-binPROGRAMS + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-exec-hook + +install-info: install-info-recursive + +install-man: install-man6 + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man + +uninstall-info: uninstall-info-recursive + +uninstall-man: uninstall-man6 + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \ + check-am clean clean-binPROGRAMS clean-generic clean-local \ + clean-recursive ctags ctags-recursive dist dist-all dist-bzip2 \ + dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \ + distclean-compile distclean-generic distclean-hdr \ + distclean-recursive distclean-tags distcleancheck distdir \ + distuninstallcheck dvi dvi-am html html-am info info-am \ + install install-am install-binPROGRAMS install-data \ + install-data-am install-data-hook install-exec install-exec-am \ + install-exec-hook install-info install-info-am install-man \ + install-man6 install-strip installcheck installcheck-am \ + installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am uninstall-binPROGRAMS uninstall-info-am \ + uninstall-man uninstall-man6 + + +@BUILD_MACOSX_BUNDLE_TRUE@@PACKAGE@_bundle: ${EXEFILE} +@BUILD_MACOSX_BUNDLE_TRUE@ mkdir -p $(bundle_contents)/MacOS +@BUILD_MACOSX_BUNDLE_TRUE@ echo "APPL????" > $(bundle_contents)/PkgInfo +@BUILD_MACOSX_BUNDLE_TRUE@ $(INSTALL_DATA) Info.plist $(bundle_contents) +@BUILD_MACOSX_BUNDLE_TRUE@ $(INSTALL_PROGRAM) ${EXEFILE} $(bundle_contents)/MacOS/ + +@BUILD_MACOSX_BUNDLE_TRUE@install-exec-hook: @PACKAGE@_bundle +@BUILD_MACOSX_BUNDLE_TRUE@ rm -rf $(DESTDIR)$(prefix)/@PACKAGE@.app +@BUILD_MACOSX_BUNDLE_TRUE@ mkdir -p $(DESTDIR)$(prefix)/ +@BUILD_MACOSX_BUNDLE_TRUE@ cp -r @PACKAGE@.app $(DESTDIR)$(prefix)/ + +@BUILD_MACOSX_BUNDLE_TRUE@clean-local: +@BUILD_MACOSX_BUNDLE_TRUE@ rm -rf $(bundle_contents) + +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@@PACKAGE@_bundle: ${EXEFILE} +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ $(INSTALL_PROGRAM) ${EXEFILE} $(bundle_contents)/ + +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@install-exec-hook: @PACKAGE@_bundle +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ rm -rf $(DESTDIR)/$(prefix)/@PACKAGE@ +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ mkdir -p $(DESTDIR)/$(prefix)/ +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp COPYING @PACKAGE@/COPYING.txt +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp COPYING.LIB @PACKAGE@/COPYING_LIB.txt +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp ChangeLog @PACKAGE@/ChangeLog.txt +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp TODO @PACKAGE@/TODO.txt +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp README @PACKAGE@/README.txt +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp README.jp @PACKAGE@/README_jp.txt +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp README.sfont @PACKAGE@/sfont.txt +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp README.xkobo @PACKAGE@/xkobo.txt +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp README.xkobo.jp @PACKAGE@/xkobo_jp.txt +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp KoboPlayer @PACKAGE@/scores/42 +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp -r @PACKAGE@ $(DESTDIR)/$(prefix)/ + +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@clean-local: +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ rm -rf $(bundle_contents) + +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_FALSE@@PACKAGE@_bundle: + +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_FALSE@install-exec-hook: + +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_FALSE@clean-local: + +@UNIX_SCOREDIR_TRUE@install-data-hook: $(DESTDIR)$(kobo_scoredir) +@UNIX_SCOREDIR_TRUE@ chmod a+w $(DESTDIR)$(kobo_scoredir) + +@UNIX_SCOREDIR_FALSE@install-data-hook: +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/README b/README new file mode 100644 index 0000000..f4e50d6 --- /dev/null +++ b/README @@ -0,0 +1,370 @@ +(This document was generated from the kobodl.6 'man' file.) + + Kobo Deluxe + ----------- + v0.5.1 + + An enhanced port + of the scrolling video game + XKobo + +DESCRIPTION + Kobo Deluxe is a 3'rd person scrolling 2D shooter with a simple and + responsive control system - which you'll need to tackle the tons of + enemy ships that shoot at you, chase you, circle around you shooting, + or even launch other ships at you, while you're trying to destroy the + labyrinth shaped bases. There are 50 action packed levels with smoothly + increasing difficulty, and different combinations of enemies that + require different tactics to be dealt with successfully. + + Kobo Deluxe has an improved graphics engine that delivers smoother ani- + mation, while keeping the game logic totally accurate and predictable + regardless of frame rate. It also adds sound effects, new graphics, + fullscreen mode, four extra skill levels with smoother gameplay and + various other features expected from a modern game. (There is still a + "Clasic" mode that plays exactly like the original XKobo.) + + Kobo Deluxe uses SDL for sound, graphics and input, and builds and runs + on all major operating systems, as well as some more unusual platforms. + It can also use OpenGL for accelerated rendering, through glSDL. + + In short, Kobo Deluxe is loads of classical arcade style fun for just + about any machine with graphics and sound! + +CONTROLS + The ship can be controlled with the keyboard, or optionally a mouse or + joystick. With the keyboard, the arrow keys move the ship (two keys for + diagonals), and the shift and ctrl keys shoots. The numeric key pad can + also be used; the usual 2/4/6/8 (arrows), and also 1/3/7/9 for single + key diagonals. Escape enters the meny system, from where it is possi- + ble to change settings, start a new game or exit the game. + +OPTIONS + Note that all relevant options can be also configured in the config + file, which can be edited directly, or using the options menus in the + game. + + -[no]logfile + Log To File. Default: Off. + + -logformat + Log File Format. Default: 0. + + -logverbosity + Log Verbosity Level. Default: 2. + + -[no]joystick + Use Joystick. Default: Off. + + -joystick_no + Joystick Number. Default: 0. + + -[no]mouse + Use Mouse. Default: Off. + + -mousemode + Mouse Control Mode. Default: 1. + + -[no]broken_numdia + Broken NumPad Diagonals. Default: Off. + + -dia_emphasis + Diagonals Emphasis Filter. Default: 0. + + -[no]always_fire + Always Fire. Default: Off. + + -[no]mousecapture + In-game Mouse Capture. Default: On. + + -scrollradar + Radar Scroll Mode. Default: 2. + + -[no]filter + Enable/disable motion interpolation. Interpolation is what makes + animation smooth at high frame rates despite the game logic run- + ning at 33.33 fps. However, it also adds some input latency! + Default: On. + + -timefilter + Time filter, for smoothing out timing jitter induced by the + operating system. Default: 50. + + -countdown + Get Ready Countdown. Default: 5. + + -starfield + Starfield Style. Default: 2. + + -stars Number of Parallax Stars. Default: 500. + + -overheatloud + Overheat Warning Loudness. Default: 100. + + -cannonloud + Player Cannons Loudness. Default: 100. + + -[no]sound + Enable Sound. Default: On. + + -[no]music + Enable Music. Default: On. + + -[no]cached_sounds + Use Cached Sounds. Default: Off. + + -[no]oss + Use OSS Sound Driver. Default: Off. + + -samplerate + Sample Rate. Default: 44100. + + -latency + Sound Latency. Default: 50. + + -mixquality + Mixing Quality. Default: 3. + + -vol Master Volume. Default: 100. + + -intro_vol + Intro Music Volume. Default: 100. + + -sfx_vol + Sound Effects Volume. Default: 100. + + -music_vol + In-Game Music Volume. Default: 50. + + -reverb + Reverb Level. Default: 100. + + -vol_boost + Volume Boost. Default: 0. + + -[no]fullscreen + Fullscreen Display. Default: Off. + + -videodriver + Display Driver. Default: 0. + + -width Horizontal Resolution. Default: 640. + + -height + Vertical Resolution. Default: 480. + + -aspect + Pixel Aspect Ratio. Default: 1000. + + -depth Display Depth. Default: 0. + + -maxfps + Limit the framerate (fps). Saves power on laptops (75 works + well), and can also avoid long stalls due to timesharing and + background processes. Default: 100. + + -maxfpsstrict + Strictly Regulated fps. Default: 0. + + -buffer + Display Buffer Mode. Default: 1. + + -[no]shadow + Use Software Shadow Buffer. Default: On. + + -videomode + Video Mode. Default: 17200. + + -[no]vsync + Enable Vertical Sync. Default: On. + + -videopages + Number of Video Pages. Default: -1. + + -scalemode + Scaling Filter Mode. Default: 1. + + -[no]dither + Use Dithering. Default: On. + + -dither_type + Dither Type. Default: 0. + + -[no]broken_rgba8 + Broken RGBA (OpenGL). Default: Off. + + -[no]alpha + Use Alpha Blending. Default: On. + + -brightness + Brightness. Default: 100. + + -contrast + Contrast. Default: 100. + + -files Specify the root path of the game. Default: "" + + -gfx Specify the path to the game's graphics data. Default: "" + + -sfx Specify the path to the game's sound data. Default: "" + + -scores + Specify the path to the game's score files. Default: "" + + -size (Not saved!) Screen Size (Obsolete). Default: 0. + + -wait Game Speed (Obsolete). Default: 30. + + -bgm (Not saved!) Background Music File (Obsolete). Default: "" + + -threshold + (Not saved!) Limiter Gain. Default: 200. + + -release + (Not saved!) Limiter Speed. Default: 50. + + -internalres + (Not saved!) Texture Resolution. Default: 1. + + -last_profile + Last used player profile. Default: 0. + + -number_of_joysticks + Number of Connected Joysticks. Default: 0. + + -[no]showcfg + (Not saved!) Show Configuration. Default: Off. + + -[no]hiscores + (Not saved!) List High Scores. Default: Off. + + -[no]highscores + (Not saved!) List High Scores. Default: Off. + + -[no]override + (Not saved!) Ignore Configuration File. Default: Off. + + -[no]debug + (Not saved!) Enable Debug Features. Default: Off. + + -[no]fps + (Not saved!) Display frames per second in game screen. Default: + Off. + + -[no]noframe + (Not saved!) Do not render rounded corners on the playfield. + Default: Off. + + -[no]midi + (Not saved!) Enable MIDI Input. Default: Off. + + -[no]cheat + (Not saved!) Enable/disable cheat mode. Cheat mode allows any + level to be played, but highscores are not saved! Default: Off. + + -[no]indicator + (Not saved!) Enable Collision Indicator Mode. Default: Off. + + -[no]pushmove + (Not saved!) Enable Push Move Mode. Default: Off. + + -[no]noparachute + (Not saved!) Disable SDL Parachute. Default: Off. + + -[no]pollaudio + (Not saved!) Use Polling Audio Output. Default: Off. + + -[no]autoshot + (Not saved!) Ingame screenshots/movie. Default: Off. + + -[no]help + (Not saved!) Print usage info and exit. Default: Off. + + -[no]options_man + (Not saved!) Print options for 'man'. Default: Off. + +FILES + ~/.kobodlrc + The per-user configuration file for Kobo Deluxe. + +AUTHORS + Originally written by Akira Higuchi (a-higuti@math.hokudai.ac.jp), + XKobo was turned into Kobo Deluxe by David Olofson + +THANKS + Thanks, in no particular order, to... + + Akira Higuchi + Author of the Original XKobo. + + Masanao Izumo + Sound effects and original sound engine. + + Torsten Giebl + Slackware. + + David Andersson + Various Good Ideas. + + Max Horn + Mac OS X & Build Script Patches. + + Jeremy Sheeley + Player Profiles. + + Tsuyoshi Iguchi + FreeBSD, NetBSD. + + Samuel Hart + Joystick Support. + + G. Low Solaris. + + Gerry Jo Trick Jellestad + Testing and ideas. + + Riki Intel Compiler. + + Andreas Spaangberg + Sun Compiler & Bug Spotting. + + SixK Amiga Port. + + Joey Hess + Debian. + + Martijn van Oosterhout + FPS limiter. + + Antonio Messina + Stage 1601+ difficulty wrap, Always Fire option. + + Hans de Goede + Audio buffer handling bug. + + Marianne Ibbotson + "Autopause" idea. + + Sam Palmer + MS Windows testing. + + Michael Sterrett + glSDL issues. + + Sam Lantinga & Others + SDL, the Simple DirectMedia library. + + Members of the SDL mailing list + Testing and ideas. + +COPYRIGHT + Copyright (c) 1995, 1996 Akira Higuchi + Copyright (C) 1997 Masanao Izumo + Copyright (C) 1999-2001 Simon Peter + Copyright (C) 2002 Florian Schulze + Copyright (C) 2002 Jeremy Sheeley + Copyright (C) 2005 Erik Auerswald + Copyright (c) 1999-2007 David Olofson + + Kobo Deluxe is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License. diff --git a/README.html b/README.html new file mode 100644 index 0000000..af62b8b --- /dev/null +++ b/README.html @@ -0,0 +1,803 @@ + + + + + + + + + +KOBODL + + + + +

KOBODL

+ +NAME
+SYNOPSIS
+DESCRIPTION
+CONTROLS
+OPTIONS
+FILES
+AUTHORS
+THANKS
+COPYRIGHT
+ +
+ + + +

NAME

+ + +

kobodl - Kobo +Deluxe, an enhanced version of the scrolling game XKobo

+ + +

SYNOPSIS

+ + +

kobodl [ +options ]

+ + +

DESCRIPTION

+ + +

Kobo Deluxe is +a 3’rd person scrolling 2D shooter with a simple and +responsive control system - which you’ll need to +tackle the tons of enemy ships that shoot at you, chase you, +circle around you shooting, or even launch other ships at +you, while you’re trying to destroy the labyrinth +shaped bases. There are 50 action packed levels with +smoothly increasing difficulty, and different combinations +of enemies that require different tactics to be dealt with +successfully.

+ +

Kobo Deluxe has +an improved graphics engine that delivers smoother +animation, while keeping the game logic totally accurate and +predictable regardless of frame rate. It also adds sound +effects, new graphics, fullscreen mode, four extra skill +levels with smoother gameplay and various other features +expected from a modern game. (There is still a +"Clasic" mode that plays exactly like the original +XKobo.)

+ +

Kobo Deluxe +uses SDL for sound, graphics and input, and builds and runs +on all major operating systems, as well as some more unusual +platforms. It can also use OpenGL for accelerated rendering, +through glSDL.

+ +

In short, Kobo +Deluxe is loads of classical arcade style fun for just about +any machine with graphics and sound!

+ + +

CONTROLS

+ + +

The ship can be +controlled with the keyboard, or optionally a mouse or +joystick. With the keyboard, the arrow keys move the ship +(two keys for diagonals), and the shift and ctrl keys +shoots. The numeric key pad can also be used; the usual +2/4/6/8 (arrows), and also 1/3/7/9 for single key diagonals. +Escape enters the meny system, from where it is possible to +change settings, start a new game or exit the game.

+ + +

OPTIONS

+ + +

Note that all +relevant options can be also configured in the config file, +which can be edited directly, or using the options menus in +the game.
+−[no]logfile

+ +

Log To File. Default: Off.

+ +

−logformat

+ +

Log File Format. Default: +0.

+ +

−logverbosity

+ +

Log Verbosity Level. Default: +2.

+ +

−[no]joystick

+ +

Use Joystick. Default: Off.

+ +

−joystick_no

+ +

Joystick Number. Default: +0.

+ +

−[no]mouse

+ +

Use Mouse. Default: Off.

+ +

−mousemode

+ +

Mouse Control Mode. Default: +1.

+ + +

−[no]broken_numdia

+ +

Broken NumPad Diagonals. +Default: Off.

+ +

−dia_emphasis

+ +

Diagonals Emphasis Filter. +Default: 0.

+ + +

−[no]always_fire

+ +

Always Fire. Default: Off.

+ + +

−[no]mousecapture

+ +

In-game Mouse Capture. Default: +On.

+ +

−scrollradar

+ +

Radar Scroll Mode. Default: +2.

+ +

−[no]filter

+ +

Enable/disable motion +interpolation. Interpolation is what makes animation smooth +at high frame rates despite the game logic running at 33.33 +fps. However, it also adds some input latency! Default: +On.

+ +

−timefilter

+ +

Time filter, for smoothing out +timing jitter induced by the operating system. Default: +50.

+ +

−countdown

+ +

Get Ready Countdown. Default: +5.

+ +

−starfield

+ +

Starfield Style. Default: +2.

+ + + + + + + + +
+ + + +

−stars

+ + +

Number of Parallax +Stars. Default: 500.

+
+ +

−[no]sound

+ +

Enable Sound. Default: On.

+ +

−[no]music

+ +

Enable Music. Default: On.

+ + +

−[no]cached_sounds

+ +

Use Cached Sounds. Default: +Off.

+ +

−[no]oss

+ +

Use OSS Sound Driver. Default: +Off.

+ +

−samplerate

+ +

Sample Rate. Default: +44100.

+ +

−latency

+ +

Sound Latency. Default: 50.

+ +

−mixquality

+ +

Mixing Quality. Default: 3.

+ + + + + + + + +
+ + + +

−vol

+ + +

Master Volume. +Default: 100.

+
+ +

−intro_vol

+ +

Intro Music Volume. Default: +100.

+ +

−sfx_vol

+ +

Sound Effects Volume. Default: +100.

+ +

−music_vol

+ +

In-Game Music Volume. Default: +50.

+ +

−reverb

+ +

Reverb Level. Default: 100.

+ +

−vol_boost

+ +

Volume Boost. Default: 0.

+ + +

−[no]fullscreen

+ +

Fullscreen Display. Default: +Off.

+ +

−videodriver

+ +

Display Driver. Default: 0.

+ + + + + + + + +
+ + + +

−width

+ + +

Horizontal +Resolution. Default: 640.

+
+ +

−height

+ +

Vertical Resolution. Default: +480.

+ +

−aspect

+ +

Pixel Aspect Ratio. Default: +1000.

+ + + + + + + + +
+ + + +

−depth

+ + +

Display Depth. +Default: 0.

+
+ +

−maxfps

+ +

Limit the framerate (fps). +Saves power on laptops (75 works well), and can also avoid +long stalls due to timesharing and background processes. +Default: 100.

+ +

−maxfpsstrict

+ +

Strictly Regulated fps. +Default: 0.

+ +

−buffer

+ +

Display Buffer Mode. Default: +1.

+ +

−[no]shadow

+ +

Use Software Shadow Buffer. +Default: On.

+ +

−videomode

+ +

Video Mode. Default: 17200.

+ +

−[no]vsync

+ +

Enable Vertical Sync. Default: +On.

+ +

−videopages

+ +

Number of Video Pages. Default: +-1.

+ +

−scalemode

+ +

Scaling Filter Mode. Default: +1.

+ +

−[no]dither

+ +

Use Dithering. Default: On.

+ +

−dither_type

+ +

Dither Type. Default: 0.

+ + +

−[no]broken_rgba8

+ +

Broken RGBA (OpenGL). Default: +Off.

+ +

−[no]alpha

+ +

Use Alpha Blending. Default: +On.

+ +

−brightness

+ +

Brightness. Default: 100.

+ +

−contrast

+ +

Contrast. Default: 100.

+ + + + + + + + + + + + + + + + + +
+ + + +

−files

+ + +

Specify the root +path of the game. Default: ""

+ + + +

−gfx

+ + +

Specify the path to +the game’s graphics data. Default: ""

+ + + +

−sfx

+ + +

Specify the path to +the game’s sound data. Default: ""

+ +

−scores

+ +

Specify the path to the +game’s score files. Default: ""

+ + + + + + + + + + + + + + + + + +
+ + + +

−size

+ + +

(Not saved!) Screen +Size (Obsolete). Default: 0.

+ + + +

−wait

+ + +

Game Speed +(Obsolete). Default: 30.

+ + + +

−bgm

+ + +

(Not saved!) +Background Music File (Obsolete). Default: ""

+ +

−threshold

+ +

(Not saved!) Limiter Gain. +Default: 200.

+ +

−release

+ +

(Not saved!) Limiter Speed. +Default: 50.

+ +

−internalres

+ +

(Not saved!) Texture +Resolution. Default: 1.

+ +

−last_profile

+ +

Last used player profile. +Default: 0.

+ + +

−number_of_joysticks

+ +

Number of Connected Joysticks. +Default: 0.

+ +

−[no]showcfg

+ +

(Not saved!) Show +Configuration. Default: Off.

+ +

−[no]hiscores

+ +

(Not saved!) List High Scores. +Default: Off.

+ + +

−[no]highscores

+ +

(Not saved!) List High Scores. +Default: Off.

+ +

−[no]override

+ +

(Not saved!) Ignore +Configuration File. Default: Off.

+ +

−[no]debug

+ +

(Not saved!) Enable Debug +Features. Default: Off.

+ +

−[no]fps

+ +

(Not saved!) Display frames per +second in game screen. Default: Off.

+ +

−[no]noframe

+ +

(Not saved!) Do not render +rounded corners on the playfield. Default: Off.

+ +

−[no]midi

+ +

(Not saved!) Enable MIDI Input. +Default: Off.

+ +

−[no]cheat

+ +

(Not saved!) Enable/disable +cheat mode. Cheat mode allows any level to be played, but +highscores are not saved! Default: Off.

+ + +

−[no]indicator

+ +

(Not saved!) Enable Collision +Indicator Mode. Default: Off.

+ +

−[no]pushmove

+ +

(Not saved!) Enable Push Move +Mode. Default: Off.

+ + +

−[no]noparachute

+ +

(Not saved!) Disable SDL +Parachute. Default: Off.

+ + +

−[no]pollaudio

+ +

(Not saved!) Use Polling Audio +Output. Default: Off.

+ +

−[no]autoshot

+ +

(Not saved!) Ingame +screenshots/movie. Default: Off.

+ +

−[no]help

+ +

(Not saved!) Print usage info +and exit. Default: Off.

+ + +

−[no]options_man

+ +

(Not saved!) Print options for +’man’. Default: Off.

+ + +

FILES

+ + + +

~/.kobodlrc

+ +

The per-user configuration file +for Kobo Deluxe.

+ + +

AUTHORS

+ + +

Originally +written by Akira Higuchi (a-higuti@math.hokudai.ac.jp), +XKobo was turned into Kobo Deluxe by David Olofson +<david@olofson.net>

+ + +

THANKS

+ + +

Thanks, in no +particular order, to...
+Akira Higuchi

+ +

Author of the Original +XKobo.

+ +

Masanao Izumo

+ +

Sound effects and original +sound engine.

+ +

Torsten Giebl

+ +

Slackware.

+ +

David Andersson

+ +

Various Good Ideas.

+ +

Max Horn

+ +

Mac OS X & Build Script +Patches.

+ +

Jeremy Sheeley

+ +

Player Profiles.

+ +

Tsuyoshi Iguchi

+ +

FreeBSD, NetBSD.

+ +

Samuel Hart

+ +

Joystick Support.

+ + + + + + + + +
+ + +

G. Low

+ + +

Solaris.

+
+ +

Gerry Jo Trick +Jellestad

+ +

Testing and ideas.

+ + + + + + + + +
+ + +

Riki

+ + +

Intel Compiler.

+
+ +

Andreas Spaangberg

+ +

Sun Compiler & Bug +Spotting.

+ + + + + + + + +
+ + +

SixK

+ + +

Amiga Port.

+
+ +

Joey Hess

+ +

Debian.

+ +

Martijn van +Oosterhout

+ +

FPS limiter.

+ +

Antonio Messina

+ +

Stage 1601+ difficulty wrap, +Always Fire option.

+ +

Hans de Goede

+ +

Audio buffer handling bug.

+ +

Marianne Ibbotson

+ +

"Autopause" idea.

+ +

Sam Palmer

+ +

MS Windows testing.

+ +

Michael Sterrett

+ +

glSDL issues.

+ +

Sam Lantinga & +Others

+ +

SDL, the Simple DirectMedia +library.

+ +

Members of the SDL mailing +list

+ +

Testing and ideas.

+ + +

COPYRIGHT

+ + +

Copyright (c) +1995, 1996 Akira Higuchi

+ +

Copyright (C) +1997 Masanao Izumo

+ +

Copyright (C) +1999-2001 Simon Peter

+ +

Copyright (C) +2002 Florian Schulze

+ +

Copyright (C) +2002 Jeremy Sheeley

+ +

Copyright (C) +2005 Erik Auerswald

+ +

Copyright (c) +1999-2007 David Olofson

+ +

Kobo +Deluxe is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public +License.

+
+ + diff --git a/README.jp b/README.jp new file mode 100644 index 0000000..942edd0 --- /dev/null +++ b/README.jp @@ -0,0 +1,46 @@ + + Kobo Deluxe + ----------- + v0.4 + + $B%7%e!<%F%#%s%0%2!<%`(B XKobo$B$N6/2=HG(B + +Kobo Deluxe $B$OBh;0e>:$7!"E(5!$NAH$_9g$o$;$,JQ2=$7$^$9!#$&$^$/@Z$jH4$1$k(B +$B$?$a$K$O$=$NETEYE*3N$J@oN,$rI,MW$H$7$^$9!#(B + +Kobo Deluxe$B$O%0%i%U%#%C%/%(%s%8%s$r?J2=$5$;!"%2!<%`$N?J9T$d%?%$(B +$B%_%s%0$K0MB8$7$J$$=@Fp$J%U%l!<%`%l!<%H@_Dj$r2DG=$H$7$F$$$^$9!#$^$?!"(B +$B8z2L2;!"GIe$GF0:n$7$^$9!#$"$^$j0lHLE*$G$O$J%W%i%C%H%[!<%`$G$bF0:n$9$k(B +$B$+$b$7$l$^$;$s!#(B + +$B$R$H$3$H$G8@$&$J$i!"(BKobo Deluxe$B$O%/%i%7%C%/$J%"!<%1!<%I%9%?%$%k$N(B +$B%2!<%`$r!"MM!9$J4D6-$N%^%7%s$GM7$Y$k$h$&$K$7$?$H$$$&$3$H$G$9!#(B + + Enjoy...! + + David Olofson + http://olofson.net + + +Thanks to: + Akira Higuchi ($B%*%j%8%J%kHG(BXKobo$B$N:n------------------------------------ + +License: GPL +Author: Karl Bartel +WWW: http://members.linuxstart.com/~karlb/ + +Usage: + 1. Load a font and place it in an SDL_Surface *. If your are using the + SDL_image library you can do this with Font=IMG_Load("filename"); + 2. Initialize the font by using InitFont(surface *Font); + 3. Now you can use the font in you SDL program. + Please take a look at SFont.h to get info about the funtions. + +FileFormat: + The font file can be any type image file. The characters start with + ASCII symbol #33. They are seperated by pink(255,0,255) lines at the top + of the image. The space between these lines is the width of the caracter. + Just take a look at the font, and you'll be able to understand what I tried + to explain here. + The easiest way to create a new font is to use the GIMP's Logo function. + Use the following string as text (ASCII 33-127 with escape sequences and + spaces between the letters): + ! \" # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ + +Example for the font file format: + +____ _____ _____ _____ <- This is the pink line at the top + + # ##### #### + # # # # # + # # # # # + # # ##### # + ##### # # # + # # # # # + # # ##### #### + + |----| + Width of the character + + |----------| +Part of the font surface that is beeing blitted + + +ChangeLog: +2.0 beta + *** Added SoFont, a C++ version of SFont *** + Added lock and unlock for hardware surfaces + Added blinking cursor to SFont_Input + Added check for ASCII<33 in SFont_Input + TextWidth returned a too highh value -> fixed + +1.4 + Added support for multiple fonts in one program + Add a missing "*" in the SFont.h file + Proper '\0' at the end of stings produced by SFont_Input + Fixed problems in SFont_Input, which were creating '\b' in the string + Fixed two other bugs in SFont_Input + Added the SFontViewer adn new test programs + +1.3 + Fixed three wrong interpretations of the file format + o wrong division (float had to be used) + o detection of right ends of pink lines (were one pixel too far right) + o blit destination (all blits were too far right) + support for non-alpha mapped fonts + some fonts updated + +1.2 + added XCenteredString + +1.1 + renamed font.c to SFont.c and font.h to SFont.h + better Makefile +1.0 + Added the Input function + Added a check wether the Font has been loaded +0.9 + better Makefile for the example (using sdl-config) + better Neon Font +0.8 + First Release + +If you have any Questions please write a mail! + +Karl \ No newline at end of file diff --git a/README.xkobo b/README.xkobo new file mode 100644 index 0000000..746ecf4 --- /dev/null +++ b/README.xkobo @@ -0,0 +1,146 @@ + +------------------------------------------------------------------------- + + __ __ + \ \ / / + \ \/ / ## ## #### ##### #### + \ / ## ## ## ## ## ## ## ## + / \ #### ## ## ##### ## ## + / /\ \ ## ## ## ## ## ## ## ## + / / \ \ ## ## #### ##### #### + /_/ --' + Version 1.11+-do3 + + by + + Akira Higuchi + + + sound effects and other enhancements + Masanao Izumo + + improved OSS sound engine + David Olofson + +------------------------------------------------------------------------- + +* DESCRIPTION + Xkobo is a single player action game. The play is quite + simple. Your object is to destroy all the fortresses. You + can control your ship by pressing the cursor keys (or mov- + ing the mouse cursor), and shot beams by pressing the + SHIFT key (or the left mouse button). The game can be + paused by pressing 's' (or the right mouse button). + +------------------------------------------------------------------------- + +* REQUIREMENT + Xkobo requires: + 1) Unix (BSD, Linux, etc.) + 2) X window system (256 colors or greater) + 3) OSS compatible sound system (8 kHz, 16 bit stereo) + 4) C++ compiler + + Xkobo is known to compile and run under the following systems: + * Linux + * Sun-OS 4.1.4 + * BSD/OS + * Solaris 2.4 (Sparc) + * HP-UX 9.05 + +------------------------------------------------------------------------- + +* INSTALLING + Edit Imakefile (if you need) and run + + % xmkmf -a + % make + % su + # make install + # make install.man + +------------------------------------------------------------------------- + +* OPTIONS + -display displayname + This option specifies the name of the X server to use. + + -fit + This option causes xkobo to use the default colormap. + Without this option, xkobo uses a private colormap. + + -wait value + This option specifies the speed of the game. The + default value is 30(msec). + + -doublesize + This option causes xkobo to enlarge the size of the + window. But it costs HUGE memory. + + -fast + This option causes xkobo to use a faster algorithm. But + it costs much memory. + + -cheat + Cheat mode. It allows any level to be played, does not + update score table. + + -hiscores + Print the high score table to standard out, and exit. + + -sound + Enable sound effects. (Default.) + + -nosound + Disable sound effects. + + -vol value + Set sound effects volume to value. Default is 100. + +FIXME: Some options aren't translated from README.jp. + +------------------------------------------------------------------------- + +* THANKS TO ... + + Bruce Cheng + Christoph Lameter + Davide Rossi + Eduard Martinescu + Elan Feingold + Helmut Hoenig + Jeff Epler + Joe Ramey + Joey Hess + Michael Sterrett + Mihail Iotov + Shoichi Nakayama + Thomas Marsh + Torsten Wolnik + +* David's Thanks To... + + Akira Higuchi (original Xkobo) + Masanao Izumo (sound effects) + +========================================================================= + + XKOBO, a video-oriented game + Copyright (C) 1995,1996 Akira Higuchi + a-higuti@math.hokudai.ac.jp + + 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. + +========================================================================= diff --git a/README.xkobo.jp b/README.xkobo.jp new file mode 100644 index 0000000..4b16123 --- /dev/null +++ b/README.xkobo.jp @@ -0,0 +1,139 @@ + +------------------------------------------------------------------------- + + XKOBO Version 1.11+-do3 + + Fri Jan 10 11:17:50 JST 1997 Akira Higuchi + a-higuti@math.hokudai.ac.jp + +------------------------------------------------------------------------- + +* DESCRIPTION + + Xkobo $B$O#1?MMQ$N%"%/%7%g%s%2!<%`$G$9!#@N$N%J%`%3$N%2!<%`(B Bosconian + $B$K;w$F$$$^$9!#%k!<%k$OC1=c$G!"<+5!$rA`$C$F2hLL>e$K$"$kMW:I$rA4$FGK(B + $B2u$9$k$3$H$,%2!<%`$NL\E*$G$9!#(B + +------------------------------------------------------------------------- + +* REQUIREMENT + + Xkobo $B$r%3%s%Q%$%k!?eI=<($G$-$k(B X $B%5!<%P(B) + 3) C++ $B%3%s%Q%$%i(B + + Xkobo $B$O>/$J$/$H$b0J2<$N%7%9%F%`$GF0:n$7$^$9!#(B + + * Linux + * Sun-OS 4.1.4 + * BSD/OS + * Solaris 2.4 (Sparc) + * HP-UX 9.05 + +------------------------------------------------------------------------- + +* INSTALLING + + $B$b$7I,MW$J$i(B Imakefile $B$rJT=8$7$F$+$i!"e$G%3%s%Q%$%k$,40N;$G$9!#$b$7$"$J$?$,(B root $B$K$J$l$k$J$i!"/$J$$$H!"(Bxkobo $B$N(B + $B1GA|$N?'$,JQ$K$J$k$3$H$,$"$j$^$9!#$3$l$r;XDj$7$J$+$C$?$i!"%W(B + $B%i%$%Y!<%H%+%i!<%^%C%W$r;HMQ$7$^$9!#(B + $BCm!'(Bsgi $BMQ$K%O%C%/$7$?$3$N%P!<%8%g%s$G$O!$$3$N%*%W%7%g%s$O$"(B + $B$j$^$;$s!%(B + + -wait value + $B%2!<%`$N%9%T!<%I$r;XDj$7$^$9!#$3$N%*%W%7%g%s$G;XDj$7$J$1$l$P!"(B + 40$B!J%_%jIC!KKh$K2hLL$,%"%C%W%G!<%H$5$l$^$9!#(B + + -doublesize + $B2hLL$N%5%$%:$,=D2#$=$l$>$l#2G\$K$J$j$^$9!#$?$@!";HMQ$9$k%a%b(B + $B%j$NNL$,Ls#4G\!*$K$J$j$^$9!#(B + + -tetrasize + $B2hLL$N%5%$%:$,=D2#$=$l$>$l#4G\$K$J$j$^$9!#$?$@!";HMQ$9$k%a%b(B + $B%j$NNL$,Ls#1#6G\!*$K$J$j$^$9!#(B + + -fast + $BB.$$%"%k%4%j%:%`$r;HMQ$7$^$9!#%a%b%j$N;HMQNL$OA}$($^$9!#(B + + -cheat + $B%A%c%C%H!&%b!<%I$Gr7o2<$G$N2~B$!?:FG[I[$,2DG=(B + $B$G$9!#>\$7$/$O(B COPYING $B$r$_$F$/$@$5$$!#(B + + $B5l%P!<%8%g%s$KB8:_$7$?(B Towns PAD $BBP1~$O:o=|$7$^$7$?!#JL$N%W%m%0%i%`(B + xpadtrans $B$r;H$($P(B Towns PAD $B$GA`:n$G$-$k$h$&$K$J$j$^$9!#>\$7$/$O!"(B + http://www.math.hokudai.ac.jp/~a-higuti/ + http://seki.math.hokudai.ac.jp:20080/ + $B$"$?$j$rGA$$$F$_$F2<$5$$!#(B + +------------------------------------------------------------------------- + +* THANKS TO ... + + Bruce Cheng + Christoph Lameter + Davide Rossi + Eduard Martinescu + Elan Feingold + Helmut Hoenig + Jeff Epler + Joe Ramey + Joey Hess + Michael Sterrett + Mihail Iotov + Shoichi Nakayama + Thomas Marsh + Torsten Wolnik + diff --git a/TODO b/TODO new file mode 100644 index 0000000..c4759c5 --- /dev/null +++ b/TODO @@ -0,0 +1,330 @@ + + Priority: + + * Cleaner gold fonts! (Poor AA in bigfont3, and goldfont + is just a scaled and colorized version of icefont2.) + + * Sort the video modes! + + * Nodes and cores should have some sort of "spawn" + effect when firing. + + * Logic object pool optimization: Use LIFO pool + lists! + + * Graphics scaling: + * Remove or hide the advanced graphics options! + * Graphics quality: + * Fastest + * Medium + * Best (Default) + * Custom (show old detailed settings) + * At first startup, quality would be + "Unknown". The game will start by + testing the intro with no logo. The game + picks a quality setting based on frame + rate. If "Medium" or "Fastest" is picked, + the game should warn and ask the user. + * Specify in the loader what scaling methods should + be used for each quality setting. (What about + Custom?) + * Disable alpha in Fastest quality. Medium...? + + * Better scaling! + * Try SDL_resize!!! + * Combine Scale2x and Diamond2x? + * S-spline style enhancement filters? + * Detail textures? + + * Indirectly changing the video mode (by changing one + of the "Show" options) will not trigger a video + restart. + + * Death sequence UI timing should not be governed by + game logic time! Throw in a "state time" feature in + the gamestate manager or something. Or perhaps just + switch to a fixed logic frame rate when not + actually in-game? (It does actually make sense to + scale in-game effects with game speed!) + + * Quicker menu navigation with PgUp/Dn, Home, End etc. + + * 3D "rockfield" for highscore and/or credits? (2D + parallax rocks + stars without glSDL.) glSDL should + support texture filtering for nice scaling. + + * There should be some feedback from the sound engine, + perhaps... As it is, you can't even see what sample + rate it's actually using. + + Bugs: + + * Y scale factor f*cked up when switching to 2560x1600! + Apparently happens only after "escape hammering"... + + * In-game music volume affects intro music! + + * Mouse crosshair can stick around after disabling mouse + control! + + * Multiple keys and buttons bound to the same + function results in up/down state confusion; if + you release one of the keys, the "target" gets a + release event, despite other keys with the same + target being held down. + + * Nibble effect still doesn't like double buffering. + + * The sound engine is mixing up PAN events!!! + + * glSDL surface leak when taking screenshots! + + * Do we *really* wait for all bases to stop exploding + after the player lost a ship...? + + * Noise fx glitches in some resolutions. + + * If a ctrl+enter fullscreen/windowed switch is made + while the menu is shown, the text goes away! + + * Any playing game aborts after toggling windowed/ + fullscreen! + + * VSync settings doesn't change as it should! Doesn't seem + to be much I can do about this... + + * Leaving the game running for a few hours results in + "hickups" at around 2 Hz, until the graphics is reloaded + or similar. (Logic re-init?) + + * Downscaling (sub 320x240) breaks the radar and + causes various other issues. (Pretty much expected...) + + * SIGSTOP kills the main thread... SDL/AMD64 bug...? + + * SIGSTOP/SIGCONT seems to confuse the game logic. + (Already fixed...?) + + * SDL_GetAppState()! (Fixed...?) + + + Internals: + + * Try to create a scoredir if missing! + + * Add doc() method to the config manager, for longer + explanations of the options. + * Structured documentation for values...? + + * Try reading back from the display buffer to autodetect + how page flipping is handled! Mark pages with a few + pixels in the corner (binary page numbers), and see + if/when they come back. + + * Pause mode should not consume CPU or GPU power, + at least not if the window is passive. + + * Multiple priority groups for sound effects! + + * glSDL and EEL should output errors to the logger. + + * Switch to PhysicsFS!? + + * WAV writer? (Just for "cache sounds on disk.") + + * Don't overwrite other windows when refreshing the + in-game framework. + + * Convert text files to Win32 format in the Win32 + install target! + + * Add source info to "key" codes, to tell joystick + input from keyboard and the like, when desired. + + * Use custom keyboard repeat code. Should be used + for joystick events as well. + + * Show a system dialog of some sort, instead of + printing to stderr. (Critical errors only.) + + * Range checking on command line args and config. + + * Remove either gamecontrol or gsm event pushing + calls from skobo_gfxengine_t::frame(). Don't know + which one, but it can't be right the way it is + now... + + * Rearrange the source tree so that all source is + in an src subdir. + + * Put README, COPYING etc in binary distros. (Done + for Win32 "simple bundles".) + + * Add CRC or simple "checksum" to score files, to + prevent too easy modification. You must at least + download the game source and hack it if you + *really* want to cheat! ;-) + + + Features: + + * Proper start-of-map savegames! + + * Instructions! (In the radar window...?) + + * Input configurator!!! + + * Game statistics! + * Shots fired + * Hits + * Accuracy + * Kills + * Deaths + * Damage + + * Adrenaline Mode: + * Health/damage accounting + * Powerups + * Indestructible labyrinths + * N bases or objects to destroy + * Loads of aggressive enemies + * "Forced speedrun" style gameplay + + * Throw in some *real* music. (The demo songs don't + really have anything to do with Kobo Deluxe. I + was basically just testing things when developing + the audio engine.) + + * Implement "world snapshot" feature, to use for + save game option, as well as internal temporary + save game for changing video options in the + middle of the game and the like. Needs to save + score, lives etc, the current map, all objects, + random number seed etc. + + * Implement multiplayer modes. (Deathmatch and + Cooperative, for starters.) + + * Separate personal and global highscores. Where + applicable, one could keep score for player/user, + system local, local network and the internet, + and/or maybe some kind user defined groups. + + * New "Instructions" solution. (New state...?) + + * "Sloppy Refresh" hack to improve frame rate for + sprites and base tiles, while reducing it for + the starry background tiles. + + * On targets with sync'ed flips, accept "close + enough" refresh rates as time base, so that the + video frame rate becomes an integer multiple of + the engine frame rate. (Smoother scrolling.) + + Gameplay: + + * Elite and God modes should make enemies smarter + (aim-ahead, at least). We want "tough" - not + "stupid fast"! + + Radar: + * Radar markings for death + respawn points when + getting killed? + + * Show map borders in radar, for orientation? + + Base layout: + * Prevent the map generator from building + impossible bases! Possibly build a list of + tested and approved random seeds for each + level... + * Don't make bases where you have to navigate + into the base on the first few levels. + * Simulation based base verification method: + 1. Destroy all destructible nodes. + 2. Figure out how many turns one would + have to navigate into the base in + order to get a shot at the core. + * Provide a fixed set of maps for fair highscore, + speedruns and the like! As it is, every game + is truly unique, so scores cannot really be + compared. (Well, that *could* be considered + part of the game, of course...) + + * Import some extra maps from xkobo-1.11+w01? + + * Bonus levels...? + + * "Smooth chase" scroll in non Classic modes? Maybe + even filtered player movement? + + * Fire to push rocks around? + + * "Milking" cores that fire enemies is a potential + way of cheating for a higher score. Throw in an + enemy_m* after some time as assassin to prevent + this? (How to detect whether the player is doing + something "sensible" or not...?) + + Trick suggested a nice and simple solution: Just + lower the "price tag" on enemies spawned from + nodes over time. No effect on gameplay, but if + you fly around shooting defenseless enemies for + too long, they'll eventually stop counting + towards your score. The only remaining problem + is figuring out when to start decreasing enemy + scores, and how fast. + + + Features: + + * Instant restart button? (Shouldn't really be needed + if the "impossible base" bugs are fixed...) + + * Should be able to skip the death explosion sequence, + if there are more ships! Maybe an option to remove + it (and other effects) altogether? + + * Separate highscores for different skills. + + * Help texts (in the radar window?) for config options! + + * Add native OpenGL support with sub-pixel accurate + rendering for ultra smooth animation. + + * Nice health bar flash effects. + + * Fine rotation adjustment when using OpenGL. (Needs + a generic high resolution rotation field.) + + * Screen pixel accurate map scrolling. + + * "Stage cleared" screens with stats and stuff! + + * Demo recording and playback! (Nice feature and + debugging tool.) + + * Implement waveshaper AGW command! + + * New master output processor: + * Three bands with separate "boost" controls. + + * Non-linear audio output for high boost! + + * New limiter that programs a waveshaper based + on input level? + + * Interesting soundscape while loading? + + * "Center Playfield" (as opposed to "center framework") + video option + + * Default/Changed status indicators in the options. + + + Web site and other stuff: + + * Find binary packages and maintainers! + + * Links to unrelated games sites. + + * Write a design paper! diff --git a/acconfig.h b/acconfig.h new file mode 100644 index 0000000..e69de29 diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..6639d33 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,1044 @@ +# generated automatically by aclocal 1.9.6 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# Configure paths for SDL +# Sam Lantinga 9/21/99 +# stolen from Manish Singh +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS +dnl +AC_DEFUN([AM_PATH_SDL], +[dnl +dnl Get the cflags and libraries from the sdl-config script +dnl +AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], + sdl_prefix="$withval", sdl_prefix="") +AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], + sdl_exec_prefix="$withval", sdl_exec_prefix="") +AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], + , enable_sdltest=yes) + + if test x$sdl_exec_prefix != x ; then + sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config + fi + fi + if test x$sdl_prefix != x ; then + sdl_args="$sdl_args --prefix=$sdl_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_prefix/bin/sdl-config + fi + fi + + if test "x$prefix" != xNONE; then + PATH="$prefix/bin:$prefix/usr/bin:$PATH" + fi + AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH]) + min_sdl_version=ifelse([$1], ,0.11.0,$1) + AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) + no_sdl="" + if test "$SDL_CONFIG" = "no" ; then + no_sdl=yes + else + SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` + SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` + + sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_sdltest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_CXXFLAGS="$CXXFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SDL_CFLAGS" + CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" +dnl +dnl Now check if the installed SDL is sufficiently new. (Also sanity +dnl checks the results of sdl-config to some extent +dnl + rm -f conf.sdltest + AC_TRY_RUN([ +#include +#include +#include +#include "SDL.h" + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main (int argc, char *argv[]) +{ + int major, minor, micro; + char *tmp_version; + + /* This hangs on some systems (?) + system ("touch conf.sdltest"); + */ + { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_sdl_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_sdl_version"); + exit(1); + } + + if (($sdl_major_version > major) || + (($sdl_major_version == major) && ($sdl_minor_version > minor)) || + (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); + printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); + printf("*** to point to the correct copy of sdl-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + CXXFLAGS="$ac_save_CXXFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_sdl" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$SDL_CONFIG" = "no" ; then + echo "*** The sdl-config script installed by SDL could not be found" + echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the SDL_CONFIG environment variable to the" + echo "*** full path to sdl-config." + else + if test -f conf.sdltest ; then + : + else + echo "*** Could not run SDL test program, checking why..." + CFLAGS="$CFLAGS $SDL_CFLAGS" + CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + AC_TRY_LINK([ +#include +#include "SDL.h" + +int main(int argc, char *argv[]) +{ return 0; } +#undef main +#define main K_and_R_C_main +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding SDL or finding the wrong" + echo "*** version of SDL. If it is not finding SDL, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means SDL was incorrectly installed" + echo "*** or that you have moved SDL since it was installed. In the latter case, you" + echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + CXXFLAGS="$ac_save_CXXFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SDL_CFLAGS="" + SDL_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(SDL_CFLAGS) + AC_SUBST(SDL_LIBS) + rm -f conf.sdltest +]) + +# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION so it can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], + [AM_AUTOMAKE_VERSION([1.9.6])]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 7 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE]) +AC_SUBST([$1_FALSE]) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 8 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH]) +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +#serial 3 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 8 + +# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. +AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 12 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.58])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +]) +]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $1 | $1:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"$am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. +# +# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories +# created by `make install' are always world readable, even if the +# installer happens to have an overly restrictive umask (e.g. 077). +# This was a mistake. There are at least two reasons why we must not +# use `-m 0755': +# - it causes special bits like SGID to be ignored, +# - it may be too restrictive (some setups expect 775 directories). +# +# Do not use -m 0755 and let people choose whatever they expect by +# setting umask. +# +# We cannot accept any implementation of `mkdir' that recognizes `-p'. +# Some implementations (such as Solaris 8's) are not thread-safe: if a +# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' +# concurrently, both version can detect that a/ is missing, but only +# one can create it and the other will error out. Consequently we +# restrict ourselves to GNU make (using the --version option ensures +# this.) +AC_DEFUN([AM_PROG_MKDIR_P], +[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi +AC_SUBST([mkdir_p])]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + diff --git a/aconfig.h b/aconfig.h new file mode 100644 index 0000000..524de5d --- /dev/null +++ b/aconfig.h @@ -0,0 +1,190 @@ +/* aconfig.h. Generated from aconfig.h.in by configure. */ +/* aconfig.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the `atexit' function. */ +#define HAVE_ATEXIT 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +/* #undef HAVE_DOPRNT */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `floor' function. */ +#define HAVE_FLOOR 1 + +/* Define to 1 if you have the `getegid' function. */ +#define HAVE_GETEGID 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `SDL_image' library (-lSDL_image). */ +#define HAVE_LIBSDL_IMAGE 1 + +/* Define to 1 if you have the `memcmp' function. */ +#define HAVE_MEMCMP 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have the `mkdir' function. */ +#define HAVE_MKDIR 1 + +/* Define to 1 if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `munmap' function. */ +#define HAVE_MUNMAP 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the `pow' function. */ +#define HAVE_POW 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SDL_SDL_OPENGL_H 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define to 1 if you have the `sqrt' function. */ +#define HAVE_SQRT 1 + +/* Define to 1 if you have the `stat' function. */ +#define HAVE_STAT 1 + +/* Define to 1 if `stat' has the bug that it succeeds when given the + zero-length file name argument. */ +/* #undef HAVE_STAT_EMPTY_STRING_BUG */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strrchr' function. */ +#define HAVE_STRRCHR 1 + +/* Define to 1 if you have the `strstr' function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Define to 1 if you have the `_snprintf' function. */ +/* #undef HAVE__SNPRINTF */ + +/* Define to 1 if you have the `_vsnprintf' function. */ +/* #undef HAVE__VSNPRINTF */ + +/* Define to 1 if `lstat' dereferences a symlink specified with a trailing + slash. */ +#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 + +/* Name of package */ +#define PACKAGE "KoboDeluxe" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Version number of package */ +#define VERSION "0.5.1" + +/* Define to 1 if the X Window System is missing or not being used. */ +/* #undef X_DISPLAY_MISSING */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif diff --git a/aconfig.h.in b/aconfig.h.in new file mode 100644 index 0000000..8f6033a --- /dev/null +++ b/aconfig.h.in @@ -0,0 +1,189 @@ +/* aconfig.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the `atexit' function. */ +#undef HAVE_ATEXIT + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_DIRENT_H + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the header file. */ +#undef HAVE_ERRNO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the `floor' function. */ +#undef HAVE_FLOOR + +/* Define to 1 if you have the `getegid' function. */ +#undef HAVE_GETEGID + +/* Define to 1 if you have the `getpagesize' function. */ +#undef HAVE_GETPAGESIZE + +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `SDL_image' library (-lSDL_image). */ +#undef HAVE_LIBSDL_IMAGE + +/* Define to 1 if you have the `memcmp' function. */ +#undef HAVE_MEMCMP + +/* Define to 1 if you have the `memmove' function. */ +#undef HAVE_MEMMOVE + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if you have the `mkdir' function. */ +#undef HAVE_MKDIR + +/* Define to 1 if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the `munmap' function. */ +#undef HAVE_MUNMAP + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#undef HAVE_NDIR_H + +/* Define to 1 if you have the `pow' function. */ +#undef HAVE_POW + +/* Define to 1 if you have the header file. */ +#undef HAVE_SDL_SDL_OPENGL_H + +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT + +/* Define to 1 if you have the `setgid' function. */ +#undef HAVE_SETGID + +/* Define to 1 if you have the `snprintf' function. */ +#undef HAVE_SNPRINTF + +/* Define to 1 if you have the `sqrt' function. */ +#undef HAVE_SQRT + +/* Define to 1 if you have the `stat' function. */ +#undef HAVE_STAT + +/* Define to 1 if `stat' has the bug that it succeeds when given the + zero-length file name argument. */ +#undef HAVE_STAT_EMPTY_STRING_BUG + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strrchr' function. */ +#undef HAVE_STRRCHR + +/* Define to 1 if you have the `strstr' function. */ +#undef HAVE_STRSTR + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_DIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `vprintf' function. */ +#undef HAVE_VPRINTF + +/* Define to 1 if you have the `vsnprintf' function. */ +#undef HAVE_VSNPRINTF + +/* Define to 1 if you have the `_snprintf' function. */ +#undef HAVE__SNPRINTF + +/* Define to 1 if you have the `_vsnprintf' function. */ +#undef HAVE__VSNPRINTF + +/* Define to 1 if `lstat' dereferences a symlink specified with a trailing + slash. */ +#undef LSTAT_FOLLOWS_SLASHED_SYMLINK + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Version number of package */ +#undef VERSION + +/* Define to 1 if the X Window System is missing or not being used. */ +#undef X_DISPLAY_MISSING + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif diff --git a/buildpkg.sh b/buildpkg.sh new file mode 100755 index 0000000..0af74c8 --- /dev/null +++ b/buildpkg.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# +# How to build a solaris package, by Andreas Spångberg: +# ./configure +# make +# cd solaris +# ./buildpkg.sh +# pkgadd -d ./ASkobodl.pkg +# + +ARCH=`uname -p` +INSTDIR=`pwd`/package +cd .. +make install DESTDIR=$INSTDIR +cd $INSTDIR + +cat > pkginfo << EOPKG +PKG="ASkobodl" +NAME=`grep PACKAGE ../../aconfig.h | awk -e '{print $3}'` +ARCH="$ARCH" +VERSION=`grep VERSION ../../aconfig.h | awk -e '{print $3}'` +CATEGORY="games" +VENDOR="David Olofson" +EMAIL="david@olofson.net" +PSTAMP="Andreas Spångberg" +BASEDIR="/usr/local" +CLASSES="none" +EOPKG + +echo "i pkginfo=./pkginfo" > prototype +find . -print | pkgproto ./usr/local= >> prototype + +cd .. +pkgmk -d . -f package/prototype -o +rm -rf $INSTDIR +echo 1 | pkgtrans -os . ASkobodl.pkg +rm -rf ./ASkobodl diff --git a/cfg-beta b/cfg-beta new file mode 100755 index 0000000..6a90a36 --- /dev/null +++ b/cfg-beta @@ -0,0 +1,2 @@ +#!/bin/sh +CFLAGS="-O3" CXXFLAGS="-O3" ./configure --enable-debug --enable-alsa --enable-opengl --enable-oss diff --git a/cfg-cross-release b/cfg-cross-release new file mode 100755 index 0000000..0e67785 --- /dev/null +++ b/cfg-cross-release @@ -0,0 +1,2 @@ +#!/bin/sh +CFLAGS="-O3 -Wall" CXXFLAGS="-O3 -Wall" cross-configure --disable-debug --disable-epm diff --git a/cfg-profile b/cfg-profile new file mode 100755 index 0000000..27f5757 --- /dev/null +++ b/cfg-profile @@ -0,0 +1,2 @@ +#!/bin/sh +CFLAGS="-O3 -pg" CXXFLAGS="-O3 -pg" ./configure --disable-alsa --enable-opengl --enable-oss diff --git a/cfg-release b/cfg-release new file mode 100755 index 0000000..0c88348 --- /dev/null +++ b/cfg-release @@ -0,0 +1,2 @@ +#!/bin/sh +CFLAGS="-O3" CXXFLAGS="-O3" ./configure --prefix=/usr --disable-alsa --enable-opengl --enable-oss diff --git a/cfg-work b/cfg-work new file mode 100755 index 0000000..a914827 --- /dev/null +++ b/cfg-work @@ -0,0 +1,2 @@ +#!/bin/sh +CFLAGS="-O0" CXXFLAGS="-O0" ./configure --prefix=/usr --enable-epm --enable-debug --disable-alsa --enable-opengl --enable-oss diff --git a/cfg-work-opt b/cfg-work-opt new file mode 100755 index 0000000..7e9667c --- /dev/null +++ b/cfg-work-opt @@ -0,0 +1,2 @@ +#!/bin/sh +CFLAGS="-O3" CXXFLAGS="-O3" ./configure --prefix=/usr --enable-epm --enable-debug --disable-alsa --enable-opengl --enable-oss diff --git a/cfgform.cpp b/cfgform.cpp new file mode 100644 index 0000000..160b395 --- /dev/null +++ b/cfgform.cpp @@ -0,0 +1,152 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 2001-2003, 2006-2007 David Olofson + * + * 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. + */ + +#include "kobolog.h" +#include "config.h" +#include "cfgform.h" +#include "kobo.h" +#include "sound.h" +#include "vidmodes.h" + +int global_status = 0; + + +config_form_t::config_form_t() +{ + prf = NULL; + stat = 0; +} + + +config_form_t::~config_form_t() +{ +} + + +void config_form_t::open(prefs_t *p) +{ + init(gengine); + place(wmain->x(), wmain->y(), wmain->width(), wmain->height()); + font(B_NORMAL_FONT); + foreground(wmain->map_rgb(0xffffff)); + background(wmain->map_rgb(0x000000)); + prf = p; + prfbak = *p; + stat = global_status & (OS_RELOAD | OS_RESTART | OS_UPDATE); + build_all(); +} + + +void config_form_t::close() +{ + vmm_Close(); + clean(); +} + + +void config_form_t::undo() +{ + *prf = prfbak; + undo_hook(); +} + + +int config_form_t::status() +{ + return stat; +} + + +void config_form_t::clearstatus(int mask) +{ + stat &= ~mask; + global_status = stat & (OS_RELOAD | OS_RESTART | OS_UPDATE); +} + + +void config_form_t::setstatus(int mask) +{ + stat |= mask; + global_status = stat & (OS_RELOAD | OS_RESTART | OS_UPDATE); +} + +/*virtual*/ void config_form_t::change(int delta) +{ + kobo_form_t::change(delta); + + if(!selected()) + return; + + if(selected()->tag & OS_CLOSE) + { + if(delta == 0) + { + sound.ui_ok(); + setstatus(OS_CLOSE); + } + } + else if(selected()->tag & OS_CANCEL) + { + if(delta == 0) + { + sound.ui_cancel(); + undo(); + setstatus(OS_CLOSE); + } + } + else + sound.ui_tick(); + + if(selected()->user) + prf->changed = 1; + + setstatus(selected()->tag & (OS_RELOAD | OS_RESTART | OS_UPDATE)); + + // If a video mode from the table is selected, get the parameters + // from the video mode manager! + if(prf->videomode) + { + VMM_Mode *m = vmm_FindMode(prf->videomode); + if(m) + { + prf->width = m->width; + prf->height = m->height; + prf->aspect = (int)(m->aspect * 1000.0f + .5f); + } + } + + if(selected()->tag & OS_REBUILD) + { + int sel = selected_index(); + build_all(); + select(sel); + } +} + +/* virtual */void config_form_t::build() +{ +} + +/* virtual */ void config_form_t::undo_hook() +{ + stat = 0; + global_status = 0; +} diff --git a/cfgform.h b/cfgform.h new file mode 100644 index 0000000..086d442 --- /dev/null +++ b/cfgform.h @@ -0,0 +1,76 @@ +/* +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 2001, 2003, David Olofson + * + * 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. + */ + +#ifndef _CONFIG_FORM_H_ +#define _CONFIG_FORM_H_ + +#include "form.h" +#include "prefs.h" + +enum +{ + OS_CLOSE = 0x0001, + OS_CANCEL = 0x0002, + OS_REBUILD = 0x0004, + OS_ACTION = 0x000f, + + OS_RELOAD_GRAPHICS = 0x0010, + OS_RELOAD_AUDIO_CACHE = 0x0020, + OS_RELOAD = 0x0070, + + OS_RESTART_VIDEO = 0x0100, + OS_RESTART_AUDIO = 0x0200, + OS_RESTART_ENGINE = 0x0400, + OS_RESTART_INPUT = 0x0800, + OS_RESTART_LOGGER = 0x0080, + OS_RESTART = 0x0f80, + + OS_UPDATE_AUDIO = 0x1000, + OS_UPDATE_ENGINE = 0x2000, + OS_UPDATE = 0xf000 +}; + + +class config_form_t : public kobo_form_t +{ + protected: + prefs_t *prf; + prefs_t prfbak; + int stat; + public: + config_form_t(); + virtual ~config_form_t(); + void open(prefs_t *p); + virtual void build(); // <-- Override this! + //...and this, if you need. Normally, + //it just sets the status to 0. + virtual void undo_hook(); + void close(); + int status(); + void setstatus(int mask); + void clearstatus(int mask); + void undo(); + void change(int delta); +}; + +extern int global_status; + +#endif //_CONFIG_FORM_H_ diff --git a/cfgparse.cpp b/cfgparse.cpp new file mode 100644 index 0000000..c6fcb18 --- /dev/null +++ b/cfgparse.cpp @@ -0,0 +1,1080 @@ +/*(LGPL) +------------------------------------------------------------------- + cfgparse.cpp - Generic Config File and Argument Parser +------------------------------------------------------------------- + * Copyright (C) 2001, 2007 David Olofson + * + * This code is released under the terms of the GNU LGPL. + */ + +#include "config.h" +#include "logger.h" + +#include +#include +#include + +#include "cfgparse.h" + +#define MAX_CONFIG_LINES 1024 + + +/*---------------------------------------------------------- + cfg_key_t +----------------------------------------------------------*/ + +cfg_key_t::cfg_key_t() +{ + next = NULL; + name = ""; + save = 1; + typecode = CFG_NONE; + redefined = 0; + description = NULL; +} + + +cfg_key_t::~cfg_key_t() +{ + free(description); +} + + +int cfg_key_t::read(int argc, char *argv[]) +{ + return 0; +} + + +int cfg_key_t::test(const char *arg) +{ + if(arg[0] == '-' || arg[0] == '/') + ++arg; + return !strcmp(name, arg); +} + + +/*---------------------------------------------------------- + cfg_comment_t +----------------------------------------------------------*/ + +void cfg_comment_t::write(FILE *f) +{ + fprintf(f, "#%s\n", name); +} + + +int cfg_comment_t::copy(cfg_key_t *from) +{ + if(typecode != from->typecode) + return -1; + return 0; +} + + +/*---------------------------------------------------------- + cfg_switch_t +----------------------------------------------------------*/ + +cfg_switch_t::cfg_switch_t(const char *_name, int &var, int def, int _save) +{ + name = _name; + value = &var; + default_value = def; + save = _save; + typecode = CFG_BOOL; +} + + +int cfg_switch_t::copy(cfg_key_t *from) +{ + if(typecode != from->typecode) + return -1; + *value = *((cfg_switch_t *)from)->value; + return 0; +} + + +int cfg_switch_t::test(const char *arg) +{ + if(arg[0] == '-' || arg[0] == '/') + ++arg; + if(strncmp("no", name, 2)) + if(!strncmp("no", arg, 2)) + arg += 2; + return !strcmp(name, arg); +} + + +int cfg_switch_t::read(int argc, char *argv[]) +{ + char *arg = argv[0]; + *value = 1; + if(arg[0] == '-' || arg[0] == '/') + ++arg; + if(!strncmp("no", arg, 2)) + *value = 0; + if(!strncmp("no", name, 2)) + *value = !(*value); + return 1; +} + + +void cfg_switch_t::write(FILE *f) +{ + fprintf(f, *value ? "%s\n" : "no%s\n", name); +} + + +void cfg_switch_t::set_default() +{ + *value = default_value; +} + + +int cfg_switch_t::is_your_var(void *var) +{ + return var == (void *)value; +} + + + +/*---------------------------------------------------------- + cfg_key_int_t +----------------------------------------------------------*/ + +cfg_key_int_t::cfg_key_int_t(const char *_name, int &var, int def, int _save) +{ + name = _name; + value = &var; + default_value = def; + save = _save; + typecode = CFG_INT; +} + + +int cfg_key_int_t::copy(cfg_key_t *from) +{ + if(typecode != from->typecode) + return -1; + *value = *((cfg_key_int_t *)from)->value; + return 0; +} + + +int cfg_key_int_t::read(int argc, char *argv[]) +{ + if(argc < 2) + return -1; + *value = atoi(argv[1]); + return 2; +} + + +void cfg_key_int_t::write(FILE *f) +{ + fprintf(f, "%s %d\n", name, *value); +} + + +void cfg_key_int_t::set_default() +{ + *value = default_value; +} + + +int cfg_key_int_t::is_your_var(void *var) +{ + return var == (void *)value; +} + + + +/*---------------------------------------------------------- + cfg_key_float_t +----------------------------------------------------------*/ + +cfg_key_float_t::cfg_key_float_t(const char *_name, float &var, float def, int _save) +{ + name = _name; + value = &var; + default_value = def; + save = _save; + typecode = CFG_FLOAT; +} + + +int cfg_key_float_t::copy(cfg_key_t *from) +{ + if(typecode != from->typecode) + return -1; + *value = *((cfg_key_float_t *)from)->value; + return 0; +} + + + + +int cfg_key_float_t::read(int argc, char *argv[]) +{ + if(argc < 2) + return -1; + *value = atof(argv[1]); + return 2; +} + + +void cfg_key_float_t::write(FILE *f) +{ + fprintf(f, "%s %f\n", name, *value); +} + + +void cfg_key_float_t::set_default() +{ + *value = default_value; +} + + +int cfg_key_float_t::is_your_var(void *var) +{ + return var == (void *)value; +} + + + +/*---------------------------------------------------------- + cfg_key_string_t +----------------------------------------------------------*/ + +cfg_key_string_t::cfg_key_string_t(const char *_name, cfg_string_t &var, + const cfg_string_t def, int _save) +{ + name = _name; + value = &var; + strncpy(default_value, def, CFG_STRING_LENGTH); + save = _save; + typecode = CFG_STRING; +} + + +int cfg_key_string_t::copy(cfg_key_t *from) +{ + if(typecode != from->typecode) + return -1; + memcpy(*value, *((cfg_key_string_t *)from)->value, CFG_STRING_LENGTH); + return 0; +} + + +int cfg_key_string_t::read(int argc, char *argv[]) +{ + if(argc < 2) + return -1; + strncpy(*value, argv[1], CFG_STRING_LENGTH); + return 2; +} + + +void cfg_key_string_t::write(FILE *f) +{ + fprintf(f, "%s \"%s\"\n", name, *value); +} + + +void cfg_key_string_t::set_default() +{ + strncpy(*value, default_value, CFG_STRING_LENGTH); +} + + +int cfg_key_string_t::is_your_var(void *var) +{ + return var == (void *)value; +} + + + +/*---------------------------------------------------------- + config_parser_t +----------------------------------------------------------*/ + +config_parser_t::config_parser_t() +{ + keys = last_key = NULL; + changed = 0; + initialized = 0; +} + + +void config_parser_t::initialize() +{ + if(initialized) + return; + + init(); + set_defaults(); + build_table(); + initialized = 1; +} + +void config_parser_t::build_table() +{ + cfg_key_t *k = keys; + nkeys = 0; + while(k) + { + ++nkeys; + k = k->next; + } + table = new cfg_key_t*[nkeys]; + + k = keys; + int i = 0; + while(k) + { + table[i++] = k; + k = k->next; + } +} + +config_parser_t::~config_parser_t() +{ + cfg_key_t *k = keys; + while(k) + { + keys = k->next; + delete k; + k = keys; + } + delete[]table; +} + +config_parser_t &config_parser_t::operator = (config_parser_t &from) +{ + initialize(); + from.initialize(); + cfg_key_t *k = keys; + while(k) + { + cfg_key_t *fk = from.keys; + while(fk) + { + if(!strcmp(fk->name, k->name)) + { + if(k->copy(fk) < 0) + log_printf(ELOG, "config_parser_t: Tried" + " to copy from incompatible" + " source!\n"); + break; + } + fk = fk->next; + } + k = k->next; + } + return *this; +} + +void config_parser_t::add(cfg_key_t *_key) +{ + if(last_key) + { + last_key->next = _key; + last_key = _key; + } + else + keys = last_key = _key; +} + + +void config_parser_t::comment(const char *text) +{ + add(new cfg_comment_t(text)); +} + + +void config_parser_t::yesno(const char *name, int &var, int def, int save) +{ + add(new cfg_switch_t(name, var, def, save)); +} + + +void config_parser_t::command(const char *name, int &var) +{ + add(new cfg_switch_t(name, var, 0, 0)); +} + + +void config_parser_t::key(const char *name, int &var, int def, int save) +{ + add(new cfg_key_int_t(name, var, def, save)); +} + + +void config_parser_t::key(const char *name, float &var, float def, int save) +{ + add(new cfg_key_float_t(name, var, def, save)); +} + + +void config_parser_t::key(const char *name, cfg_string_t &var, + const cfg_string_t def, int save) +{ + add(new cfg_key_string_t(name, var, def, save)); +} + + +void config_parser_t::desc(const char *text) +{ + if(!last_key) + { + log_printf(ELOG, "config_parser_t::description() called" + " with no key registered!\n"); + return; + } + last_key->description = strdup(text); +} + + +void config_parser_t::set_defaults() +{ + cfg_key_t *k = keys; + while(k) + { + k->set_default(); + k->redefined = 0; + k = k->next; + } +} + + +/* + * "Uuuh, a leetle icky finite state machine parser... :-D" + * (Actually a very nice and simple way of coding this kind + * of stuff, if you don't want to drag in Bison or something.) + */ +enum scanstate_t +{ + SS_BLANK, + SS_QUOTE, + SS_WORD, + SS_COMMENT +}; + +int config_parser_t::read_config(char ***cv, FILE *f) +{ + *cv = (char **)calloc(MAX_CONFIG_LINES, sizeof(char *)); + if(!*cv) + return -1; + + if(!f) + { + free((*cv)); + (*cv) = NULL; + return -2; + } + + fseek(f, 0, SEEK_END); + int len = ftell(f); + (*cv)[0] = (char *)malloc(len+1); + if(!(*cv)[0]) + { + rewind(f); + free(*cv); + *cv = NULL; + return -3; + } + rewind(f); + if(fread((*cv)[0], len, 1, f) < 0) + { + free(*cv[0]); + free(*cv); + *cv = NULL; + return -4; + } + (*cv)[0][len] = 0; + + char *v = (*cv)[0]; + scanstate_t state = SS_BLANK; + int arg = 1; + int start_arg = 0; + while(*v) + { + switch(state) + { + case SS_BLANK: + if(*v == '"') + { + start_arg = 1; + state = SS_QUOTE; + } + else if(*v == '#') + state = SS_COMMENT; + else if(*v > ' ') + { + start_arg = 1; + state = SS_WORD; + } + break; + case SS_QUOTE: + if(*v == '"') + { + *v = 0; + state = SS_BLANK; + } + break; + case SS_WORD: + if(*v <= ' ') + { + *v = 0; + state = SS_BLANK; + } + break; + case SS_COMMENT: + if((*v == 10) || (*v == 13)) + state = SS_BLANK; + break; + } + if(start_arg) + { + if(arg < MAX_CONFIG_LINES) + { + if(state == SS_QUOTE) + (*cv)[arg++] = v+1; + else + (*cv)[arg++] = v; + } + start_arg = 0; + } + ++v; + } + rewind(f); + return arg; +} + + +int config_parser_t::parse(int argc, char *argv[]) +{ + initialize(); + + int i = 0; + while(i < argc) + { + if(argv[i][0] == '#') + { + ++i; + continue; + } + + cfg_key_t *k = keys; + int grabbed = 0; + while(k) + { + if(k->test(argv[i])) + { + grabbed = k->read(argc - i, argv + i); + if(grabbed > 0) + { + k->redefined = 1; + break; + } + else if(grabbed < 0) + { + log_printf(ELOG, "ERROR: Too few parameters to" + " argument '%s'!\n", + k->name); + return -2; + } + } + k = k->next; + } + if(!grabbed) + { + log_printf(ELOG, "ERROR: Unknown argument" + " '%s'!\n", argv[i]); + return -3; + } + i += grabbed; + } + postload(); + return 0; /* Ok. */ +} + + +int config_parser_t::read(FILE *f) +{ + int res = -10; + int cc; + char **cv; + cc = read_config(&cv, f); + if(cc > 0) + { + res = parse(cc, cv); + if(cv) + free(cv[0]); + free(cv); + } + return res; +} + + +int config_parser_t::write(FILE *f) +{ + initialize(); + + presave(); + cfg_key_t *k = keys; + while(k) + { + if(k->save) + k->write(f); + k = k->next; + } + return ferror(f); +} + + +int config_parser_t::_redefined(void *var) +{ + cfg_key_t *k = keys; + while(k) + { + if(k->is_your_var(var)) + return k->redefined; + k = k->next; + } + return 0; +} + + +void config_parser_t::_accept(void *var) +{ + cfg_key_t *k = keys; + while(k) + { + if(k->is_your_var(var)) + { + k->redefined = 0; + break; + } + k = k->next; + } +} + + + +/*---------------------------------------------------------- + Generic Symbol Table Style API +----------------------------------------------------------*/ + +int config_parser_t::find(const char *name) +{ + if(!table) + initialize(); + if(!table) + return -1; + for(int i = 0; i < nkeys; ++i) + if(table[i]->test(name)) + return i; + return -1; +} + + +int config_parser_t::find_next(int symbol) +{ + if(!table) + initialize(); + if(!table) + return -1; + + // Note that this simple code handles the + // "find first" -1 case for free. :-) + ++symbol; + if(symbol < 0) + return -1; + else if(symbol >= nkeys) + return -1; + + return symbol; +} + + +int config_parser_t::check_symbol(int symbol) +{ + if(!table) + return -1; + if(symbol < 0) + return -1; + else if(symbol >= nkeys) + return -1; + return 0; +} + + +cfg_types_t config_parser_t::type(int symbol) +{ + if(check_symbol(symbol) < 0) + return CFG_NONE; + return table[symbol]->typecode; +} + + +int config_parser_t::do_save(int symbol) +{ + if(check_symbol(symbol) < 0) + return CFG_NONE; + return table[symbol]->save; +} + + +const char *config_parser_t::description(int symbol) +{ + if(check_symbol(symbol) < 0) + return ""; + if(table[symbol]->description) + return table[symbol]->description; + else + return ""; +} + + +const char *config_parser_t::name(int symbol) +{ + if(check_symbol(symbol) < 0) + return ""; + if(table[symbol]->name) + return table[symbol]->name; + else + return ""; +} + + +void config_parser_t::set(int symbol, int value) +{ + if(check_symbol(symbol) < 0) + return; + switch(table[symbol]->typecode) + { + case CFG_NONE: + return; + case CFG_BOOL: + { + cfg_switch_t *k = (cfg_switch_t *)table[symbol]; + *(k->value) = value ? 1 : 0; + } + break; + case CFG_INT: + { + cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; + *(k->value) = value; + } + break; + case CFG_FLOAT: + { + cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; + *(k->value) = (float)value; + } + break; + case CFG_STRING: + { + cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; + snprintf(*(k->value), CFG_STRING_LENGTH-1, "%d", value); + } + break; + } + table[symbol]->redefined = 1; +} + + +void config_parser_t::set(int symbol, float value) +{ + if(check_symbol(symbol) < 0) + return; + switch(table[symbol]->typecode) + { + case CFG_NONE: + return; + case CFG_BOOL: + { + cfg_switch_t *k = (cfg_switch_t *)table[symbol]; + *(k->value) = value ? 1 : 0; + } + break; + case CFG_INT: + { + cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; + *(k->value) = (int)value; + } + break; + case CFG_FLOAT: + { + cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; + *(k->value) = value; + } + break; + case CFG_STRING: + { + cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; + snprintf(*(k->value), CFG_STRING_LENGTH-1, "%f", value); + } + break; + } + table[symbol]->redefined = 1; +} + + +void config_parser_t::set(int symbol, const char *text) +{ + if(check_symbol(symbol) < 0) + return; + switch(table[symbol]->typecode) + { + case CFG_NONE: + return; + case CFG_BOOL: + { + /* + * Unfortunately, only *real* operating systems have + * strcasecmp(), so we have to mess around a little. + */ + char buf[16]; + strncpy(buf, text, 15); + for(int i = 0; i < 15; ++i) + buf[i] = tolower(buf[i]); + cfg_switch_t *k = (cfg_switch_t *)table[symbol]; + if( strncmp(buf, "yes", 3) || strncmp(buf, "true", 4) || + strcmp(buf, "on") || strncmp(buf, "enable", 6) || + strncmp(buf, "activ", 5) || + strcmp(buf, "one") || strcmp(buf, "1") ) + *(k->value) = 1; + else + *(k->value) = 0; + } + break; + case CFG_INT: + { + cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; + *(k->value) = atoi(text); + } + break; + case CFG_FLOAT: + { + cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; + *(k->value) = atof(text); + } + break; + case CFG_STRING: + { + cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; + strncpy(*(k->value), text, CFG_STRING_LENGTH-1); + *(k->value)[CFG_STRING_LENGTH-1] = 0; + } + break; + } + table[symbol]->redefined = 1; +} + + +int config_parser_t::get_i(int symbol) +{ + if(check_symbol(symbol) < 0) + return 0; + switch(table[symbol]->typecode) + { + case CFG_NONE: + return 0; + case CFG_BOOL: + { + cfg_switch_t *k = (cfg_switch_t *)table[symbol]; + return *(k->value) ? 1 : 0; + } + case CFG_INT: + { + cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; + return *(k->value); + } + case CFG_FLOAT: + { + cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; + return (int)*(k->value); + } + case CFG_STRING: + { + cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; + return atoi(*(k->value)); + } + } + return 0; +} + + +float config_parser_t::get_f(int symbol) +{ + if(check_symbol(symbol) < 0) + return 0.0; + switch(table[symbol]->typecode) + { + case CFG_NONE: + return 0.0; + case CFG_BOOL: + { + cfg_switch_t *k = (cfg_switch_t *)table[symbol]; + return *(k->value) ? 1.0 : 0.0; + } + case CFG_INT: + { + cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; + return (float)*(k->value); + } + case CFG_FLOAT: + { + cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; + return *(k->value); + } + case CFG_STRING: + { + cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; + return atof(*(k->value)); + } + } + return 0.0; +} + + +const char *config_parser_t::get_s(int symbol) +{ + if(check_symbol(symbol) < 0) + return ""; + switch(table[symbol]->typecode) + { + case CFG_NONE: + return ""; + case CFG_BOOL: + { + cfg_switch_t *k = (cfg_switch_t *)table[symbol]; + return *(k->value) ? "On" : "Off"; + } + case CFG_INT: + { + cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; + snprintf(retbuf, sizeof(retbuf)-1, "%d", *(k->value)); + return retbuf; + } + case CFG_FLOAT: + { + cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; + snprintf(retbuf, sizeof(retbuf)-1, "%f", *(k->value)); + return retbuf; + } + case CFG_STRING: + { + cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; + return *(k->value); + } + break; + } + return ""; +} + + +int config_parser_t::get_default_i(int symbol) +{ + if(check_symbol(symbol) < 0) + return 0; + switch(table[symbol]->typecode) + { + case CFG_NONE: + return 0; + case CFG_BOOL: + { + cfg_switch_t *k = (cfg_switch_t *)table[symbol]; + return k->default_value ? 1 : 0; + } + case CFG_INT: + { + cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; + return k->default_value; + } + case CFG_FLOAT: + { + cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; + return (int)k->default_value; + } + case CFG_STRING: + { + cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; + return atoi(k->default_value); + } + } + return 0; +} + + +float config_parser_t::get_default_f(int symbol) +{ + if(check_symbol(symbol) < 0) + return 0.0; + switch(table[symbol]->typecode) + { + case CFG_NONE: + return 0.0; + case CFG_BOOL: + { + cfg_switch_t *k = (cfg_switch_t *)table[symbol]; + return k->default_value ? 1.0 : 0.0; + } + case CFG_INT: + { + cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; + return (float)k->default_value; + } + case CFG_FLOAT: + { + cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; + return k->default_value; + } + case CFG_STRING: + { + cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; + return atof(k->default_value); + } + } + return 0.0; +} + + +const char *config_parser_t::get_default_s(int symbol) +{ + if(check_symbol(symbol) < 0) + return ""; + switch(table[symbol]->typecode) + { + case CFG_NONE: + return ""; + case CFG_BOOL: + { + cfg_switch_t *k = (cfg_switch_t *)table[symbol]; + return k->default_value ? "On" : "Off"; + } + case CFG_INT: + { + cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; + snprintf(retbuf, sizeof(retbuf)-1, "%d", k->default_value); + return retbuf; + } + case CFG_FLOAT: + { + cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; + snprintf(retbuf, sizeof(retbuf)-1, "%f", k->default_value); + return retbuf; + } + case CFG_STRING: + { + cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; + return k->default_value; + } + break; + } + return ""; +} + diff --git a/cfgparse.h b/cfgparse.h new file mode 100644 index 0000000..356ecf7 --- /dev/null +++ b/cfgparse.h @@ -0,0 +1,199 @@ +/* +------------------------------------------------------------------- + cfgparse.h - Generic Config File and Argument Parser +------------------------------------------------------------------- + * Copyright (C) 2001, 2007 David Olofson + * + * This code is released under the terms of the GNU LGPL. + */ + +#ifndef CFGPARSE_H +#define CFGPARSE_H + +#include + +enum cfg_types_t +{ + CFG_NONE, + CFG_BOOL, + CFG_INT, + CFG_FLOAT, + CFG_STRING +}; + + +#define CFG_STRING_LENGTH 256 + +typedef char cfg_string_t[CFG_STRING_LENGTH]; + + +class cfg_key_t +{ + public: + cfg_key_t *next; + int save; + int redefined; + + cfg_types_t typecode; + const char *name; + char *description; + cfg_key_t(); + virtual ~cfg_key_t(); + virtual int read(int argc, char *argv[]); + virtual int test(const char *arg); + virtual int copy(cfg_key_t *from) = 0; + virtual void write(FILE *f) = 0; + virtual void set_default() = 0; + virtual int is_your_var(void *var) = 0; +}; + + +class cfg_comment_t : public cfg_key_t +{ + public: + cfg_comment_t(const char *text) { name = text; } + int read(int argc, char *argv[]) { return 0; } + int copy(cfg_key_t *from); + void write(FILE *f); + void set_default() { ; } + int is_your_var(void *var) { return 0; } +}; + + +class cfg_switch_t : public cfg_key_t +{ + public: + int *value; + int default_value; + + cfg_switch_t(const char *_name, int &var, int def, int _save); + int copy(cfg_key_t *from); + virtual int test(const char *arg); + int read(int argc, char *argv[]); + void write(FILE *f); + void set_default(); + int is_your_var(void *var); +}; + + +class cfg_key_int_t : public cfg_key_t +{ + public: + int *value; + int default_value; + + cfg_key_int_t(const char *_name, int &var, int def, int _save); + int copy(cfg_key_t *from); + int read(int argc, char *argv[]); + void write(FILE *f); + void set_default(); + int is_your_var(void *var); +}; + + +class cfg_key_float_t : public cfg_key_t +{ + public: + float *value; + float default_value; + + cfg_key_float_t(const char *_name, float &var, float def, int _save); + int copy(cfg_key_t *from); + int read(int argc, char *argv[]); + void write(FILE *f); + void set_default(); + int is_your_var(void *var); +}; + + +class cfg_key_string_t : public cfg_key_t +{ + public: + cfg_string_t *value; + cfg_string_t default_value; + + cfg_key_string_t(const char *_name, cfg_string_t &var, + const cfg_string_t def, int _save); + int copy(cfg_key_t *from); + int read(int argc, char *argv[]); + void write(FILE *f); + void set_default(); + int is_your_var(void *var); +}; + + +class config_parser_t +{ + cfg_key_t *keys, *last_key; + int initialized; + int nkeys; // For symbol table API + cfg_key_t **table; // For symbol table API + cfg_string_t retbuf; // For symbol table API + void initialize(); + void print_switch(FILE *f, const char *base, int flag); + int read_config(char ***cv, FILE *f); + void add(cfg_key_t *_key); + int _redefined(void *var); + void _accept(void *var); + void build_table(); + int check_symbol(int symbol); + protected: + //Key registration: For use in inherited init() + void comment(const char *text); + void yesno(const char *name, int &var, int def, int save = 1); + void command(const char *name, int &var); + void key(const char *name, int &var, int def, int save = 1); + void key(const char *name, float &var, float def, int save = 1); + void key(const char *name, cfg_string_t &var, const cfg_string_t def, + int save = 1); + void desc(const char *text); + + //Plug key registration and custom stuff in here! + virtual void init() = 0; + virtual void postload() { ; } + virtual void presave() { ; } + public: + int changed; //Set when *edited* by the user + config_parser_t(); + virtual ~config_parser_t(); + config_parser_t &operator = (config_parser_t &from); + void set_defaults(); + int parse(int argc, char *argv[]); + int read(FILE *f); + int write(FILE *f); + + //Changed since last accept() call? + int redefined(int &var) { return _redefined(&var); } + int redefined(float &var) { return _redefined(&var); } + int redefined(cfg_string_t &var) { return _redefined(&var); } + + //Reset redefined() state to 0. + void accept(int &var) { _accept(&var); } + void accept(float &var) { _accept(&var); } + void accept(cfg_string_t &var) { _accept(&var); } + + /* Generic Symbol Table Style API */ + int find(const char *name); + int find_next(int symbol = -1); + cfg_types_t type(int symbol); + int do_save(int symbol); + const char *name(int symbol); + const char *description(int symbol); + void set(int symbol, int value); + void set(int symbol, float value); + void set(int symbol, const char *text); + int get_i(int symbol); + int get_default_i(int symbol); + float get_f(int symbol); + float get_default_f(int symbol); + /* + * WARNING: These ones sometimes return pointers to non-constant + * buffers! Therefore, you need to copy the results + * before you call these functions again. + */ + const char *get_s(int symbol); + const char *get_default_s(int symbol); +}; + + +#endif //CFGPARSE_H diff --git a/compile b/compile new file mode 100755 index 0000000..9bb997a --- /dev/null +++ b/compile @@ -0,0 +1,99 @@ +#! /bin/sh + +# Wrapper for compilers which do not understand `-c -o'. + +# Copyright 1999, 2000 Free Software Foundation, Inc. +# Written by Tom Tromey . +# +# 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, 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. + +# Usage: +# compile PROGRAM [ARGS]... +# `-o FOO.o' is removed from the args passed to the actual compile. + +prog=$1 +shift + +ofile= +cfile= +args= +while test $# -gt 0; do + case "$1" in + -o) + # configure might choose to run compile as `compile cc -o foo foo.c'. + # So we do something ugly here. + ofile=$2 + shift + case "$ofile" in + *.o | *.obj) + ;; + *) + args="$args -o $ofile" + ofile= + ;; + esac + ;; + *.c) + cfile=$1 + args="$args $1" + ;; + *) + args="$args $1" + ;; + esac + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no `-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # `.c' file was seen then we are probably linking. That is also + # ok. + exec "$prog" $args +fi + +# Name of file we expect compiler to create. +cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'` + +# Create the lock directory. +# Note: use `[/.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d +while true; do + if mkdir $lockdir > /dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir $lockdir; exit 1" 1 2 15 + +# Run the compile. +"$prog" $args +status=$? + +if test -f "$cofile"; then + mv "$cofile" "$ofile" +fi + +rmdir $lockdir +exit $status diff --git a/config.guess b/config.guess new file mode 100755 index 0000000..9e55e1a --- /dev/null +++ b/config.guess @@ -0,0 +1,1391 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + +timestamp='2003-05-19' + +# 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. + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# 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, 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" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + 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 1994-08-24) +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. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + 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 + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # 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 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + macppc:OpenBSD:*:*) + echo powerpc-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 ;; + mvmeppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mipseb-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # 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. + 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;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + 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 ;; + DRS?6000:UNIX_SV:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7 && exit 0 ;; + esac ;; + 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=`(sed 1q /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 ;; + # 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 ;; + 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) + eval $set_cc_for_build + 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 -o $dummy $dummy.c \ + && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && exit 0 + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-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 + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + 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 | sed 1q | 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]) + 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" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + 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 -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + # avoid double evaluation of $set_cc_for_build + test -n "$CC_FOR_BUILD" || eval $set_cc_for_build + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + 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:*:*) + eval $set_cc_for_build + 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 -o $dummy $dummy.c && $dummy && exit 0 + 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:*:* | *3000*: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 ;; + 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*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + 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/ \ + -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${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 ;; + *:UNICOS/mp:*:*) + echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + 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 ;; + 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:*:*|*:GNU/FreeBSD:*:*) + # Determine whether the default compiler uses glibc. + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #if __GLIBC__ >= 2 + LIBC=gnu + #else + LIBC= + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} + 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 ;; + x86:Interix*:3*) + echo i586-pc-interix3 + exit 0 ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + 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 i586-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 ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit 0 ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + 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. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit 0 ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; + i*86:DYNIX/ptx:4*:*) + # 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. + 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:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + 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:[78]*) + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + 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|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + 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 ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit 0 ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + 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 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*: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 ;; + 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:*: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 ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + 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 ;; + SX-6:SUPER-UX:*:*) + echo sx6-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:*:*) + case `uname -p` in + *86) UNAME_PROCESSOR=i686 ;; + powerpc) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-[DGKLNPTVW]: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 ;; + *: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 + +eval $set_cc_for_build +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 -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 + +# 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.h b/config.h new file mode 100644 index 0000000..375bbd1 --- /dev/null +++ b/config.h @@ -0,0 +1,149 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996, Akira Higuchi + * Copyright (C) 2001-2003, David Olofson + * + * 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. + */ + +#ifndef _KOBO_CONFIG_H_ +#define _KOBO_CONFIG_H_ + +#include + +#ifndef DEBUG +# undef DBG +# undef DBG2 +# undef DBG3 +# undef DBG4 +# define DBG(x) +# define DBG2(x) +# define DBG3(x) +# define DBG4(x) +#endif + +#ifndef HAVE_SNPRINTF +#ifndef HAVE__SNPRINTF +#error Must have snprintf() or _snprintf! +#endif +#define snprintf _snprintf +#endif + +#ifndef HAVE_VSNPRINTF +#ifndef HAVE__VSNPRINTF +#error Must have vsnprintf() or _vsnprintf! +#endif +#define vsnprintf _vsnprintf +#endif + +/* + * On some platforms, assignments of these "opaque objects" are + * illegal - while on others, the macro to handle that can be + * missing... Oh, and this is really only in C99, of course. :-/ + */ +#include +#ifndef va_copy +# ifdef __va_copy +# define va_copy(to, from) __va_copy(to, from) +# else +# define va_copy(to, from) (to) = (from) +# endif +#endif + +/* Key/button repeat timing */ +#define KOBO_KEY_DELAY 250 +#define KOBO_KEY_REPEAT 40 + +/* + * This was originally 1024, but was changed in Kobo Deluxe 0.4.1 + * to avoid the bug where we run out of enemies when destroying a + * base, and thus leave parts of it behind. + */ +#define ENEMY_MAX 2048 + +/* + * Game display size. + * + * In XKobo, there was only WSIZE - VIEWLIMIT was added + * for Kobo Deluxe, and WSIZE was set to 230, to add some + * extra pixels, most of which were more or less covered + * by the rounded framework. + * + * As of Kobo Deluxe 0.4.1, WSIZE is restored to the + * original 224. + * + * Note that if WSIZE is larger than VIEWLIMIT, some + * objects might be created or deleted in view. Finding + * out whether or not it can really happen calls for + * closer analysis of the code. + */ +#define WSIZE 224 +#define MARGIN 8 + +/* + * (In XKobo, WSIZE was used where this is + * used now; in the game logic code.) + * + * NOTE: I *DON'T* want to change the view + * range as the XKobo engine knows it, + * as that would make the game play + * slightly differently. (Probably not + * so that anyone would notice, but + * let's not take chances... This is + * NOT "Kobo II".) + */ +#define VIEWLIMIT 224 + +// Player ship hit rect size +#define HIT_MYSHIP 5 + +// Player bolt hit rect size +#define HIT_BOLT 5 + +/* Actually, this is not the *full* size in windowed mode any more. */ +#define SCREEN_WIDTH 320 +#define SCREEN_HEIGHT 240 + +/* Various size info (DO NOT EDIT!) */ +#define CHIP_SIZEX_LOG2 4 +#define CHIP_SIZEY_LOG2 4 +#define MAP_SIZEX_LOG2 6 +#define MAP_SIZEY_LOG2 7 +#define WORLD_SIZEX_LOG2 (MAP_SIZEX_LOG2+CHIP_SIZEX_LOG2) +#define WORLD_SIZEY_LOG2 (MAP_SIZEY_LOG2+CHIP_SIZEY_LOG2) +#define NOISE_SIZEX_LOG2 8 + +#define CHIP_SIZEX (1<. Submit a context +# diff and a properly formatted ChangeLog entry. +# +# 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* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + 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 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + 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. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k \ + | m32r | m68000 | m68k | m88k | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | msp430 \ + | ns16k | ns32k \ + | openrisc | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xstormy16 | xtensa \ + | z8k) + 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 | v70 | w65 | z8k) + ;; + + # 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. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* \ + | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* \ + | m32r-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | msp430-* \ + | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ + | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + # 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 + ;; + amd64) + basic_machine=x86_64-pc + ;; + 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 + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + 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 | j90) + basic_machine=j90-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 + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + 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 + ;; + 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 + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + 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 + ;; + nv1) + basic_machine=nv1-cray + os=-unicosmp + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + or32 | or32-*) + basic_machine=or32-unknown + os=-coff + ;; + 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 | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i686-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + 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/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`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 + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sparclite-wrs | simso-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=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic4x | c4x*) + basic_machine=tic4x-unknown + os=-coff + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + 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 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + 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 + ;; + 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 | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sh64) + basic_machine=sh64-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 + ;; + *-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* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|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 + ;; + -atheos*) + os=-atheos + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -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 + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -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 + ;; + # This must come before the *-dec entry. + 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 + ;; + or32-*) + os=-coff + ;; + *-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* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + 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..90b3a55 --- /dev/null +++ b/configure @@ -0,0 +1,12135 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.61. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + + +exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +ac_unique_file="Makefile.am" +ac_unique_file="Makefile.am" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +build +build_cpu +build_vendor +build_os +host +host_cpu +host_vendor +host_os +target +target_cpu +target_vendor +target_os +INSTALL_PROGRAM +INSTALL_SCRIPT +INSTALL_DATA +CYGPATH_W +PACKAGE +VERSION +ACLOCAL +AUTOCONF +AUTOMAKE +AUTOHEADER +MAKEINFO +install_sh +STRIP +INSTALL_STRIP_PROGRAM +mkdir_p +AWK +SET_MAKE +am__leading_dot +AMTAR +am__tar +am__untar +XMKMF +CC +CFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CC +EXEEXT +OBJEXT +DEPDIR +am__include +am__quote +AMDEP_TRUE +AMDEP_FALSE +AMDEPBACKSLASH +CCDEPMODE +am__fastdepCC_TRUE +am__fastdepCC_FALSE +CPP +X_CFLAGS +X_PRE_LIBS +X_LIBS +X_EXTRA_LIBS +BUILD_MACOSX_BUNDLE_TRUE +BUILD_MACOSX_BUNDLE_FALSE +BUILD_SIMPLE_BUNDLE_TRUE +BUILD_SIMPLE_BUNDLE_FALSE +UNIX_SCOREDIR_TRUE +UNIX_SCOREDIR_FALSE +DATADIR +SCOREDIR +CONFIGDIR +CONFIGFILE +EXEFILE +MATHLIB +CXX +CXXFLAGS +ac_ct_CXX +CXXDEPMODE +am__fastdepCXX_TRUE +am__fastdepCXX_FALSE +RANLIB +SDL_CONFIG +SDL_CFLAGS +SDL_LIBS +GREP +EGREP +LIBOBJS +POW_LIB +AUDIO_LIBS +LOCALCFLAGS +LTLIBOBJS' +ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +XMKMF +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP +CXX +CXXFLAGS +CCC' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +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=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -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_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$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 ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + 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 | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$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 ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + 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 | -n) + 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 ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$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_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + 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 "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute directory names. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# 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 the parent directory. + ac_confdir=`$as_dirname -- "$0" || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + 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 + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # 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 <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --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 + +X features: + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --enable-debug Build with debug switches and defines default=no + --disable-sdltest Do not try to compile and run a test SDL program + --enable-opengl use OpenGL rendering layer default=yes + --enable-oss support the OSS audio API default=no + --enable-alsa support the ALSA audio API default=no + --enable-epm Compile with extremely picky settings default=no + --enable-efence Link with ElectricFence default=no + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-x use the X Window System + --with-sdl-prefix=PFX Prefix where SDL is installed (optional) + --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional) + +Some influential environment variables: + XMKMF Path to xmkmf, Makefile generator for X Window System + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + CXX C++ compiler command + CXXFLAGS C++ compiler flags + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +configure +generated by GNU Autoconf 2.61 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.61. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +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 || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" +fi +shift +for ac_site_file +do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + + + + + + + + + + + + + + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +ac_config_headers="$ac_config_headers aconfig.h" + +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 + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} + { (exit 1); exit 1; }; } +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} + { (exit 1); exit 1; }; } + +{ echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6; } +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +echo "$as_me: error: invalid value of canonical build" >&2;} + { (exit 1); exit 1; }; };; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6; } +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} + { (exit 1); exit 1; }; } +fi + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 +echo "$as_me: error: invalid value of canonical host" >&2;} + { (exit 1); exit 1; }; };; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ echo "$as_me:$LINENO: checking target system type" >&5 +echo $ECHO_N "checking target system type... $ECHO_C" >&6; } +if test "${ac_cv_target+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} + { (exit 1); exit 1; }; } +fi + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +echo "${ECHO_T}$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 +echo "$as_me: error: invalid value of canonical target" >&2;} + { (exit 1); exit 1; }; };; +esac +target=$ac_cv_target +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- +am__api_version="1.9" +# 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 +# AmigaOS /C/install, which installs bootblocks on floppy discs +# 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" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /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 + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done +IFS=$as_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. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&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}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm -f conftest.sed + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi + +for ac_prog in gawk mawk nawk awk +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 "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } +set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + SET_MAKE= +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE=KoboDeluxe + VERSION=0.5.1 + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +install_sh=${install_sh-"$am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + + +LOCALCFLAGS='' + + +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +{ echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + + +if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + fi +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 "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_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 $# != 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 + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +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 "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } + +{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&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 "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ echo "$as_me:$LINENO: checking for X" >&5 +echo $ECHO_N "checking for X... $ECHO_C" >&6; } + + +# Check whether --with-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 + case $x_includes,$x_libraries in #( + *\'*) { { echo "$as_me:$LINENO: error: Cannot use X directory names containing '" >&5 +echo "$as_me: error: Cannot use X directory names containing '" >&2;} + { (exit 1); exit 1; }; };; #( + *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 -f -r conftest.dir +if mkdir conftest.dir; then + cd conftest.dir + cat >Imakefile <<'_ACEOF' +incroot: + @echo incroot='${INCROOT}' +usrlibdir: + @echo usrlibdir='${USRLIBDIR}' +libdir: + @echo libdir='${LIBDIR}' +_ACEOF + if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then + # GNU make sometimes prints "make[1]: Entering...", which would confuse us. + for ac_var in incroot usrlibdir libdir; do + eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`" + done + # 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) ac_x_includes= ;; + *) 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 -f -r conftest.dir +fi + +# Standard set of common directories for X headers. +# Check X11 before X11Rn because it is often a symlink to the current release. +ac_x_header_dirs=' +/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' + +if test "$ac_x_includes" = no; then + # Guess where to find include files, by looking for Xlib.h. + # First, try using that file with no special directory specified. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # We can compile using X headers with no special include directory. +ac_x_includes= +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + for ac_dir in $ac_x_header_dirs; do + if test -r "$ac_dir/X11/Xlib.h"; then + ac_x_includes=$ac_dir + break + fi +done +fi + +rm -f conftest.err conftest.$ac_ext +fi # $ac_x_includes = no + +if test "$ac_x_libraries" = no; then + # Check for the libraries. + # See if we find them without any special options. + # Don't add to $LIBS permanently. + ac_save_LIBS=$LIBS + LIBS="-lX11 $LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +int +main () +{ +XrmInitialize () + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + LIBS=$ac_save_LIBS +# We can link X programs with no special library path. +ac_x_libraries= +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + LIBS=$ac_save_LIBS +for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` +do + # Don't even attempt the hair of trying to link an X program! + for ac_extension in a so sl; do + if test -r "$ac_dir/libX11.$ac_extension"; then + ac_x_libraries=$ac_dir + break 2 + fi + done +done +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi # $ac_x_libraries = no + +case $ac_x_includes,$ac_x_libraries in #( + no,* | *,no | *\'*) + # Didn't find X, or a directory has "'" in its name. + ac_cv_have_x="have_x=no";; #( + *) + # 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'" +esac +fi +;; #( + *) have_x=yes;; + esac + eval "$ac_cv_have_x" +fi # $with_x != no + +if test "$have_x" != yes; then + { echo "$as_me:$LINENO: result: $have_x" >&5 +echo "${ECHO_T}$have_x" >&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 "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5 +echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&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 <<\_ACEOF +#define X_DISPLAY_MISSING 1 +_ACEOF + + 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 . . . . + { echo "$as_me:$LINENO: checking whether -R must be followed by a space" >&5 +echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6; } + ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries" + ac_xsave_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + X_LIBS="$X_LIBS -R$x_libraries" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + LIBS="$ac_xsave_LIBS -R $x_libraries" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + X_LIBS="$X_LIBS -R $x_libraries" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: neither works" >&5 +echo "${ECHO_T}neither works" >&6; } +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + ac_c_werror_flag=$ac_xsave_c_werror_flag + LIBS=$ac_xsave_LIBS + 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 says this is needed for Ultrix, if the X + # libraries were built with DECnet support. And Karl Berry says + # the Alpha needs dnet_stub (dnet does not exist). + ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char XOpenDisplay (); +int +main () +{ +return XOpenDisplay (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet" >&5 +echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6; } +if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldnet $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dnet_ntoa (); +int +main () +{ +return dnet_ntoa (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_dnet_dnet_ntoa=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dnet_dnet_ntoa=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 +echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6; } +if test $ac_cv_lib_dnet_dnet_ntoa = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" +fi + + if test $ac_cv_lib_dnet_dnet_ntoa = no; then + { echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet_stub" >&5 +echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6; } +if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldnet_stub $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dnet_ntoa (); +int +main () +{ +return dnet_ntoa (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_dnet_stub_dnet_ntoa=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dnet_stub_dnet_ntoa=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 +echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; } +if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" +fi + + fi +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$ac_xsave_LIBS" + + # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, + # to get the SysV transport functions. + # Chad R. Larson 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 T.E. Dickey. + # The functions gethostbyname, getservbyname, and inet_addr are + # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. + { echo "$as_me:$LINENO: checking for gethostbyname" >&5 +echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6; } +if test "${ac_cv_func_gethostbyname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define gethostbyname to an innocuous variant, in case declares gethostbyname. + For example, HP-UX 11i declares gettimeofday. */ +#define gethostbyname innocuous_gethostbyname + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char gethostbyname (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef gethostbyname + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostbyname (); +/* 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 +#endif + +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func_gethostbyname=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_gethostbyname=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname" >&5 +echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6; } + + if test $ac_cv_func_gethostbyname = no; then + { echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5 +echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6; } +if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnsl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_nsl_gethostbyname=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_nsl_gethostbyname=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5 +echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6; } +if test $ac_cv_lib_nsl_gethostbyname = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" +fi + + if test $ac_cv_lib_nsl_gethostbyname = no; then + { echo "$as_me:$LINENO: checking for gethostbyname in -lbsd" >&5 +echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6; } +if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lbsd $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_bsd_gethostbyname=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_bsd_gethostbyname=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_bsd_gethostbyname" >&5 +echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6; } +if test $ac_cv_lib_bsd_gethostbyname = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" +fi + + 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 Leinen: it contains gethostby* + # variants that don't use the name server (or something). -lsocket + # must be given before -lnsl if both are needed. We assume that + # if connect needs -lnsl, so does gethostbyname. + { echo "$as_me:$LINENO: checking for connect" >&5 +echo $ECHO_N "checking for connect... $ECHO_C" >&6; } +if test "${ac_cv_func_connect+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define connect to an innocuous variant, in case declares connect. + For example, HP-UX 11i declares gettimeofday. */ +#define connect innocuous_connect + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char connect (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef connect + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char connect (); +/* 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 +#endif + +int +main () +{ +return connect (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func_connect=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_connect=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_connect" >&5 +echo "${ECHO_T}$ac_cv_func_connect" >&6; } + + if test $ac_cv_func_connect = no; then + { echo "$as_me:$LINENO: checking for connect in -lsocket" >&5 +echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6; } +if test "${ac_cv_lib_socket_connect+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket $X_EXTRA_LIBS $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char connect (); +int +main () +{ +return connect (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_socket_connect=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_socket_connect=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_socket_connect" >&5 +echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6; } +if test $ac_cv_lib_socket_connect = yes; then + X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" +fi + + fi + + # Guillermo Gomez says -lposix is necessary on A/UX. + { echo "$as_me:$LINENO: checking for remove" >&5 +echo $ECHO_N "checking for remove... $ECHO_C" >&6; } +if test "${ac_cv_func_remove+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define remove to an innocuous variant, in case declares remove. + For example, HP-UX 11i declares gettimeofday. */ +#define remove innocuous_remove + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char remove (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef remove + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char remove (); +/* 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 +#endif + +int +main () +{ +return remove (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func_remove=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_remove=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_remove" >&5 +echo "${ECHO_T}$ac_cv_func_remove" >&6; } + + if test $ac_cv_func_remove = no; then + { echo "$as_me:$LINENO: checking for remove in -lposix" >&5 +echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6; } +if test "${ac_cv_lib_posix_remove+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lposix $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char remove (); +int +main () +{ +return remove (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_posix_remove=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_posix_remove=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_posix_remove" >&5 +echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6; } +if test $ac_cv_lib_posix_remove = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" +fi + + fi + + # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. + { echo "$as_me:$LINENO: checking for shmat" >&5 +echo $ECHO_N "checking for shmat... $ECHO_C" >&6; } +if test "${ac_cv_func_shmat+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define shmat to an innocuous variant, in case declares shmat. + For example, HP-UX 11i declares gettimeofday. */ +#define shmat innocuous_shmat + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shmat (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef shmat + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shmat (); +/* 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 +#endif + +int +main () +{ +return shmat (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func_shmat=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_shmat=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_shmat" >&5 +echo "${ECHO_T}$ac_cv_func_shmat" >&6; } + + if test $ac_cv_func_shmat = no; then + { echo "$as_me:$LINENO: checking for shmat in -lipc" >&5 +echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6; } +if test "${ac_cv_lib_ipc_shmat+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lipc $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shmat (); +int +main () +{ +return shmat (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_ipc_shmat=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_ipc_shmat=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_ipc_shmat" >&5 +echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6; } +if test $ac_cv_lib_ipc_shmat = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" +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. + # John Interrante, Karl Berry + { echo "$as_me:$LINENO: checking for IceConnectionNumber in -lICE" >&5 +echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6; } +if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lICE $X_EXTRA_LIBS $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char IceConnectionNumber (); +int +main () +{ +return IceConnectionNumber (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_ICE_IceConnectionNumber=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_ICE_IceConnectionNumber=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 +echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6; } +if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then + X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" +fi + + LDFLAGS=$ac_save_LDFLAGS + +fi + + + +{ echo "$as_me:$LINENO: checking target platform and install style" >&5 +echo $ECHO_N "checking target platform and install style... $ECHO_C" >&6; }; +build_macosx_bundle=no +build_simple_bundle=no +unix_scoredir=yes +DATADIR='$(datadir)/kobo-deluxe' +SCOREDIR='$(sharedstatedir)/kobo-deluxe/scores' +CONFIGDIR='HOME>>' +CONFIGFILE='.kobodlrc' +EXEFILE=kobodl +case "$target_os" in + linux*) + { echo "$as_me:$LINENO: result: GNU/Linux; Un*x style" >&5 +echo "${ECHO_T}GNU/Linux; Un*x style" >&6; } + MATHLIB="-lm" + if test x$have_x = xyes; then + CFLAGS="$CFLAGS $X_CFLAGS" + fi + ;; + beos) + { echo "$as_me:$LINENO: result: BeOS; Un*x style install" >&5 +echo "${ECHO_T}BeOS; Un*x style install" >&6; } + MATHLIB="" + ;; + mingw32*) + { echo "$as_me:$LINENO: result: Win32 (mingw32); Simple bundle" >&5 +echo "${ECHO_T}Win32 (mingw32); Simple bundle" >&6; } + build_simple_bundle=yes + unix_scoredir=no + DATADIR='EXE>>' + SCOREDIR='EXE>>scores' + CONFIGDIR='EXE>>' + CONFIGFILE='kobodl.cfg' + EXEFILE=kobodl.exe + MATHLIB="" + ;; + cygwin*) + { echo "$as_me:$LINENO: result: Win32 (cygwin); Simple bundle" >&5 +echo "${ECHO_T}Win32 (cygwin); Simple bundle" >&6; } + build_simple_bundle=yes + unix_scoredir=no + DATADIR='EXE>>' + SCOREDIR='EXE>>scores' + CONFIGDIR='EXE>>' + CONFIGFILE='kobodl.cfg' + EXEFILE=kobodl.exe + MATHLIB="" + ;; + darwin*) + { echo "$as_me:$LINENO: result: Mac OS X/Darwin; Mac OS X bundle" >&5 +echo "${ECHO_T}Mac OS X/Darwin; Mac OS X bundle" >&6; } + build_macosx_bundle=yes + DATADIR='EXE>>../Resources' + SCOREDIR='/Library/Preferences/KoboDeluxe/scores' + CONFIGDIR='HOME>>Library/Preferences' + CONFIGFILE='KoboDeluxe Preferences' + MATHLIB="" + ;; + aix*) + { echo "$as_me:$LINENO: result: AIX; Un*x style" >&5 +echo "${ECHO_T}AIX; Un*x style" >&6; } + if test x$ac_cv_c_compiler_gnu = xyes; then + CFLAGS="-mthreads" + fi + if test x$have_x = xyes; then + CFLAGS="$CFLAGS $X_CFLAGS" + fi + ;; + solaris*) + { echo "$as_me:$LINENO: result: Solaris SPARC; Un*x style" >&5 +echo "${ECHO_T}Solaris SPARC; Un*x style" >&6; } + MATHLIB="-lm" + CFLAGS="$CFLAGS $X_CFLAGS" + ;; + *) + { echo "$as_me:$LINENO: result: Unknown (assuming Un*x-like); Un*x style" >&5 +echo "${ECHO_T}Unknown (assuming Un*x-like); Un*x style" >&6; } + MATHLIB="-lm" + if test x$have_x = xyes; then + CFLAGS="$CFLAGS $X_CFLAGS" + fi + ;; +esac + + +if test x$build_macosx_bundle = xyes; then + BUILD_MACOSX_BUNDLE_TRUE= + BUILD_MACOSX_BUNDLE_FALSE='#' +else + BUILD_MACOSX_BUNDLE_TRUE='#' + BUILD_MACOSX_BUNDLE_FALSE= +fi + + + +if test x$build_simple_bundle = xyes; then + BUILD_SIMPLE_BUNDLE_TRUE= + BUILD_SIMPLE_BUNDLE_FALSE='#' +else + BUILD_SIMPLE_BUNDLE_TRUE='#' + BUILD_SIMPLE_BUNDLE_FALSE= +fi + + + +if test x$unix_scoredir = xyes; then + UNIX_SCOREDIR_TRUE= + UNIX_SCOREDIR_FALSE='#' +else + UNIX_SCOREDIR_TRUE='#' + UNIX_SCOREDIR_FALSE= +fi + + + + + + + + + +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then + enableval=$enable_debug; +else + enable_debug=no +fi + +{ echo "$as_me:$LINENO: checking for debug build" >&5 +echo $ECHO_N "checking for debug build... $ECHO_C" >&6; } +if test x$enable_debug = xyes; then + CFLAGS="$CFLAGS -g -DDEBUG" + CXXFLAGS="$CXXFLAGS -g -DDEBUG" +fi +{ echo "$as_me:$LINENO: result: $enable_debug" >&5 +echo "${ECHO_T}$enable_debug" >&6; } + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + fi +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 "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_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 $# != 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 + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +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 "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&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 "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { echo "$as_me:$LINENO: result: $CXX" >&5 +echo "${ECHO_T}$CXX" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +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 "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 +echo "${ECHO_T}$ac_ct_CXX" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C++ compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +{ echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; } +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; } +GXX=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cxx_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CXXFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cxx_g" >&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 +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CXX" am_compiler_list= + +{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } +if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +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 +# AmigaOS /C/install, which installs bootblocks on floppy discs +# 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" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /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 + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done +IFS=$as_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. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&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}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +for ac_prog in gawk mawk nawk awk +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 "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$AWK" && break +done + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + + + +SDL_VERSION=1.2.0 + +# Check whether --with-sdl-prefix was given. +if test "${with_sdl_prefix+set}" = set; then + withval=$with_sdl_prefix; sdl_prefix="$withval" +else + sdl_prefix="" +fi + + +# Check whether --with-sdl-exec-prefix was given. +if test "${with_sdl_exec_prefix+set}" = set; then + withval=$with_sdl_exec_prefix; sdl_exec_prefix="$withval" +else + sdl_exec_prefix="" +fi + +# Check whether --enable-sdltest was given. +if test "${enable_sdltest+set}" = set; then + enableval=$enable_sdltest; +else + enable_sdltest=yes +fi + + + if test x$sdl_exec_prefix != x ; then + sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config + fi + fi + if test x$sdl_prefix != x ; then + sdl_args="$sdl_args --prefix=$sdl_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_prefix/bin/sdl-config + fi + fi + + if test "x$prefix" != xNONE; then + PATH="$prefix/bin:$prefix/usr/bin:$PATH" + fi + # Extract the first word of "sdl-config", so it can be a program name with args. +set dummy sdl-config; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_SDL_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $SDL_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_SDL_CONFIG="$SDL_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_SDL_CONFIG="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + test -z "$ac_cv_path_SDL_CONFIG" && ac_cv_path_SDL_CONFIG="no" + ;; +esac +fi +SDL_CONFIG=$ac_cv_path_SDL_CONFIG +if test -n "$SDL_CONFIG"; then + { echo "$as_me:$LINENO: result: $SDL_CONFIG" >&5 +echo "${ECHO_T}$SDL_CONFIG" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + min_sdl_version=$SDL_VERSION + { echo "$as_me:$LINENO: checking for SDL - version >= $min_sdl_version" >&5 +echo $ECHO_N "checking for SDL - version >= $min_sdl_version... $ECHO_C" >&6; } + no_sdl="" + if test "$SDL_CONFIG" = "no" ; then + no_sdl=yes + else + SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` + SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` + + sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` + if test "x$enable_sdltest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_CXXFLAGS="$CXXFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SDL_CFLAGS" + CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + rm -f conf.sdltest + if test "$cross_compiling" = yes; then + echo $ac_n "cross compiling; assumed OK... $ac_c" +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#include +#include +#include "SDL.h" + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main (int argc, char *argv[]) +{ + int major, minor, micro; + char *tmp_version; + + /* This hangs on some systems (?) + system ("touch conf.sdltest"); + */ + { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_sdl_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_sdl_version"); + exit(1); + } + + if (($sdl_major_version > major) || + (($sdl_major_version == major) && ($sdl_minor_version > minor)) || + (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); + printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); + printf("*** to point to the correct copy of sdl-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +no_sdl=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + CFLAGS="$ac_save_CFLAGS" + CXXFLAGS="$ac_save_CXXFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_sdl" = x ; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + : + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + if test "$SDL_CONFIG" = "no" ; then + echo "*** The sdl-config script installed by SDL could not be found" + echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the SDL_CONFIG environment variable to the" + echo "*** full path to sdl-config." + else + if test -f conf.sdltest ; then + : + else + echo "*** Could not run SDL test program, checking why..." + CFLAGS="$CFLAGS $SDL_CFLAGS" + CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#include "SDL.h" + +int main(int argc, char *argv[]) +{ return 0; } +#undef main +#define main K_and_R_C_main + +int +main () +{ + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding SDL or finding the wrong" + echo "*** version of SDL. If it is not finding SDL, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means SDL was incorrectly installed" + echo "*** or that you have moved SDL since it was installed. In the latter case, you" + echo "*** may want to edit the sdl-config script: $SDL_CONFIG" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$ac_save_CFLAGS" + CXXFLAGS="$ac_save_CXXFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SDL_CFLAGS="" + SDL_LIBS="" + { { echo "$as_me:$LINENO: error: *** SDL version $SDL_VERSION required!" >&5 +echo "$as_me: error: *** SDL version $SDL_VERSION required!" >&2;} + { (exit 1); exit 1; }; } + + fi + + + rm -f conf.sdltest + +CFLAGS="$CFLAGS $SDL_CFLAGS" +CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" +LIBS="$LIBS $SDL_LIBS" + + + +{ echo "$as_me:$LINENO: checking for IMG_Load in -lSDL_image" >&5 +echo $ECHO_N "checking for IMG_Load in -lSDL_image... $ECHO_C" >&6; } +if test "${ac_cv_lib_SDL_image_IMG_Load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lSDL_image -lSDL + $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char IMG_Load (); +int +main () +{ +return IMG_Load (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_SDL_image_IMG_Load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_SDL_image_IMG_Load=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_SDL_image_IMG_Load" >&5 +echo "${ECHO_T}$ac_cv_lib_SDL_image_IMG_Load" >&6; } +if test $ac_cv_lib_SDL_image_IMG_Load = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSDL_IMAGE 1 +_ACEOF + + LIBS="-lSDL_image $LIBS" + +else + { { echo "$as_me:$LINENO: error: You need the SDL_image library to compile this software. + Get it at http://www.libsdl.org/projects/SDL_image/" >&5 +echo "$as_me: error: You need the SDL_image library to compile this software. + Get it at http://www.libsdl.org/projects/SDL_image/" >&2;} + { (exit 1); exit 1; }; } +fi + +LIBS="$LIBS -lSDL_image" + + +{ echo "$as_me:$LINENO: checking for OpenGL support" >&5 +echo $ECHO_N "checking for OpenGL support... $ECHO_C" >&6; } +have_opengl=no +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #if defined(__APPLE__) && defined(__MACH__) + #include + #else + #include + #endif + +int +main () +{ + + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + +have_opengl=yes + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +# Check whether --enable-opengl was given. +if test "${enable_opengl+set}" = set; then + enableval=$enable_opengl; +else + enable_opengl=yes +fi + +if test x$enable_opengl = xyes; then + { echo "$as_me:$LINENO: result: $have_opengl" >&5 +echo "${ECHO_T}$have_opengl" >&6; } +else + have_opengl=no + { echo "$as_me:$LINENO: result: Disabled" >&5 +echo "${ECHO_T}Disabled" >&6; } +fi + +if test x$have_opengl = xyes; then + CFLAGS="$CFLAGS -DHAVE_OPENGL" + CXXFLAGS="$CXXFLAGS -DHAVE_OPENGL" +fi + + + + + + + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 +echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include <$ac_hdr> + +int +main () +{ +if ((DIR *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 +_ACEOF + +ac_header_dirent=$ac_hdr; break +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 "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' dir; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_opendir=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_opendir+set}" = set; then + break +fi +done +if test "${ac_cv_search_opendir+set}" = set; then + : +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +else + { echo "$as_me:$LINENO: checking for library containing opendir" >&5 +echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } +if test "${ac_cv_search_opendir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' x; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_opendir=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_opendir+set}" = set; then + break +fi +done +if test "${ac_cv_search_opendir+set}" = set; then + : +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 +echo "${ECHO_T}$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +fi + +{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_GREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + # Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_GREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_GREP=$GREP +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_EGREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + # Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_EGREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_EGREP=$EGREP +fi + + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdc=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + 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 <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + 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 <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#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)) + return 2; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 +echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6; } +if test "${ac_cv_header_time+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_time=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_time=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 +echo "${ECHO_T}$ac_cv_header_time" >&6; } +if test $ac_cv_header_time = yes; then + +cat >>confdefs.h <<\_ACEOF +#define TIME_WITH_SYS_TIME 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + +for ac_header in errno.h fcntl.h stdlib.h string.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + +for ac_header in sys/ioctl.h sys/time.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in SDL/SDL_opengl.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +{ echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; } +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset cs; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_c_const=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for inline" >&5 +echo $ECHO_N "checking for inline... $ECHO_C" >&6; } +if test "${ac_cv_c_inline+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_inline=$ac_kw +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_inline" != no && break +done + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 +echo "${ECHO_T}$ac_cv_c_inline" >&6; } + + +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac + +{ echo "$as_me:$LINENO: checking return type of signal handlers" >&5 +echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6; } +if test "${ac_cv_type_signal+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +return *(signal (0, 0)) (0) == 1; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_signal=int +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_signal=void +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 +echo "${ECHO_T}$ac_cv_type_signal" >&6; } + +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal +_ACEOF + + + + + + + + +for ac_func in strdup strstr strchr strrchr +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* 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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + + +for ac_func in snprintf _snprintf vsnprintf _vsnprintf +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* 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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + +for ac_func in pow sqrt +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* 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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + + +for ac_func in munmap mkdir select stat +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* 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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + + + +for ac_func in atexit floor memmove memset memcmp +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* 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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +for ac_func in gettimeofday +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* 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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + +for ac_func in getegid setgid +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* 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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +{ echo "$as_me:$LINENO: checking for working memcmp" >&5 +echo $ECHO_N "checking for working memcmp... $ECHO_C" >&6; } +if test "${ac_cv_func_memcmp_working+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_memcmp_working=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Some versions of memcmp are not 8-bit clean. */ + char c0 = '\100', c1 = '\200', c2 = '\201'; + if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0) + return 1; + + /* The Next x86 OpenStep bug shows up only when comparing 16 bytes + or more and with at least one buffer not starting on a 4-byte boundary. + William Lewis provided this test program. */ + { + char foo[21]; + char bar[21]; + int i; + for (i = 0; i < 4; i++) + { + char *a = foo + i; + char *b = bar + i; + strcpy (a, "--------01111111"); + strcpy (b, "--------10000000"); + if (memcmp (a, b, 16) >= 0) + return 1; + } + return 0; + } + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_memcmp_working=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_memcmp_working=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_memcmp_working" >&5 +echo "${ECHO_T}$ac_cv_func_memcmp_working" >&6; } +test $ac_cv_func_memcmp_working = no && case " $LIBOBJS " in + *" memcmp.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS memcmp.$ac_objext" + ;; +esac + + +{ echo "$as_me:$LINENO: checking for working strtod" >&5 +echo $ECHO_N "checking for working strtod... $ECHO_C" >&6; } +if test "${ac_cv_func_strtod+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_strtod=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +$ac_includes_default +#ifndef strtod +double strtod (); +#endif +int +main() +{ + { + /* Some versions of Linux strtod mis-parse strings with leading '+'. */ + char *string = " +69"; + char *term; + double value; + value = strtod (string, &term); + if (value != 69 || term != (string + 4)) + return 1; + } + + { + /* Under Solaris 2.4, strtod returns the wrong value for the + terminating character under some conditions. */ + char *string = "NaN"; + char *term; + strtod (string, &term); + if (term != string && *(term - 1) == 0) + return 1; + } + return 0; +} + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_strtod=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_strtod=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_strtod" >&5 +echo "${ECHO_T}$ac_cv_func_strtod" >&6; } +if test $ac_cv_func_strtod = no; then + case " $LIBOBJS " in + *" strtod.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strtod.$ac_objext" + ;; +esac + +{ echo "$as_me:$LINENO: checking for pow" >&5 +echo $ECHO_N "checking for pow... $ECHO_C" >&6; } +if test "${ac_cv_func_pow+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define pow to an innocuous variant, in case declares pow. + For example, HP-UX 11i declares gettimeofday. */ +#define pow innocuous_pow + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char pow (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef pow + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pow (); +/* 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_pow || defined __stub___pow +choke me +#endif + +int +main () +{ +return pow (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func_pow=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_pow=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_pow" >&5 +echo "${ECHO_T}$ac_cv_func_pow" >&6; } + +if test $ac_cv_func_pow = no; then + { echo "$as_me:$LINENO: checking for pow in -lm" >&5 +echo $ECHO_N "checking for pow in -lm... $ECHO_C" >&6; } +if test "${ac_cv_lib_m_pow+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pow (); +int +main () +{ +return pow (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_m_pow=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_m_pow=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_m_pow" >&5 +echo "${ECHO_T}$ac_cv_lib_m_pow" >&6; } +if test $ac_cv_lib_m_pow = yes; then + POW_LIB=-lm +else + { echo "$as_me:$LINENO: WARNING: cannot find library containing definition of pow" >&5 +echo "$as_me: WARNING: cannot find library containing definition of pow" >&2;} +fi + +fi + +fi + + +for ac_func in vprintf +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* 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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +{ echo "$as_me:$LINENO: checking for _doprnt" >&5 +echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6; } +if test "${ac_cv_func__doprnt+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define _doprnt to an innocuous variant, in case declares _doprnt. + For example, HP-UX 11i declares gettimeofday. */ +#define _doprnt innocuous__doprnt + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char _doprnt (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef _doprnt + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char _doprnt (); +/* 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__doprnt || defined __stub____doprnt +choke me +#endif + +int +main () +{ +return _doprnt (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func__doprnt=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func__doprnt=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 +echo "${ECHO_T}$ac_cv_func__doprnt" >&6; } +if test $ac_cv_func__doprnt = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DOPRNT 1 +_ACEOF + +fi + +fi +done + + + + +for ac_header in stdlib.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_func in getpagesize +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* 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 +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +{ echo "$as_me:$LINENO: checking for working mmap" >&5 +echo $ECHO_N "checking for working mmap... $ECHO_C" >&6; } +if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_mmap_fixed_mapped=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +/* malloc might have been renamed as rpl_malloc. */ +#undef malloc + +/* Thanks to Mike Haertel and Jim Avera for this test. + Here is a matrix of mmap possibilities: + mmap private not fixed + mmap private fixed at somewhere currently unmapped + mmap private fixed at somewhere already mapped + mmap shared not fixed + mmap shared fixed at somewhere currently unmapped + mmap shared fixed at somewhere already mapped + For private mappings, we should verify that changes cannot be read() + back from the file, nor mmap's back from the file at a different + address. (There have been systems where private was not correctly + implemented like the infamous i386 svr4.0, and systems where the + VM page cache was not coherent with the file system buffer cache + like early versions of FreeBSD and possibly contemporary NetBSD.) + For shared mappings, we should conversely verify that changes get + propagated back to all the places they're supposed to be. + + Grep wants private fixed already mapped. + The main things grep needs to know about mmap are: + * does it exist and is it safe to write into the mmap'd area + * how to use it (BSD variants) */ + +#include +#include + +#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H +char *malloc (); +#endif + +/* This mess was copied from the GNU getpagesize.h. */ +#ifndef HAVE_GETPAGESIZE +/* Assume that all systems that can run configure have sys/param.h. */ +# ifndef HAVE_SYS_PARAM_H +# define HAVE_SYS_PARAM_H 1 +# endif + +# ifdef _SC_PAGESIZE +# define getpagesize() sysconf(_SC_PAGESIZE) +# else /* no _SC_PAGESIZE */ +# ifdef HAVE_SYS_PARAM_H +# include +# ifdef EXEC_PAGESIZE +# define getpagesize() EXEC_PAGESIZE +# else /* no EXEC_PAGESIZE */ +# ifdef NBPG +# define getpagesize() NBPG * CLSIZE +# ifndef CLSIZE +# define CLSIZE 1 +# endif /* no CLSIZE */ +# else /* no NBPG */ +# ifdef NBPC +# define getpagesize() NBPC +# else /* no NBPC */ +# ifdef PAGESIZE +# define getpagesize() PAGESIZE +# endif /* PAGESIZE */ +# endif /* no NBPC */ +# endif /* no NBPG */ +# endif /* no EXEC_PAGESIZE */ +# else /* no HAVE_SYS_PARAM_H */ +# define getpagesize() 8192 /* punt totally */ +# endif /* no HAVE_SYS_PARAM_H */ +# endif /* no _SC_PAGESIZE */ + +#endif /* no HAVE_GETPAGESIZE */ + +int +main () +{ + char *data, *data2, *data3; + int i, pagesize; + int fd; + + pagesize = getpagesize (); + + /* First, make a file with some known garbage in it. */ + data = (char *) malloc (pagesize); + if (!data) + return 1; + for (i = 0; i < pagesize; ++i) + *(data + i) = rand (); + umask (0); + fd = creat ("conftest.mmap", 0600); + if (fd < 0) + return 1; + if (write (fd, data, pagesize) != pagesize) + return 1; + close (fd); + + /* Next, try to mmap the file at a fixed address which already has + something else allocated at it. If we can, also make sure that + we see the same garbage. */ + fd = open ("conftest.mmap", O_RDWR); + if (fd < 0) + return 1; + data2 = (char *) malloc (2 * pagesize); + if (!data2) + return 1; + data2 += (pagesize - ((long int) data2 & (pagesize - 1))) & (pagesize - 1); + if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_FIXED, fd, 0L)) + return 1; + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data2 + i)) + return 1; + + /* Finally, make sure that changes to the mapped area do not + percolate back to the file as seen by read(). (This is a bug on + some variants of i386 svr4.0.) */ + for (i = 0; i < pagesize; ++i) + *(data2 + i) = *(data2 + i) + 1; + data3 = (char *) malloc (pagesize); + if (!data3) + return 1; + if (read (fd, data3, pagesize) != pagesize) + return 1; + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data3 + i)) + return 1; + close (fd); + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_mmap_fixed_mapped=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_mmap_fixed_mapped=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_mmap_fixed_mapped" >&5 +echo "${ECHO_T}$ac_cv_func_mmap_fixed_mapped" >&6; } +if test $ac_cv_func_mmap_fixed_mapped = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_MMAP 1 +_ACEOF + +fi +rm -f conftest.mmap + +{ echo "$as_me:$LINENO: checking whether lstat dereferences a symlink specified with a trailing slash" >&5 +echo $ECHO_N "checking whether lstat dereferences a symlink specified with a trailing slash... $ECHO_C" >&6; } +if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + rm -f conftest.sym conftest.file +echo >conftest.file +if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then + if test "$cross_compiling" = yes; then + ac_cv_func_lstat_dereferences_slashed_symlink=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +struct stat sbuf; + /* Linux will dereference the symlink and fail. + That is better in the sense that it means we will not + have to compile and use the lstat wrapper. */ + return lstat ("conftest.sym/", &sbuf) == 0; + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_lstat_dereferences_slashed_symlink=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_lstat_dereferences_slashed_symlink=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +else + # If the `ln -s' command failed, then we probably don't even + # have an lstat function. + ac_cv_func_lstat_dereferences_slashed_symlink=no +fi +rm -f conftest.sym conftest.file + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 +echo "${ECHO_T}$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } + +test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && + +cat >>confdefs.h <<_ACEOF +#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 +_ACEOF + + +if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then + case " $LIBOBJS " in + *" lstat.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS lstat.$ac_objext" + ;; +esac + +fi + +{ echo "$as_me:$LINENO: checking whether stat accepts an empty string" >&5 +echo $ECHO_N "checking whether stat accepts an empty string... $ECHO_C" >&6; } +if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_stat_empty_string_bug=yes +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +struct stat sbuf; + return stat ("", &sbuf) == 0; + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_stat_empty_string_bug=no +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_stat_empty_string_bug=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_stat_empty_string_bug" >&5 +echo "${ECHO_T}$ac_cv_func_stat_empty_string_bug" >&6; } +if test $ac_cv_func_stat_empty_string_bug = yes; then + case " $LIBOBJS " in + *" stat.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS stat.$ac_objext" + ;; +esac + + +cat >>confdefs.h <<_ACEOF +#define HAVE_STAT_EMPTY_STRING_BUG 1 +_ACEOF + +fi + +if test $ac_cv_c_compiler_gnu = yes; then + { echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5 +echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6; } +if test "${ac_cv_prog_gcc_traditional+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_pattern="Autoconf.*'x'" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +Autoconf TIOCGETP +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then + ac_cv_prog_gcc_traditional=yes +else + ac_cv_prog_gcc_traditional=no +fi +rm -f conftest* + + + if test $ac_cv_prog_gcc_traditional = no; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +Autoconf TCGETA +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then + ac_cv_prog_gcc_traditional=yes +fi +rm -f conftest* + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5 +echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6; } + if test $ac_cv_prog_gcc_traditional = yes; then + CC="$CC -traditional" + fi +fi + + + +{ echo "$as_me:$LINENO: checking for OSS audio support" >&5 +echo $ECHO_N "checking for OSS audio support... $ECHO_C" >&6; } +if test x$enable_oss = xyes; then + have_oss=no + if test x$have_oss != xyes; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include + +int +main () +{ + + int arg = SNDCTL_DSP_SETFRAGMENT; + ++arg; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + + have_oss=yes + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test x$have_oss != xyes; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include + +int +main () +{ + + int arg = SNDCTL_DSP_SETFRAGMENT; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + + have_oss=yes + CFLAGS="$CFLAGS -DOSS_USE_SOUNDCARD_H" + CXXFLAGS="$CXXFLAGS -DOSS_USE_SOUNDCARD_H" + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi +fi + +# Check whether --enable-oss was given. +if test "${enable_oss+set}" = set; then + enableval=$enable_oss; +else + enable_oss=no +fi + +if test x$enable_oss = xyes; then + { echo "$as_me:$LINENO: result: $have_oss" >&5 +echo "${ECHO_T}$have_oss" >&6; } +else + have_oss=no + { echo "$as_me:$LINENO: result: Disabled" >&5 +echo "${ECHO_T}Disabled" >&6; } +fi + +if test x$have_oss = xyes; then + CFLAGS="$CFLAGS -DHAVE_OSS" + CXXFLAGS="$CXXFLAGS -DHAVE_OSS" +fi + + +if test "${ac_cv_header_sys_asoundlib_h+set}" = set; then + { echo "$as_me:$LINENO: checking for sys/asoundlib.h" >&5 +echo $ECHO_N "checking for sys/asoundlib.h... $ECHO_C" >&6; } +if test "${ac_cv_header_sys_asoundlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_asoundlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_sys_asoundlib_h" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking sys/asoundlib.h usability" >&5 +echo $ECHO_N "checking sys/asoundlib.h usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking sys/asoundlib.h presence" >&5 +echo $ECHO_N "checking sys/asoundlib.h presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: sys/asoundlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: sys/asoundlib.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: sys/asoundlib.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: sys/asoundlib.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: sys/asoundlib.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: sys/asoundlib.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: sys/asoundlib.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: sys/asoundlib.h: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for sys/asoundlib.h" >&5 +echo $ECHO_N "checking for sys/asoundlib.h... $ECHO_C" >&6; } +if test "${ac_cv_header_sys_asoundlib_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_sys_asoundlib_h=$ac_header_preproc +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_asoundlib_h" >&5 +echo "${ECHO_T}$ac_cv_header_sys_asoundlib_h" >&6; } + +fi +if test $ac_cv_header_sys_asoundlib_h = yes; then + have_alsa_hdr=yes +fi + + +{ echo "$as_me:$LINENO: checking for snd_pcm_open in -lasound" >&5 +echo $ECHO_N "checking for snd_pcm_open in -lasound... $ECHO_C" >&6; } +if test "${ac_cv_lib_asound_snd_pcm_open+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lasound $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char snd_pcm_open (); +int +main () +{ +return snd_pcm_open (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_asound_snd_pcm_open=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_asound_snd_pcm_open=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_asound_snd_pcm_open" >&5 +echo "${ECHO_T}$ac_cv_lib_asound_snd_pcm_open" >&6; } +if test $ac_cv_lib_asound_snd_pcm_open = yes; then + have_alsa_lib=yes +fi + +{ echo "$as_me:$LINENO: checking for ALSA audio support" >&5 +echo $ECHO_N "checking for ALSA audio support... $ECHO_C" >&6; } +have_alsa=no +if test x$have_alsa_hdr = xyes -a x$have_alsa_lib = xyes; then + have_alsa=yes +fi + +# Check whether --enable-alsa was given. +if test "${enable_alsa+set}" = set; then + enableval=$enable_alsa; +else + enable_alsa=no +fi + +if test x$enable_alsa = xyes; then + { echo "$as_me:$LINENO: result: $have_alsa" >&5 +echo "${ECHO_T}$have_alsa" >&6; } +else + have_alsa=no + { echo "$as_me:$LINENO: result: Disabled" >&5 +echo "${ECHO_T}Disabled" >&6; } +fi + +if test x$have_alsa = xyes; then + CFLAGS="$CFLAGS -DHAVE_ALSA" + CXXFLAGS="$CXXFLAGS -DHAVE_ALSA" + AUDIO_LIBS="-lasound" +else + AUDIO_LIBS="" +fi + + + +# Check whether --enable-epm was given. +if test "${enable_epm+set}" = set; then + enableval=$enable_epm; +else + enable_epm=no +fi + +{ echo "$as_me:$LINENO: checking for Extreme Pickyness Mode" >&5 +echo $ECHO_N "checking for Extreme Pickyness Mode... $ECHO_C" >&6; } +if test x$enable_epm = xyes; then + LOCALCFLAGS="$LOCALCFLAGS -Wall -Werror -Wwrite-strings -fno-builtin" +fi +{ echo "$as_me:$LINENO: result: $enable_epm" >&5 +echo "${ECHO_T}$enable_epm" >&6; } + + +# Check whether --enable-efence was given. +if test "${enable_efence+set}" = set; then + enableval=$enable_efence; +else + enable_efence=no +fi + +{ echo "$as_me:$LINENO: checking if we should use ElectricFence" >&5 +echo $ECHO_N "checking if we should use ElectricFence... $ECHO_C" >&6; } +if test x$enable_efence = xyes; then + LIBS="$LIBS -lefence" +fi +{ echo "$as_me:$LINENO: result: $enable_efence" >&5 +echo "${ECHO_T}$enable_efence" >&6; } + + + +ac_config_files="$ac_config_files Makefile Info.plist graphics/Makefile sound/Makefile data/Makefile data/sfx/Makefile data/gfx/Makefile eel/Makefile" + +cat >confcache <<\_ACEOF +# 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, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# 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. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${BUILD_MACOSX_BUNDLE_TRUE}" && test -z "${BUILD_MACOSX_BUNDLE_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"BUILD_MACOSX_BUNDLE\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"BUILD_MACOSX_BUNDLE\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${BUILD_SIMPLE_BUNDLE_TRUE}" && test -z "${BUILD_SIMPLE_BUNDLE_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"BUILD_SIMPLE_BUNDLE\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"BUILD_SIMPLE_BUNDLE\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${UNIX_SCOREDIR_TRUE}" && test -z "${UNIX_SCOREDIR_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"UNIX_SCOREDIR\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"UNIX_SCOREDIR\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 + +# Save the log message, to keep $[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by $as_me, which was +generated by GNU Autoconf 2.61. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2006 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + { echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "aconfig.h") CONFIG_HEADERS="$CONFIG_HEADERS aconfig.h" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "Info.plist") CONFIG_FILES="$CONFIG_FILES Info.plist" ;; + "graphics/Makefile") CONFIG_FILES="$CONFIG_FILES graphics/Makefile" ;; + "sound/Makefile") CONFIG_FILES="$CONFIG_FILES sound/Makefile" ;; + "data/Makefile") CONFIG_FILES="$CONFIG_FILES data/Makefile" ;; + "data/sfx/Makefile") CONFIG_FILES="$CONFIG_FILES data/sfx/Makefile" ;; + "data/gfx/Makefile") CONFIG_FILES="$CONFIG_FILES data/gfx/Makefile" ;; + "eel/Makefile") CONFIG_FILES="$CONFIG_FILES eel/Makefile" ;; + + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +# +# Set up the sed scripts for CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "$CONFIG_FILES"; then + +_ACEOF + + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +build!$build$ac_delim +build_cpu!$build_cpu$ac_delim +build_vendor!$build_vendor$ac_delim +build_os!$build_os$ac_delim +host!$host$ac_delim +host_cpu!$host_cpu$ac_delim +host_vendor!$host_vendor$ac_delim +host_os!$host_os$ac_delim +target!$target$ac_delim +target_cpu!$target_cpu$ac_delim +target_vendor!$target_vendor$ac_delim +target_os!$target_os$ac_delim +INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim +INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim +INSTALL_DATA!$INSTALL_DATA$ac_delim +CYGPATH_W!$CYGPATH_W$ac_delim +PACKAGE!$PACKAGE$ac_delim +VERSION!$VERSION$ac_delim +ACLOCAL!$ACLOCAL$ac_delim +AUTOCONF!$AUTOCONF$ac_delim +AUTOMAKE!$AUTOMAKE$ac_delim +AUTOHEADER!$AUTOHEADER$ac_delim +MAKEINFO!$MAKEINFO$ac_delim +install_sh!$install_sh$ac_delim +STRIP!$STRIP$ac_delim +INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim +mkdir_p!$mkdir_p$ac_delim +AWK!$AWK$ac_delim +SET_MAKE!$SET_MAKE$ac_delim +am__leading_dot!$am__leading_dot$ac_delim +AMTAR!$AMTAR$ac_delim +am__tar!$am__tar$ac_delim +am__untar!$am__untar$ac_delim +XMKMF!$XMKMF$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +DEPDIR!$DEPDIR$ac_delim +am__include!$am__include$ac_delim +am__quote!$am__quote$ac_delim +AMDEP_TRUE!$AMDEP_TRUE$ac_delim +AMDEP_FALSE!$AMDEP_FALSE$ac_delim +AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim +CCDEPMODE!$CCDEPMODE$ac_delim +am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim +am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim +CPP!$CPP$ac_delim +X_CFLAGS!$X_CFLAGS$ac_delim +X_PRE_LIBS!$X_PRE_LIBS$ac_delim +X_LIBS!$X_LIBS$ac_delim +X_EXTRA_LIBS!$X_EXTRA_LIBS$ac_delim +BUILD_MACOSX_BUNDLE_TRUE!$BUILD_MACOSX_BUNDLE_TRUE$ac_delim +BUILD_MACOSX_BUNDLE_FALSE!$BUILD_MACOSX_BUNDLE_FALSE$ac_delim +BUILD_SIMPLE_BUNDLE_TRUE!$BUILD_SIMPLE_BUNDLE_TRUE$ac_delim +BUILD_SIMPLE_BUNDLE_FALSE!$BUILD_SIMPLE_BUNDLE_FALSE$ac_delim +UNIX_SCOREDIR_TRUE!$UNIX_SCOREDIR_TRUE$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +_ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +CEOF$ac_eof +_ACEOF + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +UNIX_SCOREDIR_FALSE!$UNIX_SCOREDIR_FALSE$ac_delim +DATADIR!$DATADIR$ac_delim +SCOREDIR!$SCOREDIR$ac_delim +CONFIGDIR!$CONFIGDIR$ac_delim +CONFIGFILE!$CONFIGFILE$ac_delim +EXEFILE!$EXEFILE$ac_delim +MATHLIB!$MATHLIB$ac_delim +CXX!$CXX$ac_delim +CXXFLAGS!$CXXFLAGS$ac_delim +ac_ct_CXX!$ac_ct_CXX$ac_delim +CXXDEPMODE!$CXXDEPMODE$ac_delim +am__fastdepCXX_TRUE!$am__fastdepCXX_TRUE$ac_delim +am__fastdepCXX_FALSE!$am__fastdepCXX_FALSE$ac_delim +RANLIB!$RANLIB$ac_delim +SDL_CONFIG!$SDL_CONFIG$ac_delim +SDL_CFLAGS!$SDL_CFLAGS$ac_delim +SDL_LIBS!$SDL_LIBS$ac_delim +GREP!$GREP$ac_delim +EGREP!$EGREP$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +POW_LIB!$POW_LIB$ac_delim +AUDIO_LIBS!$AUDIO_LIBS$ac_delim +LOCALCFLAGS!$LOCALCFLAGS$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 24; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-2.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end +_ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof +_ACEOF + + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$ac_file_inputs $ac_f" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s&@configure_input@&$configure_input&;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; + esac + ;; + :H) + # + # CONFIG_HEADER + # +_ACEOF + +# Transform confdefs.h into a sed script `conftest.defines', that +# substitutes the proper values into config.h.in to produce config.h. +rm -f conftest.defines conftest.tail +# First, append a space to every undef/define line, to ease matching. +echo 's/$/ /' >conftest.defines +# Then, protect against being on the right side of a sed subst, or in +# an unquoted here document, in config.status. If some macros were +# called several times there might be several #defines for the same +# symbol, which is useless. But do not sort them, since the last +# AC_DEFINE must be honored. +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where +# NAME is the cpp macro being defined, VALUE is the value it is being given. +# PARAMS is the parameter list in the macro definition--in most cases, it's +# just an empty string. +ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' +ac_dB='\\)[ (].*,\\1define\\2' +ac_dC=' ' +ac_dD=' ,' + +uniq confdefs.h | + sed -n ' + t rset + :rset + s/^[ ]*#[ ]*define[ ][ ]*// + t ok + d + :ok + s/[\\&,]/\\&/g + s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p + s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p + ' >>conftest.defines + +# Remove the space that was appended to ease matching. +# Then replace #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. +# (The regexp can be short, since the line contains either #define or #undef.) +echo 's/ $// +s,^[ #]*u.*,/* & */,' >>conftest.defines + +# Break up conftest.defines: +ac_max_sed_lines=50 + +# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" +# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" +# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" +# et cetera. +ac_in='$ac_file_inputs' +ac_out='"$tmp/out1"' +ac_nxt='"$tmp/out2"' + +while : +do + # Write a here document: + cat >>$CONFIG_STATUS <<_ACEOF + # First, check the format of the line: + cat >"\$tmp/defines.sed" <<\\CEOF +/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def +/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def +b +:def +_ACEOF + sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS + ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in + sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail + grep . conftest.tail >/dev/null || break + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines conftest.tail + +echo "ac_result=$ac_in" >>$CONFIG_STATUS +cat >>$CONFIG_STATUS <<\_ACEOF + if test x"$ac_file" != x-; then + echo "/* $configure_input */" >"$tmp/config.h" + cat "$ac_result" >>"$tmp/config.h" + if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f $ac_file + mv "$tmp/config.h" $ac_file + fi + else + echo "/* $configure_input */" + cat "$ac_result" + fi + rm -f "$tmp/out12" +# Compute $ac_file's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $ac_file | $ac_file:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $ac_file" >`$as_dirname -- $ac_file || +$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X$ac_file : 'X\(//\)[^/]' \| \ + X$ac_file : 'X\(//\)$' \| \ + X$ac_file : 'X\(/\)' \| . 2>/dev/null || +echo X$ac_file | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { echo "$as_me:$LINENO: executing $ac_file commands" >&5 +echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir=$dirpart/$fdir + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + + esac +done # for ac_tag + + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..8558e9c --- /dev/null +++ b/configure.in @@ -0,0 +1,350 @@ +dnl Process this file with autoconf to produce a configure script. + +dnl---------------------------------------------------------- +dnl configure.in for Kobo Deluxe - David Olofson, 2001-2007 +dnl Some tests stolen from SDL (http://www.libsdl.org) +dnl---------------------------------------------------------- + +AC_INIT(Makefile.am) +AC_CONFIG_SRCDIR([Makefile.am]) +AM_CONFIG_HEADER(aconfig.h) +AC_CANONICAL_HOST +AC_CANONICAL_TARGET +AM_INIT_AUTOMAKE(KoboDeluxe, 0.5.1) + +dnl (For Extreme Pickyness Mode) +LOCALCFLAGS='' + + +dnl------------------------------------------------------- +dnl Look for X +dnl------------------------------------------------------- +dnl *MUST* be out here! Pretty much everything breaks on +dnl some targets if they're inside the case statement... +AC_PATH_X +AC_PATH_XTRA + + +dnl------------------------------------------------------- +dnl Detect target platform and build style +dnl------------------------------------------------------- +AC_MSG_CHECKING(target platform and install style); +build_macosx_bundle=no +build_simple_bundle=no +unix_scoredir=yes +DATADIR='$(datadir)/kobo-deluxe' +SCOREDIR='$(sharedstatedir)/kobo-deluxe/scores' +CONFIGDIR='HOME>>' +CONFIGFILE='.kobodlrc' +EXEFILE=kobodl +case "$target_os" in + linux*) + AC_MSG_RESULT(GNU/Linux; Un*x style) + MATHLIB="-lm" + if test x$have_x = xyes; then + CFLAGS="$CFLAGS $X_CFLAGS" + fi + ;; + beos) + AC_MSG_RESULT(BeOS; Un*x style install) + MATHLIB="" + ;; + mingw32*) + AC_MSG_RESULT(Win32 (mingw32); Simple bundle) + build_simple_bundle=yes + unix_scoredir=no + DATADIR='EXE>>' + SCOREDIR='EXE>>scores' + CONFIGDIR='EXE>>' + CONFIGFILE='kobodl.cfg' + EXEFILE=kobodl.exe + MATHLIB="" + ;; + cygwin*) + AC_MSG_RESULT(Win32 (cygwin); Simple bundle) + build_simple_bundle=yes + unix_scoredir=no + DATADIR='EXE>>' + SCOREDIR='EXE>>scores' + CONFIGDIR='EXE>>' + CONFIGFILE='kobodl.cfg' + EXEFILE=kobodl.exe + MATHLIB="" + ;; + darwin*) + AC_MSG_RESULT(Mac OS X/Darwin; Mac OS X bundle) + build_macosx_bundle=yes + DATADIR='EXE>>../Resources' + SCOREDIR='/Library/Preferences/KoboDeluxe/scores' + CONFIGDIR='HOME>>Library/Preferences' + CONFIGFILE='KoboDeluxe Preferences' + MATHLIB="" + ;; + aix*) + AC_MSG_RESULT(AIX; Un*x style) + if test x$ac_cv_c_compiler_gnu = xyes; then + CFLAGS="-mthreads" + fi + if test x$have_x = xyes; then + CFLAGS="$CFLAGS $X_CFLAGS" + fi + ;; + solaris*) + AC_MSG_RESULT(Solaris SPARC; Un*x style) + MATHLIB="-lm" + CFLAGS="$CFLAGS $X_CFLAGS" + ;; + *) + AC_MSG_RESULT(Unknown (assuming Un*x-like); Un*x style) + MATHLIB="-lm" + if test x$have_x = xyes; then + CFLAGS="$CFLAGS $X_CFLAGS" + fi + ;; +esac +AM_CONDITIONAL(BUILD_MACOSX_BUNDLE, test x$build_macosx_bundle = xyes) +AM_CONDITIONAL(BUILD_SIMPLE_BUNDLE, test x$build_simple_bundle = xyes) +AM_CONDITIONAL(UNIX_SCOREDIR, test x$unix_scoredir = xyes) +AC_SUBST(DATADIR) +AC_SUBST(SCOREDIR) +AC_SUBST(CONFIGDIR) +AC_SUBST(CONFIGFILE) +AC_SUBST(EXEFILE) +AC_SUBST(MATHLIB) + + +dnl------------------------------------------------------- +dnl Checks for debug mode +dnl------------------------------------------------------- +AC_ARG_ENABLE(debug, +[ --enable-debug Build with debug switches and defines [default=no]], + , enable_debug=no) +AC_MSG_CHECKING(for debug build) +if test x$enable_debug = xyes; then + CFLAGS="$CFLAGS -g -DDEBUG" + CXXFLAGS="$CXXFLAGS -g -DDEBUG" +fi +AC_MSG_RESULT($enable_debug) + + +dnl------------------------------------------------------- +dnl Checks for programs. +dnl------------------------------------------------------- +AC_PROG_CC +AC_PROG_CXX +AC_PROG_INSTALL +AC_PROG_AWK +AC_PROG_RANLIB + + +dnl------------------------------------------------------- +dnl Checks for SDL +dnl------------------------------------------------------- +SDL_VERSION=1.2.0 +AM_PATH_SDL($SDL_VERSION,:, + AC_MSG_ERROR([*** SDL version $SDL_VERSION required!]) +) +CFLAGS="$CFLAGS $SDL_CFLAGS" +CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" +LIBS="$LIBS $SDL_LIBS" + + +dnl------------------------------------------------------- +dnl Checks for SDL_image +dnl------------------------------------------------------- +AC_CHECK_LIB(SDL_image, IMG_Load,, + AC_MSG_ERROR([You need the SDL_image library to compile this software. + Get it at http://www.libsdl.org/projects/SDL_image/]), + -lSDL +) +LIBS="$LIBS -lSDL_image" + + +dnl------------------------------------------------------- +dnl Checks for OpenGL +dnl------------------------------------------------------- +AC_MSG_CHECKING(for OpenGL support) +have_opengl=no +AC_TRY_COMPILE([ + #if defined(__APPLE__) && defined(__MACH__) + #include + #else + #include + #endif +],[ +],[ +have_opengl=yes +]) + +AC_ARG_ENABLE(opengl, +[ --enable-opengl use OpenGL rendering layer [default=yes]], + , enable_opengl=yes) +if test x$enable_opengl = xyes; then + AC_MSG_RESULT($have_opengl) +else + have_opengl=no + AC_MSG_RESULT(Disabled) +fi + +if test x$have_opengl = xyes; then + CFLAGS="$CFLAGS -DHAVE_OPENGL" + CXXFLAGS="$CXXFLAGS -DHAVE_OPENGL" +fi + + +dnl------------------------------------------------------- +dnl Checks for header files. +dnl------------------------------------------------------- +AC_HEADER_DIRENT +AC_HEADER_STDC +AC_HEADER_TIME +AC_CHECK_HEADERS(errno.h fcntl.h stdlib.h string.h) +AC_CHECK_HEADERS(sys/ioctl.h sys/time.h unistd.h) +AC_CHECK_HEADERS(SDL/SDL_opengl.h) + + +dnl------------------------------------------------------- +dnl Checks for typedefs, structures, and compiler characteristics. +dnl------------------------------------------------------- +AC_C_CONST +AC_C_INLINE +AC_TYPE_SIGNAL + + +dnl------------------------------------------------------- +dnl Checks for library functions. +dnl------------------------------------------------------- +AC_CHECK_FUNCS(strdup strstr strchr strrchr) +AC_CHECK_FUNCS(snprintf _snprintf vsnprintf _vsnprintf) +AC_CHECK_FUNCS(pow sqrt) +AC_CHECK_FUNCS(munmap mkdir select stat) +AC_CHECK_FUNCS(atexit floor memmove memset memcmp) +AC_CHECK_FUNCS(gettimeofday) +AC_CHECK_FUNCS(getegid setgid) +AC_FUNC_MEMCMP +AC_FUNC_STRTOD +AC_FUNC_VPRINTF +AC_FUNC_MMAP +dnl AC_FUNC_MALLOC +AC_FUNC_STAT +AC_PROG_GCC_TRADITIONAL + + +dnl------------------------------------------------------- +dnl See if the OSS audio interface is supported (from SDL) +dnl------------------------------------------------------- +AC_MSG_CHECKING(for OSS audio support) +if test x$enable_oss = xyes; then + have_oss=no + if test x$have_oss != xyes; then + AC_TRY_COMPILE([ + #include + ],[ + int arg = SNDCTL_DSP_SETFRAGMENT; + ++arg; + ],[ + have_oss=yes + ]) + fi + if test x$have_oss != xyes; then + AC_TRY_COMPILE([ + #include + ],[ + int arg = SNDCTL_DSP_SETFRAGMENT; + ],[ + have_oss=yes + CFLAGS="$CFLAGS -DOSS_USE_SOUNDCARD_H" + CXXFLAGS="$CXXFLAGS -DOSS_USE_SOUNDCARD_H" + ]) + fi +fi + +AC_ARG_ENABLE(oss, +[ --enable-oss support the OSS audio API [default=no]], + , enable_oss=no) +if test x$enable_oss = xyes; then + AC_MSG_RESULT($have_oss) +else + have_oss=no + AC_MSG_RESULT(Disabled) +fi + +if test x$have_oss = xyes; then + CFLAGS="$CFLAGS -DHAVE_OSS" + CXXFLAGS="$CXXFLAGS -DHAVE_OSS" +fi + + +dnl------------------------------------------------------- +dnl See if the ALSA audio interface is supported (from SDL) +dnl------------------------------------------------------- +AC_CHECK_HEADER(sys/asoundlib.h, have_alsa_hdr=yes) +AC_CHECK_LIB(asound, snd_pcm_open, have_alsa_lib=yes) +AC_MSG_CHECKING(for ALSA audio support) +have_alsa=no +if test x$have_alsa_hdr = xyes -a x$have_alsa_lib = xyes; then + have_alsa=yes +fi + +AC_ARG_ENABLE(alsa, +[ --enable-alsa support the ALSA audio API [default=no]], + , enable_alsa=no) +if test x$enable_alsa = xyes; then + AC_MSG_RESULT($have_alsa) +else + have_alsa=no + AC_MSG_RESULT(Disabled) +fi + +if test x$have_alsa = xyes; then + CFLAGS="$CFLAGS -DHAVE_ALSA" + CXXFLAGS="$CXXFLAGS -DHAVE_ALSA" + AUDIO_LIBS="-lasound" +else + AUDIO_LIBS="" +fi +AC_SUBST(AUDIO_LIBS) + + +dnl------------------------------------------------------- +dnl Checks for Extreme Pickyness Mode +dnl We have to put this here, as throwing -Werror +dnl into C(XX)FLAGS will cause lots of autoconf +dnl tests to fail on some systems. +dnl------------------------------------------------------- +AC_ARG_ENABLE(epm, +[ --enable-epm Compile with extremely picky settings [default=no]], + , enable_epm=no) +AC_MSG_CHECKING(for Extreme Pickyness Mode) +if test x$enable_epm = xyes; then + LOCALCFLAGS="$LOCALCFLAGS -Wall -Werror -Wwrite-strings -fno-builtin" +fi +AC_MSG_RESULT($enable_epm) +AC_SUBST(LOCALCFLAGS) + +dnl------------------------------------------------------- +dnl Check if we should use ElectricFence +dnl------------------------------------------------------- +AC_ARG_ENABLE(efence, +[ --enable-efence Link with ElectricFence [default=no]], + , enable_efence=no) +AC_MSG_CHECKING(if we should use ElectricFence) +if test x$enable_efence = xyes; then + LIBS="$LIBS -lefence" +fi +AC_MSG_RESULT($enable_efence) +AC_SUBST(LOCALCFLAGS) + + +dnl------------------------------------------------------- +dnl Generate output files +dnl------------------------------------------------------- +AC_OUTPUT([Makefile +Info.plist +graphics/Makefile +sound/Makefile +data/Makefile +data/sfx/Makefile +data/gfx/Makefile +eel/Makefile +]) diff --git a/dashboard.cpp b/dashboard.cpp new file mode 100644 index 0000000..385b61f --- /dev/null +++ b/dashboard.cpp @@ -0,0 +1,452 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 2003, 2007 David Olofson + * + * 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. + */ + +#include "config.h" +#include "kobo.h" +#include "random.h" +#include +#include + +#define MAX_PROGRESS 1000 + + +/*---------------------------------------------------------- + Screen +----------------------------------------------------------*/ + +void screen_window_t::border(int top, int left, int right, int bottom) +{ + _top = top; + _left = left; + _right = right; + _bottom = bottom; +} + + +void screen_window_t::refresh(SDL_Rect *r) +{ + int x, y, w, h; + foreground(map_rgb(0x000000)); + x = 0; + y = 0; + w = width(); + h = _top; + fillrect(x, y, w, h); + + y = height() - _bottom; + h = _bottom; + fillrect(x, y, w, h); + + y = _top; + w = _left; + h = height() - _top - _bottom; + fillrect(x, y, w, h); + + x = width() - _right; + w = _right; + fillrect(x, y, w, h); +} + + +/*---------------------------------------------------------- + Dashboard +----------------------------------------------------------*/ + +dashboard_window_t::dashboard_window_t() +{ + _mode = DASHBOARD_BLACK; + _percent = 0.0f; + _msg = NULL; +} + + +dashboard_window_t::~dashboard_window_t() +{ + free(_msg); +} + + +void dashboard_window_t::mode(dashboard_modes_t m) +{ + int vis; + _mode = m; + switch(_mode) + { + case DASHBOARD_GAME: + vis = 1; + break; + default: + vis = 0; + break; + } + wmain->visible(vis); + whealth->visible(vis); + wtemp->visible(vis); + wttemp->visible(vis); + wradar->visible(vis); + dhigh->visible(vis); + dscore->visible(vis); + dstage->visible(vis); + dships->visible(vis); + switch(_mode) + { + case DASHBOARD_OFF: + break; + default: + gengine->invalidate(); + gengine->flip(); + gengine->invalidate(); + gengine->flip(); + gengine->invalidate(); + break; + } +} + + +void dashboard_window_t::doing(const char *msg) +{ + free(_msg); + _msg = strdup(msg); + invalidate(); + gengine->flip(); +} + + +void dashboard_window_t::progress_init(float *progtab) +{ + if(!progtab) + { + progress_table = (float *)malloc(MAX_PROGRESS * sizeof(float)); + progress_bench = (progress_table != NULL); + } + else + { + progress_table = progtab; + progress_bench = 0; + } + progress_index = 0; +} + + +void dashboard_window_t::progress() +{ + if(progress_table) + { + if(progress_bench) + { + progress_table[progress_index++] = (float)SDL_GetTicks(); + _percent = 0.0f; + } + else + _percent = progress_table[progress_index++]; + } + else + _percent = 50.0f; + invalidate(); + gengine->flip(); +} + + +void dashboard_window_t::progress_done() +{ + if(progress_bench) + { + int i; + int total = SDL_GetTicks() - (int)progress_table[0]; + printf("Progress percentages:\n"); + printf("---------------------\n"); + for(i = 0; i < progress_index; ++i) + printf("\t%f,\n", (progress_table[i] - + progress_table[0]) * 100.0f / total); + printf("---------------------\n"); + free(progress_table); + progress_bench = 0; + } + progress_table = NULL; +} + + +void dashboard_window_t::render_progress() +{ + SDL_Rect r; + int x, y, w, h; + + x = 0; + w = (int)(_percent * 0.01f * width() + 0.5f); + if(w < 4) + w = 4; + else if(w > width()) + w = width(); + + h = 16; + y = height() - h; + + r.x = x; + r.y = y; + r.w = w; + r.h = h; + + foreground(map_rgb(0x000099)); + rectangle(x, y, w, h); + + ++x; + ++y; + w -= 2; + h -= 2; + foreground(map_rgb(0x0000cc)); + rectangle(x, y, w, h); + + ++x; + ++y; + w -= 2; + h -= 2; + foreground(map_rgb(0x0000ff)); + fillrect(x, y, w, h); + + r.x = 0; + r.y = height() - 40; + r.w = width(); + r.h = 12; + foreground(map_rgb(0x000000)); + fillrect(r.x, r.y, r.w, r.h); + if(_msg) + { + font(B_NORMAL_FONT); + center(height() - 40, _msg); + } +} + + +#define NIBBLE_W 4 +#define NIBBLE_H 4 +#define NIBBLE_TILES ((SCREEN_WIDTH/NIBBLE_W+1)*(SCREEN_HEIGHT/NIBBLE_H+1)) + +void dashboard_window_t::nibble(int tool) +{ + int i; + int x[NIBBLE_TILES]; + int y[NIBBLE_TILES]; + + mode(DASHBOARD_OFF); + + if(tool < 0) + tool = (pubrand.get(20) + SDL_GetTicks()) % 5; + + /* Clear */ + for(i = 0; i < NIBBLE_TILES; ++i) + x[i] = y[i] = -1; + + /* Fill in */ + int ind = 0; + int xx = -NIBBLE_W / 2; + int yy = -NIBBLE_H / 2; + for(i = 0; i < NIBBLE_TILES; ++i) + { + ind = pubrand.get() % NIBBLE_TILES; + if(ind >= NIBBLE_TILES) + ind = 0; + while(x[ind] != -1) + if(++ind >= NIBBLE_TILES) + ind = 0; + x[ind] = xx; + y[ind] = yy; + xx += NIBBLE_W; + if(xx >= SCREEN_WIDTH + NIBBLE_W / 2) + { + xx = -NIBBLE_W / 2; + yy += NIBBLE_H; + } + } + + /* Clear 8000 tiles/second, until all are done. */ + foreground(map_rgb(0x000000)); + ind = 0; + int last_index; + int t = SDL_GetTicks(); + while(ind < NIBBLE_TILES) + { + int nt = SDL_GetTicks(); + int dt = nt - t; + t = nt; + last_index = ind; /* For double buffer mode */ + for(i = 0; i < dt * 8; ++i) + { + if(ind >= NIBBLE_TILES) + break; + switch (tool) + { + case 0: + fillrect(x[ind] + NIBBLE_W / 2, + y[ind] + NIBBLE_H / 2, + NIBBLE_W, NIBBLE_H); + break; + default: + sprite(x[ind] - 8 + NIBBLE_W / 2, + y[ind] - 8 + + NIBBLE_H / 2, B_BRUSHES, + tool - 1); + break; + } + ++ind; + } + gengine->invalidate(); + gengine->flip(); + if(gengine->doublebuffer()) + { + for(i = 0; i < dt * 4; ++i) + { + if(last_index >= NIBBLE_TILES) + break; + switch (tool) + { + case 0: + fillrect(x[last_index] + + NIBBLE_W / 2, + y[last_index] + + NIBBLE_H / 2, + NIBBLE_W, + NIBBLE_H); + break; + default: + sprite(x[last_index] - 8 + + NIBBLE_W / 2, + y[last_index] - 8 + + NIBBLE_H / 2, + B_BRUSHES, + tool - 1); + break; + } + ++last_index; + } + } + } + mode(DASHBOARD_BLACK); + gengine->flip(); +} + + +void dashboard_window_t::refresh(SDL_Rect *r) +{ + switch(_mode) + { + case DASHBOARD_OFF: + break; + case DASHBOARD_BLACK: + background(map_rgb(0x000000)); + clear(); + break; + case DASHBOARD_GAME: + sprite(0, 0, B_SCREEN, 0); + break; + case DASHBOARD_LOADING: + background(map_rgb(0x000000)); + clear(); + sprite((width() - 250) / 2, 55, B_LOADING, 0); + render_progress(); + break; + } +} + + +/*---------------------------------------------------------- + Bar graph display +----------------------------------------------------------*/ + +bargraph_t::bargraph_t() +{ + _value = 0.0f; + _redmax = 1; + _y = -1000; + _enabled = 1; +} + + +void bargraph_t::value(float val) +{ + if(val < 0.0f) + _value = 0.0f; + else + _value = val; + if(!_enabled) + return; + int y = (int)((height() - 2) * _value); + if(y != _y) + invalidate(); +} + + +void bargraph_t::enable(int ena) +{ + _enabled = ena; + invalidate(); +} + + +void bargraph_t::refresh(SDL_Rect *r) +{ + if(!_enabled) + { + clear(); + return; + } + float v = _value; + int red, green, blue; + if(v > 1.0f) + { + blue = 50 + (v - 1.0f) * 512; + if(_redmax) + { + red = 255; + green = blue / 2; + } + else + { + green = 255; + red = blue / 2; + } + v = 1.0f; + } + else + { + if(_redmax) + { + red = (int)(v * 300.0); + green = (int)((1.0 - v) * 400.0); + } + else + { + red = (int)((1.0 - v) * 300.0); + green = (int)(v * 400.0); + } + blue = 50; + } + if(green > 180) + green = 180; + if(red > 230) + red = 230; + if(blue > 255) + blue = 255; + _y = (int)((height() - 2) * (1.0f - v)); + foreground(bgcolor); + fillrect(0, 0, width(), height()); + foreground(map_rgb(red, green, blue)); + fillrect(1, _y + 1, width() - 2, height() - _y - 2); +} diff --git a/dashboard.h b/dashboard.h new file mode 100644 index 0000000..01003d5 --- /dev/null +++ b/dashboard.h @@ -0,0 +1,98 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 2003, 2007 David Olofson + * + * 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. + */ + +#ifndef KOBO_DASHBOARD_H +#define KOBO_DASHBOARD_H + +#include "window.h" + + +/* "Screen" window; takes care of the border, if any. */ +class screen_window_t : public window_t +{ + int _top, _left, _right, _bottom; + public: + void border(int top, int left, int right, int bottom); + void refresh(SDL_Rect *r); +}; + + +enum dashboard_modes_t { + DASHBOARD_OFF = 0, + DASHBOARD_BLACK, + DASHBOARD_GAME, + DASHBOARD_LOADING +}; + +/* Dashboard window; dashboard or loading screen. */ +class dashboard_window_t : public window_t +{ + char *_msg; + float _percent; + dashboard_modes_t _mode; + int progress_index; + float *progress_table; + Uint32 progress_time; + int progress_bench; + void render_progress(); + public: + dashboard_window_t(); + ~dashboard_window_t(); + void mode(dashboard_modes_t m); + void doing(const char *msg); + void progress_init(float *progtab); + void progress(); + void progress_done(); + /* + * Tools: + * -1: Random tool + * 0: Black 4x4 square + * 1+: Brushes from "brushes.png"; + * 1: Soft black 16 pixel round brush + * 2: (4/8)x4 tilable romboid brush + * 3: Tilable garbage brush + * 4: Vertical "D" brush + */ + void nibble(int tool = -1); + void refresh(SDL_Rect *r); +}; + + +/* Bar graph display */ +class bargraph_t : public window_t +{ + float _value; + int _redmax; + int _y; + int _enabled; + public: + bargraph_t(); + void value(float val); + void refresh(SDL_Rect *r); + void redmax(int rm) + { + _redmax = rm; + } + void enable(int ena); +}; + + +#endif /* KOBO_DASHBOARD_H */ diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 0000000..6727a7d --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1,9 @@ +if UNIX_SCOREDIR +koboscoredir = @SCOREDIR@ +koboscore_DATA = +else +koboscoredir = $(srcdir)/../@PACKAGE@/scores +koboscore_DATA = +endif + +SUBDIRS = sfx gfx diff --git a/data/Makefile.in b/data/Makefile.in new file mode 100644 index 0000000..aaf9b49 --- /dev/null +++ b/data/Makefile.in @@ -0,0 +1,515 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = data +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/aconfig.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(koboscoredir)" +koboscoreDATA_INSTALL = $(INSTALL_DATA) +DATA = $(koboscore_DATA) +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUDIO_LIBS = @AUDIO_LIBS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_MACOSX_BUNDLE_FALSE = @BUILD_MACOSX_BUNDLE_FALSE@ +BUILD_MACOSX_BUNDLE_TRUE = @BUILD_MACOSX_BUNDLE_TRUE@ +BUILD_SIMPLE_BUNDLE_FALSE = @BUILD_SIMPLE_BUNDLE_FALSE@ +BUILD_SIMPLE_BUNDLE_TRUE = @BUILD_SIMPLE_BUNDLE_TRUE@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONFIGDIR = @CONFIGDIR@ +CONFIGFILE = @CONFIGFILE@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXEFILE = @EXEFILE@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LOCALCFLAGS = @LOCALCFLAGS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MATHLIB = @MATHLIB@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POW_LIB = @POW_LIB@ +RANLIB = @RANLIB@ +SCOREDIR = @SCOREDIR@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +UNIX_SCOREDIR_FALSE = @UNIX_SCOREDIR_FALSE@ +UNIX_SCOREDIR_TRUE = @UNIX_SCOREDIR_TRUE@ +VERSION = @VERSION@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +@UNIX_SCOREDIR_FALSE@koboscoredir = $(srcdir)/../@PACKAGE@/scores +@UNIX_SCOREDIR_TRUE@koboscoredir = @SCOREDIR@ +@UNIX_SCOREDIR_FALSE@koboscore_DATA = +@UNIX_SCOREDIR_TRUE@koboscore_DATA = +SUBDIRS = sfx gfx +all: all-recursive + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign data/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign data/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +uninstall-info-am: +install-koboscoreDATA: $(koboscore_DATA) + @$(NORMAL_INSTALL) + test -z "$(koboscoredir)" || $(mkdir_p) "$(DESTDIR)$(koboscoredir)" + @list='$(koboscore_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(koboscoreDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(koboscoredir)/$$f'"; \ + $(koboscoreDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(koboscoredir)/$$f"; \ + done + +uninstall-koboscoreDATA: + @$(NORMAL_UNINSTALL) + @list='$(koboscore_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(koboscoredir)/$$f'"; \ + rm -f "$(DESTDIR)$(koboscoredir)/$$f"; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(DATA) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(koboscoredir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-recursive + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: install-koboscoreDATA + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-info-am uninstall-koboscoreDATA + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ + clean clean-generic clean-recursive ctags ctags-recursive \ + distclean distclean-generic distclean-recursive distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am \ + install-koboscoreDATA install-man install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive \ + mostlyclean mostlyclean-generic mostlyclean-recursive pdf \ + pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ + uninstall-info-am uninstall-koboscoreDATA + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/data/gfx/Makefile.am b/data/gfx/Makefile.am new file mode 100644 index 0000000..a7ec9b0 --- /dev/null +++ b/data/gfx/Makefile.am @@ -0,0 +1,17 @@ +KOBOGFX_OBJECTS = *.png + +if BUILD_MACOSX_BUNDLE +kobogfxdir = $(srcdir)/../@PACKAGE@.app/Contents/Resources/gfx +else + +if BUILD_SIMPLE_BUNDLE +kobogfxdir = $(srcdir)/../@PACKAGE@/gfx +else +kobogfxdir = $(datadir)/kobo-deluxe/gfx +endif + +endif + +kobogfx_DATA = $(KOBOGFX_OBJECTS) + +EXTRA_DIST = $(KOBOGFX_OBJECTS) diff --git a/data/gfx/Makefile.in b/data/gfx/Makefile.in new file mode 100644 index 0000000..a8b3fe8 --- /dev/null +++ b/data/gfx/Makefile.in @@ -0,0 +1,360 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = data/gfx +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/aconfig.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(kobogfxdir)" +kobogfxDATA_INSTALL = $(INSTALL_DATA) +DATA = $(kobogfx_DATA) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUDIO_LIBS = @AUDIO_LIBS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_MACOSX_BUNDLE_FALSE = @BUILD_MACOSX_BUNDLE_FALSE@ +BUILD_MACOSX_BUNDLE_TRUE = @BUILD_MACOSX_BUNDLE_TRUE@ +BUILD_SIMPLE_BUNDLE_FALSE = @BUILD_SIMPLE_BUNDLE_FALSE@ +BUILD_SIMPLE_BUNDLE_TRUE = @BUILD_SIMPLE_BUNDLE_TRUE@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONFIGDIR = @CONFIGDIR@ +CONFIGFILE = @CONFIGFILE@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXEFILE = @EXEFILE@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LOCALCFLAGS = @LOCALCFLAGS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MATHLIB = @MATHLIB@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POW_LIB = @POW_LIB@ +RANLIB = @RANLIB@ +SCOREDIR = @SCOREDIR@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +UNIX_SCOREDIR_FALSE = @UNIX_SCOREDIR_FALSE@ +UNIX_SCOREDIR_TRUE = @UNIX_SCOREDIR_TRUE@ +VERSION = @VERSION@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +KOBOGFX_OBJECTS = *.png +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_FALSE@kobogfxdir = $(datadir)/kobo-deluxe/gfx +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@kobogfxdir = $(srcdir)/../@PACKAGE@/gfx +@BUILD_MACOSX_BUNDLE_TRUE@kobogfxdir = $(srcdir)/../@PACKAGE@.app/Contents/Resources/gfx +kobogfx_DATA = $(KOBOGFX_OBJECTS) +EXTRA_DIST = $(KOBOGFX_OBJECTS) +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign data/gfx/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign data/gfx/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +uninstall-info-am: +install-kobogfxDATA: $(kobogfx_DATA) + @$(NORMAL_INSTALL) + test -z "$(kobogfxdir)" || $(mkdir_p) "$(DESTDIR)$(kobogfxdir)" + @list='$(kobogfx_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(kobogfxDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(kobogfxdir)/$$f'"; \ + $(kobogfxDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(kobogfxdir)/$$f"; \ + done + +uninstall-kobogfxDATA: + @$(NORMAL_UNINSTALL) + @list='$(kobogfx_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(kobogfxdir)/$$f'"; \ + rm -f "$(DESTDIR)$(kobogfxdir)/$$f"; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(DATA) +installdirs: + for dir in "$(DESTDIR)$(kobogfxdir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-kobogfxDATA + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am uninstall-kobogfxDATA + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am \ + install-kobogfxDATA install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am uninstall uninstall-am uninstall-info-am \ + uninstall-kobogfxDATA + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/data/gfx/bigfont3.png b/data/gfx/bigfont3.png new file mode 100644 index 0000000..08e8274 Binary files /dev/null and b/data/gfx/bigfont3.png differ diff --git a/data/gfx/bigship.png b/data/gfx/bigship.png new file mode 100644 index 0000000..ada494a Binary files /dev/null and b/data/gfx/bigship.png differ diff --git a/data/gfx/bmr-green.png b/data/gfx/bmr-green.png new file mode 100644 index 0000000..b9eeda3 Binary files /dev/null and b/data/gfx/bmr-green.png differ diff --git a/data/gfx/bmr-pink.png b/data/gfx/bmr-pink.png new file mode 100644 index 0000000..5f4ddc8 Binary files /dev/null and b/data/gfx/bmr-pink.png differ diff --git a/data/gfx/bmr-purple.png b/data/gfx/bmr-purple.png new file mode 100644 index 0000000..23ed88f Binary files /dev/null and b/data/gfx/bmr-purple.png differ diff --git a/data/gfx/bolt.png b/data/gfx/bolt.png new file mode 100644 index 0000000..d3ca78a Binary files /dev/null and b/data/gfx/bolt.png differ diff --git a/data/gfx/boltexpl.png b/data/gfx/boltexpl.png new file mode 100644 index 0000000..2ec4a06 Binary files /dev/null and b/data/gfx/boltexpl.png differ diff --git a/data/gfx/bomb.png b/data/gfx/bomb.png new file mode 100644 index 0000000..cb65d7f Binary files /dev/null and b/data/gfx/bomb.png differ diff --git a/data/gfx/bombdeto.png b/data/gfx/bombdeto.png new file mode 100644 index 0000000..bb97382 Binary files /dev/null and b/data/gfx/bombdeto.png differ diff --git a/data/gfx/brushes.png b/data/gfx/brushes.png new file mode 100644 index 0000000..92497e9 Binary files /dev/null and b/data/gfx/brushes.png differ diff --git a/data/gfx/bullet5b.png b/data/gfx/bullet5b.png new file mode 100644 index 0000000..33f16dc Binary files /dev/null and b/data/gfx/bullet5b.png differ diff --git a/data/gfx/bulletexpl2.png b/data/gfx/bulletexpl2.png new file mode 100644 index 0000000..5a9b3d2 Binary files /dev/null and b/data/gfx/bulletexpl2.png differ diff --git a/data/gfx/counterfont.png b/data/gfx/counterfont.png new file mode 100644 index 0000000..ddb3571 Binary files /dev/null and b/data/gfx/counterfont.png differ diff --git a/data/gfx/crosshair.png b/data/gfx/crosshair.png new file mode 100644 index 0000000..2a1ab1f Binary files /dev/null and b/data/gfx/crosshair.png differ diff --git a/data/gfx/deluxe.png b/data/gfx/deluxe.png new file mode 100644 index 0000000..6c7141c Binary files /dev/null and b/data/gfx/deluxe.png differ diff --git a/data/gfx/explo1e.png b/data/gfx/explo1e.png new file mode 100644 index 0000000..9e68a5e Binary files /dev/null and b/data/gfx/explo1e.png differ diff --git a/data/gfx/explo3e.png b/data/gfx/explo3e.png new file mode 100644 index 0000000..02a2418 Binary files /dev/null and b/data/gfx/explo3e.png differ diff --git a/data/gfx/explo4e.png b/data/gfx/explo4e.png new file mode 100644 index 0000000..dd09db2 Binary files /dev/null and b/data/gfx/explo4e.png differ diff --git a/data/gfx/explo5e.png b/data/gfx/explo5e.png new file mode 100644 index 0000000..835a6fa Binary files /dev/null and b/data/gfx/explo5e.png differ diff --git a/data/gfx/fighter.png b/data/gfx/fighter.png new file mode 100644 index 0000000..136a872 Binary files /dev/null and b/data/gfx/fighter.png differ diff --git a/data/gfx/flatstars1.png b/data/gfx/flatstars1.png new file mode 100644 index 0000000..be81036 Binary files /dev/null and b/data/gfx/flatstars1.png differ diff --git a/data/gfx/focusfx.png b/data/gfx/focusfx.png new file mode 100644 index 0000000..d1c08a0 Binary files /dev/null and b/data/gfx/focusfx.png differ diff --git a/data/gfx/goldfont.png b/data/gfx/goldfont.png new file mode 100644 index 0000000..d1ba963 Binary files /dev/null and b/data/gfx/goldfont.png differ diff --git a/data/gfx/hitnoise.png b/data/gfx/hitnoise.png new file mode 100644 index 0000000..fd32b3a Binary files /dev/null and b/data/gfx/hitnoise.png differ diff --git a/data/gfx/icefont2.png b/data/gfx/icefont2.png new file mode 100644 index 0000000..05e4c0f Binary files /dev/null and b/data/gfx/icefont2.png differ diff --git a/data/gfx/loading3.png b/data/gfx/loading3.png new file mode 100644 index 0000000..e3fb0b8 Binary files /dev/null and b/data/gfx/loading3.png differ diff --git a/data/gfx/logo-outline.png b/data/gfx/logo-outline.png new file mode 100644 index 0000000..923dc49 Binary files /dev/null and b/data/gfx/logo-outline.png differ diff --git a/data/gfx/logomask3.png b/data/gfx/logomask3.png new file mode 100644 index 0000000..1df64e3 Binary files /dev/null and b/data/gfx/logomask3.png differ diff --git a/data/gfx/missile.png b/data/gfx/missile.png new file mode 100644 index 0000000..3fd11b7 Binary files /dev/null and b/data/gfx/missile.png differ diff --git a/data/gfx/missile2.png b/data/gfx/missile2.png new file mode 100644 index 0000000..059a3c8 Binary files /dev/null and b/data/gfx/missile2.png differ diff --git a/data/gfx/missile3.png b/data/gfx/missile3.png new file mode 100644 index 0000000..c5c5fe9 Binary files /dev/null and b/data/gfx/missile3.png differ diff --git a/data/gfx/noise.png b/data/gfx/noise.png new file mode 100644 index 0000000..6ac8e27 Binary files /dev/null and b/data/gfx/noise.png differ diff --git a/data/gfx/player.png b/data/gfx/player.png new file mode 100644 index 0000000..19e9ba4 Binary files /dev/null and b/data/gfx/player.png differ diff --git a/data/gfx/ring.png b/data/gfx/ring.png new file mode 100644 index 0000000..6128f0f Binary files /dev/null and b/data/gfx/ring.png differ diff --git a/data/gfx/ringexpl2b.png b/data/gfx/ringexpl2b.png new file mode 100644 index 0000000..2c693e3 Binary files /dev/null and b/data/gfx/ringexpl2b.png differ diff --git a/data/gfx/rock1c.png b/data/gfx/rock1c.png new file mode 100644 index 0000000..1c4be19 Binary files /dev/null and b/data/gfx/rock1c.png differ diff --git a/data/gfx/rock2.png b/data/gfx/rock2.png new file mode 100644 index 0000000..99faa8c Binary files /dev/null and b/data/gfx/rock2.png differ diff --git a/data/gfx/rockexpl.png b/data/gfx/rockexpl.png new file mode 100644 index 0000000..6a3cb93 Binary files /dev/null and b/data/gfx/rockexpl.png differ diff --git a/data/gfx/screen2.png b/data/gfx/screen2.png new file mode 100644 index 0000000..26599c3 Binary files /dev/null and b/data/gfx/screen2.png differ diff --git a/data/gfx/shinyrock.png b/data/gfx/shinyrock.png new file mode 100644 index 0000000..bd3476e Binary files /dev/null and b/data/gfx/shinyrock.png differ diff --git a/data/gfx/tiles-blood.png b/data/gfx/tiles-blood.png new file mode 100644 index 0000000..59ce3a8 Binary files /dev/null and b/data/gfx/tiles-blood.png differ diff --git a/data/gfx/tiles-chrome.png b/data/gfx/tiles-chrome.png new file mode 100644 index 0000000..ad31291 Binary files /dev/null and b/data/gfx/tiles-chrome.png differ diff --git a/data/gfx/tiles-double.png b/data/gfx/tiles-double.png new file mode 100644 index 0000000..66dc4a9 Binary files /dev/null and b/data/gfx/tiles-double.png differ diff --git a/data/gfx/tiles-green.png b/data/gfx/tiles-green.png new file mode 100644 index 0000000..e21f032 Binary files /dev/null and b/data/gfx/tiles-green.png differ diff --git a/data/gfx/tiles-metal.png b/data/gfx/tiles-metal.png new file mode 100644 index 0000000..db2d893 Binary files /dev/null and b/data/gfx/tiles-metal.png differ diff --git a/data/sfx/Makefile.am b/data/sfx/Makefile.am new file mode 100644 index 0000000..1152d41 --- /dev/null +++ b/data/sfx/Makefile.am @@ -0,0 +1,19 @@ +KOBOSFX_OBJECTS = *.agw *.mid *.h + +if BUILD_MACOSX_BUNDLE +kobosfxdir = $(srcdir)/../@PACKAGE@.app/Contents/Resources/sfx +else + +if BUILD_SIMPLE_BUNDLE +kobosfxdir = $(srcdir)/../@PACKAGE@/sfx +else +kobosfxdir = $(datadir)/kobo-deluxe/sfx +endif + +endif + +kobosfx_DATA = $(KOBOSFX_OBJECTS) + +EXTRA_DIST = $(KOBOSFX_OBJECTS) + +CLEANFILES = *_c.raw diff --git a/data/sfx/Makefile.in b/data/sfx/Makefile.in new file mode 100644 index 0000000..4460a9a --- /dev/null +++ b/data/sfx/Makefile.in @@ -0,0 +1,362 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = data/sfx +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/aconfig.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(kobosfxdir)" +kobosfxDATA_INSTALL = $(INSTALL_DATA) +DATA = $(kobosfx_DATA) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUDIO_LIBS = @AUDIO_LIBS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_MACOSX_BUNDLE_FALSE = @BUILD_MACOSX_BUNDLE_FALSE@ +BUILD_MACOSX_BUNDLE_TRUE = @BUILD_MACOSX_BUNDLE_TRUE@ +BUILD_SIMPLE_BUNDLE_FALSE = @BUILD_SIMPLE_BUNDLE_FALSE@ +BUILD_SIMPLE_BUNDLE_TRUE = @BUILD_SIMPLE_BUNDLE_TRUE@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONFIGDIR = @CONFIGDIR@ +CONFIGFILE = @CONFIGFILE@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXEFILE = @EXEFILE@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LOCALCFLAGS = @LOCALCFLAGS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MATHLIB = @MATHLIB@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POW_LIB = @POW_LIB@ +RANLIB = @RANLIB@ +SCOREDIR = @SCOREDIR@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +UNIX_SCOREDIR_FALSE = @UNIX_SCOREDIR_FALSE@ +UNIX_SCOREDIR_TRUE = @UNIX_SCOREDIR_TRUE@ +VERSION = @VERSION@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +KOBOSFX_OBJECTS = *.agw *.mid *.h +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_FALSE@kobosfxdir = $(datadir)/kobo-deluxe/sfx +@BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@kobosfxdir = $(srcdir)/../@PACKAGE@/sfx +@BUILD_MACOSX_BUNDLE_TRUE@kobosfxdir = $(srcdir)/../@PACKAGE@.app/Contents/Resources/sfx +kobosfx_DATA = $(KOBOSFX_OBJECTS) +EXTRA_DIST = $(KOBOSFX_OBJECTS) +CLEANFILES = *_c.raw +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign data/sfx/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign data/sfx/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +uninstall-info-am: +install-kobosfxDATA: $(kobosfx_DATA) + @$(NORMAL_INSTALL) + test -z "$(kobosfxdir)" || $(mkdir_p) "$(DESTDIR)$(kobosfxdir)" + @list='$(kobosfx_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(kobosfxDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(kobosfxdir)/$$f'"; \ + $(kobosfxDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(kobosfxdir)/$$f"; \ + done + +uninstall-kobosfxDATA: + @$(NORMAL_UNINSTALL) + @list='$(kobosfx_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(kobosfxdir)/$$f'"; \ + rm -f "$(DESTDIR)$(kobosfxdir)/$$f"; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(DATA) +installdirs: + for dir in "$(DESTDIR)$(kobosfxdir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-kobosfxDATA + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am uninstall-kobosfxDATA + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am \ + install-kobosfxDATA install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ + pdf-am ps ps-am uninstall uninstall-am uninstall-info-am \ + uninstall-kobosfxDATA + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/data/sfx/aguitar1.agw b/data/sfx/aguitar1.agw new file mode 100644 index 0000000..237e47d --- /dev/null +++ b/data/sfx/aguitar1.agw @@ -0,0 +1,49 @@ +///////////////////////////////////////////// +// Acoustic Guitar 1 +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +w_format target, MONO16, 33488; +w_blank target, 33488, 0; + +//string +w_env AMPLITUDE, + 0, .4, + .005, .1, + .995, 0; +w_env FREQUENCY, 0, 261.65; +w_env MOD1, + 0, .2, + 1, .1; +w_osc target, PULSE; + +w_env AMPLITUDE, + 0, .6, + .005, .2, + .5, 0; +w_env FREQUENCY, 0, 261.75; +w_env MOD1, + 0, .2, + 1, .1; +w_osc target, PULSE; + +w_env AMPLITUDE, + 0, 2, + .1, 1.5; +w_env FREQUENCY, + 0, 8000, + .01, 2500, + .1, 1500; +w_filter target, LOWPASS_12; + +w_env AMPLITUDE, 1; +w_env FREQUENCY, 300; +w_env MOD1, 0; +w_filter target, HIGHPASS_12; + +//body +w_env AMPLITUDE, 0, 5; +w_env FREQUENCY, 0, 150; +w_filter target, PEAK_12; +w_env FREQUENCY, 0, 180; +w_filter target, PEAK_12; diff --git a/data/sfx/bassdrum5.agw b/data/sfx/bassdrum5.agw new file mode 100644 index 0000000..2b84a59 --- /dev/null +++ b/data/sfx/bassdrum5.agw @@ -0,0 +1,42 @@ +///////////////////////////////////////////// +// Bass Drum 5 +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +w_format target, MONO16, 8000; +w_blank target, 8000, 0; + +//attack +w_env AMPLITUDE, + 0, .3, + .01, .07, + .04, .02, + .5, 0; +w_env FREQUENCY, + 0, 4000, + .03, 500; +w_osc target, NOISE; + +//power +w_env AMPLITUDE, + 0, .8, + .05, .9, + .15, .7, + .8, 0; +w_env MOD1, + 0, .05, + .1, 0; +w_env FREQUENCY, + 0, 300, + .02, 160, + .03, 70, + .2, 40; +w_osc target, SINE; + +//filter +w_env AMPLITUDE, 0, 0; +w_env FREQUENCY, + 0, 1500, + 0.02, 500, + 0.2, 400; +w_filter target, LOWPASS_12; diff --git a/data/sfx/bleep1.agw b/data/sfx/bleep1.agw new file mode 100644 index 0000000..8c1b1b5 --- /dev/null +++ b/data/sfx/bleep1.agw @@ -0,0 +1,36 @@ +///////////////////////////////////////////// +// Bleep 1 +// Copyright (C) 2007, David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 3200, 0; + +w_env AMPLITUDE, .5; +w_env FREQUENCY, 1700; +w_osc target, SINE; +w_env FREQUENCY, 2295; +w_osc target, SINE; + +w_env AMPLITUDE, 1; +w_env BALANCE, 1; +w_env FREQUENCY, 1500.5; +w_osc target, SINE, MUL; + +w_env AMPLITUDE, + 0, .9, + .01, .2, + .08, .3, + .005, .7, + .005, 0; +w_env BALANCE, + 0, 20, + .01, 35, + .08, 45, + .01, 0; +w_env FREQUENCY, 1000; +w_osc target, SINE, FM; + +w_env FREQUENCY, 500; +w_env AMPLITUDE, 0; +w_filter target, HIGHPASS_12; diff --git a/data/sfx/bleep3.agw b/data/sfx/bleep3.agw new file mode 100644 index 0000000..ab4dcca --- /dev/null +++ b/data/sfx/bleep3.agw @@ -0,0 +1,35 @@ +///////////////////////////////////////////// +// Bleep 3 +// Copyright (C) 2007, David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 800, 0; + +w_env AMPLITUDE, .5; +w_env FREQUENCY, 3400; +w_osc target, SINE; +w_env FREQUENCY, 4600; +w_osc target, SINE; + +w_env AMPLITUDE, 1; +w_env BALANCE, 1; +w_env FREQUENCY, 7010; +w_osc target, SINE, MUL; + +w_env AMPLITUDE, + .00125, .8, + .00125, .3, + .02, .4, + .0025, 0; +w_env BALANCE, + 0, 20, + .0025, 30, + .02, 40, + .0025, 0; +w_env FREQUENCY, 2000; +w_osc target, SINE, FM; + +w_env FREQUENCY, 1600; +w_env AMPLITUDE, 5; +w_filter target, HIGHPASS_12; diff --git a/data/sfx/boltfire2.agw b/data/sfx/boltfire2.agw new file mode 100644 index 0000000..bef26d8 --- /dev/null +++ b/data/sfx/boltfire2.agw @@ -0,0 +1,53 @@ +///////////////////////////////////////////// +// Bolt Fire 2 +// Copyright (C) 2003, 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 1600, 0; + +//fm thump +w_env AMPLITUDE, .5; +w_env FREQUENCY, 1965; +w_osc target, SINE; +w_env FREQUENCY, 1985; +w_osc target, SINE; + +w_env AMPLITUDE, 1; +w_env BALANCE, 1; +w_env FREQUENCY, 2000; +w_osc target, SINE, MUL; + +w_env AMPLITUDE, + 0, .5, + .01, .25, + .02, .1, + .02, 0; +w_env BALANCE, + 0, 50, + .05, 20; +w_env FREQUENCY, 400; +w_osc target, SINE, FM; + +//tecno squeal +w_env AMPLITUDE, + .04, .05, + .01, 0; +w_env MOD1, + 0, .15, + .05, .25; +w_env FREQUENCY, + 0, 3000, + .05, 4000; +w_osc target, SINE; +w_env FREQUENCY, + 0, 1800, + .05, 2000; +w_osc target, SINE; +w_env MOD1, + 0, .4, + .05, .6; +w_env FREQUENCY, + 0, 500, + .05, 600; +w_osc target, SINE; diff --git a/data/sfx/boltfire2e.agw b/data/sfx/boltfire2e.agw new file mode 100644 index 0000000..5ddd3d4 --- /dev/null +++ b/data/sfx/boltfire2e.agw @@ -0,0 +1,30 @@ +///////////////////////////////////////////// +// Bolt Fire 2 - End (*after* last shot) +// Copyright (C) 2003, 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 16000, 0; + +//tecno squeal +w_env AMPLITUDE, + .1, .05, + .4, 0; +w_env MOD1, + 0, .2, + .5, 0; +w_env FREQUENCY, + 0, 4000, + .5, 2000; +w_osc target, SINE; +w_env FREQUENCY, + 0, 2200, + .5, 1100; +w_osc target, SINE; +w_env MOD1, + 0, .5, + .5, 0; +w_env FREQUENCY, + 0, 600, + .5, 300; +w_osc target, SINE; diff --git a/data/sfx/boltfire2o.agw b/data/sfx/boltfire2o.agw new file mode 100644 index 0000000..d10dacb --- /dev/null +++ b/data/sfx/boltfire2o.agw @@ -0,0 +1,30 @@ +///////////////////////////////////////////// +// Bolt Fire 2 - Overheat +// Copyright (C) 2003, 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 3200, 0; + +//tecno squeal +w_env AMPLITUDE, + .07, .05, + .03, 0; +w_env MOD1, + 0, .25, + .1, .1; +w_env FREQUENCY, + 0, 4000, + .1, 3000; +w_osc target, SINE; +w_env FREQUENCY, + 0, 1800, + .1, 2000; +w_osc target, SINE; +w_env MOD1, + 0, .6, + .1, .2; +w_env FREQUENCY, + 0, 600, + .1, 500; +w_osc target, SINE; diff --git a/data/sfx/boltfire2s.agw b/data/sfx/boltfire2s.agw new file mode 100644 index 0000000..06bc73f --- /dev/null +++ b/data/sfx/boltfire2s.agw @@ -0,0 +1,52 @@ +///////////////////////////////////////////// +// Bolt Fire 2 - Start (first shot) +// Copyright (C) 2003, 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 6400, 0; + +//fm thump +w_env AMPLITUDE, .5; +w_env FREQUENCY, 1965; +w_osc target, SINE; +w_env FREQUENCY, 1985; +w_osc target, SINE; + +w_env AMPLITUDE, 1; +w_env BALANCE, 1; +w_env FREQUENCY, 2000; +w_osc target, SINE, MUL; + +w_env AMPLITUDE, + .02, 0, + 0, .5, + .01, .25, + .02, .1, + .02, 0; +w_env BALANCE, + .02, 0, + 0, 50, + .05, 20; +w_env FREQUENCY, 900; +w_osc target, SINE, FM; + +//tecno squeal +w_env AMPLITUDE, + .03, .075, + .07, .05, + .07, 0; +w_env MOD1, .2; +w_env FREQUENCY, + 0, 1500, + .2, 4000; +w_osc target, SINE; +w_env FREQUENCY, + 0, 900, + .2, 2000; +w_osc target, SINE; +w_env MOD1, .5; +w_env FREQUENCY, + 0, 150, + .2, 600; +w_osc target, SINE; diff --git a/data/sfx/brass2.agw b/data/sfx/brass2.agw new file mode 100644 index 0000000..0dec0ef --- /dev/null +++ b/data/sfx/brass2.agw @@ -0,0 +1,57 @@ +///////////////////////////////////////////// +// Brass 2 +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 128000, 0; + +C = 523.25; + +//modulator +w_env FREQUENCY, C; +w_env AMPLITUDE, 1; +w_env MOD2, .5; +w_osc target, SINEMORPH; + +//FM oscillator +w_env AMPLITUDE, 1; +w_env FREQUENCY, + 0, C * 0.93, + .07, C; +w_mod FREQUENCY, .2, 0, 0.002; +w_env MOD1, + 0, 1, + .5, .5, + 2, 0; +w_env MOD2; +w_env BALANCE, + 0, 2, + 1, 1.3, + 3, .7; +w_osc target, SINEMORPH, FM; + +//"chorus" +w_env FREQUENCY, C; +w_mod FREQUENCY, 3, 0, .01; +w_env AMPLITUDE, 1; +w_env MOD1, 1; +w_env MOD2, 0; +w_osc target, SINEMORPH; + +//Soft dist +w_env AMPLITUDE, .7; +w_gain target; + +w_env AMPLITUDE, 1; +w_env FREQUENCY, 3000; +w_env MOD1; +w_filter target, LOWPASS_12; + +//final envelope +w_env AMPLITUDE, + 0, 1, + 1, 1, + 2, .5, + 1, 0; +w_gain target; diff --git a/data/sfx/bzzzt1.agw b/data/sfx/bzzzt1.agw new file mode 100644 index 0000000..6ea8bd3 --- /dev/null +++ b/data/sfx/bzzzt1.agw @@ -0,0 +1,37 @@ +///////////////////////////////////////////// +// Bzzzt! 1 +// Copyright (C) David Olofson, 2003 +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 16000, 0; + +w_env AMPLITUDE, .5; +w_env FREQUENCY, 55; +w_env MOD1, 1; +w_osc target, TRIANGLE; + +w_env FREQUENCY, 50; +w_osc target, TRIANGLE, SYNC; + +w_env FREQUENCY, 7000; +w_env BALANCE, 1; +w_osc target, NOISE, MUL; + +w_env AMPLITUDE, .1; +w_env FREQUENCY, 49; +w_env BALANCE, .5; +w_osc target, TRIANGLE, MUL; +w_env AMPLITUDE, .05; +w_env FREQUENCY, 57; +w_env MOD1, .1; +w_osc target, PULSE; + +w_env AMPLITUDE, + .01, 1, + .09, .8, + .2, .6, + .05, .1, + .1, .05, + .05, 0; +w_gain target; diff --git a/data/sfx/cannon1.agw b/data/sfx/cannon1.agw new file mode 100644 index 0000000..65de4ca --- /dev/null +++ b/data/sfx/cannon1.agw @@ -0,0 +1,141 @@ +///////////////////////////////////////////// +// Cannon 1 +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +a = .8; + +w_format target, MONO16, 24000; +w_blank target, 24000*3, 0; + +// Rumble +w_env AMPLITUDE, + 0, a/4, + .5, a/8, + .5, a/16, + 1, a/32, + 1, 0; +w_env FREQUENCY, + 0, 100, + 3, 70; +w_osc target, NOISE; + +w_env FREQUENCY, + 0, 100, + .5, 300, + .5, 100, + .1, 200, + .1, 50, + .2, 150, + .2, 250, + .4, 100, + 1, 10; +w_env AMPLITUDE, 2; +w_filter target, LOWPASS_12; + +// Ka-blam +w_env AMPLITUDE, + 0, a/4, + .5, a/8, + .5, a/16, + 1, a/32, + 1, 0; +w_env FREQUENCY, + 0, 700, + .1, 200, + .1, 700, + 2.8, 850; +w_osc target, NOISE; +w_env FREQUENCY, + 0, 500, + .1, 100, + .5, 300, + 2.4, 200; +w_osc target, NOISE; + + +// Attack +w_env AMPLITUDE, + 0, a/2, + .1, a/8, + .5, 0; +w_env FREQUENCY, 1500; +w_osc target, NOISE; + + +// Mod +w_env AMPLITUDE, 1; +w_env FREQUENCY, 15; +w_env BALANCE, .4; +w_osc target, NOISE, MUL; + + +// Thunder reso +w_env FREQUENCY, + 0, 300, + .02, 50, + .08, 300, + .1, 150, + .2, 300, + .2, 150, + .4, 50, + 2.2, 150; +w_env AMPLITUDE, + 0, 5, + .02, 10, + .08, 5, + .1, 0, + .2, 5, + .2, 0, + .4, 2, + 2.2, 0; +w_filter target, PEAK_12; + + +// Quake reso +w_env FREQUENCY, + 0, 200, + .1, 70, + 2.9, 50; +w_env AMPLITUDE, + 0, 5, + .1, 0, + .5, 7, + 2.4, 15; +w_filter target, PEAK_12; + + +// Crackle boost +w_env FREQUENCY, 400; +w_env AMPLITUDE, + 0, 5, + .5, 15, + 2.5, 0; +w_filter target, PEAK_12; +w_env FREQUENCY, 750; +w_env AMPLITUDE, 3; +w_filter target, PEAK_12; +w_env FREQUENCY, 1100; +w_env AMPLITUDE, + 0, 1, + 1, 8, + 2, 0; +w_filter target, PEAK_12; +w_env FREQUENCY, 1700; +w_env AMPLITUDE, + 0, 8, + 1, 0; +w_filter target, PEAK_12; + + +// Treble damping +w_env FREQUENCY, + 0, 9000, + .25, 4000, + 1.25, 2000, + 1.5, 500; +w_env AMPLITUDE, 0; +w_env MOD1, + 0, .3, + .5, 0; +w_filter target, LOWPASS_12; diff --git a/data/sfx/claps1.agw b/data/sfx/claps1.agw new file mode 100644 index 0000000..26d4254 --- /dev/null +++ b/data/sfx/claps1.agw @@ -0,0 +1,41 @@ +///////////////////////////////////////////// +// Claps 1 +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 8000, 0; + +procedure clap(delay, l1, l2, l3) +{ + w_env AMPLITUDE, + delay, 0, + 0, l1, + .01, l2, + .02, l3, + .2, 0; + w_osc target, NOISE; +} + +//claps +w_env FREQUENCY, 0, 8000; +clap 0, .15, .05, .01; +clap .02, .5, .1, .02; +clap .05, .2, .1, .02; +clap .085, .15, .05, .015; + +//lpf +w_env MOD1; +w_env AMPLITUDE, 0, 1; +w_env FREQUENCY, 0, 4500; +w_filter target, LOWPASS_12; + +//coloration +w_env AMPLITUDE, 0, 4; +w_env FREQUENCY, 0, 800; +w_filter target, PEAK_12; +w_env FREQUENCY, 0, 1200; +w_filter target, PEAK_12; +w_env AMPLITUDE, 0, 2; +w_env FREQUENCY, 0, 4000; +w_filter target, PEAK_12; diff --git a/data/sfx/edge2.agw b/data/sfx/edge2.agw new file mode 100644 index 0000000..addfc67 --- /dev/null +++ b/data/sfx/edge2.agw @@ -0,0 +1,41 @@ +///////////////////////////////////////////// +// Edge 2 +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 32000, 0; + +w_env FREQUENCY, 8000; +w_env AMPLITUDE, + 0, .5, + .02, .05, + .03, .006, + .95, 0; +w_osc target, NOISE; + +//attack shaper +w_env AMPLITUDE, 0; +w_env MOD1, .2; +w_env FREQUENCY, + 0, 6000, + .01, 3500, + .9, 1700; +w_filter target, LOWPASS_12; +w_env FREQUENCY, + 0, 100, + .01, 800, + .9, 1200; +w_filter target, HIGHPASS_12; + +//drum resonance +w_env AMPLITUDE, + 0, 3, + .2, 2; +w_env FREQUENCY, 2200; +w_filter target, PEAK_12; + +//stick resonance +w_env AMPLITUDE, 4; +w_env FREQUENCY, 3700; +w_filter target, PEAK_12; diff --git a/data/sfx/explo1b-rg.agw b/data/sfx/explo1b-rg.agw new file mode 100644 index 0000000..ca8128a --- /dev/null +++ b/data/sfx/explo1b-rg.agw @@ -0,0 +1,58 @@ +///////////////////////////////////////////// +// Explo 1 B Rumble Grain +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 16000, 0; + +procedure f(tp, f0, res) +{ + w_env FREQUENCY, f0; + w_env AMPLITUDE, res; + w_filter target, tp; +} + +// Rumble +w_env AMPLITUDE, .3; +w_env FREQUENCY, 130; +w_osc target, NOISE; + +// Crackle +w_env AMPLITUDE, .8; +w_env FREQUENCY, 350; +w_osc target, NOISE; + +// Attack +w_env AMPLITUDE, .4; +w_env FREQUENCY, 5000; +w_osc target, NOISE; + +// Mod +w_env AMPLITUDE, 1; +w_env FREQUENCY, 70; +w_env BALANCE, .8; +w_osc target, NOISE, MUL; + +// Resonances +f PEAK_12, 900, 1; +f PEAK_12, 1100, 2; +f PEAK_12, 2700, 2; + +// Treble damping +w_env FREQUENCY, + 0, 5000, + 1, 100; +w_filter target, LOWPASS_6; +w_env FREQUENCY, 150; +w_env AMPLITUDE, 0; +w_env MOD1, + .05, 1, + .15, .3, + .8, .1; +w_filter target, LOWPASS_12; + +w_env AMPLITUDE, + .1, 1, + .9, 0; +w_gain target; diff --git a/data/sfx/explo1b.agw b/data/sfx/explo1b.agw new file mode 100644 index 0000000..a9c34f6 --- /dev/null +++ b/data/sfx/explo1b.agw @@ -0,0 +1,71 @@ +///////////////////////////////////////////// +// Explo 1 B - Short version +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 16000, 0; + +procedure ax(a) +{ + w_env AMPLITUDE, + 0, a, + .5, a/2, + .5, 0; +} + +procedure f(tp, f0, res) +{ + w_env FREQUENCY, f0; + w_env AMPLITUDE, res; + w_filter target, tp; +} + +// Rumble +ax .3; +w_env FREQUENCY, 130; +w_osc target, NOISE; +f LOWPASS_12, 80, 2; + +// Crackle +ax .8; +w_env FREQUENCY, 350; +w_osc target, NOISE; + +// Attack +ax .4; +w_env FREQUENCY, 5000; +w_osc target, NOISE; + +// Mod +w_env AMPLITUDE, 1; +w_env FREQUENCY, 70; +w_env BALANCE, 1; +w_osc target, NOISE, MUL; + +// Resonances +f PEAK_12, 40, 11; +f PEAK_12, 220, 8; +f PEAK_12, 900, 2; +f PEAK_12, 1100, 3; +f PEAK_12, 2700, 4; + +// Treble damping +w_env FREQUENCY, + 0, 16000, + .2, 4000, + .8, 1000; +w_filter target, LOWPASS_6; +w_env FREQUENCY, 150; +w_env AMPLITUDE, 3; +w_env MOD1, + 0, 1, + .2, .4, + .8, 0; +w_filter target, LOWPASS_12; + +w_env AMPLITUDE, + 0, 1, + .5, 1, + .5, 0; +w_gain target; diff --git a/data/sfx/explo1c-rg.agw b/data/sfx/explo1c-rg.agw new file mode 100644 index 0000000..b832cc7 --- /dev/null +++ b/data/sfx/explo1c-rg.agw @@ -0,0 +1,58 @@ +///////////////////////////////////////////// +// Explo 1 C Rumble Grain +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 16000, 0; + +procedure f(tp, f0, res) +{ + w_env FREQUENCY, f0; + w_env AMPLITUDE, res; + w_filter target, tp; +} + +// Rumble +w_env AMPLITUDE, .3; +w_env FREQUENCY, 130; +w_osc target, NOISE; + +// Crackle +w_env AMPLITUDE, .8; +w_env FREQUENCY, 350; +w_osc target, NOISE; + +// Attack +w_env AMPLITUDE, .2; +w_env FREQUENCY, 7000; +w_osc target, NOISE; + +// Mod +w_env AMPLITUDE, 1; +w_env FREQUENCY, 70; +w_env BALANCE, .8; +w_osc target, NOISE, MUL; + +// Resonances +f PEAK_12, 900, 2; +f PEAK_12, 1700, 1; +f PEAK_12, 3100, 5; + +// Treble damping +w_env FREQUENCY, + 0, 5000, + 1, 100; +w_filter target, LOWPASS_6; +w_env FREQUENCY, 150; +w_env AMPLITUDE, 0; +w_env MOD1, + .05, 1, + .15, .4, + .8, .1; +w_filter target, LOWPASS_12; + +w_env AMPLITUDE, + .1, 1, + .9, 0; +w_gain target; diff --git a/data/sfx/explo1c.agw b/data/sfx/explo1c.agw new file mode 100644 index 0000000..bcf9b7c --- /dev/null +++ b/data/sfx/explo1c.agw @@ -0,0 +1,72 @@ +///////////////////////////////////////////// +// Explo 1 C - Short version, variation +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 16000, 0; + +procedure ax(a) +{ + w_env AMPLITUDE, + 0, a, + .5, a/2, + .5, 0; +} + +procedure f(tp, f0, res) +{ + w_env FREQUENCY, f0; + w_env AMPLITUDE, res; + w_filter target, tp; +} + +// Rumble +ax .3; +w_env FREQUENCY, 130; +w_osc target, NOISE; +f LOWPASS_12, 80, 2; + +// Crackle +ax .8; +w_env FREQUENCY, 350; +w_osc target, NOISE; + +// Attack +ax .4; +w_env FREQUENCY, 7000; +w_osc target, NOISE; + +// Mod +w_env AMPLITUDE, 1; +w_env FREQUENCY, 70; +w_env BALANCE, 1; +w_osc target, NOISE, MUL; + +// Resonances +f PEAK_12, 40, 11; +f PEAK_12, 180, 8; +f PEAK_12, 500, 3; +f PEAK_12, 900, 4; +f PEAK_12, 1700, 3; +f PEAK_12, 3100, 5; + +// Treble damping +w_env FREQUENCY, + 0, 16000, + .2, 4000, + .8, 1000; +w_filter target, LOWPASS_6; +w_env FREQUENCY, 150; +w_env AMPLITUDE, 3; +w_env MOD1, + 0, 1, + .2, .3, + .8, 0; +w_filter target, LOWPASS_12; + +w_env AMPLITUDE, + 0, 1, + .5, 1, + .5, 0; +w_gain target; diff --git a/data/sfx/explo3d.agw b/data/sfx/explo3d.agw new file mode 100644 index 0000000..272f45f --- /dev/null +++ b/data/sfx/explo3d.agw @@ -0,0 +1,71 @@ +///////////////////////////////////////////// +// Explo 3 D - Short version, less rumble +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 16000, 0; + +procedure f(tp, f0, res) +{ + w_env FREQUENCY, f0; + w_env AMPLITUDE, res; + w_filter target, tp; +} + +// Rumble +w_env AMPLITUDE, + 0, .1, + .5, .5; +w_env FREQUENCY, 150; +w_osc target, NOISE; + +// Crackle +w_env AMPLITUDE, + 0, 1, + .5, .5; +w_env FREQUENCY, 300; +w_osc target, NOISE; +w_env FREQUENCY, 50; +w_osc target, NOISE; + +// Attack +w_env AMPLITUDE, + 0, 1, + .5, .1; +w_env FREQUENCY, 3000; +w_osc target, NOISE; + +// Mod +w_env FREQUENCY, 25; +w_env BALANCE, + 0, .5, + .5, .2; +w_osc target, NOISE, MUL; + +// Resonances +f PEAK_12, 200, 5; +f PEAK_12, 350, 7; +f PEAK_12, 500, 5; +f PEAK_12, 2100, 3; +f PEAK_12, 4700, 0; + +// Treble damping +w_env FREQUENCY, + 0, 16000, + .25, 4000, + .75, 1000; +w_filter target, LOWPASS_6; +w_env FREQUENCY, 60; +w_env AMPLITUDE, 1; +w_env MOD1, + 0, 1, + .2, .3, + .8, 0; +w_filter target, LOWPASS_12; + +w_env AMPLITUDE, + 0, 1, + .3, 1, + .7, 0; +w_gain target; diff --git a/data/sfx/explo4d.agw b/data/sfx/explo4d.agw new file mode 100644 index 0000000..affbc96 --- /dev/null +++ b/data/sfx/explo4d.agw @@ -0,0 +1,80 @@ +///////////////////////////////////////////// +// Explo 4 D - Short version, less rumble +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 16000, 0; + +procedure ax(a) +{ + w_env AMPLITUDE, + 0, a, + .25, a/2, + .25, a/4, + .25, a/8, + .25, 0; +} + +procedure f(tp, f0, res) +{ + w_env FREQUENCY, f0; + w_env AMPLITUDE, res; + w_filter target, tp; +} + +// Rumble +w_env AMPLITUDE, .5; +w_env FREQUENCY, 150; +w_osc target, NOISE; + +// Crackle +ax 1; +w_env FREQUENCY, 300; +w_osc target, NOISE; +w_env FREQUENCY, 50; +w_osc target, NOISE; + +// Attack +w_env AMPLITUDE, + 0, .7, + .5, .1; +w_env FREQUENCY, 6000; +w_osc target, NOISE; +w_env FREQUENCY, 2000; +w_osc target, NOISE; + +// Mod +w_env AMPLITUDE, 1; +w_env FREQUENCY, 25; +w_env BALANCE, + 0, .5, + .5, .2; +w_osc target, NOISE, MUL; + +// Resonances +f PEAK_12, 110, 10; +f PEAK_12, 220, 10; +f PEAK_12, 400, 5; +f PEAK_12, 1700, 3; +f PEAK_12, 3000, 2; + +// Treble damping +w_env FREQUENCY, + 0, 16000, + .25, 4000, + .75, 1000; +w_filter target, LOWPASS_6; +w_env FREQUENCY, 60; +w_env AMPLITUDE, 1; +w_env MOD1, + 0, 1, + .2, .2, + .8, 0; +w_filter target, LOWPASS_12; + +w_env AMPLITUDE, + 0, 1, + .3, 1, + .7, 0; +w_gain target; diff --git a/data/sfx/explo5.agw b/data/sfx/explo5.agw new file mode 100644 index 0000000..042e404 --- /dev/null +++ b/data/sfx/explo5.agw @@ -0,0 +1,47 @@ +///////////////////////////////////////////// +// Explo 5 - Electric +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 32000*.75, 0; + +procedure f(tp, f0, res) +{ + w_env FREQUENCY, f0; + w_env AMPLITUDE, res; + w_filter target, tp; +} + +// Bump +w_env AMPLITUDE, + 0, .5, + .1, 0; +w_env FREQUENCY, 1000; +w_osc target, NOISE; +f LOWPASS_12, 2000, 2; + +// Crackle +w_env AMPLITUDE, + 0, .1, + .5, .05, + .55, 0; +w_env FREQUENCY, 8000; +w_osc target, NOISE; +w_env FREQUENCY, 15000; +w_osc target, NOISE; + +// Mod +w_env AMPLITUDE, 1; +w_env FREQUENCY, 50; +w_env BALANCE, + 0, .5, + .5, 1; +w_osc target, NOISE, MUL; + +// Resonances +f PEAK_12, 90, 10; +f PEAK_12, 160, 15; +f PEAK_12, 800, 5; +f PEAK_12, 1700, 3; +f PEAK_12, 3500, 1; diff --git a/data/sfx/explo5b.agw b/data/sfx/explo5b.agw new file mode 100644 index 0000000..84cbe9b --- /dev/null +++ b/data/sfx/explo5b.agw @@ -0,0 +1,47 @@ +///////////////////////////////////////////// +// Explo 5 B +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 32000*.75, 0; + +procedure f(tp, f0, res) +{ + w_env FREQUENCY, f0; + w_env AMPLITUDE, res; + w_filter target, tp; +} + +// Bump +w_env AMPLITUDE, + 0, .5, + .1, 0; +w_env FREQUENCY, 900; +w_osc target, NOISE; +f LOWPASS_12, 1900, 2; + +// Crackle +w_env AMPLITUDE, + 0, .1, + .5, .05, + .25, 0; +w_env FREQUENCY, 7000; +w_osc target, NOISE; +w_env FREQUENCY, 13000; +w_osc target, NOISE; + +// Mod +w_env AMPLITUDE, 1; +w_env FREQUENCY, 30; +w_env BALANCE, + 0, .5, + .5, 1; +w_osc target, NOISE, MUL; + +// Resonances +f PEAK_12, 80, 10; +f PEAK_12, 140, 10; +f PEAK_12, 900, 3; +f PEAK_12, 1500, 3; +f PEAK_12, 4000, 3; diff --git a/data/sfx/explo5c.agw b/data/sfx/explo5c.agw new file mode 100644 index 0000000..5c5f24d --- /dev/null +++ b/data/sfx/explo5c.agw @@ -0,0 +1,46 @@ +///////////////////////////////////////////// +// Explo 5 C +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 32000*.75, 0; + +procedure f(tp, f0, res) +{ + w_env FREQUENCY, f0; + w_env AMPLITUDE, res; + w_filter target, tp; +} + +// Bump +w_env AMPLITUDE, + 0, .5, + .1, 0; +w_env FREQUENCY, 800; +w_osc target, NOISE; +f LOWPASS_12, 2100, 2; + +// Crackle +w_env AMPLITUDE, + 0, .1, + .5, .05, + .25, 0; +w_env FREQUENCY, 9000; +w_osc target, NOISE; +w_env FREQUENCY, 11000; +w_osc target, NOISE; + +// Mod +w_env AMPLITUDE, 1; +w_env FREQUENCY, 40; +w_env BALANCE, + 0, .5, + .5, 1; +w_osc target, NOISE, MUL; + +// Resonances +f PEAK_12, 100, 15; +f PEAK_12, 900, 3; +f PEAK_12, 2000, 3; +f PEAK_12, 5000, 3; diff --git a/data/sfx/explo6.agw b/data/sfx/explo6.agw new file mode 100644 index 0000000..1b530ac --- /dev/null +++ b/data/sfx/explo6.agw @@ -0,0 +1,78 @@ +///////////////////////////////////////////// +// Explo 6 +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 24000; +w_blank target, 24000*4, 0; + +procedure f(tp, f0, res) +{ + w_env FREQUENCY, f0; + w_env AMPLITUDE, res; + w_filter target, tp; +} + +// Rumble +w_env AMPLITUDE, .5; +w_env FREQUENCY, 150; +w_osc target, NOISE; + +f LOWPASS_12, 150, 5; + +// Crackle +w_env AMPLITUDE, .5; +w_env FREQUENCY, 300; +w_osc target, NOISE; +w_env FREQUENCY, 50; +w_osc target, NOISE; + +// Attack +w_env AMPLITUDE, + 0, .5, + .5, .1, + 3, 0; +w_env FREQUENCY, 6000; +w_osc target, NOISE; +w_env FREQUENCY, 2000; +w_osc target, NOISE; + +// Mod +w_env AMPLITUDE, 1; +w_env FREQUENCY, 25; +w_env BALANCE, + 0, .7, + 1.5, .2; +w_osc target, NOISE, MUL; + +// Resonances +f PEAK_12, 45, 5; +f PEAK_12, 110, 12; +f PEAK_12, 220, 15; +f PEAK_12, 400, 7; +f PEAK_12, 600, 3; +f PEAK_12, 1100, 2; +f PEAK_12, 1900, 4; +f PEAK_12, 3200, 3; + +// Treble damping +w_env FREQUENCY, + 0, 24000, + .5, 6000, + 1.25, 1500; +w_filter target, LOWPASS_6; +w_env FREQUENCY, 60; +w_env AMPLITUDE, 1; +w_env MOD1, + 0, 1, + .5, .5, + 1, .3, + 2.5, .1; +w_filter target, LOWPASS_12; + +w_env AMPLITUDE, + 0, 1, + 2, .8, + 1, .2, + 1, 0; +w_gain target; diff --git a/data/sfx/fmthump1b.agw b/data/sfx/fmthump1b.agw new file mode 100644 index 0000000..e179f00 --- /dev/null +++ b/data/sfx/fmthump1b.agw @@ -0,0 +1,29 @@ +///////////////////////////////////////////// +// FM Thump 1 B +// Copyright (C) 2007, David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 3200, 0; + +w_env AMPLITUDE, .5; +w_env FREQUENCY, 1955; +w_osc target, SINE; +w_env FREQUENCY, 1985; +w_osc target, SINE; + +w_env AMPLITUDE, 1; +w_env BALANCE, 1; +w_env FREQUENCY, 1975; +w_osc target, SINE, MUL; + +w_env AMPLITUDE, + 0, .5, + .02, .2, + .04, .05, + .04, 0; +w_env BALANCE, + 0, 50, + .1, 10; +w_env FREQUENCY, 1200; +w_osc target, SINE, FM; diff --git a/data/sfx/gameover1.agw b/data/sfx/gameover1.agw new file mode 100644 index 0000000..69b7b29 --- /dev/null +++ b/data/sfx/gameover1.agw @@ -0,0 +1,70 @@ +///////////////////////////////////////////// +// Game Over 1 +// Copyright (C) David Olofson, 2003 +///////////////////////////////////////////// + +SWEEP = 10; + +w_format target, MONO16, 32000; +w_blank target, 48000, 0; + +//Pulses +w_env AMPLITUDE, + .1, .05, + 1.3, .05, + .1, 0; +w_env MOD1, .1; + +w_env FREQUENCY, + 0, 43.9, + 1.5, 43.9 - SWEEP; +w_osc target, PULSE; + +w_env FREQUENCY, + 0, 44.1, + 1.5, 44.1 - SWEEP; +w_osc target, PULSE; + +w_env FREQUENCY, + 0, 88, + 1.5, 88 - SWEEP; +w_osc target, PULSE; + +//LF +w_env AMPLITUDE, .2; +w_env FREQUENCY, + 0, 22, + 1.5, 22 - SWEEP; +w_env MOD1, .5; +w_osc target, SINE; + +//noise +w_env AMPLITUDE, .05; +w_env MOD1, 20000; +w_env FREQUENCY, + 0, 1000, + 1.5, 50; +w_osc target, NOISE; + +//Filters +w_env MOD1, 0; +w_env AMPLITUDE, 50; +w_env FREQUENCY, + 0, 700, + .6, 5300, + .9, 200; +w_filter target, LOWPASS_12; + +w_env AMPLITUDE, 40; +w_env FREQUENCY, + 0, 300, + .6, 700, + .9, 30; +w_filter target, PEAK_12; + +//Envelope +w_env AMPLITUDE, + .1, 1, + 1, .5, + .4, 0; +w_gain, target; diff --git a/data/sfx/hardsync1.agw b/data/sfx/hardsync1.agw new file mode 100644 index 0000000..7d6353e --- /dev/null +++ b/data/sfx/hardsync1.agw @@ -0,0 +1,44 @@ +///////////////////////////////////////////// +// Hardsync 1 +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 128000, 0; + +//fundamental +w_env FREQUENCY, 261.625 / 2; +w_env AMPLITUDE, .3; +w_env MOD2, 1; +w_osc target, SINEMORPH; + +//hardsync'ed harmonics +w_env AMPLITUDE, + 0, .4, + 1, .25, + 1, .1, + 1, .07, + 1, 0; +w_env FREQUENCY, + 0, 200, + 4, 4000; +w_env MOD2, 1; +w_osc target, SINEMORPH, SYNC_ADD; + +//filter +w_env AMPLITUDE, + 0, 15, + 1, 5, + 3, 0; +w_env FREQUENCY, + 0, 5000, + .5, 2500, + 3, 1500; +w_filter target, LOWPASS_12; + +//final envelope +w_env AMPLITUDE, + 0, 1, + 3, 1, + 1, 0; +w_gain target; diff --git a/data/sfx/impact2.agw b/data/sfx/impact2.agw new file mode 100644 index 0000000..5f1a978 --- /dev/null +++ b/data/sfx/impact2.agw @@ -0,0 +1,27 @@ +///////////////////////////////////////////// +// Impact 2 +// Copyright (C) 2007, David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 16000*.05, 0; + +w_env AMPLITUDE, + 0, 1, + .01, .2, + .04, 0; +w_env FREQUENCY, + 0, 8000, + .01, 4000, + .04, 50; +w_osc target, NOISE; + +w_env AMPLITUDE, + .002, 1, + .018, .5, + .03, 0; +w_env FREQUENCY, + 0, 2000, + .01, 250, + .04, 50; +w_osc target, SINE; diff --git a/data/sfx/impact2b.agw b/data/sfx/impact2b.agw new file mode 100644 index 0000000..0749787 --- /dev/null +++ b/data/sfx/impact2b.agw @@ -0,0 +1,27 @@ +///////////////////////////////////////////// +// Impact 2 B +// Copyright (C) 2007, David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 16000*.05, 0; + +w_env AMPLITUDE, + 0, 1, + .01, .2, + .01, 0; +w_env FREQUENCY, + 0, 7000, + .01, 3000, + .04, 200; +w_osc target, NOISE; + +w_env AMPLITUDE, + .002, 1, + .028, .3, + .02, 0; +w_env FREQUENCY, + 0, 1700, + .01, 270, + .04, 50; +w_osc target, SINE; diff --git a/data/sfx/impact2c.agw b/data/sfx/impact2c.agw new file mode 100644 index 0000000..9f7fe88 --- /dev/null +++ b/data/sfx/impact2c.agw @@ -0,0 +1,27 @@ +///////////////////////////////////////////// +// Impact 2 C +// Copyright (C) 2007, David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 16000*.05, 0; + +w_env AMPLITUDE, + 0, 1, + .01, .2, + .04, 0; +w_env FREQUENCY, + 0, 9000, + .01, 2000, + .04, 300; +w_osc target, NOISE; + +w_env AMPLITUDE, + .001, 1, + .005, .5, + .044, 0; +w_env FREQUENCY, + 0, 2200, + .01, 220, + .04, 50; +w_osc target, SINE; diff --git a/data/sfx/klank2b.agw b/data/sfx/klank2b.agw new file mode 100644 index 0000000..fd2f379 --- /dev/null +++ b/data/sfx/klank2b.agw @@ -0,0 +1,29 @@ +///////////////////////////////////////////// +// Klank 2 B +// Copyright (C) 2007, David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 3200, 0; + +w_env AMPLITUDE, .5; +w_env FREQUENCY, 1975; +w_osc target, SINE; +w_env FREQUENCY, 1990; +w_osc target, SINE; + +w_env AMPLITUDE, 1; +w_env BALANCE, 1; +w_env FREQUENCY, 5650; +w_osc target, SINE, MUL; + +w_env AMPLITUDE, + 0, .9, + .02, .4, + .04, .1, + .04, 0; +w_env BALANCE, + 0, 60, + .1, 10; +w_env FREQUENCY, 1300; +w_osc target, SINE, FM; diff --git a/data/sfx/klank3.agw b/data/sfx/klank3.agw new file mode 100644 index 0000000..121c310 --- /dev/null +++ b/data/sfx/klank3.agw @@ -0,0 +1,39 @@ +///////////////////////////////////////////// +// Klank 3 +// Copyright (C) 2007, David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 3200, 0; + +w_env AMPLITUDE, .5; +w_env FREQUENCY, 1980; +w_osc target, SINE; +w_env FREQUENCY, 1990; +w_osc target, SINE; + +w_env AMPLITUDE, 1; +w_env BALANCE, 1; +w_env FREQUENCY, 5700; +w_osc target, SINE, MUL; + +w_env AMPLITUDE, + 0, .9, + .02, .4, + .04, .1, + .04, 0; +w_env BALANCE, + 0, 60, + .1, 10; +w_env FREQUENCY, 1200; +w_osc target, SINE, FM; + +w_env AMPLITUDE, + .002, 1, + .018, .5, + .075, 0; +w_env FREQUENCY, + 0, 2000, + .02, 150, + .08, 50; +w_osc target, SINE; diff --git a/data/sfx/klank3b.agw b/data/sfx/klank3b.agw new file mode 100644 index 0000000..f686be3 --- /dev/null +++ b/data/sfx/klank3b.agw @@ -0,0 +1,39 @@ +///////////////////////////////////////////// +// Klank 2 B +// Copyright (C) 2007, David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 3200, 0; + +w_env AMPLITUDE, .5; +w_env FREQUENCY, 1975; +w_osc target, SINE; +w_env FREQUENCY, 1990; +w_osc target, SINE; + +w_env AMPLITUDE, 1; +w_env BALANCE, 1; +w_env FREQUENCY, 5650; +w_osc target, SINE, MUL; + +w_env AMPLITUDE, + 0, .9, + .02, .4, + .04, .1, + .04, 0; +w_env BALANCE, + 0, 60, + .1, 10; +w_env FREQUENCY, 1300; +w_osc target, SINE, FM; + +w_env AMPLITUDE, + .002, 1, + .015, .3, + .075, 0; +w_env FREQUENCY, + 0, 1800, + .02, 200, + .08, 50; +w_osc target, SINE; diff --git a/data/sfx/klank3c.agw b/data/sfx/klank3c.agw new file mode 100644 index 0000000..383dd50 --- /dev/null +++ b/data/sfx/klank3c.agw @@ -0,0 +1,39 @@ +///////////////////////////////////////////// +// Klank 2 C +// Copyright (C) 2007, David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 3200, 0; + +w_env AMPLITUDE, .5; +w_env FREQUENCY, 1975; +w_osc target, SINE; +w_env FREQUENCY, 2000; +w_osc target, SINE; + +w_env AMPLITUDE, 1; +w_env BALANCE, 1; +w_env FREQUENCY, 5550; +w_osc target, SINE, MUL; + +w_env AMPLITUDE, + 0, .9, + .02, .4, + .04, .1, + .04, 0; +w_env BALANCE, + 0, 60, + .1, 10; +w_env FREQUENCY, 1100; +w_osc target, SINE, FM; + +w_env AMPLITUDE, + .001, 1, + .005, .5, + .08, 0; +w_env FREQUENCY, + 0, 2200, + .02, 130, + .08, 50; +w_osc target, SINE; diff --git a/data/sfx/klank4.agw b/data/sfx/klank4.agw new file mode 100644 index 0000000..db68300 --- /dev/null +++ b/data/sfx/klank4.agw @@ -0,0 +1,45 @@ +///////////////////////////////////////////// +// Klank 4 +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 32000*.5, 0; + +procedure cr(f, r) +{ + w_env FREQUENCY, f; + w_env MOD1, + .01, r, + .49, r*.9; + w_env MOD2, + .01, .93, + .19, .4, + .3, 0; + w_osc target, ASPECTRUM; +} + +w_env AMPLITUDE, + 0, .1, + .1, .05, + .2, .02, + .2, 0; + +cr 170, 1.3; +cr 270, 1.07; +cr 285, 1.09; +cr 460, 1.2; +cr 480, 1.3; +cr 773, 1.35; +cr 810, 1.15; + +w_env AMPLITUDE, + .002, 1, + .02, .5, + .1, 0; +w_env FREQUENCY, + 0, 2000, + .02, 100, + .1, 50; +w_env MOD1, 0; +w_osc target, SINE; diff --git a/data/sfx/kobosfx.h b/data/sfx/kobosfx.h new file mode 100644 index 0000000..df3d86a --- /dev/null +++ b/data/sfx/kobosfx.h @@ -0,0 +1,54 @@ +/* + * Kobo Deluxe Sound Effects + * + * IF YOU EDIT THIS FILE, YOU WILL NEED + * TO RECOMPILE THE KOBO DELUXE BINARY! + * + * NOTE: + * Songs use waves 16 and up by convention, so + * we need to stay away from those indices here! + */ + +#define SOUND_BGM 0 +#define SOUND_ONEUP 1 +#define SOUND_FINE 2 +#define SOUND_BEAM 3 +#define SOUND_RING 4 + +#define SOUND_BOMB_DETO 5 +#define SOUND_EXPLO_NODE1 6 +#define SOUND_EXPLO_NODE2 7 +#define SOUND_EXPLO_ENEMY1 8 +#define SOUND_EXPLO_ENEMY2 9 +#define SOUND_EXPLO_PLAYER 10 +#define SOUND_EXPLO_RING1 11 +#define SOUND_EXPLO_RING2 12 +#define SOUND_EXPLO_RING3 13 +#define SOUND_EXPLO_ROCK 14 + +#define SOUND_BZZZT 127 +#define SOUND_GAMEOVER 126 +#define SOUND_READY 125 +#define SOUND_PLAY 124 +#define SOUND_PAUSE 123 +#define SOUND_TITLE 122 +#define SOUND_CANCEL 121 +#define SOUND_LAUNCH2 120 +#define SOUND_LAUNCH 119 +#define SOUND_RUMBLE_NODE2 118 +#define SOUND_RUMBLE_NODE1 117 +#define SOUND_SHOT_START 116 +#define SOUND_SHOT 115 +#define SOUND_SHOT_END 114 +#define SOUND_SHOT_OVERHEAT 113 +#define SOUND_OVERHEAT 112 +#define SOUND_METALLIC3 111 +#define SOUND_METALLIC2 110 +#define SOUND_METALLIC1 109 +#define SOUND_DAMAGE 108 +#define SOUND_MOVE 107 +#define SOUND_HIT3 106 +#define SOUND_HIT2 105 +#define SOUND_HIT1 104 +#define SOUND_TICK 103 +#define SOUND_ENEMYM 102 diff --git a/data/sfx/launch.agw b/data/sfx/launch.agw new file mode 100644 index 0000000..8aa5a8c --- /dev/null +++ b/data/sfx/launch.agw @@ -0,0 +1,60 @@ +///////////////////////////////////////////// +// Turbine howl + acceleration stall noise +// Copyright (C) 2002, 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 12800, 0; + +//noise +w_env FREQUENCY, 0, 8000; +w_env AMPLITUDE, + .05, .03, + .05, .05, + .1, .08, + .5, 0; +w_env MOD1, 1; +w_osc target, NOISE; + +//low turbine +w_env AMPLITUDE, + .2, .03, + .6, 0; + +w_env FREQUENCY, + 0, 700, + .3, 1400, + .5, 1500; +w_env MOD1, .5; +w_osc target, TRIANGLE; + +w_env FREQUENCY, + 0, 800, + .3, 1600, + .5, 1750; +w_osc target, TRIANGLE; + +//high turbine +w_env AMPLITUDE, + .5, .04, + .3, 0; +w_env FREQUENCY, + 0, 2200, + .3, 3300, + .5, 3540; +w_env MOD1, 0; +w_osc target, SINE; + +//bp filter sweep +w_env FREQUENCY, + 0, 3000, + .15, 2000, + .05, 1000, + .6, 800; +w_env AMPLITUDE, + 0, 1.5, + .02, 1.5, + .01, 10, + .17, 8, + .6, 5; +w_filter target, BANDPASS_12; diff --git a/data/sfx/launch2.agw b/data/sfx/launch2.agw new file mode 100644 index 0000000..3ebd1d0 --- /dev/null +++ b/data/sfx/launch2.agw @@ -0,0 +1,73 @@ +///////////////////////////////////////////// +// "Open gate and eject!" +// Copyright (C) 2002, 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 5500, 0; + +//noise +w_env FREQUENCY, 0, 8000; +w_env AMPLITUDE, + .01, .1, + .01, .15, + .01, .02, + .15, .03, + .15, .01, + .01, 0; +w_env MOD1, 1; +w_osc target, NOISE; + +//bp filter sweep +w_env FREQUENCY, + 0, 4000, + .1, 2000, + .15, 2000, + .01, 1000; +w_env AMPLITUDE, 0, 13; +w_env MOD1, 0; +w_filter target, BANDPASS_12; + +//electro humming +w_env AMPLITUDE, + .01, .1, + .14, .2, + .05, 0; +w_env FREQUENCY, 0, 60; +w_env MOD1, + .2, .5; +w_osc target, SINE; + +//electro buzz +w_env AMPLITUDE, + .01, .01, + .14, .02, + .05, 0; +w_env FREQUENCY, + 0, 59, + .2, 60; +w_env MOD1, + 0, 0.5, + .2, 0.6; +w_osc target, PULSE; + +//tecno squeal +wf = SINE; +w_env AMPLITUDE, + .01, .02, + .14, .05, + .05, 0; +w_env MOD1, + .3, 1; +w_env FREQUENCY, + 0, 1000, + .3, 1500; +w_osc target, wf; +w_env FREQUENCY, + 0, 1200, + .3, 2000; +w_osc target, wf; +w_env FREQUENCY, + 0, 3500, + .3, 4000; +w_osc target, wf; diff --git a/data/sfx/launch3b.agw b/data/sfx/launch3b.agw new file mode 100644 index 0000000..12bce36 --- /dev/null +++ b/data/sfx/launch3b.agw @@ -0,0 +1,88 @@ +///////////////////////////////////////////// +// Teleport launch, short version +// Copyright (C) 2002, 2007 David Olofson +///////////////////////////////////////////// + +d = .7; + +w_format target, MONO16, 16000; +w_blank target, 16000*d, 0; + +//noise +w_env FREQUENCY, 0, 8000; +w_env AMPLITUDE, + d*.01, .1, + d*.01, .15, + d*.01, .02, + d*.15, .03, + d*.15, .01, + d*.17, 0; +w_env MOD1, 1; +w_osc target, NOISE; + +//bp filter sweep +w_env FREQUENCY, + 0, 4000, + d*.1, 2000, + d*.15, 2000, + d*.01, 1000; +w_env AMPLITUDE, 0, 13; +w_env MOD1, 3; +w_filter target, BANDPASS_12; + +//electro humming +w_env AMPLITUDE, + d*.01, .1, + d*.14, .3, + d*.35, .1, + d*.55, 0; +w_env FREQUENCY, + 0, 59, + d*.5, 60, + d*.5, 180; +w_env MOD1, + d*.2, .7, + d*.2, 2, + d*.1, 0; +w_osc target, SINE; + +//electro buzz +w_env AMPLITUDE, + d*.01, .1, + d*.14, .05, + d*.3, .1, + d*.05, .05, + d*.55, 0; +w_env FREQUENCY, + 0, 59, + d*.5, 60, + d*.5, 180; +w_env MOD1, + 0, .5, + d*.2, .6; +w_osc target, PULSE; + +//tecno squeal +w_env AMPLITUDE, + d*.01, .03, + d*.14, .1, + d*.05, .05, + d*.8, 0; +w_env MOD1, + d*.3, 2, + d*.7, 0; +procedure ts(f0) +{ + w_env FREQUENCY, + 0, f0, + d*.3, f0*1.1+400, + d*.1, f0, + d*.6, f0*3; + w_osc target, SINE; +} +ts(200); +ts(700); +ts(1500); +ts(2500); +ts(4000); +ts(5000); diff --git a/data/sfx/launch4.agw b/data/sfx/launch4.agw new file mode 100644 index 0000000..9b80203 --- /dev/null +++ b/data/sfx/launch4.agw @@ -0,0 +1,70 @@ +///////////////////////////////////////////// +// Boss teleport launch +// Copyright (C) 2002, 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 16000, 0; + +//noise +w_env FREQUENCY, 0, 8000; +w_env AMPLITUDE, + .01, .1, + .01, .15, + .01, .02, + .15, .03, + .15, .01, + .17, 0; +w_env MOD1, 1; +w_osc target, NOISE; + +//bp filter sweep +w_env FREQUENCY, + 0, 4000, + .1, 2000, + .15, 2000, + .01, 1000; +w_env AMPLITUDE, 0, 13; +w_env MOD1, 3; +w_filter target, BANDPASS_12; + +//electro buzz +w_env AMPLITUDE, + .01, .2, + .14, .05, + .3, .1, + .2, 0; +w_env FREQUENCY, + 0, 30, + .3, 60, + .2, 30, + .2, 10; +w_env MOD1, + 0, .5, + .5, .9; +w_osc target, PULSE; + +//tecno squeal +w_env AMPLITUDE, + .01, .03, + .14, .1, + .05, .05, + .8, 0; +w_env MOD1, + .3, 2, + .5, 0; +procedure ts(f0) +{ + w_env FREQUENCY, + 0, f0, + .3, f0*1.1+400, + .4, f0/2, + .3, f0*3; + w_osc target, SINE; +} +ts(150); +ts(500); +ts(1500); +ts(2500); +ts(4500); +ts(6500); diff --git a/data/sfx/metallic7.agw b/data/sfx/metallic7.agw new file mode 100644 index 0000000..36205b1 --- /dev/null +++ b/data/sfx/metallic7.agw @@ -0,0 +1,66 @@ +///////////////////////////////////////////// +// Metallic 7 +// Copyright (C) 2007, David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 48000; +w_blank target, 48000, 0; + +procedure cr(f, r) +{ + w_env FREQUENCY, + 0, 4.5*f, + .01, 4*f; + w_env MOD1, + 0, r*.8, + .01, r, + .99, r*.9; + w_env MOD2, + 0, 1, + .02, .5, + .08, .3, + .2, .05, + .8, 0; + w_osc target, ASPECTRUM; +} + +w_env AMPLITUDE, + 0, .1, + .1, .05, + .2, .02, + .2, .005, + .2, .00125, + .3, 0; + +cr 170, 1.3; +cr 270, 1.07; +cr 275, 1.09; +cr 560, 1.2; +cr 565, 1.3; +cr 773, 1.35; +cr 800, 1.15; + +w_env AMPLITUDE, + 0, .5, + .1, .1, + .1, 0, + .01, .2, + .1, .04, + .1, 0, + .01, .1, + .1, .02, + .1, 0, + .01, .05, + .1, .01, + .1, 0, + .01, .025, + .1, .005, + .06, 0; +w_env MOD1, + 0, 2, + .5, 3, + .5, 0; +w_env FREQUENCY, + 0, 50, + 1, 40; +w_osc target, SINE; diff --git a/data/sfx/metallic7rs.agw b/data/sfx/metallic7rs.agw new file mode 100644 index 0000000..fec0ce9 --- /dev/null +++ b/data/sfx/metallic7rs.agw @@ -0,0 +1,53 @@ +///////////////////////////////////////////// +// Metallic 7 R S - Reverse, short +// Copyright (C) 2007, David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 48000; +w_blank target, 24000, 0; + +procedure cr(f, r) +{ + w_env FREQUENCY, 4*f; + w_env MOD1, + 0, r*.9, + .49, r, + .01, r*.8; + w_env MOD2, + .3, .05, + .1, .3, + .08, .4, + .02, .7; + w_osc target, ASPECTRUM; +} + +w_env AMPLITUDE, + .15, .00125, + .1, .005, + .1, .02, + .1, .05, + .05, .1; + +cr 170, 1.3; +cr 270, 1.07; +cr 275, 1.09; +cr 560, 1.2; +cr 565, 1.3; +cr 773, 1.35; +cr 800, 1.15; + +w_env AMPLITUDE, + .08, .05, + .01, 0, + .1, .04, + .1, .2, + .01, 0, + .1, .1, + .1, .5; +w_env MOD1, + 0, 3, + .5, 2; +w_env FREQUENCY, + 0, 45, + .5, 50; +w_osc target, SINE; diff --git a/data/sfx/music.agw b/data/sfx/music.agw new file mode 100644 index 0000000..73de72c --- /dev/null +++ b/data/sfx/music.agw @@ -0,0 +1,9 @@ +///////////////////////////////////////////// +// Music loader script for Kobo Deluxe +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +#include "kobosfx.h" + +w_load SOUND_BGM, "trance1.agw"; +w_load SOUND_TITLE, "test2.agw"; diff --git a/data/sfx/music_c.agw b/data/sfx/music_c.agw new file mode 100644 index 0000000..536e184 --- /dev/null +++ b/data/sfx/music_c.agw @@ -0,0 +1,12 @@ +///////////////////////////////////////////// +// Music loader script for Kobo Deluxe +// (Cached version; uses prerendered sounds) +// Copyright (C) David Olofson, 2002, 2003 +///////////////////////////////////////////// + +#include "kobosfx.h" + +w_load SOUND_BGM, "trance1_c.agw"; + +// We don't bother caching the "one period of sine" waveform... :-) +w_load SOUND_TITLE, "test2.agw"; diff --git a/data/sfx/noiseburst2.agw b/data/sfx/noiseburst2.agw new file mode 100644 index 0000000..fe0ef1c --- /dev/null +++ b/data/sfx/noiseburst2.agw @@ -0,0 +1,25 @@ +///////////////////////////////////////////// +// Noise Burst 2 +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 16000, 0; + +w_env AMPLITUDE, + 0, .5, + .01, .06, + .12, .02, + .3, 0; +w_env FREQUENCY, 0, 6000; +w_osc target, NOISE; + +w_env AMPLITUDE, + 0, 10, + .02, 50, + .1, 20; +w_env FREQUENCY, + 0, 3000, + 0.01, 2093; +w_env MOD1; +w_filter target, BANDPASS_12; diff --git a/data/sfx/phattpad2.agw b/data/sfx/phattpad2.agw new file mode 100644 index 0000000..44e1a0c --- /dev/null +++ b/data/sfx/phattpad2.agw @@ -0,0 +1,52 @@ +///////////////////////////////////////////// +// Phatt Pad 2 +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +wid = target; + +w_format wid, MONO16, 33488; +w_blank wid, 33488, 1; + +// The exact desired frequency is 523.25 Hz, +// but as we need a perfect loop, we'll round +// all frequencies so that we get integer +// numbers of periods per loop. + +w_env AMPLITUDE, + 0, .15, + .25, .25, + .5, .25, + .25, .15; +w_env MOD1, + 0, 0, + .5, .1, + .5, 0; +w_env FREQUENCY, 519; +w_osc wid, TRIANGLE; +w_env FREQUENCY, 521; +w_osc wid, TRIANGLE; + +w_env MOD1, + 0, 0, + .2, .2, + .3, .07, + .3, .15, + .2, 0; +w_env FREQUENCY, 523; +w_osc wid, TRIANGLE; +w_env FREQUENCY, 526; +w_osc wid, TRIANGLE; + +p_param target, WAVE, wid; +p_param target, DRIVER, POLY; +p_param target, ENV_SKIP, 1; +p_param target, ENV_L0, 0; +p_param target, ENV_DELAY, 0; +p_param target, ENV_T1, .001; +p_param target, ENV_L1, 1; +p_param target, ENV_HOLD, .05; +p_param target, ENV_T2, .1; +p_param target, ENV_L2, .6; +p_param target, ENV_T3, -1; +p_param target, ENV_T4, .02; diff --git a/data/sfx/pioing1b.agw b/data/sfx/pioing1b.agw new file mode 100644 index 0000000..f827715 --- /dev/null +++ b/data/sfx/pioing1b.agw @@ -0,0 +1,48 @@ +///////////////////////////////////////////// +// Pioioioioio....ing 1 B +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 32000, 0; + +// Vibrato (w_mod not implemented...) +w_env FREQUENCY, 10; +w_env AMPLITUDE, 1; +w_osc target, SINE, FM; + +w_env AMPLITUDE, + 0, .5, + .1, .8, + .2, .6, + .2, .3, + .4, 0; +w_env FREQUENCY, + 0, 1200, + .01, 440; +w_env MOD1, + 0, .8, + .05, 2.5, + .05, 1.2, + .9, .5; +w_env BALANCE, .45; +w_osc target, SINE, FM; + +w_env AMPLITUDE, + .005, 1, + .03, 1, + .02, 0; +w_env FREQUENCY, + 0, 700, + .05, 220; +w_env MOD1, + 0, 1, + .05, 0; +w_osc target, SINE; + +w_env AMPLITUDE, 0; +w_env MOD1, 0; +w_env FREQUENCY, 2600; +w_filter target, NOTCH_12; +w_env FREQUENCY, 600; +w_filter target, NOTCH_12; diff --git a/data/sfx/rockexplo.agw b/data/sfx/rockexplo.agw new file mode 100644 index 0000000..0e25e81 --- /dev/null +++ b/data/sfx/rockexplo.agw @@ -0,0 +1,90 @@ +///////////////////////////////////////////// +// Rock Explosion +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 24000; +w_blank target, 24000, 0; + +// Rumble +w_env AMPLITUDE, + 0, 1/4, + .5, 1/8, + .5, 1/16; +w_env FREQUENCY, + 0, 200, + 1, 140; +w_osc target, NOISE; +w_env FREQUENCY, + 0, 200, + .5, 600, + .5, 200; +w_env AMPLITUDE, 1; +w_filter target, LOWPASS_12; + +// Ka-blam +w_env AMPLITUDE, + 0, 1/4, + .5, 1/8, + .5, 1/16; +w_env FREQUENCY, + 0, 1400, + .1, 400, + .1, 1400, + .8, 1700; +w_osc target, NOISE; +w_env FREQUENCY, + 0, 1000, + .1, 200, + .5, 600, + .4, 400; +w_osc target, NOISE; + +// Attack +w_env AMPLITUDE, + 0, 1/4, + .1, 1/16, + .1, 0; +w_env FREQUENCY, + 0, 10000, + .2, 0; +w_osc target, NOISE; + +// Mod +w_env AMPLITUDE, 1; +w_env FREQUENCY, 15; +w_env BALANCE, + 0, .5, + 1, 1; +w_osc target, NOISE, MUL; + +// Resonances +w_env FREQUENCY, 150; +w_env AMPLITUDE, 3; +w_filter target, PEAK_12; +w_env FREQUENCY, 400; +w_env AMPLITUDE, 3; +w_filter target, PEAK_12; +w_env FREQUENCY, 1750; +w_env AMPLITUDE, 2; +w_filter target, PEAK_12; +w_env FREQUENCY, 2100; +w_env AMPLITUDE, 2; +w_filter target, PEAK_12; +w_env FREQUENCY, 3700; +w_env AMPLITUDE, + 0, 3, + 1, 1; +w_filter target, PEAK_12; + +// Treble damping +w_env FREQUENCY, + 0, 24000, + .3, 6000, + .7, 1000; +w_filter target, LOWPASS_6; + +w_env AMPLITUDE, + 0, 1, + 1, .1; +w_gain target; \ No newline at end of file diff --git a/data/sfx/save_waves.agw b/data/sfx/save_waves.agw new file mode 100644 index 0000000..266788c --- /dev/null +++ b/data/sfx/save_waves.agw @@ -0,0 +1,60 @@ +////////////////////////////////////////// +// Script to write all sounds to disk +// Copyright (C) 2003, 2007 David Olofson +////////////////////////////////////////// + +#include "kobosfx.h" + +w_save SOUND_LAUNCH, "launch_c.raw"; +w_save SOUND_LAUNCH2, "launch2_c.raw"; + +w_save SOUND_BZZZT, "bzzzt1_c.raw"; +w_save SOUND_GAMEOVER, "gameover1_c.raw"; + +w_save SOUND_EXPLO_NODE1, "explo1b_c.raw"; +w_save SOUND_EXPLO_NODE2, "explo1c_c.raw"; +w_save SOUND_RUMBLE_NODE1, "explo1b-rg_c.raw"; +w_save SOUND_RUMBLE_NODE2, "explo1c-rg_c.raw"; +w_save SOUND_EXPLO_ENEMY1, "explo3d_c.raw"; +w_save SOUND_EXPLO_ENEMY2, "explo4d_c.raw"; +w_save SOUND_EXPLO_PLAYER, "explo6_c.raw"; +w_save SOUND_EXPLO_RING1, "explo5_c.raw"; +w_save SOUND_EXPLO_RING2, "explo5b_c.raw"; +w_save SOUND_EXPLO_RING3, "explo5c_c.raw"; +w_save SOUND_BOMB_DETO, "launch3b_c.raw"; +w_save SOUND_EXPLO_ROCK, "rockexplo_c.raw"; +w_save SOUND_FINE, "cannon1_c.raw"; +w_save SOUND_SHOT_START, "boltfire2s_c.raw"; +w_save SOUND_SHOT, "boltfire2_c.raw"; +w_save SOUND_SHOT_END, "boltfire2e_c.raw"; +w_save SOUND_SHOT_OVERHEAT, "boltfire2o_c.raw"; +w_save SOUND_OVERHEAT, "bleep3_c.raw"; +w_save SOUND_METALLIC1, "klank3_c.raw"; +w_save SOUND_METALLIC2, "klank3b_c.raw"; +w_save SOUND_METALLIC3, "klank3c_c.raw"; +w_save SOUND_DAMAGE, "klank4_c.raw"; +w_save SOUND_CANCEL, "bleep1_c.raw"; +w_save SOUND_PLAY, "metallic7_c.raw"; +w_save SOUND_PAUSE, "metallic7rs_c.raw"; +w_save SOUND_ONEUP, "pioing1b_c.raw"; +w_save SOUND_READY, "schwoop2_c.raw"; +w_save SOUND_MOVE, "schwoom1_c.raw"; +w_save SOUND_HIT1, "impact2_c.raw"; +w_save SOUND_HIT2, "impact2b_c.raw"; +w_save SOUND_HIT3, "impact2c_c.raw"; +w_save SOUND_TICK, "klank2b_c.raw"; +w_save SOUND_BEAM, "zapp1_c.raw"; +w_save SOUND_RING, "schwoop3_c.raw"; +w_save SOUND_ENEMYM, "launch4_c.raw"; + +w_save 16, "aguitar1_c.raw"; +w_save 30, "synbass1_c.raw"; +w_save 50, "snare1_c.raw"; +w_save 55, "edge2_c.raw"; +w_save 58, "bassdrum5_c.raw"; +w_save 60, "claps1_c.raw"; +w_save 63, "noiseburst2_c.raw"; +w_save 74, "phattpad2_c.raw"; +w_save 84, "hardsync1_c.raw"; +w_save 86, "brass2_c.raw"; +w_save 87, "thunder1_c.raw"; diff --git a/data/sfx/schwoom1.agw b/data/sfx/schwoom1.agw new file mode 100644 index 0000000..68ff8a4 --- /dev/null +++ b/data/sfx/schwoom1.agw @@ -0,0 +1,52 @@ +///////////////////////////////////////////// +// Schwoom 1 +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 8000, 0; + +// Low noise +w_env FREQUENCY, + 0, 1500, + .2, 150; +w_env AMPLITUDE, + .1, .5, + .1, .05, + .1, .01, + .2, 0; +w_osc target, NOISE; +w_env FREQUENCY, + .1, 600, + .1, 150; +w_env AMPLITUDE, 5; +w_filter target, PEAK_12; + +// High noise +w_env FREQUENCY, 8000; +w_env AMPLITUDE, + .05, .2, + .1, 0; +w_osc target, NOISE; + +// Mod +w_env AMPLITUDE, 1; +w_env FREQUENCY, 150; +w_env BALANCE, .5; +w_osc target, NOISE, MUL; + +// Bass +w_env AMPLITUDE, + .05, .5, + .15, .1, + .2, .05, + .1, 0; +w_env MOD1, + 0, 1, + .1, 2.5, + .1, .5, + .3, 0; +w_env FREQUENCY, + 0, 50, + .5, 45; +w_osc target, SINE; diff --git a/data/sfx/schwoop2.agw b/data/sfx/schwoop2.agw new file mode 100644 index 0000000..9017ac1 --- /dev/null +++ b/data/sfx/schwoop2.agw @@ -0,0 +1,56 @@ +///////////////////////////////////////////// +// Schwoop 2 +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 32000, 0; + +w_env AMPLITUDE, + .1, .02, + .8, .1, + .1, 0; +w_env FREQUENCY, + 0, 500, + 1, 1000; +w_osc target, NOISE; + +w_env FREQUENCY, + 0, 2000, + 1, 4000; +w_env AMPLITUDE, 5; +w_env MOD1, 0; +w_filter target, BANDPASS_12; + +w_env AMPLITUDE, + .1, .1, + .8, .2, + .1, 0; +w_env MOD1, + 0, 2, + 1, .5; +w_env FREQUENCY, + 0, 600, + 1, 1200; +w_osc target, SINE; + +w_env AMPLITUDE, + .1, .01, + .8, .1, + .1, 0; +w_env MOD1, 3; +w_env FREQUENCY, + 0, 300, + 1, 600; +w_osc target, SINE; + +w_env AMPLITUDE, + .5, .2, + .5, 0; +w_env MOD1, + .5, 1.5, + .5, 0; +w_env FREQUENCY, + 0, 50, + 1, 48; +w_osc target, SINE; diff --git a/data/sfx/schwoop3.agw b/data/sfx/schwoop3.agw new file mode 100644 index 0000000..e5c8057 --- /dev/null +++ b/data/sfx/schwoop3.agw @@ -0,0 +1,42 @@ +///////////////////////////////////////////// +// Schwoop 3 +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 16000*.4, 0; + +w_env FREQUENCY, 600; +w_env AMPLITUDE, + .1, .1, + .1, 0; +w_osc target, NOISE; + +w_env FREQUENCY, 12000; +w_env AMPLITUDE, + .02, .2, + .1, 0; +w_osc target, NOISE; + +w_env FREQUENCY, + 0, 500, + .1, 800, + .3, 1000; +w_env AMPLITUDE, 30; +w_env MOD1, + .02, .2, + .1, .1, + .1, 0; +w_filter target, BANDPASS_12; + +w_env AMPLITUDE, + .1, .02, + .3, 0; +w_env MOD1, + .2, 1, + .2, 0; +w_env FREQUENCY, + 0, 500, + .1, 800, + .3, 1000; +w_osc target, SINE; diff --git a/data/sfx/sfx.agw b/data/sfx/sfx.agw new file mode 100644 index 0000000..fd5ba4e --- /dev/null +++ b/data/sfx/sfx.agw @@ -0,0 +1,66 @@ +//////////////////////////////////////////////// +// Sound effect loader script for Kobo Deluxe +// Copyright (C) 2002, 2003, 2007 David Olofson +//////////////////////////////////////////////// + +#include "kobosfx.h" + +procedure load(pid, name, randpitch) +{ + wid = pid; + w_load wid, name; + p_param pid, WAVE, wid; + p_param pid, DRIVER, POLY; + p_param pid, RANDPITCH, randpitch; +} + +/* + * New for 0.4-pre7 (David Olofson) + */ +load SOUND_LAUNCH, "launch.agw", .6; +load SOUND_LAUNCH2, "launch2.agw", .2; + +/* + * New for 0.4.0 (David Olofson) + */ +load SOUND_BZZZT, "bzzzt1.agw", .3; +load SOUND_GAMEOVER, "gameover1.agw", .1; + +/* + * New for 0.5.1 (David Olofson) + */ +load SOUND_EXPLO_NODE1, "explo1b.agw", 1; +load SOUND_EXPLO_NODE2, "explo1c.agw", 1; +load SOUND_RUMBLE_NODE1, "explo1b-rg.agw", 2; +load SOUND_RUMBLE_NODE2, "explo1c-rg.agw", 2; +load SOUND_EXPLO_ENEMY1, "explo3d.agw", 2; +load SOUND_EXPLO_ENEMY2, "explo4d.agw", 1; +load SOUND_EXPLO_PLAYER, "explo6.agw", 0; +load SOUND_EXPLO_RING1, "explo5.agw", .5; +load SOUND_EXPLO_RING2, "explo5b.agw", .5; +load SOUND_EXPLO_RING3, "explo5c.agw", .5; +load SOUND_BOMB_DETO, "launch3b.agw", .4; +load SOUND_EXPLO_ROCK, "rockexplo.agw", 2; +load SOUND_FINE, "cannon1.agw", 0; +load SOUND_SHOT_START, "boltfire2s.agw", 1; +load SOUND_SHOT, "boltfire2.agw", 1; +load SOUND_SHOT_END, "boltfire2e.agw", 1; +load SOUND_SHOT_OVERHEAT, "boltfire2o.agw", 1; +load SOUND_OVERHEAT, "bleep3.agw", .1; +load SOUND_METALLIC1, "klank3.agw", .5; +load SOUND_METALLIC2, "klank3b.agw", .5; +load SOUND_METALLIC3, "klank3c.agw", .5; +load SOUND_DAMAGE, "klank4.agw", 0; +load SOUND_CANCEL, "bleep1.agw", .2; +load SOUND_PLAY, "metallic7.agw", 0; +load SOUND_PAUSE, "metallic7rs.agw", 0; +load SOUND_ONEUP, "pioing1b.agw", 0; +load SOUND_READY, "schwoop2.agw", 0; +load SOUND_MOVE, "schwoom1.agw", .5; +load SOUND_HIT1, "impact2.agw", 1.5; +load SOUND_HIT2, "impact2b.agw", 1.5; +load SOUND_HIT3, "impact2c.agw", 1.5; +load SOUND_TICK, "klank2b.agw", 0; +load SOUND_BEAM, "zapp1.agw", 1; +load SOUND_RING, "schwoop3.agw", 1.5; +load SOUND_ENEMYM, "launch4.agw", .5; diff --git a/data/sfx/sfx_c.agw b/data/sfx/sfx_c.agw new file mode 100644 index 0000000..0c78ff2 --- /dev/null +++ b/data/sfx/sfx_c.agw @@ -0,0 +1,58 @@ +//////////////////////////////////////////////// +// Sound effect loader script for Kobo Deluxe +// (Cached version; uses prerendered sounds) +// Copyright (C) 2002, 2003, 2007 David Olofson +//////////////////////////////////////////////// + +#include "kobosfx.h" + +procedure load(pid, name, randpitch) +{ + wid = pid; + w_load wid, name; + p_param pid, WAVE, wid; + p_param pid, DRIVER, POLY; + p_param pid, RANDPITCH, randpitch; +} + +load SOUND_LAUNCH, "launch_c.raw", .6; +load SOUND_LAUNCH2, "launch2_c.raw", .2; + +load SOUND_BZZZT, "bzzzt1_c.raw", .3; +load SOUND_GAMEOVER, "gameover1_c.raw", .1; + +load SOUND_EXPLO_NODE1, "explo1b_c.raw", 1; +load SOUND_EXPLO_NODE2, "explo1c_c.raw", 1; +load SOUND_RUMBLE_NODE1, "explo1b-rg_c.raw", 2; +load SOUND_RUMBLE_NODE2, "explo1c-rg_c.raw", 2; +load SOUND_EXPLO_ENEMY1, "explo3d_c.raw", 2; +load SOUND_EXPLO_ENEMY2, "explo4d_c.raw", 1; +load SOUND_EXPLO_PLAYER, "explo6_c.raw", 0; +load SOUND_EXPLO_RING1, "explo5_c.raw", .5; +load SOUND_EXPLO_RING2, "explo5b_c.raw", .5; +load SOUND_EXPLO_RING3, "explo5c_c.raw", .5; +load SOUND_BOMB_DETO, "launch3b_c.raw", .4; +load SOUND_EXPLO_ROCK, "rockexplo_c.raw", 2; +load SOUND_FINE, "cannon1_c.raw", 0; +load SOUND_SHOT_START, "boltfire2s_c.raw", 1; +load SOUND_SHOT, "boltfire2_c.raw", 1; +load SOUND_SHOT_END, "boltfire2e_c.raw", 1; +load SOUND_SHOT_OVERHEAT, "boltfire2o_c.raw", 1; +load SOUND_OVERHEAT, "bleep3_c.raw", .1; +load SOUND_METALLIC1, "klank3_c.raw", .5; +load SOUND_METALLIC2, "klank3b_c.raw", .5; +load SOUND_METALLIC3, "klank3c_c.raw", .5; +load SOUND_DAMAGE, "klank4_c.raw", 0; +load SOUND_CANCEL, "bleep1_c.raw", .2; +load SOUND_PLAY, "metallic7_c.raw", 0; +load SOUND_PAUSE, "metallic7rs_c.raw", 0; +load SOUND_ONEUP, "pioing1b_c.raw", 0; +load SOUND_READY, "schwoop2_c.raw", 0; +load SOUND_MOVE, "schwoom1_c.raw", .5; +load SOUND_HIT1, "impact2_c.raw", 1.5; +load SOUND_HIT2, "impact2b_c.raw", 1.5; +load SOUND_HIT3, "impact2c_c.raw", 1.5; +load SOUND_TICK, "klank2b_c.raw", 0; +load SOUND_BEAM, "zapp1_c.raw", 1; +load SOUND_RING, "schwoop3_c.raw", 1.5; +load SOUND_ENEMYM, "launch4_c.raw", .5; diff --git a/data/sfx/sine.agw b/data/sfx/sine.agw new file mode 100644 index 0000000..84e9178 --- /dev/null +++ b/data/sfx/sine.agw @@ -0,0 +1,25 @@ +///////////////////////////////////////////// +// Plain looped sine waveform +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +wid = target; + +w_format wid, MONO16, 33488; +w_blank wid, 128, 1; + +w_env FREQUENCY, 523.25; +w_osc wid, SINE; + +p_param target, WAVE, wid; +p_param target, DRIVER, POLY; +p_param target, ENV_SKIP, 1; +p_param target, ENV_L0, 0; +p_param target, ENV_DELAY, 0; +p_param target, ENV_T1, .001; +p_param target, ENV_L1, 1; +p_param target, ENV_HOLD, .01; +p_param target, ENV_T2, .05; +p_param target, ENV_L2, .5; +p_param target, ENV_T3, -1; +p_param target, ENV_T4, .1; diff --git a/data/sfx/snare1.agw b/data/sfx/snare1.agw new file mode 100644 index 0000000..988575a --- /dev/null +++ b/data/sfx/snare1.agw @@ -0,0 +1,45 @@ +///////////////////////////////////////////// +// Snare Drum 1 +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 32000, 0; + +w_env AMPLITUDE, + 0, .3, + .015, .07, + .08, .013, + .4, .003, + .5, 0; +w_env FREQUENCY, 0, 1200; +w_osc target, NOISE; +w_env FREQUENCY, 0, 4000; +w_osc target, NOISE; +w_env FREQUENCY, 0, 16000; +w_osc target, NOISE; + +w_env MOD1; +w_env AMPLITUDE, 0, 20; +w_env FREQUENCY, 0, 180; +w_filter target, PEAK_12; +w_env AMPLITUDE, 0, 10; +w_env FREQUENCY, 0, 260; +w_filter target, PEAK_12; + +//reverberation shaper +w_env AMPLITUDE, 0, 0; +w_env MOD1, + 0, 1, + .3, .6, + .7, .3; +w_env FREQUENCY, 0, 3500; +w_filter target, LOWPASS_12; + +//attack +w_env AMPLITUDE, 0, 10; +w_env FREQUENCY, 0, 1700; +w_env MOD1, + 0, 0, + .007, 1; +w_filter target, PEAK_12; diff --git a/data/sfx/synbass1.agw b/data/sfx/synbass1.agw new file mode 100644 index 0000000..c767ba4 --- /dev/null +++ b/data/sfx/synbass1.agw @@ -0,0 +1,40 @@ +///////////////////////////////////////////// +// Synth Bass 1 +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +w_format target, MONO16, 33488; +w_blank target, 33488, 0; + +//attack +w_env AMPLITUDE, + 0, .5, + .01, .1, + .4, 0; +w_env FREQUENCY, + 0, 4000, + .01, 1000; +w_osc target, NOISE; + +//bass +w_env AMPLITUDE, + 0, .9, + .01, .5, + .49, .3, + .5, 0; +w_env FREQUENCY, + 0, 200, + .01, 65.40625; +w_env MOD1, + 0, 1, + .5, .1, + .5, 0; +w_osc target, SINE; + +//filter +w_env AMPLITUDE, 1; +w_env FREQUENCY, + 0, 1500, + 0.1, 200; +w_env MOD1, 0; +w_filter target, LOWPASS_12; diff --git a/data/sfx/test2.agw b/data/sfx/test2.agw new file mode 100644 index 0000000..93a1efd --- /dev/null +++ b/data/sfx/test2.agw @@ -0,0 +1,15 @@ +///////////////////////////////////////////// +// MIDI Song Loader for "test2.mid" +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +print "Loading \"Test2\"...\n"; +print " Copyright (C) David Olofson, 2002.\n"; + +w_load target, "test2.mid"; +p_param target, WAVE, target; +p_param target, DRIVER, MIDI; + +w_load 32, "sine.agw"; + +print " Done!\n"; diff --git a/data/sfx/test2.mid b/data/sfx/test2.mid new file mode 100644 index 0000000..f373b7e Binary files /dev/null and b/data/sfx/test2.mid differ diff --git a/data/sfx/thunder1.agw b/data/sfx/thunder1.agw new file mode 100644 index 0000000..3dfac14 --- /dev/null +++ b/data/sfx/thunder1.agw @@ -0,0 +1,25 @@ +///////////////////////////////////////////// +// Thunder 1 +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +w_format target, MONO16, 16000; +w_blank target, 48000, 0; + +w_env AMPLITUDE, + 0, .1, + 1, 1, + 2, 0; +w_env FREQUENCY, 150; +w_osc target, NOISE; + +w_env FREQUENCY, 150; +w_env AMPLITUDE, 5; +w_filter target, LOWPASS_12; + +w_env AMPLITUDE, 0.80; +w_gain target; + +w_env FREQUENCY, 150; +w_env AMPLITUDE, 0; +w_filter target, LOWPASS_12; diff --git a/data/sfx/trance1.agw b/data/sfx/trance1.agw new file mode 100644 index 0000000..a1876e2 --- /dev/null +++ b/data/sfx/trance1.agw @@ -0,0 +1,25 @@ +///////////////////////////////////////////// +// MIDI Song Loader for "trance1.mid" +// Copyright (C) David Olofson, 2002 +///////////////////////////////////////////// + +print "Loading \"Trance1\"...\n"; +print " Copyright (C) David Olofson, 2002.\n"; + +w_load target, "trance1.mid"; +p_param target, WAVE, target; +p_param target, DRIVER, MIDI; + +w_load 16, "aguitar1.agw"; +w_load 30, "synbass1.agw"; +w_load 50, "snare1.agw"; +w_load 55, "edge2.agw"; +w_load 58, "bassdrum5.agw"; +w_load 60, "claps1.agw"; +w_load 63, "noiseburst2.agw"; +w_load 74, "phattpad2.agw"; +w_load 84, "hardsync1.agw"; +w_load 86, "brass2.agw"; +w_load 87, "thunder1.agw"; + +print " Done!\n"; diff --git a/data/sfx/trance1.mid b/data/sfx/trance1.mid new file mode 100644 index 0000000..13c68e7 Binary files /dev/null and b/data/sfx/trance1.mid differ diff --git a/data/sfx/trance1_c.agw b/data/sfx/trance1_c.agw new file mode 100644 index 0000000..0675044 --- /dev/null +++ b/data/sfx/trance1_c.agw @@ -0,0 +1,26 @@ +///////////////////////////////////////////// +// MIDI Song Loader for "trance1.mid" +// (Cached version; uses prerendered sounds) +// Copyright (C) David Olofson, 2002, 2003 +///////////////////////////////////////////// + +print "Loading \"Trance1\"...\n"; +print " Copyright (C) David Olofson, 2002.\n"; + +w_load target, "trance1.mid"; +p_param target, WAVE, target; +p_param target, DRIVER, MIDI; + +w_load 16, "aguitar1_c.raw"; +w_load 30, "synbass1_c.raw"; +w_load 50, "snare1_c.raw"; +w_load 55, "edge2_c.raw"; +w_load 58, "bassdrum5_c.raw"; +w_load 60, "claps1_c.raw"; +w_load 63, "noiseburst2_c.raw"; +w_load 74, "phattpad2_c.raw"; +w_load 84, "hardsync1_c.raw"; +w_load 86, "brass2_c.raw"; +w_load 87, "thunder1_c.raw"; + +print " Done!\n"; diff --git a/data/sfx/zapp1.agw b/data/sfx/zapp1.agw new file mode 100644 index 0000000..4d28f45 --- /dev/null +++ b/data/sfx/zapp1.agw @@ -0,0 +1,32 @@ +///////////////////////////////////////////// +// Zapp 1 +// Copyright (C) 2007 David Olofson +///////////////////////////////////////////// + +w_format target, MONO16, 32000; +w_blank target, 3200, 0; + +w_env AMPLITUDE, 1; +w_env FREQUENCY, 120; +w_osc target, SINE; + +w_env AMPLITUDE, + .02, 1, + .03, 1, + .05, 0; +w_env FREQUENCY, + 0, 1500, + .02, 400, + .08, 150; +w_env MOD1, + 0, 1.5, + .1, 0; +w_env BALANCE, 1; +w_osc target, SINE, MUL; + +w_env AMPLITUDE, 0; +w_env MOD1, 0; +w_env FREQUENCY, 2200; +w_filter target, NOTCH_12; +w_env FREQUENCY, 600; +w_filter target, NOTCH_12; diff --git a/depcomp b/depcomp new file mode 100755 index 0000000..6589965 --- /dev/null +++ b/depcomp @@ -0,0 +1,411 @@ +#! /bin/sh + +# depcomp - compile a program generating dependencies as side-effects +# Copyright 1999, 2000 Free Software Foundation, Inc. + +# 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, 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. + +# Originally written by Alexandre Oliva . + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi +# `libtool' can also be set to `yes' or `no'. + +depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. This file always lives in the current directory. + # Also, the AIX compiler puts `$object:' at the start of each line; + # $object doesn't have directory information. + stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + outname="$stripped.o" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +tru64) + # The Tru64 AIX compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + + tmpdepfile1="$object.d" + tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'` + if test "$libtool" = yes; then + "$@" -Wc,-MD + else + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + if test -f "$tmpdepfile1"; then + tmpdepfile="$tmpdepfile1" + else + tmpdepfile="$tmpdepfile2" + fi + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a space and a tab in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the proprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + test -z "$dashmflag" && dashmflag=-M + ( IFS=" " + case " $* " in + *" --mode=compile "*) # this is libtool, let us make it quiet + for arg + do # cycle over the arguments + case "$arg" in + "--mode=compile") + # insert --quiet before "--mode=compile" + set fnord "$@" --quiet + shift # fnord + ;; + esac + set fnord "$@" "$arg" + shift # fnord + shift # "$arg" + done + ;; + esac + "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + # X makedepend + ( + shift + cleared=no + for arg in "$@"; do + case $cleared in no) + set ""; shift + cleared=yes + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift;; + -*) + ;; + *) + set fnord "$@" "$arg"; shift;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tail +3 "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the proprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + ( IFS=" " + case " $* " in + *" --mode=compile "*) + for arg + do # cycle over the arguments + case $arg in + "--mode=compile") + # insert --quiet before "--mode=compile" + set fnord "$@" --quiet + shift # fnord + ;; + esac + set fnord "$@" "$arg" + shift # fnord + shift # "$arg" + done + ;; + esac + "$@" -E | + sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the proprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + ( IFS=" " + case " $* " in + *" --mode=compile "*) + for arg + do # cycle over the arguments + case $arg in + "--mode=compile") + # insert --quiet before "--mode=compile" + set fnord "$@" --quiet + shift # fnord + ;; + esac + set fnord "$@" "$arg" + shift # fnord + shift # "$arg" + done + ;; + esac + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 diff --git a/eel/Makefile.am b/eel/Makefile.am new file mode 100644 index 0000000..dc250d9 --- /dev/null +++ b/eel/Makefile.am @@ -0,0 +1,8 @@ +noinst_LIBRARIES = libeel.a + +INCLUDES = @LOCALCFLAGS@ + +libeel_a_SOURCES = eel.c e_script.c e_symtab.c e_path.c e_util.c \ + e_lexer.c e_register.c e_builtin.c e_getargs.c + +EXTRA_DIST = *.h *.txt diff --git a/eel/Makefile.in b/eel/Makefile.in new file mode 100644 index 0000000..ef6a128 --- /dev/null +++ b/eel/Makefile.in @@ -0,0 +1,434 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = eel +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/aconfig.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +libeel_a_AR = $(AR) $(ARFLAGS) +libeel_a_LIBADD = +am_libeel_a_OBJECTS = eel.$(OBJEXT) e_script.$(OBJEXT) \ + e_symtab.$(OBJEXT) e_path.$(OBJEXT) e_util.$(OBJEXT) \ + e_lexer.$(OBJEXT) e_register.$(OBJEXT) e_builtin.$(OBJEXT) \ + e_getargs.$(OBJEXT) +libeel_a_OBJECTS = $(am_libeel_a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libeel_a_SOURCES) +DIST_SOURCES = $(libeel_a_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUDIO_LIBS = @AUDIO_LIBS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_MACOSX_BUNDLE_FALSE = @BUILD_MACOSX_BUNDLE_FALSE@ +BUILD_MACOSX_BUNDLE_TRUE = @BUILD_MACOSX_BUNDLE_TRUE@ +BUILD_SIMPLE_BUNDLE_FALSE = @BUILD_SIMPLE_BUNDLE_FALSE@ +BUILD_SIMPLE_BUNDLE_TRUE = @BUILD_SIMPLE_BUNDLE_TRUE@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONFIGDIR = @CONFIGDIR@ +CONFIGFILE = @CONFIGFILE@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXEFILE = @EXEFILE@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LOCALCFLAGS = @LOCALCFLAGS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MATHLIB = @MATHLIB@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POW_LIB = @POW_LIB@ +RANLIB = @RANLIB@ +SCOREDIR = @SCOREDIR@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +UNIX_SCOREDIR_FALSE = @UNIX_SCOREDIR_FALSE@ +UNIX_SCOREDIR_TRUE = @UNIX_SCOREDIR_TRUE@ +VERSION = @VERSION@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +noinst_LIBRARIES = libeel.a +INCLUDES = @LOCALCFLAGS@ +libeel_a_SOURCES = eel.c e_script.c e_symtab.c e_path.c e_util.c \ + e_lexer.c e_register.c e_builtin.c e_getargs.c + +EXTRA_DIST = *.h *.txt +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign eel/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign eel/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libeel.a: $(libeel_a_OBJECTS) $(libeel_a_DEPENDENCIES) + -rm -f libeel.a + $(libeel_a_AR) libeel.a $(libeel_a_OBJECTS) $(libeel_a_LIBADD) + $(RANLIB) libeel.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/e_builtin.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/e_getargs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/e_lexer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/e_path.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/e_register.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/e_script.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/e_symtab.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/e_util.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eel.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-noinstLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/eel/_e_script.h b/eel/_e_script.h new file mode 100644 index 0000000..ca83ee9 --- /dev/null +++ b/eel/_e_script.h @@ -0,0 +1,40 @@ +/*(LGPL) +--------------------------------------------------------------------------- + _e_script.h - EEL source code management (Private) +--------------------------------------------------------------------------- + * Copyright (C) 2002, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _EEL__SCRIPT_H_ +#define _EEL__SCRIPT_H_ + +#include "eel.h" +#include "e_script.h" + +#define MAX_SCRIPTS 256 + +typedef struct script_t +{ + char *name; + unsigned char *data; + unsigned len; +} script_t; + +extern script_t eel_scripttab[MAX_SCRIPTS]; + + +#endif /*_EEL__SCRIPT_H_*/ diff --git a/eel/e_builtin.c b/eel/e_builtin.c new file mode 100644 index 0000000..fc60fe3 --- /dev/null +++ b/eel/e_builtin.c @@ -0,0 +1,462 @@ +/*(LGPL) +--------------------------------------------------------------------------- + e_builtin.c - EEL built-in commands and directives +--------------------------------------------------------------------------- + * Copyright (C) 2002, 2003, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define DBG(x) + +#include "kobolog.h" +#include "math.h" +#include "e_builtin.h" +#include "e_util.h" +#include "e_lexer.h" + + +/*---------------------------------------------------------- + Command Callbacks +----------------------------------------------------------*/ + +int eel_cmd_end(int argc, struct eel_data_t *argv) +{ + DBG(log_printf(DLOG, "end;\n");) + return 0; +} + + +int eel_cmd_set(int argc, struct eel_data_t *argv) +{ + eel_symbol_t *to; + eel_data_t *val; + + if(eel_get_args("nV(irsce)", &to, &val) != 2) + return -1; + + DBG(log_printf(DLOG, "set %s, ", eel_s_stringrep(to));) + DBG(log_printf(DLOG, "%s;\n", eel_d_stringrep(val));) + + eel_s_set(to, val); + + return 1; +} + + +int eel_cmd_print(int argc, struct eel_data_t *argv) +{ + int i; + for(i = 0; i < argc; ++i) + { + if(EDT_SYMREF == argv[i].type) + switch(argv[i].value.sym->type) + { + case EST_CONSTANT: + case EST_VARIABLE: + /* Print the *value* of these... */ + log_printf(ULOG, "%s", eel_d_stringrep( + &argv[i].value.sym->data)); + continue; + default: + break; + } + log_printf(ULOG, "%s", eel_d_stringrep(argv + i)); + } + + return 1; +} + + +/*---------------------------------------------------------- + Operator Callbacks +----------------------------------------------------------*/ + +static inline eel_datatypes_t promote(struct eel_data_t *left, + struct eel_data_t *right) +{ + if(left->type == right->type) + { + if(left->type == EDT_INTEGER || left->type == EDT_REAL) + return left->type; + else + { + eel_error("Operands of unsupported type!"); + return -1; + } + } + + if(left->type == EDT_INTEGER) + { + left->value.r = (double)left->value.i; + left->type = EDT_REAL; + } + else if(left->type != EDT_REAL) + { + eel_error("Left hand operand of unsupported type!"); + return -1; + } + + if(right->type == EDT_INTEGER) + { + right->value.r = (double)right->value.i; + right->type = EDT_REAL; + } + else if(right->type != EDT_REAL) + { + eel_error("Right hand operand of unsupported type!"); + return -1; + } + + return EDT_REAL; +} + + +int eel_op_add(int argc, struct eel_data_t *argv) +{ + eel_data_t *left = argv, *right = argv + 1; + DBG(log_printf(DLOG, "add ");) + if(argc != 2) + { + eel_error("Operator needs exactly two arguments!"); + return -1; + } + switch(promote(left, right)) + { + case EDT_REAL: + DBG(log_printf(DLOG, "%f, %f\n", left->value.r, right->value.r);) + left->value.r += right->value.r; + break; + case EDT_INTEGER: + DBG(log_printf(DLOG, "%d, %d\n", left->value.i, right->value.i);) + left->value.i += right->value.i; + break; + default: + return -1; + } + return 0; +} + + +int eel_op_sub(int argc, struct eel_data_t *argv) +{ + eel_data_t *left = argv, *right = argv + 1; + DBG(log_printf(DLOG, "sub ");) + if(argc != 2) + { + eel_error("Operator needs exactly two arguments!"); + return -1; + } + switch(promote(left, right)) + { + case EDT_REAL: + DBG(log_printf(DLOG, "%f, %f\n", left->value.r, right->value.r);) + left->value.r -= right->value.r; + break; + case EDT_INTEGER: + DBG(log_printf(DLOG, "%d, %d\n", left->value.i, right->value.i);) + left->value.i -= right->value.i; + break; + default: + return -1; + } + return 0; +} + + +int eel_op_mul(int argc, struct eel_data_t *argv) +{ + eel_data_t *left = argv, *right = argv + 1; + DBG(log_printf(DLOG, "mul ");) + if(argc != 2) + { + eel_error("Operator needs exactly two arguments!"); + return -1; + } + switch(promote(left, right)) + { + case EDT_REAL: + DBG(log_printf(DLOG, "%f, %f\n", left->value.r, right->value.r);) + left->value.r *= right->value.r; + break; + case EDT_INTEGER: + DBG(log_printf(DLOG, "%d, %d\n", left->value.i, right->value.i);) + left->value.i *= right->value.i; + break; + default: + return -1; + } + return 0; +} + + +int eel_op_div(int argc, struct eel_data_t *argv) +{ + eel_data_t *left = argv, *right = argv + 1; + DBG(log_printf(DLOG, "div ");) + if(argc != 2) + { + eel_error("Operator needs exactly two arguments!"); + return -1; + } + switch(promote(left, right)) + { + case EDT_REAL: + if(!right->value.r) + { + eel_error("Division by zero!"); + return -1; + } + DBG(log_printf(DLOG, "%f, %f\n", left->value.r, right->value.r);) + left->value.r /= right->value.r; + break; + case EDT_INTEGER: + if(!right->value.i) + { + eel_error("Division by zero!"); + return -1; + } + DBG(log_printf(DLOG, "%d, %d\n", left->value.i, right->value.i);) + left->value.i /= right->value.i; + break; + default: + return -1; + } + return 0; +} + + +int eel_op_mod(int argc, struct eel_data_t *argv) +{ + eel_data_t *left = argv, *right = argv + 1; + DBG(log_printf(DLOG, "mod ");) + if(argc != 2) + { + eel_error("Operator needs exactly two arguments!"); + return -1; + } + switch(promote(left, right)) + { + case EDT_REAL: + if(!right->value.r) + { + eel_error("Zero modulus!"); + return -1; + } + DBG(log_printf(DLOG, "%f, %f\n", left->value.r, right->value.r);) + left->value.r -= right->value.r * + floor(left->value.r / right->value.r); + break; + case EDT_INTEGER: + if(!right->value.i) + { + eel_error("Zero modulus!"); + return -1; + } + DBG(log_printf(DLOG, "%d, %d\n", left->value.i, right->value.i);) + left->value.i %= right->value.i; + break; + default: + return -1; + } + return 0; +} + + +int eel_op_pow(int argc, struct eel_data_t *argv) +{ + eel_data_t *left = argv, *right = argv + 1; + DBG(log_printf(DLOG, "pow ");) + if(argc != 2) + { + eel_error("Operator needs exactly two arguments!"); + return -1; + } + switch(promote(left, right)) + { + case EDT_REAL: + DBG(log_printf(DLOG, "%f, %f\n", left->value.r, right->value.r);) + left->value.r = pow(left->value.r, right->value.r); + break; + case EDT_INTEGER: + DBG(log_printf(DLOG, "%d, %d\n", left->value.i, right->value.i);) + left->value.i = pow(left->value.i, right->value.i); + break; + default: + return -1; + } + return 0; +} + + +/*---------------------------------------------------------- + Directive Callbacks +----------------------------------------------------------*/ + +int eel_dir_include(void) +{ + int h, res; + const char *fn; + + if(eel_parse_args(" ", '\n') < 0) + return -1; + + if(eel_get_args("s", &fn) < 0) + return -1; + + h = eel_load(fn); + if(h < 0) + { + eel_error("Couldn't include file \"%s\"!", fn); + return -1; + } + res = eel_run(h); + eel_free(h); + + if(res < 0) + return res; + else + return 1; +} + + +int eel_dir_define(void) +{ + eel_symbol_t *to; + eel_data_t *val; + int res; + + if(eel_parse_args(" ", '\n') < 0) + return -1; + + res = eel_get_args("n[V(irsce)]", &to, &val); + + if(res < 0) + return -1; + + switch(res) + { + case 1: + DBG(log_printf(DLOG, "#define\t%s\n", eel_s_stringrep(to));) + to->data.type = EDT_ILLEGAL; + to->data.value.i = 0; + to->type = EST_CONSTANT; + break; + case 2: + DBG(log_printf(DLOG, "#define\t%s\t%s\n", + eel_s_stringrep(to), eel_d_stringrep(val));) + eel_s_set(to, val); + to->type = EST_CONSTANT; + break; + default: + eel_error("Expected either one or two arguments!"); + return -1; + } + return res; +} + + +/*---------------------------------------------------------- + Special Callbacks +----------------------------------------------------------*/ + +static int _proc_func(void) +{ + const char *funcname; + eel_symbol_t *s; + int tk, res; + + /* Get function name */ + tk = eel_lex(0); + if(tk != TK_NEWSYM) + { + eel_error("Function/procedure name must be unique!"); + return -1; + } + funcname = eel_current.lval->value.s; + + /* Create function symbol */ + s = eel_s_new(funcname, EST_FUNCTION); + if(!s) + { + eel_error("INTERNAL ERROR: Failed to create " + "function/procedure symbol!"); + return -1; + } + + /* Check argument list */ + if(eel_lex(0) != '(') + { + eel_error("Expected '('!"); + return -1; + } + + /* Store the start of the *argument list*... :-) */ + s->data.value.a = bio_tell(eel_current.bio); + s->token = eel_current.script; + eel_push_scope(); + res = eel_parse_args(",", ')'); + eel_pop_scope(); + if(res < 0) + return -1; + + DBG(log_printf(DLOG, "Function/procedure '%s' defined; starting at %d.\n", + s->name, s->data.value.a);) + + /* Find start of body ("the code") */ + if(eel_lex(0) != '{') + { + eel_error("Expected '{'!"); + return -1; + } + + return 1; +} + +int eel_spec_function(void) +{ + int c; + + if(_proc_func() < 0) + return -1; + + /* QUICK HACK: Skip function body */ + while((c = bio_getchar(eel_current.bio)) != '}') + if(EOF == c) + { + eel_error("EOF inside function body!"); + return -1; + } + + return 1; +} + +int eel_spec_procedure(void) +{ + int c; + + if(_proc_func() < 0) + return -1; + + /* QUICK HACK: Skip procedure body */ + while((c = bio_getchar(eel_current.bio)) != '}') + if(EOF == c) + { + eel_error("EOF inside procedure body!"); + return -1; + } + + return 1; +} diff --git a/eel/e_builtin.h b/eel/e_builtin.h new file mode 100644 index 0000000..8970f7c --- /dev/null +++ b/eel/e_builtin.h @@ -0,0 +1,59 @@ +/*(LGPL) +--------------------------------------------------------------------------- + e_builtin.c - EEL built-in commands and directives +--------------------------------------------------------------------------- + * Copyright (C) 2002, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _EEL_BUILTIN_H_ +#define _EEL_BUILTIN_H_ + +#include "eel.h" + +/*---------------------------------------------------------- + Command Callbacks +----------------------------------------------------------*/ +int eel_cmd_end(int argc, struct eel_data_t *argv); +int eel_cmd_set(int argc, struct eel_data_t *argv); +int eel_cmd_print(int argc, struct eel_data_t *argv); + + +/*---------------------------------------------------------- + Operator Callbacks +----------------------------------------------------------*/ +int eel_op_add(int argc, struct eel_data_t *argv); +int eel_op_sub(int argc, struct eel_data_t *argv); +int eel_op_mul(int argc, struct eel_data_t *argv); +int eel_op_div(int argc, struct eel_data_t *argv); +int eel_op_mod(int argc, struct eel_data_t *argv); +int eel_op_pow(int argc, struct eel_data_t *argv); + + +/*---------------------------------------------------------- + Directive Callbacks +----------------------------------------------------------*/ +int eel_dir_include(void); +int eel_dir_define(void); + + +/*---------------------------------------------------------- + Special Callbacks +----------------------------------------------------------*/ +int eel_spec_function(void); +int eel_spec_procedure(void); + +#endif /*_EEL_BUILTIN_H_*/ diff --git a/eel/e_getargs.c b/eel/e_getargs.c new file mode 100644 index 0000000..adea3d9 --- /dev/null +++ b/eel/e_getargs.c @@ -0,0 +1,1023 @@ +/*(LGPL) +--------------------------------------------------------------------------- + e_getargs.c - scanf() style "argument fetcher" + expr. evaluator +--------------------------------------------------------------------------- + * Copyright (C) 2002, 2003, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include + +#include "kobolog.h" +#include "config.h" +#include "eel.h" +#include "e_lexer.h" +#include "e_util.h" +#include "e_builtin.h" + +#define DBG(x) + + +/*---------------------------------------------------------- + Argument list parser +----------------------------------------------------------*/ + +eel_data_t eel_arg_table[EEL_MAX_ARGS]; +int eel_arg_token_table[EEL_MAX_ARGS]; + +int eel_arg_count = 0; +eel_data_t *eel_args = eel_arg_table; +int *eel_arg_tokens = eel_arg_token_table; + + +int eel_grab_arg(void) +{ + if(eel_arg_count >= EEL_MAX_ARGS) + return -1; + + eel_arg_tokens[eel_arg_count] = eel_current.token; + + if(eel_current.lval) + { + if(EDT_SYMREF == eel_current.lval->type) + { + /* Kill "runaway indirection" right at it's root! */ + if(EDT_SYMREF == eel_current.lval->value.sym->data.type) + eel_d_copy(eel_current.lval, + &eel_current.lval->value.sym->data); + } + + /* + * Important: + * This is a *move* operation! This is + * to avoid copying external string + * buffers around, while still making + * sure the new eel_data_t gains true + * ownership of them. + */ + eel_args[eel_arg_count] = *eel_current.lval; + free(eel_current.lval); + eel_current.lval = NULL; + } + ++eel_arg_count; + return eel_arg_count; +} + + +void eel_clear_args(int first) +{ + int i; + for(i = first; i < eel_arg_count; ++i) + eel_d_freestring(eel_args + i); + eel_arg_count = first; +} + + +void eel_remove_arg(int pos) +{ + int i; + eel_d_freestring(eel_args + pos); + for(i = pos + 1; i < eel_arg_count; ++i) + { + eel_args[i-1] = eel_args[i]; + eel_arg_tokens[i-1] = eel_arg_tokens[i]; + } + --eel_arg_count; +} + + +/* + * Remove all arguments in the range ]start, end[. + * (That is, not including args 'start' or 'end'.) + */ +void eel_collapse(int start, int end) +{ + int i; + for(i = start + 1; i < end; ++i) + eel_remove_arg(i); +} + + +/* + * Try to convert 'd' into a value. If it's not + * possible, nothing will be done. + */ +static inline void resolve(eel_data_t *d) +{ + if(EDT_SYMREF == d->type) + switch(d->value.sym->type) + { + case EST_CONSTANT: + case EST_VARIABLE: + case EST_ENUM: + /* These are OK. */ + *d = d->value.sym->data; + break; + default: + break; + } +} + + +/* + * Steenkin' special case for a single unary minus before a term. + * (Could be recursive, call unary operator callbacks and stuff, + * but there are too many screaming babies here right now... :-) + */ +static inline int neg(int pos) +{ + eel_data_t *d; + if((EDT_SYMREF == eel_args[pos].type) && + (EST_OPERATOR == eel_args[pos].value.sym->type)) + { + DBG(log_printf(DLOG, "neg\n");) + if(eel_op_sub != eel_args[pos].value.sym->data.value.op.cb) + { + eel_error("No unary operator '%s'!", + eel_args[pos].value.sym->name); + return -1; + } + d = &eel_args[pos+1]; + if(!d) + { + eel_error("Expected operand for unary minus!"); + return -1; + } + resolve(d); + switch(d->type) + { + case EDT_REAL: /* Real */ + d->value.r = -d->value.r; + break; + case EDT_INTEGER: /* Integer */ + d->value.i = -d->value.i; + break; + case EDT_SYMREF: /* Symbol reference */ + eel_error("Chained unary operators not yet supported!"); + return -1; + case EDT_SYMTAB: /* Symbol table reference */ + case EDT_STRING: /* String */ + case EDT_CADDR: /* Code address */ + case EDT_SYMNAME: /* Name of a new symbol (String) */ + case EDT_OPERATOR: /* Operator callback */ + case EDT_DIRECTIVE: /* Directive parser callback */ + case EDT_SPECIAL: /* Special parser callback */ + case EDT_ILLEGAL: + eel_error("Illegal operation!"); + return -1; + } + eel_remove_arg(pos); + } + else + resolve(&eel_args[pos]); + return 0; +} + + +/* + * Recursively evaluate expression, taking operator + * precedence in account. The 'left' argument is the + * index of the left operand, which is also the + * target for the result, and must be followed by an + * operator and a valid right term. + * +FIXME: + * Note that a single unary minus is allowed as a + * part of each term, and will be evaluated here. + * This feature should be removed as soon as the + * new operator system is fully implemented. (Unary + * minus can then be implemented as just another EEL + * operator.) +/FIXME + * + * Returns the index of the last argument used, or a + * negative value, if the operation fails. + * +FIXME: Handle 0 returns from operators...? + */ +static int recursive_eval(int left) +{ + int right = left + 1; + if(neg(left) < 0) + return -1; + + while(right + 1 < eel_arg_count) + { + eel_symbol_t *op, *op2; + op = eel_args[right].value.sym; + if(neg(right + 1) < 0) + return -1; + + if(right + 2 < eel_arg_count) + { + op2 = eel_args[right + 2].value.sym; + if(op2->data.value.op.priority > op->data.value.op.priority) + { + int maxr = recursive_eval(right + 1); + eel_remove_arg(right); /* Remove operator */ + if(op->data.value.op.cb(2, eel_args + left) < 0) + return -1; + + eel_remove_arg(right); /* Remove right term */ + return maxr; + } + } + eel_remove_arg(right); /* Remove operator token */ + if(op->data.value.op.cb(2, eel_args + left) < 0) + return -1; + + eel_remove_arg(right); /* Remove right hand term */ + } + return right; +} + + +/* + * Evaluate expression, starting at position 'start' + * in the internal argument list. The whole expression + * will be replaced by a single term, stored in the + * 'start' position, and all terms after it will be + * deleted. + * + * Returns a token corresponding to the result type, + * or a negative value in case of an error. + */ +static int do_eval(int start) +{ + if(eel_arg_count - start > 1) + { + int right; +#if 0 +int i; +for(i = 0; i < start; ++i) + log_printf(D3LOG, " "); +log_printf(D3LOG, "do_eval(): "); +for(i = start; i < eel_arg_count; ++i) +{ + if(EDT_SYMREF == eel_args[i].type) + log_printf(D3LOG, "<%s, %d>", eel_symbol_is(eel_args[i].value.sym), + eel_arg_tokens[i]); + else + log_printf(D3LOG, "<%s, %d>", eel_data_is(&eel_args[i]), + eel_arg_tokens[i]); +} +log_printf(D3LOG, "\n"); +#endif + right = recursive_eval(start); + if(right < 0) + return -1; + + /* Check for bogus "terminating operator" */ + if(right < eel_arg_count) + { + eel_error("Expression syntax error!"); + return -1; + } + } + + /* Prepare and return result */ +/* eel_clear_args(start + 1);*/ + switch (eel_args[start].type) + { + case EDT_REAL: + eel_arg_tokens[start] = TK_RNUM; + break; + case EDT_INTEGER: + eel_arg_tokens[start] = TK_INUM; + break; + case EDT_STRING: + eel_arg_tokens[start] = TK_STRN; + break; + case EDT_SYMNAME: + eel_arg_tokens[start] = TK_NEWSYM; + break; + case EDT_SYMTAB: + /* + * Note: + * If we were to get a namespace reference, it would + * actually be an EDT_SYMREF referring to the namespace + * symbol, rather than a raw pointer to namespace + * symbol table itself. + */ + eel_error("Weird... do_eval() saw a symbol table reference."); + eel_arg_tokens[start] = -1; + break; + case EDT_SYMREF: + case EDT_OPERATOR: + case EDT_DIRECTIVE: + case EDT_SPECIAL: + eel_arg_tokens[start] = TK_SYMREF; + break; + default: + eel_error("Weird things going on in do_eval()!"); + eel_arg_tokens[start] = -1; + break; + } + return eel_arg_tokens[start]; +} + + +/* + * Grab, and if required, evaluate the next "token". + * + * This function will return a token, and when applicable, + * the corresponding eel_data_t already last in the argument + * list. + * + * Note that returned arguments may be results of evaluated + * expressions, rather than constants from the source. + * + * Also note that the function will stop at ')' tokens. This + * functions as a way of supporting the alternative LISP + * style function calls (required when functions are used + * inside argument lists and expressions). It's also a + * feature that's relied upon internally, to recursively + * resolve expressions containing parentheses. + */ +static int eval(int report_eoln) +{ + int tk = EOF; + int prev_tk; + int expect_operator = 0; + int tokens = 0; + int start = eel_arg_count; + int grab_and_return = 0; + eel_symbol_t *sym; + /* + * Get terms and operators, checking that we + * get term, operator(s), term,... etc. Stop + * and evaluate if the chain is broken, or + * any other token is seen. + */ + while(1) + { + prev_tk = tk; + tk = eel_lex(report_eoln); + switch(tk) + { + case TK_SYMREF: + sym = eel_current.lval->value.sym; + if(expect_operator) + { + if(EST_OPERATOR != sym->type) + { + eel_unlex(); + return do_eval(start); + } + expect_operator = 0; + } + else + if(EST_OPERATOR != sym->type) + expect_operator = 1; + break; + case TK_NEWSYM: + case TK_RNUM: + case TK_INUM: + case TK_STRN: + if(expect_operator) + { + eel_unlex(); + return do_eval(start); + } + expect_operator = !expect_operator; + break; + case '(': + if(eval(report_eoln) < 0) + return -1; + tk = eel_lex(report_eoln); + if(')' != tk) + { + eel_error("Unmatched '(' in expression!"); + return -1; + } + continue; + case ')': + if(0 == tokens) + /* Not part of the expression. */ + return ')'; + else + { + eel_unlex(); + return do_eval(start); + } + break; + default: + if(0 == tokens) + { + return tk; + } + else + { + eel_unlex(); + return do_eval(start); + } + } + if(eel_grab_arg() < 0) + { + eel_error("Argument overflow!"); + return -1; + } + if(grab_and_return) + return tk; + ++tokens; + } +} + + +int eel_parse_args(const char *separators, char terminator) +{ + int sep_required = (strchr(separators, ' ') == 0); + int expect_separator = 0; + int tk; + eel_current.arg = 1; + while( (tk = eval('\n' == terminator)) ) + { + if(tk == terminator) + return 0; + switch(tk) + { + case TK_SYMREF: + /* No operators here, please! */ + if(EST_OPERATOR == eel_args[eel_arg_count-1]. + value.sym->type) + { + eel_error("Incorrectly used operator!"); + eel_current.arg = 0; + return -1; + } + case TK_NEWSYM: + case TK_RNUM: + case TK_INUM: + case TK_STRN: + if(expect_separator) + { + eel_error("Argument separator expected!"); + eel_current.arg = 0; + return -1; + } + expect_separator = sep_required; + break; + default: + if(tk < 256) + if(strchr(separators, tk)) + { + expect_separator = 0; + ++eel_current.arg; + break; + } +/* eel_error("Unexpected token!");*/ + eel_current.arg = 0; + return -1; + } + } + eel_error("Unexpected end of file!"); + eel_current.arg = 0; + return -1; +} + + +/*---------------------------------------------------------- + Argument list fetcher +----------------------------------------------------------*/ + +/* + * Extract a "value" out of an argument. + * Only types marked in 'types' are accepted. + * + * If symrefs are accepted, the 'stypes' mask + * determines which symbol types are accepted. + * + * Returns NULL upon failure, or the address of + * a eel_data_t struct. + */ +static eel_data_t *get_value(eel_data_t *arg, int types, int stypes) +{ + eel_data_t *dat; + + dat = arg; + + /* Find actual source data */ +#if 0 + while(EDT_SYMREF == dat->type) +#else + if(EDT_SYMREF == dat->type) +#endif + { + switch(dat->value.sym->type) + { + case EST_ENUM: + /* Keep symref if enums are desired! */ + if(types & EDTM_SYMREF) + break; + case EST_CONSTANT: + case EST_VARIABLE: + dat = &dat->value.sym->data; + break; + default: + eel_error("Invalid argument!"); + return NULL; + } + } + + if((EDT_SYMREF == dat->type) && (types & EDTM_SYMREF)) + { + /* Check symbol type */ + if(!(stypes & (1<value.sym->type))) + { + eel_error("Wrong symbol type! (%s)", + eel_data_is(dat)); + return NULL; + } + return arg; + } + else + { + /* Check data type */ + if(!(types & (1<type))) + { + eel_error("Wrong data type! (%s)", + eel_data_is(dat)); + return NULL; + } + return dat; + } +} + + +/* + * Find the symbol table entry for the variable + * referenced by 'arg'. If 'arg' is not a symbol + * reference, or if the referenced symbol is not + * a variable, NULL is returned, otherwise the + * symbol is returned. + */ +static eel_symbol_t *get_variable(eel_data_t *arg) +{ + eel_symbol_t *sym; + + if(EDT_SYMREF != arg->type) + return NULL; + + sym = arg->value.sym; + + if(sym->type != EST_VARIABLE) + { + eel_error("Expected a variable, not %s!", eel_symbol_is(sym)); + return NULL; + } + return sym; +} + + +static int eel_get_argsv(int argc, struct eel_data_t *argv, + const char *fmt, va_list args) +{ + int parsing = 1; + int optional = 0; + int tuple = 0; + int using_tuple = 0; + const char *tuple_start = NULL; + int got = 0; + int flags; + eel_data_t *dat; + eel_symbol_t *sym; + va_list args_tuple_start; + + int *i; + double *r; + char **s; + eel_data_t **datp; + eel_symbol_t **symp; + + eel_current.arg = 1; + + va_copy(args_tuple_start, args); + + while(parsing > 0) + { + eel_data_t *a; + + /* Handle "harmless" control characters */ + switch(*fmt) + { + case 0: +/* case ')': For LISP style function calls */ + if(tuple_start) + { + /* + * We should never get here if + * we have an argument tuple! + */ + log_printf(ELOG,"eel eel_get_args(): Error in" + " format string; " + "unterminated argument" + "tuple!\n"); + parsing = -1; + continue; + } + if(!optional && (got < argc)) + { + eel_error("%d arguments required; got %d!", + got, argc); + parsing = -1; + continue; + } + parsing = 0; + continue; + case '<': + /* Argument tuple start */ + ++fmt; + va_end(args_tuple_start); + if(using_tuple) + { + log_printf(ELOG,"eel eel_get_args(): Error in" + " format string; " + "'<' inside tuple!\n"); + parsing = -1; + continue; + } + using_tuple = 1; + tuple_start = fmt; + va_copy(args_tuple_start, args); + continue; + case '>': + /* Argument tuple end */ + if(!tuple_start) + { + log_printf(ELOG,"eel eel_get_args(): Error in" + " format string; " + "'>' without '<'!\n"); + parsing = -1; + continue; + } + fmt = tuple_start; + va_end(args); + va_copy(args, args_tuple_start); + ++tuple; + continue; + case '[': + /* Optional arguments */ + optional = 1; + case ']': + ++fmt; + continue; + case '*': + /* Throw away this argument */ + ++fmt; + ++eel_current.arg; + continue; + case ',': + ++fmt; + continue; + default: + if(got < argc) + a = argv + got; + else + { + parsing = 0; + continue; + } + } + + /* Handle actual data extraction tokens */ + switch(*fmt) + { + case '?': + datp = va_arg(args, eel_data_t **); + datp[tuple] = a; + break; + case 'E': + symp = va_arg(args, eel_symbol_t **); + if(EDT_SYMREF != a->type) + { + eel_error("Not an enum constant!\n"); + parsing = -1; + continue; + } + symp[tuple] = a->value.sym; + + /* Handle variables containing symrefs! */ + if( (symp[tuple]->type == EST_VARIABLE) && + (symp[tuple]->data.type == EDT_SYMREF) ) + symp[tuple] = symp[tuple]->data.value.sym; + + if(symp[tuple]->type != EST_ENUM) + { + eel_error("%s, not an enum constant!", + eel_symbol_is(symp[tuple])); + parsing = -1; + continue; + } + break; + case 'V': + datp = va_arg(args, eel_data_t **); + if('(' == *(fmt+1)) + { + fmt += 2; + flags = 0; + while(*fmt != ')') + { + switch(*fmt) + { + case 0: + log_printf(ELOG,"Unexpected end" + " of control" + "string!\n"); + parsing = -1; + break; + case 'i': + flags |= EDTM_INTEGER; + break; + case 'r': + flags |= EDTM_REAL; + break; + case 's': + flags |= EDTM_STRING; + break; + case 'c': + flags |= EDTM_CADDR; + break; + case 'e': + flags |= EDTM_SYMREF; + break; + default: + log_printf(ELOG,"Unknown type" + " code '%c'!", + *fmt); + parsing = -1; + break; + } + if(parsing < 0) + break; + ++fmt; + } + if(parsing < 0) + continue; + } + else + flags = EDTM_REAL | EDTM_INTEGER | + EDTM_STRING | EDTM_CADDR; + datp[tuple] = get_value(a, flags, ESTM_ENUM); + if(!datp[tuple]) + { + parsing = -1; + continue; + } + break; + case 'e': + i = va_arg(args, int *); + if(a->type != EDT_SYMREF) + { + eel_error("Enum argument must be a symref, " + "not %s!", eel_data_is(a)); + parsing = -1; + continue; + } + sym = a->value.sym; + if(sym->type == EST_VARIABLE) + { + /* Follow reference */ + eel_data_t *sd = &sym->data; + if(sd->type == EDT_SYMREF) + if(sd->value.sym->type == EST_ENUM) + sym = sd->value.sym; + } + if(sym->type != EST_ENUM) + { + eel_error("Expected enumerated type, not %s!", + eel_symbol_is(sym)); + parsing = -1; + continue; + } + if(sym->token != *i) + { + /* Oops, inter-enum namespace conflict! + * See if we can find the same identifier + * in the *right* class... + */ + sym = eel_s_find_n_tk(sym, sym->name, *i); + if(!sym) + { + eel_error("Wrong enumeration class!"); + parsing = -1; + continue; + } + } + i[tuple] = sym->data.value.i; + break; + case 'f': + symp = va_arg(args, eel_symbol_t **); + if(EDT_SYMREF != a->type) + { + eel_error("Not a function!\n"); + parsing = -1; + continue; + } + symp[tuple] = a->value.sym; + + /* Handle variables containing symrefs! */ + if( (symp[tuple]->type == EST_VARIABLE) && + (symp[tuple]->data.type == EDT_SYMREF) ) + symp[tuple] = symp[tuple]->data.value.sym; + + if(symp[tuple]->type != EST_FUNCTION) + { + eel_error("%s, not a function!", + eel_symbol_is(symp[tuple])); + parsing = -1; + continue; + } + break; + case 'i': + i = va_arg(args, int *); + dat = get_value(a, EDTM_INTEGER | EDTM_REAL | EDTM_STRING, + 0); + if(!dat) + { + eel_error("Failed to cast argument to integer."); + parsing = -1; + continue; + } + switch(dat->type) + { + case EDT_REAL: + i[tuple] = (int)dat->value.r; + break; + case EDT_INTEGER: + i[tuple] = dat->value.i; + break; + case EDT_STRING: + i[tuple] = (int)atof(dat->value.s); + break; + default: + eel_error("INTERNAL: Got type I didn't ask for."); + parsing = -1; + continue; + } + break; + case 'n': + symp = va_arg(args, eel_symbol_t **); + symp[tuple] = get_variable(a); + if(!symp[tuple]) + { + if(a->type == EDT_SYMNAME) + symp[tuple] = eel_set_integer( + a->value.s, 0); + if(!symp[tuple]) + { + eel_error("Failed to create new symbol! '%s'", + a->value.s); + parsing = -1; + continue; + } + } + break; + case 'r': + r = va_arg(args, double *); + dat = get_value(a, EDTM_INTEGER | EDTM_REAL | EDTM_STRING, + 0); + if(!dat) + { + eel_error("Failed to cast argument to real."); + parsing = -1; + continue; + } + switch(dat->type) + { + case EDT_REAL: + r[tuple] = dat->value.r; + break; + case EDT_INTEGER: + r[tuple] = (double)dat->value.i; + break; + case EDT_STRING: + r[tuple] = atof(dat->value.s); + break; + default: + eel_error("INTERNAL: Got type I didn't ask for."); + parsing = -1; + continue; + } + break; + case 's': + s = va_arg(args, char **); + dat = get_value(a, EDTM_STRING, 0); + if(!dat) + { + eel_error("Failed to cast argument to string."); + parsing = -1; + continue; + } + switch(dat->type) + { +#if 0 +TODO: (String memory management problem) + case EDT_REAL: + break; + case EDT_INTEGER: + break; +#endif + case EDT_STRING: + s[tuple] = dat->value.s; + break; + default: + eel_error("INTERNAL: Got type I didn't ask for."); + parsing = -1; + continue; + } + break; + case 'v': + symp = va_arg(args, eel_symbol_t **); + symp[tuple] = get_variable(a); + if(!symp[tuple]) + { + parsing = -1; + continue; + } + break; + default: + eel_error("eel_get_args(): Error in format string; " + "unknown control char '%c'.\n", *fmt); + parsing = -1; + continue; + } + ++fmt; + ++got; + ++eel_current.arg; /* (For error messages) */ + } + va_end(args_tuple_start); + + if(parsing < 0) + return -1; /* Error exit! */ + + eel_current.arg = 0; + + if(!optional) + { + /* + * We *should* be at the end of the format string + * now. Let's check... + */ + while(*fmt) + { + switch(*fmt) + { + case '>': + case ']': + break; + default: + eel_error("Insufficient number of arguments!"); + return -1; + } + ++fmt; + } + } + + if(argc > got) + { + eel_error("Too many arguments!"); + eel_current.arg = 0; + return -1; + } + + return got; +} + + +int eel_get_args_from(int argc, struct eel_data_t *argv, const char *fmt, ...) +{ + int ret; + va_list args; + va_start(args, fmt); + ret = eel_get_argsv(argc, argv, fmt, args); + va_end(args); + return ret; +} + + +int eel_get_args(const char *fmt, ...) +{ + int ret; + va_list args; + va_start(args, fmt); + ret = eel_get_argsv(eel_arg_count, eel_args, fmt, args); + va_end(args); + return ret; +} + diff --git a/eel/e_lexer.c b/eel/e_lexer.c new file mode 100644 index 0000000..14c952d --- /dev/null +++ b/eel/e_lexer.c @@ -0,0 +1,419 @@ +/*(LGPL) +--------------------------------------------------------------------------- + e_lexer.c - EEL engine lexer +--------------------------------------------------------------------------- + * Copyright (C) 2002, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include + +#include "e_lexer.h" +#include "e_util.h" + + +int eel_get_unique_token() +{ + static int last = TK_USER; + return last++; +} + + +static char *lexbuf = NULL; +static int lexbuf_length = 0; + + +static int lexbuf_realloc(int len) +{ + char *nsb; + lexbuf_length = len * 5 / 4; + nsb = (char *)realloc(lexbuf, lexbuf_length + 1); + if(!nsb) + { + eel_error("EEL lexer out of memory!"); + return -1; + } + lexbuf = nsb; + return 0; +} + + +static inline int lexbuf_bump(int len) +{ + if(len >= lexbuf_length) + return lexbuf_realloc(len); + return 0; +} + + +void eel_lexer_cleanup(void) +{ + if(eel_current.lval) + { + eel_d_freestring(eel_current.lval); + free(eel_current.lval); + eel_current.lval = NULL; + } + free(lexbuf); + lexbuf = NULL; + lexbuf_length = 0; +} + + +static int skipwhite(int report_eoln) +{ + int c; + /* Ignore whitespace and get first nonwhite character. */ + while((c = bio_getchar(eel_current.bio)) == ' ' || c == '\t' || + c == '\r' || c == '\n') + if((c == '\n') && report_eoln) + return c; + return c; +} + + +static eel_data_t *newdata(eel_datatypes_t type) +{ + eel_data_t *d = (eel_data_t *)calloc(1, sizeof(eel_data_t)); + if(!d) + return NULL; + d->type = type; + return d; +} + + +static int get_figure(bio_file_t *h, int base) +{ + int n = bio_getchar(h); + if(n >= '0' && n <= '9') + n -= '0'; + else if(n >= 'a' && n <= 'z') + n -= 'a'; + else if(n >= 'A' && n <= 'Z') + n -= 'A'; + else + return -1; + if(n >= base) + return -1; + return n; +} + + +static int get_num(bio_file_t *h, int base, int figures) +{ + int value = 0; + while(figures--) + { + int n = get_figure(h, base); + if(n < 0) + return n; + value *= base; + value += n; + } + return value; +} + + +/* + * Parse quoted string. + * C printf "backslash codes" are supported, + * as well as "\dXXX", for decimal codes. + */ +static int parse_string(bio_file_t *h) +{ + int c, len = 0; + while((c = bio_getchar(h)) != '"') + { + switch(c) + { + case EOF: + eel_error("EOF inside string literal!"); + return TK_ERROR; + case '\\': + c = bio_getchar(h); + switch(c) + { + case EOF: + eel_error("EOF inside string escape sequence!"); + return -1; + case '0': + c = get_num(h, 8, 3); + if(c < 0) + { + eel_error("Illegal octal figure!"); + return TK_ERROR; + } + break; + case 'a': + c = '\a'; + break; + case 'b': + c = '\b'; + break; + case 'c': + c = '\0'; + break; + case 'd': + c = get_num(h, 10, 2); + if(c < 0) + { + eel_error("Illegal decimal figure!"); + return TK_ERROR; + } + break; + case 'f': + c = '\f'; + break; + case 'n': + c = '\n'; + break; + case 'r': + c = '\r'; + break; + case 't': + c = '\t'; + break; + case 'v': + c = '\v'; + break; + case 'x': + c = get_num(h, 16, 2); + if(c < 0) + { + eel_error("Illegal hex figure!"); + return TK_ERROR; + } + break; + default: + break; + } + break; + default: + break; + } + lexbuf_bump(len + 1); + lexbuf[len++] = c; + } + lexbuf[len] = 0; + eel_current.lval = newdata(EDT_STRING); + if(!eel_current.lval) + return TK_ERROR; + eel_d_setstring(eel_current.lval, lexbuf); + return TK_STRN; +} + + +static inline int token(int tk) +{ + eel_current.token = tk; + return tk; +} + +/* + * Pass 1 for 'report_eoln' to get '\n' back whenever a + * newline occurs in the source. + * + * Note that newlines inside comments are *always* treated + * as white space! + */ +int eel_lex(int report_eoln) +{ + int c, prevc; + int negative = 0, directive = 0; + bio_file_t *h = eel_current.bio; + eel_symbol_t *s; + + /* Handle eel_unlex() pushbacks */ + if(eel_current.unlexed) + { + eel_current.unlexed = 0; + return eel_current.token; + } + + /* In case someone should ignore an lval... */ + if(eel_current.lval) + { + eel_d_freestring(eel_current.lval); + free(eel_current.lval); + eel_current.lval = NULL; + } + + while(1) + { + c = skipwhite(report_eoln); + if(c == EOF) + return token(0); + + /* /X comment tokens */ + if(c == '/') + { + switch ((c = bio_getchar(h))) + { + case '/': /* C++ style single line comment */ + while(EOF != (c = bio_getchar(h))) + if('\n' == c) + break; + continue; + case '*': /* C style comment */ + prevc = 0; + while(EOF != (c = bio_getchar(h))) + { + if(('/' == c) && ('*' == prevc)) + break; + else + prevc = c; + } + continue; + default: + bio_ungetc(h); + c = '/'; + break; + } + } + break; + } + + /* + * Char starts a number => parse the number. + * Note: This never returns an EDT_INTEGER! + */ + if(c == '.' || isdigit(c)) + { + bio_ungetc(h); + eel_current.lval = newdata(EDT_REAL); + if(!eel_current.lval) + return token(TK_ERROR); + eel_current.lval->value.r = bio_strtod(h); + if(negative) + eel_current.lval->value.r = -eel_current.lval->value.r; + return token(TK_RNUM); + } + + negative = 0; + + /* + * (Multi)character literal (cast to integer) + * Note that this is always little endian, so + * it's safe to use for "FourCC" identifiers + * and the like. + */ + if('\'' == c) + { + eel_current.lval = newdata(EDT_INTEGER); + if(!eel_current.lval) + return token(TK_ERROR); + eel_current.lval->value.i = 0; + while((c = bio_getchar(h)) != '\'') + { + if(EOF == c) + { + eel_error("EOF inside character literal!"); + return token(TK_ERROR); + } + eel_current.lval->value.i <<= 8; + eel_current.lval->value.i |= c; + } + return token(TK_INUM); + } + + /* String literal */ + if('"' == c) + return token(parse_string(h)); + + /* Check for "preprocessor" directives */ + if('#' == c) + { + directive = 1; + c = bio_getchar(h); + } + + /* Char starts an identifier => read the name. */ + if(isalpha(c) || ('_' == c)) + { + int len = 1; + int start = bio_tell(h) - 1; + while((isalnum(c = bio_getchar(h)) || ('_' == c)) && (EOF != c)) + ++len; + + if(lexbuf_bump(len) < 0) + return token(TK_ERROR); + bio_seek(h, start, SEEK_SET); + bio_read(h, lexbuf, len); + lexbuf[len] = '\0'; + + if(directive) + { + directive = 0; + s = eel_s_find_n_t(NULL, lexbuf, EST_DIRECTIVE); + if(!s) + { + eel_error("Unknown directive '%s'!", + lexbuf); + return token(TK_ERROR); + } + if(s->type != EST_DIRECTIVE) + { + eel_error("Preprocessor directive expected!"); + return token(TK_ERROR); + } + eel_current.lval = newdata(EDT_SYMREF); + eel_current.lval->value.sym = s; + return token(TK_SYMREF); + } + else + { + s = eel_s_find(NULL, lexbuf); + if(s) + { + eel_current.lval = newdata(EDT_SYMREF); + eel_current.lval->value.sym = s; + return token(TK_SYMREF); + } + else + { + eel_current.lval = newdata(EDT_SYMNAME); + eel_d_setstring(eel_current.lval, lexbuf); + return token(TK_NEWSYM); + } + } + } + + /* Look for valid operator characters */ + if(strchr("+-*/^<>~&%@!|$", (char)c)) + { + lexbuf[0] = c; + lexbuf[1] = 0; + s = eel_s_find_n_t(NULL, lexbuf, EST_OPERATOR); + if(!s) + { + eel_error("Unknown operator '%s'!", lexbuf); + return token(TK_ERROR); + } + eel_current.lval = newdata(EDT_SYMREF); + eel_current.lval->value.sym = s; + return token(TK_SYMREF); + } + + return token(c); +} + + +void eel_unlex(void) +{ + eel_current.unlexed = 1; +} diff --git a/eel/e_lexer.h b/eel/e_lexer.h new file mode 100644 index 0000000..4e9d1b8 --- /dev/null +++ b/eel/e_lexer.h @@ -0,0 +1,65 @@ +/*(LGPL) +--------------------------------------------------------------------------- + e_lexer.h - EEL engine lexer +--------------------------------------------------------------------------- + * Copyright (C) 2002, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _EEL_LEXER_H_ +#define _EEL_LEXER_H_ + +#include "eel.h" + + +/*---------------------------------------------------------- + Tokens and Unique User Token management +----------------------------------------------------------*/ + +/* Errors... */ +#define TK_ERROR -1 /* Lexer complains about something */ + +/* Immediate arguments */ +#define TK_RNUM 300 /* Real number */ +#define TK_INUM 301 /* Integer number */ +#define TK_STRN 302 /* String literal */ + +/* Symbol reference */ +#define TK_SYMREF 303 + +/* New symbol */ +#define TK_NEWSYM 304 + +#define TK_USER 1024 + +int eel_get_unique_token(); + + +/*---------------------------------------------------------- + The Lexer +----------------------------------------------------------*/ +/* Get next "token" */ +int eel_lex(int report_eoln); + +/* + * Push back last token + lval. + * Works only for *one* token per context! + */ +void eel_unlex(void); + +void eel_lexer_cleanup(void); + +#endif /*_EEL_LEXER_H_*/ diff --git a/eel/e_path.c b/eel/e_path.c new file mode 100644 index 0000000..f3871db --- /dev/null +++ b/eel/e_path.c @@ -0,0 +1,60 @@ +/*(LGPL) +--------------------------------------------------------------------------- + e_path.c - EEL file +--------------------------------------------------------------------------- + * Copyright (C) 2002, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include + +#include "eel.h" + + +/*---------------------------------------------------------- + File System Interface (Hah! :-) +----------------------------------------------------------*/ + +static char *_eel_path = NULL; + + +void eel_set_path(const char *path) +{ + if(_eel_path) + free(_eel_path); + if(path) + _eel_path = strdup(path); + else + _eel_path = NULL; +} + + +const char *eel_path(void) +{ + if(!_eel_path) + { +#if defined(WIN32) + eel_set_path(""); +#elif defined(MACOS) + eel_set_path(""); +#else + eel_set_path("./"); +#endif + } + return _eel_path; +} + diff --git a/eel/e_register.c b/eel/e_register.c new file mode 100644 index 0000000..e62e1af --- /dev/null +++ b/eel/e_register.c @@ -0,0 +1,89 @@ +/*(LGPL) +--------------------------------------------------------------------------- + e_register.c - EEL extension registry +--------------------------------------------------------------------------- + * Copyright (C) 2002, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "e_register.h" +#include "e_symtab.h" +#include "e_lexer.h" + +eel_symbol_t *_register(const char *name, eel_symtypes_t stype, + eel_datatypes_t type) +{ + eel_symbol_t *s = eel_s_new(name, stype); + if(!s) + return (eel_symbol_t *)0; + s->data.type = type; + return s; +} + + +int eel_register_operator(const char *name, eel_operator_cb_t handler, + int priority, int retargs, int preargs) +{ + eel_symbol_t *s = _register(name, EST_OPERATOR, EDT_OPERATOR); + if(!s) + return -1; + + s->token = eel_get_unique_token(); + s->data.value.op.priority = priority; + s->data.value.op.retargs = retargs; + s->data.value.op.preargs = preargs; + s->data.value.op.cb = handler; + return s->token; +} + + +int eel_register_enum_class(void) +{ + return eel_get_unique_token(); +} + + +int eel_register_enum(int eclass, const char *name, int value) +{ + eel_symbol_t *s = _register(name, EST_ENUM, EDT_INTEGER); + if(!s) + return -1; + s->token = eclass; + s->data.value.i = value; + return 0; +} + + +int eel_register_directive(const char *name, eel_parser_cb_t parser) +{ + eel_symbol_t *s = _register(name, EST_DIRECTIVE, EDT_DIRECTIVE); + if(!s) + return -1; + s->token = eel_get_unique_token(); + s->data.value.parse = parser; + return 0; +} + + +int eel_register_special(const char *name, eel_parser_cb_t parser) +{ + eel_symbol_t *s = _register(name, EST_SPECIAL, EDT_SPECIAL); + if(!s) + return -1; + s->token = eel_get_unique_token(); + s->data.value.parse = parser; + return 0; +} diff --git a/eel/e_register.h b/eel/e_register.h new file mode 100644 index 0000000..458cf47 --- /dev/null +++ b/eel/e_register.h @@ -0,0 +1,96 @@ +/*(LGPL) +--------------------------------------------------------------------------- + e_register.h - EEL extension registry +--------------------------------------------------------------------------- + * Copyright (C) 2002, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _EEL_REGISTER_H_ +#define _EEL_REGISTER_H_ + +#include "eel.h" + +/*---------------------------------------------------------- + Language Extension API +----------------------------------------------------------*/ + +/* + * Register an EEL operator. ("The real thing") + * + * (This is the "direct to the metal" interface; you may want + * to use eel_register_cmd_operator(), eel_register_func_operator() + * or eel_register_math_operator() instead most of the time.) + * + * The callback should check the types and number of + * arguments (easily done with eel_get_args()), and return + * 1 upon success, -1 in case of an error, or 0 if the script + * should be terminated. + * + * Operator precendence in expressions is controlled by means + * of operator priorities specified when operators are + * registered. EEL built-in operators also have priorities, + * and these are of course put in relation to the ones + * specified for extension operators; + * '=' (assignment) 0 (always lowest) + * '+' '-' (add, sub) 10 + * '*' '/' '%' (mul, div, mod) 20 + * '^' (power) 30 + * (command and function operators) 100 + * + * 'retargs' is the number of return arguments, and 'preargs' + * is the number of arguments that must be placed *before* the + * operator token. (Only normal, "post operator token" argument + * lists can be variable length!) + * + * The return value is the command's unique token, or a + * negative value upon failure. + */ +int eel_register_operator(const char *name, eel_operator_cb_t handler, + int priority, int retargs, int preargs); + +/* Register a new enum class. The unique token is returned. */ +int eel_register_enum_class(void); + +/* + * Add enum constant to specified enum class. + * + * A negative value is returned if the operation fails. + */ +int eel_register_enum(int eclass, const char *name, int value); + +/* + * Register a directive. + * + * A directive is similar to a command, but can optionally be + * invoked with a '#' before it's name. It does argument + * parsing itself, which provides more detailed control. + * + * A negative value is returned if the operation fails. + */ +int eel_register_directive(const char *name, int (*parser)(void)); + +/* + * Register a special. + * + * A special does argument parsing itself, like a directive, + * but the # syntax is not valid. + * + * A negative value is returned if the operation fails. + */ +int eel_register_special(const char *name, int (*parser)(void)); + +#endif /*_EEL_REGISTER_H_*/ diff --git a/eel/e_script.c b/eel/e_script.c new file mode 100644 index 0000000..71e9f73 --- /dev/null +++ b/eel/e_script.c @@ -0,0 +1,159 @@ +/*(LGPL) +--------------------------------------------------------------------------- + e_script.c - EEL source code management +--------------------------------------------------------------------------- + * Copyright (C) 2002, David Olofson + * Copyright (C) 2002, Florian Schulze + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include + +#include "config.h" +#include "_e_script.h" +#include "e_util.h" + +#define DBG(x) + + +/*---------------------------------------------------------- + Script source management +----------------------------------------------------------*/ + +script_t eel_scripttab[MAX_SCRIPTS]; + +int eel_script_alloc() +{ + int h = 0; + while(h < MAX_SCRIPTS) + { + if(!eel_scripttab[h].data) + return h; + ++h; + } + return -1; +} + + +int eel_load(const char *filename) +{ + FILE *f; + int h = eel_script_alloc(); + if(h < 0) + return h; + + /* Construct full name with path */ + eel_scripttab[h].name = malloc(strlen(filename) + + strlen(eel_path()) + 2); + if(!eel_scripttab[h].name) + return -1; + strcpy(eel_scripttab[h].name, eel_path()); +#ifdef WIN32 + strcat(eel_scripttab[h].name, "\\"); +#elif defined MACOS + strcat(eel_scripttab[h].name, ":"); +#else + strcat(eel_scripttab[h].name, "/"); +#endif + strcat(eel_scripttab[h].name, filename); + + f = fopen(eel_scripttab[h].name, "rb"); + if(!f) + return -1; + + if(fseek(f, 0, SEEK_END) == 0) + { + eel_scripttab[h].len = ftell(f); + if(fseek(f, 0, SEEK_SET) == 0) + { + eel_scripttab[h].data = (unsigned char *)malloc( + eel_scripttab[h].len + 1); + if(eel_scripttab[h].data) + { + if(fread(eel_scripttab[h].data, + eel_scripttab[h].len, + 1, f) == 1) + { + fclose(f); + DBG(log_printf(DLOG, "Loaded script \"%s\"." + " (Handle %d)\n", + eel_scripttab[h].name, + h);) + return h; + } + DBG(printf("eel_load(): Read error!\n");) + eel_free(h); + } + DBG(printf("eel_load(): Memory allocation error!\n");) + } + DBG(printf("eel_load(): Rewind error!\n");) + } + DBG(printf("eel_load(): Seek-to-end error!\n");) + fclose(f); + return -2; +} + + +int eel_load_from_mem(const char *script, unsigned len) +{ + char name_buffer[128]; + int h = eel_script_alloc(); + if(h < 0) + return h; + + /* Construct name */ + snprintf(name_buffer, 127, "mem_script (%p, %u)", script, len); + name_buffer[127] = '\0'; + eel_scripttab[h].name = (char *)malloc(strlen(name_buffer) + 1); + if(!eel_scripttab[h].name) + return -1; + + strcpy(eel_scripttab[h].name, name_buffer); + + eel_scripttab[h].len = len; + eel_scripttab[h].data = + (unsigned char *)malloc(eel_scripttab[h].len + 1); + if(!eel_scripttab[h].data) + { + DBG(printf("eel_load_from_mem(): Memory allocation error!\n");) + return -2; + } + memcpy(eel_scripttab[h].data, script, len); + DBG(printf("Loaded script \"%s\" (Handle %d)\n", + eel_scripttab[h].name, h);) + return h; +} + + +void eel_free(int handle) +{ + if(handle < 0) + return; + if(handle > MAX_SCRIPTS) + return; + if(!eel_scripttab[handle].data) + return; + + DBG(printf("Freeing script \"%s\". (Handle %d)\n", + eel_scripttab[handle].name, handle);) + free(eel_scripttab[handle].data); + eel_scripttab[handle].data = NULL; + free(eel_scripttab[handle].name); + eel_scripttab[handle].name = NULL; + eel_scripttab[handle].len = 0; +} diff --git a/eel/e_script.h b/eel/e_script.h new file mode 100644 index 0000000..b7c6e03 --- /dev/null +++ b/eel/e_script.h @@ -0,0 +1,29 @@ +/*(LGPL) +--------------------------------------------------------------------------- + e_script.h - EEL source code management (API) +--------------------------------------------------------------------------- + * Copyright (C) 2002, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _EEL_SCRIPT_H_ +#define _EEL_SCRIPT_H_ + +int eel_load(const char *filename); +int eel_load_from_mem(const char *script, unsigned len); +void eel_free(int handle); + +#endif /*_EEL_SCRIPT_H_*/ diff --git a/eel/e_symtab.c b/eel/e_symtab.c new file mode 100644 index 0000000..8947423 --- /dev/null +++ b/eel/e_symtab.c @@ -0,0 +1,444 @@ +/*(LGPL) +--------------------------------------------------------------------------- + symtab.c - Simple symbol table for EEL +--------------------------------------------------------------------------- + * Copyright (C) 2000-2003, 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "config.h" + +#include +#include +#include + +#include "kobolog.h" +#include "e_symtab.h" + +#define DBG(x) + +#define STRINGREP_SIZE 128 + +#define MAX_SCOPES 32 + + +/*------------------------------------------------ + Data container +------------------------------------------------*/ + +int eel_d_copy(eel_data_t *data, const eel_data_t *from) +{ + eel_d_freestring(data); + switch (from->type) + { + case EDT_ILLEGAL: + case EDT_REAL: + case EDT_INTEGER: + case EDT_CADDR: + case EDT_SYMREF: + case EDT_SYMTAB: + case EDT_OPERATOR: + case EDT_DIRECTIVE: + case EDT_SPECIAL: + *data = *from; + return 1; + case EDT_STRING: + case EDT_SYMNAME: + data->type = from->type; + return eel_d_setstring(data, from->value.s); + } + return -1; +} + +int eel_d_setstring(eel_data_t *data, const char *s) +{ + if((EDT_STRING == data->type) || (EDT_SYMNAME == data->type)) + free(data->value.s); + else + data->type = EDT_STRING; + data->value.s = (char *)malloc(strlen(s) + 1); + if(data->value.s < 0) + return -1; + strcpy(data->value.s, s); + return 0; +} + +void eel_d_grabstring(eel_data_t *data, char *s) +{ + if((EDT_STRING == data->type) || (EDT_SYMNAME == data->type)) + free(data->value.s); + else + data->type = EDT_STRING; + data->value.s = s; +} + +void eel_d_freestring(eel_data_t *data) +{ + if((data->type != EDT_STRING) && (data->type != EDT_SYMNAME)) + return; + free(data->value.s); + data->value.s = 0; +} + +/* NOTE: Output string only valid until next call. */ +const char *eel_d_stringrep(eel_data_t * data) +{ + static char buf[STRINGREP_SIZE]; + switch (data->type) + { + case EDT_ILLEGAL: + return ""; + case EDT_REAL: + snprintf(buf, STRINGREP_SIZE, "%.10g", data->value.r); + return buf; + case EDT_INTEGER: + snprintf(buf, STRINGREP_SIZE, "%d", data->value.i); + return buf; + case EDT_STRING: + case EDT_SYMNAME: + if(data->value.s) + { + strncpy(buf, data->value.s, STRINGREP_SIZE); + return buf; + } + else + return ""; + case EDT_SYMTAB: + return ""; + case EDT_CADDR: + snprintf(buf, STRINGREP_SIZE, "%x", data->value.a); + return buf; + case EDT_SYMREF: + return eel_s_stringrep(data->value.sym); + case EDT_OPERATOR: + if(data->value.s) + { + snprintf(buf, STRINGREP_SIZE, "(%s)", + data->value.s); + return buf; + } + else + return ""; + case EDT_DIRECTIVE: + if(data->value.s) + { + snprintf(buf, STRINGREP_SIZE, "(#%s)", + data->value.s); + return buf; + } + else + return ""; + case EDT_SPECIAL: + if(data->value.s) + { + snprintf(buf, STRINGREP_SIZE, "(%s)", + data->value.s); + return buf; + } + else + return ""; + default: + return ""; + } +} + + +/*------------------------------------------------ + Symbol table +------------------------------------------------*/ + +/* The symbol table: a chain of `struct symrec'. */ +static eel_symbol_t *eel_s_table[MAX_SCOPES]; + +static int _current_scope = 0; +static int _deepest_scope = 0; + + +int eel_s_open(void) +{ + memset(eel_s_table, 0, sizeof(eel_s_table)); + _current_scope = 0; + _deepest_scope = 0; + return 0; +} + + +void eel_s_close(void) +{ + eel_s_freeall(); +} + + +eel_symbol_t *eel_s_new(const char *name, eel_symtypes_t type) +{ + eel_symbol_t *sym; + sym = (eel_symbol_t *) calloc(1, sizeof(eel_symbol_t)); + if(!sym) + { + log_printf(ELOG, "eel_s_new: Out of memory!\n"); + return 0; + } + sym->name = strdup(name); + sym->type = type; + switch (type) + { + case EST_UNDEFINED: + break; + case EST_CONSTANT: + case EST_VARIABLE: + sym->data.type = EDT_REAL; /* Default type */ + break; + case EST_LABEL: + case EST_FUNCTION: + sym->data.type = EDT_CADDR; + break; + case EST_OPERATOR: + sym->data.type = EDT_OPERATOR; + break; + case EST_DIRECTIVE: + sym->data.type = EDT_DIRECTIVE; + break; + case EST_SPECIAL: + sym->data.type = EDT_SPECIAL; + break; + case EST_ENUM: + sym->data.type = EDT_INTEGER; /* For the value */ + break; + case EST_NAMESPACE: + sym->data.type = EDT_SYMTAB; + default: + log_printf(ELOG, "internal error: created" + " symbol of undef type\n"); + } + sym->next = (struct eel_symbol_t *)eel_s_table[_current_scope]; + eel_s_table[_current_scope] = sym; + return sym; +} + +static void _free_scope(int scope) +{ + eel_symbol_t *sym, *nextptr; + for(sym = eel_s_table[scope]; sym; sym = nextptr) + { + nextptr = (eel_symbol_t *) sym->next; + eel_d_freestring(&sym->data); + free(sym->name); + free(sym); + } + eel_s_table[scope] = (eel_symbol_t *)0; +} + +void eel_s_freeall(void) +{ + int scope; + for(scope = 0; scope < MAX_SCOPES; ++scope) + _free_scope(scope); +} + +eel_symbol_t *eel_s_find(eel_symbol_t * sym, const char *eel_s_name) +{ + int scope = _current_scope; + while(scope >= 0) + { + if(!sym) + sym = eel_s_table[scope]; + for(; sym; sym = (eel_symbol_t *) sym->next) + if(strcmp(sym->name, eel_s_name) == 0) + return sym; + sym = NULL; + --scope; + } + return NULL; +} + +eel_symbol_t *eel_s_find_n_tk(eel_symbol_t * sym, const char *eel_s_name, int token) +{ + int scope = _current_scope; + while(scope >= 0) + { + if(!sym) + sym = eel_s_table[scope]; + for(; sym; sym = (eel_symbol_t *) sym->next) + if((sym->token == token) && + (strcmp(sym->name, eel_s_name) == 0)) + return sym; + sym = NULL; + --scope; + } + return NULL; +} + +eel_symbol_t *eel_s_find_tk(eel_symbol_t * sym, int token) +{ + int scope = _current_scope; + while(scope >= 0) + { + if(!sym) + sym = eel_s_table[scope]; + for(; sym; sym = (eel_symbol_t *) sym->next) + if(sym->token == token) + return sym; + sym = NULL; + --scope; + } + return NULL; +} + +eel_symbol_t *eel_s_find_n_t(eel_symbol_t * sym, const char *eel_s_name, + eel_symtypes_t type) +{ + int scope = _current_scope; + while(scope >= 0) + { + if(!sym) + sym = eel_s_table[scope]; + for(; sym; sym = (eel_symbol_t *) sym->next) + if((sym->type == type) && + (strcmp(sym->name, eel_s_name) == 0)) + return sym; + --scope; + } + return NULL; +} + +eel_symbol_t *eel_s_find_t(eel_symbol_t * sym, eel_symtypes_t type) +{ + int scope = _current_scope; + while(scope >= 0) + { + if(!sym) + sym = eel_s_table[scope]; + for(; sym; sym = (eel_symbol_t *) sym->next) + if(sym->type == type) + return sym; + --scope; + } + return NULL; +} + +/* NOTE: Output string only valid until next call. */ +const char *eel_s_stringrep(eel_symbol_t * sym) +{ + static char buf[STRINGREP_SIZE]; + switch (sym->type) + { + case EST_UNDEFINED: + snprintf(buf, STRINGREP_SIZE, "", + sym->name); + return buf; + case EST_CONSTANT: + strncpy(buf, eel_d_stringrep(&sym->data), STRINGREP_SIZE); + return buf; + case EST_VARIABLE: + case EST_LABEL: + case EST_FUNCTION: + case EST_OPERATOR: + case EST_DIRECTIVE: + case EST_SPECIAL: + case EST_ENUM: + case EST_NAMESPACE: + strncpy(buf, sym->name, STRINGREP_SIZE); + return buf; + default: + return ""; + } +} + + +/*------------------------------------------------ + Scope/Namespace Management +------------------------------------------------*/ + +int eel_push_scope(void) +{ + if(_deepest_scope >= MAX_SCOPES-1) + { + log_printf(ELOG, "EEL ERROR: Too deep scope nesting!\n"); + return -1; + } + ++_deepest_scope; + _current_scope = _deepest_scope; + DBG(log_printf(DLOG, "eel_push_scope(): current scope = %d\n", _current_scope);) + return 0; +} + + +int eel_pop_scope(void) +{ + if(!_deepest_scope) + { + log_printf(ELOG, "EEL ERROR: Tried to pop root scope!\n"); + return -1; + } + _free_scope(_deepest_scope); + --_deepest_scope; + _current_scope = _deepest_scope; + DBG(log_printf(DLOG, "eel_pop_scope(): current scope = %d\n", _current_scope);) + return 0; +} + + +int eel_scope(void) +{ + return _current_scope; +} + + +int eel_set_scope(int ns) +{ + if(ns < 0 || ns > _deepest_scope) + { + log_printf(ELOG, "EEL ERROR: Tried to select illegal scope!\n"); + return -1; + } + _current_scope = ns; + return 0; +} + + +void eel_restore_scope(void) +{ + _current_scope = _deepest_scope; +} + + +/*------------------------------------------------ + Symbol table tools +------------------------------------------------*/ + +eel_symbol_t *eel_s_get(const char *name, eel_symtypes_t type) +{ + eel_symbol_t *sym = eel_s_find(NULL, name); + if(sym) + { + if(sym->type == type) + return sym; + else + { + log_printf(ELOG, "eel_s_integer: '%s' is of" + " the wrong type!\n", name); + return NULL; + } + } + else + return eel_s_new(name, type); +} + + +int eel_s_set(eel_symbol_t *sym, const eel_data_t *dat) +{ + return eel_d_copy(&sym->data, dat); +} diff --git a/eel/e_symtab.h b/eel/e_symtab.h new file mode 100644 index 0000000..3a0bea1 --- /dev/null +++ b/eel/e_symtab.h @@ -0,0 +1,239 @@ +/*(LGPL) +--------------------------------------------------------------------------- + symtab.h - Simple symbol table for EEL +--------------------------------------------------------------------------- + * Copyright (C) 2000, 2002, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _EEL_SYMTAB_H_ +#define _EEL_SYMTAB_H_ + + +/*------------------------------------------------ + Data container +------------------------------------------------*/ + +struct eel_symbol_table_t; +struct eel_symbol_t; +struct eel_data_t; + +typedef int (*eel_operator_cb_t)(int argc, struct eel_data_t *argv); +typedef int (*eel_parser_cb_t)(void); + +/* Native datatypes */ +typedef enum +{ + EDT_ILLEGAL = 0, + EDT_REAL, /* Real */ + EDT_INTEGER, /* Integer */ + EDT_STRING, /* String */ + EDT_CADDR, /* Code address */ + EDT_SYMREF, /* Symbol reference */ + EDT_SYMTAB, /* Symbol Table Reference (for namespaces) */ + EDT_SYMNAME, /* Name of a new symbol (String) */ + EDT_OPERATOR, /* Operator callback */ + EDT_DIRECTIVE, /* Directive parser callback */ + EDT_SPECIAL /* Special parser callback */ +} eel_datatypes_t; + +#define EDTM_ILLEGAL (1< callback; token = priority */ + EST_DIRECTIVE, /* data -> callback */ + EST_SPECIAL, /* data -> callback */ + EST_ENUM, /* token = enum type; data.i = enum value */ + EST_NAMESPACE /* data -> namespace symbol table */ +} eel_symtypes_t; + +#define ESTM_UNDEFINED (1< +#include +#include + +#include "kobolog.h" +#include "e_util.h" +#include "eel.h" + +#include "_e_script.h" + + +/*---------------------------------------------------------- + "stdio" style API for raw memory buffers +----------------------------------------------------------*/ + +bio_file_t *bio_open(void *data, int len) +{ + bio_file_t *bio = malloc(sizeof(bio_file_t)); + if(!bio) + return NULL; + bio->data = (unsigned char *)data; + bio->len = len; + bio->pos = 0; + return bio; +} + + +bio_file_t *bio_clone(bio_file_t *bio) +{ + bio_file_t *c = malloc(sizeof(bio_file_t)); + if(!c) + return NULL; + *c = *bio; + return c; +} + + +void bio_close(bio_file_t *bio) +{ + free(bio); +} + + +int bio_seek(bio_file_t *bio, int offset, int whence) +{ + switch(whence) + { + case SEEK_SET: + bio->pos = offset; + break; + case SEEK_CUR: + bio->pos += offset; + break; + case SEEK_END: + bio->pos = bio->len - offset; + break; + } + if(bio->pos < 0) + bio->pos = 0; + else if(bio->pos > bio->len) + bio->pos = bio->len; + return 0; +} + + +int bio_read(bio_file_t *bio, char *buf, int count) +{ + if(bio->pos + count > bio->len) + count = bio->len - bio->pos; + memcpy(buf, bio->data + bio->pos, count); + bio->pos += count; + return count; +} + + +double bio_strtod(bio_file_t *bio) +{ + char *p = (char *)bio->data + bio->pos; + double val; + val = strtod(p, &p); + bio->pos = p - (char *)bio->data; + return val; +} + + +/*---------------------------------------------------------- + Context management ("VM stack") +----------------------------------------------------------*/ + +eel_context_t eel_current = { + NULL, + NULL, + -1, + 0, + 0, + EOF, + NULL +}; + +static eel_context_t *context_stack = NULL; + + +void eel_push_context(void) +{ + eel_context_t *c = malloc(sizeof(eel_context_t)); + if(!c) + { + eel_error("INTERNAL ERROR: Failed to push context!"); + return; + } + memcpy(c, &eel_current, sizeof(eel_context_t)); + c->previous = context_stack; + context_stack = c; +} + + +void eel_pop_context(void) +{ + eel_context_t *c = context_stack; + if(!c) + { + eel_error("INTERNAL ERROR: No context to pop!"); + return; + } + memcpy(&eel_current, c, sizeof(eel_context_t)); + context_stack = c->previous; + if(c->lval) + { + eel_d_freestring(c->lval); + free(c->lval); + } + free(c); +} + + + +/*---------------------------------------------------------- + Error handling tools +----------------------------------------------------------*/ + +static int last_script = -1; + +int eel_error(const char *format, ...) +{ + int count = 0; + va_list args; + int i, pos, line = 1; + + /* Figure out which line we're at... */ + pos = bio_tell(eel_current.bio); + bio_seek(eel_current.bio, 0, SEEK_SET); + for(i = 0; i < pos; ++i) + if('\n' == bio_getchar(eel_current.bio)) + ++line; + + if((eel_current.script >= 0) && (eel_current.script != last_script)) + { + count = log_printf(ELOG, "(EEL) in file \"%s\":\n", + eel_scripttab[eel_current.script].name); + last_script = eel_current.script; + } + if(eel_current.arg) + count += log_printf(ELOG, "(EEL) line %d, arg %d: ", + line, eel_current.arg); + else + count += log_printf(ELOG, "(EEL) line %d: ", line); + va_start(args, format); + count += vfprintf(stderr, format, args); + va_end(args); + count += log_printf(ELOG, "\n"); + return count; +} + +const char *eel_symbol_is(eel_symbol_t *s) +{ + switch(s->type) + { + case EST_UNDEFINED: return "an undedined symbol"; + case EST_CONSTANT: return "a constant"; + case EST_VARIABLE: return "a variable"; + case EST_LABEL: return "a label"; + case EST_FUNCTION: return "a function"; + case EST_OPERATOR: return "an operator"; + case EST_DIRECTIVE: return "a directive"; + case EST_SPECIAL: return "a special"; + case EST_ENUM: return "an enum constant"; + case EST_NAMESPACE: return "a namespace"; + } + /* + * Should be here, and not under default:, to get + * a warning if we forget to add new types. :-) + */ + return "a broken symbol! (illegal type)"; +} + +const char *eel_data_is(eel_data_t *d) +{ + switch(d->type) + { + case EDT_ILLEGAL: return "an illegal value"; + case EDT_REAL: return "a real value"; + case EDT_INTEGER: return "an integer value"; + case EDT_STRING: return "a string"; + case EDT_CADDR: return "a code address"; + case EDT_SYMREF: return "a symbol reference"; + case EDT_SYMTAB: return "a symbol table pointer"; + case EDT_SYMNAME: return "a (new) symbol name"; + case EDT_OPERATOR: return "an operator callback pointer"; + case EDT_DIRECTIVE: return "a directive callback pointer"; + case EDT_SPECIAL: return "a special callback pointer"; + } + return "a broken value! (illegal type)"; +} + + diff --git a/eel/e_util.h b/eel/e_util.h new file mode 100644 index 0000000..7124a35 --- /dev/null +++ b/eel/e_util.h @@ -0,0 +1,107 @@ +/*(LGPL) +--------------------------------------------------------------------------- + e_util.h - EEL engine utilities +--------------------------------------------------------------------------- + * Copyright (C) 2002, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _EEL_UTIL_H_ +#define _EEL_UTIL_H_ + +#include +#include "eel.h" + + +/*---------------------------------------------------------- + "stdio" style API for raw memory buffers +----------------------------------------------------------*/ + +typedef struct bio_file_t +{ + unsigned char *data; + int len; + int pos; +} bio_file_t; + +bio_file_t *bio_open(void *data, int len); +bio_file_t *bio_clone(bio_file_t *bio); +void bio_close(bio_file_t *bio); + +/* Get the next character from the buffer */ +static inline int bio_getchar(bio_file_t *bio) +{ + if(bio->pos < bio->len) + return bio->data[bio->pos++]; + else + return EOF; +} + +/* Push last character back */ +static inline void bio_ungetc(bio_file_t *bio) +{ + if(bio->pos > 0) + --bio->pos; +} + +/* + * Get the current source buffer position + */ +static inline int bio_tell(bio_file_t *bio) +{ + return bio->pos; +} + +/* + * Set the current source buffer position + */ +int bio_seek(bio_file_t *bio, int offset, int whence); + +/* + * Read 'count' bytes from the source code, + * starting at the current position, into + * 'buf'. Returns the number of bytes + * actually read. + */ +int bio_read(bio_file_t *bio, char *buf, int count); + +double bio_strtod(bio_file_t *bio); + + +/*---------------------------------------------------------- + Context management ("VM stack") +------------------------------------------------------------ + * This supports skipping between scripts, and also keeps + * track of the arg count for error messages. + */ + +typedef struct eel_context_t +{ + struct eel_context_t *previous; + bio_file_t *bio; + int script; + int arg; + int unlexed; + int token; + eel_data_t *lval; +} eel_context_t; + +extern eel_context_t eel_current; + +void eel_push_context(void); +void eel_pop_context(void); + +#endif /*_EEL_UTIL_H_*/ diff --git a/eel/eel-comp-src.txt b/eel/eel-comp-src.txt new file mode 100644 index 0000000..0aaec00 --- /dev/null +++ b/eel/eel-comp-src.txt @@ -0,0 +1,89 @@ + + The "EEL Compressed Source" file format + --------------------------------------- + +EEL Compressed Source files are EEL source files stripped of +all comments and formatting information. They are tokenized +using an external dictionary, which contains all keywords of +EEL and extensions, and any project names. Immediate values +are encoded using an extended "variable length number" BCD +format. + +* EEL Compressed Source files should have the extension + ".eec" instead of the normal ".eel", for reliable + identification, and to avoid accidentally overwriting + source files with compressed source files. (That would + be nasty, as the compression is destructive WRT comments, + symbol names and code formatting...) + +* The files are based on 4 bit words. Wider words (8 or 16 + bits) are *not* aligned to 8 or 16 bits, but start + directly at the current 4 bit word position. + +* There are two modes: XASCII and XBCD. Decoding of a file + starts in the XASCII mode. XASCII codes are 8 bits, and + XBCD codes are 4 bits. + +* The file starts with an 8 bit version code for the EEL + dictionary to use. Then follows a list of 4 byte EEL + extension IDs, terminated by a 0 byte. The EEL extension + IDs are of the form "XXXv", where "XXX" is an acronym + identifying the extension, and "v" is the version of the + extension dictionary to use. + + Any extension ID that doesn't math any known EEL + extension is assumed to be a Local Dictionary name. + ".eed" will be appended to the full 4 byte string (no + version code), and then EEL will try to find a file by + that name and load it as a Local Dictionary. + +* A Local Dictionary file consists of a 32 bit little + endian integer that holds the number of tokens needed + by the dictionary, *optionally* followed by a list of + null terminated ASCII strings, holding the human + readable names of all tokens. (The token name list is + useful when mixing compressed source with ASCII source + during development.) + +* Token values are allocated from 0 and up as + dictionaries are loaded. This is why there are + extension version numbers in the dictionary lists - + and it should also make it obvious that EEL extensions + must only *add* to their dictionaries if compatibility + with old compressed sources is to be maintained. + +* XASCII code: + 0-14 XBCD code + enter XBCD mode + + 15 Local token dictionary follows + 16 8 bit character follows + 17 Null terminated 8 bit quoted string + 18 Quoted 8 bit Pascal string follows + 19 Quoted 8 bit Pascal string continued + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + + 32-127 Standard 7 bit ASCII (copied as is) + + 128-191 Short Tokens + 192-254 Extended Tokens (8 extra bits follow) + 255 Wide Tokens (16 extra bits follow) + +* XBCD code: + 0-9 Decimal numbers 0-9 + 10 Decimal point (.) + 11 Unary minus (-) + 12 Argument separator/white space + 13 Statement terminator (;) + 14 Single XASCII character follows + 15 Switch to XASCII mode diff --git a/eel/eel-lang.txt b/eel/eel-lang.txt new file mode 100644 index 0000000..09d5aef --- /dev/null +++ b/eel/eel-lang.txt @@ -0,0 +1,161 @@ + + The Extensible Embeddable Language + ---------------------------------- + + Well, here's a simple extensible scripting language + for ya' - all in a few thousand lines of (hopefully) + portable C code! No external tools needed to build + this version, although future versions might have the + parsing functions replaced with a Bison parser. (You + still won't really need Bison, unless you want to + change the language syntax.) + + Extending the language is done by adding commands, + directives, operators, enums and "specials". It's pretty + much as simple as it gets, without using a custom source + preprocessor. A single scanf() style function call does + argument checking and casting for commands, so you + usually get away with a single call to get all your + arguments. + + The Language: + EEL is CaSe SEnSitIve! + + An EEL file consists of zero or more statements. + + There are (so far) two kinds of statements: Command + Statements and Assignments. + + A Command Statement starts with a command name, + followed by zero or more coma (,) separated arguments, + and is terminated with a semicolon (;). Some commands + accept variable numbers of arguments. + + A command argument may be of any type, which means + that symbol references, command references and other + weird stuff can be passed. + + "Functions" can be implemented as commands that + require one or more arguments to be passed by + reference. (See "set" / '=' command, which is an + example of this.) + + Assignments can be written in two forms; either using + the 'set' command, which takes two arguments; the + target and the source - or the more compact '=' + operator method, is which the target is on the left + side of the '=' operator, and the source is on the + right. +TODO: + "Function commands" can alternatively be called using + the traditional "a = function ...;" style. The + command's first argument should be an output argument, + and preferably the only output argument. (Note that + the *real* set command/'=' operator is not involved!) +/TODO + + Variables are created implicitly as a result of the + first Assignment. (This will probably change...) + + Variables are dynamically typed. Both value and type + may be changed after a variable has been declared. + + EEL strives to use "late casting", which means that + in the normal case, assignments change type as well + as value. +TODO: + The above is somewhat confusing, and will most probably + change. We need a clear distinction between "passing + by value" and "passing by reference", as this becomes + very important in algorithmic code.) +/TODO + + Data types that can be stored in a variable: + Real (64 bit float) + Integer (32 bit signed) + String (Null terminated) + Code Address (Source or bytecode position) + Symbol Reference (Can refer to any symbol) + + Symbol reference variables are quite interesting, as + they can theoretically reference *anything*, including + commands - and all type info is available as an extra + bonus. (Note that most of this is rather useless right + now, as the language doesn't have constructs that can + make use of it!) + + Built-in EEL commands, functions and directives: + end; + End of script. (Same effect as EOF.) + + set , ; + = ; + Set variable to . If + is not yet defined, it will be created + automatically. (This is likely to change.) + + print arg[, arg[,...]]; + Print the arguments in the "standard console". + + procedure ([arg[, arg[,...]]]) { } + function ([arg[, arg[,...]]]) { } + Define procedure 'procname' or function + 'funcname', respectively. The function will + take (as in "require") the specified + (dynamically typed) arguments, and when it's + invoked, the code in between the curly + brackets ('{' and '}') will be executed. + The function *must* return a value, while + the procedure must *not* - that's the only + difference between them. + + When a function or procedure is running, a + local "partition" of the symbol table is used. + Initially, this table contains only the + arguments, but any new variables declared as + the body code executes are added to *this* + table, instead of the global table, as in the + normal case. The "partition" (actually just a + local namespace) is removed as the function + or procedure returns, which obviously means + that the argument variables, as well as any + local variables, are deleted. + + [arg[, arg[,...]]]; + Function invocation. Works just like a + command invocation, although EEL will just + add the arguments to the Local Symbol Table - + it will not perform any type checking, as + argument types aren't supported as of now. + + #include + Run the file 'filename' in the current scope, + and then continue executing the current + script. + + Note that as of now, this is not 100% + compatible with the way a C/C++ preprocessor + works! It's more like loading and executing + a "subroutine script". + + #define + C header compatibility hack for defining + constants. It's mostly there to allow EEL + scripts to share headers with other languages + using C preprocessors, like C or C++. We want + to do that *without* actually using cpp, as + EEL scripts are supposed to load and run from + source without "special tools". + +TODO: + : + Label declaration. Creates a symbol + that contains the Code Address of the + statement following the colon. + +TODO: + i = 0; + for i < 10 + { + ... + } i = i + 1; diff --git a/eel/eel.c b/eel/eel.c new file mode 100644 index 0000000..e128233 --- /dev/null +++ b/eel/eel.c @@ -0,0 +1,573 @@ +/*(LGPL) +--------------------------------------------------------------------------- + eel.c - The "Extensible Embeddable Language" +--------------------------------------------------------------------------- + * Copyright (C) 2002, 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* +TODO: + * Eliminate the parser and use the expression + evaluator instead. "Everything is an expression." + The evaluator will need a few extra features, but + lots of messy code will be eliminated, and the + design will be much cleaner and more flexible. + + * Make all commands, functions and stuff operators. + Binary commands and operators should use the same + callback prototype. A way of describing return, + reference and input arguments will be needed. (Not + sure about multiple return arguments...) + + * Split the command and operator callbacks up + into one "parser" callback, and one or more + run-time callbacks. Leave argument grabbing/casting + and callback selection to the parser callbacks, for + simplicity and flexibility. (They can still use + tools like the EEL argument grabber.) Let them + generate byte code or similar (using some EEL API + calls) for one or more "operations", as required to + perform the desired actions. + + Interpreting mode could still be implemented, + with some overhead, by compiling and executing one + statement at a time - although IMHO, one might as + well make a complete switch to compiling + VM. + That would eliminate issues with distinguishing + between compiled and interpreted functions and the + like. + + * To make the above work, we'll need a distinction + between compile time and run-time symbols. (In + fact, we don't really need actual symbols at run + time, other than for globals. Local variables + should be allocated from some VM stack.) For + example, some features of the current argument + grabber won't work for compiling, as they rely on + the actual contents of a symbol, to extract data. + Such features will have to be implemented though + run-time callbacks that execute the corresponding + operations. + + * Remove EDT_INTEGER? The lexer currently never + returns TK_INUM except for character literals, + and I'm starting to think it's a good idea to + keep it that way, for various reasons... + + * Functions should return values! Make sure + that errors are issued if a function returns + without an explicit return statement. + + * Add "procedure" keyword for "functions" + without return values. Issue an error if a + "return with value" statement is executed + within a procedure. + + * Implement conditional constructs. + + * Implement '&' ("address" of function) operator. + + * Add a procedure extension(name) to EEL, to allow + scripts to check for extension availability and + version. Should return version #, or 0 if the + extension is not available. There should probably + also be a uses(name), to avoid implicitly stuffing + all available extensions into the name space of + every script. + + * Eliminate all fixed size arrays and limits... + + * Implement the Compressed Source file format. + + */ + +#include "config.h" +#include +#include +#include + +#include "eel.h" +#include "e_lexer.h" +#include "e_util.h" +#include "e_builtin.h" + +#include "_e_script.h" + + +/*---------------------------------------------------------- + Parser/Interpreter +----------------------------------------------------------*/ + +static int command(void) +{ + eel_symbol_t *sym = eel_current.lval->value.sym; + + if(!sym->data.value.op.cb) + { + eel_error("INTERNAL ERROR: Command callback missing!"); + return -1; + } + + if(sym->data.value.op.retargs) + { + eel_error("INTERNAL ERROR: Return value ignored!"); + return -1; + } + + if(eel_parse_args(",", ';') < 0) + return -1; + + return sym->data.value.op.cb(eel_arg_count, eel_args); +} + + +static int assignment(int token) +{ + int res; + + /* Get target */ + switch(token) + { + case TK_SYMREF: + switch (eel_current.lval->value.sym->type) + { + case EST_UNDEFINED: + case EST_VARIABLE: + break; + default: + eel_error("Cannot change the value of %s!", + eel_symbol_is(eel_current.lval->value.sym)); + return -1; + } + case TK_NEWSYM: + if(eel_grab_arg() < 0) + { + eel_error("Argument overflow!"); + return -1; + } + break; +#if 0 + case 0: + eel_error("Unexpected end of file!"); + return -1; + default: + eel_error("Unexpected token!"); + return -1; +#endif + } + + /* Get operator */ + if(eel_lex(0) != '=') + { + eel_error("Expected '='!"); + return -1; + } + + /* Get source */ + if(eel_parse_args(",", ';') < 0) + return -1; + + /* End of declaration; execute! */ + res = eel_cmd_set(eel_arg_count, eel_args); + + return res; +} + + +static int directive(void) +{ + int res; + eel_symbol_t *sym = eel_current.lval->value.sym; + + if(!sym->data.value.parse) + { + eel_error("INTERNAL ERROR: Directive callback missing!"); + return -1; + } + + res = sym->data.value.parse(); + return res; +} + + +static int function(void) +{ + int arg, res; + eel_symbol_t *func = eel_current.lval->value.sym; + + eel_push_scope(); + + /* Grab arguments */ + res = eel_parse_args(",", ';'); + + /* Enter function */ + eel_push_context(); + if(eel_current.script == func->token) + eel_current.bio = bio_clone(eel_current.bio); + else + eel_current.bio = bio_open(eel_scripttab[func->token].data, + eel_scripttab[func->token].len); + if(!eel_current.bio) + { + eel_error("INTERNAL ERROR: Failed to set up script" + " reading at start of function!"); + eel_pop_context(); + eel_pop_scope(); + return -1; + } + res = bio_seek(eel_current.bio, func->data.value.a, SEEK_SET); + + /* + * Find out where to stuff the arguments. + */ + for(arg = 0; (arg < eel_arg_count) && (res >= 0); ) + switch(eel_lex(0)) + { + case ',': + /* Already verified, so we just skip them. */ + break; + case TK_NEWSYM: + { + eel_symbol_t *sym; + sym = eel_set_data(eel_current.lval->value.s, + eel_args + arg); + if(sym) + { + sym->type = EST_VARIABLE; + ++arg; + } + else + { + eel_error("INTERNAL ERROR: Failed to " + "create argument variable!"); + res = -1; + } + break; + } + case TK_SYMREF: + eel_error("Function argument clashes with " + "previously defined symbol!"); + res = -1; + break; + default: + eel_error("Syntax error in argument list!"); + res = -1; + break; + } + + /* Find start of body ("the code") */ + if(res >= 0) + { + if(eel_lex(0) != ')') + { + eel_error("Expected ')'!"); + res = -1; + } + else if(eel_lex(0) != '{') + { + eel_error("Expected '{'!"); + res = -1; + } + } + + if(res >= 0) + { + /* + * Execute function + * + * Note that this is a simple, inefficient + * RECURSIVE implementation! + * + * Alternatively, we could set up a "trigger" + * to run "the rest of this function" when + * the function ends - and then just return. + */ + res = eel_call(eel_current.script, bio_tell(eel_current.bio)); + } + + /* Leave function */ + bio_close(eel_current.bio); + eel_pop_context(); + eel_pop_scope(); + + if(res >= 0) + return 1; + else + return res; +} + + +int eel_call(int handle, int pos) +{ + int res = 1; + int depth = 0; + eel_push_context(); + eel_current.script = handle; + eel_current.bio = bio_open(eel_scripttab[handle].data, + eel_scripttab[handle].len); + if(!eel_current.bio) + { + eel_error("INTERNAL ERROR: Couldn't read script!"); + eel_pop_context(); + return -1; + } + bio_seek(eel_current.bio, pos, SEEK_SET); + + eel_current.lval = NULL; + while(res > 0) + { + /* Start of statement */ + eel_clear_args(0); + eel_current.arg = 0; + switch(eel_lex(0)) + { + case 0: + /* End of script */ + res = 0; + break; + case ';': + /* Empty statement */ + res = 1; + break; + case '{': + /* Begin scope */ + eel_push_scope(); + ++depth; + res = 1; + break; + case '}': + /* End scope */ + if(depth) + { + eel_pop_scope(); + --depth; + } + else + res = 0; + break; + case TK_NEWSYM: + res = assignment(TK_NEWSYM); + break; + case TK_SYMREF: + switch(eel_current.lval->value.sym->type) + { + case EST_CONSTANT: /* Just to get a more + * sensible error message... + */ + case EST_UNDEFINED: + case EST_VARIABLE: + res = assignment(TK_SYMREF); + break; +/* case EST_COMMAND: + res = command(); + break;*/ + case EST_FUNCTION: + res = function(); + break; + case EST_DIRECTIVE: + case EST_SPECIAL: + res = directive(); + break; + case EST_ENUM: + case EST_LABEL: + eel_error("Syntax error!"); + res = -1; + break; + case EST_OPERATOR: + res = command(); + break; + default: + eel_error("INTERNAL ERROR: Lexer returned" + " symbol of illegal type!"); + res = -1; + break; + } + break; + default: + eel_error("Unexpected character!"); + res = -1; + break; + } + } + eel_current.arg = 0; + bio_close(eel_current.bio); + eel_pop_context(); + return res; +} + + +int eel_run(int handle) +{ + return eel_call(handle, 0); +} + + +static int _eel_users = 0; + +int eel_open(void) +{ + if(_eel_users++) + return 0; + + memset(eel_scripttab, 0, sizeof(eel_scripttab)); + + if(eel_s_open() < 0) + { + _eel_users = 0; + return -1; + } + + eel_register_operator("end", eel_cmd_end, 100, 0, 0); + eel_register_operator("set", eel_cmd_set, 100, 0, 0); + eel_register_operator("print", eel_cmd_print, 100, 0, 0); + + eel_register_operator("+", eel_op_add, 10, 0, 1); + eel_register_operator("-", eel_op_sub, 10, 0, 1); + + eel_register_operator("*", eel_op_mul, 20, 0, 1); + eel_register_operator("/", eel_op_div, 20, 0, 1); + eel_register_operator("%", eel_op_mod, 20, 0, 1); + + eel_register_operator("^", eel_op_pow, 30, 0, 1); + + eel_register_directive("include", eel_dir_include); + eel_register_directive("define", eel_dir_define); + + eel_register_special("function", eel_spec_function); + eel_register_special("procedure", eel_spec_procedure); +/* eel_register_special("global", eel_spec_global);*/ + + return 0; +} + +void eel_close() +{ + int h; + if(!_eel_users) + return; + + for(h = 0; h < MAX_SCRIPTS; ++h) + eel_free(h); + + eel_s_freeall(); + eel_set_path(NULL); + eel_s_close(); + eel_lexer_cleanup(); + + --_eel_users; +} + + + +/*---------------------------------------------------------- + EEL variable access +----------------------------------------------------------*/ + +eel_symbol_t *eel_set_integer(const char *name, int value) +{ + eel_symbol_t *sym = eel_s_get(name, EST_VARIABLE); + if(!sym) + return NULL; + eel_d_freestring(&sym->data); + sym->data.type = EDT_INTEGER; + sym->data.value.i = value; + return sym; +} + + +eel_symbol_t *eel_set_real(const char *name, double value) +{ + eel_symbol_t *sym = eel_s_get(name, EST_VARIABLE); + if(!sym) + return NULL; + eel_d_freestring(&sym->data); + sym->data.type = EDT_REAL; + sym->data.value.r = value; + return sym; +} + + +eel_symbol_t *eel_set_string(const char *name, const char *s) +{ + eel_symbol_t *sym = eel_s_get(name, EST_VARIABLE); + if(!sym) + return NULL; + eel_d_setstring(&sym->data, s); + return sym; +} + + +eel_symbol_t *eel_set_data(const char *name, const eel_data_t *dat) +{ + eel_symbol_t *sym = eel_s_get(name, EST_VARIABLE); + if(!sym) + return NULL; + + eel_d_freestring(&sym->data); + switch (dat->type) + { + case EDT_ILLEGAL: + case EDT_REAL: + case EDT_INTEGER: + case EDT_CADDR: + case EDT_SYMREF: + case EDT_SYMTAB: + case EDT_OPERATOR: + case EDT_DIRECTIVE: + case EDT_SPECIAL: + sym->data = *dat; + break; + case EDT_STRING: + case EDT_SYMNAME: + sym->data.type = dat->type; + if(eel_d_setstring(&sym->data, dat->value.s) < 0) + return NULL; + break; + } + return sym; +} + + +eel_symbol_t *eel_clone_symbol(const char *name, const eel_symbol_t *orig) +{ + eel_symbol_t *sym = eel_s_new(name, orig->type); + if(!sym) + return NULL; + + eel_d_freestring(&sym->data); + switch (orig->data.type) + { + case EDT_ILLEGAL: + case EDT_REAL: + case EDT_INTEGER: + case EDT_CADDR: + case EDT_SYMREF: + case EDT_SYMTAB: + case EDT_OPERATOR: + case EDT_DIRECTIVE: + case EDT_SPECIAL: + sym->data = orig->data; + break; + case EDT_STRING: + case EDT_SYMNAME: + sym->data.type = orig->data.type; + if(eel_d_setstring(&sym->data, orig->data.value.s) < 0) + return NULL; + break; + } + return sym; +} diff --git a/eel/eel.h b/eel/eel.h new file mode 100644 index 0000000..05fe855 --- /dev/null +++ b/eel/eel.h @@ -0,0 +1,376 @@ +/*(LGPL) +--------------------------------------------------------------------------- + eel.c - The "Extensible Embeddable Language" +--------------------------------------------------------------------------- + * Copyright (C) 2002, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* +TODO: + ...or at least think about: Extend the dynamic typing to + include functions. Ex: + + set some_var, some_function; + + will connect 'some_function' to 'some_var', so that the + function is called to calculate the value whenever the + variable is read. Obviously, such a variable becomes + read-only! This could be worked around with the following + syntax: + + set some_var, read_function, write_function; + + A handy syntax extension: + + set some_var, some_function(...); + + or + + set some_other_var, + { + ... + some code + ... + }; + + which would be interpreted as a nameless, single statement + function being connected to 'some_var', and a nameless + function with a normal body being connected to + 'some_other_var'. + + The whole point with this is that it allows the way a + variable gets written to change at run time, and that it's + even applicable to code that isn't aware of this feature. + + BTW, this is pretty similar to Delphi 'properties' - + although you cannot turn variables into properties or vice + versa, at run time, as you could do with this feature. + +---------------------------------------------------------------------- + + Scope/Namespace management sucks. Namespaces probably need + to be arranged in a tree rather than a stack. + + This becomes obvious when considering what happens when you + call a function... The function executes in a scope that's + the calling scope + a local namespace! + + Indeed, this could be considered an interesting "feature", + but I'm not sure it's as useful as it is confusing... + + As a quick hack solution, one could reserve the first few + namespaces (ie highest levels) for language extensions, to + make it easy to install and remove extensions without them + interfering with each other. + + One could possible change the "scope level" into a "scope + handle", and make a scope a "list of namespaces" rather + than the current "lowest namespace index". That would allow + multiple totally independent scopes under the same scripting + engine. + + */ + +#ifndef _EEL_H_ +#define _EEL_H_ + +#include "e_script.h" +#include "e_symtab.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define EEL_MAX_ARGS 128 + +#define _EEL_API_ + +#include "e_register.h" + + +/*---------------------------------------------------------- + Toolkit for directive callbacks +----------------------------------------------------------*/ + +/* + * The internal argument list. Avoid using this directly! + */ +extern int eel_arg_count; +extern eel_data_t *eel_args; + +/* + * Add the last lval returned from the lexer to the internal + * argument list. + */ +int eel_grab_arg(void); + +/* + * Clear the internal argument list starting at argument + * 'first'. + */ +void eel_clear_args(int first); + +/* + * Parse arguments separated by one of the characters in + * 'separators', until the character 'terminator' is + * matched, or an error occurs. + * + * The arguments that are "grabbed" are added to the + * internal argument list using eel_grab_arg(), and can + * be retrieved, decoded and typechecked with eel_get_args() + * if desired. + * + * Returns a negative value in case of an error. + */ +int eel_parse_args(const char *separators, char terminator); + + +/*---------------------------------------------------------- + Toolkit for command callbacks +----------------------------------------------------------*/ + +/* + * Grab arguments from the internal argument list, verifying + * that their types and count are in accordance with 'fmt'. + * Results will be stored in the variables passed by + * reference after the 'fmt' argument. + * + * Normally, the argument count not matching the number of + * arguments specified in the format string will be reported + * as an error. However, this can be changed by means of + * argument tipples and optional arguments, denoted by the + * '<', '>' and '[', ']' characters respectively. + * + * The return value is the number of arguments correctly + * retrieved, or a negative value if something goes wrong. + * + * Format string syntax: + * + * Char Meaning Type + *-------------------------------------------------------------------- + * * Skip argument N/A + * + * , Next argument (optional) N/A + * + * ? Grab any argument as is eel_data_t * + * + * < > Argument tipple. The argument spec in N/A + * between the < and > will be repeated + * until all arguments have been grabbed, + * or an error occurs. The target args + * should be ARRAYS and *must* be large + * enough to fit all arguments retrieved, + * or bad things will happen. Argument + * tipples cannot be nested. There must + * be no argument specifiers after the + * '>', as an argument tipple repeats + * "forever". Normally, the arguments + * must match an *integer* number of + * tipple repetitions - but this can be + * changed using the Optional Argument + * format codes. + * + * [ ] Optional arguments. Arguments beyond N/A + * the '[' character after the 'argv' + * array has been exhausted will not + * generate an error, as this situation + * normally would. + * + * Optional arguments inside argument + * tipples apply only to the *last* + * tipple repetition. + * + * Note that no argument specifiers must + * follow the ']' character - or; optional + * arguments must be the last ones in the + * list. + * + * E Get any enum symbol. Any enum class eel_symbol_t * + * is accepted. (Do check, if you care!) + * + * V Get value of any allowed type. This eel_data_t * + * code can optionally be followed by a + * list of allowed types, enclosed within + * parentheses. If no list is specified, + * all *value* data types are accepted, + * including EDT_CADDR. Available types: + * i integer (EDT_INTEGER) + * r real (EDT_REAL) + * s string (EDT_STRING) + * c code address (EDT_CADDR) + * e enum constant (EDT_SYMREF) + * All but 'e' are set by default, if no + * explicit list is provided. + * + * Note that symrefs are followed, to get + * the values of the symbols they refer to, + * except that when 'e' (enum constant) is + * listed, symrefs to enum constants will + * stay symrefs. + * + * e Get enum value. The argument should be int + * INITIALIZED with the enum class. Only + * enum constants from the right class + * are accepted. + * + * i Get integer value int + * + * n Get or create variable. In the case of eel_symbol_t * + * a new variable being created, the + * argument has to be a string holding the + * name of the new variable. The type of + * a new variable is undefined. + * + * r Get real value double + * + * s Get string value char * + * NOTE: Currently it's NOT possible to + * get non-string values casted to strings. + * (We need a fast, reference counting + * string package...) + * + * v Get variable (must be defined) eel_symbol_t * + * + * f Get function "address". The returned eel_symbol_t * + * symbol will be of type EST_FUNCTION. + * + * Any other character in the format string in matched with that + * respective character in the input. + */ +int eel_get_args(const char *fmt, ...); + + +/* + * Like eel_get_args(), but reads from the specified eel_data_t + * array instead of the internal argument list. + */ +int eel_get_args_from(int argc, struct eel_data_t *argv, const char *fmt, ...); + +/* + * Print a nice error "prompt" with file name, line # + * and arg #, followed by your formatted error message, + * followed by a newline ('\n') where appropriate. (Don't + * add this yourself, unless you need multiple lines.) + * + * Note that syntax checking and most type + * and error checking is done automatically + * by EEL (mostly in eel_get_args()). This + * function is only for errors that EEL + * can't detect. + * + * Returns total number of characters printed. + */ +int eel_error(const char *format, ...); + +/* + * Returns a string describing the specified symbol + * in a way that would complete the sentences: + * "This is ..." + * "Expected ..." + */ +const char *eel_symbol_is(eel_symbol_t *s); + +/* + * As eel_symbol_is(), but for data containers. + */ +const char *eel_data_is(eel_data_t *d); + + + +/*---------------------------------------------------------- + Runtime API +----------------------------------------------------------*/ + +/* + * Set the EEL path for scripts and includes. + * + * This must be a valid path, terminated by a + * '/', '\', ':' or whatever "directory separator" + * the current platform is using, and will be + * prepended to file names passed to the #include + * directive. + */ +void eel_set_path(const char *path); + +/* Returns the current EEL path. */ +const char *eel_path(void); + +/* Open/Close EEL. (Keep track of nested calls!) */ +int eel_open(void); +void eel_close(); + +/* + * Execute code inside script 'handle', starting at 'pos'. + * + * Execution will take place as a "sub procedure", with it's + * own context¨, but *not* automatically it's own *scope*. + * This is because most real applications will require + * scripts to be passed some "arguments", which is actually + * done by creating a few variables before the script is + * called. Obviously, the code that sets up the "argument + * variables" and calls eel_run() will also have to do any + * scope pushing and popping *around* these calls - which is + * why it can't be done inside eel_run(). + * + * The following events will end execution: + * - A statement gives a "stop execution" return code. + * - The top level scope is terminated; ie an unmatched + * curly brace ('}') is found. + * - EOF is reached. + * - An error occurs. + * + * Returns the result, which will be negative in the case + * of an error. + */ +int eel_call(int handle, int pos); + +/* + * Run a script from the start. + * + * Currently 100% equivalent to eel_call('handle', 0); + */ +int eel_run(int handle); + +/* + * Create or set variable 'name' to the specified value. + * Existing symbols *must* be of type ST_VARIABLE, or + * these calls will fail. + * + * Returns the changed/created symbol, or NULL if the + * operation failed. + */ +eel_symbol_t *eel_set_integer(const char *name, int value); +eel_symbol_t *eel_set_real(const char *name, double value); +eel_symbol_t *eel_set_string(const char *name, const char *s); +eel_symbol_t *eel_set_data(const char *name, const eel_data_t *dat); + +/* + * Make an exact copy of symbol 'orig', except for the name, + * which will be 'name'. Symbol 'name' must not exist before + * this call. + * + * Returns the created symbol, or NULL if the operation failed. + */ +eel_symbol_t *eel_clone_symbol(const char *name, const eel_symbol_t *orig); + +#undef _EEL_API_ + +#ifdef __cplusplus +}; +#endif + +#endif /* _EEL_H_ */ diff --git a/enemies.cpp b/enemies.cpp new file mode 100644 index 0000000..81700a0 --- /dev/null +++ b/enemies.cpp @@ -0,0 +1,188 @@ +/* +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2001, 2003, 2007 David Olofson + * + * 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. + */ + +#include +#include "enemies.h" +#include "random.h" +#include "radar.h" + +_enemy _enemies::enemy[ENEMY_MAX]; +_enemy *_enemies::enemy_max; +const enemy_kind *_enemies::ekind_to_generate_1; +const enemy_kind *_enemies::ekind_to_generate_2; +int _enemies::e1_interval; +int _enemies::e2_interval; +int _enemies::explocount = 0; +int _enemies::is_intro = 0; + +_enemy::_enemy() +{ + object = NULL; + _state = notuse; +} + +void _enemy::state(_state_t s) +{ + switch(s) + { + case notuse: + if(object) + { + gengine->free_obj(object); + object = NULL; + } + break; + case reserved: + case moving: + if(bank >= 0) + { + if(!object) + object = gengine->get_obj(ek->layer); + if(!object) + break; + if(s == moving) + cs_obj_show(object); + else + cs_obj_hide(object); + } + else if(object) + { + gengine->free_obj(object); + object = NULL; + } + break; + } + _state = s; +} + + + +void _enemies::off() +{ + _enemy *enemyp; + for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) + enemyp->release(); +} + +int _enemies::init() +{ + _enemy *enemyp; + for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) + enemyp->init(); + enemy_max = enemy; + ekind_to_generate_1 = NULL; + ekind_to_generate_2 = NULL; + e1_interval = 1; + e2_interval = 1; + return 0; +} + +void _enemies::move() +{ + _enemy *enemyp; + /* realize reserved enemies */ + for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) + { + if(enemyp->realize()) + enemy_max = enemyp; + } + for(enemyp = enemy; enemyp <= enemy_max; enemyp++) + enemyp->move(); +} + +void _enemies::move_intro() +{ + _enemy *enemyp; + is_intro = 1; + /* realize reserved enemies */ + for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) + { + if(enemyp->realize()) + enemy_max = enemyp; + } + for(enemyp = enemy; enemyp <= enemy_max; enemyp++) + enemyp->move_intro(); + is_intro = 0; +} + +void _enemies::put() +{ + _enemy *enemyp; + for(enemyp = enemy; enemyp <= enemy_max; enemyp++) + enemyp->put(); +} + +int _enemies::make(const enemy_kind * ek, int x, int y, int h, int v, + int di) +{ + _enemy *enemyp; + for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) + if(!enemyp->make(ek, x, y, h, v, di)) + return 0; + return 1; +} + +const enemy_kind *_enemies::randexp() +{ + explocount += 1 + pubrand.get(1); + switch(explocount & 3) + { + case 0: + return &explosion; + case 1: + return &explosion3; + case 2: + return &explosion4; + default: + return &explosion5; + } +} + +int _enemies::erase_cannon(int x, int y) +{ + int count = 0; + _enemy *enemyp; + for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) + count += enemyp->erase_cannon(x, y); + if(count) + wradar->update(x, y); + return count; +} + +int _enemies::exist_pipe() +{ + int count = 0; + _enemy *enemyp; + for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) + if(enemyp->is_pipe()) + count++; + return count; +} + +void _enemies::set_ekind_to_generate(const enemy_kind * e1, int i1, + const enemy_kind * e2, int i2) +{ + ekind_to_generate_1 = e1; + ekind_to_generate_2 = e2; + e1_interval = i1; + e2_interval = i2; +} diff --git a/enemies.h b/enemies.h new file mode 100644 index 0000000..2971f61 --- /dev/null +++ b/enemies.h @@ -0,0 +1,437 @@ +/* +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2001-2003, 2007 David Olofson + * + * 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. + */ + +#ifndef XKOBO_H_ENEMIES +#define XKOBO_H_ENEMIES + +#include +#include "kobo.h" +#include "config.h" +#include "myship.h" +#include "manage.h" +#include "sound.h" + +#define ABS(x) (((x)>=0) ? (x) : (-(x))) +#define MAX(x,y) (((x)>(y)) ? (x) : (y)) + +#define HEALTH_INDESTRUCTIBLE 9000000 + +class _enemy; +class _enemies; +//---------------------------------------------------------------------------// +struct enemy_kind +{ + int score; + void (_enemy::*make) (); + void (_enemy::*move) (); + void (_enemy::*kill) (); + int hitsize; + int bank, frame; + int layer; +}; + + +extern const enemy_kind beam; +extern const enemy_kind explosion; +extern const enemy_kind explosion3; +extern const enemy_kind explosion4; +extern const enemy_kind explosion5; +extern const enemy_kind ringexpl; +extern const enemy_kind beamexpl; +extern const enemy_kind boltexpl; +extern const enemy_kind rockexpl; +extern const enemy_kind enemy1; +extern const enemy_kind enemy2; +extern const enemy_kind enemy3; +extern const enemy_kind enemy4; +extern const enemy_kind enemy5; +extern const enemy_kind enemy6; +extern const enemy_kind enemy7; +extern const enemy_kind bomb1; +extern const enemy_kind bomb2; +extern const enemy_kind bombdeto; +extern const enemy_kind cannon; +extern const enemy_kind pipe1; +extern const enemy_kind core; +extern const enemy_kind pipe2; +extern const enemy_kind rock; +extern const enemy_kind ring; +extern const enemy_kind enemy_m1; +extern const enemy_kind enemy_m2; +extern const enemy_kind enemy_m3; +extern const enemy_kind enemy_m4; + + +//---------------------------------------------------------------------------// +enum _state_t +{ + notuse, + reserved, + moving +}; + +class _enemy +{ + cs_obj_t *object; /* For the gfxengine connection */ + _state_t _state; + const enemy_kind *ek; + int x, y; + int h, v; + int di; + int a, b; + int count; + int health; + int damage; + int shootable; + int diffx, diffy; + int norm; + int hitsize; + int bank, frame; + void hit(int dmg); + void move_enemy_m(int quick, int maxspeed); + void move_enemy_template(int quick, int maxspeed); + void move_enemy_template_2(int quick, int maxspeed); + void move_enemy_template_3(int quick, int maxspeed); + void shot_template(const enemy_kind * ekp, + int shift, int rand_num, int maxspeed); + void shot_template_8_dir(const enemy_kind * ekp); + public: + _enemy(); + inline void init(); + inline void release(); + void state(_state_t s); + inline void move(); + inline void move_intro(); + inline void put(); + inline int make(const enemy_kind * k, + int px, int py, int h1, int v1, int dir = 0); + inline int realize(); + inline int is_pipe(); + inline int erase_cannon(int px, int py); + + void kill_default(); + + void make_beam(); + void move_beam(); + void kill_beam(); + + void make_rock(); + void move_rock(); + void kill_rock(); + + void make_ring(); + void move_ring(); + void kill_ring(); + + void make_bomb(); + void move_bomb1(); + void move_bomb2(); + + void make_expl(); + void move_expl(); + + void make_cannon(); + void move_cannon(); + void kill_cannon(); + + void make_core(); + void move_core(); + void kill_core(); + + void make_pipe1(); + void move_pipe1(); + + void make_pipe2(); + void move_pipe2(); + + void make_enemy1(); + void move_enemy1(); + + void make_enemy2(); + void move_enemy2(); + + void make_enemy3(); + void move_enemy3(); + + void make_enemy4(); + void move_enemy4(); + + void make_enemy(); + void move_enemy5(); + void move_enemy6(); + void move_enemy7(); + + void make_enemy_m1(); + void move_enemy_m1(); + + void make_enemy_m2(); + void move_enemy_m2(); + + void make_enemy_m3(); + void move_enemy_m3(); + + void make_enemy_m4(); + void move_enemy_m4(); +}; + +//---------------------------------------------------------------------------// +class _enemies +{ + static _enemy enemy[ENEMY_MAX]; + static _enemy *enemy_max; + static const enemy_kind *ekind_to_generate_1; + static const enemy_kind *ekind_to_generate_2; + static int e1_interval; + static int e2_interval; + static int explocount; + public: + static int is_intro; + static int init(); + static void off(); + static void move(); + static void move_intro(); + static void put(); + static int make(const enemy_kind * ek, + int x, int y, int h = 0, int v = 0, int di = 0); + static const enemy_kind *randexp(); + static int erase_cannon(int x, int y); + static int exist_pipe(); + static void set_ekind_to_generate(const enemy_kind * ek1, int i1, + const enemy_kind * ek2, int i2); + static inline const enemy_kind *ek1() + { + return ekind_to_generate_1; + } + static inline const enemy_kind *ek2() + { + return ekind_to_generate_2; + } + static inline int eint1() + { + return e1_interval; + } + static inline int eint2() + { + return e2_interval; + } +}; + +extern _enemies enemies; + + +inline void _enemy::init() +{ + release(); +} + +inline void _enemy::release() +{ + state(notuse); +} + +inline int _enemy::make(const enemy_kind * k, int px, int py, + int h1, int v1, int dir) +{ + if(_state != notuse) + return -1; + + ek = k; + state(reserved); + x = PIXEL2CS(px); + y = PIXEL2CS(py); + di = dir; + h = h1; + v = v1; + a = 0; + b = 0; + count = 0; + health = 20; + damage = 50; + shootable = 1; + hitsize = ek->hitsize; + bank = ek->bank; + frame = ek->frame; + (this->*(ek->make)) (); + return 0; +} + +inline void _enemy::hit(int dmg) +{ + if(HEALTH_INDESTRUCTIBLE != health) + health -= dmg; + if(enemies.is_intro) + { + if(health <= 0) + { + enemies.make(&explosion, CS2PIXEL(x), CS2PIXEL(y)); + release(); + } + return; + } + else if(health > 0) + { + if(ek == &rock) + sound.g_bolt_hit_rock(x, y); + else + sound.g_bolt_hit(x, y); + return; + } + + manage.add_score(ek->score); + (this->*(ek->kill)) (); +} + +inline int _enemy::erase_cannon(int px, int py) +{ + if( (_state != notuse) && (ek == &cannon) + && ((signed)(CS2PIXEL(x) & (WORLD_SIZEX - 1)) >> 4 == px) + && ((signed)(CS2PIXEL(y) & (WORLD_SIZEY - 1)) >> 4 == py) + ) + { + release(); + return 1; + } + return 0; +} + +inline void _enemy::move() +{ + if(_state != moving) + return; + x += h; + y += v; + diffx = CS2PIXEL(x) - myship.get_x(); + diffy = CS2PIXEL(y) - myship.get_y(); + + if(diffx > (WORLD_SIZEX >> 1)) + { + diffx -= WORLD_SIZEX; + x -= PIXEL2CS(WORLD_SIZEX); + } + if(diffx < -(WORLD_SIZEX >> 1)) + { + diffx += WORLD_SIZEX; + x += PIXEL2CS(WORLD_SIZEX); + } + if(diffy > (WORLD_SIZEY >> 1)) + { + diffy -= WORLD_SIZEY; + y -= PIXEL2CS(WORLD_SIZEY); + } + if(diffy < -(WORLD_SIZEY >> 1)) + { + diffy += WORLD_SIZEY; + y += PIXEL2CS(WORLD_SIZEY); + } + + norm = MAX(ABS(diffx), ABS(diffy)); + (this->*(ek->move)) (); + + // Handle collisions with the player ship + if((hitsize >= 0) && (norm < (hitsize + HIT_MYSHIP))) + if(prefs->cmd_indicator) + sound.g_player_damage(); + else if(myship.alive()) + { + hit(game.damage); // Ship damages object + myship.hit(damage); // Object damages ship + } + + // Handle collisions with player bolts (Player bolts kill themselves + // when they hit something, so we don't need to hit them from here.) + if(!shootable || (norm >= ((VIEWLIMIT >> 1) + 8))) + return; + + int dmg = myship.hit_bolt(CS2PIXEL(x), CS2PIXEL(y), + hitsize + HIT_BOLT, health); + if(dmg) + if(prefs->cmd_indicator) + sound.g_player_damage(); + else + hit(dmg); // Bolt damages object +} + +inline void _enemy::move_intro() +{ + if(_state != moving) + return; + x += h; + y += v; + diffx = CS2PIXEL(x) - myship.get_x(); + diffy = CS2PIXEL(y) - myship.get_y(); + + if(diffx > (WORLD_SIZEX >> 1)) + { + diffx -= WORLD_SIZEX; + x -= PIXEL2CS(WORLD_SIZEX); + } + if(diffx < -(WORLD_SIZEX >> 1)) + { + diffx += WORLD_SIZEX; + x += PIXEL2CS(WORLD_SIZEX); + } + if(diffy > (WORLD_SIZEY >> 1)) + { + diffy -= WORLD_SIZEY; + y -= PIXEL2CS(WORLD_SIZEY); + } + if(diffy < -(WORLD_SIZEY >> 1)) + { + diffy += WORLD_SIZEY; + y += PIXEL2CS(WORLD_SIZEY); + } + + norm = MAX(ABS(diffx), ABS(diffy)); + (this->*(ek->move)) (); +} + +inline void _enemy::put() +{ + if(!object) + return; + object->point.v.x = x; + object->point.v.y = y; + cs_obj_image(object, bank, frame + di - 1); +} + +inline int _enemy::realize() +{ + if(_state == reserved) + { + state(moving); + if(object) + { + object->point.v.x = x; + object->point.v.y = y; + cs_point_force(&object->point); + } + } + return (_state == moving); +} + +inline int _enemy::is_pipe() +{ + return ((_state != notuse) && ((ek == &pipe1) || (ek == &pipe2))); +} + + +#endif // XKOBO_H_ENEMIES diff --git a/enemy.cpp b/enemy.cpp new file mode 100644 index 0000000..136eefb --- /dev/null +++ b/enemy.cpp @@ -0,0 +1,1429 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2001-2003, 2007 David Olofson + * + * 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. + */ + +#include "screen.h" +#include "manage.h" +#include "enemies.h" +#include "myship.h" +#include "random.h" +#include + +/////////////////////////////////////////////////////////////////////////////// +// Fast integer atan() approximation. Input is 24:8 fixed point. +// Output is 0..64 for 0..45 deg, accurate accurate down to LSB. +// In: q = 256 * minv / maxv (0..256 <==> 0..1) +// Out: atan(q / 256) * 256 (0..64 <==> 0..45 deg) +/////////////////////////////////////////////////////////////////////////////// +// atan() approximations for 0..9 deg: +// a = 83 * q / 256 - q*q / 2844 (+/- 2.1%) +// a = 82 * q / 256 - k*k / 8500 - x*x*x / 1600000 (+/- 0.6%) +/////////////////////////////////////////////////////////////////////////////// +static inline int fastatan(int q) +{ + int q2 = q * q; + int q3 = q2 * q; + return (82 * q >> 8) - (62 * q2 >> 19) - (10 * q3 >> 24); +} + +static int speed2dir(int sx, int sy, int frames) +{ + if(!sx && !sy) + return 0; + int at2; + if(sx > 0) + { + // Right + if(sy < 0) + { + // Top-right quadrant + sy = -sy; + if(sy > sx) + at2 = fastatan(sx * 256 / sy); + else + at2 = 128 - fastatan(sy * 256 / sx); + } + else + { + // Bottom-right quadrant + if(sx > sy) + at2 = 128 + fastatan(sy * 256 / sx); + else + at2 = 256 - fastatan(sx * 256 / sy); + } + } + else + { + // Left + sx = -sx; + if(sy > 0) + { + // Bottom-left quadrant + if(sy > sx) + at2 = 256 + fastatan(sx * 256 / sy); + else + at2 = 384 - fastatan(sy * 256 / sx); + } + else + { + // Top-left quadrant + sy = -sy; + if(sx > sy) + at2 = 384 + fastatan(sy * 256 / sx); + else + at2 = 512 - fastatan(sx * 256 / sy); + } + } + at2 = (at2 * frames + 256) >> 9; + return at2 > frames - 1 ? 1 : at2 + 1; +} + + +/* + * =========================================================================== + * (template) + * =========================================================================== + */ + +inline void _enemy::move_enemy_m(int quick, int maxspeed) +{ + if(diffx > 0) + { + if(h > -maxspeed) + h -= quick; + } + else if(diffx < 0) + { + if(h < maxspeed) + h += quick; + } + if(diffy > 0) + { + if(v > -maxspeed) + v -= quick; + } + else if(diffy < 0) + { + if(v < maxspeed) + v += quick; + } +} + +inline void _enemy::move_enemy_template(int quick, int maxspeed) +{ + if(diffx > 0) + { + if(h > -maxspeed) + h -= quick; + } + else if(diffx < 0) + { + if(h < maxspeed) + h += quick; + } + if(diffy > 0) + { + if(v > -maxspeed) + v -= quick; + } + else if(diffy < 0) + { + if(v < maxspeed) + v += quick; + } + int ndi = speed2dir(h, v, 16); + if(ndi > 0) + di = ndi; +} + +inline void _enemy::move_enemy_template_2(int quick, int maxspeed) +{ + h = -PIXEL2CS(diffy) / (1< 0) + { + if(h > -maxspeed) + h -= quick; + } + else if(diffx < 0) + { + if(h < maxspeed) + h += quick; + } + if(diffy > 0) + { + if(v > -maxspeed) + v -= quick; + } + else if(diffy < 0) + { + if(v < maxspeed) + v += quick; + } + int ndi = speed2dir(h, v, 16); + if(ndi > 0) + di = ndi; +} + +inline void _enemy::move_enemy_template_3(int quick, int maxspeed) +{ + h = PIXEL2CS(diffy) / (1< 0) + { + if(h > -maxspeed) + h -= quick; + } + else if(diffx < 0) + { + if(h < maxspeed) + h += quick; + } + if(diffy > 0) + { + if(v > -maxspeed) + v -= quick; + } + else if(diffy < 0) + { + if(v < maxspeed) + v += quick; + } + int ndi = speed2dir(h, v, 16); + if(ndi > 0) + di = ndi; +} + +inline void _enemy::shot_template(const enemy_kind * ekp, + int shift, int rnd, int maxspeed) +{ + int vx = -diffx; + int vy = -diffy; + if(rnd) + { + vx += gamerand.get() & (rnd - 1) - (rnd >> 1); + vy += gamerand.get() & (rnd - 1) - (rnd >> 1); + } + vx = PIXEL2CS(vx) / (1< 0) + { + if(vx > maxspeed) + vx = maxspeed; + else if(vx < -maxspeed) + vx = -maxspeed; + if(vy > maxspeed) + vy = maxspeed; + else if(vy < -maxspeed) + vy = -maxspeed; + } + enemies.make(ekp, CS2PIXEL(x + vx), CS2PIXEL(y + vy), vx, + vy); + if(enemies.is_intro) + return; + if(&ring == ekp) + sound.g_launch_ring(x, y); + else if(&beam == ekp) + sound.g_launch_beam(x, y); + else if(&bomb1 == ekp || &bomb2 == ekp) + sound.g_launch_bomb(x, y); + else + sound.g_launch(x, y); +} + +void _enemy::shot_template_8_dir(const enemy_kind * ekp) +{ + static int vx[] = { 0, 200, 300, 200, 0, -200, -300, -200 }; + static int vy[] = { -300, -200, 0, 200, 300, 200, 0, -200 }; + int i; + for(i = 0; i < 8; i++) + enemies.make(ekp, CS2PIXEL(x), CS2PIXEL(y), vx[i], + vy[i]); + if(&ring == ekp) + sound.g_m_launch_ring(x, y); + else if(&beam == ekp) + sound.g_m_launch_beam(x, y); + else if(&bomb1 == ekp || &bomb2 == ekp) + sound.g_m_launch_bomb(x, y); + else + sound.g_m_launch(x, y); +} + +void _enemy::kill_default() +{ + enemies.make(enemies.randexp(), CS2PIXEL(x), CS2PIXEL(y), + h >> 1, v >> 1); + sound.g_enemy_explo(x, y); + release(); +} + + +/* + * =========================================================================== + * beam + * =========================================================================== + */ +void _enemy::make_beam() +{ + di = 1 + pubrand.get(4); + health = 1; + shootable = 0; + damage = 20; +} + +void _enemy::move_beam() +{ + if(norm >= ((VIEWLIMIT >> 1) + 32)) + release(); + di += pubrand.get(1) + 1; + if(di > 16) + di = 1; +} + +void _enemy::kill_beam() +{ + enemies.make(&beamexpl, CS2PIXEL(x), CS2PIXEL(y)); + release(); +} + +const enemy_kind beam = { + 0, + &_enemy::make_beam, + &_enemy::move_beam, + &_enemy::kill_beam, + 2, + B_BULLETS, 0, + LAYER_BULLETS +}; + +/* + * =========================================================================== + * rock + * =========================================================================== + */ +void _enemy::make_rock() +{ + count = 500; + health = game.rock_health; + damage = game.rock_damage; + di = gamerand.get(5) + 1; + a = gamerand.get(1) ? 1 : -1; + switch(gamerand.get() % 3) + { + case 0: + bank = B_ROCK1; + break; + case 1: + bank = B_ROCK2; + break; + case 2: + bank = B_ROCK3; + break; + } +} + +void _enemy::move_rock() +{ + if(bank == B_ROCK3) + { + di += a; + if(di < 1) + di += 48; + else if(di > 48) + di -= 48; + } + else + di = ((di + a - 1) & 31) + 1; +} + +void _enemy::kill_rock() +{ + enemies.make(&rockexpl, CS2PIXEL(x), CS2PIXEL(y), h >> 1, v >> 1); + sound.g_rock_explo(x, y); + release(); +} + +const enemy_kind rock = { + 10, + &_enemy::make_rock, + &_enemy::move_rock, + &_enemy::kill_rock, + 4, + B_ROCK1, 0, + LAYER_ENEMIES +}; + +/* + * =========================================================================== + * ring + * =========================================================================== + */ +void _enemy::make_ring() +{ + count = 500; + health = 20; + damage = 30; + di = 1; +} + +void _enemy::move_ring() +{ + di += 1 + pubrand.get(1); + if(di > 16) + di = 1; +} + +void _enemy::kill_ring() +{ + enemies.make(&ringexpl, CS2PIXEL(x), CS2PIXEL(y), h >> 1, v >> 1); + sound.g_ring_explo(x, y); + release(); +} + +const enemy_kind ring = { + 1, + &_enemy::make_ring, + &_enemy::move_ring, + &_enemy::kill_ring, + 4, + B_RING, 0, + LAYER_BULLETS +}; + +/* + * =========================================================================== + * bomb + * =========================================================================== + */ +void _enemy::make_bomb() +{ + count = 500; + health = 20; + damage = 70; + di = 1; +} + +void _enemy::move_bomb1() +{ + int h1 = ABS(diffx); + int v1 = ABS(diffy); + if(((h1 < 100) && (v1 < 30)) || (h1 < 30) && (v1 < 100)) + { + int vx1 = PIXEL2CS(-diffx) / (3*8); + int vy1 = PIXEL2CS(-diffy) / (3*8); + int vx2 = vx1, vx3 = vx1; + int vy2 = vy1, vy3 = vy1; + int i; + for(i = 0; i < 4; i++) + { + int tmp = vx2; + vx2 += (vy2 >> 4); + vy2 -= (tmp >> 4); + tmp = vx3; + vx3 -= (vy3 >> 4); + vy3 += (tmp >> 4); + } + enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx2, vy2); + enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx3, vy3); + enemies.make(&bombdeto, CS2PIXEL(x), CS2PIXEL(y), vx1, vy1); + sound.g_bomb_deto(x, y); + release(); + } + if(++di > 16) + di = 1; +} + +const enemy_kind bomb1 = { + 5, + &_enemy::make_bomb, + &_enemy::move_bomb1, + &_enemy::kill_default, + 5, + B_BOMB, 0, + LAYER_ENEMIES +}; + +/* + * =========================================================================== + * bomb2 + * =========================================================================== + */ +void _enemy::move_bomb2() +{ + int h1 = ABS(diffx); + int v1 = ABS(diffy); + if(((h1 < 100) && (v1 < 20)) || (h1 < 20) && (v1 < 100)) + { + int vx1 = PIXEL2CS(-diffx) / (3*8); + int vy1 = PIXEL2CS(-diffy) / (3*8); + int vx2 = vx1, vx3 = vx1; + int vy2 = vy1, vy3 = vy1; + int i; + for(i = 0; i < 6; i++) + { + int tmp = vx2; + vx2 += (vy2 >> 4); + vy2 -= (tmp >> 4); + tmp = vx3; + vx3 -= (vy3 >> 4); + vy3 += (tmp >> 4); + } + int vx4 = vx2, vx5 = vx3; + int vy4 = vy2, vy5 = vy3; + for(i = 0; i < 6; i++) + { + int tmp = vx2; + vx2 += (vy2 >> 4); + vy2 -= (tmp >> 4); + tmp = vx3; + vx3 -= (vy3 >> 4); + vy3 += (tmp >> 4); + } + enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx1, vy1); + enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx2, vy2); + enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx3, vy3); + enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx4, vy4); + enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx5, vy5); + enemies.make(&bombdeto, CS2PIXEL(x), CS2PIXEL(y), vx1, vy1); + sound.g_bomb_deto(x, y); + release(); + } + if(--di < 1) + di = 16; +} + +const enemy_kind bomb2 = { + 20, + &_enemy::make_bomb, + &_enemy::move_bomb2, + &_enemy::kill_default, + 5, + B_BOMB, 0, + LAYER_ENEMIES +}; + +/* + * =========================================================================== + * explosionX + * Various explosions + * =========================================================================== + */ +void _enemy::make_expl() +{ + health = 1; + damage = 0; + shootable = 0; + switch(bank) + { + case B_EXPLO1: + case B_BOMBDETO: + a = 8; + break; + case B_EXPLO3: + case B_EXPLO4: + case B_EXPLO5: + case B_ROCKEXPL: + a = 12; + break; + case B_RINGEXPL: + frame = 8 * pubrand.get(1); + a = 8; + break; + case B_BULLETEXPL: + a = 6; + break; + case B_BOLTEXPL: + frame = 6 * pubrand.get(1); + di = pubrand.get(2); + a = 6; + break; + } +} + +void _enemy::move_expl() +{ + if(++di > a) + release(); +} + +const enemy_kind explosion = { + 0, + &_enemy::make_expl, + &_enemy::move_expl, + &_enemy::kill_default, + -1, + B_EXPLO1, 0, + LAYER_FX +}; + +const enemy_kind explosion3 = { + 0, + &_enemy::make_expl, + &_enemy::move_expl, + &_enemy::kill_default, + -1, + B_EXPLO3, 0, + LAYER_FX +}; + +const enemy_kind explosion4 = { + 0, + &_enemy::make_expl, + &_enemy::move_expl, + &_enemy::kill_default, + -1, + B_EXPLO4, 0, + LAYER_FX +}; + +const enemy_kind explosion5 = { + 0, + &_enemy::make_expl, + &_enemy::move_expl, + &_enemy::kill_default, + -1, + B_EXPLO5, 0, + LAYER_FX +}; + +/* + * =========================================================================== + * ringexpl + * Ring dies in a flash + * =========================================================================== + */ +const enemy_kind ringexpl = { + 0, + &_enemy::make_expl, + &_enemy::move_expl, + &_enemy::kill_default, + -1, + B_RINGEXPL, 0, + LAYER_FX +}; + +/* + * =========================================================================== + * beamexpl + * Enemy "bullet" discharges + * =========================================================================== + */ +const enemy_kind beamexpl = { + 0, + &_enemy::make_expl, + &_enemy::move_expl, + &_enemy::kill_default, + -1, + B_BULLETEXPL, 0, + LAYER_FX +}; + +/* + * =========================================================================== + * boltexpl + * Player bolt discharges + * =========================================================================== + */ +const enemy_kind boltexpl = { + 0, + &_enemy::make_expl, + &_enemy::move_expl, + &_enemy::kill_default, + -1, + B_BOLTEXPL, 0, + LAYER_FX +}; + +/* + * =========================================================================== + * rockexpl + * Rock *finally* explodes + * =========================================================================== + */ +const enemy_kind rockexpl = { + 0, + &_enemy::make_expl, + &_enemy::move_expl, + &_enemy::kill_default, + -1, + B_ROCKEXPL, 0, + LAYER_FX +}; + +/* + * =========================================================================== + * bombdeto + * Bomb detonation (not really an explosion!) + * =========================================================================== + */ +const enemy_kind bombdeto = { + 0, + &_enemy::make_expl, + &_enemy::move_expl, + &_enemy::kill_default, + -1, + B_BOMBDETO, 0, + LAYER_ENEMIES +}; + +/* + * =========================================================================== + * cannon + * =========================================================================== + */ +void _enemy::make_cannon() +{ + count = 0; + health = 20; + damage = 75; + b = enemies.eint1() - 1; + a = gamerand.get() & b; +} + +void _enemy::move_cannon() +{ + (count)++; + (count) &= (b); + if(count == a && norm < ((VIEWLIMIT >> 1) + 8)) + { + int shift = (enemies.ek1() == &beam) ? 6 : 5; + this->shot_template(enemies.ek1(), shift, 32, 0); + } +} + +void _enemy::kill_cannon() +{ + enemies.make(&pipe1, CS2PIXEL(x), CS2PIXEL(y)); + sound.g_base_node_explo(x, y); + release(); +} + +const enemy_kind cannon = { + 10, + &_enemy::make_cannon, + &_enemy::move_cannon, + &_enemy::kill_cannon, + 4, + -1, 0, + LAYER_BASES +}; + +/* + * =========================================================================== + * core + * =========================================================================== + */ +void _enemy::make_core() +{ + count = 0; + health = 20; + damage = 150; + b = enemies.eint2() - 1; + a = gamerand.get() & b; +} + +void _enemy::move_core() +{ + (count)++; + (count) &= (b); + if(count == a && norm < ((VIEWLIMIT >> 1) + 8)) + { + int shift = (enemies.ek2() == &beam) ? 6 : 5; + this->shot_template(enemies.ek2(), shift, 0, 0); + } +} + +void _enemy::kill_core() +{ + enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 3); + enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 7); + enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 1); + enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 5); + enemies.make(&explosion4, CS2PIXEL(x), CS2PIXEL(y)); + sound.g_base_core_explo(x, y); + release(); + manage.destroyed_a_core(); +} + +const enemy_kind core = { + 200, + &_enemy::make_core, + &_enemy::move_core, + &_enemy::kill_core, + 4, + -1, 0, + LAYER_BASES +}; + +/* + * =========================================================================== + * pipe1 + * =========================================================================== + */ +void _enemy::make_pipe1() +{ + health = 1; + damage = 0; + shootable = 0; + count = 4; + a = 0; + b = 0; +} + +void _enemy::move_pipe1() +{ + sound.g_pipe_rumble(x, y); + if((norm < ((VIEWLIMIT >> 1) + 32)) && (count == 1)) + enemies.make(&explosion, + CS2PIXEL(x) + pubrand.get(4) - 8, + CS2PIXEL(y) + pubrand.get(4) - 8, + 0, 0, 1); + + if(++count < 4) + return; + count = 0; + + int x1 = (CS2PIXEL(x) & (WORLD_SIZEX - 1)) >> 4; + int y1 = (CS2PIXEL(y) & (WORLD_SIZEY - 1)) >> 4; + int a_next = 0; + int x_next = 0; + int y_next = 0; + int m = screen.get_map(x1, y1); + int p = MAP_BITS(m); + if(IS_SPACE(p)) + { + release(); + return; + } + if(norm < ((VIEWLIMIT >> 1) + 32)) + enemies.make(enemies.randexp(), CS2PIXEL(x), CS2PIXEL(y), + 0, 0, b); + b = 1; + if((p ^ a) == U_MASK) + { + a_next = D_MASK; + y_next = -PIXEL2CS(16); + } + if((p ^ a) == R_MASK) + { + a_next = L_MASK; + x_next = PIXEL2CS(16); + } + if((p ^ a) == D_MASK) + { + a_next = U_MASK; + y_next = PIXEL2CS(16); + } + if((p ^ a) == L_MASK) + { + a_next = R_MASK; + x_next = -PIXEL2CS(16); + } + if(a_next) + { + screen.set_map(x1, y1, 0); + x += x_next; + y += y_next; + a = a_next; + return; + } + if(!(p & CORE)) + screen.set_map(x1, y1, m ^ a); + release(); +} +const enemy_kind pipe1 = { + 0, + &_enemy::make_pipe1, + &_enemy::move_pipe1, + &_enemy::kill_default, + -1, + -1, 0, + LAYER_BASES +}; + +/* + * =========================================================================== + * pipe2 + * =========================================================================== + */ +void _enemy::make_pipe2() +{ + int x1 = (CS2PIXEL(x) & (WORLD_SIZEX - 1)) >> 4; + int y1 = (CS2PIXEL(y) & (WORLD_SIZEY - 1)) >> 4; + + screen.set_map(x1, y1, 0); + health = 1; + damage = 0; + shootable = 0; + count = 4; + switch (di) + { + case 1: + a = D_MASK; + y -= PIXEL2CS(16); + break; + case 3: + a = L_MASK; + x += PIXEL2CS(16); + break; + case 5: + a = U_MASK; + y += PIXEL2CS(16); + break; + case 7: + a = R_MASK; + x -= PIXEL2CS(16); + break; + } +} + + +void _enemy::move_pipe2() +{ + if((norm < ((VIEWLIMIT >> 1) + 32)) && (count == 1)) + enemies.make(&explosion, + CS2PIXEL(x) + pubrand.get(4) - 8, + CS2PIXEL(y) + pubrand.get(4) - 8, + 0, 0, 1); + if(++count < 4) + { + sound.g_pipe_rumble(x, y); + return; + } + count = 0; + + int x1 = (CS2PIXEL(x) & (WORLD_SIZEX - 1)) >> 4; + int y1 = (CS2PIXEL(y) & (WORLD_SIZEY - 1)) >> 4; + int a_next = 0; + int x_next = 0; + int y_next = 0; + int p = MAP_BITS(screen.get_map(x1, y1)); + if(IS_SPACE(p)) + { + release(); + return; + } + if((p ^ a) == 0) + { + manage.add_score(30); + release(); + enemies.erase_cannon(x1, y1); + screen.set_map(x1, y1, 0); + sound.g_base_node_explo(x, y); + if(norm < ((VIEWLIMIT >> 1) + 32)) + enemies.make(enemies.randexp(), CS2PIXEL(x), CS2PIXEL(y)); + return; + } + if((p ^ a) == HARD) + { + release(); + screen.set_map(x1, y1, 0); + sound.g_pipe_rumble(x, y); + if(norm < ((VIEWLIMIT >> 1) + 32)) + enemies.make(enemies.randexp(), CS2PIXEL(x), CS2PIXEL(y), + 0, 0, 1); + return; + } + if((p ^ a) == U_MASK) + { + a_next = D_MASK; + y_next = -PIXEL2CS(16); + } + if((p ^ a) == R_MASK) + { + a_next = L_MASK; + x_next = PIXEL2CS(16); + } + if((p ^ a) == D_MASK) + { + a_next = U_MASK; + y_next = PIXEL2CS(16); + } + if((p ^ a) == L_MASK) + { + a_next = R_MASK; + x_next = -PIXEL2CS(16); + } + screen.set_map(x1, y1, 0); + sound.g_pipe_rumble(x, y); + if(norm < ((VIEWLIMIT >> 1) + 32)) + enemies.make(enemies.randexp(), CS2PIXEL(x), CS2PIXEL(y), + 0, 0, 1); + if(a_next) + { + x += x_next; + y += y_next; + a = a_next; + return; + } + p ^= a; + if(p & U_MASK) + enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 1); + if(p & R_MASK) + enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 3); + if(p & D_MASK) + enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 5); + if(p & L_MASK) + enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 7); + manage.add_score(10); + release(); +} + + +const enemy_kind pipe2 = { + 0, + &_enemy::make_pipe2, + &_enemy::move_pipe2, + &_enemy::kill_default, + -1, + -1, 0, + LAYER_BASES +}; + +/* + * =========================================================================== + * enemy1 + * Gray Dumb Missile + * =========================================================================== + */ +void _enemy::make_enemy1() +{ + di = 1; + health = 20; +} + +void _enemy::move_enemy1() +{ + this->move_enemy_template(2, 256); +} +const enemy_kind enemy1 = { + 2, + &_enemy::make_enemy1, + &_enemy::move_enemy1, + &_enemy::kill_default, + 6, + B_MISSILE1, 0, + LAYER_ENEMIES +}; + +/* + * =========================================================================== + * enemy2 + * Teal Firing Fighter + * =========================================================================== + */ +void _enemy::make_enemy2() +{ + di = 1; + health = 20; + count = gamerand.get() & 63; +} + +void _enemy::move_enemy2() +{ + this->move_enemy_template(4, 192); + if(--(count) <= 0) + { + if(norm < ((VIEWLIMIT >> 1) + 8)) + { + this->shot_template(&beam, 5, 0, 0); + } + count = 32; + } +} +const enemy_kind enemy2 = { + 10, + &_enemy::make_enemy2, + &_enemy::move_enemy2, + &_enemy::kill_default, + 6, + B_FIGHTER, 0, + LAYER_ENEMIES +}; + +/* + * =========================================================================== + * enemy3 + * Maroon Homing Missile + * =========================================================================== + */ +void _enemy::make_enemy3() +{ + di = 1; + health = 20; +} + +void _enemy::move_enemy3() +{ + this->move_enemy_template(32, 96); +} +const enemy_kind enemy3 = { + 1, + &_enemy::make_enemy3, + &_enemy::move_enemy3, + &_enemy::kill_default, + 6, + B_MISSILE2, 0, + LAYER_ENEMIES +}; + +/* + * =========================================================================== + * enemy4 + * Blue Homing Missile + * =========================================================================== + */ +void _enemy::make_enemy4() +{ + di = 1; + health = 20; +} + +void _enemy::move_enemy4() +{ + this->move_enemy_template(4, 96); +} +const enemy_kind enemy4 = { + 1, + &_enemy::make_enemy4, + &_enemy::move_enemy4, + &_enemy::kill_default, + 6, + B_MISSILE3, 0, + LAYER_ENEMIES +}; + +/* + * =========================================================================== + * enemy5 + * Green Boomerang Fighter + * =========================================================================== + */ +void _enemy::make_enemy() +{ + count = gamerand.get() & 127; + di = 1; + health = 20; + a = 0; +} + +void _enemy::move_enemy5() +{ + if(a == 0) + { + if(norm > ((VIEWLIMIT >> 1) - 32)) + this->move_enemy_template(6, 192); + else + a = 1; + } + else + { + if(norm < VIEWLIMIT) + this->move_enemy_template_2(4, 192); + else + a = 0; + } + if(enemies.is_intro) + { + if(gamerand.get(7) > 110) + hit(1); + } + else if((--count) <= 0) + { + count = 8; + if(norm > ((VIEWLIMIT >> 1) - 32)) + this->shot_template(&beam, 6, 0, 0); + } +} +const enemy_kind enemy5 = { + 5, + &_enemy::make_enemy, + &_enemy::move_enemy5, + &_enemy::kill_default, + 6, + B_BMR_GREEN, 0, + LAYER_ENEMIES +}; + +/* + * =========================================================================== + * enemy6 + * Purple Boomerang Fighter + * =========================================================================== + */ +void _enemy::move_enemy6() +{ + if(a == 0) + { + if(norm > ((VIEWLIMIT >> 1) - 0)) + this->move_enemy_template(6, 192); + else + a = 1; + } + else + { + if(norm < VIEWLIMIT) + this->move_enemy_template_2(5, 192); + else + a = 0; + } + if((--count) <= 0) + { + count = 128; + if(norm > ((VIEWLIMIT >> 1) - 32)) + this->shot_template(&beam, 6, 0, 0); + } +} +const enemy_kind enemy6 = { + 2, + &_enemy::make_enemy, + &_enemy::move_enemy6, + &_enemy::kill_default, + 6, + B_BMR_PURPLE, 0, + LAYER_ENEMIES +}; + +/* + * =========================================================================== + * enemy7 + * Pink Boomerang Fighter + * =========================================================================== + */ +void _enemy::move_enemy7() +{ + if(a == 0) + { + if(norm > ((VIEWLIMIT >> 1) - 32)) + this->move_enemy_template(6, 192); + else + a = 1; + } + else + { + if(norm < VIEWLIMIT) + this->move_enemy_template_3(4, 192); + else + a = 0; + } + if(enemies.is_intro) + { + if(gamerand.get(7) > 110) + hit(1); + } + else if((--count) <= 0) + { + count = 8; + if(norm > ((VIEWLIMIT >> 1) - 32)) + this->shot_template(&beam, 6, 0, 0); + } +} +const enemy_kind enemy7 = { + 5, + &_enemy::make_enemy, + &_enemy::move_enemy7, + &_enemy::kill_default, + 6, + B_BMR_PINK, 0, + LAYER_ENEMIES +}; +/* + * =========================================================================== + * enemy_m1 + * =========================================================================== + */ +void _enemy::make_enemy_m1() +{ + di = 1; + health = 20 * 26; + count = gamerand.get() & 15; +} + +void _enemy::move_enemy_m1() +{ + this->move_enemy_m(3, 128); + if(++di > 16) + di = 1; + if((count--) <= 0) + { + count = 4; + if(norm < ((VIEWLIMIT >> 1) - 16)) + { + this->shot_template(&enemy1, 4, 0, 0); + } + } + if(health < 200) + { + this->shot_template_8_dir(&enemy2); + release(); + } +} +const enemy_kind enemy_m1 = { + 50, + &_enemy::make_enemy_m1, + &_enemy::move_enemy_m1, + &_enemy::kill_default, + 12, + B_BIGSHIP, 0, + LAYER_ENEMIES +}; + +/* + * =========================================================================== + * enemy_m2 + * =========================================================================== + */ +void _enemy::make_enemy_m2() +{ + di = 1; + health = 20 * 26; + count = gamerand.get() & 15; +} + +void _enemy::move_enemy_m2() +{ + this->move_enemy_m(3, 128); + if(++di > 16) + di = 1; + if((count--) <= 0) + { + count = 8; + if(norm < ((VIEWLIMIT >> 1) + 8)) + { + this->shot_template(&enemy2, 4, 128, 192); + } + } + if(health < 200) + { + this->shot_template_8_dir(&bomb2); + release(); + } +} +const enemy_kind enemy_m2 = { + 50, + &_enemy::make_enemy_m2, + &_enemy::move_enemy_m2, + &_enemy::kill_default, + 12, + B_BIGSHIP, 0, + LAYER_ENEMIES +}; + +/* + * =========================================================================== + * enemy_m3 + * =========================================================================== + */ +void _enemy::make_enemy_m3() +{ + di = 1; + health = 20 * 26; + count = gamerand.get() & 15; +} + +void _enemy::move_enemy_m3() +{ + this->move_enemy_m(3, 128); + if(--di < 1) + di = 16; + if((count--) <= 0) + { + count = 64; + if(norm < ((VIEWLIMIT >> 1) + 8)) + { + this->shot_template_8_dir(&bomb2); + } + } + if(health < 200) + { + this->shot_template_8_dir(&rock); + release(); + } +} +const enemy_kind enemy_m3 = { + 50, + &_enemy::make_enemy_m3, + &_enemy::move_enemy_m3, + &_enemy::kill_default, + 12, + B_BIGSHIP, 0, + LAYER_ENEMIES +}; + +/* + * =========================================================================== + * enemy_m4 + * =========================================================================== + */ +void _enemy::make_enemy_m4() +{ + di = 1; + health = 20 * 26; + count = gamerand.get() & 15; +} + +void _enemy::move_enemy_m4() +{ + this->move_enemy_m(2, 96); + if(--di < 1) + di = 16; + static const enemy_kind *shot[8] = { + &enemy1, &enemy2, &bomb2, &ring, &enemy1, &enemy2, &ring, + &enemy1 + }; + if((count--) <= 0) + { + count = 64; + if(norm < ((VIEWLIMIT >> 1) + 8)) + { + this->shot_template_8_dir(shot[gamerand.get() & 7]); + } + } + if(health < 200) + { + this->shot_template_8_dir(&rock); + release(); + } +} +const enemy_kind enemy_m4 = { + 100, + &_enemy::make_enemy_m4, + &_enemy::move_enemy_m4, + &_enemy::kill_default, + 12, + B_BIGSHIP, 0, + LAYER_ENEMIES +}; + + +/*---------------------------------------------------------------------------*/ +/* void _enemy::make_xxxx(){} + * void _enemy::move_xxxx(){} + * void _enemy::die_xxxx(){} + * enemy_kind xxxxx = { + * score, + * make_xxxx, move_xxxx, die_xxx, + * hitsize, + * bank, frame, tilesize + * }; + */ diff --git a/filemap.cpp b/filemap.cpp new file mode 100644 index 0000000..e0d75e8 --- /dev/null +++ b/filemap.cpp @@ -0,0 +1,857 @@ +/*(LGPL) +------------------------------------------------------------ + filemap.cpp - Simple Portable File Path Mapper +------------------------------------------------------------ + * Copyright (C) David Olofson, 2001, 2003, 2007 + * This code is released under the terms of the GNU LGPL. + */ + +#include "config.h" +#include "kobolog.h" + +#include "filemap.h" + +#include +#include +#include +#include + +#ifdef HAVE_STAT +#include +#include +#endif + + +fm_object_t::~fm_object_t() +{ + free(path); +} + + +/* + * Delete the 'count' first bytes of a string. + * Does *not* realloc(), so it's safe to use + * on static or local (stack) buffers. + * + * Returns new length of string. + */ +static int strdel(char *str, int count) +{ + int len = strlen(str); + memmove(str, str+count, len-count+1); + return len-count; +} + + +/* + * Inserts string 'ins' into 'str', starting at 'pos'. + * Does *not* realloc(), so it's safe to use + * on static or local (stack) buffers. + * + * Relies on FM_BUFFER_SIZE to prevent buffer overflow! + * (In fact, it stops at (str + FM_BUFFER_SIZE - 1) to + * ensure that the result is NULL terminated.) + * + * Returns new length of string. + */ +static int strins(char *str, const char *ins, int pos) +{ + char *cpy = strdup(str+pos); + if(!cpy) + return strlen(str); //Silly but harmless... + + snprintf(str+pos, FM_BUFFER_SIZE-pos-1, "%s%s", ins, cpy); + str[FM_BUFFER_SIZE - 1] = 0; + free(cpy); + return strlen(str); +} + + +filemapper_t::filemapper_t() +{ + keys = NULL; + app_path = strdup("."); + next_buffer = 0; + objects = NULL; + current_obj = NULL; + + /* + * I'll put this here for now. + * Don't know if it's the perfect place... + */ + char *home = (char *)getenv("HOME"); + if(home) + addpath("HOME", home); +} + + +filemapper_t::~filemapper_t() +{ + fm_key_t *k = keys; + while(k) + { + fm_key_t *nk = k->next; + free(k->path); + delete k; + k = nk; + } + while(objects) + { + fm_object_t *o = objects; + objects = objects->next; + delete o; + } + free(app_path); +} + + +char *filemapper_t::salloc() +{ + char *b = buffers[next_buffer++]; + if(next_buffer >= FM_BUFFERS) + next_buffer = 0; + return b; +} + + +void filemapper_t::no_double_slashes(char *buf) +{ + /* + * Clean slashes + */ + char *c = buf; + while(c[0]) + { + if(c[0] == '/') + { + if(0 == c[1]) + c[0] = 0; + else + while('/' == c[1]) + strdel(c + 1, 1); + } + ++c; + } +} + + +void filemapper_t::unix_slashes(char *buf) +{ + /* + * Convert "~/" into "HOME>>". + */ + if(strncmp(buf, "~/", 2) == 0) + { + strdel(buf, 2); + strins(buf, "HOME" FM_DEREF_TOKEN, 0); + } + +#if defined(WIN32) + int len = strlen(buf); + for(int i = 0; i < len; ++i) + if(buf[i] == '\\') + buf[i] = '/'; +#elif defined(MACOS) + int start = 0; + int len = strlen(buf); + for(int i = start; i < len; ++i) + if(buf[i] == ':') + buf[i] = '/'; +#endif + no_double_slashes(buf); +} + + +void filemapper_t::sys_slashes(char *buf) +{ + no_double_slashes(buf); + +#if defined(WIN32) + int len; + if(strncmp(buf, "./", 2) == 0) + len = strdel(buf, 2); + else + len = strlen(buf); + for(int i = 0; i < len; ++i) + if(buf[i] == '/') + buf[i] = '\\'; +#elif defined(MACOS) + /* + * Untested. + */ + int len; + if(strncmp(buf, "./", 2) == 0) + len = strdel(buf, 2); + else + len = strlen(buf); + /* Fix absolute/relative */ + if(buf[0] == '/') + len = strdel(buf, 1); + else + { + memmove(buf + 1, buf, len); + ++len; + buf[0] = ':'; + } + /* + * '/' --> ':' + */ + for(int i = 0; i < len; ++i) + if(buf[i] == '/') + buf[i] = ':'; + /* + * "..:" --> "::" + */ + for(int i = 0; i < len; ++i) + if(strncmp(buf + i, "..:", 3) == 0) + { + strdel(buf + i, 1); + buf[i] = ':'; + --len; + } +#endif +} + + +void filemapper_t::exepath(const char *appname) +{ + free(app_path); + app_path = strdup(sys2unix(appname)); + if(app_path) + { + char *c = strrchr(app_path, '/'); + if(c) + c[0] = 0; + else + { + free(app_path); + app_path = strdup("."); + } + } + else + app_path = strdup("."); + addpath("EXE", app_path); + log_printf(DLOG, "Application path: '%s'\n", app_path); +} + + +void filemapper_t::addpath(const char *key, const char *path, int first) +{ + fm_key_t *k, *insk; + try + { + k = new fm_key_t; + strncpy(k->key, key, 8); + k->key[8] = 0; + k->path = strdup(path); + if(!k->path) + { + delete k; + return; + } + if(first) + { + k->next = keys; + keys = k; + } + else + { + k->next = NULL; + if(keys) + { + insk = keys; + while(insk->next) + insk = insk->next; + insk->next = k; + } + else + keys = k; + } + } + catch(...) + { + return; + } +} + + +fm_key_t *filemapper_t::getkey(fm_key_t *key, const char *ref) +{ + int all = ref ? 0 : (ref[0] == '*'); + if(key) + { + if(!ref) + ref = key->key; + else if(all) + return key->next; + else + key = key->next; + } + else + { + if(!ref || all) + return keys; + else + key = keys; + } + + while(key) + { + if(strcmp(key->key, ref) == 0) + return key; + key = key->next; + } + return NULL; +} + + +/* + * Checks if an object exists, and if so, what kind it is. + */ +int filemapper_t::probe(const char *syspath) +{ +#ifdef HAVE_STAT + struct stat st; +// log_printf(DLOG, "probe(\"%s\") (with stat())\n", syspath); + if(::stat(syspath, &st) == 0) + { + if(S_ISDIR(st.st_mode)) + return FM_DIR; + else + return FM_FILE; + } +#else +#warning This platform lacks stat(). File/directory probing may be unreliable! + // This is wrong and weird, but *does* in fact + // work on Linux... where it isn't needed! *heh* + // (Opening a dir with "r" will succeed on Linux, BTW...) + FILE *f = ::fopen(syspath, "r+"); +// log_printf(DLOG, "probe(\"%s\") (with fopen())\n", syspath); + if(f) + { + ::fclose(f); + return FM_FILE; + } + else + if(errno == EISDIR) + return FM_DIR; +#endif + return FM_ERROR; +} + + +/* + * Create a file for writing, or if it exists, test if it + * can be opened in write mode. + * + * Returns + * FM_FILE if the file exists and is writable, + * FM_FILE_CREATE if the file had to be created, + * FM_DIR if the path leads to a directory, or + * FM_ERROR if the object is not a writable file. + */ +int filemapper_t::test_file_create(const char *syspath) +{ + int exists = (probe(syspath) == FM_FILE); + FILE *f = ::fopen(syspath, "a"); + if(f) + { + fclose(f); + if(exists) + { +// log_printf(DLOG, " File is writable!\n"); + return FM_FILE; + } + else + { +// log_printf(DLOG, " File created!\n"); + return FM_FILE_CREATE; + } + } + else + { + if(errno == EISDIR) + { +// log_printf(DLOG, " Is a directory.\n"); + return FM_DIR; + } +// else +// log_printf(DLOG, " Nope.\n"); + } + return FM_ERROR; +} + + +int filemapper_t::test_file_dir_any(const char *syspath, int kind) +{ + int res = probe(syspath); + switch (res) + { + case FM_ERROR: +// log_printf(DLOG, " Nope.\n"); + break; + case FM_FILE: + if((kind == FM_ANY) || (kind == FM_FILE)) + { +// log_printf(DLOG, " Found! (File)\n"); + return 1; + } + break; + case FM_DIR: + if((kind == FM_ANY) || (kind == FM_DIR)) + { +// log_printf(DLOG, " Found! (Dir)\n"); + return 1; + } + break; + case FM_ANY: + log_printf(ELOG, "INTERNAL ERROR: filemapper_t::probe()" + " returned FM_ANY...\n"); + break; + } + if(res != FM_ERROR) + switch (kind) + { + case FM_FILE: +// log_printf(DLOG, " Not a file.\n"); + break; + case FM_DIR: +// log_printf(DLOG, " Not a directory.\n"); + break; + default: + break; + } + return 0; +} + + +char *filemapper_t::sys2unix(const char *syspath) +{ + char *buffer = salloc(); + strncpy(buffer, syspath, FM_BUFFER_SIZE - 1); + buffer[FM_BUFFER_SIZE - 1] = 0; + unix_slashes(buffer); + return buffer; +} + + +char *filemapper_t::unix2sys(const char *path) +{ + char *buffer = salloc(); + strncpy(buffer, path, FM_BUFFER_SIZE - 1); + buffer[FM_BUFFER_SIZE - 1] = 0; + sys_slashes(buffer); + return buffer; +} + + +/* + * Try the specified operation on a path. + * The path must be in *system* format. + */ +int filemapper_t::try_get(const char *path, int kind) +{ + switch (kind) + { + case FM_FILE: + case FM_DIR: + case FM_ANY: + if(test_file_dir_any(path, kind)) + return 1; + break; + case FM_FILE_CREATE: + switch (test_file_create(path)) + { + case FM_FILE: + case FM_FILE_CREATE: + return 1; + default: + break; + } + break; + default: + break; + } + return 0; +} + + +void filemapper_t::add_object(const char *path, int kind) +{ + try + { + fm_object_t *obj = new fm_object_t; + obj->path = strdup(path); + if(!obj->path) + { + delete obj; + return; + } + obj->kind = kind; + + obj->next = NULL; + if(objects) + { + fm_object_t *insobj = objects; + while(insobj->next) + insobj = insobj->next; + insobj->next = obj; + } + else + objects = obj; + } + catch(...) + { + return; + } +} + + +/* + * Parse the specified path, recurse through all possible + * combinations, trying each terminal with try_get(). + * + * When the 'build' argument is 0, the function returns + * the first valid hit. + * + * 'ref' must be in unix format, but 'result' will be in + * system format. + * + * NEW MODE: + * When the 'build' argument is non-zero, all + * possible paths are generated and tested. All + * valid objects are added to a linked list of + * fm_object_t. + * + * Note that in this mode, 'result' is not used + * or set! You may pass NULL. + * +TODO: Wildcards... + * + */ +int filemapper_t::recurse_get(char *result, const char *ref, int kind, + int level, int build) +{ +// log_printf(DLOG, " [level %d]\n", level); + char buffer[FM_BUFFER_SIZE]; + strncpy(buffer, ref, FM_BUFFER_SIZE); + + // Check for the ">>" dereferencing token. + char *obj = (char *)strstr(ref, FM_DEREF_TOKEN); + + // If there isn't one, the object path will + // be tried as is. + if(!obj) + { + int res; + snprintf(buffer, FM_BUFFER_SIZE, "%s", ref); + buffer[FM_BUFFER_SIZE-1] = 0; +#if 0 + { + for(int s=0; s>" + if(len > 8) + len = 8; + memcpy(kclass, ref, len); + kclass[len] = 0; + + fm_key_t *k = NULL; + int hits = 0; + while( (k = getkey(k, kclass)) ) + { + ++hits; + snprintf(buffer, FM_BUFFER_SIZE, "%s/%s", k->path, obj); + buffer[FM_BUFFER_SIZE-1] = 0; +#if 0 + { + for(int s=0; spath); + if(dt[2] == '/') // No slash after ">>"! + strdel(dt + 2, 1); + res = recurse_get(buffer, buffer, kind, level + 1, + build); + } + else + { +// log_printf(DLOG, "Trying '%s' -> '%s'...", k->key, +// k->path); + sys_slashes(buffer); + res = try_get(buffer, kind); + if(build && res) + add_object(buffer, kind); + } + if(res && !build) + { + strncpy(result, buffer, FM_BUFFER_SIZE); + return 1; + } + } +#if 0 + if(!hits) + { + for(int s=0; snext; + delete obj; + } + + if(kind == FM_FILE_CREATE) + { +// log_printf(ELOG, "filemapper_t: Tried to create files" +// " in get_all()!\n"); + return; + } +#if 0 + else if(kind == FM_DIR) + log_printf(DLOG, "get_all('%s', DIR)...", ref); + else + log_printf(DLOG, "get_all('%s')...", ref); +#endif + recurse_get(NULL, ref, kind, 1, 1); + current_obj = objects; + current_dir = NULL; +} + + +const char *filemapper_t::get_next() +{ + while(1) + { + if(!current_dir) + { + // + // Get next object! + // + if(!current_obj) + return NULL; //All done. + + switch(probe(current_obj->path)) + { + case FM_FILE: + { + const char *res = current_obj->path; + current_obj = current_obj->next; +// log_printf(DLOG, "get_next() found file '%s'.\n", res); + return res; + } + case FM_DIR: + current_dir = ::opendir(current_obj->path); +// log_printf(DLOG, "get_next() found dir '%s'.\n", +// current_obj->path); + if(!current_dir) + { + //Couldn't opendir()! Skip object... + current_obj = current_obj->next; + continue; + } + break; + default: + //Probing failed! Skip this object. +// log_printf(DLOG, "get_next(): Object '%s' skipped!\n", +// current_obj->path); + current_obj = current_obj->next; + continue; + } + } + + // + // Get first/next dir entry! + // + struct dirent *d = readdir(current_dir); + if(!d) + { + // Error or end-of-dir ==> try next object + closedir(current_dir); + current_dir = NULL; + current_obj = current_obj->next; +// log_printf(DLOG, "get_next(): end-of-dir\n"); + continue; + } + + // Get dir entry + char *path = salloc(); + if(!path) + { + log_printf(CELOG, "Out of memory in get_next()!\n", path); + return NULL; + } + + // Skip "parent dir" links! +#ifdef MACOS + if(!strcmp(d->d_name, "::")) //??? +#else + if(!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) +#endif + continue; + + // Check dir entry! + snprintf(path, FM_BUFFER_SIZE, +#ifdef WIN32 + "%s\\%s", +#elif defined(MACOS) + "%s:%s", +#else + "%s/%s", +#endif + current_obj->path, d->d_name); + switch(probe(path)) + { + case FM_FILE: +// log_printf(DLOG, "get_next() found file '%s'.\n", path); + return path; + case FM_DIR: + //We don't do recursive, so skip subdirs... +// log_printf(DLOG, "get_next() found dir '%s'.\n", path); + continue; + default: +// log_printf(DLOG, "get_next() found crap in dir.\n"); + continue; + } + } +} + + +FILE *filemapper_t::fopen(const char *ref, const char *mode) +{ + const char *path = NULL; + int md = 0; + + if(strchr(mode, 'r')) + md = 1; + else if(strchr(mode, 'w')) + md = 3; + else if(strchr(mode, 'a')) + md = 5; + if(md) + if(strchr(mode, '+')) + md += 1; + + switch(md) + { + case 0: //Error! + return NULL; + case 1: //r + case 2: //r+ + path = get(ref, FM_FILE); + break; + case 3: //w + case 4: //w+ + case 5: //a + case 6: //a+ + path = get(ref, FM_FILE_CREATE); + break; + } + if(path) + return ::fopen(path, mode); + else + return NULL; +} + + +DIR *filemapper_t::opendir(const char *ref) +{ + const char *path = get(ref, FM_DIR); + if(path) + return ::opendir(path); + else + return NULL; +} + + +int filemapper_t::mkdir(const char *ref, int perm) +{ + log_printf(ELOG, "filemapper_t::mkdir() not yet implemented!\n"); + return -1; +#if 0 + const char *path = get(ref, FM_DIR_CREATE); +// ::mkdir(path, perm); +#endif +} + + +void filemapper_t::print(FILE *f, const char *ref) +{ + char key[9]; + key[8] = 0; + char *obj = (char *)strstr(ref, FM_DEREF_TOKEN); + if(!obj) + strncpy(key, ref, 8); + else + { + int len = obj - ref; + strncpy(key, ref, 8); + if(len > 8) + len = 8; + key[len] = 0; + } + int all = (key[0] == '*'); + fm_key_t *k = keys; + while(k) + { + if(strcmp(k->key, key) == 0 || all) + fprintf(f, "%s"FM_DEREF_TOKEN" --> \"%s\"\n", k->key, k->path); + k = k->next; + } +} diff --git a/filemap.h b/filemap.h new file mode 100644 index 0000000..de091a0 --- /dev/null +++ b/filemap.h @@ -0,0 +1,170 @@ +/* +------------------------------------------------------------ + filemap.h - Simple Portable File Path Mapper +------------------------------------------------------------ + * © David Olofson, 2001 + * This code is released under the terms of the GNU LGPL. + */ + +/* + * Path syntax: + * All filemapper_t functions but exepath() + * and sys2unix() (obviously!) expect paths in the + * native system format. + * + * ALL OTHER PATHS SHOULD BE IN UNIX FORMAT. + * + * All arguments that are expected to be in system + * format are named along the lines of "syspath". + * + * Classes: + * The 'class>>' construct expands to one of the + * paths registered for 'class', or makes the mapping + * fail (NULL is returned), if the object doesn't + * exist or cannot be created as applicable. + * + * Class references are recursive, and are resolved + * late, at mapping time. (That is, they are resolved + * when someone asks for it, not when registering + * paths.) + * + * Class "HOME>>" is built-in, and resolves to the + * root of the user home directory. (Currently + * looks only at the environment variable "HOME", + * which may not be defined on all platforms.) + * + * Class "EXE>>" is another built-in, and refers to + * the path extracted from exepath(). + */ + +#ifndef _FILEMAP_H_ +#define _FILEMAP_H_ + +#include "aconfig.h" + +#define FM_DEREF_TOKEN ">>" + +#include +#include + +#define FM_BUFFERS 16 +#define FM_BUFFER_SIZE 512 + + +struct fm_key_t +{ + fm_key_t *next; + char key[10]; + char *path; +}; + + +enum +{ + FM_ERROR = 0, + FM_FILE, + FM_DIR, + FM_ANY, + FM_FILE_CREATE, + FM_DIR_CREATE +}; + + +// Not a great name - but fm_path_t would just be confusing, +// and an fm_object_t can actually be either a dir or a file. +struct fm_object_t +{ + fm_object_t *next; + char *path; + int kind; + ~fm_object_t(); +}; + + +class filemapper_t +{ + // For get_(first|next)() + fm_object_t *objects; + fm_object_t *current_obj; + DIR *current_dir; + + // File mapper keys + fm_key_t *keys; + + // Application executable path + char *app_path; + + // Silly/safe/string alloc :-) + char buffers[FM_BUFFERS][FM_BUFFER_SIZE]; + int next_buffer; + char *salloc(); + + // Various private funcs + void no_double_slashes(char *buf); + void unix_slashes(char *buf); + void sys_slashes(char *buf); + int probe(const char *syspath); + int test_file_create(const char *syspath); + int test_file_dir_any(const char *syspath, int kind); + int try_get(const char *path, int kind); + void add_object(const char *path, int kind); + int recurse_get(char *result, const char *ref, int kind, + int level, int build); + public: + filemapper_t(); + ~filemapper_t(); + + // Set/get path to exe file. + // Note that exepath() expects a + // path in the *native system* format, + // while exepath() returns a Unix path. + void exepath(const char *syspath); + const char *exepath() { return app_path; } + + // Add 'path' to class 'key'. + // Key should be given *without* the '::'. + void addpath(const char *key, const char *path, int first = 0); + + // key == NULL, ref == NULL or "*": + // Get first key. + // key == NULL, ref == : + // Get first key of class 'ref'. + // key == , ref == NULL: + // Get next key of same class as 'key'. + // key == , ref == : + // Get next key of class 'ref'. + // The "*" wildcard for 'ref' is allowed. + // Returns NULL if no key was found. + fm_key_t *getkey(fm_key_t *key = NULL, const char *ref = NULL); + + // Get object path (returns path in system format!) + const char *get(const char *ref, int kind = FM_FILE); + +/* +FIXME: Do these really handle the 'kind' argument properly...? +FIXME: When looking for files, they should return only files +FIXME: matching the 'ref' path, while when looking for dirs, +FIXME: every file inside each matching dir should be returned. +*/ + // Initialize path scan. Use get_next() to get the + // paths to all matches. + void get_all(const char *ref, int kind = FM_FILE); + + // Get next object (returns path in system format!) + const char *get_next(); + + // Open/create file/dir. + FILE *fopen(const char *ref, const char *mode); + DIR *opendir(const char *ref); + int mkdir(const char *ref, int perm); + + // Print out all registered paths of class 'ref' + // to stream 'f'. (ref == '*') ==> All classes. + void print(FILE *f, const char *ref); + + // Translate to and from the internal Unix-like path format + char *sys2unix(const char *syspath); + char *unix2sys(const char *path); +}; + +#endif diff --git a/form.cpp b/form.cpp new file mode 100644 index 0000000..6d0375a --- /dev/null +++ b/form.cpp @@ -0,0 +1,321 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 2001, 2002, 2007 David Olofson + * Copyright (C) 2005 Erik Auerswald + * + * 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. + */ + +#define DBG(x) + +#include "kobolog.h" +#include "config.h" +#include "form.h" +#include "kobo.h" +#include "audio.h" + +kobo_form_t::kobo_form_t() +{ + ypos = 0; + current_list = NULL; + _big = 0; + xoffs = 0.5; + halign = ALIGN_DEFAULT; +} + + +kobo_form_t::~kobo_form_t() +{ +} + + +void kobo_form_t::next() +{ + sound.ui_move(); + ct_form_t::next(); +} + + +void kobo_form_t::prev() +{ + sound.ui_move(); + ct_form_t::prev(); +} + + +/* virtual */ void kobo_form_t::change(int delta) +{ + ct_form_t::change(delta); + if(selected()->user) + { + int *val = (int *)selected()->user; + *val = selected()->value(); + DBG(log_printf(D2LOG, "Changed to %d\n", selected()->value());) + } +} + + +/* virtual */void kobo_form_t::build() +{ +} + + +void kobo_form_t::init_widget(ct_widget_t *w) +{ + current_widget = w; + w->init(engine); + switch(_big) + { + case 0: + w->place(x(), y()+ypos, width(), LINE_H); + w->font(B_NORMAL_FONT); + ypos += LINE_H; + break; + case 1: + w->place(x(), y()+ypos, width(), BIG_LINE_H); + w->font(B_BIG_FONT); + ypos += BIG_LINE_H; + break; + case 2: + w->place(x(), y()+ypos, width(), BIG_LINE_H); + w->font(B_MEDIUM_FONT); + ypos += BIG_LINE_H; + break; + } + w->halign(halign); + add(w); +} + + +void kobo_form_t::big() +{ + _big = 1; +} + + +void kobo_form_t::medium() +{ + _big = 2; +} + + +void kobo_form_t::small() +{ + _big = 0; +} + + +void kobo_form_t::begin() +{ + clean(); + ypos = 15; + current_list = NULL; + small(); +} + + +void kobo_form_t::label(const char *cap) +{ + ct_label_t *w = new ct_label_t(cap); + init_widget(w); +} + + +void kobo_form_t::yesno(const char *cap, int *var, int tag) +{ + current_list = new ct_list_t(cap); + current_list->offset(xoffs, 0); + current_list->user = var; + current_list->tag = tag; + current_list->add("Yes", 1); + current_list->add("No", 0); + init_widget(current_list); +} + + +void kobo_form_t::onoff(const char *cap, int *var, int tag) +{ + current_list = new ct_list_t(cap); + current_list->offset(xoffs, 0); + current_list->user = var; + current_list->tag = tag; + current_list->add("On", 1); + current_list->add("Off", 0); + init_widget(current_list); +} + + +void kobo_form_t::spin(const char *cap, int *var, int min, int max, + const char *unit, int tag) +{ + ct_spin_t *w = new ct_spin_t(cap, min, max, unit); + w->offset(xoffs, 0); + w->user = var; + w->tag = tag; + init_widget(w); +} + + +void kobo_form_t::list(const char *cap, int *var, int tag) +{ + ct_list_t *w = new ct_list_t(cap); + w->offset(xoffs, 0); + w->user = var; + w->tag = tag; + current_list = w; + init_widget(w); +} + + +void kobo_form_t::item(const char *cap, int value, int ind) +{ + if(current_list) + { + ct_item_t *i = new ct_item_t(cap, value); + i->index(ind); + current_list->add(i); + } + else + log_printf(ELOG, "kobo_form_t::form_item(): No list!\n"); +} + + +void kobo_form_t::perc_list(int first, int last, int step) +{ + char buf[50]; + for(int i = first; i <= last; i += step) + { + snprintf(buf, sizeof(buf), "%d%%", i); + item(buf, i); + } +} + + +void kobo_form_t::enum_list(int first, int last) +{ + char buf[50]; + for(int i = first; i <= last; i++) + { + snprintf(buf, sizeof(buf), "%d", i); + item(buf, i); + } +} + + +void kobo_form_t::button(const char *cap, int tag) +{ + ct_widget_t *w = new ct_button_t(cap); + w->offset(xoffs, 0); + w->tag = tag; + init_widget(w); +} + + +void kobo_form_t::data(config_parser_t *_d) +{ + _data = _d; +} + + +void kobo_form_t::editor(int handle, int tag) +{ + if(!_data) + return; + + switch(_data->type(handle)) + { + default: + log_printf(ELOG, "kobo_form_t: Unknown data type!\n"); + break; + case CFG_BOOL: + onoff(_data->description(handle), (int *)NULL, tag); + current_widget->user2 = handle; + break; + case CFG_INT: + case CFG_FLOAT: + spin(_data->description(handle), (int *)NULL, + -100000, 100000, "", tag); + current_widget->user2 = handle; + break; + case CFG_STRING: + log_printf(ELOG, "kobo_form_t: String editor not yet implemented!\n"); + break; + } +} + + +void kobo_form_t::editor(const char *name, int tag) +{ + if(!_data) + return; + + int h = _data->find(name); + if(h < 0) + return; + editor(h, tag); +} + + +void kobo_form_t::space(int lines) +{ + if(_big) + ypos += BIG_SPACE_SIZE * lines; + else + ypos += SPACE_SIZE * lines; +} + + +void kobo_form_t::end() +{ +} + + +void kobo_form_t::build_all() +{ + xoffs = 0.5; + begin(); + build(); + end(); + + /* + * Initialize all widgets from prefs and/or config_parser. + */ + ct_widget_t *w = widgets; + while(w) + { + if(w->user) + { + int *val = (int *)w->user; + if(val) + { + w->value(*val); + log_printf(D3LOG, "Initialized to %d from prefs\n", + w->value()); + } + else if(_data) + { + w->value(_data->get_i(w->user2)); + log_printf(D3LOG, "Initialized to %d from config_parser\n", + w->value()); + } + } + w = w->next; + if(w == widgets) + break; //Done! + } +} + diff --git a/form.h b/form.h new file mode 100644 index 0000000..cb518a4 --- /dev/null +++ b/form.h @@ -0,0 +1,84 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 2001, 2007 David Olofson + * Copyright (C) 2005 Erik Auerswald + * + * 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. + */ + +#ifndef _KOBO_FORM_H_ +#define _KOBO_FORM_H_ + +#include "toolkit.h" +#include "cfgparse.h" + +#define LINE_H 9 +#define SPACE_SIZE 7 + +#define BIG_LINE_H 18 +#define BIG_SPACE_SIZE 14 + +class kobo_form_t : public ct_form_t +{ + config_parser_t *_data; + //Called by build_all(). + void begin(); + void end(); + protected: + ct_widget_t *current_widget; + ct_list_t *current_list; + int ypos; + int _big; + float xoffs; + ct_align_t halign; + virtual void init_widget(ct_widget_t *wg); + + //Toolkit + void big(); + void medium(); + void small(); + void label(const char *cap); + void yesno(const char *cap, int *var, int tag = 0); + void onoff(const char *cap, int *var, int tag = 0); + void spin(const char *cap, int *var, int min, int max, + const char *unit, int tag = 0); + void button(const char *cap, int tag = 0); + void space(int lines = 1); + + //config_parser_t aware version! :-) + void data(config_parser_t *_d); + void editor(int handle, int tag = 0); + void editor(const char *name, int tag = 0); + + //List tools + void list(const char *cap, int *var, int tag = 0); + void item(const char *cap, int value, int ind = 0); + void perc_list(int first, int last, int step); + void enum_list(int first, int last); + + //Internal wrapper for build() + void build_all(); + public: + kobo_form_t(); + virtual ~kobo_form_t(); + void next(); + void prev(); + virtual void change(int delta); + virtual void build(); +}; + +#endif diff --git a/game.cpp b/game.cpp new file mode 100644 index 0000000..1a54f0a --- /dev/null +++ b/game.cpp @@ -0,0 +1,138 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 2002, 2007 David Olofson + * + * 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. + */ + +#include "config.h" +#include "game.h" + +game_t game; + + +game_t::game_t() +{ + reset(); +} + + +void game_t::reset() +{ + set(GAME_SINGLE, SKILL_CLASSIC); +} + + +void game_t::set(game_types_t tp, skill_levels_t sk) +{ + type = tp; + skill = sk; + + // Game and player + speed = 30; + lives = 5; + bonus_first = 2000; + bonus_every = 3000; + health = 1; + health_fade = 5; + damage = 0; + bolts = 10; + bolt_damage = 20; + noseloadtime = 1; + noseheatup = 0; + nosecooling = 256; + altfire = 0; + tailloadtime = 1; + tailheatup = 0; + tailcooling = 256; + + // Enemies + rock_health = 255 * bolt_damage; + rock_damage = 1000; + + switch(skill) + { + case SKILL_CLASSIC: + break; + case SKILL_NEWBIE: + speed = 40; + lives = 5; + bonus_first = 5000; + bonus_every = 7000; + health = 100; + damage = 100; + bolts = MAX_BOLTS; + noseloadtime = 1; + noseheatup = 14; + nosecooling = 5; + tailloadtime = 0; + tailheatup = 7; + tailcooling = 5; + altfire = 1; + rock_health = 200; + rock_damage = 50; + break; + case SKILL_GAMER: + speed = 30; + lives = 5; + bonus_first = 8000; + bonus_every = 8000; + health = 60; + damage = 100; + bolts = MAX_BOLTS; + noseloadtime = 0; + noseheatup = 10; + nosecooling = 5; + tailloadtime = 1; + tailheatup = 20; + tailcooling = 5; + rock_health = 500; + rock_damage = 50; + break; + case SKILL_ELITE: + speed = 27; + lives = 4; + bonus_first = 10000; + bonus_every = 10000; + health = 50; + damage = 50; + bolts = MAX_BOLTS; + noseloadtime = 1; + noseheatup = 26; + nosecooling = 5; + tailloadtime = 2; + tailheatup = 39; + tailcooling = 5; + break; + case SKILL_GOD: + default: + speed = 25; + lives = 3; + bonus_first = 10000; + bonus_every = 10000; + health = 40; + damage = 30; + bolts = MAX_BOLTS; + noseloadtime = 1; + noseheatup = 30; + nosecooling = 5; + tailloadtime = 2; + tailheatup = 45; + tailcooling = 5; + break; + } +} diff --git a/game.h b/game.h new file mode 100644 index 0000000..d4b0b7d --- /dev/null +++ b/game.h @@ -0,0 +1,83 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 2002, 2007 David Olofson + * + * 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. + */ + +#ifndef _KOBO_GAME_H_ +#define _KOBO_GAME_H_ + +// Max number of player bolts flying +#define MAX_BOLTS 40 + +enum game_types_t +{ + GAME_UNKNOWN = -1, + GAME_SINGLE, + GAME_SINGLE_NEW, + GAME_COOPERATIVE, + GAME_DEATHMATCH, + GAME_EXPERIMENTAL = 0x10000000 // Testing! No official highscores. +}; + + +enum skill_levels_t +{ + SKILL_UNKNOWN = -1, + SKILL_CLASSIC, + SKILL_NEWBIE, + SKILL_GAMER, + SKILL_ELITE, + SKILL_GOD +}; + +class game_t +{ + public: + int type; + int skill; + int speed; // ms per logic frame + int lives; // When starting new games of certain types + int bonus_first; // First bonus ship at this score + int bonus_every; // New bonus ship every N points + int health; // Initial health + int health_fade; // Health fade period (logic frames/unit) + int damage; // Damage player inflicts when colliding with + // another object + int bolts; // maximum active at a time + int noseloadtime; // logic frames per nose shot + int noseheatup; // nose cannon heatup per shot + int nosecooling; // nose cannon cooling speed + int altfire; // use wing mounted cannons and stuff + int tailloadtime; // logic frames per tail shot + int tailheatup; // tail cannon heatup per shot + int tailcooling; // tail cannon cooling speed + int bolt_damage; // Damage inflicted by player fire bolt + + // Enemies + int rock_health; + int rock_damage; + + game_t(); + void reset(); + void set(game_types_t tp, skill_levels_t sk); +}; + +extern game_t game; + +#endif /*_KOBO_GAME_H_*/ diff --git a/gamectl.cpp b/gamectl.cpp new file mode 100644 index 0000000..48c7054 --- /dev/null +++ b/gamectl.cpp @@ -0,0 +1,409 @@ +/* +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996, Akira Higuchi + * Copyright (C) 2001 - 2003, 2006, David Olofson + * + * 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. + */ + +#include "manage.h" +#include "kobo.h" +#include "gamectl.h" +#include "myship.h" + + +int gamecontrol_t::afire; +int gamecontrol_t::r_delay = 250; +int gamecontrol_t::r_interval = 40; +int gamecontrol_t::space; +int gamecontrol_t::left; +int gamecontrol_t::up; +int gamecontrol_t::down; +int gamecontrol_t::right; +int gamecontrol_t::dl; +int gamecontrol_t::dr; +int gamecontrol_t::ul; +int gamecontrol_t::ur; +int gamecontrol_t::shot; +int gamecontrol_t::direction = 1; +int gamecontrol_t::new_direction = 0; +int gamecontrol_t::latch_timer = 0; +int gamecontrol_t::movekey_pressed; + + +void gamecontrol_t::init(int always_fire) +{ + afire = always_fire; + left = 0; + right = 0; + up = 0; + down = 0; + shot = 0; + movekey_pressed = 0; + SDL_EnableKeyRepeat(r_delay, r_interval); +} + + +gamecontrol_t::gamecontrol_t() +{ + init(0); +} + + +void gamecontrol_t::repeat(int delay, int interval) +{ + r_delay = delay; + r_interval = interval; + //Temporary kludge - should apply repeat to + //all switch inputs, not just the keyboard! + SDL_EnableKeyRepeat(delay, interval); +} + + +void gamecontrol_t::clear() +{ + direction = 1; +} + + +int gamecontrol_t::map(SDLKey sym) +{ +/* +FIXME: This should be replaced by a configurable mapping system. +*/ + switch(sym) + { + case KEY_KP_LEFT: + case SDLK_LEFT: + return BTN_LEFT; + case KEY_KP_RIGHT: + case SDLK_RIGHT: + return BTN_RIGHT; + case KEY_KP_UP: + case SDLK_UP: + return BTN_UP; + case KEY_KP_DOWN: + case SDLK_DOWN: + return BTN_DOWN; + case KEY_KP_DL: + return BTN_DL; + case KEY_KP_DR: + return BTN_DR; + case KEY_KP_UL: + return BTN_UL; + case KEY_KP_UR: + return BTN_UR; + + case SDLK_PAGEUP: + if(prefs->broken_numdia) + return BTN_UR; + else + return BTN_NEXT; + case SDLK_PAGEDOWN: + if(prefs->broken_numdia) + return BTN_DR; + else + return BTN_PREV; + case SDLK_HOME: + if(prefs->broken_numdia) + return BTN_UL; + else + return -1; + case SDLK_END: + if(prefs->broken_numdia) + return BTN_UL; + else + return -1; + + case SDLK_LSHIFT: + case SDLK_RSHIFT: + case SDLK_LCTRL: + case SDLK_RCTRL: + return BTN_FIRE; + case SDLK_ESCAPE: + return BTN_EXIT; + case SDLK_PAUSE: + case SDLK_p: + return BTN_PAUSE; + case SDLK_SPACE: + return BTN_START; + case SDLK_KP_ENTER: + case SDLK_RETURN: + return BTN_SELECT; + case SDLK_KP_PLUS: + return BTN_INC; + case SDLK_KP_MINUS: + return BTN_DEC; + case SDLK_y: + return BTN_YES; + case SDLK_n: + return BTN_NO; + case SDLK_BACKSPACE: + return BTN_BACK; + case SDLK_F1: + return BTN_F1; + case SDLK_F2: + return BTN_F2; + case SDLK_F3: + return BTN_F3; + case SDLK_F4: + return BTN_F4; + case SDLK_F5: + return BTN_F5; + case SDLK_F6: + return BTN_F6; + case SDLK_F7: + return BTN_F7; + case SDLK_F8: + return BTN_F8; + case SDLK_F9: + return BTN_F9; + case SDLK_F10: + return BTN_F10; + case SDLK_F11: + return BTN_F11; + case SDLK_F12: + return BTN_F12; + default: + return -1; + } +} + + +void gamecontrol_t::press(int k) +{ + switch(k) + { + case BTN_LEFT: + left = 1; + break; + case BTN_RIGHT: + right = 1; + break; + case BTN_UP: + up = 1; + break; + case BTN_DOWN: + down = 1; + break; + case BTN_UL: + ul = 1; + break; + case BTN_UR: + ur = 1; + break; + case BTN_DL: + dl = 1; + break; + case BTN_DR: + dr = 1; + break; + case BTN_FIRE: + shot = 1; + break; + } + gamecontrol_t::change(); +} + +void gamecontrol_t::release(int k) +{ + switch(k) + { + case BTN_LEFT: + left = 0; + break; + case BTN_RIGHT: + right = 0; + break; + case BTN_UP: + up = 0; + break; + case BTN_DOWN: + down = 0; + break; + case BTN_UL: + ul = 0; + break; + case BTN_UR: + ur = 0; + break; + case BTN_DL: + dl = 0; + break; + case BTN_DR: + dr = 0; + break; + case BTN_FIRE: + shot = 0; + break; + } + gamecontrol_t::change(); +} + + +void gamecontrol_t::mouse_press(int n) +{ + if(n == 1) + shot = 1; +// else if(n == 3) +// manage.key_down(KEY_START); + gamecontrol_t::change(); +} + + +void gamecontrol_t::mouse_release(int n) +{ + if(n == 1) + shot = 0; + gamecontrol_t::change(); +} + + +void gamecontrol_t::mouse_position(int h, int v) +{ + switch(prefs->mousemode) + { + case MMD_OFF: + return; + case MMD_CROSSHAIR: + myship.put_crosshair(); + break; + case MMD_RELATIVE: + /* Insert delta pos sensitivity filter here */ + break; + } + if(h > 0) + { + if(v > 0) + { + if(h > (v << 1)) + direction = 3; + else if(v > (h << 1)) + direction = 5; + else + direction = 4; + } + else if(v <= 0) + { + if(h > ((-v) << 1)) + direction = 3; + else if((-v) > (h << 1)) + direction = 1; + else + direction = 2; + } + else + direction = 3; + } + else if(h <= 0) + { + if(v > 0) + { + if((-h) > (v << 1)) + direction = 7; + else if(v > ((-h) << 1)) + direction = 5; + else + direction = 6; + } + else if(v <= 0) + { + if((-h) > ((-v) << 1)) + direction = 7; + else if((-v) > ((-h) << 1)) + direction = 1; + else + direction = 8; + } + else + direction = 7; + } +} + + +void gamecontrol_t::change() +{ + int lr = left - right + ul - ur + dl - dr; + int ud = up - down + ul + ur - dl - dr; + if(lr > 0) + { + if(ud > 0) + new_direction = 8; + else if(ud < 0) + new_direction = 6; + else + new_direction = 7; + } + else if(lr < 0) + { + if(ud > 0) + new_direction = 2; + else if(ud < 0) + new_direction = 4; + else + new_direction = 3; + } + else + { + if(ud > 0) + new_direction = 1; + else if(ud < 0) + new_direction = 5; + else + new_direction = 0; + } + + if(prefs->dia_emphasis) + { + if(!new_direction) + { + //Change to neutral. Cancel delayed latch! + latch_timer = 0; + } + else if(!movekey_pressed) + { + //Change from neutral - latch immediately. + direction = new_direction; + latch_timer = 0; + } + else if(new_direction & 1) + { + //Change from diagonal! + latch_timer = prefs->dia_emphasis; + } + else + { + //Change to diagonal - latch immediately. + direction = new_direction; + latch_timer = 0; + } + } + else if(new_direction) + direction = new_direction; + + movekey_pressed = (new_direction != 0); + mouse_x = 0; + mouse_y = 0; +} + + +void gamecontrol_t::process() +{ + if(latch_timer) + if(!--latch_timer) + direction = new_direction; +} diff --git a/gamectl.h b/gamectl.h new file mode 100644 index 0000000..dfdebf2 --- /dev/null +++ b/gamectl.h @@ -0,0 +1,122 @@ +/* +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996, Akira Higuchi + * Copyright (C) 2001, 2002, 2006, David Olofson + * + * 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. + */ + +#ifndef _KOBO_GAMECTL_H_ +#define _KOBO_GAMECTL_H_ + +#include "glSDL.h" +#include "config.h" + +#define KEY_KP_DOWN SDLK_KP2 +#define KEY_KP_LEFT SDLK_KP4 +#define KEY_KP_UP SDLK_KP8 +#define KEY_KP_RIGHT SDLK_KP6 +#define KEY_KP_DL SDLK_KP1 +#define KEY_KP_DR SDLK_KP3 +#define KEY_KP_UL SDLK_KP7 +#define KEY_KP_UR SDLK_KP9 + + +enum buttons_t +{ + BTN_UP, //Joystick, arrows, numpad etc + BTN_DOWN, + BTN_LEFT, + BTN_RIGHT, + BTN_UL, + BTN_UR, + BTN_DL, + BTN_DR, + + BTN_INC, // + + BTN_DEC, // - + + BTN_NEXT, // PageUp + BTN_PREV, // PageDn + + BTN_YES, // 'Y' + BTN_NO, // 'N' + + BTN_FIRE, //ctrl, fire button, mouse button,... + BTN_START, //Space + BTN_SELECT, //Return, enter,... + BTN_EXIT, //ESC + BTN_PAUSE, //Pause or P; also used as an internal event. + BTN_CLOSE, //Window close button, ALT-F4,... + BTN_BACK, //Backspace + + BTN_F1, //Function keys + BTN_F2, + BTN_F3, + BTN_F4, + + BTN_F5, + BTN_F6, + BTN_F7, + BTN_F8, + + BTN_F9, + BTN_F10, + BTN_F11, + BTN_F12 +}; + + +enum mousemodes_t +{ + MMD_OFF = 0, + MMD_CROSSHAIR, + MMD_RELATIVE +}; + + +class gamecontrol_t +{ + static int r_delay, r_interval; + static int afire; + static int space; + static int left, up, down, right, ul, ur, dl, dr; + static int shot; + static int direction, new_direction; + static int latch_timer; + static int movekey_pressed; + static void change(); + public: + gamecontrol_t(); + static void init(int always_fire); + static void repeat(int delay, int interval); + static void clear(); + static int map(SDLKey sym); + static void process(); // Call every frame! + static void press(int k); + static void release(int k); + static void mouse_press(int n); + static void mouse_release(int n); + static void mouse_position(int h, int v); + static inline int dir() { return direction; } + static inline int get_shot() { return shot || afire; } + static inline int dir_push() { return movekey_pressed; } +}; + +extern gamecontrol_t gamecontrol; + +#endif //_KOBO_KEY_H_ diff --git a/gamestate.cpp b/gamestate.cpp new file mode 100644 index 0000000..a6ebe00 --- /dev/null +++ b/gamestate.cpp @@ -0,0 +1,206 @@ +/*(LGPL) +------------------------------------------------------------ + Game State Manager +------------------------------------------------------------ + * Copyright (C) 2001-2003, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define DBG(x) + +#include +#include "logger.h" +#include "gamestate.h" + +/*---------------------------------------------------------- + gamestate_t +----------------------------------------------------------*/ + +gamestate_t::gamestate_t() +{ + next = 0; + manager = 0; + unicode = 0; +} + +gamestate_t::~gamestate_t() {} + +void gamestate_t::pop() +{ + if(!manager) + return; + //This is far from fool-proof, but it should + //handle the most common cases of "trying to + //pop 'this' more than once"... + if(manager->current() == this) + manager->pop(); + else + log_printf(WLOG, "GameStateManager: " + "WARNING: Tried to pop state more than once!\n"); +} + +void gamestate_t::enter() {} +void gamestate_t::leave() {} +void gamestate_t::yield() {} +void gamestate_t::reenter() {} +void gamestate_t::press(int button) {} +void gamestate_t::release(int button) {} +void gamestate_t::pos(int x, int y) {} +void gamestate_t::delta(int dx, int dy) {} +void gamestate_t::frame() {} +void gamestate_t::pre_render() {} +void gamestate_t::post_render() {} + + + +/*---------------------------------------------------------- + gamestatemanager_t +----------------------------------------------------------*/ + +gamestatemanager_t::gamestatemanager_t() +{ + top = 0; +} + + +gamestatemanager_t::~gamestatemanager_t() +{ +} + + +void gamestatemanager_t::change(gamestate_t *gs) +{ + gs->manager = this; + + gamestate_t *oldtop = top; + if(top) + top = top->next; + gs->next = top; + top = gs; + + if(oldtop) + { + oldtop->leave(); + oldtop->manager = 0; + } + if(top) + top->enter(); + + log_printf(DLOG, "GameStateManager: Switched to '%s'\n", gs->name); +} + + +void gamestatemanager_t::push(gamestate_t *gs) +{ + gs->manager = this; + + gamestate_t *oldtop = top; + gs->next = top; + top = gs; + + if(oldtop) + oldtop->yield(); + if(top) + top->enter(); + + log_printf(DLOG, "GameStateManager: Pushed state '%s'\n", gs->name); +} + + +void gamestatemanager_t::pop() +{ + gamestate_t *oldtop = top; + if(top) + top = top->next; + if(oldtop) + { + oldtop->leave(); + oldtop->manager = 0; + log_printf(DLOG, "GameStateManager: Popped state '%s'\n", oldtop->name); + } + if(top) + top->reenter(); +} + + +gamestate_t *gamestatemanager_t::current() +{ + return top; +} + + +gamestate_t *gamestatemanager_t::previous() +{ + if(top) + return top->next; + else + return NULL; +} + + +void gamestatemanager_t::press(int button, int unicode) +{ + if(top) + { + top->unicode = unicode; + top->press(button); + } +} + + +void gamestatemanager_t::release(int button, int unicode) +{ + if(top) + { + top->unicode = unicode; + top->release(button); + } +} + + +void gamestatemanager_t::pos(int x, int y) +{ + if(top) + top->pos(x, y); +} + + +void gamestatemanager_t::delta(int dx, int dy) +{ + if(top) + top->delta(dx, dy); +} + + +void gamestatemanager_t::frame() +{ + if(top) + top->frame(); +} + + +void gamestatemanager_t::pre_render() +{ + if(top) + top->pre_render(); +} + + +void gamestatemanager_t::post_render() +{ + if(top) + top->post_render(); +} diff --git a/gamestate.h b/gamestate.h new file mode 100644 index 0000000..2a7f872 --- /dev/null +++ b/gamestate.h @@ -0,0 +1,84 @@ +/*(LGPL) +------------------------------------------------------------ + Game State Manager +------------------------------------------------------------ + * Copyright (C) 2001-2003, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _GAMESTATEMANAGER_H_ +#define _GAMESTATEMANAGER_H_ + +class gamestatemanager_t; + +class gamestate_t +{ + friend class gamestatemanager_t; + private: + gamestate_t *next; //LIFO stack + gamestatemanager_t *manager; + protected: + const char *name; + int unicode; //for last press()/release() + void pop(); + + virtual void press(int button); + virtual void release(int button); + virtual void pos(int x, int y); + virtual void delta(int dx, int dy); + + virtual void enter(); + virtual void leave(); + virtual void yield(); + virtual void reenter(); + + virtual void frame(); //Control system stuff + virtual void pre_render(); //Background rendering + virtual void post_render(); //Foreground rendering + public: + gamestate_t(); + virtual ~gamestate_t(); +}; + + +class gamestatemanager_t +{ + private: + gamestate_t *top; //Stack top + public: + gamestatemanager_t(); + ~gamestatemanager_t(); + + /* Event router interface */ + void press(int button, int unicode = 0); + void release(int button, int unicode = 0); + void pos(int x, int y); + void delta(int dx, int dy); + + /* CS frame and rendering callbacks */ + void frame(); + void pre_render(); + void post_render(); + + /* State management */ + void change(gamestate_t *gs); + void push(gamestate_t *gs); + void pop(); + gamestate_t *current(); + gamestate_t *previous(); +}; + +#endif /*_GAMESTATEMANAGER_H_*/ diff --git a/graphics/Makefile.am b/graphics/Makefile.am new file mode 100644 index 0000000..4579977 --- /dev/null +++ b/graphics/Makefile.am @@ -0,0 +1,10 @@ +noinst_LIBRARIES = libgraphics.a + +INCLUDES = @LOCALCFLAGS@ + +libgraphics_a_SOURCES = cs.c sprite.c filters.c glSDL.c \ + gfxengine.cpp window.cpp sofont.cpp \ + display.cpp toolkit.cpp vidmodes.c \ + region.c + +EXTRA_DIST = *.h diff --git a/graphics/Makefile.in b/graphics/Makefile.in new file mode 100644 index 0000000..d1dc39e --- /dev/null +++ b/graphics/Makefile.in @@ -0,0 +1,457 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = graphics +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/aconfig.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +libgraphics_a_AR = $(AR) $(ARFLAGS) +libgraphics_a_LIBADD = +am_libgraphics_a_OBJECTS = cs.$(OBJEXT) sprite.$(OBJEXT) \ + filters.$(OBJEXT) glSDL.$(OBJEXT) gfxengine.$(OBJEXT) \ + window.$(OBJEXT) sofont.$(OBJEXT) display.$(OBJEXT) \ + toolkit.$(OBJEXT) vidmodes.$(OBJEXT) region.$(OBJEXT) +libgraphics_a_OBJECTS = $(am_libgraphics_a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +SOURCES = $(libgraphics_a_SOURCES) +DIST_SOURCES = $(libgraphics_a_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUDIO_LIBS = @AUDIO_LIBS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_MACOSX_BUNDLE_FALSE = @BUILD_MACOSX_BUNDLE_FALSE@ +BUILD_MACOSX_BUNDLE_TRUE = @BUILD_MACOSX_BUNDLE_TRUE@ +BUILD_SIMPLE_BUNDLE_FALSE = @BUILD_SIMPLE_BUNDLE_FALSE@ +BUILD_SIMPLE_BUNDLE_TRUE = @BUILD_SIMPLE_BUNDLE_TRUE@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONFIGDIR = @CONFIGDIR@ +CONFIGFILE = @CONFIGFILE@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXEFILE = @EXEFILE@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LOCALCFLAGS = @LOCALCFLAGS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MATHLIB = @MATHLIB@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POW_LIB = @POW_LIB@ +RANLIB = @RANLIB@ +SCOREDIR = @SCOREDIR@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +UNIX_SCOREDIR_FALSE = @UNIX_SCOREDIR_FALSE@ +UNIX_SCOREDIR_TRUE = @UNIX_SCOREDIR_TRUE@ +VERSION = @VERSION@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +noinst_LIBRARIES = libgraphics.a +INCLUDES = @LOCALCFLAGS@ +libgraphics_a_SOURCES = cs.c sprite.c filters.c glSDL.c \ + gfxengine.cpp window.cpp sofont.cpp \ + display.cpp toolkit.cpp vidmodes.c \ + region.c + +EXTRA_DIST = *.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .cpp .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign graphics/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign graphics/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libgraphics.a: $(libgraphics_a_OBJECTS) $(libgraphics_a_DEPENDENCIES) + -rm -f libgraphics.a + $(libgraphics_a_AR) libgraphics.a $(libgraphics_a_OBJECTS) $(libgraphics_a_LIBADD) + $(RANLIB) libgraphics.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/display.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filters.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gfxengine.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glSDL.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/region.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sofont.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sprite.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/toolkit.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vidmodes.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/window.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-noinstLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/graphics/cs.c b/graphics/cs.c new file mode 100644 index 0000000..1fd8af4 --- /dev/null +++ b/graphics/cs.c @@ -0,0 +1,720 @@ +/*(LGPL) + * Project Spitfire sprites + scrolling engine for SDL +---------------------------------------------------------------------- + cs.c - Simplistic Control System +---------------------------------------------------------------------- + * Copyright (C) 2001, 2003, 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define DBG(x) + +#include "cs.h" +#include "logger.h" +#include +#include +#include + +/*#define ABS(x) (((x)>=0) ? (x) : (-(x)))*/ +#define ABS(x) labs(x) + + +static inline void __wrap_point(cs_point_t *p, int wx, int wy) +{ + if(wx) + { + if(p->gx < 0) + p->gx += (-p->gx / wx + 1) * wx; + p->gx %= wx; + } + if(wy) + { + if(p->gy < 0) + p->gy += (-p->gy / wy + 1) * wy; + p->gy %= wy; + } +} + + +/* + * Make one point do it's thing... + */ +static inline void __move_point(cs_point_t *p, int wx, int wy) +{ + /* + * Push filter + */ + p->ox = p->v.x; + p->oy = p->v.y; + + /* + * Update position and speed + */ + p->v.x += p->v.xv; + p->v.y += p->v.yv; + p->v.xv += p->v.xa; + p->v.yv += p->v.ya; + + __wrap_point(p, wx, wy); +} + + +/* + * Update the motion filtered output of a point. + */ +static inline void __update_point_f(cs_point_t *p, int ff, int wx, int wy) +{ + int ogx = p->gx; + int ogy = p->gy; + int ox = p->ox; + int oy = p->oy; + + /* Unwrap filter for correct interpolation */ + if(wx | wy) + { + if((ox - p->v.x) > (wx >> 1)) + ox -= wx; + else if((p->v.x - ox) > (wx >> 1)) + ox += wx; + if((oy - p->v.y) > (wy >> 1)) + oy -= wy; + else if((p->v.y - oy) > (wy >> 1)) + oy += wy; + } + + /* + * Interpolate output graphics coordinate + */ + p->gx = (ff * p->v.x + (256 - ff) * ox) >> 8; + p->gy = (ff * p->v.y + (256 - ff) * oy) >> 8; + + /* + * Wrap interpolated output + */ + if(wx) + { + while(p->gx < 0) + p->gx += wx; + p->gx %= wx; + } + if(wy) + { + while(p->gy < 0) + p->gy += wy; + p->gy %= wy; + } + + /* + * Generate "changed" flag mask. + */ + p->changed = (ogx ^ p->gx) | (ogy ^ p->gy); +} + + +static inline void __update_point(cs_point_t *p, int ff) +{ + int ogx = p->gx; + int ogy = p->gy; + + /* + * Interpolate output graphics coordinate + */ + p->gx = p->v.x; + p->gy = p->v.y; + + /* + * Generate "changed" flag mask. + */ + p->changed = (ogx ^ p->gx) | (ogy ^ p->gy); +} + + +/* +---------------------------------------------------------------------- + * cs_obj_t +---------------------------------------------------------------------- + */ + +/* + * Final adjustment of interpolated graphics coords to deal + * with the display window wrapping over the edge of the world. + */ +static inline void __fix_wrap(cs_engine_t *e, cs_obj_t *o) +{ + if(o->point.gx + (o->w << __CS_SHIFT) < 0) + o->point.gx += e->wx; + else if(o->point.gx > (e->w << __CS_SHIFT)) + o->point.gx -= e->wx; + if(o->point.gy + (o->h << __CS_SHIFT) < 0) + o->point.gy += e->wy; + else if(o->point.gy > (e->h << __CS_SHIFT)) + o->point.gy -= e->wy; +} + + +static inline int __onscreen(cs_engine_t *e, cs_obj_t *o) +{ + int gx = CS2PIXEL(o->point.gx); + int gy = CS2PIXEL(o->point.gy); + if((gx + o->w < 0) || (gx > e->w)) + return 0; + if((gy + o->h < 0) || (gy > e->h)) + return 0; + return 1; +} + + +static inline void __obj_set_layer(cs_obj_t *o, unsigned int layer) +{ + if(o->layer < 0) + o->layer = CS_DEFAULT_LAYER; + if(layer >= CS_LAYERS) + layer = CS_LAYERS - 1; + o->layer = layer; +} + +/* + * Add object *first*, ie with lowest priority. + * (Hmmm... Isn't that how some h/w sprite generators do it, + * if you allocate in increasing channel order?) + */ +static inline void __obj_attach(cs_obj_t *o) +{ + if(o->head || o->next || o->prev) + { + log_printf(ELOG, "cs: HEEEELP! Someone's trying" + " to short-circuit my guts!\n"); + return; + } + + if(o->layer < 0) + o->layer = CS_DEFAULT_LAYER; + o->next = o->owner->objects[o->layer]; + o->head = &o->owner->objects[o->layer]; + if(o->next) + o->next->prev = o; + o->owner->objects[o->layer] = o; +} + +/* + * BEWARE! There's a nasty hack in here; these objects need to + * keep track of the addresses of their list heads in order to + * remove themselves properly! + */ +static inline void __obj_detach(cs_obj_t *o) +{ + /* "Bypass" */ + if(o->next) + o->next->prev = o->prev; + if(o->prev) + o->prev->next = o->next; + /* In case we're the first object in the list... */ + if(o->head) + if(*(o->head) == o) + *(o->head) = o->next; + + o->head = NULL; + o->next = NULL; + o->prev = NULL; +} + + +void cs_obj_layer(cs_obj_t *o, unsigned int layer) +{ + if(layer == o->layer) + return; + + __obj_set_layer(o, layer); + if(o->flags | CS_OBJ_ACTIVE) + { + __obj_detach(o); + __obj_attach(o); + } +} + + +void cs_obj_activate(cs_obj_t *o) +{ + if(o->flags | CS_OBJ_ACTIVE) + { + DBG(log_printf(DLOG, "cs: Tried to activate active object!\n");) + return; + } + + __obj_attach(o); + o->flags |= CS_OBJ_ACTIVE; +} + + +void cs_obj_deactivate(cs_obj_t *o) +{ + if(!(o->flags | CS_OBJ_ACTIVE)) + { + DBG(log_printf(DLOG, "cs: Tried to deactivate passive object!\n");) + return; + } + + __obj_detach(o); + o->flags &= ~CS_OBJ_ACTIVE; +} + + +/* Basic methods */ + +void cs_obj_pos(cs_obj_t *o, int x, int y) +{ + o->point.v.x = PIXEL2CS(x); + o->point.v.y = PIXEL2CS(y); +} + + +void cs_obj_vel(cs_obj_t *o, int xs, int ys) +{ + o->point.v.xv = xs; + o->point.v.yv = ys; +} + + +/*Set movement acceleration*/ +void cs_obj_acc(cs_obj_t *o, int xa, int ya) +{ + o->point.v.xa = xa; + o->point.v.ya = ya; +} + + +/*Disable display*/ +void cs_obj_hide(cs_obj_t *o) +{ + o->flags &= ~CS_OBJ_VISIBLE; +} + + +/*Enable display*/ +void cs_obj_show(cs_obj_t *o) +{ + if(o->flags & CS_OBJ_VISIBLE) + return; + + o->flags |= CS_OBJ_VISIBLE; + /* + * Kludge? I'm not sure this is really the right place... + */ + cs_point_force(&o->point); +} + + +/* + * Remove and throw back in the pool + */ +void cs_obj_free(cs_obj_t *o) +{ + if(o->head == &o->owner->pool) + { + DBG(log_printf(DLOG, "cs: Tried to free free object %p!\n", + o);) + return; + } + cs_obj_deactivate(o); + if(o->on_free) + o->on_free(o); + cs_obj_clear(o); + + /* Set up head pointer for error checking. */ + o->head = &o->owner->pool; + + /* Link to pool; singly only */ + o->next = o->owner->pool; + o->owner->pool = o; + + ++o->owner->pool_free; +} + +void cs_obj_clear(cs_obj_t *o) +{ + o->flags = 0; + o->layer = -1; + o->fire.rate = 0; + o->score = 0; + o->health = 0; +} + +void cs_obj_vector(cs_obj_t *o, cs_vector_t * v) +{ + if(v) + o->point.v = *v; + else + memset(&(o->point.v), 0, sizeof(o->point.v)); +} + + + +/* Animation methods */ +void cs_obj_anim(cs_obj_t *o, int bank, + int first, int num, int start, int spd) +{ + o->anim.bank = bank; + o->anim.frame = first; + o->anim.fframe = first; + o->anim.aframes = num; + o->anim.cframe = start << 4; + o->anim.aspeed = spd; + o->flags |= CS_OBJ_DOANIM; +} + + +void cs_obj_image(cs_obj_t *o, int bank, int frame) +{ + o->anim.bank = bank; + o->anim.frame = frame; + o->flags &= ~CS_OBJ_DOANIM; + if((bank >= 0) && (bank < o->owner->nimageinfo)) + { + o->w = o->owner->imageinfo[bank].w; + o->h = o->owner->imageinfo[bank].h; + } + else + o->w = o->h = 1; +} + + +/*Start death sequence*/ +void cs_obj_explode(cs_obj_t *o) +{ + o->flags |= CS_OBJ_DYING; +/* +FIXME: Hardcoded bank for explosion!!! +*/ + cs_obj_anim(o, 4, 0, 15, 0, 12); + if(o->on_dying) + o->on_dying(o); +} + +void cs_obj_shoot(cs_obj_t *o, int xo, int yo, int xs, + int ys, int rate, int delay, int ammo) +{ + o->fire.v.x = xo; + o->fire.v.y = yo; + o->fire.v.xv = xs; + o->fire.v.yv = ys; + o->fire.rate = rate; + o->fire.timer = delay; + o->fire.ammo = ammo; +} + + + +/* + * cs_engine_t + */ + +static cs_obj_t *__new_obj(cs_engine_t *e) +{ + cs_obj_t *o = calloc(1, sizeof(cs_obj_t)); + if(!o) + return NULL; + + o->owner = e; + o->prev = NULL; + o->next = NULL; + cs_obj_clear(o); + ++e->pool_total; + return o; +} + +cs_engine_t *cs_engine_create(int w, int h, int objects) +{ + cs_engine_t *e = calloc(1, sizeof(cs_engine_t)); + if(!e) + return NULL; + + cs_engine_set_size(e, w, h); + cs_engine_set_wrap(e, 0, 0); + + /* + * Create some objects and throw into the pool. + * Note that "pool_free" gets initialized by + * cs_obj_die(), objects are initialized and so + * on, this way - automatically! + */ + while(objects--) + { + cs_obj_t *o = __new_obj(e); + if(o) + cs_obj_free(o); + else + { + /* Oops, no memory... */ + cs_engine_delete(e); + return NULL; + } + } + return e; +} + + +cs_obj_t *cs_engine_get_obj(cs_engine_t *e) +{ + cs_obj_t *o = e->pool; + if(o) + { + e->pool = o->next; + o->head = NULL; + o->prev = NULL; + o->next = NULL; + --e->pool_free; + } + return o; +} + + +void cs_engine_set_size(cs_engine_t *e, int w, int h) +{ + e->w = w; + e->h = h; +} + + +void cs_engine_set_image_size(cs_engine_t *e, int bank, int w, int h) +{ + if(bank < 0) + return; + + if(bank >= e->nimageinfo) + { + int nnii = bank + 16; + image_info_t *nii = realloc(e->imageinfo, + sizeof(image_info_t) * nnii); + if(!nii) + return; + + e->nimageinfo = nnii; + e->imageinfo = nii; + } + + e->imageinfo[bank].w = w; + e->imageinfo[bank].h = h; +} + + +void cs_engine_set_wrap(cs_engine_t *e, int x, int y) +{ + e->wx = PIXEL2CS(x); + e->wy = PIXEL2CS(y); +} + + +void cs_engine_delete(cs_engine_t *e) +{ + cs_obj_t *o; + /* First get all objects to the pool... */ + cs_engine_reset(e); + /* ...then empty the pool. */ + while((o = cs_engine_get_obj(e))) + free(o); + free(e->imageinfo); + free(e); +} + + +void cs_engine_reset(cs_engine_t *e) +{ + int i; + for(i = 0; i < CS_LAYERS; ++i) + while(e->objects[i]) + cs_obj_free(e->objects[i]); + e->time = 0.0; +} + + + +/* +---------------------------------------------------------------------- + * The actual *engine* :-) +---------------------------------------------------------------------- + */ + +void __enemy_fire(cs_obj_t *o) +{ + log_printf(DLOG, "fire!\n"); +} + +void __make_move(cs_obj_t *o, int wx, int wy) +{ + /* + * Movement + */ + __move_point(&o->point, wx, wy); + + /* + * Animation + */ + if(o->flags & CS_OBJ_DOANIM) + { +/* +FIXME: Dirty hack here... Should play *any* death animation one-shot and then die. +*/ + if((o->flags & CS_OBJ_DYING) + && (o->anim.cframe >> 4 == 14)) + cs_obj_free(o); + + o->anim.cframe += o->anim.aspeed; + o->anim.cframe %= o->anim.aframes << 4; + o->anim.frame = (o->anim.cframe >> 4) + o->anim.fframe; + } + + /* + * Fire / spawning + */ + if(!(o->flags & CS_OBJ_DYING) && o->fire.rate) + { + if(o->fire.timer > 0) + --o->fire.timer; + else + { + o->fire.timer = o->fire.rate; + __enemy_fire(o); + if(o->on_fire) + o->on_fire(o); + } + } +} + + +void __update_points(cs_engine_t *e, float frac_frame) +{ + cs_obj_t *o; + int i; + int ff = frac_frame * 256.0; + + if(ff < 0) + ff = 0; + else if(ff > 256) + ff = 256; + + if(e->filter) + for(i = 0; i < CS_USER_POINTS; ++i) + __update_point_f(&e->points[i], ff, e->wx, e->wy); + else + for(i = 0; i < CS_USER_POINTS; ++i) + __update_point(&e->points[i], ff); + + for(i = 0; i < CS_LAYERS; ++i) + { + if(e->filter) + __update_point_f(&e->offsets[i], ff, e->wx, e->wy); + else + __update_point(&e->offsets[i], ff); + e->changed[i] = 0; + o = e->objects[i]; + while(o) + { + if(e->filter) + __update_point_f(&o->point, ff, e->wx, + e->wy); + else + __update_point(&o->point, ff); + o->point.gx -= e->offsets[i].gx; + o->point.gy -= e->offsets[i].gy; + e->changed[i] |= o->point.changed; + __fix_wrap(e, o); + o = o->next; + } + } +} + + +void __run_all(cs_engine_t *e) +{ + int i; + cs_obj_t *o; + + for(i = 0; i < CS_USER_POINTS; ++i) + __move_point(&e->points[i], e->wx, e->wy); + + for(i = 0; i < CS_LAYERS; ++i) + { + __move_point(&e->offsets[i], e->wx, e->wy); + o = e->objects[i]; + while(o) + { + __make_move(o, e->wx, e->wy); + o = o->next; + } + } +} + + +void __wrap_all(cs_engine_t *e) +{ + int i; + cs_obj_t *o; + + for(i = 0; i < CS_USER_POINTS; ++i) + __wrap_point(&e->points[i], e->wx, e->wy); + + for(i = 0; i < CS_LAYERS; ++i) + { + __wrap_point(&e->offsets[i], e->wx, e->wy); + o = e->objects[i]; + while(o) + { + __wrap_point(&o->point, e->wx, e->wy); + o = o->next; + } + } +} + + +void cs_engine_advance(cs_engine_t *e, double to_frame) +{ + if(to_frame > 0) + { + int frames = floor(to_frame) - floor(e->time); + if(frames > 0) + { + while(frames--) + { + __run_all(e); + e->on_frame(e); + } + } + } + e->time = to_frame; + if(e->wx || e->wy) + __wrap_all(e); + __update_points(e, to_frame - floor(to_frame)); +} + + +void cs_engine_render(cs_engine_t *e) +{ + cs_obj_t *o; + int i; + + for(i = CS_LAYERS - 1; i >= 0; --i) + { + o = e->objects[i]; + while(o) + { + if(o->flags & CS_OBJ_VISIBLE) + if(o->render) + if(__onscreen(e, o)) + o->render(o); + o = o->next; + } + } +} diff --git a/graphics/cs.h b/graphics/cs.h new file mode 100644 index 0000000..8f0628f --- /dev/null +++ b/graphics/cs.h @@ -0,0 +1,472 @@ +/*(LGPL) + * Project Spitfire sprites + scrolling engine for SDL +---------------------------------------------------------------------- + cs.h - Simplistic Control System +---------------------------------------------------------------------- + * Copyright (C) 2001, 2003, 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * Note on coordinates: + * Normally, cs assumes that the world continues + * indefinitely in every direction. (Actually, + * it wraps at 4 Gpixel intervals... :-) + * + * However, by calling cs_engine_set_wrap(x, y), + * it's possible to make the engine wrap + * automatically, to nicely support old style + * endless scrolling games. The movement system + * will automatically wrap around edges, and + * most importantly, *interpolation* will work + * correctly in conjunction with wrapping. This + * applies to all points in the system, user + * points included. + * + * Note that cs doesn't have an internal notion + * of layers when it comes to wrapping, which + * means that it's not trivial to implement + * wrapping for parallax scrolling correctly. + * All parallax layers have to be of the same + * size, as cs cannot tell which points belong + * to which layer when performing the internal + * calculations. + * + * Call cs_engine_set_wrap(0, 0); to disable + * wrapping. Wrapping can be set or disabled + * individually for each axis. + * + * Note on graphics coordinates: + * Graphics coordinates don't always wrap at the + * same time as their corresponding object + * coordinates! This is because the engine must + * consider the view rectangle and the bounding + * rectangles of objects, and adjust the wrapping + * so that all objects that should be visible + * are. + * + * Note on wrapping (with wrapping enabled only): + * When a layer is scrolled so that it's limits + * end up inside the display window, the engine + * automatically makes objects wrap around from + * the far edge, so that continuous looping is + * possible. + * However, note that this breaks if objects can + * be seen at more than one edge at a time! That + * is, (wrap size - display size) must be bigger + * than the size of the largest object. + * + * TODO: + * * Scrap the animation system and throw + * something nicer in. A primitive VM based + * "scripting" system with + * commands and switches based on speed, + * direction, state etc would be incredibly + * powerful, and still not too complicated. + * + * * Implement collision detection. There should + * be flags to enable/disable it on per-layer + * as well as per-object basis. + * + * * Group all per-layer stuff into a struct, + * and then use an array of structs. + * + * * Split each layer into two lists; one for + * visible objects and one for hidden objects, + * so they can be handled more efficiently. + * (Hidden objects are skipped one by one in + * the render loop now, for example - it will + * become worse over time, I think.) + * + * * Implement some sort of zone based collision + * detection engine that scales better than + * "check everything against everything". + */ + /* + * + * BUGS: + * * There is a restriction on object movement + * speed in a wrapping world: No object must + * move more than half of the extent of the + * world on either axis in one engine cycle. + * STATUS: Who cares? + * + * * Objects that are not free or active (they + * do *not* have to be visible!) are "missing + * in action" as far as the engine is concerned. + * It won't find them unless you free them, + * or make them visible. + * STATUS: Can and should be fixed. + */ + +#ifndef _CS_H_ +#define _CS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + + +#define __CS_SHIFT 8 +#define CS2PIXEL(x) ( (x) >> __CS_SHIFT ) +#define PIXEL2CS(x) ( (x) << __CS_SHIFT ) + +#define CS_LAYERS 8 +#define CS_DEFAULT_LAYER 1 /*0 is normally for overlays*/ +#define CS_USER_POINTS 16 + +/* +FIXME: This fixpoint crap should probably be changed to float... +FIXME: Would break the "changed" mask bonus feature described +FIXME: below, though. +*/ + +typedef struct +{ + /* 24:8 fixpoint values */ + int x, y; /* logic position */ + int xv, yv; + int xa, ya; +} cs_vector_t; + + +/* + * Some handy vector construction macros... + * + * NOTE: position (x,y) in integer format, not fixpoint! + */ + +/* Point */ +static inline cs_vector_t cs_vector_p(int x, int y) +{ + cs_vector_t v; + v.x = PIXEL2CS(x); + v.y = PIXEL2CS(y); + v.xv = v.yv = v.xa = v.ya = 0; + return v; +} + +/* Point + velocity */ +static inline cs_vector_t cs_vector_pv(int x, int y, int xv, int yv) +{ + cs_vector_t v; + v.x = PIXEL2CS(x); + v.y = PIXEL2CS(y); + v.xv = xv; + v.yv = yv; + v.xa = v.ya = 0; + return v; +} + +/* Point + velocity + acceleration */ +static inline cs_vector_t cs_vector_pva(int x, int y, int xv, int yv, int xa, int ya) +{ + cs_vector_t v; + v.x = PIXEL2CS(x); + v.y = PIXEL2CS(y); + v.xv = xv; + v.yv = yv; + v.xa = xa; + v.ya = ya; + return v; +} + + +/* + * Generic coordinate + speed and acceleration type. Position filtering + * support is built-in as well, for smooth animation regardless of + * control system / video frame rate ratio. +FIXME: Interpolation can break detailed animations involving multiple +FIXME: sprites that move and animate (changing images) at the same +FIXME: time. Provide a "CS_OBJ_NO_INTERPOLATION" flag? + */ +typedef struct +{ + /* 24:8 fixpoint values here as well */ + cs_vector_t v; + + int ox, oy; /* last position (for filtering) */ + int gx, gy; /* graphic position */ + + /* (changed != 0) if gx or gy changed during the last update. + * This is a bit mask with the same format as the coords, + * which means that you can mask some low bits off to set + * a coarse movement sensitivity threshold. + * Ex. (changed & 0xffffff00) == "gx or gy moved to + * another pixel posn." + */ + int changed; +} cs_point_t; + + +/* + * Force the interpolation filter of a point to the current + * position of the vector. (This is required when activating + * new objects.) + */ +static inline void cs_point_force(cs_point_t *p) +{ + p->ox = p->gx = p->v.x; + p->oy = p->gy = p->v.y; +} + + +/* + * This stuff is translated from Object Pascal to "Object + * Oriented Style C" with my new naming conventions... + * I don't consider this code needing advanced OO, so I + * don't want to drag C++ in. + */ + +struct cs_engine_t; +struct cs_obj_t; + +/* +---------------------------------------------------------------------- + * cs_obj_t (used to be object + sprite) +---------------------------------------------------------------------- + * + * "The Basic Move Object. + * + * This object reperesents a moving object on the screen. + * You just tell it in what direction to go, and the Game Graphics + * system will do the job." + * + * What to do in the callbacks: + * collision() Check accurately if two objects really collide. + * (The control system will ask when bounding rects + * are overlapping and the collision masks indicate + * that a collision would affect one or both objects.) + */ +typedef struct cs_obj_t +{ + struct cs_engine_t *owner; + struct cs_obj_t **head; + struct cs_obj_t *next, *prev; + + cs_point_t point; /* Position, speed, acceleration */ + + int w, h; /* Sprite bounding rect size (pixels) */ + + int flags; + int layer; + + /* Collision filter (new) */ + int group_mask; /* bit set = "belongs to group" */ + int hit_mask; /* bit set = "can hit group" */ + + struct + { + int bank; /* Image bank */ + int frame; /* Image frame */ + int fframe; /* First frame (integer) */ + int aframes; /* # of frames; from fframe (integer) */ + int cframe; /* Current frame; from fframe (28:4 fixp) */ + int aspeed; /* Frames / engine cycle (28:4 fixp) */ + } anim; + + struct + { + cs_vector_t v; /* weapon offset + vel + acc */ + int rate; /* frames/shot */ + int timer; + int ammo; /* bullet type */ + } fire; + + int score; /*Score for destroy*/ + int health; /*Health points*/ + + /* + * Event callbacks + */ + int (*on_hit)(struct cs_obj_t *o); /* Ouch! */ + int (*on_dying)(struct cs_obj_t *o); /* Destructing... */ + int (*on_fire)(struct cs_obj_t *o); /* BOOM! */ + + /* + * Collision detection callbacks + * Called when bounding rect intersection is detected. + * Should return 1 if there actually is a collision. + */ + int (*collision)(struct cs_obj_t *o1, struct cs_obj_t *o2); + + /* + * Rendering callback + * NOTE: Use (gx,gy) when rendering, *NOT* (x,y)! + */ + void (*render)(struct cs_obj_t *o); + + /* + * User destructor; Object is freed after you return. + */ + int (*on_free)(struct cs_obj_t *o); + + /* User data */ + int tag; /* user ID */ + void *user; /* user data */ +} cs_obj_t; + + +/* cs_obj_t flags */ + +/* + * True when an object is "in the system"; ie when it's in one of + * the sprite lists, as opposed to in the free pool, or unattached. + * ("Unattached" is the state an object is in when you've just got + * it from cs_engine_get_obj().) + */ +#define CS_OBJ_ACTIVE 0x00000001 + +/* + * Note that an object with a 0 visible flag is still *active*! It's + * coordinates are updated, animation, collisions, spawning/shooting + * etc runs - it's just not visible. (Well, whatever is spawned is.) + */ +#define CS_OBJ_VISIBLE 0x00000002 + +/* + * Set by the collision detection system whenever any part of the + * object's bounding rectangle is inside the bounding rectangle + * of the screen. + */ +#define CS_OBJ_ONSCREN 0x00000004 + +/* + * Set whenever the cs animation system is to be used to generate + * image frame numbers for this object. + */ +#define CS_OBJ_DOANIM 0x00000008 + +/* + * Set while the object is marked as dying. Normally, you would + * run some animation and perhaps spawn some explosion objects, + * and then free the object. + */ +#define CS_OBJ_DYING 0x00000010 + + +/* Basic methods */ +/* + * Note: You only really need cs_obj_layer(), cs_obj_show() + * and cs_obj_free(). The others are just for more fine + * grained life cycle control. + */ +void cs_obj_layer(cs_obj_t *o, unsigned int layer); +void cs_obj_activate(cs_obj_t *o); /* Add to cs */ +void cs_obj_show(cs_obj_t *o); /* Enable display */ +void cs_obj_hide(cs_obj_t *o); /* Disable display */ +void cs_obj_deactivate(cs_obj_t *o); /* Disengage from cs */ +void cs_obj_free(cs_obj_t *o); /* Remove and throw back in the pool */ + +void cs_obj_pos(cs_obj_t *o, int x, int y); /* Set new position */ +void cs_obj_vel(cs_obj_t *o, int xs, int ys); /* Set movement speed */ +void cs_obj_acc(cs_obj_t *o, int xa, int ya); /* Set movement acceleration */ +void cs_obj_vector(cs_obj_t *o, cs_vector_t *v);/* Set all */ + +void cs_obj_clear(cs_obj_t *o); + +/* Animation methods */ +void cs_obj_image(cs_obj_t *o, int bank, int frame); +void cs_obj_anim(cs_obj_t *o, int bank, + int first, int num, + int start, int spd); +void cs_obj_explode(cs_obj_t *o); /*Start death sequence*/ + +/* Fire/spawning control */ +/* NOTE: + In the original version, spawned object speed was + absolute, while here, it's relative to object 'o'. +*/ +void cs_obj_shoot(cs_obj_t *o, int xo, int yo, int xs, + int ys, int rate, int delay, int ammo); + + +typedef struct +{ + int w, h; +} image_info_t; + +/* +---------------------------------------------------------------------- + * cs_engine_t (new) +---------------------------------------------------------------------- + */ +typedef struct cs_engine_t +{ + /* Display window size (pixels) */ + int w, h; + + /* Wrapping limits (pixels) */ + int wx, wy; + + /* Motion filtering */ + int filter; /* 0: newest, + * 1: linear interpolation + */ + + /* Current time in frames */ + double time; + + /* + * Callback that's called once per Control System + * frame from within cs_engine_advance(). + */ + void (*on_frame)(struct cs_engine_t *e); + + /* Active objects */ + cs_obj_t *objects[CS_LAYERS]; + + /* Layer position/offset control */ + cs_point_t offsets[CS_LAYERS]; + + /* Position control for custom stuff */ + cs_point_t points[CS_USER_POINTS]; + + /* + * Combined "changed" flag masks for the object groups above. + */ + int changed[CS_LAYERS]; + + /* Pool of unused objects */ + cs_obj_t *pool; + int pool_free; /* # of objects in here */ + int pool_total; /* # of objects in system */ + + /* Image info table */ + image_info_t *imageinfo; + int nimageinfo; +} cs_engine_t; + + +cs_engine_t *cs_engine_create(int w, int h, int objects); +void cs_engine_set_size(cs_engine_t *e, int w, int h); +void cs_engine_set_image_size(cs_engine_t *e, int bank, int w, int h); +void cs_engine_set_wrap(cs_engine_t *e, int x, int y); +void cs_engine_delete(cs_engine_t *e); + +void cs_engine_reset(cs_engine_t *e); +void cs_engine_advance(cs_engine_t *e, double to_frame); /* 0 == reset timer*/ +void cs_engine_render(cs_engine_t *e); + +cs_obj_t *cs_engine_get_obj(cs_engine_t *e); + +#ifdef __cplusplus +}; +#endif + +#endif /* _CS_H_ */ diff --git a/graphics/display.cpp b/graphics/display.cpp new file mode 100644 index 0000000..cfeeb52 --- /dev/null +++ b/graphics/display.cpp @@ -0,0 +1,104 @@ +/*(LGPL) + * Simple display for score, lives etc. + * © David Olofson, 2001-2003, 2007 + */ + +#define D_LINE_HEIGHT 9 + +#define D_LINE1_POS 1 +#define D_LINE1_TXOFFS 0 + +#define D_LINE2_POS 9 +#define D_LINE2_TXOFFS 0 + +#include + +#include "window.h" +#include "display.h" + +display_t::display_t() +{ + _on = 0; + caption("CAPTION"); + text("TEXT"); + on(); +} + + +void display_t::color(Uint32 _cl) +{ + _color = _cl; + if(_on) + invalidate(); +} + + +void display_t::caption(const char *cap) +{ + strncpy(_caption, cap, sizeof(_caption)); + if(_on) + invalidate(); +} + + +void display_t::text(const char *txt) +{ + strncpy(_text, txt, sizeof(_text)); + if(_on) + invalidate(); +} + + +void display_t::on() +{ + if(_on) + return; + + _on = 1; + invalidate(); +} + + +void display_t::off() +{ + if(!_on) + return; + + _on = 0; + invalidate(); +} + + +void display_t::render_caption() +{ + SDL_Rect r; + r.x = 0; + r.y = D_LINE1_POS; + r.w = width(); + r.h = D_LINE_HEIGHT; + background(_color); + clear(&r); + if(_on) + center(D_LINE1_POS + D_LINE1_TXOFFS, _caption); +} + + +void display_t::render_text() +{ + SDL_Rect r; + r.x = 0; + r.y = D_LINE2_POS; + r.w = width(); + r.h = D_LINE_HEIGHT; + background(_color); + clear(&r); + if(_on) + center(D_LINE2_POS + D_LINE2_TXOFFS, _text); +} + + +void display_t::refresh(SDL_Rect *r) +{ + render_caption(); + render_text(); +} diff --git a/graphics/display.h b/graphics/display.h new file mode 100644 index 0000000..50ea4f5 --- /dev/null +++ b/graphics/display.h @@ -0,0 +1,24 @@ +/*(LGPL) + * Simple display for score, lives etc. + * © David Olofson, 2001 + */ + +#include "window.h" + +class display_t : public window_t +{ + char _caption[64]; + char _text[64]; + int _on; + Uint32 _color; + void render_caption(); + void render_text(); + public: + display_t(); + void refresh(SDL_Rect *r); + void color(Uint32 _cl); + void caption(const char *cap); + void text(const char *txt); + void on(); + void off(); +}; diff --git a/graphics/filters.c b/graphics/filters.c new file mode 100644 index 0000000..106041e --- /dev/null +++ b/graphics/filters.c @@ -0,0 +1,1159 @@ +/*(LGPL) +---------------------------------------------------------------------- + filters.c - Filters for the sprite manager +---------------------------------------------------------------------- + * Copyright (C) 2001, 2003, 2006, 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include "logger.h" +#include "glSDL.h" +#include "SDL_image.h" +#include "sprite.h" +#include "filters.h" + + +/*-------------------------------------------------- + RNG +--------------------------------------------------*/ + +static unsigned int rnd = 16576; + +//Resets the noise generator +static void noise_reset(int seed) +{ + rnd = 16576 + seed; +} + +//Returns a pseudo random number in the range [0, 65535] +static inline int noise(void) +{ + rnd *= 1566083941UL; + rnd++; + rnd &= 0xffffffffUL; /* NOP on 32 bit machines */ + return (int)(rnd * (rnd >> 16) >> 16); +} + + +/*-------------------------------------------------- + Pixel access ops for 32 bit RGBA +--------------------------------------------------*/ + +static pix_t getpix32_empty = {0x7f, 0x7f, 0x7f, 0x7f}; + +static inline pix_t getpix32(SDL_Surface *s, int x, int y) +{ + pix_t *p; + if((x < 0) || (x >= s->w) || (y < 0) || (y >= s->h)) + return getpix32_empty; + + p = (pix_t *)((char *)s->pixels + y * s->pitch); + return p[x]; +} + + +/* Clamping version */ +static inline pix_t getpix32c(SDL_Surface *s, int x, int y) +{ + pix_t *p; + if(x < 0) + x = 0; + else if(x >= s->w-1) + x = s->w-1; + if(y < 0) + y = 0; + else if(y >= s->h-1) + y = s->h-1; + p = (pix_t *)((char *)s->pixels + y * s->pitch); + return p[x]; +} + +#define GETPIXI(gp) \ +{ \ + int c0x, c0y, c1x, c1y; \ + int c[4]; \ + pix_t e = {0, 0, 0, 0}; \ + pix_t p[4], r; \ + getpix32_empty = e; \ + \ + /* Calculate filter core */ \ + x -= 8; \ + y -= 8; \ + c1x = x & 0xf; \ + c1y = y & 0xf; \ + c0x = 16 - c1x; \ + c0y = 16 - c1y; \ + c[0] = c0x * c0y; \ + c[1] = c1x * c0y; \ + c[2] = c0x * c1y; \ + c[3] = c1x * c1y; \ + \ + /* Grab input pixels */ \ + x >>= 4; \ + y >>= 4; \ + p[0] = gp(s, x, y); \ + p[1] = gp(s, x+1, y); \ + p[2] = gp(s, x, y+1); \ + p[3] = gp(s, x+1, y+1); \ + \ + /* Interpolate... */ \ + r.r = (p[0].r*c[0] + p[1].r*c[1] + p[2].r*c[2] + p[3].r*c[3])>>8; \ + r.g = (p[0].g*c[0] + p[1].g*c[1] + p[2].g*c[2] + p[3].g*c[3])>>8; \ + r.b = (p[0].b*c[0] + p[1].b*c[1] + p[2].b*c[2] + p[3].b*c[3])>>8; \ + r.a = (p[0].a*c[0] + p[1].a*c[1] + p[2].a*c[2] + p[3].a*c[3])>>8; \ + return r; \ +} + +/* Interpolated; 28:4 fixed point coords. */ +static inline pix_t getpix32i(SDL_Surface *s, int x, int y) +{ + GETPIXI(getpix32) +} + + +/* Clamping version */ +static inline pix_t getpix32ic(SDL_Surface *s, int x, int y) +{ + GETPIXI(getpix32c) +} + + +static inline pix_t *pix32(SDL_Surface *s, int x, int y) +{ + static pix_t dummy = {0x7f, 0x7f, 0x7f, 0x7f}; + pix_t *p; + if((x < 0) || (x >= s->w) || (y < 0) || (y >= s->h)) + return &dummy; + p = (pix_t *)((char *)s->pixels + y * s->pitch); + return p + x; +} + + +static inline void setpix32(SDL_Surface *s, int x, int y, pix_t pix) +{ + pix_t *p; + if((x < 0) || (x >= s->w) || (y < 0) || (y >= s->h)) + return; + p = (pix_t *)((char *)s->pixels + y * s->pitch); + p[x] = pix; +} + + +/*-------------------------------------------------- + Non-clipping versions of everything + (No clamping here, obviously...!) +--------------------------------------------------*/ + +static inline pix_t getpix32_nc(SDL_Surface *s, int x, int y) +{ + pix_t *p = (pix_t *)((char *)s->pixels + y * s->pitch); +#ifdef DEBUG + if((x < 0) || (x >= s->w) || (y < 0) || (y >= s->h)) + { + log_printf(ELOG, "Clip in getpix32_nc()!" + " x = %d, y = %d\n", x, y); +*((char *)NULL) = 0; + return getpix32_empty; + } +#endif + return p[x]; +} + + +/* Interpolated; 28:4 fixed point coords. */ +static inline pix_t getpix32i_nc(SDL_Surface *s, int x, int y) +{ +#ifdef DEBUG + if((x < 0) || (x >= s->w << 4) || (y < 0) || (y >= s->h << 4)) + { + log_printf(ELOG, "Clip in getpix32i_nc()!" + " x = %d, y = %d\n", x>>4, y>>4); +*((char *)NULL) = 0; +// return getpix32_empty; + } + GETPIXI(getpix32) +#else + GETPIXI(getpix32_nc) +#endif +} +#undef GETPIXI + +static inline void setpix32_nc(SDL_Surface *s, int x, int y, pix_t pix) +{ + pix_t *p = (pix_t *)((char *)s->pixels + y * s->pitch); +#ifdef DEBUG + if((x < 0) || (x >= s->w) || (y < 0) || (y >= s->h)) + { + log_printf(ELOG, "Clip in setpix32_nc()!" + " x = %d, y = %d\n", x, y); +*((char *)NULL) = 0; +// return; + } +#endif + p[x] = pix; +} + + +static inline pix_t *pix32_nc(SDL_Surface *s, int x, int y) +{ + pix_t *p = (pix_t *)((char *)s->pixels + y * s->pitch); +#ifdef DEBUG +// static pix_t trash; + if((x < 0) || (x >= s->w) || (y < 0) || (y >= s->h)) + { + log_printf(ELOG, "Clip in pix32_nc()!" + " x = %d, y = %d\n", x, y); +*((char *)NULL) = 0; +// return &trash; + } +#endif + return p + x; +} + + + +/*-------------------------------------------------- + The filters +--------------------------------------------------*/ + +int s_filter_rgba8(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args) +{ + unsigned i; + SDL_PixelFormat fmt; + memset(&fmt, 0, sizeof(fmt)); + fmt.BitsPerPixel = 32; + fmt.BytesPerPixel = 4; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + fmt.Rmask = 0xff000000; + fmt.Gmask = 0x00ff0000; + fmt.Bmask = 0x0000ff00; + fmt.Amask = 0x000000ff; +#else + fmt.Rmask = 0x000000ff; + fmt.Gmask = 0x0000ff00; + fmt.Bmask = 0x00ff0000; + fmt.Amask = 0xff000000; +#endif + for(i = 0; i < frames; ++i) + { + SDL_Surface *tmp; + s_sprite_t *s = s_get_sprite_b(b, first+i); + if(!s) + continue; + tmp = SDL_ConvertSurface(s->surface, &fmt, + SDL_SWSURFACE); + if(!tmp) + return -1; + + SDL_FreeSurface(s->surface); + s->surface = tmp; + } + return 0; +} + + +int s_filter_dither(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args) +{ + int x, y; + unsigned i; + int ar, ag, ab; + if(!args->x && !args->r && !args->g && !args->b) + return 0; + noise_reset(first); + for(i = 0; i < frames; ++i) + { + s_sprite_t *s = s_get_sprite_b(b, first+i); + if(!s) + continue; + ar = args->r; + ag = args->g; + ab = args->b; + if(args->x) + switch (s_blitmode) + { + case S_BLITMODE_AUTO: + if(s->surface->format->Amask) + ar = ag = ab = 8; + break; + case S_BLITMODE_OPAQUE: + break; + case S_BLITMODE_COLORKEY: + case S_BLITMODE_ALPHA: + ar = ag = ab = 8; + break; + } + switch(args->y) + { + default: + case 0: + case 1: + ar >>= 1; + ag >>= 1; + ab >>= 1; + case 2: + break; + } + for(y = (args->flags & SF_CLAMP_SFONT) ? 1 : 0; y < b->h; ++y) + { + pix_t *p = (pix_t *)((char *)s->surface->pixels + + y * s->surface->pitch); + switch(args->y) + { + default: + case 0: + /* 2x2 filter */ + for(x = 0; x < b->w; ++x) + { + int r, g, b; + pix_t *pix = p + x; + if((x^y)&1) + { + r = pix->r + ar; + g = pix->g + ag; + b = pix->b + ab; + if(r>255) + r = 255; + if(g>255) + g = 255; + if(b>255) + b = 255; + } + else + { + r = pix->r - ar; + g = pix->g - ag; + b = pix->b - ab; + if(r<0) + r = 0; + if(g<0) + g = 0; + if(b<0) + b = 0; + } + pix->r = r; + pix->g = g; + pix->b = b; + } + break; + case 1: + /* 4x4 filter */ + for(x = 0; x < b->w; ++x) + { + int dr, dg, db; + int r, g, b; + pix_t *pix = p + x; + r = pix->r; + g = pix->g; + b = pix->b; + if((x^y) & 1) + { + dr = ar; + dg = ag; + db = ab; + } + else + { + dr = -ar; + dg = -ag; + db = -ab; + } + if(y & 1) + { + dr += ar >> 1; + dg += ag >> 1; + db += ab >> 1; + } + else + { + dr -= ar >> 1; + dg -= ag >> 1; + db -= ab >> 1; + } + r += dr; + g += dg; + b += db; + + if(r>255) + r = 255; + else if(r<0) + r = 0; + + if(g>255) + g = 255; + else if(g<0) + g = 0; + + if(b>255) + b = 255; + else if(b<0) + b = 0; + + pix->r = r; + pix->g = g; + pix->b = b; + } + break; + case 2: + /* Random */ + for(x = 0; x < b->w; ++x) + { + int r, g, b, z; + pix_t *pix = p + x; + z = noise(); + r = pix->r - ar + (((ar << 1) - 1) & z); + g = pix->g - ag + (((ag << 1) - 1) & z); + b = pix->b - ab + (((ab << 1) - 1) & z); + + if(r>255) + r = 255; + else if(r<0) + r = 0; + + if(g>255) + g = 255; + else if(g<0) + g = 0; + + if(b>255) + b = 255; + else if(b<0) + b = 0; + + pix->r = r; + pix->g = g; + pix->b = b; + } + break; + } + } + } + return 0; +} + + +/* + * Ugly hack to get around the problems caused by + * SDL_SetColorKey() ignoring the alpha channel. + * Basically just sets the blue LSB of any pixels + * that match the colorkey, but have non-transparent + * alpha. + */ +static void tweak_ck(SDL_Surface *s) +{ + int x, y; + if(s->format->BitsPerPixel != 32) + return; + for(y = 0; y < s->h; ++y) + { + pix_t *p = (pix_t *)((char *)s->pixels + y * s->pitch); + for(x = 0; x < s->w; ++x) + { + pix_t *pix = p + x; + if(!pix->r && !pix->g && !pix->b) + if(pix->a) + pix->b |= 1; + } + } +} + + +int s_filter_displayformat(s_bank_t * b, unsigned first, unsigned frames, + s_filter_args_t * args) +{ + unsigned i; + for(i = 0; i < frames; ++i) + { + SDL_Surface *tmp; + s_sprite_t *s = s_get_sprite_b(b, first + i); + if(!s) + continue; + + switch(s_blitmode) + { + case S_BLITMODE_AUTO: + if(s->surface->format->Amask) + SDL_SetAlpha(s->surface, + SDL_SRCALPHA | + SDL_RLEACCEL, + SDL_ALPHA_OPAQUE); + else + SDL_SetColorKey(s->surface, SDL_RLEACCEL, 0); + break; + case S_BLITMODE_OPAQUE: + SDL_SetColorKey(s->surface, SDL_RLEACCEL, 0); + break; + case S_BLITMODE_COLORKEY: + SDL_SetColorKey(s->surface, + SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(s->surface->format, + s_colorkey.r, + s_colorkey.g, + s_colorkey.b)); + break; + case S_BLITMODE_ALPHA: + SDL_SetAlpha(s->surface, + SDL_SRCALPHA | SDL_RLEACCEL, + s_alpha); + break; + } + + if(args->x) + { + if(s->surface->format->Amask) + tweak_ck(s->surface); + tmp = SDL_DisplayFormat(s->surface); + if(s->surface->format->Amask) + SDL_SetColorKey(tmp, + SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(tmp->format, 0,0,0)); + } + else + { + if(s->surface->format->Amask) + tmp = SDL_DisplayFormatAlpha(s->surface); + else + tmp = SDL_DisplayFormat(s->surface); + } + if(!tmp) + return -1; + + SDL_FreeSurface(s->surface); + s->surface = tmp; + } + return 0; +} + + +typedef struct +{ + SDL_Surface *src; /* Source surface */ + SDL_Surface *dst; /* Destination surface */ + int scx, scy; /* Scale (fixp 16:16) */ + int start_sy, start_sx; /* Src start pos (fixp 16:16) */ + int start_x, start_y; /* Dst start pos (pixels) */ + int max_x, max_y; /* Dst end pos (pixels) */ +} scale_params_t; + + +static inline void select_rect(scale_params_t *p, scale_params_t *orig, + int x, int y, int w, int h) +{ + p->start_sx = orig->start_sx + x * orig->scx; + p->start_sy = orig->start_sy + y * orig->scy; + p->start_x = orig->start_x + x; + p->start_y = orig->start_y + y; + p->max_x = p->start_x + w; + p->max_y = p->start_y + h; +} + +/* Optimization tool; use the slow clipping funcs only around the edges! */ +static inline void do_scale(scale_params_t *p, + void (*border)(scale_params_t *p), + void (*body)(scale_params_t *p)) +{ + /* Copy the parameters */ + scale_params_t lp = *p; + int w = p->max_x - p->start_x; + int h = p->max_y - p->start_y; + int bx = (65535 + p->scx) / p->scx; + int by = (65535 + p->scy) / p->scy; + if(bx * 2 >= w || by * 2 >= h) + { + /* Area too small - body size would be zero or negative! */ + select_rect(&lp, p, 0, 0, w, h); + border(&lp); + return; + } + + /* Top border */ + select_rect(&lp, p, 0, 0, w, by); + border(&lp); + + /* Bottom border */ + select_rect(&lp, p, 0, h - by, w, by); + border(&lp); + + /* Left border */ + select_rect(&lp, p, 0, by, bx, h - 2 * by); + border(&lp); + + /* Right border */ + select_rect(&lp, p, w - bx, by, bx, h - 2 * by); + border(&lp); + + /* Body */ + select_rect(&lp, p, bx, by, w - 2 * bx, h - 2 * by); + body(&lp); +} + + +/* + * Ugly but fast "nearest pixel" scaling + */ + +static void scale_nearest(scale_params_t *p) +{ + int x, y, sx, sy; + for(y = p->start_y, sy = p->start_sy; y < p->max_y; ++y, sy += p->scy) + { + pix_t *pix = (pix_t *)((char *)p->dst->pixels + + y * p->dst->pitch); + for(x = p->start_x, sx = p->start_sx; x < p->max_x; + ++x, sx += p->scx) + pix[x] = getpix32_nc(p->src, sx >> 16, sy >> 16); + } +} + + +/* + * Bilinear scaling + */ + +static void do_scale_bilinear_noclip(scale_params_t *p) +{ + int x, y, sx, sy; + for(y = p->start_y, sy = p->start_sy; y < p->max_y; ++y, sy += p->scy) + { + pix_t *pix = (pix_t *)((char *)p->dst->pixels + + y * p->dst->pitch); + for(x = p->start_x, sx = p->start_sx; x < p->max_x; + ++x, sx += p->scx) + pix[x] = getpix32i_nc(p->src, sx >> 12, sy >> 12); + } +} + +static void do_scale_bilinear_clip(scale_params_t *p) +{ + int x, y, sx, sy; + for(y = p->start_y, sy = p->start_sy; y < p->max_y; ++y, sy += p->scy) + { + pix_t *pix = (pix_t *)((char *)p->dst->pixels + + y * p->dst->pitch); + for(x = p->start_x, sx = p->start_sx; x < p->max_x; + ++x, sx += p->scx) + pix[x] = getpix32i(p->src, sx >> 12, sy >> 12); + } +} + +static void do_scale_bilinear_clamp(scale_params_t *p) +{ + int x, y, sx, sy; + for(y = p->start_y, sy = p->start_sy; y < p->max_y; ++y, sy += p->scy) + { + pix_t *pix = (pix_t *)((char *)p->dst->pixels + + y * p->dst->pitch); + for(x = p->start_x, sx = p->start_sx; x < p->max_x; + ++x, sx += p->scx) + pix[x] = getpix32ic(p->src, sx >> 12, sy >> 12); + } +} + +static void scale_bilinear(scale_params_t *p) +{ + do_scale(p, do_scale_bilinear_clip, do_scale_bilinear_noclip); +} + +static void scale_bilinear_clamp(scale_params_t *p) +{ + do_scale(p, do_scale_bilinear_clamp, do_scale_bilinear_noclip); +} + + +/* + * Scale2x scaling + * + * This one's cool for 16 color graphics and the like, but + * even with the fuzziness factor, it doesn't work well + * with 24 bit data, or even 256 color graphics. + */ +#define CDIFF(x,y) (((x).r^(y).r) | ((x).g^(y).g) | ((x).b^(y).b) | ((x).a^(y).a)) +#define SCALE2X(gp, sp) \ +{ \ + int DB, BF, DH, FH; \ + pix_t B ; \ + pix_t D, E, F; \ + pix_t H ; \ + pix_t E0, E1; \ + pix_t E2, E3; \ + B = gp(p->src, sx, sy-1); \ + D = gp(p->src, sx-1, sy); \ + E = gp(p->src, sx, sy); \ + F = gp(p->src, sx+1, sy); \ + H = gp(p->src, sx, sy+1); \ + DB = CDIFF(D, B) & 0xc0; \ + BF = CDIFF(B, F) & 0xc0; \ + DH = CDIFF(D, H) & 0xc0; \ + FH = CDIFF(F, H) & 0xc0; \ + E0 = (!DB && BF && DH) ? D : E; \ + E1 = (!BF && DB && FH) ? F : E; \ + E2 = (!DH && DB && FH) ? D : E; \ + E3 = (!FH && DH && BF) ? F : E; \ + sp(p->dst, x, y, E0); \ + sp(p->dst, x+1, y, E1); \ + sp(p->dst, x, y+1, E2); \ + sp(p->dst, x+1, y+1, E3); \ +} +static void do_scale_2x_noclip(scale_params_t *p) +{ + int x, y, sx, sy; + for(y = p->start_y, sy = p->start_sy >> 16; y < p->max_y; y += 2, ++sy) + for(x = p->start_x, sx = p->start_sx >> 16; x < p->max_x; + x += 2, ++sx) + SCALE2X(getpix32_nc, setpix32_nc); +} + +static void do_scale_2x_clip(scale_params_t *p) +{ + int x, y, sx, sy; + for(y = p->start_y, sy = p->start_sy >> 16; y < p->max_y; y += 2, ++sy) + for(x = p->start_x, sx = p->start_sx >> 16; x < p->max_x; + x += 2, ++sx) + SCALE2X(getpix32, setpix32); +} + +static void do_scale_2x_clamp(scale_params_t *p) +{ + int x, y, sx, sy; + for(y = p->start_y, sy = p->start_sy >> 16; y < p->max_y; y += 2, ++sy) + for(x = p->start_x, sx = p->start_sx >> 16; x < p->max_x; + x += 2, ++sx) + SCALE2X(getpix32c, setpix32); +} +#undef CDIFF +#undef SCALE2X + +static void scale_2x(scale_params_t *p) +{ + do_scale(p, do_scale_2x_clip, do_scale_2x_noclip); +} + +static void scale_2x_clamp(scale_params_t *p) +{ + do_scale(p, do_scale_2x_clamp, do_scale_2x_noclip); +} + + +/* + * Diamond2x scaling + * + * This works *great* though; kicks the butt of + * Linear/Oversampled real hard - and at an order + * of magnitude higher speed! :-) + */ +#define MIX(t,x,y,z) (t).r = ((x).r+(x).r+(y).r+(z).r)>>2; \ + (t).g = ((x).g+(x).g+(y).g+(z).g)>>2; \ + (t).b = ((x).b+(x).b+(y).b+(z).b)>>2; \ + (t).a = ((x).a+(x).a+(y).a+(z).a)>>2; +#define DIAMOND(gp, sp) \ +{ \ + pix_t B; \ + pix_t D, E, F; \ + pix_t H; \ + pix_t E0, E1; \ + pix_t E2, E3; \ + B = gp(p->src, sx, sy-1); \ + D = gp(p->src, sx-1, sy); \ + E = gp(p->src, sx, sy); \ + F = gp(p->src, sx+1, sy); \ + H = gp(p->src, sx, sy+1); \ + MIX(E0, E, B, D); \ + MIX(E1, E, B, F); \ + MIX(E2, E, H, D); \ + MIX(E3, E, H, F); \ + sp(p->dst, x, y, E0); \ + sp(p->dst, x+1, y, E1); \ + sp(p->dst, x, y+1, E2); \ + sp(p->dst, x+1, y+1, E3); \ +} +static void do_scale_diamond2x_noclip(scale_params_t *p) +{ + int x, y, sx, sy; + for(y = p->start_y, sy = p->start_sy >> 16; y < p->max_y; y += 2, ++sy) + for(x = p->start_x, sx = p->start_sx >> 16; x < p->max_x; + x += 2, ++sx) + DIAMOND(getpix32_nc, setpix32_nc); +} + +static void do_scale_diamond2x_clip(scale_params_t *p) +{ + int x, y, sx, sy; + for(y = p->start_y, sy = p->start_sy >> 16; y < p->max_y; y += 2, ++sy) + for(x = p->start_x, sx = p->start_sx >> 16; x < p->max_x; + x += 2, ++sx) + DIAMOND(getpix32, setpix32); +} + +static void do_scale_diamond2x_clamp(scale_params_t *p) +{ + int x, y, sx, sy; + for(y = p->start_y, sy = p->start_sy >> 16; y < p->max_y; y += 2, ++sy) + for(x = p->start_x, sx = p->start_sx >> 16; x < p->max_x; + x += 2, ++sx) + DIAMOND(getpix32c, setpix32); +} +#undef MIX +#undef DIAMOND + +static void scale_diamond2x(scale_params_t *p) +{ + do_scale(p, do_scale_diamond2x_clip, do_scale_diamond2x_noclip); +} + +static void scale_diamond2x_clamp(scale_params_t *p) +{ + do_scale(p, do_scale_diamond2x_clamp, do_scale_diamond2x_noclip); +} + + +int s_filter_scale(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args) +{ + scale_params_t params; + int fmode, smode = args->x; + unsigned i; + if((args->fx <= 0.0f) && (args->fy <= 0.0f)) + return 0; + if((args->fx == 1.0f) && (args->fy <= 1.0f)) + return 0; + + switch(smode) + { + case SF_SCALE_NEAREST: + case SF_SCALE_BILINEAR: + break; + case SF_SCALE_SCALE2X: + case SF_SCALE_DIAMOND: + if((args->fx != 2.0) || (args->fy != 2.0)) + { + log_printf(WLOG, "Scale2x and Diamond2x scaling " + "works only with a scaling factor " + "of exactly 2.0!\n"); +/* smode = SF_SCALE_NEAREST;*/ + smode = SF_SCALE_BILINEAR; + } + break; + } + + getpix32_empty = s_clampcolor; + + params.max_x = (int)ceil(b->w * args->fx); + params.scx = (int)(65536.0 / args->fx); + params.scy = (int)(65536.0 / args->fy); + params.start_x = 0; + params.start_sx = 0; + + /* Check for special SFont mode */ + if(args->flags & SF_CLAMP_SFONT) + { + params.start_y = 1; + params.start_sy = 65536; + params.max_y = (int)((b->h - 1) * args->fy + 1 + 0.5f); + } + else + { + params.start_y = 0; + params.start_sy = 0; + params.max_y = (int)(b->h * args->fy + 0.5f); + } + + /* Decode filter type + SF_CLAMP_EXTEND flag */ + fmode = (args->flags & SF_CLAMP_EXTEND) ? 1 : 0; + switch(smode) + { + case SF_SCALE_NEAREST: + fmode += 0; + break; + case SF_SCALE_BILINEAR: + fmode += 2; + /* Offset by half a pixel */ + params.start_sx += params.scx / 2; + params.start_sy += params.scy / 2; + break; + case SF_SCALE_SCALE2X: + fmode += 4; + break; + case SF_SCALE_DIAMOND: + fmode += 6; + break; + } + + for(i = 0; i < frames; ++i) + { + s_sprite_t *s = s_get_sprite_b(b, first+i); + if(!s) + continue; + params.src = s->surface; + params.dst = SDL_CreateRGBSurface(SDL_SWSURFACE, + params.max_x, params.max_y, 32, +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); +#else + 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); +#endif + if(!params.dst) + return -1; +#ifdef DEBUG + SDL_FillRect(params.dst, NULL, + SDL_MapRGB(params.dst->format, 255, 128, 0)); +#endif + + /* Deal with SFont marker row */ + if(args->flags & SF_CLAMP_SFONT) + { + int x, sx; + pix_t clear = {0, 0, 0, 0}; + /* Scale marker row with "nearest" filter */ + for(x = 0, sx = params.start_sx; x < params.max_x; + ++x, sx += params.scx) + setpix32_nc(params.dst, x, 0, + getpix32(params.src, + sx >> 16, 0)); + /* Remove marker row to avoid garbage */ + for(x = 0; x < b->w; ++x) + setpix32_nc(params.src, x, 0, clear); + } + + /* Do the scaling! */ + switch(fmode) + { + case 0: /*Nearest*/ + case 1: /*Nearest + extend clamping*/ + scale_nearest(¶ms); + break; + case 2: /*Bilinear*/ + scale_bilinear(¶ms); + break; + case 3: /*Bilinear + extend clamping*/ + scale_bilinear_clamp(¶ms); + break; + case 4: /*Scale2x*/ + scale_2x(¶ms); + break; + case 5: /*Scale2x + extend clamping*/ + scale_2x_clamp(¶ms); + break; + case 6: /*Diamond2x*/ + scale_diamond2x(¶ms); + break; + case 7: /*Diamond2x + extend clamping*/ + scale_diamond2x_clamp(¶ms); + break; + } + + SDL_FreeSurface(s->surface); + s->surface = params.dst; + } + b->w = params.max_x; + b->h = params.max_y; + return 0; +} + + +int s_filter_cleanalpha(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args) +{ + int min = args->min; + int max = args->max; + int x, y; + unsigned i; + int contrast = (int)(args->fx * 256); + int offset = args->x + 128; /* 128 for the bias! */ + if(!contrast) + contrast = 256; /*Default = 1.0*/ + for(i = 0; i < frames; ++i) + { + s_sprite_t *s = s_get_sprite_b(b, first+i); + if(!s) + continue; + for(y = (args->flags & SF_CLAMP_SFONT) ? 1 : 0; y < b->h; ++y) + { + pix_t *p = (pix_t *)((char *)s->surface->pixels + + y * s->surface->pitch); + for(x = 0; x < b->w; ++x) + { + pix_t *pix = p + x; + int alpha = pix->a; + alpha = (alpha-128) * contrast >> 8; + alpha += offset; + if(alpha <= min) + pix->a = pix->r = pix->g = pix->b = 0; + else if(alpha > max) + pix->a = 255; + else + pix->a = alpha; + } + } + } + return 0; +} + + +int s_filter_brightness(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args) +{ + int min = args->min; + int max = args->max; + int x, y; + unsigned i; + int contrast = (int)(args->fy * 256); + int offset = (int)(args->fx * 256 - 256) + 128; /* bias! */ + if((256 == contrast) && (128 == offset) && (min <= 0) && (max >= 255)) + return 0; /* No effect! --> */ + + for(i = 0; i < frames; ++i) + { + s_sprite_t *s = s_get_sprite_b(b, first + i); + if(!s) + continue; + for(y = (args->flags & SF_CLAMP_SFONT) ? 1 : 0; y < b->h; ++y) + { + pix_t *p = (pix_t *)((char *)s->surface->pixels + + y * s->surface->pitch); + for(x = 0; x < b->w; ++x) + { + int v; + pix_t *pix = p + x; + v = ((pix->r - 128) * contrast >> 8) + offset; + if(v < min) + v = min; + else if(v > max) + v = max; + pix->r = v; + v = ((pix->g - 128) * contrast >> 8) + offset; + if(v < min) + v = min; + else if(v > max) + v = max; + pix->g = v; + v = ((pix->b - 128) * contrast >> 8) + offset; + if(v < min) + v = min; + else if(v > max) + v = max; + pix->b = v; + } + } + } + return 0; +} + + +static void construct_limits(int *min, int *max, int maxdev) +{ + *min -= maxdev; + if(*min < 0) + *min = 0; + *max += maxdev; + if(*max > 255) + *max = 255; +} + + +static inline int check_limits(int min, int max, int value) +{ + if(value < min) + return 0; + if(value > max) + return 0; + return 1; +} + + +int s_filter_key2alpha(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args) +{ + int x, y, krmin, krmax, kgmin, kgmax, kbmin, kbmax; + unsigned i; + krmin = krmax = s_colorkey.r; + kgmin = kgmax = s_colorkey.g; + kbmin = kbmax = s_colorkey.b; + construct_limits(&krmin, &krmax, args->max); + construct_limits(&kgmin, &kgmax, args->max); + construct_limits(&kbmin, &kbmax, args->max); + for(i = 0; i < frames; ++i) + { + s_sprite_t *s = s_get_sprite_b(b, first+i); + if(!s) + continue; + for(y = (args->flags & SF_CLAMP_SFONT) ? 1 : 0; y < b->h; ++y) + { + pix_t *p = (pix_t *)((char *)s->surface->pixels + + y * s->surface->pitch); + for(x = 0; x < b->h; ++x) + { + pix_t *pix = p + x; + if(check_limits(krmin, krmax, pix->r) + && check_limits(kgmin, kgmax, pix->g) + && check_limits(kbmin, kbmax, pix->b)) + pix->r = pix->g = pix->b = pix->a = 0; + } + } + } + return 0; +} + + +int s_filter_noise(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args) +{ + int x, y; + unsigned i; + int br, bg, bb; /* bias */ + int ar, ag, ab; /* amplitude */ + i = args->min; + br = args->r * i >> 8; + bg = args->g * i >> 8; + bb = args->b * i >> 8; + i = args->max - args->min; + ar = args->r * i >> 8; + ag = args->g * i >> 8; + ab = args->b * i >> 8; + noise_reset(args->x); + for(i = 0; i < frames; ++i) + { + s_sprite_t *s = s_get_sprite_b(b, first+i); + if(!s) + continue; + for(y = (args->flags & SF_CLAMP_SFONT) ? 1 : 0; y < b->h; ++y) + { + pix_t *p = (pix_t *)((char *)s->surface->pixels + + y * s->surface->pitch); + for(x = 0; x < b->w; ++x) + { + int r, g, b; + pix_t *pix = p + x; + int rnd = noise(); + r = rnd * ar + br + pix->r; + g = rnd * ag + bg + pix->g; + b = rnd * ab + bb + pix->b; + if(r>255) + r = 255; + if(g>255) + g = 255; + if(b>255) + b = 255; + pix->r = r; + pix->g = g; + pix->b = b; + } + } + } + return 0; +} diff --git a/graphics/filters.h b/graphics/filters.h new file mode 100644 index 0000000..82ea343 --- /dev/null +++ b/graphics/filters.h @@ -0,0 +1,192 @@ +/*(LGPL) +---------------------------------------------------------------------- + filters.h - Filters for the sprite manager +---------------------------------------------------------------------- + * Copyright (C) David Olofson, 2001, 2003 + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef SPRITE_FILTERS_H +#define SPRITE_FILTERS_H + +#include "sprite.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Flags (args.flags) that apply to most plugins: + */ +#define SF_CLAMP_EXTEND 0x00000001 +#define SF_CLAMP_SFONT 0x00000002 + + +/* + * Convert bank to RGBA 8:8:8:8 format. + * + * (No arguments.) + */ +int s_filter_rgba8(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args); + +/* + * Dither R, G and B channels to the specified bit depth. + * + * args.x = 1 activates 16 bit RGBA fix (assume +/-16 dither depth for RGBA) + * args.y = dither type (0 = 2x2 filter, 1 = random) + * + * args.r = red dither depth + * args.g = green dither depth + * args.b = blue dither depth + * + * args.flags; + * SF_CLAMP_SFONT SFont mode; first row is ignored. + * + * Note: This plugin does *not* dither the alpha channel! + */ +int s_filter_dither(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args); + +/* + * Convert bank to display format for fast rendering. + * + * args.x = 1 forces use of SDL_DisplayFormat(). + * RGBA surfaces get a colorkey of <0,0,0,0>. + */ +int s_filter_displayformat(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args); + +/* + * Convert colorkey to alpha channel. + * + * The global colorkey variable is used for base colorkey value. + * args.max = colorkey detection fuzziness factor + * args.flags; + * SF_CLAMP_SFONT SFont mode; first row is ignored. + */ +int s_filter_key2alpha(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args); + +/* + * Adjust alpha level and contrast, and then clean out almost opaque + * and almost transparent pixels. + * + * args.fx = alpha contrast (1.0 = unchanged; 2.0 = double; scales around 128) + * args.x = alpha offset (0 = unchanged; -255 = all transp.; 255 = all opaque) + * + * args.min = min alpha passed (lower ==> 0) + * args.max = max alpha passed (higher ==> 255) + * + * args.flags; + * SF_CLAMP_SFONT SFont mode; first row is ignored. + */ +int s_filter_cleanalpha(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args); + +/* + * Adjust brightness and contrast. + * + * args.fx = brightness (1.0 = unchanged; 0.0 = black; 2.0 = white) + * args.fy = contrast (1.0 = unchanged; 0.5 = 50%; 2.0 = 200%) + * + * args.min = min value (clamping) + * args.max = max value (clamping) + * + * args.flags; + * SF_CLAMP_SFONT SFont mode; first row is ignored. + */ +int s_filter_brightness(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args); + +/* + * Scale images by the specified factor, using the specified method. + * + * args.x = scaling mode; + * SF_SCALE_NEAREST Nearest + * SF_SCALE_BILINEAR Bilinear interpolation + * SF_SCALE_SCALE2X Scale2x (Based on an algo from AdvanceMAME) + * SF_SCALE_DIAMOND Diamond (Weighted diamond shaped core) + * + * args.fx = horizontal scale factor (1.0 ==> 1:1) + * args.fy = vertical scale factor (1.0 ==> 1:1) + * + * args.flags; + * SF_CLAMP_EXTEND Clamp at edges; image edge is extended outwards + * SF_CLAMP_SFONT SFont mode; first row is treated specially. + * + */ +#define SF_SCALE_NEAREST 0 +#define SF_SCALE_BILINEAR 1 +#define SF_SCALE_SCALE2X 2 +#define SF_SCALE_DIAMOND 3 +int s_filter_scale(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args); + +#if 0 +/* +TODO: + * Add shaded light to images. + * + * args.fx = Highlight X position ([0,1]) + * args.fy = Highlight Y position ([0,1]) + * args.fz = Highlight "half intensity" radius + * + * args.x = Gradient type: + * SF_LIGHT_LINEAR Linear gradient + * SF_LIGHT_CIRCULAR Circular spotlight + * + * args.z = Gradient rotation (65536 units/rotation) + * + * args.min = "Ambient light" + * args.max = Max brightness + * + * args.r = Light color, red component + * args.g = Light color, green component + * args.b = Light color, blue component + * + * args.flags; + * SF_CLAMP_SFONT SFont mode; first row is ignored. + */ +#define SF_LIGHT_LINEAR 0 +#define SF_LIGHT_CIRCULAR 1 +int s_filter_light(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args); +#endif + +/* + * Add single colored noise to images. + * + * args.x = Pseudo-RNG seed for first frame + * + * args.min = Min brightness ([0,255]) + * args.max = Max brightness ([0,255]) + * + * args.r = Noise color, red component ([0,255]) + * args.g = Noise color, green component ([0,255]) + * args.b = Noise color, blue component ([0,255]) + * + * args.flags; + * SF_CLAMP_SFONT SFont mode; first row is ignored. + */ +int s_filter_noise(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args); + +#ifdef __cplusplus +} +#endif + +#endif /* SPRITE_FILTERS_H */ diff --git a/graphics/gfxengine.cpp b/graphics/gfxengine.cpp new file mode 100644 index 0000000..c70a4b1 --- /dev/null +++ b/graphics/gfxengine.cpp @@ -0,0 +1,1426 @@ +/*(LGPL) +---------------------------------------------------------------------- + gfxengine.cpp - Graphics Engine +---------------------------------------------------------------------- + * Copyright (C) 2001-2003, 2006-2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define DBG(x) x + +#include "logger.h" + +#include +#include + +#include "gfxengine.h" +#include "filters.h" +#include "SDL_image.h" +#include "glSDL.h" +#include "sofont.h" +#include "window.h" + +gfxengine_t *gfxengine; + + +gfxengine_t::gfxengine_t() +{ + gfxengine = this; /* Uurgh! Kludge. */ + + screen_surface = NULL; + softbuf = NULL; + fullwin = NULL; + window = NULL; + windows = NULL; + wx = wy = 0; + xs = ys = 256; // 1.0 + sxs = sys = 256; // 1.0 + sf1 = df = dsf = acf = NULL; + gfx = NULL; + csengine = NULL; + _driver = GFX_DRIVER_SDL2D; + _shadow = 1; + _doublebuf = 1; + _pages = -1; + _vsync = 1; + _fullscreen = 0; + _centered = 0; + use_interpolation = 1; + _depth = 0; + _title = "GfxEngine v0.4"; + _icontitle = "GfxEngine"; + _cursor = 1; + _width = 320; + _height = 240; + _autoinvalidate = 1; + _scalemode = GFX_SCALE_NEAREST; + _clamping = 0; + xflags = 0; + + _dither = 0; + _dither_type = 0; + broken_rgba8 = 0; + alpha_threshold = 0; + + _brightness = 1.0; + _contrast = 1.0; + + last_tick = -1000000; + ticks_per_frame = 1000.0/60.0; + + is_running = 0; + is_showing = 0; + is_open = 0; + + memset(fonts, 0, sizeof(fonts)); + + xscroll = yscroll = 0; + for(int i = 0; i < CS_LAYERS ; ++i) + xratio[i] = yratio[i] = 0.0; + + dirtyrects[0] = 0; + dirtyrects[1] = 0; + frontpage = 0; + backpage = 1; + screenshot_count = 0; +} + + +gfxengine_t::~gfxengine_t() +{ + stop(); + hide(); + close(); + window_t *w = windows; + while(w) + { + w->engine = NULL; + w = w->next; + } +} + + +void gfxengine_t::output(window_t *outwin) +{ + window = outwin; +} + + +/*---------------------------------------------------------- + Initialization +----------------------------------------------------------*/ + +void gfxengine_t::size(int w, int h) +{ + int was_showing = is_showing; + hide(); + + _width = w; + _height = h; + if(csengine) + cs_engine_set_size(csengine, w, h); + + if(was_showing) + show(); +} + +void gfxengine_t::centered(int c) +{ + int was_showing = is_showing; + hide(); + + _centered = c; + + if(was_showing) + show(); +} + +void gfxengine_t::scale(float x, float y) +{ + xs = (int)(x * 256.f); + ys = (int)(y * 256.f); + log_printf(DLOG, "gfxengine: Setting scale to %d:256 x %d:256.\n", xs, ys); +} + +void gfxengine_t::mode(int bits, int fullscreen) +{ + int was_showing = is_showing; + hide(); + + int olddepth = _depth; + _depth = bits; + if(_depth != olddepth) + reload(); + _fullscreen = fullscreen; + + if(was_showing) + show(); +} + +void gfxengine_t::driver(gfx_drivers_t drv) +{ + int was_showing = is_showing; + hide(); + + _driver = drv; + + if(was_showing) + show(); +} + +void gfxengine_t::doublebuffer(int use) +{ + if(_doublebuf == use) + return; + + int was_showing = is_showing; + hide(); + + _doublebuf = use; + + if(was_showing) + show(); +} + +void gfxengine_t::pages(int np) +{ + _pages = np; +} + +void gfxengine_t::vsync(int use) +{ + if(_vsync == use) + return; + + int was_showing = is_showing; + hide(); + + _vsync = use; + + if(was_showing) + show(); +} + +void gfxengine_t::shadow(int use) +{ + if(_shadow == use) + return; + + int was_showing = is_showing; + hide(); + + _shadow = use; + + if(was_showing) + show(); +} + +void gfxengine_t::autoinvalidate(int use) +{ + _autoinvalidate = use; +} + +void gfxengine_t::period(float frameduration) +{ + if(frameduration > 0) + { + ticks_per_frame = frameduration; + } + else + log_printf(DLOG, "gfxengine: Time line reset.\n"); + if(csengine) + cs_engine_advance(csengine, 0); +} + +void gfxengine_t::wrap(int x, int y) +{ + wx = x; + wy = y; + if(csengine) + cs_engine_set_wrap(csengine, x, y); +} + + +/*---------------------------------------------------------- + Data management +----------------------------------------------------------*/ + +void gfxengine_t::reset_filters() +{ + /* Remove all filters */ + s_remove_filter(NULL); + sf1 = df = dsf = acf = NULL; + + /* Set up filter pipeline */ + s_remove_filter(NULL); + + s_add_filter(s_filter_rgba8); +#if 0 + s_filter_t *fi; + fi = s_add_filter(s_filter_key2alpha); + fi->args.max = 1; +#endif + sf1 = s_add_filter(s_filter_scale); + sf2 = s_add_filter(s_filter_scale); + acf = s_add_filter(s_filter_cleanalpha); + bcf = s_add_filter(s_filter_brightness); + df = s_add_filter(s_filter_dither); + dsf = s_add_filter(s_filter_displayformat); + + /* Set default parameters */ +// colorkey(0, 0, 0); + clampcolor(0, 0, 0, 0); + scalemode(GFX_SCALE_NEAREST); + dither(0, 0); + noalpha(0); + brightness(1.0, 1.0); + filterflags(0); +} + + +void gfxengine_t::filterflags(int fgs) +{ + s_filter_flags = fgs; +} + + +void gfxengine_t::scalemode(gfx_scalemodes_t sm, int clamping) +{ + _scalemode = sm; + _clamping = clamping; + if(!sf1 || !df) + return; + + int rxs = (xs * 256 + 128) / sxs; + int rys = (ys * 256 + 128) / sys; +#if 1 + // Filter 2 is off in most cases + sf2->args.x = 0; + sf2->args.fx = 0.0f; + sf2->args.fy = 0.0f; +#endif + if((rxs == 256) && (rys == 256)) + { + sf1->args.x = SF_SCALE_NEAREST; + sf1->args.fx = 1.0f; + sf1->args.fy = 1.0f; + return; + } + + switch(clamping) + { + default: + case 0: + filterflags(0); + break; + case 1: + filterflags(SF_CLAMP_EXTEND); + break; + case 2: + filterflags(SF_CLAMP_SFONT); + break; + } + + sf1->args.fx = rxs * (1.0f/256.0f); + sf1->args.fy = rys * (1.0f/256.0f); + + switch(_scalemode) + { + case GFX_SCALE_NEAREST: //Nearest + sf1->args.x = SF_SCALE_NEAREST; + break; + case GFX_SCALE_BILINEAR: //Bilinear + sf1->args.x = SF_SCALE_BILINEAR; + break; + case GFX_SCALE_BILIN_OVER: //Bilinear + Oversampling +#if 0 + sf1->args.x = SF_SCALE_BILINEAR; + sf2->args.x = SF_SCALE_BILINEAR; + sf1->args.fx = rxs * (1.5f/256.f); + sf1->args.fy = rys * (1.5f/256.f); + sf2->args.fx = 1.0f/1.5f; + sf2->args.fy = 1.0f/1.5f; + break; + /* Hack for better bilinear [+ oversampling] scaling... */ + switch(clamping) + { + case 2: + sf1->args.x = SF_SCALE_NEAREST; + sf2->args.x = SF_SCALE_BILINEAR; + switch((rxs + 128) / 256) + { + case 2: + sf1->args.fx = 4.0f; + sf1->args.fy = 4.0f; + sf2->args.fx = 0.5f; + sf2->args.fy = 0.5f; + break; + case 3: + sf1->args.fx = 2.0f; + sf1->args.fy = 2.0f; + sf2->args.fx = 1.5f; + sf2->args.fy = 1.5f; + break; + case 4: + sf1->args.fx = 2.0f; + sf1->args.fy = 2.0f; + sf2->args.fx = 2.0f; + sf2->args.fy = 2.0f; + break; + default: + sf1->args.fx = rxs * (2.f/256.f); + sf1->args.fy = rys * (2.f/256.f); + sf2->args.fx = 0.5f; + sf2->args.fy = 0.5f; + break; + } + break; + default: + sf1->args.x = SF_SCALE_BILINEAR; + break; + } +#endif + sf1->args.x = SF_SCALE_BILINEAR; + break; + case GFX_SCALE_SCALE2X: //Scale2x + sf1->args.x = SF_SCALE_SCALE2X; + break; + case GFX_SCALE_DIAMOND: //Diamond2x + sf1->args.x = SF_SCALE_DIAMOND; + break; + } +} + + +void gfxengine_t::source_scale(float x, float y) +{ + sxs = (int)(x * 256.f); + sys = (int)(y * 256.f); + scalemode(_scalemode, _clamping); +} + +#if 0 +void gfxengine_t::colorkey(Uint8 r, Uint8 g, Uint8 b) +{ + s_colorkey.r = r; + s_colorkey.g = g; + s_colorkey.b = b; +} +#endif + +void gfxengine_t::clampcolor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + s_clampcolor.r = r; + s_clampcolor.g = g; + s_clampcolor.b = b; + s_clampcolor.a = b; +} + + +void gfxengine_t::dither(int type, int _broken_rgba8) +{ + _dither = type >= 0; + _dither_type = type; + broken_rgba8 = _broken_rgba8; + + if(!df) + return; + if(!screen_surface) + return; + + if(_dither) + { + if(_driver == GFX_DRIVER_GLSDL) + { + //Klugde for glSDL, which doesn't give us a faked + //screen surface - while we're interested only in + //the *texture* depth; not the display depth! + df->args.r = df->args.g = df->args.b = 0; + //Another kludge, because some cards support RGB8 + //(24 bit) textures, but not RGBA8 (32 bit). + df->args.x = broken_rgba8; + } + else + { + df->args.x = 0; + df->args.r = 1<<(screen_surface->format->Rloss-1); + df->args.g = 1<<(screen_surface->format->Gloss-1); + df->args.b = 1<<(screen_surface->format->Bloss-1); + } + } + else + df->args.x = df->args.r = df->args.g = df->args.b = 0; + df->args.y = type; +} + + +void gfxengine_t::noalpha(int threshold) +{ + alpha_threshold = threshold; + if(!dsf || !acf) + return; + + if(threshold > 0) + { + acf->args.min = 128; + acf->args.max = 128; + acf->args.fx = 1.0; + acf->args.x = threshold; + + dsf->args.x = 1; + } + else + { + acf->args.min = 16; + acf->args.max = 255-16; + acf->args.fx = 1.3; + acf->args.x = -16; + + dsf->args.x = 0; + } +} + + +void gfxengine_t::brightness(float bright, float contr) +{ + _brightness = bright; + _contrast = contr; + if(!bcf) + return; + + bcf->args.fx = _brightness; + bcf->args.fy = _contrast; + bcf->args.min = 0; + bcf->args.max = 255; +} + + +int gfxengine_t::loadimage(int bank, const char *name) +{ + if(!csengine) + { + log_printf(ELOG, "loadimage: Engine must be open!\n"); + return -10; + } + s_blitmode = S_BLITMODE_AUTO; + log_printf(DLOG, "Loading image %s (bank %d)...\n", name, bank); + if(s_load_image(gfx, bank, name)) + { + log_printf(ELOG, " Failed to load %s!\n", name); + return -1; + } + + s_bank_t *b = s_get_bank(gfx, bank); + if(!b) + { + log_printf(ELOG, " gfxengine: Internal error 1!\n"); + return -15; + } + cs_engine_set_image_size(csengine, bank, b->w, b->h); + + log_printf(DLOG, " Ok.\n"); + return 0; +} + + +int gfxengine_t::loadtiles(int bank, int w, int h, const char *name) +{ + if(!csengine) + { + log_printf(ELOG, "loadtiles: Engine must be open!\n"); + return -10; + } + s_blitmode = S_BLITMODE_AUTO; + log_printf(DLOG, "Loading tiles %s (bank %d; %dx%d)...\n", + name, bank, w, h); + if(s_load_bank(gfx, bank, w, h, name)) + { + log_printf(ELOG, " Failed to load %s!\n", name); + return -2; + } + + cs_engine_set_image_size(csengine, bank, w, h); + + log_printf(DLOG, " Ok. (%d frames)\n", s_get_bank(gfx, bank)->max+1); + return 0; +} + + +int gfxengine_t::loadfont(int bank, const char *name) +{ + if(!csengine) + { + log_printf(ELOG, "loadfont: Engine must be open!\n"); + return -10; + } + s_blitmode = S_BLITMODE_AUTO; + scalemode(_scalemode, 2); + log_printf(DLOG, "Loading font %s (bank %d)...\n", name, bank); + if(s_load_image(gfx, bank, name)) + { + log_printf(ELOG, " Failed to load %s!\n", name); + return -2; + } + if(bank >= GFX_BANKS) + { + log_printf(ELOG, " Too high bank #!\n"); + return -3; + } + + if(!fonts[bank]) + fonts[bank] = new SoFont; + if(!fonts[bank]) + { + log_printf(ELOG, " Failed to instantiate SoFont!\n"); + return -4; + } + + fonts[bank]->ExtraSpace((xs + 127) / 256); + if(fonts[bank]->load(s_get_sprite(gfx, bank, 0)->surface)) + { + s_detach_sprite(gfx, bank, 0); + log_printf(DLOG, " Ok.\n"); + return 0; + } + else + { + log_printf(ELOG, " SoFont::load() failed!\n"); + return -5; + } + return 0; +} + + +int gfxengine_t::copyrect(int bank, int sbank, int sframe, SDL_Rect *r) +{ + SDL_Rect sr = *r; + if(!csengine) + { + log_printf(ELOG, "copyrect: Engine must be open!\n"); + return -10; + } + log_printf(DLOG, "Copying rect from %d:%d (bank %d)...\n", + sbank, sframe, bank); + int x2 = (int)((sr.x + sr.w) * xs + 128) >> 8; + int y2 = (int)((sr.y + sr.h) * ys + 128) >> 8; + sr.x = (int)(sr.x * xs + 128) >> 8; + sr.y = (int)(sr.y * ys + 128) >> 8; + sr.w = x2 - sr.x; + sr.h = y2 - sr.y; + if(s_copy_rect(gfx, bank, sbank, sframe, &sr) < 0) + { + log_printf(ELOG, " s_copy_rect() failed!\n"); + return -1; + } + log_printf(DLOG, " Ok.\n"); + return 0; +} + + +int gfxengine_t::is_loaded(int bank) +{ + if(!csengine) + return 0; + if(!s_get_bank(gfx, (unsigned)bank)) + return 0; + return 1; +} + + +void gfxengine_t::reload() +{ + log_printf(DLOG, "Reloading all banks. (Not implemented!)\n"); +// s_reload_all_banks(gfx); +} + + +void gfxengine_t::unload(int bank) +{ + if(bank < 0) + { + log_printf(DLOG, "Unloading all banks.\n"); + for(int i = 0; i < GFX_BANKS; ++i) + { + delete fonts[i]; + fonts[i] = NULL; + } + if(gfx) + s_delete_all_banks(gfx); + } + else + { + log_printf(DLOG, "Unloading bank %d.\n", bank); + if(bank < GFX_BANKS) + { + delete fonts[bank]; + fonts[bank] = NULL; + } + if(gfx) + s_delete_bank(gfx, bank); + } +} + + +/*---------------------------------------------------------- + Engine open/close +----------------------------------------------------------*/ + +void gfxengine_t::on_frame(cs_engine_t *e) +{ + gfxengine->__frame(); + gfxengine->frame(); +} + + +int gfxengine_t::open(int objects, int extraflags) +{ + xflags = extraflags; + + if(is_open) + return show(); + + log_printf(DLOG, "Opening engine...\n"); + csengine = cs_engine_create(_width, _height, objects); + if(!csengine) + { + log_printf(ELOG, "Failed to set up control system engine!\n"); + return -1; + } + + csengine->on_frame = on_frame; + cs_engine_set_wrap(csengine, wx, wy); + + gfx = s_new_container(GFX_BANKS); + if(!gfx) + { + log_printf(ELOG, "Failed to set up graphics container!\n"); + cs_engine_delete(csengine); + return -2; + } + + reset_filters(); + + is_open = 1; + return show(); +} + + +void gfxengine_t::close() +{ + if(!is_open) + return; + + log_printf(DLOG ,"Closing engine...\n"); + stop(); + hide(); + unload(); + cs_engine_delete(csengine); + csengine = NULL; + s_remove_filter(NULL); + sf1 = df = dsf = acf = NULL; + s_delete_container(gfx); + gfx = NULL; + is_open = 0; +} + + +/*---------------------------------------------------------- + Settings +----------------------------------------------------------*/ + +void gfxengine_t::title(const char *win, const char *icon) +{ + _title = win; + _icontitle = icon; + if(screen_surface) + SDL_WM_SetCaption(_title, _icontitle); +} + + +/*---------------------------------------------------------- + Display show/hide +----------------------------------------------------------*/ + +int gfxengine_t::show() +{ + int flags = 0; + + if(!is_open) + return -1; + + if(is_showing) + return 0; + + if(_centered && !_fullscreen) + SDL_putenv((char *)"SDL_VIDEO_CENTERED=1"); + + log_printf(DLOG, "Opening screen...\n"); + if(!SDL_WasInit(SDL_INIT_VIDEO)) + if(SDL_InitSubSystem(SDL_INIT_VIDEO) == -1) + { + log_printf(ELOG, "Failed to initialize SDL!\n"); + return -2; + } + + switch(_driver) + { + case GFX_DRIVER_SDL2D: + break; + case GFX_DRIVER_GLSDL: + if(!_doublebuf) + { + log_printf(WLOG, "Only double buffering is supported" + " with OpenGL drivers!\n"); + doublebuffer(1); + } + if(_shadow) + { + log_printf(WLOG, "Shadow buffer not supported" + " with OpenGL drivers!\n"); + shadow(0); + } + break; + } + + switch(_driver) + { + case GFX_DRIVER_SDL2D: + /* Nothing extra */ + break; + case GFX_DRIVER_GLSDL: + flags |= SDL_GLSDL; + break; + } + + if(_doublebuf) + flags |= SDL_DOUBLEBUF | SDL_HWSURFACE; + else + { + if(!_shadow) + flags |= SDL_HWSURFACE; + } + + if(_fullscreen) + flags |= SDL_FULLSCREEN; + + glSDL_VSync(_vsync); + flags |= xflags; + + screen_surface = SDL_SetVideoMode(_width, _height, _depth, flags); + if(!screen_surface) + { + log_printf(ELOG, "Failed to open display!\n"); + return -3; + } + + if(_driver != GFX_DRIVER_GLSDL) + { + if((screen_surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) + { + if(!_doublebuf) + { + log_printf(WLOG, "Could not get" + " single buffered display.\n"); + doublebuffer(1); + } + } + else + { + if(_doublebuf) + { + log_printf(WLOG, "Could not get" + " double buffered display.\n"); + doublebuffer(0); + } + } + } + + if((screen_surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE) + { + if(_shadow) + { + softbuf = SDL_CreateRGBSurface(SDL_SWSURFACE, + _width, _height, + screen_surface->format->BitsPerPixel, + screen_surface->format->Rmask, + screen_surface->format->Gmask, + screen_surface->format->Bmask, + screen_surface->format->Amask); + if(!softbuf) + { + log_printf(WLOG, "Failed to create shadow buffer! " + "Trying direct rendering.\n"); + shadow(0); + } + } + } + else + { + if(_shadow) + log_printf(WLOG, "Shadow buffer requested; " + "relying on SDL's shadow buffer.\n"); + else + { + log_printf(WLOG, "Could not get h/w display surface.\n"); + shadow(0); //...which means we're using SDL's shadow. + } + } + + SDL_WM_SetCaption(_title, _icontitle); + SDL_ShowCursor(_cursor); + cs_engine_set_size(csengine, _width, _height); + csengine->filter = use_interpolation; + + dither(_dither); + noalpha(alpha_threshold); + is_showing = 1; + + fullwin = new window_t; + fullwin->init(this); + fullwin->place(0, 0, (int)(_width / xscale()), + (int)(_height / yscale())); + + clear(); + + return 0; +} + + +void gfxengine_t::clear(Uint32 _color) +{ + if(!fullwin) + return; + + fullwin->background(fullwin->map_rgb(_color)); + fullwin->clear(); + flip(); + fullwin->clear(); + flip(); + fullwin->clear(); +} + + +void gfxengine_t::hide(void) +{ + if(!is_showing) + return; + + log_printf(DLOG, "Closing screen...\n"); + stop(); + delete fullwin; + fullwin = NULL; + + // Make sure no windows keep old surface pointers! + window_t *w = windows; + while(w) + { + if((w->surface == screen_surface) || + (w->surface == softbuf)) + w->surface = NULL; + w = w->next; + } + + if(softbuf) + { + SDL_FreeSurface(softbuf); + softbuf = NULL; + } + screen_surface = NULL; + + is_showing = 0; +} + + +void gfxengine_t::invalidate(SDL_Rect *rect, window_t *window) +{ + switch(_pages) + { + case -1: + if(_doublebuf) + __invalidate(1, rect, window); + __invalidate(0, rect, window); + break; + case 0: + __invalidate(0, NULL, NULL); + break; + case 3: + __invalidate(2, rect, window); + // Fallthrough! + case 2: + __invalidate(1, rect, window); + // Fallthrough! + case 1: + __invalidate(0, rect, window); + break; + } +} + + +void gfxengine_t::__invalidate(int page, SDL_Rect *rect, window_t *window) +{ + if(!screen_surface) + return; + + if(!rect || (_pages == 0)) + { + dirtyrects[page] = 1; + dirtytable[page][0].x = 0; + dirtytable[page][0].y = 0; + dirtytable[page][0].w = screen_surface->w; + dirtytable[page][0].h = screen_surface->h; + dirtywtable[page][0] = NULL; + return; + } + + /* Clip to screen (stolen from SDL_surface.c) */ + SDL_Rect dr = *rect; + int Amin, Amax, Bmin, Bmax; + + /* Horizontal intersection */ + Amin = dr.x; + Amax = Amin + dr.w; + Bmin = screen_surface->clip_rect.x; + Bmax = Bmin + screen_surface->clip_rect.w; + if(Bmin > Amin) + Amin = Bmin; + dr.x = Amin; + if(Bmax < Amax) + Amax = Bmax; + dr.w = Amax - Amin > 0 ? Amax - Amin : 0; + + /* Vertical intersection */ + Amin = dr.y; + Amax = Amin + dr.h; + Bmin = screen_surface->clip_rect.y; + Bmax = Bmin + screen_surface->clip_rect.h; + if(Bmin > Amin) + Amin = Bmin; + dr.y = Amin; + if(Bmax < Amax) + Amax = Bmax; + dr.h = Amax - Amin > 0 ? Amax - Amin : 0; + + if(!dr.w || !dr.h) + return; + + for(int i = 0; i < dirtyrects[page]; ++i) + if(memcmp(&dirtytable[page][i], &dr, sizeof(dr)) == 0) + return; + + if(dirtyrects[page] < MAX_DIRTYRECTS - 1) + { + dirtytable[page][dirtyrects[page]] = dr; + dirtywtable[page][dirtyrects[page]] = window; + ++dirtyrects[page]; + } + else + log_printf(ELOG, "gfxengine: Page %d out of dirtyrects!\n", + page); +} + + +/*---------------------------------------------------------- + Engine start/stop +----------------------------------------------------------*/ + +void gfxengine_t::start_engine() +{ + last_tick = -1000000; +} + + +void gfxengine_t::stop_engine() +{ +} + + +/*---------------------------------------------------------- + Control +----------------------------------------------------------*/ + +/* + * Run engine until stop() is called. + * + * The virtual member frame() will be called once for + * each control system frame. pre_render() and + * post_render() will be called before/after the engine + * renders each video frame. + */ +void gfxengine_t::run() +{ + open(); + show(); + start_engine(); + is_running = 1; + double toframe = 0.0f; + double fdt = 1.0f; + cs_engine_advance(csengine, 0); + while(is_running) + { + int t = (int)SDL_GetTicks(); + int dt = t - last_tick; + last_tick = t; + if(abs(dt) > 500) + last_tick = t; + if(dt > 250) + dt = (int)ticks_per_frame; + if(_timefilter) + fdt += (dt - fdt) * _timefilter; + else + fdt = ticks_per_frame; + toframe += fdt / ticks_per_frame; + cs_engine_advance(csengine, toframe); + pre_render(); + window->select(); + cs_engine_render(csengine); + post_render(); + if(_autoinvalidate) + window->invalidate(); + flip(); + } + stop_engine(); +} + + +void gfxengine_t::stop() +{ + if(!is_running) + return; + + log_printf(DLOG, "Stopping engine...\n"); + is_running = 0; +} + + +void gfxengine_t::cursor(int csr) +{ + _cursor = csr; + if(screen_surface) + SDL_ShowCursor(csr); +} + + +void gfxengine_t::interpolation(int inter) +{ + use_interpolation = inter; + if(!csengine) + return; + + csengine->filter = use_interpolation; +} + + +void gfxengine_t::timefilter(float coeff) +{ + if(coeff < 0.001f) + _timefilter = 0.0f; + else if(coeff > 1.0f) + _timefilter = 1.0f; + else + _timefilter = coeff; +} + + +void gfxengine_t::scroll_ratio(int layer, float xr, float yr) +{ + if(layer < 0) + return; + if(layer >= CS_LAYERS) + return; + + xratio[layer] = xr; + yratio[layer] = yr; +} + + +void gfxengine_t::scroll(int xscr, int yscr) +{ + xscroll = xscr; + yscroll = yscr; + + /* Apply current scroll pos to layers */ + for(int i = 0; i < CS_LAYERS ; ++i) + { + csengine->offsets[i].v.x = (int)floor(xscroll * xratio[i]); + csengine->offsets[i].v.y = (int)floor(yscroll * yratio[i]); + } +} + + +void gfxengine_t::force_scroll() +{ + if(csengine) + for(int i = 0; i < CS_LAYERS ; ++i) + cs_point_force(&csengine->offsets[i]); +} + + +int gfxengine_t::xoffs(int layer) +{ + if(layer < 0) + return 0; + if(layer >= CS_LAYERS) + return 0; + return csengine->offsets[layer].gx; +} + + +int gfxengine_t::yoffs(int layer) +{ + if(layer < 0) + return 0; + if(layer >= CS_LAYERS) + return 0; + return csengine->offsets[layer].gy; +} + + +SDL_Surface *gfxengine_t::surface() +{ + if(softbuf) + return softbuf; + else + return screen_surface; +} + + +void gfxengine_t::screenshot() +{ + char filename[1024]; + snprintf(filename, sizeof(filename), "screen%d.bmp", screenshot_count++); + SDL_SaveBMP(screen_surface, filename); +} + + +/*---------------------------------------------------------- + Internal stuff +----------------------------------------------------------*/ + +/* Default frame handler */ +void gfxengine_t::frame() +{ + SDL_Event ev; + while(SDL_PollEvent(&ev)) + { + if(ev.type == SDL_KEYDOWN) + if(ev.key.keysym.sym == SDLK_ESCAPE) + stop(); + } +} + + +/* Internal frame handler */ +void gfxengine_t::__frame() +{ +} + + +void gfxengine_t::pre_render() +{ +} + + +void gfxengine_t::post_render() +{ +} + + +void gfxengine_t::refresh_rect(SDL_Rect *r) +{ + window_t *w = windows; + for(w = windows; w; w = w->next) + { + if(!w->visible()) + continue; + + SDL_Rect dr = *r; + + /* Clip to window */ + int Amin, Amax, Bmin, Bmax; + + /* Horizontal intersection */ + Amin = dr.x; + Amax = Amin + dr.w; + Bmin = w->phys_rect.x; + Bmax = Bmin + w->phys_rect.w; + if(Bmin > Amin) + Amin = Bmin; + dr.x = Amin; + if(Bmax < Amax) + Amax = Bmax; + dr.w = Amax - Amin > 0 ? Amax - Amin : 0; + + /* Vertical intersection */ + Amin = dr.y; + Amax = Amin + dr.h; + Bmin = w->phys_rect.y; + Bmax = Bmin + w->phys_rect.h; + if(Bmin > Amin) + Amin = Bmin; + dr.y = Amin; + if(Bmax < Amax) + Amax = Bmax; + dr.h = Amax - Amin > 0 ? Amax - Amin : 0; + + if(dr.w && dr.h) + w->phys_refresh(&dr); + } +} + + +void gfxengine_t::flip() +{ + if(!screen_surface) + return; + + // Init dirtyrect table flipping, if necessary. + switch(_pages) + { + case -1: + if(!_doublebuf) + frontpage = backpage = 0; + else if(frontpage == backpage) + { + frontpage = 0; + backpage = 1; + } + break; + case 0: + frontpage = backpage = 0; + invalidate(); + break; + case 1: + frontpage = backpage = 0; + break; + case 2: + case 3: + if(frontpage == backpage) + { + frontpage = 0; + backpage = 1; + } + break; + } + + // Process the dirtyrects. + int i; + for(i = 0; i < dirtyrects[backpage]; ++i) + { + if(dirtywtable[backpage][i]) + { + if(!dirtywtable[backpage][i]->visible()) + continue; + SDL_Rect dr = dirtytable[backpage][i]; + dirtywtable[backpage][i]->phys_refresh(&dr); + } + else + refresh_rect(&dirtytable[backpage][i]); + } + + // Perform the actual flip or update + if(_shadow) + { + for(i = 0; i < dirtyrects[backpage]; ++i) + SDL_BlitSurface(softbuf, + &dirtytable[backpage][i], + screen_surface, + &dirtytable[backpage][i]); + } + if(_doublebuf) + { + dirtyrects[backpage] = 0; + if(_pages == -1) + { + backpage = !backpage; + frontpage = !frontpage; + } + else if(_pages > 1) + { + backpage = (backpage + 1) % _pages; + frontpage = (frontpage + 1) % _pages; + } + SDL_Flip(screen_surface); + } + else + { + SDL_UpdateRects(screen_surface, dirtyrects[0], dirtytable[0]); + dirtyrects[0] = 0; + } +} + + +/* + * Generic render() callback for sprites and tiles. + */ +void gfxengine_t::render_sprite(cs_obj_t *o) +{ + SDL_Rect dest_rect; + s_sprite_t *s = gfxengine->get_sprite(o->anim.bank, o->anim.frame); + if(!s || !s->surface) + return; + + int x = o->point.gx - (s->x << 8); + int y = o->point.gy - (s->y << 8); + dest_rect.x = CS2PIXEL((x * gfxengine->xs + 128) >> 8); + dest_rect.y = CS2PIXEL((y * gfxengine->ys + 128) >> 8); + dest_rect.x += (gfxengine->window->x() * gfxengine->xs + 128) >> 8; + dest_rect.y += (gfxengine->window->y() * gfxengine->xs + 128) >> 8; + SDL_BlitSurface(s->surface, NULL, gfxengine->surface(), &dest_rect); + + if(!gfxengine->_autoinvalidate) + { + dest_rect.w = s->surface->w; + dest_rect.h = s->surface->h; + gfxengine->invalidate(&dest_rect); + } +} + + +cs_obj_t *gfxengine_t::get_obj(int layer) +{ + cs_obj_t *o = cs_engine_get_obj(csengine); + if(o) + { + o->render = render_sprite; + cs_obj_layer(o, layer); + cs_obj_activate(o); + } + return o; +} + + +void gfxengine_t::free_obj(cs_obj_t *obj) +{ + cs_obj_free(obj); +} + + +int gfxengine_t::objects_in_use() +{ + if(!csengine) + return 0; + + return csengine->pool_total - csengine->pool_free; +} + + +SoFont *gfxengine_t::get_font(unsigned int f) +{ + if(f < GFX_BANKS) + return fonts[f]; + else + return NULL; +} diff --git a/graphics/gfxengine.h b/graphics/gfxengine.h new file mode 100644 index 0000000..b473247 --- /dev/null +++ b/graphics/gfxengine.h @@ -0,0 +1,282 @@ +/*(LGPL) +---------------------------------------------------------------------- + gfxengine.h - Graphics Engine +---------------------------------------------------------------------- + * Copyright (C) 2001-2003, 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _GFXENGINE_H_ +#define _GFXENGINE_H_ + +#define GFX_BANKS 256 +#define MAX_DIRTYRECTS 1024 +#define MAX_PAGES 3 + +#include +#include +#include +#include "glSDL.h" +#include "sprite.h" +#include "cs.h" + +enum gfx_drivers_t +{ + GFX_DRIVER_SDL2D = 0, + GFX_DRIVER_GLSDL = 1 +}; + +enum gfx_scalemodes_t +{ + GFX_SCALE_NEAREST = 0, + GFX_SCALE_BILINEAR = 1, + GFX_SCALE_BILIN_OVER = 2, + GFX_SCALE_SCALE2X = 3, + GFX_SCALE_DIAMOND = 4 +}; + +class window_t; +class SoFont; + +class gfxengine_t +{ + friend class window_t; + public: + gfxengine_t(); + virtual ~gfxengine_t(); + + void output(window_t *outwin); + window_t *output() { return window; } + + void screen(window_t *fullwin); + window_t *screen() { return fullwin; } + + /* + * Initialization + */ + void size(int w, int h); + void centered(int c); + void scale(float x, float y); + void driver(gfx_drivers_t drv); + void mode(int bits, int fullscreen); + + // 1: Use double buffering if possible + void doublebuffer(int use); + + // -1: Use default for shadow() and doublebuffer() settings + // 0: None; assume flipping gives you a garbage buffer + // 1: Assume flipping leaves the back buffer intact + // 2: Assume two buffers that are swapped when flipping + // 3: Assume three buffers cycled when flipping + void pages(int np); + + // 1: Enable vsync, if available + void vsync(int use); + + // 1: Use a software shadow back buffer, if possible + void shadow(int use); + + void autoinvalidate(int use); + + void interpolation(int inter); + + // 0 to reset internal timer + void period(float frameduration); + + // 0 to disable timing, running one logic frame per rendered frame. + // 1 to disable filtering, using raw delta times for timing. + void timefilter(float coeff); + + void wrap(int x, int y); + + /* Info */ + int doublebuffer() { return _doublebuf; } + int shadow() { return _shadow; } + int autoinvalidate() { return _autoinvalidate; } + + /* Engine open/close */ + int open(int objects = 1024, int extraflags = 0); + void close(); + + /* Data management (use while engine is open) */ + void reset_filters(); + void filterflags(int fgs); + void scalemode(gfx_scalemodes_t sm, int clamping = 0); + void source_scale(float x, float y); +// void colorkey(Uint8 r, Uint8 g, Uint8 b); + void clampcolor(Uint8 r, Uint8 g, Uint8 b, Uint8 a); + void dither(int type = 0, int _broken_rgba8 = 0); + void noalpha(int threshold = 128); + void brightness(float bright, float contr); + + int loadimage(int bank, const char *name); + int loadtiles(int bank, int w, int h, const char *name); + int loadfont(int bank, const char *name); + int copyrect(int bank, int sbank, int sframe, SDL_Rect *r); + + int is_loaded(int bank); + void reload(); + void unload(int bank = -1); + + /* Settings (use while engine is open) */ + void title(const char *win, const char *icon); + + /* Display show/hide */ + int show(); + void hide(); + + /* Main loop take-over */ + void run(); + + /* + * Override these; + * frame() is called once per control system frame, + * after the control system has executed. + * pre_render() is called after the engine has advanced + * to the state for the current video frame + * (interpolated state is calculated), before + * the engine renders all graphics. + * post_render() is called after the engine have + * rendered all sprites, but before video the + * sync/flip/update operation. + */ + virtual void frame(); + virtual void pre_render(); + virtual void post_render(); + + /* + --------------------------------------------- + * The members below this line can safely be + * called from within the frame() handler. + */ + + /* Rendering */ + void clear(Uint32 _color = 0x000000); + void invalidate(SDL_Rect *rect = NULL, window_t *window = NULL); + + /* Screenshots */ + void screenshot(); + + /* Control */ + cs_engine_t *cs() { return csengine; } + SDL_Surface *surface(); + void flip(); // Flip pages + void update(); // Full update, making current draw page visible + void stop(); + cs_obj_t *get_obj(int layer); + void free_obj(cs_obj_t *obj); + void cursor(int csr); + + s_sprite_t *get_sprite(unsigned bank, int _frame) + { + return s_get_sprite(gfx, bank, _frame); + } + SoFont *get_font(unsigned int f); + int set_hotspot(unsigned bank, int _frame, int x, int y) + { + return s_set_hotspot(gfx, bank, _frame, x, y); + } + + void scroll_ratio(int layer, float xr, float yr); + void scroll(int xs, int ys); + void force_scroll(); + + int xoffs(int layer); + int yoffs(int layer); + + /* Info */ + int objects_in_use(); + + int width() { return _width; } + int height() { return _height; } + float xscale() { return xs * (1.f/256.f); } + float yscale() { return ys * (1.f/256.f); } + + protected: + gfx_drivers_t _driver; + gfx_scalemodes_t _scalemode; + int _clamping; + SDL_Surface *screen_surface; + SDL_Surface *softbuf; + int backpage; + int frontpage; + int dirtyrects[MAX_PAGES]; + SDL_Rect dirtytable[MAX_PAGES][MAX_DIRTYRECTS]; + window_t *dirtywtable[MAX_PAGES][MAX_DIRTYRECTS]; + window_t *fullwin; + window_t *window; + window_t *windows; // Linked list + int wx, wy; + int xs, ys; // fix 24:8 + int sxs, sys; // fix 24:8 + s_filter_t *sf1, *sf2; // Scaling filter plugins + s_filter_t *acf; // Alpha cleaning plugin + s_filter_t *bcf; // Brightness/contrast plugin + s_filter_t *df; // Dither filter plugin + s_filter_t *dsf; // Display format plugin + int xscroll, yscroll; + float xratio[CS_LAYERS]; + float yratio[CS_LAYERS]; + s_container_t *gfx; + SoFont *fonts[GFX_BANKS]; // Kludge. + cs_engine_t *csengine; + int xflags; + int _doublebuf; + int _pages; + int _vsync; + int _shadow; + int _fullscreen; + int _centered; + int _autoinvalidate; + int use_interpolation; + int _width, _height; + int _depth; + const char *_title; + const char *_icontitle; + int _cursor; + int _dither; + int _dither_type; + int broken_rgba8; //Klugde for OpenGL (if RGBA8 ==> RGBA4) + int alpha_threshold; //For noalpha() + float _brightness; + float _contrast; + + int last_tick; + float ticks_per_frame; + float _timefilter; + + int is_showing; + int is_running; + int is_open; + + int screenshot_count; + + void __invalidate(int page, SDL_Rect *rect = NULL, + window_t *window = NULL); + void refresh_rect(SDL_Rect *r); + + static void on_frame(cs_engine_t *e); + void __frame(); + + void start_engine(); + void stop_engine(); + static void render_sprite(cs_obj_t *o); +}; + + +extern gfxengine_t *gfxengine; + +#endif diff --git a/graphics/glSDL.c b/graphics/glSDL.c new file mode 100644 index 0000000..599a1ff --- /dev/null +++ b/graphics/glSDL.c @@ -0,0 +1,2328 @@ +/*(LGPL) +------------------------------------------------------------ + glSDL 0.9 - SDL 2D API on top of OpenGL +------------------------------------------------------------ + * Copyright (C) 2001-2004, 2006-2007 David Olofson + * This code is released under the terms of the GNU LGPL. + */ + +#define _GLSDL_NO_REDEFINES_ +#include "glSDL.h" + +#ifdef HAVE_OPENGL + +#define LEAK_TRACKING + +#define DBG(x) /*error messages, warnings*/ +#define DBG2(x) /*texture allocation*/ +#define DBG3(x) /*chopping/tiling*/ +#define DBG4(x) /*texture uploading*/ +#define DBG5(x) /*two-way chopping/tiling*/ +#define DBG6(x) /*OpenGL lib loading*/ + +#undef CKSTATS /*colorkey statistics*/ + +/* Keep this on for now! Makes large surfaces faster. */ +#define FAKE_MAXTEXSIZE 256 + +#include +#include +#include + +#if HAS_SDL_OPENGL_H +#include "SDL_opengl.h" +#else +#ifdef WIN32 +#include +#endif +#if defined(__APPLE__) && defined(__MACH__) +#include +#include +#else +#include +#include +#endif +#endif + +#if defined(_WIN32) && !defined(APIENTRY) && \ + !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#include +#endif +#ifndef APIENTRY +#define APIENTRY +#endif + + +static inline void clip_rect(SDL_Rect *r, SDL_Rect *to) +{ + int dx1 = r->x; + int dy1 = r->y; + int dx2 = dx1 + r->w; + int dy2 = dy1 + r->h; + if(dx1 < to->x) + dx1 = to->x; + if(dy1 < to->y) + dy1 = to->y; + if(dx2 > to->x + to->w) + dx2 = to->x + to->w; + if(dy2 > to->y + to->h) + dy2 = to->y + to->h; + if(dx2 < dx1 || dy2 < dy1) + { + r->x = r->y = 0; + r->w = r->h = 0; + } + else + { + r->x = dx1; + r->y = dy1; + r->w = dx2 - dx1; + r->h = dy2 - dy1; + } +} + + +/*---------------------------------------------------------- + OpenGL interface +----------------------------------------------------------*/ + +static struct +{ + void (APIENTRY *Begin)(GLenum); + void (APIENTRY *BindTexture)(GLenum, GLuint); + void (APIENTRY *BlendFunc)(GLenum, GLenum); + void (APIENTRY *Color4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); + void (APIENTRY *DeleteTextures)(GLsizei n, const GLuint *textures); + void (APIENTRY *Disable)(GLenum cap); + void (APIENTRY *Enable)(GLenum cap); + void (APIENTRY *End)(void); + void (APIENTRY *Flush)(void); + void (APIENTRY *GenTextures)(GLsizei n, GLuint *textures); + GLenum (APIENTRY *GetError)(void); + void (APIENTRY *GetIntegerv)(GLenum pname, GLint *params); + void (APIENTRY *LoadIdentity)(void); + void (APIENTRY *MatrixMode)(GLenum mode); + void (APIENTRY *Ortho)(GLdouble left, GLdouble right, GLdouble bottom, + GLdouble top, GLdouble zNear, GLdouble zFar); + void (APIENTRY *PixelStorei)(GLenum pname, GLint param); + void (APIENTRY *ReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid *pixels); + void (APIENTRY *TexCoord2f)(GLfloat s, GLfloat t); + void (APIENTRY *TexImage2D)(GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels); + void (APIENTRY *TexParameteri)(GLenum target, GLenum pname, GLint param); + void (APIENTRY *TexSubImage2D)(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels); + void (APIENTRY *Translatef)(GLfloat x, GLfloat y, GLfloat z); + void (APIENTRY *Vertex2i)(GLint x, GLint y); + void (APIENTRY *Viewport)(GLint x, GLint y, GLsizei width, GLsizei height); + void (APIENTRY *Rotated)(GLdouble, GLdouble, GLdouble, GLdouble); + void (APIENTRY *Scalef)(GLfloat, GLfloat, GLfloat); + void (APIENTRY *PushMatrix)(void); + void (APIENTRY *PopMatrix)(void); +} gl; + + +static int GetGL(void) +{ + int i; + struct + { + const char *name; + void **fn; + } glfuncs[] = { + {"glBegin", (void *)&gl.Begin }, + {"glBindTexture", (void *)&gl.BindTexture }, + {"glBlendFunc", (void *)&gl.BlendFunc }, + {"glColor4ub", (void *)&gl.Color4ub }, + {"glDeleteTextures", (void *)&gl.DeleteTextures }, + {"glDisable", (void *)&gl.Disable }, + {"glEnable", (void *)&gl.Enable }, + {"glEnd", (void *)&gl.End }, + {"glFlush", (void *)&gl.Flush }, + {"glGenTextures", (void *)&gl.GenTextures }, + {"glGetError", (void *)&gl.GetError }, + {"glGetIntegerv", (void *)&gl.GetIntegerv }, + {"glLoadIdentity", (void *)&gl.LoadIdentity }, + {"glMatrixMode", (void *)&gl.MatrixMode }, + {"glOrtho", (void *)&gl.Ortho }, + {"glPixelStorei", (void *)&gl.PixelStorei }, + {"glReadPixels", (void *)&gl.ReadPixels }, + {"glTexCoord2f", (void *)&gl.TexCoord2f }, + {"glTexImage2D", (void *)&gl.TexImage2D }, + {"glTexParameteri", (void *)&gl.TexParameteri }, + {"glTexSubImage2D", (void *)&gl.TexSubImage2D }, + {"glTranslatef", (void *)&gl.Translatef }, + {"glVertex2i", (void *)&gl.Vertex2i }, + {"glViewport", (void *)&gl.Viewport }, + {"glRotated", (void *)&gl.Rotated }, + {"glScalef", (void *)&gl.Scalef }, + {"glPushMatrix", (void *)&gl.PushMatrix }, + {"glPopMatrix", (void *)&gl.PopMatrix }, + {NULL, NULL } + }; + for(i = 0; glfuncs[i].name; ++i) + { + *glfuncs[i].fn = SDL_GL_GetProcAddress(glfuncs[i].name); + if(!*glfuncs[i].fn) + { + DBG6(fprintf(stderr,"glSDL/wrapper ERROR: Could not get " + "OpenGL function '%s'!\n", + glfuncs[i].name);) + return -1; + } + DBG6(printf("Got OpenGL function '%s'.\n", glfuncs[i].name);) + } + return 0; +} + + +static int LoadGL(void) +{ + if(GetGL() < 0) + { + DBG6(printf("Couldn't get GL funcs! Trying to load lib...\n");) + SDL_GL_LoadLibrary(NULL); + if(GetGL() < 0) + { + DBG6(printf("Still couldn't get GL funcs!\n");) + return -1; + } + } + return 0; +} + + +static void UnloadGL(void) +{ +} + + +static void print_glerror(int point) +{ +#if (DBG(1)+0 == 1) + const char *err = ""; + switch(gl.GetError()) + { + case GL_NO_ERROR: + return; + case GL_INVALID_ENUM: + err = "GL_INVALID_ENUM"; + break; + case GL_INVALID_VALUE: + err = "GL_INVALID_VALUE"; + break; + case GL_INVALID_OPERATION: + err = "GL_INVALID_OPERATION"; + break; + case GL_STACK_OVERFLOW: + err = "GL_STACK_OVERFLOW"; + break; + case GL_STACK_UNDERFLOW: + err = "GL_STACK_UNDERFLOW"; + break; + case GL_OUT_OF_MEMORY: + err = "GL_OUT_OF_MEMORY"; + break; + default: + err = ""; + break; + } + fprintf(stderr,"OpenGL error \"%s\" at point %d.\n", err, point); +#endif +} + + +/*---------------------------------------------------------- + OpenGL state wrapper +----------------------------------------------------------*/ + +static struct +{ + int do_blend; + int do_texture; + GLint texture; + GLenum sfactor, dfactor; +} glstate; + +static void gl_reset(void) +{ + glstate.do_blend = -1; + glstate.do_blend = -1; + glstate.texture = -1; + glstate.sfactor = 0xffffffff; + glstate.dfactor = 0xffffffff; +} + +static __inline__ void gl_do_blend(int on) +{ + if(glstate.do_blend == on) + return; + + if(on) + gl.Enable(GL_BLEND); + else + gl.Disable(GL_BLEND); + glstate.do_blend = on; +} + +static __inline__ void gl_do_texture(int on) +{ + if(glstate.do_texture == on) + return; + + if(on) + gl.Enable(GL_TEXTURE_2D); + else + gl.Disable(GL_TEXTURE_2D); + glstate.do_texture = on; +} + +static __inline__ void gl_blendfunc(GLenum sfactor, GLenum dfactor) +{ + if((sfactor == glstate.sfactor) && (dfactor == glstate.dfactor)) + return; + + gl.BlendFunc(sfactor, dfactor); + + glstate.sfactor = sfactor; + glstate.dfactor = dfactor; +} + +static __inline__ void gl_texture(GLuint tx) +{ + if(tx == (unsigned)glstate.texture) + return; + + gl.BindTexture(GL_TEXTURE_2D, tx); + glstate.texture = tx; +} + + +/*---------------------------------------------------------- + Global stuff +----------------------------------------------------------*/ + +static int initialized = 0; + +static int using_glsdl = 0; +#define USING_GLSDL (0 != using_glsdl) + +#define MAX_TEXINFOS 16384 + +static glSDL_TexInfo **texinfotab = NULL; +static GLint maxtexsize = 256; +static SDL_PixelFormat RGBfmt, RGBAfmt; + +static void UnloadTexture(glSDL_TexInfo *txi); + +static int scale = 1; +static int vsync = 1; + +static SDL_Surface *fake_screen = NULL; + + +static int glSDL_BlitGL(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); + + +/*---------------------------------------------------------- + glSDL Global State +----------------------------------------------------------*/ + +static struct +{ + Uint8 alpha; /* Alpha */ + Uint8 r, g, b; /* Color modulation */ + float cx, cy; /* Transform center offset */ + float sx, sy; /* Scale */ + float rot; /* Rotation */ +} state; + + +void glSDL_SetBlendAlpha(Uint8 alpha) +{ + state.alpha = alpha; +} + + +void glSDL_SetBlendColor(Uint8 r, Uint8 g, Uint8 b) +{ + state.r = r; + state.g = g; + state.b = b; +} + + +void glSDL_SetCenter(float x, float y) +{ + state.cx = x; + state.cy = y; +} + + +void glSDL_SetRotation(float angle) +{ + state.rot = angle; +} + + +void glSDL_SetScale(float x, float y) +{ + state.sx = x; + state.sy = y; +} + + +void glSDL_ResetState(void) +{ + glSDL_SetBlendAlpha(255); + glSDL_SetBlendColor(255, 255, 255); + glSDL_SetCenter(0.0f, 0.0f); + glSDL_SetRotation(0.0f); + glSDL_SetScale(1.0f, 1.0f); +} + + +/*---------------------------------------------------------- + Code +----------------------------------------------------------*/ + +/* Get texinfo for a surface. */ +static __inline__ glSDL_TexInfo *glSDL_GetTexInfo(SDL_Surface *surface) +{ + if(texinfotab) + return texinfotab[surface->unused1]; + else + return NULL; +} + + +/* Allocate a "blank" texinfo for a suface. */ +glSDL_TexInfo *glSDL_AllocTexInfo(SDL_Surface *surface) +{ + int handle, i = 0; + glSDL_TexInfo *txi; + if(!surface) + return NULL; + + txi = glSDL_GetTexInfo(surface); + if(txi) + return txi; /* There already is one! --> */ + + /* Find a free handle... */ + handle = -1; + for(i = 1; i < MAX_TEXINFOS + 1; ++i) + if(NULL == texinfotab[i]) + { + handle = i; + break; + } + + if(handle < 0) + { + DBG(fprintf(stderr, "glSDL/wrapper: Out of handles!\n")); + return NULL; + } + + /* ...and hook a new texinfo struct up to it. */ + texinfotab[handle] = (glSDL_TexInfo*)calloc(1, sizeof(glSDL_TexInfo)); + if(!texinfotab[handle]) + return NULL; + + /* Connect the surface to the new TexInfo. */ + surface->unused1 = (Uint32)handle; + + DBG2(fprintf(stderr, "glSDL/wrapper: Allocated TexInfo %d.\n", handle)); + + return texinfotab[handle]; +} + + +static void FreeTexInfo(Uint32 handle) +{ + if(handle >= MAX_TEXINFOS) + return; + if(!texinfotab[handle]) + return; + + UnloadTexture(texinfotab[handle]); + texinfotab[handle]->textures = 0; + free(texinfotab[handle]->texture); + texinfotab[handle]->texture = NULL; + free(texinfotab[handle]); + texinfotab[handle] = NULL; + DBG2(fprintf(stderr, "glSDL/wrapper: Freed TexInfo %d.\n", handle)); +} + + +/* Detach and free the texinfo of a surface. */ +void glSDL_FreeTexInfo(SDL_Surface *surface) +{ + if(!texinfotab) + return; + + if(!surface) + return; + + if(!glSDL_GetTexInfo(surface)) + return; + + FreeTexInfo(surface->unused1); + GLSDL_FIX_SURFACE(surface); +} + + +/* + * Calculate chopping/tiling of a surface to + * fit it into the smallest possible OpenGL + * texture. + */ +static int CalcChop(SDL_Surface *s, glSDL_TexInfo *txi) +{ + int rows, vw, vh; + int vertical = 0; + int texsize; + int lastw, lasth, minsize; + + vw = s->w; + vh = s->h; + + DBG3(fprintf(stderr, "w=%d, h=%d ", vw, vh)); + if(vh > vw) + { + int t = vw; + vw = vh; + vh = t; + vertical = 1; + DBG3(fprintf(stderr, "(vertical) \t")); + } + + /* + * Check whether this is a "huge" surface - at least one dimension + * must be <= than the maximum texture size, or we'll have to chop + * in both directions. + */ + if(vh > maxtexsize) + { + /* + * Very simple hack for now; we just tile + * both ways with maximum size textures. + */ + texsize = maxtexsize; + + txi->tilemode = GLSDL_TM_HUGE; + txi->texsize = texsize; + txi->tilew = texsize; + txi->tileh = texsize; + txi->tilespertex = 1; + + /* Calculate number of textures needed */ + txi->textures = (vw + texsize - 1) / texsize; + txi->textures *= (vh + texsize - 1) / texsize; + txi->texture = (int*)malloc(txi->textures * sizeof(int)); + memset(txi->texture, -1, txi->textures * sizeof(int)); + DBG5(fprintf(stderr, "two-way tiling; textures=%d\n", txi->textures)); + if(!txi->texture) + { + fprintf(stderr, "glSDL/wrapper: INTERNAL ERROR: Failed to allocate" + " texture name table!\n"); + return -3; + } + return 0; + } + + /* Calculate minimum size */ + rows = 1; + lastw = vw; + lasth = vh; + minsize = lastw > lasth ? lastw : lasth; + while(1) + { + int w, h, size; + ++rows; + w = vw / rows; + h = rows * vh; + size = w > h ? w : h; + if(size >= minsize) + { + --rows; + break; + } + lastw = w; + lasth = h; + minsize = size; + } + if(minsize > maxtexsize) + { + /* Handle multiple textures for very wide/tall surfaces. */ + minsize = maxtexsize; + rows = (vw + minsize-1) / minsize; + } + DBG3(fprintf(stderr, "==> minsize=%d ", minsize)); + DBG3(fprintf(stderr, "(rows=%d) \t", rows)); + + /* Recalculate with nearest higher power-of-2 width. */ + for(texsize = 1; texsize < minsize; texsize <<= 1) + ; + txi->texsize = texsize; + rows = (vw + texsize-1) / texsize; + DBG3(fprintf(stderr, "==> texsize=%d (rows=%d) \t", texsize, rows)); + + /* Calculate number of tiles per texture */ + txi->tilespertex = txi->texsize / vh; + DBG3(fprintf(stderr, "tilespertex=%d \t", txi->tilespertex)); + + /* Calculate number of textures needed */ + txi->textures = (rows + txi->tilespertex-1) / txi->tilespertex; + txi->texture = (int*)malloc(txi->textures * sizeof(int)); + memset(txi->texture, -1, txi->textures * sizeof(int)); + DBG3(fprintf(stderr, "textures=%d, ", txi->textures)); + if(!txi->texture) + { + fprintf(stderr, "glSDL/wrapper: INTERNAL ERROR: Failed to allocate" + " texture name table!\n"); + return -2; + } + + /* Set up tile size. (Only one axis supported here!) */ + if(1 == rows) + { + txi->tilemode = GLSDL_TM_SINGLE; + if(vertical) + { + txi->tilew = vh; + txi->tileh = vw; + } + else + { + txi->tilew = vw; + txi->tileh = vh; + } + } + else if(vertical) + { + txi->tilemode = GLSDL_TM_VERTICAL; + txi->tilew = vh; + txi->tileh = texsize; + } + else + { + txi->tilemode = GLSDL_TM_HORIZONTAL; + txi->tilew = texsize; + txi->tileh = vh; + } + + DBG3(fprintf(stderr, "tilew=%d, tileh=%d\n", txi->tilew, txi->tileh)); + return 0; +} + + +/* Add a glSDL_TexInfo struct to an SDL_Surface */ +static int glSDL_AddTexInfo(SDL_Surface *surface) +{ + glSDL_TexInfo *txi; + + if(!surface) + return -1; + if(IS_GLSDL_SURFACE(surface)) + return 0; /* Do nothing */ + + glSDL_AllocTexInfo(surface); + txi = glSDL_GetTexInfo(surface); + if(!txi) + return -2; /* Oops! Didn't get a texinfo... --> */ + + if(CalcChop(surface, txi) < 0) + return -3; + + SDL_SetClipRect(surface, NULL); + + return 0; +} + + +/* Create a surface of the prefered OpenGL RGB texture format */ +static SDL_Surface *CreateRGBSurface(int w, int h) +{ + SDL_Surface *s; + Uint32 rmask, gmask, bmask; + int bits = 24; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + rmask = 0x00ff0000; + gmask = 0x0000ff00; + bmask = 0x000000ff; +#else + rmask = 0x000000ff; + gmask = 0x0000ff00; + bmask = 0x00ff0000; +#endif + s = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, + bits, rmask, gmask, bmask, 0); + if(s) + GLSDL_FIX_SURFACE(s); + + glSDL_AddTexInfo(s); + return s; +} + + +/* Create a surface of the prefered OpenGL RGBA texture format */ +static SDL_Surface *CreateRGBASurface(int w, int h) +{ + SDL_Surface *s; + Uint32 rmask, gmask, bmask, amask; + int bits = 32; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + rmask = 0xff000000; + gmask = 0x00ff0000; + bmask = 0x0000ff00; + amask = 0x000000ff; +#else + rmask = 0x000000ff; + gmask = 0x0000ff00; + bmask = 0x00ff0000; + amask = 0xff000000; +#endif + s = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, + bits, rmask, gmask, bmask, amask); + if(s) + GLSDL_FIX_SURFACE(s); + + glSDL_AddTexInfo(s); + return s; +} + + +static void init_formats(void) +{ + SDL_Surface *s = CreateRGBSurface(1, 1); + if(!s) + return; + RGBfmt = *(s->format); + glSDL_FreeSurface(s); + + s = CreateRGBASurface(1, 1); + if(!s) + return; + RGBAfmt = *(s->format); + glSDL_FreeSurface(s); +} + + +static int FormatIsOk(SDL_Surface *surface) +{ + SDL_PixelFormat *pf; + if(!surface) + return 1; /* Well, there ain't much we can do anyway... */ + + pf = surface->format; + + /* Colorkeying always requires conversion! */ + if(surface->flags & SDL_SRCCOLORKEY) + return 0; + + /* We need pitch == (width * BytesPerPixel) for glTex[Sub]Image2D() */ + if(surface->pitch != (surface->w * pf->BytesPerPixel)) + return 0; + + if(pf->Amask) + { + if(pf->BytesPerPixel != RGBAfmt.BytesPerPixel) + return 0; + if(pf->Rmask != RGBAfmt.Rmask) + return 0; + if(pf->Gmask != RGBAfmt.Gmask) + return 0; + if(pf->Bmask != RGBAfmt.Bmask) + return 0; + if(pf->Amask != RGBAfmt.Amask) + return 0; + } + else + { + if(pf->BytesPerPixel != RGBfmt.BytesPerPixel) + return 0; + if(pf->Rmask != RGBfmt.Rmask) + return 0; + if(pf->Gmask != RGBfmt.Gmask) + return 0; + if(pf->Bmask != RGBfmt.Bmask) + return 0; + } + return 1; +} + + + +static void key2alpha(SDL_Surface *surface) +{ + int x, y; +#ifdef CKSTATS + int transp = 0; +#endif + Uint32 rgbmask = surface->format->Rmask | + surface->format->Gmask | + surface->format->Bmask; + Uint32 ckey = surface->format->colorkey & rgbmask; + if(SDL_LockSurface(surface) < 0) + return; + + for(y = 0; y < surface->h; ++y) + { + Uint32 *px = (Uint32 *)((char *)surface->pixels + y*surface->pitch); + for(x = 0; x < surface->w; ++x) + if((px[x] & rgbmask) == ckey) + { + px[x] = 0; +#ifdef CKSTATS + ++transp; +#endif + } + } +#ifdef CKSTATS + printf("glSDL/wrapper: key2alpha(); %dx%d surface, %d opaque pixels.\n", + surface->w, surface->h, + surface->w * surface->h - transp); +#endif + SDL_UnlockSurface(surface); +} + + + +/*---------------------------------------------------------- + SDL style API +----------------------------------------------------------*/ + +static void KillAllTextures(void) +{ + if(texinfotab) + { + unsigned i; +#ifdef LEAK_TRACKING + int leaked = 0; + for(i = 3; i < MAX_TEXINFOS + 1; ++i) + if(texinfotab[i]) + { + ++leaked; + fprintf(stderr, "glSDL/wrapper: Leaked TexInfo" + " %d! (%d %dx%d textures)\n", + i, + texinfotab[i]->textures, + texinfotab[i]->texsize, + texinfotab[i]->texsize + ); + } + if(leaked) + fprintf(stderr, "glSDL/wrapper: Leaked %d TexInfos!\n", leaked); +#endif + for(i = 1; i < MAX_TEXINFOS + 1; ++i) + FreeTexInfo(i); + free(texinfotab); + texinfotab = NULL; + } +} + +void glSDL_Quit(void) +{ + if(SDL_WasInit(SDL_INIT_VIDEO)) + { + glSDL_FreeTexInfo(SDL_GetVideoSurface()); + if(fake_screen) + { + glSDL_FreeTexInfo(fake_screen); + SDL_FreeSurface(fake_screen); + fake_screen = NULL; + } + UnloadGL(); + SDL_QuitSubSystem(SDL_INIT_VIDEO); + } +#ifndef LEAK_TRACKING + KillAllTextures(); +#endif +} + + +void glSDL_FullQuit(void) +{ +#ifdef LEAK_TRACKING + KillAllTextures(); +#endif + glSDL_Quit(); + SDL_Quit(); +} + + +void glSDL_QuitSubSystem(Uint32 flags) +{ + if(flags & SDL_INIT_VIDEO) + glSDL_Quit(); + SDL_QuitSubSystem(flags); +} + + +SDL_Surface *glSDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) +{ + SDL_Surface *screen; + GLint gl_doublebuf; + + if(!initialized) + { + glSDL_ResetState(); + initialized = 1; + } + + if(USING_GLSDL) + { + glSDL_FreeTexInfo(SDL_GetVideoSurface()); + if(fake_screen) + { + glSDL_FreeTexInfo(fake_screen); + SDL_FreeSurface(fake_screen); + fake_screen = NULL; + } + UnloadGL(); + using_glsdl = 0; + } + + if(!(flags & SDL_GLSDL)) + { + screen = SDL_SetVideoMode(width, height, bpp, flags); + if(screen) + GLSDL_FIX_SURFACE(screen); + return screen; + } + + if((SDL_Linked_Version()->major <= 1) && + (SDL_Linked_Version()->minor <= 2) && + (SDL_Linked_Version()->patch < 5)) + fprintf(stderr, "glSDL/wrapper WARNING: Using SDL version" + " 1.2.5 or later is strongly" + " recommended!\n"); + + if(LoadGL() < 0) + { + fprintf(stderr, "glSDL/wrapper ERROR: Could not load OpenGL library!\n"); + return NULL; + } + +/* + * FIXME: Here's the place to insert proper handling of this call being + * used for resizing the window... For now, just make sure we + * don't end up with invalid texinfos and stuff no matter what. + */ + KillAllTextures(); + + texinfotab = (glSDL_TexInfo**)calloc(MAX_TEXINFOS + 1, sizeof(glSDL_TexInfo *)); + if(!texinfotab) + return NULL; + + /* Remove flag to avoid confusion inside SDL - just in case! */ + flags &= ~SDL_GLSDL; + + flags |= SDL_OPENGL; + if(bpp == 15) + { + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); + } + else if(bpp == 16) + { + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); + } + else if(bpp >= 24) + { + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + } + gl_doublebuf = (flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF; + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, gl_doublebuf); + SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, vsync); + scale = 1; + + screen = SDL_SetVideoMode(width*scale, height*scale, bpp, flags); + if(!screen) + { + KillAllTextures(); + return NULL; + } + + GLSDL_FIX_SURFACE(screen); + +#ifdef FAKE_MAXTEXSIZE + maxtexsize = FAKE_MAXTEXSIZE; +#else + gl.GetIntegerv(GL_MAX_TEXTURE_SIZE, &maxtexsize); +#endif + DBG(fprintf(stderr, "glSDL/wrapper: Max texture size: %d\n", maxtexsize)); + + init_formats(); + gl_reset(); + + if(glSDL_AddTexInfo(screen) < 0) + { + DBG(fprintf(stderr, "glSDL/wrapper: Failed to add info to screen surface!\n")); + SDL_QuitSubSystem(SDL_INIT_VIDEO); + return NULL; + } + + glSDL_SetClipRect(screen, &screen->clip_rect); + + gl.Viewport(0, 0, screen->w * scale, screen->h * scale); + /* + * Note that this projection is upside down in + * relation to the OpenGL coordinate system. + */ + gl.MatrixMode(GL_PROJECTION); + gl.LoadIdentity(); + gl.Ortho(0, scale * (float)screen->w, scale * (float)screen->h, 0, + -1.0, 1.0); + + gl.MatrixMode(GL_MODELVIEW); + gl.LoadIdentity(); + gl.Translatef(0.0f, 0.0f, 0.0f); + + gl.Disable(GL_DEPTH_TEST); + gl.Disable(GL_CULL_FACE); + + /* + * Create a software shadow buffer of the requested size. + * This is used for blit-from-screen and simulation of + * direct software rendering. (Dog slow crap. It's only + * legitimate use is probably screen shots.) + */ + fake_screen = CreateRGBSurface(screen->w / scale, + screen->h / scale); + using_glsdl = 1; + return fake_screen; +} + + +SDL_Surface *glSDL_GetVideoSurface(void) +{ + if(fake_screen) + return fake_screen; + else + return SDL_GetVideoSurface(); +} + + +void glSDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) +{ + if(IS_GLSDL_SURFACE(screen)) + glSDL_Flip(screen); + else + SDL_UpdateRects(screen, numrects, rects); +} + + +void glSDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) +{ + SDL_Rect r; + r.x = x; + r.y = y; + r.w = w; + r.h = h; + glSDL_UpdateRects(screen, 1, &r); +} + + +int glSDL_Flip(SDL_Surface *screen) +{ + if(!IS_GLSDL_SURFACE(screen)) + return SDL_Flip(screen); + + SDL_GL_SwapBuffers(); + return 0; +} + + +void glSDL_FreeSurface(SDL_Surface *surface) +{ + if(!surface) + return; + glSDL_FreeTexInfo(surface); + SDL_FreeSurface(surface); +} + + +int glSDL_LockSurface(SDL_Surface *surface) +{ + if(!surface) + return 0; + + if(IS_GLSDL_SURFACE(surface)) + { + if((surface == fake_screen) || + (SDL_GetVideoSurface() == surface)) + { + if(scale > 1) + return -1; + + glSDL_Invalidate(fake_screen, NULL); + + gl.PixelStorei(GL_UNPACK_ROW_LENGTH, + fake_screen->pitch / + fake_screen->format->BytesPerPixel); + + gl.ReadPixels(0, 0, fake_screen->w, fake_screen->h, + GL_RGB, GL_UNSIGNED_BYTE, + fake_screen->pixels); + return 0; + } + else + { + glSDL_Invalidate(surface, NULL); + return SDL_LockSurface(surface); + } + } + else + return SDL_LockSurface(surface); +} + + +void glSDL_UnlockSurface(SDL_Surface *surface) +{ + if(!surface) + return; + + if(IS_GLSDL_SURFACE(surface)) + { + glSDL_UploadSurface(surface); + if((surface == fake_screen) || + (SDL_GetVideoSurface() == surface)) + glSDL_BlitGL(fake_screen, NULL, + SDL_GetVideoSurface(), NULL); + } + else + SDL_UnlockSurface(surface); +} + + +int glSDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key) +{ + int res = SDL_SetColorKey(surface, flag, key); + if(res < 0) + return res; + /* + * If an application does this *after* SDL_DisplayFormat, + * we're basically screwed, unless we want to do an + * in-place surface conversion hack here. + * + * What we do is just kill the glSDL texinfo... No big + * deal in most cases, as glSDL only converts once anyway, + * *unless* you keep modifying the surface. + */ + if(IS_GLSDL_SURFACE(surface)) + glSDL_FreeTexInfo(surface); + return res; +} + + +int glSDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha) +{ + /* + * This is just parameters to OpenGL, so the actual + * "work" is done in glSDL_BlitSurface(). + */ + return SDL_SetAlpha(surface, flag, alpha); +} + + +SDL_bool glSDL_SetClipRect(SDL_Surface *surface, SDL_Rect *rect) +{ + SDL_bool res; + SDL_Surface *screen; + SDL_Rect fsr; + if(!surface) + return SDL_FALSE; + + screen = SDL_GetVideoSurface(); + + res = SDL_SetClipRect(surface, rect); + if(!res) + return SDL_FALSE; + + if(!rect) + { + fsr.x = 0; + fsr.y = 0; + fsr.w = screen->w; + fsr.h = screen->h; + rect = &fsr; + } + if(surface == fake_screen) + { + SDL_Rect r; + r.x = rect->x; + r.y = rect->y; + r.w = rect->w; + r.h = rect->h; + surface = screen; + SDL_SetClipRect(surface, rect); + return SDL_TRUE; + } + return res; +} + + +static int glSDL_BlitFromGL(SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect) +{ + int i, sy0, dy0; + SDL_Rect sr, dr; + + if(scale > 1) + return -1; + + /* In case the destination has an OpenGL texture... */ + glSDL_Invalidate(dst, dstrect); + + /* Abuse the fake screen buffer a little. */ + gl.PixelStorei(GL_UNPACK_ROW_LENGTH, fake_screen->pitch / + fake_screen->format->BytesPerPixel); + if(srcrect) + { + sr = *srcrect; + dr.x = dr.y = 0; + dr.w = fake_screen->w; + dr.h = fake_screen->h; + clip_rect(&sr, &dr); + gl.ReadPixels(sr.x, sr.y, sr.w, sr.h, GL_RGB, GL_UNSIGNED_BYTE, + fake_screen->pixels); + } + else + { + sr.x = sr.y = 0; + sr.w = dst->w; + srcrect = &sr; + gl.ReadPixels(0, 0, fake_screen->w, fake_screen->h, + GL_RGB, GL_UNSIGNED_BYTE, fake_screen->pixels); + } + + /* Blit to the actual target! (Vert. flip... Uuurgh!) */ + if(dstrect) + dr = *dstrect; + else + { + dr.x = dr.y = 0; + dstrect = &dr; + } + + i = srcrect->h; + sy0 = srcrect->y; + dy0 = dstrect->y + dstrect->h - 1; + while(i--) + { + sr.y = sy0 + i; + dr.y = dy0 - i; + sr.h = 1; + if(SDL_BlitSurface(fake_screen, &sr, dst, &dr) < 0) + return -1; + } + return 0; +} + + +static __inline__ void BlitGL_single(glSDL_TexInfo *txi, + float sx1, float sy1, SDL_Rect *dst, unsigned char alpha) +{ + float sx2, sy2, texscale; + if(!txi->textures) + return; + if(-1 == txi->texture[0]) + return; + gl_texture(txi->texture[0]); + + texscale = 1.0 / (float)txi->texsize; + sx2 = (sx1 + (float)dst->w) * texscale; + sy2 = (sy1 + (float)dst->h) * texscale; + sx1 *= texscale; + sy1 *= texscale; + + gl.Begin(GL_QUADS); + gl.Color4ub(state.r, state.g, state.b, alpha); + gl.TexCoord2f(sx1, sy1); + gl.Vertex2i(dst->x, dst->y); + gl.TexCoord2f(sx2, sy1); + gl.Vertex2i(dst->x + dst->w, dst->y); + gl.TexCoord2f(sx2, sy2); + gl.Vertex2i(dst->x + dst->w, dst->y + dst->h); + gl.TexCoord2f(sx1, sy2); + gl.Vertex2i(dst->x, dst->y + dst->h); + gl.End(); +} + + +static void BlitGL_htile(glSDL_TexInfo *txi, + float sx1, float sy1, SDL_Rect *dst, unsigned char alpha) +{ + int tex; + float tile, sx2, sy2, yo; + float texscale = 1.0 / (float)txi->texsize; + float tileh = (float)txi->tileh * texscale; + sx2 = (sx1 + (float)dst->w) * texscale; + sy2 = (sy1 + (float)dst->h) * texscale; + sx1 *= texscale; + sy1 *= texscale; + tile = floor(sx1); + tex = (int)tile / txi->tilespertex; + yo = ((int)tile % txi->tilespertex) * tileh; + + if(tex >= txi->textures) + return; + if(-1 == txi->texture[tex]) + return; + gl_texture(txi->texture[tex]); + + gl.Begin(GL_QUADS); + while(tile < sx2) + { + int tdx1 = dst->x; + int tdx2 = dst->x + dst->w; + float tsx1 = sx1 - tile; + float tsx2 = sx2 - tile; + + /* Clip to current tile */ + if(tsx1 < 0.0) + { + tdx1 -= (int)(tsx1 * txi->texsize); + tsx1 = 0.0; + } + if(tsx2 > 1.0) + { + tdx2 -= (int)((tsx2 - 1.0) * txi->texsize); + tsx2 = 1.0; + } + + /* Maybe select next texture? */ + if(yo + tileh > 1.0) + { + ++tex; + gl.End(); + if(tex >= txi->textures) + return; + if(-1 == txi->texture[tex]) + return; + gl_texture(txi->texture[tex]); + yo = 0.0; + gl.Begin(GL_QUADS); + } + + gl.Color4ub(state.r, state.g, state.b, alpha); + gl.TexCoord2f(tsx1, yo + sy1); + gl.Vertex2i(tdx1, dst->y); + gl.TexCoord2f(tsx2, yo + sy1); + gl.Vertex2i(tdx2, dst->y); + gl.TexCoord2f(tsx2, yo + sy2); + gl.Vertex2i(tdx2, dst->y + dst->h); + gl.TexCoord2f(tsx1, yo + sy2); + gl.Vertex2i(tdx1, dst->y + dst->h); + + tile += 1.0; + yo += tileh; + } + gl.End(); +} + + +static void BlitGL_vtile(glSDL_TexInfo *txi, + float sx1, float sy1, SDL_Rect *dst, unsigned char alpha) +{ + int tex; + float tile, sx2, sy2, xo; + float texscale = 1.0 / (float)txi->texsize; + float tilew = (float)txi->tilew * texscale; + sx2 = (sx1 + (float)dst->w) * texscale; + sy2 = (sy1 + (float)dst->h) * texscale; + sx1 *= texscale; + sy1 *= texscale; + tile = floor(sy1); + tex = (int)tile / txi->tilespertex; + xo = ((int)tile % txi->tilespertex) * tilew; + + if(tex >= txi->textures) + return; + if(-1 == txi->texture[tex]) + return; + gl_texture(txi->texture[tex]); + + gl.Begin(GL_QUADS); + while(tile < sy2) + { + int tdy1 = dst->y; + int tdy2 = dst->y + dst->h; + float tsy1 = sy1 - tile; + float tsy2 = sy2 - tile; + + /* Clip to current tile */ + if(tsy1 < 0.0) + { + tdy1 -= (int)(tsy1 * txi->texsize); + tsy1 = 0.0; + } + if(tsy2 > 1.0) + { + tdy2 -= (int)((tsy2 - 1.0) * txi->texsize); + tsy2 = 1.0; + } + + /* Maybe select next texture? */ + if(xo + tilew > 1.0) + { + ++tex; + gl.End(); + if(tex >= txi->textures) + return; + if(-1 == txi->texture[tex]) + return; + gl_texture(txi->texture[tex]); + xo = 0.0; + gl.Begin(GL_QUADS); + } + + gl.Color4ub(state.r, state.g, state.b, alpha); + gl.TexCoord2f(xo + sx1, tsy1); + gl.Vertex2i(dst->x, tdy1); + gl.TexCoord2f(xo + sx2, tsy1); + gl.Vertex2i(dst->x + dst->w, tdy1); + gl.TexCoord2f(xo + sx2, tsy2); + gl.Vertex2i(dst->x + dst->w, tdy2); + gl.TexCoord2f(xo + sx1, tsy2); + gl.Vertex2i(dst->x, tdy2); + + tile += 1.0; + xo += tilew; + } + gl.End(); +} + + +static void BlitGL_hvtile(SDL_Surface *src, glSDL_TexInfo *txi, + float sx1, float sy1, SDL_Rect *dst, unsigned char alpha) +{ + int x, y, last_tex, tex; + float sx2, sy2; + float texscale = 1.0 / (float)txi->texsize; + int tilesperrow = (src->w + txi->tilew - 1) / txi->tilew; + sx2 = (sx1 + (float)dst->w) * texscale; + sy2 = (sy1 + (float)dst->h) * texscale; + sx1 *= texscale; + sy1 *= texscale; + + last_tex = tex = (int)(floor(sy1) * tilesperrow + floor(sx1)); + if(tex >= txi->textures) + return; + if(-1 == txi->texture[tex]) + return; + gl_texture(txi->texture[tex]); + + gl.Begin(GL_QUADS); + for(y = (int)floor(sy1); y < sy2; ++y) + { + int tdy1 = dst->y; + int tdy2 = dst->y + dst->h; + float tsy1 = sy1 - y; + float tsy2 = sy2 - y; + + /* Clip to current tile */ + if(tsy1 < 0.0) + { + tdy1 -= (int)(tsy1 * txi->texsize); + tsy1 = 0.0; + } + if(tsy2 > 1.0) + { + tdy2 -= (int)((tsy2 - 1.0) * txi->texsize); + tsy2 = 1.0; + } + for(x = (int)floor(sx1); x < sx2; ++x) + { + int tdx1 = dst->x; + int tdx2 = dst->x + dst->w; + float tsx1 = sx1 - x; + float tsx2 = sx2 - x; + + /* Clip to current tile */ + if(tsx1 < 0.0) + { + tdx1 -= (int)(tsx1 * txi->texsize); + tsx1 = 0.0; + } + if(tsx2 > 1.0) + { + tdx2 -= (int)((tsx2 - 1.0) * txi->texsize); + tsx2 = 1.0; + } + + /* Select texture */ + tex = y * tilesperrow + x; + if(tex != last_tex) + { + gl.End(); + if(tex >= txi->textures) + return; + if(-1 == txi->texture[tex]) + return; + gl_texture(txi->texture[tex]); + last_tex = tex; + gl.Begin(GL_QUADS); + } + + gl.Color4ub(state.r, state.g, state.b, alpha); + gl.TexCoord2f(tsx1, tsy1); + gl.Vertex2i(tdx1, tdy1); + gl.TexCoord2f(tsx2, tsy1); + gl.Vertex2i(tdx2, tdy1); + gl.TexCoord2f(tsx2, tsy2); + gl.Vertex2i(tdx2, tdy2); + gl.TexCoord2f(tsx1, tsy2); + gl.Vertex2i(tdx1, tdy2); + } + } + gl.End(); +} + + +/* + * Calculate the actual blit rectangle and source offset + * for a blit from a rectangle in a surface with specified + * size to a surface with a cliprect. + * + * In: rect source rectangle + * w, h source surface size + * (x, y) destination coordinate + * clip destination clip rectangle + * + * Out: (x, y) source top-left offset + * rect destination rectangle + * + * Returns 1 if the result is visible, otherwise 0. + */ +static __inline__ int blitclip(SDL_Rect *rect, int w, int h, + int *x, int *y, SDL_Rect *clip) +{ + int sx1, sy1, sx2, sy2; + int dx1, dy1, dx2, dy2; + + /* Get source and destination coordinates */ + sx1 = rect->x; + sy1 = rect->y; + sx2 = sx1 + rect->w; + sy2 = sy1 + rect->h; + dx1 = *x; + dy1 = *y; + + /* Keep source rect inside source surface */ + if(sx1 < 0) + { + dx1 -= sx1; + sx1 = 0; + } + if(sy1 < 0) + { + dy1 -= sy1; + sy1 = 0; + } + if(sx2 > w) + sx2 = w; + if(sy2 > h) + sy2 = h; + + /* Cull blits from void space */ + if(sx1 >= sx2 || sy1 >= sy2) + return 0; + + /* Calculate destination lower-right */ + dx2 = dx1 + (sx2 - sx1); + dy2 = dy1 + (sy2 - sy1); + + if(clip) + { + /* Clip to destination cliprect */ + if(dx1 < clip->x) + { + sx1 += clip->x - dx1; + dx1 = clip->x; + } + if(dy1 < clip->y) + { + sy1 += clip->y - dy1; + dy1 = clip->y; + } + if(dx2 > clip->x + clip->w) + dx2 = clip->x + clip->w; + if(dy2 > clip->y + clip->h) + dy2 = clip->y + clip->h; + } + + /* Cull nop/off-screen blits */ + if(dx1 >= dx2 || dy1 >= dy2) + return 0; + + *x = sx1; + *y = sy1; + rect->x = dx1; + rect->y = dy1; + rect->w = dx2 - dx1; + rect->h = dy2 - dy1; + return 1; +} + + +static int glSDL_BlitGL(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect) +{ + glSDL_TexInfo *txi; + SDL_Rect r; + int x, y; + unsigned char alpha; + int plain = (state.rot == 0.0f) && + (state.sx == 1.0f) && + (state.sy == 1.0f); + if(!src || !dst) + return -1; + + /* Get source and destination coordinates */ + if(srcrect) + r = *srcrect; + else + { + r.x = r.y = 0; + r.w = src->w; + r.h = src->h; + } + if(dstrect) + { + x = dstrect->x; + y = dstrect->y; + } + else + x = y = 0; + + /* Clip! */ + if(!blitclip(&r, src->w, src->h, &x, &y, + plain ? &dst->clip_rect : NULL)) + { + if(dstrect) + dstrect->w = dstrect->h = 0; + return 0; + } + + /* Write back the resulting cliprect */ + if(dstrect) + *dstrect = r; + + /* Make sure we have a source with a valid texture */ + glSDL_UploadSurface(src); + txi = glSDL_GetTexInfo(src); + if(!txi) + return -1; + + /* Set up blending */ + if(src->flags & (SDL_SRCALPHA | SDL_SRCCOLORKEY) || + (state.alpha != 255)) + { + gl_blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_do_blend(1); + } + else + gl_do_blend(0); + + /* Enable texturing */ + gl_do_texture(1); + + /* + * Note that we actually *prevent* the use of "full surface alpha" + * and alpha channel in combination - to stay SDL 2D compatible. + */ + if((src->flags & SDL_SRCALPHA) && + (!src->format->Amask || (src->flags & SDL_SRCCOLORKEY))) + alpha = src->format->alpha; + else + alpha = 255; + + /* ...however, the GL only global state alpha is always applied! */ + alpha = (Uint32)alpha * state.alpha * 258 >> 16; + + /* Render! */ + if(!plain) + { + int rcx = (r.w >> 1) + state.cx; + int rcy = (r.h >> 1) + state.cy; + gl.PushMatrix(); + gl.Translatef(r.x + rcx, r.y + rcy, 0.0f); + if(state.rot) + gl.Rotated(state.rot, 0.0f, 0.0f, 1.0f); + if(state.sx || state.sy) + gl.Scalef(state.sx, state.sy, 1.0f); + r.x = -rcx; + r.y = -rcy; + } + switch(txi->tilemode) + { + case GLSDL_TM_SINGLE: + BlitGL_single(txi, x, y, &r, alpha); + break; + case GLSDL_TM_HORIZONTAL: + BlitGL_htile(txi, x, y, &r, alpha); + break; + case GLSDL_TM_VERTICAL: + BlitGL_vtile(txi, x, y, &r, alpha); + break; + case GLSDL_TM_HUGE: + BlitGL_hvtile(src, txi, x, y, &r, alpha); + break; + } + if(!plain) + gl.PopMatrix(); + return 0; +} + + +int glSDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect) +{ + SDL_Surface *vs; + if(!src || !dst) + return -1; + + /* + * Figure out what to do: + * Not using glSDL: SDL_BlitSurface() + * screen->screen: _glSDL_BlitFromGL() + _glSDL_BlitGL() + * surface->screen: _glSDL_BlitGL() + * screen->surface: _glSDL_BlitFromGL() + * surface->surface: SDL_BlitSurface() + */ + if(!USING_GLSDL) + return SDL_BlitSurface(src, srcrect, dst, dstrect); + + vs = SDL_GetVideoSurface(); + if(src == fake_screen) + src = vs; + if(dst == fake_screen) + dst = vs; + if(src == vs) + { + if(dst == vs) + { + glSDL_BlitFromGL(srcrect, fake_screen, dstrect); + return glSDL_BlitGL(fake_screen, srcrect, + dst, dstrect); + } + else + { + return glSDL_BlitFromGL(srcrect, dst, dstrect); + } + } + else + { + if(dst == vs) + { + return glSDL_BlitGL(src, srcrect, + dst, dstrect); + } + else + { + glSDL_Invalidate(dst, dstrect); + return SDL_BlitSurface(src, srcrect, dst, dstrect); + } + } +} + + +int glSDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) +{ + SDL_Surface *vs = SDL_GetVideoSurface(); + SDL_PixelFormat *pf = dst->format; + int dx1, dy1, dx2, dy2; + Uint32 r, g, b; + + if(dst == fake_screen) + dst = vs; + if(vs != dst) + glSDL_Invalidate(dst, dstrect); + if((vs != dst) || !USING_GLSDL) + return SDL_FillRect(dst, dstrect, color); + + if(dstrect) + { + dx1 = dstrect->x; + dy1 = dstrect->y; + dx2 = dx1 + dstrect->w; + dy2 = dy1 + dstrect->h; + if(dx1 < dst->clip_rect.x) + dx1 = dst->clip_rect.x; + if(dy1 < dst->clip_rect.y) + dy1 = dst->clip_rect.y; + if(dx2 > dst->clip_rect.x + dst->clip_rect.w) + dx2 = dst->clip_rect.x + dst->clip_rect.w; + if(dy2 > dst->clip_rect.y + dst->clip_rect.h) + dy2 = dst->clip_rect.y + dst->clip_rect.h; + dstrect->x = dx1; + dstrect->y = dy1; + dstrect->w = dx2 - dx1; + dstrect->h = dy2 - dy1; + if(!dstrect->w || !dstrect->h) + return 0; + } + else + { + dx1 = dst->clip_rect.x; + dy1 = dst->clip_rect.y; + dx2 = dx1 + dst->clip_rect.w; + dy2 = dy1 + dst->clip_rect.h; + } + + r = color & pf->Rmask; + r = r >> pf->Rshift; + r = r << pf->Rloss; + g = color & pf->Gmask; + g = g >> pf->Gshift; + g = g << pf->Gloss; + b = color & pf->Bmask; + b = b >> pf->Bshift; + b = b << pf->Bloss; + + r = r * state.r * 258 >> 16; + g = g * state.g * 258 >> 16; + b = b * state.b * 258 >> 16; + + gl_do_texture(0); + if(state.alpha != 255) + { + gl_blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_do_blend(1); + } + else + gl_do_blend(0); + + gl.Begin(GL_QUADS); + gl.Color4ub(r, g, b, state.alpha); + gl.Vertex2i(dx1, dy1); + gl.Vertex2i(dx2, dy1); + gl.Vertex2i(dx2, dy2); + gl.Vertex2i(dx1, dy2); + gl.End(); + return 0; +} + + +SDL_Surface *glSDL_DisplayFormat(SDL_Surface *surface) +{ + SDL_Surface *s, *tmp; + if(USING_GLSDL) + { + int use_rgba = (surface->flags & SDL_SRCCOLORKEY) || + ((surface->flags & SDL_SRCALPHA) && + surface->format->Amask); + if(use_rgba) + tmp = SDL_ConvertSurface(surface, &RGBAfmt, SDL_SWSURFACE); + else + tmp = SDL_ConvertSurface(surface, &RGBfmt, SDL_SWSURFACE); + if(!tmp) + return NULL; + GLSDL_FIX_SURFACE(tmp); + SDL_SetAlpha(tmp, 0, 0); + + if(surface->flags & SDL_SRCCOLORKEY) + { + /* + * We drop colorkey data here, but we have to, + * or we'll run into trouble when converting, + * in particular from indexed color formats. + */ + SDL_SetColorKey(tmp, SDL_SRCCOLORKEY, + surface->format->colorkey); + key2alpha(tmp); + } + SDL_SetColorKey(tmp, 0, 0); + + if(use_rgba) + s = CreateRGBASurface(surface->w, surface->h); + else + s = CreateRGBSurface(surface->w, surface->h); + if(!s) + { + glSDL_FreeSurface(tmp); + return NULL; + } + SDL_BlitSurface(tmp, NULL, s, NULL); + glSDL_FreeSurface(tmp); + + if(surface->flags & SDL_SRCALPHA) + SDL_SetAlpha(s, SDL_SRCALPHA, + surface->format->alpha); + return s; + } + else + { + s = SDL_DisplayFormat(surface); + if(s) + GLSDL_FIX_SURFACE(s); + return s; + } +} + + +SDL_Surface *glSDL_DisplayFormatAlpha(SDL_Surface *surface) +{ + SDL_Surface *s, *tmp; + if(USING_GLSDL) + { + tmp = SDL_ConvertSurface(surface, &RGBAfmt, SDL_SWSURFACE); + if(!tmp) + return NULL; + GLSDL_FIX_SURFACE(tmp); + + SDL_SetAlpha(tmp, 0, 0); + SDL_SetColorKey(tmp, 0, 0); + s = CreateRGBASurface(surface->w, surface->h); + if(!s) + { + glSDL_FreeSurface(tmp); + return NULL; + } + SDL_BlitSurface(tmp, NULL, s, NULL); + glSDL_FreeSurface(tmp); + + if(surface->flags & SDL_SRCCOLORKEY) + { + SDL_SetColorKey(s, SDL_SRCCOLORKEY, + surface->format->colorkey); + key2alpha(s); + } + if(surface->flags & SDL_SRCALPHA) + SDL_SetAlpha(s, SDL_SRCALPHA, + surface->format->alpha); + return s; + } + else + { + s = SDL_DisplayFormatAlpha(surface); + if(s) + GLSDL_FIX_SURFACE(s); + return s; + } +} + + +SDL_Surface *glSDL_ConvertSurface + (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags) +{ + SDL_Surface *s = SDL_ConvertSurface(src, fmt, flags); + if(s) + GLSDL_FIX_SURFACE(s); + return s; +} + + +SDL_Surface *glSDL_CreateRGBSurface + (Uint32 flags, int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) +{ + SDL_Surface *s = SDL_CreateRGBSurface(flags, width, height, depth, + Rmask, Gmask, Bmask, Amask); + if(s) + GLSDL_FIX_SURFACE(s); + return s; +} + + +SDL_Surface *glSDL_CreateRGBSurfaceFrom(void *pixels, + int width, int height, int depth, int pitch, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) +{ + SDL_Surface *s = SDL_CreateRGBSurfaceFrom(pixels, + width, height, depth, pitch, + Rmask, Gmask, Bmask, Amask); + if(s) + GLSDL_FIX_SURFACE(s); + return s; +} + + +SDL_Surface *glSDL_LoadBMP(const char *file) +{ + SDL_Surface *s = SDL_LoadBMP(file); + if(s) + GLSDL_FIX_SURFACE(s); + return s; +} + + +int glSDL_SaveBMP(SDL_Surface *surface, const char *file) +{ + SDL_Rect r; + SDL_Surface *buf; + SDL_Surface *screen = SDL_GetVideoSurface(); + + if(!USING_GLSDL) + return SDL_SaveBMP(surface, file); + + if((surface != screen) && (surface != fake_screen)) + return SDL_SaveBMP(surface, file); + + buf = CreateRGBSurface(fake_screen->w, fake_screen->h); + + r.x = 0; + r.y = 0; + r.w = fake_screen->w; + r.h = fake_screen->h; + if(glSDL_BlitFromGL(&r, buf, &r) < 0) + return -1; + + return SDL_SaveBMP(buf, file); + + glSDL_FreeSurface(buf); +} + + + + +static int InitTexture(SDL_Surface *datasurf, glSDL_TexInfo *txi, int tex) +{ + gl.GenTextures(1, (unsigned int *)&txi->texture[tex]); + gl.BindTexture(GL_TEXTURE_2D, txi->texture[tex]); + gl.PixelStorei(GL_UNPACK_ROW_LENGTH, datasurf->pitch / + datasurf->format->BytesPerPixel); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + gl.TexImage2D(GL_TEXTURE_2D, 0, + datasurf->format->Amask ? GL_RGBA8 : GL_RGB8, + txi->texsize, txi->texsize, 0, + datasurf->format->Amask ? GL_RGBA : GL_RGB, + GL_UNSIGNED_BYTE, NULL); + print_glerror(1); + return 0; +} + + +/* Image tiled horizontally (wide surface), or not at all */ +static int UploadHoriz(SDL_Surface *datasurf, glSDL_TexInfo *txi) +{ + int bpp = datasurf->format->BytesPerPixel; + int res; + int tex = 0; + int fromx = 0; + int toy = txi->texsize; /* To init first texture */ + while(1) + { + int thistw = datasurf->w - fromx; + if(thistw > txi->tilew) + thistw = txi->tilew; + else if(thistw <= 0) + break; + if(toy + txi->tileh > txi->texsize) + { + toy = 0; + res = InitTexture(datasurf, txi, tex); + if(res < 0) + return res; + ++tex; + } + gl.TexSubImage2D(GL_TEXTURE_2D, 0, 0, toy, + thistw, txi->tileh, + datasurf->format->Amask ? GL_RGBA : GL_RGB, + GL_UNSIGNED_BYTE, + (char *)datasurf->pixels + bpp * fromx); + print_glerror(2); + fromx += txi->tilew; + toy += txi->tileh; + gl.Flush(); + } + return 0; +} + + +/* Image tiled vertically (tall surface) */ +static int UploadVert(SDL_Surface *datasurf, glSDL_TexInfo *txi) +{ + int res; + int tex = 0; + int fromy = 0; + int tox = txi->texsize; /* To init first texture */ + while(1) + { + int thisth = datasurf->h - fromy; + if(thisth > txi->tileh) + thisth = txi->tileh; + else if(thisth <= 0) + break; + if(tox + txi->tilew > txi->texsize) + { + tox = 0; + res = InitTexture(datasurf, txi, tex); + if(res < 0) + return res; + ++tex; + } + gl.TexSubImage2D(GL_TEXTURE_2D, 0, tox, 0, + txi->tilew, thisth, + datasurf->format->Amask ? GL_RGBA : GL_RGB, + GL_UNSIGNED_BYTE, + (char *)datasurf->pixels + datasurf->pitch * fromy); + print_glerror(3); + fromy += txi->tileh; + tox += txi->tilew; + gl.Flush(); + } + return 0; +} + + +/* Image tiled two-way (huge surface) */ +static int UploadHuge(SDL_Surface *datasurf, glSDL_TexInfo *txi) +{ + int bpp = datasurf->format->BytesPerPixel; + int res; + int tex = 0; + int y = 0; + while(y < datasurf->h) + { + int x; + int thisth = datasurf->h - y; + if(thisth > txi->tileh) + thisth = txi->tileh; + x = 0; + while(x < datasurf->w) + { + int thistw = datasurf->w - x; + if(thistw > txi->tilew) + thistw = txi->tilew; + res = InitTexture(datasurf, txi, tex++); + if(res < 0) + return res; + gl.TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, + thistw, thisth, + datasurf->format->Amask ? GL_RGBA : GL_RGB, + GL_UNSIGNED_BYTE, + (char *)datasurf->pixels + + datasurf->pitch * y + bpp * x); + print_glerror(4); + x += txi->tilew; + gl.Flush(); + } + y += txi->tileh; + } + return 0; +} + + +/* Upload all textures for a surface. */ +static int UploadTextures(SDL_Surface *datasurf, glSDL_TexInfo *txi) +{ + switch(txi->tilemode) + { + case GLSDL_TM_SINGLE: + case GLSDL_TM_HORIZONTAL: + UploadHoriz(datasurf, txi); + break; + case GLSDL_TM_VERTICAL: + UploadVert(datasurf, txi); + break; + case GLSDL_TM_HUGE: + UploadHuge(datasurf, txi); + break; + } + return 0; +} + + +SDL_Surface *glSDL_IMG_Load(const char *file) +{ + SDL_Surface *s; + s = IMG_Load(file); + if(s) + GLSDL_FIX_SURFACE(s); + return s; +} + + +/*---------------------------------------------------------- + glSDL specific API extensions +----------------------------------------------------------*/ + +int glSDL_VSync(int use) +{ + int old = vsync; + if(use >= 0) + vsync = use; + return old; +} + + +void glSDL_Invalidate(SDL_Surface *surface, SDL_Rect *area) +{ + glSDL_TexInfo *txi; + if(!surface) + return; + txi = glSDL_GetTexInfo(surface); + if(!txi) + return; + if(!area) + { + txi->invalid_area.x = 0; + txi->invalid_area.y = 0; + txi->invalid_area.w = surface->w; + txi->invalid_area.h = surface->h; + return; + } + txi->invalid_area = *area; +} + + +int glSDL_UploadSurface(SDL_Surface *surface) +{ + SDL_Surface *datasurf = surface; + glSDL_TexInfo *txi; + int i; + /* + * For now, we just assume that *every* texture needs + * conversion before uploading. + */ + + /* If there's no TexInfo, add one. */ + if(!IS_GLSDL_SURFACE(surface)) + glSDL_AddTexInfo(surface); + + txi = glSDL_GetTexInfo(surface); + if(!txi) + return -1; + + /* No partial updates implemented yet... */ + if(txi->invalid_area.w) + glSDL_UnloadSurface(surface); + else + { + int missing = 0; + if(txi->textures) + { + for(i = 0; i < txi->textures; ++i) + if(-1 == txi->texture[i]) + { + missing = 1; + break; + } + if(!missing) + return 0; /* They're already there! */ + } + } + + if(txi->texsize > maxtexsize) + { + fprintf(stderr, "glSDL/wrapper: INTERNAL ERROR: Too large texture!\n"); + return -1; /* This surface wasn't tiled properly... */ + } + + /* + * Kludge: Convert if not of preferred RGB or RGBA format. + * + * Conversion should only be done when *really* needed. + * That is, it should rarely have to be done with OpenGL + * 1.2+. + * + * Besides, any surface that's been SDL_DisplayFormat()ed + * should already be in the best known OpenGL format - + * preferably one that makes DMA w/o conversion possible. + */ + if(FormatIsOk(surface)) + datasurf = surface; + else + { + DBG(fprintf(stderr, "glSDL/wrapper: WARNING: On-the-fly conversion performed!\n")); + if(surface->format->Amask) + datasurf = glSDL_DisplayFormatAlpha(surface); + else + datasurf = glSDL_DisplayFormat(surface); + if(!datasurf) + return -2; + } + + if(UploadTextures(datasurf, txi) < 0) + return -3; + + if(datasurf != surface) + glSDL_FreeSurface(datasurf); + return 0; +} + + +static void UnloadTexture(glSDL_TexInfo *txi) +{ + int i; + if(SDL_WasInit(SDL_INIT_VIDEO)) + for(i = 0; i < txi->textures; ++i) + gl.DeleteTextures(1, (unsigned int *)&txi->texture[i]); + memset(&txi->invalid_area, 0, sizeof(txi->invalid_area)); +} + + +void glSDL_UnloadSurface(SDL_Surface *surface) +{ + glSDL_TexInfo *txi; + if(!IS_GLSDL_SURFACE(surface)) + return; + + txi = glSDL_GetTexInfo(surface); + if(txi) + UnloadTexture(txi); +} + + +#else /* HAVE_OPENGL */ + +/*---------------------------------------------------------- + Dummies for glSDL extensions that require OpenGL +----------------------------------------------------------*/ + +void glSDL_Invalidate(SDL_Surface *surface, SDL_Rect *area) +{ +} + +int glSDL_UploadSurface(SDL_Surface *surface) +{ + return 0; +} + +void glSDL_UnloadSurface(SDL_Surface *surface) +{ +} + +int glSDL_VSync(int use) +{ + return 0; +} + +void glSDL_SetBlendAlpha(Uint8 alpha) +{ +} + +void glSDL_SetBlendColor(Uint8 r, Uint8 g, Uint8 b) +{ +} + +void glSDL_SetCenter(float x, float y) +{ +} + +void glSDL_SetRotation(float angle) +{ +} + +void glSDL_SetScale(float x, float y) +{ +} + +void glSDL_ResetState(void) +{ +} + +#endif /* HAVE_OPENGL */ diff --git a/graphics/glSDL.h b/graphics/glSDL.h new file mode 100644 index 0000000..7bdf193 --- /dev/null +++ b/graphics/glSDL.h @@ -0,0 +1,399 @@ +/*(LGPL) +------------------------------------------------------------ + glSDL 0.9 - SDL 2D API on top of OpenGL +------------------------------------------------------------ + * Copyright (C) 2001-2004, 2006-2007 David Olofson + * This code is released under the terms of the GNU LGPL. + */ + +#ifndef _GLSDL_H_ +#define _GLSDL_H_ + +/* + * If you don't use GNU autotools or similar, uncomment this to + * compile with OpenGL enabled: +#define HAVE_OPENGL + * + * NOTE: + * See README about using this glSDL wrapper with + * SDL versions that have the glSDL backend! + */ + +/* We're still using SDL datatypes here - we just add some stuff. */ +#include "SDL.h" + +/* + * Ignore the flag from SDL w/ glSDL backend, since we're going + * to use glSDL/wrapper by default. + */ +#ifdef SDL_GLSDL +#undef SDL_GLSDL +#endif + +#ifndef HAVE_OPENGL + +/* Fakes to make glSDL code compile with SDL. */ +#define SDL_GLSDL 0 +#define GLSDL_FIX_SURFACE(s) + +#else /* HAVE_OPENGL */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if (SDL_MAJOR_VERSION <= 1) && (SDL_MINOR_VERSION <= 2) && \ + (SDL_PATCHLEVEL < 5) +#warning glSDL: Using SDL version 1.2.5 or later is strongly recommended! +#endif + +/*---------------------------------------------------------- + SDL style API +----------------------------------------------------------*/ + +typedef enum glSDL_TileModes +{ + GLSDL_TM_SINGLE, + GLSDL_TM_HORIZONTAL, + GLSDL_TM_VERTICAL, + GLSDL_TM_HUGE +} glSDL_TileModes; + + +typedef struct glSDL_TexInfo +{ + int textures; + int *texture; + int texsize; /* width/height of OpenGL texture */ + glSDL_TileModes tilemode; + int tilew, tileh; /* At least one must equal texsize! */ + int tilespertex; + + /* Area of surface to download when/after unlocking */ + SDL_Rect invalid_area; +} glSDL_TexInfo; + +#define GLSDL_FIX_SURFACE(s) (s)->unused1 = 0; +#define IS_GLSDL_SURFACE(s) ((s) && texinfotab && glSDL_GetTexInfo(s)) + +#ifdef SDL_GLSDL +#undef SDL_GLSDL /* In case SDL has the glSDL backend... */ +#endif +#define SDL_GLSDL 0x00100000 /* Create an OpenGL 2D rendering context */ + + +/* + * Wraps SDL_SetVideoMode(), and adds support for the SDL_GLSDL flag. + * + * If 'flags' contains SDL_GLSDL, glSDL_SetVideoMode() sets up a "pure" + * OpenGL rendering context for use with the glSDL_ calls. + * + * SDL can be closed as usual (using SDL_ calls), but you should call + * glSDL_Quit() (kludge) to allow glSDL to clean up it's internal stuff. + */ +SDL_Surface *glSDL_SetVideoMode(int width, int height, int bpp, Uint32 flags); +void glSDL_Quit(void); + +void glSDL_QuitSubSystem(Uint32 flags); + +/* Replaces SDL_Quit() entirely, when using the override defines */ +void glSDL_FullQuit(void); + +SDL_Surface *glSDL_GetVideoSurface(void); + +void glSDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects); +void glSDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h); + +/* + * Works like SDL_Flip(), but may also perform enqueued blits. + * (That is, it's possible that the implementation renders + * *nothing* until glSDL_Flip() is called.) + */ +int glSDL_Flip(SDL_Surface *screen); + +void glSDL_FreeSurface(SDL_Surface *surface); + +int glSDL_LockSurface(SDL_Surface *surface); +void glSDL_UnlockSurface(SDL_Surface *surface); + +/* + * Like the respective SDL functions, although they ignore + * SDL_RLEACCEL, as it makes no sense in this context. + */ +int glSDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key); +int glSDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha); + +/* + * Sets up clipping for the screen, or a SDL_Surface. + * + * Note that this function takes both SDL_Surfaces and + * glSDL_Surfaces. + */ +SDL_bool glSDL_SetClipRect(SDL_Surface *surface, SDL_Rect *rect); + +int glSDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); + +int glSDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color); + +/* + * Convert the given surface into a SDL_Surface (if it isn't + * one already), and makes sure that the underlying SDL_Surface + * is of a pixel format suitable for fast texture downloading. + * + * Note that you *only* have to use this function if you want + * fast pixel access to surfaces (ie "procedural textures"). + * Any surfaces that aren't converted will be downloaded + * automatically upon the first call to glSDL_BlitSurface(), + * but if conversion is required, it will be required for + * every glSDL_UnlockSurface() call. + * + * IMPORTANT: + * You *can* pass an SDL_Surface directly to this function, + * and it will try to deal with it nicely. However, this + * requires that a temporary SDL_Surface is created, and + * this surface is cached only until the texture memory is + * needed for new surfaces. + */ +SDL_Surface *glSDL_DisplayFormat(SDL_Surface *surface); +SDL_Surface *glSDL_DisplayFormatAlpha(SDL_Surface *surface); + +SDL_Surface *glSDL_ConvertSurface + (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags); +SDL_Surface *glSDL_CreateRGBSurface + (Uint32 flags, int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +SDL_Surface *glSDL_CreateRGBSurfaceFrom(void *pixels, + int width, int height, int depth, int pitch, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +SDL_Surface *glSDL_LoadBMP(const char *file); +int glSDL_SaveBMP(SDL_Surface *surface, const char *file); + +#ifdef __cplusplus +} +#endif + +/* Some ugly "overriding"... */ +#ifndef _GLSDL_NO_REDEFINES_ +/* + * You *always* need to lock and unlock a glSDL surface in + * order to get glSDL to update the OpenGL texture! + */ +#undef SDL_MUSTLOCK +#define SDL_MUSTLOCK(surface) \ + (surface->offset || \ + ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0) || \ + IS_GLSDL_SURFACE(surface)) + +#define SDL_SetVideoMode glSDL_SetVideoMode +#define SDL_GetVideoSurface glSDL_GetVideoSurface +#define SDL_Quit glSDL_FullQuit +#define SDL_QuitSubSystem glSDL_QuitSubSystem +#define SDL_UpdateRects glSDL_UpdateRects +#define SDL_UpdateRect glSDL_UpdateRect +#define SDL_Flip glSDL_Flip +#define SDL_FreeSurface glSDL_FreeSurface +#define SDL_LockSurface glSDL_LockSurface +#define SDL_UnlockSurface glSDL_UnlockSurface +#define SDL_SetColorKey glSDL_SetColorKey +#define SDL_SetAlpha glSDL_SetAlpha +#define SDL_SetClipRect glSDL_SetClipRect +#undef SDL_BlitSurface +#define SDL_BlitSurface glSDL_BlitSurface +#define SDL_FillRect glSDL_FillRect +#define SDL_DisplayFormat glSDL_DisplayFormat +#define SDL_DisplayFormatAlpha glSDL_DisplayFormatAlpha +#define SDL_ConvertSurface glSDL_ConvertSurface +#define SDL_CreateRGBSurface glSDL_CreateRGBSurface +#define SDL_CreateRGBSurfaceFrom glSDL_CreateRGBSurfaceFrom +#undef SDL_AllocSurface +#define SDL_AllocSurface glSDL_CreateRGBSurface +#undef SDL_LoadBMP +#define SDL_LoadBMP glSDL_LoadBMP +#undef SDL_SaveBMP +#define SDL_SaveBMP glSDL_SaveBMP +#define IMG_Load(x) glSDL_IMG_Load(x) +#endif + +#endif /* HAVE_OPENGL */ + + +#ifdef HAVE_OPENGL + +/* Some extra overloading for common external lib calls... */ +#include "SDL_image.h" +#ifdef __cplusplus +extern "C" { +#endif +SDL_Surface *glSDL_IMG_Load(const char *file); +#ifdef __cplusplus +} +#endif + +#endif /* HAVE_OPENGL */ + + +/*---------------------------------------------------------- + glSDL API extensions, transparent +----------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" { +#endif +/* + * Invalidate part of a texture. + * + * This function can be used either between calls to + * glSDL_LockSurface() and glSDL_UnlockSurface(), or before + * calling glSDL_DownloadSurface(). + * + * In either case, it causes only the specified area to be + * downloaded when unlocking the surface, or calling + * glSDL_UnlockSurface(), respectively. + * + * Note that if this function is not used, glSDL assumes that + * the entire surface has to be updated. (That is, it's safe + * to ignore this function - it's "just a performance hack.") + * + * Passing a rectangle with zero height or width cancels the + * downloading when/after unlocking the surface. Use if you + * just want to read the texture, but feel like being nice and + * obeying SDL_MUSTLOCK() - which is a good idea, as things + * may change... + * + * Passing NULL for the 'area' argument results in the entire + * surface being invalidated. + * + * NOTE: This function does NOT perform clipping! Weird or + * even Bad Things may happen if you specify areas + * that protrude outside the edges of the actual + * surface. + */ +void glSDL_Invalidate(SDL_Surface *surface, SDL_Rect *area); + +/* + * Make sure that the texture of the specified surface is up + * to date in OpenGL texture memory. + * + * This can be used together with glSDL_UnloadSurface() to + * implement custom texture caching schemes. + * + * Returns 0 on success, or a negative value if something + * went wrong. + */ +int glSDL_UploadSurface(SDL_Surface *surface); + +/* + * Free the texture space used by the specified surface. + * + * Normally, glSDL should download textures when needed, and + * unload the oldest (in terms of use) surfaces, if it runs out + * of texture space. + */ +void glSDL_UnloadSurface(SDL_Surface *surface); + + +/*---------------------------------------------------------- + glSDL API extensions, OpenGL mode ONLY +----------------------------------------------------------*/ + +/* + * Enable, disable or check the state of "vsync" or + * vertical retrace synchronization. Note that enabling + * this does not *guarantee* that the driver actually + * uses vsync; it only instructs OpenGL to do so if + * possible. + * Pass 1 for 'use' to enable vsync, '0' to disable + * it, and -1 to just return the current state without + * changing it. + * Returns the vsync state *before* any change made + * by the call. + * + * NOTE: Ignored when not using OpenGL acceleration! + */ +int glSDL_VSync(int use); + +/* + * Set alpha multiplier. This is multiplied with any full + * surface alpha or alpha channels of surfaces. + * + * The default value is 255, which makes glSDL render like + * the standard SDL 2D backends, ie based only on the + * surface settings. + * + * This function affects the global state of glSDL. + * + * NOTE: NOT available without OpenGL acceleration! + */ +void glSDL_SetBlendAlpha(Uint8 alpha); + +/* + * Set color multipliers. These are multiplied with the + * respective color channers of rendered surfaces, + * modulating the brightness of the resulting output. + * + * The default values are 255, which makes glSDL render + * like the standard SDL 2D backends. + * + * This function affects the global state of glSDL. + * + * NOTE: NOT available without OpenGL acceleration! + */ +void glSDL_SetBlendColor(Uint8 r, Uint8 g, Uint8 b); + +/* + * Set center offset in pixels for scaling and rotation. + * + * The default is (0, 0), which makes surfaces rotate and + * scale around their centers. + * + * This function affects the global state of glSDL. + * + * NOTE: NOT available without OpenGL acceleration! + */ +void glSDL_SetCenter(float x, float y); + + +/* + * Set rotation angle in degrees. Rotation is done around + * the center point, which is defined as + * (w/2 + cx, h/2 + cy) + * where w and h are the width and height of the source + * surface, and cx and cy are the center offsets set by + * glSDL_SetCenter(). + * + * The default value is 0.0f, which makes glSDL render + * like a normal SDL 2D backend. + * + * This function affects the global state of glSDL. + * + * NOTE: NOT available without OpenGL acceleration! + */ +void glSDL_SetRotation(float angle); + +/* + * Set scale factor. Scaling is centered around around + * the point + * (w/2 + cx, h/2 + cy) + * where w and h are the width and height of the source + * surface, and cx and cy are the center offsets set by + * glSDL_SetCenter(). + * + * The default value is 1.0f, which makes glSDL render + * like a normal SDL 2D backend. + * + * This function affects the global state of glSDL. + * + * NOTE: NOT available without OpenGL acceleration! + */ +void glSDL_SetScale(float x, float y); + +/* + * Reset glSDL global state to defaults. + */ +void glSDL_ResetState(void); +#ifdef __cplusplus +} +#endif + + +#endif /* _GLSDL_H_ */ diff --git a/graphics/region.c b/graphics/region.c new file mode 100644 index 0000000..f72b45d --- /dev/null +++ b/graphics/region.c @@ -0,0 +1,213 @@ +/*(LGPL) +---------------------------------------------------------------------- + region.c - Graphics Engine +---------------------------------------------------------------------- + * Copyright (C) 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "region.h" +#include + +static struct +{ + RGN_region *region; + int x, y; + SDL_Surface *target; +} s; + + +static Uint32 gp1(SDL_Surface *surface, int x, int y) +{ + return *((Uint8 *)surface->pixels + y * surface->pitch + x); +} + + +static Uint32 gp2(SDL_Surface *surface, int x, int y) +{ + return *((Uint16 *)surface->pixels + y * surface->pitch / 2 + x); +} + + +static Uint32 gp3(SDL_Surface *surface, int x, int y) +{ + int bpp = surface->format->BytesPerPixel; + Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; +#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + return p[0] << 16 | p[1] << 8 | p[2]; +#else + return p[0] | p[1] << 8 | p[2] << 16; +#endif +} + + +static Uint32 gp4(SDL_Surface *surface, int x, int y) +{ + return *((Uint32 *)surface->pixels + y * surface->pitch / 4 + x); +} + + +RGN_region *RGN_ScanMask(SDL_Surface *src, Uint32 key) +{ + RGN_region *rgn = (RGN_region *)calloc(1, sizeof(RGN_region)); + Uint32 (*gp)(SDL_Surface *surface, int x, int y); + int x, y; + if(!rgn) + return NULL; + rgn->rows = src->h; + rgn->spans = (Uint16 **)calloc(1, sizeof(Uint16 *) * src->h); + if(!rgn->spans) + { + RGN_FreeRegion(rgn); + return NULL; + } + switch(src->format->BytesPerPixel) + { + case 1: + gp = gp1; + break; + case 2: + gp = gp2; + break; + case 3: + gp = gp3; + break; + case 4: + gp = gp4; + break; + default: + RGN_FreeRegion(rgn); + return NULL; + } + SDL_LockSurface(src); + for(y = 0; y < src->h; ++y) + { + int i = 0; + int drawing = 0; + Uint16 *sp = (Uint16 *)malloc(sizeof(Uint16) * 2 * (src->w + 1)); + if(!sp) + { + SDL_UnlockSurface(src); + RGN_FreeRegion(rgn); + return NULL; + } + for(x = 0; x < src->w; ++x) + { + int nd = (gp(src, x, y) == key); + if(nd != drawing) + { + sp[i++] = x; + drawing = nd; + } + } + if(drawing) + sp[i++] = src->w; + sp[i++] = 0; + sp[i++] = 0; + rgn->spans[y] = (Uint16 *)realloc(sp, sizeof(Uint16) * i); + if(!rgn->spans[y]) + rgn->spans[y] = sp; + } + SDL_UnlockSurface(src); + return rgn; +} + + +void RGN_FreeRegion(RGN_region *rgn) +{ + if(!rgn) + return; + if(rgn->spans) + { + int i; + for(i = rgn->rows - 1; i >= 0; --i) + free(rgn->spans[i]); + free(rgn->spans); + } + free(rgn); +} + + +void RGN_Target(SDL_Surface *tgt) +{ + s.target = tgt; +} + + +void RGN_SetRegion(RGN_region *rgn, int xpos, int ypos) +{ + s.region = rgn; + s.x = xpos; + s.y = ypos; +} + + +int RGN_Blit(SDL_Surface *src, SDL_Rect *sr, int x, int y) +{ +// FIXME: Clipping is only half done here... + int yy0, yy, yy1; + int sxmin, sxmax, symin, symax; + SDL_Rect sr2; + if(!s.region) + { + SDL_Rect dr; + dr.x = x; + dr.y = y; + return SDL_BlitSurface(src, sr, s.target, &dr); + } + if(sr) + { + sxmin = sr->x; + symin = sr->y; + sxmax = sxmin + sr->w; + symax = symin + sr->h; + } + else + { + sxmin = 0; + symin = 0; + sxmax = src->w; + symax = src->h; + } + yy0 = s.y; + if(yy0 >= y + (symax - symin)) + return 0; + if(yy0 < y) + yy0 = y; + yy1 = s.y + s.region->rows; + if(y >= yy1) + return 0; + if(yy1 > y + (symax - symin)) + yy1 = y + (symax - symin); + sr2.h = 1; + for(yy = yy0; yy < yy1; ++yy) + { + SDL_Rect dr; + Uint16 *spans = s.region->spans[yy - s.y]; + sr2.y = symin + y - yy0; + dr.y = yy; + for( ; spans[0] && spans[1] ; spans += 2) + { + int x0 = s.x + spans[0]; + int x1 = s.x + spans[1]; + dr.x = x0; + sr2.x = sxmin + x0 - x; + sr2.w = x1 - x0; + SDL_BlitSurface(src, &sr2, s.target, &dr); + } + } + return 0; +} diff --git a/graphics/region.h b/graphics/region.h new file mode 100644 index 0000000..cb88e62 --- /dev/null +++ b/graphics/region.h @@ -0,0 +1,61 @@ +/*(LGPL) +---------------------------------------------------------------------- + region.h - Graphics Engine +---------------------------------------------------------------------- + * Copyright (C) 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef KOBO_REGION_H +#define KOBO_REGION_H + +#include "glSDL.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Region + * Describes an area as a number of pixel spaced rows, + * each containing zero or more spans on the form . + */ +typedef struct RGN_region +{ + int rows; + Uint16 **spans; +} RGN_region; + +/* Construct region by scanning an SDL surface */ +RGN_region *RGN_ScanMask(SDL_Surface *src, Uint32 key); + +/* Free a region */ +void RGN_FreeRegion(RGN_region *rgn); + +/* Set target for region rendering */ +void RGN_Target(SDL_Surface *tgt); + +/* Select and position region for subsequent operations */ +void RGN_SetRegion(RGN_region *rgn, int xpos, int ypos); + +/* Blit to region! */ +int RGN_Blit(SDL_Surface *src, SDL_Rect *sr, int x, int y); + +#ifdef __cplusplus +}; +#endif + +#endif /* KOBO_REGION_H */ diff --git a/graphics/sofont.cpp b/graphics/sofont.cpp new file mode 100644 index 0000000..3ade135 --- /dev/null +++ b/graphics/sofont.cpp @@ -0,0 +1,577 @@ +#include "logger.h" +#include "stdlib.h" +#include "sofont.h" +#include "string.h" + +SoFont::SoFont() +{ + picture = NULL; + CharPos = NULL; + CharOffset = NULL; + Spacing = NULL; + height = 0; + max_i = 0; + spacew = 0; + cursShift = 0; + background = 0; + xspace = 1; +} + +SoFont::~SoFont() +{ + if(picture) + SDL_FreeSurface(picture); + delete[]CharPos; + delete[]CharOffset; + delete[]Spacing; +} + +namespace SoFontUtilities +{ + Uint32 SoFontGetPixel(SDL_Surface * Surface, Sint32 X, Sint32 Y) + { + Uint8 *bits; + Uint32 Bpp; + + if(!Surface) + { + log_printf(ELOG, "SoFontGetPixel: No surface!\n"); + return 0; + } + if((X < 0) || (X >= Surface->w)) + { + log_printf(ELOG, "SoFontGetPixel: X (%d)" + " out of range!\n", X); + return 0; + } + + Bpp = Surface->format->BytesPerPixel; + + bits = ((Uint8 *) Surface->pixels) + Y * Surface->pitch + + X * Bpp; + + switch (Bpp) + { + case 1: + return *((Uint8 *) Surface->pixels + + Y * Surface->pitch + X); + break; + case 2: + return *((Uint16 *) Surface->pixels + + Y * Surface->pitch / 2 + X); + break; + case 3: + // Format/endian independent + Uint8 r, g, b; + r = *((bits) + Surface->format->Rshift / 8); + g = *((bits) + Surface->format->Gshift / 8); + b = *((bits) + Surface->format->Bshift / 8); + return SDL_MapRGB(Surface->format, r, g, b); + break; + case 4: + return *((Uint32 *) Surface->pixels + + Y * Surface->pitch / 4 + X); + break; + } + log_printf(ELOG, "SoFontGetPixel: Unsupported pixel format!\n"); + return 0; // David (to get rid of warning) + } + void SoFontSetPixel(SDL_Surface * Surface, Sint32 X, Sint32 Y, + Uint32 c) + { + Uint8 *bits; + Uint32 Bpp; + + if(!Surface) + { + log_printf(ELOG, "SoFontSetPixel: No surface!\n"); + return; + } + if((X < 0) || (X >= Surface->w)) + { + log_printf(ELOG, "SoFontSetPixel: X (%d)" + " out of range!\n", X); + return; + } + + Bpp = Surface->format->BytesPerPixel; + + bits = ((Uint8 *) Surface->pixels) + Y * Surface->pitch + + X * Bpp; + + switch (Bpp) + { + case 1: + *((Uint8 *) Surface->pixels + Y * Surface->pitch + + X) = (Uint8) c; + break; + case 2: + *((Uint16 *) Surface->pixels + + Y * Surface->pitch / 2 + X) = + (Uint16) c; + break; + case 3: + // Format/endian independent + Uint8 r, g, b; + SDL_GetRGB(c, Surface->format, &r, &g, &b); + *((bits) + Surface->format->Rshift / 8) = r; + *((bits) + Surface->format->Gshift / 8) = g; + *((bits) + Surface->format->Bshift / 8) = b; + break; + case 4: + *((Uint32 *) Surface->pixels + + Y * Surface->pitch / 4 + X) = c; + break; + } + } + void clipx(SDL_Rect * srcrect, SDL_Rect * dstrect, SDL_Rect * clip) + { + // Use if destination have the same size than source. + int dx = clip->x - dstrect->x; + + int sw = srcrect->w; // Because SDL_Rect.w are + // unsigned. + int dw = dstrect->w; + + if(dx > 0) + { + srcrect->x += dx; + dstrect->x += dx; + + sw -= dx; + dw -= dx; + } + + int dwx = (dstrect->x + dstrect->w) - (clip->x + clip->w); + + if(dwx > 0) + { + sw -= dwx; + dw -= dwx; + } + + if(sw > 0) + srcrect->w = sw; + else + srcrect->w = 0; + + if(dw > 0) + dstrect->w = dw; + else + dstrect->w = 0; + } + void sdcRects(SDL_Rect * source, SDL_Rect * destination, + SDL_Rect clipping) + { + // Use if destination have the same size than source & + // cliping on destination + int dx = clipping.x - destination->x; + int dy = clipping.y - destination->y; + + int sw = source->w; + int sh = source->h; + + if(dx > 0) + { + source->x += dx; + destination->x += dx; + + sw -= dx; + destination->w -= dx; + } + if(dy > 0) + { + source->y += dy; + destination->y += dy; + + sh -= dy; + destination->h -= dy; + } + + int dwx = (destination->x + destination->w) - (clipping.x + + clipping.w); + int dhy = (destination->y + destination->h) - (clipping.y + + clipping.h); + + if(dwx > 0) + { + sw -= dwx; + destination->w -= dwx; + } + if(dhy > 0) + { + sh -= dhy; + destination->h -= dhy; + } + + if(sw > 0) + source->w = sw; + else + source->w = 0; + + if(sh > 0) + source->h = sh; + else + source->h = 0; + + } + +} +using namespace SoFontUtilities; + +bool SoFont::DoStartNewChar(Sint32 x) +{ + if(!picture) + return false; + return SoFontGetPixel(picture, x, 0) == + SDL_MapRGB(picture->format, 255, 0, 255); +} + +void SoFont::CleanSurface() +{ + if(!picture) + return; + + int x = 0, y = 0; + Uint32 pix = SDL_MapRGB(picture->format, 255, 0, 255); + + while(x < picture->w) + { + y = 0; + if(SoFontGetPixel(picture, x, y) == pix) + SoFontSetPixel(picture, x, y, background); + x++; + } +} + + +bool SoFont::load(SDL_Surface * FontSurface) +{ + int x = 0, i = 0, s = 0; + + int _CharPos[256]; + int _CharOffset[256]; + int _Spacing[256]; + + if(!FontSurface) + { + log_printf(ELOG, "SoFont recieved a NULL SDL_Surface\n"); + return false; + } + if(picture) + SDL_FreeSurface(picture); + picture = FontSurface; + height = picture->h - 1; + while(x < picture->w) + { + if(DoStartNewChar(x)) + { + if(i) + _Spacing[i - 1] = x - s + xspace; + int p = x; + while((x < picture->w) && (DoStartNewChar(x))) + x++; + s = x; + _CharPos[i] = (x + p + 1) / 2; + _CharOffset[i] = x - _CharPos[i]; + i++; + } + x++; + } + //Note that spacing is not needed for the last char, + //as it's just used for the blit width calculation. + if(i) + _Spacing[i - 1] = x - s; + _Spacing[i] = 0; + _CharOffset[i] = 0; + _CharPos[i++] = picture->w; + + max_i = START_CHAR + i - 1; + background = SoFontGetPixel(picture, 0, height); +// FIXME: Use this when there is no alpha channel? +// SDL_SetColorKey(picture, SDL_SRCCOLORKEY, background); + CleanSurface(); + + delete[]CharPos; + delete[]CharOffset; + delete[]Spacing; + CharPos = new int[i]; + CharOffset = new int[i]; + Spacing = new int[i]; + memcpy(CharPos, _CharPos, i * sizeof(int)); + memcpy(CharOffset, _CharOffset, i * sizeof(int)); + memcpy(Spacing, _Spacing, i * sizeof(int)); + + // We search for a smart space width: + // Changed from "a", "A", "0" for Kobo Deluxe. + // Spaces were *way* to wide! //David + spacew = 0; + if(!spacew) + spacew = TextWidth("i") * 3 / 2; + if(!spacew) + spacew = TextWidth("I") * 3 / 2; + if(!spacew) + spacew = TextWidth(".") * 3 / 2; + if(!spacew) + spacew = CharPos[1] - CharPos[0]; + + // We search for a smart cursor position: + int cursBegin = 0; + int cursWidth = 0; + cursShift = 0; + if('|' > max_i) + return true; //No bar in this font! + + if(background == SoFontGetPixel(picture, CharPos['|' - START_CHAR], + height / 2)) + { + // Up to the first | color + for(cursBegin = 0; cursBegin <= TextWidth("|"); + cursBegin++) + if(background != SoFontGetPixel(picture, + CharPos['|' - START_CHAR] + + cursBegin, height / 2)) + break; + // Up to the end of the | color + for(cursWidth = 0; cursWidth <= TextWidth("|"); + cursWidth++) + if(background == SoFontGetPixel(picture, + CharPos['|' - START_CHAR] + + cursBegin + cursWidth, + height / 2)) + break; + } + else + { + // Up to the end of the | color + for(cursWidth = 0; cursWidth <= TextWidth("|"); + cursWidth++) + if(background == SoFontGetPixel(picture, + CharPos['|' - START_CHAR] + + cursWidth, height / 2)) + break; + } + cursShift = cursBegin + 1; // cursWidth could be used if + // image format changes. + + return true; +} + +void SoFont::PutString(SDL_Surface *Surface, int x, int y, + const char *text, SDL_Rect *clip) +{ + if((!picture) || (!Surface) || (!text)) + return; + int ofs, i = 0; + SDL_Rect srcrect, dstrect; + while(text[i] != '\0') + { + if(text[i] == ' ') + { + x += spacew; + i++; + } + else if((text[i] >= START_CHAR) && (text[i] <= max_i)) + { + ofs = text[i] - START_CHAR; + srcrect.w = dstrect.w = + this->CharPos[ofs + 1] - + this->CharPos[ofs]; + srcrect.h = dstrect.h = height; + srcrect.x = this->CharPos[ofs]; + srcrect.y = 1; + dstrect.x = x - CharOffset[ofs]; + dstrect.y = y; + x += Spacing[ofs]; + if(clip) + sdcRects(&srcrect, &dstrect, *clip); + SDL_BlitSurface(picture, &srcrect, Surface, + &dstrect); + i++; + } + else + i++; // other chars are ignored + + // Coarse clipping + if(clip) + { + if(x > clip->x + clip->w) + return; + } + else + { + if(x > Surface->w) + return; + } + } +} + +void SoFont::PutStringWithCursor(SDL_Surface * Surface, int xs, int y, + const char *text, int cursPos, SDL_Rect * clip, + bool showCurs) +{ + if((!picture) || (!Surface) || (!text)) + return; + if('|' > max_i) + showCurs = false; + int ofs, i = 0, x = xs; + + SDL_Rect srcrect, dstrect; + + // We want the cursor to appear under the main text. + if(showCurs) + { + while(text[i] != '\0') + if(i == cursPos) + break; + else if(text[i] == ' ') + { + x += spacew; + i++; + } + else if((text[i] >= START_CHAR) + && (text[i] <= max_i)) + { + ofs = text[i] - START_CHAR; + x += Spacing[ofs]; + i++; + } + else + i++; + ofs = '|' - START_CHAR; + + srcrect.w = dstrect.w = CharPos[ofs + 1] - CharPos[ofs]; + srcrect.h = dstrect.h = height; + srcrect.x = this->CharPos[ofs]; + srcrect.y = 1; + dstrect.x = x - cursShift; + dstrect.y = y; + if(clip) + sdcRects(&srcrect, &dstrect, *clip); + SDL_BlitSurface(picture, &srcrect, Surface, &dstrect); + } + // Then the text: + PutString(Surface, xs, y, text, clip); +} +int SoFont::TextWidth(const char *text, int min, int max) +{ + if(!picture) + return 0; + int ofs, x = 0, i = min; + while((text[i] != '\0') && (i < max)) + { + if(text[i] == ' ') + { + x += spacew; + i++; + } + else if((text[i] >= START_CHAR) && (text[i] <= max_i)) + { + ofs = text[i] - START_CHAR; + x += Spacing[ofs]; + i++; + } + else + i++; + } + return x; +} +void SoFont::XCenteredString(SDL_Surface * Surface, int y, + const char *text, SDL_Rect * clip) +{ + if(!picture) + return; + PutString(Surface, Surface->w / 2 - TextWidth(text) / 2, y, text, + clip); +} + +void SoFont::CenteredString(SDL_Surface * Surface, int x, int y, + const char *text, SDL_Rect * clip) +{ + if(!picture) + return; + PutString(Surface, x - TextWidth(text) / 2, y - height / 2, text, + clip); +} + +void SoFont::CenteredString(SDL_Surface * Surface, const char *text, + SDL_Rect * clip) +{ + if(!picture) + return; + CenteredString(Surface, Surface->clip_rect.w / 2, + Surface->clip_rect.h / 2, text, clip); +} + +void SoFont::PutStringCleverCursor(SDL_Surface * Surface, const char *text, + int cursPos, SDL_Rect * r, SDL_Rect * clip, bool showCurs) +{ + if((!picture) || (!text)) + return; + + int w1, w2; + + w1 = TextWidth(text, 0, cursPos); + w2 = TextWidth(text); + + if((w2 < r->w) || (w1 < r->w / 2)) + PutStringWithCursor(Surface, r->x, + r->y + (r->h - height) / 2, text, cursPos, + clip, showCurs); + else if(w1 < w2 - r->w / 2) + PutStringWithCursor(Surface, r->x - w1 + r->w / 2, + r->y + (r->h - height) / 2, text, cursPos, + clip, showCurs); + else + PutStringWithCursor(Surface, r->x - w2 + r->w, + r->y + (r->h - height) / 2, text, cursPos, + clip, showCurs); +} + +int SoFont::TextCursorAt(const char *text, int px) +{ + if(!picture) + return 0; + int ofs, x = 0, i = 0, ax = 0; + + if(px <= 0) + return 0; + + while(text[i] != '\0') + { + if(text[i] == ' ') + { + x += spacew; + i++; + } + else if((text[i] >= START_CHAR) && (text[i] <= max_i)) + { + ofs = text[i] - START_CHAR; + x += Spacing[ofs]; + i++; + } + else + i++; + + if(px < (ax + x) / 2) + return (i - 1); + ax = x; + } + return i; +} + +int SoFont::CleverTextCursorAt(const char *text, int px, int cursPos, + SDL_Rect * r) +{ + if((!picture) || (!text)) + return 0; + int w1, w2; + w1 = TextWidth(text, 0, cursPos); + w2 = TextWidth(text); + if((w2 < r->w) || (w1 < r->w / 2)) + return TextCursorAt(text, px); + else if(w1 < w2 - r->w / 2) + return TextCursorAt(text, px + w1 - (r->w / 2)); + else + return TextCursorAt(text, px + w2 - r->w); +} diff --git a/graphics/sofont.h b/graphics/sofont.h new file mode 100644 index 0000000..4cf62e1 --- /dev/null +++ b/graphics/sofont.h @@ -0,0 +1,103 @@ + /* + SoFont - SDL Object Font Library + + 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 + + Originally from C Library: + Karl Bartel + +* SFONT - SDL Font Library by Karl Bartel * +* * +* All functions are explained below. There are two versions of each * +* funtction. The first is the normal one, the function with the * +* 2 at the end can be used when you want to handle more than one font * +* in your program. * +* * + + Copied into a C++ object to allow multiple fonts by: + Luc-Olivier de Charriere + + David Olofson : + * Strings changed to 'const char *' + * Cursor tests first check if '|' is present. + * Shadowed variables fixed. + * Garbage data in spacing table fixed. (Thanks to + Andreas Spångberg for discovering this one!) + * Added ExtraSpace(). (Scaling support hack...) + * Disabled colorkeying. (Ruins some RGBA fonts!) +*/ + +#ifndef __SOFONT_H +#define __SOFONT_H + +#include "glSDL.h" + +class SoFont +{ +public: + SoFont(); + ~SoFont(); + + bool load(SDL_Surface *FontSurface); + + // Blits a string to a surface + // Destination: the suface you want to blit to + // text: a string containing the text you want to blit. + void PutString(SDL_Surface *Surface, int x, int y, const char *text, SDL_Rect *clip=NULL); + void PutStringWithCursor(SDL_Surface *Surface, int x, int y, const char *text, int cursPos, SDL_Rect *clip=NULL, bool showCurs=true); + + // Returns the width of "text" in pixels + int TextWidth(const char *text, int min=0, int max=255); + + int FontHeight() { return height; } + + // Blits a string to with centered x position + void XCenteredString(SDL_Surface *Surface, int y, const char *text, SDL_Rect* clip=NULL); + // Blits a string to with centered x & y position + void CenteredString(SDL_Surface *Surface, const char *text, SDL_Rect* clip=NULL); + // Blits a string to with centered around x & y positions + void CenteredString(SDL_Surface *Surface, int x, int y, const char *text, SDL_Rect* clip=NULL); + + // This was specially developped for GUI + void PutStringCleverCursor(SDL_Surface *Surface, const char *text, int cursPos, SDL_Rect *r, SDL_Rect* clip=NULL, bool showCurs=true); + + // Gives the cursor position given a x-axix point in the text + int TextCursorAt(const char *text, int px); + int CleverTextCursorAt(const char *text, int px, int cursPos, SDL_Rect *r); + +# define START_CHAR 33 + int getMinChar(){return START_CHAR;} + int getMaxChar(){return max_i;} + + void ExtraSpace(int xs) + { + xspace = xs; + } + +protected: + int height; + SDL_Surface *picture; + int *CharPos; + int *CharOffset; + int *Spacing; + int xspace; + + int max_i, spacew, cursShift; + Uint32 background; + bool DoStartNewChar(Sint32 x); + void CleanSurface(); +}; + +#endif diff --git a/graphics/sprite.c b/graphics/sprite.c new file mode 100644 index 0000000..bb3c582 --- /dev/null +++ b/graphics/sprite.c @@ -0,0 +1,612 @@ +/*(LGPL) +---------------------------------------------------------------------- + sprite.c - Sprite engine for use with cs.h +---------------------------------------------------------------------- + * Copyright (C) 2001, 2003, 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* +TODO: Automatic extension of the bank and sprite +TODO: tables as needed when loading banks. +*/ + +#define DBG(x) x + +#include +#include +#include "logger.h" +#include "glSDL.h" +#include "SDL_image.h" +#include "sprite.h" +#include "filters.h" + + +s_blitmodes_t s_blitmode = S_BLITMODE_AUTO; +pix_t s_colorkey = {0, 0, 0, 0}; +pix_t s_clampcolor = {0, 0, 0, 0}; +unsigned char s_alpha = SDL_ALPHA_OPAQUE; +int s_filter_flags = 0; + + +s_filter_t *filters = NULL; + + +/* +---------------------------------------------------------------------- + Filter Plugin Interface +---------------------------------------------------------------------- + */ + +s_filter_t *s_insert_filter(s_filter_cb_t callback) +{ + s_filter_t *nf = calloc(1, sizeof(s_filter_t)); + if(!nf) + return NULL; + + nf->callback = callback; + nf->next = filters; + filters = nf; + return nf; +} + + +s_filter_t *s_add_filter(s_filter_cb_t callback) +{ + s_filter_t *nf = calloc(1, sizeof(s_filter_t)); + if(!nf) + return NULL; + + nf->callback = callback; + if(!filters) + filters = nf; + else + { + s_filter_t *f = filters; + while(f->next) + f = f->next; + f->next = nf; + } + return nf; +} + + +/* filter == NULL means "remove all plugins" */ +void s_remove_filter(s_filter_t *filter) +{ + s_filter_t *f; + if(!filters) + return; + + f = filters; + while(f->next) + { + if(f->next == filter || !filter) + { + s_filter_t *df = f->next; + f->next = f->next->next; + free(df); + } + else + f = f->next; + } + if(filters == filter || !filter) + { + s_filter_t *df = filters; + filters = filters->next; + free(df); + } +} + + +static void __run_plugins(s_bank_t *b, unsigned first, unsigned frames) +{ + s_filter_t *f = filters; + while(f) + { + int oflags = f->args.flags; + f->args.flags |= s_filter_flags; + f->callback(b, first, frames, &f->args); + f->args.flags = oflags; + f = f->next; + } +} + + +/* +---------------------------------------------------------------------- + Basic Container Management +---------------------------------------------------------------------- + */ + +static int __alloc_bank_table(s_container_t *c, unsigned int count) +{ + c->max = count - 1; + c->banks = (s_bank_t **)calloc((unsigned)count, sizeof(s_bank_t *)); + return -(c->banks == NULL); +} + +s_container_t *s_new_container(unsigned banks) +{ + s_container_t *ret = (s_container_t *)calloc(1, sizeof(s_container_t)); + if(!ret) + return NULL; + if(__alloc_bank_table(ret, banks) < 0) + return NULL; + return ret; +} + +void s_delete_container(s_container_t *c) +{ + s_delete_all_banks(c); + free(c->banks); + free(c); +} + + +/* + * Allocates a new sprite. + * If the sprite exists already, it's surface will be removed, so + * that one can safely expect to get an *empty* sprite. + */ +s_sprite_t *s_new_sprite_b(s_bank_t *b, unsigned frame) +{ + s_sprite_t *s = NULL; + if(frame > b->max) + return NULL; + if(!b->sprites[frame]) + { + s = calloc(1, sizeof(s_sprite_t)); + if(!s) + return NULL; + b->sprites[frame] = s; + } + else + { + if(s->surface) + SDL_FreeSurface(s->surface); + s->surface = NULL; + } + return s; +} + + +/* + * Allocates a new sprite. + * If the sprite exists already, it's surface will be removed, so + * that one can safely expect to get an *empty* sprite. + * + * If the bank does not exist, or if the operation failed for + * other reasons, this call returns NULL. + */ +s_sprite_t *s_new_sprite(s_container_t *c, unsigned bank, unsigned frame) +{ + if(bank > c->max) + return NULL; + if(!c->banks[bank]) + return NULL; + + return s_new_sprite_b(c->banks[bank], frame); +} + + +void s_delete_sprite_b(s_bank_t *b, unsigned frame) +{ + if(!b->sprites) /* This can happen when failing to create a new bank */ + return; + if(frame > b->max) + return; + if(!b->sprites[frame]) + return; + if(b->sprites[frame]->surface) + SDL_FreeSurface(b->sprites[frame]->surface); + b->sprites[frame]->surface = NULL; + free(b->sprites[frame]); + b->sprites[frame] = NULL; +} + + +void s_delete_sprite(s_container_t *c, unsigned bank, unsigned frame) +{ + s_bank_t *b = s_get_bank(c, bank); + if(b) + s_delete_sprite_b(b, frame); +} + + +static int __alloc_sprite_table(s_bank_t *b, unsigned frames) +{ + b->max = frames - 1; + b->sprites = (s_sprite_t **)calloc(frames, sizeof(s_sprite_t *)); + if(!b->sprites) + return -1; + return 0; +} + + +s_bank_t *s_new_bank(s_container_t *c, unsigned bank, unsigned frames, + unsigned w, unsigned h) +{ + s_bank_t *b; + DBG(log_printf(DLOG, "s_new_bank(%p, %d, %d, %d, %d)\n", + c, bank, frames, w, h);) + if(bank > c->max) + return NULL; + if(c->banks[bank]) + s_delete_bank(c, bank); + + c->banks[bank] = (s_bank_t *)calloc(1, sizeof(s_bank_t)); + if(!c->banks[bank]) + return NULL; + if(__alloc_sprite_table(c->banks[bank], frames) < 0) + { + s_delete_bank(c, bank); + return NULL; + } + b = c->banks[bank]; + b->max = frames - 1; + b->w = w; + b->h = h; + return b; +} + + +void s_delete_bank(s_container_t *c, unsigned bank) +{ + unsigned i; + s_bank_t *b; + if(!c->banks) + return; + if(bank > c->max) + return; + b = c->banks[bank]; + if(b) + { + for(i = 0; i <= b->max; ++i) + s_delete_sprite_b(b, i); + free(b->sprites); + free(b); + c->banks[bank] = NULL; + } +} + + +void s_delete_all_banks(s_container_t *c) +{ + unsigned i; + for(i = 0; i <= c->max; ++i) + s_delete_bank(c, i); +} + + + +/* +---------------------------------------------------------------------- + Getting data +---------------------------------------------------------------------- + */ + +s_bank_t *s_get_bank(s_container_t *c, unsigned bank) +{ + if(bank > c->max) + return NULL; + if(!c->banks[bank]) + return NULL; + return c->banks[bank]; +} + +s_sprite_t *s_get_sprite(s_container_t *c, unsigned bank, unsigned frame) +{ + s_bank_t *b = s_get_bank(c, bank); + if(!b) + return NULL; + if(frame > b->max) + return NULL; + return b->sprites[frame]; +} + +s_sprite_t *s_get_sprite_b(s_bank_t *b, unsigned frame) +{ + if(!b) + return NULL; + if(frame > b->max) + return NULL; + return b->sprites[frame]; +} + +void s_detach_sprite(s_container_t *c, unsigned bank, unsigned frame) +{ + s_sprite_t *s = s_get_sprite(c, bank, frame); + if(!s) + return; + s->surface = NULL; +} + + +/* +---------------------------------------------------------------------- + File tools +---------------------------------------------------------------------- + */ + +static int extract_sprite(s_bank_t *bank, unsigned frame, + SDL_Surface *src, SDL_Rect *from) +{ + int y; + SDL_Surface *tmp; + if(frame > bank->max) + { + log_printf(ELOG, "sprite: Too many frames!\n"); + return -1; + } + if(!s_new_sprite_b(bank, frame)) + return -2; + + tmp = SDL_CreateRGBSurface(src->flags, + from->w, from->h, + src->format->BitsPerPixel, + src->format->Rmask, + src->format->Gmask, + src->format->Bmask, + src->format->Amask ); + if(!tmp) + return -3; + + /* Copy the pixel data */ + if(SDL_LockSurface(src) < 0) + { + log_printf(ELOG, "sprite: extract_sprite() failed to lock surface!\n"); + SDL_FreeSurface(tmp); + return -4; + } + for(y = 0; y < tmp->h; ++y) + { + char *s = (char *)src->pixels + src->pitch * (y + from->y) + + from->x * src->format->BytesPerPixel; + char *d = (char *)tmp->pixels + tmp->pitch * y; + memcpy(d, s, src->format->BytesPerPixel * tmp->w); + } + SDL_UnlockSurface(src); + + /* Copy palette, if any */ + if(src->format->palette) + SDL_SetColors(tmp, src->format->palette->colors, 0, + src->format->palette->ncolors); + + /* Copy alpha and colorkey */ + if(src->flags & SDL_SRCALPHA) + SDL_SetAlpha(tmp, src->flags & (SDL_SRCALPHA | SDL_RLEACCEL), + src->format->alpha); + if(src->flags & SDL_SRCCOLORKEY) + SDL_SetColorKey(tmp, src->flags & (SDL_SRCCOLORKEY | SDL_RLEACCEL), + src->format->colorkey); + + bank->sprites[frame]->surface = tmp; + + DBG(log_printf(DLOG, "image %d: (%d,%d)/%dx%d @ %p\n", frame, + from->x, from->y, from->w, from->h, + bank->sprites[frame]->surface);) + return 0; +} + + +int s_copy_rect(s_container_t *c, unsigned bank, + unsigned frombank, unsigned fromframe, SDL_Rect *from) +{ +#if 0 + s_filter_args_t args; +#endif + SDL_Surface *src; + s_sprite_t *s; + s_bank_t *b; + + /* Get source image */ + s = s_get_sprite(c, frombank, fromframe); + if(!s) + { + log_printf(ELOG, "sprite: Couldn't get source sprite %d:%d!\n", + frombank, fromframe); + return -1; + } + src = s->surface; + if(!src) + { + log_printf(ELOG, "sprite: Sprite %d:%d" + " does not have a surface!\n", + frombank, fromframe); + return -2; + } + + /* Create destination bank */ + b = s_new_bank(c, bank, 1, from->w, from->h); + if(!b) + { + log_printf(ELOG, "sprite: Failed to allocate bank %d!\n", bank); + return -3; + } + + if(extract_sprite(b, 0, src, from) < 0) + { + log_printf(ELOG, "sprite: Something went wrong while " + "copying from sprite %d:%d.\n", + frombank, fromframe); + return -4; + } +#if 0 + memset(&args, 0, sizeof(args)); + args.x = 0; + s_filter_displayformat(b, 0, 1, &args); +#endif + return 0; +} + + +int s_load_image(s_container_t *c, unsigned bank, const char *name) +{ + SDL_Surface *src; + s_bank_t *b; + + src = IMG_Load(name); + if(!src) + { + log_printf(ELOG, "sprite: Failed to load sprite \"%s\"!\n", name); + return -1; + } + + b = s_new_bank(c, bank, 1, src->clip_rect.w, src->clip_rect.h); + if(!b) + { + log_printf(ELOG, "sprite: Failed to allocate bank for \"%s\"!\n", name); + return -2; + } + + if(extract_sprite(b, 0, src, &src->clip_rect) < 0) + { + log_printf(ELOG, "sprite: Something went wrong while" + " extracting sprite \"%s\".\n", name); + return -3; + } + + SDL_FreeSurface(src); + __run_plugins(b, 0, 1); + return 0; +} + + +int s_load_sprite(s_container_t *c, unsigned bank, unsigned frame, + const char *name) +{ + SDL_Surface *src; + SDL_Rect from; + s_bank_t *b = s_get_bank(c, bank); + if(!b) + { + log_printf(ELOG, "sprite: While loading \"%s\":" + " Bank %d does not exist!\n", name, bank); + return -2; + } + + src = IMG_Load(name); + if(!src) + { + log_printf(ELOG, "sprite: Failed to load sprite \"%s\"!\n", name); + return -1; + } + + from = src->clip_rect; + if( (from.w != b->w) || (from.h != b->h) ) + { + log_printf(ELOG, "sprite: Warning: Sprite \"%s\" cropped" + " to fit in bank %d.\n", name, bank); + from.w = b->w; + from.h = b->h; + } + + if(extract_sprite(b, frame, src, &from) < 0) + { + log_printf(ELOG, "sprite: Something went wrong while" + " extracting sprite \"%s\".\n", name); + return -3; + } + + SDL_FreeSurface(src); + __run_plugins(b, frame, 1); + return 0; +} + + +int s_load_bank(s_container_t *c, unsigned bank, unsigned w, unsigned h, + const char *name) +{ + SDL_Surface *src; + s_bank_t *b; + int x, y; + unsigned frame = 0; + unsigned frames; + + DBG(log_printf(DLOG, "s_load_bank(%p, %d, %d, %d, %s)\n", + c, bank, w, h, name);) + + src = IMG_Load(name); + if(!src) + { + log_printf(ELOG, "sprite: Failed to load sprite palette %s!\n", name); + return -1; + } + + if(w > src->w) + { + log_printf(ELOG, "sprite: Source image %s not wide enough!\n", name); + return -4; + } + + if(h > src->h) + { + log_printf(ELOG, "sprite: Source image %s not high enough!\n", name); + return -5; + } + + frames = (src->w / w) * (src->h / h); + b = s_new_bank(c, bank, frames, w, h); + if(!b) + { + log_printf(ELOG, "sprite: Failed to allocate bank for \"%s\"!\n", name); + return -2; + } + for(y = 0; y <= src->h - h; y += h) + for(x = 0; x <= src->w - w; x += w) + { + SDL_Rect r; + r.x = x; + r.y = y; + r.w = w; + r.h = h; + if(extract_sprite(b, frame, src, &r) < 0) + { + log_printf(ELOG, "sprite: Something went wrong while" + " extracting sprites.\n"); + return -3; + } + ++frame; + } + SDL_FreeSurface(src); + __run_plugins(b, 0, frames); + return 0; +} + + +int s_set_hotspot(s_container_t *c, unsigned bank, int frame, int x, int y) +{ + if(frame < 0) + { + frame = 0; + while(1) + { + s_sprite_t *s = s_get_sprite(c, bank, frame++); + if(!s) + break; + s->x = x; + s->y = y; + } + } + else + { + s_sprite_t *s = s_get_sprite(c, bank, frame); + s->x = x; + s->y = y; + } + return 0; +} diff --git a/graphics/sprite.h b/graphics/sprite.h new file mode 100644 index 0000000..6897cdc --- /dev/null +++ b/graphics/sprite.h @@ -0,0 +1,242 @@ +/*(LGPL) +---------------------------------------------------------------------- + sprite.h - Sprite engine for use with cs.h +---------------------------------------------------------------------- + * Copyright (C) 2001, 2003, 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _SPRITE_H_ +#define _SPRITE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "glSDL.h" + +typedef enum +{ + S_BLITMODE_AUTO = 0, /* Use source alpha if present */ + S_BLITMODE_OPAQUE, /* Alpha: blend over black during conv. */ + S_BLITMODE_COLORKEY, /* Like OPAQUE, but apply colorkey to the result */ + S_BLITMODE_ALPHA /* Apply source alpha during conv, + * then use full surface alpha */ +} s_blitmodes_t; + +struct s_container_t; + +/* sprite image */ +typedef struct +{ + int x, y; /* kern or hot-spot*/ +#if 0 +/* TODO TODO TODO TODO TODO TODO */ + struct + { + int x, y, w, h; /* spacing or collision rect */ + } logic; +/* /TODO TODO TODO TODO TODO TODO */ +#endif + SDL_Surface *surface; +} s_sprite_t; + +/* Bank of sprite images */ +typedef struct +{ +#if 0 +/* TODO TODO TODO TODO TODO TODO */ + struct s_container_t *container; + int index; /* Index of this bank */ +/* /TODO TODO TODO TODO TODO TODO */ +#endif + unsigned w, h; /* Same size for all sprites in bank! */ + unsigned last; + unsigned max; + s_sprite_t **sprites; +} s_bank_t; + +/* Two dimensionally indexed sprite container */ +typedef struct s_container_t +{ + unsigned max; + s_bank_t **banks; +} s_container_t; + + +/* + * Basic Container Management + */ +s_container_t *s_new_container(unsigned banks); +void s_delete_container(s_container_t *c); + +s_bank_t *s_new_bank(s_container_t *c, unsigned bank, unsigned frames, + unsigned w, unsigned h); +void s_delete_bank(s_container_t *c, unsigned bank); +void s_delete_all_banks(s_container_t *c); + +s_sprite_t *s_new_sprite(s_container_t *c, unsigned bank, unsigned frame); +void s_delete_sprite(s_container_t *c, unsigned bank, unsigned frame); + +/* + * Getting data + */ +s_sprite_t *s_get_sprite(s_container_t *c, unsigned bank, unsigned frame); +/* Detach sprite image from the manager. */ +void s_detach_sprite(s_container_t *c, unsigned bank, unsigned frame); + +/* + * File Import Tools + * (Will run plugins as files are loaded!) + */ +int s_load_image(s_container_t *c, unsigned bank, const char *name); +int s_load_bank(s_container_t *c, unsigned bank, unsigned w, unsigned h, + const char *name); +int s_load_sprite(s_container_t *c, unsigned bank, unsigned frame, + const char *name); + +/* + * Rendering Tools + */ +int s_generate_bank(s_container_t *c, unsigned bank, unsigned w, unsigned h, + const char *name); + +/* + * Sprite metadata + */ +/* Set sprite hotspot. Pass -1 for 'frame' to set hotspot for all frames. */ +int s_set_hotspot(s_container_t *c, unsigned bank, int frame, int x, int y); + + +/* + * Internal data manipulation API + * (Will not automatically run plugins.) + */ +int s_copy_rect(s_container_t *c, unsigned bank, + unsigned frombank, unsigned fromframe, SDL_Rect *from); + +/* + * Lower level interfaces + */ +s_bank_t *s_get_bank(s_container_t *c, unsigned bank); +s_sprite_t *s_get_sprite_b(s_bank_t *b, unsigned frame); +s_sprite_t *s_new_sprite_b(s_bank_t *b, unsigned frame); +void s_delete_sprite_b(s_bank_t *b, unsigned frame); + + +/* + * Filter Plugin Interface + * + * Rules: + * * Plugins are called to process one bank at a time, + * after new frames have been loaded. + * + * * Plugins are called in the order they were + * registered. + * + * * Plugins may replace the surfaces of sprites. If + * they do so, they're responsible for disposing of + * the old surfaces. + * + * * It is recommended that plugins operate only on + * the specified range of frames in a bank. + * + * * The surface size of all sprites in a bank should + * preferably match that of the bank. A chain of + * plugins may break this rule temporarily, as long + * as "order is restored" (ie surfaces are resized, or + * bank size values is adjusted) before the chain ends. + * + * Cool plugin ideas: + * * Rotator: + * Takes a bank and generates N rotated versions of + * each sprite. + * + * * Bumpmapper: + * Takes a bank and applies light, shadows, highlights + * and stuff to frames that have bumpmap channels. + * (Q: Where do we put bumpmaps? Extend the bank to + * twice the # of frames, using the last half for BMs? + * Use two banks? I think we need an API change that + * make plugins operators; X = A B, where the + * banks X, A and B are arguments.) + * + * * Mixer: + * A plugin that takes two banks and performs various + * operations between them to produce the output. + * + * * Colorizer: + * Converts images to HSV and then replaces hue with + * a fixed color. + * + * * Map Colorizer: + * Like Colorizer, but uses a (wrapping) source image + * as a map to determine the new hue for each pixel. + * + * * Tiled Stretch: + * Given a list of tile interdependencies, generate + * all tiles required for seamless rendering of the + * map for which the interdependency list was generated. + */ +typedef struct s_filter_args_t +{ + int x, y, z; + float fx, fy, fz; + int min, max; + short r, g, b; + int flags; + unsigned bank; + void *data; +} s_filter_args_t; + +typedef int (*s_filter_cb_t)(s_bank_t *b, unsigned first, unsigned frames, + s_filter_args_t *args); + +typedef struct s_filter_t +{ + struct s_filter_t *next; + s_filter_cb_t callback; + s_filter_args_t args; +} s_filter_t; + +s_filter_t *s_insert_filter(s_filter_cb_t callback); +s_filter_t *s_add_filter(s_filter_cb_t callback); +/* callback == NULL means "remove all plugins" */ +void s_remove_filter(s_filter_t *filter); + +/* RGBA pixel type (used internally by most filters as well) */ +typedef struct +{ + Uint8 r; + Uint8 g; + Uint8 b; + Uint8 a; +} pix_t; + +/* + * UURGH!!! This should be OO like the rest... + */ +extern s_blitmodes_t s_blitmode; +extern pix_t s_colorkey; /* NOTE: Alpha is ignored! */ +extern pix_t s_clampcolor; +extern unsigned char s_alpha; +extern int s_filter_flags; /* Global flags; applied to all plugins. */ + +#ifdef __cplusplus +}; +#endif + +#endif /* _SPRITE_H_ */ diff --git a/graphics/toolkit.cpp b/graphics/toolkit.cpp new file mode 100644 index 0000000..d1a1f06 --- /dev/null +++ b/graphics/toolkit.cpp @@ -0,0 +1,764 @@ +/*(LGPL) +--------------------------------------------------------------------------- + toolkit.cpp - Simple "GUI" toolkit for config screens. +--------------------------------------------------------------------------- + * Copyright (C) 2001 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "config.h" + +#include +#include + +#include "window.h" +#include "toolkit.h" + + + +/*---------------------------------------------------------- + ct_widget_t:: +----------------------------------------------------------*/ + +ct_widget_t::ct_widget_t() +{ + interactive = 0; + transparent = 1; + highlighted = 0; + user = NULL; + user2 = 0; + tag = 0; + _color = 0; + next = prev = NULL; + _widget_index = -1; + halign(ALIGN_DEFAULT); + valign(ALIGN_DEFAULT); + _token = 0; + xo = yo = 0.0; +} + + +void ct_widget_t::halign(ct_align_t ha) +{ + if(ALIGN_DEFAULT == ha) + _halign = ALIGN_RIGHT; + else + _halign = ha; +} + + +void ct_widget_t::valign(ct_align_t va) +{ + if(ALIGN_DEFAULT == va) + _valign = ALIGN_TOP; + else + _valign = va; +} + + +void ct_widget_t::init(gfxengine_t *e) +{ + window_t::init(e); + _color = map_rgb(0,0,0); +} + + +void ct_widget_t::transparency(int t) +{ + if(t == transparent) + return; + + transparent = t; + if(!transparent) + render(); +} + + +void ct_widget_t::highlight(int hl) +{ + if(hl == highlighted) + return; + + highlighted = hl; + if(!transparent) + render(); +} + + +void ct_widget_t::color(Uint32 _cl) +{ + if(_cl == _color) + return; + + _color = _cl; + if(!transparent) + render(); +} + + +void ct_widget_t::render() +{ + if(!transparent) + { + foreground(_color); + fillrect(0, 0, width(), height()); + } + if(highlighted) + ct_engine.render_highlight(this); +} + + +/* Handy tool function used by some descendents. */ +void ct_widget_t::render_text_aligned(const char *buf) +{ + int yy = 0; + switch(_valign) + { + case ALIGN_DEFAULT: //dummy + case ALIGN_NONE: + case ALIGN_TOP: + yy = yoffs(); + break; + case ALIGN_BOTTOM: + yy = height() - fontheight() - yoffs(); + break; + case ALIGN_CENTER: + case ALIGN_CENTER_TOKEN: + yy = (height() - fontheight()) / 2 + yoffs(); + break; + } + switch(_halign) + { + case ALIGN_DEFAULT: //dummy + case ALIGN_NONE: + case ALIGN_LEFT: + string(xoffs(), yy, buf); + break; + case ALIGN_RIGHT: + center_token(width() - xoffs(), yy, buf); + break; + case ALIGN_CENTER: + center_token(xoffs(), yy, buf, -1); + break; + case ALIGN_CENTER_TOKEN: + center_token(xoffs(), yy, buf, _token); + break; + } +} + + +void ct_widget_t::change(int delta) +{ + _value += delta; +} + + +void ct_widget_t::value(int val) +{ + _value = val; +} + + +int ct_widget_t::value() +{ + return _value; +} + + + +/*---------------------------------------------------------- + ct_engine_t:: +----------------------------------------------------------*/ + +void default_render_highlight(ct_widget_t *wg) +{ + Uint32 hlc[6]; + hlc[0] = wg->map_rgb(0x440000); + hlc[1] = wg->map_rgb(0x660000); + hlc[2] = wg->map_rgb(0x880000); + hlc[3] = wg->map_rgb(0x990000); + hlc[4] = wg->map_rgb(0xaa0000); + hlc[5] = wg->map_rgb(0xbb0000); + wg->foreground(hlc[5]); + wg->fillrect(0, 6, wg->width(), wg->height()-6-1); + for(int i = 0; i < 6; ++i) + { + wg->foreground(hlc[i]); + wg->fillrect(0, i, wg->width(), 1); + wg->fillrect(0, wg->height()-1-i, wg->width(), 1); + } +} + + +ct_engine_t::ct_engine_t() +{ + ct_engine.render_highlight = default_render_highlight; +} + + +ct_engine_t ct_engine; + + + +/*---------------------------------------------------------- + ct_label_t:: +----------------------------------------------------------*/ + +ct_label_t::ct_label_t(const char *cap) +{ + xo = 0.5; + if(cap) + caption(cap); + else + caption("Label"); +} + + +void ct_label_t::halign(ct_align_t ha) +{ + if(ALIGN_DEFAULT == ha) + _halign = ALIGN_CENTER; + else + _halign = ha; +} + + +void ct_label_t::caption(const char *cap) +{ + strncpy(_caption, cap, sizeof(_caption)); + _caption[sizeof(_caption)-1] = 0; + if(!transparent) + render(); +} + + +void ct_label_t::render() +{ + ct_widget_t::render(); + render_text_aligned(_caption); +} + + +/*---------------------------------------------------------- + ct_item_t:: +----------------------------------------------------------*/ + +ct_item_t::ct_item_t(const char *cap, int val) +{ + if(cap) + caption(cap); + else + caption("Item"); + _value = val; +} + + +void ct_item_t::caption(const char *cap) +{ + strncpy(_caption, cap, sizeof(_caption)); + _caption[sizeof(_caption)-1] = 0; +} + + +static ct_item_t dummy_item("", -1); + + +/*---------------------------------------------------------- + ct_list_t:: +----------------------------------------------------------*/ + +ct_list_t::ct_list_t(const char *cap) : ct_label_t(cap) +{ + interactive = 1; + if(cap) + caption(cap); + else + caption("List"); + items = NULL; + _selected = NULL; + + _token = ':'; + xo = 0.55; +} + + +ct_list_t::~ct_list_t() +{ + clean(); +} + + +void ct_list_t::halign(ct_align_t ha) +{ + if(ALIGN_DEFAULT == ha) + _halign = ALIGN_CENTER_TOKEN; + else + _halign = ha; +} + + +void ct_list_t::clean() +{ + if(!items) + return; + + /* + * Break the circular list first, or we'll + * blow up the memory manager...! :-) + */ + items->prev->next = NULL; + + while(items) + { + ct_item_t *i = items; + items = i->next; + delete i; + } + + items = NULL; + _selected = NULL; +} + + +void ct_list_t::add(ct_item_t *item) +{ + if(items) + { + item->next = items; + item->prev = items->prev; + items->prev->next = item; + items->prev = item; + } + else + { + item->next = item->prev = item; + items = item; + _selected = item; + if(!transparent) + render(); + } +} + + +void ct_list_t::add(const char *cap, int val) +{ + ct_item_t *it = new ct_item_t(cap, val); + add(it); +} + + +void ct_list_t::select(ct_item_t *item) +{ + _selected = item; +#if 0 + ct_item_t *i = items; + if(i) + for(int n = 0; n < 10000; ++n) //Just in case... + { + if(i == _selected) + { + _value = n; + break; + } + i = i->next; + } +#endif + if(_selected) + _value = _selected->value(); + if(!transparent) + render(); +} + + +void ct_list_t::select(int ind) +{ + if(!items) + return; + + _selected = items; + for(int i = 0; i < ind; ++i) + _selected = _selected->next; + select(_selected); //To update _value, render etc... +} + + +ct_item_t *ct_list_t::selected() +{ + if(!items) + return &dummy_item; + + return _selected; +} + + +void ct_list_t::value(int val) +{ + if(!items) + return; + + ct_item_t *best = items; + _selected = items; + while(_selected->value() != val) + { + if(labs(_selected->value()-val) < labs(best->value()-val)) + best = _selected; + if(_selected->next == items) + break; + _selected = _selected->next; + } + if(_selected->value() != val) + _selected = best; + select(_selected); //To update _value, render etc... +} + + +int ct_list_t::value() +{ + if(!items) + return dummy_item.value(); + if(_selected) + return _selected->value(); + else + return dummy_item.value(); +} + + +void ct_list_t::change(int delta) +{ + if(_selected) + { + if(0 == delta) + delta = 1; + if(delta > 0) + for(int i = 0; i < delta; ++i) + _selected = _selected->next; + else if(delta < 0) + for(int i = 0; i > delta; --i) + _selected = _selected->prev; + select(_selected); //To update _value, render etc... + } + ct_widget_t::change(delta); +} + + +void ct_list_t::render() +{ + char buf[128]; + const char *ic; + if(_selected) + ic = _selected->caption(); + else + ic = dummy_item.caption(); + ct_widget_t::render(); + snprintf(buf, sizeof(buf), "%s: %s", caption(), ic); + //center(0, buf); + //center_token(width()*3/5, 0, buf, ':'); + render_text_aligned(buf); +} + + + +/*---------------------------------------------------------- + ct_spin_t:: +----------------------------------------------------------*/ + +ct_spin_t::ct_spin_t(const char *cap, int _min, int _max, + const char *__unit) : ct_label_t(cap) +{ + interactive = 1; + min = _min; + max = _max; + _token = ':'; + xo = 0.55; + if(__unit) + unit(__unit); + else + unit(""); +} + + +void ct_spin_t::unit(const char *txt) +{ + strncpy(_unit, txt, sizeof(_unit)); + _unit[sizeof(_unit)-1] = 0; + if(!transparent) + render(); +} + + +void ct_spin_t::value(int val) +{ + val -= min; + while(val < 0) + val += max - min + 1; + val %= max - min + 1; + val += min; + ct_label_t::value(val); +} + + +void ct_spin_t::change(int delta) +{ + value(_value + delta); +} + + +void ct_spin_t::render() +{ + char buf[128]; + ct_widget_t::render(); + snprintf(buf, sizeof(buf), "%s: %d %s", caption(), _value, unit()); + //center(0, buf); + //center_token(width()*3/5, 0, buf, ':'); + render_text_aligned(buf); +} + + + +/*---------------------------------------------------------- + ct_button_t:: +----------------------------------------------------------*/ + +ct_button_t::ct_button_t(const char *cap) : ct_label_t(cap) +{ + interactive = 1; +} + + +void ct_button_t::render() +{ + ct_label_t::render(); +} + + +void ct_button_t::change(int delta) +{ + ct_label_t::change(delta); + if(!transparent) + render(); +} + + + +/*---------------------------------------------------------- + ct_form_t:: +----------------------------------------------------------*/ + +ct_form_t::ct_form_t() +{ + widgets = NULL; + _selected = NULL; +} + + +ct_form_t::~ct_form_t() +{ + if(!widgets) + return; + + /* + * Break the circular list first, or we'll + * blow up the memory manager...! :-) + */ + widgets->prev->next = NULL; + + while(widgets) + { + ct_widget_t *i = widgets; + widgets = i->next; + delete i; + } +} + + +void ct_form_t::add(ct_widget_t *widget) +{ + if(widgets) + { + widget->next = widgets; + widget->prev = widgets->prev; + widgets->prev->next = widget; + widgets->prev = widget; + widget->_widget_index = widget->prev->_widget_index + 1; + if(!_selected->interactive) + select(widget); + } + else + { + widget->_widget_index = 0; + widget->next = widget->prev = widget; + widgets = widget; + select(widget); + } + render_nontransparent(); +} + + +void ct_form_t::clean() +{ + if(!widgets) + return; + + /* + * Break the circular list first, or we'll + * blow up the memory manager...! :-) + */ + widgets->prev->next = NULL; + + while(widgets) + { + ct_widget_t *w = widgets; + widgets = w->next; + delete w; + } + + widgets = NULL; + _selected = NULL; +} + + +void ct_form_t::select(ct_widget_t *widget) +{ + if(_selected) + _selected->highlight(0); + _selected = widget; + if(_selected) + { + _selected->highlight(1); + if(!_selected->transparent) + _selected->render(); + } +} + + +void ct_form_t::select(int ind) +{ + if(!widgets) + return; + + if(!widgets) + return; + + ct_widget_t *sel = widgets; + for(int i = 0; i < ind; ++i) + sel = sel->next; + + int lim = 10000; + while(!sel->interactive) + { + if(!lim--) + break; + sel = sel->next; + } + select(sel); +} + + +void ct_form_t::next() +{ + if(!widgets) + return; + + if(!_selected) + { + select(0); + return; + } + + ct_widget_t *sel = _selected->next; + + int lim = 1000; + while(!sel->interactive) + { + if(!lim--) + break; + sel = sel->next; + } + select(sel); +} + + +void ct_form_t::prev() +{ + if(!widgets) + return; + + if(!_selected) + { + select(0); + return; + } + + ct_widget_t *sel = _selected->prev; + + int lim = 1000; + while(!sel->interactive) + { + if(!lim--) + break; + sel = sel->prev; + } + select(sel); +} + + +ct_widget_t *ct_form_t::selected() +{ + return _selected; +} + + +int ct_form_t::selected_index() +{ + if(_selected) + return _selected->_widget_index; + else + return -1; +} + + +void ct_form_t::change(int delta) +{ + if(_selected) + _selected->change(delta); +} + + +void ct_form_t::render() +{ + ct_widget_t *w = widgets; + while(w) + { + w->render(); + w = w->next; + if(w == widgets) + break; //Done! + } +} + + +void ct_form_t::render_nontransparent() +{ + ct_widget_t *w = widgets; + while(w) + { + if(!w->transparent) + w->render(); + w = w->next; + if(w == widgets) + break; //Done! + } +} diff --git a/graphics/toolkit.h b/graphics/toolkit.h new file mode 100644 index 0000000..46de69d --- /dev/null +++ b/graphics/toolkit.h @@ -0,0 +1,196 @@ +/*(LGPL) +--------------------------------------------------------------------------- + toolkit.h - Simple "GUI" toolkit for config screens. +--------------------------------------------------------------------------- + * Copyright (C) 2001, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * Note: change(0) means "apply", and would be the normal + * result of pressing enter while a widget is selected. + */ + +#include "window.h" + +enum ct_align_t +{ + ALIGN_DEFAULT = -1, + ALIGN_NONE = 0, + ALIGN_LEFT, + ALIGN_TOP = ALIGN_LEFT, + ALIGN_RIGHT, + ALIGN_BOTTOM = ALIGN_RIGHT, + ALIGN_CENTER, + ALIGN_CENTER_TOKEN +}; + +class ct_widget_t : public window_t +{ + protected: + friend class ct_form_t; + int interactive; + int transparent; + int highlighted; + Uint32 _color; + int _value; + int _widget_index; + ct_align_t _halign; + ct_align_t _valign; + char _token; + float xo, yo; //[0,1] maps to [0,width()]! + virtual void render(); + void render_text_aligned(const char *buf); + public: + ct_widget_t *next, *prev; //*CIRCULAR* list! + void *user; //user stuff + int user2; //user stuff + int tag; //user stuff + ct_widget_t(); + virtual void init(gfxengine_t *e); + void transparency(int t); + void highlight(int hl); + void color(Uint32 _cl); + virtual void change(int delta); + virtual void value(int val); + virtual int value(); + + //Contents alignment modes. + virtual void halign(ct_align_t ha); + virtual void valign(ct_align_t va); + ct_align_t halign() { return _halign; } + ct_align_t valign() { return _valign; } + + //Token and offsets- used by some alignment modes. + virtual void token(char tok) { _token = tok; } + char token() { return _token; } + virtual void offset(float x, float y) { xo = x; yo = y; } + int xoffs() { return (int)(xo * width()); } + int yoffs() { return (int)(yo * height()); } + float rxoffs() { return xo; } + float ryoffs() { return yo; } +}; + + +class ct_engine_t +{ + public: + ct_engine_t(); + void (*render_highlight)(ct_widget_t *wg); +}; + +extern ct_engine_t ct_engine; + + +class ct_label_t : public ct_widget_t +{ + protected: + char _caption[64]; + void render(); + public: + ct_label_t(const char *cap = NULL); + void caption(const char *cap); + const char *caption() { return _caption; } + virtual void halign(ct_align_t ha); +}; + + +class ct_item_t +{ + protected: + char _caption[64]; + int _index; + int _value; + public: + ct_item_t *next, *prev; //*CIRCULAR* list! + ct_item_t(const char *cap = NULL, int val = 0); + void caption(const char *cap); + const char *caption() { return _caption; } + void value(int val) { _value = val; } + int value() { return _value; } + void index(int i) { _index = i; } + int index() { return _index; } +}; + +class ct_list_t : public ct_label_t +{ + protected: + ct_item_t *items; + ct_item_t *_selected; + void render(); + public: + ct_list_t(const char *cap = NULL); + virtual ~ct_list_t(); + void add(ct_item_t *item); + void add(const char *cap, int val); + void clean(); + void select(ct_item_t *item); + void select(int ind); + ct_item_t *selected(); + void value(int val); + int value(); + void change(int delta); + virtual void halign(ct_align_t ha); +}; + + +class ct_spin_t : public ct_label_t +{ + protected: + int min; + int max; + char _unit[32]; + void render(); + public: + ct_spin_t(const char *cap = NULL, int _min = 0, int _max = 99999, + const char *__unit = NULL); + void value(int val); + void change(int delta); + void unit(const char *txt); + const char *unit() { return _unit; } +}; + + +class ct_button_t : public ct_label_t +{ + protected: + void render(); + public: + ct_button_t(const char *cap = NULL); + void change(int delta); +}; + + +class ct_form_t : public window_t +{ + protected: + ct_widget_t *widgets; + ct_widget_t *_selected; + public: + ct_form_t(); + virtual ~ct_form_t(); + void add(ct_widget_t *w); + void clean(); + virtual void select(ct_widget_t *w); + virtual void select(int ind); + virtual void next(); + virtual void prev(); + ct_widget_t *selected(); + int selected_index(); + void render(); + void render_nontransparent(); + virtual void change(int delta); +}; diff --git a/graphics/vidmodes.c b/graphics/vidmodes.c new file mode 100644 index 0000000..77403a0 --- /dev/null +++ b/graphics/vidmodes.c @@ -0,0 +1,193 @@ +/*(LGPL) +--------------------------------------------------------------------------- + vidmodes.c - Video Mode Manager for Kobo Deluxe +--------------------------------------------------------------------------- + * Copyright (C) 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "vidmodes.h" +#include +#include + +typedef struct VMM_IMode +{ + int flags, width, height, id; + const char *name; +} VMM_IMode; + +static VMM_IMode modetab[] = +{ + // 4:3 modes + {VMM_4_3 | VMM_PC, 320, 200, 0x04300, "CGA"}, + {VMM_4_3 | VMM_PC, 320, 240, 0x04301, "QVGA"}, + {VMM_4_3, 320, 256, 0x04302, "Amiga LoRes"}, + {VMM_4_3 | VMM_LORES, 400, 300, 0x04310, NULL}, + {VMM_4_3 | VMM_LORES, 512, 384, 0x04320, NULL}, + {VMM_4_3 | VMM_PC, 640, 480, 0x04330, "VGA"}, + {VMM_4_3, 640, 512, 0x04331, "Amiga HiRes"}, + {VMM_4_3 | VMM_TV, 768, 576, 0x04340, "PAL"}, + {VMM_4_3 | VMM_PC, 800, 600, 0x04350, NULL}, + {VMM_4_3 | VMM_LORES, 960, 720, 0x04360, NULL}, + {VMM_4_3 | VMM_PC, 1024, 768, 0x04370, "XGA"}, + {VMM_4_3 | VMM_PC, 1152, 864, 0x04380, NULL}, + {VMM_4_3 | VMM_PC, 1280, 960, 0x04390, NULL}, + {VMM_4_3 | VMM_PC, 1400, 1050, 0x043a0, "SXGA+"}, + {VMM_4_3 | VMM_PC, 1600, 1200, 0x043b0, "UXGA"}, + {VMM_4_3 | VMM_PC, 1920, 1440, 0x043c0, NULL}, + {VMM_4_3 | VMM_PC, 2048, 1536, 0x043d0, "QXGA"}, + + // 3:2 modes + {VMM_3_2 | VMM_LORES, 360, 240, 0x03200, NULL}, + {VMM_3_2 | VMM_LORES, 720, 480, 0x03240, "NTSC"}, + {VMM_3_2, 1152, 768, 0x03280, NULL}, + {VMM_3_2, 1280, 854, 0x03290, NULL}, + {VMM_3_2, 1440, 960, 0x032a0, NULL}, + + // 5:4 modes + {VMM_5_4 | VMM_LORES, 320, 256, 0x05400, "Amiga LoRes"}, + {VMM_5_4 | VMM_LORES, 640, 512, 0x05430, "Amiga HiRes"}, + {VMM_5_4 | VMM_PC, 1280, 1024, 0x05490, "SXGA"}, + {VMM_5_4, 2560, 2048, 0x054e0, "QSXGA"}, + + // 16:10 modes + {VMM_16_10 | VMM_LORES, 320, 200, 0x10a00, NULL}, + {VMM_16_10 | VMM_PC, 640, 400, 0x10a30, NULL}, + {VMM_16_10 | VMM_LORES, 840, 525, 0x10a50, NULL}, + {VMM_16_10 | VMM_PC, 1280, 800, 0x10a90, NULL}, + {VMM_16_10 | VMM_PC, 1680, 1050, 0x10ab0, "WSXGA+"}, + {VMM_16_10 | VMM_PC, 1920, 1200, 0x10ac0, "WUXGA"}, + {VMM_16_10 | VMM_PC, 2560, 1600, 0x10ae0, "WQXGA"}, + + // 16:9 modes + {VMM_16_9 | VMM_LORES, 480, 270, 0x10910, NULL}, + {VMM_16_9 | VMM_LORES, 678, 384, 0x10930, NULL}, + {VMM_16_9 | VMM_TV, 854, 480, 0x10950, "WVGA"}, + {VMM_16_9 | VMM_LORES, 960, 540, 0x10960, NULL}, + {VMM_16_9, 1280, 720, 0x10990, "HD 720"}, + {VMM_16_9 | VMM_TV, 1356, 768, 0x109a0, "Flat TV"}, + {VMM_16_9 | VMM_TV, 1920, 1080, 0x109c0, "HD 1080"}, + {VMM_16_9, 2560, 1440, 0x109e0, NULL}, + + // End of table + {0, 0, 0} +}; + + +/*------------------------------------------------------------------------- + Gathering and constructing modes +-------------------------------------------------------------------------*/ + +static VMM_Mode *vmm_modes = NULL; + +int vmm_Init(int show, int hide) +{ + int i; + VMM_Mode *lastm = NULL; + vmm_Close(); + +/* +TODO: Include detected SDL modes, if requested. + */ + + for(i = 0; modetab[i].width; ++i) + { + VMM_Mode *m; + double nominal_aspect; + VMM_IMode *im = &modetab[i]; + if(im->flags & hide) + continue; + if(!(im->flags & show)) + continue; + m = calloc(1, sizeof(VMM_Mode)); + if(!m) + return -1; /* Out of memory! */ + m->id = im->id; + m->width = im->width; + m->height = im->height; + m->flags = im->flags; + if(im->flags & VMM_3_2) + nominal_aspect = 3.0f / 2.0f; + else if(im->flags & VMM_5_4) + nominal_aspect = 5.0f / 4.0f; + else if(im->flags & VMM_16_10) + nominal_aspect = 16.0f / 10.0f; + else if(im->flags & VMM_16_9) + nominal_aspect = 16.0f / 9.0f; + else + nominal_aspect = 4.0f / 3.0f; + if(im->width) + m->aspect = nominal_aspect / im->width * im->height; + else + m->aspect = 1.0f; + if(im->name) + m->name = strdup(im->name); + if(lastm) + lastm->next = m; + else + vmm_modes = m; + lastm = m; + } + + return 0; +} + + +void vmm_Close(void) +{ + VMM_Mode *m = vmm_First(); + while(m) + { + VMM_Mode *dm = m; + m = vmm_Next(m); + free(dm->name); + free(dm); + } + vmm_modes = NULL; +} + + +/*------------------------------------------------------------------------- + Scanning +-------------------------------------------------------------------------*/ + +VMM_Mode *vmm_First(void) +{ + return vmm_modes; +} + + +VMM_Mode *vmm_Next(VMM_Mode *current) +{ + return current->next; +} + + +/*------------------------------------------------------------------------- + Indexing +-------------------------------------------------------------------------*/ + +VMM_Mode *vmm_FindMode(int id) +{ + VMM_Mode *m = vmm_First(); + while(m) + { + if(m->id == id) + return m; + m = vmm_Next(m); + } + return NULL; +} diff --git a/graphics/vidmodes.h b/graphics/vidmodes.h new file mode 100644 index 0000000..f7da560 --- /dev/null +++ b/graphics/vidmodes.h @@ -0,0 +1,93 @@ +/*(LGPL) +--------------------------------------------------------------------------- + vidmodes.h - Video Mode Manager for Kobo Deluxe +--------------------------------------------------------------------------- + * Copyright (C) 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef KOBO_VIDMODES_H +#define KOBO_VIDMODES_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/*------------------------------------------------------------------------- + Data Types and Structures +-------------------------------------------------------------------------*/ + +typedef enum +{ + VMM_ALL = 0xffffffff, + VMM_DETECT = 0x00000001, /* Available modes as detected by SDL */ + VMM_4_3 = 0x00000010, /* 4:3 modes */ + VMM_3_2 = 0x00000020, /* 3:2 modes */ + VMM_5_4 = 0x00000040, /* 5:4 modes */ + VMM_16_10 = 0x00000080, /* 16:10 modes */ + VMM_16_9 = 0x00000100, /* 16:9 modes */ + VMM_PC = 0x00010000, /* Standard PC/Mac modes */ + VMM_WPC = 0x00020000, /* Widescreen PC/Mac modes */ + VMM_TV = 0x00040000, /* Standard TV modes */ + VMM_WTV = 0x00080000, /* Widescreen TV modes */ + VMM_LORES = 0x10000000 /* Special low resolution modes */ +} VMM_Flags; + + +typedef struct VMM_Mode VMM_Mode; +struct VMM_Mode +{ + VMM_Mode *next; /* Next mode in list */ + char *name; /* Name, if any */ + int id; /* Somewhat constant mode ID */ + int width; /* Display width in pixels */ + int height; /* Display height in pixels */ + int flags; /* (WMM_Flags) */ + float aspect; /* Pixel aspect ratio */ +}; + + +/*------------------------------------------------------------------------- + Gathering and constructing modes +-------------------------------------------------------------------------*/ +int vmm_Init(int show, int hide); +void vmm_Close(void); + + +/*------------------------------------------------------------------------- + Scanning +-------------------------------------------------------------------------*/ +VMM_Mode *vmm_First(void); +VMM_Mode *vmm_Next(VMM_Mode *current); + + +/*------------------------------------------------------------------------- + Indexing +-------------------------------------------------------------------------*/ +VMM_Mode *vmm_FindMode(int id); + + +/*------------------------------------------------------------------------- + Searching +-------------------------------------------------------------------------*/ +/* TODO: VMM_Mode *vmm_Find(int width, int height, int aspect); */ + +#ifdef __cplusplus +}; +#endif + +#endif /* KOBO_VIDMODES_H */ diff --git a/graphics/window.cpp b/graphics/window.cpp new file mode 100644 index 0000000..9a889c7 --- /dev/null +++ b/graphics/window.cpp @@ -0,0 +1,654 @@ +/*(LGPL) +--------------------------------------------------------------------------- + window.cpp - Generic Rendering Window +--------------------------------------------------------------------------- + * Copyright (C) 2001-2003, 2006, 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "logger.h" +#include "window.h" +#include "gfxengine.h" +#include "sofont.h" + +#define SELECT if(selected != this) _select(); + +window_t *window_t::selected = NULL; + +window_t::window_t() +{ + engine = NULL; + surface = NULL; + next = NULL; + prev = NULL; + phys_rect.x = phys_rect.y = 0; + phys_rect.w = 320; + phys_rect.h = 240; + fgcolor = bgcolor = 0; + selected = 0; + xs = ys = 256; + bg_bank = -1; + bg_frame = -1; + _visible = 1; + _offscreen = 0; +} + + +window_t::~window_t() +{ + if(_offscreen && surface) + SDL_FreeSurface(surface); + if(selected == this) + selected = NULL; + unlink(); +} + + +void window_t::init(gfxengine_t *e) +{ + link(e); + xs = engine->xs; + ys = engine->ys; + if(_offscreen && surface) + { + SDL_FreeSurface(surface); + surface = NULL; + } + _offscreen = 0; + surface = engine->surface(); +} + + +void window_t::visible(int vis) +{ + if(_offscreen) + return; // Cannot be visible! + if(_visible == vis) + return; + _visible = vis; + invalidate(); +} + + +void window_t::link(gfxengine_t *e) +{ + unlink(); + engine = e; + next = NULL; + prev = engine->windows; + if(prev) + { + while(prev->next) + prev = prev->next; + prev->next = this; + } + else + engine->windows = this; +} + + +void window_t::unlink(void) +{ + if(engine) + { + if(engine->windows == this) + engine->windows = next; + if(engine->surface() == surface) + surface = NULL; + } + if(next) + next->prev = prev; + if(prev) + prev->next = next; +} + + +void window_t::place(int left, int top, int sizex, int sizey) +{ + int x2 = ((left + sizex) * xs + 128) >> 8; + int y2 = ((top + sizey) * ys + 128) >> 8; + phys_rect.x = (left * xs + 128) >> 8; + phys_rect.y = (top * ys + 128) >> 8; + phys_rect.w = x2 - phys_rect.x; + phys_rect.h = y2 - phys_rect.y; +} + + +int window_t::offscreen() +{ + if(!engine) + return -1; + if(!engine->surface()) + return -1; + if(_offscreen) + return 0; // Already offscreen! + visible(0); + _offscreen = 1; + SDL_Surface *s = SDL_CreateRGBSurface(SDL_SWSURFACE, + phys_rect.w, phys_rect.h, + 32, 0xff000000, 0x00ff0000, + 0x0000ff00, 0x000000ff); + if(!s) + return -1; + surface = SDL_DisplayFormat(s); + SDL_FreeSurface(s); + if(!surface) + return -1; + return 0; +} + + +void window_t::select() +{ + if(engine) + _select(); +} + + +void window_t::_select() +{ + SDL_Rect r = phys_rect; + selected = this; + if(surface) + SDL_SetClipRect(surface, &r); +} + + +void window_t::invalidate(SDL_Rect *r) +{ + if(!engine) + return; + if(!engine->surface()) + return; + + SELECT + + if(_offscreen) + { + if(!r) + { + SDL_Rect rr; + rr.x = 0; + rr.y = 0; + rr.w = phys_rect.w; + rr.h = phys_rect.h; + phys_refresh(&rr); + glSDL_Invalidate(surface, &rr); + } + else + { + phys_refresh(r); + glSDL_Invalidate(surface, r); + } + return; + } + + if(!r) + engine->invalidate(&phys_rect, this); + else + { + /* Translate to screen coordinates */ + SDL_Rect dr = *r; + dr.x = (dr.x * xs + 128) >> 8; + dr.y = (dr.y * ys + 128) >> 8; + dr.w = (((dr.w + dr.x) * xs + 128) >> 8) - dr.x; + dr.h = (((dr.h + dr.y) * ys + 128) >> 8) - dr.y; + dr.x += phys_rect.x; + dr.y += phys_rect.y; + + /* Clip to window (stolen from SDL_surface.c) */ + int Amin, Amax, Bmin, Bmax; + + /* Horizontal intersection */ + Amin = dr.x; + Amax = Amin + dr.w; + Bmin = phys_rect.x; + Bmax = Bmin + phys_rect.w; + if(Bmin > Amin) + Amin = Bmin; + dr.x = Amin; + if(Bmax < Amax) + Amax = Bmax; + dr.w = Amax - Amin > 0 ? Amax - Amin : 0; + + /* Vertical intersection */ + Amin = dr.y; + Amax = Amin + dr.h; + Bmin = phys_rect.y; + Bmax = Bmin + phys_rect.h; + if(Bmin > Amin) + Amin = Bmin; + dr.y = Amin; + if(Bmax < Amax) + Amax = Bmax; + dr.h = Amax - Amin > 0 ? Amax - Amin : 0; + + if(dr.w && dr.h) + engine->invalidate(&dr, this); + } +} + + +/*--------------------------------------------------------------- + Rendering API +---------------------------------------------------------------*/ + +Uint32 window_t::map_rgb(Uint8 r, Uint8 g, Uint8 b) +{ + if(!engine) + return 0; + + if(surface) + return SDL_MapRGB(surface->format, r, g, b); + else + return 0xffffff; +} + +Uint32 window_t::map_rgb(Uint32 rgb) +{ + if(!engine) + return 0; + + Uint8 r = (rgb >> 16) & 0xff; + Uint8 g = (rgb >> 8) & 0xff; + Uint8 b = rgb & 0xff; + + if(surface) + return SDL_MapRGB(surface->format, r, g, b); + else + return 0xffffff; +} + +void window_t::bgimage(int bank, int frame) +{ + bg_bank = bank; + bg_frame = frame; +} + + +void window_t::colorkey(Uint32 color) +{ + if(!engine) + return; + if(!engine->surface()) + return; + if(!_offscreen) + return; + SDL_SetColorKey(surface, SDL_SRCCOLORKEY, color); +} + +void window_t::colorkey() +{ + if(!engine) + return; + if(!engine->surface()) + return; + if(!_offscreen) + return; + SDL_SetColorKey(surface, 0, 0); +} + +void window_t::alpha(float a) +{ + if(!engine) + return; + if(!engine->surface()) + return; + if(!_offscreen) + return; + SDL_SetAlpha(surface, SDL_SRCALPHA, (int)(a * 255.0)); +} + + +void window_t::font(int fnt) +{ + _font = fnt; +} + + +void window_t::string(int _x, int _y, const char *txt) +{ + string_fxp(PIXEL2CS(_x), PIXEL2CS(_y), txt); +} + + +void window_t::center(int _y, const char *txt) +{ + center_fxp(PIXEL2CS(_y), txt); +} + + +void window_t::center_token(int _x, int _y, const char *txt, char token) +{ + center_token_fxp(PIXEL2CS(_x), PIXEL2CS(_y), txt, token); +} + + +void window_t::string_fxp(int _x, int _y, const char *txt) +{ + if(!engine) + return; + + _x = CS2PIXEL((_x * xs + 128) >> 8); + _y = CS2PIXEL((_y * ys + 128) >> 8); + SoFont *f = engine->get_font(_font); + if(!f) + return; + SELECT + _x += phys_rect.x; + _y += phys_rect.y; + if(surface) + f->PutString(surface, _x, _y, txt); +} + + +void window_t::center_fxp(int _y, const char *txt) +{ + _y = CS2PIXEL((_y * ys + 128) >> 8); + + if(!engine) + return; + + SoFont *f = engine->get_font(_font); + if(!f) + return; + SELECT + int _x = (phys_rect.w - f->TextWidth(txt) + 1) / 2; + _x += phys_rect.x; + _y += phys_rect.y; + if(surface) + f->PutString(surface, _x, _y, txt); +} + + +void window_t::center_token_fxp(int _x, int _y, const char *txt, char token) +{ + _x = CS2PIXEL((_x * xs + 128) >> 8); + _y = CS2PIXEL((_y * ys + 128) >> 8); + + if(!engine) + return; + + SoFont *f = engine->get_font(_font); + if(!f) + return; + SELECT + int _cx; + if(-1 == token) + _cx = _x - f->TextWidth(txt)/2; + else + { + int tokpos; + /* + * My docs won't say if strchr(???, 0) is legal + * or even defined, so I'm not taking any chances... + */ + if(token) + { + char *tok = strchr(txt, token); + if(tok) + tokpos = tok-txt; + else + tokpos = 255; + } + else + tokpos = 255; + _cx = _x - f->TextWidth(txt, 0, tokpos); + } + _cx += phys_rect.x; + _y += phys_rect.y; + if(surface) + f->PutString(surface, _cx, _y, txt); +} + + +int window_t::textwidth_fxp(const char *txt, int min, int max) +{ + if(!engine) + return strlen(txt); + + SoFont *f = engine->get_font(_font); + if(!f) + return strlen(txt); + + return (f->TextWidth(txt, min, max) << 16) / xs; +} + + +int window_t::textwidth(const char *txt, int min, int max) +{ + if(!engine) + return strlen(txt); + + SoFont *f = engine->get_font(_font); + if(!f) + return strlen(txt); + + return (f->TextWidth(txt, min, max) << 8) / xs; +} + + +int window_t::fontheight() +{ + if(!engine) + return 1; + + SoFont *f = engine->get_font(_font); + if(!f) + return 1; + + return (f->FontHeight() * 256) / ys; +} + + +void window_t::clear(SDL_Rect *r) +{ + SDL_Rect sr, dr; + if(!engine) + return; + if(!surface) + return; + SELECT + if(!r) + { + sr = phys_rect; + sr.x = 0; + sr.y = 0; + dr = phys_rect; + } + else + { + sr.x = ((int)r->x * xs + 128) >> 8; + sr.y = ((int)r->y * ys + 128) >> 8; + sr.w = (((int)(r->x + r->w) * xs + 128) >> 8) - sr.x; + sr.h = (((int)(r->y + r->h) * ys + 128) >> 8) - sr.y; + dr = sr; + dr.x += phys_rect.x; + dr.y += phys_rect.y; + } + if((-1 == bg_bank) && (-1 == bg_frame)) + SDL_FillRect(surface, &dr, bgcolor); + else + { + s_sprite_t *s = engine->get_sprite(bg_bank, bg_frame); + if(!s || !s->surface) + { + SDL_FillRect(surface, &dr, bgcolor); + return; + } + SDL_BlitSurface(s->surface, &sr, surface, &dr); + } +} + + +void window_t::point(int _x, int _y) +{ + int x2 = ((_x + 1) * xs + 128) >> 8; + int y2 = ((_y + 1) * ys + 128) >> 8; + _x = (_x * xs + 128) >> 8; + _y = (_y * ys + 128) >> 8; + + if(!engine) + return; + SELECT + /* Quick hack; slow */ + SDL_Rect r; + r.x = phys_rect.x + _x; + r.y = phys_rect.y + _y; + r.w = x2 - _x; + r.h = y2 - _y; + if(surface) + SDL_FillRect(surface, &r, fgcolor); +} + + +void window_t::fillrect(int _x, int _y, int w, int h) +{ + int x2 = ((_x + w) * xs + 128) >> 8; + int y2 = ((_y + h) * ys + 128) >> 8; + _x = (_x * xs + 128) >> 8; + _y = (_y * ys + 128) >> 8; + + if(!engine) + return; + SELECT + SDL_Rect r; + r.x = phys_rect.x + _x; + r.y = phys_rect.y + _y; + r.w = x2 - _x; + r.h = y2 - _y; + if(surface) + SDL_FillRect(surface, &r, fgcolor); +} + + +void window_t::rectangle(int _x, int _y, int w, int h) +{ + fillrect(_x, _y, w, 1); + fillrect(_x, _y + h - 1, w, 1); + fillrect(_x, _y + 1, 1, h - 2); + fillrect(_x + w - 1, _y + 1, 1, h - 2); +} + + +void window_t::fillrect_fxp(int _x, int _y, int w, int h) +{ + int xx = CS2PIXEL((_x * xs + 128) >> 8); + int yy = CS2PIXEL((_y * ys + 128) >> 8); + w = CS2PIXEL(((w + _x) * xs + 128) >> 8) - xx; + h = CS2PIXEL(((h + _y) * ys + 128) >> 8) - yy; + + if(!engine) + return; + SELECT + SDL_Rect r; + r.x = phys_rect.x + xx; + r.y = phys_rect.y + yy; + r.w = w; + r.h = h; + if(surface) + SDL_FillRect(surface, &r, fgcolor); +} + + +void window_t::sprite(int _x, int _y, int bank, int frame, int inval) +{ + sprite_fxp(PIXEL2CS(_x), PIXEL2CS(_y), bank, frame, inval); +} + + +void window_t::sprite_fxp(int _x, int _y, int bank, int frame, int inval) +{ + if(!engine) + return; + s_sprite_t *s = engine->get_sprite(bank, frame); + if(!s || !s->surface) + return; + _x = CS2PIXEL(((_x - (s->x << 8)) * xs + 128) >> 8); + _y = CS2PIXEL(((_y - (s->y << 8)) * ys + 128) >> 8); + SDL_Rect dest_rect; + + SELECT + dest_rect.x = phys_rect.x + _x; + dest_rect.y = phys_rect.y + _y; + if(surface) + SDL_BlitSurface(s->surface, NULL, surface, &dest_rect); + + if(inval && !engine->autoinvalidate()) + { + dest_rect.w = s->surface->w; + dest_rect.h = s->surface->h; + engine->invalidate(&dest_rect, this); + } +} + + +void window_t::blit(int dx, int dy, + int sx, int sy, int sw, int sh, window_t *src) +{ + if(!engine) + return; + if(!src) + return; + if(!surface) + return; + if(!src->surface) + return; + SELECT + + SDL_Rect src_rect; + int sx2 = ((sx + sw) * xs + 128) >> 8; + int sy2 = ((sy + sh) * ys + 128) >> 8; + src_rect.x = (sx * xs + 128) >> 8; + src_rect.y = (sy * ys + 128) >> 8; + src_rect.w = sx2 - src_rect.x; + src_rect.h = sy2 - src_rect.y; + + SDL_Rect dest_rect; + dest_rect.x = phys_rect.x + ((dx * xs + 128) >> 8); + dest_rect.y = phys_rect.y + ((dy * ys + 128) >> 8); + + SDL_BlitSurface(src->surface, &src_rect, surface, &dest_rect); +} + + +void window_t::blit(int dx, int dy, window_t *src) +{ + if(!engine) + return; + if(!src) + return; + if(!surface) + return; + if(!src->surface) + return; + + SELECT + dx = (dx * xs + 128) >> 8; + dy = (dy * ys + 128) >> 8; + + SDL_Rect src_rect; + src_rect.x = 0; + src_rect.y = 0; + src_rect.w = src->surface->w; + src_rect.h = src->surface->h; + + SDL_Rect dest_rect; + dest_rect.x = phys_rect.x + dx; + dest_rect.y = phys_rect.y + dy; + + SDL_BlitSurface(src->surface, &src_rect, surface, &dest_rect); +} diff --git a/graphics/window.h b/graphics/window.h new file mode 100644 index 0000000..702ec1d --- /dev/null +++ b/graphics/window.h @@ -0,0 +1,339 @@ +/*(LGPL) +--------------------------------------------------------------------------- + window.h - Generic Rendering Window +--------------------------------------------------------------------------- + * Copyright (C) 2001-2003, 2007 David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * Programmer's Documentation: + * The window_t class represents a simple window of the + * screen surface. It provides some high level rendering + * functions that operate inside the window's bounding + * rectangle. All operations are clipped. However, + * window occlusion is *not* handled, so you can't use + * this class for "real" windows. + * + * virtual void init(gfxengine_t *e); + * Call this to connect a window_t instance to + * the gfxengine_t instance that manages your + * screen. You *must* call this for pretty much + * any other calls to work. + * + * void place(int left, int top, int sizex, int sizey); + * Position the window on the screen. + * + * int offscreen(); + * Make this an off-screen window, with a + * surface of it's own for rendering. An off- + * screen window will never be directly visible, + * but can be used as a source window for blit(). + * May return -1 if there is an error. + * + * void select(); + * Makes this window active, and sets up SDL's + * clipping appropriately. You should not use + * this call normally, but it's provided to + * allow this engine to interface with other + * SDL code. + * + * void invalidate(SDL_Rect *r = NULL); + * Invalidate the specified area, or the whole + * window if r is NULL. This will ensure that + * any changes in the invalidated area are made + * visible on the screen. Note that this call + * may also indirectly cause one or more calls + * to refresh(). + * + * virtual void refresh(SDL_Rect *r); + * Virtual refresh call to be implemented by + * windows that aren't repainted every frame. + * After a call to invalidate(), refresh() will + * be called by the engine as necessary to + * produce a correct display. Note that in some + * cases, this means that refresh() will be + * called once for each screen flip, until all + * buffers (usually two) are up to date. Also + * note that you should do all rendering to the + * window either directly *or* in the refresh() + * function. + * + * Uint32 map_rgb(Uint8 r, Uint8 g, Uint8 b); + * Uint32 map_rgb(Uint32 rgb); + * Two different ways of translating a color in + * standard RGB format (separate components or + * HTML style hex code, respectively) into a + * pixel value compatible with the screen. + * + * void foreground(Uint32 color); + * void background(Uint32 color); + * Change the foreground and background colors + * used by subsequent rendering operations. + * Note that the arguments have to be in screen + * pixel format - the easiest way is to use the + * map_rgb() calls to generate the values. + * + * void bgimage(int bank, int frame); + * Select a background image, to use instead of + * a background color. Setting bank and frame to + * -1 (default) disables the image, so that the + * background color is used instead. + * + * void colorkey(Uint32 color); + * void colorkey(); + * Set the colorkey for this window to 'color' + * and enable colorkeying. This affects blit() + * when this window is used as the source. The + * version without arguments disables + * colorkeying for this window. + * NOTE: Colorkeying is only supported by + * offscreen windows. + * + * void alpha(float a); + * Set the full surface alpha of this window. + * 0.0 is fully transparent and 1.0 is opaque. + * NOTE: Alpha is only supported by offscreen + * windows. + * + * void clear(SDL_Rect *r = NULL); + * Fill the specified rectangle with the current + * background color or background image. If r is + * NULL (default), clear the whole window. + * + * void font(int fnt); + * Select the font to be used for subsequent + * text rendering operations. The argument is a + * gfxengine_t bank index, and must refer to a + * bank that has been loaded with + * gfxengine_t::loadfont(). + * + * void string(int _x, int _y, const char *txt); + * Put text string 'txt' starting at (_x, _y). + * + * void center(int _y, const char *txt); + * Put text string 'txt' centered horizontally + * inside the window, using '_y' as the y coord. + * + * void center_token(int _x, int _y, const char *txt, char token = 0); + * Print string 'txt', positioning it so that + * the first occurrence of character 'token' + * is located at (_x, _y). Omitting the 'token' + * argument, or passing 0 aligns the end of the + * string with _x. Setting 'token' to -1 results + * in the graphical center of the string being + * located at (_x, _y) - basically an advanced + * version of center(). + * + * void string_fxp(int _x, int _y, const char *txt); + * void center_fxp(int _y, const char *txt); + * void center_token_fxp(int _x, int _y, const char *txt, char token = 0); + * gfxengine_t fixed point format versions of + * the corresponding non-fxp calls. (For sub- + * pixel accurate rendering and/or to make use + * of the higher resolutions in scaled modes.) + * + * int textwidth(const char *txt, int min = 0, int max = 255); + * Calculates the graphical width of 'txt' if it + * was to be printed with the current font. + * Calculation starts at position 'min' in the + * string, and ends at 'max', which makes it + * possible to use this call for various + * advanced alignment calculations. + * + * int fontheight(); + * Returns the height of the currently selected + * font. + * + * void point(int _x, int _y); + * Plot a pixel with the current foreground + * color at (_x, _y). Note that the pixel will + * become a quadratic block if the screen is + * scaled to a higher resolution. + * + * void rectangle(int _x, int _y, int w, int h); + * Draw a hollow rectangle of w x h pixels at + * (_x, _y). The line thickness is scaled along + * with screen resolution, as with point(). + * + * void fillrect(int _x, int _y, int w, int h); + * Draw a solid rectangle of w x h pixels at + * (_x, _y). + * + * void fillrect_fxp(int _x, int _y, int w, int h); + * As fillrect(), but with pixel or sub-pixel + * accuracy, depending on scaling and video + * driver. + * + * void sprite(int _x, int _y, int bank, int frame, int inval = 1); + * Render sprite 'bank':'frame' at (_x, _y). If + * inval is passed and set to 0, the affected + * area will *not* be invalidated automatically. + * + * void sprite_fxp(int _x, int _y, int bank, int frame, int inval = 1); + * As sprite(), but with pixel or sub-pixel + * accuracy, depending on scaling and video + * driver. + * + * void blit(int dx, int dy, window_t *src); + * Blit from window 'src' into this window, placing + * the top left corner of 'src' at (dx, dy). + * + * void blit(int dx, int dy, int sx, int sy, int sw, int sh, window_t *src); + * Blit rectangle (sx, sy, sw, sh) from window 'src' + * into this window, placing the top left corner of + * 'src' at (dx, dy). + * + * int x() { return rect.x / xsc; } + * int y() { return rect.y / ysc; } + * int width() { return rect.w / xsc; } + * int height() { return rect.h / ysc; } + * Get the current screen position of the + * window's top-left corner, and it's size. + * + * int x2() { return (rect.x + rect.w) / xsc; } + * int y2() { return (rect.y + rect.h) / ysc; } + * Get the screen position of the bottom-right + * corner of the window. + */ + +#ifndef _WINDOW_H_ +#define _WINDOW_H_ + +#include "glSDL.h" + +class gfxengine_t; + +class window_t +{ + friend class gfxengine_t; + public: + window_t(); + window_t(gfxengine_t *e); + virtual ~window_t(); + + virtual void init(gfxengine_t *e); + void place(int left, int top, int sizex, int sizey); + int offscreen(); + void visible(int vis); + int visible() { return _visible; } + void select(); + void invalidate(SDL_Rect *r = NULL); + virtual void refresh(SDL_Rect *r) { ; } + + /* Color tools */ + Uint32 mulrgb(Uint32 c1, Uint32 c2) + { + int r = ((c1 >> 16) & 0xff) * ((c2 >> 16) & 0xff) * 258 >> 16; + int g = ((c1 >> 8) & 0xff) * ((c2 >> 8) & 0xff) * 258 >> 16; + int b = (c1 & 0xff) * (c2 & 0xff) * 258 >> 16; + return r << 16 | g << 8 | b; + } + Uint32 fadergb(Uint32 rgb, Uint8 fade) + { + int r = ((rgb >> 16) & 0xff) * fade * 258 >> 16; + int g = ((rgb >> 8) & 0xff) * fade * 258 >> 16; + int b = (rgb & 0xff) * fade * 258 >> 16; + return r << 16 | g << 8 | b; + } + + /* Rendering */ + Uint32 map_rgb(Uint8 r, Uint8 g, Uint8 b); + Uint32 map_rgb(Uint32 rgb); + void foreground(Uint32 color) { fgcolor = color; } + void background(Uint32 color) { bgcolor = color; }; + + void bgimage(int bank = -1, int frame = -1); + void colorkey(Uint32 color); + void colorkey(); + void alpha(float a); + + void clear(SDL_Rect *r = NULL); + void font(int fnt); + void string(int _x, int _y, const char *txt); + void center(int _y, const char *txt); + void center_token(int _x, int _y, const char *txt, char token = 0); + void string_fxp(int _x, int _y, const char *txt); + void center_fxp(int _y, const char *txt); + void center_token_fxp(int _x, int _y, const char *txt, char token = 0); + int textwidth(const char *txt, int min = 0, int max = 255); + int textwidth_fxp(const char *txt, int min = 0, int max = 255); + int fontheight(); + + void point(int _x, int _y); + void rectangle(int _x, int _y, int w, int h); + void fillrect(int _x, int _y, int w, int h); + void fillrect_fxp(int _x, int _y, int w, int h); + + void sprite(int _x, int _y, int bank, int frame, int inval = 1); + void sprite_fxp(int _x, int _y, int bank, int frame, int inval = 1); + + void blit(int dx, int dy, int sx, int sy, int sw, int sh, window_t *src); + void blit(int dx, int dy, window_t *src); + + int x() { return (phys_rect.x * 256 + 128) / xs; } + int y() { return (phys_rect.y * 256 + 128) / ys; } + int x2() { return ((phys_rect.x + phys_rect.w) * 256 + 128) / xs; } + int y2() { return ((phys_rect.y + phys_rect.h) * 256 + 128) / ys; } + int width() { return x2() - x(); } + int height() { return y2() - y(); } + + SDL_Rect phys_rect; + + protected: + window_t *next, *prev; + /* + * Kludge: This is for window selection to work. + * the problem is that this will break (along + * with some other things) if more than one + * gfxengine_t instance is used. + */ + static window_t *selected; //Currently selected window + + gfxengine_t *engine; + SDL_Surface *surface; + int xs, ys; //fixp 24:8 + Uint32 fgcolor, bgcolor; + int bg_bank, bg_frame; + int _font; + int _visible; + int _offscreen; + + void _select(); //Internal version + void link(gfxengine_t *e); + void unlink(void); + + void phys_refresh(SDL_Rect *r) + { + if(!r) + refresh(NULL); + else + { + SDL_Rect dr; + dr.x = r->x - phys_rect.x; + dr.y = r->y - phys_rect.y; + int x2 = (int)(dr.x + r->w) * 256 / xs; + int y2 = (int)(dr.y + r->h) * 256 / ys; + dr.x = (int)dr.x * 256 / xs; + dr.y = (int)dr.y * 256 / ys; + dr.w = x2 - dr.x; + dr.h = y2 - dr.y; + refresh(&dr); + } + } +}; + +#endif diff --git a/icons.tar.gz b/icons.tar.gz new file mode 100644 index 0000000..663e4d2 Binary files /dev/null and b/icons.tar.gz differ 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/kobo.cpp b/kobo.cpp new file mode 100644 index 0000000..5ae1baa --- /dev/null +++ b/kobo.cpp @@ -0,0 +1,2164 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2001-2003, 2005-2007 David Olofson + * Copyright (C) 2005 Erik Auerswald + * + * 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. + */ + +#define DBG(x) x + +#undef DEBUG_OUT + +// Use this to benchmark and create a new percentage table! +#undef TIME_PROGRESS + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef DEBUG +#include "audio.h" +extern "C" { +/*For the oscilloscope*/ +#include "a_globals.h" +/*For VU and voice info*/ +#include "a_struct.h" +} +#endif + +#include "kobolog.h" +#include "config.h" +#include "kobo.h" +#include "states.h" +#include "screen.h" +#include "manage.h" +#include "score.h" +#include "gamectl.h" +#include "random.h" +#include "version.h" +#include "options.h" +#include "myship.h" +#include "enemies.h" + +#define MAX_FPS_RESULTS 64 + +/* Joystick support */ +#define DEFAULT_JOY_LR 0 // Joystick axis left-right default +#define DEFAULT_JOY_UD 1 // Joystick axis up-down default +#define DEFAULT_JOY_FIRE 0 // Default fire button on joystick +#define DEFAULT_JOY_START 1 + + +/*---------------------------------------------------------- + Singletons +----------------------------------------------------------*/ +KOBO_sound sound; + + +/*---------------------------------------------------------- + Globals +----------------------------------------------------------*/ +filemapper_t *fmap = NULL; +prefs_t *prefs = NULL; +kobo_gfxengine_t *gengine = NULL; + +screen_window_t *wscreen = NULL; +dashboard_window_t *wdash = NULL; +bargraph_t *whealth = NULL; +bargraph_t *wtemp = NULL; +bargraph_t *wttemp = NULL; +radar_map_t *wmap = NULL; +radar_window_t *wradar = NULL; +window_t *wmain = NULL; +display_t *dhigh = NULL; +display_t *dscore = NULL; +display_t *dstage = NULL; +display_t *dships = NULL; +RGN_region *logo_region = NULL; + +int mouse_x = 0; +int mouse_y = 0; +int mouse_left = 0; +int mouse_middle = 0; +int mouse_right = 0; + +int exit_game = 0; + + +static int main_init() +{ + prefs = new prefs_t; + fmap = new filemapper_t; + gengine = new kobo_gfxengine_t; + return 0; +} + + +static void main_cleanup() +{ + delete gengine; + gengine = NULL; + delete fmap; + fmap = NULL; + delete prefs; + prefs = NULL; +} + + +/*---------------------------------------------------------- + Various functions +----------------------------------------------------------*/ + +static void setup_dirs(char *xpath) +{ + fmap->exepath(xpath); + + fmap->addpath("DATA", KOBO_DATA_DIR); + + /* + * Graphics data + */ + /* Current dir; from within the build tree */ + fmap->addpath("GFX", "./data/gfx"); + /* Real data dir */ + fmap->addpath("GFX", "DATA>>gfx"); + /* Current dir */ + fmap->addpath("GFX", "./gfx"); + + /* + * Sound data + */ + /* Current dir; from within the build tree */ + fmap->addpath("SFX", "./data/sfx"); + /* Real data dir */ + fmap->addpath("SFX", "DATA>>sfx"); + /* Current dir */ + fmap->addpath("SFX", "./sfx"); + + /* + * Score files (user and global) + */ + fmap->addpath("SCORES", KOBO_SCORE_DIR); + /* 'scores' in current dir (For importing scores, perhaps...) */ +// (Disabled for now, since filemapper_t can't tell +// when it hits the same dir more than once...) +// fmap->addpath("SCORES", "./scores"); + + /* + * Configuration files + */ + fmap->addpath("CONFIG", KOBO_CONFIG_DIR); + /* System local */ + fmap->addpath("CONFIG", SYSCONF_DIR); + /* In current dir (last resort) */ + fmap->addpath("CONFIG", "./"); +} + + +static void add_dirs(prefs_t *p) +{ + char buf[300]; + if(p->dir[0]) + { + char *upath = fmap->sys2unix(p->dir); + snprintf(buf, 300, "%s/sfx", upath); + fmap->addpath("SFX", buf, 1); + snprintf(buf, 300, "%s/gfx", upath); + fmap->addpath("GFX", buf, 1); + snprintf(buf, 300, "%s/scores", upath); + fmap->addpath("SCORES", buf, 1); + snprintf(buf, 300, "%s", upath); + fmap->addpath("CONFIG", buf, 0); + } + + if(p->sfxdir[0]) + fmap->addpath("SFX", fmap->sys2unix(p->sfxdir), 1); + + if(p->gfxdir[0]) + fmap->addpath("GFX", fmap->sys2unix(p->gfxdir), 1); + + if(p->scoredir[0]) + fmap->addpath("SCORES", fmap->sys2unix(p->scoredir), 1); +} + + +#ifdef DEBUG +static void draw_osc(int mode) +{ + int mx = oscframes; + if(mx > wmain->width()) + mx = wmain->width(); + int yo = wmain->height() - 40; + wmain->foreground(wmain->map_rgb(0x000099)); + wmain->fillrect(0, yo, wmain->width(), 1); + wmain->foreground(wmain->map_rgb(0x990000)); + wmain->fillrect(0, yo - 32, wmain->width(), 1); + wmain->fillrect(0, yo + 31, wmain->width(), 1); + + switch(mode) + { + case 0: + wmain->foreground(wmain->map_rgb(0x009900)); + for(int s = 0; s < mx; ++s) + wmain->point(s, ((oscbufl[s]+oscbufr[s]) >> 11) + yo); + break; + case 1: + wmain->foreground(wmain->map_rgb(0x009900)); + for(int s = 0; s < mx; ++s) + wmain->point(s, (oscbufl[s] >> 10) + yo); + wmain->foreground(wmain->map_rgb(0xcc0000)); + for(int s = 0; s < mx; ++s) + wmain->point(s, (oscbufr[s] >> 10) + yo); + break; + case 2: + wmain->foreground(wmain->map_rgb(0x009900)); + for(int s = 0; s < mx; ++s) + wmain->point(s>>1, (oscbufl[s] >> 10) + yo); + wmain->foreground(wmain->map_rgb(0xcc0000)); + for(int s = 0; s < mx; ++s) + wmain->point((s>>1) + (mx>>1), (oscbufr[s] >> 10) + yo); + wmain->fillrect(mx/2, yo-34, 1, 68); + break; + } + + wmain->foreground(wmain->map_rgb(0xcc0000)); + wmain->fillrect(0, yo - 32, 6, limiter.attenuation >> 11); +} + + +static void draw_vu(void) +{ + int xo = (wmain->width() - 5 * AUDIO_MAX_VOICES) / 2; + int yo = wmain->height() - 50; + wmain->foreground(wmain->map_rgb(0x000000)); + for(int s = 4; s < 40; s += 4) + wmain->fillrect(xo, yo+s, 5 * AUDIO_MAX_VOICES-1, 1); + wmain->foreground(wmain->map_rgb(0x333333)); + wmain->fillrect(xo-1, yo, 5 * AUDIO_MAX_VOICES+1, 1); + wmain->fillrect(xo-1, yo+40, 5 * AUDIO_MAX_VOICES+1, 4); + for(int s = 0; s <= AUDIO_MAX_VOICES; ++s) + wmain->fillrect(xo + s*5 - 1, yo+1, 1, 39); + for(int s = 0; s < AUDIO_MAX_VOICES; ++s) + { + int vu, vu2, vumin; + if(VS_STOPPED != voicetab[s].state) + { + wmain->foreground(wmain->map_rgb(0x009900)); + wmain->fillrect(xo + 1, yo + 41, 2, 2); + + vu = labs((voicetab[s].ic[VIC_LVOL].v>>1) + + (voicetab[s].ic[VIC_RVOL].v>>1)) >> + RAMP_BITS; +#ifdef AUDIO_USE_VU + vu2 = voicetab[s].vu; + voicetab[s].vu = 0; +#else + vu2 = 0; +#endif + vu2 = (vu2>>4) * (vu>>4) >> 8; + vu2 >>= 11; + if(vu2 > 40) + vu2 = 40; + vu >>= 11; + if(vu > 40) + vu = 40; + vumin = vu < vu2 ? vu : vu2; + } + else + vu = vu2 = vumin = 0; + wmain->foreground(wmain->map_rgb(0x006600)); + wmain->fillrect(xo, yo + 40 - vu, 4, vu - vu2); + wmain->foreground(wmain->map_rgb(0xffcc00)); + wmain->fillrect(xo, yo + 40 - vu2, 4, vu2); + xo += 5; + } +} +#endif + + +/*---------------------------------------------------------- + The main object +----------------------------------------------------------*/ +class KOBO_main +{ + public: +#ifdef DEBUG + static int audio_vismode; +#endif + static SDL_Joystick *joystick; + static int js_lr; + static int js_ud; + static int js_fire; + static int js_start; + + static FILE *logfile; + + static Uint32 esc_tick; + static int esc_count; + static int exit_game_fast; + + // Frame rate counter + static int fps_count; + static int fps_starttime; + static int fps_nextresult; + static int fps_lastresult; + static float *fps_results; + static display_t *dfps; + + // Frame rate limiter + static float max_fps_filter; + static int max_fps_begin; + + static int xoffs; + static int yoffs; + + // Backup in case we screw up we can't get back up + static prefs_t safe_prefs; + + static int open(); + static void close(); + static int run(); + + static int open_logging(prefs_t *p); + static void close_logging(); + static void load_config(prefs_t *p); + static void save_config(prefs_t *p); + + static void build_screen(); + static int init_display(prefs_t *p); + static void close_display(); + + static void show_progress(prefs_t *p); + static void progress(); + static void doing(const char *msg); + static int load_graphics(prefs_t *p); + static int load_sounds(prefs_t *p, int render_all = 0); + + static int init_js(prefs_t *p); + static void close_js(); + + static int escape_hammering(); + static int quit_requested(); + static void brutal_quit(); + static void pause_game(); + + static void print_fps_results(); +}; + +#ifdef DEBUG +int KOBO_main::audio_vismode = 0; +#endif + +SDL_Joystick *KOBO_main::joystick = NULL; +int KOBO_main::js_lr = DEFAULT_JOY_LR; +int KOBO_main::js_ud = DEFAULT_JOY_UD; +int KOBO_main::js_fire = DEFAULT_JOY_FIRE; +int KOBO_main::js_start = DEFAULT_JOY_START; + +FILE *KOBO_main::logfile = NULL; + +Uint32 KOBO_main::esc_tick = 0; +int KOBO_main::esc_count = 0; +int KOBO_main::exit_game_fast = 0; + +int KOBO_main::fps_count = 0; +int KOBO_main::fps_starttime = 0; +int KOBO_main::fps_nextresult = 0; +int KOBO_main::fps_lastresult = 0; +float *KOBO_main::fps_results = NULL; +display_t *KOBO_main::dfps = NULL; + +float KOBO_main::max_fps_filter = 0.0f; +int KOBO_main::max_fps_begin = 0; + +int KOBO_main::xoffs = 0; +int KOBO_main::yoffs = 0; + +prefs_t KOBO_main::safe_prefs; + + +static KOBO_main km; + + +void KOBO_main::print_fps_results() +{ + int i, r = fps_nextresult; + if(fps_lastresult != MAX_FPS_RESULTS-1) + r = 0; + for(i = 0; i < fps_lastresult; ++i) + { + log_printf(ULOG, "%.1f fps\n", fps_results[r++]); + if(r >= MAX_FPS_RESULTS) + r = 0; + } + + free(fps_results); + fps_nextresult = 0; + fps_lastresult = 0; + fps_results = NULL; +} + + +int KOBO_main::escape_hammering() +{ + Uint32 nt = SDL_GetTicks(); + if(nt - esc_tick > 300) + esc_count = 1; + else + ++esc_count; + esc_tick = nt; + return esc_count >= 5; +} + + +int KOBO_main::quit_requested() +{ + SDL_Event e; + while(SDL_PollEvent(&e)) + { + switch(e.type) + { + case SDL_QUIT: + exit_game_fast = 1; + break; + case SDL_VIDEOEXPOSE: + gengine->invalidate(); + break; + case SDL_KEYUP: + switch(e.key.keysym.sym) + { + case SDLK_ESCAPE: + if(escape_hammering()) + exit_game_fast = 1; + break; + default: + break; + } + break; + } + } + if(exit_game_fast) + return 1; + return SDL_QuitRequested(); +} + + +void KOBO_main::close_logging() +{ + /* Flush logs to disk, close log files etc. */ + log_close(); + + if(logfile) + { + fclose(logfile); + logfile = NULL; + } +} + + +int KOBO_main::open_logging(prefs_t *p) +{ + close_logging(); + + if(log_open() < 0) + return -1; + + if(p && p->logfile) + switch (p->logformat) + { + case 2: + logfile = fopen("log.html", "wb"); + break; + default: + logfile = fopen("log.txt", "wb"); + break; + } + + if(logfile) + { + log_set_target_stream(0, logfile); + log_set_target_stream(1, logfile); + } + else + { + log_set_target_stream(0, stdout); + log_set_target_stream(1, stderr); + } + + log_set_target_stream(2, NULL); + + if(p) + switch(p->logformat) + { + default: + log_set_target_flags(-1, LOG_TIMESTAMP); + break; + case 1: + log_set_target_flags(-1, LOG_ANSI | LOG_TIMESTAMP); + break; + case 2: + log_set_target_flags(-1, LOG_HTML | LOG_TIMESTAMP); + break; + } + + /* All levels output to stdout... */ + log_set_level_target(-1, 0); + + /* ...except these, that output to stderr. */ + log_set_level_target(ELOG, 1); + log_set_level_target(CELOG, 1); + + /* Some fancy colors... */ + log_set_level_attr(ULOG, LOG_YELLOW); + log_set_level_attr(WLOG, LOG_YELLOW | LOG_BRIGHT); + log_set_level_attr(ELOG, LOG_RED | LOG_BRIGHT); + log_set_level_attr(CELOG, LOG_RED | LOG_BRIGHT | LOG_BLINK); + log_set_level_attr(DLOG, LOG_CYAN); + log_set_level_attr(D2LOG, LOG_BLUE | LOG_BRIGHT); + log_set_level_attr(D3LOG, LOG_BLUE); + + /* Disable levels as desired */ + if(p) + switch(p->logverbosity) + { + case 0: + log_set_level_target(ELOG, 2); + case 1: + log_set_level_target(WLOG, 2); + case 2: + log_set_level_target(DLOG, 2); + case 3: + log_set_level_target(D2LOG, 2); + case 4: + log_set_level_target(D3LOG, 2); + case 5: + break; + } + + if(p && p->logfile && !logfile) + log_printf(ELOG, "Couldn't open log file!\n"); + + return 0; +} + + +void KOBO_main::build_screen() +{ + gengine->clear(0x000000); + + wdash->place(xoffs, yoffs, SCREEN_WIDTH, SCREEN_HEIGHT); + + whealth->place(xoffs + 4, yoffs + 92, 8, 128); + whealth->bgimage(B_HEALTH_LID, 0); + whealth->background(whealth->map_rgb(0x182838)); + whealth->redmax(0); + + wmain->place(xoffs + 8 + MARGIN, yoffs + MARGIN, WSIZE, WSIZE); + gengine->output(wmain); + + dhigh->place(xoffs + 252, yoffs + 4, 64, 18); + dhigh->font(B_NORMAL_FONT); + dhigh->bgimage(B_HIGH_BACK, 0); + dhigh->caption("HIGHSCORE"); + dhigh->text("000000000"); + + dscore->place(dhigh->x(), dhigh->y2() + 4, 64, 18); + dscore->font(B_NORMAL_FONT); + dscore->bgimage(B_SCORE_BACK, 0); + dscore->caption("SCORE"); + dscore->text("000000000"); + + wmap->place(0, 0, MAP_SIZEX, MAP_SIZEY); + wmap->offscreen(); + + wradar->place(xoffs + 244, + yoffs + (SCREEN_HEIGHT - MAP_SIZEY) / 2, + MAP_SIZEX, MAP_SIZEY); + wradar->bgimage(B_RADAR_BACK, 0); + + wtemp->place(xoffs + 244, yoffs + 188, 4, 32); + wtemp->bgimage(B_TEMP_LID, 0); + wtemp->background(wtemp->map_rgb(0x182838)); + wtemp->redmax(1); + + wttemp->place(xoffs + 248, yoffs + 188, 4, 32); + wttemp->bgimage(B_TTEMP_LID, 0); + wttemp->background(wttemp->map_rgb(0x182838)); + wttemp->redmax(1); + + dships->place(xoffs + 264, yoffs + 196, 38, 18); + dships->font(B_NORMAL_FONT); + dships->bgimage(B_SHIPS_BACK, 0); + dships->caption("SHIPS"); + dships->text("000"); + + dstage->place(dships->x(), dships->y2() + 4, 38, 18); + dstage->font(B_NORMAL_FONT); + dstage->bgimage(B_STAGE_BACK, 0); + dstage->caption("STAGE"); + dstage->text("000"); + + if(prefs->cmd_fps) + { + dfps = new display_t; + dfps->init(gengine); + dfps->place(0, -9, 48, 18); + dfps->color(wdash->map_rgb(0, 0, 0)); + dfps->font(B_NORMAL_FONT); + dfps->caption("FPS"); + } +} + + +int KOBO_main::init_display(prefs_t *p) +{ + int dw, dh; // Display size + int gw, gh; // Game "window" size + gengine->title("Kobo Deluxe " VERSION, "kobodl"); + gengine->driver((gfx_drivers_t)p->videodriver); + + dw = p->width; + dh = p->height; + if(p->fullscreen) + { + // This game assumes 1:1 pixel aspect ratio, or 4:3 + // width:height ratio, so we need to adjust accordingly. + // Note: + // This code assumes 1:1 pixels for all resolutions! + // This does not hold true for 1280x1024 or a CRT + // for example, but that's an incorrect (although + // all too common) setup anyway. (1280x1024 is for + // 5:4 TFT displays only!) + if(dw * 3 >= dh * 4) + { + // 4:3 or widescreen; Height defines size + gw = dh * 4 / 3; + gh = dh; + } + else + { + // "tallscreen" (probably 5:4 TFT or rotated display) + // Width defines size + gw = dw; + gh = dw * 3 / 4; + } + } + else + { + gw = dw; + gh = dh; + } + + // Scaling has 16ths granularity, so tiles scale properly! + gengine->scale((int)((gw * 16 + 8) / SCREEN_WIDTH) / 16.f, + (int)((gh * 16 + 8) / SCREEN_HEIGHT) / 16.f); + + // Read back and recalculate, in case the engine has some ideas... + gw = (int)(SCREEN_WIDTH * gengine->xscale() + 0.5f); + gh = (int)(SCREEN_HEIGHT * gengine->yscale() + 0.5f); + + if(!p->fullscreen) + { + //Add thin black border around the game "screen" in windowed mode. + dw = gw + 8; + dh = gh + 8; + } + + xoffs = (int)((dw - gw) / 2 / gengine->xscale()); + yoffs = (int)((dh - gh) / 2 / gengine->yscale()); + gengine->size(dw, dh); + + gengine->mode(0, p->fullscreen); + gengine->doublebuffer(p->doublebuf); + gengine->pages(p->pages); + gengine->vsync(p->vsync); + gengine->shadow(p->shadow); + gengine->cursor(0); + + gengine->period(game.speed); + sound.period(game.speed); + gengine->timefilter(p->timefilter * 0.01f); + gengine->interpolation(p->filter); + + gengine->scroll_ratio(LAYER_OVERLAY, 0.0, 0.0); + gengine->scroll_ratio(LAYER_BULLETS, 1.0, 1.0); + gengine->scroll_ratio(LAYER_FX, 1.0, 1.0); + gengine->scroll_ratio(LAYER_PLAYER, 1.0, 1.0); + gengine->scroll_ratio(LAYER_ENEMIES, 1.0, 1.0); + gengine->scroll_ratio(LAYER_BASES, 1.0, 1.0); + gengine->wrap(MAP_SIZEX * CHIP_SIZEX, MAP_SIZEY * CHIP_SIZEY); + + if(gengine->open(ENEMY_MAX) < 0) + return -1; + + gengine->clear(); + + wscreen = new screen_window_t; + wscreen->init(gengine); + wscreen->place(0, 0, + (int)(gengine->width() / gengine->xscale() + 0.5f), + (int)(gengine->height() / gengine->yscale() + 0.5f)); + wscreen->border((int)(yoffs * gengine->yscale() + 0.5f), + (int)(xoffs * gengine->xscale() + 0.5f), + dw - gw - (int)(xoffs * gengine->xscale() + 0.5f), + dh - gh - (int)(yoffs * gengine->yscale() + 0.5f)); + + wdash = new dashboard_window_t; + wdash->init(gengine); + whealth = new bargraph_t; + whealth->init(gengine); + wmain = new window_t; + wmain->init(gengine); + dhigh = new display_t; + dhigh->init(gengine); + dscore = new display_t; + dscore->init(gengine); + wmap = new radar_map_t; + wmap->init(gengine); + wradar = new radar_window_t; + wradar->init(gengine); + wtemp = new bargraph_t; + wtemp->init(gengine); + wttemp = new bargraph_t; + wttemp->init(gengine); + dships = new display_t; + dships->init(gengine); + dstage = new display_t; + dstage->init(gengine); + + build_screen(); + + wdash->mode(DASHBOARD_BLACK); + + return 0; +} + + +void KOBO_main::close_display() +{ + delete dfps; + dfps = NULL; + delete dstage; + dstage = NULL; + delete dships; + dships = NULL; + delete wttemp; + wttemp = NULL; + delete wtemp; + wtemp = NULL; + delete wradar; + wradar = NULL; + delete wmap; + wmap = NULL; + delete dscore; + dscore = NULL; + delete dhigh; + dhigh = NULL; + delete wmain; + wmain = NULL; + delete whealth; + whealth = NULL; + delete wdash; + wdash = NULL; + delete wscreen; + wscreen = NULL; +} + + +void KOBO_main::show_progress(prefs_t *p) +{ + wdash->mode(DASHBOARD_LOADING); + wdash->doing(""); +} + + +void KOBO_main::progress() +{ + wdash->progress(); +} + + +void KOBO_main::doing(const char *msg) +{ + wdash->doing(msg); +} + + +#ifndef TIME_PROGRESS +static float progtab_graphics[] = { + 0.000000, + 1.167315, + 4.085603, + 5.836576, + 7.490273, + 9.046693, + 10.992218, + 12.937743, + 13.813230, + 15.564202, + 17.217899, + 18.774319, + 20.428015, + 22.081713, + 23.540855, + 25.291828, + 26.848249, + 28.404669, + 29.961090, + 32.003891, + 33.560310, + 35.311283, + 36.770428, + 38.521400, + 40.369648, + 41.828793, + 43.190662, + 44.649807, + 46.595329, + 48.151752, + 49.610893, + 51.361866, + 53.501945, + 58.852139, + 60.116730, + 61.089493, + 63.521400, + 66.050583, + 68.287941, + 69.844360, + 72.665367, + 74.124512, + 76.653694, + 77.334633, + 79.182877, + 80.642021, + 82.295723, + 83.852142, + 85.505836, + 87.159531, + 88.813232, + 90.369652, + 92.023346, + 93.677040, + 95.233459, + 96.984436, + 98.540855, + 100.0, + 0 +}; + +static float progtab_sounds[] = { + 0.000000, + 58.709679, + 59.516129, + 98.790321, + 98.790321, + 100.0, + 0 +}; + +static float progtab_all[] = { + 0.000000, + 1.556684, + 2.639594, + 3.282572, + 4.060914, + 4.737733, + 5.380711, + 8.697124, + 8.764806, + 10.016920, + 10.761421, + 11.472081, + 12.216582, + 12.893401, + 13.604061, + 14.416244, + 15.093062, + 15.262267, + 16.074450, + 17.428087, + 18.680202, + 19.932318, + 20.879864, + 21.759729, + 23.011845, + 24.365482, + 24.534687, + 24.839256, + 25.651438, + 26.429781, + 26.700508, + 27.241962, + 29.678511, + 38.477158, + 40.203045, + 40.372250, + 40.913704, + 42.571911, + 45.211506, + 45.922165, + 46.565144, + 46.903553, + 48.866329, + 48.967850, + 49.306259, + 49.847717, + 50.389172, + 50.964466, + 51.641285, + 52.115059, + 52.690357, + 53.231812, + 53.773266, + 54.382404, + 54.991539, + 55.499153, + 56.006767, + 57.495770, + 82.673431, + 82.978004, + 99.763115, + 99.796951, + 100.0, + 0 +}; +#endif + + +typedef enum +{ + KOBO_CLAMP = 0x0001, // Clamp to frame edge pixels + KOBO_CLAMP_OPAQUE = 0x0002, // Clamp to black instead of transparent + KOBO_NOALPHA = 0x0004, // Disable alpha channel + KOBO_NODITHER = 0x0008, // Disable dithering + KOBO_NEAREST = 0x0010, // Force NEAREST scale mode + KOBO_CENTER = 0x0020, // Center hotspot in frames + KOBO_NOBRIGHT = 0x0040, // Disable brightness/contrast filter + KOBO_FONT = 0x0080, // Load as "SFont" rather than tiles! + KOBO_MESSAGE = 0x1000 // Not a file! 'path' is a message. +} KOBO_GfxDescFlags; + +typedef struct KOBO_GfxDesc +{ + const char *path; // Path + name (for filemapper) + int bank; // Sprite bank ID + int w, h; // Frame size (original image pixels) + float scale; // Scale of source data rel. 320x240 + int flags; // KOBO_GfxDescFlags +} KOBO_GfxDesc; + +static KOBO_GfxDesc gfxdesc[] = { + // Loading screen + { "Loading loading screen graphics", 0, 0,0, 0.0f, KOBO_MESSAGE }, + { "GFX>>loading3.png", B_LOADING, 0, 0, 2.0f, + KOBO_CLAMP | KOBO_NOALPHA }, + { "GFX>>icefont2.png", B_NORMAL_FONT, 0, 0, 2.0f, KOBO_FONT }, + + // In-game + { "Loading in-game graphics", 0, 0,0, 0.0f, KOBO_MESSAGE }, + { "GFX>>tiles-green.png", B_TILES1, 32, 32, 2.0f, KOBO_CLAMP }, + { "GFX>>tiles-metal.png", B_TILES2, 32, 32, 2.0f, KOBO_CLAMP }, + { "GFX>>tiles-blood.png", B_TILES3, 32, 32, 2.0f, KOBO_CLAMP }, + { "GFX>>tiles-double.png", B_TILES4, 32, 32, 2.0f, KOBO_CLAMP }, + { "GFX>>tiles-chrome.png", B_TILES5, 32, 32, 2.0f, KOBO_CLAMP }, + { "GFX>>flatstars1.png", B_OLDSTARS, 32, 32, 2.0f, KOBO_CLAMP }, + { "GFX>>crosshair.png", B_CROSSHAIR, 32, 32, 2.0f, KOBO_CENTER }, + { "GFX>>player.png", B_PLAYER, 40, 40, 2.0f, KOBO_CENTER }, + { "GFX>>bmr-green.png", B_BMR_GREEN, 40, 40, 2.0f, KOBO_CENTER }, + { "GFX>>bmr-purple.png", B_BMR_PURPLE, 40, 40, 2.0f, KOBO_CENTER }, + { "GFX>>bmr-pink.png", B_BMR_PINK, 40, 40, 2.0f, KOBO_CENTER }, + { "GFX>>fighter.png", B_FIGHTER, 40, 40, 2.0f, KOBO_CENTER }, + { "GFX>>missile.png", B_MISSILE1, 40, 40, 2.0f, KOBO_CENTER }, + { "GFX>>missile2.png", B_MISSILE2, 40, 40, 2.0f, KOBO_CENTER }, + { "GFX>>missile3.png", B_MISSILE3, 40, 40, 2.0f, KOBO_CENTER }, + { "GFX>>bolt.png", B_BOLT, 16, 16, 2.0f, KOBO_CENTER }, + { "GFX>>boltexpl.png", B_BOLTEXPL, 32, 32, 2.0f, KOBO_CENTER }, + { "GFX>>explo1e.png", B_EXPLO1, 48, 48, 2.0f, KOBO_CENTER }, + { "GFX>>explo3e.png", B_EXPLO3, 64, 64, 2.0f, KOBO_CENTER }, + { "GFX>>explo4e.png", B_EXPLO4, 64, 64, 2.0f, KOBO_CENTER }, + { "GFX>>explo5e.png", B_EXPLO5, 64, 64, 2.0f, KOBO_CENTER }, + { "GFX>>rock1c.png", B_ROCK1, 32, 32, 2.0f, KOBO_CENTER }, + { "GFX>>rock2.png", B_ROCK2, 32, 32, 2.0f, KOBO_CENTER }, + { "GFX>>shinyrock.png", B_ROCK3, 32, 32, 2.0f, KOBO_CENTER }, + { "GFX>>rockexpl.png", B_ROCKEXPL, 64, 64, 2.0f, KOBO_CENTER }, + { "GFX>>bullet5b.png", B_BULLETS, 16, 16, 2.0f, KOBO_CENTER }, + { "GFX>>bulletexpl2.png", B_BULLETEXPL, 32, 32, 2.0f, KOBO_CENTER }, + { "GFX>>ring.png", B_RING, 32, 32, 2.0f, KOBO_CENTER }, + { "GFX>>ringexpl2b.png", B_RINGEXPL, 40, 40, 2.0f, KOBO_CENTER }, + { "GFX>>bomb.png", B_BOMB, 24, 24, 2.0f, KOBO_CENTER }, + { "GFX>>bombdeto.png", B_BOMBDETO, 40, 40, 2.0f, KOBO_CENTER }, + { "GFX>>bigship.png", B_BIGSHIP, 72, 72, 2.0f, KOBO_CENTER }, + + // Framework + { "Loading framework graphics", 0, 0,0, 0.0f, KOBO_MESSAGE }, + { "GFX>>screen2.png", B_SCREEN, 0, 0, 2.0f, KOBO_CLAMP_OPAQUE }, + + // Logo + { "Loading logo", 0, 0,0, 0.0f, KOBO_MESSAGE }, + { "GFX>>logo-outline.png", B_LOGO, 0, 0, 2.0f, 0 }, + { "GFX>>deluxe.png", B_LOGODELUXE, 0, 0, 2.0f, 0 }, + { "GFX>>logomask3.png", B_LOGOMASK, 0, 0, 4.0f, + KOBO_NEAREST | KOBO_NODITHER }, + + // Fonts + { "Loading fonts", 0, 0,0, 0.0f, KOBO_MESSAGE }, + { "GFX>>goldfont.png", B_MEDIUM_FONT, 0, 0, 2.0f, KOBO_FONT }, + { "GFX>>bigfont3.png", B_BIG_FONT, 0, 0, 2.0f, KOBO_FONT }, + { "GFX>>counterfont.png", B_COUNTER_FONT, 0, 0, 2.0f, KOBO_FONT }, + + // Special FX + { "Loading special FX graphics", 0, 0,0, 0.0f, KOBO_MESSAGE }, + { "GFX>>noise.png", B_NOISE, NOISE_SIZEX, 1, 1.0f, + KOBO_CLAMP }, + { "GFX>>hitnoise.png", B_HITNOISE, NOISE_SIZEX, 1, 1.0f, + KOBO_CLAMP | KOBO_NEAREST }, + { "GFX>>focusfx.png", B_FOCUSFX, 0, 0, 1.0f, KOBO_CLAMP }, + { "GFX>>brushes.png", B_BRUSHES, 16, 16, 1.0f, + KOBO_CLAMP | KOBO_NEAREST | KOBO_NOALPHA }, + + { NULL, 0, 0, 0, 0.0f, 0 } // Terminator +}; + + +int KOBO_main::load_graphics(prefs_t *p) +{ + KOBO_GfxDesc *gd; + gengine->reset_filters(); + show_progress(p); + for(gd = gfxdesc; gd->path; ++gd) + { + if(gd->flags & KOBO_MESSAGE) + { + doing(gd->path); + continue; + } + + // Set scale (filter) mode and clamping + int clamping; + gfx_scalemodes_t sm; + if(gd->flags & KOBO_CLAMP) + { + gengine->clampcolor(0, 0, 0, 0); + clamping = 1; + } + else if(gd->flags & KOBO_CLAMP_OPAQUE) + { + gengine->clampcolor(0, 0, 0, 255); + clamping = 1; + } + else + clamping = 0; + if(gd->flags & KOBO_NEAREST) + sm = GFX_SCALE_NEAREST; + else + sm = (gfx_scalemodes_t) p->scalemode; + gengine->scalemode(sm, clamping); + + // Disable brightness filter? + if(gd->flags & KOBO_NOBRIGHT) + gengine->brightness(1.0f, 1.0f); + else + gengine->brightness(0.01f * p->brightness, + 0.01f * p->contrast); + + // Dithering + if(gd->flags & KOBO_NODITHER || !p->use_dither) + gengine->dither(-1); + else + gengine->dither(p->dither_type, p->broken_rgba8); + + // Alpha channels + if(gd->flags & KOBO_NOALPHA || !p->alpha) + gengine->noalpha(NOALPHA_THRESHOLD); + else + gengine->noalpha(0); + + // Source image scale + gengine->source_scale(gd->scale, gd->scale); + + // Load! + const char *fn = fmap->get(gd->path); + if(!fn) + { + log_printf(ELOG, "Couldn't get path to \"%s\"!\n", + gd->path); + return -1; + } + int res; + if(gd->flags & KOBO_FONT) + res = gengine->loadfont(gd->bank, fn); + else if(!gd->w || !gd->h) + res = gengine->loadimage(gd->bank, fn); + else + res = gengine->loadtiles(gd->bank, gd->w, gd->h, fn); + if(res < 0) + { + log_printf(ELOG, "Couldn't load \"%s\"!\n", fn); + return -1; + } + + // Hotspot + if(gd->flags & KOBO_CENTER) + gengine->set_hotspot(gd->bank, -1, + (int)(gd->w / gd->scale / 2), + (int)(gd->h / gd->scale / 2)); + + // Update progress bar + progress(); + } + + // Chop up the dashboard graphics as needed + SDL_Rect r; + r.w = r.h = 16; + r.x = (8 + MARGIN); + r.y = MARGIN; + if(gengine->copyrect(B_FRAME_TL, B_SCREEN, 0, &r) < 0) + return -6; + progress(); + r.x += WSIZE - 16; + if(gengine->copyrect(B_FRAME_TR, B_SCREEN, 0, &r) < 0) + return -7; + progress(); + r.x = (8 + MARGIN); + r.y = MARGIN + WSIZE - 16; + if(gengine->copyrect(B_FRAME_BL, B_SCREEN, 0, &r) < 0) + return -8; + progress(); + r.x += WSIZE - 16; + if(gengine->copyrect(B_FRAME_BR, B_SCREEN, 0, &r) < 0) + return -9; + progress(); + r.x = 252; + r.y = 4; + r.w = 64; + r.h = 18; + if(gengine->copyrect(B_HIGH_BACK, B_SCREEN, 0, &r) < 0) + return -26; + progress(); + r.y += 18 + 4; + if(gengine->copyrect(B_SCORE_BACK, B_SCREEN, 0, &r) < 0) + return -27; + progress(); + r.x = 244; + r.y = (SCREEN_HEIGHT - MAP_SIZEY) / 2; + r.w = MAP_SIZEX; + r.h = MAP_SIZEY; + if(gengine->copyrect(B_RADAR_BACK, B_SCREEN, 0, &r) < 0) + return -28; + progress(); + r.x = 264; + r.y = 196; + r.w = 38; + r.h = 18; + if(gengine->copyrect(B_SHIPS_BACK, B_SCREEN, 0, &r) < 0) + return -29; + progress(); + r.y += 18 + 4; + if(gengine->copyrect(B_STAGE_BACK, B_SCREEN, 0, &r) < 0) + return -30; + progress(); + r.x = 4; + r.y = 92; + r.w = 8; + r.h = 128; + if(gengine->copyrect(B_HEALTH_LID, B_SCREEN, 0, &r) < 0) + return -31; + progress(); + r.x = 244; + r.y = 188; + r.w = 4; + r.h = 32; + if(gengine->copyrect(B_TEMP_LID, B_SCREEN, 0, &r) < 0) + return -32; + progress(); + r.x += 4; + if(gengine->copyrect(B_TTEMP_LID, B_SCREEN, 0, &r) < 0) + return -33; + progress(); + + // Prepare the logo region + s_sprite_t *s = gengine->get_sprite(B_LOGOMASK, 0); + if(!s || !s->surface) + return -10; + RGN_FreeRegion(logo_region); + logo_region = RGN_ScanMask(s->surface, + SDL_MapRGB(s->surface->format, 255, 255, 255)); + if(!logo_region) + { + log_printf(ELOG, "Could not create logo region!\n"); + return -92; + } + progress(); + + return 0; +} + + +static int progress_cb(const char *msg) +{ + if(msg) + km.doing(msg); + km.progress(); + if(km.quit_requested()) + return -999; + return 0; +} + + +int KOBO_main::load_sounds(prefs_t *p, int render_all) +{ + if(!p->use_sound) + return 0; + show_progress(p); + return sound.load(progress_cb, render_all); +} + + +int KOBO_main::init_js(prefs_t *p) +{ + /* Activate Joystick sub-sys if we are using it */ + if(p->use_joystick) + { + if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) + { + log_printf(ELOG, "Error setting up joystick!\n"); + return -1; + } + p->number_of_joysticks = SDL_NumJoysticks(); + if(p->number_of_joysticks > 0) + { + SDL_JoystickEventState(SDL_ENABLE); + if(p->joystick_no >= p->number_of_joysticks) + p->joystick_no = 0; + joystick = SDL_JoystickOpen(p->joystick_no); + if(!joystick) + { + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + return -2; + } + } + else + { + log_printf(ELOG, "No joysticks found!\n"); + joystick = NULL; + return -3; + } + + } + return 0; +} + + +void KOBO_main::close_js() +{ + if(!SDL_WasInit(SDL_INIT_JOYSTICK)) + return; + + if(!joystick) + return; + + if(SDL_JoystickOpened(0)) + SDL_JoystickClose(joystick); + joystick = NULL; + + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); +} + + +void KOBO_main::load_config(prefs_t *p) +{ + FILE *f = fmap->fopen(KOBO_CONFIG_DIR "/" KOBO_CONFIG_FILE, "r"); + if(f) + { + p->read(f); + fclose(f); + } +} + + +void KOBO_main::save_config(prefs_t *p) +{ + FILE *f; +#if defined(HAVE_GETEGID) && defined(HAVE_SETGID) + gid_t oldgid = getegid(); + if(setgid(getgid()) != 0) + { + log_printf(ELOG, "Cannot save config! (%s)\n", + strerror(errno)); + return; + } +#endif + f = fmap->fopen(KOBO_CONFIG_DIR "/" KOBO_CONFIG_FILE, "w"); + if(f) + { + p->write(f); + fclose(f); + } +#if defined(HAVE_GETEGID) && defined(HAVE_SETGID) + if(setgid(oldgid) != 0) + { + log_printf(ELOG, "Cannot restore GID! (%s)\n", + strerror(errno)); + return; + } +#endif +} + + +void KOBO_main::brutal_quit() +{ + if(exit_game_fast) + { + log_printf(ULOG, "Second try quitting; using brutal method!\n"); + atexit(SDL_Quit); + close_logging(); + exit(1); + } + + exit_game_fast = 1; + if(gengine) + gengine->stop(); +} + + +void KOBO_main::pause_game() +{ + if(gsm.current() != &st_pause_game) + gsm.press(BTN_PAUSE); +} + + +void kobo_render_highlight(ct_widget_t *wg) +{ + screen.set_highlight(wg->y() + wg->height() / 2 - wmain->y(), + wg->height()); +} + + +int KOBO_main::open() +{ + if(init_display(prefs) < 0) + return -1; + +#ifdef TIME_PROGRESS + wdash->progress_init(NULL); +#else + wdash->progress_init(progtab_all); +#endif + + if(load_graphics(prefs) < 0) + return -2; + +#ifdef TIME_PROGRESS + // Use these two lines to time graphics and sounds separately! + wdash->progress_done(); + wdash->progress_init(NULL); +#endif + + sound.open(); + + if(load_sounds(prefs) < 0) + return -3; + + wdash->progress_done(); + + wdash->nibble(); + + ct_engine.render_highlight = kobo_render_highlight; + wdash->mode(DASHBOARD_GAME); + wradar->mode(RM_NOISE); + pubrand.init(); + init_js(prefs); + gamecontrol.init(prefs->always_fire); + manage.init(); + + gsm.push(&st_intro_title); + + return 0; +} + + +void KOBO_main::close() +{ + close_js(); + RGN_FreeRegion(logo_region); + logo_region = NULL; + close_display(); + if(gengine) + { + delete gengine; + gengine = NULL; + } + sound.close(); + SDL_Quit(); +} + + +int KOBO_main::run() +{ + int retry_status = 0; + int dont_retry = 0; + while(1) + { + if(!retry_status) + { + safe_prefs = *prefs; + gengine->run(); + + if(!manage.game_stopped()) + manage.abort(); + + if(exit_game_fast) + break; + + if(exit_game) + { + if(wdash) + wdash->nibble(); + break; + } + dont_retry = 0; + } + + retry_status = 0; + if(global_status & OS_RESTART_AUDIO) + { + if(prefs->use_sound) + { + log_printf(ULOG, "--- Restarting audio...\n"); + sound.stop(); +#ifdef TIME_PROGRESS + wdash->progress_init(NULL); +#else + wdash->progress_init(progtab_sounds); +#endif + if(load_sounds(prefs) < 0) + return 5; + wdash->progress_done(); + sound.open(); + wdash->nibble(); + log_printf(ULOG, "--- Audio restarted.\n"); + wdash->mode(DASHBOARD_GAME); + wradar->mode(screen.radar_mode); + manage.set_bars(); + } + else + { + log_printf(ULOG, "--- Stopping audio...\n"); + sound.close(); + log_printf(ULOG, "--- Audio stopped.\n"); + } + } + if((global_status & OS_RELOAD_AUDIO_CACHE) && prefs->cached_sounds) + { + log_printf(ULOG, "--- Rendering sounds to disk...\n"); +#ifdef TIME_PROGRESS + wdash->progress_init(NULL); +#else + wdash->progress_init(progtab_sounds); +#endif + if(load_sounds(prefs) < 0) + { + log_printf(ELOG, "--- Could not render sounds to disk!\n"); + st_error.message("Could not render to disk!", + "Please, check your installation."); + gsm.push(&st_error); + } + wdash->progress_done(); + wdash->mode(DASHBOARD_GAME); + wradar->mode(screen.radar_mode); + manage.set_bars(); + } + if(global_status & OS_RESTART_VIDEO) + { + log_printf(ULOG, "--- Restarting video...\n"); + wdash->nibble(); + gengine->hide(); + close_display(); + gengine->unload(); + if(init_display(prefs) < 0) + { + log_printf(ELOG, "--- Video init failed!\n"); + st_error.message("Video initialization failed!", + "Try different settings."); + gsm.push(&st_error); + if(dont_retry) + return 6; + *prefs = safe_prefs; + dont_retry = 1; + retry_status |= OS_RESTART_VIDEO; + } + else + { + gamecontrol.init(prefs->always_fire); + log_printf(ULOG, "--- Video restarted.\n"); + } + } + if(global_status & (OS_RELOAD_GRAPHICS | + OS_RESTART_VIDEO)) + { + if(!(global_status & OS_RESTART_VIDEO)) + wdash->nibble(); + gengine->unload(); + RGN_FreeRegion(logo_region); + logo_region = NULL; + if(!retry_status) + { + log_printf(ULOG, "--- Reloading graphics...\n"); +#ifdef TIME_PROGRESS + wdash->progress_init(NULL); +#else + wdash->progress_init(progtab_graphics); +#endif + if(load_graphics(prefs) < 0) + return 7; + wdash->progress_done(); + wdash->nibble(); + wdash->mode(DASHBOARD_GAME); + wradar->mode(screen.radar_mode); + manage.set_bars(); + log_printf(ULOG, "--- Graphics reloaded.\n"); + } + } + if(global_status & OS_RESTART_ENGINE) + log_printf(ELOG, "OS_RESTART_ENGINE not implemented!\n"); + if(global_status & OS_RESTART_INPUT) + { + close_js(); + init_js(prefs); + gamecontrol.init(prefs->always_fire); + } + if(global_status & OS_RESTART_LOGGER) + open_logging(prefs); + + global_status = retry_status; + km.pause_game(); + manage.reenter(); + } + return 0; +} + + +/*---------------------------------------------------------- + Kobo Graphics Engine +----------------------------------------------------------*/ + +kobo_gfxengine_t::kobo_gfxengine_t() +{ +} + + +void kobo_gfxengine_t::frame() +{ + sound.frame(); + + if(!gsm.current()) + { + log_printf(CELOG, "INTERNAL ERROR: No gamestate!\n"); + exit_game = 1; + stop(); + return; + } + if(exit_game || manage.aborted()) + { + stop(); + return; + } + + /* + * Process input + */ + SDL_Event ev; + while(SDL_PollEvent(&ev)) + { + int k, ms; + switch (ev.type) + { + case SDL_KEYDOWN: + switch(ev.key.keysym.sym) + { +#ifdef PROFILE_AUDIO + case SDLK_F10: + ++km.audio_vismode; + break; + case SDLK_F12: + audio_print_info(); + break; + case SDLK_r: + { + audio_channel_stop(-1, -1); + int startt = SDL_GetTicks(); + audio_wave_load(0, "sfx.agw", 0); + log_printf(VLOG, "(Loading + processing time: %d ms)\n", + SDL_GetTicks() - startt); + break; + } +#endif + case SDLK_DELETE: + if(prefs->cmd_debug) + { + manage.ships = 1; + myship.hit(1000); + } + break; + case SDLK_RETURN: + ms = SDL_GetModState(); + if(ms & (KMOD_CTRL | KMOD_SHIFT | KMOD_META)) + break; + if(!(ms & KMOD_ALT)) + break; + km.pause_game(); + prefs->fullscreen = !prefs->fullscreen; + prefs->changed = 1; + global_status |= OS_RELOAD_GRAPHICS | + OS_RESTART_VIDEO; + stop(); + return; + case SDLK_PRINT: + case SDLK_SYSREQ: +// FIXME: Doesn't this trigger when entering names and stuff...? + case SDLK_s: + gengine->screenshot(); + break; + default: + break; + } + k = gamecontrol.map(ev.key.keysym.sym); + gamecontrol.press(k); + gsm.press(k, ev.key.keysym.unicode); + break; + case SDL_KEYUP: + if((ev.key.keysym.sym == SDLK_ESCAPE) && km.escape_hammering()) + { + km.pause_game(); + prefs->fullscreen = 0; + prefs->videodriver = (int)GFX_DRIVER_SDL2D; + prefs->width = 640; + prefs->height = 480; + prefs->aspect = 1000; + prefs->depth = 0; + prefs->doublebuf = 0; + prefs->pages = -1; + prefs->shadow = 1; + prefs->scalemode = (int)GFX_SCALE_NEAREST; + prefs->brightness = 100; + prefs->contrast = 100; + global_status |= OS_RELOAD_GRAPHICS | + OS_RESTART_VIDEO; + stop(); + st_error.message("Safe video settings applied!", + "Enter Options menu to save."); + gsm.push(&st_error); + return; + } + k = gamecontrol.map(ev.key.keysym.sym); + if(k == SDLK_PAUSE) + { + gamecontrol.press(BTN_PAUSE); + gsm.press(BTN_PAUSE); + } + else + { + gamecontrol.release(k); + gsm.release(k); + } + break; + case SDL_VIDEOEXPOSE: + gengine->invalidate(); + break; + case SDL_ACTIVEEVENT: + // Any type of focus loss should activate pause mode! + if(!ev.active.gain) + km.pause_game(); + break; + case SDL_QUIT: + /*gsm.press(BTN_CLOSE);*/ + km.brutal_quit(); + break; + case SDL_JOYBUTTONDOWN: + if(ev.jbutton.button == km.js_fire) + { + gamecontrol.press(BTN_FIRE); + gsm.press(BTN_FIRE); + } + else if(ev.jbutton.button == km.js_start) + { + gamecontrol.press(BTN_START); + gsm.press(BTN_START); + } + break; + case SDL_JOYBUTTONUP: + if(ev.jbutton.button == km.js_fire) + { + gamecontrol.release(BTN_FIRE); + gsm.release(BTN_FIRE); + } + break; + case SDL_JOYAXISMOTION: + // FIXME: We will want to allow these to be + // redefined, but for now, this works ;-) + if(ev.jaxis.axis == km.js_lr) + { + if(ev.jaxis.value < -3200) + { + gamecontrol.press(BTN_LEFT); + gsm.press(BTN_LEFT); + } + else if(ev.jaxis.value > 3200) + { + gamecontrol.press(BTN_RIGHT); + gsm.press(BTN_RIGHT); + } + else + { + gamecontrol.release(BTN_LEFT); + gamecontrol.release(BTN_RIGHT); + gsm.release(BTN_LEFT); + gsm.release(BTN_RIGHT); + } + + } + else if(ev.jaxis.axis == km.js_ud) + { + if(ev.jaxis.value < -3200) + { + gamecontrol.press(BTN_UP); + gsm.press(BTN_UP); + } + else if(ev.jaxis.value > 3200) + { + gamecontrol.press(BTN_DOWN); + gsm.press(BTN_DOWN); + } + else + { + gamecontrol.release(BTN_UP); + gamecontrol.release(BTN_DOWN); + gsm.release(BTN_UP); + gsm.release(BTN_DOWN); + } + + } + case SDL_MOUSEMOTION: + mouse_x = (int)(ev.motion.x / gengine->xscale()) - km.xoffs; + mouse_y = (int)(ev.motion.y / gengine->yscale()) - km.yoffs; + if(prefs->use_mouse) + gamecontrol.mouse_position( + mouse_x - 8 - MARGIN - WSIZE/2, + mouse_y - MARGIN - WSIZE/2); + break; + case SDL_MOUSEBUTTONDOWN: + mouse_x = (int)(ev.motion.x / gengine->xscale()) - km.xoffs; + mouse_y = (int)(ev.motion.y / gengine->yscale()) - km.yoffs; + gsm.press(BTN_FIRE); + if(prefs->use_mouse) + { + gamecontrol.mouse_position( + mouse_x - 8 - MARGIN - WSIZE/2, + mouse_y - MARGIN - WSIZE/2); + switch(ev.button.button) + { + case SDL_BUTTON_LEFT: + mouse_left = 1; + break; + case SDL_BUTTON_MIDDLE: + mouse_middle = 1; + break; + case SDL_BUTTON_RIGHT: + mouse_right = 1; + break; + } + gamecontrol.press(BTN_FIRE); + } + break; + case SDL_MOUSEBUTTONUP: + mouse_x = (int)(ev.motion.x / gengine->xscale()) - km.xoffs; + mouse_y = (int)(ev.motion.y / gengine->yscale()) - km.yoffs; + if(prefs->use_mouse) + { + gamecontrol.mouse_position( + mouse_x - 8 - MARGIN - WSIZE/2, + mouse_y - MARGIN - WSIZE/2); + switch(ev.button.button) + { + case SDL_BUTTON_LEFT: + mouse_left = 0; + break; + case SDL_BUTTON_MIDDLE: + mouse_middle = 0; + break; + case SDL_BUTTON_RIGHT: + mouse_right = 0; + break; + } + } + if(!mouse_left && !mouse_middle && !mouse_right) + { + if(prefs->use_mouse) + gamecontrol.release(BTN_FIRE); + gsm.release(BTN_FIRE); + } + break; + } + } + gamecontrol.process(); + + /* + * Run the current gamestate for one frame + */ + gsm.frame(); + + if(prefs->cmd_autoshot && !manage.game_stopped()) + { + static int c = 0; + ++c; + if(c >= 3) + { + gengine->screenshot(); + c = 0; + } + } +} + + +void kobo_gfxengine_t::pre_render() +{ + sound.run(); + gsm.pre_render(); +} + + +void kobo_gfxengine_t::post_render() +{ + gsm.post_render(); + + if(!prefs->cmd_noframe) + { + wmain->sprite(0, 0, B_FRAME_TL, 0, 0); + wmain->sprite(WSIZE - 16, 0, B_FRAME_TR, 0, 0); + wmain->sprite(0, WSIZE - 16, B_FRAME_BL, 0, 0); + wmain->sprite(WSIZE - 16, WSIZE - 16, B_FRAME_BR, 0, 0); + } + +#ifdef DEBUG + if(prefs->cmd_debug) + { + char buf[20]; + snprintf(buf, sizeof(buf), "Obj: %d", + gengine->objects_in_use()); + wmain->font(B_NORMAL_FONT); + wmain->string(160, 5, buf); + } + + switch (km.audio_vismode % 5) + { + case 0: + break; + case 1: + draw_osc(0); + break; + case 2: + draw_vu(); + break; + case 3: + draw_osc(1); + break; + case 4: + draw_osc(2); + break; + } +#endif + + // Frame rate counter + int nt = (int)SDL_GetTicks(); + int tt = nt - km.fps_starttime; + if((tt > 1000) && km.fps_count) + { + float f = km.fps_count * 1000.0 / tt; + ::screen.fps(f); + km.fps_count = 0; + km.fps_starttime = nt; + if(prefs->cmd_fps) + { + char buf[20]; + snprintf(buf, sizeof(buf), "%.1f", f); + km.dfps->text(buf); + if(!km.fps_results) + km.fps_results = (float *) + calloc(MAX_FPS_RESULTS, + sizeof(float)); + if(km.fps_results) + { + km.fps_results[km.fps_nextresult++] = f; + if(km.fps_nextresult >= MAX_FPS_RESULTS) + km.fps_nextresult = 0; + if(km.fps_nextresult > km.fps_lastresult) + km.fps_lastresult = km.fps_nextresult; + } + } + } + ++km.fps_count; + + // Frame rate limiter + if(prefs->max_fps) + { + if(prefs->max_fps_strict) + { + static double nextframe = -1000000.0f; + while(1) + { + double t = (double)SDL_GetTicks(); + if(fabs(nextframe - t) > 1000.0f) + nextframe = t; + double d = nextframe - t; + if(d > 10.0f) + SDL_Delay(10); + else if(d > 1.0f) + SDL_Delay(1); + else + break; + } + nextframe += 1000.0f / prefs->max_fps; + } + else + { + int rtime = nt - km.max_fps_begin; + km.max_fps_begin = nt; + km.max_fps_filter += (float)(rtime - km.max_fps_filter) * 0.3; + int delay = (int)(1000.0 / prefs->max_fps - + km.max_fps_filter + 0.5); + if((delay > 0) && (delay < 1100)) + SDL_Delay(delay); + km.max_fps_begin = (int)SDL_GetTicks(); + } + } +} + + +/*---------------------------------------------------------- + main() and related stuff +----------------------------------------------------------*/ + +static void put_usage() +{ + printf("\nKobo Deluxe %s\n", KOBO_VERSION); + printf("Usage: kobodl []\n"); + printf("Recognized options:\n"); + int s = -1; + while(1) + { + const char *fs; + s = prefs->find_next(s); + if(s < 0) + break; + switch(prefs->type(s)) + { + case CFG_BOOL: + fs = " -[no]%-16.16s[%s]\t%s%s\n"; + break; + case CFG_INT: + case CFG_FLOAT: + fs = " -%-20.20s[%s]\t%s%s\n"; + break; + case CFG_STRING: + fs = " -%-20.20s[\"%s\"]\t%s%s\n"; + break; + default: + continue; + } + printf(fs, prefs->name(s), prefs->get_default_s(s), + prefs->do_save(s) ? "" : "(Not saved!) ", + prefs->description(s)); + } +} + + +static void put_options_man() +{ + int s = -1; + while(1) + { + const char *fs; + s = prefs->find_next(s); + if(s < 0) + break; + switch(prefs->type(s)) + { + case CFG_BOOL: + fs = ".TP\n.B \\-[no]%s\n%s%s. Default: %s.\n"; + break; + case CFG_INT: + case CFG_FLOAT: + fs = ".TP\n.B \\-%s\n%s%s. Default: %s.\n"; + break; + case CFG_STRING: + fs = ".TP\n.B \\-%s\n%s%s. Default: \"%s\"\n"; + break; + default: + continue; + } + printf(fs, prefs->name(s), + prefs->do_save(s) ? "" : "(Not saved!) ", + prefs->description(s), + prefs->get_default_s(s)); + } +} + + +extern "C" void emergency_close(void) +{ + km.close(); +} + + +extern "C" RETSIGTYPE breakhandler(int dummy) +{ + /* For platforms that drop the handlers on the first signal... */ + signal(SIGTERM, breakhandler); + signal(SIGINT, breakhandler); + km.brutal_quit(); +#if (RETSIGTYPE != void) + return 0; +#endif +} + + +int main(int argc, char *argv[]) +{ + int cmd_exit = 0; + atexit(emergency_close); + signal(SIGTERM, breakhandler); + signal(SIGINT, breakhandler); + + SDL_Init(0); + + if(main_init()) + { + fprintf(stderr, "INTERNAL ERROR\n"); + return 1; + }; + + km.open_logging(NULL); + + setup_dirs(argv[0]); + --argc; + ++argv; + + if((argc < 1) || (strcmp("-override", argv[0]) != 0)) + km.load_config(prefs); + + if((prefs->parse(argc, argv) < 0) || prefs->cmd_help) + { + put_usage(); + main_cleanup(); + return 1; + } + + if(prefs->cmd_options_man) + { + put_options_man(); + main_cleanup(); + return 1; + } + + if(prefs->cmd_noparachute) + { + SDL_Quit(); + SDL_Init(SDL_INIT_NOPARACHUTE); + } + + km.open_logging(prefs); + + for(int a = 0; a < argc; ++a) + log_printf(DLOG, "argv[%d] = \"%s\"\n", a, argv[a]); + + int k = -1; + while((k = prefs->find_next(k)) >= 0) + { + log_printf(D3LOG, "key %d: \"%s\"\ttype=%d\t\"%s\"\n", + k, + prefs->name(k), + prefs->type(k), + prefs->description(k) + ); + } + + add_dirs(prefs); + + if(prefs->cmd_hiscores) + { + scorefile.gather_high_scores(); + scorefile.print_high_scores(); + cmd_exit = 1; + } + + if(prefs->cmd_showcfg) + { + printf("Configuration:\n"); + printf("----------------------------------------\n"); + prefs->write(stdout); + printf("\nPaths:\n"); + printf("----------------------------------------\n"); + fmap->print(stdout, "*"); + printf("----------------------------------------\n"); + cmd_exit = 1; + } + + if(cmd_exit) + { + km.close_logging(); + main_cleanup(); + return 0; + } + + if(km.open() < 0) + { + km.close_logging(); + main_cleanup(); + return 1; + } + + km.run(); + + km.close(); + + /* + * Seems like we got all the way here without crashing, + * so let's save the current configuration! :-) + */ + if(prefs->changed) + { + km.save_config(prefs); + prefs->changed = 0; + } + + if(prefs->cmd_fps) + km.print_fps_results(); + + km.close_logging(); + main_cleanup(); + return 0; +} diff --git a/kobo.h b/kobo.h new file mode 100644 index 0000000..19fedea --- /dev/null +++ b/kobo.h @@ -0,0 +1,167 @@ +/* +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2001-2003, 2005, 2007 David Olofson + * + * 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. + */ + +#ifndef _KOBO_H_ +#define _KOBO_H_ + +#include "gfxengine.h" +#include "window.h" +#include "display.h" +#include "filemap.h" +#include "prefs.h" +#include "radar.h" +#include "dashboard.h" +#include "sound.h" +#include "region.h" + +/*---------------------------------------------------------- + Singletons +----------------------------------------------------------*/ +extern KOBO_sound sound; + + +/*---------------------------------------------------------- + Globals +----------------------------------------------------------*/ + +class kobo_gfxengine_t : public gfxengine_t +{ + void frame(); + void pre_render(); + void post_render(); + public: + kobo_gfxengine_t(); +}; + +extern kobo_gfxengine_t *gengine; +extern filemapper_t *fmap; +extern prefs_t *prefs; + +extern screen_window_t *wscreen; +extern dashboard_window_t *wdash; +extern bargraph_t *whealth; +extern bargraph_t *wtemp; +extern bargraph_t *wttemp; +extern radar_map_t *wmap; +extern radar_window_t *wradar; +extern window_t *wmain; +extern display_t *dhigh; +extern display_t *dscore; +extern display_t *dstage; +extern display_t *dships; + +extern RGN_region *logo_region; + +extern int mouse_x, mouse_y; +extern int mouse_left, mouse_middle, mouse_right; + +extern int exit_game; + + +/* Sprite priority levels */ +#define LAYER_OVERLAY 0 // Mouse crosshair +#define LAYER_BULLETS 1 // Bullets - most important! +#define LAYER_FX 2 // Explosions and similar effects +#define LAYER_PLAYER 3 // Player and fire bolts +#define LAYER_ENEMIES 4 // Enemies +#define LAYER_BASES 5 // Bases and stationary enemies + +/* Graphics banks */ +typedef enum +{ + B_TILES1 = 0, + B_TILES2, + B_TILES3, + B_TILES4, + B_TILES5, + + B_OLDSTARS, + B_CROSSHAIR, + B_PLAYER, + B_BULLETS, + B_BULLETEXPL, + B_RING, + B_RINGEXPL, + B_BOMB, + B_BOMBDETO, + B_BOLT, + B_BOLTEXPL, + B_EXPLO1, + B_EXPLO3, + B_EXPLO4, + B_EXPLO5, + B_ROCK1, + B_ROCK2, + B_ROCK3, + B_ROCKEXPL, + B_BMR_GREEN, + B_BMR_PURPLE, + B_BMR_PINK, + B_FIGHTER, + B_MISSILE1, + B_MISSILE2, + B_MISSILE3, + B_BIGSHIP, + + B_NOISE, + B_HITNOISE, + B_FOCUSFX, + + B_SCREEN, + B_FRAME_TL, + B_FRAME_TR, + B_FRAME_BL, + B_FRAME_BR, + B_LOGO, + B_LOGOMASK, + B_LOGODELUXE, + B_BRUSHES, + + B_HIGH_BACK, + B_SCORE_BACK, + B_RADAR_BACK, + B_SHIPS_BACK, + B_STAGE_BACK, + + B_HEALTH_LID, + B_TEMP_LID, + B_TTEMP_LID, + + B_LOADING, + B_NORMAL_FONT, + B_MEDIUM_FONT, + B_BIG_FONT, + B_COUNTER_FONT +} KOBO_Banks; + +#define NOALPHA_THRESHOLD 64 + +#define INTRO_SCENE -100000 + +typedef enum +{ + STARFIELD_NONE = 0, + STARFIELD_OLD, + STARFIELD_PARALLAX +} KOBO_StarfieldModes; + +#endif // _KOBO_H_ diff --git a/kobodl.6 b/kobodl.6 new file mode 100644 index 0000000..7395f1f --- /dev/null +++ b/kobodl.6 @@ -0,0 +1,378 @@ +.TH KOBODL 6 "26 December 2007" +.SH NAME +kobodl - Kobo Deluxe, an enhanced version of the scrolling game XKobo +.SH SYNOPSIS +.B kobodl +[ +.I options +] +.SH DESCRIPTION +Kobo Deluxe is a 3'rd person scrolling 2D shooter with a simple and responsive +control system - which you'll need to tackle the tons of enemy ships that shoot +at you, chase you, circle around you shooting, or even launch other ships at +you, while you're trying to destroy the labyrinth shaped bases. There are 50 +action packed levels with smoothly increasing difficulty, and different +combinations of enemies that require different tactics to be dealt with +successfully. +.P +Kobo Deluxe has an improved graphics engine that delivers smoother animation, +while keeping the game logic totally accurate and predictable regardless of +frame rate. It also adds sound effects, new graphics, fullscreen mode, four +extra skill levels with smoother gameplay and various other features expected +from a modern game. (There is still a "Clasic" mode that plays exactly like the +original XKobo.) +.P +Kobo Deluxe uses SDL for sound, graphics and input, and builds and runs on all +major operating systems, as well as some more unusual platforms. It can also +use OpenGL for accelerated rendering, through glSDL. +.P +In short, Kobo Deluxe is loads of classical arcade style fun for just about any +machine with graphics and sound! +.SH CONTROLS +The ship can be controlled with the keyboard, or optionally a mouse or +joystick. With the keyboard, the arrow keys move the ship (two keys for +diagonals), and the shift and ctrl keys shoots. The numeric key pad can also be +used; the usual 2/4/6/8 (arrows), and also 1/3/7/9 for single key diagonals. +Escape enters the meny system, from where it is possible to change settings, +start a new game or exit the game. +.SH OPTIONS +Note that all relevant options can be also configured in the config file, +which can be edited directly, or using the options menus in the game. +.TP +.B \-[no]logfile +Log To File. Default: Off. +.TP +.B \-logformat +Log File Format. Default: 0. +.TP +.B \-logverbosity +Log Verbosity Level. Default: 2. +.TP +.B \-[no]joystick +Use Joystick. Default: Off. +.TP +.B \-joystick_no +Joystick Number. Default: 0. +.TP +.B \-[no]mouse +Use Mouse. Default: Off. +.TP +.B \-mousemode +Mouse Control Mode. Default: 1. +.TP +.B \-[no]broken_numdia +Broken NumPad Diagonals. Default: Off. +.TP +.B \-dia_emphasis +Diagonals Emphasis Filter. Default: 0. +.TP +.B \-[no]always_fire +Always Fire. Default: Off. +.TP +.B \-[no]mousecapture +In-game Mouse Capture. Default: On. +.TP +.B \-scrollradar +Radar Scroll Mode. Default: 2. +.TP +.B \-[no]filter +Enable/disable motion interpolation. Interpolation is what makes animation +smooth at high frame rates despite the game logic running at 33.33 fps. +However, it also adds some input latency! Default: On. +.TP +.B \-timefilter +Time filter, for smoothing out timing jitter induced by the operating system. +Default: 50. +.TP +.B \-countdown +Get Ready Countdown. Default: 5. +.TP +.B \-starfield +Starfield Style. Default: 2. +.TP +.B \-stars +Number of Parallax Stars. Default: 500. +.TP +.B \-overheatloud +Overheat Warning Loudness. Default: 100. +.TP +.B \-cannonloud +Player Cannons Loudness. Default: 100. +.TP +.B \-[no]sound +Enable Sound. Default: On. +.TP +.B \-[no]music +Enable Music. Default: On. +.TP +.B \-[no]cached_sounds +Use Cached Sounds. Default: Off. +.TP +.B \-[no]oss +Use OSS Sound Driver. Default: Off. +.TP +.B \-samplerate +Sample Rate. Default: 44100. +.TP +.B \-latency +Sound Latency. Default: 50. +.TP +.B \-mixquality +Mixing Quality. Default: 3. +.TP +.B \-vol +Master Volume. Default: 100. +.TP +.B \-intro_vol +Intro Music Volume. Default: 100. +.TP +.B \-sfx_vol +Sound Effects Volume. Default: 100. +.TP +.B \-music_vol +In-Game Music Volume. Default: 30. +.TP +.B \-reverb +Reverb Level. Default: 100. +.TP +.B \-vol_boost +Volume Boost. Default: 0. +.TP +.B \-[no]fullscreen +Fullscreen Display. Default: Off. +.TP +.B \-videodriver +Display Driver. Default: 0. +.TP +.B \-width +Horizontal Resolution. Default: 640. +.TP +.B \-height +Vertical Resolution. Default: 480. +.TP +.B \-aspect +Pixel Aspect Ratio. Default: 1000. +.TP +.B \-depth +Display Depth. Default: 0. +.TP +.B \-maxfps +Limit the framerate (fps). Saves power on laptops (75 works well), and can also +avoid long stalls due to timesharing and background processes. Default: 100. +.TP +.B \-maxfpsstrict +Strictly Regulated fps. Default: 0. +.TP +.B \-buffer +Display Buffer Mode. Default: 1. +.TP +.B \-[no]shadow +Use Software Shadow Buffer. Default: On. +.TP +.B \-videomode +Video Mode. Default: 17200. +.TP +.B \-[no]vsync +Enable Vertical Sync. Default: On. +.TP +.B \-videopages +Number of Video Pages. Default: -1. +.TP +.B \-scalemode +Scaling Filter Mode. Default: 1. +.TP +.B \-[no]dither +Use Dithering. Default: On. +.TP +.B \-dither_type +Dither Type. Default: 0. +.TP +.B \-[no]broken_rgba8 +Broken RGBA (OpenGL). Default: Off. +.TP +.B \-[no]alpha +Use Alpha Blending. Default: On. +.TP +.B \-brightness +Brightness. Default: 100. +.TP +.B \-contrast +Contrast. Default: 100. +.TP +.B \-files +Specify the root path of the game. Default: "" +.TP +.B \-gfx +Specify the path to the game's graphics data. Default: "" +.TP +.B \-sfx +Specify the path to the game's sound data. Default: "" +.TP +.B \-scores +Specify the path to the game's score files. Default: "" +.TP +.B \-size +(Not saved!) Screen Size (Obsolete). Default: 0. +.TP +.B \-wait +Game Speed (Obsolete). Default: 30. +.TP +.B \-bgm +(Not saved!) Background Music File (Obsolete). Default: "" +.TP +.B \-threshold +(Not saved!) Limiter Gain. Default: 200. +.TP +.B \-release +(Not saved!) Limiter Speed. Default: 50. +.TP +.B \-internalres +(Not saved!) Texture Resolution. Default: 1. +.TP +.B \-last_profile +Last used player profile. Default: 0. +.TP +.B \-number_of_joysticks +Number of Connected Joysticks. Default: 0. +.TP +.B \-[no]showcfg +(Not saved!) Show Configuration. Default: Off. +.TP +.B \-[no]hiscores +(Not saved!) List High Scores. Default: Off. +.TP +.B \-[no]highscores +(Not saved!) List High Scores. Default: Off. +.TP +.B \-[no]override +(Not saved!) Ignore Configuration File. Default: Off. +.TP +.B \-[no]debug +(Not saved!) Enable Debug Features. Default: Off. +.TP +.B \-[no]fps +(Not saved!) Display frames per second in game screen. Default: Off. +.TP +.B \-[no]noframe +(Not saved!) Do not render rounded corners on the playfield. Default: Off. +.TP +.B \-[no]midi +(Not saved!) Enable MIDI Input. Default: Off. +.TP +.B \-[no]cheat +(Not saved!) Enable/disable cheat mode. Cheat mode allows any level to be +played, but highscores are not saved! Default: Off. +.TP +.B \-[no]indicator +(Not saved!) Enable Collision Indicator Mode. Default: Off. +.TP +.B \-[no]pushmove +(Not saved!) Enable Push Move Mode. Default: Off. +.TP +.B \-[no]noparachute +(Not saved!) Disable SDL Parachute. Default: Off. +.TP +.B \-[no]pollaudio +(Not saved!) Use Polling Audio Output. Default: Off. +.TP +.B \-[no]autoshot +(Not saved!) Ingame screenshots/movie. Default: Off. +.TP +.B \-[no]help +(Not saved!) Print usage info and exit. Default: Off. +.TP +.B \-[no]options_man +(Not saved!) Print options for 'man'. Default: Off. +.SH FILES +.TP +.B ~/.kobodlrc +The per-user configuration file for Kobo Deluxe. +.SH AUTHORS +Originally written by +Akira Higuchi (a-higuti@math.hokudai.ac.jp), XKobo was turned into Kobo +Deluxe by David Olofson +.SH THANKS +Thanks, in no particular order, to... +.TP +.B Akira Higuchi +Author of the Original XKobo. +.TP +.B Masanao Izumo +Sound effects and original sound engine. +.TP +.B Torsten Giebl +Slackware. +.TP +.B David Andersson +Various Good Ideas. +.TP +.B Max Horn +Mac OS X & Build Script Patches. +.TP +.B Jeremy Sheeley +Player Profiles. +.TP +.B Tsuyoshi Iguchi +FreeBSD, NetBSD. +.TP +.B Samuel Hart +Joystick Support. +.TP +.B G. Low +Solaris. +.TP +.B Gerry Jo "Trick" Jellestad +Testing and ideas. +.TP +.B "Riki" +Intel Compiler. +.TP +.B Andreas Spaangberg +Sun Compiler & Bug Spotting. +.TP +.B "SixK" +Amiga Port. +.TP +.B Joey Hess +Debian. +.TP +.B Martijn van Oosterhout +FPS limiter. +.TP +.B Antonio Messina +Stage 1601+ difficulty wrap, Always Fire option. +.TP +.B Hans de Goede +Audio buffer handling bug. +.TP +.B Marianne Ibbotson +"Autopause" idea. +.TP +.B Sam Palmer +MS Windows testing. +.TP +.B Michael Sterrett +glSDL issues. +.TP +.B Sam Lantinga & Others +SDL, the Simple DirectMedia library. +.TP +.B Members of the SDL mailing list +Testing and ideas. +.SH COPYRIGHT +Copyright (c) 1995, 1996 Akira Higuchi +.P +Copyright (C) 1997 Masanao Izumo +.P +Copyright (C) 1999-2001 Simon Peter +.P +Copyright (C) 2002 Florian Schulze +.P +Copyright (C) 2002 Jeremy Sheeley +.P +Copyright (C) 2005 Erik Auerswald +.P +Copyright (c) 1999-2007 David Olofson +.P +\fBKobo Deluxe\fP is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License. diff --git a/kobolog.h b/kobolog.h new file mode 100644 index 0000000..a80e41c --- /dev/null +++ b/kobolog.h @@ -0,0 +1,44 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - Logger definitions +------------------------------------------------------------ + * Copyright (C) 2003, David Olofson + * + * 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. + */ + +#ifndef KOBOLOG_H +#define KOBOLOG_H + +#include "logger.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Critical error messages: "Huston, we have a problem." */ +#define CELOG 5 + +/* Debug messages; level 2: Detailed */ +#define D2LOG 6 + +/* Debug messages; level 3: Deep Hack Mode stuff */ +#define D3LOG 7 + +#ifdef __cplusplus +}; +#endif + +#endif /* KOBOLOG_H */ diff --git a/logger.c b/logger.c new file mode 100644 index 0000000..f315c2b --- /dev/null +++ b/logger.c @@ -0,0 +1,484 @@ +/*(LGPL) +--------------------------------------------------------------------------- + logger.c - Simple logger with redirection +--------------------------------------------------------------------------- + * Copyright (C) 2003, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include + +#include "config.h" +#include "logger.h" +#include "glSDL.h" + +#define LOG_BUFFER 1024 + +static int i__last; +#define for_one_or_all(iterator, index, items) \ + if(index < LOG_TARGETS) \ + { \ + if(index >= 0) \ + iterator = i__last = index; \ + else \ + { \ + iterator = 0; \ + i__last = items - 1; \ + } \ + } \ + else \ + { \ + iterator = 0; \ + i__last = -10; \ + } \ + --iterator; \ + while(++iterator <= i__last) + + +typedef struct +{ + /* Stream output */ + int use_stream; + FILE *stream; + + /* Callback output */ + int handle; + int (*callback)(int handle, const char *data); + + /* Formatting control */ + unsigned flags; + int written; +} LOG_target; + + +typedef struct +{ + /* Output */ + int target; + + /* Atributes */ + unsigned attr; +} LOG_level; + + +static LOG_level *l_levels = NULL; +static LOG_target *l_targets = NULL; +static char *l_buffer = NULL; + +Uint32 start_time; + + +/*-------------------------------------------------------------------- + Low level internal stuff +--------------------------------------------------------------------*/ + +/* Write stuff without any translation */ +static inline int log_write_raw(int target, const char *text) +{ + if(l_targets[target].use_stream) + return fputs(text, l_targets[target].stream); + else if(l_targets[target].callback) + return l_targets[target].callback( + l_targets[target].handle, text); + else + { + /* We should never get here. */ + assert(0); + } +} + + +/* Write log file header if applicable. */ +static inline void check_header(int target) +{ + if(l_targets[target].written) + return; + + if(l_targets[target].flags & LOG_HTML) + { + log_write_raw(target, "\n"); + log_write_raw(target, "\n\t\n"); + log_write_raw(target, "\t\tLog File\n"); + log_write_raw(target, "\t\t\n"); + log_write_raw(target, "\t\n"); + log_write_raw(target, "\t\n"); + } + l_targets[target].written = 1; +} + + +/* Write log file footer if applicable. */ +static inline void check_footer(int target) +{ + if(!l_targets[target].written) + return; + + if(l_targets[target].flags & LOG_HTML) + log_write_raw(target, "\t\n\n"); +} + + +/* Write converting/escaping any reserved characters as needed */ +static inline int log_write(int target, const char *text) +{ + int i; + if(l_targets[target].flags & LOG_HTML) + { +/* +FIXME: Optimize this a little, maybe. :-) +*/ + char buf[2] = "\0\0"; + int last = -1; + for(i = 0; text[i]; ++i) + { + buf[0] = text[i]; + switch(text[i]) + { + case '\n': + log_write_raw(target, "
\n"); + break; + case ' ': + if(' ' == last) + log_write_raw(target, " "); + else + log_write_raw(target, " "); + break; + case '<': + log_write_raw(target, "<"); + break; + case '>': + log_write_raw(target, ">"); + break; + case '&': + log_write_raw(target, "&"); + break; + default: + log_write_raw(target, buf); + break; + } + last = text[i]; + } + return i; + } + else + return log_write_raw(target, text); +} + + +static inline void put_timestamp(int level) +{ + if(l_targets[l_levels[level].target].flags & LOG_TIMESTAMP) + { + char buf[16]; + snprintf(buf, sizeof(buf)-1, "[%d] ", SDL_GetTicks() - start_time); + log_write_raw(l_levels[level].target, buf); + } +} + + +#define ANSI_SUPPORTED_FLAGS (LOG_COLORS | LOG_BRIGHT | LOG_STRONG | LOG_BLINK) +#define HTML_SUPPORTED_FLAGS (LOG_COLORS | LOG_BRIGHT | LOG_STRONG | LOG_BLINK) + +static inline void set_attr(int level) +{ + unsigned a = l_levels[level].attr; + if(l_targets[l_levels[level].target].flags & LOG_ANSI) + { +#define SEP if('[' != buf[pos - 1]) buf[pos++] = ';' + int pos = 0; + char buf[24]; + if(!(a & ANSI_SUPPORTED_FLAGS)) + return; + + buf[pos++] = '\033'; + buf[pos++] = '['; + if(a & LOG_COLORS) + { + buf[pos++] = '3'; + buf[pos++] = '0' + (a & LOG_COLORS) - 1; + } + if(a & LOG_BRIGHT) + { + SEP; + buf[pos++] = '1'; + } + if(a & LOG_STRONG) + { + SEP; + buf[pos++] = '4'; + } + if(a & LOG_BLINK) + { + SEP; + buf[pos++] = '5'; + } + buf[pos++] = 'm'; + buf[pos++] = '\0'; + log_write_raw(l_levels[level].target, buf); +#undef SEP + } + else if(l_targets[l_levels[level].target].flags & LOG_HTML) + { + if(a & LOG_COLORS) + { + const char *sel; + if(a & LOG_BRIGHT) + switch( (a & LOG_COLORS) - 1) + { + case 0: sel = ""; break; + case 1: sel = ""; break; + case 2: sel = ""; break; + case 3: sel = ""; break; + case 4: sel = ""; break; + case 5: sel = ""; break; + case 6: sel = ""; break; + case 7: + default: + sel = ""; break; + } + else + switch( (a & LOG_COLORS) - 1) + { + case 0: sel = ""; break; + case 1: sel = ""; break; + case 2: sel = ""; break; + case 3: sel = ""; break; + case 4: sel = ""; break; + case 5: sel = ""; break; + case 6: sel = ""; break; + case 7: + default: + sel = ""; break; + } + log_write_raw(l_levels[level].target, sel); + } + if(a & LOG_STRONG) + log_write_raw(l_levels[level].target, ""); + if(a & LOG_BLINK) + log_write_raw(l_levels[level].target, ""); + } +} + + +static inline void reset_attr(int level) +{ + unsigned a = l_levels[level].attr; + if(l_targets[l_levels[level].target].flags & LOG_ANSI) + { + if(!(a & ANSI_SUPPORTED_FLAGS)) + return; + + log_write_raw(l_levels[level].target, "\033[0m"); + } + else if(l_targets[l_levels[level].target].flags & LOG_HTML) + { + if(a & LOG_BLINK) + log_write_raw(l_levels[level].target, ""); + if(a & LOG_STRONG) + log_write_raw(l_levels[level].target, ""); + if(a & LOG_COLORS) + log_write_raw(l_levels[level].target, ""); + } +} + + +static inline int is_active(int level) +{ + LOG_target *t = &l_targets[l_levels[level].target]; + return (t->use_stream || t->callback); +} + + +/*-------------------------------------------------------------------- + API entry points +--------------------------------------------------------------------*/ + +int log_open(void) +{ + if(l_levels) + return 0; + + l_levels = calloc(LOG_LEVELS, sizeof(LOG_level)); + if(!l_levels) + return -1; + + l_targets = calloc(LOG_TARGETS, sizeof(LOG_target)); + if(!l_targets) + { + log_close(); + return -2; + } + l_buffer = calloc(1, LOG_BUFFER); + if(!l_buffer) + { + log_close(); + return -3; + } + + log_set_target_stream(-1, stdout); + log_set_target_flags(-1, 0); + + log_set_level_target(-1, 0); + log_set_level_attr(-1, LOG_NOCOLOR); + + start_time = SDL_GetTicks(); + return 0; +} + + +#define CHECK_INIT (l_levels ? 0 : -1) + + +void log_close(void) +{ + int i; + if(CHECK_INIT < 0) + return; + for(i = 0; i < LOG_TARGETS; ++i) + check_footer(i); + free(l_targets); + l_targets = NULL; + free(l_levels); + l_levels = NULL; + free(l_buffer); + l_buffer = NULL; +} + + +void log_set_target_stream(int target, FILE *stream) +{ + int i; + if(CHECK_INIT < 0) + return; + + for_one_or_all(i, target, LOG_TARGETS) + { + l_targets[i].callback = NULL; + l_targets[i].stream = stream; + l_targets[i].use_stream = (stream != NULL); + } +} + + +void log_set_target_callback(int target, + int (*callback)(int handle, const char *data), int handle) +{ + int i; + if(CHECK_INIT < 0) + return; + + for_one_or_all(i, target, LOG_TARGETS) + { + l_targets[i].use_stream = 0; + l_targets[i].callback = callback; + l_targets[i].handle = handle; + } +} + + +void log_set_target_flags(int target, unsigned flags) +{ + int i; + if(CHECK_INIT < 0) + return; + + for_one_or_all(i, target, LOG_TARGETS) + l_targets[i].flags = flags; +} + + +void log_set_level_target(int level, int target) +{ + int i; + if(CHECK_INIT < 0) + return; + + for_one_or_all(i, level, LOG_LEVELS) + l_levels[i].target = target; +} + + +void log_set_level_attr(int level, unsigned attr) +{ + int i; + if(CHECK_INIT < 0) + return; + + for_one_or_all(i, level, LOG_LEVELS) + l_levels[i].attr = attr; +} + + +int log_puts(int level, const char *text) +{ + int result, result2; + + if(CHECK_INIT < 0) + return -1; + + if(level < 0 || level >= LOG_LEVELS) + return -2; + + if(!is_active(level)) + return 0; + + check_header(l_levels[level].target); + set_attr(level); + put_timestamp(level); + + result = log_write(l_levels[level].target, text); + if(result >= 0) + { + result2 = log_write_raw(l_levels[level].target, "\n"); + if(result2 >= 0) + result += result2; + } + reset_attr(level); + return result; +} + + +int log_printf(int level, const char *format, ...) +{ + va_list args; + int result; + + if(CHECK_INIT < 0) + return -1; + + if(level < 0 || level >= LOG_LEVELS) + return -2; + + if(!is_active(level)) + return 0; + + check_header(l_levels[level].target); + set_attr(level); + put_timestamp(level); + + va_start(args, format); + result = vsnprintf(l_buffer, LOG_BUFFER-1, format, args); + va_end(args); + if(result >= 0) + result = log_write(l_levels[level].target, l_buffer); + reset_attr(level); + return result; +} diff --git a/logger.h b/logger.h new file mode 100644 index 0000000..2d100f6 --- /dev/null +++ b/logger.h @@ -0,0 +1,158 @@ +/*(LGPL) +--------------------------------------------------------------------------- + logger.h - Simple logger with redirection +--------------------------------------------------------------------------- + * Copyright (C) 2003, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef DO_LOGGER_H +#define DO_LOGGER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* +TODO: Levels sending to multiple targets. +TODO: Printing to multiple levels. +*/ + +#define LOG_TARGETS 8 +#define LOG_LEVELS 32 + +/* + * Standard log levels (so libs and stuff can share your logger! :-) + */ +#define ULOG 0 /* User: Messages meant for normal users */ +#define WLOG 1 /* Warning: Warning messages */ +#define ELOG 2 /* Error: Error messages */ +#define VLOG 3 /* Verbose: Messages for advanced users */ +#define DLOG 4 /* Debug: Debug messages */ + + +typedef enum +{ + LOG_ANSI = 0x00000001, /* Use ANSI escape codes */ + LOG_HTML = 0x00000002, /* Use HTML formatting tags */ + LOG_TIMESTAMP = 0x00000100 /* Timestamp messages */ +} LOG_flags; + + +typedef enum +{ + LOG_COLORS = 0x000f, /* Mask for color bits */ + LOG_NOCOLOR = 0, /* Don't try to change! */ + LOG_BLACK, + LOG_RED, + LOG_GREEN, + LOG_YELLOW, + LOG_BLUE, + LOG_MAGENTA, + LOG_CYAN, + LOG_WHITE, + LOG_BRIGHT = 0x0100, /* High intensity colors */ + LOG_STRONG = 0x0200, /* Bold or underlined */ + LOG_BLINK = 0x0400 /* Blinking, if possible */ +} LOG_attributes; + + +/* + * The usual open/close calls... + * + * Note that log_close() may write footers and stuff to files, + * so you may get slightly broken log files if you exit + * without calling it! + * + * log_open() returns a negative value in case of failure. + */ +int log_open(void); +void log_close(void); + + +/* + * Send output through 'target' to 'stream'. 'stream' must be + * a valid stdio stream opened for output. + * + * If 'target' is -1, all targets are changed. + */ +void log_set_target_stream(int target, FILE *stream); + + +/* + * Send output through 'target' to 'callback'. The callback + * will receive the value passed as 'handle' as it's first + * argument, followed by the data to output. (NULL terminated + * string.) The callback should return the number of bytes + * successfully handled, or, in case of failure, a negative + * value. + * + * If 'target' is -1, all targets are changed. + */ +void log_set_target_callback(int target, + int (*callback)(int handle, const char *data), int handle); + + +/* + * Set formatting flags for 'target'. + * + * If 'target' is -1, all targets are changed. + */ +void log_set_target_flags(int target, unsigned flags); + + +/* + * Send output through 'level' to 'target'. 'levels' is a bit + * mask with one bit for each log level. + * + * If 'level' is -1, all levels are changed. + */ +void log_set_level_target(int level, int target); + + +/* + * Set attributes for 'level'. + * + * If 'level' is -1, all levels are changed. + */ +void log_set_level_attr(int level, unsigned attr); + + +/* + * Print 'text' to 'level'. 'level' is the index of the log + * level to print to. No formatting will be done, and the + * output will be followed by a "newline". + * + * Returns a negative value in case of failure. + */ +int log_puts(int level, const char *text); + + +/* + * Format and print to 'level'. 'level' is the index of the + * log level to print to. + * + * Returns a negative value in case of failure. + */ +int log_printf(int level, const char *format, ...); + +#ifdef __cplusplus +}; +#endif + +#endif /* DO_LOGGER_H */ diff --git a/manage.cpp b/manage.cpp new file mode 100644 index 0000000..caa266f --- /dev/null +++ b/manage.cpp @@ -0,0 +1,730 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2002 Jeremy Sheeley + * Copyright (C) 2001-2003, 2007 David Olofson + * + * 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. + */ + +// Define to get time and ships lost printed out per finished stage +// NOTE: Also disables bonus ships! +#undef PLAYSTATS + +#include "config.h" + +#include +#include +#include +#include +#include +#include +#ifndef M_PI +# define M_PI 3.14159265358979323846 /* pi */ +#endif + +#include "kobo.h" +#include "screen.h" +#include "manage.h" +#include "options.h" +#include "scenes.h" +#include "score.h" +#include "enemies.h" +#include "myship.h" +#include "radar.h" +#include "gamectl.h" +#include "states.h" +#include "audio.h" +#include "random.h" + +#define GIGA 1000000000 + +int _manage::blank = 0; +int _manage::next_state_out; +int _manage::next_state_next; +int _manage::game_seed; +int _manage::scene_num; +int _manage::ships; +int _manage::score; +float _manage::disp_health; +float _manage::disp_temp; +int _manage::score_changed = 1; +int _manage::ships_changed = 1; +int _manage::bonus_next; +int _manage::flush_score_count = 0; +int _manage::flush_ships_count = 0; +int _manage::scroll_jump = 0; +int _manage::delay_count; +int _manage::rest_cores; +int _manage::introtime = 0; +int _manage::exit_manage = 0; +int _manage::playing = 0; +int _manage::_get_ready = 0; +int _manage::_game_over = 0; +s_hiscore_t _manage::hi; +int _manage::noise_duration = 0; +int _manage::noise_timer = 0; +int _manage::noise_flash = 500; +float _manage::noise_level = 0.0f; +int _manage::intro_x = CHIP_SIZEX * (64-18); +int _manage::intro_y = CHIP_SIZEY * (64-7); +int _manage::show_bars = 0; + +#ifdef PLAYSTATS +static Uint32 start_time = 0; +static int start_ships = 0; +#endif + + +void _manage::set_bars() +{ + whealth->enable(show_bars); + wtemp->enable(show_bars); + wttemp->enable(show_bars); +} + + +// NOTE: +// After a noise out has faded out the sound effects, it's the +// noise/interfecence effect when the playfield is reinitialized +// that "accidentally" restores volume! +// +void _manage::run_noise() +{ + if(noise_flash == -2) + { + // Damage flash + noise_timer -= game.speed; + if(noise_timer <= 0) + noise_timer = 0; + screen.noise(noise_timer); + float t = (float)noise_timer / noise_duration; + wmain->background(wmain->map_rgb(wmain->fadergb(0xff0000, + (int)(t * noise_level * 64)))); + screen.set_noise(B_HITNOISE, t * noise_level, + t * noise_level, 0.0f); + return; + } + else if(noise_flash == -1) + { + // Noise-out + noise_timer -= game.speed; + if(noise_timer <= 0) + noise_timer = 0; + float t = (float)noise_timer / noise_duration; + float a = t * 2.0f * M_PI; + wmain->background(wmain->map_rgb(wmain->fadergb(0x00ff99, + (int)(sin(a * 0.5f) * 0.3f * 64)))); + screen.set_noise(B_NOISE, 1.0f - t, + sin(a * 0.5f) * 0.3f, + 0.3f + t * 0.5f); + sound.sfx_volume(t); + return; + } + + wmain->background(wmain->map_rgb(0x00000)); + + // Noise/interference + int noise; + if(noise_timer > noise_flash) + { + noise_timer -= game.speed; + noise = 1; + } + else if(noise_timer > 0) + { + unsigned prob = noise_flash - noise_timer; + prob <<= 8; + prob /= noise_flash; + noise_timer -= game.speed; + noise = pubrand.get(8) > prob; + } + else + { + noise_timer = 0; + noise = 0; + } + + noise_level += (noise - noise_level) * 0.3f; + screen.set_noise(B_NOISE, noise_level, 0.0f, noise_level); + screen.noise(noise_level > 0.1f); + + sound.ui_noise(noise); +} + + +void _manage::noise(int duration, int flash) +{ + noise_flash = flash; + noise_duration = noise_timer = duration; + sound.ui_noise(-1); + screen.set_noise(B_NOISE, 1.0f, 0.0f, 1.0f); + noise_level = 1.0f; +} + + +void _manage::noise_out(int duration) +{ + noise_flash = -1; + noise_duration = noise_timer = duration; + screen.noise(1); +} + + +void _manage::noise_damage(float amt) +{ + noise_flash = -2; + noise_duration = noise_timer = (int)(300.0f + 1500.0f * amt); + noise_level = 0.3f + 0.3f * amt; +} + + +void _manage::game_start() +{ + _game_over = 0; + hi.clear(); + + game.set(GAME_SINGLE, (skill_levels_t)scorefile.profile()->skill); + +#ifdef PLAYSTATS + ships = 100; +#else + ships = game.lives; +#endif + disp_health = 0; + disp_temp = 0; + score = 0; + flush_score_count = 0; + bonus_next = game.bonus_first; + gengine->period(game.speed); + sound.period(game.speed); + screen.init_scene(scene_num); + init_resources_to_play(1); + + gamecontrol.clear(); + gamecontrol.repeat(0, 0); + + playing = 1; + _get_ready = 1; + + hi.skill = game.skill; + hi.playtime = 0; + hi.gametype = game.type; +#if 1 + // The new skill levels are under development! + // We want to mark highscores so they're not mistaken + // for official scores from a future finalized version. + if(game.skill != SKILL_CLASSIC) + hi.gametype |= GAME_EXPERIMENTAL; +#endif + hi.saves = 0; + hi.loads = 0; + hi.start_scene = scene_num; + hi.end_lives = ships; + sound.g_music(SOUND_BGM); + +#ifdef PLAYSTATS + start_time = SDL_GetTicks(); + start_ships = ships; +#endif +} + + +void _manage::game_stop() +{ + if(!prefs->cmd_cheat && !prefs->cmd_pushmove) + { + hi.score = score; + hi.end_scene = scene_num; + hi.end_health = myship.health(); + + scorefile.record(&hi); + } + ships = 0; + ships_changed = 1; + audio_channel_stop(0, -1); + playing = 0; +} + +void _manage::next_scene() +{ +#ifdef PLAYSTATS + printf("stage %d:\n", scene_num); + Uint32 nst = SDL_GetTicks(); + printf(" time: %d s\n", (nst - start_time) / 1000); + printf(" deaths: %d\n", start_ships - ships); + start_time = nst; + start_ships = ships; +#endif + scene_num++; + if(scene_num >= GIGA - 1) + scene_num = GIGA - 2; + screen.init_scene(scene_num); + scroll_jump = 1; + _get_ready = 1; +} + + +void _manage::retry() +{ + if(!prefs->cmd_cheat) + { + ships--; + ships_changed = 1; + } + if(ships <= 0) + { + if(!_game_over) + { + game_stop(); + _game_over = 1; + } + } + else + _get_ready = 1; + gamecontrol.clear(); +} + + +void _manage::init_resources_title() +{ + noise(1000, 800); + screen.init_scene(INTRO_SCENE); + gengine->period(30); + sound.period(30); + gamerand.init(); + enemies.init(); + myship.init(); + myship.off(); + screen.prepare(); + screen.generate_fixed_enemies(); + put_info(); + put_score(); + put_ships(); + put_health(1); + put_temp(1); + run_intro(); + gengine->force_scroll(); + gamecontrol.repeat(KOBO_KEY_DELAY, KOBO_KEY_REPEAT); + show_bars = 0; + set_bars(); +} + + +void _manage::init_resources_to_play(int newship) +{ + noise(400, 300); + delay_count = 0; + flush_score_count = (flush_score_count) ? -1 : 0; + flush_ships_count = 0; + score_changed = 0; + next_state_out = 0; + next_state_next = 0; + + gamerand.init(); + game_seed = gamerand.get_seed(); + enemies.init(); + myship.init(); + if(newship) + myship.health(game.health); + rest_cores = screen.prepare(); + scroll_jump = 1; + screen.generate_fixed_enemies(); + put_info(); + put_score(); + put_ships(); + switch(game.skill) + { + case SKILL_CLASSIC: + show_bars = 0; + break; + case SKILL_NEWBIE: + case SKILL_GAMER: + case SKILL_ELITE: + case SKILL_GOD: + default: + show_bars = 1; + break; + } + set_bars(); + put_health(1); + put_temp(1); + myship.put(); + gengine->scroll(PIXEL2CS(myship.get_virtx()), + PIXEL2CS(myship.get_virty())); + gengine->force_scroll(); +} + + +void _manage::put_health(int force) +{ + int h = myship.health(); + if(h > disp_health) + { + disp_health += (float)game.health * .05; + if(disp_health > h) + disp_health = h; +// whealth->background(whealth->map_rgb(0, 100, 0)); + } + else if(h < disp_health) + { + disp_health -= (float)game.health * .1; + if(disp_health < h) + disp_health = h; +// whealth->background(whealth->map_rgb(128, 0, 0)); + } +// else +// whealth->background(whealth->map_rgb(0, 0, 0)); + whealth->value((float)disp_health / game.health); + if(force) + whealth->invalidate(); +} + + +void _manage::put_temp(int force) +{ + wtemp->value(myship.get_nose_temp() / 256.0f); + wttemp->value(myship.get_tail_temp() / 256.0f); + if(force) + { + wtemp->invalidate(); + wttemp->invalidate(); + } +} + + +void _manage::put_info() +{ + static char s[16]; + + snprintf(s, 16, "%010d", scorefile.highscore()); + dhigh->text(s); + dhigh->on(); + + snprintf(s, 16, "%03d", scene_num + 1); + dstage->text(s); + dstage->on(); + + score_changed = 1; + ships_changed = 1; +} + + +void _manage::put_score() +{ + if(score_changed) + { + static char s[32]; + snprintf(s, 16, "%010d", score); + dscore->text(s); + dscore->on(); + if(score > scorefile.highscore()) + { + dhigh->text(s); + dhigh->on(); + } + score_changed = 0; + } + if(flush_score_count > 0) + flush_score(); +} + + +void _manage::put_ships() +{ + if(ships_changed) + { + static char s[32]; + if(!prefs->cmd_cheat) + snprintf(s, 16, "%03d", ships); + else + snprintf(s, 16, "999"); + dships->text(s); + dships->on(); + ships_changed = 0; + } + if(flush_ships_count > 0) + flush_ships(); +} + + +void _manage::flush_score() +{ + flush_score_count--; + if(flush_score_count & 1) + return; + + if(flush_score_count & 2) + dscore->off(); + else + dscore->on(); + if(flush_score_count == 0) + flush_score_count = -1; +} + + +void _manage::flush_ships() +{ + flush_ships_count--; + if(flush_ships_count & 1) + return; + + if(flush_ships_count & 2) + dships->off(); + else + dships->on(); + if(flush_ships_count == 0) + flush_ships_count = -1; +} + + +/****************************************************************************/ +void _manage::init() +{ + scorefile.init(); + ships = 0; + exit_manage = 0; + scene_num = -1; + flush_ships_count = 0; + flush_score_count = 0; + delay_count = 0; + screen.init(); + init_resources_title(); +} + + +void _manage::run_intro() +{ + double t = SDL_GetTicks() * 0.001f; + gengine->scroll(PIXEL2CS(intro_x), PIXEL2CS(intro_y)); + intro_y -= 3; + intro_x &= MAP_SIZEX*CHIP_SIZEX-1; + intro_y &= MAP_SIZEY*CHIP_SIZEY-1; + sound.g_position(intro_x + (WSIZE >> 1), intro_y + (WSIZE >> 1)); + myship.set_position(intro_x + (WSIZE >> 1) + (int)(WSIZE * 0.3f * sin(t)), + intro_y + (WSIZE >> 1) + (int)(WSIZE * 0.3f * sin(t * 1.73))); + enemies.move_intro(); + enemies.put(); + + put_health(); + put_temp(); + put_score(); + put_ships(); + + run_noise(); +} + + +void _manage::update() +{ + myship.put(); + enemies.put(); + put_score(); + put_ships(); + gengine->scroll(PIXEL2CS(myship.get_virtx()), + PIXEL2CS(myship.get_virty())); + if(scroll_jump) + { + gengine->force_scroll(); + scroll_jump = 0; + } + run_noise(); +} + + +void _manage::run_pause() +{ + put_health(); + put_temp(); + update(); +} + + +void _manage::run_game() +{ + put_health(); + put_temp(); + + if(delay_count) + delay_count--; + + if(delay_count == 1) + { + if(enemies.exist_pipe()) + delay_count = 2; + else + { + int newship = next_state_out; + put_info(); + if(next_state_out) + { + retry(); + if(ships <= 0) + return; + } + if(next_state_next) + next_scene(); + init_resources_to_play(newship); + return; + } + } + + myship.move(); + enemies.move(); + myship.hit_structure(); + update(); + ++hi.playtime; +} + + +void _manage::lost_myship() +{ + if(delay_count == 0) + delay_count = 100; + next_state_out = 1; +} + + +void _manage::destroyed_a_core() +{ + // Award 10% health bonus for destroyed core! + myship.health_bonus(10); + rest_cores--; + if(rest_cores == 0) + { + next_state_next = 1; + delay_count = 50; + // Award another 25% health bonus for stage cleared! + myship.health_bonus(25); + } + screen.generate_fixed_enemies(); +} + + +void _manage::add_score(int sc) +{ + score += sc; + if(score >= GIGA) //This *could* happen... Or maybe not. :-) + score = GIGA - 1; + else if(!prefs->cmd_cheat) + { +#ifndef PLAYSTATS + if(score >= bonus_next) + { + bonus_next += game.bonus_every; + ships++; + ships_changed = 1; + flush_ships_count = 50; + sound.ui_oneup(); + } +#endif + if(score >= scorefile.highscore()) + { + if(flush_score_count == 0) + flush_score_count = 50; + } + } + score_changed = 1; +} + + +void _manage::select_next(int redraw_map) +{ + if((scene_num < scorefile.last_scene()) || prefs->cmd_cheat) + { + sound.ui_tick(); + scene_num++; + } + else + sound.ui_error(); + select_scene(scene_num); +} + + +void _manage::select_prev(int redraw_map) +{ + scene_num--; + if(scene_num < 0) + { + sound.ui_error(); + scene_num = 0; + } + else + sound.ui_tick(); + select_scene(scene_num); +} + + +void _manage::regenerate() +{ + sound.ui_tick(); + select_scene(scene_num, 1); +} + + +void _manage::select_scene(int scene, int redraw_map) +{ + scene_num = scene; + put_info(); + if(redraw_map) + screen.init_scene(-scene_num - 1); + noise(150, 0); +} + + +void _manage::abort() +{ + if(!exit_manage) + { + game_stop(); + exit_manage = 1; + } +} + + +void _manage::freeze_abort() +{ + exit_manage = 1; +} + + +void _manage::reenter() +{ + exit_manage = 0; + put_health(1); + put_temp(1); + put_info(); + put_score(); + put_ships(); +} + + +int _manage::get_ready() +{ + if(_get_ready) + { + _get_ready = 0; + return 1; + } + return 0; +} + + +int _manage::game_over() +{ + return _game_over; +} diff --git a/manage.h b/manage.h new file mode 100644 index 0000000..24cd294 --- /dev/null +++ b/manage.h @@ -0,0 +1,110 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2002 Jeremy Sheeley + * Copyright (C) 2001-2003, 2007 David Olofson + * + * 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. + */ + +#ifndef _KOBO_MANAGE_H_ +#define _KOBO_MANAGE_H_ + +#include "glSDL.h" +#include "score.h" + +class _manage +{ + static int blank; + static int next_state_out; + static int next_state_next; + static int game_seed; + static int bonus_next; + static int scroll_jump; + static int delay_count; + static int introtime; + static int rest_cores; + static int exit_manage; + static int playing; + static int _get_ready; + static int _game_over; + static s_hiscore_t hi; + static int noise_flash; + static int noise_duration; + static int noise_timer; + static float noise_level; + static int intro_x; + static int intro_y; + static int show_bars; + + static void next_scene(); + static void retry(); + + static int scene_num; + static int score; + static float disp_health; + static float disp_temp; + static int flush_score_count; + static int flush_ships_count; + static int score_changed; + static int ships_changed; + static void put_health(int force = 0); + static void put_temp(int force = 0); + static void put_info(); + static void put_score(); + static void put_ships(); + static void flush_score(); + static void flush_ships(); + static void game_stop(); + static void run_noise(); + public: + static int ships; + static void init(); + static void set_bars(); + static void init_resources_title(); + static void init_resources_to_play(int newship); + static void noise(int duration, int flash); + static void noise_out(int duration); + static void noise_damage(float amt); + static void update(); + static void run_intro(); + static void run_pause(); + static void run_game(); + static void lost_myship(); + static void destroyed_a_core(); + static void add_score(int sc); + static void key_down(SDLKey sym); + static void key_up(SDLKey sym); + static int title_blank() { return blank; } + static void select_next(int redraw_map = 1); + static void select_prev(int redraw_map = 1); + static void regenerate(); + static void select_scene(int scene, int redraw_map = 1); + static int scene() { return scene_num; } + static void abort(); + static void freeze_abort(); + static int aborted() { return exit_manage; } + static void reenter(); + static int game_stopped() { return !playing; } + static int get_ready(); + static void game_start(); + static int game_over(); +}; + +extern _manage manage; + +#endif //_KOBO_MANAGE_H_ diff --git a/map.cpp b/map.cpp new file mode 100644 index 0000000..4d0b549 --- /dev/null +++ b/map.cpp @@ -0,0 +1,220 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2002, 2007 David Olofson + * + * 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. + */ + +#include "config.h" +#include "map.h" +#include "random.h" + +void _map::init() +{ + int i, j; + for(i = 0; i < MAP_SIZEX; i++) + for(j = 0; j < MAP_SIZEY; j++) + pos(i, j) = SPACE; +} + +void _map::make_maze(int x, int y, int difx, int dify) +{ + int i, j; + int vx, vy; + + /* clear */ + for(i = x - difx; i <= x + difx; i++) + for(j = y - dify; j <= y + dify; j++) + pos(i, j) = SPACE; + + /* push initial sites */ + site_max = 0; + if(gamerand.get(8) < 128) + { + pos(x, y) = CORE | R_MASK | L_MASK; + maze_push(x - 1, y); + maze_push(x + 1, y); + } + else + { + pos(x, y) = CORE | U_MASK | D_MASK; + maze_push(x, y - 1); + maze_push(x, y + 1); + } + + for(;;) + { + /* get one */ + if(maze_pop()) + break; + vx = sitex[site_max]; + vy = sitey[site_max]; + + int dirs[4]; + for(i = 0; i < 4; i++) + dirs[i] = 0; + int dirs_max = 0; + if(maze_judge(x, y, difx, dify, vx + 2, vy + 0)) + dirs[dirs_max++] = 1; + if(maze_judge(x, y, difx, dify, vx + 0, vy + 2)) + dirs[dirs_max++] = 2; + if(maze_judge(x, y, difx, dify, vx - 2, vy + 0)) + dirs[dirs_max++] = 3; + if(maze_judge(x, y, difx, dify, vx + 0, vy - 2)) + dirs[dirs_max++] = 4; + if(dirs_max == 0) + continue; /* there are no places to go */ + i = gamerand.get() % dirs_max; + maze_move_and_push(vx, vy, dirs[i]); + maze_push(vx, vy); + } +} + +int _map::maze_pop() +{ + if(site_max == 0) + return 1; + int i = gamerand.get() % site_max; + site_max--; + if(i != site_max) + { + int tmpx = sitex[site_max]; + int tmpy = sitey[site_max]; + sitex[site_max] = sitex[i]; + sitey[site_max] = sitey[i]; + sitex[i] = tmpx; + sitey[i] = tmpy; + } + return 0; +} + +void _map::maze_push(int x, int y) +{ + sitex[site_max] = x; + sitey[site_max++] = y; + pos(x, y) = WALL; +} + +void _map::maze_move_and_push(int x, int y, int d) +{ + int x1 = x; + int y1 = y; + switch (d) + { + case 1: + { + x1 += 2; + break; + } + case 2: + { + y1 += 2; + break; + } + case 3: + { + x1 -= 2; + break; + } + case 4: + { + y1 -= 2; + break; + } + } + maze_push(x1, y1); + pos((x + x1) / 2, (y + y1) / 2) = WALL; +} + +int _map::maze_judge(int cx, int cy, int dx, int dy, int x, int y) +{ + if((x < cx - dx) || (x > cx + dx) || (y < cy - dy) + || (y > cy + dy)) + return 0; + if(pos(x, y) == WALL) + return 0; + return 1; +} + +// Translate map "tile state bits" into tile index +// +// The hard end nodes need some special treatment here. There are 16 direction +// mask combinations, but only 4 are valid in this case. So, we use a 16 x 2 +// bit lookup "table" (packed into an 'int') to get the right tile index. +// +// 00 01 10 11 <-- mask bits 1 (right) and 0 (up) +// ----------------------------------------------------- +// 00 -- 00 01 -- +// 01 10 -- -- -- <-- Tile indices +// 10 11 -- -- -- +// 11 -- -- -- -- +// ^ +// '- mask bits 3 (left) and 2 (down) +// +// Thus, our table is 00000000 00000011 00000010 00010000 == 0x00030210 +// +static inline int bits2tile(int n) +{ + if(n & CORE) // Core + return n & (U_MASK | D_MASK) ? 6 : 7; + else if(n & HARD) // One of the 4 indestructible end nodes + return (0x00030210 >> ((n & 15) << 1)) & 3; + else if(n == 5) // Vertical pipe + return pubrand.get(2) ? 13 : 4; + else if(n == 10) // Vertical pipe + return pubrand.get(2) ? 18 : 5; + else // Other pipe parts or normal end nodes + return n + 8; +} + +void _map::convert(unsigned ratio) +{ + int i, j; + int p = 0; + for(i = 0; i < MAP_SIZEX; i++) + for(j = 0; j < MAP_SIZEY; j++) + { + p = pos(i, j) & CORE; + if(IS_SPACE(pos(i, j))) + { + clearpos(i, j); + continue; + } + if((j > 0) && !IS_SPACE(pos(i, j - 1))) + p |= U_MASK; + if((i < MAP_SIZEX - 1) && !IS_SPACE(pos(i + 1, j))) + p |= R_MASK; + if((j < MAP_SIZEY - 1) && !IS_SPACE(pos(i, j + 1))) + p |= D_MASK; + if((i > 0) && !IS_SPACE(pos(i - 1, j))) + p |= L_MASK; + if((p == U_MASK) || (p == R_MASK) || (p == D_MASK) + || (p == L_MASK)) + { + if(gamerand.get(8) < ratio) + p |= HARD; + } + pos(i, j) = (bits2tile(p) << 8) | p; + } +} + + +void _map::clearpos(int x, int y) +{ + pos(x, y) = (gamerand.get(6) << 8) | SPACE; +} diff --git a/map.h b/map.h new file mode 100644 index 0000000..19a5374 --- /dev/null +++ b/map.h @@ -0,0 +1,69 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2002, 2007 David Olofson + * + * 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. + */ + +#ifndef XKOBO_H_MAP +#define XKOBO_H_MAP + +#include "config.h" + +#define SITE_MAX 1024 + +#define WALL 1 + +// Tile state bits +#define U_MASK (1<<0) +#define R_MASK (1<<1) +#define D_MASK (1<<2) +#define L_MASK (1<<3) +#define CORE (1<<4) +#define HIT_MASK (CORE | U_MASK | R_MASK | D_MASK | L_MASK) +#define HARD (1<<5) +#define SPACE (1<<6) +#define MAP_BITS(x) ((x) & 0xff) + +#define IS_SPACE(x) ((x) & SPACE) + +class _map +{ + public: + void init(); + void make_maze(int x, int y, int difx, int dify); + void convert(unsigned ratio); /* ratio < 64 */ + inline unsigned short &pos(int x, int y) + { + x &= MAP_SIZEX - 1; + y &= MAP_SIZEY - 1; + return data[(y << MAP_SIZEX_LOG2) + x]; + } + void clearpos(int x, int y); + protected: + int sitex[SITE_MAX]; + int sitey[SITE_MAX]; + int site_max; + unsigned short data[1 << (MAP_SIZEX_LOG2 + MAP_SIZEY_LOG2)]; + int maze_pop(); + void maze_push(int x, int y); + void maze_move_and_push(int x, int y, int d); + int maze_judge(int cx, int cy, int dx, int dy, int x, int y); +}; + +#endif // XKOBO_H_MAP diff --git a/missing b/missing new file mode 100755 index 0000000..0a7fb5a --- /dev/null +++ b/missing @@ -0,0 +1,283 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. +# Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# 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, 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. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +case "$1" in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case "$1" in + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch]" + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing 0.3 - GNU automake" + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + + aclocal) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then + # We have makeinfo, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + tar) + shift + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + fi + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar ${1+"$@"} && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar ${1+"$@"} && exit 0 + fi + firstarg="$1" + if shift; then + case "$firstarg" in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" ${1+"$@"} && exit 0 + ;; + esac + case "$firstarg" in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" ${1+"$@"} && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and you do not seem to have it handy on your + system. You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequirements for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 diff --git a/mkinstalldirs b/mkinstalldirs new file mode 100755 index 0000000..4f58503 --- /dev/null +++ b/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $ + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/myship.cpp b/myship.cpp new file mode 100644 index 0000000..954e9ae --- /dev/null +++ b/myship.cpp @@ -0,0 +1,665 @@ +/* +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996, Akira Higuchi + * Copyright (C) 2001-2003, 2007 David Olofson + * + * 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. + */ + +#include "kobo.h" +#include "screen.h" +#include "myship.h" +#include "enemies.h" +#include "gamectl.h" +#include "manage.h" +#include "random.h" +#include "sound.h" + +#define WING_GUN_OFFSET 4 + +_myship_state _myship::_state; +int _myship::di; +int _myship::virtx; +int _myship::virty; +int _myship::x; +int _myship::y; +int _myship::_health; +int _myship::health_time; +int _myship::explo_time; +int _myship::nose_reload_timer; +int _myship::nose_temperature; +int _myship::nose_alt = 0; +int _myship::tail_reload_timer; +int _myship::tail_temperature; +int _myship::tail_alt = WING_GUN_OFFSET; +int _myship::lapx; +int _myship::lapy; +int _myship::boltx[MAX_BOLTS]; +int _myship::bolty[MAX_BOLTS]; +int _myship::boltdx[MAX_BOLTS]; +int _myship::boltdy[MAX_BOLTS]; +int _myship::boltst[MAX_BOLTS]; +cs_obj_t *_myship::object; +cs_obj_t *_myship::bolt_objects[MAX_BOLTS]; +cs_obj_t *_myship::crosshair; + + +_myship::_myship() +{ + object = NULL; + memset(bolt_objects, 0, sizeof(bolt_objects)); + crosshair = NULL; +} + + +void _myship::state(_myship_state s) +{ + switch (s) + { + case dead: + if(object) + gengine->free_obj(object); + object = NULL; + if(crosshair) + gengine->free_obj(crosshair); + crosshair = NULL; + break; + case normal: + if(!object) + object = gengine->get_obj(LAYER_PLAYER); + if(object) + cs_obj_show(object); + break; + } + _state = s; +} + + +void _myship::off() +{ + state(dead); + int i; + for(i = 0; i < MAX_BOLTS; i++) + if(bolt_objects[i]) + { + gengine->free_obj(bolt_objects[i]); + bolt_objects[i] = NULL; + } +} + + +int _myship::init() +{ + nose_reload_timer = 0; + nose_temperature = 0; + tail_reload_timer = 0; + tail_temperature = 0; + x = WORLD_SIZEX >> 1; + y = (WORLD_SIZEY >> 2) * 3; + virtx = x - (WSIZE >> 1); + virty = y - (WSIZE >> 1); + lapx = 0; + lapy = 0; + di = 1; + state(normal); + + apply_position(); + + int i; + for(i = 0; i < MAX_BOLTS; i++) + { + boltx[i] = 0; + bolty[i] = 0; + boltdx[i] = 0; + boltdy[i] = 0; + boltst[i] = 0; + if(bolt_objects[i]) + gengine->free_obj(bolt_objects[i]); + bolt_objects[i] = NULL; + } + return 0; +} + + +void _myship::explode(int x, int y) +{ + if(explo_time == 56) + manage.noise_out(1000); + else if(explo_time > 64) + return; + + int d = 4096 - (64 - explo_time)*(64 - explo_time); + int i; + for(i = 0; i < 2; ++i) + { + int dx = (int)(pubrand.get(6)) - 32; + int dy = (int)(pubrand.get(6)) - 32; + int vx = dx * (4096 - d) >> 8; + int vy = dy * (4096 - d) >> 8; + dx = dx * d >> 12; + dy = dy * d >> 12; + enemies.make(enemies.randexp(), x + dx, y + dy, vx, vy, + explo_time >> 4); + } + ++explo_time; +} + + +#define BEAMV1 12 +#define BEAMV2 (BEAMV1*2/3) + +int _myship::move() +{ + int i; + di = gamecontrol.dir(); + + if(++health_time >= game.health_fade) + { + health_time = 0; + if(_health > game.health) + --_health; + } + + virtx = x - (WSIZE >> 1); + virty = y - (WSIZE >> 1); + if(_state == normal) + { + int vd, vo; + if(!prefs->cmd_pushmove) + { + vd = 2; + vo = 3; + } + else if(gamecontrol.dir_push()) + { + vd = 1; + vo = 1; + } + else + { + vd = 0; + vo = 0; + } + switch (di) + { + case 1: + virty -= vo; + break; + case 2: + virty -= vd; + virtx += vd; + break; + case 3: + virtx += vo; + break; + case 4: + virtx += vd; + virty += vd; + break; + case 5: + virty += vo; + break; + case 6: + virty += vd; + virtx -= vd; + break; + case 7: + virtx -= vo; + break; + case 8: + virtx -= vd; + virty -= vd; + break; + } + explo_time = 0; + } + else if(_state == dead) + explode(x, y); + + lapx = 0; + lapy = 0; + if(virtx < 0) + { + virtx += WORLD_SIZEX; + lapx = WORLD_SIZEX; + } + if(virtx >= WORLD_SIZEX) + { + virtx -= WORLD_SIZEX; + lapx = -WORLD_SIZEX; + } + if(virty < 0) + { + virty += WORLD_SIZEY; + lapy = WORLD_SIZEY; + } + if(virty >= WORLD_SIZEY) + { + virty -= WORLD_SIZEY; + lapy = -WORLD_SIZEY; + } + x = virtx + (WSIZE >> 1); + y = virty + (WSIZE >> 1); + + nose_temperature -= game.nosecooling; + if(nose_temperature < 0) + nose_temperature = 0; + tail_temperature -= game.tailcooling; + if(tail_temperature < 0) + tail_temperature = 0; + + if((_state == normal) && gamecontrol.get_shot()) + { + if(game.skill == SKILL_CLASSIC) + { + if(nose_reload_timer > 0) + --nose_reload_timer; + else + { + _myship::xkobo_shot(); + nose_reload_timer = game.noseloadtime - 1; + } + } + else + { + int fired = 0; + if(tail_reload_timer > 0) + --tail_reload_timer; + else if(!_myship::tail_fire()) + fired = 1; // Ok! + else + fired = 2; // Overheat! + if(nose_reload_timer > 0) + --nose_reload_timer; + else if(!_myship::nose_fire()) + fired = 1; // Ok! + else + fired = 2; // Overheat! + if(fired == 1) + sound.g_player_fire(); + else if(fired == 2) + sound.g_player_overheat(); + } + } + else + { + if(!gamecontrol.get_shot()) + { + nose_alt = 1; + sound.g_player_fire_off(); + } + if(nose_reload_timer > 0) + --nose_reload_timer; + if(tail_reload_timer > 0) + --tail_reload_timer; + } + + const char animtab[8] = { 3, 2, 1, 0, 1, 2, 1, 2 }; + for(i = 0; i < MAX_BOLTS; i++) + { + if(!boltst[i]) + continue; + ++boltst[i]; + boltx[i] += lapx; + bolty[i] += lapy; + boltx[i] += boltdx[i]; + bolty[i] += boltdy[i]; + if((ABS(boltx[i] - x) >= (VIEWLIMIT >> 1) + 16) || + (ABS(bolty[i] - y) >= (VIEWLIMIT >> 1) + 16)) + { + boltst[i] = 0; + if(bolt_objects[i]) + gengine->free_obj(bolt_objects[i]); + bolt_objects[i] = NULL; + } + else if(bolt_objects[i]) + cs_obj_image(bolt_objects[i], B_BOLT, + (bolt_objects[i]->anim.frame & 0xfffffffc) + + animtab[boltst[i] & 7]); + } + return 0; +} + + +void _myship::hit(int dmg) +{ + if(_state != normal) + return; + + if(!dmg) + dmg = 1000; + + if(_health && (dmg < _health)) + manage.noise_damage((float)dmg / _health); + else + manage.noise_damage(1.0f); + + _health -= dmg; + if(_health > 0) + sound.g_player_damage(); + else + { + _health = 0; + manage.lost_myship(); + state(dead); + sound.g_player_explo_start(); + } +} + + +void _myship::health_bonus(int h) +{ + if(game.skill == SKILL_CLASSIC) + return; + _health += game.health * h / 100; + health_time = 0; + if(_health > game.health * 2) + _health = game.health * 2; +} + + +int _myship::hit_structure() +{ + int x1, y1; + int i, ch; + + // Check bolts/objects + for(i = 0; i < MAX_BOLTS; i++) + { + if(!boltst[i]) + continue; + x1 = (boltx[i] & (WORLD_SIZEX - 1)) >> 4; + y1 = (bolty[i] & (WORLD_SIZEY - 1)) >> 4; + ch = screen.get_map(x1, y1); + if(!IS_SPACE(ch) && (ch & HIT_MASK)) + { + sound.g_bolt_hit(x1<<12, y1<<12); + enemies.make(&boltexpl, boltx[i], bolty[i]); + boltst[i] = 0; + if(bolt_objects[i]) + gengine->free_obj(bolt_objects[i]); + bolt_objects[i] = NULL; + } + } + + // Check player/bases + x1 = (x & (WORLD_SIZEX - 1)) >> 4; + y1 = (y & (WORLD_SIZEY - 1)) >> 4; + ch = screen.get_map(x1, y1); + if(!IS_SPACE(ch) && (ch & HIT_MASK)) + { + if(prefs->cmd_indicator) + sound.g_player_damage(); + else + _myship::hit(1000); + } + return 0; +} + + +int _myship::hit_bolt(int ex, int ey, int hitsize, int health) +{ + int dmg = 0; + int i; + for(i = 0; i < MAX_BOLTS; i++) + { + if(boltst[i] == 0) + continue; + if(ABS(ex - boltx[i]) >= hitsize) + continue; + if(ABS(ey - bolty[i]) >= hitsize) + continue; + if(!prefs->cmd_cheat) + { + boltst[i] = 0; + if(bolt_objects[i]) + gengine->free_obj(bolt_objects[i]); + bolt_objects[i] = NULL; + } + enemies.make(&boltexpl, boltx[i], bolty[i]); + dmg += game.bolt_damage; + if(dmg >= health) + break; + } + return dmg; +} + + +void _myship::put_crosshair() +{ + if(_state != normal) + return; + if(!crosshair) + { + crosshair = gengine->get_obj(LAYER_OVERLAY); + if(crosshair) + cs_obj_show(crosshair); + } + if(crosshair) + { + cs_obj_image(crosshair, B_CROSSHAIR, 0); + crosshair->point.v.x = PIXEL2CS(mouse_x - 8 - MARGIN); + crosshair->point.v.y = PIXEL2CS(mouse_y - MARGIN); + } +} + + +int _myship::put() +{ + /* Player */ + apply_position(); + if(object) + cs_obj_image(object, B_PLAYER, (di - 1) * 2); + + /* Bullets */ + int i; + for(i = 0; i < MAX_BOLTS; i++) + { + if(!bolt_objects[i]) + continue; + if(boltst[i]) + { + bolt_objects[i]->point.v.x = PIXEL2CS(boltx[i]); + bolt_objects[i]->point.v.y = PIXEL2CS(bolty[i]); + } + } + return 0; +} + + +void _myship::shot_single(int i, int dir, int offset) +{ + int doffset = (offset * 7071 + (offset > 0 ? 5000 : -5000)) / 10000; + boltst[i] = 1; + boltx[i] = x; + bolty[i] = y; + switch((dir + 1) % 8 + 1) + { + case 1: + bolty[i] -= offset; + break; + case 2: + bolty[i] -= doffset; + boltx[i] += doffset; + break; + case 3: + boltx[i] += offset; + break; + case 4: + boltx[i] += doffset; + bolty[i] += doffset; + break; + case 5: + bolty[i] += offset; + break; + case 6: + bolty[i] += doffset; + boltx[i] -= doffset; + break; + case 7: + boltx[i] -= offset; + break; + case 8: + boltx[i] -= doffset; + bolty[i] -= doffset; + break; + } + switch(dir) + { + case 1: + boltdx[i] = 0; + boltdy[i] = -BEAMV1; + break; + case 2: + boltdy[i] = -BEAMV2; + boltdx[i] = BEAMV2; + break; + case 3: + boltdx[i] = BEAMV1; + boltdy[i] = 0; + break; + case 4: + boltdx[i] = BEAMV2; + boltdy[i] = BEAMV2; + break; + case 5: + boltdx[i] = 0; + boltdy[i] = BEAMV1; + break; + case 6: + boltdy[i] = BEAMV2; + boltdx[i] = -BEAMV2; + break; + case 7: + boltdx[i] = -BEAMV1; + boltdy[i] = 0; + break; + case 8: + boltdx[i] = -BEAMV2; + boltdy[i] = -BEAMV2; + break; + } + if(!bolt_objects[i]) + bolt_objects[i] = gengine->get_obj(LAYER_PLAYER); + if(bolt_objects[i]) + { + bolt_objects[i]->point.v.x = PIXEL2CS(boltx[i]); + bolt_objects[i]->point.v.y = PIXEL2CS(bolty[i]); + cs_obj_image(bolt_objects[i], B_BOLT, (((dir - 1) & 0x3) << 2) + 3); + cs_obj_show(bolt_objects[i]); + } +} + + +int _myship::xkobo_shot() +{ + int i, j; + for(i = 0; i < game.bolts && boltst[i]; i++) + ; + for(j = i + 1; j < game.bolts && boltst[j]; j++) + ; + if(j >= game.bolts) + { + sound.g_player_overheat(1); + return 1; + } + shot_single(i, di, 0); + shot_single(j, (di > 4) ? (di - 4) : (di + 4), 0); + sound.g_player_fire(); + return 0; +} + + +int _myship::nose_fire() +{ + int i, j; + // Logic: If firing would cause overheat, wait! + if(255 - nose_temperature < game.noseheatup) + return 1; + for(i = 0; i < game.bolts && boltst[i]; i++) + ; + if(!game.altfire) + { + if(i >= game.bolts) + return 1; + shot_single(i, di, 0); + nose_temperature += game.noseheatup; + nose_reload_timer = game.noseloadtime; + return 0; + } + for(j = i + 1; j < game.bolts && boltst[j]; j++) + ; + if(j >= game.bolts) + return 1; + if(++nose_alt > 2) + nose_alt = 0; + shot_single(i, di, (nose_alt - 1) * WING_GUN_OFFSET); + if(++nose_alt > 2) + nose_alt = 0; + shot_single(j, di, (nose_alt - 1) * WING_GUN_OFFSET); + nose_temperature += game.noseheatup; + nose_reload_timer = game.noseloadtime; + return 0; +} + + +int _myship::tail_fire() +{ + int i; + if(255 - tail_temperature < game.tailheatup) + return 1; + for(i = 0; i < game.bolts && boltst[i]; i++) + ; + if(i >= game.bolts) + return 1; + if(game.altfire) + { + tail_alt = -tail_alt; + shot_single(i, (di > 4) ? (di - 4) : (di + 4), tail_alt); + } + else + shot_single(i, (di > 4) ? (di - 4) : (di + 4), 0); + tail_temperature += game.tailheatup; + tail_reload_timer = game.tailloadtime; + return 0; +} + + +void _myship::set_position(int px, int py) +{ + x = px; + y = py; + virtx = x - (WSIZE >> 1); + virty = y - (WSIZE >> 1); + + if(object) + { + apply_position(); + cs_point_force(&object->point); + } +} + + +void _myship::apply_position() +{ + if(object) + { + object->point.v.x = PIXEL2CS(x); + object->point.v.y = PIXEL2CS(y); + } + sound.g_position(x, y); +} diff --git a/myship.h b/myship.h new file mode 100644 index 0000000..18e953e --- /dev/null +++ b/myship.h @@ -0,0 +1,113 @@ +/* +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996, Akira Higuchi + * Copyright (C) 2001, 2003, 2007 David Olofson + * + * 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. + */ + +#ifndef XKOBO_H_MYSHIP +#define XKOBO_H_MYSHIP + +#include "config.h" +#include "gfxengine.h" +#include "game.h" + +#define ABS(x) (((x)>=0) ? (x) : (-(x))) +#define MAX(x,y) (((x)>(y)) ? (x) : (y)) + +//---------------------------------------------------------------------------// +enum _myship_state +{ + normal, + dead +}; + +class _myship +{ + static _myship_state _state; + static int di; /* direction */ + static int virtx, virty; /* scroll position */ + static int x, y; + static int _health; + static int health_time; + static int explo_time; + static int nose_reload_timer; + static int nose_temperature; + static int nose_alt; + static int tail_reload_timer; + static int tail_temperature; + static int tail_alt; + static int lapx, lapy; + static int boltx[MAX_BOLTS], bolty[MAX_BOLTS]; + static int boltdx[MAX_BOLTS], boltdy[MAX_BOLTS]; + static int boltst[MAX_BOLTS]; + /* For the gfxengine connection */ + static cs_obj_t *object; + static cs_obj_t *bolt_objects[MAX_BOLTS]; + static cs_obj_t *crosshair; + static void state(_myship_state s); + static void shot_single(int i, int dir, int offset); + static void apply_position(); + static void explode(int x, int y); + public: + _myship(); + static inline int get_x() + { + return x; + } + static inline int get_y() + { + return y; + } + static inline int get_virtx() + { + return virtx; + } + static inline int get_virty() + { + return virty; + } + static inline int get_nose_temp() + { + return nose_temperature; + } + static inline int get_tail_temp() + { + return tail_temperature; + } + static int init(); + static void off(); + static int move(); + static int put(); + static void put_crosshair(); + static int xkobo_shot(); + static int nose_fire(); + static int tail_fire(); + static int hit_structure(); + static int hit_bolt(int ex, int ey, int hitsize, int health); + static void hit(int dmg); + static int health() { return _health; } + static void health(int h) { _health = h; } + static void health_bonus(int h); + static void set_position(int px, int py); + static int alive() { return _state == normal; } +}; + +extern _myship myship; + +#endif // XKOBO_H_MYSHIP diff --git a/options.cpp b/options.cpp new file mode 100644 index 0000000..2161c6c --- /dev/null +++ b/options.cpp @@ -0,0 +1,506 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 2001-2003, 2006-2007 David Olofson + * Copyright (C) 2005 Erik Auerswald + * + * 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. + */ + + +#include "config.h" +#include "options.h" +#include "gfxengine.h" +#include "gamectl.h" +#include "a_types.h" +#include "kobo.h" + + +void system_options_t::build() +{ + medium(); + label("System Options"); + + space(); + small(); + xoffs = 0.6; + list("Maximum Frame Rate", &prf->max_fps, OS_REBUILD); + { + char buf[10]; + item("OFF", 0); + for(int i = 1; i < 25; i += 1) + { + snprintf((char *)&buf, sizeof(buf), + "%d Hz", i); + item(buf, i); + } + for(int i = 25; i < 100; i += 5) + { + snprintf((char *)&buf, sizeof(buf), + "%d Hz", i); + item(buf, i); + } + for(int i = 100; i <= 200; i += 10) + { + snprintf((char *)&buf, sizeof(buf), + "%d Hz", i); + item(buf, i); + } + } + if(prf->max_fps) + yesno("Strictly Regulated", &prf->max_fps_strict, 0); + + space(); + xoffs = 0.6; + list("Time Filter", &prf->timefilter, OS_UPDATE_ENGINE); + item("Off", 100); + item("Fast", 75); + item("Normal", 50); + item("Slow", 10); + item("Logic/Video Lock", 0); + onoff("Motion Interpolation", &prf->filter, OS_UPDATE_ENGINE); + + space(); + xoffs = 0.6; + yesno("Log Messages to File", &prf->logfile, OS_RESTART_LOGGER); + list("Log Output Format", &prf->logformat, 0); + item("Plain Text", 0); + item("ANSI Coloring", 1); + item("HTML", 2); + xoffs = 0.45; + list("Log Verbosity", &prf->logverbosity, 0); + item("Critical Errors Only", 0); + item("Errors Only", 1); + item("Errors & Warnings", 2); + item("Some Debug", 3); + item("More Debug", 4); + item("Everything", 5); + + big(); + space(); + xoffs = 0.5; + button("ACCEPT", OS_CLOSE); + button("CANCEL", OS_CANCEL); +} + + +void video_options_t::build() +{ + medium(); + label("Video Options"); + space(); + small(); + + if(firstbuild) + { + vmm_Init(VMM_ALL, 0); + VMM_Mode *vm = vmm_FindMode(prf->videomode); + if(vm) + { + if(vm->flags & VMM_PC) + showmodes = VMM_PC; + else if(vm->flags & VMM_TV) + showmodes = VMM_TV; + else if(vm->flags & VMM_4_3) + showmodes = VMM_4_3; + else if(vm->flags & VMM_3_2) + showmodes = VMM_3_2; + else if(vm->flags & VMM_5_4) + showmodes = VMM_5_4; + else if(vm->flags & VMM_16_10) + showmodes = VMM_16_10; + else if(vm->flags & VMM_16_9) + showmodes = VMM_16_9; + else + showmodes = VMM_ALL; + if(vm->flags & VMM_LORES) + showlow = 1; + } + else + { + showmodes = VMM_PC; + showlow = 0; + prf->videomode = -1; + } + firstbuild = 0; + } + + xoffs = 0.35; + list("Show Modes" , &showmodes, OS_REBUILD); + item("Show All", VMM_ALL); + item("Common PC/Mac Modes", VMM_PC); + item("Common TV Modes", VMM_TV); + item("4:3 (Standard CRT)", VMM_4_3); + item("3:2 (NTSC TV)", VMM_3_2); + item("5:4 (Some TFTs)", VMM_5_4); + item("16:10 (PC/Mac Widescreen)", VMM_16_10); + item("16:9 (TV Widescreen)", VMM_16_9); + xoffs = 0.7; + yesno("Show Odd Low Resolutions" , &showlow, OS_REBUILD); + xoffs = 0.5; + list("Display Mode", &prf->videomode, OS_RESTART_VIDEO | OS_REBUILD); + vmm_Init(showmodes, showlow ? 0 : VMM_LORES); + VMM_Mode *vm = vmm_First(); + char buf[256]; + buf[sizeof(buf) - 1] = 0; + while(vm) + { + if(vm->name) + snprintf(buf, sizeof(buf) - 1, "%dx%d (%s)", + vm->width, vm->height, vm->name); + else + snprintf(buf, sizeof(buf) - 1, "%dx%d", + vm->width, vm->height); + item(buf, vm->id); + vm = vmm_Next(vm); + } + item("Custom", -1); + if(prf->videomode < 0) + { + spin("Width", &prf->width, 32, 4096, "pixels", + OS_RESTART_VIDEO | OS_REBUILD); + spin("Height", &prf->height, 32, 4096, "pixels", + OS_RESTART_VIDEO | OS_REBUILD); + } + space(); + yesno("Fullscreen Display", &prf->fullscreen, OS_RESTART_VIDEO); + list("Display Depth", &prf->depth, OS_RESTART_VIDEO); + item("Default", 0); + item("8 bits", 8); + item("15 bits", 15); + item("16 bits", 16); + item("24 bits", 24); + item("32 bits", 32); +#if defined(HAVE_OPENGL) && !defined(GLSDL_OFF) + list("Display Driver", &prf->videodriver, OS_RESTART_VIDEO | + OS_REBUILD); + item("SDL 2D", GFX_DRIVER_SDL2D); + item("OpenGL/glSDL", GFX_DRIVER_GLSDL); +#else + prf->videodriver = GFX_DRIVER_SDL2D; +#endif + space(); + xoffs = 0.55; + switch(prf->videodriver) + { + case GFX_DRIVER_SDL2D: + list("Display Buffering Mode", &prf->doublebuf, OS_RESTART_VIDEO); + item("Single", 0); + item("Double", 1); + yesno("Software Shadow Buffer", &prf->shadow, OS_RESTART_VIDEO); + break; + case GFX_DRIVER_GLSDL: + yesno("Vertical Retrace Sync", &prf->vsync, OS_RESTART_VIDEO); + break; + } + list("Display Buffer Pages", &prf->pages, OS_UPDATE_ENGINE); + item("Assume Standard", -1); + item("Always Repaint", 0); + item("Single", 1); + item("Double", 2); + item("Triple", 3); + big(); + space(); + xoffs = 0.5; + button("ACCEPT", OS_CLOSE); + button("CANCEL", OS_CANCEL); +} + + +void graphics_options_t::build() +{ + medium(); + label("Graphics Options"); + space(); + small(); + xoffs = 0.6; + list("Scale Mode", &prf->scalemode, OS_RELOAD_GRAPHICS); + item("Nearest", GFX_SCALE_NEAREST); + item("Bilinear", GFX_SCALE_BILINEAR); +// FIXME: Bilinear+Oversampling is unreliable and doesn't help much anyway +// item("Bilinear+Oversampling", GFX_SCALE_BILIN_OVER); + +// FIXME: We need to specify a fallback chain for when filters do not support +// FIXME: ratios. So, we have quality and image specific requirements, and we +// FIXME: want a list of filters/modes in order of preference. + +// if((gengine->xscale() == 2.0f) && (gengine->yscale() == 2.0f)) +// { + item("Scale2x", GFX_SCALE_SCALE2X); + item("Diamond2x", GFX_SCALE_DIAMOND); +// } +// else if(prf->scalemode >= GFX_SCALE_SCALE2X) +// prf->scalemode = GFX_SCALE_BILINEAR; + space(1); + yesno("Dithering", &prf->use_dither, OS_RELOAD_GRAPHICS); + list("Dither Type", &prf->dither_type, OS_RELOAD_GRAPHICS); + item("2x2 Filter", 0); + item("4x4 Filter", 1); + item("Random", 2); + switch(prf->videodriver) + { + case GFX_DRIVER_GLSDL: + yesno("Broken RGBA8 (OpenGL)", &prf->broken_rgba8, + OS_RELOAD_GRAPHICS); + break; + } + space(); + yesno("Alpha Blending", &prf->alpha, OS_RELOAD_GRAPHICS); + space(); + list("Brightness", &prf->brightness, OS_RELOAD_GRAPHICS); + perc_list(50, 150, 10); + list("Contrast", &prf->contrast, OS_RELOAD_GRAPHICS); + perc_list(50, 150, 10); + big(); + space(); + xoffs = 0.5; + button("ACCEPT", OS_CLOSE); + button("CANCEL", OS_CANCEL); +} + + +void audio_options_t::build() +{ + medium(); + label("Sound Options"); + small(); + space(); + xoffs = 0.57; + yesno("Enable Sound", &prf->use_sound, OS_RESTART_AUDIO | OS_REBUILD); + if(prf->use_sound) + { + yesno("Enable Music", &prf->use_music, OS_RESTART_AUDIO | OS_REBUILD); + yesno("Cached Sounds", &prf->cached_sounds, OS_RELOAD_AUDIO_CACHE); + + //System + space(); + list("Sample Rate", &prf->samplerate, OS_RESTART_AUDIO); + item("8 kHz", 8000); + item("11025 Hz", 11025); + item("16 kHz", 16000); + item("22050", 22050); + item("32 kHz", 32000); + item("44.1 kHz", 44100); + item("48 kHz", 48000); + item("88.2 kHz", 88200); + item("96 kHz", 96000); + item("176.4 kHz", 176400); + item("192 kHz", 192000); + list("Mixing Quality", &prf->mixquality, OS_UPDATE_AUDIO); + item("Very Low", AQ_VERY_LOW); + item("Low", AQ_LOW); + item("Normal", AQ_NORMAL); + item("High", AQ_HIGH); + item("Very High", AQ_VERY_HIGH); + list("Sound Latency", &prf->latency, OS_RESTART_AUDIO); + { + char buf[10]; + for(int i = 1; i < 20; i += 1) + { + snprintf((char *)&buf, sizeof(buf), + "%d ms", i); + item(buf, i); + } + for(int i = 20; i < 50; i += 5) + { + snprintf((char *)&buf, sizeof(buf), + "%d ms", i); + item(buf, i); + } + for(int i = 50; i < 100; i += 10) + { + snprintf((char *)&buf, sizeof(buf), + "%d ms", i); + item(buf, i); + } + for(int i = 100; i <= 500; i += 25) + { + snprintf((char *)&buf, sizeof(buf), + "%d ms", i); + item(buf, i); + } + } +#ifdef HAVE_OSS + yesno("Use OSS Sound Driver", &prf->use_oss, OS_RESTART_AUDIO); +#else + // We're running out of space here... :-/ + space(); +#endif + //Mixer + list("Sound Effects Level", &prf->sfx_vol, OS_UPDATE_AUDIO); + item("OFF", 0); + perc_list(10, 90, 10); + perc_list(100, 200, 25); + if(prf->use_music) + { + list("Intro Music Level", &prf->intro_vol, OS_UPDATE_AUDIO); + item("OFF", 0); + perc_list(10, 90, 10); + perc_list(100, 200, 25); + list("In-Game Music Level", &prf->music_vol, OS_UPDATE_AUDIO); + item("OFF", 0); + perc_list(10, 90, 10); + perc_list(100, 200, 25); + } + + //Master effects + list("Ambience", &prf->reverb, OS_UPDATE_AUDIO); + item("OFF", 0); + item("Low", 50); + item("Normal", 100); + item("High", 175); + item("Extreme", 250); + list("Volume Boost", &prf->vol_boost, OS_UPDATE_AUDIO); + item("OFF", 0); + item("Low", 1); + item("Moderate", 2); + item("High", 3); + item("Extreme", 4); + } + space(); + big(); + xoffs = 0.5; + button("ACCEPT", OS_CLOSE); + button("CANCEL", OS_CANCEL | OS_UPDATE_AUDIO); +} + +void audio_options_t::undo_hook() +{ + clearstatus(OS_RELOAD | OS_RESTART | OS_UPDATE); + setstatus(OS_UPDATE_AUDIO); +} + + +void control_options_t::build() +{ + medium(); + label("Control Options"); + space(); + small(); + xoffs = 0.67; + yesno("Always Fire", &prf->always_fire, OS_RESTART_INPUT); + space(); + yesno("Broken NumPad Diagonals", &prf->broken_numdia, 0); + list("Diagonals Emphasis Filter", &prf->dia_emphasis, 0); + item("OFF", 0); + item("1 frame", 1); + item("2 frames", 2); + item("3 frames", 3); + item("4 frames", 4); + item("5 frames", 5); + space(); + + if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) + label("Could not initialize joysticks!"); + else + { + prf->number_of_joysticks = SDL_NumJoysticks(); + yesno("Use Joystick", &prf->use_joystick, + OS_RESTART_INPUT | OS_REBUILD); + if(prf->use_joystick) + { + if(prf->number_of_joysticks) + { + list("Joystick Number", &prf->joystick_no, + OS_RESTART_INPUT); + enum_list(0, prf->number_of_joysticks - 1); + } + else + label("No Joysticks Found!"); + } + } + space(); + + yesno("Use Mouse", &prf->use_mouse, OS_RESTART_INPUT | OS_REBUILD); + if(prf->use_mouse) + { + list("Mouse Control Mode", &prf->mousemode, OS_RESTART_INPUT); + item("Disabled", MMD_OFF); + item("Crosshair", MMD_CROSSHAIR); + } + space(); + yesno("In-game Mouse Capture", &prf->mousecapture, 0); + big(); + space(); + xoffs = 0.5; + button("ACCEPT", OS_CLOSE); + button("CANCEL", OS_CANCEL); +} + + +void game_options_t::build() +{ + medium(); + label("Game Options"); + space(); + small(); + xoffs = 0.6; + list("Radar Scroll Mode", &prf->scrollradar, 0); + item("Off", 0); +// FIXME: Radar sweep mode is broken! +// item("Sweep", 1); + item("Scroll", 2); + space(); + list("Get Ready Countdown", &prf->countdown, 0); + item("Quick Start", 0); + item("1 second", 1); + item("2 seconds", 2); + item("3 seconds", 3); + item("4 seconds", 4); + item("5 seconds", 5); + item("6 seconds", 6); + item("7 seconds", 7); + item("8 seconds", 8); + item("9 seconds", 9); + item("Wait Forever", 10); + space(); + list("Starfield Mode", &prf->starfield, OS_REBUILD); + item("None", STARFIELD_NONE); + item("Old (Flat)", STARFIELD_OLD); + item("Parallax", STARFIELD_PARALLAX); + if(prf->starfield == STARFIELD_PARALLAX) + { + list("Starfield Density", &prf->stars, 0); + item("Minimal", 50); + item("Low", 250); + item("Normal", 500); + item("High", 1000); + item("Massive", 2500); + item("Insane", 8000); + } + space(); + xoffs = 0.7; + list("Cannon Overheat Warning", &prf->overheatloud, 0); + item("Off", 0); + item("Soft", 50); + item("Normal", 100); + item("Loud", 200); + list("Cannon Sound Suppression", &prf->cannonloud, 0); + item("Off", 200); + item("Low", 100); + item("High", 50); + big(); + space(); + xoffs = 0.5; + button("ACCEPT", OS_CLOSE); + button("CANCEL", OS_CANCEL | OS_UPDATE_ENGINE); +} + +void game_options_t::undo_hook() +{ + clearstatus(OS_RELOAD | OS_RESTART | OS_UPDATE); + setstatus(OS_UPDATE_ENGINE); +} diff --git a/options.h b/options.h new file mode 100644 index 0000000..523d11b --- /dev/null +++ b/options.h @@ -0,0 +1,75 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 2001, 2003, 2007 David Olofson + * + * 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. + */ + +#ifndef _KOBO_OPTIONS_H_ +#define _KOBO_OPTIONS_H_ + +#include "cfgform.h" +#include "vidmodes.h" + +class system_options_t : public config_form_t +{ + public: + void build(); +}; + +class video_options_t : public config_form_t +{ + int showmodes; + int showlow; + int firstbuild; + public: + video_options_t() + { + showmodes = VMM_PC; + showlow = 0; + firstbuild = 1; + } + void build(); +}; + +class graphics_options_t : public config_form_t +{ + public: + void build(); +}; + +class audio_options_t : public config_form_t +{ + public: + void build(); + void undo_hook(); +}; + +class control_options_t : public config_form_t +{ + public: + void build(); +}; + +class game_options_t : public config_form_t +{ + public: + void build(); + void undo_hook(); +}; + +#endif //_KOBO_OPTIONS_H_ diff --git a/pfile.cpp b/pfile.cpp new file mode 100644 index 0000000..fb0addb --- /dev/null +++ b/pfile.cpp @@ -0,0 +1,282 @@ +/*(LGPL) +--------------------------------------------------------------------------- + pfile.cpp - Portable File Access Toolkit +--------------------------------------------------------------------------- + * Copyright (C) 2002, 2003, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define DBG(x) + +#include +#include +#include + +#include "kobolog.h" +#include "pfile.h" + + +/*---------------------------------------------------------- + Constructor/Destructor +----------------------------------------------------------*/ + +pfile_t::pfile_t(FILE *file) +{ + f = file; + _status = 0; + bufsize = bufused = bufpos = 0; + buffer = NULL; +} + + +pfile_t::~pfile_t() +{ + buffer_close(); +} + + +/*---------------------------------------------------------- + Internal buffer control +----------------------------------------------------------*/ + +int pfile_t::buffer_init() +{ + buffer_close(); + + bufsize = 1024; + buffer = (char *)malloc(bufsize); + if(!buffer) + return status(-1); + + bufused = bufpos = 0; + return _status; +} + + +int pfile_t::buffer_write() +{ + DBG(log_printf(D3LOG, "pfile_t::buffer_write() %d bytes\n", bufused);) + if(fwrite(buffer, bufused, 1, f) != 1) + return status(-1); + + bufused = bufpos = 0; + return _status; +} + + +int pfile_t::buffer_read(int len) +{ + buffer_close(); + + bufsize = len; + buffer = (char *)malloc(bufsize); + if(!buffer) + return status(-1); + + if(fread(buffer, bufsize, 1, f) != 1) + { + buffer_close(); + return status(-1); + } + + bufused = bufsize; + bufpos = 0; + return status(len); +} + + +void pfile_t::buffer_close() +{ + free(buffer); + buffer = NULL; + bufsize = bufused = bufpos = 0; +} + + +int pfile_t::read(void *data, int len) +{ + if(_status < 0) + return _status; + + if(buffer) + { + if(bufpos + len > bufused) + return -1; + memcpy(data, buffer + bufpos, len); + bufpos += len; + return len; + } + else + { + if(fread(data, len, 1, f) != 1) + return status(-1); + return len; + } +} + + +int pfile_t::write(void *data, int len) +{ + if(_status < 0) + return _status; + DBG(log_printf(D3LOG, "pfile_t::write(block of %d bytes)\n", len);) + + if(bufused + len > bufsize) + { + int nbs = (bufused + len) * 3 / 2; + char *nb = (char *)realloc(buffer, nbs); + if(!nb) + return -1; + buffer = nb; + bufsize = nbs; + } + memcpy(buffer + bufused, data, len); + bufused += len; + return len; +} + + + +/*---------------------------------------------------------- + Status +----------------------------------------------------------*/ + +int pfile_t::status() +{ + int os = _status; + _status = 0; + return os; +} + + +int pfile_t::status(int new_status) +{ + if(_status >= 0) + _status = new_status; + return _status; +} + + +/*---------------------------------------------------------- + Little endian read/write API +----------------------------------------------------------*/ + +int pfile_t::read(unsigned int &x) +{ + unsigned char b[4]; + int result = read(&b, 4); + if(4 == result) + x = b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24); + return result; +} + + +int pfile_t::read(int &x) +{ + unsigned int ux; + int result = read(ux); + if(4 == result) + x = (int)ux; + return result; +} + + +int pfile_t::write(unsigned int x) +{ + DBG(log_printf(D3LOG, "pfile_t::write(int)\n");) + unsigned char b[4]; + b[0] = x & 0xff; + b[1] = (x >> 8) & 0xff; + b[2] = (x >> 16) & 0xff; + b[3] = (x >> 24) & 0xff; + return status(write(&b, 4)); +} + + +int pfile_t::write(int x) +{ + return status(write((unsigned int)x)); +} + + +/*---------------------------------------------------------- + Unbuffered Write API +----------------------------------------------------------*/ +int pfile_t::write_ub(void *data, int len) +{ + DBG(log_printf(D3LOG, "pfile_t::write_ub(block of %d bytes)\n", len);) + if(fwrite(data, len, 1, f) != 1) + return status(-1); + + return _status; +} + + +int pfile_t::write_ub(unsigned int x) +{ + unsigned char b[4]; + b[0] = x & 0xff; + b[1] = (x >> 8) & 0xff; + b[2] = (x >> 16) & 0xff; + b[3] = (x >> 24) & 0xff; + return status(write_ub(&b, 4)); +} + + +int pfile_t::write_ub(int x) +{ + return status(write_ub((unsigned int)x)); +} + + +/*---------------------------------------------------------- + RIFF style chunk API +----------------------------------------------------------*/ + +int pfile_t::chunk_read() +{ + unsigned int size; + + chunk_writing = 0; + if(read(chunk_id) != 4) + return _status; + if(read(size) != 4) + return _status; + + return buffer_read(size); +} + + +int pfile_t::chunk_write(int id) +{ + chunk_writing = 1; + chunk_id = id; + buffer_init(); + return _status; +} + + +int pfile_t::chunk_end() +{ + if(chunk_writing) + { + write_ub(chunk_id); + write_ub(bufused); + buffer_write(); + } + buffer_close(); + return _status; +} diff --git a/pfile.h b/pfile.h new file mode 100644 index 0000000..15b9220 --- /dev/null +++ b/pfile.h @@ -0,0 +1,136 @@ +/*(LGPL) +--------------------------------------------------------------------------- + pfile.h - Portable File Access Toolkit +--------------------------------------------------------------------------- + * Copyright (C) 2002, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _PFILE_H_ +#define _PFILE_H_ + + //////////////////////////////////////////////////////////// + // Note that these classes can keep track of only one + // chunk at a time! Recursive chunk-inside-chunk is *NOT* + // supported. +//////////////////////////////////////////////////////////// + +//Create a little endian "FOURCC" ID code. (That is, 'a' will be +//first if the integer result is stored in little endian format +//in a file.) +#define MAKE_4CC(a, b, c, d) \ + ((a)&0xff | ((b)<<8)&0xff00 | \ + ((c)<<16)&0xff0000 | ((d)<<24)&0xff000000) + + + //////////////////////////////////////////////////////////// + // pfile_t - Portable File Access Base Class +//////////////////////////////////////////////////////////// +// Handles the reading and writing of data from/to file +// via the internal buffer. +// +// Reading can be done either directly from the file, or +// through the internal buffer. +// +// To read through the buffer, the desired number of +// bytes (for example, all bytes of a chunk) must be +// read into the buffer using read_buffer(). Subsequent +// reads will be from the buffer, and end-of-buffer is +// treated like EOF. +// +// Writing is always done to the buffer. To actually +// write data to file, call write_buffer(). +// +// IMPORTANT: +// Written data is *lost* if the pfile object +// is destroyed before write_buffer() is called! +// +// Reading RIFF style chunks: +// Use chunk_read() to read the entire chunk into +// the internal buffer. If this succeeds, +// chunk_type() and chunk_size() will return +// information about the chunk, and subsequent +// read() calls will read from the data section of +// the chunk. Use chunk_end() to stop reading, and +// discard the buffer. The next read() will start +// at the first byte after the end of the chunk. +// +// Writing RIFF style chunks: +// Use chunk_write() to set the type of the chunk +// to write. Subsequent write()ing will be done to +// the internal buffer, which will grow as needed. +// Use chunk_end() to write the whole chunk, with +// the correct size and all data. chunk_end() will +// discard the buffer and return the object to +// "direct" operation. +// +class pfile_t +{ + FILE *f; //Just a plain file handle... + int _status; // < 0 if there was an error + int bufsize; //Actual malloc()ed size of buffer + int bufused; //Current buffer write position + int bufpos; //Current buffer read position + char *buffer; //Read/write buffer + int chunk_id; //Chunk type ID + int chunk_writing; //1 if we're building a chunk for writing + + // Initialize buffer for writing. Subsequent write() calls + // will write to the buffer instead of the file. + int buffer_init(); + + // Initialize buffer, and read 'len' bytes into it. + // Subsequent read() calls will read from the buffer + // instead of the file. + int buffer_read(int len); + + //Unbuffered write operations + int write_ub(void *data, int len); + int write_ub(unsigned int x); + int write_ub(int x); + public: + pfile_t(FILE *file); + virtual ~pfile_t(); + + int status(); //Read and reset current status. + int status(int new_status); //Set (provided the current status + // >= 0) and return (new) status + + //These return # of bytes read, or -1 in case of EOF, or an error. + int read(void *data, int len); + int read(unsigned int &x); + int read(int &x); + + void buffer_close(); //Discard the buffer and return to + //"direct" operation. + + //These return # of bytes written, or -1 in case of EOF, or an error. + int write(void *data, int len); + int write(unsigned int x); + int write(int x); + + int buffer_write(); //Write the whole buffer to the file. + //This will flush the buffer as well. + + //RIFF style chunk handling + int chunk_read(); + int chunk_type() { return chunk_id; } + int chunk_size() { return bufused; } + int chunk_write(int id); + int chunk_end(); +}; + +#endif diff --git a/prefs.cpp b/prefs.cpp new file mode 100644 index 0000000..ea60a1e --- /dev/null +++ b/prefs.cpp @@ -0,0 +1,177 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 2001-2003, 2007 David Olofson + * Copyright (C) 2005 Erik Auerswald + * + * 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. + */ + +#include "kobolog.h" +#include "prefs.h" +#include "gfxengine.h" +#include "gamectl.h" +#include "a_types.h" +#include "game.h" + +void prefs_t::init() +{ + comment("--------------------------------------------"); + comment(" Kobo Deluxe "VERSION" Configuration File"); + comment("--------------------------------------------"); + comment(" Switches - [no]"); + comment(" Values - [|\"\"]"); + comment("--------------------------------------------"); + comment("--- System options --------------------------"); + yesno("logfile", logfile, 0); desc("Log To File"); + key("logformat", logformat, 0); desc("Log File Format"); + key("logverbosity", logverbosity, 2); desc("Log Verbosity Level"); + + comment("--- Input options --------------------------"); + yesno("joystick", use_joystick, 0); desc("Use Joystick"); + key("joystick_no", joystick_no, 0); desc("Joystick Number"); + yesno("mouse", use_mouse, 0); desc("Use Mouse"); + key("mousemode", mousemode, MMD_CROSSHAIR); desc("Mouse Control Mode"); + yesno("broken_numdia", broken_numdia, 0); desc("Broken NumPad Diagonals"); + key("dia_emphasis", dia_emphasis, 0); desc("Diagonals Emphasis Filter"); + yesno("always_fire", always_fire, 0); desc("Always Fire"); + yesno("mousecapture", mousecapture, 1); desc("In-game Mouse Capture"); + + comment("--- Game options ---------------------------"); + key("scrollradar", scrollradar, 2); desc("Radar Scroll Mode"); + yesno("filter", filter, 1); desc("Motion Interpolation"); + key("timefilter", timefilter, 50); desc("Time Filter"); + key("countdown", countdown, 5); desc("Get Ready Countdown"); + key("starfield", starfield, 2); desc("Starfield Style"); + key("stars", stars, 500); desc("Number of Parallax Stars"); + key("overheatloud", overheatloud, 100); desc("Overheat Warning Loudness"); + key("cannonloud", cannonloud, 100); desc("Player Cannons Loudness"); + + comment("--- Sound settings -------------------------"); + yesno("sound", use_sound, 1); desc("Enable Sound"); + yesno("music", use_music, 1); desc("Enable Music"); + yesno("cached_sounds", cached_sounds, 0); desc("Use Cached Sounds"); +#ifdef HAVE_OSS + yesno("oss", use_oss, 0); +#else + yesno("oss", use_oss, 0, 0); //Don't write! +#endif + desc("Use OSS Sound Driver"); + key("samplerate", samplerate, 44100); desc("Sample Rate"); + key("latency", latency, 50); desc("Sound Latency"); + key("mixquality", mixquality, AQ_HIGH); desc("Mixing Quality"); + key("vol", volume, 100); desc("Master Volume"); + key("intro_vol", intro_vol, 100); desc("Intro Music Volume"); + key("sfx_vol", sfx_vol, 100); desc("Sound Effects Volume"); + key("music_vol", music_vol, 30); desc("In-Game Music Volume"); + key("reverb", reverb, 100); desc("Reverb Level"); + key("vol_boost", vol_boost, 0); desc("Volume Boost"); + + comment("--- Video settings -------------------------"); + yesno("fullscreen", fullscreen, 0); desc("Fullscreen Display"); + key("videodriver", videodriver, GFX_DRIVER_SDL2D); + desc("Display Driver"); + key("width", width, 640); desc("Horizontal Resolution"); + key("height", height, 480); desc("Vertical Resolution"); + key("aspect", aspect, 1000); desc("Pixel Aspect Ratio"); + key("depth", depth, 0); desc("Display Depth"); + key("maxfps", max_fps, 100); desc("Maximum fps"); + key("maxfpsstrict", max_fps_strict, 0); desc("Strictly Regulated fps"); + key("buffer", doublebuf, 1); desc("Display Buffer Mode"); + yesno("shadow", shadow, 1); desc("Use Software Shadow Buffer"); + key("videomode", videomode, 0x04330); desc("Video Mode"); + yesno("vsync", vsync, 1); desc("Enable Vertical Sync"); + key("videopages", pages, -1); desc("Number of Video Pages"); + + comment("--- Graphics settings ----------------------"); + key("scalemode", scalemode, 1); desc("Scaling Filter Mode"); + yesno("dither", use_dither, 1); desc("Use Dithering"); + key("dither_type", dither_type, 0); desc("Dither Type"); + yesno("broken_rgba8", broken_rgba8, 0); desc("Broken RGBA (OpenGL)"); + yesno("alpha", alpha, 1); desc("Use Alpha Blending"); + key("brightness", brightness, 100); desc("Brightness"); + key("contrast", contrast, 100); desc("Contrast"); + + comment("--- File paths -----------------------------"); + key("files", dir, ""); desc("Game Root Path"); + key("gfx", gfxdir, ""); desc("Graphics Data Path"); + key("sfx", sfxdir, ""); desc("Sound Data Path"); + key("scores", scoredir, ""); desc("Score File Path"); + + // Obsolete stuff (not written into new files) + key("size", o_size, 0, 0); desc("Screen Size (Obsolete)"); + key("wait", o_wait_msec, 30); desc("Game Speed (Obsolete)"); + key("bgm", o_bgm_indexfile, "", 0); + desc("Background Music File (Obsolete)"); + key("threshold", o_threshold, 200, 0); desc("Limiter Gain"); + key("release", o_release, 50, 0); desc("Limiter Speed"); + key("internalres", o_internalres, 1, 0); desc("Texture Resolution"); + + comment("--- Temporary variables --------------------"); + key("last_profile", last_profile, 0); + desc("Last used player profile"); + key("number_of_joysticks", number_of_joysticks, 0); + desc("Number of Connected Joysticks"); + + // "Commands" - never written to config files + command("showcfg", cmd_showcfg); desc("Show Configuration"); + command("hiscores", cmd_hiscores); desc("List High Scores"); + command("highscores", cmd_hiscores); desc("List High Scores"); + command("override", cmd_override); desc("Ignore Configuration File"); + command("debug", cmd_debug); desc("Enable Debug Features"); + command("fps", cmd_fps); desc("Show Frame Rate"); + command("noframe", cmd_noframe); desc("Remove Window Frame"); + command("midi", cmd_midi); desc("Enable MIDI Input"); + command("cheat", cmd_cheat); desc("Enable Cheat Mode"); + command("indicator", cmd_indicator); + desc("Enable Collision Indicator Mode"); + command("pushmove", cmd_pushmove); desc("Enable Push Move Mode"); + command("noparachute", cmd_noparachute); desc("Disable SDL Parachute"); + command("pollaudio", cmd_pollaudio); desc("Use Polling Audio Output"); + command("autoshot", cmd_autoshot); desc("Ingame screenshots/movie"); + command("help", cmd_help); desc("Print usage info and exit"); + command("options_man", cmd_options_man); + desc("Print options for 'man'"); +} + + +void prefs_t::postload() +{ + if(redefined(o_size)) + { + //For pre 20011007 compatibility + width = 320 * o_size; + height = 240 * o_size; + o_size = 0; + accept(o_size); + } + + if((o_wait_msec != 30) && !cmd_cheat) + { + log_printf(ELOG, "'wait' is only avaliable in cheat mode!\n"); + o_wait_msec = 30; + } + + if(scrollradar == 1) + { + log_printf(ELOG, "Radar sweep mode broken and disabled!\n"); + scrollradar = 2; + } + + // Some unimplemented enums were removed in 0.4.1 + if(videodriver != GFX_DRIVER_SDL2D) + videodriver = GFX_DRIVER_GLSDL; +} diff --git a/prefs.h b/prefs.h new file mode 100644 index 0000000..b56bc43 --- /dev/null +++ b/prefs.h @@ -0,0 +1,137 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 2001-2003, 2007 David Olofson + * Copyright (C) 2005 Erik Auerswald + * + * 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. + */ + +#ifndef _KOBO_PREFS_H_ +#define _KOBO_PREFS_H_ + +#include "aconfig.h" +#include "cfgparse.h" + +class prefs_t : public config_parser_t +{ + public: + //System options + int logfile; //Log messages to log.txt/html + int logformat; //0: text, 1: ANSI, 2: HTML + int logverbosity; + + //Input options + int use_joystick; + int joystick_no; //which joystick to use + int use_mouse; + int mousemode; + int broken_numdia; + int dia_emphasis; + int always_fire; + int mousecapture; + + //Game options + int filter; //Use motion filtering + int timefilter; //Delta time filter + int scrollradar; //Radar display mode + int countdown; //"Get Ready" countdown + int starfield; //None/Old/parallax + int stars; //Number of parallax stars + int overheatloud; //Overheat warning loudness + int cannonloud; //Cannon loudness + + //Sound: System + int use_sound; //Enable sound + int use_music; //Enable "real" music + int cached_sounds; //Use prerendered waveforms + int use_oss; //Use OSS audio driver + int samplerate; + int latency; //Audio latency in ms + int mixquality; //Mixer quality control + int volume; //Digital master volume + //Sound: Mixer + int intro_vol; //Intro music volume + int sfx_vol; //Sound effects volume + int music_vol; //In-game music volume + //Sound: Master Effects + int reverb; //Master reverb level + int vol_boost; //Master volume boost + + //Video settings + int fullscreen; //Use fullscreen mode + int videodriver; //Internal video driver + int width; //Screen/window width + int height; //Screen/window height + int aspect; //Pixel aspect ratio * 1000 + int depth; //Bits per pixel + int max_fps; //Maximum fps + int max_fps_strict; //Strictly regulated fps limiter + int doublebuf; //Use double buffering + int shadow; //Use software shadow buffer + int videomode; //New video mode codes + int vsync; //Vertical (retrace) sync + int pages; //Number of physical video pages + + //Graphics settings + int scalemode; //Scaling filter mode + int use_dither; + int dither_type; + int broken_rgba8; //For some OpenGL setups + int alpha; //Alpha blending + int brightness; //Graphics brightness + int contrast; //Graphics contrast + + //File paths + cfg_string_t dir; //Path to kobo-deluxe/ + cfg_string_t gfxdir; //Path to gfx/ + cfg_string_t sfxdir; //Path to sfx/ + cfg_string_t scoredir; //Path to scores/ + + //Obsolete stuff (compatibility) + int o_size; //Screen scale + int o_wait_msec; //ms per control system frame + cfg_string_t o_bgm_indexfile; //Ext playlist path + int o_threshold; //Limiter threshold + int o_release; //Limiter release rate + int o_internalres; //Internal resolution for OpenGL + + //"Hidden" stuff ("to remember until next startup") + int last_profile; //Last used player profile + int number_of_joysticks; //no of connected joysticks + + void init(); + void postload(); + + /* "Commands" - never written to config files */ + int cmd_showcfg; + int cmd_hiscores; + int cmd_override; + int cmd_debug; + int cmd_fps; + int cmd_noframe; + int cmd_midi; + int cmd_cheat; //Unlimited lives; select any starting stage + int cmd_indicator; //Enable collision testing mode + int cmd_pushmove; //Stop when not holding any direction down + int cmd_noparachute; //Disable SDL parachute + int cmd_pollaudio; //Use polling based audio instead of thread + int cmd_autoshot; //Take ingame screenshots + int cmd_help; //Show help and exit + int cmd_options_man; //Output OPTIONS doc in Un*x man source format +}; + +#endif //_KOBO_PREFS_H_ diff --git a/radar.cpp b/radar.cpp new file mode 100644 index 0000000..5932e0b --- /dev/null +++ b/radar.cpp @@ -0,0 +1,297 @@ +/* +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2001-2003, 2005-2007 David Olofson + * + * 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. + */ + +#include +#include + +#include "kobo.h" +#include "kobolog.h" +#include "screen.h" +#include "myship.h" +#include "radar.h" +#include "prefs.h" +#include "random.h" + +/*--------------------------------------------------------------------- + radar_map_t +---------------------------------------------------------------------*/ +radar_map_t::radar_map_t() +{ + w = MAP_SIZEX; + h = MAP_SIZEY; + pixel_core = 0; + pixel_launcher = 0; + pixel_hard = 0; + pixel_bg = 0; +} + + +void radar_map_t::update(int x, int y, int force) +{ + int a = MAP_BITS(screen.get_map(x, y)); + if(IS_SPACE(a)) + { + if(!force) + return; + foreground(pixel_bg); + } + else if(a & CORE) + foreground(pixel_core); + else if((a == U_MASK) || (a == R_MASK) || (a == D_MASK) || (a == L_MASK)) + foreground(pixel_launcher); + else if((a & HIT_MASK)) + foreground(pixel_hard); + point(x, y); +} + + +void radar_map_t::refresh(SDL_Rect *r) +{ + clear(r); + SDL_Rect nr; + if(!r) + { + nr.x = 0; + nr.y = 0; + nr.w = w; + nr.h = h; + r = &nr; + } + int i, j; + for(i = r->x; i < r->w; i++) + for(j = r->y; j < r->h; j++) + update(i, j, 0); +} + + +/*--------------------------------------------------------------------- + radar_window_t +---------------------------------------------------------------------*/ +radar_window_t::radar_window_t() +{ + _mode = RM_OFF; + old_scrollradar = -1; + xpos = -1; + ypos = -1; + xoffs = 0; + yoffs = 0; + time = 0; + refresh_pos = 0; +} + + +void radar_window_t::update(int mx, int my) +{ + wmap->update(mx, my, 1); + if(prefs->scrollradar == 1) + return; /* No instant updates in sweep mode! */ + SDL_Rect r; + r.x = (mx - xoffs) & (MAP_SIZEX-1); + r.y = (my - yoffs) & (MAP_SIZEY-1); + r.w = r.h = 1; + invalidate(&r); +} + + +void radar_window_t::update_player(int px, int py) +{ + SDL_Rect r; + r.x = (px - pxoffs) & (MAP_SIZEX-1); + r.y = (py - pyoffs) & (MAP_SIZEY-1); + r.w = r.h = 1; + invalidate(&r); +} + + +void radar_window_t::refresh(SDL_Rect *r) +{ + int t = SDL_GetTicks(); + clear(r); + switch(_mode) + { + case RM__REINIT: + case RM_OFF: + case RM_NOISE: + case RM_INFO: + break; + case RM_SHOW: + blit(0, 0, wmap); + break; + case RM_RADAR: + switch(prefs->scrollradar) + { + case 0: + blit(0, 0, wmap); + break; + case 1: + foreground(map_rgb(48, 192, 160)); + fillrect(0, refresh_pos - 1, wmap->w, 1); + foreground(map_rgb(40, 160, 128)); + fillrect(0, refresh_pos - 2, wmap->w, 1); + foreground(map_rgb(32, 128, 96)); + fillrect(0, refresh_pos - 3, wmap->w, 1); + // Fallthrough! + case 2: + blit(-xoffs, MAP_SIZEY - yoffs, wmap); + blit(-xoffs, -yoffs, wmap); + blit(MAP_SIZEX - xoffs, MAP_SIZEY - yoffs, wmap); + blit(MAP_SIZEX - xoffs, -yoffs, wmap); + break; + } + if(_mode != RM_SHOW) + { + foreground(map_rgb((t >> 1) & 255, + 120 + ((t >> 2) & 127), + 120 + ((t >> 2) & 127))); + point((xpos - pxoffs) & (MAP_SIZEX - 1), + (ypos - pyoffs) & (MAP_SIZEY - 1)); + } + break; + } +} + + +void radar_window_t::mode(radar_modes_t newmode) +{ + if(newmode == RM__REINIT) + newmode = _mode; + wmap->offscreen(); + wmap->pixel_core = wmap->map_rgb(255, 255, 128); + wmap->pixel_hard = wmap->map_rgb(64, 128, 128); + wmap->pixel_launcher = wmap->map_rgb(64, 200, 240); + wmap->pixel_bg = wmap->map_rgb(32, 48, 64); + wmap->background(wmap->pixel_bg); + wmap->colorkey(wmap->pixel_bg); + _mode = newmode; + refresh_pos = 0; + time = SDL_GetTicks(); + wmap->invalidate(); + invalidate(); +} + + +void radar_window_t::set_scroll(int xs, int ys) +{ + xoffs = (xs + MAP_SIZEX / 2) & (MAP_SIZEX - 1); + yoffs = (ys + MAP_SIZEY / 2) & (MAP_SIZEY - 1); +} + + +void radar_window_t::sweep(void) +{ + int start_y = refresh_pos; + int ct = SDL_GetTicks(); + int t = ct - time; + int end_y = t / 8; + if((t < 0) || (end_y >= wmap->h)) + { + end_y = wmap->h; + time = ct; + refresh_pos = 0; + set_scroll(xpos, ypos); + platched = 0; + } + else + refresh_pos = end_y; + if(!platched) + if(refresh_pos > ((ypos - pyoffs) & (MAP_SIZEY - 1))) + { + pxoffs = xoffs; + pyoffs = yoffs; + platched = 1; + } + SDL_Rect r; + r.x = 0; + r.y = start_y >= 3 ? start_y - 3 : 0; + r.w = wmap->w; + r.h = end_y - start_y + 1; + invalidate(&r); +} + + +void radar_window_t::radar() +{ + int xpos_new = (myship.get_x() & (WORLD_SIZEX - 1)) >> 4; + int ypos_new = (myship.get_y() & (WORLD_SIZEY - 1)) >> 4; + switch(prefs->scrollradar) + { + case 0: /* No scrolling */ + // Note this first one just invalidates the *area* + // that the player is in! That is, if the player + // has moved, the player will be somewhere else + // when the rendering is performed, and no player + // cursor is rendered. + update_player(xpos, ypos); + if((xpos_new == xpos) && (ypos_new == ypos)) + break; + xpos = xpos_new; + ypos = ypos_new; + pxoffs = pyoffs = xoffs = yoffs = 0; + update_player(xpos, ypos); + break; + case 1: /* Radar screen sweep */ + update_player(xpos, ypos); + xpos = xpos_new; + ypos = ypos_new; + sweep(); + update_player(xpos, ypos); + break; + case 2: /* Plain scrolling */ + if((xpos_new == xpos) && (ypos_new == ypos)) + break; + xpos = xpos_new; + ypos = ypos_new; + set_scroll(xpos, ypos); + pxoffs = xoffs; + pyoffs = yoffs; + invalidate(); + break; + } +} + + +void radar_window_t::frame() +{ + if(prefs->scrollradar != old_scrollradar) + { + old_scrollradar = prefs->scrollradar; + refresh_pos = 0; + time = SDL_GetTicks(); + pxoffs = pyoffs = xoffs = yoffs = 0; + invalidate(); + } + switch(_mode) + { + case RM__REINIT: + case RM_OFF: + break; + case RM_RADAR: + radar(); + break; + case RM_SHOW: + break; + case RM_NOISE: + case RM_INFO: + invalidate(); + break; + } +} diff --git a/radar.h b/radar.h new file mode 100644 index 0000000..4e55a8e --- /dev/null +++ b/radar.h @@ -0,0 +1,76 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2001-2003, 2005-2007 David Olofson + * + * 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. + */ + +#ifndef KOBO_RADAR_H +#define KOBO_RADAR_H + +#include "window.h" + +enum radar_modes_t +{ + RM__REINIT, // Reinitialize (lost windows etc) + RM_OFF, // Gray, empty + RM_RADAR, // Radar display + RM_SHOW, // Show map (no player ship cursor) + RM_NOISE, // Radar interference + RM_INFO // Scrolling info display +}; + +// The off-screen map window +class radar_map_t : public window_t +{ + public: + int w, h; //Map size (tiles) + Uint32 pixel_core; //Pixel colors + Uint32 pixel_launcher; + Uint32 pixel_hard; + Uint32 pixel_bg; + radar_map_t(); + void refresh(SDL_Rect *r); + void update(int x, int y, int force); //Update one tile +}; + +// The on-screen radar window +class radar_window_t : public window_t +{ + radar_modes_t _mode; + int old_scrollradar; //To detect prefs change + int xpos, ypos; //Player position (tiles) + int xoffs, yoffs; //Scroll offset (tiles) + int pxoffs, pyoffs; //Scroll offset for player marker + int platched; //p*offset latched yet? + int time; //for delta time calc + int refresh_pos; //Sweeping refresh posn + void sweep(); //Incremental sweeping refresh + void radar(); //Drive any actual radar mode + void noise(); //Render noise effect + void set_scroll(int xs, int ys);//Set map scroll offset + public: + radar_window_t(); + void refresh(SDL_Rect *r); + void mode(radar_modes_t newmode);//Set radar mode + void update(int mx, int my); //Update map + radar + void update_player(int px, int py);//Update player cursor + void frame(); //Track player, drive logic etc... +}; + +#endif // KOBO_RADAR_H diff --git a/random.cpp b/random.cpp new file mode 100644 index 0000000..051a794 --- /dev/null +++ b/random.cpp @@ -0,0 +1,26 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996, Akira Higuchi + * Copyright (C) 2002, David Olofson + * + * 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. + */ + +#include "random.h" + +rand_num_t gamerand; +rand_num_t pubrand; diff --git a/random.h b/random.h new file mode 100644 index 0000000..97c69c7 --- /dev/null +++ b/random.h @@ -0,0 +1,71 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996, Akira Higuchi + * Copyright (C) 2002, 2007 David Olofson + * + * 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. + */ + +#ifndef _KOBO_RANDOM_H_ +#define _KOBO_RANDOM_H_ + +#include +#include "glSDL.h" + +class rand_num_t +{ + Uint32 seed; + public: + void init(Uint32 _seed = 0) + { + if(_seed) + seed = _seed; + else + seed = SDL_GetTicks(); + } + Uint32 get_seed() { return seed; } + Uint32 get() + { + seed *= 1566083941UL; + seed++; + seed &= 0xffffffffUL; + return seed; + } + Uint32 get(Uint32 bit) + { + seed *= 1566083941UL; + seed++; + seed &= 0xffffffffUL; + return (seed >> (32 - bit)); + } +}; + +//This instance is *ONLY* for map generation and +//pure game AI stuff!!! Stealing numbers from here +//will screw up demo playback totally, as demos +//record only the seed used for each level; not +//every random number used. +extern rand_num_t gamerand; + +//Use this "public" random number generator for +//other stuff, like explosion effects, and things +//that may pick different amounts of numbers +//depending on engine version, configuration, +//computer speed and the like. +extern rand_num_t pubrand; + +#endif //_KOBO_RANDOM_H_ diff --git a/rwc-20040113.txt b/rwc-20040113.txt new file mode 100644 index 0000000..6af3765 --- /dev/null +++ b/rwc-20040113.txt @@ -0,0 +1,15 @@ +-------------------------------------------------------- + (lines) (words) (bytes) +Root: 17203 46478 367321 +-------------------------------------------------------- +Subdirs: + ./autom4te.cache 0 0 0 + ./data 35 108 736 + ./eel 4474 13404 105546 + ./graphics 9916 28839 212012 + ./sound 16624 55079 397875 +-------------------------------------------------------- +Total: 48252 143908 1083490 +-------------------------------------------------------- +Filename pattern: *.([cChH]|[ch]pp|[CH]PP) +-------------------------------------------------------- diff --git a/rwc-20071005.txt b/rwc-20071005.txt new file mode 100644 index 0000000..54a108d --- /dev/null +++ b/rwc-20071005.txt @@ -0,0 +1,15 @@ +-------------------------------------------------------- + (lines) (words) (bytes) +Root: 17554 47376 376215 +-------------------------------------------------------- +Subdirs: + ./autom4te.cache 0 0 0 + ./data 35 108 736 + ./eel 4474 13401 105519 + ./graphics 10588 31216 229546 + ./sound 16631 55108 398040 +-------------------------------------------------------- +Total: 49282 147209 1110056 +-------------------------------------------------------- +Filename pattern: *.([cChH]|[ch]pp|[CH]PP) +-------------------------------------------------------- diff --git a/scenes.cpp b/scenes.cpp new file mode 100644 index 0000000..583fb40 --- /dev/null +++ b/scenes.cpp @@ -0,0 +1,1179 @@ + +/* + * XKOBO, a video-oriented game + * Copyright (C) 1995,1996 Akira Higuchi + * a-higuti@math.hokudai.ac.jp + * + * 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. + * + */ + +#include "scenes.h" + +const _scene scene[] = { +#if 0 + /* Test map */ + { + 0, 32, 0, + &enemy_m1, 128, &beam, 16, + 1,{ + {&enemy_m4, 1, 5}, +// {&enemy4, 10, 5}, + }, + 1,{ +// {32, 64, 31, 62}, + {48, 64, 4, 4}, + }, + }, +#endif + /* 1 */ + { + 0, 32, 96, + &beam, 128, &beam, 16, + 1,{ + {&enemy4, 10, 5}, + }, + 2,{ + {48, 64, 4, 4}, + {24, 80, 4, 4}, + }, + }, + /* 2 */ + { + 0, 32, 96, + &beam, 64, &beam, 64, + 3,{ + {&enemy4, 10, 5}, + {&enemy4, 10, 5}, + {&enemy1, 10, 5}, + }, + 4,{ + {16, 48, 6, 6}, + {48, 48, 6, 6}, + {16, 64, 6, 6}, + {48, 64, 6, 6}, + }, + }, + /* 3 */ + { + 64, 32, 64, + &beam, 64, &beam, 16, + 1,{ + {&rock, 20, 3}, + }, + 6,{ + {16, 40, 4, 4}, + {16, 60, 4, 4}, + {16, 80, 4, 4}, + {48, 40, 4, 4}, + {48, 60, 4, 4}, + {48, 80, 4, 4}, + }, + }, + /* 4 */ + { + 0, 32, 96, + &beam, 32, &beam, 8, + 1,{ + {&enemy4, 10, 5}, + }, + 3,{ + {14, 55, 6, 6}, + {55, 14, 6, 6}, + {35, 70, 6, 6}, + }, + }, + /* 5 */ + { + 0, 32, 96, + &beam, 128, &beam, 128, + 3,{ + {&enemy6, 10, 5}, + {&enemy6, 10, 5}, + {&enemy4, 10, 5}, + }, + 2,{ + {32, 32, 6, 6}, + {32, 64, 6, 6}, + }, + }, + /* 6 */ + { + 0, 32, 96, + &enemy1, 32, &enemy1, 8, + 0,{ + {&enemy1, 40, 10}, + }, + 1,{ + {32, 64, 8, 8}, + }, + }, + /* 7 */ + { + 0, 32, 64, + &ring, 64, &enemy1, 32, + 2,{ + {&enemy3, 30, 5}, + {&enemy6, 20, 5}, + }, + 8,{ + {32, 54, 3, 3}, + {42, 54, 3, 3}, + {42, 64, 3, 3}, + {42, 74, 3, 3}, + {32, 74, 3, 3}, + {22, 74, 3, 3}, + {22, 64, 3, 3}, + {22, 54, 3, 3}, + }, + }, + /* 8 */ + { + 0, 32, 64, + &enemy4, 64, &enemy1, 8, + 3,{ + {&ring , 20, 5}, + {&ring , 20, 5}, + {&ring , 20, 5}, + }, + 8,{ + {48, 64, 4, 4}, + {16, 64, 4, 4}, + {32, 80, 4, 4}, + {32, 48, 4, 4}, + {44, 76, 4, 4}, + {20, 76, 4, 4}, + {44, 52, 4, 4}, + {20, 52, 4, 4}, + }, + }, + /* 9 */ + { + 0, 32, 96, + &beam, 16, &beam, 8, + 1,{ + {&bomb2, 20, 5}, + }, + 1,{ + {32, 32, 7, 7}, + }, + }, + /* 10 */ + { + 0, 32, 96, + &bomb1, 128, &bomb1, 4, + 1,{ + {&rock, 100, 5}, + }, + 1,{ + {32, 64, 12, 12}, + }, + }, + /* 11 */ + { + 0, 32, 96, + &enemy2, 128, &enemy1, 32, + 5,{ + {&rock, 30, 5}, + {&enemy3, 50, 5}, + {&enemy6, 20, 5}, + {&enemy7, 10, 5}, + {&bomb1, 20, 5}, + }, + 6,{ + { 5, 64, 3, 3}, + {15, 64, 3, 3}, + {25, 64, 3, 3}, + {35, 64, 3, 3}, + {45, 64, 3, 3}, + {55, 64, 3, 3}, + }, + }, + /* 12 */ + { + 0, 47, 33, + &beam, 128, &beam, 16, + 3,{ + {&enemy6, 10, 5}, + {&enemy6, 10, 5}, + {&rock, 100, 5}, + }, + 3,{ + { 15, 88, 12, 12}, + { 21, 20, 12, 12}, + { 50, 70, 12, 12}, + }, + }, + /* 13 */ + { + 0, 32, 64, + &bomb2, 128, &enemy1, 32, + 2,{ + {&bomb1, 30, 5}, + {&bomb1, 20, 5}, + }, + 5,{ + { 24, 66, 3, 3}, + { 23, 80, 3, 3}, + { 44, 50, 3, 3}, + { 39, 102, 3, 3}, + { 15, 43, 3, 3}, + }, + }, + /* 14 */ + { + 0, 24, 107, + &enemy2, 128, &beam, 8, + 4,{ + {&enemy3, 10, 5}, + {&enemy6, 10, 5}, + {&rock, 100, 5}, + {&enemy2, 10, 5}, + }, + 3,{ + { 9, 36, 5, 5}, + { 44, 19, 5, 5}, + { 46, 79, 5, 5}, + }, + }, + /* 15 */ + { + 0, 36, 94, + &enemy4, 64, &bomb1, 32, + 2,{ + {&enemy6, 10, 5}, + {&rock, 50, 5}, + }, + 5,{ + { 16, 54, 4, 4}, + { 47, 56, 4, 4}, + { 24, 70, 4, 4}, + { 31, 14, 4, 4}, + { 27, 31, 4, 4}, + }, + }, + /* 16 */ + { + 0, 31, 37, + &enemy6, 64, &enemy6, 8, + 3,{ + {&enemy1, 20, 5}, + {&enemy3, 10, 5}, + {&rock, 100, 5}, + }, + 5,{ + { 41, 84, 6, 10}, + { 12, 115, 6, 5}, + { 22, 92, 6, 10}, + { 11, 26, 8, 8}, + { 51, 65, 9, 7}, + }, + }, + /* 17 */ + { + 0, 53, 17, + &beam, 32, &enemy1, 32, + 1,{ + {&enemy3, 10, 5}, + }, + 10,{ + { 14, 99, 6, 6}, + { 37, 18, 6, 6}, + { 13, 67, 6, 6}, + { 19, 46, 6, 6}, + { 41, 59, 6, 6}, + { 39, 97, 6, 6}, + { 47, 32, 6, 6}, + { 56, 100, 6, 6}, + { 19, 25, 6, 6}, + { 54, 76, 6, 6}, + }, + }, + /* 18 */ + { + 0, 32, 80, + &enemy1, 32, &ring, 8, + 4,{ + {&rock, 40, 2}, + {&enemy1, 20, 5}, + {&rock, 40, 5}, + {&enemy1, 20, 5}, + }, + 3,{ + { 27, 104, 5, 5}, + { 49, 105, 5, 5}, + { 32, 90, 5, 5}, + }, + }, + /* 19 */ + { + 0, 32, 64, + &ring, 128, &enemy1, 8, + 0,{ + {&enemy1, 30, 5}, + }, + 16,{ + { 32, 91, 3, 3}, + { 42, 89, 3, 3}, + { 51, 83, 3, 3}, + { 57, 74, 3, 3}, + { 59, 64, 3, 3}, + { 57, 54, 3, 3}, + { 51, 45, 3, 3}, + { 42, 39, 3, 3}, + { 32, 37, 3, 3}, + { 22, 39, 3, 3}, + { 13, 45, 3, 3}, + { 7, 54, 3, 3}, + { 5, 64, 3, 3}, + { 7, 74, 3, 3}, + { 13, 83, 3, 3}, + { 22, 89, 3, 3}, + }, + }, + /* 20 */ + { + 0, 7, 84, + &enemy7, 128, &enemy5, 16, + 0,{ + {&bomb2, 30, 5}, + }, + 20,{ + { 37, 82, 6, 6}, + { 13, 99, 6, 6}, + { 30, 44, 6, 6}, + { 19, 14, 6, 6}, + { 55, 85, 6, 6}, + { 23, 69, 6, 6}, + { 16, 35, 6, 6}, + { 11, 52, 6, 6}, + { 36, 116, 6, 6}, + { 39, 97, 6, 6}, + { 50, 114, 6, 6}, + { 39, 22, 6, 6}, + { 55, 43, 6, 6}, + { 52, 71, 6, 6}, + { 56, 100, 6, 6}, + { 54, 25, 6, 6}, + { 51, 57, 6, 6}, + { 7, 115, 6, 6}, + { 47, 8, 6, 6}, + { 8, 70, 6, 6}, + }, + }, + /* 21 */ + { + 0, 26, 30, + &enemy1, 128, &beam, 16, + 2,{ + {&enemy3, 20, 5}, + {&rock, 50, 5}, + }, + 6,{ + { 27, 79, 5, 5}, + { 6, 105, 5, 5}, + { 11, 50, 5, 5}, + { 11, 23, 5, 5}, + { 56, 57, 5, 5}, + { 7, 70, 5, 5}, + }, + }, + /* 22 */ + { + 0, 38, 120, + &ring, 128, &beam, 16, + 6,{ + {&ring, 10, 5}, + {&ring, 10, 5}, + {&ring, 10, 5}, + {&ring, 10, 5}, + {&ring, 10, 5}, + {&enemy_m1, 1, 5}, + }, + 30,{ + { 55, 25, 4, 4}, + { 49, 12, 4, 4}, + { 30, 84, 4, 4}, + { 33, 97, 4, 4}, + { 24, 21, 4, 4}, + { 28, 52, 4, 4}, + { 50, 117, 4, 4}, + { 22, 95, 4, 4}, + { 46, 56, 4, 4}, + { 36, 10, 4, 4}, + { 15, 77, 4, 4}, + { 32, 74, 4, 4}, + { 7, 15, 4, 4}, + { 13, 107, 4, 4}, + { 6, 51, 4, 4}, + { 11, 62, 4, 4}, + { 57, 76, 4, 4}, + { 57, 95, 4, 4}, + { 11, 90, 4, 4}, + { 46, 93, 4, 4}, + { 34, 27, 4, 4}, + { 58, 56, 4, 4}, + { 40, 45, 4, 4}, + { 10, 31, 4, 4}, + { 44, 35, 4, 4}, + { 25, 122, 4, 4}, + { 24, 62, 4, 4}, + { 51, 107, 4, 4}, + { 16, 50, 4, 4}, + { 25, 110, 4, 4}, + }, + }, + /* 23 */ + { + 0, 13, 92, + &bomb1, 64, &bomb1, 32, + 4,{ + {&enemy1, 20, 5}, + {&enemy2, 10, 5}, + {&enemy7, 10, 5}, + {&enemy6, 20, 5}, + }, + 5,{ + { 40, 95, 15, 15}, + { 44, 28, 13, 18}, + { 15, 16, 12, 15}, + { 14, 50, 13, 12}, + { 49, 62, 12, 11}, + }, + }, + /* 24 */ + { + 127, 32, 41, + &enemy1, 128, &beam, 16, + 3,{ + {&rock, 50, 5}, + {&enemy2, 20, 5}, + {&bomb2, 30, 5}, + }, + 8,{ + { 38, 73, 4, 4}, + { 27, 98, 4, 4}, + { 27, 71, 4, 4}, + { 56, 89, 4, 4}, + { 39, 6, 4, 4}, + { 12, 67, 4, 4}, + { 58, 14, 4, 4}, + { 14, 21, 4, 4}, + }, + }, + /* 25 */ + { + 256, 32, 96, + &beam, 32, &enemy1, 32, + 2,{ + {&enemy6, 50, 5}, + {&rock, 100, 5}, + }, + 2,{ + {25, 53, 7, 6}, + {40, 70, 5, 4}, + }, + }, + /* 26 */ + { + 0, 32, 64, + &ring, 64, &ring, 16, + 0,{ + {&enemy1, 40, 10}, + }, + 32,{ + { 8, 8, 5, 5}, + {24, 8, 5, 5}, + {40, 8, 5, 5}, + {56, 8, 5, 5}, + { 8, 24, 5, 5}, + {24, 24, 5, 5}, + {40, 24, 5, 5}, + {56, 24, 5, 5}, + { 8, 40, 5, 5}, + {24, 40, 5, 5}, + {40, 40, 5, 5}, + {56, 40, 5, 5}, + { 8, 56, 5, 5}, + {24, 56, 5, 5}, + {40, 56, 5, 5}, + {56, 56, 5, 5}, + { 8, 72, 5, 5}, + {24, 72, 5, 5}, + {40, 72, 5, 5}, + {56, 72, 5, 5}, + { 8, 88, 5, 5}, + {24, 88, 5, 5}, + {40, 88, 5, 5}, + {56, 88, 5, 5}, + { 8, 104, 5, 5}, + {24, 104, 5, 5}, + {40, 104, 5, 5}, + {56, 104, 5, 5}, + { 8, 120, 5, 5}, + {24, 120, 5, 5}, + {40, 120, 5, 5}, + {56, 120, 5, 5}, + }, + }, + /* 27 */ + { + 0, 32, 64, + &beam, 32, &enemy5, 32, + 3,{ + {&enemy1, 20, 5}, + {&bomb1, 50, 5}, + {&enemy_m2, 1, 5}, + }, + 4,{ + { 49, 64, 6, 10}, + { 40, 40, 11, 4}, + { 36, 95, 13, 4}, + { 13, 74, 8, 10}, + }, + }, + /* 28 */ + { + 4, 45, 107, + &enemy1, 32, &enemy5, 16, + 1,{ + {&rock, 50, 5}, + }, + 4,{ + { 15, 108, 11, 18}, + { 13, 62, 12, 19}, + { 46, 42, 11, 41}, + { 16, 23, 13, 13}, + }, + }, + /* 29 */ + { + 0, 32, 60, + &enemy2, 128, &beam, 4, + 5,{ + {&enemy5, 20, 5}, + {&bomb2, 10, 5}, + {&rock, 50, 5}, + {&enemy_m1, 1, 5}, + {&enemy7, 10, 5}, + }, + 5,{ + { 40, 46, 13, 9}, + { 20, 74, 12, 8}, + { 24, 106, 11, 6}, + { 29, 120, 14, 6}, + { 54, 90, 5, 8}, + }, + }, + /* 30 */ + { + 0, 23, 71, + &enemy5, 64, &beam, 16, + 3,{ + {&enemy6, 2, 5}, + {&enemy6, 2, 5}, + {&enemy_m4, 1, 5}, + }, + 20,{ + { 38, 120, 5, 5}, + { 43, 64, 5, 5}, + { 32, 106, 5, 5}, + { 14, 52, 5, 5}, + { 48, 76, 5, 5}, + { 9, 110, 5, 5}, + { 12, 34, 5, 5}, + { 40, 90, 5, 5}, + { 38, 33, 5, 5}, + { 23, 9, 5, 5}, + { 22, 120, 5, 5}, + { 9, 90, 5, 5}, + { 6, 15, 5, 5}, + { 41, 46, 5, 5}, + { 43, 13, 5, 5}, + { 25, 88, 5, 5}, + { 8, 65, 5, 5}, + { 57, 49, 5, 5}, + { 52, 108, 5, 5}, + { 6, 77, 5, 5}, + }, + }, + /* 31 */ + { + 0, 32, 120, + &ring, 64, &ring, 8, + 0,{ + {&enemy1, 10, 5}, + }, + 16,{ + { 24, 8, 6, 6}, + { 24, 24, 6, 6}, + { 24, 40, 6, 6}, + { 24, 56, 6, 6}, + { 24, 72, 6, 6}, + { 24, 88, 6, 6}, + { 24, 104, 6, 6}, + { 24, 120, 6, 6}, + { 40, 8, 6, 6}, + { 40, 24, 6, 6}, + { 40, 40, 6, 6}, + { 40, 56, 6, 6}, + { 40, 72, 6, 6}, + { 40, 88, 6, 6}, + { 40, 104, 6, 6}, + { 40, 120, 6, 6}, + }, + }, + /* 32 */ + { + 0, 32, 96, + &beam, 128, &beam, 16, + 0,{ + {&enemy1, 40, 10}, + }, + 1,{ + {32, 64, 24, 24}, + }, + }, + /* 33 */ + { + 0, 24, 113, + &enemy4, 32, &enemy4, 16, + 5,{ + {&enemy5, 30, 5}, + {&bomb1, 50, 5}, + {&enemy_m2, 1, 5}, + {&enemy2, 20, 5}, + {&rock, 100, 5}, + }, + 5,{ + { 17, 70, 13, 21}, + { 46, 32, 10, 10}, + { 49, 63, 10, 11}, + { 18, 25, 14, 21}, + { 45, 109, 10, 17}, + }, + }, + /* 34 */ + { + 0, 54, 120, + &enemy6, 64, &beam, 16, + 1,{ + {&bomb2, 10, 5}, + }, + 15,{ + { 8, 87, 6, 15}, + { 26, 72, 9, 12}, + { 37, 110, 9, 6}, + { 36, 31, 16, 5}, + { 32, 11, 17, 9}, + { 46, 51, 6, 12}, + { 54, 96, 5, 10}, + { 12, 39, 5, 11}, + { 13, 116, 9, 9}, + { 40, 93, 7, 6}, + { 7, 64, 6, 6}, + { 7, 10, 5, 8}, + { 47, 77, 8, 5}, + { 28, 46, 5, 6}, + { 56, 14, 5, 5}, + }, + }, + /* 35 */ + { + 0, 32, 64, + &enemy3, 128, &ring, 32, + 8,{ + {&enemy1, 10, 5}, + {&enemy_m1, 1, 5}, + {&bomb2, 10, 5}, + {&enemy2, 10, 5}, + {&enemy_m2, 1, 5}, + {&enemy4, 10, 5}, + {&enemy5, 10, 5}, + {&enemy7, 10, 5}, + }, + 8,{ + {32, 48, 7, 7}, + {48, 48, 7, 7}, + {48, 64, 7, 7}, + {48, 80, 7, 7}, + {32, 80, 7, 7}, + {16, 80, 7, 7}, + {16, 64, 7, 7}, + {16, 48, 7, 7}, + }, + }, + /* 36 */ + { + 0, 32, 64, + &beam, 16, &enemy2, 64, + 5,{ + {&enemy1, 10, 10}, + {&enemy2, 10, 10}, + {&bomb2, 10, 10}, + {&enemy_m1, 1, 10}, + {&enemy_m2, 1, 10}, + }, + 10,{ + {16, 20, 4, 4}, + {16, 40, 4, 4}, + {16, 60, 4, 4}, + {16, 80, 4, 4}, + {16,100, 4, 4}, + {48, 20, 4, 4}, + {48, 40, 4, 4}, + {48, 60, 4, 4}, + {48, 80, 4, 4}, + {48,100, 4, 4}, + }, + }, + /* 37 */ + { + 256, 32, 96, + &beam, 64, &ring, 64, + 0,{ + {&ring, 0, 5}, + }, + 1,{ + {32, 58, 18, 18}, + }, + }, + /* 38 */ + { + 0, 32, 72, + &ring, 64, &bomb1, 4, + 1,{ + {&rock, 10, 5}, + }, + 20,{ + {16, 48, 3, 3}, + {24, 48, 3, 3}, + {32, 48, 3, 3}, + {40, 48, 3, 3}, + {48, 48, 3, 3}, + {16, 64, 3, 3}, + {24, 64, 3, 3}, + {32, 64, 3, 3}, + {40, 64, 3, 3}, + {48, 64, 3, 3}, + {16, 80, 3, 3}, + {24, 80, 3, 3}, + {32, 80, 3, 3}, + {40, 80, 3, 3}, + {48, 80, 3, 3}, + {16, 96, 3, 3}, + {24, 96, 3, 3}, + {32, 96, 3, 3}, + {40, 96, 3, 3}, + {48, 96, 3, 3}, + }, + }, + /* 39 */ + { + 0, 32, 50, + &enemy5, 32, &enemy2, 16, + 6,{ + {&enemy_m2, 1, 5}, + {&rock , 50, 5}, + {&rock , 50, 5}, + {&rock , 50, 5}, + {&enemy_m1, 1, 5}, + {&rock , 50, 5}, + }, + 8,{ + {34, 14, 4, 4}, + {16, 22, 4, 4}, + { 6, 35, 4, 4}, + {22, 38, 4, 4}, + {45, 40, 4, 4}, + { 6, 52, 4, 4}, + {46, 66, 4, 4}, + {30, 70, 4, 4}, + {15, 90, 4, 4}, + }, + }, + /* 40 */ + { + 0, 28, 11, + &bomb1, 128, &enemy1, 16, + 1,{ + {&enemy6, 10, 5}, + }, + 35,{ + { 12, 48, 9, 9}, + { 14, 80, 6, 5}, + { 42, 14, 7, 3}, + { 52, 112, 4, 9}, + { 33, 103, 5, 6}, + { 17, 12, 4, 3}, + { 49, 78, 5, 4}, + { 49, 50, 4, 5}, + { 19, 32, 5, 5}, + { 32, 77, 6, 4}, + { 9, 113, 4, 9}, + { 36, 38, 7, 6}, + { 50, 96, 8, 3}, + { 57, 7, 3, 5}, + { 53, 34, 5, 7}, + { 11, 94, 5, 3}, + { 27, 63, 3, 6}, + { 44, 4, 3, 3}, + { 48, 63, 5, 6}, + { 37, 51, 6, 3}, + { 28, 116, 3, 3}, + { 8, 31, 4, 5}, + { 4, 18, 3, 3}, + { 13, 69, 6, 4}, + { 21, 96, 3, 3}, + { 36, 114, 3, 3}, + { 55, 87, 5, 3}, + { 58, 63, 3, 7}, + { 35, 87, 4, 4}, + { 35, 25, 3, 4}, + { 20, 107, 3, 5}, + { 13, 4, 3, 3}, + { 23, 21, 4, 4}, + { 5, 8, 3, 5}, + { 47, 22, 7, 3}, + }, + }, + /* 41 */ + { + 0, 32, 96, + &beam, 64, &beam, 16, + 1,{ + {&bomb2, 40, 10}, + }, + 1,{ + {32, 64, 18, 18}, + }, + }, + /* 42 */ + { + 0, 54, 46, + &enemy7, 64, &enemy5, 32, + 3,{ + {&bomb2, 10, 5}, + {&enemy1, 10, 5}, + {&enemy6, 10, 5}, + }, + 20,{ + { 8, 106, 5, 8}, + { 7, 32, 5, 13}, + { 39, 83, 9, 7}, + { 54, 63, 8, 9}, + { 28, 20, 6, 13}, + { 16, 61, 14, 10}, + { 55, 25, 6, 13}, + { 53, 106, 8, 7}, + { 38, 115, 5, 7}, + { 22, 109, 7, 14}, + { 12, 82, 7, 8}, + { 39, 51, 5, 5}, + { 57, 89, 5, 7}, + { 41, 21, 5, 7}, + { 10, 10, 9, 6}, + { 20, 41, 5, 5}, + { 38, 66, 5, 5}, + { 54, 121, 7, 5}, + { 37, 100, 5, 6}, + { 41, 7, 5, 5}, + }, + }, + /* 43 */ + { + 0, 22, 107, + &enemy2, 64, &bomb1, 8, + 7,{ + {&enemy4, 20, 5}, + {&bomb2, 30, 5}, + {&enemy2, 20, 5}, + {&enemy6, 20, 5}, + {&bomb2, 30, 5}, + {&enemy7, 30, 5}, + {&enemy_m3, 1, 5}, + }, + 5,{ + { 49, 38, 8, 14}, + { 20, 86, 5, 10}, + { 19, 28, 14, 16}, + { 19, 57, 17, 8}, + { 48, 86, 8, 18}, + }, + }, + /* 44 */ + { + 0, 32, 64, + &enemy2, 64, &ring, 8, + 4,{ + {&bomb2, 20, 7}, + {&rock, 20, 8}, + {&enemy_m1, 1, 5}, + {&rock, 20, 8}, + }, + 24,{ + { 46, 64, 3, 3}, + { 18, 64, 3, 3}, + { 32, 79, 3, 3}, + { 32, 48, 3, 3}, + { 43, 75, 3, 3}, + { 21, 75, 3, 3}, + { 43, 53, 3, 3}, + { 21, 53, 3, 3}, + { 32, 91, 3, 3}, + { 42, 89, 3, 3}, + { 51, 83, 3, 3}, + { 57, 74, 3, 3}, + { 59, 64, 3, 3}, + { 57, 54, 3, 3}, + { 51, 45, 3, 3}, + { 42, 39, 3, 3}, + { 32, 37, 3, 3}, + { 22, 39, 3, 3}, + { 13, 45, 3, 3}, + { 7, 54, 3, 3}, + { 5, 64, 3, 3}, + { 7, 74, 3, 3}, + { 13, 83, 3, 3}, + { 22, 89, 3, 3}, + }, + }, + /* 45 */ + { + 0, 31, 87, + &bomb1, 64, &ring, 16, + 1,{ + {&bomb2, 20, 5}, + }, + 10,{ + { 18, 66, 15, 15}, + { 52, 59, 7, 54}, + { 31, 101, 8, 7}, + { 39, 41, 4, 30}, + { 9, 97, 7, 13}, + { 21, 44, 11, 5}, + { 25, 118, 5, 5}, + { 20, 16, 8, 14}, + { 42, 122, 10, 4}, + { 5, 16, 4, 4}, + }, + }, + /* 46 */ + { + 0, 59, 34, + &beam, 64, &beam, 16, + 4,{ + {&rock, 15, 5}, + {&enemy_m3, 1, 5}, + {&rock, 15, 5}, + {&enemy_m1, 1, 5}, + }, + 35,{ + { 46, 19, 9, 10}, + { 45, 115, 10, 4}, + { 14, 60, 5, 8}, + { 48, 60, 5, 10}, + { 21, 45, 8, 5}, + { 11, 83, 5, 13}, + { 39, 97, 13, 8}, + { 36, 49, 4, 3}, + { 18, 8, 5, 4}, + { 40, 80, 9, 5}, + { 54, 44, 8, 4}, + { 13, 27, 9, 3}, + { 15, 110, 3, 5}, + { 9, 122, 5, 4}, + { 28, 63, 6, 6}, + { 35, 39, 3, 3}, + { 6, 5, 5, 3}, + { 6, 113, 4, 3}, + { 6, 40, 4, 5}, + { 29, 116, 3, 9}, + { 29, 9, 4, 4}, + { 59, 65, 3, 10}, + { 21, 86, 3, 7}, + { 4, 60, 3, 6}, + { 6, 18, 5, 4}, + { 29, 22, 5, 6}, + { 52, 4, 10, 3}, + { 18, 19, 4, 3}, + { 46, 34, 5, 3}, + { 57, 91, 3, 4}, + { 59, 103, 3, 6}, + { 25, 35, 4, 3}, + { 19, 122, 3, 4}, + { 54, 80, 3, 3}, + { 5, 101, 3, 3}, + }, + }, + /* 47 */ + { + 0, 24, 31, + &enemy5, 64, &ring, 32, + 5,{ + {&enemy1, 10, 5}, + {&enemy7, 10, 5}, + {&enemy1, 10, 5}, + {&enemy7, 10, 5}, + {&bomb2, 10, 5}, + }, + 35,{ + { 29, 37, 19, 2}, + { 24, 109, 3, 11}, + { 7, 62, 3, 4}, + { 47, 92, 2, 4}, + { 50, 112, 7, 12}, + { 54, 22, 8, 10}, + { 35, 104, 5, 7}, + { 32, 69, 9, 5}, + { 27, 46, 17, 5}, + { 32, 14, 9, 10}, + { 12, 28, 8, 4}, + { 5, 94, 4, 18}, + { 46, 57, 7, 2}, + { 46, 83, 11, 3}, + { 58, 76, 4, 2}, + { 56, 94, 4, 4}, + { 59, 63, 2, 3}, + { 16, 120, 3, 4}, + { 14, 75, 2, 11}, + { 17, 18, 2, 2}, + { 7, 6, 6, 4}, + { 37, 28, 6, 2}, + { 6, 47, 2, 3}, + { 50, 72, 2, 2}, + { 57, 44, 2, 9}, + { 18, 8, 2, 6}, + { 46, 8, 2, 2}, + { 25, 90, 4, 2}, + { 4, 37, 3, 3}, + { 17, 98, 2, 2}, + { 27, 58, 9, 2}, + { 27, 81, 5, 3}, + { 57, 7, 5, 2}, + { 7, 120, 2, 6}, + { 36, 92, 3, 3}, + }, + }, + /* 48 */ + { + 0, 19, 92, + &enemy1, 64, &enemy2, 128, + 3,{ + {&enemy1, 10, 5}, + {&bomb2, 10, 5}, + {&rock, 20, 5}, + }, + 38,{ + { 16, 54, 3, 3}, + { 47, 56, 3, 4}, + { 24, 70, 4, 3}, + { 31, 14, 3, 3}, + { 27, 31, 4, 3}, + { 36, 94, 4, 4}, + { 21, 19, 3, 4}, + { 36, 68, 4, 3}, + { 53, 4, 3, 3}, + { 36, 80, 4, 4}, + { 17, 36, 4, 3}, + { 34, 118, 4, 3}, + { 40, 13, 3, 4}, + { 55, 121, 4, 4}, + { 43, 26, 4, 3}, + { 12, 71, 4, 4}, + { 58, 108, 3, 4}, + { 51, 36, 4, 4}, + { 23, 94, 3, 3}, + { 46, 73, 4, 4}, + { 9, 25, 4, 3}, + { 27, 48, 3, 3}, + { 50, 91, 3, 3}, + { 14, 122, 3, 3}, + { 17, 113, 3, 4}, + { 16, 8, 3, 4}, + { 36, 38, 3, 4}, + { 25, 103, 4, 3}, + { 55, 70, 3, 4}, + { 28, 56, 3, 3}, + { 23, 85, 3, 3}, + { 50, 108, 3, 3}, + { 25, 122, 3, 3}, + { 14, 82, 4, 4}, + { 50, 16, 4, 4}, + { 38, 49, 4, 3}, + { 4, 6, 3, 3}, + { 7, 38, 3, 3}, + }, + }, + /* 49 */ + { + 0, 38, 67, + &beam, 32, &beam, 8, + 6,{ + {&enemy2, 10, 5}, + {&bomb1, 50, 5}, + {&enemy1, 20, 5}, + {&enemy2, 10, 5}, + {&enemy_m1, 1, 5}, + {&enemy1, 20, 5}, + }, + 22,{ + { 28, 104, 10, 6}, + { 43, 28, 12, 7}, + { 22, 72, 7, 10}, + { 11, 16, 8, 6}, + { 50, 102, 8, 4}, + { 12, 40, 5, 6}, + { 49, 80, 11, 5}, + { 6, 95, 4, 13}, + { 51, 61, 6, 10}, + { 30, 14, 4, 4}, + { 17, 118, 6, 6}, + { 34, 52, 6, 7}, + { 40, 119, 15, 6}, + { 31, 91, 15, 4}, + { 53, 10, 8, 9}, + { 8, 61, 4, 7}, + { 7, 28, 5, 4}, + { 58, 92, 4, 4}, + { 19, 55, 5, 5}, + { 25, 29, 4, 5}, + { 58, 44, 4, 4}, + { 9, 76, 4, 4}, + }, + }, + /* 50 */ + { + 0, 32, 120, + &beam, 8, &enemy1, 8, + 1,{ + {&bomb2, 80, 5}, + }, + 1,{ + {32, 60, 30, 45}, + }, + }, + { + /******************* dummy *************************/ + -1, 0, 0, + &enemy1, 0, &enemy1, 0, + 0,{ + {&enemy1, 0, 0}, + }, + 0,{ + {0, 0, 0, 0}, + }, + }, +}; diff --git a/scenes.h b/scenes.h new file mode 100644 index 0000000..d9c99a8 --- /dev/null +++ b/scenes.h @@ -0,0 +1,62 @@ + +/* + * XKOBO, a video-oriented game + * Copyright (C) 1995,1996 Akira Higuchi + * a-higuti@math.hokudai.ac.jp + * Copyright (C) 2006, 2007 David Olofson + * + * 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. + * + */ + +#ifndef XKOBO_H_SCENES +#define XKOBO_H_SCENES + +#include "config.h" +#include "enemies.h" + +#define SCENE_ENEMY_MAX 20 +#define SCENE_BASE_MAX 40 + +struct enemy_set +{ + const enemy_kind *kind; + int num; + int speed; +}; + +struct _base +{ + int x, y, h, v; +}; + +struct _scene +{ + int ratio; + int startx; + int starty; + const enemy_kind *ek1; + int ek1_interval; + const enemy_kind *ek2; + int ek2_interval; + int enemy_max; + enemy_set enemy[SCENE_ENEMY_MAX]; + int base_max; + _base base[SCENE_BASE_MAX]; +}; + +extern const _scene scene[]; + +#endif // XKOBO_H_SCENES diff --git a/score.cpp b/score.cpp new file mode 100644 index 0000000..a99530d --- /dev/null +++ b/score.cpp @@ -0,0 +1,733 @@ +/* +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2002 Jeremy Sheeley + * Copyright (C) 2001-2003, 2007 David Olofson + * + * 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. + */ + +#define DBG(x) +#define DBG2(x) +#define DBG3(x) + +#include +#include +#include +#include +#include +#include + +#if HAVE_DIRENT_H +# include +# define NAMLEN(dirent) strlen((dirent)->d_name) +#else +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# if HAVE_SYS_NDIR_H +# include +# endif +# if HAVE_SYS_DIR_H +# include +# endif +# if HAVE_NDIR_H +# include +# endif +#endif + +#if !defined(WIN32) && !defined(MACOS) +#include +#endif + +#include "kobolog.h" +#include "kobo.h" +#include "score.h" + +score_manager_t scorefile; + + +/*---------------------------------------------------------- + s_hiscore_t +----------------------------------------------------------*/ + +s_hiscore_t::s_hiscore_t() +{ + profile = NULL; + name[0] = 0; + clear(); +} + +void s_hiscore_t::clear() +{ + start_date = 0; + end_date = 0; + skill = -1; + score = 0; + start_scene = -1; + end_scene = -1; + end_lives = -1; + end_health = -1; + playtime = 0; + saves = loads = -1; + gametype = -1; +} + +void s_hiscore_t::read(pfile_t &pf) +{ + pf.read(start_date); + pf.read(end_date); + pf.read(skill); + pf.read(score); + pf.read(start_scene); + pf.read(end_scene); + pf.read(end_lives); + pf.read(end_health); + pf.read(playtime); + pf.read(saves); + pf.read(loads); + pf.read(gametype); +#if 0 + log_printf(DLOG, "--------\n"); + log_printf(DLOG, " start_date: %u\n", start_date); + log_printf(DLOG, " end_date: %u\n", end_date); + log_printf(DLOG, " skill: %d\n", skill); + log_printf(DLOG, " gametype: %d\n", gametype); + log_printf(DLOG, " score: %u\n", score); + log_printf(DLOG, " start_scene: %d\n", start_scene); + log_printf(DLOG, " end_scene: %d\n", end_scene); + log_printf(DLOG, " end_lives: %d\n", end_lives); + log_printf(DLOG, " end_health: %d\n", end_health); + log_printf(DLOG, " playtime: %u\n", playtime); + log_printf(DLOG, " saves: %d\n", saves); + log_printf(DLOG, " loads: %d\n", loads); + log_printf(DLOG, "--------\n"); +#endif +} + +void s_hiscore_t::write(pfile_t &pf) +{ + pf.write(start_date); + pf.write(end_date); + pf.write(skill); + pf.write(score); + pf.write(start_scene); + pf.write(end_scene); + pf.write(end_lives); + pf.write(end_health); + pf.write(playtime); + pf.write(saves); + pf.write(loads); + pf.write(gametype); +} + + +/*---------------------------------------------------------- + s_profile_t +----------------------------------------------------------*/ + +s_profile_t::s_profile_t() +{ + for(int i = 0; i < HISCORE_SAVE_MAX; ++i) + hiscoretab[i].profile = this; + filename = NULL; +} + +s_profile_t::~s_profile_t() +{ + free(filename); +} + +void s_profile_t::clear() +{ + best_score = 0; + last_scene = 0; + name[0] = 0; + version = 0; + skill = SKILL_CLASSIC; + handicap = 0; + color1 = -1; + color2 = -1; + hiscores = 0; + for(int i = 0; i < HISCORE_SAVE_MAX; ++i) + hiscoretab[i].clear(); +} + +int s_profile_t::load(const char *fn) +{ + log_printf(D3LOG, "s_profile_t::load('%s')\n", fn); + + free(filename); + filename = strdup(fn); + + FILE *f = fopen(filename, "rb"); + if(!f) + { + log_printf(ELOG, "Failed to open player profile '%s'!\n", fn); + return -1; + } + + pfile_t pf(f); + + clear(); + + // Check if this is an old broken 73 byte file written by a + // previous version for Win32. If it is, skip the first byte. + fseek(f, 0, SEEK_END); + if(ftell(f) == 73) + { + log_printf(ELOG, "Broken score file '%s' detected and fixed.\n", fn); + fseek(f, 1, SEEK_SET); + } + else + fseek(f, 0, SEEK_SET); + + pf.read(best_score); + pf.read(last_scene); + pf.read(name, sizeof(name)); + log_printf(DLOG, "name: %s\n", name); + log_printf(DLOG, " best_score: %u\n", best_score); + log_printf(DLOG, " last_scene: %u\n", last_scene); + pf.buffer_close(); + + if(pf.status() < 0) + { + log_printf(ELOG, "Error reading player profile '%s'!\n", fn); + fclose(f); + return -1; + } + + //Kobo Deluxe profile file format 1+ + int chunks = 0; + while(!feof(f)) + { + if(pf.chunk_read() < 0) + { + pf.status(); // Just EOF - no big deal... + break; + } + switch(pf.chunk_type()) + { + case MAKE_4CC('P', 'R', 'O', 'F'): + log_printf(D2LOG, "Chunk 'PROF'; %d bytes.\n", + pf.chunk_size()); + if(pf.chunk_size() >= 20) + { + pf.read(version); + pf.read(skill); + pf.read(handicap); + pf.read(color1); + pf.read(color2); + } + else + { + log_printf(WLOG, "WARNING: Truncated 'PROF' chunk" + " in player profile '%s'!\n", fn); + } + break; + case MAKE_4CC('H', 'I', 'S', 'C'): + log_printf(D2LOG, "Chunk 'HISC'; %d bytes.\n", + pf.chunk_size()); + if(hiscores < HISCORE_SAVE_MAX) + hiscoretab[hiscores++].read(pf); + break; + default: + { + char tp[5]; + int t = pf.chunk_type(); + tp[0] = (t >> 24) & 0xff; + tp[1] = (t >> 16) & 0xff; + tp[2] = (t >> 8) & 0xff; + tp[3] = t & 0xff; + tp[4] = 0; + log_printf(D2LOG, "Unknown chunk '%s'; %d bytes.\n", + tp, pf.chunk_size()); + } + break; + } + ++chunks; + pf.chunk_end(); + } + + if(!chunks) + { + log_printf(D2LOG, "Old scorefile.\n"); + //Construct a "fake" highscore entry from the old data. + hiscores = 1; + hiscoretab[0].skill = SKILL_CLASSIC; //Can't tell speed. + hiscoretab[0].gametype = GAME_SINGLE; //No others available. + hiscoretab[0].score = best_score; + hiscoretab[0].end_scene = last_scene; //Likely, but... + hiscoretab[0].saves = 0; //Not implemented. + hiscoretab[0].loads = 0; //Not implemented. + } + + fclose(f); + return pf.status(); +} + + +int s_profile_t::save() +{ + log_printf(D3LOG, "s_profile_t::save('%s')\n", filename); +#ifndef WIN32 + umask(022); +#endif + if(!filename) + { + log_printf(ELOG, "Failed to save player profile - no file name!\n"); + return -1; + } + +//The "safe list"; platforms that do not have symlinks: +#if !defined(WIN32) +#ifdef HAVE_STAT + // We will not write score files via symlinks! + struct stat statbuf; + if(lstat(filename, &statbuf) < 0) + { + log_printf(ELOG, "Cannot stat player profile '%s'! " + "Could be a symlink - will NOT write.\n", + filename); + return -1; + } + if( (statbuf.st_mode & S_IFLNK) == S_IFLNK ) + { + log_printf(ELOG, "Player profile '%s' is a symlink! " + "I will NOT write through symlinks.\n", + filename); + return -1; + } +#else +#warning ================= SECURITY HAZARD ================= +#warning If this platform has symlinks or similar, please +#warning add an appropriate test. If not, add your platform +#warning to the "safe list". Either way, if you read this, +#warning post a bug report to the Kobo Deluxe maintainer. +#warning ================= SECURITY HAZARD ================= +#error (Remove this line to compile anyway.) +#endif /* HAVE_STAT */ +#endif /* "Safe list" */ + + FILE *f = fopen(filename, "wb"); + if(!f) + { + log_printf(ELOG, "Failed to create player profile '%s'!\n", + filename); + return -1; + } + + fseek(f, 0, SEEK_SET); + + pfile_t pf(f); + + // Write old XKobo stuff + pf.write(best_score); + pf.write(last_scene); + pf.write(name, sizeof(name)); + pf.buffer_write(); + + // Write profile header + if(pf.chunk_write(MAKE_4CC('P', 'R', 'O', 'F')) < 0) + { + fclose(f); + return pf.status(); + } + pf.write((unsigned int)PROFILE_VERSION); + pf.write(skill); + pf.write(handicap); + pf.write(color1); + pf.write(color2); + pf.chunk_end(); + + // Write highscores + for(unsigned int i = 0; i < hiscores; ++i) + { + if(pf.chunk_write(MAKE_4CC('H', 'I', 'S', 'C')) < 0) + { + fclose(f); + return pf.status(); + } + hiscoretab[i].write(pf); + pf.chunk_end(); + } + + fclose(f); + return pf.status(); +} + + +s_hiscore_t *s_profile_t::best_hiscore() +{ + if(!hiscores) + return NULL; + + s_hiscore_t *hs = hiscoretab; + for(unsigned int i = 1; i < hiscores; ++i) + if(hiscoretab[i].score > hs->score) + hs = hiscoretab + i; + + return hs; +} + + +/*---------------------------------------------------------- + score_manager_t +----------------------------------------------------------*/ + +score_manager_t::score_manager_t() +{ +} + + +score_manager_t::~score_manager_t() +{ +} + + +void score_manager_t::init() +{ + const char *p; + + // The logic to this is: + // 1. Check to see if they have an old score file. + // If they do, rename it to follow the new naming format + // which is X.UID. On Win32 (which doesn't have a UID), the + // UID is set to 42. + // 2. Load all of the X.UID scores into our array. + // 3. Determine what the last used file was. + + // Change as of 0.4-pre7: "score files" are upgraded + // to "player profile files", which contain IFF style + // chunks beyond the 74 XKobo compatible bytes. + +#ifdef WIN32 +/* +FIXME: This should be properly implemented on Windoze - if we +FIXME: decide that it's actually much point. (Users, security etc +FIXME: are rather foreign matters to the average winuser...) +*/ + int nUID = 42; +#else + uid_t nUID = getuid(); +#endif + // Now load all of the files. Start with trying to get the old + // file name first. That file's information will become games[0], + // and then the old file name will be deleted. + + int numberSaveGamesFound = 0; + for(int i = 0; i < MAX_PROFILES; i++) + profiles[i].clear(); + + char buf[1024]; + snprintf(buf, sizeof(buf), "SCORES>>%u", nUID); + p = fmap->get(buf); + if(p) + { + if(profiles[numberSaveGamesFound].load(p) < 0) + log_printf(WLOG, "WARNING: Can't read score file!\n"); + else + { + numberSaveGamesFound = 1; + log_printf(ULOG, "Old score file \"%s\" found" + " and imported.\n", p); + } + } + + // Search through all registered score directories + // for all of the files that end in .UID + struct stat st_buffer; + fmap->get_all("SCORES>>", FM_DIR); + char UIDbuf[12]; + snprintf(UIDbuf, sizeof(UIDbuf), ".%u", nUID); + while(1) + { + const char *path = fmap->get_next(); + if(!path) + break; + + // if the last characters in the file name is the string + // UIDbuf... + char *tmpptr = strstr((char *)path, UIDbuf); + if(tmpptr != NULL && (*(tmpptr + strlen(UIDbuf)) == '\0')) + { + if(stat(path, &st_buffer)) + continue; + if(!S_ISREG(st_buffer.st_mode)) + continue; + + if(profiles[numberSaveGamesFound].load(path) < 0) + continue; + + if((++numberSaveGamesFound) >= MAX_PROFILES) + break; + } + } + + numProfiles = numberSaveGamesFound; + + // If there are no save files, introbase in states.cpp will take + // them to the enter_name screen. + + gather_high_scores(); + print_high_scores(); +} + + +int score_manager_t::addPlayer(const char *name) +{ + log_printf(D3LOG, "creating profile %d\n", numProfiles); + if(numProfiles == MAX_PROFILES) + return -1; + int ret = 0; +#ifdef WIN32 + int userid = 42; +#else + uid_t userid = getuid(); +#endif + profiles[numProfiles].clear(); + strncpy(profiles[numProfiles].name, name, SCORE_NAME_LEN); + +// TODO: Somewhere around here would be a nice place to check if the +// TODO: scoredir exists, and if not, try to create one. + + // This means that we always create new profiles in the first + // scoredir registered. (Loaded score files are written back + // where they were read from when changed.) + char buf[1024]; + snprintf(buf, sizeof(buf), "SCORES>>%s.%u", name, userid); + const char *fn = fmap->get(buf, FM_FILE_CREATE); + free(profiles[numProfiles].filename); + if(fn) + profiles[numProfiles].filename = strdup(fn); + else + { + profiles[numProfiles].filename = NULL; + log_printf(ELOG, "ERROR: Couldn't resolve player profile" + " path '%s'!\n", buf); + ret = -2; + } + + log_printf(ULOG, "Created new player profile '%s' for player '%s'\n", + fn ? fn : "", profiles[numProfiles].name); + currentProfile = numProfiles; + + // Try to create the high score file. + if(profiles[numProfiles].save() < 0) + ret = -3; + + numProfiles++; + return ret; +} + + +void score_manager_t::select_profile(int prof) +{ + log_printf(D3LOG, "score_manager_t::select_profile(%d)\n", prof); + currentProfile = prof; +} + + +// Rules: +// * Highest score gets highest priority. +// * If the maximum number of entries is +// exceeded, the lowest score entry is +// overwritten. +// * best_score and last_scene of the +// profile are bumped if exceeded. +void score_manager_t::record(s_hiscore_t *entry, int force) +{ + log_printf(D3LOG, "score_manager_t::record\n"); + s_profile_t *p = profiles + currentProfile; + int write; + if(force) + write = 1; + else + write = 0; + + if(entry->score > p->best_score) + { + p->best_score = entry->score; + write = 1; + } + + if(entry->end_scene > p->last_scene) + { + p->last_scene = entry->end_scene; + write = 1; + } + + int si = -1; + if(p->hiscores < HISCORE_SAVE_MAX) + { + // Grab next free slot + si = p->hiscores++; + } + else + { + // Find worst score +//FIXME: Pick old or new when scores are equal? + unsigned int worst_score = entry->score; + for(int i = 0; i < HISCORE_SAVE_MAX; ++i) + if(p->hiscoretab[i].score <= worst_score) + { + si = i; + worst_score = p->hiscoretab[i].score; + } + } + if(si >= 0) + { + // Copy and "fix" entry... + log_printf(DLOG, "Saving in slot %d.\n", si); + p->hiscoretab[si] = *entry; + p->hiscoretab[si].profile = p; + memcpy(p->hiscoretab[si].name, p->name, SCORE_NAME_LEN); + write = 1; + } + else + log_printf(DLOG, "Not saved.\n"); + + if(write) + { + log_printf(DLOG, "Writing file %s for player %s...\n", + p->filename, p->name); + p->save(); + gather_high_scores(); + print_high_scores(); + log_printf(DLOG, " Done!\n"); + } +} + + +int s_table_cmp(const void *_a, const void *_b) +{ + s_hiscore_t *a = (s_hiscore_t *)_a; + s_hiscore_t *b = (s_hiscore_t *)_b; +#if 0 + if(a->gametype < b->gametype) + return 1; + else if(a->gametype > b->gametype) + return -1; + else +#endif + if(a->score < b->score) + return 1; + else if(a->score > b->score) + return -1; + return 0; +} + + +void score_manager_t::gather_high_scores(int placeholders) +{ + const int sc[] = { + 10000, 9000, 8000, 7000, 6000, + 5000, 4000, 3000, 2000, 1000, + 0 + }; + const int st[] = { + 10, 9, 8, 7, 6, + 5, 4, 3, 2, 1 + }; + const char *nm[] = { + "DAVID OLOFSON", + "AKIRA HIGUCHI", + "MASANAO IZUMO", + "MAX HORN", + "SAMUEL HART", + "ANDREAS", + "TRICK", + "RIKI", + "GEORGIE", + "JEREMY" + }; + + for(int i = 0; i < MAX_HIGHSCORES; ++i) + high_tbl[i].clear(); + + s_profile_t p; + highs = 0; + fmap->get_all("SCORES>>", FM_DIR); + while(highs < MAX_HIGHSCORES) + { + const char *path = fmap->get_next(); + if(!path) + break; + + if(p.load(path) < 0) + continue; + + s_hiscore_t *hs = p.best_hiscore(); + if(!hs) + continue; + + high_tbl[highs] = *hs; + memcpy(high_tbl[highs].name, p.name, SCORE_NAME_LEN); + high_tbl[highs].profile = NULL; + ++highs; + } + + if(placeholders) + { + //Throw some nice looking names in, if there's room. ;-) + int i = 0; + while(highs < MAX_HIGHSCORES) + { + if(!sc[i]) + break; + memcpy(high_tbl[highs].name, nm[i], SCORE_NAME_LEN); + high_tbl[highs].skill = SKILL_CLASSIC; + high_tbl[highs].gametype = GAME_SINGLE; + high_tbl[highs].score = sc[i]; + high_tbl[highs].start_scene = 0; + high_tbl[highs].end_scene = st[i]; + ++i; + ++highs; + } + } + + qsort(high_tbl, highs, sizeof(high_tbl[0]), s_table_cmp); +} + + +int score_manager_t::highscore(int prof) +{ + if(-1 == prof) + return profiles[currentProfile].last_scene; + else if(-2 == prof) + return high_tbl[0].score; + else + return profiles[prof].best_score; +} + + +void score_manager_t::print_high_scores() +{ + if(!highs) + { + log_printf(WLOG, "No hiscore entries found!\n"); + return; + } + + log_printf(ULOG, "Name Score Start End\n"); + for(unsigned int j = 0; j < highs; j++) + { + log_printf(ULOG, "%-20s %9u %5d %3d\n", high_tbl[j].name, + high_tbl[j].score, + high_tbl[j].start_scene, + high_tbl[j].end_scene); + } +} diff --git a/score.h b/score.h new file mode 100644 index 0000000..a4ea228 --- /dev/null +++ b/score.h @@ -0,0 +1,220 @@ +/* +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2001, 2002 David Olofson + * Copyright (C) 2002 Jeremy Sheeley + * Copyright (C) 2007 David Olofson + * + * 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. + */ + +#ifndef _KOBO_SCORE_H_ +#define _KOBO_SCORE_H_ + +#include "config.h" +#include "game.h" +#include "pfile.h" + +#define MAX_PROFILES 100 +#define MAX_HIGHSCORES 100 +#define HISCORE_SAVE_MAX 100 + +#define PROFILE_VERSION 1 + +//DO NOT CHANGE! (Will break the file format.) +#define SCORE_NAME_LEN 64 + + +/*---------------------------------------------------------- + s_*_t - Profile and score data wrappers +----------------------------------------------------------*/ +// File format: +// * The first 74 bytes are identical to those in old +// XKobo score files, for compatibility reasons. +// +// * New sections are added in the form of RIFF style +// chunks, starting at offset 74 in the file. (See +// pfile.(h|cpp) for details.) +// +// * Chunks of unknown types are IGNORED, and are +// therefore LOST if the file is overwritten by an +// older version of Kobo Deluxe. +// +// * Extra data beyond the end of a chunk (ie data that +// is added by a later version of Kobo Deluxe) is +// IGNORED, and is therefore LOST if the file is +// overwritten by an older version of Kobo Deluxe. +// +// * New versions may ADD data to chunks, but never +// remove data from chunks. +// +// * New versions may add new chunk types. +// +// * New versions may remove old chunk types, although +// this is STRONGLY DISCOURAGED, as it may render +// old Kobo Deluxe versions seeing a vertually empty +// profile file... +// +// * Strings are stored as fixed length, null padded +// arrays of 64 bytes. All strings should have at +// least one terminating null byte. +// +// * Signed and unsigned int are stored as little +// endian 32 bit integers. +// +// Version 1 chunks: +// +// PROF: //Player profile header +// Sint32 version; +// Sint32 skill; +// Sint32 handicap; +// Sint32 color1; +// Sint32 color2; +// +// HISC: //Hiscore entry +// Uint32 start_date; +// Uint32 end_date; +// Sint32 skill; +// Uint32 score; +// Sint32 start_scene; +// Sint32 end_scene; +// Sint32 end_lives; +// Sint32 end_health; +// Uint32 playtime; +// Sint32 saves; +// Sint32 loads; +// Sint32 gametype; +// + +struct s_profile_t; + +// Stored as one "HISC" chunk for each entry. +// No "real" maximum number of entries per profile, +// but the current implementation uses an array of +// HISCORE_SAVE_MAX entries. +// FIXME: Should be dynamic, although there should +// FIXME: probably be some sensible limit regardless. +struct s_hiscore_t +{ + // For all of the below, -1 (signed) or 0 (unsigned) means "unknown". + unsigned int start_date; //Seconds since 2000...? + unsigned int end_date; //Seconds since 2000...? + int skill; //Skill setting used + int gametype; //Single/cooperative/deathmatch/... + unsigned int score; //Score achieved + int start_scene; //Scene player started on + int end_scene; //Scene player quit or died on + int end_lives; //# of lives when player quit + int end_health; //Health when player quit + unsigned int playtime; //Effective play time, logic frames + int saves; //# of times game was saved + int loads; //# of times game was aborted + loaded + + // The fields below this line are not saved to file. + s_profile_t *profile; //Profile this entry belongs to, + //if any. (May be NULL!) + char name[SCORE_NAME_LEN]; //(Kludge for highscore table.) + + s_hiscore_t(); + void clear(); //Reset and clear all fields. + void read(pfile_t &f); //Read this struct from pfile 'f'. + void write(pfile_t &f); //Write this struct to pfile 'f'. +}; + +// Stored as one "PROF" chunk. +struct s_profile_t +{ + //Old stuff (from XKobo) + unsigned int best_score; //Best score + int last_scene; //Last scene completed + char name[SCORE_NAME_LEN]; //Player name + + //New stuff (for Kobo Deluxe 0.4) + unsigned int version; //Profile file format version + int skill; //Player skill setting + int handicap; //Player handicap. 0 == none. + int color1; //Primary color. (-1 == default) + int color2; //Secondary color. (-1 == default) + + s_hiscore_t hiscoretab[HISCORE_SAVE_MAX]; + + // The fields below this line are not saved to file. + unsigned int hiscores; //# of hiscores stored + char *filename; + + s_profile_t(); + ~s_profile_t(); + void clear(); //Reset and clear all fields. + int load(const char *fn); //Load from file 'fn'. + int save(); //Save back to file. + + s_hiscore_t *best_hiscore(); +}; + + +/*---------------------------------------------------------- + score_manager_t +----------------------------------------------------------*/ + +class score_manager_t +{ + s_profile_t profiles[MAX_PROFILES]; + unsigned int currentProfile; + public: + unsigned int highs; + s_hiscore_t high_tbl[MAX_HIGHSCORES]; + + int numProfiles; + score_manager_t(); + ~score_manager_t(); + int addPlayer(const char *name); + void init(); + s_profile_t *profile(int prof = -1) + { + if(prof < 0) + return profiles + currentProfile; + else + return profiles + prof; + } + // NOTE: hiscore() with no argument (or -2) returns + // the best known score of all found profiles; NOT + // that of the current profile. + int highscore(int prof = -2); + int last_scene(int prof = -1) + { + if(prof < 0) + return profiles[currentProfile].last_scene; + else + return profiles[prof].last_scene; + } + char *name(int prof = -1) + { + if(prof < 0) + return profiles[currentProfile].name; + else + return profiles[prof].name; + } + void select_profile(int prof); + int current_profile() { return currentProfile; } + void record(s_hiscore_t *entry, int force = 0); + void gather_high_scores(int placeholders = 0); + void print_high_scores(); +}; + +extern score_manager_t scorefile; + +#endif //_KOBO_SCORE_H_ diff --git a/screen.cpp b/screen.cpp new file mode 100644 index 0000000..e16243a --- /dev/null +++ b/screen.cpp @@ -0,0 +1,1042 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996, Akira Higuchi + * Copyright (C) 2001-2003, 2005, 2007 David Olofson + * + * 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. + */ + +#include +#ifndef M_PI +# define M_PI 3.14159265358979323846 /* pi */ +#endif + +#include "kobo.h" +#include "screen.h" +#include "manage.h" +#include "options.h" +#include "enemies.h" +#include "myship.h" +#include "radar.h" +#include "scenes.h" +#include "config.h" +#include "random.h" +#include "version.h" + +int _screen::scene_max; +int _screen::scene_num; +int _screen::level; +int _screen::generate_count; +_map _screen::map; +int _screen::show_title = 0; +int _screen::do_noise = 0; +float _screen::_fps = 40; +float _screen::scroller_speed = SCROLLER_SPEED; +float _screen::target_speed = SCROLLER_SPEED; +int _screen::noise_y = 0; +int _screen::noise_h = WSIZE; +int _screen::noise_source = B_NOISE; +float _screen::noise_fade = 0.0f; +float _screen::noise_bright = 0.0f; +float _screen::noise_depth = 0.0f; +int _screen::highlight_y = WSIZE / 2; +int _screen::highlight_h = 0; +int _screen::hi_sc[10]; +int _screen::hi_st[10]; +char _screen::hi_nm[10][20]; +int _screen::nstars = 0; +KOBO_Star *_screen::stars = NULL; +Uint32 _screen::starcolors[STAR_COLORS]; +int _screen::star_oxo = 0; +int _screen::star_oyo = 0; +radar_modes_t _screen::radar_mode = RM_OFF; + + +_screen::~_screen() +{ + free(stars); +} + + +void _screen::init() +{ + scene_max = 0; + while(scene[scene_max].ratio != -1) + scene_max++; +} + + +void _screen::render_title_plasma(int t, float fade, int y, int h) +{ + s_sprite_t *s = gengine->get_sprite(B_FOCUSFX, 0); + if(!s || !s->surface) + return; + SDL_Surface *fx = s->surface; + SDL_Rect sr; + sr.x = 0; + sr.w = fx->w; + sr.h = 1; + for(int ty = 0; ty < h; ++ty) + { + float sy = (float)ty / (h - 1); + float shape = sin(M_PI * sy); + float plasma = 0.5f + 0.5f * sin(t * 0.004f + + sin(t * 0.00017f) * sy * 18.0f); + float plasma2 = 0.5f + 0.5f * sin(t * 0.001f + + sin(t * 0.00013f) * sy * 12.0f); + int i = (int)((fx->h - 1) * (0.3f * plasma + 0.7f * shape) * fade); + int xo = (int)(8192 * plasma2 * gengine->xscale() / 256); + xo -= (int)(xo / fx->w) * fx->w; + int xmax = wmain->phys_rect.x + wmain->phys_rect.w; + for(int x = -xo; x < xmax; x += fx->w) + { + sr.y = i; + RGN_Blit(fx, &sr, x, y + ty); + } + } +} + + +void _screen::render_title_noise(float fade, int y, int h, int bank, int frame) +{ + for(int ty = 0; ty < h; ) + { + int xo = (int)(pubrand.get(16) * gengine->xscale()) / 256; + s_sprite_t *s = gengine->get_sprite(bank, pubrand.get(4)); + if(!s || !s->surface) + continue; + SDL_Surface *fx = s->surface; + xo -= (int)(xo / fx->w) * fx->w; + int xmax = wmain->phys_rect.x + wmain->phys_rect.w; + for(int x = -xo; x < xmax; x += fx->w) + RGN_Blit(fx, NULL, x, y + ty); + ty += fx->h; + } +} + + +static int flashin(int t) +{ + if(t < 0) + return 1; + else if(t > 800) + return 0; + else + return (t % 200) > 100; +} + + +void _screen::title(int t, float fade, int mode) +{ + // Enclosed effect + s_sprite_t *s = gengine->get_sprite(B_LOGO, 0); + if(!s || !s->surface) + return; + float mf = (1.0f - fade); + int h = s->surface->h; + int y0 = wmain->phys_rect.y + (int)(60 * gengine->yscale() + 0.5f); + int y = (int)(y0 - mf * mf * mf * (y0 + h) + 0.5f); + wmain->select(); + RGN_Target(gengine->surface()); + RGN_SetRegion(logo_region, + wmain->phys_rect.x + + (int)((wmain->width() - 206) / 2 * gengine->xscale()), + y); + switch(mode) + { + case 0: + render_title_plasma(t, fade, y, h); + break; + case 1: + render_title_noise(fade, y, h, (int)B_NOISE, 0); + break; + case 2: + render_title_noise(fade, y, h, (int)B_HITNOISE, 0); + break; + } + + // Outline + wmain->sprite_fxp(PIXEL2CS((wmain->width() - 206) / 2), + (int)((y * 256 + 255) / gengine->yscale()) - + PIXEL2CS(wmain->y()), + B_LOGO, 0); + + // "DELUXE" + wmain->sprite_fxp(PIXEL2CS((wmain->width() - 139) / 2), + PIXEL2CS(123) + (int)(PIXEL2CS(160) * mf * mf), + B_LOGODELUXE, 0); + + // Version + if(fade > 0.9) + { + wmain->font(B_NORMAL_FONT); + wmain->center(132, KOBO_VERSION); + } + + // Cheat mode warning + if((prefs->cmd_cheat || prefs->cmd_pushmove) && (t % 1000 < 500)) + { + wmain->font(B_MEDIUM_FONT); + wmain->center(145, "CHEAT MODE"); + } +#if 1 + // WIP notice + if(!flashin(t - 2000)) + { + wmain->font(B_MEDIUM_FONT); + wmain->center(170, "This is a Work in Progress!"); + wmain->center(180, "Check http://olofson.net/kobodl"); + } +#endif +} + + +void _screen::init_highscores() +{ + for(unsigned int i = 0; i < 10; ++i) + if(i < scorefile.highs) + { + hi_sc[i] = scorefile.high_tbl[i].score; + hi_st[i] = scorefile.high_tbl[i].end_scene; + strncpy(hi_nm[i], scorefile.high_tbl[i].name, 19); + hi_nm[i][19] = 0; + } + else + { + hi_sc[i] = 0; + hi_st[i] = 0; + strcpy(hi_nm[i], "---"); + } + +} + + +void _screen::highscores(int t, float fade) +{ + int i, y; + float mf = (1.0f - fade); + mf *= mf * mf * mf * mf; + screen.set_highlight(0, 0); + + wmain->font(B_BIG_FONT); + y = (int)(PIXEL2CS(100) * mf) - 256; + if(y < 0) + y = 0; + wmain->center_fxp(PIXEL2CS(20) - y, "HALL OF FAME"); + int xo = (int)(50 * 256 * mf); + wmain->sprite_fxp(PIXEL2CS(32) - xo, PIXEL2CS(30), + B_PLAYER, (t / 50) % 16); + wmain->sprite_fxp(PIXEL2CS(wmain->width() - 32) + xo, PIXEL2CS(30), + B_PLAYER, 15 - (t / 50) % 16); + + wmain->font(B_NORMAL_FONT); + y = (int)(PIXEL2CS(75) * mf - 0.5f) - 256; + if(y < 0) + y = 0; + wmain->center_fxp(PIXEL2CS(40) - y, "(Score/Stage/Name)"); + + wmain->font(B_MEDIUM_FONT); + float yo = t * (11*18+100) * 256.0 / 12500.0 - PIXEL2CS(110); + for(i = 0, y = 65; i < 10; ++i, y += 18) + { + static char s[20]; + float xo, cy; + int real_y = PIXEL2CS(y) - (int)yo; + if(real_y < PIXEL2CS(55) || real_y > PIXEL2CS(165)) + continue; + cy = (PIXEL2CS(y) - yo) - PIXEL2CS(65 + 5*18/2); + xo = cy*cy*cy*cy*cy * 1e-16; + snprintf(s, 16, "%d", hi_sc[i]); + wmain->center_token_fxp(PIXEL2CS(70)+(int)xo, real_y, s); + snprintf(s, 16, "%d", hi_st[i]); + wmain->center_token_fxp(PIXEL2CS((70+125)/2)+(int)xo, real_y, s, -1); + wmain->string_fxp(PIXEL2CS(125)+(int)xo, real_y, hi_nm[i]); + } +#if 1 + if(!flashin(t - 1000)) + { + wmain->font(B_MEDIUM_FONT); + wmain->center(170, "NOTE: Highscores for \"Classic\" only!"); + wmain->center(180, "The new skill levels are experimental."); + } +#endif +} + + +void _screen::credits(int t) +{ + if((t % 4000 < 3600) && (t / 4000 <= 2)) + screen.set_highlight(102, 70); + else + screen.set_highlight(0, 0); + int t2 = 10 * (t % 4000) / 3700; + if(t % 4000 < 3700) + switch(t / 4000) + { + case 0: + wmain->font(B_BIG_FONT); + if(t2 > 0) + wmain->center(80, "DAVID OLOFSON"); + wmain->font(B_NORMAL_FONT); + if(t2 > 2) + wmain->center(105, "New SDL Audio & GFX Engines"); + if(t2 > 3) + wmain->center(115, "New Graphics, Sound & Music"); + break; + case 1: + wmain->font(B_BIG_FONT); + if(t2 > 0) + wmain->center(80, "AKIRA HIGUCHI"); + wmain->font(B_NORMAL_FONT); + if(t2 > 2) + wmain->center(110, "XKobo - The Original Game"); + break; + case 2: + wmain->font(B_BIG_FONT); + if(t2 > 0) + wmain->center(80, "MASANAO IZUMO"); + wmain->font(B_NORMAL_FONT); + if(t2 > 2) + wmain->center(105, "Original Sounds"); + if(t2 > 3) + wmain->center(115, "Original Sound Engine"); + break; + } + if(!flashin(t - 11000)) + { + wmain->font(B_MEDIUM_FONT); + wmain->center(170, "Additional Credits & Thanks"); + wmain->center(180, "in the scroller below"); + } +} + + +void _screen::help(int t) +{ + wmain->font(B_BIG_FONT); + wmain->center(53, "HOW TO PLAY"); + + // 0..3000: Control + if(t < 200) + screen.set_highlight(112, 80); + else if(t < 2800) + { + if(t > 2700) + screen.set_highlight(0, 0); + wmain->font(B_MEDIUM_FONT); + wmain->sprite(wmain->width() / 2, 105, B_PLAYER, (t / 50) % 16); + wmain->center(125, "Use arrow keys or NumPad."); + wmain->center(135, "to control the ship."); + } + else if(t < 3000) + return; + + // 3000..6000: Fire + else if(t < 3200) + screen.set_highlight(112, 80); + else if(t < 5800) + { + if(t > 5700) + screen.set_highlight(0, 0); + wmain->font(B_MEDIUM_FONT); + int i; + for(i = 0; i < 4; ++i) + { + int t2 = t + 153 * i; + wmain->sprite(wmain->width() / 2 - (t2 / 5) % 120, 105, + B_BOLT, 8 + (t2 / 50) % 4); + wmain->sprite(wmain->width() / 2 + (t2 / 5) % 120, 105, + B_BOLT, 8 + (t2 / 50) % 4); + } + wmain->sprite(wmain->width() / 2, 105, B_PLAYER, 4); + wmain->center(135, "Use any SHIFT or CONTROL keys to fire."); + } + else if(t < 6000) + return; + + // 6000..9000: Bases + else if(t < 6200) + screen.set_highlight(112, 80); + else if(t < 8800) + { + if(t > 8700) + screen.set_highlight(0, 0); + wmain->font(B_MEDIUM_FONT); +// TODO: Short demo of how to destroy a base + int i; + for(i = B_TILES1; i <= B_TILES5; ++i) + { + int xo = 24 * i - (5 * 24 / 2) + 4; + wmain->sprite(wmain->width() / 2 + xo, 105 - 8, i, 7); + } + wmain->center(135, "Destroy bases by shooting their cores."); + } + else if(t < 9000) + return; + + // 9000..14000: Shoot everything! + else if(t < 9200) + screen.set_highlight(112, 80); + else if(t < 13800) + { + if(t > 13700) + screen.set_highlight(0, 0); + wmain->font(B_MEDIUM_FONT); +// TODO: Short demo of intense battle + wmain->sprite(50, 110, B_RING, (t / 30) % 16); + wmain->sprite(65, 90, B_BOMB, (t / 40) % 16); + wmain->sprite(80, 110, B_BMR_GREEN, (t / 80) % 16); + wmain->sprite(95, 90, B_BMR_PURPLE, (t / 70) % 16); + wmain->sprite(110, 110, B_BMR_PINK, (t / 60) % 16); + wmain->sprite(125, 90, B_FIGHTER, (t / 50) % 16); + wmain->sprite(140, 110, B_MISSILE1, (t / 45) % 16); + wmain->sprite(155, 90, B_MISSILE2, (t / 40) % 16); + wmain->sprite(170, 110, B_MISSILE3, (t / 55) % 16); + wmain->center(125, "Shoot everything that moves,"); + wmain->center(135, "but avoid getting hit!"); + } + else if(t < 14000) + return; + + // 14000..20000: Indestructible + else if(t < 14200) + screen.set_highlight(112, 80); + else if(t < 19800) + { + if(t > 19700) + screen.set_highlight(0, 0); + wmain->font(B_MEDIUM_FONT); +// TODO: Demo destroying a rock in Gamer mode? + int i; + for(i = B_TILES1; i <= B_TILES5; ++i) + { + int xo = 24 * i - (5 * 24 / 2) + 4; + wmain->sprite(wmain->width() / 2 + xo, 82 - 8, i, 0); + } + wmain->center(87, "Some objects are indestructible..."); + wmain->sprite(65, 120, B_ROCK1, (t / 45) % 32); + wmain->sprite(90, 115, B_ROCK2, (t / 40) % 32); + wmain->sprite(115, 125, B_ROCK3, (t / 35) % 48); + wmain->sprite(155, 120, B_BIGSHIP, (t / 40) % 16); + wmain->center(135, "...or take many hits to destroy."); + } +} + + +void _screen::scroller() +{ + if(do_noise) + return; + + /* + * Adjust scroller speed according to + * frame rate, for readability. + */ + if(_fps < 30) + target_speed = SCROLLER_SPEED / 2; + else if(_fps > 40) + target_speed = SCROLLER_SPEED; + + scroller_speed += (target_speed - scroller_speed) * 0.05; + + static const char scrolltext[] = + "Welcome to KOBO DELUXE, an enhanced version of " + "Akira Higuchi's fabulous X-Window game XKOBO. " + " " + "KOBO DELUXE uses SDL, the Simple DirectMedia " + "Layer (www.libsdl.org) for graphics and input, " + "and Audiality (olofson.net/audiality) for sound " + "and music. " + " " + "KOBO DELUXE has been known to hinder productivity on: " + " " + " - " + "Windows 95/98/ME - " + "Windows 2000/XP - " + "Mac OS X (PPC) - " + "BeOS (x86, PPC) - " + "AmigaOS (68k, PPC) - " + "Solaris (x86, SPARC) - " + "QNX (x86) - " + "GNU/Linux (x86, x86_64, PPC, PPC64) - " + "OpenBSD (x86, PPC, SPARC, SPARC64) - " + "FreeBSD (x86) - " + "NetBSD (x86) - " + "IRIX - " + "OS/2 - " + "PlayStation 2/PS2Linux - " + "Xbox - " + "Syllable - " + "ITOS (Nokia internet tablets) - " + " " + "Any help in the Cause of Infiltrating Further " + "Platforms is Greatly Appreciated! " + " " + "Additional Credits & Thanks to: " + " Torsten Giebl (Slackware)" + " David Andersson (Some Good Ideas)" + " Samuel Hart (Joystick Support)" + " Max Horn (Mac OS X)" + " Jeremy Sheeley (Player Profiles)" + " Tsuyoshi Iguchi (FreeBSD, NetBSD)" + " G. Low (Solaris)" + " Gerry Jo \"Trick\" Jellestad (Testing & Ideas)" + " \"Riki\" (Intel Compiler)" + " Andreas Spaangberg (Sun Compiler)" + " \"SixK\" (Amiga Port)" + " Joey Hess (Debian)" + " Martijn van Oosterhout (FPS limiter)" + " Antonio Messina (Stage 1601+, Always Fire)" + " Hans de Goede (Audio bug)" + " Marianne Ibbotson (\"Autopause\")" + " Sam Palmer (Windows testing)" + " Michael Sterrett (glSDL issues)" + " Sam Lantinga & Others (SDL)" + " Members of the SDL Mailing List" + " " + "Additional Thanks from Akira Higuchi Go To: " + " Bruce Cheng" + " Christoph Lameter" + " Davide Rossi" + " Eduard Martinescu" + " Elan Feingold" + " Helmut Hoenig" + " Jeff Epler" + " Joe Ramey" + " Joey Hess" + " Michael Sterrett" + " Mihail Iotov" + " Shoichi Nakayama" + " Thomas Marsh" + " Torsten Wolnik" + " " + "And as we said in the old days... " + " " + " "; +// FIXME: Nasty static state variables... + static const char *stp = scrolltext; + static int pos = PIXEL2CS(SCREEN_WIDTH); + static int t = 0; + int nt = (int)SDL_GetTicks(); + int dt = nt - t; + t = nt; + if(dt > 100) + dt = 100; + static int fdt = 0; + fdt += ((dt<<8) - fdt) >> 3; + pos -= (fdt * PIXEL2CS((int)scroller_speed) + 128000) / 256000; + wmain->font(B_BIG_FONT); + wmain->string_fxp(pos, PIXEL2CS(200), stp); + + /* + * Chop away characters at the left edge + */ + char buf[2] = {*stp, 0}; + int cw = wmain->textwidth_fxp(buf); + if(-pos > cw) + { + pos += cw; + ++stp; + if(*stp == 0) + { + // Wrap! + pos = PIXEL2CS(SCREEN_WIDTH); + stp = scrolltext; + } + } +} + + +void _screen::init_scene(int sc) +{ + map.init(); + if(sc < 0) + { + /* + * Intro mode + */ + show_title = 1; + myship.off(); + enemies.off(); + if(sc == INTRO_SCENE) + { + /* + * Plain intro - no map + */ + radar_mode = RM_OFF; /* Clear radar */ + scene_num = 19; + level = 0; + } + else + { + /* + * Map selection - show current map + */ + radar_mode = RM_SHOW; + scene_num = -(sc+1) % scene_max; + level = -(sc+1) / scene_max; + } + } + else + { + /* + * In-game mode + */ + show_title = 0; + scene_num = sc % scene_max; + level = sc / scene_max; + radar_mode = RM_RADAR; + } + gengine->period(game.speed); + sound.period(game.speed); + + const _scene *s = &scene[scene_num]; + int i; + for(i = 0; i < s->base_max; i++) + map.make_maze(s->base[i].x, s->base[i].y, s->base[i].h, + s->base[i].v); + map.convert(s->ratio); + generate_count = 0; + wradar->mode(radar_mode); +} + + +int _screen::prepare() +{ + if(scene_num < 0) + return 0; + const _scene *s = &scene[scene_num]; + int i, j; + int count_core = 0; + int c = 0; + + int lc = level > 31 ? 31 : level; + int interval_1 = (s->ek1_interval) >> lc; + int interval_2 = (s->ek2_interval) >> lc; + if(interval_1 < 4) + interval_1 = 4; + if(interval_2 < 4) + interval_2 = 4; + enemies.set_ekind_to_generate(s->ek1, interval_1, s->ek2, + interval_2); + + wmain->clear(); + for(i = 0; i < MAP_SIZEX; i++) + for(j = 0; j < MAP_SIZEY; j++) + { + int m = MAP_BITS(map.pos(i, j)); + if(IS_SPACE(m)) + continue; + if((m == U_MASK) || (m == R_MASK) || (m == D_MASK) + || (m == L_MASK)) + { + enemies.make(&cannon, i * 16 + 8, + j * 16 + 8); + c++; + } + else if(m & CORE) + { + enemies.make(&core, i * 16 + 8, + j * 16 + 8); + count_core++; + c++; + } + } + + myship.set_position(s->startx << 4, s->starty << 4); + + return count_core; +} + + +void _screen::generate_fixed_enemies() +{ + static int sint[16] = + { 0, 12, 23, 30, 32, 30, 23, 12, 0, -12, -23, -30, + -32, -30, -23, -12 }; + static int cost[16] = + { 32, 30, 23, 12, 0, -12, -23, -30, -32, -30, -23, + -12, 0, 12, 23, 30 }; + const _scene *s = &scene[scene_num]; + if(generate_count < s->enemy_max) + { + int j; + for(j = 0; j < s->enemy[generate_count].num; j++) + { + int sp = s->enemy[generate_count].speed; + int x, y, h, v, t; + x = gamerand.get() % (WORLD_SIZEX - VIEWLIMIT * 2); + y = gamerand.get() % (WORLD_SIZEY - VIEWLIMIT * 2); + x -= (WORLD_SIZEX / 2 - VIEWLIMIT); + y -= (WORLD_SIZEY / 2 - VIEWLIMIT); + if(x < 0) + x -= VIEWLIMIT; + else + x += VIEWLIMIT; + if(y < 0) + y -= VIEWLIMIT; + else + y += VIEWLIMIT; + x += myship.get_x(); + y += myship.get_y(); + + t = gamerand.get(4); + h = PIXEL2CS(sp * sint[t]) / 64; + v = PIXEL2CS(sp * cost[t]) / 64; + enemies.make(s->enemy[generate_count].kind, x, y, + h, v); + } + generate_count++; + } + if(generate_count >= s->enemy_max) + generate_count = 0; +} + + +void _screen::set_map(int x, int y, int n) +{ + if(n == 0) + map.clearpos(x, y); + else + map.pos(x, y) = n; + wradar->update(x, y); +} + + +void _screen::render_noise(window_t *win) +{ + if(!do_noise) + return; + if(noise_fade < 0.01f) + return; + int ymax = noise_y + noise_h; + int np = pubrand.get(8); + int dnp = pubrand.get(4) - 8; + float ifade = 1.0f - noise_fade; + float step = 1.0f + ifade*ifade*ifade * 5.0f; + float rstep = (ifade + ifade*ifade*ifade * 10.0f) / 256.0f; + if(step < 1.0f) + step = 1.0f; + if(rstep < 0.0f) + rstep = 0.0f; + for(float fy = noise_y + pubrand.get(8) * rstep; fy < ymax; + fy += step + pubrand.get(8) * rstep) + { + int xo = PIXEL2CS(pubrand.get(NOISE_SIZEX_LOG2)); + int xmax = ((WSIZE + CS2PIXEL(xo)) >> NOISE_SIZEX_LOG2) + 1; + dnp += pubrand.get(3) - 4 + pubrand.get(1); + np += dnp; + if(np > 255) + np = 255, dnp = -dnp / 2; + else if(np < 0) + np = 0, dnp = -dnp / 2; + float level = np * noise_depth * (1.0f - noise_bright) / 255.0f + + noise_bright; + for(int x = 0; x < xmax; ++x) + win->sprite_fxp(PIXEL2CS(x<height() / 2; + + static float ypos = -50; + static float hf = 0; + static int ot = 0; + int t = (int)SDL_GetTicks(); + int dt = t - ot; + ot = t; + if(dt > 1000) + dt = 100; + + //Spring + friction style velocity component + if(dt < 500) + ypos += ((float)highlight_y - ypos) * (float)dt * 0.005f; + else + ypos = (float)highlight_y; + + //Constant velocity component + float v = (float)dt * 0.2f; + if((float)highlight_y - ypos > v) + ypos += v; + else if((float)highlight_y - ypos < -v) + ypos -= v; + else + ypos = (float)highlight_y; + + // Scale to new height + hf += ((float)highlight_h - hf) * (float)dt * 0.01f; + + // Render! + int y = (int)((ypos - hf / 2.0f) * 256.0f); + int h = (int)(hf * 256.0f); + if(h < 128) + return; + for(int ty = -256; ty <= h; ty += h + 256) + { + int xo = PIXEL2CS(pubrand.get(NOISE_SIZEX_LOG2)); + int xmax = ((WSIZE + CS2PIXEL(xo)) >> NOISE_SIZEX_LOG2) + 1; + for(int x = 0; x < xmax; ++x) + wmain->sprite_fxp(PIXEL2CS(x << NOISE_SIZEX_LOG2) - xo, + ty + y, + B_NOISE, 6); + } + + int x0 = win->phys_rect.x; + s_sprite_t *s = gengine->get_sprite(B_FOCUSFX, 0); + if(!s || !s->surface) + return; + SDL_Surface *fx = s->surface; + SDL_Surface *dst = gengine->surface(); + y = (int)((y * gengine->yscale() + 128) / 256) + win->phys_rect.y; + h = (int)(hf * gengine->yscale()); + win->select(); + for(int ty = 0; ty < h; ++ty) + { + float sy = (float)ty / (h - 1); + float scy = sy * hf; + float shape = 1.0f - sin(M_PI * sy); + float edges = shape * shape * shape; + float plasma = 0.5f + 0.5f * sin(t * 0.004f + + sin(t * 0.00017f) * scy * 0.18f); + float plasma2 = 0.5f + 0.5f * sin(t * .003 + + sin(t * 0.0001f) * scy * 0.12f); + int i = (int)((fx->h - 1) * ((.5f * plasma + .5f * plasma * shape) * + (1.0f - edges) + edges)); + int xo = (int)((t * 10 + 8192 * plasma2) * gengine->xscale() / 256); + xo -= (int)(xo / fx->w) * fx->w; + int xmax = (int)((WSIZE * gengine->xscale() + xo) / fx->w); + for(int x = 0; x <= xmax; ++x) + { + SDL_Rect sr, dr; + sr.x = 0; + sr.y = i; + sr.w = fx->w; + sr.h = 1; + dr.x = x0 + (int)(x * fx->w) - xo; + dr.y = y + ty; + SDL_BlitSurface(fx, &sr, dst, &dr); + } + } +} + + +void _screen::set_highlight(int y, int h) +{ + highlight_y = y; + highlight_h = h; +} + + +// This starfield implementation may seem a bit backwards. Instead of moving +// around in a 3D point cloud, projecting by dividing x and y by z etc, we're +// doing a plain orthogonal projection. That is, the z coordinates have no +// direct impact on rendering! +// What actually creates the parallax effect is that we scroll the *stars* +// around at different speeds, depending on their distance from the screen, +// which effectively replaces the usual (x/z, y/z) operation when projecting. +// The interesting part is that stars wrap around the edges automatically as +// a side effect of the integer arithmetics. Thus we can have a nice, dense +// "3D" starfield covering the whole window - no nearby stars way off screen, +// and no distant stars wrapping around in a small square in the middle of the +// screen. No clipping is needed, and thus, no cycles are wasted animating off- +// screen stars. +// Of course, this design means we cannot move along the Z axis (well, not +// trivially, at least), but we don't really need that here anyway. +// +#define WSX (WORLD_SIZEX << 8) +#define WSY (WORLD_SIZEY << 8) +void _screen::render_starfield(window_t *win, int xo, int yo) +{ + int i; + int w = win->width() * 256; + int h = win->height() * 256; + int xc = w / 2; + int yc = h / 2; + + // Calculate delta from last position, dealing with map position wrap + int dx = (xo - star_oxo) & (WSX - 1); + star_oxo = xo; + if(dx & (WSX >> 1)) + dx |= 1 - (WSX - 1); + int dy = (yo - star_oyo) & (WSY - 1); + star_oyo = yo; + if(dy & (WSY >> 1)) + dy |= 1 - (WSY - 1); + + // Scale the deltas to compensate for window/starfield size mismatch + // (Otherwise stars at zero distance won't sync up with the map as + // intended!) + dx = (dx << 16) / w; + dy = (dy << 16) / h; + + /* (Re-)initialize starfield */ + if(nstars != prefs->stars) + { + free(stars); + nstars = prefs->stars; + stars = (KOBO_Star *)malloc(nstars * sizeof(KOBO_Star)); + if(!stars) + { + nstars = 0; + return; // Out of memory!!! + } + for(i = 0; i < nstars; ++i) + { + stars[i].x = pubrand.get(); + stars[i].y = pubrand.get(); + int zz = 255 * i / nstars; + stars[i].z = 65025 - zz * zz; + } + } + + // Map colors (Should be done elsewhere, but must be re-done after + // restarting video!) + for(i = 0; i < STAR_COLORS; i += 2) + { + int c = 64 + i * (255 - 64) / STAR_COLORS; + starcolors[STAR_COLORS - i - 1] = win->map_rgb( + win->fadergb(0x6699cc, c)); + starcolors[STAR_COLORS - i - 2] = win->map_rgb( + win->fadergb(0x999966, c)); + } + + win->select(); + for(i = 0; i < nstars; ++i) + { + int z = (int)stars[i].z >> (16 - STAR_ZBITS); + + // Move stars with deltas scaled by 'z' + stars[i].x -= (dx << 8) / (z + STAR_Z0); + stars[i].y -= (dy << 8) / (z + STAR_Z0); + + // Scale and center + int x = (stars[i].x * (w >> 8) >> 8) + xc; + int y = (stars[i].y * (h >> 8) >> 8) + yc; + + // Plot! + win->foreground(starcolors[z * STAR_COLORS >> STAR_ZBITS]); + int s = 256 - (z * 128 >> STAR_ZBITS); + win->fillrect_fxp(x, y, s, s); + } +} + + +void _screen::render_background(window_t *win) +{ + if(!win) + return; + if(do_noise && (noise_fade >= 1.0f)) + return; + + int vx, vy, xo, yo, x, y, xmax, ymax; + int mx, my; + vx = gengine->xoffs(LAYER_BASES); + vy = gengine->yoffs(LAYER_BASES); + + /* + * Start exactly at the top-left corner + * of the tile visible in the top-left + * corner of the display window. + */ + xo = vx & (PIXEL2CS(CHIP_SIZEX) - 1); + yo = vy & (PIXEL2CS(CHIP_SIZEY) - 1); + mx = CS2PIXEL(vx >> CHIP_SIZEX_LOG2); + my = CS2PIXEL(vy >> CHIP_SIZEY_LOG2); + ymax = ((WSIZE+CS2PIXEL(yo)) >> CHIP_SIZEY_LOG2) + 1; + xmax = ((WSIZE+CS2PIXEL(xo)) >> CHIP_SIZEX_LOG2) + 1; + + /* + * NOTE: + * We need to clear regardless of starfield mode, as the new tiles + * use alpha/colorkey. + */ + win->clear(); + + /* Render parallax starfield, if selected */ + if(prefs->starfield == STARFIELD_PARALLAX) + render_starfield(win, vx, vy); + + int tileset = B_TILES1 + (scene_num / 10) % 5; + switch(prefs->starfield) + { + case STARFIELD_NONE: + case STARFIELD_PARALLAX: + /* Ignore star tiles */ + for(y = 0; y < ymax; ++y) + for(x = 0; x < xmax; ++x) + { + int n = map.pos(mx + x, my + y); + if(IS_SPACE(n)) + continue; + win->sprite_fxp(PIXEL2CS(x<> 8); + } + break; + case STARFIELD_OLD: + /* Draw all tiles, XKobo style */ + for(y = 0; y < ymax; ++y) + for(x = 0; x < xmax; ++x) + { + int n = map.pos(mx + x, my + y); + int b = IS_SPACE(n) ? B_OLDSTARS : tileset; + win->sprite_fxp(PIXEL2CS(x<> 8); + } + break; + } +} + + +void _screen::render_fx(window_t *win) +{ + if(!win) + return; + render_noise(win); + render_highlight(win); +} + + +void _screen::fps(float f) +{ + _fps = f; +} + + +void _screen::noise(int on) +{ + do_noise = on; +} diff --git a/screen.h b/screen.h new file mode 100644 index 0000000..0c39013 --- /dev/null +++ b/screen.h @@ -0,0 +1,105 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - An enhanced SDL port of XKobo +------------------------------------------------------------ + * Copyright (C) 1995, 1996 Akira Higuchi + * Copyright (C) 2001-2003, 2007 David Olofson + * + * 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. + */ + +#ifndef _KOBO_SCREEN_H_ +#define _KOBO_SCREEN_H_ + +#include "map.h" +#include "radar.h" + +#define STAR_COLORS 16 +#define STAR_ZBITS 10 +#define STAR_Z0 256 + +class window_t; + +struct KOBO_Star +{ + short x; + short y; + unsigned short z; +}; + +class _screen +{ + protected: + static int scene_num; + static int level; + static int generate_count; + static _map map; + static int scene_max; + static int show_title; + static int do_noise; + static float _fps; + static float scroller_speed; + static float target_speed; + static int noise_y; + static int noise_h; + static int noise_source; + static float noise_fade; + static float noise_bright; + static float noise_depth; + static int highlight_y; + static int highlight_h; + static int hi_sc[10]; + static int hi_st[10]; + static char hi_nm[10][20]; + static int nstars; + static KOBO_Star *stars; + static Uint32 starcolors[STAR_COLORS]; + static int star_oxo; + static int star_oyo; + static void render_noise(window_t *win); + static void render_highlight(window_t *win); + static void render_title_plasma(int t, float fade, int y, int h); + static void render_title_noise(float fade, int y, int h, int bank, int frame); + static void render_starfield(window_t *win, int xo, int yo); + public: + ~_screen(); + static radar_modes_t radar_mode; // Last set radar mode + static void init(); + static void init_scene(int sc); + static int prepare(); + static void generate_fixed_enemies(); + static inline int get_map(int x, int y) + { + return map.pos(x, y); + } + static void set_map(int x, int y, int n); + static void set_highlight(int y, int h); + static void set_noise(int source, float fade, float bright, float depth); + static void render_background(window_t * win); + static void render_fx(window_t * win); + static void title(int t, float fade, int mode); + static void init_highscores(); + static void highscores(int t, float fade); + static void credits(int t); + static void help(int t); + static void scroller(); + static void fps(float f); + static float fps() { return _fps; } + static void noise(int on); +}; + +extern _screen screen; + +#endif //_KOBO_SCREEN_H_ diff --git a/sound.cpp b/sound.cpp new file mode 100644 index 0000000..d6dfd43 --- /dev/null +++ b/sound.cpp @@ -0,0 +1,708 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - Wrapper for Sound Control +------------------------------------------------------------ + * Copyright (C) 2007 David Olofson + * + * 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. + */ + +#include "sound.h" + +#include "kobo.h" +#include "kobolog.h" +#include "random.h" +#include "audio.h" + +int KOBO_sound::sounds_loaded = 0; +int KOBO_sound::music_loaded = 0; +int KOBO_sound::time = 0; +int KOBO_sound::_period = 30; +int KOBO_sound::sfx2d_tag = 0; +int KOBO_sound::listener_x = 0; +int KOBO_sound::listener_y = 0; +int KOBO_sound::wrap_x = 0; +int KOBO_sound::wrap_y = 0; +int KOBO_sound::scale = 65536 / 1000; +int KOBO_sound::panscale = 65536 / 700; +int KOBO_sound::firing = 0; +int KOBO_sound::overheat = 0; +unsigned KOBO_sound::rumble = 0; + + +KOBO_sound::KOBO_sound() +{ +} + + +KOBO_sound::~KOBO_sound() +{ + close(); +} + + +/*-------------------------------------------------- + Open/close +--------------------------------------------------*/ + + +int KOBO_sound::load(int (*prog)(const char *msg), int force) +{ + int res; + int save_to_disk = 0; + const char *ap = fmap->get("SFX>>", FM_DIR); + if(!ap) + { + log_printf(ELOG, "Couldn't find audio data directory!\n"); + return -1; + } + audio_set_path(ap); + + if(!sounds_loaded || force) + { + if(prog("Loading sound effects")) + return -999; + res = -1; + if(prefs->cached_sounds && !force) + { + res = audio_wave_load(0, "sfx_c.agw", 0); + if(res < 0) + save_to_disk = 1; + } + if(res < 0) + res = audio_wave_load(0, "sfx.agw", 0); + if(res >= 0) + sounds_loaded = 1; + else + log_printf(ELOG, "Could not load sound effects!\n"); + prog(NULL); + } + + if(prefs->use_music && !music_loaded || force) + { + if(prog("Loading music")) + return -999; + res = -1; + if(prefs->cached_sounds && !force) + { + res = audio_wave_load(0, "music_c.agw", 0); + if(res < 0) + save_to_disk = 1; + } + if(res < 0) + res = audio_wave_load(0, "music.agw", 0); + if(res >= 0) + music_loaded = 1; + else + log_printf(ELOG, "Could not load music!\n"); + prog(NULL); + } + + if(save_to_disk) + if(prog("Preparing audio engine")) + return -999; + + audio_wave_prepare(-1); + + if(save_to_disk) + { + if(prog("Writing sounds to disk")) + return -999; + if(audio_wave_load(0, "save_waves.agw", 0) < 0) + log_printf(ELOG, "Could not save sounds to disk!\n"); + } + + audio_wave_info(-1); + + return prog(NULL); +} + + +void KOBO_sound::prefschange() +{ + /* Levels */ +// audio_master_volume((float)prefs->volume/100.0); + audio_group_controlf(SOUND_GROUP_UI, ACC_VOLUME, + (float)prefs->intro_vol/100.0); + audio_group_controlf(SOUND_GROUP_UIMUSIC, ACC_VOLUME, + (float)prefs->intro_vol/100.0); + audio_group_controlf(SOUND_GROUP_SFX, ACC_VOLUME, + (float)prefs->sfx_vol/100.0); + audio_group_controlf(SOUND_GROUP_BGMUSIC, ACC_VOLUME, + (float)prefs->music_vol/100.0); + set_boost(prefs->vol_boost); + audio_quality((audio_quality_t)prefs->mixquality); + + // Bus 7: Our "Master Reverb Bus" + master_reverb((float)prefs->reverb/100.0); +} + + +int KOBO_sound::open() +{ + if(!prefs->use_sound) + { + log_printf(WLOG, "Sound disabled!\n"); + return 0; + } + + if(audio_start(prefs->samplerate, prefs->latency, prefs->use_oss, prefs->cmd_midi, + prefs->cmd_pollaudio) < 0) + { + log_printf(ELOG, "Couldn't initialize audio;" + " disabling sound effects.\n"); + return -1; + } + + // Channel grouping. We use only one chanel per group here, so we + // just assign the first channels to the available groups. + for(int i = 0; i < AUDIO_MAX_GROUPS; ++i) + audio_channel_control(i, -1, ACC_GROUP, i); + + // Dirty hack for the music; the sequencer uses channels 16..31. + for(int i = 16; i < 32; ++i) + audio_channel_control(i, -1, ACC_GROUP, SOUND_GROUP_BGMUSIC); + + // Higher priority for music and UI effects + audio_channel_control(SOUND_GROUP_BGMUSIC, AVT_ALL, ACC_PRIORITY, 1); + audio_channel_control(SOUND_GROUP_UIMUSIC, AVT_ALL, ACC_PRIORITY, 2); + audio_channel_control(SOUND_GROUP_UI, AVT_ALL, ACC_PRIORITY, 3); + audio_channel_control(SOUND_GROUP_SFX, AVT_ALL, ACC_PRIORITY, 4); + + g_wrap(MAP_SIZEX*CHIP_SIZEX, MAP_SIZEY*CHIP_SIZEY); + g_scale(VIEWLIMIT * 3 / 2, VIEWLIMIT); + + // For the noise "bzzzt" effect :-) + audio_channel_control(3, -1, ACC_PRIM_BUS, 1); + + // Bus 0: Sound effects + audio_bus_control(0, 1, ABC_FX_TYPE, AFX_NONE); + audio_bus_controlf(0, 0, ABC_SEND_MASTER, 1.0); + audio_bus_controlf(0, 0, ABC_SEND_BUS_7, 0.5); // Always a little rvb! + + // Bus 1: Sound effects with less reverb + audio_bus_control(1, 1, ABC_FX_TYPE, AFX_NONE); + audio_bus_controlf(1, 0, ABC_SEND_MASTER, 1.0); + audio_bus_controlf(1, 0, ABC_SEND_BUS_7, 0.1); + + prefschange(); + + time = SDL_GetTicks(); + return 0; +} + + +void KOBO_sound::stop() +{ + audio_stop(); +} + + +void KOBO_sound::close() +{ + audio_close(); + sounds_loaded = 0; + music_loaded = 0; +} + + + +/*-------------------------------------------------- + Main controls +--------------------------------------------------*/ + +void KOBO_sound::master_reverb(float rvb) +{ + int master_rvb = (int)(rvb * 65536.0); + audio_bus_controlf(7, 0, ABC_SEND_MASTER, 0.0); + audio_bus_control(7, 1, ABC_SEND_MASTER, master_rvb); + if(master_rvb) + audio_bus_control(7, 1, ABC_FX_TYPE, AFX_REVERB); + else + audio_bus_control(7, 1, ABC_FX_TYPE, AFX_NONE); +} + + +void KOBO_sound::set_boost(int boost) +{ + switch(boost) + { + case 0: + audio_set_limiter(1.0, 5.0); + break; + case 1: + audio_set_limiter(.9, 4.5); + break; + case 2: + default: + audio_set_limiter(.75, 4.0); + break; + case 3: + audio_set_limiter(.5, 3.5); + break; + case 4: + audio_set_limiter(.25, 3.0); + break; + } +} + + +void KOBO_sound::sfx_volume(float vol) +{ + audio_group_controlf(SOUND_GROUP_SFX, ACC_VOLUME, + (float)prefs->sfx_vol * vol / 100.0f); +} + + +void KOBO_sound::intro_volume(float vol) +{ + audio_group_controlf(SOUND_GROUP_UIMUSIC, ACC_VOLUME, + (float)prefs->intro_vol * vol / 100.0f); +} + + +void KOBO_sound::music_volume(float vol) +{ + audio_group_controlf(SOUND_GROUP_BGMUSIC, ACC_VOLUME, + (float)prefs->music_vol * vol / 100.0f); +} + + +void KOBO_sound::period(int ms) +{ + if(ms > 0) + _period = ms; + time = 0; +} + + +void KOBO_sound::frame() +{ +#if 0 + // Positional audio test + static int aaa = 0; + if(++aaa > 20) + aaa = 0; + if(aaa == 10) + g_play(SOUND_OVERHEAT, listener_x + 128, listener_y, 32768, 55<<16); + else if (aaa == 20) + g_play(SOUND_OVERHEAT, listener_x - 128, listener_y, 32768, 67<<16); +#endif + // Advance to next game logic frame + int nc = audio_next_callback(); + if(time < nc) + time = nc; + else + time -= 1 + (labs(time - nc) >> 5); + audio_bump(time); + time += _period; + + // Various sound control logic + ++rumble; // Rumble timer +} + + +void KOBO_sound::run() +{ + audio_run(); +} + + +/*-------------------------------------------------- + In-game sound +--------------------------------------------------*/ + +void KOBO_sound::g_music(int wid) +{ + audio_channel_control(SOUND_GROUP_BGMUSIC, AVT_FUTURE, ACC_PATCH, wid); + audio_channel_control(SOUND_GROUP_UI, AVT_FUTURE, ACC_PAN, 0); + audio_channel_play(SOUND_GROUP_BGMUSIC, 0, 60<<16, 65536); +} + + +void KOBO_sound::play(int wid, int vol, int pitch, int pan) +{ + audio_channel_control(SOUND_GROUP_UI, AVT_FUTURE, ACC_PATCH, wid); + audio_channel_control(SOUND_GROUP_UI, AVT_FUTURE, ACC_PAN, pan); + audio_channel_play(SOUND_GROUP_UI, 0, pitch, vol); +} + + +void KOBO_sound::g_position(int x, int y) +{ + listener_x = x; + listener_y = y; +} + + +void KOBO_sound::g_wrap(int w, int h) +{ + wrap_x = w; + wrap_y = h; +} + + +void KOBO_sound::g_scale(int maxrange, int pan_maxrange) +{ + scale = 65536 / maxrange; + panscale = 65536 / pan_maxrange; +} + + +void KOBO_sound::g_play(int wid, int x, int y, int vol, int pitch) +{ + int volume, vx, vy, pan; + /* Calculate volume */ + x -= listener_x; + y -= listener_y; + if(wrap_x) + { + x += wrap_x / 2; + while(x < 0) + x += wrap_x; + x %= wrap_x; + x -= wrap_x / 2; + } + if(wrap_y) + { + y += wrap_y / 2; + while(y < 0) + y += wrap_y; + y %= wrap_y; + y -= wrap_y / 2; + } + + /* Approximation of distance attenuation */ + vx = abs(x * scale); + vy = abs(y * scale); + if((vx | vy) & 0xffff0000) + return; + + vx = (65536 - vx) >> 1; + vy = (65536 - vy) >> 1; + volume = vx * vy >> 14; + volume = (volume>>1) * (volume>>1) >> 14; + + pan = x * panscale; + if(pan < -65536) + pan = -65536; + else if(pan > 65536) + pan = 65536; + + audio_channel_control(SOUND_GROUP_SFX, AVT_FUTURE, ACC_PATCH, wid); + audio_channel_control(SOUND_GROUP_SFX, AVT_FUTURE, ACC_PAN, pan); + audio_channel_control(SOUND_GROUP_SFX, AVT_FUTURE, ACC_VOLUME, volume); + audio_channel_play(SOUND_GROUP_SFX, sfx2d_tag, pitch, vol); + sfx2d_tag = (sfx2d_tag + 1) & 0xffff; +} + + +void KOBO_sound::g_play0(int wid, int vol, int pitch) +{ + audio_channel_control(SOUND_GROUP_SFX, AVT_FUTURE, ACC_PATCH, wid); + audio_channel_control(SOUND_GROUP_SFX, AVT_FUTURE, ACC_PAN, 0); + audio_channel_control(SOUND_GROUP_SFX, AVT_FUTURE, ACC_VOLUME, 65536); + audio_channel_play(SOUND_GROUP_SFX, sfx2d_tag, 60<<16, vol); + sfx2d_tag = (sfx2d_tag + 1) & 0xffff; +} + + +void KOBO_sound::g_player_fire() +{ + if(firing) + g_play0(SOUND_SHOT, (prefs->cannonloud << 13) / 100); + else + { + firing = 1; + g_play0(SOUND_SHOT_START, 20000); + } + overheat = 0; +} + + +void KOBO_sound::g_player_fire_off() +{ + if(firing) + { + firing = 0; + g_play0(SOUND_SHOT_END, 20000); + } +} + + +void KOBO_sound::g_player_overheat(int classic) +{ + if(overheat) + return; + overheat = 1; + g_play0(SOUND_SHOT_OVERHEAT, (prefs->cannonloud << 13) / 75); + if(!classic) + g_play(SOUND_OVERHEAT, listener_x + 100, listener_y, + (prefs->overheatloud << 14) / 100); +} + + +void KOBO_sound::g_player_damage() +{ + int p0 = (60<<16) + (pubrand.get(9) << 8); + g_play(SOUND_DAMAGE, listener_x - 100, listener_y, + 65536, p0 + 3000); + g_play(SOUND_DAMAGE, listener_x + 100, listener_y, + 65536, p0 - 3000); +} + + +void KOBO_sound::g_player_explo_start() +{ + g_player_damage(); + g_play(SOUND_EXPLO_PLAYER, listener_x - 100, listener_y, + 65536, (55<<16) + 4000); + g_play(SOUND_EXPLO_PLAYER, listener_x + 100, listener_y, + 65536, (55<<16) - 4000); +} + + +void KOBO_sound::g_bolt_hit(int x, int y) +{ + g_play(SOUND_METALLIC1 + (pubrand.get() % 3), + CS2PIXEL(x), CS2PIXEL(y), + 12000); +} + + +void KOBO_sound::g_bolt_hit_rock(int x, int y) +{ + g_play(SOUND_HIT1 + (pubrand.get() % 3), + CS2PIXEL(x), CS2PIXEL(y), + 20000); +} + + +void KOBO_sound::g_base_node_explo(int x, int y) +{ + g_play(pubrand.get(8) > 128 ? SOUND_EXPLO_NODE1 : SOUND_EXPLO_NODE2, + CS2PIXEL(x), CS2PIXEL(y)); + rumble = 0; +} + + +void KOBO_sound::g_base_core_explo(int x, int y) +{ + x = CS2PIXEL(x); + y = CS2PIXEL(y); + g_play(pubrand.get(8) > 128 ? SOUND_EXPLO_NODE1 : SOUND_EXPLO_NODE2, + x, y, 100000, 62<<16); + g_play(SOUND_FINE, x + 30, y, 65536, (60<<16) + 4000); + g_play(SOUND_FINE, x - 30, y, 65536, (60<<16) - 4000); + rumble = 0; +} + + +void KOBO_sound::g_pipe_rumble(int x, int y) +{ + if(rumble < 4 + pubrand.get(3)) + return; + g_play(pubrand.get(8) > 128 ? SOUND_RUMBLE_NODE1 : SOUND_RUMBLE_NODE2, + CS2PIXEL(x), CS2PIXEL(y)); + rumble = 0; +} + + +void KOBO_sound::g_enemy_explo(int x, int y) +{ + g_play(SOUND_EXPLO_ENEMY1 + (pubrand.get() % 2), + CS2PIXEL(x), CS2PIXEL(y), 40000); +} + + +void KOBO_sound::g_rock_explo(int x, int y) +{ + g_play(SOUND_EXPLO_ROCK, CS2PIXEL(x), CS2PIXEL(y), 40000); +} + + +void KOBO_sound::g_ring_explo(int x, int y) +{ + g_play(SOUND_EXPLO_RING1 + (pubrand.get() % 3), + CS2PIXEL(x), CS2PIXEL(y), 32768); +} + + +void KOBO_sound::g_bomb_deto(int x, int y) +{ + g_play(SOUND_BOMB_DETO, CS2PIXEL(x), CS2PIXEL(y), 40000); +} + + +void KOBO_sound::g_launch_ring(int x, int y) +{ + g_play(SOUND_RING, CS2PIXEL(x), CS2PIXEL(y)); +} + + +void KOBO_sound::g_launch_beam(int x, int y) +{ + g_play(SOUND_BEAM, CS2PIXEL(x), CS2PIXEL(y)); +} + + +void KOBO_sound::g_launch_bomb(int x, int y) +{ + g_play(SOUND_LAUNCH2, CS2PIXEL(x), CS2PIXEL(y)); +} + + +void KOBO_sound::g_launch(int x, int y) +{ + g_play(SOUND_LAUNCH, CS2PIXEL(x), CS2PIXEL(y)); +} + + +void KOBO_sound::g_m_launch_ring(int x, int y) +{ + g_play(SOUND_RING, CS2PIXEL(x), CS2PIXEL(y)); + g_play(SOUND_ENEMYM, CS2PIXEL(x), CS2PIXEL(y)); +} + + +void KOBO_sound::g_m_launch_beam(int x, int y) +{ + g_play(SOUND_BEAM, CS2PIXEL(x), CS2PIXEL(y)); + g_play(SOUND_ENEMYM, CS2PIXEL(x), CS2PIXEL(y)); +} + + +void KOBO_sound::g_m_launch_bomb(int x, int y) +{ + g_play(SOUND_LAUNCH2, CS2PIXEL(x), CS2PIXEL(y)); + g_play(SOUND_ENEMYM, CS2PIXEL(x), CS2PIXEL(y)); +} + + +void KOBO_sound::g_m_launch(int x, int y) +{ + g_play(SOUND_LAUNCH, CS2PIXEL(x), CS2PIXEL(y)); + g_play(SOUND_ENEMYM, CS2PIXEL(x), CS2PIXEL(y)); +} + + +/*-------------------------------------------------- + UI sound effects +--------------------------------------------------*/ + +void KOBO_sound::ui_music(int wid) +{ +// KLUDGE UNTIL MIDI SONGS AND FX CONTROL IS FIXED! + audio_bus_control(0, 1, ABC_FX_TYPE, AFX_NONE); + audio_bus_controlf(0, 0, ABC_SEND_MASTER, 1.0); + audio_bus_controlf(0, 0, ABC_SEND_BUS_7, 0.5); +// KLUDGE UNTIL MIDI SONGS AND FX CONTROL IS FIXED! + audio_channel_control(SOUND_GROUP_UIMUSIC, AVT_FUTURE, ACC_PATCH, wid); + audio_channel_play(SOUND_GROUP_UIMUSIC, 0, 60<<16, 65536); +} + + +void KOBO_sound::ui_noise(int n) +{ + if(n < 0) + { + sound.sfx_volume(0.0f); + audio_channel_control(SOUND_GROUP_UI, + AVT_FUTURE, ACC_PATCH, SOUND_BZZZT); + audio_channel_play(SOUND_GROUP_UI, 0, 60<<16, + 10000 + pubrand.get(14)); + return; + } + if(n && pubrand.get(1)) + { + sound.sfx_volume(0.0f); + audio_channel_control(SOUND_GROUP_UI, + AVT_FUTURE, ACC_PATCH, SOUND_BZZZT); + audio_channel_play(SOUND_GROUP_UI, 0, 60<<16, + 20000 + pubrand.get(14)); + } + else + sound.sfx_volume(1.0f); +} + + +void KOBO_sound::ui_ok() +{ + play(SOUND_EXPLO_NODE1, 32768); +} + + +void KOBO_sound::ui_cancel() +{ + play(SOUND_CANCEL, 20000); +} + + +void KOBO_sound::ui_move() +{ + play(SOUND_MOVE, 20000); +} + + +void KOBO_sound::ui_tick() +{ + play(SOUND_METALLIC1, 15000); +} + + +void KOBO_sound::ui_error() +{ + play(SOUND_OVERHEAT, 20000); +} + + +void KOBO_sound::ui_play() +{ + play(SOUND_PLAY, 32768, (50<<16) + 2000, -40000); + play(SOUND_PLAY, 32768, (50<<16) - 2000, 40000); +} + + +void KOBO_sound::ui_pause() +{ + play(SOUND_PAUSE, 32768, (56<<16) + 2000, -40000); + play(SOUND_PAUSE, 32768, (56<<16) - 2000, 40000); +} + + +void KOBO_sound::ui_ready() +{ + play(SOUND_READY, 15000, (60<<16) + 3000, -40000); + play(SOUND_READY, 15000, (60<<16) - 3000, 40000); +} + + +void KOBO_sound::ui_countdown(int remain) +{ + play(SOUND_TICK, 20000, (65 - remain)<<16); +} + + +void KOBO_sound::ui_oneup() +{ + play(SOUND_ONEUP, 32768, (60<<16) + 5000, -40000); + play(SOUND_ONEUP, 32768, (60<<16) - 5000, 40000); +} + + +void KOBO_sound::ui_gameover() +{ + play(SOUND_GAMEOVER); +} diff --git a/sound.h b/sound.h new file mode 100644 index 0000000..2843a7a --- /dev/null +++ b/sound.h @@ -0,0 +1,152 @@ +/*(GPL) +------------------------------------------------------------ + Kobo Deluxe - Wrapper for Sound Control +------------------------------------------------------------ + * Copyright (C) 2007 David Olofson + * + * 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. + */ + +#ifndef KOBO_SOUND_H +#define KOBO_SOUND_H + +#include "kobosfx.h" + +/* Sound groups */ +#define SOUND_GROUP_UI 0 +#define SOUND_GROUP_SFX 1 +#define SOUND_GROUP_UIMUSIC 2 +#define SOUND_GROUP_BGMUSIC 3 + + +class KOBO_sound +{ + static int sounds_loaded; + static int music_loaded; + + /* In-game sfx stuff */ + static int time; + static int _period; + static int sfx2d_tag; + static int listener_x; + static int listener_y; + static int wrap_x; + static int wrap_y; + static int scale; + static int panscale; + static int firing; + static int overheat; + static unsigned rumble; + + public: + KOBO_sound(); + ~KOBO_sound(); + + /*-------------------------------------------------- + Open/close + --------------------------------------------------*/ + static int open(); + static void prefschange(); + static int load(int (*prog)(const char *msg), int force); + static void stop(); + static void close(); + + /*-------------------------------------------------- + Main controls + --------------------------------------------------*/ + static void master_reverb(float rvb); + static void set_boost(int vol_boost); + static void sfx_volume(float vol); + static void intro_volume(float vol); + static void music_volume(float vol); + static void period(int ms); // 0 to reset time + static void frame(); + static void run(); + + /* Play a user interface sound */ + static void play(int wid, int vol = 65536, int pitch = 60<<16, + int pan = 0); + + /* Play a sound at a specific location on the map */ + static void g_play(int wid, int x, int y, + int vol = 65536, int pitch = 60<<16); + + /* Play a sound right where the listener is. */ + static void g_play0(int wid, int vol = 65536, int pitch = 60<<16); + + /*-------------------------------------------------- + In-game sound + --------------------------------------------------*/ + /* Play in-game music */ + static void g_music(int wid); + + /* Set listener position */ + static void g_position(int x, int y); + + /* Set world size for wrapping */ + static void g_wrap(int w, int h); + + /* + * Set world scale. 'maxrange' is the distance where + * a sound is out of the audible range. + */ + static void g_scale(int maxrange, int pan_maxrange); + + /* Various sound effects */ + static void g_player_fire(); + static void g_player_fire_off(); + static void g_player_overheat(int classic = 0); + static void g_player_damage(); + static void g_player_explo_start(); + static void g_bolt_hit(int x, int y); + static void g_bolt_hit_rock(int x, int y); + static void g_base_node_explo(int x, int y); + static void g_base_core_explo(int x, int y); + static void g_pipe_rumble(int x, int y); + static void g_enemy_explo(int x, int y); + static void g_rock_explo(int x, int y); + static void g_ring_explo(int x, int y); + static void g_bomb_deto(int x, int y); + static void g_launch_ring(int x, int y); + static void g_launch_beam(int x, int y); + static void g_launch_bomb(int x, int y); + static void g_launch(int x, int y); + static void g_m_launch_ring(int x, int y); + static void g_m_launch_beam(int x, int y); + static void g_m_launch_bomb(int x, int y); + static void g_m_launch(int x, int y); + + /*-------------------------------------------------- + UI sound effects + --------------------------------------------------*/ + /* Low level interface */ + static void ui_music(int wid); + + /* Various UI effects */ + static void ui_noise(int n); + static void ui_ok(); + static void ui_cancel(); + static void ui_move(); + static void ui_tick(); + static void ui_error(); + static void ui_play(); + static void ui_pause(); + static void ui_ready(); + static void ui_countdown(int remain); + static void ui_oneup(); + static void ui_gameover(); +}; + +#endif /* KOBO_SOUND_H */ diff --git a/sound/Makefile.am b/sound/Makefile.am new file mode 100644 index 0000000..08650d3 --- /dev/null +++ b/sound/Makefile.am @@ -0,0 +1,12 @@ +noinst_LIBRARIES = libsound.a + +INCLUDES = -I../eel -I../graphics @LOCALCFLAGS@ + +libsound_a_SOURCES = audio.c a_globals.c a_struct.c \ + audiodev.c a_midi.c sfifo.c a_pitch.c a_midisock.c \ + a_wave.c a_patch.c a_channel.c a_voice.c a_bus.c \ + a_commands.c a_control.c a_midicon.c a_midifile.c \ + a_plugin.c a_delay.c a_limiter.c a_filters.c \ + a_wca.c a_agw.c a_sequencer.c a_events.c + +EXTRA_DIST = *.h diff --git a/sound/Makefile.in b/sound/Makefile.in new file mode 100644 index 0000000..d7915a7 --- /dev/null +++ b/sound/Makefile.in @@ -0,0 +1,459 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = sound +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/aconfig.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +libsound_a_AR = $(AR) $(ARFLAGS) +libsound_a_LIBADD = +am_libsound_a_OBJECTS = audio.$(OBJEXT) a_globals.$(OBJEXT) \ + a_struct.$(OBJEXT) audiodev.$(OBJEXT) a_midi.$(OBJEXT) \ + sfifo.$(OBJEXT) a_pitch.$(OBJEXT) a_midisock.$(OBJEXT) \ + a_wave.$(OBJEXT) a_patch.$(OBJEXT) a_channel.$(OBJEXT) \ + a_voice.$(OBJEXT) a_bus.$(OBJEXT) a_commands.$(OBJEXT) \ + a_control.$(OBJEXT) a_midicon.$(OBJEXT) a_midifile.$(OBJEXT) \ + a_plugin.$(OBJEXT) a_delay.$(OBJEXT) a_limiter.$(OBJEXT) \ + a_filters.$(OBJEXT) a_wca.$(OBJEXT) a_agw.$(OBJEXT) \ + a_sequencer.$(OBJEXT) a_events.$(OBJEXT) +libsound_a_OBJECTS = $(am_libsound_a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libsound_a_SOURCES) +DIST_SOURCES = $(libsound_a_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUDIO_LIBS = @AUDIO_LIBS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_MACOSX_BUNDLE_FALSE = @BUILD_MACOSX_BUNDLE_FALSE@ +BUILD_MACOSX_BUNDLE_TRUE = @BUILD_MACOSX_BUNDLE_TRUE@ +BUILD_SIMPLE_BUNDLE_FALSE = @BUILD_SIMPLE_BUNDLE_FALSE@ +BUILD_SIMPLE_BUNDLE_TRUE = @BUILD_SIMPLE_BUNDLE_TRUE@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONFIGDIR = @CONFIGDIR@ +CONFIGFILE = @CONFIGFILE@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +EXEFILE = @EXEFILE@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LOCALCFLAGS = @LOCALCFLAGS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MATHLIB = @MATHLIB@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POW_LIB = @POW_LIB@ +RANLIB = @RANLIB@ +SCOREDIR = @SCOREDIR@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +UNIX_SCOREDIR_FALSE = @UNIX_SCOREDIR_FALSE@ +UNIX_SCOREDIR_TRUE = @UNIX_SCOREDIR_TRUE@ +VERSION = @VERSION@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +noinst_LIBRARIES = libsound.a +INCLUDES = -I../eel -I../graphics @LOCALCFLAGS@ +libsound_a_SOURCES = audio.c a_globals.c a_struct.c \ + audiodev.c a_midi.c sfifo.c a_pitch.c a_midisock.c \ + a_wave.c a_patch.c a_channel.c a_voice.c a_bus.c \ + a_commands.c a_control.c a_midicon.c a_midifile.c \ + a_plugin.c a_delay.c a_limiter.c a_filters.c \ + a_wca.c a_agw.c a_sequencer.c a_events.c + +EXTRA_DIST = *.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign sound/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign sound/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libsound.a: $(libsound_a_OBJECTS) $(libsound_a_DEPENDENCIES) + -rm -f libsound.a + $(libsound_a_AR) libsound.a $(libsound_a_OBJECTS) $(libsound_a_LIBADD) + $(RANLIB) libsound.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_agw.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_bus.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_channel.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_commands.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_control.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_delay.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_events.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_filters.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_globals.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_limiter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_midi.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_midicon.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_midifile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_midisock.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_patch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_pitch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_plugin.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_sequencer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_struct.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_voice.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_wave.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_wca.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audiodev.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfifo.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-noinstLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/sound/a_agw.c b/sound/a_agw.c new file mode 100644 index 0000000..ead55b0 --- /dev/null +++ b/sound/a_agw.c @@ -0,0 +1,528 @@ +/*(LGPL) +--------------------------------------------------------------------------- + a_agw.c - "Algorithmically Generated Waveform" file support +--------------------------------------------------------------------------- + * Copyright (C) 2002, 2003, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define DBG(x) + +#include + +#include "kobolog.h" +#include "config.h" +#include "eel.h" +#include "a_types.h" +#include "a_wca.h" +#include "a_control.h" + + +/* Enum class handles */ + +static int enum_aformat, enum_amodtarget, enum_awaveform, enum_afiltertype; +static int enum_amixmode, enum_aresample; + +static int enum_pparam, enum_pdriver; + + +/*---------------------------------------------------------- + AGW Command Callbacks +----------------------------------------------------------*/ + +static int op_w_reset(int argc, struct eel_data_t *argv) +{ + DBG(log_printf(D2LOG, "w_reset;\n");) + wca_reset(); + return 1; +} + + +static int op_w_format(int argc, struct eel_data_t *argv) +{ + int target; + double fs; + int format = enum_aformat; +#if 0 + /* Alternative, more verbose method. */ + eel_symbol_t *fmt; + if(eel_get_args("iEr", &target, &fmt, &fs) != 3) + return -1; + if(fmt->token != enum_aformat) + { + eel_error("Wrong enum class!"); + return -1; + } + DBG(log_printf(D2LOG, "w_format %d, %s, %f;\n", target, eel_s_stringrep(fmt), fs);) + format = fmt->data.value.i; +#else + if(eel_get_args("ier", &target, &format, &fs) != 3) + return -1; +#endif + DBG(log_printf(D2LOG, "w_format %d, %d, %f;\n", target, format, fs);) + audio_wave_format(target, format, (int)fs); + return 1; +} + + +static int op_w_gain(int argc, struct eel_data_t *argv) +{ + int target; + if(eel_get_args("i", &target) != 1) + return -1; + DBG(log_printf(D2LOG, "w_gain %d;\n", target);) + wca_gain(target); + return 1; +} + + +static int op_w_convert(int argc, struct eel_data_t *argv) +{ + int source, target; + double fs; + int format = enum_aformat; + int interpol = enum_aresample; + argc = eel_get_args("iie[re]", + &source, &target, &format, + &fs, &interpol); + if(argc < 3) + return -1; + if(argc < 4) + fs = 0; + if(argc < 5) + interpol = AR_BEST; + DBG(log_printf(D2LOG, "w_convert %d, %d, %d, %d, %d;\n", source, target, + format, (int)fs, interpol);) + audio_wave_convert(source, target, format, (int)fs, interpol); + return 1; +} + + +static int op_w_enhance(int argc, struct eel_data_t *argv) +{ + int target; + double f, level; + if(eel_get_args("irr", &target, &f, &level) != 3) + return -1; + DBG(log_printf(D2LOG, "w_enhance %d, %d, %f;\n", target, (int)f, level);) + wca_enhance(target, (int)f, level); + return 1; +} + + +static int op_w_gate(int argc, struct eel_data_t *argv) +{ + int target; + double f, min, thres, att; + if(eel_get_args("irrrr", + &target, &f, &min, &thres, &att) != 5) + return -1; + DBG(log_printf(D2LOG, "w_gate %d, %d, %f, %f, %f;\n", + target, (int)f, min, thres, att);) + wca_gate(target, (int)f, min, thres, att); + return 1; +} + + +static int op_w_blank(int argc, struct eel_data_t *argv) +{ + int target, loop; + unsigned samples; + argc = eel_get_args("ii[i]", &target, &samples, &loop); + if(argc < 2) + return -1; + if(argc < 3) + loop = 0; + DBG(log_printf(D2LOG, "w_blank %d, %d, %d;\n", target, samples, loop);) + audio_wave_blank(target, samples, loop); + return 1; +} + + +static int op_w_load(int argc, struct eel_data_t *argv) +{ + int target, loop; + const char *fn; + argc = eel_get_args("is[i]", &target, &fn, &loop); + if(argc < 2) + return -1; + if(argc < 3) + loop = 0; + DBG(log_printf(D2LOG, "w_load %d, \"%s\", %d;\n", target, fn, loop);) + if(audio_wave_load(target, fn, loop) < 0) + return -1; + return 1; +} + + +static int op_w_save(int argc, struct eel_data_t *argv) +{ + int target; + const char *fn; + if(eel_get_args("is", &target, &fn) != 2) + return -1; + DBG(log_printf(D2LOG, "w_save %d, \"%s\";\n", target, fn);) + if(audio_wave_save(target, fn) < 0) + return -1; + return 1; +} + + +static int op_w_prepare(int argc, struct eel_data_t *argv) +{ + int target; + if(eel_get_args("i", &target) < 1) + return -1; + DBG(log_printf(D2LOG, "w_prepare %d;\n", target);) + audio_wave_prepare(target); + return 1; +} + + +static int op_w_env(int argc, struct eel_data_t *argv) +{ + int i; + int modtarget = enum_amodtarget; + double dur[WCA_MAX_ENV_STEPS]; + double val[WCA_MAX_ENV_STEPS]; + + if(argc > 1 + 2*WCA_MAX_ENV_STEPS) + { + eel_error("Too many envelope steps!"); + return -1; + } + + if(eel_get_args("e[]", &modtarget, &dur, &val) != argc) + return -1; + + DBG(log_printf(D2LOG, "w_env %d", modtarget);) + wca_mod_reset(modtarget); + if(2 == argc) + { + /* + * Note that dur[0] actually becomes a *value* + * rather than a time in this case! + */ + DBG(log_printf(D2LOG, ", %f;\n", dur[0]);) + wca_val(modtarget, dur[0]); + return 1; + } + for(i = 1; i < argc; i += 2) + { + int sec = (i-1)/2; + DBG(log_printf(D2LOG, ", <%f", dur[sec]);) + if(i+1 >= argc) + { + eel_error(" argruments must" + " come in pairs!"); + return -1; + } + DBG(else + log_printf(D2LOG, ", %f", val[sec]);) + DBG(log_printf(D2LOG, ">");) + wca_env(modtarget, dur[sec], val[sec]); + } + DBG(log_printf(D2LOG, ";\n");) + + return 1; +} + + +static int op_w_mod(int argc, struct eel_data_t *argv) +{ + int mt; + double f, a, d; + mt = enum_amodtarget; + if(eel_get_args("errr", &mt, &f, &a, &d) != 4) + return -1; + DBG(log_printf(D2LOG, "w_mod %d, %f, %f, %f;\n", mt, f, a, d);) + wca_mod(mt, f, a, d); + return 1; +} + + +static int op_w_osc(int argc, struct eel_data_t *argv) +{ + int target, wf, mm; + wf = enum_awaveform; + mm = enum_amixmode; + switch(eel_get_args("ie[e]", &target, &wf, &mm)) + { + case 2: + mm = WCA_ADD; + case 3: + break; + default: + return -1; + } + DBG(log_printf(D2LOG, "w_osc %d, %d, %d;\n", target, wf, mm);) + wca_osc(target, wf, mm); + return 1; +} + + +static int op_w_filter(int argc, struct eel_data_t *argv) +{ + int target, ft; + ft = enum_afiltertype; + if(eel_get_args("ie", &target, &ft) != 2) + return -1; + DBG(log_printf(D2LOG, "w_filter %d, %d;\n", target, ft);) + wca_filter(target, ft); + return 1; +} + + + +/*---------------------------------------------------------- + Patch Command Callbacks +----------------------------------------------------------*/ + +static int op_p_param(int argc, struct eel_data_t *argv) +{ + int patch, param; + double value; + param = enum_pparam; + if(eel_get_args("ier", &patch, ¶m, &value) != 3) + return -1; + switch(param) + { + case APP_DRIVER: + case APP_WAVE: + case APP_ENV_SKIP: + case APP_LFO_SHAPE: + audio_patch_param(patch, param, (int)value); + break; + default: + audio_patch_param(patch, param, (int)(value * 65536.0)); + break; + } + DBG(log_printf(D2LOG, "p_param %d, %d, %f;\n", patch, param, value);) + return 1; +} + + +static int op_p_driver(int argc, struct eel_data_t *argv) +{ + int patch; + eel_symbol_t *callback; + if(eel_get_args("if", &patch, &callback) != 2) + return -1; + DBG(log_printf(D2LOG, "p_driver %d, %s;\n", patch, eel_s_stringrep(callback));) + return 1; +} + + +/*---------------------------------------------------------- + Init code +----------------------------------------------------------*/ + +static void load_keywords(void) +{ + /* WCA calls */ + eel_register_operator("w_reset", op_w_reset, 100, 0 ,0); + eel_register_operator("w_format", op_w_format, 100, 0 ,0); + eel_register_operator("w_blank", op_w_blank, 100, 0 ,0); + eel_register_operator("w_load", op_w_load, 100, 0 ,0); + eel_register_operator("w_save", op_w_save, 100, 0 ,0); + eel_register_operator("w_prepare", op_w_prepare, 100, 0 ,0); + eel_register_operator("w_env", op_w_env, 100, 0 ,0); + eel_register_operator("w_mod", op_w_mod, 100, 0 ,0); + eel_register_operator("w_osc", op_w_osc, 100, 0 ,0); + eel_register_operator("w_filter", op_w_filter, 100, 0 ,0); + eel_register_operator("w_gain", op_w_gain, 100, 0 ,0); + eel_register_operator("w_convert", op_w_convert, 100, 0 ,0); + eel_register_operator("w_enhance", op_w_enhance, 100, 0 ,0); + eel_register_operator("w_gate", op_w_gate, 100, 0 ,0); + + /* w_convert resampling modes */ + enum_aresample = eel_register_enum_class(); + eel_register_enum(enum_aresample, "NEAREST", AR_NEAREST); + eel_register_enum(enum_aresample, "NEAREST4X", AR_NEAREST_4X); + eel_register_enum(enum_aresample, "LINEAR", AR_LINEAR); + eel_register_enum(enum_aresample, "LINEAR2X", AR_LINEAR_2X_R); + eel_register_enum(enum_aresample, "LINEAR4X", AR_LINEAR_4X_R); + eel_register_enum(enum_aresample, "LINEAR8X", AR_LINEAR_8X_R); + eel_register_enum(enum_aresample, "LINEAR16X", AR_LINEAR_16X_R); + eel_register_enum(enum_aresample, "CUBIC", AR_CUBIC_R); + + eel_register_enum(enum_aresample, "WORST", AR_WORST); + eel_register_enum(enum_aresample, "MEDIUM", AR_MEDIUM); + eel_register_enum(enum_aresample, "BEST", AR_BEST); + + /* Sample formats */ + enum_aformat = eel_register_enum_class(); + eel_register_enum(enum_aformat, "MONO8", AF_MONO8); + eel_register_enum(enum_aformat, "STEREO8", AF_STEREO8); + eel_register_enum(enum_aformat, "MONO16", AF_MONO16); + eel_register_enum(enum_aformat, "STEREO16", AF_STEREO16); + eel_register_enum(enum_aformat, "MONO32", AF_MONO32); + eel_register_enum(enum_aformat, "STEREO32", AF_STEREO32); + + /* Modulation targets */ + enum_amodtarget = eel_register_enum_class(); + eel_register_enum(enum_amodtarget, "AMPLITUDE", WCA_AMPLITUDE); + eel_register_enum(enum_amodtarget, "BALANCE", WCA_BALANCE); + eel_register_enum(enum_amodtarget, "FREQUENCY", WCA_FREQUENCY); + eel_register_enum(enum_amodtarget, "LIMIT", WCA_LIMIT); + eel_register_enum(enum_amodtarget, "MOD1", WCA_MOD1); + eel_register_enum(enum_amodtarget, "MOD2", WCA_MOD2); + eel_register_enum(enum_amodtarget, "MOD3", WCA_MOD3); + + /* Oscillator output modes */ + enum_amixmode = eel_register_enum_class(); + eel_register_enum(enum_amixmode, "ADD", WCA_ADD); + eel_register_enum(enum_amixmode, "MUL", WCA_MUL); + eel_register_enum(enum_amixmode, "FM", WCA_FM); + eel_register_enum(enum_amixmode, "FM_ADD", WCA_FM_ADD); + eel_register_enum(enum_amixmode, "SYNC", WCA_SYNC); + eel_register_enum(enum_amixmode, "SYNC_ADD", WCA_SYNC_ADD); + + /* Oscillator waveforms */ + enum_awaveform = eel_register_enum_class(); + eel_register_enum(enum_awaveform, "DC", WCA_DC); + eel_register_enum(enum_awaveform, "SINE", WCA_SINE); + eel_register_enum(enum_awaveform, "HALFSINE", WCA_HALFSINE); + eel_register_enum(enum_awaveform, "RECTSINE", WCA_RECTSINE); + eel_register_enum(enum_awaveform, "SINEMORPH", WCA_SINEMORPH); + eel_register_enum(enum_awaveform, "BLMORPH", WCA_BLMORPH); + eel_register_enum(enum_awaveform, "BLCROSS", WCA_BLCROSS); + eel_register_enum(enum_awaveform, "PULSE", WCA_PULSE); + eel_register_enum(enum_awaveform, "TRIANGLE", WCA_TRIANGLE); + eel_register_enum(enum_awaveform, "NOISE", WCA_NOISE); + eel_register_enum(enum_awaveform, "SPECTRUM", WCA_SPECTRUM); + eel_register_enum(enum_awaveform, "ASPECTRUM", WCA_ASPECTRUM); + eel_register_enum(enum_awaveform, "HSPECTRUM", WCA_HSPECTRUM); + eel_register_enum(enum_awaveform, "AHSPECTRUM", WCA_AHSPECTRUM); + + /* Filter types */ + enum_afiltertype = eel_register_enum_class(); + eel_register_enum(enum_afiltertype, "ALLPASS", WCA_ALLPASS); + eel_register_enum(enum_afiltertype, "LOWPASS_6", WCA_LOWPASS_6DB); + eel_register_enum(enum_afiltertype, "HIGHPASS_6", WCA_HIGHPASS_6DB); + eel_register_enum(enum_afiltertype, "LOWPASS_12", WCA_LOWPASS_12DB); + eel_register_enum(enum_afiltertype, "HIGHPASS_12", WCA_HIGHPASS_12DB); + eel_register_enum(enum_afiltertype, "BANDPASS_12", WCA_BANDPASS_12DB); + eel_register_enum(enum_afiltertype, "NOTCH_12", WCA_NOTCH_12DB); + eel_register_enum(enum_afiltertype, "PEAK_12", WCA_PEAK_12DB); + + /* Patch calls */ + eel_register_operator("p_param", op_p_param, 100, 0 ,0); + eel_register_operator("p_driver", op_p_driver, 100, 0 ,0); + + /* Patch Parameters */ + enum_pparam = eel_register_enum_class(); + eel_register_enum(enum_pparam, "DRIVER", APP_DRIVER); + eel_register_enum(enum_pparam, "WAVE", APP_WAVE); + eel_register_enum(enum_pparam, "RANDPITCH", APP_RANDPITCH); + eel_register_enum(enum_pparam, "RANDVOL", APP_RANDVOL); + + eel_register_enum(enum_pparam, "ENV_SKIP", APP_ENV_SKIP); + eel_register_enum(enum_pparam, "ENV_L0", APP_ENV_L0); + eel_register_enum(enum_pparam, "ENV_DELAY", APP_ENV_DELAY); + eel_register_enum(enum_pparam, "ENV_T1", APP_ENV_T1); + eel_register_enum(enum_pparam, "ENV_L1", APP_ENV_L1); + eel_register_enum(enum_pparam, "ENV_HOLD", APP_ENV_HOLD); + eel_register_enum(enum_pparam, "ENV_T2", APP_ENV_T2); + eel_register_enum(enum_pparam, "ENV_L2", APP_ENV_L2); + eel_register_enum(enum_pparam, "ENV_T3", APP_ENV_T3); + eel_register_enum(enum_pparam, "ENV_T4", APP_ENV_T4); + + /* Patch Drivers */ + enum_pdriver = eel_register_enum_class(); + eel_register_enum(enum_pdriver, "MONO", PD_MONO); + eel_register_enum(enum_pdriver, "POLY", PD_POLY); + eel_register_enum(enum_pdriver, "MIDI", PD_MIDI); + eel_register_enum(enum_pdriver, "EEL", PD_EEL); +} + + +/*---------------------------------------------------------- + API code +----------------------------------------------------------*/ + +static int _agw_initialized = 0; + + +int agw_open(void) +{ + if(_agw_initialized) + return 0; + + eel_open(); + + eel_push_scope(); /* begin AGW extensions scope */ + + load_keywords(); + + /* Built-in variables */ + (void)eel_set_integer("target", -1); + + _agw_initialized = 1; + return 0; +} + +void agw_close(void) +{ + if(!_agw_initialized) + return; + + eel_pop_scope(); /* end AGW extensions scope */ + + eel_close(); + + _agw_initialized = 0; +} + +#define CHECKINIT if(!_agw_initialized) agw_open(); + +int agw_load(int wid, const char *name) +{ + int script, res; + + CHECKINIT + + if(wid < 0) + { + wid = audio_wave_alloc(wid); + if(wid < 0) + return wid; + } + + script = eel_load(name); + if(script < 0) + return -1; + + eel_push_scope(); /* begin script scope */ + + /* Initialize "argument" variables */ + (void)eel_set_integer("target", wid); + + /* Reset the waveform construction engine */ + wca_reset(); + + res = eel_run(script); + eel_free(script); + + eel_pop_scope(); /* end script scope */ + + if(res < 0) + return -1; + + audio_wave_prepare(wid); + + return wid; +} diff --git a/sound/a_agw.h b/sound/a_agw.h new file mode 100644 index 0000000..26de07f --- /dev/null +++ b/sound/a_agw.h @@ -0,0 +1,359 @@ +/*(LGPL) +--------------------------------------------------------------------------- + a_agw.h - "Algorithmically Generated Waveform" file support +--------------------------------------------------------------------------- + * Copyright (C) 2002, 2003, David Olofson + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * The AGW v0.1 file format: + * + * This extension to the EEL language makes it possible + * to use EEL scripts to construct waveforms using the + * "Waveform Construction API" of the engine. + * + * Why!? + * Well, pages of hard-coded calls to the Waveform + * Construction API and recompiling for every turn + * while creating sounds got boring, so I decided to + * hack up something simple to get cleaner code and + * faster sound editing. + * + * Over a few weeks, the file format turned into an + * interpreted language, which I eventually cleaned up + * and separated from the engine. This language is + * called "EEL" - Extensible Embeddable Language, and + * is not tied to the audio engine. + * + * Built-in commands: + * // + * C++ style comment. + * + */ /* ... */ +/* C style comment. + * + * w_reset; + * Resets the AGW engine state to the default. + * This is done automatically before a script + * is executed after being loaded with w_load(). + * See below for default settings for w_env etc. + * + * w_format , , ; + * Set format of to ; + * samples per second. + * + * Supported sample formats: + * MONO8 STEREO8 + * MONO16 STEREO16 + * + * w_blank , , ; + * Create samples of silent data + * for waveform . can be either 0 + * or 1, and if it's 1, the waveform will be + * set up for looping playback. + * + * w_env [,