- Merged each of bsd/, solaris/, and irix/ into src/; bsd,

solaris and irix are no longer pertinent, they will remain
  only until I can be sure that the code was merged
  correctly, i.e. for reference purposes only.
This commit is contained in:
Jamie Wilkinson 2002-03-02 03:56:00 +00:00
parent 2daf1584a5
commit 2e6851b85b
13 changed files with 857 additions and 237 deletions

View file

@ -1199,6 +1199,6 @@ clean2:
$(REF_SOFT_X11_OBJS) \
$(REF_GL_OBJS)
distclean:
distclean: clean
-rm -rf $(BUILD_DEBUG_DIR) $(BUILD_RELEASE_DIR)
-rm -f `find . \( -not -type d \) -and \( -name '*~' \) -type f -print`

189
src/cd.c
View file

@ -1,25 +1,33 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
/* $Id$
*
* used to be cd_linux.c
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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.
*/
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.
*/
// Quake is a trademark of Id Software, Inc., (c) 1996 Id Software, Inc. All
// rights reserved.
/* cd_irix.c comments out just about all of this code, replacing the functions
* with stubs... instead I'll leave the full implementations here and someone
* can work out how to play cds under irix -- jaq */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@ -31,7 +39,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <time.h>
#include <errno.h>
#include <linux/cdrom.h>
/* merged in from cd_bsd.c -- jaq */
#ifdef __linux__
#include <linux/cdrom.h>
#else /* __bsd__ */
#include <sys/cdio.h>
#include <sys/disklabel.h>
#endif
#include "../client/client.h"
@ -62,8 +76,14 @@ static void CDAudio_Eject(void)
if (cdfile == -1 || !enabled)
return; // no cd init'd
/* merged in from cd_bsd.c -- jaq */
#ifdef __linux__
if ( ioctl(cdfile, CDROMEJECT) == -1 )
Com_DPrintf("ioctl cdromeject failed\n");
#else /* bsd */
if (ioctl(cdfile, CDIOCEJECT) == -1)
Com_DPrintf("ioctl cdioeject failed\n");
#endif
}
@ -72,30 +92,55 @@ static void CDAudio_CloseDoor(void)
if (cdfile == -1 || !enabled)
return; // no cd init'd
/* merged in from cd_bsd.c -- jaq */
#ifdef __linux__
if ( ioctl(cdfile, CDROMCLOSETRAY) == -1 )
Com_DPrintf("ioctl cdromclosetray failed\n");
#else /* bsd */
/* No OpenBSD equivalent of this Linux ioctl() */
Com_DPrintf("ioctl cdromclosetray not supported\n");
#endif
}
static int CDAudio_GetAudioDiskInfo(void)
{
/* merged in from cd_bsd.c */
#ifdef __linux__
struct cdrom_tochdr tochdr;
#else /* bsd */
struct ioc_toc_header tochdr;
#endif
cdValid = false;
if ( ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1 )
{
#ifdef __linux__
if (ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1) {
Com_DPrintf("ioctl cdromreadtochdr failed\n");
return -1;
}
#else /* bsd */
if (ioctl(cdfile, CDIOREADTOCHEADER, &tochdr) == -1) {
Com_DPrintf("ioctl cdioreadtocheader failed\n");
return -1;
}
#endif
#ifdef __linux__
if (tochdr.cdth_trk0 < 1)
#else /* bsd */
if (tochdr.starting_track < 1)
#endif
{
Com_DPrintf("CDAudio: no music tracks\n");
return -1;
}
cdValid = true;
#ifdef __linux__
maxTrack = tochdr.cdth_trk1;
#else /* bsd */
maxTrack = tochdr.ending_track;
#endif
return 0;
}
@ -103,8 +148,15 @@ static int CDAudio_GetAudioDiskInfo(void)
void CDAudio_Play(int track, qboolean looping)
{
/* merged in from cd_bsd.c -- jaq */
#ifdef __linux__
struct cdrom_tocentry entry;
struct cdrom_ti ti;
#else /* bsd */
struct ioc_read_toc_entry entry;
struct cd_toc_entry cd_entry;
struct ioc_play_track ti;
#endif
if (cdfile == -1 || !enabled)
return;
@ -125,14 +177,34 @@ void CDAudio_Play(int track, qboolean looping)
}
// don't try to play a non-audio track
#ifdef __linux__
entry.cdte_track = track;
entry.cdte_format = CDROM_MSF;
if ( ioctl(cdfile, CDROMREADTOCENTRY, &entry) == -1 )
{
if (ioctl(cdfile, CDROMREADTOCENTRY, &entry) == -1) {
Com_DPrintf("ioctl cdromreadtocentry failed\n");
return;
}
#else /* bsd */
entry.starting_track = track;
entry.address_format = CD_MSF_FORMAT;
entry.data_len = sizeof(struct cd_toc_entry);
entry.data = &cd_entry;
if (ioctl(cdfile, CDIOREADTOCENTRYS, &entry) == -1) {
Com_DPrintf("ioctl cdioreadtocentrys failed\n");
return;
}
#endif
/* merged in from cd_bsd.c -- jaq */
#ifdef __linux__
if (entry.cdte_ctrl == CDROM_DATA_TRACK)
#else /* bsd */
#ifndef CDROM_DATA_TRACK
#define CDROM_DATA_TRACK 4
#endif
if (cd_entry.control == CDROM_DATA_TRACK)
#endif
{
Com_Printf("CDAudio: track %i is not audio\n", track);
return;
@ -145,19 +217,32 @@ void CDAudio_Play(int track, qboolean looping)
CDAudio_Stop();
}
#ifdef __linux__
ti.cdti_trk0 = track;
ti.cdti_trk1 = track;
ti.cdti_ind0 = 1;
ti.cdti_ind1 = 99;
if ( ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1 )
{
if (ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1) {
#else /* bsd */
ti.start_track = track;
ti.start_index = 1;
ti.end_track = track;
ti.end_index = 99;
if (ioctl(cdfile, CDIOCPLAYTRACKS, &ti) == -1) {
#endif
Com_DPrintf("ioctl cdromplaytrkind failed\n");
return;
}
#ifdef __linux__
if ( ioctl(cdfile, CDROMRESUME) == -1 )
Com_DPrintf("ioctl cdromresume failed\n");
#else /* bsd */
if (ioctl(cdfile, CDIOCRESUME) == -1)
Com_DPrintf("ioctl cdiocresume failed\n");
#endif
playLooping = looping;
playTrack = track;
@ -167,6 +252,8 @@ void CDAudio_Play(int track, qboolean looping)
CDAudio_Pause ();
}
#ifdef __linux__
/* only because it hasn't been ported to bsd yet */
void CDAudio_RandomPlay(void)
{
int track, i = 0, free_tracks = 0, remap_track;
@ -239,6 +326,7 @@ void CDAudio_RandomPlay(void)
}
while (free_tracks > 0);
}
#endif
void CDAudio_Stop(void)
{
@ -248,8 +336,14 @@ void CDAudio_Stop(void)
if (!playing)
return;
/* merged in from cd_bsd.c -- jaq */
#ifdef __linux__
if ( ioctl(cdfile, CDROMSTOP) == -1 )
Com_DPrintf("ioctl cdromstop failed (%d)\n", errno);
Com_DPrintf("ioctl cdromstop failed (%d:%s)\n", errno, strerror(errno));
#else /* bsd */
if (ioctl(cdfile, CDIOCSTOP) == -1)
Com_DPrintf("ioctl cdiocstop failed (%d:%s)\n", errno, strerror(errno));
#endif
wasPlaying = false;
playing = false;
@ -263,8 +357,14 @@ void CDAudio_Pause(void)
if (!playing)
return;
/* merged in from cd_bsd.c -- jaq */
#ifdef __linux__
if ( ioctl(cdfile, CDROMPAUSE) == -1 )
Com_DPrintf("ioctl cdrompause failed\n");
#else /* bsd */
if (ioctl(cdfile, CDIOCPAUSE) == -1)
Com_DPrintf("ioctl cdiocpause failed\n");
#endif
wasPlaying = playing;
playing = false;
@ -281,9 +381,14 @@ void CDAudio_Resume(void)
if (!wasPlaying)
return;
/* merged in from cd_bsd.c -- jaq */
#ifdef __linux__
if ( ioctl(cdfile, CDROMRESUME) == -1 )
Com_DPrintf("ioctl cdromresume failed\n");
#else /* bsd */
if (ioctl(cdfile, CDIOCRESUME) == -1)
Com_DPrintf("ioctl cdiocresume failed\n");
#endif
playing = true;
}
@ -407,7 +512,13 @@ static void CD_f (void)
void CDAudio_Update(void)
{
/* merged in from cd_bsd.c -- jaq */
#ifdef __linux__
struct cdrom_subchnl subchnl;
#else /* bsd */
struct ioc_read_subchannel subchnl;
struct cd_sub_channel_info subchnl_info;
#endif
static time_t lastchk;
if (cdfile == -1 || !enabled)
@ -431,18 +542,37 @@ void CDAudio_Update(void)
if (playing && lastchk < time(NULL)) {
lastchk = time(NULL) + 2; //two seconds between chks
#ifdef __linux__
subchnl.cdsc_format = CDROM_MSF;
if (ioctl(cdfile, CDROMSUBCHNL, &subchnl) == -1 ) {
Com_DPrintf("ioctl cdromsubchnl failed\n");
playing = false;
return;
}
if (subchnl.cdsc_audiostatus != CDROM_AUDIO_PLAY &&
subchnl.cdsc_audiostatus != CDROM_AUDIO_PAUSED) {
playing = false;
if (playLooping)
CDAudio_Play(playTrack, true);
}
#else /* bsd */
subchnl.address_format = CD_MSF_FORMAT;
subchnl.data_len = sizeof(struct cd_sub_channel_info);
subchnl.data = &subchnl_info;
if (ioctl(cdfile, CDIOCREADSUBCHANNEL, &subchnl) == -1) {
Com_DPrintf("ioctl cdiocreadsubchannel failed\n");
playing = false;
return;
}
if (subchnl_info.header.audio_status != CD_AS_PLAY_IN_PROGRESS &&
subchnl_info.header.audio_status != CD_AS_PLAY_PAUSED) {
playing = false;
if (playLooping)
CDAudio_Play(playTrack, true);
}
#endif
}
}
@ -465,7 +595,12 @@ int CDAudio_Init(void)
cd_volume = Cvar_Get ("cd_volume", "1", CVAR_ARCHIVE);
/* merged in from cd_bsd.c -- jaq */
#ifdef __linux__
cd_dev = Cvar_Get("cd_dev", "/dev/cdrom", CVAR_ARCHIVE);
#else /* bsd */
cd_dev = Cvar_Get("cd_dev", "/dev/cd0c", CVAR_ARCHIVE);
#endif
seteuid(saved_euid);

View file

@ -45,8 +45,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../client/keys.h"
#include "rw.h"
#include "glw.h"
#include "../src/rw.h"
#include "../src/glw.h"
#include <GL/glx.h>

View file

@ -1,22 +1,27 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
/* $Id$
*
* used to be in_linux.c, no idea what in means
* FIXME: it seems that this file isn't referenced at all by anything
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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.
*/
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.
*/
// in_null.c -- for systems without a mouse
#include "../client/client.h"

View file

@ -1,22 +1,26 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
/* $Id$
*
* used to be sys_linux.c
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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.
*/
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.
*/
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
@ -35,10 +39,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <sys/wait.h>
#include <sys/mman.h>
#include <errno.h>
#include <mntent.h>
/* merged from sys_*.c -- jaq */
#if defined(__linux__) || defined(__sgi)
#include <mntent.h>
#elif defined(__bsd__)
#include <fstab.h>
#elif defined(sun)
#include <sys/file.h>
#endif
#include <dlfcn.h>
/* merged from sys_bsd.c -- jaq */
#ifndef RTLD_NOW
#define RTLD_NOW RTLD_LAZY
#endif
/* merged from sys_bsd.c -- jaq */
#ifdef __OpenBSD__
#define dlsym(X, Y) dlsym(X, "_"##Y)
#endif
#include "../qcommon/qcommon.h"
#include "../game/game.h"
#include "rw.h"
@ -119,7 +141,6 @@ void Sys_Error (char *error, ...)
fprintf(stderr, "Error: %s\n", string);
_exit (1);
}
void Sys_Warn (char *warning, ...)
@ -296,6 +317,7 @@ int main (int argc, char **argv)
Qcommon_Init(argc, argv);
/* sys_irix.c had this and the fcntl line 3 lines down commented out */
fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
nostdout = Cvar_Get("nostdout", "0", 0);
@ -320,8 +342,13 @@ int main (int argc, char **argv)
#if 0
void Sys_CopyProtect(void)
{
/* merged in from sys_bsd.c -- jaq */
#ifdef __linux__
FILE *mnt;
struct mntent *ent;
#else /* __bsd__ */
struct fstab * ent;
#endif
char path[MAX_OSPATH];
struct stat st;
qboolean found_cd = false;
@ -331,37 +358,85 @@ void Sys_CopyProtect(void)
if (checked)
return;
/* sys_irix.c -- jaq
Com_Printf("XXX - Sys_CopyProtect disabled\n");
checked = true;
return;
*/
/* merged in from sys_bsd.c */
#ifdef __linux__
if ((mnt = setmntent("/etc/mtab", "r")) == NULL)
Com_Error(ERR_FATAL, "Can't read mount table to determine mounted cd location.");
while ((ent = getmntent(mnt)) != NULL) {
if (strcmp(ent->mnt_type, "iso9660") == 0) {
#else /* __bsd__ */
while ((ent = getfsent()) != NULL) {
if (strcmp(ent->fs_vfstype, "cd9660") == 0) {
#endif
// found a cd file system
found_cd = true;
/* merged in from sys_bsd.c */
#ifdef __linux__
sprintf(path, "%s/%s", ent->mnt_dir, "install/data/quake2.exe");
#else /* __bsd__ */
sprintf(path, "%s/%s", ent->fs_file, "install/data/quake2.exe");
#endif
if (stat(path, &st) == 0) {
// found it
checked = true;
/* merged in from sys_bsd.c */
#ifdef __linux__
endmntent(mnt);
#else /* __bsd__ */
endfsent();
#endif
return;
}
/* merged in from sys_bsd.c */
#ifdef __linux__
sprintf(path, "%s/%s", ent->mnt_dir, "Install/Data/quake2.exe");
#else /* __bsd__ */
sprintf(path, "%s/%s", ent->fs_file, "Install/Data/quake2.exe");
#endif
if (stat(path, &st) == 0) {
// found it
checked = true;
/* merged in from sys_bsd.c */
#ifdef __linux__
endmntent(mnt);
#else /* __bsd__ */
endfsent();
#endif
return;
}
/* merged in from sys_bsd.c */
#ifdef __linux__
sprintf(path, "%s/%s", ent->mnt_dir, "quake2.exe");
#else /* __bsd__ */
sprintf(path, "%s/%s", ent->fs_file, "quake2.exe");
#endif
if (stat(path, &st) == 0) {
// found it
checked = true;
/* merged in from sys_bsd.c */
#ifdef __linux__
endmntent(mnt);
#else /* __bsd__ */
endfsent();
#endif
return;
}
}
}
/* merged in from sys_bsd.c */
#ifdef __linux__
endmntent(mnt);
#else /* __bsd__ */
endfsent();
#endif
if (found_cd)
Com_Error (ERR_FATAL, "Could not find a Quake2 CD in your CD drive.");

View file

@ -1,22 +1,24 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
/* $Id$
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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.
*/
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.
*/
// net_wins.c
#include "../qcommon/qcommon.h"
@ -32,6 +34,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <sys/uio.h>
#include <errno.h>
/* merged in from solaris/net_udp.c -- jaq */
#ifdef sun
#include <sys/filio.h>
#endif
#ifdef NeXT
#include <libc.h>
#endif

View file

@ -1,22 +1,26 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
/* $Id$
*
* used to be q_shlinux.c
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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.
*/
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.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
@ -42,8 +46,14 @@ void *Hunk_Begin (int maxsize)
// reserve a huge chunk of memory, but don't commit any yet
maxhunksize = maxsize + sizeof(int);
curhunksize = 0;
membase = mmap(0, maxhunksize, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
/* merged in from q_sh*.c -- jaq */
#if defined(__linux__)
membase = mmap(0, maxhunksize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
#elif defined(__bsd__)
membase = mmap(0, maxhunksize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
#elif defined(sun) || defined(__sgi)
membase = malloc(maxhunksize);
#endif
if (membase == NULL || membase == (byte *)-1)
Sys_Error("unable to virtual allocate %d bytes", maxsize);
@ -65,21 +75,26 @@ void *Hunk_Alloc (int size)
return buf;
}
#ifdef __linux__
#if defined(__linux__) || defined(sun)
int Hunk_End (void)
{
byte *n;
#ifdef __linux__
n = mremap(membase, maxhunksize, curhunksize + sizeof(int), 0);
#else /* sun */
n = realloc(membase, curhunksize);
#endif
if (n != membase)
Sys_Error("Hunk_End: Could not remap virtual block (%d)", errno);
*((int *)membase) = curhunksize + sizeof(int);
return curhunksize;
}
#else
#else /* bsd and irix */
int Hunk_End (void)
{
#ifndef __sgi
long pgsz, newsz, modsz;
pgsz = sysconf(_SC_PAGESIZE);
@ -99,19 +114,29 @@ int Hunk_End (void)
}
*((int *)membase) = curhunksize + sizeof(int);
#endif /* __sgi */
return curhunksize;
}
#endif
#endif /* bsd or __sgi */
void Hunk_Free (void *base)
{
byte *m;
if (base) {
/* merged in from q_shsolaris.c -- jaq */
#ifdef sun
/* FIXME: I'm not sure that 'sun' is the correct define -- jaq */
free(base);
#else
m = ((byte *)base) - sizeof(int);
#ifdef __sgi
free(m);
#else
if (munmap(m, *((int *)m)))
Sys_Error("Hunk_Free: munmap failed (%d)", errno);
Sys_Error("Hunk_Free: munmap failed (%d:%s)", errno, strerror(errno));
#endif /* __sgi */
#endif /* sun */
}
}
@ -175,6 +200,7 @@ static qboolean CompareAttributes(char *path, char *name,
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
return false;
/* FIXME: what's the point of the return? -- jaq */
#if 1
sprintf(fn, "%s/%s", path, name);
#else

112
src/qgl.c
View file

@ -1,22 +1,26 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
/* $Id$
*
* used to be qgl_linux.c
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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.
*/
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.
*/
/*
** QGL_WIN.C
**
@ -27,15 +31,57 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
** QGL_Init() - loads libraries, assigns function pointers, etc.
** QGL_Shutdown() - unloads libraries, NULLs function pointers
*/
#include <ctype.h>
#include <float.h>
/* from qgl_irix.c */
#ifdef __sgi
#define QGL
#endif
#include "../ref_gl/gl_local.h"
#include "glw.h"
//#include <GL/glx.h>
//#include <GL/fxmesa.h>
#include <dlfcn.h>
/* merged in from qgl_irix.c -- jaq
* irix used log_fp instead of glw_state.log_fp for the fprintf calls
* in the log* functions1
static FILE * log_fp = NULL;
*/
/* merged in from qgl_bsd.c -- jaq */
#ifndef RTLD_NOW
#define RTLD_NOW RTLD_LAZY
#endif
#ifndef RTLD_GLOBAL
#define RTLD_GLOBAL 0
#endif
/* merged in from qgl_bsd.c -- jaq */
#ifdef __bsd__
/*
//FX Mesa Functions
fxMesaContext (*qfxMesaCreateContext)(GLuint win, GrScreenResolution_t, GrScreenRefresh_t, const GLint attribList[]);
fxMesaContext (*qfxMesaCreateBestContext)(GLuint win, GLint width, GLint height, const GLint attribList[]);
void (*qfxMesaDestroyContext)(fxMesaContext ctx);
void (*qfxMesaMakeCurrent)(fxMesaContext ctx);
fxMesaContext (*qfxMesaGetCurrentContext)(void);
void (*qfxMesaSwapBuffers)(void);
*/
XVisualInfo * (*qglXChooseVisual)( Display *dpy, int screen, int *attribList );+GLXContext (*qglXCreateContext)( Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct );
void (*qglXDestroyContext)( Display *dpy, GLXContext ctx );
Bool (*qglXMakeCurrent)( Display *dpy, GLXDrawable drawable, GLXContext ctx);
void (*qglXCopyContext)( Display *dpy, GLXContext src, GLXContext dst, GLuint mask );
void (*qglXSwapBuffers)( Display *dpy, GLXDrawable drawable );
#endif
void ( APIENTRY * qglAccum )(GLenum op, GLfloat value);
void ( APIENTRY * qglAlphaFunc )(GLenum func, GLclampf ref);
GLboolean ( APIENTRY * qglAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences);
@ -2616,12 +2662,14 @@ static void APIENTRY logViewport(GLint x, GLint y, GLsizei width, GLsizei height
*/
void QGL_Shutdown( void )
{
/* qgl_irix has this commented out -- jaq */
if ( glw_state.OpenGLLib )
{
dlclose ( glw_state.OpenGLLib );
glw_state.OpenGLLib = NULL;
}
/* and this */
glw_state.OpenGLLib = NULL;
qglAccum = NULL;
@ -2960,16 +3008,28 @@ void QGL_Shutdown( void )
qglVertex4sv = NULL;
qglVertexPointer = NULL;
qglViewport = NULL;
/* merged in from qgl_bsd.c -- jaq */
#ifdef __bsd__
/*
qfxMesaCreateContext = NULL;
qfxMesaCreateBestContext = NULL;
qfxMesaDestroyContext = NULL;
qfxMesaMakeCurrent = NULL;
qfxMesaGetCurrentContext = NULL;
qfxMesaSwapBuffers = NULL;
*/
qglXChooseVisual = NULL;
qglXCreateContext = NULL;
qglXDestroyContext = NULL;
qglXMakeCurrent = NULL;
qglXCopyContext = NULL;
qglXSwapBuffers = NULL;
*/
#endif
}
/* merged in from qgl_bsd.c -- jaq */
#ifdef __linux__
#define GPA( a ) dlsym( glw_state.OpenGLLib, a )
void *qwglGetProcAddress(char *symbol)
@ -2978,6 +3038,7 @@ void *qwglGetProcAddress(char *symbol)
return GPA ( symbol );
return NULL;
}
#endif
/*
** QGL_Init
@ -3362,14 +3423,25 @@ qboolean QGL_Init( const char *dllname )
qglVertex4sv = dllVertex4sv = GPA( "glVertex4sv" );
qglVertexPointer = dllVertexPointer = GPA( "glVertexPointer" );
qglViewport = dllViewport = GPA( "glViewport" );
/* merged in from qgl_bsd.c -- jaq */
#ifdef __bsd__
/*
qfxMesaCreateContext = GPA("fxMesaCreateContext");
qfxMesaCreateBestContext = GPA("fxMesaCreateBestContext");
qfxMesaDestroyContext = GPA("fxMesaDestroyContext");
qfxMesaMakeCurrent = GPA("fxMesaMakeCurrent");
qfxMesaGetCurrentContext = GPA("fxMesaGetCurrentContext");
qfxMesaSwapBuffers = GPA("fxMesaSwapBuffers");
*/
qglXChooseVisual = GPA("glXChooseVisual");
qglXCreateContext = GPA("glXCreateContext");
qglXDestroyContext = GPA("glXDestroyContext");
qglXMakeCurrent = GPA("glXMakeCurrent");
qglXCopyContext = GPA("glXCopyContext");
qglXSwapBuffers = GPA("glXSwapBuffers");
*/
#endif
qglLockArraysEXT = 0;
qglUnlockArraysEXT = 0;
qglPointParameterfEXT = 0;

View file

@ -1,23 +1,28 @@
/*
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.
*/
/* $Id$
*
* used to be rw_linux.h, no idea what rw means
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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.
*/
#ifndef __RW_H__
#define __RW_H__
typedef void (*Key_Event_fp_t)(int key, qboolean down);
@ -33,3 +38,4 @@ typedef struct in_state {
int *in_strafe_state;
} in_state_t;
#endif /* __RW_H__ */

View file

@ -27,13 +27,13 @@
#ifdef OPENGL
#include "../ref_gl/gl_local.h"
#include "glw.h"
#include "../src/glw.h"
#else
#include "../ref_soft/r_local.h"
#endif
#include "../client/keys.h"
#include "rw.h"
#include "../src/rw.h"
/*****************************************************************************/

287
src/snd.c
View file

@ -1,22 +1,28 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
/* $Id$
*
* used to be snd_linux.c
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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.
*/
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.
*/
/* merged in from snd_irix.c -- jaq */
#ifndef __sgi
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
@ -26,8 +32,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <sys/mman.h>
#include <sys/shm.h>
#include <sys/wait.h>
#include <linux/soundcard.h>
#include <stdio.h>
/* merged in from snd_bsd.c -- jaq */
#ifdef __linux__
#include <linux/soundcard.h>
#else /* bsd */
#include <soundcard.h>
#endif /* __linux__ */
#else /* __sgi */
#include <dmedia/dmedia.h>
#include <dmedia/audio.h>
#endif /* __sgi */
#include "../client/client.h"
#include "../client/snd_loc.h"
@ -38,17 +54,39 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define AUDIOBUFFERSIZE 4096
#define AUDIOBUFFERS 64
#ifdef __sgi
/* must be a power of 2! */
#define QSND_SKID 2
#define QSND_BUFFER_FRAMES 8192
#define QSND_BUFFER_SIZE (QSND_BUFFER_FRAMES * 2)
#define UST_TO_BUFFPOS(ust) ((int)((ust) & (QSND_BUFFERS_FRAMES - 1)) << 1)
short int dma_buffer[QSND_BUFFER_SIZE];
ALport sgisnd_aport = NULL;
long long sgisnd_startframe;
double sgisnd_frames_per_ns;
long long sgisnd_lastframewritten = 0;
#else /* !__sgi */
static int audio_fd = -1;
static volatile int snd_inited;
static volatile int frags_sent;
static int mmapped = 0;
static int tryrates[] = { 11025, 22051, 44100, 48000, 8000 };
#endif
cvar_t *sndbits;
cvar_t *sndspeed;
cvar_t *sndchannels;
cvar_t *snddevice;
static int tryrates[] = { 11025, 22051, 44100, 48000, 8000 };
/* irix cvars -- jaq */
cvar_t * s_loadas8bit;
cvar_t * s_khz;
static pthread_t audio;
@ -61,12 +99,96 @@ void * thesound(void * arg) {
pthread_exit(0L);
}
qboolean SNDDMA_Init(void)
{
qboolean SNDDMA_Init(void) {
/* merged in from snd_irix.c -- jaq */
#ifdef __sgi
ALconfig ac = NULL;
ALpv pvbuf[2];
s_loadas8bit = Cvar_Get("s_loadas8bit", "16", CVAR_ARCHIVE);
if ((int) s_loadas8bit->value)
dma.samplebits = 8;
else
dma.samplebits = 16;
if (dma.samplebits != 16) {
Com_Printf("Don't currently support %i-bit data. Forcing 16-bit\n", dma.samplebits);
dma.samplebits = 16;
Cvar_SetValue("s_loadas8bit", false);
}
s_khz = Cvar_Get("s_khz", "0", CVAR_ARCHIVE);
switch ((int) s_khz->value) {
case 48:
dma.speed = AL_RATE_48000;
break;
case 44:
dma.speed = AL_RATE_44100;
break;
case 32:
dma.speed = AL_RATE_32000;
break;
case 22:
dma.speed = AL_RATE_22050;
break;
case 16:
dma.speed = AL_RATE_16000;
break;
case 11:
dma.speed = AL_RATE_11025;
break;
case 8:
dma.speed = AL_RATE_8000;
break;
default:
dma.speed = AL_RATE_22050;
Com_Printf("Don't currently support %ikHz sample rate, using %i.\n", (int) s_khz->value, (int) (dma.speed/1000));
}
sndchannels = Cvar_Get("sndchannels", "2", CVAR_ARCHIVE);
dma.channels = (int) sndchannels->value;
if (dma.channels != 2)
Com_Printf("Don't currently support %i sound channels, try 2.\n", dma.channels);
ac = alNewConfig();
alSetChannels(ac, AL_STEREO);
alSetStampFmt(ac, AL_SAMPFMT_TWOSCOMP);
alSetQueueSize(ac, QSND_BUFFER_FRAMES);
if (dma.samplebits == 8)
alSetWidth(ac, AL_SAMPLE_8);
else
alSetWidth(ac, AL_SAMPLE_16);
sgisnd_aport = alOpenPort("Quake", "w", ac);
if (!sgisnd_aport) {
printf("failed to open audio port!\n");
}
/* set desired sample rate */
pvbuf[0].param = AL_MASTER_CLOCK;
pvbuf[0].value.i = AL_CRYSTAL_MCLK_TYPE;
pvbuf[1].param = AL_RATE;
pvbuf[1].value.ll = alIntToFixed(dma.speed);
alSetParams(alGetResource(sgisnd_aport), pvbuf, 2);
if (pvbuf[1].sizeOut < 0)
printf("illegal sample rate %d\n", dma.speed);
sgisnd_frames_per_ns = dma.speed * 1.0e-9;
dma.samples = sizeof(dma_buffer) / (dma.samplebits / 8);
dma.submission_chunk = 1;
dma.buffer = (unsigned char *) dma_buffer;
dma.samplepos = 0;
alFreeConfig(ac);
return true;
#else /* __sgi */
int rc;
int fmt;
int fmt;
int tmp;
int i;
int i;
struct audio_buf_info info;
int caps;
extern uid_t saved_euid;
@ -76,22 +198,30 @@ qboolean SNDDMA_Init(void)
snd_inited = 0;
if (!snddevice)
{
if (!snddevice) {
sndbits = Cvar_Get("sndbits", "16", CVAR_ARCHIVE);
sndspeed = Cvar_Get("sndspeed", "0", CVAR_ARCHIVE);
sndchannels = Cvar_Get("sndchannels", "2", CVAR_ARCHIVE);
/* merged in from snd_bsd.c -- jaq */
#ifdef __linux__
snddevice = Cvar_Get("snddevice", "/dev/dsp", CVAR_ARCHIVE);
#else /* bsd */
snddevice = Cvar_Get("snddevice", "/dev/audio", CVAR_ARCHIVE);
#endif
}
// open /dev/dsp, check capability to mmap, and get size of dma buffer
/* snd_bsd.c had "if (!audio_fd)" */
if (audio_fd == -1)
{
seteuid(saved_euid);
audio_fd = open(snddevice->string, O_RDWR);
/* moved from below in snd_bsd.c -- jaq */
seteuid(getuid());
if (audio_fd == -1)
{
perror(snddevice->string);
@ -99,11 +229,13 @@ qboolean SNDDMA_Init(void)
Com_Printf("SNDDMA_Init: Could not open %s.\n", snddevice->string);
return 0;
}
/*
seteuid(getuid());
*/
}
rc = ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
if (rc == -1)
if (rc == -1) /* snd_bsd has "rc < 0" */
{
perror(snddevice->string);
Com_Printf("SNDDMA_Init: Could not reset %s.\n", snddevice->string);
@ -156,16 +288,14 @@ qboolean SNDDMA_Init(void)
// set sample bits & speed
dma.samplebits = (int)sndbits->value;
if (dma.samplebits != 16 && dma.samplebits != 8)
{
if (dma.samplebits != 16 && dma.samplebits != 8) {
ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &fmt);
if (fmt & AFMT_S16_NE) dma.samplebits = 16;
else if (fmt & AFMT_U8) dma.samplebits = 8;
}
dma.speed = (int)sndspeed->value;
if (!dma.speed)
{
if (!dma.speed) {
for (i=0 ; i<sizeof(tryrates)/4 ; i++)
if (!ioctl(audio_fd, SNDCTL_DSP_SPEED, &tryrates[i]))
break;
@ -299,10 +429,31 @@ qboolean SNDDMA_Init(void)
snd_inited = 1;
}
return 1;
#endif /* !__sgi */
}
int SNDDMA_GetDMAPos(void)
{
/*
* SNDDMA_GetDMAPos
*
* return the current sample position (in mono samples, not stereo)
* insde the recirculating dma buffer, so the mixing code will know
* how many samples are required to fill it up.
*/
int SNDDMA_GetDMAPos(void) {
/* merged in from snd_irix.c -- jaq */
#ifdef __sgi
long long ustFuture, ustNow;
if (!sgisnd_aport)
return 0;
alGetFrameTime(sgisnd_aport, &sgisnd_startframe, &ustFuture);
dmGetUST((unsigned long long *) &ustNow);
sgisnd_startframe -= (long long) ((ustFuture - ustNow) * sgisnd_frames_per_ns);
sgisnd_startframe += 100;
/* printf("frame %ld pos %d\n", frame, UST_TO_BUFFPOS(sgisnd_startframe)); */
return UST_TO_BUFFPOS(sgisnd_startframe);
#else /* __sgi */
struct count_info count;
if (!snd_inited) return 0;
@ -324,8 +475,13 @@ int SNDDMA_GetDMAPos(void)
dma.samplepos = count.ptr / (dma.samplebits / 8);
return dma.samplepos;
#endif /* __sgi */
}
/*
* SNDDMA_Shutdown
* Reset the sound device for exiting
*/
void SNDDMA_Shutdown(void) {
#if 0
if (snd_inited)
@ -335,6 +491,13 @@ void SNDDMA_Shutdown(void) {
snd_inited = 0;
}
#endif
/* merged in from snd_irix.c -- jaq */
#ifdef __sgi
if (sgisnd_aport) {
alClosePort(sgisnd_aport);
sgisnd_aport = NULL;
}
#else
if (snd_inited) {
if (!mmapped) {
snd_inited = 0L;
@ -351,6 +514,7 @@ void SNDDMA_Shutdown(void) {
audio_fd = -1;
snd_inited = 0;
}
#endif
}
/*
@ -360,8 +524,59 @@ SNDDMA_Submit
Send sound to device if buffer isn't really the dma buffer
===============
*/
void SNDDMA_Submit(void)
{
/* merged in from snd_irix.c -- jaq */
#ifdef __sgi
extern int soundtime;
#endif
void SNDDMA_Submit(void) {
#ifdef __sgi
int nFillable, nFilled, nPos;
int nFrames, nFramesLeft;
unsigned endtime;
if (!sgisnd_aport)
return;
nFillable = alGetFillable(sgisnd_aport);
nFilled = QSND_BUFFER_FRAMES - nFillable;
nFrames = dma.samples >> (dma.channels - 1);
if (paintedtime - soundtime < nFrames)
nFrames = paintedtime - soundtime;
if (nFrames <= QSND_SKID)
return;
nPos = UST_TO_BUFFPOS(sgisnd_startframe);
/* dump rewritten contents of the buffer */
if (sgisnd_lastframewritten > sgisnd_startframe) {
alDiscardFrames(sgisnd_aport, sgisnd_lastframewritten - sgisnd_startframe);
} else if ((int) (sgisnd_startframe - sgisnd_lastframewritten) >= QSND_BUFFER_FRAMES) {
/* blow away everything if we've underflowed */
alDiscardFrames(sgisnd_aport, QSND_BUFFER_FRAMES);
}
/* don't block */
if (nFrames > nFillable)
nFrames = nFillable;
/* account for stereo */
nFramesLeft = nFrames;
if (nPos + nFrames * dma.channels > QSND_BUFFER_SIZE) {
int nFramesAtEnd = (QSND_BUFFER_SIZE - nPos) >> (dma.channels - 1);
alWriteFrames(sgisnd_aport, &dma_buffer[nPos], nFramesAtEnd);
nPos = 0;
nFramesLeft -= nFramesAtEnd;
}
alWriteFrames(sgi_aport, &dma_buffer[nPos], nFramesLeft);
sgisnd_lastframewritten = sgisnd_startframe + nFrames;
#endif /* __sgi */
}
void SNDDMA_BeginPainting (void)

View file

@ -1,25 +1,28 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
/* $Id$
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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.
*/
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.
*/
#include "../client/client.h"
#include "../client/qmenu.h"
/* irix/vid_menu.c defines only REF_SOFT and REF_OPENGL, we'll use REF_GLX */
#define REF_SOFT 0
#define REF_SOFTX11 1
#define REF_SOFTSDL 2
@ -106,9 +109,9 @@ static void BrightnessCallback( void *s )
else
s_brightness_slider[0].curvalue = s_brightness_slider[1].curvalue;
if ( stricmp( vid_ref->string, "soft" ) == 0 ||
stricmp( vid_ref->string, "softx" ) == 0 ||
stricmp( vid_ref->string, "softsdl" ) == 0 )
if ( Q_stricmp( vid_ref->string, "soft" ) == 0 ||
Q_stricmp( vid_ref->string, "softx" ) == 0 ||
Q_stricmp( vid_ref->string, "softsdl" ) == 0 )
{
float gamma = ( 0.8 - ( slider->curvalue/10.0 - 0.5 ) ) + 0.5;
@ -176,12 +179,12 @@ static void ApplyChanges( void *unused )
** update appropriate stuff if we're running OpenGL and gamma
** has been modified
*/
if ( stricmp( vid_ref->string, "gl" ) == 0 )
if ( Q_stricmp( vid_ref->string, "gl" ) == 0 )
{
if ( vid_gamma->modified )
{
vid_ref->modified = true;
if ( stricmp( gl_driver->string, "3dfxgl" ) == 0 )
if ( Q_stricmp( gl_driver->string, "3dfxgl" ) == 0 )
{
char envbuffer[1024];
float g;
@ -218,6 +221,7 @@ void VID_MenuInit( void )
"[1152 864 ]",
"[1280 1024]",
"[1600 1200]",
"[2048 1536]", /* irix/vid_menu.c -- jaq */
0
};
static const char *refs[] =

View file

@ -1,32 +1,52 @@
/*
Copyright (C) 1997-2001 Id Software, Inc.
/* $Id$
*
* Copyright (C) 1997-2001 Id Software, Inc.
* Copyright (c) 2002 The Quakeforge Project.
*
* 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.
*/
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.
*/
// Main windowed and fullscreen graphics interface module. This module
// is used for both the software and OpenGL rendering versions of the
// Quake refresh engine.
/* merged in from irix/vid_so.c -- jaq */
#ifdef __sgi
#define SO_FILE "/etc/quake2.conf"
#endif
#include <assert.h>
#include <dlfcn.h> // ELF dl loader
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
/* merged in from bsd -- jaq */
#ifndef RTLD_NOW
#define RTLD_NOW RTLD_LAZY
#endif
#ifndef RTLD_GLOBAL
#define RTLD_GLOBAL 0
#endif
#ifdef __OpenBSD__
#define dlsym(X, Y) dlsym(X, "_"##Y)
#endif
#include "../client/client.h"
#include "rw.h"
@ -34,6 +54,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Structure containing functions exported from refresh DLL
refexport_t re;
/* merged from irix/vid_so.c -- jaq */
#ifdef REF_HARD_LINKED
refexport_t GetRefAPI(refimport_t rimp);
#endif
// Console variables that we need to access from this module
cvar_t *vid_gamma;
cvar_t *vid_ref; // Name of Refresh DLL loaded
@ -177,7 +202,10 @@ void VID_FreeReflib (void)
KBD_Close_fp();
if (RW_IN_Shutdown_fp)
RW_IN_Shutdown_fp();
/* merged from irix/vid_so.c -- jaq */
#ifndef REF_HARD_LINKED
dlclose(reflib_library);
#endif
}
KBD_Init_fp = NULL;
@ -204,7 +232,10 @@ VID_LoadRefresh
qboolean VID_LoadRefresh( char *name )
{
refimport_t ri;
/* from irix/vid_so.c -- jaq */
#ifndef REF_HARD_LINKED
GetRefAPI_t GetRefAPI;
#endif
char fn[MAX_OSPATH];
char *path;
struct stat st;
@ -222,6 +253,9 @@ qboolean VID_LoadRefresh( char *name )
VID_FreeReflib ();
}
/* from irix/vid_so.c -- jaq */
#ifndef REF_HARD_LINKED
Com_Printf( "------- Loading %s -------\n", name );
//regain root
@ -263,7 +297,8 @@ qboolean VID_LoadRefresh( char *name )
return false;
}
Com_Printf( "LoadLibrary(\"%s\")\n", fn );
Com_Printf( "LoadLibrary(\"%s\")\n", fn );
#endif /* REF_HARD_LINKED */
ri.Cmd_AddCommand = Cmd_AddCommand;
ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
@ -282,8 +317,10 @@ qboolean VID_LoadRefresh( char *name )
ri.Vid_MenuInit = VID_MenuInit;
ri.Vid_NewWindow = VID_NewWindow;
#ifndef REF_HARD_LINKED
if ( ( GetRefAPI = (GetRefAPI_t) dlsym( reflib_library, "GetRefAPI" ) ) == 0 )
Com_Error( ERR_FATAL, "dlsym failed on %s", name );
#endif
re = GetRefAPI( ri );
@ -299,6 +336,7 @@ qboolean VID_LoadRefresh( char *name )
in_state.viewangles = cl.viewangles;
in_state.in_strafe_state = &in_strafe.state;
#ifndef REF_HARD_LINKED
if ((RW_IN_Init_fp = (void (*)(in_state_t *)) dlsym(reflib_library, "RW_IN_Init")) == NULL ||
(RW_IN_Shutdown_fp = (void(*)(void)) dlsym(reflib_library, "RW_IN_Shutdown")) == NULL ||
(RW_IN_Activate_fp = (void(*)(qboolean)) dlsym(reflib_library, "RW_IN_Activate")) == NULL ||
@ -311,6 +349,23 @@ qboolean VID_LoadRefresh( char *name )
RW_Sys_GetClipboardData_fp = (char*(*)(void)) dlsym(reflib_library, "RW_Sys_GetClipboardData");
Real_IN_Init();
#else /* ref-hard-linked */
{
void RW_IN_Init(in_state_t *in_state_p);
void RW_IN_Shutdown(void);
void RW_IN_Commands (void);
void RW_IN_Move (usercmd_t *cmd);
void RW_IN_Frame (void);
void RW_IN_Activate(void);
RW_IN_Init_fp = RW_IN_Init;
RW_IN_Shutdown_fp = RW_IN_Shutdown;
RW_IN_Activate_fp = RW_IN_Activate;
RW_IN_Commands_fp = RW_IN_Commands;
RW_IN_Move_fp = RW_IN_Move;
RW_IN_Frame_fp = RW_IN_Frame;
}
#endif
if ( re.Init( 0, 0 ) == -1 )
{
@ -319,8 +374,15 @@ qboolean VID_LoadRefresh( char *name )
return false;
}
/* merged in from irix/vid_so.c */
#ifdef __sgi
/* give up root now */
setreuid(getuid(), getuid());
setegid(getgid());
#endif
/* Init KBD */
#if 1
#ifndef REF_HARD_LINKED
if ((KBD_Init_fp = (void(*)(Key_Event_fp_t)) dlsym(reflib_library, "KBD_Init")) == NULL ||
(KBD_Update_fp = (void(*)(void)) dlsym(reflib_library, "KBD_Update")) == NULL ||
(KBD_Close_fp = (void(*)(void)) dlsym(reflib_library, "KBD_Close")) == NULL)
@ -338,11 +400,17 @@ qboolean VID_LoadRefresh( char *name )
#endif
KBD_Init_fp(Do_Key_Event);
/* for some reason irix has this swapped with elsewhere, kinda dodgy, needs
* cleaning */
#ifndef __sgi
Key_ClearStates();
// give up root now
setreuid(getuid(), getuid());
setegid(getgid());
#else
Real_IN_Init();
#endif
Com_Printf( "------------------------------------\n");
reflib_active = true;
@ -382,11 +450,11 @@ void VID_CheckChanges (void)
if ( !VID_LoadRefresh( name ) )
{
if ( strcmp (vid_ref->string, "soft") == 0 ||
strcmp (vid_ref->string, "softx") == 0 ) {
Com_Printf("Refresh failed\n");
strcmp (vid_ref->string, "softx") == 0 ) {
Com_Printf("Refresh failed\n");
sw_mode = Cvar_Get( "sw_mode", "0", 0 );
if (sw_mode->value != 0) {
Com_Printf("Trying mode 0\n");
Com_Printf("Trying mode 0\n");
Cvar_SetValue("sw_mode", 0);
if ( !VID_LoadRefresh( name ) )
Com_Error (ERR_FATAL, "Couldn't fall back to software refresh!");
@ -500,6 +568,8 @@ void IN_Move (usercmd_t *cmd)
void IN_Frame (void)
{
/* merged from irix/vid_so.c */
#ifndef __sgi
if (RW_IN_Activate_fp)
{
if ( !cl.refresh_prepped || cls.key_dest == key_console || cls.key_dest == key_menu)
@ -507,13 +577,18 @@ void IN_Frame (void)
else
RW_IN_Activate_fp(true);
}
#endif
if (RW_IN_Frame_fp)
RW_IN_Frame_fp();
}
void IN_Activate (qboolean active)
{
void IN_Activate (qboolean active) {
/* merged in from irix/vid_so.c -- jaq */
#ifdef __sgi
if (RW_IN_Activate_fp)
RW_IN_Activate_fp(active);
#endif
}
void Do_Key_Event(int key, qboolean down)