mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-01-21 07:30:55 +00:00
Reapply changes - this time tested w/ svga under Linux
This commit is contained in:
parent
c9d579b1b5
commit
5b094c2aa1
31 changed files with 428 additions and 31 deletions
|
@ -85,5 +85,8 @@
|
|||
/* If your version of OpenGL uses APIENTRY, define GLAPIENTRY to be APIENTRY */
|
||||
#undef GLAPIENTRY
|
||||
|
||||
/* Define this to something sane if you don't have stricmp */
|
||||
#undef stricmp
|
||||
|
||||
@BOTTOM@
|
||||
#endif // _CONFIG_H
|
||||
|
|
59
configure.in
59
configure.in
|
@ -84,11 +84,13 @@ AC_TYPE_SIZE_T
|
|||
AC_STRUCT_ST_BLKSIZE
|
||||
AC_HEADER_TIME
|
||||
AC_STRUCT_TM
|
||||
AC_C_BIGENDIAN
|
||||
|
||||
AC_TRY_COMPILE(
|
||||
[#include <sys/types.h>],
|
||||
[ socklen_t x = 0;],
|
||||
AC_DEFINE(HAVE_SOCKLEN_T)
|
||||
AC_DEFINE(HAVE_SOCKLEN_T) AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no)
|
||||
dnl FreeBSD 4.0 has it in sys/socket.h
|
||||
AC_MSG_CHECKING(for socklen_t in sys/socket.h)
|
||||
AC_TRY_COMPILE(
|
||||
|
@ -462,13 +464,14 @@ case "${host}" in
|
|||
[ --disable-asmopt disable assembler optimization],
|
||||
ASM_ARCH=none
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_DEFINE(USE_INTEL_ASM)
|
||||
AC_DEFINE(USE_INTEL_ASM)
|
||||
ASM_ARCH=yes
|
||||
AC_MSG_RESULT(no)
|
||||
)
|
||||
;;
|
||||
*) AC_MSG_RESULT(no)
|
||||
esac
|
||||
AC_SUBST(ASM_ARCH)
|
||||
AM_CONDITIONAL(ASM_ARCH, test "$ASM_ARCH" = "yes")
|
||||
|
||||
dnl ==================================================================
|
||||
dnl Checks for sound
|
||||
|
@ -546,6 +549,15 @@ QF_maGiC_VALUE
|
|||
], SNDTYPE="WIN32"
|
||||
SOUND_LIBS="-lwinmm")
|
||||
fi
|
||||
dnl Sun
|
||||
if test -z "$SNDTYPE" -a "x$ac_cv_header_sys_audioio_h" = "xyes"; then
|
||||
AC_EGREP_CPP([QF_maGiC_VALUE],[
|
||||
#include <sys/audioio.h>
|
||||
#ifdef AUDIO_SETINFO
|
||||
QF_maGiC_VALUE
|
||||
#endif
|
||||
], SNDTYPE="SUN")
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT([yes ($SNDTYPE)])
|
||||
AC_SUBST(SOUND_LIBS)
|
||||
|
@ -553,8 +565,7 @@ AM_CONDITIONAL(SNDTYPE_MME, test "$SNDTYPE" = "MME")
|
|||
AM_CONDITIONAL(SNDTYPE_OSS, test "$SNDTYPE" = "OSS")
|
||||
AM_CONDITIONAL(SNDTYPE_ALSA, test "$SNDTYPE" = "ALSA")
|
||||
AM_CONDITIONAL(SNDTYPE_WIN32, test "$SNDTYPE" = "WIN32")
|
||||
AM_CONDITIONAL(SNDTYPE_NULL, test "$SNDTYPE" != "WIN32" -a "$SNDTYPE" != "ALSA" -a "$SNDTYPE" != "OSS" -a "$SNDTYPE" != "MME")
|
||||
|
||||
AM_CONDITIONAL(SNDTYPE_SUN, test "$SNDTYPE" = "SUN")
|
||||
|
||||
dnl ==================================================================
|
||||
dnl Checks for CD-ROM
|
||||
|
@ -595,7 +606,43 @@ dnl ==================================================================
|
|||
dnl Checks for networking
|
||||
dnl ==================================================================
|
||||
|
||||
NET_LIBS=""
|
||||
if test "x$ac_cv_func_connect" != "xyes"; then
|
||||
AC_CHECK_LIB(socket,connect,
|
||||
NET_LIBS="$NET_LIBS -lsocket"
|
||||
ac_cv_func_connect=yes)
|
||||
fi
|
||||
if test "x$ac_cv_func_gethostbyname" != "xyes"; then
|
||||
AC_CHECK_LIB(nsl,gethostbyname,
|
||||
NET_LIBS="$NET_LIBS -lnsl"
|
||||
ac_cv_func_gethostbyname=yes)
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for connect in -lwsock32])
|
||||
SAVELIBS="$LIBS"
|
||||
LIBS="$LIBS -lwsock32"
|
||||
AC_TRY_LINK([
|
||||
#include <winsock.h>
|
||||
],[
|
||||
connect(0, NULL, 42);
|
||||
],
|
||||
NET_LIBS="$NET_LIBS -lwsock32 -lwinmm"
|
||||
ac_cv_func_connect=yes
|
||||
ac_cv_func_gethostbyname=yes
|
||||
HAVE_WSOCK=yes
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no))
|
||||
LIBS="$SAVELIBS"
|
||||
|
||||
AC_MSG_CHECKING(for UDP support)
|
||||
if test "x$ac_cv_func_connect" = "xyes" -a \
|
||||
"x$ac_cv_func_gethostbyname" = "xyes"; then
|
||||
HAVE_UDP=yes
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
|
||||
if test "x$ac_cv_func_connect" != "xyes"; then
|
||||
AC_MSG_CHECKING([for connect in -lwsock32])
|
||||
SAVELIBS="$LIBS"
|
||||
|
|
|
@ -17,21 +17,35 @@ libqfsys_cl_a_SOURCES = sys_unix.c cl_sys_unix.c
|
|||
libqfsys_sv_a_SOURCES = sys_unix.c sv_sys_unix.c
|
||||
endif
|
||||
|
||||
if ASM_ARCH
|
||||
MATH_ASM = math.S
|
||||
WORLDA_ASM = worlda.S
|
||||
CL_ASM = snd_mixa.S cl_math.S sys_x86.S
|
||||
SOFT_ASM = d_draw.S d_draw16.S d_parta.S d_polysa.S d_scana.S \
|
||||
d_spr8.S d_varsa.S r_aclipa.S r_aliasa.S r_drawa.S r_edgea.S \
|
||||
r_varsa.S surf16.S surf8.S
|
||||
endif
|
||||
|
||||
EXTRA_libqfsys_cl_a_SOURCES = cl_sys_unix.c cl_sys_win.c sys_win.c sys_unix.c fnmatch.c dirent.c
|
||||
EXTRA_libqfsys_sv_a_SOURCES = sv_sys_unix.c sv_sys_win.c sys_win.c sys_unix.c fnmatch.c dirent.c
|
||||
|
||||
if SNDTYPE_WIN32
|
||||
libqfsnd_a_SOURCES = snd_dma.c snd_win.c
|
||||
endif
|
||||
libqfsnd_a_SOURCES = snd_win.c snd_dma.c snd_mem.c snd_mix.c
|
||||
else
|
||||
if SNDTYPE_OSS
|
||||
libqfsnd_a_SOURCES = snd_dma.c snd_oss.c
|
||||
endif
|
||||
libqfsnd_a_SOURCES = snd_oss.c snd_dma.c snd_mem.c snd_mix.c
|
||||
else
|
||||
if SNDTYPE_ALSA
|
||||
libqfsnd_a_SOURCES = snd_dma.c snd_alsa.c
|
||||
endif
|
||||
if SNDTYPE_NULL
|
||||
libqfsnd_a_SOURCES = snd_alsa.c snd_dma.c snd_mem.c snd_mix.c
|
||||
else
|
||||
if SNDTYPE_SUN
|
||||
libqfsnd_a_SOURCES = snd_sun.c snd_dma.c snd_mem.c snd_mix.c
|
||||
else
|
||||
libqfsnd_a_SOURCES = snd_null.c
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
EXTRA_libqfsnd_a_SOURCES = snd_dma.c snd_win.c snd_oss.c snd_alsa.c snd_null.c
|
||||
|
||||
if CDTYPE_WIN32
|
||||
|
@ -46,26 +60,23 @@ endif
|
|||
EXTRA_libqfcd_a_SOURCES = cd_win.c cd_linux.c cd_null.c
|
||||
|
||||
common_SOURCES= net_chan.c net_com.c net_udp.c pmove.c pmovetst.c zone.c \
|
||||
mdfour.c mathlib.c math.S cvar.c crc.c model.c cmd.c \
|
||||
mdfour.c mathlib.c cvar.c crc.c model.c cmd.c \
|
||||
qargs.c qendian.c quakefs.c quakeio.c msg.c sizebuf.c info.c \
|
||||
checksum.c link.c buildnum.c va.c com.c
|
||||
checksum.c link.c buildnum.c va.c com.c $(MATH_ASM)
|
||||
server_SOURCES= pr_cmds.c pr_edict.c pr_exec.c sv_init.c sv_main.c sv_misc.c \
|
||||
sv_model.c sv_nchan.c sv_ents.c sv_send.c sv_move.c sv_phys.c \
|
||||
sv_user.c sv_ccmds.c world.c worlda.S sv_cvar.c
|
||||
sv_user.c sv_ccmds.c world.c sv_cvar.c $(WORLDA_ASM)
|
||||
client_SOURCES= cl_cmd.c cl_cvar.c cl_demo.c cl_ents.c cl_input.c cl_main.c \
|
||||
cl_math.S cl_misc.c cl_parse.c cl_pred.c cl_tent.c cl_cam.c \
|
||||
r_view.c wad.c snd_mem.c snd_mix.c snd_mixa.S \
|
||||
cl_misc.c cl_parse.c cl_pred.c cl_tent.c cl_cam.c \
|
||||
r_view.c wad.c \
|
||||
skin.c sbar.c nonintel.c menu.c keys.c console.c \
|
||||
sys_x86.S cl_slist.c
|
||||
cl_slist.c $(CL_ASM)
|
||||
soft_SOURCES= cl_model.c cl_trans.c d_edge.c d_fill.c d_init.c d_modech.c \
|
||||
d_part.c d_polyse.c d_scan.c d_sky.c d_sprite.c d_surf.c \
|
||||
d_vars.c d_zpoint.c draw.c r_aclip.c r_alias.c r_bsp.c \
|
||||
r_draw.c r_edge.c r_efrag.c r_light.c r_main.c r_misc.c \
|
||||
r_part.c r_sky.c r_sprite.c r_surf.c r_vars.c sw_view.c \
|
||||
screen.c \
|
||||
d_draw.S d_draw16.S d_parta.S d_polysa.S d_scana.S \
|
||||
d_spr8.S d_varsa.S r_aclipa.S r_aliasa.S r_drawa.S r_edgea.S \
|
||||
r_varsa.S surf16.S surf8.S
|
||||
screen.c $(SOFT_ASM)
|
||||
ogl_SOURCES= gl_draw.c gl_mesh.c gl_model.c gl_ngraph.c gl_part.c \
|
||||
gl_refrag.c gl_rlight.c gl_rmain.c gl_rmisc.c gl_rsurf.c \
|
||||
gl_screen.c gl_trans.c gl_view.c gl_warp.c
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
//char *date = "Dec 21 1999";
|
||||
static char *date = __DATE__ ;
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
#include "msg.h"
|
||||
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
===================
|
||||
|
|
|
@ -58,6 +58,12 @@
|
|||
#include "draw.h"
|
||||
#include "qargs.h"
|
||||
#include "cdaudio.h"
|
||||
|
||||
#ifdef __sun
|
||||
/* Sun's model_t in sys/model.h conflicts w/ Quake's model_t */
|
||||
#define model_t sunmodel_t
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "winquake.h"
|
||||
#include "winsock.h"
|
||||
|
@ -65,7 +71,15 @@
|
|||
#else
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#ifdef __sun
|
||||
#undef model_t
|
||||
#endif
|
||||
|
||||
#include <cl_slist.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
|
||||
// we need to declare some mouse variables here, because the menu system
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "model.h"
|
||||
#include "crc.h"
|
||||
#include "msg.h"
|
||||
|
|
|
@ -40,6 +40,9 @@
|
|||
#include "msg.h"
|
||||
#include "pmove.h"
|
||||
#include "sbar.h"
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
extern cvar_t *gl_flashblend;
|
||||
extern cvar_t *cl_autoexec;
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#define MAX_BEAMS 8
|
||||
typedef struct
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
#include "client.h"
|
||||
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
=====================
|
||||
|
|
|
@ -41,6 +41,9 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
void Cmd_ForwardToServer (void);
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ COM_Init
|
|||
*/
|
||||
void COM_Init (void)
|
||||
{
|
||||
#ifndef WORDS_BIGENDIEN
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
bigendien = false;
|
||||
BigShort = ShortSwap;
|
||||
LittleShort = ShortNoSwap;
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "bothdefs.h" // needed by: common.h, net.h, client.h
|
||||
|
||||
|
@ -1240,7 +1243,12 @@ void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboole
|
|||
{
|
||||
if (!mipmap)
|
||||
{
|
||||
/* FIXME - what if this extension isn't available? */
|
||||
#ifdef HAVE_GL_COLOR_INDEX8_EXT
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL_COLOR_INDEX , GL_UNSIGNED_BYTE, data);
|
||||
#else
|
||||
/* FIXME - should warn that this isn't available */
|
||||
#endif
|
||||
goto done;
|
||||
}
|
||||
memcpy (scaled, data, width*height);
|
||||
|
@ -1248,7 +1256,12 @@ void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboole
|
|||
else
|
||||
GL_Resample8BitTexture (data, width, height, scaled, scaled_width, scaled_height);
|
||||
|
||||
// FIXME - what if this extension isn't available?
|
||||
#ifdef HAVE_GL_COLOR_INDEX8_EXT
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, scaled);
|
||||
#else
|
||||
/* FIXME - should warn that this isn't available */
|
||||
#endif
|
||||
if (mipmap)
|
||||
{
|
||||
int miplevel;
|
||||
|
@ -1264,7 +1277,12 @@ void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboole
|
|||
if (scaled_height < 1)
|
||||
scaled_height = 1;
|
||||
miplevel++;
|
||||
/* FIXME - what if this extension isn't available? */
|
||||
#ifdef HAVE_GL_COLOR_INDEX8_EXT
|
||||
glTexImage2D (GL_TEXTURE_2D, miplevel, GL_COLOR_INDEX8_EXT, scaled_width, scaled_height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, scaled);
|
||||
#else
|
||||
/* FIXME - should warn that this isn't available */
|
||||
#endif
|
||||
}
|
||||
}
|
||||
done: ;
|
||||
|
@ -1401,7 +1419,7 @@ void GL_SelectTexture (GLenum target)
|
|||
{
|
||||
if (!gl_mtexable)
|
||||
return;
|
||||
#ifndef __linux__ // no multitexture under Linux yet
|
||||
#ifdef _WIN32 // FIXME - only multi-texture under Win32
|
||||
qglSelectTextureSGIS(target);
|
||||
#endif
|
||||
if (target == oldtarget)
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
#endif
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "bothdefs.h" // needed by: common.h, net.h, client.h
|
||||
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "bothdefs.h"
|
||||
#include "console.h"
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
=====================================================================
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "qtypes.h"
|
||||
#include "sys.h"
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include <math.h>
|
||||
#include "qtypes.h"
|
||||
#include "mathlib.h"
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
#else
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
|
|
|
@ -82,6 +82,14 @@
|
|||
# define MAXHOSTNAMELEN 512
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SOCKLEN_T
|
||||
# ifdef HAVE_SIZE
|
||||
typedef size_t socklen_t;
|
||||
# else
|
||||
typedef unsigned int socklen_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
netadr_t net_local_adr;
|
||||
|
||||
netadr_t net_from;
|
||||
|
@ -230,13 +238,13 @@ qboolean NET_IsClientLegal(netadr_t *adr)
|
|||
|
||||
qboolean NET_GetPacket (void)
|
||||
{
|
||||
int ret;
|
||||
struct sockaddr_in from;
|
||||
int fromlen;
|
||||
int ret;
|
||||
struct sockaddr_in from;
|
||||
socklen_t fromlen;
|
||||
|
||||
fromlen = sizeof(from);
|
||||
ret = recvfrom(net_socket, net_message_buffer, sizeof(net_message_buffer),
|
||||
0, (struct sockaddr *)&from, &fromlen);
|
||||
ret = recvfrom(net_socket, (void*)net_message_buffer, sizeof(net_message_buffer), 0, (struct sockaddr *)&from, &fromlen);
|
||||
SockadrToNetadr (&from, &net_from);
|
||||
SockadrToNetadr(&from, &net_from);
|
||||
|
||||
if (ret == -1) {
|
||||
|
@ -337,7 +345,7 @@ void NET_GetLocalAddress (void)
|
|||
{
|
||||
char buff[MAXHOSTNAMELEN];
|
||||
struct sockaddr_in address;
|
||||
int namelen;
|
||||
socklen_t namelen;
|
||||
|
||||
gethostname(buff, MAXHOSTNAMELEN);
|
||||
buff[MAXHOSTNAMELEN-1] = 0;
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "sys.h"
|
||||
#include "qtypes.h"
|
||||
#include "pmove.h"
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
void SV_Error (char *error, ...);
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "sys.h"
|
||||
#include "cmd.h"
|
||||
#include "bothdefs.h"
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "sound.h"
|
||||
#include "console.h"
|
||||
|
||||
|
|
224
source/snd_sun.c
Normal file
224
source/snd_sun.c
Normal file
|
@ -0,0 +1,224 @@
|
|||
/*
|
||||
snd_sun.c
|
||||
|
||||
(description)
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
||||
Please see the file "AUTHORS" for a list of contributors
|
||||
|
||||
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:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <qtypes.h>
|
||||
#include <sound.h>
|
||||
#include <qargs.h>
|
||||
#include <console.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/wait.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/audioio.h>
|
||||
#include <errno.h>
|
||||
|
||||
int audio_fd;
|
||||
int snd_inited;
|
||||
|
||||
static int wbufp;
|
||||
static audio_info_t info;
|
||||
|
||||
#define BUFFER_SIZE 8192
|
||||
|
||||
unsigned char dma_buffer[BUFFER_SIZE];
|
||||
unsigned char pend_buffer[BUFFER_SIZE];
|
||||
int pending;
|
||||
|
||||
qboolean SNDDMA_Init(void)
|
||||
{
|
||||
if (snd_inited) {
|
||||
printf("Sound already init'd\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
shm = &sn;
|
||||
shm->splitbuffer = 0;
|
||||
|
||||
audio_fd = open("/dev/audio", O_WRONLY|O_NDELAY);
|
||||
|
||||
if (audio_fd < 0) {
|
||||
if (errno == EBUSY) {
|
||||
Con_Printf("Audio device is being used by another process\n");
|
||||
}
|
||||
perror("/dev/audio");
|
||||
Con_Printf("Could not open /dev/audio\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (ioctl(audio_fd, AUDIO_GETINFO, &info) < 0) {
|
||||
perror("/dev/audio");
|
||||
Con_Printf("Could not communicate with audio device.\n");
|
||||
close(audio_fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// set to nonblock
|
||||
//
|
||||
if (fcntl(audio_fd, F_SETFL, O_NONBLOCK) < 0) {
|
||||
perror("/dev/audio");
|
||||
close(audio_fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
AUDIO_INITINFO(&info);
|
||||
|
||||
shm->speed = 11025;
|
||||
|
||||
// try 16 bit stereo
|
||||
info.play.encoding = AUDIO_ENCODING_LINEAR;
|
||||
info.play.sample_rate = 11025;
|
||||
info.play.channels = 2;
|
||||
info.play.precision = 16;
|
||||
|
||||
if (ioctl(audio_fd, AUDIO_SETINFO, &info) < 0) {
|
||||
info.play.encoding = AUDIO_ENCODING_LINEAR;
|
||||
info.play.sample_rate = 11025;
|
||||
info.play.channels = 1;
|
||||
info.play.precision = 16;
|
||||
if (ioctl(audio_fd, AUDIO_SETINFO, &info) < 0) {
|
||||
Con_Printf("Incapable sound hardware.\n");
|
||||
close(audio_fd);
|
||||
return 0;
|
||||
}
|
||||
Con_Printf("16 bit mono sound initialized\n");
|
||||
shm->samplebits = 16;
|
||||
shm->channels = 1;
|
||||
} else { // 16 bit stereo
|
||||
Con_Printf("16 bit stereo sound initialized\n");
|
||||
shm->samplebits = 16;
|
||||
shm->channels = 2;
|
||||
}
|
||||
|
||||
shm->soundalive = true;
|
||||
shm->samples = sizeof(dma_buffer) / (shm->samplebits/8);
|
||||
shm->samplepos = 0;
|
||||
shm->submission_chunk = 1;
|
||||
shm->buffer = (unsigned char *)dma_buffer;
|
||||
|
||||
snd_inited = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SNDDMA_GetDMAPos(void)
|
||||
{
|
||||
if (!snd_inited)
|
||||
return (0);
|
||||
|
||||
if (ioctl(audio_fd, AUDIO_GETINFO, &info) < 0) {
|
||||
perror("/dev/audio");
|
||||
Con_Printf("Could not communicate with audio device.\n");
|
||||
close(audio_fd);
|
||||
snd_inited = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
return ((info.play.samples*shm->channels) % shm->samples);
|
||||
}
|
||||
|
||||
int SNDDMA_GetSamples(void)
|
||||
{
|
||||
if (!snd_inited)
|
||||
return (0);
|
||||
|
||||
if (ioctl(audio_fd, AUDIO_GETINFO, &info) < 0) {
|
||||
perror("/dev/audio");
|
||||
Con_Printf("Could not communicate with audio device.\n");
|
||||
close(audio_fd);
|
||||
snd_inited = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
return info.play.samples;
|
||||
}
|
||||
|
||||
void SNDDMA_Shutdown(void)
|
||||
{
|
||||
if (snd_inited) {
|
||||
close(audio_fd);
|
||||
snd_inited = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
SNDDMA_Submit
|
||||
|
||||
Send sound to device if buffer isn't really the dma buffer
|
||||
===============
|
||||
*/
|
||||
void SNDDMA_Submit(void)
|
||||
{
|
||||
int bsize;
|
||||
int bytes, b;
|
||||
static unsigned char writebuf[1024];
|
||||
unsigned char *p;
|
||||
int idx;
|
||||
int stop = paintedtime;
|
||||
|
||||
if (paintedtime < wbufp)
|
||||
wbufp = 0; // reset
|
||||
|
||||
bsize = shm->channels * (shm->samplebits/8);
|
||||
bytes = (paintedtime - wbufp) * bsize;
|
||||
|
||||
if (!bytes)
|
||||
return;
|
||||
|
||||
if (bytes > sizeof(writebuf)) {
|
||||
bytes = sizeof(writebuf);
|
||||
stop = wbufp + bytes/bsize;
|
||||
}
|
||||
|
||||
p = writebuf;
|
||||
idx = (wbufp*bsize) & (BUFFER_SIZE - 1);
|
||||
|
||||
for (b = bytes; b; b--) {
|
||||
*p++ = dma_buffer[idx];
|
||||
idx = (idx + 1) & (BUFFER_SIZE - 1);
|
||||
}
|
||||
|
||||
wbufp = stop;
|
||||
|
||||
if (write(audio_fd, writebuf, bytes) < bytes)
|
||||
printf("audio can't keep up!\n");
|
||||
|
||||
}
|
||||
|
|
@ -45,6 +45,9 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
qboolean sv_allow_cheats;
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "server.h"
|
||||
#include "crc.h"
|
||||
#include "msg.h"
|
||||
|
|
|
@ -45,6 +45,9 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
quakeparms_t host_parms;
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "server.h"
|
||||
#include "crc.h"
|
||||
#include "msg.h"
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include "qargs.h"
|
||||
#include "cvar.h"
|
||||
#include "server.h"
|
||||
|
@ -46,6 +49,9 @@
|
|||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* cvar_t sys_extrasleep = {"sys_extrasleep","0"};
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
#include "console.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
|
|
Loading…
Reference in a new issue