summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlashbunny2009-08-12 22:17:38 -0400
committerSlashbunny2009-08-12 22:17:38 -0400
commitcb1407a5d0afa2b6e20a574064508f221ad7f656 (patch)
treeb9e4062059597e53b3e5fca7973f922274a3016c
downloadaur-cb1407a5d0afa2b6e20a574064508f221ad7f656.tar.gz
Initial commit of personal PKGBUILDs for Arch Linux
-rw-r--r--.SRCINFO42
-rw-r--r--.gitignore5
-rw-r--r--PKGBUILD122
-rw-r--r--ctf.sh2
-rw-r--r--gnusource.patch13
-rw-r--r--q2ded.sh2
-rw-r--r--quake2.install30
-rw-r--r--quake2.sh2
-rw-r--r--rogue.sh2
-rw-r--r--snd_alsa.c254
-rw-r--r--xatrix.sh2
11 files changed, 476 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..77f98626be08
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,42 @@
+pkgbase = quake2
+ pkgdesc = Quake 2 engine. You need the retail .pak files to play.
+ pkgver = r0.16.1
+ pkgrel = 8
+ url = http://www.icculus.org/quake2/
+ install = quake2.install
+ arch = i686
+ arch = x86_64
+ license = GPL
+ makedepends = patch
+ makedepends = unzip
+ depends = libjpeg
+ depends = sdl
+ depends = libxxf86vm
+ depends = libxxf86dga
+ source = http://www.icculus.org/quake2/files/quake2-r0.16.1.tar.gz
+ source = http://www.icculus.org/quake2/files/maxpak.pak
+ source = http://cesium.di.uminho.pt/pub/games/quake2/source/xatrixsrc320.shar.Z
+ source = http://cesium.di.uminho.pt/pub/games/quake2/source/roguesrc320.shar.Z
+ source = ftp://ftp.idsoftware.com/idstuff/quake2/q2-3.20-x86-full-ctf.exe
+ source = quake2.sh
+ source = q2ded.sh
+ source = xatrix.sh
+ source = rogue.sh
+ source = ctf.sh
+ source = snd_alsa.c
+ source = gnusource.patch
+ md5sums = 6b0e3fff324a5db58a8f8309dcabb47a
+ md5sums = 04d3f1fb7fb4dada7175a41f4595c7eb
+ md5sums = 41fc4ecc4f25c068e7d1f488bd4a1e1a
+ md5sums = 7d5e052839c9e629bad0a6570aa70554
+ md5sums = 490557d4a90ff346a175d865a2bade87
+ md5sums = ec5664163c74b4648b9782a0d844b26a
+ md5sums = 77f6156b5cb3e7f72e7eb69710a91db2
+ md5sums = 06fa0aff03dae18ae003699ce514046c
+ md5sums = 396d146a53a2f9637f18d53e1bb0d877
+ md5sums = 2c3f56b44d1f5e7f6b46e31877e190e0
+ md5sums = c16644a6ddf93159ccc71e4c06e312c4
+ md5sums = 5788ed0d1bde8b00fa8b91a0c865f427
+
+pkgname = quake2
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..e4f398dc5b3a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+src/
+pkg/
+*.pkg.tar.xz
+*.pkg.tar
+*.src.tar.gz
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..6cffefabca9a
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,122 @@
+# Contributor: Slash <demodevil5 [at] yahoo [dot] com>
+# Contributor: Andrew Simmons <andrew.simmons@gmail.com>
+# Contributor: Premysl Janouch <warriant@gmail.com>
+
+pkgname=quake2
+pkgver=r0.16.1
+pkgrel=8
+pkgdesc="Quake 2 engine. You need the retail .pak files to play."
+url="http://www.icculus.org/quake2/"
+license=('GPL')
+depends=('libjpeg' 'sdl' 'libxxf86vm' 'libxxf86dga')
+makedepends=('patch' 'unzip')
+conflicts=()
+replaces=()
+backup=()
+install="quake2.install"
+arch=('i686' 'x86_64')
+source=("http://www.icculus.org/quake2/files/quake2-$pkgver.tar.gz" \
+'http://www.icculus.org/quake2/files/maxpak.pak' \
+'http://cesium.di.uminho.pt/pub/games/quake2/source/xatrixsrc320.shar.Z' \
+'http://cesium.di.uminho.pt/pub/games/quake2/source/roguesrc320.shar.Z' \
+'ftp://ftp.idsoftware.com/idstuff/quake2/q2-3.20-x86-full-ctf.exe' \
+'quake2.sh' 'q2ded.sh' 'xatrix.sh' 'rogue.sh' 'ctf.sh' 'snd_alsa.c' 'gnusource.patch')
+md5sums=('6b0e3fff324a5db58a8f8309dcabb47a'
+ '04d3f1fb7fb4dada7175a41f4595c7eb'
+ '41fc4ecc4f25c068e7d1f488bd4a1e1a'
+ '7d5e052839c9e629bad0a6570aa70554'
+ '490557d4a90ff346a175d865a2bade87'
+ 'ec5664163c74b4648b9782a0d844b26a'
+ '77f6156b5cb3e7f72e7eb69710a91db2'
+ '06fa0aff03dae18ae003699ce514046c'
+ '396d146a53a2f9637f18d53e1bb0d877'
+ '2c3f56b44d1f5e7f6b46e31877e190e0'
+ 'c16644a6ddf93159ccc71e4c06e312c4'
+ '5788ed0d1bde8b00fa8b91a0c865f427')
+
+build() {
+ cd $srcdir
+
+ # Create Temporary Directories
+ install -d $pkgname-$pkgver/src/xatrix $pkgname-$pkgver/src/rogue
+
+ # Decompress and patch The Reckoning (xatrix) Expansion
+ cp $srcdir/xatrixsrc320.shar.Z $srcdir/$pkgname-$pkgver/src/xatrix
+ cd $srcdir/$pkgname-$pkgver/src/xatrix
+ uncompress xatrixsrc320.shar.Z
+ sh xatrixsrc320.shar
+ /bin/sed -e "s/extern\tint\tjacket_armor_index/static\tint\tjacket_armor_index/" -i g_local.h
+ /bin/sed -e "s/extern\tint\tcombat_armor_index/static\tint\tcombat_armor_index/" -i g_local.h
+ /bin/sed -e "s/extern\tint\tbody_armor_index/static\tint\tbody_armor_index/" -i g_local.h
+
+ # Decompress and patch Ground Zero (rouge) Expansion
+ cp $srcdir/roguesrc320.shar.Z $srcdir/$pkgname-$pkgver/src/rogue
+ cd $srcdir/$pkgname-$pkgver/src/rogue
+ uncompress roguesrc320.shar.Z
+ sh roguesrc320.shar
+ /bin/sed -e "s/#include <nan.h>/#include <bits\/nan.h>/" -i g_local.h
+ /bin/sed -e "s/extern\tint\tjacket_armor_index/static\tint\tjacket_armor_index/" -i g_local.h
+ /bin/sed -e "s/extern\tint\tcombat_armor_index/static\tint\tcombat_armor_index/" -i g_local.h
+ /bin/sed -e "s/extern\tint\tbody_armor_index/static\tint\tbody_armor_index/" -i g_local.h
+
+ cd $srcdir/$pkgname-$pkgver/
+
+ # Patch from SVN
+ cp $srcdir/snd_alsa.c ./src/linux/snd_alsa.c
+
+ # x86_64 patch from Gentoo
+ patch -p1 < $srcdir/gnusource.patch
+
+ # Compile Quake 2
+ make -s BUILD_XATRIX=YES BUILD_ROGUE=YES BUILD_DEDICATED=YES BUILD_CTF=YES BUILD_QMAX=YES build_release || return 1
+
+ [ "$CARCH" = "i686" ] && _dirarch=i386
+ [ "$CARCH" = "x86_64" ] && _dirarch=x86_64
+
+ cd $srcdir/$pkgname-$pkgver/release$_dirarch
+
+ # Create Destination Directories
+ install -d $pkgdir/opt/quake2/{baseq2,ctf,xatrix,rogue}
+
+ # Install Base Game Library
+ install -m 755 game$_dirarch.so $pkgdir/opt/quake2/baseq2/
+ cp * $pkgdir/opt/quake2/
+
+ # Install CTF Library
+ install -m 755 ctf/game$_dirarch.so $pkgdir/opt/quake2/ctf/
+
+ # Install Xatrix Library
+ install -m 755 xatrix/game$_dirarch.so $pkgdir/opt/quake2/xatrix/
+
+ # Install Rogue Library
+ install -m 755 rogue/game$_dirarch.so $pkgdir/opt/quake2/rogue/
+
+ cd $srcdir
+
+ # Install Pak File
+ install $srcdir/maxpak.pak $pkgdir/opt/quake2/baseq2/
+
+ # Decompress and Install CTF Patch Data
+ mkdir $srcdir/q2
+ cp $srcdir/q2-3.20-x86-full-ctf.exe $srcdir/q2
+ cd $srcdir/q2
+ unzip -L q2-3.20-x86-full-ctf.exe
+ cp baseq2/pak1.pak baseq2/pak2.pak $pkgdir/opt/quake2/baseq2/
+ cp -r baseq2/players $pkgdir/opt/quake2/baseq2/
+ cp ctf/* $pkgdir/opt/quake2/ctf/
+
+ cd $srcdir
+
+ # x86_64 has the default ref_softx.so disabled, use glx
+ if [ "$CARCH" = "x86_64" ]; then
+ /bin/sed -e 's|/quake2 |/quake2 +set vid_ref glx |' -i *.sh
+ fi
+
+ # Install Game Launchers
+ install -D -m 755 quake2.sh $pkgdir/usr/bin/quake2
+ install -D -m 755 q2ded.sh $pkgdir/usr/bin/q2ded
+ install -D -m 755 xatrix.sh $pkgdir/usr/bin/quake2-the-reckoning
+ install -D -m 755 rogue.sh $pkgdir/usr/bin/quake2-ground-zero
+ install -D -m 755 ctf.sh $pkgdir/usr/bin/quake2-ctf
+}
+
diff --git a/ctf.sh b/ctf.sh
new file mode 100644
index 000000000000..5ddd8b89be99
--- /dev/null
+++ b/ctf.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec /opt/quake2/quake2 +set basedir /opt/quake2 +set game ctf +set dedicated 1 $*
diff --git a/gnusource.patch b/gnusource.patch
new file mode 100644
index 000000000000..cc7c8451293b
--- /dev/null
+++ b/gnusource.patch
@@ -0,0 +1,13 @@
+diff -Naur quake2-r0.16.1/src/linux/q_shlinux.c quake2-r0.16.1-modified/src/linux/q_shlinux.c
+--- quake2-r0.16.1/src/linux/q_shlinux.c 2002-02-09 17:09:23.000000000 -0500
++++ quake2-r0.16.1-modified/src/linux/q_shlinux.c 2007-06-26 13:40:25.000000000 -0400
+@@ -17,6 +17,9 @@
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ */
++#if !defined(_GNU_SOURCE)
++ #define _GNU_SOURCE
++#endif
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <errno.h>
diff --git a/q2ded.sh b/q2ded.sh
new file mode 100644
index 000000000000..e719375317b4
--- /dev/null
+++ b/q2ded.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec /opt/quake2/q2ded +set basedir /opt/quake2 $* \ No newline at end of file
diff --git a/quake2.install b/quake2.install
new file mode 100644
index 000000000000..da92e91c3b2c
--- /dev/null
+++ b/quake2.install
@@ -0,0 +1,30 @@
+post_install() {
+cat << EOF
+==> DATA FILES
+To play Quake 2, you need the following files from the disc:
+copy <cdromdir>/Install/Data/baseq2/pak0.pak to /opt/quake2/baseq2/
+copy <cdromdir>/Install/Data/baseq2/video/ to /opt/quake2/baseq2/
+
+To play The Reckoning, you need the following files from the disc:
+copy <cdromdir>/Data/all/pak0.pak to /opt/quake2/xatrix/
+copy <cdromdir>/Data/max/xatrix/video/ to /opt/quake2/xatrix/
+
+To play Ground Zero, you need the following files from the disc:
+copy <cdromdir>/Data/all/pak0.pak to /opt/quake2/rogue/
+copy <cdromdir>/Data/max/Rogue/video/ to /opt/quake2/rogue/ (optional)
+
+==> QUAKE2 BINARY
+You can control switch between the quake2 and sdlquake2 binaries by changing
+the q2 symlink. If you want to use sdlquake2, then as root type:
+# ln -sf ./sdlquake2 /opt/quake2/q2
+
+sdlquake2 uses sdl for audio, and quake2 uses oss for audio. Alsa does not
+work well in the current version, so it is not built.
+EOF
+ /bin/true
+}
+
+
+op=$1
+shift
+$op $*
diff --git a/quake2.sh b/quake2.sh
new file mode 100644
index 000000000000..e4c7f8d63f13
--- /dev/null
+++ b/quake2.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec /opt/quake2/quake2 +set basedir /opt/quake2 $*
diff --git a/rogue.sh b/rogue.sh
new file mode 100644
index 000000000000..dcca76167aff
--- /dev/null
+++ b/rogue.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec /opt/quake2/quake2 +set basedir /opt/quake2 +set game rogue $*
diff --git a/snd_alsa.c b/snd_alsa.c
new file mode 100644
index 000000000000..2fb7411ce68d
--- /dev/null
+++ b/snd_alsa.c
@@ -0,0 +1,254 @@
+/*
+* 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
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <alsa/asoundlib.h>
+
+#include "../client/client.h"
+#include "../client/snd_loc.h"
+
+#define BUFFER_SAMPLES 4096
+#define SUBMISSION_CHUNK BUFFER_SAMPLES / 2
+
+static snd_pcm_t *pcm_handle;
+static snd_pcm_hw_params_t *hw_params;
+
+static struct sndinfo * si;
+
+static int sample_bytes;
+static int buffer_bytes;
+
+cvar_t *sndbits;
+cvar_t *sndspeed;
+cvar_t *sndchannels;
+cvar_t *snddevice;
+
+
+/*
+* The sample rates which will be attempted.
+*/
+static int RATES[] = {
+ 44100, 22050, 11025, 8000
+};
+
+/*
+* Initialize ALSA pcm device, and bind it to sndinfo.
+*/
+qboolean SNDDMA_Init(void){
+ int i, err, dir;
+ unsigned int r;
+ snd_pcm_uframes_t p;
+
+
+ if (!snddevice)
+ {
+ sndbits = Cvar_Get("sndbits", "16", CVAR_ARCHIVE);
+ sndspeed = Cvar_Get("sndspeed", "0", CVAR_ARCHIVE);
+ sndchannels = Cvar_Get("sndchannels", "2", CVAR_ARCHIVE);
+ snddevice = Cvar_Get("snddevice", "/dev/dsp", CVAR_ARCHIVE);
+ }
+
+ if(!strcmp(snddevice->string, "/dev/dsp")) //silly oss default
+ snddevice->string = "default";
+
+ if((err = snd_pcm_open(&pcm_handle, snddevice->string,
+ SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0)
+ {
+ Com_Printf("ALSA: cannot open device %s(%s)\n",
+ snddevice->string, snd_strerror(err));
+ return false;
+ }
+
+ if((err = snd_pcm_hw_params_malloc(&hw_params)) < 0){
+ Com_Printf("ALSA: cannot allocate hw params(%s)\n",
+ snd_strerror(err));
+ return false;
+ }
+
+ if((err = snd_pcm_hw_params_any(pcm_handle, hw_params)) < 0){
+ Com_Printf("ALSA: cannot init hw params(%s)\n", snd_strerror(err));
+ snd_pcm_hw_params_free(hw_params);
+ return false;
+ }
+
+ if((err = snd_pcm_hw_params_set_access
+ (pcm_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
+ {
+ Com_Printf("ALSA: cannot set access(%s)\n", snd_strerror(err));
+ snd_pcm_hw_params_free(hw_params);
+ return false;
+ }
+
+ dma.samplebits = (int)sndbits->value;
+ if(dma.samplebits != 8){ //try 16 by default
+ dma.samplebits = 16; //ensure this is set for other calculations
+
+ if((err = snd_pcm_hw_params_set_format(pcm_handle, hw_params,
+ SND_PCM_FORMAT_S16)) < 0){
+ Com_Printf("ALSA: 16 bit not supported, trying 8\n");
+ dma.samplebits = 8;
+ }
+ }
+ if(dma.samplebits == 8){ //or 8 if specifically asked to
+ if((err = snd_pcm_hw_params_set_format(pcm_handle, hw_params,
+ SND_PCM_FORMAT_U8)) < 0){
+ Com_Printf("ALSA: cannot set format(%s)\n", snd_strerror(err));
+ snd_pcm_hw_params_free(hw_params);
+ return false;
+ }
+ }
+
+ dma.speed = (int)sndspeed->value;
+ if(dma.speed){ //try specified rate
+ r = dma.speed;
+
+ if((err = snd_pcm_hw_params_set_rate_near(pcm_handle, hw_params, &r, &dir)) < 0)
+ Com_Printf("ALSA: cannot set rate %d(%s)\n", r, snd_strerror(err));
+ else { //rate succeeded, but is perhaps slightly different
+ if(dir != 0)
+ Com_Printf("ALSA: rate %d not supported, using %d\n", sndspeed->value, r);
+ dma.speed = r;
+ }
+ }
+ if(!dma.speed){ //or all available ones
+ for(i = 0; i < sizeof(RATES); i++){
+ r = RATES[i];
+ dir = 0;
+
+ if((err = snd_pcm_hw_params_set_rate_near(pcm_handle, hw_params, &r, &dir)) < 0)
+ Com_Printf("ALSA: cannot set rate %d(%s)\n", r, snd_strerror(err));
+ else { //rate succeeded, but is perhaps slightly different
+ dma.speed = r;
+ if(dir != 0)
+ Com_Printf("ALSA: rate %d not supported, using %d\n", RATES[i], r);
+ break;
+ }
+ }
+ }
+ if(!dma.speed){ //failed
+ Com_Printf("ALSA: cannot set rate\n");
+ snd_pcm_hw_params_free(hw_params);
+ return false;
+ }
+
+ dma.channels = sndchannels->value;
+ if(dma.channels < 1 || dma.channels > 2)
+ dma.channels = 2; //ensure either stereo or mono
+
+
+
+ if((err = snd_pcm_hw_params_set_channels(pcm_handle, hw_params,
+ dma.channels)) < 0)
+ {
+ Com_Printf("ALSA: cannot set channels %d(%s)\n",
+ sndchannels->value, snd_strerror(err));
+ snd_pcm_hw_params_free(hw_params);
+ return false;
+ }
+
+ p = BUFFER_SAMPLES / dma.channels;
+ if((err = snd_pcm_hw_params_set_period_size_near(pcm_handle, hw_params,
+ &p, &dir)) < 0){
+ Com_Printf("ALSA: cannot set period size (%s)\n", snd_strerror(err));
+ snd_pcm_hw_params_free(hw_params);
+ return false;
+ }
+ else { //rate succeeded, but is perhaps slightly different
+ if(dir != 0)
+ Com_Printf("ALSA: period %d not supported, using %d\n", (BUFFER_SAMPLES/dma.channels), p);
+ }
+
+ if((err = snd_pcm_hw_params(pcm_handle, hw_params)) < 0){ //set params
+ Com_Printf("ALSA: cannot set params(%s)\n", snd_strerror(err));
+ snd_pcm_hw_params_free(hw_params);
+ return false;
+ }
+
+ sample_bytes = dma.samplebits / 8;
+ buffer_bytes = BUFFER_SAMPLES * sample_bytes;
+
+ dma.buffer = malloc(buffer_bytes); //allocate pcm frame buffer
+ memset(dma.buffer, 0, buffer_bytes);
+
+ dma.samplepos = 0;
+
+ dma.samples = BUFFER_SAMPLES;
+ dma.submission_chunk = SUBMISSION_CHUNK;
+
+ snd_pcm_prepare(pcm_handle);
+
+ return true;
+}
+
+/*
+* Returns the current sample position, if sound is running.
+*/
+int SNDDMA_GetDMAPos(void){
+
+ if(dma.buffer)
+ return dma.samplepos;
+
+ Com_Printf("Sound not inizialized\n");
+ return 0;
+}
+
+/*
+* Closes the ALSA pcm device and frees the dma buffer.
+*/
+void SNDDMA_Shutdown(void){
+
+ if(dma.buffer){
+ snd_pcm_drop(pcm_handle);
+ snd_pcm_close(pcm_handle);
+ }
+
+ free(dma.buffer);
+ dma.buffer = 0;
+}
+
+/*
+* Writes the dma buffer to the ALSA pcm device.
+*/
+void SNDDMA_Submit(void){
+ int s, w, frames;
+ void *start;
+
+ if(!dma.buffer)
+ return;
+
+ s = dma.samplepos * sample_bytes;
+ start = (void *)&dma.buffer[s];
+
+ frames = dma.submission_chunk / dma.channels;
+
+ if((w = snd_pcm_writei(pcm_handle, start, frames)) < 0){ //write to card
+ snd_pcm_prepare(pcm_handle); //xrun occured
+ return;
+ }
+
+ dma.samplepos += w * dma.channels; //mark progress
+
+ if(dma.samplepos >= dma.samples)
+ dma.samplepos = 0; //wrap buffer
+}
+
+/*
+* Callback provided by the engine in case we need it. We don't.
+*/
+void SNDDMA_BeginPainting(void){}
diff --git a/xatrix.sh b/xatrix.sh
new file mode 100644
index 000000000000..6a15a0eb05ff
--- /dev/null
+++ b/xatrix.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec /opt/quake2/quake2 +set basedir /opt/quake2 +set game xatrix $*