]> git.sesse.net Git - ccbs/commitdiff
Import TinyPTC 0.7.3 sources, switch from OpenGL to TinyPTC for now.
authorSteinar H. Gunderson <sesse@samfundet.no>
Sat, 19 Feb 2005 02:40:55 +0000 (02:40 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sat, 19 Feb 2005 02:40:55 +0000 (02:40 +0000)
30 files changed:
bigscreen/Makefile
bigscreen/ccbs_bigscreen.cpp
bigscreen/tinyptc/AUTHORS [new file with mode: 0644]
bigscreen/tinyptc/COPYING [new file with mode: 0644]
bigscreen/tinyptc/ChangeLog [new file with mode: 0644]
bigscreen/tinyptc/Makefile [new file with mode: 0644]
bigscreen/tinyptc/README [new file with mode: 0644]
bigscreen/tinyptc/TODO [new file with mode: 0644]
bigscreen/tinyptc/buildmmx.sh [new file with mode: 0755]
bigscreen/tinyptc/convert.c [new file with mode: 0644]
bigscreen/tinyptc/convert.h [new file with mode: 0644]
bigscreen/tinyptc/findused.sh [new file with mode: 0755]
bigscreen/tinyptc/mmx.h [new file with mode: 0644]
bigscreen/tinyptc/mmx.s [new file with mode: 0644]
bigscreen/tinyptc/python_test.py [new file with mode: 0644]
bigscreen/tinyptc/test.c [new file with mode: 0644]
bigscreen/tinyptc/tinyptc.h [new file with mode: 0644]
bigscreen/tinyptc/xdbe.c [new file with mode: 0644]
bigscreen/tinyptc/xdbe.h [new file with mode: 0644]
bigscreen/tinyptc/xdga1.c [new file with mode: 0644]
bigscreen/tinyptc/xdga1.h [new file with mode: 0644]
bigscreen/tinyptc/xdga2.c [new file with mode: 0644]
bigscreen/tinyptc/xdga2.h [new file with mode: 0644]
bigscreen/tinyptc/xlib.c [new file with mode: 0644]
bigscreen/tinyptc/xlib.h [new file with mode: 0644]
bigscreen/tinyptc/xshm.c [new file with mode: 0644]
bigscreen/tinyptc/xshm.h [new file with mode: 0644]
bigscreen/tinyptc/xvshm.c [new file with mode: 0644]
bigscreen/tinyptc/xvshm.h [new file with mode: 0644]
bigscreen/tinyptc/yv12.s [new file with mode: 0644]

index 07201d5cee973a266b0e8c57ba10e1ca519054db..24584ac6ac8890c18f73224f9b74d1e18d799a18 100644 (file)
@@ -1,17 +1,21 @@
 CC=gcc
 CXX=g++
-CPPFLAGS=-I/usr/include/postgresql $(shell freetype-config --cflags)
+CPPFLAGS=-I/usr/include/postgresql $(shell freetype-config --cflags) -Itinyptc/
 CXXFLAGS=-g -Wall
 LDFLAGS=-L/usr/X11R6/lib
-LIBS=-lGL -lX11 -lXext -lXxf86vm $(shell freetype-config --libs) $(shell libpq3-config) -lpqxx
+LIBS=-lGL -lX11 -lXext -lXxf86vm $(shell freetype-config --libs) $(shell libpq3-config) -lpqxx tinyptc/libtinyptc.a
 CCBS_BIGSCREEN_OBJS=ccbs_bigscreen.o glwindow.o
 
 all: ccbs-bigscreen
 
-ccbs-bigscreen: $(CCBS_BIGSCREEN_OBJS)
+tinyptc/libtinyptc.a:
+       $(MAKE) -C tinyptc
+
+ccbs-bigscreen: $(CCBS_BIGSCREEN_OBJS) tinyptc/libtinyptc.a
        $(CXX) -o ccbs-bigscreen $(CCBS_BIGSCREEN_OBJS) $(LDFLAGS) $(LIBS)
 
 clean:
        $(RM) $(CCBS_BIGSCREEN_OBJS) ccbs-bigscreen
+       $(MAKE) -C tinyptc clean
 
 .PHONY: clean
index 5df9dcdc989ec6defcdc0d4f0f61a710f49adf4a..684f423777db0214390df3ae07634984ad3de814 100644 (file)
@@ -5,8 +5,7 @@
 #include <pqxx/pqxx>
 #include <ft2build.h>
 #include FT_FREETYPE_H
-
-#include "glwindow.h"
+#include <tinyptc.h>
 
 iconv_t ucs4_iconv;
 
@@ -182,7 +181,7 @@ int main(int argc, char **argv)
 {
        ucs4_iconv = iconv_open("ucs-4", "utf-8");
        
-       GLWindow glw("CCBS bigscreen", 800, 600, 32, false, 16, -1);
+       ptc_open("CCBS bigscreen", 800, 600);
        
        try {
                init_freetype();
diff --git a/bigscreen/tinyptc/AUTHORS b/bigscreen/tinyptc/AUTHORS
new file mode 100644 (file)
index 0000000..9943172
--- /dev/null
@@ -0,0 +1,3 @@
+X11 version done by Alessandro Gatti <a.gatti@tiscali.it>
+XVideo/XSHM target written by Fred Howell <foohoo@shaw.ca>
+Original windows version done by Glenn Fiedler <gaffer@gaffer.org>
diff --git a/bigscreen/tinyptc/COPYING b/bigscreen/tinyptc/COPYING
new file mode 100644 (file)
index 0000000..223ede7
--- /dev/null
@@ -0,0 +1,504 @@
+                 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.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                           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.
+\f
+  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.
+\f
+                 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.
+\f
+  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.
+\f
+  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.
+\f
+  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.
+\f
+  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.
+\f
+  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.
+\f
+  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
+\f
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  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.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library 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 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/bigscreen/tinyptc/ChangeLog b/bigscreen/tinyptc/ChangeLog
new file mode 100644 (file)
index 0000000..18d71ea
--- /dev/null
@@ -0,0 +1,136 @@
+TinyPTC x11 ChangeLog + Bug(Fixes) list.
+
+*** Note ***
+
+English isn't my native language. So, some grammar/spelling errors might have
+made their way into this document. You've been warned.
+
+Alessandro Gatti <a.gatti@tiscali.it>
+
+*** **** ***
+
+20021208 0.7.3
+
+Fixed a typo in the python source and updated the documentation.
+
+20021207 0.7.2
+
+The perl script for the assembler include generation was replaced with a
+plain shell script in order to overcome the remote possibility of perl
+not being installed on the system TinyPTC gets built on. Now TinyPTC can
+be built as a python extension by using the excellent SWIG package, just
+use the 'python' target of the makefile and look at python_test.py.
+
+20020706 0.7.1
+
+Kevin Nickels (knickels@users.sourceforge.net) sent a patch for the BGR888
+converter that fixes the colour order on little endian platforms in the xlib
+target. A minor error in the documentation has been corrected, and the MMX
+assembly include file builder perl script has been slightly cleaned up.
+
+20020517 0.7
+
+Fred Howell wrote the XVideo target handling code and was kind enough to send
+it in order to have that included in the major next release of TinyPTC/x11. It
+has been tested both on NVidia-based cards with their binary-only drivers, on
+ATI-based cards, and with Matrox-based ones, all of them under XFree 4.x. The
+XVideo target features realtime scaling on the windowed output (fullscreen
+support will be added on a later stage...), with a lightning fast MMX converter
+from RGB to YV12. Make sure to check it out!
+
+20011103 0.6.1
+
+Version 0.6.0 was entirely done during one long coding night, so a few bugs
+were present. Anyway, I made the C functions callable by C++ as well (tested
+with g++), the example configuration file now has some enabled #defines that
+let the example work flawlessly (otherwise it won't run if you haven't got
+low-res modes defined in your X configuration. I've got them in, that's why I
+didn't notice that...). Then, g++ complained on a few targets for some
+duplicated variable definition. That's funny, gcc didn't complain. By the way,
+I also tested the whole package with GCC 3.0.1, and it works fine. So, this is
+mostly a "cleaned up" version.
+
+20011102 0.6.0
+
+After nine months, I found the time to work again on TinyPTC/X11. Big changes
+this time... First of all, now TinyPTC/X11 is released under the LGPL license,
+then I (finally) added DGA 2.0 support, although its heuristic stuff for best
+videodepth choice isn't tested at all, since my hardware supports 32bpp
+natively (if it doesn't work, please tell me, so I can attempt to fix the
+problem). Then, I splitted all the various targets in a source/header pair of
+their own, in order to improve manteniability and easy new targets addition.
+Currently you compile and link all the various targets even if you use only
+one of them but don't worry, because with some kind of #define magic and a fair
+job done by strip, the executable size won't grow at all. The makefile has been
+reworked in order to use automated dependencies and for generate automatically
+the NASM includefile for mmx.s from mmx.h. Then, I had to change a variable
+name in the supplied example due to clashes with a function with the same name.
+Oh, I also added DBE support, if you need it. Of course the documentation has
+been updated and the makefile now creates a static library called libtinyptc.a
+that can be included in your own programs without having to recompile tinyptc
+all the time. Have fun!.
+
+20010206 0.5.1
+
+The makefile now contains a different optimization flag, now the executable is
+a bit smaller (at least on my box). I updated the documentation, too (I forgot
+to add the __PTC_MEMCPY__ #define). Added a cleanup callback function, in order
+to let it be a bit more programmer-friendly. Now you can use PTC_SUCCESS and
+PTC_FAILURE in order to check the results of the TinyPTC functions you call.
+Documentation now contains NetBSD compilation workaround.
+
+20001027 0.5
+
+The mmx converters were added and the makefile was cleaned up in order to be
+a bit more flexible and to support the external assembler code. I left out a
+debug fprintf somewhere in the DGA code, now it's just history. The
+documentation was updated, too. Nothing more to say, over and out.
+
+20001306 0.4
+
+Bugs are calling... And we're supposed to fix them. There was a glitch in the
+32bpp->15bpp conversion code, thanks to tolemaC/Elerium Core for the bug
+report. Now the 24bpp conversion modules should work for big-endian machines as
+well. Try them if you've got such a system and then tell us.
+
+20000531 0.3.1
+
+Sometimes, fixing a bug, brings another one in. Well, now the only thing that
+worked was the 32bpp code. Strange, isn't it ? ;) Anyway, this is fixed now.
+
+20000527 0.3
+
+TinyPTC was developed again after a little pause. Great news this time... I
+added color conversion and it seems to work quite well, too. It's rather slow
+but I think that some compiler optimizations can speed it up a bit as well. If
+it's still too slow for you, feel free to write your own converters and submit
+them to Gaffer =) As an added bonus, the 24-32 bpp dilemma seems to be
+disappeared... Maybe it's fixed, try and see. Tell me if there's something that
+doesn't work.
+
+20000508 0.2
+
+TinyPTC was rewritten from scratch (literally), now the sources are easier to
+read and I threw some comment in, too. The XShm support is finished and seems
+to work. Tell me if I'm wrong about that. The DGA part wasn't working properly,
+it blarfed on the fullscreen-emulation blit code, now it works again. I also
+added a 'best-fit' videomode switch logic for fullscreen-emulation code.
+
+20000505 0.1.1
+
+Some kind of preliminary XShm support is now included. There wasn't an UID
+check for DGA mode (it needs Root access in order to access video memory
+directly). I forgot to include it when I joined the two x11 sourcetrees
+together (windowed and DGA). The bitdepth is incorrectly reported as 24 even on
+32bpp servers. Strangely enough, my server correctly reports 32bpp.
+The pitch value calculation method is wrong. On some cards the assumption 
+pitch=width*bpp isn't true (TNT cards for example but not Banshees). Damn, I'm 
+so lame... =) I was calculating it with the logical screenwidth of the 
+resulting viewport instead of calculating it with the physical screenwidth 
+returned in the videomode info.        The makefile was modified in order to include a
+check to "tinyptc.h" during the 'make' operation. 
+
+20000503 0.1
+
+Initial release. Supports X11 Windowed and X11 DGA access. No color 
+conversions, just a bare bones emulation of the windows version.
diff --git a/bigscreen/tinyptc/Makefile b/bigscreen/tinyptc/Makefile
new file mode 100644 (file)
index 0000000..754faf3
--- /dev/null
@@ -0,0 +1,90 @@
+# TinyPTC x11 v0.7.3 Makefile
+# Copyright (C) 2000-2002 Alessandro Gatti <a.gatti@tiscali.it>
+#
+# http://www.sourceforge.net/projects/tinyptc/
+#
+# This library 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 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+CFLAGS      = -Wall -Wno-unknown-pragmas -Os
+CC          = gcc
+CPP         = cpp
+SH          = /bin/sh
+LFLAGS     = -s
+LD          = gcc
+AFLAGS      = -f elf
+AS          = nasm
+AR          = ar
+RANLIB      = ranlib
+STRIP      = strip
+SWIG        = swig
+RM          = /bin/rm -f
+INCLUDES    = -I/usr/X11R6/include -I/usr/local/include -I/usr/include
+LIBS        = -L/usr/X11R6/lib -L/usr/lib -L/usr/local/lib -lX11 -lXext \
+       -lXxf86dga -lXxf86vm -lXv
+CSOURCES    = test.c
+CTARGETS    = xlib.c xdbe.c xshm.c convert.c xdga1.c xdga2.c xvshm.c
+ASOURCES    = mmx.s yv12.s
+OTARGETS    = $(CTARGETS:.c=.o)
+COBJECTS    = $(CSOURCES:.c=.o)
+AOBJECTS    = $(ASOURCES:.s=.o)
+EXECUTABLE  = tinyptc_test
+LIBRARY     = libtinyptc.a
+
+# Feel free to change this.
+PYTHON_VERSION = 2.2
+
+$(EXECUTABLE): $(OTARGETS) $(COBJECTS) $(LIBRARY)
+       $(LD) $(LDFLAGS) $(OTARGETS) $(COBJECTS) $(AOBJECTS) $(LIBS) -o $(EXECUTABLE)
+       $(STRIP) --strip-all $(EXECUTABLE)
+       $(STRIP) --remove-section=".comment" $(EXECUTABLE)
+       $(STRIP) --remove-section=".note" $(EXECUTABLE)
+
+$(LIBRARY): $(OTARGETS) $(AOBJECTS)
+       $(AR) cru $(LIBRARY) $(OTARGETS) $(AOBJECTS)
+       $(RANLIB) $(LIBRARY)
+
+%.o: %.c
+       $(CC) $(CFLAGS) $(INCLUDES) -c $<
+
+# Unfortunately makedepend doesn't work for assembly files...
+
+mmx.i: mmx.h
+       $(CPP) $(INCLUDES) mmx.h | $(SH) buildmmx.sh > mmx.i
+
+mmx.o: mmx.s mmx.i
+       $(AS) $(AFLAGS) mmx.s
+
+yv12.o: yv12.s
+       $(AS) $(AFLAGS) yv12.s
+
+python: $(LIBRARY)
+       $(RM) ptctarget.o
+       $(CPP) $(INCLUDES) tinyptc.h | $(SH) findused.sh
+       $(SWIG) -python tinyptc.h
+       $(CC) -c tinyptc_wrap.c -I/usr/include/python$(PYTHON_VERSION) \
+       -I/usr/local/include/python$(PYTHON_VERSION) $(INCLUDES)
+       $(CC) -shared $(LIBS) $(LIBRARY) convert.o ptctarget.o tinyptc_wrap.o \
+       -o _TinyPTC.so
+
+.depend:
+       $(RM) .depend 2> /dev/null
+       makedepend -f- -- $(INCLUDES) $(CFLAGS) $(CSOURCES) > .depend 2> /dev/null
+
+clean:
+       $(RM) $(EXECUTABLE) $(LIBRARY) $(OTARGETS) $(COBJECTS) $(AOBJECTS)
+       $(RM) ptctarget.o .depend mmx.i tinyptc_wrap.[co] TinyPTC.py*
+       $(RM) _TinyPTC.so
+
+include .depend
diff --git a/bigscreen/tinyptc/README b/bigscreen/tinyptc/README
new file mode 100644 (file)
index 0000000..9267eef
--- /dev/null
@@ -0,0 +1,303 @@
+                 TinyPTC/x11 0.7.3 Readme file
+
+-------------------------------------------------------------------------------
+
+This library 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 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+-------------------------------------------------------------------------------                                 
+
+This is the only documentation you can find in this package because the
+library is pretty straightforward to use. So, here it goes:
+
+   Index:
+
+  * What is TinyPTC
+  * What TinyPTC has to offer
+  * How tiny is TinyPTC
+  * TinyPTC's usage
+  * How to compile TinyPTC
+  * DGA considerations
+  * XVideo considerations
+  * Python extension
+  * How to contact the authors
+  * Where the latest version can be found
+
+* What is TinyPTC
+
+TinyPTC is a reduced subset of OpenPTC, made exclusively with size
+optimizations in mind. TinyPTC is a somehow "low-level" graphics library
+that runs on top of XLib, providing only a few functionalities you may
+need when working with framebuffer devices.
+
+* What TinyPTC has to offer
+
+TinyPTC will simplify your programs that are using X11 to output
+graphics. It does all the grunt work for you, so your life will be easier :)
+
+Actually TinyPTC features:
+
+- Automatic display management
+  * XLib, DBE, XVideo, and Mit-Shm window management
+  * DGA 1.x support, including videomode switch and fullscreen emulation
+  * DGA 2.x support, including videomode/videodepth switch and fullscreen
+    emulation.
+
+- Automatic color conversion
+  * Detects and converts the internal 32bpp ARGB buffer to 15, 16 and
+    24 bpp modes, both RGB and BGR. Two versions are supplied, one featuring
+    MMX conversions and one that doesn't.
+
+- Automatic event management
+  * It automatically quits when the ESC key is pressed or the window
+    is closed by the user.
+
+* How tiny is TinyPTC
+
+TinyPTC is rather small by itself, actually I can give you some
+information about the test program supplied with the library.
+
+(I'm talking about UNPACKED executables, once they've been stripped)
+
+Raw XLib                                      7388 bytes
+Raw XLib+Color conversion                     7580 bytes (*)
+Mit-Shm                                       8252 bytes
+Mit-Shm+Color conversion                      8421 bytes (*)
+DBE                                           8380 bytes
+DBE+Color conversion                          8604 bytes (*)
+DGA 1.x                                      20860 bytes (**)
+DGA 1.x+Best Videomode                       21084 bytes (**)
+DGA 1.x+Color conversion                     20924 bytes (*) (**)
+DGA 1.x+Color conversion+Best Videomode      21404 bytes (*) (**)
+DGA 2.x                                       8028 bytes
+DGA 2.x+Best Videomode                        8220 bytes
+DGA 2.x+Color conversion                      8252 bytes (*)
+DGA 2.x+Color conversion+Best Videomode       9244 bytes (*)
+XVideo+Mit-Shm                               22352 bytes
+XVideo+Mit-Shm+MMX conversion                19152 bytes
+
+The executables were stripped with:
+
+strip --strip-all ./executable
+strip --remove-section=".comment" ./executable
+strip --remove-section=".note" ./executable
+
+[By the way, a better "strip" does exist, it's called "sstrip". It was
+programmed by Brian Raiter, and on his site you can find further information
+about tricks you can use in order to reduce your programs' size and so on.
+Brian Raiter's page is http://www.muppetlabs.com/~breadbox/software/tiny/]
+
+(*) The color conversion modules were included all at once, you will
+    get a smaller executable if you include only the ones you need.
+
+(**) The DGA 1.x executables are so big because the library that manages
+     DGA+Videomode switch extensions is linked statically. If you look
+     at the object file you get from x11.c you'll notice the absence
+     of all those control strings like "Video memory protecting" and
+     such. I tried to link the library dynamically but the
+     executables were bigger due to the library loading code being
+     added. Hopefully with DGA 2.x those two libraries are dynamically linked.
+
+If you pack them with UPX 1.2 (or better) you'll get a 10%-50% size reduction,
+at least on my box... (I'm talking about the supplied example, of course).
+
+UPX can be found at: http://upx.sf.net
+SStrip can be found at: 
+                  http://www.muppetlabs.com/~breadbox/software/elfkickers.html
+
+* TinyPTC's usage
+
+TinyPTC exports just three functions you can use:
+
+  *   int ptc_open(char *title, int width, int height);
+  *   int ptc_update(void *buffer);
+  *   void ptc_close(void);
+
+ (It can't get any simpler, can it?)
+
+ - ptc_open(char *title, int width, int height)
+
+   ptc_open() either opens the window that your application needs for blitting
+   data on the screen or it will go fullscreen. It accepts a title for the
+   window that will be created (that title will be discarded for fullscreen
+   mode) and the window size. For fullscreen mode, TinyPTC will try to find a
+   suitable videomode first, and it will emulate a fullscreen mode if it didn't
+   find any (you'll see your application's output in the middle of the screen).
+   If you enabled best-videomode-choice at compile time, the library will set
+   the best videmode that fits the supplied window size. It will return
+   PTC_FAILURE if it fails, otherwise it will return PTC_SUCCESS.
+
+ - ptc_update(void *buffer)
+
+   ptc_update() does a mere blitting of your buffer onto the screen. If
+   automatic color conversion was enabled it will do the conversion for you. It
+   will return PTC_SUCCESS if the buffer was blitted and nothing else happened,
+   else it will return PTC_FAILURE.
+
+ - ptc_close(void)
+
+   ptc_close() closes the window the library created. If it is in fullscreen
+   mode, it will switch back to normal videomode. ptc_close() is called
+   automatically when the user presses ESC or closes manually the window.
+
+Plus, there is an optional callback function that gets called when TinyPTC is
+about to shut itself down, called ptc_cleanup_callback, that you must supply if
+you are going to use that callback option. Its prototype is:
+
+  *   void ptc_cleanup_callback(void);
+
+* How to compile TinyPTC
+
+First of all, Laurent Mascherpa (laurent.mascherpa@epita.fr) managed to compile
+TinyPTC with the mmx converters under NetBSD. As he told me, NetBSD uses a
+slightly different a.out object format, so the files generated by nasm are
+useless. Anyway, the workaround consists in modifying the AFLAGS variable in
+the makefile:
+
+  From:
+
+         AFLAGS = -f elf
+
+  to:
+
+         AFLAGS = -f aoutb --PREFIX _
+
+(Next time I'm going to add some sort of "autoconf"-like scripts ;))
+Please note that you'll also get a static library called libtinyptc.a, ready to
+be included in your own programs...
+
+TinyPTC's behaviour can be set with a few #define lines in the include files.
+Here's a list:
+
+ - Callback usage
+
+    __PTC_CLEANUP_CALLBACK__
+
+   Enables the use of an user-supplied callback function that is called on
+   application's exit.
+
+ - MMX usage
+
+    __PTC_MMX__
+
+   Enables the use of MMX code.
+
+ - 32 bpp blit type
+
+    __PTC_MEMCPY__
+
+   If this is defined, a single memcpy() call will be used to blit the buffer
+   (Only for 32bpp RGB modes only).
+
+ - Color conversion modules
+
+    __PTC_CONVERTER_32_TO_32_RGB888
+    __PTC_CONVERTER_32_TO_32_BGR888
+    __PTC_CONVERTER_32_TO_24_RGB888
+    __PTC_CONVERTER_32_TO_24_BGR888
+    __PTC_CONVERTER_32_TO_16_RGB565
+    __PTC_CONVERTER_32_TO_16_BGR565
+    __PTC_CONVERTER_32_TO_16_RGB555
+    __PTC_CONVERTER_32_TO_16_BGR555
+
+    __PTC_MMX_CONVERT_32_TO_32_BGR888
+    __PTC_MMX_CONVERT_32_TO_32_RGB888
+    __PTC_MMX_CONVERT_32_TO_24_BGR888
+    __PTC_MMX_CONVERT_32_TO_24_RGB888
+    __PTC_MMX_CONVERT_32_TO_16_BGR565
+    __PTC_MMX_CONVERT_32_TO_16_RGB565
+    __PTC_MMX_CONVERT_32_TO_16_BGR555
+    __PTC_MMX_CONVERT_32_TO_16_RGB555
+
+   Those #define lines, if added, enable the described color conversion module.
+   Please note that you can't just enable an MMX converter without enabling the
+   standard converter as well. It doesn't hurt performance or size because the 
+   standard code isn't added if there is an MMX version avaliable.
+
+ - Output targets
+
+   The output target can be chosen by defining one of these #defines in
+   tinyptc.h:
+   
+   __PTC_XLIB__       * This is the raw XLib target.
+   __PTC_XSHM__       * This is the Mit-Shm target.
+   __PTC_XDBE__       * This is the X DBE target.
+   __PTC_XDGA1__      * This is the X DGA 1.x target.
+   __PTC_XDGA2__      * This is the X DGA 2.x target.
+   __PTC_XVSHM__      * This is the XVideo+Mit-Shm target.
+
+ - Extra behaviour definitions
+
+   __PTC_ENABLE_CONVERSIONS__
+
+   If it's enabled, it activates the automatic color conversion. If you will
+   run an executable that doesn't have the conversions in on a non-32bpp
+   display, it will silently quit. Ignored for the XVideo+Mit-Shm target.
+
+   __PTC_BEST_VIDEOMODE__
+
+   Enables the best-fit videomode switching for the requested window size. This
+   works only for fullscreen executables.
+
+ - Endianness considerations
+
+   __PTC_LITTLE_ENDIAN__
+
+   Selects the right converter for 24bpp and 32bpp conversion code. Pretty
+   useless if you don't plan to support those videomodes or little endian
+   architectures. It has not been tested extensively, so don't assume it's
+   100% working. Ignored for the XVideo+Mit-Shm target.
+
+* DGA considerations
+
+Although TinyPTC is fairly portable, the DGA mode is a XFree86-only extension
+to the X Windowing system. So if you try to compile the fullscreen support on
+a non-i386 machine it will complain. Anyway, Mit-Shm and DBE are portable as
+far as I know, so is "raw" XLib mode. Please note that you will need either be
+root in order to run fullscreen-enabled applications or set the executable as
+suid root.
+
+* XVideo considerations
+
+The XVideo support has been tested on NVidia (with binary-only drivers), ATI,
+and Matrox cards under XFree 4.x. It's totally untested on S3 Savage-based
+cards. If you happen to have such a card and want to test it out, tell us! =)
+
+* Python extension
+
+Since version 0.7.2, a python extension can be built out of TinyPTC. In order
+to get that you've got to use the python target in the makefile and copy the
+_TinyPTC.so file whereever is appropriate for your program. The python API
+replicates almost entirely the C/C++ one except for pointer management. You
+have to use the provided TinyPTC.pixel_array method to allocate the buffers
+you'll pass to TinyPTC.ptc_update. The objects returned by TinyPTC.pixel_array
+act almost like normal python arrays. In case of doubt, take a look at the
+supplied python_test.py file.
+
+Note that you need SWIG 1.3 or newer to generate the wrapper code.
+
+* How to contact the authors
+
+Alessandro Gatti (Rigel) can be reached at a.gatti@tiscali.it
+Fred Howell (Fred) can be reached at foohoo@shaw.ca
+Glenn Fiedler (Gaffer) can be reached at gaffer@gaffer.org
+
+Please send all bug-reports, ideas, fixes, additions, and so on. Don't be
+shy =).
+
+* Where the latest version can be found
+
+The latest version of the x11 and SDL versions is now hosted on sourceforge at
+the following URL: http://www.sourceforge.net/projects/tinyptc/. The main page
+still remains http://www.gaffer.org/tinyptc.
diff --git a/bigscreen/tinyptc/TODO b/bigscreen/tinyptc/TODO
new file mode 100644 (file)
index 0000000..0f34a85
--- /dev/null
@@ -0,0 +1,4 @@
+* Add 8 Bit conversion modules.
+* Try to implement fullscreen emulation if DGA is not avaliable.
+* Add Fullscreen XVideo target.
+* Clean up the XDga2 target.
diff --git a/bigscreen/tinyptc/buildmmx.sh b/bigscreen/tinyptc/buildmmx.sh
new file mode 100755 (executable)
index 0000000..24344ca
--- /dev/null
@@ -0,0 +1,73 @@
+#! /bin/sh
+
+# TinyPTC x11 v0.7.3 MMX-Optimized pixelformat converters include generator
+# Copyright (C) 2001-2002 Alessandro Gatti <a.gatti@tiscali.it>
+#
+# http://www.sourceforge.net/projects/tinyptc/
+#
+# This library 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 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+cat << EOF
+
+;
+; TinyPTC x11 v0.7.3 MMX-optimized pixelformat converters
+; Copyright (C) 2001-2002 Alessandro Gatti <a.gatti@tiscali.it>
+; Copyright (C) 2001 Glenn Fiedler <gaffer@gaffer.org>
+;
+; http://www.sourceforge.net/projects/tinyptc/
+;
+; This library 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 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
+; Lesser General Public License for more details.
+;
+; You should have received a copy of the GNU Lesser General Public
+; License along with this library; if not, write to the Free Software
+; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+; 02111-1307 USA
+;
+
+;
+; Do not change this file, it is automatically generated.
+; Modify mmx.h instead and then recreate this file.
+;
+
+EOF
+
+# Is this portable?
+lines=`grep -i "^ *void *mmx_" - | expand | sed -e 's/^ *void *//g' | sed -e 's/ *(.*//'`
+
+for line in $lines
+do
+       case $line in
+               mmx_memcpy) echo "%define __PTC_MMX__";;
+               mmx_convert_32_to_32_bgr888) echo "%define __PTC_MMX_CONVERT_32_TO_32_BGR888";;
+               mmx_convert_32_to_32_rgb888) echo "%define __PTC_MMX_CONVERT_32_TO_32_RGB888";;
+               mmx_convert_32_to_24_bgr888) echo "%define __PTC_MMX_CONVERT_32_TO_24_BGR888";;
+               mmx_convert_32_to_24_rgb888) echo "%define __PTC_MMX_CONVERT_32_TO_24_RGB888";;
+               mmx_convert_32_to_16_bgr565) echo "%define __PTC_MMX_CONVERT_32_TO_16_BGR565";;
+               mmx_convert_32_to_16_rgb565) echo "%define __PTC_MMX_CONVERT_32_TO_16_RGB565";;
+               mmx_convert_32_to_16_bgr555) echo "%define __PTC_MMX_CONVERT_32_TO_16_BGR555";;
+               mmx_convert_32_to_16_rgb555) echo "%define __PTC_MMX_CONVERT_32_TO_16_RGB555";;
+       esac
+done
+
+echo 
+echo "; *** end ***"
diff --git a/bigscreen/tinyptc/convert.c b/bigscreen/tinyptc/convert.c
new file mode 100644 (file)
index 0000000..8ea7a35
--- /dev/null
@@ -0,0 +1,267 @@
+/*
+ * TinyPTC x11 v0.7.3 Pixelformat converters
+ * Copyright (C) 2000-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ * Copyright (C) 2000-2001 Glenn Fiedler <gaffer@gaffer.org>
+ *
+ * http://www.sourceforge.net/projects/tinyptc/
+ *
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * 
+ */
+
+#include "convert.h"
+#include "mmx.h"
+#include <string.h>
+
+#ifdef __PTC_CONVERTER_32_TO_32_RGB888
+void
+ptc_convert_32_to_32_rgb888 (void *src, void *dst, int pixels)
+{
+#ifdef __PTC_MMX__
+  mmx_memcpy (dst, src, pixels * 4);
+#else
+#ifdef __PTC_MEMCPY__
+  memcpy (dst, src, pixels * 4);
+#else
+  int32 *p = (int32 *) src;
+  int32 *q = (int32 *) dst;
+  while (pixels--)
+    {
+      *(q++) = *(p++);
+    }
+#endif /* __PTC_MEMCPY__ */
+#endif /* __PTC_MMX__ */
+}
+#endif /* __PTC_CONVERTER_32_TO_32_RGB888 */
+
+#ifdef __PTC_CONVERTER_32_TO_32_BGR888
+void
+ptc_convert_32_to_32_bgr888 (void *src, void *dst, int pixels)
+{
+  int32 *p = (int32 *) src;
+  int32 *q = (int32 *) dst;
+  while (pixels--)
+    {
+#ifdef __PTC_LITTLE_ENDIAN__
+      int32 r = (int32) ((*p & 0x00FF0000) << 8);
+      int32 g = (int32) ((*p & 0x0000FF00) << 8);
+      int32 b = (int32) ((*p & 0x000000FF) << 8);
+#else
+      int32 r = (int32) ((*p & 0x00FF0000) >> 16);
+      int32 g = (int32) ((*p & 0x0000FF00));
+      int32 b = (int32) ((*p & 0x000000FF) << 16);
+#endif /* __PTC_LITTLE_ENDIAN__ */
+      *(q++) = r | g | b;
+      p++;
+    }
+}
+#endif /* __PTC_CONVERTER_32_TO_32_BGR888 */
+
+#ifdef __PTC_CONVERTER_32_TO_24_RGB888
+void
+ptc_convert_32_to_24_rgb888 (void *src, void *dst, int pixels)
+{
+#ifdef __PTC_MMX__
+  mmx_convert_32_to_24_rgb888 (dst, src, pixels);
+#else
+  char8 *p = (char8 *) src;
+  char8 *q = (char8 *) dst;
+  while (pixels--)
+    {
+#ifdef __PTC_LITTLE_ENDIAN__
+      *q = *p;
+      *(q + 1) = *(p + 1);
+      *(q + 2) = *(p + 2);
+#else
+      *(q + 2) = *p;
+      *(q + 1) = *(p + 1);
+      *q = *(p + 2);
+#endif /* __PTC_LITTLE_ENDIAN__ */
+      p += 4;
+      q += 3;
+    }
+#endif /* __PTC_MMX__ */
+}
+#endif /* __PTC_CONVERTER_32_TO_24_RGB888 */
+
+#ifdef __PTC_CONVERTER_32_TO_24_BGR888
+void
+ptc_convert_32_to_24_bgr888 (void *src, void *dst, int pixels)
+{
+#ifdef __PTC_MMX__
+  mmx_convert_32_to_24_bgr888 (dst, src, pixels);
+#else
+  char8 *p = (char8 *) src;
+  char8 *q = (char8 *) dst;
+  while (pixels--)
+    {
+#ifdef __PTC_LITTLE_ENDIAN__
+      *(q + 2) = *p;
+      *(q + 1) = *(p + 1);
+      *q = *(p + 2);
+#else
+      *q = *p;
+      *(q + 1) = *(p + 1);
+      *(q + 2) = *(p + 2);
+#endif /* __PTC_LITTLE_ENDIAN__ */
+      p += 4;
+      q += 3;
+    }
+#endif /* __PTC_MMX__ */
+}
+#endif /* __PTC_CONVERTER_32_TO_24_BGR888 */
+
+#ifdef __PTC_CONVERTER_32_TO_16_RGB565
+void
+ptc_convert_32_to_16_rgb565 (void *src, void *dst, int pixels)
+{
+#ifdef __PTC_MMX__
+  mmx_convert_32_to_16_rgb565 (dst, src, pixels);
+#else
+  int32 *p = (int32 *) src;
+  short16 *q = (short16 *) dst;
+  while (pixels--)
+    {
+      short16 r = (short16) ((*p & 0x00F80000) >> 8);
+      short16 g = (short16) ((*p & 0x0000FC00) >> 5);
+      short16 b = (short16) ((*p & 0x000000F8) >> 3);
+      *q = r | g | b;
+      p++;
+      q++;
+    }
+#endif /* __PTC_MMX__ */
+}
+#endif /* __PTC_CONVERTER_32_TO_16_RGB565 */
+
+#ifdef __PTC_CONVERTER_32_TO_16_BGR565
+void
+ptc_convert_32_to_16_bgr565 (void *src, void *dst, int pixels)
+{
+#ifdef __PTC_MMX__
+  mmx_convert_32_to_16_bgr565 (dst, src, pixels);
+#else
+  int32 *p = (int32 *) src;
+  short16 *q = (short16 *) dst;
+  while (pixels--)
+    {
+      short16 r = (short16) ((*p & 0x00F80000) >> 19);
+      short16 g = (short16) ((*p & 0x0000FC00) >> 5);
+      short16 b = (short16) ((*p & 0x000000F8) << 8);
+      *q = r | g | b;
+      p++;
+      q++;
+    }
+#endif /* __PTC_MMX__ */
+}
+#endif /* __PTC_CONVERTER_32_TO_16_RGB565 */
+
+#ifdef __PTC_CONVERTER_32_TO_16_RGB555
+void
+ptc_convert_32_to_16_rgb555 (void *src, void *dst, int pixels)
+{
+#ifdef __PTC_MMX__
+  mmx_convert_32_to_16_rgb555 (dst, src, pixels);
+#else
+  int32 *p = (int32 *) src;
+  short16 *q = (short16 *) dst;
+  while (pixels--)
+    {
+      short16 r = (short16) ((*p & 0x00F80000) >> 9);
+      short16 g = (short16) ((*p & 0x0000F800) >> 6);
+      short16 b = (short16) ((*p & 0x000000F8) >> 3);
+      *q = r | g | b;
+      p++;
+      q++;
+    }
+#endif /* __PTC_MMX__ */
+}
+#endif /* __PTC_CONVERTER_32_TO_16_RGB555 */
+
+#ifdef __PTC_CONVERTER_32_TO_16_BGR555
+void
+ptc_convert_32_to_16_bgr555 (void *src, void *dst, int pixels)
+{
+#ifdef __PTC_MMX__
+  mmx_convert_32_to_16_bgr555 (dst, src, pixels);
+#else
+  int32 *p = (int32 *) src;
+  short16 *q = (short16 *) dst;
+  while (pixels--)
+    {
+      short16 r = (short16) ((*p & 0x00F80000) >> 20);
+      short16 g = (short16) ((*p & 0x0000F800) >> 6);
+      short16 b = (short16) ((*p & 0x000000F8) << 8);
+      *q = r | g | b;
+      p++;
+      q++;
+    }
+#endif /* __PTC_MMX__ */
+}
+#endif /* __PTC_CONVERTER_32_TO_16_BGR555 */
+
+PTC_CONVERTER
+ptc_request_converter (int bits, int32 r, int32 g, int32 b)
+{
+  /* 32bit RGB888 -> 32bit RGB888 */
+#ifdef __PTC_CONVERTER_32_TO_32_RGB888
+  if (bits == 32 && r == 0x00FF0000 && g == 0x0000FF00 && b == 0x000000FF)
+    return &ptc_convert_32_to_32_rgb888;
+#endif
+
+  /* 32bit RGB888 -> 32bit BGR888 */
+#ifdef __PTC_CONVERTER_32_TO_32_BGR888
+  if (bits == 32 && r == 0x000000FF && g == 0x0000FF00 && b == 0x00FF0000)
+    return &ptc_convert_32_to_32_bgr888;
+#endif
+
+  /* 32bit RGB888 -> 24bit RGB888 */
+#ifdef __PTC_CONVERTER_32_TO_24_RGB888
+  if (bits == 24 && r == 0x00FF0000 && g == 0x0000FF00 && b == 0x000000FF)
+    return &ptc_convert_32_to_24_rgb888;
+#endif
+
+  /* 32bit RGB888 -> 24bit BGR888 */
+#ifdef __PTC_CONVERTER_32_TO_24_BGR888
+  if (bits == 24 && r == 0x000000FF && g == 0x0000FF00 && b == 0x00FF0000)
+    return &ptc_convert_32_to_24_bgr888;
+#endif
+
+  /* 32bit RGB888 -> 16bit RGB565 */
+#ifdef __PTC_CONVERTER_32_TO_16_RGB565
+  if (bits == 16 && r == 0xF800 && g == 0x07E0 && b == 0x001F)
+    return &ptc_convert_32_to_16_rgb565;
+#endif
+
+  /* 32bit RGB888 -> 16bit BGR565 */
+#ifdef __PTC_CONVERTER_32_TO_16_BGR565
+  if (bits == 16 && r == 0x001F && g == 0x07E0 && b == 0xF800)
+    return &ptc_convert_32_to_16_bgr565;
+#endif
+
+  /* 32bit RGB888 -> 16bit RGB555 */
+#ifdef __PTC_CONVERTER_32_TO_16_RGB555
+  if (bits == 16 && r == 0x7C00 && g == 0x03E0 && b == 0x001F)
+    return &ptc_convert_32_to_16_rgb555;
+#endif
+
+  /* 32bit RGB888 -> 16bit BGR555 */
+#ifdef __PTC_CONVERTER_32_TO_16_BGR555
+  if (bits == 16 && r == 0x001F && g == 0x03E0 && b == 0x7C00)
+    return &ptc_convert_32_to_16_bgr555;
+#endif
+
+  /* failure */
+  return 0;
+}
diff --git a/bigscreen/tinyptc/convert.h b/bigscreen/tinyptc/convert.h
new file mode 100644 (file)
index 0000000..021462b
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * TinyPTC x11 v0.7.3 Pixelformat converters
+ * Copyright (C) 2000-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ * Copyright (C) 2000-2001 Glenn Fiedler <gaffer@gaffer.org>
+ *
+ * http://www.sourceforge.net/projects/tinyptc/
+ *
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * 
+ */
+
+#ifndef __TINYPTC_CONVERT_H
+#define __TINYPTC_CONVERT_H
+
+/* include files */
+#include "tinyptc.h"
+
+#define __PTC_CONVERTER_32_TO_32_RGB888
+#define __PTC_CONVERTER_32_TO_32_BGR888
+#define __PTC_CONVERTER_32_TO_24_RGB888
+#define __PTC_CONVERTER_32_TO_24_BGR888
+#define __PTC_CONVERTER_32_TO_16_RGB565
+#define __PTC_CONVERTER_32_TO_16_BGR565
+#define __PTC_CONVERTER_32_TO_16_RGB555
+#define __PTC_CONVERTER_32_TO_16_BGR555
+
+#ifdef __cplusplus
+       extern "C" {
+#endif /* __cplusplus */
+                       
+/* converter function type */
+typedef void (*PTC_CONVERTER) (void *src, void *dst, int pixels);
+
+/* converter request */
+PTC_CONVERTER ptc_request_converter (int bits, int32 r, int32 g, int32 b);
+
+#ifdef __cplusplus
+       }
+#endif /* __cplusplus */
+
+#endif /* __TINYPTC_CONVERT_H */
diff --git a/bigscreen/tinyptc/findused.sh b/bigscreen/tinyptc/findused.sh
new file mode 100755 (executable)
index 0000000..11119f6
--- /dev/null
@@ -0,0 +1,42 @@
+#! /bin/sh
+
+# TinyPTC x11 v0.7.3 Chosen rendering target finder
+# Copyright (C) 2001-2002 Alessandro Gatti <a.gatti@tiscali.it>
+#
+# http://www.sourceforge.net/projects/tinyptc/
+#
+# This library 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 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Is this portable?
+pragmas=`grep -i "^ *#pragma target" - | expand | sed -e 's/^ *#pragma target *//g'`
+
+rm -f ptctarget.o
+
+for pragma in $pragmas
+do
+       case $pragmas in
+               xlib) target="xlib.o" ;;
+               xdbe) target="xdbe.o" ;;
+               xdga1) target="xdga1.o" ;;
+               xdga2) target="xdga2.o" ;;
+               xshm) target="xshm.o" ;;
+               xvshm) target="xvshm.o" ;;
+       esac
+done
+
+if [ target ]
+then
+       ln -s $target ptctarget.o
+fi
diff --git a/bigscreen/tinyptc/mmx.h b/bigscreen/tinyptc/mmx.h
new file mode 100644 (file)
index 0000000..49f9438
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * TinyPTC x11 v0.7.3 MMX-Optimized pixelformat converters
+ * Copyright (C) 2000-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ * Copyright (C) 2000-2001 Glenn Fiedler <gaffer@gaffer.org>
+ *
+ * http://www.sourceforge.net/projects/tinyptc/
+ *
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef __TINYPTC_MMX_H
+#define __TINYPTC_MMX_H
+
+#include "tinyptc.h"
+
+#define __PTC_MMX_CONVERT_32_TO_32_BGR888
+#define __PTC_MMX_CONVERT_32_TO_32_RGB888
+#define __PTC_MMX_CONVERT_32_TO_24_BGR888
+#define __PTC_MMX_CONVERT_32_TO_24_RGB888
+#define __PTC_MMX_CONVERT_32_TO_16_BGR565
+#define __PTC_MMX_CONVERT_32_TO_16_RGB565
+#define __PTC_MMX_CONVERT_32_TO_16_BGR555
+#define __PTC_MMX_CONVERT_32_TO_16_RGB555
+
+#ifdef __cplusplus
+       extern "C" {
+#endif /* __cplusplus */
+
+#ifdef __PTC_MMX__
+void mmx_memcpy (void *d, void *s, int bytes);
+#endif /* __PTC_MMX__ */
+
+#ifdef __PTC_MMX_CONVERT_32_TO_32_BGR888
+void mmx_convert_32_to_32_bgr888 (void *d, void *s, int pixels);
+#endif /* __PTC_MMX_CONVER_32_TO_32_BGR888 */
+
+#ifdef __PTC_MMX_CONVERT_32_TO_32_RGB888
+void mmx_convert_32_to_24_rgb888 (void *d, void *s, int pixels);
+#endif /* __PTC_MMX_CONVERT_32_TO_32_RGB888 */
+
+#ifdef __PTC_MMX_CONVERT_32_TO_24_BGR888
+void mmx_convert_32_to_24_bgr888 (void *d, void *s, int pixels);
+#endif /* __PTC_MMX_CONVERT_32_TO_24_BGR888 */
+
+#ifdef __PTC_MMX_CONVERT_32_TO_16_BGR565
+void mmx_convert_32_to_16_rgb565 (void *d, void *s, int pixels);
+#endif /* __PTC_MMX_CONVERT_32_TO_16_BGR565 */
+
+#ifdef __PTC_MMX_CONVERT_32_TO_16_RGB565
+void mmx_convert_32_to_16_bgr565 (void *d, void *s, int pixels);
+#endif /* __PTC_MMX_CONVERT_32_TO_16_RGB565 */
+
+#ifdef __PTC_MMX_CONVERT_32_TO_16_BGR555
+void mmx_convert_32_to_16_rgb555 (void *d, void *s, int pixels);
+#endif /* __PTC_MMX_CONVERT_32_TO_16_BGR555 */
+
+#ifdef __PTC_MMX_CONVERT_32_TO_16_RGB555
+void mmx_convert_32_to_16_bgr555 (void *d, void *s, int pixels);
+#endif /* __PTC_MMX_CONVERT_32_TO_16_RGB555 */
+
+#ifdef __cplusplus
+       }
+#endif /* __cplusplus */
+
+#endif /* __TINYPTC_MMX_H */
diff --git a/bigscreen/tinyptc/mmx.s b/bigscreen/tinyptc/mmx.s
new file mode 100644 (file)
index 0000000..6509c47
--- /dev/null
@@ -0,0 +1,582 @@
+;
+; TinyPTC x11 v0.7.3 MMX-Optimized pixelformat converters
+; Copyright (C) 2000-2002 Alessandro Gatti <a.gatti@tiscali.it>
+; Copyright (C) 2000-2001 Glenn Fiedler <gaffer@gaffer.org>
+;
+; http://www.sourceforge.net/projects/tinyptc/
+;
+; This library 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 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
+; Lesser General Public License for more details.
+;
+; You should have received a copy of the GNU Lesser General Public
+; License along with this library; if not, write to the Free Software
+; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+; 
+
+%include "mmx.i"
+
+bits 32
+
+%ifdef __PTC_MMX__
+global mmx_memcpy
+%endif
+
+%ifdef __PTC_MMX_CONVERT_32_TO_32_BGR888
+global mmx_convert_32_to_32_bgr888
+%endif
+
+%ifdef __PTC_MMX_CONVERT_32_TO_24_RGB888
+global mmx_convert_32_to_24_rgb888
+%endif
+
+%ifdef __PTC_MMX_CONVERT_32_TO_24_BGR888
+global mmx_convert_32_to_24_bgr888
+%endif 
+
+%ifdef __PTC_MMX_CONVERT_32_TO_16_RGB565
+global mmx_convert_32_to_16_rgb565
+%endif
+
+%ifdef __PTC_MMX_CONVERT_32_TO_16_BGR565
+global mmx_convert_32_to_16_bgr565
+%endif
+
+%ifdef __PTC_MMX_CONVERT_32_TO_16_RGB555
+global mmx_convert_32_to_16_rgb555
+%endif
+
+%ifdef __PTC_MMX_CONVERT_32_TO_16_BGR555
+global mmx_convert_32_to_16_bgr555
+%endif
+
+section .data
+
+align 16
+
+mmx_rgb888_mask dd 00ffffffh,00ffffffh
+
+mmx_rgb565_b dd 000000f8h, 000000f8h
+mmx_rgb565_g dd 0000fc00h, 0000fc00h
+mmx_rgb565_r dd 00f80000h, 00f80000h
+
+mmx_rgb555_rb dd 00f800f8h,00f800f8h
+mmx_rgb555_g dd 0000f800h,0000f800h
+mmx_rgb555_mul dd 20000008h,20000008h
+mmx_bgr555_mul dd 00082000h,00082000h
+
+section .text
+
+%ifdef __PTC_MMX__
+
+align 16
+
+mmx_memcpy:
+
+    push ebp
+    mov ebp,esp
+
+    pushad
+
+    mov edi,[ebp+8]       ; destination
+    mov esi,[ebp+12]      ; source
+    mov ecx,[ebp+16]      ; bytes
+
+    mov eax,ecx
+    shr ecx,6
+    mov ebx,ecx
+    shl ebx,6
+    sub eax,ebx
+
+align 16
+             
+    .loop
+
+        movq mm0,[esi]
+        movq mm1,[esi+8]
+        movq mm2,[esi+16]
+        movq mm3,[esi+24]
+        movq mm4,[esi+32]
+        movq mm5,[esi+40]
+        movq mm6,[esi+48]
+        movq mm7,[esi+56]
+        movq [edi],mm0
+        movq [edi+8],mm1
+        movq [edi+16],mm2
+        movq [edi+24],mm3
+        movq [edi+32],mm4
+        movq [edi+40],mm5
+        movq [edi+48],mm6
+        movq [edi+56],mm7
+        add esi,8*8
+        add edi,8*8
+        dec ecx
+        jnz .loop
+
+    mov ecx,eax
+    rep movsb
+
+    emms
+
+    popad
+    
+    pop ebp
+    ret
+
+%endif
+
+%ifdef __PTC_MMX_CONVERT_32_TO_32_BGR888
+
+align 16
+
+mmx_convert_32_to_32_bgr888:
+
+    ret
+
+%endif
+
+%ifdef __PTC_MMX_CONVERT_32_TO_24_RGB888
+
+
+align 16
+
+mmx_convert_32_to_24_rgb888:
+
+    push ebp
+    mov ebp,esp
+
+    pushad
+
+    mov edi,[ebp+8]       ; destination
+    mov esi,[ebp+12]      ; source
+    mov ecx,[ebp+16]      ; bytes
+
+    ; set up mm6 as the mask, mm7 as zero
+    movq mm6, qword [mmx_rgb888_mask]
+    pxor mm7, mm7
+
+    mov edx, ecx                    ; save ecx
+    and ecx, 0fffffffch             ; clear lower two bits
+    jnz .L1
+    jmp .L2
+
+.L1:
+
+    movq mm0, [esi]                 ; A R G B a r g b
+    pand mm0, mm6                   ; 0 R G B 0 r g b
+    movq mm1, [esi+8]               ; A R G B a r g b
+    pand mm1, mm6                   ; 0 R G B 0 r g b
+
+    movq mm2, mm0                   ; 0 R G B 0 r g b
+    punpckhdq mm2, mm7              ; 0 0 0 0 0 R G B
+    punpckldq mm0, mm7              ; 0 0 0 0 0 r g b
+    psllq mm2, 24                   ; 0 0 R G B 0 0 0
+    por mm0, mm2                    ; 0 0 R G B r g b
+
+    movq mm3, mm1                   ; 0 R G B 0 r g b
+    psllq mm3, 48                   ; g b 0 0 0 0 0 0
+    por mm0, mm3                    ; g b R G B r g b
+
+    movq mm4, mm1                   ; 0 R G B 0 r g b
+    punpckhdq mm4, mm7              ; 0 0 0 0 0 R G B
+    punpckldq mm1, mm7              ; 0 0 0 0 0 r g b
+    psrlq mm1, 16                   ; 0 0 0 R G B 0 r
+    psllq mm4, 8                    ; 0 0 0 0 R G B 0
+    por mm1, mm4                    ; 0 0 0 0 R G B r
+
+    movq [edi], mm0
+    add esi, BYTE 16
+    movd [edi+8], mm1
+    add edi, BYTE 12
+    sub ecx, BYTE 4
+    jnz .L1
+
+.L2:
+    mov ecx, edx
+    and ecx, BYTE 3
+    jz .L4
+.L3:
+    mov al, [esi]
+    mov bl, [esi+1]
+    mov dl, [esi+2]
+    mov [edi], al
+    mov [edi+1], bl
+    mov [edi+2], dl
+    add esi, BYTE 4
+    add edi, BYTE 3
+    dec ecx
+    jnz .L3
+.L4:
+
+    emms
+
+    popad
+    
+    pop ebp
+    ret
+
+%endif
+
+%ifdef __PTC_MMX_CONVERT_32_TO_24_BGR888
+
+align 16
+
+mmx_convert_32_to_24_bgr888:
+
+    ret
+
+%endif
+
+
+%ifdef __PTC_MMX_CONVERT_32_TO_16_RGB565
+
+align 16
+
+mmx_convert_32_to_16_rgb565:
+
+    push ebp
+    mov ebp,esp
+
+    pushad
+
+    mov edi,[ebp+8]       ; destination
+    mov esi,[ebp+12]      ; source
+    mov ecx,[ebp+16]      ; bytes
+
+    ; set up masks
+    movq mm5, [mmx_rgb565_b]
+    movq mm6, [mmx_rgb565_g]
+    movq mm7, [mmx_rgb565_r]
+
+    mov edx, ecx
+    shr ecx, 2
+    jnz .L1
+    jmp .L2         ; not necessary at the moment, but doesn't hurt (much)
+
+.L1:
+    movq mm0, [esi]         ; argb
+    movq mm1, mm0           ; argb
+    pand mm0, mm6           ; 00g0
+    movq mm3, mm1           ; argb
+    pand mm1, mm5           ; 000b
+    pand mm3, mm7           ; 0r00
+    pslld mm1, 2            ; 0 0 000000bb bbb00000
+    por mm0, mm1            ; 0 0 ggggggbb bbb00000
+    psrld mm0, 5            ; 0 0 00000ggg gggbbbbb
+
+    movq mm4, [esi+8]       ; argb
+    movq mm2, mm4           ; argb
+    pand mm4, mm6           ; 00g0
+    movq mm1, mm2           ; argb
+    pand mm2, mm5           ; 000b
+    pand mm1, mm7           ; 0r00
+    pslld mm2, 2            ; 0 0 000000bb bbb00000
+    por mm4, mm2            ; 0 0 ggggggbb bbb00000
+    psrld mm4, 5            ; 0 0 00000ggg gggbbbbb
+
+    packuswb mm3, mm1       ; R 0 r 0
+    packssdw mm0, mm4       ; as above.. ish
+    por mm0, mm3            ; done.
+    movq [edi], mm0
+
+    add esi, 16
+    add edi, 8
+    dec ecx
+    jnz .L1
+
+.L2:
+    mov ecx, edx
+    and ecx, BYTE 3
+    jz .L4
+.L3:
+    mov al, [esi]
+    mov bh, [esi+1]
+    mov ah, [esi+2]
+    shr al, 3
+    and eax, 0F81Fh            ; BYTE?
+    shr ebx, 5
+    and ebx, 07E0h             ; BYTE?
+    add eax, ebx
+    mov [edi], al
+    mov [edi+1], ah
+    add esi, BYTE 4
+    add edi, BYTE 2
+    dec ecx
+    jnz .L3
+
+.L4:
+
+    emms
+
+    popad
+    
+    pop ebp
+    ret
+
+%endif
+
+%ifdef __PTC_MMX_CONVERT_32_TO_16_BGR565
+
+align 16
+
+mmx_convert_32_to_16_bgr565:
+
+    push ebp
+    mov ebp,esp
+
+    pushad
+
+    mov edi,[ebp+8]       ; destination
+    mov esi,[ebp+12]      ; source
+    mov ecx,[ebp+16]      ; bytes
+
+    movq mm5, [mmx_rgb565_r]
+    movq mm6, [mmx_rgb565_g]
+    movq mm7, [mmx_rgb565_b]
+
+    mov edx, ecx
+    shr ecx, 2
+    jnz .L1
+    jmp .L2
+
+.L1:
+    movq mm0, [esi]                 ; a r g b
+    movq mm1, mm0                   ; a r g b
+    pand mm0, mm6                   ; 0 0 g 0
+    movq mm3, mm1                   ; a r g b
+    pand mm1, mm5                   ; 0 r 0 0
+    pand mm3, mm7                   ; 0 0 0 b
+
+    psllq mm3, 16                   ; 0 b 0 0
+    psrld mm1, 14                   ; 0 0 000000rr rrr00000
+    por mm0, mm1                    ; 0 0 ggggggrr rrr00000
+    psrld mm0, 5                    ; 0 0 00000ggg gggrrrrr
+
+    movq mm4, [esi+8]               ; a r g b
+    movq mm2, mm4                   ; a r g b
+    pand mm4, mm6                   ; 0 0 g 0
+    movq mm1, mm2                   ; a r g b
+    pand mm2, mm5                   ; 0 r 0 0
+    pand mm1, mm7                   ; 0 0 0 b
+
+    psllq mm1, 16                   ; 0 b 0 0
+    psrld mm2, 14                   ; 0 0 000000rr rrr00000
+    por mm4, mm2                    ; 0 0 ggggggrr rrr00000
+    psrld mm4, 5                    ; 0 0 00000ggg gggrrrrr
+
+    packuswb mm3, mm1               ; BBBBB000 00000000 bbbbb000 00000000
+    packssdw mm0, mm4               ; 00000GGG GGGRRRRR 00000GGG GGGRRRRR
+    por mm0, mm3                    ; BBBBBGGG GGGRRRRR bbbbbggg gggrrrrr
+    movq [edi], mm0
+
+    add esi, BYTE 16
+    add edi, BYTE 8
+    dec ecx
+    jnz .L1
+
+.L2:
+    and edx, BYTE 3
+    jz .L4
+.L3:
+    mov al, [esi+2]
+    mov bh, [esi+1]
+    mov ah, [esi]
+    shr al, 3
+    and eax, 0F81Fh                    ; BYTE ?
+    shr ebx, 5
+    and ebx, 07E0h                     ; BYTE ?
+    add eax, ebx
+    mov [edi], al
+    mov [edi+1], ah
+    add esi, BYTE 4
+    add edi, BYTE 2
+    dec edx
+    jnz .L3
+
+.L4:
+
+    emms
+
+    popad
+    
+    pop ebp
+    ret
+
+%endif
+
+%ifdef __PTC_MMX_CONVERT_32_TO_16_BGR555
+
+align 16
+
+mmx_convert_32_to_16_bgr555:
+
+    ; the 16BGR555 converter is identical to the RGB555 one,
+    ; except it uses a different multiplier for the pmaddwd
+    ; instruction.  cool huh.
+
+    movq mm7, qword [mmx_bgr555_mul]
+
+%endif
+
+%ifdef __PTC_MMX_CONVERT_32_TO_16_RGB555
+%ifdef __PTC_MMX_CONVERT_32_TO_16_BGR555
+    jmp _convert_bgr555_cheat
+%endif
+
+    ; This is the same as the Intel version.. they obviously went to
+    ; much more trouble to expand/coil the loop than I did, so theirs
+    ; would almost certainly be faster, even if only a little.
+    ; I did rename 'mmx_rgb555_add' to 'mmx_rgb555_mul', which is
+    ; (I think) a more accurate name..
+
+align 16
+
+mmx_convert_32_to_16_rgb555:
+
+    movq mm7,qword [mmx_rgb555_mul]
+
+%endif
+
+%ifdef __PTC_MMX_CONVERT_32_TO_16_RGB555
+%ifdef __PTC_MMX_CONVERT_32_TO_16_BGR555
+
+_convert_bgr555_cheat:
+
+    movq mm6,qword [mmx_rgb555_g]
+    push ebp
+    mov ebp,esp
+
+    pushad
+
+    mov edi,[ebp+8]       ; destination
+    mov esi,[ebp+12]      ; source
+    mov ecx,[ebp+16]      ; bytes
+        
+       mov edx,ecx                        ; Save ecx 
+
+    and ecx,BYTE 0fffffff8h            ; clear lower three bits
+       jnz .L_OK
+    jmp .L2 
+
+.L_OK:
+       
+       movq mm2,[esi+8]
+
+       movq mm0,[esi]
+       movq mm3,mm2
+
+       pand mm3,qword [mmx_rgb555_rb]
+       movq mm1,mm0
+
+       pand mm1,qword [mmx_rgb555_rb]
+       pmaddwd mm3,mm7
+
+       pmaddwd mm1,mm7
+       pand mm2,mm6
+
+.L1:
+       movq mm4,[esi+24]
+       pand mm0,mm6
+
+       movq mm5,[esi+16]
+       por mm3,mm2
+
+       psrld mm3,6
+       por mm1,mm0
+
+       movq mm0,mm4
+       psrld mm1,6
+
+       pand mm0,qword [mmx_rgb555_rb]
+       packssdw mm1,mm3
+
+       movq mm3,mm5
+       pmaddwd mm0,mm7
+
+       pand mm3,qword [mmx_rgb555_rb]
+       pand mm4,mm6
+
+       movq [edi],mm1                  
+       pmaddwd mm3,mm7
+
+        add esi,BYTE 32
+       por mm4,mm0
+
+       pand mm5,mm6
+       psrld mm4,6
+
+       movq mm2,[esi+8]
+       por mm5,mm3
+
+       movq mm0,[esi]
+       psrld mm5,6
+
+       movq mm3,mm2
+       movq mm1,mm0
+
+       pand mm3,qword [mmx_rgb555_rb]
+       packssdw mm5,mm4
+
+       pand mm1,qword [mmx_rgb555_rb]
+       pand mm2,mm6
+
+       movq [edi+8],mm5
+       pmaddwd mm3,mm7
+
+       pmaddwd mm1,mm7
+    add edi,BYTE 16
+
+    sub ecx,BYTE 8
+       jz .L2
+    jmp .L1
+
+.L2:   
+       mov ecx,edx
+       
+    and ecx,BYTE 7
+       jz .L4
+       
+.L3:   
+       mov ebx,[esi]
+    add esi,BYTE 4
+       
+    mov eax,ebx
+    mov edx,ebx
+
+    shr eax,3
+    shr edx,6
+
+    and eax,BYTE 0000000000011111b
+    and edx,     0000001111100000b
+
+    shr ebx,9
+
+    or eax,edx
+
+    and ebx,     0111110000000000b
+
+    or eax,ebx
+
+    mov [edi],ax
+    add edi,BYTE 2
+
+    dec ecx
+    jnz .L3    
+
+.L4:
+
+    emms
+
+    popad
+    
+    pop ebp
+    ret
+
+%endif
+%endif
diff --git a/bigscreen/tinyptc/python_test.py b/bigscreen/tinyptc/python_test.py
new file mode 100644 (file)
index 0000000..6e9d08e
--- /dev/null
@@ -0,0 +1,51 @@
+#! /usr/bin/env python
+
+# TinyPTC x11 v0.7.3 Python example
+# Copyright (C) 2002 Alessandro Gatti <a.gatti@tiscali.it>
+#
+# http://www.sourceforge.net/projects/tinyptc/
+#
+# This library 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 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 Lesser General Public License
+# for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import TinyPTC
+
+WIDTH       = 320
+HEIGHT      = 200
+SIZE        = (WIDTH * HEIGHT)
+noise       = None
+carry       = None
+counter     = None
+pixel       = None
+seed        = 0x12345
+
+if not TinyPTC.ptc_open("Test", 320, 200):
+       raise Exception, "Can't open window!"
+
+pixel = TinyPTC.pixel_array(SIZE)
+
+while True:
+       for counter in range(SIZE):
+               noise = seed
+               noise = noise >> 3
+               noise = noise ^ seed
+               carry = noise & 1
+               noise = noise >> 1
+               seed = seed >> 1
+               seed = seed | (carry << 30)
+               noise = noise & 0xFF
+               pixel[counter] = (noise << 16) | (noise << 8) | noise
+       TinyPTC.ptc_update(pixel)
+
+TinyPTC.ptc_close()
diff --git a/bigscreen/tinyptc/test.c b/bigscreen/tinyptc/test.c
new file mode 100644 (file)
index 0000000..cc6ccaf
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * TinyPTC x11 v0.7.3 Example file
+ * Copyright (C) 2001-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ * Copyright (C) 2000-2001 Glenn Fiedler <gaffer@gaffer.org>
+ *
+ * http://www.sourceforge.net/projects/tinyptc/
+ *
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "tinyptc.h"
+
+#include <stdio.h>
+
+#define WIDTH 320
+#define HEIGHT 200
+#define SIZE WIDTH*HEIGHT
+
+static int noise;
+static int carry;
+static int counter;
+static int seed = 0x12345;
+static int pixel[SIZE];
+
+void
+ptc_cleanup_callback (void)
+{
+  fprintf (stderr, "Callback!\n");
+}
+
+int
+main ()
+{
+  if (!ptc_open ("test", WIDTH, HEIGHT))
+    return 1;
+  for (;;)
+    {
+      for (counter = 0; counter < SIZE; counter++)
+       {
+         noise = seed;
+         noise >>= 3;
+         noise ^= seed;
+         carry = noise & 1;
+         noise >>= 1;
+         seed >>= 1;
+         seed |= (carry << 30);
+         noise &= 0xFF;
+         pixel[counter] = (noise << 16) | (noise << 8) | noise;
+       }
+      ptc_update (pixel);
+    }
+  ptc_close ();
+  return 0;
+}
diff --git a/bigscreen/tinyptc/tinyptc.h b/bigscreen/tinyptc/tinyptc.h
new file mode 100644 (file)
index 0000000..5fee0de
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * TinyPTC x11 v0.7.3 Main header file
+ * Copyright (C) 2000-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ * Copyright (C) 2002      Fred Howell <foohoo@shaw.ca>
+ * Copyright (C) 2000-2001 Glenn Fiedler <gaffer@gaffer.org>
+ *
+ * http://www.sourceforge.net/projects/tinyptc/
+ *
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * 
+ */
+
+#ifndef __TINYPTC_X11
+#define __TINYPTC_X11
+
+#define PTC_FAILURE 0
+#define PTC_SUCCESS 1
+
+#define __PTC_FUNCTION_KEY__ 0xFF
+#define __PTC_ESCAPE_KEY__ 0x1B
+
+typedef unsigned int int32;
+typedef unsigned short int16;
+typedef unsigned short short16;
+typedef unsigned char char8;
+
+/* This directive enables pixelformat conversions - ignored for the
+ * XVideo+Mit-Shm target */
+
+#define __PTC_ENABLE_CONVERSIONS__
+
+/* This directive enables mmx-optimized pixelformat conversions */
+
+/* #define __PTC_MMX__ */
+
+/* This directive enables little-endian pixelformat converters - ignored for
+ * the XVideo+Mit-Shm target */
+
+/* #define __PTC_LITTLE_ENDIAN__ */
+
+/* This directive enables a best-fit video-mode choice logic for DGA 1.x and
+ * DGA 2.x targets */
+
+#define __PTC_BEST_VIDEOMODE__
+
+/* This directive enables the use of an user-supplied callback that will be
+ * triggered upon exit */
+
+/* #define __PTC_CLEANUP_CALLBACK__ */
+
+/* If you uncomment this directive, you'll choose raw xlib video rendering */
+
+#define __PTC_XLIB__
+
+/* If you uncomment this directive, you'll choose X Shared memory extension
+ * video rendering */
+
+/* #define __PTC_XSHM__ */
+
+/* If you uncomment this directive, you'll choose X Double buffer extension
+ * video rendering */
+
+/* #define __PTC_XDBE__ */
+
+/* If you uncomment this directive, you'll choose X Direct Graphics Access
+ * extension (version 1.x) video rendering */
+
+/* #define __PTC_XDGA1__ */
+
+/* If you uncomment this directive, you'll choose X Direct Graphics Access
+ * extension (version 2.x) video rendering */
+
+/* #define __PTC_XDGA2__ */
+
+/* If you uncomment this directive, you'll choose XVideo YV12 Accelerated
+ * extension video rendering (using shared memory) */
+
+/* #define __PTC_XVSHM__ */
+
+#ifdef __PTC_WINDOWED__
+#error __PTC_WINDOWED__ is not valid anymore, use __PTC_XLIB__ instead.
+#endif /* __PTC_WINDOWED__ */
+
+#ifdef __PTC_XLIB__
+#include "xlib.h"
+#endif /* __PTC_XLIB__ */
+
+#ifdef __PTC_XSHM__
+#include "xshm.h"
+#endif /* __PTC_XSHM__ */
+
+#ifdef __PTC_XDBE__
+#include "xdbe.h"
+#endif /* __PTC_XDBE__ */
+
+#ifdef __PTC_XDGA1__
+#include "xdga1.h"
+#endif /* __PTC_XDGA1__ */
+
+#ifdef __PTC_XDGA2__
+#include "xdga2.h"
+#endif /* __PTC_XDGA2__ */
+
+#ifdef __PTC_XVSHM__
+#include "xvshm.h"
+#endif /* __PTC_XVSHM__ */
+
+#ifndef __TINYPTC_INCLUDED
+#error You should select at least one target. If you did not select \
+       anything in order to use the DGA target, use __PTC_XDGA1__ or \
+       __PTC_XDGA2__ instead. Please check tinyptc.h settings.
+#endif /* __TINYPTC_INCLUDED */
+
+#if defined(__PTC_MMX__) && (! defined(__PTC_ENABLE_CONVERSIONS__))
+    #if ! defined(__PTC_XVSHM__)
+      #undef __PTC_MMX__
+    #endif /* !(__PTC_XVSHM__) */
+#endif /* __PTC_MMX__ && (!(__PTC_ENABLE_CONVERSIONS__)) */
+       
+#ifdef __PTC_ENABLE_CONVERSIONS__
+#include "convert.h"
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+
+#ifdef SWIG
+%module TinyPTC
+%{
+%}
+%include "carrays.i"
+%array_class(int, pixel_array);
+#endif /* SWIG */
+
+#ifdef __cplusplus
+       extern "C" {
+#endif /* __cplusplus */
+       
+extern int ptc_open (char *title, int width, int height);
+extern int ptc_update (void *buffer);
+extern void ptc_close (void);
+int ptc_process_events (void);
+
+#ifdef __PTC_CLEANUP_CALLBACK__
+extern void ptc_cleanup_callback (void);
+#endif /* __PTC_CLEANUP_CALLBACK__ */
+
+#ifdef __cplusplus
+       }
+#endif /* __cplusplus */
+
+#endif /* __TINYPTC_X11 */
diff --git a/bigscreen/tinyptc/xdbe.c b/bigscreen/tinyptc/xdbe.c
new file mode 100644 (file)
index 0000000..b4e7e7e
--- /dev/null
@@ -0,0 +1,326 @@
+/*
+ * TinyPTC x11 v0.7.3 X Double Buffer Extension target
+ * Copyright (C) 2001-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ * 
+ * http://www.sourceforge.net/projects/tinyptc/
+ * 
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/* #includes */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/Xdbe.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include "tinyptc.h"
+
+#ifdef __PTC_XDBE__
+
+#define __PTC_FROM_SOURCE
+
+#include "xdbe.h"
+
+/* Open the screen */
+
+int
+ptc_open (char *title, int width, int height)
+{
+  /* Open a display on the current root window */
+  ptc_display = XOpenDisplay (NULL);
+  if (ptc_display == NULL)
+    {
+      return PTC_FAILURE;
+    }
+  /* Get the default screen associated with the previously opened display */
+  ptc_screen = DefaultScreen (ptc_display);
+  /* Get screen bitdepth */
+  ptc_depth = DefaultDepth (ptc_display, ptc_screen);
+  /* Get a pointer to the supported pixmap formats */
+  ptc_pixmap_formats =
+    XListPixmapFormats (ptc_display, &ptc_pixmap_format_count);
+  /* Check if there's one that's suitable */
+  for (ptc_pixmap_counter = 0; ptc_pixmap_counter < ptc_pixmap_format_count;
+       ptc_pixmap_counter++)
+    {
+      if (ptc_depth == ptc_pixmap_formats[ptc_pixmap_counter].depth)
+       {
+         /* Set the right value */
+         ptc_converter_depth =
+           ptc_pixmap_formats[ptc_pixmap_counter].bits_per_pixel;
+       }
+    }
+  XFree (ptc_pixmap_formats);
+#ifdef __PTC_ENABLE_CONVERSIONS__
+  /* Get the default visual */
+  ptc_visual = DefaultVisual (ptc_display, ptc_screen);
+  /* Check if a converter is avaliable */
+  ptc_convert =
+    ptc_request_converter (ptc_converter_depth, ptc_visual->red_mask,
+                          ptc_visual->green_mask, ptc_visual->blue_mask);
+  if (!ptc_convert)
+    {
+      /* Close the display */
+      XCloseDisplay (ptc_display);
+      return 0;
+    }
+  /* Get the actual bytes-per-pixel value */
+  switch (ptc_converter_depth)
+    {
+    case 8:
+      ptc_output_pitch = 1;
+      break;
+    case 15:
+      ptc_output_pitch = 2;
+      break;
+    case 16:
+      ptc_output_pitch = 2;
+      break;
+    case 24:
+      ptc_output_pitch = 3;
+      break;
+    case 32:
+      ptc_output_pitch = 4;
+      break;
+    }
+  /* Allocate the temporary buffer */
+  ptc_buffer = (char *) malloc (width * height * ptc_output_pitch);
+  if (ptc_buffer == NULL)
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+#else
+  /* It runs only on a 32bpp display if no conversions were activated */
+  if (ptc_converter_depth != 32)
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+
+  /* Check for Xdbe extension */
+  if (!XdbeQueryExtension
+      (ptc_display, &ptc_dbe_major_version, &ptc_dbe_minor_version))
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Get Xdbe visual info */
+  ptc_dbe_drawables = 0;
+  ptc_dbe_visual_infoptr =
+    XdbeGetVisualInfo (ptc_display, &ptc_root_window, &ptc_dbe_drawables);
+  if (ptc_dbe_visual_infoptr == NULL)
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Choose the best visual */
+  ptc_dbe_best_performance = INT_MIN;
+  ptc_dbe_best_visual = 0;
+  ptc_dbe_visualptr = ptc_dbe_visual_infoptr->visinfo;
+  for (ptc_dbe_counter = 0; ptc_dbe_counter < ptc_dbe_visual_infoptr->count;
+       ptc_dbe_counter++)
+    {
+      if (ptc_dbe_visualptr[ptc_dbe_counter].depth == ptc_depth)
+       {
+         if (ptc_dbe_visualptr[ptc_dbe_counter].perflevel >
+             ptc_dbe_best_performance)
+           {
+             ptc_dbe_best_performance =
+               ptc_dbe_visualptr[ptc_dbe_counter].perflevel;
+             ptc_dbe_best_visual = ptc_dbe_visualptr[ptc_dbe_counter].visual;
+           }
+       }
+    }
+  /* Deallocate visual info data */
+  XdbeFreeVisualInfo (ptc_dbe_visual_infoptr);
+  /* No suitable visuals */
+  if (ptc_dbe_best_visual == 0)
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Get screen dimensions */
+  ptc_screen_width = DisplayWidth (ptc_display, ptc_screen);
+  ptc_screen_height = DisplayHeight (ptc_display, ptc_screen);
+  /* Get the default root window */
+  ptc_root_window = DefaultRootWindow (ptc_display);
+  /* Initialize window's attribute structure */
+  ptc_window_attributes.border_pixel = BlackPixel (ptc_display, ptc_screen);
+  ptc_window_attributes.background_pixel =
+    BlackPixel (ptc_display, ptc_screen);
+  ptc_window_attributes.backing_store = NotUseful;
+#ifdef __PTC_CENTER_WINDOW__
+  /* Center the window on the screen */
+  ptc_x_position = (ptc_screen_width - width) / 2;
+  ptc_y_position = (ptc_screen_height - height) / 2;
+#else
+  /* Dock the window on the top-left corner */
+  ptc_x_position = 0;
+  ptc_y_position = 0;
+#endif /* __PTC_CENTER_WINDOW__ */
+  /* Create the window */
+  ptc_window =
+    XCreateWindow (ptc_display, ptc_root_window, ptc_x_position,
+                  ptc_y_position, width, height, 0, ptc_depth, InputOutput,
+                  (Visual *) & ptc_dbe_best_visual,
+                  CWBackPixel | CWBorderPixel | CWBackingStore,
+                  &ptc_window_attributes);
+  /* Set the window's name */
+  XStoreName (ptc_display, ptc_window, title);
+  /* Tell the server to report only keypress-related events */
+  XSelectInput (ptc_display, ptc_window, KeyPressMask | KeyReleaseMask);
+  /* Initialize window's sizehint definition structure */
+  ptc_window_sizehints.flags = PPosition | PMinSize | PMaxSize;
+  ptc_window_sizehints.x = 0;
+  ptc_window_sizehints.y = 0;
+  ptc_window_sizehints.min_width = width;
+  ptc_window_sizehints.max_width = width;
+  ptc_window_sizehints.min_height = height;
+  ptc_window_sizehints.max_height = height;
+  /* Set the window's sizehint */
+  XSetWMNormalHints (ptc_display, ptc_window, &ptc_window_sizehints);
+  /* Clear the window */
+  XClearWindow (ptc_display, ptc_window);
+  /* Put the window on top of the others */
+  XMapRaised (ptc_display, ptc_window);
+  /* Clear event queue */
+  XFlush (ptc_display);
+  /* Get the default graphic context */
+  ptc_window_gc = DefaultGC (ptc_display, ptc_screen);
+  /* Create an XImage */
+  ptc_ximage =
+    XCreateImage (ptc_display, CopyFromParent, ptc_depth, ZPixmap, 0, NULL,
+                 width, height, 32, width * 4);
+  /* Allocate the back buffers */
+  ptc_dbe_backbuffer =
+    XdbeAllocateBackBufferName (ptc_display, ptc_window, XdbeBackground);
+  ptc_dbe_swapinfo.swap_window = ptc_window;
+  ptc_dbe_swapinfo.swap_action = XdbeBackground;
+  /* Save windowsize values */
+  ptc_viewport_width = width;
+  ptc_viewport_height = height;
+  return PTC_SUCCESS;
+}
+
+/* Update the screen */
+
+int
+ptc_update (void *buffer)
+{
+  char *ptc_buffer;
+
+  ptc_buffer=(char *)buffer;
+#ifdef __PTC_ENABLE_CONVERSIONS__
+  ptc_ximage->data = ptc_buffer;
+  ptc_source_index = 0;
+  ptc_destination_index = 0;
+  /* Convert the image line by line */
+  for (ptc_blitcounter = 0; ptc_blitcounter < ptc_viewport_height;
+       ptc_blitcounter++)
+    {
+      /* Conversion */
+      ptc_convert (ptc_buffer + ptc_source_index,
+                  (ptc_ximage->data) + ptc_destination_index,
+                  ptc_viewport_width);
+      /* Pointers update */
+      ptc_source_index += ptc_viewport_width * sizeof (int);
+      ptc_destination_index += ptc_viewport_width * ptc_output_pitch;
+    }
+#else
+  /* Set XImage's data buffer value with the supplied buffer pointer */
+  ptc_ximage->data = ptc_buffer;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+  /* Put the buffer on the back buffer */
+  XPutImage (ptc_display, ptc_dbe_backbuffer, ptc_window_gc, ptc_ximage, 0, 0,
+            0, 0, ptc_viewport_width, ptc_viewport_height);
+  /* Start the swap operation */
+  XdbeBeginIdiom (ptc_display);
+  /* Swap */
+  XdbeSwapBuffers (ptc_display, &ptc_dbe_swapinfo, 1);
+  /* End the swap operation */
+  XdbeEndIdiom (ptc_display);
+  /* Check for incoming events */
+  XFlush (ptc_display);
+  /* Process incoming events */
+  if (ptc_process_events ())
+    {
+#ifdef __PTC_CLEANUP_CALLBACK__
+      ptc_cleanup_callback ();
+#endif /* __PTC_CLEANUP_CALLBACK__ */
+      ptc_close ();
+      exit (0);
+    }
+  return PTC_SUCCESS;
+}
+
+/* Process events */
+
+int
+ptc_process_events (void)
+{
+  XEvent ptc_xevent;
+  KeySym ptc_keysym;
+  /* Check if there are events waiting in the display's queue */
+  if (XPending (ptc_display))
+    {
+      /* Get the next event in queue */
+      XNextEvent (ptc_display, &ptc_xevent);
+      /* Check if it's a keypress event */
+      if (ptc_xevent.type == KeyPress)
+       {
+         /* Get the keysym */
+         ptc_keysym = XLookupKeysym (&ptc_xevent.xkey, 0);
+         /* Check if the key pressed was a function one */
+         if ((ptc_keysym >> 8) == __PTC_FUNCTION_KEY__)
+           {
+             /* Check if it was the escape key */
+             if ((ptc_keysym & 0xFF) == __PTC_ESCAPE_KEY__)
+               {
+                 return PTC_SUCCESS;
+               }
+           }
+       }
+    }
+  return PTC_FAILURE;
+}
+
+/* Close the screen */
+
+void
+ptc_close (void)
+{
+  /* Deallocate the back buffer */
+  XdbeDeallocateBackBufferName (ptc_display, ptc_dbe_backbuffer);
+  /* Restore XImage's buffer pointer */
+  ptc_ximage->data = NULL;
+  /* Destroy the XImage */
+  XDestroyImage (ptc_ximage);
+  /* Close the window */
+  XDestroyWindow (ptc_display, ptc_window);
+  /* Close the display */
+  XCloseDisplay (ptc_display);
+  /* Deallocate the buffer */
+  if (ptc_buffer)
+    {
+      free (ptc_buffer);
+    }
+}
+
+#endif /* __PTC_XDBE__ */
diff --git a/bigscreen/tinyptc/xdbe.h b/bigscreen/tinyptc/xdbe.h
new file mode 100644 (file)
index 0000000..746b1cf
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * TinyPTC x11 v0.7.3 X Double Buffer Extension target
+ * Copyright (C) 2001-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ * 
+ * http://www.sourceforge.net/projects/tinyptc/
+ * 
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef __PTC_XDBE_H
+#define __PTC_XDBE_H
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/Xdbe.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include "tinyptc.h"
+
+#ifdef __PTC_XDBE__
+
+#ifdef __TINYPTC_INCLUDED
+#error You chose more than one target. Please make your mind and try again.
+#endif /* __TINYPTC_INCLUDED */
+
+#define __TINYPTC_INCLUDED
+#pragma target xdbe
+
+#ifdef __cplusplus
+       extern "C" {
+#endif /* __cplusplus */
+
+int ptc_open (char *title, int width, int height);
+int ptc_update (void *buffer);
+void ptc_close (void);
+int ptc_process_events (void);
+
+#ifdef __cplusplus
+       }
+#endif /* __cplusplus */
+
+#endif /* __PTC_XDBE__ */
+
+#endif /* __PTC_XDBE_H */
+
+#ifdef __PTC_FROM_SOURCE
+
+static Display *ptc_display;
+static int ptc_screen;
+static int ptc_screen_width;
+static int ptc_screen_height;
+static int ptc_viewport_width;
+static int ptc_viewport_height;
+static int ptc_depth;
+static Window ptc_root_window;
+static char *ptc_buffer;
+static int ptc_pixmap_format_count;
+static int ptc_pixmap_counter;
+static int ptc_converter_depth;
+static Visual *ptc_visual;
+static XPixmapFormatValues *ptc_pixmap_formats;
+
+static Window ptc_window;
+static int ptc_x_position;
+static int ptc_y_position;
+static XSetWindowAttributes ptc_window_attributes;
+static XSizeHints ptc_window_sizehints;
+static GC ptc_window_gc;
+static XImage *ptc_ximage;
+
+static int ptc_dbe_major_version;
+static int ptc_dbe_minor_version;
+static int ptc_dbe_drawables;
+static int ptc_dbe_counter;
+static int ptc_dbe_best_performance;
+static XdbeScreenVisualInfo *ptc_dbe_visual_infoptr;
+static XdbeVisualInfo *ptc_dbe_visualptr;
+static VisualID ptc_dbe_best_visual;
+static XdbeSwapInfo ptc_dbe_swapinfo;
+static XdbeBackBuffer ptc_dbe_backbuffer;
+
+#ifdef __PTC_ENABLE_CONVERSIONS__
+static PTC_CONVERTER ptc_convert;
+static int ptc_output_pitch;
+static int ptc_blitcounter;
+static int ptc_source_index;
+static int ptc_destination_index;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+
+#endif /* __PTC_FROM_SOURCE */
diff --git a/bigscreen/tinyptc/xdga1.c b/bigscreen/tinyptc/xdga1.c
new file mode 100644 (file)
index 0000000..97801f4
--- /dev/null
@@ -0,0 +1,411 @@
+/*
+ * TinyPTC x11 v0.7.3 X Direct Graphics Access Extension v1 target
+ * Copyright (C) 2000-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ * 
+ * http://www.sourceforge.net/projects/tinyptc/
+ * 
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/* #includes */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/xf86dga.h>
+#include <X11/extensions/xf86vmode.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include "tinyptc.h"
+
+#ifdef __PTC_XDGA1__
+
+#define __PTC_FROM_SOURCE
+
+#include "xdga1.h"
+
+/* Open the screen */
+
+int
+ptc_open (char *title, int width, int height)
+{
+  /* Check for the effective UID of the running process */
+  if (geteuid ())
+    {
+      return PTC_FAILURE;
+    }
+  /* Open a display on the current root window */
+  ptc_display = XOpenDisplay (NULL);
+  if (ptc_display == NULL)
+    {
+      return PTC_FAILURE;
+    }
+  /* Get the default screen associated with the previously opened display */
+  ptc_screen = DefaultScreen (ptc_display);
+  /* Get the default visual */
+  ptc_visual = DefaultVisual (ptc_display, ptc_screen);
+  /* Get screen bitdepth */
+  ptc_depth = DefaultDepth (ptc_display, ptc_screen);
+  /* Get a pointer to the supported pixmap formats */
+  ptc_pixmap_formats =
+    XListPixmapFormats (ptc_display, &ptc_pixmap_format_count);
+  /* Check if there's one that's suitable */
+  for (ptc_pixmap_counter = 0; ptc_pixmap_counter < ptc_pixmap_format_count;
+       ptc_pixmap_counter++)
+    {
+      if (ptc_depth == ptc_pixmap_formats[ptc_pixmap_counter].depth)
+       {
+         /* Set the right value */
+         ptc_converter_depth =
+           ptc_pixmap_formats[ptc_pixmap_counter].bits_per_pixel;
+       }
+    }
+  XFree (ptc_pixmap_formats);
+#ifdef __PTC_ENABLE_CONVERSIONS__
+  /* Check if a converter is avaliable */
+  ptc_convert =
+    ptc_request_converter (ptc_converter_depth, ptc_visual->red_mask,
+                          ptc_visual->green_mask, ptc_visual->blue_mask);
+  if (!ptc_convert)
+    {
+      /* Close the display */
+      XCloseDisplay (ptc_display);
+      return 0;
+    }
+  /* Get the actual bytes-per-pixel value */
+  switch (ptc_converter_depth)
+    {
+    case 8:
+      ptc_output_pitch = 1;
+      break;
+    case 15:
+      ptc_output_pitch = 2;
+      break;
+    case 16:
+      ptc_output_pitch = 2;
+      break;
+    case 24:
+      ptc_output_pitch = 3;
+      break;
+    case 32:
+      ptc_output_pitch = 4;
+      break;
+    }
+  /* Allocate the temporary buffer */
+  ptc_buffer = (char *) malloc (width * height * ptc_output_pitch);
+  if (ptc_buffer == NULL)
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+#else
+  /* It runs only on a 32bpp display if no conversions were activated */
+  if (ptc_converter_depth != 32)
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  ptc_output_pitch = sizeof (int);
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+  /* Check for DGA extension avaliability */
+  if (!XF86DGAQueryExtension (ptc_display, &ptc_event_base, &ptc_error_base))
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Get framebuffer parameters */
+  XF86DGAGetVideo (ptc_display, ptc_screen, &ptc_framebuffer_address,
+                  &ptc_framebuffer_width, &ptc_framebuffer_banksize,
+                  &ptc_framebuffer_memory);
+  /* Check if the mode is banked */
+  if (ptc_framebuffer_banksize < ptc_framebuffer_memory)
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Check for VidMode extension avaliability */
+  if (!XF86VidModeQueryExtension
+      (ptc_display, &ptc_event_base, &ptc_error_base))
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Get all the mode parameters */
+  XF86VidModeGetAllModeLines (ptc_display, ptc_screen, &ptc_totalmodes,
+                             &ptc_modeinfodata);
+  /* Get current mode parameters */
+  XF86VidModeGetModeLine (ptc_display, ptc_screen, &ptc_dotclock,
+                         &ptc_currentmodeline);
+  /* Search for current mode in parameter list */
+  for (ptc_modecounter = 0; ptc_modecounter < ptc_totalmodes;
+       ptc_modecounter++)
+    {
+      if ((ptc_currentmodeline.hdisplay ==
+          ptc_modeinfodata[ptc_modecounter]->hdisplay)
+         && (ptc_currentmodeline.vdisplay ==
+             ptc_modeinfodata[ptc_modecounter]->vdisplay))
+       {
+         /* Save the parameters */
+         ptc_previousmode_number = ptc_modecounter;
+         ptc_screen_width = ptc_currentmodeline.hdisplay;
+         ptc_screen_height = ptc_currentmodeline.vdisplay;
+         break;
+       }
+    }
+  ptc_emulate_fullscreen = True;
+  /* Search for desired mode in parameter list */
+  for (ptc_modecounter = 0; ptc_modecounter < ptc_totalmodes;
+       ptc_modecounter++)
+    {
+      if ((ptc_modeinfodata[ptc_modecounter]->hdisplay == width)
+         && (ptc_modeinfodata[ptc_modecounter]->vdisplay == height))
+       {
+         /* Try to switch mode */
+         if (!XF86VidModeSwitchToMode
+             (ptc_display, ptc_screen, ptc_modeinfodata[ptc_modecounter]))
+           {
+             XFree (ptc_modeinfodata);
+             XCloseDisplay (ptc_display);
+             return PTC_FAILURE;
+           }
+         ptc_emulate_fullscreen = False;
+         break;
+       }
+    }
+#ifdef __PTC_BEST_VIDEOMODE__
+  /* It works for fullscreen emulation only */
+  if (ptc_emulate_fullscreen)
+    {
+      /* Set up loop */
+      ptc_best_delta = INT_MAX;
+      ptc_best_videomode = 0;
+      /* Check for all avaliable modes */
+      for (ptc_modecounter = 0; ptc_modecounter < ptc_totalmodes;
+          ptc_modecounter++)
+       {
+         if ((ptc_modeinfodata[ptc_modecounter]->hdisplay >= width)
+             && (ptc_modeinfodata[ptc_modecounter]->vdisplay >= height))
+           {
+             /* If it fits, get delta parameters */
+             ptc_best_x_delta =
+               ptc_modeinfodata[ptc_modecounter]->hdisplay - width;
+             ptc_best_x_delta *= ptc_best_x_delta;
+             ptc_best_y_delta =
+               ptc_modeinfodata[ptc_modecounter]->vdisplay - height;
+             ptc_best_y_delta *= ptc_best_y_delta;
+             /* Check if the mode was fitting better than the previous one */
+             if (ptc_best_x_delta + ptc_best_y_delta < ptc_best_delta)
+               {
+                 /* Set up next iteration */
+                 ptc_best_delta = ptc_best_x_delta + ptc_best_y_delta;
+                 ptc_best_videomode = ptc_modecounter;
+               }
+           }
+       }
+      /* Try to switch mode */
+      if (!XF86VidModeSwitchToMode
+         (ptc_display, ptc_screen, ptc_modeinfodata[ptc_best_videomode]))
+       {
+         XFree (ptc_modeinfodata);
+         XCloseDisplay (ptc_display);
+         return PTC_FAILURE;
+       }
+    }
+#endif /* __PTC_BEST_VIDEOMODE__ */
+  /* Clear event queue */
+  XFlush (ptc_display);
+  /* Get the root window */
+  ptc_root_window = XRootWindow (ptc_display, ptc_screen);
+  /* Get exclusive keyboard access */
+  XGrabKeyboard (ptc_display, ptc_root_window, False, GrabModeAsync,
+                GrabModeAsync, CurrentTime);
+  /* Get exclusive mouse access */
+  XGrabPointer (ptc_display, ptc_root_window, True,
+               PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
+               GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
+  /* Leave root mode */
+  setuid (getuid ());
+  /* Get viewport parameters */
+  XF86DGAGetViewPortSize (ptc_display, ptc_screen,
+                         (int *) (&ptc_screen_width),
+                         (int *) (&ptc_screen_height));
+  /* Set fullscreen emulation up */
+  if (ptc_emulate_fullscreen)
+    {
+      /* Get effective framebuffer address */
+#ifdef __PTC_ENABLE_CONVERSIONS__
+      ptc_framebuffer_start =
+       ptc_framebuffer_width * ((ptc_screen_height - height) / 2) *
+       ptc_output_pitch +
+       ((ptc_screen_width - width) / 2) * ptc_output_pitch;
+#else
+      ptc_framebuffer_start =
+       ptc_framebuffer_width * ((ptc_screen_height - height) / 2) *
+       sizeof (int) + ((ptc_screen_width - width) / 2) * sizeof (int);
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+    }
+  else
+    {
+      /* Ignore offsets */
+      ptc_framebuffer_start = 0;
+    }
+  /* Get the pitch value */
+  ptc_framebuffer_pitch = ptc_framebuffer_width * ptc_output_pitch;
+  /* Do a safety fork */
+  if (XF86DGAForkApp (ptc_screen))
+    {
+      /* Exit DGA mode */
+      XF86DGADirectVideo (ptc_display, ptc_screen, False);
+      /* Switch back to the previous video mode */
+      XF86VidModeSwitchToMode (ptc_display, ptc_screen,
+                              ptc_modeinfodata[ptc_previousmode_number]);
+      /* Free modeinfo data */
+      XFree (ptc_modeinfodata);
+      /* Leave exclusive keyboard access */
+      XUngrabKeyboard (ptc_display, CurrentTime);
+      /* Leave exclusive mouse access */
+      XUngrabPointer (ptc_display, CurrentTime);
+      /* Close the display */
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Initialize DGA video access */
+  XF86DGADirectVideo (ptc_display, ptc_screen,
+                     XF86DGADirectGraphics | XF86DGADirectKeyb |
+                     XF86DGADirectMouse);
+  /* Clear the screen */
+  memset (ptc_framebuffer_address, 0x00,
+         ptc_framebuffer_width * ptc_screen_height * ptc_output_pitch);
+  /* Select the input events that should be reported */
+  XSelectInput (ptc_display, DefaultRootWindow (ptc_display),
+               KeyPressMask | KeyReleaseMask);
+  /* Set the final viewport */
+  XF86DGASetViewPort (ptc_display, ptc_screen, 0, 0);
+  /* Clear event queue */
+  XFlush (ptc_display);
+  /* Save the buffer size */
+  ptc_viewport_width = width;
+  ptc_viewport_height = height;
+  return PTC_SUCCESS;
+}
+
+/* Update the screen */
+
+int
+ptc_update (void *buffer)
+{
+  char *ptc_buffer;
+
+  ptc_buffer=(char *)buffer;
+  ptc_framebuffer_index = 0;
+#ifdef __PTC_ENABLE_CONVERSIONS__
+  ptc_source_index = 0;
+  ptc_destination_index = 0;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+  /* Do the blit line by line */
+  for (ptc_blitcounter = 0; ptc_blitcounter < ptc_viewport_height;
+       ptc_blitcounter++)
+    {
+#ifdef __PTC_ENABLE_CONVERSIONS__
+      /* Conversion */
+      ptc_convert (ptc_buffer + ptc_source_index,
+                  ptc_framebuffer_address + ptc_framebuffer_start +
+                  ptc_destination_index, ptc_viewport_width);
+      /* Pointers update */
+      ptc_source_index += ptc_viewport_width * sizeof (int);
+      ptc_destination_index += ptc_framebuffer_pitch;
+#else
+      /* Copy the data */
+      memcpy (ptc_framebuffer_address + ptc_framebuffer_start +
+             ptc_framebuffer_index, ptc_buffer,
+             ptc_viewport_width * sizeof (int));
+      ptc_buffer += ptc_viewport_width * sizeof (int);
+      /* Set up offsets */
+      ptc_framebuffer_index += ptc_framebuffer_pitch;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+    }
+  /* Process incoming events */
+  if (ptc_process_events ())
+    {
+#ifdef __PTC_CLEANUP_CALLBACK__
+      ptc_cleanup_callback ();
+#endif /* __PTC_CLEANUP_CALLBACK__ */
+      ptc_close ();
+      exit (0);
+    }
+  return PTC_SUCCESS;
+}
+
+/* Process events */
+
+int
+ptc_process_events (void)
+{
+  XEvent ptc_xevent;
+  KeySym ptc_keysym;
+  /* Check if there are events waiting in the display's queue */
+  if (XPending (ptc_display))
+    {
+      /* Get the next event in queue */
+      XNextEvent (ptc_display, &ptc_xevent);
+      /* Check if it's a keypress event */
+      if (ptc_xevent.type == KeyPress)
+       {
+         /* Get the keysym */
+         ptc_keysym = XLookupKeysym (&ptc_xevent.xkey, 0);
+         /* Check if the key pressed was a function one */
+         if ((ptc_keysym >> 8) == __PTC_FUNCTION_KEY__)
+           {
+             /* Check if it was the escape key */
+             if ((ptc_keysym & 0xFF) == __PTC_ESCAPE_KEY__)
+               {
+                 return PTC_SUCCESS;
+               }
+           }
+       }
+    }
+  return PTC_FAILURE;
+}
+
+/* Close the screen */
+
+void
+ptc_close (void)
+{
+  /* Exit from DGA mode */
+  XF86DGADirectVideo (ptc_display, ptc_screen, False);
+  /* Switch back to the previous video mode */
+  XF86VidModeSwitchToMode (ptc_display, ptc_screen,
+                          ptc_modeinfodata[ptc_previousmode_number]);
+  /* Free modeinfo data */
+  XFree (ptc_modeinfodata);
+  /* Leave exclusive keyboard access */
+  XUngrabKeyboard (ptc_display, CurrentTime);
+  /* Leave exclusive mouse access */
+  XUngrabPointer (ptc_display, CurrentTime);
+  /* Close the display */
+  XCloseDisplay (ptc_display);
+  /* Deallocate the buffer */
+  if (ptc_buffer)
+    {
+      free (ptc_buffer);
+    }
+}
+
+#endif /* __PTC_XDGA1__ */
diff --git a/bigscreen/tinyptc/xdga1.h b/bigscreen/tinyptc/xdga1.h
new file mode 100644 (file)
index 0000000..a66d994
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * TinyPTC x11 v0.7.3 X Direct Graphics Access Extension v1 target
+ * Copyright (C) 2000-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ * 
+ * http://www.sourceforge.net/projects/tinyptc/
+ * 
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef __PTC_XDGA1_H
+#define __PTC_XDGA1_H
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/xf86dga.h>
+#include <X11/extensions/xf86vmode.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include "tinyptc.h"
+
+#ifdef __PTC_XDGA1__
+
+#ifdef __TINYPTC_INCLUDED
+#error You chose more than one target. Please make your mind and try again.
+#endif /* __TINYPTC_INCLUDED */
+
+#define __TINYPTC_INCLUDED
+#pragma target xdga1
+
+#ifdef __cplusplus
+       extern "C" {
+#endif /* __cplusplus */
+
+int ptc_open (char *title, int width, int height);
+int ptc_update (void *buffer);
+void ptc_close (void);
+int ptc_process_events (void);
+
+#ifdef __cplusplus
+       }
+#endif /* __cplusplus */
+
+#endif /* __PTC_XDGA1__ */
+
+#endif /* __PTC_XDGA1_H */
+
+#ifdef __PTC_FROM_SOURCE
+
+static Display *ptc_display;
+static int ptc_screen;
+static int ptc_screen_width;
+static int ptc_screen_height;
+static int ptc_viewport_width;
+static int ptc_viewport_height;
+static int ptc_depth;
+static Window ptc_root_window;
+static Visual *ptc_visual;
+static char *ptc_buffer;
+static int ptc_pixmap_format_count;
+static int ptc_pixmap_counter;
+static int ptc_converter_depth;
+XPixmapFormatValues *ptc_pixmap_formats;
+
+static char *ptc_framebuffer_address;
+static int ptc_framebuffer_width;
+static int ptc_framebuffer_banksize;
+static int ptc_framebuffer_memory;
+static int ptc_framebuffer_start;
+static int ptc_framebuffer_pitch;
+static int ptc_framebuffer_index;
+static int ptc_totalmodes;
+static int ptc_dotclock;
+static int ptc_modecounter;
+static int ptc_previousmode_number;
+static int ptc_event_base;
+static int ptc_error_base;
+static int ptc_blitcounter;
+static int ptc_output_pitch;
+static Bool ptc_emulate_fullscreen;
+static XF86VidModeModeInfo **ptc_modeinfodata;
+static XF86VidModeModeLine ptc_currentmodeline;
+
+#ifdef __PTC_BEST_VIDEOMODE__
+static int ptc_best_x_delta;
+static int ptc_best_y_delta;
+static int ptc_best_videomode;
+static int ptc_best_delta;
+#endif /* __PTC_BEST_VIDEOMODE__ */
+
+#ifdef __PTC_ENABLE_CONVERSIONS__
+PTC_CONVERTER ptc_convert;
+static int ptc_source_index;
+static int ptc_destination_index;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+
+#endif /* __PTC_FROM_SOURCE */
diff --git a/bigscreen/tinyptc/xdga2.c b/bigscreen/tinyptc/xdga2.c
new file mode 100644 (file)
index 0000000..f74f3cd
--- /dev/null
@@ -0,0 +1,627 @@
+/*
+ * TinyPTC x11 v0.7.3 X Direct Graphics Access Extension v2 target
+ * Copyright (C) 2001-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ * 
+ * http://www.sourceforge.net/projects/tinyptc/
+ * 
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/* #includes */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/xf86dga.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include "tinyptc.h"
+
+#ifdef __PTC_XDGA2__
+
+#define __PTC_FROM_SOURCE
+
+#include "xdga2.h"
+
+/* Open the screen */
+
+int
+ptc_open (char *title, int width, int height)
+{
+  /* Check for the effective UID of the running process */
+  if (geteuid ())
+    {
+      return PTC_FAILURE;
+    }
+  /* Open a display on the current root window */
+  ptc_display = XOpenDisplay (NULL);
+  if (ptc_display == NULL)
+    {
+      return PTC_FAILURE;
+    }
+  /* Get the default screen associated with the previously opened display */
+  ptc_screen = DefaultScreen (ptc_display);
+  /* Get the default visual */
+  ptc_visual = DefaultVisual (ptc_display, ptc_screen);
+
+  /* Check for DGA extension avaliability */
+  if (!XDGAQueryExtension (ptc_display, &ptc_dga_event_base, &ptc_error_base))
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Check for version 2.x of the extension */
+  ptc_dga_major_version = 0;
+  if (!XDGAQueryVersion
+      (ptc_display, &ptc_dga_major_version, &ptc_dga_minor_version)
+      || (ptc_dga_major_version < 2))
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Enable framebuffer access */
+  if (!XDGAOpenFramebuffer (ptc_display, ptc_screen))
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Get all the modelines */
+  ptc_dga_mode = XDGAQueryModes (ptc_display, ptc_screen, &ptc_dga_modes);
+  ptc_dga_emulate_fullscreen = True;
+#ifdef __PTC_ENABLE_CONVERSIONS__
+  ptc_dga_mode_32 = INT_MIN;
+  ptc_dga_mode_24 = INT_MIN;
+  ptc_dga_mode_16 = INT_MIN;
+  ptc_dga_mode_15 = INT_MIN;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+  ptc_dga_new_mode = INT_MIN;
+  /* Search for desired mode in parameter list */
+  for (ptc_dga_counter = 0; ptc_dga_counter < ptc_dga_modes;
+       ptc_dga_counter++)
+    {
+      if ((ptc_dga_mode[ptc_dga_counter].viewportWidth == width)
+         && (ptc_dga_mode[ptc_dga_counter].viewportHeight == height))
+       {
+#ifdef __PTC_ENABLE_CONVERSIONS__
+         /* Get the right videomode for each colordepth */
+         if (ptc_dga_mode[ptc_dga_counter].depth == 24)
+           {
+             if (ptc_dga_mode[ptc_dga_counter].bitsPerPixel == 32)
+               {
+                 ptc_dga_mode_32 = ptc_dga_counter;
+                 ptc_dga_emulate_fullscreen = False;
+               }
+             if (ptc_dga_mode[ptc_dga_counter].bitsPerPixel == 24)
+               {
+                 ptc_dga_mode_24 = ptc_dga_counter;
+                 ptc_dga_emulate_fullscreen = False;
+               }
+           }
+         if (ptc_dga_mode[ptc_dga_counter].bitsPerPixel == 16)
+           {
+             if (ptc_dga_mode[ptc_dga_counter].depth == 15)
+               {
+                 ptc_dga_mode_15 = ptc_dga_counter;
+                 ptc_dga_emulate_fullscreen = False;
+               }
+             if (ptc_dga_mode[ptc_dga_counter].depth == 16)
+               {
+                 ptc_dga_mode_16 = ptc_dga_counter;
+                 ptc_dga_emulate_fullscreen = False;
+               }
+           }
+#else
+         /* Get the right videomode */
+         if ((ptc_dga_mode[ptc_dga_counter].bitsPerPixel == 32)
+             && (ptc_dga_mode[ptc_dga_counter].depth == 32))
+           {
+             ptc_dga_new_mode = ptc_dga_counter;
+             ptc_dga_emulate_fullscreen = False;
+             break;
+           }
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+       }
+    }
+
+#ifdef __PTC_ENABLE_CONVERSIONS__
+  /* Simple heuristics for getting the best videomode and the right
+   * converter for that videomode */
+  if (ptc_dga_mode_32 == INT_MIN)
+    {
+      if (ptc_dga_mode_24 == INT_MIN)
+       {
+         if (ptc_dga_mode_16 == INT_MIN)
+           {
+             if (ptc_dga_mode_15 == INT_MIN)
+               {
+               }
+             else
+               {
+                 ptc_convert =
+                   ptc_request_converter (15,
+                                          ptc_dga_mode[ptc_dga_mode_15].
+                                          redMask,
+                                          ptc_dga_mode[ptc_dga_mode_15].
+                                          greenMask,
+                                          ptc_dga_mode[ptc_dga_mode_15].
+                                          blueMask);
+                 if (!ptc_convert)
+                   {
+                     ptc_dga_new_mode = INT_MIN;
+                   }
+                 else
+                   {
+                     ptc_dga_new_mode = ptc_dga_mode_15;
+                     ptc_dga_output_pitch = 2;
+                   }
+               }
+           }
+         else
+           {
+             ptc_convert =
+               ptc_request_converter (16,
+                                      ptc_dga_mode[ptc_dga_mode_16].
+                                      redMask,
+                                      ptc_dga_mode[ptc_dga_mode_16].
+                                      greenMask,
+                                      ptc_dga_mode[ptc_dga_mode_16].
+                                      blueMask);
+             if (!ptc_convert)
+               {
+                 ptc_dga_new_mode = INT_MIN;
+               }
+             else
+               {
+                 ptc_dga_new_mode = ptc_dga_mode_16;
+                 ptc_dga_output_pitch = 2;
+               }
+           }
+       }
+      else
+       {
+         ptc_convert =
+           ptc_request_converter (24, ptc_dga_mode[ptc_dga_mode_24].redMask,
+                                  ptc_dga_mode[ptc_dga_mode_24].greenMask,
+                                  ptc_dga_mode[ptc_dga_mode_24].blueMask);
+         if (!ptc_convert)
+           {
+             ptc_dga_new_mode = INT_MIN;
+           }
+         else
+           {
+             ptc_dga_new_mode = ptc_dga_mode_24;
+             ptc_dga_output_pitch = 3;
+           }
+       }
+    }
+  else
+    {
+      ptc_convert =
+       ptc_request_converter (32, ptc_dga_mode[ptc_dga_mode_32].redMask,
+                              ptc_dga_mode[ptc_dga_mode_32].greenMask,
+                              ptc_dga_mode[ptc_dga_mode_32].blueMask);
+      if (!ptc_convert)
+       {
+         ptc_dga_new_mode = INT_MIN;
+       }
+      else
+       {
+         ptc_dga_new_mode = ptc_dga_mode_32;
+         ptc_dga_output_pitch = 4;
+       }
+    }
+#else
+  ptc_dga_output_pitch = 4;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+
+#ifdef __PTC_BEST_VIDEOMODE__
+  /* It works for fullscreen emulation only */
+  if (ptc_dga_emulate_fullscreen)
+    {
+      /* Set up loop */
+#ifdef __PTC_ENABLE_CONVERSIONS__
+      ptc_dga_32.best_delta = INT_MAX;
+      ptc_dga_24.best_delta = INT_MAX;
+      ptc_dga_16.best_delta = INT_MAX;
+      ptc_dga_15.best_delta = INT_MAX;
+      ptc_dga_32.best_videomode = INT_MIN;
+      ptc_dga_24.best_videomode = INT_MIN;
+      ptc_dga_16.best_videomode = INT_MIN;
+      ptc_dga_15.best_videomode = INT_MIN;
+#else
+      ptc_dga_best_delta = INT_MAX;
+      ptc_dga_best_videomode = INT_MIN;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+      /* Check for all avaliable modes */
+      for (ptc_dga_counter = 0; ptc_dga_counter < ptc_dga_modes;
+          ptc_dga_counter++)
+       {
+         if ((ptc_dga_mode[ptc_dga_counter].viewportWidth >= width)
+             && (ptc_dga_mode[ptc_dga_counter].viewportHeight >= height))
+           {
+             ptc_dga_best_x_delta =
+               ptc_dga_mode[ptc_dga_counter].viewportWidth - width;
+             ptc_dga_best_x_delta *= ptc_dga_best_x_delta;
+             ptc_dga_best_y_delta =
+               ptc_dga_mode[ptc_dga_counter].viewportHeight - height;
+             ptc_dga_best_y_delta *= ptc_dga_best_y_delta;
+
+             /* Check if the mode fits better than the previous one */
+
+#ifdef __PTC_ENABLE_CONVERSIONS__
+             if (ptc_dga_mode[ptc_dga_counter].depth == 24)
+               {
+                 if (ptc_dga_mode[ptc_dga_counter].bitsPerPixel == 32)
+                   {
+                     if (ptc_dga_best_x_delta + ptc_dga_best_y_delta <
+                         ptc_dga_32.best_delta)
+                       {
+                         ptc_dga_32.best_delta =
+                           ptc_dga_best_x_delta + ptc_dga_best_y_delta;
+                         ptc_dga_32.best_videomode = ptc_dga_counter;
+                       }
+                   }
+                 if (ptc_dga_mode[ptc_dga_counter].bitsPerPixel == 24)
+                   {
+                     if (ptc_dga_best_x_delta + ptc_dga_best_y_delta <
+                         ptc_dga_24.best_delta)
+                       {
+                         ptc_dga_24.best_delta =
+                           ptc_dga_best_x_delta + ptc_dga_best_y_delta;
+                         ptc_dga_24.best_videomode = ptc_dga_counter;
+                       }
+                   }
+               }
+             if (ptc_dga_mode[ptc_dga_counter].bitsPerPixel == 16)
+               {
+                 if (ptc_dga_mode[ptc_dga_counter].depth == 15)
+                   {
+                     if (ptc_dga_best_x_delta + ptc_dga_best_y_delta <
+                         ptc_dga_15.best_delta)
+                       {
+                         ptc_dga_15.best_delta =
+                           ptc_dga_best_x_delta + ptc_dga_best_y_delta;
+                         ptc_dga_15.best_videomode = ptc_dga_counter;
+                       }
+                   }
+                 if (ptc_dga_mode[ptc_dga_counter].depth == 16)
+                   {
+                     if (ptc_dga_best_x_delta + ptc_dga_best_y_delta <
+                         ptc_dga_16.best_delta)
+                       {
+                         ptc_dga_16.best_delta =
+                           ptc_dga_best_x_delta + ptc_dga_best_y_delta;
+                         ptc_dga_16.best_videomode = ptc_dga_counter;
+                       }
+                   }
+               }
+#else
+             /* Set up next iteration */
+             ptc_dga_best_delta =
+               ptc_dga_best_x_delta + ptc_dga_best_y_delta;
+             ptc_dga_best_videomode = ptc_dga_counter;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+           }
+       }
+    }
+
+#ifdef __PTC_ENABLE_CONVERSIONS__
+  /* Simple heuristics for getting the best videomode and the right
+   * converter for that videomode */
+
+  if (ptc_dga_32.best_videomode == INT_MIN)
+    {
+      if (ptc_dga_24.best_videomode == INT_MIN)
+       {
+         if (ptc_dga_16.best_videomode == INT_MIN)
+           {
+             if (ptc_dga_15.best_videomode == INT_MIN)
+               {
+               }
+             else
+               {
+                 ptc_convert =
+                   ptc_request_converter (15,
+                                          ptc_dga_mode[ptc_dga_15.
+                                                       best_videomode].
+                                          redMask,
+                                          ptc_dga_mode[ptc_dga_15.
+                                                       best_videomode].
+                                          greenMask,
+                                          ptc_dga_mode[ptc_dga_15.
+                                                       best_videomode].
+                                          blueMask);
+                 if (!ptc_convert)
+                   {
+                     ptc_dga_new_mode = INT_MIN;
+                   }
+                 else
+                   {
+                     ptc_dga_new_mode = ptc_dga_15.best_videomode;
+                     ptc_dga_output_pitch = 2;
+                   }
+               }
+           }
+         else
+           {
+
+             ptc_convert =
+               ptc_request_converter (16,
+                                      ptc_dga_mode[ptc_dga_16.
+                                                   best_videomode].redMask,
+                                      ptc_dga_mode[ptc_dga_16.
+                                                   best_videomode].greenMask,
+                                      ptc_dga_mode[ptc_dga_16.
+                                                   best_videomode].blueMask);
+             if (!ptc_convert)
+               {
+                 ptc_dga_new_mode = INT_MIN;
+               }
+             else
+               {
+                 ptc_dga_new_mode = ptc_dga_16.best_videomode;
+                 ptc_dga_output_pitch = 2;
+               }
+           }
+       }
+      else
+       {
+
+         ptc_convert =
+           ptc_request_converter (24,
+                                  ptc_dga_mode[ptc_dga_24.best_videomode].
+                                  redMask,
+                                  ptc_dga_mode[ptc_dga_24.best_videomode].
+                                  greenMask,
+                                  ptc_dga_mode[ptc_dga_24.best_videomode].
+                                  blueMask);
+         if (!ptc_convert)
+           {
+             ptc_dga_new_mode = INT_MIN;
+           }
+         else
+           {
+             ptc_dga_new_mode = ptc_dga_24.best_videomode;
+             ptc_dga_output_pitch = 3;
+           }
+       }
+    }
+  else
+    {
+      ptc_convert =
+       ptc_request_converter (32,
+                              ptc_dga_mode[ptc_dga_32.best_videomode].
+                              redMask,
+                              ptc_dga_mode[ptc_dga_32.best_videomode].
+                              greenMask,
+                              ptc_dga_mode[ptc_dga_32.best_videomode].
+                              blueMask);
+      if (!ptc_convert)
+       {
+         ptc_dga_new_mode = INT_MIN;
+       }
+      else
+       {
+         ptc_dga_new_mode = ptc_dga_32.best_videomode;
+         ptc_dga_output_pitch = 4;
+       }
+    }
+#else
+  ptc_dga_output_pitch = 4;
+  ptc_dga_new_mode = ptc_dga_best_videomode;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+#endif /* __PTC_BEST_VIDEOMODE__ */
+
+  /* No suitable mode found */
+  if (ptc_dga_new_mode == INT_MIN)
+    {
+      XFree (ptc_dga_mode);
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Try to switch mode */
+  ptc_dga_device =
+    XDGASetMode (ptc_display, ptc_screen, ptc_dga_mode[ptc_dga_new_mode].num);
+  if (ptc_dga_device == NULL)
+    {
+      XFree (ptc_dga_mode);
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Clear event queue */
+  XFlush (ptc_display);
+  /* Leave root mode */
+  setuid (getuid ());
+  /* Get viewport parameters */
+  ptc_screen_width = ptc_dga_device->mode.viewportWidth;
+  ptc_screen_height = ptc_dga_device->mode.viewportHeight;
+  /* Get framebuffer address */
+  ptc_dga_framebuffer_address = (char *)ptc_dga_device->data;
+
+
+  /* Set fullscreen emulation up */
+  if (ptc_dga_emulate_fullscreen)
+    {
+      /* Get effective framebuffer address */
+      ptc_framebuffer_start =
+       ptc_dga_device->mode.bytesPerScanline *
+       ((ptc_screen_height - height) / 2) +
+       (((ptc_screen_width - width) / 2) * ptc_dga_output_pitch);
+    }
+  else
+    {
+      /* Ignore offsets */
+      ptc_framebuffer_start = 0;
+    }
+  ptc_dga_video_length =
+    ptc_dga_device->mode.bytesPerScanline *
+    ptc_dga_device->mode.viewportHeight;
+
+  ptc_dga_first_page_address = ptc_dga_framebuffer_address + ptc_framebuffer_start;
+  ptc_dga_second_page_address =
+    ptc_dga_first_page_address + ptc_dga_video_length;
+
+  /* Set the final viewport */
+  XDGASetViewport (ptc_display, ptc_screen, 0, 0, XDGAFlipRetrace);
+  /* Select the input events that should be reported */
+  XDGASelectInput (ptc_display, ptc_screen, KeyPressMask | KeyReleaseMask);
+  /* Clear event queue */
+  XFlush (ptc_display);
+  /* Clear video memory */
+  memset (ptc_dga_device->data, 0x00, ptc_dga_video_length * 2);
+  /* Save the buffer size */
+  ptc_viewport_width = width;
+  ptc_viewport_height = height;
+  ptc_dga_first_page = False;
+  return PTC_SUCCESS;
+}
+
+/* Update the screen */
+
+int
+ptc_update (void *buffer)
+{
+  char *ptc_vram_pointer;
+
+  /* This is here just to keep the c++ compiler happy */
+  char *ptc_buffer;
+
+  ptc_buffer=(char *)buffer;
+
+  ptc_framebuffer_index = 0;
+#ifdef __PTC_ENABLE_CONVERSIONS__
+  ptc_source_index = 0;
+  ptc_destination_index = 0;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+
+  /* Get the right memory area to write into */
+  if (ptc_dga_first_page == True)
+    {
+      ptc_vram_pointer = ptc_dga_first_page_address;
+    }
+  else
+    {
+      ptc_vram_pointer = ptc_dga_second_page_address;
+    }
+
+  /* Do the blit line by line */
+  for (ptc_blitcounter = 0; ptc_blitcounter < ptc_viewport_height;
+       ptc_blitcounter++)
+    {
+#ifdef __PTC_ENABLE_CONVERSIONS__
+      /* Conversion */
+      ptc_convert (ptc_buffer + ptc_source_index,
+                  ptc_vram_pointer + ptc_destination_index,
+                  ptc_viewport_width);
+      /* Pointers update */
+      ptc_source_index += ptc_viewport_width * sizeof (int);
+      ptc_destination_index += ptc_dga_device->mode.bytesPerScanline;
+#else
+      /* Data copy */
+      memcpy (ptc_vram_pointer + ptc_framebuffer_index, ptc_buffer,
+             ptc_viewport_width * sizeof (int));
+      ptc_buffer += ptc_viewport_width * sizeof (int);
+      /* Set up offsets */
+      ptc_framebuffer_index += ptc_dga_device->mode.bytesPerScanline;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+    }
+
+  /* Wait for retrace */
+  while (XDGAGetViewportStatus (ptc_display, ptc_screen));
+
+  /* Flip the two pages */
+  if (ptc_dga_first_page == True)
+    {
+      XDGASetViewport (ptc_display, ptc_screen, 0, 0, XDGAFlipImmediate);
+    }
+  else
+    {
+      XDGASetViewport (ptc_display, ptc_screen, 0,
+                      ptc_dga_device->mode.viewportHeight,
+                      XDGAFlipImmediate);
+    }
+  ptc_dga_first_page = !ptc_dga_first_page;
+
+  /* Process incoming events */
+  if (ptc_process_events ())
+    {
+#ifdef __PTC_CLEANUP_CALLBACK__
+      ptc_cleanup_callback ();
+#endif /* __PTC_CLEANUP_CALLBACK__ */
+      ptc_close ();
+      exit (0);
+    }
+  return PTC_SUCCESS;
+}
+
+/* Process events */
+
+int
+ptc_process_events (void)
+{
+  XDGAEvent ptc_dga_event;
+  KeySym ptc_keysym;
+  XKeyEvent ptc_dga_keyevent;
+  /* Check if there are events waiting in the display's queue */
+  if (XPending (ptc_display))
+    {
+      /* Get the next event in queue */
+      XNextEvent (ptc_display, (XEvent *) & ptc_dga_event);
+      ptc_dga_event.type -= ptc_dga_event_base;
+
+      /* Check if it's a keypress event */
+      if (ptc_dga_event.type == KeyPress)
+       {
+         /* Translate the event */
+         XDGAKeyEventToXKeyEvent (&ptc_dga_event.xkey, &ptc_dga_keyevent);
+         /* Get the keysym */
+         ptc_keysym = XLookupKeysym (&ptc_dga_keyevent, 0);
+         /* Check if the key pressed was a function one */
+         if ((ptc_keysym >> 8) == __PTC_FUNCTION_KEY__)
+           {
+             /* Check if it was the escape key */
+             if ((ptc_keysym & 0xFF) == __PTC_ESCAPE_KEY__)
+               {
+                 return PTC_SUCCESS;
+               }
+           }
+       }
+    }
+  return PTC_FAILURE;
+}
+
+/* Close the screen */
+
+void
+ptc_close (void)
+{
+  /* Switch back to the previous video mode */
+  XDGASetMode (ptc_display, ptc_screen, 0);
+  /* Disable framebuffer access */
+  XDGACloseFramebuffer (ptc_display, ptc_screen);
+  /* Close the display */
+  XCloseDisplay (ptc_display);
+  /* Deallocate the buffer */
+  if (ptc_buffer)
+    {
+      free (ptc_buffer);
+    }
+}
+
+#endif /* __PTC_XDGA2__ */
diff --git a/bigscreen/tinyptc/xdga2.h b/bigscreen/tinyptc/xdga2.h
new file mode 100644 (file)
index 0000000..dc6ff36
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * TinyPTC x11 v0.7.3 X Direct Graphics Access Extension v2 target
+ * Copyright (C) 2001-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ * 
+ * http://www.sourceforge.net/projects/tinyptc/
+ * 
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef __PTC_XDGA2_H
+#define __PTC_XDGA2_H
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/xf86dga.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include "tinyptc.h"
+
+#ifdef __PTC_XDGA2__
+
+#ifdef __TINYPTC_INCLUDED
+#error You chose more than one target. Please make your mind and try again.
+#endif /* __TINYPTC_INCLUDED */
+
+#define __TINYPTC_INCLUDED
+#pragma target xdga2
+
+#ifdef __cplusplus
+       extern "C" {
+#endif /* __cplusplus */
+
+int ptc_open (char *title, int width, int height);
+int ptc_update (void *buffer);
+void ptc_close (void);
+int ptc_process_events (void);
+
+#ifdef __cplusplus
+       }
+#endif /* __cplusplus */
+
+#endif /* __PTC_XDGA2__ */
+
+#endif /* __PTC_XDGA2_H */
+
+#ifdef __PTC_FROM_SOURCE
+
+static Display *ptc_display;
+static int ptc_screen;
+static int ptc_screen_width;
+static int ptc_screen_height;
+static int ptc_viewport_width;
+static int ptc_viewport_height;
+static Visual *ptc_visual;
+static char *ptc_buffer;
+
+static int ptc_framebuffer_start;
+static int ptc_framebuffer_index;
+static int ptc_dga_event_base;
+static int ptc_error_base;
+static int ptc_blitcounter;
+static int ptc_dga_major_version;
+static int ptc_dga_minor_version;
+
+static int ptc_dga_video_length;
+static Bool ptc_dga_emulate_fullscreen;
+
+static int ptc_dga_output_pitch;
+static char *ptc_dga_framebuffer_address;
+static char *ptc_dga_first_page_address;
+static char *ptc_dga_second_page_address;
+static XDGAMode *ptc_dga_mode;
+static XDGADevice *ptc_dga_device;
+static Bool ptc_dga_first_page;
+static int ptc_dga_modes;
+static int ptc_dga_counter;
+static int ptc_dga_new_mode;
+
+#ifdef __PTC_ENABLE_CONVERSIONS__
+static int ptc_dga_mode_32;
+static int ptc_dga_mode_24;
+static int ptc_dga_mode_16;
+static int ptc_dga_mode_15;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+
+#ifdef __PTC_BEST_VIDEOMODE__
+#ifdef __PTC_ENABLE_CONVERSIONS__
+typedef struct
+{
+  int best_videomode;
+  int best_delta;
+}
+PTC_VIDEO_DATA;
+
+static PTC_VIDEO_DATA ptc_dga_32;
+static PTC_VIDEO_DATA ptc_dga_24;
+static PTC_VIDEO_DATA ptc_dga_16;
+static PTC_VIDEO_DATA ptc_dga_15;
+#else
+static int ptc_dga_best_videomode;
+static int ptc_dga_best_delta;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+static int ptc_dga_best_x_delta;
+static int ptc_dga_best_y_delta;
+#endif /* __PTC_BEST_VIDEOMODE__ */
+
+#ifdef __PTC_ENABLE_CONVERSIONS__
+PTC_CONVERTER ptc_convert;
+static int ptc_source_index;
+static int ptc_destination_index;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+
+#endif /* __PTC_FROM_SOURCE */
diff --git a/bigscreen/tinyptc/xlib.c b/bigscreen/tinyptc/xlib.c
new file mode 100644 (file)
index 0000000..2d2751b
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+ * TinyPTC x11 v0.7.3 Raw XLib target
+ * Copyright (C) 2000-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ * 
+ * http://www.sourceforge.net/projects/tinyptc/
+ * 
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/* #includes */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include "tinyptc.h"
+
+#ifdef __PTC_XLIB__
+
+#define __PTC_FROM_SOURCE
+
+#include "xlib.h"
+
+/* Open the screen */
+
+int
+ptc_open (char *title, int width, int height)
+{
+  /* Open a display on the current root window */
+  ptc_display = XOpenDisplay (NULL);
+  if (ptc_display == NULL)
+    {
+      return PTC_FAILURE;
+    }
+  /* Get the default screen associated with the previously opened display */
+  ptc_screen = DefaultScreen (ptc_display);
+  /* Get the default visual */
+  ptc_visual = DefaultVisual (ptc_display, ptc_screen);
+  /* Get screen bitdepth */
+  ptc_depth = DefaultDepth (ptc_display, ptc_screen);
+  /* Get a pointer to the supported pixmap formats */
+  ptc_pixmap_formats =
+    XListPixmapFormats (ptc_display, &ptc_pixmap_format_count);
+  /* Check if there's one that's suitable */
+  for (ptc_pixmap_counter = 0; ptc_pixmap_counter < ptc_pixmap_format_count;
+       ptc_pixmap_counter++)
+    {
+      if (ptc_depth == ptc_pixmap_formats[ptc_pixmap_counter].depth)
+       {
+         /* Set the right value */
+         ptc_converter_depth =
+           ptc_pixmap_formats[ptc_pixmap_counter].bits_per_pixel;
+       }
+    }
+  XFree (ptc_pixmap_formats);
+#ifdef __PTC_ENABLE_CONVERSIONS__
+  /* Check if a converter is avaliable */
+  ptc_convert =
+    ptc_request_converter (ptc_converter_depth, ptc_visual->red_mask,
+                          ptc_visual->green_mask, ptc_visual->blue_mask);
+  if (!ptc_convert)
+    {
+      /* Close the display */
+      XCloseDisplay (ptc_display);
+      return 0;
+    }
+  /* Get the actual bytes-per-pixel value */
+  switch (ptc_converter_depth)
+    {
+    case 8:
+      ptc_output_pitch = 1;
+      break;
+    case 15:
+      ptc_output_pitch = 2;
+      break;
+    case 16:
+      ptc_output_pitch = 2;
+      break;
+    case 24:
+      ptc_output_pitch = 3;
+      break;
+    case 32:
+      ptc_output_pitch = 4;
+      break;
+    }
+  /* Allocate the temporary buffer */
+  ptc_buffer = (char *) malloc (width * height * ptc_output_pitch);
+  if (ptc_buffer == NULL)
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+#else
+  /* It runs only on a 32bpp display if no conversions were activated */
+  if (ptc_converter_depth != 32)
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+  /* Get screen dimensions */
+  ptc_screen_width = DisplayWidth (ptc_display, ptc_screen);
+  ptc_screen_height = DisplayHeight (ptc_display, ptc_screen);
+  /* Get the default root window */
+  ptc_root_window = DefaultRootWindow (ptc_display);
+  /* Initialize window's attribute structure */
+  ptc_window_attributes.border_pixel = BlackPixel (ptc_display, ptc_screen);
+  ptc_window_attributes.background_pixel =
+    BlackPixel (ptc_display, ptc_screen);
+  ptc_window_attributes.backing_store = NotUseful;
+#ifdef __PTC_CENTER_WINDOW__
+  /* Center the window on the screen */
+  ptc_x_position = (ptc_screen_width - width) / 2;
+  ptc_y_position = (ptc_screen_height - height) / 2;
+#else
+  /* Dock the window on the top-left corner */
+  ptc_x_position = 0;
+  ptc_y_position = 0;
+#endif /* __PTC_CENTER_WINDOW__ */
+  /* Create the window */
+  ptc_window =
+    XCreateWindow (ptc_display, ptc_root_window, ptc_x_position,
+                  ptc_y_position, width, height, 0, ptc_depth, InputOutput,
+                  ptc_visual, CWBackPixel | CWBorderPixel | CWBackingStore,
+                  &ptc_window_attributes);
+  /* Set the window's name */
+  XStoreName (ptc_display, ptc_window, title);
+  /* Tell the server to report only keypress-related events */
+  XSelectInput (ptc_display, ptc_window, KeyPressMask | KeyReleaseMask);
+  /* Initialize window's sizehint definition structure */
+  ptc_window_sizehints.flags = PPosition | PMinSize | PMaxSize;
+  ptc_window_sizehints.x = 0;
+  ptc_window_sizehints.y = 0;
+  ptc_window_sizehints.min_width = width;
+  ptc_window_sizehints.max_width = width;
+  ptc_window_sizehints.min_height = height;
+  ptc_window_sizehints.max_height = height;
+  /* Set the window's sizehint */
+  XSetWMNormalHints (ptc_display, ptc_window, &ptc_window_sizehints);
+  /* Clear the window */
+  XClearWindow (ptc_display, ptc_window);
+  /* Put the window on top of the others */
+  XMapRaised (ptc_display, ptc_window);
+  /* Clear event queue */
+  XFlush (ptc_display);
+  /* Get the default graphic context */
+  ptc_window_gc = DefaultGC (ptc_display, ptc_screen);
+  /* Create an XImage */
+  ptc_ximage =
+    XCreateImage (ptc_display, CopyFromParent, ptc_depth, ZPixmap, 0, NULL,
+                 width, height, 32, width * ptc_output_pitch);
+  /* Save windowsize values */
+  ptc_viewport_width = width;
+  ptc_viewport_height = height;
+  return PTC_SUCCESS;
+}
+
+/* Update the screen */
+
+int
+ptc_update (void *buffer)
+{
+  char *ptc_buffer;
+
+  ptc_buffer=(char *)buffer;
+#ifdef __PTC_ENABLE_CONVERSIONS__
+  ptc_ximage->data = ptc_buffer;
+  ptc_source_index = 0;
+  ptc_destination_index = 0;
+  /* Convert the image line by line */
+  for (ptc_blitcounter = 0; ptc_blitcounter < ptc_viewport_height;
+       ptc_blitcounter++)
+    {
+      /* Conversion */
+      ptc_convert (ptc_buffer + ptc_source_index,
+                  (ptc_ximage->data) + ptc_destination_index,
+                  ptc_viewport_width);
+      /* Pointers update */
+      ptc_source_index += ptc_viewport_width * sizeof (int);
+      ptc_destination_index += ptc_viewport_width * ptc_output_pitch;
+    }
+#else
+  /* Set XImage's data buffer value with the supplied buffer pointer */
+  ptc_ximage->data = ptc_buffer;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+  /* Put the buffer on the window */
+  XPutImage (ptc_display, ptc_window, ptc_window_gc, ptc_ximage, 0, 0, 0, 0,
+            ptc_viewport_width, ptc_viewport_height);
+  /* Check for incoming events */
+  XFlush (ptc_display);
+  /* Process incoming events */
+  if (ptc_process_events ())
+    {
+#ifdef __PTC_CLEANUP_CALLBACK__
+      ptc_cleanup_callback ();
+#endif /* __PTC_CLEANUP_CALLBACK__ */
+      ptc_close ();
+      exit (0);
+    }
+  return PTC_SUCCESS;
+}
+
+/* Process events */
+
+int
+ptc_process_events (void)
+{
+  XEvent ptc_xevent;
+  KeySym ptc_keysym;
+  /* Check if there are events waiting in the display's queue */
+  if (XPending (ptc_display))
+    {
+      /* Get the next event in queue */
+      XNextEvent (ptc_display, &ptc_xevent);
+      /* Check if it's a keypress event */
+      if (ptc_xevent.type == KeyPress)
+       {
+         /* Get the keysym */
+         ptc_keysym = XLookupKeysym (&ptc_xevent.xkey, 0);
+         /* Check if the key pressed was a function one */
+         if ((ptc_keysym >> 8) == __PTC_FUNCTION_KEY__)
+           {
+             /* Check if it was the escape key */
+             if ((ptc_keysym & 0xFF) == __PTC_ESCAPE_KEY__)
+               {
+                 return PTC_SUCCESS;
+               }
+           }
+       }
+    }
+  return PTC_FAILURE;
+}
+
+/* Close the screen */
+
+void
+ptc_close (void)
+{
+  /* Restore XImage's buffer pointer */
+  ptc_ximage->data = NULL;
+  /* Destroy the XImage */
+  XDestroyImage (ptc_ximage);
+  /* Close the window */
+  XDestroyWindow (ptc_display, ptc_window);
+  /* Close the display */
+  XCloseDisplay (ptc_display);
+  /* Deallocate the buffer */
+  if (ptc_buffer)
+    {
+      free (ptc_buffer);
+    }
+}
+
+#endif /* __PTC_XLIB__ */
diff --git a/bigscreen/tinyptc/xlib.h b/bigscreen/tinyptc/xlib.h
new file mode 100644 (file)
index 0000000..00fe1e1
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * TinyPTC x11 v0.7.3 Raw XLib target
+ * Copyright (C) 2000-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ * 
+ * http://www.sourceforge.net/projects/tinyptc/
+ * 
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef __PTC_XLIB_H
+#define __PTC_XLIB_H
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include "tinyptc.h"
+
+#ifdef __PTC_XLIB__
+
+#ifdef __TINYPTC_INCLUDED
+#error You chose more than one target. Please make your mind and try again.
+#endif /* __TINYPTC_INCLUDED */
+
+#define __TINYPTC_INCLUDED
+#pragma target xlib
+
+#ifdef __cplusplus
+       extern "C" {
+#endif /* __cplusplus */
+
+int ptc_open (char *title, int width, int height);
+int ptc_update (void *buffer);
+void ptc_close (void);
+int ptc_process_events (void);
+
+#ifdef __cplusplus
+       }
+#endif /* __cplusplus */
+
+#endif /* __PTC_XLIB__ */
+
+#endif /* __PTC_XLIB_H */
+
+#ifdef __PTC_FROM_SOURCE
+
+static Display *ptc_display;
+static int ptc_screen;
+static int ptc_screen_width;
+static int ptc_screen_height;
+static int ptc_viewport_width;
+static int ptc_viewport_height;
+static int ptc_depth;
+static Window ptc_root_window;
+static Visual *ptc_visual;
+static char *ptc_buffer;
+static int ptc_pixmap_format_count;
+static int ptc_pixmap_counter;
+static int ptc_converter_depth;
+static XPixmapFormatValues *ptc_pixmap_formats;
+
+static Window ptc_window;
+static int ptc_x_position;
+static int ptc_y_position;
+static XSetWindowAttributes ptc_window_attributes;
+static XSizeHints ptc_window_sizehints;
+static GC ptc_window_gc;
+static XImage *ptc_ximage;
+
+#ifdef __PTC_ENABLE_CONVERSIONS__
+static PTC_CONVERTER ptc_convert;
+static int ptc_output_pitch;
+static int ptc_blitcounter;
+static int ptc_source_index;
+static int ptc_destination_index;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+
+#endif /* __PTC_FROM_SOURCE */
diff --git a/bigscreen/tinyptc/xshm.c b/bigscreen/tinyptc/xshm.c
new file mode 100644 (file)
index 0000000..db38951
--- /dev/null
@@ -0,0 +1,308 @@
+/*
+ * TinyPTC x11 v0.7.3 X Shared Memory Extension target
+ * Copyright (C) 2000-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ *
+ * http://www.sourceforge.net/projects/tinyptc/
+ *
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * 
+ */
+
+/* #includes */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/XShm.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include "tinyptc.h"
+
+#ifdef __PTC_XSHM__
+
+#define __PTC_FROM_SOURCE
+
+#include "xshm.h"
+
+/* Open the screen */
+
+int
+ptc_open (char *title, int width, int height)
+{
+  /* Open a display on the current root window */
+  ptc_display = XOpenDisplay (NULL);
+  if (ptc_display == NULL)
+    {
+      return PTC_FAILURE;
+    }
+  /* Get the default screen associated with the previously opened display */
+  ptc_screen = DefaultScreen (ptc_display);
+  /* Get the default visual */
+  ptc_visual = DefaultVisual (ptc_display, ptc_screen);
+  /* Get screen bitdepth */
+  ptc_depth = DefaultDepth (ptc_display, ptc_screen);
+  /* Get a pointer to the supported pixmap formats */
+  ptc_pixmap_formats =
+    XListPixmapFormats (ptc_display, &ptc_pixmap_format_count);
+  /* Check if there's one that's suitable */
+  for (ptc_pixmap_counter = 0; ptc_pixmap_counter < ptc_pixmap_format_count;
+       ptc_pixmap_counter++)
+    {
+      if (ptc_depth == ptc_pixmap_formats[ptc_pixmap_counter].depth)
+       {
+         /* Set the right value */
+         ptc_converter_depth =
+           ptc_pixmap_formats[ptc_pixmap_counter].bits_per_pixel;
+       }
+    }
+  XFree (ptc_pixmap_formats);
+#ifdef __PTC_ENABLE_CONVERSIONS__
+  /* Check if a converter is avaliable */
+  ptc_convert =
+    ptc_request_converter (ptc_converter_depth, ptc_visual->red_mask,
+                          ptc_visual->green_mask, ptc_visual->blue_mask);
+  if (!ptc_convert)
+    {
+      /* Close the display */
+      XCloseDisplay (ptc_display);
+      return 0;
+    }
+  /* Get the actual bytes-per-pixel value */
+  switch (ptc_converter_depth)
+    {
+    case 8:
+      ptc_output_pitch = 1;
+      break;
+    case 15:
+      ptc_output_pitch = 2;
+      break;
+    case 16:
+      ptc_output_pitch = 2;
+      break;
+    case 24:
+      ptc_output_pitch = 3;
+      break;
+    case 32:
+      ptc_output_pitch = 4;
+      break;
+    }
+  /* Allocate the temporary buffer */
+  ptc_buffer = (char *) malloc (width * height * ptc_output_pitch);
+  if (ptc_buffer == NULL)
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+#else
+  /* It runs only on a 32bpp display if no conversions were activated */
+  if (ptc_converter_depth != 32)
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+  /* Check for XShm extension */
+  if (!XShmQueryExtension (ptc_display))
+    {
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Get screen dimensions */
+  ptc_screen_width = DisplayWidth (ptc_display, ptc_screen);
+  ptc_screen_height = DisplayHeight (ptc_display, ptc_screen);
+  /* Get the default root window */
+  ptc_root_window = DefaultRootWindow (ptc_display);
+  /* Initialize window's attribute structure */
+  ptc_window_attributes.border_pixel = BlackPixel (ptc_display, ptc_screen);
+  ptc_window_attributes.background_pixel =
+    BlackPixel (ptc_display, ptc_screen);
+  ptc_window_attributes.backing_store = NotUseful;
+#ifdef __PTC_CENTER_WINDOW__
+  /* Center the window on the screen */
+  ptc_x_position = (ptc_screen_width - width) / 2;
+  ptc_y_position = (ptc_screen_height - height) / 2;
+#else
+  /* Dock the window on the top-left corner */
+  ptc_x_position = 0;
+  ptc_y_position = 0;
+#endif /* __PTC_CENTER_WINDOW__ */
+  /* Create the window */
+  ptc_window =
+    XCreateWindow (ptc_display, ptc_root_window, ptc_x_position,
+                  ptc_y_position, width, height, 0, ptc_depth, InputOutput,
+                  ptc_visual, CWBackPixel | CWBorderPixel | CWBackingStore,
+                  &ptc_window_attributes);
+  /* Set the window's name */
+  XStoreName (ptc_display, ptc_window, title);
+  /* Tell the server to report only keypress-related events */
+  XSelectInput (ptc_display, ptc_window, KeyPressMask | KeyReleaseMask);
+  /* Initialize window's sizehint definition structure */
+  ptc_window_sizehints.flags = PPosition | PMinSize | PMaxSize;
+  ptc_window_sizehints.x = 0;
+  ptc_window_sizehints.y = 0;
+  ptc_window_sizehints.min_width = width;
+  ptc_window_sizehints.max_width = width;
+  ptc_window_sizehints.min_height = height;
+  ptc_window_sizehints.max_height = height;
+  /* Set the window's sizehint */
+  XSetWMNormalHints (ptc_display, ptc_window, &ptc_window_sizehints);
+  /* Clear the window */
+  XClearWindow (ptc_display, ptc_window);
+  /* Put the window on top of the others */
+  XMapRaised (ptc_display, ptc_window);
+  /* Clear event queue */
+  XFlush (ptc_display);
+  /* Get the default graphic context */
+  ptc_window_gc = DefaultGC (ptc_display, ptc_screen);
+  /* Create an XShmImage */
+  ptc_ximage =
+    XShmCreateImage (ptc_display, ptc_visual, ptc_depth, ZPixmap, 0,
+                    &ptc_shm_segment, width, height);
+  /* Get a shared segment */
+  ptc_shm_segment.shmid =
+    shmget (IPC_PRIVATE, ptc_ximage->bytes_per_line * ptc_ximage->height,
+           IPC_CREAT | 0777);
+  /* Initialize XShmImage data buffer pointer */
+  ptc_ximage->data = (char *)shmat (ptc_shm_segment.shmid, 0, 0);
+  /* Save buffer address */
+  ptc_shm_segment.shmaddr = ptc_ximage->data;
+  /* Put the segment in read/write */
+  ptc_shm_segment.readOnly = False;
+  /* Attach the segment to the display */
+  if (!XShmAttach (ptc_display, &ptc_shm_segment))
+    {
+      /* Destroy the image */
+      XDestroyImage (ptc_ximage);
+      /* Detach the buffer from the segment */
+      shmdt (ptc_shm_segment.shmaddr);
+      /* Remove the segment */
+      shmctl (ptc_shm_segment.shmid, IPC_RMID, 0);
+      /* Destroy the window */
+      XDestroyWindow (ptc_display, ptc_window);
+      /* Close the display */
+      XCloseDisplay (ptc_display);
+      return PTC_FAILURE;
+    }
+  /* Save windowsize values */
+  ptc_viewport_width = width;
+  ptc_viewport_height = height;
+  return PTC_SUCCESS;
+}
+
+/* Update the screen */
+
+int
+ptc_update (void *buffer)
+{ 
+  char *ptc_buffer;
+               
+  ptc_buffer=(char *)buffer;
+  /* Copy buffer data into the XShmImage */
+#ifdef __PTC_ENABLE_CONVERSIONS__
+  ptc_source_index = 0;
+  ptc_destination_index = 0;
+  /* Convert the image line by line */
+  for (ptc_blitcounter = 0; ptc_blitcounter < ptc_viewport_height;
+       ptc_blitcounter++)
+    {
+      /* Conversion */
+      ptc_convert (ptc_buffer + ptc_source_index,
+                  (ptc_ximage->data) + ptc_destination_index,
+                  ptc_viewport_width);
+      /* Pointers update */
+      ptc_source_index += ptc_viewport_width * sizeof (int);
+      ptc_destination_index += ptc_viewport_width * ptc_output_pitch;
+    }
+#else
+  /* Blit the image */
+  memcpy (ptc_ximage->data, buffer,
+         ptc_viewport_width * ptc_viewport_height * sizeof (int));
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+  /* Synchronize the event queue */
+  XSync (ptc_display, 0);
+  /* Put the buffer on the window */
+  XShmPutImage (ptc_display, ptc_window, ptc_window_gc, ptc_ximage, 0, 0, 0,
+               0, ptc_viewport_width, ptc_viewport_height, False);
+  /* Process incoming events */
+  if (ptc_process_events ())
+    {
+#ifdef __PTC_CLEANUP_CALLBACK__
+      ptc_cleanup_callback ();
+#endif /* __PTC_CLEANUP_CALLBACK__ */
+      ptc_close ();
+      exit (0);
+    }
+  return PTC_SUCCESS;
+}
+
+/* Process events */
+
+int
+ptc_process_events (void)
+{
+  XEvent ptc_xevent;
+  KeySym ptc_keysym;
+  /* Check if there are events waiting in the display's queue */
+  if (XPending (ptc_display))
+    {
+      /* Get the next event in queue */
+      XNextEvent (ptc_display, &ptc_xevent);
+      /* Check if it's a keypress event */
+      if (ptc_xevent.type == KeyPress)
+       {
+         /* Get the keysym */
+         ptc_keysym = XLookupKeysym (&ptc_xevent.xkey, 0);
+         /* Check if the key pressed was a function one */
+         if ((ptc_keysym >> 8) == __PTC_FUNCTION_KEY__)
+           {
+             /* Check if it was the escape key */
+             if ((ptc_keysym & 0xFF) == __PTC_ESCAPE_KEY__)
+               {
+                 return PTC_SUCCESS;
+               }
+           }
+       }
+    }
+  return PTC_FAILURE;
+}
+
+/* Close the screen */
+
+void
+ptc_close (void)
+{
+  /* Detach the segment from the display */
+  XShmDetach (ptc_display, &ptc_shm_segment);
+  /* Destroy the XShmImage */
+  XDestroyImage (ptc_ximage);
+  /* Detach the buffer from the segment */
+  shmdt (ptc_shm_segment.shmaddr);
+  /* Remove the segment */
+  shmctl (ptc_shm_segment.shmid, IPC_RMID, 0);
+  /* Close the window */
+  XDestroyWindow (ptc_display, ptc_window);
+  /* Close the display */
+  XCloseDisplay (ptc_display);
+  /* Deallocate the buffer */
+  if (ptc_buffer)
+    {
+      free (ptc_buffer);
+    }
+}
+
+#endif /* __PTC_XSHM__ */
diff --git a/bigscreen/tinyptc/xshm.h b/bigscreen/tinyptc/xshm.h
new file mode 100644 (file)
index 0000000..4ffac19
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * TinyPTC x11 v0.7.3 X Shared Memory Extension target
+ * Copyright (C) 2000-2002 Alessandro Gatti <a.gatti@tiscali.it>
+ *
+ * http://www.sourceforge.net/projects/tinyptc/
+ *
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * 
+ */
+
+#ifndef __PTC_XSHM_H
+#define __PTC_XSHM_H
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/XShm.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include "tinyptc.h"
+
+#ifdef __PTC_XSHM__
+
+#ifdef __TINYPTC_INCLUDED
+#error You chose more than one target. Please make your mind and try again.
+#endif /* __TINYPTC_INCLUDED */
+
+#define __TINYPTC_INCLUDED
+#pragma target xshm
+
+#ifdef __cplusplus
+       extern "C" {
+#endif
+
+int ptc_open (char *title, int width, int height);
+int ptc_update (void *buffer);
+void ptc_close (void);
+int ptc_process_events (void);
+
+#ifdef __cplusplus
+       }
+#endif /* __cplusplus */
+
+#endif /* __PTC_XSHM__ */
+
+#endif /* __PTC_XSHM_H */
+
+#ifdef __PTC_FROM_SOURCE
+
+static Display *ptc_display;
+static int ptc_screen;
+static int ptc_screen_width;
+static int ptc_screen_height;
+static int ptc_viewport_width;
+static int ptc_viewport_height;
+static int ptc_depth;
+static Window ptc_root_window;
+static Visual *ptc_visual;
+static char *ptc_buffer;
+static int ptc_pixmap_format_count;
+static int ptc_pixmap_counter;
+static int ptc_converter_depth;
+static XPixmapFormatValues *ptc_pixmap_formats;
+
+static Window ptc_window;
+static int ptc_x_position;
+static int ptc_y_position;
+static XSetWindowAttributes ptc_window_attributes;
+static XSizeHints ptc_window_sizehints;
+static GC ptc_window_gc;
+static XImage *ptc_ximage;
+
+static XShmSegmentInfo ptc_shm_segment;
+
+#ifdef __PTC_ENABLE_CONVERSIONS__
+static PTC_CONVERTER ptc_convert;
+static int ptc_output_pitch;
+static int ptc_blitcounter;
+static int ptc_source_index;
+static int ptc_destination_index;
+#endif /* __PTC_ENABLE_CONVERSIONS__ */
+
+#endif /* __PTC_FROM_SOURCE */
diff --git a/bigscreen/tinyptc/xvshm.c b/bigscreen/tinyptc/xvshm.c
new file mode 100644 (file)
index 0000000..cfc1b7a
--- /dev/null
@@ -0,0 +1,390 @@
+/*
+ * TinyPTC x11 v0.7.3 XVideo with Shared Memory Extension target
+ * Copyright (C) 2002 Fred Howell <foohoo@shaw.ca>
+ * Copyright (C) 2002 Alessandro Gatti <a.gatti@tiscali.it>
+ *
+ * http://www.sourceforge.net/projects/tinyptc/
+ *
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/* #includes */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <X11/extensions/XShm.h>
+#include <X11/extensions/Xvlib.h>
+#include "tinyptc.h"
+
+#ifdef __PTC_XVSHM__
+
+#define __PTC_FROM_SOURCE
+
+#include "xvshm.h"
+
+/* Open the screen */
+
+int
+ptc_open (char *title, int width, int height)
+{
+       unsigned int xvver,xvrel,xvreqbase,xvevbase,xverrbase;
+       int i,j,k;
+       int nAdaptors;
+       XvAdaptorInfo *adaptors;
+       int nFmts;
+       XvImageFormatValues *fmts;
+
+#ifdef __PTC_MMX__
+       /* Round down width and height for MMX routine */
+       width -= (width % 8);
+       height -= (height % 2);
+#else
+       yuvbuf_init();
+#endif
+
+  /* Open a display on the current root window */
+  ptc_display = XOpenDisplay (NULL);
+  if (ptc_display == NULL)
+    {
+      return 0;
+    }
+  /* Get the default screen associated with the previously opened display */
+  ptc_screen = DefaultScreen (ptc_display);
+  /* Get the default visual */
+  ptc_visual = DefaultVisual (ptc_display, ptc_screen);
+  ptc_xv_ok = 1;
+  if (XvQueryExtension(ptc_display,&xvver,&xvrel,
+               &xvreqbase,&xvevbase,&xverrbase) != Success) {
+         ptc_xv_ok = 0;
+  }
+  if (ptc_xv_ok == 0) return 0;
+  /* Check for XShm extension */
+  if (!XShmQueryExtension (ptc_display))
+    {
+      XCloseDisplay (ptc_display);
+      return 0;
+    }
+  /* Get screen dimensions */
+  ptc_screen_width = DisplayWidth (ptc_display, ptc_screen);
+  ptc_screen_height = DisplayHeight (ptc_display, ptc_screen);
+  /* Get the default root window */
+  ptc_root_window = DefaultRootWindow (ptc_display);
+  /* Initialize window's attribute structure */
+  ptc_window_attributes.border_pixel = BlackPixel (ptc_display, ptc_screen);
+  ptc_window_attributes.background_pixel =
+    BlackPixel (ptc_display, ptc_screen);
+  ptc_window_attributes.backing_store = NotUseful;
+#ifdef __PTC_CENTER_WINDOW__
+  /* Center the window on the screen */
+  ptc_x_position = (ptc_screen_width - width) / 2;
+  ptc_y_position = (ptc_screen_height - height) / 2;
+#else
+  /* Dock the window on the top-left corner */
+  ptc_x_position = 0;
+  ptc_y_position = 0;
+#endif /* __PTC_CENTER_WINDOW__ */
+  /* Create the window */
+  ptc_window =
+    XCreateWindow (ptc_display, ptc_root_window, ptc_x_position,
+                  ptc_y_position, width, height, 0, ptc_depth, InputOutput,
+                  ptc_visual, CWBackPixel | CWBorderPixel | CWBackingStore,
+                  &ptc_window_attributes);
+  /* Set the window's name */
+  XStoreName (ptc_display, ptc_window, title);
+  /* Tell the server to report only keypress-related events */
+  XSelectInput (ptc_display, ptc_window, KeyPressMask);
+  /* Initialize window's sizehint definition structure */
+  /* Clear the window */
+  XClearWindow (ptc_display, ptc_window);
+  /* Put the window on top of the others */
+  XMapRaised (ptc_display, ptc_window);
+  /* Clear event queue */
+  XFlush (ptc_display);
+  /* Get the default graphic context */
+  ptc_window_gc = DefaultGC (ptc_display, ptc_screen);
+  do {
+         if (ptc_xv_ok == 0) break;
+         if (XvQueryAdaptors(ptc_display,ptc_window,&nAdaptors,&adaptors) != Success) {
+                 ptc_xv_ok = 0;
+                 break;
+         }
+         ptc_xv_ok = 0;
+         for (i = 0; i < nAdaptors; i++) {
+                 for (j = 0; j < adaptors[i].num_ports; j++) {
+                         if (!(adaptors[i].type && XvInputMask) || !(adaptors[i].type && XvImageMask)) continue;
+                         fmts = XvListImageFormats(ptc_display,adaptors[i].base_id + j, &nFmts);
+                         if (fmts == NULL) continue;
+                         for (k = 0; k < nFmts; k++) {
+                                 if (fmts[k].id == 0x32315659) {
+                                         if (fmts[k].guid[0] != 'Y') break;
+                                         if (fmts[k].guid[1] != 'V') break;
+                                         if (fmts[k].guid[2] != '1') break;
+                                         if (fmts[k].guid[3] != '2') break;
+                                         if (XvGrabPort(ptc_display,adaptors[i].base_id + j,0) == Success) {
+                                               ptc_xv_ok = 1;
+                                               ptc_xv_port = adaptors[i].base_id + j;
+                                         }
+                                         break;
+                                 }
+                         }
+                         XFree(fmts);
+                         if (ptc_xv_ok == 1) break;
+                 }
+                 if (ptc_xv_ok == 1) break;
+         }
+         XvFreeAdaptorInfo(adaptors);
+         if (ptc_xv_ok == 0) {
+             /* Destroy the window */
+             XDestroyWindow (ptc_display, ptc_window);
+             /* Close the display */
+             XCloseDisplay (ptc_display);
+             ptc_xv_ok = 0;
+             return 0;
+         }
+  } while (0);
+  if (ptc_xv_ok == 0) return 0;
+  /* Get a shared segment */
+  ptc_shm_segment.shmid =
+    shmget (IPC_PRIVATE, width * height + (width * height)/2,
+           IPC_CREAT | 0777);
+  /* Save buffer address */
+  ptc_shm_segment.shmaddr = shmat(ptc_shm_segment.shmid,0,0);
+  /* Put the segment in read/write */
+  ptc_shm_segment.readOnly = False;
+  /* Attach the segment to the display */
+  if (!XShmAttach (ptc_display, &ptc_shm_segment))
+    {
+      /* Detach the buffer from the segment */
+      shmdt (ptc_shm_segment.shmaddr);
+      /* Remove the segment */
+      shmctl (ptc_shm_segment.shmid, IPC_RMID, 0);
+      /* Destroy the window */
+      XvUngrabPort(ptc_display,ptc_xv_port,0);
+      XDestroyWindow (ptc_display, ptc_window);
+      /* Close the display */
+      XCloseDisplay (ptc_display);
+      ptc_xv_ok = 0;
+      return 0;
+    }
+  ptc_xvimage = XvShmCreateImage(ptc_display,ptc_xv_port,0x32315659,ptc_shm_segment.shmaddr,
+                 width,height,&ptc_shm_segment);
+  if (ptc_xvimage == NULL) {
+      /* Detach the buffer from the segment */
+      shmdt (ptc_shm_segment.shmaddr);
+      /* Remove the segment */
+      shmctl (ptc_shm_segment.shmid, IPC_RMID, 0);
+      /* Destroy the window */
+      XvUngrabPort(ptc_display,ptc_xv_port,0);
+      XDestroyWindow (ptc_display, ptc_window);
+      /* Close the display */
+      XCloseDisplay (ptc_display);
+      ptc_xv_ok = 0;
+      return 0;
+   }
+  ptc_viewport_width = width;
+  ptc_viewport_height = height;
+  return 1;
+}
+
+/* Update the screen */
+
+int
+ptc_update (void *buffer)
+{
+       int wsize,hsize,dum1,dum2,dum3,dum4;
+       unsigned char *pin, *py,*pu,*pv,*pfin;
+       int strid8,strid2,stridby2;
+       Window wndret;
+  if (ptc_xv_ok == 1) {
+         if (!XGetGeometry(ptc_display,ptc_window,&wndret,&dum1,&dum2,
+                                 &wsize,&hsize,&dum3,&dum4)) {
+                 wsize = ptc_viewport_width;
+                 hsize = ptc_viewport_height;
+         }
+         pin = (unsigned char *)buffer;
+         py = ptc_shm_segment.shmaddr;
+         pu = &py[ptc_viewport_width*ptc_viewport_height];
+         pv = &pu[(ptc_viewport_width*ptc_viewport_height)/4];
+         strid8 = ptc_viewport_width*8;
+         strid2 = ptc_viewport_width*2;
+         stridby2 = ptc_viewport_width/2;
+         pfin = pu;
+         while (py < pfin) {
+#ifdef __PTC_MMX__
+               convert_yv12_mmx(pin,py,pu,pv,ptc_viewport_width);
+#else
+               convert_yv12_c(pin,py,pu,pv,ptc_viewport_width);
+#endif
+               pin += strid8;
+               py += strid2;
+               pu += stridby2;
+               pv += stridby2;
+         }
+         XvShmPutImage(ptc_display,ptc_xv_port,ptc_window,ptc_window_gc,
+                       ptc_xvimage,0,0,ptc_viewport_width,ptc_viewport_height,0,0,wsize,hsize,True);
+         XFlush(ptc_display);
+  }
+  if (ptc_process_events ())
+    {
+      ptc_close ();
+      exit (0);
+    }
+  return 1;
+}
+
+/* Process events */
+
+int
+ptc_process_events (void)
+{
+  XEvent ptc_xevent;
+  KeySym ptc_keysym;
+  /* Check if there are events waiting in the display's queue */
+  if (XPending (ptc_display))
+    {
+      /* Get the next event in queue */
+      XNextEvent (ptc_display, &ptc_xevent);
+      /* Check if it's a keypress event */
+      if (ptc_xevent.type == KeyPress)
+               {
+                 /* Get the keysym */
+                 ptc_keysym = XLookupKeysym (&ptc_xevent.xkey, 0);
+                 /* Check if the key pressed was a function one */
+                 if ((ptc_keysym >> 8) == __PTC_FUNCTION_KEY__)
+                   {
+                     /* Check if it was the escape key */
+                     if ((ptc_keysym & 0xFF) == __PTC_ESCAPE_KEY__)
+                               {
+                                 return 1;
+                               }
+                   }
+               }
+    }
+  return 0;
+}
+
+/* Close the screen */
+
+void
+ptc_close (void)
+{
+  if (ptc_xv_ok == 1) {
+         XFree(ptc_xvimage);
+  }
+  /* Detach the segment from the display */
+  XShmDetach (ptc_display, &ptc_shm_segment);
+  /* Destroy the XShmImage */
+  /* Detach the buffer from the segment */
+  shmdt (ptc_shm_segment.shmaddr);
+  /* Remove the segment */
+  shmctl (ptc_shm_segment.shmid, IPC_RMID, 0);
+         XvUngrabPort(ptc_display,ptc_xv_port,0);
+  /* Close the window */
+  XDestroyWindow (ptc_display, ptc_window);
+  XCloseDisplay (ptc_display);
+  /* Deallocate the buffer */
+  if (ptc_buffer)
+    {
+      free (ptc_buffer);
+      ptc_buffer = NULL;
+    }
+  ptc_xv_ok = 0;
+}
+
+#ifndef __PTC_MMX__
+
+/* very slow conversion routine - just for reference */
+static unsigned int ybufr[256];
+static unsigned int ybufg[256];
+static unsigned int ybufb[256];
+static unsigned char ubuf[512];
+static unsigned char vbuf[512];
+static unsigned char *uptr;
+static unsigned char *vptr;
+
+void yuvbuf_init()
+{
+       unsigned char c,c2;
+       int i,j;
+
+       uptr = &ubuf[255];
+       vptr = &vbuf[255];
+       for (i = 0, c = 0; i < 256; i++, c++) {
+               ybufr[i] = 9798*c;
+               ybufg[i] = 19235*c;
+               ybufb[i] = 3736*c;
+       }
+       c2 = 255;
+       for (j = 0, c = 0; j < 256; j++, c++) {
+               ubuf[j] = ((16122*(c-c2))>>15)+128;
+               vbuf[j] = ((25203*(c-c2))>>15)+128;
+       }
+       c2 = 0;
+       for (j = 256, c = 1; j < 511; j++, c++) {
+               ubuf[j] = ((16122*(c-c2))>>15)+128;
+               vbuf[j] = ((25203*(c-c2))>>15)+128;
+       }
+}
+
+void inline getyuv2(unsigned char *c, unsigned char *y, unsigned char *u, unsigned char *v)
+{
+       *y = (ybufr[c[0]] + ybufg[c[1]] + ybufb[c[2]]) >> 15;
+       *u = uptr[c[2]-*y];
+       *v = vptr[c[0]-*y];
+}
+
+void convert_yv12_c(void *expix2, unsigned char *py, unsigned char *pu, unsigned char *pv, int width)
+{
+       unsigned char *l,*nl;
+       unsigned int j;
+       unsigned char u1,u2,u3,u4;
+       unsigned char v1,v2,v3,v4;
+       unsigned int tmp1,tmp2;
+       unsigned char *pny;
+
+       l = (unsigned char *)expix2;
+
+
+       nl = &l[4*width];
+       pny = &py[width];
+
+
+               for (j = 0; j < width; j += 2) {
+                       getyuv2(l,&py[0],&u1,&v1);
+                       getyuv2(&l[4],&py[1],&u2,&v2);
+                       getyuv2(nl,&pny[0],&u3,&v3);
+                       getyuv2(&nl[4],&pny[1],&u4,&v4);
+                       tmp1 = u1 + u2 + u3 + u4 + 2;
+                       tmp2 = v1 + v2 + v3 + v4 + 2;
+                       pu[0] = (unsigned char)(tmp1 >> 2);
+                       pv[0] = (unsigned char)(tmp2 >> 2);
+                       py += 2;
+                       pny += 2;
+                       pu ++;
+                       pv ++;
+                       l += 8;
+                       nl += 8;
+               } 
+}
+
+#endif /* !__PTC_MMX__ */
+
+#endif /* __PTC_XVSHM__ */
diff --git a/bigscreen/tinyptc/xvshm.h b/bigscreen/tinyptc/xvshm.h
new file mode 100644 (file)
index 0000000..10d61ab
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * TinyPTC x11 v0.7.3 XVideo with Shared Memory Extension target
+ * Copyright (C) 2002 Fred Howell <foohoo@shaw.ca>
+ * Copyright (C) 2002 Alessandro Gatti <a.gatti@tiscali.it>
+ *
+ * http://www.sourceforge.net/projects/tinyptc/
+ *
+ * This library 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 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef __PTC_XVSHM_H
+#define __PTC_XVSHM_H
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <X11/extensions/XShm.h>
+#include <X11/extensions/Xvlib.h>
+#include "tinyptc.h"
+
+#ifdef __PTC_XVSHM__
+
+#ifdef __TINYPTC_INCLUDED
+#error You chose more than one target. Please make your mind and try again.
+#endif /* __TINYPTC_INCLUDED */
+
+#define __TINYPTC_INCLUDED
+#define pragma target xvshm
+
+#ifdef __cplusplus
+       extern "C" {
+#endif /* __cplusplus */
+
+int ptc_open (char *title, int width, int height);
+int ptc_update (void *buffer);
+void ptc_close (void);
+int ptc_process_events (void);
+
+#ifdef __PTC_MMX__
+void convert_yv12_mmx(void *pin, void *py, void *pu, void *pv, int stride);
+#else
+void yuvbuf_init();
+void convert_yv12_c(void *pin, unsigned char *py, unsigned char *pu, unsigned char *pv, int stride);
+#endif /* __PTC_MMX__ */
+
+#ifdef __cplusplus
+       }
+#endif /* __cplusplus */
+
+#endif /* __PTC_XVSHM__ */
+
+#endif /* __PTC_XVSHM_H */
+
+#ifdef __PTC_FROM_SOURCE
+
+static Display *ptc_display;
+static int ptc_screen, ptc_screen_width, ptc_screen_height,
+  ptc_viewport_width, ptc_viewport_height, ptc_depth;
+static Window ptc_root_window;
+static Visual *ptc_visual;
+static char *ptc_buffer = NULL;
+
+static Window ptc_window;
+static int ptc_x_position, ptc_y_position;
+static XSetWindowAttributes ptc_window_attributes;
+static GC ptc_window_gc;
+
+static XShmSegmentInfo ptc_shm_segment;
+static int ptc_xv_ok;
+static XvImage *ptc_xvimage;
+static XvPortID ptc_xv_port;
+
+
+#endif /* __PTC_FROM_SOURCE */
diff --git a/bigscreen/tinyptc/yv12.s b/bigscreen/tinyptc/yv12.s
new file mode 100644 (file)
index 0000000..aa158c2
--- /dev/null
@@ -0,0 +1,594 @@
+;
+; TinyPTC x11 v0.7.3 MMX-Optimized YV12 converter
+; Copyright (C) 2002 Fred Howell <foohoo@shaw.ca>
+;
+; http://www.sourceforge.net/projects/tinyptc/
+;
+; This library 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 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
+; Lesser General Public License for more details.
+;
+; You should have received a copy of the GNU Lesser General Public
+; License along with this library; if not, write to the Free Software
+; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+;
+
+bits 32
+
+global convert_yv12_mmx
+
+section .data
+
+align 16
+
+;      static short ygr0bcoff[] = {33058/2,16390/2,0,6405/2};
+;      static short vgr0bcoff[] = {-24110/2,28781/2,0,-4671/2};
+;      static short ugr0bcoff[] = {-19068/2,-9713/2,0,28781/2};
+;      static short yb0grcoff[] = {6405/2,0,33058/2,16390/2};
+;      static short vb0grcoff[] = {-4671/2,0,-24110/2,28781/2};
+;      static short ub0grcoff[] = {28781/2,-19068/2,-9713/2,0};
+;
+;      static unsigned short add2w[] = {1,1,1,1};
+;      static short aoff[] = {16,128,16,128};
+;      static unsigned char bmask[] = {0xff, 0, 0, 0, 0, 0, 0, 0};
+;      static unsigned short grmask[] = {0,0xffff,0,0};
+
+thezero dw  0,0,0,0
+ygr0bcoff dw 0x4091,0x2003,0x0000,0x0c82
+ugr0bcoff dw 0xdac2,0xed08,0x0000,0x3836
+vgr0bcoff dw 0xd0e9,0x3836,0x0000,0xf6e1
+yb0grcoff dw 0x0c82,0x0000,0x4091,0x2003
+ub0grcoff dw 0x3836,0x0000,0xdac2,0xed08
+vb0grcoff dw 0xf6e1,0x0000,0xd0e9,0x3836
+yoff  dw 0x0010,0x0010,0x0010,0x0010
+uvoff  dw 0x0080,0x0080,0x0080,0x0080
+add2w dw 1,1,1,1
+grmask dw  0,0xffff,0,0
+bmask  db 0xff,0,0,0, 0,0,0,0
+
+
+section text
+
+align 16
+
+convert_yv12_mmx:
+
+push ebp
+push eax
+push ebx
+push ecx
+push edx
+push edi
+push esi
+
+;// initialisation du mm7 à zero
+pxor mm7,mm7
+
+%assign _P 7*4
+mov edx, [esp+_P+ 4]
+mov ebx, [esp+_P+8]
+mov ebp,[esp+_P+12]
+mov eax,[esp+_P+16]
+mov ecx,[esp+_P+20]
+mov edi,ecx
+mov esi,ecx
+shr ecx, 3
+shl edi, 2
+
+
+.while:
+; 1ere quad 1ere ligne
+       movq mm3, [edx];
+       movq mm1,mm3;
+       psrlq mm3,8;
+       movq mm4,mm1;
+       psrlq mm1, 24;
+       pand mm4, [bmask];
+       pand mm1, [grmask];
+       por  mm4, mm1;
+       punpcklbw mm3, [thezero];
+       punpcklbw mm4, [thezero];
+
+; Y
+       movq mm5, mm3;
+                       
+       pmaddwd mm5, [ygr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [yb0grcoff];
+
+       paddd mm5, mm1
+       psrad mm5,15;
+                       
+
+; U
+       movq mm6, mm3;
+                       
+       pmaddwd mm6, [ugr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [ub0grcoff];
+
+       paddd mm6, mm1;
+       psrad mm6,15;
+
+
+; V
+       
+       pmaddwd mm3, [vgr0bcoff];
+
+
+       pmaddwd mm4, [vb0grcoff];
+
+       paddd mm3, mm4;
+       psrad mm3,15;
+
+       movq mm7, mm3;
+
+; 1ere quad 2eme ligne
+       movq mm3, [edx+edi];
+       movq mm1,mm3;
+       psrlq mm3,8;
+       movq mm4,mm1;
+       psrlq mm1, 24;
+       pand mm4, [bmask];
+       pand mm1, [grmask];
+       por  mm4, mm1;
+       punpcklbw mm3, [thezero];
+       punpcklbw mm4, [thezero];
+
+
+; Y
+       movq mm2, mm3;
+                       
+       pmaddwd mm2, [ygr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [yb0grcoff];
+
+       paddd mm2, mm1
+       psrad mm2,15;
+
+; U
+       movq mm0, mm3;
+                       
+       pmaddwd mm0, [ugr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [ub0grcoff];
+
+       paddd mm0, mm1;
+       psrad mm0,15;
+
+       packssdw mm6,mm0;
+       pmaddwd mm6,[add2w];
+
+       packssdw mm6,[thezero];
+; V
+       
+       pmaddwd mm3, [vgr0bcoff];
+
+
+       pmaddwd mm4, [vb0grcoff];
+
+       paddd mm3, mm4;
+       psrad mm3,15;
+
+       packssdw mm7,mm3;
+       pmaddwd mm7,[add2w];
+
+       packssdw mm7,[thezero];
+
+; 2eme quad 1ere ligne
+       movq mm3, [edx+8];
+       movq mm1,mm3;
+       psrlq mm3,8;
+       movq mm4,mm1;
+       psrlq mm1, 24;
+       pand mm4, [bmask];
+       pand mm1, [grmask];
+       por  mm4, mm1;
+       punpcklbw mm3, [thezero];
+       punpcklbw mm4, [thezero];
+
+; Y
+       movq mm0, mm3;
+                       
+       pmaddwd mm0, [ygr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [yb0grcoff];
+
+       paddd mm0, mm1
+       psrad mm0,15;
+       packssdw mm5,mm0
+                       
+       paddw mm5,[yoff]
+       packuswb mm5,mm5
+
+       movd [ebx], mm5
+
+; U
+       movq mm0, mm3;
+                       
+       pmaddwd mm0, [ugr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [ub0grcoff];
+
+       paddd mm0, mm1;
+       psrad mm0,15;
+
+       packssdw mm0,mm0
+       psllq mm0,32
+
+       paddw mm6,mm0
+
+
+; V
+       
+       pmaddwd mm3, [vgr0bcoff];
+
+
+       pmaddwd mm4, [vb0grcoff];
+
+       paddd mm3, mm4;
+       psrad mm3,15;
+
+       packssdw mm3,mm3
+       psllq mm3,32
+
+       paddw mm7,mm3
+
+; 2eme quad 2eme ligne
+       movq mm3, [edx+edi+8];
+       movq mm1,mm3;
+       psrlq mm3,8;
+       movq mm4,mm1;
+       psrlq mm1, 24;
+       pand mm4, [bmask];
+       pand mm1, [grmask];
+       por  mm4, mm1;
+       punpcklbw mm3, [thezero];
+       punpcklbw mm4, [thezero];
+
+
+; Y
+       movq mm0, mm3;
+                       
+       pmaddwd mm0, [ygr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [yb0grcoff];
+
+       paddd mm0, mm1
+       psrad mm0,15;
+       packssdw mm2,mm0
+
+       paddw mm2,[yoff]
+       packuswb mm2,mm2
+
+       movd [ebx+esi], mm2
+
+; U
+       movq mm0, mm3;
+                       
+       pmaddwd mm0, [ugr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [ub0grcoff];
+
+       paddd mm0, mm1;
+       psrad mm0,15;
+
+       packssdw mm0,mm0
+       psllq mm0,32
+
+       paddw mm6,mm0
+       pmaddwd mm6,[add2w]
+       packssdw mm6,[thezero]
+; V
+       
+       pmaddwd mm3, [vgr0bcoff];
+
+
+       pmaddwd mm4, [vb0grcoff];
+
+       paddd mm3, mm4;
+       psrad mm3,15;
+
+       packssdw mm3,mm3
+       psllq mm3,32
+
+       paddw mm7,mm3
+       pmaddwd mm7,[add2w]
+       packssdw mm7,[thezero]
+
+; 3eme quad 1ere ligne
+       movq mm3, [edx+16];
+       movq mm1,mm3;
+       psrlq mm3,8;
+       movq mm4,mm1;
+       psrlq mm1, 24;
+       pand mm4, [bmask];
+       pand mm1, [grmask];
+       por  mm4, mm1;
+       punpcklbw mm3, [thezero];
+       punpcklbw mm4, [thezero];
+
+; Y
+       movq mm5, mm3;
+                       
+       pmaddwd mm5, [ygr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [yb0grcoff];
+
+       paddd mm5, mm1
+       psrad mm5,15;
+                       
+
+; U
+       movq mm0, mm3;
+                       
+       pmaddwd mm0, [ugr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [ub0grcoff];
+
+       paddd mm0, mm1;
+       psrad mm0,15;
+
+       packssdw mm0,mm0
+       pmaddwd mm0,[add2w]
+       psllq mm0,32
+       paddw mm6, mm0
+
+; V
+       
+       pmaddwd mm3, [vgr0bcoff];
+
+
+       pmaddwd mm4, [vb0grcoff];
+
+       paddd mm3, mm4;
+       psrad mm3,15;
+
+       packssdw mm3,mm3
+       pmaddwd mm3,[add2w]
+       psllq mm3,32
+       paddw mm7, mm3
+
+; 3eme quad 2eme ligne
+       movq mm3, [edx+edi+16];
+       movq mm1,mm3;
+       psrlq mm3,8;
+       movq mm4,mm1;
+       psrlq mm1, 24;
+       pand mm4, [bmask];
+       pand mm1, [grmask];
+       por  mm4, mm1;
+       punpcklbw mm3, [thezero];
+       punpcklbw mm4, [thezero];
+
+
+; Y
+       movq mm2, mm3;
+                       
+       pmaddwd mm2, [ygr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [yb0grcoff];
+
+       paddd mm2, mm1
+       psrad mm2,15;
+
+; U
+       movq mm0, mm3;
+                       
+       pmaddwd mm0, [ugr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [ub0grcoff];
+
+       paddd mm0, mm1;
+       psrad mm0,15;
+
+       packssdw mm0,mm0
+       pmaddwd mm0,[add2w]
+       psllq mm0,32
+       paddw mm6, mm0
+; V
+       
+       pmaddwd mm3, [vgr0bcoff];
+
+
+       pmaddwd mm4, [vb0grcoff];
+
+       paddd mm3, mm4;
+       psrad mm3,15;
+
+       packssdw mm3,mm3
+       pmaddwd mm3,[add2w]
+       psllq mm3,32
+       paddw mm7, mm3
+
+; 4eme quad 1ere ligne
+       movq mm3, [edx+24];
+       movq mm1,mm3;
+       psrlq mm3,8;
+       movq mm4,mm1;
+       psrlq mm1, 24;
+       pand mm4, [bmask];
+       pand mm1, [grmask];
+       por  mm4, mm1;
+       punpcklbw mm3, [thezero];
+       punpcklbw mm4, [thezero];
+
+; Y
+       movq mm0, mm3;
+                       
+       pmaddwd mm0, [ygr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [yb0grcoff];
+
+       paddd mm0, mm1
+       psrad mm0,15;
+       packssdw mm5,mm0
+                       
+       paddw mm5,[yoff]
+       packuswb mm5,mm5
+
+       movd [ebx+4], mm5
+
+; U
+       movq mm0, mm3;
+                       
+       pmaddwd mm0, [ugr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [ub0grcoff];
+
+       paddd mm0, mm1;
+       psrad mm0,15;
+
+       packssdw mm0,mm0
+       pmaddwd mm0,[add2w]
+       psllq mm0,48
+       paddw mm6, mm0
+
+; V
+       
+       pmaddwd mm3, [vgr0bcoff];
+
+
+       pmaddwd mm4, [vb0grcoff];
+
+       paddd mm3, mm4;
+       psrad mm3,15;
+
+       packssdw mm3,mm3
+       pmaddwd mm3,[add2w]
+       psllq mm3,48
+       paddw mm7, mm3
+
+; 4eme quad 2eme line
+       movq mm3, [edx+edi+24];
+       movq mm1,mm3;
+       psrlq mm3,8;
+       movq mm4,mm1;
+       psrlq mm1, 24;
+       pand mm4, [bmask];
+       pand mm1, [grmask];
+       por  mm4, mm1;
+       punpcklbw mm3, [thezero];
+       punpcklbw mm4, [thezero];
+
+
+; Y
+       movq mm0, mm3;
+                       
+       pmaddwd mm0, [ygr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [yb0grcoff];
+
+       paddd mm0, mm1
+       psrad mm0,15;
+       packssdw mm2,mm0
+
+       paddw mm2,[yoff]
+       packuswb mm2,mm2
+
+       movd [ebx+esi+4], mm2
+
+; U
+       movq mm0, mm3;
+                       
+       pmaddwd mm0, [ugr0bcoff];
+
+       movq mm1, mm4;
+
+       pmaddwd mm1, [ub0grcoff];
+
+       paddd mm0, mm1;
+       psrad mm0,15;
+
+       packssdw mm0,mm0
+       pmaddwd mm0,[add2w]
+       psllq mm0,48
+       paddw mm6, mm0
+
+       psraw mm6,2
+       paddw mm6, [uvoff]
+       packuswb mm6,mm6
+       movd [eax],mm6
+; V
+       
+       pmaddwd mm3, [vgr0bcoff];
+
+
+       pmaddwd mm4, [vb0grcoff];
+
+       paddd mm3, mm4;
+       psrad mm3,15;
+
+       packssdw mm3,mm3
+       pmaddwd mm3,[add2w]
+       psllq mm3,48
+       paddw mm7, mm3
+
+       psraw mm7,2
+       paddw mm7, [uvoff]
+       packuswb mm7,mm7
+       movd [ebp],mm7
+
+
+       dec ecx
+
+       cmp ecx,0
+
+jz .fin_while
+
+; preparations pour les 4 quads suivantes
+       lea edx, [edx + 32];
+       lea ebx, [ebx + 8];
+       lea eax, [eax + 4];
+       lea ebp, [ebp + 4];
+       
+jmp .while
+
+.fin_while:
+emms
+
+pop esi
+pop edi
+pop edx
+pop ecx
+pop ebx
+pop eax
+pop ebp
+
+ret                  ;//The End