summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-07-08 20:56:55 +0000
committerHolger Zickner <[email protected]>2004-07-08 20:56:55 +0000
commit6b36f9e0380b7c80aecdc78ef07a0cf473712416 (patch)
tree4a378b960321b3b7b07ef2effac295d0dd589eab
parent252832999fa43bce63ca4b643fab5d9dd51fccc4 (diff)
import of Jake2 version v_0_9
-rw-r--r--.cvsignore1
-rw-r--r--ChangeLog11
-rw-r--r--LICENSE340
-rw-r--r--README38
-rw-r--r--build.bat8
-rw-r--r--build.sh8
-rw-r--r--build.xml104
-rw-r--r--readme.id29
-rw-r--r--scripts/Jake2.bat1
-rw-r--r--scripts/Jake2.sh6
-rw-r--r--src/jake2/client/CL.java3
-rw-r--r--src/jake2/client/CL_ents.java4
-rw-r--r--src/jake2/client/CL_fx.java3
-rw-r--r--src/jake2/client/CL_parse.java26
-rw-r--r--src/jake2/client/CL_tent.java3
-rw-r--r--src/jake2/client/M.java3
-rw-r--r--src/jake2/client/Menu.java3
-rw-r--r--src/jake2/client/S.java33
-rw-r--r--src/jake2/client/SCR.java3
-rw-r--r--src/jake2/client/SND_DMA.java1218
-rw-r--r--src/jake2/client/SND_JAVA.java168
-rw-r--r--src/jake2/client/SND_MEM.java364
-rw-r--r--src/jake2/client/SND_MIX.java565
-rw-r--r--src/jake2/client/VID.java3
-rw-r--r--src/jake2/client/centity_t.java4
-rw-r--r--src/jake2/client/client_state_t.java7
-rw-r--r--src/jake2/client/frame_t.java4
-rw-r--r--src/jake2/render/jogl/Impl.java9
-rw-r--r--src/jake2/render/jogl/Light.java18
-rw-r--r--src/jake2/server/SV_GAME.java4
-rw-r--r--src/jake2/server/SV_SEND.java4
-rw-r--r--src/jake2/sound/DummyDriver.java111
-rw-r--r--src/jake2/sound/S.java187
-rw-r--r--src/jake2/sound/Sound.java105
-rw-r--r--src/jake2/sound/sfx_t.java (renamed from src/jake2/client/sfx_t.java)25
-rw-r--r--src/jake2/sound/sfxcache_t.java (renamed from src/jake2/client/sfxcache_t.java)16
-rw-r--r--src/jake2/sound/soundinfo_t.java19
-rw-r--r--src/jake2/sound/wavinfo_t.java19
-rw-r--r--src/jake2/util/Math3D.java15
39 files changed, 1052 insertions, 2440 deletions
diff --git a/.cvsignore b/.cvsignore
index c46d6e3..d97898e 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -2,3 +2,4 @@ build
baseq2
dist
*.tar.gz
+*.zip
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..8128e2a
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,11 @@
+0.9.0 2004-04-28
+
+ - initial release
+ - what works so far:
+ - local single player games
+ - demos (at least we have the coolest Java benchmark out there)
+ - console and menus 90%
+ - todo until 1.0:
+ - sound support
+ - save games / load games
+ - network games
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..5b6e7c6
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/README b/README
new file mode 100644
index 0000000..6142684
--- /dev/null
+++ b/README
@@ -0,0 +1,38 @@
+Jake2 README
+============
+
+Jake2 is a port of the GPL'd Quake2 engine from id Software to Java. Jake2 is
+distributed under the terms of the GPL (see LICENSE).
+
+The port was done completely in Java. No native libraries are used for the
+game functionality. For graphics rendering we use the jogl Java OpenGL bindings.
+
+Currently Jake2 supports Linux and Windows2000/XP.
+
+requirements:
+400 MHz CPU
+Geforce2 MX or better graphics accelerator
+JRE 1.4 or higher
+
+Installation
+------------
+
+from binary distribution:
+- unpack jake2-version.tar.gz or jake2-version.zip
+- copy the baseq2 directory from your full version of Quake2 or from the
+ demo version to the Jake2 base directory
+- run the game with Jake2.sh or Jake2.bat
+
+build from source:
+- unpack jake2src-version.tar.gz or jake2-version.zip
+- set JAVA_HOME environment variable to Your J2SDK1.4 installation
+- run "build.sh bindist" or "build.bat bindist" to build the binary
+ distribution
+
+have fun!
+
+bytonic Software
+
+Holger Zickner <[email protected]>
+Carsten Weisse <[email protected]>
+Rene Stoeckel <[email protected]>
diff --git a/build.bat b/build.bat
new file mode 100644
index 0000000..ecd87a7
--- /dev/null
+++ b/build.bat
@@ -0,0 +1,8 @@
+@echo off
+
+set CP=lib/ant/ant.jar;lib/ant/ant-launcher.jar
+set CP=%CP%;lib/xerces/xercesImpl.jar;lib/xerces/xml-apis.jar
+set CP=%CP%;lib/proguard/proguard.jar
+set CP=%CP%;%JAVA_HOME%/lib/tools.jar
+
+java -Dant.home=lib/ant -cp %CP% org.apache.tools.ant.Main -buildfile build.xml %1 %2 %3 %4 \ No newline at end of file
diff --git a/build.sh b/build.sh
new file mode 100644
index 0000000..f5515d3
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+CP=lib/ant/ant.jar:lib/ant/ant-launcher.jar
+CP=$CP:lib/xerces/xercesImpl.jar:lib/xerces/xml-apis.jar
+CP=$CP:lib/proguard/proguard.jar
+CP=$CP:$JAVA_HOME/lib/tools.jar
+
+java -Dant.home=lib/ant -cp $CP org.apache.tools.ant.Main -buildfile build.xml $@ \ No newline at end of file
diff --git a/build.xml b/build.xml
index 30ff8e7..eb1f47c 100644
--- a/build.xml
+++ b/build.xml
@@ -1,6 +1,12 @@
<!-- Buildfile -->
-<project name="jake2" default="jar" basedir=".">
+<project name="jake2" default="dist" basedir=".">
+ <taskdef name="proguard" classname="proguard.ant.ProGuardTask">
+ <classpath>
+ <pathelement location="lib/proguard/proguard.jar"/>
+ </classpath>
+ </taskdef>
+
<!-- properties -->
<property name="src" location="src"/>
<property name="test" location="test"/>
@@ -9,28 +15,20 @@
<!-- different classpaths -->
<path id="build.class.path">
- <pathelement location="lib/jogl/jogl.jar"/>
- </path>
-
- <path id="test.class.path">
- <pathelement path="${build}"/>
- </path>
-
- <path id="source.path">
- <pathelement location="src"/>
+ <pathelement location="lib/jogl/linux/jogl.jar"/>
+ <pathelement location="lib/joal/linux/joal.jar"/>
</path>
<!-- initialize directories -->
<target name="init">
<mkdir dir="${build}"/>
- <mkdir dir="${dist}"/>
+ <mkdir dir="${dist}/lib"/>
</target>
<!-- compile -->
<target name="compile" depends="init">
- <javac destdir="${build}" optimize="on" debug="on" source="1.4">
+ <javac destdir="${build}" optimize="on" debug="off" source="1.4">
<src path="${src}"/>
- <src path="${test}"/>
<include name="jake2/**"/>
<classpath refid="build.class.path"/>
</javac>
@@ -38,11 +36,32 @@
<!-- copy libs -->
<target name="copylibs">
+ <copy todir="${dist}/lib/linux">
+ <fileset dir="lib/jogl/linux">
+ <include name="*"/>
+ </fileset>
+ <fileset dir="lib/joal/linux">
+ <include name="*"/>
+ </fileset>
+ </copy>
+ <copy todir="${dist}/lib/windows">
+ <fileset dir="lib/jogl/windows">
+ <include name="*"/>
+ </fileset>
+ <fileset dir="lib/joal/windows">
+ <include name="*"/>
+ </fileset>
+ </copy>
<copy todir="${dist}">
- <fileset dir="lib">
- <include name="/jogl/jogl.jar"/>
+ <fileset dir="scripts">
+ <include name="Jake2.*"/>
</fileset>
</copy>
+ <chmod perm="755">
+ <fileset dir="${dist}">
+ <include name="*.sh"/>
+ </fileset>
+ </chmod>
</target>
<!-- copy resources -->
@@ -56,11 +75,22 @@
<!-- jar -->
<target name="jar" depends="compile,copyres">
- <jar destfile="${dist}/jake2.jar" basedir="${build}">
+ <jar destfile="${dist}/lib/jake.jar" basedir="${build}">
<include name="jake2/**"/>
</jar>
+ <proguard printseeds="on" printusage="off" outjar="${dist}/lib/jake2.jar"
+ defaultpackage="" overloadaggressively="off">
+ <injar name="${dist}/lib/jake.jar"/>
+ <libraryjar name="lib/jogl/linux/jogl.jar"/>
+ <libraryjar name="lib/joal/linux/joal.jar"/>
+ <libraryjar name="${java.home}/lib/rt.jar"/>
+ <keep access="public" name="jake2.Jake2">
+ <method name="main(java.lang.String[])"/>
+ </keep>
+ </proguard>
+ <delete file="${dist}/lib/jake.jar"/>
</target>
-
+
<!-- everything -->
<target name="all" depends="bindist,srcdist">
</target>
@@ -72,21 +102,45 @@
<!-- binary distribution -->
<target name="bindist" depends="dist">
<tar destfile="jake2.tar.gz" compression="gzip">
- <tarfileset dir=".">
- <include name="dist/**"/>
+ <tarfileset dir="${dist}" prefix="Jake2" mode="755">
+ <include name="*.sh"/>
+ </tarfileset>
+ <tarfileset dir="${dist}" prefix="Jake2">
+ <include name="**"/>
+ <exclude name="*.sh"/>
</tarfileset>
</tar>
+ <zip destfile="jake2.zip">
+ <zipfileset dir="${dist}" prefix="Jake2">
+ <include name="**"/>
+ </zipfileset>
+ </zip>
</target>
<!-- source distribution -->
<target name="srcdist" >
<tar destfile="jake2-src.tar.gz" compression="gzip">
- <tarfileset dir="." prefix="jake2">
- <include name="src/**"/>
+ <tarfileset dir="." prefix="Jake2" mode="755">
+ <include name="scripts/*.*"/>
+ <include name="build.sh"/>
+ </tarfileset>
+ <tarfileset dir="." prefix="Jake2">
+ <include name="src/jake2/**"/>
<include name="lib/**"/>
<include name="build.xml"/>
+ <include name="build.bat"/>
</tarfileset>
</tar>
+ <zip destfile="jake2-src.zip">
+ <zipfileset dir="." prefix="Jake2">
+ <include name="src/jake2/**"/>
+ <include name="scripts/*.*"/>
+ <include name="lib/**"/>
+ <include name="build.xml"/>
+ <include name="build.sh"/>
+ <include name="build.bat"/>
+ </zipfileset>
+ </zip>
</target>
<!-- clean -->
@@ -98,7 +152,11 @@
<!-- distclean -->
<target name="distclean" depends="clean">
<delete dir="${dist}"/>
- <delete file="jake2.tar.gz"/>
- <delete file="jake2-src.tar.gz"/>
+ <delete>
+ <fileset dir=".">
+ <include name="*.tar.gz"/>
+ <include name="*.zip"/>
+ </fileset>
+ </delete>
</target>
</project> \ No newline at end of file
diff --git a/readme.id b/readme.id
new file mode 100644
index 0000000..ff05cab
--- /dev/null
+++ b/readme.id
@@ -0,0 +1,29 @@
+
+This is the complete source code for Quake 2, version 3.21, buildable with
+visual C++ 6.0. The linux version should be buildable, but we haven't
+tested it for the release.
+
+The code is all licensed under the terms of the GPL (gnu public license).
+You should read the entire license, but the gist of it is that you can do
+anything you want with the code, including sell your new version. The catch
+is that if you distribute new binary versions, you are required to make the
+entire source code available for free to everyone.
+
+The primary intent of this release is for entertainment and educational
+purposes, but the GPL does allow commercial exploitation if you obey the
+full license. If you want to do something commercial and you just can't bear
+to have your source changes released, we could still negotiate a separate
+license agreement (for $$$), but I would encourage you to just live with the
+GPL.
+
+All of the Q2 data files remain copyrighted and licensed under the
+original terms, so you cannot redistribute data from the original game, but if
+you do a true total conversion, you can create a standalone game based on
+this code.
+
+Thanks to Robert Duffy for doing the grunt work of building this release.
+
+John Carmack
+Id Software
+
+
diff --git a/scripts/Jake2.bat b/scripts/Jake2.bat
new file mode 100644
index 0000000..6230d9e
--- /dev/null
+++ b/scripts/Jake2.bat
@@ -0,0 +1 @@
+@javaw -Xmx128M -Djava.library.path=lib/windows -cp lib/jake2.jar;lib/windows/jogl.jar;lib/windows/joal.jar jake2.Jake2 \ No newline at end of file
diff --git a/scripts/Jake2.sh b/scripts/Jake2.sh
new file mode 100644
index 0000000..11ba52f
--- /dev/null
+++ b/scripts/Jake2.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+export LD_LIBRARY_PATH=lib/linux
+CP=lib/jake2.jar:lib/linux/jogl.jar:lib/linux/joal.jar
+
+exec java -Xmx128M -Djava.library.path=lib/linux -cp $CP jake2.Jake2 \ No newline at end of file
diff --git a/src/jake2/client/CL.java b/src/jake2/client/CL.java
index 18d19be..5b30e34 100644
--- a/src/jake2/client/CL.java
+++ b/src/jake2/client/CL.java
@@ -2,7 +2,7 @@
* CL.java
* Copyright (C) 2004
*
- * $Id: CL.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+ * $Id: CL.java,v 1.4 2004-07-08 20:56:50 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -30,6 +30,7 @@ import jake2.Globals;
import jake2.game.*;
import jake2.qcommon.*;
import jake2.server.SV_MAIN;
+import jake2.sound.*;
import jake2.sys.*;
import jake2.util.Vargs;
diff --git a/src/jake2/client/CL_ents.java b/src/jake2/client/CL_ents.java
index 4dc4330..d406ff2 100644
--- a/src/jake2/client/CL_ents.java
+++ b/src/jake2/client/CL_ents.java
@@ -2,7 +2,7 @@
* CL_ents.java
* Copyright (C) 2004
*
- * $Id: CL_ents.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
+ * $Id: CL_ents.java,v 1.3 2004-07-08 20:56:50 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -1268,7 +1268,7 @@ public class CL_ents extends CL_inv {
Called to get the sound spatialization origin
===============
*/
- void GetEntitySoundOrigin(int ent, float[] org) {
+ public static void GetEntitySoundOrigin(int ent, float[] org) {
centity_t old;
if (ent < 0 || ent >= MAX_EDICTS)
diff --git a/src/jake2/client/CL_fx.java b/src/jake2/client/CL_fx.java
index 2a77d21..45e9fdd 100644
--- a/src/jake2/client/CL_fx.java
+++ b/src/jake2/client/CL_fx.java
@@ -2,7 +2,7 @@
* CL_fx.java
* Copyright (C) 2004
*
- * $Id: CL_fx.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+ * $Id: CL_fx.java,v 1.4 2004-07-08 20:56:50 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -30,6 +30,7 @@ import jake2.game.M_Flash;
import jake2.game.entity_state_t;
import jake2.qcommon.Com;
import jake2.qcommon.MSG;
+import jake2.sound.*;
/**
* CL_fx
diff --git a/src/jake2/client/CL_parse.java b/src/jake2/client/CL_parse.java
index f636ba0..ad19960 100644
--- a/src/jake2/client/CL_parse.java
+++ b/src/jake2/client/CL_parse.java
@@ -2,7 +2,7 @@
* CL_parse.java
* Copyright (C) 2004
*
- * $Id: CL_parse.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+ * $Id: CL_parse.java,v 1.4 2004-07-08 20:56:49 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,24 +25,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.client;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
import jake2.Defines;
import jake2.game.Cmd;
import jake2.game.entity_state_t;
-import jake2.qcommon.CM;
-import jake2.qcommon.Cbuf;
-import jake2.qcommon.Com;
-import jake2.qcommon.Cvar;
-import jake2.qcommon.FS;
-import jake2.qcommon.MSG;
-import jake2.qcommon.SZ;
-import jake2.qcommon.xcommand_t;
+import jake2.qcommon.*;
import jake2.render.model_t;
+import jake2.sound.S;
import jake2.sys.Sys;
import jake2.util.Lib;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
/**
* CL_parse
*/
@@ -200,7 +194,7 @@ public class CL_parse extends CL_view {
S.BeginRegistration();
CL.RegisterTEntSounds();
for (int i = 1; i < MAX_SOUNDS; i++) {
- if (cl.configstrings[CS_SOUNDS + i] == null || cl.configstrings[CS_SOUNDS + i] == "")
+ if (cl.configstrings[CS_SOUNDS + i] == null || cl.configstrings[CS_SOUNDS + i].equals("") || cl.configstrings[CS_SOUNDS + i].equals("\0"))
break;
cl.sound_precache[i] = S.RegisterSound(cl.configstrings[CS_SOUNDS + i]);
Sys.SendKeyEvents(); // pump message loop
@@ -555,7 +549,7 @@ public class CL_parse extends CL_view {
}
else if (i >= CS_SOUNDS && i < CS_SOUNDS + MAX_MODELS) {
if (cl.refresh_prepped)
- cl.sound_precache[i - CS_SOUNDS] = SND_DMA.RegisterSound(cl.configstrings[i]);
+ cl.sound_precache[i - CS_SOUNDS] = S.RegisterSound(cl.configstrings[i]);
}
else if (i >= CS_IMAGES && i < CS_IMAGES + MAX_MODELS) {
if (cl.refresh_prepped)
@@ -632,7 +626,7 @@ public class CL_parse extends CL_view {
if (null==cl.sound_precache[sound_num])
return;
- SND_DMA.StartSound(pos, ent, channel, cl.sound_precache[sound_num], volume, attenuation, ofs);
+ S.StartSound(pos, ent, channel, cl.sound_precache[sound_num], volume, attenuation, ofs);
}
public static void SHOWNET(String s) {
@@ -709,7 +703,7 @@ public class CL_parse extends CL_view {
case svc_print :
i = MSG.ReadByte(net_message);
if (i == PRINT_CHAT) {
- SND_DMA.StartLocalSound("misc/talk.wav");
+ S.StartLocalSound("misc/talk.wav");
con.ormask = 128;
}
Com.Printf(MSG.ReadString(net_message));
diff --git a/src/jake2/client/CL_tent.java b/src/jake2/client/CL_tent.java
index 939f3ca..8966e01 100644
--- a/src/jake2/client/CL_tent.java
+++ b/src/jake2/client/CL_tent.java
@@ -2,7 +2,7 @@
* CL_tent.java
* Copyright (C) 2004
*
- * $Id: CL_tent.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
+ * $Id: CL_tent.java,v 1.3 2004-07-08 20:56:50 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -30,6 +30,7 @@ import jake2.game.player_state_t;
import jake2.qcommon.Com;
import jake2.qcommon.MSG;
import jake2.render.model_t;
+import jake2.sound.*;
/**
* CL_tent
diff --git a/src/jake2/client/M.java b/src/jake2/client/M.java
index dd8304f..3e076a6 100644
--- a/src/jake2/client/M.java
+++ b/src/jake2/client/M.java
@@ -2,7 +2,7 @@
* M.java
* Copyright (C) 2003
*
- * $Id: M.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+ * $Id: M.java,v 1.4 2004-07-08 20:56:50 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -28,7 +28,6 @@ package jake2.client;
import jake2.Defines;
import jake2.Globals;
import jake2.game.*;
-import jake2.qcommon.Com;
import jake2.server.SV;
import jake2.util.Lib;
import jake2.util.Math3D;
diff --git a/src/jake2/client/Menu.java b/src/jake2/client/Menu.java
index 8ac689f..00944ed 100644
--- a/src/jake2/client/Menu.java
+++ b/src/jake2/client/Menu.java
@@ -2,7 +2,7 @@
* Menu.java
* Copyright (C) 2004
*
- * $Id: Menu.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
+ * $Id: Menu.java,v 1.3 2004-07-08 20:56:49 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -29,6 +29,7 @@ import jake2.Globals;
import jake2.game.Cmd;
import jake2.game.cvar_t;
import jake2.qcommon.*;
+import jake2.sound.*;
import jake2.sys.NET;
import jake2.sys.Sys;
import jake2.util.Lib;
diff --git a/src/jake2/client/S.java b/src/jake2/client/S.java
deleted file mode 100644
index 302de14..0000000
--- a/src/jake2/client/S.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * S.java
- * Copyright (C) 2003
- *
- * $Id: S.java,v 1.1 2004-07-07 19:58:51 hzi Exp $
- */
-/*
-Copyright (C) 1997-2001 Id Software, Inc.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-package jake2.client;
-
-/**
- * S
- */
-public class S extends SND_DMA {
-
-}
diff --git a/src/jake2/client/SCR.java b/src/jake2/client/SCR.java
index 6a426d1..66b5c33 100644
--- a/src/jake2/client/SCR.java
+++ b/src/jake2/client/SCR.java
@@ -2,7 +2,7 @@
* SCR.java
* Copyright (C) 2003
*
- * $Id: SCR.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+ * $Id: SCR.java,v 1.4 2004-07-08 20:56:49 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -30,6 +30,7 @@ import jake2.Globals;
import jake2.game.Cmd;
import jake2.game.cvar_t;
import jake2.qcommon.*;
+import jake2.sound.*;
import jake2.sys.Sys;
import jake2.util.Vargs;
diff --git a/src/jake2/client/SND_DMA.java b/src/jake2/client/SND_DMA.java
deleted file mode 100644
index 0409e8b..0000000
--- a/src/jake2/client/SND_DMA.java
+++ /dev/null
@@ -1,1218 +0,0 @@
-/*
- * S_DMA.java
- * Copyright (C) 2004
- *
- * $Id: SND_DMA.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
- */
-/*
-Copyright (C) 1997-2001 Id Software, Inc.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-
-// Created on 26.01.2004 by RST.
-
-package jake2.client;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.Arrays;
-
-import jake2.game.*;
-import jake2.game.Cmd;
-import jake2.game.cvar_t;
-import jake2.qcommon.*;
-import jake2.util.Vargs;
-
-
-
-/**
- * SND_DMA
- * TODO implement sound system
- */
-public class SND_DMA extends SND_MIX {
-//// snd_dma.c -- main control for any streaming sound output device
-//
-// #include "client.h"
-// #include "snd_loc.h"
-//
-// void S_Play(void);
-// void S_SoundList(void);
-// void S_Update_();
-// void S_StopAllSounds(void);
-//
-//
-//// =======================================================================
-//// Internal sound data & structures
-//// =======================================================================
-//
-//// only begin attenuating sound volumes when outside the FULLVOLUME range
-// #define SOUND_FULLVOLUME 80
-//
-// #define SOUND_LOOPATTENUATE 0.003
-//
- static int s_registration_sequence;
-//
- static channel_t[] channels = new channel_t[MAX_CHANNELS];
- static {
- for(int i=0; i < MAX_CHANNELS; i++)
- channels[i] = new channel_t();
- }
-//
-// qboolean snd_initialized = false;
- static boolean sound_started = false;
-
- static float[] listener_origin = {0, 0, 0};
- static float[] listener_forward = {0, 0, 0};
- static float[] listener_right = {0, 0, 0};
- static float[] listener_up = {0, 0, 0};
-
- static boolean s_registering;
-
- static int soundtime; // sample PAIRS
- static int paintedtime; // sample PAIRS
-//
-//// during registration it is possible to have more sounds
-//// than could actually be referenced during gameplay,
-//// because we don't want to free anything until we are
-//// sure we won't need it.
- static final int MAX_SFX = (MAX_SOUNDS*2);
- static sfx_t[] known_sfx = new sfx_t[MAX_SFX];
- static {
- for (int i = 0; i< known_sfx.length; i++)
- known_sfx[i] = new sfx_t();
- }
- static int num_sfx;
-//
- static final int MAX_PLAYSOUNDS = 128;
- static playsound_t[] s_playsounds = new playsound_t[MAX_PLAYSOUNDS];
- static {
- for( int i = 0; i < MAX_PLAYSOUNDS; i++) {
- s_playsounds[i] = new playsound_t();
- }
- }
- static playsound_t s_freeplays = new playsound_t();
- static playsound_t s_pendingplays = new playsound_t();
-
- static int s_beginofs;
-
- static cvar_t s_testsound;
- static cvar_t s_loadas8bit;
- static cvar_t s_khz;
- static cvar_t s_show;
- static cvar_t s_mixahead;
- static cvar_t s_primary;
-//
-//
-// int s_rawend;
-// portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
-//
-//
-// ====================================================================
-// User-setable variables
-// ====================================================================
-
-
- static void SoundInfo_f() {
- if (!sound_started) {
- Com.Printf("sound system not started\n");
- return;
- }
-
- Com.Printf("%5d stereo\n", new Vargs(1).add(dma.channels - 1));
- Com.Printf("%5d samples\n", new Vargs(1).add(dma.samples));
- Com.Printf("%5d samplepos\n", new Vargs(1).add(dma.samplepos));
- Com.Printf("%5d samplebits\n", new Vargs(1).add(dma.samplebits));
- Com.Printf("%5d submission_chunk\n", new Vargs(1).add(dma.submission_chunk));
- Com.Printf("%5d speed\n", new Vargs(1).add(dma.speed));
- }
-
- /*
- ================
- S_Init
- ================
- */
- public static void Init() {
- cvar_t cv;
-
- Com.Printf("\n------- sound initialization -------\n");
-
- cv = Cvar.Get("s_initsound", "0", 0);
- if (cv.value == 0.0f)
- Com.Printf("not initializing.\n");
- else {
- s_volume = Cvar.Get("s_volume", "0.7", CVAR_ARCHIVE);
- s_khz = Cvar.Get("s_khz", "11", CVAR_ARCHIVE);
- s_loadas8bit = Cvar.Get("s_loadas8bit", "1", CVAR_ARCHIVE);
- s_mixahead = Cvar.Get("s_mixahead", "0.2", CVAR_ARCHIVE);
- s_show = Cvar.Get("s_show", "0", 0);
- s_testsound = Cvar.Get("s_testsound", "0", 0);
- s_primary = Cvar.Get("s_primary", "0", CVAR_ARCHIVE); // win32 specific
-
- Cmd.AddCommand("play", new xcommand_t() {
- public void execute() {
- S.Play();
- }
- });
- Cmd.AddCommand("stopsound", new xcommand_t() {
- public void execute() {
- S.StopAllSounds();
- }
- });
- Cmd.AddCommand("soundlist", new xcommand_t() {
- public void execute() {
- S.SoundList();
- }
- });
- Cmd.AddCommand("soundinfo", new xcommand_t() {
- public void execute() {
- S.SoundInfo_f();
- }
- });
-
- if (!SNDDMA_Init())
- return;
-
- S.InitScaletable();
-
- sound_started = true;
- num_sfx = 0;
-
- soundtime = 0;
- paintedtime = 0;
-
- Com.Printf("sound sampling rate: " + dma.speed + "\n");
-
- S.StopAllSounds();
- }
-
- Com.Printf("------------------------------------\n");
- }
-
-
-// =======================================================================
-// Shutdown sound engine
-// =======================================================================
-
- static void Shutdown() {
- int i;
- sfx_t[] sfx;
-
- if (!sound_started)
- return;
-
- SNDDMA_Shutdown();
-
- sound_started = false;
-
- Cmd.RemoveCommand("play");
- Cmd.RemoveCommand("stopsound");
- Cmd.RemoveCommand("soundlist");
- Cmd.RemoveCommand("soundinfo");
-
- // free all sounds
- for (i = 0, sfx = known_sfx; i < num_sfx; i++) {
- if (sfx[i].name == null)
- continue;
-
- //memset (sfx, 0, sizeof(*sfx));
- sfx[i].clear();
- }
-
- num_sfx = 0;
- }
-
-// =======================================================================
-// Load a sound
-// =======================================================================
-
- /*
- ==================
- S_FindName
-
- ==================
- */
- static sfx_t FindName(String name, boolean create) {
- int i;
- sfx_t sfx = null;
-
- if (name == null)
- Com.Error(ERR_FATAL, "S_FindName: NULL\n");
- if (name.length() == 0)
- Com.Error(ERR_FATAL, "S_FindName: empty name\n");
-
- if (name.length() >= MAX_QPATH)
- Com.Error(ERR_FATAL, "Sound name too long: " + name);
-
- // see if already loaded
- for (i = 0; i < num_sfx; i++)
- if (name.equals(known_sfx[i].name)) {
- return known_sfx[i];
- }
-
- if (!create)
- return null;
-
- // find a free sfx
- for (i = 0; i < num_sfx; i++)
- if (known_sfx[i].name == null)
- // registration_sequence < s_registration_sequence)
- break;
-
- if (i == num_sfx) {
- if (num_sfx == MAX_SFX)
- Com.Error(ERR_FATAL, "S_FindName: out of sfx_t");
- num_sfx++;
- }
-
- sfx = known_sfx[i];
- //memset (sfx, 0, sizeof(*sfx));
- sfx.clear();
- sfx.name = name;
- sfx.registration_sequence = s_registration_sequence;
-
- return sfx;
- }
-//
-//
- /*
- ==================
- S_AliasName
-
- ==================
- */
- static sfx_t AliasName(String aliasname, String truename)
- {
- sfx_t sfx = null;
-// char *s;
-// int i;
-//
-// s = Z_Malloc (MAX_QPATH);
-// strcpy (s, truename);
-//
-// // find a free sfx
-// for (i=0 ; i < num_sfx ; i++)
-// if (!known_sfx[i].name[0])
-// break;
-//
-// if (i == num_sfx)
-// {
-// if (num_sfx == MAX_SFX)
-// Com_Error (ERR_FATAL, "S_FindName: out of sfx_t");
-// num_sfx++;
-// }
-//
-// sfx = &known_sfx[i];
-// memset (sfx, 0, sizeof(*sfx));
-// strcpy (sfx->name, aliasname);
-// sfx->registration_sequence = s_registration_sequence;
-// sfx->truename = s;
-//
- return sfx;
- }
-
-
- /*
- =====================
- S_BeginRegistration
-
- =====================
- */
- static void BeginRegistration() {
- s_registration_sequence++;
- s_registering = true;
- }
-
- /*
- ==================
- S_RegisterSound
-
- ==================
- */
- static sfx_t RegisterSound(String name) {
- sfx_t sfx = null;
-
- if (!sound_started)
- return null;
-
- sfx = S.FindName(name, true);
- sfx.registration_sequence = s_registration_sequence;
-
- if (!s_registering)
- S.LoadSound(sfx);
-
- return sfx;
- }
-
-
- /*
- =====================
- S_EndRegistration
-
- =====================
- */
- static void EndRegistration() {
- int i;
- sfx_t sfx;
- int size;
-
- // free any sounds not from this registration sequence
- for (i = 0; i < num_sfx; i++) {
- sfx = known_sfx[i];
- if (sfx.name == null)
- continue;
- if (sfx.registration_sequence != s_registration_sequence) { // don't need this sound
- //memset (sfx, 0, sizeof(*sfx));
- sfx.clear();
- } else {
- // make sure it is paged in
- // if (sfx->cache)
- // {
- // size = sfx->cache->length*sfx->cache->width;
- // Com_PageInMemory ((byte *)sfx->cache, size);
- // }
- }
-
- }
-
- // load everything in
- for (i = 0; i < num_sfx; i++) {
- sfx = known_sfx[i];
- if (sfx.name == null)
- continue;
- S.LoadSound(sfx);
- }
-
- s_registering = false;
- }
-//
-//
-//// =============================================================================
-//
-// /*
-// =================
-// S_PickChannel
-// =================
-// */
-// channel_t *S_PickChannel(int entnum, int entchannel)
-// {
-// int ch_idx;
-// int first_to_die;
-// int life_left;
-// channel_t *ch;
-//
-// if (entchannel<0)
-// Com_Error (ERR_DROP, "S_PickChannel: entchannel<0");
-//
-//// Check for replacement sound, or find the best one to replace
-// first_to_die = -1;
-// life_left = 0x7fffffff;
-// for (ch_idx=0 ; ch_idx < MAX_CHANNELS ; ch_idx++)
-// {
-// if (entchannel != 0 // channel 0 never overrides
-// && channels[ch_idx].entnum == entnum
-// && channels[ch_idx].entchannel == entchannel)
-// { // always override sound from same entity
-// first_to_die = ch_idx;
-// break;
-// }
-//
-// // don't let monster sounds override player sounds
-// if (channels[ch_idx].entnum == cl.playernum+1 && entnum != cl.playernum+1 && channels[ch_idx].sfx)
-// continue;
-//
-// if (channels[ch_idx].end - paintedtime < life_left)
-// {
-// life_left = channels[ch_idx].end - paintedtime;
-// first_to_die = ch_idx;
-// }
-// }
-//
-// if (first_to_die == -1)
-// return NULL;
-//
-// ch = &channels[first_to_die];
-// memset (ch, 0, sizeof(*ch));
-//
-// return ch;
-// }
-//
-// /*
-// =================
-// S_SpatializeOrigin
-//
-// Used for spatializing channels and autosounds
-// =================
-// */
-// void S_SpatializeOrigin (vec3_t origin, float master_vol, float dist_mult, int *left_vol, int *right_vol)
-// {
-// vec_t dot;
-// vec_t dist;
-// vec_t lscale, rscale, scale;
-// vec3_t source_vec;
-//
-// if (cls.state != ca_active)
-// {
-// *left_vol = *right_vol = 255;
-// return;
-// }
-//
-//// calculate stereo seperation and distance attenuation
-// VectorSubtract(origin, listener_origin, source_vec);
-//
-// dist = VectorNormalize(source_vec);
-// dist -= SOUND_FULLVOLUME;
-// if (dist < 0)
-// dist = 0; // close enough to be at full volume
-// dist *= dist_mult; // different attenuation levels
-//
-// dot = DotProduct(listener_right, source_vec);
-//
-// if (dma.channels == 1 || !dist_mult)
-// { // no attenuation = no spatialization
-// rscale = 1.0;
-// lscale = 1.0;
-// }
-// else
-// {
-// rscale = 0.5 * (1.0 + dot);
-// lscale = 0.5*(1.0 - dot);
-// }
-//
-// // add in distance effect
-// scale = (1.0 - dist) * rscale;
-// *right_vol = (int) (master_vol * scale);
-// if (*right_vol < 0)
-// *right_vol = 0;
-//
-// scale = (1.0 - dist) * lscale;
-// *left_vol = (int) (master_vol * scale);
-// if (*left_vol < 0)
-// *left_vol = 0;
-// }
-//
-// /*
-// =================
-// S_Spatialize
-// =================
-// */
- static void Spatialize(channel_t ch)
- {
-// vec3_t origin;
-//
-// // anything coming from the view entity will always be full volume
-// if (ch->entnum == cl.playernum+1)
-// {
-// ch->leftvol = ch->master_vol;
-// ch->rightvol = ch->master_vol;
-// return;
-// }
-//
-// if (ch->fixed_origin)
-// {
-// VectorCopy (ch->origin, origin);
-// }
-// else
-// CL_GetEntitySoundOrigin (ch->entnum, origin);
-//
-// S_SpatializeOrigin (origin, ch->master_vol, ch->dist_mult, &ch->leftvol, &ch->rightvol);
- }
-
- /*
- =================
- S_AllocPlaysound
- =================
- */
- static playsound_t AllocPlaysound ()
- {
- playsound_t ps;
-
- ps = s_freeplays.next;
- if (ps == s_freeplays)
- return null; // no free playsounds
-
- // unlink from freelist
- ps.prev.next = ps.next;
- ps.next.prev = ps.prev;
-
- return ps;
- }
-//
-//
-// /*
-// =================
-// S_FreePlaysound
-// =================
-// */
-// void S_FreePlaysound (playsound_t *ps)
-// {
-// // unlink from channel
-// ps->prev->next = ps->next;
-// ps->next->prev = ps->prev;
-//
-// // add to free list
-// ps->next = s_freeplays.next;
-// s_freeplays.next->prev = ps;
-// ps->prev = &s_freeplays;
-// s_freeplays.next = ps;
-// }
-//
-//
-//
-// /*
-// ===============
-// S_IssuePlaysound
-//
-// Take the next playsound and begin it on the channel
-// This is never called directly by S_Play*, but only
-// by the update loop.
-// ===============
-// */
-// void S_IssuePlaysound (playsound_t *ps)
-// {
-// channel_t *ch;
-// sfxcache_t *sc;
-//
-// if (s_show->value)
-// Com_Printf ("Issue %i\n", ps->begin);
-// // pick a channel to play on
-// ch = S_PickChannel(ps->entnum, ps->entchannel);
-// if (!ch)
-// {
-// S_FreePlaysound (ps);
-// return;
-// }
-//
-// // spatialize
-// if (ps->attenuation == ATTN_STATIC)
-// ch->dist_mult = ps->attenuation * 0.001;
-// else
-// ch->dist_mult = ps->attenuation * 0.0005;
-// ch->master_vol = ps->volume;
-// ch->entnum = ps->entnum;
-// ch->entchannel = ps->entchannel;
-// ch->sfx = ps->sfx;
-// VectorCopy (ps->origin, ch->origin);
-// ch->fixed_origin = ps->fixed_origin;
-//
-// S_Spatialize(ch);
-//
-// ch->pos = 0;
-// sc = S_LoadSound (ch->sfx);
-// ch->end = paintedtime + sc->length;
-//
-// // free the playsound
-// S_FreePlaysound (ps);
-// }
-
- static sfx_t RegisterSexedSound(entity_state_t ent, String base) {
- sfx_t sfx = null;
-
- // determine what model the client is using
- String model = "male";
- int n = CS_PLAYERSKINS + ent.number - 1;
- if (cl.configstrings[n] != null) {
- int p = cl.configstrings[n].indexOf('\\');
- if (p >= 0) {
- p++;
- model = cl.configstrings[n].substring(p);
- //strcpy(model, p);
- p = model.indexOf('/');
- if (p > 0)
- model = model.substring(0, p - 1);
- }
- }
- // if we can't figure it out, they're male
- if (model == null || model.length() == 0)
- model = "male";
-
- // see if we already know of the model specific sound
- String sexedFilename = "#players/" + model + "/" + base.substring(1);
- //Com_sprintf (sexedFilename, sizeof(sexedFilename), "#players/%s/%s", model, base+1);
- sfx = S.FindName(sexedFilename, false);
-
- if (sfx == null) {
- // no, so see if it exists
- RandomAccessFile f = null;
- try {
- f = FS.FOpenFile(sexedFilename.substring(1));
- } catch (IOException e) {}
- if (f != null) {
- // yes, close the file and register it
- try {
- FS.FCloseFile(f);
- } catch (IOException e1) {}
- sfx = S.RegisterSound(sexedFilename);
- } else {
- // no, revert to the male sound in the pak0.pak
- //Com_sprintf (maleFilename, sizeof(maleFilename), "player/%s/%s", "male", base+1);
- String maleFilename = "player/male/" + base.substring(1);
- sfx = S.AliasName(sexedFilename, maleFilename);
- }
- }
-
- return sfx;
- }
-
-
-// =======================================================================
-// Start a sound effect
-// =======================================================================
-
- /*
- ====================
- S_StartSound
-
- Validates the parms and ques the sound up
- if pos is NULL, the sound will be dynamically sourced from the entity
- Entchannel 0 will never override a playing sound
- ====================
- */
- static void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) {
-
- if (!sound_started)
- return;
-
- if (sfx == null)
- return;
-
- if (sfx.name.charAt(0) == '*')
- sfx = S.RegisterSexedSound(cl_entities[entnum].current, sfx.name);
-
- // make sure the sound is loaded
- sfxcache_t sc = S.LoadSound(sfx);
- if (sc == null)
- return; // couldn't load the sound's data
-
- int vol = (int) (fvol * 255);
-
- // make the playsound_t
- playsound_t ps = S.AllocPlaysound();
- if (ps == null)
- return;
-
- if (origin != null) {
- VectorCopy(origin, ps.origin);
- ps.fixed_origin = true;
- } else
- ps.fixed_origin = false;
-
- ps.entnum = entnum;
- ps.entchannel = entchannel;
- ps.attenuation = attenuation;
- ps.volume = vol;
- ps.sfx = sfx;
-
- // drift s_beginofs
- int start = (int) (cl.frame.servertime * 0.001f * dma.speed + s_beginofs);
- if (start < paintedtime) {
- start = paintedtime;
- s_beginofs = (int) (start - (cl.frame.servertime * 0.001f * dma.speed));
- } else if (start > paintedtime + 0.3f * dma.speed) {
- start = (int) (paintedtime + 0.1f * dma.speed);
- s_beginofs = (int) (start - (cl.frame.servertime * 0.001f * dma.speed));
- } else {
- s_beginofs -= 10;
- }
-
- if (timeofs == 0.0f)
- ps.begin = paintedtime;
- else
- ps.begin = (long) (start + timeofs * dma.speed);
-
- // sort into the pending sound list
- playsound_t sort;
- for (sort = s_pendingplays.next; sort != s_pendingplays && sort.begin < ps.begin; sort = sort.next);
-
- ps.next = sort;
- ps.prev = sort.prev;
-
- ps.next.prev = ps;
- ps.prev.next = ps;
- }
-
- /*
- ==================
- S_StartLocalSound
- ==================
- */
- static void StartLocalSound(String sound) {
- sfx_t sfx;
-
- if (!sound_started)
- return;
-
- sfx = S.RegisterSound(sound);
- if (sfx == null) {
- Com.Printf("S_StartLocalSound: can't cache " + sound + "\n");
- return;
- }
- S.StartSound(null, cl.playernum + 1, 0, sfx, 1, 1, 0);
- }
-
-
- /*
- ==================
- S_ClearBuffer
- ==================
- */
- static void ClearBuffer()
- {
- int clear;
-
- if (!sound_started)
- return;
-
- s_rawend = 0;
-
- if (dma.samplebits == 8)
- clear = 0x80;
- else
- clear = 0;
-
- SNDDMA_BeginPainting ();
- if (dma.buffer != null)
- //memset(dma.buffer, clear, dma.samples * dma.samplebits/8);
- Arrays.fill(dma.buffer, (byte)clear);
- SNDDMA_Submit ();
- }
-
- /*
- ==================
- S_StopAllSounds
- ==================
- */
- static void StopAllSounds()
- {
- int i;
-
- if (!sound_started)
- return;
-
- // clear all the playsounds
- //memset(s_playsounds, 0, sizeof(s_playsounds));
- s_freeplays.next = s_freeplays.prev = s_freeplays;
- s_pendingplays.next = s_pendingplays.prev = s_pendingplays;
-
- for (i=0 ; i<MAX_PLAYSOUNDS ; i++)
- {
- s_playsounds[i].clear();
- s_playsounds[i].prev = s_freeplays;
- s_playsounds[i].next = s_freeplays.next;
- s_playsounds[i].prev.next = s_playsounds[i];
- s_playsounds[i].next.prev = s_playsounds[i];
- }
-
- // clear all the channels
- //memset(channels, 0, sizeof(channels));
- for (i = 0; i < MAX_CHANNELS; i++)
- channels[i].clear();
-
- S.ClearBuffer();
- }
-//
- /*
- ==================
- S_AddLoopSounds
-
- Entities with a ->sound field will generated looped sounds
- that are automatically started, stopped, and merged together
- as the entities are sent to the client
- ==================
- */
- static void AddLoopSounds()
- {
-// int i, j;
-// int sounds[MAX_EDICTS];
-// int left, right, left_total, right_total;
-// channel_t *ch;
-// sfx_t *sfx;
-// sfxcache_t *sc;
-// int num;
-// entity_state_t *ent;
-//
-// if (cl_paused->value)
-// return;
-//
-// if (cls.state != ca_active)
-// return;
-//
-// if (!cl.sound_prepped)
-// return;
-//
-// for (i=0 ; i<cl.frame.num_entities ; i++)
-// {
-// num = (cl.frame.parse_entities + i)&(MAX_PARSE_ENTITIES-1);
-// ent = &cl_parse_entities[num];
-// sounds[i] = ent->sound;
-// }
-//
-// for (i=0 ; i<cl.frame.num_entities ; i++)
-// {
-// if (!sounds[i])
-// continue;
-//
-// sfx = cl.sound_precache[sounds[i]];
-// if (!sfx)
-// continue; // bad sound effect
-// sc = sfx->cache;
-// if (!sc)
-// continue;
-//
-// num = (cl.frame.parse_entities + i)&(MAX_PARSE_ENTITIES-1);
-// ent = &cl_parse_entities[num];
-//
-// // find the total contribution of all sounds of this type
-// S_SpatializeOrigin (ent->origin, 255.0, SOUND_LOOPATTENUATE,
-// &left_total, &right_total);
-// for (j=i+1 ; j<cl.frame.num_entities ; j++)
-// {
-// if (sounds[j] != sounds[i])
-// continue;
-// sounds[j] = 0; // don't check this again later
-//
-// num = (cl.frame.parse_entities + j)&(MAX_PARSE_ENTITIES-1);
-// ent = &cl_parse_entities[num];
-//
-// S_SpatializeOrigin (ent->origin, 255.0, SOUND_LOOPATTENUATE,
-// &left, &right);
-// left_total += left;
-// right_total += right;
-// }
-//
-// if (left_total == 0 && right_total == 0)
-// continue; // not audible
-//
-// // allocate a channel
-// ch = S_PickChannel(0, 0);
-// if (!ch)
-// return;
-//
-// if (left_total > 255)
-// left_total = 255;
-// if (right_total > 255)
-// right_total = 255;
-// ch->leftvol = left_total;
-// ch->rightvol = right_total;
-// ch->autosound = true; // remove next frame
-// ch->sfx = sfx;
-// ch->pos = paintedtime % sc->length;
-// ch->end = paintedtime + sc->length - ch->pos;
-// }
- }
-//
-//// =============================================================================
-//
-// /*
-// ============
-// S_RawSamples
-//
-// Cinematic streaming and voice over network
-// ============
-// */
-// void S_RawSamples (int samples, int rate, int width, int channels, byte *data)
-// {
-// int i;
-// int src, dst;
-// float scale;
-//
-// if (!sound_started)
-// return;
-//
-// if (s_rawend < paintedtime)
-// s_rawend = paintedtime;
-// scale = (float)rate / dma.speed;
-//
-//// Com_Printf ("%i < %i < %i\n", soundtime, paintedtime, s_rawend);
-// if (channels == 2 && width == 2)
-// {
-// if (scale == 1.0)
-// { // optimized case
-// for (i=0 ; i<samples ; i++)
-// {
-// dst = s_rawend&(MAX_RAW_SAMPLES-1);
-// s_rawend++;
-// s_rawsamples[dst].left =
-// LittleShort(((short *)data)[i*2]) << 8;
-// s_rawsamples[dst].right =
-// LittleShort(((short *)data)[i*2+1]) << 8;
-// }
-// }
-// else
-// {
-// for (i=0 ; ; i++)
-// {
-// src = i*scale;
-// if (src >= samples)
-// break;
-// dst = s_rawend&(MAX_RAW_SAMPLES-1);
-// s_rawend++;
-// s_rawsamples[dst].left =
-// LittleShort(((short *)data)[src*2]) << 8;
-// s_rawsamples[dst].right =
-// LittleShort(((short *)data)[src*2+1]) << 8;
-// }
-// }
-// }
-// else if (channels == 1 && width == 2)
-// {
-// for (i=0 ; ; i++)
-// {
-// src = i*scale;
-// if (src >= samples)
-// break;
-// dst = s_rawend&(MAX_RAW_SAMPLES-1);
-// s_rawend++;
-// s_rawsamples[dst].left =
-// LittleShort(((short *)data)[src]) << 8;
-// s_rawsamples[dst].right =
-// LittleShort(((short *)data)[src]) << 8;
-// }
-// }
-// else if (channels == 2 && width == 1)
-// {
-// for (i=0 ; ; i++)
-// {
-// src = i*scale;
-// if (src >= samples)
-// break;
-// dst = s_rawend&(MAX_RAW_SAMPLES-1);
-// s_rawend++;
-// s_rawsamples[dst].left =
-// ((char *)data)[src*2] << 16;
-// s_rawsamples[dst].right =
-// ((char *)data)[src*2+1] << 16;
-// }
-// }
-// else if (channels == 1 && width == 1)
-// {
-// for (i=0 ; ; i++)
-// {
-// src = i*scale;
-// if (src >= samples)
-// break;
-// dst = s_rawend&(MAX_RAW_SAMPLES-1);
-// s_rawend++;
-// s_rawsamples[dst].left =
-// (((byte *)data)[src]-128) << 16;
-// s_rawsamples[dst].right = (((byte *)data)[src]-128) << 16;
-// }
-// }
-// }
-//
-//// =============================================================================
-
- /*
- ============
- S_Update
-
- Called once each time through the main loop
- ============
- */
- static void Update(float[] origin, float[] forward, float[] right, float[] up) {
-
- if (!sound_started)
- return;
-
- // if the laoding plaque is up, clear everything
- // out to make sure we aren't looping a dirty
- // dma buffer while loading
- if (cls.disable_screen != 0.0f) {
- S.ClearBuffer();
- return;
- }
-
- // rebuild scale tables if volume is modified
- if (s_volume.modified)
- S.InitScaletable();
-
- VectorCopy(origin, listener_origin);
- VectorCopy(forward, listener_forward);
- VectorCopy(right, listener_right);
- VectorCopy(up, listener_up);
-
- channel_t combine = null;
-
- // update spatialization for dynamic sounds
- channel_t ch;
- for (int i = 0; i < MAX_CHANNELS; i++) {
- ch = channels[i];
- if (ch.sfx == null)
- continue;
- if (ch.autosound) { // autosounds are regenerated fresh each frame
- //memset (ch, 0, sizeof(*ch));
- ch.clear();
- continue;
- }
- S.Spatialize(ch); // respatialize channel
- if (ch.leftvol == 0 && ch.rightvol == 0) {
- //memset (ch, 0, sizeof(*ch));
- ch.clear();
- continue;
- }
- }
-
- // add loopsounds
- S.AddLoopSounds();
-
- //
- // debugging output
- //
- if (s_show.value != 0.0f) {
- int total = 0;
-
- for (int i = 0; i < MAX_CHANNELS; i++) {
- ch = channels[i];
- if (ch.sfx != null && (ch.leftvol != 0 || ch.rightvol != 0)) {
- Com.Printf(ch.leftvol + " " + ch.rightvol + " " + ch.sfx.name + "\n");
- total++;
- }
- }
-
- Com.Printf("----(" + total + ")---- painted: " + paintedtime + "\n");
- }
-
- // mix some sound
- S.Update_();
- }
-
-//
-// void GetSoundtime(void)
-// {
-// int samplepos;
-// static int buffers;
-// static int oldsamplepos;
-// int fullsamples;
-//
-// fullsamples = dma.samples / dma.channels;
-//
-//// it is possible to miscount buffers if it has wrapped twice between
-//// calls to S_Update. Oh well.
-// samplepos = SNDDMA_GetDMAPos();
-//
-// if (samplepos < oldsamplepos)
-// {
-// buffers++; // buffer wrapped
-//
-// if (paintedtime > 0x40000000)
-// { // time to chop things off to avoid 32 bit limits
-// buffers = 0;
-// paintedtime = fullsamples;
-// S_StopAllSounds ();
-// }
-// }
-// oldsamplepos = samplepos;
-//
-// soundtime = buffers*fullsamples + samplepos/dma.channels;
-// }
-//
-//
- static void Update_()
- {
-// unsigned endtime;
-// int samps;
-//
-// if (!sound_started)
-// return;
-//
-// SNDDMA_BeginPainting ();
-//
-// if (!dma.buffer)
-// return;
-//
-//// Updates DMA time
-// GetSoundtime();
-//
-//// check to make sure that we haven't overshot
-// if (paintedtime < soundtime)
-// {
-// Com_DPrintf ("S_Update_ : overflow\n");
-// paintedtime = soundtime;
-// }
-//
-//// mix ahead of current position
-// endtime = soundtime + s_mixahead->value * dma.speed;
-//// endtime = (soundtime + 4096) & ~4095;
-//
-// // mix to an even submission block size
-// endtime = (endtime + dma.submission_chunk-1)
-// & ~(dma.submission_chunk-1);
-// samps = dma.samples >> (dma.channels-1);
-// if (endtime - soundtime > samps)
-// endtime = soundtime + samps;
-//
-// S_PaintChannels (endtime);
-//
-// SNDDMA_Submit ();
- }
-
- /*
- ===============================================================================
-
- console functions
-
- ===============================================================================
- */
-
- static void Play() {
- int i;
- String name;
- sfx_t sfx;
-
- i = 1;
- while (i < Cmd.Argc()) {
- name = new String(Cmd.Argv(i));
- if (name.indexOf('.') == -1)
- name += ".wav";
-
- sfx = S.RegisterSound(name);
- S.StartSound(null, cl.playernum + 1, 0, sfx, 1.0f, 1.0f, 0.0f);
- i++;
- }
- }
-
- static void SoundList() {
- int i;
- sfx_t sfx;
- sfxcache_t sc;
- int size, total;
-
- total = 0;
- for (i = 0; i < num_sfx; i++) {
- sfx = known_sfx[i];
- if (sfx.registration_sequence == 0)
- continue;
- sc = sfx.cache;
- if (sc != null) {
- size = sc.length * sc.width * (sc.stereo + 1);
- total += size;
- if (sc.loopstart >= 0)
- Com.Printf("L");
- else
- Com.Printf(" ");
- Com.Printf("(%2db) %6i : %s\n", new Vargs(3).add(sc.width * 8).add(size).add(sfx.name));
- } else {
- if (sfx.name.charAt(0) == '*')
- Com.Printf(" placeholder : " + sfx.name + "\n");
- else
- Com.Printf(" not loaded : " + sfx.name + "\n");
- }
- }
- Com.Printf("Total resident: " + total + "\n");
- }
-
-}
diff --git a/src/jake2/client/SND_JAVA.java b/src/jake2/client/SND_JAVA.java
deleted file mode 100644
index ddfa020..0000000
--- a/src/jake2/client/SND_JAVA.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * SND_JAVA.java
- * Copyright (C) 2004
- *
- * $Id: SND_JAVA.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
- */
-/*
-Copyright (C) 1997-2001 Id Software, Inc.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-package jake2.client;
-
-import jake2.Globals;
-import jake2.game.cvar_t;
-import jake2.qcommon.Cvar;
-import jake2.qcommon.FS;
-
-import java.io.*;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import javax.sound.sampled.*;
-
-/**
- * SND_JAVA
- */
-public class SND_JAVA extends Globals {
-
- static boolean snd_inited= false;
-
- static cvar_t sndbits;
- static cvar_t sndspeed;
- static cvar_t sndchannels;
-
-// static int tryrates[] = { 11025, 22051, 44100, 8000 };
- static class dma_t {
- int channels;
- int samples; // mono samples in buffer
- int submission_chunk; // don't mix less than this #
- int samplepos; // in mono samples
- int samplebits;
- int speed;
- byte[] buffer;
- }
- static SND_DMA.dma_t dma = new dma_t();
-
- static SourceDataLine line;
- static AudioFormat format;
-
-
- static boolean SNDDMA_Init() {
-
- if (snd_inited)
- return true;
-
- if (sndbits == null) {
- sndbits = Cvar.Get("sndbits", "16", CVAR_ARCHIVE);
- sndspeed = Cvar.Get("sndspeed", "0", CVAR_ARCHIVE);
- sndchannels = Cvar.Get("sndchannels", "2", CVAR_ARCHIVE);
- }
-
- byte[] sound = FS.LoadFile("sound/misc/menu1.wav");
- AudioInputStream stream;
- try {
- stream = AudioSystem.getAudioInputStream(new ByteArrayInputStream(sound));
- } catch (UnsupportedAudioFileException e) {
- return false;
- } catch (IOException e) {
- return false;
- }
- format = stream.getFormat();
-
- DataLine.Info dinfo = new DataLine.Info(SourceDataLine.class, format);
- //format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, format.getSampleRate(), format.getSampleSizeInBits(), 2, 2*format.getFrameSize(), format.getFrameRate(), format.isBigEndian());
-
- try {
- line = (SourceDataLine)AudioSystem.getLine(dinfo);
- } catch (LineUnavailableException e4) {
- return false;
- }
- dma.buffer = new byte[65536];
-// try {
-// stream.read(dma.buffer);
-// } catch (IOException e3) {
-// // TODO Auto-generated catch block
-// e3.printStackTrace();
-// }
-
- dma.channels = format.getChannels();
- dma.samplebits = format.getSampleSizeInBits();
- dma.samples = dma.buffer.length / format.getFrameSize();
- dma.speed = (int)format.getSampleRate();
- dma.samplepos = 0;
- dma.submission_chunk = 1;
-
- try {
- line.open(format, 4096);
- } catch (LineUnavailableException e5) {
- return false;
- }
-
- line.start();
- runLine();
-
- snd_inited = true;
- return true;
-
- }
-
- static int SNDDMA_GetDMAPos() {
- dma.samplepos = line.getFramePosition() % dma.samples;
- return dma.samplepos;
- }
-
- static void SNDDMA_Shutdown() {
- line.stop();
- line.flush();
- line.close();
- line=null;
- snd_inited = false;
- }
-
- /*
- ==============
- SNDDMA_Submit
-
- Send sound to device if buffer isn't really the dma buffer
- ===============
- */
- public static void SNDDMA_Submit() {
- runLine();
- }
-
- static void SNDDMA_BeginPainting() {}
-
- private static int pos = 0;
- static void runLine() {
-
- int p = line.getFramePosition() * format.getFrameSize() % dma.buffer.length;
- System.out.println("run " + p + " " + pos);
- if (p == 0) {
- writeLine();
- }
- else if (pos - p < 2048 ) writeLine();
- }
-
- static void writeLine() {
- line.write(dma.buffer, pos, 4096);
- pos+=4096;
- if (pos>=dma.buffer.length) pos = 0;
- }
-
-}
diff --git a/src/jake2/client/SND_MEM.java b/src/jake2/client/SND_MEM.java
deleted file mode 100644
index 85215d1..0000000
--- a/src/jake2/client/SND_MEM.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * SND_MEM.java
- * Copyright (C) 2004
- *
- * $Id: SND_MEM.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
- */
-/*
-Copyright (C) 1997-2001 Id Software, Inc.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-package jake2.client;
-
-import jake2.qcommon.Com;
-import jake2.qcommon.FS;
-
-/**
- * SND_MEM
- */
-public class SND_MEM extends SND_JAVA {
-
-//// snd_mem.c: sound caching
-//
-// #include "client.h"
-// #include "snd_loc.h"
-//
-// int cache_full_cycle;
-//
-// byte *S_Alloc (int size);
-//
- /*
- ================
- ResampleSfx
- ================
- */
- static void ResampleSfx (sfx_t sfx, int inrate, int inwidth, byte[] data, int ofs)
- {
- int outcount;
- int srcsample;
- float stepscale;
- int i;
- int sample, samplefrac, fracstep;
- sfxcache_t sc;
-
- sc = sfx.cache;
- if (sc == null)
- return;
-
- stepscale = (float)inrate / dma.speed; // this is usually 0.5, 1, or 2
-
- outcount = (int)(sc.length / stepscale);
- sc.length = outcount;
- if (sc.loopstart != -1)
- sc.loopstart = (int)(sc.loopstart / stepscale);
-
- sc.speed = dma.speed;
- if (SND_DMA.s_loadas8bit.value != 0.0f)
- sc.width = 1;
- else
- sc.width = inwidth;
- sc.stereo = 0;
-
-// resample / decimate to the current source rate
-
- if (stepscale == 1 && inwidth == 1 && sc.width == 1)
- {
-// fast special case
- for (i=0 ; i<outcount ; i++)
- sc.data[i+ofs] = (byte)((data[i+ofs] & 0xFF) - 128);
- }
- else
- {
-// general case
- samplefrac = 0;
- fracstep = (int)(stepscale*256);
-// for (i=0 ; i<outcount ; i++)
-// {
-// srcsample = samplefrac >> 8;
-// samplefrac += fracstep;
-// if (inwidth == 2)
-// sample = LittleShort ( ((short *)data)[srcsample] );
-// else
-// sample = (int)( (unsigned char)(data[srcsample]) - 128) << 8;
-// if (sc->width == 2)
-// ((short *)sc->data)[i] = sample;
-// else
-// ((signed char *)sc->data)[i] = sample >> 8;
-// }
- }
- }
-//
-//// =============================================================================
-//
- /*
- ==============
- S_LoadSound
- ==============
- */
- static sfxcache_t LoadSound(sfx_t s) {
- String namebuffer;
- byte[] data;
- wavinfo_t info;
- int len;
- float stepscale;
- sfxcache_t sc = null;
- int size;
- String name;
-
- if (s.name.charAt(0) == '*')
- return null;
-
- // see if still in memory
- sc = s.cache;
- if (sc != null)
- return sc;
-
- // load it in
- if (s.truename != null)
- name = s.truename;
- else
- name = s.name;
-
- if (name.charAt(0) == '#')
- namebuffer = name.substring(1);
- //strcpy(namebuffer, &name[1]);
- else
- namebuffer = "sound/" + name;
- //Com_sprintf (namebuffer, sizeof(namebuffer), "sound/%s", name);
-
- data = FS.LoadFile(namebuffer);
-
- if (data == null) {
- Com.DPrintf("Couldn't load " + namebuffer + "\n");
- return null;
- }
- size = data.length;
-
- info = GetWavinfo(s.name, data, size);
- if (info.channels != 1) {
- Com.Printf(s.name + " is a stereo sample\n");
- FS.FreeFile(data);
- return null;
- }
-
- stepscale = ((float)info.rate) / dma.speed;
- len = (int) (info.samples / stepscale);
-
- len = len * info.width * info.channels;
-
- //sc = s.cache = Z_Malloc (len + sizeof(sfxcache_t));
- sc = s.cache = new sfxcache_t(len);
-
- sc.length = info.samples;
- sc.loopstart = info.loopstart;
- sc.speed = info.rate;
- sc.width = info.width;
- sc.stereo = info.channels;
-
- ResampleSfx(s, sc.speed, sc.width, data, info.dataofs);
-
- FS.FreeFile(data);
-
- return sc;
- }
-//
-//
-//
-// /*
-// ===============================================================================
-//
-// WAV loading
-//
-// ===============================================================================
-// */
-//
- static byte[] data_b;
- static int data_p;
- static int iff_end;
- static int last_chunk;
- static int iff_data;
- static int iff_chunk_len;
-
-
- static short GetLittleShort() {
- short val = 0;
- val = data_b[data_p];
- data_p++;
- val |= (data_b[data_p] << 8);
- data_p++;
- return val;
- }
-
- static int GetLittleLong() {
- int val = 0;
- val = data_b[data_p];
- data_p++;
- val |= (data_b[data_p] << 8);
- data_p++;
- val |= (data_b[data_p] << 16);
- data_p++;
- val |= (data_b[data_p] << 24);
- data_p++;
- return val;
- }
-
- static void FindNextChunk(String name) {
- while (true) {
- data_p = last_chunk;
-
- if (data_p >= iff_end) { // didn't find the chunk
- data_p = 0;
- return;
- }
-
- data_p += 4;
- iff_chunk_len = GetLittleLong();
- if (iff_chunk_len < 0) {
- data_p = 0;
- return;
- }
- // if (iff_chunk_len > 1024*1024)
- // Sys_Error ("FindNextChunk: %i length is past the 1 meg sanity limit", iff_chunk_len);
- data_p -= 8;
- last_chunk = data_p + 8 + ((iff_chunk_len + 1) & ~1);
- String s = new String(data_b, data_p, 4);
- if (s.equals(name))
- return;
- }
- }
-
- static void FindChunk(String name) {
- last_chunk = iff_data;
- FindNextChunk(name);
- }
-//
-//
-// void DumpChunks(void)
-// {
-// char str[5];
-//
-// str[4] = 0;
-// data_p=iff_data;
-// do
-// {
-// memcpy (str, data_p, 4);
-// data_p += 4;
-// iff_chunk_len = GetLittleLong();
-// Com_Printf ("0x%x : %s (%d)\n", (int)(data_p - 4), str, iff_chunk_len);
-// data_p += (iff_chunk_len + 1) & ~1;
-// } while (data_p < iff_end);
-// }
-//
- /*
- ============
- GetWavinfo
- ============
- */
- static wavinfo_t GetWavinfo(String name, byte[] wav, int wavlength) {
- wavinfo_t info = new wavinfo_t();
- int i;
- int format;
- int samples;
-
- if (wav == null)
- return info;
-
- iff_data = 0;
- iff_end = wavlength;
- data_b = wav;
-
- // find "RIFF" chunk
- FindChunk("RIFF");
- String s = new String(data_b, data_p + 8, 4);
- if (!((data_p != 0) && s.equals("WAVE"))) {
- Com.Printf("Missing RIFF/WAVE chunks\n");
- return info;
- }
-
- // get "fmt " chunk
- iff_data = data_p + 12;
- // DumpChunks ();
-
- FindChunk("fmt ");
- if (data_p == 0) {
- Com.Printf("Missing fmt chunk\n");
- return info;
- }
- data_p += 8;
- format = GetLittleShort();
- if (format != 1) {
- Com.Printf("Microsoft PCM format only\n");
- return info;
- }
-
- info.channels = GetLittleShort();
- info.rate = GetLittleLong();
- data_p += 4 + 2;
- info.width = GetLittleShort() / 8;
-
- // get cue chunk
- FindChunk("cue ");
- if (data_p != 0) {
- data_p += 32;
- info.loopstart = GetLittleLong();
- // Com_Printf("loopstart=%d\n", sfx->loopstart);
-
- // if the next chunk is a LIST chunk, look for a cue length marker
- FindNextChunk("LIST");
- if (data_p != 0) {
- s = new String(data_b, data_p + 28, 4);
- if (s.equals("MARK")) { // this is not a proper parse, but it works with cooledit...
- data_p += 24;
- i = GetLittleLong(); // samples in loop
- info.samples = info.loopstart + i;
- // Com_Printf("looped length: %i\n", i);
- }
- }
- } else
- info.loopstart = -1;
-
- // find data chunk
- FindChunk("data");
- if (data_p == 0) {
- Com.Printf("Missing data chunk\n");
- return info;
- }
-
- data_p += 4;
- samples = GetLittleLong() / info.width;
-
- if (info.samples != 0) {
- if (samples < info.samples)
- Com.Error(ERR_DROP, "Sound " + name + " has a bad loop length");
- } else
- info.samples = samples;
-
- info.dataofs = data_p;
-
- return info;
- }
-
- static class wavinfo_t {
- int rate;
- int width;
- int channels;
- int loopstart;
- int samples;
- int dataofs; // chunk starts this many bytes from file start
- }
-}
diff --git a/src/jake2/client/SND_MIX.java b/src/jake2/client/SND_MIX.java
deleted file mode 100644
index 39f80a2..0000000
--- a/src/jake2/client/SND_MIX.java
+++ /dev/null
@@ -1,565 +0,0 @@
-/*
- * SND_MIX.java
- * Copyright (C) 2004
- *
- * $Id: SND_MIX.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
- */
-/*
-Copyright (C) 1997-2001 Id Software, Inc.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-package jake2.client;
-
-import jake2.game.cvar_t;
-import jake2.util.Math3D;
-
-/**
- * SND_MIX
- */
-public class SND_MIX extends SND_MEM {
-
- static final int MAX_CHANNELS = 32;
-
- static class playsound_t {
- playsound_t prev, next;
- sfx_t sfx;
- float volume;
- float attenuation;
- int entnum;
- int entchannel;
- boolean fixed_origin; // use origin field instead of entnum's origin
- float[] origin = { 0, 0, 0 };
- long begin; // begin on this sample
-
- public void clear() {
- prev = next = null;
- sfx = null;
- volume = attenuation = begin = entnum = entchannel = 0;
- fixed_origin = false;
- Math3D.VectorClear(origin);
- }
- };
-
- static class channel_t {
- sfx_t sfx; // sfx number
- int leftvol; // 0-255 volume
- int rightvol; // 0-255 volume
- int end; // end time in global paintsamples
- int pos; // sample position in sfx
- int looping; // where to loop, -1 = no looping OBSOLETE?
- int entnum; // to allow overriding a specific sound
- int entchannel; //
- float[] origin = { 0, 0, 0 }; // only use if fixed_origin is set
- float[] dist_mult = { 0, 0, 0 }; // distance multiplier (attenuation/clipK)
- int master_vol; // 0-255 master volume
- boolean fixed_origin; // use origin instead of fetching entnum's origin
- boolean autosound; // from an entity->sound, cleared each frame
-
- void clear() {
- sfx = null;
- leftvol = rightvol = end = pos = looping = entnum = entchannel = master_vol = 0;
- Math3D.VectorClear(origin);
- Math3D.VectorClear(dist_mult);
- fixed_origin = autosound = false;
- }
- };
-
- static cvar_t s_volume;
- static int s_rawend;
-//// snd_mix.c -- portable code to mix sounds for snd_dma.c
-//
-// #include "client.h"
-// #include "snd_loc.h"
-//
-// #define PAINTBUFFER_SIZE 2048
-// portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];
- static int[][] snd_scaletable = new int[32][256];
-// int *snd_p, snd_linear_count, snd_vol;
-// short *snd_out;
-//
-// void S_WriteLinearBlastStereo16 (void);
-//
-// #if !(defined __linux__ && defined __i386__)
-// #if !id386
-//
-// void S_WriteLinearBlastStereo16 (void)
-// {
-// int i;
-// int val;
-//
-// for (i=0 ; i<snd_linear_count ; i+=2)
-// {
-// val = snd_p[i]>>8;
-// if (val > 0x7fff)
-// snd_out[i] = 0x7fff;
-// else if (val < (short)0x8000)
-// snd_out[i] = (short)0x8000;
-// else
-// snd_out[i] = val;
-//
-// val = snd_p[i+1]>>8;
-// if (val > 0x7fff)
-// snd_out[i+1] = 0x7fff;
-// else if (val < (short)0x8000)
-// snd_out[i+1] = (short)0x8000;
-// else
-// snd_out[i+1] = val;
-// }
-// }
-// #else
-// __declspec( naked ) void S_WriteLinearBlastStereo16 (void)
-// {
-// __asm {
-//
-// push edi
-// push ebx
-// mov ecx,ds:dword ptr[snd_linear_count]
-// mov ebx,ds:dword ptr[snd_p]
-// mov edi,ds:dword ptr[snd_out]
-// LWLBLoopTop:
-// mov eax,ds:dword ptr[-8+ebx+ecx*4]
-// sar eax,8
-// cmp eax,07FFFh
-// jg LClampHigh
-// cmp eax,0FFFF8000h
-// jnl LClampDone
-// mov eax,0FFFF8000h
-// jmp LClampDone
-// LClampHigh:
-// mov eax,07FFFh
-// LClampDone:
-// mov edx,ds:dword ptr[-4+ebx+ecx*4]
-// sar edx,8
-// cmp edx,07FFFh
-// jg LClampHigh2
-// cmp edx,0FFFF8000h
-// jnl LClampDone2
-// mov edx,0FFFF8000h
-// jmp LClampDone2
-// LClampHigh2:
-// mov edx,07FFFh
-// LClampDone2:
-// shl edx,16
-// and eax,0FFFFh
-// or edx,eax
-// mov ds:dword ptr[-4+edi+ecx*2],edx
-// sub ecx,2
-// jnz LWLBLoopTop
-// pop ebx
-// pop edi
-// ret
-// }
-// }
-//
-// #endif
-// #endif
-//
-// void S_TransferStereo16 (unsigned long *pbuf, int endtime)
-// {
-// int lpos;
-// int lpaintedtime;
-//
-// snd_p = (int *) paintbuffer;
-// lpaintedtime = paintedtime;
-//
-// while (lpaintedtime < endtime)
-// {
-// // handle recirculating buffer issues
-// lpos = lpaintedtime & ((dma.samples>>1)-1);
-//
-// snd_out = (short *) pbuf + (lpos<<1);
-//
-// snd_linear_count = (dma.samples>>1) - lpos;
-// if (lpaintedtime + snd_linear_count > endtime)
-// snd_linear_count = endtime - lpaintedtime;
-//
-// snd_linear_count <<= 1;
-//
-// // write a linear blast of samples
-// S_WriteLinearBlastStereo16 ();
-//
-// snd_p += snd_linear_count;
-// lpaintedtime += (snd_linear_count>>1);
-// }
-// }
-//
-// /*
-// ===================
-// S_TransferPaintBuffer
-//
-// ===================
-// */
-// void S_TransferPaintBuffer(int endtime)
-// {
-// int out_idx;
-// int count;
-// int out_mask;
-// int *p;
-// int step;
-// int val;
-// unsigned long *pbuf;
-//
-// pbuf = (unsigned long *)dma.buffer;
-//
-// if (s_testsound->value)
-// {
-// int i;
-// int count;
-//
-// // write a fixed sine wave
-// count = (endtime - paintedtime);
-// for (i=0 ; i<count ; i++)
-// paintbuffer[i].left = paintbuffer[i].right = sin((paintedtime+i)*0.1)*20000*256;
-// }
-//
-//
-// if (dma.samplebits == 16 && dma.channels == 2)
-// { // optimized case
-// S_TransferStereo16 (pbuf, endtime);
-// }
-// else
-// { // general case
-// p = (int *) paintbuffer;
-// count = (endtime - paintedtime) * dma.channels;
-// out_mask = dma.samples - 1;
-// out_idx = paintedtime * dma.channels & out_mask;
-// step = 3 - dma.channels;
-//
-// if (dma.samplebits == 16)
-// {
-// short *out = (short *) pbuf;
-// while (count--)
-// {
-// val = *p >> 8;
-// p+= step;
-// if (val > 0x7fff)
-// val = 0x7fff;
-// else if (val < (short)0x8000)
-// val = (short)0x8000;
-// out[out_idx] = val;
-// out_idx = (out_idx + 1) & out_mask;
-// }
-// }
-// else if (dma.samplebits == 8)
-// {
-// unsigned char *out = (unsigned char *) pbuf;
-// while (count--)
-// {
-// val = *p >> 8;
-// p+= step;
-// if (val > 0x7fff)
-// val = 0x7fff;
-// else if (val < (short)0x8000)
-// val = (short)0x8000;
-// out[out_idx] = (val>>8) + 128;
-// out_idx = (out_idx + 1) & out_mask;
-// }
-// }
-// }
-// }
-//
-//
-// /*
-// ===============================================================================
-//
-// CHANNEL MIXING
-//
-// ===============================================================================
-// */
-//
-// void S_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime, int offset);
-// void S_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime, int offset);
-//
-// void S_PaintChannels(int endtime)
-// {
-// int i;
-// int end;
-// channel_t *ch;
-// sfxcache_t *sc;
-// int ltime, count;
-// playsound_t *ps;
-//
-// snd_vol = s_volume->value*256;
-//
-//// Com_Printf ("%i to %i\n", paintedtime, endtime);
-// while (paintedtime < endtime)
-// {
-// // if paintbuffer is smaller than DMA buffer
-// end = endtime;
-// if (endtime - paintedtime > PAINTBUFFER_SIZE)
-// end = paintedtime + PAINTBUFFER_SIZE;
-//
-// // start any playsounds
-// while (1)
-// {
-// ps = s_pendingplays.next;
-// if (ps == &s_pendingplays)
-// break; // no more pending sounds
-// if (ps->begin <= paintedtime)
-// {
-// S_IssuePlaysound (ps);
-// continue;
-// }
-//
-// if (ps->begin < end)
-// end = ps->begin; // stop here
-// break;
-// }
-//
-// // clear the paint buffer
-// if (s_rawend < paintedtime)
-// {
-//// Com_Printf ("clear\n");
-// memset(paintbuffer, 0, (end - paintedtime) * sizeof(portable_samplepair_t));
-// }
-// else
-// { // copy from the streaming sound source
-// int s;
-// int stop;
-//
-// stop = (end < s_rawend) ? end : s_rawend;
-//
-// for (i=paintedtime ; i<stop ; i++)
-// {
-// s = i&(MAX_RAW_SAMPLES-1);
-// paintbuffer[i-paintedtime] = s_rawsamples[s];
-// }
-//// if (i != end)
-//// Com_Printf ("partial stream\n");
-//// else
-//// Com_Printf ("full stream\n");
-// for ( ; i<end ; i++)
-// {
-// paintbuffer[i-paintedtime].left =
-// paintbuffer[i-paintedtime].right = 0;
-// }
-// }
-//
-//
-// // paint in the channels.
-// ch = channels;
-// for (i=0; i<MAX_CHANNELS ; i++, ch++)
-// {
-// ltime = paintedtime;
-//
-// while (ltime < end)
-// {
-// if (!ch->sfx || (!ch->leftvol && !ch->rightvol) )
-// break;
-//
-// // max painting is to the end of the buffer
-// count = end - ltime;
-//
-// // might be stopped by running out of data
-// if (ch->end - ltime < count)
-// count = ch->end - ltime;
-//
-// sc = S_LoadSound (ch->sfx);
-// if (!sc)
-// break;
-//
-// if (count > 0 && ch->sfx)
-// {
-// if (sc->width == 1)// FIXME; 8 bit asm is wrong now
-// S_PaintChannelFrom8(ch, sc, count, ltime - paintedtime);
-// else
-// S_PaintChannelFrom16(ch, sc, count, ltime - paintedtime);
-//
-// ltime += count;
-// }
-//
-// // if at end of loop, restart
-// if (ltime >= ch->end)
-// {
-// if (ch->autosound)
-// { // autolooping sounds always go back to start
-// ch->pos = 0;
-// ch->end = ltime + sc->length;
-// }
-// else if (sc->loopstart >= 0)
-// {
-// ch->pos = sc->loopstart;
-// ch->end = ltime + sc->length - ch->pos;
-// }
-// else
-// { // channel just stopped
-// ch->sfx = NULL;
-// }
-// }
-// }
-//
-// }
-//
-// // transfer out according to DMA format
-// S_TransferPaintBuffer(end);
-// paintedtime = end;
-// }
-// }
-//
- static void InitScaletable ()
- {
- int i, j;
- int scale;
-
- s_volume.modified = false;
- for (i=0 ; i<32 ; i++)
- {
- scale = (int)(i * 8 * 256 * s_volume.value);
- for (j=0 ; j<256 ; j++)
- snd_scaletable[i][j] = ((byte)j) * scale;
- }
- }
-//
-//
-// #if !(defined __linux__ && defined __i386__)
-// #if !id386
-//
-// void S_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count, int offset)
-// {
-// int data;
-// int *lscale, *rscale;
-// unsigned char *sfx;
-// int i;
-// portable_samplepair_t *samp;
-//
-// if (ch->leftvol > 255)
-// ch->leftvol = 255;
-// if (ch->rightvol > 255)
-// ch->rightvol = 255;
-//
-// //ZOID-- >>11 has been changed to >>3, >>11 didn't make much sense
-// //as it would always be zero.
-// lscale = snd_scaletable[ ch->leftvol >> 3];
-// rscale = snd_scaletable[ ch->rightvol >> 3];
-// sfx = (signed char *)sc->data + ch->pos;
-//
-// samp = &paintbuffer[offset];
-//
-// for (i=0 ; i<count ; i++, samp++)
-// {
-// data = sfx[i];
-// samp->left += lscale[data];
-// samp->right += rscale[data];
-// }
-//
-// ch->pos += count;
-// }
-//
-// #else
-//
-// __declspec( naked ) void S_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count, int offset)
-// {
-// __asm {
-// push esi
-// push edi
-// push ebx
-// push ebp
-// mov ebx,ds:dword ptr[4+16+esp]
-// mov esi,ds:dword ptr[8+16+esp]
-// mov eax,ds:dword ptr[4+ebx]
-// mov edx,ds:dword ptr[8+ebx]
-// cmp eax,255
-// jna LLeftSet
-// mov eax,255
-// LLeftSet:
-// cmp edx,255
-// jna LRightSet
-// mov edx,255
-// LRightSet:
-// and eax,0F8h
-// add esi,20
-// and edx,0F8h
-// mov edi,ds:dword ptr[16+ebx]
-// mov ecx,ds:dword ptr[12+16+esp]
-// add esi,edi
-// shl eax,7
-// add edi,ecx
-// shl edx,7
-// mov ds:dword ptr[16+ebx],edi
-// add eax,offset snd_scaletable
-// add edx,offset snd_scaletable
-// sub ebx,ebx
-// mov bl,ds:byte ptr[-1+esi+ecx*1]
-// test ecx,1
-// jz LMix8Loop
-// mov edi,ds:dword ptr[eax+ebx*4]
-// mov ebp,ds:dword ptr[edx+ebx*4]
-// add edi,ds:dword ptr[paintbuffer+0-8+ecx*8]
-// add ebp,ds:dword ptr[paintbuffer+4-8+ecx*8]
-// mov ds:dword ptr[paintbuffer+0-8+ecx*8],edi
-// mov ds:dword ptr[paintbuffer+4-8+ecx*8],ebp
-// mov bl,ds:byte ptr[-2+esi+ecx*1]
-// dec ecx
-// jz LDone
-// LMix8Loop:
-// mov edi,ds:dword ptr[eax+ebx*4]
-// mov ebp,ds:dword ptr[edx+ebx*4]
-// add edi,ds:dword ptr[paintbuffer+0-8+ecx*8]
-// add ebp,ds:dword ptr[paintbuffer+4-8+ecx*8]
-// mov bl,ds:byte ptr[-2+esi+ecx*1]
-// mov ds:dword ptr[paintbuffer+0-8+ecx*8],edi
-// mov ds:dword ptr[paintbuffer+4-8+ecx*8],ebp
-// mov edi,ds:dword ptr[eax+ebx*4]
-// mov ebp,ds:dword ptr[edx+ebx*4]
-// mov bl,ds:byte ptr[-3+esi+ecx*1]
-// add edi,ds:dword ptr[paintbuffer+0-8*2+ecx*8]
-// add ebp,ds:dword ptr[paintbuffer+4-8*2+ecx*8]
-// mov ds:dword ptr[paintbuffer+0-8*2+ecx*8],edi
-// mov ds:dword ptr[paintbuffer+4-8*2+ecx*8],ebp
-// sub ecx,2
-// jnz LMix8Loop
-// LDone:
-// pop ebp
-// pop ebx
-// pop edi
-// pop esi
-// ret
-// }
-// }
-//
-// #endif
-// #endif
-//
-// void S_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count, int offset)
-// {
-// int data;
-// int left, right;
-// int leftvol, rightvol;
-// signed short *sfx;
-// int i;
-// portable_samplepair_t *samp;
-//
-// leftvol = ch->leftvol*snd_vol;
-// rightvol = ch->rightvol*snd_vol;
-// sfx = (signed short *)sc->data + ch->pos;
-//
-// samp = &paintbuffer[offset];
-// for (i=0 ; i<count ; i++, samp++)
-// {
-// data = sfx[i];
-// left = (data * leftvol)>>8;
-// right = (data * rightvol)>>8;
-// samp->left += left;
-// samp->right += right;
-// }
-//
-// ch->pos += count;
-// }
-//
-//
-} \ No newline at end of file
diff --git a/src/jake2/client/VID.java b/src/jake2/client/VID.java
index 2b8cb81..53a943f 100644
--- a/src/jake2/client/VID.java
+++ b/src/jake2/client/VID.java
@@ -2,7 +2,7 @@
* VID.java
* Copyright (C) 2003
*
- * $Id: VID.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+ * $Id: VID.java,v 1.4 2004-07-08 20:56:50 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -31,6 +31,7 @@ import jake2.game.Cmd;
import jake2.game.cvar_t;
import jake2.qcommon.*;
import jake2.render.Renderer;
+import jake2.sound.*;
import jake2.sys.IN;
import jake2.sys.KBD;
import jake2.util.Vargs;
diff --git a/src/jake2/client/centity_t.java b/src/jake2/client/centity_t.java
index 0c26bed..0d4f822 100644
--- a/src/jake2/client/centity_t.java
+++ b/src/jake2/client/centity_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 27.11.2003 by RST.
-// $Id: centity_t.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+// $Id: centity_t.java,v 1.2 2004-07-08 20:56:50 hzi Exp $
package jake2.client;
@@ -27,7 +27,7 @@ import jake2.game.entity_state_t;
public class centity_t {
entity_state_t baseline= new entity_state_t(null); // delta from this if not from a previous frame
- entity_state_t current= new entity_state_t(null);
+ public entity_state_t current= new entity_state_t(null);
entity_state_t prev= new entity_state_t(null); // will always be valid, but might just be a copy of current
int serverframe; // if not current, this ent isn't in the frame
diff --git a/src/jake2/client/client_state_t.java b/src/jake2/client/client_state_t.java
index 3577932..ff86070 100644
--- a/src/jake2/client/client_state_t.java
+++ b/src/jake2/client/client_state_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 27.11.2003 by RST.
-//$Id: client_state_t.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+//$Id: client_state_t.java,v 1.2 2004-07-08 20:56:51 hzi Exp $
package jake2.client;
@@ -28,6 +28,7 @@ import jake2.game.cmodel_t;
import jake2.game.usercmd_t;
import jake2.render.image_t;
import jake2.render.model_t;
+import jake2.sound.*;
import java.io.RandomAccessFile;
@@ -118,9 +119,9 @@ public class client_state_t {
boolean attractloop; // running the attract loop, any key will menu
int servercount; // server identification for prespawns
String gamedir ="";
- int playernum;
+ public int playernum;
- String configstrings[] = new String[Defines.MAX_CONFIGSTRINGS];
+ public String configstrings[] = new String[Defines.MAX_CONFIGSTRINGS];
//
// locally derived information from server state
diff --git a/src/jake2/client/frame_t.java b/src/jake2/client/frame_t.java
index d493363..1e414dc 100644
--- a/src/jake2/client/frame_t.java
+++ b/src/jake2/client/frame_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 27.11.2003 by RST.
-// $Id: frame_t.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+// $Id: frame_t.java,v 1.2 2004-07-08 20:56:50 hzi Exp $
package jake2.client;
@@ -33,7 +33,7 @@ public class frame_t implements Cloneable {
boolean valid; // cleared if delta parsing was invalid
int serverframe;
- int servertime; // server time the message is valid for (in msec)
+ public int servertime; // server time the message is valid for (in msec)
int deltaframe;
byte areabits[] = new byte [MAX_MAP_AREAS/8]; // portalarea visibility bits
public player_state_t playerstate = new player_state_t(); // mem
diff --git a/src/jake2/render/jogl/Impl.java b/src/jake2/render/jogl/Impl.java
index ba8b929..991c349 100644
--- a/src/jake2/render/jogl/Impl.java
+++ b/src/jake2/render/jogl/Impl.java
@@ -2,7 +2,7 @@
* Impl.java
* Copyright (C) 2003
*
- * $Id: Impl.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+ * $Id: Impl.java,v 1.4 2004-07-08 20:56:55 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -27,7 +27,10 @@ package jake2.render.jogl;
import jake2.Defines;
import jake2.Globals;
+import jake2.client.CL;
+import jake2.qcommon.Com;
import jake2.qcommon.xcommand_t;
+import jake2.server.SV;
import jake2.sys.KBD;
import java.awt.Dimension;
@@ -126,9 +129,7 @@ public class Impl extends Misc implements GLEventListener {
// register event listener
window.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
- R_Shutdown();
- System.out.println("Received event " + e.paramString() + ", exiting...\n");
- System.exit(0);
+ ri.Cmd_ExecuteText(Defines.EXEC_APPEND, "quit");
}
});
diff --git a/src/jake2/render/jogl/Light.java b/src/jake2/render/jogl/Light.java
index 214641d..686884a 100644
--- a/src/jake2/render/jogl/Light.java
+++ b/src/jake2/render/jogl/Light.java
@@ -2,7 +2,7 @@
* Light.java
* Copyright (C) 2003
*
- * $Id: Light.java,v 1.2 2004-07-08 20:24:30 hzi Exp $
+ * $Id: Light.java,v 1.3 2004-07-08 20:56:55 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -146,6 +146,7 @@ public abstract class Light extends Warp {
float dist;
msurface_t surf;
int i;
+ int sidebit;
if (node.contents != -1)
return;
@@ -167,7 +168,22 @@ public abstract class Light extends Warp {
// mark the polygons
for (i=0 ; i<node.numsurfaces ; i++)
{
+
surf = r_worldmodel.surfaces[node.firstsurface + i];
+
+ /*
+ * cwei
+ * bugfix for dlight behind the walls
+ */
+ dist = Math3D.DotProduct (light.origin, surf.plane.normal) - surf.plane.dist;
+ sidebit = (dist >= 0) ? 0 : Defines.SURF_PLANEBACK;
+ if ( (surf.flags & Defines.SURF_PLANEBACK) != sidebit )
+ continue;
+ /*
+ * cwei
+ * bugfix end
+ */
+
if (surf.dlightframe != r_dlightframecount)
{
surf.dlightbits = 0;
diff --git a/src/jake2/server/SV_GAME.java b/src/jake2/server/SV_GAME.java
index 8f920ec..8f6eec4 100644
--- a/src/jake2/server/SV_GAME.java
+++ b/src/jake2/server/SV_GAME.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 14.01.2004 by RST.
-// $Id: SV_GAME.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
+// $Id: SV_GAME.java,v 1.4 2004-07-08 20:56:54 hzi Exp $
package jake2.server;
@@ -312,7 +312,7 @@ public class SV_GAME extends SV_INIT {
return;
//TODO: impl SV_StartSound
- //SV_SEND.SV_StartSound (null, entity, channel, sound_num, volume, attenuation, timeofs);
+ SV_SEND.SV_StartSound (null, entity, channel, sound_num, volume, attenuation, timeofs);
}
//==============================================
diff --git a/src/jake2/server/SV_SEND.java b/src/jake2/server/SV_SEND.java
index 747f2d4..0764ce6 100644
--- a/src/jake2/server/SV_SEND.java
+++ b/src/jake2/server/SV_SEND.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_SEND.java,v 1.2 2004-07-08 20:24:30 hzi Exp $
+// $Id: SV_SEND.java,v 1.3 2004-07-08 20:56:54 hzi Exp $
package jake2.server;
@@ -287,7 +287,7 @@ public class SV_SEND extends SV_MAIN {
int flags;
int i;
int ent;
- float[] origin_v = null;
+ float[] origin_v = {0,0,0};
boolean use_phs;
if (volume < 0 || volume > 1.0)
diff --git a/src/jake2/sound/DummyDriver.java b/src/jake2/sound/DummyDriver.java
new file mode 100644
index 0000000..e663d09
--- /dev/null
+++ b/src/jake2/sound/DummyDriver.java
@@ -0,0 +1,111 @@
+/*
+ * Created on Apr 25, 2004
+ *
+ * Copyright (C) 2003
+ *
+ * $Id: DummyDriver.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
+ */
+/*
+Copyright (C) 1997-2001 Id Software, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+package jake2.sound;
+
+/**
+ * DummyDriver
+ *
+ * @author cwei
+ */
+public final class DummyDriver implements Sound {
+
+ static {
+ S.register(new DummyDriver());
+ };
+
+ private DummyDriver() {
+ }
+
+ /* (non-Javadoc)
+ * @see jake2.sound.Sound#Init()
+ */
+ public boolean Init() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see jake2.sound.Sound#Shutdown()
+ */
+ public void Shutdown() {
+ }
+
+ /* (non-Javadoc)
+ * @see jake2.sound.Sound#BeginRegistration()
+ */
+ public void BeginRegistration() {
+ }
+
+ /* (non-Javadoc)
+ * @see jake2.sound.Sound#RegisterSound(java.lang.String)
+ */
+ public sfx_t RegisterSound(String sample) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see jake2.sound.Sound#EndRegistration()
+ */
+ public void EndRegistration() {
+ }
+
+ /* (non-Javadoc)
+ * @see jake2.sound.Sound#StartLocalSound(java.lang.String)
+ */
+ public void StartLocalSound(String sound) {
+ }
+
+ /* (non-Javadoc)
+ * @see jake2.sound.Sound#StartSound(float[], int, int, jake2.sound.sfx_t, float, float, float)
+ */
+ public void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) {
+ }
+
+ /* (non-Javadoc)
+ * @see jake2.sound.Sound#Update(float[], float[], float[], float[])
+ */
+ public void Update(float[] origin, float[] forward, float[] right, float[] up) {
+ }
+
+ /* (non-Javadoc)
+ * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[])
+ */
+ public void RawSamples(int samples, int rate, int width, int channels, byte[] data) {
+ }
+
+ /* (non-Javadoc)
+ * @see jake2.sound.Sound#StopAllSounds()
+ */
+ public void StopAllSounds() {
+ }
+
+ /* (non-Javadoc)
+ * @see jake2.sound.Sound#getName()
+ */
+ public String getName() {
+ return "dummy";
+ }
+}
diff --git a/src/jake2/sound/S.java b/src/jake2/sound/S.java
new file mode 100644
index 0000000..c696501
--- /dev/null
+++ b/src/jake2/sound/S.java
@@ -0,0 +1,187 @@
+/*
+ * S.java
+ * Copyright (C) 2003
+ *
+ * $Id: S.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
+ */
+/*
+Copyright (C) 1997-2001 Id Software, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+package jake2.sound;
+
+import jake2.Defines;
+import jake2.game.cvar_t;
+import jake2.qcommon.Com;
+import jake2.qcommon.Cvar;
+
+import java.util.Vector;
+
+/**
+ * S
+ */
+public class S {
+
+ static Sound impl;
+ static cvar_t s_impl;
+
+ static Vector drivers = new Vector(3);
+
+ static {
+ try {
+ Class.forName("jake2.sound.DummyDriver");
+ Class.forName("jake2.sound.joal.JOALSoundImpl");
+ Class.forName("jake2.sound.jsound.JSoundImpl");
+ }
+ catch (ClassNotFoundException e) {
+ }
+ };
+
+ public static void register(Sound driver) {
+ if (driver == null) {
+ throw new IllegalArgumentException("Sound implementation can't be null");
+ }
+ if (!drivers.contains(driver)) {
+ drivers.add(driver);
+ }
+ }
+
+ public static void useDriver(String driverName) {
+ Sound driver = null;
+ int count = drivers.size();
+ for (int i = 0; i < count; i++) {
+ driver = (Sound) drivers.get(i);
+ if (driver.getName().equals(driverName)) {
+ impl = driver;
+ return;
+ }
+ }
+ // if driver not found use dummy
+ impl = (Sound)drivers.get(0);
+ }
+
+ public static void Init() {
+
+ Com.Printf("\n------- sound initialization -------\n");
+
+ cvar_t cv = Cvar.Get("s_initsound", "1", 0);
+ if (cv.value == 0.0f) {
+ Com.Printf("not initializing.\n");
+ useDriver("dummy");
+ return;
+ }
+
+ s_impl = Cvar.Get("s_impl", "joal", Defines.CVAR_ARCHIVE);
+ useDriver(s_impl.string);
+
+ if (impl.Init()) {
+ // driver ok
+ Cvar.Set("s_impl", impl.getName());
+ } else {
+ // fallback
+ useDriver("dummy");
+ }
+
+ Com.Printf("\n------- use sound driver \"" + impl.getName() + "\" -------\n");
+ StopAllSounds();
+ }
+
+ public static void Shutdown() {
+ impl.Shutdown();
+ }
+
+ /*
+ =====================
+ S_BeginRegistration
+ =====================
+ */
+ public static void BeginRegistration() {
+ impl.BeginRegistration();
+ }
+
+ /*
+ =====================
+ S_RegisterSound
+ =====================
+ */
+ public static sfx_t RegisterSound(String sample) {
+ return impl.RegisterSound(sample);
+ }
+
+ /*
+ =====================
+ S_EndRegistration
+ =====================
+ */
+ public static void EndRegistration() {
+ impl.EndRegistration();
+ }
+
+ /*
+ ==================
+ S_StartLocalSound
+ ==================
+ */
+ public static void StartLocalSound(String sound) {
+ impl.StartLocalSound(sound);
+ }
+
+ /*
+ ====================
+ S_StartSound
+
+ Validates the parms and ques the sound up
+ if pos is NULL, the sound will be dynamically sourced from the entity
+ Entchannel 0 will never override a playing sound
+ ====================
+ */
+ public static void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) {
+ impl.StartSound(origin, entnum, entchannel, sfx, fvol, attenuation, timeofs);
+ }
+
+ /*
+ ============
+ S_Update
+
+ Called once each time through the main loop
+ ============
+ */
+ public static void Update(float[] origin, float[] forward, float[] right, float[] up) {
+ impl.Update(origin, forward, right, up);
+ }
+
+ /*
+ ============
+ S_RawSamples
+
+ Cinematic streaming and voice over network
+ ============
+ */
+ public static void RawSamples(int samples, int rate, int width, int channels, byte[] data) {
+ impl.RawSamples(samples, rate, width, channels, data);
+ }
+
+ /*
+ ==================
+ S_StopAllSounds
+ ==================
+ */
+ public static void StopAllSounds() {
+ impl.StopAllSounds();
+ }
+}
diff --git a/src/jake2/sound/Sound.java b/src/jake2/sound/Sound.java
new file mode 100644
index 0000000..30bd8c6
--- /dev/null
+++ b/src/jake2/sound/Sound.java
@@ -0,0 +1,105 @@
+/*
+ * Created on Apr 25, 2004
+ *
+ * Copyright (C) 2003
+ *
+ * $Id: Sound.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
+ */
+/*
+Copyright (C) 1997-2001 Id Software, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+package jake2.sound;
+
+/**
+ * Sound
+ *
+ * @author cwei
+ */
+public interface Sound {
+
+
+ String getName();
+
+ boolean Init();
+ void Shutdown();
+
+ /*
+ =====================
+ S_BeginRegistration
+ =====================
+ */
+ void BeginRegistration();
+
+ /*
+ =====================
+ S_RegisterSound
+ =====================
+ */
+ sfx_t RegisterSound(String sample);
+
+ /*
+ =====================
+ S_EndRegistration
+ =====================
+ */
+ void EndRegistration();
+
+ /*
+ ==================
+ S_StartLocalSound
+ ==================
+ */
+ void StartLocalSound(String sound);
+
+ /*
+ ====================
+ S_StartSound
+
+ Validates the parms and ques the sound up
+ if pos is NULL, the sound will be dynamically sourced from the entity
+ Entchannel 0 will never override a playing sound
+ ====================
+ */
+ void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs);
+
+ /*
+ ============
+ S_Update
+
+ Called once each time through the main loop
+ ============
+ */
+ void Update(float[] origin, float[] forward, float[] right, float[] up);
+ /*
+ ============
+ S_RawSamples
+
+ Cinematic streaming and voice over network
+ ============
+ */
+ void RawSamples(int samples, int rate, int width, int channels, byte[] data);
+
+ /*
+ ==================
+ S_StopAllSounds
+ ==================
+ */
+ void StopAllSounds();
+
+}
diff --git a/src/jake2/client/sfx_t.java b/src/jake2/sound/sfx_t.java
index 71ab344..992c0e7 100644
--- a/src/jake2/client/sfx_t.java
+++ b/src/jake2/sound/sfx_t.java
@@ -1,14 +1,8 @@
/*
* sfx_t.java
- * Copyright (C) 2003
- *
- * $Id: sfx_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
- */
-/*
- * sfx_t.java
* Copyright (C) 2004
*
- * $Id: sfx_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+ * $Id: sfx_t.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -32,17 +26,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Created on 28.11.2003 by RST.
-package jake2.client;
+package jake2.sound;
+
public class sfx_t {
- String name; //mem
- int registration_sequence;
- sfxcache_t cache; //ptr
- String truename; //ptr
+ public String name; //mem
+ public int registration_sequence;
+ public sfxcache_t cache; //ptr
+ public String truename; //ptr
+
+ // cwei
+ public int id = -1;
public void clear() {
name = truename = null;
cache = null;
registration_sequence = 0;
+
+ // cwei
+ id = -1;
}
}
diff --git a/src/jake2/client/sfxcache_t.java b/src/jake2/sound/sfxcache_t.java
index 245d921..7f4428a 100644
--- a/src/jake2/client/sfxcache_t.java
+++ b/src/jake2/sound/sfxcache_t.java
@@ -19,17 +19,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 28.11.2003 by RST.
-// $Id: sfxcache_t.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
+// $Id: sfxcache_t.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
-package jake2.client;
+package jake2.sound;
public class sfxcache_t {
- int length;
- int loopstart;
- int speed; // not needed, because converted on load?
- int width;
- int stereo;
- byte data[]; // variable sized
+ public int length;
+ public int loopstart;
+ public int speed; // not needed, because converted on load?
+ public int width;
+ public int stereo;
+ public byte data[]; // variable sized
public sfxcache_t(int size) {
data = new byte[size];
diff --git a/src/jake2/sound/soundinfo_t.java b/src/jake2/sound/soundinfo_t.java
new file mode 100644
index 0000000..2c9e6c6
--- /dev/null
+++ b/src/jake2/sound/soundinfo_t.java
@@ -0,0 +1,19 @@
+/*
+ * soundinfo_t.java
+ * Copyright (C) 2004
+ *
+ * $Id: soundinfo_t.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
+ */
+package jake2.sound;
+
+/**
+ * soundinfo_t
+ */
+public class soundinfo_t {
+ int channels;
+ int samples; // mono samples in buffer
+ int submission_chunk; // don't mix less than this #
+ int samplepos; // in mono samples
+ int samplebits;
+ int speed;
+}
diff --git a/src/jake2/sound/wavinfo_t.java b/src/jake2/sound/wavinfo_t.java
new file mode 100644
index 0000000..76a28fc
--- /dev/null
+++ b/src/jake2/sound/wavinfo_t.java
@@ -0,0 +1,19 @@
+/*
+ * wavinfo_t.java
+ * Copyright (C) 2004
+ *
+ * $Id: wavinfo_t.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
+ */
+package jake2.sound;
+
+/**
+ * wavinfo_t
+ */
+public class wavinfo_t {
+ public int rate;
+ public int width;
+ public int channels;
+ public int loopstart;
+ public int samples;
+ public int dataofs; // chunk starts this many bytes from file start
+}
diff --git a/src/jake2/util/Math3D.java b/src/jake2/util/Math3D.java
index fcdeaee..a434a05 100644
--- a/src/jake2/util/Math3D.java
+++ b/src/jake2/util/Math3D.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 09.12.2003 by RST.
-// $Id: Math3D.java,v 1.3 2004-07-08 20:24:31 hzi Exp $
+// $Id: Math3D.java,v 1.4 2004-07-08 20:56:54 hzi Exp $
package jake2.util;
@@ -459,13 +459,14 @@ public class Math3D extends Lib {
float angle;
float sr, sp, sy, cr, cp, cy;
- angle = (float) (angles[Defines.YAW] * (2.0f * piratio));
+ cr = 2.0f * piratio;
+ angle = (float) (angles[Defines.YAW] * (cr));
sy = (float) Math.sin(angle);
cy = (float) Math.cos(angle);
- angle = (float) (angles[Defines.PITCH] * (2.0f * piratio));
+ angle = (float) (angles[Defines.PITCH] * (cr));
sp = (float) Math.sin(angle);
cp = (float) Math.cos(angle);
- angle = (float) (angles[Defines.ROLL] * (2.0f * piratio));
+ angle = (float) (angles[Defines.ROLL] * (cr));
sr = (float) Math.sin(angle);
cr = (float) Math.cos(angle);
@@ -475,9 +476,9 @@ public class Math3D extends Lib {
forward[2] = -sp;
}
if (right != null) {
- right[0] = (-1 * sr * sp * cy + -1 * cr * -sy);
- right[1] = (-1 * sr * sp * sy + -1 * cr * cy);
- right[2] = -1 * sr * cp;
+ right[0] = (-sr * sp * cy + cr * sy);
+ right[1] = (-sr * sp * sy + -cr * cy);
+ right[2] = -sr * cp;
}
if (up != null) {
up[0] = (cr * sp * cy + -sr * -sy);