Compare commits
5 Commits
40264fdea9
...
3bbba8adce
Author | SHA1 | Date |
---|---|---|
an | 3bbba8adce | |
an | 8452118b9c | |
an | 98b8e36bdc | |
an | b5dcbff08d | |
an | 408f1ea5fe |
|
@ -13,16 +13,17 @@ find_package(OpenGL REQUIRED)
|
|||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
pkg_check_modules(SDL2 REQUIRED IMPORTED_TARGET sdl2>=2.0.0)
|
||||
pkg_check_modules(FLAC REQUIRED IMPORTED_TARGET flac>=1.3.3)
|
||||
pkg_check_modules(Vorbis REQUIRED IMPORTED_TARGET vorbis>=1.3.6
|
||||
|
||||
pkg_check_modules(FLAC IMPORTED_TARGET flac>=1.3.3)
|
||||
pkg_check_modules(Vorbis IMPORTED_TARGET vorbis>=1.3.6
|
||||
vorbisfile>=1.3.6
|
||||
ogg>=1.3.4)
|
||||
pkg_check_modules(Opus REQUIRED IMPORTED_TARGET opus>=1.3.1
|
||||
pkg_check_modules(Opus IMPORTED_TARGET opus>=1.3.1
|
||||
opusfile>=0.11
|
||||
ogg>=1.3.4)
|
||||
pkg_check_modules(MikMod REQUIRED IMPORTED_TARGET libmikmod>=3.3.11)
|
||||
pkg_check_modules(MikMod IMPORTED_TARGET libmikmod>=3.3.11)
|
||||
|
||||
add_executable(quake WIN32
|
||||
set(srcs
|
||||
source/anorm_dots.h
|
||||
source/anorms.h
|
||||
source/arch_def.h
|
||||
|
@ -85,7 +86,6 @@ add_executable(quake WIN32
|
|||
source/menu.h
|
||||
source/modelgen.h
|
||||
source/net.h
|
||||
source/net_bsd.c
|
||||
source/net_defs.h
|
||||
source/net_dgrm.c
|
||||
source/net_dgrm.h
|
||||
|
@ -93,9 +93,6 @@ add_executable(quake WIN32
|
|||
source/net_loop.h
|
||||
source/net_main.c
|
||||
source/net_sys.h
|
||||
source/net_udp.c
|
||||
source/net_udp.h
|
||||
source/pl_linux.c
|
||||
source/platform.h
|
||||
source/pr_cmds.c
|
||||
source/pr_comp.h
|
||||
|
@ -140,10 +137,6 @@ add_executable(quake WIN32
|
|||
source/snd_umx.h
|
||||
source/snd_vorbis.c
|
||||
source/snd_vorbis.h
|
||||
source/snd_wave.c
|
||||
source/snd_wave.h
|
||||
source/snd_xmp.c
|
||||
source/snd_xmp.h
|
||||
source/spritegn.h
|
||||
source/stb_image_write.h
|
||||
source/strl_fn.h
|
||||
|
@ -154,7 +147,6 @@ add_executable(quake WIN32
|
|||
source/sv_phys.c
|
||||
source/sv_user.c
|
||||
source/sys.h
|
||||
source/sys_sdl_unix.c
|
||||
source/vid.h
|
||||
source/view.c
|
||||
source/view.h
|
||||
|
@ -166,20 +158,36 @@ add_executable(quake WIN32
|
|||
source/zone.c
|
||||
source/zone.h)
|
||||
|
||||
target_compile_definitions(
|
||||
quake
|
||||
PUBLIC
|
||||
-DUSE_CODEC_FLAC=1
|
||||
-DUSE_CODEC_VORBIS=1
|
||||
-DUSE_CODEC_OPUS=1
|
||||
-DUSE_CODEC_MIKMOD=1
|
||||
-DUSE_CODEC_UMX=1)
|
||||
if(WIN32)
|
||||
list(APPEND srcs
|
||||
source/net_win.c
|
||||
source/net_wins.c
|
||||
source/net_wins.h
|
||||
source/net_wipx.c
|
||||
source/net_wipx.h
|
||||
source/pl_win.c
|
||||
source/sys_sdl_win.c)
|
||||
else()
|
||||
list(APPEND srcs
|
||||
source/net_bsd.c
|
||||
source/net_udp.c
|
||||
source/net_udp.h
|
||||
source/pl_linux.c
|
||||
source/sys_sdl_unix.c)
|
||||
endif()
|
||||
|
||||
target_link_libraries(quake
|
||||
m
|
||||
OpenGL::GL
|
||||
PkgConfig::SDL2
|
||||
PkgConfig::FLAC
|
||||
PkgConfig::Vorbis
|
||||
PkgConfig::Opus
|
||||
PkgConfig::MikMod)
|
||||
add_executable(quake WIN32 ${srcs})
|
||||
|
||||
function(agw_checked_library define library)
|
||||
if(${library}_FOUND)
|
||||
target_compile_definitions(quake PUBLIC -D${define}=1)
|
||||
target_link_libraries(quake PkgConfig::${library})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
agw_checked_library(USE_CODEC_FLAC FLAC)
|
||||
agw_checked_library(USE_CODEC_VORBIS Vorbis)
|
||||
agw_checked_library(USE_CODEC_OPUS Opus)
|
||||
agw_checked_library(USE_CODEC_MikMod MikMod)
|
||||
|
||||
target_link_libraries(quake m OpenGL::GL PkgConfig::SDL2)
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "quakedef.h"
|
||||
#include "snd_codec.h"
|
||||
#include "bgmusic.h"
|
||||
#include "cdaudio.h"
|
||||
|
||||
#define MUSIC_DIRNAME "music"
|
||||
|
||||
|
@ -169,7 +170,7 @@ qboolean BGM_Init (void)
|
|||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return CDAudio_Init ();
|
||||
}
|
||||
|
||||
void BGM_Shutdown (void)
|
||||
|
@ -178,6 +179,7 @@ void BGM_Shutdown (void)
|
|||
/* sever our connections to
|
||||
* midi_drv and snd_codec */
|
||||
music_handlers = NULL;
|
||||
CDAudio_Shutdown ();
|
||||
}
|
||||
|
||||
static void BGM_Play_noext (const char *filename, unsigned int allowed_types)
|
||||
|
@ -344,6 +346,7 @@ void BGM_Stop (void)
|
|||
bgmstream = NULL;
|
||||
s_rawend = 0;
|
||||
}
|
||||
CDAudio_Stop();
|
||||
}
|
||||
|
||||
void BGM_Pause (void)
|
||||
|
@ -353,6 +356,7 @@ void BGM_Pause (void)
|
|||
if (bgmstream->status == STREAM_PLAY)
|
||||
bgmstream->status = STREAM_PAUSE;
|
||||
}
|
||||
CDAudio_Pause ();
|
||||
}
|
||||
|
||||
void BGM_Resume (void)
|
||||
|
@ -362,6 +366,7 @@ void BGM_Resume (void)
|
|||
if (bgmstream->status == STREAM_PAUSE)
|
||||
bgmstream->status = STREAM_PLAY;
|
||||
}
|
||||
CDAudio_Resume ();
|
||||
}
|
||||
|
||||
static void BGM_UpdateStream (void)
|
||||
|
@ -465,5 +470,7 @@ void BGM_Update (void)
|
|||
}
|
||||
if (bgmstream)
|
||||
BGM_UpdateStream ();
|
||||
|
||||
CDAudio_Update();
|
||||
}
|
||||
|
||||
|
|
|
@ -310,101 +310,5 @@ typedef struct
|
|||
|
||||
//============================================================================
|
||||
|
||||
#ifndef QUAKE_GAME
|
||||
|
||||
#define ANGLE_UP -1
|
||||
#define ANGLE_DOWN -2
|
||||
|
||||
|
||||
// the utilities get to be lazy and just use large static arrays
|
||||
|
||||
extern int nummodels;
|
||||
extern dmodel_t dmodels[MAX_MAP_MODELS];
|
||||
|
||||
extern int visdatasize;
|
||||
extern byte dvisdata[MAX_MAP_VISIBILITY];
|
||||
|
||||
extern int lightdatasize;
|
||||
extern byte dlightdata[MAX_MAP_LIGHTING];
|
||||
|
||||
extern int texdatasize;
|
||||
extern byte dtexdata[MAX_MAP_MIPTEX]; // (dmiptexlump_t)
|
||||
|
||||
extern int entdatasize;
|
||||
extern char dentdata[MAX_MAP_ENTSTRING];
|
||||
|
||||
//extern int numleafs;
|
||||
//extern dleaf_t dleafs[MAX_MAP_LEAFS];
|
||||
|
||||
extern int numplanes;
|
||||
extern dplane_t dplanes[MAX_MAP_PLANES];
|
||||
|
||||
extern int numvertexes;
|
||||
extern dvertex_t dvertexes[MAX_MAP_VERTS];
|
||||
|
||||
extern int numnodes;
|
||||
extern dnode_t dnodes[MAX_MAP_NODES];
|
||||
|
||||
extern int numtexinfo;
|
||||
extern texinfo_t texinfo[MAX_MAP_TEXINFO];
|
||||
|
||||
extern int numfaces;
|
||||
extern dface_t dfaces[MAX_MAP_FACES];
|
||||
|
||||
extern int numclipnodes;
|
||||
extern dclipnode_t dclipnodes[MAX_MAP_CLIPNODES];
|
||||
|
||||
extern int numedges;
|
||||
extern dedge_t dedges[MAX_MAP_EDGES];
|
||||
|
||||
extern int nummarksurfaces;
|
||||
extern unsigned short dmarksurfaces[MAX_MAP_MARKSURFACES];
|
||||
|
||||
extern int numsurfedges;
|
||||
extern int dsurfedges[MAX_MAP_SURFEDGES];
|
||||
|
||||
|
||||
void DecompressVis (byte *in, byte *decompressed);
|
||||
int CompressVis (byte *vis, byte *dest);
|
||||
|
||||
void LoadBSPFile (char *filename);
|
||||
void WriteBSPFile (char *filename);
|
||||
void PrintBSPFileSizes (void);
|
||||
|
||||
//===============
|
||||
|
||||
|
||||
typedef struct epair_s
|
||||
{
|
||||
struct epair_s *next;
|
||||
char *key;
|
||||
char *value;
|
||||
} epair_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t origin;
|
||||
int firstbrush;
|
||||
int numbrushes;
|
||||
epair_t *epairs;
|
||||
} entity_t;
|
||||
|
||||
extern int num_entities;
|
||||
extern entity_t entities[MAX_MAP_ENTITIES];
|
||||
|
||||
void ParseEntities (void);
|
||||
void UnparseEntities (void);
|
||||
|
||||
void SetKeyValue (entity_t *ent, char *key, char *value);
|
||||
char *ValueForKey (entity_t *ent, char *key);
|
||||
// will return "" if not present
|
||||
|
||||
vec_t FloatForKey (entity_t *ent, char *key);
|
||||
void GetVectorForKey (entity_t *ent, char *key, vec3_t vec);
|
||||
|
||||
epair_t *ParseEpair (void);
|
||||
|
||||
#endif /* QUAKE_GAME */
|
||||
|
||||
#endif /* __BSPFILE_H */
|
||||
|
||||
|
|
|
@ -24,16 +24,15 @@
|
|||
|
||||
#include <SDL.h>
|
||||
|
||||
#ifndef SDL_INIT_CDROM
|
||||
#if !defined(SDL_INIT_CDROM)
|
||||
|
||||
/* SDL dropped support for
|
||||
cd audio since v1.3.0 */
|
||||
#pragma message("Warning: SDL CDAudio support disabled")
|
||||
/* SDL dropped support for CD audio since v1.3.0 */
|
||||
#include "cd_null.c"
|
||||
|
||||
#else /* SDL_INIT_CDROM */
|
||||
#else /* defined(SDL_INIT_CDROM) */
|
||||
|
||||
#include "quakedef.h"
|
||||
#include "cdaudio.h"
|
||||
|
||||
static qboolean cdValid = false;
|
||||
static qboolean playing = false;
|
||||
|
@ -581,5 +580,5 @@ void CDAudio_Shutdown(void)
|
|||
SDL_QuitSubSystem(SDL_INIT_CDROM);
|
||||
}
|
||||
|
||||
#endif /* SDL_INIT_CDROM */
|
||||
#endif /* defined(SDL_INIT_CDROM) */
|
||||
|
||||
|
|
|
@ -107,7 +107,6 @@ void CL_Disconnect (void)
|
|||
// stop sounds (especially looping!)
|
||||
S_StopAllSounds (true);
|
||||
BGM_Stop();
|
||||
CDAudio_Stop();
|
||||
|
||||
// if running a local server, shut it down
|
||||
if (cls.demoplayback)
|
||||
|
|
|
@ -1124,15 +1124,9 @@ void CL_ParseServerMessage (void)
|
|||
case svc_setpause:
|
||||
cl.paused = MSG_ReadByte ();
|
||||
if (cl.paused)
|
||||
{
|
||||
CDAudio_Pause ();
|
||||
BGM_Pause ();
|
||||
}
|
||||
else
|
||||
{
|
||||
CDAudio_Resume ();
|
||||
BGM_Resume ();
|
||||
}
|
||||
break;
|
||||
|
||||
case svc_signonnum:
|
||||
|
|
|
@ -1227,7 +1227,7 @@ void Con_DrawConsole (int lines, qboolean drawinput)
|
|||
|
||||
//draw version number in bottom right
|
||||
y += 8;
|
||||
q_snprintf (ver, sizeof(ver), "QuakeSpasm " QUAKESPASM_VER_STRING);
|
||||
q_snprintf (ver, sizeof(ver), "QuakeSpasm " QUAKESPASM_VERSION);
|
||||
for (x = 0; x < (int)strlen(ver); x++)
|
||||
Draw_Character ((con_linewidth - strlen(ver) + x + 2)<<3, y, ver[x] /*+ 128*/);
|
||||
}
|
||||
|
|
|
@ -485,7 +485,6 @@ static qboolean VID_SetMode (int width, int height, int refreshrate, int bpp, qb
|
|||
temp = scr_disabled_for_loading;
|
||||
scr_disabled_for_loading = true;
|
||||
|
||||
CDAudio_Pause ();
|
||||
BGM_Pause ();
|
||||
|
||||
/* z-buffer depth */
|
||||
|
@ -506,7 +505,7 @@ static qboolean VID_SetMode (int width, int height, int refreshrate, int bpp, qb
|
|||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, fsaa > 0 ? 1 : 0);
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
|
||||
|
||||
q_snprintf(caption, sizeof(caption), "QuakeSpasm " QUAKESPASM_VER_STRING);
|
||||
q_snprintf(caption, sizeof(caption), "QuakeSpasm " QUAKESPASM_VERSION);
|
||||
|
||||
/* Create the window if needed, hidden */
|
||||
if (!draw_context)
|
||||
|
@ -599,7 +598,6 @@ static qboolean VID_SetMode (int width, int height, int refreshrate, int bpp, qb
|
|||
|
||||
modestate = VID_GetFullscreen() ? MS_FULLSCREEN : MS_WINDOWED;
|
||||
|
||||
CDAudio_Resume ();
|
||||
BGM_Resume ();
|
||||
scr_disabled_for_loading = temp;
|
||||
|
||||
|
|
|
@ -230,8 +230,8 @@ void Host_FindMaxClients (void)
|
|||
|
||||
void Host_Version_f (void)
|
||||
{
|
||||
Con_Printf ("Quake Version %1.2f\n", VERSION);
|
||||
Con_Printf ("QuakeSpasm Version " QUAKESPASM_VER_STRING "\n");
|
||||
Con_Printf ("Quake Version %s\n", VERSION);
|
||||
Con_Printf ("QuakeSpasm Version " QUAKESPASM_VERSION "\n");
|
||||
Con_Printf ("Exe: " __TIME__ " " __DATE__ "\n");
|
||||
}
|
||||
|
||||
|
@ -749,8 +749,6 @@ void _Host_Frame (float time)
|
|||
else
|
||||
S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
|
||||
|
||||
CDAudio_Update();
|
||||
|
||||
if (host_speeds.value)
|
||||
{
|
||||
pass1 = (time1 - time3)*1000;
|
||||
|
@ -862,7 +860,6 @@ void Host_Init (void)
|
|||
SCR_Init ();
|
||||
R_Init ();
|
||||
S_Init ();
|
||||
CDAudio_Init ();
|
||||
BGM_Init();
|
||||
Sbar_Init ();
|
||||
CL_Init ();
|
||||
|
@ -924,7 +921,6 @@ void Host_Shutdown(void)
|
|||
if (con_initialized)
|
||||
History_Shutdown ();
|
||||
BGM_Shutdown();
|
||||
CDAudio_Shutdown ();
|
||||
S_Shutdown ();
|
||||
IN_Shutdown ();
|
||||
VID_Shutdown();
|
||||
|
|
|
@ -442,7 +442,7 @@ void Host_Status_f (void)
|
|||
print_fn = SV_ClientPrintf;
|
||||
|
||||
print_fn ("host: %s\n", Cvar_VariableString ("hostname"));
|
||||
print_fn ("version: %4.2f\n", VERSION);
|
||||
print_fn ("version: " VERSION "\n");
|
||||
if (tcpipAvailable)
|
||||
print_fn ("tcp/ip: %s\n", my_tcpip_address);
|
||||
if (ipxAvailable)
|
||||
|
|
|
@ -105,11 +105,10 @@ int main(int argc, char *argv[])
|
|||
if (!parms.membase)
|
||||
Sys_Error ("Not enough memory free; check disk space\n");
|
||||
|
||||
Sys_Printf("Quake %1.2f (c) id Software\n", VERSION);
|
||||
Sys_Printf("GLQuake %1.2f (c) id Software\n", GLQUAKE_VERSION);
|
||||
Sys_Printf("FitzQuake %1.2f (c) John Fitzgibbons\n", FITZQUAKE_VERSION);
|
||||
Sys_Printf("Quake " VERSION " (c) id Software\n");
|
||||
Sys_Printf("FitzQuake " FITZQUAKE_VERSION " (c) John Fitzgibbons\n");
|
||||
Sys_Printf("FitzQuake SDL port (c) SleepwalkR, Baker\n");
|
||||
Sys_Printf("QuakeSpasm " QUAKESPASM_VER_STRING " (c) Ozkan Sezer, Eric Wasylishen & others\n");
|
||||
Sys_Printf("QuakeSpasm " QUAKESPASM_VERSION " (c) Ozkan Sezer, Eric Wasylishen & others\n");
|
||||
|
||||
Sys_Printf("Host_Init\n");
|
||||
Host_Init();
|
||||
|
|
|
@ -1696,7 +1696,7 @@ void M_Quit_Draw (void) //johnfitz -- modified for new quit message
|
|||
m_state = m_quit;
|
||||
}
|
||||
|
||||
sprintf(msg1, "QuakeSpasm " QUAKESPASM_VER_STRING);
|
||||
sprintf(msg1, "QuakeSpasm " QUAKESPASM_VERSION);
|
||||
|
||||
//okay, this is kind of fucked up. M_DrawTextBox will always act as if
|
||||
//width is even. Also, the width and lines values are for the interior of the box,
|
||||
|
|
|
@ -26,27 +26,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
// quakedef.h -- primary header for client
|
||||
|
||||
#define QUAKE_GAME // as opposed to utilities
|
||||
|
||||
#define VERSION 1.09
|
||||
#define GLQUAKE_VERSION 1.00
|
||||
#define D3DQUAKE_VERSION 0.01
|
||||
#define WINQUAKE_VERSION 0.996
|
||||
#define LINUX_VERSION 1.30
|
||||
#define X11_VERSION 1.10
|
||||
|
||||
#define FITZQUAKE_VERSION 0.85 //johnfitz
|
||||
#define QUAKESPASM_VERSION 0.93
|
||||
#define QUAKESPASM_VER_PATCH 1 // helper to print a string like 0.93.1
|
||||
#ifndef QUAKESPASM_VER_SUFFIX
|
||||
#define QUAKESPASM_VER_SUFFIX // optional version suffix string literal like "-beta1"
|
||||
#endif
|
||||
|
||||
#define QS_STRINGIFY_(x) #x
|
||||
#define QS_STRINGIFY(x) QS_STRINGIFY_(x)
|
||||
|
||||
// combined version string like "0.92.1-beta1"
|
||||
#define QUAKESPASM_VER_STRING QS_STRINGIFY(QUAKESPASM_VERSION) "." QS_STRINGIFY(QUAKESPASM_VER_PATCH) QUAKESPASM_VER_SUFFIX
|
||||
#define VERSION "1.09"
|
||||
#define FITZQUAKE_VERSION "0.85" //johnfitz
|
||||
#define QUAKESPASM_VERSION "0.93.1"
|
||||
|
||||
//define PARANOID // speed sapping error checking
|
||||
|
||||
|
@ -248,7 +230,6 @@ typedef struct
|
|||
#include "input.h"
|
||||
#include "keys.h"
|
||||
#include "menu.h"
|
||||
#include "cdaudio.h"
|
||||
#include "glquake.h"
|
||||
|
||||
|
||||
|
|
|
@ -29,9 +29,7 @@
|
|||
|
||||
/* headers for individual codecs */
|
||||
#include "snd_mikmod.h"
|
||||
#include "snd_xmp.h"
|
||||
#include "snd_umx.h"
|
||||
#include "snd_wave.h"
|
||||
#include "snd_flac.h"
|
||||
#include "snd_mp3.h"
|
||||
#include "snd_vorbis.h"
|
||||
|
@ -63,29 +61,21 @@ void S_CodecInit (void)
|
|||
|
||||
/* Register in the inverse order
|
||||
* of codec choice preference: */
|
||||
#ifdef USE_CODEC_UMX
|
||||
S_CodecRegister(&umx_codec);
|
||||
#endif
|
||||
#ifdef USE_CODEC_MIKMOD
|
||||
S_CodecRegister(&mikmod_codec);
|
||||
#endif
|
||||
#ifdef USE_CODEC_XMP
|
||||
S_CodecRegister(&xmp_codec);
|
||||
#endif
|
||||
#ifdef USE_CODEC_WAVE
|
||||
S_CodecRegister(&wav_codec);
|
||||
#endif
|
||||
#ifdef USE_CODEC_FLAC
|
||||
S_CodecRegister(&flac_codec);
|
||||
#endif
|
||||
#ifdef USE_CODEC_MP3
|
||||
S_CodecRegister(&mp3_codec);
|
||||
#ifdef USE_CODEC_OPUS
|
||||
S_CodecRegister(&opus_codec);
|
||||
#endif
|
||||
#ifdef USE_CODEC_VORBIS
|
||||
S_CodecRegister(&vorbis_codec);
|
||||
#endif
|
||||
#ifdef USE_CODEC_OPUS
|
||||
S_CodecRegister(&opus_codec);
|
||||
#ifdef USE_CODEC_MP3
|
||||
S_CodecRegister(&mp3_codec);
|
||||
#endif
|
||||
|
||||
codec = codecs;
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
#include "quakedef.h"
|
||||
|
||||
#if defined(USE_CODEC_UMX)
|
||||
#include "snd_codec.h"
|
||||
#include "snd_codeci.h"
|
||||
#include "snd_umx.h"
|
||||
|
@ -403,5 +402,3 @@ snd_codec_t umx_codec =
|
|||
NULL
|
||||
};
|
||||
|
||||
#endif /* USE_CODEC_UMX */
|
||||
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
#if !defined(_SND_UMX_H_)
|
||||
#define _SND_UMX_H_
|
||||
|
||||
#if defined(USE_CODEC_UMX)
|
||||
|
||||
extern snd_codec_t umx_codec;
|
||||
|
||||
#endif /* USE_CODEC_UMX */
|
||||
|
||||
#endif /* ! _SND_UMX_H_ */
|
||||
|
||||
|
|
|
@ -1,276 +0,0 @@
|
|||
/*
|
||||
* WAV streaming music support. Adapted from ioquake3 with changes.
|
||||
*
|
||||
* Copyright (C) 1999-2005 Id Software, Inc.
|
||||
* Copyright (C) 2005 Stuart Dalton <badcdev@gmail.com>
|
||||
* Copyright (C) 2010-2012 O.Sezer <sezero@users.sourceforge.net>
|
||||
*
|
||||
* 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.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "quakedef.h"
|
||||
|
||||
#if defined(USE_CODEC_WAVE)
|
||||
#include "snd_codec.h"
|
||||
#include "snd_codeci.h"
|
||||
#include "snd_wave.h"
|
||||
|
||||
/*
|
||||
=================
|
||||
FGetLittleLong
|
||||
=================
|
||||
*/
|
||||
static int FGetLittleLong (FILE *f)
|
||||
{
|
||||
int v;
|
||||
|
||||
fread(&v, 1, sizeof(v), f);
|
||||
|
||||
return LittleLong(v);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
FGetLittleShort
|
||||
=================
|
||||
*/
|
||||
static short FGetLittleShort(FILE *f)
|
||||
{
|
||||
short v;
|
||||
|
||||
fread(&v, 1, sizeof(v), f);
|
||||
|
||||
return LittleShort(v);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
WAV_ReadChunkInfo
|
||||
=================
|
||||
*/
|
||||
static int WAV_ReadChunkInfo(FILE *f, char *name)
|
||||
{
|
||||
int len, r;
|
||||
|
||||
name[4] = 0;
|
||||
|
||||
r = fread(name, 1, 4, f);
|
||||
if (r != 4)
|
||||
return -1;
|
||||
|
||||
len = FGetLittleLong(f);
|
||||
if (len < 0)
|
||||
{
|
||||
Con_Printf("WAV: Negative chunk length\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
WAV_FindRIFFChunk
|
||||
|
||||
Returns the length of the data in the chunk, or -1 if not found
|
||||
=================
|
||||
*/
|
||||
static int WAV_FindRIFFChunk(FILE *f, const char *chunk)
|
||||
{
|
||||
char name[5];
|
||||
int len;
|
||||
|
||||
while ((len = WAV_ReadChunkInfo(f, name)) >= 0)
|
||||
{
|
||||
/* If this is the right chunk, return */
|
||||
if (!strncmp(name, chunk, 4))
|
||||
return len;
|
||||
len = ((len + 1) & ~1); /* pad by 2 . */
|
||||
|
||||
/* Not the right chunk - skip it */
|
||||
fseek(f, len, SEEK_CUR);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
WAV_ReadRIFFHeader
|
||||
=================
|
||||
*/
|
||||
static qboolean WAV_ReadRIFFHeader(const char *name, FILE *file, snd_info_t *info)
|
||||
{
|
||||
char dump[16];
|
||||
int wav_format;
|
||||
int fmtlen = 0;
|
||||
|
||||
if (fread(dump, 1, 12, file) < 12 ||
|
||||
strncmp(dump, "RIFF", 4) != 0 ||
|
||||
strncmp(&dump[8], "WAVE", 4) != 0)
|
||||
{
|
||||
Con_Printf("%s is missing RIFF/WAVE chunks\n", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Scan for the format chunk */
|
||||
if ((fmtlen = WAV_FindRIFFChunk(file, "fmt ")) < 0)
|
||||
{
|
||||
Con_Printf("%s is missing fmt chunk\n", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Save the parameters */
|
||||
wav_format = FGetLittleShort(file);
|
||||
if (wav_format != WAV_FORMAT_PCM)
|
||||
{
|
||||
Con_Printf("%s is not Microsoft PCM format\n", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
info->channels = FGetLittleShort(file);
|
||||
info->rate = FGetLittleLong(file);
|
||||
FGetLittleLong(file);
|
||||
FGetLittleShort(file);
|
||||
info->bits = FGetLittleShort(file);
|
||||
|
||||
if (info->bits != 8 && info->bits != 16)
|
||||
{
|
||||
Con_Printf("%s is not 8 or 16 bit\n", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
info->width = info->bits / 8;
|
||||
info->dataofs = 0;
|
||||
|
||||
/* Skip the rest of the format chunk if required */
|
||||
if (fmtlen > 16)
|
||||
{
|
||||
fmtlen -= 16;
|
||||
fseek(file, fmtlen, SEEK_CUR);
|
||||
}
|
||||
|
||||
/* Scan for the data chunk */
|
||||
if ((info->size = WAV_FindRIFFChunk(file, "data")) < 0)
|
||||
{
|
||||
Con_Printf("%s is missing data chunk\n", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (info->channels != 1 && info->channels != 2)
|
||||
{
|
||||
Con_Printf("Unsupported number of channels %d in %s\n",
|
||||
info->channels, name);
|
||||
return false;
|
||||
}
|
||||
info->samples = (info->size / info->width) / info->channels;
|
||||
if (info->samples == 0)
|
||||
{
|
||||
Con_Printf("%s has zero samples\n", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
S_WAV_CodecOpenStream
|
||||
=================
|
||||
*/
|
||||
static qboolean S_WAV_CodecOpenStream(snd_stream_t *stream)
|
||||
{
|
||||
long start = stream->fh.start;
|
||||
|
||||
/* Read the RIFF header */
|
||||
/* The file reads are sequential, therefore no need
|
||||
* for the FS_*() functions: We will manipulate the
|
||||
* file by ourselves from now on. */
|
||||
if (!WAV_ReadRIFFHeader(stream->name, stream->fh.file, &stream->info))
|
||||
return false;
|
||||
|
||||
stream->fh.start = ftell(stream->fh.file); /* reset to data position */
|
||||
if (stream->fh.start - start + stream->info.size > stream->fh.length)
|
||||
{
|
||||
Con_Printf("%s data size mismatch\n", stream->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
S_WAV_CodecReadStream
|
||||
=================
|
||||
*/
|
||||
int S_WAV_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
|
||||
{
|
||||
int remaining = stream->info.size - stream->fh.pos;
|
||||
int i, samples;
|
||||
|
||||
if (remaining <= 0)
|
||||
return 0;
|
||||
if (bytes > remaining)
|
||||
bytes = remaining;
|
||||
stream->fh.pos += bytes;
|
||||
fread(buffer, 1, bytes, stream->fh.file);
|
||||
if (stream->info.width == 2)
|
||||
{
|
||||
samples = bytes / 2;
|
||||
for (i = 0; i < samples; i++)
|
||||
((short *)buffer)[i] = LittleShort( ((short *)buffer)[i] );
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
static void S_WAV_CodecCloseStream (snd_stream_t *stream)
|
||||
{
|
||||
S_CodecUtilClose(&stream);
|
||||
}
|
||||
|
||||
static int S_WAV_CodecRewindStream (snd_stream_t *stream)
|
||||
{
|
||||
FS_rewind(&stream->fh);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static qboolean S_WAV_CodecInitialize (void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static void S_WAV_CodecShutdown (void)
|
||||
{
|
||||
}
|
||||
|
||||
snd_codec_t wav_codec =
|
||||
{
|
||||
CODECTYPE_WAVE,
|
||||
true, /* always available. */
|
||||
"wav",
|
||||
S_WAV_CodecInitialize,
|
||||
S_WAV_CodecShutdown,
|
||||
S_WAV_CodecOpenStream,
|
||||
S_WAV_CodecReadStream,
|
||||
S_WAV_CodecRewindStream,
|
||||
S_WAV_CodecCloseStream,
|
||||
NULL
|
||||
};
|
||||
|
||||
#endif /* USE_CODEC_WAVE */
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
/* WAV streaming music support. */
|
||||
|
||||
#if !defined(_SND_WAVE_H_)
|
||||
#define _SND_WAVE_H_
|
||||
|
||||
#if defined(USE_CODEC_WAVE)
|
||||
|
||||
extern snd_codec_t wav_codec;
|
||||
|
||||
#endif /* USE_CODEC_WAVE */
|
||||
|
||||
#endif /* ! _SND_WAVE_H_ */
|
||||
|
168
source/snd_xmp.c
168
source/snd_xmp.c
|
@ -1,168 +0,0 @@
|
|||
/* tracker music (module file) decoding support using libxmp >= v4.2.0
|
||||
* https://sourceforge.net/projects/xmp/
|
||||
* https://github.com/cmatsuoka/libxmp.git
|
||||
*
|
||||
* Copyright (C) 2016 O.Sezer <sezero@users.sourceforge.net>
|
||||
*
|
||||
* 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.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "quakedef.h"
|
||||
|
||||
#if defined(USE_CODEC_XMP)
|
||||
#include "snd_codec.h"
|
||||
#include "snd_codeci.h"
|
||||
#include "snd_xmp.h"
|
||||
#if defined(_WIN32) && defined(XMP_NO_DLL)
|
||||
#define BUILDING_STATIC
|
||||
#endif
|
||||
#include <xmp.h>
|
||||
#if ((XMP_VERCODE+0) < 0x040200)
|
||||
#error libxmp version 4.2 or newer is required
|
||||
#endif
|
||||
|
||||
static int S_XMP_StartPlay (snd_stream_t *stream)
|
||||
{
|
||||
int fmt = 0;
|
||||
|
||||
if (stream->info.channels == 1)
|
||||
fmt |= XMP_FORMAT_MONO;
|
||||
if (stream->info.width == 1)
|
||||
fmt |= XMP_FORMAT_8BIT|XMP_FORMAT_UNSIGNED;
|
||||
|
||||
return xmp_start_player((xmp_context)stream->priv, stream->info.rate, fmt);
|
||||
}
|
||||
|
||||
static qboolean S_XMP_CodecInitialize (void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static void S_XMP_CodecShutdown (void)
|
||||
{
|
||||
}
|
||||
|
||||
static qboolean S_XMP_CodecOpenStream (snd_stream_t *stream)
|
||||
{
|
||||
/* need to load the whole file into memory and pass it to libxmp
|
||||
* using xmp_load_module_from_memory() which requires libxmp >= 4.2.
|
||||
* libxmp-4.0/4.1 only have xmp_load_module() which accepts a file
|
||||
* name which isn't good with files in containers like paks, etc. */
|
||||
xmp_context c;
|
||||
byte *moddata;
|
||||
long len;
|
||||
int mark;
|
||||
|
||||
c = xmp_create_context();
|
||||
if (c == NULL)
|
||||
return false;
|
||||
|
||||
len = FS_filelength (&stream->fh);
|
||||
mark = Hunk_LowMark();
|
||||
moddata = (byte *) Hunk_Alloc(len);
|
||||
FS_fread(moddata, 1, len, &stream->fh);
|
||||
if (xmp_load_module_from_memory(c, moddata, len) != 0)
|
||||
{
|
||||
Con_DPrintf("Could not load module %s\n", stream->name);
|
||||
goto err1;
|
||||
}
|
||||
|
||||
Hunk_FreeToLowMark(mark); /* free original file data */
|
||||
stream->priv = c;
|
||||
if (shm->speed > XMP_MAX_SRATE)
|
||||
stream->info.rate = 44100;
|
||||
else if (shm->speed < XMP_MIN_SRATE)
|
||||
stream->info.rate = 11025;
|
||||
else stream->info.rate = shm->speed;
|
||||
stream->info.bits = shm->samplebits;
|
||||
stream->info.width = stream->info.bits / 8;
|
||||
stream->info.channels = shm->channels;
|
||||
|
||||
if (S_XMP_StartPlay(stream) != 0)
|
||||
goto err2;
|
||||
/* percentual left/right channel separation, default is 70. */
|
||||
if (stream->info.channels == 2)
|
||||
if (xmp_set_player(c, XMP_PLAYER_MIX, 100) != 0)
|
||||
goto err3;
|
||||
/* interpolation type, default is XMP_INTERP_LINEAR */
|
||||
if (xmp_set_player(c, XMP_PLAYER_INTERP, XMP_INTERP_SPLINE) != 0)
|
||||
goto err3;
|
||||
|
||||
return true;
|
||||
|
||||
err3: xmp_end_player(c);
|
||||
err2: xmp_release_module(c);
|
||||
err1: xmp_free_context(c);
|
||||
return false;
|
||||
}
|
||||
|
||||
static int S_XMP_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer)
|
||||
{
|
||||
int r;
|
||||
/* xmp_play_buffer() requires libxmp >= 4.1. it will write
|
||||
* native-endian pcm data to the buffer. if the data write
|
||||
* is partial, the rest of the buffer will be zero-filled.
|
||||
* the last param is the number that the current sequence of
|
||||
* the song will be looped at max. */
|
||||
r = xmp_play_buffer((xmp_context)stream->priv, buffer, bytes, 1);
|
||||
if (r == 0) {
|
||||
return bytes;
|
||||
}
|
||||
if (r == -XMP_END) {
|
||||
Con_DPrintf("XMP EOF\n");
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void S_XMP_CodecCloseStream (snd_stream_t *stream)
|
||||
{
|
||||
xmp_context c = (xmp_context)stream->priv;
|
||||
xmp_end_player(c);
|
||||
xmp_release_module(c);
|
||||
xmp_free_context(c);
|
||||
S_CodecUtilClose(&stream);
|
||||
}
|
||||
|
||||
static int S_XMP_CodecRewindStream (snd_stream_t *stream)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = S_XMP_StartPlay(stream);
|
||||
if (ret < 0) return ret;
|
||||
|
||||
/*ret = xmp_set_position((xmp_context)stream->priv, 0);*/
|
||||
ret = xmp_seek_time((xmp_context)stream->priv, 0);
|
||||
if (ret < 0) return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
snd_codec_t xmp_codec =
|
||||
{
|
||||
CODECTYPE_MOD,
|
||||
true, /* always available. */
|
||||
"s3m",
|
||||
S_XMP_CodecInitialize,
|
||||
S_XMP_CodecShutdown,
|
||||
S_XMP_CodecOpenStream,
|
||||
S_XMP_CodecReadStream,
|
||||
S_XMP_CodecRewindStream,
|
||||
S_XMP_CodecCloseStream,
|
||||
NULL
|
||||
};
|
||||
|
||||
#endif /* USE_CODEC_XMP */
|
|
@ -1,12 +0,0 @@
|
|||
/* module tracker decoding support using libxmp */
|
||||
#if !defined(_SND_XMP_H_)
|
||||
#define _SND_XMP_H_
|
||||
|
||||
#if defined(USE_CODEC_XMP)
|
||||
|
||||
extern snd_codec_t xmp_codec;
|
||||
|
||||
#endif /* USE_CODEC_XMP */
|
||||
|
||||
#endif /* ! _SND_XMP_H_ */
|
||||
|
|
@ -289,7 +289,7 @@ void SV_SendServerinfo (client_t *client)
|
|||
int i; //johnfitz
|
||||
|
||||
MSG_WriteByte (&client->message, svc_print);
|
||||
sprintf (message, "%c\nFITZQUAKE %1.2f SERVER (%i CRC)\n", 2, FITZQUAKE_VERSION, pr_crc); //johnfitz -- include fitzquake version
|
||||
sprintf (message, "%c\nFITZQUAKE " FITZQUAKE_VERSION " SERVER (%i CRC)\n", 2, pr_crc); //johnfitz -- include fitzquake version
|
||||
MSG_WriteString (&client->message,message);
|
||||
|
||||
MSG_WriteByte (&client->message, svc_serverinfo);
|
||||
|
|
Loading…
Reference in New Issue