mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
- SW sound WIP
* removed old sound loading code, which was the last bit to use cacheAllocateBlock which is also gone now. * cleanup of player sound code. All game side tracking of the sound resources has been removed. does not compile yet.
This commit is contained in:
parent
650b53454d
commit
a7075bc1b0
37 changed files with 172 additions and 415 deletions
|
@ -709,7 +709,6 @@ set (PCH_SOURCES
|
|||
build/src/a-c.cpp
|
||||
build/src/animvpx.cpp
|
||||
build/src/baselayer.cpp
|
||||
build/src/cache1d.cpp
|
||||
build/src/clip.cpp
|
||||
build/src/colmatch.cpp
|
||||
build/src/common.cpp
|
||||
|
|
|
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#pragma once
|
||||
#include "baselayer.h"
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "pragmas.h"
|
||||
#include "misc.h"
|
||||
|
|
|
@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "baselayer.h"
|
||||
#include "common_game.h"
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "sndcards.h"
|
||||
#include "hash.h"
|
||||
#include "renderlayer.h"
|
||||
|
|
|
@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "compat.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "common_game.h"
|
||||
|
||||
#include "misc.h"
|
||||
|
|
|
@ -27,7 +27,7 @@ static_assert('\xff' == 255, "Char must be unsigned!");
|
|||
#include "palette.h"
|
||||
#include "pragmas.h"
|
||||
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "textures.h"
|
||||
#include "c_cvars.h"
|
||||
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
|
||||
// Ken Silverman's official web site: "http://www.advsys.net/ken"
|
||||
// See the included license file "BUILDLIC.TXT" for license info.
|
||||
//
|
||||
// This file has been modified from Ken Silverman's original release
|
||||
// by Jonathon Fowler (jf@jonof.id.au)
|
||||
// by the EDuke32 team (development@voidpoint.com)
|
||||
|
||||
#ifndef cache1d_h_
|
||||
#define cache1d_h_
|
||||
|
||||
void cacheAllocateBlock(intptr_t *newhandle, int32_t newbytes, uint8_t *newlockptr);
|
||||
|
||||
#endif // cache1d_h_
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
#ifndef EDUKE32_COMMON_H_
|
||||
#define EDUKE32_COMMON_H_
|
||||
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "pragmas.h" // klabs
|
||||
#include "scriptfile.h"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "compat.h"
|
||||
#include "baselayer.h"
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "matrix.h"
|
||||
#include "../../glbackend/glbackend.h"
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "a.h"
|
||||
#include "polymost.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "inputstate.h"
|
||||
#include "d_event.h"
|
||||
#include "../../glbackend/glbackend.h"
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
|
||||
// Ken Silverman's official web site: "http://www.advsys.net/ken"
|
||||
// See the included license file "BUILDLIC.TXT" for license info.
|
||||
//
|
||||
// This file has been modified from Ken Silverman's original release
|
||||
// by Jonathon Fowler (jf@jonof.id.au)
|
||||
// by the EDuke32 team (development@voidpoint.com)
|
||||
|
||||
#include <stdint.h>
|
||||
#include "tarray.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
// Only the sound code still uses this - but it never frees the data.
|
||||
// So we may just toss out the cache and do regular allocations.
|
||||
// The TArray is merely for taking down the data before shutdown.
|
||||
static TArray<TArray<uint8_t>> pseudocache;
|
||||
|
||||
void cacheAllocateBlock(intptr_t *newhandle, int32_t newbytes, uint8_t *)
|
||||
{
|
||||
pseudocache.Reserve(1);
|
||||
auto& buffer = pseudocache.Last();
|
||||
buffer.Resize(newbytes);
|
||||
*newhandle = reinterpret_cast<intptr_t>(buffer.Data());
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
#include "compat.h"
|
||||
#include "build.h"
|
||||
#include "scriptfile.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "baselayer.h"
|
||||
|
||||
#include "common.h"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "engine_priv.h"
|
||||
#include "baselayer.h"
|
||||
#include "scriptfile.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "mdsprite.h" // md3model_t
|
||||
#include "colmatch.h"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "a.h"
|
||||
#include "baselayer.h"
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "colmatch.h"
|
||||
#include "common.h"
|
||||
#include "compat.h"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "hightile.h"
|
||||
#include "polymost.h"
|
||||
#include "mdsprite.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "palette.h"
|
||||
#include "textures.h"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "engine_priv.h"
|
||||
#include "baselayer.h"
|
||||
#include "colmatch.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "palette.h"
|
||||
#include "a.h"
|
||||
#include "superfasthash.h"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "a.h"
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "compat.h"
|
||||
#include "engine_priv.h"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "build.h"
|
||||
#include "baselayer.h"
|
||||
#include "engine_priv.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
|
||||
//
|
||||
// copytilepiece
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "hightile.h"
|
||||
#include "polymost.h"
|
||||
#include "mdsprite.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "palette.h"
|
||||
#include "../../glbackend/glbackend.h"
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include "v_text.h"
|
||||
#include "image.h"
|
||||
#include "utf8.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "m_png.h"
|
||||
#include "printf.h"
|
||||
#include "filesystem.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "openaudio.h"
|
||||
#include "gamecvars.h"
|
||||
|
||||
|
|
|
@ -216,6 +216,7 @@ enum // This cannot be remain as this, but for now it has to suffice.
|
|||
SOURCE_Actor, // Sound is coming from an actor.
|
||||
SOURCE_Ambient, // Sound is coming from a blood ambient definition.
|
||||
SOURCE_Unattached, // Sound is not attached to any particular emitter.
|
||||
SOURCE_Player, // SW player sound (player in SW is not connected to a sprite so needs to be special.)
|
||||
};
|
||||
|
||||
|
||||
|
@ -310,7 +311,7 @@ public:
|
|||
void RelinkSound(int sourcetype, const void* from, const void* to, const FVector3* optpos);
|
||||
void ChangeSoundVolume(int sourcetype, const void* source, int channel, double dvolume);
|
||||
void ChangeSoundPitch(int sourcetype, const void* source, int channel, double pitch, int sound_id = -1);
|
||||
bool IsSourcePlayingSomething(int sourcetype, const void* actor, int channel, int sound_id);
|
||||
bool IsSourcePlayingSomething(int sourcetype, const void* actor, int channel, int sound_id = -1);
|
||||
|
||||
// Stop and resume music, during game PAUSE.
|
||||
int GetSoundPlayingInfo(int sourcetype, const void* source, int sound_id);
|
||||
|
@ -372,7 +373,7 @@ public:
|
|||
}
|
||||
bool isValidSoundId(int id)
|
||||
{
|
||||
return id > 0 && id < (int)S_sfx.Size() && !S_sfx[id].bTentative;
|
||||
return id > 0 && id < (int)S_sfx.Size() && !S_sfx[id].bTentative && S_sfx[id].lumpnum != sfx_empty;
|
||||
}
|
||||
|
||||
template<class func> bool EnumerateChannels(func callback)
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "zstring.h"
|
||||
#include "textures.h"
|
||||
#include "image.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "baselayer.h"
|
||||
#include "palette.h"
|
||||
#include "m_crc32.h"
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "templates.h"
|
||||
#include "bitmap.h"
|
||||
#include "image.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "build.h"
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "a.h"
|
||||
#include "baselayer.h"
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "pragmas.h"
|
||||
#include "polymost.h"
|
||||
|
|
|
@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#define ONLY_USERDEFS
|
||||
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "compat.h"
|
||||
#include "startwin.game.h"
|
||||
#include "windows_inc.h"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "build.h"
|
||||
#include "baselayer.h"
|
||||
#include "osd.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "zstring.h"
|
||||
#include "winbits.h"
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "a.h"
|
||||
#include "baselayer.h"
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
#include "pragmas.h"
|
||||
|
|
|
@ -26,7 +26,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
|
||||
#include "ns.h"
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
|
||||
#include "keys.h"
|
||||
#include "mytypes.h"
|
||||
|
|
|
@ -28,7 +28,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
//#define MAIN
|
||||
//#define QUIET
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
|
||||
#include "keys.h"
|
||||
#include "names2.h"
|
||||
|
|
|
@ -28,7 +28,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
#define QUIET
|
||||
#include "build.h"
|
||||
#include "pragmas.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
|
||||
#include "keys.h"
|
||||
#include "names2.h"
|
||||
|
|
|
@ -44,7 +44,7 @@ Things required to make savegames work:
|
|||
#define QUIET
|
||||
#include "build.h"
|
||||
#include "baselayer.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "osd.h"
|
||||
#include "renderlayer.h"
|
||||
|
||||
|
@ -274,7 +274,6 @@ int krandcount;
|
|||
void BOT_DeleteAllBots(void);
|
||||
void BotPlayerInsert(PLAYERp pp);
|
||||
void SybexScreen(void);
|
||||
void DosScreen(void);
|
||||
void PlayTheme(void);
|
||||
void MenuLevel(void);
|
||||
void StatScreen(PLAYERp mpp);
|
||||
|
@ -634,14 +633,8 @@ void TerminateGame(void)
|
|||
|
||||
engineUnInit();
|
||||
|
||||
//Terminate3DSounds(); // Kill the sounds linked list
|
||||
UnInitSound();
|
||||
|
||||
timerUninit();
|
||||
|
||||
if (CleanExit)
|
||||
DosScreen();
|
||||
|
||||
Bexit(0);
|
||||
}
|
||||
|
||||
bool LoadLevel(const char *filename)
|
||||
|
@ -731,7 +724,6 @@ void MultiSharewareCheck(void)
|
|||
//uninitmultiplayers();
|
||||
//uninitkeys();
|
||||
engineUnInit();
|
||||
UnInitSound();
|
||||
timerUninit();
|
||||
Bexit(0);
|
||||
}
|
||||
|
@ -1318,7 +1310,6 @@ TerminateLevel(void)
|
|||
|
||||
StopSound();
|
||||
Terminate3DSounds(); // Kill the 3d sounds linked list
|
||||
//ClearSoundLocks();
|
||||
|
||||
// Clear all anims and any memory associated with them
|
||||
// Clear before killing sprites - save a little time
|
||||
|
@ -2795,15 +2786,6 @@ void RunLevel(void)
|
|||
ready2send = 0;
|
||||
}
|
||||
|
||||
void swexit(int exitval)
|
||||
{
|
||||
exit(exitval);
|
||||
}
|
||||
|
||||
void DosScreen(void)
|
||||
{
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char notshareware;
|
||||
|
@ -2813,20 +2795,7 @@ typedef struct
|
|||
const char *arg_descr;
|
||||
} CLI_ARG;
|
||||
|
||||
#if DEBUG
|
||||
CLI_ARG cli_dbg_arg[] =
|
||||
{
|
||||
{0, "/demosyncrecord", 13, "-demosyncrecord", "Demo sync record" },
|
||||
{0, "/demosynctest", 13, "-demosynctest", "Demo sync test" },
|
||||
{0, "/cam", 4, "-cam", "Camera test mode" },
|
||||
{0, "/debugactor", 11, "-debugactor", "No Actors" },
|
||||
{0, "/debuganim", 10, "-debuganim", "No Anims" },
|
||||
{0, "/debugso", 8, "-debugso", "No Sector Objects" },
|
||||
{0, "/debugsector", 12, "-debugsector", "No Sector Movement" },
|
||||
{0, "/debugpanel", 11, "-debugpanel", "No Panel" },
|
||||
{0, "/mono", 5, "-mono", "Mono" },
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
CLI_ARG cli_arg[] =
|
||||
|
|
|
@ -1204,9 +1204,6 @@ struct PLAYERstruct
|
|||
SWBOOL IsAI; // Is this and AI character?
|
||||
short fta,ftq; // First time active and first time quote, for talking in multiplayer games
|
||||
short NumFootPrints; // Number of foot prints left to lay down
|
||||
SWBOOL PlayerTalking; // Is player currently talking
|
||||
int TalkVocnum; // Number of sound that player is using
|
||||
int TalkVocHandle; // Handle of sound in sound queue, to access in Dose's code
|
||||
unsigned char WpnUziType; // Toggle between single or double uzi's if you own 2.
|
||||
unsigned char WpnShotgunType; // Shotgun has normal or fully automatic fire
|
||||
unsigned char WpnShotgunAuto; // 50-0 automatic shotgun rounds
|
||||
|
@ -2277,8 +2274,10 @@ extern void DoPaletteFlash(PLAYERp pp);
|
|||
extern unsigned char palette_data[256][3];
|
||||
extern SWBOOL NightVision;
|
||||
|
||||
int _PlayerSound(const char *file, int line, int num, int *x, int *y, int *z, Voc3D_Flags flags, PLAYERp pp);
|
||||
#define PlayerSound(num, x, y, z, flags, pp) _PlayerSound(__FILE__, __LINE__, (num), (x), (y), (z), (flags), (pp))
|
||||
int _PlayerSound(int num, PLAYERp pp);
|
||||
inline int PlayerSound(int num, int x, int y, int z, int flags, PLAYERp pp) { return _PlayerSound(num, pp); }
|
||||
void StopPlayerSound(PLAYERp pp);
|
||||
|
||||
|
||||
#define MAXSO (INT32_MAX)
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
//-------------------------------------------------------------------------
|
||||
|
||||
#include "compat.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "savegamehelp.h"
|
||||
|
||||
BEGIN_SW_NS
|
||||
|
|
|
@ -3648,7 +3648,6 @@ DoPlayerFall(PLAYERp pp)
|
|||
short i;
|
||||
int recoil_amt;
|
||||
int depth;
|
||||
static int handle=0;
|
||||
|
||||
// reset flag key for double jumps
|
||||
if (!TEST_SYNC_KEY(pp, SK_JUMP))
|
||||
|
@ -3680,7 +3679,6 @@ DoPlayerFall(PLAYERp pp)
|
|||
{
|
||||
PlayerSound(DIGI_FALLSCREAM, &pp->posx, &pp->posy, &pp->posz,
|
||||
v3df_dontpan|v3df_doppler|v3df_follow,pp);
|
||||
handle = pp->TalkVocHandle; // Save id for later
|
||||
}
|
||||
else if (pp->jump_speed > 1300)
|
||||
{
|
||||
|
@ -3730,15 +3728,6 @@ DoPlayerFall(PLAYERp pp)
|
|||
PlaySound(DIGI_HITGROUND, &pp->posx, &pp->posy, &pp->posz, v3df_follow|v3df_dontpan);
|
||||
}
|
||||
|
||||
if (FX_SoundValidAndActive(handle))
|
||||
{
|
||||
// My sound code will detect the sound has stopped and clean up
|
||||
// for you.
|
||||
FX_StopSound(handle);
|
||||
pp->PlayerTalking = FALSE;
|
||||
handle = 0;
|
||||
}
|
||||
|
||||
// i any kind of crawl key get rid of recoil
|
||||
if (DoPlayerTestCrawl(pp) || TEST_SYNC_KEY(pp, SK_CRAWL))
|
||||
{
|
||||
|
@ -5160,12 +5149,7 @@ DoPlayerStopDiveNoWarp(PLAYERp pp)
|
|||
|
||||
if (!NoMeters) SetRedrawScreen(pp);
|
||||
|
||||
if (FX_SoundValidAndActive(pp->TalkVocHandle))
|
||||
{
|
||||
FX_StopSound(pp->TalkVocHandle);
|
||||
pp->TalkVocHandle = 0;
|
||||
pp->PlayerTalking = FALSE;
|
||||
}
|
||||
StopPlayerSound(pp);
|
||||
|
||||
// stop diving no warp
|
||||
PlayerSound(DIGI_SURFACE,&pp->posx,&pp->posy,&pp->posz,v3df_dontpan|v3df_follow|v3df_doppler,pp);
|
||||
|
@ -5196,12 +5180,7 @@ DoPlayerStopDive(PLAYERp pp)
|
|||
|
||||
if (!NoMeters) SetRedrawScreen(pp);
|
||||
|
||||
if (FX_SoundValidAndActive(pp->TalkVocHandle))
|
||||
{
|
||||
FX_StopSound(pp->TalkVocHandle);
|
||||
pp->TalkVocHandle = 0;
|
||||
pp->PlayerTalking = FALSE;
|
||||
}
|
||||
StopPlayerSound(pp);
|
||||
|
||||
// stop diving with warp
|
||||
PlayerSound(DIGI_SURFACE,&pp->posx,&pp->posy,&pp->posz,v3df_dontpan|v3df_follow|v3df_doppler,pp);
|
||||
|
|
|
@ -27,7 +27,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
#include "ns.h"
|
||||
// scriplib.c
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
|
||||
#include "keys.h"
|
||||
#include "names2.h"
|
||||
|
|
|
@ -26,7 +26,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
#include "ns.h"
|
||||
#include "compat.h"
|
||||
#include "build.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
|
||||
#include "keys.h"
|
||||
|
||||
|
@ -52,16 +52,11 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
#include "config.h"
|
||||
#include "menu/menu.h"
|
||||
#include "z_music.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "sdlayer.h"
|
||||
#endif
|
||||
#include "sound/s_soundinternal.h"
|
||||
#include "filesystem/filesystem.h"
|
||||
|
||||
BEGIN_SW_NS
|
||||
|
||||
extern USERp User[MAXSPRITES];
|
||||
void DumpSounds(void);
|
||||
|
||||
// Parentally locked sounds list
|
||||
int PLocked_Sounds[] =
|
||||
{
|
||||
|
@ -72,6 +67,79 @@ int PLocked_Sounds[] =
|
|||
558,557
|
||||
};
|
||||
|
||||
//
|
||||
// Includes digi.h to build the table
|
||||
//
|
||||
|
||||
#define DIGI_TABLE
|
||||
VOC_INFO voc[] =
|
||||
{
|
||||
#include "digi.h"
|
||||
};
|
||||
|
||||
#undef DIGI_TABLE
|
||||
|
||||
//
|
||||
// Includes ambient.h to build the table of ambient sounds for game
|
||||
//
|
||||
|
||||
#define AMBIENT_TABLE
|
||||
AMB_INFO ambarray[] =
|
||||
{
|
||||
#include "ambient.h"
|
||||
};
|
||||
#undef AMBIENT_TABLE
|
||||
#define MAX_AMBIENT_SOUNDS 82
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void InitFX(void)
|
||||
{
|
||||
auto &S_sfx = soundEngine->GetSounds();
|
||||
S_sfx.Resize(countof(voc));
|
||||
for (auto& sfx : S_sfx) { sfx.Clear(); sfx.lumpnum = sfx_empty; }
|
||||
for (size_t i = 1; i < countof(voc); i++)
|
||||
{
|
||||
auto& entry = voc[i];
|
||||
auto lump = fileSystem.FindFile(entry.name);
|
||||
if (lump > 0)
|
||||
{
|
||||
auto& newsfx = S_sfx[i];
|
||||
newsfx.name = entry.name;
|
||||
newsfx.lumpnum = lump;
|
||||
newsfx.NearLimit = 6;
|
||||
newsfx.UserData.Resize(sizeof(void*));
|
||||
auto p = (VOC_INFOp *)newsfx.UserData.Data();
|
||||
*p = &entry; // store a link to the static data.
|
||||
}
|
||||
}
|
||||
soundEngine->HashSounds();
|
||||
for (auto& sfx : S_sfx)
|
||||
{
|
||||
soundEngine->CacheSound(&sfx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
extern USERp User[MAXSPRITES];
|
||||
void DumpSounds(void);
|
||||
|
||||
|
||||
|
||||
// Global vars used by ambient sounds to set spritenum of ambient sounds for later lookups in
|
||||
// the sprite array so FAFcansee can know the sound sprite's current sector location
|
||||
|
@ -100,30 +168,6 @@ int loopflag;
|
|||
|
||||
extern SWBOOL DemoMode;
|
||||
|
||||
//
|
||||
// Includes digi.h to build the table
|
||||
//
|
||||
|
||||
#define DIGI_TABLE
|
||||
VOC_INFO voc[] =
|
||||
{
|
||||
#include "digi.h"
|
||||
};
|
||||
|
||||
#undef DIGI_TABLE
|
||||
|
||||
//
|
||||
// Includes ambient.h to build the table of ambient sounds for game
|
||||
//
|
||||
|
||||
#define AMBIENT_TABLE
|
||||
AMB_INFO ambarray[] =
|
||||
{
|
||||
#include "ambient.h"
|
||||
};
|
||||
#undef AMBIENT_TABLE
|
||||
#define MAX_AMBIENT_SOUNDS 82
|
||||
|
||||
SWBOOL OpenSound(VOC_INFOp vp, FileReader &handle, int *length);
|
||||
int ReadSound(FileReader & handle, VOC_INFOp vp, int length);
|
||||
|
||||
|
@ -134,56 +178,6 @@ VOC3D_INFOp Insert3DSound(void);
|
|||
// Routine called when a sound is finished playing
|
||||
//
|
||||
|
||||
void
|
||||
SoundCallBack(intptr_t num)
|
||||
{
|
||||
VOC_INFOp vp;
|
||||
|
||||
if ((int) num == MUSIC_ID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// RTS sounds are negative
|
||||
if ((int)num < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vp = &voc[num];
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
void
|
||||
ClearSoundLocks(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
UnInitSound(void)
|
||||
{
|
||||
SoundShutdown();
|
||||
Mus_Stop();
|
||||
}
|
||||
|
||||
void
|
||||
InitFX(void)
|
||||
{
|
||||
VOC_INFOp vp;
|
||||
short i;
|
||||
|
||||
// Select which cards to use
|
||||
SoundStartup();
|
||||
|
||||
for (vp = voc; vp < &voc[SIZ(voc)]; vp++)
|
||||
{
|
||||
vp->playing = 0;
|
||||
}
|
||||
|
||||
// Set up our fx callback so we can display the sounds that are playing
|
||||
FX_SetCallBack(SoundCallBack);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
|
@ -276,96 +270,6 @@ short SoundAngle(int x, int y)
|
|||
return delta_angle >> 4;
|
||||
}
|
||||
|
||||
int _PlayerSound(const char *file, int line, int num, int *x, int *y, int *z, Voc3D_Flags flags, PLAYERp pp)
|
||||
{
|
||||
int handle;
|
||||
VOC_INFOp vp;
|
||||
|
||||
if (Prediction)
|
||||
return 0;
|
||||
|
||||
if (pp < Player || pp >= Player + MAX_SW_PLAYERS)
|
||||
{
|
||||
TerminateGame();
|
||||
printf("Player Sound invalid player: file %s, line %d\n",file,line);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
PRODUCTION_ASSERT(pp >= Player && pp < Player+MAX_SW_PLAYERS);
|
||||
PRODUCTION_ASSERT(num >= 0 && num < DIGI_MAX);
|
||||
|
||||
if (TEST(pp->Flags, PF_DEAD)) return 0; // You're dead, no talking!
|
||||
|
||||
// If this is a player voice and he's already yacking, forget it.
|
||||
vp = &voc[num];
|
||||
if (vp == NULL)
|
||||
{
|
||||
TerminateGame();
|
||||
printf("vp == NULL in PlayerSound, num = %d\n",num);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Not a player voice, bail.
|
||||
if (vp->priority != PRI_PLAYERVOICE && vp->priority != PRI_PLAYERDEATH)
|
||||
return 0;
|
||||
|
||||
// He wasn't talking, but he will be now.
|
||||
if (!pp->PlayerTalking)
|
||||
{
|
||||
pp->PlayerTalking = TRUE;
|
||||
pp->TalkVocnum = num; // Set the voc number
|
||||
pp->TalkVocHandle = PlaySound(num, x, y, z, flags); // Play the sound
|
||||
if (pp->TalkVocHandle < 0)
|
||||
{
|
||||
pp->PlayerTalking = FALSE;
|
||||
pp->TalkVocnum = -1;
|
||||
pp->TalkVocHandle = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LockSound(int num)
|
||||
{
|
||||
}
|
||||
|
||||
SWBOOL CacheSound(int num, int type)
|
||||
{
|
||||
VOC_INFOp vp = &voc[num];
|
||||
|
||||
PRODUCTION_ASSERT(num >= 0 && num < DIGI_MAX);
|
||||
|
||||
// if no data we need to cache it in
|
||||
if (!vp->data)
|
||||
{
|
||||
FileReader handle;
|
||||
int length;
|
||||
|
||||
if (!OpenSound(vp, handle, &length))
|
||||
{
|
||||
sprintf(ds,"Could not open sound %s, num %d, priority %d\n",vp->name,num,vp->priority);
|
||||
OSD_Printf("%s", ds);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (vp != NULL)
|
||||
{
|
||||
vp->lock = CACHE_UNLOCK_MAX;
|
||||
|
||||
cacheAllocateBlock((intptr_t*)&vp->data, length, &vp->lock);
|
||||
|
||||
///////
|
||||
|
||||
ASSERT(vp->data);
|
||||
ReadSound(handle, vp, length);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Play a sound
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -489,7 +393,6 @@ int PlaySound(int num, int *x, int *y, int *z, Voc3D_Flags flags)
|
|||
tx=sp->x;
|
||||
ty=sp->y;
|
||||
tz=sp->z;
|
||||
//CON_Message("Using sp to set tx=%ld,ty=%ld,tz=%ld",tx,ty,tz);
|
||||
}
|
||||
|
||||
// Calculate sound angle
|
||||
|
@ -507,9 +410,6 @@ int PlaySound(int num, int *x, int *y, int *z, Voc3D_Flags flags)
|
|||
v3p->doplr_delta = sound_dist; // Save of distance for doppler
|
||||
// effect
|
||||
|
||||
// //DSPRINTF(ds,"sound dist = %d\n",sound_dist);
|
||||
// MONO_PRINT(ds);
|
||||
|
||||
// Can the ambient sound see the player? If not, tone it down some.
|
||||
if ((vp->voc_flags & vf_loop) && Use_SoundSpriteNum && SoundSpriteNum >= 0)
|
||||
{
|
||||
|
@ -534,6 +434,7 @@ int PlaySound(int num, int *x, int *y, int *z, Voc3D_Flags flags)
|
|||
priority = v3p->priority;
|
||||
}
|
||||
|
||||
/*
|
||||
if (!CacheSound(num, CACHE_SOUND_PLAY))
|
||||
{
|
||||
v3p->flags = v3df_kill;
|
||||
|
@ -541,9 +442,7 @@ int PlaySound(int num, int *x, int *y, int *z, Voc3D_Flags flags)
|
|||
v3p->dist = 0;
|
||||
v3p->deleted = TRUE; // Sound init failed, remove it!
|
||||
return -1;
|
||||
}
|
||||
|
||||
LockSound(num);
|
||||
}*/
|
||||
|
||||
if (sound_dist < 5)
|
||||
angle = 0;
|
||||
|
@ -626,65 +525,6 @@ void PlaySoundRTS(int rts_num)
|
|||
voice = FX_Play3D(rtsptr, RTS_SoundLength(rts_num - 1), FX_ONESHOT, 0, 0, 0, 255, 1.f, -rts_num); // [JM] Float volume here too I bet. !CHECKME!
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
|
||||
SWBOOL
|
||||
OpenSound(VOC_INFOp vp, FileReader &handle, int *length)
|
||||
{
|
||||
handle = fileSystem.OpenFileReader(vp->name, 0);
|
||||
|
||||
if (!handle.isOpen())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*length = handle.GetLength();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ReadSound(FileReader &handle, VOC_INFOp vp, int length)
|
||||
{
|
||||
if (handle.Read(vp->data, length) != length)
|
||||
{
|
||||
TerminateGame();
|
||||
printf("Error reading file '%s'.\n", vp->name);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
vp->datalen = length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SoundStartup(void)
|
||||
{
|
||||
void *initdata = 0;
|
||||
|
||||
|
||||
#ifdef MIXERTYPEWIN
|
||||
initdata = (void *) win_gethwnd();
|
||||
#endif
|
||||
|
||||
//snd_enabled = TRUE;
|
||||
|
||||
|
||||
int status = FX_Init(snd_numvoices, snd_numchannels, snd_mixrate, initdata);
|
||||
if (status != FX_Ok)
|
||||
{
|
||||
buildprintf("Sound error: %s\n", FX_ErrorString(status));
|
||||
return;
|
||||
}
|
||||
|
||||
FxInitialized = TRUE;
|
||||
snd_fxvolume.Callback();
|
||||
snd_reversestereo.Callback();
|
||||
|
||||
FX_SetCallBack(SoundCallBack);
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
=
|
||||
|
@ -693,19 +533,6 @@ SoundStartup(void)
|
|||
===================
|
||||
*/
|
||||
|
||||
void
|
||||
SoundShutdown(void)
|
||||
{
|
||||
if (!FxInitialized)
|
||||
return;
|
||||
|
||||
int status = FX_Shutdown();
|
||||
if (status != FX_Ok)
|
||||
{
|
||||
buildprintf("Sound error: %s\n", FX_ErrorString(status));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void COVER_SetReverb(int amt)
|
||||
{
|
||||
|
@ -905,23 +732,6 @@ Delete3DSounds(void)
|
|||
{
|
||||
printf("Delete3DSounds(): NULL vp->vp\n");
|
||||
}
|
||||
else // JBF: added null check
|
||||
if (vp->vp->priority == PRI_PLAYERVOICE || vp->vp->priority == PRI_PLAYERDEATH)
|
||||
{
|
||||
int16_t pnum;
|
||||
|
||||
TRAVERSE_CONNECT(pnum)
|
||||
{
|
||||
pp = &Player[pnum];
|
||||
|
||||
if (vp->num == pp->TalkVocnum)
|
||||
{
|
||||
pp->PlayerTalking = FALSE;
|
||||
pp->TalkVocnum = -1;
|
||||
pp->TalkVocHandle = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dp = vp; // Point to sound to be deleted
|
||||
if (vp->prev)
|
||||
|
@ -1008,10 +818,6 @@ DoTimedSound(VOC3D_INFOp p)
|
|||
}
|
||||
|
||||
p->tics = 0;
|
||||
//while (p->tics >= p->maxtics) // Really stupid thing to do!
|
||||
// {
|
||||
// p->tics -= p->maxtics;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1355,7 +1161,6 @@ Terminate3DSounds(void)
|
|||
}
|
||||
|
||||
Delete3DSounds(); // Now delete all remaining sounds
|
||||
ClearSoundLocks();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1483,13 +1288,58 @@ int PlayerYellVocs[] =
|
|||
DIGI_PLAYERYELL3
|
||||
};
|
||||
|
||||
/*
|
||||
============================================================================
|
||||
=
|
||||
= PLays music
|
||||
=
|
||||
============================================================================
|
||||
*/
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
int _PlayerSound(int num, PLAYERp pp)
|
||||
{
|
||||
int handle;
|
||||
VOC_INFOp vp;
|
||||
|
||||
if (Prediction)
|
||||
return 0;
|
||||
|
||||
if (pp < Player || pp >= Player + MAX_SW_PLAYERS)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (num < 0 || num >= DIGI_MAX || !soundEngine->isValidSoundId(num))
|
||||
return 0;
|
||||
|
||||
if (TEST(pp->Flags, PF_DEAD)) return 0; // You're dead, no talking!
|
||||
|
||||
// If this is a player voice and he's already yacking, forget it.
|
||||
vp = &voc[num];
|
||||
|
||||
// Not a player voice, bail.
|
||||
if (vp->priority != PRI_PLAYERVOICE && vp->priority != PRI_PLAYERDEATH)
|
||||
return 0;
|
||||
|
||||
// He wasn't talking, but he will be now.
|
||||
if (!soundEngine->IsSourcePlayingSomething(SOURCE_Player, pp, CHAN_VOICE))
|
||||
{
|
||||
soundEngine->StartSound(SOURCE_Player, pp, nullptr, CHAN_VOICE, 0, num, 1.f, ATTN_NORM);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void StopPlayerSound(PLAYERp pp)
|
||||
{
|
||||
soundEngine->StopSound(SOURCE_Player, pp, CHAN_VOICE);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PLays music
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
extern short Level;
|
||||
CVAR(Bool, sw_nothememidi, false, CVAR_ARCHIVE)
|
||||
|
|
|
@ -143,7 +143,7 @@ struct VOCstruct
|
|||
int16_t voc_num; // Backward reference to parent sound
|
||||
int voc_distance; // Sound's distance effectiveness
|
||||
Voc_Flags voc_flags; // Various allowable flag settings for voc
|
||||
uint8_t lock; // locking byte for caching
|
||||
uint16_t lock; // locking byte for caching
|
||||
uint8_t playing; // number of this type of sound currently playing
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue