From dbadee987c7cc2961195fce46bfd0d20a2fc23f9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 14 Dec 2024 22:49:03 +0100 Subject: [PATCH] delet all the hardware sound crap psure it doesent even properly work at this point --- src/Makefile | 73 +- src/d_main.c | 11 - src/doomdef.h | 18 +- src/hardware/hw3dsdrv.h | 85 -- src/hardware/hw3sound.c | 996 ------------- src/hardware/hw3sound.h | 106 -- src/hardware/hws_data.h | 123 -- src/hardware/s_ds3d/s_ds3d.c | 1237 ----------------- src/hardware/s_ds3d/s_ds3d.dev | 59 - src/hardware/s_ds3d/s_ds3d.dsp | 99 -- src/hardware/s_fmod/s_fmod.c | 1201 ---------------- src/hardware/s_fmod/s_fmod.dev | 59 - src/hardware/s_fmod/s_fmod.dsp | 97 -- src/hardware/s_openal/s_openal.c | 998 ------------- src/hardware/s_openal/s_openal.dev | 59 - src/hardware/s_openal/s_openal.dsp | 98 -- src/info.c | 1 - src/info.h | 1 - src/locale/en.po | 30 - src/locale/srb2.pot | 30 - src/p_enemy.c | 4 - src/p_spec.c | 4 - src/p_user.c | 4 - src/s_sound.c | 88 +- src/s_sound.h | 2 - src/sdl/Makefile.cfg | 16 - src/sdl/Srb2SDL.dsp | 29 +- src/sdl/Srb2SDL.dsw | 12 - src/sdl/Srb2SDL.props | 6 +- src/sdl/hwsym_sdl.c | 31 +- src/sdl/macosx/Srb2mac.pbproj/project.pbxproj | 80 +- .../macosx/Srb2mac.xcodeproj/project.pbxproj | 22 - src/sdl/sdl_sound.c | 210 +-- 33 files changed, 37 insertions(+), 5852 deletions(-) delete mode 100644 src/hardware/hw3dsdrv.h delete mode 100644 src/hardware/hw3sound.c delete mode 100644 src/hardware/hw3sound.h delete mode 100644 src/hardware/hws_data.h delete mode 100644 src/hardware/s_ds3d/s_ds3d.c delete mode 100644 src/hardware/s_ds3d/s_ds3d.dev delete mode 100644 src/hardware/s_ds3d/s_ds3d.dsp delete mode 100644 src/hardware/s_fmod/s_fmod.c delete mode 100644 src/hardware/s_fmod/s_fmod.dev delete mode 100644 src/hardware/s_fmod/s_fmod.dsp delete mode 100644 src/hardware/s_openal/s_openal.c delete mode 100644 src/hardware/s_openal/s_openal.dev delete mode 100644 src/hardware/s_openal/s_openal.dsp diff --git a/src/Makefile b/src/Makefile index 1c368b933..e26b696b3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -31,18 +31,6 @@ # compile all HW render and 3D sound DLLs for the set # opengl_dll # Pure Mingw only, compile OpenGL HW render DLL -# minigl_dll -# Pure Mingw only, compile MiniGL HW render DLL -# ds3d_dll -# Pure Mingw only, compile DirectX DirectSound HW sound DLL -# fmod_dll -# Pure Mingw only, compile FMOD HW sound DLL -# openal_dll -# Pure Mingw only, compile OpenAL HW sound DLL -# fmod_so -# Non-Mingw, compile FMOD HW sound SO -# openal_so -# Non-Mingw, compile OpenAL HW sound SO # # # Addon: @@ -69,10 +57,7 @@ # Compile without SDL_Mixer, add 'NOMIXER=1' # Compile without BSD API, add 'NONET=1' # Compile without IPX/SPX, add 'NOIPX=1' -# Compile Mingw/SDL with S_DS3S, add 'DS3D=1' # Compile without libopenmpt, add 'NOOPENMPT=1' -# Compile with S_FMOD3D, add 'FMOD=1' (WIP) -# Compile with S_OPENAL, add 'OPENAL=1' (WIP) # To link with the whole SDL_Image lib to load Icons, add 'SDL_IMAGE=1' but it isn't not realy needed # To link with SDLMain to hide console or make on a console-less binary, add 'SDLMAIN=1' # @@ -701,7 +686,7 @@ else dll : opengl_dll endif ifdef MINGW -all_dll: opengl_dll ds3d_dll fmod_dll openal_dll +all_dll: opengl_dll opengl_dll: $(BIN)/r_opengl.dll $(BIN)/r_opengl.dll: $(OBJDIR)/ogl_win.o $(OBJDIR)/r_opengl.o @@ -711,37 +696,6 @@ $(BIN)/r_opengl.dll: $(OBJDIR)/ogl_win.o $(OBJDIR)/r_opengl.o ifndef NOUPX -$(UPX) $(UPX_OPTS) $@ endif - -ds3d_dll: $(BIN)/s_ds3d.dll -$(BIN)/s_ds3d.dll: $(OBJDIR)/s_ds3d.o - @echo Linking S_DS3d.dll... - $(CC) --shared $^ -o $@ -g -Wl,--add-stdcall-alias -ldsound -luuid - -fmod_dll: $(BIN)/s_fmod.dll -$(BIN)/s_fmod.dll: $(OBJDIR)/s_fmod.o - -$(MKDIR) $(BIN) - @echo Linking S_FMOD.dll... - $(CC) --shared $^ -o $@ -g -Wl,--add-stdcall-alias -lfmod - -openal_dll: $(BIN)/s_openal.dll -$(BIN)/s_openal.dll: $(OBJDIR)/s_openal.o - -$(MKDIR) $(BIN) - @echo Linking S_OpenAL.dll... - $(CC) --shared $^ -o $@ -g -Wl,--add-stdcall-alias -lopenal32 -else -all_dll: fmod_so openal_so - -fmod_so: $(BIN)/s_fmod.so -$(BIN)/s_fmod.so: $(OBJDIR)/s_fmod.o - -$(MKDIR) $(BIN) - @echo Linking S_FMOD.so... - $(CC) --shared $^ -o $@ -g --nostartfiles -lm -lfmod - -openal_so: $(BIN)/s_openal.so -$(BIN)/s_openal.so: $(OBJDIR)/s_openal.o - -$(MKDIR) $(BIN) - @echo Linking S_OpenAL.so... - $(CC) --shared $^ -o $@ -g --nostartfiles -lm -lopenal endif else @@ -851,31 +805,6 @@ $(OBJDIR)/win_dbg.o: win32/win_dbg.c $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ endif -ifdef STATICHS -$(OBJDIR)/s_openal.o: hardware/s_openal/s_openal.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/s_fmod.o: hardware/s_fmod/s_fmod.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -ifdef MINGW -$(OBJDIR)/s_ds3d.o: hardware/s_ds3d/s_ds3d.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ -endif -else - -$(OBJDIR)/s_fmod.o: hardware/s_fmod/s_fmod.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_fmod.o -DHW3SOUND -DUNIXCOMMON -shared -nostartfiles -c hardware/s_fmod/s_fmod.c - -$(OBJDIR)/s_openal.o: hardware/s_openal/s_openal.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_openal.o -DHW3SOUND -DUNIXCOMMON -shared -nostartfiles -c hardware/s_openal/s_openal.c -endif - ifdef FILTERS $(OBJDIR)/%.o: $(INTERFACE)/filter/%.c @echo $< needs deps diff --git a/src/d_main.c b/src/d_main.c index 044fc322b..576901307 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -86,10 +86,6 @@ #include "hardware/hw_main.h" // 3D View Rendering #endif -#ifdef HW3SOUND -#include "hardware/hw3sound.h" -#endif - #ifdef HAVE_DISCORDRPC #include "discord.h" #endif @@ -738,10 +734,6 @@ void D_SRB2Loop(void) interp = R_UsingFrameInterpolation() && !dedicated; doDisplay = false; -#ifdef HW3SOUND - HW3S_BeginFrameUpdate(); -#endif - renderisnewtic = (realtics > 0 || singletics); if (renderisnewtic) @@ -849,9 +841,6 @@ void D_SRB2Loop(void) // consoleplayer -> displayplayers (hear sounds from viewpoint) S_UpdateSounds(); // move positional sounds -#ifdef HW3SOUND - HW3S_EndFrameUpdate(); -#endif LUA_Step(); diff --git a/src/doomdef.h b/src/doomdef.h index 6cfff1483..297128269 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -21,7 +21,6 @@ #define SOUND_DUMMY 0 #define SOUND_SDL 1 #define SOUND_MIXER 2 -#define SOUND_FMOD 3 #ifndef SOUND #ifdef HAVE_SDL @@ -29,9 +28,6 @@ // Use Mixer interface? #ifdef HAVE_MIXER #define SOUND SOUND_MIXER - #ifdef HW3SOUND - #undef HW3SOUND - #endif #endif // Use generic SDL interface. @@ -40,18 +36,8 @@ #endif #else // No SDL. - -// Use FMOD? -#ifdef HAVE_FMOD - #define SOUND SOUND_FMOD - #ifdef HW3SOUND - #undef HW3SOUND - #endif -#else - // No more interfaces. :( - #define SOUND SOUND_DUMMY -#endif - +// No more interfaces. :( +#define SOUND SOUND_DUMMY #endif #endif diff --git a/src/hardware/hw3dsdrv.h b/src/hardware/hw3dsdrv.h deleted file mode 100644 index 8811d4546..000000000 --- a/src/hardware/hw3dsdrv.h +++ /dev/null @@ -1,85 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2001 by DooM Legacy Team. -// -// 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. -// -//----------------------------------------------------------------------------- -/// \file -/// \brief 3D sound import/export prototypes for low-level hardware interface - -#ifndef __HW_3DS_DRV_H__ -#define __HW_3DS_DRV_H__ - -// Use standart hardware API -#include "hw_dll.h" -#include "hws_data.h" - -#if defined (HAVE_SDL) || !defined (HWD) -EXPORT void HWRAPI(Shutdown) (void); -#endif - -// Use standart Init and Shutdown functions - -EXPORT INT32 HWRAPI (Startup) (I_Error_t FatalErrorFunction, snddev_t *snd_dev); -EXPORT u_int HWRAPI (AddSfx) (sfx_data_t *sfx); -EXPORT INT32 HWRAPI (AddSource) (source3D_data_t *src, u_int sfxhandle); -EXPORT INT32 HWRAPI (StartSource) (INT32 handle); -EXPORT void HWRAPI (StopSource) (INT32 handle); -EXPORT INT32 HWRAPI (GetHW3DSVersion) (void); -EXPORT void HWRAPI (BeginFrameUpdate) (void); -EXPORT void HWRAPI (EndFrameUpdate) (void); -EXPORT INT32 HWRAPI (IsPlaying) (INT32 handle); -EXPORT void HWRAPI (UpdateListener) (listener_data_t *data, INT32 num); -EXPORT void HWRAPI (UpdateSourceParms) (INT32 handle, INT32 vol, INT32 sep); -EXPORT void HWRAPI (SetGlobalSfxVolume) (INT32 volume); -EXPORT INT32 HWRAPI (SetCone) (INT32 handle, cone_def_t *cone_def); -EXPORT void HWRAPI (Update3DSource) (INT32 handle, source3D_pos_t *data); -EXPORT INT32 HWRAPI (ReloadSource) (INT32 handle, u_int sfxhandle); -EXPORT void HWRAPI (KillSource) (INT32 handle); -EXPORT void HWRAPI (KillSfx) (u_int sfxhandle); -EXPORT void HWRAPI (GetHW3DSTitle) (char *buf, size_t size); - - -#if !defined (_CREATE_DLL_) - -struct hardware3ds_s -{ - Startup pfnStartup; - AddSfx pfnAddSfx; - AddSource pfnAddSource; - StartSource pfnStartSource; - StopSource pfnStopSource; - GetHW3DSVersion pfnGetHW3DSVersion; - BeginFrameUpdate pfnBeginFrameUpdate; - EndFrameUpdate pfnEndFrameUpdate; - IsPlaying pfnIsPlaying; - UpdateListener pfnUpdateListener; - UpdateSourceParms pfnUpdateSourceParms; - SetGlobalSfxVolume pfnSetGlobalSfxVolume; - SetCone pfnSetCone; - Update3DSource pfnUpdate3DSource; - ReloadSource pfnReloadSource; - KillSource pfnKillSource; - KillSfx pfnKillSfx; - Shutdown pfnShutdown; - GetHW3DSTitle pfnGetHW3DSTitle; -}; - -extern struct hardware3ds_s hw3ds_driver; - -#define HW3DS hw3ds_driver - - -#endif // _CREATE_DLL_ - -#endif // __HW_3DS_DRV_H__ diff --git a/src/hardware/hw3sound.c b/src/hardware/hw3sound.c deleted file mode 100644 index 2594a5df9..000000000 --- a/src/hardware/hw3sound.c +++ /dev/null @@ -1,996 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2001 by DooM Legacy Team. -// -// 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. -//----------------------------------------------------------------------------- -/// \file -/// \brief Hardware 3D sound general code - -#include "../doomdef.h" - -#ifdef HW3SOUND - -#include "../i_sound.h" -#include "../s_sound.h" -#include "../w_wad.h" -#include "../z_zone.h" -#include "../g_game.h" -#include "../tables.h" -#include "../sounds.h" -#include "../r_main.h" -#include "../r_things.h" -#include "../m_random.h" -#include "../p_local.h" -#include "hw3dsdrv.h" -#include "hw3sound.h" - -#define ANGLE2DEG(x) (((double)(x)) / ((double)ANGLE_45/45)) -#define NORM_PITCH 128 -#define NORM_PRIORITY 64 -#define NORM_SEP 128 -#if 1 -#define TPS(x) (x) -#else //Alam_GBC: MPS, not MPF! -#define TPS(x) ((float)(x)/(float)TICRATE) -#endif - -struct hardware3ds_s hw3ds_driver; - - -typedef struct source_s -{ - sfxinfo_t *sfxinfo; - const void *origin; - INT32 handle; // Internal source handle - channel_type_t type; // Sound type (attack, scream, etc) -} source_t; - - -typedef struct ambient_sdata_s -{ - source3D_data_t left; - source3D_data_t right; -} ambient_sdata_t; - - -typedef struct ambient_source_s -{ - source_t left; - source_t right; -} ambient_source_t; - -// Static sources -// This sources always creates -static source_t p_attack_source; // Player attack source -static source_t p_attack_source2; // Player2 attack source -static source_t p_scream_source; // Player scream source -static source_t p_scream_source2; // Player2 scream source - - -static ambient_source_t ambient_source; // Ambinet sound sources - -// abuse??? -//static source3D_data_t p_attack_sdata; // ?? Now just holds precalculated player attack source data -//static source3D_data_t p_default_sdata;// ?? ---- // ---- // ---- // ---- player scream source data - -static ambient_sdata_t ambient_sdata; // Precalculated datas of an ambient sound sources - -// Stack of dynamic sources -static source_t *sources = NULL; // Much like original channels -static INT32 num_sources = 0; - -// Current mode of 3D sound system -// Default is original (stereo) mode -INT32 hws_mode = HWS_DEFAULT_MODE; - -//============================================================================= -void HW3S_SetSourcesNum(void) -{ - INT32 i; - - // Allocating the internal channels for mixing - // (the maximum number of sounds rendered - // simultaneously) within zone memory. - if (sources) - HW3S_StopSounds(); - Z_Free(sources); - - if (cv_numChannels.value <= STATIC_SOURCES_NUM) - I_Error("HW3S_SetSourcesNum: Number of sound sources cannot be less than %d\n", STATIC_SOURCES_NUM + 1); - - num_sources = cv_numChannels.value - STATIC_SOURCES_NUM; - - sources = (source_t *) Z_Malloc(num_sources * sizeof (*sources), PU_STATIC, 0); - - // Free all channels for use - for (i = 0; i < num_sources; i++) - { - sources[i].sfxinfo = NULL; - sources[i].type = CT_NORMAL; - sources[i].handle = -1; - } -} - - -//============================================================================= -static void HW3S_KillSource(INT32 snum) -{ - source_t * s = &sources[snum]; - - if (s->sfxinfo) - { - HW3DS.pfnStopSource(s->handle); - HW3DS.pfnKillSource(s->handle); - s->handle = -1; - s->sfxinfo->usefulness--; - s->origin = NULL; - s->sfxinfo = NULL; - } -} - - -//============================================================================= -/* -static void HW3S_StopSource(INT32 snum) -{ - source_t * s = &sources[snum]; - - if (s->sfxinfo) - { - // stop the sound playing - HW3DS.pfnStopSource(s->handle); - } -} -*/ - - -//============================================================================= -void HW3S_StopSound(void *origin) -{ - INT32 snum; - - for (snum = 0; snum < num_sources; snum++) - { - if (sources[snum].sfxinfo && sources[snum].origin == origin) - { - HW3S_KillSource(snum); - break; - } - } -} - -void HW3S_StopSoundByID(void *origin, sfxenum_t sfx_id) -{ - INT32 snum; - - for (snum = 0; snum < num_sources; snum++) - { - if (sources[snum].sfxinfo == &S_sfx[sfx_id] && sources[snum].origin == origin) - { - HW3S_KillSource(snum); - break; - } - } -} - -void HW3S_StopSoundByNum(sfxenum_t sfxnum) -{ - INT32 snum; - - for (snum = 0; snum < num_sources; snum++) - { - if (sources[snum].sfxinfo == &S_sfx[sfxnum]) - { - HW3S_KillSource(snum); - break; - } - } -} - -//============================================================================= -void HW3S_StopSounds(void) -{ - INT32 snum; - - // kill all playing sounds at start of level - // (trust me - a good idea) - for (snum = 0; snum < num_sources; snum++) - if (sources[snum].sfxinfo) - HW3S_KillSource(snum); - - // Also stop all static sources - HW3DS.pfnStopSource(p_attack_source.handle); - HW3DS.pfnStopSource(p_attack_source2.handle); - HW3DS.pfnStopSource(p_scream_source.handle); - HW3DS.pfnStopSource(p_scream_source2.handle); - HW3DS.pfnStopSource(ambient_source.left.handle); - HW3DS.pfnStopSource(ambient_source.right.handle); -} - - -//============================================================================= -static INT32 HW3S_GetSource(const void *origin, sfxinfo_t *sfxinfo, boolean splitsound) -{ - // - // If none available, return -1. Otherwise source #. - // source number to use - - INT32 snum; - source_t * src; - INT32 sep = NORM_SEP, pitch = NORM_PITCH, volume = 255; - - (void)splitsound; - - // Find an open source - for (snum = 0, src = sources; snum < num_sources; src++, snum++) - { - if (!src->sfxinfo) - break; - -#if 0 - if (origin && src->origin == origin) - { - HW3S_KillSource(snum); - break; - } -#endif - } - -#if 0 - // Check to see if it is audible - if (origin && origin != listenmobj) - { - INT32 rc; - rc = S_AdjustSoundParams(listenmobj, origin, &volume, &sep, &pitch, sfxinfo); - if (!rc) - return -1; - } -#else - (void)origin; - (void)pitch; - (void)volume; - (void)sep; -#endif - - // None available - if (snum == num_sources) - { - // Look for lower priority - for (snum = 0, src = sources; snum < num_sources; src++, snum++) - if (src->sfxinfo->priority <= sfxinfo->priority) - break; - - if (snum == num_sources) - { - // No lower priority. Sorry, Charlie. - return -1; - } - else - { - // Otherwise, kick out lower priority - HW3S_KillSource(snum); - } - } - return snum; -} - - -//============================================================================= -static void HW3S_FillSourceParameters - (const mobj_t *origin, - source3D_data_t *data, - channel_type_t c_type) -{ - fixed_t x = 0, y = 0, z = 0; - - data->max_distance = MAX_DISTANCE; - data->min_distance = MIN_DISTANCE; - - if (origin && origin != players[displayplayers[0]].mo) - { - data->head_relative = false; - - data->pos.momx = TPS(FIXED_TO_FLOAT(origin->momx)); - data->pos.momy = TPS(FIXED_TO_FLOAT(origin->momy)); - data->pos.momz = TPS(FIXED_TO_FLOAT(origin->momz)); - - x = origin->x; - y = origin->y; - z = origin->z; - - if (c_type == CT_ATTACK) - { - const angle_t an = origin->angle >> ANGLETOFINESHIFT; - x += FixedMul(16*FRACUNIT, FINECOSINE(an)); - y += FixedMul(16*FRACUNIT, FINESINE(an)); - z += origin->height >> 1; - } - - else if (c_type == CT_SCREAM) - z += origin->height - (5 * FRACUNIT); - } - else - { - data->head_relative = true; - - data->pos.momx = 0.0f; - data->pos.momy = 0.0f; - data->pos.momz = 0.0f; - } - data->pos.x = FIXED_TO_FLOAT(x); - data->pos.y = FIXED_TO_FLOAT(y); - data->pos.z = FIXED_TO_FLOAT(z); -} - -#define HEADER_SIZE 8 -//============================================================== -/* -static void make_outphase_sfx(void *dest, void *src, INT32 size) -{ - SINT8 *s = (SINT8 *)src + HEADER_SIZE, *d = (SINT8 *)dest + HEADER_SIZE; - - M_Memcpy(dest, src, HEADER_SIZE); - size -= HEADER_SIZE; - - while (size--) - *d++ = -(*s++); -} -*/ - -//INT32 HW3S_Start3DSound(const void *origin, source3D_data_t *source_parm, cone_def_t *cone_parm, channel_type_t channel, INT32 sfx_id, INT32 vol, INT32 pitch); -//============================================================================= -INT32 HW3S_I_StartSound(const void *origin_p, source3D_data_t *source_parm, channel_type_t c_type, sfxenum_t sfx_id, INT32 volume, INT32 pitch, INT32 sep) -{ - sfxinfo_t *sfx; - const mobj_t *origin = (const mobj_t *)origin_p; - source3D_data_t source3d_data; - INT32 s_num = 0; - source_t *source = NULL; - mobj_t *listenmobj = players[displayplayers[0]].mo; // TODO: Kart 4P does not support sounds properly here - mobj_t *listenmobj2 = NULL; - - if (splitscreen) listenmobj2 = players[displayplayers[1]].mo; - - if (sound_disabled) - return -1; - - sfx = &S_sfx[sfx_id]; - - if (sfx->skinsound!=-1 && origin && origin->skin) - { - // it redirect player sound to the sound in the skin table - sfx_id = ((skin_t *)origin->skin)->soundsid[sfx->skinsound]; - sfx = &S_sfx[sfx_id]; - } - - if (!sfx->data) - sfx->data = HW3S_GetSfx(sfx); - - // judgecutor 08-16-2002 - // Sound pitching for both Doom and Heretic -#if 0 - if (cv_rndsoundpitch.value) - { - /*if (gamemode != heretic) - { - if (sfx_id >= sfx_sawup && sfx_id <= sfx_sawhit) - pitch += 8 - (M_RandomByte()&15); - else if (sfx_id != sfx_itemup && sfx_id != sfx_tink) - pitch += 16 - (M_RandomByte()&31); - } - else*/ - pitch = 128 + (M_RandomByte() & 7) - (M_RandomByte() & 7); - } -#endif - - if (pitch < 0) - pitch = NORMAL_PITCH; - - if (pitch > 255) - pitch = 255; - - if (sep < 0) - sep = 128; - - if (splitscreen && listenmobj2) // Copy the sound for the split player - { - if (c_type != CT_NORMAL && origin && (origin == listenmobj2)) - { - if (c_type == CT_ATTACK) - { - if (origin == listenmobj2) - source = &p_attack_source; - else - source = &p_attack_source2; - } - else - { - if (origin == listenmobj2) - source = &p_scream_source; - else - source = &p_scream_source2; - } - - if (source->sfxinfo != sfx) - { - HW3DS.pfnStopSource(source->handle); - source->handle = HW3DS.pfnReloadSource(source->handle, sfx->volume); - //I_OutputMsg("PlayerSound data reloaded\n"); - } - } - else if (c_type == CT_AMBIENT) - { - // sfx_data_t outphased_sfx; - - if (ambient_source.left.sfxinfo != sfx) - { - HW3DS.pfnStopSource(ambient_source.left.handle); - HW3DS.pfnStopSource(ambient_source.right.handle); - - // judgecutor: - // Outphased sfx's temporarily not used!!! - /* - outphased_sfx.data = Z_Malloc(sfx_data.length, PU_STATIC, 0); - make_outphase_sfx(outphased_sfx.data, sfx_data.data, sfx_data.length); - outphased_sfx.length = sfx_data.length; - outphased_sfx.id = sfx_data.id; - */ - ambient_source.left.handle = HW3DS.pfnReloadSource(ambient_source.left.handle, (u_int)sfx->length); - //ambient_source.right.handle = HW3DS.pfnReloadSource(ambient_source.right.handle, &outphased_sfx); - ambient_source.right.handle = HW3DS.pfnReloadSource(ambient_source.right.handle, (u_int)sfx->length); - ambient_source.left.sfxinfo = ambient_source.right.sfxinfo = sfx; - //Z_Free(outphased_sfx.data); - } - - HW3DS.pfnUpdateSourceParms(ambient_source.left.handle, volume, -1); - HW3DS.pfnUpdateSourceParms(ambient_source.right.handle, volume, -1); - - if (sfx->usefulness++ < 0) - sfx->usefulness = -1; - - // Ambient sound is special case - HW3DS.pfnStartSource(ambient_source.left.handle); - HW3DS.pfnStartSource(ambient_source.right.handle); - } - else - { - s_num = HW3S_GetSource(origin, sfx, true); - - if (s_num < 0) - { - //I_OutputMsg("No free source, aborting\n"); - return -1; - } - - source = &sources[s_num]; - - if (origin && c_type == CT_NORMAL) - { - if (!source_parm) - { - source_parm = &source3d_data; - source3d_data.permanent = 0; - HW3S_FillSourceParameters(origin, source_parm, c_type); - } - - source->handle = HW3DS.pfnAddSource(source_parm, (u_int)sfx->length); - } - else - source->handle = HW3DS.pfnAddSource(NULL, (u_int)sfx->length); - } - - // increase the usefulness - if (sfx->usefulness++ < 0) - sfx->usefulness = -1; - - source->sfxinfo = sfx; - source->origin = origin; - HW3DS.pfnStartSource(source->handle); - } - - if (c_type != CT_NORMAL && origin && (origin == listenmobj)) - { - if (c_type == CT_ATTACK) - { - if (origin == listenmobj) - source = &p_attack_source; - else - source = &p_attack_source2; - } - else - { - if (origin == listenmobj) - source = &p_scream_source; - else - source = &p_scream_source2; - } - - if (source->sfxinfo != sfx) - { - HW3DS.pfnStopSource(source->handle); - source->handle = HW3DS.pfnReloadSource(source->handle, sfx->volume); - //I_OutputMsg("PlayerSound data reloaded\n"); - } - } - else if (c_type == CT_AMBIENT) - { -// sfx_data_t outphased_sfx; - - if (ambient_source.left.sfxinfo != sfx) - { - HW3DS.pfnStopSource(ambient_source.left.handle); - HW3DS.pfnStopSource(ambient_source.right.handle); - - // judgecutor: - // Outphased sfx's temporarily not used!!! -/* - outphased_sfx.data = Z_Malloc(sfx_data.length, PU_STATIC, 0); - make_outphase_sfx(outphased_sfx.data, sfx_data.data, sfx_data.length); - outphased_sfx.length = sfx_data.length; - outphased_sfx.id = sfx_data.id; -*/ - ambient_source.left.handle = HW3DS.pfnReloadSource(ambient_source.left.handle, (u_int)sfx->length); - //ambient_source.right.handle = HW3DS.pfnReloadSource(ambient_source.right.handle, &outphased_sfx); - ambient_source.right.handle = HW3DS.pfnReloadSource(ambient_source.right.handle, (u_int)sfx->length); - ambient_source.left.sfxinfo = ambient_source.right.sfxinfo = sfx; - //Z_Free(outphased_sfx.data); - } - - HW3DS.pfnUpdateSourceParms(ambient_source.left.handle, volume, -1); - HW3DS.pfnUpdateSourceParms(ambient_source.right.handle, volume, -1); - - if (sfx->usefulness++ < 0) - sfx->usefulness = -1; - - // Ambient sound is special case - HW3DS.pfnStartSource(ambient_source.left.handle); - HW3DS.pfnStartSource(ambient_source.right.handle); - return -1; - } - else - { - s_num = HW3S_GetSource(origin, sfx, false); - - if (s_num < 0) - { - //I_OutputMsg("No free source, aborting\n"); - return -1; - } - - source = &sources[s_num]; - - if (origin && c_type == CT_NORMAL) - { - if (!source_parm) - { - source_parm = &source3d_data; - source3d_data.permanent = 0; - HW3S_FillSourceParameters(origin, source_parm, c_type); - } - - source->handle = HW3DS.pfnAddSource(source_parm, (u_int)sfx->length); - } - else - source->handle = HW3DS.pfnAddSource(NULL, (u_int)sfx->length); - - } - - // increase the usefulness - if (sfx->usefulness++ < 0) - sfx->usefulness = -1; - - source->sfxinfo = sfx; - source->origin = origin; - HW3DS.pfnStartSource(source->handle); - return s_num; - -} - - -// Start normal sound -//============================================================================= -void HW3S_StartSound(const void *origin, sfxenum_t sfx_id) -{ - HW3S_I_StartSound(origin, NULL, CT_NORMAL, sfx_id, 255, NORMAL_PITCH, NORMAL_SEP); -} - - -//============================================================================= -void S_StartAttackSound(const void *origin, sfxenum_t sfx_id) -{ - if (hws_mode != HWS_DEFAULT_MODE) - HW3S_I_StartSound(origin, NULL, CT_ATTACK, sfx_id, 255, NORMAL_PITCH, NORMAL_SEP); - else - S_StartSound(origin, sfx_id); -} - -void S_StartScreamSound(const void *origin, sfxenum_t sfx_id) -{ - if (hws_mode != HWS_DEFAULT_MODE) - HW3S_I_StartSound(origin, NULL, CT_SCREAM, sfx_id, 255, NORMAL_PITCH, NORMAL_SEP); - else - S_StartSound(origin, sfx_id); -} - -#if 0 /// NOTE: not used -void S_StartAmbientSound(sfxenum_t sfx_id, INT32 volume) -{ - if (hws_mode != HWS_DEFAULT_MODE) - { - volume += 30; - if (volume > 255) - volume = 255; - - HW3S_I_StartSound(NULL, NULL, CT_AMBIENT, sfx_id, volume, NORMAL_PITCH, NORMAL_SEP); - } - else - S_StartSoundAtVolume(NULL, sfx_id, volume); -} -#endif - -FUNCMATH static inline float AmbientPos(angle_t an) -{ - const fixed_t fm = FixedMul(FLOAT_TO_FIXED(MIN_DISTANCE), FINESINE(an>>ANGLETOFINESHIFT)); - return FIXED_TO_FLOAT(fm); -} - - -//============================================================================= -INT32 HW3S_Init(I_Error_t FatalErrorFunction, snddev_t *snd_dev) -{ - INT32 succ; - source3D_data_t source_data; - - if (HW3DS.pfnStartup(FatalErrorFunction, snd_dev)) - { - // Attack source - source_data.head_relative = 1; - source_data.pos.x = 0.0f; - source_data.pos.y = 16.0f; - source_data.pos.z = -FIXED_TO_FLOAT(mobjinfo[MT_PLAYER].height >> 1); - source_data.pos.momx = 0.0f; - source_data.pos.momy = 0.0f; - source_data.pos.momz = 0.0f; - source_data.min_distance = MIN_DISTANCE; - source_data.max_distance = MAX_DISTANCE; - source_data.permanent = 1; - - p_attack_source.sfxinfo = NULL; - - M_Memcpy(&p_attack_source2, &p_attack_source, sizeof (source_t)); - - p_attack_source.handle = HW3DS.pfnAddSource(&source_data, sfx_None); - p_attack_source2.handle = HW3DS.pfnAddSource(&source_data, sfx_None); - - // Scream source - source_data.pos.y = 0; - source_data.pos.z = 0; - - p_scream_source.sfxinfo = NULL; - - M_Memcpy(&p_scream_source2, &p_scream_source, sizeof (source_t)); - - p_scream_source.handle = HW3DS.pfnAddSource(&source_data, sfx_None); - p_scream_source2.handle = HW3DS.pfnAddSource(&source_data, sfx_None); - - //FIXED_TO_FLOAT(mobjinfo[MT_PLAYER].height - (5 * FRACUNIT)); - - // Ambient sources (left and right) at 210 and 330 degree - // relative to listener - memset(&ambient_sdata, 0, sizeof (ambient_sdata)); - - ambient_sdata.left.head_relative = 1; - ambient_sdata.left.pos.x = ambient_sdata.left.pos.y = AmbientPos(ANG210); - ambient_sdata.left.max_distance = MAX_DISTANCE; - ambient_sdata.left.min_distance = MIN_DISTANCE; - - ambient_sdata.left.permanent = 1; - - M_Memcpy(&ambient_sdata.right, &ambient_sdata.left, sizeof (source3D_data_t)); - - ambient_sdata.right.pos.x = -ambient_sdata.left.pos.x; - ambient_source.left.handle = HW3DS.pfnAddSource(&ambient_sdata.left, sfx_None); - ambient_source.right.handle = HW3DS.pfnAddSource(&ambient_sdata.right, sfx_None); - - succ = p_attack_source.handle > -1 && p_scream_source.handle > -1 && - p_attack_source2.handle > -1 && p_scream_source2.handle > -1 && - ambient_source.left.handle > -1 && ambient_source.right.handle > -1; - - //I_OutputMsg("Player handles: attack %d, default %d\n", p_attack_source.handle, p_scream_source.handle); - return succ; - } - return 0; -} - - - - -//============================================================================= -INT32 HW3S_GetVersion(void) -{ - return HW3DS.pfnGetHW3DSVersion(); -} - - -//============================================================================= -void HW3S_BeginFrameUpdate(void) -{ - if (hws_mode != HWS_DEFAULT_MODE) - HW3DS.pfnBeginFrameUpdate(); -} - - -//============================================================================= -void HW3S_EndFrameUpdate(void) -{ - if (hws_mode != HWS_DEFAULT_MODE) - HW3DS.pfnEndFrameUpdate(); -} - - - -//============================================================================= -INT32 HW3S_SoundIsPlaying(INT32 handle) -{ - return HW3DS.pfnIsPlaying(handle); -} - -INT32 HW3S_OriginPlaying(void *origin) -{ - INT32 snum; - - if (!origin) - return 0; - for (snum = 0; snum < num_sources; snum++) - if (sources[snum].origin == origin) - return 1; - return 0; -} - -INT32 HW3S_IdPlaying(sfxenum_t id) -{ - INT32 snum; - for (snum = 0; snum < num_sources; snum++) - if ((size_t)(sources[snum].sfxinfo - S_sfx) == (size_t)id) - return 1; - return 0; -} - -INT32 HW3S_SoundPlaying(void *origin, sfxenum_t id) -{ - INT32 snum; - - if (!origin) - return 0; - - for (snum = 0; snum < num_sources; snum++) - { - if (sources[snum].origin == origin - && (size_t)(sources[snum].sfxinfo - S_sfx) == (size_t)id) - return 1; - } - return 0; -} - -//============================================================================= -static void HW3S_UpdateListener(mobj_t *listener) -{ - listener_data_t data; - - if (!listener || !listener->player) - return; - - if (camera.chase) - { - data.x = FIXED_TO_FLOAT(camera.x); - data.y = FIXED_TO_FLOAT(camera.y); - data.z = FIXED_TO_FLOAT(camera.z + camera.height - (5 * FRACUNIT)); - - data.f_angle = ANGLE2DEG(camera.angle); - data.h_angle = ANGLE2DEG(camera.aiming); - - data.momx = TPS(FIXED_TO_FLOAT(camera.momx)); - data.momy = TPS(FIXED_TO_FLOAT(camera.momy)); - data.momz = TPS(FIXED_TO_FLOAT(camera.momz)); - } - else - { - data.x = FIXED_TO_FLOAT(listener->x); - data.y = FIXED_TO_FLOAT(listener->y); - data.z = FIXED_TO_FLOAT(listener->z + listener->height - (5 * FRACUNIT)); - - data.f_angle = ANGLE2DEG(listener->angle); - data.h_angle = ANGLE2DEG(listener->player->aiming); - - data.momx = TPS(FIXED_TO_FLOAT(listener->momx)); - data.momy = TPS(FIXED_TO_FLOAT(listener->momy)); - data.momz = TPS(FIXED_TO_FLOAT(listener->momz)); - } - HW3DS.pfnUpdateListener(&data, 1); -} - -static void HW3S_UpdateListener2(mobj_t *listener) -{ - listener_data_t data; - - if (!listener || !listener->player) - { - HW3DS.pfnUpdateListener(NULL, 2); - return; - } - - if (camera2.chase) - { - data.x = FIXED_TO_FLOAT(camera2.x); - data.y = FIXED_TO_FLOAT(camera2.y); - data.z = FIXED_TO_FLOAT(camera2.z + camera2.height - (5 * FRACUNIT)); - - data.f_angle = ANGLE2DEG(camera2.angle); - data.h_angle = ANGLE2DEG(camera2.aiming); - - data.momx = TPS(FIXED_TO_FLOAT(camera2.momx)); - data.momy = TPS(FIXED_TO_FLOAT(camera2.momy)); - data.momz = TPS(FIXED_TO_FLOAT(camera2.momz)); - } - else - { - data.x = FIXED_TO_FLOAT(listener->x); - data.y = FIXED_TO_FLOAT(listener->y); - data.z = FIXED_TO_FLOAT(listener->z + listener->height - (5 * FRACUNIT)); - - data.f_angle = ANGLE2DEG(listener->angle); - data.h_angle = ANGLE2DEG(listener->player->aiming); - - data.momx = TPS(FIXED_TO_FLOAT(listener->momx)); - data.momy = TPS(FIXED_TO_FLOAT(listener->momy)); - data.momz = TPS(FIXED_TO_FLOAT(listener->momz)); - } - - HW3DS.pfnUpdateListener(&data, 2); -} - -void HW3S_SetSfxVolume(INT32 volume) -{ - HW3DS.pfnSetGlobalSfxVolume(volume); -} - - -static void HW3S_Update3DSource(source_t *src) -{ - source3D_data_t data; - data.permanent = 0; - HW3S_FillSourceParameters(src->origin, &data, src->type); - HW3DS.pfnUpdate3DSource(src->handle, &data.pos); - -} - -void HW3S_UpdateSources(void) -{ - mobj_t *listener = players[displayplayers[0]].mo; - mobj_t *listener2 = NULL; - source_t *src; - INT32 audible, snum, volume, sep, pitch; - - if (splitscreen) listener2 = players[displayplayers[1]].mo; - - HW3S_UpdateListener2(listener2); - HW3S_UpdateListener(listener); - - for (snum = 0, src = sources; snum < num_sources; src++, snum++) - { - if (src->sfxinfo) - { -#if 0 - if (HW3DS.pfnIsPlaying(src->handle)) - { - if (src->origin) - { - // initialize parameters - volume = 255; // 8 bits internal volume precision - pitch = NORM_PITCH; - sep = NORM_SEP; - - // check non-local sounds for distance clipping - // or modify their params - if (src->origin && listener != src->origin && !(listener2 && src->origin == listener2)) - { - INT32 audible2; - INT32 volume2 = volume, sep2 = sep, pitch2 = pitch; - audible = S_AdjustSoundParams(listener, src->origin, &volume, &sep, &pitch, - src->sfxinfo); - - if (listener2) - { - audible2 = S_AdjustSoundParams(listener2, - src->origin, &volume2, &sep2, &pitch2, src->sfxinfo); - if (audible2 && (!audible || (audible && volume2 > volume))) - { - audible = true; - volume = volume2; - sep = sep2; - pitch = pitch2; - } - } - - if (audible) - HW3S_Update3DSource(src); // Update positional sources - else - HW3S_KillSource(snum); //Kill it! - } - } - } - else - { - // Source allocated but stopped. Kill. - HW3S_KillSource(snum); - } -#else - if (src->origin && listener != src->origin && !(listener2 && src->origin == listener2)) - HW3S_Update3DSource(src); // Update positional sources - (void)pitch; - (void)sep; - (void)volume; - (void)audible; -#endif - } - } -} - -void HW3S_Shutdown(void) -{ - HW3DS.pfnShutdown(); -} - -void *HW3S_GetSfx(sfxinfo_t *sfx) -{ - sfx_data_t sfx_data; - - if (sfx->lumpnum == LUMPERROR) - sfx->lumpnum = S_GetSfxLumpNum (sfx); - - sfx_data.length = W_LumpLength(sfx->lumpnum); - sfx_data.data = Z_Malloc(sfx_data.length, PU_SOUND, &sfx->data); - W_ReadLump(sfx->lumpnum, sfx_data.data); - sfx_data.priority = sfx->priority; - - sfx->length = HW3DS.pfnAddSfx(&sfx_data); - - Z_ChangeTag(sfx->data, PU_CACHE); - - return sfx_data.data; -} - -void HW3S_FreeSfx(sfxinfo_t *sfx) -{ - INT32 snum; - - for (snum = 0; snum < num_sources; snum++) - { - if (sources[snum].sfxinfo == sfx) - { - HW3S_KillSource(snum); - break; - } - } - - if (sfx->length > 0) - HW3DS.pfnKillSfx((u_int)sfx->length); - sfx->length = 0; - - sfx->lumpnum = LUMPERROR; - - Z_Free(sfx->data); - sfx->data = NULL; -} - -#endif diff --git a/src/hardware/hw3sound.h b/src/hardware/hw3sound.h deleted file mode 100644 index a8a475b69..000000000 --- a/src/hardware/hw3sound.h +++ /dev/null @@ -1,106 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2001 by DooM Legacy Team. -// -// 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. -// -//----------------------------------------------------------------------------- -/// \file -/// \brief High-level functions of hardware 3D sound - -#ifndef __HW3_SOUND_H__ -#define __HW3_SOUND_H__ - -#ifdef HW3SOUND -#include "hws_data.h" -//#include "../s_sound.h" -//#include "../p_mobj.h" - -// Default sound mode (original stereo mode) -enum -{ - HWS_DEFAULT_MODE = 0, - HWS_DS3D, - HWS_OTHER, - HWS_FMOD3D, - HWS_OPENAL, -}; - -typedef enum -{ - CT_NORMAL = 0, - CT_ATTACK, - CT_SCREAM, - CT_AMBIENT, -} channel_type_t; - -extern INT32 hws_mode; // Current sound mode - -#if defined (HW3DS) || defined (DOXYGEN) -INT32 HW3S_Init(I_Error_t FatalErrorFunction, snddev_t *snd_dev); -#endif -void HW3S_Shutdown(void); -INT32 HW3S_GetVersion(void); - -// Common case - start 3D or 2D source -void HW3S_StartSound(const void *origin, sfxenum_t sfx_id); - -// Special cases of 3D sources -void S_StartAmbientSound(sfxenum_t sfx_id, INT32 volume); -void S_StartAttackSound(const void *origin, sfxenum_t sfx_id); -void S_StartScreamSound(const void *origin, sfxenum_t sfx_id); - -// Starts 3D sound with specified parameters -// origin - for object movement tracking. NULL are possible value (no movement tracking) -// source_parm - 3D source parameters (position etc.) -// cone_parm - 3D source cone parameters. NULL are possible value (default cone will be used) -// channel - -// sfx_id - sfx id -// vol - sound volume -// pitch - sound pitching value -// Returns: - sound id -INT32 HW3S_I_StartSound(const void *origin, source3D_data_t *source_parm, channel_type_t channel, sfxenum_t sfx_id, INT32 vol, INT32 pitch, INT32 sep); -void HW3S_StopSoundByID(void *origin, sfxenum_t sfx_id); -void HW3S_StopSoundByNum(sfxenum_t sfxnum); -void HW3S_StopSound(void *origin); -void HW3S_StopSounds(void); - -void HW3S_BeginFrameUpdate(void); -void HW3S_EndFrameUpdate(void); - -void HW3S_UpdateSources(void); - -void HW3S_SetSfxVolume(INT32 volume); - -// Utility functions -INT32 HW3S_SoundIsPlaying(INT32 handle); -void HW3S_SetSourcesNum(void); - -INT32 HW3S_OriginPlaying(void *origin); -INT32 HW3S_IdPlaying(sfxenum_t id); -INT32 HW3S_SoundPlaying(void *origin, sfxenum_t id); - -void *HW3S_GetSfx(sfxinfo_t *sfx); -void HW3S_FreeSfx(sfxinfo_t *sfx); - -#else // HW3SOUND - -//#define S_StartAmbientSound(i,v) S_StartSoundAtVolume(NULL, i, v) -#define S_StartAttackSound S_StartSound -#define S_StartScreamSound S_StartSound - -#endif // HW3SOUND - -INT32 S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, - INT32 *vol, INT32 *sep, INT32 *pitch, sfxinfo_t *sfxinfo); - -#endif // __HW3_SOUND_H__ diff --git a/src/hardware/hws_data.h b/src/hardware/hws_data.h deleted file mode 100644 index b890d976b..000000000 --- a/src/hardware/hws_data.h +++ /dev/null @@ -1,123 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2005 by SRB2 Jr. Team. -// -// 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. -//----------------------------------------------------------------------------- -/// \file -/// \brief 3D sound definitions - -#ifndef __HWS_DATA_H__ -#define __HWS_DATA_H__ - -#define NORMAL_SEP 128 - -// abuse? -#define STATIC_SOURCES_NUM 6 // Total number of static sources - -#define MIN_DISTANCE 160.0f -#define MAX_DISTANCE 1200.0f - -typedef struct source_pos_s -{ - double x; - double y; - double z; -} source_pos_t; - -typedef struct source3D_pos_s -{ - float x; - float y; - float z; - //float angle; - float momx; - float momy; - float momz; - -} source3D_pos_t; - - -enum {NORMAL_PITCH = 128}; - -/*typedef struct source2D_data_s -{ - INT32 volume; - INT32 sep; - -} source2D_data_t;*/ - - -// General 3D sound source description -typedef struct source3D_data_s -{ - float min_distance; // - float max_distance; // - INT32 head_relative; // - INT32 permanent; // - source3D_pos_t pos; // source position in 3D - -} source3D_data_t; - - -// Sound data -typedef struct sfx_data_s -{ - size_t length; - void *data; - INT32 priority; - INT32 sep; // Only when source is 2D sound -} sfx_data_t; - - -// Sound cone (for 3D sources) -typedef struct cone_def_s -{ - float inner; - float outer; - INT32 outer_gain; - /*float f_angle; - float h_angle;*/ -} cone_def_t; - - -typedef struct listener_data_s -{ - // Listener position - double x; - double y; - double z; - - // Listener front and head orientation (degrees) - double f_angle; - double h_angle; - - // Listener momentums - double momx; - double momy; - double momz; -} listener_data_t; - -typedef struct snddev_s -{ - INT32 sample_rate; - INT32 bps; - size_t numsfxs; - -// Windows specific data -#ifdef _WIN32 - UINT32 cooplevel; - HWND hWnd; -#endif -} snddev_t; - -#endif //__HWS_DATA_H__ diff --git a/src/hardware/s_ds3d/s_ds3d.c b/src/hardware/s_ds3d/s_ds3d.c deleted file mode 100644 index 5299c1795..000000000 --- a/src/hardware/s_ds3d/s_ds3d.c +++ /dev/null @@ -1,1237 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2001 by DooM Legacy Team. -// -// 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. -//----------------------------------------------------------------------------- -/// \file -/// \brief General driver for 3D sound system -/// -/// Implementend via DirectSound3D API - -#define INITGUID -//#define WIN32_LEAN_AND_MEAN -#define RPC_NO_WINDOWS_H -#include -#include -#define DIRECTSOUND_VERSION 0x0700 /* version 7.0 */ - -#ifdef __MINGW32__ -#define NONAMELESSUNION -#endif -#include - -#if (defined (DIRECTSOUND_VERSION) && (DIRECTSOUND_VERSION >= 0x0700)) -#define DX7 //Enable DX7 or up only code -#undef DUMMYUNIONNAMEN -#endif - -#ifdef __MINGW32__ -//#undef DX7 -#endif - -#define _CREATE_DLL_ -#include "../hw3dsdrv.h" -#include "../../m_fixed.h" -#include "../../doomdef.h" -//#define VERSIONSTRING "v1.08" - -#undef DEBUG_TO_FILE -#define DEBUG_TO_FILE - -#if defined ( HAVE_SDL ) && !defined ( LOGMESSAGES ) -#undef DEBUG_TO_FILE -#endif - - -// Internal sound stack -typedef struct stack_snd_s -{ - // Sound data - LPDIRECTSOUNDBUFFER dsbuffer; - - // 3D data of 3D source - LPDIRECTSOUND3DBUFFER dsbuffer3D; // 3D data - - // Current parameters of 3D source - // Valid only when source is 3D source - // (dsbuffer3D is not NULL) - DS3DBUFFER parameters; - - // Currently unused - INT32 sfx_id; - - // Currently unused - INT32 LRU; - - // Flag of static source - // Driver does not manage intrenally such sources - INT32 permanent; - -} stack_t; - -// Just for now... -#define SOUND_ALLOCATE_DELTA 16 // Amount of sources per stack incrementation -#define MAX_LRU 16 // Maximum iterations to keep source in stack - -static stack_t *_stack; // Sound stack -static INT32 allocated_sounds; // Size of stack - -static INT32 srate; // Default sample rate - - -// output all debugging messages to this file -#if defined (DEBUG_TO_FILE) -#include -FILE *logstream = NULL; -#endif - -static LPDIRECTSOUND DSnd = NULL; // Main DirectSound object -static LPDIRECTSOUNDBUFFER PrimaryBuffer = NULL; // -static LPDIRECTSOUND3DLISTENER Listener = NULL; // - -static DS3DLISTENER listener_parms; // Listener papameters - -#ifdef DX7 -static BOOL virtualization; // TRUE if HRTF virtualization enabled -#endif - -static DWORD update_mode; // Current update mode of listener -//static DWORD max_3d_buffers; - -static I_Error_t I_ErrorDS3D = NULL; - -//static stack_snd_t sound_stack[MAX_SOUNDS]; - -// Safe buffer release -#define RELEASE_BUFFER(buf) {if (buf) { IDirectSoundBuffer_Release(buf); (buf) = NULL; }} -#define RELEASE_3DBUFFER(buf) {if (buf) { IDirectSound3DBuffer_Release(buf); (buf) = NULL; }} - -// Default flags for buffers -#define _2DSOURCE_FLAGS (DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_STICKYFOCUS | DSBCAPS_STATIC | DSBCAPS_CTRLFREQUENCY) -#define _3DSOURCE_FLAGS (DSBCAPS_CTRL3D | DSBCAPS_STATIC | DSBCAPS_MUTE3DATMAXDISTANCE | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY) - - -enum {IS_2DSOURCE = 0, IS_3DSOURCE = 1}; - -#define NEW_HANDLE -1 - -#ifdef _WINDOWS -BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module - DWORD fdwReason, // reason for calling function - LPVOID lpvReserved) // reserved -{ - // Perform actions based on the reason for calling - UNREFERENCED_PARAMETER(lpvReserved); - switch ( fdwReason ) - { - case DLL_PROCESS_ATTACH: - // Initialize once for each new process. - // Return FALSE to fail DLL load. -#ifdef DEBUG_TO_FILE - logstream = fopen("s_ds3d.log", "wt"); - if (logstream == NULL) - return FALSE; -#endif - DisableThreadLibraryCalls(hinstDLL); - break; - - case DLL_THREAD_ATTACH: - // Do thread-specific initialization. - break; - - case DLL_THREAD_DETACH: - // Do thread-specific cleanup. - break; - - case DLL_PROCESS_DETACH: - // Perform any necessary cleanup. -#ifdef DEBUG_TO_FILE - if (logstream) - { - fclose(logstream); - logstream = NULL; - } -#endif - break; - } - return TRUE; // Successful DLL_PROCESS_ATTACH. -} -#endif - -// ************************************************************************** -// FUNCTIONS -// ************************************************************************** - -/*************************************************************** - * - * DBG_Printf - * Output error messages to debug log if DEBUG_TO_FILE is defined, - * else do nothing - * - *************************************************************** - */ -// -----------------+ -// DBG_Printf : Output error messages to debug log if DEBUG_TO_FILE is defined, -// : else do nothing -// Returns : -// -----------------+ -void DBG_Printf(const char *lpFmt, ... ) -{ -#ifdef DEBUG_TO_FILE - char str[4096] = ""; - va_list arglist; - - va_start(arglist, lpFmt); - vsnprintf(str, 4096, lpFmt, arglist); - va_end(arglist); - - if (logstream) - fwrite(str, strlen(str), 1, logstream); -#endif -} - - -/*************************************************************** - * - * Grow intrenal sound stack by SOUND_ALLOCATE_DELTA amount - * - *************************************************************** - */ -static BOOL reallocate_stack(void) -{ - stack_t *new_stack; - - if (_stack) - new_stack = realloc(_stack, sizeof (stack_t) * (allocated_sounds + SOUND_ALLOCATE_DELTA)); - else - new_stack = malloc(sizeof (stack_t) * (allocated_sounds + SOUND_ALLOCATE_DELTA)); - if (new_stack) - { - _stack = new_stack; - ZeroMemory(&_stack[allocated_sounds], SOUND_ALLOCATE_DELTA * sizeof (stack_t)); - allocated_sounds += SOUND_ALLOCATE_DELTA; - } - return (new_stack != NULL); -} - - -/*************************************************************** - * - * Destroys source in stack - * - *************************************************************** - */ -static void kill_sound(stack_t *snd) -{ - //stack_t *snd = _stack + handle; - - if (snd->dsbuffer3D) - RELEASE_3DBUFFER(snd->dsbuffer3D); - - if (snd->dsbuffer) - RELEASE_BUFFER(snd->dsbuffer); - - ZeroMemory(snd, sizeof (stack_t)); -} - - -/*************************************************************** - * - * Returns TRUE if source currently playing - * - *************************************************************** - */ -static BOOL is_playing(stack_t *snd) -{ - DWORD status; - LPDIRECTSOUNDBUFFER dsbuffer = snd->dsbuffer; - - if (dsbuffer == NULL) - return 0; - - IDirectSoundBuffer_GetStatus(dsbuffer, &status); - - return (status & (DSBSTATUS_PLAYING | DSBSTATUS_LOOPING)); -} - - -/*************************************************************** - * - * Creates DirectSound buffer and fills with sound data - * NULL sound data pointer are valid (empty buffer - * will be created) - * - *************************************************************** - */ -static LPDIRECTSOUNDBUFFER create_buffer (void *data, INT32 length, BOOL as3d) -{ - LPDIRECTSOUNDBUFFER dsbuffer; - HRESULT hr; - WAVEFORMATEX wfm; - DSBUFFERDESC dsbdesc; - LPVOID lpvAudio1; // receives address of lock start - DWORD dwBytes1; // receives number of bytes locked - LPVOID lpvAudio2; // receives address of lock start - DWORD dwBytes2; // receives number of bytes locked - - ZeroMemory(&wfm, sizeof (WAVEFORMATEX)); - wfm.wFormatTag = WAVE_FORMAT_PCM; - wfm.nChannels = 1; - wfm.nSamplesPerSec = data?*((UINT16 *)data+1):srate; //mostly 11025, but some at 22050. - wfm.wBitsPerSample = 8; - wfm.nBlockAlign = (WORD)(wfm.wBitsPerSample / 8 * wfm.nChannels); - wfm.nAvgBytesPerSec = wfm.nSamplesPerSec * wfm.nBlockAlign; - - // Set up DSBUFFERDESC structure. - ZeroMemory (&dsbdesc, sizeof (DSBUFFERDESC) ); - dsbdesc.dwSize = sizeof (DSBUFFERDESC); - dsbdesc.dwFlags = as3d?_3DSOURCE_FLAGS:_2DSOURCE_FLAGS; - dsbdesc.dwBufferBytes = length; - dsbdesc.lpwfxFormat = &wfm; - - // DirectX 7.0 and above! - // Try to enable full HRTF virtualization algorithm for - // two-speakers or headphones -#ifdef DX7 - if (as3d) - dsbdesc.guid3DAlgorithm = (virtualization?DS3DALG_HRTF_FULL:DS3DALG_DEFAULT); -#endif - - hr = IDirectSound_CreateSoundBuffer (DSnd, &dsbdesc, &dsbuffer, NULL); - - // CreateSoundBuffer might return DS_NO_VIRTUALIZATION so uses FAILED - // macro rather than check explictly for DS_OK value - if (FAILED(hr)) - { - DBG_Printf("CreateSoundBuffer FAILED. Code %d\n", hr); - return NULL; - } - - if (data) - { - hr = IDirectSoundBuffer_Lock(dsbuffer, 0, length, &lpvAudio1, &dwBytes1, &lpvAudio2, &dwBytes2, 0); - - // If DSERR_BUFFERLOST is returned, restore and retry lock. - if (hr == DSERR_BUFFERLOST) - { - hr = IDirectSoundBuffer_Restore(dsbuffer); - if (FAILED(hr)) - I_ErrorDS3D("Restore fail on %x, code %d\n",dsbuffer, hr); - hr = IDirectSoundBuffer_Lock(dsbuffer, 0, length, &lpvAudio1, &dwBytes1, &lpvAudio2, &dwBytes2, 0); - if (FAILED(hr)) - I_ErrorDS3D("Lock fail(2) on %x, code %d\n",dsbuffer, hr); - } - else - if (FAILED(hr)) - I_ErrorDS3D("Lock fail(1) on %x, code %d\n",dsbuffer, hr); - - // copy wave data into the buffer (note: dwBytes1 should equal to dsbdesc->dwBufferBytes ...) - CopyMemory (lpvAudio1, (LPBYTE)data+8, dwBytes1); - - if ( dwBytes2 && lpvAudio2) - CopyMemory(lpvAudio2, ((LPBYTE)data + 8) + dwBytes1, dwBytes2); - - - // finally, unlock the buffer - hr = IDirectSoundBuffer_Unlock(dsbuffer, lpvAudio1, dwBytes1, lpvAudio2, dwBytes2); - - if (FAILED(hr)) - I_ErrorDS3D("Unlock fail on %x, code %d\n",dsbuffer, hr); - } - - return dsbuffer; -} - - -/*************************************************************** - * - * Creates 3D source data buffer - * - *************************************************************** - */ -static LPDIRECTSOUND3DBUFFER create_3dbuffer(LPDIRECTSOUNDBUFFER dsbuffer, LPDIRECTSOUND3DBUFFER source3d) -{ - HRESULT hr; - - hr = IDirectSoundBuffer_QueryInterface(dsbuffer, - &IID_IDirectSound3DBuffer, (void **)&source3d); - - if (FAILED(hr)) - { - DBG_Printf("Couldn't obtain 3D Buffer interface. Code %d\n", hr); - return NULL; - } -#ifdef DX7 - if (hr == DS_NO_VIRTUALIZATION) - { - DBG_Printf("The 3D virtualization is not supported under this OS.\n"); - virtualization = FALSE; - } -#endif - return source3d; -} - - -/*************************************************************** - * - * Returns free (unused) source stack slot - * If none available sound stack will be increased - * - *************************************************************** - */ -static INT32 find_handle(INT32 new_sfx_id, INT32 new_is3d) -{ - INT32 free_sfx; - stack_t *snd; - - // At first do look for sound with same sfx ID and reuse it - new_sfx_id = new_is3d = 0; - for (free_sfx = 0, snd = _stack; free_sfx < allocated_sounds; snd++, free_sfx++) - { - - if (snd->permanent) - continue; -/* - if (!is_playing(snd)) - { - if (same_sfx == 0 && snd->sfx_id == new_sfx_id && snd->dsbuffer) - { - same_sfx = i; - continue; - } - - if (snd->sfx_id && ++snd->LRU >= MAX_LRU) - kill_sound(snd); - } -*/ - if (snd->dsbuffer == 0) - break; - //free_sfx = i; - } - - // No suitable resource found so increase sound stack - if (free_sfx == allocated_sounds) - { - DBG_Printf("No free or same sfx found so increase stack (currently %d srcs)\n", allocated_sounds); - free_sfx = reallocate_stack() ? free_sfx : -1; - } - - return free_sfx; -} - - -/*************************************************************** - * - * Recalculates volume from Doom scale to DirectSound scale - * - *************************************************************** - */ -static INT32 recalc_volume(INT32 base_vol, INT32 steps) -{ - return (base_vol * ((DSBVOLUME_MAX-DSBVOLUME_MIN)/4)) / steps - + (DSBVOLUME_MAX - ((DSBVOLUME_MAX-DSBVOLUME_MIN)/4)); -} - - -/*************************************************************** - * - * Updates sound volume of the DirectSound buffer - * - *************************************************************** - */ -static void UpdateSoundVolume (LPDIRECTSOUNDBUFFER lpSnd, INT32 volume) -{ - /*volume = (volume * ((DSBVOLUME_MAX-DSBVOLUME_MIN)/4)) / 256 + - (DSBVOLUME_MAX - ((DSBVOLUME_MAX-DSBVOLUME_MIN)/4)); - - IDirectSoundBuffer_SetVolume (lpSnd, volume);*/ - IDirectSoundBuffer_SetVolume (lpSnd, recalc_volume(volume, 256)); -} - - -// -------------------------------------------------------------------------- -// Update the panning for a secondary buffer, make sure it was created with -// DSBCAPS_CTRLPAN -// -------------------------------------------------------------------------- -#define DSBPAN_RANGE (DSBPAN_RIGHT-(DSBPAN_LEFT)) - -//Doom sounds pan range 0-255 (128 is centre) -#define SEP_RANGE 256 -static void Update2DSoundPanning (LPDIRECTSOUNDBUFFER lpSnd, INT32 sep) -{ - HRESULT hr; - hr = IDirectSoundBuffer_SetPan (lpSnd, (sep * DSBPAN_RANGE)/SEP_RANGE - DSBPAN_RIGHT); - //if (FAILED(hr)) - // DEBFILE(va("SetPan FAILED for sep %d pan %d\n", sep, (sep * DSBPAN_RANGE)/SEP_RANGE - DSBPAN_RIGHT)); -} - - - -/****************************************************************************** - * - * Initialise driver and listener - * - *****************************************************************************/ -EXPORT BOOL HWRAPI( Startup ) (I_Error_t FatalErrorFunction, snddev_t *snd_dev) -{ - HRESULT hr; - DSBUFFERDESC desc; - WAVEFORMATEX wfm; - DSCAPS dscaps; - DWORD speakers; - DWORD speaker_config; - DWORD speaker_geometry; - - I_ErrorDS3D = FatalErrorFunction; - DBG_Printf ("S_DS3D Init(): DirectSound3D driver for SRB2 v1.09"); // Tails - - DBG_Printf("Initialising DirectSound3D...\n"); - hr = DirectSoundCreate( NULL, &DSnd, NULL); - if (FAILED(hr)) - { - DBG_Printf("Failed to obtain DirectSound\n"); - return FALSE; - } - - hr = IDirectSound_SetCooperativeLevel(DSnd, snd_dev->hWnd, snd_dev->cooplevel); - if (FAILED(hr)) - { - DBG_Printf("Couldn't set coopertive level\n"); - return FALSE; - } - - dscaps.dwSize = sizeof (DSCAPS); - - IDirectSound_GetCaps(DSnd, &dscaps); - IDirectSound_GetSpeakerConfig(DSnd, &speakers); - - DBG_Printf("Sound hardware capabilities:\n"); - DBG_Printf(" Driver is %scertified.\n", (dscaps.dwFlags & DSCAPS_CERTIFIED) == DSCAPS_CERTIFIED?"":"not "); - DBG_Printf(" Maximum hardware mixing buffers %d\n", dscaps.dwMaxHwMixingAllBuffers); - DBG_Printf(" Maximum hardware 3D buffers %d\n", dscaps.dwFreeHw3DAllBuffers); - - speaker_config = DSSPEAKER_CONFIG(speakers); - speaker_geometry = DSSPEAKER_GEOMETRY(speakers); - - DBG_Printf("Current speaker configuration: "); - - switch (speaker_config) - { -#ifdef DX7 - case DSSPEAKER_5POINT1: - DBG_Printf("5.1 (5 speakers with subwoofer).\n"); - break; -#endif - case DSSPEAKER_HEADPHONE: - DBG_Printf("headphone.\n"); - break; - - case DSSPEAKER_MONO: - DBG_Printf("single speaker (mono).\n"); - break; - - case DSSPEAKER_QUAD: - DBG_Printf("quadrophonic\n"); - break; - - case DSSPEAKER_SURROUND: - DBG_Printf("surround.\n"); - break; - - case DSSPEAKER_STEREO: - DBG_Printf("stereo with %s geometry ", - speaker_geometry == DSSPEAKER_GEOMETRY_WIDE - ? "wide (arc of 20 deg.)" - : speaker_geometry == DSSPEAKER_GEOMETRY_NARROW - ? "narrow (arc of 10 deg.)" - : speaker_geometry == DSSPEAKER_GEOMETRY_MIN - ? "min (arc of 5 deg.)" - : speaker_geometry == DSSPEAKER_GEOMETRY_MAX - ? "max (arc of 180 deg.)" - : "unknown"); - break; - default: - DBG_Printf("undetectable.\n"); - - } - - update_mode = DS3D_IMMEDIATE; - - // Create primary sound buffer - ZeroMemory(&desc, sizeof (DSBUFFERDESC)); - desc.dwSize = sizeof (DSBUFFERDESC); - desc.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME; - desc.dwBufferBytes = 0; - desc.lpwfxFormat = NULL; - - hr = IDirectSound_CreateSoundBuffer(DSnd, &desc, &PrimaryBuffer, NULL); - if (FAILED(hr)) - { - DBG_Printf("CreateSoundBuffer FAILED (ErrNo %d)\n", hr); - return FALSE; - } - - // Query for 3D Listener object - hr = IDirectSoundBuffer_QueryInterface(PrimaryBuffer, - &IID_IDirectSound3DListener, (void **)&Listener); - - if (FAILED(hr)) - { - DBG_Printf("Couldn't obtain 3D Listener interface (ErrNo %d)\n", hr); - return FALSE; - } - - // Set up initial listsner parameters - IDirectSound3DListener_SetDistanceFactor(Listener, 1.0f/72.0f, DS3D_IMMEDIATE); - IDirectSound3DListener_SetRolloffFactor(Listener, 1.6f, DS3D_IMMEDIATE); - //IDirectSound3DListener_SetRolloffFactor(Listener, DS3D_MAXROLLOFFFACTOR, DS3D_IMMEDIATE); - listener_parms.dwSize = sizeof (DS3DLISTENER); - IDirectSound3DListener_GetAllParameters(Listener, &listener_parms); - - ZeroMemory (&wfm, sizeof (WAVEFORMATEX)); - wfm.wFormatTag = WAVE_FORMAT_PCM; - wfm.nChannels = 2; - wfm.nSamplesPerSec = srate = snd_dev->sample_rate; - wfm.wBitsPerSample = (WORD)snd_dev->bps; - wfm.nBlockAlign = (WORD)(wfm.wBitsPerSample / 8 * wfm.nChannels); - wfm.nAvgBytesPerSec = wfm.nSamplesPerSec * wfm.nBlockAlign; - - if (snd_dev->cooplevel >= DSSCL_PRIORITY) - { - hr = IDirectSoundBuffer_SetFormat(PrimaryBuffer, &wfm); - if (FAILED(hr)) - DBG_Printf("Couldn't set primary buffer format.\n"); - - DBG_Printf(" Compacting onboard sound-memory..."); - hr = IDirectSound_Compact(DSnd); - DBG_Printf(" %s\n", SUCCEEDED(hr) ? M_GetText("Done\n") : M_GetText("Failed\n")); - } - -#ifdef DX7 - // Initially enables HRTF virtualization (may be changed later) - virtualization = TRUE; -#endif - - _stack = NULL; - allocated_sounds = 0; - IDirectSoundBuffer_Play(PrimaryBuffer, 0, 0, DSBPLAY_LOOPING); - return reallocate_stack(); -} - - - -/*************************************************************** - * - * Shutdown driver - * - *************************************************************** - */ -EXPORT void HWRAPI( Shutdown ) (void) -{ - INT32 i; - - DBG_Printf ("S_DS3D Shutdown()\n"); - - for (i = 0; i < allocated_sounds; i++) - { - StopSource(i); - kill_sound(_stack + i); - } - - if (_stack) - free(_stack); - - if (Listener) - { - IDirectSound3DListener_Release(Listener); - Listener = NULL; - } - - if (PrimaryBuffer) - RELEASE_BUFFER(PrimaryBuffer); - - if (DSnd) - { - IDirectSound_Release(DSnd); - DSnd = NULL; - } - -} - - - -EXPORT INT32 HWRAPI (IsPlaying) (INT32 handle) -{ - if (handle < 0 || handle >= allocated_sounds) - return FALSE; - - return is_playing(_stack + handle); -} - - -// Calculate sound pitching -static float recalc_pitch(INT32 doom_pitch) -{ - return doom_pitch < NORMAL_PITCH ? - (float)(doom_pitch + NORMAL_PITCH) / (NORMAL_PITCH * 2) - :(float)doom_pitch / (float)NORMAL_PITCH; -} - - -static stack_t *setup_source(INT32 handle, sfx_data_t *sfx, BOOL is_3dsource) -{ - stack_t *snd; - //INT32 handle; - INT32 data_length; - LPDIRECTSOUNDBUFFER dsbuffer = NULL; - LPDIRECTSOUND3DBUFFER ds3dbuffer = NULL; - - if (handle == NEW_HANDLE) - handle = find_handle(sfx?sfx->id:0, is_3dsource); - - snd = _stack + handle; - - // Check for reused source - if (snd->dsbuffer) - return snd; - - data_length = sfx?sfx->length - 8:DSBSIZE_MIN; - - dsbuffer = create_buffer(sfx ? sfx->data : NULL, data_length, is_3dsource); - if (dsbuffer) - { - - if (is_3dsource) - { - ds3dbuffer = create_3dbuffer(dsbuffer, ds3dbuffer); - if (!ds3dbuffer) - { - RELEASE_BUFFER(dsbuffer); - return NULL; - } - snd->parameters.dwSize = sizeof (DS3DBUFFER); - IDirectSound3DBuffer_GetAllParameters(ds3dbuffer, &snd->parameters); - } - - // judgecutor: sound pitching - if (sfx) - { - DWORD freq; - - freq = (DWORD)((float)(*((UINT16 *)sfx->data+1)) * recalc_pitch(sfx->pitch)); - IDirectSoundBuffer_SetFrequency(dsbuffer, freq); - } - - snd->dsbuffer = dsbuffer; - snd->dsbuffer3D = ds3dbuffer; - snd->LRU = 0; - snd->sfx_id = sfx ? sfx->id : 0; - if (!is_3dsource) - snd->permanent = 0; - return snd; - } - return NULL; - -} - -/****************************************************************************** - * - * Creates 2D (stereo) source - * - ******************************************************************************/ -EXPORT INT32 HWRAPI ( Add2DSource ) (sfx_data_t *sfx) -{ - stack_t *snd; - - if (!sfx) - return -1; - - snd = setup_source(NEW_HANDLE, sfx, IS_2DSOURCE); - if (snd) - { - UpdateSoundVolume(snd->dsbuffer, sfx->volume); - Update2DSoundPanning(snd->dsbuffer, sfx->sep); - } - return snd - _stack; -} - -/****************************************************************************** - * - * Creates 3D source - * - ******************************************************************************/ - -EXPORT INT32 HWRAPI ( Add3DSource ) (source3D_data_t *src, sfx_data_t *sfx) -{ - stack_t *snd; - - snd = setup_source(NEW_HANDLE, sfx, IS_3DSOURCE); - - if (snd) - { - - /*x = src->pos.x; - y = src->pos.z; - z = src->pos.y; - - IDirectSound3DBuffer_SetPosition(source, x, y, z, update_mode); - IDirectSound3DBuffer_SetVelocity(source, src->pos.momx, src->pos.momz, src->pos.momy, update_mode); - IDirectSound3DBuffer_SetMode(source, src->head_relative?DS3DMODE_HEADRELATIVE:DS3DMODE_NORMAL, update_mode);*/ - -#ifdef DUMMYUNIONNAMEN - snd->parameters.vPosition.DUMMYUNIONNAMEN(9).x = src->pos.x; - snd->parameters.vPosition.DUMMYUNIONNAMEN(10).y = src->pos.z; - snd->parameters.vPosition.DUMMYUNIONNAMEN(11).z = src->pos.y; - - snd->parameters.vVelocity.DUMMYUNIONNAMEN(9).x = src->pos.momx; - snd->parameters.vVelocity.DUMMYUNIONNAMEN(10).y = src->pos.momz; - snd->parameters.vVelocity.DUMMYUNIONNAMEN(11).z = src->pos.momy; -#else - snd->parameters.vPosition.x = src->pos.x; - snd->parameters.vPosition.y = src->pos.z; - snd->parameters.vPosition.z = src->pos.y; - - snd->parameters.vVelocity.x = src->pos.momx; - snd->parameters.vVelocity.y = src->pos.momz; - snd->parameters.vVelocity.z = src->pos.momy; -#endif - snd->parameters.dwMode = src->head_relative ? DS3DMODE_HEADRELATIVE : DS3DMODE_NORMAL; - - snd->parameters.flMinDistance = src->min_distance; - snd->parameters.flMaxDistance = src->max_distance; - //snd->parameters.flMaxDistance = DS3D_DEFAULTMAXDISTANCE; - - snd->permanent = src->permanent; - - UpdateSoundVolume(snd->dsbuffer, sfx?sfx->volume:255); - IDirectSound3DBuffer_SetAllParameters(snd->dsbuffer3D, &snd->parameters, DS3D_IMMEDIATE); - IDirectSoundBuffer_SetCurrentPosition(snd->dsbuffer, 0); - } - - return (snd - _stack); -} - -/****************************************************************************** - * - * Destroy source and remove it from stack if it is a 2D source. - * Otherwise put source into cache - * - *****************************************************************************/ -EXPORT void HWRAPI (KillSource) (INT32 handle) -{ - - if (handle < 0 || handle >= allocated_sounds) - return; -/* - if (_stack[handle].dsbuffer3D) - { - // It's a 3D source so let him chance to be reused :-) - _stack[handle].LRU = 1; - } - else - { */ - // No, it is a 2D source so kill him - kill_sound(_stack + handle); - //} -} - - -/****************************************************************************** - * - * Update volume and separation (panning) of 2D source - * - *****************************************************************************/ -EXPORT void HWRAPI (Update2DSoundParms) (INT32 handle, INT32 vol, INT32 sep) -{ - LPDIRECTSOUNDBUFFER dsbuffer; - - if (handle < 0 || handle >= allocated_sounds) - return; - - if ((_stack+handle)->dsbuffer3D) - return; - dsbuffer = (_stack + handle)->dsbuffer; - - UpdateSoundVolume(dsbuffer, vol); - Update2DSoundPanning(dsbuffer, sep); -} - - - -// -------------------------------------------------------------------------- -// Set the global volume for sound effects -// -------------------------------------------------------------------------- -EXPORT void HWRAPI (SetGlobalSfxVolume) (INT32 volume) -{ - INT32 vol; - HRESULT hr; - - // use the last quarter of volume range - if (volume) - vol = recalc_volume(volume, 31); - else - vol = DSBVOLUME_MIN; - - hr = IDirectSoundBuffer_SetVolume (PrimaryBuffer, vol); -} - -EXPORT void HWRAPI ( StopSource) (INT32 handle) -{ - LPDIRECTSOUNDBUFFER dsbuffer; - - if (handle < 0 || handle >= allocated_sounds) - return; - - dsbuffer = (_stack + handle)->dsbuffer; - - if (dsbuffer) - { - IDirectSoundBuffer_Stop(dsbuffer); - IDirectSoundBuffer_SetCurrentPosition(dsbuffer, 0); - } -} - - -EXPORT INT32 HWRAPI ( GetHW3DSVersion) (void) -{ - return VERSION; -} - - -EXPORT void HWRAPI (BeginFrameUpdate) (void) -{ - update_mode = DS3D_DEFERRED; -} - - -EXPORT void HWRAPI (EndFrameUpdate) (void) -{ - if (update_mode == DS3D_DEFERRED) - IDirectSound3DListener_CommitDeferredSettings(Listener); - - update_mode = DS3D_IMMEDIATE; -} - - -/****************************************************************************** - * UpdateListener - * - * Set up main listener properties: - * - position - * - orientation - * - velocity - *****************************************************************************/ -EXPORT void HWRAPI (UpdateListener) (listener_data_t *data) -{ - D3DVECTOR pos; - D3DVECTOR face; - D3DVECTOR head; - D3DVECTOR velocity; - double f_angle; - //double h_angle, t_angle; - //double f_cos, f_sin, t_sin; - -#ifdef DUMMYUNIONNAMEN - pos.DUMMYUNIONNAMEN(9).x = (D3DVALUE)data->x; - pos.DUMMYUNIONNAMEN(10).y = (D3DVALUE)data->z; - pos.DUMMYUNIONNAMEN(11).z = (D3DVALUE)data->y; - - velocity.DUMMYUNIONNAMEN(9).x = (D3DVALUE)data->momx; - velocity.DUMMYUNIONNAMEN(10).y = (D3DVALUE)data->momz; - velocity.DUMMYUNIONNAMEN(11).z = (D3DVALUE)data->momy; -#else - pos.x = (D3DVALUE)data->x; - pos.y = (D3DVALUE)data->z; - pos.z = (D3DVALUE)data->y; - - velocity.x = (D3DVALUE)data->momx; - velocity.y = (D3DVALUE)data->momz; - velocity.z = (D3DVALUE)data->momy; -#endif - f_angle = (data->f_angle) / 180 * M_PI; - //h_angle = data->h_angle / 180 * M_PI; - //h_angle = 90 / 180 * M_PI; - - // Treat listener orientation angles as spherical coordinates. - // x = sin h * cos f - // y = sin h * sin f - // z = cos h - - // Front vector - //t_angle = (M_PI/2 - h_angle); - //t_angle = M_PI/2; - - //face.x = (t_sin = sin(t_angle)) * (f_cos = cos(f_angle)); - //face.z = t_sin * (f_sin = sin(f_angle)); - //face.y = cos(t_angle); -#ifdef DUMMYUNIONNAMEN - face.DUMMYUNIONNAMEN(9).x = (D3DVALUE)cos(f_angle); - face.DUMMYUNIONNAMEN(11).z = (D3DVALUE)sin(f_angle); - face.DUMMYUNIONNAMEN(10).y = 0.0f; - - head.DUMMYUNIONNAMEN(9).x = 0.0f; - head.DUMMYUNIONNAMEN(10).y = 1.0f; - head.DUMMYUNIONNAMEN(11).z = 0.0f; -#else - face.x = (D3DVALUE)cos(f_angle); - face.z = (D3DVALUE)sin(f_angle); - face.y = 0.0f; - - head.x = 0.0f; - head.y = 1.0f; - head.z = 0.0f; -#endif - // Top vector - //h_angle = (-data->h_angle) / 180 * M_PI; - -/* - t_angle = -h_angle; - - head.z = (t_sin = sin(t_angle)) * f_cos; - head.x = t_sin * f_sin; - head.y = cos(t_angle); -*/ - - // Update at once - CopyMemory(&listener_parms.vPosition, &pos, sizeof (D3DVECTOR)); - CopyMemory(&listener_parms.vOrientFront, &face, sizeof (D3DVECTOR)); - CopyMemory(&listener_parms.vOrientTop, &head, sizeof (D3DVECTOR)); - CopyMemory(&listener_parms.vVelocity, &velocity, sizeof (D3DVECTOR)); - //IDirectSound3DListener_SetAllParameters(Listener, &listener_parms, DS3D_IMMEDIATE); - IDirectSound3DListener_SetAllParameters(Listener, &listener_parms, update_mode); -} - -EXPORT void HWRAPI (UpdateListener2) (listener_data_t *data) -{ - D3DVECTOR pos; - D3DVECTOR face; - D3DVECTOR head; - D3DVECTOR velocity; - double f_angle; - //double h_angle, t_angle; - //double f_cos, f_sin, t_sin; - - if (!data) return; - -#ifdef DUMMYUNIONNAMEN - pos.DUMMYUNIONNAMEN(9).x = (D3DVALUE)data->x; - pos.DUMMYUNIONNAMEN(10).y = (D3DVALUE)data->z; - pos.DUMMYUNIONNAMEN(11).z = (D3DVALUE)data->y; - - velocity.DUMMYUNIONNAMEN(9).x = (D3DVALUE)data->momx; - velocity.DUMMYUNIONNAMEN(10).y = (D3DVALUE)data->momz; - velocity.DUMMYUNIONNAMEN(11).z = (D3DVALUE)data->momy; -#else - pos.x = (D3DVALUE)data->x; - pos.y = (D3DVALUE)data->z; - pos.z = (D3DVALUE)data->y; - - velocity.x = (D3DVALUE)data->momx; - velocity.y = (D3DVALUE)data->momz; - velocity.z = (D3DVALUE)data->momy; -#endif - f_angle = (data->f_angle) / 180 * M_PI; - //h_angle = data->h_angle / 180 * M_PI; - //h_angle = 90 / 180 * M_PI; - - // Treat listener orientation angles as spherical coordinates. - // x = sin h * cos f - // y = sin h * sin f - // z = cos h - - // Front vector - //t_angle = (M_PI/2 - h_angle); - //t_angle = M_PI/2; - - //face.x = (t_sin = sin(t_angle)) * (f_cos = cos(f_angle)); - //face.z = t_sin * (f_sin = sin(f_angle)); - //face.y = cos(t_angle); -#ifdef DUMMYUNIONNAMEN - face.DUMMYUNIONNAMEN(9).x = cos(f_angle); - face.DUMMYUNIONNAMEN(11).z = sin(f_angle); - face.DUMMYUNIONNAMEN(10).y = 0.0f; - - head.DUMMYUNIONNAMEN(9).x = 0.0f; - head.DUMMYUNIONNAMEN(10).y = 1.0f; - head.DUMMYUNIONNAMEN(11).z = 0.0f; -#else - face.x = (D3DVALUE)cos(f_angle); - face.z = (D3DVALUE)sin(f_angle); - face.y = 0.0f; - - head.x = 0.0f; - head.y = 1.0f; - head.z = 0.0f; -#endif - - // Top vector - //h_angle = (-data->h_angle) / 180 * M_PI; - -/* - t_angle = -h_angle; - - head.z = (t_sin = sin(t_angle)) * f_cos; - head.x = t_sin * f_sin; - head.y = cos(t_angle); -*/ - - // Update at once - CopyMemory(&listener_parms.vPosition, &pos, sizeof (D3DVECTOR)); - CopyMemory(&listener_parms.vOrientFront, &face, sizeof (D3DVECTOR)); - CopyMemory(&listener_parms.vOrientTop, &head, sizeof (D3DVECTOR)); - CopyMemory(&listener_parms.vVelocity, &velocity, sizeof (D3DVECTOR)); - //IDirectSound3DListener_SetAllParameters(Listener, &listener_parms, DS3D_IMMEDIATE); - //Alam_GBC: 2 Listeners? - //IDirectSound3DListener_SetAllParameters(Listener, &listener_parms, update_mode); -} - -EXPORT INT32 HWRAPI (SetCone) (INT32 handle, cone_def_t *cone_def) -{ - stack_t *snd; - //DS3DBUFFER parms; - - if (handle < 0 || handle >= allocated_sounds) - return -1; - - snd = _stack + handle; - - if (snd->dsbuffer3D) - { - - /*f_angle = cone_def->f_angle / 180 * M_PI; - h_angle = (90 - cone_def->h_angle) / 180 * M_PI; - parms.vConeOrientation.x = sin(h_angle) * cos(f_angle); - parms.vConeOrientation.z = sin(h_angle) * sin(f_angle); - parms.vConeOrientation.y = cos(h_angle);*/ - - snd->parameters.dwInsideConeAngle = (DWORD)cone_def->inner; - snd->parameters.dwOutsideConeAngle = (DWORD)cone_def->outer; - snd->parameters.lConeOutsideVolume = recalc_volume(cone_def->outer_gain, 256); - - return IDirectSound3DBuffer_SetAllParameters(snd->dsbuffer3D, &snd->parameters, update_mode); - } - - return -1; -} - -EXPORT void HWRAPI (Update3DSource) (INT32 handle, source3D_pos_t *data) -{ - stack_t *snd; - - if (handle < 0 || handle >= allocated_sounds) - return; - - snd = _stack + handle; - if (snd->dsbuffer3D) - { - - /*parms.dwSize = sizeof (DS3DBUFFER); - IDirectSound3DBuffer_GetAllParameters(snd, &parms);*/ - - //angle = data->angle * 180 / M_PI; - -#ifdef DUMMYUNIONNAMEN - snd->parameters.vPosition.DUMMYUNIONNAMEN(9).x = data->x; - snd->parameters.vPosition.DUMMYUNIONNAMEN(10).y = data->z; - snd->parameters.vPosition.DUMMYUNIONNAMEN(11).z = data->y; -#else - snd->parameters.vPosition.x = data->x; - snd->parameters.vPosition.y = data->z; - snd->parameters.vPosition.z = data->y; -#endif - - /*parms.vConeOrientation.x = cos(angle); - parms.vConeOrientation.z = sin(angle); - parms.vConeOrientation.y = 0;*/ - -#ifdef DUMMYUNIONNAMEN - snd->parameters.vVelocity.x = data->momx; - snd->parameters.vVelocity.y = data->momz; - snd->parameters.vVelocity.z = data->momy; -#else - snd->parameters.vVelocity.x = data->momx; - snd->parameters.vVelocity.y = data->momz; - snd->parameters.vVelocity.z = data->momy; -#endif - - //snd->parameters.flMinDistance = data->min_distance; - //snd->parameters.flMaxDistance = data->max_distance; - //snd->parameters.dwMode = pos->head_realtive?DS3DMODE_HEADREALTIVE:DS3DMODE_NORMAL; - - IDirectSound3DBuffer_SetAllParameters(snd->dsbuffer3D, &snd->parameters, update_mode); - } -} - - -EXPORT INT32 HWRAPI (StartSource) (INT32 handle) -{ - LPDIRECTSOUNDBUFFER snd; - - if (handle < 0 || handle >= allocated_sounds) - return -1; - - snd = (_stack + handle)->dsbuffer; - IDirectSoundBuffer_SetCurrentPosition(snd, 0); - return IDirectSoundBuffer_Play(snd, 0, 0, 0); - -} - -//------------------------------------------------------------- -// Load new sound data into source -//------------------------------------------------------------- -EXPORT INT32 HWRAPI (Reload3DSource) (INT32 handle, sfx_data_t *data) -{ - DS3DBUFFER temp; - stack_t *snd; - INT32 perm; - - // DirectX could not load new sound data into source - // so recreate sound buffers - if (handle < 0 || handle >= allocated_sounds) - return -1; - - snd = _stack + handle; - CopyMemory(&temp, &snd->parameters, sizeof (DS3DBUFFER)); - perm = snd->permanent; - - kill_sound(snd); - - snd = setup_source(handle, data, IS_3DSOURCE); - /*snd->dsbuffer = create_buffer(data->data, data->length, true); - if (snd->dsbuffer == NULL) - return -1; - snd->dsbuffer3D = create_3dbuffer(snd->dsbuffer, snd->dsbuffer3D); - if (snd->dsbuffer3D == NULL) - { - RELEASE_BUFFER(snd->dsbuffer); - return -1; - } - - snd->sfx_id = data->id; - snd->LRU = 0;*/ - if (snd) - { - snd->permanent = perm; - IDirectSound3DBuffer_SetAllParameters(snd->dsbuffer3D, &temp, DS3D_IMMEDIATE); - CopyMemory(&snd->parameters, &temp, sizeof (DS3DBUFFER)); - } - - return(snd - _stack); -} - -EXPORT void HWRAPI (UpdateSourceVolume) (INT32 handle, INT32 volume) -{ - if (handle < 0 || handle >= allocated_sounds) - return; - UpdateSoundVolume((_stack + handle)->dsbuffer, volume); -} diff --git a/src/hardware/s_ds3d/s_ds3d.dev b/src/hardware/s_ds3d/s_ds3d.dev deleted file mode 100644 index 1b51b1b77..000000000 --- a/src/hardware/s_ds3d/s_ds3d.dev +++ /dev/null @@ -1,59 +0,0 @@ -[Project] -FileName=s_ds3d.dev -Name=s_ds3d -Ver=1 -IsCpp=1 -Type=3 -Compiler=-D_M_IX86=500_@@_-Wall_@@_-D_WINDOWS_@@_-Os_@@_-fno-strict-aliasing_@@_-fomit-frame-pointer_@@_ -CppCompiler= -Includes= -Linker=--def ../s_mingw.def_@@_-luuid_@@_-ldsound_@@_ -Libs= -UnitCount=1 -Folders= -ObjFiles= -PrivateResource= -ResourceIncludes= -MakeIncludes= -Icon= -ExeOutput=C:\srb2demo2 -ObjectOutput=..\..\..\objs\Mingw\s_ds3d -OverrideOutput=1 -OverrideOutputName=s_ds3d.dll -HostApplication= -CommandLine= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=00000000000000000111d0 -UseCustomMakefile=0 -CustomMakefile= - -[Unit1] -FileName=s_ds3d.c -Folder= -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion=0.1 -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename=s_ds3d.exe -ProductName=s_ds3d -ProductVersion=0.1 -AutoIncBuildNr=0 - diff --git a/src/hardware/s_ds3d/s_ds3d.dsp b/src/hardware/s_ds3d/s_ds3d.dsp deleted file mode 100644 index a82207c97..000000000 --- a/src/hardware/s_ds3d/s_ds3d.dsp +++ /dev/null @@ -1,99 +0,0 @@ -# Microsoft Developer Studio Project File - Name="s_ds3d" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=s_ds3d - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "s_ds3d.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "s_ds3d.mak" CFG="s_ds3d - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "s_ds3d - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "s_ds3d - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "s_ds3d - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\..\..\bin\VC\Release\s_ds3d" -# PROP Intermediate_Dir "..\..\..\objs\VC\Release\s_ds3d" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "S_DS3D_EXPORTS" /YX /FD /c -# ADD CPP /nologo /G5 /MT /W3 /GX /Zi /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "__WIN32__" /D "__MSC__" /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x419 /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 dsound.lib /nologo /dll /pdb:"..\..\..\bin\VC\Release\s_ds3d.pdb" /machine:I386 /out:"..\..\..\bin\VC\Release\s_ds3d.dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "s_ds3d - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\..\..\bin\VC\Debug\s_ds3d" -# PROP Intermediate_Dir "..\..\..\objs\VC\Debug\s_ds3d" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "S_DS3D_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WIN32__" /D "__MSC__" /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -# ADD BASE RSC /l 0x419 /d "_DEBUG" -# ADD RSC /l 0x40c /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 dsound.lib /nologo /dll /pdb:"..\..\..\bin\VC\Debug\s_ds3d.pdb" /debug /machine:I386 /out:"..\..\..\bin\VC\Debug\s_ds3d.dll" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none /incremental:no /nodefaultlib - -!ENDIF - -# Begin Target - -# Name "s_ds3d - Win32 Release" -# Name "s_ds3d - Win32 Debug" -# Begin Source File - -SOURCE=.\s_ds3d.c -# End Source File -# End Target -# End Project diff --git a/src/hardware/s_fmod/s_fmod.c b/src/hardware/s_fmod/s_fmod.c deleted file mode 100644 index 5d4422bb1..000000000 --- a/src/hardware/s_fmod/s_fmod.c +++ /dev/null @@ -1,1201 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2001 by DooM Legacy Team. -// -// 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. -// -//----------------------------------------------------------------------------- -/// \file -/// \brief General driver for 3D sound system -/// -/// Implementend via FMOD_SOUND API - -#ifdef _WINDOWS -//#define WIN32_LEAN_AND_MEAN -#define RPC_NO_WINDOWS_H -#include -#else -#include -#include -#include -#include -#include -#endif - -#include -FILE *logstream = NULL; - -#ifdef __MINGW32__ -#include -#else -#include -#endif - -#ifdef FSOUND_INIT_DONTLATENCYADJUST //Alam: why didn't I think about this before? :) -#define FSOUND_Sample_Load(index,data,mode,length) FSOUND_Sample_Load(index,data,mode,0,length) -#else -#define OLDFMOD //Alam: Yea! -#endif - -#ifdef __MINGW32__ -#include -#else -#include /* optional */ -#endif - -#define MAXCHANNEL 1024 - -#undef DEBUG_TO_FILE -#if defined ( HAVE_SDL ) && !defined ( LOGMESSAGES ) -#define DEBUG_TO_FILE -#endif - -#ifndef MORESTUFF -//#define MORESTUFF -#define REL2D -#endif - -#define _CREATE_DLL_ -#include "../../doomdef.h" -#include "../hw3dsdrv.h" -#define INT2CHAR(p) (char *)p + 8 - -//Doom sound sample format -#define FSOUND_UNORMAL (FSOUND_8BITS | FSOUND_MONO | FSOUND_UNSIGNED) -//Load Raw -#define FSOUND_RAWLOAD (FSOUND_LOADRAW | FSOUND_LOADMEMORY) -//Load Sample Raw from pointer -#define FSOUND_DOOMLOAD (FSOUND_UNORMAL | FSOUND_RAWLOAD) -//length of SFX -#define SFXLENGTH (sfx->length-8) - -//SRB2 treats +X as east, +Y as north, +Z as up. -//FSOUND treats +X as right, +Y as up, and +Z as forwards. -//So SRB2's XZY is FSOUND's XYZ -//And FSOUND's XZY is SRB2's XYZ - -static I_Error_t I_ErrorFMOD = NULL; - -static FSOUND_SAMPLE *blankfmsample = NULL; - -// Calculate sound pitching -static float recalc_pitch(INT32 doom_pitch) -{ -#ifdef MORESTUFF - return (float)1; -#else - return doom_pitch < NORMAL_PITCH ? - (float)(doom_pitch + NORMAL_PITCH) / (NORMAL_PITCH * 2) - :(float)doom_pitch / (float)NORMAL_PITCH; -#endif -} - -/*************************************************************** - * - * DBG_Printf - * Output error messages to debug log if DEBUG_TO_FILE is defined, - * else do nothing - * - ************************************************************** - */ -// -----------------+ -// DBG_Printf : Output error messages to debug log if DEBUG_TO_FILE is defined, -// : else do nothing -// Returns : -// -----------------+ -FUNCPRINTF void DBG_Printf(const char *lpFmt, ...) -{ -#ifdef DEBUG_TO_FILE - char str[4096] = ""; - va_list arglist; - - va_start(arglist, lpFmt); - vsnprintf(str, 4096, lpFmt, arglist); - va_end(arglist); - - if (logstream) - fwrite(str, strlen(str), 1, logstream); -#endif -} - -// Start of head_relative system for FMOD3D - -typedef struct rellistener_s -{ - float pos[3]; - INT32 active; - float vel[3]; - -} rellistener_s_t; //Easy - -static rellistener_s_t rellistener[2]; //The 2 listeners - -typedef struct relarray_s -{ - INT32 handle; // handle number - INT32 chan; // real channel - INT32 listener; // for which listener - rellistener_s_t pos; // source position in 3D -} relarray_s_t; - -static relarray_s_t relarray[STATIC_SOURCES_NUM+1]; // array of chans - - -//set listener -static void relset(INT32 which) -{ - INT32 i; - - if (which == -2 || which == -1) - { - which = -which; - - memset(&rellistener[which-1], 0, sizeof (rellistener_s_t)); //Delete me - for (i = 0; i <= STATIC_SOURCES_NUM; i++) - { - if (relarray[i].pos.active && relarray[i].listener == which) - { - FSOUND_SetPaused(relarray[i].chan,true); - relarray[i].pos.active = false; - } - } - return; - } - else if (which == 1 || which ==2) - { - float pos[3], vel[3]; // Temp bin - which -= 1; //Hello! - - //Get update - FSOUND_3D_Listener_GetAttributes(&pos[0],&vel[0],NULL,NULL,NULL,NULL,NULL,NULL); - memcpy(&rellistener[which].pos[0],&pos[0],sizeof (pos)); - memcpy(&rellistener[which].vel[0],&vel[0],sizeof (vel)); - - if (!rellistener[which].active) - for (i = 0; i <= STATIC_SOURCES_NUM; i++) - { - if (!relarray[i].pos.active && relarray[i].listener == which) - { - FSOUND_SetPaused(relarray[i].chan,false); - relarray[i].pos.active = true; - } - } - - rellistener[which].active = which; - } - else - { - memset(&rellistener[0], 0, sizeof (rellistener_s_t)); - memset(&rellistener[1], 0, sizeof (rellistener_s_t)); - } -} - -//setup system -static void relsetup() -{ - INT32 i; - - // Setup the rel array for use - for (i = 0; i <= STATIC_SOURCES_NUM; i++) - { - relarray[i].handle = FSOUND_FREE; - relarray[i].chan = FSOUND_FREE; - relarray[i].listener = (i == 1 || i == 3)?2:1; - memset(&relarray[i].pos, 0, sizeof (rellistener_s_t)); - } - - // Set up the Listener array - relset(0); -} - - -//checkup for stack -static INT32 relstack(INT32 chan) -{ - INT32 i; - - for (i = 0; i <= STATIC_SOURCES_NUM; i++) - { - if (relarray[i].pos.active && relarray[i].handle == chan) - return i; - } - return -1; -} - -//checkup for fake rel chan -static INT32 relcheckup(INT32 chan) -{ - INT32 i = relstack(chan); - - if (i == -1) - return chan; - else - return relarray[i].chan; -} - - //Update place rel chan's vol -static void relvol(INT32 chan) -{ - INT32 vol = FSOUND_GetVolume(chan); - INT32 error = FSOUND_GetError(); - - if (chan == relcheckup(chan)) - return; - - if (!vol && error) - DBG_Printf("FMOD(relvol, FSOUND_GetVolume, Channel # %i): %s\n",chan,FMOD_ErrorString(error)); - else if (!FSOUND_SetVolume(relcheckup(chan), vol)) - DBG_Printf("FMOD(relvol, FSOUND_SetVolume, Channel # %i): %s\n",chan,FMOD_ErrorString(FSOUND_GetError())); -} - -//Copy rel chan -static INT32 relcopy(INT32 handle) -{ - FSOUND_SAMPLE *fmsample = NULL; - INT32 chan = -1; - float pos[3]; - float vel[3]; - - if (!FSOUND_3D_GetAttributes(handle,&pos[0],&vel[0])) - if (FSOUND_GetError() != FMOD_ERR_NONE) DBG_Printf("FMOD(relcopy, FSOUND_3D_GetAttributes, Channel # %i): %s\n",handle,FMOD_ErrorString(FSOUND_GetError())); - - fmsample = FSOUND_GetCurrentSample(handle); - - if (fmsample) - { -#ifdef REL2D - if (!FSOUND_Sample_SetMode(fmsample, FSOUND_2D)) - DBG_Printf("FMOD(relcopy, FSOUND_Sample_SetMode, handle# %i): %s\n",handle,FMOD_ErrorString(FSOUND_GetError())); -#endif - chan = FSOUND_PlaySoundEx(FSOUND_FREE,fmsample,NULL,true); - - if (chan == -1) - { - if (FSOUND_GetError() != FMOD_ERR_NONE) DBG_Printf("FMOD(relcopy, FSOUND_PlaySoundEx, handle# %i): %s\n",handle,FMOD_ErrorString(FSOUND_GetError())); - return FSOUND_FREE; - } -#ifdef MORESTUFF - else - DBG_Printf("FMOD(relcopy, Main): Copy Handle#%i to channel#%i\n",handle,chan); -#endif - } - else - { - if (FSOUND_GetError() != FMOD_ERR_NONE) - DBG_Printf("FMOD(relcopy, FSOUND_GetCurrentSample, handle# %i): %s\n",handle,FMOD_ErrorString(FSOUND_GetError())); - chan = FSOUND_PlaySoundEx(FSOUND_FREE,blankfmsample,NULL,true); - //return FSOUND_FREE; - } - - if (FSOUND_GetCurrentSample(chan)) - { - - if (!FSOUND_SetCurrentPosition(chan, 0)) - DBG_Printf("FMOD(relcopy, FSOUND_SetCurrentPosition, handle#%i, channel# %i): %s\n",handle,chan,FMOD_ErrorString(FSOUND_GetError())); -#ifndef REL2D - if (!FSOUND_3D_SetAttributes(chan,pos,vel)) - DBG_Printf("FMOD(relcopy, FSOUND_3D_SetAttributes, handle#%i, channel#%i): %s\n",handle,chan,FMOD_ErrorString(FSOUND_GetError())); -#endif -/* - if (!FSOUND_SetReserved(chan, TURE)) - DBG_Printf("FMOD(relcopy, FSOUND_SetReserved, handle#%i, channel# %i): %s\n",handle,chan,FMOD_ErrorString(FSOUND_GetError())); -*/ - return chan; - } - - return FSOUND_FREE; -} - -//update the rel chans -static void relupdate(INT32 handle) -{ - if (handle == FSOUND_FREE) - { - INT32 stack; - - for (stack = 0; stack <= STATIC_SOURCES_NUM;stack++) - { - //if (FSOUND_GetCurrentSample(relarray[stack].handle)) - // relarray[stack].chan = relcopy(relarray[stack].handle); - - if (relarray[stack].chan != FSOUND_FREE) - { - relarray[stack].pos.active = false; - relupdate(relarray[stack].chan); - } - else - relarray[stack].pos.active = false; - } - } - else if (handle == relcheckup(handle)) - return; -#ifndef REL2D - else - { - float pos[3], vel[3]; - INT32 stack = relstack(handle); - INT32 chan = relcheckup(handle); - INT32 which = relarray[stack].listener; - - pos[0] = relarray[stack].pos.pos[0] + rellistener[which].pos[0]; - pos[1] = relarray[stack].pos.pos[1] + rellistener[which].pos[1]; - pos[2] = relarray[stack].pos.pos[2] + rellistener[which].pos[2]; - vel[0] = relarray[stack].pos.vel[0] + rellistener[which].vel[0]; - vel[1] = relarray[stack].pos.vel[1] + rellistener[which].vel[1]; - vel[2] = relarray[stack].pos.vel[2] + rellistener[which].vel[2]; - - if (!FSOUND_3D_SetAttributes(chan,pos,vel)) - DBG_Printf("FMOD(relupdate, FSOUND_3D_SetAttributes, Handle #%i,Channel #%i): %s\n",handle, chan,FMOD_ErrorString(FSOUND_GetError())); - } -#endif -} - - //Update place rel chan's pos -static void relplace(INT32 chan) -{ - float pos[3], vel[3]; // Temp bin - - if (chan == relcheckup(chan)) - return; - - if (!FSOUND_3D_GetAttributes(chan,&pos[0],&vel[0])) - { - if (FSOUND_GetError() != FMOD_ERR_NONE) DBG_Printf("FMOD(relplace, FSOUND_3D_GetAttributes, Channel # %i): %s\n",chan,FMOD_ErrorString(FSOUND_GetError())); - } - else - { - INT32 stack = relstack(chan); - - if (stack == -1) - return; - - memcpy(&relarray[stack].pos.pos,&pos,sizeof (pos)); - memcpy(&relarray[stack].pos.vel,&vel,sizeof (vel)); - relupdate(chan); - } -} - -//New rel chan -static void reladd(INT32 chan) -{ - if (chan != relcheckup(chan)) - return; - else - { - INT32 stack = STATIC_SOURCES_NUM; - { - if (relarray[0].handle == FSOUND_FREE) - stack = 0; - else if (relarray[1].handle == FSOUND_FREE) - stack = 1; - else if (relarray[2].handle == FSOUND_FREE) - stack = 2; - else if (relarray[3].handle == FSOUND_FREE) - stack = 3; - else if (relarray[4].handle == FSOUND_FREE) - stack = 4; - else if (relarray[5].handle == FSOUND_FREE) - stack = 5; - else - DBG_Printf("No more room in relarray\n"); - } - - relarray[stack].handle = chan; - relarray[stack].chan = relcopy(chan); - - if (relarray[stack].chan != FSOUND_FREE) - { - relarray[stack].pos.active = true; - relupdate(chan); - } - else - relarray[stack].pos.active = false; - } -} - -// End of head_relative system for FMOD3D - - -/****************************************************************************** - * - * Initialise driver and listener - * - *****************************************************************************/ -EXPORT INT32 HWRAPI(Startup) (I_Error_t FatalErrorFunction, snddev_t *snd_dev) -{ - boolean inited = false; - INT32 i = 0; - - I_ErrorFMOD = FatalErrorFunction; - - if (FSOUND_GetVersion() < FMOD_VERSION) - { - DBG_Printf("Error : You are using the wrong DLL version!\nYou should be using FMOD %.02f\n", FMOD_VERSION); - return inited; - } - else - DBG_Printf("S_FMOD Init(): FMOD_SOUND driver for SRB2Kart %s\n",VERSIONSTRING); - - if (!FSOUND_SetMinHardwareChannels(STATIC_SOURCES_NUM*4)) - DBG_Printf("FMOD(Startup,FSOUND_SetMinHardwareChannels,# of Channels Min: %i): %s\n",STATIC_SOURCES_NUM*4, FMOD_ErrorString(FSOUND_GetError())); - - if (!FSOUND_SetMaxHardwareChannels(0)) - DBG_Printf("FMOD(Startup,FSOUND_SetMaxHardwareChannels,# of Channels Min: %i): %s\n",0, FMOD_ErrorString(FSOUND_GetError())); - - for (i = 0; i < FSOUND_GetNumDrivers(); i++) - { - UINT32 caps = 0; - DBG_Printf("Driver Caps, if any\n"); - - if (FSOUND_GetDriverCaps(i, &caps)) - { - DBG_Printf("FMOD: Driver# %d - %s\n", i+1, FSOUND_GetDriverName(i)); // print driver names - if (caps & FSOUND_CAPS_HARDWARE) - DBG_Printf("This sound hardware supports hardware accelerated 3d sound.\n"); - - if (caps & FSOUND_CAPS_EAX2) - DBG_Printf("This sound hardware supports hardware accelerated 3d sound with EAX 2 reverb.\n"); - - if (caps & FSOUND_CAPS_EAX3) - DBG_Printf("This sound hardware supports hardware accelerated 3d sound with EAX 3 reverb.\n"); - } - else - DBG_Printf("FMOD(Startup,FSOUND_GetDriverCaps,%s): %s\n",FSOUND_GetDriverName(i), FMOD_ErrorString(FSOUND_GetError())); - } -#if defined (_WIN32) || defined (_WIN64) - if (!FSOUND_SetHWND(snd_dev->hWnd)) - { - DBG_Printf("FMOD(Startup,FSOUND_SetHWND): %s\n", FMOD_ErrorString(FSOUND_GetError())); - return inited; - } - else -#endif - { - DBG_Printf("Initialising FMOD %.02f\n",FMOD_VERSION); - inited = FSOUND_Init(snd_dev->sample_rate,MAXCHANNEL,0); - } - - if (!inited) - { - DBG_Printf("FMOD(Startup,Main): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - else - { -#ifdef OLDFMOD - DBG_Printf(" Maximum hardware mixing buffers %d\n", FSOUND_GetNumHardwareChannels()); -#else - INT32 num2DC, num3DC, numDC; - - if (FSOUND_GetNumHWChannels(&num2DC,&num3DC,&numDC)) - { - DBG_Printf(" Maximum hardware 2D buffers %d\n", num2DC); - DBG_Printf(" Maximum hardware 3D buffers %d\n", num3DC); - DBG_Printf(" Maximum hardware mixing buffers %d\n", numDC); - } - else - DBG_Printf("FMOD(Startup,FSOUND_GetNumHWChannels): %s\n", FMOD_ErrorString(FSOUND_GetError())); -#endif - - DBG_Printf("FMOD is up and running at %i KHZ\n",FSOUND_GetOutputRate()); - DBG_Printf("Sound hardware capabilities:\n"); - - if (FSOUND_GetDriverName(FSOUND_GetDriver())) - DBG_Printf(" Driver is %s\n",FSOUND_GetDriverName(FSOUND_GetDriver())); - else - DBG_Printf("FMOD(Startup,FSOUND_GetDriverName): %s\n", FMOD_ErrorString(FSOUND_GetError())); - - FSOUND_3D_SetDistanceFactor(1.0f/72.0f); - FSOUND_3D_SetRolloffFactor(0); - FSOUND_3D_SetRolloffFactor(1.6f); -#ifdef MORESTUFF - FSOUND_3D_SetDopplerFactor(0); -#endif - - switch (FSOUND_GetOutput()) - { - case FSOUND_OUTPUT_NOSOUND: - DBG_Printf("FMOD driver: NoSound driver, all calls to this succeed but do nothing.\n"); - break; - case FSOUND_OUTPUT_WINMM: - DBG_Printf("FMOD driver: Windows Multimedia driver.\n"); - break; - case FSOUND_OUTPUT_DSOUND: - DBG_Printf("FMOD driver: DirectSound driver. You need this to get EAX2 or EAX3 support, or FX api support.\n"); - break; - case FSOUND_OUTPUT_A3D: - DBG_Printf("FMOD driver: A3D driver.\n"); - break; - case FSOUND_OUTPUT_OSS: - DBG_Printf("FMOD driver: Linux/Unix OSS (Open Sound System) driver, i.e. the kernel sound drivers.\n"); - break; - case FSOUND_OUTPUT_ESD: - DBG_Printf("FMOD driver: Linux/Unix ESD (Enlightment Sound Daemon) driver.\n"); - break; - case FSOUND_OUTPUT_ALSA: - DBG_Printf("FMOD driver: Linux Alsa driver.\n"); - break; - case FSOUND_OUTPUT_MAC: - DBG_Printf("FMOD driver: Mac SoundManager driver\n"); - break; - case FSOUND_OUTPUT_NOSOUND_NONREALTIME: - DBG_Printf("FMOD driver: This is the same as nosound, but the sound generation is driven by FSOUND_Update\n"); - break; - case FSOUND_OUTPUT_ASIO: - DBG_Printf("FMOD driver: Low latency ASIO driver\n"); - break; - default: - DBG_Printf("FMOD driver: Unknown Sound Driver\n"); - break; - } - - relsetup(); - - blankfmsample = FSOUND_Sample_Alloc(FSOUND_UNMANAGED,1,FSOUND_UNORMAL,11025,127,FSOUND_STEREOPAN,127); - - if (!blankfmsample) - DBG_Printf("FMOD(Startup,FSOUND_Sample_Alloc): %s\n", FMOD_ErrorString(FSOUND_GetError())); - else if (!FSOUND_Sample_SetMaxPlaybacks(blankfmsample,STATIC_SOURCES_NUM*2)) - DBG_Printf("FMOD(Startup,FSOUND_Sample_SetMaxPlaybacks): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - return inited; -} - -EXPORT void HWRAPI(Shutdown) (void) -{ - DBG_Printf("Shuting down FMOD\n"); - FSOUND_Sample_Free(blankfmsample); - DBG_Printf("Shutdown of FMOD done\n"); - FSOUND_Close(); -} - -/****************************************************************************** - * - * Creates 3D source - * - ******************************************************************************/ - -EXPORT INT32 HWRAPI (Add3DSource) (source3D_data_t *src, sfx_data_t *sfx) -{ - FSOUND_SAMPLE *fmsample = NULL; - INT32 chan = -1; - float pos[3]; - float vel[3]; -#ifdef MORESTUFF - src->min_distance = MIN_DISTANCE; - src->max_distance = MAX_DISTANCE; -#endif - - pos[0] = src->pos.x; - pos[1] = src->pos.z; - pos[2] = src->pos.y; - vel[0] = src->pos.momx; - vel[1] = src->pos.momz; - vel[2] = src->pos.momy; - if (sfx) - fmsample = FSOUND_Sample_Load(FSOUND_FREE, INT2CHAR(sfx->data), FSOUND_DOOMLOAD, SFXLENGTH); - else - fmsample = blankfmsample; - - if (fmsample) - { - if (sfx && !FSOUND_Sample_SetDefaults(fmsample, - (INT32)((*((UINT16 *)sfx->data+1))*recalc_pitch(sfx->pitch)), - (sfx->volume == -1 ? 255 : sfx->volume), - (sfx->sep == NORMAL_SEP ? FSOUND_STEREOPAN : sfx->sep), - (sfx->priority) - ) - ) - DBG_Printf("FMOD(Add3DSource, FSOUND_Sample_SetDefaults, SFX's ID# %i): %s\n", sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); -#if 0 - if (!FSOUND_Sample_SetMinMaxDistance(fmsample, src->min_distance, src->max_distance)) - DBG_Printf("FMOD(Add3DSource, FSOUND_Sample_SetMinMaxDistance, SFX's ID# %i): %s\n", sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); -#endif - chan = FSOUND_PlaySoundEx(FSOUND_FREE,fmsample,NULL,true); - - if (chan == -1) - { - DBG_Printf("FMOD(Add3DSource, FSOUND_PlaySoundEx, SFX's ID# %i): %s\n",sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); - return chan; - } - else - { - if (!sfx) - DBG_Printf("FMOD(Add3DSource, Main): Added blank-sound added to channel %i\n",chan); -#ifdef MORESTUFF - else DBG_Printf("FMOD(Add3DSource, Main): Added sfxid# %i added to channel %i\n",sfx->id,chan); -#endif - } - } - else - { - if (sfx) - DBG_Printf("FMOD(Add3DSource, FSOUND_Sample_Load, sfxid# %i): %s\n",sfx->id,FMOD_ErrorString(FSOUND_GetError())); - else - DBG_Printf("FMOD(Add3DSource, FSOUND_Sample_Alloc): %s\n", FMOD_ErrorString(FSOUND_GetError())); - - return chan; - } - - if (FSOUND_GetCurrentSample(chan)) - { - if (!FSOUND_SetCurrentPosition(chan, 0)) - DBG_Printf("FMOD(Add3DSource, FSOUND_SetCurrentPosition, channel %i, sfxid# %i): %s\n", chan,sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); - - if (!FSOUND_3D_SetAttributes(chan,pos,vel)) - DBG_Printf("FMOD(Add3DSource, FSOUND_3D_SetAttributes, channel %i, sfxid# %i): %s\n", chan,sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); - - if (!FSOUND_SetReserved(chan, (signed char)src->permanent)) - DBG_Printf("FMOD(Add3DSource, FSOUND_SetReserved, channel %i, sfxid# %i): %s\n", chan,sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); - - if (src->head_relative) reladd(chan); - } - - return chan; -} - -/****************************************************************************** - * - * Creates 2D (stereo) source - * - ******************************************************************************/ -EXPORT INT32 HWRAPI (Add2DSource) (sfx_data_t *sfx) -{ - FSOUND_SAMPLE *fmsample = NULL; - INT32 chan = -1; - - if (!sfx) - return chan; - - fmsample = FSOUND_Sample_Load(FSOUND_FREE, INT2CHAR(sfx->data), FSOUND_DOOMLOAD, SFXLENGTH); - - if (fmsample) - { - if (!FSOUND_Sample_SetDefaults(fmsample, - (INT32)((float)(*((UINT16 *)sfx->data+1)) * recalc_pitch(sfx->pitch)), - sfx->volume == -1 ? 255 : sfx->volume, - sfx->sep == NORMAL_SEP ? FSOUND_STEREOPAN : sfx->sep, - sfx->priority)) - DBG_Printf("FMOD(Add2DSource, FSOUND_Sample_SetDefaults, sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError())); - - if (!FSOUND_Sample_SetMode(fmsample,FSOUND_2D)) - DBG_Printf("FMOD(Add2DSource, FSOUND_Sample_SetMode, sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError())); - - chan = FSOUND_PlaySoundEx(FSOUND_FREE,fmsample,NULL,true); - - if (chan == -1) - { - DBG_Printf("FMOD(Add2DSource, FSOUND_PlaySoundEx, sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError())); - return chan; - } -#ifdef MORESTUFF - else DBG_Printf("FMOD(Add2DSource, FSOUND_PlaySoundEx): sfxid# %i is playing on channel %i\n", sfx->id,chan); -#endif - } - else - { - DBG_Printf("FMOD(Add2DSource,FSOUND_Sample_Load, sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError())); - return chan; - } - - if (FSOUND_GetCurrentSample(chan)) - { - if (!FSOUND_SetCurrentPosition(chan, 0)) - DBG_Printf("FMOD(Add2DSource, FSOUND_SetCurrentPosition, channel %i, sfxid# %i): %s\n", chan,sfx->id,FMOD_ErrorString(FSOUND_GetError())); - } - - return chan; -} - -EXPORT INT32 HWRAPI (StartSource) (INT32 chan) -{ - FSOUND_SAMPLE *fmsample; - if (chan < 0) - return -1; - - fmsample = FSOUND_GetCurrentSample(chan); - - if (!fmsample) - return -1; - -#ifdef MORESTUFF - if (FSOUND_Sample_GetMode(fmsample) & FSOUND_2D) - { - DBG_Printf("FMOD(StartSource,Main): Starting 2D channel %i?\n",chan); - //return -1; - } - else - { - DBG_Printf("FMOD(StartSource,Main): Starting 3D Channel %i?\n",chan); - //return -1; - } -#endif - - if (FSOUND_GetPaused(relcheckup(chan))) - { - if (!FSOUND_SetPaused(relcheckup(chan), false)) - DBG_Printf("FMOD(StartSource,FSOUND_SetPaused, channel %i): %s\n", chan,FMOD_ErrorString(FSOUND_GetError())); - else if (relstack(chan) != -1) - relarray[relstack(chan)].pos.active = false; - } - else - DBG_Printf("FMOD(StartSource,FSOUND_GetPaused): Channel %i is playing already",chan); - - return chan; -} - -EXPORT void HWRAPI (StopSource) (INT32 chan) -{ - FSOUND_SAMPLE *fmsample; - - if (chan < 0) - return; - - fmsample = FSOUND_GetCurrentSample(chan); - - if (!fmsample) - return; - - if (!FSOUND_GetPaused(relcheckup(chan))) - { - if (!FSOUND_SetPaused(relcheckup(chan),true)) - { - DBG_Printf("FMOD(StopSource,FSOUND_SetPaused, channel %i): %s\n", chan,FMOD_ErrorString(FSOUND_GetError())); - } - else if (relstack(chan) != -1) - { - relarray[relstack(chan)].pos.active = false; - } - } -#ifdef MORESTUFF - else - DBG_Printf("FMOD(StopSource,FSOUND_GetPaused): Channel %i is stopped already\n",chan); -#endif -} - -EXPORT INT32 HWRAPI (GetHW3DSVersion) (void) -{ - return VERSION; -} - -EXPORT void HWRAPI (BeginFrameUpdate) (void) -{ - FSOUND_Update(); -} - -EXPORT void HWRAPI (EndFrameUpdate) (void) -{ - relupdate(FSOUND_FREE); -} - -EXPORT INT32 HWRAPI (IsPlaying) (INT32 chan) -{ - if (chan < 0) - return false; - - if (!FSOUND_GetCurrentSample(chan)) - return false; - - return FSOUND_IsPlaying(relcheckup(chan)); -} - -/****************************************************************************** - * UpdateListener - * - * Set up main listener properties: - * - position - * - orientation - * - velocity - *****************************************************************************/ -EXPORT void HWRAPI (UpdateListener) (listener_data_t *data) -{ - if (data) - { - float pos[3]; - float vel[3]; - double f_angle = 0; - if (data->f_angle) f_angle = (data->f_angle) / 180 * M_PI; - pos[0] = (float)data->x; - pos[1] = (float)data->z; - pos[2] = (float)data->y; - vel[0] = (float)data->momx; - vel[1] = (float)data->momz; - vel[2] = (float)data->momy; - - FSOUND_3D_Listener_SetAttributes(pos,vel,(float)cos(f_angle),0.0f,(float)sin(f_angle), 0.0f , 1.0f, 0.0f); - relset(1); - } - else - { - relset(-1); - DBG_Printf("Error: 1st listener data is missing\n"); - } -} - -EXPORT void HWRAPI (UpdateListener2) (listener_data_t *data) -{ - if (data) - { - float pos[3]; - float vel[3]; - double f_angle = 0; - if (data->f_angle) f_angle = (data->f_angle) / 180 * M_PI; - pos[0] = (float)data->x; - pos[1] = (float)data->z; - pos[2] = (float)data->y; - vel[0] = (float)data->momx; - vel[1] = (float)data->momz; - vel[2] = (float)data->momy; - - FSOUND_3D_Listener_SetCurrent(1,2); - FSOUND_3D_Listener_SetAttributes(pos,vel,(float)cos(f_angle),0.0f,(float)sin(f_angle), 0.0f , 1.0f, 0.0f); - relset(2); - FSOUND_3D_Listener_SetCurrent(0,2); - } - else - { - relset(-2); - FSOUND_3D_Listener_SetCurrent(0,1); - } -} - -EXPORT void HWRAPI (UpdateSourceVolume) (INT32 chan, INT32 vol) -{ - if (chan < 0) - return; - - if (!FSOUND_GetCurrentSample(chan)) - return; - - if (!FSOUND_SetVolume(chan,vol)) - DBG_Printf("FMOD(UpdateSourceVolume, FSOUND_SetVolume, channel %i to volume %i): %s\n", chan,vol,FMOD_ErrorString(FSOUND_GetError())); - else - { -#ifdef MORESTUFF - DBG_Printf("FMOD(UpdateSourceVolume, Main): channel %i is set to the volume of %i", chan,vol); -#endif - relvol(chan); - } -} - -/****************************************************************************** - * - * Update volume and separation (panning) of 2D source - * - *****************************************************************************/ -EXPORT void HWRAPI (Update2DSoundParms) (INT32 chan, INT32 vol, INT32 sep) -{ - FSOUND_SAMPLE *fmsample; - - if (chan < 0) - return; - - fmsample = FSOUND_GetCurrentSample(chan); - - if (fmsample) - { - if (!FSOUND_Sample_GetMode(fmsample) & FSOUND_2D) - { - DBG_Printf("FMOD(Update2DSoundParms,Main): 2D Vol/Pan on 3D channel %i?\n",chan); - //return; - } - } - else - return; - - if (!FSOUND_SetPaused(chan, true)) - DBG_Printf("FMOD(Update2DSoundParms, FSOUND_SetPaused, Pause, channel %i): %s\n", chan,FMOD_ErrorString(FSOUND_GetError())); - - if (!FSOUND_SetVolume(chan,vol)) - DBG_Printf("FMOD(Update2DSoundParms, , channel %i to volume %i): %s\n", chan,vol,FMOD_ErrorString(FSOUND_GetError())); - - if (!FSOUND_SetPan(chan, sep == NORMAL_SEP ? FSOUND_STEREOPAN : sep)) - DBG_Printf("FMOD(Update2DSoundParms, FSOUND_SetPan, channel %i to sep %i): %s\n", chan,sep,FMOD_ErrorString(FSOUND_GetError())); - - if (!FSOUND_SetPaused(chan, false)) - DBG_Printf("FMOD(Update2DSoundParms, FSOUND_SetPaused, Resume, channel %i): %s\n", chan,FMOD_ErrorString(FSOUND_GetError())); -} - -// -------------------------------------------------------------------------- -// Set the global volume for sound effects -// -------------------------------------------------------------------------- -EXPORT void HWRAPI (SetGlobalSfxVolume) (INT32 vol) -{ - INT32 realvol = (vol<<3)+(vol>>2); - - FSOUND_SetSFXMasterVolume(realvol); -#ifdef MORESTUFF - DBG_Printf("FMOD(SetGlobalSfxVolume, Main, the volume is set to %i): %s\n", realvol,FMOD_ErrorString(FSOUND_GetError())); -#endif -} - -//Alam_GBC: Not Used? -EXPORT INT32 HWRAPI (SetCone) (INT32 chan, cone_def_t *cone_def) -{ - FSOUND_SAMPLE *fmsample; - - if (chan < 0) - return -1; - - fmsample = FSOUND_GetCurrentSample(chan); - - if (fmsample) - { - if (FSOUND_Sample_GetMode(fmsample) & FSOUND_2D) - { - DBG_Printf("FMOD(Update3DSource,Main): 3D Cone on 2D Channel %i?\n",chan); - return -1; - } - } - - if (cone_def) - { - return -1; - } - else - { - return 1; - } - -} - -EXPORT void HWRAPI (Update3DSource) (INT32 chan, source3D_pos_t *sfx) -{ - float pos[3]; - float vel[3]; - FSOUND_SAMPLE *fmsample; - - pos[0] = sfx->x; - pos[1] = sfx->z; - pos[2] = sfx->y; - vel[0] = sfx->momx; - vel[1] = sfx->momz; - vel[2] = sfx->momy; - if (chan < 0) - return; - - fmsample = FSOUND_GetCurrentSample(chan); - - if (!fmsample) - return; - - if (fmsample) - { - if (FSOUND_Sample_GetMode(fmsample) & FSOUND_2D) - { - //DBG_Printf("FMOD(Update3DSource,Main): 3D Pos/Vel on 2D Channel %i?\n",chan); - //return; - } - } - else - { - return; - } - - if (!FSOUND_3D_SetAttributes(chan,pos,vel)) - DBG_Printf("FMOD(Update3DSource,FSOUND_3D_SetAttributes, onto channel %i): %s\n", chan,FMOD_ErrorString(FSOUND_GetError())); - else - relplace(chan); -} - -//------------------------------------------------------------- -// Load new sound data into source -//------------------------------------------------------------- -EXPORT INT32 HWRAPI (Reload3DSource) (INT32 handle, sfx_data_t *sfx) -{ - source3D_data_t src; - float pos[3], vel[3]; - INT32 chan = relcheckup(handle); - FSOUND_SAMPLE *fmsample; - - if (handle < 0 || !sfx) - return -1; - - fmsample = FSOUND_GetCurrentSample(chan); - - if (!fmsample) - return -1; - - if (FSOUND_Sample_GetMode(fmsample) & FSOUND_2D) - { - DBG_Printf("FMOD(Reload3DSource,Main): New 3D Sound on 2D Channel %i?\n",handle); - return -1; - } -#ifdef MORESTUFF - else - DBG_Printf("FMOD(Reload3DSource, Main, sending new sfx# %i to chan %i)\n",sfx->id,handle); -#endif - -#ifdef OLDFMOD - src.min_distance = MIN_DISTANCE; - src.max_distance = MAX_DISTANCE; -#else - if (!FSOUND_3D_GetMinMaxDistance(handle,&src.min_distance,&src.min_distance)) - DBG_Printf("FMOD(Reload3DSource, FSOUND_3D_GetMinMaxDistance, channel %i, for sfxid# %i): %s\n",handle, sfx->id,FMOD_ErrorString(FSOUND_GetError())); -#endif - src.head_relative = (handle != chan); - src.permanent = FSOUND_GetReserved(handle); - if (!FSOUND_3D_GetAttributes(handle,&pos[0],&vel[0])) - DBG_Printf("FMOD(Reload3DSource, FSOUND_3D_GetAttributes, channel %i, for sfxid# %i): %s\n",handle,sfx->id,FMOD_ErrorString(FSOUND_GetError())); - - //if (handle == chan) - { - if (fmsample != blankfmsample) FSOUND_Sample_Free(fmsample); - } - //else - { - // fmsample = FSOUND_GetCurrentSample(handle); - } - - fmsample = FSOUND_Sample_Load(FSOUND_FREE, INT2CHAR(sfx->data), FSOUND_DOOMLOAD, SFXLENGTH); - - if (!FSOUND_StopSound(chan)) - DBG_Printf("FMOD(Reload3DSource,FSOUND_StopSound, of channel %i for sfxid# %i): %s\n", handle,sfx->id,FMOD_ErrorString(FSOUND_GetError())); - - if (fmsample) - { - if (!FSOUND_Sample_SetDefaults(fmsample, - (INT32)((float)(*((UINT16 *)sfx->data+1)) * recalc_pitch(sfx->pitch)), - sfx->volume == -1 ? 255 : sfx->volume, - sfx->sep == NORMAL_SEP ? FSOUND_STEREOPAN : sfx->sep, - sfx->priority)) - DBG_Printf("FMOD(Reload3DSource, FSOUND_Sample_SetDefaults, for sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError())); - - if (!FSOUND_Sample_SetMinMaxDistance(fmsample, src.min_distance, src.max_distance)) - DBG_Printf("FMOD(Reload3DSource, FSOUND_Sample_SetMinMaxDistance, SFX's ID# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError())); - - chan = FSOUND_PlaySoundEx(chan,fmsample,NULL,true); - - if (chan == -1) - { - DBG_Printf("FMOD(Reload3DSource, FSOUND_PlaySoundEx, for sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError())); - return chan; - } - - if (FSOUND_GetCurrentSample(chan)) - { - if (!FSOUND_SetCurrentPosition(chan, 0)) - DBG_Printf("FMOD(Reload3DSource, FSOUND_SetCurrentPosition, channel %i, sfxid# %i): %s\n", chan,sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); - - if (!FSOUND_3D_SetAttributes(chan,pos,vel)) - DBG_Printf("FMOD(Reload3DSource, FSOUND_3D_SetAttributes, channel %i, sfxid# %i): %s\n", chan,sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); - - if (!FSOUND_SetReserved(chan, (signed char)src.permanent)) - DBG_Printf("FMOD(Reload3DSource, FSOUND_SetReserved, channel %i, sfxid# %i): %s\n", chan,sfx?sfx->id:0,FMOD_ErrorString(FSOUND_GetError())); - - if (src.head_relative) relupdate(handle); - } - } - else - DBG_Printf("FMOD(Reload3DSource,FSOUND_Sample_Load, for sfxid# %i): %s\n", sfx->id,FMOD_ErrorString(FSOUND_GetError())); - - return chan; -} - -/****************************************************************************** - * - * Destroy source and remove it from stack if it is a 2D source. - * Otherwise put source into cache - * - *****************************************************************************/ -EXPORT void HWRAPI (KillSource) (INT32 chan) -{ - FSOUND_SAMPLE *fmsample; - INT32 relchan; - - if (chan < 0) - return; - - relchan = relcheckup(chan); - - fmsample = FSOUND_GetCurrentSample(chan); - - if (!fmsample) - return; - -#ifdef MORESTUFF - if (FSOUND_IsPlaying(relchan)) - if (!FSOUND_SetLoopMode(relchan, FSOUND_LOOP_OFF)) - DBG_Printf("FMOD(KillSource,FSOUND_SetLoopMode, for channel %i): %s\n", chan,FMOD_ErrorString(FSOUND_GetError())); //Alam_GBC: looping off - else -#endif - if (!FSOUND_StopSound(relchan)) - { - DBG_Printf("FMOD(KillSource,FSOUND_StopSound, for channel %i): %s\n", chan,FMOD_ErrorString(FSOUND_GetError())); - } -#ifdef MORESTUFF - else DBG_Printf("FMOD(KillSource, Main, for channel %i)\n", chan); -#endif - if (fmsample != blankfmsample) FSOUND_Sample_Free(fmsample); -} - -#ifdef _WINDOWS -BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module - DWORD fdwReason, // reason for calling function - LPVOID lpvReserved) // reserved -{ - // Perform actions based on the reason for calling. - UNREFERENCED_PARAMETER(lpvReserved); - switch (fdwReason) - { - case DLL_PROCESS_ATTACH: - // Initialize once for each new process. - // Return FALSE to fail DLL load. -#ifdef DEBUG_TO_FILE - logstream = fopen("s_fmod.log", "wt"); - if (logstream == NULL) - return FALSE; -#endif - DisableThreadLibraryCalls(hinstDLL); - break; - - case DLL_THREAD_ATTACH: - // Do thread-specific initialization. - break; - - case DLL_THREAD_DETACH: - // Do thread-specific cleanup. - break; - - case DLL_PROCESS_DETACH: - // Perform any necessary cleanup. -#ifdef DEBUG_TO_FILE - if (logstream) - { - fclose(logstream); - logstream = NULL; - } -#endif - break; - } - return TRUE; // Successful DLL_PROCESS_ATTACH. -} -#elif !defined (HAVE_SDL) - -// ************************************************************************** -// FUNCTIONS -// ************************************************************************** - -EXPORT void _init() -{ -#ifdef DEBUG_TO_FILE - logstream = fopen("s_fmod.log","wt"); -#endif -} - -EXPORT void _fini() -{ -#ifdef DEBUG_TO_FILE - if (logstream) - fclose(logstream); -#endif -} -#endif diff --git a/src/hardware/s_fmod/s_fmod.dev b/src/hardware/s_fmod/s_fmod.dev deleted file mode 100644 index 01e21e2b7..000000000 --- a/src/hardware/s_fmod/s_fmod.dev +++ /dev/null @@ -1,59 +0,0 @@ -[Project] -FileName=s_fmod.dev -Name=s_fmod -Ver=1 -IsCpp=1 -Type=3 -Compiler=-D_M_IX86=500_@@_-Wall_@@_-D_WINDOWS_@@_-Os_@@_-fomit-frame-pointer_@@_ -CppCompiler= -Includes=..\..\win32\FMOD -Linker=--def ../s_mingw.def_@@_-lfmod_@@_ -Libs=..\..\win32\FMOD -UnitCount=1 -Folders= -ObjFiles= -PrivateResource= -ResourceIncludes= -MakeIncludes= -Icon= -ExeOutput=C:\srb2demo2 -ObjectOutput=..\..\..\objs\Mingw\s_fmod -OverrideOutput=1 -OverrideOutputName=s_fmod.dll -HostApplication= -CommandLine= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=00000000000000000111d0 -UseCustomMakefile=0 -CustomMakefile= - -[Unit1] -FileName=s_fmod.c -Folder= -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=1 -Minor=0 -Release=8 -Build=42 -LanguageID=1033 -CharsetID=1252 -CompanyName=Alam Arias -FileVersion=1.42 -FileDescription=SRB2 Sound API DLL for FMOD -InternalName=Super FMOD! -LegalCopyright= -LegalTrademarks= -OriginalFilename=s_fmod.dll -ProductName=s_fmod -ProductVersion=0.1 -AutoIncBuildNr=0 - diff --git a/src/hardware/s_fmod/s_fmod.dsp b/src/hardware/s_fmod/s_fmod.dsp deleted file mode 100644 index c9a1fb743..000000000 --- a/src/hardware/s_fmod/s_fmod.dsp +++ /dev/null @@ -1,97 +0,0 @@ -# Microsoft Developer Studio Project File - Name="s_fmod" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=s_fmod - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "s_fmod.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "s_fmod.mak" CFG="s_fmod - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "s_fmod - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "s_fmod - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "s_fmod - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\..\..\bin\VC\Release\s_fmod" -# PROP Intermediate_Dir "..\..\..\objs\VC\Release\s_fmod" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "S_FMOD_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WIN32__" /D "__MSC__" /FR /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 fmodvc.lib /nologo /dll /pdb:"..\..\..\bin\VC\Release\s_fmod.pdb" /machine:I386 /out:"..\..\..\bin\VC\Release\s_fmod.dll" - -!ELSEIF "$(CFG)" == "s_fmod - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\..\..\bin\VC\Debug\s_fmod" -# PROP Intermediate_Dir "..\..\..\objs\VC\Debug\s_fmod" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "S_FMOD_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "__WIN32__" /D "__MSC__" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 fmodvc.lib /nologo /dll /pdb:"..\..\..\bin\VC\Debug\s_fmod.pdb" /debug /machine:I386 /out:"..\..\..\bin\VC\Debug\s_fmod.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "s_fmod - Win32 Release" -# Name "s_fmod - Win32 Debug" -# Begin Source File - -SOURCE=.\s_fmod.c -# End Source File -# End Target -# End Project diff --git a/src/hardware/s_openal/s_openal.c b/src/hardware/s_openal/s_openal.c deleted file mode 100644 index 7f91ccf2c..000000000 --- a/src/hardware/s_openal/s_openal.c +++ /dev/null @@ -1,998 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2001 by DooM Legacy Team. -// -// 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. -//----------------------------------------------------------------------------- -/// \file -/// \brief General driver for 3D sound system -/// -/// Implementend via OpenAL API - -#ifdef _WINDOWS -//#define WIN32_LEAN_AND_MEAN -#define RPC_NO_WINDOWS_H -#include -#include -FILE* logstream = NULL; -#else -#include -#include -#include -#include -#include -#include -#ifndef HAVE_SDL // let not make a logstream here is we are inline the HW3D in the SDL binary -FILE* logstream = NULL; -#endif -#endif - -#ifdef __APPLE__ -#include //Main AL -#include //Helpers -#else -#include //Main AL -#include //Helpers -#endif - -#define _CREATE_DLL_ -#include "../../doomdef.h" -#include "../hw3dsdrv.h" - -//#undef DEBUG_TO_FILE -//#if defined ( HAVE_SDL ) && !defined ( LOGMESSAGES ) -#define DEBUG_TO_FILE -//#endif - -// Internal sound stack -typedef struct stack_snd_s -{ - ALuint ALsource;// 3D data of 3D source - - ALint sfx_id;// Currently unused - - ALint LRU;// Currently unused - - ALboolean permanent;// Flag of static source -} stack_snd_t; - -#ifndef AL_INVALID -#define AL_INVALID (-1) -#endif - -static I_Error_t I_ErrorOpenAl = NULL; -static stack_snd_t *ALstack = NULL; // Sound stack -static ALsizei allocated_sounds = 0; // Size of stack -static ALsizei allocate_delta = 16; -static ALCdevice *ALCDevice = NULL; -static ALCcontext *ALContext = NULL; -static ALenum ALo_Lasterror = AL_NO_ERROR; -static ALenum ALCo_Lasterror = ALC_NO_ERROR; - -static ALenum ALo_GetError(ALvoid) -{ - ALo_Lasterror = alGetError(); - return ALo_Lasterror; -} - -static ALenum ALCo_GetError(ALvoid) -{ - ALCo_Lasterror = alcGetError(ALCDevice); - return ALCo_Lasterror; -} - -static ALfloat ALvol(ALint vol, ALsizei step) -{ - return ((ALfloat)vol)/(ALfloat)step; -} - -/* -static ALfloat Alpitch(ALint pitch) -{ -#if 1 - pitch = NORMAL_PITCH; -#endif - return pitch < NORMAL_PITCH ? - (float)(pitch + NORMAL_PITCH) / (NORMAL_PITCH * 2) - :(float)pitch / (float)NORMAL_PITCH; -} -*/ - -static const ALchar *GetALErrorString(ALenum err) -{ - switch (err) - { - case AL_NO_ERROR: - return "There no error"; - break; - - case AL_INVALID_NAME: - return "Invalid name"; - break; - - case AL_INVALID_ENUM: - return "Invalid enum"; - break; - - case AL_INVALID_VALUE: - return "Invalid value"; - break; - - case AL_INVALID_OPERATION: - return "Invalid operation"; - break; - - case AL_OUT_OF_MEMORY: - return "Out Of Memory"; - break; - - default: - return alGetString(err); - break; - } -} - -static const ALchar *GetALCErrorString(ALenum err) -{ - switch (err) - { - case ALC_NO_ERROR: - return "There no error"; - break; - - case ALC_INVALID_DEVICE: - return "Invalid Device"; - break; - - case ALC_INVALID_CONTEXT: - return "Invalid Context"; - break; - - case ALC_INVALID_ENUM: - return "Invalid enum"; - break; - - case ALC_INVALID_VALUE: - return "Invalid value"; - break; - - case ALC_OUT_OF_MEMORY: - return "Out Of Memory"; - break; - - default: - return alcGetString(ALCDevice, err); - break; - } -} - -/*************************************************************** - * - * DBG_Printf - * Output error messages to debug log if DEBUG_TO_FILE is defined, - * else do nothing - * - ************************************************************** - */ -// -----------------+ -// DBG_Printf : Output error messages to debug log if DEBUG_TO_FILE is defined, -// : else do nothing -// Returns : -// -----------------+ -FUNCPRINTF void DBG_Printf(const char *lpFmt, ... ) -{ -#ifdef DEBUG_TO_FILE - char str[4096] = ""; - va_list arglist; - - va_start(arglist, lpFmt); - vsnprintf(str, 4096, lpFmt, arglist); - va_end(arglist); - if (logstream) - fwrite(str, strlen(str), 1 , logstream); -#else - lpFmt = NULL; -#endif -} - -/*************************************************************** - * - * Grow internal sound stack by allocate_delta amount - * - *************************************************************** - */ -static ALboolean reallocate_stack(void) -{ - stack_snd_t *new_stack; - if (ALstack) - new_stack = realloc(ALstack, sizeof (stack_snd_t) * (allocated_sounds + allocate_delta)); - else - new_stack = malloc(sizeof (stack_snd_t) * (allocate_delta)); - if (new_stack) - { - ALsizei clean_stack; - ALstack = new_stack; - memset(&ALstack[allocated_sounds], 0, allocate_delta * sizeof (stack_snd_t)); - for (clean_stack = allocated_sounds; clean_stack < allocated_sounds; clean_stack++) - ALstack[clean_stack].ALsource = (ALuint)AL_INVALID; - allocated_sounds += allocate_delta; - return AL_TRUE; - } - return AL_FALSE; -} - - -/*************************************************************** - * - * Destroys source in stack - * - *************************************************************** - */ -static ALvoid kill_sound(stack_snd_t *snd) -{ - if (alIsSource(snd->ALsource)) - alDeleteSources(1,&snd->ALsource); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: alDeleteSources, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - memset(snd,0, sizeof (stack_snd_t)); - snd->ALsource = (ALuint)AL_INVALID; -} - -/*************************************************************** - * - * Returns free (unused) source stack slot - * If none available sound stack will be increased - * - *************************************************************** - */ -static ALsizei find_handle(void) -{ - ALsizei free_sfx = 0; - stack_snd_t *snd; - - for (snd = ALstack; free_sfx < allocated_sounds; snd++, free_sfx++) - { - if (snd->permanent) - continue; - if (snd->ALsource==(ALuint)AL_INVALID) - break; - if (!alIsSource(snd->ALsource)) - break; - ALo_GetError(); - if (snd->sfx_id == 0) - break; - } - - // No suitable resource found so increase sound stack - //DBG_Printf("sfx chan %d\n", free_sfx); - if (free_sfx == allocated_sounds) - { - DBG_Printf("No free or same sfx found so increase stack (currently %d srcs)\n", allocated_sounds); - free_sfx = reallocate_stack() ? free_sfx : (ALsizei)AL_INVALID; - } - return free_sfx; -} - -static ALvoid ALSetPan(ALuint sid, INT32 sep) -{ - ALfloat facing[3] ={0.0f, 0.0f, 0.0f}; //Alam: bad? - const ALfloat fsep = (ALfloat)sep; - const ALfloat nsep = (ALfloat)NORMAL_SEP; - if (sep) - { - facing[0] = (ALfloat)(fsep/nsep); - facing[2] = 1.0f; - } - alSourcefv(sid, AL_POSITION, facing); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: alSourcefv, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } -} - - -/****************************************************************************** - * - * Initialise driver and listener - * - *****************************************************************************/ -EXPORT INT32 HWRAPI( Startup ) (I_Error_t FatalErrorFunction, snddev_t *snd_dev) -{ - ALenum model = AL_INVERSE_DISTANCE_CLAMPED; - ALCboolean inited = ALC_FALSE; - ALCint AlSetup[8] = {ALC_FREQUENCY,22050,ALC_REFRESH,35,ALC_SYNC,AL_FALSE,ALC_INVALID,ALC_INVALID}; -#if (defined (_WIN32) || defined (_WIN64)) && 0 - const ALCubyte *ALCdriver = alcGetString(NULL,ALC_DEFAULT_DEVICE_SPECIFIER); - const ALCubyte *DSdriver = "DirectSound"; - - if (!strcmp((const ALCbyte *)ALCdriver,"DirectSound3D")) //Alam: OpenAL's DS3D is buggy - ALCDevice = alcOpenDevice(DSdriver); //Open DirectSound - else //Alam: The OpenAl device - ALCDevice = alcOpenDevice(ALCdriver); //Open Default -#else - ALCDevice = alcOpenDevice(alcGetString(NULL,ALC_DEFAULT_DEVICE_SPECIFIER)); -#endif - if (ALCo_GetError() != ALC_NO_ERROR || !ALCDevice) - { - DBG_Printf("S_OpenAl: Error %s when opening device!\n", GetALCErrorString(ALCo_Lasterror)); - return inited; - } - else - { - DBG_Printf("Driver Name : %s\n", alcGetString(ALCDevice,ALC_DEVICE_SPECIFIER)); - DBG_Printf("Extensions : %s\n", alcGetString(ALCDevice,ALC_EXTENSIONS)); - DBG_Printf("S_OpenAl: OpenAl Device %s opened\n",alcGetString(ALCDevice, ALC_DEVICE_SPECIFIER)); - } - - I_ErrorOpenAl = FatalErrorFunction; - - AlSetup[1] = snd_dev->sample_rate; //ALC_FREQUENCY - AlSetup[1] = 44100; - AlSetup[3] = 35; //ALC_REFRESH - - //Alam: The Environment? - ALContext = alcCreateContext(ALCDevice,AlSetup); - if (ALCo_GetError() != ALC_NO_ERROR || !ALContext) - { - DBG_Printf("S_OpenAl: Error %s when making the environment!\n",GetALCErrorString(ALCo_Lasterror)); - return inited; - } - else - { - DBG_Printf("S_OpenAl: OpenAl environment made\n"); - } - - alcMakeContextCurrent(ALContext); - if (ALCo_GetError() != ALC_NO_ERROR) - { - DBG_Printf("S_OpenAl: Error %s when setting the environment!\n",GetALCErrorString(ALCo_Lasterror)); - return inited; - } - else - { - DBG_Printf("S_OpenAl: OpenAl environment setted up\n"); - } - - DBG_Printf("Vendor : %s\n", alGetString(AL_VENDOR)); - DBG_Printf("Renderer : %s\n", alGetString(AL_RENDERER)); - DBG_Printf("Version : %s\n", alGetString(AL_VERSION)); - DBG_Printf("Extensions : %s\n", alGetString(AL_EXTENSIONS)); - - alDopplerFactor(0.0f); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("S_OpenAl: Error %s when setting Doppler Factor!\n",GetALErrorString(ALo_Lasterror)); - return inited; - } - else - { - DBG_Printf("S_OpenAl: Doppler Factor of %f setted\n", alGetDouble(AL_DOPPLER_FACTOR)); - } - - alSpeedOfSound(600.0f); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("S_OpenAl: Error %s when setting Speed of Sound!\n",GetALErrorString(ALo_Lasterror)); - return inited; - } - else - { - DBG_Printf("S_OpenAl: Speed of Sound set to %f\n", alGetDouble(AL_SPEED_OF_SOUND)); - } - - alDistanceModel(model); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("S_OpenAl: Error %s when setting Distance Model!\n",GetALErrorString(ALo_Lasterror)); - return inited; - } - else - { - //DBG_Printf("S_OpenAl: %s mode setted\n",alGetString(model)); - } - - inited = reallocate_stack(); - - return inited; -} - -/****************************************************************************** - * - * Shutdown 3D Sound - * - ******************************************************************************/ -EXPORT void HWRAPI( Shutdown ) ( void ) -{ - ALsizei i; - - DBG_Printf ("S_OpenAL Shutdown()\n"); - - for (i = 0; i < allocated_sounds; i++) - { - StopSource(i); - kill_sound(ALstack + i); - } - -#if defined(linux) || defined(__linux) || defined(__linux__) - alcMakeContextCurrent(NULL); - //TODO:check? -#endif - - if (ALContext) - { - alcDestroyContext(ALContext); - ALContext = NULL; - } - - if (ALstack) - { - free(ALstack); - ALstack = NULL; - } - - //TODO:check? - if (ALCDevice) - { - alcCloseDevice(ALCDevice); - ALCDevice = NULL; - } - //TODO:check? -} - -#ifdef _MSC_VER -#pragma warning(disable : 4200) -#pragma pack(1) -#endif - -typedef struct -{ - ALushort header; // 3? - ALushort samplerate; // 11025+ - ALushort samples; // number of samples - ALushort dummy; // 0 - ALubyte data[0]; // data; -} ATTRPACK dssfx_t; - -#ifdef _MSC_VER -#pragma pack() -#pragma warning(default : 4200) -#endif - -static ALsizei getfreq(ALvoid *sfxdata, size_t len) -{ - dssfx_t *dsfx = sfxdata; - const ALsizei freq = SHORT(dsfx->samplerate); - - if (len <= 8) - return 0; - else - return freq; -} - -static ALsizei makechan(ALuint sfxhandle, ALboolean perm) -{ - ALsizei chan = find_handle(); - - if (chan == (ALsizei)AL_INVALID) return chan; - - alGenSources(1, &ALstack[chan].ALsource); - if (ALo_GetError() != AL_NO_ERROR || !alIsSource(ALstack[chan].ALsource)) - { - DBG_Printf("S_OpenAl: Error %s when make an ALSource!\n",GetALErrorString(ALo_Lasterror)); - ALstack[chan].ALsource = (ALuint)AL_INVALID; - return (ALsizei)AL_INVALID; - } - - ALstack[chan].permanent = perm; - - alSourceQueueBuffers(ALstack[chan].ALsource, 1, &sfxhandle); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("S_OpenAl: Error %s when queue up an alSource!\n",GetALErrorString(ALo_Lasterror)); - } - - return chan; -} - -/****************************************************************************** - * - * Creates ?D source - * - ******************************************************************************/ -EXPORT INT32 HWRAPI ( AddSource ) (source3D_data_t *src, u_int sfxhandle) -{ - ALsizei chan = makechan(sfxhandle, (ALboolean)(src?src->permanent:AL_FALSE)); - ALuint sid = (ALuint)AL_INVALID; - if (chan == (ALsizei)AL_INVALID) - return AL_INVALID; - else - sid = ALstack[chan].ALsource; - - if (src) //3D - { -#if 0 - alSourcef(sid, AL_REFERENCE_DISTANCE, src->min_distance); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_REFERENCE_DISTANCE, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - - alSourcef(sid, AL_MAX_DISTANCE, src->max_distance); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_MAX_DISTANCE, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } -#endif - - if (src->head_relative) - alSourcei(sid, AL_SOURCE_RELATIVE, AL_TRUE); - else - alSourcei(sid, AL_SOURCE_RELATIVE, AL_FALSE); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_SOURCE_RELATIVE, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - - alSource3f(sid, AL_POSITION, src->pos.x, src->pos.z, src->pos.y); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_POSITION, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - alSource3f(sid, AL_VELOCITY, src->pos.momx, src->pos.momz, src->pos.momy); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_VELOCITY, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - } - else //2D - { - alSourcei(sid, AL_SOURCE_RELATIVE, AL_TRUE); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_SOURCE_RELATIVE, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - } - - alSourcef(sid, AL_ROLLOFF_FACTOR, 0.0f); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_ROLLOFF_FACTOR, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - - alSourcef(sid, AL_REFERENCE_DISTANCE, 0.0f); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_REFERENCE_DISTANC, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - return chan; -} - -EXPORT INT32 HWRAPI ( StartSource ) (INT32 chan) -{ - ALint state = AL_NONE; - ALuint sid = (ALuint)AL_INVALID; - - if (chan <= AL_INVALID || !alIsSource(ALstack[chan].ALsource)) - return AL_FALSE; - else - sid = ALstack[chan].ALsource; - - ALo_GetError(); - - alSourcePlay(sid); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: alSourcePlay, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - - alGetSourcei(sid, AL_SOURCE_STATE, &state); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: alGetSourcei, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - - return (state == AL_PLAYING); -} - -EXPORT void HWRAPI ( StopSource) (INT32 chan) -{ - ALuint sfxhandle = AL_NONE; - ALuint sid = (ALuint)AL_INVALID; - if (chan <= AL_INVALID || !alIsSource(ALstack[chan].ALsource)) - return; - else - sid = ALstack[chan].ALsource; - - ALo_GetError(); - -#if 1 - alSourceQueueBuffers(sid, 1, &sfxhandle); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: alSourceQueueBuffers, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } -#else - alSourceStop(sid); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: alSourceStop, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } -#endif -} - -EXPORT INT32 HWRAPI ( GetHW3DSVersion) (void) -{ - return VERSION; -} - -EXPORT void HWRAPI (BeginFrameUpdate) (void) -{ - alcSuspendContext(ALContext); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: alcSuspendContext, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } -} - -EXPORT void HWRAPI (EndFrameUpdate) (void) -{ - alcProcessContext(ALContext); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: alcProcessContext, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } -} - -EXPORT INT32 HWRAPI (IsPlaying) (INT32 chan) -{ - ALint state = AL_NONE; - ALuint sid = (ALuint)AL_INVALID; - - if (chan <= AL_INVALID || !alIsSource(ALstack[chan].ALsource)) - return AL_FALSE; - else - sid = ALstack[chan].ALsource; - - ALo_GetError(); - - alGetSourcei(sid, AL_SOURCE_STATE, &state); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: alGetSourcei, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - - return (state == AL_PLAYING); -} - -/****************************************************************************** - * UpdateListener - * - * Set up main listener properties: - * - position - * - orientation - * - velocity - *****************************************************************************/ -EXPORT void HWRAPI (UpdateListener) (listener_data_t *data, INT32 num) -{ - if (num != 1) return; - - if (data) - { - ALfloat facing[6]; - ALdouble f_angle = 0.0; - if (data->f_angle) f_angle = (ALdouble)((data->f_angle) / 180.0l * M_PIl); - facing[0] = (ALfloat)cos(f_angle); - facing[1] = 0.0f; - facing[2] = (ALfloat)sin(f_angle); - facing[3] = 0.0f; - facing[4] = 1.0f; - facing[5] = 0.0f; - - alListener3f(AL_POSITION,(ALfloat)-data->x,(ALfloat)data->z,(ALfloat)data->y); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_POSITIO, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - - alListener3f(AL_VELOCITY,(ALfloat)data->momx,(ALfloat)data->momz,(ALfloat)data->momy); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_VELOCITY, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - - alListenerfv(AL_ORIENTATION, facing); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_ORIENTATION, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - } - else - { - DBG_Printf("Error: 1st listener data is missing\n"); - } -} - -/****************************************************************************** - * - * Update volume for 2D source and separation (panning) of 2D source - * - *****************************************************************************/ -EXPORT void HWRAPI (UpdateSourceParms) (INT32 chan, INT32 vol, INT32 sep) -{ - ALuint sid = AL_NONE; - ALint is2d = AL_FALSE; - if (chan > AL_INVALID && !alIsSource(ALstack[chan].ALsource)) - return; - else - sid = ALstack[chan].ALsource; - - alGetSourcei(sid, AL_SOURCE_RELATIVE, &is2d); - - if (!is2d) - return; - - if (vol != -1) - { - alSourcef(sid,AL_GAIN,ALvol(vol,256)); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: alSourcef, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - } - - if (sep != -1) - { - ALSetPan(sid,sep-NORMAL_SEP); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: ALSetPan, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - } -} - -// -------------------------------------------------------------------------- -// Set the global volume for sound effects -// -------------------------------------------------------------------------- -EXPORT void HWRAPI (SetGlobalSfxVolume) (INT32 vol) -{ - alListenerf(AL_GAIN, ALvol(vol,32)); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_GAIN, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } -} - -//Alam: Not Used? -EXPORT INT32 HWRAPI (SetCone) (INT32 chan, cone_def_t *cone_def) -{ - ALuint sid = AL_NONE; - ALint is2d = AL_FALSE; - if (chan > AL_INVALID && !alIsSource(ALstack[chan].ALsource)) - return AL_FALSE; - else - sid = ALstack[chan].ALsource; - - alGetSourcei(sid, AL_SOURCE_RELATIVE, &is2d); - - if(is2d || !cone_def) - return AL_FALSE; - - alSourcef(sid,AL_CONE_INNER_ANGLE,cone_def->inner); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_CONE_INNER_ANGLE, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - - alSourcef(sid,AL_CONE_OUTER_ANGLE,cone_def->outer); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_CONE_OUTER_ANGL, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - - alSourcei(sid,AL_CONE_OUTER_GAIN, cone_def->outer_gain); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_CONE_OUTER_GAIN, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - - return AL_TRUE; -} - -EXPORT void HWRAPI (Update3DSource) (INT32 chan, source3D_pos_t *sfx) -{ - ALuint sid = AL_NONE; - ALint is2d = AL_FALSE; - if (chan > AL_INVALID && !alIsSource(ALstack[chan].ALsource)) - return; - else - sid = ALstack[chan].ALsource; - - alGetSourcei(sid, AL_SOURCE_RELATIVE, &is2d); - - if (is2d) - return; - - alSource3f(sid, AL_POSITION, sfx->x, sfx->z, sfx->y); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_POSITION, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - - alSource3f(sid, AL_VELOCITY, sfx->momx, sfx->momz, sfx->momy); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("%s: AL_VELOCITY, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } -} - -//------------------------------------------------------------- -// Load new sound data into source -//------------------------------------------------------------- -EXPORT INT32 HWRAPI (ReloadSource) (INT32 chan, u_int sfxhandle) -{ - ALuint sid; - - if (chan <= AL_INVALID || !alIsSource(ALstack[chan].ALsource) || !alIsBuffer(sfxhandle)) - return AL_INVALID; - else - sid = ALstack[chan].ALsource; - - ALo_GetError(); - - alSourceQueueBuffers(sid, 1, &sfxhandle); - if (ALo_GetError() == AL_INVALID_OPERATION) //Alam: not needed? - { - alSourceStop(sid); - alSourcei(sid, AL_BUFFER, sfxhandle); - ALo_GetError(); - } - if (ALo_Lasterror != AL_NO_ERROR) - { - DBG_Printf("%s: alSourcei, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } - - return chan; -} - -/****************************************************************************** - * - * Destroy source and remove it from stack if it is a 2D source. - * Otherwise put source into cache - * - *****************************************************************************/ -EXPORT void HWRAPI (KillSource) (INT32 chan) -{ - if (chan > AL_INVALID && (ALsizei)chan <= allocated_sounds) - kill_sound(ALstack + chan); -} - -EXPORT u_int HWRAPI (AddSfx) (sfx_data_t *sfx) -{ - ALuint chan = (ALuint)AL_INVALID; - ALsizei freq = 11025; - ALubyte *data = NULL; - ALsizei size = 0; - - if (!sfx) - return 0; - else - { - data = ((ALubyte *)sfx->data)+8; - size = (ALsizei)(sfx->length-8); - } - - alGenBuffers(1, &chan); - if (ALo_GetError() != AL_NO_ERROR || !alIsBuffer(chan)) - { - DBG_Printf("S_OpenAl: Error %s when make an ALBuffer!\n",GetALErrorString(ALo_Lasterror)); - return (u_int)AL_INVALID; - } - - freq = getfreq(sfx->data, sfx->length); - - alBufferData(chan, AL_FORMAT_MONO8, data, size, freq); - if (ALo_GetError() != AL_NO_ERROR) - { - DBG_Printf("S_OpenAl: Error %s when setting up a alBuffer!\n",GetALErrorString(ALo_Lasterror)); - } - - return chan; -} - -EXPORT void HWRAPI (KillSfx) (u_int sfxhandle) -{ - ALuint ALsfx = sfxhandle; - if (!alIsBuffer(ALsfx)) - return; - alDeleteBuffers(1, &ALsfx); - if (ALo_GetError() == AL_INVALID_OPERATION) - { - // Buffer leak - } - else if (ALo_Lasterror != AL_NO_ERROR) - { - DBG_Printf("%s: alDeleteBuffers, %s", __FUNCTION__, GetALErrorString(ALo_Lasterror)); - } -} - -EXPORT void HWRAPI (GetHW3DSTitle) (char *buf, size_t size) -{ - strncpy(buf, "OpenAL", size); -} - - -#ifdef _WINDOWS -BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module - DWORD fdwReason, // reason for calling function - LPVOID lpvReserved) // reserved -{ - // Perform actions based on the reason for calling. - UNREFERENCED_PARAMETER(lpvReserved); - switch ( fdwReason ) - { - case DLL_PROCESS_ATTACH: - // Initialize once for each new process. - // Return FALSE to fail DLL load. -#ifdef DEBUG_TO_FILE - logstream = fopen("s_openal.log", "wt"); - if (logstream == NULL) - return FALSE; -#endif - DisableThreadLibraryCalls(hinstDLL); - break; - - case DLL_THREAD_ATTACH: - // Do thread-specific initialization. - break; - - case DLL_THREAD_DETACH: - // Do thread-specific cleanup. - break; - - case DLL_PROCESS_DETACH: - // Perform any necessary cleanup. -#ifdef DEBUG_TO_FILE - if ( logstream) - { - fclose(logstream); - logstream = NULL; - } -#endif - break; - } - return TRUE; // Successful DLL_PROCESS_ATTACH. -} -#elif !defined (_WINDOWS) - -// ************************************************************************** -// FUNCTIONS -// ************************************************************************** - -EXPORT void _init() -{ -#ifdef DEBUG_TO_FILE - logstream = fopen("s_openal.log", "w+"); -#endif -} - -EXPORT void _fini() -{ -#ifdef DEBUG_TO_FILE - if (logstream) - fclose(logstream); - logstream = NULL; -#endif -} -#endif - diff --git a/src/hardware/s_openal/s_openal.dev b/src/hardware/s_openal/s_openal.dev deleted file mode 100644 index c8fb9e62b..000000000 --- a/src/hardware/s_openal/s_openal.dev +++ /dev/null @@ -1,59 +0,0 @@ -[Project] -FileName=s_openal.dev -Name=s_openal -Ver=1 -IsCpp=1 -Type=3 -Compiler=-D_M_IX86=500_@@_-Wall_@@_-fexceptions_@@_-D_WINDOWS_@@_ -CppCompiler= -Includes= -Linker=--def ../s_mingw.def_@@_-lopenal32_@@_ -Libs= -UnitCount=1 -Folders= -ObjFiles= -PrivateResource= -ResourceIncludes= -MakeIncludes= -Icon= -ExeOutput=..\..\..\bin -ObjectOutput=..\..\..\objs\Mingw\s_opengl -OverrideOutput=0 -OverrideOutputName=s_openal.dll -HostApplication= -CommandLine= -UseCustomMakefile=0 -CustomMakefile= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=0000000010001001001001 - -[Unit1] -FileName=s_openal.c -Folder= -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion=0.1 -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename=s_openal.dll -ProductName=s_openal -ProductVersion=0.1 -AutoIncBuildNr=0 - diff --git a/src/hardware/s_openal/s_openal.dsp b/src/hardware/s_openal/s_openal.dsp deleted file mode 100644 index ac7fbaa84..000000000 --- a/src/hardware/s_openal/s_openal.dsp +++ /dev/null @@ -1,98 +0,0 @@ -# Microsoft Developer Studio Project File - Name="s_openal" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=s_openal - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "s_openal.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "s_openal.mak" CFG="s_openal - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "s_openal - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "s_openal - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "s_openal - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\..\..\bin\VC\Release\s_openal" -# PROP Intermediate_Dir "..\..\..\objs\VC\Release\s_openal" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "S_OPENAL_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "__WIN32__" /D "__MSC__" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /win32 -# SUBTRACT MTL /mktyplib203 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 OpenAL32.lib /nologo /dll /pdb:"..\..\..\bin\VC\Release\s_openal.pdb" /machine:I386 /out:"C:\srb2demo2\s_openal.dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "s_openal - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\..\..\bin\VC\Debug\s_openal" -# PROP Intermediate_Dir "..\..\..\objs\VC\Debug\s_openal" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "S_OPENAL_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WIN32__" /D "__MSC__" /D "_MBCS" /D "_USRDLL" /D "S_OPENAL_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 OpenAL32.lib /nologo /dll /pdb:"..\..\..\bin\VC\Debug\s_openal.pdb" /debug /machine:I386 /out:"C:\srb2demo2\s_openaldebug.dll" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "s_openal - Win32 Release" -# Name "s_openal - Win32 Debug" -# Begin Source File - -SOURCE=.\s_openal.c -# End Source File -# End Target -# End Project diff --git a/src/info.c b/src/info.c index 91fb99b5a..ea2017e17 100644 --- a/src/info.c +++ b/src/info.c @@ -21,7 +21,6 @@ #include "d_player.h" #include "lzf.h" -// Hey, moron! If you change this table, don't forget about the sprite enum in info.h and the sprite lights in hw_light.c! char sprnames[NUMSPRITES + 1][5] = { "NULL","UNKN","THOK","PLAY","POSS","SPOS","FISH","BUZZ","RBUZ","JETB", diff --git a/src/info.h b/src/info.h index 6b2726f7e..4d24f729a 100644 --- a/src/info.h +++ b/src/info.h @@ -457,7 +457,6 @@ extern boolean actionsoverridden[NUMACTIONS]; #define NUMSPRITEFREESLOTS NUMMOBJFREESLOTS #define NUMSTATEFREESLOTS (NUMMOBJFREESLOTS*8) -// Hey, moron! If you change this table, don't forget about sprnames in info.c and the sprite lights in hw_light.c! typedef enum sprite { SPR_NULL, // invisible object diff --git a/src/locale/en.po b/src/locale/en.po index ce4510802..b20dd837f 100644 --- a/src/locale/en.po +++ b/src/locale/en.po @@ -1910,15 +1910,6 @@ msgstr "" msgid " Not found: %s\n" msgstr "" -#: hardware/s_ds3d/s_ds3d.c:617 p_tick.c:168 sdl/i_sound.c:1347 -#: win32/win_snd.c:1073 win32/win_snd.c:1431 -msgid "Done\n" -msgstr "" - -#: hardware/s_ds3d/s_ds3d.c:617 win32/win_snd.c:1073 -msgid "Failed\n" -msgstr "" - #: hu_stuff.c:375 msgid "The chat is muted. You can't say anything at the moment.\n" msgstr "" @@ -3174,21 +3165,6 @@ msgstr "" msgid "I_ShutdownMusic: " msgstr "" -#: sdl/i_sound.c:1494 -msgid " disabled loading FMOD\n" -msgstr "" - -#: sdl/i_sound.c:1513 -msgid " failed to load FMOD\n" -msgstr "" - -#: sdl/i_sound.c:1522 win32/win_snd.c:1237 -#, c-format -msgid "" -"Wrong FMOD DLL version.\n" -"You should be using FMOD %s\n" -msgstr "" - #: sdl/i_sound.c:1611 msgid "I_InitMusic:" msgstr "" @@ -3803,12 +3779,6 @@ msgstr "" msgid "%d mixer devices available\n" msgstr "" -#: win32/win_snd.c:1227 -msgid "" -" failed to load FMOD\n" -" no DigiMusic support\n" -msgstr "" - #: win32/win_snd.c:1289 msgid "No MIDI devices available, music is disabled\n" msgstr "" diff --git a/src/locale/srb2.pot b/src/locale/srb2.pot index c61cbcc97..a25ea69ae 100644 --- a/src/locale/srb2.pot +++ b/src/locale/srb2.pot @@ -1994,15 +1994,6 @@ msgstr "" msgid " Not found: %s\n" msgstr "" -#: hardware/s_ds3d/s_ds3d.c:617 p_tick.c:168 sdl/i_sound.c:1347 -#: win32/win_snd.c:1071 win32/win_snd.c:1429 -msgid "Done\n" -msgstr "" - -#: hardware/s_ds3d/s_ds3d.c:617 win32/win_snd.c:1071 -msgid "Failed\n" -msgstr "" - #: hu_stuff.c:405 msgid "The chat is muted. You can't say anything at the moment.\n" msgstr "" @@ -3377,21 +3368,6 @@ msgstr "" msgid "I_ShutdownMusic: " msgstr "" -#: sdl/i_sound.c:1494 -msgid " disabled loading FMOD\n" -msgstr "" - -#: sdl/i_sound.c:1513 -msgid " failed to load FMOD\n" -msgstr "" - -#: sdl/i_sound.c:1522 win32/win_snd.c:1235 -#, c-format -msgid "" -"Wrong FMOD DLL version.\n" -"You should be using FMOD %s\n" -msgstr "" - #: sdl/i_sound.c:1611 msgid "I_InitMusic:" msgstr "" @@ -3999,12 +3975,6 @@ msgstr "" msgid "%d mixer devices available\n" msgstr "" -#: win32/win_snd.c:1225 -msgid "" -" failed to load FMOD\n" -" no DigiMusic support\n" -msgstr "" - #: win32/win_snd.c:1287 msgid "No MIDI devices available, music is disabled\n" msgstr "" diff --git a/src/p_enemy.c b/src/p_enemy.c index 6e47def15..8f0967e14 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -25,10 +25,6 @@ #include "lua_hook.h" #include "k_kart.h" // SRB2kart -#ifdef HW3SOUND -#include "hardware/hw3sound.h" -#endif - boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor); INT32 var1; diff --git a/src/p_spec.c b/src/p_spec.c index 1c3970b78..a300f8cbc 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -40,10 +40,6 @@ #include "k_kart.h" // SRB2kart #include "console.h" // CON_LogMessage -#ifdef HW3SOUND -#include "hardware/hw3sound.h" -#endif - // Not sure if this is necessary, but it was in w_wad.c, so I'm putting it here too -Shadow Hog #include diff --git a/src/p_user.c b/src/p_user.c index e9942bdf8..7dce8248d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -50,10 +50,6 @@ #include "console.h" // CON_LogMessage #include "m_menu.h" -#ifdef HW3SOUND -#include "hardware/hw3sound.h" -#endif - #ifdef HWRENDER #include "hardware/hw_main.h" #endif diff --git a/src/s_sound.c b/src/s_sound.c index 119b0cbb9..4a4134c49 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -33,13 +33,7 @@ #include "lua_hook.h" // MusicChange hook -#ifdef HW3SOUND -// 3D Sound Interface -#include "hardware/hw3sound.h" -#else static boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 *vol, INT32 *sep, INT32 *pitch, sfxinfo_t *sfxinfo); -#endif - static void SetChannelsNum(void); static void Command_Tunes_f(void); static void Command_RestartAudio_f(void); @@ -330,14 +324,6 @@ static void SetChannelsNum(void) if (cv_numChannels.value == 999999999) //Alam_GBC: OH MY ROD!(ROD rimmiced with GOD!) CV_StealthSet(&cv_numChannels,cv_numChannels.defaultvalue); -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - { - HW3S_SetSourcesNum(); - return; - } -#endif - if (cv_numChannels.value) channels = (channel_t *)Z_Calloc(cv_numChannels.value * sizeof (channel_t), PU_STATIC, NULL); numofchannels = (channels ? cv_numChannels.value : 0); @@ -387,14 +373,6 @@ void S_StopSounds(void) { INT32 cnum; -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - { - HW3S_StopSounds(); - return; - } -#endif - // kill all playing sounds at start of level for (cnum = 0; cnum < numofchannels; cnum++) if (channels[cnum].sfxinfo) @@ -409,13 +387,7 @@ void S_StopSoundByID(void *origin, sfxenum_t sfx_id) // be stopped by new sounds. if (!origin) return; -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - { - HW3S_StopSoundByID(origin, sfx_id); - return; - } -#endif + for (cnum = 0; cnum < numofchannels; cnum++) { if (channels[cnum].sfxinfo == &S_sfx[sfx_id] && channels[cnum].origin == origin) @@ -429,13 +401,6 @@ void S_StopSoundByNum(sfxenum_t sfxnum) { INT32 cnum; -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - { - HW3S_StopSoundByNum(sfxnum); - return; - } -#endif for (cnum = 0; cnum < numofchannels; cnum++) { if (channels[cnum].sfxinfo == &S_sfx[sfxnum]) @@ -510,14 +475,6 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) } } -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - { - HW3S_StartSound(origin, sfx_id); - return; - }; -#endif - for (i = 0; i <= splitscreen; i++) { player_t *player = &players[displayplayers[i]]; @@ -653,12 +610,7 @@ void S_StartSound(const void *origin, sfxenum_t sfx_id) return; // the volume is handled 8 bits -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - HW3S_StartSound(origin, sfx_id); - else -#endif - S_StartSoundAtVolume(origin, sfx_id, 255); + S_StartSoundAtVolume(origin, sfx_id, 255); } void S_StopSound(void *origin) @@ -670,13 +622,6 @@ void S_StopSound(void *origin) if (!origin) return; -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - { - HW3S_StopSound(origin); - return; - } -#endif for (cnum = 0; cnum < numofchannels; cnum++) { if (channels[cnum].sfxinfo && channels[cnum].origin == origin) @@ -723,7 +668,6 @@ void S_UpdateSounds(void) I_UpdateMumble(NULL, listener[0]); #endif - // Stop cutting FMOD out. WE'RE sick of it. I_UpdateSound(); return; } @@ -758,15 +702,6 @@ void S_UpdateSounds(void) I_UpdateMumble(players[consoleplayer].mo, listener[0]); #endif -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - { - HW3S_UpdateSources(); - I_UpdateSound(); - return; - } -#endif - for (i = 0; i <= splitscreen; i++) { player_t *player = &players[displayplayers[i]]; @@ -881,12 +816,8 @@ void S_SetSfxVolume(INT32 volume) CV_SetValue(&cv_soundvolume, volume&0x1F); actualsfxvolume = cv_soundvolume.value; // check for change of var -#ifdef HW3SOUND - hws_mode == HWS_DEFAULT_MODE ? I_SetSfxVolume(volume&0x1F) : HW3S_SetSfxVolume(volume&0x1F); -#else // now hardware volume I_SetSfxVolume(volume&0x1F); -#endif } void S_ClearSfx(void) @@ -1075,11 +1006,6 @@ INT32 S_OriginPlaying(void *origin) if (!origin) return false; -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - return HW3S_OriginPlaying(origin); -#endif - for (cnum = 0; cnum < numofchannels; cnum++) if (channels[cnum].origin == origin) return 1; @@ -1092,11 +1018,6 @@ INT32 S_IdPlaying(sfxenum_t id) { INT32 cnum; -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - return HW3S_IdPlaying(id); -#endif - for (cnum = 0; cnum < numofchannels; cnum++) if ((size_t)(channels[cnum].sfxinfo - S_sfx) == (size_t)id) return 1; @@ -1111,11 +1032,6 @@ INT32 S_SoundPlaying(void *origin, sfxenum_t id) if (!origin) return 0; -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - return HW3S_SoundPlaying(origin, id); -#endif - for (cnum = 0; cnum < numofchannels; cnum++) { if (channels[cnum].origin == origin diff --git a/src/s_sound.h b/src/s_sound.h index be4ed381d..124b74de3 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -296,10 +296,8 @@ void S_StartSoundName(void *mo, const char *soundname); void S_StopSoundByID(void *origin, sfxenum_t sfx_id); void S_StopSoundByNum(sfxenum_t sfxnum); -#ifndef HW3SOUND #define S_StartAttackSound S_StartSound #define S_StartScreamSound S_StartSound -#endif #ifdef MUSICSLOT_COMPATIBILITY // For compatibility with code/scripts relying on older versions diff --git a/src/sdl/Makefile.cfg b/src/sdl/Makefile.cfg index 72a94dca8..3cf04509b 100644 --- a/src/sdl/Makefile.cfg +++ b/src/sdl/Makefile.cfg @@ -90,22 +90,6 @@ ifdef MINGW endif endif -ifndef NOHW -ifdef OPENAL -ifdef MINGW - LIBS:=-lopenal32 $(LIBS) -else - LIBS:=-lopenal $(LIBS) -endif -else -ifdef MINGW -ifdef DS3D - LIBS:=-ldsound -luuid $(LIBS) -endif -endif -endif -endif - ifndef NOLIBBACKTRACE OPTS+=-DHAVE_LIBBACKTRACE ifdef MINGW64 diff --git a/src/sdl/Srb2SDL.dsp b/src/sdl/Srb2SDL.dsp index 6f799f4fb..35e5ec32b 100644 --- a/src/sdl/Srb2SDL.dsp +++ b/src/sdl/Srb2SDL.dsp @@ -45,7 +45,7 @@ MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G5 /W3 /GX /Zi /Ot /Og /Oi /Op /Oy /Ob1 /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "NDEBUG" /D "SDLMAIN" /D "NO_STDIO_REDIRECT" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "HAVE_SDL" /D "HWRENDER" /D "HW3SOUND" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GF /c +# ADD CPP /nologo /G5 /W3 /GX /Zi /Ot /Og /Oi /Op /Oy /Ob1 /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "NDEBUG" /D "SDLMAIN" /D "NO_STDIO_REDIRECT" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "HAVE_SDL" /D "HWRENDER" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GF /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" # SUBTRACT RSC /x @@ -72,7 +72,7 @@ LINK32=link.exe # PROP Target_Dir "" MTL=midl.exe # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G6 /W4 /WX /Gm /GX /ZI /Od /Op /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "_DEBUG" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "HAVE_SDL" /D "HWRENDER" /D "HW3SOUND" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GZ /c +# ADD CPP /nologo /G6 /W4 /WX /Gm /GX /ZI /Od /Op /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "_DEBUG" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "HAVE_SDL" /D "HWRENDER" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" @@ -536,18 +536,6 @@ SOURCE=..\y_inter.h # PROP Default_Filter "" # Begin Source File -SOURCE=..\hardware\hw3dsdrv.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw3sound.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw3sound.h -# End Source File -# Begin Source File - SOURCE=..\hardware\hw_bsp.c # End Source File # Begin Source File @@ -580,14 +568,6 @@ SOURCE=..\hardware\hw_glob.h # End Source File # Begin Source File -SOURCE=..\hardware\hw_light.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_light.h -# End Source File -# Begin Source File - SOURCE=..\hardware\hw_main.c # End Source File # Begin Source File @@ -604,11 +584,6 @@ SOURCE=..\hardware\hw_md2.h # End Source File # Begin Source File -SOURCE=..\hardware\hws_data.h -# End Source File -# End Group -# Begin Group "I_Interface" - # PROP Default_Filter "" # Begin Source File diff --git a/src/sdl/Srb2SDL.dsw b/src/sdl/Srb2SDL.dsw index 4f8f7bdce..888d2fcf3 100644 --- a/src/sdl/Srb2SDL.dsw +++ b/src/sdl/Srb2SDL.dsw @@ -36,18 +36,6 @@ Package=<4> ############################################################################### -Project: "s_openal"=..\hardware\s_openal\s_openal.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - Project: "zlib"=..\..\libs\zlib\projects\visualc6\zlib.dsp - Package Owner=<4> Package=<5> diff --git a/src/sdl/Srb2SDL.props b/src/sdl/Srb2SDL.props index 75839a5b2..f02b9b35e 100644 --- a/src/sdl/Srb2SDL.props +++ b/src/sdl/Srb2SDL.props @@ -6,10 +6,10 @@ - HAVE_ZLIB;HAVE_LIBGME;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) + HAVE_ZLIB;HAVE_LIBGME;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) - USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) + USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) - \ No newline at end of file + diff --git a/src/sdl/hwsym_sdl.c b/src/sdl/hwsym_sdl.c index d3da79355..4b1988c6f 100644 --- a/src/sdl/hwsym_sdl.c +++ b/src/sdl/hwsym_sdl.c @@ -43,10 +43,6 @@ #define _CREATE_DLL_ // necessary for Unix AND Windows -#ifdef HW3SOUND -#include "../hardware/hw3dsdrv.h" -#endif - #define GETFUNC(func) \ else if (0 == strcmp(#func, funcName)) \ funcPointer = &func \ @@ -66,35 +62,16 @@ void *hwSym(const char *funcName,void *handle) { void *funcPointer = NULL; if (0) ; -#ifdef STATIC3DS - GETFUNC(Startup); - GETFUNC(AddSfx); - GETFUNC(AddSource); - GETFUNC(StartSource); - GETFUNC(StopSource); - GETFUNC(GetHW3DSVersion); - GETFUNC(BeginFrameUpdate); - GETFUNC(EndFrameUpdate); - GETFUNC(IsPlaying); - GETFUNC(UpdateListener); - GETFUNC(UpdateSourceParms); - GETFUNC(SetGlobalSfxVolume); - GETFUNC(SetCone); - GETFUNC(Update3DSource); - GETFUNC(ReloadSource); - GETFUNC(KillSource); - GETFUNC(Shutdown); - GETFUNC(GetHW3DSTitle); -#endif #ifdef NOLOADSO else funcPointer = handle; #else else if (handle) - funcPointer = SDL_LoadFunction(handle,funcName); + funcPointer = SDL_LoadFunction(handle, funcName); #endif if (!funcPointer) I_OutputMsg("hwSym for %s: %s\n", funcName, SDL_GetError()); + return funcPointer; } @@ -103,8 +80,6 @@ void *hwSym(const char *funcName,void *handle) \param hwfile Open a handle to the SO \return Handle to SO - - */ void *hwOpen(const char *hwfile) @@ -125,8 +100,6 @@ void *hwOpen(const char *hwfile) \param handle Close the handle of the SO \return void - - */ void hwClose(void *handle) diff --git a/src/sdl/macosx/Srb2mac.pbproj/project.pbxproj b/src/sdl/macosx/Srb2mac.pbproj/project.pbxproj index a4888ec50..24f05a04c 100644 --- a/src/sdl/macosx/Srb2mac.pbproj/project.pbxproj +++ b/src/sdl/macosx/Srb2mac.pbproj/project.pbxproj @@ -255,12 +255,6 @@ path = ../../../bin/Resources/drill.dta; refType = 2; }; - 6755C8BF101802C300A80195 = { - isa = PBXFileReference; - name = fmod.dll; - path = ../../../bin/Resources/fmod.dll; - refType = 2; - }; 6755C8C0101802C300A80195 = { isa = PBXFileReference; name = knux.plr; @@ -425,14 +419,6 @@ name = r_opengl; refType = 4; }; - 677B5ECA10180D7100A80195 = { - children = ( - 84F202CA08A92AA0000C01D8, - ); - isa = PBXGroup; - name = s_openal; - refType = 4; - }; 67B2D0C91018779900A80195 = { fileRef = 84177748085A1097000C01D8; isa = PBXBuildFile; @@ -1071,20 +1057,6 @@ path = ../../hardware/hw_glob.h; refType = 2; }; - 8417773D085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_light.c; - path = ../../hardware/hw_light.c; - refType = 2; - }; - 8417773E085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_light.h; - path = ../../hardware/hw_light.h; - refType = 2; - }; 8417773F085A106C000C01D8 = { fileEncoding = 30; isa = PBXFileReference; @@ -1113,41 +1085,6 @@ path = ../../hardware/hw_md2.h; refType = 2; }; - 84177743085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_trick.c; - path = ../../hardware/hw_trick.c; - refType = 2; - }; - 84177744085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw3dsdrv.h; - path = ../../hardware/hw3dsdrv.h; - refType = 2; - }; - 84177745085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw3sound.c; - path = ../../hardware/hw3sound.c; - refType = 2; - }; - 84177746085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw3sound.h; - path = ../../hardware/hw3sound.h; - refType = 2; - }; - 84177747085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hws_data.h; - path = ../../hardware/hws_data.h; - refType = 2; - }; 84177748085A1097000C01D8 = { fileEncoding = 30; isa = PBXFileReference; @@ -2136,7 +2073,7 @@ buildSettings = { DEBUGGING_SYMBOLS = NO; FRAMEWORK_SEARCH_PATHS = "\"$(LOCAL_LIBRARY_DIR)/Frameworks\""; - HEADER_SEARCH_PATHS = "\"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL_mixer.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/OpenAL.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/libpng.framework/Headers\""; + HEADER_SEARCH_PATHS = "\"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL_mixer.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/libpng.framework/Headers\""; INSTALL_PATH = "$(HOME)/Applications"; JAVA_COMPILER_DEBUGGING_SYMBOLS = NO; OPTIMIZATION_CFLAGS = "-O2"; @@ -2328,7 +2265,7 @@ ); buildSettings = { FRAMEWORK_SEARCH_PATHS = "\"$(LOCAL_LIBRARY_DIR)/Frameworks\""; - HEADER_SEARCH_PATHS = "\"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL_mixer.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/OpenAL.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/libpng.framework/Headers\""; + HEADER_SEARCH_PATHS = "\"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL_mixer.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/libpng.framework/Headers\""; INSTALL_PATH = "$(HOME)/Applications"; OPTIMIZATION_CFLAGS = "-O0"; OTHER_CFLAGS = "-DMAC_ALERT -DUNIXCOMMON -DSDLMAIN -DHAVE_MIXER -DHAVE_PNG -D_BIG_ENDIAN -DSTDC_HEADERS -DSDL -Wall -W -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -fno-strict-aliasing -fno-exceptions -D_DEBUG"; @@ -3521,19 +3458,6 @@ settings = { }; }; - 84F202C708A92A5D000C01D8 = { - isa = PBXFrameworkReference; - name = OpenAL.framework; - path = /Library/Frameworks/OpenAL.framework; - refType = 0; - }; - 84F202CA08A92AA0000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = s_openal.c; - path = ../../hardware/s_openal/s_openal.c; - refType = 2; - }; }; rootObject = 84177702085A0C64000C01D8; } diff --git a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj index 9ec22ebcc..c95642240 100644 --- a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj +++ b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj @@ -13,13 +13,10 @@ 1E32C4290B6E6D5D0029E058 /* libpng.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E32C4140B6E6D5D0029E058 /* libpng.framework */; }; 1E32C42B0B6E6D6E0029E058 /* libpng.framework in Copy Frameworks into .app bundle */ = {isa = PBXBuildFile; fileRef = 1E32C4140B6E6D5D0029E058 /* libpng.framework */; }; 1E44AE750B67CC2B00BAD059 /* hw_bsp.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE610B67CC2B00BAD059 /* hw_bsp.c */; }; - 1E44AE770B67CC2B00BAD059 /* hw3sound.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE630B67CC2B00BAD059 /* hw3sound.c */; }; 1E44AE780B67CC2B00BAD059 /* hw_cache.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE640B67CC2B00BAD059 /* hw_cache.c */; }; - 1E44AE7C0B67CC2B00BAD059 /* hw_light.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE680B67CC2B00BAD059 /* hw_light.c */; }; 1E44AE800B67CC2B00BAD059 /* hw_draw.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE6C0B67CC2B00BAD059 /* hw_draw.c */; }; 1E44AE820B67CC2B00BAD059 /* hw_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE6E0B67CC2B00BAD059 /* hw_main.c */; }; 1E44AE840B67CC2B00BAD059 /* hw_md2.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE700B67CC2B00BAD059 /* hw_md2.c */; }; - 1E44AE860B67CC2B00BAD059 /* hw_trick.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE720B67CC2B00BAD059 /* hw_trick.c */; }; 1E44AEA40B67CC8500BAD059 /* d_clisrv.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE8D0B67CC8400BAD059 /* d_clisrv.c */; }; 1E44AEA70B67CC8500BAD059 /* d_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE900B67CC8400BAD059 /* d_main.c */; }; 1E44AEA80B67CC8500BAD059 /* d_net.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE910B67CC8500BAD059 /* d_net.c */; }; @@ -174,16 +171,11 @@ 1E32C4140B6E6D5D0029E058 /* libpng.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libpng.framework; path = /Library/Frameworks/libpng.framework; sourceTree = ""; }; 1E44AE440B67CBE800BAD059 /* music.dta */ = {isa = PBXFileReference; lastKnownFileType = text; name = music.dta; path = ../../../bin/Resources/music.dta; sourceTree = SOURCE_ROOT; }; 1E44AE4B0B67CBE800BAD059 /* srb2.wad */ = {isa = PBXFileReference; lastKnownFileType = text; name = srb2.wad; path = ../../../bin/Resources/srb2.wad; sourceTree = SOURCE_ROOT; }; - 1E44AE600B67CC2B00BAD059 /* hw3dsdrv.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw3dsdrv.h; path = ../../hardware/hw3dsdrv.h; sourceTree = SOURCE_ROOT; }; 1E44AE610B67CC2B00BAD059 /* hw_bsp.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_bsp.c; path = ../../hardware/hw_bsp.c; sourceTree = SOURCE_ROOT; }; 1E44AE620B67CC2B00BAD059 /* hw_defs.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_defs.h; path = ../../hardware/hw_defs.h; sourceTree = SOURCE_ROOT; }; - 1E44AE630B67CC2B00BAD059 /* hw3sound.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw3sound.c; path = ../../hardware/hw3sound.c; sourceTree = SOURCE_ROOT; }; 1E44AE640B67CC2B00BAD059 /* hw_cache.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_cache.c; path = ../../hardware/hw_cache.c; sourceTree = SOURCE_ROOT; }; 1E44AE650B67CC2B00BAD059 /* hw_dll.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_dll.h; path = ../../hardware/hw_dll.h; sourceTree = SOURCE_ROOT; }; 1E44AE660B67CC2B00BAD059 /* hw_gl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_gl.h; path = ../../hardware/hw_gl.h; sourceTree = SOURCE_ROOT; }; - 1E44AE680B67CC2B00BAD059 /* hw_light.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_light.c; path = ../../hardware/hw_light.c; sourceTree = SOURCE_ROOT; }; - 1E44AE690B67CC2B00BAD059 /* hw_light.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_light.h; path = ../../hardware/hw_light.h; sourceTree = SOURCE_ROOT; }; - 1E44AE6A0B67CC2B00BAD059 /* hw3sound.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw3sound.h; path = ../../hardware/hw3sound.h; sourceTree = SOURCE_ROOT; }; 1E44AE6B0B67CC2B00BAD059 /* hw_data.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_data.h; path = ../../hardware/hw_data.h; sourceTree = SOURCE_ROOT; }; 1E44AE6C0B67CC2B00BAD059 /* hw_draw.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_draw.c; path = ../../hardware/hw_draw.c; sourceTree = SOURCE_ROOT; }; 1E44AE6D0B67CC2B00BAD059 /* hw_glob.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_glob.h; path = ../../hardware/hw_glob.h; sourceTree = SOURCE_ROOT; }; @@ -191,9 +183,6 @@ 1E44AE6F0B67CC2B00BAD059 /* hw_main.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_main.h; path = ../../hardware/hw_main.h; sourceTree = SOURCE_ROOT; }; 1E44AE700B67CC2B00BAD059 /* hw_md2.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_md2.c; path = ../../hardware/hw_md2.c; sourceTree = SOURCE_ROOT; }; 1E44AE710B67CC2B00BAD059 /* hw_md2.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_md2.h; path = ../../hardware/hw_md2.h; sourceTree = SOURCE_ROOT; }; - 1E44AE720B67CC2B00BAD059 /* hw_trick.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_trick.c; path = ../../hardware/hw_trick.c; sourceTree = SOURCE_ROOT; }; - 1E44AE730B67CC2B00BAD059 /* hws_data.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hws_data.h; path = ../../hardware/hws_data.h; sourceTree = SOURCE_ROOT; }; - 1E44AE8A0B67CC6000BAD059 /* asm_defs.inc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.pascal; name = asm_defs.inc; path = ../../asm_defs.inc; sourceTree = SOURCE_ROOT; }; 1E44AE8D0B67CC8400BAD059 /* d_clisrv.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = d_clisrv.c; path = ../../d_clisrv.c; sourceTree = SOURCE_ROOT; }; 1E44AE8E0B67CC8400BAD059 /* d_clisrv.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = d_clisrv.h; path = ../../d_clisrv.h; sourceTree = SOURCE_ROOT; }; 1E44AE8F0B67CC8400BAD059 /* d_event.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = d_event.h; path = ../../d_event.h; sourceTree = SOURCE_ROOT; }; @@ -527,16 +516,11 @@ 1E44AE5C0B67CC0F00BAD059 /* Hw_Hardware */ = { isa = PBXGroup; children = ( - 1E44AE600B67CC2B00BAD059 /* hw3dsdrv.h */, 1E44AE610B67CC2B00BAD059 /* hw_bsp.c */, 1E44AE620B67CC2B00BAD059 /* hw_defs.h */, - 1E44AE630B67CC2B00BAD059 /* hw3sound.c */, 1E44AE640B67CC2B00BAD059 /* hw_cache.c */, 1E44AE650B67CC2B00BAD059 /* hw_dll.h */, 1E44AE660B67CC2B00BAD059 /* hw_gl.h */, - 1E44AE680B67CC2B00BAD059 /* hw_light.c */, - 1E44AE690B67CC2B00BAD059 /* hw_light.h */, - 1E44AE6A0B67CC2B00BAD059 /* hw3sound.h */, 1E44AE6B0B67CC2B00BAD059 /* hw_data.h */, 1E44AE6C0B67CC2B00BAD059 /* hw_draw.c */, 1E44AE6D0B67CC2B00BAD059 /* hw_glob.h */, @@ -544,8 +528,6 @@ 1E44AE6F0B67CC2B00BAD059 /* hw_main.h */, 1E44AE700B67CC2B00BAD059 /* hw_md2.c */, 1E44AE710B67CC2B00BAD059 /* hw_md2.h */, - 1E44AE720B67CC2B00BAD059 /* hw_trick.c */, - 1E44AE730B67CC2B00BAD059 /* hws_data.h */, ); name = Hw_Hardware; sourceTree = ""; @@ -1072,13 +1054,10 @@ buildActionMask = 2147483647; files = ( 1E44AE750B67CC2B00BAD059 /* hw_bsp.c in Sources */, - 1E44AE770B67CC2B00BAD059 /* hw3sound.c in Sources */, 1E44AE780B67CC2B00BAD059 /* hw_cache.c in Sources */, - 1E44AE7C0B67CC2B00BAD059 /* hw_light.c in Sources */, 1E44AE800B67CC2B00BAD059 /* hw_draw.c in Sources */, 1E44AE820B67CC2B00BAD059 /* hw_main.c in Sources */, 1E44AE840B67CC2B00BAD059 /* hw_md2.c in Sources */, - 1E44AE860B67CC2B00BAD059 /* hw_trick.c in Sources */, 1E44AEA40B67CC8500BAD059 /* d_clisrv.c in Sources */, 1E44AEA70B67CC8500BAD059 /* d_main.c in Sources */, 1E44AEA80B67CC8500BAD059 /* d_net.c in Sources */, @@ -1108,7 +1087,6 @@ 1E44AF220B67CE4100BAD059 /* mserv.c in Sources */, 1E44AF3C0B67CE5F00BAD059 /* p_enemy.c in Sources */, 1E44AF3D0B67CE5F00BAD059 /* p_inter.c in Sources */, - 1E44AF3E0B67CE5F00BAD059 /* p_fab.c in Sources */, 1E44AF3F0B67CE5F00BAD059 /* p_lights.c in Sources */, 1E44AF400B67CE5F00BAD059 /* p_map.c in Sources */, 1E44AF410B67CE5F00BAD059 /* p_maputl.c in Sources */, diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 33714f32a..58aa5ee91 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -69,12 +69,6 @@ #include "../d_main.h" -#ifdef HW3SOUND -#include "../hardware/hw3dsdrv.h" -#include "../hardware/hw3sound.h" -#include "hwsym_sdl.h" -#endif - #ifdef HAVE_LIBGME #include "gme/gme.h" #endif @@ -195,11 +189,7 @@ static void Snd_LockAudio(void) //Alam: Lock audio data and uninstall audio call { if (Snd_Mutex) SDL_LockMutex(Snd_Mutex); else if (sound_disabled) return; - else if (midi_disabled && digital_disabled -#ifdef HW3SOUND - && hws_mode == HWS_DEFAULT_MODE -#endif - ) SDL_LockAudio(); + else if (midi_disabled && digital_disabled) SDL_LockAudio(); #ifdef HAVE_MIXER else if (musicStarted) Mix_SetPostMix(NULL, NULL); #endif @@ -209,11 +199,7 @@ static void Snd_UnlockAudio(void) //Alam: Unlock audio data and reinstall audio { if (Snd_Mutex) SDL_UnlockMutex(Snd_Mutex); else if (sound_disabled) return; - else if (midi_disabled && digital_disabled -#ifdef HW3SOUND - && hws_mode == HWS_DEFAULT_MODE -#endif - ) SDL_UnlockAudio(); + else if (midi_disabled && digital_disabled) SDL_UnlockAudio(); #ifdef HAVE_MIXER else if (musicStarted) Mix_SetPostMix(audio.callback, audio.userdata); #endif @@ -536,11 +522,6 @@ void *I_GetSfx(sfxinfo_t *sfx) // else if (sfx->lumpnum != S_GetSfxLumpNum(sfx)) // I_FreeSfx(sfx); -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - return HW3S_GetSfx(sfx); -#endif - if (sfx->data) return sfx->data; //Alam: I have it done! @@ -555,39 +536,31 @@ void I_FreeSfx(sfxinfo_t * sfx) // if (sfx->lumpnum<0) // return; -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - { - HW3S_FreeSfx(sfx); - } - else -#endif - { - size_t i; + size_t i; - for (i = 1; i < NUMSFX; i++) + for (i = 1; i < NUMSFX; i++) + { + // Alias? Example is the chaingun sound linked to pistol. + if (S_sfx[i].data == sfx->data) { - // Alias? Example is the chaingun sound linked to pistol. - if (S_sfx[i].data == sfx->data) - { - if (S_sfx+i != sfx) S_sfx[i].data = NULL; - S_sfx[i].lumpnum = LUMPERROR; - S_sfx[i].length = 0; - } + if (S_sfx+i != sfx) S_sfx[i].data = NULL; + S_sfx[i].lumpnum = LUMPERROR; + S_sfx[i].length = 0; } - //Snd_LockAudio(); //Alam: too much? - // Loop all channels, check. - for (i = 0; i < NUM_CHANNELS; i++) - { - // Active, and using the same SFX? - if (channels[i].end && channels[i].id == sfx->data) - { - channels[i].end = NULL; // Reset. - } - } - //Snd_UnlockAudio(); //Alam: too much? - Z_Free(sfx->data); } + //Snd_LockAudio(); //Alam: too much? + // Loop all channels, check. + for (i = 0; i < NUM_CHANNELS; i++) + { + // Active, and using the same SFX? + if (channels[i].end && channels[i].id == sfx->data) + { + channels[i].end = NULL; // Reset. + } + } + //Snd_UnlockAudio(); //Alam: too much? + Z_Free(sfx->data); + sfx->data = NULL; sfx->lumpnum = LUMPERROR; } @@ -1081,62 +1054,6 @@ void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch) } -#ifdef HW3SOUND - -static void *soundso = NULL; - -static INT32 Init3DSDriver(const char *soName) -{ - if (soName) soundso = hwOpen(soName); -#if defined (_WIN32) && defined (_X86_) && !defined (STATIC3DS) - HW3DS.pfnStartup = hwSym("Startup@8",soundso); - HW3DS.pfnShutdown = hwSym("Shutdown@0",soundso); - HW3DS.pfnAddSfx = hwSym("AddSfx@4",soundso); - HW3DS.pfnAddSource = hwSym("AddSource@8",soundso); - HW3DS.pfnStartSource = hwSym("StartSource@4",soundso); - HW3DS.pfnStopSource = hwSym("StopSource@4",soundso); - HW3DS.pfnGetHW3DSVersion = hwSym("GetHW3DSVersion@0",soundso); - HW3DS.pfnBeginFrameUpdate = hwSym("BeginFrameUpdate@0",soundso); - HW3DS.pfnEndFrameUpdate = hwSym("EndFrameUpdate@0",soundso); - HW3DS.pfnIsPlaying = hwSym("IsPlaying@4",soundso); - HW3DS.pfnUpdateListener = hwSym("UpdateListener@8",soundso); - HW3DS.pfnUpdateSourceParms = hwSym("UpdateSourceParms@12",soundso); - HW3DS.pfnSetCone = hwSym("SetCone@8",soundso); - HW3DS.pfnSetGlobalSfxVolume = hwSym("SetGlobalSfxVolume@4",soundso); - HW3DS.pfnUpdate3DSource = hwSym("Update3DSource@8",soundso); - HW3DS.pfnReloadSource = hwSym("ReloadSource@8",soundso); - HW3DS.pfnKillSource = hwSym("KillSource@4",soundso); - HW3DS.pfnKillSfx = hwSym("KillSfx@4",soundso); - HW3DS.pfnGetHW3DSTitle = hwSym("GetHW3DSTitle@8",soundso); -#else - HW3DS.pfnStartup = hwSym("Startup",soundso); - HW3DS.pfnShutdown = hwSym("Shutdown",soundso); - HW3DS.pfnAddSfx = hwSym("AddSfx",soundso); - HW3DS.pfnAddSource = hwSym("AddSource",soundso); - HW3DS.pfnStartSource = hwSym("StartSource",soundso); - HW3DS.pfnStopSource = hwSym("StopSource",soundso); - HW3DS.pfnGetHW3DSVersion = hwSym("GetHW3DSVersion",soundso); - HW3DS.pfnBeginFrameUpdate = hwSym("BeginFrameUpdate",soundso); - HW3DS.pfnEndFrameUpdate = hwSym("EndFrameUpdate",soundso); - HW3DS.pfnIsPlaying = hwSym("IsPlaying",soundso); - HW3DS.pfnUpdateListener = hwSym("UpdateListener",soundso); - HW3DS.pfnUpdateSourceParms = hwSym("UpdateSourceParms",soundso); - HW3DS.pfnSetCone = hwSym("SetCone",soundso); - HW3DS.pfnSetGlobalSfxVolume = hwSym("SetGlobalSfxVolume",soundso); - HW3DS.pfnUpdate3DSource = hwSym("Update3DSource",soundso); - HW3DS.pfnReloadSource = hwSym("ReloadSource",soundso); - HW3DS.pfnKillSource = hwSym("KillSource",soundso); - HW3DS.pfnKillSfx = hwSym("KillSfx",soundso); - HW3DS.pfnGetHW3DSTitle = hwSym("GetHW3DSTitle",soundso); -#endif - -// if (HW3DS.pfnUpdateListener2 && HW3DS.pfnUpdateListener2 != soundso) - return true; -// else -// return false; -} -#endif - void I_ShutdownSound(void) { if (sound_disabled || !sound_started) @@ -1144,15 +1061,6 @@ void I_ShutdownSound(void) CONS_Printf("I_ShutdownSound: "); -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - { - HW3S_Shutdown(); - hwClose(soundso); - return; - } -#endif - if (midi_disabled && digital_disabled) SDL_CloseAudio(); CONS_Printf("%s", M_GetText("shut down\n")); @@ -1169,9 +1077,6 @@ void I_UpdateSound(void) void I_StartupSound(void) { -#ifdef HW3SOUND - const char *sdrv_name = NULL; -#endif #ifndef HAVE_MIXER #ifndef NO_MIDI midi_disabled = @@ -1228,75 +1133,6 @@ void I_StartupSound(void) if (sound_disabled) return; -#ifdef HW3SOUND -#ifdef STATIC3DS - if (M_CheckParm("-3dsound") || M_CheckParm("-ds3d")) - { - hws_mode = HWS_OPENAL; - } -#elif defined (_WIN32) - if (M_CheckParm("-ds3d")) - { - hws_mode = HWS_DS3D; - sdrv_name = "s_ds3d.dll"; - } - else if (M_CheckParm("-fmod3d")) - { - hws_mode = HWS_FMOD3D; - sdrv_name = "s_fmod.dll"; - } - else if (M_CheckParm("-openal")) - { - hws_mode = HWS_OPENAL; - sdrv_name = "s_openal.dll"; - } -#else - if (M_CheckParm("-fmod3d")) - { - hws_mode = HWS_FMOD3D; - sdrv_name = "./s_fmod.so"; - } - else if (M_CheckParm("-openal")) - { - hws_mode = HWS_OPENAL; - sdrv_name = "./s_openal.so"; - } -#endif - else if (M_CheckParm("-sounddriver") && M_IsNextParm()) - { - hws_mode = HWS_OTHER; - sdrv_name = M_GetNextParm(); - } - if (hws_mode != HWS_DEFAULT_MODE) - { - if (Init3DSDriver(sdrv_name)) - { - snddev_t snddev; - - //sound_disabled = true; - //I_AddExitFunc(I_ShutdownSound); - snddev.bps = 16; - snddev.sample_rate = audio.freq; - snddev.numsfxs = NUMSFX; -#if defined (_WIN32) - snddev.cooplevel = 0x00000002; - snddev.hWnd = vid.WndParent; -#endif - if (HW3S_Init(I_Error, &snddev)) - { - audio.userdata = NULL; - CONS_Printf("%s", M_GetText(" Using 3D sound driver\n")); - return; - } - CONS_Printf("%s", M_GetText(" Failed loading 3D sound driver\n")); - // Falls back to default sound system - HW3S_Shutdown(); - hwClose(soundso); - } - CONS_Printf("%s", M_GetText(" Failed loading 3D sound driver\n")); - hws_mode = HWS_DEFAULT_MODE; - } -#endif if (!musicStarted && SDL_OpenAudio(&audio, &audio) < 0) { CONS_Printf("%s", M_GetText(" couldn't open audio with desired format\n"));